pokecrystal-board/engine/debug/color_picker.asm

1387 lines
22 KiB
NASM
Raw Normal View History

; DebugColor_GFX tile IDs
2018-01-31 08:38:45 -08:00
const_def $6a
const DEBUGTEST_TICKS_1 ; $6a
const DEBUGTEST_TICKS_2 ; $6b
const DEBUGTEST_WHITE ; $6c
const DEBUGTEST_LIGHT ; $6d
const DEBUGTEST_DARK ; $6e
const DEBUGTEST_BLACK ; $6f
const DEBUGTEST_0 ; $70
const DEBUGTEST_1 ; $71
const DEBUGTEST_2 ; $72
const DEBUGTEST_3 ; $73
const DEBUGTEST_4 ; $74
const DEBUGTEST_5 ; $75
const DEBUGTEST_6 ; $76
const DEBUGTEST_7 ; $77
const DEBUGTEST_8 ; $78
const DEBUGTEST_9 ; $79
const DEBUGTEST_A ; $7a
const DEBUGTEST_B ; $7b
const DEBUGTEST_C ; $7c
const DEBUGTEST_D ; $7d
const DEBUGTEST_E ; $7e
const DEBUGTEST_F ; $7f
; DebugColorMain.Jumptable indexes
const_def
const DEBUGCOLORMAIN_INITSCREEN ; 0
const DEBUGCOLORMAIN_UPDATESCREEN ; 1
const DEBUGCOLORMAIN_UPDATEPALETTES ; 2
const DEBUGCOLORMAIN_JOYPAD ; 3
const DEBUGCOLORMAIN_INITTMHM ; 4
const DEBUGCOLORMAIN_TMHMJOYPAD ; 5
DebugColorPicker: ; unreferenced
2015-11-19 15:07:20 -08:00
; A debug menu to test monster and trainer palettes at runtime.
ldh a, [hInMenu]
2015-11-19 15:07:20 -08:00
push af
ld a, TRUE
ldh [hInMenu], a
2015-11-19 15:07:20 -08:00
call DisableLCD
2020-10-06 10:50:02 -07:00
call DebugColor_InitVRAM
call DebugColor_LoadGFX
call DebugColor_InitPalettes
call DebugColor_InitMonOrTrainerColor
2015-11-19 15:07:20 -08:00
call EnableLCD
ld de, MUSIC_NONE
call PlayMusic
xor a ; DEBUGCOLORMAIN_INITSCREEN
2015-11-19 15:07:20 -08:00
ld [wJumptableIndex], a
2020-10-23 13:04:15 -07:00
ld [wDebugColorCurMon], a
ld [wDebugColorIsShiny], a
2020-10-06 10:50:02 -07:00
.loop
2015-11-19 15:07:20 -08:00
ld a, [wJumptableIndex]
bit 7, a
2020-10-06 10:50:02 -07:00
jr nz, .exit
call DebugColorMain
call DebugColor_PlaceCursor
2015-11-19 15:07:20 -08:00
call DelayFrame
2020-10-06 10:50:02 -07:00
jr .loop
2015-11-19 15:07:20 -08:00
2020-10-06 10:50:02 -07:00
.exit
2015-11-19 15:07:20 -08:00
pop af
ldh [hInMenu], a
2015-11-19 15:07:20 -08:00
ret
DebugColor_InitMonOrTrainerColor:
2020-10-23 13:04:15 -07:00
ld a, [wDebugColorIsTrainer]
2015-11-19 15:07:20 -08:00
and a
2020-10-06 10:50:02 -07:00
jr nz, DebugColor_InitTrainerColor
2015-11-19 15:07:20 -08:00
ld hl, PokemonPalettes
; fallthrough
2015-11-19 15:07:20 -08:00
DebugColor_InitMonColor:
2020-10-23 13:04:15 -07:00
ld de, wDebugOriginalColors
2015-11-19 15:07:20 -08:00
ld c, NUM_POKEMON + 1
2020-10-06 10:50:02 -07:00
.loop
2015-11-19 15:07:20 -08:00
push bc
push hl
2020-10-06 10:50:02 -07:00
call DebugColor_InitColor
2015-11-19 15:07:20 -08:00
pop hl
ld bc, 8
add hl, bc
pop bc
dec c
2020-10-06 10:50:02 -07:00
jr nz, .loop
2015-11-19 15:07:20 -08:00
ret
2020-10-06 10:50:02 -07:00
DebugColor_InitTrainerColor:
2015-11-19 15:07:20 -08:00
ld hl, TrainerPalettes
2020-10-23 13:04:15 -07:00
ld de, wDebugOriginalColors
ld c, NUM_TRAINER_CLASSES + 1
2020-10-06 10:50:02 -07:00
.loop
2015-11-19 15:07:20 -08:00
push bc
push hl
2020-10-06 10:50:02 -07:00
call DebugColor_InitColor
2015-11-19 15:07:20 -08:00
pop hl
ld bc, 4
add hl, bc
pop bc
dec c
2020-10-06 10:50:02 -07:00
jr nz, .loop
2015-11-19 15:07:20 -08:00
ret
2020-10-06 10:50:02 -07:00
DebugColor_InitColor:
2020-10-23 13:04:15 -07:00
rept 3
ld a, BANK(PokemonPalettes) ; aka BANK(TrainerPalettes)
2015-11-19 15:07:20 -08:00
call GetFarByte
ld [de], a
inc de
inc hl
2020-10-23 13:04:15 -07:00
endr
ld a, BANK(PokemonPalettes) ; aka BANK(TrainerPalettes)
2015-11-19 15:07:20 -08:00
call GetFarByte
ld [de], a
inc de
ret
2020-10-06 10:50:02 -07:00
DebugColor_InitVRAM:
2022-01-20 17:16:22 -08:00
ld a, $1
ldh [rVBK], a
2022-01-20 17:16:22 -08:00
ld hl, VRAM_Begin
ld bc, VRAM_End - VRAM_Begin
2015-11-19 15:07:20 -08:00
xor a
call ByteFill
2020-10-06 10:50:02 -07:00
2022-01-20 17:16:22 -08:00
ld a, $0
ldh [rVBK], a
2022-01-20 17:16:22 -08:00
ld hl, VRAM_Begin
ld bc, VRAM_End - VRAM_Begin
2015-11-19 15:07:20 -08:00
xor a
call ByteFill
2020-10-06 10:50:02 -07:00
hlcoord 0, 0, wAttrmap
2015-11-19 15:07:20 -08:00
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
xor a
call ByteFill
2020-10-06 10:50:02 -07:00
2015-11-19 15:07:20 -08:00
hlcoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
xor a
call ByteFill
2020-10-06 10:50:02 -07:00
2015-11-19 15:07:20 -08:00
call ClearSprites
ret
2020-10-06 10:50:02 -07:00
DebugColor_LoadGFX:
ld hl, DebugColor_GFX
ld de, vTiles2 tile DEBUGTEST_TICKS_1
ld bc, 22 tiles
2015-11-19 15:07:20 -08:00
call CopyBytes
2020-10-06 10:50:02 -07:00
ld hl, DebugColor_UpArrowGFX
2017-12-28 04:32:33 -08:00
ld de, vTiles0
ld bc, 1 tiles
2015-11-19 15:07:20 -08:00
call CopyBytes
2020-10-06 10:50:02 -07:00
; Invert the font colors.
2015-11-19 15:07:20 -08:00
call LoadStandardFont
2017-12-28 04:32:33 -08:00
ld hl, vTiles1
2020-10-06 10:50:02 -07:00
ld bc, $80 tiles
.loop
2015-11-19 15:07:20 -08:00
ld a, [hl]
xor $ff
ld [hli], a
dec bc
ld a, c
or b
2020-10-06 10:50:02 -07:00
jr nz, .loop
2015-11-19 15:07:20 -08:00
ret
2020-10-06 10:50:02 -07:00
DebugColor_InitPalettes:
ldh a, [rSVBK]
2015-11-19 15:07:20 -08:00
push af
ld a, BANK(wBGPals2)
ldh [rSVBK], a
2020-10-06 10:50:02 -07:00
2018-03-02 16:39:16 -08:00
ld hl, Palette_DebugBG
2018-01-01 06:08:21 -08:00
ld de, wBGPals2
2017-12-15 19:36:33 -08:00
ld bc, 16 palettes
2015-11-19 15:07:20 -08:00
call CopyBytes
2020-10-06 10:50:02 -07:00
ld a, 1 << rBGPI_AUTO_INCREMENT
ldh [rBGPI], a
2018-03-02 16:39:16 -08:00
ld hl, Palette_DebugBG
ld c, 8 palettes
2015-11-19 15:07:20 -08:00
xor a
2020-10-06 10:50:02 -07:00
.bg_loop
ldh [rBGPD], a
2015-11-19 15:07:20 -08:00
dec c
2020-10-06 10:50:02 -07:00
jr nz, .bg_loop
ld a, 1 << rOBPI_AUTO_INCREMENT
ldh [rOBPI], a
2018-03-02 16:39:16 -08:00
ld hl, Palette_DebugOB
ld c, 8 palettes
2020-10-06 10:50:02 -07:00
.ob_loop
2015-11-19 15:07:20 -08:00
ld a, [hli]
ldh [rOBPD], a
2015-11-19 15:07:20 -08:00
dec c
2020-10-06 10:50:02 -07:00
jr nz, .ob_loop
2020-10-23 13:04:15 -07:00
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
2020-10-06 10:50:02 -07:00
2015-11-19 15:07:20 -08:00
pop af
ldh [rSVBK], a
2015-11-19 15:07:20 -08:00
ret
2018-06-24 07:09:41 -07:00
Palette_DebugBG:
INCLUDE "gfx/debug/bg.pal"
2015-11-19 15:07:20 -08:00
2018-06-24 07:09:41 -07:00
Palette_DebugOB:
INCLUDE "gfx/debug/ob.pal"
2015-11-19 15:07:20 -08:00
2020-10-06 10:50:02 -07:00
DebugColorMain:
2015-11-19 15:07:20 -08:00
call JoyTextDelay
ld a, [wJumptableIndex]
cp DEBUGCOLORMAIN_INITTMHM
2020-10-22 09:55:46 -07:00
jr nc, .no_start_select
2015-11-19 15:07:20 -08:00
ld hl, hJoyLast
ld a, [hl]
and SELECT
2020-10-06 10:50:02 -07:00
jr nz, .NextMon
2015-11-19 15:07:20 -08:00
ld a, [hl]
and START
2020-10-06 10:50:02 -07:00
jr nz, .PreviousMon
2015-11-19 15:07:20 -08:00
2020-10-22 09:55:46 -07:00
.no_start_select
jumptable .Jumptable, wJumptableIndex
2015-11-19 15:07:20 -08:00
.NextMon:
2020-10-06 10:50:02 -07:00
call DebugColor_BackupSpriteColors
call .SetMaxNum
2015-11-19 15:07:20 -08:00
ld e, a
2020-10-23 13:04:15 -07:00
ld a, [wDebugColorCurMon]
2015-11-19 15:07:20 -08:00
inc a
cp e
2020-10-06 10:50:02 -07:00
jr c, .SwitchMon
2015-11-19 15:07:20 -08:00
xor a
2020-10-06 10:50:02 -07:00
jr .SwitchMon
2015-11-19 15:07:20 -08:00
.PreviousMon:
2020-10-06 10:50:02 -07:00
call DebugColor_BackupSpriteColors
2020-10-23 13:04:15 -07:00
ld a, [wDebugColorCurMon]
2015-11-19 15:07:20 -08:00
dec a
2020-10-06 10:50:02 -07:00
cp -1
jr nz, .SwitchMon
call .SetMaxNum
2015-11-19 15:07:20 -08:00
dec a
.SwitchMon:
2020-10-23 13:04:15 -07:00
ld [wDebugColorCurMon], a
ld a, DEBUGCOLORMAIN_INITSCREEN
2015-11-19 15:07:20 -08:00
ld [wJumptableIndex], a
ret
.SetMaxNum:
2015-11-19 15:07:20 -08:00
; Looping back around the pic set.
2020-10-23 13:04:15 -07:00
ld a, [wDebugColorIsTrainer]
2015-11-19 15:07:20 -08:00
and a
2020-10-06 10:50:02 -07:00
jr nz, .trainer
; mon
2015-11-19 15:07:20 -08:00
ld a, NUM_POKEMON ; CELEBI
ret
2020-10-06 10:50:02 -07:00
.trainer
ld a, NUM_TRAINER_CLASSES ; MYSTICALMAN
2015-11-19 15:07:20 -08:00
ret
.Jumptable:
; entries correspond to DEBUGCOLORMAIN_* constants
2020-10-06 10:50:02 -07:00
dw DebugColor_InitScreen
dw DebugColor_UpdateScreen
dw DebugColor_UpdatePalettes
dw DebugColor_Joypad
dw DebugColor_InitTMHM
dw DebugColor_TMHMJoypad
2015-11-19 15:07:20 -08:00
2020-10-06 10:50:02 -07:00
DebugColor_InitScreen:
2015-11-19 15:07:20 -08:00
xor a
ldh [hBGMapMode], a
2015-11-19 15:07:20 -08:00
hlcoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
ld a, DEBUGTEST_BLACK
2015-11-19 15:07:20 -08:00
call ByteFill
hlcoord 1, 3
lb bc, 7, 18
ld a, DEBUGTEST_WHITE
call DebugColor_FillBoxWithByte
2015-11-19 15:07:20 -08:00
hlcoord 11, 0
lb bc, 2, 3
ld a, DEBUGTEST_LIGHT
call DebugColor_FillBoxWithByte
2015-11-19 15:07:20 -08:00
hlcoord 16, 0
lb bc, 2, 3
ld a, DEBUGTEST_DARK
call DebugColor_FillBoxWithByte
2020-10-06 10:50:02 -07:00
call DebugColor_LoadRGBMeter
call DebugColor_SetRGBMeter
2020-10-23 13:04:15 -07:00
ld a, [wDebugColorCurMon]
2015-11-19 15:07:20 -08:00
inc a
2018-01-23 14:39:09 -08:00
ld [wCurPartySpecies], a
ld [wTextDecimalByte], a
2015-11-19 15:07:20 -08:00
hlcoord 0, 1
ld de, wTextDecimalByte
2015-11-19 15:07:20 -08:00
lb bc, PRINTNUM_LEADINGZEROS | 1, 3
call PrintNum
2020-10-23 13:04:15 -07:00
ld a, [wDebugColorIsTrainer]
2015-11-19 15:07:20 -08:00
and a
2020-10-06 10:50:02 -07:00
jr nz, .trainer
; mon
2020-10-06 10:50:02 -07:00
ld a, UNOWN_A
2018-01-23 14:39:09 -08:00
ld [wUnownLetter], a
2015-11-19 15:07:20 -08:00
call GetPokemonName
hlcoord 4, 1
call PlaceString
xor a
ld [wBoxAlignment], a
2015-11-19 15:07:20 -08:00
hlcoord 12, 3
call _PrepMonFrontpic
2017-12-28 04:32:33 -08:00
ld de, vTiles2 tile $31
predef GetMonBackpic
2015-11-19 15:07:20 -08:00
ld a, $31
ldh [hGraphicStartTile], a
2015-11-19 15:07:20 -08:00
hlcoord 2, 4
lb bc, 6, 6
predef PlaceGraphic
2020-10-06 10:50:02 -07:00
2020-10-23 13:04:15 -07:00
ld a, [wDebugColorIsShiny]
2015-11-19 15:07:20 -08:00
and a
jr z, .normal
; shiny
ld de, .ShinyText
jr .place_text
.normal
ld de, .NormalText
.place_text
2015-11-19 15:07:20 -08:00
hlcoord 7, 17
call PlaceString
hlcoord 0, 17
ld de, .SwitchText
2015-11-19 15:07:20 -08:00
call PlaceString
2020-10-06 10:50:02 -07:00
jr .done
2015-11-19 15:07:20 -08:00
2020-10-06 10:50:02 -07:00
.trainer
ld a, [wTextDecimalByte]
2018-01-23 14:39:09 -08:00
ld [wTrainerClass], a
2017-12-24 09:47:30 -08:00
callfar GetTrainerAttributes
2018-01-23 14:39:09 -08:00
ld de, wStringBuffer1
2015-11-19 15:07:20 -08:00
hlcoord 4, 1
call PlaceString
2017-12-28 04:32:33 -08:00
ld de, vTiles2
callfar GetTrainerPic
2015-11-19 15:07:20 -08:00
xor a
2018-01-23 14:39:09 -08:00
ld [wTempEnemyMonSpecies], a
ldh [hGraphicStartTile], a
2015-11-19 15:07:20 -08:00
hlcoord 2, 3
lb bc, 7, 7
predef PlaceGraphic
2015-11-19 15:07:20 -08:00
2020-10-06 10:50:02 -07:00
.done
ld a, DEBUGCOLORMAIN_UPDATESCREEN
2015-11-19 15:07:20 -08:00
ld [wJumptableIndex], a
ret
.ShinyText:
2020-10-06 10:50:02 -07:00
db "レア", DEBUGTEST_BLACK, DEBUGTEST_BLACK, "@" ; Rare (shiny)
2015-11-19 15:07:20 -08:00
.NormalText:
2020-10-06 10:50:02 -07:00
db "ノーマル@" ; Normal
.SwitchText:
2020-10-06 10:50:02 -07:00
db DEBUGTEST_A, "きりかえ▶@" ; (A) Switches
DebugColor_LoadRGBMeter:
decoord 0, 11, wAttrmap
2015-11-19 15:07:20 -08:00
hlcoord 2, 11
ld a, 1
call .load_meter
decoord 0, 13, wAttrmap
2015-11-19 15:07:20 -08:00
hlcoord 2, 13
ld a, 2
call .load_meter
decoord 0, 15, wAttrmap
2015-11-19 15:07:20 -08:00
hlcoord 2, 15
ld a, 3
.load_meter:
2015-11-19 15:07:20 -08:00
push af
ld a, DEBUGTEST_TICKS_1
2015-11-19 15:07:20 -08:00
ld [hli], a
2020-10-06 10:50:02 -07:00
ld bc, 15
ld a, DEBUGTEST_TICKS_2
2015-11-19 15:07:20 -08:00
call ByteFill
ld l, e
ld h, d
pop af
2020-10-06 10:50:02 -07:00
ld bc, 20 * 2
2015-11-19 15:07:20 -08:00
call ByteFill
ret
2020-10-06 10:50:02 -07:00
DebugColor_SetRGBMeter:
2020-10-23 13:04:15 -07:00
ld a, [wDebugColorCurMon]
2015-11-19 15:07:20 -08:00
inc a
ld l, a
2020-10-06 10:50:02 -07:00
ld h, 0
2015-11-19 15:07:20 -08:00
add hl, hl
add hl, hl
2020-10-23 13:04:15 -07:00
ld de, wDebugOriginalColors
2015-11-19 15:07:20 -08:00
add hl, de
2020-10-23 13:04:15 -07:00
ld de, wDebugMiddleColors
2015-11-19 15:07:20 -08:00
ld bc, 4
call CopyBytes
xor a
2020-10-23 13:04:15 -07:00
ld [wDebugColorRGBJumptableIndex], a
ld [wDebugColorCurColor], a
ld de, wDebugLightColor
2020-10-06 10:50:02 -07:00
call DebugColor_CalculateRGB
2015-11-19 15:07:20 -08:00
ret
DebugColor_UpdateScreen:
2020-10-06 10:50:02 -07:00
ld a, 2
ldh [hBGMapMode], a
2015-11-19 15:07:20 -08:00
call DelayFrame
call DelayFrame
call DelayFrame
call WaitBGMap
ld a, DEBUGCOLORMAIN_UPDATEPALETTES
2015-11-19 15:07:20 -08:00
ld [wJumptableIndex], a
ret
DebugColor_UpdatePalettes:
ldh a, [rSVBK]
2015-11-19 15:07:20 -08:00
push af
ld a, BANK(wBGPals2)
ldh [rSVBK], a
2020-10-06 10:50:02 -07:00
2018-01-01 06:08:21 -08:00
ld hl, wBGPals2
2020-10-23 13:04:15 -07:00
ld de, wDebugMiddleColors
ld c, 1
call DebugColor_LoadPalettes_White_Col1_Col2_Black
2015-11-19 15:07:20 -08:00
hlcoord 10, 2
2020-10-23 13:04:15 -07:00
ld de, wDebugLightColor
call DebugColor_PrintHexColor
2015-11-19 15:07:20 -08:00
hlcoord 15, 2
2020-10-23 13:04:15 -07:00
ld de, wDebugDarkColor
call DebugColor_PrintHexColor
2020-08-03 14:41:01 -07:00
ld a, TRUE
ldh [hCGBPalUpdate], a
2020-10-06 10:50:02 -07:00
ld a, DEBUGCOLORMAIN_JOYPAD
2015-11-19 15:07:20 -08:00
ld [wJumptableIndex], a
2020-10-06 10:50:02 -07:00
2015-11-19 15:07:20 -08:00
pop af
ldh [rSVBK], a
2015-11-19 15:07:20 -08:00
ret
DebugColor_PrintHexColor:
2015-11-19 15:07:20 -08:00
inc hl
inc hl
inc hl
2015-11-19 15:07:20 -08:00
ld a, [de]
call .place_tile
2015-11-19 15:07:20 -08:00
ld a, [de]
swap a
call .place_tile
2015-11-19 15:07:20 -08:00
inc de
ld a, [de]
call .place_tile
2015-11-19 15:07:20 -08:00
ld a, [de]
swap a
.place_tile:
2015-11-19 15:07:20 -08:00
and $f
add DEBUGTEST_0
2015-11-19 15:07:20 -08:00
ld [hld], a
ret
DebugColor_Joypad:
ldh a, [hJoyLast]
2015-11-19 15:07:20 -08:00
and B_BUTTON
jr nz, .tmhm
ldh a, [hJoyLast]
2015-11-19 15:07:20 -08:00
and A_BUTTON
jr nz, .toggle_shiny
2020-10-23 13:04:15 -07:00
ld a, [wDebugColorRGBJumptableIndex]
maskbits 4 ; .PointerTable length
2015-11-19 15:07:20 -08:00
ld e, a
ld d, 0
ld hl, .PointerTable
2015-11-19 15:07:20 -08:00
add hl, de
add hl, de
2015-11-19 15:07:20 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
2015-11-19 15:07:20 -08:00
.tmhm
; Enter the TM/HM checker.
ld a, DEBUGCOLORMAIN_INITTMHM
2015-11-19 15:07:20 -08:00
ld [wJumptableIndex], a
ret
.toggle_shiny
; Toggle between the normal and shiny mon colors.
2020-10-23 13:04:15 -07:00
ld a, [wDebugColorIsTrainer]
2015-11-19 15:07:20 -08:00
and a
ret nz
2020-10-23 13:04:15 -07:00
ld a, [wDebugColorIsShiny]
2020-10-06 10:50:02 -07:00
xor %00000100
2020-10-23 13:04:15 -07:00
ld [wDebugColorIsShiny], a
2015-11-19 15:07:20 -08:00
ld c, a
ld b, 0
ld hl, PokemonPalettes
add hl, bc
call DebugColor_InitMonColor
ld a, DEBUGCOLORMAIN_INITSCREEN
2015-11-19 15:07:20 -08:00
ld [wJumptableIndex], a
ret
.PointerTable:
2020-10-06 10:50:02 -07:00
dw DebugColor_SelectColorBox
dw DebugColor_ChangeRedValue
dw DebugColor_ChangeGreenValue
dw DebugColor_ChangeBlueValue
2015-11-19 15:07:20 -08:00
2020-10-06 10:50:02 -07:00
DebugColor_SelectColorBox:
2015-11-19 15:07:20 -08:00
ld hl, hJoyLast
ld a, [hl]
and D_DOWN
2020-10-06 10:50:02 -07:00
jr nz, DebugColor_NextRGBColor
2015-11-19 15:07:20 -08:00
ld a, [hl]
and D_LEFT
jr nz, .light
2015-11-19 15:07:20 -08:00
ld a, [hl]
and D_RIGHT
jr nz, .dark
2015-11-19 15:07:20 -08:00
ret
.light
2020-10-23 13:04:15 -07:00
xor a ; FALSE
ld [wDebugColorCurColor], a
ld de, wDebugLightColor
2020-10-06 10:50:02 -07:00
call DebugColor_CalculateRGB
2015-11-19 15:07:20 -08:00
ret
.dark
ld a, TRUE
2020-10-23 13:04:15 -07:00
ld [wDebugColorCurColor], a
ld de, wDebugDarkColor
2020-10-06 10:50:02 -07:00
call DebugColor_CalculateRGB
2015-11-19 15:07:20 -08:00
ret
2020-10-06 10:50:02 -07:00
DebugColor_ChangeRedValue:
2015-11-19 15:07:20 -08:00
ld hl, hJoyLast
ld a, [hl]
and D_DOWN
2020-10-06 10:50:02 -07:00
jr nz, DebugColor_NextRGBColor
2015-11-19 15:07:20 -08:00
ld a, [hl]
and D_UP
2020-10-06 10:50:02 -07:00
jr nz, DebugColor_PreviousRGBColor
2020-10-23 13:04:15 -07:00
ld hl, wDebugRedChannel
jr DebugColor_UpdateRGBColor
2015-11-19 15:07:20 -08:00
2020-10-06 10:50:02 -07:00
DebugColor_ChangeGreenValue:
2015-11-19 15:07:20 -08:00
ld hl, hJoyLast
ld a, [hl]
and D_DOWN
2020-10-06 10:50:02 -07:00
jr nz, DebugColor_NextRGBColor
2015-11-19 15:07:20 -08:00
ld a, [hl]
and D_UP
2020-10-06 10:50:02 -07:00
jr nz, DebugColor_PreviousRGBColor
2020-10-23 13:04:15 -07:00
ld hl, wDebugGreenChannel
jr DebugColor_UpdateRGBColor
2015-11-19 15:07:20 -08:00
2020-10-06 10:50:02 -07:00
DebugColor_ChangeBlueValue:
2015-11-19 15:07:20 -08:00
ld hl, hJoyLast
ld a, [hl]
and D_UP
2020-10-06 10:50:02 -07:00
jr nz, DebugColor_PreviousRGBColor
2020-10-23 13:04:15 -07:00
ld hl, wDebugBlueChannel
; fallthrough
2015-11-19 15:07:20 -08:00
DebugColor_UpdateRGBColor:
ldh a, [hJoyLast]
2015-11-19 15:07:20 -08:00
and D_RIGHT
jr nz, .increment
ldh a, [hJoyLast]
2015-11-19 15:07:20 -08:00
and D_LEFT
jr nz, .decrement
2015-11-19 15:07:20 -08:00
ret
.increment
2015-11-19 15:07:20 -08:00
ld a, [hl]
2020-10-06 10:50:02 -07:00
cp 31
2015-11-19 15:07:20 -08:00
ret nc
inc [hl]
2020-10-06 10:50:02 -07:00
jr .done
2015-11-19 15:07:20 -08:00
.decrement
2015-11-19 15:07:20 -08:00
ld a, [hl]
and a
ret z
dec [hl]
.done
2020-10-06 10:50:02 -07:00
call DebugColor_CalculatePalette
ld a, DEBUGCOLORMAIN_UPDATEPALETTES
2015-11-19 15:07:20 -08:00
ld [wJumptableIndex], a
ret
2020-10-06 10:50:02 -07:00
DebugColor_PreviousRGBColor:
2020-10-23 13:04:15 -07:00
ld hl, wDebugColorRGBJumptableIndex
2015-11-19 15:07:20 -08:00
dec [hl]
ret
2020-10-06 10:50:02 -07:00
DebugColor_NextRGBColor:
2020-10-23 13:04:15 -07:00
ld hl, wDebugColorRGBJumptableIndex
2015-11-19 15:07:20 -08:00
inc [hl]
ret
DebugColor_InitTMHM:
2015-11-19 15:07:20 -08:00
hlcoord 0, 10
2020-10-06 10:50:02 -07:00
ld bc, SCREEN_WIDTH * 8
ld a, DEBUGTEST_BLACK
2015-11-19 15:07:20 -08:00
call ByteFill
hlcoord 2, 12
2020-10-06 10:50:02 -07:00
ld de, DebugColor_AreYouFinishedString
2015-11-19 15:07:20 -08:00
call PlaceString
xor a
2020-10-23 13:04:15 -07:00
ld [wDebugColorCurTMHM], a
call DebugColor_PrintTMHMMove
ld a, DEBUGCOLORMAIN_TMHMJOYPAD
2015-11-19 15:07:20 -08:00
ld [wJumptableIndex], a
ret
DebugColor_TMHMJoypad:
2015-11-19 15:07:20 -08:00
ld hl, hJoyPressed
ld a, [hl]
and B_BUTTON
2020-10-06 10:50:02 -07:00
jr nz, .cancel
call .scroll
2015-11-19 15:07:20 -08:00
ret
2020-10-06 10:50:02 -07:00
.cancel
ld a, DEBUGCOLORMAIN_INITSCREEN
2015-11-19 15:07:20 -08:00
ld [wJumptableIndex], a
ret
2020-10-06 10:50:02 -07:00
.exit ; unreferenced
2015-11-19 15:07:20 -08:00
ld hl, wJumptableIndex
set 7, [hl]
ret
.scroll:
2015-11-19 15:07:20 -08:00
ld hl, hJoyLast
ld a, [hl]
and D_UP
2020-10-06 10:50:02 -07:00
jr nz, .up
2015-11-19 15:07:20 -08:00
ld a, [hl]
and D_DOWN
2020-10-06 10:50:02 -07:00
jr nz, .down
2015-11-19 15:07:20 -08:00
ret
2020-10-06 10:50:02 -07:00
.up
2020-10-23 13:04:15 -07:00
ld a, [wDebugColorCurTMHM]
2020-10-06 10:50:02 -07:00
cp NUM_TM_HM_TUTOR - 1
jr z, .wrap_down
2015-11-19 15:07:20 -08:00
inc a
2020-10-06 10:50:02 -07:00
jr .done
2015-11-19 15:07:20 -08:00
2020-10-06 10:50:02 -07:00
.wrap_down
2015-11-19 15:07:20 -08:00
xor a
2020-10-06 10:50:02 -07:00
jr .done
2015-11-19 15:07:20 -08:00
2020-10-06 10:50:02 -07:00
.down
2020-10-23 13:04:15 -07:00
ld a, [wDebugColorCurTMHM]
2015-11-19 15:07:20 -08:00
and a
2020-10-06 10:50:02 -07:00
jr z, .wrap_up
2015-11-19 15:07:20 -08:00
dec a
2020-10-06 10:50:02 -07:00
jr .done
2015-11-19 15:07:20 -08:00
2020-10-06 10:50:02 -07:00
.wrap_up
ld a, NUM_TM_HM_TUTOR - 1
2015-11-19 15:07:20 -08:00
2020-10-06 10:50:02 -07:00
.done
2020-10-23 13:04:15 -07:00
ld [wDebugColorCurTMHM], a
call DebugColor_PrintTMHMMove
2015-11-19 15:07:20 -08:00
ret
DebugColor_PrintTMHMMove:
2015-11-19 15:07:20 -08:00
hlcoord 10, 11
call .ClearRow
2015-11-19 15:07:20 -08:00
hlcoord 10, 12
call .ClearRow
2015-11-19 15:07:20 -08:00
hlcoord 10, 13
call .ClearRow
2015-11-19 15:07:20 -08:00
hlcoord 10, 14
call .ClearRow
2020-10-23 13:04:15 -07:00
ld a, [wDebugColorCurTMHM]
2015-11-19 15:07:20 -08:00
inc a
ld [wTempTMHM], a
predef GetTMHMMove
ld a, [wTempTMHM]
ld [wPutativeTMHMMove], a
2015-11-19 15:07:20 -08:00
call GetMoveName
hlcoord 10, 12
call PlaceString
2020-10-23 13:04:15 -07:00
ld a, [wDebugColorCurTMHM]
call .GetNumberedTMHM
2018-01-23 14:39:09 -08:00
ld [wCurItem], a
predef CanLearnTMHMMove
2015-11-19 15:07:20 -08:00
ld a, c
and a
ld de, .AbleText
2020-10-06 10:50:02 -07:00
jr nz, .place_string
ld de, .NotAbleText
2020-10-06 10:50:02 -07:00
.place_string
2015-11-19 15:07:20 -08:00
hlcoord 10, 14
call PlaceString
ret
.AbleText:
2020-10-06 10:50:02 -07:00
db "おぼえられる@" ; Learnable
.NotAbleText:
2020-10-06 10:50:02 -07:00
db "おぼえられない@" ; Not learnable
2015-11-19 15:07:20 -08:00
.GetNumberedTMHM:
2020-10-06 10:50:02 -07:00
cp NUM_TMS
jr c, .tm
; hm - skip two gap items
2015-11-19 15:07:20 -08:00
inc a
inc a
2020-10-06 10:50:02 -07:00
.tm
add TM01
2015-11-19 15:07:20 -08:00
ret
.ClearRow:
ld bc, 10
ld a, DEBUGTEST_BLACK
2015-11-19 15:07:20 -08:00
call ByteFill
ret
2020-10-06 10:50:02 -07:00
DebugColor_CalculatePalette:
2020-10-23 13:04:15 -07:00
ld a, [wDebugRedChannel]
2020-10-06 10:50:02 -07:00
and %00011111
2015-11-19 15:07:20 -08:00
ld e, a
2020-10-23 13:04:15 -07:00
ld a, [wDebugGreenChannel]
2020-10-06 10:50:02 -07:00
and %00000111
2015-11-19 15:07:20 -08:00
sla a
swap a
or e
ld e, a
2020-10-23 13:04:15 -07:00
ld a, [wDebugGreenChannel]
2020-10-06 10:50:02 -07:00
and %00011000
2015-11-19 15:07:20 -08:00
sla a
swap a
ld d, a
2020-10-23 13:04:15 -07:00
ld a, [wDebugBlueChannel]
2020-10-06 10:50:02 -07:00
and %00011111
2015-11-19 15:07:20 -08:00
sla a
sla a
or d
ld d, a
2020-10-23 13:04:15 -07:00
ld a, [wDebugColorCurColor]
2015-11-19 15:07:20 -08:00
and a
jr z, .light
2020-10-06 10:50:02 -07:00
; dark
2015-11-19 15:07:20 -08:00
ld a, e
2020-10-23 13:04:15 -07:00
ld [wDebugDarkColor + 0], a
2015-11-19 15:07:20 -08:00
ld a, d
2020-10-23 13:04:15 -07:00
ld [wDebugDarkColor + 1], a
2015-11-19 15:07:20 -08:00
ret
.light
2015-11-19 15:07:20 -08:00
ld a, e
2020-10-23 13:04:15 -07:00
ld [wDebugLightColor + 0], a
2015-11-19 15:07:20 -08:00
ld a, d
2020-10-23 13:04:15 -07:00
ld [wDebugLightColor + 1], a
2015-11-19 15:07:20 -08:00
ret
2020-10-06 10:50:02 -07:00
DebugColor_CalculateRGB:
2015-11-19 15:07:20 -08:00
ld a, [de]
2020-10-06 10:50:02 -07:00
and %00011111
2020-10-23 13:04:15 -07:00
ld [wDebugRedChannel], a
2015-11-19 15:07:20 -08:00
ld a, [de]
2020-10-06 10:50:02 -07:00
and %11100000
2015-11-19 15:07:20 -08:00
swap a
srl a
ld b, a
inc de
ld a, [de]
2020-10-06 10:50:02 -07:00
and %00000011
2015-11-19 15:07:20 -08:00
swap a
srl a
or b
2020-10-23 13:04:15 -07:00
ld [wDebugGreenChannel], a
2015-11-19 15:07:20 -08:00
ld a, [de]
2020-10-06 10:50:02 -07:00
and %01111100
2015-11-19 15:07:20 -08:00
srl a
srl a
2020-10-23 13:04:15 -07:00
ld [wDebugBlueChannel], a
2015-11-19 15:07:20 -08:00
ret
2020-10-06 10:50:02 -07:00
DebugColor_BackupSpriteColors:
2020-10-23 13:04:15 -07:00
ld a, [wDebugColorCurMon]
2015-11-19 15:07:20 -08:00
inc a
ld l, a
2020-10-06 10:50:02 -07:00
ld h, 0
2015-11-19 15:07:20 -08:00
add hl, hl
add hl, hl
2020-10-23 13:04:15 -07:00
ld de, wDebugOriginalColors
2015-11-19 15:07:20 -08:00
add hl, de
ld e, l
ld d, h
2020-10-23 13:04:15 -07:00
ld hl, wDebugMiddleColors
2015-11-19 15:07:20 -08:00
ld bc, 4
call CopyBytes
ret
DebugColor_LoadPalettes_White_Col1_Col2_Black:
2020-10-06 10:50:02 -07:00
.loop
ld a, LOW(PALRGB_WHITE)
2015-11-19 15:07:20 -08:00
ld [hli], a
ld a, HIGH(PALRGB_WHITE)
2015-11-19 15:07:20 -08:00
ld [hli], a
rept 4
2015-11-19 15:07:20 -08:00
ld a, [de]
inc de
ld [hli], a
endr
2015-11-19 15:07:20 -08:00
xor a
ld [hli], a
ld [hli], a
2015-11-19 15:07:20 -08:00
dec c
2020-10-06 10:50:02 -07:00
jr nz, .loop
2015-11-19 15:07:20 -08:00
ret
DebugColor_FillBoxWithByte:
2015-11-19 15:07:20 -08:00
; For some reason, we have another copy of FillBoxWithByte here
.row
push bc
push hl
.col
ld [hli], a
dec c
jr nz, .col
pop hl
ld bc, SCREEN_WIDTH
add hl, bc
pop bc
dec b
jr nz, .row
ret
DebugColor_PushSGBPals:
ld a, [wJoypadDisable]
2015-11-19 15:07:20 -08:00
push af
set JOYPAD_DISABLE_SGB_TRANSFER_F, a
ld [wJoypadDisable], a
call _DebugColor_PushSGBPals
2015-11-19 15:07:20 -08:00
pop af
ld [wJoypadDisable], a
2015-11-19 15:07:20 -08:00
ret
_DebugColor_PushSGBPals:
2015-11-19 15:07:20 -08:00
ld a, [hl]
and $7
ret z
ld b, a
2020-10-06 10:50:02 -07:00
.loop
2015-11-19 15:07:20 -08:00
push bc
xor a
ldh [rJOYP], a
2015-11-19 15:07:20 -08:00
ld a, $30
ldh [rJOYP], a
2015-11-19 15:07:20 -08:00
ld b, $10
2020-10-06 10:50:02 -07:00
.loop2
2015-11-19 15:07:20 -08:00
ld e, $8
ld a, [hli]
ld d, a
2020-10-06 10:50:02 -07:00
.loop3
2015-11-19 15:07:20 -08:00
bit 0, d
ld a, $10
2020-10-06 10:50:02 -07:00
jr nz, .okay
2015-11-19 15:07:20 -08:00
ld a, $20
2020-10-06 10:50:02 -07:00
.okay
ldh [rJOYP], a
2015-11-19 15:07:20 -08:00
ld a, $30
ldh [rJOYP], a
2015-11-19 15:07:20 -08:00
rr d
dec e
2020-10-06 10:50:02 -07:00
jr nz, .loop3
2015-11-19 15:07:20 -08:00
dec b
2020-10-06 10:50:02 -07:00
jr nz, .loop2
2015-11-19 15:07:20 -08:00
ld a, $20
ldh [rJOYP], a
2015-11-19 15:07:20 -08:00
ld a, $30
ldh [rJOYP], a
2015-11-19 15:07:20 -08:00
ld de, 7000
2020-10-06 10:50:02 -07:00
.wait
2015-11-19 15:07:20 -08:00
nop
nop
nop
dec de
ld a, d
or e
2020-10-06 10:50:02 -07:00
jr nz, .wait
2015-11-19 15:07:20 -08:00
pop bc
dec b
2020-10-06 10:50:02 -07:00
jr nz, .loop
2015-11-19 15:07:20 -08:00
ret
2020-10-06 10:50:02 -07:00
DebugColor_PlaceCursor:
ld a, DEBUGTEST_BLACK
2015-11-19 15:07:20 -08:00
hlcoord 10, 0
ld [hl], a
hlcoord 15, 0
ld [hl], a
hlcoord 1, 11
ld [hl], a
hlcoord 1, 13
ld [hl], a
hlcoord 1, 15
ld [hl], a
2015-11-19 15:07:20 -08:00
ld a, [wJumptableIndex]
cp DEBUGCOLORMAIN_JOYPAD
2020-10-06 10:50:02 -07:00
jr nz, .clearsprites
2020-10-23 13:04:15 -07:00
ld a, [wDebugColorRGBJumptableIndex]
2015-11-19 15:07:20 -08:00
and a
2020-10-22 09:55:46 -07:00
jr z, .place_cursor
2015-11-19 15:07:20 -08:00
dec a
hlcoord 1, 11
ld bc, 2 * SCREEN_WIDTH
call AddNTimes
2020-10-06 10:50:02 -07:00
ld [hl], "▶"
2015-11-19 15:07:20 -08:00
2020-10-22 09:55:46 -07:00
.place_cursor
2020-10-23 13:04:15 -07:00
ld a, [wDebugColorCurColor]
2015-11-19 15:07:20 -08:00
and a
jr z, .light
; dark
2015-11-19 15:07:20 -08:00
hlcoord 15, 0
2020-10-06 10:50:02 -07:00
jr .place
.light
2015-11-19 15:07:20 -08:00
hlcoord 10, 0
2020-10-06 10:50:02 -07:00
.place
ld [hl], "▶"
ld b, $70 ; initial tile id
ld c, 5 ; initial palette
ld hl, wShadowOAM
2020-10-23 13:04:15 -07:00
ld de, wDebugRedChannel
2020-10-06 10:50:02 -07:00
call .placesprite
2020-10-23 13:04:15 -07:00
ld de, wDebugGreenChannel
2020-10-06 10:50:02 -07:00
call .placesprite
2020-10-23 13:04:15 -07:00
ld de, wDebugBlueChannel
2020-10-06 10:50:02 -07:00
call .placesprite
2015-11-19 15:07:20 -08:00
ret
.placesprite:
2015-11-19 15:07:20 -08:00
ld a, b
2018-01-10 10:47:57 -08:00
ld [hli], a ; y
2015-11-19 15:07:20 -08:00
ld a, [de]
add a
add a
2018-01-10 10:47:57 -08:00
add 3 * TILE_WIDTH
ld [hli], a ; x
2015-11-19 15:07:20 -08:00
xor a
2018-01-10 10:47:57 -08:00
ld [hli], a ; tile id
2015-11-19 15:07:20 -08:00
ld a, c
2018-01-10 10:47:57 -08:00
ld [hli], a ; attributes
ld a, 2 * TILE_WIDTH
2015-11-19 15:07:20 -08:00
add b
ld b, a
inc c
ret
.clearsprites:
2015-11-19 15:07:20 -08:00
call ClearSprites
ret
2020-10-06 10:50:02 -07:00
DebugColor_AreYouFinishedString:
db "おわりますか?" ; Are you finished?
next "はい<DOT><DOT><DOT>", DEBUGTEST_A ; YES...(A)
next "いいえ<DOT><DOT>", DEBUGTEST_B ; NO..(B)
2015-11-19 15:07:20 -08:00
db "@"
DebugColor_UpArrowGFX:
INCBIN "gfx/debug/up_arrow.2bpp"
2020-10-06 10:50:02 -07:00
DebugColor_GFX:
2015-11-19 15:07:20 -08:00
INCBIN "gfx/debug/color_test.2bpp"
TilesetColorPicker: ; unreferenced
; A debug menu to test tileset palettes at runtime.
2020-10-06 10:50:02 -07:00
; dummied out
2015-11-19 15:07:20 -08:00
ret
2015-11-19 15:07:20 -08:00
xor a
ld [wJumptableIndex], a
2020-10-23 13:04:15 -07:00
ld [wDebugTilesetCurPalette], a
ld [wDebugTilesetRGBJumptableIndex], a
ld [wDebugTilesetCurColor], a
ldh [hMapAnims], a
2015-11-19 15:07:20 -08:00
call ClearSprites
call OverworldTextModeSwitch
2015-12-11 13:59:40 -08:00
call WaitBGMap2
2015-11-19 15:07:20 -08:00
xor a
ldh [hBGMapMode], a
2020-10-06 10:50:02 -07:00
ld de, DebugColor_GFX
ld hl, vTiles2 tile DEBUGTEST_TICKS_1
2020-10-06 10:50:02 -07:00
lb bc, BANK(DebugColor_GFX), 22
2015-11-19 15:07:20 -08:00
call Request2bpp
ld de, DebugColor_UpArrowGFX
2017-12-28 04:32:33 -08:00
ld hl, vTiles1
lb bc, BANK(DebugColor_UpArrowGFX), 1
2015-11-19 15:07:20 -08:00
call Request2bpp
2017-12-28 04:32:33 -08:00
ld a, HIGH(vBGMap1)
ldh [hBGMapAddress + 1], a
2015-11-19 15:07:20 -08:00
hlcoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
ld a, DEBUGTEST_BLACK
2015-11-19 15:07:20 -08:00
call ByteFill
hlcoord 0, 0, wAttrmap
2015-11-19 15:07:20 -08:00
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
ld a, PAL_BG_TEXT
2015-11-19 15:07:20 -08:00
call ByteFill
decoord 1, 1, 0
ld a, DEBUGTEST_WHITE
call DebugTileset_DrawColorSwatch
decoord 6, 1, 0
ld a, DEBUGTEST_LIGHT
call DebugTileset_DrawColorSwatch
decoord 11, 1, 0
ld a, DEBUGTEST_DARK
call DebugTileset_DrawColorSwatch
decoord 16, 1, 0
ld a, DEBUGTEST_BLACK
call DebugTileset_DrawColorSwatch
call DebugTileset_LoadRGBMeter
call DebugTileset_LoadPalettes
2015-12-11 13:59:40 -08:00
call WaitBGMap2
2015-11-19 15:07:20 -08:00
ld [wJumptableIndex], a
ld a, $40
ldh [hWY], a
2015-11-19 15:07:20 -08:00
ret
DebugTileset_DrawColorSwatch:
2015-11-19 15:07:20 -08:00
hlcoord 0, 0
call _DebugColor_DrawSwatch
2015-11-19 15:07:20 -08:00
DebugColor_DrawAttributeSwatch:
2020-10-23 13:04:15 -07:00
ld a, [wDebugTilesetCurPalette]
hlcoord 0, 0, wAttrmap
2020-10-23 13:04:15 -07:00
; fallthrough
2015-11-19 15:07:20 -08:00
_DebugColor_DrawSwatch:
; Fills a 4x3 box at de with byte a.
2015-11-19 15:07:20 -08:00
add hl, de
rept 4
ld [hli], a
endr
rept 2
ld bc, SCREEN_WIDTH - 4
2015-11-19 15:07:20 -08:00
add hl, bc
rept 4
ld [hli], a
endr
endr
ret
DebugTileset_LoadRGBMeter:
2015-11-19 15:07:20 -08:00
hlcoord 2, 4
2020-10-06 10:50:02 -07:00
call .Place
2015-11-19 15:07:20 -08:00
hlcoord 2, 6
2020-10-06 10:50:02 -07:00
call .Place
2015-11-19 15:07:20 -08:00
hlcoord 2, 8
2020-10-06 10:50:02 -07:00
.Place:
ld a, DEBUGTEST_TICKS_1
2015-11-19 15:07:20 -08:00
ld [hli], a
ld bc, 15
ld a, DEBUGTEST_TICKS_2
2015-11-19 15:07:20 -08:00
call ByteFill
ret
DebugTileset_LoadPalettes:
ldh a, [rSVBK]
2015-11-19 15:07:20 -08:00
push af
ld a, BANK(wBGPals1)
ldh [rSVBK], a
2020-10-06 10:50:02 -07:00
2020-10-23 13:04:15 -07:00
ld a, [wDebugTilesetCurPalette]
2015-11-19 15:07:20 -08:00
ld l, a
2020-10-06 10:50:02 -07:00
ld h, 0
2015-11-19 15:07:20 -08:00
add hl, hl
add hl, hl
add hl, hl
2018-01-01 06:08:21 -08:00
ld de, wBGPals1
2015-11-19 15:07:20 -08:00
add hl, de
2020-10-23 13:04:15 -07:00
ld de, wDebugPalette
ld bc, 1 palettes
2015-11-19 15:07:20 -08:00
call CopyBytes
2020-10-23 13:04:15 -07:00
ld de, wDebugPalette
2020-10-06 10:50:02 -07:00
call DebugColor_CalculateRGB
2015-11-19 15:07:20 -08:00
pop af
ldh [rSVBK], a
2015-11-19 15:07:20 -08:00
ret
2020-10-06 10:50:02 -07:00
DebugColorMain2: ; unreferenced
2015-11-19 15:07:20 -08:00
ld hl, hJoyLast
ld a, [hl]
and SELECT
2020-10-23 13:04:15 -07:00
jr nz, .next_palette
2015-11-19 15:07:20 -08:00
ld a, [hl]
and B_BUTTON
jr nz, .cancel
call DebugTileset_Joypad
2015-11-19 15:07:20 -08:00
ret
2020-10-23 13:04:15 -07:00
.next_palette
ld hl, wDebugTilesetCurPalette
2015-11-19 15:07:20 -08:00
ld a, [hl]
inc a
and PALETTE_MASK
cp PAL_BG_TEXT
jr nz, .palette_ok
xor a ; PAL_BG_GRAY
.palette_ok
2015-11-19 15:07:20 -08:00
ld [hl], a
decoord 1, 1, 0
call DebugColor_DrawAttributeSwatch
decoord 6, 1, 0
call DebugColor_DrawAttributeSwatch
decoord 11, 1, 0
call DebugColor_DrawAttributeSwatch
decoord 16, 1, 0
call DebugColor_DrawAttributeSwatch
ldh a, [rSVBK]
2015-11-19 15:07:20 -08:00
push af
ld a, BANK(wBGPals2)
ldh [rSVBK], a
2018-01-01 06:08:21 -08:00
ld hl, wBGPals2
2020-10-23 13:04:15 -07:00
ld a, [wDebugTilesetCurPalette]
2018-01-01 05:47:16 -08:00
ld bc, 1 palettes
2015-11-19 15:07:20 -08:00
call AddNTimes
2020-10-23 13:04:15 -07:00
ld de, wDebugPalette
2018-01-01 05:47:16 -08:00
ld bc, 1 palettes
2015-11-19 15:07:20 -08:00
call CopyBytes
2015-11-19 15:07:20 -08:00
pop af
ldh [rSVBK], a
2020-10-06 10:50:02 -07:00
ld a, 2
ldh [hBGMapMode], a
2015-11-19 15:07:20 -08:00
ld c, 3
call DelayFrames
2020-10-06 10:50:02 -07:00
ld a, 1
ldh [hBGMapMode], a
2015-11-19 15:07:20 -08:00
ret
.cancel
2015-11-19 15:07:20 -08:00
call ClearSprites
ldh a, [hWY]
2020-10-06 10:50:02 -07:00
xor %11010000
ldh [hWY], a
2015-11-19 15:07:20 -08:00
ret
DebugTileset_UpdatePalettes:
ldh a, [rSVBK]
2015-11-19 15:07:20 -08:00
push af
ld a, BANK(wBGPals2)
ldh [rSVBK], a
2018-01-01 06:08:21 -08:00
ld hl, wBGPals2
2020-10-23 13:04:15 -07:00
ld a, [wDebugTilesetCurPalette]
2018-01-01 05:47:16 -08:00
ld bc, 1 palettes
2015-11-19 15:07:20 -08:00
call AddNTimes
ld e, l
ld d, h
2020-10-23 13:04:15 -07:00
ld hl, wDebugPalette
2018-01-01 05:47:16 -08:00
ld bc, 1 palettes
2015-11-19 15:07:20 -08:00
call CopyBytes
2015-11-19 15:07:20 -08:00
hlcoord 1, 0
2020-10-23 13:04:15 -07:00
ld de, wDebugWhiteTileColor
call DebugColor_PrintHexColor
2015-11-19 15:07:20 -08:00
hlcoord 6, 0
2020-10-23 13:04:15 -07:00
ld de, wDebugLightTileColor
call DebugColor_PrintHexColor
2015-11-19 15:07:20 -08:00
hlcoord 11, 0
2020-10-23 13:04:15 -07:00
ld de, wDebugDarkTileColor
call DebugColor_PrintHexColor
2015-11-19 15:07:20 -08:00
hlcoord 16, 0
2020-10-23 13:04:15 -07:00
ld de, wDebugBlackTileColor
call DebugColor_PrintHexColor
2015-11-19 15:07:20 -08:00
pop af
ldh [rSVBK], a
2020-08-03 14:41:01 -07:00
ld a, TRUE
ldh [hCGBPalUpdate], a
2015-11-19 15:07:20 -08:00
call DelayFrame
ret
DebugTileset_Joypad:
2020-10-23 13:04:15 -07:00
ld a, [wDebugTilesetRGBJumptableIndex]
maskbits 4 ; .PointerTable length
2015-11-19 15:07:20 -08:00
ld e, a
ld d, 0
2020-10-06 10:50:02 -07:00
ld hl, .PointerTable
2015-11-19 15:07:20 -08:00
add hl, de
add hl, de
2015-11-19 15:07:20 -08:00
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
2015-11-19 15:07:20 -08:00
2020-10-06 10:50:02 -07:00
.PointerTable:
dw DebugTileset_SelectColorBox
dw DebugTileset_ChangeRedValue
dw DebugTileset_ChangeGreenValue
dw DebugTileset_ChangeBlueValue
2015-11-19 15:07:20 -08:00
DebugTileset_SelectColorBox:
2015-11-19 15:07:20 -08:00
ld hl, hJoyLast
ld a, [hl]
and D_DOWN
jr nz, DebugTileset_NextRGBColor
2015-11-19 15:07:20 -08:00
ld a, [hl]
and D_LEFT
2020-10-06 10:50:02 -07:00
jr nz, .left
2015-11-19 15:07:20 -08:00
ld a, [hl]
and D_RIGHT
2020-10-06 10:50:02 -07:00
jr nz, .right
2015-11-19 15:07:20 -08:00
ret
2020-10-06 10:50:02 -07:00
.left
2020-10-23 13:04:15 -07:00
ld a, [wDebugTilesetCurColor]
2015-11-19 15:07:20 -08:00
dec a
2020-10-06 10:50:02 -07:00
jr .done
2015-11-19 15:07:20 -08:00
2020-10-06 10:50:02 -07:00
.right
2020-10-23 13:04:15 -07:00
ld a, [wDebugTilesetCurColor]
2015-11-19 15:07:20 -08:00
inc a
2020-10-06 10:50:02 -07:00
.done
2020-10-23 13:04:15 -07:00
maskbits NUM_PAL_COLORS
ld [wDebugTilesetCurColor], a
2015-11-19 15:07:20 -08:00
ld e, a
2020-10-06 10:50:02 -07:00
ld d, 0
2020-10-23 13:04:15 -07:00
ld hl, wDebugPalette
2015-11-19 15:07:20 -08:00
add hl, de
add hl, de
2015-11-19 15:07:20 -08:00
ld e, l
ld d, h
2020-10-06 10:50:02 -07:00
call DebugColor_CalculateRGB
2015-11-19 15:07:20 -08:00
ret
DebugTileset_ChangeRedValue:
2015-11-19 15:07:20 -08:00
ld hl, hJoyLast
ld a, [hl]
and D_DOWN
jr nz, DebugTileset_NextRGBColor
2015-11-19 15:07:20 -08:00
ld a, [hl]
and D_UP
jr nz, DebugTileset_PreviousRGBColor
2020-10-23 13:04:15 -07:00
ld hl, wDebugRedChannel
jr DebugTileset_UpdateRGBColor
2015-11-19 15:07:20 -08:00
DebugTileset_ChangeGreenValue:
2015-11-19 15:07:20 -08:00
ld hl, hJoyLast
ld a, [hl]
and D_DOWN
jr nz, DebugTileset_NextRGBColor
2015-11-19 15:07:20 -08:00
ld a, [hl]
and D_UP
jr nz, DebugTileset_PreviousRGBColor
2020-10-23 13:04:15 -07:00
ld hl, wDebugGreenChannel
jr DebugTileset_UpdateRGBColor
2015-11-19 15:07:20 -08:00
DebugTileset_ChangeBlueValue:
2015-11-19 15:07:20 -08:00
ld hl, hJoyLast
ld a, [hl]
and D_UP
jr nz, DebugTileset_PreviousRGBColor
2020-10-23 13:04:15 -07:00
ld hl, wDebugBlueChannel
; fallthrough
2015-11-19 15:07:20 -08:00
DebugTileset_UpdateRGBColor:
ldh a, [hJoyLast]
2015-11-19 15:07:20 -08:00
and D_RIGHT
jr nz, .increment
ldh a, [hJoyLast]
2015-11-19 15:07:20 -08:00
and D_LEFT
jr nz, .decrement
2015-11-19 15:07:20 -08:00
ret
.increment
2015-11-19 15:07:20 -08:00
ld a, [hl]
2020-10-06 10:50:02 -07:00
cp 31
2015-11-19 15:07:20 -08:00
ret nc
inc [hl]
2020-10-06 10:50:02 -07:00
jr .done
2015-11-19 15:07:20 -08:00
.decrement
2015-11-19 15:07:20 -08:00
ld a, [hl]
and a
ret z
dec [hl]
2020-10-06 10:50:02 -07:00
.done
call DebugTileset_CalculatePalette
call DebugTileset_UpdatePalettes
2015-11-19 15:07:20 -08:00
ret
DebugTileset_PreviousRGBColor:
2020-10-23 13:04:15 -07:00
ld hl, wDebugTilesetRGBJumptableIndex
2015-11-19 15:07:20 -08:00
dec [hl]
ret
DebugTileset_NextRGBColor:
2020-10-23 13:04:15 -07:00
ld hl, wDebugTilesetRGBJumptableIndex
2015-11-19 15:07:20 -08:00
inc [hl]
ret
DebugTileset_CalculatePalette:
2020-10-23 13:04:15 -07:00
ld a, [wDebugRedChannel]
2020-10-06 10:50:02 -07:00
and %00011111
2015-11-19 15:07:20 -08:00
ld e, a
2020-10-23 13:04:15 -07:00
ld a, [wDebugGreenChannel]
2020-10-06 10:50:02 -07:00
and %0000111
2015-11-19 15:07:20 -08:00
sla a
swap a
or e
ld e, a
2020-10-23 13:04:15 -07:00
ld a, [wDebugGreenChannel]
2020-10-06 10:50:02 -07:00
and %00011000
2015-11-19 15:07:20 -08:00
sla a
swap a
ld d, a
2020-10-23 13:04:15 -07:00
ld a, [wDebugBlueChannel]
2020-10-06 10:50:02 -07:00
and %00011111
2015-11-19 15:07:20 -08:00
sla a
sla a
or d
ld d, a
2020-10-23 13:04:15 -07:00
ld a, [wDebugTilesetCurColor]
2015-11-19 15:07:20 -08:00
ld c, a
2020-10-06 10:50:02 -07:00
ld b, 0
2020-10-23 13:04:15 -07:00
ld hl, wDebugPalette
2015-11-19 15:07:20 -08:00
add hl, bc
add hl, bc
2015-11-19 15:07:20 -08:00
ld a, e
ld [hli], a
ld [hl], d
ret
.dummy1: ; unreferenced
2015-11-19 15:07:20 -08:00
ret
.dummy2: ; unreferenced
2015-11-19 15:07:20 -08:00
ret