-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathap.s
12621 lines (12084 loc) · 185 KB
/
ap.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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;OK, add a cheat mode!
;
;adding chat-line...
;
;OK, modem stuff...
;
;Once 2 machines are linked, player 1 gets to choose options!
;player 2 is ignored...
;
;player 1 if linked=1, 2 if linked=-1
;*********
;* GLOOM *
;*********
;
;error codes
;
;red - allocmem failed
;yel - freemem failed
;orange - unknown script command
;purp - unknown event command
;cyn - can't open file in loadfile
;blu - ran out of remap colours!
ok equ 750+125 ;overkill level!
;
cy equ 166
pl_eyey equ 110
pl_firey equ 60
pl_gutsy equ 64
debugser equ 0
debugmem equ 0
onedemo equ 0
;
ireload equ 5 ;initial reload val.
maxobjects equ 256 ;max objects in game
maxdoors equ 16 ;max doors opening at once
maxblood equ 128 ;max droplets of bluuurd
maxgore equ 128 ;body parts on ground!
maxrotpolys equ 32 ;max rotating thingys.
;
focshft equ 6
grdshft equ 8
darkshft equ 7 ;smaller=smaller range=faster!
maxz equ 16<<darkshft ;16*128=2048*8=16384
;
exshft equ 3
exone equ 1<<exshft
exhalf equ exone>>1
;
linemod equ 40*7
jmp entrypoint
rsreset
;
;rotpoly details...
;
rp_next rs.l 1
rp_prev rs.l 1
;
rp_speed rs.w 1
rp_rot rs.w 1
rp_flags rs.w 1 ;what to do?
;
rp_cx rs.w 1 ;only for rot
rp_cz rs.w 1
rp_first rs.l 1 ;pointer to first!
rp_num rs.w 1
;
rp_vx rs.w 0
rp_lx rs.w 1
rp_vz rs.w 0
rp_lz rs.w 1
rp_ox rs.w 0
rp_na rs.w 1
rp_oz rs.w 0
rp_nb rs.w 1
;
rp_more rs.b 8*31 ;=32 max verts!
;
rp_size rs.b 0
rsreset
;
;sfx channel info
;
fx_status rs.w 1
fx_priority rs.w 1
fx_sfx rs.l 1
fx_vol rs.w 1
fx_offset rs.w 1
fx_dma rs.w 1
fx_int rs.w 1
;
fx_size rs.b 0
rsreset
;
;blood!
;
bl_next rs.l 1
bl_prev rs.l 1
bl_x rs.l 1
bl_y rs.l 1
bl_z rs.l 1
bl_xvec rs.l 1
bl_dest rs.l 0
bl_yvec rs.l 1
bl_zvec rs.l 1
bl_color rs.l 1 ;colour and!
;
bl_size rs.b 0
rsreset
;
;a texture
;
te_pal rs.l 1
;
te_size rs.b 0
rsreset
;
;an opening/closing door!
;
do_next rs.l 1
do_prev rs.l 1
do_poly rs.l 1 ;door polygon
do_lx rs.w 1
do_lz rs.w 1
do_rx rs.w 1
do_rz rs.w 1
do_frac rs.w 1
do_fracadd rs.w 1
;
do_size rs.b 0
rsreset
;
;wall list...
;
wl_next rs.l 1
wl_lsx rs.w 1 ;leftmost screen X
wl_rsx rs.w 1 ;rightmost screen X
wl_nz rs.w 1 ;near Z!
wl_fz rs.w 1 ;far Z!
wl_lx rs.w 1
wl_lz rs.w 1
wl_rx rs.w 1
wl_rz rs.w 1
wl_a rs.w 1
wl_b rs.w 1
wl_c rs.l 1
wl_sc rs.w 1
wl_open rs.w 1 ;0=door shut, $4000=open!
wl_t rs.b 8 ;textures
;
wl_size rs.b 0
rsreset
;
;a zone...
;
zo_done rs.w 1
zo_lx rs.w 1
zo_lz rs.w 1
zo_rx rs.w 1
zo_rz rs.w 1
;
zo_a rs.w 1
zo_b rs.w 1
zo_na rs.w 1
zo_nb rs.w 1
zo_ln rs.w 1
;
zo_t rs.b 8 ;8 textures
;
zo_sc rs.w 1 ;scale (how many txts on wall)
zo_open rs.w 0 ;for wall polys...
zo_ev rs.w 1 ;for events...
;
zo_size rs.b 0 ;32!
rsreset
;
;a shape to draw!
;
sh_next rs.l 1
sh_prev rs.l 1
sh_x rs.w 1
sh_y rs.w 1
sh_z rs.w 1
sh_shape rs.l 1
sh_scale rs.w 0
sh_strip rs.l 1
sh_render rs.l 1 ;drawobjnorm or drawobjinvs
;
sh_size rs.b 0
rsreset
;
;gore...body parts lying around!
;
go_next rs.l 1
go_prev rs.l 1
go_x rs.w 1
go_z rs.w 1
go_shape rs.l 1
;
go_size rs.b 0
rsreset
;
;an object in the game (player/alien etc...)
;
ob_next rs.l 1
ob_prev rs.l 1
ob_x rs.l 1
ob_y rs.l 1
ob_z rs.l 1
ob_rot rs.l 1
;
;start of info load by prog.
ob_info rs.b 0
;
ob_rotspeed rs.l 1
ob_movspeed rs.l 1
ob_shape rs.l 1
ob_logic rs.l 1
ob_render rs.l 1
ob_hit rs.l 1 ;routine to do when damaged
ob_die rs.l 1 ;routine to do when killed
ob_eyey rs.w 1 ;eye height
ob_firey rs.w 1 ;where bullets come from
ob_gutsy rs.w 1
ob_mega rs.w 0
ob_othery rs.w 1
ob_colltype rs.w 1
ob_collwith rs.w 1
ob_cntrl rs.w 1
ob_damage rs.w 1
ob_hitpoints rs.w 1
ob_think rs.w 1
ob_frame rs.l 1 ;anim frame
ob_framespeed rs.l 1 ;anim frame
ob_base rs.w 1
ob_range rs.w 1
ob_weapon rs.w 1 ;weapon meter (0...4)
ob_reload rs.b 1 ;weapon reload timer
ob_reloadcnt rs.b 1 ;counter
ob_hurtpause rs.w 1
ob_firerate rs.w 0
ob_punchrate rs.w 1
ob_bouncecnt rs.w 1 ;how many times my bullets bounce!
ob_firecnt rs.w 0
ob_something rs.w 1
ob_scale rs.w 1 ;scale factor for drawing
ob_lastbut rs.w 1
ob_blood rs.w 1 ;color AND for blood
ob_ypad rs.w 1
;
ob_oldlogic rs.l 1
ob_oldlogic2 rs.l 1
ob_oldhit rs.l 1
ob_olddie rs.l 1
ob_oldrot rs.w 1
ob_newrot rs.w 1
ob_yvec rs.l 1
ob_xvec rs.l 1
ob_zvec rs.l 1
ob_radsq rs.l 1 ;radius squared
ob_rad rs.w 1
ob_delay rs.w 1
ob_delay2 rs.w 0
ob_bounce rs.w 1
ob_hurtwait rs.w 1
;
ob_washit rs.l 1 ;flag for un-hit coll detect!
ob_window rs.l 1 ;pointer back to window!
ob_nxvec rs.w 0 ;normalized X vec
ob_lives rs.w 1
ob_nzvec rs.w 0 ;nomralized z vec
ob_infra rs.w 1
ob_thermo rs.w 1
ob_invisible rs.w 1
ob_hyper rs.w 1
ob_update rs.w 1 ;update stats!
ob_mess rs.l 1 ;message
ob_messlen rs.w 1
ob_messtimer rs.w 1 ;timer for messages
ob_palette rs.l 1 ;palette for window
ob_paltimer rs.w 1 ;timer before back to normal
ob_pixsize rs.w 1
ob_pixsizeadd rs.w 1
ob_telex rs.w 1
ob_telez rs.w 1
ob_telerot rs.w 1
ob_chunks rs.l 1
;
ob_size rs.b 0
rsreset
;
;solid wall draw data
;
vd_z rs.w 1 ;current Z
vd_pal rs.w 1 ;palette# (0...15)
vd_y rs.w 1
vd_h rs.w 1
vd_data rs.l 1
vd_ystep rs.l 1
;
vd_size rs.b 0
rsreset
;
;palette file...
;
pa_numcols rs.w 1 ;how many colours
pa_cols rs.w 256 ;the colours!
rsreset
;
;anim file...
;
an_rotshft rs.w 1
an_frames rs.w 1
an_maxw rs.w 1
an_maxh rs.w 1
an_pal rs.l 1
;
an_size rs.b 0
rsreset
;
;window
;
wi_slice rs.l 1 ;slice window appears in!
wi_nslice rs.l 1 ;next slice to disp.
wi_x rs 1
wi_y rs 1
wi_w rs 1 ;how many chixels across
wi_h rs 1 ;how many down
wi_pw rs 1 ;width of 1 chixel
wi_ph rs 1 ;hite of 1 chixel
;
wi_bw rs 1 ;bitmap width
wi_bh rs 1 ;bitmap height
;
wi_bmapmem rs.l 1
wi_copmem rs.l 1
wi_bmap rs.l 1
wi_cop rs.l 1
wi_cop1 rs.l 1
wi_cop2 rs.l 1
wi_copmod rs.w 1
;
wi_strip rs.l 1
wi_iff rs.l 1 ;show iff instead!
wi_pal rs.l 1 ;palette for IFF!
;
wi_size rs.b 0
key macro
btst #\1&7,\1>>3(a0)
endm
keya1 macro
btst #\1&7,\1>>3(a1)
endm
qkey macro
move.l rawtable(pc),a0
key \1
endm
freemem macro
;
ifne debugmem
lea .fmem\@,a0
jsr freemem_
bra .fmemskip\@
.fmem\@ dc.b '\1',0
even
.fmemskip\@ ;
elseif
jsr freemem_
endc
;
endm
allocmem macro
;
ifne debugmem
;
lea .amem\@,a0
jsr allocmem_
bra .amemskip\@
.amem\@ dc.b '\1',10,0
even
.amemskip\@ ;
elseif
;
jsr allocmem_
;
endc
;
endm
allocmem2 macro
;
ifne debugmem
;
lea .amem\@,a0
jsr allocmem2_
bra .amemskip\@
.amem\@ dc.b '\1',10,0
even
.amemskip\@ ;
elseif
;
jsr allocmem2_
;
endc
;
endm
alloclist macro ;alloclist listname,maxitems,itemsize
;
move.l \2,d0
move.l \3,d1
lea \1(pc),a2
jsr k_alloclist
bra.s alskip\@
;
\1 dc.l 0 ;0
\1_last dc.l 0 ;4
dc.l 0 ;8
\1_free dc.l 0 ;12
alskip\@ ;
endm
k_alloclist ;a2=address of 'first' pointer
;d0=max items, d1=item size
;
move.l a2,8(a2) ;clear out used list
lea 4(a2),a0
clr.l (a0)
move.l a0,(a2)
movem.l d0-d1,-(a7)
mulu d1,d0
move.l #$10001,d1
allocmem alloclist
move.l d0,a0
lea 12(a2),a2
movem.l (a7)+,d0-d1
subq #1,d0
.loop move.l a0,(a2)
move.l a0,a2
add d1,a0
dbf d0,.loop
rts
addnext macro
;
;addnext 'listname'
;add after a5
;return eq if none available else a0
;
move.l \1_free,d0
beq.s .anskip\@
move.l d0,a0
move.l (a0),\1_free
move.l (a5),a1
move.l a1,(a0)
move.l a0,4(a1)
move.l a0,(a5)
move.l a5,4(a0)
.anskip\@ ;
endm
addfirst macro
;
;addfirst 'listname'
;return eq if none available else a0
;
move.l \1_free,d0
beq.s .afskip\@
move.l d0,a0
move.l (a0),\1_free
move.l \1,a1 ;current first
move.l a1,(a0)
move.l a0,4(a1)
move.l a0,\1
move.l #\1,4(a0)
.afskip\@ ;
endm
addlast macro
;
;addlast 'listname'
;return eq in none available else a0
;
move.l \1_free,d0
beq.s .alskip\@
move.l d0,a0
move.l (a0),\1_free
;
move.l \1_last+4,a1 ;current last
move.l a0,(a1)
move.l a1,4(a0)
move.l a0,\1_last+4
move.l #\1_last,(a0)
.alskip\@ ;
endm
killitem macro
;
;killitem listname
;a0=item to kill, return a0=previous item.
;
move.l (a0),a1 ;next of me!
move.l 4(a0),4(a1)
move.l 4(a0),a1 ;prev of me
move.l (a0),(a1)
move.l \1_free,(a0)
move.l a0,\1_free
move.l a1,a0
endm
clearlist macro
;
;clearlist listname
;
.clloop\@ move.l \1,a0
tst.l (a0)
beq .cldone\@
killitem \1
bra .clloop\@
.cldone\@ ;
endm
zerolist macro listname,size of item
;
;fill all list items with 0!
;
clearlist \1
.zlloop\@ addlast \1
beq .zlskip\@
lea 8(a0),a1
moveq #0,d0
move #(\2-8)/2-1,d1
.zlloop2\@ move d0,(a1)+
dbf d1,.zlloop2\@
bra .zlloop\@
.zlskip\@ clearlist \1
;
endm
bwait macro
;
.bwait\@ btst #6,$dff002
beq.s .bwait2\@
bra.s .bwait\@
.bwait2\@ ;
endm
printlong macro
move.l \1,-(a7)
jsr printlong_
endm
check macro
list
check set *-\1
nolist
endm
push macro
movem.l d2-d7/a2-a6,-(a7)
endm
pull macro
movem.l (a7)+,d2-d7/a2-a6
endm
col macro
move #0,$dff106
move \1,$dff180
endm
warn macro
move d0,-(a7)
move #-1,d0
.wloop\@ col \1
dbf d0,.wloop\@
move (a7)+,d0
endm
tempfile ds.b 64
wbmess dc.l 0 ;workbench message!
entrypoint ;
clr.l map_test
move.l 4.w,a6
move.l 276(a6),a5 ;task
tst.l $ac(a5) ;cli?
bne.s cli
;
lea $5c(a5),a0
jsr -384(a6) ;waitport
lea $5c(a5),a0
jsr -372(a6) ;get message
move.l d0,wbmess
bra wb
cli ;
cmp.b #'@',(a0)+
bne.s wb
lea tempfile,a1
move.l a1,map_test
.loop move.b (a0)+,(a1)
beq.s wb
cmp.b #10,(a1)+
bne.s .loop
clr.b -(a1)
wb ;
lea dosname,a1
move.l 4.w,a6
jsr -408(a6)
move.l d0,dosbase
;
move.l d0,a6
jsr -60(a6)
move.l d0,outhand
;
move.l wbmess(pc),d0
beq.s .nocd
move.l d0,a0
move.l $24(a0),a0
move.l (a0),d1
move.l dosbase,a6
jsr -126(a6)
.nocd ;
jsr initmain
bsr bigfont
;
.intro move.l medat(pc),a1
move.l titlemed(pc),a0
jsr 8(a1) ;start title music!
;
.intro2 jsr dointro ;returns gametype
;
cmp #3,gametype
bcs.s .play
move.l medat(pc),a1
jsr 12(a1)
bra.s exittoos
.play ;
bsr initnewgame
tst gametype
bmi .intro2
;
bsr smallfont
tst twowins
beq.s .n2
bsr swaphflags
.n2 bsr execscript_med
.wmf tst fadevol
bne.s .wmf
tst twowins
beq.s .n22
bsr swaphflags
.n22 bsr bigfont
bra .intro
;
exittoos bsr freeobjlist2
move #$4000,$dff09a
move.l ciaa,a0
movem.l rawstuff,d0-d1
movem.l d0-d1,$64(a0)
move #$c000,$dff09a
jsr permit
jsr finitdisplay
jsr finitvbint
jsr finitsfx
jsr finitser
jsr freememlist
jsr undir
;
move.l wbmess(pc),d0
beq.s .bye
;
move.l 4.w,a6
move.l d0,a1
jsr -378(a6)
clr.l wbmess
;
.bye rts
; ************* FAST SUBS ********************
fastsubs
swaphflags movem.l floorflag(pc),d0-d1
move.l d1,floorflag
move.l d0,floorflag2
rts
smallfont move #6,fontw
move #8,fonth
move.l smallfont_,font
rts
bigfont move #8,fontw
move #10,fonth
move.l bigfont_,font
rts
encodejoy ;a0=cntrl block to encode...
;return d0 encoded
;
;bit:
;0 = joyx -1
;1 = joyx 1
;2 = joyy -1
;3 = joyy 1
;4 = joyb true
;5 = joys true
;
moveq #0,d0
;
tst (a0)
beq.s .skipx
bpl.s .x1
bset #0,d0
bra.s .skipx
.x1 bset #1,d0
.skipx tst 2(a0)
beq.s .skipy
bpl.s .y1
bset #2,d0
bra.s .skipy
.y1 bset #3,d0
.skipy tst 4(a0)
beq.s .skipb
bset #4,d0
.skipb tst 6(a0)
beq.s .skipf
bset #5,d0
.skipf ;
rts
decodejoy ;
;d0.b = encoded byte...
;a0 = block to fill
;
;0 = joyx -1
;1 = joyx 1
;2 = joyy -1
;3 = joyy 1
;4 = joyb true
;5 = joys true
;
clr (a0)
move d0,d1
and #3,d1
beq.s .skipx
cmp #1,d1
bne.s .x1
move #-1,(a0)
bra.s .skipx
.x1 move #1,(a0)
.skipx clr 2(a0)
move d0,d1
and #12,d1
beq.s .skipy
cmp #4,d1
bne.s .y1
move #-1,2(a0)
bra.s .skipy
.y1 move #1,2(a0)
.skipy btst #4,d0
sne d1
ext d1
move d1,4(a0)
btst #5,d0
sne d1
ext d1
move d1,6(a0)
rts
sfxs ;
sfx0 ds.b fx_size
sfx1 ds.b fx_size
sfx2 ds.b fx_size
sfx3 ds.b fx_size
sfxintserver0 dc.l 0,0
dc.b 2,0
dc.l 0
dc.l sfx0
dc.l sfxint
sfxintserver1 dc.l 0,0
dc.b 2,0
dc.l 0
dc.l sfx1
dc.l sfxint
sfxintserver2 dc.l 0,0
dc.b 2,0
dc.l 0
dc.l sfx2
dc.l sfxint
sfxintserver3 dc.l 0,0
dc.b 2,0
dc.l 0
dc.l sfx3
dc.l sfxint
initsfx push
move.l 4.w,a6
;
moveq #7,d0
lea sfxintserver0,a1
jsr -162(a6) ;setintvector
;
moveq #8,d0
lea sfxintserver1,a1
jsr -162(a6)
;
moveq #9,d0
lea sfxintserver2,a1
jsr -162(a6)
;
moveq #10,d0
lea sfxintserver3,a1
jsr -162(a6)
;
lea sfxs(pc),a1
move #$80,d0
moveq #1,d1
moveq #0,d2
moveq #3,d3
.loop bsr .init
lea fx_size(a1),a1
dbf d3,.loop
;
pull
rts
;
.init clr fx_status(a1)
move d0,fx_int(a1)
move d1,fx_dma(a1)
move d2,fx_offset(a1)
add d0,d0
add d1,d1
add #16,d2
rts
finitsfx push
move.l 4.w,a6
;
moveq #7,d0
sub.l a1,a1
jsr -162(a6)
;
move.l 4.w,a6
moveq #8,d0
sub.l a1,a1
jsr -162(a6)
;
move.l 4.w,a6
moveq #9,d0
sub.l a1,a1
jsr -162(a6)
;
move.l 4.w,a6
moveq #10,d0
sub.l a1,a1
jsr -162(a6)
;
pull
rts
waitquiet bsr vwait
lea sfxs(pc),a0
moveq #3,d0
.loop tst fx_status(a0)
bne.s waitquiet
lea fx_size(a0),a0
dbf d0,.loop
rts
playsfx ;sfx file in a0, vol in d0, priority in d1
;
move #$4000,$dff09a ;snd/vb ints off
;
lea sfxs(pc),a1
moveq #3,d2
.loop tst fx_status(a1)
beq.s makesfx
lea fx_size(a1),a1
dbf d2,.loop
;
;OK, none free...check priorities
;
lea sfxs(pc),a1
moveq #3,d2
.loop2 cmp fx_priority(a1),d1
bgt.s queuesfx
lea fx_size(a1),a1
dbf d2,.loop2
;
;no-can-do!
;
move #$c000,$dff09a
rts
;
queuesfx ;OK, turn off other and play US!
;
move #1,fx_status(a1)
move d0,fx_vol(a1)
move d1,fx_priority(a1)
move.l a0,fx_sfx(a1) ;play me next!
;
bsr sfxoff
;
move #$c000,$dff09a
rts
sfxoff lea $dff0a0,a2
add fx_offset(a1),a2
move.l chipzero(pc),(a2)
move #1,4(a2) ;len
move #0,8(a2) ;vol
move fx_int(a1),$dff09a
move fx_dma(a1),$dff096
rts
makesfx ;OK, play this SFX NOW!
;
move d1,fx_priority(a1)
move d0,fx_vol(a1)
bsr playsfxnow
move #$c000,$dff09a
rts
playsfxnow move #-2,fx_status(a1)
;
lea $dff0a0,a2
add fx_offset(a1),a2
move (a0)+,6(a2) ;period
move (a0)+,4(a2) ;len
move fx_vol(a1),8(a2) ;vol
move.l a0,(a2) ;data
;
move fx_dma(a1),d0 ;dma bits
or #$8000,d0
move fx_int(a1),d1 ;int bits
move d1,d2
or #$8000,d1
;
move d0,$dff096 ;dma on!
move d1,$dff09a ;int en
move d2,$dff09c ;intreq clr
;
rts
sfxint ;interupt for sfx!
;
tst fx_status(a1)
bge.s .skip
addq #1,fx_status(a1)
blt.s .skip
;
move.l a2,-(a7)
bsr sfxoff
move.l (a7)+,a2
;
.skip move fx_int(a1),$dff09c
moveq #0,d0
rts
dogamemenu ;
move #$20,$dff09a
;
st paused
move framecnt,-(a7)
move linked,-(a7)
clr linked
;
move #$8020,$dff09a
;