-
Notifications
You must be signed in to change notification settings - Fork 0
/
MAIN.S
383 lines (289 loc) · 9.2 KB
/
MAIN.S
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
378
379
380
381
382
383
; oOOOOOOOo oOOo oOOo oOOOOOOOOOOo
; OOOO OOOo OOOO OOOO OOOOO
; OOOO OOOo OOOO OOOO OOOOO
; OOOOOo OOOO OOOOOOOOOOOOO OOOOOOOOOOOo
; OOOOOO OOOO OOOOOo OOOO OOOOOO
; OOOOOO OOOO OOOOOO OOOO OOOOOO
; OOOOOO OOOO OOOOOO OOOO OOOOOO
; OOOOOO OOOO OOOOOO OOOO OOOOOO
; OOOOOOOOO OOOOOO OOOO oOOOOOOOOOOO
;
; Dead Hackers Society Falcon Demoshell v15
; November 3, 1999 - February 8, 2004
;
; Recent changes/fixes:
;
; November 16, 2003: CT60-fixed DSPMOD
; January 20, 2004: Fixed Dsp_Lock(), Locksnd() and fgetdta()
; February 07, 2004: Timer routines run at 300Hz rather than 100Hz
; (even by 100, 60 and 50Hz-VBL's) should make
; varaible-framerate effects look a bit smoother.
; Timing table for sequencer stands att 100Hz.
; February 07, 2004: Removed lame buggy FPS counting, will make a new
; better one later.
; February 08, 2004: I introduced a silly bug in v14 that made no
; timer routines run! Argh. Fixed now.
; Additionally I had put the wrong timer-divide
; value.. Error errors errors.. I hope it's OK now!
;
;
; Bugreports to:
;
; Anders Eriksson
;
;
; mpeg 1 layer 2 player: Noring and Nobrain of NoCrew
; soundtracker replay: Bitmaster / TCE
; video save/restore: Aura & Mugwumps
;
; main.s
;
; Check at the bottom of this file for init-list, includes,
; and demo sequencer part-list.
opt D+,X+
opt p=68030/68882,NOCASE ;68030+68882 code allowed
comment HEAD=%111 ;fastload/loadalt/mallocalt = ON
v_scr_w: equ 320
v_scr_h: equ 240
scr_w: equ 320 ;width (x - in pixels)
scr_h: equ 240 ;height (y - in pixels)
scr_d: equ 2 ;depth (in bytes)
startupmenu: equ 0 ;1 = enable startup menu
dspmodmusic: equ 0 ;1 = use dspmod music
mp2music: equ 1 ;1 = use mpeg1 layer 2 music
;select which mod or mp2 file
;to load in sys/dspmod.s or
;sys/mp2.s
pause: equ 0 ;1 = enable pause on left-shift
cputime: equ 0 ;1 = enable vbl-time on control
def_vga_freq: equ 60 ;VGA frequency (60 or 100Hz)
def_rgb_freq: equ 50 ;RGB frequency (50 or 60Hz)
def_detailmode: equ 1 ;Detail mode (just a dumb flag for demos
;supporting more than one level of detail)
; --------------------------------------------------------------
section text
; --------------------------------------------------------------
include 'sys\init.s' ;init demosshell
; --------------------------------------------------------------
; mainloop
; --------------------------------------------------------------
mainloop:
ifne pause
cmp.b #$2a,$fffffc02.w ;pause
beq.s .done ;
endc
move.w .var,d0 ;wait for next vbl always
cmp.w vblwait,d0 ;
beq.s .done ;
.waitdone: move.l main_routine,a0 ;main routine
jsr (a0) ;
move.w vblwait,.var ;later use
cmp.l #2,swapscreens ;number of screens to cycle
blt.s .done ;
lea.l screen_adr1,a0 ;
bgt.s .swap3 ;
.swap2: move.l (a0),d0 ;cycle 2 screens
move.l 4(a0),(a0)+ ;
move.l d0,(a0) ;
bra.s .done ;
.swap3: move.l (a0),d0 ;cycle 3 screens
move.l 4(a0),(a0)+ ;
move.l 4(a0),(a0)+ ;
move.l d0,(a0) ;
.done:
ifne cputime
cmp.b #$1d,$fffffc02.w
bne.s .nocpu
move.l #$000000ff,$ffff9800.w
.nocpu:
endc
bra mainloop
.var: ds.w 1
; --------------------------------------------------------------
; vbl 50-100 Hz
; --------------------------------------------------------------
vbl: movem.l d0-a6,-(sp)
ifne pause
cmp.b #$2a,$fffffc02.w ;pause
beq.s .done ;
endc
ifne cputime
cmp.b #$1d,$fffffc02.w
bne.s .nocpu
clr.l $ffff9800.w
.nocpu:
endc
cmp.l #2,swapscreens ;set screen_adr
bge.s .no ;
move.l screen_adr,d0 ;single set
cmp.l .var,d0 ;
beq.s .noset ;
move.l d0,.var ;
bra.s .set ;
.no: move.l screen_adr1,d0 ;double/tripple set
cmp.l .var,d0 ;
beq.s .noset ;
move.l d0,.var ;
.set: move.l d0,d1 ;set screen
lsr.w #8,d0 ;
move.l d0,$ffff8200.w ;
move.b d1,$ffff820d.w ;
.noset: move.l vbl_routine,a0 ;vbl
jsr (a0) ;
addq.w #1,vblwait ;inc vbl
ifne dspmodmusic
bsr.w dspmod_vbl ;modplayer
endc
.done: movem.l (sp)+,d0-a6
rte
.var: ds.l 1
; --------------------------------------------------------------
; timer-d 100 Hz
; --------------------------------------------------------------
timer_d: movem.l d0-a6,-(sp)
ifne pause
cmp.b #$2a,$fffffc02.w ;pause
beq.s .done2 ;
endc
subq.w #1,.var ;300->100Hz sequencer
bne.s .skip_sequence ;
move.w #3,.var ;
move.l current_fx,a0 ;current position
lea.l timer_routine,a1 ;routinelist
subq.l #1,(a0)+ ;dec
bne.s .done ;0=next part
add.l #24,current_fx ;next part
.done: move.l (a0)+,(a1)+ ;timer routine
move.l (a0)+,(a1)+ ;vbl routine
move.l (a0)+,(a1)+ ;main routine
move.l (a0)+,(a1)+ ;screens to cycle
move.l (a0),(a1) ;vblwait type
.skip_sequence: move.l timer_routine,a2
jsr (a2) ;timer routine
.nah:
.done2: movem.l (sp)+,d0-a6
bclr #4,$fffffa11.w ;clear busybit
rte
.var: dc.w 3
; --------------------------------------------------------------
; subroutines & includes
; --------------------------------------------------------------
dummy: rts
blackpal: lea.l $ffff9800.w,a0 ;black palette
move.w #256-1,d7 ;
.loop: clr.l (a0)+ ;
dbra d7,.loop ;
rts ;
include 'sys\exit.s' ;exit routines
include 'sys\video.s' ;videolib
include 'sys\loader.s' ;loader rout
ifne startupmenu ;
include 'sys\startup.s' ;startup menu
endc ;
include 'gfx.s'
include 'data\gamovrbx.s'
include 'backgrnd.s'
include 'grid.s'
include 'joy.s'
include 'game.s'
include 'menu.s'
include 'util.s'
include 'setup.s'
include 'font.s'
include 'data\red.s'
include 'data\blue.s'
include 'data\yellow.s'
include 'data\purple.s'
include 'data\green.s'
ifne dspmodmusic ;
include 'sys\dspmod.s' ;tracker player
endc ;
ifne mp2music ;
include 'sys\mp2.s' ;mpeg player
endc ;
include 'sfx.s'
; --------------------------------------------------------------
section data
; --------------------------------------------------------------
even
; videomode settings
; see video.s for available resolutions and how to set them
monitor: dc.w 0 ;0=vga 1=rgb/tv (init.s auto detect)
vga_freq: dc.w def_vga_freq ;60/100 Hz
rgb_freq: dc.w def_rgb_freq ;50/60 Hz
detail: dc.w def_detailmode ;0=low 1=high
; initroutines to run before demo starts
;
; REMEMBER!
; Always start music at the end! Or you will get unsynced
; with the music on machines with different speed than your own!
;
; list ends with dc.l 0
inits:
dc.l video_5 ;set resolution
dc.l setup_all ;general loading
ifne dspmodmusic ;
dc.l dspmod_load ;load module/reserve mem
dc.l dspmod_begin ;init musicroutine
endc ;
ifne mp2music ;
dc.l mp2_load ;load mpeg file/reserve mem
dc.l mp2_begin ;init mpeg rout and start playing
endc
dc.l 0
; demo sequencer list
;
; dc.l ticks,timer,vbl,main,screens,vblwait
;
; ticks : 100Hz frames to run part
; timer : address to timer routine (routine runs att 300Hz)
; vbl : address to vbl routine
; main : address to main routine
; screens : number of screens to cycle. valid options:
; 1 = singlebuffer
; 2 = doublebuffer
; 3 = tripple buffer
; lower vales are treated as single buffer and
; higher values as tripple buffer
; vblwait : mainloop wait for vbl.
; 0 = waitvbl if efx run faster than 1 vbl (tripplebuffer only!)
; 1 = always waitvbl (even if efx is multivbl (always with single/doublebuffer!))
demo_parts:
;dummy effect doing nothing
; seq_setup: dc.l 0,dummy,dummy,setup_all,1,1
seq_menuinit: dc.l 0,dummy,dummy,main_menu_init,1,1
seq_menuloop: dc.l 0,dummy,dummy,main_menu_loop,1,1
seq_gameinit: dc.l 0,dummy,dummy,game_init,1,1
seq_gameloop: dc.l 0,dummy,dummy,game_loop,2,1
seq_gameover: dc.l 0,dummy,dummy,game_over_loop,1,1
;exit demo
seq_exit: dc.l -1,dummy,dummy,exit,1,1
current_fx: dc.l demo_parts ;current
timer_routine: dc.l dummy ;timer
vbl_routine: dc.l dummy ;vbl
main_routine: dc.l dummy ;main
swapscreens: ds.l 1 ;screens
vblsync: ds.l 1 ;vblwait
; -------------------------
section bss
; --------------------------------------------------------------
even
runlevel: ds.w 1
vblwait: ds.w 1 ;for fx in less than 1vbl
screen_adr1: ds.l 1 ;screen address 1
screen_adr: ;WORK ADDRESS!
screen_adr2: ds.l 1 ;screen address 2
screen_adr3: ds.l 1 ;screen address 3
save_stack: ds.l 1 ;old stackpointer
save_timer_d: ds.l 1 ;old timer-d
save_keyboard: ds.l 1
save_vbl: ds.l 1 ;old vbl
save_mfp: ds.l 2 ;old mfp
save_dta: ds.l 1 ;old dta address
save_pal: ds.l 256+8 ;old colours (falcon+st/e)
save_video: ds.b 32+12+2 ;videl save
save_keymode: ds.w 1 ;old keyclick mode
save_cacr: ds.l 1
dta: ds.l 11 ;new dta buffer
end