Prev: DD97 Up: Map Next: DE00
DDC0: Choose Control Type
Used by the routines at SelectionScreen, ChangeControls and UserDefinedKeys.
ChooseControlType DDC0 LD DE,$FF2F DE=FF2F.
DDC3 LD BC,$FEFE BC=FEFE.
ReadKeyboard_Loop DDC6 IN A,(C) Read from the keyboard.
DDC8 CPL Invert the bits in A.
DDC9 AND %00011111 Keep only bits 0-4.
DDCB JR Z,ChooseControlType_1 Jump to ChooseControlType_1 if there's no match.
DDCD INC D Increment D by one.
DDCE RET NZ Return if D is not zero.
DDCF LD H,A H=A.
DDD0 LD A,E A=E.
ChooseControlType_0 DDD1 SUB $08 A-=08.
DDD3 SRL H Shift H right.
DDD5 JR NC,ChooseControlType_0 Jump to ChooseControlType_0 if {} is higher.
DDD7 RET NZ Return if {} is not zero.
DDD8 LD D,A D=A.
DDD9 LD L,B L=B.
ChooseControlType_1 DDDA DEC E Decrease E by one.
DDDB RLC B Rotate B left (with carry).
DDDD JR C,ReadKeyboard_Loop Jump to ReadKeyboard_Loop if {} is lower.
DDDF LD A,D A=D.
DDE0 AND %00111000 Keep only bits 3-5.
DDE2 RRCA Rotate A right three positions (bits 3 to 5 are now in positions 0 to 2).
DDE3 RRCA
DDE4 RRCA
DDE5 PUSH HL Stash HL on the stack.
DDE6 LD HL,$DDF2 HL=DDF2.
DDE9 LD B,$00 B=00.
DDEB LD C,A C=A.
DDEC ADD HL,BC HL+=BC.
DDED LD B,(HL) B=*HL.
DDEE POP HL Restore HL from the stack.
DDEF LD H,B H=B.
DDF0 XOR A A=00.
DDF1 RET Return.
DDF2 DEFB $10,$08,$04,$02,$01,$00,$00,$00
DDFA DEFB $00,$00,$00,$00,$00,$00
Prev: DD97 Up: Map Next: DE00