A89: how do i fix this... quick question


[Prev][Next][Index][Thread]

A89: how do i fix this... quick question



ok, im testing keys through using the masks...
now, as you know, the up arrow is bit 0 and so is esc. but on different masks.
im checking mask 0 (u,d,l,r) and mask 6 (esc) but say if i hold the up arrow, it will think escape was pressed (after a few loops)
how do i fix this? i dont want it quitting the game when their character moves up :P i know its a newbie question, but its bugging me...
 
here is what im using...:
 
getkey:
        move.b   #mask6,d0 ;put key mask 6 into d0, thats the esc key mask
        bsr  get_key
        btst.b   #0,d0  ;check esc.
        beq   _exit  ;esc pressed, else goto next line
        move.w   #mask0,d0 ;move key mask 0 into d0 (keys 2nd, left, right, up, down, etc.)
        bsr   get_key  ;goes to get_key, which will put the key that was pushed into d0
        btst.b   #0,d0  ;test to see if up was pressed
        beq  keyup  ;up was pressed, goto keyup, else goto next line
        btst.b  #2,d0  ;test to see if down was pressed
        beq   keydown  ;down was pressed, goto keydown, else goto next line
        btst.b  #1,d0  ;check left
        beq   keyleft  ;left pressed
        btst.b   #3,d0  ;check right
        beq   keyright ;right pressed
        btst.b   #4,d0  ;check 2nd
        beq   key2nd  ;2nd pressed
endgetkey:
        bra   nextloop    ;go back to mainloop
 

get_key:
        move.b  d0,($600019)  ;keypad located at $600019 (wr) $60001b (re).
        move.w #50,d0   ;give 89 time to store key press, about 50 loops
delay_c:
        dbra d0,delay_c   ;loop 50 times
        move.b $60001b,d0  ;gives bit stored into d0 i.e. bit 1-7
 rts