|
|
Atari coding BBS
Re: ST Joystick Routine |
Posted by: gwEm
|
Feb,28.2013-14:21
|
Here is mine:
kbinterrupt: movem.l d0-d2/a0-a2,-(sp)
bclr #6,$fffffa15.w ;mask acia interrupt
;move.w #$2500,sr ;enable MFP interrupts (timer effects), disable vbl
kbinterrupt_top:btst.b #0,$fffffc00.w ;test if keyboard
bne.s kbint_handler
btst.b #0,$fffffc04.w ;test if MIDI
bne midiint_handler
bclr #6,$fffffa11.w ;clear ACIA interrupt
bset #6,$fffffa15.w ;unmask ACIA interrupt
movem.l (sp)+,d0-d2/a0-a2
rte
kbint_handler: lea newscancode(pc),a0
cmpi.b #1,6(a0) ;mouse int status
beq mouse_x_handler
cmpi.b #2,6(a0) ;mouse int status
beq mouse_y_handler
bhi joystick_handler
moveq #0,d0
move.b $fffffc02.w,d0 ;move IKBD byte into D0
move.w d0,d1
add.w d1,d1
move.w .jumptable(pc,d1.w),d1
jmp .jumptable(pc,d1.w)
.jumptable
REPT $1D-$0
dc.w .keyon-.jumptable ;0-7f
ENDR
dc.w .ctrlon-.jumptable ;1D
REPT $29-$1d
dc.w .keyon-.jumptable ;0-7f
ENDR
dc.w .shifton-.jumptable ;2A
REPT $37-$2a
dc.w .keyon-.jumptable ;0-7f
ENDR
dc.w .alton-.jumptable ;38
REPT $39-$38
dc.w .keyon-.jumptable ;0-7f
ENDR
dc.w .capson-.jumptable ;3A
REPT $80-$3a
dc.w .keyon-.jumptable ;0-7f
ENDR
REPT $9c-$80
dc.w .keyoff-.jumptable ;80-FF
ENDR
dc.w .ctrloff-.jumptable ;9D
REPT $a9-$9d
dc.w .keyoff-.jumptable ;80-FF
ENDR
dc.w .shiftoff-.jumptable ;AA
REPT $b7-$aa
dc.w .keyoff-.jumptable ;80-FF
ENDR
dc.w .altoff-.jumptable ;B8
REPT $f7-$b8
dc.w .keyoff-.jumptable ;80-FF
ENDR
dc.w .yesmouse-.jumptable ;F8
dc.w .yesmouse-.jumptable ;F9
dc.w .yesmouse-.jumptable ;FA
dc.w .yesmouse-.jumptable ;FB
dc.w .yesjoystick-.jumptable ;FC
dc.w .yesjoystick-.jumptable ;FD
dc.w .yesjoystick-.jumptable ;FE
dc.w .yesjoystick-.jumptable ;FF
.yesjoystick ;we now know its a joystick event report
move.b #3,6(a0) ; get packet
bra kbinterrupt_top
.yesmouse ;we now know its a maus relative position event
move.b d0,5(a0) ;store potential scancode which we use if the mouse didnt move
move.b #1,6(a0) ; - ignore clicks with moving mouse
bra kbinterrupt_top
.keyon move.b d0,(a0) ;not mouse event so we update the scancode
bra kbinterrupt_top
.keyoff move.b d0,(a0) ;not mouse event so we update the scancode
move.b #9,currentkeydelay ;key released - go back to long delay
bra kbinterrupt_top
.ctrlon move.b d0,(a0)
st 1(a0)
bra kbinterrupt_top
.ctrloff move.b d0,(a0)
clr.b 1(a0)
bra kbinterrupt_top
.alton move.b d0,(a0)
st 2(a0)
bra kbinterrupt_top
.altoff move.b d0,(a0)
clr.b 2(a0)
bra kbinterrupt_top
.shifton move.b d0,(a0)
st 3(a0)
bra kbinterrupt_top
.shiftoff move.b d0,(a0)
clr.b 3(a0)
bra kbinterrupt_top
.capson move.b d0,(a0)
tst.b 4(a0)
seq 4(a0)
bra kbinterrupt_top
joystick_handler:
move.b $fffffc02.w,d0
btst #0,midienables ;dont trigger if external sync not enabled
beq.s .end
btst #1,midienables ;dont trigger sync24 events if not enabled
beq.s .end
andi.b #%00000111,d0 ;d0 newjoycode: right, left, down, up
move.b 7(a0),d1 ;d1 oldjoycode:reserved, cont, clock, run
eor.b d0,d1 ;d1 change vector
btst #0,d1 ;change to run/stop?
bne.s .runchange
btst #1,d1 ;change to clock?
bne.s .clockchange
bra.s .end ;change to continue? do nothing
.runchange btst #0,d0
beq.s .stop
btst #2,d0
bne.s .cont
.start bsr recvstart
bsr flushikbd
bra.s .end
.cont bsr recvcont
bsr flushikbd
bra.s .end
.stop bsr recvstop
bra.s .end
.clockchange btst #1,d0
beq.s .end ;negative edge - do nothing
bsr recvclock ;positive edge - trigger replayer
.end move.b #0,6(a0) ;end of joystick packet
move.b d0,7(a0)
bra kbinterrupt_top
|
[All messages in this thread] [Start new thread]
What's the anti-troll code? That's your personal code to be able to add comments and messages on the dhs.nu site.
Don't have a code or forgot it? Fix it here.
|
|
|