[A83] Re: Multiple Keypresses


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

[A83] Re: Multiple Keypresses




This was ripped from Bubble Bobble, needs to be edited if you want it in 
your program...
This reads the keyboard and stores the keys in memory, so if you are moving 
right, (jRight) will contain nonzero.

;=============
;  ReadKeys
;=============
ReadKeys:
;Check for Clear
ld a,255
out (1),a
ld a,KeyRow_5
out (1),a
in a,(1)
cp KClear
jp z,SaveAndQuit

;Do stuff for freshly hit buttons
;(Bubble bobble distinguishes between holding down buttons
;and pressing them, feel free to rename the variables,
;you probably won't have a Bubble button :)
	ld a,(jJump)
	or a
	ld a,0
	jr nz,$+4
	ld a,1
	ld (jJumpPress),a
	ld a,(jBubble)
	or a
	ld a,0
	jr nz,$+4
	ld a,1
	ld (jBubblePress),a

;Read arrows
;(NOTE: Up jumps, so down isn't there.  You can replace stuff
;with jUp and add a jDown manually...)
	ld a,255
	out (1),a
	ld a,KeyRow_Pad
	out (1),a
	in a,(1)
	cpl
	ld b,a
	and KILeft
	ld (jLeft),a
	ld a,b
	and KIRight
	ld (jRight),a
	ld a,b
	and KIUp
	ld (jJump),a
;Read 2nd,Mode,Del...
	ld a,255
	out (1),a
	ld a,KeyRow_Top
	out (1),a
	in a,(1)
	cpl
	ld b,a
	and KI2nd
	ld (jBubble),a
;Read Alpha and on...
;(note that the alpha code shown here merges up with alpha,
; you might not want that)
	ld a,255
	out (1),a
	ld a,KeyRow_1
	out (1),a
	in a,(1)
	cpl
	ld b,a
	and kIAlpha
	ld hl,jJump
	or (hl)
	ld (hl),a
	ld a,b
	and kIMath
	call nz,PowerOff
	ret

Don't know if you want Math to be the shutoff key...

All the key equates here require DWEDIT.INC, you can easily find that in the 
bubble bobble zip file.

>Hi I am trying to learn how to detect multiple keypresses. I looked at asm 
>guru but i really couldn't follow it because i had no clue what they were 
>doing with the 'out' and 'in'. Could someone please explain this to me, and 
>are there any .incs that have the key commands in it like keys.inc does for 
>the getcsc command, instead of me typin out the long binary code that it 
>looks like I need for the program.
>
>


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp