[go: up one dir, main page]

Menu

[r63]: / psrp / asm / t4a_2.asm  Maximize  Restore  History

Download this file

159 lines (110 with data), 2.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
;
; Narrative formatter
; - Extra scripting codes
;
; Written in TASM 3.0.1
;
#include "vars.asm"
.org $7e00 ; $7fe00-7fecf
Start:
CALL CACHE ; Check substring RAM
CP NEWLINE
JR Z,No_decode
CP EOS ; Look for decode flag
JP NZ,Done
Decode:
CALL DECODER ; Regular decode
No_decode:
; ______________________________________________________
Code1:
CP $59 ; Post-length hints
JR NZ,Code2 ; Check next code
CALL DECODER ; Grab length
LD (POST_LEN),A ; Cache it
JR Decode ; Immediately grab next code
; ______________________________________________________
Code2:
CP $00 ; Whitespace
JR NZ,Code3 ; Check next code
PUSH HL
LD (TEMP_STR),A ; Store WS, $00
INC A ; A = $01
LD (LEN),A ; Store length
LD HL,TEMP_STR ; Load string location
LD (STR),HL ; Store string pointer
POP HL
CALL CACHE ; Our new dictionary lookup code
; will do auto-formatting
; Intentional fall-through
; ______________________________________________________
Code3:
CP $55 ; - wait more
JR NZ,Code4
Reset_Lines:
PUSH AF
XOR A
Set_Lines:
LD (LINE_NUM),A ; Clear # lines used
POP AF
JP Done
; _________________________________________________________
Code4:
CP $54 ; Newline check
JR NZ,Code5 ; Next code
PUSH HL ; Automatic narrative waiting
LD HL,LINE_NUM ; Grab # lines drawn
INC (HL) ; One more line break
LD L,(HL) ; Load current value
LD A,(VLIMIT) ; Read vertical limit
CP L ; Check if limit reached
JR Z,WAIT
NO_WAIT:
LD A,NEWLINE ; Reload newline
JR Code4_End
WAIT:
LD A,$55 ; wait more
LD (FLAG),A ; Raise flag
LD HL,LINE_NUM
Wait_Clear:
DEC (HL) ; Keep shrinking # lines drawn
JR NZ,Wait_Clear ; to save 1 byte of space
Code4_End:
POP HL ; Restore stack
JR Done
; ______________________________________________________
Code5:
CP $60
JR C,Code6 ; Control codes, don't interfere
SUB $60 ; Relocate dictionary entry #
PUSH HL
PUSH DE
PUSH BC
LD HL,WORDS
CALL DICT_2 ; Relocate substring entry and copy
POP BC
POP DE
POP HL
JP Start ; Our new dictionary lookup code
; JR Code4 ; Go back for formatting concerns
; ______________________________________________________
Code6:
CP $5A ; Use article
JR NZ,Code7
CALL DECODER ; Grab #
LD (ARTICLE),A
JP Decode
; ______________________________________________________
Code7:
CP $5B ; Use suffix
JR NZ,Code8
LD A,(SUFFIX) ; Check flag
OR A
JP Z,Decode ; No 's' needed
LD A,LETTER_S ; add 's'
; ______________________________________________________
Code8:
; ---
Done:
CP $58 ; Old code
RET ; Go to remaining text handler
.end ; TASM-only