Prev: 60222 Up: Map Next: 60608
60241: 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 60241 SUB A Clear the length, cursor and dirty flag.
60242 LD (23547),A
60245 LD (23546),A
60248 LD (23549),A
60251 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-255 value.
InputLine_Poll 60254 LD A,(23548) Remember the previous key; read KSTATE.
60257 LD D,A
60258 LD A,(23556)
60261 LD (23548),A Store the key and jump to InputLine_Poll if none is down.
60264 CP 255
60266 JR Z,InputLine_Poll
60268 CP D Jump to InputLine_Poll if the key has not changed.
60269 JR Z,InputLine_Poll
60271 LD E,A E=A.
Caps Shift held: dispatch editing chords at InputLine_CapsShift.
60272 LD BC,65278 Jump to InputLine_CapsShift when Caps Shift is held.
60275 IN A,(C)
60277 BIT 0,A
60279 JP Z,InputLine_CapsShift
Test Symbol Shift on the CAPS/Symbol Shift row.
60282 LD BC,32766 Fetch that row and test Symbol Shift.
60285 IN A,(C)
60287 BIT 1,A
Jump to InputLine_SymbolShiftRemap when Symbol Shift is held.
InputLine_SymbolShiftHeld 60289 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 60291 LD A,E Jump to InputLine_Enter if Enter was pressed.
60292 CP 13
60294 JR Z,InputLine_Enter
Append E to the buffer when there is room (length < 62).
60296 LD A,(23546) Jump to InputLine_Poll if the line already holds 62 characters.
60299 LD D,A
60300 CP 62
60302 JR NC,InputLine_Poll
60304 LD HL,23470 Store the key into the buffer at InputBuffer.
60307 ADD A,L
60308 LD L,A
60309 LD A,E
60310 LD (HL),A
60311 LD (23545),A
60314 LD A,22 Set print state for echoing on row 22.
60316 LD (23544),A
60319 SUB A
60320 LD (23542),A
60323 LD A,5
60325 LD (23541),A
60328 LD A,D Wrap onto row 23 when the cursor column is past 32.
60329 LD (23543),A
60332 CP 32
60334 JR C,InputLine_EchoChar
60336 SUB 32
60338 LD (23543),A
60341 LD A,23
60343 LD (23544),A
InputLine_EchoChar 60346 CALL PrintCharacter Call PrintCharacter.
60349 LD A,(23547) Grow the stored length if this column is new.
60352 CP D
60353 JR NZ,InputLine_AdvanceCursor
60355 INC A
60356 LD (23547),A
InputLine_AdvanceCursor 60359 LD A,D Advance the cursor and redraw it.
60360 INC A
60361 LD (23546),A
60364 CALL InputLine_DrawCursor
60367 LD A,1 Mark the line dirty, click, and poll again.
60369 LD (23549),A
60372 CALL InputLine_Click
60375 JR InputLine_Poll
Terminate the buffer with 13, point both read pointers at the input buffer, and submit via SubmitInputLine.
InputLine_Enter 60377 LD A,(23547) Save the length and CR-terminate the buffer.
60380 LD (23550),A
60383 LD A,(23547)
60386 LD HL,23470
60389 ADD A,L
60390 LD L,A
60391 LD (HL),13
60393 LD HL,23470 Point both token pointers at the input buffer.
60396 LD (23463),HL
60399 LD (23465),HL
60402 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 60405 LD A,E Jump to InputLine_Caps1 if Caps Shift + 1.
60406 CP 49
60408 JR Z,InputLine_Caps1
60410 CP 50 Jump to InputLine_Caps2 if Caps Shift + 2.
60412 JR Z,InputLine_Caps2
60414 CP 53 Jump to InputLine_Caps5 if Caps Shift + 5.
60416 JR Z,InputLine_Caps5
60418 CP 56 Jump to InputLine_Caps8 if Caps Shift + 8.
60420 JR Z,InputLine_Caps8
60422 CP 48 Jump to InputLine_Caps0 if Caps Shift + 0.
60424 JP Z,InputLine_Caps0
60427 CP 57 Jump to InputLine_Caps9 if Caps Shift + 9.
60429 JR Z,InputLine_Caps9
60431 JP InputLine_Poll Jump to InputLine_Poll.
InputLine_Caps1 60434 LD A,(23549) Jump to InputLine_Poll if the line is dirty.
60437 AND A
60438 JP NZ,InputLine_Poll
60441 LD A,(23550) Restore the saved length and redraw the line.
60444 LD (23547),A
60447 CALL InputLine_Redraw
60450 JP InputLine_Poll
InputLine_Caps2 60453 LD A,(23549) Jump to InputLine_Poll (Caps Shift + 2 is a no-op).
60456 AND A
60457 JP Z,InputLine_Poll
60460 JP NZ,InputLine_Poll
60463 LD A,(23550) Unreachable restore of the saved length.
60466 LD (23547),A
60469 RET
Move the cursor one column left and redraw it.
InputLine_Caps5 60470 LD A,(23546) Jump to InputLine_Poll if already at the start.
60473 AND A
60474 JP Z,InputLine_Poll
60477 CALL InputLine_ClearCursor Clear the old cursor, step left, and redraw.
60480 LD A,(23546)
60483 DEC A
60484 LD (23546),A
60487 CALL InputLine_DrawCursor
60490 JP InputLine_Poll
Move the cursor one column right (not past the line length).
InputLine_Caps8 60493 LD A,(23547) Jump to InputLine_Poll if already at the end of the line.
60496 LD B,A
60497 LD A,(23546)
60500 CP B
60501 JP Z,InputLine_Poll
60504 CALL InputLine_ClearCursor Clear the old cursor, step right, and redraw.
60507 LD A,(23546)
60510 INC A
60511 LD (23546),A
60514 CALL InputLine_DrawCursor
60517 JP InputLine_Poll
Insert a space at the cursor by shifting the tail right.
InputLine_Caps9 60520 LD A,(23547) Jump to InputLine_Poll if the line is full.
60523 CP 62
60525 JP NC,InputLine_Poll
60528 INC A Grow the length and work out how many bytes to shift.
60529 LD (23547),A
60532 LD E,A
60533 LD A,(23546)
60536 LD B,A
60537 LD A,E
60538 SUB B
60539 LD C,A
60540 LD A,E
60541 LD HL,23470 LDDR the tail right and write a space at the cursor.
60544 ADD A,L
60545 LD L,A
60546 PUSH HL
60547 POP DE
60548 DEC HL
60549 LD B,0
60551 LDDR
60553 LD A,32
60555 LD (DE),A
60556 CALL InputLine_Redraw Redraw, mark the line dirty, and poll again.
60559 LD A,1
60561 LD (23549),A
60564 JP InputLine_Poll
Delete the character left of the cursor by shifting the tail left.
InputLine_Caps0 60567 LD A,(23546) Jump to InputLine_Poll if already at the start.
60570 AND A
60571 JP Z,InputLine_Poll
60574 DEC A Step the cursor left and shrink the stored length.
60575 LD (23546),A
60578 LD B,A
60579 LD A,(23547)
60582 DEC A
60583 LD (23547),A
60586 SUB B
60587 LD C,A
60588 INC C
60589 LD HL,23470 LDIR the tail left over the deleted character.
60592 LD A,B
60593 ADD A,L
60594 LD L,A
60595 PUSH HL
60596 POP DE
60597 INC HL
60598 LD B,0
60600 LDIR
60602 CALL InputLine_Redraw Redraw the line and poll again.
60605 JP InputLine_Poll
Prev: 60222 Up: Map Next: 60608