Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Reading C1531 Mouse from both ports
2010-06-08 12:18
TWW

Registered: Jul 2009
Posts: 545
Reading C1531 Mouse from both ports

In the C64 & C128, the SID POT lines are connected to both joystick ports. A 4066 analog switch is used to switch the POT lines between the two ports based on one of the keyboard scan lines. This means that the normal keyscan interrupt temporarily affects the values returned in the POT registers. Therefore, in order to perform reliable conversions, the POT lines must be connected to the mouse for a period >1.6 millisecond before the value in the POT register is valid.


I tried reading the POTs as follows:

lda #$80 // select Joyport #2
sta $dc00

waste 512 cycles

lda $d419
-doshit
lda $d41a
-doshit

lda #$40 // select Joyport #1
sta $dc00

waste 512 cycles

lda $d419
-doshit
lda $d41a
-doshit

rts


From the referance manual:

DC00 56320 Data Port A (Keyboard, Joystick, Paddles, Light-Pen)
7-0 Write Keyboard Column Values for Keyboard Scan
7-6 Read Paddles on Port A / B (01 = Port A, 10 = Port B)
4 Joystick A Fire Button: 1 = Fire
3-2 Paddle Fire Buttons
3-0 Joystick A Direction (0-15)


On both vice & ccs64 this gives funny readings. Have I gotten this all wrong or is it simply not emulated good enough?

-TWW
 
... 10 posts hidden. Click here to view all posts....
 
2010-06-12 11:05
enthusi

Registered: May 2004
Posts: 677
TWW,
c1351 in port2:
CARRY becomes set
ACC becomes %11111111
movement caused 'change' in $fe,$ff
both buttons have no effect

port1:
CARRY clear
ACC %00111111
movements show in $fc (green?!),$fd

left button: Y-REg = %10000000
right button: Y-REg = %01000000

PADDLES:
one plug, 2 paddles
@port2: change in $fe,$ff
button - nothing
Same for both paddels

@port1:
change in $fc,$fd

button changes Y to %1000000
for both paddles!

ACC and CARRY same as for mouse depending on port-connection.

Hope, this helps :)
Would be nicer to have an actual pointer in your test-code as well.
And why is the irq that unstable?
No SEI?
RESTORE changes $fb at least...

Cheers,
enthusi

2010-06-12 11:39
TWW

Registered: Jul 2009
Posts: 545
Quote: TWW,
c1351 in port2:
CARRY becomes set
ACC becomes %11111111
movement caused 'change' in $fe,$ff
both buttons have no effect

port1:
CARRY clear
ACC %00111111
movements show in $fc (green?!),$fd

left button: Y-REg = %10000000
right button: Y-REg = %01000000

PADDLES:
one plug, 2 paddles
@port2: change in $fe,$ff
button - nothing
Same for both paddels

@port1:
change in $fc,$fd

button changes Y to %1000000
for both paddles!

ACC and CARRY same as for mouse depending on port-connection.

Hope, this helps :)
Would be nicer to have an actual pointer in your test-code as well.
And why is the irq that unstable?
No SEI?
RESTORE changes $fb at least...

Cheers,
enthusi



Interesting...

The change you are experiencing on $fc, fd, fe & ff is the X & Y change in signed byte from the 2 ports (Meaning bit #7 = 1 means negative direcition change and 0 means positive direction change(for the mice)). AFAICT this is then working as it should do. I'll include a "pointer" to check this properly and make you happpy at the same time aswell ;]


The green you get is a confirmed detection of mouse in Port #1 (However I have not made that for port #2 yet so i'll include that in next driver ^^) However it is strange that the Carry isn't set in this case but then again I need to re-evaluate my code here a little bit...

LMB/RMB from mouse-port #2 should be shown in the 2 MSB of the Accumulator so I need to re-think that one aswell...

plan:

Recode known bugs and map up $dc00 while reading mousebuttons from port #2 to figgure out what is going on there. Also I'll add more green depending on detection or not :) and ofcourse the pointer (I'll set up different collours aswell depending on Mouse port #1 or 2^^)

If we can make this SW work properly I'll upload it here as a "test-program" which emu-ppl and other with real HW can use for testing purposes AND hopefully it can also serve as a standard IO driver for those who don't want to use the KERNA/EL.

Ignore IRQ/NMI stuff as this isn't set up to do nothing except call the routine each frame and display data.

Thanx for your prompt response and Hopefully I'll have something new to try during the weekend.

cheers TWW/CTR
2010-06-12 21:58
TWW

Registered: Jul 2009
Posts: 545
Alright A new version is ready. I have uploaded it here on CSDB: C1351 Mouse Driver / Test Software

Eagerly awaiting test results C",)

TWW/CTR
Previous - 1 | 2 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
celticdesign/G★P/M..
aNdy/AL/Cosine
Wiklund/Fairlight
sln.pixelrat
rexbeng
rambo/Therapy/ Resou..
kbs/Pht/Lxt
Guests online: 152
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Logo Graphicians
1 t0m3000  (10)
2 Sander  (9.8)
3 Mermaid  (9.5)
4 Facet  (9.4)
5 Shine  (9.4)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.052 sec.