tomaitheous
09-11-2011, 02:07 AM
After toying with emulation for a while, I finally got a real PCE mouse to test out. Protocol as follows:
; Mouse:
;
; $01 -> port, read X direction
;
; $00 -> port, read buttons
;
; $01 -> port, read X speed
;
; $00 -> port, read buttons
;
; $01 -> port, read Y direction
;
; $00 -> port, read buttons
;
; $01 -> port, read Y speed
;
; $00 -> port, read buttons
;
; Direction: Bit 8 indicates direction
;
; X: set value move right, clear value move left
;
; Y: set value move down, clear value move up
;
; Speed: Values are 4bit signed
It is read in 4bit segments like the gamepad. 8 reads of nybbles as describe above. This is done in a single instance, not over multiple frames. I snag some mouse code from an official game and uses a small delay after resetting the TAP (mouse read on port 0 of tap):
lda #$24
.loop1
dec a
bne .loop1
No delay is needed for reading each nybble or byte. Only the initial start.
The mouse only has four buttons, but the extra/duplicate button reads in the above sample are for clocking the mouse (I assume. High to low or low to high edge logic/trigger). Pretty straight forward/easy.
Automatic mouse detect should be easy. Since the code would read the gamepad multiple times, the directional values would be duplicated on a gamepad VS a mouse. And on a 6button pad, the signature is unique and different as well (one read has all four directional buttons pressed, the other directional read will not). So you can distinguish between a 2button, 6button and mouse. The cool thing is, you can use the mouse with the 5 port TAP. Imagine a homebrew game with 5 player mouse support! :D
; Mouse:
;
; $01 -> port, read X direction
;
; $00 -> port, read buttons
;
; $01 -> port, read X speed
;
; $00 -> port, read buttons
;
; $01 -> port, read Y direction
;
; $00 -> port, read buttons
;
; $01 -> port, read Y speed
;
; $00 -> port, read buttons
;
; Direction: Bit 8 indicates direction
;
; X: set value move right, clear value move left
;
; Y: set value move down, clear value move up
;
; Speed: Values are 4bit signed
It is read in 4bit segments like the gamepad. 8 reads of nybbles as describe above. This is done in a single instance, not over multiple frames. I snag some mouse code from an official game and uses a small delay after resetting the TAP (mouse read on port 0 of tap):
lda #$24
.loop1
dec a
bne .loop1
No delay is needed for reading each nybble or byte. Only the initial start.
The mouse only has four buttons, but the extra/duplicate button reads in the above sample are for clocking the mouse (I assume. High to low or low to high edge logic/trigger). Pretty straight forward/easy.
Automatic mouse detect should be easy. Since the code would read the gamepad multiple times, the directional values would be duplicated on a gamepad VS a mouse. And on a 6button pad, the signature is unique and different as well (one read has all four directional buttons pressed, the other directional read will not). So you can distinguish between a 2button, 6button and mouse. The cool thing is, you can use the mouse with the 5 port TAP. Imagine a homebrew game with 5 player mouse support! :D