diff options
-rw-r--r-- | Makefile | 9 | ||||
-rw-r--r-- | audio.asm | 669 | ||||
-rw-r--r-- | audio/duty_1.asm | 33 | ||||
-rw-r--r-- | audio/duty_2.asm | 32 | ||||
-rw-r--r-- | audio/duty_3.asm | 33 | ||||
-rw-r--r-- | audio/engine_1.asm | 1682 | ||||
-rw-r--r-- | audio/engine_2.asm | 1733 | ||||
-rw-r--r-- | audio/engine_3.asm | 1682 | ||||
-rw-r--r-- | audio_blue.asm | 2 | ||||
-rw-r--r-- | audio_red.asm | 2 | ||||
-rw-r--r-- | blue.asm | 2 | ||||
-rw-r--r-- | constants.asm | 1 | ||||
-rw-r--r-- | constants/music_constants.asm | 54 | ||||
m--------- | extras | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | main.asm | 7165 | ||||
-rw-r--r-- | menu/pc.asm | 588 | ||||
-rw-r--r-- | music/blue/sfx_1f_5d.asm | 20 | ||||
-rw-r--r-- | music/sfx/sfx_1f_5d.asm | 19 | ||||
-rw-r--r-- | pokeblue.asm | 3 | ||||
-rw-r--r-- | pokered.asm | 3 | ||||
-rw-r--r-- | red.asm | 2 |
21 files changed, 6816 insertions, 6918 deletions
@@ -6,8 +6,13 @@ PYTHON := python TEXTQUEUE := -RED_OBJS := pokered.o -BLUE_OBJS := pokeblue.o +RED_OBJS := \ +pokered.o \ +audio_red.o + +BLUE_OBJS := \ +pokeblue.o \ +audio_blue.o OBJS := $(RED_OBJS) $(BLUE_OBJS) diff --git a/audio.asm b/audio.asm new file mode 100644 index 00000000..a77f6f0c --- /dev/null +++ b/audio.asm @@ -0,0 +1,669 @@ +INCLUDE "globals.asm" + +AUDIO_1 EQU $2 +AUDIO_2 EQU $8 +AUDIO_3 EQU $1f + +INCLUDE "macros.asm" +INCLUDE "constants/music_constants.asm" +INCLUDE "constants/trainer_constants.asm" + +; PC +INCLUDE "hram.asm" +INCLUDE "constants/move_constants.asm" + + + +SECTION "Sound Effect Headers 1", ROMX, BANK[AUDIO_1] +INCLUDE "music/headers/sfxheaders02.asm" + +SECTION "Sound Effect Headers 2", ROMX, BANK[AUDIO_2] +INCLUDE "music/headers/sfxheaders08.asm" + +SECTION "Sound Effect Headers 3", ROMX, BANK[AUDIO_3] +INCLUDE "music/headers/sfxheaders1f.asm" + + + +SECTION "Music Headers 1", ROMX, BANK[AUDIO_1] +INCLUDE "music/headers/musicheaders02.asm" + +SECTION "Music Headers 2", ROMX, BANK[AUDIO_2] +INCLUDE "music/headers/musicheaders08.asm" + +SECTION "Music Headers 3", ROMX, BANK[AUDIO_3] +INCLUDE "music/headers/musicheaders1f.asm" + + + +SECTION "Sound Effects 1", ROMX, BANK[AUDIO_1] + +INCLUDE "music/sfx/sfx_02_01.asm" +INCLUDE "music/sfx/sfx_02_02.asm" +INCLUDE "music/sfx/sfx_02_03.asm" +INCLUDE "music/sfx/sfx_02_04.asm" +INCLUDE "music/sfx/sfx_02_05.asm" +INCLUDE "music/sfx/sfx_02_06.asm" +INCLUDE "music/sfx/sfx_02_07.asm" +INCLUDE "music/sfx/sfx_02_08.asm" +INCLUDE "music/sfx/sfx_02_09.asm" +INCLUDE "music/sfx/sfx_02_0a.asm" +INCLUDE "music/sfx/sfx_02_0b.asm" +INCLUDE "music/sfx/sfx_02_0c.asm" +INCLUDE "music/sfx/sfx_02_0d.asm" +INCLUDE "music/sfx/sfx_02_0e.asm" +INCLUDE "music/sfx/sfx_02_0f.asm" +INCLUDE "music/sfx/sfx_02_10.asm" +INCLUDE "music/sfx/sfx_02_11.asm" +INCLUDE "music/sfx/sfx_02_12.asm" +INCLUDE "music/sfx/sfx_02_13.asm" + +INCLUDE "audio/duty_1.asm" + +INCLUDE "music/sfx/sfx_02_3f.asm" +INCLUDE "music/sfx/sfx_02_5e.asm" +INCLUDE "music/sfx/sfx_02_56.asm" +INCLUDE "music/sfx/sfx_02_57.asm" +INCLUDE "music/sfx/sfx_02_58.asm" +INCLUDE "music/sfx/sfx_02_3c.asm" +INCLUDE "music/sfx/sfx_02_59.asm" +INCLUDE "music/sfx/sfx_02_5a.asm" +INCLUDE "music/sfx/sfx_02_5b.asm" +INCLUDE "music/sfx/sfx_02_5c.asm" +INCLUDE "music/sfx/sfx_02_40.asm" +INCLUDE "music/sfx/sfx_02_5d.asm" +INCLUDE "music/sfx/sfx_02_3d.asm" +INCLUDE "music/sfx/sfx_02_43.asm" +INCLUDE "music/sfx/sfx_02_3e.asm" +INCLUDE "music/sfx/sfx_02_44.asm" +INCLUDE "music/sfx/sfx_02_45.asm" +INCLUDE "music/sfx/sfx_02_46.asm" +INCLUDE "music/sfx/sfx_02_47.asm" +INCLUDE "music/sfx/sfx_02_48.asm" +INCLUDE "music/sfx/sfx_02_49.asm" +INCLUDE "music/sfx/sfx_02_4a.asm" +INCLUDE "music/sfx/sfx_02_4b.asm" +INCLUDE "music/sfx/sfx_02_4c.asm" +INCLUDE "music/sfx/sfx_02_4d.asm" +INCLUDE "music/sfx/sfx_02_4e.asm" +INCLUDE "music/sfx/sfx_02_4f.asm" +INCLUDE "music/sfx/sfx_02_50.asm" +INCLUDE "music/sfx/sfx_02_51.asm" +INCLUDE "music/sfx/sfx_02_52.asm" +INCLUDE "music/sfx/sfx_02_53.asm" +INCLUDE "music/sfx/sfx_02_54.asm" +INCLUDE "music/sfx/sfx_02_55.asm" +INCLUDE "music/sfx/sfx_02_5f.asm" +INCLUDE "music/sfx/sfx_02_unused.asm" +INCLUDE "music/sfx/sfx_02_1d.asm" +INCLUDE "music/sfx/sfx_02_37.asm" +INCLUDE "music/sfx/sfx_02_38.asm" +INCLUDE "music/sfx/sfx_02_25.asm" +INCLUDE "music/sfx/sfx_02_39.asm" +INCLUDE "music/sfx/sfx_02_17.asm" +INCLUDE "music/sfx/sfx_02_23.asm" +INCLUDE "music/sfx/sfx_02_24.asm" +INCLUDE "music/sfx/sfx_02_14.asm" +INCLUDE "music/sfx/sfx_02_22.asm" +INCLUDE "music/sfx/sfx_02_1a.asm" +INCLUDE "music/sfx/sfx_02_1b.asm" +INCLUDE "music/sfx/sfx_02_19.asm" +INCLUDE "music/sfx/sfx_02_1f.asm" +INCLUDE "music/sfx/sfx_02_20.asm" +INCLUDE "music/sfx/sfx_02_16.asm" +INCLUDE "music/sfx/sfx_02_21.asm" +INCLUDE "music/sfx/sfx_02_15.asm" +INCLUDE "music/sfx/sfx_02_1e.asm" +INCLUDE "music/sfx/sfx_02_1c.asm" +INCLUDE "music/sfx/sfx_02_18.asm" +INCLUDE "music/sfx/sfx_02_2d.asm" +INCLUDE "music/sfx/sfx_02_2a.asm" +INCLUDE "music/sfx/sfx_02_2f.asm" +INCLUDE "music/sfx/sfx_02_26.asm" +INCLUDE "music/sfx/sfx_02_27.asm" +INCLUDE "music/sfx/sfx_02_28.asm" +INCLUDE "music/sfx/sfx_02_32.asm" +INCLUDE "music/sfx/sfx_02_29.asm" +INCLUDE "music/sfx/sfx_02_2b.asm" +INCLUDE "music/sfx/sfx_02_30.asm" +INCLUDE "music/sfx/sfx_02_2e.asm" +INCLUDE "music/sfx/sfx_02_31.asm" +INCLUDE "music/sfx/sfx_02_2c.asm" +INCLUDE "music/sfx/sfx_02_33.asm" +INCLUDE "music/sfx/sfx_02_34.asm" +INCLUDE "music/sfx/sfx_02_35.asm" +INCLUDE "music/sfx/sfx_02_36.asm" + + +SECTION "Sound Effects 2", ROMX, BANK[AUDIO_2] + +INCLUDE "music/sfx/sfx_08_01.asm" +INCLUDE "music/sfx/sfx_08_02.asm" +INCLUDE "music/sfx/sfx_08_03.asm" +INCLUDE "music/sfx/sfx_08_04.asm" +INCLUDE "music/sfx/sfx_08_05.asm" +INCLUDE "music/sfx/sfx_08_06.asm" +INCLUDE "music/sfx/sfx_08_07.asm" +INCLUDE "music/sfx/sfx_08_08.asm" +INCLUDE "music/sfx/sfx_08_09.asm" +INCLUDE "music/sfx/sfx_08_0a.asm" +INCLUDE "music/sfx/sfx_08_0b.asm" +INCLUDE "music/sfx/sfx_08_0c.asm" +INCLUDE "music/sfx/sfx_08_0d.asm" +INCLUDE "music/sfx/sfx_08_0e.asm" +INCLUDE "music/sfx/sfx_08_0f.asm" +INCLUDE "music/sfx/sfx_08_10.asm" +INCLUDE "music/sfx/sfx_08_11.asm" +INCLUDE "music/sfx/sfx_08_12.asm" +INCLUDE "music/sfx/sfx_08_13.asm" + +INCLUDE "audio/duty_2.asm" + +INCLUDE "music/sfx/sfx_08_40.asm" +INCLUDE "music/sfx/sfx_08_3f.asm" +INCLUDE "music/sfx/sfx_08_3c.asm" +INCLUDE "music/sfx/sfx_08_3d.asm" +INCLUDE "music/sfx/sfx_08_3e.asm" +INCLUDE "music/sfx/sfx_08_77.asm" +INCLUDE "music/sfx/sfx_08_41.asm" +INCLUDE "music/sfx/sfx_08_42.asm" +INCLUDE "music/sfx/sfx_08_43.asm" +INCLUDE "music/sfx/sfx_08_44.asm" +INCLUDE "music/sfx/sfx_08_45.asm" +INCLUDE "music/sfx/sfx_08_pokeflute_ch3.asm" +INCLUDE "music/sfx/sfx_08_47.asm" +INCLUDE "music/sfx/sfx_08_48.asm" +INCLUDE "music/sfx/sfx_08_49.asm" +INCLUDE "music/sfx/sfx_08_4a.asm" +INCLUDE "music/sfx/sfx_08_4b.asm" +INCLUDE "music/sfx/sfx_08_4c.asm" +INCLUDE "music/sfx/sfx_08_4d.asm" +INCLUDE "music/sfx/sfx_08_4e.asm" +INCLUDE "music/sfx/sfx_08_4f.asm" +INCLUDE "music/sfx/sfx_08_50.asm" +INCLUDE "music/sfx/sfx_08_51.asm" +INCLUDE "music/sfx/sfx_08_52.asm" +INCLUDE "music/sfx/sfx_08_53.asm" +INCLUDE "music/sfx/sfx_08_54.asm" +INCLUDE "music/sfx/sfx_08_55.asm" +INCLUDE "music/sfx/sfx_08_56.asm" +INCLUDE "music/sfx/sfx_08_57.asm" +INCLUDE "music/sfx/sfx_08_58.asm" +INCLUDE "music/sfx/sfx_08_59.asm" +INCLUDE "music/sfx/sfx_08_5a.asm" +INCLUDE "music/sfx/sfx_08_5b.asm" +INCLUDE "music/sfx/sfx_08_5c.asm" +INCLUDE "music/sfx/sfx_08_5d.asm" +INCLUDE "music/sfx/sfx_08_5e.asm" +INCLUDE "music/sfx/sfx_08_5f.asm" +INCLUDE "music/sfx/sfx_08_60.asm" +INCLUDE "music/sfx/sfx_08_61.asm" +INCLUDE "music/sfx/sfx_08_62.asm" +INCLUDE "music/sfx/sfx_08_63.asm" +INCLUDE "music/sfx/sfx_08_64.asm" +INCLUDE "music/sfx/sfx_08_65.asm" +INCLUDE "music/sfx/sfx_08_66.asm" +INCLUDE "music/sfx/sfx_08_67.asm" +INCLUDE "music/sfx/sfx_08_68.asm" +INCLUDE "music/sfx/sfx_08_69.asm" +INCLUDE "music/sfx/sfx_08_6a.asm" +INCLUDE "music/sfx/sfx_08_6b.asm" +INCLUDE "music/sfx/sfx_08_6c.asm" +INCLUDE "music/sfx/sfx_08_6d.asm" +INCLUDE "music/sfx/sfx_08_6e.asm" +INCLUDE "music/sfx/sfx_08_6f.asm" +INCLUDE "music/sfx/sfx_08_70.asm" +INCLUDE "music/sfx/sfx_08_71.asm" +INCLUDE "music/sfx/sfx_08_72.asm" +INCLUDE "music/sfx/sfx_08_73.asm" +INCLUDE "music/sfx/sfx_08_74.asm" +INCLUDE "music/sfx/sfx_08_75.asm" +INCLUDE "music/sfx/sfx_08_76.asm" +INCLUDE "music/sfx/sfx_08_unused.asm" +INCLUDE "music/sfx/sfx_08_1d.asm" +INCLUDE "music/sfx/sfx_08_37.asm" +INCLUDE "music/sfx/sfx_08_38.asm" +INCLUDE "music/sfx/sfx_08_25.asm" +INCLUDE "music/sfx/sfx_08_39.asm" +INCLUDE "music/sfx/sfx_08_17.asm" +INCLUDE "music/sfx/sfx_08_23.asm" +INCLUDE "music/sfx/sfx_08_24.asm" +INCLUDE "music/sfx/sfx_08_14.asm" +INCLUDE "music/sfx/sfx_08_22.asm" +INCLUDE "music/sfx/sfx_08_1a.asm" +INCLUDE "music/sfx/sfx_08_1b.asm" +INCLUDE "music/sfx/sfx_08_19.asm" +INCLUDE "music/sfx/sfx_08_1f.asm" +INCLUDE "music/sfx/sfx_08_20.asm" +INCLUDE "music/sfx/sfx_08_16.asm" +INCLUDE "music/sfx/sfx_08_21.asm" +INCLUDE "music/sfx/sfx_08_15.asm" +INCLUDE "music/sfx/sfx_08_1e.asm" +INCLUDE "music/sfx/sfx_08_1c.asm" +INCLUDE "music/sfx/sfx_08_18.asm" +INCLUDE "music/sfx/sfx_08_2d.asm" +INCLUDE "music/sfx/sfx_08_2a.asm" +INCLUDE "music/sfx/sfx_08_2f.asm" +INCLUDE "music/sfx/sfx_08_26.asm" +INCLUDE "music/sfx/sfx_08_27.asm" +INCLUDE "music/sfx/sfx_08_28.asm" +INCLUDE "music/sfx/sfx_08_32.asm" +INCLUDE "music/sfx/sfx_08_29.asm" +INCLUDE "music/sfx/sfx_08_2b.asm" +INCLUDE "music/sfx/sfx_08_30.asm" +INCLUDE "music/sfx/sfx_08_2e.asm" +INCLUDE "music/sfx/sfx_08_31.asm" +INCLUDE "music/sfx/sfx_08_2c.asm" +INCLUDE "music/sfx/sfx_08_33.asm" +INCLUDE "music/sfx/sfx_08_34.asm" +INCLUDE "music/sfx/sfx_08_35.asm" +INCLUDE "music/sfx/sfx_08_36.asm" + + +SECTION "Sound Effects 3", ROMX, BANK[AUDIO_3] + +INCLUDE "music/sfx/sfx_1f_01.asm" +INCLUDE "music/sfx/sfx_1f_02.asm" +INCLUDE "music/sfx/sfx_1f_03.asm" +INCLUDE "music/sfx/sfx_1f_04.asm" +INCLUDE "music/sfx/sfx_1f_05.asm" +INCLUDE "music/sfx/sfx_1f_06.asm" +INCLUDE "music/sfx/sfx_1f_07.asm" +INCLUDE "music/sfx/sfx_1f_08.asm" +INCLUDE "music/sfx/sfx_1f_09.asm" +INCLUDE "music/sfx/sfx_1f_0a.asm" +INCLUDE "music/sfx/sfx_1f_0b.asm" +INCLUDE "music/sfx/sfx_1f_0c.asm" +INCLUDE "music/sfx/sfx_1f_0d.asm" +INCLUDE "music/sfx/sfx_1f_0e.asm" +INCLUDE "music/sfx/sfx_1f_0f.asm" +INCLUDE "music/sfx/sfx_1f_10.asm" +INCLUDE "music/sfx/sfx_1f_11.asm" +INCLUDE "music/sfx/sfx_1f_12.asm" +INCLUDE "music/sfx/sfx_1f_13.asm" + +INCLUDE "audio/duty_3.asm" + +INCLUDE "music/sfx/sfx_1f_3f.asm" +INCLUDE "music/sfx/sfx_1f_56.asm" +INCLUDE "music/sfx/sfx_1f_57.asm" +INCLUDE "music/sfx/sfx_1f_58.asm" +INCLUDE "music/sfx/sfx_1f_3c.asm" +INCLUDE "music/sfx/sfx_1f_59.asm" +INCLUDE "music/sfx/sfx_1f_5a.asm" +INCLUDE "music/sfx/sfx_1f_5b.asm" +INCLUDE "music/sfx/sfx_1f_5c.asm" +INCLUDE "music/sfx/sfx_1f_40.asm" +INCLUDE "music/sfx/sfx_1f_5d.asm" +INCLUDE "music/sfx/sfx_1f_3d.asm" +INCLUDE "music/sfx/sfx_1f_43.asm" +INCLUDE "music/sfx/sfx_1f_3e.asm" +INCLUDE "music/sfx/sfx_1f_44.asm" +INCLUDE "music/sfx/sfx_1f_45.asm" +INCLUDE "music/sfx/sfx_1f_46.asm" +INCLUDE "music/sfx/sfx_1f_47.asm" +INCLUDE "music/sfx/sfx_1f_48.asm" +INCLUDE "music/sfx/sfx_1f_49.asm" +INCLUDE "music/sfx/sfx_1f_4a.asm" +INCLUDE "music/sfx/sfx_1f_4b.asm" +INCLUDE "music/sfx/sfx_1f_4c.asm" +INCLUDE "music/sfx/sfx_1f_4d.asm" +INCLUDE "music/sfx/sfx_1f_4e.asm" +INCLUDE "music/sfx/sfx_1f_4f.asm" +INCLUDE "music/sfx/sfx_1f_50.asm" +INCLUDE "music/sfx/sfx_1f_51.asm" +INCLUDE "music/sfx/sfx_1f_52.asm" +INCLUDE "music/sfx/sfx_1f_53.asm" +INCLUDE "music/sfx/sfx_1f_54.asm" +INCLUDE "music/sfx/sfx_1f_55.asm" +INCLUDE "music/sfx/sfx_1f_5e.asm" +INCLUDE "music/sfx/sfx_1f_5f.asm" +INCLUDE "music/sfx/sfx_1f_60.asm" +INCLUDE "music/sfx/sfx_1f_61.asm" +INCLUDE "music/sfx/sfx_1f_62.asm" +INCLUDE "music/sfx/sfx_1f_63.asm" +INCLUDE "music/sfx/sfx_1f_64.asm" +INCLUDE "music/sfx/sfx_1f_65.asm" +INCLUDE "music/sfx/sfx_1f_66.asm" +INCLUDE "music/sfx/sfx_1f_67.asm" +INCLUDE "music/sfx/sfx_1f_unused.asm" +INCLUDE "music/sfx/sfx_1f_1d.asm" +INCLUDE "music/sfx/sfx_1f_37.asm" +INCLUDE "music/sfx/sfx_1f_38.asm" +INCLUDE "music/sfx/sfx_1f_25.asm" +INCLUDE "music/sfx/sfx_1f_39.asm" +INCLUDE "music/sfx/sfx_1f_17.asm" +INCLUDE "music/sfx/sfx_1f_23.asm" +INCLUDE "music/sfx/sfx_1f_24.asm" +INCLUDE "music/sfx/sfx_1f_14.asm" +INCLUDE "music/sfx/sfx_1f_22.asm" +INCLUDE "music/sfx/sfx_1f_1a.asm" +INCLUDE "music/sfx/sfx_1f_1b.asm" +INCLUDE "music/sfx/sfx_1f_19.asm" +INCLUDE "music/sfx/sfx_1f_1f.asm" +INCLUDE "music/sfx/sfx_1f_20.asm" +INCLUDE "music/sfx/sfx_1f_16.asm" +INCLUDE "music/sfx/sfx_1f_21.asm" +INCLUDE "music/sfx/sfx_1f_15.asm" +INCLUDE "music/sfx/sfx_1f_1e.asm" +INCLUDE "music/sfx/sfx_1f_1c.asm" +INCLUDE "music/sfx/sfx_1f_18.asm" +INCLUDE "music/sfx/sfx_1f_2d.asm" +INCLUDE "music/sfx/sfx_1f_2a.asm" +INCLUDE "music/sfx/sfx_1f_2f.asm" +INCLUDE "music/sfx/sfx_1f_26.asm" +INCLUDE "music/sfx/sfx_1f_27.asm" +INCLUDE "music/sfx/sfx_1f_28.asm" +INCLUDE "music/sfx/sfx_1f_32.asm" +INCLUDE "music/sfx/sfx_1f_29.asm" +INCLUDE "music/sfx/sfx_1f_2b.asm" +INCLUDE "music/sfx/sfx_1f_30.asm" +INCLUDE "music/sfx/sfx_1f_2e.asm" +INCLUDE "music/sfx/sfx_1f_31.asm" +INCLUDE "music/sfx/sfx_1f_2c.asm" +INCLUDE "music/sfx/sfx_1f_33.asm" +INCLUDE "music/sfx/sfx_1f_34.asm" +INCLUDE "music/sfx/sfx_1f_35.asm" +INCLUDE "music/sfx/sfx_1f_36.asm" + + + +SECTION "Audio Engine 1", ROMX, BANK[AUDIO_1] + +PlayBattleMusic:: ; 0x90c6 + xor a + ld [wMusicHeaderPointer], a + ld [$d083], a + dec a + ld [$c0ee], a + call PlaySound ; stop music + call DelayFrame + ld c, BANK(Music_GymLeaderBattle) + ld a, [W_GYMLEADERNO] + and a + jr z, .notGymLeaderBattle + ld a, MUSIC_GYM_LEADER_BATTLE + jr .playSong +.notGymLeaderBattle + ld a, [W_CUROPPONENT] + cp $c8 + jr c, .wildBattle + cp SONY3 + $c8 + jr z, .finalBattle + cp LANCE + $c8 + jr nz, .normalTrainerBattle + ld a, MUSIC_GYM_LEADER_BATTLE ; lance also plays gym leader theme + jr .playSong +.normalTrainerBattle + ld a, MUSIC_TRAINER_BATTLE + jr .playSong +.finalBattle + ld a, MUSIC_FINAL_BATTLE + jr .playSong +.wildBattle + ld a, MUSIC_WILD_BATTLE +.playSong + jp PlayMusic + + +INCLUDE "audio/engine_1.asm" + + +; an alternate start for MeetRival which has a different first measure +Music_RivalAlternateStart:: ; 0x9b47 + ld c, BANK(Music_MeetRival) + ld a, MUSIC_MEET_RIVAL + call PlayMusic + ld hl, $c006 + ld de, Music_MeetRival_branch_b1a2 + call Music2_OverwriteChannelPointer + ld de, Music_MeetRival_branch_b21d + call Music2_OverwriteChannelPointer + ld de, Music_MeetRival_branch_b2b5 + +Music2_OverwriteChannelPointer: ; 0x9b60 + ld a, e + ld [hli], a + ld a, d + ld [hli], a + ret + +; an alternate tempo for MeetRival which is slightly slower +Music_RivalAlternateTempo:: ; 0x9b65 + ld c, BANK(Music_MeetRival) + ld a, MUSIC_MEET_RIVAL + call PlayMusic + ld hl, $c006 + ld de, Music_MeetRival_branch_b119 + jp Music2_OverwriteChannelPointer + +; applies both the alternate start and alternate tempo +Music_RivalAlternateStartAndTempo:: ; 0x9b75 + call Music_RivalAlternateStart + ld hl, $c006 + ld de, Music_MeetRival_branch_b19b + jp Music2_OverwriteChannelPointer + +; an alternate tempo for Cities1 which is used for the Hall of Fame room +Music_Cities1AlternateTempo:: ; 0x9b81 + ld a, $a + ld [$cfc8], a + ld [$cfc9], a + ld a, $ff + ld [wMusicHeaderPointer], a + ld c, $64 + call DelayFrames + ld c, BANK(Music_Cities1) + ld a, MUSIC_CITIES1 + call PlayMusic + ld hl, $c006 + ld de, Music_Cities1_branch_aa6f + jp Music2_OverwriteChannelPointer + + +SECTION "Audio Engine 2", ROMX, BANK[AUDIO_2] + +Func_2136e: ; 2136e (8:536e) + ld a, [$d083] + cp $ff + jr z, .asm_2139b + bit 7, a + ret z + and $7f + jr nz, .asm_21383 + call Func_213a7 + ld a, $1e + jr .asm_21395 +.asm_21383 + cp $14 + jr nz, .asm_2138a + call Func_213ac +.asm_2138a + ld a, $86 + ld [$c02a], a + ld a, [$d083] + and $7f + dec a +.asm_21395 + set 7, a + ld [$d083], a + ret +.asm_2139b + xor a + ld [$d083], a + ld [$c02a], a + ld de, Unknown_213c4 ; $53c4 + jr asm_213af + +Func_213a7: ; 213a7 (8:53a7) + ld de, Unknown_213bc ; $53bc + jr asm_213af + +Func_213ac: ; 213ac (8:53ac) + ld de, Unknown_213c0 ; $53c0 +asm_213af: ; 213af (8:53af) + ld hl, $ff10 + ld c, $5 + xor a +.asm_213b5 + ld [hli], a + ld a, [de] + inc de + dec c + jr nz, .asm_213b5 + ret + +Unknown_213bc: ; 213bc (8:53bc) + db $A0,$E2,$50,$87 + +Unknown_213c0: ; 213c0 (8:53c0) + db $B0,$E2,$EE,$86 + +Unknown_213c4: ; 213c4 (8:53c4) + db $00,$00,$00,$80 + + +INCLUDE "menu/pc.asm" + +INCLUDE "audio/engine_2.asm" + + +Music_PokeFluteInBattle: ; 22306 (8:6306) + ld a, (SFX_08_46 - $4000) / 3 ; PokeFlute outside of battle + call PlaySoundWaitForCurrent + ld hl, $c00e + ld de, SFX_08_PokeFlute_Ch1 + call Music8_OverwriteChannelPointer + ld de, SFX_08_PokeFlute_Ch2 + call Music8_OverwriteChannelPointer + ld de, SFX_08_PokeFlute_Ch3 + +Music8_OverwriteChannelPointer: ; 2231d (8:631d) + ld a, e + ld [hli], a + ld a, d + ld [hli], a + ret + + +SECTION "Audio Engine 3", ROMX, BANK[AUDIO_3] + +Func_7d13b:: ; 7d13b (1f:513b) + ld a, [$FF00+$dc] + ld c, $0 + ld hl, OwnedMonValues +.getSfxPointer + cp [hl] + jr c, .gotSfxPointer + inc c + inc hl + jr .getSfxPointer +.gotSfxPointer + push bc + ld a, $ff + ld [$c0ee], a + call PlaySoundWaitForCurrent + pop bc + ld b, $0 + ld hl, PokedexRatingSfxPointers + add hl, bc + add hl, bc + ld a, [hli] + ld c, [hl] + call PlayMusic + jp Func_2307 + +PokedexRatingSfxPointers: ; 7d162 (1f:5162) + db (SFX_1f_51 - $4000) / 3 + db BANK(SFX_1f_51) + db (SFX_02_41 - $4000) / 3 + db BANK(SFX_02_41) + db (SFX_02_3a - $4000) / 3 + db BANK(SFX_02_3a) + db (SFX_08_46 - $4000) / 3 + db BANK(SFX_08_46) + db (SFX_08_3a - $4000) / 3 + db BANK(SFX_08_3a) + db (SFX_02_42 - $4000) / 3 + db BANK(SFX_02_42) + db (SFX_02_3b - $4000) / 3 + db BANK(SFX_02_3b) + +OwnedMonValues: ; 7d170 (1f:5170) + db 10, 40, 60, 90, 120, 150, $ff + + +INCLUDE "audio/engine_3.asm" + + + +SECTION "Music 1", ROMX, BANK[AUDIO_1] + +INCLUDE "music/pkmnhealed.asm" +INCLUDE "music/routes1.asm" +INCLUDE "music/routes2.asm" +INCLUDE "music/routes3.asm" +INCLUDE "music/routes4.asm" +INCLUDE "music/indigoplateau.asm" +INCLUDE "music/pallettown.asm" +INCLUDE "music/unusedsong.asm" +INCLUDE "music/cities1.asm" +INCLUDE "music/sfx/sfx_02_3a.asm" +INCLUDE "music/museumguy.asm" +INCLUDE "music/meetprofoak.asm" +INCLUDE "music/meetrival.asm" +INCLUDE "music/sfx/sfx_02_41.asm" +INCLUDE "music/sfx/sfx_02_3b.asm" +INCLUDE "music/sfx/sfx_02_42.asm" +INCLUDE "music/ssanne.asm" +INCLUDE "music/cities2.asm" +INCLUDE "music/celadon.asm" +INCLUDE "music/cinnabar.asm" +INCLUDE "music/vermilion.asm" +INCLUDE "music/lavender.asm" +INCLUDE "music/safarizone.asm" +INCLUDE "music/gym.asm" +INCLUDE "music/pokecenter.asm" + + +SECTION "Music 2", ROMX, BANK[AUDIO_2] + +INCLUDE "music/sfx/sfx_08_pokeflute.asm" +INCLUDE "music/sfx/sfx_08_unused2.asm" +INCLUDE "music/gymleaderbattle.asm" +INCLUDE "music/trainerbattle.asm" +INCLUDE "music/wildbattle.asm" +INCLUDE "music/finalbattle.asm" +INCLUDE "music/sfx/sfx_08_3a.asm" +INCLUDE "music/sfx/sfx_08_3b.asm" +INCLUDE "music/sfx/sfx_08_46.asm" +INCLUDE "music/defeatedtrainer.asm" +INCLUDE "music/defeatedwildmon.asm" +INCLUDE "music/defeatedgymleader.asm" + + +SECTION "Music 3", ROMX, BANK[AUDIO_3] + +INCLUDE "music/bikeriding.asm" +INCLUDE "music/dungeon1.asm" +INCLUDE "music/gamecorner.asm" +INCLUDE "music/titlescreen.asm" +INCLUDE "music/sfx/sfx_1f_3a.asm" +INCLUDE "music/dungeon2.asm" +INCLUDE "music/dungeon3.asm" +INCLUDE "music/cinnabarmansion.asm" +INCLUDE "music/sfx/sfx_1f_41.asm" +INCLUDE "music/sfx/sfx_1f_3b.asm" +INCLUDE "music/sfx/sfx_1f_42.asm" +INCLUDE "music/oakslab.asm" +INCLUDE "music/pokemontower.asm" +INCLUDE "music/silphco.asm" +INCLUDE "music/meeteviltrainer.asm" +INCLUDE "music/meetfemaletrainer.asm" +INCLUDE "music/meetmaletrainer.asm" +INCLUDE "music/introbattle.asm" +INCLUDE "music/surfing.asm" +INCLUDE "music/jigglypuffsong.asm" +INCLUDE "music/halloffame.asm" +INCLUDE "music/credits.asm" + diff --git a/audio/duty_1.asm b/audio/duty_1.asm new file mode 100644 index 00000000..2c650ac1 --- /dev/null +++ b/audio/duty_1.asm @@ -0,0 +1,33 @@ +Music2_Channel3DutyPointers: ; 0x8361 + dw Music2_Channel3Duty0 + dw Music2_Channel3Duty1 + dw Music2_Channel3Duty2 + dw Music2_Channel3Duty3 + dw Music2_Channel3Duty4 + dw Music2_Channel3Duty5 ; used in the Lavender Town theme + dw Music2_Channel3Duty5 ; unused + dw Music2_Channel3Duty5 ; unused + dw Music2_Channel3Duty5 ; unused + +; these are the definitions for the channel 3 instruments +; each instrument definition is made up of 32 points (nibbles) that form +; the graph of the wave +; the current instrument is copied to $FF30 +Music2_Channel3Duty0: ; 0x8373 + db $02,$46,$8A,$CE,$FF,$FE,$ED,$DC,$CB,$A9,$87,$65,$44,$33,$22,$11 + +Music2_Channel3Duty1: ; 0x8383 + db $02,$46,$8A,$CE,$EF,$FF,$FE,$EE,$DD,$CB,$A9,$87,$65,$43,$22,$11 + +Music2_Channel3Duty2: ; 0x8393 + db $13,$69,$BD,$EE,$EE,$FF,$FF,$ED,$DE,$FF,$FF,$EE,$EE,$DB,$96,$31 + +Music2_Channel3Duty3: ; 0x83a3 + db $02,$46,$8A,$CD,$EF,$FE,$DE,$FF,$EE,$DC,$BA,$98,$76,$54,$32,$10 + +Music2_Channel3Duty4: ; 0x83b3 + db $01,$23,$45,$67,$8A,$CD,$EE,$F7,$7F,$EE,$DC,$A8,$76,$54,$32,$10 + +; duty 5 reads from sfx data +Music2_Channel3Duty5: ; 0x83c3 + diff --git a/audio/duty_2.asm b/audio/duty_2.asm new file mode 100644 index 00000000..b4561091 --- /dev/null +++ b/audio/duty_2.asm @@ -0,0 +1,32 @@ +Music8_Channel3DutyPointers: ; 20361 (8:4361) + dw Music8_Channel3Duty0 + dw Music8_Channel3Duty1 + dw Music8_Channel3Duty2 + dw Music8_Channel3Duty3 + dw Music8_Channel3Duty4 + dw Music8_Channel3Duty5 ; unused + dw Music8_Channel3Duty5 ; unused + dw Music8_Channel3Duty5 ; unused + dw Music8_Channel3Duty5 ; unused + +; these are the definitions for the channel 3 instruments +; each instrument definition is made up of 32 points (nibbles) that form +; the graph of the wave +; the current instrument is copied to $FF30 +Music8_Channel3Duty0: ; 20373 (8:4373) + db $02,$46,$8A,$CE,$FF,$FE,$ED,$DC,$CB,$A9,$87,$65,$44,$33,$22,$11 + +Music8_Channel3Duty1: ; 20383 (8:4383) + db $02,$46,$8A,$CE,$EF,$FF,$FE,$EE,$DD,$CB,$A9,$87,$65,$43,$22,$11 + +Music8_Channel3Duty2: ; 20393 (8:4393) + db $13,$69,$BD,$EE,$EE,$FF,$FF,$ED,$DE,$FF,$FF,$EE,$EE,$DB,$96,$31 + +Music8_Channel3Duty3: ; 203a3 (8:43a3) + db $02,$46,$8A,$CD,$EF,$FE,$DE,$FF,$EE,$DC,$BA,$98,$76,$54,$32,$10 + +Music8_Channel3Duty4: ; 203b3 (8:43b3) + db $01,$23,$45,$67,$8A,$CD,$EE,$F7,$7F,$EE,$DC,$A8,$76,$54,$32,$10 + +Music8_Channel3Duty5: + diff --git a/audio/duty_3.asm b/audio/duty_3.asm new file mode 100644 index 00000000..b9702a7f --- /dev/null +++ b/audio/duty_3.asm @@ -0,0 +1,33 @@ +Music1f_Channel3DutyPointers: ; 7c361 (1f:4361) + dw Music1f_Channel3Duty0 + dw Music1f_Channel3Duty1 + dw Music1f_Channel3Duty2 + dw Music1f_Channel3Duty3 + dw Music1f_Channel3Duty4 + dw Music1f_Channel3Duty5 ; used in the Pokemon Tower theme + dw Music1f_Channel3Duty5 ; unused + dw Music1f_Channel3Duty5 ; unused + dw Music1f_Channel3Duty5 ; unused + +; these are the definitions for the channel 3 instruments +; each instrument definition is made up of 32 points (nibbles) that form +; the graph of the wave +; the current instrument is copied to $FF30 +Music1f_Channel3Duty0: ; 7c373 (1f:4373) + db $02,$46,$8A,$CE,$FF,$FE,$ED,$DC,$CB,$A9,$87,$65,$44,$33,$22,$11 + +Music1f_Channel3Duty1: ; 7c383 (1f:4383) + db $02,$46,$8A,$CE,$EF,$FF,$FE,$EE,$DD,$CB,$A9,$87,$65,$43,$22,$11 + +Music1f_Channel3Duty2: ; 7c393 (1f:4393) + db $13,$69,$BD,$EE,$EE,$FF,$FF,$ED,$DE,$FF,$FF,$EE,$EE,$DB,$96,$31 + +Music1f_Channel3Duty3: ; 7c3a3 (1f:43a3) + db $02,$46,$8A,$CD,$EF,$FE,$DE,$FF,$EE,$DC,$BA,$98,$76,$54,$32,$10 + +Music1f_Channel3Duty4: ; 7c3b3 (1f:43b3) + db $01,$23,$45,$67,$8A,$CD,$EE,$F7,$7F,$EE,$DC,$A8,$76,$54,$32,$10 + +; duty 5 reads from sfx data +Music1f_Channel3Duty5: ; 7c3c3 (1f:43c3) + diff --git a/audio/engine_1.asm b/audio/engine_1.asm new file mode 100644 index 00000000..0d60308a --- /dev/null +++ b/audio/engine_1.asm @@ -0,0 +1,1682 @@ +; The first of three duplicated sound engines. + +Func_9103: ; 0x9103 + ld c, CH0 +.loop + ld b, $0 + ld hl, $c026 + add hl, bc + ld a, [hl] + and a + jr z, .nextChannel + ld a, c + cp CH4 + jr nc, .asm_912e ; if sfx channel + ld a, [$c002] + and a + jr z, .asm_912e + bit 7, a + jr nz, .nextChannel + set 7, a + ld [$c002], a + xor a + ld [$ff00+$25], a + ld [$ff00+$1a], a + ld a, $80 + ld [$ff00+$1a], a + jr .nextChannel +.asm_912e + call Music2_ApplyMusicAffects +.nextChannel + ld a, c + inc c ; inc channel number + cp CH7 + jr nz, .loop + ret + +; this routine checks flags for music effects currently applied +; to the channel and calls certain functions based on flags. +; known flags for $c02e: +; 1: call has been used +; 3: a toggle used only by this routine for vibrato +; 4: pitchbend flag +; 6: dutycycle flag +Music2_ApplyMusicAffects: ; 0x9138 + ld b, $0 + ld hl, $c0b6 ; delay unitl next note + add hl, bc + ld a, [hl] + cp $1 ; if the delay is 1, play next note + jp z, Music2_PlayNextNote + dec a ; otherwise, decrease the delay timer + ld [hl], a + ld a, c + cp CH4 + jr nc, .startChecks ; if a sfx channel + ld hl, $c02a + add hl, bc + ld a, [hl] + and a + jr z, .startChecks + ret +.startChecks + ld hl, $c02e + add hl, bc + bit 6, [hl] ; dutycycle + jr z, .checkForExecuteMusic + call Music2_ApplyDutyCycle +.checkForExecuteMusic + ld b, $0 + ld hl, $c036 + add hl, bc + bit 0, [hl] + jr nz, .checkForPitchBend + ld hl, $c02e + add hl, bc + bit 2, [hl] + jr nz, .disablePitchBendVibrato +.checkForPitchBend + ld hl, $c02e + add hl, bc + bit 4, [hl] ; pitchbend + jr z, .checkVibratoDelay + jp Music2_ApplyPitchBend +.checkVibratoDelay + ld hl, $c04e ; vibrato delay + add hl, bc + ld a, [hl] + and a ; check if delay is over + jr z, .checkForVibrato + dec [hl] ; otherwise, dec delay +.disablePitchBendVibrato + ret +.checkForVibrato + ld hl, $c056 ; vibrato rate + add hl, bc + ld a, [hl] + and a + jr nz, .vibrato + ret ; no vibrato +.vibrato + ld d, a + ld hl, $c05e + add hl, bc + ld a, [hl] + and $f + and a + jr z, .vibratoAlreadyDone + dec [hl] ; apply vibrato pitch change + ret +.vibratoAlreadyDone + ld a, [hl] + swap [hl] + or [hl] + ld [hl], a ; reset the vibrato value and start again + ld hl, $c066 + add hl, bc + ld e, [hl] ; get note pitch + ld hl, $c02e + add hl, bc + bit 3, [hl] ; this is the only code that sets/resets bit three so + jr z, .unset ; it continuously alternates which path it takes + res 3, [hl] + ld a, d + and $f + ld d, a + ld a, e + sub d + jr nc, .noCarry + ld a, $0 +.noCarry + jr .done +.unset + set 3, [hl] + ld a, d + and $f0 + swap a + add e + jr nc, .done + ld a, $ff +.done + ld d, a + ld b, $3 + call Func_9838 + ld [hl], d + ret + +; this routine executes all music commands that take up no time, +; like tempo changes, duty changes etc. and doesn't return +; until the first note is reached +Music2_PlayNextNote ; 0x91d0 + ld hl, $c06e + add hl, bc + ld a, [hl] + ld hl, $c04e + add hl, bc + ld [hl], a + ld hl, $c02e + add hl, bc + res 4, [hl] + res 5, [hl] + call Music2_endchannel + ret + +Music2_endchannel: ; 0x91e6 + call Music2_GetNextMusicByte + ld d, a + cp $ff ; is this command an endchannel? + jp nz, Music2_callchannel ; no + ld b, $0 ; yes + ld hl, $c02e + add hl, bc + bit 1, [hl] + jr nz, .returnFromCall + ld a, c + cp CH3 + jr nc, .noiseOrSfxChannel + jr .asm_923f +.noiseOrSfxChannel + res 2, [hl] + ld hl, $c036 + add hl, bc + res 0, [hl] + cp CH6 + jr nz, .notSfxChannel3 + ld a, $0 + ld [$ff00+$1a], a + ld a, $80 + ld [$ff00+$1a], a +.notSfxChannel3 + jr nz, .asm_9222 + ld a, [$c003] + and a + jr z, .asm_9222 + xor a + ld [$c003], a + jr .asm_923f +.asm_9222 + jr .asm_9248 +.returnFromCall + res 1, [hl] + ld d, $0 + ld a, c + add a + ld e, a + ld hl, $c006 + add hl, de + push hl ; store current channel address + ld hl, $c016 + add hl, de + ld e, l + ld d, h + pop hl + ld a, [de] + ld [hli], a + inc de + ld a, [de] + ld [hl], a ; loads channel address to return to + jp Music2_endchannel +.asm_923f + ld hl, Unknown_9b1f + add hl, bc + ld a, [$ff00+$25] + and [hl] + ld [$ff00+$25], a +.asm_9248 + ld a, [$c02a] + cp $14 + jr nc, .asm_9251 + jr .asm_926e +.asm_9251 + ld a, [$c02a] + cp $86 + jr z, .asm_926e + jr c, .asm_925c + jr .asm_926e +.asm_925c + ld a, c + cp CH4 + jr z, .asm_9265 + call Func_96c7 + ret c +.asm_9265 + ld a, [$c005] + ld [$ff00+$24], a + xor a + ld [$c005], a +.asm_926e + ld hl, $c026 + add hl, bc + ld [hl], b + ret + +Music2_callchannel: ; 0x9274 + cp $fd ; is this command a callchannel? + jp nz, Music2_loopchannel ; no + call Music2_GetNextMusicByte ; yes + push af + call Music2_GetNextMusicByte + ld d, a + pop af + ld e, a + push de ; store pointer + ld d, $0 + ld a, c + add a + ld e, a + ld hl, $c006 + add hl, de + push hl + ld hl, $c016 + add hl, de + ld e, l + ld d, h + pop hl + ld a, [hli] + ld [de], a + inc de + ld a, [hld] + ld [de], a ; copy current channel address + pop de + ld [hl], e + inc hl + ld [hl], d ; overwrite current address with pointer + ld b, $0 + ld hl, $c02e + add hl, bc + set 1, [hl] ; set the call flag + jp Music2_endchannel + +Music2_loopchannel: ; 0x92a9 + cp $fe ; is this command a loopchannel? + jp nz, Music2_notetype ; no + call Music2_GetNextMusicByte ; yes + ld e, a + and a + jr z, .infiniteLoop + ld b, $0 + ld hl, $c0be + add hl, bc + ld a, [hl] + cp e + jr nz, .loopAgain + ld a, $1 ; if no more loops to make, + ld [hl], a + call Music2_GetNextMusicByte ; skip pointer + call Music2_GetNextMusicByte + jp Music2_endchannel +.loopAgain ; inc loop count + inc a + ld [hl], a + ; fall through +.infiniteLoop ; overwrite current address with pointer + call Music2_GetNextMusicByte + push af + call Music2_GetNextMusicByte + ld b, a + ld d, $0 + ld a, c + add a + ld e, a + ld hl, $c006 + add hl, de + pop af + ld [hli], a + ld [hl], b + jp Music2_endchannel + +Music2_notetype: ; 0x92e4 + and $f0 + cp $d0 ; is this command a notetype? + jp nz, Music2_togglecall ; no + ld a, d ; yes + and $f + ld b, $0 + ld hl, $c0c6 + add hl, bc + ld [hl], a ; store low nibble as speed + ld a, c + cp CH3 + jr z, .noiseChannel ; noise channel has 0 params + call Music2_GetNextMusicByte + ld d, a + ld a, c + cp CH2 + jr z, .musicChannel3 + cp CH6 + jr nz, .notChannel3 + ld hl, $c0e7 + jr .sfxChannel3 +.musicChannel3 + ld hl, $c0e6 +.sfxChannel3 + ld a, d + and $f + ld [hl], a ; store low nibble of param as duty + ld a, d + and $30 + sla a + ld d, a + ; fall through + + ; if channel 3, store high nibble as volume + ; else, store volume (high nibble) and fade (low nibble) +.notChannel3 + ld b, $0 + ld hl, $c0de + add hl, bc + ld [hl], d +.noiseChannel + jp Music2_endchannel + +Music2_togglecall: ; 0x9323 + ld a, d + cp $e8 ; is this command an togglecall? + jr nz, Music2_vibrato ; no + ld b, $0 ; yes + ld hl, $c02e + add hl, bc + ld a, [hl] + xor $1 + ld [hl], a ; flip bit 0 of $c02e (toggle returning from call) + jp Music2_endchannel + +Music2_vibrato: ; 0x9335 + cp $ea ; is this command a vibrato? + jr nz, Music2_pitchbend ; no + call Music2_GetNextMusicByte ; yes + ld b, $0 + ld hl, $c04e + add hl, bc + ld [hl], a ; store delay + ld hl, $c06e + add hl, bc + ld [hl], a ; store delay + call Music2_GetNextMusicByte + ld d, a + and $f0 + swap a + ld b, $0 + ld hl, $c056 + add hl, bc + srl a + ld e, a + adc b + swap a + or e + ld [hl], a ; store rate as both high and low nibbles + ld a, d + and $f + ld d, a + ld hl, $c05e + add hl, bc + swap a + or d + ld [hl], a ; store depth as both high and low nibbles + jp Music2_endchannel + +Music2_pitchbend: ; 0x936d + cp $eb ; is this command a pitchbend? + jr nz, Music2_duty ; no + call Music2_GetNextMusicByte ; yes + ld b, $0 + ld hl, $c076 + add hl, bc + ld [hl], a ; store first param + call Music2_GetNextMusicByte + ld d, a + and $f0 + swap a + ld b, a + ld a, d + and $f + call Func_9858 + ld b, $0 + ld hl, $c0a6 + add hl, bc + ld [hl], d ; store unknown part of second param + ld hl, $c0ae + add hl, bc + ld [hl], e ; store unknown part of second param + ld b, $0 + ld hl, $c02e + add hl, bc + set 4, [hl] ; set pitchbend flag + call Music2_GetNextMusicByte + ld d, a + jp Music2_notelength + +Music2_duty: ; 0x93a5 + cp $ec ; is this command a duty? + jr nz, Music2_tempo ; no + call Music2_GetNextMusicByte ; yes + rrca + rrca + and $c0 + ld b, $0 + ld hl, $c03e + add hl, bc + ld [hl], a ; store duty + jp Music2_endchannel + +Music2_tempo: ; 0x93ba + cp $ed ; is this command a tempo? + jr nz, Music2_unknownmusic0xee ; no + ld a, c ; yes + cp CH4 + jr nc, .sfxChannel + call Music2_GetNextMusicByte + ld [$c0e8], a ; store first param + call Music2_GetNextMusicByte + ld [$c0e9], a ; store second param + xor a + ld [$c0ce], a ; clear RAM + ld [$c0cf], a + ld [$c0d0], a + ld [$c0d1], a + jr .musicChannelDone +.sfxChannel + call Music2_GetNextMusicByte + ld [$c0ea], a ; store first param + call Music2_GetNextMusicByte + ld [$c0eb], a ; store second param + xor a + ld [$c0d2], a ; clear RAM + ld [$c0d3], a + ld [$c0d4], a + ld [$c0d5], a +.musicChannelDone + jp Music2_endchannel + +Music2_unknownmusic0xee: ; 0x93fa + cp $ee ; is this command an unknownmusic0xee? + jr nz, Music2_unknownmusic0xef ; no + call Music2_GetNextMusicByte ; yes + ld [$c004], a ; store first param + jp Music2_endchannel + +; this appears to never be used +Music2_unknownmusic0xef ; 0x9407 + cp $ef ; is this command an unknownmusic0xef? + jr nz, Music2_dutycycle ; no + call Music2_GetNextMusicByte ; yes + push bc + call Func_9876 + pop bc + ld a, [$c003] + and a + jr nz, .skip + ld a, [$c02d] + ld [$c003], a + xor a + ld [$c02d], a +.skip + jp Music2_endchannel + +Music2_dutycycle: ; 0x9426 + cp $fc ; is this command a dutycycle? + jr nz, Music2_stereopanning ; no + call Music2_GetNextMusicByte ; yes + ld b, $0 + ld hl, $c046 + add hl, bc + ld [hl], a ; store full cycle + and $c0 + ld hl, $c03e + add hl, bc + ld [hl], a ; store first duty + ld hl, $c02e + add hl, bc + set 6, [hl] ; set dutycycle flag + jp Music2_endchannel + +Music2_stereopanning: ; 0x9444 + cp $f0 ; is this command a stereopanning? + jr nz, Music2_executemusic ; no + call Music2_GetNextMusicByte ; yes + ld [$ff00+$24], a ; store stereopanning + jp Music2_endchannel + +Music2_executemusic: ; 0x9450 + cp $f8 ; is this command an executemusic? + jr nz, Music2_octave ; no + ld b, $0 ; yes + ld hl, $c036 + add hl, bc + set 0, [hl] + jp Music2_endchannel + +Music2_octave: ; 0x945f + and $f0 + cp $e0 ; is this command an octave? + jr nz, Music2_unknownsfx0x20 ; no + ld hl, $c0d6 ; yes + ld b, $0 + add hl, bc + ld a, d + and $f + ld [hl], a ; store low nibble as octave + jp Music2_endchannel + +Music2_unknownsfx0x20: ; 0x9472 + cp $20 ; is this command an unknownsfx0x20? + jr nz, Music2_unknownsfx0x10 ; no + ld a, c + cp CH3 ; is this a noise or sfx channel? + jr c, Music2_unknownsfx0x10 ; no + ld b, $0 + ld hl, $c036 + add hl, bc + bit 0, [hl] + jr nz, Music2_unknownsfx0x10 ; no + call Music2_notelength ; yes + ld d, a + ld b, $0 + ld hl, $c03e + add hl, bc + ld a, [hl] + or d + ld d, a + ld b, $1 + call Func_9838 + ld [hl], d + call Music2_GetNextMusicByte + ld d, a + ld b, $2 + call Func_9838 + ld [hl], d + call Music2_GetNextMusicByte + ld e, a + ld a, c + cp CH7 + ld a, $0 + jr z, .sfxNoiseChannel ; only two params for noise channel + push de + call Music2_GetNextMusicByte + pop de +.sfxNoiseChannel + ld d, a + push de + call Func_9629 + call Func_95f8 + pop de + call Func_964b + ret + +Music2_unknownsfx0x10: + ld a, c + cp CH4 + jr c, Music2_note ; if not a sfx + ld a, d + cp $10 ; is this command a unknownsfx0x10? + jr nz, Music2_note ; no + ld b, $0 + ld hl, $c036 + add hl, bc + bit 0, [hl] + jr nz, Music2_note ; no + call Music2_GetNextMusicByte ; yes + ld [$ff00+$10], a + jp Music2_endchannel + +Music2_note: + ld a, c + cp CH3 + jr nz, Music2_notelength ; if not noise channel + ld a, d + and $f0 + cp $b0 ; is this command a dnote? + jr z, Music2_dnote ; yes + jr nc, Music2_notelength ; no + swap a + ld b, a + ld a, d + and $f + ld d, a + ld a, b + push de + push bc + jr asm_94fd + +Music2_dnote: + ld a, d + and $f + push af + push bc + call Music2_GetNextMusicByte ; get dnote instrument +asm_94fd + ld d, a + ld a, [$c003] + and a + jr nz, .asm_9508 + ld a, d + call Func_9876 +.asm_9508 + pop bc + pop de + +Music2_notelength: ; 0x950a + ld a, d + push af + and $f + inc a + ld b, $0 + ld e, a ; store note length (in 16ths) + ld d, b + ld hl, $c0c6 + add hl, bc + ld a, [hl] + ld l, b + call Func_9847 + ld a, c + cp CH4 + jr nc, .sfxChannel + ld a, [$c0e8] + ld d, a + ld a, [$c0e9] + ld e, a + jr .skip +.sfxChannel + ld d, $1 + ld e, $0 + cp CH7 + jr z, .skip ; if noise channel + call Func_9693 + ld a, [$c0ea] + ld d, a + ld a, [$c0eb] + ld e, a +.skip + ld a, l + ld b, $0 + ld hl, $c0ce + add hl, bc + ld l, [hl] + call Func_9847 + ld e, l + ld d, h + ld hl, $c0ce + add hl, bc + ld [hl], e + ld a, d + ld hl, $c0b6 + add hl, bc + ld [hl], a + ld hl, $c036 + add hl, bc + bit 0, [hl] + jr nz, Music2_notepitch + ld hl, $c02e + add hl, bc + bit 2, [hl] + jr z, Music2_notepitch + pop hl + ret + +Music2_notepitch: ; 0x9568 + pop af + and $f0 + cp $c0 ; compare to rest + jr nz, .notRest + ld a, c + cp CH4 + jr nc, .sfxChannel + ld hl, $c02a + add hl, bc + ld a, [hl] + and a + jr nz, .done + ; fall through +.sfxChannel + ld a, c + cp CH2 + jr z, .musicChannel3 + cp CH6 + jr nz, .notSfxChannel3 +.musicChannel3 + ld b, $0 + ld hl, Unknown_9b1f + add hl, bc + ld a, [$ff00+$25] + and [hl] + ld [$ff00+$25], a + jr .done +.notSfxChannel3 + ld b, $2 + call Func_9838 + ld a, $8 + ld [hli], a + inc hl + ld a, $80 + ld [hl], a +.done + ret +.notRest + swap a + ld b, $0 + ld hl, $c0d6 + add hl, bc + ld b, [hl] + call Func_9858 + ld b, $0 + ld hl, $c02e + add hl, bc + bit 4, [hl] + jr z, .asm_95b8 + call Func_978f +.asm_95b8 + push de + ld a, c + cp CH4 + jr nc, .skip ; if sfx channel + ld hl, $c02a + ld d, $0 + ld e, a + add hl, de + ld a, [hl] + and a + jr nz, .asm_95cb + jr .skip +.asm_95cb + pop de + ret +.skip + ld b, $0 + ld hl, $c0de + add hl, bc + ld d, [hl] + ld b, $2 + call Func_9838 + ld [hl], d + call Func_9629 + call Func_95f8 + pop de + ld b, $0 + ld hl, $c02e + add hl, bc + bit 0, [hl] + jr z, .asm_95ef + inc e + jr nc, .asm_95ef + inc d +.asm_95ef + ld hl, $c066 + add hl, bc + ld [hl], e + call Func_964b + ret + +Func_95f8: ; 0x95f8 + ld b, $0 + ld hl, Unknown_9b27 + add hl, bc + ld a, [$ff00+$25] + or [hl] + ld d, a + ld a, c + cp CH7 + jr z, .sfxNoiseChannel + cp CH4 + jr nc, .skip ; if sfx channel + ld hl, $c02a + add hl, bc + ld a, [hl] + and a + jr nz, .skip +.sfxNoiseChannel + ld a, [$c004] + ld hl, Unknown_9b27 + add hl, bc + and [hl] + ld d, a + ld a, [$ff00+$25] + ld hl, Unknown_9b1f + add hl, bc + and [hl] + or d + ld d, a +.skip + ld a, d + ld [$ff00+$25], a + ret + +Func_9629: ; 0x9629 + ld b, $0 + ld hl, $c0b6 + add hl, bc + ld d, [hl] + ld a, c + cp CH2 + jr z, .channel3 ; if music channel 3 + cp CH6 + jr z, .channel3 ; if sfx channel 3 + ld a, d + and $3f + ld d, a + ld hl, $c03e + add hl, bc + ld a, [hl] + or d + ld d, a +.channel3 + ld b, $1 + call Func_9838 + ld [hl], d + ret + +Func_964b: ; 0x964b + ld a, c + cp CH2 + jr z, .channel3 + cp CH6 + jr nz, .notSfxChannel3 + ; fall through +.channel3 + push de + ld de, $c0e6 + cp CH2 + jr z, .musicChannel3 + ld de, $c0e7 +.musicChannel3 + ld a, [de] + add a + ld d, $0 + ld e, a + ld hl, Music2_Channel3DutyPointers + add hl, de + ld e, [hl] + inc hl + ld d, [hl] + ld hl, $ff30 + ld b, $f + ld a, $0 + ld [$ff00+$1a], a +.loop + ld a, [de] + inc de + ld [hli], a + ld a, b + dec b + and a + jr nz, .loop + ld a, $80 + ld [$ff00+$1a], a + pop de +.notSfxChannel3 + ld a, d + or $80 + and $c7 + ld d, a + ld b, $3 + call Func_9838 + ld [hl], e + inc hl + ld [hl], d + call Func_96b5 + ret + +Func_9693: ; 0x9693 + call Func_96e5 + jr nc, .asm_96ab + ld d, $0 + ld a, [$c0f2] + add $80 + jr nc, .asm_96a2 + inc d +.asm_96a2 + ld [$c0eb], a + ld a, d + ld [$c0ea], a + jr .asm_96b4 +.asm_96ab + xor a + ld [$c0eb], a + ld a, $1 + ld [$c0ea], a +.asm_96b4 + ret + +Func_96b5: ; 0x96b5 + call Func_96e5 + jr nc, .asm_96c6 + ld a, [$c0f1] + add e + jr nc, .asm_96c1 + inc d +.asm_96c1 + dec hl + ld e, a + ld [hl], e + inc hl + ld [hl], d +.asm_96c6 + ret + +Func_96c7: ; 0x96c7 + call Func_96e5 + jr nc, .asm_96e2 + ld hl, $c006 + ld e, c + ld d, $0 + sla e + rl d + add hl, de + ld a, [hl] + sub $1 + ld [hl], a + inc hl + ld a, [hl] + sbc $0 + ld [hl], a + scf + ret +.asm_96e2 + scf + ccf + ret + +Func_96e5: ; 0x96e5 + ld a, [$c02a] + cp $14 + jr nc, .asm_96ee + jr .asm_96f4 +.asm_96ee + cp $86 + jr z, .asm_96f4 + jr c, .asm_96f7 +.asm_96f4 + scf + ccf + ret +.asm_96f7 + scf + ret + +Music2_ApplyPitchBend: ; 0x96f9 + ld hl, $c02e + add hl, bc + bit 5, [hl] + jp nz, .asm_9740 + ld hl, $c09e + add hl, bc + ld e, [hl] + ld hl, $c096 + add hl, bc + ld d, [hl] + ld hl, $c07e + add hl, bc + ld l, [hl] + ld h, b + add hl, de + ld d, h + ld e, l + ld hl, $c08e + add hl, bc + push hl + ld hl, $c086 + add hl, bc + ld a, [hl] + pop hl + add [hl] + ld [hl], a + ld a, $0 + adc e + ld e, a + ld a, $0 + adc d + ld d, a + ld hl, $c0a6 + add hl, bc + ld a, [hl] + cp d + jp c, .asm_9786 + jr nz, .asm_9773 + ld hl, $c0ae + add hl, bc + ld a, [hl] + cp e + jp c, .asm_9786 + jr .asm_9773 +.asm_9740 + ld hl, $c09e + add hl, bc + ld a, [hl] + ld hl, $c096 + add hl, bc + ld d, [hl] + ld hl, $c07e + add hl, bc + ld e, [hl] + sub e + ld e, a + ld a, d + sbc b + ld d, a + ld hl, $c086 + add hl, bc + ld a, [hl] + add a + ld [hl], a + ld a, e + sbc b + ld e, a + ld a, d + sbc b + ld d, a + ld hl, $c0a6 + add hl, bc + ld a, d + cp [hl] + jr c, .asm_9786 + jr nz, .asm_9773 + ld hl, $c0ae + add hl, bc + ld a, e + cp [hl] + jr c, .asm_9786 +.asm_9773 + ld hl, $c09e + add hl, bc + ld [hl], e + ld hl, $c096 + add hl, bc + ld [hl], d + ld b, $3 + call Func_9838 + ld a, e + ld [hli], a + ld [hl], d + ret +.asm_9786 + ld hl, $c02e + add hl, bc + res 4, [hl] + res 5, [hl] + ret + +Func_978f: ; 0x978f + ld hl, $c096 + add hl, bc + ld [hl], d + ld hl, $c09e + add hl, bc + ld [hl], e + ld hl, $c0b6 + add hl, bc + ld a, [hl] + ld hl, $c076 + add hl, bc + sub [hl] + jr nc, .asm_97a7 + ld a, $1 +.asm_97a7 + ld [hl], a + ld hl, $c0ae + add hl, bc + ld a, e + sub [hl] + ld e, a + ld a, d + sbc b + ld hl, $c0a6 + add hl, bc + sub [hl] + jr c, .asm_97c3 + ld d, a + ld b, $0 + ld hl, $c02e + add hl, bc + set 5, [hl] + jr .asm_97e6 +.asm_97c3 + ld hl, $c096 + add hl, bc + ld d, [hl] + ld hl, $c09e + add hl, bc + ld e, [hl] + ld hl, $c0ae + add hl, bc + ld a, [hl] + sub e + ld e, a + ld a, d + sbc b + ld d, a + ld hl, $c0a6 + add hl, bc + ld a, [hl] + sub d + ld d, a + ld b, $0 + ld hl, $c02e + add hl, bc + res 5, [hl] +.asm_97e6 + ld hl, $c076 + add hl, bc +.asm_97ea + inc b + ld a, e + sub [hl] + ld e, a + jr nc, .asm_97ea + ld a, d + and a + jr z, .asm_97f8 + dec a + ld d, a + jr .asm_97ea +.asm_97f8 + ld a, e + add [hl] + ld d, b + ld b, $0 + ld hl, $c07e + add hl, bc + ld [hl], d + ld hl, $c086 + add hl, bc + ld [hl], a + ld hl, $c08e + add hl, bc + ld [hl], a + ret + +Music2_ApplyDutyCycle: ; 0x980d + ld b, $0 + ld hl, $c046 + add hl, bc + ld a, [hl] + rlca + rlca + ld [hl], a + and $c0 + ld d, a + ld b, $1 + call Func_9838 + ld a, [hl] + and $3f + or d + ld [hl], a + ret + +Music2_GetNextMusicByte: ; 0x9825 + ld d, $0 + ld a, c + add a + ld e, a + ld hl, $c006 + add hl, de + ld a, [hli] + ld e, a + ld a, [hld] + ld d, a + ld a, [de] ; get next music command + inc de + ld [hl], e ; store address of next command + inc hl + ld [hl], d + ret + +Func_9838: ; 0x9838 + ld a, c + ld hl, Unknown_9b17 + add l + jr nc, .noCarry + inc h +.noCarry + ld l, a + ld a, [hl] + add b + ld l, a + ld h, $ff + ret + +Func_9847: ; 0x9847 + ld h, $0 +.loop + srl a + jr nc, .noCarry + add hl, de +.noCarry + sla e + rl d + and a + jr z, .done + jr .loop +.done + ret + +Func_9858: ; 0x9858 + ld h, $0 + ld l, a + add hl, hl + ld d, h + ld e, l + ld hl, Unknown_9b2f + add hl, de + ld e, [hl] + inc hl + ld d, [hl] + ld a, b +.loop + cp $7 + jr z, .done + sra d + rr e + inc a + jr .loop +.done + ld a, $8 + add d + ld d, a + ret + +Func_9876: ; 0x9876 + ld [$c001], a + cp $ff + jp z, Func_9a34 + cp $b9 + jp z, Func_994e + jp c, Func_994e + cp $fe + jr z, .asm_988d + jp nc, Func_994e +.asm_988d + xor a + ld [$c000], a + ld [$c003], a + ld [$c0e9], a + ld [$c0e6], a + ld [$c0e7], a + ld d, $8 + ld hl, $c016 + call FillMusicRAM2 + ld hl, $c006 + call FillMusicRAM2 + ld d, $4 + ld hl, $c026 + call FillMusicRAM2 + ld hl, $c02e + call FillMusicRAM2 + ld hl, $c03e + call FillMusicRAM2 + ld hl, $c046 + call FillMusicRAM2 + ld hl, $c04e + call FillMusicRAM2 + ld hl, $c056 + call FillMusicRAM2 + ld hl, $c05e + call FillMusicRAM2 + ld hl, $c066 + call FillMusicRAM2 + ld hl, $c06e + call FillMusicRAM2 + ld hl, $c036 + call FillMusicRAM2 + ld hl, $c076 + call FillMusicRAM2 + ld hl, $c07e + call FillMusicRAM2 + ld hl, $c086 + call FillMusicRAM2 + ld hl, $c08e + call FillMusicRAM2 + ld hl, $c096 + call FillMusicRAM2 + ld hl, $c09e + call FillMusicRAM2 + ld hl, $c0a6 + call FillMusicRAM2 + ld hl, $c0ae + call FillMusicRAM2 + ld a, $1 + ld hl, $c0be + call FillMusicRAM2 + ld hl, $c0b6 + call FillMusicRAM2 + ld hl, $c0c6 + call FillMusicRAM2 + ld [$c0e8], a + ld a, $ff + ld [$c004], a + xor a + ld [$ff00+$24], a + ld a, $8 + ld [$ff00+$10], a + ld a, $0 + ld [$ff00+$25], a + xor a + ld [$ff00+$1a], a + ld a, $80 + ld [$ff00+$1a], a + ld a, $77 + ld [$ff00+$24], a + jp Func_9a8f + +Func_994e: ; 0x994e + ld l, a + ld e, a + ld h, $0 + ld d, h + add hl, hl + add hl, de + ld de, SFX_Headers_02 + add hl, de + ld a, h + ld [$c0ec], a + ld a, l + ld [$c0ed], a + ld a, [hl] + and $c0 + rlca + rlca + ld c, a +.asm_9967 + ld d, c + ld a, c + add a + add c + ld c, a + ld b, $0 + ld a, [$c0ec] + ld h, a + ld a, [$c0ed] + ld l, a + add hl, bc + ld c, d + ld a, [hl] + and $f + ld e, a + ld d, $0 + ld hl, $c026 + add hl, de + ld a, [hl] + and a + jr z, .asm_99a3 + ld a, e + cp $7 + jr nz, .asm_999a + ld a, [$c001] + cp $14 + jr nc, .asm_9993 + ret +.asm_9993 + ld a, [hl] + cp $14 + jr z, .asm_99a3 + jr c, .asm_99a3 +.asm_999a + ld a, [$c001] + cp [hl] + jr z, .asm_99a3 + jr c, .asm_99a3 + ret +.asm_99a3 + xor a + push de + ld h, d + ld l, e + add hl, hl + ld d, h + ld e, l + ld hl, $c016 + add hl, de + ld [hli], a + ld [hl], a + ld hl, $c006 + add hl, de + ld [hli], a + ld [hl], a + pop de + ld hl, $c026 + add hl, de + ld [hl], a + ld hl, $c02e + add hl, de + ld [hl], a + ld hl, $c03e + add hl, de + ld [hl], a + ld hl, $c046 + add hl, de + ld [hl], a + ld hl, $c04e + add hl, de + ld [hl], a + ld hl, $c056 + add hl, de + ld [hl], a + ld hl, $c05e + add hl, de + ld [hl], a + ld hl, $c066 + add hl, de + ld [hl], a + ld hl, $c06e + add hl, de + ld [hl], a + ld hl, $c076 + add hl, de + ld [hl], a + ld hl, $c07e + add hl, de + ld [hl], a + ld hl, $c086 + add hl, de + ld [hl], a + ld hl, $c08e + add hl, de + ld [hl], a + ld hl, $c096 + add hl, de + ld [hl], a + ld hl, $c09e + add hl, de + ld [hl], a + ld hl, $c0a6 + add hl, de + ld [hl], a + ld hl, $c0ae + add hl, de + ld [hl], a + ld hl, $c036 + add hl, de + ld [hl], a + ld a, $1 + ld hl, $c0be + add hl, de + ld [hl], a + ld hl, $c0b6 + add hl, de + ld [hl], a + ld hl, $c0c6 + add hl, de + ld [hl], a + ld a, e + cp $4 + jr nz, .asm_9a2b + ld a, $8 + ld [$ff00+$10], a +.asm_9a2b + ld a, c + and a + jp z, Func_9a8f + dec c + jp .asm_9967 + +Func_9a34: ; 0x9a34 + ld a, $80 + ld [$ff00+$26], a + ld [$ff00+$1a], a + xor a + ld [$ff00+$25], a + ld [$ff00+$1c], a + ld a, $8 + ld [$ff00+$10], a + ld [$ff00+$12], a + ld [$ff00+$17], a + ld [$ff00+$21], a + ld a, $40 + ld [$ff00+$14], a + ld [$ff00+$19], a + ld [$ff00+$23], a + ld a, $77 + ld [$ff00+$24], a + xor a + ld [$c000], a + ld [$c003], a + ld [$c002], a + ld [$c0e9], a + ld [$c0eb], a + ld [$c0e6], a + ld [$c0e7], a + ld d, $a0 + ld hl, $c006 + call FillMusicRAM2 + ld a, $1 + ld d, $18 + ld hl, $c0b6 + call FillMusicRAM2 + ld [$c0e8], a + ld [$c0ea], a + ld a, $ff + ld [$c004], a + ret + +; fills d bytes at hl with a +FillMusicRAM2: ; 0x9a89 + ld b, d +.loop + ld [hli], a + dec b + jr nz, .loop + ret + +Func_9a8f: ; 0x9a8f + ld a, [$c001] + ld l, a + ld e, a + ld h, $0 + ld d, h + add hl, hl + add hl, de + ld de, SFX_Headers_02 + add hl, de + ld e, l + ld d, h + ld hl, $c006 + ld a, [de] ; get channel number + ld b, a + rlca + rlca + and $3 + ld c, a + ld a, b + and $f + ld b, c + inc b + inc de + ld c, $0 +.asm_9ab1 + cp c + jr z, .asm_9ab9 + inc c + inc hl + inc hl + jr .asm_9ab1 +.asm_9ab9 + push hl + push bc + push af + ld b, $0 + ld c, a + ld hl, $c026 + add hl, bc + ld a, [$c001] + ld [hl], a + pop af + cp $3 + jr c, .asm_9ad2 + ld hl, $c02e + add hl, bc + set 2, [hl] +.asm_9ad2 + pop bc + pop hl + ld a, [de] ; get channel pointer + ld [hli], a + inc de + ld a, [de] + ld [hli], a + inc de + inc c + dec b + ld a, b + and a + ld a, [de] + inc de + jr nz, .asm_9ab1 + ld a, [$c001] + cp $14 + jr nc, .asm_9aeb + jr .asm_9b15 +.asm_9aeb + ld a, [$c001] + cp $86 + jr z, .asm_9b15 + jr c, .asm_9af6 + jr .asm_9b15 +.asm_9af6 + ld hl, $c02a + ld [hli], a + ld [hli], a + ld [hli], a + ld [hl], a + ld hl, $c012 ; sfx noise channel pointer + ld de, Noise2_endchannel + ld [hl], e + inc hl + ld [hl], d ; overwrite pointer to point to endchannel + ld a, [$c005] + and a + jr nz, .asm_9b15 + ld a, [$ff00+$24] + ld [$c005], a + ld a, $77 + ld [$ff00+$24], a +.asm_9b15 + ret + +Noise2_endchannel: ; 0x9b16 + endchannel + +Unknown_9b17: ; 0x9b17 + db $10, $15, $1A, $1F ; channels 0-3 + db $10, $15, $1A, $1F ; channels 4-7 + +Unknown_9b1f: ; 0x9b1f + db $EE, $DD, $BB, $77 ; channels 0-3 + db $EE, $DD, $BB, $77 ; channels 4-7 + +Unknown_9b27: ; 0x9b27 + db $11, $22, $44, $88 ; channels 0-3 + db $11, $22, $44, $88 ; channels 4-7 + +Unknown_9b2f: ; 0x9b2f + dw $F82C + dw $F89D + dw $F907 + dw $F96B + dw $F9CA + dw $FA23 + dw $FA77 + dw $FAC7 + dw $FB12 + dw $FB58 + dw $FB9B + dw $FBDA + + diff --git a/audio/engine_2.asm b/audio/engine_2.asm new file mode 100644 index 00000000..deb65357 --- /dev/null +++ b/audio/engine_2.asm @@ -0,0 +1,1733 @@ +; The second of three duplicated sound engines. + +Func_21879: ; 21879 (8:5879) + ld c, CH0 +.loop + ld b, $0 + ld hl, $c026 + add hl, bc + ld a, [hl] + and a + jr z, .nextChannel + ld a, c + cp CH4 + jr nc, .applyAffects ; if sfx channel + ld a, [$c002] + and a + jr z, .applyAffects + bit 7, a + jr nz, .nextChannel + set 7, a + ld [$c002], a + xor a + ld [$FF00+$25], a + ld [$FF00+$1a], a + ld a, $80 + ld [$FF00+$1a], a + jr .nextChannel +.applyAffects + call Music8_ApplyMusicAffects +.nextChannel + ld a, c + inc c + cp CH7 + jr nz, .loop + ret + +; this routine checks flags for music effects currently applied +; to the channel and calls certain functions based on flags. +; known flags for $c02e: +; 1: call has been used +; 3: a toggle used only by this routine for vibrato +; 4: pitchbend flag +; 6: dutycycle flag +Music8_ApplyMusicAffects: ; 218ae (8:58ae) + ld b, $0 + ld hl, $c0b6 ; delay unitl next note + add hl, bc + ld a, [hl] + cp $1 ; if the delay is 1, play next note + jp z, Music8_PlayNextNote + dec a ; otherwise, decrease the delay timer + ld [hl], a + ld a, c + cp CH4 + jr nc, .startChecks ; if a sfx channel + ld hl, $c02a + add hl, bc + ld a, [hl] + and a + jr z, .startChecks + ret +.startChecks + ld hl, $c02e + add hl, bc + bit 6, [hl] ; dutycycle + jr z, .checkForExecuteMusic + call Music8_ApplyDutyCycle +.checkForExecuteMusic + ld b, $0 + ld hl, $c036 + add hl, bc + bit 0, [hl] + jr nz, .checkForPitchBend + ld hl, $c02e + add hl, bc + bit 2, [hl] + jr nz, .disablePitchBendVibrato +.checkForPitchBend + ld hl, $c02e + add hl, bc + bit 4, [hl] ; pitchbend + jr z, .checkVibratoDelay + jp Music8_ApplyPitchBend +.checkVibratoDelay + ld hl, $c04e ; vibrato delay + add hl, bc + ld a, [hl] + and a ; check if delay is over + jr z, .checkForVibrato + dec [hl] ; otherwise, dec delay +.disablePitchBendVibrato + ret +.checkForVibrato + ld hl, $c056 ; vibrato rate + add hl, bc + ld a, [hl] + and a + jr nz, .vibrato + ret ; no vibrato +.vibrato + ld d, a + ld hl, $c05e + add hl, bc + ld a, [hl] + and $f + and a + jr z, .vibratoAlreadyDone + dec [hl] ; apply vibrato pitch change + ret +.vibratoAlreadyDone + ld a, [hl] + swap [hl] + or [hl] + ld [hl], a ; reset the vibrato value and start again + ld hl, $c066 + add hl, bc + ld e, [hl] ; get note pitch + ld hl, $c02e + add hl, bc + bit 3, [hl] ; this is the only code that sets/resets bit three so + jr z, .unset ; it continuously alternates which path it takes + res 3, [hl] + ld a, d + and $f + ld d, a + ld a, e + sub d + jr nc, .noCarry + ld a, $0 +.noCarry + jr .done +.unset + set 3, [hl] + ld a, d + and $f0 + swap a + add e + jr nc, .done + ld a, $ff +.done + ld d, a + ld b, $3 + call Func_21ff7 + ld [hl], d + ret + +; this routine executes all music commands that take up no time, +; like tempo changes, duty changes etc. and doesn't return +; until the first note is reached +Music8_PlayNextNote: ; 21946 (8:5946) + ld hl, $c06e + add hl, bc + ld a, [hl] + ld hl, $c04e + add hl, bc + ld [hl], a + ld hl, $c02e + add hl, bc + res 4, [hl] + res 5, [hl] + ld a, c + cp CH4 + jr nz, .beginChecks + ld a, [$d083] + bit 7, a + ret nz +.beginChecks + call Music8_endchannel + ret + +Music8_endchannel: ; 21967 (8:5967) + call Music8_GetNextMusicByte + ld d, a + cp $ff ; is this command an endchannel? + jp nz, Music8_callchannel ; no + ld b, $0 ; yes + ld hl, $c02e + add hl, bc + bit 1, [hl] + jr nz, .returnFromCall + ld a, c + cp CH3 + jr nc, .noiseOrSfxChannel + jr .asm_219c0 +.noiseOrSfxChannel + res 2, [hl] + ld hl, $c036 + add hl, bc + res 0, [hl] + cp CH6 + jr nz, .notSfxChannel3 + ld a, $0 + ld [$FF00+$1a], a + ld a, $80 + ld [$FF00+$1a], a +.notSfxChannel3 + jr nz, .asm_219a3 + ld a, [$c003] + and a + jr z, .asm_219a3 + xor a + ld [$c003], a + jr .asm_219c0 +.asm_219a3 + jr .asm_219c9 +.returnFromCall + res 1, [hl] + ld d, $0 + ld a, c + add a + ld e, a + ld hl, $c006 + add hl, de + push hl ; store current channel address + ld hl, $c016 + add hl, de + ld e, l + ld d, h + pop hl + ld a, [de] + ld [hli], a + inc de + ld a, [de] + ld [hl], a ; loads channel address to return to + jp Music8_endchannel +.asm_219c0 + ld hl, Unknown_222de + add hl, bc + ld a, [$FF00+$25] + and [hl] + ld [$FF00+$25], a +.asm_219c9 + ld a, [$c02a] + cp $14 + jr nc, .asm_219d2 + jr .asm_219ef +.asm_219d2 + ld a, [$c02a] + cp $86 + jr z, .asm_219ef + jr c, .asm_219dd + jr .asm_219ef +.asm_219dd + ld a, c + cp CH4 + jr z, .asm_219e6 + call Func_21e6d + ret c +.asm_219e6 + ld a, [$c005] + ld [$FF00+$24], a + xor a + ld [$c005], a +.asm_219ef + ld hl, $c026 + add hl, bc + ld [hl], b + ret + +Music8_callchannel: ; 219f5 (8:59f5) + cp $fd ; is this command a callchannel? + jp nz, Music8_loopchannel ; no + call Music8_GetNextMusicByte ; yes + push af + call Music8_GetNextMusicByte + ld d, a + pop af + ld e, a + push de ; store pointer + ld d, $0 + ld a, c + add a + ld e, a + ld hl, $c006 + add hl, de + push hl + ld hl, $c016 + add hl, de + ld e, l + ld d, h + pop hl + ld a, [hli] + ld [de], a + inc de + ld a, [hld] + ld [de], a ; copy current channel address + pop de + ld [hl], e + inc hl + ld [hl], d ; overwrite current address with pointer + ld b, $0 + ld hl, $c02e + add hl, bc + set 1, [hl] ; set the call flag + jp Music8_endchannel + +Music8_loopchannel: ; 21a2a (8:5a2a) + cp $fe ; is this command a loopchannel? + jp nz, Music8_notetype ; no + call Music8_GetNextMusicByte ; yes + ld e, a + and a + jr z, .infiniteLoop + ld b, $0 + ld hl, $c0be + add hl, bc + ld a, [hl] + cp e + jr nz, .loopAgain + ld a, $1 ; if no more loops to make, + ld [hl], a + call Music8_GetNextMusicByte ; skip pointer + call Music8_GetNextMusicByte + jp Music8_endchannel +.loopAgain ; inc loop count + inc a + ld [hl], a + ; fall through +.infiniteLoop ; overwrite current address with pointer + call Music8_GetNextMusicByte + push af + call Music8_GetNextMusicByte + ld b, a + ld d, $0 + ld a, c + add a + ld e, a + ld hl, $c006 + add hl, de + pop af + ld [hli], a + ld [hl], b + jp Music8_endchannel + +Music8_notetype: ; 21a65 (8:5a65) + and $f0 + cp $d0 ; is this command a notetype? + jp nz, Music8_togglecall ; no + ld a, d ; yes + and $f + ld b, $0 + ld hl, $c0c6 + add hl, bc + ld [hl], a ; store low nibble as speed + ld a, c + cp CH3 + jr z, .noiseChannel ; noise channel has 0 params + call Music8_GetNextMusicByte + ld d, a + ld a, c + cp CH2 + jr z, .musicChannel3 + cp CH6 + jr nz, .notChannel3 + ld hl, $c0e7 + jr .sfxChannel3 +.musicChannel3 + ld hl, $c0e6 +.sfxChannel3 + ld a, d + and $f + ld [hl], a ; store low nibble of param as duty + ld a, d + and $30 + sla a + ld d, a + ; fall through + + ; if channel 3, store high nibble as volume + ; else, store volume (high nibble) and fade (low nibble) +.notChannel3 + ld b, $0 + ld hl, $c0de + add hl, bc + ld [hl], d +.noiseChannel + jp Music8_endchannel + +Music8_togglecall: ; 21aa4 (8:5aa4) + ld a, d + cp $e8 ; is this command an togglecall? + jr nz, Music8_vibrato ; no + ld b, $0 ; yes + ld hl, $c02e + add hl, bc + ld a, [hl] + xor $1 + ld [hl], a ; flip bit 0 of $c02e (toggle returning from call) + jp Music8_endchannel + +Music8_vibrato: ; 21ab6 (8:5ab6) + cp $ea ; is this command a vibrato? + jr nz, Music8_pitchbend ; no + call Music8_GetNextMusicByte ; yes + ld b, $0 + ld hl, $c04e + add hl, bc + ld [hl], a ; store delay + ld hl, $c06e + add hl, bc + ld [hl], a ; store delay + call Music8_GetNextMusicByte + ld d, a + and $f0 + swap a + ld b, $0 + ld hl, $c056 + add hl, bc + srl a + ld e, a + adc b + swap a + or e + ld [hl], a ; store rate as both high and low nibbles + ld a, d + and $f + ld d, a + ld hl, $c05e + add hl, bc + swap a + or d + ld [hl], a ; store depth as both high and low nibbles + jp Music8_endchannel + +Music8_pitchbend: ; 21aee (8:5aee) + cp $eb ; is this command a pitchbend? + jr nz, Music8_duty ; no + call Music8_GetNextMusicByte ; yes + ld b, $0 + ld hl, $c076 + add hl, bc + ld [hl], a ; store first param + call Music8_GetNextMusicByte + ld d, a + and $f0 + swap a + ld b, a + ld a, d + and $f + call Func_22017 + ld b, $0 + ld hl, $c0a6 + add hl, bc + ld [hl], d ; store unknown part of second param + ld hl, $c0ae + add hl, bc + ld [hl], e ; store unknown part of second param + ld b, $0 + ld hl, $c02e + add hl, bc + set 4, [hl] ; set pitchbend flag + call Music8_GetNextMusicByte + ld d, a + jp Music8_notelength + +Music8_duty: ; 21b26 (8:5b26) + cp $ec ; is this command a duty? + jr nz, Music8_tempo ; no + call Music8_GetNextMusicByte ; yes + rrca + rrca + and $c0 + ld b, $0 + ld hl, $c03e + add hl, bc + ld [hl], a ; store duty + jp Music8_endchannel + +Music8_tempo: ; 21b3b (8:5b3b) + cp $ed ; is this command a tempo? + jr nz, Music8_unknownmusic0xee ; no + ld a, c ; yes + cp CH4 + jr nc, .sfxChannel + call Music8_GetNextMusicByte + ld [$c0e8], a ; store first param + call Music8_GetNextMusicByte + ld [$c0e9], a ; store second param + xor a + ld [$c0ce], a ; clear RAM + ld [$c0cf], a + ld [$c0d0], a + ld [$c0d1], a + jr .musicChannelDone +.sfxChannel + call Music8_GetNextMusicByte + ld [$c0ea], a ; store first param + call Music8_GetNextMusicByte + ld [$c0eb], a ; store second param + xor a + ld [$c0d2], a ; clear RAM + ld [$c0d3], a + ld [$c0d4], a + ld [$c0d5], a +.musicChannelDone + jp Music8_endchannel + +Music8_unknownmusic0xee: ; 21b7b (8:5b7b) + cp $ee ; is this command an unknownmusic0xee? + jr nz, Music8_unknownmusic0xef ; no + call Music8_GetNextMusicByte ; yes + ld [$c004], a ; store first param + jp Music8_endchannel + +; this appears to never be used +Music8_unknownmusic0xef: ; 21b88 (8:5b88) + cp $ef ; is this command an unknownmusic0xef? + jr nz, Music8_dutycycle ; no + call Music8_GetNextMusicByte ; yes + push bc + call Func_22035 + pop bc + ld a, [$c003] + and a + jr nz, .skip + ld a, [$c02d] + ld [$c003], a + xor a + ld [$c02d], a +.skip + jp Music8_endchannel + +Music8_dutycycle: ; 21ba7 (8:5ba7) + cp $fc ; is this command a dutycycle? + jr nz, Music8_stereopanning ; no + call Music8_GetNextMusicByte ; yes + ld b, $0 + ld hl, $c046 + add hl, bc + ld [hl], a ; store full cycle + and $c0 + ld hl, $c03e + add hl, bc + ld [hl], a ; store first duty + ld hl, $c02e + add hl, bc + set 6, [hl] ; set dutycycle flag + jp Music8_endchannel + +Music8_stereopanning: ; 21bc5 (8:5bc5) + cp $f0 ; is this command a stereopanning? + jr nz, Music8_executemusic ; no + call Music8_GetNextMusicByte ; yes + ld [$FF00+$24], a + jp Music8_endchannel + +Music8_executemusic: ; 21bd1 (8:5bd1) + cp $f8 ; is this command an executemusic? + jr nz, Music8_octave ; no + ld b, $0 ; yes + ld hl, $c036 + add hl, bc + set 0, [hl] + jp Music8_endchannel + +Music8_octave: ; 21be0 (8:5be0) + and $f0 + cp $e0 ; is this command an octave? + jr nz, Music8_unknownsfx0x20 ; no + ld hl, $c0d6 ; yes + ld b, $0 + add hl, bc + ld a, d + and $f + ld [hl], a ; store low nibble as octave + jp Music8_endchannel + +Music8_unknownsfx0x20: ; 21bf3 + cp $20 ; is this command an unknownsfx0x20? + jr nz, Music8_unknownsfx0x10 ; no + ld a, c + cp CH3 ; is this a noise or sfx channel? + jr c, Music8_unknownsfx0x10 ; no + ld b, $0 + ld hl, $c036 + add hl, bc + bit 0, [hl] + jr nz, Music8_unknownsfx0x10 ; no + call Music8_notelength + ld d, a + ld b, $0 + ld hl, $c03e + add hl, bc + ld a, [hl] + or d + ld d, a + ld b, $1 + call Func_21ff7 + ld [hl], d + call Music8_GetNextMusicByte + ld d, a + ld b, $2 + call Func_21ff7 + ld [hl], d + call Music8_GetNextMusicByte + ld e, a + ld a, c + cp CH7 + ld a, $0 + jr z, .sfxNoiseChannel ; only two params for noise channel + push de + call Music8_GetNextMusicByte + pop de +.sfxNoiseChannel + ld d, a + push de + call Func_21daa + call Func_21d79 + pop de + call Func_21dcc + ret + +Music8_unknownsfx0x10: ; 21c40 (8:5c40) + ld a, c + cp CH4 + jr c, Music8_note ; if not a sfx + ld a, d + cp $10 ; is this command a unknownsfx0x10? + jr nz, Music8_note ; no + ld b, $0 + ld hl, $c036 + add hl, bc + bit 0, [hl] + jr nz, Music8_note ; no + call Music8_GetNextMusicByte ; yes + ld [$FF00+$10], a + jp Music8_endchannel + +Music8_note: ; 21c5c (8:5c5c) + ld a, c + cp CH3 + jr nz, Music8_notelength ; if not noise channel + ld a, d + and $f0 + cp $b0 ; is this command a dnote? + jr z, Music8_dnote ; yes + jr nc, Music8_notelength ; no + swap a + ld b, a + ld a, d + and $f + ld d, a + ld a, b + push de + push bc + jr asm_21c7e + +Music8_dnote: ; 21c76 (8:5c76) + ld a, d + and $f + push af + push bc + call Music8_GetNextMusicByte ; get dnote instrument +asm_21c7e + ld d, a + ld a, [$c003] + and a + jr nz, .asm_21c89 + ld a, d + call Func_22035 +.asm_21c89 + pop bc + pop de + +Music8_notelength: ; 21c8b (8:5c8b) + ld a, d + push af + and $f + inc a + ld b, $0 + ld e, a ; store note length (in 16ths) + ld d, b + ld hl, $c0c6 + add hl, bc + ld a, [hl] + ld l, b + call Func_22006 + ld a, c + cp CH4 + jr nc, .sfxChannel + ld a, [$c0e8] + ld d, a + ld a, [$c0e9] + ld e, a + jr .skip +.sfxChannel + ld d, $1 + ld e, $0 + cp CH7 + jr z, .skip ; if noise channel + call Func_21e2f + ld a, [$c0ea] + ld d, a + ld a, [$c0eb] + ld e, a +.skip + ld a, l + ld b, $0 + ld hl, $c0ce + add hl, bc + ld l, [hl] + call Func_22006 + ld e, l + ld d, h + ld hl, $c0ce + add hl, bc + ld [hl], e + ld a, d + ld hl, $c0b6 + add hl, bc + ld [hl], a + ld hl, $c036 + add hl, bc + bit 0, [hl] + jr nz, Music8_notepitch + ld hl, $c02e + add hl, bc + bit 2, [hl] + jr z, Music8_notepitch + pop hl + ret + +Music8_notepitch: ; 21ce9 (8:5ce9) + pop af + and $f0 + cp $c0 ; compare to rest + jr nz, .notRest + ld a, c + cp CH4 + jr nc, .sfxChannel + ld hl, $c02a + add hl, bc + ld a, [hl] + and a + jr nz, .done + ; fall through +.sfxChannel + ld a, c + cp CH2 + jr z, .musicChannel3 + cp CH6 + jr nz, .notSfxChannel3 +.musicChannel3 + ld b, $0 + ld hl, Unknown_222de + add hl, bc + ld a, [$FF00+$25] + and [hl] + ld [$FF00+$25], a + jr .done +.notSfxChannel3 + ld b, $2 + call Func_21ff7 + ld a, $8 + ld [hli], a + inc hl + ld a, $80 + ld [hl], a +.done + ret +.notRest + swap a + ld b, $0 + ld hl, $c0d6 + add hl, bc + ld b, [hl] + call Func_22017 + ld b, $0 + ld hl, $c02e + add hl, bc + bit 4, [hl] + jr z, .asm_21d39 + call Func_21f4e +.asm_21d39 + push de + ld a, c + cp CH4 + jr nc, .skip ; if sfx channel + ld hl, $c02a + ld d, $0 + ld e, a + add hl, de + ld a, [hl] + and a + jr nz, .asm_21d4c + jr .skip +.asm_21d4c + pop de + ret +.skip + ld b, $0 + ld hl, $c0de + add hl, bc + ld d, [hl] + ld b, $2 + call Func_21ff7 + ld [hl], d + call Func_21daa + call Func_21d79 + pop de + ld b, $0 + ld hl, $c02e + add hl, bc + bit 0, [hl] + jr z, .asm_21d70 + inc e + jr nc, .asm_21d70 + inc d +.asm_21d70 + ld hl, $c066 + add hl, bc + ld [hl], e + call Func_21dcc + ret + +Func_21d79: ; 21d79 (8:5d79) + ld b, $0 + ld hl, Unknown_222e6 + add hl, bc + ld a, [$FF00+$25] + or [hl] + ld d, a + ld a, c + cp CH7 + jr z, .sfxNoiseChannel + cp CH4 + jr nc, .skip ; if sfx channel + ld hl, $c02a + add hl, bc + ld a, [hl] + and a + jr nz, .skip +.sfxNoiseChannel + ld a, [$c004] + ld hl, Unknown_222e6 + add hl, bc + and [hl] + ld d, a + ld a, [$FF00+$25] + ld hl, Unknown_222de + add hl, bc + and [hl] + or d + ld d, a +.skip + ld a, d + ld [$FF00+$25], a + ret + +Func_21daa: ; 21daa (8:5daa) + ld b, $0 + ld hl, $c0b6 + add hl, bc + ld d, [hl] + ld a, c + cp CH2 + jr z, .channel3 ; if music channel 3 + cp CH6 + jr z, .channel3 ; if sfx channel 3 + ld a, d + and $3f + ld d, a + ld hl, $c03e + add hl, bc + ld a, [hl] + or d + ld d, a +.channel3 + ld b, $1 + call Func_21ff7 + ld [hl], d + ret + +Func_21dcc: ; 21dcc (8:5dcc) + ld a, c + cp CH2 + jr z, .channel3 + cp CH6 + jr nz, .notSfxChannel3 + ; fall through +.channel3 + push de + ld de, $c0e6 + cp CH2 + jr z, .musicChannel3 + ld de, $c0e7 +.musicChannel3 + ld a, [de] + add a + ld d, $0 + ld e, a + ld hl, Music8_Channel3DutyPointers + add hl, de + ld e, [hl] + inc hl + ld d, [hl] + ld hl, $ff30 + ld b, $f + ld a, $0 + ld [$FF00+$1a], a +.loop + ld a, [de] + inc de + ld [hli], a + ld a, b + dec b + and a + jr nz, .loop + ld a, $80 + ld [$FF00+$1a], a + pop de +.notSfxChannel3 + ld a, d + or $80 + and $c7 + ld d, a + ld b, $3 + call Func_21ff7 + ld [hl], e + inc hl + ld [hl], d + ld a, c + cp CH4 + jr c, .musicChannel + call Func_21e56 +.musicChannel + ret + +Func_21e19: ; 21e19 (8:5e19) + ld a, c + cp CH4 + jr nz, .asm_21e2e + ld a, [$d083] + bit 7, a + jr z, .asm_21e2e + xor a + ld [$c0f1], a + ld a, $80 + ld [$c0f2], a +.asm_21e2e + ret + +Func_21e2f: ; 21e2f (8:5e2f) + call Func_21e8b + jr c, .asm_21e39 + call Func_21e9f + jr nc, .asm_21e4c +.asm_21e39 + ld d, $0 + ld a, [$c0f2] + add $80 + jr nc, .asm_21e43 + inc d +.asm_21e43 + ld [$c0eb], a + ld a, d + ld [$c0ea], a + jr .asm_21e55 +.asm_21e4c + xor a + ld [$c0eb], a + ld a, $1 + ld [$c0ea], a +.asm_21e55 + ret + +Func_21e56: ; 21e56 (8:5e56) + call Func_21e8b + jr c, .asm_21e60 + call Func_21e9f + jr nc, .asm_21e6c +.asm_21e60 + ld a, [$c0f1] + add e + jr nc, .asm_21e67 + inc d +.asm_21e67 + dec hl + ld e, a + ld [hl], e + inc hl + ld [hl], d +.asm_21e6c + ret + +Func_21e6d: ; 21e6d (8:5e6d) + call Func_21e8b + jr nc, .asm_21e88 + ld hl, $c006 + ld e, c + ld d, $0 + sla e + rl d + add hl, de + ld a, [hl] + sub $1 + ld [hl], a + inc hl + ld a, [hl] + sbc $0 + ld [hl], a + scf + ret +.asm_21e88 + scf + ccf + ret + +Func_21e8b: ; 21e8b (8:5e8b) + ld a, [$c02a] + cp $14 + jr nc, .asm_21e94 + jr .asm_21e9a +.asm_21e94 + cp $86 + jr z, .asm_21e9a + jr c, .asm_21e9d +.asm_21e9a + scf + ccf + ret +.asm_21e9d + scf + ret + +Func_21e9f: ; 21e9f (8:5e9f) + ld a, [$c02d] + ld b, a + ld a, [$c02a] + or b + cp $9d + jr nc, .asm_21ead + jr .asm_21eb3 +.asm_21ead + cp $ea + jr z, .asm_21eb3 + jr c, .asm_21eb6 +.asm_21eb3 + scf + ccf + ret +.asm_21eb6 + scf + ret + +Music8_ApplyPitchBend: ; 21eb8 (8:5eb8) + ld hl, $c02e + add hl, bc + bit 5, [hl] + jp nz, .asm_21eff + ld hl, $c09e + add hl, bc + ld e, [hl] + ld hl, $c096 + add hl, bc + ld d, [hl] + ld hl, $c07e + add hl, bc + ld l, [hl] + ld h, b + add hl, de + ld d, h + ld e, l + ld hl, $c08e + add hl, bc + push hl + ld hl, $c086 + add hl, bc + ld a, [hl] + pop hl + add [hl] + ld [hl], a + ld a, $0 + adc e + ld e, a + ld a, $0 + adc d + ld d, a + ld hl, $c0a6 + add hl, bc + ld a, [hl] + cp d + jp c, .asm_21f45 + jr nz, .asm_21f32 + ld hl, $c0ae + add hl, bc + ld a, [hl] + cp e + jp c, .asm_21f45 + jr .asm_21f32 +.asm_21eff + ld hl, $c09e + add hl, bc + ld a, [hl] + ld hl, $c096 + add hl, bc + ld d, [hl] + ld hl, $c07e + add hl, bc + ld e, [hl] + sub e + ld e, a + ld a, d + sbc b + ld d, a + ld hl, $c086 + add hl, bc + ld a, [hl] + add a + ld [hl], a + ld a, e + sbc b + ld e, a + ld a, d + sbc b + ld d, a + ld hl, $c0a6 + add hl, bc + ld a, d + cp [hl] + jr c, .asm_21f45 + jr nz, .asm_21f32 + ld hl, $c0ae + add hl, bc + ld a, e + cp [hl] + jr c, .asm_21f45 +.asm_21f32 + ld hl, $c09e + add hl, bc + ld [hl], e + ld hl, $c096 + add hl, bc + ld [hl], d + ld b, $3 + call Func_21ff7 + ld a, e + ld [hli], a + ld [hl], d + ret +.asm_21f45 + ld hl, $c02e + add hl, bc + res 4, [hl] + res 5, [hl] + ret + +Func_21f4e: ; 21f4e (8:5f4e) + ld hl, $c096 + add hl, bc + ld [hl], d + ld hl, $c09e + add hl, bc + ld [hl], e + ld hl, $c0b6 + add hl, bc + ld a, [hl] + ld hl, $c076 + add hl, bc + sub [hl] + jr nc, .asm_21f66 + ld a, $1 +.asm_21f66 + ld [hl], a + ld hl, $c0ae + add hl, bc + ld a, e + sub [hl] + ld e, a + ld a, d + sbc b + ld hl, $c0a6 + add hl, bc + sub [hl] + jr c, .asm_21f82 + ld d, a + ld b, $0 + ld hl, $c02e + add hl, bc + set 5, [hl] + jr .asm_21fa5 +.asm_21f82 + ld hl, $c096 + add hl, bc + ld d, [hl] + ld hl, $c09e + add hl, bc + ld e, [hl] + ld hl, $c0ae + add hl, bc + ld a, [hl] + sub e + ld e, a + ld a, d + sbc b + ld d, a + ld hl, $c0a6 + add hl, bc + ld a, [hl] + sub d + ld d, a + ld b, $0 + ld hl, $c02e + add hl, bc + res 5, [hl] +.asm_21fa5 + ld hl, $c076 + add hl, bc +.asm_21fa9 + inc b + ld a, e + sub [hl] + ld e, a + jr nc, .asm_21fa9 + ld a, d + and a + jr z, .asm_21fb7 + dec a + ld d, a + jr .asm_21fa9 +.asm_21fb7 + ld a, e + add [hl] + ld d, b + ld b, $0 + ld hl, $c07e + add hl, bc + ld [hl], d + ld hl, $c086 + add hl, bc + ld [hl], a + ld hl, $c08e + add hl, bc + ld [hl], a + ret + +Music8_ApplyDutyCycle: ; 21fcc (8:5fcc) + ld b, $0 + ld hl, $c046 + add hl, bc + ld a, [hl] + rlca + rlca + ld [hl], a + and $c0 + ld d, a + ld b, $1 + call Func_21ff7 + ld a, [hl] + and $3f + or d + ld [hl], a + ret + +Music8_GetNextMusicByte: ; 21fe4 (8:5fe4) + ld d, $0 + ld a, c + add a + ld e, a + ld hl, $c006 + add hl, de + ld a, [hli] + ld e, a + ld a, [hld] + ld d, a + ld a, [de] ; get next music command + inc de + ld [hl], e ; store address of next command + inc hl + ld [hl], d + ret + +Func_21ff7: ; 21ff7 (8:5ff7) + ld a, c + ld hl, Unknown_222d6 + add l + jr nc, .noCarry + inc h +.noCarry + ld l, a + ld a, [hl] + add b + ld l, a + ld h, $ff + ret + +Func_22006: ; 22006 (8:6006) + ld h, $0 +.loop + srl a + jr nc, .noCarry + add hl, de +.noCarry + sla e + rl d + and a + jr z, .done + jr .loop +.done + ret + +Func_22017: ; 22017 (8:6017) + ld h, $0 + ld l, a + add hl, hl + ld d, h + ld e, l + ld hl, Unknown_222ee + add hl, de + ld e, [hl] + inc hl + ld d, [hl] + ld a, b +.loop + cp CH7 + jr z, .done + sra d + rr e + inc a + jr .loop +.done + ld a, $8 + add d + ld d, a + ret + +Func_22035: ; 22035 (8:6035) + ld [$c001], a + cp $ff + jp z, Func_221f3 + cp $e9 + jp z, Func_2210d + jp c, Func_2210d + cp $fe + jr z, .asm_2204c + jp nc, Func_2210d +.asm_2204c + xor a + ld [$c000], a + ld [$c003], a + ld [$c0e9], a + ld [$c0e6], a + ld [$c0e7], a + ld d, $8 + ld hl, $c016 + call FillMusicRAM8 + ld hl, $c006 + call FillMusicRAM8 + ld d, $4 + ld hl, $c026 + call FillMusicRAM8 + ld hl, $c02e + call FillMusicRAM8 + ld hl, $c03e + call FillMusicRAM8 + ld hl, $c046 + call FillMusicRAM8 + ld hl, $c04e + call FillMusicRAM8 + ld hl, $c056 + call FillMusicRAM8 + ld hl, $c05e + call FillMusicRAM8 + ld hl, $c066 + call FillMusicRAM8 + ld hl, $c06e + call FillMusicRAM8 + ld hl, $c036 + call FillMusicRAM8 + ld hl, $c076 + call FillMusicRAM8 + ld hl, $c07e + call FillMusicRAM8 + ld hl, $c086 + call FillMusicRAM8 + ld hl, $c08e + call FillMusicRAM8 + ld hl, $c096 + call FillMusicRAM8 + ld hl, $c09e + call FillMusicRAM8 + ld hl, $c0a6 + call FillMusicRAM8 + ld hl, $c0ae + call FillMusicRAM8 + ld a, $1 + ld hl, $c0be + call FillMusicRAM8 + ld hl, $c0b6 + call FillMusicRAM8 + ld hl, $c0c6 + call FillMusicRAM8 + ld [$c0e8], a + ld a, $ff + ld [$c004], a + xor a + ld [$FF00+$24], a + ld a, $8 + ld [$FF00+$10], a + ld a, $0 + ld [$FF00+$25], a + xor a + ld [$FF00+$1a], a + ld a, $80 + ld [$FF00+$1a], a + ld a, $77 + ld [$FF00+$24], a + jp Func_2224e + +Func_2210d: ; 2210d (8:610d) + ld l, a + ld e, a + ld h, $0 + ld d, h + add hl, hl + add hl, de + ld de, SFX_Headers_08 + add hl, de + ld a, h + ld [$c0ec], a + ld a, l + ld [$c0ed], a + ld a, [hl] + and $c0 + rlca + rlca + ld c, a +.asm_22126 + ld d, c + ld a, c + add a + add c + ld c, a + ld b, $0 + ld a, [$c0ec] + ld h, a + ld a, [$c0ed] + ld l, a + add hl, bc + ld c, d + ld a, [hl] + and $f + ld e, a + ld d, $0 + ld hl, $c026 + add hl, de + ld a, [hl] + and a + jr z, .asm_22162 + ld a, e + cp $7 + jr nz, .asm_22159 + ld a, [$c001] + cp $14 + jr nc, .asm_22152 + ret +.asm_22152 + ld a, [hl] + cp $14 + jr z, .asm_22162 + jr c, .asm_22162 +.asm_22159 + ld a, [$c001] + cp [hl] + jr z, .asm_22162 + jr c, .asm_22162 + ret +.asm_22162 + xor a + push de + ld h, d + ld l, e + add hl, hl + ld d, h + ld e, l + ld hl, $c016 + add hl, de + ld [hli], a + ld [hl], a + ld hl, $c006 + add hl, de + ld [hli], a + ld [hl], a + pop de + ld hl, $c026 + add hl, de + ld [hl], a + ld hl, $c02e + add hl, de + ld [hl], a + ld hl, $c03e + add hl, de + ld [hl], a + ld hl, $c046 + add hl, de + ld [hl], a + ld hl, $c04e + add hl, de + ld [hl], a + ld hl, $c056 + add hl, de + ld [hl], a + ld hl, $c05e + add hl, de + ld [hl], a + ld hl, $c066 + add hl, de + ld [hl], a + ld hl, $c06e + add hl, de + ld [hl], a + ld hl, $c076 + add hl, de + ld [hl], a + ld hl, $c07e + add hl, de + ld [hl], a + ld hl, $c086 + add hl, de + ld [hl], a + ld hl, $c08e + add hl, de + ld [hl], a + ld hl, $c096 + add hl, de + ld [hl], a + ld hl, $c09e + add hl, de + ld [hl], a + ld hl, $c0a6 + add hl, de + ld [hl], a + ld hl, $c0ae + add hl, de + ld [hl], a + ld hl, $c036 + add hl, de + ld [hl], a + ld a, $1 + ld hl, $c0be + add hl, de + ld [hl], a + ld hl, $c0b6 + add hl, de + ld [hl], a + ld hl, $c0c6 + add hl, de + ld [hl], a + ld a, e + cp $4 + jr nz, .asm_221ea + ld a, $8 + ld [$FF00+$10], a +.asm_221ea + ld a, c + and a + jp z, Func_2224e + dec c + jp .asm_22126 + +Func_221f3: ; 221f3 (8:61f3) + ld a, $80 + ld [$FF00+$26], a + ld [$FF00+$1a], a + xor a + ld [$FF00+$25], a + ld [$FF00+$1c], a + ld a, $8 + ld [$FF00+$10], a + ld [$FF00+$12], a + ld [$FF00+$17], a + ld [$FF00+$21], a + ld a, $40 + ld [$FF00+$14], a + ld [$FF00+$19], a + ld [$FF00+$23], a + ld a, $77 + ld [$FF00+$24], a + xor a + ld [$c000], a + ld [$c003], a + ld [$c002], a + ld [$c0e9], a + ld [$c0eb], a + ld [$c0e6], a + ld [$c0e7], a + ld d, $a0 + ld hl, $c006 + call FillMusicRAM8 + ld a, $1 + ld d, $18 + ld hl, $c0b6 + call FillMusicRAM8 + ld [$c0e8], a + ld [$c0ea], a + ld a, $ff + ld [$c004], a + ret + +; fills d bytes at hl with a +FillMusicRAM8: ; 22248 (8:6248) + ld b, d +.loop + ld [hli], a + dec b + jr nz, .loop + ret + +Func_2224e: ; 2224e (8:624e) + ld a, [$c001] + ld l, a + ld e, a + ld h, $0 + ld d, h + add hl, hl + add hl, de + ld de, SFX_Headers_08 + add hl, de + ld e, l + ld d, h + ld hl, $c006 + ld a, [de] ; get channel number + ld b, a + rlca + rlca + and $3 + ld c, a + ld a, b + and $f + ld b, c + inc b + inc de + ld c, $0 +.asm_22270 + cp c + jr z, .asm_22278 + inc c + inc hl + inc hl + jr .asm_22270 +.asm_22278 + push hl + push bc + push af + ld b, $0 + ld c, a + ld hl, $c026 + add hl, bc + ld a, [$c001] + ld [hl], a + pop af + cp $3 + jr c, .asm_22291 + ld hl, $c02e + add hl, bc + set 2, [hl] +.asm_22291 + pop bc + pop hl + ld a, [de] ; get channel pointer + ld [hli], a + inc de + ld a, [de] + ld [hli], a + inc de + inc c + dec b + ld a, b + and a + ld a, [de] + inc de + jr nz, .asm_22270 + ld a, [$c001] + cp $14 + jr nc, .asm_222aa + jr .asm_222d4 +.asm_222aa + ld a, [$c001] + cp $86 + jr z, .asm_222d4 + jr c, .asm_222b5 + jr .asm_222d4 +.asm_222b5 + ld hl, $c02a + ld [hli], a + ld [hli], a + ld [hli], a + ld [hl], a + ld hl, $c012 ; sfx noise channel pointer + ld de, Noise8_endchannel + ld [hl], e + inc hl + ld [hl], d ; overwrite pointer to point to endchannel + ld a, [$c005] + and a + jr nz, .asm_222d4 + ld a, [$FF00+$24] + ld [$c005], a + ld a, $77 + ld [$FF00+$24], a +.asm_222d4 + ret + +Noise8_endchannel: ; 222d5 (8:62d5) + endchannel + +Unknown_222d6: ; 222d6 (8:62d6) + db $10, $15, $1A, $1F ; channels 0-3 + db $10, $15, $1A, $1F ; channels 4-7 + +Unknown_222de: ; 222de (8:62de) + db $EE, $DD, $BB, $77 ; channels 0-3 + db $EE, $DD, $BB, $77 ; channels 4-7 + +Unknown_222e6: ; 222e6 (8:62e6) + db $11, $22, $44, $88 ; channels 0-3 + db $11, $22, $44, $88 ; channels 4-7 + +Unknown_222ee: ; 222ee (8:62ee) + dw $F82C + dw $F89D + dw $F907 + dw $F96B + dw $F9CA + dw $FA23 + dw $FA77 + dw $FAC7 + dw $FB12 + dw $FB58 + dw $FB9B + dw $FBDA + + diff --git a/audio/engine_3.asm b/audio/engine_3.asm new file mode 100644 index 00000000..1f285ee6 --- /dev/null +++ b/audio/engine_3.asm @@ -0,0 +1,1682 @@ +; The third of three duplicated sound engines. + +Func_7d177: ; 7d177 (1f:5177) + ld c, CH0 +.loop + ld b, $0 + ld hl, $c026 + add hl, bc + ld a, [hl] + and a + jr z, .nextChannel + ld a, c + cp CH4 + jr nc, .applyAffects ; if sfx channel + ld a, [$c002] + and a + jr z, .applyAffects + bit 7, a + jr nz, .nextChannel + set 7, a + ld [$c002], a + xor a + ld [$FF00+$25], a + ld [$FF00+$1a], a + ld a, $80 + ld [$FF00+$1a], a + jr .nextChannel +.applyAffects + call Music1f_Music2_ApplyMusicAffects +.nextChannel + ld a, c + inc c ; inc channel number + cp CH7 + jr nz, .loop + ret + +; this routine checks flags for music effects currently applied +; to the channel and calls certain functions based on flags. +; known flags for $c02e: +; 1: call has been used +; 3: a toggle used only by this routine for vibrato +; 4: pitchbend flag +; 6: dutycycle flag +Music1f_Music2_ApplyMusicAffects: ; 7d1ac (1f:51ac) + ld b, $0 + ld hl, $c0b6 ; delay until next note + add hl, bc + ld a, [hl] + cp $1 ; if delay is 1, play next note + jp z, Music1f_Music2_PlayNextNote + dec a ; otherwise, decrease the delay timer + ld [hl], a + ld a, c + cp CH4 + jr nc, .startChecks ; if a sfx channel + ld hl, $c02a + add hl, bc + ld a, [hl] + and a + jr z, .startChecks + ret +.startChecks + ld hl, $c02e + add hl, bc + bit 6, [hl] ; dutycycle + jr z, .checkForExecuteMusic + call Music1f_ApplyDutyCycle +.checkForExecuteMusic + ld b, $0 + ld hl, $c036 + add hl, bc + bit 0, [hl] + jr nz, .checkForPitchBend + ld hl, $c02e + add hl, bc + bit 2, [hl] + jr nz, .disablePitchBendVibrato +.checkForPitchBend + ld hl, $c02e + add hl, bc + bit 4, [hl] ; pitchbend + jr z, .checkVibratoDelay + jp Music1f_ApplyPitchBend +.checkVibratoDelay + ld hl, $c04e ; vibrato delay + add hl, bc + ld a, [hl] + and a ; check if delay is over + jr z, .checkForVibrato + dec [hl] ; otherwise, dec delay +.disablePitchBendVibrato + ret +.checkForVibrato + ld hl, $c056 ; vibrato rate + add hl, bc + ld a, [hl] + and a + jr nz, .vibrato + ret ; no vibrato +.vibrato + ld d, a + ld hl, $c05e + add hl, bc + ld a, [hl] + and $f + and a + jr z, .vibratoAlreadyDone + dec [hl] ; apply vibrato pitch change + ret +.vibratoAlreadyDone + ld a, [hl] + swap [hl] + or [hl] + ld [hl], a ; reset the vibrato value and start again + ld hl, $c066 + add hl, bc + ld e, [hl] ; get note pitch + ld hl, $c02e + add hl, bc + bit 3, [hl] ; this is the only code that sets/resets bit three so + jr z, .unset ; it continuously alternates which path it takes + res 3, [hl] + ld a, d + and $f + ld d, a + ld a, e + sub d + jr nc, .noCarry + ld a, $0 +.noCarry + jr .done +.unset + set 3, [hl] + ld a, d + and $f0 + swap a + add e + jr nc, .done + ld a, $ff +.done + ld d, a + ld b, $3 + call Func_7d8ac + ld [hl], d + ret + +; this routine executes all music commands that take up no time, +; like tempo changes, duty changes etc. and doesn't return +; until the first note is reached +Music1f_Music2_PlayNextNote: ; 7d244 (1f:5244) + ld hl, $c06e + add hl, bc + ld a, [hl] + ld hl, $c04e + add hl, bc + ld [hl], a + ld hl, $c02e + add hl, bc + res 4, [hl] + res 5, [hl] + call Music1f_endchannel + ret + +Music1f_endchannel: ; 7d25a (1f:525a) + call Music1f_GetNextMusicByte + ld d, a + cp $ff ; is this command an endchannel? + jp nz, Music1f_callchannel ; no + ld b, $0 ; yes + ld hl, $c02e + add hl, bc + bit 1, [hl] + jr nz, .returnFromCall + ld a, c + cp CH3 + jr nc, .noiseOrSfxChannel + jr .asm_7d2b3 +.noiseOrSfxChannel + res 2, [hl] + ld hl, $c036 + add hl, bc + res 0, [hl] + cp CH6 + jr nz, .notSfxChannel3 + ld a, $0 + ld [$FF00+$1a], a + ld a, $80 + ld [$FF00+$1a], a +.notSfxChannel3 + jr nz, .asm_7d296 + ld a, [$c003] + and a + jr z, .asm_7d296 + xor a + ld [$c003], a + jr .asm_7d2b3 +.asm_7d296 + jr .asm_7d2bc +.returnFromCall + res 1, [hl] + ld d, $0 + ld a, c + add a + ld e, a + ld hl, $c006 + add hl, de + push hl ; store current channel address + ld hl, $c016 + add hl, de + ld e, l + ld d, h + pop hl + ld a, [de] + ld [hli], a + inc de + ld a, [de] + ld [hl], a ; loads channel address to return to + jp Music1f_endchannel +.asm_7d2b3 + ld hl, Unknown_7db93 + add hl, bc + ld a, [$FF00+$25] + and [hl] + ld [$FF00+$25], a +.asm_7d2bc + ld a, [$c02a] + cp $14 + jr nc, .asm_7d2c5 + jr .asm_7d2e2 +.asm_7d2c5 + ld a, [$c02a] + cp $86 + jr z, .asm_7d2e2 + jr c, .asm_7d2d0 + jr .asm_7d2e2 +.asm_7d2d0 + ld a, c + cp CH4 + jr z, .asm_7d2d9 + call Func_7d73b + ret c +.asm_7d2d9 + ld a, [$c005] + ld [$FF00+$24], a + xor a + ld [$c005], a +.asm_7d2e2 + ld hl, $c026 + add hl, bc + ld [hl], b + ret + +Music1f_callchannel: ; 7d2e8 (1f:52e8) + cp $fd ; is this command a callchannel? + jp nz, Music1f_loopchannel ; no + call Music1f_GetNextMusicByte ; yes + push af + call Music1f_GetNextMusicByte + ld d, a + pop af + ld e, a + push de ; store pointer + ld d, $0 + ld a, c + add a + ld e, a + ld hl, $c006 + add hl, de + push hl + ld hl, $c016 + add hl, de + ld e, l + ld d, h + pop hl + ld a, [hli] + ld [de], a + inc de + ld a, [hld] + ld [de], a ; copy current channel address + pop de + ld [hl], e + inc hl + ld [hl], d ; overwrite current address with pointer + ld b, $0 + ld hl, $c02e + add hl, bc + set 1, [hl] ; set the call flag + jp Music1f_endchannel + +Music1f_loopchannel: ; 7d31d (1f:531d) + cp $fe ; is this command a loopchannel? + jp nz, Music1f_notetype ; no + call Music1f_GetNextMusicByte ; yes + ld e, a + and a + jr z, .infiniteLoop + ld b, $0 + ld hl, $c0be + add hl, bc + ld a, [hl] + cp e + jr nz, .loopAgain + ld a, $1 ; if no more loops to make + ld [hl], a + call Music1f_GetNextMusicByte ; skip pointer + call Music1f_GetNextMusicByte + jp Music1f_endchannel +.loopAgain ; inc loop count + inc a + ld [hl], a + ; fall through +.infiniteLoop ; overwrite current address with pointer + call Music1f_GetNextMusicByte + push af + call Music1f_GetNextMusicByte + ld b, a + ld d, $0 + ld a, c + add a + ld e, a + ld hl, $c006 + add hl, de + pop af + ld [hli], a + ld [hl], b + jp Music1f_endchannel + +Music1f_notetype: ; 7d358 (1f:5358) + and $f0 + cp $d0 ; is this command a notetype? + jp nz, Music1f_togglecall ; no + ld a, d ; yes + and $f + ld b, $0 + ld hl, $c0c6 + add hl, bc + ld [hl], a ; store low nibble as speed + ld a, c + cp CH3 + jr z, .noiseChannel ; noise channel has 0 params + call Music1f_GetNextMusicByte + ld d, a + ld a, c + cp CH2 + jr z, .musicChannel3 + cp CH6 + jr nz, .notChannel3 + ld hl, $c0e7 + jr .sfxChannel3 +.musicChannel3 + ld hl, $c0e6 +.sfxChannel3 + ld a, d + and $f + ld [hl], a ; store low nibble of param as duty + ld a, d + and $30 + sla a + ld d, a + ; fall through + + ; if channel 3, store high nibble as volume + ; else, store volume (high nibble) and fade (low nibble) +.notChannel3 + ld b, $0 + ld hl, $c0de + add hl, bc + ld [hl], d +.noiseChannel + jp Music1f_endchannel + +Music1f_togglecall: ; 7d397 (1f:5397) + ld a, d + cp $e8 ; is this command an togglecall? + jr nz, Music1f_vibrato ; no + ld b, $0 ; yes + ld hl, $c02e + add hl, bc + ld a, [hl] + xor $1 + ld [hl], a ; flip bit 0 of $c02e (toggle returning from call) + jp Music1f_endchannel + +Music1f_vibrato: ; 7d3a9 (1f:53a9) + cp $ea ; is this command a vibrato? + jr nz, Music1f_pitchbend ; no + call Music1f_GetNextMusicByte ; yes + ld b, $0 + ld hl, $c04e + add hl, bc + ld [hl], a ; store delay + ld hl, $c06e + add hl, bc + ld [hl], a ; store delay + call Music1f_GetNextMusicByte + ld d, a + and $f0 + swap a + ld b, $0 + ld hl, $c056 + add hl, bc + srl a + ld e, a + adc b + swap a + or e + ld [hl], a ; store rate as both high and low nibbles + ld a, d + and $f + ld d, a + ld hl, $c05e + add hl, bc + swap a + or d + ld [hl], a ; store depth as both high and low nibbles + jp Music1f_endchannel + +Music1f_pitchbend: ; 7d3e1 (1f:53e1) + cp $eb ; is this command a pitchbend? + jr nz, Music1f_duty ; no + call Music1f_GetNextMusicByte ; yes + ld b, $0 + ld hl, $c076 + add hl, bc + ld [hl], a ; store first param + call Music1f_GetNextMusicByte + ld d, a + and $f0 + swap a + ld b, a + ld a, d + and $f + call Func_7d8cc + ld b, $0 + ld hl, $c0a6 + add hl, bc + ld [hl], d ; store unknown part of second param + ld hl, $c0ae + add hl, bc + ld [hl], e ; store unknown part of second param + ld b, $0 + ld hl, $c02e + add hl, bc + set 4, [hl] ; set pitchbend flag + call Music1f_GetNextMusicByte + ld d, a + jp Music1f_notelength + +Music1f_duty: ; 7d419 (1f:5419) + cp $ec ; is this command a duty? + jr nz, Music1f_tempo ; no + call Music1f_GetNextMusicByte ; yes + rrca + rrca + and $c0 + ld b, $0 + ld hl, $c03e + add hl, bc + ld [hl], a ; store duty + jp Music1f_endchannel + +Music1f_tempo: ; 7d42e (1f:542e) + cp $ed ; is this command a tempo? + jr nz, Music1f_unknownmusic0xee ; no + ld a, c ; yes + cp CH4 + jr nc, .sfxChannel + call Music1f_GetNextMusicByte + ld [$c0e8], a ; store first param + call Music1f_GetNextMusicByte + ld [$c0e9], a ; store second param + xor a + ld [$c0ce], a ; clear RAM + ld [$c0cf], a + ld [$c0d0], a + ld [$c0d1], a + jr .musicChannelDone +.sfxChannel + call Music1f_GetNextMusicByte + ld [$c0ea], a ; store first param + call Music1f_GetNextMusicByte + ld [$c0eb], a ; store second param + xor a + ld [$c0d2], a ; clear RAM + ld [$c0d3], a + ld [$c0d4], a + ld [$c0d5], a +.musicChannelDone + jp Music1f_endchannel + +Music1f_unknownmusic0xee: ; 7d46e (1f:546e) + cp $ee ; is this command an unknownmusic0xee? + jr nz, Music1f_unknownmusic0xef ; no + call Music1f_GetNextMusicByte ; yes + ld [$c004], a ; store first param + jp Music1f_endchannel + +; this appears to never be used +Music1f_unknownmusic0xef: ; 7d47b (1f:547b) + cp $ef ; is this command an unknownmusic0xef? + jr nz, Music1f_dutycycle ; no + call Music1f_GetNextMusicByte ; yes + push bc + call Func_7d8ea + pop bc + ld a, [$c003] + and a + jr nz, .skip + ld a, [$c02d] + ld [$c003], a + xor a + ld [$c02d], a +.skip + jp Music1f_endchannel + +Music1f_dutycycle: ; 7d49a (1f:549a) + cp $fc ; is this command a dutycycle? + jr nz, Music1f_stereopanning ; no + call Music1f_GetNextMusicByte ; yes + ld b, $0 + ld hl, $c046 + add hl, bc + ld [hl], a ; store full cycle + and $c0 + ld hl, $c03e + add hl, bc + ld [hl], a ; store first duty + ld hl, $c02e + add hl, bc + set 6, [hl] ; set duty flag + jp Music1f_endchannel + +Music1f_stereopanning: ; 7d4b8 (1f:54b8) + cp $f0 ; is this command a stereopanning? + jr nz, Music1f_executemusic ; no + call Music1f_GetNextMusicByte ; yes + ld [$FF00+$24], a ; store stereopanning + jp Music1f_endchannel + +Music1f_executemusic: ; 7d4c4 (1f:54c4) + cp $f8 ; is this command an executemusic? + jr nz, Music1f_octave ; no + ld b, $0 ; yes + ld hl, $c036 + add hl, bc + set 0, [hl] + jp Music1f_endchannel + +Music1f_octave: ; 7d4d3 (1f:54d3) + and $f0 + cp $e0 ; is this command an octave? + jr nz, Music1f_unknownsfx0x20 ; no + ld hl, $c0d6 ; yes + ld b, $0 + add hl, bc + ld a, d + and $f + ld [hl], a ; store low nibble as octave + jp Music1f_endchannel + +Music1f_unknownsfx0x20: ; 7d4e6 (1f:54e6) + cp $20 ; is this command an unknownsfx0x20? + jr nz, Music1f_unknownsfx0x10 ; no + ld a, c + cp CH3 ; is this a noise or sfx channel? + jr c, Music1f_unknownsfx0x10 ; no + ld b, $0 + ld hl, $c036 + add hl, bc + bit 0, [hl] + jr nz, Music1f_unknownsfx0x10 ; no + call Music1f_notelength ; yes + ld d, a + ld b, $0 + ld hl, $c03e + add hl, bc + ld a, [hl] + or d + ld d, a + ld b, $1 + call Func_7d8ac + ld [hl], d + call Music1f_GetNextMusicByte + ld d, a + ld b, $2 + call Func_7d8ac + ld [hl], d + call Music1f_GetNextMusicByte + ld e, a + ld a, c + cp CH7 + ld a, $0 + jr z, .sfxNoiseChannel ; only two params for noise channel + push de + call Music1f_GetNextMusicByte + pop de +.sfxNoiseChannel + ld d, a + push de + call Func_7d69d + call Func_7d66c + pop de + call Func_7d6bf + ret + +Music1f_unknownsfx0x10 ; 7d533 (1f:5533) + ld a, c + cp CH4 + jr c, Music1f_note ; if not a sfx + ld a, d + cp $10 ; is this command an unknownsfx0x10? + jr nz, Music1f_note ; no + ld b, $0 + ld hl, $c036 + add hl, bc + bit 0, [hl] + jr nz, Music1f_note ; no + call Music1f_GetNextMusicByte ; yes + ld [$FF00+$10], a + jp Music1f_endchannel + +Music1f_note: ; 7d54f (1f:554f) + ld a, c + cp CH3 + jr nz, Music1f_notelength ; if not noise channel + ld a, d + and $f0 + cp $b0 ; is this command a dnote? + jr z, Music1f_dnote ; yes + jr nc, Music1f_notelength ; no + swap a + ld b, a + ld a, d + and $f + ld d, a + ld a, b + push de + push bc + jr asm_7d571 + +Music1f_dnote: ; 7d569 (1f:5569) + ld a, d + and $f + push af + push bc + call Music1f_GetNextMusicByte ; get dnote instrument +asm_7d571 + ld d, a + ld a, [$c003] + and a + jr nz, .asm_7d57c + ld a, d + call Func_7d8ea +.asm_7d57c + pop bc + pop de + +Music1f_notelength: ; 7d57e (1f:557e) + ld a, d + push af + and $f + inc a + ld b, $0 + ld e, a ; store note length (in 16ths) + ld d, b + ld hl, $c0c6 + add hl, bc + ld a, [hl] + ld l, b + call Func_7d8bb + ld a, c + cp CH4 + jr nc, .sfxChannel + ld a, [$c0e8] + ld d, a + ld a, [$c0e9] + ld e, a + jr .skip +.sfxChannel + ld d, $1 + ld e, $0 + cp CH7 + jr z, .skip ; if noise channel + call Func_7d707 + ld a, [$c0ea] + ld d, a + ld a, [$c0eb] + ld e, a +.skip + ld a, l + ld b, $0 + ld hl, $c0ce + add hl, bc + ld l, [hl] + call Func_7d8bb + ld e, l + ld d, h + ld hl, $c0ce + add hl, bc + ld [hl], e + ld a, d + ld hl, $c0b6 + add hl, bc + ld [hl], a + ld hl, $c036 + add hl, bc + bit 0, [hl] + jr nz, Music1f_notepitch + ld hl, $c02e + add hl, bc + bit 2, [hl] + jr z, Music1f_notepitch + pop hl + ret + +Music1f_notepitch: ; 7d5dc (1f:55dc) + pop af + and $f0 + cp $c0 ; compare to rest + jr nz, .notRest + ld a, c + cp CH4 + jr nc, .sfxChannel + ld hl, $c02a + add hl, bc + ld a, [hl] + and a + jr nz, .quit + ; fall through +.sfxChannel + ld a, c + cp CH2 + jr z, .musicChannel3 + cp CH6 + jr nz, .notSfxChannel3 +.musicChannel3 + ld b, $0 + ld hl, Unknown_7db93 + add hl, bc + ld a, [$FF00+$25] + and [hl] + ld [$FF00+$25], a + jr .quit +.notSfxChannel3 + ld b, $2 + call Func_7d8ac + ld a, $8 + ld [hli], a + inc hl + ld a, $80 + ld [hl], a +.quit + ret +.notRest + swap a + ld b, $0 + ld hl, $c0d6 + add hl, bc + ld b, [hl] + call Func_7d8cc + ld b, $0 + ld hl, $c02e + add hl, bc + bit 4, [hl] + jr z, .asm_7d62c + call Func_7d803 +.asm_7d62c + push de + ld a, c + cp CH4 + jr nc, .skip ; if sfx Channel + ld hl, $c02a + ld d, $0 + ld e, a + add hl, de + ld a, [hl] + and a + jr nz, .done + jr .skip +.done + pop de + ret +.skip + ld b, $0 + ld hl, $c0de + add hl, bc + ld d, [hl] + ld b, $2 + call Func_7d8ac + ld [hl], d + call Func_7d69d + call Func_7d66c + pop de + ld b, $0 + ld hl, $c02e + add hl, bc + bit 0, [hl] + jr z, .asm_7d663 + inc e + jr nc, .asm_7d663 + inc d +.asm_7d663 + ld hl, $c066 + add hl, bc + ld [hl], e + call Func_7d6bf + ret + +Func_7d66c: ; 7d66c (1f:566c) + ld b, $0 + ld hl, Unknown_7db9b + add hl, bc + ld a, [$FF00+$25] + or [hl] + ld d, a + ld a, c + cp CH7 + jr z, .sfxNoiseChannel + cp CH4 + jr nc, .skip ; if sfx channel + ld hl, $c02a + add hl, bc + ld a, [hl] + and a + jr nz, .skip +.sfxNoiseChannel + ld a, [$c004] + ld hl, Unknown_7db9b + add hl, bc + and [hl] + ld d, a + ld a, [$FF00+$25] + ld hl, Unknown_7db93 + add hl, bc + and [hl] + or d + ld d, a +.skip + ld a, d + ld [$FF00+$25], a + ret + +Func_7d69d: ; 7d69d (1f:569d) + ld b, $0 + ld hl, $c0b6 + add hl, bc + ld d, [hl] + ld a, c + cp CH2 + jr z, .channel3 ; if music channel 3 + cp CH6 + jr z, .channel3 ; if sfx channel 3 + ld a, d + and $3f + ld d, a + ld hl, $c03e + add hl, bc + ld a, [hl] + or d + ld d, a +.channel3 + ld b, $1 + call Func_7d8ac + ld [hl], d + ret + +Func_7d6bf: ; 7d6bf (1f:56bf) + ld a, c + cp CH2 + jr z, .channel3 + cp CH6 + jr nz, .notSfxChannel3 + ; fall through +.channel3 + push de + ld de, $c0e6 + cp CH2 + jr z, .musicChannel3 + ld de, $c0e7 +.musicChannel3 + ld a, [de] + add a + ld d, $0 + ld e, a + ld hl, Music1f_Channel3DutyPointers + add hl, de + ld e, [hl] + inc hl + ld d, [hl] + ld hl, $ff30 + ld b, $f + ld a, $0 + ld [$FF00+$1a], a +.loop + ld a, [de] + inc de + ld [hli], a + ld a, b + dec b + and a + jr nz, .loop + ld a, $80 + ld [$FF00+$1a], a + pop de +.notSfxChannel3 + ld a, d + or $80 + and $c7 + ld d, a + ld b, $3 + call Func_7d8ac + ld [hl], e + inc hl + ld [hl], d + call Func_7d729 + ret + +Func_7d707: ; 7d707 (1f:5707) + call Func_7d759 + jr nc, .asm_7d71f + ld d, $0 + ld a, [$c0f2] + add $80 + jr nc, .asm_7d716 + inc d +.asm_7d716 + ld [$c0eb], a + ld a, d + ld [$c0ea], a + jr .asm_7d728 +.asm_7d71f + xor a + ld [$c0eb], a + ld a, $1 + ld [$c0ea], a +.asm_7d728 + ret + +Func_7d729: ; 7d729 (1f:5729) + call Func_7d759 + jr nc, .asm_7d73a + ld a, [$c0f1] + add e + jr nc, .asm_7d735 + inc d +.asm_7d735 + dec hl + ld e, a + ld [hl], e + inc hl + ld [hl], d +.asm_7d73a + ret + +Func_7d73b: ; 7d73b (1f:573b) + call Func_7d759 + jr nc, .asm_7d756 + ld hl, $c006 + ld e, c + ld d, $0 + sla e + rl d + add hl, de + ld a, [hl] + sub $1 + ld [hl], a + inc hl + ld a, [hl] + sbc $0 + ld [hl], a + scf + ret +.asm_7d756 + scf + ccf + ret + +Func_7d759: ; 7d759 (1f:5759) + ld a, [$c02a] + cp $14 + jr nc, .asm_7d762 + jr .asm_7d768 +.asm_7d762 + cp $86 + jr z, .asm_7d768 + jr c, .asm_7d76b +.asm_7d768 + scf + ccf + ret +.asm_7d76b + scf + ret + +Music1f_ApplyPitchBend: ; 7d76d (1f:576d) + ld hl, $c02e + add hl, bc + bit 5, [hl] + jp nz, .asm_7d7b4 + ld hl, $c09e + add hl, bc + ld e, [hl] + ld hl, $c096 + add hl, bc + ld d, [hl] + ld hl, $c07e + add hl, bc + ld l, [hl] + ld h, b + add hl, de + ld d, h + ld e, l + ld hl, $c08e + add hl, bc + push hl + ld hl, $c086 + add hl, bc + ld a, [hl] + pop hl + add [hl] + ld [hl], a + ld a, $0 + adc e + ld e, a + ld a, $0 + adc d + ld d, a + ld hl, $c0a6 + add hl, bc + ld a, [hl] + cp d + jp c, .asm_7d7fa + jr nz, .asm_7d7e7 + ld hl, $c0ae + add hl, bc + ld a, [hl] + cp e + jp c, .asm_7d7fa + jr .asm_7d7e7 +.asm_7d7b4 + ld hl, $c09e + add hl, bc + ld a, [hl] + ld hl, $c096 + add hl, bc + ld d, [hl] + ld hl, $c07e + add hl, bc + ld e, [hl] + sub e + ld e, a + ld a, d + sbc b + ld d, a + ld hl, $c086 + add hl, bc + ld a, [hl] + add a + ld [hl], a + ld a, e + sbc b + ld e, a + ld a, d + sbc b + ld d, a + ld hl, $c0a6 + add hl, bc + ld a, d + cp [hl] + jr c, .asm_7d7fa + jr nz, .asm_7d7e7 + ld hl, $c0ae + add hl, bc + ld a, e + cp [hl] + jr c, .asm_7d7fa +.asm_7d7e7 + ld hl, $c09e + add hl, bc + ld [hl], e + ld hl, $c096 + add hl, bc + ld [hl], d + ld b, $3 + call Func_7d8ac + ld a, e + ld [hli], a + ld [hl], d + ret +.asm_7d7fa + ld hl, $c02e + add hl, bc + res 4, [hl] + res 5, [hl] + ret + +Func_7d803: ; 7d803 (1f:5803) + ld hl, $c096 + add hl, bc + ld [hl], d + ld hl, $c09e + add hl, bc + ld [hl], e + ld hl, $c0b6 + add hl, bc + ld a, [hl] + ld hl, $c076 + add hl, bc + sub [hl] + jr nc, .asm_7d81b + ld a, $1 +.asm_7d81b + ld [hl], a + ld hl, $c0ae + add hl, bc + ld a, e + sub [hl] + ld e, a + ld a, d + sbc b + ld hl, $c0a6 + add hl, bc + sub [hl] + jr c, .asm_7d837 + ld d, a + ld b, $0 + ld hl, $c02e + add hl, bc + set 5, [hl] + jr .asm_7d85a +.asm_7d837 + ld hl, $c096 + add hl, bc + ld d, [hl] + ld hl, $c09e + add hl, bc + ld e, [hl] + ld hl, $c0ae + add hl, bc + ld a, [hl] + sub e + ld e, a + ld a, d + sbc b + ld d, a + ld hl, $c0a6 + add hl, bc + ld a, [hl] + sub d + ld d, a + ld b, $0 + ld hl, $c02e + add hl, bc + res 5, [hl] +.asm_7d85a + ld hl, $c076 + add hl, bc +.asm_7d85e + inc b + ld a, e + sub [hl] + ld e, a + jr nc, .asm_7d85e + ld a, d + and a + jr z, .asm_7d86c + dec a + ld d, a + jr .asm_7d85e +.asm_7d86c + ld a, e + add [hl] + ld d, b + ld b, $0 + ld hl, $c07e + add hl, bc + ld [hl], d + ld hl, $c086 + add hl, bc + ld [hl], a + ld hl, $c08e + add hl, bc + ld [hl], a + ret + +Music1f_ApplyDutyCycle: ; 7d881 (1f:5881) + ld b, $0 + ld hl, $c046 + add hl, bc + ld a, [hl] + rlca + rlca + ld [hl], a + and $c0 + ld d, a + ld b, $1 + call Func_7d8ac + ld a, [hl] + and $3f + or d + ld [hl], a + ret + +Music1f_GetNextMusicByte: ; 7d899 (1f:5899) + ld d, $0 + ld a, c + add a + ld e, a + ld hl, $c006 + add hl, de + ld a, [hli] + ld e, a + ld a, [hld] + ld d, a + ld a, [de] ; get next music command + inc de + ld [hl], e ; store address of next command + inc hl + ld [hl], d + ret + +Func_7d8ac: ; 7d8ac (1f:58ac) + ld a, c + ld hl, Unknown_7db8b + add l + jr nc, .noCarry + inc h +.noCarry + ld l, a + ld a, [hl] + add b + ld l, a + ld h, $ff + ret + +Func_7d8bb: ; 7d8bb (1f:58bb) + ld h, $0 +.loop + srl a + jr nc, .noCarry + add hl, de +.noCarry + sla e + rl d + and a + jr z, .done + jr .loop +.done + ret + +Func_7d8cc: ; 7d8cc (1f:58cc) + ld h, $0 + ld l, a + add hl, hl + ld d, h + ld e, l + ld hl, Unknown_7dba3 + add hl, de + ld e, [hl] + inc hl + ld d, [hl] + ld a, b +.loop + cp $7 + jr z, .done + sra d + rr e + inc a + jr .loop +.done + ld a, $8 + add d + ld d, a + ret + +Func_7d8ea: ; 7d8ea (1f:58ea) + ld [$c001], a + cp $ff + jp z, Func_7daa8 + cp $c2 + jp z, Func_7d9c2 + jp c, Func_7d9c2 + cp $fe + jr z, .asm_7d901 + jp nc, Func_7d9c2 +.asm_7d901 + xor a + ld [$c000], a + ld [$c003], a + ld [$c0e9], a + ld [$c0e6], a + ld [$c0e7], a + ld d, $8 + ld hl, $c016 + call FillMusicRAM1f + ld hl, $c006 + call FillMusicRAM1f + ld d, $4 + ld hl, $c026 + call FillMusicRAM1f + ld hl, $c02e + call FillMusicRAM1f + ld hl, $c03e + call FillMusicRAM1f + ld hl, $c046 + call FillMusicRAM1f + ld hl, $c04e + call FillMusicRAM1f + ld hl, $c056 + call FillMusicRAM1f + ld hl, $c05e + call FillMusicRAM1f + ld hl, $c066 + call FillMusicRAM1f + ld hl, $c06e + call FillMusicRAM1f + ld hl, $c036 + call FillMusicRAM1f + ld hl, $c076 + call FillMusicRAM1f + ld hl, $c07e + call FillMusicRAM1f + ld hl, $c086 + call FillMusicRAM1f + ld hl, $c08e + call FillMusicRAM1f + ld hl, $c096 + call FillMusicRAM1f + ld hl, $c09e + call FillMusicRAM1f + ld hl, $c0a6 + call FillMusicRAM1f + ld hl, $c0ae + call FillMusicRAM1f + ld a, $1 + ld hl, $c0be + call FillMusicRAM1f + ld hl, $c0b6 + call FillMusicRAM1f + ld hl, $c0c6 + call FillMusicRAM1f + ld [$c0e8], a + ld a, $ff + ld [$c004], a + xor a + ld [$FF00+$24], a + ld a, $8 + ld [$FF00+$10], a + ld a, $0 + ld [$FF00+$25], a + xor a + ld [$FF00+$1a], a + ld a, $80 + ld [$FF00+$1a], a + ld a, $77 + ld [$FF00+$24], a + jp Func_7db03 + +Func_7d9c2: ; 7d9c2 (1f:59c2) + ld l, a + ld e, a + ld h, $0 + ld d, h + add hl, hl + add hl, de + ld de, SFX_Headers_1f + add hl, de + ld a, h + ld [$c0ec], a + ld a, l + ld [$c0ed], a + ld a, [hl] + and $c0 + rlca + rlca + ld c, a +.asm_7d9db + ld d, c + ld a, c + add a + add c + ld c, a + ld b, $0 + ld a, [$c0ec] + ld h, a + ld a, [$c0ed] + ld l, a + add hl, bc + ld c, d + ld a, [hl] + and $f + ld e, a + ld d, $0 + ld hl, $c026 + add hl, de + ld a, [hl] + and a + jr z, .asm_7da17 + ld a, e + cp $7 + jr nz, .asm_7da0e + ld a, [$c001] + cp $14 + jr nc, .asm_7da07 + ret +.asm_7da07 + ld a, [hl] + cp $14 + jr z, .asm_7da17 + jr c, .asm_7da17 +.asm_7da0e + ld a, [$c001] + cp [hl] + jr z, .asm_7da17 + jr c, .asm_7da17 + ret +.asm_7da17 + xor a + push de + ld h, d + ld l, e + add hl, hl + ld d, h + ld e, l + ld hl, $c016 + add hl, de + ld [hli], a + ld [hl], a + ld hl, $c006 + add hl, de + ld [hli], a + ld [hl], a + pop de + ld hl, $c026 + add hl, de + ld [hl], a + ld hl, $c02e + add hl, de + ld [hl], a + ld hl, $c03e + add hl, de + ld [hl], a + ld hl, $c046 + add hl, de + ld [hl], a + ld hl, $c04e + add hl, de + ld [hl], a + ld hl, $c056 + add hl, de + ld [hl], a + ld hl, $c05e + add hl, de + ld [hl], a + ld hl, $c066 + add hl, de + ld [hl], a + ld hl, $c06e + add hl, de + ld [hl], a + ld hl, $c076 + add hl, de + ld [hl], a + ld hl, $c07e + add hl, de + ld [hl], a + ld hl, $c086 + add hl, de + ld [hl], a + ld hl, $c08e + add hl, de + ld [hl], a + ld hl, $c096 + add hl, de + ld [hl], a + ld hl, $c09e + add hl, de + ld [hl], a + ld hl, $c0a6 + add hl, de + ld [hl], a + ld hl, $c0ae + add hl, de + ld [hl], a + ld hl, $c036 + add hl, de + ld [hl], a + ld a, $1 + ld hl, $c0be + add hl, de + ld [hl], a + ld hl, $c0b6 + add hl, de + ld [hl], a + ld hl, $c0c6 + add hl, de + ld [hl], a + ld a, e + cp $4 + jr nz, .asm_7da9f + ld a, $8 + ld [$FF00+$10], a +.asm_7da9f + ld a, c + and a + jp z, Func_7db03 + dec c + jp .asm_7d9db + +Func_7daa8: ; 7daa8 (1f:5aa8) + ld a, $80 + ld [$FF00+$26], a + ld [$FF00+$1a], a + xor a + ld [$FF00+$25], a + ld [$FF00+$1c], a + ld a, $8 + ld [$FF00+$10], a + ld [$FF00+$12], a + ld [$FF00+$17], a + ld [$FF00+$21], a + ld a, $40 + ld [$FF00+$14], a + ld [$FF00+$19], a + ld [$FF00+$23], a + ld a, $77 + ld [$FF00+$24], a + xor a + ld [$c000], a + ld [$c003], a + ld [$c002], a + ld [$c0e9], a + ld [$c0eb], a + ld [$c0e6], a + ld [$c0e7], a + ld d, $a0 + ld hl, $c006 + call FillMusicRAM1f + ld a, $1 + ld d, $18 + ld hl, $c0b6 + call FillMusicRAM1f + ld [$c0e8], a + ld [$c0ea], a + ld a, $ff + ld [$c004], a + ret + +; fills d bytes at hl with a +FillMusicRAM1f: ; 7dafd (1f:5afd) + ld b, d +.loop + ld [hli], a + dec b + jr nz, .loop + ret + +Func_7db03: ; 7db03 (1f:5b03) + ld a, [$c001] + ld l, a + ld e, a + ld h, $0 + ld d, h + add hl, hl + add hl, de + ld de, SFX_Headers_1f + add hl, de + ld e, l + ld d, h + ld hl, $c006 + ld a, [de] ; get channel number + ld b, a + rlca + rlca + and $3 + ld c, a + ld a, b + and $f + ld b, c + inc b + inc de + ld c, $0 +.asm_7db25 + cp c + jr z, .asm_7db2d + inc c + inc hl + inc hl + jr .asm_7db25 +.asm_7db2d + push hl + push bc + push af + ld b, $0 + ld c, a + ld hl, $c026 + add hl, bc + ld a, [$c001] + ld [hl], a + pop af + cp $3 + jr c, .asm_7db46 + ld hl, $c02e + add hl, bc + set 2, [hl] +.asm_7db46 + pop bc + pop hl + ld a, [de] ; get channel pointer + ld [hli], a + inc de + ld a, [de] + ld [hli], a + inc de + inc c + dec b + ld a, b + and a + ld a, [de] + inc de + jr nz, .asm_7db25 + ld a, [$c001] + cp $14 + jr nc, .asm_7db5f + jr .asm_7db89 +.asm_7db5f + ld a, [$c001] + cp $86 + jr z, .asm_7db89 + jr c, .asm_7db6a + jr .asm_7db89 +.asm_7db6a + ld hl, $c02a + ld [hli], a + ld [hli], a + ld [hli], a + ld [hl], a + ld hl, $c012 ; sfx noise channel pointer + ld de, Noise1f_endchannel + ld [hl], e + inc hl + ld [hl], d ; overwrite pointer to point to endchannel + ld a, [$c005] + and a + jr nz, .asm_7db89 + ld a, [$FF00+$24] + ld [$c005], a + ld a, $77 + ld [$FF00+$24], a +.asm_7db89 + ret + +Noise1f_endchannel: ; 7db8a (1f:5b8a) + endchannel + +Unknown_7db8b: ; 7db8b (1f:5b8b) + db $10, $15, $1A, $1F ; channels 0-3 + db $10, $15, $1A, $1F ; channels 4-7 + +Unknown_7db93: ; 7db93 (1f:5b93) + db $EE, $DD, $BB, $77 ; channels 0-3 + db $EE, $DD, $BB, $77 ; channels 4-7 + +Unknown_7db9b: ; 7db9b (1f:5b9b) + db $11, $22, $44, $88 ; channels 0-3 + db $11, $22, $44, $88 ; channels 4-7 + +Unknown_7dba3: ; 7dba3 (1f:5ba3) + dw $F82C + dw $F89D + dw $F907 + dw $F96B + dw $F9CA + dw $FA23 + dw $FA77 + dw $FAC7 + dw $FB12 + dw $FB58 + dw $FB9B + dw $FBDA + + diff --git a/audio_blue.asm b/audio_blue.asm new file mode 100644 index 00000000..53e37a2d --- /dev/null +++ b/audio_blue.asm @@ -0,0 +1,2 @@ +INCLUDE "blue.asm" +INCLUDE "audio.asm" diff --git a/audio_red.asm b/audio_red.asm new file mode 100644 index 00000000..6c90a7c1 --- /dev/null +++ b/audio_red.asm @@ -0,0 +1,2 @@ +INCLUDE "red.asm" +INCLUDE "audio.asm" diff --git a/blue.asm b/blue.asm new file mode 100644 index 00000000..abbd4b0f --- /dev/null +++ b/blue.asm @@ -0,0 +1,2 @@ +_BLUE EQU 1 +_RED EQU 0 diff --git a/constants.asm b/constants.asm index 0f726b6a..2d5b3d9b 100644 --- a/constants.asm +++ b/constants.asm @@ -26,3 +26,4 @@ INCLUDE "constants/map_constants.asm" INCLUDE "constants/map_dimensions.asm" INCLUDE "constants/connection_constants.asm" INCLUDE "constants/credits_constants.asm" +INCLUDE "constants/music_constants.asm" diff --git a/constants/music_constants.asm b/constants/music_constants.asm new file mode 100644 index 00000000..3d2ac3f8 --- /dev/null +++ b/constants/music_constants.asm @@ -0,0 +1,54 @@ +; Song ids are calculated by address to save space. + +music_const: MACRO +\1 EQUS "((\2 - $4000) / 3)" +ENDM + + music_const MUSIC_PALLET_TOWN, Music_PalletTown + music_const MUSIC_POKECENTER, Music_Pokecenter + music_const MUSIC_GYM, Music_Gym + music_const MUSIC_CITIES1, Music_Cities1 + music_const MUSIC_CITIES2, Music_Cities2 + music_const MUSIC_CELADON, Music_Celadon + music_const MUSIC_CINNABAR, Music_Cinnabar + music_const MUSIC_VERMILION, Music_Vermilion + music_const MUSIC_LAVENDER, Music_Lavender + music_const MUSIC_SS_ANNE, Music_SSAnne + music_const MUSIC_MEET_PROF_OAK, Music_MeetProfOak + music_const MUSIC_MEET_RIVAL, Music_MeetRival + music_const MUSIC_MUSEUM_GUY, Music_MuseumGuy + music_const MUSIC_SAFARI_ZONE, Music_SafariZone + music_const MUSIC_PKMN_HEALED, Music_PkmnHealed + music_const MUSIC_ROUTES1, Music_Routes1 + music_const MUSIC_ROUTES2, Music_Routes2 + music_const MUSIC_ROUTES3, Music_Routes3 + music_const MUSIC_ROUTES4, Music_Routes4 + music_const MUSIC_INDIGO_PLATEAU, Music_IndigoPlateau + + music_const MUSIC_GYM_LEADER_BATTLE, Music_GymLeaderBattle + music_const MUSIC_TRAINER_BATTLE, Music_TrainerBattle + music_const MUSIC_WILD_BATTLE, Music_WildBattle + music_const MUSIC_FINAL_BATTLE, Music_FinalBattle + music_const MUSIC_DEFEATED_TRAINER, Music_DefeatedTrainer + music_const MUSIC_DEFEATED_WILD_MON, Music_DefeatedWildMon + music_const MUSIC_DEFEATED_GYM_LEADER, Music_DefeatedGymLeader + + music_const MUSIC_TITLE_SCREEN, Music_TitleScreen + music_const MUSIC_CREDITS, Music_Credits + music_const MUSIC_HALL_OF_FAME, Music_HallOfFame + music_const MUSIC_OAKS_LAB, Music_OaksLab + music_const MUSIC_JIGGLYPUFF_SONG, Music_JigglypuffSong + music_const MUSIC_BIKE_RIDING, Music_BikeRiding + music_const MUSIC_SURFING, Music_Surfing + music_const MUSIC_GAME_CORNER, Music_GameCorner + music_const MUSIC_INTRO_BATTLE, Music_IntroBattle + music_const MUSIC_DUNGEON1, Music_Dungeon1 + music_const MUSIC_DUNGEON2, Music_Dungeon2 + music_const MUSIC_DUNGEON3, Music_Dungeon3 + music_const MUSIC_CINNABAR_MANSION, Music_CinnabarMansion + music_const MUSIC_POKEMON_TOWER, Music_PokemonTower + music_const MUSIC_SILPH_CO, Music_SilphCo + music_const MUSIC_MEET_EVIL_TRAINER, Music_MeetEvilTrainer + music_const MUSIC_MEET_FEMALE_TRAINER, Music_MeetFemaleTrainer + music_const MUSIC_MEET_MALE_TRAINER, Music_MeetMaleTrainer + diff --git a/extras b/extras -Subproject d8f4e687ebc49d4b135f0d8b7f10a643114a0d8 +Subproject 89ca24a93475cdb7fdbdc046cb3ac7a83fe9d9e @@ -5798,10 +5798,10 @@ asm_2324: ; 2324 (0:2324) jr z, .asm_2343 cp $2 jr z, .asm_2332 - ld a, (Music_BikeRiding - $4000) / 3 + ld a, MUSIC_BIKE_RIDING jr .asm_2334 .asm_2332 - ld a, (Music_Surfing - $4000) / 3 + ld a, MUSIC_SURFING .asm_2334 ld b, a ld a, d @@ -8440,7 +8440,7 @@ PlayTrainerMusic: ; 33e8 (0:33e8) jr z, .noEvilTrainer cp b jr nz, .evilTrainerListLoop - ld a, (Music_MeetEvilTrainer - $4000) / 3 + ld a, MUSIC_MEET_EVIL_TRAINER jr .PlaySound .noEvilTrainer ld hl, FemaleTrainerList @@ -8450,10 +8450,10 @@ PlayTrainerMusic: ; 33e8 (0:33e8) jr z, .maleTrainer cp b jr nz, .femaleTrainerListLoop - ld a, (Music_MeetFemaleTrainer - $4000) / 3 + ld a, MUSIC_MEET_FEMALE_TRAINER jr .PlaySound .maleTrainer - ld a, (Music_MeetMaleTrainer - $4000) / 3 + ld a, MUSIC_MEET_MALE_TRAINER .PlaySound ld [$c0ee], a jp PlaySound @@ -10623,7 +10623,7 @@ PointerTable_3f22: ; 3f22 (0:3f22) dw ElevatorText ; id = 41 dw PokemonStuffText ; id = 42 -SECTION "bank1",ROMX,Bank[$1] +SECTION "bank1",ROMX,BANK[$1] SpriteFacingAndAnimationTable: ; 4000 (1:4000) dw SpriteFacingDownAndStanding, SpriteOAMParameters ; facing down, walk animation frame 0 @@ -11012,7 +11012,7 @@ ENDC call PrintGameVersionOnTitleScreen call Delay3 call WaitForSoundToFinish - ld a, (Music_TitleScreen - $4000) / 3 + ld a, MUSIC_TITLE_SCREEN ld [$c0ee], a call PlaySound xor a @@ -13211,7 +13211,7 @@ Func_5345: ; 5345 jp Func_577d .asm_5506 ld c, BANK(Music_GameCorner) - ld a, (Music_GameCorner - $4000) / 3 + ld a, MUSIC_GAME_CORNER call PlayMusic jr Func_551c @@ -13851,7 +13851,7 @@ Func_5a5f: ; 5a5f (1:5a5f) ld [wMusicHeaderPointer], a ld a, BANK(Music_Celadon) ld [$c0f0], a - ld a, (Music_Celadon - $4000) / 3 + ld a, MUSIC_CELADON ld [$c0ee], a jp PlaySound @@ -14667,7 +14667,7 @@ OakSpeech: ; 6115 (1:6115) call PlaySound ; stop music ld a, BANK(Func_9876) ld c,a - ld a, (Music_Routes2 - $4000) / 3 ; song # + ld a, MUSIC_ROUTES2 ; song # call PlayMusic ; plays music call ClearScreen call LoadTextBoxTilePatterns @@ -18321,1927 +18321,6 @@ Func_7c18: ; 7c18 (1:7c18) ld [$cc3c], a ret -SECTION "bank2",ROMX,Bank[$2] - -INCLUDE "music/headers/sfxheaders02.asm" -INCLUDE "music/headers/musicheaders02.asm" - -INCLUDE "music/sfx/sfx_02_01.asm" -INCLUDE "music/sfx/sfx_02_02.asm" -INCLUDE "music/sfx/sfx_02_03.asm" -INCLUDE "music/sfx/sfx_02_04.asm" -INCLUDE "music/sfx/sfx_02_05.asm" -INCLUDE "music/sfx/sfx_02_06.asm" -INCLUDE "music/sfx/sfx_02_07.asm" -INCLUDE "music/sfx/sfx_02_08.asm" -INCLUDE "music/sfx/sfx_02_09.asm" -INCLUDE "music/sfx/sfx_02_0a.asm" -INCLUDE "music/sfx/sfx_02_0b.asm" -INCLUDE "music/sfx/sfx_02_0c.asm" -INCLUDE "music/sfx/sfx_02_0d.asm" -INCLUDE "music/sfx/sfx_02_0e.asm" -INCLUDE "music/sfx/sfx_02_0f.asm" -INCLUDE "music/sfx/sfx_02_10.asm" -INCLUDE "music/sfx/sfx_02_11.asm" -INCLUDE "music/sfx/sfx_02_12.asm" -INCLUDE "music/sfx/sfx_02_13.asm" - -Music2_Channel3DutyPointers: ; 0x8361 - dw Music2_Channel3Duty0 - dw Music2_Channel3Duty1 - dw Music2_Channel3Duty2 - dw Music2_Channel3Duty3 - dw Music2_Channel3Duty4 - dw Music2_Channel3Duty5 ; used in the Lavender Town theme - dw SFX_02_3f_Ch1 ; unused - dw SFX_02_3f_Ch1 ; unused - dw SFX_02_3f_Ch1 ; unused - -; these are the definitions for the channel 3 instruments -; each instrument definition is made up of 32 points (nibbles) that form -; the graph of the wave -; the current instrument is copied to $FF30 -Music2_Channel3Duty0: ; 0x8373 - db $02,$46,$8A,$CE,$FF,$FE,$ED,$DC,$CB,$A9,$87,$65,$44,$33,$22,$11 - -Music2_Channel3Duty1: ; 0x8383 - db $02,$46,$8A,$CE,$EF,$FF,$FE,$EE,$DD,$CB,$A9,$87,$65,$43,$22,$11 - -Music2_Channel3Duty2: ; 0x8393 - db $13,$69,$BD,$EE,$EE,$FF,$FF,$ED,$DE,$FF,$FF,$EE,$EE,$DB,$96,$31 - -Music2_Channel3Duty3: ; 0x83a3 - db $02,$46,$8A,$CD,$EF,$FE,$DE,$FF,$EE,$DC,$BA,$98,$76,$54,$32,$10 - -Music2_Channel3Duty4: ; 0x83b3 - db $01,$23,$45,$67,$8A,$CD,$EE,$F7,$7F,$EE,$DC,$A8,$76,$54,$32,$10 - -; duty 5 reads from sfx data -Music2_Channel3Duty5: ; 0x83c3 -INCLUDE "music/sfx/sfx_02_3f.asm" -INCLUDE "music/sfx/sfx_02_5e.asm" -INCLUDE "music/sfx/sfx_02_56.asm" -INCLUDE "music/sfx/sfx_02_57.asm" -INCLUDE "music/sfx/sfx_02_58.asm" -INCLUDE "music/sfx/sfx_02_3c.asm" -INCLUDE "music/sfx/sfx_02_59.asm" -INCLUDE "music/sfx/sfx_02_5a.asm" -INCLUDE "music/sfx/sfx_02_5b.asm" -INCLUDE "music/sfx/sfx_02_5c.asm" -INCLUDE "music/sfx/sfx_02_40.asm" -INCLUDE "music/sfx/sfx_02_5d.asm" -INCLUDE "music/sfx/sfx_02_3d.asm" -INCLUDE "music/sfx/sfx_02_43.asm" -INCLUDE "music/sfx/sfx_02_3e.asm" -INCLUDE "music/sfx/sfx_02_44.asm" -INCLUDE "music/sfx/sfx_02_45.asm" -INCLUDE "music/sfx/sfx_02_46.asm" -INCLUDE "music/sfx/sfx_02_47.asm" -INCLUDE "music/sfx/sfx_02_48.asm" -INCLUDE "music/sfx/sfx_02_49.asm" -INCLUDE "music/sfx/sfx_02_4a.asm" -INCLUDE "music/sfx/sfx_02_4b.asm" -INCLUDE "music/sfx/sfx_02_4c.asm" -INCLUDE "music/sfx/sfx_02_4d.asm" -INCLUDE "music/sfx/sfx_02_4e.asm" -INCLUDE "music/sfx/sfx_02_4f.asm" -INCLUDE "music/sfx/sfx_02_50.asm" -INCLUDE "music/sfx/sfx_02_51.asm" -INCLUDE "music/sfx/sfx_02_52.asm" -INCLUDE "music/sfx/sfx_02_53.asm" -INCLUDE "music/sfx/sfx_02_54.asm" -INCLUDE "music/sfx/sfx_02_55.asm" -INCLUDE "music/sfx/sfx_02_5f.asm" -INCLUDE "music/sfx/sfx_02_unused.asm" -INCLUDE "music/sfx/sfx_02_1d.asm" -INCLUDE "music/sfx/sfx_02_37.asm" -INCLUDE "music/sfx/sfx_02_38.asm" -INCLUDE "music/sfx/sfx_02_25.asm" -INCLUDE "music/sfx/sfx_02_39.asm" -INCLUDE "music/sfx/sfx_02_17.asm" -INCLUDE "music/sfx/sfx_02_23.asm" -INCLUDE "music/sfx/sfx_02_24.asm" -INCLUDE "music/sfx/sfx_02_14.asm" -INCLUDE "music/sfx/sfx_02_22.asm" -INCLUDE "music/sfx/sfx_02_1a.asm" -INCLUDE "music/sfx/sfx_02_1b.asm" -INCLUDE "music/sfx/sfx_02_19.asm" -INCLUDE "music/sfx/sfx_02_1f.asm" -INCLUDE "music/sfx/sfx_02_20.asm" -INCLUDE "music/sfx/sfx_02_16.asm" -INCLUDE "music/sfx/sfx_02_21.asm" -INCLUDE "music/sfx/sfx_02_15.asm" -INCLUDE "music/sfx/sfx_02_1e.asm" -INCLUDE "music/sfx/sfx_02_1c.asm" -INCLUDE "music/sfx/sfx_02_18.asm" -INCLUDE "music/sfx/sfx_02_2d.asm" -INCLUDE "music/sfx/sfx_02_2a.asm" -INCLUDE "music/sfx/sfx_02_2f.asm" -INCLUDE "music/sfx/sfx_02_26.asm" -INCLUDE "music/sfx/sfx_02_27.asm" -INCLUDE "music/sfx/sfx_02_28.asm" -INCLUDE "music/sfx/sfx_02_32.asm" -INCLUDE "music/sfx/sfx_02_29.asm" -INCLUDE "music/sfx/sfx_02_2b.asm" -INCLUDE "music/sfx/sfx_02_30.asm" -INCLUDE "music/sfx/sfx_02_2e.asm" -INCLUDE "music/sfx/sfx_02_31.asm" -INCLUDE "music/sfx/sfx_02_2c.asm" -INCLUDE "music/sfx/sfx_02_33.asm" -INCLUDE "music/sfx/sfx_02_34.asm" -INCLUDE "music/sfx/sfx_02_35.asm" -INCLUDE "music/sfx/sfx_02_36.asm" - -PlayBattleMusic: ; 0x90c6 - xor a - ld [wMusicHeaderPointer], a - ld [$d083], a - dec a - ld [$c0ee], a - call PlaySound ; stop music - call DelayFrame - ld c, BANK(Music_GymLeaderBattle) - ld a, [W_GYMLEADERNO] - and a - jr z, .notGymLeaderBattle - ld a, (Music_GymLeaderBattle - $4000) / 3 - jr .playSong -.notGymLeaderBattle - ld a, [W_CUROPPONENT] - cp $c8 - jr c, .wildBattle - cp SONY3 + $c8 - jr z, .finalBattle - cp LANCE + $c8 - jr nz, .normalTrainerBattle - ld a, (Music_GymLeaderBattle - $4000) / 3 ; lance also plays gym leader theme - jr .playSong -.normalTrainerBattle - ld a, (Music_TrainerBattle - $4000) / 3 - jr .playSong -.finalBattle - ld a, (Music_FinalBattle - $4000) / 3 - jr .playSong -.wildBattle - ld a, (Music_WildBattle - $4000) / 3 -.playSong - jp PlayMusic - -Func_9103: ; 0x9103 - ld c, CH0 -.loop - ld b, $0 - ld hl, $c026 - add hl, bc - ld a, [hl] - and a - jr z, .nextChannel - ld a, c - cp CH4 - jr nc, .asm_912e ; if sfx channel - ld a, [$c002] - and a - jr z, .asm_912e - bit 7, a - jr nz, .nextChannel - set 7, a - ld [$c002], a - xor a - ld [$ff00+$25], a - ld [$ff00+$1a], a - ld a, $80 - ld [$ff00+$1a], a - jr .nextChannel -.asm_912e - call Music2_ApplyMusicAffects -.nextChannel - ld a, c - inc c ; inc channel number - cp CH7 - jr nz, .loop - ret - -; this routine checks flags for music effects currently applied -; to the channel and calls certain functions based on flags. -; known flags for $c02e: -; 1: call has been used -; 3: a toggle used only by this routine for vibrato -; 4: pitchbend flag -; 6: dutycycle flag -Music2_ApplyMusicAffects: ; 0x9138 - ld b, $0 - ld hl, $c0b6 ; delay unitl next note - add hl, bc - ld a, [hl] - cp $1 ; if the delay is 1, play next note - jp z, Music2_PlayNextNote - dec a ; otherwise, decrease the delay timer - ld [hl], a - ld a, c - cp CH4 - jr nc, .startChecks ; if a sfx channel - ld hl, $c02a - add hl, bc - ld a, [hl] - and a - jr z, .startChecks - ret -.startChecks - ld hl, $c02e - add hl, bc - bit 6, [hl] ; dutycycle - jr z, .checkForExecuteMusic - call Music2_ApplyDutyCycle -.checkForExecuteMusic - ld b, $0 - ld hl, $c036 - add hl, bc - bit 0, [hl] - jr nz, .checkForPitchBend - ld hl, $c02e - add hl, bc - bit 2, [hl] - jr nz, .disablePitchBendVibrato -.checkForPitchBend - ld hl, $c02e - add hl, bc - bit 4, [hl] ; pitchbend - jr z, .checkVibratoDelay - jp Music2_ApplyPitchBend -.checkVibratoDelay - ld hl, $c04e ; vibrato delay - add hl, bc - ld a, [hl] - and a ; check if delay is over - jr z, .checkForVibrato - dec [hl] ; otherwise, dec delay -.disablePitchBendVibrato - ret -.checkForVibrato - ld hl, $c056 ; vibrato rate - add hl, bc - ld a, [hl] - and a - jr nz, .vibrato - ret ; no vibrato -.vibrato - ld d, a - ld hl, $c05e - add hl, bc - ld a, [hl] - and $f - and a - jr z, .vibratoAlreadyDone - dec [hl] ; apply vibrato pitch change - ret -.vibratoAlreadyDone - ld a, [hl] - swap [hl] - or [hl] - ld [hl], a ; reset the vibrato value and start again - ld hl, $c066 - add hl, bc - ld e, [hl] ; get note pitch - ld hl, $c02e - add hl, bc - bit 3, [hl] ; this is the only code that sets/resets bit three so - jr z, .unset ; it continuously alternates which path it takes - res 3, [hl] - ld a, d - and $f - ld d, a - ld a, e - sub d - jr nc, .noCarry - ld a, $0 -.noCarry - jr .done -.unset - set 3, [hl] - ld a, d - and $f0 - swap a - add e - jr nc, .done - ld a, $ff -.done - ld d, a - ld b, $3 - call Func_9838 - ld [hl], d - ret - -; this routine executes all music commands that take up no time, -; like tempo changes, duty changes etc. and doesn't return -; until the first note is reached -Music2_PlayNextNote ; 0x91d0 - ld hl, $c06e - add hl, bc - ld a, [hl] - ld hl, $c04e - add hl, bc - ld [hl], a - ld hl, $c02e - add hl, bc - res 4, [hl] - res 5, [hl] - call Music2_endchannel - ret - -Music2_endchannel: ; 0x91e6 - call Music2_GetNextMusicByte - ld d, a - cp $ff ; is this command an endchannel? - jp nz, Music2_callchannel ; no - ld b, $0 ; yes - ld hl, $c02e - add hl, bc - bit 1, [hl] - jr nz, .returnFromCall - ld a, c - cp CH3 - jr nc, .noiseOrSfxChannel - jr .asm_923f -.noiseOrSfxChannel - res 2, [hl] - ld hl, $c036 - add hl, bc - res 0, [hl] - cp CH6 - jr nz, .notSfxChannel3 - ld a, $0 - ld [$ff00+$1a], a - ld a, $80 - ld [$ff00+$1a], a -.notSfxChannel3 - jr nz, .asm_9222 - ld a, [$c003] - and a - jr z, .asm_9222 - xor a - ld [$c003], a - jr .asm_923f -.asm_9222 - jr .asm_9248 -.returnFromCall - res 1, [hl] - ld d, $0 - ld a, c - add a - ld e, a - ld hl, $c006 - add hl, de - push hl ; store current channel address - ld hl, $c016 - add hl, de - ld e, l - ld d, h - pop hl - ld a, [de] - ld [hli], a - inc de - ld a, [de] - ld [hl], a ; loads channel address to return to - jp Music2_endchannel -.asm_923f - ld hl, Unknown_9b1f - add hl, bc - ld a, [$ff00+$25] - and [hl] - ld [$ff00+$25], a -.asm_9248 - ld a, [$c02a] - cp $14 - jr nc, .asm_9251 - jr .asm_926e -.asm_9251 - ld a, [$c02a] - cp $86 - jr z, .asm_926e - jr c, .asm_925c - jr .asm_926e -.asm_925c - ld a, c - cp CH4 - jr z, .asm_9265 - call Func_96c7 - ret c -.asm_9265 - ld a, [$c005] - ld [$ff00+$24], a - xor a - ld [$c005], a -.asm_926e - ld hl, $c026 - add hl, bc - ld [hl], b - ret - -Music2_callchannel: ; 0x9274 - cp $fd ; is this command a callchannel? - jp nz, Music2_loopchannel ; no - call Music2_GetNextMusicByte ; yes - push af - call Music2_GetNextMusicByte - ld d, a - pop af - ld e, a - push de ; store pointer - ld d, $0 - ld a, c - add a - ld e, a - ld hl, $c006 - add hl, de - push hl - ld hl, $c016 - add hl, de - ld e, l - ld d, h - pop hl - ld a, [hli] - ld [de], a - inc de - ld a, [hld] - ld [de], a ; copy current channel address - pop de - ld [hl], e - inc hl - ld [hl], d ; overwrite current address with pointer - ld b, $0 - ld hl, $c02e - add hl, bc - set 1, [hl] ; set the call flag - jp Music2_endchannel - -Music2_loopchannel: ; 0x92a9 - cp $fe ; is this command a loopchannel? - jp nz, Music2_notetype ; no - call Music2_GetNextMusicByte ; yes - ld e, a - and a - jr z, .infiniteLoop - ld b, $0 - ld hl, $c0be - add hl, bc - ld a, [hl] - cp e - jr nz, .loopAgain - ld a, $1 ; if no more loops to make, - ld [hl], a - call Music2_GetNextMusicByte ; skip pointer - call Music2_GetNextMusicByte - jp Music2_endchannel -.loopAgain ; inc loop count - inc a - ld [hl], a - ; fall through -.infiniteLoop ; overwrite current address with pointer - call Music2_GetNextMusicByte - push af - call Music2_GetNextMusicByte - ld b, a - ld d, $0 - ld a, c - add a - ld e, a - ld hl, $c006 - add hl, de - pop af - ld [hli], a - ld [hl], b - jp Music2_endchannel - -Music2_notetype: ; 0x92e4 - and $f0 - cp $d0 ; is this command a notetype? - jp nz, Music2_togglecall ; no - ld a, d ; yes - and $f - ld b, $0 - ld hl, $c0c6 - add hl, bc - ld [hl], a ; store low nibble as speed - ld a, c - cp CH3 - jr z, .noiseChannel ; noise channel has 0 params - call Music2_GetNextMusicByte - ld d, a - ld a, c - cp CH2 - jr z, .musicChannel3 - cp CH6 - jr nz, .notChannel3 - ld hl, $c0e7 - jr .sfxChannel3 -.musicChannel3 - ld hl, $c0e6 -.sfxChannel3 - ld a, d - and $f - ld [hl], a ; store low nibble of param as duty - ld a, d - and $30 - sla a - ld d, a - ; fall through - - ; if channel 3, store high nibble as volume - ; else, store volume (high nibble) and fade (low nibble) -.notChannel3 - ld b, $0 - ld hl, $c0de - add hl, bc - ld [hl], d -.noiseChannel - jp Music2_endchannel - -Music2_togglecall: ; 0x9323 - ld a, d - cp $e8 ; is this command an togglecall? - jr nz, Music2_vibrato ; no - ld b, $0 ; yes - ld hl, $c02e - add hl, bc - ld a, [hl] - xor $1 - ld [hl], a ; flip bit 0 of $c02e (toggle returning from call) - jp Music2_endchannel - -Music2_vibrato: ; 0x9335 - cp $ea ; is this command a vibrato? - jr nz, Music2_pitchbend ; no - call Music2_GetNextMusicByte ; yes - ld b, $0 - ld hl, $c04e - add hl, bc - ld [hl], a ; store delay - ld hl, $c06e - add hl, bc - ld [hl], a ; store delay - call Music2_GetNextMusicByte - ld d, a - and $f0 - swap a - ld b, $0 - ld hl, $c056 - add hl, bc - srl a - ld e, a - adc b - swap a - or e - ld [hl], a ; store rate as both high and low nibbles - ld a, d - and $f - ld d, a - ld hl, $c05e - add hl, bc - swap a - or d - ld [hl], a ; store depth as both high and low nibbles - jp Music2_endchannel - -Music2_pitchbend: ; 0x936d - cp $eb ; is this command a pitchbend? - jr nz, Music2_duty ; no - call Music2_GetNextMusicByte ; yes - ld b, $0 - ld hl, $c076 - add hl, bc - ld [hl], a ; store first param - call Music2_GetNextMusicByte - ld d, a - and $f0 - swap a - ld b, a - ld a, d - and $f - call Func_9858 - ld b, $0 - ld hl, $c0a6 - add hl, bc - ld [hl], d ; store unknown part of second param - ld hl, $c0ae - add hl, bc - ld [hl], e ; store unknown part of second param - ld b, $0 - ld hl, $c02e - add hl, bc - set 4, [hl] ; set pitchbend flag - call Music2_GetNextMusicByte - ld d, a - jp Music2_notelength - -Music2_duty: ; 0x93a5 - cp $ec ; is this command a duty? - jr nz, Music2_tempo ; no - call Music2_GetNextMusicByte ; yes - rrca - rrca - and $c0 - ld b, $0 - ld hl, $c03e - add hl, bc - ld [hl], a ; store duty - jp Music2_endchannel - -Music2_tempo: ; 0x93ba - cp $ed ; is this command a tempo? - jr nz, Music2_unknownmusic0xee ; no - ld a, c ; yes - cp CH4 - jr nc, .sfxChannel - call Music2_GetNextMusicByte - ld [$c0e8], a ; store first param - call Music2_GetNextMusicByte - ld [$c0e9], a ; store second param - xor a - ld [$c0ce], a ; clear RAM - ld [$c0cf], a - ld [$c0d0], a - ld [$c0d1], a - jr .musicChannelDone -.sfxChannel - call Music2_GetNextMusicByte - ld [$c0ea], a ; store first param - call Music2_GetNextMusicByte - ld [$c0eb], a ; store second param - xor a - ld [$c0d2], a ; clear RAM - ld [$c0d3], a - ld [$c0d4], a - ld [$c0d5], a -.musicChannelDone - jp Music2_endchannel - -Music2_unknownmusic0xee: ; 0x93fa - cp $ee ; is this command an unknownmusic0xee? - jr nz, Music2_unknownmusic0xef ; no - call Music2_GetNextMusicByte ; yes - ld [$c004], a ; store first param - jp Music2_endchannel - -; this appears to never be used -Music2_unknownmusic0xef ; 0x9407 - cp $ef ; is this command an unknownmusic0xef? - jr nz, Music2_dutycycle ; no - call Music2_GetNextMusicByte ; yes - push bc - call Func_9876 - pop bc - ld a, [$c003] - and a - jr nz, .skip - ld a, [$c02d] - ld [$c003], a - xor a - ld [$c02d], a -.skip - jp Music2_endchannel - -Music2_dutycycle: ; 0x9426 - cp $fc ; is this command a dutycycle? - jr nz, Music2_stereopanning ; no - call Music2_GetNextMusicByte ; yes - ld b, $0 - ld hl, $c046 - add hl, bc - ld [hl], a ; store full cycle - and $c0 - ld hl, $c03e - add hl, bc - ld [hl], a ; store first duty - ld hl, $c02e - add hl, bc - set 6, [hl] ; set dutycycle flag - jp Music2_endchannel - -Music2_stereopanning: ; 0x9444 - cp $f0 ; is this command a stereopanning? - jr nz, Music2_executemusic ; no - call Music2_GetNextMusicByte ; yes - ld [$ff00+$24], a ; store stereopanning - jp Music2_endchannel - -Music2_executemusic: ; 0x9450 - cp $f8 ; is this command an executemusic? - jr nz, Music2_octave ; no - ld b, $0 ; yes - ld hl, $c036 - add hl, bc - set 0, [hl] - jp Music2_endchannel - -Music2_octave: ; 0x945f - and $f0 - cp $e0 ; is this command an octave? - jr nz, Music2_unknownsfx0x20 ; no - ld hl, $c0d6 ; yes - ld b, $0 - add hl, bc - ld a, d - and $f - ld [hl], a ; store low nibble as octave - jp Music2_endchannel - -Music2_unknownsfx0x20: ; 0x9472 - cp $20 ; is this command an unknownsfx0x20? - jr nz, Music2_unknownsfx0x10 ; no - ld a, c - cp CH3 ; is this a noise or sfx channel? - jr c, Music2_unknownsfx0x10 ; no - ld b, $0 - ld hl, $c036 - add hl, bc - bit 0, [hl] - jr nz, Music2_unknownsfx0x10 ; no - call Music2_notelength ; yes - ld d, a - ld b, $0 - ld hl, $c03e - add hl, bc - ld a, [hl] - or d - ld d, a - ld b, $1 - call Func_9838 - ld [hl], d - call Music2_GetNextMusicByte - ld d, a - ld b, $2 - call Func_9838 - ld [hl], d - call Music2_GetNextMusicByte - ld e, a - ld a, c - cp CH7 - ld a, $0 - jr z, .sfxNoiseChannel ; only two params for noise channel - push de - call Music2_GetNextMusicByte - pop de -.sfxNoiseChannel - ld d, a - push de - call Func_9629 - call Func_95f8 - pop de - call Func_964b - ret - -Music2_unknownsfx0x10: - ld a, c - cp CH4 - jr c, Music2_note ; if not a sfx - ld a, d - cp $10 ; is this command a unknownsfx0x10? - jr nz, Music2_note ; no - ld b, $0 - ld hl, $c036 - add hl, bc - bit 0, [hl] - jr nz, Music2_note ; no - call Music2_GetNextMusicByte ; yes - ld [$ff00+$10], a - jp Music2_endchannel - -Music2_note: - ld a, c - cp CH3 - jr nz, Music2_notelength ; if not noise channel - ld a, d - and $f0 - cp $b0 ; is this command a dnote? - jr z, Music2_dnote ; yes - jr nc, Music2_notelength ; no - swap a - ld b, a - ld a, d - and $f - ld d, a - ld a, b - push de - push bc - jr asm_94fd - -Music2_dnote: - ld a, d - and $f - push af - push bc - call Music2_GetNextMusicByte ; get dnote instrument -asm_94fd - ld d, a - ld a, [$c003] - and a - jr nz, .asm_9508 - ld a, d - call Func_9876 -.asm_9508 - pop bc - pop de - -Music2_notelength: ; 0x950a - ld a, d - push af - and $f - inc a - ld b, $0 - ld e, a ; store note length (in 16ths) - ld d, b - ld hl, $c0c6 - add hl, bc - ld a, [hl] - ld l, b - call Func_9847 - ld a, c - cp CH4 - jr nc, .sfxChannel - ld a, [$c0e8] - ld d, a - ld a, [$c0e9] - ld e, a - jr .skip -.sfxChannel - ld d, $1 - ld e, $0 - cp CH7 - jr z, .skip ; if noise channel - call Func_9693 - ld a, [$c0ea] - ld d, a - ld a, [$c0eb] - ld e, a -.skip - ld a, l - ld b, $0 - ld hl, $c0ce - add hl, bc - ld l, [hl] - call Func_9847 - ld e, l - ld d, h - ld hl, $c0ce - add hl, bc - ld [hl], e - ld a, d - ld hl, $c0b6 - add hl, bc - ld [hl], a - ld hl, $c036 - add hl, bc - bit 0, [hl] - jr nz, Music2_notepitch - ld hl, $c02e - add hl, bc - bit 2, [hl] - jr z, Music2_notepitch - pop hl - ret - -Music2_notepitch: ; 0x9568 - pop af - and $f0 - cp $c0 ; compare to rest - jr nz, .notRest - ld a, c - cp CH4 - jr nc, .sfxChannel - ld hl, $c02a - add hl, bc - ld a, [hl] - and a - jr nz, .done - ; fall through -.sfxChannel - ld a, c - cp CH2 - jr z, .musicChannel3 - cp CH6 - jr nz, .notSfxChannel3 -.musicChannel3 - ld b, $0 - ld hl, Unknown_9b1f - add hl, bc - ld a, [$ff00+$25] - and [hl] - ld [$ff00+$25], a - jr .done -.notSfxChannel3 - ld b, $2 - call Func_9838 - ld a, $8 - ld [hli], a - inc hl - ld a, $80 - ld [hl], a -.done - ret -.notRest - swap a - ld b, $0 - ld hl, $c0d6 - add hl, bc - ld b, [hl] - call Func_9858 - ld b, $0 - ld hl, $c02e - add hl, bc - bit 4, [hl] - jr z, .asm_95b8 - call Func_978f -.asm_95b8 - push de - ld a, c - cp CH4 - jr nc, .skip ; if sfx channel - ld hl, $c02a - ld d, $0 - ld e, a - add hl, de - ld a, [hl] - and a - jr nz, .asm_95cb - jr .skip -.asm_95cb - pop de - ret -.skip - ld b, $0 - ld hl, $c0de - add hl, bc - ld d, [hl] - ld b, $2 - call Func_9838 - ld [hl], d - call Func_9629 - call Func_95f8 - pop de - ld b, $0 - ld hl, $c02e - add hl, bc - bit 0, [hl] - jr z, .asm_95ef - inc e - jr nc, .asm_95ef - inc d -.asm_95ef - ld hl, $c066 - add hl, bc - ld [hl], e - call Func_964b - ret - -Func_95f8: ; 0x95f8 - ld b, $0 - ld hl, Unknown_9b27 - add hl, bc - ld a, [$ff00+$25] - or [hl] - ld d, a - ld a, c - cp CH7 - jr z, .sfxNoiseChannel - cp CH4 - jr nc, .skip ; if sfx channel - ld hl, $c02a - add hl, bc - ld a, [hl] - and a - jr nz, .skip -.sfxNoiseChannel - ld a, [$c004] - ld hl, Unknown_9b27 - add hl, bc - and [hl] - ld d, a - ld a, [$ff00+$25] - ld hl, Unknown_9b1f - add hl, bc - and [hl] - or d - ld d, a -.skip - ld a, d - ld [$ff00+$25], a - ret - -Func_9629: ; 0x9629 - ld b, $0 - ld hl, $c0b6 - add hl, bc - ld d, [hl] - ld a, c - cp CH2 - jr z, .channel3 ; if music channel 3 - cp CH6 - jr z, .channel3 ; if sfx channel 3 - ld a, d - and $3f - ld d, a - ld hl, $c03e - add hl, bc - ld a, [hl] - or d - ld d, a -.channel3 - ld b, $1 - call Func_9838 - ld [hl], d - ret - -Func_964b: ; 0x964b - ld a, c - cp CH2 - jr z, .channel3 - cp CH6 - jr nz, .notSfxChannel3 - ; fall through -.channel3 - push de - ld de, $c0e6 - cp CH2 - jr z, .musicChannel3 - ld de, $c0e7 -.musicChannel3 - ld a, [de] - add a - ld d, $0 - ld e, a - ld hl, Music2_Channel3DutyPointers - add hl, de - ld e, [hl] - inc hl - ld d, [hl] - ld hl, $ff30 - ld b, $f - ld a, $0 - ld [$ff00+$1a], a -.loop - ld a, [de] - inc de - ld [hli], a - ld a, b - dec b - and a - jr nz, .loop - ld a, $80 - ld [$ff00+$1a], a - pop de -.notSfxChannel3 - ld a, d - or $80 - and $c7 - ld d, a - ld b, $3 - call Func_9838 - ld [hl], e - inc hl - ld [hl], d - call Func_96b5 - ret - -Func_9693: ; 0x9693 - call Func_96e5 - jr nc, .asm_96ab - ld d, $0 - ld a, [$c0f2] - add $80 - jr nc, .asm_96a2 - inc d -.asm_96a2 - ld [$c0eb], a - ld a, d - ld [$c0ea], a - jr .asm_96b4 -.asm_96ab - xor a - ld [$c0eb], a - ld a, $1 - ld [$c0ea], a -.asm_96b4 - ret - -Func_96b5: ; 0x96b5 - call Func_96e5 - jr nc, .asm_96c6 - ld a, [$c0f1] - add e - jr nc, .asm_96c1 - inc d -.asm_96c1 - dec hl - ld e, a - ld [hl], e - inc hl - ld [hl], d -.asm_96c6 - ret - -Func_96c7: ; 0x96c7 - call Func_96e5 - jr nc, .asm_96e2 - ld hl, $c006 - ld e, c - ld d, $0 - sla e - rl d - add hl, de - ld a, [hl] - sub $1 - ld [hl], a - inc hl - ld a, [hl] - sbc $0 - ld [hl], a - scf - ret -.asm_96e2 - scf - ccf - ret - -Func_96e5: ; 0x96e5 - ld a, [$c02a] - cp $14 - jr nc, .asm_96ee - jr .asm_96f4 -.asm_96ee - cp $86 - jr z, .asm_96f4 - jr c, .asm_96f7 -.asm_96f4 - scf - ccf - ret -.asm_96f7 - scf - ret - -Music2_ApplyPitchBend: ; 0x96f9 - ld hl, $c02e - add hl, bc - bit 5, [hl] - jp nz, .asm_9740 - ld hl, $c09e - add hl, bc - ld e, [hl] - ld hl, $c096 - add hl, bc - ld d, [hl] - ld hl, $c07e - add hl, bc - ld l, [hl] - ld h, b - add hl, de - ld d, h - ld e, l - ld hl, $c08e - add hl, bc - push hl - ld hl, $c086 - add hl, bc - ld a, [hl] - pop hl - add [hl] - ld [hl], a - ld a, $0 - adc e - ld e, a - ld a, $0 - adc d - ld d, a - ld hl, $c0a6 - add hl, bc - ld a, [hl] - cp d - jp c, .asm_9786 - jr nz, .asm_9773 - ld hl, $c0ae - add hl, bc - ld a, [hl] - cp e - jp c, .asm_9786 - jr .asm_9773 -.asm_9740 - ld hl, $c09e - add hl, bc - ld a, [hl] - ld hl, $c096 - add hl, bc - ld d, [hl] - ld hl, $c07e - add hl, bc - ld e, [hl] - sub e - ld e, a - ld a, d - sbc b - ld d, a - ld hl, $c086 - add hl, bc - ld a, [hl] - add a - ld [hl], a - ld a, e - sbc b - ld e, a - ld a, d - sbc b - ld d, a - ld hl, $c0a6 - add hl, bc - ld a, d - cp [hl] - jr c, .asm_9786 - jr nz, .asm_9773 - ld hl, $c0ae - add hl, bc - ld a, e - cp [hl] - jr c, .asm_9786 -.asm_9773 - ld hl, $c09e - add hl, bc - ld [hl], e - ld hl, $c096 - add hl, bc - ld [hl], d - ld b, $3 - call Func_9838 - ld a, e - ld [hli], a - ld [hl], d - ret -.asm_9786 - ld hl, $c02e - add hl, bc - res 4, [hl] - res 5, [hl] - ret - -Func_978f: ; 0x978f - ld hl, $c096 - add hl, bc - ld [hl], d - ld hl, $c09e - add hl, bc - ld [hl], e - ld hl, $c0b6 - add hl, bc - ld a, [hl] - ld hl, $c076 - add hl, bc - sub [hl] - jr nc, .asm_97a7 - ld a, $1 -.asm_97a7 - ld [hl], a - ld hl, $c0ae - add hl, bc - ld a, e - sub [hl] - ld e, a - ld a, d - sbc b - ld hl, $c0a6 - add hl, bc - sub [hl] - jr c, .asm_97c3 - ld d, a - ld b, $0 - ld hl, $c02e - add hl, bc - set 5, [hl] - jr .asm_97e6 -.asm_97c3 - ld hl, $c096 - add hl, bc - ld d, [hl] - ld hl, $c09e - add hl, bc - ld e, [hl] - ld hl, $c0ae - add hl, bc - ld a, [hl] - sub e - ld e, a - ld a, d - sbc b - ld d, a - ld hl, $c0a6 - add hl, bc - ld a, [hl] - sub d - ld d, a - ld b, $0 - ld hl, $c02e - add hl, bc - res 5, [hl] -.asm_97e6 - ld hl, $c076 - add hl, bc -.asm_97ea - inc b - ld a, e - sub [hl] - ld e, a - jr nc, .asm_97ea - ld a, d - and a - jr z, .asm_97f8 - dec a - ld d, a - jr .asm_97ea -.asm_97f8 - ld a, e - add [hl] - ld d, b - ld b, $0 - ld hl, $c07e - add hl, bc - ld [hl], d - ld hl, $c086 - add hl, bc - ld [hl], a - ld hl, $c08e - add hl, bc - ld [hl], a - ret - -Music2_ApplyDutyCycle: ; 0x980d - ld b, $0 - ld hl, $c046 - add hl, bc - ld a, [hl] - rlca - rlca - ld [hl], a - and $c0 - ld d, a - ld b, $1 - call Func_9838 - ld a, [hl] - and $3f - or d - ld [hl], a - ret - -Music2_GetNextMusicByte: ; 0x9825 - ld d, $0 - ld a, c - add a - ld e, a - ld hl, $c006 - add hl, de - ld a, [hli] - ld e, a - ld a, [hld] - ld d, a - ld a, [de] ; get next music command - inc de - ld [hl], e ; store address of next command - inc hl - ld [hl], d - ret - -Func_9838: ; 0x9838 - ld a, c - ld hl, Unknown_9b17 - add l - jr nc, .noCarry - inc h -.noCarry - ld l, a - ld a, [hl] - add b - ld l, a - ld h, $ff - ret - -Func_9847: ; 0x9847 - ld h, $0 -.loop - srl a - jr nc, .noCarry - add hl, de -.noCarry - sla e - rl d - and a - jr z, .done - jr .loop -.done - ret - -Func_9858: ; 0x9858 - ld h, $0 - ld l, a - add hl, hl - ld d, h - ld e, l - ld hl, Unknown_9b2f - add hl, de - ld e, [hl] - inc hl - ld d, [hl] - ld a, b -.loop - cp $7 - jr z, .done - sra d - rr e - inc a - jr .loop -.done - ld a, $8 - add d - ld d, a - ret - -Func_9876: ; 0x9876 - ld [$c001], a - cp $ff - jp z, Func_9a34 - cp $b9 - jp z, Func_994e - jp c, Func_994e - cp $fe - jr z, .asm_988d - jp nc, Func_994e -.asm_988d - xor a - ld [$c000], a - ld [$c003], a - ld [$c0e9], a - ld [$c0e6], a - ld [$c0e7], a - ld d, $8 - ld hl, $c016 - call FillMusicRAM2 - ld hl, $c006 - call FillMusicRAM2 - ld d, $4 - ld hl, $c026 - call FillMusicRAM2 - ld hl, $c02e - call FillMusicRAM2 - ld hl, $c03e - call FillMusicRAM2 - ld hl, $c046 - call FillMusicRAM2 - ld hl, $c04e - call FillMusicRAM2 - ld hl, $c056 - call FillMusicRAM2 - ld hl, $c05e - call FillMusicRAM2 - ld hl, $c066 - call FillMusicRAM2 - ld hl, $c06e - call FillMusicRAM2 - ld hl, $c036 - call FillMusicRAM2 - ld hl, $c076 - call FillMusicRAM2 - ld hl, $c07e - call FillMusicRAM2 - ld hl, $c086 - call FillMusicRAM2 - ld hl, $c08e - call FillMusicRAM2 - ld hl, $c096 - call FillMusicRAM2 - ld hl, $c09e - call FillMusicRAM2 - ld hl, $c0a6 - call FillMusicRAM2 - ld hl, $c0ae - call FillMusicRAM2 - ld a, $1 - ld hl, $c0be - call FillMusicRAM2 - ld hl, $c0b6 - call FillMusicRAM2 - ld hl, $c0c6 - call FillMusicRAM2 - ld [$c0e8], a - ld a, $ff - ld [$c004], a - xor a - ld [$ff00+$24], a - ld a, $8 - ld [$ff00+$10], a - ld a, $0 - ld [$ff00+$25], a - xor a - ld [$ff00+$1a], a - ld a, $80 - ld [$ff00+$1a], a - ld a, $77 - ld [$ff00+$24], a - jp Func_9a8f - -Func_994e: ; 0x994e - ld l, a - ld e, a - ld h, $0 - ld d, h - add hl, hl - add hl, de - ld de, SFX_Headers_02 - add hl, de - ld a, h - ld [$c0ec], a - ld a, l - ld [$c0ed], a - ld a, [hl] - and $c0 - rlca - rlca - ld c, a -.asm_9967 - ld d, c - ld a, c - add a - add c - ld c, a - ld b, $0 - ld a, [$c0ec] - ld h, a - ld a, [$c0ed] - ld l, a - add hl, bc - ld c, d - ld a, [hl] - and $f - ld e, a - ld d, $0 - ld hl, $c026 - add hl, de - ld a, [hl] - and a - jr z, .asm_99a3 - ld a, e - cp $7 - jr nz, .asm_999a - ld a, [$c001] - cp $14 - jr nc, .asm_9993 - ret -.asm_9993 - ld a, [hl] - cp $14 - jr z, .asm_99a3 - jr c, .asm_99a3 -.asm_999a - ld a, [$c001] - cp [hl] - jr z, .asm_99a3 - jr c, .asm_99a3 - ret -.asm_99a3 - xor a - push de - ld h, d - ld l, e - add hl, hl - ld d, h - ld e, l - ld hl, $c016 - add hl, de - ld [hli], a - ld [hl], a - ld hl, $c006 - add hl, de - ld [hli], a - ld [hl], a - pop de - ld hl, $c026 - add hl, de - ld [hl], a - ld hl, $c02e - add hl, de - ld [hl], a - ld hl, $c03e - add hl, de - ld [hl], a - ld hl, $c046 - add hl, de - ld [hl], a - ld hl, $c04e - add hl, de - ld [hl], a - ld hl, $c056 - add hl, de - ld [hl], a - ld hl, $c05e - add hl, de - ld [hl], a - ld hl, $c066 - add hl, de - ld [hl], a - ld hl, $c06e - add hl, de - ld [hl], a - ld hl, $c076 - add hl, de - ld [hl], a - ld hl, $c07e - add hl, de - ld [hl], a - ld hl, $c086 - add hl, de - ld [hl], a - ld hl, $c08e - add hl, de - ld [hl], a - ld hl, $c096 - add hl, de - ld [hl], a - ld hl, $c09e - add hl, de - ld [hl], a - ld hl, $c0a6 - add hl, de - ld [hl], a - ld hl, $c0ae - add hl, de - ld [hl], a - ld hl, $c036 - add hl, de - ld [hl], a - ld a, $1 - ld hl, $c0be - add hl, de - ld [hl], a - ld hl, $c0b6 - add hl, de - ld [hl], a - ld hl, $c0c6 - add hl, de - ld [hl], a - ld a, e - cp $4 - jr nz, .asm_9a2b - ld a, $8 - ld [$ff00+$10], a -.asm_9a2b - ld a, c - and a - jp z, Func_9a8f - dec c - jp .asm_9967 - -Func_9a34: ; 0x9a34 - ld a, $80 - ld [$ff00+$26], a - ld [$ff00+$1a], a - xor a - ld [$ff00+$25], a - ld [$ff00+$1c], a - ld a, $8 - ld [$ff00+$10], a - ld [$ff00+$12], a - ld [$ff00+$17], a - ld [$ff00+$21], a - ld a, $40 - ld [$ff00+$14], a - ld [$ff00+$19], a - ld [$ff00+$23], a - ld a, $77 - ld [$ff00+$24], a - xor a - ld [$c000], a - ld [$c003], a - ld [$c002], a - ld [$c0e9], a - ld [$c0eb], a - ld [$c0e6], a - ld [$c0e7], a - ld d, $a0 - ld hl, $c006 - call FillMusicRAM2 - ld a, $1 - ld d, $18 - ld hl, $c0b6 - call FillMusicRAM2 - ld [$c0e8], a - ld [$c0ea], a - ld a, $ff - ld [$c004], a - ret - -; fills d bytes at hl with a -FillMusicRAM2: ; 0x9a89 - ld b, d -.loop - ld [hli], a - dec b - jr nz, .loop - ret - -Func_9a8f: ; 0x9a8f - ld a, [$c001] - ld l, a - ld e, a - ld h, $0 - ld d, h - add hl, hl - add hl, de - ld de, SFX_Headers_02 - add hl, de - ld e, l - ld d, h - ld hl, $c006 - ld a, [de] ; get channel number - ld b, a - rlca - rlca - and $3 - ld c, a - ld a, b - and $f - ld b, c - inc b - inc de - ld c, $0 -.asm_9ab1 - cp c - jr z, .asm_9ab9 - inc c - inc hl - inc hl - jr .asm_9ab1 -.asm_9ab9 - push hl - push bc - push af - ld b, $0 - ld c, a - ld hl, $c026 - add hl, bc - ld a, [$c001] - ld [hl], a - pop af - cp $3 - jr c, .asm_9ad2 - ld hl, $c02e - add hl, bc - set 2, [hl] -.asm_9ad2 - pop bc - pop hl - ld a, [de] ; get channel pointer - ld [hli], a - inc de - ld a, [de] - ld [hli], a - inc de - inc c - dec b - ld a, b - and a - ld a, [de] - inc de - jr nz, .asm_9ab1 - ld a, [$c001] - cp $14 - jr nc, .asm_9aeb - jr .asm_9b15 -.asm_9aeb - ld a, [$c001] - cp $86 - jr z, .asm_9b15 - jr c, .asm_9af6 - jr .asm_9b15 -.asm_9af6 - ld hl, $c02a - ld [hli], a - ld [hli], a - ld [hli], a - ld [hl], a - ld hl, $c012 ; sfx noise channel pointer - ld de, Noise2_endchannel - ld [hl], e - inc hl - ld [hl], d ; overwrite pointer to point to endchannel - ld a, [$c005] - and a - jr nz, .asm_9b15 - ld a, [$ff00+$24] - ld [$c005], a - ld a, $77 - ld [$ff00+$24], a -.asm_9b15 - ret - -Noise2_endchannel: ; 0x9b16 - endchannel - -Unknown_9b17: ; 0x9b17 - db $10, $15, $1A, $1F ; channels 0-3 - db $10, $15, $1A, $1F ; channels 4-7 - -Unknown_9b1f: ; 0x9b1f - db $EE, $DD, $BB, $77 ; channels 0-3 - db $EE, $DD, $BB, $77 ; channels 4-7 - -Unknown_9b27: ; 0x9b27 - db $11, $22, $44, $88 ; channels 0-3 - db $11, $22, $44, $88 ; channels 4-7 - -Unknown_9b2f: ; 0x9b2f - dw $F82C - dw $F89D - dw $F907 - dw $F96B - dw $F9CA - dw $FA23 - dw $FA77 - dw $FAC7 - dw $FB12 - dw $FB58 - dw $FB9B - dw $FBDA - -; an alternate start for MeetRival which has a different first measure -Music_RivalAlternateStart: ; 0x9b47 - ld c, BANK(Music_MeetRival) - ld a, (Music_MeetRival - $4000) / 3 - call PlayMusic - ld hl, $c006 - ld de, Music_MeetRival_branch_b1a2 - call Music2_OverwriteChannelPointer - ld de, Music_MeetRival_branch_b21d - call Music2_OverwriteChannelPointer - ld de, Music_MeetRival_branch_b2b5 - -Music2_OverwriteChannelPointer: ; 0x9b60 - ld a, e - ld [hli], a - ld a, d - ld [hli], a - ret - -; an alternate tempo for MeetRival which is slightly slower -Music_RivalAlternateTempo: ; 0x9b65 - ld c, BANK(Music_MeetRival) - ld a, (Music_MeetRival - $4000) / 3 - call PlayMusic - ld hl, $c006 - ld de, Music_MeetRival_branch_b119 - jp Music2_OverwriteChannelPointer - -; applies both the alternate start and alternate tempo -Music_RivalAlternateStartAndTempo: ; 0x9b75 - call Music_RivalAlternateStart - ld hl, $c006 - ld de, Music_MeetRival_branch_b19b - jp Music2_OverwriteChannelPointer - -; an alternate tempo for Cities1 which is used for the Hall of Fame room -Music_Cities1AlternateTempo: ; 0x9b81 - ld a, $a - ld [$cfc8], a - ld [$cfc9], a - ld a, $ff - ld [wMusicHeaderPointer], a - ld c, $64 - call DelayFrames - ld c, BANK(Music_Cities1) - ld a, (Music_Cities1 - $4000) / 3 - call PlayMusic - ld hl, $c006 - ld de, Music_Cities1_branch_aa6f - jp Music2_OverwriteChannelPointer - -INCLUDE "music/pkmnhealed.asm" -INCLUDE "music/routes1.asm" -INCLUDE "music/routes2.asm" -INCLUDE "music/routes3.asm" -INCLUDE "music/routes4.asm" -INCLUDE "music/indigoplateau.asm" -INCLUDE "music/pallettown.asm" -INCLUDE "music/unusedsong.asm" -INCLUDE "music/cities1.asm" -INCLUDE "music/sfx/sfx_02_3a.asm" -INCLUDE "music/museumguy.asm" -INCLUDE "music/meetprofoak.asm" -INCLUDE "music/meetrival.asm" -INCLUDE "music/sfx/sfx_02_41.asm" -INCLUDE "music/sfx/sfx_02_3b.asm" -INCLUDE "music/sfx/sfx_02_42.asm" -INCLUDE "music/ssanne.asm" -INCLUDE "music/cities2.asm" -INCLUDE "music/celadon.asm" -INCLUDE "music/cinnabar.asm" -INCLUDE "music/vermilion.asm" -INCLUDE "music/lavender.asm" -INCLUDE "music/safarizone.asm" -INCLUDE "music/gym.asm" -INCLUDE "music/pokecenter.asm" SECTION "bank3",ROMX,BANK[$3] @@ -20297,502 +18376,254 @@ HandleJoypadResetButtons: ; c03c (3:403c) jp GetJoypadState MapSongBanks: ; c04d (3:404d) - db (Music_PalletTown - $4000) / 3 - db BANK(Music_PalletTown) ;PALLET_TOWN - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; VIRIDIAN_CITY - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; PEWTER_CITY - db (Music_Cities2 - $4000) / 3 - db BANK(Music_Cities2) ; CERULEAN_CITY - db (Music_Lavender - $4000) / 3 - db BANK(Music_Lavender) ; LAVENDER_TOWN - db (Music_Vermilion - $4000) / 3 - db BANK(Music_Vermilion) ; VERMILION_CITY - db (Music_Celadon - $4000) / 3 - db BANK(Music_Celadon) ; CELADON_CITY - db (Music_Cities2 - $4000) / 3 - db BANK(Music_Cities2) ; FUCHSIA_CITY - db (Music_Cinnabar - $4000) / 3 - db BANK(Music_Cinnabar) ; CINNABAR_ISLAND - db (Music_IndigoPlateau - $4000) / 3 - db BANK(Music_IndigoPlateau) ; INDIGO_PLATEAU - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; SAFFRON_CITY - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; unused - db (Music_Routes1 - $4000) / 3 - db BANK(Music_Routes1) ; ROUTE_1 - db (Music_Routes1 - $4000) / 3 - db BANK(Music_Routes1) ; ROUTE_2 - db (Music_Routes3 - $4000) / 3 - db BANK(Music_Routes3) ; ROUTE_3 - db (Music_Routes3 - $4000) / 3 - db BANK(Music_Routes3) ; ROUTE_4 - db (Music_Routes3 - $4000) / 3 - db BANK(Music_Routes3) ; ROUTE_5 - db (Music_Routes3 - $4000) / 3 - db BANK(Music_Routes3) ; ROUTE_6 - db (Music_Routes3 - $4000) / 3 - db BANK(Music_Routes3) ; ROUTE_7 - db (Music_Routes3 - $4000) / 3 - db BANK(Music_Routes3) ; ROUTE_8 - db (Music_Routes3 - $4000) / 3 - db BANK(Music_Routes3) ; ROUTE_9 - db (Music_Routes3 - $4000) / 3 - db BANK(Music_Routes3) ; ROUTE_10 - db (Music_Routes4 - $4000) / 3 - db BANK(Music_Routes4) ; ROUTE_11 - db (Music_Routes4 - $4000) / 3 - db BANK(Music_Routes4) ; ROUTE_12 - db (Music_Routes4 - $4000) / 3 - db BANK(Music_Routes4) ; ROUTE_13 - db (Music_Routes4 - $4000) / 3 - db BANK(Music_Routes4) ; ROUTE_14 - db (Music_Routes4 - $4000) / 3 - db BANK(Music_Routes4) ; ROUTE_15 - db (Music_Routes3 - $4000) / 3 - db BANK(Music_Routes3) ; ROUTE_16 - db (Music_Routes3 - $4000) / 3 - db BANK(Music_Routes3) ; ROUTE_17 - db (Music_Routes3 - $4000) / 3 - db BANK(Music_Routes3) ; ROUTE_18 - db (Music_Routes3 - $4000) / 3 - db BANK(Music_Routes3) ; ROUTE_19 - db (Music_Routes3 - $4000) / 3 - db BANK(Music_Routes3) ; ROUTE_20 - db (Music_Routes3 - $4000) / 3 - db BANK(Music_Routes3) ; ROUTE_21 - db (Music_Routes3 - $4000) / 3 - db BANK(Music_Routes3) ; ROUTE_22 - db (Music_IndigoPlateau - $4000) / 3 - db BANK(Music_IndigoPlateau) ; ROUTE_23 - db (Music_Routes2 - $4000) / 3 - db BANK(Music_Routes2) ; ROUTE_24 - db (Music_Routes2 - $4000) / 3 - db BANK(Music_Routes2) ; ROUTE_25 - db (Music_PalletTown - $4000) / 3 - db BANK(Music_PalletTown) ; RedsHouse1F - db (Music_PalletTown - $4000) / 3 - db BANK(Music_PalletTown) ; RedsHouse2F - db (Music_PalletTown - $4000) / 3 - db BANK(Music_PalletTown) ; BluesHouse - db (Music_OaksLab - $4000) / 3 - db BANK(Music_OaksLab) ; OaksLab - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; ViridianPokecenter - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; ViridianMart - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; School - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; ViridianHouse - db (Music_Gym - $4000) / 3 - db BANK(Music_Gym) ; ViridianGym - db (Music_Dungeon2 - $4000) / 3 - db BANK(Music_Dungeon2) ; DiglettsCaveRoute2 - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; ViridianForestexit - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; Route2House - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; Route2Gate - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; ViridianForestEntrance - db (Music_Dungeon2 - $4000) / 3 - db BANK(Music_Dungeon2) ; ViridianForest - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; MuseumF1 - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; MuseumF2 - db (Music_Gym - $4000) / 3 - db BANK(Music_Gym) ; PewterGym - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; PewterHouse1 - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; PewterMart - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; PewterHouse2 - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; PewterPokecenter - db (Music_Dungeon3 - $4000) / 3 - db BANK(Music_Dungeon3) ; MtMoon1 - db (Music_Dungeon3 - $4000) / 3 - db BANK(Music_Dungeon3) ; MtMoon2 - db (Music_Dungeon3 - $4000) / 3 - db BANK(Music_Dungeon3) ; MtMoon3 - db (Music_Cities2 - $4000) / 3 - db BANK(Music_Cities2) ; CeruleanHouseTrashed - db (Music_Cities2 - $4000) / 3 - db BANK(Music_Cities2) ; CeruleanHouse - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; CeruleanPokecenter - db (Music_Gym - $4000) / 3 - db BANK(Music_Gym) ; CeruleanGym - db (Music_Cities2 - $4000) / 3 - db BANK(Music_Cities2) ; BikeShop - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; CeruleanMart - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; MtMoonPokecenter - db (Music_Dungeon3 - $4000) / 3 - db BANK(Music_Dungeon3) ; CeruleanHouseTrashed - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; Route5Gate - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; UndergroundTunnelEntranceRoute5 - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; DayCareM - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; Route6Gate - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; UndergroundTunnelEntranceRoute6 - db (Music_Vermilion - $4000) / 3 - db BANK(Music_Vermilion) ; FREEZE - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; Route7Gate - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; UndergroundPathEntranceRoute7 - db (Music_Celadon - $4000) / 3 - db BANK(Music_Celadon) ;FREEZE - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; Route8Gate - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; UndergroundPathEntranceRoute8 - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; RockTunnelPokecenter - db (Music_Dungeon3 - $4000) / 3 - db BANK(Music_Dungeon3) ; RockTunnel1 - db (Music_Dungeon1 - $4000) / 3 - db BANK(Music_Dungeon1) ; PowerPlant - db (Music_Vermilion - $4000) / 3 - db BANK(Music_Vermilion) ; Route11Gate - db (Music_Dungeon2 - $4000) / 3 - db BANK(Music_Dungeon2) ; DiglettsCaveEntranceRoute11 - db (Music_Vermilion - $4000) / 3 - db BANK(Music_Vermilion) ; Route11GateUpstairs - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; Route12Gate - db (Music_Cities2 - $4000) / 3 - db BANK(Music_Cities2) ; BillsHouse - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; VermilionPokecenter - db (Music_Vermilion - $4000) / 3 - db BANK(Music_Vermilion) ; FanClub - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; VermilionMart - db (Music_Gym - $4000) / 3 - db BANK(Music_Gym) ; VermilionGym - db (Music_Vermilion - $4000) / 3 - db BANK(Music_Vermilion) ; VermilionHouse1 - db (Music_SSAnne - $4000) / 3 - db BANK(Music_SSAnne) ; VermilionDock - db (Music_SSAnne - $4000) / 3 - db BANK(Music_SSAnne) ; SSAnne1 - db (Music_SSAnne - $4000) / 3 - db BANK(Music_SSAnne) ; SSAnne2 - db (Music_SSAnne - $4000) / 3 - db BANK(Music_SSAnne) ; SSAnne3 - db (Music_SSAnne - $4000) / 3 - db BANK(Music_SSAnne) ; SSAnne4 - db (Music_SSAnne - $4000) / 3 - db BANK(Music_SSAnne) ; SSAnne5 - db (Music_SSAnne - $4000) / 3 - db BANK(Music_SSAnne) ; SSAnne6 - db (Music_SSAnne - $4000) / 3 - db BANK(Music_SSAnne) ; SSAnne7 - db (Music_SSAnne - $4000) / 3 - db BANK(Music_SSAnne) ; SSAnne8 - db (Music_SSAnne - $4000) / 3 - db BANK(Music_SSAnne) ; SSAnne9 - db (Music_SSAnne - $4000) / 3 - db BANK(Music_SSAnne) ; SSAnne10 - db (Music_Dungeon2 - $4000) / 3 - db BANK(Music_Dungeon2) ;unused - db (Music_Dungeon2 - $4000) / 3 - db BANK(Music_Dungeon2) ;unused - db (Music_SSAnne - $4000) / 3 - db BANK(Music_SSAnne) ;unused - db (Music_Dungeon3 - $4000) / 3 - db BANK(Music_Dungeon3) ; VictoryRoad1 - db (Music_PokemonTower - $4000) / 3 - db BANK(Music_PokemonTower) ;unused - db (Music_Dungeon1 - $4000) / 3 - db BANK(Music_Dungeon1) ;unused - db (Music_SilphCo - $4000) / 3 - db BANK(Music_SilphCo) ;unused - db (Music_SilphCo - $4000) / 3 - db BANK(Music_SilphCo) ;unused - db (Music_IndigoPlateau - $4000) / 3 - db BANK(Music_IndigoPlateau) ; Lance - db (Music_SSAnne - $4000) / 3 - db BANK(Music_SSAnne) ;unused - db (Music_SSAnne - $4000) / 3 - db BANK(Music_SSAnne) ;unused - db (Music_SSAnne - $4000) / 3 - db BANK(Music_SSAnne) ;unused - db (Music_SSAnne - $4000) / 3 - db BANK(Music_SSAnne) ;unused - db (Music_PalletTown - $4000) / 3 - db BANK(Music_PalletTown) ; HallofFameRoom - db (Music_Routes1 - $4000) / 3 - db BANK(Music_Routes1) ; UndergroundPathNS - db (Music_IndigoPlateau - $4000) / 3 - db BANK(Music_IndigoPlateau) ; Gary - db (Music_Routes1 - $4000) / 3 - db BANK(Music_Routes1) ; UndergroundPathWE - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; CeladonMart1 - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; CeladonMart2 - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; CeladonMart3 - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; CeladonMart4 - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; CeladonMartRoof - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; CeladonMartElevator - db (Music_Celadon - $4000) / 3 - db BANK(Music_Celadon) ; CeladonMansion1 - db (Music_Celadon - $4000) / 3 - db BANK(Music_Celadon) ; CeladonMansion2 - db (Music_Celadon - $4000) / 3 - db BANK(Music_Celadon) ; CeladonMansion3 - db (Music_Celadon - $4000) / 3 - db BANK(Music_Celadon) ; CeladonMansion4 - db (Music_Celadon - $4000) / 3 - db BANK(Music_Celadon) ; CeladonMansion5 - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; CeladonPokecenter - db (Music_Gym - $4000) / 3 - db BANK(Music_Gym) ; CeladonGym - db (Music_GameCorner - $4000) / 3 - db BANK(Music_GameCorner) ; CeladonGameCorner - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; CeladonMart5 - db (Music_Celadon - $4000) / 3 - db BANK(Music_Celadon) ; CeladonPrizeRoom - db (Music_Celadon - $4000) / 3 - db BANK(Music_Celadon) ; CeladonDiner - db (Music_Celadon - $4000) / 3 - db BANK(Music_Celadon) ; CeladonHouse - db (Music_Celadon - $4000) / 3 - db BANK(Music_Celadon) ; CeladonHotel - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; LavenderPokecenter - db (Music_PokemonTower - $4000) / 3 - db BANK(Music_PokemonTower) ; PokemonTower1 - db (Music_PokemonTower - $4000) / 3 - db BANK(Music_PokemonTower) ; PokemonTower2 - db (Music_PokemonTower - $4000) / 3 - db BANK(Music_PokemonTower) ; PokemonTower3 - db (Music_PokemonTower - $4000) / 3 - db BANK(Music_PokemonTower) ; PokemonTower4 - db (Music_PokemonTower - $4000) / 3 - db BANK(Music_PokemonTower) ; PokemonTower5 - db (Music_PokemonTower - $4000) / 3 - db BANK(Music_PokemonTower) ; PokemonTower6 - db (Music_PokemonTower - $4000) / 3 - db BANK(Music_PokemonTower) ; PokemonTower7 - db (Music_Lavender - $4000) / 3 - db BANK(Music_Lavender) ; LavenderHouse1 - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; LavenderMart - db (Music_Lavender - $4000) / 3 - db BANK(Music_Lavender) ; LavenderHouse2 - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; FuchsiaMart - db (Music_Cities2 - $4000) / 3 - db BANK(Music_Cities2) ; FuchsiaHouse1 - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; FuchsiaPokecenter - db (Music_Cities2 - $4000) / 3 - db BANK(Music_Cities2) ; FuchsiaHouse2 - db (Music_Cities2 - $4000) / 3 - db BANK(Music_Cities2) ; SafariZoneEntrance - db (Music_Gym - $4000) / 3 - db BANK(Music_Gym) ; FuchsiaGym - db (Music_Cities2 - $4000) / 3 - db BANK(Music_Cities2) ; FuchsiaMeetingRoom - db (Music_Dungeon2 - $4000) / 3 - db BANK(Music_Dungeon2) ; SeafoamIslands2 - db (Music_Dungeon2 - $4000) / 3 - db BANK(Music_Dungeon2) ; SeafoamIslands3 - db (Music_Dungeon2 - $4000) / 3 - db BANK(Music_Dungeon2) ; SeafoamIslands4 - db (Music_Dungeon2 - $4000) / 3 - db BANK(Music_Dungeon2) ; SeafoamIslands5 - db (Music_Cities2 - $4000) / 3 - db BANK(Music_Cities2) ; VermilionHouse2 - db (Music_Cities2 - $4000) / 3 - db BANK(Music_Cities2) ; FuchsiaHouse3 - db (Music_CinnabarMansion - $4000) / 3 - db BANK(Music_CinnabarMansion) ; Mansion1 - db (Music_Gym - $4000) / 3 - db BANK(Music_Gym) ; CinnabarGym - db (Music_Cinnabar - $4000) / 3 - db BANK(Music_Cinnabar) ; Lab1 - db (Music_Cinnabar - $4000) / 3 - db BANK(Music_Cinnabar) ; Lab2 - db (Music_Cinnabar - $4000) / 3 - db BANK(Music_Cinnabar) ; Lab3 - db (Music_Cinnabar - $4000) / 3 - db BANK(Music_Cinnabar) ; Lab4 - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; CinnabarPokecenter - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; CinnabarMart - db (Music_Cinnabar - $4000) / 3 - db BANK(Music_Cinnabar) - db (Music_IndigoPlateau - $4000) / 3 - db BANK(Music_IndigoPlateau) ; IndigoPlateauLobby - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; CopycatsHouseF1 - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; CopycatsHouseF2 - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; FightingDojo - db (Music_Gym - $4000) / 3 - db BANK(Music_Gym) ; SaffronGym - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; SaffronHouse1 - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; SaffronMart - db (Music_SilphCo - $4000) / 3 - db BANK(Music_SilphCo) ; SilphCo1 - db (Music_Pokecenter - $4000) / 3 - db BANK(Music_Pokecenter) ; SaffronPokecenter - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; SaffronHouse2 - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; Route15Gate - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; Route15GateUpstairs - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; Route16GateMap - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; Route16GateUpstairs - db (Music_Celadon - $4000) / 3 - db BANK(Music_Celadon) ; Route16House - db (Music_Celadon - $4000) / 3 - db BANK(Music_Celadon) ; Route12House - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; Route18Gate - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; Route18GateUpstairs - db (Music_Dungeon2 - $4000) / 3 - db BANK(Music_Dungeon2) ; SeafoamIslands1 - db (Music_Dungeon2 - $4000) / 3 - db BANK(Music_Dungeon2) ; Route22Gate - db (Music_Dungeon3 - $4000) / 3 - db BANK(Music_Dungeon3) ; VictoryRoad2 - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; Route12GateUpstairs - db (Music_Vermilion - $4000) / 3 - db BANK(Music_Vermilion) ; VermilionHouse3 - db (Music_Dungeon2 - $4000) / 3 - db BANK(Music_Dungeon2) ; DiglettsCave - db (Music_Dungeon3 - $4000) / 3 - db BANK(Music_Dungeon3) ; VictoryRoad3 - db (Music_Dungeon1 - $4000) / 3 - db BANK(Music_Dungeon1) ; RocketHideout1 - db (Music_Dungeon1 - $4000) / 3 - db BANK(Music_Dungeon1) ; RocketHideout2 - db (Music_Dungeon1 - $4000) / 3 - db BANK(Music_Dungeon1) ; RocketHideout3 - db (Music_Dungeon1 - $4000) / 3 - db BANK(Music_Dungeon1) ; RocketHideout4 - db (Music_Dungeon1 - $4000) / 3 - db BANK(Music_Dungeon1) ; RocketHideoutElevator - db (Music_Dungeon1 - $4000) / 3 - db BANK(Music_Dungeon1) - db (Music_Dungeon1 - $4000) / 3 - db BANK(Music_Dungeon1) - db (Music_Dungeon1 - $4000) / 3 - db BANK(Music_Dungeon1) - db (Music_SilphCo - $4000) / 3 - db BANK(Music_SilphCo) ; SilphCo2 - db (Music_SilphCo - $4000) / 3 - db BANK(Music_SilphCo) ; SilphCo3 - db (Music_SilphCo - $4000) / 3 - db BANK(Music_SilphCo) ; SilphCo4 - db (Music_SilphCo - $4000) / 3 - db BANK(Music_SilphCo) ; SilphCo5 - db (Music_SilphCo - $4000) / 3 - db BANK(Music_SilphCo) ; SilphCo6 - db (Music_SilphCo - $4000) / 3 - db BANK(Music_SilphCo) ; SilphCo7 - db (Music_SilphCo - $4000) / 3 - db BANK(Music_SilphCo) ; SilphCo8 - db (Music_CinnabarMansion - $4000) / 3 - db BANK(Music_CinnabarMansion) ; Mansion2 - db (Music_CinnabarMansion - $4000) / 3 - db BANK(Music_CinnabarMansion) ; Mansion3 - db (Music_CinnabarMansion - $4000) / 3 - db BANK(Music_CinnabarMansion) ; Mansion4 - db (Music_SafariZone - $4000) / 3 - db BANK(Music_SafariZone) ; SafariZoneEast - db (Music_SafariZone - $4000) / 3 - db BANK(Music_SafariZone) ; SafariZoneNorth - db (Music_SafariZone - $4000) / 3 - db BANK(Music_SafariZone) ; SafariZoneWest - db (Music_SafariZone - $4000) / 3 - db BANK(Music_SafariZone) ; SafariZoneCenter - db (Music_SafariZone - $4000) / 3 - db BANK(Music_SafariZone) ; SafariZoneRestHouse1 - db (Music_SafariZone - $4000) / 3 - db BANK(Music_SafariZone) ; SafariZoneSecretHouse - db (Music_SafariZone - $4000) / 3 - db BANK(Music_SafariZone) ; SafariZoneRestHouse2 - db (Music_SafariZone - $4000) / 3 - db BANK(Music_SafariZone) ; SafariZoneRestHouse3 - db (Music_SafariZone - $4000) / 3 - db BANK(Music_SafariZone) ; SafariZoneRestHouse4 - db (Music_Dungeon1 - $4000) / 3 - db BANK(Music_Dungeon1) ; UnknownDungeon2 - db (Music_Dungeon1 - $4000) / 3 - db BANK(Music_Dungeon1) ; UnknownDungeon3 - db (Music_Dungeon1 - $4000) / 3 - db BANK(Music_Dungeon1) ; UnknownDungeon1 - db (Music_Cities2 - $4000) / 3 - db BANK(Music_Cities2) ; NameRater - db (Music_Cities1 - $4000) / 3 - db BANK(Music_Cities1) ; CeruleanHouse2 - db (Music_Cinnabar - $4000) / 3 - db BANK(Music_Cinnabar) - db (Music_Dungeon3 - $4000) / 3 - db BANK(Music_Dungeon3) ; RockTunnel2 - db (Music_SilphCo - $4000) / 3 - db BANK(Music_SilphCo) ; SilphCo9 - db (Music_SilphCo - $4000) / 3 - db BANK(Music_SilphCo) ; SilphCo10 - db (Music_SilphCo - $4000) / 3 - db BANK(Music_SilphCo) ; SilphCo11 - db (Music_SilphCo - $4000) / 3 - db BANK(Music_SilphCo) ; SilphCoElevator - db (Music_SilphCo - $4000) / 3 - db BANK(Music_SilphCo) - db (Music_SilphCo - $4000) / 3 - db BANK(Music_SilphCo) - db (Music_Celadon - $4000) / 3 - db BANK(Music_Celadon) ; BattleCenterM - db (Music_Celadon - $4000) / 3 - db BANK(Music_Celadon) ; TradeCenterM - db (Music_SilphCo - $4000) / 3 - db BANK(Music_SilphCo) - db (Music_SilphCo - $4000) / 3 - db BANK(Music_SilphCo) - db (Music_SilphCo - $4000) / 3 - db BANK(Music_SilphCo) - db (Music_SilphCo - $4000) / 3 - db BANK(Music_SilphCo) - db (Music_Gym - $4000) / 3 - db BANK(Music_Gym) ; Lorelei - db (Music_Dungeon1 - $4000) / 3 - db BANK(Music_Dungeon1) ; Bruno - db (Music_PokemonTower - $4000) / 3 - db BANK(Music_PokemonTower) ; Agatha + db MUSIC_PALLET_TOWN, BANK(Music_PalletTown) ;PALLET_TOWN + db MUSIC_CITIES1, BANK(Music_Cities1) ; VIRIDIAN_CITY + db MUSIC_CITIES1, BANK(Music_Cities1) ; PEWTER_CITY + db MUSIC_CITIES2, BANK(Music_Cities2) ; CERULEAN_CITY + db MUSIC_LAVENDER, BANK(Music_Lavender) ; LAVENDER_TOWN + db MUSIC_VERMILION, BANK(Music_Vermilion) ; VERMILION_CITY + db MUSIC_CELADON, BANK(Music_Celadon) ; CELADON_CITY + db MUSIC_CITIES2, BANK(Music_Cities2) ; FUCHSIA_CITY + db MUSIC_CINNABAR, BANK(Music_Cinnabar) ; CINNABAR_ISLAND + db MUSIC_INDIGO_PLATEAU, BANK(Music_IndigoPlateau) ; INDIGO_PLATEAU + db MUSIC_CITIES1, BANK(Music_Cities1) ; SAFFRON_CITY + db MUSIC_CITIES1, BANK(Music_Cities1) ; unused + db MUSIC_ROUTES1, BANK(Music_Routes1) ; ROUTE_1 + db MUSIC_ROUTES1, BANK(Music_Routes1) ; ROUTE_2 + db MUSIC_ROUTES3, BANK(Music_Routes3) ; ROUTE_3 + db MUSIC_ROUTES3, BANK(Music_Routes3) ; ROUTE_4 + db MUSIC_ROUTES3, BANK(Music_Routes3) ; ROUTE_5 + db MUSIC_ROUTES3, BANK(Music_Routes3) ; ROUTE_6 + db MUSIC_ROUTES3, BANK(Music_Routes3) ; ROUTE_7 + db MUSIC_ROUTES3, BANK(Music_Routes3) ; ROUTE_8 + db MUSIC_ROUTES3, BANK(Music_Routes3) ; ROUTE_9 + db MUSIC_ROUTES3, BANK(Music_Routes3) ; ROUTE_10 + db MUSIC_ROUTES4, BANK(Music_Routes4) ; ROUTE_11 + db MUSIC_ROUTES4, BANK(Music_Routes4) ; ROUTE_12 + db MUSIC_ROUTES4, BANK(Music_Routes4) ; ROUTE_13 + db MUSIC_ROUTES4, BANK(Music_Routes4) ; ROUTE_14 + db MUSIC_ROUTES4, BANK(Music_Routes4) ; ROUTE_15 + db MUSIC_ROUTES3, BANK(Music_Routes3) ; ROUTE_16 + db MUSIC_ROUTES3, BANK(Music_Routes3) ; ROUTE_17 + db MUSIC_ROUTES3, BANK(Music_Routes3) ; ROUTE_18 + db MUSIC_ROUTES3, BANK(Music_Routes3) ; ROUTE_19 + db MUSIC_ROUTES3, BANK(Music_Routes3) ; ROUTE_20 + db MUSIC_ROUTES3, BANK(Music_Routes3) ; ROUTE_21 + db MUSIC_ROUTES3, BANK(Music_Routes3) ; ROUTE_22 + db MUSIC_INDIGO_PLATEAU, BANK(Music_IndigoPlateau) ; ROUTE_23 + db MUSIC_ROUTES2, BANK(Music_Routes2) ; ROUTE_24 + db MUSIC_ROUTES2, BANK(Music_Routes2) ; ROUTE_25 + db MUSIC_PALLET_TOWN, BANK(Music_PalletTown) ; RedsHouse1F + db MUSIC_PALLET_TOWN, BANK(Music_PalletTown) ; RedsHouse2F + db MUSIC_PALLET_TOWN, BANK(Music_PalletTown) ; BluesHouse + db MUSIC_OAKS_LAB, BANK(Music_OaksLab) ; OaksLab + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; ViridianPokecenter + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; ViridianMart + db MUSIC_CITIES1, BANK(Music_Cities1) ; School + db MUSIC_CITIES1, BANK(Music_Cities1) ; ViridianHouse + db MUSIC_GYM, BANK(Music_Gym) ; ViridianGym + db MUSIC_DUNGEON2, BANK(Music_Dungeon2) ; DiglettsCaveRoute2 + db MUSIC_CITIES1, BANK(Music_Cities1) ; ViridianForestexit + db MUSIC_CITIES1, BANK(Music_Cities1) ; Route2House + db MUSIC_CITIES1, BANK(Music_Cities1) ; Route2Gate + db MUSIC_CITIES1, BANK(Music_Cities1) ; ViridianForestEntrance + db MUSIC_DUNGEON2, BANK(Music_Dungeon2) ; ViridianForest + db MUSIC_CITIES1, BANK(Music_Cities1) ; MuseumF1 + db MUSIC_CITIES1, BANK(Music_Cities1) ; MuseumF2 + db MUSIC_GYM, BANK(Music_Gym) ; PewterGym + db MUSIC_CITIES1, BANK(Music_Cities1) ; PewterHouse1 + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; PewterMart + db MUSIC_CITIES1, BANK(Music_Cities1) ; PewterHouse2 + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; PewterPokecenter + db MUSIC_DUNGEON3, BANK(Music_Dungeon3) ; MtMoon1 + db MUSIC_DUNGEON3, BANK(Music_Dungeon3) ; MtMoon2 + db MUSIC_DUNGEON3, BANK(Music_Dungeon3) ; MtMoon3 + db MUSIC_CITIES2, BANK(Music_Cities2) ; CeruleanHouseTrashed + db MUSIC_CITIES2, BANK(Music_Cities2) ; CeruleanHouse + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; CeruleanPokecenter + db MUSIC_GYM, BANK(Music_Gym) ; CeruleanGym + db MUSIC_CITIES2, BANK(Music_Cities2) ; BikeShop + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; CeruleanMart + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; MtMoonPokecenter + db MUSIC_DUNGEON3, BANK(Music_Dungeon3) ; CeruleanHouseTrashed + db MUSIC_CITIES1, BANK(Music_Cities1) ; Route5Gate + db MUSIC_CITIES1, BANK(Music_Cities1) ; UndergroundTunnelEntranceRoute5 + db MUSIC_CITIES1, BANK(Music_Cities1) ; DayCareM + db MUSIC_CITIES1, BANK(Music_Cities1) ; Route6Gate + db MUSIC_CITIES1, BANK(Music_Cities1) ; UndergroundTunnelEntranceRoute6 + db MUSIC_VERMILION, BANK(Music_Vermilion) ; FREEZE + db MUSIC_CITIES1, BANK(Music_Cities1) ; Route7Gate + db MUSIC_CITIES1, BANK(Music_Cities1) ; UndergroundPathEntranceRoute7 + db MUSIC_CELADON, BANK(Music_Celadon) ;FREEZE + db MUSIC_CITIES1, BANK(Music_Cities1) ; Route8Gate + db MUSIC_CITIES1, BANK(Music_Cities1) ; UndergroundPathEntranceRoute8 + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; RockTunnelPokecenter + db MUSIC_DUNGEON3, BANK(Music_Dungeon3) ; RockTunnel1 + db MUSIC_DUNGEON1, BANK(Music_Dungeon1) ; PowerPlant + db MUSIC_VERMILION, BANK(Music_Vermilion) ; Route11Gate + db MUSIC_DUNGEON2, BANK(Music_Dungeon2) ; DiglettsCaveEntranceRoute11 + db MUSIC_VERMILION, BANK(Music_Vermilion) ; Route11GateUpstairs + db MUSIC_CITIES1, BANK(Music_Cities1) ; Route12Gate + db MUSIC_CITIES2, BANK(Music_Cities2) ; BillsHouse + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; VermilionPokecenter + db MUSIC_VERMILION, BANK(Music_Vermilion) ; FanClub + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; VermilionMart + db MUSIC_GYM, BANK(Music_Gym) ; VermilionGym + db MUSIC_VERMILION, BANK(Music_Vermilion) ; VermilionHouse1 + db MUSIC_SS_ANNE, BANK(Music_SSAnne) ; VermilionDock + db MUSIC_SS_ANNE, BANK(Music_SSAnne) ; SSAnne1 + db MUSIC_SS_ANNE, BANK(Music_SSAnne) ; SSAnne2 + db MUSIC_SS_ANNE, BANK(Music_SSAnne) ; SSAnne3 + db MUSIC_SS_ANNE, BANK(Music_SSAnne) ; SSAnne4 + db MUSIC_SS_ANNE, BANK(Music_SSAnne) ; SSAnne5 + db MUSIC_SS_ANNE, BANK(Music_SSAnne) ; SSAnne6 + db MUSIC_SS_ANNE, BANK(Music_SSAnne) ; SSAnne7 + db MUSIC_SS_ANNE, BANK(Music_SSAnne) ; SSAnne8 + db MUSIC_SS_ANNE, BANK(Music_SSAnne) ; SSAnne9 + db MUSIC_SS_ANNE, BANK(Music_SSAnne) ; SSAnne10 + db MUSIC_DUNGEON2, BANK(Music_Dungeon2) ;unused + db MUSIC_DUNGEON2, BANK(Music_Dungeon2) ;unused + db MUSIC_SS_ANNE, BANK(Music_SSAnne) ;unused + db MUSIC_DUNGEON3, BANK(Music_Dungeon3) ; VictoryRoad1 + db MUSIC_POKEMON_TOWER, BANK(Music_PokemonTower) ;unused + db MUSIC_DUNGEON1, BANK(Music_Dungeon1) ;unused + db MUSIC_SILPH_CO, BANK(Music_SilphCo) ;unused + db MUSIC_SILPH_CO, BANK(Music_SilphCo) ;unused + db MUSIC_INDIGO_PLATEAU, BANK(Music_IndigoPlateau) ; Lance + db MUSIC_SS_ANNE, BANK(Music_SSAnne) ;unused + db MUSIC_SS_ANNE, BANK(Music_SSAnne) ;unused + db MUSIC_SS_ANNE, BANK(Music_SSAnne) ;unused + db MUSIC_SS_ANNE, BANK(Music_SSAnne) ;unused + db MUSIC_PALLET_TOWN, BANK(Music_PalletTown) ; HallofFameRoom + db MUSIC_ROUTES1, BANK(Music_Routes1) ; UndergroundPathNS + db MUSIC_INDIGO_PLATEAU, BANK(Music_IndigoPlateau) ; Gary + db MUSIC_ROUTES1, BANK(Music_Routes1) ; UndergroundPathWE + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; CeladonMart1 + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; CeladonMart2 + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; CeladonMart3 + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; CeladonMart4 + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; CeladonMartRoof + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; CeladonMartElevator + db MUSIC_CELADON, BANK(Music_Celadon) ; CeladonMansion1 + db MUSIC_CELADON, BANK(Music_Celadon) ; CeladonMansion2 + db MUSIC_CELADON, BANK(Music_Celadon) ; CeladonMansion3 + db MUSIC_CELADON, BANK(Music_Celadon) ; CeladonMansion4 + db MUSIC_CELADON, BANK(Music_Celadon) ; CeladonMansion5 + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; CeladonPokecenter + db MUSIC_GYM, BANK(Music_Gym) ; CeladonGym + db MUSIC_GAME_CORNER, BANK(Music_GameCorner) ; CeladonGameCorner + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; CeladonMart5 + db MUSIC_CELADON, BANK(Music_Celadon) ; CeladonPrizeRoom + db MUSIC_CELADON, BANK(Music_Celadon) ; CeladonDiner + db MUSIC_CELADON, BANK(Music_Celadon) ; CeladonHouse + db MUSIC_CELADON, BANK(Music_Celadon) ; CeladonHotel + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; LavenderPokecenter + db MUSIC_POKEMON_TOWER, BANK(Music_PokemonTower) ; PokemonTower1 + db MUSIC_POKEMON_TOWER, BANK(Music_PokemonTower) ; PokemonTower2 + db MUSIC_POKEMON_TOWER, BANK(Music_PokemonTower) ; PokemonTower3 + db MUSIC_POKEMON_TOWER, BANK(Music_PokemonTower) ; PokemonTower4 + db MUSIC_POKEMON_TOWER, BANK(Music_PokemonTower) ; PokemonTower5 + db MUSIC_POKEMON_TOWER, BANK(Music_PokemonTower) ; PokemonTower6 + db MUSIC_POKEMON_TOWER, BANK(Music_PokemonTower) ; PokemonTower7 + db MUSIC_LAVENDER, BANK(Music_Lavender) ; LavenderHouse1 + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; LavenderMart + db MUSIC_LAVENDER, BANK(Music_Lavender) ; LavenderHouse2 + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; FuchsiaMart + db MUSIC_CITIES2, BANK(Music_Cities2) ; FuchsiaHouse1 + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; FuchsiaPokecenter + db MUSIC_CITIES2, BANK(Music_Cities2) ; FuchsiaHouse2 + db MUSIC_CITIES2, BANK(Music_Cities2) ; SafariZoneEntrance + db MUSIC_GYM, BANK(Music_Gym) ; FuchsiaGym + db MUSIC_CITIES2, BANK(Music_Cities2) ; FuchsiaMeetingRoom + db MUSIC_DUNGEON2, BANK(Music_Dungeon2) ; SeafoamIslands2 + db MUSIC_DUNGEON2, BANK(Music_Dungeon2) ; SeafoamIslands3 + db MUSIC_DUNGEON2, BANK(Music_Dungeon2) ; SeafoamIslands4 + db MUSIC_DUNGEON2, BANK(Music_Dungeon2) ; SeafoamIslands5 + db MUSIC_CITIES2, BANK(Music_Cities2) ; VermilionHouse2 + db MUSIC_CITIES2, BANK(Music_Cities2) ; FuchsiaHouse3 + db MUSIC_CINNABAR_MANSION, BANK(Music_CinnabarMansion) ; Mansion1 + db MUSIC_GYM, BANK(Music_Gym) ; CinnabarGym + db MUSIC_CINNABAR, BANK(Music_Cinnabar) ; Lab1 + db MUSIC_CINNABAR, BANK(Music_Cinnabar) ; Lab2 + db MUSIC_CINNABAR, BANK(Music_Cinnabar) ; Lab3 + db MUSIC_CINNABAR, BANK(Music_Cinnabar) ; Lab4 + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; CinnabarPokecenter + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; CinnabarMart + db MUSIC_CINNABAR, BANK(Music_Cinnabar) + db MUSIC_INDIGO_PLATEAU, BANK(Music_IndigoPlateau) ; IndigoPlateauLobby + db MUSIC_CITIES1, BANK(Music_Cities1) ; CopycatsHouseF1 + db MUSIC_CITIES1, BANK(Music_Cities1) ; CopycatsHouseF2 + db MUSIC_CITIES1, BANK(Music_Cities1) ; FightingDojo + db MUSIC_GYM, BANK(Music_Gym) ; SaffronGym + db MUSIC_CITIES1, BANK(Music_Cities1) ; SaffronHouse1 + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; SaffronMart + db MUSIC_SILPH_CO, BANK(Music_SilphCo) ; SilphCo1 + db MUSIC_POKECENTER, BANK(Music_Pokecenter) ; SaffronPokecenter + db MUSIC_CITIES1, BANK(Music_Cities1) ; SaffronHouse2 + db MUSIC_CITIES1, BANK(Music_Cities1) ; Route15Gate + db MUSIC_CITIES1, BANK(Music_Cities1) ; Route15GateUpstairs + db MUSIC_CITIES1, BANK(Music_Cities1) ; Route16GateMap + db MUSIC_CITIES1, BANK(Music_Cities1) ; Route16GateUpstairs + db MUSIC_CELADON, BANK(Music_Celadon) ; Route16House + db MUSIC_CELADON, BANK(Music_Celadon) ; Route12House + db MUSIC_CITIES1, BANK(Music_Cities1) ; Route18Gate + db MUSIC_CITIES1, BANK(Music_Cities1) ; Route18GateUpstairs + db MUSIC_DUNGEON2, BANK(Music_Dungeon2) ; SeafoamIslands1 + db MUSIC_DUNGEON2, BANK(Music_Dungeon2) ; Route22Gate + db MUSIC_DUNGEON3, BANK(Music_Dungeon3) ; VictoryRoad2 + db MUSIC_CITIES1, BANK(Music_Cities1) ; Route12GateUpstairs + db MUSIC_VERMILION, BANK(Music_Vermilion) ; VermilionHouse3 + db MUSIC_DUNGEON2, BANK(Music_Dungeon2) ; DiglettsCave + db MUSIC_DUNGEON3, BANK(Music_Dungeon3) ; VictoryRoad3 + db MUSIC_DUNGEON1, BANK(Music_Dungeon1) ; RocketHideout1 + db MUSIC_DUNGEON1, BANK(Music_Dungeon1) ; RocketHideout2 + db MUSIC_DUNGEON1, BANK(Music_Dungeon1) ; RocketHideout3 + db MUSIC_DUNGEON1, BANK(Music_Dungeon1) ; RocketHideout4 + db MUSIC_DUNGEON1, BANK(Music_Dungeon1) ; RocketHideoutElevator + db MUSIC_DUNGEON1, BANK(Music_Dungeon1) + db MUSIC_DUNGEON1, BANK(Music_Dungeon1) + db MUSIC_DUNGEON1, BANK(Music_Dungeon1) + db MUSIC_SILPH_CO, BANK(Music_SilphCo) ; SilphCo2 + db MUSIC_SILPH_CO, BANK(Music_SilphCo) ; SilphCo3 + db MUSIC_SILPH_CO, BANK(Music_SilphCo) ; SilphCo4 + db MUSIC_SILPH_CO, BANK(Music_SilphCo) ; SilphCo5 + db MUSIC_SILPH_CO, BANK(Music_SilphCo) ; SilphCo6 + db MUSIC_SILPH_CO, BANK(Music_SilphCo) ; SilphCo7 + db MUSIC_SILPH_CO, BANK(Music_SilphCo) ; SilphCo8 + db MUSIC_CINNABAR_MANSION, BANK(Music_CinnabarMansion) ; Mansion2 + db MUSIC_CINNABAR_MANSION, BANK(Music_CinnabarMansion) ; Mansion3 + db MUSIC_CINNABAR_MANSION, BANK(Music_CinnabarMansion) ; Mansion4 + db MUSIC_SAFARI_ZONE, BANK(Music_SafariZone) ; SafariZoneEast + db MUSIC_SAFARI_ZONE, BANK(Music_SafariZone) ; SafariZoneNorth + db MUSIC_SAFARI_ZONE, BANK(Music_SafariZone) ; SafariZoneWest + db MUSIC_SAFARI_ZONE, BANK(Music_SafariZone) ; SafariZoneCenter + db MUSIC_SAFARI_ZONE, BANK(Music_SafariZone) ; SafariZoneRestHouse1 + db MUSIC_SAFARI_ZONE, BANK(Music_SafariZone) ; SafariZoneSecretHouse + db MUSIC_SAFARI_ZONE, BANK(Music_SafariZone) ; SafariZoneRestHouse2 + db MUSIC_SAFARI_ZONE, BANK(Music_SafariZone) ; SafariZoneRestHouse3 + db MUSIC_SAFARI_ZONE, BANK(Music_SafariZone) ; SafariZoneRestHouse4 + db MUSIC_DUNGEON1, BANK(Music_Dungeon1) ; UnknownDungeon2 + db MUSIC_DUNGEON1, BANK(Music_Dungeon1) ; UnknownDungeon3 + db MUSIC_DUNGEON1, BANK(Music_Dungeon1) ; UnknownDungeon1 + db MUSIC_CITIES2, BANK(Music_Cities2) ; NameRater + db MUSIC_CITIES1, BANK(Music_Cities1) ; CeruleanHouse2 + db MUSIC_CINNABAR, BANK(Music_Cinnabar) + db MUSIC_DUNGEON3, BANK(Music_Dungeon3) ; RockTunnel2 + db MUSIC_SILPH_CO, BANK(Music_SilphCo) ; SilphCo9 + db MUSIC_SILPH_CO, BANK(Music_SilphCo) ; SilphCo10 + db MUSIC_SILPH_CO, BANK(Music_SilphCo) ; SilphCo11 + db MUSIC_SILPH_CO, BANK(Music_SilphCo) ; SilphCoElevator + db MUSIC_SILPH_CO, BANK(Music_SilphCo) + db MUSIC_SILPH_CO, BANK(Music_SilphCo) + db MUSIC_CELADON, BANK(Music_Celadon) ; BattleCenterM + db MUSIC_CELADON, BANK(Music_Celadon) ; TradeCenterM + db MUSIC_SILPH_CO, BANK(Music_SilphCo) + db MUSIC_SILPH_CO, BANK(Music_SilphCo) + db MUSIC_SILPH_CO, BANK(Music_SilphCo) + db MUSIC_SILPH_CO, BANK(Music_SilphCo) + db MUSIC_GYM, BANK(Music_Gym) ; Lorelei + db MUSIC_DUNGEON1, BANK(Music_Dungeon1) ; Bruno + db MUSIC_POKEMON_TOWER, BANK(Music_PokemonTower) ; Agatha ; see also MapHeaderPointers MapHeaderBanks: ; c23d (3:423d) @@ -36146,7 +33977,7 @@ PalletTownScript0: ; 18e81 (6:4e81) call PlaySound ; stop music ld a, BANK(Music_MeetProfOak) ld c,a ; song bank - ld a, (Music_MeetProfOak - $4000) / 3 ; “oak appears” music + ld a, MUSIC_MEET_PROF_OAK ; “oak appears” music call PlayMusic ; plays music ld a,$FC ld [wJoypadForbiddenButtonsMask],a @@ -37070,7 +34901,7 @@ CeruleanCityScript0: ; 194c8 (6:54c8) call PlaySound .asm_19512 ld c, BANK(Music_MeetRival) - ld a, (Music_MeetRival - $4000) / 3 + ld a, MUSIC_MEET_RIVAL call PlayMusic xor a ld [H_CURRENTPRESSEDBUTTONS], a @@ -40348,7 +38179,7 @@ OaksLabScript10: ; 1cd6d (7:4d6d) ld a, $8 ld [$d528], a ld c, BANK(Music_MeetRival) - ld a, (Music_MeetRival - $4000) / 3 + ld a, MUSIC_MEET_RIVAL call PlayMusic ; play music ld a, $f ld [$ff00+$8c], a @@ -42334,7 +40165,7 @@ VermilionDock_1db9b: ; 1db9b (7:5b9b) ld [$c0ee], a call PlaySound ld c, BANK(Music_Surfing) - ld a, (Music_Surfing - $4000) / 3 + ld a, MUSIC_SURFING call PlayMusic ld b, BANK(Func_79fc0) ld hl, Func_79fc0 @@ -44509,2566 +42340,7 @@ OakLabEmailText: ; 1ecbd (7:6cbd) TX_FAR _OakLabEmailText db "@" -SECTION "bank8",ROMX,BANK[$8] - -INCLUDE "music/headers/sfxheaders08.asm" -INCLUDE "music/headers/musicheaders08.asm" - -INCLUDE "music/sfx/sfx_08_01.asm" -INCLUDE "music/sfx/sfx_08_02.asm" -INCLUDE "music/sfx/sfx_08_03.asm" -INCLUDE "music/sfx/sfx_08_04.asm" -INCLUDE "music/sfx/sfx_08_05.asm" -INCLUDE "music/sfx/sfx_08_06.asm" -INCLUDE "music/sfx/sfx_08_07.asm" -INCLUDE "music/sfx/sfx_08_08.asm" -INCLUDE "music/sfx/sfx_08_09.asm" -INCLUDE "music/sfx/sfx_08_0a.asm" -INCLUDE "music/sfx/sfx_08_0b.asm" -INCLUDE "music/sfx/sfx_08_0c.asm" -INCLUDE "music/sfx/sfx_08_0d.asm" -INCLUDE "music/sfx/sfx_08_0e.asm" -INCLUDE "music/sfx/sfx_08_0f.asm" -INCLUDE "music/sfx/sfx_08_10.asm" -INCLUDE "music/sfx/sfx_08_11.asm" -INCLUDE "music/sfx/sfx_08_12.asm" -INCLUDE "music/sfx/sfx_08_13.asm" - -Music8_Channel3DutyPointers: ; 20361 (8:4361) - dw Music8_Channel3Duty0 - dw Music8_Channel3Duty1 - dw Music8_Channel3Duty2 - dw Music8_Channel3Duty3 - dw Music8_Channel3Duty4 - dw SFX_08_40_Ch1 ; unused - dw SFX_08_40_Ch1 ; unused - dw SFX_08_40_Ch1 ; unused - dw SFX_08_40_Ch1 ; unused - -; these are the definitions for the channel 3 instruments -; each instrument definition is made up of 32 points (nibbles) that form -; the graph of the wave -; the current instrument is copied to $FF30 -Music8_Channel3Duty0: ; 20373 (8:4373) - db $02,$46,$8A,$CE,$FF,$FE,$ED,$DC,$CB,$A9,$87,$65,$44,$33,$22,$11 - -Music8_Channel3Duty1: ; 20383 (8:4383) - db $02,$46,$8A,$CE,$EF,$FF,$FE,$EE,$DD,$CB,$A9,$87,$65,$43,$22,$11 - -Music8_Channel3Duty2: ; 20393 (8:4393) - db $13,$69,$BD,$EE,$EE,$FF,$FF,$ED,$DE,$FF,$FF,$EE,$EE,$DB,$96,$31 - -Music8_Channel3Duty3: ; 203a3 (8:43a3) - db $02,$46,$8A,$CD,$EF,$FE,$DE,$FF,$EE,$DC,$BA,$98,$76,$54,$32,$10 - -Music8_Channel3Duty4: ; 203b3 (8:43b3) - db $01,$23,$45,$67,$8A,$CD,$EE,$F7,$7F,$EE,$DC,$A8,$76,$54,$32,$10 - -INCLUDE "music/sfx/sfx_08_40.asm" -INCLUDE "music/sfx/sfx_08_3f.asm" -INCLUDE "music/sfx/sfx_08_3c.asm" -INCLUDE "music/sfx/sfx_08_3d.asm" -INCLUDE "music/sfx/sfx_08_3e.asm" -INCLUDE "music/sfx/sfx_08_77.asm" -INCLUDE "music/sfx/sfx_08_41.asm" -INCLUDE "music/sfx/sfx_08_42.asm" -INCLUDE "music/sfx/sfx_08_43.asm" -INCLUDE "music/sfx/sfx_08_44.asm" -INCLUDE "music/sfx/sfx_08_45.asm" -INCLUDE "music/sfx/sfx_08_pokeflute_ch3.asm" -INCLUDE "music/sfx/sfx_08_47.asm" -INCLUDE "music/sfx/sfx_08_48.asm" -INCLUDE "music/sfx/sfx_08_49.asm" -INCLUDE "music/sfx/sfx_08_4a.asm" -INCLUDE "music/sfx/sfx_08_4b.asm" -INCLUDE "music/sfx/sfx_08_4c.asm" -INCLUDE "music/sfx/sfx_08_4d.asm" -INCLUDE "music/sfx/sfx_08_4e.asm" -INCLUDE "music/sfx/sfx_08_4f.asm" -INCLUDE "music/sfx/sfx_08_50.asm" -INCLUDE "music/sfx/sfx_08_51.asm" -INCLUDE "music/sfx/sfx_08_52.asm" -INCLUDE "music/sfx/sfx_08_53.asm" -INCLUDE "music/sfx/sfx_08_54.asm" -INCLUDE "music/sfx/sfx_08_55.asm" -INCLUDE "music/sfx/sfx_08_56.asm" -INCLUDE "music/sfx/sfx_08_57.asm" -INCLUDE "music/sfx/sfx_08_58.asm" -INCLUDE "music/sfx/sfx_08_59.asm" -INCLUDE "music/sfx/sfx_08_5a.asm" -INCLUDE "music/sfx/sfx_08_5b.asm" -INCLUDE "music/sfx/sfx_08_5c.asm" -INCLUDE "music/sfx/sfx_08_5d.asm" -INCLUDE "music/sfx/sfx_08_5e.asm" -INCLUDE "music/sfx/sfx_08_5f.asm" -INCLUDE "music/sfx/sfx_08_60.asm" -INCLUDE "music/sfx/sfx_08_61.asm" -INCLUDE "music/sfx/sfx_08_62.asm" -INCLUDE "music/sfx/sfx_08_63.asm" -INCLUDE "music/sfx/sfx_08_64.asm" -INCLUDE "music/sfx/sfx_08_65.asm" -INCLUDE "music/sfx/sfx_08_66.asm" -INCLUDE "music/sfx/sfx_08_67.asm" -INCLUDE "music/sfx/sfx_08_68.asm" -INCLUDE "music/sfx/sfx_08_69.asm" -INCLUDE "music/sfx/sfx_08_6a.asm" -INCLUDE "music/sfx/sfx_08_6b.asm" -INCLUDE "music/sfx/sfx_08_6c.asm" -INCLUDE "music/sfx/sfx_08_6d.asm" -INCLUDE "music/sfx/sfx_08_6e.asm" -INCLUDE "music/sfx/sfx_08_6f.asm" -INCLUDE "music/sfx/sfx_08_70.asm" -INCLUDE "music/sfx/sfx_08_71.asm" -INCLUDE "music/sfx/sfx_08_72.asm" -INCLUDE "music/sfx/sfx_08_73.asm" -INCLUDE "music/sfx/sfx_08_74.asm" -INCLUDE "music/sfx/sfx_08_75.asm" -INCLUDE "music/sfx/sfx_08_76.asm" -INCLUDE "music/sfx/sfx_08_unused.asm" -INCLUDE "music/sfx/sfx_08_1d.asm" -INCLUDE "music/sfx/sfx_08_37.asm" -INCLUDE "music/sfx/sfx_08_38.asm" -INCLUDE "music/sfx/sfx_08_25.asm" -INCLUDE "music/sfx/sfx_08_39.asm" -INCLUDE "music/sfx/sfx_08_17.asm" -INCLUDE "music/sfx/sfx_08_23.asm" -INCLUDE "music/sfx/sfx_08_24.asm" -INCLUDE "music/sfx/sfx_08_14.asm" -INCLUDE "music/sfx/sfx_08_22.asm" -INCLUDE "music/sfx/sfx_08_1a.asm" -INCLUDE "music/sfx/sfx_08_1b.asm" -INCLUDE "music/sfx/sfx_08_19.asm" -INCLUDE "music/sfx/sfx_08_1f.asm" -INCLUDE "music/sfx/sfx_08_20.asm" -INCLUDE "music/sfx/sfx_08_16.asm" -INCLUDE "music/sfx/sfx_08_21.asm" -INCLUDE "music/sfx/sfx_08_15.asm" -INCLUDE "music/sfx/sfx_08_1e.asm" -INCLUDE "music/sfx/sfx_08_1c.asm" -INCLUDE "music/sfx/sfx_08_18.asm" -INCLUDE "music/sfx/sfx_08_2d.asm" -INCLUDE "music/sfx/sfx_08_2a.asm" -INCLUDE "music/sfx/sfx_08_2f.asm" -INCLUDE "music/sfx/sfx_08_26.asm" -INCLUDE "music/sfx/sfx_08_27.asm" -INCLUDE "music/sfx/sfx_08_28.asm" -INCLUDE "music/sfx/sfx_08_32.asm" -INCLUDE "music/sfx/sfx_08_29.asm" -INCLUDE "music/sfx/sfx_08_2b.asm" -INCLUDE "music/sfx/sfx_08_30.asm" -INCLUDE "music/sfx/sfx_08_2e.asm" -INCLUDE "music/sfx/sfx_08_31.asm" -INCLUDE "music/sfx/sfx_08_2c.asm" -INCLUDE "music/sfx/sfx_08_33.asm" -INCLUDE "music/sfx/sfx_08_34.asm" -INCLUDE "music/sfx/sfx_08_35.asm" -INCLUDE "music/sfx/sfx_08_36.asm" - -Func_2136e: ; 2136e (8:536e) - ld a, [$d083] - cp $ff - jr z, .asm_2139b - bit 7, a - ret z - and $7f - jr nz, .asm_21383 - call Func_213a7 - ld a, $1e - jr .asm_21395 -.asm_21383 - cp $14 - jr nz, .asm_2138a - call Func_213ac -.asm_2138a - ld a, $86 - ld [$c02a], a - ld a, [$d083] - and $7f - dec a -.asm_21395 - set 7, a - ld [$d083], a - ret -.asm_2139b - xor a - ld [$d083], a - ld [$c02a], a - ld de, Unknown_213c4 ; $53c4 - jr asm_213af - -Func_213a7: ; 213a7 (8:53a7) - ld de, Unknown_213bc ; $53bc - jr asm_213af - -Func_213ac: ; 213ac (8:53ac) - ld de, Unknown_213c0 ; $53c0 -asm_213af: ; 213af (8:53af) - ld hl, $ff10 - ld c, $5 - xor a -.asm_213b5 - ld [hli], a - ld a, [de] - inc de - dec c - jr nz, .asm_213b5 - ret - -Unknown_213bc: ; 213bc (8:53bc) - db $A0,$E2,$50,$87 - -Unknown_213c0: ; 213c0 (8:53c0) - db $B0,$E2,$EE,$86 - -Unknown_213c4: ; 213c4 (8:53c4) - db $00,$00,$00,$80 - -Func_213c8: ; 213c8 (8:53c8) - xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $FF00+$ba - call SaveScreenTilesToBuffer2 - ld a, [$d5a2] - and a - jr nz, .asm_213f3 - ld a, [$d74b] - bit 5, a - jr z, .asm_213ea - ld a, [$d5a2] - and a - jr nz, .asm_213f3 - ld hl, wTileMap - ld b, $8 - ld c, $e - jr .asm_213fa -.asm_213ea - ld hl, wTileMap - ld b, $6 - ld c, $e - jr .asm_213fa -.asm_213f3 - ld hl, wTileMap - ld b, $a - ld c, $e -.asm_213fa - call TextBoxBorder - call UpdateSprites - ld a, $3 - ld [wMaxMenuItem], a ; $cc28 - ld a, [$d7f1] - bit 0, a - jr nz, .asm_21414 - FuncCoord 2, 2 ; $c3ca - ld hl, Coord - ld de, SomeonesPCText ; $548b - jr .asm_2141a -.asm_21414 - FuncCoord 2, 2 ; $c3ca - ld hl, Coord - ld de, BillsPCText ; $5497 -.asm_2141a - call PlaceString - FuncCoord 2, 4 ; $c3f2 - ld hl, Coord - ld de, W_PLAYERNAME ; $d158 - call PlaceString - ld l, c - ld h, b - ld de, PlayersPCText ; $54a0 - call PlaceString - ld a, [$d74b] - bit 5, a - jr z, .asm_21462 - FuncCoord 2, 6 ; $c41a - ld hl, Coord - ld de, OaksPCText ; $54a5 - call PlaceString - ld a, [$d5a2] - and a - jr z, .asm_2145a - ld a, $4 - ld [wMaxMenuItem], a ; $cc28 - FuncCoord 2, 8 ; $c442 - ld hl, Coord - ld de, PKMNLeaguePCText ; $54b2 - call PlaceString - FuncCoord 2, 10 ; $c46a - ld hl, Coord - ld de, LogOffPCText ; $54ba - jr .asm_2146d -.asm_2145a - FuncCoord 2, 8 ; $c442 - ld hl, Coord - ld de, LogOffPCText ; $54ba - jr .asm_2146d -.asm_21462 - ld a, $2 - ld [wMaxMenuItem], a ; $cc28 - FuncCoord 2, 6 ; $c41a - ld hl, Coord - ld de, LogOffPCText ; $54ba -.asm_2146d - call PlaceString - ld a, $3 - ld [wMenuWatchedKeys], a ; $cc29 - ld a, $2 - ld [wTopMenuItemY], a ; $cc24 - ld a, $1 - ld [wTopMenuItemX], a ; $cc25 - xor a - ld [wCurrentMenuItem], a ; $cc26 - ld [wLastMenuItem], a ; $cc2a - ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $FF00+$ba - ret - -SomeonesPCText: ; 2148b (8:548b) - db "SOMEONE's PC@" - -BillsPCText: ; 21497 (8:5497) - db "BILL's PC@" - -PlayersPCText: ; 214a0 (8:54a0) - db "'s PC@" - -OaksPCText: ; 214a5 (8:54a5) - db "PROF.OAK's PC@" - -PKMNLeaguePCText: ; 214b2 (8:54b2) - db $4a,"LEAGUE@" - -LogOffPCText: ; 214ba (8:54ba) - db "LOG OFF@" - -Func_214c2: ; 214c2 (8:54c2) -BillsPC_: ; 0x214c2 - ld hl, $d730 - set 6, [hl] - xor a - ld [$ccd3], a - inc a ; MONSTER_NAME - ld [W_LISTTYPE], a - call LoadHpBarAndStatusTilePatterns - ld a, [wListScrollOffset] ; $cc36 - push af - ld a, [wFlags_0xcd60] - bit 3, a - jr nz, BillsPCMenu - ld a, $99 - call PlaySound - ld hl, SwitchOnText - call PrintText - -Func_214e8: ; 214e8 (8:54e8) -BillsPCMenu: - ld a, [$ccd3] - ld [wCurrentMenuItem], a ; $cc26 - ld hl, $9780 - ld de, PokeballTileGraphics ; $697e - ld bc, (BANK(PokeballTileGraphics) << 8) + $01 - call CopyVideoData - call LoadScreenTilesFromBuffer2DisableBGTransfer - ld hl, wTileMap - ld b, $a - ld c, $c - call TextBoxBorder - FuncCoord 2, 2 ; $c3ca - ld hl, Coord - ld de, BillsPCMenuText ; $56e1 - call PlaceString - ld hl, wTopMenuItemY ; $cc24 - ld a, $2 - ld [hli], a - dec a - ld [hli], a - inc hl - inc hl - ld a, $4 - ld [hli], a - ld a, $3 - ld [hli], a - xor a - ld [hli], a - ld [hli], a - ld hl, wListScrollOffset ; $cc36 - ld [hli], a - ld [hl], a - ld [wPlayerMonNumber], a ; $cc2f - ld hl, WhatText - call PrintText - FuncCoord 9, 14 ; $c4c1 - ld hl, Coord - ld b, $2 - ld c, $9 - call TextBoxBorder - ld a, [$d5a0] - and $7f - cp $9 - jr c, .asm_2154f - sub $9 - FuncCoord 17, 16 ; $c4f1 - ld hl, Coord - ld [hl], $f7 - add $f6 - jr .asm_21551 -.asm_2154f - add $f7 -.asm_21551 - FuncCoord 18, 16 ; $c4f2 - ld [Coord], a - FuncCoord 10, 16 ; $c4ea - ld hl, Coord - ld de, BoxNoPCText ; $5713 - call PlaceString - ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $FF00+$ba - call Delay3 - call HandleMenuInput - bit 1, a - jp nz, Func_21588 ; b button - call PlaceUnfilledArrowMenuCursor - ld a, [wCurrentMenuItem] ; $cc26 - ld [$ccd3], a - and a - jp z, Func_21618 ; withdraw - cp $1 - jp z, Func_215ac ; deposit - cp $2 - jp z, Func_21673 ; release - cp $3 - jp z, Func_216b3 ; change box - -Func_21588: ; 21588 (8:5588) - ld a, [wFlags_0xcd60] - bit 3, a - jr nz, .asm_2159a - call LoadTextBoxTilePatterns - ld a, $9a - call PlaySound - call WaitForSoundToFinish -.asm_2159a - ld hl, wFlags_0xcd60 - res 5, [hl] - call LoadScreenTilesFromBuffer2 - pop af - ld [wListScrollOffset], a ; $cc36 - ld hl, $d730 - res 6, [hl] - ret - -Func_215ac: ; 215ac (8:55ac) -BillsPCDeposit: - ld a, [W_NUMINPARTY] ; $d163 - dec a - jr nz, .asm_215bb - ld hl, CantDepositLastMonText - call PrintText - jp BillsPCMenu -.asm_215bb - ld a, [W_NUMINBOX] ; $da80 - cp $14 - jr nz, .asm_215cb - ld hl, BoxFullText ; $5802 - call PrintText - jp BillsPCMenu -.asm_215cb - ld hl, W_NUMINPARTY ; $d163 - call Func_216be - jp c, BillsPCMenu - call Func_2174b - jp nc, BillsPCMenu - ld a, [$cf91] - call GetCryData - call PlaySoundWaitForCurrent - ld a, $1 - ld [$cf95], a - call Func_3a68 - xor a - ld [$cf95], a - call RemovePokemon - call WaitForSoundToFinish - ld hl, wWhichTrade ; $cd3d - ld a, [$d5a0] - and $7f - cp $9 - jr c, .asm_2160a - sub $9 - ld [hl], $f7 - inc hl - add $f6 - jr .asm_2160c -.asm_2160a - add $f7 -.asm_2160c - ld [hli], a - ld [hl], $50 - ld hl, MonWasStoredText ; $57f8 - call PrintText - jp BillsPCMenu - -Func_21618: ; 21618 (8:5618) - ld a, [W_NUMINBOX] ; $da80 - and a - jr nz, .asm_21627 - ld hl, NoMonText ; $580c - call PrintText - jp Func_214e8 -.asm_21627 - ld a, [W_NUMINPARTY] ; $d163 - cp $6 - jr nz, .asm_21637 - ld hl, CantTakeMonText ; $5811 - call PrintText - jp Func_214e8 -.asm_21637 - ld hl, W_NUMINBOX ; $da80 - call Func_216be - jp c, Func_214e8 - call Func_2174b - jp nc, Func_214e8 - ld a, [wWhichPokemon] ; $cf92 - ld hl, W_BOXMON1NAME - call GetPartyMonName - ld a, [$cf91] - call GetCryData - call PlaySoundWaitForCurrent - xor a - ld [$cf95], a - call Func_3a68 - ld a, $1 - ld [$cf95], a - call RemovePokemon - call WaitForSoundToFinish - ld hl, MonIsTakenOutText ; $5807 - call PrintText - jp Func_214e8 - -Func_21673: ; 21673 (8:5673) - ld a, [W_NUMINBOX] ; $da80 - and a - jr nz, .asm_21682 - ld hl, NoMonText ; $580c - call PrintText - jp Func_214e8 -.asm_21682 - ld hl, W_NUMINBOX ; $da80 - call Func_216be - jp c, Func_214e8 - ld hl, OnceReleasedText ; $581b - call PrintText - call YesNoChoice - ld a, [wCurrentMenuItem] ; $cc26 - and a - jr nz, .asm_21682 - inc a - ld [$cf95], a - call RemovePokemon - call WaitForSoundToFinish - ld a, [$cf91] - call PlayCry - ld hl, MonWasReleasedText ; $5820 - call PrintText - jp Func_214e8 - -Func_216b3: ; 216b3 (8:56b3) - ld b, BANK(Func_738a1) - ld hl, Func_738a1 - call Bankswitch ; indirect jump to Func_738a1 (738a1 (1c:78a1)) - jp Func_214e8 - -Func_216be: ; 216be (8:56be) - ld a, l - ld [$cf8b], a - ld a, h - ld [$cf8c], a - xor a - ld [$cf93], a - ld [wListMenuID], a ; $cf94 - inc a ; MONSTER_NAME - ld [W_LISTTYPE], a - ld a, [$cc2b] - ld [wCurrentMenuItem], a ; $cc26 - call DisplayListMenuID - ld a, [wCurrentMenuItem] ; $cc26 - ld [$cc2b], a - ret - -BillsPCMenuText: ; 216e1 (8:56e1) - db "WITHDRAW ",$4a,$4e,"DEPOSIT ",$4a,$4e,"RELEASE ",$4a,$4e,"CHANGE BOX",$4e,"SEE YA!@" - -BoxNoPCText: ; 21713 (8:5713) - db "BOX No.@" - -Func_2171b: ; 2171b (8:571b) - ld hl, $d173 - ld bc, $002c - jr .asm_21729 ; 0x21721 $6 - ld hl, $da9e - ld bc, $0021 -.asm_21729 - ld a, [wWhichPokemon] - call AddNTimes - ld b, $4 -.asm_21731 - ld a, [hli] - push hl - push bc - ld hl, HMMoveArray ; $5745 - ld de, $0001 - call IsInArray - pop bc - pop hl - ret c - dec b - jr nz, .asm_21731 ; 0x21741 $ee - and a - ret - -HMMoveArray: ; 21745 (8:5745) - db CUT - db FLY - db SURF - db STRENGTH - db FLASH - db $ff - -Func_2174b: ; 2174b (8:574b) - FuncCoord 9, 10 ; $c471 - ld hl, Coord - ld b, $6 - ld c, $9 - call TextBoxBorder - ld a, [$ccd3] - and a - ld de, DepositPCText ; $57cb - jr nz, .asm_21761 - ld de, WithdrawPCText ; $57d3 -.asm_21761 - FuncCoord 11, 12 ; $c49b - ld hl, Coord - call PlaceString - FuncCoord 11, 14 ; $c4c3 - ld hl, Coord - ld de, StatsCancelPCText ; $57dc - call PlaceString - ld hl, wTopMenuItemY ; $cc24 - ld a, $c - ld [hli], a - ld a, $a - ld [hli], a - xor a - ld [hli], a - inc hl - ld a, $2 - ld [hli], a - ld a, $3 - ld [hli], a - xor a - ld [hl], a - ld hl, wListScrollOffset ; $cc36 - ld [hli], a - ld [hl], a - ld [wPlayerMonNumber], a ; $cc2f - ld [$cc2b], a -.asm_2178f - call HandleMenuInput - bit 1, a - jr nz, .asm_2179f - ld a, [wCurrentMenuItem] ; $cc26 - and a - jr z, .asm_217a1 - dec a - jr z, .asm_217a3 -.asm_2179f - and a - ret -.asm_217a1 - scf - ret -.asm_217a3 - call SaveScreenTilesToBuffer1 - ld a, [$ccd3] - and a - ld a, $0 - jr nz, .asm_217b0 - ld a, $2 -.asm_217b0 - ld [$cc49], a - ld a, $36 - call Predef ; indirect jump to StatusScreen (12953 (4:6953)) - ld a, $37 - call Predef ; indirect jump to StatusScreen2 (12b57 (4:6b57)) - call LoadScreenTilesFromBuffer1 - call ReloadTilesetTilePatterns - call GoPAL_SET_CF1C - call LoadGBPal - jr .asm_2178f - -DepositPCText: ; 217cb (8:57cb) - db "DEPOSIT@" - -WithdrawPCText: ; 217d3 (8:57d3) - db "WITHDRAW@" - -StatsCancelPCText: ; 217dc (8:57dc) - db "STATS",$4e,"CANCEL@" - -SwitchOnText: ; 0x217e9 - TX_FAR _SwitchOnText - db "@" - -WhatText: ; 0x217ee - TX_FAR _WhatText - db "@" - -DepositWhichMonText: ; 0x217f3 - TX_FAR _DepositWhichMonText - db "@" - -MonWasStoredText: ; 0x217f8 - TX_FAR _MonWasStoredText - db "@" - -CantDepositLastMonText: ; 0x217fd - TX_FAR _CantDepositLastMonText - db "@" - -BoxFullText: ; 0x21802 - TX_FAR _BoxFullText - db "@" - -MonIsTakenOutText: ; 0x21807 - TX_FAR _MonIsTakenOutText - db "@" - -NoMonText: ; 0x2180c - TX_FAR _NoMonText - db "@" - -CantTakeMonText: ; 0x21811 - TX_FAR _CantTakeMonText - db "@" - -ReleaseWhichMonText: ; 0x21816 - TX_FAR _ReleaseWhichMonText - db "@" - -OnceReleasedText: ; 0x2181b - TX_FAR _OnceReleasedText - db "@" - -MonWasReleasedText: ; 0x21820 - TX_FAR _MonWasReleasedText - db "@" - -Func_21825: ; 5824 (8:5825) - ld a, [$ff00+$aa] - cp $1 - ret z - ld a, [$c109] - cp $c - ret nz - ld a, [W_CURMAP] - cp $ef - ld a, $2 - jr z, .asm_2183a - inc a -.asm_2183a - ld [$d12b], a - call EnableAutoTextBoxDrawing - ld a, $22 - jp Func_3ef5 - -Func_21845: ; 5845 (8:5845) - ld a, [$ff00+$aa] - cp $2 - ret z - ld a, [$c109] - cp $8 - ret nz - ld a, [W_CURMAP] - cp $ef - ld a, $2 - jr z, .asm_2185a - inc a -.asm_2185a - ld [$d12b], a - call EnableAutoTextBoxDrawing - ld a, $22 - jp Func_3ef5 - -UnnamedText_21865: ; 21865 (8:5865) - TX_FAR _UnnamedText_21865 - db "@" - - ld a, [$c109] - cp $4 - ret nz - call EnableAutoTextBoxDrawing - ld a, $23 - jp Func_3ef5 - -Unknown_21878: ; 21878 (8:5878) - db $FD - -Func_21879: ; 21879 (8:5879) - ld c, CH0 -.loop - ld b, $0 - ld hl, $c026 - add hl, bc - ld a, [hl] - and a - jr z, .nextChannel - ld a, c - cp CH4 - jr nc, .applyAffects ; if sfx channel - ld a, [$c002] - and a - jr z, .applyAffects - bit 7, a - jr nz, .nextChannel - set 7, a - ld [$c002], a - xor a - ld [$FF00+$25], a - ld [$FF00+$1a], a - ld a, $80 - ld [$FF00+$1a], a - jr .nextChannel -.applyAffects - call Music8_ApplyMusicAffects -.nextChannel - ld a, c - inc c - cp CH7 - jr nz, .loop - ret - -; this routine checks flags for music effects currently applied -; to the channel and calls certain functions based on flags. -; known flags for $c02e: -; 1: call has been used -; 3: a toggle used only by this routine for vibrato -; 4: pitchbend flag -; 6: dutycycle flag -Music8_ApplyMusicAffects: ; 218ae (8:58ae) - ld b, $0 - ld hl, $c0b6 ; delay unitl next note - add hl, bc - ld a, [hl] - cp $1 ; if the delay is 1, play next note - jp z, Music8_PlayNextNote - dec a ; otherwise, decrease the delay timer - ld [hl], a - ld a, c - cp CH4 - jr nc, .startChecks ; if a sfx channel - ld hl, $c02a - add hl, bc - ld a, [hl] - and a - jr z, .startChecks - ret -.startChecks - ld hl, $c02e - add hl, bc - bit 6, [hl] ; dutycycle - jr z, .checkForExecuteMusic - call Music8_ApplyDutyCycle -.checkForExecuteMusic - ld b, $0 - ld hl, $c036 - add hl, bc - bit 0, [hl] - jr nz, .checkForPitchBend - ld hl, $c02e - add hl, bc - bit 2, [hl] - jr nz, .disablePitchBendVibrato -.checkForPitchBend - ld hl, $c02e - add hl, bc - bit 4, [hl] ; pitchbend - jr z, .checkVibratoDelay - jp Music8_ApplyPitchBend -.checkVibratoDelay - ld hl, $c04e ; vibrato delay - add hl, bc - ld a, [hl] - and a ; check if delay is over - jr z, .checkForVibrato - dec [hl] ; otherwise, dec delay -.disablePitchBendVibrato - ret -.checkForVibrato - ld hl, $c056 ; vibrato rate - add hl, bc - ld a, [hl] - and a - jr nz, .vibrato - ret ; no vibrato -.vibrato - ld d, a - ld hl, $c05e - add hl, bc - ld a, [hl] - and $f - and a - jr z, .vibratoAlreadyDone - dec [hl] ; apply vibrato pitch change - ret -.vibratoAlreadyDone - ld a, [hl] - swap [hl] - or [hl] - ld [hl], a ; reset the vibrato value and start again - ld hl, $c066 - add hl, bc - ld e, [hl] ; get note pitch - ld hl, $c02e - add hl, bc - bit 3, [hl] ; this is the only code that sets/resets bit three so - jr z, .unset ; it continuously alternates which path it takes - res 3, [hl] - ld a, d - and $f - ld d, a - ld a, e - sub d - jr nc, .noCarry - ld a, $0 -.noCarry - jr .done -.unset - set 3, [hl] - ld a, d - and $f0 - swap a - add e - jr nc, .done - ld a, $ff -.done - ld d, a - ld b, $3 - call Func_21ff7 - ld [hl], d - ret - -; this routine executes all music commands that take up no time, -; like tempo changes, duty changes etc. and doesn't return -; until the first note is reached -Music8_PlayNextNote: ; 21946 (8:5946) - ld hl, $c06e - add hl, bc - ld a, [hl] - ld hl, $c04e - add hl, bc - ld [hl], a - ld hl, $c02e - add hl, bc - res 4, [hl] - res 5, [hl] - ld a, c - cp CH4 - jr nz, .beginChecks - ld a, [$d083] - bit 7, a - ret nz -.beginChecks - call Music8_endchannel - ret -Music8_endchannel: ; 21967 (8:5967) - call Music8_GetNextMusicByte - ld d, a - cp $ff ; is this command an endchannel? - jp nz, Music8_callchannel ; no - ld b, $0 ; yes - ld hl, $c02e - add hl, bc - bit 1, [hl] - jr nz, .returnFromCall - ld a, c - cp CH3 - jr nc, .noiseOrSfxChannel - jr .asm_219c0 -.noiseOrSfxChannel - res 2, [hl] - ld hl, $c036 - add hl, bc - res 0, [hl] - cp CH6 - jr nz, .notSfxChannel3 - ld a, $0 - ld [$FF00+$1a], a - ld a, $80 - ld [$FF00+$1a], a -.notSfxChannel3 - jr nz, .asm_219a3 - ld a, [$c003] - and a - jr z, .asm_219a3 - xor a - ld [$c003], a - jr .asm_219c0 -.asm_219a3 - jr .asm_219c9 -.returnFromCall - res 1, [hl] - ld d, $0 - ld a, c - add a - ld e, a - ld hl, $c006 - add hl, de - push hl ; store current channel address - ld hl, $c016 - add hl, de - ld e, l - ld d, h - pop hl - ld a, [de] - ld [hli], a - inc de - ld a, [de] - ld [hl], a ; loads channel address to return to - jp Music8_endchannel -.asm_219c0 - ld hl, Unknown_222de - add hl, bc - ld a, [$FF00+$25] - and [hl] - ld [$FF00+$25], a -.asm_219c9 - ld a, [$c02a] - cp $14 - jr nc, .asm_219d2 - jr .asm_219ef -.asm_219d2 - ld a, [$c02a] - cp $86 - jr z, .asm_219ef - jr c, .asm_219dd - jr .asm_219ef -.asm_219dd - ld a, c - cp CH4 - jr z, .asm_219e6 - call Func_21e6d - ret c -.asm_219e6 - ld a, [$c005] - ld [$FF00+$24], a - xor a - ld [$c005], a -.asm_219ef - ld hl, $c026 - add hl, bc - ld [hl], b - ret - -Music8_callchannel: ; 219f5 (8:59f5) - cp $fd ; is this command a callchannel? - jp nz, Music8_loopchannel ; no - call Music8_GetNextMusicByte ; yes - push af - call Music8_GetNextMusicByte - ld d, a - pop af - ld e, a - push de ; store pointer - ld d, $0 - ld a, c - add a - ld e, a - ld hl, $c006 - add hl, de - push hl - ld hl, $c016 - add hl, de - ld e, l - ld d, h - pop hl - ld a, [hli] - ld [de], a - inc de - ld a, [hld] - ld [de], a ; copy current channel address - pop de - ld [hl], e - inc hl - ld [hl], d ; overwrite current address with pointer - ld b, $0 - ld hl, $c02e - add hl, bc - set 1, [hl] ; set the call flag - jp Music8_endchannel - -Music8_loopchannel: ; 21a2a (8:5a2a) - cp $fe ; is this command a loopchannel? - jp nz, Music8_notetype ; no - call Music8_GetNextMusicByte ; yes - ld e, a - and a - jr z, .infiniteLoop - ld b, $0 - ld hl, $c0be - add hl, bc - ld a, [hl] - cp e - jr nz, .loopAgain - ld a, $1 ; if no more loops to make, - ld [hl], a - call Music8_GetNextMusicByte ; skip pointer - call Music8_GetNextMusicByte - jp Music8_endchannel -.loopAgain ; inc loop count - inc a - ld [hl], a - ; fall through -.infiniteLoop ; overwrite current address with pointer - call Music8_GetNextMusicByte - push af - call Music8_GetNextMusicByte - ld b, a - ld d, $0 - ld a, c - add a - ld e, a - ld hl, $c006 - add hl, de - pop af - ld [hli], a - ld [hl], b - jp Music8_endchannel - -Music8_notetype: ; 21a65 (8:5a65) - and $f0 - cp $d0 ; is this command a notetype? - jp nz, Music8_togglecall ; no - ld a, d ; yes - and $f - ld b, $0 - ld hl, $c0c6 - add hl, bc - ld [hl], a ; store low nibble as speed - ld a, c - cp CH3 - jr z, .noiseChannel ; noise channel has 0 params - call Music8_GetNextMusicByte - ld d, a - ld a, c - cp CH2 - jr z, .musicChannel3 - cp CH6 - jr nz, .notChannel3 - ld hl, $c0e7 - jr .sfxChannel3 -.musicChannel3 - ld hl, $c0e6 -.sfxChannel3 - ld a, d - and $f - ld [hl], a ; store low nibble of param as duty - ld a, d - and $30 - sla a - ld d, a - ; fall through - - ; if channel 3, store high nibble as volume - ; else, store volume (high nibble) and fade (low nibble) -.notChannel3 - ld b, $0 - ld hl, $c0de - add hl, bc - ld [hl], d -.noiseChannel - jp Music8_endchannel - -Music8_togglecall: ; 21aa4 (8:5aa4) - ld a, d - cp $e8 ; is this command an togglecall? - jr nz, Music8_vibrato ; no - ld b, $0 ; yes - ld hl, $c02e - add hl, bc - ld a, [hl] - xor $1 - ld [hl], a ; flip bit 0 of $c02e (toggle returning from call) - jp Music8_endchannel - -Music8_vibrato: ; 21ab6 (8:5ab6) - cp $ea ; is this command a vibrato? - jr nz, Music8_pitchbend ; no - call Music8_GetNextMusicByte ; yes - ld b, $0 - ld hl, $c04e - add hl, bc - ld [hl], a ; store delay - ld hl, $c06e - add hl, bc - ld [hl], a ; store delay - call Music8_GetNextMusicByte - ld d, a - and $f0 - swap a - ld b, $0 - ld hl, $c056 - add hl, bc - srl a - ld e, a - adc b - swap a - or e - ld [hl], a ; store rate as both high and low nibbles - ld a, d - and $f - ld d, a - ld hl, $c05e - add hl, bc - swap a - or d - ld [hl], a ; store depth as both high and low nibbles - jp Music8_endchannel - -Music8_pitchbend: ; 21aee (8:5aee) - cp $eb ; is this command a pitchbend? - jr nz, Music8_duty ; no - call Music8_GetNextMusicByte ; yes - ld b, $0 - ld hl, $c076 - add hl, bc - ld [hl], a ; store first param - call Music8_GetNextMusicByte - ld d, a - and $f0 - swap a - ld b, a - ld a, d - and $f - call Func_22017 - ld b, $0 - ld hl, $c0a6 - add hl, bc - ld [hl], d ; store unknown part of second param - ld hl, $c0ae - add hl, bc - ld [hl], e ; store unknown part of second param - ld b, $0 - ld hl, $c02e - add hl, bc - set 4, [hl] ; set pitchbend flag - call Music8_GetNextMusicByte - ld d, a - jp Music8_notelength - -Music8_duty: ; 21b26 (8:5b26) - cp $ec ; is this command a duty? - jr nz, Music8_tempo ; no - call Music8_GetNextMusicByte ; yes - rrca - rrca - and $c0 - ld b, $0 - ld hl, $c03e - add hl, bc - ld [hl], a ; store duty - jp Music8_endchannel - -Music8_tempo: ; 21b3b (8:5b3b) - cp $ed ; is this command a tempo? - jr nz, Music8_unknownmusic0xee ; no - ld a, c ; yes - cp CH4 - jr nc, .sfxChannel - call Music8_GetNextMusicByte - ld [$c0e8], a ; store first param - call Music8_GetNextMusicByte - ld [$c0e9], a ; store second param - xor a - ld [$c0ce], a ; clear RAM - ld [$c0cf], a - ld [$c0d0], a - ld [$c0d1], a - jr .musicChannelDone -.sfxChannel - call Music8_GetNextMusicByte - ld [$c0ea], a ; store first param - call Music8_GetNextMusicByte - ld [$c0eb], a ; store second param - xor a - ld [$c0d2], a ; clear RAM - ld [$c0d3], a - ld [$c0d4], a - ld [$c0d5], a -.musicChannelDone - jp Music8_endchannel - -Music8_unknownmusic0xee: ; 21b7b (8:5b7b) - cp $ee ; is this command an unknownmusic0xee? - jr nz, Music8_unknownmusic0xef ; no - call Music8_GetNextMusicByte ; yes - ld [$c004], a ; store first param - jp Music8_endchannel - -; this appears to never be used -Music8_unknownmusic0xef: ; 21b88 (8:5b88) - cp $ef ; is this command an unknownmusic0xef? - jr nz, Music8_dutycycle ; no - call Music8_GetNextMusicByte ; yes - push bc - call Func_22035 - pop bc - ld a, [$c003] - and a - jr nz, .skip - ld a, [$c02d] - ld [$c003], a - xor a - ld [$c02d], a -.skip - jp Music8_endchannel - -Music8_dutycycle: ; 21ba7 (8:5ba7) - cp $fc ; is this command a dutycycle? - jr nz, Music8_stereopanning ; no - call Music8_GetNextMusicByte ; yes - ld b, $0 - ld hl, $c046 - add hl, bc - ld [hl], a ; store full cycle - and $c0 - ld hl, $c03e - add hl, bc - ld [hl], a ; store first duty - ld hl, $c02e - add hl, bc - set 6, [hl] ; set dutycycle flag - jp Music8_endchannel - -Music8_stereopanning: ; 21bc5 (8:5bc5) - cp $f0 ; is this command a stereopanning? - jr nz, Music8_executemusic ; no - call Music8_GetNextMusicByte ; yes - ld [$FF00+$24], a - jp Music8_endchannel - -Music8_executemusic: ; 21bd1 (8:5bd1) - cp $f8 ; is this command an executemusic? - jr nz, Music8_octave ; no - ld b, $0 ; yes - ld hl, $c036 - add hl, bc - set 0, [hl] - jp Music8_endchannel - -Music8_octave: ; 21be0 (8:5be0) - and $f0 - cp $e0 ; is this command an octave? - jr nz, Music8_unknownsfx0x20 ; no - ld hl, $c0d6 ; yes - ld b, $0 - add hl, bc - ld a, d - and $f - ld [hl], a ; store low nibble as octave - jp Music8_endchannel - -Music8_unknownsfx0x20: ; 21bf3 - cp $20 ; is this command an unknownsfx0x20? - jr nz, Music8_unknownsfx0x10 ; no - ld a, c - cp CH3 ; is this a noise or sfx channel? - jr c, Music8_unknownsfx0x10 ; no - ld b, $0 - ld hl, $c036 - add hl, bc - bit 0, [hl] - jr nz, Music8_unknownsfx0x10 ; no - call Music8_notelength - ld d, a - ld b, $0 - ld hl, $c03e - add hl, bc - ld a, [hl] - or d - ld d, a - ld b, $1 - call Func_21ff7 - ld [hl], d - call Music8_GetNextMusicByte - ld d, a - ld b, $2 - call Func_21ff7 - ld [hl], d - call Music8_GetNextMusicByte - ld e, a - ld a, c - cp CH7 - ld a, $0 - jr z, .sfxNoiseChannel ; only two params for noise channel - push de - call Music8_GetNextMusicByte - pop de -.sfxNoiseChannel - ld d, a - push de - call Func_21daa - call Func_21d79 - pop de - call Func_21dcc - ret - -Music8_unknownsfx0x10: ; 21c40 (8:5c40) - ld a, c - cp CH4 - jr c, Music8_note ; if not a sfx - ld a, d - cp $10 ; is this command a unknownsfx0x10? - jr nz, Music8_note ; no - ld b, $0 - ld hl, $c036 - add hl, bc - bit 0, [hl] - jr nz, Music8_note ; no - call Music8_GetNextMusicByte ; yes - ld [$FF00+$10], a - jp Music8_endchannel - -Music8_note: ; 21c5c (8:5c5c) - ld a, c - cp CH3 - jr nz, Music8_notelength ; if not noise channel - ld a, d - and $f0 - cp $b0 ; is this command a dnote? - jr z, Music8_dnote ; yes - jr nc, Music8_notelength ; no - swap a - ld b, a - ld a, d - and $f - ld d, a - ld a, b - push de - push bc - jr asm_21c7e - -Music8_dnote: ; 21c76 (8:5c76) - ld a, d - and $f - push af - push bc - call Music8_GetNextMusicByte ; get dnote instrument -asm_21c7e - ld d, a - ld a, [$c003] - and a - jr nz, .asm_21c89 - ld a, d - call Func_22035 -.asm_21c89 - pop bc - pop de - -Music8_notelength: ; 21c8b (8:5c8b) - ld a, d - push af - and $f - inc a - ld b, $0 - ld e, a ; store note length (in 16ths) - ld d, b - ld hl, $c0c6 - add hl, bc - ld a, [hl] - ld l, b - call Func_22006 - ld a, c - cp CH4 - jr nc, .sfxChannel - ld a, [$c0e8] - ld d, a - ld a, [$c0e9] - ld e, a - jr .skip -.sfxChannel - ld d, $1 - ld e, $0 - cp CH7 - jr z, .skip ; if noise channel - call Func_21e2f - ld a, [$c0ea] - ld d, a - ld a, [$c0eb] - ld e, a -.skip - ld a, l - ld b, $0 - ld hl, $c0ce - add hl, bc - ld l, [hl] - call Func_22006 - ld e, l - ld d, h - ld hl, $c0ce - add hl, bc - ld [hl], e - ld a, d - ld hl, $c0b6 - add hl, bc - ld [hl], a - ld hl, $c036 - add hl, bc - bit 0, [hl] - jr nz, Music8_notepitch - ld hl, $c02e - add hl, bc - bit 2, [hl] - jr z, Music8_notepitch - pop hl - ret - -Music8_notepitch: ; 21ce9 (8:5ce9) - pop af - and $f0 - cp $c0 ; compare to rest - jr nz, .notRest - ld a, c - cp CH4 - jr nc, .sfxChannel - ld hl, $c02a - add hl, bc - ld a, [hl] - and a - jr nz, .done - ; fall through -.sfxChannel - ld a, c - cp CH2 - jr z, .musicChannel3 - cp CH6 - jr nz, .notSfxChannel3 -.musicChannel3 - ld b, $0 - ld hl, Unknown_222de - add hl, bc - ld a, [$FF00+$25] - and [hl] - ld [$FF00+$25], a - jr .done -.notSfxChannel3 - ld b, $2 - call Func_21ff7 - ld a, $8 - ld [hli], a - inc hl - ld a, $80 - ld [hl], a -.done - ret -.notRest - swap a - ld b, $0 - ld hl, $c0d6 - add hl, bc - ld b, [hl] - call Func_22017 - ld b, $0 - ld hl, $c02e - add hl, bc - bit 4, [hl] - jr z, .asm_21d39 - call Func_21f4e -.asm_21d39 - push de - ld a, c - cp CH4 - jr nc, .skip ; if sfx channel - ld hl, $c02a - ld d, $0 - ld e, a - add hl, de - ld a, [hl] - and a - jr nz, .asm_21d4c - jr .skip -.asm_21d4c - pop de - ret -.skip - ld b, $0 - ld hl, $c0de - add hl, bc - ld d, [hl] - ld b, $2 - call Func_21ff7 - ld [hl], d - call Func_21daa - call Func_21d79 - pop de - ld b, $0 - ld hl, $c02e - add hl, bc - bit 0, [hl] - jr z, .asm_21d70 - inc e - jr nc, .asm_21d70 - inc d -.asm_21d70 - ld hl, $c066 - add hl, bc - ld [hl], e - call Func_21dcc - ret - -Func_21d79: ; 21d79 (8:5d79) - ld b, $0 - ld hl, Unknown_222e6 - add hl, bc - ld a, [$FF00+$25] - or [hl] - ld d, a - ld a, c - cp CH7 - jr z, .sfxNoiseChannel - cp CH4 - jr nc, .skip ; if sfx channel - ld hl, $c02a - add hl, bc - ld a, [hl] - and a - jr nz, .skip -.sfxNoiseChannel - ld a, [$c004] - ld hl, Unknown_222e6 - add hl, bc - and [hl] - ld d, a - ld a, [$FF00+$25] - ld hl, Unknown_222de - add hl, bc - and [hl] - or d - ld d, a -.skip - ld a, d - ld [$FF00+$25], a - ret - -Func_21daa: ; 21daa (8:5daa) - ld b, $0 - ld hl, $c0b6 - add hl, bc - ld d, [hl] - ld a, c - cp CH2 - jr z, .channel3 ; if music channel 3 - cp CH6 - jr z, .channel3 ; if sfx channel 3 - ld a, d - and $3f - ld d, a - ld hl, $c03e - add hl, bc - ld a, [hl] - or d - ld d, a -.channel3 - ld b, $1 - call Func_21ff7 - ld [hl], d - ret - -Func_21dcc: ; 21dcc (8:5dcc) - ld a, c - cp CH2 - jr z, .channel3 - cp CH6 - jr nz, .notSfxChannel3 - ; fall through -.channel3 - push de - ld de, $c0e6 - cp CH2 - jr z, .musicChannel3 - ld de, $c0e7 -.musicChannel3 - ld a, [de] - add a - ld d, $0 - ld e, a - ld hl, Music8_Channel3DutyPointers - add hl, de - ld e, [hl] - inc hl - ld d, [hl] - ld hl, $ff30 - ld b, $f - ld a, $0 - ld [$FF00+$1a], a -.loop - ld a, [de] - inc de - ld [hli], a - ld a, b - dec b - and a - jr nz, .loop - ld a, $80 - ld [$FF00+$1a], a - pop de -.notSfxChannel3 - ld a, d - or $80 - and $c7 - ld d, a - ld b, $3 - call Func_21ff7 - ld [hl], e - inc hl - ld [hl], d - ld a, c - cp CH4 - jr c, .musicChannel - call Func_21e56 -.musicChannel - ret - -Func_21e19: ; 21e19 (8:5e19) - ld a, c - cp CH4 - jr nz, .asm_21e2e - ld a, [$d083] - bit 7, a - jr z, .asm_21e2e - xor a - ld [$c0f1], a - ld a, $80 - ld [$c0f2], a -.asm_21e2e - ret - -Func_21e2f: ; 21e2f (8:5e2f) - call Func_21e8b - jr c, .asm_21e39 - call Func_21e9f - jr nc, .asm_21e4c -.asm_21e39 - ld d, $0 - ld a, [$c0f2] - add $80 - jr nc, .asm_21e43 - inc d -.asm_21e43 - ld [$c0eb], a - ld a, d - ld [$c0ea], a - jr .asm_21e55 -.asm_21e4c - xor a - ld [$c0eb], a - ld a, $1 - ld [$c0ea], a -.asm_21e55 - ret - -Func_21e56: ; 21e56 (8:5e56) - call Func_21e8b - jr c, .asm_21e60 - call Func_21e9f - jr nc, .asm_21e6c -.asm_21e60 - ld a, [$c0f1] - add e - jr nc, .asm_21e67 - inc d -.asm_21e67 - dec hl - ld e, a - ld [hl], e - inc hl - ld [hl], d -.asm_21e6c - ret - -Func_21e6d: ; 21e6d (8:5e6d) - call Func_21e8b - jr nc, .asm_21e88 - ld hl, $c006 - ld e, c - ld d, $0 - sla e - rl d - add hl, de - ld a, [hl] - sub $1 - ld [hl], a - inc hl - ld a, [hl] - sbc $0 - ld [hl], a - scf - ret -.asm_21e88 - scf - ccf - ret - -Func_21e8b: ; 21e8b (8:5e8b) - ld a, [$c02a] - cp $14 - jr nc, .asm_21e94 - jr .asm_21e9a -.asm_21e94 - cp $86 - jr z, .asm_21e9a - jr c, .asm_21e9d -.asm_21e9a - scf - ccf - ret -.asm_21e9d - scf - ret - -Func_21e9f: ; 21e9f (8:5e9f) - ld a, [$c02d] - ld b, a - ld a, [$c02a] - or b - cp $9d - jr nc, .asm_21ead - jr .asm_21eb3 -.asm_21ead - cp $ea - jr z, .asm_21eb3 - jr c, .asm_21eb6 -.asm_21eb3 - scf - ccf - ret -.asm_21eb6 - scf - ret - -Music8_ApplyPitchBend: ; 21eb8 (8:5eb8) - ld hl, $c02e - add hl, bc - bit 5, [hl] - jp nz, .asm_21eff - ld hl, $c09e - add hl, bc - ld e, [hl] - ld hl, $c096 - add hl, bc - ld d, [hl] - ld hl, $c07e - add hl, bc - ld l, [hl] - ld h, b - add hl, de - ld d, h - ld e, l - ld hl, $c08e - add hl, bc - push hl - ld hl, $c086 - add hl, bc - ld a, [hl] - pop hl - add [hl] - ld [hl], a - ld a, $0 - adc e - ld e, a - ld a, $0 - adc d - ld d, a - ld hl, $c0a6 - add hl, bc - ld a, [hl] - cp d - jp c, .asm_21f45 - jr nz, .asm_21f32 - ld hl, $c0ae - add hl, bc - ld a, [hl] - cp e - jp c, .asm_21f45 - jr .asm_21f32 -.asm_21eff - ld hl, $c09e - add hl, bc - ld a, [hl] - ld hl, $c096 - add hl, bc - ld d, [hl] - ld hl, $c07e - add hl, bc - ld e, [hl] - sub e - ld e, a - ld a, d - sbc b - ld d, a - ld hl, $c086 - add hl, bc - ld a, [hl] - add a - ld [hl], a - ld a, e - sbc b - ld e, a - ld a, d - sbc b - ld d, a - ld hl, $c0a6 - add hl, bc - ld a, d - cp [hl] - jr c, .asm_21f45 - jr nz, .asm_21f32 - ld hl, $c0ae - add hl, bc - ld a, e - cp [hl] - jr c, .asm_21f45 -.asm_21f32 - ld hl, $c09e - add hl, bc - ld [hl], e - ld hl, $c096 - add hl, bc - ld [hl], d - ld b, $3 - call Func_21ff7 - ld a, e - ld [hli], a - ld [hl], d - ret -.asm_21f45 - ld hl, $c02e - add hl, bc - res 4, [hl] - res 5, [hl] - ret - -Func_21f4e: ; 21f4e (8:5f4e) - ld hl, $c096 - add hl, bc - ld [hl], d - ld hl, $c09e - add hl, bc - ld [hl], e - ld hl, $c0b6 - add hl, bc - ld a, [hl] - ld hl, $c076 - add hl, bc - sub [hl] - jr nc, .asm_21f66 - ld a, $1 -.asm_21f66 - ld [hl], a - ld hl, $c0ae - add hl, bc - ld a, e - sub [hl] - ld e, a - ld a, d - sbc b - ld hl, $c0a6 - add hl, bc - sub [hl] - jr c, .asm_21f82 - ld d, a - ld b, $0 - ld hl, $c02e - add hl, bc - set 5, [hl] - jr .asm_21fa5 -.asm_21f82 - ld hl, $c096 - add hl, bc - ld d, [hl] - ld hl, $c09e - add hl, bc - ld e, [hl] - ld hl, $c0ae - add hl, bc - ld a, [hl] - sub e - ld e, a - ld a, d - sbc b - ld d, a - ld hl, $c0a6 - add hl, bc - ld a, [hl] - sub d - ld d, a - ld b, $0 - ld hl, $c02e - add hl, bc - res 5, [hl] -.asm_21fa5 - ld hl, $c076 - add hl, bc -.asm_21fa9 - inc b - ld a, e - sub [hl] - ld e, a - jr nc, .asm_21fa9 - ld a, d - and a - jr z, .asm_21fb7 - dec a - ld d, a - jr .asm_21fa9 -.asm_21fb7 - ld a, e - add [hl] - ld d, b - ld b, $0 - ld hl, $c07e - add hl, bc - ld [hl], d - ld hl, $c086 - add hl, bc - ld [hl], a - ld hl, $c08e - add hl, bc - ld [hl], a - ret - -Music8_ApplyDutyCycle: ; 21fcc (8:5fcc) - ld b, $0 - ld hl, $c046 - add hl, bc - ld a, [hl] - rlca - rlca - ld [hl], a - and $c0 - ld d, a - ld b, $1 - call Func_21ff7 - ld a, [hl] - and $3f - or d - ld [hl], a - ret - -Music8_GetNextMusicByte: ; 21fe4 (8:5fe4) - ld d, $0 - ld a, c - add a - ld e, a - ld hl, $c006 - add hl, de - ld a, [hli] - ld e, a - ld a, [hld] - ld d, a - ld a, [de] ; get next music command - inc de - ld [hl], e ; store address of next command - inc hl - ld [hl], d - ret - -Func_21ff7: ; 21ff7 (8:5ff7) - ld a, c - ld hl, Unknown_222d6 - add l - jr nc, .noCarry - inc h -.noCarry - ld l, a - ld a, [hl] - add b - ld l, a - ld h, $ff - ret - -Func_22006: ; 22006 (8:6006) - ld h, $0 -.loop - srl a - jr nc, .noCarry - add hl, de -.noCarry - sla e - rl d - and a - jr z, .done - jr .loop -.done - ret - -Func_22017: ; 22017 (8:6017) - ld h, $0 - ld l, a - add hl, hl - ld d, h - ld e, l - ld hl, Unknown_222ee - add hl, de - ld e, [hl] - inc hl - ld d, [hl] - ld a, b -.loop - cp CH7 - jr z, .done - sra d - rr e - inc a - jr .loop -.done - ld a, $8 - add d - ld d, a - ret - -Func_22035: ; 22035 (8:6035) - ld [$c001], a - cp $ff - jp z, Func_221f3 - cp $e9 - jp z, Func_2210d - jp c, Func_2210d - cp $fe - jr z, .asm_2204c - jp nc, Func_2210d -.asm_2204c - xor a - ld [$c000], a - ld [$c003], a - ld [$c0e9], a - ld [$c0e6], a - ld [$c0e7], a - ld d, $8 - ld hl, $c016 - call FillMusicRAM8 - ld hl, $c006 - call FillMusicRAM8 - ld d, $4 - ld hl, $c026 - call FillMusicRAM8 - ld hl, $c02e - call FillMusicRAM8 - ld hl, $c03e - call FillMusicRAM8 - ld hl, $c046 - call FillMusicRAM8 - ld hl, $c04e - call FillMusicRAM8 - ld hl, $c056 - call FillMusicRAM8 - ld hl, $c05e - call FillMusicRAM8 - ld hl, $c066 - call FillMusicRAM8 - ld hl, $c06e - call FillMusicRAM8 - ld hl, $c036 - call FillMusicRAM8 - ld hl, $c076 - call FillMusicRAM8 - ld hl, $c07e - call FillMusicRAM8 - ld hl, $c086 - call FillMusicRAM8 - ld hl, $c08e - call FillMusicRAM8 - ld hl, $c096 - call FillMusicRAM8 - ld hl, $c09e - call FillMusicRAM8 - ld hl, $c0a6 - call FillMusicRAM8 - ld hl, $c0ae - call FillMusicRAM8 - ld a, $1 - ld hl, $c0be - call FillMusicRAM8 - ld hl, $c0b6 - call FillMusicRAM8 - ld hl, $c0c6 - call FillMusicRAM8 - ld [$c0e8], a - ld a, $ff - ld [$c004], a - xor a - ld [$FF00+$24], a - ld a, $8 - ld [$FF00+$10], a - ld a, $0 - ld [$FF00+$25], a - xor a - ld [$FF00+$1a], a - ld a, $80 - ld [$FF00+$1a], a - ld a, $77 - ld [$FF00+$24], a - jp Func_2224e - -Func_2210d: ; 2210d (8:610d) - ld l, a - ld e, a - ld h, $0 - ld d, h - add hl, hl - add hl, de - ld de, SFX_Headers_08 - add hl, de - ld a, h - ld [$c0ec], a - ld a, l - ld [$c0ed], a - ld a, [hl] - and $c0 - rlca - rlca - ld c, a -.asm_22126 - ld d, c - ld a, c - add a - add c - ld c, a - ld b, $0 - ld a, [$c0ec] - ld h, a - ld a, [$c0ed] - ld l, a - add hl, bc - ld c, d - ld a, [hl] - and $f - ld e, a - ld d, $0 - ld hl, $c026 - add hl, de - ld a, [hl] - and a - jr z, .asm_22162 - ld a, e - cp $7 - jr nz, .asm_22159 - ld a, [$c001] - cp $14 - jr nc, .asm_22152 - ret -.asm_22152 - ld a, [hl] - cp $14 - jr z, .asm_22162 - jr c, .asm_22162 -.asm_22159 - ld a, [$c001] - cp [hl] - jr z, .asm_22162 - jr c, .asm_22162 - ret -.asm_22162 - xor a - push de - ld h, d - ld l, e - add hl, hl - ld d, h - ld e, l - ld hl, $c016 - add hl, de - ld [hli], a - ld [hl], a - ld hl, $c006 - add hl, de - ld [hli], a - ld [hl], a - pop de - ld hl, $c026 - add hl, de - ld [hl], a - ld hl, $c02e - add hl, de - ld [hl], a - ld hl, $c03e - add hl, de - ld [hl], a - ld hl, $c046 - add hl, de - ld [hl], a - ld hl, $c04e - add hl, de - ld [hl], a - ld hl, $c056 - add hl, de - ld [hl], a - ld hl, $c05e - add hl, de - ld [hl], a - ld hl, $c066 - add hl, de - ld [hl], a - ld hl, $c06e - add hl, de - ld [hl], a - ld hl, $c076 - add hl, de - ld [hl], a - ld hl, $c07e - add hl, de - ld [hl], a - ld hl, $c086 - add hl, de - ld [hl], a - ld hl, $c08e - add hl, de - ld [hl], a - ld hl, $c096 - add hl, de - ld [hl], a - ld hl, $c09e - add hl, de - ld [hl], a - ld hl, $c0a6 - add hl, de - ld [hl], a - ld hl, $c0ae - add hl, de - ld [hl], a - ld hl, $c036 - add hl, de - ld [hl], a - ld a, $1 - ld hl, $c0be - add hl, de - ld [hl], a - ld hl, $c0b6 - add hl, de - ld [hl], a - ld hl, $c0c6 - add hl, de - ld [hl], a - ld a, e - cp $4 - jr nz, .asm_221ea - ld a, $8 - ld [$FF00+$10], a -.asm_221ea - ld a, c - and a - jp z, Func_2224e - dec c - jp .asm_22126 - -Func_221f3: ; 221f3 (8:61f3) - ld a, $80 - ld [$FF00+$26], a - ld [$FF00+$1a], a - xor a - ld [$FF00+$25], a - ld [$FF00+$1c], a - ld a, $8 - ld [$FF00+$10], a - ld [$FF00+$12], a - ld [$FF00+$17], a - ld [$FF00+$21], a - ld a, $40 - ld [$FF00+$14], a - ld [$FF00+$19], a - ld [$FF00+$23], a - ld a, $77 - ld [$FF00+$24], a - xor a - ld [$c000], a - ld [$c003], a - ld [$c002], a - ld [$c0e9], a - ld [$c0eb], a - ld [$c0e6], a - ld [$c0e7], a - ld d, $a0 - ld hl, $c006 - call FillMusicRAM8 - ld a, $1 - ld d, $18 - ld hl, $c0b6 - call FillMusicRAM8 - ld [$c0e8], a - ld [$c0ea], a - ld a, $ff - ld [$c004], a - ret - -; fills d bytes at hl with a -FillMusicRAM8: ; 22248 (8:6248) - ld b, d -.loop - ld [hli], a - dec b - jr nz, .loop - ret - -Func_2224e: ; 2224e (8:624e) - ld a, [$c001] - ld l, a - ld e, a - ld h, $0 - ld d, h - add hl, hl - add hl, de - ld de, SFX_Headers_08 - add hl, de - ld e, l - ld d, h - ld hl, $c006 - ld a, [de] ; get channel number - ld b, a - rlca - rlca - and $3 - ld c, a - ld a, b - and $f - ld b, c - inc b - inc de - ld c, $0 -.asm_22270 - cp c - jr z, .asm_22278 - inc c - inc hl - inc hl - jr .asm_22270 -.asm_22278 - push hl - push bc - push af - ld b, $0 - ld c, a - ld hl, $c026 - add hl, bc - ld a, [$c001] - ld [hl], a - pop af - cp $3 - jr c, .asm_22291 - ld hl, $c02e - add hl, bc - set 2, [hl] -.asm_22291 - pop bc - pop hl - ld a, [de] ; get channel pointer - ld [hli], a - inc de - ld a, [de] - ld [hli], a - inc de - inc c - dec b - ld a, b - and a - ld a, [de] - inc de - jr nz, .asm_22270 - ld a, [$c001] - cp $14 - jr nc, .asm_222aa - jr .asm_222d4 -.asm_222aa - ld a, [$c001] - cp $86 - jr z, .asm_222d4 - jr c, .asm_222b5 - jr .asm_222d4 -.asm_222b5 - ld hl, $c02a - ld [hli], a - ld [hli], a - ld [hli], a - ld [hl], a - ld hl, $c012 ; sfx noise channel pointer - ld de, Noise8_endchannel - ld [hl], e - inc hl - ld [hl], d ; overwrite pointer to point to endchannel - ld a, [$c005] - and a - jr nz, .asm_222d4 - ld a, [$FF00+$24] - ld [$c005], a - ld a, $77 - ld [$FF00+$24], a -.asm_222d4 - ret - -Noise8_endchannel: ; 222d5 (8:62d5) - endchannel - -Unknown_222d6: ; 222d6 (8:62d6) - db $10, $15, $1A, $1F ; channels 0-3 - db $10, $15, $1A, $1F ; channels 4-7 - -Unknown_222de: ; 222de (8:62de) - db $EE, $DD, $BB, $77 ; channels 0-3 - db $EE, $DD, $BB, $77 ; channels 4-7 - -Unknown_222e6: ; 222e6 (8:62e6) - db $11, $22, $44, $88 ; channels 0-3 - db $11, $22, $44, $88 ; channels 4-7 - -Unknown_222ee: ; 222ee (8:62ee) - dw $F82C - dw $F89D - dw $F907 - dw $F96B - dw $F9CA - dw $FA23 - dw $FA77 - dw $FAC7 - dw $FB12 - dw $FB58 - dw $FB9B - dw $FBDA - -Music_PokeFluteInBattle: ; 22306 (8:6306) - ld a, (SFX_08_46 - $4000) / 3 ; PokeFlute outside of battle - call PlaySoundWaitForCurrent - ld hl, $c00e - ld de, SFX_08_PokeFlute_Ch1 - call Music8_OverwriteChannelPointer - ld de, SFX_08_PokeFlute_Ch2 - call Music8_OverwriteChannelPointer - ld de, SFX_08_PokeFlute_Ch3 - -Music8_OverwriteChannelPointer: ; 2231d (8:631d) - ld a, e - ld [hli], a - ld a, d - ld [hli], a - ret - -INCLUDE "music/sfx/sfx_08_pokeflute.asm" -INCLUDE "music/sfx/sfx_08_unused2.asm" -INCLUDE "music/gymleaderbattle.asm" -INCLUDE "music/trainerbattle.asm" -INCLUDE "music/wildbattle.asm" -INCLUDE "music/finalbattle.asm" -INCLUDE "music/sfx/sfx_08_3a.asm" -INCLUDE "music/sfx/sfx_08_3b.asm" -INCLUDE "music/sfx/sfx_08_46.asm" -INCLUDE "music/defeatedtrainer.asm" -INCLUDE "music/defeatedwildmon.asm" -INCLUDE "music/defeatedgymleader.asm" SECTION "bank9",ROMX,BANK[$9] @@ -61735,7 +57007,7 @@ FaintEnemyPokemon ; 0x3c567 jr .sfxplayed .wild_win call Func_3c643 - ld a, (Music_DefeatedWildMon - $4000) / 3 + ld a, MUSIC_DEFEATED_WILD_MON call Func_3c6ee .sfxplayed ld hl, W_PLAYERMONCURHP ; $d015 @@ -61846,16 +57118,16 @@ Func_3c664: ; 3c664 (f:4664) TrainerBattleVictory: ; 3c696 (f:4696) call Func_3c643 - ld b, (Music_DefeatedGymLeader - $4000) / 3 + ld b, MUSIC_DEFEATED_GYM_LEADER ld a, [W_GYMLEADERNO] ; $d05c and a jr nz, .gymleader - ld b, (Music_DefeatedTrainer - $4000) / 3 + ld b, MUSIC_DEFEATED_TRAINER .gymleader ld a, [W_TRAINERCLASS] ; $d031 cp SONY3 ; final battle against rival jr nz, .notrival - ld b, (Music_DefeatedGymLeader - $4000) / 3 + ld b, MUSIC_DEFEATED_GYM_LEADER ld hl, W_FLAGS_D733 set 1, [hl] .notrival @@ -83412,7 +78684,7 @@ Route22Script0: ; 50f00 (14:4f00) call PlaySound .asm_50f4e ld c, BANK(Music_MeetRival) - ld a, (Music_MeetRival - $4000) / 3 + ld a, MUSIC_MEET_RIVAL call PlayMusic ld a, $1 ld [$ff00+$8c], a @@ -85132,7 +80404,7 @@ SilphCo7Script0: ; 51c23 (14:5c23) ld [$c0ee], a call PlaySound ld c, BANK(Music_MeetRival) - ld a, (Music_MeetRival - $4000) / 3 + ld a, MUSIC_MEET_RIVAL call PlayMusic ld a, $9 ld [H_DOWNARROWBLINKCNT2], a ; $FF00+$8c @@ -95682,7 +90954,7 @@ PewterPokecenterText3: ; 5c59b (17:459b) dec hl push hl ld c, BANK(Music_JigglypuffSong) - ld a, (Music_JigglypuffSong - $4000) / 3 + ld a, MUSIC_JIGGLYPUFF_SONG call PlayMusic pop hl .asm_5c5d1 @@ -99040,7 +94312,7 @@ PokemonTower2Script0: ; 6050f (18:450f) ld [$c0ee], a call PlaySound ld c, BANK(Music_MeetRival) - ld a, (Music_MeetRival - $4000) / 3 + ld a, MUSIC_MEET_RIVAL call PlayMusic ld hl, $d764 res 6, [hl] @@ -100724,7 +95996,7 @@ SSAnne2Script0: ; 613be (18:53be) ld [$c0ee], a call PlaySound ld c, BANK(Music_MeetRival) - ld a, (Music_MeetRival - $4000) / 3 + ld a, MUSIC_MEET_RIVAL call PlayMusic ld a, [$cd3d] ld [$ff00+$db], a @@ -103133,7 +98405,7 @@ Func_701a0: ; 701a0 (1c:41a0) ld a, $90 ld [$FF00+$b0], a ld c, BANK(Music_HallOfFame) - ld a, (Music_HallOfFame - $4000) / 3 + ld a, MUSIC_HALL_OF_FAME call PlayMusic ld hl, W_PARTYMON1 ; $d164 ld c, $ff @@ -108519,7 +103791,7 @@ Func_7405c: ; 7405c (1d:405c) ld a, $ff call PlaySoundWaitForCurrent ld c, BANK(Music_Credits) - ld a, (Music_Credits - $4000) / 3 + ld a, MUSIC_CREDITS call PlayMusic ld c, $80 call DelayFrames @@ -120094,7 +115366,7 @@ Func_7bde9: ; 7bde9 (1e:7de9) call PlayCry call WaitForSoundToFinish ld c, BANK(Music_SafariZone) - ld a, (Music_SafariZone - $4000) / 3 + ld a, MUSIC_SAFARI_ZONE call PlayMusic ld c, $50 call DelayFrames @@ -120309,1895 +115581,6 @@ TechnicalMachinePrices: ; 7bfa7 (1e:7fa7) db $21, $12, $42, $25, $24 db $22, $52, $24, $34, $42 -SECTION "bank1F",ROMX,BANK[$1F] - -INCLUDE "music/headers/sfxheaders1f.asm" -INCLUDE "music/headers/musicheaders1f.asm" - -INCLUDE "music/sfx/sfx_1f_01.asm" -INCLUDE "music/sfx/sfx_1f_02.asm" -INCLUDE "music/sfx/sfx_1f_03.asm" -INCLUDE "music/sfx/sfx_1f_04.asm" -INCLUDE "music/sfx/sfx_1f_05.asm" -INCLUDE "music/sfx/sfx_1f_06.asm" -INCLUDE "music/sfx/sfx_1f_07.asm" -INCLUDE "music/sfx/sfx_1f_08.asm" -INCLUDE "music/sfx/sfx_1f_09.asm" -INCLUDE "music/sfx/sfx_1f_0a.asm" -INCLUDE "music/sfx/sfx_1f_0b.asm" -INCLUDE "music/sfx/sfx_1f_0c.asm" -INCLUDE "music/sfx/sfx_1f_0d.asm" -INCLUDE "music/sfx/sfx_1f_0e.asm" -INCLUDE "music/sfx/sfx_1f_0f.asm" -INCLUDE "music/sfx/sfx_1f_10.asm" -INCLUDE "music/sfx/sfx_1f_11.asm" -INCLUDE "music/sfx/sfx_1f_12.asm" -INCLUDE "music/sfx/sfx_1f_13.asm" - -Music1f_Channel3DutyPointers: ; 7c361 (1f:4361) - dw Music1f_Channel3Duty0 - dw Music1f_Channel3Duty1 - dw Music1f_Channel3Duty2 - dw Music1f_Channel3Duty3 - dw Music1f_Channel3Duty4 - dw Music1f_Channel3Duty5 ; used in the Pokemon Tower theme - dw SFX_1f_3f_Ch1 ; unused - dw SFX_1f_3f_Ch1 ; unused - dw SFX_1f_3f_Ch1 ; unused - -; these are the definitions for the channel 3 instruments -; each instrument definition is made up of 32 points (nibbles) that form -; the graph of the wave -; the current instrument is copied to $FF30 -Music1f_Channel3Duty0: ; 7c373 (1f:4373) - db $02,$46,$8A,$CE,$FF,$FE,$ED,$DC,$CB,$A9,$87,$65,$44,$33,$22,$11 - -Music1f_Channel3Duty1: ; 7c383 (1f:4383) - db $02,$46,$8A,$CE,$EF,$FF,$FE,$EE,$DD,$CB,$A9,$87,$65,$43,$22,$11 - -Music1f_Channel3Duty2: ; 7c393 (1f:4393) - db $13,$69,$BD,$EE,$EE,$FF,$FF,$ED,$DE,$FF,$FF,$EE,$EE,$DB,$96,$31 - -Music1f_Channel3Duty3: ; 7c3a3 (1f:43a3) - db $02,$46,$8A,$CD,$EF,$FE,$DE,$FF,$EE,$DC,$BA,$98,$76,$54,$32,$10 - -Music1f_Channel3Duty4: ; 7c3b3 (1f:43b3) - db $01,$23,$45,$67,$8A,$CD,$EE,$F7,$7F,$EE,$DC,$A8,$76,$54,$32,$10 - -; duty 5 reads from sfx data -Music1f_Channel3Duty5: ; 7c3c3 (1f:43c3) -INCLUDE "music/sfx/sfx_1f_3f.asm" -INCLUDE "music/sfx/sfx_1f_56.asm" -INCLUDE "music/sfx/sfx_1f_57.asm" -INCLUDE "music/sfx/sfx_1f_58.asm" -INCLUDE "music/sfx/sfx_1f_3c.asm" -INCLUDE "music/sfx/sfx_1f_59.asm" -INCLUDE "music/sfx/sfx_1f_5a.asm" -INCLUDE "music/sfx/sfx_1f_5b.asm" -INCLUDE "music/sfx/sfx_1f_5c.asm" -INCLUDE "music/sfx/sfx_1f_40.asm" -IF _RED - INCLUDE "music/sfx/sfx_1f_5d.asm" -ENDC -IF _BLUE - INCLUDE "music/blue/sfx_1f_5d.asm" -ENDC -INCLUDE "music/sfx/sfx_1f_3d.asm" -INCLUDE "music/sfx/sfx_1f_43.asm" -INCLUDE "music/sfx/sfx_1f_3e.asm" -INCLUDE "music/sfx/sfx_1f_44.asm" -INCLUDE "music/sfx/sfx_1f_45.asm" -INCLUDE "music/sfx/sfx_1f_46.asm" -INCLUDE "music/sfx/sfx_1f_47.asm" -INCLUDE "music/sfx/sfx_1f_48.asm" -INCLUDE "music/sfx/sfx_1f_49.asm" -INCLUDE "music/sfx/sfx_1f_4a.asm" -INCLUDE "music/sfx/sfx_1f_4b.asm" -INCLUDE "music/sfx/sfx_1f_4c.asm" -INCLUDE "music/sfx/sfx_1f_4d.asm" -INCLUDE "music/sfx/sfx_1f_4e.asm" -INCLUDE "music/sfx/sfx_1f_4f.asm" -INCLUDE "music/sfx/sfx_1f_50.asm" -INCLUDE "music/sfx/sfx_1f_51.asm" -INCLUDE "music/sfx/sfx_1f_52.asm" -INCLUDE "music/sfx/sfx_1f_53.asm" -INCLUDE "music/sfx/sfx_1f_54.asm" -INCLUDE "music/sfx/sfx_1f_55.asm" -INCLUDE "music/sfx/sfx_1f_5e.asm" -INCLUDE "music/sfx/sfx_1f_5f.asm" -INCLUDE "music/sfx/sfx_1f_60.asm" -INCLUDE "music/sfx/sfx_1f_61.asm" -INCLUDE "music/sfx/sfx_1f_62.asm" -INCLUDE "music/sfx/sfx_1f_63.asm" -INCLUDE "music/sfx/sfx_1f_64.asm" -INCLUDE "music/sfx/sfx_1f_65.asm" -INCLUDE "music/sfx/sfx_1f_66.asm" -INCLUDE "music/sfx/sfx_1f_67.asm" -INCLUDE "music/sfx/sfx_1f_unused.asm" -INCLUDE "music/sfx/sfx_1f_1d.asm" -INCLUDE "music/sfx/sfx_1f_37.asm" -INCLUDE "music/sfx/sfx_1f_38.asm" -INCLUDE "music/sfx/sfx_1f_25.asm" -INCLUDE "music/sfx/sfx_1f_39.asm" -INCLUDE "music/sfx/sfx_1f_17.asm" -INCLUDE "music/sfx/sfx_1f_23.asm" -INCLUDE "music/sfx/sfx_1f_24.asm" -INCLUDE "music/sfx/sfx_1f_14.asm" -INCLUDE "music/sfx/sfx_1f_22.asm" -INCLUDE "music/sfx/sfx_1f_1a.asm" -INCLUDE "music/sfx/sfx_1f_1b.asm" -INCLUDE "music/sfx/sfx_1f_19.asm" -INCLUDE "music/sfx/sfx_1f_1f.asm" -INCLUDE "music/sfx/sfx_1f_20.asm" -INCLUDE "music/sfx/sfx_1f_16.asm" -INCLUDE "music/sfx/sfx_1f_21.asm" -INCLUDE "music/sfx/sfx_1f_15.asm" -INCLUDE "music/sfx/sfx_1f_1e.asm" -INCLUDE "music/sfx/sfx_1f_1c.asm" -INCLUDE "music/sfx/sfx_1f_18.asm" -INCLUDE "music/sfx/sfx_1f_2d.asm" -INCLUDE "music/sfx/sfx_1f_2a.asm" -INCLUDE "music/sfx/sfx_1f_2f.asm" -INCLUDE "music/sfx/sfx_1f_26.asm" -INCLUDE "music/sfx/sfx_1f_27.asm" -INCLUDE "music/sfx/sfx_1f_28.asm" -INCLUDE "music/sfx/sfx_1f_32.asm" -INCLUDE "music/sfx/sfx_1f_29.asm" -INCLUDE "music/sfx/sfx_1f_2b.asm" -INCLUDE "music/sfx/sfx_1f_30.asm" -INCLUDE "music/sfx/sfx_1f_2e.asm" -INCLUDE "music/sfx/sfx_1f_31.asm" -INCLUDE "music/sfx/sfx_1f_2c.asm" -INCLUDE "music/sfx/sfx_1f_33.asm" -INCLUDE "music/sfx/sfx_1f_34.asm" -INCLUDE "music/sfx/sfx_1f_35.asm" -INCLUDE "music/sfx/sfx_1f_36.asm" - -Func_7d13b: ; 7d13b (1f:513b) - ld a, [$FF00+$dc] - ld c, $0 - ld hl, OwnedMonValues -.getSfxPointer - cp [hl] - jr c, .gotSfxPointer - inc c - inc hl - jr .getSfxPointer -.gotSfxPointer - push bc - ld a, $ff - ld [$c0ee], a - call PlaySoundWaitForCurrent - pop bc - ld b, $0 - ld hl, PokedexRatingSfxPointers - add hl, bc - add hl, bc - ld a, [hli] - ld c, [hl] - call PlayMusic - jp Func_2307 - -PokedexRatingSfxPointers: ; 7d162 (1f:5162) - db (SFX_1f_51 - $4000) / 3 - db BANK(SFX_1f_51) - db (SFX_02_41 - $4000) / 3 - db BANK(SFX_02_41) - db (SFX_02_3a - $4000) / 3 - db BANK(SFX_02_3a) - db (SFX_08_46 - $4000) / 3 - db BANK(SFX_08_46) - db (SFX_08_3a - $4000) / 3 - db BANK(SFX_08_3a) - db (SFX_02_42 - $4000) / 3 - db BANK(SFX_02_42) - db (SFX_02_3b - $4000) / 3 - db BANK(SFX_02_3b) - -OwnedMonValues: ; 7d170 (1f:5170) - db 10, 40, 60, 90, 120, 150, $ff - -Func_7d177: ; 7d177 (1f:5177) - ld c, CH0 -.loop - ld b, $0 - ld hl, $c026 - add hl, bc - ld a, [hl] - and a - jr z, .nextChannel - ld a, c - cp CH4 - jr nc, .applyAffects ; if sfx channel - ld a, [$c002] - and a - jr z, .applyAffects - bit 7, a - jr nz, .nextChannel - set 7, a - ld [$c002], a - xor a - ld [$FF00+$25], a - ld [$FF00+$1a], a - ld a, $80 - ld [$FF00+$1a], a - jr .nextChannel -.applyAffects - call Music1f_Music2_ApplyMusicAffects -.nextChannel - ld a, c - inc c ; inc channel number - cp CH7 - jr nz, .loop - ret - -; this routine checks flags for music effects currently applied -; to the channel and calls certain functions based on flags. -; known flags for $c02e: -; 1: call has been used -; 3: a toggle used only by this routine for vibrato -; 4: pitchbend flag -; 6: dutycycle flag -Music1f_Music2_ApplyMusicAffects: ; 7d1ac (1f:51ac) - ld b, $0 - ld hl, $c0b6 ; delay until next note - add hl, bc - ld a, [hl] - cp $1 ; if delay is 1, play next note - jp z, Music1f_Music2_PlayNextNote - dec a ; otherwise, decrease the delay timer - ld [hl], a - ld a, c - cp CH4 - jr nc, .startChecks ; if a sfx channel - ld hl, $c02a - add hl, bc - ld a, [hl] - and a - jr z, .startChecks - ret -.startChecks - ld hl, $c02e - add hl, bc - bit 6, [hl] ; dutycycle - jr z, .checkForExecuteMusic - call Music1f_ApplyDutyCycle -.checkForExecuteMusic - ld b, $0 - ld hl, $c036 - add hl, bc - bit 0, [hl] - jr nz, .checkForPitchBend - ld hl, $c02e - add hl, bc - bit 2, [hl] - jr nz, .disablePitchBendVibrato -.checkForPitchBend - ld hl, $c02e - add hl, bc - bit 4, [hl] ; pitchbend - jr z, .checkVibratoDelay - jp Music1f_ApplyPitchBend -.checkVibratoDelay - ld hl, $c04e ; vibrato delay - add hl, bc - ld a, [hl] - and a ; check if delay is over - jr z, .checkForVibrato - dec [hl] ; otherwise, dec delay -.disablePitchBendVibrato - ret -.checkForVibrato - ld hl, $c056 ; vibrato rate - add hl, bc - ld a, [hl] - and a - jr nz, .vibrato - ret ; no vibrato -.vibrato - ld d, a - ld hl, $c05e - add hl, bc - ld a, [hl] - and $f - and a - jr z, .vibratoAlreadyDone - dec [hl] ; apply vibrato pitch change - ret -.vibratoAlreadyDone - ld a, [hl] - swap [hl] - or [hl] - ld [hl], a ; reset the vibrato value and start again - ld hl, $c066 - add hl, bc - ld e, [hl] ; get note pitch - ld hl, $c02e - add hl, bc - bit 3, [hl] ; this is the only code that sets/resets bit three so - jr z, .unset ; it continuously alternates which path it takes - res 3, [hl] - ld a, d - and $f - ld d, a - ld a, e - sub d - jr nc, .noCarry - ld a, $0 -.noCarry - jr .done -.unset - set 3, [hl] - ld a, d - and $f0 - swap a - add e - jr nc, .done - ld a, $ff -.done - ld d, a - ld b, $3 - call Func_7d8ac - ld [hl], d - ret - -; this routine executes all music commands that take up no time, -; like tempo changes, duty changes etc. and doesn't return -; until the first note is reached -Music1f_Music2_PlayNextNote: ; 7d244 (1f:5244) - ld hl, $c06e - add hl, bc - ld a, [hl] - ld hl, $c04e - add hl, bc - ld [hl], a - ld hl, $c02e - add hl, bc - res 4, [hl] - res 5, [hl] - call Music1f_endchannel - ret - -Music1f_endchannel: ; 7d25a (1f:525a) - call Music1f_GetNextMusicByte - ld d, a - cp $ff ; is this command an endchannel? - jp nz, Music1f_callchannel ; no - ld b, $0 ; yes - ld hl, $c02e - add hl, bc - bit 1, [hl] - jr nz, .returnFromCall - ld a, c - cp CH3 - jr nc, .noiseOrSfxChannel - jr .asm_7d2b3 -.noiseOrSfxChannel - res 2, [hl] - ld hl, $c036 - add hl, bc - res 0, [hl] - cp CH6 - jr nz, .notSfxChannel3 - ld a, $0 - ld [$FF00+$1a], a - ld a, $80 - ld [$FF00+$1a], a -.notSfxChannel3 - jr nz, .asm_7d296 - ld a, [$c003] - and a - jr z, .asm_7d296 - xor a - ld [$c003], a - jr .asm_7d2b3 -.asm_7d296 - jr .asm_7d2bc -.returnFromCall - res 1, [hl] - ld d, $0 - ld a, c - add a - ld e, a - ld hl, $c006 - add hl, de - push hl ; store current channel address - ld hl, $c016 - add hl, de - ld e, l - ld d, h - pop hl - ld a, [de] - ld [hli], a - inc de - ld a, [de] - ld [hl], a ; loads channel address to return to - jp Music1f_endchannel -.asm_7d2b3 - ld hl, Unknown_7db93 - add hl, bc - ld a, [$FF00+$25] - and [hl] - ld [$FF00+$25], a -.asm_7d2bc - ld a, [$c02a] - cp $14 - jr nc, .asm_7d2c5 - jr .asm_7d2e2 -.asm_7d2c5 - ld a, [$c02a] - cp $86 - jr z, .asm_7d2e2 - jr c, .asm_7d2d0 - jr .asm_7d2e2 -.asm_7d2d0 - ld a, c - cp CH4 - jr z, .asm_7d2d9 - call Func_7d73b - ret c -.asm_7d2d9 - ld a, [$c005] - ld [$FF00+$24], a - xor a - ld [$c005], a -.asm_7d2e2 - ld hl, $c026 - add hl, bc - ld [hl], b - ret - -Music1f_callchannel: ; 7d2e8 (1f:52e8) - cp $fd ; is this command a callchannel? - jp nz, Music1f_loopchannel ; no - call Music1f_GetNextMusicByte ; yes - push af - call Music1f_GetNextMusicByte - ld d, a - pop af - ld e, a - push de ; store pointer - ld d, $0 - ld a, c - add a - ld e, a - ld hl, $c006 - add hl, de - push hl - ld hl, $c016 - add hl, de - ld e, l - ld d, h - pop hl - ld a, [hli] - ld [de], a - inc de - ld a, [hld] - ld [de], a ; copy current channel address - pop de - ld [hl], e - inc hl - ld [hl], d ; overwrite current address with pointer - ld b, $0 - ld hl, $c02e - add hl, bc - set 1, [hl] ; set the call flag - jp Music1f_endchannel - -Music1f_loopchannel: ; 7d31d (1f:531d) - cp $fe ; is this command a loopchannel? - jp nz, Music1f_notetype ; no - call Music1f_GetNextMusicByte ; yes - ld e, a - and a - jr z, .infiniteLoop - ld b, $0 - ld hl, $c0be - add hl, bc - ld a, [hl] - cp e - jr nz, .loopAgain - ld a, $1 ; if no more loops to make - ld [hl], a - call Music1f_GetNextMusicByte ; skip pointer - call Music1f_GetNextMusicByte - jp Music1f_endchannel -.loopAgain ; inc loop count - inc a - ld [hl], a - ; fall through -.infiniteLoop ; overwrite current address with pointer - call Music1f_GetNextMusicByte - push af - call Music1f_GetNextMusicByte - ld b, a - ld d, $0 - ld a, c - add a - ld e, a - ld hl, $c006 - add hl, de - pop af - ld [hli], a - ld [hl], b - jp Music1f_endchannel - -Music1f_notetype: ; 7d358 (1f:5358) - and $f0 - cp $d0 ; is this command a notetype? - jp nz, Music1f_togglecall ; no - ld a, d ; yes - and $f - ld b, $0 - ld hl, $c0c6 - add hl, bc - ld [hl], a ; store low nibble as speed - ld a, c - cp CH3 - jr z, .noiseChannel ; noise channel has 0 params - call Music1f_GetNextMusicByte - ld d, a - ld a, c - cp CH2 - jr z, .musicChannel3 - cp CH6 - jr nz, .notChannel3 - ld hl, $c0e7 - jr .sfxChannel3 -.musicChannel3 - ld hl, $c0e6 -.sfxChannel3 - ld a, d - and $f - ld [hl], a ; store low nibble of param as duty - ld a, d - and $30 - sla a - ld d, a - ; fall through - - ; if channel 3, store high nibble as volume - ; else, store volume (high nibble) and fade (low nibble) -.notChannel3 - ld b, $0 - ld hl, $c0de - add hl, bc - ld [hl], d -.noiseChannel - jp Music1f_endchannel - -Music1f_togglecall: ; 7d397 (1f:5397) - ld a, d - cp $e8 ; is this command an togglecall? - jr nz, Music1f_vibrato ; no - ld b, $0 ; yes - ld hl, $c02e - add hl, bc - ld a, [hl] - xor $1 - ld [hl], a ; flip bit 0 of $c02e (toggle returning from call) - jp Music1f_endchannel - -Music1f_vibrato: ; 7d3a9 (1f:53a9) - cp $ea ; is this command a vibrato? - jr nz, Music1f_pitchbend ; no - call Music1f_GetNextMusicByte ; yes - ld b, $0 - ld hl, $c04e - add hl, bc - ld [hl], a ; store delay - ld hl, $c06e - add hl, bc - ld [hl], a ; store delay - call Music1f_GetNextMusicByte - ld d, a - and $f0 - swap a - ld b, $0 - ld hl, $c056 - add hl, bc - srl a - ld e, a - adc b - swap a - or e - ld [hl], a ; store rate as both high and low nibbles - ld a, d - and $f - ld d, a - ld hl, $c05e - add hl, bc - swap a - or d - ld [hl], a ; store depth as both high and low nibbles - jp Music1f_endchannel - -Music1f_pitchbend: ; 7d3e1 (1f:53e1) - cp $eb ; is this command a pitchbend? - jr nz, Music1f_duty ; no - call Music1f_GetNextMusicByte ; yes - ld b, $0 - ld hl, $c076 - add hl, bc - ld [hl], a ; store first param - call Music1f_GetNextMusicByte - ld d, a - and $f0 - swap a - ld b, a - ld a, d - and $f - call Func_7d8cc - ld b, $0 - ld hl, $c0a6 - add hl, bc - ld [hl], d ; store unknown part of second param - ld hl, $c0ae - add hl, bc - ld [hl], e ; store unknown part of second param - ld b, $0 - ld hl, $c02e - add hl, bc - set 4, [hl] ; set pitchbend flag - call Music1f_GetNextMusicByte - ld d, a - jp Music1f_notelength - -Music1f_duty: ; 7d419 (1f:5419) - cp $ec ; is this command a duty? - jr nz, Music1f_tempo ; no - call Music1f_GetNextMusicByte ; yes - rrca - rrca - and $c0 - ld b, $0 - ld hl, $c03e - add hl, bc - ld [hl], a ; store duty - jp Music1f_endchannel - -Music1f_tempo: ; 7d42e (1f:542e) - cp $ed ; is this command a tempo? - jr nz, Music1f_unknownmusic0xee ; no - ld a, c ; yes - cp CH4 - jr nc, .sfxChannel - call Music1f_GetNextMusicByte - ld [$c0e8], a ; store first param - call Music1f_GetNextMusicByte - ld [$c0e9], a ; store second param - xor a - ld [$c0ce], a ; clear RAM - ld [$c0cf], a - ld [$c0d0], a - ld [$c0d1], a - jr .musicChannelDone -.sfxChannel - call Music1f_GetNextMusicByte - ld [$c0ea], a ; store first param - call Music1f_GetNextMusicByte - ld [$c0eb], a ; store second param - xor a - ld [$c0d2], a ; clear RAM - ld [$c0d3], a - ld [$c0d4], a - ld [$c0d5], a -.musicChannelDone - jp Music1f_endchannel - -Music1f_unknownmusic0xee: ; 7d46e (1f:546e) - cp $ee ; is this command an unknownmusic0xee? - jr nz, Music1f_unknownmusic0xef ; no - call Music1f_GetNextMusicByte ; yes - ld [$c004], a ; store first param - jp Music1f_endchannel - -; this appears to never be used -Music1f_unknownmusic0xef: ; 7d47b (1f:547b) - cp $ef ; is this command an unknownmusic0xef? - jr nz, Music1f_dutycycle ; no - call Music1f_GetNextMusicByte ; yes - push bc - call Func_7d8ea - pop bc - ld a, [$c003] - and a - jr nz, .skip - ld a, [$c02d] - ld [$c003], a - xor a - ld [$c02d], a -.skip - jp Music1f_endchannel - -Music1f_dutycycle: ; 7d49a (1f:549a) - cp $fc ; is this command a dutycycle? - jr nz, Music1f_stereopanning ; no - call Music1f_GetNextMusicByte ; yes - ld b, $0 - ld hl, $c046 - add hl, bc - ld [hl], a ; store full cycle - and $c0 - ld hl, $c03e - add hl, bc - ld [hl], a ; store first duty - ld hl, $c02e - add hl, bc - set 6, [hl] ; set duty flag - jp Music1f_endchannel - -Music1f_stereopanning: ; 7d4b8 (1f:54b8) - cp $f0 ; is this command a stereopanning? - jr nz, Music1f_executemusic ; no - call Music1f_GetNextMusicByte ; yes - ld [$FF00+$24], a ; store stereopanning - jp Music1f_endchannel - -Music1f_executemusic: ; 7d4c4 (1f:54c4) - cp $f8 ; is this command an executemusic? - jr nz, Music1f_octave ; no - ld b, $0 ; yes - ld hl, $c036 - add hl, bc - set 0, [hl] - jp Music1f_endchannel - -Music1f_octave: ; 7d4d3 (1f:54d3) - and $f0 - cp $e0 ; is this command an octave? - jr nz, Music1f_unknownsfx0x20 ; no - ld hl, $c0d6 ; yes - ld b, $0 - add hl, bc - ld a, d - and $f - ld [hl], a ; store low nibble as octave - jp Music1f_endchannel - -Music1f_unknownsfx0x20: ; 7d4e6 (1f:54e6) - cp $20 ; is this command an unknownsfx0x20? - jr nz, Music1f_unknownsfx0x10 ; no - ld a, c - cp CH3 ; is this a noise or sfx channel? - jr c, Music1f_unknownsfx0x10 ; no - ld b, $0 - ld hl, $c036 - add hl, bc - bit 0, [hl] - jr nz, Music1f_unknownsfx0x10 ; no - call Music1f_notelength ; yes - ld d, a - ld b, $0 - ld hl, $c03e - add hl, bc - ld a, [hl] - or d - ld d, a - ld b, $1 - call Func_7d8ac - ld [hl], d - call Music1f_GetNextMusicByte - ld d, a - ld b, $2 - call Func_7d8ac - ld [hl], d - call Music1f_GetNextMusicByte - ld e, a - ld a, c - cp CH7 - ld a, $0 - jr z, .sfxNoiseChannel ; only two params for noise channel - push de - call Music1f_GetNextMusicByte - pop de -.sfxNoiseChannel - ld d, a - push de - call Func_7d69d - call Func_7d66c - pop de - call Func_7d6bf - ret - -Music1f_unknownsfx0x10 ; 7d533 (1f:5533) - ld a, c - cp CH4 - jr c, Music1f_note ; if not a sfx - ld a, d - cp $10 ; is this command an unknownsfx0x10? - jr nz, Music1f_note ; no - ld b, $0 - ld hl, $c036 - add hl, bc - bit 0, [hl] - jr nz, Music1f_note ; no - call Music1f_GetNextMusicByte ; yes - ld [$FF00+$10], a - jp Music1f_endchannel - -Music1f_note: ; 7d54f (1f:554f) - ld a, c - cp CH3 - jr nz, Music1f_notelength ; if not noise channel - ld a, d - and $f0 - cp $b0 ; is this command a dnote? - jr z, Music1f_dnote ; yes - jr nc, Music1f_notelength ; no - swap a - ld b, a - ld a, d - and $f - ld d, a - ld a, b - push de - push bc - jr asm_7d571 - -Music1f_dnote: ; 7d569 (1f:5569) - ld a, d - and $f - push af - push bc - call Music1f_GetNextMusicByte ; get dnote instrument -asm_7d571 - ld d, a - ld a, [$c003] - and a - jr nz, .asm_7d57c - ld a, d - call Func_7d8ea -.asm_7d57c - pop bc - pop de - -Music1f_notelength: ; 7d57e (1f:557e) - ld a, d - push af - and $f - inc a - ld b, $0 - ld e, a ; store note length (in 16ths) - ld d, b - ld hl, $c0c6 - add hl, bc - ld a, [hl] - ld l, b - call Func_7d8bb - ld a, c - cp CH4 - jr nc, .sfxChannel - ld a, [$c0e8] - ld d, a - ld a, [$c0e9] - ld e, a - jr .skip -.sfxChannel - ld d, $1 - ld e, $0 - cp CH7 - jr z, .skip ; if noise channel - call Func_7d707 - ld a, [$c0ea] - ld d, a - ld a, [$c0eb] - ld e, a -.skip - ld a, l - ld b, $0 - ld hl, $c0ce - add hl, bc - ld l, [hl] - call Func_7d8bb - ld e, l - ld d, h - ld hl, $c0ce - add hl, bc - ld [hl], e - ld a, d - ld hl, $c0b6 - add hl, bc - ld [hl], a - ld hl, $c036 - add hl, bc - bit 0, [hl] - jr nz, Music1f_notepitch - ld hl, $c02e - add hl, bc - bit 2, [hl] - jr z, Music1f_notepitch - pop hl - ret - -Music1f_notepitch: ; 7d5dc (1f:55dc) - pop af - and $f0 - cp $c0 ; compare to rest - jr nz, .notRest - ld a, c - cp CH4 - jr nc, .sfxChannel - ld hl, $c02a - add hl, bc - ld a, [hl] - and a - jr nz, .quit - ; fall through -.sfxChannel - ld a, c - cp CH2 - jr z, .musicChannel3 - cp CH6 - jr nz, .notSfxChannel3 -.musicChannel3 - ld b, $0 - ld hl, Unknown_7db93 - add hl, bc - ld a, [$FF00+$25] - and [hl] - ld [$FF00+$25], a - jr .quit -.notSfxChannel3 - ld b, $2 - call Func_7d8ac - ld a, $8 - ld [hli], a - inc hl - ld a, $80 - ld [hl], a -.quit - ret -.notRest - swap a - ld b, $0 - ld hl, $c0d6 - add hl, bc - ld b, [hl] - call Func_7d8cc - ld b, $0 - ld hl, $c02e - add hl, bc - bit 4, [hl] - jr z, .asm_7d62c - call Func_7d803 -.asm_7d62c - push de - ld a, c - cp CH4 - jr nc, .skip ; if sfx Channel - ld hl, $c02a - ld d, $0 - ld e, a - add hl, de - ld a, [hl] - and a - jr nz, .done - jr .skip -.done - pop de - ret -.skip - ld b, $0 - ld hl, $c0de - add hl, bc - ld d, [hl] - ld b, $2 - call Func_7d8ac - ld [hl], d - call Func_7d69d - call Func_7d66c - pop de - ld b, $0 - ld hl, $c02e - add hl, bc - bit 0, [hl] - jr z, .asm_7d663 - inc e - jr nc, .asm_7d663 - inc d -.asm_7d663 - ld hl, $c066 - add hl, bc - ld [hl], e - call Func_7d6bf - ret - -Func_7d66c: ; 7d66c (1f:566c) - ld b, $0 - ld hl, Unknown_7db9b - add hl, bc - ld a, [$FF00+$25] - or [hl] - ld d, a - ld a, c - cp CH7 - jr z, .sfxNoiseChannel - cp CH4 - jr nc, .skip ; if sfx channel - ld hl, $c02a - add hl, bc - ld a, [hl] - and a - jr nz, .skip -.sfxNoiseChannel - ld a, [$c004] - ld hl, Unknown_7db9b - add hl, bc - and [hl] - ld d, a - ld a, [$FF00+$25] - ld hl, Unknown_7db93 - add hl, bc - and [hl] - or d - ld d, a -.skip - ld a, d - ld [$FF00+$25], a - ret - -Func_7d69d: ; 7d69d (1f:569d) - ld b, $0 - ld hl, $c0b6 - add hl, bc - ld d, [hl] - ld a, c - cp CH2 - jr z, .channel3 ; if music channel 3 - cp CH6 - jr z, .channel3 ; if sfx channel 3 - ld a, d - and $3f - ld d, a - ld hl, $c03e - add hl, bc - ld a, [hl] - or d - ld d, a -.channel3 - ld b, $1 - call Func_7d8ac - ld [hl], d - ret - -Func_7d6bf: ; 7d6bf (1f:56bf) - ld a, c - cp CH2 - jr z, .channel3 - cp CH6 - jr nz, .notSfxChannel3 - ; fall through -.channel3 - push de - ld de, $c0e6 - cp CH2 - jr z, .musicChannel3 - ld de, $c0e7 -.musicChannel3 - ld a, [de] - add a - ld d, $0 - ld e, a - ld hl, Music1f_Channel3DutyPointers - add hl, de - ld e, [hl] - inc hl - ld d, [hl] - ld hl, $ff30 - ld b, $f - ld a, $0 - ld [$FF00+$1a], a -.loop - ld a, [de] - inc de - ld [hli], a - ld a, b - dec b - and a - jr nz, .loop - ld a, $80 - ld [$FF00+$1a], a - pop de -.notSfxChannel3 - ld a, d - or $80 - and $c7 - ld d, a - ld b, $3 - call Func_7d8ac - ld [hl], e - inc hl - ld [hl], d - call Func_7d729 - ret - -Func_7d707: ; 7d707 (1f:5707) - call Func_7d759 - jr nc, .asm_7d71f - ld d, $0 - ld a, [$c0f2] - add $80 - jr nc, .asm_7d716 - inc d -.asm_7d716 - ld [$c0eb], a - ld a, d - ld [$c0ea], a - jr .asm_7d728 -.asm_7d71f - xor a - ld [$c0eb], a - ld a, $1 - ld [$c0ea], a -.asm_7d728 - ret - -Func_7d729: ; 7d729 (1f:5729) - call Func_7d759 - jr nc, .asm_7d73a - ld a, [$c0f1] - add e - jr nc, .asm_7d735 - inc d -.asm_7d735 - dec hl - ld e, a - ld [hl], e - inc hl - ld [hl], d -.asm_7d73a - ret - -Func_7d73b: ; 7d73b (1f:573b) - call Func_7d759 - jr nc, .asm_7d756 - ld hl, $c006 - ld e, c - ld d, $0 - sla e - rl d - add hl, de - ld a, [hl] - sub $1 - ld [hl], a - inc hl - ld a, [hl] - sbc $0 - ld [hl], a - scf - ret -.asm_7d756 - scf - ccf - ret - -Func_7d759: ; 7d759 (1f:5759) - ld a, [$c02a] - cp $14 - jr nc, .asm_7d762 - jr .asm_7d768 -.asm_7d762 - cp $86 - jr z, .asm_7d768 - jr c, .asm_7d76b -.asm_7d768 - scf - ccf - ret -.asm_7d76b - scf - ret - -Music1f_ApplyPitchBend: ; 7d76d (1f:576d) - ld hl, $c02e - add hl, bc - bit 5, [hl] - jp nz, .asm_7d7b4 - ld hl, $c09e - add hl, bc - ld e, [hl] - ld hl, $c096 - add hl, bc - ld d, [hl] - ld hl, $c07e - add hl, bc - ld l, [hl] - ld h, b - add hl, de - ld d, h - ld e, l - ld hl, $c08e - add hl, bc - push hl - ld hl, $c086 - add hl, bc - ld a, [hl] - pop hl - add [hl] - ld [hl], a - ld a, $0 - adc e - ld e, a - ld a, $0 - adc d - ld d, a - ld hl, $c0a6 - add hl, bc - ld a, [hl] - cp d - jp c, .asm_7d7fa - jr nz, .asm_7d7e7 - ld hl, $c0ae - add hl, bc - ld a, [hl] - cp e - jp c, .asm_7d7fa - jr .asm_7d7e7 -.asm_7d7b4 - ld hl, $c09e - add hl, bc - ld a, [hl] - ld hl, $c096 - add hl, bc - ld d, [hl] - ld hl, $c07e - add hl, bc - ld e, [hl] - sub e - ld e, a - ld a, d - sbc b - ld d, a - ld hl, $c086 - add hl, bc - ld a, [hl] - add a - ld [hl], a - ld a, e - sbc b - ld e, a - ld a, d - sbc b - ld d, a - ld hl, $c0a6 - add hl, bc - ld a, d - cp [hl] - jr c, .asm_7d7fa - jr nz, .asm_7d7e7 - ld hl, $c0ae - add hl, bc - ld a, e - cp [hl] - jr c, .asm_7d7fa -.asm_7d7e7 - ld hl, $c09e - add hl, bc - ld [hl], e - ld hl, $c096 - add hl, bc - ld [hl], d - ld b, $3 - call Func_7d8ac - ld a, e - ld [hli], a - ld [hl], d - ret -.asm_7d7fa - ld hl, $c02e - add hl, bc - res 4, [hl] - res 5, [hl] - ret - -Func_7d803: ; 7d803 (1f:5803) - ld hl, $c096 - add hl, bc - ld [hl], d - ld hl, $c09e - add hl, bc - ld [hl], e - ld hl, $c0b6 - add hl, bc - ld a, [hl] - ld hl, $c076 - add hl, bc - sub [hl] - jr nc, .asm_7d81b - ld a, $1 -.asm_7d81b - ld [hl], a - ld hl, $c0ae - add hl, bc - ld a, e - sub [hl] - ld e, a - ld a, d - sbc b - ld hl, $c0a6 - add hl, bc - sub [hl] - jr c, .asm_7d837 - ld d, a - ld b, $0 - ld hl, $c02e - add hl, bc - set 5, [hl] - jr .asm_7d85a -.asm_7d837 - ld hl, $c096 - add hl, bc - ld d, [hl] - ld hl, $c09e - add hl, bc - ld e, [hl] - ld hl, $c0ae - add hl, bc - ld a, [hl] - sub e - ld e, a - ld a, d - sbc b - ld d, a - ld hl, $c0a6 - add hl, bc - ld a, [hl] - sub d - ld d, a - ld b, $0 - ld hl, $c02e - add hl, bc - res 5, [hl] -.asm_7d85a - ld hl, $c076 - add hl, bc -.asm_7d85e - inc b - ld a, e - sub [hl] - ld e, a - jr nc, .asm_7d85e - ld a, d - and a - jr z, .asm_7d86c - dec a - ld d, a - jr .asm_7d85e -.asm_7d86c - ld a, e - add [hl] - ld d, b - ld b, $0 - ld hl, $c07e - add hl, bc - ld [hl], d - ld hl, $c086 - add hl, bc - ld [hl], a - ld hl, $c08e - add hl, bc - ld [hl], a - ret - -Music1f_ApplyDutyCycle: ; 7d881 (1f:5881) - ld b, $0 - ld hl, $c046 - add hl, bc - ld a, [hl] - rlca - rlca - ld [hl], a - and $c0 - ld d, a - ld b, $1 - call Func_7d8ac - ld a, [hl] - and $3f - or d - ld [hl], a - ret - -Music1f_GetNextMusicByte: ; 7d899 (1f:5899) - ld d, $0 - ld a, c - add a - ld e, a - ld hl, $c006 - add hl, de - ld a, [hli] - ld e, a - ld a, [hld] - ld d, a - ld a, [de] ; get next music command - inc de - ld [hl], e ; store address of next command - inc hl - ld [hl], d - ret - -Func_7d8ac: ; 7d8ac (1f:58ac) - ld a, c - ld hl, Unknown_7db8b - add l - jr nc, .noCarry - inc h -.noCarry - ld l, a - ld a, [hl] - add b - ld l, a - ld h, $ff - ret - -Func_7d8bb: ; 7d8bb (1f:58bb) - ld h, $0 -.loop - srl a - jr nc, .noCarry - add hl, de -.noCarry - sla e - rl d - and a - jr z, .done - jr .loop -.done - ret - -Func_7d8cc: ; 7d8cc (1f:58cc) - ld h, $0 - ld l, a - add hl, hl - ld d, h - ld e, l - ld hl, Unknown_7dba3 - add hl, de - ld e, [hl] - inc hl - ld d, [hl] - ld a, b -.loop - cp $7 - jr z, .done - sra d - rr e - inc a - jr .loop -.done - ld a, $8 - add d - ld d, a - ret - -Func_7d8ea: ; 7d8ea (1f:58ea) - ld [$c001], a - cp $ff - jp z, Func_7daa8 - cp $c2 - jp z, Func_7d9c2 - jp c, Func_7d9c2 - cp $fe - jr z, .asm_7d901 - jp nc, Func_7d9c2 -.asm_7d901 - xor a - ld [$c000], a - ld [$c003], a - ld [$c0e9], a - ld [$c0e6], a - ld [$c0e7], a - ld d, $8 - ld hl, $c016 - call FillMusicRAM1f - ld hl, $c006 - call FillMusicRAM1f - ld d, $4 - ld hl, $c026 - call FillMusicRAM1f - ld hl, $c02e - call FillMusicRAM1f - ld hl, $c03e - call FillMusicRAM1f - ld hl, $c046 - call FillMusicRAM1f - ld hl, $c04e - call FillMusicRAM1f - ld hl, $c056 - call FillMusicRAM1f - ld hl, $c05e - call FillMusicRAM1f - ld hl, $c066 - call FillMusicRAM1f - ld hl, $c06e - call FillMusicRAM1f - ld hl, $c036 - call FillMusicRAM1f - ld hl, $c076 - call FillMusicRAM1f - ld hl, $c07e - call FillMusicRAM1f - ld hl, $c086 - call FillMusicRAM1f - ld hl, $c08e - call FillMusicRAM1f - ld hl, $c096 - call FillMusicRAM1f - ld hl, $c09e - call FillMusicRAM1f - ld hl, $c0a6 - call FillMusicRAM1f - ld hl, $c0ae - call FillMusicRAM1f - ld a, $1 - ld hl, $c0be - call FillMusicRAM1f - ld hl, $c0b6 - call FillMusicRAM1f - ld hl, $c0c6 - call FillMusicRAM1f - ld [$c0e8], a - ld a, $ff - ld [$c004], a - xor a - ld [$FF00+$24], a - ld a, $8 - ld [$FF00+$10], a - ld a, $0 - ld [$FF00+$25], a - xor a - ld [$FF00+$1a], a - ld a, $80 - ld [$FF00+$1a], a - ld a, $77 - ld [$FF00+$24], a - jp Func_7db03 - -Func_7d9c2: ; 7d9c2 (1f:59c2) - ld l, a - ld e, a - ld h, $0 - ld d, h - add hl, hl - add hl, de - ld de, SFX_Headers_1f - add hl, de - ld a, h - ld [$c0ec], a - ld a, l - ld [$c0ed], a - ld a, [hl] - and $c0 - rlca - rlca - ld c, a -.asm_7d9db - ld d, c - ld a, c - add a - add c - ld c, a - ld b, $0 - ld a, [$c0ec] - ld h, a - ld a, [$c0ed] - ld l, a - add hl, bc - ld c, d - ld a, [hl] - and $f - ld e, a - ld d, $0 - ld hl, $c026 - add hl, de - ld a, [hl] - and a - jr z, .asm_7da17 - ld a, e - cp $7 - jr nz, .asm_7da0e - ld a, [$c001] - cp $14 - jr nc, .asm_7da07 - ret -.asm_7da07 - ld a, [hl] - cp $14 - jr z, .asm_7da17 - jr c, .asm_7da17 -.asm_7da0e - ld a, [$c001] - cp [hl] - jr z, .asm_7da17 - jr c, .asm_7da17 - ret -.asm_7da17 - xor a - push de - ld h, d - ld l, e - add hl, hl - ld d, h - ld e, l - ld hl, $c016 - add hl, de - ld [hli], a - ld [hl], a - ld hl, $c006 - add hl, de - ld [hli], a - ld [hl], a - pop de - ld hl, $c026 - add hl, de - ld [hl], a - ld hl, $c02e - add hl, de - ld [hl], a - ld hl, $c03e - add hl, de - ld [hl], a - ld hl, $c046 - add hl, de - ld [hl], a - ld hl, $c04e - add hl, de - ld [hl], a - ld hl, $c056 - add hl, de - ld [hl], a - ld hl, $c05e - add hl, de - ld [hl], a - ld hl, $c066 - add hl, de - ld [hl], a - ld hl, $c06e - add hl, de - ld [hl], a - ld hl, $c076 - add hl, de - ld [hl], a - ld hl, $c07e - add hl, de - ld [hl], a - ld hl, $c086 - add hl, de - ld [hl], a - ld hl, $c08e - add hl, de - ld [hl], a - ld hl, $c096 - add hl, de - ld [hl], a - ld hl, $c09e - add hl, de - ld [hl], a - ld hl, $c0a6 - add hl, de - ld [hl], a - ld hl, $c0ae - add hl, de - ld [hl], a - ld hl, $c036 - add hl, de - ld [hl], a - ld a, $1 - ld hl, $c0be - add hl, de - ld [hl], a - ld hl, $c0b6 - add hl, de - ld [hl], a - ld hl, $c0c6 - add hl, de - ld [hl], a - ld a, e - cp $4 - jr nz, .asm_7da9f - ld a, $8 - ld [$FF00+$10], a -.asm_7da9f - ld a, c - and a - jp z, Func_7db03 - dec c - jp .asm_7d9db - -Func_7daa8: ; 7daa8 (1f:5aa8) - ld a, $80 - ld [$FF00+$26], a - ld [$FF00+$1a], a - xor a - ld [$FF00+$25], a - ld [$FF00+$1c], a - ld a, $8 - ld [$FF00+$10], a - ld [$FF00+$12], a - ld [$FF00+$17], a - ld [$FF00+$21], a - ld a, $40 - ld [$FF00+$14], a - ld [$FF00+$19], a - ld [$FF00+$23], a - ld a, $77 - ld [$FF00+$24], a - xor a - ld [$c000], a - ld [$c003], a - ld [$c002], a - ld [$c0e9], a - ld [$c0eb], a - ld [$c0e6], a - ld [$c0e7], a - ld d, $a0 - ld hl, $c006 - call FillMusicRAM1f - ld a, $1 - ld d, $18 - ld hl, $c0b6 - call FillMusicRAM1f - ld [$c0e8], a - ld [$c0ea], a - ld a, $ff - ld [$c004], a - ret - -; fills d bytes at hl with a -FillMusicRAM1f: ; 7dafd (1f:5afd) - ld b, d -.loop - ld [hli], a - dec b - jr nz, .loop - ret - -Func_7db03: ; 7db03 (1f:5b03) - ld a, [$c001] - ld l, a - ld e, a - ld h, $0 - ld d, h - add hl, hl - add hl, de - ld de, SFX_Headers_1f - add hl, de - ld e, l - ld d, h - ld hl, $c006 - ld a, [de] ; get channel number - ld b, a - rlca - rlca - and $3 - ld c, a - ld a, b - and $f - ld b, c - inc b - inc de - ld c, $0 -.asm_7db25 - cp c - jr z, .asm_7db2d - inc c - inc hl - inc hl - jr .asm_7db25 -.asm_7db2d - push hl - push bc - push af - ld b, $0 - ld c, a - ld hl, $c026 - add hl, bc - ld a, [$c001] - ld [hl], a - pop af - cp $3 - jr c, .asm_7db46 - ld hl, $c02e - add hl, bc - set 2, [hl] -.asm_7db46 - pop bc - pop hl - ld a, [de] ; get channel pointer - ld [hli], a - inc de - ld a, [de] - ld [hli], a - inc de - inc c - dec b - ld a, b - and a - ld a, [de] - inc de - jr nz, .asm_7db25 - ld a, [$c001] - cp $14 - jr nc, .asm_7db5f - jr .asm_7db89 -.asm_7db5f - ld a, [$c001] - cp $86 - jr z, .asm_7db89 - jr c, .asm_7db6a - jr .asm_7db89 -.asm_7db6a - ld hl, $c02a - ld [hli], a - ld [hli], a - ld [hli], a - ld [hl], a - ld hl, $c012 ; sfx noise channel pointer - ld de, Noise1f_endchannel - ld [hl], e - inc hl - ld [hl], d ; overwrite pointer to point to endchannel - ld a, [$c005] - and a - jr nz, .asm_7db89 - ld a, [$FF00+$24] - ld [$c005], a - ld a, $77 - ld [$FF00+$24], a -.asm_7db89 - ret - -Noise1f_endchannel: ; 7db8a (1f:5b8a) - endchannel - -Unknown_7db8b: ; 7db8b (1f:5b8b) - db $10, $15, $1A, $1F ; channels 0-3 - db $10, $15, $1A, $1F ; channels 4-7 - -Unknown_7db93: ; 7db93 (1f:5b93) - db $EE, $DD, $BB, $77 ; channels 0-3 - db $EE, $DD, $BB, $77 ; channels 4-7 - -Unknown_7db9b: ; 7db9b (1f:5b9b) - db $11, $22, $44, $88 ; channels 0-3 - db $11, $22, $44, $88 ; channels 4-7 - -Unknown_7dba3: ; 7dba3 (1f:5ba3) - dw $F82C - dw $F89D - dw $F907 - dw $F96B - dw $F9CA - dw $FA23 - dw $FA77 - dw $FAC7 - dw $FB12 - dw $FB58 - dw $FB9B - dw $FBDA - -INCLUDE "music/bikeriding.asm" -INCLUDE "music/dungeon1.asm" -INCLUDE "music/gamecorner.asm" -INCLUDE "music/titlescreen.asm" -INCLUDE "music/sfx/sfx_1f_3a.asm" -INCLUDE "music/dungeon2.asm" -INCLUDE "music/dungeon3.asm" -INCLUDE "music/cinnabarmansion.asm" -INCLUDE "music/sfx/sfx_1f_41.asm" -INCLUDE "music/sfx/sfx_1f_3b.asm" -INCLUDE "music/sfx/sfx_1f_42.asm" -INCLUDE "music/oakslab.asm" -INCLUDE "music/pokemontower.asm" -INCLUDE "music/silphco.asm" -INCLUDE "music/meeteviltrainer.asm" -INCLUDE "music/meetfemaletrainer.asm" -INCLUDE "music/meetmaletrainer.asm" -INCLUDE "music/introbattle.asm" -INCLUDE "music/surfing.asm" -INCLUDE "music/jigglypuffsong.asm" -INCLUDE "music/halloffame.asm" -INCLUDE "music/credits.asm" SECTION "bank20",ROMX,BANK[$20] diff --git a/menu/pc.asm b/menu/pc.asm new file mode 100644 index 00000000..8b31f822 --- /dev/null +++ b/menu/pc.asm @@ -0,0 +1,588 @@ + +Func_213c8: ; 213c8 (8:53c8) + xor a + ld [H_AUTOBGTRANSFERENABLED], a ; $FF00+$ba + call SaveScreenTilesToBuffer2 + ld a, [$d5a2] + and a + jr nz, .asm_213f3 + ld a, [$d74b] + bit 5, a + jr z, .asm_213ea + ld a, [$d5a2] + and a + jr nz, .asm_213f3 + ld hl, wTileMap + ld b, $8 + ld c, $e + jr .asm_213fa +.asm_213ea + ld hl, wTileMap + ld b, $6 + ld c, $e + jr .asm_213fa +.asm_213f3 + ld hl, wTileMap + ld b, $a + ld c, $e +.asm_213fa + call TextBoxBorder + call UpdateSprites + ld a, $3 + ld [wMaxMenuItem], a ; $cc28 + ld a, [$d7f1] + bit 0, a + jr nz, .asm_21414 + FuncCoord 2, 2 ; $c3ca + ld hl, Coord + ld de, SomeonesPCText ; $548b + jr .asm_2141a +.asm_21414 + FuncCoord 2, 2 ; $c3ca + ld hl, Coord + ld de, BillsPCText ; $5497 +.asm_2141a + call PlaceString + FuncCoord 2, 4 ; $c3f2 + ld hl, Coord + ld de, W_PLAYERNAME ; $d158 + call PlaceString + ld l, c + ld h, b + ld de, PlayersPCText ; $54a0 + call PlaceString + ld a, [$d74b] + bit 5, a + jr z, .asm_21462 + FuncCoord 2, 6 ; $c41a + ld hl, Coord + ld de, OaksPCText ; $54a5 + call PlaceString + ld a, [$d5a2] + and a + jr z, .asm_2145a + ld a, $4 + ld [wMaxMenuItem], a ; $cc28 + FuncCoord 2, 8 ; $c442 + ld hl, Coord + ld de, PKMNLeaguePCText ; $54b2 + call PlaceString + FuncCoord 2, 10 ; $c46a + ld hl, Coord + ld de, LogOffPCText ; $54ba + jr .asm_2146d +.asm_2145a + FuncCoord 2, 8 ; $c442 + ld hl, Coord + ld de, LogOffPCText ; $54ba + jr .asm_2146d +.asm_21462 + ld a, $2 + ld [wMaxMenuItem], a ; $cc28 + FuncCoord 2, 6 ; $c41a + ld hl, Coord + ld de, LogOffPCText ; $54ba +.asm_2146d + call PlaceString + ld a, $3 + ld [wMenuWatchedKeys], a ; $cc29 + ld a, $2 + ld [wTopMenuItemY], a ; $cc24 + ld a, $1 + ld [wTopMenuItemX], a ; $cc25 + xor a + ld [wCurrentMenuItem], a ; $cc26 + ld [wLastMenuItem], a ; $cc2a + ld a, $1 + ld [H_AUTOBGTRANSFERENABLED], a ; $FF00+$ba + ret + +SomeonesPCText: ; 2148b (8:548b) + db "SOMEONE's PC@" + +BillsPCText: ; 21497 (8:5497) + db "BILL's PC@" + +PlayersPCText: ; 214a0 (8:54a0) + db "'s PC@" + +OaksPCText: ; 214a5 (8:54a5) + db "PROF.OAK's PC@" + +PKMNLeaguePCText: ; 214b2 (8:54b2) + db $4a,"LEAGUE@" + +LogOffPCText: ; 214ba (8:54ba) + db "LOG OFF@" + +Func_214c2: ; 214c2 (8:54c2) +BillsPC_: ; 0x214c2 + ld hl, $d730 + set 6, [hl] + xor a + ld [$ccd3], a + inc a ; MONSTER_NAME + ld [W_LISTTYPE], a + call LoadHpBarAndStatusTilePatterns + ld a, [wListScrollOffset] ; $cc36 + push af + ld a, [wFlags_0xcd60] + bit 3, a + jr nz, BillsPCMenu + ld a, $99 + call PlaySound + ld hl, SwitchOnText + call PrintText + +Func_214e8: ; 214e8 (8:54e8) +BillsPCMenu: + ld a, [$ccd3] + ld [wCurrentMenuItem], a ; $cc26 + ld hl, $9780 + ld de, PokeballTileGraphics ; $697e + ld bc, (BANK(PokeballTileGraphics) << 8) + $01 + call CopyVideoData + call LoadScreenTilesFromBuffer2DisableBGTransfer + ld hl, wTileMap + ld b, $a + ld c, $c + call TextBoxBorder + FuncCoord 2, 2 ; $c3ca + ld hl, Coord + ld de, BillsPCMenuText ; $56e1 + call PlaceString + ld hl, wTopMenuItemY ; $cc24 + ld a, $2 + ld [hli], a + dec a + ld [hli], a + inc hl + inc hl + ld a, $4 + ld [hli], a + ld a, $3 + ld [hli], a + xor a + ld [hli], a + ld [hli], a + ld hl, wListScrollOffset ; $cc36 + ld [hli], a + ld [hl], a + ld [wPlayerMonNumber], a ; $cc2f + ld hl, WhatText + call PrintText + FuncCoord 9, 14 ; $c4c1 + ld hl, Coord + ld b, $2 + ld c, $9 + call TextBoxBorder + ld a, [$d5a0] + and $7f + cp $9 + jr c, .asm_2154f + sub $9 + FuncCoord 17, 16 ; $c4f1 + ld hl, Coord + ld [hl], $f7 + add $f6 + jr .asm_21551 +.asm_2154f + add $f7 +.asm_21551 + FuncCoord 18, 16 ; $c4f2 + ld [Coord], a + FuncCoord 10, 16 ; $c4ea + ld hl, Coord + ld de, BoxNoPCText ; $5713 + call PlaceString + ld a, $1 + ld [H_AUTOBGTRANSFERENABLED], a ; $FF00+$ba + call Delay3 + call HandleMenuInput + bit 1, a + jp nz, Func_21588 ; b button + call PlaceUnfilledArrowMenuCursor + ld a, [wCurrentMenuItem] ; $cc26 + ld [$ccd3], a + and a + jp z, Func_21618 ; withdraw + cp $1 + jp z, Func_215ac ; deposit + cp $2 + jp z, Func_21673 ; release + cp $3 + jp z, Func_216b3 ; change box + +Func_21588: ; 21588 (8:5588) + ld a, [wFlags_0xcd60] + bit 3, a + jr nz, .asm_2159a + call LoadTextBoxTilePatterns + ld a, $9a + call PlaySound + call WaitForSoundToFinish +.asm_2159a + ld hl, wFlags_0xcd60 + res 5, [hl] + call LoadScreenTilesFromBuffer2 + pop af + ld [wListScrollOffset], a ; $cc36 + ld hl, $d730 + res 6, [hl] + ret + +Func_215ac: ; 215ac (8:55ac) +BillsPCDeposit: + ld a, [W_NUMINPARTY] ; $d163 + dec a + jr nz, .asm_215bb + ld hl, CantDepositLastMonText + call PrintText + jp BillsPCMenu +.asm_215bb + ld a, [W_NUMINBOX] ; $da80 + cp $14 + jr nz, .asm_215cb + ld hl, BoxFullText ; $5802 + call PrintText + jp BillsPCMenu +.asm_215cb + ld hl, W_NUMINPARTY ; $d163 + call Func_216be + jp c, BillsPCMenu + call Func_2174b + jp nc, BillsPCMenu + ld a, [$cf91] + call GetCryData + call PlaySoundWaitForCurrent + ld a, $1 + ld [$cf95], a + call Func_3a68 + xor a + ld [$cf95], a + call RemovePokemon + call WaitForSoundToFinish + ld hl, wWhichTrade ; $cd3d + ld a, [$d5a0] + and $7f + cp $9 + jr c, .asm_2160a + sub $9 + ld [hl], $f7 + inc hl + add $f6 + jr .asm_2160c +.asm_2160a + add $f7 +.asm_2160c + ld [hli], a + ld [hl], $50 + ld hl, MonWasStoredText ; $57f8 + call PrintText + jp BillsPCMenu + +Func_21618: ; 21618 (8:5618) + ld a, [W_NUMINBOX] ; $da80 + and a + jr nz, .asm_21627 + ld hl, NoMonText ; $580c + call PrintText + jp Func_214e8 +.asm_21627 + ld a, [W_NUMINPARTY] ; $d163 + cp $6 + jr nz, .asm_21637 + ld hl, CantTakeMonText ; $5811 + call PrintText + jp Func_214e8 +.asm_21637 + ld hl, W_NUMINBOX ; $da80 + call Func_216be + jp c, Func_214e8 + call Func_2174b + jp nc, Func_214e8 + ld a, [wWhichPokemon] ; $cf92 + ld hl, $de06 + call GetPartyMonName + ld a, [$cf91] + call GetCryData + call PlaySoundWaitForCurrent + xor a + ld [$cf95], a + call Func_3a68 + ld a, $1 + ld [$cf95], a + call RemovePokemon + call WaitForSoundToFinish + ld hl, MonIsTakenOutText ; $5807 + call PrintText + jp Func_214e8 + +Func_21673: ; 21673 (8:5673) + ld a, [W_NUMINBOX] ; $da80 + and a + jr nz, .asm_21682 + ld hl, NoMonText ; $580c + call PrintText + jp Func_214e8 +.asm_21682 + ld hl, W_NUMINBOX ; $da80 + call Func_216be + jp c, Func_214e8 + ld hl, OnceReleasedText ; $581b + call PrintText + call YesNoChoice + ld a, [wCurrentMenuItem] ; $cc26 + and a + jr nz, .asm_21682 + inc a + ld [$cf95], a + call RemovePokemon + call WaitForSoundToFinish + ld a, [$cf91] + call PlayCry + ld hl, MonWasReleasedText ; $5820 + call PrintText + jp Func_214e8 + +Func_216b3: ; 216b3 (8:56b3) + ld b, BANK(Func_738a1) + ld hl, Func_738a1 + call Bankswitch ; indirect jump to Func_738a1 (738a1 (1c:78a1)) + jp Func_214e8 + +Func_216be: ; 216be (8:56be) + ld a, l + ld [$cf8b], a + ld a, h + ld [$cf8c], a + xor a + ld [$cf93], a + ld [wListMenuID], a ; $cf94 + inc a ; MONSTER_NAME + ld [W_LISTTYPE], a + ld a, [$cc2b] + ld [wCurrentMenuItem], a ; $cc26 + call DisplayListMenuID + ld a, [wCurrentMenuItem] ; $cc26 + ld [$cc2b], a + ret + +BillsPCMenuText: ; 216e1 (8:56e1) + db "WITHDRAW ",$4a,$4e,"DEPOSIT ",$4a,$4e,"RELEASE ",$4a,$4e,"CHANGE BOX",$4e,"SEE YA!@" + +BoxNoPCText: ; 21713 (8:5713) + db "BOX No.@" + +Func_2171b: ; 2171b (8:571b) + ld hl, $d173 + ld bc, $002c + jr .asm_21729 ; 0x21721 $6 + ld hl, $da9e + ld bc, $0021 +.asm_21729 + ld a, [$cf92] + call AddNTimes + ld b, $4 +.asm_21731 + ld a, [hli] + push hl + push bc + ld hl, HMMoveArray ; $5745 + ld de, $0001 + call IsInArray + pop bc + pop hl + ret c + dec b + jr nz, .asm_21731 ; 0x21741 $ee + and a + ret + +HMMoveArray: ; 21745 (8:5745) + db CUT + db FLY + db SURF + db STRENGTH + db FLASH + db $ff + +Func_2174b: ; 2174b (8:574b) + FuncCoord 9, 10 ; $c471 + ld hl, Coord + ld b, $6 + ld c, $9 + call TextBoxBorder + ld a, [$ccd3] + and a + ld de, DepositPCText ; $57cb + jr nz, .asm_21761 + ld de, WithdrawPCText ; $57d3 +.asm_21761 + FuncCoord 11, 12 ; $c49b + ld hl, Coord + call PlaceString + FuncCoord 11, 14 ; $c4c3 + ld hl, Coord + ld de, StatsCancelPCText ; $57dc + call PlaceString + ld hl, wTopMenuItemY ; $cc24 + ld a, $c + ld [hli], a + ld a, $a + ld [hli], a + xor a + ld [hli], a + inc hl + ld a, $2 + ld [hli], a + ld a, $3 + ld [hli], a + xor a + ld [hl], a + ld hl, wListScrollOffset ; $cc36 + ld [hli], a + ld [hl], a + ld [wPlayerMonNumber], a ; $cc2f + ld [$cc2b], a +.asm_2178f + call HandleMenuInput + bit 1, a + jr nz, .asm_2179f + ld a, [wCurrentMenuItem] ; $cc26 + and a + jr z, .asm_217a1 + dec a + jr z, .asm_217a3 +.asm_2179f + and a + ret +.asm_217a1 + scf + ret +.asm_217a3 + call SaveScreenTilesToBuffer1 + ld a, [$ccd3] + and a + ld a, $0 + jr nz, .asm_217b0 + ld a, $2 +.asm_217b0 + ld [$cc49], a + ld a, $36 + call Predef ; indirect jump to StatusScreen (12953 (4:6953)) + ld a, $37 + call Predef ; indirect jump to StatusScreen2 (12b57 (4:6b57)) + call LoadScreenTilesFromBuffer1 + call ReloadTilesetTilePatterns + call GoPAL_SET_CF1C + call LoadGBPal + jr .asm_2178f + +DepositPCText: ; 217cb (8:57cb) + db "DEPOSIT@" + +WithdrawPCText: ; 217d3 (8:57d3) + db "WITHDRAW@" + +StatsCancelPCText: ; 217dc (8:57dc) + db "STATS",$4e,"CANCEL@" + +SwitchOnText: ; 0x217e9 + TX_FAR _SwitchOnText + db "@" + +WhatText: ; 0x217ee + TX_FAR _WhatText + db "@" + +DepositWhichMonText: ; 0x217f3 + TX_FAR _DepositWhichMonText + db "@" + +MonWasStoredText: ; 0x217f8 + TX_FAR _MonWasStoredText + db "@" + +CantDepositLastMonText: ; 0x217fd + TX_FAR _CantDepositLastMonText + db "@" + +BoxFullText: ; 0x21802 + TX_FAR _BoxFullText + db "@" + +MonIsTakenOutText: ; 0x21807 + TX_FAR _MonIsTakenOutText + db "@" + +NoMonText: ; 0x2180c + TX_FAR _NoMonText + db "@" + +CantTakeMonText: ; 0x21811 + TX_FAR _CantTakeMonText + db "@" + +ReleaseWhichMonText: ; 0x21816 + TX_FAR _ReleaseWhichMonText + db "@" + +OnceReleasedText: ; 0x2181b + TX_FAR _OnceReleasedText + db "@" + +MonWasReleasedText: ; 0x21820 + TX_FAR _MonWasReleasedText + db "@" + +Func_21825: ; 5824 (8:5825) + ld a, [$ff00+$aa] + cp $1 + ret z + ld a, [$c109] + cp $c + ret nz + ld a, [$d35e] + cp $ef + ld a, $2 + jr z, .asm_2183a + inc a +.asm_2183a + ld [$d12b], a + call EnableAutoTextBoxDrawing + ld a, $22 + jp Func_3ef5 + +Func_21845: ; 5845 (8:5845) + ld a, [$ff00+$aa] + cp $2 + ret z + ld a, [$c109] + cp $8 + ret nz + ld a, [$d35e] + cp $ef + ld a, $2 + jr z, .asm_2185a + inc a +.asm_2185a + ld [$d12b], a + call EnableAutoTextBoxDrawing + ld a, $22 + jp Func_3ef5 + +UnnamedText_21865: ; 21865 (8:5865) + TX_FAR _UnnamedText_21865 + db "@" + + ld a, [$c109] + cp $4 + ret nz + call EnableAutoTextBoxDrawing + ld a, $23 + jp Func_3ef5 + +Unknown_21878: ; 21878 (8:5878) + db $FD + diff --git a/music/blue/sfx_1f_5d.asm b/music/blue/sfx_1f_5d.asm deleted file mode 100644 index 8b1ce426..00000000 --- a/music/blue/sfx_1f_5d.asm +++ /dev/null @@ -1,20 +0,0 @@ -SFX_1f_5d_Ch1: ; 7c45e (1f:445e) - duty 2 - unknownsfx0x20 3, 228, 0, 6 - unknownsfx0x20 3, 228, 128, 6 - unknownsfx0x20 3, 228, 192, 6 - unknownsfx0x20 3, 228, 0, 7 - unknownsfx0x20 15, 242, 224, 7 - endchannel - - -SFX_1f_5d_Ch2: ; 7c475 (1f:4475) - duty 2 - unknownsfx0x20 3, 8, 0, 0 - unknownsfx0x20 3, 196, 1, 6 - unknownsfx0x20 3, 196, 129, 6 - unknownsfx0x20 3, 196, 193, 6 - unknownsfx0x20 3, 196, 1, 7 - unknownsfx0x20 15, 210, 225, 7 - endchannel -; 0x7c490
\ No newline at end of file diff --git a/music/sfx/sfx_1f_5d.asm b/music/sfx/sfx_1f_5d.asm index f8ce8d23..297f826d 100644 --- a/music/sfx/sfx_1f_5d.asm +++ b/music/sfx/sfx_1f_5d.asm @@ -1,20 +1,37 @@ SFX_1f_5d_Ch1: ; 7c45e (1f:445e) duty 2 +IF _RED unknownsfx0x20 4, 244, 0, 7 unknownsfx0x20 3, 228, 128, 6 unknownsfx0x20 3, 228, 192, 6 unknownsfx0x20 3, 228, 0, 7 unknownsfx0x20 2, 228, 160, 7 +ELSE + unknownsfx0x20 3, 228, 0, 6 + unknownsfx0x20 3, 228, 128, 6 + unknownsfx0x20 3, 228, 192, 6 + unknownsfx0x20 3, 228, 0, 7 + unknownsfx0x20 15, 242, 224, 7 +ENDC endchannel SFX_1f_5d_Ch2: ; 7c475 (1f:4475) duty 2 +IF _RED unknownsfx0x20 4, 8, 0, 0 unknownsfx0x20 3, 212, 1, 7 unknownsfx0x20 3, 196, 129, 6 unknownsfx0x20 3, 196, 193, 6 unknownsfx0x20 3, 196, 1, 7 unknownsfx0x20 2, 196, 161, 7 +ELSE + unknownsfx0x20 3, 8, 0, 0 + unknownsfx0x20 3, 196, 1, 6 + unknownsfx0x20 3, 196, 129, 6 + unknownsfx0x20 3, 196, 193, 6 + unknownsfx0x20 3, 196, 1, 7 + unknownsfx0x20 15, 210, 225, 7 +ENDC endchannel -; 0x7c490
\ No newline at end of file +; 0x7c490 diff --git a/pokeblue.asm b/pokeblue.asm index dd621ca4..254e4b38 100644 --- a/pokeblue.asm +++ b/pokeblue.asm @@ -1,5 +1,4 @@ -_RED EQU 0 -_BLUE EQU 1 +INCLUDE "blue.asm" INCLUDE "globals.asm" INCLUDE "wram.asm" INCLUDE "main.asm" diff --git a/pokered.asm b/pokered.asm index bcc826c8..c2d3a507 100644 --- a/pokered.asm +++ b/pokered.asm @@ -1,5 +1,4 @@ -_RED EQU 1 -_BLUE EQU 0 +INCLUDE "red.asm" INCLUDE "globals.asm" INCLUDE "wram.asm" INCLUDE "main.asm" diff --git a/red.asm b/red.asm new file mode 100644 index 00000000..882bf66a --- /dev/null +++ b/red.asm @@ -0,0 +1,2 @@ +_RED EQU 1 +_BLUE EQU 0 |