-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpaceVacuum.x68
1886 lines (1654 loc) · 41.6 KB
/
SpaceVacuum.x68
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
*-----------------------------------------------------------
* Title : Space Vacuum
* Written by : Jacob Lites
* Date : 10/18/2017
* Description: Space Vacuum is a physics based arcade game in which you must keep asteroids from hitting the vacuum consuming the cosmos
*-----------------------------------------------------------
ALL_REG REG D0-D7/A0-A6
CIRCLE_SIZE EQU 12
SI_SHOOT EQU 1
SF_MUSIC EQU 2
SF_WIN EQU 3
SF_LOSE EQU 4
SF_HIT EQU 5
FINAL_MUSIC EQU 6
FINAL_SHOOT EQU 7
FINAL_HIT EQU 8
FINAL_WIN EQU 9
FINAL_LOSE EQU 10
SI_HIT EQU 11
A_SCREEN_X_SIZE EQU 640
A_SCREEN_Y_SIZE EQU 480
A_PLAY_X_START EQU 68
A_PLAY_Y_START EQU 89
A_PLAY_X_START_OFFSET EQU A_PLAY_X_START+(CIRCLE_SIZE/2)
A_PLAY_Y_START_OFFSET EQU A_PLAY_Y_START+(CIRCLE_SIZE/2)
A_PLAY_X_SIZE EQU 564
A_PLAY_Y_SIZE EQU 384
A_FINAL_SCORE_X EQU A_PLAY_X_START+(A_PLAY_X_SIZE/2)
A_FINAL_SCORE_Y EQU A_PLAY_Y_START+(A_PLAY_Y_SIZE/2)
A_PLAY_X_END EQU A_PLAY_X_START+A_PLAY_X_SIZE
A_PLAY_Y_END EQU A_PLAY_Y_START+A_PLAY_Y_SIZE
A_PLAY_X_END_OFFSET EQU A_PLAY_X_END-(CIRCLE_SIZE)
A_PLAY_Y_END_OFFSET EQU A_PLAY_Y_END-(CIRCLE_SIZE)
A_VACUUM_OFFSET EQU A_PLAY_X_START+(A_PLAY_X_SIZE/5)
A_SCORE_X EQU 485
A_SCORE_Y EQU 45
A_THRESHOLD_X EQU 355
A_THRESHOLD_Y EQU 45
A_BULLET_COUNT_X EQU 270
A_BULLET_COUNT_Y EQU 45
A_CIRCLE_SPEED EQU $01A0
A_BULLET_SPEED EQU $0200
A_ASTEROIDSIZE EQU 40
A_HALF_ASTEROIDSIZE EQU 20
A_ASTEROID_HEALTH EQU 5
B_SCREEN_X_SIZE EQU 720
B_SCREEN_Y_SIZE EQU 578
B_PLAY_X_START EQU 0
B_PLAY_Y_START EQU 0
B_PLAY_X_START_OFFSET EQU B_PLAY_X_START+(CIRCLE_SIZE/2)
B_PLAY_Y_START_OFFSET EQU B_PLAY_Y_START+(CIRCLE_SIZE/2)
B_PLAY_X_SIZE EQU 580
B_PLAY_Y_SIZE EQU 578
B_FINAL_SCORE_X EQU B_PLAY_X_START+(B_PLAY_X_SIZE/2)
B_FINAL_SCORE_Y EQU B_PLAY_Y_START+(B_PLAY_Y_SIZE/2)
B_PLAY_X_END EQU B_PLAY_X_START+B_PLAY_X_SIZE
B_PLAY_Y_END EQU B_PLAY_Y_START+B_PLAY_Y_SIZE
B_PLAY_X_END_OFFSET EQU B_PLAY_X_END-(CIRCLE_SIZE)
B_PLAY_Y_END_OFFSET EQU B_PLAY_Y_END-(CIRCLE_SIZE)
B_VACUUM_OFFSET EQU B_PLAY_X_START+(B_PLAY_X_SIZE/5)
B_SCORE_X EQU 668
B_SCORE_Y EQU 75
B_BULLET_COUNT_X EQU 660
B_BULLET_COUNT_Y EQU 495
B_THRESHOLD_X EQU 620
B_THRESHOLD_Y EQU 75
B_CIRCLE_SPEED EQU $0200
B_BULLET_SPEED EQU $0300
B_ASTEROIDSIZE EQU 36
B_HALF_ASTEROIDSIZE EQU 18
B_ASTEROID_HEALTH EQU 6
C_SCREEN_X_SIZE EQU 1024
C_SCREEN_Y_SIZE EQU 768
C_PLAY_X_START EQU 150
C_PLAY_Y_START EQU 0
C_PLAY_X_START_OFFSET EQU C_PLAY_X_START+(CIRCLE_SIZE/2)
C_PLAY_Y_START_OFFSET EQU C_PLAY_Y_START+(CIRCLE_SIZE/2)
C_PLAY_X_SIZE EQU 874
C_PLAY_Y_SIZE EQU 768
C_FINAL_SCORE_X EQU C_PLAY_X_START+(C_PLAY_X_SIZE/2)
C_FINAL_SCORE_Y EQU C_PLAY_Y_START+(C_PLAY_Y_SIZE/2)
C_PLAY_X_END EQU C_PLAY_X_START+C_PLAY_X_SIZE
C_PLAY_Y_END EQU C_PLAY_Y_START+C_PLAY_Y_SIZE
C_PLAY_X_END_OFFSET EQU C_PLAY_X_END-(CIRCLE_SIZE)
C_PLAY_Y_END_OFFSET EQU C_PLAY_Y_END-(CIRCLE_SIZE)
C_VACUUM_OFFSET EQU C_PLAY_X_START+(C_PLAY_X_SIZE/5)
C_SCORE_X EQU 120
C_SCORE_Y EQU 720
C_BULLET_COUNT_X EQU 25
C_BULLET_COUNT_Y EQU 720
C_THRESHOLD_X EQU 70
C_THRESHOLD_Y EQU 720
C_CIRCLE_SPEED EQU $0240
C_BULLET_SPEED EQU $0380
C_ASTEROIDSIZE EQU 32
C_HALF_ASTEROIDSIZE EQU 16
C_ASTEROID_HEALTH EQU 7
D_SCREEN_X_SIZE EQU 1280
D_SCREEN_Y_SIZE EQU 720
D_PLAY_X_START EQU 230
D_PLAY_Y_START EQU 0
D_PLAY_X_START_OFFSET EQU D_PLAY_X_START+(CIRCLE_SIZE/2)
D_PLAY_Y_START_OFFSET EQU D_PLAY_Y_START+(CIRCLE_SIZE/2)
D_PLAY_X_SIZE EQU 1006
D_PLAY_Y_SIZE EQU 720
D_FINAL_SCORE_X EQU D_PLAY_X_START+(D_PLAY_X_SIZE/2)
D_FINAL_SCORE_Y EQU D_PLAY_Y_START+(D_PLAY_Y_SIZE/2)
D_PLAY_X_END EQU D_PLAY_X_START+D_PLAY_X_SIZE
D_PLAY_Y_END EQU D_PLAY_Y_START+D_PLAY_Y_SIZE
D_PLAY_X_END_OFFSET EQU D_PLAY_X_END-(CIRCLE_SIZE)
D_PLAY_Y_END_OFFSET EQU D_PLAY_Y_END-(CIRCLE_SIZE)
D_VACUUM_OFFSET EQU D_PLAY_X_START+(D_PLAY_X_SIZE/5)
D_SCORE_X EQU 1220
D_SCORE_Y EQU 45
D_BULLET_COUNT_X EQU 1220
D_BULLET_COUNT_Y EQU 600
D_THRESHOLD_X EQU 1220
D_THRESHOLD_Y EQU 355
D_CIRCLE_SPEED EQU $0280
D_BULLET_SPEED EQU $0400
D_ASTEROIDSIZE EQU 30
D_HALF_ASTEROIDSIZE EQU 15
D_ASTEROID_HEALTH EQU 8
ENABLE_DOUBLE_BUFFER_CODE EQU 17
OUTPUT_WINDOW_TRAP_CODE EQU 33
NOT_FULL_SCREEN_SETTING_NUM EQU 1
FULL_SCREEN_SETTING_NUM EQU 2
GET_TIME_TRAP_CODE EQU 8
DELAY_TIME_TRAP_CODE EQU 23
GET_MOUSE_LOC_TRAP_CODE EQU 61
SET_PEN_COLOR_TRAP_CODE EQU 80
SET_FILL_COLOR_TRAP_CODE EQU 81
DRAW_FILLED_RECT_TRAP_CODE EQU 87
DRAW_FILLED_ELLIPSE_TRAP_CODE EQU 88
DRAW_ELLIPSE_TRAP_CODE EQU 91
SET_DRAW_MODE_TRAP_CODE EQU 92
DRAW_TO_SCREEN_TRAP_CODE EQU 94
MAROON EQU $000E003E
RED EQU $000000FF
BLUE EQU $00FF0000
DARKBLUE EQU $005E0E00
GREEN EQU $0000FF00
DARKGREEN EQU $000E3E00
YELLOW EQU $0000F2FF
DARKYELLOW EQU $00003F34
WHITE EQU $00FFFFFF
BLACK EQU $00000000
GREY EQU $00666666
BULLET_X EQU 0
BULLET_Y EQU 4
BULLET_SIZE_IN_MEMORY EQU 8
BULLET_COUNT EQU 7
ASTEROID_X EQU 0
ASTEROID_Y EQU 4
ASTEROID_X_VELOCITY EQU 8
ASTEROID_Y_VELOCITY EQU 12
ASTEROID_HEALTH EQU 16
ASTEROID_SIZE_IN_MEMORY EQU 20
MAX_ASTEROID_COUNT EQU 6
ORG $1000
START:
jsr loadSounds ;Loading sounds into directX Audio player
jsr seedRandomNumber ;Priming the pump
move.l #OUTPUT_WINDOW_TRAP_CODE,d0
move.w #A_SCREEN_X_SIZE,d1
swap d1
move.w #A_SCREEN_Y_SIZE,d1
trap #15
;POPULATING CIRCLE_SIZE DATA
move.l #CIRCLE_SIZE,d0
lsr.b #1,d0
move.l d0,halfCircleSize
jsr setDoubleBufferMode
jsr startLevel
;Main game loop. Updates time, then calculates the state for the given frame
loop:
jsr updateTimeSinceLastLoop
jsr updateInput
jsr updateElements
jsr drawElements
jsr removeElements
jsr checkForLevelEnd
jmp loop
;Element removal step. Removes all drawn elements from the draw step of the game loop
removeElements:
moveq #0,d1
jsr setPenColor
jsr setFillColor
jsr removeCircle
jsr removeBullets
jsr removeAsteroids
rts
;Updating logical representation of the elements in memory. Includes physics updates and collisions
updateElements:
jsr updateCircleLocation
jsr spawnBulletIfPossible
jsr updateBulletLocation
jsr updateAsteroidLocation
jsr checkForAsteroidBulletCollision
rts
;Draws all elements after their state has been updated.
drawElements:
move.l #WHITE,d1
jsr setPenColor
jsr setFillColor
move.l curDrawShipFunction,a6 ;Can set the draw function based on current arcade cabinet
jsr (a6)
jsr drawBullets
move.l #GREY,d1
jsr setPenColor
jsr setFillColor
move.l curDrawAsteroidFunction,a6 ;Can set the draw function based on current arcade cabinet
jsr (a6)
jsr drawVacuumLine
jsr drawScore
jsr drawBulletCount
jsr drawThresholdCount
jsr drawBufferToScreen
rts
;Function to check if there are any free spaces into which to spawn a bullet
spawnBulletIfPossible:
move.b spawnBullet,d0
beq finishBulletSpawn
move.b #0,spawnBullet
moveq #0,d7
moveq #BULLET_COUNT,d6
findEmptyBulletSpaceLoop:
lea bullet,a0
move.l (a0,d7.w),d0
bne nextFindEmptyBulletLoopIter ;Moves to the next iteration if this one is taken, IE not zero
;We got here, that means this one is NOT taken. Populate it, get out of the loop
jsr playShoot
add.l d7,a0 ;Move the A0 register to point to our new bullet
move.l circleXLocation,d0
move.l halfCircleSize,d1
lsl.l #8,d1
lsl.l #1,d1
add.l d1,d0
move.l d0,BULLET_X(a0)
move.l circleYLocation,d0
move.l halfCircleSize,d1
lsl.l #8,d1
add.l d1,d0
move.l d0,BULLET_Y(a0)
jmp finishBulletSpawn
nextFindEmptyBulletLoopIter:
add.w #BULLET_SIZE_IN_MEMORY,d7
sub.b #1,d6
bne findEmptyBulletSpaceLoop
finishBulletSpawn:
rts
updateBulletLocation:
lea bullet,a0
moveq #BULLET_COUNT,d6
bulletUpdateLoop:
cmp.l #0,BULLET_X(a0) ;Means bullet is not in use
beq updateBulletNextIter
move.l BULLET_X(a0),d1
;Mult by current deltaTime
move.l bulletSpeed,d3
muls.w deltaTime,d3
add.l d3,d1
move.l d1,d2
lsr.l #8,d2
cmp.l playXEnd,d2
ble saveNewBulletLoc
move.l #0,BULLET_X(a0)
jmp updateBulletNextIter
saveNewBulletLoc:
move.l d1,BULLET_X(a0)
updateBulletNextIter:
add.l #BULLET_SIZE_IN_MEMORY,a0
sub.b #1,d6
bne bulletUpdateLoop
rts
drawBullets:
move.l #0,currentBullets
lea bullet,a0
moveq #BULLET_COUNT,d6
drawBulletLoop:
move.l BULLET_X(a0),d1
cmp.l #0,d1
beq dontDrawThisBullet
move.l BULLET_Y(a0),d2
;Drawing bullet
lsr.l #8,d2
lsr.l #8,d1
moveq #DRAW_FILLED_RECT_TRAP_CODE,d0
moveq #1,d3
add.l d1,d3
moveq #1,d4
add.l d2,d4
trap #15
jmp nextBulletDrawIter
dontDrawThisBullet:
add.l #1,currentBullets
nextBulletDrawIter:
add.l #BULLET_SIZE_IN_MEMORY,a0
sub.b #1,d6
bne drawBulletLoop
drawBulletEnd:
rts
removeBullets:
lea bullet,a0
moveq #BULLET_COUNT,d6
removeBulletLoop:
move.l BULLET_X(a0),d1
cmp.l #$0,d1
beq removeBulletEnd
move.l BULLET_Y(a0),d2
;Drawing bullet
lsr.l #8,d2
lsr.l #8,d1
moveq #DRAW_FILLED_RECT_TRAP_CODE,d0
moveq #1,d3
add.l d1,d3
moveq #1,d4
add.l d2,d4
trap #15
removeBulletEnd:
add.l #BULLET_SIZE_IN_MEMORY,a0
sub.b #1,d6
bne removeBulletLoop
rts
resetCircleLocation:
move.l playYSize,d0
lsr.l #1,d0
add.l playYStartOffset,d0
lsl.l #8,d0
move.l playXStartOffset,d1
lsl.l #8,d1
move.l d0,circleYLocation
move.l d1,circleXLocation
rts
updateCircleLocation:
move.l halfCircleSize,d3
move.w mouseXLocation,d1
ext.l d1
;CHECKING LOWER X BOUNDARY
cmp.l playXStartOffset,d1
bgt .notOutOfX
move.l playXStartOffset,d1
jmp .xAdjDone
.notOutOfX:
;CHECKING HIGHER X BOUNDARY
move.l currentVacuumLineX,d5
sub.l #CIRCLE_SIZE,d5
cmp.l d5,d1
blt .notOutOfXU
move.l d5,d1
jmp .xAdjDone
.notOutOfXU:
sub.l d3,d1
.xAdjDone:
move.w mouseYLocation,d2
ext.l d2
;CHECKING LOWER Y BOUNDARY
cmp.l playYStartOffset,d2
bgt .notOutOfY
move.l playYStartOffset,d2
jmp .yAdjDone
.notOutOfY:
;CHECKING HIGHER Y BOUNDARY
cmp.l playYEndOffset,d2
blt .notOutOfYU
move.l playYEndOffset,d2
jmp .yAdjDone
.notOutOfYU:
sub.l d3,d2
.yAdjDone:
lsl.l #8,d1
lsl.l #8,d2
move.l circleXLocation,d3
move.l circleYLocation,d4
;If we're within 10 X or Y pixels of the mouse cursor, don't update. Otherwise we overshoot and get jerky movement
move.l d1,d5
sub.l d3,d5
bpl .validXCheck
neg.l d5
.validXCheck
move.l d2,d6
sub.l d4,d6
bpl .validYCheck
neg.l d6
.validYCheck
add.l d5,d6
move.l #10,d5
lsl.l #8,d5
cmp.l d5,d6
blt dontMove
;At this point:
;D1 has mouse x
;D2 has mouse y
;D3 has cur circle x
;D4 has cur circle y
;D5 will have x vel
;D6 will have y vel
;D0 is saved for calcs/trap codes
move.l circleSpeed,d5
cmp.l d1,d3
ble dontNegateX
neg.l d5
dontNegateX:
muls.w deltaTime,d5
add.l d5,d3
move.l circleSpeed,d6
cmp.l d2,d4
ble dontNegateY
neg.l d6
dontNegateY:
muls.w deltaTime,d6
add.l d6,d4
move.l d3,circleXLocation
move.l d4,circleYLocation
dontMove:
rts
drawShip:
move.l circleXLocation,d1
move.l circleYLocation,d2
lsr.l #8,d1
lsr.l #8,d2
moveq #CIRCLE_SIZE,d3
moveq #CIRCLE_SIZE,d4
add.l d2,d4
add.l d1,d3
moveq #DRAW_FILLED_ELLIPSE_TRAP_CODE,d0
trap #15
rts
drawLevel2Ship:
move.l circleXLocation,d1
move.l circleYLocation,d2
lsr.l #8,d1
lsr.l #8,d2
moveq #CIRCLE_SIZE,d3
moveq #CIRCLE_SIZE,d4
add.l d2,d4
add.l d1,d3
moveq #DRAW_FILLED_ELLIPSE_TRAP_CODE,d0
trap #15
move.l d1,d5
move.l #RED,d1
jsr setPenColor
jsr setFillColor
move.l d5,d1
add.l #CIRCLE_SIZE,d1
sub.l #6,d1
add.l #2,d2
sub.l #CIRCLE_SIZE,d4
add.l #5,d4
sub.l #4,d3
moveq #DRAW_FILLED_RECT_TRAP_CODE,d0
trap #15
add.l #6,d2
add.l #6,d4
moveq #DRAW_FILLED_RECT_TRAP_CODE,d0
trap #15
move.l #WHITE,d1
jsr setPenColor
jsr setFillColor
rts
drawLevel3Ship:
move.l circleXLocation,d1
move.l circleYLocation,d2
lsr.l #8,d1
lsr.l #8,d2
moveq #CIRCLE_SIZE,d3
moveq #CIRCLE_SIZE,d4
add.l d2,d4
add.l d1,d3
moveq #DRAW_FILLED_ELLIPSE_TRAP_CODE,d0
trap #15
move.l d1,d5
move.l #BLACK,d1
jsr setPenColor
jsr setFillColor
move.l d5,d1
add.l #CIRCLE_SIZE,d1
sub.l #6,d1
sub.l #CIRCLE_SIZE,d4
add.l #5,d4
moveq #DRAW_FILLED_RECT_TRAP_CODE,d0
trap #15
add.l #8,d2
add.l #8,d4
moveq #DRAW_FILLED_RECT_TRAP_CODE,d0
trap #15
move.l #WHITE,d1
jsr setPenColor
jsr setFillColor
rts
updateTimeSinceLastLoop:
moveq #DELAY_TIME_TRAP_CODE,d0
moveq #2,d1
trap #15
moveq #GET_TIME_TRAP_CODE,d0
trap #15
move.l lastIterTime,d2
move.l d1,lastIterTime
sub.l d2,d1
;bne deltaTimeNotZero
;moveq #1,d1
deltaTimeNotZero:
move.w d1,deltaTime
rts
updateInput:
moveq #GET_MOUSE_LOC_TRAP_CODE,d0
moveq #0,d1
trap #15
;Getting mouse Location
move.w d1,mouseXLocation
swap d1
move.w d1,mouseYLocation
;Getting mouse down state
and.b #2,d0
lsr.b #1,d0
moveq #0,d1
move.b (mouseDown),d1
cmp d1,d0
ble dontSpawnBullet
move.b #1,spawnBullet
dontSpawnBullet:
move.b d0,(mouseDown)
rts
removeCircle:
move.l (circleXLocation),d1
move.l (circleYLocation),d2
lsr.l #8,d1
lsr.l #8,d2
moveq #CIRCLE_SIZE,d3
add.l d1,d3
moveq #CIRCLE_SIZE,d4
add.l d2,d4
moveq #DRAW_FILLED_RECT_TRAP_CODE,d0
trap #15
rts
setPenColor:
moveq #SET_PEN_COLOR_TRAP_CODE,d0
trap #15
rts
setFillColor:
moveq #SET_FILL_COLOR_TRAP_CODE,d0
trap #15
rts
setDoubleBufferMode:
moveq #SET_DRAW_MODE_TRAP_CODE,d0
moveq #ENABLE_DOUBLE_BUFFER_CODE,d1
trap #15
rts
drawBufferToScreen:
moveq #DRAW_TO_SCREEN_TRAP_CODE,d0
trap #15
rts
spawnRandomAsteroid:
moveq #0,d6
jsr getRandomByteIntoD6
move.l playXEnd,d1
sub.l d6,d1
lsl.l #8,d1
jsr getRandomByteIntoD6
move.l playYEnd,d2
sub.l d6,d2
sub.l d6,d2
lsl.l #8,d2
jsr getRandomByteIntoD6
sub.l #127,d6
move.l d6,d3
jsr getRandomByteIntoD6
sub.l #127,d6
move.l d6,d4
jsr spawnAsteroid
rts
;When calling:
;D1 is x, Fixed point lsl 8
;D2 is y, Fixed point lsl 8
;D3 is xVel, Fixed point lsl 8
;D4 is yVel, Fixed point lsl 8
spawnAsteroid:
lea asteroids,a0
moveq #MAX_ASTEROID_COUNT,d7
.loop:
move.l ASTEROID_X(a0),d6
bne .continueLoop ;Next loop iter if this asteroid's taken
move.l d1,ASTEROID_X(a0)
move.l d2,ASTEROID_Y(a0)
move.l d3,ASTEROID_X_VELOCITY(a0)
move.l d4,ASTEROID_Y_VELOCITY(a0)
move.l levelAsteroidHealth,ASTEROID_HEALTH(a0)
jmp .spawnedAsteroid
.continueLoop
add.l #ASTEROID_SIZE_IN_MEMORY,a0
sub.b #1,d7
bne .loop
.spawnedAsteroid
rts
removeAsteroids:
lea asteroids,a0
moveq #MAX_ASTEROID_COUNT,d7
.loop:
move.l ASTEROID_X(a0),d1
beq .continueLoop ;Don't draw if it's not populated
move.l ASTEROID_Y(a0),d2
asr.l #8,d1
asr.l #8,d2
moveq #0,d3
move.b curAsteroidSize,d3
moveq #0,d4
move.b curAsteroidSize,d4
add.l d1,d3
add.l d2,d4
moveq #DRAW_FILLED_ELLIPSE_TRAP_CODE,d0
trap #15
.continueLoop
add.l #ASTEROID_SIZE_IN_MEMORY,a0
sub.b #1,d7
bne .loop
rts
drawAsteroids:
lea asteroids,a0
moveq #MAX_ASTEROID_COUNT,d7
.loop:
move.l ASTEROID_X(a0),d1
beq .continueLoop ;Don't draw if it's not populated
move.l ASTEROID_Y(a0),d2
asr.l #8,d1
asr.l #8,d2
moveq #0,d3
move.b curAsteroidSize,d3
moveq #0,d4
move.b curAsteroidSize,d4
add.l d1,d3
add.l d2,d4
moveq #DRAW_ELLIPSE_TRAP_CODE,d0
trap #15
.continueLoop
add.l #ASTEROID_SIZE_IN_MEMORY,a0
sub.b #1,d7
bne .loop
rts
drawLevel2Asteroids:
lea asteroids,a0
moveq #MAX_ASTEROID_COUNT,d7
.loop:
move.l ASTEROID_X(a0),d1
beq .continueLoop ;Don't draw if it's not populated
move.l ASTEROID_Y(a0),d2
asr.l #8,d1
asr.l #8,d2
moveq #0,d3
move.b curAsteroidSize,d3
moveq #0,d4
move.b curAsteroidSize,d4
add.l d1,d3
add.l d2,d4
moveq #DRAW_FILLED_ELLIPSE_TRAP_CODE,d0
trap #15
.continueLoop
add.l #ASTEROID_SIZE_IN_MEMORY,a0
sub.b #1,d7
bne .loop
rts
drawLevel3Asteroids:
lea asteroids,a0
moveq #MAX_ASTEROID_COUNT,d7
.loop:
move.l ASTEROID_X(a0),d1
beq .continueLoop ;Don't draw if it's not populated
move.l ASTEROID_Y(a0),d2
asr.l #8,d1
asr.l #8,d2
moveq #0,d3
move.b curAsteroidSize,d3
moveq #0,d4
move.b curAsteroidSize,d4
add.l d1,d3
add.l d2,d4
moveq #DRAW_FILLED_ELLIPSE_TRAP_CODE,d0
trap #15
move.l d1,d5
move.l #WHITE,d1
jsr setPenColor
jsr setFillColor
move.l d5,d1
add.l curHalfAsteroidSize,d1
add.l curHalfAsteroidSize,d2
sub.l #6,d3
sub.l #6,d4
moveq #DRAW_FILLED_ELLIPSE_TRAP_CODE,d0
trap #15
move.l #GREY,d1
jsr setPenColor
jsr setFillColor
.continueLoop
add.l #ASTEROID_SIZE_IN_MEMORY,a0
sub.b #1,d7
bne .loop
rts
updateAsteroidLocation:
lea asteroids,a0
moveq #MAX_ASTEROID_COUNT,d6
updateAsteroidloop:
move.l ASTEROID_X(a0),d1 ;Means asteroid is not in use
beq nextAsteroidDrawIter
move.l ASTEROID_Y(a0),d2
;Updating X Location based on velocity
move.l ASTEROID_X_VELOCITY(a0),d3
muls.w deltaTime,d3
sub.l d3,d1
move.l d1,ASTEROID_X(a0)
;We're going to apply gravity in the X Direction
move.l ASTEROID_X_VELOCITY(a0),d3
move.l curAsteroidGravity,d4
muls.w deltaTime,d4
add.l d4,d3
move.l d3,ASTEROID_X_VELOCITY(a0)
;Updating Y Location based on velocity
move.l ASTEROID_Y_VELOCITY(a0),d3
muls.w deltaTime,d3
add.l d3,d2
move.l d2,ASTEROID_Y(a0) ;MAY BE ABLE TO UPDATE IN MEMORY
;Checking if we're out of Y bounds, if so, reverse velocity
move.l ASTEROID_Y(a0),d3
asr.l #8,d3
cmp.l playYStart,d3
bgt dontReverseAsteroidY
move.l playYStart,d3
lsl.l #8,d3
move.l d3,ASTEROID_Y(a0)
move.l ASTEROID_Y_VELOCITY(a0),d3
bpl dontReverseAsteroidY
;asr.l #8,d3
muls.w #-1,d3
move.l d3,ASTEROID_Y_VELOCITY(a0)
dontReverseAsteroidY:
;Checking if we're out of Y bounds, if so, reverse velocity
move.l ASTEROID_Y(a0),d3
lsr.l #8,d3
move.l playYEnd,d4
sub.l curHalfAsteroidSize,d4
sub.l curHalfAsteroidSize,d4
cmp.l d4,d3
blt dontReverseAsteroidY2
move.l playYEnd,d3
sub.l curHalfAsteroidSize,d3
sub.l curHalfAsteroidSize,d3
lsl.l #8,d3
move.l d3,ASTEROID_Y(a0)
move.l ASTEROID_Y_VELOCITY(a0),d3
bmi dontReverseAsteroidY2
muls.w #-1,d3
move.l d3,ASTEROID_Y_VELOCITY(a0)
dontReverseAsteroidY2:
;Checking if asteroids are out of up bounds, and setting xVel to 0 if they are
move.l d1,d2
lsr.l #8,d2
moveq #0,d3
move.b curAsteroidSize,d3
add.l d3,d2
cmp.l playXEnd,d2
ble dontNukeVel
move.l #0,ASTEROID_X_VELOCITY(a0)
move.l playXEnd,d5
sub.l d3,d5
lsl.l #8,d5
move.l d5,ASTEROID_X(a0)
dontNukeVel:
sub.l d3,d2
;Checking if asteroids are out of down bounds, and invalidating them if they are
cmp.l currentVacuumLineX,d2
bge nextAsteroidDrawIter
move.l #0,ASTEROID_X(a0)
nextAsteroidDrawIter:
add.l #ASTEROID_SIZE_IN_MEMORY,a0
sub.b #1,d6
bne updateAsteroidloop
rts
checkForAsteroidBulletCollision:
lea asteroids,a0
moveq #MAX_ASTEROID_COUNT,d7
moveq #0,d5
move.b curAsteroidSize,d5
;Retrieving and squaring radius of asteroid
lsr.l #1,d5
moveq #0,d4
move.b d5,d4
muls.w d4,d5
add.l #2,d5
checkAsteroidLoop:
move.l ASTEROID_X(a0),d0
beq nextAsteroidCheckIter
move.l ASTEROID_Y(a0),d1
lsr.l #8,d0
lsr.l #8,d1
add.l curHalfAsteroidSize,d0
add.l curHalfAsteroidSize,d1
lea bullet,a1
moveq #BULLET_COUNT,d6
checkBulletLoop:
move.l BULLET_X(a1),d2
beq nextBulletCheckIter
move.l BULLET_Y(a1),d3
lsr.l #8,d2
lsr.l #8,d3
sub.l d0,d2
move.l d2,d4
muls.w d4,d2
sub.l d1,d3
move.l d3,d4
muls.w d4,d3
add.l d3,d2
cmp.l d2,d5
blt nextBulletCheckIter ;If we pass this, THERE IS A COLLISION
jsr playHit
;Get Mult Factor
move.l BULLET_Y(a1),d2
lsr.l #8,d2
sub.l d1,d2
muls.w #-1,d2
move.l curBulletYPower,d3
muls.w d3,d2
add.l d2,ASTEROID_Y_VELOCITY(a0)
move.l curBulletXPower,d2
sub.l d2,ASTEROID_X_VELOCITY(a0)
move.l #0,BULLET_X(a1)
jsr incrementScoreCounter
sub.l #1,ASTEROID_HEALTH(a0)
move.l ASTEROID_HEALTH(a0),d4
bne nextBulletCheckIter ;If we pass this, ASTEROID HAS DIED
move.l #0,ASTEROID_X(a0)
jmp nextAsteroidCheckIter
nextBulletCheckIter:
add.l #BULLET_SIZE_IN_MEMORY,a1
sub.b #1,d6
bne checkBulletLoop
nextAsteroidCheckIter:
add.l #ASTEROID_SIZE_IN_MEMORY,a0
sub.b #1,d7
bne checkAsteroidLoop
rts
;D0 is number to draw
;D1 is center X location
;D2 is center Y location
drawSevenSegment:
movem.l ALL_REG,-(sp)
move.l d1,segmentCenterX
move.l d2,segmentCenterY
moveq #0,d1
moveq #0,d2
moveq #0,d3
moveq #0,d4
lea sevenSegmentList,a0
lea segmentStartXLocs,a1
lea segmentStartYLocs,a2
lea segmentEndXLocs,a3
lea segmentEndYLocs,a4
move.b (a0,d0),d7
moveq #7,d5
;AT THIS POINT
;D0 is clobbered for trap code
;D1 is draw left x
;D2 is draw upper y
;D3 is draw right x
;D4 is draw lower y
;D5 is loop controller
;D7 is 7 seg binary checker
.loop:
sub.l #1,d5
btst d5,d7
beq .penIsMaroon
jmp .penIsRed
.penIsMaroon:
move.l curCounterOffColor,d1
jsr setPenColor
jsr setFillColor
jmp .drawSegment