-
Notifications
You must be signed in to change notification settings - Fork 5
/
FBUTIL.ASM
1872 lines (1741 loc) · 50.7 KB
/
FBUTIL.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 'UTIL.ASM'
.TITLE " <<< FOOTBALL GENERAL PURPOSE SUBROUTINES >>>"
**************************************************************************
* *
* COPYRIGHT (C) 1988 WILLIAMS ELECTRONICS GAMES, INC. *
* ALL RIGHTS RESERVED. *
* *
**************************************************************************
.WIDTH 132
.OPTION B,D,L
.MNOLIST
* GET THE SYSTEM STUFF
.INCLUDE "MPROCEQU.ASM" ;MPROC equates
.INCLUDE "DISPEQU.ASM" ;Display processor equates
.INCLUDE "SYSEQU.ASM" ;SYS.INC and GSP.INC
.INCLUDE "MACROS.HDR" ;Macros, Yeah!
.INCLUDE "MAINEQU.ASM"
.INCLUDE IMGTBL.GLO
.EVEN
.TEXT
*EUGENE'S SCORE ROUTINES
*
*BCD ADD ROUTINE
*A0=SCORE (8 DIGIT BCD) 32 BITS
*A1=NUMBER TO ADD TO A0 (8 DIGIT BCD)
*PACKED BCD FORMAT 4-BITS/ DIGIT
BCDADD:
MMTM SP,A1,A3,A4,A5,A6
MOVK 8,A5 ;DO 8 DIGITS
CLRC ;CLEAR THE CARRY
MOVK 0Ah,A6
BCDLP:
MOVK 0Fh,A3
MOVK 0Fh,A4
AND A1,A3 ;MASK GARBAGE
AND A0,A4
ADDC A3,A4
CMP A6,A4 ;NEED TO ADJUST?
JRLO BCDAD1
ADDK 6,A4
SRL 4,A0
SLL 28,A4
ADD A4,A0
SRL 4,A1
SETC
DSJS A5,BCDLP
JRUC BCDADX
BCDAD1:
SRL 4,A0
SLL 28,A4
ADD A4,A0
SRL 4,A1
CLRC
DSJS A5,BCDLP
BCDADX:
MMFM SP,A1,A3,A4,A5,A6
RETS
*
*PLAYER SCORE ROUTINE
*A1=SCORE VALUE
*A2=PLAYER INDEX
;SCORE:
; MMTM SP,A0,A2
; MOVE @GSTATE,A0,W
; CMPI INAMODE,A0
; JREQ SCOREX ;NO SCORING IN ATTRACT MODE
; MOVE *A2(PSCORE),A0,L ;GET SCORE
; CALLR BCDADD ;ADD IN NEW VALUE
; CALLR REPCK ;CHECK REPLAY
; MOVE A0,*A2(PSCORE),L ;STORE SCORE
;* CALLR OUTSCR ;OUTPUT CURRENT PLAYER SCORE
;SCOREX
; MMFM SP,A0,A2
; RETS
;
;*
;*PLAYER SCORE IMMEADIATE ROUTINE, DOESN'T WAIT FOR SCORE REFRESH
;*DO NOT USE THIS DURING HEAVY GAME ACTION PLEASE
;*A1=SCORE VALUE
;*A2=PLAYER INDEX
;SCRIMM:
; MMTM SP,A0,A2
; MOVE @GSTATE,A0,W
; CMPI INAMODE,A0
; JREQ SCRIMMX ;NO SCORING IN ATTRACT MODE
; MOVE *A2(PSCORE),A0,L ;GET SCORE
; CALLR BCDADD ;ADD IN NEW VALUE
; MOVE A0,*A2(PSCORE),L ;STORE SCORE
; CALLR OUTSCR ;OUTPUT CURRENT PLAYER SCORE
;SCRIMMX
; MMFM SP,A0,A2
; RETS
;*
;*OUTPUT SCORE TO SCREEN
;*A0=CURRENT PLAYER SCORE
;*A2=PLINDX=PLAYER DATA AREA
;*
;OUTSCR:
; MMTM SP,A0,A1,A2,A3,A4,A5,A6,A7,A14
; MOVK 8,A6 ;DIGIT COUNT
; MOVE *A2(PSCRAD),A3,L ;PLAYER SCORE ADDRESS
; MOVI SCRSPC,A4 ;SPACING BETWEEN DIGITS
; CLR A7 ;INIT BLANKING FLAG
; MOVI 9|8000H,A5 ;CONTROL REGISTER
;
;OUTSCL:
; MOVE A0,A1
; SRL 28,A1
; JRNE OUTSC1 ;NON-ZERO DIGIT
; CMPI 2,A6
; JRLS OUTSC1 ;LAST DIGITS - OUTPUT ANYWAY
; MOVE A7,A7 ;BLANKING OVER?
; JREQ OUTSC2 ;NO
;OUTSC1:
; INC A7 ;BLANKING IS OVER
; SLL 7,A1 ;MULTIPLY BY 128
; MOVE A1,A14
; ADDI RRD0,A14 ;ADDRESS OF IMAGE HEADER
;
; MOVE @GSTATE,A1,W
; CMPI INAMODE,A1
; JREQ OUTSC10 ;BR = NO FLASH SCORE DURING AMODE
;
; MOVE *A2(POBJ),A1,L ;IS THE PLAYER ACTIVE
; JRNE OUTSC1A ;BR = YES, DO A FLASHY SCORE
;OUTSC10
; MOVI 0F9F90000H,A1 ;CONSTANT COLOR:PALETTE SELECT
; JRUC OUTSC1B
;OUTSC1A
; MOVI 0F5F50000H,A1 ;CONSTANT COLOR:PALETTE SELECT
;OUTSC1B
; CALLA DTIME ;OUTPUT THE SUCKER
;OUTSC2:
; ADDXY A4,A3 ;SPACE TO NEXT DIGIT
; SLL 4,A0
; DSJ A6,OUTSCL
; MMFM SP,A0,A1,A2,A3,A4,A5,A6,A7,A14
; RETS
**************************************************************************
* *
* OBJECT BLOCK INITIALIZATION ROUTINES *
* *
**************************************************************************
**************************************************************************
* *
* SHVELCPY - COPY VELOCITIES TO SHADOW (IF ANY) *
* A8=OBJECT *
* *
**************************************************************************
SHVELCPY:
MMTM SP,A0,A1
MOVE *A8(OSHAD),A0,L
JREQ SHVLCPX
MOVE *A8(OXVEL),*A0(OXVEL),L
MOVE *A8(OZVEL),*A0(OZVEL),L
SHVLCPX:
MMFM SP,A0,A1
RETS
*
*SHVELFLP - COPY SHADOW VELOCITY AND FLIP HIM
*A8=OBJECT
*A3=OXVEL
SHVELFLP:
CALLR SHVELCPY
MOVE *A8(OXVEL+>10),A14,W ;TEST X VELOCITY
*FLIPDUDE
*A8=OBJECT, N=SIGN OF XVEL
FLP:
JAN YFLP
JAUC NOYFLP
**************************************************************************
* *
* OBJOFF - TURN AN OBJECT "OFF" I.E. SET DMA OUTPUT TO 0 *
* A0 = PTR TO OBJECT BLOCK *
* *
**************************************************************************
OBJOFF
PUSH A4
MOVE *A0(OFLAGS),A4,W
SRL 4,A4
SLL 4,A4
MOVE A4,*A0(OFLAGS),W
PULL A4
RETS
**************************************************************************
* *
* OBJON - TURN AN OBJECT "ON" I.E. SET DMA OUTPUT TO WRITE <> 0 *
* A0 = PTR TO OBJECT BLOCK *
* *
**************************************************************************
OBJON
PUSH A4
MOVE *A0(OFLAGS),A4,W
SRL 4,A4
SLL 4,A4
ADDK 2,A4
MOVE A4,*A0(OFLAGS),W
PULL A4
RETS
**************************************************************************
* *
* Z POSITIONING ROUTINES *
* *
**************************************************************************
*
*XZCHK
*CALLING PARAMETERS:
*A8=OBJECT SEEKING
*A0=OBJECT SEEKED
*A5=X RANGE
*A6=Z RANGE
*RETURNS:
*CARRY SET IF HE IS CLOSE ENOUGH
*A1=DELTA X
*A2=DELTA Z
*A3=ABS DELTA X
*A4=ABS DELTA Z
XZCHK:
MOVE A0,A4
CALLR GETANIX ;GET X ANIMATION POINT
MOVE A0,A3
SWAP A4,A8
CALLR GETANIX
MOVE A0,A1
MOVE A8,A0
MOVE A4,A8
MOVE *A8(OZPOS),A4,W
MOVE *A0(OZPOS),A2,W
SUB A4,A2
SUB A3,A1
MOVE A1,A3
MOVE A2,A4
ABS A3
ABS A4
CMP A5,A3
JRNC XZCHKX
CMP A6,A4
XZCHKX:
RETS
**************************************************************************
* *
* CLRPDATA - CLEAR THE PDATA AREA OF A PROCESS BLOCK *
* A13 = PTR TO PROCESS BLOCK *
* *
**************************************************************************
CLRPDATA
MMTM SP,A1,A6,A14
MOVE A13,A14
CLR A1
ADDI PDATA,A14
MOVI (PSDATA-PDATA)/16,A6
CLRSHL
SRL 1,A6
JRNC CLRPDL
MOVE A1,*A14+,W ;STUFF THE ODD WORD
CLRPDL
MOVE A1,*A14+,L
DSJS A6,CLRPDL
MMFM SP,A1,A6,A14
RETS
**************************************************************************
* *
* GET BOTTOM Y OF AN OBJECT *
* A8 = OBJECT BLOCK PTR *
* RETURN(S) *
* A1 = 16 BIT BOTTOM Y IN LSW *
* STATUS SET ACCORDING TO THE BOTTOM Y *
*NOTE: MAKE SURE OBLOCK IS INIT'D WITH GSAGOF BEFORE CALLING *
* *
**************************************************************************
GETBOTY
PUSH A2
MOVE *A8(OYPOS),A1,W ;GET Y POSITION
MOVE *A8(OSIZEY),A2,W ;GET THE CURRENT SIZE
ADD A2,A1 ;A1 = BOTTOM Y
MMFM SP,A2
RETS
**************************************************************************
* *
* GETCPNT - RETURNS THE CENTER XY POSITION OF A GIVEN IMAGE *
* A8 = IMAGE OBLOCK *
* RETURN(S) *
* A1 = CENTER Y:CENTER X *
* *
**************************************************************************
GETCPNT MOVE A0,-*SP,L
MOVE *A8(OYPOS),A0,W
SLL 16,A0
MOVE *A8(OXPOS),A1,W
MOVX A1,A0
MOVE *A8(OSIZE),A1,L
CALLR GETCENT
SLL 16,A0
MOVY A0,A1
MOVE *SP+,A0,L
RETS
**************************************************************************
* *
* GETCENT - RETURNS THE CENTER POINT OF A BOX *
* A0 = UPPER LEFT Y:UPPER LEFT X *
* A1 = Y_SIZE:X_SIZE *
* RETURN(S) *
* A0 = CENTER Y(LSW) *
* A1 = CENTER X(LSW) *
* *
**************************************************************************
GETCENT MOVE A2,-*SP,L
MOVY A1,A2
SRL 17,A2 ;YSIZE/2
SLL 16,A2 ;BACK TO Y HALF
SLL 16,A1 ;CLEAR Y
SRL 17,A1 ;XSIZE/2
MOVY A2,A1
ADDXY A1,A0 ;OFFSET TO CENTER
CLR A1
MOVX A0,A1 ;RETURN THESE IN USEFUL POSITIONS
SRL 16,A0
MOVE *SP+,A2,L
RETS
**************************************************************************
* *
* GETSCRRX - THE THE WORLD X COORDINATE OF THE SCREEN RIGHT END *
* RETURNS *
* A0 = SCREEN RIGHT X, 32 BITS *
* *
**************************************************************************
GETSCRRX
PUSH A2
MOVE @SCRNLR,A0,W
MOVE @WORLDTL,A2,W
ADD A2,A0 ;GET SCREEN LOWER RT.
SLL 16,A0
PULL A2
RETS
*
*GETANIX - GET ANIMATION POINT X COORD
*CALLING PARMS: A8=OBJECT
*RETURNS A0=16 BIT WORLD COORD OF UPPER LEFT
*
GETANIX:
MMTM SP,A1,A2
MOVE *A8(OIMG),A1,L
MOVE *A1(IANIOFF),A2,W
MOVE *A8(OFLAGS),A0,W
BTST B_FLIPH,A0
JRZ GETAX1
MOVE *A1(ISIZE),A0,W
SUB A2,A0
DEC A0
MOVE A0,A2
GETAX1:
MOVE *A8(OXPOS),A0,W
ADD A2,A0
MMFM SP,A1,A2
RETS
**************************************************************************
* *
* GETZMID - GET THE Z MIDPOINT OF AN OBJECT. *
* A8 = PTR TO OBJECT *
* RETURNS: *
* A0 = 32 BIT Z CENTER *
* *
**************************************************************************
;GETZMID
; MMTM SP,A1,A2
* THIS OBJECT FIELD HAS BEEN REDEFINED, IF YOU STILL WANNA USE THIS
* ROUTINE YOU WILL HAVE TO MODIFY IT FOR THE NEW "OZSIZE" (EJB-5/5/90)
; MOVE *A8(OZSIZ),A2,L
; MOVY A2,A1 ;A1 = OZPLUS
; SRL 16,A1
; ZEXT A2
; ADD A1,A2 ;A2 = TOTAL Z WIDTH
; SLL 15,A2 ;DIVIDE FOR HALF
; SLL 16,A1
; MOVE *A8(OZVAL),A0,L
; ADD A1,A0 ;GET TO THE EDGE
; SUB A2,A0 ;GO BACK TO MIDPOINT
; MMFM SP,A1,A2
; RETS
**************************************************************************
* *
* CLRWORLD - CLEAR ALL WORLD COORDINATES AND SCROLL VELOCITIES. *
* *
**************************************************************************
CLRWORLD
PUSH A0
CLR A0
MOVE A0,@SCROLLX,L ;X SCROLL VALUE
MOVE A0,@SCROLLY,L ;Y SCROLL VALUE
MOVE A0,@WORLDTLX,L ;TOP LEFT X SCREEN COORD (WORLD)
MOVE A0,@WORLDTLY,L ;TOP LEFT Y SCREEN COORD (WORLD)
MOVE A0,@WORLDTL,L
MOVE A0,@BAK2TLY,L ;TOP LFT Y SLOW SCROLL BACKGROUND
MOVE A0,@BAK2TLX,L ;TOP LFT X SLOW SCROLL BACKGROUND
MOVI SCRNST,A0
MOVE A0,@SCRNTL,L
MOVE A0,@SCRNTL2,L
MOVE A0,@SCRNTL3,L
MOVI SCRNEND,A0
MOVE A0,@SCRNLR,L
MOVE A0,@SCRNLR2,L
MOVE A0,@SCRNLR3,L
PULL A0
RETS
**************************************************************************
* *
* GETSCRBY - THE THE WORLD Y COORDINATE OF THE SCREEN BOTTOM *
* RETURNS *
* A0 = SCREEN BOTTOM Y *
* *
**************************************************************************
GETSCRBY
PUSH A2
MOVE @SCRNLR+16,A0,W
MOVE @WORLDTL+16,A2,W
ADD A2,A0 ;GET SCREEN BOTTOM Y
SLL 16,A0 ;MAKE IT A 32 BIT VALUE
PULL A2
RETS
**************************************************************************
* *
* SETYPOS - SETUP OBJECTS Y POSITION SO HES ON THE GROUND * *
* A0 = OBJECT BLOCK *
* *
**************************************************************************
SETYPOS MOVE A1,-*SP,L
MOVE *A0(OSIZEY),A1,W
NEG A1
SLL 16,A1
MOVE A1,*A0(OYVAL),L
MOVE *SP+,A1,L
RETS
**************************************************************************
* *
* MYOINIT - INITIALIZE SUPPLEMENTAL OBJECT LIST HEADERS *
* *
**************************************************************************
MYOINIT
MMTM SP,A0,A1,A2,A3,A4,A5
PUSHST
DINT
MOVE @INTENB,A0,W
ANDNI X1E,A0 ;NO MORE DMA INTERRUPTS
MOVE A0,@INTENB,W
POPST
CLR A0
MOVE A0,@GAMERASE
CALLA AUTOEOFF ;DISABLE AUTOERASE
CALLR DMAWAIT ;WAIT ON DMA
MOVI ERASECOL,A1
SLL 16,A1 ;CONSTANT:PALETTE
MOVI [2,511],A2 ;HEIGHT:WIDTH
MOVI [510,0],A3 ;DAG
MOVI 2000000H,A4 ;SAG
MOVI DMAREGS,A0
MMTM A0,A1,A2,A3,A4 ;STORE TO LAST 2 LINES OF BITMAP
CLR A5 ;STUFF OFFSET
MOVE A5,-*A0,W
MOVI DMACAL,A5 ; CONTROL &
MOVE A5,-*A0,W ; GO!
CALLA CLRPAL ; CLEAR PALETTE RAM
CLR A0
MOVE A0,@SL_OFFENSE,L
MOVE A0,@SL_DEFENSE,L ; RE-INIT SUPPLEMENTAL LISTS
MOVK 1,A0
MOVE A0,@GAMERASE
CALLA AUTOEON ; AUTOERASE / GAME ERASE ON !!!
MOVI boonpal,A0
CALLA GETFPAL ; FOOTBALL FIXED PALETTE !!
MMFM SP,A0,A1,A2,A3,A4,A5
JAUC OINIT
**************************************************************************
* *
* ADDSUPP - ADD OBJECT TO A SUPPLEMENTAL LIST *
* A0 = PTR TO OBJECT *
* A1 = MEMORY LOCATION OF SUPPLEMENTAL LIST HEADER *
* *
**************************************************************************
ADDSUPP
MOVE *A1(0),*A0(OSLINK),L ;LINK SLIST TO THIS BLOCK
MOVE A0,*A1,L ;NEW HEAD OF THE SLIST
RETS
**************************************************************************
* *
* DELSBOBJ - DELETE OBJECT FROM SUPPLEMENTAL BACKGROUND LIST *
* A0 = PTR TO OBJECT *
* *
**************************************************************************
;DELSBOBJ
; PUSH A1
; MOVI BACKSLST,A1
; CALLR DELSUPP
; PULL A1
; RETS
**************************************************************************
* *
* DELSUPP - DELETE OBJECT FROM THE SUPPLEMENTAL LIST *
* A0 = PTR TO OBJECT *
* A1 = MEMORY LOCATION OF SUPPLEMENTAL LIST HEADER *
* *
**************************************************************************
DELSUPP
MMTM SP,A1,A2
MOVE A1,A2
MOVE *A1,A1,L ;SPECIAL CASE THE HEADER
JRNZ DELSCHK1
LOCKUP
JRUC DELSX
DELSCHK1
CMP A1,A0
JRNE DELSLUP
MOVE *A1(OSLINK),*A2(0),L ;LINK AROUND THIS GUY
DELSX
MMFM SP,A1,A2
RETS
DELSLUP
MOVE A1,A2 ;SAVE PREVIOUS
MOVE *A1(OSLINK),A1,L ;SEARCHING FOR THE ELEMENT IN THE LIST
JRNZ DELSCHK2
LOCKUP
JRUC DELSX
DELSCHK2
CMP A1,A0
JRNE DELSLUP ;NOT FOUND KEEP LOOKING
MOVE *A1(OSLINK),*A2(OSLINK),L ;LINK AROUND THIS GUY
MMFM SP,A1,A2
RETS
**************************************************************************
* *
* ISSUPP - IS AN OBJECT ON A SUPPLEMENTAL LIST *
* A0 = PTR TO OBJECT *
* A1 = MEMORY LOCATION OF SUPPLEMENTAL LIST HEADER *
* RETURNS: *
* Z BIT SET = NOT ON *
* Z BIT CLR = IS ON *
* *
**************************************************************************
ISSUPP
PUSH A1
MOVE *A1,A1,L ;SPECIAL CASE THE HEADER
JREQ ISEND
CMP A1,A0
JRNE ISSEARCH
ISFOUND
MOVE A1,A1 ;SET Z BIT
ISEND
PULL A1
RETS
ISSEARCH
MOVE *A1(OSLINK),A1,L ;SEARCHING FOR THE ELEMENT IN THE LIST
JREQ ISEND ;ELEMENT DOES NOT EXIST
CMP A1,A0
JRNE ISSEARCH ;NOT FOUND KEEP LOOKING
JRUC ISFOUND ;FOUND RETURN
**************************************************************************
* *
* ISSUPPID - IS AN OBJECT ON A SUPPLEMENTAL LIST(SEARCH BY OBJECT I.D.) *
* A0 = OBJECT I.D. *
* A1 = MEMORY LOCATION OF SUPPLEMENTAL LIST HEADER *
* RETURNS: *
* Z BIT SET = NOT ON *
* A1 = ZERO *
* Z BIT CLR = IS ON *
* A1 = PTR TO OBJECT *
* *
**************************************************************************
ISSUPPID
PUSH A2
MOVE *A1,A1,L ;SPECIAL CASE THE HEADER
JREQ ISENDID
MOVE *A1(OID),A2,W
CMP A2,A0
JRNE ISSRCHID
ISFNDID
MOVE A1,A1 ;SET Z BIT
ISENDID
PULL A2
RETS
ISSRCHID
MOVE *A1(OSLINK),A1,L ;SEARCHING FOR THE ELEMENT IN THE LIST
JREQ ISENDID ;ELEMENT DOES NOT EXIST
MOVE *A1(OID),A2,W
CMP A2,A0
JRNE ISSRCHID ;NOT FOUND KEEP LOOKING
JRUC ISFNDID ;FOUND RETURN
**************************************************************************
* *
* CNTSUPP - COUNT THE NUMBER OF OBJECTS ON GIVEN SUPPLEMENTAL LIST. *
* A1 = SUPPLEMENTAL LIST *
* RETURNS: *
* A0 = OBJECT CNT *
* *
**************************************************************************
CNTSUPP
PUSH A1
CLR A0
MOVE *A1,A1,L
JRZ CNTSUPPX
CNTSUPPL
INC A0
CMPI NOBJ,A0
JRHS CNTSUPPX ;WE'VE MAXED, SOMETHING IS WRONG
MOVE *A1(OSLINK),A1,L
JRNZ CNTSUPPL
CNTSUPPX
PULL A1
RETS
**************************************************************************
* *
* RANDOM - GENERATE A RANDOM NUMBER *
* RETURNS: *
* A0 = 32 BIT RANDOM # *
* *
**************************************************************************
RANDOM: PUSH A1
MOVE @RAND,A0,L
SLA 1,A0
JRV RND2
ORI 2,A0
RND2: MOVE A0,@RAND,L
CLR A1
ADDC A1,A0 ;GET LAST BIT BACK TO MAKE 32
MOVE @HCOUNT,A1
RL A1,A0 ;RANDOM ROTATION
MOVE A0,A0 ;SET STATUS BITS
MMFM SP,A1
RETS
**************************************************************************
* *
* RANDU - GENERATE A UNIFORMLY DISTRIBUTED RANDOM # BETWEEN 1 AND [A0] *
* A0 = RANGE INPUT *
* RETURNS: *
* A0 = RANDOM # *
* *
**************************************************************************
RANDU: PUSH A1
MOVE A0,A1
CALLR RANDOM
MPYU A1,A0
INC A0
MMFM SP,A1
RETS
*
*GET SIGNED RANDOM # IN RANGE +/- A0
*CALLING PARAMETERS: A0
*RETURNS A0
*
SRAND:
MMTM SP,A1
MOVE A0,A1
SLL 1,A0
CALLA RANDU
SUB A1,A0
MMFM SP,A1
RETS
**************************************************************************
* *
* RANGRAND - GENERATE A RANDOM NUMBER IN A GIVEN RANGE. *
* B0 = LOWER BOUND *
* B1 = UPPER BOUND *
* RETURNS *
* A0 = RANDOM # *
* *
**************************************************************************
RANGRAND
PUSH A1
PUSH B1
SUB B0,B1 ;NORMALIZE THE RANGE
MOVE B1,A0 ;SET RANGE FOR RANDU
CALLR RANDU
MOVE B0,A1
ADD A1,A0
PULL B1
PULL A1
RETS
*
*RANDPER - RANDOM % ROUTINE
*CALLING PARAMETERS:
*A0=PROBABILITY OF EVENT (0-1000) P(A0=1000) = 1; P(A0=1) = 1/1000.
*RETURNS CS IF PROBABILITY IS TRUE, CC FOR FALSE
*RETURNS A0 = ACTUAL RANDOM # 0-999
RANDPER:
MMTM SP,A1,A2
MOVE A0,A2
CALLA RANDOM
MOVI 1000,A1
MPYU A1,A0
CMP A2,A0
MMFM SP,A1,A2
RETS
**************************************************************************
* *
* FILLAREA - FILL A GIVEN SQUARE AREA ON THE SCREEN WITH A COLOR *
* A1 = [COLOR,PALETTE] *
* A3 = DAG OF AREA [YPOS,XPOS] *
* A4 = [Y,X] SIZE OF AREA *
* *
**************************************************************************
FILLAREA
MMTM SP,A1,A2,A4,A5
JRUC AREACON
**************************************************************************
* *
* BLNKAREA - BLANK A GIVEN SQUARE AREA ON THE SCREEN *
* A3 = DAG OF AREA [YPOS,XPOS] *
* A4 = [Y,X] SIZE OF AREA *
* *
**************************************************************************
BLNKAREA
MMTM SP,A1,A2,A4,A5
CLR A1 ;CONSTANT 0:PALETTE 0
AREACON
MOVE A4,A2
MOVI 2000000H,A4 ;SOMEWHERE IN IMAGE ROM
MOVI DMACAL,A5
CALLA QDMAN
MMFM SP,A1,A2,A4,A5
RETS
**************************************************************************
* *
* PFRAME - GET NEXT FRAME FROM ANIMATION LIST *
* A8 = POINTER TO OBJECT BLOCK *
* A11 = POINTER TO NEXT FRAME IN THE ANIMATION LIST *
* RETURN(S) *
* A5 = TICKS FOR THIS FRAME *
* C BIT SET(JxC) = END OF LIST WAS HIT *
* N BIT SET(JxN) = SPECIAL FRAME ENCOUNTERED *
* *
**************************************************************************
PFRAME MMTM SP,A1,A4
MOVE *A11+,A1,L ;LOAD NEXT FRAME
JRNE PFRAME1 ;NOT THE END OF THE LIST
SETC ;SET CARRY FLAG
JRUC PFRAMEX
PFRAME1
MOVE *A8(OFLAGS),A4,W
CALLA ANI ;SETUP NEW FRAME
PFRAME2
MOVE *A11+,A5,W ;LOAD SLEEP TICKS PER FRAME
CLRC
PFRAMEX MMFM SP,A1,A4
RETS
PSTOP
MMTM SP,A0,A1
CLR A1 ; NO VELOCITY
MOVE A1,*A8(OXVEL),L ; IN THE "X" DIRECTION (AND DESIGN)
MOVE A1,*A8(OYVEL),L ; STOP MOVEMENT
MOVE A1,*A8(OZVEL),L ; STOP MOVEMENT
MOVE A1,*A8(OXACC),L ; NO ACCELERATION
MOVE A1,*A8(OZACC),L
MOVE *A8(OSHAD),A0,L
JREQ PSTOPX
MOVE A1,*A0(OXVEL),L ; STOP THE SHADOW
MOVE A1,*A0(OYVEL),L
MOVE A1,*A0(OZVEL),L ; STOP MOVEMENT
PSTOPX
MMFM SP,A0,A1
RETS
*
*YFLP - SET OBJECT Y-FLIP, A8:OBJECT BLOCK PTR
YFLP MMTM SP,A1,A4
MOVE *A8(OFLAGS),A4
ORI M_FLIPH,A4
JRUC STUFLAGS
*
*NOYFLP - CLEAR OBJECT Y-FLIP, A8:OBJECT BLOCK PTR
NOYFLP MMTM SP,A1,A4
MOVE *A8(OFLAGS),A4
ANDNI M_FLIPH,A4
STUFLAGS
MOVE *A8(OIMG),A1,L ;GET THE CURRENT IMAGE POINTER
CALLA ANI ;SETUP THE "NEW" IMAGE
UNFLPD MMFM SP,A1,A4
RETS
**************************************************************************
* *
* SYNCUP - SYNCHRONIZE WITH THE NEXT DISPLAY INTERRUPT, I.E. *
* WAIT UNTIL THE NEXT INTERRUPT IS FINISHED BEFORE RETURNING *
* *
**************************************************************************
SYNCUP MOVE A0,-*SP,L
CLR A0
MOVE A0,@INTSYNC0,L ;CLEAR HALF SCREEN SYNC
SYNCUP1 MOVE @INTSYNC0,A0,L
JREQ SYNCUP1 ;END HASN'T HIT YET
MOVE *SP+,A0,L
RETS
**************************************************************************
* *
* SYNCHALF - SYNCHRONIZE WITH THE HALF SCREEN INTERRUPT *
* *
**************************************************************************
SYNCHALF
MMTM SP,A0,A1
MOVI INTSYNC0,A1
JRUC SYNCSD
**************************************************************************
* *
* SYNCFULL - SYNCHRONIZE WITH THE FULL SCREEN INTERRUPT *
* *
**************************************************************************
SYNCFULL
MMTM SP,A0,A1
MOVI INTSYNC1,A1
SYNCSD CLR A0
MOVE A0,*A1,W ;CLEAR HALF SCREEN SYNC
SYNCSD1 MOVE *A1,A0,W
JREQ SYNCSD1 ;END HASN'T HIT YET
MMFM SP,A0,A1
RETS
**************************************************************************
* *
* DTIME - USED TO DMA AN IMAGE *
* A1 = [CONSTANT COLOR,PALETTE(STUFFED IN DTIME)] *
* A3 = DAG [Y,X] *
* A5 = [OFFSET,CONTROL] *
* A14 = ADDRESS OF IMAGE HEADER *
* *
**************************************************************************
DTIME:
MMTM SP,A0,A1
MOVE *A14(ICMAP),A0,L ;GET THE PALETTE
CALLA FINDPAL ;GET THE CORRECT COLOR MAP #
JRNZ DTIME1 ;BR = PALETTE WAS FOUND
CLR A0 ;DEFAULT TO FIXED PALETTE
DTIME1
MOVX A0,A1
CALLA QDMA ;QUEUE THIS SUCKAH
MMFM SP,A0,A1
RETS
**************************************************************************
* *
* DMAWAIT - WAIT ON THE DMA BUSY BIT TO CLEAR *
* *
**************************************************************************
DMAWAIT
PUSH A0
DMAWAITL
MOVE @DMACTRL,A0,W ;DMA BUSY?
JRN DMAWAITL ;BR = YES
PULL A0
RETS
**************************************************************************
* *
* DMAQWAIT - WAIT FOR DMA QUEUES TO EMPTY, THEN WAIT FOR DMA TO FINISH *
* THE LAST ONE. *
* *
**************************************************************************
;DMAQWAIT
; PUSH A0
;DMAQWT1
; MOVE @TOPQ0CNT,A0,W
; JRNE DMAQWT1
; MOVE @TOPQ1CNT,A0,W
; JRNE DMAQWT1
; MOVE @BOTQ0CNT,A0,W
; JRNE DMAQWT1
; MOVE @BOTQ1CNT,A0,W
; JRNE DMAQWT1
; PULL A0
;DMAQWT2
; MOVE B13,B13
; JRZ DMAWAIT
; JRUC DMAQWT2
**************************************************************************
* *
* DMAHALT - HALT THE DMA *
* *
**************************************************************************
DMAHALT
PUSH A0
CLR A0
MOVE A0,@DMACTRL,W ;HALT THE DMA
PULL A0
RETS
*
*CMAPRS - RESET THE COLOR MAP SELECT
CMAPRS CLR A0
*CMAPSL - SELECT THE COLOR MAP(0-15 IN A0)
CMAPSL MOVE A1,-*SP,L
CALLA DMAWAIT
MOVE A0,@CMAPSEL
MOVE *SP+,A1,L
RETS
**************************************************************************
* *
* CRINIT - COLOR RAM INITIALIZATION, FIRST CLEAR ALL COLOR RAM, THEN *
* FILL WITH PALETTES. *
* *
**************************************************************************
CRINIT
MMTM SP,A0,A1,A2,A6
MOVI COLRAM,A1
CLR A0
MOVI 10000H,A6,L
*CLEAR ALL COLOR PALETTES
CRINIT1
MOVE A0,*A1+,L ;STUFF TWO WORDS AT A TIME
DSJS A6,CRINIT1
MMFM SP,A0,A1,A2,A6 ;<----
RETS ;<----
*
*SCRCLR - CLEAR THE SCREEN WITH EUGENE
*ONLY CALL WITH INTERRUPTS DISABLED AND THE DMA SHUT DOWN, OTHERWISE
* USE CLR_SCRN
SCRCLR CLR A0
*SCRFIL - FILL SCREEN WITH A0
SCRFIL:
MMTM SP,A1,A2
CLR A1
MOVE A1,@CMAPSEL,W ;SELECT COLOR MAP 0
MOVI SCREEN,A1,L
MOVI (SCRNE-SCREEN)/32,A2,L
SCRLP MOVE A0,*A1+,L
DSJS A2,SCRLP
MMFM SP,A1,A2
RETS
**************************************************************************
* *
* SETPPROC - SETUP TI'S PIXEL PROCESSING REGISTER'S (BFILE), TO MATCH *
* THE ZUNIT SYSTEM. *
* NOTE: IF YOU WANT TO DO ANY SPECIAL TRICKS, DON'T USE THIS. *
* *
**************************************************************************
SETPPROC
PUSH A0
MOVI OFFSETVAL,B4 ;Set up OFFSET register
MOVI 0,B8 ;Set background color
MOVI SCRN_PTCH,A0 ;Get Screen Pitch
MOVE A0,B1
MOVE A0,B3
LMO A0,A0 ;Convert in temporary register
MOVE A0,@CONVSP ;Move to CONVSP io register
MOVE A0,@CONVDP ;Move to CONVDP io register
PULL A0
RETS
************ CLEAR SCREEN ROUTINE *********************