-
Notifications
You must be signed in to change notification settings - Fork 1k
Sound Test in Debug Menu
sabra55 edited this page Jan 23, 2024
·
4 revisions
Code by Cram-o-Dev (in Cramorant Version)
Edited a bit to disable SFX_PRESS_AB
when selecting music, reset cursor position and put the Sound Test in the Debug Menu, rather than the overworld like Pokémon Cramorant Ver.
; item ids
...
...
const MAX_ELIXER ; $53
DEF NUM_ITEMS EQU const_value - 1
; elevator floors use item IDs
const FLOOR_B2F ; $54
const FLOOR_B1F ; $55
const FLOOR_1F ; $56
const FLOOR_2F ; $57
const FLOOR_3F ; $58
const FLOOR_4F ; $59
const FLOOR_5F ; $5A
const FLOOR_6F ; $5B
const FLOOR_7F ; $5C
const FLOOR_8F ; $5D
const FLOOR_9F ; $5E
const FLOOR_10F ; $5F
const FLOOR_11F ; $60
const FLOOR_B4F ; $61
+
+; for sound test
+ const PALLET_TOWN_M ; $62
+ const POKECENTER_MS ; $63
+ const GYM_MUSIC_PLA ; $64
DEF NUM_FLOORS EQU const_value - 1 - NUM_ITEMS
const_next $C4
; HMs are defined before TMs, so the actual number of TM definitions
...
ItemNames::
...
...
li "MAX ELIXER"
assert_list_length NUM_ITEMS
li "B2F"
li "B1F"
li "1F"
li "2F"
li "3F"
li "4F"
li "5F"
li "6F"
li "7F"
li "8F"
li "9F"
li "10F"
li "11F"
li "B4F"
+ li "PALLET TOWN"
+ li "# CENTER"
+ li "GYM MUSIC"
assert_list_length NUM_ITEMS + NUM_FLOORS
ItemPrices::
table_width 3, ItemPrices
...
...
bcd3 0 ; MAX_ELIXER
assert_table_length NUM_ITEMS
bcd3 0 ; FLOOR_B2F
bcd3 0 ; FLOOR_B1F
bcd3 0 ; FLOOR_1F
bcd3 0 ; FLOOR_2F
bcd3 0 ; FLOOR_3F
bcd3 0 ; FLOOR_4F
bcd3 0 ; FLOOR_5F
bcd3 0 ; FLOOR_6F
bcd3 0 ; FLOOR_7F
bcd3 0 ; FLOOR_8F
bcd3 0 ; FLOOR_9F
bcd3 0 ; FLOOR_10F
bcd3 0 ; FLOOR_11F
bcd3 0 ; FLOOR_B4F
+ bcd3 0 ; PALLET_TOWN_M
+ bcd3 0 ; POKECENTER_MS
+ bcd3 0 ; GYM_MUSIC_PLA
assert_table_length NUM_ITEMS + NUM_FLOORS
...
_DreamWasEatenText::
text "<TARGET>'s"
line "dream was eaten!"
prompt
_TradeCenterOpponentText::
text "!"
done
_ColosseumOpponentText::
text "!"
done
+_CDPowerOn::
+ text "Powering on..."
+ prompt
+_CDSelectTrack::
+ text "Please select a"
+ line "track."
+ done
+_CDNowPlaying::
+ text "Now playing..."
+ prompt
+_CDPowerOff::
+ text "Powering off..."
+ prompt
DebugMenu:
IF DEF(_DEBUG)
call ClearScreen
+; enable SFX_PRESS_AB again
+ ld hl, wFlags_0xcd60
+ res 5, [hl]
; These debug names are used for TestBattle.
; StartNewGameDebug uses the debug names from PrepareOakSpeech.
ld hl, DebugBattlePlayerName
ld de, wPlayerName
ld bc, NAME_LENGTH
call CopyData
ld hl, DebugBattleRivalName
ld de, wRivalName
ld bc, NAME_LENGTH
call CopyData
call LoadFontTilePatterns
call LoadHpBarAndStatusTilePatterns
call ClearSprites
call RunDefaultPaletteCommand
- hlcoord 5, 6
- ld b, 3
- ld c, 9
+ hlcoord 4, 6
+ lb bc, 5, 10
call TextBoxBorder
- hlcoord 7, 7
+ hlcoord 6, 7
ld de, DebugMenuOptions
call PlaceString
ld a, TEXT_DELAY_MEDIUM
ld [wOptions], a
ld a, A_BUTTON | B_BUTTON | START
ld [wMenuWatchedKeys], a
xor a
ld [wMenuJoypadPollCount], a
- inc a
+ ld a, 2
ld [wMaxMenuItem], a
ld a, 7
ld [wTopMenuItemY], a
- dec a
+ ld a, 5
ld [wTopMenuItemX], a
xor a
ld [wCurrentMenuItem], a
ld [wLastMenuItem], a
ld [wMenuWatchMovingOutOfBounds], a
call HandleMenuInput
bit BIT_B_BUTTON, a
jp nz, DisplayTitleScreen
ld a, [wCurrentMenuItem]
- and a ; FIGHT?
+ and a ; first option? (FIGHT)
jp z, TestBattle
+ cp 1 ; second option? (DEBUG)
+ jp z, DebugModeOption
+ jp SoundTestDebugMenu ; last option? (SOUNDTEST)
- ; DEBUG
+DebugModeOption:
ld hl, wd732
set BIT_DEBUG_MODE, [hl]
jp StartNewGameDebug
DebugBattlePlayerName:
db "Tom@"
DebugBattleRivalName:
db "Juerry@"
DebugMenuOptions:
db "FIGHT"
- next "DEBUG@"
+ next "DEBUG"
+ next "SOUNDTEST@"
ELSE
ret
ENDC
TestBattle: ; unreferenced except in _DEBUG
.loop
call GBPalNormal
; Don't mess around with obedience.
ld a, 1 << BIT_EARTHBADGE
ld [wObtainedBadges], a
ld hl, wFlags_D733
set BIT_TEST_BATTLE, [hl]
; wNumBagItems and wBagItems are not initialized here,
; and their garbage values happen to act as if EXP_ALL
; is in the bag at the end of the test battle.
; pokeyellow fixes this by initializing them with a
; list of items.
; Reset the party.
ld hl, wPartyCount
xor a
ld [hli], a
dec a
ld [hl], a
; Give the player a level 20 Rhydon.
ld a, RHYDON
ld [wcf91], a
ld a, 20
ld [wCurEnemyLVL], a
xor a
ld [wMonDataLocation], a
ld [wCurMap], a
call AddPartyMon
; Fight against a level 20 Rhydon.
ld a, RHYDON
ld [wCurOpponent], a
predef InitOpponent
; When the battle ends, do it all again.
; There are some graphical quirks in SGB mode.
ld a, 1
ld [wUpdateSpritesEnabled], a
ldh [hAutoBGTransferEnabled], a
jr .loop
+SoundTestDebugMenu:
+; don't play SFX_PRESS_AB when A or B is pressed in menu
+ ld hl, wFlags_0xcd60
+ bit 5, [hl]
+ set 5, [hl]
; yellow
+ call StopAllMusic
; green/red/blue
+ ld a, SFX_STOP_ALL_MUSIC
+ ld [wNewSoundID], a
+ call PlaySound
+; reset cursor position
+ xor a
+ ld [wCurrentMenuItem], a
+ ld [wListScrollOffset], a
+ ld hl, CDPowerOn
+ call PrintText
+.playmusic
+ ld hl, CDSelectTrack
+ call PrintText
+ hlcoord 5, 1
+ ld de, SoundTestText
+ call PlaceString
+ ld hl, MusicItemList
+ call LoadItemList
+ ld hl, wItemList
+ ld a, l
+ ld [wListPointer], a
+ ld a, h
+ ld [wListPointer + 1], a
+ xor a
+ ld [wPrintItemPrices], a
+ ld [wMenuItemToSwap], a
+ ld a, SPECIALLISTMENU
+ ld [wListMenuID], a
+ call DisplayListMenuID
+ jr c, .asm_74e60
+ ld hl, CDTextPointers
+ ld a, [wcf91]
+ sub PALLET_TOWN_M ; first option for sound_test in item_constants
+ add a
+ ld d, $0
+ ld e, a
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ call PrintText
+ jr .playmusic
+.asm_74e60
+ xor a
+ ld [wListScrollOffset], a
+ ld hl, CDPowerOff
+ call PrintText
+ jp DebugMenu
+CDPowerOn:
+ text_far _CDPowerOn
+ text_end
+CDSelectTrack:
+ text_far _CDSelectTrack
+ text_end
+CDPowerOff:
+ text_far _CDPowerOff
+ text_end
+CDNowPlaying:
+ text_far _CDNowPlaying
+ text_end
+SoundTestText:
+ db "SOUND TEST@"
+MusicItemList:
+ db 3 ; tracks number
+ db PALLET_TOWN_M
+ db POKECENTER_MS
+ db GYM_MUSIC_PLA
+ db -1 ; end
+CDTextPointers:
+ dw PalletTownMusicCdPlayer
+ dw PokecenterMusicCdPlayer
+ dw GymMusicCdPlayer
; pokered (vanilla)
+PalletTownMusicCdPlayer:
+ text_asm
+ ld c, BANK(Music_PalletTown)
+ ld a, MUSIC_PALLET_TOWN
+ call PlayMusic
+ ld hl, CDNowPlaying
+ call PrintText
+ jp TextScriptEnd
+PokecenterMusicCdPlayer:
+ text_asm
+ ld c, BANK(Music_Pokecenter)
+ ld a, MUSIC_POKECENTER
+ call PlayMusic
+ ld hl, CDNowPlaying
+ call PrintText
+ jp TextScriptEnd
+GymMusicCdPlayer:
+ text_asm
+ ld c, BANK(Music_Gym)
+ ld a, MUSIC_GYM
+ call PlayMusic
+ ld hl, CDNowPlaying
+ call PrintText
+ jp TextScriptEnd
; pokered_crysaudio
+PalletTownMusicCdPlayer:
+ text_asm
+ ld c, 0
+ ld a, MUSIC_PALLET_TOWN
+ call PlayMusic
+ ld hl, CDNowPlaying
+ call PrintText
+ jp TextScriptEnd
+PokecenterMusicCdPlayer:
+ text_asm
+ ld c, 0
+ ld a, MUSIC_POKECENTER
+ call PlayMusic
+ ld hl, CDNowPlaying
+ call PrintText
+ jp TextScriptEnd
+GymMusicCdPlayer:
+ text_asm
+ ld c, 0
+ ld a, MUSIC_GYM
+ call PlayMusic
+ ld hl, CDNowPlaying
+ call PrintText
+ jp TextScriptEnd
Any ITEM_LIST
is held by wItemList
, included that music list.
...
wGymCityName:: ds 17
wGymLeaderName:: ds NAME_LENGTH
-wItemList:: ds 16
wListPointer:: dw
; used to store pointers, but never read
wUnusedCF8D:: dw
wItemPrices:: dw
wcf91:: db ; used with a lot of things (too much to list here)
; which pokemon you selected
wWhichPokemon:: db
; if non-zero, then print item prices when displaying lists
wPrintItemPrices:: db
; type of HP bar
; $00 = enemy HUD in battle
...
So, in vanilla, this soundtrack can hold 16 musics...
Increasing wItemList
:
...
wGymCityName:: ds 17
wGymLeaderName:: ds NAME_LENGTH
-wItemList:: ds 16
+ ds 16
wListPointer:: dw
; used to store pointers, but never read
wUnusedCF8D:: dw
wItemPrices:: dw
wcf91:: db ; used with a lot of things (too much to list here)
; which pokemon you selected
wWhichPokemon:: db
; if non-zero, then print item prices when displaying lists
wPrintItemPrices:: db
; type of HP bar
; $00 = enemy HUD in battle
...
...
; current map warp entries
wWarpEntries:: ds 32 * 4 ; Y, X, warp ID, map ID
; if $ff, the player's coordinates are not updated when entering the map
wDestinationWarpID:: db
- ds 128
+wItemList:: ds 128
; number of signs in the current map (up to 16)
wNumSigns:: db
wSignCoords:: ds 16 * 2 ; Y, X
wSignTextIDs:: ds 16
; number of sprites on the current map (up to 16)
wNumSprites:: db
...