-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathboss4Code.asm
More file actions
1468 lines (1429 loc) · 66.4 KB
/
boss4Code.asm
File metadata and controls
1468 lines (1429 loc) · 66.4 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
; diverse banks, see "if else clauses"
if CURRENT_BANK = 3
;
; Boss "Death star"
;
LASER_TIME = 200
BETWEEN_TIME = 60
BOSS_Y_POSSITION_4 = $40 ; $60
;;;;;;; *****************************************
;;;;;;; * BANK 3 *
;;;;;;; *****************************************
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
coldetectBoss3_4
lda playerNumberOfBulletsPerShot
cmpa #6 ; laser
beq xCheckOnly_laser_34
; "non" shots have ypos set to max ($7f) therefore below test is always met and goes to noHit
; we do not need to test the shot itself for validity!
; yTest
; for "easyness" - just we say here if
; y pos of shot is >= enemyPos than we hit!
;
lda bossPosY ; pos of boss2, boss start at the top
suba #$28
sta enemyMINY
ldb bossPosY ; pos of boss2, boss start at the top
sex
; subd #$28; reduce by some offset to get the "mouth" part
std tmp3_tmp
ldb T_YPOS, y
sex
subd tmp3_tmp
bpl nonNegb2_34
std tmp3_tmp
clra
clrb
subd tmp3_tmp
nonNegb2_34
cmpd #$28
bhi notHit_34
;;;;; y done
xCheckOnly_34
; xTest
ldb bossPosX
addb #$80 ; x coordinate enemy now 0 based in b 0-255
; test center
stb tmp1
addb #BOSS3_HIT_X_OFFSET
bcc testOnB3_1_34
ldb #$ff
testOnB3_1_34
cmpb T_XPOS0_MINUS_1_RADIUS , y
blo notHit_34 ; enemy is on left side of shot
; in b 0 based enemy pos
subb #2*BOSS3_HIT_X_OFFSET
bcc testOnB3_2_34
ldb #$00
testOnB3_2_34
cmpb T_XPOS0_PLUS_1_RADIUS , y
bhi notHit_34 ; enemy is on right side of shot
inc tmp2_tmp_unique
jmp removeCurrentShotAndObjectBoss
;..........
notHit_34
jmp [backJump]
xCheckOnly_laser_34
lda bossPosY ; pos of boss2, boss start at the top
suba #$20 ; reduce by some offset to get the "mouth" part
; for laser cut off
sta laserTmp
clr laserTmp2 ; main laser only
bra xCheckOnly_34
;
; .....................................................
;
subInitBoss4 ;#isfunction
lda lockPurchased
ora #ENEMY_DESTRUCTED_FLAG
sta lockPurchased
; destroy scoopies!
ldd #0
sta displayExplosions
std scoopEnemy1
std scoopEnemy2
lda #MAX_SHOT_OBJECTS_BOSS
jsr initBossFight
REPLACE_1_2_playerShotsDoneBoss04_varFrom0_0
ldd #0 ;
std PLAYERSHOTS_DONE_A
; enemies
lda #MAX_ENEMY_OBJECTS_BOSS4
ldu #enemyobject_list
stu enemylist_empty_head
ldy #ENEMY_DONE
next_list_entry_igb4
leax EnemyStruct,u
stx NEXT_ENEMY_OBJECT,u
clr BIT_MASK,u
leau ,x
deca
bne next_list_entry_igb4
leau -EnemyStruct,u
sty NEXT_ENEMY_OBJECT,u
sty enemylist_objects_head
clr boss4WeaponActive
clr allowBossShots
; quick hack - zero 2 laser shots
ldu #boss4laserData
ldd #0
std ,u++
std ,u++
std ,u++
std ,u++
std ,u++
std ,u++
ldu #boss4explosionData
std ,u++
std ,u++
std ,u++
std ,u++
std ,u++
std ,u++
stb signFlag
stb b4_divide_tmp
std b4_tmp1
stb b4_tmp2
lda #6
sta levelBulletBorder
sta lukeX
rts
;
; .....................................................
;
initBoss4 ;#isfunction
; Boss intro
bsr subInitBoss4
REPLACE_1_2_initTitleRAM_varFrom0_19
ldx #0 ; initTitleRAM
jsr jsrBank0X
REPLACE_1_2_boss4Intro_varFromIRQ0_9
ldx #0 ; boss4Intro
jsr jsrBank0_fromBank3_T1
jsr subInitBoss4
inc displayExplosions
inc allowBossShots
; initialize boss fight 3 for real
; done in bank 0
ldd #BOSS_Y_POSSITION_4*256
std bossPosY
lda diverseFlags
ora #%00001000 ; boss flag
sta diverseFlags
REPLACE_1_2_adjustShotDamage_varFrom0_42 ; bank 0 replace
ldx #0 ; adjustShotDamage
jsr jsrBank0X
ldb difficulty
andb #$f ;
beq easy8
decb
beq normal8
decb
beq hard8
impossible8
ldd #BOSS4_HITPOINTS*3
bra difCont8
normal8
hard8
ldd #BOSS4_HITPOINTS*2
bra difCont8
easy8
ldd #BOSS4_HITPOINTS
difCont8
std bossHP
ldd #enemies_done_boss4
std ENEMY_DONE_A
ldd #enemiesShots_done_boss4
std SHOTS_DONE_A
clr boss4ShotStage
lda #100 ; 2s
sta boss4ShotStageDelayCounter
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
main1Boss4: ;#isfunction
enemiesShots_done_boss4
lds #MY_STACK ; CBFC ; correct the stack to default address
; initialize all "round" stuff for player
jsr bossFightPlayerStuff
ldd bulletSpawnAt
beq nowBulletSpawnb4
jsr spawnShot
nowBulletSpawnb4
ldd #0
std bulletSpawnAt
sta isBugShot
clr bossWasHit
RESET_LASER_SMALL
ldy #testShot
ldx ,y
beq backToTestBoss4_1
ldd #backToTestBoss4_1
std backJump
jmp coldetectBoss3_4
backToTestBoss4_1
ldy #test2Shot
ldx ,y
beq backToTestBoss4_2
ldd #backToTestBoss4_2
std backJump
jmp coldetectBoss3_4
backToTestBoss4_2
; check for boss death
ldx bossHP
lbmi extroBoss4
; display boss in bank 0
REPLACE_1_2_displayBoss4_varFrom0_4
ldx #0 ;displayBoss4
jsr jsrBank0X
dec boss4ShotStageDelayCounter
bne continueCurrentStageBoss4
; do fight!
inc boss4ShotStage
lda #25
sta boss4ShotStageDelayCounter
lda boss4ShotStage
deca
beq not10
lda #10
sta boss4ShotStageDelayCounter
not10
continueCurrentStageBoss4
ldb gameScale
stB VIA_t1_cnt_lo
jsr Reset0Ref ; claibration reset
lda boss4ShotStage
; stage 0: waiting for weapon initialze
beq nothingSpecialAtAll
deca
; stage 1: start rotating
beq startRotateWeapon
; stage 2-8: switch on supporting lasers
ldd bossPosY
adda #17 +12+1
addb #28 +16
if IS_VIA_FAULTY_RESISTENT = 1
JSR myMovetod ;Moveto_d
else
JSR Moveto_d
endif
lda boss4ShotStage
cmpa #8
ble weaponLinesOnly
lda #8
weaponLinesOnly
deca
sta boss4ShotLineCounter
doWeaponLines
ldb #50 / 2
stB VIA_t1_cnt_lo
ldx #WeaponList
Draw_VLpWeapon:
; DRAW
LDD ,X++ ;Get next coordinate pair
STA <VIA_port_a ;Send Y to A/D
if IS_VIA_FAULTY_RESISTENT = 1
clra
sta <VIA_port_b ;Enable mux
inca
sta <VIA_port_b ;Disable mux
else
CLR <VIA_port_b ;Enable mux
NOP
INC <VIA_port_b ;Disable mux
endif
STB <VIA_port_a ;Send X to A/D
ldd #%11111111
sta <VIA_t1_cnt_hi ;Clear T1H
stb <VIA_shift_reg
LDD -2,X ;Get next coordinate pair
nega
negb
nop 8
clr <VIA_shift_reg
; MOVE BACK
STA <VIA_port_a ;Send Y to A/D
if IS_VIA_FAULTY_RESISTENT = 1
clra
sta <VIA_port_b ;Enable mux
inca
sta <VIA_port_b ;Disable mux
else
CLR <VIA_port_b ;Enable mux
NOP
INC <VIA_port_b ;Disable mux
endif
STB <VIA_port_a ;Send X to A/D
clr <VIA_t1_cnt_hi ;Clear T1H
nop 5
dec boss4ShotLineCounter
bne Draw_VLpWeapon
_ZERO_VECTOR_BEAM
;..........
lda boss4ShotStage
cmpa #9
blo nothingSpecialAtAll
; stage: 9 prepare laser, next stage 4 seconds
lbeq initBoss4LaserPhase
cmpa #10
; stage: 10 start firing
lbeq laserFireStage
; stage 11: reset to stage 0
clr boss4ShotStage
clr boss4WeaponActive
jsr initVader
bra nothingSpecialAtAll
;laserIsReady
; fire shots each ## rounds
startRotateWeapon
lda #1
sta boss4WeaponActive
nothingSpecialAtAll
jsr handleBossLaserShots
jsr calibrationZero7
jsr drawLuke
_ZERO_VECTOR_BEAM
lda gameScale
sta <VIA_t1_cnt_lo
; jsr drawVader vader is enemy
lda #DEFAULT_ENEMY_INTENSITY
_INTENSITY_A
lds enemylist_objects_head
puls d,pc ; (D = y,x) ; do all objects _> jumps to enemies_done_boss4
;
; .....................................................
;
enemyVader
dw VaderAngle8Table
db 2
dw VaderAnimTable
db 1,TYPE_DONT_WAIT
VaderAngle8Table
VaderAnimTable
dw VaderList
dw VaderList
dw VaderList
dw VaderList
dw VaderList
dw VaderList
dw VaderList
dw VaderList
dw 0
VaderList
Vader
db -$26, $01, -$39, hi(SMVB_continue_single), lo(SMVB_continue_single)
db $5F, $01, $00, hi(SMVB_startDraw_single), lo(SMVB_startDraw_single)
db $13, $01, $39, hi(SMVB_continue3_single), lo(SMVB_continue3_single)
db -$13, $01, $39
db -$13, $01, $4D
db $43, $01, -$26, hi(SMVB_continue_double), lo(SMVB_continue_double)
db -$73, $01, $73, hi(SMVB_continue3_single), lo(SMVB_continue3_single)
db -$5F, $01, $00
db -$73, $01, -$73
db $43, $01, $26, hi(SMVB_continue_double), lo(SMVB_continue_double)
db -$13, $01, -$4D, hi(SMVB_continue4_single), lo(SMVB_continue4_single)
db -$13, $01, -$39
db $13, $01, -$39
db $13, $01, -$4D
db -$43, $01, $26, hi(SMVB_continue_double), lo(SMVB_continue_double)
db $73, $01, -$73, hi(SMVB_continue3_single), lo(SMVB_continue3_single)
db $5F, $01, $00
db $73, $01, $73
db -$43, $01, -$26, hi(SMVB_continue_double), lo(SMVB_continue_double)
db $13, $01, $4D, hi(SMVB_continue_single), lo(SMVB_continue_single)
db $00, $01, $72, hi(SMVB_startMove_single), lo(SMVB_startMove_single)
db -$5F, $01, $00, hi(SMVB_startDraw_single), lo(SMVB_startDraw_single)
db $f0, $00, $00, hi(SMVB_lastDraw_rts2), lo(SMVB_lastDraw_rts2)
XWing
db -$2B, $01, -$1A, hi(SMVB_continue_single), lo(SMVB_continue_single)
db $0A, $01, $44, hi(SMVB_startDraw_single), lo(SMVB_startDraw_single)
db $0C, $01, -$06, hi(SMVB_continue7_single), lo(SMVB_continue7_single)
db $09, $01, -$12
db $0B, $01, -$5A
db $0D, $01, $58
db $04, $01, $12
db $12, $01, $08
db $06, $01, -$46
db $03, $01, $4C, hi(SMVB_continue6_single), lo(SMVB_continue6_single)
db -$15, $01, $04
db -$18, $01, $1A
db -$1E, $01, -$1A
db -$0E, $01, -$02
db $00, $01, -$4B
db $f0, $00, $00, hi(SMVB_lastDraw_rts), lo(SMVB_lastDraw_rts)
initVader ;#isfunction
vaderIntroPattern = vaderLoopyPattern ;entry8
tst bonusSpawnCount
bne noSpawnBoss4
lda #-1
sta patternDelayCounter
lda #1
sta introWaveEnemyDelayCount
ldx #vaderIntroPattern
stx introWaveCurrentPattern
jsr doIntro
; only one enemy - can do it hardcoded!
ldx enemylist_objects_head
ldd #enemyIntroPatternBehaviourVader
std 2,x
noSpawnBoss4
rts
;
;..............................................
;
drawLuke ;#isfunction
lda lukeX
bmi lukeIsNeg
nega
lukeIsNeg
adda #$2f
jsr Intensity_a
lda #gameScale
sta <VIA_t1_cnt_lo
lda Vec_Loop_Count+1
anda #1
beq noLukeDec
dec lukeX
noLukeDec
ldb lukeX
cmpb #-40
bgt lukeOk
cmpb #-80
bgt lukeInvisible
ldb #40
stb lukeX
lukeOk
addb bossPosX
lda bossPosY
suba #23
if IS_VIA_FAULTY_RESISTENT = 1
JSR myMovetod ;Moveto_d
else
JSR Moveto_d
endif
lda #5
sta <VIA_t1_cnt_lo
ldu #XWing
jmp SMVB_drawSmart
lukeInvisible
rts
;
;..............................................
;
laserFireStage
ldb difficulty
andb #$f
beq noextendedLaser
; deca
; beq noextendedLaser2
;
;
;
; salvae
; ldu #boss4laserData
; lda boss4ShotStageDelayCounter
; cmpa #LASER_TIME - 5
; beq fireLaser
;
; cmpa #LASER_TIME - 5 -BETWEEN_TIME/2-BETWEEN_TIME/2-BETWEEN_TIME/2
; beq fireLaser
;
;
;
; leau 4,u
; cmpa #LASER_TIME - 5 -BETWEEN_TIME/2
; beq fireLaser
;
; cmpa #LASER_TIME - 5 -BETWEEN_TIME/2-BETWEEN_TIME/2-BETWEEN_TIME/2-BETWEEN_TIME/2
; beq fireLaser
;
;
; leau 4,u
; cmpa #LASER_TIME - 5 -BETWEEN_TIME/2-BETWEEN_TIME/2
; beq fireLaser
; jmp nothingSpecialAtAll
noextendedLaser2
; salvae
ldu #boss4laserData
lda boss4ShotStageDelayCounter
cmpa #LASER_TIME - 5
beq fireLaser
cmpa #LASER_TIME - 5 -BETWEEN_TIME/2-BETWEEN_TIME/2-BETWEEN_TIME/2
beq fireLaser
leau 4,u
cmpa #LASER_TIME - 5 -BETWEEN_TIME/2
beq fireLaser
leau 4,u
cmpa #LASER_TIME - 5 -BETWEEN_TIME/2-BETWEEN_TIME/2
beq fireLaser
jmp nothingSpecialAtAll
noextendedLaser
ldu #boss4laserData
lda boss4ShotStageDelayCounter
cmpa #LASER_TIME - 5
beq fireLaser
leau 4,u
cmpa #LASER_TIME - 5 -BETWEEN_TIME
beq fireLaser
leau 4,u
cmpa #LASER_TIME - 5 -BETWEEN_TIME-BETWEEN_TIME
beq fireLaser
jmp nothingSpecialAtAll
fireLaser ;#isfunction
lda #$81
asra
ldb playerXpos
asrb ; half the player pos
std boss4LaserTarget,u
lda bossPosY
clr boss4shotMax,u
lda #-20
sta boss4shotMin,u
jmp nothingSpecialAtAll
;
;..............................................
;
handleBossLaserShots ;#isfunction
ldu #boss4laserData
ldd ,u
beq noLaser1
bsr boss4FireLaser
noLaser1
leau 4,u
ldd ,u
beq noLaser2
bsr boss4FireLaser
noLaser2
leau 4,u
ldd ,u
beq noLaser3
bsr boss4FireLaser
noLaser3
rts
;
;..............................................
;
; input U pointer to laser struct
boss4FireLaser ;#isfunction
ldb gameScale
stB VIA_t1_cnt_lo
; get lazer start
ldd bossPosY
adda #17 +12+1
addb #28 +16
std boss4LaserStartTmp
asra
sta maxYSum ; start of weapon pos (1/2)
asrb
nega
negb
adda boss4LaserTarget,u
addb boss4LaserTarget+1,u
std boss4LaserTargetTmp
ldd boss4LaserStartTmp
stb b4_tmp2
if IS_VIA_FAULTY_RESISTENT = 1
jsr myMovetod
else
jsr Moveto_d
endif
ldb gameScale
bpl okAsislaser
ldb #$ff
bra storeHere
okAsislaser
decb
aslb
storeHere
stB VIA_t1_cnt_lo
lda boss4shotMax,u
pshs a
ldd boss4LaserTargetTmp
jsr clipDToMax
std boss4LaserStartTmp
if IS_VIA_FAULTY_RESISTENT = 1
jsr myMovetod
else
jsr Moveto_d
endif
ldb b4_tmp2
asrb
stb b4_tmp2
ldb boss4LaserStartTmp+1
addb b4_tmp2
stb b4_tmp2
lda maxYSum
adda boss4LaserStartTmp
sta maxYSum ; start of laser which is LIT
puls a
; get laser End
lda boss4shotMin,u
pshs a
ldb gameScale
bpl okAsislaser2
ldb #$ff
bra storeHere2
okAsislaser2
decb
aslb
storeHere2
stB VIA_t1_cnt_lo
ldd boss4LaserTargetTmp
suba boss4LaserStartTmp
subb boss4LaserStartTmp+1
bsr clipDToMax
std boss4LaserStartTmp
STA <VIA_port_a ;Send Y to A/D
if IS_VIA_FAULTY_RESISTENT = 1
clra
sta <VIA_port_b ;Enable mux
inca
sta <VIA_port_b ;Disable mux
else
CLR <VIA_port_b ;Enable mux
NOP
INC <VIA_port_b ;Disable mux
endif
STB <VIA_port_a ;Send X to A/D
LDD #$FF00 ;Shift reg=$FF (solid line), T1H=0
STA <VIA_shift_reg ;Put pattern in shift register
STB <VIA_t1_cnt_hi ;Set T1H (scale factor?)
LDD #$0040 ;B-reg = T1 interrupt bit
LF3F4_b4: BITB <VIA_int_flags ;Wait for T1 to time out
BEQ LF3F4_b4
NOP ;Wait a moment more
STA <VIA_shift_reg ;Clear shift register (blank output)
_ZERO_VECTOR_BEAM
ldb boss4LaserStartTmp+1
addb b4_tmp2
stb b4_tmp2
puls a
lda boss4LaserStartTmp
adda maxYSum
sta maxYSum ; end of laser which is LIT
; in maxYSum is the start position of the "lit" laser part
BOSS4_LASER_YEND = -$40
cmpa #BOSS4_LASER_YEND
bgt nomaxOverflow
bsr boss4InitGroundExplosion
inc boss4shotMin,u
inc boss4shotMin,u
bpl doneLser
bra noMinDec
BOSS3_LASER_LENGTH = -40
nomaxOverflow
lda boss4shotMin,u
cmpa #BOSS3_LASER_LENGTH
blt noMinDec
dec boss4shotMin,u
dec boss4shotMin,u
bra noMaxDec
noMinDec
dec boss4shotMax,u
dec boss4shotMax,u
noMaxDec
rts
doneLser
ldd #0
std ,u
rts
; bra nothingSpecialAtAll
;
;..............................................
;
; in u current laser pointer
; explosion pointer is u + 8
boss4InitGroundExplosion ;#isfunction
; ypos is player "ground"
; x pos = boss4LaserTargetTmp+1
;
; struct Boss4GroundExplosion
; ds ExPosy, 1
; ds ExPosx, 1
; ds ExSizeCounter, 1
; ds ExSize, 1
; end struct
;
;
; end current laser
ldd ExPosy+(Boss4LaserBeam * BOSS4_LASER_COUNT),u
bne exIsInit
ldb b4_tmp2 ; this is double scale
aslb
lda #$80
std ExPosy+(Boss4LaserBeam * BOSS4_LASER_COUNT),u
lda #5 ; min explosion size
sta ExSize+(Boss4LaserBeam * BOSS4_LASER_COUNT),u
exIsInit
rts
;
;..............................................
;
; in "d"
clipDToMax ;#isfunction
; resulting y is always boss4shotMax, that is the delta of the first move gap
nega ; assuming boss4shotMax is alsways negative
clr b4_tmp1
sta b4_tmp1+1 ; clear space for DIF, and set dif value
; sta signFlag ; assuming always moving down -> thus negative
clr signFlag
lda 2,s
bpl maxShotPos
nega
maxShotPos
; in a abs(delta)
tstb ; x value
bpl bPosb4_1
inc signFlag
negb
; bvc bPosb4_1 ; $80 has overflow set ->
; ldb #$7f
bPosb4_1
mul
; in d = abs(Ydelta) * abs(x)
; new X = sign * (d/abs(y))
bsr difDByTmp
lda signFlag
bita #1
beq bPosB4_2
negb
bPosB4_2
lda 2,s ; new y is the max
rts
;
;..............................................
;
;-------------------------------------------------------------------------------------------
;***************************************************************************
; divides D by tmp1, result in B
; uses divide_tmp as storage
; only 8 bit in tmp1, but must be manually poked to tmp1 + 1
; sign is correctly handled
;
; can probably be optimized like hell
; perhaps only nearing the result
; using 2 shifts and a plus
; might be worth a try,
; see vectrex emulator for algorithm...
; could be implemented with a tabel, which in turn
; could be caclulated on the fly... (upon startup)
;
; this makro divides exact, but slow
MY_DIV_D_BY_TMP1_TO_B_UNSIGNED macro
CLR b4_divide_tmp
TST b4_tmp1+1
BEQ divide_by_zero\?
DEC b4_divide_tmp
CMPD #0
BPL divide_next\?
divide_next1\?:
INC b4_divide_tmp
ADDD b4_tmp1
BMI divide_next1\?
divide_by_zero1\?:
LDB b4_divide_tmp
NEGB
BRA divide_end\?
divide_next\?:
INC b4_divide_tmp
SUBD b4_tmp1
BPL divide_next\?
divide_by_zero\?:
LDB b4_divide_tmp
divide_end\?:
endm
difDByTmp
MY_DIV_D_BY_TMP1_TO_B_UNSIGNED
rts
;
;..............................................
;
initBoss4LaserPhase ;#isfunction
lda #LASER_TIME ; laser fires x second
sta boss4ShotStageDelayCounter
inc boss4ShotStage
inc boss4WeaponActive
jmp nothingSpecialAtAll
;
;..............................................
;
;
;..............................................
;
WeaponList:
DB -$03*2, -$32*2 ; y, x
DB -$0B*2, -$3F*2 ; y, x
DB -$1E*2, -$3E*2 ; y, x
DB -$2F*2, -$32*2 ; y, x
DB -$37*2, -$1E*2 ; y, x
DB -$2F*2, -$10*2 ; y, x
DB -$0A*2, -$1E*2 ; y, x
DB -$1C*2, -$11*2 ; y, x
enemies_done_boss4
lda #$7f
_INTENSITY_A
lds shotlist_objects_head
puls d,pc ; jumpsto enemiesShots_done_boss4, which is: main1Boss4
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Boss fight done
extroBoss4 ;#isfunction
lda #2
sta explosionCount
lda #-1
sta boss4WeaponActive
ldx #extro4PointerSUB
stx bossExtroPointer
jmp extroBoss
extro4PointerSUB
REPLACE_1_2_displayFullDeathstar_varFrom0_2
ldx #0 ;displayFullDeathstar
jmp jsrBank0X
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
endif
if CURRENT_BANK = 2
;;;;;;; *****************************************
;;;;;;; * BANK 2 *
;;;;;;; *****************************************
displayBoss4
displayBoss4_0_0 ;#isfunction
jsr calibrationZero7
sts tmp4
lda #$60
_INTENSITY_A
lds playershotlist_objects_head
puls d,pc ; (D = y,x) ; do all objects
playerShotsDoneBoss04
lds tmp4
; check if boss was hit (change intensity)
tst bossWasHit
beq boss4NotHit
jsr Intensity_7F
bra intDoneBoss4
boss4NotHit
jsr Intensity_3F
intDoneBoss4
jsr bossDisplayHead
jsr calibrationZero50
clra
sta <VIA_shift_reg
ldd #0
std <VIA_port_b
ldd bossPosY
; bsr displayFullDeathstar
; rts
displayFullDeathstar
;.....................
jsr calibrationZero50
clra
sta <VIA_shift_reg
LDy #deathStarSceneData ; address of data
nextBoss4Part_a
ldu ,y++
beq headDoneBoss4
ldb gameScale
stB VIA_t1_cnt_lo
ldd bossPosY
if IS_VIA_FAULTY_RESISTENT = 1
jsr my_Moveto_d ; Moveto_d
else
JSR Moveto_d
endif
lda #50
sta VIA_t1_cnt_lo
jsr SMVB50_drawSmart
bra nextBoss4Part_a
headDoneBoss4
tst boss4WeaponActive
bmi noWeaponAtall4
;.....................
ldb gameScale
stB VIA_t1_cnt_lo
ldd bossPosY
adda #17
addb #28
if IS_VIA_FAULTY_RESISTENT = 1
jsr my_Moveto_d ; Moveto_d
else
JSR Moveto_d
endif
LDy #deathStarWeaponAnim
lda boss4WeaponActive
beq noBoss4Anim
cmpa #1
bne fastestBoss4Weapon
tst animDelayCounter
bne notAnimNextBoss4
fastestBoss4Weapon
inc boss4WeaponAnimCounter
notIncingBoss4Weapon
lda boss4WeaponAnimCounter
lsla
ldu a,y
bne notAnimNextBoss4
noBoss4Anim
clr boss4WeaponAnimCounter
notAnimNextBoss4
lda boss4WeaponAnimCounter
lsla
ldu a,y
lda #50
sta VIA_t1_cnt_lo
jsr SMVB50_drawSmart
noWeaponAtall4
tst displayExplosions
bne handleBossExplosions
noEplisionsBoss4
_ZERO_VECTOR_BEAM
rts
;
;..............................................
;
handleBossExplosions ;#isfunction
lda gameScale
sta <VIA_t1_cnt_lo
ldu #boss4explosionData
ldd ExPosy,u
beq trySecondExplosion
sex
addd #$80
std b4_tmp1
ldb playerXpos
sex
addd #$80
subd b4_tmp1
MY_LSR_D
bpl noNegpb4
negb
noNegpb4
stb b4_tmp1
ldb ExSize,u
asrb
cmpb b4_tmp1
blo notHItpv4
inc playerWasHitFor
notHItpv4
ldd ExPosy,u
if IS_VIA_FAULTY_RESISTENT = 1
jsr my_Moveto_d ; Moveto_d
else
JSR Moveto_d
endif
lda ExSize,u
inca
sta ExSize,u
cmpa #50
lbhi removeFirstExplosion
sta <VIA_t1_cnt_lo
asla
nega
adda #$7f
jsr Intensity_a
ldu #circleHalf
jsr SMVB50_drawSmart
trySecondExplosion
ldu #boss4explosionData+Boss4GroundExplosion
ldd ExPosy,u
beq tryThirdExplosion
sex
addd #$80
std b4_tmp1