From 94d755003ebd0abee80e276f2af964a453ec3ca1 Mon Sep 17 00:00:00 2001 From: yenatch Date: Mon, 6 Jan 2014 22:34:14 -0500 Subject: split out the audio engines --- audio/engine_1.asm | 1682 ++++++++ audio/engine_2.asm | 1733 ++++++++ audio/engine_3.asm | 1682 ++++++++ main.asm | 10946 ++++++++++++++------------------------------------- 4 files changed, 8032 insertions(+), 8011 deletions(-) create mode 100644 audio/engine_1.asm create mode 100644 audio/engine_2.asm create mode 100644 audio/engine_3.asm 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/main.asm b/main.asm index 8ebf2ebb..fc08389e 100755 --- a/main.asm +++ b/main.asm @@ -18485,1814 +18485,139 @@ PlayBattleMusic: ; 0x90c6 .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 +INCLUDE "audio/engine_1.asm" -; 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 +; 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 - 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 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 - 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 +; 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 - 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 + ld de, Music_MeetRival_branch_b119 + jp Music2_OverwriteChannelPointer -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 +; applies both the alternate start and alternate tempo +Music_RivalAlternateStartAndTempo: ; 0x9b75 + call Music_RivalAlternateStart 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 + ld de, Music_MeetRival_branch_b19b + jp Music2_OverwriteChannelPointer - ; 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 +; 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 -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 +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" -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 +SECTION "bank3",ROMX,BANK[$3] -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 +_GetJoypadState: ; c000 (3:4000) + ld a, [H_JOYPADSTATE] + cp BTN_A | BTN_B | BTN_SELECT | BTN_START ; soft reset sequence + jp z, HandleJoypadResetButtons 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 a, [H_OLDPRESSEDBUTTONS] 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 + xor b 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 + and e + ld [H_NEWLYRELEASEDBUTTONS], a ld a, d - and $f - ld d, a + and b + ld [H_NEWLYPRESSEDBUTTONS], 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] + ld [H_OLDPRESSEDBUTTONS], a + ld a, [$d730] + bit 5, a + jr nz, DiscardButtonPresses + ld a, [H_OLDPRESSEDBUTTONS] + ld [H_CURRENTPRESSEDBUTTONS], a + ld a, [wJoypadForbiddenButtonsMask] 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 z + cpl + ld b, a + ld a, [H_CURRENTPRESSEDBUTTONS] + and b + ld [H_CURRENTPRESSEDBUTTONS], a + ld a, [H_NEWLYPRESSEDBUTTONS] + and b + ld [H_NEWLYPRESSEDBUTTONS], a 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 +; clears all button presses +DiscardButtonPresses: ; c034 (3:4034) + xor a + ld [H_CURRENTPRESSEDBUTTONS], a + ld [H_NEWLYPRESSEDBUTTONS], a + ld [H_NEWLYRELEASEDBUTTONS], 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] - -_GetJoypadState: ; c000 (3:4000) - ld a, [H_JOYPADSTATE] - cp BTN_A | BTN_B | BTN_SELECT | BTN_START ; soft reset sequence - jp z, HandleJoypadResetButtons - ld b, a - ld a, [H_OLDPRESSEDBUTTONS] - ld e, a - xor b - ld d, a - and e - ld [H_NEWLYRELEASEDBUTTONS], a - ld a, d - and b - ld [H_NEWLYPRESSEDBUTTONS], a - ld a, b - ld [H_OLDPRESSEDBUTTONS], a - ld a, [$d730] - bit 5, a - jr nz, DiscardButtonPresses - ld a, [H_OLDPRESSEDBUTTONS] - ld [H_CURRENTPRESSEDBUTTONS], a - ld a, [wJoypadForbiddenButtonsMask] - and a - ret z - cpl - ld b, a - ld a, [H_CURRENTPRESSEDBUTTONS] - and b - ld [H_CURRENTPRESSEDBUTTONS], a - ld a, [H_NEWLYPRESSEDBUTTONS] - and b - ld [H_NEWLYPRESSEDBUTTONS], a - ret - -; clears all button presses -DiscardButtonPresses: ; c034 (3:4034) - xor a - ld [H_CURRENTPRESSEDBUTTONS], a - ld [H_NEWLYPRESSEDBUTTONS], a - ld [H_NEWLYRELEASEDBUTTONS], a - ret - -HandleJoypadResetButtons: ; c03c (3:403c) - call DelayFrame - ld a, $30 - ld [rJOYP], a ; reset joypad state (to enusre the user really intends to reset) - ld hl, H_SOFTRESETCOUNTER - dec [hl] - jp z, SoftReset - jp GetJoypadState +HandleJoypadResetButtons: ; c03c (3:403c) + call DelayFrame + ld a, $30 + ld [rJOYP], a ; reset joypad state (to enusre the user really intends to reset) + ld hl, H_SOFTRESETCOUNTER + dec [hl] + jp z, SoftReset + jp GetJoypadState MapSongBanks: ; c04d (3:404d) db (Music_PalletTown - $4000) / 3 @@ -43231,3812 +41556,2086 @@ Route8GateScript0: ; 1e1ee (7:61ee) ld [$ff00+$8c], a jp DisplayTextID -CoordsData_1e22c: ; 1e22c (7:622c) - db 3,2 - db 4,2 - db $ff - -Route8GateScript1: ; 1e231 (7:6231) - ld a, [$cd38] - and a - ret nz - call Delay3 - xor a - ld [wJoypadForbiddenButtonsMask], a - ld [W_ROUTE8GATECURSCRIPT], a - ret - -Route8GateTextPointers: ; 1e241 (7:6241) - dw Route8GateText1 - dw Route8GateText2 - dw Route8GateText3 - -Route8GateObject: ; 0x1e247 (size=42) - db $a ; border tile - - db $4 ; warps - db $3, $0, $0, $ff - db $4, $0, $1, $ff - db $3, $5, $2, $ff - db $4, $5, $3, $ff - - db $0 ; signs - - db $1 ; people - db SPRITE_GUARD, $1 + 4, $2 + 4, $ff, $d0, $1 ; person - - ; warp-to - EVENT_DISP $3, $3, $0 - EVENT_DISP $3, $4, $0 - EVENT_DISP $3, $3, $5 - EVENT_DISP $3, $4, $5 - -Route8GateBlocks: ; 1e271 (7:6271) - INCBIN "maps/route8gate.blk" - -UndergroundPathEntranceRoute8_h: ; 0x1e27d to 0x1e289 (12 bytes) (bank=7) (id=80) - db $0c ; tileset - db PATH_ENTRANCE_ROUTE_8_HEIGHT, PATH_ENTRANCE_ROUTE_8_WIDTH ; dimensions (y, x) - dw UndergroundPathEntranceRoute8Blocks, UndergroundPathEntranceRoute8TextPointers, UndergroundPathEntranceRoute8Script ; blocks, texts, scripts - db $00 ; connections - dw UndergroundPathEntranceRoute8Object ; objects - -UndergroundPathEntranceRoute8Script: ; 1e289 (7:6289) - ld a, $13 - ld [$d365], a - jp EnableAutoTextBoxDrawing - -UndergroundPathEntranceRoute8TextPointers: ; 1e291 (7:6291) - dw UndergroundPathEntranceRoute8Text1 - -UndergroundPathEntranceRoute8Text1: ; 1e293 (7:6293) - TX_FAR _UndergroundPathEntRoute8Text1 - db "@" - -UndergroundPathEntranceRoute8Object: ; 0x1e298 (size=34) - db $a ; border tile - - db $3 ; warps - db $7, $3, $4, $ff - db $7, $4, $4, $ff - db $4, $4, $1, UNDERGROUND_PATH_WE - - db $0 ; signs - - db $1 ; people - db SPRITE_GIRL, $4 + 4, $3 + 4, $ff, $ff, $1 ; person - - ; warp-to - EVENT_DISP $4, $7, $3 - EVENT_DISP $4, $7, $4 - EVENT_DISP $4, $4, $4 ; UNDERGROUND_PATH_WE - -PowerPlant_h: ; 0x1e2ba to 0x1e2c6 (12 bytes) (bank=7) (id=83) - db $16 ; tileset - db POWER_PLANT_HEIGHT, POWER_PLANT_WIDTH ; dimensions (y, x) - dw PowerPlantBlocks, PowerPlantTextPointers, PowerPlantScript ; blocks, texts, scripts - db $00 ; connections - dw PowerPlantObject ; objects - -PowerPlantScript: ; 1e2c6 (7:62c6) - call EnableAutoTextBoxDrawing - ld hl, PowerPlantTrainerHeaders - ld de, PowerPlantScriptPointers - ld a, [W_POWERPLANTCURSCRIPT] - call ExecuteCurMapScriptInTable - ld [W_POWERPLANTCURSCRIPT], a - ret - -PowerPlantScriptPointers: ; 1e2d9 (7:62d9) - dw CheckFightingMapTrainers - dw Func_324c - dw EndTrainerBattle - -PowerPlantTextPointers: ; 1e2df (7:62df) - dw PowerPlantText1 - dw PowerPlantText2 - dw PowerPlantText3 - dw PowerPlantText4 - dw PowerPlantText5 - dw PowerPlantText6 - dw PowerPlantText7 - dw PowerPlantText8 - dw PowerPlantText9 - dw Predef5CText - dw Predef5CText - dw Predef5CText - dw Predef5CText - dw Predef5CText - -PowerPlantTrainerHeaders: ; 1e2fb (7:62fb) -PowerPlantTrainerHeader0: ; 1e2fb (7:62fb) - db 1 ; flag's bit - db 0 ; view range - dw $d7d3 ; flag's byte - dw VoltorbBattleText ; TextBeforeBattle - dw VoltorbBattleText ; TextAfterBattle - dw VoltorbBattleText ; TextEndBattle - dw VoltorbBattleText ; TextEndBattle - -PowerPlantTrainerHeader1: ; 1e307 (7:6307) - db 2 ; flag's bit - db 0 ; view range - dw $d7d3 ; flag's byte - dw VoltorbBattleText ; TextBeforeBattle - dw VoltorbBattleText ; TextAfterBattle - dw VoltorbBattleText ; TextEndBattle - dw VoltorbBattleText ; TextEndBattle - -PowerPlantTrainerHeader2: ; 1e313 (7:6313) - db 3 ; flag's bit - db 0 ; view range - dw $d7d3 ; flag's byte - dw VoltorbBattleText ; TextBeforeBattle - dw VoltorbBattleText ; TextAfterBattle - dw VoltorbBattleText ; TextEndBattle - dw VoltorbBattleText ; TextEndBattle - -PowerPlantTrainerHeader3: ; 1e31f (7:631f) - db 4 ; flag's bit - db 0 ; view range - dw $d7d3 ; flag's byte - dw VoltorbBattleText ; TextBeforeBattle - dw VoltorbBattleText ; TextAfterBattle - dw VoltorbBattleText ; TextEndBattle - dw VoltorbBattleText ; TextEndBattle - -PowerPlantTrainerHeader4: ; 1e32b (7:632b) - db 5 ; flag's bit - db 0 ; view range - dw $d7d3 ; flag's byte - dw VoltorbBattleText ; TextBeforeBattle - dw VoltorbBattleText ; TextAfterBattle - dw VoltorbBattleText ; TextEndBattle - dw VoltorbBattleText ; TextEndBattle - -PowerPlantTrainerHeader5: ; 1e337 (7:6337) - db 6 ; flag's bit - db 0 ; view range - dw $d7d3 ; flag's byte - dw VoltorbBattleText ; TextBeforeBattle - dw VoltorbBattleText ; TextAfterBattle - dw VoltorbBattleText ; TextEndBattle - dw VoltorbBattleText ; TextEndBattle - -PowerPlantTrainerHeader6: ; 1e343 (7:6343) - db 7 ; flag's bit - db 0 ; view range - dw $d7d3 ; flag's byte - dw VoltorbBattleText ; TextBeforeBattle - dw VoltorbBattleText ; TextAfterBattle - dw VoltorbBattleText ; TextEndBattle - dw VoltorbBattleText ; TextEndBattle - -PowerPlantTrainerHeader7: ; 1e34f (7:634f) - db 8 ; flag's bit - db 0 ; view range - dw $d7d3 ; flag's byte - dw VoltorbBattleText ; TextBeforeBattle - dw VoltorbBattleText ; TextAfterBattle - dw VoltorbBattleText ; TextEndBattle - dw VoltorbBattleText ; TextEndBattle - -PowerPlantTrainerHeader8: ; 1e35b (7:635b) - db 9 ; flag's bit - db 0 ; view range - dw $d7d3 ; flag's byte - dw ZapdosBattleText ; TextBeforeBattle - dw ZapdosBattleText ; TextAfterBattle - dw ZapdosBattleText ; TextEndBattle - dw ZapdosBattleText ; TextEndBattle - - db $ff - -asm_234cc: ; 1e368 (7:6368) - call TalkToTrainer - ld a, [W_CURMAPSCRIPT] - ld [W_POWERPLANTCURSCRIPT], a - jp TextScriptEnd - -PowerPlantText1: ; 1e374 (7:6374) - db $8 ; asm - ld hl, PowerPlantTrainerHeader0 ; $62fb - jr asm_234cc ; 0x1e378 $ee - -PowerPlantText2: ; 1e37a (7:637a) - db $8 ; asm - ld hl, PowerPlantTrainerHeader1 ; $6307 - jr asm_234cc ; 0x1e37e $e8 - -PowerPlantText3: ; 1e380 (7:6380) - db $8 ; asm - ld hl, PowerPlantTrainerHeader2 ; $6313 - jr asm_234cc ; 0x1e384 $e2 - -PowerPlantText4: ; 1e386 (7:6386) - db $8 ; asm - ld hl, PowerPlantTrainerHeader3 ; $631f - jr asm_234cc ; 0x1e38a $dc - -PowerPlantText5: ; 1e38c (7:638c) - db $8 ; asm - ld hl, PowerPlantTrainerHeader4 ; $632b - jr asm_234cc ; 0x1e390 $d6 - -PowerPlantText6: ; 1e392 (7:6392) - db $8 ; asm - ld hl, PowerPlantTrainerHeader5 ; $6337 - jr asm_234cc ; 0x1e396 $d0 - -PowerPlantText7: ; 1e398 (7:6398) - db $8 ; asm - ld hl, PowerPlantTrainerHeader6 ; $6343 - jr asm_234cc ; 0x1e39c $ca - -PowerPlantText8: ; 1e39e (7:639e) - db $8 ; asm - ld hl, PowerPlantTrainerHeader7 ; $634f - jr asm_234cc ; 0x1e3a2 $c4 - -PowerPlantText9: ; 1e3a4 (7:63a4) - db $8 ; asm - ld hl, PowerPlantTrainerHeader8 ; $635b - jr asm_234cc ; 0x1e3a8 $be - -VoltorbBattleText: ; 1e3aa (7:63aa) - TX_FAR _VoltorbBattleText ; 0x8c5e2 - db "@" - -ZapdosBattleText: ; 1e3af (7:63af) - TX_FAR _ZapdosBattleText ; 0x8c5ea - db $8 - ld a, ZAPDOS - call PlayCry - call WaitForSoundToFinish - jp TextScriptEnd - -PowerPlantObject: ; 0x1e3bf (size=135) - db $2e ; border tile - - db $3 ; warps - db $23, $4, $3, $ff - db $23, $5, $3, $ff - db $b, $0, $3, $ff - - db $0 ; signs - - db $e ; people - db SPRITE_BALL, $14 + 4, $9 + 4, $ff, $ff, $41, VOLTORB, 40 ; trainer - db SPRITE_BALL, $12 + 4, $20 + 4, $ff, $ff, $42, VOLTORB, 40 ; trainer - db SPRITE_BALL, $19 + 4, $15 + 4, $ff, $ff, $43, VOLTORB, 40 ; trainer - db SPRITE_BALL, $12 + 4, $19 + 4, $ff, $ff, $44, ELECTRODE, 43 ; trainer - db SPRITE_BALL, $22 + 4, $17 + 4, $ff, $ff, $45, VOLTORB, 40 ; trainer - db SPRITE_BALL, $1c + 4, $1a + 4, $ff, $ff, $46, VOLTORB, 40 ; trainer - db SPRITE_BALL, $e + 4, $15 + 4, $ff, $ff, $47, ELECTRODE, 43 ; trainer - db SPRITE_BALL, $20 + 4, $25 + 4, $ff, $ff, $48, VOLTORB, 40 ; trainer - db SPRITE_BIRD, $9 + 4, $4 + 4, $ff, $d1, $49, ZAPDOS, 50 ; trainer - db SPRITE_BALL, $19 + 4, $7 + 4, $ff, $ff, $8a, CARBOS ; item - db SPRITE_BALL, $3 + 4, $1c + 4, $ff, $ff, $8b, HP_UP ; item - db SPRITE_BALL, $3 + 4, $22 + 4, $ff, $ff, $8c, RARE_CANDY ; item - db SPRITE_BALL, $20 + 4, $1a + 4, $ff, $ff, $8d, TM_25 ; item - db SPRITE_BALL, $20 + 4, $14 + 4, $ff, $ff, $8e, TM_33 ; item - - ; warp-to - EVENT_DISP $14, $23, $4 - EVENT_DISP $14, $23, $5 - EVENT_DISP $14, $b, $0 - -PowerPlantBlocks: ; 1e446 (7:6446) - INCBIN "maps/powerplant.blk" - -DiglettsCaveEntranceRoute11_h: ; 0x1e5ae to 0x1e5ba (12 bytes) (bank=7) (id=85) - db $11 ; tileset - db DIGLETTS_CAVE_ENTRANCE_HEIGHT, DIGLETTS_CAVE_ENTRANCE_WIDTH ; dimensions (y, x) - dw DiglettsCaveEntranceRoute11Blocks, DiglettsCaveEntranceRoute11TextPointers, DiglettsCaveEntranceRoute11Script ; blocks, texts, scripts - db $00 ; connections - dw DiglettsCaveEntranceRoute11Object ; objects - -DiglettsCaveEntranceRoute11Script: ; 1e5ba (7:65ba) - call EnableAutoTextBoxDrawing - ld a, $16 - ld [$d365], a - ret - -DiglettsCaveEntranceRoute11TextPointers: ; 1e5c3 (7:65c3) - dw DiglettsCaveEntranceRoute11Text1 - -DiglettsCaveEntranceRoute11Text1: ; 1e5c5 (7:65c5) - TX_FAR _DiglettsCaveEntRoute11Text1 - db "@" - -DiglettsCaveEntranceRoute11Object: ; 0x1e5ca (size=34) - db $7d ; border tile - - db $3 ; warps - db $7, $2, $4, $ff - db $7, $3, $4, $ff - db $4, $4, $1, DIGLETTS_CAVE - - db $0 ; signs - - db $1 ; people - db SPRITE_GAMBLER, $3 + 4, $2 + 4, $ff, $ff, $1 ; person - - ; warp-to - EVENT_DISP $4, $7, $2 - EVENT_DISP $4, $7, $3 - EVENT_DISP $4, $4, $4 ; DIGLETTS_CAVE - -Route16House_h: ; 0x1e5ec to 0x1e5f8 (12 bytes) (bank=7) (id=188) - db $08 ; tileset - db ROUTE_16_HOUSE_HEIGHT, ROUTE_16_HOUSE_WIDTH ; dimensions (y, x) - dw Route16HouseBlocks, Route16HouseTextPointers, Route16HouseScript ; blocks, texts, scripts - db $00 ; connections - dw Route16HouseObject ; objects - -Route16HouseScript: ; 1e5f8 (7:65f8) - jp EnableAutoTextBoxDrawing - -Route16HouseTextPointers: ; 1e5fb (7:65fb) - dw Route16HouseText1 - dw Route16HouseText2 - -Route16HouseText1: ; 1e5ff (7:65ff) - db $08 ; asm - ld a, [$d7e0] - bit 6, a - ld hl, HM02ExplanationText - jr nz, .asm_13616 ; 0x1e608 - ld hl, Route16HouseText3 - call PrintText - ld bc, (HM_02 << 8) | 1 - call GiveItem - jr nc, .BagFull - ld hl, $d7e0 - set 6, [hl] - ld hl, ReceivedHM02Text - jr .asm_13616 ; 0x1e620 -.BagFull - ld hl, HM02NoRoomText -.asm_13616 ; 0x1e625 - call PrintText - jp TextScriptEnd - -Route16HouseText3: ; 1e62b (7:662b) - TX_FAR _Route16HouseText3 - db "@" - -ReceivedHM02Text: ; 1e630 (7:6630) - TX_FAR _ReceivedHM02Text ; 0x8ce66 - db $11, "@" - -HM02ExplanationText: ; 1e636 (7:6636) - TX_FAR _HM02ExplanationText - db "@" - -HM02NoRoomText: ; 1e63b (7:663b) - TX_FAR _HM02NoRoomText - db "@" - -Route16HouseText2: ; 1e640 (7:6640) - db $08 ; asm - ld hl, UnnamedText_1e652 - call PrintText - ld a, FEAROW - call PlayCry - call WaitForSoundToFinish - jp TextScriptEnd - -UnnamedText_1e652: ; 1e652 (7:6652) - TX_FAR _UnnamedText_1e652 - db "@" - -Route16HouseObject: ; 0x1e657 (size=32) - db $a ; border tile - - db $2 ; warps - db $7, $2, $8, $ff - db $7, $3, $8, $ff - - db $0 ; signs - - db $2 ; people - db SPRITE_BRUNETTE_GIRL, $3 + 4, $2 + 4, $ff, $d3, $1 ; person - db SPRITE_BIRD, $4 + 4, $6 + 4, $fe, $0, $2 ; person - - ; warp-to - EVENT_DISP $4, $7, $2 - EVENT_DISP $4, $7, $3 - -Route22Gate_h: ; 0x1e677 to 0x1e683 (12 bytes) (bank=7) (id=193) - db $0c ; tileset - db ROUTE_22_GATE_HEIGHT, ROUTE_22_GATE_WIDTH ; dimensions (y, x) - dw Route22GateBlocks, Route22GateTextPointers, Route22GateScript ; blocks, texts, scripts - db $00 ; connections - dw Route22GateObject ; objects - -Route22GateScript: ; 1e683 (7:6683) - call EnableAutoTextBoxDrawing - ld hl, Route22GateScriptPointers - ld a, [W_ROUTE22GATECURSCRIPT] - call CallFunctionInTable - ld a, [$d361] - cp $4 - ld a, $22 - jr c, .asm_1e69a ; 0x1e696 $2 - ld a, $21 -.asm_1e69a - ld [$d365], a - ret - -Route22GateScriptPointers: ; 1e69e (7:669e) - dw Route22GateScript0 - dw Route22GateScript1 - dw Route22GateScript2 - -Route22GateScript0: ; 1e6a4 (7:66a4) - ld hl, Route22GateScriptCoords - call ArePlayerCoordsInArray - ret nc - xor a - ld [H_CURRENTPRESSEDBUTTONS], a - ld a, $1 - ld [$ff00+$8c], a - jp DisplayTextID - -Route22GateScriptCoords: ; 1e6b5 (7:66b5) - db 2,4 - db 2,5 - db $ff - -Func_1e6ba: ; 1e6ba (7:66ba) - ld a, $1 - ld [$cd38], a - ld a, $80 - ld [$ccd3], a - ld [$c109], a - ld [wJoypadForbiddenButtonsMask], a - jp Func_3486 +CoordsData_1e22c: ; 1e22c (7:622c) + db 3,2 + db 4,2 + db $ff -Route22GateScript1: ; 1e6cd (7:66cd) +Route8GateScript1: ; 1e231 (7:6231) ld a, [$cd38] and a ret nz + call Delay3 xor a ld [wJoypadForbiddenButtonsMask], a - call Delay3 - ld a, $0 - ld [W_ROUTE22GATECURSCRIPT], a -Route22GateScript2: ; 1e6de (7:66de) - ret - -Route22GateTextPointers: ; 1e6df (7:66df) - dw Route22GateText1 - -Route22GateText1: ; 1e6e1 (7:66e1) - db $8 - ld a, [$d356] - bit 0, a - jr nz, .asm_8a809 ; 0x1e6e7 $d - ld hl, UnnamedText_1e704 - call PrintText - call Func_1e6ba - ld a, $1 - jr .asm_20f7e ; 0x1e6f4 $8 -.asm_8a809 ; 0x1e6f6 - ld hl, UnnamedText_1e71a - call PrintText - ld a, $2 -.asm_20f7e ; 0x1e6fe - ld [W_ROUTE22GATECURSCRIPT], a - jp TextScriptEnd - -UnnamedText_1e704: ; 1e704 (7:6704) - TX_FAR _UnnamedText_1e704 ; 0x8cfbb - db $8 - ld a, $a5 - call PlaySoundWaitForCurrent - call WaitForSoundToFinish - ld hl, UnnamedText_1e715 ; $6715 + ld [W_ROUTE8GATECURSCRIPT], a ret -UnnamedText_1e715: ; 1e715 (7:6715) - TX_FAR _UnnamedText_1e715 - db "@" - -UnnamedText_1e71a: ; 1e71a (7:671a) - TX_FAR _UnnamedText_1e71a ; 0x8d03e - db $0B, "@" +Route8GateTextPointers: ; 1e241 (7:6241) + dw Route8GateText1 + dw Route8GateText2 + dw Route8GateText3 -Route22GateObject: ; 0x1e720 (size=42) +Route8GateObject: ; 0x1e247 (size=42) db $a ; border tile db $4 ; warps - db $7, $4, $0, $ff - db $7, $5, $0, $ff - db $0, $4, $0, $ff - db $0, $5, $1, $ff + db $3, $0, $0, $ff + db $4, $0, $1, $ff + db $3, $5, $2, $ff + db $4, $5, $3, $ff db $0 ; signs db $1 ; people - db SPRITE_GUARD, $2 + 4, $6 + 4, $ff, $d2, $1 ; person + db SPRITE_GUARD, $1 + 4, $2 + 4, $ff, $d0, $1 ; person ; warp-to - EVENT_DISP $5, $7, $4 - EVENT_DISP $5, $7, $5 - EVENT_DISP $5, $0, $4 - EVENT_DISP $5, $0, $5 + EVENT_DISP $3, $3, $0 + EVENT_DISP $3, $4, $0 + EVENT_DISP $3, $3, $5 + EVENT_DISP $3, $4, $5 -Route22GateBlocks: ; 1e74a (7:674a) - INCBIN "maps/route22gate.blk" +Route8GateBlocks: ; 1e271 (7:6271) + INCBIN "maps/route8gate.blk" -BillsHouse_h: ; 0x1e75e to 0x1e76a (12 bytes) (bank=7) (id=88) - db $10 ; tileset - db BILLS_HOUSE_HEIGHT, BILLS_HOUSE_WIDTH ; dimensions (y, x) - dw BillsHouseBlocks, BillsHouseTextPointers, BillsHouseScript ; blocks, texts, scripts +UndergroundPathEntranceRoute8_h: ; 0x1e27d to 0x1e289 (12 bytes) (bank=7) (id=80) + db $0c ; tileset + db PATH_ENTRANCE_ROUTE_8_HEIGHT, PATH_ENTRANCE_ROUTE_8_WIDTH ; dimensions (y, x) + dw UndergroundPathEntranceRoute8Blocks, UndergroundPathEntranceRoute8TextPointers, UndergroundPathEntranceRoute8Script ; blocks, texts, scripts db $00 ; connections - dw BillsHouseObject ; objects + dw UndergroundPathEntranceRoute8Object ; objects -BillsHouseScript: ; 1e76a (7:676a) - call EnableAutoTextBoxDrawing - ld a, [W_BILLSHOUSECURSCRIPT] - ld hl, BillsHouseScriptPointers - jp CallFunctionInTable +UndergroundPathEntranceRoute8Script: ; 1e289 (7:6289) + ld a, $13 + ld [$d365], a + jp EnableAutoTextBoxDrawing -BillsHouseScriptPointers: ; 1e776 (7:6776) - dw BillsHouseScript0 - dw BillsHouseScript1 - dw BillsHouseScript2 - dw BillsHouseScript3 - dw BillsHouseScript4 - dw BillsHouseScript5 +UndergroundPathEntranceRoute8TextPointers: ; 1e291 (7:6291) + dw UndergroundPathEntranceRoute8Text1 -BillsHouseScript0: ; 1e782 (7:6782) - ret +UndergroundPathEntranceRoute8Text1: ; 1e293 (7:6293) + TX_FAR _UndergroundPathEntRoute8Text1 + db "@" -BillsHouseScript1: ; 1e783 (7:6783) - ld a, [$c109] - and a - ld de, MovementData_1e79c - jr nz, .asm_1e78f ; 0x1e78a $3 - ld de, MovementData_1e7a0 -.asm_1e78f - ld a, $1 - ld [$ff00+$8c], a - call MoveSprite - ld a, $2 - ld [W_BILLSHOUSECURSCRIPT], a - ret +UndergroundPathEntranceRoute8Object: ; 0x1e298 (size=34) + db $a ; border tile -MovementData_1e79c: ; 1e79c (7:679c) - db $40,$40,$40,$FF + db $3 ; warps + db $7, $3, $4, $ff + db $7, $4, $4, $ff + db $4, $4, $1, UNDERGROUND_PATH_WE -MovementData_1e7a0: ; 1e7a0 (7:67a0) - db $C0,$40,$40,$80,$40,$FF + db $0 ; signs -BillsHouseScript2: ; 1e7a6 (7:67a6) - ld a, [$d730] - bit 0, a - ret nz - ld a, $61 - ld [$cc4d], a - ld a, $11 - call Predef - ld hl, $d7f2 - set 6, [hl] - xor a - ld [wJoypadForbiddenButtonsMask], a - ld a, $3 - ld [W_BILLSHOUSECURSCRIPT], a - ret + db $1 ; people + db SPRITE_GIRL, $4 + 4, $3 + 4, $ff, $ff, $1 ; person -BillsHouseScript3: ; 1e7c5 (7:67c5) - ld a, [$d7f2] - bit 3, a - ret z - ld a, $f0 - ld [wJoypadForbiddenButtonsMask], a - ld a, $2 - ld [$cf13], a - ld a, $c - ld [$ff00+$eb], a - ld a, $40 - ld [$ff00+$ec], a - ld a, $6 - ld [$ff00+$ed], a - ld a, $5 - ld [$ff00+$ee], a - call Func_32f9 - ld a, $62 - ld [$cc4d], a - ld a, $15 - call Predef - ld c, $8 - call DelayFrames - ld a, $2 - ld [$ff00+$8c], a - ld de, MovementData_1e807 - call MoveSprite - ld a, $4 - ld [W_BILLSHOUSECURSCRIPT], a - ret + ; warp-to + EVENT_DISP $4, $7, $3 + EVENT_DISP $4, $7, $4 + EVENT_DISP $4, $4, $4 ; UNDERGROUND_PATH_WE -MovementData_1e807: ; 1e807 (7:6807) - db $00,$C0,$C0,$C0,$00,$FF +PowerPlant_h: ; 0x1e2ba to 0x1e2c6 (12 bytes) (bank=7) (id=83) + db $16 ; tileset + db POWER_PLANT_HEIGHT, POWER_PLANT_WIDTH ; dimensions (y, x) + dw PowerPlantBlocks, PowerPlantTextPointers, PowerPlantScript ; blocks, texts, scripts + db $00 ; connections + dw PowerPlantObject ; objects -BillsHouseScript4: ; 1e80d (7:680d) - ld a, [$d730] - bit 0, a - ret nz - xor a - ld [wJoypadForbiddenButtonsMask], a - ld hl, $d7f2 - set 5, [hl] - ld hl, $d7f1 - set 0, [hl] - ld a, $0 - ld [W_BILLSHOUSECURSCRIPT], a +PowerPlantScript: ; 1e2c6 (7:62c6) + call EnableAutoTextBoxDrawing + ld hl, PowerPlantTrainerHeaders + ld de, PowerPlantScriptPointers + ld a, [W_POWERPLANTCURSCRIPT] + call ExecuteCurMapScriptInTable + ld [W_POWERPLANTCURSCRIPT], a ret -BillsHouseScript5: ; 1e827 (7:6827) - ld a, $4 - ld [$ff00+$8c], a - call DisplayTextID - ld a, $0 - ld [W_BILLSHOUSECURSCRIPT], a - ret +PowerPlantScriptPointers: ; 1e2d9 (7:62d9) + dw CheckFightingMapTrainers + dw Func_324c + dw EndTrainerBattle -BillsHouseTextPointers: ; 1e834 (7:6834) - dw BillsHouseText1 - dw BillsHouseText2 - dw BillsHouseText3 - dw BillsHouseText4 +PowerPlantTextPointers: ; 1e2df (7:62df) + dw PowerPlantText1 + dw PowerPlantText2 + dw PowerPlantText3 + dw PowerPlantText4 + dw PowerPlantText5 + dw PowerPlantText6 + dw PowerPlantText7 + dw PowerPlantText8 + dw PowerPlantText9 + dw Predef5CText + dw Predef5CText + dw Predef5CText + dw Predef5CText + dw Predef5CText -BillsHouseText4: ; 1e83c (7:683c) - db $fd +PowerPlantTrainerHeaders: ; 1e2fb (7:62fb) +PowerPlantTrainerHeader0: ; 1e2fb (7:62fb) + db 1 ; flag's bit + db 0 ; view range + dw $d7d3 ; flag's byte + dw VoltorbBattleText ; TextBeforeBattle + dw VoltorbBattleText ; TextAfterBattle + dw VoltorbBattleText ; TextEndBattle + dw VoltorbBattleText ; TextEndBattle -BillsHouseText1: ; 1e83d (7:683d) - db $8 - ld hl, UnnamedText_1e865 - call PrintText - call YesNoChoice - ld a, [$cc26] - and a - jr nz, asm_6b196 ; 0x1e84b $d -asm_4d03c: ; 1e84d (7:684d) - ld hl, UnnamedText_1e86a - call PrintText - ld a, $1 - ld [W_BILLSHOUSECURSCRIPT], a - jr asm_fd4e2 ; 0x1e858 $8 -asm_6b196: ; 1e85a (7:685a) - ld hl, UnnamedText_1e86f - call PrintText - jr asm_4d03c ; 0x1e860 $eb -asm_fd4e2 ; 0x1e862 - jp TextScriptEnd +PowerPlantTrainerHeader1: ; 1e307 (7:6307) + db 2 ; flag's bit + db 0 ; view range + dw $d7d3 ; flag's byte + dw VoltorbBattleText ; TextBeforeBattle + dw VoltorbBattleText ; TextAfterBattle + dw VoltorbBattleText ; TextEndBattle + dw VoltorbBattleText ; TextEndBattle -UnnamedText_1e865: ; 1e865 (7:6865) - TX_FAR _UnnamedText_1e865 ; 0x8d267 - db "@" +PowerPlantTrainerHeader2: ; 1e313 (7:6313) + db 3 ; flag's bit + db 0 ; view range + dw $d7d3 ; flag's byte + dw VoltorbBattleText ; TextBeforeBattle + dw VoltorbBattleText ; TextAfterBattle + dw VoltorbBattleText ; TextEndBattle + dw VoltorbBattleText ; TextEndBattle -UnnamedText_1e86a: ; 1e86a (7:686a) - TX_FAR _UnnamedText_1e86a ; 0x8d345 - db "@" +PowerPlantTrainerHeader3: ; 1e31f (7:631f) + db 4 ; flag's bit + db 0 ; view range + dw $d7d3 ; flag's byte + dw VoltorbBattleText ; TextBeforeBattle + dw VoltorbBattleText ; TextAfterBattle + dw VoltorbBattleText ; TextEndBattle + dw VoltorbBattleText ; TextEndBattle -UnnamedText_1e86f: ; 1e86f (7:686f) - TX_FAR _UnnamedText_1e86f ; 0x8d391 - db "@" +PowerPlantTrainerHeader4: ; 1e32b (7:632b) + db 5 ; flag's bit + db 0 ; view range + dw $d7d3 ; flag's byte + dw VoltorbBattleText ; TextBeforeBattle + dw VoltorbBattleText ; TextAfterBattle + dw VoltorbBattleText ; TextEndBattle + dw VoltorbBattleText ; TextEndBattle -BillsHouseText2: ; 1e874 (7:6874) - db $08 ; asm - ld a, [$d7f2] - bit 4, a - jr nz, .asm_5491f ; 0x1e87a - ld hl, BillThankYouText - call PrintText - ld bc, (S_S__TICKET << 8) | 1 - call GiveItem - jr nc, .BagFull - ld hl, SSTicketReceivedText - call PrintText - ld hl, $d7f2 - set 4, [hl] - ld a, $7 - ld [$cc4d], a - ld a, $15 - call Predef - ld a, $9 - ld [$cc4d], a - ld a, $11 - call Predef -.asm_5491f ; 0x1e8a9 - ld hl, UnnamedText_1e8cb - call PrintText - jr .asm_bd408 ; 0x1e8af -.BagFull - ld hl, SSTicketNoRoomText - call PrintText -.asm_bd408 ; 0x1e8b7 - jp TextScriptEnd +PowerPlantTrainerHeader5: ; 1e337 (7:6337) + db 6 ; flag's bit + db 0 ; view range + dw $d7d3 ; flag's byte + dw VoltorbBattleText ; TextBeforeBattle + dw VoltorbBattleText ; TextAfterBattle + dw VoltorbBattleText ; TextEndBattle + dw VoltorbBattleText ; TextEndBattle -BillThankYouText: ; 1e8ba (7:68ba) - TX_FAR _BillThankYouText - db "@" +PowerPlantTrainerHeader6: ; 1e343 (7:6343) + db 7 ; flag's bit + db 0 ; view range + dw $d7d3 ; flag's byte + dw VoltorbBattleText ; TextBeforeBattle + dw VoltorbBattleText ; TextAfterBattle + dw VoltorbBattleText ; TextEndBattle + dw VoltorbBattleText ; TextEndBattle -SSTicketReceivedText: ; 1e8bf (7:68bf) - TX_FAR _SSTicketReceivedText ; 0x8d499 - db $11, $6, "@" +PowerPlantTrainerHeader7: ; 1e34f (7:634f) + db 8 ; flag's bit + db 0 ; view range + dw $d7d3 ; flag's byte + dw VoltorbBattleText ; TextBeforeBattle + dw VoltorbBattleText ; TextAfterBattle + dw VoltorbBattleText ; TextEndBattle + dw VoltorbBattleText ; TextEndBattle -SSTicketNoRoomText: ; 1e8c6 (7:68c6) - TX_FAR _SSTicketNoRoomText - db "@" +PowerPlantTrainerHeader8: ; 1e35b (7:635b) + db 9 ; flag's bit + db 0 ; view range + dw $d7d3 ; flag's byte + dw ZapdosBattleText ; TextBeforeBattle + dw ZapdosBattleText ; TextAfterBattle + dw ZapdosBattleText ; TextEndBattle + dw ZapdosBattleText ; TextEndBattle -UnnamedText_1e8cb: ; 1e8cb (7:68cb) - TX_FAR _UnnamedText_1e8cb - db "@" + db $ff -BillsHouseText3: ; 1e8d0 (7:68d0) - db $08 ; asm - ld hl, UnnamedText_1e8da - call PrintText +asm_234cc: ; 1e368 (7:6368) + call TalkToTrainer + ld a, [W_CURMAPSCRIPT] + ld [W_POWERPLANTCURSCRIPT], a jp TextScriptEnd -UnnamedText_1e8da: ; 1e8da (7:68da) - TX_FAR _UnnamedText_1e8da - db "@" +PowerPlantText1: ; 1e374 (7:6374) + db $8 ; asm + ld hl, PowerPlantTrainerHeader0 ; $62fb + jr asm_234cc ; 0x1e378 $ee -BillsHouseObject: ; 0x1e8df (size=38) - db $d ; border tile +PowerPlantText2: ; 1e37a (7:637a) + db $8 ; asm + ld hl, PowerPlantTrainerHeader1 ; $6307 + jr asm_234cc ; 0x1e37e $e8 - db $2 ; warps - db $7, $2, $0, $ff - db $7, $3, $0, $ff +PowerPlantText3: ; 1e380 (7:6380) + db $8 ; asm + ld hl, PowerPlantTrainerHeader2 ; $6313 + jr asm_234cc ; 0x1e384 $e2 - db $0 ; signs +PowerPlantText4: ; 1e386 (7:6386) + db $8 ; asm + ld hl, PowerPlantTrainerHeader3 ; $631f + jr asm_234cc ; 0x1e38a $dc - db $3 ; people - db SPRITE_SLOWBRO, $5 + 4, $6 + 4, $ff, $ff, $1 ; person - db SPRITE_BLACK_HAIR_BOY_2, $4 + 4, $4 + 4, $ff, $ff, $2 ; person - db SPRITE_BLACK_HAIR_BOY_2, $5 + 4, $6 + 4, $ff, $ff, $3 ; person +PowerPlantText5: ; 1e38c (7:638c) + db $8 ; asm + ld hl, PowerPlantTrainerHeader4 ; $632b + jr asm_234cc ; 0x1e390 $d6 - ; warp-to - EVENT_DISP $4, $7, $2 - EVENT_DISP $4, $7, $3 +PowerPlantText6: ; 1e392 (7:6392) + db $8 ; asm + ld hl, PowerPlantTrainerHeader5 ; $6337 + jr asm_234cc ; 0x1e396 $d0 -BillsHouseBlocks: ; 1e905 (7:6905) - INCBIN "maps/billshouse.blk" +PowerPlantText7: ; 1e398 (7:6398) + db $8 ; asm + ld hl, PowerPlantTrainerHeader6 ; $6343 + jr asm_234cc ; 0x1e39c $ca -Func_1e915: ; 1e915 (7:6915) - call SaveScreenTilesToBuffer2 - ld hl, UnnamedText_1e946 ; $6946 - call PrintText - ld hl, UnnamedText_1e93b ; $693b - call PrintText - call YesNoChoice - ld a, [wCurrentMenuItem] ; $cc26 - and a - jr nz, .asm_1e932 - ld a, $56 - call Predef ; indirect jump to DisplayDexRating (44169 (11:4169)) -.asm_1e932 - ld hl, UnnamedText_1e940 ; $6940 - call PrintText - jp LoadScreenTilesFromBuffer2 +PowerPlantText8: ; 1e39e (7:639e) + db $8 ; asm + ld hl, PowerPlantTrainerHeader7 ; $634f + jr asm_234cc ; 0x1e3a2 $c4 -UnnamedText_1e93b: ; 1e93b (7:693b) - TX_FAR _UnnamedText_1e93b +PowerPlantText9: ; 1e3a4 (7:63a4) + db $8 ; asm + ld hl, PowerPlantTrainerHeader8 ; $635b + jr asm_234cc ; 0x1e3a8 $be + +VoltorbBattleText: ; 1e3aa (7:63aa) + TX_FAR _VoltorbBattleText ; 0x8c5e2 db "@" -UnnamedText_1e940: ; 1e940 (7:6940) - TX_FAR _UnnamedText_1e940 - db $0d,"@" +ZapdosBattleText: ; 1e3af (7:63af) + TX_FAR _ZapdosBattleText ; 0x8c5ea + db $8 + ld a, ZAPDOS + call PlayCry + call WaitForSoundToFinish + jp TextScriptEnd -UnnamedText_1e946: ; 1e946 (7:6946) - TX_FAR _UnnamedText_1e946 - db "@" +PowerPlantObject: ; 0x1e3bf (size=135) + db $2e ; border tile -Func_1e94b: ; 1e94b (7:694b) - call EnableAutoTextBoxDrawing - ld a, $39 - jp Func_3ef5 + db $3 ; warps + db $23, $4, $3, $ff + db $23, $5, $3, $ff + db $b, $0, $3, $ff + + db $0 ; signs + + db $e ; people + db SPRITE_BALL, $14 + 4, $9 + 4, $ff, $ff, $41, VOLTORB, 40 ; trainer + db SPRITE_BALL, $12 + 4, $20 + 4, $ff, $ff, $42, VOLTORB, 40 ; trainer + db SPRITE_BALL, $19 + 4, $15 + 4, $ff, $ff, $43, VOLTORB, 40 ; trainer + db SPRITE_BALL, $12 + 4, $19 + 4, $ff, $ff, $44, ELECTRODE, 43 ; trainer + db SPRITE_BALL, $22 + 4, $17 + 4, $ff, $ff, $45, VOLTORB, 40 ; trainer + db SPRITE_BALL, $1c + 4, $1a + 4, $ff, $ff, $46, VOLTORB, 40 ; trainer + db SPRITE_BALL, $e + 4, $15 + 4, $ff, $ff, $47, ELECTRODE, 43 ; trainer + db SPRITE_BALL, $20 + 4, $25 + 4, $ff, $ff, $48, VOLTORB, 40 ; trainer + db SPRITE_BIRD, $9 + 4, $4 + 4, $ff, $d1, $49, ZAPDOS, 50 ; trainer + db SPRITE_BALL, $19 + 4, $7 + 4, $ff, $ff, $8a, CARBOS ; item + db SPRITE_BALL, $3 + 4, $1c + 4, $ff, $ff, $8b, HP_UP ; item + db SPRITE_BALL, $3 + 4, $22 + 4, $ff, $ff, $8c, RARE_CANDY ; item + db SPRITE_BALL, $20 + 4, $1a + 4, $ff, $ff, $8d, TM_25 ; item + db SPRITE_BALL, $20 + 4, $14 + 4, $ff, $ff, $8e, TM_33 ; item -NewBicycleText: ; 1e953 (7:6953) - TX_FAR _NewBicycleText - db "@" + ; warp-to + EVENT_DISP $14, $23, $4 + EVENT_DISP $14, $23, $5 + EVENT_DISP $14, $b, $0 -Func_1e958: ; 1e958 (7:6958) - call EnableAutoTextBoxDrawing - ld a, $05 - jp Func_3ef5 +PowerPlantBlocks: ; 1e446 (7:6446) + INCBIN "maps/powerplant.blk" -UnnamedText_1e960: ; 1e960 (7:6960) - TX_FAR _UnnamedText_1e960 - db "@" +DiglettsCaveEntranceRoute11_h: ; 0x1e5ae to 0x1e5ba (12 bytes) (bank=7) (id=85) + db $11 ; tileset + db DIGLETTS_CAVE_ENTRANCE_HEIGHT, DIGLETTS_CAVE_ENTRANCE_WIDTH ; dimensions (y, x) + dw DiglettsCaveEntranceRoute11Blocks, DiglettsCaveEntranceRoute11TextPointers, DiglettsCaveEntranceRoute11Script ; blocks, texts, scripts + db $00 ; connections + dw DiglettsCaveEntranceRoute11Object ; objects -Func_1e965: ; 1e965 (7:6965) +DiglettsCaveEntranceRoute11Script: ; 1e5ba (7:65ba) call EnableAutoTextBoxDrawing - ld hl, $d2f7 - ld b, $13 - call CountSetBits - ld a, [$d11e] - cp $2 - ld a, $6 - jr c, .asm_1e97b - ld a, $7 -.asm_1e97b - jp Func_3ef5 + ld a, $16 + ld [$d365], a + ret -UnnamedText_1e97e: ; 1e97e (7:697e) - TX_FAR _UnnamedText_1e97e - db "@" +DiglettsCaveEntranceRoute11TextPointers: ; 1e5c3 (7:65c3) + dw DiglettsCaveEntranceRoute11Text1 -UnnamedText_1e983: ; 1e983 (7:6983) - TX_FAR _UnnamedText_1e983 +DiglettsCaveEntranceRoute11Text1: ; 1e5c5 (7:65c5) + TX_FAR _DiglettsCaveEntRoute11Text1 db "@" -Func_1e988: ; 1e988 (7:6988) - ld hl, $d790 - bit 7, [hl] - jr z, asm_1e9ab - ld a, [W_NUMSAFARIBALLS] ; $da47 - and a - jr z, asm_1e9b0 - jr asm_1e9ab +DiglettsCaveEntranceRoute11Object: ; 0x1e5ca (size=34) + db $7d ; border tile -Func_1e997: ; 1e997 (7:6997) - ld a, [wSafariSteps] ; $d70d - ld b, a - ld a, [wSafariSteps + 1] ; $d70e - ld c, a - or b - jr z, asm_1e9b0 - dec bc - ld a, b - ld [wSafariSteps], a ; $d70d - ld a, c - ld [wSafariSteps + 1], a ; $d70e -asm_1e9ab: ; 1e9ab (7:69ab) - xor a - ld [$da46], a - ret -asm_1e9b0: ; 1e9b0 (7:69b0) - call EnableAutoTextBoxDrawing - xor a - ld [wMusicHeaderPointer], a - dec a - call PlaySound - ld c, BANK(SFX_02_5f) - ld a, (SFX_02_5f - $4000) / 3 - call PlayMusic -.asm_1e9c2 - ld a, [$c02a] - cp $b9 - jr nz, .asm_1e9c2 - ld a, $d3 - ld [H_DOWNARROWBLINKCNT2], a ; $FF00+$8c - call DisplayTextID - xor a - ld [$d528], a - ld a, $9c - ld [H_DOWNARROWBLINKCNT1], a ; $FF00+$8b - ld a, $3 - ld [$d42f], a - ld a, $5 - ld [W_SAFARIZONEENTRANCECURSCRIPT], a - ld hl, $d790 - set 6, [hl] - ld a, $1 - ld [$da46], a - ret + db $3 ; warps + db $7, $2, $4, $ff + db $7, $3, $4, $ff + db $4, $4, $1, DIGLETTS_CAVE -Func_1e9ed: ; 1e9ed (7:69ed) - xor a - ld [wJoypadForbiddenButtonsMask], a - ld hl, UnnamedText_1e9f7 ; $69f7 - jp PrintText + db $0 ; signs -UnnamedText_1e9f7: ; 1e9f7 (7:69f7) - db $08 ; asm - ld a, [W_NUMSAFARIBALLS] ; $da47 - and a - jr z, .asm_1ea04 - ld hl, UnnamedText_1ea0d ; $6a0d - call PrintText -.asm_1ea04 - ld hl, UnnamedText_1ea12 ; $6a12 - call PrintText - jp TextScriptEnd + db $1 ; people + db SPRITE_GAMBLER, $3 + 4, $2 + 4, $ff, $ff, $1 ; person -UnnamedText_1ea0d: ; 1ea0d (7:6a0d) - TX_FAR _UnnamedText_1ea0d - db "@" + ; warp-to + EVENT_DISP $4, $7, $2 + EVENT_DISP $4, $7, $3 + EVENT_DISP $4, $4, $4 ; DIGLETTS_CAVE -UnnamedText_1ea12: ; 1ea12 (7:6a12) - TX_FAR _UnnamedText_1ea12 - db "@" +Route16House_h: ; 0x1e5ec to 0x1e5f8 (12 bytes) (bank=7) (id=188) + db $08 ; tileset + db ROUTE_16_HOUSE_HEIGHT, ROUTE_16_HOUSE_WIDTH ; dimensions (y, x) + dw Route16HouseBlocks, Route16HouseTextPointers, Route16HouseScript ; blocks, texts, scripts + db $00 ; connections + dw Route16HouseObject ; objects -Func_1eaa17: ; 1ea17 (7:6a17) - ld a, [$c109] - cp $4 - ret nz - call EnableAutoTextBoxDrawing - ld a, $31 - jp Func_3ef5 +Route16HouseScript: ; 1e5f8 (7:65f8) + jp EnableAutoTextBoxDrawing -CinnabarGymQuiz: ; 1ea25 (7:6a25) +Route16HouseTextPointers: ; 1e5fb (7:65fb) + dw Route16HouseText1 + dw Route16HouseText2 + +Route16HouseText1: ; 1e5ff (7:65ff) db $08 ; asm - xor a - ld [$da38], a - ld a, [wWhichTrade] ; $cd3d - push af - and $f - ld [$FF00+$db], a - pop af - and $f0 - swap a - ld [$FF00+$dc], a - ld hl, CinnabarGymQuizIntroText ; $6a5b + ld a, [$d7e0] + bit 6, a + ld hl, HM02ExplanationText + jr nz, .asm_13616 ; 0x1e608 + ld hl, Route16HouseText3 call PrintText - ld a, [$FF00+$db] - dec a - add a - ld d, $0 - ld e, a - ld hl, CinnabarQuizQuestions ; $6a60 - add hl, de - ld a, [hli] - ld h, [hl] - ld l, a + ld bc, (HM_02 << 8) | 1 + call GiveItem + jr nc, .BagFull + ld hl, $d7e0 + set 6, [hl] + ld hl, ReceivedHM02Text + jr .asm_13616 ; 0x1e620 +.BagFull + ld hl, HM02NoRoomText +.asm_13616 ; 0x1e625 call PrintText - ld a, $1 - ld [$cc3c], a - call Func_1ea92 jp TextScriptEnd -CinnabarGymQuizIntroText: ; 1ea5b (7:6a5b) - TX_FAR _CinnabarGymQuizIntroText - db "@" - -CinnabarQuizQuestions: ; 1ea60 (7:6a60) - dw CinnabarQuizQuestionsText1 - dw CinnabarQuizQuestionsText2 - dw CinnabarQuizQuestionsText3 - dw CinnabarQuizQuestionsText4 - dw CinnabarQuizQuestionsText5 - dw CinnabarQuizQuestionsText6 - -CinnabarQuizQuestionsText1: ; 1ea6c (7:6a6c) - TX_FAR _CinnabarQuizQuestionsText1 - db "@" - -CinnabarQuizQuestionsText2: ; 1ea71 (7:6a71) - TX_FAR _CinnabarQuizQuestionsText2 - db "@" - -CinnabarQuizQuestionsText3: ; 1ea76 (7:6a76) - TX_FAR _CinnabarQuizQuestionsText3 +Route16HouseText3: ; 1e62b (7:662b) + TX_FAR _Route16HouseText3 db "@" -CinnabarQuizQuestionsText4: ; 1ea7b (7:6a7b) - TX_FAR _CinnabarQuizQuestionsText4 - db "@" +ReceivedHM02Text: ; 1e630 (7:6630) + TX_FAR _ReceivedHM02Text ; 0x8ce66 + db $11, "@" -CinnabarQuizQuestionsText5: ; 1ea80 (7:6a80) - TX_FAR _CinnabarQuizQuestionsText5 +HM02ExplanationText: ; 1e636 (7:6636) + TX_FAR _HM02ExplanationText db "@" -CinnabarQuizQuestionsText6: ; 1ea85 (7:6a85) - TX_FAR _CinnabarQuizQuestionsText6 +HM02NoRoomText: ; 1e63b (7:663b) + TX_FAR _HM02NoRoomText db "@" -Func_1ea8a: ; 1ea8a (7:6a8a) - ld hl, $d79c - ld a, $10 - jp Predef ; indirect jump to HandleBitArray (f666 (3:7666)) - -Func_1ea92: ; 1ea92 (7:6a92) - call YesNoChoice - ld a, [$FF00+$dc] - ld c, a - ld a, [wCurrentMenuItem] ; $cc26 - cp c - jr nz, .asm_1eab8 - ld hl, $d126 - set 5, [hl] - ld a, [$FF00+$db] - ld [$FF00+$e0], a - ld hl, CinnabarGymQuizCorrectText ; $6ae3 - call PrintText - ld a, [$FF00+$e0] - ld c, a - ld b, $1 - call Func_1ea8a - jp Func_1eb0a -.asm_1eab8 - call WaitForSoundToFinish - ld a, $a5 - call PlaySound - call WaitForSoundToFinish - ld hl, CinnabarGymQuizIncorrectText ; $6b05 +Route16HouseText2: ; 1e640 (7:6640) + db $08 ; asm + ld hl, UnnamedText_1e652 call PrintText - ld a, [$FF00+$db] - add $2 - ld c, a - ld b, $2 - ld hl, $d79a - ld a, $10 - call Predef ; indirect jump to HandleBitArray (f666 (3:7666)) - ld a, c - and a - ret nz - ld a, [$FF00+$db] - add $2 - ld [$da38], a - ret - -CinnabarGymQuizCorrectText: ; 1eae3 (7:6ae3) - db $0b - TX_FAR _CinnabarGymQuizCorrectText - db $06,$08 - - ld a, [$FF00+$e0] - ld c, a - ld b, $2 - call Func_1ea8a - ld a, c - and a - jp nz, TextScriptEnd - call WaitForSoundToFinish - ld a, $ad - call PlaySound + ld a, FEAROW + call PlayCry call WaitForSoundToFinish jp TextScriptEnd -CinnabarGymQuizIncorrectText: ; 1eb05 (7:6b05) - TX_FAR _CinnabarGymQuizIncorrectText +UnnamedText_1e652: ; 1e652 (7:6652) + TX_FAR _UnnamedText_1e652 db "@" -Func_1eb0a: ; 1eb0a (7:6b0a) - ld a, $6 - ld [$FF00+$db], a -.asm_1eb0e - ld a, [$FF00+$db] - dec a - add a - add a - ld d, $0 - ld e, a - ld hl, CinnabarGymGateCoords ; $6b48 - add hl, de - ld a, [hli] - ld b, [hl] - ld c, a - inc hl - ld a, [hl] - ld [$d12f], a - push bc - ld a, [$FF00+$db] - ld [$FF00+$e0], a - ld c, a - ld b, $2 - call Func_1ea8a - ld a, c - and a - jr nz, .asm_1eb36 - ld a, [$d12f] - jr .asm_1eb38 -.asm_1eb36 - ld a, $e -.asm_1eb38 - pop bc - ld [$d09f], a - ld a, $17 - call Predef ; indirect jump to Func_ee9e (ee9e (3:6e9e)) - ld hl, $ffdb - dec [hl] - jr nz, .asm_1eb0e - ret - -CinnabarGymGateCoords: ; 1eb48 (7:6b48) - ; format: x-coord, y-coord, direction, padding - ; direction: $54 = horizontal gate, $5f = vertical gate - db $09,$03,$54,$00 - db $06,$03,$54,$00 - db $06,$06,$54,$00 - db $03,$08,$5f,$00 - db $02,$06,$54,$00 - db $02,$03,$54,$00 - -Func_1eb60: ; 1eb60 (7:6b60) - call EnableAutoTextBoxDrawing - ld a, $30 - call Func_3ef5 - ret +Route16HouseObject: ; 0x1e657 (size=32) + db $a ; border tile -UnnamedText_1eb69: ; 1eb69 (7:6b69) - TX_FAR _UnnamedText_1eb69 - db "@" + db $2 ; warps + db $7, $2, $8, $ff + db $7, $3, $8, $ff -Func_1eb6e: ; 1eb6e (7:6b6e) - call EnableAutoTextBoxDrawing - ld a, [$c109] - cp $4 - ret nz - ld a, [$d7f2] - bit 7, a - jr nz, .asm_1ebd2 - bit 3, a - jr nz, .asm_1eb86 - bit 6, a - jr nz, .asm_1eb8b -.asm_1eb86 - ld a, $2d - jp Func_3ef5 -.asm_1eb8b - ld a, $1 - ld [$cc3c], a - ld a, $2e - call Func_3ef5 - ld c, $20 - call DelayFrames - ld a, $8c - call PlaySound - call WaitForSoundToFinish - ld c, $50 - call DelayFrames - ld a, $9c - call PlaySound - call WaitForSoundToFinish - ld c, $30 - call DelayFrames - ld a, $8c - call PlaySound - call WaitForSoundToFinish - ld c, $20 - call DelayFrames - ld a, $86 - call PlaySound - call WaitForSoundToFinish - call Func_2307 - ld hl, $d7f2 - set 3, [hl] - ret -.asm_1ebd2 - ld a, $1 - ld [$cc3c], a - ld a, $2f - call Func_3ef5 - ret + db $0 ; signs -BillsHouseMonitorText: ; 1ebdd (7:6bdd) - TX_FAR _BillsHouseMonitorText - db "@" + db $2 ; people + db SPRITE_BRUNETTE_GIRL, $3 + 4, $2 + 4, $ff, $d3, $1 ; person + db SPRITE_BIRD, $4 + 4, $6 + 4, $fe, $0, $2 ; person -BillsHouseInitiatedText: ; 1ebe2 (7:6be2) - TX_FAR _BillsHouseInitiatedText - db $06 - db $08 ; asm - ld a, $ff - ld [$c0ee], a - call PlaySound - ld c, $10 - call DelayFrames - ld a, $9d - call PlaySound - call WaitForSoundToFinish - ld c, $3c - call DelayFrames - jp TextScriptEnd + ; warp-to + EVENT_DISP $4, $7, $2 + EVENT_DISP $4, $7, $3 -BillsHousePokemonList: ; 1ec05 (7:6c05) - db $08 ; asm - call SaveScreenTilesToBuffer1 - ld hl, BillsHousePokemonListText1 - call PrintText - xor a - ld [$d07c], a - ld [$cc26], a - ld [$cc2a], a - ld a, $3 - ld [$cc29], a - ld a, $4 - ld [$cc28], a - ld a, $2 - ld [$cc24], a - ld a, $1 - ld [$cc25], a -.asm_1ec2d - ld hl, $d730 - set 6, [hl] - ld hl, wTileMap - ld b, $a - ld c, $9 - call TextBoxBorder - ld hl, $c3ca - ld de, BillsMonListText - call PlaceString - ld hl, BillsHousePokemonListText2 - call PrintText - call SaveScreenTilesToBuffer2 - call HandleMenuInput - bit 1, a - jr nz, .asm_1ec74 - ld a, [$cc26] - add $66 - cp EEVEE - jr z, .asm_1ec6c - cp FLAREON - jr z, .asm_1ec6c - cp JOLTEON - jr z, .asm_1ec6c - cp VAPOREON - jr z, .asm_1ec6c - jr .asm_1ec74 -.asm_1ec6c - call DisplayPokedex - call LoadScreenTilesFromBuffer2 - jr .asm_1ec2d -.asm_1ec74 - ld hl, $d730 - res 6, [hl] - call LoadScreenTilesFromBuffer2 - jp TextScriptEnd +Route22Gate_h: ; 0x1e677 to 0x1e683 (12 bytes) (bank=7) (id=193) + db $0c ; tileset + db ROUTE_22_GATE_HEIGHT, ROUTE_22_GATE_WIDTH ; dimensions (y, x) + dw Route22GateBlocks, Route22GateTextPointers, Route22GateScript ; blocks, texts, scripts + db $00 ; connections + dw Route22GateObject ; objects -BillsHousePokemonListText1: ; 1ec7f (7:6c7f) - TX_FAR _BillsHousePokemonListText1 - db "@" +Route22GateScript: ; 1e683 (7:6683) + call EnableAutoTextBoxDrawing + ld hl, Route22GateScriptPointers + ld a, [W_ROUTE22GATECURSCRIPT] + call CallFunctionInTable + ld a, [$d361] + cp $4 + ld a, $22 + jr c, .asm_1e69a ; 0x1e696 $2 + ld a, $21 +.asm_1e69a + ld [$d365], a + ret -BillsMonListText: ; 1ec84 (7:6c84) - db "EEVEE",$4e,"FLAREON",$4e,"JOLTEON",$4e,"VAPOREON",$4e,"CANCEL@" +Route22GateScriptPointers: ; 1e69e (7:669e) + dw Route22GateScript0 + dw Route22GateScript1 + dw Route22GateScript2 -BillsHousePokemonListText2: ; 1ecaa (7:6caa) - TX_FAR _BillsHousePokemonListText2 - db "@" +Route22GateScript0: ; 1e6a4 (7:66a4) + ld hl, Route22GateScriptCoords + call ArePlayerCoordsInArray + ret nc + xor a + ld [H_CURRENTPRESSEDBUTTONS], a + ld a, $1 + ld [$ff00+$8c], a + jp DisplayTextID -Func_1ecaf: ; 1ecaf (7:6caf) - ld a, [$c109] - cp $4 - ret nz - call EnableAutoTextBoxDrawing - ld a, $8 - jp Func_3ef5 +Route22GateScriptCoords: ; 1e6b5 (7:66b5) + db 2,4 + db 2,5 + db $ff -OakLabEmailText: ; 1ecbd (7:6cbd) - TX_FAR _OakLabEmailText - db "@" +Func_1e6ba: ; 1e6ba (7:66ba) + ld a, $1 + ld [$cd38], a + ld a, $80 + ld [$ccd3], a + ld [$c109], a + ld [wJoypadForbiddenButtonsMask], a + jp Func_3486 -SECTION "bank8",ROMX,BANK[$8] +Route22GateScript1: ; 1e6cd (7:66cd) + ld a, [$cd38] + and a + ret nz + xor a + ld [wJoypadForbiddenButtonsMask], a + call Delay3 + ld a, $0 + ld [W_ROUTE22GATECURSCRIPT], a +Route22GateScript2: ; 1e6de (7:66de) + ret -INCLUDE "music/headers/sfxheaders08.asm" -INCLUDE "music/headers/musicheaders08.asm" +Route22GateTextPointers: ; 1e6df (7:66df) + dw Route22GateText1 -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" +Route22GateText1: ; 1e6e1 (7:66e1) + db $8 + ld a, [$d356] + bit 0, a + jr nz, .asm_8a809 ; 0x1e6e7 $d + ld hl, UnnamedText_1e704 + call PrintText + call Func_1e6ba + ld a, $1 + jr .asm_20f7e ; 0x1e6f4 $8 +.asm_8a809 ; 0x1e6f6 + ld hl, UnnamedText_1e71a + call PrintText + ld a, $2 +.asm_20f7e ; 0x1e6fe + ld [W_ROUTE22GATECURSCRIPT], a + jp TextScriptEnd -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 +UnnamedText_1e704: ; 1e704 (7:6704) + TX_FAR _UnnamedText_1e704 ; 0x8cfbb + db $8 + ld a, $a5 + call PlaySoundWaitForCurrent + call WaitForSoundToFinish + ld hl, UnnamedText_1e715 ; $6715 + ret -; 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 +UnnamedText_1e715: ; 1e715 (7:6715) + TX_FAR _UnnamedText_1e715 + db "@" -Music8_Channel3Duty1: ; 20383 (8:4383) - db $02,$46,$8A,$CE,$EF,$FF,$FE,$EE,$DD,$CB,$A9,$87,$65,$43,$22,$11 +UnnamedText_1e71a: ; 1e71a (7:671a) + TX_FAR _UnnamedText_1e71a ; 0x8d03e + db $0B, "@" -Music8_Channel3Duty2: ; 20393 (8:4393) - db $13,$69,$BD,$EE,$EE,$FF,$FF,$ED,$DE,$FF,$FF,$EE,$EE,$DB,$96,$31 +Route22GateObject: ; 0x1e720 (size=42) + db $a ; border tile -Music8_Channel3Duty3: ; 203a3 (8:43a3) - db $02,$46,$8A,$CD,$EF,$FE,$DE,$FF,$EE,$DC,$BA,$98,$76,$54,$32,$10 + db $4 ; warps + db $7, $4, $0, $ff + db $7, $5, $0, $ff + db $0, $4, $0, $ff + db $0, $5, $1, $ff -Music8_Channel3Duty4: ; 203b3 (8:43b3) - db $01,$23,$45,$67,$8A,$CD,$EE,$F7,$7F,$EE,$DC,$A8,$76,$54,$32,$10 + db $0 ; signs -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" + db $1 ; people + db SPRITE_GUARD, $2 + 4, $6 + 4, $ff, $d2, $1 ; person -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 + ; warp-to + EVENT_DISP $5, $7, $4 + EVENT_DISP $5, $7, $5 + EVENT_DISP $5, $0, $4 + EVENT_DISP $5, $0, $5 -Func_213a7: ; 213a7 (8:53a7) - ld de, Unknown_213bc ; $53bc - jr asm_213af +Route22GateBlocks: ; 1e74a (7:674a) + INCBIN "maps/route22gate.blk" -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 +BillsHouse_h: ; 0x1e75e to 0x1e76a (12 bytes) (bank=7) (id=88) + db $10 ; tileset + db BILLS_HOUSE_HEIGHT, BILLS_HOUSE_WIDTH ; dimensions (y, x) + dw BillsHouseBlocks, BillsHouseTextPointers, BillsHouseScript ; blocks, texts, scripts + db $00 ; connections + dw BillsHouseObject ; objects -Unknown_213bc: ; 213bc (8:53bc) - db $A0,$E2,$50,$87 +BillsHouseScript: ; 1e76a (7:676a) + call EnableAutoTextBoxDrawing + ld a, [W_BILLSHOUSECURSCRIPT] + ld hl, BillsHouseScriptPointers + jp CallFunctionInTable -Unknown_213c0: ; 213c0 (8:53c0) - db $B0,$E2,$EE,$86 +BillsHouseScriptPointers: ; 1e776 (7:6776) + dw BillsHouseScript0 + dw BillsHouseScript1 + dw BillsHouseScript2 + dw BillsHouseScript3 + dw BillsHouseScript4 + dw BillsHouseScript5 -Unknown_213c4: ; 213c4 (8:53c4) - db $00,$00,$00,$80 +BillsHouseScript0: ; 1e782 (7:6782) + ret -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] +BillsHouseScript1: ; 1e783 (7:6783) + ld a, [$c109] 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 de, MovementData_1e79c + jr nz, .asm_1e78f ; 0x1e78a $3 + ld de, MovementData_1e7a0 +.asm_1e78f ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $FF00+$ba + ld [$ff00+$8c], a + call MoveSprite + ld a, $2 + ld [W_BILLSHOUSECURSCRIPT], a 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@" +MovementData_1e79c: ; 1e79c (7:679c) + db $40,$40,$40,$FF -LogOffPCText: ; 214ba (8:54ba) - db "LOG OFF@" +MovementData_1e7a0: ; 1e7a0 (7:67a0) + db $C0,$40,$40,$80,$40,$FF -Func_214c2: ; 214c2 (8:54c2) -BillsPC_: ; 0x214c2 - ld hl, $d730 +BillsHouseScript2: ; 1e7a6 (7:67a6) + ld a, [$d730] + bit 0, a + ret nz + ld a, $61 + ld [$cc4d], a + ld a, $11 + call Predef + ld hl, $d7f2 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 + ld [wJoypadForbiddenButtonsMask], a + ld a, $3 + ld [W_BILLSHOUSECURSCRIPT], a + ret -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 +BillsHouseScript3: ; 1e7c5 (7:67c5) + ld a, [$d7f2] + bit 3, a + ret z + ld a, $f0 + ld [wJoypadForbiddenButtonsMask], a + ld a, $2 + ld [$cf13], a + ld a, $c + ld [$ff00+$eb], a + ld a, $40 + ld [$ff00+$ec], a + ld a, $6 + ld [$ff00+$ed], a + ld a, $5 + ld [$ff00+$ee], a + call Func_32f9 + ld a, $62 + ld [$cc4d], a + ld a, $15 + call Predef + ld c, $8 + call DelayFrames ld a, $2 - ld [hli], a - dec a - ld [hli], a - inc hl - inc hl + ld [$ff00+$8c], a + ld de, MovementData_1e807 + call MoveSprite ld a, $4 - ld [hli], a - ld a, $3 - ld [hli], a + ld [W_BILLSHOUSECURSCRIPT], a + ret + +MovementData_1e807: ; 1e807 (7:6807) + db $00,$C0,$C0,$C0,$00,$FF + +BillsHouseScript4: ; 1e80d (7:680d) + ld a, [$d730] + bit 0, a + ret nz 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 + ld [wJoypadForbiddenButtonsMask], a + ld hl, $d7f2 + set 5, [hl] + ld hl, $d7f1 + set 0, [hl] + ld a, $0 + ld [W_BILLSHOUSECURSCRIPT], a + ret -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] +BillsHouseScript5: ; 1e827 (7:6827) + ld a, $4 + ld [$ff00+$8c], a + call DisplayTextID + ld a, $0 + ld [W_BILLSHOUSECURSCRIPT], a ret -Func_215ac: ; 215ac (8:55ac) -BillsPCDeposit: - ld a, [W_NUMINPARTY] ; $d163 - dec a - jr nz, .asm_215bb - ld hl, CantDepositLastMonText +BillsHouseTextPointers: ; 1e834 (7:6834) + dw BillsHouseText1 + dw BillsHouseText2 + dw BillsHouseText3 + dw BillsHouseText4 + +BillsHouseText4: ; 1e83c (7:683c) + db $fd + +BillsHouseText1: ; 1e83d (7:683d) + db $8 + ld hl, UnnamedText_1e865 call PrintText - jp BillsPCMenu -.asm_215bb - ld a, [W_NUMINBOX] ; $da80 - cp $14 - jr nz, .asm_215cb - ld hl, BoxFullText ; $5802 + call YesNoChoice + ld a, [$cc26] + and a + jr nz, asm_6b196 ; 0x1e84b $d +asm_4d03c: ; 1e84d (7:684d) + ld hl, UnnamedText_1e86a 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 + ld [W_BILLSHOUSECURSCRIPT], a + jr asm_fd4e2 ; 0x1e858 $8 +asm_6b196: ; 1e85a (7:685a) + ld hl, UnnamedText_1e86f call PrintText - jp BillsPCMenu + jr asm_4d03c ; 0x1e860 $eb +asm_fd4e2 ; 0x1e862 + jp TextScriptEnd -Func_21618: ; 21618 (8:5618) - ld a, [W_NUMINBOX] ; $da80 - and a - jr nz, .asm_21627 - ld hl, NoMonText ; $580c +UnnamedText_1e865: ; 1e865 (7:6865) + TX_FAR _UnnamedText_1e865 ; 0x8d267 + db "@" + +UnnamedText_1e86a: ; 1e86a (7:686a) + TX_FAR _UnnamedText_1e86a ; 0x8d345 + db "@" + +UnnamedText_1e86f: ; 1e86f (7:686f) + TX_FAR _UnnamedText_1e86f ; 0x8d391 + db "@" + +BillsHouseText2: ; 1e874 (7:6874) + db $08 ; asm + ld a, [$d7f2] + bit 4, a + jr nz, .asm_5491f ; 0x1e87a + ld hl, BillThankYouText call PrintText - jp Func_214e8 -.asm_21627 - ld a, [W_NUMINPARTY] ; $d163 - cp $6 - jr nz, .asm_21637 - ld hl, CantTakeMonText ; $5811 + ld bc, (S_S__TICKET << 8) | 1 + call GiveItem + jr nc, .BagFull + ld hl, SSTicketReceivedText 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 + ld hl, $d7f2 + set 4, [hl] + ld a, $7 + ld [$cc4d], a + ld a, $15 + call Predef + ld a, $9 + ld [$cc4d], a + ld a, $11 + call Predef +.asm_5491f ; 0x1e8a9 + ld hl, UnnamedText_1e8cb call PrintText - jp Func_214e8 + jr .asm_bd408 ; 0x1e8af +.BagFull + ld hl, SSTicketNoRoomText + call PrintText +.asm_bd408 ; 0x1e8b7 + jp TextScriptEnd -Func_21673: ; 21673 (8:5673) - ld a, [W_NUMINBOX] ; $da80 - and a - jr nz, .asm_21682 - ld hl, NoMonText ; $580c +BillThankYouText: ; 1e8ba (7:68ba) + TX_FAR _BillThankYouText + db "@" + +SSTicketReceivedText: ; 1e8bf (7:68bf) + TX_FAR _SSTicketReceivedText ; 0x8d499 + db $11, $6, "@" + +SSTicketNoRoomText: ; 1e8c6 (7:68c6) + TX_FAR _SSTicketNoRoomText + db "@" + +UnnamedText_1e8cb: ; 1e8cb (7:68cb) + TX_FAR _UnnamedText_1e8cb + db "@" + +BillsHouseText3: ; 1e8d0 (7:68d0) + db $08 ; asm + ld hl, UnnamedText_1e8da call PrintText - jp Func_214e8 -.asm_21682 - ld hl, W_NUMINBOX ; $da80 - call Func_216be - jp c, Func_214e8 - ld hl, OnceReleasedText ; $581b + jp TextScriptEnd + +UnnamedText_1e8da: ; 1e8da (7:68da) + TX_FAR _UnnamedText_1e8da + db "@" + +BillsHouseObject: ; 0x1e8df (size=38) + db $d ; border tile + + db $2 ; warps + db $7, $2, $0, $ff + db $7, $3, $0, $ff + + db $0 ; signs + + db $3 ; people + db SPRITE_SLOWBRO, $5 + 4, $6 + 4, $ff, $ff, $1 ; person + db SPRITE_BLACK_HAIR_BOY_2, $4 + 4, $4 + 4, $ff, $ff, $2 ; person + db SPRITE_BLACK_HAIR_BOY_2, $5 + 4, $6 + 4, $ff, $ff, $3 ; person + + ; warp-to + EVENT_DISP $4, $7, $2 + EVENT_DISP $4, $7, $3 + +BillsHouseBlocks: ; 1e905 (7:6905) + INCBIN "maps/billshouse.blk" + +Func_1e915: ; 1e915 (7:6915) + call SaveScreenTilesToBuffer2 + ld hl, UnnamedText_1e946 ; $6946 + call PrintText + ld hl, UnnamedText_1e93b ; $693b 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 + jr nz, .asm_1e932 + ld a, $56 + call Predef ; indirect jump to DisplayDexRating (44169 (11:4169)) +.asm_1e932 + ld hl, UnnamedText_1e940 ; $6940 call PrintText - jp Func_214e8 + jp LoadScreenTilesFromBuffer2 -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 +UnnamedText_1e93b: ; 1e93b (7:693b) + TX_FAR _UnnamedText_1e93b + db "@" -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 +UnnamedText_1e940: ; 1e940 (7:6940) + TX_FAR _UnnamedText_1e940 + db $0d,"@" -BillsPCMenuText: ; 216e1 (8:56e1) - db "WITHDRAW ",$4a,$4e,"DEPOSIT ",$4a,$4e,"RELEASE ",$4a,$4e,"CHANGE BOX",$4e,"SEE YA!@" +UnnamedText_1e946: ; 1e946 (7:6946) + TX_FAR _UnnamedText_1e946 + db "@" -BoxNoPCText: ; 21713 (8:5713) - db "BOX No.@" +Func_1e94b: ; 1e94b (7:694b) + call EnableAutoTextBoxDrawing + ld a, $39 + jp Func_3ef5 -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 +NewBicycleText: ; 1e953 (7:6953) + TX_FAR _NewBicycleText + db "@" -HMMoveArray: ; 21745 (8:5745) - db CUT - db FLY - db SURF - db STRENGTH - db FLASH - db $ff +Func_1e958: ; 1e958 (7:6958) + call EnableAutoTextBoxDrawing + ld a, $05 + jp Func_3ef5 -Func_2174b: ; 2174b (8:574b) - FuncCoord 9, 10 ; $c471 - ld hl, Coord - ld b, $6 - ld c, $9 - call TextBoxBorder - ld a, [$ccd3] +UnnamedText_1e960: ; 1e960 (7:6960) + TX_FAR _UnnamedText_1e960 + db "@" + +Func_1e965: ; 1e965 (7:6965) + call EnableAutoTextBoxDrawing + ld hl, $d2f7 + ld b, $13 + call CountSetBits + ld a, [$d11e] + cp $2 + ld a, $6 + jr c, .asm_1e97b + ld a, $7 +.asm_1e97b + jp Func_3ef5 + +UnnamedText_1e97e: ; 1e97e (7:697e) + TX_FAR _UnnamedText_1e97e + db "@" + +UnnamedText_1e983: ; 1e983 (7:6983) + TX_FAR _UnnamedText_1e983 + db "@" + +Func_1e988: ; 1e988 (7:6988) + ld hl, $d790 + bit 7, [hl] + jr z, asm_1e9ab + ld a, [W_NUMSAFARIBALLS] ; $da47 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 + jr z, asm_1e9b0 + jr asm_1e9ab + +Func_1e997: ; 1e997 (7:6997) + ld a, [wSafariSteps] ; $d70d + ld b, a + ld a, [wSafariSteps + 1] ; $d70e + ld c, a + or b + jr z, asm_1e9b0 + dec bc + ld a, b + ld [wSafariSteps], a ; $d70d + ld a, c + ld [wSafariSteps + 1], a ; $d70e +asm_1e9ab: ; 1e9ab (7:69ab) xor a - ld [hli], a - inc hl - ld a, $2 - ld [hli], a - ld a, $3 - ld [hli], a + ld [$da46], a + ret +asm_1e9b0: ; 1e9b0 (7:69b0) + call EnableAutoTextBoxDrawing 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 + ld [wMusicHeaderPointer], a dec a - jr z, .asm_217a3 -.asm_2179f - and a - ret -.asm_217a1 - scf + call PlaySound + ld c, BANK(SFX_02_5f) + ld a, (SFX_02_5f - $4000) / 3 + call PlayMusic +.asm_1e9c2 + ld a, [$c02a] + cp $b9 + jr nz, .asm_1e9c2 + ld a, $d3 + ld [H_DOWNARROWBLINKCNT2], a ; $FF00+$8c + call DisplayTextID + xor a + ld [$d528], a + ld a, $9c + ld [H_DOWNARROWBLINKCNT1], a ; $FF00+$8b + ld a, $3 + ld [$d42f], a + ld a, $5 + ld [W_SAFARIZONEENTRANCECURSCRIPT], a + ld hl, $d790 + set 6, [hl] + ld a, $1 + ld [$da46], a 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@" +Func_1e9ed: ; 1e9ed (7:69ed) + xor a + ld [wJoypadForbiddenButtonsMask], a + ld hl, UnnamedText_1e9f7 ; $69f7 + jp PrintText -SwitchOnText: ; 0x217e9 - TX_FAR _SwitchOnText - db "@" +UnnamedText_1e9f7: ; 1e9f7 (7:69f7) + db $08 ; asm + ld a, [W_NUMSAFARIBALLS] ; $da47 + and a + jr z, .asm_1ea04 + ld hl, UnnamedText_1ea0d ; $6a0d + call PrintText +.asm_1ea04 + ld hl, UnnamedText_1ea12 ; $6a12 + call PrintText + jp TextScriptEnd -WhatText: ; 0x217ee - TX_FAR _WhatText +UnnamedText_1ea0d: ; 1ea0d (7:6a0d) + TX_FAR _UnnamedText_1ea0d db "@" -DepositWhichMonText: ; 0x217f3 - TX_FAR _DepositWhichMonText +UnnamedText_1ea12: ; 1ea12 (7:6a12) + TX_FAR _UnnamedText_1ea12 db "@" -MonWasStoredText: ; 0x217f8 - TX_FAR _MonWasStoredText - db "@" +Func_1eaa17: ; 1ea17 (7:6a17) + ld a, [$c109] + cp $4 + ret nz + call EnableAutoTextBoxDrawing + ld a, $31 + jp Func_3ef5 -CantDepositLastMonText: ; 0x217fd - TX_FAR _CantDepositLastMonText - db "@" +CinnabarGymQuiz: ; 1ea25 (7:6a25) + db $08 ; asm + xor a + ld [$da38], a + ld a, [wWhichTrade] ; $cd3d + push af + and $f + ld [$FF00+$db], a + pop af + and $f0 + swap a + ld [$FF00+$dc], a + ld hl, CinnabarGymQuizIntroText ; $6a5b + call PrintText + ld a, [$FF00+$db] + dec a + add a + ld d, $0 + ld e, a + ld hl, CinnabarQuizQuestions ; $6a60 + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + call PrintText + ld a, $1 + ld [$cc3c], a + call Func_1ea92 + jp TextScriptEnd -BoxFullText: ; 0x21802 - TX_FAR _BoxFullText +CinnabarGymQuizIntroText: ; 1ea5b (7:6a5b) + TX_FAR _CinnabarGymQuizIntroText db "@" -MonIsTakenOutText: ; 0x21807 - TX_FAR _MonIsTakenOutText - db "@" +CinnabarQuizQuestions: ; 1ea60 (7:6a60) + dw CinnabarQuizQuestionsText1 + dw CinnabarQuizQuestionsText2 + dw CinnabarQuizQuestionsText3 + dw CinnabarQuizQuestionsText4 + dw CinnabarQuizQuestionsText5 + dw CinnabarQuizQuestionsText6 -NoMonText: ; 0x2180c - TX_FAR _NoMonText +CinnabarQuizQuestionsText1: ; 1ea6c (7:6a6c) + TX_FAR _CinnabarQuizQuestionsText1 db "@" -CantTakeMonText: ; 0x21811 - TX_FAR _CantTakeMonText +CinnabarQuizQuestionsText2: ; 1ea71 (7:6a71) + TX_FAR _CinnabarQuizQuestionsText2 db "@" -ReleaseWhichMonText: ; 0x21816 - TX_FAR _ReleaseWhichMonText +CinnabarQuizQuestionsText3: ; 1ea76 (7:6a76) + TX_FAR _CinnabarQuizQuestionsText3 db "@" -OnceReleasedText: ; 0x2181b - TX_FAR _OnceReleasedText +CinnabarQuizQuestionsText4: ; 1ea7b (7:6a7b) + TX_FAR _CinnabarQuizQuestionsText4 db "@" -MonWasReleasedText: ; 0x21820 - TX_FAR _MonWasReleasedText +CinnabarQuizQuestionsText5: ; 1ea80 (7:6a80) + TX_FAR _CinnabarQuizQuestionsText5 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 +CinnabarQuizQuestionsText6: ; 1ea85 (7:6a85) + TX_FAR _CinnabarQuizQuestionsText6 db "@" - ld a, [$c109] - cp $4 - ret nz - call EnableAutoTextBoxDrawing - ld a, $23 - jp Func_3ef5 - -Unknown_21878: ; 21878 (8:5878) - db $FD +Func_1ea8a: ; 1ea8a (7:6a8a) + ld hl, $d79c + ld a, $10 + jp Predef ; indirect jump to HandleBitArray (f666 (3:7666)) -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 +Func_1ea92: ; 1ea92 (7:6a92) + call YesNoChoice + ld a, [$FF00+$dc] + ld c, a + ld a, [wCurrentMenuItem] ; $cc26 + cp c + jr nz, .asm_1eab8 + ld hl, $d126 + set 5, [hl] + ld a, [$FF00+$db] + ld [$FF00+$e0], a + ld hl, CinnabarGymQuizCorrectText ; $6ae3 + call PrintText + ld a, [$FF00+$e0] + ld c, a + ld b, $1 + call Func_1ea8a + jp Func_1eb0a +.asm_1eab8 + call WaitForSoundToFinish + ld a, $a5 + call PlaySound + call WaitForSoundToFinish + ld hl, CinnabarGymQuizIncorrectText ; $6b05 + call PrintText + ld a, [$FF00+$db] + add $2 + ld c, a + ld b, $2 + ld hl, $d79a + ld a, $10 + call Predef ; indirect jump to HandleBitArray (f666 (3:7666)) 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 nz + ld a, [$FF00+$db] + add $2 + ld [$da38], a 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 +CinnabarGymQuizCorrectText: ; 1eae3 (7:6ae3) + db $0b + TX_FAR _CinnabarGymQuizCorrectText + db $06,$08 + + ld a, [$FF00+$e0] + ld c, a + ld b, $2 + call Func_1ea8a 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 + jp nz, TextScriptEnd + call WaitForSoundToFinish + ld a, $ad + call PlaySound + call WaitForSoundToFinish + jp TextScriptEnd -; 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 +CinnabarGymQuizIncorrectText: ; 1eb05 (7:6b05) + TX_FAR _CinnabarGymQuizIncorrectText + db "@" -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 +Func_1eb0a: ; 1eb0a (7:6b0a) + ld a, $6 + ld [$FF00+$db], a +.asm_1eb0e + ld a, [$FF00+$db] + dec a 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 d, $0 ld e, a - ld hl, $c006 - add hl, de - push hl - ld hl, $c016 + ld hl, CinnabarGymGateCoords ; $6b48 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 + ld b, [hl] + ld c, a 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 [$d12f], a + push bc + ld a, [$FF00+$db] + ld [$FF00+$e0], a + ld c, a + ld b, $2 + call Func_1ea8a 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 + and a + jr nz, .asm_1eb36 + ld a, [$d12f] + jr .asm_1eb38 +.asm_1eb36 + ld a, $e +.asm_1eb38 + pop bc + ld [$d09f], a + ld a, $17 + call Predef ; indirect jump to Func_ee9e (ee9e (3:6e9e)) + ld hl, $ffdb + dec [hl] + jr nz, .asm_1eb0e + ret -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 +CinnabarGymGateCoords: ; 1eb48 (7:6b48) + ; format: x-coord, y-coord, direction, padding + ; direction: $54 = horizontal gate, $5f = vertical gate + db $09,$03,$54,$00 + db $06,$03,$54,$00 + db $06,$06,$54,$00 + db $03,$08,$5f,$00 + db $02,$06,$54,$00 + db $02,$03,$54,$00 + +Func_1eb60: ; 1eb60 (7:6b60) + call EnableAutoTextBoxDrawing + ld a, $30 + call Func_3ef5 + ret + +UnnamedText_1eb69: ; 1eb69 (7:6b69) + TX_FAR _UnnamedText_1eb69 + db "@" + +Func_1eb6e: ; 1eb6e (7:6b6e) + call EnableAutoTextBoxDrawing + ld a, [$c109] + cp $4 + ret nz + ld a, [$d7f2] + bit 7, a + jr nz, .asm_1ebd2 + bit 3, a + jr nz, .asm_1eb86 + bit 6, a + jr nz, .asm_1eb8b +.asm_1eb86 + ld a, $2d + jp Func_3ef5 +.asm_1eb8b + ld a, $1 + ld [$cc3c], a + ld a, $2e + call Func_3ef5 + ld c, $20 + call DelayFrames + ld a, $8c + call PlaySound + call WaitForSoundToFinish + ld c, $50 + call DelayFrames + ld a, $9c + call PlaySound + call WaitForSoundToFinish + ld c, $30 + call DelayFrames + ld a, $8c + call PlaySound + call WaitForSoundToFinish + ld c, $20 + call DelayFrames + ld a, $86 + call PlaySound + call WaitForSoundToFinish + call Func_2307 + ld hl, $d7f2 + set 3, [hl] + ret +.asm_1ebd2 + ld a, $1 + ld [$cc3c], a + ld a, $2f + call Func_3ef5 + ret - ; 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 +BillsHouseMonitorText: ; 1ebdd (7:6bdd) + TX_FAR _BillsHouseMonitorText + db "@" -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 +BillsHouseInitiatedText: ; 1ebe2 (7:6be2) + TX_FAR _BillsHouseInitiatedText + db $06 + db $08 ; asm + ld a, $ff + ld [$c0ee], a + call PlaySound + ld c, $10 + call DelayFrames + ld a, $9d + call PlaySound + call WaitForSoundToFinish + ld c, $3c + call DelayFrames + jp TextScriptEnd -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 +BillsHousePokemonList: ; 1ec05 (7:6c05) + db $08 ; asm + call SaveScreenTilesToBuffer1 + ld hl, BillsHousePokemonListText1 + call PrintText + xor a + ld [$d07c], a + ld [$cc26], a + ld [$cc2a], a + ld a, $3 + ld [$cc29], a + ld a, $4 + ld [$cc28], a + ld a, $2 + ld [$cc24], a + ld a, $1 + ld [$cc25], a +.asm_1ec2d + ld hl, $d730 + set 6, [hl] + ld hl, wTileMap + ld b, $a + ld c, $9 + call TextBoxBorder + ld hl, $c3ca + ld de, BillsMonListText + call PlaceString + ld hl, BillsHousePokemonListText2 + call PrintText + call SaveScreenTilesToBuffer2 + call HandleMenuInput + bit 1, a + jr nz, .asm_1ec74 + ld a, [$cc26] + add $66 + cp EEVEE + jr z, .asm_1ec6c + cp FLAREON + jr z, .asm_1ec6c + cp JOLTEON + jr z, .asm_1ec6c + cp VAPOREON + jr z, .asm_1ec6c + jr .asm_1ec74 +.asm_1ec6c + call DisplayPokedex + call LoadScreenTilesFromBuffer2 + jr .asm_1ec2d +.asm_1ec74 + ld hl, $d730 + res 6, [hl] + call LoadScreenTilesFromBuffer2 + jp TextScriptEnd -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 +BillsHousePokemonListText1: ; 1ec7f (7:6c7f) + TX_FAR _BillsHousePokemonListText1 + db "@" -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 +BillsMonListText: ; 1ec84 (7:6c84) + db "EEVEE",$4e,"FLAREON",$4e,"JOLTEON",$4e,"VAPOREON",$4e,"CANCEL@" -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 +BillsHousePokemonListText2: ; 1ecaa (7:6caa) + TX_FAR _BillsHousePokemonListText2 + db "@" -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 +Func_1ecaf: ; 1ecaf (7:6caf) + ld a, [$c109] + cp $4 + ret nz + call EnableAutoTextBoxDrawing + ld a, $8 + jp Func_3ef5 -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 +OakLabEmailText: ; 1ecbd (7:6cbd) + TX_FAR _OakLabEmailText + db "@" -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 +SECTION "bank8",ROMX,BANK[$8] -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 +INCLUDE "music/headers/sfxheaders08.asm" +INCLUDE "music/headers/musicheaders08.asm" -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 +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_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_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 -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 +; 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_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_Channel3Duty1: ; 20383 (8:4383) + db $02,$46,$8A,$CE,$EF,$FF,$FE,$EE,$DD,$CB,$A9,$87,$65,$43,$22,$11 -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 +Music8_Channel3Duty2: ; 20393 (8:4393) + db $13,$69,$BD,$EE,$EE,$FF,$FF,$ED,$DE,$FF,$FF,$EE,$EE,$DB,$96,$31 -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 +Music8_Channel3Duty3: ; 203a3 (8:43a3) + db $02,$46,$8A,$CD,$EF,$FE,$DE,$FF,$EE,$DC,$BA,$98,$76,$54,$32,$10 -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 +Music8_Channel3Duty4: ; 203b3 (8:43b3) + db $01,$23,$45,$67,$8A,$CD,$EE,$F7,$7F,$EE,$DC,$A8,$76,$54,$32,$10 -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 +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_21e19: ; 21e19 (8:5e19) - ld a, c - cp CH4 - jr nz, .asm_21e2e +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] - bit 7, a - jr z, .asm_21e2e - xor a - ld [$c0f1], a - ld a, $80 - ld [$c0f2], a -.asm_21e2e + and $7f + dec a +.asm_21395 + set 7, a + ld [$d083], a 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 +.asm_2139b xor a - ld [$c0eb], a - ld a, $1 - ld [$c0ea], a -.asm_21e55 - ret + ld [$d083], a + ld [$c02a], a + ld de, Unknown_213c4 ; $53c4 + jr asm_213af -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_213a7: ; 213a7 (8:53a7) + ld de, Unknown_213bc ; $53bc + jr asm_213af -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 +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 -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 +Unknown_213bc: ; 213bc (8:53bc) + db $A0,$E2,$50,$87 -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 +Unknown_213c0: ; 213c0 (8:53c0) + db $B0,$E2,$EE,$86 -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 +Unknown_213c4: ; 213c4 (8:53c4) + db $00,$00,$00,$80 -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 +Func_213c8: ; 213c8 (8:53c8) + xor a + ld [H_AUTOBGTRANSFERENABLED], a ; $FF00+$ba + call SaveScreenTilesToBuffer2 + ld a, [$d5a2] 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 + 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 -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 +SomeonesPCText: ; 2148b (8:548b) + db "SOMEONE's PC@" -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 +BillsPCText: ; 21497 (8:5497) + db "BILL's PC@" -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 +PlayersPCText: ; 214a0 (8:54a0) + db "'s PC@" -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 +OaksPCText: ; 214a5 (8:54a5) + db "PROF.OAK's PC@" -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 +PKMNLeaguePCText: ; 214b2 (8:54b2) + db $4a,"LEAGUE@" -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 +LogOffPCText: ; 214ba (8:54ba) + db "LOG OFF@" + +Func_214c2: ; 214c2 (8:54c2) +BillsPC_: ; 0x214c2 + ld hl, $d730 + set 6, [hl] xor a - ld [$FF00+$1a], a - ld a, $80 - ld [$FF00+$1a], a - ld a, $77 - ld [$FF00+$24], a - jp Func_2224e + 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_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] +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 - jr z, .asm_22162 - ld a, e - cp $7 - jr nz, .asm_22159 - ld a, [$c001] - cp $14 - jr nc, .asm_22152 + 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 -.asm_22152 - ld a, [hl] + +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 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 + 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 - 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 [$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], 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 [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 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 + 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 - jp z, Func_2224e - dec c - jp .asm_22126 + 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_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 +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 [$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 + 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 -; fills d bytes at hl with a -FillMusicRAM8: ; 22248 (8:6248) - ld b, d -.loop - ld [hli], a - dec b - jr nz, .loop - ret +BillsPCMenuText: ; 216e1 (8:56e1) + db "WITHDRAW ",$4a,$4e,"DEPOSIT ",$4a,$4e,"RELEASE ",$4a,$4e,"CHANGE BOX",$4e,"SEE YA!@" -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 +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 - 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 + ld hl, HMMoveArray ; $5745 + ld de, $0001 + call IsInArray 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 + ret c dec b - ld a, b + jr nz, .asm_21731 ; 0x21741 $ee 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 + 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 - 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] + 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 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 + 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 + + +INCLUDE "audio/engine_2.asm" + Music_PokeFluteInBattle: ; 22306 (8:6306) ld a, (SFX_08_46 - $4000) / 3 ; PokeFlute outside of battle @@ -119373,2797 +115972,1122 @@ FrameBlock44: ; 7b720 (1e:7720) db $28,$00,$49,$00 db $28,$28,$49,$00 -FrameBlock45: ; 7b731 (1e:7731) - db $04 - db $00,$00,$49,$00 - db $00,$18,$49,$00 - db $18,$00,$49,$00 - db $18,$18,$49,$00 - -FrameBlock46: ; 7b742 (1e:7742) - db $04 - db $00,$00,$49,$00 - db $00,$08,$49,$00 - db $08,$00,$49,$00 - db $08,$08,$49,$00 - -FrameBlock47: ; 7b753 (1e:7753) - db $04 - db $00,$00,$43,$00 - db $00,$08,$43,$20 - db $08,$00,$43,$40 - db $08,$08,$43,$60 - -FrameBlock48: ; 7b764 (1e:7764) - db $04 - db $08,$08,$33,$00 - db $08,$10,$33,$20 - db $10,$08,$33,$40 - db $10,$10,$33,$60 - -FrameBlock49: ; 7b775 (1e:7775) - db $10 - db $00,$00,$22,$00 - db $00,$08,$23,$00 - db $00,$10,$23,$20 - db $00,$18,$22,$20 - db $08,$00,$32,$00 - db $08,$08,$43,$00 - db $08,$10,$43,$20 - db $08,$18,$32,$20 - db $10,$00,$32,$40 - db $10,$08,$43,$40 - db $10,$10,$43,$60 - db $10,$18,$32,$60 - db $18,$00,$22,$40 - db $18,$08,$23,$40 - db $18,$10,$23,$60 - db $18,$18,$22,$60 - -FrameBlock71: ; 7b7b6 (1e:77b6) - db $10 - db $00,$00,$22,$00 - db $00,$08,$3b,$00 - db $00,$10,$23,$20 - db $00,$18,$22,$20 - db $08,$00,$32,$00 - db $08,$08,$43,$00 - db $08,$10,$43,$20 - db $08,$18,$32,$20 - db $10,$00,$32,$40 - db $10,$08,$43,$40 - db $10,$10,$43,$60 - db $10,$18,$32,$60 - db $18,$00,$22,$40 - db $18,$08,$23,$40 - db $18,$10,$23,$60 - db $18,$18,$22,$60 - -FrameBlock72: ; 7b7f7 (1e:77f7) - db $0c - db $00,$00,$32,$00 - db $00,$08,$43,$00 - db $00,$10,$43,$20 - db $00,$18,$32,$20 - db $08,$00,$32,$40 - db $08,$08,$43,$40 - db $08,$10,$43,$60 - db $08,$18,$32,$60 - db $10,$00,$22,$40 - db $10,$08,$23,$40 - db $10,$10,$23,$60 - db $10,$18,$22,$60 - -FrameBlock73: ; 7b828 (1e:7828) - db $08 - db $00,$00,$32,$40 - db $00,$08,$43,$40 - db $00,$10,$43,$60 - db $00,$18,$32,$60 - db $08,$00,$22,$40 - db $08,$08,$23,$40 - db $08,$10,$23,$60 - db $08,$18,$22,$60 - -FrameBlock74: ; 7b849 (1e:7849) - db $04 - db $00,$00,$22,$40 - db $00,$08,$23,$40 - db $00,$10,$23,$60 - db $00,$18,$22,$60 - -FrameBlock4a: ; 7b85a (1e:785a) - db $04 - db $08,$18,$4c,$20 - db $20,$08,$4b,$00 - db $30,$20,$4c,$00 - db $18,$30,$4b,$40 - -FrameBlock4b: ; 7b86b (1e:786b) - db $04 - db $00,$18,$4c,$00 - db $20,$00,$4b,$40 - db $38,$20,$4c,$20 - db $18,$38,$4b,$00 - -FrameBlock4c: ; 7b87c (1e:787c) - db $04 - db $10,$08,$4a,$40 - db $30,$10,$4a,$00 - db $28,$30,$4a,$20 - db $08,$28,$4a,$60 - -FrameBlock4d: ; 7b88d (1e:788d) - db $04 - db $08,$00,$4a,$20 - db $38,$08,$4a,$60 - db $30,$38,$4a,$40 - db $00,$30,$4a,$00 - -FrameBlock4e: ; 7b89e (1e:789e) - db $08 - db $00,$30,$44,$00 - db $00,$38,$44,$20 - db $08,$30,$44,$40 - db $08,$38,$44,$60 - db $26,$0a,$44,$00 - db $26,$12,$44,$20 - db $2e,$0a,$44,$40 - db $2e,$12,$44,$60 - -FrameBlock4f: ; 7b8bf (1e:78bf) - db $0c - db $0e,$22,$44,$00 - db $0e,$2a,$44,$20 - db $16,$22,$44,$40 - db $16,$2a,$44,$60 - db $06,$32,$47,$00 - db $00,$38,$47,$00 - db $1a,$16,$44,$00 - db $1a,$1e,$44,$20 - db $22,$16,$44,$40 - db $22,$1e,$44,$60 - db $30,$08,$47,$00 - db $2a,$0e,$47,$00 - -FrameBlock50: ; 7b8f0 (1e:78f0) - db $08 - db $06,$32,$47,$00 - db $00,$38,$47,$00 - db $12,$26,$47,$00 - db $0c,$2c,$47,$00 - db $1e,$1a,$47,$00 - db $18,$20,$47,$00 - db $2a,$0e,$47,$00 - db $24,$14,$47,$00 - -FrameBlock51: ; 7b911 (1e:7911) - db $08 - db $00,$00,$35,$20 - db $08,$00,$35,$40 - db $10,$00,$35,$00 - db $18,$00,$35,$60 - db $00,$40,$35,$00 - db $08,$40,$35,$60 - db $10,$40,$35,$20 - db $18,$40,$35,$40 - -FrameBlock52: ; 7b932 (1e:7932) - db $04 - db $00,$00,$2a,$00 - db $00,$08,$2b,$00 - db $08,$00,$3a,$00 - db $08,$08,$3b,$00 - -FrameBlock53: ; 7b943 (1e:7943) - db $03 - db $00,$00,$3f,$00 - db $00,$08,$3f,$00 - db $08,$06,$3f,$00 - -FrameBlock54: ; 7b950 (1e:7950) - db $04 - db $00,$00,$0e,$00 - db $00,$08,$0e,$20 - db $08,$00,$0f,$00 - db $08,$08,$0f,$20 - -FrameBlock55: ; 7b961 (1e:7961) - db $03 - db $10,$00,$2c,$00 - db $10,$08,$3c,$00 - db $10,$10,$2d,$00 - -FrameBlock56: ; 7b96e (1e:796e) - db $06 - db $10,$10,$31,$00 - db $10,$18,$31,$00 - db $08,$10,$2c,$00 - db $08,$18,$3c,$00 - db $08,$20,$2d,$00 - db $10,$20,$2d,$00 - -FrameBlock57: ; 7b987 (1e:7987) - db $09 - db $08,$20,$31,$00 - db $10,$20,$31,$00 - db $08,$28,$31,$00 - db $10,$28,$31,$00 - db $00,$20,$2c,$00 - db $00,$28,$3c,$00 - db $00,$30,$2d,$00 - db $08,$30,$2d,$00 - db $10,$30,$2d,$00 - -FrameBlock58: ; 7b9ac (1e:79ac) - db $07 - db $00,$00,$46,$00 - db $08,$02,$47,$00 - db $10,$03,$48,$00 - db $18,$04,$48,$00 - db $20,$05,$48,$00 - db $28,$05,$48,$00 - db $30,$05,$48,$00 - -FrameBlock59: ; 7b9c9 (1e:79c9) - db $01 - db $00,$00,$42,$00 - -FrameBlock5a: ; 7b9ce (1e:79ce) - db $0c - db $00,$00,$24,$00 - db $00,$08,$25,$00 - db $08,$00,$34,$00 - db $00,$10,$25,$20 - db $00,$18,$24,$20 - db $08,$18,$34,$20 - db $10,$00,$34,$40 - db $18,$00,$24,$40 - db $18,$08,$25,$40 - db $10,$18,$34,$60 - db $18,$10,$25,$60 - db $18,$18,$24,$60 - -FrameBlock5b: ; 7b9ff (1e:79ff) - db $04 - db $00,$00,$43,$00 - db $00,$08,$43,$20 - db $08,$00,$43,$40 - db $08,$08,$43,$60 - -FrameBlock5c: ; 7ba10 (1e:7a10) - db $08 - db $00,$00,$49,$00 - db $02,$08,$49,$00 - db $18,$00,$49,$00 - db $10,$10,$49,$00 - db $08,$00,$43,$00 - db $08,$08,$43,$20 - db $10,$00,$43,$40 - db $10,$08,$43,$60 - -FrameBlock5d: ; 7ba31 (1e:7a31) - db $0b - db $00,$00,$49,$00 - db $18,$02,$49,$00 - db $14,$10,$49,$00 - db $08,$00,$43,$00 - db $00,$08,$43,$20 - db $10,$00,$43,$40 - db $10,$08,$43,$60 - db $04,$08,$43,$00 - db $04,$10,$43,$20 - db $0c,$08,$43,$40 - db $0c,$10,$43,$60 - -FrameBlock5e: ; 7ba5e (1e:7a5e) - db $0f - db $00,$08,$49,$00 - db $08,$10,$49,$00 - db $20,$00,$49,$00 - db $08,$00,$43,$00 - db $08,$08,$43,$20 - db $10,$00,$43,$40 - db $10,$08,$43,$60 - db $10,$10,$43,$00 - db $10,$18,$43,$20 - db $18,$10,$43,$40 - db $18,$18,$43,$60 - db $20,$08,$43,$00 - db $20,$10,$43,$20 - db $28,$08,$43,$40 - db $28,$10,$43,$60 - -FrameBlock5f: ; 7ba9b (1e:7a9b) - db $04 - db $00,$00,$49,$00 - db $00,$10,$49,$00 - db $00,$20,$49,$00 - db $00,$30,$49,$00 - -FrameBlock60: ; 7baac (1e:7aac) - db $08 - db $00,$00,$49,$00 - db $00,$10,$49,$00 - db $00,$20,$49,$00 - db $00,$30,$49,$00 - db $08,$08,$49,$00 - db $08,$18,$49,$00 - db $08,$28,$49,$00 - db $08,$38,$49,$00 - -FrameBlock61: ; 7bacd (1e:7acd) - db $0c - db $00,$00,$49,$00 - db $00,$10,$49,$00 - db $00,$20,$49,$00 - db $00,$30,$49,$00 - db $08,$08,$49,$00 - db $08,$18,$49,$00 - db $08,$28,$49,$00 - db $08,$38,$49,$00 - db $10,$00,$49,$00 - db $10,$10,$49,$00 - db $10,$20,$49,$00 - db $10,$30,$49,$00 - -FrameBlock62: ; 7bafe (1e:7afe) - db $0f - db $00,$00,$49,$00 - db $00,$10,$49,$00 - db $00,$20,$49,$00 - db $00,$30,$49,$00 - db $08,$08,$49,$00 - db $08,$18,$49,$00 - db $08,$28,$49,$00 - db $08,$38,$49,$00 - db $10,$00,$49,$00 - db $10,$10,$49,$00 - db $10,$20,$49,$00 - db $10,$30,$49,$00 - db $18,$08,$49,$00 - db $18,$18,$49,$00 - db $18,$28,$49,$00 - db $18,$38,$49,$00 ; unused - -FrameBlock63: ; 7bb3f (1e:7b3f) - db $06 - db $10,$00,$26,$00 - db $10,$08,$27,$00 - db $08,$10,$26,$00 - db $08,$18,$27,$00 - db $00,$20,$26,$00 - db $00,$28,$27,$00 - -FrameBlock64: ; 7bb58 (1e:7b58) - db $06 - db $18,$00,$27,$00 - db $10,$08,$26,$00 - db $10,$10,$27,$00 - db $08,$18,$26,$00 - db $08,$20,$27,$00 - db $00,$28,$26,$00 - -FrameBlock65: ; 7bb71 (1e:7b71) - db $06 - db $00,$00,$1c,$00 - db $00,$08,$1d,$00 - db $10,$00,$1c,$00 - db $10,$08,$1d,$00 - db $20,$00,$1c,$00 - db $20,$08,$1d,$00 +FrameBlock45: ; 7b731 (1e:7731) + db $04 + db $00,$00,$49,$00 + db $00,$18,$49,$00 + db $18,$00,$49,$00 + db $18,$18,$49,$00 -FrameBlock66: ; 7bb8a (1e:7b8a) - db $02 - db $00,$00,$03,$00 - db $08,$00,$13,$00 +FrameBlock46: ; 7b742 (1e:7742) + db $04 + db $00,$00,$49,$00 + db $00,$08,$49,$00 + db $08,$00,$49,$00 + db $08,$08,$49,$00 -FrameBlock67: ; 7bb93 (1e:7b93) - db $01 - db $00,$00,$03,$00 +FrameBlock47: ; 7b753 (1e:7753) + db $04 + db $00,$00,$43,$00 + db $00,$08,$43,$20 + db $08,$00,$43,$40 + db $08,$08,$43,$60 -FrameBlock68: ; 7bb98 (1e:7b98) +FrameBlock48: ; 7b764 (1e:7764) db $04 - db $00,$00,$03,$00 - db $00,$08,$03,$20 - db $08,$00,$13,$00 - db $08,$08,$13,$20 + db $08,$08,$33,$00 + db $08,$10,$33,$20 + db $10,$08,$33,$40 + db $10,$10,$33,$60 -FrameBlock69: ; 7bba9 (1e:7ba9) - db $01 - db $00,$00,$06,$00 +FrameBlock49: ; 7b775 (1e:7775) + db $10 + db $00,$00,$22,$00 + db $00,$08,$23,$00 + db $00,$10,$23,$20 + db $00,$18,$22,$20 + db $08,$00,$32,$00 + db $08,$08,$43,$00 + db $08,$10,$43,$20 + db $08,$18,$32,$20 + db $10,$00,$32,$40 + db $10,$08,$43,$40 + db $10,$10,$43,$60 + db $10,$18,$32,$60 + db $18,$00,$22,$40 + db $18,$08,$23,$40 + db $18,$10,$23,$60 + db $18,$18,$22,$60 -FrameBlock6a: ; 7bbae (1e:7bae) - db $08 - db $00,$00,$2e,$00 - db $00,$30,$2e,$20 - db $30,$00,$2e,$40 - db $30,$30,$2e,$60 - db $00,$18,$2f,$00 - db $30,$18,$2f,$40 - db $18,$00,$3e,$00 - db $18,$30,$3e,$20 +FrameBlock71: ; 7b7b6 (1e:77b6) + db $10 + db $00,$00,$22,$00 + db $00,$08,$3b,$00 + db $00,$10,$23,$20 + db $00,$18,$22,$20 + db $08,$00,$32,$00 + db $08,$08,$43,$00 + db $08,$10,$43,$20 + db $08,$18,$32,$20 + db $10,$00,$32,$40 + db $10,$08,$43,$40 + db $10,$10,$43,$60 + db $10,$18,$32,$60 + db $18,$00,$22,$40 + db $18,$08,$23,$40 + db $18,$10,$23,$60 + db $18,$18,$22,$60 -FrameBlock6b: ; 7bbcf (1e:7bcf) - db $08 - db $00,$00,$2e,$00 - db $00,$20,$2e,$20 - db $20,$00,$2e,$40 - db $20,$20,$2e,$60 - db $00,$10,$2f,$00 - db $20,$10,$2f,$40 - db $10,$00,$3e,$00 - db $10,$20,$3e,$20 +FrameBlock72: ; 7b7f7 (1e:77f7) + db $0c + db $00,$00,$32,$00 + db $00,$08,$43,$00 + db $00,$10,$43,$20 + db $00,$18,$32,$20 + db $08,$00,$32,$40 + db $08,$08,$43,$40 + db $08,$10,$43,$60 + db $08,$18,$32,$60 + db $10,$00,$22,$40 + db $10,$08,$23,$40 + db $10,$10,$23,$60 + db $10,$18,$22,$60 -FrameBlock6c: ; 7bbf0 (1e:7bf0) +FrameBlock73: ; 7b828 (1e:7828) db $08 - db $00,$00,$2e,$00 - db $00,$10,$2e,$20 - db $10,$00,$2e,$40 - db $10,$10,$2e,$60 - db $00,$08,$2f,$00 - db $10,$08,$2f,$40 - db $08,$00,$3e,$00 - db $08,$10,$3e,$20 - -FrameBlock6d: ; 7bc11 (1e:7c11) - db $02 - db $00,$00,$1e,$00 - db $00,$08,$1f,$00 + db $00,$00,$32,$40 + db $00,$08,$43,$40 + db $00,$10,$43,$60 + db $00,$18,$32,$60 + db $08,$00,$22,$40 + db $08,$08,$23,$40 + db $08,$10,$23,$60 + db $08,$18,$22,$60 -FrameBlock6e: ; 7bc1a (1e:7c1a) +FrameBlock74: ; 7b849 (1e:7849) db $04 - db $00,$00,$48,$00 - db $00,$08,$48,$20 - db $08,$00,$12,$00 - db $08,$08,$12,$20 + db $00,$00,$22,$40 + db $00,$08,$23,$40 + db $00,$10,$23,$60 + db $00,$18,$22,$60 -FrameBlock6f: ; 7bc2b (1e:7c2b) +FrameBlock4a: ; 7b85a (1e:785a) db $04 - db $00,$00,$4a,$00 - db $00,$08,$07,$00 - db $08,$00,$16,$00 - db $08,$08,$17,$00 + db $08,$18,$4c,$20 + db $20,$08,$4b,$00 + db $30,$20,$4c,$00 + db $18,$30,$4b,$40 -FrameBlock70: ; 7bc3c (1e:7c3c) +FrameBlock4b: ; 7b86b (1e:786b) db $04 - db $00,$00,$07,$20 - db $00,$08,$4a,$20 - db $08,$00,$17,$20 - db $08,$08,$16,$20 - -FrameBlock76: ; 7bc4d (1e:7c4d) - db $07 - db $00,$10,$2f,$00 - db $01,$08,$2f,$00 - db $01,$18,$2f,$00 - db $02,$00,$2e,$00 - db $02,$20,$2e,$20 - db $0a,$00,$3e,$00 - db $0a,$20,$3e,$20 + db $00,$18,$4c,$00 + db $20,$00,$4b,$40 + db $38,$20,$4c,$20 + db $18,$38,$4b,$00 -FrameBlock77: ; 7bc6a (1e:7c6a) +FrameBlock4c: ; 7b87c (1e:787c) db $04 - db $00,$02,$4b,$00 - db $00,$0a,$4c,$00 - db $08,$00,$4c,$60 - db $08,$08,$4b,$60 + db $10,$08,$4a,$40 + db $30,$10,$4a,$00 + db $28,$30,$4a,$20 + db $08,$28,$4a,$60 -FrameBlock78: ; 7bc7b (1e:7c7b) - db $01 - db $00,$00,$4d,$00 +FrameBlock4d: ; 7b88d (1e:788d) + db $04 + db $08,$00,$4a,$20 + db $38,$08,$4a,$60 + db $30,$38,$4a,$40 + db $00,$30,$4a,$00 -FrameBlock79: ; 7bc80 (1e:7c80) - db $01 - db $00,$00,$4e,$00 +FrameBlock4e: ; 7b89e (1e:789e) + db $08 + db $00,$30,$44,$00 + db $00,$38,$44,$20 + db $08,$30,$44,$40 + db $08,$38,$44,$60 + db $26,$0a,$44,$00 + db $26,$12,$44,$20 + db $2e,$0a,$44,$40 + db $2e,$12,$44,$60 -FrameBlockBaseCoords: ; 7bc85 (1e:7c85) - db $10,$68 - db $10,$70 - db $10,$78 - db $10,$80 - db $10,$88 - db $10,$90 - db $10,$98 - db $18,$68 - db $18,$70 - db $18,$78 - db $34,$28 - db $18,$80 - db $18,$88 - db $18,$98 - db $20,$68 - db $20,$70 - db $20,$78 - db $20,$80 - db $20,$88 - db $20,$90 - db $20,$98 - db $28,$68 - db $28,$70 - db $28,$78 - db $28,$80 - db $28,$88 - db $30,$68 - db $30,$70 - db $30,$78 - db $30,$80 - db $30,$90 - db $30,$98 - db $38,$68 - db $38,$78 - db $38,$80 - db $38,$88 - db $40,$68 - db $40,$70 - db $40,$78 - db $40,$80 - db $40,$88 - db $40,$98 - db $10,$60 - db $18,$60 - db $20,$60 - db $28,$60 - db $30,$60 - db $40,$60 - db $58,$28 - db $43,$38 - db $33,$48 - db $20,$58 - db $32,$78 - db $58,$58 - db $2C,$6C - db $34,$80 - db $48,$70 - db $42,$36 - db $38,$44 - db $40,$52 - db $48,$60 - db $3E,$6E - db $28,$7C - db $28,$8A - db $50,$3C - db $48,$50 - db $40,$64 - db $38,$38 - db $50,$30 - db $50,$38 - db $50,$40 - db $50,$48 - db $50,$50 - db $48,$58 - db $50,$44 - db $48,$48 - db $48,$4C - db $40,$50 - db $40,$54 - db $38,$58 - db $38,$5C - db $30,$64 - db $48,$40 - db $48,$39 - db $24,$88 - db $24,$70 - db $1C,$70 - db $1C,$88 - db $34,$68 - db $34,$88 - db $68,$50 - db $60,$50 - db $68,$60 - db $58,$50 - db $60,$60 - db $68,$40 - db $40,$40 - db $38,$40 - db $0B,$60 - db $44,$48 - db $40,$14 - db $48,$1C - db $50,$24 - db $4C,$24 - db $10,$62 - db $12,$62 - db $12,$60 - db $20,$72 - db $22,$72 - db $22,$70 - db $28,$62 - db $50,$0A - db $52,$0A - db $38,$30 - db $40,$48 - db $30,$48 - db $40,$30 - db $30,$40 - db $38,$48 - db $40,$4A - db $48,$4B - db $50,$4C - db $58,$4D - db $60,$4D - db $68,$4D - db $38,$10 - db $50,$10 - db $38,$28 - db $48,$18 - db $40,$20 - db $48,$20 - db $40,$3C - db $38,$50 - db $28,$64 - db $1C,$90 - db $24,$80 - db $2C,$70 - db $30,$38 - db $10,$50 - db $3C,$40 - db $40,$58 - db $30,$58 - db $58,$48 - db $50,$58 - db $48,$68 - db $40,$18 - db $28,$58 - db $40,$38 - db $48,$38 - db $08,$70 - db $44,$1C - db $3C,$58 - db $38,$60 - db $08,$60 - db $38,$70 - db $38,$6C - db $38,$64 - db $1C,$74 - db $2E,$74 - db $34,$50 - db $2F,$60 - db $31,$70 - db $4C,$30 - db $3B,$40 - db $2D,$50 - db $26,$60 - db $2D,$70 - db $28,$50 - db $1E,$60 - db $29,$70 - db $16,$60 - db $14,$58 - db $12,$54 - db $14,$50 - db $18,$4C - db $1C,$48 - db $48,$28 +FrameBlock4f: ; 7b8bf (1e:78bf) + db $0c + db $0e,$22,$44,$00 + db $0e,$2a,$44,$20 + db $16,$22,$44,$40 + db $16,$2a,$44,$60 + db $06,$32,$47,$00 + db $00,$38,$47,$00 + db $1a,$16,$44,$00 + db $1a,$1e,$44,$20 + db $22,$16,$44,$40 + db $22,$1e,$44,$60 + db $30,$08,$47,$00 + db $2a,$0e,$47,$00 -FrameBlock00: ; 7bde7 (1e:7de7) - db $00,$00 +FrameBlock50: ; 7b8f0 (1e:78f0) + db $08 + db $06,$32,$47,$00 + db $00,$38,$47,$00 + db $12,$26,$47,$00 + db $0c,$2c,$47,$00 + db $1e,$1a,$47,$00 + db $18,$20,$47,$00 + db $2a,$0e,$47,$00 + db $24,$14,$47,$00 -Func_7bde9: ; 7bde9 (1e:7de9) - push hl - push de - push bc - ld a, [$cf91] - push af - ld a, [$d0b5] - push af - xor a - ld [$d083], a - ld [$c02a], a - dec a - ld [$c0ee], a - call PlaySound - ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $FF00+$ba - ld a, $8c - call PlaySound - call Delay3 - xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $FF00+$ba - ld [$FF00+$d7], a - ld a, [$cee9] - ld [$cf1d], a - ld c, $0 - call Func_7beb4 - ld a, [$ceea] - ld [$cf91], a - ld [$d0b5], a - call Func_7beb9 - ld de, $9000 - ld hl, $9310 - ld bc, $31 - call CopyVideoData - ld a, [$cee9] - ld [$cf91], a - ld [$d0b5], a - call Func_7beb9 - ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $FF00+$ba - ld a, [$cee9] - call PlayCry - call WaitForSoundToFinish - ld c, BANK(Music_SafariZone) - ld a, (Music_SafariZone - $4000) / 3 - call PlayMusic - ld c, $50 - call DelayFrames - ld c, $1 - call Func_7beb4 - ld bc, $110 -.asm_7be63 - push bc - call asm_7befa - jr c, .asm_7bea9 - call asm_7bec2 - pop bc - inc b - dec c - dec c - jr nz, .asm_7be63 - xor a - ld [$ceec], a - ld a, $31 - ld [$ceeb], a - call Func_7bed6 - ld a, [$ceea] -.asm_7be81 - ld [$cf1d], a - ld a, $ff - ld [$c0ee], a - call PlaySound - ld a, [$cf1d] - call PlayCry - ld c, $0 - call Func_7beb4 - pop af - ld [$d0b5], a - pop af - ld [$cf91], a - pop bc - pop de - pop hl - ld a, [$ceec] - and a - ret z - scf - ret -.asm_7bea9 - pop bc - ld a, $1 - ld [$ceec], a - ld a, [$cee9] - jr .asm_7be81 +FrameBlock51: ; 7b911 (1e:7911) + db $08 + db $00,$00,$35,$20 + db $08,$00,$35,$40 + db $10,$00,$35,$00 + db $18,$00,$35,$60 + db $00,$40,$35,$00 + db $08,$40,$35,$60 + db $10,$40,$35,$20 + db $18,$40,$35,$40 -Func_7beb4: ; 7beb4 (1e:7eb4) - ld b, $b - jp GoPAL_SET +FrameBlock52: ; 7b932 (1e:7932) + db $04 + db $00,$00,$2a,$00 + db $00,$08,$2b,$00 + db $08,$00,$3a,$00 + db $08,$08,$3b,$00 -Func_7beb9: ; 7beb9 (1e:7eb9) - call GetMonHeader - FuncCoord 7, 2 ; $c3cf - ld hl, Coord - jp LoadFlippedFrontSpriteByMonIndex -asm_7bec2: ; 7bec2 (1e:7ec2) - ld a, $31 - ld [$ceeb], a - call Func_7bed6 - ld a, $cf - ld [$ceeb], a - call Func_7bed6 - dec b - jr nz, asm_7bec2 - ret +FrameBlock53: ; 7b943 (1e:7943) + db $03 + db $00,$00,$3f,$00 + db $00,$08,$3f,$00 + db $08,$06,$3f,$00 -Func_7bed6: ; 7bed6 (1e:7ed6) - push bc - xor a - ld [H_AUTOBGTRANSFERENABLED], a ; $FF00+$ba - FuncCoord 7, 2 ; $c3cf - ld hl, Coord - ld bc, $707 - ld de, $d -.asm_7bee3 - push bc -.asm_7bee4 - ld a, [$ceeb] - add [hl] - ld [hli], a - dec c - jr nz, .asm_7bee4 - pop bc - add hl, de - dec b - jr nz, .asm_7bee3 - ld a, $1 - ld [H_AUTOBGTRANSFERENABLED], a ; $FF00+$ba - call Delay3 - pop bc - ret -asm_7befa: ; 7befa (1e:7efa) - call DelayFrame - push bc - call GetJoypadStateLowSensitivity - ld a, [$FF00+$b5] - pop bc - and $2 - jr nz, .asm_7bf0d -.asm_7bf08 - dec c - jr nz, asm_7befa - and a - ret -.asm_7bf0d - ld a, [$ccd4] - and a - jr nz, .asm_7bf08 - scf - ret +FrameBlock54: ; 7b950 (1e:7950) + db $04 + db $00,$00,$0e,$00 + db $00,$08,$0e,$20 + db $08,$00,$0f,$00 + db $08,$08,$0f,$20 -Func_7bf15: ; 7bf15 (1e:7f15) - ld de, $ffe0 - call Func_7bf64 - ld de, $240 - call Func_7bf64 - call Delay3 - ld a, $ff - call PlaySound - ld a, [$FF00+$af] - ld d, a - ld e, $1 - ld b, $64 -.asm_7bf30 - ld a, e - xor $fe - ld e, a - add d - ld [$FF00+$af], a - push bc - ld c, BANK(SFX_02_5b) - ld a, (SFX_02_5b - $4000) / 3 - call PlayMusic - pop bc - ld c, $2 - call DelayFrames - dec b - jr nz, .asm_7bf30 - ld a, d - ld [$FF00+$af], a - ld a, $ff - call PlaySound - ld c, BANK(SFX_02_5f) - ld a, (SFX_02_5f - $4000) / 3 - call PlayMusic -.asm_7bf57 - ld a, [$c02a] - cp $b9 - jr z, .asm_7bf57 - call UpdateSprites - jp Func_2307 +FrameBlock55: ; 7b961 (1e:7961) + db $03 + db $10,$00,$2c,$00 + db $10,$08,$3c,$00 + db $10,$10,$2d,$00 -Func_7bf64: ; 7bf64 (1e:7f64) - ld hl, $d527 - ld a, [hld] - push af - ld a, [hl] - push af - push hl - push hl - ld a, [hli] - ld h, [hl] - ld l, a - add hl, de - ld a, h - and $3 - or $98 - ld d, a - ld a, l - pop hl - ld [hli], a - ld [hl], d - call ScheduleNorthRowRedraw - pop hl - pop af - ld [hli], a - pop af - ld [hl], a - jp Delay3 +FrameBlock56: ; 7b96e (1e:796e) + db $06 + db $10,$10,$31,$00 + db $10,$18,$31,$00 + db $08,$10,$2c,$00 + db $08,$18,$3c,$00 + db $08,$20,$2d,$00 + db $10,$20,$2d,$00 -GetMachinePrice: ; 7bf86 (1e:7f86) - ld a, [$cf91] - sub TM_01 - ret c - ld d, a - ld hl, TechnicalMachinePrices ; $7fa7 - srl a - ld c, a - ld b, 0 - add hl, bc - ld a, [hl] - srl d - jr nc, .asm_7bf9d - swap a -.asm_7bf9d - and $f0 - ld [H_DOWNARROWBLINKCNT2], a ; $FF00+$8c - xor a - ld [H_DOWNARROWBLINKCNT1], a ; $FF00+$8b - ld [$FF00+$8d], a - ret +FrameBlock57: ; 7b987 (1e:7987) + db $09 + db $08,$20,$31,$00 + db $10,$20,$31,$00 + db $08,$28,$31,$00 + db $10,$28,$31,$00 + db $00,$20,$2c,$00 + db $00,$28,$3c,$00 + db $00,$30,$2d,$00 + db $08,$30,$2d,$00 + db $10,$30,$2d,$00 -TechnicalMachinePrices: ; 7bfa7 (1e:7fa7) -; In thousands (nybbles). - db $32, $21, $34, $24, $34 - db $21, $45, $55, $32, $32 - db $55, $52, $54, $52, $41 - db $21, $12, $42, $25, $24 - db $22, $52, $24, $34, $42 +FrameBlock58: ; 7b9ac (1e:79ac) + db $07 + db $00,$00,$46,$00 + db $08,$02,$47,$00 + db $10,$03,$48,$00 + db $18,$04,$48,$00 + db $20,$05,$48,$00 + db $28,$05,$48,$00 + db $30,$05,$48,$00 -SECTION "bank1F",ROMX,BANK[$1F] +FrameBlock59: ; 7b9c9 (1e:79c9) + db $01 + db $00,$00,$42,$00 -INCLUDE "music/headers/sfxheaders1f.asm" -INCLUDE "music/headers/musicheaders1f.asm" +FrameBlock5a: ; 7b9ce (1e:79ce) + db $0c + db $00,$00,$24,$00 + db $00,$08,$25,$00 + db $08,$00,$34,$00 + db $00,$10,$25,$20 + db $00,$18,$24,$20 + db $08,$18,$34,$20 + db $10,$00,$34,$40 + db $18,$00,$24,$40 + db $18,$08,$25,$40 + db $10,$18,$34,$60 + db $18,$10,$25,$60 + db $18,$18,$24,$60 -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" +FrameBlock5b: ; 7b9ff (1e:79ff) + db $04 + db $00,$00,$43,$00 + db $00,$08,$43,$20 + db $08,$00,$43,$40 + db $08,$08,$43,$60 -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 +FrameBlock5c: ; 7ba10 (1e:7a10) + db $08 + db $00,$00,$49,$00 + db $02,$08,$49,$00 + db $18,$00,$49,$00 + db $10,$10,$49,$00 + db $08,$00,$43,$00 + db $08,$08,$43,$20 + db $10,$00,$43,$40 + db $10,$08,$43,$60 -; 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 +FrameBlock5d: ; 7ba31 (1e:7a31) + db $0b + db $00,$00,$49,$00 + db $18,$02,$49,$00 + db $14,$10,$49,$00 + db $08,$00,$43,$00 + db $00,$08,$43,$20 + db $10,$00,$43,$40 + db $10,$08,$43,$60 + db $04,$08,$43,$00 + db $04,$10,$43,$20 + db $0c,$08,$43,$40 + db $0c,$10,$43,$60 -Music1f_Channel3Duty1: ; 7c383 (1f:4383) - db $02,$46,$8A,$CE,$EF,$FF,$FE,$EE,$DD,$CB,$A9,$87,$65,$43,$22,$11 +FrameBlock5e: ; 7ba5e (1e:7a5e) + db $0f + db $00,$08,$49,$00 + db $08,$10,$49,$00 + db $20,$00,$49,$00 + db $08,$00,$43,$00 + db $08,$08,$43,$20 + db $10,$00,$43,$40 + db $10,$08,$43,$60 + db $10,$10,$43,$00 + db $10,$18,$43,$20 + db $18,$10,$43,$40 + db $18,$18,$43,$60 + db $20,$08,$43,$00 + db $20,$10,$43,$20 + db $28,$08,$43,$40 + db $28,$10,$43,$60 -Music1f_Channel3Duty2: ; 7c393 (1f:4393) - db $13,$69,$BD,$EE,$EE,$FF,$FF,$ED,$DE,$FF,$FF,$EE,$EE,$DB,$96,$31 +FrameBlock5f: ; 7ba9b (1e:7a9b) + db $04 + db $00,$00,$49,$00 + db $00,$10,$49,$00 + db $00,$20,$49,$00 + db $00,$30,$49,$00 -Music1f_Channel3Duty3: ; 7c3a3 (1f:43a3) - db $02,$46,$8A,$CD,$EF,$FE,$DE,$FF,$EE,$DC,$BA,$98,$76,$54,$32,$10 +FrameBlock60: ; 7baac (1e:7aac) + db $08 + db $00,$00,$49,$00 + db $00,$10,$49,$00 + db $00,$20,$49,$00 + db $00,$30,$49,$00 + db $08,$08,$49,$00 + db $08,$18,$49,$00 + db $08,$28,$49,$00 + db $08,$38,$49,$00 -Music1f_Channel3Duty4: ; 7c3b3 (1f:43b3) - db $01,$23,$45,$67,$8A,$CD,$EE,$F7,$7F,$EE,$DC,$A8,$76,$54,$32,$10 +FrameBlock61: ; 7bacd (1e:7acd) + db $0c + db $00,$00,$49,$00 + db $00,$10,$49,$00 + db $00,$20,$49,$00 + db $00,$30,$49,$00 + db $08,$08,$49,$00 + db $08,$18,$49,$00 + db $08,$28,$49,$00 + db $08,$38,$49,$00 + db $10,$00,$49,$00 + db $10,$10,$49,$00 + db $10,$20,$49,$00 + db $10,$30,$49,$00 -; 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" +FrameBlock62: ; 7bafe (1e:7afe) + db $0f + db $00,$00,$49,$00 + db $00,$10,$49,$00 + db $00,$20,$49,$00 + db $00,$30,$49,$00 + db $08,$08,$49,$00 + db $08,$18,$49,$00 + db $08,$28,$49,$00 + db $08,$38,$49,$00 + db $10,$00,$49,$00 + db $10,$10,$49,$00 + db $10,$20,$49,$00 + db $10,$30,$49,$00 + db $18,$08,$49,$00 + db $18,$18,$49,$00 + db $18,$28,$49,$00 + db $18,$38,$49,$00 ; unused -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 +FrameBlock63: ; 7bb3f (1e:7b3f) + db $06 + db $10,$00,$26,$00 + db $10,$08,$27,$00 + db $08,$10,$26,$00 + db $08,$18,$27,$00 + db $00,$20,$26,$00 + db $00,$28,$27,$00 -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) +FrameBlock64: ; 7bb58 (1e:7b58) + db $06 + db $18,$00,$27,$00 + db $10,$08,$26,$00 + db $10,$10,$27,$00 + db $08,$18,$26,$00 + db $08,$20,$27,$00 + db $00,$28,$26,$00 -OwnedMonValues: ; 7d170 (1f:5170) - db 10, 40, 60, 90, 120, 150, $ff +FrameBlock65: ; 7bb71 (1e:7b71) + db $06 + db $00,$00,$1c,$00 + db $00,$08,$1d,$00 + db $10,$00,$1c,$00 + db $10,$08,$1d,$00 + db $20,$00,$1c,$00 + db $20,$08,$1d,$00 -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 +FrameBlock66: ; 7bb8a (1e:7b8a) + db $02 + db $00,$00,$03,$00 + db $08,$00,$13,$00 -; 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 +FrameBlock67: ; 7bb93 (1e:7b93) + db $01 + db $00,$00,$03,$00 -; 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 +FrameBlock68: ; 7bb98 (1e:7b98) + db $04 + db $00,$00,$03,$00 + db $00,$08,$03,$20 + db $08,$00,$13,$00 + db $08,$08,$13,$20 -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 +FrameBlock69: ; 7bba9 (1e:7ba9) + db $01 + db $00,$00,$06,$00 -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 +FrameBlock6a: ; 7bbae (1e:7bae) + db $08 + db $00,$00,$2e,$00 + db $00,$30,$2e,$20 + db $30,$00,$2e,$40 + db $30,$30,$2e,$60 + db $00,$18,$2f,$00 + db $30,$18,$2f,$40 + db $18,$00,$3e,$00 + db $18,$30,$3e,$20 -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 +FrameBlock6b: ; 7bbcf (1e:7bcf) + db $08 + db $00,$00,$2e,$00 + db $00,$20,$2e,$20 + db $20,$00,$2e,$40 + db $20,$20,$2e,$60 + db $00,$10,$2f,$00 + db $20,$10,$2f,$40 + db $10,$00,$3e,$00 + db $10,$20,$3e,$20 -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 +FrameBlock6c: ; 7bbf0 (1e:7bf0) + db $08 + db $00,$00,$2e,$00 + db $00,$10,$2e,$20 + db $10,$00,$2e,$40 + db $10,$10,$2e,$60 + db $00,$08,$2f,$00 + db $10,$08,$2f,$40 + db $08,$00,$3e,$00 + db $08,$10,$3e,$20 - ; 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 +FrameBlock6d: ; 7bc11 (1e:7c11) + db $02 + db $00,$00,$1e,$00 + db $00,$08,$1f,$00 -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 +FrameBlock6e: ; 7bc1a (1e:7c1a) + db $04 + db $00,$00,$48,$00 + db $00,$08,$48,$20 + db $08,$00,$12,$00 + db $08,$08,$12,$20 -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 +FrameBlock6f: ; 7bc2b (1e:7c2b) + db $04 + db $00,$00,$4a,$00 + db $00,$08,$07,$00 + db $08,$00,$16,$00 + db $08,$08,$17,$00 -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 +FrameBlock70: ; 7bc3c (1e:7c3c) + db $04 + db $00,$00,$07,$20 + db $00,$08,$4a,$20 + db $08,$00,$17,$20 + db $08,$08,$16,$20 -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 +FrameBlock76: ; 7bc4d (1e:7c4d) + db $07 + db $00,$10,$2f,$00 + db $01,$08,$2f,$00 + db $01,$18,$2f,$00 + db $02,$00,$2e,$00 + db $02,$20,$2e,$20 + db $0a,$00,$3e,$00 + db $0a,$20,$3e,$20 -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 +FrameBlock77: ; 7bc6a (1e:7c6a) + db $04 + db $00,$02,$4b,$00 + db $00,$0a,$4c,$00 + db $08,$00,$4c,$60 + db $08,$08,$4b,$60 -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 +FrameBlock78: ; 7bc7b (1e:7c7b) + db $01 + db $00,$00,$4d,$00 -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 +FrameBlock79: ; 7bc80 (1e:7c80) + db $01 + db $00,$00,$4e,$00 + +FrameBlockBaseCoords: ; 7bc85 (1e:7c85) + db $10,$68 + db $10,$70 + db $10,$78 + db $10,$80 + db $10,$88 + db $10,$90 + db $10,$98 + db $18,$68 + db $18,$70 + db $18,$78 + db $34,$28 + db $18,$80 + db $18,$88 + db $18,$98 + db $20,$68 + db $20,$70 + db $20,$78 + db $20,$80 + db $20,$88 + db $20,$90 + db $20,$98 + db $28,$68 + db $28,$70 + db $28,$78 + db $28,$80 + db $28,$88 + db $30,$68 + db $30,$70 + db $30,$78 + db $30,$80 + db $30,$90 + db $30,$98 + db $38,$68 + db $38,$78 + db $38,$80 + db $38,$88 + db $40,$68 + db $40,$70 + db $40,$78 + db $40,$80 + db $40,$88 + db $40,$98 + db $10,$60 + db $18,$60 + db $20,$60 + db $28,$60 + db $30,$60 + db $40,$60 + db $58,$28 + db $43,$38 + db $33,$48 + db $20,$58 + db $32,$78 + db $58,$58 + db $2C,$6C + db $34,$80 + db $48,$70 + db $42,$36 + db $38,$44 + db $40,$52 + db $48,$60 + db $3E,$6E + db $28,$7C + db $28,$8A + db $50,$3C + db $48,$50 + db $40,$64 + db $38,$38 + db $50,$30 + db $50,$38 + db $50,$40 + db $50,$48 + db $50,$50 + db $48,$58 + db $50,$44 + db $48,$48 + db $48,$4C + db $40,$50 + db $40,$54 + db $38,$58 + db $38,$5C + db $30,$64 + db $48,$40 + db $48,$39 + db $24,$88 + db $24,$70 + db $1C,$70 + db $1C,$88 + db $34,$68 + db $34,$88 + db $68,$50 + db $60,$50 + db $68,$60 + db $58,$50 + db $60,$60 + db $68,$40 + db $40,$40 + db $38,$40 + db $0B,$60 + db $44,$48 + db $40,$14 + db $48,$1C + db $50,$24 + db $4C,$24 + db $10,$62 + db $12,$62 + db $12,$60 + db $20,$72 + db $22,$72 + db $22,$70 + db $28,$62 + db $50,$0A + db $52,$0A + db $38,$30 + db $40,$48 + db $30,$48 + db $40,$30 + db $30,$40 + db $38,$48 + db $40,$4A + db $48,$4B + db $50,$4C + db $58,$4D + db $60,$4D + db $68,$4D + db $38,$10 + db $50,$10 + db $38,$28 + db $48,$18 + db $40,$20 + db $48,$20 + db $40,$3C + db $38,$50 + db $28,$64 + db $1C,$90 + db $24,$80 + db $2C,$70 + db $30,$38 + db $10,$50 + db $3C,$40 + db $40,$58 + db $30,$58 + db $58,$48 + db $50,$58 + db $48,$68 + db $40,$18 + db $28,$58 + db $40,$38 + db $48,$38 + db $08,$70 + db $44,$1C + db $3C,$58 + db $38,$60 + db $08,$60 + db $38,$70 + db $38,$6C + db $38,$64 + db $1C,$74 + db $2E,$74 + db $34,$50 + db $2F,$60 + db $31,$70 + db $4C,$30 + db $3B,$40 + db $2D,$50 + db $26,$60 + db $2D,$70 + db $28,$50 + db $1E,$60 + db $29,$70 + db $16,$60 + db $14,$58 + db $12,$54 + db $14,$50 + db $18,$4C + db $1C,$48 + db $48,$28 -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 +FrameBlock00: ; 7bde7 (1e:7de7) + db $00,$00 -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 +Func_7bde9: ; 7bde9 (1e:7de9) + push hl push de push bc - jr asm_7d571 - -Music1f_dnote: ; 7d569 (1f:5569) - ld a, d - and $f + ld a, [$cf91] + push af + ld a, [$d0b5] push af + xor a + ld [$d083], a + ld [$c02a], a + dec a + ld [$c0ee], a + call PlaySound + ld a, $1 + ld [H_AUTOBGTRANSFERENABLED], a ; $FF00+$ba + ld a, $8c + call PlaySound + call Delay3 + xor a + ld [H_AUTOBGTRANSFERENABLED], a ; $FF00+$ba + ld [$FF00+$d7], a + ld a, [$cee9] + ld [$cf1d], a + ld c, $0 + call Func_7beb4 + ld a, [$ceea] + ld [$cf91], a + ld [$d0b5], a + call Func_7beb9 + ld de, $9000 + ld hl, $9310 + ld bc, $31 + call CopyVideoData + ld a, [$cee9] + ld [$cf91], a + ld [$d0b5], a + call Func_7beb9 + ld a, $1 + ld [H_AUTOBGTRANSFERENABLED], a ; $FF00+$ba + ld a, [$cee9] + call PlayCry + call WaitForSoundToFinish + ld c, BANK(Music_SafariZone) + ld a, (Music_SafariZone - $4000) / 3 + call PlayMusic + ld c, $50 + call DelayFrames + ld c, $1 + call Func_7beb4 + ld bc, $110 +.asm_7be63 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 + call asm_7befa + jr c, .asm_7bea9 + call asm_7bec2 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) + inc b + dec c + dec c + jr nz, .asm_7be63 + xor a + ld [$ceec], a + ld a, $31 + ld [$ceeb], a + call Func_7bed6 + ld a, [$ceea] +.asm_7be81 + ld [$cf1d], a + ld a, $ff + ld [$c0ee], a + call PlaySound + ld a, [$cf1d] + call PlayCry + ld c, $0 + call Func_7beb4 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 + ld [$d0b5], a + pop af + ld [$cf91], a + pop bc 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] + pop hl + ld a, [$ceec] 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 z + scf ret +.asm_7bea9 + pop bc + ld a, $1 + ld [$ceec], a + ld a, [$cee9] + jr .asm_7be81 -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_7beb4: ; 7beb4 (1e:7eb4) + ld b, $b + jp GoPAL_SET -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 +Func_7beb9: ; 7beb9 (1e:7eb9) + call GetMonHeader + FuncCoord 7, 2 ; $c3cf + ld hl, Coord + jp LoadFlippedFrontSpriteByMonIndex +asm_7bec2: ; 7bec2 (1e:7ec2) + ld a, $31 + ld [$ceeb], a + call Func_7bed6 + ld a, $cf + ld [$ceeb], a + call Func_7bed6 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 + jr nz, asm_7bec2 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 +Func_7bed6: ; 7bed6 (1e:7ed6) + push bc 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 + ld [H_AUTOBGTRANSFERENABLED], a ; $FF00+$ba + FuncCoord 7, 2 ; $c3cf + ld hl, Coord + ld bc, $707 + ld de, $d +.asm_7bee3 + push bc +.asm_7bee4 + ld a, [$ceeb] 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 + dec c + jr nz, .asm_7bee4 + pop bc 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 + dec b + jr nz, .asm_7bee3 + ld a, $1 + ld [H_AUTOBGTRANSFERENABLED], a ; $FF00+$ba + call Delay3 + pop bc 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 +asm_7befa: ; 7befa (1e:7efa) + call DelayFrame + push bc + call GetJoypadStateLowSensitivity + ld a, [$FF00+$b5] + pop bc + and $2 + jr nz, .asm_7bf0d +.asm_7bf08 + dec c + jr nz, asm_7befa + and a ret - -Func_7d8bb: ; 7d8bb (1f:58bb) - ld h, $0 -.loop - srl a - jr nc, .noCarry - add hl, de -.noCarry - sla e - rl d +.asm_7bf0d + ld a, [$ccd4] and a - jr z, .done - jr .loop -.done + jr nz, .asm_7bf08 + scf 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 +Func_7bf15: ; 7bf15 (1e:7f15) + ld de, $ffe0 + call Func_7bf64 + ld de, $240 + call Func_7bf64 + call Delay3 + ld a, $ff + call PlaySound + ld a, [$FF00+$af] 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 e, $1 + ld b, $64 +.asm_7bf30 + ld a, e + xor $fe + ld e, a + add d + ld [$FF00+$af], a + push bc + ld c, BANK(SFX_02_5b) + ld a, (SFX_02_5b - $4000) / 3 + call PlayMusic + pop bc + ld c, $2 + call DelayFrames + dec b + jr nz, .asm_7bf30 + ld a, d + ld [$FF00+$af], 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 + call PlaySound + ld c, BANK(SFX_02_5f) + ld a, (SFX_02_5f - $4000) / 3 + call PlayMusic +.asm_7bf57 + ld a, [$c02a] + cp $b9 + jr z, .asm_7bf57 + call UpdateSprites + jp Func_2307 -Func_7d9c2: ; 7d9c2 (1f:59c2) +Func_7bf64: ; 7bf64 (1e:7f64) + ld hl, $d527 + ld a, [hld] + push af + ld a, [hl] + push af + push hl + push hl + ld a, [hli] + ld h, [hl] 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 + and $3 + or $98 + ld d, 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 + pop hl ld [hli], a - ld [hl], a - ld hl, $c006 - add hl, de + ld [hl], d + call ScheduleNorthRowRedraw + pop hl + pop af ld [hli], a + pop af 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 + jp Delay3 -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 +GetMachinePrice: ; 7bf86 (1e:7f86) + ld a, [$cf91] + sub TM_01 + ret c + ld d, a + ld hl, TechnicalMachinePrices ; $7fa7 + srl a + ld c, a + ld b, 0 + add hl, bc + ld a, [hl] + srl d + jr nc, .asm_7bf9d + swap a +.asm_7bf9d + and $f0 + ld [H_DOWNARROWBLINKCNT2], a ; $FF00+$8c 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 + ld [H_DOWNARROWBLINKCNT1], a ; $FF00+$8b + ld [$FF00+$8d], 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 +TechnicalMachinePrices: ; 7bfa7 (1e:7fa7) +; In thousands (nybbles). + db $32, $21, $34, $24, $34 + db $21, $45, $55, $32, $32 + db $55, $52, $54, $52, $41 + db $21, $12, $42, $25, $24 + db $22, $52, $24, $34, $42 -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 +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 -.asm_7db25 - cp c - jr z, .asm_7db2d + ld hl, OwnedMonValues +.getSfxPointer + cp [hl] + jr c, .gotSfxPointer inc c inc hl - inc hl - jr .asm_7db25 -.asm_7db2d - push hl + jr .getSfxPointer +.gotSfxPointer push bc - push af + ld a, $ff + ld [$c0ee], a + call PlaySoundWaitForCurrent + pop bc ld b, $0 - ld c, a - ld hl, $c026 + ld hl, PokedexRatingSfxPointers 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 + 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" + INCLUDE "music/bikeriding.asm" INCLUDE "music/dungeon1.asm" -- cgit v1.2.3