-
Notifications
You must be signed in to change notification settings - Fork 2
/
elite-teletext-flight.asm
198 lines (140 loc) · 6.39 KB
/
elite-teletext-flight.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
\ ******************************************************************************
\
\ TELETEXT ELITE FLIGHT-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: dashboard
\ Type: Variable
\ Category: Teletext Elite
\ Summary: The mode 7 dashboard image
\
\ ******************************************************************************
.dashboard
\INCBIN "1-source-files/images/P.DIALS_2LINES.bin" \ Side lines, ship as V
INCBIN "1-source-files/images/P.DIALS_DOT.bin" \ Side lines, ship as dot
\INCBIN "1-source-files/images/P.DIALS_3LINES.bin" \ Side and centre lines
\INCBIN "1-source-files/images/P.DIALS_ELLIPSE.bin" \ Just the ellipse
\INCBIN "1-source-files/images/P.DIALS_FULL.bin" \ Full set of lines
\ ******************************************************************************
\
\ Name: ShowDashboard
\ Type: Subroutine
\ Category: Teletext Elite
\ Summary: Show the dashboard
\
\ ******************************************************************************
.ShowDashboard
LDA #LO(dashboard) \ Set P(1 0) to the blank dashboard image at dashboard
STA P
LDA #HI(dashboard)
STA P+1
LDA #LO(MODE7_VRAM+(18*&28)) \ Set R(1 0) to the dashboard's on-screen
STA R \ address from row 18 onwards
LDA #HI(MODE7_VRAM+(18*&28))
STA R+1
\ The dashboard image is 256 + 24 bytes long, so we can
\ copy it into memory using two loops, the first for
\ 256 bytes and the second for 24 bytes
LDY #0 \ Set a byte counter in Y to work through the first page
\ (256 bytes) of the dashboard image as we copy it into
\ screen memory
.dash1
LDA (P),Y \ Copy the Y-th dashboard byte from P(1 0) to R(1 0)
STA (R),Y
DEY \ Decrement the byte counter
BNE dash1 \ Loop back until we have copied a whole page
INC P+1 \ Increment P(1 0) and R(1 0) to point to the next page
INC R+1 \ in memory
LDY #24 \ Set a byte counter in Y to work through the next 24
\ bytes of the dashboard image as we copy it into screen
\ memory
.dash2
LDA (P),Y \ Copy the Y-th dashboard byte from P(1 0) to R(1 0)
STA (R),Y
DEY \ Decrement the byte counter
BPL dash2 \ Loop back until we have copied 24 bytes
LDA #0 \ Unset the compass colour so we don't try to remove the
STA COMC \ existing dot (as there isn't one in the dashboard
\ image)
JMP DIALS \ Update the contents of the dashboard, returning from
\ the subroutine using a tail call
\ ******************************************************************************
\
\ Name: DrawMissiles
\ Type: Subroutine
\ Category: Teletext Elite
\ Summary: Draw the missiles on the dashboard
\
\ ******************************************************************************
.DrawMissiles
LDA MSAR \ If MSAR is zero, then the missile is not looking for
BEQ dmis1 \ a target, so jump to dmis1 to set the missile colour
\ to green or red
LDA #147 \ The missile is looking for a target, so set the
\ colour in A to yellow
BNE dmis3 \ Jump to dmis3 to set the missile colour (this BNE is
\ effectively a JMP as A is never zero)
.dmis1
LDA MSTG \ If MSTG is 1-12, then we have target lock, so jump to
BPL dmis2 \ dmis2 to set the missile colour to red
LDA #146 \ The missile does not have target lock, so set the
\ colour in A to green
BNE dmis3 \ Jump to dmis3 to set the missile colour (this BNE is
\ effectively a JMP as A is never zero)
.dmis2
LDA #145 \ The missile has target lock, so set the colour in A
\ to red
.dmis3
STA &7FC3 \ Set the missiles to the colour in A by poking the
\ control character in A into the space before the
\ missile sixels
JMP msblob \ Draw the missiles, returning from the subroutine
\ using a tail call
\ ******************************************************************************
\
\ Name: StyleSystemData
\ Type: Subroutine
\ Category: Teletext Elite
\ Summary: Print the control codes to style the Data on System screen
\
\ ******************************************************************************
.StyleSystemData
LDA &7CA5 \ 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 &7CD5 \ Economy
STA &7D28 \ Government
STA &7D78 \ Tech level
STA &7DC8 \ Population
STA &7E0C \ Species
STA &7E70 \ Gross producticity
STA &7EBC \ Average radius
RTS \ Return from the subroutine
.syst1
LDA #130 \ Set to the "green text" control code
STA &7CAE \ Distance
STA &7CD5+40 \ Economy
STA &7D28+40 \ Government
STA &7D78+40 \ Tech level
STA &7DC8+40 \ Population
STA &7E0C+40 \ Species
STA &7E70+40 \ Gross producticity
STA &7EBC+40 \ Average radius
RTS \ Return from the subroutine