-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatchPatch.S.asm
More file actions
4603 lines (4579 loc) · 198 KB
/
Copy pathMatchPatch.S.asm
File metadata and controls
4603 lines (4579 loc) · 198 KB
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
*****************************
* MATCHPATCH PROGRAM SOURCE *
* VERSION 1.0 *
* FINISHED 12-10-90 *
* by SD *
*****************************
OPT C-,D-
SECTION platform0,CODE_C
incdir ":include/"
include headers/hardware.i
include exec/exec_lib.i
include libraries/dosextens.i
OpenLib equ -552
CloseLib equ -414
Forbid equ -132
Permit equ -138
AllocMem equ -198
FreeMem equ -210
StartList equ 38
Execbase equ 4
width equ 40 game screen width
high equ 200 game screen height
top equ 40 game screen off top
bot equ 32 game screen off bottom
fscsize equ width*(top+bot+high)
bscsize equ width*(high+6)
pscsize equ width*56
COPPER MACRO
move.w \1,\2 put addr. into copper list
swap \1
move.w \1,\3
ENDM
UNUSED MACRO
dc.l 0,0,0,0,0,0,0,0
dc.l 0,0,0,0,0,0,0,0,0,0,0
dc.l 0,0,0,0,0,0
dc.l 0,0,0,$ff000000,0,0
ENDM
SOUND MACRO
tst.w scount\1 if sound channel on no new sound
bne.s \@
move.l \2,aud\1lch(a5)
move.w \3,aud\1len(a5)
move.w \4,aud\1vol(a5)
move.w \5,aud\1per(a5)
move.w \6,dmacon(a5)
move.w \7,scount\1
\@
ENDM
startup movem.l d0/a0,-(sp) FROM WORKBENCH OR CLI
clr.l workmsg save command line.clear variable
sub.l a1,a1 zero a1
CALLEXEC FindTask find our task
move.l d0,a4 save
tst.l pr_CLI(a4) from cli
beq workbench no so workbench
bra kickoff
workbench
lea pr_MsgPort(a4),a0
CALLEXEC WaitPort wait for startup message
lea pr_MsgPort(a4),a0
CALLEXEC GetMsg get message
move.l d0,workmsg save till end
kickoff movem.l (sp)+,d0/a0 restore command line
bsr prog
move.l d0,-(sp) save your exit code
tst.l workmsg was it cli
beq todos yes
CALLEXEC Forbid
move.l workmsg,a1 get workbench's mesage
CALLEXEC ReplyMsg return it
todos move.l (sp)+,d0 exit code.if any
rts
prog move.l #GRname,a1 GET OLD COPPER ADDR.
clr.l d0
move.l Execbase,a6
jsr OpenLib(a6)
move.l d0,a1
move.l StartList(a1),oldcop
move.l Execbase,a6
jsr CloseLib(a6)
bsr tpoint set up copper list
move.l Execbase,a6 SET COPPER/SCREEN
jsr Forbid(a6)
lea $dff000,a5 base address always in a5
move.w #$0180,dmacon(a5) bits 7-8 off
move.l #tlist,cop1lc(a5)
clr.w copjmp1(a5)
move.w #$0038,ddfstrt(a5) SET OVERALL SCREEN MODE
move.w #$00d0,ddfstop(a5)
move.l #0,bpl1mod(a5) clears bpl1/2mod
move.w #$83f0,dmacon(a5) bits 4-9 on
*****************************************************************************
move.w #$8010,intena(a5) SET INTERRUPT
move.l $6c,old save old interrupt adrr.
move.l #inter,$6c put in our addr.
wait btst #6,ciaapra left mouse press pauses game
bne.s play
pause bsr soff turns sounds off if paused
btst #10,potgor(a5) right mouse press restarts game
bne.s pause
play bsr soff turn sounds off
bsr vbgap synchronize with blanking gap
tst.b mode mode flags set?
beq.s xtest no
btst #0,mode set up game screen
bne drawsc
btst #2,mode put on hero
bne heroon
btst #3,mode parachute hero
bne float
btst #4,mode extra points screen delay
bne exscdy
btst #5,mode set up maze
bne setmaze
btst #6,mode maze mode
bne mazed
btst #7,mode next level
bne quickch
xtest btst #0,xmode all dead.end game/hiscore routine
bne endall
btst #1,xmode set up title screen
bne tsetup
btst #2,xmode fire pressed
bne fwait
mainlp bsr blank
bsr alter
bsr detect hit hero?
bsr strike hit missile?
bsr mover
bsr control alien movement routines
bsr missile move missiles
bsr collect bonus timer/detection
bsr extras
bsr testend
bsr put
bsr hfire fire missile.display next frame
bsr disp displays flipin screens
bsr switch switches screens in flipin/out
bsr doscore
bsr counts timer
* move.w #$444,color00(a5) *** test only ***
bra wait
drawsc bsr gpoint SET UP GAME SCREEN
bsr disp display first screen
bsr switch change to display second screen
bsr dosc1
bsr dolives
bsr dolevel
bsr copylvl
bsr dcount display level timer
bsr wipesc
bsr wipems
bsr setblks
bsr grow
bsr stsc draw background screen
bsr disphw set up hw sprites
bsr setord set up order graphics
bsr newshot set pointer pos.
move.b #4,mode set bit 2
bra wait
heroon bsr chuteon PUT PARACHUTE ON
move.b #8,mode set bit 3
bra wait
float bsr chute MOVE PARACHUTE DOWN
bra wait
exscdy subq.w #1,exsct DELAY FOR BONUS POINTS SCREENS
beq.s exscdy1
bsr killall ensures bullets are removed
bsr blank
bsr alter
bsr put
bsr disp displays flipin screens
bsr switch switches screens in flipin/out
bra wait
exscdy1 move.b #128,mode set bit 7
bra wait
setmaze bsr killall SET UP MAZE
bsr wipesc
bsr wipems
bsr remhw
bsr whichm select maze
bsr grow put minimap into scr6
bsr stsc
move.b #64,mode set bit 6
bset #0,bdhero+89 set baldy on
bra wait
mazed bsr blank MAZE LOOP
bsr alter
bsr waddle
bsr put
bsr disp displays flipin screens
bsr switch switches screens in flipin/out
bsr doscore
bsr mcount timer
* move.w #$444,color00(a5) *** test only ***
bra wait
quickch bsr nextlvl
bra wait
endall bsr killall END GAME/HISCORE ROUTINE
bsr wipesc
bsr wipems
bsr remhw
bsr cloneml two loops of mainlp
bsr cloneml
move.l score,hsscore
move.l #0,score reset score
move.l #0,plus
bsr dosc1
move.l #3,lives reset lives
bsr dolives
move.l #screens,actscr reset level data addr. start
move.l #0,level reset level
move.l #0,elscore
move.l #20000,elfreq reset score per extra life
bsr setord set up order graphics
move.b #1,sphero+110
bsr newshot set pointer pos.
*** all resets here ***
move.w #$2ae,clistc+38 set hiscore colours
move.w #$fe6,clistc+42
move.w #$e86,clistc+46
bsr printit hiscore routine
move.b #0,mode title screen set up
move.b #2,xmode
bra wait
tsetup bsr delay2 SET UP TITLE SCREEN
btst #7,ciaapra
beq.s tsetup do not exit until fire released
bsr tpoint set up title copper list
move.w #150,iscount set up swap delay (3 seconds+delay2)
move.b #0,mode
move.b #4,xmode
bra wait
fwait btst #6,ciaapra WAIT FOR BUTTON PRESS
beq goout left mouse. exit
btst #7,ciaapra
beq.s fwait3 fire. game start
subq.w #1,iscount change display?
bne wait no
tst.w isonoff which screen is on?
beq.s fwait2
fwait1 move.w #0,isonoff change to title screen
move.w #250,iscount yes. update time
bsr tpoint
bra wait
fwait2 move.w #1,isonoff change to info screen
move.w #500,iscount yes. update time
bsr ipoint
bra wait
fwait3 move.w joy2(a5),d6 any cheats?
btst #1,d6 <right joystick>
beq fwait4
move.l #10000,elfreq yes. less score per extra
fwait4 btst #9,d6 <left joystick>
beq fwait5
move.l #screens+72,actscr yes. start on level 10
move.l #9,level
fwait5 move.b #1,mode game screen set up
move.b #0,xmode
bra wait
goout move.l old,$6c restore old interrupt adrr.
move.l oldcop,cop1lc(a5) RESET COPPER.EXIT
clr.w copjmp1(a5)
move.w #$002f,dmacon(a5) all sound/sprites off
move.w #$83f0,dmacon(a5) bits 4-9 on
move.l Execbase,a6
jsr Permit(a6)
goodbye clr.l d0
rts
*****************************************************************************
inter movem.l d0-d7/a0-a6,-(sp) INTERRUPT CODE.save all
and #$10,intreqr(a5) interrupt from copper?
beq notcop no
move.w #$10,intreq(a5) clear interrupt
*** is this needed ***
notcop movem.l (sp)+,d0-d7/a0-a6 restore all
dc.w $4ef9
old dc.l 0 jump to interrupt code
*****************************************************************************
cloneml bsr blank SIMULATE ONE LOOP OF MAINLP
bsr alter
bsr put
bsr disp
bsr switch
rts
*****************************************************************************
nextlvl move.l actscr,a1 ADVANCE ONE LEVEL
add.l #8,a1
tst.l (a1)
bne.s nextl1
lea screens,a1
nextl1 move.l a1,actscr
move.b #1,mode set bit 0
move.w #0,windup
move.w #0,deadt
rts
*****************************************************************************
copylvl lea minimap,a0 LEVEL DATA TO STRUCTS.
move.l actscr,a1
move.l (a1),a2
move.l 4(a1),d0
subq.l #1,d0
copyl1 move.b (a2)+,(a0)+
dbra d0,copyl1
rts
*****************************************************************************
testend tst.w windup TEST FOR END SEQUENCE
beq.s teste9
subq.w #1,windup
bne.s teste9
bsr killall
bsr put simulate one loop of mainlp
bsr disp
bsr switch
bsr blank
bsr alter
bsr remhw
bsr wipesc
move.l #endlvlm,minimap
bsr stsc display extra points screen
add.l #4000,plus
move.w #200,exsct
move.b #16,mode set bit 4
teste9 rts
*****************************************************************************
cake add.l #1,lives CAKE BOUNS
bsr dolives
SOUND 3,#extram,#3688/2,#40,#352,#$8208,#18
rts
range move.b #50,sphero+113 GLASS BONUS
SOUND 2,#bonusm,#16236/2,#40,#352,#$8204,#66
rts
stoptim move.w #400,deadt CLOCK BONUS
SOUND 2,#bonusm,#16236/2,#40,#352,#$8204,#66
rts
bank add.l #1000,plus COIN BONUS
SOUND 2,#bonusm,#16236/2,#40,#352,#$8204,#66
rts
flower move.b #32,mode FLOWER BONUS
SOUND 2,#bonusm,#16236/2,#40,#352,#$8204,#66
rts set bit 5
timer add.l #1000,number TIMER BONUS
cmpi.l #10000,number
bmi.s timer1
move.l #9999,number
SOUND 2,#bonusm,#16236/2,#40,#352,#$8204,#66
timer1 rts
alloff lea slist+16,a2 BOMB BONUS
all1 move.l (a2)+,a4
cmpa.l #shot,a4
beq.s allend
btst #0,89(A4) on?
beq.s all1 no
btst #6,110(a4) dying already?
bne.s all1 yes
bsr smartb
bra.s all1
allend rts
smartb move.l #$00030003,76(a4) [remove aliens]
move.l #$00060006,84(a4)
move.b 110(a4),d5
bsr offset
lea anfston,a0
add.l d6,a0
move.l a0,72(a4) graphic start addr.
add.l #16,a0
move.l a0,80(a4) mask start addr.
ori.b #$60,110(a4) set special/dead bits
SOUND 2,#bonusm,#16236/2,#40,#352,#$8204,#66
rts
lswitch bset #6,sphero+89 SWITCH BONUS
SOUND 2,#bonusm,#16236/2,#40,#352,#$8204,#66
rts
fireoff lea slist+16,a2 TAP BONUS
fir1 move.l (a2)+,a4
cmpa.l #shot,a4
beq.s firend
btst #0,89(A4) on?
beq.s fir1 no
btst #6,110(a4) dying already?
bne.s fir1 yes
btst #3,110(a4) fire?
beq.s fir1 no
bsr smartb
bra.s fir1
firend rts
*****************************************************************************
whichm bsr random SELECT MAZE AT RANDOM
moveq #0,d0 clear
move.w rand,d0
andi.w #$00f0,d0 filter out (0-15)*16
lea mlist,a0
add.l d0,a0
move.l (a0),minimap set map
move.w 6(a0),bdhero+60 set x pos.
move.l 8(a0),bdhero+64 set y pos.
move.l 12(a0),number reset count
bsr dcount
rts
*****************************************************************************
waddle lea bdhero,a4 MOVE HERO
btst #0,89(A4) on?
beq waddle9 no
move.w joy2(a5),d6
btst #1,d6 right?
beq waddle1 no
lea baldmr,a1
bsr hitbit
beq.s waddle1
addq.w #1,60(a4) right 1 line
move.l #anrbald,72(a4) set anim. start
move.l #anrbald+8,80(a4) set mask start
bsr movera
waddle1 btst #9,d6 left?
beq waddle2 no
lea baldml,a1
bsr hitbit
beq.s waddle2
subq.w #1,60(a4) left 1 line
move.l #anlbald,72(a4) set anim. start
move.l #anlbald+8,80(a4) set mask start
bsr movera
waddle2 move.w d6,d7 xor for up down test
lsr.w #1,d7
eor.w d7,d6
btst #8,d6 up?
beq waddle3 no
lea baldmu,a1
bsr hitbit
beq.s waddle3
sub.l #40,64(a4) up 1 line
move.l #anubald,72(a4) set anim. start
move.l #anubald+8,80(a4) set mask start
bsr movera
waddle3 btst #0,d6 down?
beq waddle5 no
lea baldmd,a1
bsr hitbit
beq.s waddle5
add.l #40,64(a4) down 1 line
cmpi.l #8800,64(a4)
bmi.s waddle4
bclr #0,89(a4) remove baldy
move.b #1,112(a4)
bsr wipesc display extra points screen
move.l #endmazm,minimap
bsr stsc
add.l #8000,plus
move.w #200,exsct
move.b #16,mode set bit 4
rts
waddle4 move.l #andbald,72(a4) set anim. start
move.l #andbald+8,80(a4) set mask start
bsr movera
waddle5 bsr calc
bsr anim
waddle9 rts
*****************************************************************************
extras bsr random DISPLAY BONUS GRAPHICS
cmpi.w #$006f,rand
bcc extra9
bsr random
lea bonpos,a0
moveq #0,d0
move.w rand,d0
lsr.w #8,d0
andi.w #$000f,d0
lsr.w #2,d0
lsl.w #4,d0
add.l d0,a0 struct.,on/off,x,y
bset #0,7(a0) test and set
bne.s extra9 already on
move.l (a0),a4 struct.
move.b d0,115(a4) offset to data
move.w 10(a0),60(a4)
move.l 12(a0),64(a4)
moveq #0,d0
lea bonrand,a1
move.w rand+2,d2
extra1 cmp.w (a1)+,d2
bcs.s extra2
add.w #2,d0
bra.s extra1
extra2 lea bonus,a1 graphics start
add.l d0,a1 graphics addr.
move.l a1,(a4)
add.l #1200,a1 mask addr.
move.l a1,4(a4)
lsl.w #1,d0 * 2 = 0-36
lea bonaddr,a3
move.l (a3,d0.w),116(a4) routine addr.
bset #0,89(a4) set struct. on bit
move.w #500,120(a4) set remove timer
bsr calc
extra9 rts
*****************************************************************************
chute btst #0,chhero+89 MOVE PARACHUTE
beq.s chute2
bsr blank
bsr alter
lea chhero,a4
move.l stpos+4,d0 start y pos.
sub.l #920,d0 - parachute height
add.l #40,64(a4) move parachute
cmp.l 64(a4),d0 at start yet?
bne.s chute3 no
bclr #0,89(a4) turn off parachute
move.b #1,112(a4) set remove byte
bra.s chute1
chute3 bsr calc
bsr anim
bsr movera
chute1 bsr put
bsr disp displays flipin screens
bsr switch switches screens in flipin/out
* move.w #$444,color00(a5) *** test only ***
rts
chute2 tst.b chhero+112 removed?
bpl.s chute4 yes
move.b #2,mode set bit 1
bset #0,sphero+89 hero on
rts
chute4 bsr blank
bsr alter
bra.s chute1
rts
chuteon lea chhero,a4 SETUP PARACHUTE VALUES
move.l stpos,36(a4) screen offset
move.l stpos,40(a4)
move.l #0,64(a4) y pos. =0
move.w stpos+10,60(a4) x pos.
sub.w #16,60(a4) 16 pixels left for parachute width
bset #0,89(a4)
rts
*****************************************************************************
stsc move.l minimap,a3 DRAW BACKGROUND SCREEN ROUTINE
add.l #(top/8)*6,a3
lea bkb1,a4
moveq #0,d2 screen offset
moveq #25-1,d5 blocks high
stsc2 move.l (a3)+,d3 get first line in bit map
move.w (a3)+,d4
moveq #19-1,d6 blocks wide/2
move.l #bkbmsks,4(a4) mask with depth
stsc1 bsr stscbl small blocks
bsr stscbr
add.w #2,d2
dbra d6,stsc1
bsr stscbl right border
move.l #bkbmsk,4(a4) mask without depth
bsr stscbr
add.w #2,d2
add.w #7*40,d2
dbra d5,stsc2
rts
stscbl move.w #$0000,54(a4) BLIT SMALL BLOCK LEFT
lsl.w #1,d4
roxl.l #1,d3 get bit
bcc.s stscbl1 block?
bsr setscb blit left side block
stscbl1 rts
stscbr move.w #$8000,54(a4) BLIT SMALL BLOCK RIGHT
lsl.w #1,d4 get bit
roxl.l #1,d3
bcc.s stscbr2 block?
bsr setscb blit right side block
stscbr2 rts
setscb move.l 56(a4),d7 BLIT BACKGROUND BLOCKS
lea scr4,a2 screen addr.
add.l d2,a2 screen pos.
move.l (a4),a1 data
move.l 4(a4),a0 mask
setscb1 move.w 54(a4),d0 shift bits
bsr pblit2
add.l 44(a4),a1 sprite plane size
add.l #bscsize,a2 screen size
dbra d7,setscb1
rts
*****************************************************************************
grow move.l minimap,a3 DRAW DATA TO SCR6
lea blk,a4
moveq #0,d2 screen offset
moveq #34-1,d5 blocks high
gr2 move.l (a3)+,d3 get first line in bit map
move.w (a3)+,d4
moveq #20-1,d6 blocks wide/2
gr1 bsr grctl small blocks
bsr grctr
add.w #2,d2
dbra d6,gr1
add.w #7*40,d2
dbra d5,gr2
rts
grctl lsl.w #1,d4 BLIT SMALL BLOCK LEFT
roxl.l #1,d3 get bit
bcc.s grctl1 block?
bsr expl
grctl1 rts
grctr lsl.w #1,d4 BLIT SMALL BLOCK RIGHT
roxl.l #1,d3 get bit
bcc.s grctr1 block?
bsr expr
grctr1 rts
expl move.w #$0000,d0 LEFT BLOCK
bra.s expand
expr move.w #$8000,d0 RIGHT BLOCK
expand lea scr6+width*8,a2 BLIT DATA TO SCR6
add.l d2,a2
move.l (a4),a1 data
move.l 4(a4),a0 mask
bsr pblit2
rts
*****************************************************************************
printit bsr sorter HISCORE ROUTINE
tst.l d7
bmi.s prt1
bsr showtab
bsr enter
rts
prt1 rts
sorter move.l #10-1,d7 SORT HISCORE TABLE
move.l hsscore,d0 2147483647=max.number($efffffff)[2^31]
lea table,a6 start of table
sort1 move.l (a6),d1
cmp.l d0,d1 new hiscore?
bmi.s sort2 yes
add.l #16,a6 no. next score in table
dbra d7,sort1
move.l #-1,d7
rts
sort2 move.l d7,tabline lines to move -1
lsl.l #4,d7 *16
add.l #15,d7 +15=bytes to move -1 for dbra
sort3 move.b (a6,d7.w),16(a6,d7.w) a6=start of data to move
dbra d7,sort3 d6=offset (from end to stop overlap)
move.l d0,(a6)+ store new score in table
move.l a6,taboff store new data addr. for later
move.l #$20202020,(a6)+ store 10 spaces
move.l #$20202020,(a6)+
move.l #$20200000,(a6) and 2 zeros
move.l #1,d7
rts
showtab move.l #10-1,d6 DISPLAY HISCORES
move.l #hsstpos,a3
lea table,a6
shtab1 move.l a3,-(sp)
move.l (a6)+,d0 get score in hex
lea strspc,a0
lea divider+16,a1
bsr hexdec get decimal ascii
lea strspc,a0
bsr parse
lea gap,a0
bsr parse
move.l a6,a0 print name
bsr parse
move.l (sp)+,a3
add.l #width*17,a3
add.l #12,a6
dbra d6,shtab1
rts
enter move.l tabline,a3 INPUT NEW NAME
move.l #10-1,d6
sub.l a3,d6 invert d7. result in d6
move.l #(6+2)*2,a3 width of score+gap in bytes
ent1 add.l #width*17,a3 + 1 line
dbra d6,ent1
sub.l #width*17,a3 - 1 line for correct pos.
add.l #hsstpos,a3 + table start=new char. screen addr.
move.b #64,onechar displayed "?" (back)
move.l taboff,a6 addr. in table for first new char.
move.w #10-1,d6 max. char. in entry
ent2 bsr spinner
rts
spinner lea onechar,a0
bsr parse
subq.l #2,a3 set to correct pos.
bsr delay2 slow to useable speed
btst #7,ciaapra fire pressed?
beq.s nocyc yes
move.w joy2(a5),d5
btst #1,d5
beq nospr
addq.b #1,onechar
cmpi.b #96,onechar
bne.s nospr
move.b #32,onechar
nospr btst #9,d5
beq nospl
subq.b #1,onechar
cmpi.b #31,onechar
bne.s nospl
move.b #95,onechar
nospl bra.s spinner
nocyc bsr delay2
cmpi.b #64,onechar back space?
bne.s nobspc no
cmpi.w #9,d6
beq.s spinner
lea onechar+2,a0 remove "?" (back) char.
bsr parse
addq.w #1,d6
subq.l #4,a3 set to correct pos.
subq.l #1,a6
bra spinner
nobspc cmpi.b #63,onechar end?
beq.s noent yes
subq.w #1,d6 all data entered?
bmi.s fullup yes
addq.l #2,a3
move.b onechar,(a6)+
move.b #64,onechar display "?" (back)
bra spinner
fullup move.b onechar,(a6)+ keep last shown char. when full up
noent rts
*****************************************************************************
parse moveq #0,d0 PARSE AND PRINT ASCII STRING
move.b (a0)+,d0 a3=screen addr.
beq.s endstr a0=string addr.
cmpi.b #31,d0
bls.s endstr print space(32) to _(95)
cmpi.b #95,d0
bhi.s endstr
subi.w #32,d0 make from zero
move.l d0,d1 copy
lsr.w #3,d1 / 8. characters wide in grid
move.l d1,d2 copy for y value
lsl.w #3,d1 * 8. removes remainder
sub.w d1,d0 =x value in words
lsl.w #1,d0 *2 =x value in bytes
lsl.w #8,d2 y * 256=y addr. offset
add.w d0,d2 + x value=total adr. offset
move.l a3,a2
bsr lhsblit
addq.l #2,a3 text width=2 bytes
bra.s parse
endstr rts
lhsblit move.l #2-1,d7 PUT TEXT BLITTER ROUTINE
lea text,a4
add.l d2,a4
lhsblt1 bsr hsblit
add.l #bscsize,a2 screen size
add.l #2048,a4 sprite plane size
dbra d7,lhsblt1
rts
hsblit btst #14,dmaconr(a5) PUT TEXT BLIT
bne.s hsblit
move.l a4,bltapth(a5)
move.l a2,bltdpth(a5)
move.l #$ffffffff,bltafwm(a5)
move.l #$000e0026,bltamod(a5)
clr.w bltcon1(a5)
move.w #$09f0,bltcon0(a5)
move.w #$0401,bltsize(a5) 16*16
rts
*****************************************************************************
mover lea sphero,a4 MOVE HERO
btst #4,89(a4) dying?
bne fatal yes
btst #0,89(A4) on?
beq noton no
lea heromd,a1 no.try to fall
bsr falling
notdn1 move.w joy2(a5),d6
btst #1,d6
beq notrt
lea heromr,a1
bsr hitbit
beq.s animrt
addq.w #1,60(a4) right 1 line
animrt move.l 96(a4),72(a4) set anim. start
move.l 104(a4),80(a4) set mask start
move.w #1,32(a4) set right
bsr movera
notrt btst #9,d6
beq notlt
lea heroml,a1
bsr hitbit
beq.s animlt
subq.w #1,60(a4) left 1 line
animlt move.l 92(a4),72(a4) set anim. start
move.l 100(a4),80(a4) set mask start
move.w #-1,32(a4) set left
bsr movera
notlt move.w d6,d7 xor for up down test
lsr.w #1,d7
eor.w d7,d6
btst #1,88(a4) jumping?
bne.s jump yes
btst #8,d6 try to jump?
beq notup no
btst #0,88(a4) falling?
bne.s notup yes.cannot jump
bset #1,88(a4) set jump bit
jump sub.l #80,64(a4) up 1 line
subq.b #1,91(a4)
bne.s notup
move.b 90(a4),91(a4)
bclr #1,88(a4) clear jumping bit
bset #2,88(a4)
notup bsr calc
bsr anim
noton rts
fatal bsr calc
bsr anim
subq.w #1,86(a4)
bpl fatal9 delay
move.w 84(a4),86(a4) reset delay
subq.w #1,78(a4) alter count
bpl fatal9
subq.l #1,lives
bne.s fatal0
move.b #1,xmode all dead here.end game/hiscore routine
fatal0 bsr dolives
move.w #$00000029,88(a4) hero reborn
move.l #192,44(a4) update single plane size
move.l #$00010001,76(a4) anim. frame count
move.l #$00030003,84(a4) delay count
move.l #$00040024,20(a4) set modulos
move.l #$00240004,24(a4)
move.b 90(a4),91(a4) reset jump count
move.l stpos,36(a4) screen offset
move.l stpos+4,64(a4) y pos.
move.w stpos+10,60(a4) x pos.
move.w stpos+6,32(a4) facing direction
bmi.s fatal1
move.l #anrhero,72(a4)
move.l #anrhero+8,80(a4)
bra.s fatal9
fatal1 move.l #anlhero,72(a4)
move.l #anlhero+8,80(a4)
fatal9 rts
*****************************************************************************
control lea slist+16,a6 MOVE MULTIPLE SPRITES
cont1 move.l (a6)+,a4
cmpa.l #shot,a4 end of list?
beq.s contend yes
btst #0,89(A4) on?
beq.s cont1 no
btst #5,110(a4) special?
beq.s cont2 no
bsr dora dead or animate routine
bra.s cont1
cont2 btst #4,110(a4)
beq.s cont3
bsr bouncer bounce routine
bra.s cont1
cont3 bsr romper walk/jump routine
bra.s cont1
contend rts
*****************************************************************************
romper lea alienmd,a1 WALK ALIENS
bsr falling
beq.s rompe
rompf4 btst #1,89(A4) allowed to jump?
beq.s rompm2 no
btst #1,88(a4) already jumping?
bne.s rompm1 yes
bsr random new random number
cmpi.w #$00ff,rand try to jump
bcc.s rompm2 no jump
rompm1 bsr rompu
bra.s rompe
rompm2 move.w 62(a4),d2 get x vel.
subq.b #1,109(a4) left right delay
bpl.s rompe
move.b 108(a4),109(a4) reset delay
btst #2,89(a4) change direction?
beq.s rompm3 no
bsr random new random number
cmpi.w #$02ff,rand change direction?
bcc.s rompm3 no
bsr rompch yes
rompm3 tst.w 32(a4)
bmi.s rompm4
bsr rompr try to go right
bra.s rompe
rompm4 bsr rompl try to go left
rompe bsr calc
bsr anim
bsr movera
rts
rompr lea alienmr,a1 MOVE ALIEN RIGHT
bsr hitbit
beq rompch
add.w d2,60(a4) right 1 line
move.l 96(a4),72(a4)
move.l 104(a4),80(a4)
rts
rompl lea alienml,a1 MOVE ALIEN LEFT
bsr hitbit
beq.s rompch
sub.w d2,60(a4) left 1 line
move.l 92(a4),72(a4)
move.l 100(a4),80(a4)
rts
rompu btst #0,88(a4) TRY TO JUMP. falling?
bne.s rompu2 yes.cannot jump
bset #1,88(a4) set jump bit
rompu1 sub.l #80,64(a4) up 1 line
subq.b #1,91(a4)
beq.s rompu2
rts
rompu2 move.b 90(a4),91(a4)
bclr #1,88(a4) clear jumping bit
bset #2,88(a4) set end of jump bit
rompch neg.w 32(a4) CHANGE DIRECTION
rts
*****************************************************************************
bouncer move.w 62(a4),d0 BOUNCE ALIENS
add.w d0,60(a4) add x,y velocity
move.l 68(a4),d0
add.l d0,64(a4)
cmpi.l #400,64(a4) hit top?
bpl.s bounce1 no
neg.l 68(a4) yes.make bounce down
bounce1 cmpi.l #9600,64(a4) down hole?
bmi.s bounce2 no
bsr hole
sub.l #9200,64(a4) yes.make top of screen
bounce2 tst.l 68(a4)
bmi.s bounce3
move.l #840,d0 get bottom test position
bra.s bounce4
bounce3 move.l #-40,d0 get top test pos.
bounce4 move.l 36(a4),a2 screen offset
add.l d0,a2 +test pos.
add.l #scr6+320,a2 +screen start=actual test pos.
move.l #$1ffe0000,d1 top/bottom mask
move.w 52(a4),d2 get shift bits
lsl.w #1,d2
roxl.w #4,d2 move to lsb's
lsr.l d2,d1 shift mask
and.l (a2),d1 hit platform?
beq.s bounce5 no
neg.l 68(a4) yes.bounce
bounce5 tst.w 62(a4)
bmi.s bounce6
lea alienbr,a1 right mask
bra.s bounce7
bounce6 lea alienbl,a1 left mask
bounce7 bsr hitbit hit side?
bne.s bounce9 no
neg.w 62(a4) yes.bounce
bmi.s bounce8
move.l 96(a4),72(a4) rotate right
move.l 104(a4),80(a4)
bra.s bounce9
bounce8 move.l 92(a4),72(a4) rotate left
move.l 100(a4),80(a4)
bounce9 bsr calc
bsr anim
bsr movera
rts
*****************************************************************************
dora btst #1,88(a4) SPECIAL BIT SET ROUTINE
beq.s dora1 not jumping
sub.l #80,64(a4) up 2 lines
subq.b #1,91(a4)
bne.s dora2
move.b 90(a4),91(a4)
bclr #1,88(a4) clear jumping bit
bset #2,88(a4) set end of jump bit
dora1 lea alienmd,a1
bsr falling
dora2 bsr calc
bsr anim
subq.w #1,86(a4)
bpl dora8 delay
move.w 84(a4),86(a4) reset delay
subq.w #1,78(a4) alter count
bpl dora8
move.w 76(a4),78(a4) reset frame count
btst #6,110(a4) dead?
bne dora7 yes
bclr #7,110(a4) anim.? else clear bit
beq.s dora5 no. [set up appear graphics]
move.b 110(a4),d5 new type
bsr offset
lea angston,a0
add.l d6,a0
move.l a0,72(a4) graphic start addr.
add.l #16,a0
move.l a0,80(a4) mask start addr.
move.b 110(a4),d5 get offset for struct. reset