-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathDISPLAY.ASM
executable file
·3290 lines (2596 loc) · 59.9 KB
/
DISPLAY.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
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
*ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
*³ ³
*³ File : display.asm ³
*³ Contents : DMA object handler ³
*³ Project : WWF Wrestlemania ³
*³ Programmer : ³
*³ ³
*³ COPYRIGHT (C) 1993 WILLIAMS ELECTRONICS GAMES, INC. ³
*³ ³
*ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
*************************************************************************
.file "display.asm"
.title "DMA object handler"
.width 132
.option b,d,l,t
.mnolist
.include "gsp.equ"
.include "sys.equ"
.include "mproc.equ"
.include "display.equ"
.include "macros.h"
.include "fontsimg.glo"
.include "game.equ"
.INCLUDE "PLYR.EQU"
******************************************************************************
* EXTERNAL REFERENCES
.REF process_ptrs
.ref special_screen
.REF DUMRETS,WHICH_SCREEN
.REF TOP_LEFT,BOT_RIGHT
.def clear_objs
.ref FRANIMQ
.ref HALT
.ref SYSCOPY
.ref pal_getf
.ref IRQSKYE
******************************************************************************
;global variables
.sect "OFIXED"
OBJLST .long 0 ;*Active object list
OFREE .long 0 ;*Free object block
BAKLST .long 0 ;*Background list
GND_Y .equ 116-40
GNDI_Y .equ 116
GNDI_W .equ 1277
GNDI_H .equ 138
GND_H .equ GNDI_H+40
GZBASE .equ 894
.bss present_pos,16
BSSX page_addr,32
.bss SCROLLX ,32 ;X scroll value
.bss SCROLLY ,32 ;Y scroll value
;/ Must stay in order
.bss WORLDTLX ,32 ;Left X screen coord (16:16)
.bss WORLDTLY ,32 ;Top Y screen coord (16:16)
.bss WORLDTL ,32 ;Top left world Y:X
.bss SCRNTL ,32 ;TOP LEFT [Y,X] SCREEN (SCRN COORD.)
.bss SCRNLR ,32 ;LOWER RIGHT [Y,X] SCREEN (SCRN COORD.)
.bss dpage ,16 ;Display page; 0=Page0, -1=Page1
BSSX dtype ,16 ;Display type; 0=2D, 1=3D, -=Special
BSSX dcode_p ,32 ;!0=*Special code (^ must = neg)
.bss DMAQCUR ,32 ;Misc DMAQ position
.bss OBJSTR,NOBJ*OBSIZ ;Object structure mem
QSIZE .set (NOBJ+GNDI_H)*BQCELL
QMSIZE .set NOBJ*BQCELL
.bss dmaq0 ,QSIZE ;Main DMA queue
BSSX DMAQ ,QMSIZE ;Misc DMA queue
BSSX gndstat ,16 ;!0=Show ground
BSSX gndpos_t ,16*GND_H
BSSX gndx ,32
.bss DISPLAYON ,16 ;!0=Do display processing
; BSSX QDMAFLG ,16 ;!0=Misc DMAQ being updated
BSSX _3dstat ,16 ;!0=Show polygons
BSSX dma_foo ,32
.text
******************************************************************************
* NO CODE BEFORE DMA INT!!! (Cache aligned)
*
#*****************************************************************************
* DMA interrupt
* B12=*End of DMA regs
* B13=DMAQ count-1 or Neg
* B14=*Next DMAQ fetch
SUBR dma_irq
;temp!
; move b14,@dma_foo,L
move -*b14,-*b12,L ;[Y SCALE : X SCALE]
move -*b14,-*b12,L ;[COLOR CONST : PAL REGISTER]
move -*b14,-*b12,L ;[HEIGHT : WIDTH]
move -*b14,-*b12,L ;[DEST Y : DEST X]
move -*b14,-*b12,L ;[SOURCE ADDRESS]
move -*b14,-*b12,L ;[CNTRL REG-DMA go! : OFFSET/CLIP]
addi 0c0h,b12 ;DMAREGS (End of DMA)
subk 1,b13
jrn #done ;Queue empty?
RETI
push b11
move @present_pos,b11
cmp b11,b13
jreq do_shadows
pull b11
reti
#done
setf 1,0,0 ;Disable dma interrupt
move b12,@INTENB+1 ;Clr X1E
clr b13 ;For safety!
subk 1,b13 ;-1
reti
do_shadows
pull b11
pushst
dint
callr PLACE_SHADOWS
popst
reti
#*****************************************************************************
* Load DMA Q from obj list (2D type)
* A0=*Obj list
* A4=*DMAQ next free spot
* A13=Screen BR, A14=Screen TL
* B2=Y offset for top of page : XPad offset
* B4=World Y:X
* B5=OFLAGS offset
* B6=World center scrn X * 64K
* B11=*DMACTRL
dma_objlst2d
; movi [100h,100h],a5 ;A5=Y:X scale
jruc #nxt
.align
#lp
MOVE *A0(OFLAGS),A1
BTST B_NODISP,A1
JRNZ #nxt
move *a0(OSCALE),a5,L
move b5,a3
add a0,a3
move *a3+,a1 ;Get OFLAGS
mmfm a3,a12,a11,a9,a8
move *a0(OYVAL),a10,L ;Get int Y
move *a0(OXPOS),a2 ;X
movx a2,a10 ;A10=Obj Y:X
btst B_SCRNREL,a1
jrnz #noscl ;Screen relative XY?
move b4,a6 ;A6=World TL Y:X
subxy a6,a10 ;-world coord to get screen coord
#noscl
;A8=Const:PAL
;A9=HEIGHT:WIDTH
;A10=Dest Y:X
;A11=*SAG
;A12=Offset:Ctrl
btst B_BOBJ,a1
jrnz #is_bgnd_obj
move *a0(ODOFF),a3,L ;display offset Y:X
btst B_FLIPH,a12
jrz #no_x_flip0
movx a3,a2
neg a2
dec a2 ; -1
addxy a9,a2 ;- image width (gets added later)
movx a2,a3
#no_x_flip0
; btst B_FLIPV,a12
; jrz #no_y_flip0
;
; move a3,a2
; srl 16,a2
; neg a2
; dec a2 ; -1
; sll 16,a2
; addxy a9,a2 ;- image height (gets added later)
; movy a2,a3
;
;#no_y_flip0
subxy a3,a10
#is_bgnd_obj
;Check for flipping, clipping, adjust offset, sag
;Calc top,bot,left,right clips
;a2 = BR clip size
clr a3 ;a3 = TL clip size
move a10,a2 ;Dest Y:X
addxy a9,a2 ; + HEIGHT:WIDTH = BR Y:X
subxy a13,a2 ;A2=BR clip size
JRYGE #clip_bot
movy a3,a2 ;no bot clip if y neg
#clip_bot
JRXGE #clip_right
movx a3,a2 ;no right clip if x neg
#clip_right
move a14,a7 ;screen TL
subxy a10,a7 ; - DEST Y:X = TL clip size
JRYLT #no_top_clip
movy a7,a3 ;Top clip size
btst 7,a12 ;zero compression on?
jrnz #no_top_clip ;can't clip if it is
movy a14,a10 ;Y start = window top edge
#no_top_clip
JRXLT #no_left_clip
movx a7,a3 ;Left clip size
btst 7,a12
jrnz #no_left_clip ;Zero compression on?
movx a14,a10 ;X start = window left edge
#no_left_clip
move a2,b0 ;Save BR clip
add a3,a2 ;TL clip + BR clip
;no need to use addxy as no signs + this sets Z for both
jrz #noclip ;Zero clip?
move a9,a6 ;Save HEIGHT:WIDTH
subxy a2,a9 ;Get clipped size
JRXLE #nxt ;Totally clipped?
JRYLE #nxt
btst 7,a12
jrz #nozc ;Zero compression off?
move a6,a9 ;Restore v:h size
jruc #noclip
#nozc
clr a1
movx a2,a1 ;x clip total
move a1,a1
jrz #no_x_clip
movx a9,a1 ;image width
subk 8,a1
jrle #nxt ;<=8 wide? Skip so DMA doesn't lockup
#no_x_clip
movx a6,a9 ;Restore hsize
movx a3,a1 ;A1=Left clip
btst B_FLIPH,a12
jrz #no_x_flip
subxy a1,a10 ;Original X
move b0,a1 ;LClip=RClip
zext a1,W ;clear Y portion
subxy a1,a10 ;X-RClip
#no_x_flip
; btst B_FLIPV,a12
; jrz #no_y_flip
;
; move b0,a3 ;Bot clip
;
;#no_y_flip
srl 16,a3 ;A3=Top or bot clip
jrz #t0
zext a6,W ;clear Y portion
mpyu a6,a3 ;T or B clip * width
#t0
add a1,a3 ;Add x clip + y clip * width
move a12,a1
sll 32-15,a1 ;Get bits 12-14 (PIXEL SIZE)
srl 32-15+12,a1
jrnz #not8
movk 8,a1
#not8 mpys a1,a3 ;# of bits to skip
add a3,a11 ;Add to SAG
sll 16,a2
addxy a2,a12 ;Add clip offset to offset
#noclip
;if image is flipped, dma plots from opposite end
btst B_FLIPH,a12
jrz #300
movx a9,a1 ;image WIDTH
subk 1,a1
zext a1
addxy a1,a10 ;+ WIDTH-1
#300
; btst B_FLIPV,a12
; jrz #400
; move a9,a1 ;image HEIGHT
; srl 16,a1
; subk 1,a1
; sll 16,a1
; addxy a1,a10 ;+ HEIGHT-1
;#400
move b2,a1
addxy a1,a10 ;Add the page y offset : XPad
rl 16,a12 ;Flip ctrl & offset
mmtm a4,a5,a8,a9,a10,a11,a12 ;Save the dma regs
addk 1,b13 ;+1 Q cnt
jrgt #nxt ;DMA going?
dint
setf 1,0,0 ;>Enable DMA int
movk 1,a1
move a1,@INTENB+1 ;X1E
setf 16,1,0
move *b11,b0
jrn #dmaok ;DMA busy?
move b13,b13
jrn #dmaok ;DMA int done?
trap 1 ;Cause DMA int
#dmaok eint
#nxt
move *a0,a0,L ;Get next link
jrnz #lp ;More?
rets
.if 0
#*****************************************************************************
* Load DMA Q from obj list (3D type)
* A0=*Obj list
* A4=*DMAQ next free spot
* A13=Screen BR, A14=Screen TL
* B2=Y offset for top of page : XPad offset
* B4=World Y:X
* B5=OFLAGS offset
* B6=World center scrn X * 64K
* B11=*DMACTRL
dma_objlst3d
movi [100h,100h],a5 ;A5=Y:X scale
jruc #nxt
.align
#lp
move b5,a3
add a0,a3
move *a3+,a1 ;Get OFLAGS
mmfm a3,a12,a11,a9,a8
move *a0(OYVAL),a10,L ;Get int Y
move *a0(OXPOS),a2 ;X
movx a2,a10 ;A10=Obj Y:X
btst B_SCRNREL,a1
jrnz #noscl ;Screen relative XY?
move b4,a6 ;A6=World TL Y:X
subxy a6,a10 ;-world coord to get screen coord
#noscl
;A8=Const:PAL
;A9=HEIGHT:WIDTH
;A10=Dest Y:X
;A11=*SAG
;A12=Offset:Ctrl
btst B_BOBJ,a1
jrnz #is_bgnd_obj
move *a0(ODOFF),a3,L ;display offset Y:X
btst B_FLIPH,a12
jrz #no_x_flip0
movx a3,a2
neg a2
dec a2 ; -1
addxy a9,a2 ;- image width (gets added later)
movx a2,a3
#no_x_flip0
btst B_FLIPV,a12
jrz #no_y_flip0
move a3,a2
srl 16,a2
neg a2
dec a2 ; -1
sll 16,a2
addxy a9,a2 ;- image height (gets added later)
movy a2,a3
#no_y_flip0
subxy a3,a10
#is_bgnd_obj
;Check for flipping, clipping, adjust offset, sag
;Calc top,bot,left,right clips
;a2 = BR clip size
clr a3 ;a3 = TL clip size
move a10,a2 ;Dest Y:X
addxy a9,a2 ; + HEIGHT:WIDTH = BR Y:X
subxy a13,a2 ;A2=BR clip size
JRYGE #clip_bot
movy a3,a2 ;no bot clip if y neg
#clip_bot
JRXGE #clip_right
movx a3,a2 ;no right clip if x neg
#clip_right
move a14,a7 ;screen TL
subxy a10,a7 ; - DEST Y:X = TL clip size
JRYLT #no_top_clip
movy a7,a3 ;Top clip size
btst 7,a12 ;zero compression on?
jrnz #no_top_clip ;can't clip if it is
movy a14,a10 ;Y start = window top edge
#no_top_clip
JRXLT #no_left_clip
movx a7,a3 ;Left clip size
btst 7,a12
jrnz #no_left_clip ;Zero compression on?
movx a14,a10 ;X start = window left edge
#no_left_clip
move a2,b0 ;Save BR clip
add a3,a2 ;TL clip + BR clip
;no need to use addxy as no signs + this sets Z for both
jrz #noclip ;Zero clip?
move a9,a6 ;Save HEIGHT:WIDTH
subxy a2,a9 ;Get clipped size
JRXLE #nxt ;Totally clipped?
JRYLE #nxt
btst 7,a12
jrz #nozc ;Zero compression off?
move a6,a9 ;Restore v:h size
jruc #noclip
#nozc
clr a1
movx a2,a1 ;x clip total
move a1,a1
jrz #no_x_clip
movx a9,a1 ;image width
subk 8,a1
jrle #nxt ;<=8 wide? Skip so DMA doesn't lockup
#no_x_clip
movx a6,a9 ;Restore hsize
movx a3,a1 ;A1=Left clip
btst B_FLIPH,a12
jrz #no_x_flip
subxy a1,a10 ;Original X
move b0,a1 ;LClip=RClip
zext a1,W ;clear Y portion
subxy a1,a10 ;X-RClip
#no_x_flip
btst B_FLIPV,a12
jrz #no_y_flip
move b0,a3 ;Bot clip
#no_y_flip
srl 16,a3 ;A3=Top or bot clip
jrz #t0
zext a6,W ;clear Y portion
mpyu a6,a3 ;T or B clip * width
#t0
add a1,a3 ;Add x clip + y clip * width
move a12,a1
sll 32-15,a1 ;Get bits 12-14 (PIXEL SIZE)
srl 32-15+12,a1
jrnz #not8
movk 8,a1
#not8 mpys a1,a3 ;# of bits to skip
add a3,a11 ;Add to SAG
sll 16,a2
addxy a2,a12 ;Add clip offset to offset
#noclip
;if image is flipped, dma plots from opposite end
btst B_FLIPH,a12
jrz #300
movx a9,a1 ;image WIDTH
subk 1,a1
zext a1
addxy a1,a10 ;+ WIDTH-1
#300
btst B_FLIPV,a12
jrz #400
move a9,a1 ;image HEIGHT
srl 16,a1
subk 1,a1
sll 16,a1
addxy a1,a10 ;+ HEIGHT-1
#400
move b2,a1
addxy a1,a10 ;Add the page y offset : XPad
rl 16,a12 ;Flip ctrl & offset
mmtm a4,a5,a8,a9,a10,a11,a12 ;Save the dma regs
addk 1,b13 ;+1 Q cnt
jrgt #nxt ;DMA going?
dint
setf 1,0,0 ;>Enable DMA int
movk 1,a1
move a1,@INTENB+1 ;X1E
setf 16,1,0
move *b11,b0
jrn #dmaok ;DMA busy?
move b13,b13
jrn #dmaok ;DMA int done?
trap 1 ;Cause DMA int
#dmaok eint
#nxt
move *a0,a0,L ;Get next link
jrnz #lp ;More?
rets
.endif
#*****************************************************************************
* Load DMA Q from obj list
* A0=*Obj list
* A4=*DMAQ next free spot
* A13=Screen BR, A14=Screen TL
* B2=Y offset for top of page : XPad offset
* B4=World Y:X
* B5=OFLAGS offset
* B6=World center scrn X * 64K
* B11=*DMACTRL
dma_background
movi [100h,100h],a5 ;A5=Y:X scale
jruc #nxt
.align
#lp
move b5,a3
add a0,a3
move *a3+,a1 ;Get OFLAGS
mmfm a3,a12,a11,a9,a8
move *a0(OYVAL),a10,L ;Get int Y
move *a0(OXPOS),a2 ;X
movx a2,a10 ;A10=Obj Y:X
btst B_SCRNREL,a1
jrnz #noscl ;Screen relative XY?
move b4,a6 ;A6=World TL Y:X
subxy a6,a10 ;-world coord to get screen coord
#noscl
;A8=Const:PAL
;A9=HEIGHT:WIDTH
;A10=Dest Y:X
;A11=*SAG
;A12=Offset:Ctrl
;Check for flipping, clipping, adjust offset, sag
;Calc top,bot,left,right clips
clr a3 ;A3=TL clip size
move a10,a2 ;Dest Y:X
addxy a9,a2 ; + HEIGHT:WIDTH = BR Y:X
subxy a13,a2 ;A2=BR clip size
JRYGE #clip_bot
movy a3,a2 ;no bot clip if y neg
#clip_bot
JRXGE #clip_right
movx a3,a2 ;no right clip if x neg
#clip_right
move a14,a7 ;screen TL
subxy a10,a7 ; - DEST Y:X = TL clip size
JRYLT #no_top_clip
movy a7,a3 ;Top clip size
btst 7,a12 ;zero compression on?
jrnz #no_top_clip ;can't clip if it is
movy a14,a10 ;Y start = window top edge
#no_top_clip
JRXLT #no_left_clip
movx a7,a3 ;Left clip size
btst 7,a12
jrnz #no_left_clip ;Zero compression on?
movx a14,a10 ;X start = window left edge
#no_left_clip
move a2,b0 ;Save
add a3,a2 ;TL clip+BR clip
jrz #noclip ;Zero clip?
move a9,a6 ;Save HEIGHT:WIDTH
subxy a2,a9 ;Get clipped size
JRXLE #nxt ;Totally clipped?
JRYLE #nxt
btst 7,a12
jrz #nozc ;Zero compression off?
move a6,a9 ;Restore v:h size
jruc #noclip
#nozc
clr a1
movx a2,a1 ;x clip total
move a1,a1
jrz #no_x_clip
movx a9,a1 ;image width
subk 8,a1
jrle #nxt ;<=8 wide? Skip so DMA doesn't lockup
#no_x_clip
movx a6,a9 ;Restore hsize
movx a3,a1 ;A1=Left clip
btst B_FLIPH,a12
jrz #no_x_flip
subxy a1,a10 ;Original X
move b0,a1 ;LClip=RClip
zext a1
subxy a1,a10 ;X-RClip
#no_x_flip
btst B_FLIPV,a12
jrz #no_y_flip
move b0,a3 ;Bot clip
#no_y_flip
srl 16,a3 ;A3=Top or bot clip
jrz #t0
zext a6
mpyu a6,a3 ;T or B clip * total hsize
#t0
add a1,a3 ;Add left clip + tc*ths
move a12,a1
sll 32-15,a1 ;Get bits 12-14 (PIXEL SIZE)
srl 32-15+12,a1
jrnz #not8
movk 8,a1
#not8 mpys a1,a3 ;# of bits to skip
add a3,a11 ;Add to SAG
sll 16,a2
addxy a2,a12 ;Add clip offset to offset
#noclip
btst B_FLIPH,a12 ;if flipped, keep block
jrz #300 ;in same position
movx a9,a1 ;image WIDTH
subk 1,a1
zext a1
addxy a1,a10
#300 btst B_FLIPV,a12
jrz #400
move a9,a1 ;image HEIGHT
srl 16,a1
subk 1,a1
sll 16,a1
addxy a1,a10
#400
move b2,a1
addxy a1,a10 ;Add the page y offset : XPad
rl 16,a12 ;Flip ctrl & offset
mmtm a4,a5,a8,a9,a10,a11,a12 ;Save the dma regs
addk 1,b13 ;+1 Q cnt
jrgt #nxt ;DMA going?
dint
setf 1,0,0 ;>Enable DMA int
movk 1,a1
move a1,@INTENB+1 ;X1E
setf 16,1,0
move *b11,b0
jrn #dmaok ;DMA busy?
move b13,b13
jrn #dmaok ;DMA int done?
trap 1 ;Cause DMA int
#dmaok eint
#nxt
move *a0,a0,L ;Get next link
jrnz #lp ;More?
rets
#*****************************************************************************
* Display object lists, called by DIRQ
DISPLAY
move @DISPLAYON,a0
jrz #novel
movi DMACTRL,b11 ;B11=*DMACTRL
;this is for use on the pixel wash screen transition
movi [PAGE1YO,SCRNXP],b2
movi [509,256],b3 ;dma window [ bottom : top ]
move @special_screen,a1
jrnz #p1
movi SCRNXP,b2 ;B2=Page y offset : XPad offset
movi [253,0],b3 ;dma window [ bottom : top ]
move @dpage,a1
jrnz #p1
movi [PAGE1YO,SCRNXP],b2
movi [509,256],b3 ;dma window [ bottom : top ]
#p1
move b2,@page_addr,L
movi dmaq0+QSIZE,a4 ;A4=*DMAQ for new data (Top)
clr b13 ;Kill DMA
move b13,*b11
move b13,*b11
movi DMAREGS,b12 ;B12=*DMAREGS
subk 1,b13 ;B13=Q count (-1)
move a4,b14 ;B14=*DMAQ for next fetch (Top)
;------> SHAWN WAS SETTING DSZ (BIT6) ALSO ???????????????
movk BIT5,b0 ;DMAWIN (1 = BOTTOM:TOP)
move b0,*b12(30h) ;DMACONF (Top/Bottom)
move b3,*b12,L ;DMAWINDOW
; move @DISPLAYON,a0
; jrz #doff ;Stop DMA of objects except for score?
movi WORLDTLX,b0 ;Left X screen coord (16:16)
move *b0+,b3,L ;left x [16:16]
move *b0+,b4,L ;top y [16:16]
srl 16,b3 ;int left x
movx b3,b4
move b4,*b0,L ;top left world [Y:X] (WORLDTL)
movi OFLAGS,b5 ;B5=Obj data offset
move b4,b6
addi 200,b6
sll 16,b6 ;B6=World center scrn X * 64K
move @SCRNLR,a13,L ;A13=Screen BR
move @SCRNTL,a14,L ;A14=Screen TL
move @TOP_LEFT,A0,L
ADDXY A0,A14
MOVE @BOT_RIGHT,A0,L
ADDXY A0,A13
movi BAKLST,a0
callr dma_background
move b13,@present_pos
movi OBJLST,a0
callr dma_objlst2d
MOVE @WHICH_SCREEN,A0,L
CALL A0
#doff
move @DMAQCUR,a2,L
movi DMAQ+QMSIZE,a1
cmp a1,a2
jrhs #noman ;Empty?
move a1,@DMAQCUR,L ;Reset top of queue
move b2,a5
#lp move -*a1,-*a4,L ;>Copy manual DMAQ to end of Q
move -*a1,-*a4,L
move -*a1,-*a4,L
move -*a1,a0,L
addxy a5,a0 ;+Y
move a0,-*a4,L
move -*a1,-*a4,L
move -*a1,-*a4,L
addk 1,b13
cmp a2,a1
jrhi #lp
move *b11,b0
jrn #noman ;DMA busy?
move b13,b13
jrn #noman ;DMA int done?
setf 1,0,0 ;>Enable DMA int
movk 1,a1
move a1,@INTENB+1 ;X1E
setf 16,1,0
trap 1 ;Cause DMA int
#noman
move @HALT,a0
jrnz #novel ;Skip vel update?
movi OBJLST,a0
callr vel_add
#novel
#x
rets
;Null dma data
nulldma .long >80000000,IROM,0,>00010001,0,>1000100
#*****************************************************************************
* Velocity add loop
* A0=*Obj list
* Trashes A0-A7
.align
#lp move a0,a1
addk OXVEL,a1
mmfm a1,a2,a3,a4,a5,a6,a7 ;A7=XV, A6=YV, A5=ZV, A4=X, A3=Y, A2=Z
add a5,a2 ;Add ZVEL to Z
move a2,-*a1,L
add a6,a3 ;Add YVEL to Y (Uses hidden cycle!)
move a3,-*a1,L
add a7,a4 ;Add XVEL to X ^
move a4,-*a1,L
vel_add move *a0,a0,L
jrnz #lp ;!End?
rets
#*****************************************************************************
* Manual DMA
* A1=Constant color:Palette
* A2=height:width
* A3=Dest Y:X
* A4=SAG
* A5=Offset:Control
* Trashes A0,A14
QDMAN
; movk 1,a0
; move a0,@QDMAFLG ;Q being modified
move @DMAQCUR,a14,L
cmpi DMAQ,a14
jrls #x ;Q full?
movi [100h,100h],a0 ;No scale
rl 16,a5 ;Flip DMA & offset
mmtm a14,a0,a1,a2,a3,a4,a5
rl 16,a5 ;Flip DMA & offset
move a14,@DMAQCUR,L
#x
; clr a0
; move a0,@QDMAFLG
rets
.if 0
#*******************************
* Turn on the 2d with scaling display mode
* Trashes scratch
SUBRP display_2dsclmodeon
movi #drawcode,a0
move a0,@dcode_p,L
movi -1,a0
move a0,@dtype
rets
#drawcode
movi BAKLST,a0
callr dma_objlst2d
movi OBJLST,a0
;;;; jruc dma_objlst2dscl
#*******************************
* Turn on the 2d, with scaling and stars, display mode
* Trashes scratch
.asg SCRATCH+8*128*1024,STARBUF
NSTARS .equ 900
STARSIZE .equ 32*6+16
SUBRP display_2dsclstarmodeon
movi NSTARS,b0 ;>Init star array
movi STARBUF,a1