Move crysaudio ram from sram to wram

This commit is contained in:
dannye 2021-03-28 12:26:46 -05:00
parent baf447a260
commit 5f87413b23
12 changed files with 253 additions and 379 deletions

View file

@ -48,6 +48,28 @@ _InitSound::
or d or d
jr nz, .clearaudio jr nz, .clearaudio
; channels 5 and 6
ld hl, wChannel5
ld de, CHANNEL_STRUCT_LENGTH * 2
.clearaudio2
xor a
ld [hli], a
dec de
ld a, e
or d
jr nz, .clearaudio2
; channels 7 and 8
ld hl, wChannel7
ld de, CHANNEL_STRUCT_LENGTH * 2
.clearaudio3
xor a
ld [hli], a
dec de
ld a, e
or d
jr nz, .clearaudio3
ld a, MAX_VOLUME ld a, MAX_VOLUME
ld [wVolume], a ld [wVolume], a
call MusicOn call MusicOn
@ -81,7 +103,6 @@ MusicOff:
ret ret
_UpdateSound:: _UpdateSound::
call OpenSRAMForSound
; called once per frame ; called once per frame
; no use updating audio if it's not playing ; no use updating audio if it's not playing
ld a, [wMusicPlaying] ld a, [wMusicPlaying]
@ -170,8 +191,25 @@ _UpdateSound::
ld a, [wCurChannel] ld a, [wCurChannel]
cp NUM_MUSIC_CHANS cp NUM_MUSIC_CHANS
jr nc, .sfx_channel jr nc, .sfx_channel
ld hl, CHANNEL_STRUCT_LENGTH * NUM_MUSIC_CHANS + CHANNEL_FLAGS1
push af
push bc
add 4 ; corresponding sfx channel
ld c, a
ld b, 0
ld hl, ChannelPointers
add hl, bc add hl, bc
add hl, bc
ld c, [hl]
inc hl
ld b, [hl] ; bc = channel pointer
ld hl, CHANNEL_FLAGS1
add hl, bc
pop bc
pop af
; ld hl, CHANNEL_STRUCT_LENGTH * NUM_MUSIC_CHANS + CHANNEL_FLAGS1
; add hl, bc
bit SOUND_CHANNEL_ON, [hl] bit SOUND_CHANNEL_ON, [hl]
jr nz, .sound_channel_on jr nz, .sound_channel_on
.sfx_channel .sfx_channel
@ -189,12 +227,22 @@ _UpdateSound::
ld [hl], a ld [hl], a
.nextchannel .nextchannel
; next channel ; next channel
ld hl, CHANNEL_STRUCT_LENGTH ; ld hl, CHANNEL_STRUCT_LENGTH
add hl, bc ; add hl, bc
ld c, l ; ld c, l
ld b, h ; ld b, h
ld a, [wCurChannel] ld a, [wCurChannel]
inc a inc a
ld c, a
ld b, 0
ld hl, ChannelPointers
add hl, bc
add hl, bc
ld c, [hl]
inc hl
ld b, [hl] ; bc = channel pointer
ld [wCurChannel], a ld [wCurChannel], a
cp NUM_CHANNELS ; are we done? cp NUM_CHANNELS ; are we done?
jp nz, .loop ; do it all again jp nz, .loop ; do it all again
@ -1210,8 +1258,25 @@ ParseMusic:
cp CHAN5 cp CHAN5
jr nc, .chan_5to8 jr nc, .chan_5to8
; ???? ; ????
ld hl, CHANNEL_STRUCT_LENGTH * NUM_MUSIC_CHANS + CHANNEL_FLAGS1
push af
push bc
add 4 ; corresponding sfx channel
ld c, a
ld b, 0
ld hl, ChannelPointers
add hl, bc add hl, bc
add hl, bc
ld c, [hl]
inc hl
ld b, [hl] ; bc = channel pointer
ld hl, CHANNEL_FLAGS1
add hl, bc
pop bc
pop af
; ld hl, CHANNEL_STRUCT_LENGTH * NUM_MUSIC_CHANS + CHANNEL_FLAGS1
; add hl, bc
bit SOUND_CHANNEL_ON, [hl] bit SOUND_CHANNEL_ON, [hl]
jr nz, .ok jr nz, .ok
.chan_5to8 .chan_5to8
@ -2377,7 +2442,6 @@ SetLRTracks:
ret ret
_PlayMusic:: _PlayMusic::
call OpenSRAMForSound
cp NUM_SONGS cp NUM_SONGS
ret nc ; sfx ret nc ; sfx
; load music ; load music

View file

@ -781,10 +781,10 @@ FaintEnemyPokemon:
ld [wTempoModifier], a ld [wTempoModifier], a
ld a, SFX_FAINT_FALL ld a, SFX_FAINT_FALL
call PlaySoundWaitForCurrent call PlaySoundWaitForCurrent
.sfxwait ;.sfxwait
ld a, [wChannelSoundIDs + Ch5] ; ld a, [wChannelSoundIDs + Ch5]
cp SFX_FAINT_FALL ; cp SFX_FAINT_FALL
jr z, .sfxwait ; jr z, .sfxwait
ld a, SFX_FAINT_THUD ld a, SFX_FAINT_THUD
call PlaySound call PlaySound
call WaitForSoundToFinish call WaitForSoundToFinish
@ -866,7 +866,7 @@ EndLowHealthAlarm:
; the low health alarm and prevents it from reactivating until the next battle. ; the low health alarm and prevents it from reactivating until the next battle.
xor a xor a
ld [wLowHealthAlarm], a ; turn off low health alarm ld [wLowHealthAlarm], a ; turn off low health alarm
ld [wChannelSoundIDs + Ch5], a ; ld [wChannelSoundIDs + Ch5], a
inc a inc a
ld [wLowHealthAlarmDisabled], a ; prevent it from reactivating ld [wLowHealthAlarmDisabled], a ; prevent it from reactivating
ret ret
@ -1864,7 +1864,7 @@ DrawPlayerHUDAndHPBar:
ld [hl], $0 ld [hl], $0
ret z ret z
xor a xor a
ld [wChannelSoundIDs + Ch5], a ; ld [wChannelSoundIDs + Ch5], a
ret ret
.setLowHealthAlarm .setLowHealthAlarm
ld hl, wLowHealthAlarm ld hl, wLowHealthAlarm

View file

@ -46,7 +46,7 @@ EndOfBattle:
.resetVariables .resetVariables
xor a xor a
ld [wLowHealthAlarm], a ;disable low health alarm ld [wLowHealthAlarm], a ;disable low health alarm
ld [wChannelSoundIDs + Ch5], a ; ld [wChannelSoundIDs + Ch5], a
ld [wIsInBattle], a ld [wIsInBattle], a
ld [wBattleType], a ld [wBattleType], a
ld [wMoveMissed], a ld [wMoveMissed], a

View file

@ -991,7 +991,7 @@ ItemUseMedicine:
.notFullHP ; if the pokemon's current HP doesn't equal its max HP .notFullHP ; if the pokemon's current HP doesn't equal its max HP
xor a xor a
ld [wLowHealthAlarm], a ;disable low health alarm ld [wLowHealthAlarm], a ;disable low health alarm
ld [wChannelSoundIDs + Ch5], a ; ld [wChannelSoundIDs + Ch5], a
push hl push hl
push de push de
ld bc, wPartyMon1MaxHP - (wPartyMon1HP + 1) ld bc, wPartyMon1MaxHP - (wPartyMon1HP + 1)
@ -1736,10 +1736,10 @@ ItemUsePokeflute:
jr nz, .skipMusic jr nz, .skipMusic
call WaitForSoundToFinish ; wait for sound to end call WaitForSoundToFinish ; wait for sound to end
;farcall Music_PokeFluteInBattle ; play in-battle pokeflute music ; XXX ;farcall Music_PokeFluteInBattle ; play in-battle pokeflute music ; XXX
.musicWaitLoop ; wait for music to finish playing ;.musicWaitLoop ; wait for music to finish playing
ld a, [wChannelSoundIDs + Ch7] ; ld a, [wChannelSoundIDs + Ch7]
and a ; music off? ; and a ; music off?
jr nz, .musicWaitLoop ; jr nz, .musicWaitLoop
.skipMusic .skipMusic
ld hl, FluteWokeUpText ld hl, FluteWokeUpText
jp PrintText jp PrintText

View file

@ -4,10 +4,6 @@ LoadSAV:
call ClearScreen call ClearScreen
call LoadFontTilePatterns call LoadFontTilePatterns
call LoadTextBoxTilePatterns call LoadTextBoxTilePatterns
ld a, 1
ld [wHaltAudio], a
call LoadSAV0 call LoadSAV0
jr c, .badsum jr c, .badsum
call LoadSAV1 call LoadSAV1
@ -29,9 +25,6 @@ LoadSAV:
ld a, $1 ; bad checksum ld a, $1 ; bad checksum
.goodsum .goodsum
ld [wSaveFileStatus], a ld [wSaveFileStatus], a
ld a, 0
ld [wHaltAudio], a
ret ret
FileDataDestroyedText: FileDataDestroyedText:
@ -281,18 +274,9 @@ SaveSAVtoSRAM2:
SaveSAVtoSRAM:: SaveSAVtoSRAM::
ld a, $2 ld a, $2
ld [wSaveFileStatus], a ld [wSaveFileStatus], a
ld a, 1
ld [wHaltAudio], a
call SaveSAVtoSRAM0 call SaveSAVtoSRAM0
call SaveSAVtoSRAM1 call SaveSAVtoSRAM1
call SaveSAVtoSRAM2 jp SaveSAVtoSRAM2
ld a, 0
ld [wHaltAudio], a
ret
SAVCheckSum: SAVCheckSum:
;Check Sum (result[1 byte] is complemented) ;Check Sum (result[1 byte] is complemented)
@ -407,9 +391,6 @@ WhenYouChangeBoxText:
CopyBoxToOrFromSRAM: CopyBoxToOrFromSRAM:
; copy an entire box from hl to de with b as the SRAM bank ; copy an entire box from hl to de with b as the SRAM bank
ld a, 1
ld [wHaltAudio], a
push hl push hl
ld a, SRAM_ENABLE ld a, SRAM_ENABLE
ld [MBC1SRamEnable], a ld [MBC1SRamEnable], a
@ -435,9 +416,6 @@ CopyBoxToOrFromSRAM:
xor a xor a
ld [MBC1SRamBankingMode], a ld [MBC1SRamBankingMode], a
ld [MBC1SRamEnable], a ld [MBC1SRamEnable], a
xor a
ld [wHaltAudio], a
ret ret
DisplayChangeBoxMenu: DisplayChangeBoxMenu:
@ -535,9 +513,6 @@ BoxNoText:
EmptyAllSRAMBoxes: EmptyAllSRAMBoxes:
; marks all boxes in SRAM as empty (initialisation for the first time the ; marks all boxes in SRAM as empty (initialisation for the first time the
; player changes the box) ; player changes the box)
ld a, 1
ld [wHaltAudio], a
ld a, SRAM_ENABLE ld a, SRAM_ENABLE
ld [MBC1SRamEnable], a ld [MBC1SRamEnable], a
ld a, $1 ld a, $1
@ -551,9 +526,6 @@ EmptyAllSRAMBoxes:
xor a xor a
ld [MBC1SRamBankingMode], a ld [MBC1SRamBankingMode], a
ld [MBC1SRamEnable], a ld [MBC1SRamEnable], a
xor a
ld [wHaltAudio], a
ret ret
EmptySRAMBoxesInBank: EmptySRAMBoxesInBank:
@ -585,9 +557,6 @@ EmptySRAMBox:
ret ret
GetMonCountsForAllBoxes: GetMonCountsForAllBoxes:
ld a, 1
ld [wHaltAudio], a
ld hl, wBoxMonCounts ld hl, wBoxMonCounts
push hl push hl
ld a, SRAM_ENABLE ld a, SRAM_ENABLE
@ -614,8 +583,6 @@ GetMonCountsForAllBoxes:
ld a, [wNumInBox] ld a, [wNumInBox]
ld [hl], a ld [hl], a
xor a
ld [wHaltAudio], a
ret ret
GetMonCountsForBoxesInBank: GetMonCountsForBoxesInBank:
@ -637,9 +604,6 @@ SAVCheckRandomID:
; checks if Sav file is the same by checking player's name 1st letter ; checks if Sav file is the same by checking player's name 1st letter
; and the two random numbers generated at game beginning ; and the two random numbers generated at game beginning
; (which are stored at wPlayerID)s ; (which are stored at wPlayerID)s
ld a, 1
ld [wHaltAudio], a
ld a, $0a ld a, $0a
ld [MBC1SRamEnable], a ld [MBC1SRamEnable], a
ld a, $01 ld a, $01
@ -668,9 +632,6 @@ SAVCheckRandomID:
ld a, $00 ld a, $00
ld [MBC1SRamBankingMode], a ld [MBC1SRamBankingMode], a
ld [MBC1SRamEnable], a ld [MBC1SRamEnable], a
xor a
ld [wHaltAudio], a
ret ret
SaveHallOfFameTeams: SaveHallOfFameTeams:
@ -709,9 +670,6 @@ LoadHallOfFameTeams:
; fallthrough ; fallthrough
HallOfFame_Copy: HallOfFame_Copy:
ld a, 1
ld [wHaltAudio], a
ld a, SRAM_ENABLE ld a, SRAM_ENABLE
ld [MBC1SRamEnable], a ld [MBC1SRamEnable], a
ld a, $1 ld a, $1
@ -722,15 +680,9 @@ HallOfFame_Copy:
xor a xor a
ld [MBC1SRamBankingMode], a ld [MBC1SRamBankingMode], a
ld [MBC1SRamEnable], a ld [MBC1SRamEnable], a
xor a
ld [wHaltAudio], a
ret ret
ClearSAV: ClearSAV:
ld a, 1
ld [wHaltAudio], a
ld a, SRAM_ENABLE ld a, SRAM_ENABLE
ld [MBC1SRamEnable], a ld [MBC1SRamEnable], a
ld a, $1 ld a, $1
@ -746,9 +698,6 @@ ClearSAV:
xor a xor a
ld [MBC1SRamBankingMode], a ld [MBC1SRamBankingMode], a
ld [MBC1SRamEnable], a ld [MBC1SRamEnable], a
xor a
ld [wHaltAudio], a
ret ret
PadSRAM_FF: PadSRAM_FF:

View file

@ -8,7 +8,7 @@ EvolveMon:
push af push af
xor a xor a
ld [wLowHealthAlarm], a ld [wLowHealthAlarm], a
ld [wChannelSoundIDs + Ch5], a ; ld [wChannelSoundIDs + Ch5], a
dec a ; SFX_STOP_ALL_MUSIC dec a ; SFX_STOP_ALL_MUSIC
ld [wNewSoundID], a ld [wNewSoundID], a
call PlaySound call PlaySound

View file

@ -32,10 +32,10 @@ ShakeElevator::
ld c, 0 ; BANK(SFX_Safari_Zone_PA) ld c, 0 ; BANK(SFX_Safari_Zone_PA)
ld a, SFX_SAFARI_ZONE_PA ld a, SFX_SAFARI_ZONE_PA
call PlaySound call PlaySound
.musicLoop ;.musicLoop
ld a, [wChannelSoundIDs + Ch5] ; ld a, [wChannelSoundIDs + Ch5]
cp SFX_SAFARI_ZONE_PA ; cp SFX_SAFARI_ZONE_PA
jr z, .musicLoop ; jr z, .musicLoop
call UpdateSprites call UpdateSprites
jp PlayDefaultMusic jp PlayDefaultMusic

View file

@ -411,7 +411,7 @@ SlotMachine_CheckForMatches:
call PrintText call PrintText
.done .done
xor a xor a
ld [wMuteAudioAndPauseMusic], a ; ld [wMuteAudioAndPauseMusic], a
ret ret
.rollWheel3DownByOneSymbol .rollWheel3DownByOneSymbol
call SlotMachine_AnimWheel3 call SlotMachine_AnimWheel3
@ -655,7 +655,7 @@ SlotMachine_PrintPayoutCoins:
SlotMachine_PayCoinsToPlayer: SlotMachine_PayCoinsToPlayer:
ld a, $1 ld a, $1
ld [wMuteAudioAndPauseMusic], a ; ld [wMuteAudioAndPauseMusic], a
call WaitForSoundToFinish call WaitForSoundToFinish
; Put 1 in the temp coins variable. This value is added to the player's coins ; Put 1 in the temp coins variable. This value is added to the player's coins

View file

@ -92,22 +92,12 @@ PlaySound::
pop de pop de
ret ret
OpenSRAMForSound::
ld a, SRAM_ENABLE
ld [MBC1SRamEnable], a
xor a
ld [MBC1SRamBankingMode], a
ld [MBC1SRamBank], a
ret
;InitSound:: ;InitSound::
; push hl ; push hl
; push de ; push de
; push bc ; push bc
; push af ; push af
; ;
; call OpenSRAMForSound
;
; ldh a, [hLoadedROMBank] ; ldh a, [hLoadedROMBank]
; push af ; push af
; ld a, BANK(_InitSound) ; ld a, BANK(_InitSound)
@ -132,10 +122,6 @@ UpdateSound::
; push bc ; push bc
; push af ; push af
ld a, [wHaltAudio]
and a
ret nz
ldh a, [hLoadedROMBank] ldh a, [hLoadedROMBank]
push af push af
ld a, BANK(_UpdateSound) ld a, BANK(_UpdateSound)

View file

@ -126,8 +126,6 @@ ClearVram::
StopAllSounds:: StopAllSounds::
call OpenSRAMForSound
ld a, 0 ; BANK("Audio Engine 1") ld a, 0 ; BANK("Audio Engine 1")
ld [wAudioROMBank], a ld [wAudioROMBank], a
ld [wAudioSavedROMBank], a ld [wAudioSavedROMBank], a

View file

@ -95,3 +95,47 @@ spritestatedata2: MACRO
ds 1 ds 1
\1End:: \1End::
ENDM ENDM
channel_struct: MACRO
\1MusicID:: dw
\1MusicBank:: db
\1Flags1:: db ; 0:on/off 1:subroutine 2:looping 3:sfx 4:noise 5:rest
\1Flags2:: db ; 0:vibrato on/off 1:pitch slide 2:duty cycle pattern 4:pitch offset
\1Flags3:: db ; 0:vibrato up/down 1:pitch slide direction
\1MusicAddress:: dw
\1LastMusicAddress:: dw
dw
\1NoteFlags:: db ; 5:rest
\1Condition:: db ; conditional jumps
\1DutyCycle:: db ; bits 6-7 (0:12.5% 1:25% 2:50% 3:75%)
\1VolumeEnvelope:: db ; hi:volume lo:fade
\1Frequency:: dw ; 11 bits
\1Pitch:: db ; 0:rest 1-c:note
\1Octave:: db ; 7-0 (0 is highest)
\1Transposition:: db ; raises existing octaves (to repeat phrases)
\1NoteDuration:: db ; frames remaining for the current note
\1Field16:: ds 1
ds 1
\1LoopCount:: db
\1Tempo:: dw
\1Tracks:: db ; hi:left lo:right
\1DutyCyclePattern:: db
\1VibratoDelayCount:: db ; initialized by \1VibratoDelay
\1VibratoDelay:: db ; number of frames a note plays until vibrato starts
\1VibratoExtent:: db
\1VibratoRate:: db ; hi:frames for each alt lo:frames to the next alt
\1PitchSlideTarget:: dw ; frequency endpoint for pitch slide
\1PitchSlideAmount:: db
\1PitchSlideAmountFraction:: db
\1Field25:: db
ds 1
\1PitchOffset:: dw
\1Field29:: ds 1
\1Field2a:: ds 2
\1Field2c:: ds 1
\1NoteLength:: db ; frames per 16th note
\1Field2e:: ds 1
\1Field2f:: ds 1
\1Field30:: ds 1
ds 1
ENDM

401
wram.asm
View file

@ -8,130 +8,6 @@ INCLUDE "vram.asm"
SECTION "WRAM", WRAM0 SECTION "WRAM", WRAM0
wUnusedC000::
ds 1
wSoundID::
ds 1
wMuteAudioAndPauseMusic::
; bit 7: whether sound has been muted
; all bits: whether the effective is active
; Store 1 to activate effect (any value in the range [1, 127] works).
; All audio is muted and music is paused. Sfx continues playing until it
; ends normally.
; Store 0 to resume music.
ds 1
wDisableChannelOutputWhenSfxEnds::
ds 1
wStereoPanning::
ds 1
wSavedVolume::
ds 1
wChannelCommandPointers::
ds 16
wChannelReturnAddresses::
ds 16
wChannelSoundIDs::
ds 8
wChannelFlags1::
ds 8
wChannelFlags2::
ds 8
wChannelDutyCycles::
ds 8
wChannelDutyCyclePatterns::
ds 8
wChannelVibratoDelayCounters::
; reloaded at the beginning of a note. counts down until the vibrato begins.
ds 8
wChannelVibratoExtents::
ds 8
wChannelVibratoRates::
; high nybble is rate (counter reload value) and low nybble is counter.
; time between applications of vibrato.
ds 8
wChannelFrequencyLowBytes::
ds 8
wChannelVibratoDelayCounterReloadValues::
; delay of the beginning of the vibrato from the start of the note
ds 8
wChannelPitchSlideLengthModifiers::
ds 8
wChannelPitchSlideFrequencySteps::
ds 8
wChannelPitchSlideFrequencyStepsFractionalPart::
ds 8
wChannelPitchSlideCurrentFrequencyFractionalPart::
ds 8
wChannelPitchSlideCurrentFrequencyHighBytes::
ds 8
wChannelPitchSlideCurrentFrequencyLowBytes::
ds 8
wChannelPitchSlideTargetFrequencyHighBytes::
ds 8
wChannelPitchSlideTargetFrequencyLowBytes::
ds 8
wChannelNoteDelayCounters::
; Note delays are stored as 16-bit fixed-point numbers where the integer part
; is 8 bits and the fractional part is 8 bits.
ds 8
wChannelLoopCounters::
ds 8
wChannelNoteSpeeds::
ds 8
wChannelNoteDelayCountersFractionalPart::
ds 8
wChannelOctaves::
ds 8
wChannelVolumes::
; also includes fade for hardware channels that support it
ds 8
wMusicWaveInstrument::
ds 1
wSfxWaveInstrument::
ds 1
wMusicTempo::
ds 2
wSfxTempo::
ds 2
wSfxHeaderPointer::
ds 2
wNewSoundID:: wNewSoundID::
ds 1 ds 1
@ -147,11 +23,112 @@ wFrequencyModifier::
wTempoModifier:: wTempoModifier::
ds 1 ds 1
ds 11
wHaltAudio:: ds 1
wSFXDontWait:: ds 1 wSFXDontWait:: ds 1
wMusic::
; nonzero if playing
wMusicPlaying:: db
wAudio::
wChannel1:: channel_struct wChannel1
wChannel2:: channel_struct wChannel2
wChannel3:: channel_struct wChannel3
wChannel4:: channel_struct wChannel4
ds 1
wCurTrackDuty:: db
wCurTrackVolumeEnvelope:: db
wCurTrackFrequency:: dw
wUnusedBCDNumber:: db ; BCD value, dummied out
wCurNoteDuration:: db ; used in MusicE0 and LoadNote
wCurMusicByte:: db
wCurChannel:: db
wVolume::
; corresponds to rNR50
; Channel control / ON-OFF / Volume (R/W)
; bit 7 - Vin->SO2 ON/OFF
; bit 6-4 - SO2 output level (volume) (# 0-7)
; bit 3 - Vin->SO1 ON/OFF
; bit 2-0 - SO1 output level (volume) (# 0-7)
db
wSoundOutput::
; corresponds to rNR51
; bit 4-7: ch1-4 so2 on/off
; bit 0-3: ch1-4 so1 on/off
db
wPitchSweep::
; corresponds to rNR10
; bit 7: unused
; bit 4-6: sweep time
; bit 3: sweep direction
; but 0-2: sweep shift
db
wMusicID:: dw
wMusicBank:: db
wNoiseSampleAddress:: dw
wNoiseSampleDelay:: db
ds 1
wMusicNoiseSampleSet:: db
wSFXNoiseSampleSet:: db
wLowHealthAlarm::
; bit 7: on/off
; bit 4: pitch
; bit 0-3: counter
db
wMusicFade::
; fades volume over x frames
; bit 7: fade in/out
; bit 0-5: number of frames for each volume level
; $00 = none (default)
db
wMusicFadeCount:: db
wMusicFadeID:: dw
ds 5
wCryPitch:: dw
wCryLength:: dw
wLastVolume:: db
wUnusedMusicF9Flag:: db
wSFXPriority::
; if nonzero, turn off music when playing sfx
db
ds 1
wChannel1JumpCondition:: db
wChannel2JumpCondition:: db
wChannel3JumpCondition:: db
wChannel4JumpCondition:: db
wStereoPanningMask:: db
wCryTracks::
; plays only in left or right track depending on what side the monster is on
; both tracks active outside of battle
db
wSFXDuration:: db
wCurSFX::
; id of sfx currently playing
db
wAudioEnd::
wMapMusic:: db
;wDontPlayMapMusicOnReload:: db
wMusicEnd::
SECTION "Sprite State Data", WRAM0 SECTION "Sprite State Data", WRAM0
wSpriteDataStart:: wSpriteDataStart::
@ -2485,7 +2462,12 @@ wDestinationWarpID::
; if $ff, the player's coordinates are not updated when entering the map ; if $ff, the player's coordinates are not updated when entering the map
ds 1 ds 1
UNION
ds 128 ds 128
NEXTU
wChannel5:: channel_struct wChannel5
wChannel6:: channel_struct wChannel6
ENDU
wNumSigns:: wNumSigns::
; number of signs in the current map (up to 16) ; number of signs in the current map (up to 16)
@ -2609,7 +2591,7 @@ wMissableObjectList::
ds 17 * 2 ds 17 * 2
wGameProgressFlags:: wGameProgressFlags::
; $c8 bytes ; $80 bytes
wOaksLabCurScript:: wOaksLabCurScript::
ds 1 ds 1
wPalletTownCurScript:: wPalletTownCurScript::
@ -2819,10 +2801,15 @@ wSeafoamIslandsB4FCurScript::
wRoute18Gate1FCurScript:: wRoute18Gate1FCurScript::
ds 1 ds 1
ds 78 ds 6
wGameProgressFlagsEnd:: wGameProgressFlagsEnd::
ds 56 UNION
ds 128
NEXTU
wChannel7:: channel_struct wChannel7
wChannel8:: channel_struct wChannel8
ENDU
wObtainedHiddenItemsFlags:: wObtainedHiddenItemsFlags::
ds 14 ds 14
@ -3152,157 +3139,3 @@ wStack::
INCLUDE "sram.asm" INCLUDE "sram.asm"
INCLUDE "hram.asm" INCLUDE "hram.asm"
SECTION "crysaudio", SRAM, BANK[0]
channel_struct: MACRO
\1MusicID:: dw
\1MusicBank:: db
\1Flags1:: db ; 0:on/off 1:subroutine 2:looping 3:sfx 4:noise 5:rest
\1Flags2:: db ; 0:vibrato on/off 1:pitch slide 2:duty cycle pattern 4:pitch offset
\1Flags3:: db ; 0:vibrato up/down 1:pitch slide direction
\1MusicAddress:: dw
\1LastMusicAddress:: dw
dw
\1NoteFlags:: db ; 5:rest
\1Condition:: db ; conditional jumps
\1DutyCycle:: db ; bits 6-7 (0:12.5% 1:25% 2:50% 3:75%)
\1VolumeEnvelope:: db ; hi:volume lo:fade
\1Frequency:: dw ; 11 bits
\1Pitch:: db ; 0:rest 1-c:note
\1Octave:: db ; 7-0 (0 is highest)
\1Transposition:: db ; raises existing octaves (to repeat phrases)
\1NoteDuration:: db ; frames remaining for the current note
\1Field16:: ds 1
ds 1
\1LoopCount:: db
\1Tempo:: dw
\1Tracks:: db ; hi:left lo:right
\1DutyCyclePattern:: db
\1VibratoDelayCount:: db ; initialized by \1VibratoDelay
\1VibratoDelay:: db ; number of frames a note plays until vibrato starts
\1VibratoExtent:: db
\1VibratoRate:: db ; hi:frames for each alt lo:frames to the next alt
\1PitchSlideTarget:: dw ; frequency endpoint for pitch slide
\1PitchSlideAmount:: db
\1PitchSlideAmountFraction:: db
\1Field25:: db
ds 1
\1PitchOffset:: dw
\1Field29:: ds 1
\1Field2a:: ds 2
\1Field2c:: ds 1
\1NoteLength:: db ; frames per 16th note
\1Field2e:: ds 1
\1Field2f:: ds 1
\1Field30:: ds 1
ds 1
ENDM
wMusic::
; nonzero if playing
wMusicPlaying:: db
wAudio::
wChannel1:: channel_struct wChannel1
wChannel2:: channel_struct wChannel2
wChannel3:: channel_struct wChannel3
wChannel4:: channel_struct wChannel4
wChannel5:: channel_struct wChannel5
wChannel6:: channel_struct wChannel6
wChannel7:: channel_struct wChannel7
wChannel8:: channel_struct wChannel8
ds 1
wCurTrackDuty:: db
wCurTrackVolumeEnvelope:: db
wCurTrackFrequency:: dw
wUnusedBCDNumber:: db ; BCD value, dummied out
wCurNoteDuration:: db ; used in MusicE0 and LoadNote
wCurMusicByte:: db
wCurChannel:: db
wVolume::
; corresponds to rNR50
; Channel control / ON-OFF / Volume (R/W)
; bit 7 - Vin->SO2 ON/OFF
; bit 6-4 - SO2 output level (volume) (# 0-7)
; bit 3 - Vin->SO1 ON/OFF
; bit 2-0 - SO1 output level (volume) (# 0-7)
db
wSoundOutput::
; corresponds to rNR51
; bit 4-7: ch1-4 so2 on/off
; bit 0-3: ch1-4 so1 on/off
db
wPitchSweep::
; corresponds to rNR10
; bit 7: unused
; bit 4-6: sweep time
; bit 3: sweep direction
; but 0-2: sweep shift
db
wMusicID:: dw
wMusicBank:: db
wNoiseSampleAddress:: dw
wNoiseSampleDelay:: db
ds 1
wMusicNoiseSampleSet:: db
wSFXNoiseSampleSet:: db
wLowHealthAlarm::
; bit 7: on/off
; bit 4: pitch
; bit 0-3: counter
db
wMusicFade::
; fades volume over x frames
; bit 7: fade in/out
; bit 0-5: number of frames for each volume level
; $00 = none (default)
db
wMusicFadeCount:: db
wMusicFadeID:: dw
ds 5
wCryPitch:: dw
wCryLength:: dw
wLastVolume:: db
wUnusedMusicF9Flag:: db
wSFXPriority::
; if nonzero, turn off music when playing sfx
db
ds 1
wChannel1JumpCondition:: db
wChannel2JumpCondition:: db
wChannel3JumpCondition:: db
wChannel4JumpCondition:: db
wStereoPanningMask:: db
wCryTracks::
; plays only in left or right track depending on what side the monster is on
; both tracks active outside of battle
db
wSFXDuration:: db
wCurSFX::
; id of sfx currently playing
db
wAudioEnd::
wMapMusic:: db
;wDontPlayMapMusicOnReload:: db
wMusicEnd::