forked from pkali/scorch_src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweapons.asm
3284 lines (3087 loc) · 75.3 KB
/
weapons.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
; @com.wudsn.ide.asm.mainsourcefile=scorch.asm
.IF *>0 ;this is a trick that prevents compiling this file alone
;--------------------------------------------------
.proc Explosion
; xdraw,ydraw (word) - coordinates of explosion center
; TankNr - number of shooting tank
; ActiveWeapon(TankNr) - weapon that tank fires
;--------------------------------------------------
;cleanup of the soil fall down ranges (left and right)
jsr ClearScreenSoilRange
ldx TankNr
lda ActiveWeapon,x
.endp
.proc ExplosionDirect
asl
tay
lda ExplosionRoutines+1,y
pha
lda ExplosionRoutines,y
pha
rts
ExplosionRoutines
.word babymissile-1 ;Baby_Missile ;_00
.word missile-1 ;Missile ;_01
.word babynuke-1 ;Baby_Nuke ;_02
.word nuke-1 ;Nuke ;_03
.word leapfrog-1 ;LeapFrog ;_04
.word funkybomb-1 ;Funky_Bomb ;_05
.word BFG.mirv-1 ;MIRV ;_06
.word deathshead-1 ;Death_s_Head ;_07
.word napalm-1 ;Napalm ;_08
.word hotnapalm-1 ;Hot_Napalm ;_09
.word BFG.tracer-1 ;Tracer ;_10
.word BFG.tracer-1 ;Smoke_Tracer ;_11
.word babyroller-1 ;Baby_Roller ;_12
.word roller-1 ;Roller ;_13
.word heavyroller-1 ;Heavy_Roller ;_14
.word riotcharge-1 ;Riot_Charge ;_15
.word riotblast-1 ;Riot_Blast ;_16
.word riotbomb-1 ;Riot_Bomb ;_17
.word heavyriotbomb-1 ;Heavy_Riot_Bomb;_18
.word digger-1 ;Digger ;_19
.word heavydigger-1 ;Heavy_Digger ;_20
.word sandhog-1 ;Sandhog ;_21
.word heavysandhog-1 ;Heavy_Sandhog ;_22
.word dirtclod-1 ;Dirt_Clod ;_23
.word dirtball-1 ;Dirt_Ball ;_24
.word tonofdirt-1 ;Ton_of_Dirt ;_25
.word liquiddirt-1 ;Liquid_Dirt ;_26
.word dirtcharge-1 ;Dirt_Charge ;_27
.word propaganda-1 ;Propaganda ;_28
.word punch-1 ;Baby_Sandhog ;_29
.word BFG-1 ;Buy_me ;_30
.word laser-1 ;Laser ;_31
.word plasmablast-1 ; additional "weapon" only for tanks death
.endp
.proc BFG
mva #sfx_plasma_2_2 sfx_effect
jsr BFGblink
; Kill all :)
ldx NumberOfPlayers
dex
lda #$00
CheckNextTankBFG
cpx TankNr ; not me!
beq @+
sta Energy,x
@ dex
bpl CheckNextTankBFG
stx AfterBFGflag ; $ff
VOID
tracer
mirv
rts
.endp
; ------------------------
.proc babymissile
lda #11 ; ExplosionRadius
GoBabyMissileSFX
sta ExplosionRadius
mva #sfx_baby_missile sfx_effect
GoXmissile
jmp xmissile
.endp
; ------------------------
.proc missile ;
lda #17 ; ExplosionRadius
bne babymissile.GoBabyMissileSFX
; jmp xmissile
.endp
; ------------------------
.proc babynuke
lda #25 ; ExplosionRadius
GoBabyNukeSFX
sta ExplosionRadius
mva #sfx_nuke sfx_effect ; allways <>0
bne babymissile.GoXmissile
; jmp xmissile
.endp
; ------------------------
.proc nuke
lda #30 ; ExplosionRadius
bne babynuke.GoBabyNukeSFX
; jmp xmissile
.endp
; ------------------------
.proc leapfrog
lda #17 ; ExplosionRadius
; mva #sfx_baby_missile sfx_effect
; jsr xmissile
jsr babymissile.GoBabyMissileSFX
jsr SecondRepeat
SecondRepeat
; soil must fall down now! there is no other way...
; hide tanks or they fall down with soil
jsr SoilDown
; it looks like force is divided by 4 here BUT"
; in Flight routine force is multiplied by 2 and left
; so, we have Force divided by 2 here (not accurately)
;lsr Force+1
;ror Force
lsr Force+1
ror Force
mva LeapFrogAngle Angle
mva #sfx_funky_hit sfx_effect
sbw ytraj+1 #$05 ; next missiles start point goes 5 pixel UP to prevent multiple explosion at one point if tank is hit (4 pixels tank height + 1)
jsr Flight
lda HitFlag
beq EndOfLeapping
mva #14 ExplosionRadius
jsr CalculateExplosionRange0
mva #sfx_baby_missile sfx_effect
jmp xmissile.NoRangeCalc
EndOfLeapping
rts
.endp
; ------------------------
;.proc mirv ; the whole mirv is performed by Flight routine
; rts
;.endp
; ------------------------
.proc funkybomb ;
mva #sfx_baby_missile sfx_effect
mwa xtraj+1 xtrajfb
sbw ytraj+1 #$05 ytrajfb ; funky missiles start point goes 5 pixel UP to prevent multiple explosion at one point if tank is hit (4 pixels tank height + 1)
;central Explosion
mva #21 ExplosionRadius
jsr CalculateExplosionRange0
jsr xmissile.NoRangeCalc
jsr SoilDown
;
jsr cleartanks ; maybe not?
mva #1 color
mva #0 FunkyWallFlag
mva #5 FunkyBombCounter
FunkyBombLoop
mva #1 tracerflag
;force randomization (range: 256-511)
lda random
sta Force
mva #1 Force+1
;Angle randomization Range: (70-110 degrees)
randomize 70 110
sta Angle
lda #0
sta xtraj
sta ytraj
mwa xtrajfb xtraj+1
mwa ytrajfb ytraj+1
mva #sfx_funky_hit sfx_effect
jsr Flight
mva #0 ExplosionRadius ; if no explosion (off screen)
; if xdraw if over range then fix it
lda xdraw+1
bpl NoOnLeftEdge
lda #0
sta xdraw
sta xdraw+1
NoOnLeftEdge
cpw xdraw #screenwidth
bcc NoOnRightEdge
mwa #screenwidth xdraw
NoOnRightEdge
jsr CalculateExplosionRange ; add end of flight coordinates to soildown range
lda HitFlag
beq NoExplosionInFunkyBomb
mva #sfx_baby_missile sfx_effect
mva #11 ExplosionRadius
jsr xmissile
NoExplosionInFunkyBomb
dec FunkyBombCounter
bne FunkyBombLoop
mva #0 tracerflag
lda FunkyWallFlag
beq NoWallsInFunky
jsr SetFullScreenSoilRange
NoWallsInFunky
rts
.endp
; ------------------------
.proc deathshead
mva #30 ExplosionRadius
jsr GoXmissileWithSaveXYdraw
sbw xdraw #34
jsr GoXmissileWithSaveXYdraw
adw xdraw #68
jsr GoXmissileWithSaveXYdraw
sbw xdraw #34
;
sbw ydraw #34
;jsr CalculateExplosionRange
cpw ydraw #screenHeight
bcs NoUpperCircle
jsr GoXmissileWithSaveXYdraw
NoUpperCircle
adw ydraw #68
;jsr CalculateExplosionRange
cpw ydraw #screenHeight
bcs NoLowerCircle
jsr GoXmissileWithSaveXYdraw
NoLowerCircle
rts
GoXmissileWithSaveXYdraw
mva #sfx_nuke sfx_effect
mwa xdraw tempXROLLER
mwa ydraw modify
jsr xmissile
mwa tempXROLLER xdraw
mwa modify ydraw
rts
.endp
; ------------------------
.proc napalm
lda #0 ; in this weapon - flag: 0 - napalm, 1 - hotnapalm
beq xnapalm
.endp
; ------------------------
.proc hotnapalm
lda #1 ; in this weapon - flag: 0 - napalm, 1 - hotnapalm
; jmp xnapalm
.endp
; ------------------------
.proc xnapalm
sta HotNapalmFlag
mva #sfx_napalm sfx_effect
mva #(napalmRadius+4) ExplosionRadius ; real radius + 4 pixels (half characrer width)
jsr CalculateExplosionRange
;
mwa xdraw xcircle ; store hitpoint for future repeats
ldy #30 ; repeat 30 times
sty magic
RepeatNapalm ; external loop (for fire animation)
mwa xcircle xdraw
sbw xdraw #(napalmRadius) ; 10 pixels on left side hit point
ldy #0
sty Erase ; becouse Erase flag is set!
sty magic+1
RepeatFlame ; internal loop (draw flames)
ldy #0
adw xdraw #mountaintable temp
sty ydraw+1
lda (temp),y
sec
sbc #1 ; over ground
sta ydraw
lda xdraw
and HotNapalmFlag ; if hotnapalm and x is odd:
:2 asl ; modify y position 4 pixels up
ldy ydraw
sta ydraw
tya
sec
sbc ydraw
sta ydraw
sbw xdraw #4 ; half character correction
; draw flame symbol
lda magic ; if last repeat - clear flames
beq LastNapalmRepeat
lda random
and #%00000110
clc
adc #char_flame
bne PutFlameChar
LastNapalmRepeat
lda #char_clear_flame ; clear flame symbol
PutFlameChar
sta CharCode
jsr TypeChar
adw xdraw #5 ; reverse half character correction (4 px - we need positon of character center) and next char 1 pixels to righ
inc magic+1
lda magic+1
cmp #(2*napalmRadius+1) ; 10 pixels on left, 10 pixels on right and 1 in center
jne RepeatFlame
dec magic
jpl RepeatNapalm
; after napalm
;now we must check tanks in range
ldx NumberOfPlayers
dex
BurnedCheckLoop
lda eXistenZ,x
beq EndNurnedCheckLoop
;here the tank exist
; calculate right edge of the fire
adw xcircle #(napalmRadius+4+4) xdraw ; 10 pixels on right side hit point + half character width + correction
; now we compare tank position with right edge of the fire (napalm)
lda XtankstableH,x
cmp xdraw+1
bne @+
lda XtankstableL,x
cmp xdraw
@
bcs TankOutOfFire
; let's calculate left edge of the fire
sbw xcircle #(napalmRadius+TankWidth+4-4) xdraw ; 10 pixels on left + character width (tank) + half character - correction
bpl @+
mwa #0 xdraw ; left screen edge
@
; now we compare tank position with left edge of the fire (napalm)
lda XtankstableH,x
cmp xdraw+1
bne @+
lda XtankstableL,x
cmp xdraw
@
bcc TankOutOfFire
ldy #40 ; energy decrease (napalm) - but if hotnapalm:
lda HotNapalmFlag
beq NotHot
ldy #80 ; energy decrease (hotnapalm)
NotHot
; check shields ( joke :) )
jsr DecreaseEnergyX
TankOutOfFire
EndNurnedCheckLoop
dex
bpl BurnedCheckLoop
rts
.endp
; ------------------------
.proc babyroller
lda #11 ; ExplosionRadius
GoRoller
sta ExplosionRadius
jmp xroller
.endp
; ------------------------
.proc roller ;
lda #21 ; ExplosionRadius
bne babyroller.GoRoller ; 1 byte saved
; jmp xroller
.endp
; ------------------------
.proc heavyroller
lda #30 ; ExplosionRadius
bne babyroller.GoRoller ; 1 byte saved
; jmp xroller
.endp
; ------------------------
.proc riotbomb
lda #17 ; ExplosionRadius
GoRiotBomb
sta ExplosionRadius
jsr CalculateExplosionRange
jmp xriotbomb
.endp
; ------------------------
.proc heavyriotbomb
lda #29 ; ExplosionRadius
bne riotbomb.GoRiotBomb ; 4 bytes saved - optimization :)
; jsr CalculateExplosionRange
; jmp xriotbomb
.endp
; ------------------------
.proc propaganda
; It floods the target with propaganda texts.
lda #80 ; max text width with additional margins (left/right edges of the screen)
sta ExplosionRadius ; set soildown range
jsr CalculateExplosionRange
mwa xdraw tempXROLLER ; save X coordinate of hitpoint
mva #11 TempXfill ; number of text to display
nexttext
; play SFX
mva #sfx_digger sfx_effect
@ lda random ; randomize propaganda messege
cmp #talk.NumberOfPropagandaTexts
bcs @-
sta TextNumberOff
; all text start from `talk` and end with an inverse.
; we go through the `talk`, count number of inverses.
; if equal to TextNumberOff, it is our text, printit
lda #$ff
sta plot4x4color
mwa #talk LineAddress4x4
jsr _calc_inverse_display
; now find length of the text
@ iny
lda (LineAddress4x4),y
bpl @-
iny
sty fx
mwa tempXROLLER temp ; X coordinate of hitpoint
; calculate position of message
jsr Calculate4x4TextPosition
; and randomize Y coordinate (+/- 16pixels)
lda random
and #%00011111
adc LineYdraw
sbc #16
sta LineYdraw
; randomize X coordinate (+/- 8 pixels)
lda random
and #%00000111
clc
adc LineXdraw
sta LineXdraw
bcc @+
inc LineXdraw+1
@ sec
sbc #4
sta LineXdraw
bcs DisplayMessage
dec LineXdraw+1
DisplayMessage
; display propaganda message
jsr TypeLine4x4.noLengthNoColor
ldy #7
jsr PauseYFrames
dec TempXfill
bne nexttext
rts
.endp
; ------------------------
.proc digger ;
lda #3 ; diggery ; how many branches (-1)
GoDiggerSFX
sta diggery
mva #sfx_digger sfx_effect
mva #0 sandhogflag
mva #13 DigLong
bne xdigger
.endp
; ------------------------
.proc heavydigger
lda #7 ; diggery ; how many branches (-1)
bne digger.GoDiggerSFX
.endp
; ------------------------
.proc babysandhog
lda #1 ; diggery ; how many branches (-1)
bne heavysandhog.GoHeavysandhogSFX
.endp
; ------------------------
.proc sandhog
lda #3 ; diggery ; how many branches (-1)
bne heavysandhog.GoHeavysandhogSFX
.endp
; ------------------------
.proc heavysandhog
lda #5 ; diggery ; how many branches (-1)
GoHeavysandhogSFX
sta diggery
mva #sfx_sandhog sfx_effect
mva #char_sandhog_offset sandhogflag
mva #13 DigLong
; jmp xdigger
.endp
; ------------------------
.proc xdigger
;mwa xdraw digstartx
;mwa ydraw digstarty
ldx diggery
WriteToBranches
lda xdraw
sta digtabxL,x
lda xdraw+1
sta digtabxH,x
lda ydraw
sta digtabyL,x
lda ydraw+1
sta digtabyH,x
dex
bpl WriteToBranches
jsr DiggerCharacter ; start character
adw xdraw #4
lda DigLong
; looks strange, but it is (DigLong+2)*4
clc
adc #$2
asl
asl
sta ExplosionRadius
jsr CalculateExplosionRange
BranchNotFinished
ldx diggery
CalculateBranches
txa
and #$01
bne DigRight
diglewy ; even branches go left
sec
lda digtabxL,x
sbc #$04
sta digtabxL,x
scs
dec digtabxH,x
jmp DigRandomize
DigRight ; odd go right (everytime 4 pixels)
clc
lda digtabxL,x
adc #$04
sta digtabxL,x
scc
inc digtabxH,x
DigRandomize
lda random
;and #$87
bmi DigUp
DigDown
and #$07
clc
adc digtabyL,x
sta digtabyL,x
scc
inc digtabyH,x
jmp DigCalculateNext
DigUp
and #$07
sta temp
sec
lda digtabyL,x
sbc temp
sta digtabyL,x
scs
dec digtabyH,x
DigCalculateNext
dex
bpl CalculateBranches
; here we draw...
ldx diggery
DigDrawing
lda digtabxL,x
sta xdraw
lda digtabxH,x
sta xdraw+1
lda digtabyL,x
sta ydraw
lda digtabyH,x
sta ydraw+1
phx
jsr DiggerCharacter
plx
dex
bpl DigDrawing
dec:lda DigLong
jpl BranchNotFinished
DoNotPutDig
rts
DiggerCharacter
lda random
and #$06
clc
adc #char_digger
adc sandhogflag
sta CharCode
cpw xdraw #(screenwidth-6)
bcs DoNotPutDig
jmp TypeChar
.endp
; ------------------------
.proc dirtclod
lda #12 ; ExplosionRadius
bne xdirt
.endp
; ------------------------
.proc dirtball
lda #22 ; ExplosionRadius
bne xdirt
.endp
; ------------------------
.proc tonofdirt
lda #31 ; ExplosionRadius
; jmp xdirt
.endp
; -----------------
.proc xdirt ;
; -----------------
sta ExplosionRadius
jsr CalculateExplosionRange
mva #sfx_dirt_charge sfx_effect
lda #1
sta radius
sta color
dirtLoop
jsr circle
inw ydraw
jsr circle
.nowarn dew ydraw
inc radius
lda radius
cmp ExplosionRadius
bne dirtLoop
rts
.endp
; ------------------------
.proc dirtcharge
mva #61 ExplosionRadius
jsr CalculateExplosionRange
jmp ofdirt
.endp
; ------------------------
.proc riotcharge
mva #sfx_riot_blast sfx_effect
mva #31 ExplosionRadius
bne cleanDirt
.endp
; ------------------------
.proc riotblast
mva #sfx_riot_blast sfx_effect
mva #61 ExplosionRadius
; jmp cleanDirt
.endp
; -----------------
.proc cleanDirt
; -----------------
jsr CalculateExplosionRange
mva #0 color
jmp ofdirt.NoColor
.endp
; ------------------------
.proc liquiddirt
mva #sfx_liquid_dirt sfx_effect
mwa #510 FillCounter
; -----
mwa xdraw TempXfill
RepeatFill
mwa TempXfill xdraw
jsr checkRollDirection
; HowMuchToFall - direction
; $FF - we are in a hole (flying in missile direction)
; 1 - right, 2 - left
adw xdraw #mountaintable tempXROLLER
ldy #0
lda (tempXROLLER),y
sta HeightRol ; relative point
RollinContinuesLiquid
; new point is set
adw xdraw #mountaintable tempXROLLER
ldy #0
lda (tempXROLLER),y
sta ydraw
cmp HeightRol
beq UpNotYet2
bcc FillNow
UpNotYet2
sec ;clc
sta HeightRol
sbc #1
sta ydraw
lda HowMuchToFall
cmp #1
beq HowMuchToFallRight3
.NOWARN dew xdraw
lda xdraw
and xdraw+1
cmp #$ff ; like cpw xdraw #$ffff
;ora xdraw+1 ; like cpw xdraw #$0000
jne RollinContinuesLiquid
beq FillNow
HowMuchToFallRight3
inw xdraw
cpw xdraw #screenwidth
jne RollinContinuesLiquid
FillNow
; finally one pixel more
ldy #0
lda HowMuchToFall
bmi FillHole
cmp #1
beq FillLeft
inw xdraw
inw xdraw ; tricky but we must rollback xdraw in proper direction
FillLeft
.nowarn dew xdraw
FillHole
adw xdraw #mountaintable tempXROLLER
lda (tempXROLLER),y
sta ydraw
beq ToHighFill ; if we filled all playfield (very rare but possible)
dec ydraw ; one pixel up
lda ydraw
sta (tempXROLLER),y ;mountaintable update
mva #1 color
jsr plot.MakePlot
ToHighFill
.nowarn dew FillCounter
lda FillCounter
ora FillCounter+1
jne RepeatFill
rts
.endp
; ------------------------
.proc laser
; in xdraw and ydraw we have hit point coordinates
; from Shoot/Flight procedures (invisible flight)
; ------------------------
; ldx TankNr
lda AngleTable,x
tay
mwa EndOfTheBarrelX xbyte
mva EndOfTheBarrelY ybyte
mva #0 ybyte+1
sta LaserFlag ; turn on gravity and wind after shot :)
;mwa xdraw LaserCoordinate
;mwa ydraw LaserCoordinate+2
mwa xbyte LaserCoordinate
mwa ybyte LaserCoordinate+2
mva #sfx_lightning sfx_effect
mva #%10000000 drawFunction
;the above switches Draw to measuring length
jsr draw
mva #0 drawFunction
lsr LineLength+1 ; LineLength / 8
ror LineLength
lsr LineLength ; max line lenght is about 380 (9 bits)
lsr LineLength
sec
lda #60
sbc LineLength
sta yc ; laser blink counter 60-(LineLength/8)
@
lda yc
and #$01
eor #$01
sta color
;mwa LaserCoordinate xdraw
;mwa LaserCoordinate+2 ydraw
mwa LaserCoordinate xbyte
mwa LaserCoordinate+2 ybyte
mva #sfx_lightning sfx_effect
jsr draw
dec yc
bne @-
; at this point color allways = 0
inc color ; set color to 1
;mwa LaserCoordinate xdraw ; draw does not change xdraw and ydraw
;mwa LaserCoordinate+2 ydraw
mva #0 HitFlag
jsr CheckCollisionWithTank
lda HitFlag
beq LaserMisses
; here we hit a tank (X)
ldy #100
jsr DecreaseEnergyX
LaserMisses
rts
.endp
; -----------------
.proc plasmablast
; -----------------
; idea only ....
mva #sfx_plasma_1_2 sfx_effect
mva #0 drawFunction
mva #$07 ExplosionRadius
jsr CalculateExplosionRange
adw ydraw #4
sbw xdraw #4
lda ydraw
lsr
lsr
lsr
sta yc
lda #30
sbc yc
sta yc ; blink counter 60
columnloop
mva #8 fs ;lines counter
linesloop
lda yc
beq @+
lda random
@ and #$01
sta color
mwa xdraw xbyte
mwa #0 ybyte
jsr draw
inw xdraw
dec fs
bne linesloop
sbw xdraw #8
dec yc
bpl columnloop
; at this point color allways = 0
inc color ; set color to 1
rts
.endp
; -----------------
.proc xmissile ;
; -----------------
jsr CalculateExplosionRange
NoRangeCalc
lda #1
sta radius
sta color
ExplosionLoop
jsr circle
:2 inc radius
lda radius
cmp ExplosionRadius
bcc ExplosionLoop
ldx #0
stx color
inx
stx radius
ExplosionLoop2
jsr circle
inc radius
lda radius
cmp ExplosionRadius
bcc ExplosionLoop2
mva #1 color
;check tanks' distance from the centre of the explosion
mva #%10000000 drawFunction
;the above switches Draw to measuring length
;trick is easy - how many pixels does it take to draw
;a line from one point to another
;it must be somehow easier than regular Pitagoras
;calculation
ldx NumberOfPlayers
dex
DistanceCheckLoop
lda eXistenZ,x
jeq EndOfDistanceCheckLoop
;here the tank exist
lda XtankstableL,x
clc
adc #3 ;measure from middle of the tank
sta xbyte
lda XtankstableH,x
; clc ; ops :)
adc #0 ;measure from middle of the tank
sta xbyte+1
lda Ytankstable,x
sec
sbc #2 ;measure from middle of the tank
sta ybyte
lda #0
sta ybyte+1
phx
jsr draw
plx
;if tank within range of the explosion?
lda LineLength+1
bne TankIsNotWithinTheRange
lda LineLength
cmp ExplosionRadius
bcs TankIsNotWithinTheRange
lda ExplosionRadius
sec
sbc LineLength
;multiply difference by 8
clc
adc #1
:3 asl
tay
; check shields
lda ActiveDefenceWeapon,x
cmp #ind_Shield ; one hit shield
beq UseShield
cmp #ind_Force_Shield ; shield with energy and parachute
beq UseShieldWithEnergy
cmp #ind_Heavy_Shield ; shield with energy
beq UseShieldWithEnergy
cmp #ind_Bouncy_Castle ; Auto Defence (it works only if hit ground next to tank. Tank hit is handled in Flight proc)
beq UseShieldWithEnergy
cmp #ind_Mag_Deflector ; Mag deflector (it works only if hit ground next to tank. Tank hit is handled in Flight proc)
beq UseShieldWithEnergy
jsr DecreaseEnergyX
jmp EndOfDistanceCheckLoop
UseShieldWithEnergy
jsr DecreaseShieldEnergyX
cpy #0 ; is necessary to reduce tenk energy ?
beq ShieldCoveredTank
jsr DecreaseEnergyX
ShieldCoveredTank
lda ShieldEnergy,x
jne EndOfDistanceCheckLoop
ShieldEnergy0 ; deactivate if no energy. it's like use one hit shield :)
UseShield
lda TankNr
pha ; store TankNr
stx TankNr ; store X in TankNr :)
jsr ClearTankNr ; now erase tank with shield (to erase shield)
lda #0
sta ActiveDefenceWeapon,x ; deactivate defense weapons
jsr PutTankNr ; draw tank without shield
ldx TankNr ; restore X value :)
pla
sta TankNr ; restore TankNr value :)
TankIsNotWithinTheRange
EndOfDistanceCheckLoop
dex
jpl DistanceCheckLoop
rts
.endp
; -----------------
.proc xriotbomb ;
; -----------------
mva #sfx_riot_blast sfx_effect
lda #0
sta radius
sta color
rbombLoop
jsr circle
inc radius
lda radius
cmp ExplosionRadius
bne rbombLoop
mva #1 color
rts
.endp
; ----------------
.proc xroller ;
; now collisions are detected with modified draw routine
; therefore YDRAW value must be taken from mountaintable
jsr checkRollDirection
; HowMuchToFall - direction
; $FF - we are in a hole (flying in missile direction)
; 1 - right, 2 - left
Rollin
mva #sfx_shield_off sfx_effect
adw xdraw #mountaintable tempXROLLER
ldy #0
lda (tempXROLLER),y
sta HeightRol ; relative point
RollinContinues
jsr WaitOneFrame
jsr WaitOneFrame
; new point is set
adw xdraw #mountaintable tempXROLLER
ldy #0
lda (tempXROLLER),y
sta ydraw
sty ydraw+1
beq ExplodeNow
cmp HeightRol
beq UpNotYet
bcc ExplodeNow
UpNotYet
sec ;clc
sta HeightRol
sbc #1
sta ydraw
;check tank collision prior to PLOT
sty HitFlag ; set to 0
jsr CheckCollisionWithTank
lda HitFlag
bne ExplodeNow
jsr unPlot
; let's go the right direction
lda HowMuchToFall
cmp #1
beq HowMuchToFallRight2
.nowarn dew xdraw
lda xdraw
ora xdraw+1
jne RollinContinues ; like cpw xdraw #0