-
Notifications
You must be signed in to change notification settings - Fork 9
/
bank3.asm
2109 lines (1951 loc) · 34 KB
/
bank3.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
INCLUDE "gbhw.asm"
INCLUDE "sound_constants.asm"
SECTION "bank 3", ROMX, BANK[3]
LevelPointersBank3:: ; 3:4000
dw $503F
dw $5074
dw $509B
dw $503F
dw $5074
dw $509B
dw $503F ; 3-1
dw $5074 ; 3-2
dw $509B ; 3-3
dw $503F
dw $5074
dw $509B
dw $50C0 ; End of world "hangar"
LevelEnemyPointersBank3:: ; 3:401A
dw $4E74
dw $4F1D
dw $4FD8
dw $4E74
dw $4F1D
dw $4FD8
dw $4E74 ; 3-1
dw $4F1D ; 3-2
dw $4FD8 ; 3-3
dw $4E74
dw $4F1D
dw $4FD8
INCBIN "gfx/enemiesWorld3.2bpp"
INCBIN "gfx/backgroundWorld3.2bpp"
ReadJoypad:: ; 47F2
ld a, $20 ; select button keys
ldh [rJOYP], a
ldh a, [rJOYP]
ldh a, [rJOYP] ; read multiple times to avoid switch bounce
cpl ; 0 means pressed
and a, $0F
swap a
ld b, a
ld a, $10 ; select direction keys
ldh [rJOYP], a
ldh a, [rJOYP]
ldh a, [rJOYP]
ldh a, [rJOYP]
ldh a, [rJOYP]
ldh a, [rJOYP]
ldh a, [rJOYP]
cpl
and a, $0F
or b
ld c, a
ldh a, [hJoyHeld]
xor c ; set all bits which are different since the previous time
and c ; and keep only the ones that are pressed now
ldh [hJoyPressed], a
ld a, c
ldh [hJoyHeld], a
ld a, $30
ldh [rJOYP], a ; deselect keys
ret
Call_4823:: ; 4823
ld a, h
ldh [$FF96], a
ld a, l
ldh [$FF97], a
ld a, [hl]
and a
jr z, .jmp_484A
cp a, $80
jr z, .jmp_4848
.jmp_4831
ldh a, [$FF96]
ld h, a
ldh a, [$FF97]
ld l, a
ld de, $0010
add hl, de
ldh a, [$FF8F]
dec a
ldh [$FF8F], a
ret z
jr Call_4823
.jmp_4843
xor a
ldh [$FF95], a
jr .jmp_4831
.jmp_4848
ldh [$FF95], a
.jmp_484A
ld b, $07
ld de, $FF86
.jmp_484F
ldi a, [hl]
ld [de], a
inc de
dec b
jr nz, .jmp_484F
ldh a, [$FF89]
ld hl, $4C37
rlca
ld e, a
ld d, $00
add hl, de
ld e, [hl]
inc hl
ld d, [hl]
ld a, [de]
ld l, a
inc de
ld a, [de]
ld h, a
inc de
ld a, [de]
ldh [$FF90], a
inc de
ld a, [de]
ldh [$FF91], a
ld e, [hl]
inc hl
ld d, [hl]
.jmp_4872
inc hl
ldh a, [$FF8C]
ldh [$FF94], a
ld a, [hl]
cp a, $FF
jr z, .jmp_4843
cp a, $FD
jr nz, .jmp_488C
ldh a, [$FF8C]
xor a, $10
ldh [$FF94], a
jr .jmp_4872
.jmp_4888
inc de
inc de
jr .jmp_4872
.jmp_488C
cp a, $FE
jr z, .jmp_4888
ldh [$FF89], a
ldh a, [$FF87]
ld b, a
ld a, [de]
ld c, a
ldh a, [$FF8B]
bit 6, a
jr nz, .jmp_48A3
ldh a, [$FF90]
add b
adc c
jr .jmp_48AD
.jmp_48A3
ld a, b
push af
ldh a, [$FF90]
ld b, a
pop af
sub b
sbc c
sbc a, $08
.jmp_48AD
ldh [$FF93], a
ldh a, [$FF88]
ld b, a
inc de
ld a, [de]
inc de
ld c, a
ldh a, [$FF8B]
bit 5, a
jr nz, .jmp_48C2
ldh a, [$FF91]
add b
adc c
jr .jmp_48CC
.jmp_48C2
ld a, b
push af
ldh a, [$FF91]
ld b, a
pop af
sub b
sbc c
sbc a, $08
.jmp_48CC
ldh [$FF92], a
push hl
ldh a, [$FF8D]
ld h, a
ldh a, [$FF8E]
ld l, a
ldh a, [$FF95]
and a
jr z, .jmp_48DE
ld a, $FF
jr .jmp_48E0
.jmp_48DE
ldh a, [$FF93]
.jmp_48E0
ldi [hl], a
ldh a, [$FF92]
ldi [hl], a
ldh a, [$FF89]
ldi [hl], a
ldh a, [$FF94]
ld b, a
ldh a, [$FF8B]
or b
ld b, a
ldh a, [$FF8A]
or b
ldi [hl], a
ld a, h
ldh [$FF8D], a
ld a, l
ldh [$FF8E], a
pop hl
jp .jmp_4872
.jmp_48FC
ld hl, $C209
ld a, [hl]
ld b, a
and a
ret z
dec l
ld a, [hl]
cp a, $0F
ret nc
ld [hl], b
inc l
ld [hl], 0
ret
Call_490D:: ; 490D
ld a, [bc] ; C2x8
ld e, a
ld d, $00
dec c
ld a, [bc] ; C2x7
dec c
dec c
dec c
dec c
dec c
dec c
and a
ret z
cp a, $02
jr z, .jmp_4933
add hl, de
ld a, [hl]
cp a, $7F
jr z, .jmp_4948
ld a, [bc] ; C2x1
sub [hl]
ld [bc], a
inc e
.jmp_4929
ld a, e
inc c
inc c
inc c
inc c
inc c
inc c
inc c
ld [bc], a ; C2x8
ret
.jmp_4933
ld a, e
cp a, $FF
jr z, .jmp_495B
add hl, de
ld a, [hl]
cp a, $7F
jr z, .jmp_4944
.jmp_493E
ld a, [bc] ; C2x1
add [hl]
ld [bc], a
dec e
jr .jmp_4929
.jmp_4944
dec hl
dec e
jr .jmp_493E
.jmp_4948
dec de
dec hl
ld a, $02
inc c
inc c
inc c
inc c
inc c
inc c
ld [bc], a
dec c
dec c
dec c
dec c
dec c
dec c
jr .jmp_493E
.jmp_495B
xor a
inc c
inc c
inc c
inc c
inc c
inc c
ld [bc], a
inc c
ld [bc], a
ret
Jmp_4966:: ; 4966
inc e
ld a, [de]
cp a, $0F
jr nc, .jmp_49B5
inc e
dec a
ld [de], a
dec e
ld a, $0F
ld [de], a
jr .jmp_49B5
.jmp_4975
push af
ld a, [de]
and a
jr nz, .jmp_4988
ld a, [$C20C]
cp a, $03
ld a, $02
jr c, .jmp_4985
ld a, $04
.jmp_4985
ld [$C20E], a ; walking or running
.jmp_4988
pop af
jr .jmp_49AC
.jmp_498B
ldh a, [hGameState]
cp a, $0D
jp z, .jmp_4A7F
ld de, $C207 ; jump status
ldh a, [hJoyPressed]
ld b, a
ldh a, [hJoyHeld]
bit 1, a ; B button todo
jr nz, .jmp_4975
push af
ld a, [$C20E] ; walking running
cp a, $04
jr nz, .jmp_49AB
ld a, $02
ld [$C20E], a
.jmp_49AB
pop af
.jmp_49AC
bit 0, a ; A button
jr nz, .jmp_49BF
ld a, [de]
cp a, $01
jr z, Jmp_4966
.jmp_49B5
bit 7, b ; Down button
jp nz, .jmp_4A77
.jmp_49BA
bit 1, b ; B button
jr nz, .jmp_49FD
ret
.jmp_49BF
ld a, [de]
and a
jr nz, .jmp_49B5
ld hl, $C20A ; 1 if on ground
ld a, [hl]
and a
jr z, .jmp_49B5
bit 0, b ; A button
jr z, .jmp_49B5
ld [hl], $00
ld hl, $C203 ; animation thing
push hl
ld a, [hl]
cp a, $18 ; crouching big?
jr z, .jmp_49F2
and a, $F0
or a, $04
ld [hl], a
ld a, [$C20E] ; walking running
cp a, $04
jr z, .jmp_49ED
ld a, $02
ld [$C20E], a
ld [$C208], a
.jmp_49ED
ld hl, $C20C
ld [hl], $30
.jmp_49F2
ld hl, $DFE0
ld [hl], SFX_JUMP
ld a, $01
ld [de], a
pop hl
jr .jmp_49B5
.jmp_49FD
ld hl, $C20C
ld a, [hl]
cp a, $06
jr nz, .jmp_4A0C
ldh a, [$FF9F]
and a
jr nz, .jmp_4A0C
ld [hl], $00
.jmp_4A0C
ldh a, [hGameState]
cp a, $0D
ld b, $03
jr z, .jmp_4A1A
ldh a, [hSuperballMario]
and a
ret z
ld b, $01
.jmp_4A1A
ld hl, $FFA9 ; projectile status?
ld de, wOAMBuffer
.jmp_4A20
ldi a, [hl]
and a
jr z, .jmp_4A2C
inc e
inc e
inc e
inc e
dec b
jr nz, .jmp_4A20
ret
.jmp_4A2C
push hl
ld hl, $C205
ld b, [hl]
ld hl, $C201
ldi a, [hl]
add a, $FE
ld [de], a
inc e
ld c, $02
bit 5, b ; left button
jr z, .jmp_4A41
ld c, $F8
.jmp_4A41
ldi a, [hl]
add c
ld [de], a
ld c, $60
inc e
ldh a, [hGameState]
cp a, $0D
jr nz, .jmp_4A57
ld c, $7A
ldh a, [hLevelIndex]
cp a, $0B ; last level?
jr nz, .jmp_4A57
ld c, $6E
.jmp_4A57
ld a, c
ld [de], a
inc e
xor a
ld [de], a
pop hl
dec l
ld c, $0A
bit 5, b ; left button?
jr nz, .jmp_4A66
ld c, $09
.jmp_4A66
ld [hl], c
ld hl, $DFE0
ld [hl], SFX_SUPERBALL
ld a, $0C
ld [$C0AE], a
ld a, $FF
ld [wSuperballTTL], a
ret
.jmp_4A77
ld hl, $C20C
ld [hl], $20
jp .jmp_49BA
.jmp_4A7F
ldh a, [hJoyPressed]
and a, $03 ; A or B
jr nz, .jmp_4A0C
ldh a, [hJoyHeld]
bit 0, a ; A button
ret z
ld hl, $C0AE
ld a, [hl]
and a
.jmp_4A8F
jp z, .jmp_4A0C
dec [hl]
ret
INCBIN "baserom.gb", $CA94, $4E74 - $4A94
SECTION "bank 3 levels", ROMX[$503F], BANK[3]
INCBIN "baserom.gb", $D03F, $6600 - $503F
Data_6600:
dw StartJumpSFX
dw StartSuperballSFX
dw StartStompSFX
dw StartGrowSFX
dw StartCoinSFX
dw StartInjurySFX
dw StartBumpSFX
dw StartOneUpSFX
dw StartGiraSFX
dw StartTimerTickSFX
dw StartFlowerSFX
Data_6616:
dw ContinueJumpSFX
dw ContinueSquareSFX
dw ContinueStompSFX
dw ContinueSweepSquareSFX
dw ContinueCoinSFX
dw ContinueInjurySFX
dw ContinueSquareSFX
dw ContinueOneUpSFX
dw ContinueSquareSFX
dw ContinueSquareSFX
dw ContinueSweepSquareSFX
Data_662C:
dw StartExplosionSFX
dw StartBrickShatterSFX
dw StartDeathCrySFX
dw StartFireBreathSFX
Data_6634:
dw ContinueNoiseSFX
dw ContinueNoiseSFX
dw ContinueDeathCrySFX
dw ContinueNoiseSFX
; dump_music.py
Data_663C:
dw Song_6F98 ; 1
dw Song_6FA3
dw Song_6FAE
dw Song_6FB9
dw Song_6FC4 ; 5
dw Song_6FCF
dw Song_6FDA
dw Song_6FE5
dw Song_78DC
dw Song_78E7 ; 10
dw Song_78F2
dw Song_78FD
dw Song_7908
dw Song_7913
dw Song_791E ; 15
dw Song_7929
dw Song_7D6A
dw Song_7934
dw Song_793F ; 19
_Call_7FF0:: ; 6662
push af
push bc
push de
push hl
ld a, $03 ; Cartridge doesn't have RAM, and it's not even the correct
ld [$00FF], a ; way to enable it. Bug
ei ; Is this smart
ldh a, [hPauseUnpauseMusic]
cp a, $01 ; 1 means pause music
jr z, .pauseMusic
cp a, $02 ; 2 means unpause music
jr z, .unpauseMusic
ldh a, [hPauseTuneTimer]
and a
jr nz, .soundPaused
ld c, $D3
ld a, [$FF00+c] ; ?? To override other SFXs?
and a
jr z, .jmp_6688
xor a
ld [$FF00+c], a
ld a, $08 ; 1UP sound
ld [$DFE0], a
.jmp_6688
call PlaySquareSFX
call PlayNoiseSFX ; play noise sfx
call PlayWaveSFX ; play wave sfx
call StartMusic
call PlayMusic
call PanStereo
.out
xor a
ld [$DFE0], a
ld [$DFE8], a
ld [$DFF0], a
ld [$DFF8], a
ldh [hPauseUnpauseMusic], a
ld a, $07
ld [$00FF], a ; Bug continued
pop hl
pop de
pop bc
pop af
reti ; Interrupts are already enabled, necessary? Maybe to alert
; peripherals to reset their interrupt flags
.pauseMusic
call _InitSound.muteChannels
xor a
ld [$DFE1], a
ld [$DFF1], a
ld [$DFF9], a
ld a, $30
ldh [hPauseTuneTimer], a
.playFirstNote
ld hl, .pauseFirstNoteData
.playNote
call SetupChannel.square2
jr .out
.playSecondNote
ld hl, .pauseSecondNoteData
jr .playNote
.unpauseMusic
xor a
ldh [hPauseTuneTimer], a
jr .jmp_6688
.soundPaused
ld hl, hPauseTuneTimer
dec [hl]
ld a, [hl]
cp a, $28 ; Continue pause tune if it's still running
jr z, .playSecondNote
cp a, $20
jr z, .playFirstNote
cp a, $18
jr z, .playSecondNote
cp a, $10
jr nz, .out
inc [hl] ; Keep the hPauseTuneTimer non-zero, keeps the music
jr .out ; paused
.pauseFirstNoteData
db $B2, $E3, $83, $C7 ; 1048.6 Hz ~ C6
.pauseSecondNoteData
db $B2, $E3, $C1, $C7 ; 2080.5 Hz ~ C7
PlayWaveSFX:: ; 66F6
ld a, [$DFF0] ; SFX channel, only has boss cry
cp a, $01
jr z, .startBossCry
ld a, [$DFF1]
cp a, $01
jr z, .continueBossCry
ret
.bossCryChannelData
db $80, $3A, $20, $B0, $C6 ; 198/256 seconds, full volume, ~195 Hz (~G3)
.startBossCry
ld [$DFF1], a
ld hl, $DF3F
set 7, [hl] ; stops the music from using the Wave channel?
xor a
ld [$DFF4], a
ldh [rNR30], a ; wave DAC power
ld hl, BossCryWavePattern
call SetupWavePattern
ldh a, [rDIV] ; supposedly random, but because the music code is
and a, $1F ; linked to the timer interrupt, rDIV might always be 1
ld b, a ; here? Bug?
ld a, $D0
add b
ld [$DFF5], a ; "random" number from D0 to FF (always ~D1?)
ld hl, .bossCryChannelData
jp SetupChannel.wave ; copy HL to wave registers
.continueBossCry
ldh a, [rDIV]
and a, $07
ld b, a ; "random" number from 0 to 7 (always ~2?)
ld hl, $DFF4
inc [hl]
ld a, [hl]
ld hl, $DFF5
cp a, $0E
jr nc, .lowerFreq
inc [hl]
inc [hl]
.writeFreq
ld a, [hl]
and a, $F8 ; put a "random" number in the low nibble
or b
ld c, LOW(rNR33) ; modulate frequency
ld [$FF00+c], a
ret
.lowerFreq
cp a, $1E
jr z, .stopBossCry
dec [hl]
dec [hl]
dec [hl]
jr .writeFreq
.stopBossCry
xor a
ld [$DFF1], a
ldh [rNR30], a
ld hl, $DF3F
res 7, [hl] ; release wave channel?
ld bc, $DF36
ld a, [bc]
ld l, a
inc c
ld a, [bc]
ld h, a
jp SetupWavePattern
; no sweep, 50% duty, 1/16 second, envelope?, 1024 Hz, trigger, counter mode
TimerTickChannelData:: ; 6769
db $00, $B0, $53, $80, $C7
StartTimerTickSFX:: ; 676E
ld a, $03
ld hl, TimerTickChannelData
jp Jmp_69C6
GiraChannelData:: ; 6776
db $3C, $80, $A0, $50, $84 ; 138.9 Hz, C#3
StartGiraSFX:: ; 677B
call Call_6791.jmp_679C
ret z
ld a, $0E
ld hl, GiraChannelData
jp Jmp_69C6
JumpChannelData:: ; 6787
db $00, $80, $D2, $0A, $86 ; 261.1 Hz C4
; Superball?
SuperballChannelData:: ; 678C
db $3D, $80, $A3, $09, $87 ; 530.7 Hz ~ C5 (24 cents off...)
; used to check if new SFX overrides the one currently playing
Call_6791:: ; 6791
ld a, [$DFE1]
jr .jmp_67A2 ; WTF is this bullshit
.jmp_6796
ld a, [$DFE1]
cp a, SFX_STOMP
ret z
.jmp_679C
ld a, [$DFE1]
cp a, SFX_COIN
ret z
.jmp_67A2
cp a, SFX_GROW
ret z
cp a, SFX_INJURY
ret z
cp a, SFX_1UP
ret z
cp a, SFX_FLOWER
ret z
ret
StartJumpSFX:: ; 67AF
call Call_6791.jmp_6796
ret z
ld a, $10
ld hl, JumpChannelData
call Jmp_69C6
ld hl, $DFE4
ld [hl], $0A
inc l
ld [hl], $86
ret
ContinueJumpSFX:: ; 67C4
call updateSoundProgress
and a
jp z, ContinueSquareSFX.stop
ld hl, $DFE4
ld e, [hl]
inc l
ld d, [hl]
push hl
ld hl, $000F ; some sort of sweep implementation
add hl, de
ld c, LOW(rNR13)
ld a, l
ld [$FF00+c], a
ld b, a
inc c
ld a, h
and a, $3F
ld [$FF00+c], a ; rNR14
pop hl
ldd [hl], a
ld [hl], b
ret
StartSuperballSFX:: ; 67E4
call Call_6791.jmp_6796
ret z
ld a, $03
ld hl, SuperballChannelData
jp Jmp_69C6
ContinueSquareSFX:
call updateSoundProgress
and a
ret nz
.stop
xor a
ld [$DFE1], a
ldh [rNR10], a
ld a, $08
ldh [rNR12], a
ld a, $80
ldh [rNR14], a
ld hl, $DF1F
res 7, [hl] ; unlock
ret
CoinChannelData1::
db $00, $80, $E2, $06, $87 ; 524.3 Hz ~ C5
CoinChannelData2::
db $00, $80, $E2, $83, $87 ; 1049 Hz ~ C6
StartCoinSFX:: ; 6813
call Call_6791
ret z
ld hl, CoinChannelData1
jp Jmp_69C6
ContinueCoinSFX:: ; 681D
ld hl, $DFE4
inc [hl]
ld a, [hl]
cp a, $04
jr z, .secondTone
cp a, $18
jp z, ContinueSquareSFX.stop
ret
.secondTone
ld hl, CoinChannelData2
call SetupChannel.square1
ret
StompChannelData1::
db $57, $96, $8C, $30, $C7 ; 630 Hz
StompChannelData2::
db $57, $96, $8C, $35, $C7 ; 645 Hz
StartStompSFX:: ; 683D
call Call_6791.jmp_679C
ret z
ld a, $08
ld hl, StompChannelData1
jp Jmp_69C6
ContinueStompSFX:: ; 6849
call updateSoundProgress
and a
ret nz
ld hl, $DFE4
ld a, [hl]
inc [hl]
cp a, $00
jr z, .jmp_685D
cp a, $01
jp z, ContinueSquareSFX.stop
ret
.jmp_685D
ld hl, StompChannelData2
jp SetupChannel.square1
FlowerChannelData:: ; 6863
db $54, $00, $9A, $20, $87 ; 585.1 Hz ~ D5 (though 721 is closer)
StartFlowerSFX:: ; 6868
ld a, $60
ld [$DFE6], a
ld a, $05
ld hl, FlowerChannelData
jp Jmp_69C6
GrowChannelData:
db $27, $80, $8A, $10, $86 ; 264.3 Hz ~ C4 (17 cents off though)
StartGrowSFX:: ; 687A
ld a, $10
ld [$DFE6], a
ld a, $05
ld hl, GrowChannelData
jp Jmp_69C6
ContinueSweepSquareSFX::
call updateSoundProgress
and a
ret nz
ld hl, $DFE6
ld a, $10 ; sweep frequency up
add [hl]
ld [hl], a
cp a, $E0
jp z, ContinueSquareSFX.stop
ld c, LOW(rNR13)
ld [$FF00+c], a
inc c
ld a, $86
ld [$FF00+c], a ; rNR14
ret
BumpChannelData:: ;
db $2C, $80, $D3, $40, $84 ; 136.5 Hz
StartBumpSFX:: ; 68A5
call Call_6791.jmp_679C
ret z
ld a, $08
ld hl, BumpChannelData
jp Jmp_69C6
InjuryChannelData::
db $3A, $80, $E3, $20, $86 ; 273.1 Hz (one octave above the bump thing?)
InjuryEnvelopeData:
db $F3, $B3, $A3, $93, $83, $73, $63, $53, $43, $33, $23, $23, $13, $00
StartInjurySFX::
ld a, [$DFE1]
cp a, SFX_1UP
ret z
ld a, $06
ld hl, InjuryChannelData
jp Jmp_69C6
ContinueInjurySFX::
call updateSoundProgress
and a
ret nz
ld hl, $DFE4
ld c, [hl]
inc [hl]
ld b, $00
ld hl, InjuryEnvelopeData
add hl, bc
ld a, [hl]
and a
jp z, ContinueSquareSFX.stop
ld c, LOW(rNR12)
ld [$FF00+c], a