Prev: 34426 Up: Map Next: 34657
34459: Print: Write A Character To The Screen
Writes one character into the text window, scrolling when the line is full.
PrintWriteACharacterToTheScreen 34459 DEFB 0
34460 DEFW 0
34462 DEFB 0
34463 DEFB 0
34464 DEFB 0
This entry point is used by the routine at Print_Character.
PrintWriteACharacterToTheScreen_0 34465 PUSH HL Save HL, BC and AF, and bring HL back from 34460.
34466 PUSH BC
34467 PUSH AF
34468 LD HL,(34460)
34471 LD A,(34462) Read the print column.
34474 LD C,A Copy the result into C.
Test this flag.
34475 LD A,(34464) Jump to PrintWriteACharacterToTheScreen_TestForAReturn if *34464 is not zero.
34478 AND A
34479 JR NZ,PrintWriteACharacterToTheScreen_TestForAReturn
Test this flag.
34481 LD A,(34463) Jump to PrintWriteACharacterToTheScreen_TestForAReturn if *34463 is zero.
34484 AND A
34485 JR Z,PrintWriteACharacterToTheScreen_TestForAReturn
34487 LD B,A Copy the result into B.
PrintWriteACharacterToTheScreen_Loop 34488 LD A,32 Use the character ' '.
Draw this character with the game font.
34490 CALL Print_ProportionalCharacter Call Print_ProportionalCharacter to draw this character with the game's font.
34493 LD A,(34459) Read the room left on the line at PrintWriteACharacterToTheScreen.
34496 DEC A Drop one from the room left on the line.
34497 LD (34459),A Update the room left on the line.
34500 DJNZ PrintWriteACharacterToTheScreen_Loop Loop back to PrintWriteACharacterToTheScreen_Loop until the space count runs out.
PrintWriteACharacterToTheScreen_TestForAReturn 34502 POP AF Restore the character from the stack, keeping a copy there.
34503 PUSH AF
34504 CP 13 Jump to PrintWriteACharacterToTheScreen_TestBackspace unless the character is 13.
34506 JR NZ,PrintWriteACharacterToTheScreen_TestBackspace
34508 LD A,1 Set the capitalise-the-next-letter flag after a carriage return.
34510 LD (46852),A
PrintWriteACharacterToTheScreen_ClearTheFlag 34513 XOR A Clear *34464.
34514 LD (34464),A
34517 CALL ZXPrinter Call ZXPrinter to copy this text line to the ZX printer.
34520 PUSH BC Save BC.
Test how many words will be accepted.
34521 LD A,(46870) Jump to PrintWriteACharacterToTheScreen_CountDownTheWords if *46870 is not zero.
34524 AND A
34525 JR NZ,PrintWriteACharacterToTheScreen_CountDownTheWords
34527 LD BC,32768 Point BC at 32768.
PrintWriteACharacterToTheScreen_PollKeys 34530 XOR A Select every keyboard row.
34531 IN A,(254) Read port 254 into A.
34533 AND 31 Jump to PrintWriteACharacterToTheScreen_DropTheTimeout unless the low five bits are all set.
34535 CP 31
34537 JR NZ,PrintWriteACharacterToTheScreen_DropTheTimeout
34539 DEC BC Loop back to PrintWriteACharacterToTheScreen_PollKeys until the keyboard timeout reaches zero.
34540 LD A,B
34541 OR C
34542 JR NZ,PrintWriteACharacterToTheScreen_PollKeys
34544 POP BC Jump to PrintWriteACharacterToTheScreen_PointAtTheTextLine to scroll line.
34545 JR PrintWriteACharacterToTheScreen_PointAtTheTextLine
PrintWriteACharacterToTheScreen_CountDownTheWords 34547 DEC A Count down how many words will be accepted.
34548 LD (46870),A Update *46870.
PrintWriteACharacterToTheScreen_DropTheTimeout 34551 POP BC Drop the timeout and select every keyboard row.
PrintWriteACharacterToTheScreen_WaitForRelease 34552 XOR A
34553 IN A,(254) Read port 254 into A.
34555 AND 31 Jump back to PrintWriteACharacterToTheScreen_WaitForRelease unless the low five bits are all set.
34557 CP 31
34559 JR NZ,PrintWriteACharacterToTheScreen_WaitForRelease
PrintWriteACharacterToTheScreen_PointAtTheTextLine 34561 LD HL,20512 Point HL at the text line.
34564 LD C,1 One pixel row of the character.
34566 CALL ScrollLine Call ScrollLine to scroll line.
34569 LD A,42 Reset the room left on the line to 42.
34571 JR PrintWriteACharacterToTheScreen_StoreTheRoomLeft Jump to PrintWriteACharacterToTheScreen_StoreTheRoomLeft to store the room left on the line.
PrintWriteACharacterToTheScreen_TestBackspace 34573 CP 8 Jump to PrintWriteACharacterToTheScreen_TestForALetter if the character is not 8.
34575 JR NZ,PrintWriteACharacterToTheScreen_TestForALetter
34577 CALL Print_WrapTheColumn Call Print_WrapTheColumn to wrap the print column.
34580 LD A,32 Use the character ' '.
Draw this character with the game font.
34582 CALL Print_ProportionalCharacter Call Print_ProportionalCharacter to draw this character with the game's font.
34585 CALL Print_WrapTheColumn Call Print_WrapTheColumn to wrap the print column.
34588 LD A,(34459) Read the room left on the line at PrintWriteACharacterToTheScreen.
34591 INC A Count one more character on the line.
34592 JR PrintWriteACharacterToTheScreen_StoreTheRoomLeft Jump to PrintWriteACharacterToTheScreen_StoreTheRoomLeft to store the room left on the line.
PrintWriteACharacterToTheScreen_TestForALetter 34594 CP 65 Jump to PrintWriteACharacterToTheScreen_TestCapitalise if the character is below 65.
34596 JR C,PrintWriteACharacterToTheScreen_TestCapitalise
34598 CP 91 Jump to PrintWriteACharacterToTheScreen_TestCapitalise if the character is 91 or above.
34600 JR NC,PrintWriteACharacterToTheScreen_TestCapitalise
34602 OR 32 Merge in 32.
PrintWriteACharacterToTheScreen_TestCapitalise 34604 PUSH HL Point HL at the capitalise-the-next-letter flag.
34605 LD HL,46852
34608 INC (HL) Test the capitalise-the-next-letter flag without changing it.
34609 DEC (HL)
34610 JR Z,PrintWriteACharacterToTheScreen_TestForAFullStop Jump to PrintWriteACharacterToTheScreen_TestForAFullStop if the next letter should not be capitalised.
34612 CP 97 Jump to PrintWriteACharacterToTheScreen_TestForAFullStop if the character is below 97.
34614 JR C,PrintWriteACharacterToTheScreen_TestForAFullStop
34616 CP 123 Jump to PrintWriteACharacterToTheScreen_TestForAFullStop if it is 123 or above.
34618 JR NC,PrintWriteACharacterToTheScreen_TestForAFullStop
34620 RES 5,A Clear bit 5.
34622 LD (HL),0 Clear the capitalise-the-next-letter flag once the letter is upper case.
PrintWriteACharacterToTheScreen_TestForAFullStop 34624 CP 46 Jump to PrintWriteACharacterToTheScreen_DrawTheGlyph unless it is 46.
34626 JR NZ,PrintWriteACharacterToTheScreen_DrawTheGlyph
34628 INC (HL) A full stop bumps the capitalise-the-next-letter flag.
PrintWriteACharacterToTheScreen_DrawTheGlyph 34629 POP HL Pop the screen address and call Print_ProportionalCharacter to draw the glyph.
Draw this character with the game font.
34630 CALL Print_ProportionalCharacter
34633 LD (34464),A Store the column and jump back to PrintWriteACharacterToTheScreen_ClearTheFlag when the room left on the line reaches zero.
34636 LD A,(34459)
34639 DEC A
34640 JP Z,PrintWriteACharacterToTheScreen_ClearTheFlag
PrintWriteACharacterToTheScreen_StoreTheRoomLeft 34643 LD (34459),A Update the room left on the line.
34646 LD (34460),HL Store HL at 34460.
34649 LD A,C Store the print column.
34650 LD (34462),A
34653 POP AF Restore AF, BC and HL from the stack.
34654 POP BC
34655 POP HL
34656 RET Return.
Prev: 34426 Up: Map Next: 34657