View Single Post
Old 19 December 2014, 23:43   #8
Don_Adan
Registered User
 
Join Date: Jan 2008
Location: Warsaw/Poland
Age: 49
Posts: 918
Good job. Game works OK on my A4000 68040 25 MHz.
If you want, you can adapt next code for keyboard handling.
It works OK on all CPU's.

Code:
;============================================================================
; callback/hook which gets executed on each keypress

_SetupKeyboard
;set the interrupt vector
 pea (.int,pc)
 move.l (a7)+,($68.W)   ; plus VBR
;allow interrupts from the keyboard
 move.b #CIAICRF_SETCLR!CIAICRF_SP,(ciaicr+_ciaa)
;clear all ciaa-interrupts
 tst.b (ciaicr+_ciaa)
;set input mode
 and.b #~(CIACRAF_SPMODE),(ciacra+_ciaa)
;clear ports interrupt
 move.w #INTF_PORTS,(intreq+_custom)
;allow ports interrupt
 move.w #INTF_SETCLR!INTF_INTEN!INTF_PORTS,(intena+_custom)
 rts

.int
 movem.l d0-d1/a0-a1,-(a7)
 lea (_custom),a0
 lea (_ciaa),a1
;check if keyboard has caused interrupt
 btst #INTB_PORTS,(intreqr+1,a0)
 beq .end
 btst #CIAICRB_SP,(ciaicr,a1)
 beq .end
;read keycode
 move.b (ciasdr,a1),d0
;set output mode (handshake)
 or.b #CIACRAF_SPMODE,(ciacra,a1)
;calculate rawkeycode
 not.b D0
 ror.b #1,D0
 btst #7,D0
 beq.b .pushed
 cmp.b #$D0,D0  ; F1
 bne.b .endplayer1
 bset #3,gl_portB ; gl_portB
 bra .back
.endplayer1
 cmp.b #$D1,D0  ; F2
 bne.b .endplayer2
 bset #2,gl_portB ; gl_portB
 bra .back
.endplayer2
 cmp.b #$D2,D0  ; F3
 bne.b .endcoin1
 bclr #4,gl_portB ; gl_portB
 bra .back
.endcoin1
 cmp.b #$D3,D0  ; F4
 bne.b .endcoin2
 bclr #6,gl_portB ; gl_portB
 bra .back
.endcoin2
 cmp.b #$D4,D0  ; F5
 bne.b .endconfig
 bset #1,gl_portB ; gl_portB
 bra .back
.endconfig
 cmp.b #$E0,D0  ; Left Shift
 bne.b .endfire1
 bset #2,gl_potgo ; gl_potgo
 bra .back
.endfire1
 cmp.b #$E1,D0  ; Right Shift
 bne .back
 bset #6,gl_potgo ; gl_potgo
 bra .back
.pushed
 cmp.b #$D9,D0  ; F10
 bne.b .noexit
 st QuitFlag ; handled from main interrupt
 bra.b .back
.noexit
 cmp.b #$50,D0  ; F1
 bne.b .noplayer1
 bclr #3,gl_portB ; gl_portB
 bra.b .back
.noplayer1
 cmp.b #$51,D0  ; F2
 bne.b .noplayer2
 bclr #2,gl_portB ; gl_portB
 bra.b .back
.noplayer2
 cmp.b #$52,D0  ; F3
 bne.b .nocoin1
 bset #4,gl_portB ; gl_portB
 bra.b .back
.nocoin1
 cmp.b #$53,D0  ; F4
 bne.b .nocoin2
 bset #6,gl_portB ; gl_portB
 bra.b .back
.nocoin2
 cmp.b #$54,D0  ; F5
 bne.b .noconfig
 bclr #1,gl_portB ; gl_portB
 bra.b .back
.noconfig
 cmp.b #$60,D0  ; Left Shift
 bne.b .nofire1
 bclr #2,gl_potgo ; gl_potgo
 bra.b .back
.nofire1
 cmp.b #$61,D0  ; Right Shift
 bne.b .back
 bclr #6,gl_potgo ; gl_potgo
.back
;better would be to use the cia-timer to wait, but we arn't know if
;they are otherwise used, so using the rasterbeam
;required minimum waiting is 75 Ás, one rasterline is 63.5 Ás
;a loop of 3 results in min=127Ás max=190.5Ás
 moveq #3-1,d1
.wait1
 move.b (vhposr,a0),d0
.wait2
 cmp.b (vhposr,a0),d0
 beq.b .wait2
 dbf d1,.wait1

;set input mode
 and.b #~(CIACRAF_SPMODE),(ciacra,a1)
.end
 move.w #INTF_PORTS,(intreq,a0)
;to avoid timing problems on very fast machines we do another
;custom access
 tst.w (intreqr,a0)
 movem.l (a7)+,d0-d1/a0-a1
 rte
Don_Adan is offline  
 
Page generated in 0.08160 seconds with 9 queries