/
rldrawo.a
377 lines (355 loc) · 6.65 KB
/
rldrawo.a
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
;**********************************************************************
;* *
;* P R O J E C T : REALITY_ENGINE *
;* *
;* ENGINE OBJECT DRAW MODULE (SMALLER) *
;* *
;**********************************************************************
include rage.i
include rle.i
include gsumac.i
public _RLDrawObjsA
public _RLDrawObjsB
public _RLDrawObjsC
public _RLDrawObjs
SECTION ENGINE_GSUCODE
cpu sfx
;
; * * * * * * * REALITY_ENGINE DRAW OBJECTS * * * * * * *
;
; In LOW-Detail mode, each 2-pixels wide are from a single OBJECT PLOT
; Strip.
;
rPixelCount equ r3 ; Pixel SkipCount/RepeatCount
;
rColourMapB equ r4 ; Bank of ColourMap Data
rColourMap equ r5 ; ColourMap
;
rPixScaleF equ r6 ; SCN->RL Scale Fraction
rPixScale equ r7 ; SCN->RL Scale Integer
;
rObjF equ r8 ; SCN->RL Obj Fraction
rObj equ r9 ; Pointer to ObjTextureData
rObjB equ r10 ; Bank of ObjTextureData
;
rPlotDataPtr equ r11 ; Ptr within Current ObjPlotData
align 16,(_RLDrawObjsC-_RLDrawObjsLowAlign)&$0f
_RLDrawObjsC
move r2,#<_RLDrawMiscC ; _RLDrawSpritesC
bra _RLDrawObjs
nop
_RLDrawObjsB
move r2,#<_RLDrawMiscB ; _RLDrawSpritesB
bra _RLDrawObjs
nop
_RLDrawObjsA
move r2,#<_RLDrawMiscA ; _RLDrawSpritesA
_RLDrawObjs
move (<RLNextCode),r2 ; Save address of Next Code Jump
move rColourMapB,#^RLColourMaps ; Bank of ColourMap Data
move rPlotDataPtr,(<TRObjPlotPtr) ; OBJ PLOT DATA END
;
ibt r0,#%00000000 ; Transp.On,NoDither,8-BitColour,NoSpr.
cmode
;
iwt r13,#<_DOL3200+1 ; ImageOffset Address
;
ifn useCHECKOBJPLOTDATA
move r2,#0
endif
;
; * * * * * * * DRAW OBJS IN LOW DETAIL * * * * * * *
;
_RLDrawObjsLow
bra _DOL8000-1 ; @SET UP CACHE@
nop
;
; >>> DRAW OBJECTS COMPLETE <<<
;
_DOL1000
move r0,(<RLNextCode) ; Begin Execution of Next Code
ibt r8,#^_RLDrawMiscA ; _RLDrawSpritesA
ife PROFILE
ljmp r8
endif
ifn PROFILE
stop
endif
nop
CACHEB _RLDrawObjsLow
_RLDrawObjsLowAlign
;
; >>> GET OBJPLOT GROUPHEADER <<<
;
_DOL8000
dec rPlotDataPtr ; Move to Scale
dec rPlotDataPtr
; to r0 ; Get Scale
ldw (rPlotDataPtr)
moves r0,r0
; from r0
to rPixScale
beq _DOL1000 ; End of ObjPlotData!
hib
; with r0
lob
; from r0
to rPixScaleF
swap
inc r0
with rPlotDataPtr
sub #4
;
; >>> GET PIXELSTRIP PLOT INFORMATION <<<
;
_DOL7000
dec rPlotDataPtr ; Get WorldZFraction/#Pixels
dec rPlotDataPtr
; to r0
ldw (rPlotDataPtr)
ifn useCHECKOBJPLOTDATA
inc r2 ; Error with ObjPlotData?
bpl .0
HALTGSU #$21 ; YES!
.0
endif
; from r0 ; R12 = #Pixels To Draw
to r12
hib
; from r0 ; Get WorldZ DrawFraction
to rObjF
beq _DOL8000 ; End of ObjPlotGroup!
lob
with rObjF
swap
;
dec rPlotDataPtr ; Get Bank of PixelData/ColourMap
dec rPlotDataPtr
; to r0
ldw (rPlotDataPtr)
romb
move rObjB,r0
; with r0 ; Get Address of ColourMap
hib
; from r0
to rColourMap
swap
;
dec rPlotDataPtr ; Get Address of PixelData
dec rPlotDataPtr
to r14
ldw (rPlotDataPtr)
;
dec rPlotDataPtr ; Get Starting X/Y Coordinates
dec rPlotDataPtr
; to r0
ldw (rPlotDataPtr)
; from r0
to r1
lob
with r1
add r1
; from r0
to r2
hib
ifn useCHECKOBJPLOTDATA
move r0,#(RLViewPixY-1)
; with r0
sub r2
bge .2
HALTGSU #$23
.2
endif
dec rPlotDataPtr ; Get ImageOffset
dec rPlotDataPtr
; to r0
ldb (rPlotDataPtr)
moves rPixelCount,r0
beq _DOL4200+1 ; No ImageOffset
getb
;
; * * * * * * * ADJUST FOR IMAGE OFFSET * * * * * * *
;
_DOL3200
inc r14
; with r0 ; <SKIP>/<REPEAT>/<UNIQUE>?
lob
beq _DOL3400 ; <SKIP>/<REPEAT>
_DOL3300
dec rPixelCount ; <UNIQUE>
bne _DOL3200
getb ; Get Next ImageByte
bra _DOL4220
; with r0
lob
;
; >>> SKIP <<<
;
_DOL3400
getb ; <SKIP>/<REPEAT>?
inc r14
; with r0
sex
bmi _DOL3600 ; <REPEAT>
with rPixelCount ; <SKIP>
beq _DOL4800 ; <END>
sub r0
bmi _DOL3500 ; <SKIP RUNNING/EXACTLY ENDED>
inc rPixelCount
bra _DOL3200
getb ; Get Next ImageByte
_DOL3500
with rPixelCount
beq _DOL4200 ; <SKIP> ENDS EXACTLY
not
bra _DOL5400 ; <SKIP> RUNNING
inc rPixelCount
;
; >>> REPEAT <<<
;
_DOL3600
add r0 ; ImageOffset -= RepeatCount
bmi _DOL3700 ; <REPEAT RUNNING/EXACTLY ENDED>
inc rPixelCount
inc r14 ; Skip RepeatColour
bra _DOL3200
getb ; Get Next ImageByte
_DOL3700
with rPixelCount
bne _DOL6200+1 ; <REPEAT> RUNNING
not
;
; * * * * * * * STRIP PIXEL SLOW * * * * * * *
;
_DOL4200
getb ; <SKIP>/<REPEAT>/<UNIQUE>?
; with r0
lob
_DOL4220
beq _DOL5200 ; <SKIP>/<REPEAT>
;
; >>> UNIQUE <<<
;
from rColourMapB
romb
move rObj,r14
; from r0
to r14
add rColourMap
inc rObj
from rObjB
romb
getc
_DOL4400
plot ; Draw the PixelBlock
dec r12 ; One less ScreenPixel to Draw
beq _DOL4800
plot
dec r1 ; Move back to correct X Coordinate
dec r1
with rObjF ; Move to next Pixel
add rPixScaleF
from rPixScale
; to r0
adc #0
beq _DOL4400
dec r2 ; Move to next Y Coordinate
;
; >>> UNIQUE DONE <<<
;
move r14,rObj
with r0
bra _DOL3300
to rPixelCount
;
; >>> OBJDATA STRIP DONE <<<
;
_DOL4800
iwt r15,#<_DOL7000+1 ; Next ObjectPlot
dec rPlotDataPtr ; Get WorldZFraction/#Pixels
;
; >>> SKIP <<<
;
_DOL5200
inc r14 ; SkipCount/RepeatCount
getb
inc r14
; from r0 ; <SKIP>/<REPEAT>?
to rPixelCount
sex
bmi _DOL6200 ; <REPEAT>
with rPixelCount
beq _DOL4800 ; <END>
_DOL5400
dec r12 ; One less ScreenPixel to Draw
beq _DOL4800
with rObjF ; Move to next Pixel
add rPixScaleF
from rPixScale
; to r0
adc #0
beq _DOL5400
dec r2 ; Move to next Y Coordinate
with rPixelCount
sub r0
dec rPixelCount
bpl _DOL5400
inc rPixelCount
;
; >>> SKIP DONE <<<
;
beq _DOL4200+1
getb ; Get Next ImageByte
inc r14
with rPixelCount
not
jmp r13
inc rPixelCount
;
; >>> REPEAT <<<
;
_DOL6200
not ; RepeatCount
inc rPixelCount
move rObj,r14
from rColourMapB
romb
getb ; Get RepeatColour
; from r0
to r14
add rColourMap
inc rObj
from rObjB
romb
getc
_DOL6400
plot ; Draw the PixelBlock
dec r12 ; One less ScreenPixel to Draw
beq _DOL4800
plot
dec r1 ; Move back to correct X Coordinate
dec r1
with rObjF ; Move to next Pixel
add rPixScaleF
from rPixScale
; to r0
adc #0
beq _DOL6400
dec r2 ; Move to next Y Coordinate
with rPixelCount
sub r0
dec rPixelCount
bpl _DOL6400
inc rPixelCount
;
; >>> REPEAT DONE <<<
;
move r14,rObj
beq _DOL4200+1
getb ; Get Next ImageByte
inc r14
with rPixelCount
not
jmp r13
inc rPixelCount
CACHEE _RLDrawObjsLow