-
Notifications
You must be signed in to change notification settings - Fork 2
/
elite-teletext-docked.asm
277 lines (205 loc) · 7.76 KB
/
elite-teletext-docked.asm
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
\ ******************************************************************************
\
\ TELETEXT ELITE DOCKED-SPECIFIC ROUTINES
\
\ Elite was written by Ian Bell and David Braben and is copyright Acornsoft 1984
\
\ The code on this site has been reconstructed from a disassembly of the version
\ released on Ian Bell's personal website at http://www.elitehomepage.org/
\
\ The commentary is copyright Mark Moxon, and any misunderstandings or mistakes
\ in the documentation are entirely my fault
\
\ The terminology and notations used in this commentary are explained at
\ https://elite.bbcelite.com/terminology
\
\ The deep dive articles referred to in this commentary can be found at
\ https://elite.bbcelite.com/deep_dives
\
\ ******************************************************************************
\ ******************************************************************************
\
\ Name: PlotSixelIfEmpty
\ Type: Subroutine
\ Category: Teletext Elite
\ Summary: Plot a mode 7 sixel, but only if the character block containing
\ the sixel is empty
\
\ ------------------------------------------------------------------------------
\
\ Arguments:
\
\ X Sixel x-coordinate
\
\ Y Sixel y-coordinate
\
\ ------------------------------------------------------------------------------
\
\ Returns:
\
\ Z flag Did we plot the sixel?
\
\ * Clear if we did not plot the sixel because there is
\ already something there or the sixel is off-screen
\
\ * Set if we did plot the sixel
\
\ ******************************************************************************
.PlotSixelIfEmpty
CPX #MODE7_LOW_X \ If the sixel is off-screen, jump to empt2 to return
BCC empt2 \ from the subroutine with the Z flag clear
CPY #MODE7_LOW_Y
BCC empt2
CPX #MODE7_HIGH_X
BCS empt2
CPY #MODE7_HIGH_Y
BCS empt2
CLC \ Set SC(1 0) to the screen address of the character
LDA xSixel,X \ block, starting with the low byte
ADC ySixelLo,Y
STA SC
LDA ySixelHi,Y \ And then the high byte
ADC #HI(MODE7_VRAM)
STA SCH
LDA (SC),Y \ Fetch the current character from screen memory
BNE empt1 \ If it is non-zero, i.e. there is something already
\ there, jump to empt1 to return from the subroutine
\ with the Z flag clear
LDA ySixelChar,Y \ Get the sixel character with the relevant row
\ pre-filled for the y-coordinate in Y
AND xSixelChar,X \ Apply the sixel character with the relevant column
\ pre-filled for the x-coordinate in X, so the result
\ is a sixel character with the sixel at (x, y) filled
ORA (SC),Y \ OR the sixel into the screen, overwriting whatever is
STA (SC),Y \ already there
LDA #0 \ Set A = 0 so we return with the Z flag set
.empt1
RTS \ Return from the subroutine
.empt2
LDA #1 \ Set A = 1 so we return with the Z flag clear
RTS \ Return from the subroutine
\ ******************************************************************************
\
\ Name: StyleSystemData
\ Type: Subroutine
\ Category: Teletext Elite
\ Summary: Print the control codes to style the Data on System screen
\
\ ******************************************************************************
.StyleSystemData
LDA &7C55 \ If the distance is showing, jump to syst1 to style the
CMP #'D' \ screen, as everything moves down one line
BEQ syst1
LDA #130 \ Set to the "green text" control code
STA &7C85 \ Economy
STA &7CD8 \ Government
STA &7D28 \ Tech level
STA &7D78 \ Population
STA &7DBC \ Species
STA &7E20 \ Gross producticity
STA &7E6C \ Average radius
LDA #131 \ Set to the "yellow text" control code
STA &7EAC \ Extended description
STA &7EAC+(1*40)
STA &7EAC+(2*40)
STA &7EAC+(3*40)
STA &7EAC+(4*40)
RTS \ Return from the subroutine
.syst1
LDA #130 \ Set to the "green text" control code
STA &7C5E \ Distance
STA &7C85+40 \ Economy
STA &7CD8+40 \ Government
STA &7D28+40 \ Tech level
STA &7D78+40 \ Population
STA &7DBC+40 \ Species
STA &7E20+40 \ Gross producticity
STA &7E6C+40 \ Average radius
LDA #131 \ Set to the "yellow text" control code
STA &7EAC+(1*40) \ Extended description
STA &7EAC+(2*40)
STA &7EAC+(3*40)
STA &7EAC+(4*40)
STA &7EAC+(5*40)
RTS \ Return from the subroutine
\******************************************************************************
\
\ Name: StyleBuyCargo
\ Type: Subroutine
\ Category: Teletext Elite
\ Summary: Print the control codes for the Buy Cargo screen
\
\ ******************************************************************************
.StyleBuyCargo
LDA #132 \ Style rows 0 and 1 as yellow text, blue background
STA MODE7_VRAM+(0*40)
STA MODE7_VRAM+(1*40)
LDA #157
STA MODE7_VRAM+(0*40)+1
STA MODE7_VRAM+(1*40)+1
LDA #131
STA MODE7_VRAM+(0*40)+2
STA MODE7_VRAM+(1*40)+2
RTS \ Return from the subroutine
\ ******************************************************************************
\
\ Name: StyleCargo
\ Type: Subroutine
\ Category: Teletext Elite
\ Summary: Print the control codes for the cargo list
\
\ ******************************************************************************
.StyleCargo
LDA #129 \ Set to the "red text" control code
FOR n, 0, 16
STA &7C89 + n*40 \ Set the unit in the 17 price rows to red
NEXT
LDA #130 \ Set to the "green text" control code
FOR n, 0, 16
STA &7C8C + n*40 \ Set the price in the 17 price rows to green
NEXT
LDA #131 \ Set to the "yellow text" control code
FOR n, 0, 16
STA &7C92 + n*40 \ Set the price in the 17 price rows to yellow
NEXT
RTS \ Return from the subroutine
\ ******************************************************************************
\
\ Name: StyleSellCargo
\ Type: Subroutine
\ Category: Teletext Elite
\ Summary: Print the control codes for the Sell Cargo list
\
\ ******************************************************************************
.StyleSellCargo
LDA #129 \ Set to the "red text" control code
FOR n, 0, 16
STA &7C61 + n*40 \ Set the unit in the 17 price rows to red
NEXT
LDA #131 \ Set to the "yellow text" control code
FOR n, 0, 16
STA &7C67 + n*40 \ Set the Sell(Y/N) in the 17 price rows to yellow
NEXT
RTS \ Return from the subroutine
\ ******************************************************************************
\
\ Name: StyleEquipShip
\ Type: Subroutine
\ Category: Teletext Elite
\ Summary: Print the control codes for the Sell Cargo list
\
\ ******************************************************************************
.StyleEquipShip
LDA #131 \ Set to the "yellow text" control code
FOR n, 0, 16
STA &7C54 + n*40 \ Set the number in the 17 price rows to yellow
NEXT
LDA #134 \ Set to the "cyan text" control code
FOR n, 0, 16
STA &7C58 + n*40 \ Set the name in the 17 price rows to yellow
NEXT
LDA #130 \ Set to the "green text" control code
FOR n, 0, 16
STA &7C6C + n*40 \ Set the unit in the 17 price rows to green
NEXT
RTS \ Return from the subroutine