Prev: 869B Up: Map Next: 8761
86A1: Print a character of the story
Used by the routine at PRINT_CHAR.
Where most of the game's text goes, in the six-pixel font at FONT (NARROW_CHAR), 42 to a line: HL is the byte and C the pixel within it where the next character starts, kept at STORY_CURSOR and STORY_PIXEL between calls, and STORY_COLUMNS counts the columns left.
A new line starts with the indent at INDENT -- how LIST_HELD indents what is inside something. Capitals are the game's own: every letter is made lower case, and the first letter after a carriage return or a full stop made upper case again, by the flag at CAPITAL_NEXT.
At the end of a line the finished line is copied to the ZX Printer if PRINT is on, then the game waits about 0.58 s -- a 62 T-state loop run up to 32,768 times -- or less if a key is pressed, before scrolling. NO_PAUSE_LINES, when not zero, takes away that wait for as many lines as it counts: START sets it to 17 for the opening description, and MAIN_LOOP to 9 before every line, so each turn's first nine lines come at once. Either way a key pressed means waiting for every key to be let go.
STORY_CHAR 86A1 PUSH HL
86A2 PUSH BC
86A3 PUSH AF
86A4 LD HL,(STORY_CURSOR) Starting a line: the indent
86A7 LD A,(STORY_PIXEL)
86AA LD C,A
86AB LD A,(MID_LINE)
86AE AND A
86AF JR NZ,STORY_CHAR_1
86B1 LD A,(INDENT)
86B4 AND A
86B5 JR Z,STORY_CHAR_1
86B7 LD B,A
STORY_CHAR_0 86B8 LD A,$20
86BA CALL NARROW_CHAR
86BD LD A,(STORY_COLUMNS)
86C0 DEC A
86C1 LD (STORY_COLUMNS),A
86C4 DJNZ STORY_CHAR_0
STORY_CHAR_1 86C6 POP AF A carriage return?
86C7 PUSH AF
86C8 CP $0D
86CA JR NZ,STORY_CHAR_8
86CC LD A,$01 The next letter is a capital
86CE LD (CAPITAL_NEXT),A
STORY_CHAR_2 86D1 XOR A A new line: to the printer, if PRINT is on
86D2 LD (MID_LINE),A
86D5 CALL LINE_TO_PRINTER
86D8 PUSH BC A short wait, or until a key
86D9 LD A,(NO_PAUSE_LINES)
86DC AND A
86DD JR NZ,STORY_CHAR_4
86DF LD BC,$8000
STORY_CHAR_3 86E2 XOR A
86E3 IN A,($FE)
86E5 AND $1F
86E7 CP $1F
86E9 JR NZ,STORY_CHAR_5
86EB DEC BC
86EC LD A,B
86ED OR C
86EE JR NZ,STORY_CHAR_3
86F0 POP BC
86F1 JR STORY_CHAR_7
STORY_CHAR_4 86F3 DEC A
86F4 LD (NO_PAUSE_LINES),A
STORY_CHAR_5 86F7 POP BC
STORY_CHAR_6 86F8 XOR A Until the keys are let go
86F9 IN A,($FE)
86FB AND $1F
86FD CP $1F
86FF JR NZ,STORY_CHAR_6
STORY_CHAR_7 8701 LD HL,$5020 Scroll the story up a line, 42 columns ahead
8704 LD C,$01
8706 CALL SCROLL_STORY
8709 LD A,$2A
870B JR STORY_CHAR_13
STORY_CHAR_8 870D CP $08 Backspace: back a column, blank it, back again
870F JR NZ,STORY_CHAR_9
8711 CALL BACK_ONE
8714 LD A,$20
8716 CALL NARROW_CHAR
8719 CALL BACK_ONE
871C LD A,(STORY_COLUMNS)
871F INC A
8720 JR STORY_CHAR_13
STORY_CHAR_9 8722 CP $41 Capitals to lower case...
8724 JR C,STORY_CHAR_10
8726 CP $5B
8728 JR NC,STORY_CHAR_10
872A OR $20
STORY_CHAR_10 872C PUSH HL ...and a capital where a sentence starts
872D LD HL,CAPITAL_NEXT
8730 INC (HL)
8731 DEC (HL)
8732 JR Z,STORY_CHAR_11
8734 CP $61
8736 JR C,STORY_CHAR_11
8738 CP $7B
873A JR NC,STORY_CHAR_11
873C RES 5,A
873E LD (HL),$00
STORY_CHAR_11 8740 CP $2E
8742 JR NZ,STORY_CHAR_12
8744 INC (HL)
STORY_CHAR_12 8745 POP HL
8746 CALL NARROW_CHAR Print it
8749 LD (MID_LINE),A
874C LD A,(STORY_COLUMNS) The line full? A new one
874F DEC A
8750 JP Z,STORY_CHAR_2
STORY_CHAR_13 8753 LD (STORY_COLUMNS),A Keep the place
8756 LD (STORY_CURSOR),HL
8759 LD A,C
875A LD (STORY_PIXEL),A
875D POP AF
875E POP BC
875F POP HL
8760 RET
Prev: 869B Up: Map Next: 8761