Code: Select all
IKBD.turnOnJoystick
movem.l d0/a0,-(sp)
move.w #34,-(sp)
trap #14
addq.l #2,sp ;return IKBD vector table
move.l d0,ikbd_vec ;store IKBD vectors address
move.l d0,a0 ;a0 points to IKBD vectors
move.l 24(a0),old_joy ;backup old joystick vector
move.l #readjoy,24(a0) ;input my joystick vector
move.l #joy_on,-(sp) ;pointer to IKBD instructions
move.w #0,-(sp) ;instruction length - 1
move.w #25,-(sp) ;send instruction to IKBD
trap #14
addq.l #8,sp
movem.l (sp)+,d0/a0
rts
Code: Select all
readjoy move.b 1(a0),joy store joy 0 data
move.b 2(a0),joy+1 store joy 1 data
rts
Here is the actual code that doesn't work. The part between the MOVEM statements are new and is what I used a simple polling routing before. It works by placing it here for the keyboard, but the joysticks doesn't work anymore...
Code: Select all
;Lower IKBD interrupt below the priority of the HBL
IKBD.setIKBDirqLow
move.l $118,oldikbd
move.l #newikbd,$118
rts
newikbd movem.l d0-d1/a1,-(sp)
lea keyboard_buffer,a1
move.b $fffffc02.w,d0
move.b d0,d1
and.l #$7F,d1
adda.l d1,a1
btst #7,d0 ;check if it's a press or release
bne.s brkcode
move.b #1,(a1)
bra next
brkcode move.b #0,(a1)
next movem.l (sp)+,d0-d1/a1
move.w d0,-(sp)
move.w sr,d0
and.w #$f8ff,d0
or.w #$500,d0
move.w d0,sr
move.w (sp)+,d0
dc.w $4ef9
oldikbd dc.l 0
illegal