MouseInit:move.w%00111100,pad_data_a; init controller 1 datamove.w%00111100,pad_data_b; init controller 2 datamove.w%00111100,pad_ctrl_a; init controller 1move.w%00111100,pad_ctrl_b; init controller 2rts; *************************************************************; Read the Mouse; a0 controller port address; a1 address to mouse strobe table; a2 address to mouse header table; d0 loop counter; d1 mouse data; d2 mouse header data; d3 scatch ; *************************************************************ReadMouseA:leapad_data_a,a0; controller 1 dataleaMouseStrobe,a1; strobe dataleaMouseHeader,a2; header to make sure mouse in plugged inmove.b#9,d0; loop 9 times, the number of strobes required to get all the datamove.w#0,d1; mouse data goes here clear@ReadMouseLoop:move.b(a1)+,d3; move mouse strobe into scratchmove.bd3,a0; strobe the controller portmovea0,d1; store mouse datacmp.b#7,d0; has the first 3 stobes completed already?blt.s@MouseHeaderDone; if this has skip the checksmove.b(a2),d2; move the header into d2andi.b%00001111,d1; clear high bitscmp.bd2,d1; compare header with mouse databne@MouseLoopExit; if they don't match, something has gone wrong bail outmove.b#0x0,d1; the header info isn't useful to us so clear it's bits@MouseHeaderDone:cmp.b#6,d0; are we on the 4th strobe?bne.s@MouseCheckForOverflowDone; if not skip the check for overflowbtst.l#$02,d1; if the bit is set an x overflow has occurred and something is wrongbeq@MouseLoopExit; so bail outbtst.l#$03,d1; if the bit is set an y overflow has occurred and something is wrongbeq@MouseLoopExit; so bail out@MouseCheckForOverflowDonelsl.l#04,d1; shift 4 bits to the leftbne@ReadMouseLoop; loop until all the mouse data is read@MouseLoopExit:rtsReadMouseB:rtsMouseStrobe:dc.b%00010100; $20dc.b%00000000; $00dc.b%00010100; $20dc.b%00000000; $00dc.b%00010100; $20dc.b%00000000; $00dc.b%00010100; $20dc.b%00000000; $00dc.b%00010100; $20MouseHeader:dc.b%00001011; first readdc.b%00001111; second readdc.b%00001111; third read
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.