forked from historicalsource/total-carnage
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFBSTUFF.ASM
304 lines (266 loc) · 6.72 KB
/
FBSTUFF.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
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
.TITLE "FBSTUFF.ASM"
.WIDTH 132
.OPTION B,D,L,T
.MNOLIST
; ROUTINES STOLEN FROM HIGH IMPACT FOOTBALL
;
; INITIATED: JAN 10,1991
; MODIFIED: !
; SOFTWARE: MARK TURMELL
;
; COPYRIGHT (C) 1989 WILLIAMS ELECTRONICS GAMES, INC.
;
;
; GET THE SYSTEM STUFF
.INCLUDE "MPROC.EQU" ;MPROC EQUATES
.include "sys.inc" ;z unit system equates
.include "macros.hdr" ;macros definitions
.INCLUDE "GAME.EQU"
;
;SOUNDS
;
;
;SYMBOLS EXTERNALLY DEFINED
;
.REF PALSET,PALRAM
;
;SYMBOLS DEFINED IN THIS FILE
;
.DEF FB_FADEOUT,FB_FADEIN
PID_FX .EQU 200
.TEXT
**************************************************************************
* *
* FADEALL *
* *
* FADE EVERYTHING USING A GIVEN FADE ENTRY *
* *
* ENTRY *
* A0 LIST OF PALETTES *
* A11 FADE MULT TABLE *
* *
* EXIT *
* NOTHING *
* *
* CALL *
* CALL *
* *
**************************************************************************
FADEALL:
mmtm SP,A0,A1,A2,A6,A7,A8,A9,A11
JRUC Fader
**************************************************************************
* *
* FADEIN *
* *
* FADE A LIST OF PALETTES FROM BLACK TO THEIR CURRENT COLORS *
* *
* ENTRY *
* A0 PTR TO NULL TERMINATED LIST **NOT** TO FADE *
* *
* EXIT *
* NOTHING *
* *
**************************************************************************
FB_FADEIN:
mmtm SP,A0,A1,A2,A6,A7,A8,A9,A11
movi FadeIn,A11
jruc Fader
**************************************************************************
* *
* FADEOUT *
* *
* FADE A LIST OF PALETTES DOWN TO BLACK *
* *
* ENTRY *
* A0 PTR TO NULL TERMINATED LIST **NOT** TO FADE *
* *
* EXIT *
* NOTHING *
* *
**************************************************************************
FB_FADEOUT:
mmtm SP,A0,A1,A2,A6,A7,A8,A9,A11
movi FadeOut,A11
Fader:
move A0,A6
;* WALK EUGENES PALETTE TABLE, START PROC TO FADE EACH PALETTE *
clr A9 ;palette slot
dec A9
movi PALRAM-PALRSIZ,A2 ;base of eugenes palette table
PalLp:
addi PALRSIZ,A2
inc A9
cmpi NUMPAL,A9
jrge PalLpX
move *A2(PALCNT),A1,W ;is palette allocated?
jrz PalLp
move *A2(PALID),A8,L ;Ptr to palette
;*** SKIP FADING PALS IN LIST POINTED TO BY A6
move A6,A7
jrz SkFPalX
SkPalLp:
move *A7+,A1,L
jrz SkFPalX
cmp A1,A8
jreq PalLp
jruc SkPalLp
SkFPalX:
CREATE PID_FX,FADEPROC
jruc PalLp
PalLpX:
mmfm SP,A0,A1,A2,A6,A7,A8,A9,A11
rets
**************************************************************************
* *
* FADE_ONLY *
* *
* FADE ONLY A CERTAIN PALETTE *
* *
* ENTRY *
* A0 PALETTE TO BE FADED *
* A11 MULTIPLIER FOR PALETTES *
* *
* EXIT *
* NOTHING *
* *
* CALL *
* CALLA *
* *
**************************************************************************
FADE_ONLY:
mmtm SP,A0,A1,A2,A6,A7,A8,A9,A11
move A0,A6
;* WALK EUGENES PALETTE TABLE, START PROC TO FADE EACH PALETTE *
clr A9 ;palette slot
dec A9
movi PALRAM-PALRSIZ,A2 ;base of eugenes palette table
FOPalLp:
addi PALRSIZ,A2
inc A9
cmpi NUMPAL,A9
jrge FOPalLpX
move *A2(PALCNT),A1,W ;is palette allocated?
jrz FOPalLp
move *A2(PALID),A8,L ;Ptr to palette
CMP A6,A8
JRNZ FOPalLp ; BR = NOT THE ONE FOR ME
CREATE PID_FX,FADEPROC
jruc FOPalLp
FOPalLpX:
mmfm SP,A0,A1,A2,A6,A7,A8,A9,A11
rets
**************************************************************************
* *
* FADEPROC *
* *
* PROCESS TO ACTUALLY FADE A PALETTE *
* *
* ENTRY *
* A8 PTR TO PALETTE TO BE FADED *
* A9 PALETTE SLOT OF PALETTE *
* A11 FADE MULTIPLIER TABLE *
* *
* EXIT *
* NOTHING *
* *
**************************************************************************
FADEPROC:
sll 24,A9 ;B8-15 DEST PAL | B0-7 START COLOR
srl 16,A9
.IF YUNIT
MOVE A9,A2
SRL 12,A2
SLL 14,A2
SLL 20,A9
SRL 20,A9
ADD A2,A9
.ENDIF
FadePLp:
;**** SET UP FADED PAL IN PROCESS DATA SPACE ****
move *A11+,A2,W ;A2 - Color Multiplier
jrn FadePrcX
move A13,A0
addi PDATA,A0 ;A0 - Dest Ram for Pal
move A8,A1 ;A1 - Src for Pal
callr FadePal
;**** GET FADED PALETTE XFERRED TO PALRAM ****
move A9,A1 ;B8-15 DEST PAL | B0-7 START COLOR
move A13,A0
addi PDATA,A0 ;SRC FOR XFER
move *A0+,A2,W ;GET # COLORS IN PALETTE
calla PALSET ;SETUP PALETTE TRANSFER
SLEEP 2
jruc FadePLp
FadePrcX:
SLEEP 1 ;give last xfer a chance to go
DIE
**************************************************************************
* *
* FADEPAL *
* *
* APPLY THE COLOR MULTIPLIER AND DO ONE ITERATION ON THE PALETTE *
* *
* ENTRY *
* A0 DESTINATION RAM FOR PALETTE *
* A1 SOURCE FOR PALETTE *
* A2 COLOR MULTIPLIER *
* *
* EXIT *
* NOTHING *
* *
* NOTE: EACH COLOR IN PALETTE WILL BE MULTIPLIED BY A2 THEN *
* DIVIDED BY 128 *
* *
**************************************************************************
FadePal:
mmtm SP,A8,A9,A10,A11
move *A1+,A14,W
move A14,*A0+,W
sll 23,A14 ;top bits of field are flags
srl 23,A14 ; only 9 bits needed for # colors
movi 07C00H,A4 ;A4 - Pre Mult Mask for 5 bits of red
movi 003E0H,A6 ;A6 - Pre Mult Mask for 5 bits of green
movi 0001FH,A8 ;A8 - Pre Mult Mask for 5 bits of blue
move A4,A9
move A6,A10
move A8,A11
sll 7,A9 ; A9 - Post Mult Max for 5 bits of red
sll 7,A10 ;A10 - Post Mult Max for 5 bits of green
sll 7,A11 ;A11 - Post Mult Max for 5 bits of blue
FadeLp:
move *A1+,A3,W ;A3 - RED
move A3,A5 ;A5 - GREEN
move A3,A7 ;A7 - BLUE
and A4,A3
and A6,A5
and A8,A7
mpyu A2,A3
mpyu A2,A5
mpyu A2,A7
cmp A9,A3
jrle RedOk
move A9,A3
RedOk:
cmp A10,A5
jrle GreenOk
move A10,A5
GreenOk:
cmp A11,A7
jrle BlueOk
move A11,A7
BlueOk:
and A9,A3
and A10,A5
; and A11,A7 ;unnecessary cause bottom bits will get >> 7
or A5,A3
or A7,A3
srl 7,A3
move A3,*A0+,W
dsjs A14,FadeLp
mmfm SP,A8,A9,A10,A11
rets
FadeIn .word 0,0,8,16,24,32,40,48,56,64,72,80,88,96,104,112,120,128,0FFFFH
FadeOut .word 120,112,104,96,88,80,72,64,56,48,40,32,24,16,8,0,0FFFFH
.END