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
2010-06-10 07:24
TWW

Registered: Jul 2009
Posts: 545
Let me rephrase:

I am currently working on a IO-Driver which automatically detects if it's a mouse or a joystick (Or even two mice or joysticks or combination mouse & joystick) and at the same time handles the Keyboard in a 'correct' manner. But I am limited to working with emus and hence the nag...


IF a routine looks as follows:
(DDR's set to default)

:IRQInit

irq:

lda $d419  // Read PotX
sta $0400

lda $d41a  // Read PotY
sta $0401

pla
tax
pla
tay
pla
rti



In VICE I get readings regardless of which mouse port i "plug" the c1531 mouse into while on CCS64 it will only react if I "plug" the mouse into Port #1 (which is the way it should be if I understand the documentation correctly).

However the mouse emulation on CCS64 messes up the bits (ASL them) for some strage reason (as mentioned in another post)..

Conclution: Mouse emulation is flawed on both emulators.

IMO: The POT input should be flip-flopped between port A or Port B depending on the 2 MSBs of $dc00 (#$40 or #$80). And Mouse buttons should be read from Bit #5 & 1 of the corresponding port.

Are there someone who has any experience regarding this or perhaps the chance to test this on a real C64 ad a C1531 mouse (I will happily provide some "test-software" if you need it)...
2010-06-10 07:28
JackAsser

Registered: Jun 2002
Posts: 2014
I came to the same conclusion for my mouse driver in Eye of the Beholder. More over, VICE only send the mouse buttons to port 1, but port values to both iirc. Or something like that... :) It was a while ago I coded it so my memory isn't exactly fresh.
2010-06-10 08:00
zyga
Account closed

Registered: Mar 2009
Posts: 6
Long time ago, I've found strange behavior in 2 versions of Lemmings (crack) on real machine (C128DCR).

While this game supports mouse1531 in proportional mode and cursor moves smoothly, mouse buttons doesn't have any effect !
Instead of it, joystick button in opposite port works well !

But it seems little uncomfortable to move cursor by mouse, and click by joystick :) Of course joystick emulation mode was working as expected.

I don't know if this is crack "feature", my machine failure (although AmicaPaint an Geos works fine), or bug in game itself.
2010-06-10 08:40
enthusi

Registered: May 2004
Posts: 677
I noticed the x/y and button issue between port 1/2 in vice.
Confuses people in ManiacMansion Gold sometimes.
I can run a test-prg on real thing with 1351 if needed.
Joy+mouse in MM was a mess. In the end I decided to add the 'mouse toggle' key (for numerous reasons).

2010-06-10 09:00
Nafcom

Registered: Apr 2002
Posts: 588
Quote: Long time ago, I've found strange behavior in 2 versions of Lemmings (crack) on real machine (C128DCR).

While this game supports mouse1531 in proportional mode and cursor moves smoothly, mouse buttons doesn't have any effect !
Instead of it, joystick button in opposite port works well !

But it seems little uncomfortable to move cursor by mouse, and click by joystick :) Of course joystick emulation mode was working as expected.

I don't know if this is crack "feature", my machine failure (although AmicaPaint an Geos works fine), or bug in game itself.


I own the original version of Lemmings, in fact the buttons of the Commmodore 1531 mouse do work, (all port 1 only).
And I have tried it with different 1531 mice clones but no chance, there the movements do not work
(I have tried a CMD SmartMouse and a Scantronik mouse). So it only works wth the originals even though claimed to be 100% compatible clones.

Tried on different C64s, too.
2010-06-10 09:09
zyga
Account closed

Registered: Mar 2009
Posts: 6
I have had original 1531 (original Commodore box with Geos driver and book), but Lemmings was not original.

Sadly, I do not have this C128DCR nor 1531 anymore...
2010-06-11 11:28
TWW

Registered: Jul 2009
Posts: 545
Quote: I noticed the x/y and button issue between port 1/2 in vice.
Confuses people in ManiacMansion Gold sometimes.
I can run a test-prg on real thing with 1351 if needed.
Joy+mouse in MM was a mess. In the end I decided to add the 'mouse toggle' key (for numerous reasons).



Alright. I'll send you a .prg file and I am very curious what you find out

aspect of my code might be screwed too so I hope we can come up with a full-good solution which works on the real thing the nag the emu-people untill they get it right :)

brgds!
2010-06-11 18:11
rattus
Account closed

Registered: Oct 2002
Posts: 14
Not really related, but Interpaint version with support for amiga mouse works like a charm with amiga mouse... Everyone has 1 amiga mouse stored somewhere, so... :)
2010-06-11 19:52
TWW

Registered: Jul 2009
Posts: 545
Update:

Tested under hoxs64 emu but couldn't figgure out how to enable c1351 mouse emulation.....
2010-06-12 07:39
enthusi

Registered: May 2004
Posts: 677
TWW, thx - will test today and post here. cool
 
... 3 posts hidden. Click here to view all posts....
 
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
Chesser/Blazon
Paladin/G★P
The Human Co../Maste..
iAN CooG/HVSC
Alakran_64
rambo/Therapy/ Resou..
Sokrates
kbs/Pht/Lxt
Mihai
X-Raffi/X-Rated
t0m3000/hf^boom!^ibx
Guests online: 99
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 Diskmag Editors
1 Magic  (9.8)
2 hedning  (9.6)
3 Jazzcat  (9.5)
4 Elwix  (9.1)
5 Remix  (9.1)

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