Prev: 8B78 Up: Map Next: 8C4B
8B81: Get Key
8B81 DEFB $01,$00,$00,$0D,$02,$00,$00,$02
8B89 DEFW $0000
8B8B DEFB $00,$00,$00,$00,$00,$00,$00,$00
This entry point is used by the routine at 70F3.
GetKey 8B93 PUSH HL Stash HL, IX and BC on the stack.
8B94 PUSH IX
8B96 PUSH BC
8B97 CALL Pause Call Pause.
8B9A LD ($8B89),BC Write $0000 to 8B89.
8B9E LD HL,$8B8B HL=$8B8B.
8BA1 LD IX,$8B81 IX=8B81.
8BA5 LD BC,$FEFE BC=$FEFE.
GetKey_Loop 8BA8 IN A,(C) Read from the keyboard port.
8BAA AND %00011111 Keep only bits 0-4.
8BAC OR (IX+$00) OR against what IX is pointing to.
8BAF PUSH AF Stash AF on the stack.
8BB0 CPL Invert the bits (1's complement on A).
8BB1 AND (HL) Keep bits based on what HL is pointing to.
8BB2 CPL Invert the bits back (1's complement on A).
8BB3 JR Z,GetKey_ If it is zero, jump to GetKey_.
8BB5 LD ($8B89),BC Stash BC at 8B89.
8BB9 LD ($8B89),A Stash A at 8B89.
GetKey_ 8BBC POP AF Restore AF from the stack.
8BBD LD (HL),A Stash A at HL.
8BBE INC HL Increase HL by one.
8BBF INC IX Increase IX by one.
8BC1 RLC B Rotate B left.
8BC3 JR C,GetKey_Loop If there is carry then this is not a match, jump back to GetKey_Loop to try again.
8BC5 LD BC,($8B89) BC=8B89.
If no key match was found, end...
8BC9 LD A,B If BC is $0000, jump to GetKey_Return.
8BCA OR C
8BCB JR Z,GetKey_Return
8BCD LD A,$FB A=$FB.
8BCF ADD A,$05 A=A + 5.
8BD1 RRC B Rotate B right once.
8BD3 JR C,$8BCF If there is any carry, jump to 8BCF.
8BD5 DEC A Decrease A by one, ready for the following loop to begin in the same place.
8BD6 INC A Increment A by one.
8BD7 RRC C Rotate C right once.
8BD9 JR C,$8BD6 If there is any carry, jump to 8BD6.
8BDB LD C,A Create an offset in BC.
8BDC LD B,$00
8BDE LD HL,$8BFB HL=KeyboardMap1.
8BE1 LD A,$FE Read from the keyboard port.
Port Number Bit
0 1 2 3 4
$FE SHIFT Z X C V
8BE3 IN A,($FE)
8BE5 AND %00000001 Keep only bit 0 (SHIFT).
8BE7 JR Z,GetKey_UseMap2 If it is zero, jump to GetKey_UseMap2.
8BE9 LD A,$7F Read from the keyboard port.
Port Number Bit
0 1 2 3 4
$7F SPACE FULL-STOP M N B
8BEB IN A,($FE)
8BED AND %00000010 Keep only bit 1 (FULL-STOP).
8BEF JR NZ,GetKey_GetByte If it is not zero, jump to GetKey_GetByte.
GetKey_UseMap2 8BF1 LD HL,$8C23 HL=KeyboardMap2.
GetKey_GetByte 8BF4 ADD HL,BC HL=HL + keyboard map offset.
8BF5 LD A,(HL) A=HL (fetched byte from keyboard map).
GetKey_Return 8BF6 POP BC Restore BC, IX and HL from the stack.
8BF7 POP IX
8BF9 POP HL
8BFA RET Return.
KeyboardMap1 8BFB DEFB $00,$5A,$58,$43,$56 --, Z, X, C, V
8C00 DEFB $41,$53,$44,$46,$47 A, S, D, F, G
8C05 DEFB $51,$57,$45,$52,$54 Q, W, E, R, T
8C0A DEFB $00,$00,$00,$00,$08 --, --, --, --, 
8C0F DEFB $08,$00,$09,$5B,$0A , --, , [,
8C14 DEFB $50,$4F,$49,$55,$59 P, O, I, U, Y
8C19 DEFB $0D,$4C,$4B,$4A,$48 , L, K, J, H
8C1E DEFB $20,$00,$4D,$4E,$42 , --, M, N, B
KeyboardMap2 8C23 DEFB $00,$5A,$58,$43,$56 --, Z, X, C, V
8C28 DEFB $41,$53,$44,$46,$47 A, S, D, F, G
8C2D DEFB $51,$57,$45,$52,$54 Q, W, E, R, T
8C32 DEFB $00,$40,$00,$00,$08 --, @, --, --, 
8C37 DEFB $18,$00,$09,$5B,$0A , --, , [,
8C3C DEFB $22,$4F,$49,$55,$59 ", O, I, U, Y
8C41 DEFB $0D,$4C,$4B,$4A,$48 , L, K, J, H
8C46 DEFB $02,$00,$2E,$2C,$42 , --, ., ,, B
Prev: 8B78 Up: Map Next: 8C4B