Prev: DAC0 Up: Map Next: DC26
DBAE: Check for key pressed in the DEFINE keys windows
Read all the ports to detect a key pressed
Output
A Keycode of the key pressed
DBAE PUSH IY Save IY
DBB0 LD IX,$E0E0 Set IX to the base address for the list of ports to read the keys
DBB4 LD IY,$A9CC Set IY to the address pointer of the charset for keypressed
DBB8 LD B,$08 Set B to the number of ports to read the keys
DBBA PUSH BC Save BC
DBBB LD C,(IX+$00) Set BC to the port pointed by IY
DBBE LD B,(IX+$01)
DBC1 LD ($A0AB),BC Save the port at A0AB
DBC5 IN A,(C) Read the keys of the port into A
DBC7 LD B,$05 Set B to the number of bits to read to check for key pressed
DBC9 LD E,$00 Set E to the bit number to check
DBCB LD D,A Set D a copy of the result of the port reading
DBCC RRCA Rotates right A and check for the bit leaving on the right
DBCD JP NC,$DBE2 jump forward if keypressed
DBD0 INC E Increment the bit number checked
DBD1 DJNZ $DBCC Jump back until all the five bits readed
DBD3 POP BC Restore BC
DBD4 INC IX Point IX to the next port
DBD6 INC IX
DBD8 LD DE,$0005 Point IY to the next set of chars for the corresponding port
DBDB ADD IY,DE
DBDD DJNZ $DBBA Jump back until all the ports readed
DBDF JP $DBB0 Jump back and repeat the process from the beginning
Detected a key pressed
DBE2 POP BC Restore BC
DBE3 PUSH DE Save DE
DBE4 LD C,(IX+$00) Set BC to the port pointed by IY
DBE7 LD B,(IX+$01)
DBEA IN A,(C) Read the keys of the port into A
DBEC CP D Compare with the previously readed keys. Is the key still pressed?
DBED JP Z,$DBE4 Jump back if so
DBF0 LD A,E Set A to the bit number of the key pressed
DBF1 SLA A Computes the opcode of BIT to read the corresponent bit number: $47 - BIT 0,a | $4F - BIT 1,a | $57 - BIT 2,a | ...
DBF3 SLA A
DBF5 SLA A
DBF7 LD D,$47
DBF9 ADD A,D
DBFA LD ($A0AD),A Save corresponent opcode of BIT into A0AD
DBFD POP DE Restore in DE the bit number of the pressed key
DBFE LD D,$00 Set IY to the corresponding address of the key pressed in the charset table at A9CC
DC00 ADD IY,DE
DC02 LD A,(IY+$00) Set A to the keycode of the key pressed
DC05 POP IY Restore IY
DC07 CP $20 is SPACE the key pressed?
DC09 JP Z,$DBAE Jump back if so and check for another key reading
DC0C CP $48 is H the key pressed?
DC0E JP Z,$DBAE Jump back if so and check for another key reading
DC11 LD IY,$DD4E Set IY to the base address of the rex movement key defined
DC15 LD B,$05 Set B to the number of keys to define
DC17 CP (IY+$00) Is the key pressed now equals to the key already defined?
DC1A JP Z,$DBAE Jump back if so and check for another key reading
DC1D INC IY Points IY to the next key alredy defined
DC1F DJNZ $DC17 Jump back while there are keys defined to check
DC21 LD IY,$DD4E Set IY to the base address of the rex movement key defined
DC25 RET
Prev: DAC0 Up: Map Next: DC26