Prev: EB3E Up: Map Next: ECC0
EB51: Input Line
Used by the routine at JumpTable.
Main game entry from JumpTable_InputLine. Clears InputLineState, draws the cursor via InputLine_DrawCursor, then loops on KSTATE (second key slot) until the player presses Enter. Ordinary keys are echoed through PrintCharacter into the buffer at InputBuffer; Caps Shift chords edit the line; Enter submits via SubmitInputLine.)
InputLine EB51 SUB A Clear the length, cursor and dirty flag.
EB52 LD ($5BFB),A
EB55 LD ($5BFA),A
EB58 LD ($5BFD),A
EB5B CALL InputLine_DrawCursor Call InputLine_DrawCursor.
This entry point is used by the routine at InputLine_SymbolShiftRemap.
Wait for KSTATE (second key slot) to change to a new non-FF value.
InputLine_Poll EB5E LD A,($5BFC) Remember the previous key; read KSTATE.
EB61 LD D,A
EB62 LD A,($5C04)
EB65 LD ($5BFC),A Store the key and jump to InputLine_Poll if none is down.
EB68 CP $FF
EB6A JR Z,InputLine_Poll
EB6C CP D Jump to InputLine_Poll if the key has not changed.
EB6D JR Z,InputLine_Poll
EB6F LD E,A E=A.
Caps Shift held: dispatch editing chords at InputLine_CapsShift.
EB70 LD BC,$FEFE Jump to InputLine_CapsShift when Caps Shift is held.
EB73 IN A,(C)
EB75 BIT 0,A
EB77 JP Z,InputLine_CapsShift
Test Symbol Shift on the CAPS/Symbol Shift row.
EB7A LD BC,$7FFE Fetch that row and test Symbol Shift.
EB7D IN A,(C)
EB7F BIT 1,A
Jump to InputLine_SymbolShiftRemap when Symbol Shift is held.
InputLine_SymbolShiftHeld EB81 JR Z,InputLine_SymbolShiftRemap Jump to InputLine_SymbolShiftRemap when Symbol Shift is held.
This entry point is used by the routine at InputLine_SymbolShiftRemap.
InputLine_HandleKey EB83 LD A,E Jump to InputLine_Enter if Enter was pressed.
EB84 CP $0D
EB86 JR Z,InputLine_Enter
Append E to the buffer when there is room (length < 3E).
EB88 LD A,($5BFA) Jump to InputLine_Poll if the line already holds 3E characters.
EB8B LD D,A
EB8C CP $3E
EB8E JR NC,InputLine_Poll
EB90 LD HL,$5BAE Store the key into the buffer at InputBuffer.
EB93 ADD A,L
EB94 LD L,A
EB95 LD A,E
EB96 LD (HL),A
EB97 LD ($5BF9),A
EB9A LD A,$16 Set print state for echoing on row 16.
EB9C LD ($5BF8),A
EB9F SUB A
EBA0 LD ($5BF6),A
EBA3 LD A,$05
EBA5 LD ($5BF5),A
EBA8 LD A,D Wrap onto row 17 when the cursor column is past 20.
EBA9 LD ($5BF7),A
EBAC CP $20
EBAE JR C,InputLine_EchoChar
EBB0 SUB $20
EBB2 LD ($5BF7),A
EBB5 LD A,$17
EBB7 LD ($5BF8),A
InputLine_EchoChar EBBA CALL PrintCharacter Call PrintCharacter.
EBBD LD A,($5BFB) Grow the stored length if this column is new.
EBC0 CP D
EBC1 JR NZ,InputLine_AdvanceCursor
EBC3 INC A
EBC4 LD ($5BFB),A
InputLine_AdvanceCursor EBC7 LD A,D Advance the cursor and redraw it.
EBC8 INC A
EBC9 LD ($5BFA),A
EBCC CALL InputLine_DrawCursor
EBCF LD A,$01 Mark the line dirty, click, and poll again.
EBD1 LD ($5BFD),A
EBD4 CALL InputLine_Click
EBD7 JR InputLine_Poll
Terminate the buffer with 0D, point both read pointers at the input buffer, and submit via SubmitInputLine.
InputLine_Enter EBD9 LD A,($5BFB) Save the length and CR-terminate the buffer.
EBDC LD ($5BFE),A
EBDF LD A,($5BFB)
EBE2 LD HL,$5BAE
EBE5 ADD A,L
EBE6 LD L,A
EBE7 LD (HL),$0D
EBE9 LD HL,$5BAE Point both token pointers at the input buffer.
EBEC LD ($5BA7),HL
EBEF LD ($5BA9),HL
EBF2 JP SubmitInputLine Jump to SubmitInputLine.
Caps Shift chords: 1 restore length, 5/ 8 move the cursor, 9 insert a space, 0 delete, 2 is a no-op stub.
InputLine_CapsShift EBF5 LD A,E Jump to InputLine_Caps1 if Caps Shift + 1.
EBF6 CP $31
EBF8 JR Z,InputLine_Caps1
EBFA CP $32 Jump to InputLine_Caps2 if Caps Shift + 2.
EBFC JR Z,InputLine_Caps2
EBFE CP $35 Jump to InputLine_Caps5 if Caps Shift + 5.
EC00 JR Z,InputLine_Caps5
EC02 CP $38 Jump to InputLine_Caps8 if Caps Shift + 8.
EC04 JR Z,InputLine_Caps8
EC06 CP $30 Jump to InputLine_Caps0 if Caps Shift + 0.
EC08 JP Z,InputLine_Caps0
EC0B CP $39 Jump to InputLine_Caps9 if Caps Shift + 9.
EC0D JR Z,InputLine_Caps9
EC0F JP InputLine_Poll Jump to InputLine_Poll.
InputLine_Caps1 EC12 LD A,($5BFD) Jump to InputLine_Poll if the line is dirty.
EC15 AND A
EC16 JP NZ,InputLine_Poll
EC19 LD A,($5BFE) Restore the saved length and redraw the line.
EC1C LD ($5BFB),A
EC1F CALL InputLine_Redraw
EC22 JP InputLine_Poll
InputLine_Caps2 EC25 LD A,($5BFD) Jump to InputLine_Poll (Caps Shift + 2 is a no-op).
EC28 AND A
EC29 JP Z,InputLine_Poll
EC2C JP NZ,InputLine_Poll
EC2F LD A,($5BFE) Unreachable restore of the saved length.
EC32 LD ($5BFB),A
EC35 RET
Move the cursor one column left and redraw it.
InputLine_Caps5 EC36 LD A,($5BFA) Jump to InputLine_Poll if already at the start.
EC39 AND A
EC3A JP Z,InputLine_Poll
EC3D CALL InputLine_ClearCursor Clear the old cursor, step left, and redraw.
EC40 LD A,($5BFA)
EC43 DEC A
EC44 LD ($5BFA),A
EC47 CALL InputLine_DrawCursor
EC4A JP InputLine_Poll
Move the cursor one column right (not past the line length).
InputLine_Caps8 EC4D LD A,($5BFB) Jump to InputLine_Poll if already at the end of the line.
EC50 LD B,A
EC51 LD A,($5BFA)
EC54 CP B
EC55 JP Z,InputLine_Poll
EC58 CALL InputLine_ClearCursor Clear the old cursor, step right, and redraw.
EC5B LD A,($5BFA)
EC5E INC A
EC5F LD ($5BFA),A
EC62 CALL InputLine_DrawCursor
EC65 JP InputLine_Poll
Insert a space at the cursor by shifting the tail right.
InputLine_Caps9 EC68 LD A,($5BFB) Jump to InputLine_Poll if the line is full.
EC6B CP $3E
EC6D JP NC,InputLine_Poll
EC70 INC A Grow the length and work out how many bytes to shift.
EC71 LD ($5BFB),A
EC74 LD E,A
EC75 LD A,($5BFA)
EC78 LD B,A
EC79 LD A,E
EC7A SUB B
EC7B LD C,A
EC7C LD A,E
EC7D LD HL,$5BAE LDDR the tail right and write a space at the cursor.
EC80 ADD A,L
EC81 LD L,A
EC82 PUSH HL
EC83 POP DE
EC84 DEC HL
EC85 LD B,$00
EC87 LDDR
EC89 LD A,$20
EC8B LD (DE),A
EC8C CALL InputLine_Redraw Redraw, mark the line dirty, and poll again.
EC8F LD A,$01
EC91 LD ($5BFD),A
EC94 JP InputLine_Poll
Delete the character left of the cursor by shifting the tail left.
InputLine_Caps0 EC97 LD A,($5BFA) Jump to InputLine_Poll if already at the start.
EC9A AND A
EC9B JP Z,InputLine_Poll
EC9E DEC A Step the cursor left and shrink the stored length.
EC9F LD ($5BFA),A
ECA2 LD B,A
ECA3 LD A,($5BFB)
ECA6 DEC A
ECA7 LD ($5BFB),A
ECAA SUB B
ECAB LD C,A
ECAC INC C
ECAD LD HL,$5BAE LDIR the tail left over the deleted character.
ECB0 LD A,B
ECB1 ADD A,L
ECB2 LD L,A
ECB3 PUSH HL
ECB4 POP DE
ECB5 INC HL
ECB6 LD B,$00
ECB8 LDIR
ECBA CALL InputLine_Redraw Redraw the line and poll again.
ECBD JP InputLine_Poll
Prev: EB3E Up: Map Next: ECC0