Prev: EB3E Up: Map Next: ECC0
EB51: Input Line
Used by the routine at JumpTable.
Main game entry from JumpTable_InputLine. ENTER submits via SubmitInputLine.
InputLine EB51 SUB A Write 00 to *InputLineState_Length, *InputLineState and *InputLineState_Dirty.
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 until a new key is down.
InputLine_Poll EB5E LD A,($5BFC) Copy *InputLineState_LastKey to D.
EB61 LD D,A
EB62 LD A,($5C04) Read KSTATE (second key slot).
EB65 LD ($5BFC),A Write the key to *InputLineState_LastKey.
EB68 CP $FF Jump to InputLine_Poll if none is down.
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.
Test for Caps Shift.
EB70 LD BC,$FEFE Read from the keyboard;
Port Number Bit
0 1 2 3 4
FE CAPS SHIFT Z X C V
EB73 IN A,(C)
EB75 BIT 0,A Jump to InputLine_CapsShift when Caps Shift is held.
EB77 JP Z,InputLine_CapsShift
EB7A LD BC,$7FFE Read from the keyboard;
Port Number Bit
0 1 2 3 4
7F SPACE SYMBOL SHIFT M N B
EB7D IN A,(C)
EB7F BIT 1,A Test the Symbol Shift bit.
Test for Symbol Shift.
InputLine_SymbolShiftHeld EB81 JR Z,InputLine_SymbolShiftRemap Jump to InputLine_SymbolShiftRemap when it is held.
This entry point is used by the routine at InputLine_SymbolShiftRemap.
Handle an ordinary keypress.
InputLine_HandleKey EB83 LD A,E Jump to InputLine_Enter if ENTER was pressed.
EB84 CP $0D
EB86 JR Z,InputLine_Enter
Append the character to the input buffer.
EB88 LD A,($5BFA) Fetch *InputLineState into D.
EB8B LD D,A
EB8C CP $3E Jump to InputLine_Poll if the line already holds 3E characters.
EB8E JR NC,InputLine_Poll
EB90 LD HL,$5BAE Store the key in InputBuffer and *PrintState_Character.
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 PrintState_Row, PrintState_Flags and PrintState 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 Copy *InputLineState to *PrintState_Column.
EBA9 LD ($5BF7),A
EBAC CP $20 Jump to InputLine_EchoChar if the column is still on this row.
EBAE JR C,InputLine_EchoChar
EBB0 SUB $20 Wrap onto row 17.
EBB2 LD ($5BF7),A
EBB5 LD A,$17
EBB7 LD ($5BF8),A
Echo it onto the input row.
InputLine_EchoChar EBBA CALL PrintCharacter Call PrintCharacter.
EBBD LD A,($5BFB) Grow *InputLineState_Length if this column is new.
EBC0 CP D
EBC1 JR NZ,InputLine_AdvanceCursor
EBC3 INC A
EBC4 LD ($5BFB),A
Advance the cursor, click, and poll again.
InputLine_AdvanceCursor EBC7 LD A,D Advance *InputLineState.
EBC8 INC A
EBC9 LD ($5BFA),A
EBCC CALL InputLine_DrawCursor Call InputLine_DrawCursor.
EBCF LD A,$01 Set *InputLineState_Dirty.
EBD1 LD ($5BFD),A
EBD4 CALL InputLine_Click Call InputLine_Click.
EBD7 JR InputLine_Poll Jump to InputLine_Poll.
Terminate the buffer with ENTER and submit the line.
InputLine_Enter EBD9 LD A,($5BFB) Copy *InputLineState_Length to *InputLineState_SavedLength.
EBDC LD ($5BFE),A
EBDF LD A,($5BFB) Write ENTER (0D) at the end of InputBuffer.
EBE2 LD HL,$5BAE
EBE5 ADD A,L
EBE6 LD L,A
EBE7 LD (HL),$0D
EBE9 LD HL,$5BAE Point InputBuffer_TokenStart and InputBuffer_NextToken at InputBuffer.
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.
Restore the saved length and redraw.
InputLine_Caps1 EC12 LD A,($5BFD) Jump to InputLine_Poll if *InputLineState_Dirty is set.
EC15 AND A
EC16 JP NZ,InputLine_Poll
EC19 LD A,($5BFE) Copy *InputLineState_SavedLength to *InputLineState_Length.
EC1C LD ($5BFB),A
EC1F CALL InputLine_Redraw Call InputLine_Redraw.
EC22 JP InputLine_Poll Jump to InputLine_Poll.
Caps Shift + 2 is a no-op.
InputLine_Caps2 EC25 LD A,($5BFD) Jump to InputLine_Poll.
EC28 AND A
EC29 JP Z,InputLine_Poll
EC2C JP NZ,InputLine_Poll
EC2F LD A,($5BFE) Copy *InputLineState_SavedLength to *InputLineState_Length.
EC32 LD ($5BFB),A
EC35 RET Return.
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 Call InputLine_ClearCursor.
EC40 LD A,($5BFA) Decrease *InputLineState.
EC43 DEC A
EC44 LD ($5BFA),A
EC47 CALL InputLine_DrawCursor Call InputLine_DrawCursor.
EC4A JP InputLine_Poll Jump to InputLine_Poll.
Move the cursor one column right and redraw it.
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 Call InputLine_ClearCursor.
EC5B LD A,($5BFA) Increase *InputLineState.
EC5E INC A
EC5F LD ($5BFA),A
EC62 CALL InputLine_DrawCursor Call InputLine_DrawCursor.
EC65 JP InputLine_Poll Jump to 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 Increase *InputLineState_Length.
EC71 LD ($5BFB),A
EC74 LD E,A Work out how many bytes to shift.
EC75 LD A,($5BFA)
EC78 LD B,A
EC79 LD A,E
EC7A SUB B
EC7B LD C,A
EC7C LD A,E Point HL at the end of InputBuffer.
EC7D LD HL,$5BAE
EC80 ADD A,L
EC81 LD L,A
EC82 PUSH HL Copy HL to DE (using the stack).
EC83 POP DE
EC84 DEC HL Shift the tail right.
EC85 LD B,$00
EC87 LDDR
EC89 LD A,$20 Write a space at the cursor.
EC8B LD (DE),A
EC8C CALL InputLine_Redraw Call InputLine_Redraw.
EC8F LD A,$01 Set *InputLineState_Dirty.
EC91 LD ($5BFD),A
EC94 JP InputLine_Poll Jump to 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 Decrease *InputLineState.
EC9F LD ($5BFA),A
ECA2 LD B,A Decrease *InputLineState_Length.
ECA3 LD A,($5BFB)
ECA6 DEC A
ECA7 LD ($5BFB),A
ECAA SUB B Count the bytes to shift.
ECAB LD C,A
ECAC INC C
ECAD LD HL,$5BAE Point HL at the cursor in InputBuffer.
ECB0 LD A,B
ECB1 ADD A,L
ECB2 LD L,A
ECB3 PUSH HL Copy HL to DE (using the stack).
ECB4 POP DE
ECB5 INC HL Shift the tail left.
ECB6 LD B,$00
ECB8 LDIR
ECBA CALL InputLine_Redraw Call InputLine_Redraw.
ECBD JP InputLine_Poll Jump to InputLine_Poll.
Prev: EB3E Up: Map Next: ECC0