shithub: pokecrystal

Download patch

ref: a2b6befd7d12b2ad8bb97979a10519500dcdd870
parent: 7991db972b5892c36a7b004404c16f28f6b65bad
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Fri Oct 23 12:04:15 EDT 2020

Identify some more labels, mostly WRAM

--- a/engine/debug/color_picker.asm
+++ b/engine/debug/color_picker.asm
@@ -58,8 +58,8 @@
 
 	xor a ; DEBUGCOLORMAIN_INITSCREEN
 	ld [wJumptableIndex], a
-	ld [wcf66], a
-	ld [wd003], a
+	ld [wDebugColorCurMon], a
+	ld [wDebugColorIsShiny], a
 .loop
 	ld a, [wJumptableIndex]
 	bit 7, a
@@ -75,7 +75,7 @@
 	ret
 
 DebugColor_InitMonOrTrainerColor:
-	ld a, [wd002]
+	ld a, [wDebugColorIsTrainer]
 	and a
 	jr nz, DebugColor_InitTrainerColor
 	ld hl, PokemonPalettes
@@ -82,7 +82,7 @@
 	; fallthrough
 
 DebugColor_InitMonColor:
-	ld de, wOverworldMapBlocks
+	ld de, wDebugOriginalColors
 	ld c, NUM_POKEMON + 1
 .loop
 	push bc
@@ -98,7 +98,7 @@
 
 DebugColor_InitTrainerColor:
 	ld hl, TrainerPalettes
-	ld de, wOverworldMapBlocks
+	ld de, wDebugOriginalColors
 	ld c, NUM_TRAINER_CLASSES
 .loop
 	push bc
@@ -113,28 +113,17 @@
 	ret
 
 DebugColor_InitColor:
+rept 3
 	ld a, BANK(PokemonPalettes) ; aka BANK(TrainerPalettes)
 	call GetFarByte
 	ld [de], a
 	inc de
 	inc hl
-
+endr
 	ld a, BANK(PokemonPalettes) ; aka BANK(TrainerPalettes)
 	call GetFarByte
 	ld [de], a
 	inc de
-	inc hl
-
-	ld a, BANK(PokemonPalettes) ; aka BANK(TrainerPalettes)
-	call GetFarByte
-	ld [de], a
-	inc de
-	inc hl
-
-	ld a, BANK(PokemonPalettes) ; aka BANK(TrainerPalettes)
-	call GetFarByte
-	ld [de], a
-	inc de
 	ret
 
 DebugColor_InitVRAM:
@@ -225,14 +214,14 @@
 	dec c
 	jr nz, .ob_loop
 
-	ld a, $94
-	ld [wc608], a
-	ld a, $52
-	ld [wc608 + 1], a
-	ld a, $4a
-	ld [wc608 + 2], a
-	ld a, $29
-	ld [wc608 + 3], a
+	ld a, LOW(palred 20 + palgreen 20 + palblue 20)
+	ld [wDebugLightColor + 0], a
+	ld a, HIGH(palred 20 + palgreen 20 + palblue 20)
+	ld [wDebugLightColor + 1], a
+	ld a, LOW(palred 10 + palgreen 10 + palblue 10)
+	ld [wDebugDarkColor + 0], a
+	ld a, HIGH(palred 10 + palgreen 10 + palblue 10)
+	ld [wDebugDarkColor + 1], a
 
 	pop af
 	ldh [rSVBK], a
@@ -264,7 +253,7 @@
 	call DebugColor_BackupSpriteColors
 	call .SetMaxNum
 	ld e, a
-	ld a, [wcf66]
+	ld a, [wDebugColorCurMon]
 	inc a
 	cp e
 	jr c, .SwitchMon
@@ -273,7 +262,7 @@
 
 .PreviousMon:
 	call DebugColor_BackupSpriteColors
-	ld a, [wcf66]
+	ld a, [wDebugColorCurMon]
 	dec a
 	cp -1
 	jr nz, .SwitchMon
@@ -281,7 +270,7 @@
 	dec a
 
 .SwitchMon:
-	ld [wcf66], a
+	ld [wDebugColorCurMon], a
 	ld a, DEBUGCOLORMAIN_INITSCREEN
 	ld [wJumptableIndex], a
 	ret
@@ -288,7 +277,7 @@
 
 .SetMaxNum:
 ; Looping back around the pic set.
-	ld a, [wd002]
+	ld a, [wDebugColorIsTrainer]
 	and a
 	jr nz, .trainer
 ; mon
@@ -328,7 +317,7 @@
 	call DebugColor_FillBoxWithByte
 	call DebugColor_LoadRGBMeter
 	call DebugColor_SetRGBMeter
-	ld a, [wcf66]
+	ld a, [wDebugColorCurMon]
 	inc a
 	ld [wCurPartySpecies], a
 	ld [wDeciramBuffer], a
@@ -336,7 +325,7 @@
 	ld de, wDeciramBuffer
 	lb bc, PRINTNUM_LEADINGZEROS | 1, 3
 	call PrintNum
-	ld a, [wd002]
+	ld a, [wDebugColorIsTrainer]
 	and a
 	jr nz, .trainer
 
@@ -358,7 +347,7 @@
 	lb bc, 6, 6
 	predef PlaceGraphic
 
-	ld a, [wd003]
+	ld a, [wDebugColorIsShiny]
 	and a
 	jr z, .normal
 ; shiny
@@ -431,21 +420,21 @@
 	ret
 
 DebugColor_SetRGBMeter:
-	ld a, [wcf66]
+	ld a, [wDebugColorCurMon]
 	inc a
 	ld l, a
 	ld h, 0
 	add hl, hl
 	add hl, hl
-	ld de, wOverworldMapBlocks
+	ld de, wDebugOriginalColors
 	add hl, de
-	ld de, wc608
+	ld de, wDebugMiddleColors
 	ld bc, 4
 	call CopyBytes
 	xor a
-	ld [wcf64], a
-	ld [wcf65], a
-	ld de, wc608
+	ld [wDebugColorRGBJumptableIndex], a
+	ld [wDebugColorCurColor], a
+	ld de, wDebugLightColor
 	call DebugColor_CalculateRGB
 	ret
 
@@ -479,15 +468,15 @@
 	ldh [rSVBK], a
 
 	ld hl, wBGPals2
-	ld de, wc608
+	ld de, wDebugMiddleColors
 	ld c, 1
 	call DebugColor_LoadPalettes_White_Col1_Col2_Black
 
 	hlcoord 10, 2
-	ld de, wc608
+	ld de, wDebugLightColor
 	call DebugColor_PrintHexColor
 	hlcoord 15, 2
-	ld de, wc608 + 2
+	ld de, wDebugDarkColor
 	call DebugColor_PrintHexColor
 
 	ld a, TRUE
@@ -508,13 +497,13 @@
 	ld [hli], a
 	ld a, HIGH(PALRGB_WHITE)
 	ld [hli], a
-	ld a, [wc608]
+	ld a, [wDebugLightColor + 0]
 	ld [hli], a
-	ld a, [wc608 + 1]
+	ld a, [wDebugLightColor + 1]
 	ld [hli], a
-	ld a, [wc608 + 2]
+	ld a, [wDebugDarkColor + 0]
 	ld [hli], a
-	ld a, [wc608 + 3]
+	ld a, [wDebugDarkColor + 1]
 	ld [hli], a
 	xor a
 	ld [hli], a
@@ -525,10 +514,10 @@
 	call DebugColor_PushSGBPals
 
 	hlcoord 10, 2
-	ld de, wc608
+	ld de, wDebugLightColor
 	call DebugColor_PrintHexColor
 	hlcoord 15, 2
-	ld de, wc608 + 2
+	ld de, wDebugDarkColor
 	call DebugColor_PrintHexColor
 
 	ld a, DEBUGCOLORMAIN_JOYPAD
@@ -563,7 +552,7 @@
 	and A_BUTTON
 	jr nz, .toggle_shiny
 
-	ld a, [wcf64]
+	ld a, [wDebugColorRGBJumptableIndex]
 	maskbits 4 ; .PointerTable length
 	ld e, a
 	ld d, 0
@@ -583,13 +572,13 @@
 
 .toggle_shiny
 ; Toggle between the normal and shiny mon colors.
-	ld a, [wd002]
+	ld a, [wDebugColorIsTrainer]
 	and a
 	ret nz
 
-	ld a, [wd003]
+	ld a, [wDebugColorIsShiny]
 	xor %00000100
-	ld [wd003], a
+	ld [wDebugColorIsShiny], a
 	ld c, a
 	ld b, 0
 	ld hl, PokemonPalettes
@@ -620,16 +609,16 @@
 	ret
 
 .light
-	xor a
-	ld [wcf65], a
-	ld de, wc608
+	xor a ; FALSE
+	ld [wDebugColorCurColor], a
+	ld de, wDebugLightColor
 	call DebugColor_CalculateRGB
 	ret
 
 .dark
 	ld a, TRUE
-	ld [wcf65], a
-	ld de, wc608 + 2
+	ld [wDebugColorCurColor], a
+	ld de, wDebugDarkColor
 	call DebugColor_CalculateRGB
 	ret
 
@@ -641,7 +630,7 @@
 	ld a, [hl]
 	and D_UP
 	jr nz, DebugColor_PreviousRGBColor
-	ld hl, wc608 + 10
+	ld hl, wDebugRedChannel
 	jr DebugColor_UpdateRGBColor
 
 DebugColor_ChangeGreenValue:
@@ -652,7 +641,7 @@
 	ld a, [hl]
 	and D_UP
 	jr nz, DebugColor_PreviousRGBColor
-	ld hl, wc608 + 11
+	ld hl, wDebugGreenChannel
 	jr DebugColor_UpdateRGBColor
 
 DebugColor_ChangeBlueValue:
@@ -660,7 +649,8 @@
 	ld a, [hl]
 	and D_UP
 	jr nz, DebugColor_PreviousRGBColor
-	ld hl, wc608 + 12
+	ld hl, wDebugBlueChannel
+	; fallthrough
 
 DebugColor_UpdateRGBColor:
 	ldh a, [hJoyLast]
@@ -691,12 +681,12 @@
 	ret
 
 DebugColor_PreviousRGBColor:
-	ld hl, wcf64
+	ld hl, wDebugColorRGBJumptableIndex
 	dec [hl]
 	ret
 
 DebugColor_NextRGBColor:
-	ld hl, wcf64
+	ld hl, wDebugColorRGBJumptableIndex
 	inc [hl]
 	ret
 
@@ -709,7 +699,7 @@
 	ld de, DebugColor_AreYouFinishedString
 	call PlaceString
 	xor a
-	ld [wd004], a
+	ld [wDebugColorCurTMHM], a
 	call DebugColor_PrintTMHMMove
 	ld a, DEBUGCOLORMAIN_TMHMJOYPAD
 	ld [wJumptableIndex], a
@@ -744,7 +734,7 @@
 	ret
 
 .up
-	ld a, [wd004]
+	ld a, [wDebugColorCurTMHM]
 	cp NUM_TM_HM_TUTOR - 1
 	jr z, .wrap_down
 	inc a
@@ -755,7 +745,7 @@
 	jr .done
 
 .down
-	ld a, [wd004]
+	ld a, [wDebugColorCurTMHM]
 	and a
 	jr z, .wrap_up
 	dec a
@@ -765,7 +755,7 @@
 	ld a, NUM_TM_HM_TUTOR - 1
 
 .done
-	ld [wd004], a
+	ld [wDebugColorCurTMHM], a
 	call DebugColor_PrintTMHMMove
 	ret
 
@@ -779,7 +769,7 @@
 	hlcoord 10, 14
 	call .ClearRow
 
-	ld a, [wd004]
+	ld a, [wDebugColorCurTMHM]
 	inc a
 	ld [wTempTMHM], a
 	predef GetTMHMMove
@@ -789,7 +779,7 @@
 	hlcoord 10, 12
 	call PlaceString
 
-	ld a, [wd004]
+	ld a, [wDebugColorCurTMHM]
 	call .GetNumberedTMHM
 	ld [wCurItem], a
 	predef CanLearnTMHMMove
@@ -826,48 +816,48 @@
 	ret
 
 DebugColor_CalculatePalette:
-	ld a, [wc608 + 10]
+	ld a, [wDebugRedChannel]
 	and %00011111
 	ld e, a
-	ld a, [wc608 + 11]
+	ld a, [wDebugGreenChannel]
 	and %00000111
 	sla a
 	swap a
 	or e
 	ld e, a
-	ld a, [wc608 + 11]
+	ld a, [wDebugGreenChannel]
 	and %00011000
 	sla a
 	swap a
 	ld d, a
-	ld a, [wc608 + 12]
+	ld a, [wDebugBlueChannel]
 	and %00011111
 	sla a
 	sla a
 	or d
 	ld d, a
-	ld a, [wcf65]
+	ld a, [wDebugColorCurColor]
 	and a
 	jr z, .light
 
 ; dark
 	ld a, e
-	ld [wc608 + 2], a
+	ld [wDebugDarkColor + 0], a
 	ld a, d
-	ld [wc608 + 3], a
+	ld [wDebugDarkColor + 1], a
 	ret
 
 .light
 	ld a, e
-	ld [wc608], a
+	ld [wDebugLightColor + 0], a
 	ld a, d
-	ld [wc608 + 1], a
+	ld [wDebugLightColor + 1], a
 	ret
 
 DebugColor_CalculateRGB:
 	ld a, [de]
 	and %00011111
-	ld [wc608 + 10], a
+	ld [wDebugRedChannel], a
 	ld a, [de]
 	and %11100000
 	swap a
@@ -879,26 +869,26 @@
 	swap a
 	srl a
 	or b
-	ld [wc608 + 11], a
+	ld [wDebugGreenChannel], a
 	ld a, [de]
 	and %01111100
 	srl a
 	srl a
-	ld [wc608 + 12], a
+	ld [wDebugBlueChannel], a
 	ret
 
 DebugColor_BackupSpriteColors:
-	ld a, [wcf66]
+	ld a, [wDebugColorCurMon]
 	inc a
 	ld l, a
 	ld h, 0
 	add hl, hl
 	add hl, hl
-	ld de, wOverworldMapBlocks ; MonPalette
+	ld de, wDebugOriginalColors
 	add hl, de
 	ld e, l
 	ld d, h
-	ld hl, wc608
+	ld hl, wDebugMiddleColors
 	ld bc, 4
 	call CopyBytes
 	ret
@@ -1013,7 +1003,7 @@
 	cp DEBUGCOLORMAIN_JOYPAD
 	jr nz, .clearsprites
 
-	ld a, [wcf64]
+	ld a, [wDebugColorRGBJumptableIndex]
 	and a
 	jr z, .place_cursor
 	dec a
@@ -1023,7 +1013,7 @@
 	ld [hl], "▶"
 
 .place_cursor
-	ld a, [wcf65]
+	ld a, [wDebugColorCurColor]
 	and a
 	jr z, .light
 ; dark
@@ -1037,11 +1027,11 @@
 	ld b, $70 ; initial tile id
 	ld c, 5 ; initial palette
 	ld hl, wVirtualOAM
-	ld de, wc608 + 10
+	ld de, wDebugRedChannel
 	call .placesprite
-	ld de, wc608 + 11
+	ld de, wDebugGreenChannel
 	call .placesprite
-	ld de, wc608 + 12
+	ld de, wDebugBlueChannel
 	call .placesprite
 	ret
 
@@ -1086,9 +1076,9 @@
 
 	xor a
 	ld [wJumptableIndex], a
-	ld [wcf64], a
-	ld [wcf65], a
-	ld [wcf66], a
+	ld [wDebugTilesetCurPalette], a
+	ld [wDebugTilesetRGBJumptableIndex], a
+	ld [wDebugTilesetCurColor], a
 	ldh [hMapAnims], a
 	call ClearSprites
 	call OverworldTextModeSwitch
@@ -1138,8 +1128,9 @@
 	call _DebugColor_DrawSwatch
 
 DebugColor_DrawAttributeSwatch:
-	ld a, [wcf64]
+	ld a, [wDebugTilesetCurPalette]
 	hlcoord 0, 0, wAttrmap
+	; fallthrough
 
 _DebugColor_DrawSwatch:
 ; Fills a 4x3 box at de with byte a.
@@ -1176,7 +1167,7 @@
 	ld a, BANK(wBGPals1)
 	ldh [rSVBK], a
 
-	ld a, [wcf64]
+	ld a, [wDebugTilesetCurPalette]
 	ld l, a
 	ld h, 0
 	add hl, hl
@@ -1184,10 +1175,10 @@
 	add hl, hl
 	ld de, wBGPals1
 	add hl, de
-	ld de, wc608
+	ld de, wDebugPalette
 	ld bc, 1 palettes
 	call CopyBytes
-	ld de, wc608
+	ld de, wDebugPalette
 	call DebugColor_CalculateRGB
 
 	pop af
@@ -1198,7 +1189,7 @@
 	ld hl, hJoyLast
 	ld a, [hl]
 	and SELECT
-	jr nz, .loop7
+	jr nz, .next_palette
 	ld a, [hl]
 	and B_BUTTON
 	jr nz, .cancel
@@ -1205,8 +1196,8 @@
 	call DebugTileset_Joypad
 	ret
 
-.loop7
-	ld hl, wcf64
+.next_palette
+	ld hl, wDebugTilesetCurPalette
 	ld a, [hl]
 	inc a
 	and PALETTE_MASK
@@ -1230,10 +1221,10 @@
 	ldh [rSVBK], a
 
 	ld hl, wBGPals2
-	ld a, [wcf64]
+	ld a, [wDebugTilesetCurPalette]
 	ld bc, 1 palettes
 	call AddNTimes
-	ld de, wc608
+	ld de, wDebugPalette
 	ld bc, 1 palettes
 	call CopyBytes
 
@@ -1262,26 +1253,26 @@
 	ldh [rSVBK], a
 
 	ld hl, wBGPals2
-	ld a, [wcf64]
+	ld a, [wDebugTilesetCurPalette]
 	ld bc, 1 palettes
 	call AddNTimes
 	ld e, l
 	ld d, h
-	ld hl, wc608
+	ld hl, wDebugPalette
 	ld bc, 1 palettes
 	call CopyBytes
 
 	hlcoord 1, 0
-	ld de, wc608
+	ld de, wDebugWhiteTileColor
 	call DebugColor_PrintHexColor
 	hlcoord 6, 0
-	ld de, wc608 + 2
+	ld de, wDebugLightTileColor
 	call DebugColor_PrintHexColor
 	hlcoord 11, 0
-	ld de, wc608 + 4
+	ld de, wDebugDarkTileColor
 	call DebugColor_PrintHexColor
 	hlcoord 16, 0
-	ld de, wc608 + 6
+	ld de, wDebugBlackTileColor
 	call DebugColor_PrintHexColor
 
 	pop af
@@ -1294,7 +1285,7 @@
 	ret
 
 DebugTileset_Joypad:
-	ld a, [wcf65]
+	ld a, [wDebugTilesetRGBJumptableIndex]
 	maskbits 4 ; .PointerTable length
 	ld e, a
 	ld d, 0
@@ -1326,20 +1317,20 @@
 	ret
 
 .left
-	ld a, [wcf66]
+	ld a, [wDebugTilesetCurColor]
 	dec a
 	jr .done
 
 .right
-	ld a, [wcf66]
+	ld a, [wDebugTilesetCurColor]
 	inc a
 
 .done
-	and $3
-	ld [wcf66], a
+	maskbits NUM_PAL_COLORS
+	ld [wDebugTilesetCurColor], a
 	ld e, a
 	ld d, 0
-	ld hl, wc608
+	ld hl, wDebugPalette
 	add hl, de
 	add hl, de
 	ld e, l
@@ -1355,7 +1346,7 @@
 	ld a, [hl]
 	and D_UP
 	jr nz, DebugTileset_PreviousRGBColor
-	ld hl, wc608 + 10
+	ld hl, wDebugRedChannel
 	jr DebugTileset_UpdateRGBColor
 
 DebugTileset_ChangeGreenValue:
@@ -1366,7 +1357,7 @@
 	ld a, [hl]
 	and D_UP
 	jr nz, DebugTileset_PreviousRGBColor
-	ld hl, wc608 + 11
+	ld hl, wDebugGreenChannel
 	jr DebugTileset_UpdateRGBColor
 
 DebugTileset_ChangeBlueValue:
@@ -1374,7 +1365,8 @@
 	ld a, [hl]
 	and D_UP
 	jr nz, DebugTileset_PreviousRGBColor
-	ld hl, wc608 + 12
+	ld hl, wDebugBlueChannel
+	; fallthrough
 
 DebugTileset_UpdateRGBColor:
 	ldh a, [hJoyLast]
@@ -1404,40 +1396,40 @@
 	ret
 
 DebugTileset_PreviousRGBColor:
-	ld hl, wcf65
+	ld hl, wDebugTilesetRGBJumptableIndex
 	dec [hl]
 	ret
 
 DebugTileset_NextRGBColor:
-	ld hl, wcf65
+	ld hl, wDebugTilesetRGBJumptableIndex
 	inc [hl]
 	ret
 
 DebugTileset_CalculatePalette:
-	ld a, [wc608 + 10]
+	ld a, [wDebugRedChannel]
 	and %00011111
 	ld e, a
-	ld a, [wc608 + 11]
+	ld a, [wDebugGreenChannel]
 	and %0000111
 	sla a
 	swap a
 	or e
 	ld e, a
-	ld a, [wc608 + 11]
+	ld a, [wDebugGreenChannel]
 	and %00011000
 	sla a
 	swap a
 	ld d, a
-	ld a, [wc608 + 12]
+	ld a, [wDebugBlueChannel]
 	and %00011111
 	sla a
 	sla a
 	or d
 	ld d, a
-	ld a, [wcf66]
+	ld a, [wDebugTilesetCurColor]
 	ld c, a
 	ld b, 0
-	ld hl, wc608
+	ld hl, wDebugPalette
 	add hl, bc
 	add hl, bc
 	ld a, e
--- a/engine/gfx/cgb_layouts.asm
+++ b/engine/gfx/cgb_layouts.asm
@@ -321,7 +321,7 @@
 	ldh [hCGBPalUpdate], a
 	ret
 
-Function9009:
+Function9009: ; unreferenced
 	ld hl, BillsPCOrangePalette
 	call LoadHLPaletteIntoDE
 	jr .GotPalette
--- a/engine/link/mystery_gift.asm
+++ b/engine/link/mystery_gift.asm
@@ -605,13 +605,14 @@
 	xor a
 	ldh [rIF], a
 	call Function104d96
+; runs for ~$40400 cycles
 	xor a
 	ld b, a
-.asm_104d6d
+.busy_wait
 	inc a
-	jr nz, .asm_104d6d
+	jr nz, .busy_wait
 	inc b
-	jr nz, .asm_104d6d
+	jr nz, .busy_wait
 	ret
 
 Function104d74:
@@ -846,9 +847,9 @@
 	ld b, a
 	ld a, $f4
 	ldh [rTMA], a
-.asm_104eee
+.main_loop
 	inc b
-	jr z, .asm_104f2e
+	jr z, .done
 	ld a, $8
 	ldh [hPrintNumBuffer + 3], a
 	ld a, [hli]
@@ -859,7 +860,7 @@
 	ldh a, [hPrintNumBuffer + 5]
 	adc 0
 	ldh [hPrintNumBuffer + 5], a
-.asm_104f02
+.inner_loop
 	xor a
 	ldh [rIF], a
 	halt
@@ -869,26 +870,27 @@
 	ld a, e
 	rlca
 	ld e, a
-	jr nc, .asm_104f13
+	jr nc, .wait
 	inc d
-.asm_104f13
+.wait
 	ldh a, [rTIMA]
 	cp $f8
-	jr c, .asm_104f13
+	jr c, .wait
 	ld a, $c0
 	ldh [rRP], a
 	dec d
-	jr z, .asm_104f25
+	jr z, .no_halt
 	xor a
 	ldh [rIF], a
 	halt
-.asm_104f25
+.no_halt
 	ldh a, [hPrintNumBuffer + 3]
 	dec a
-	jr z, .asm_104eee
+	jr z, .main_loop
 	ldh [hPrintNumBuffer + 3], a
-	jr .asm_104f02
-.asm_104f2e
+	jr .inner_loop
+
+.done
 	ld a, $fe
 	ldh [rTMA], a
 	xor a
@@ -987,27 +989,28 @@
 	xor a
 	ldh [hMGPrevTIMA], a
 	call Function104d86
-.asm_104fd2
+.main_loop
 	inc b
-	jr z, .asm_10501a
+	jr z, .done
 	ld a, $8
 	ldh [hPrintNumBuffer + 3], a
-.asm_104fd9
+.inner_loop
 	ld d, $0
-.asm_104fdb
+.wait_one
 	inc d
-	jr z, .asm_104fe5
+	jr z, .got_one
 	ldh a, [c]
 	bit 1, a
-	jr z, .asm_104fdb
+	jr z, .wait_one
 	ld d, $0
-.asm_104fe5
+.got_one
+.wait_zero
 	inc d
-	jr z, .asm_104fed
+	jr z, .got_zero
 	ldh a, [c]
 	bit 1, a
-	jr nz, .asm_104fe5
-.asm_104fed
+	jr nz, .wait_zero
+.got_zero
 	ldh a, [hMGPrevTIMA]
 	ld d, a
 	ldh a, [rTIMA]
@@ -1014,21 +1017,22 @@
 	ldh [hMGPrevTIMA], a
 	sub d
 	cp $12
-	jr c, .asm_104ffd
+	jr c, .zero
 	set 0, e
-	jr .asm_104fff
-.asm_104ffd
+	jr .ok
+.zero
 	res 0, e
-.asm_104fff
+.ok
 	ldh a, [hPrintNumBuffer + 3]
 	dec a
 	ldh [hPrintNumBuffer + 3], a
-	jr z, .asm_10500b
+	jr z, .continue
 	ld a, e
 	rlca
 	ld e, a
-	jr .asm_104fd9
-.asm_10500b
+	jr .inner_loop
+
+.continue
 	ld a, e
 	ld [hli], a
 	ldh a, [hPrintNumBuffer + 4]
@@ -1037,8 +1041,9 @@
 	ldh a, [hPrintNumBuffer + 5]
 	adc 0
 	ldh [hPrintNumBuffer + 5], a
-	jr .asm_104fd2
-.asm_10501a
+	jr .main_loop
+
+.done
 	call Function104d74
 	xor a
 	ldh [rIF], a
--- a/wram.asm
+++ b/wram.asm
@@ -774,6 +774,24 @@
 wOddEggOTName:: ds NAME_LENGTH
 
 NEXTU
+; debug mon color picker
+wDebugMiddleColors::
+wDebugLightColor:: ds 2
+wDebugDarkColor::  ds 2
+	ds 6
+wDebugRedChannel::   db
+wDebugGreenChannel:: db
+wDebugBlueChannel::  db
+
+NEXTU
+; debug tileset color picker
+wDebugPalette::
+wDebugWhiteTileColor:: ds 2
+wDebugLightTileColor:: ds 2
+wDebugDarkTileColor::  ds 2
+wDebugBlackTileColor:: ds 2
+
+NEXTU
 wc608:: ds 16
 wc618:: ds 37
 wc63d:: ds 5
@@ -1016,6 +1034,10 @@
 wHallOfFamePokemonList:: hall_of_fame wHallOfFamePokemonList
 
 NEXTU
+; debug color picker
+wDebugOriginalColors:: ds 256 * 4
+
+NEXTU
 ; raw link data
 wLinkData:: ds $514
 wLinkDataEnd::
@@ -1502,6 +1524,18 @@
 wUnownPuzzleHeldPiece:: db
 
 NEXTU
+; debug mon color picker
+wDebugColorRGBJumptableIndex:: db
+wDebugColorCurColor:: db
+wDebugColorCurMon:: db
+
+NEXTU
+; debug tileset color picker
+wDebugTilesetCurPalette:: db
+wDebugTilesetRGBJumptableIndex:: db
+wDebugTilesetCurColor:: db
+
+NEXTU
 ; battle tower
 	ds $2
 wBattleTowerRoomMenuJumptableIndex:: db
@@ -1834,6 +1868,12 @@
 	ds 2
 wStartFlypoint:: db
 wEndFlypoint:: db
+
+NEXTU
+; debug color picker
+wDebugColorIsTrainer:: db
+wDebugColorIsShiny:: db
+wDebugColorCurTMHM:: db
 
 NEXTU
 ; link battle record data