pokecrystal/engine/debug/color_picker.asm

1453 lines
21 KiB
NASM
Raw Normal View History

; DebugColor_GFX tile IDs
2018-01-31 16:38:45 +00: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
2020-10-06 17:50:02 +00:00
DebugColorPicker:
2015-11-19 23:07:20 +00:00
; A debug menu to test monster and trainer palettes at runtime.
ldh a, [hCGB]
2015-11-19 23:07:20 +00:00
and a
2020-10-06 17:50:02 +00:00
jr nz, .cgb
ldh a, [hSGB]
2015-11-19 23:07:20 +00:00
and a
ret z
2020-10-06 17:50:02 +00:00
.cgb
ldh a, [hInMenu]
2015-11-19 23:07:20 +00:00
push af
ld a, TRUE
ldh [hInMenu], a
2015-11-19 23:07:20 +00:00
call DisableLCD
2020-10-06 17:50:02 +00:00
call DebugColor_InitVRAM
call DebugColor_LoadGFX
call DebugColor_InitPalettes
call DebugColor_InitMonOrTrainerColor
2015-11-19 23:07:20 +00:00
call EnableLCD
ld de, MUSIC_NONE
call PlayMusic
xor a ; DEBUGCOLORMAIN_INITSCREEN
2015-11-19 23:07:20 +00:00
ld [wJumptableIndex], a
ld [wcf66], a
ld [wd003], a
2020-10-06 17:50:02 +00:00
.loop
2015-11-19 23:07:20 +00:00
ld a, [wJumptableIndex]
bit 7, a
2020-10-06 17:50:02 +00:00
jr nz, .exit
call DebugColorMain
call DebugColor_PlaceCursor
2015-11-19 23:07:20 +00:00
call DelayFrame
2020-10-06 17:50:02 +00:00
jr .loop
2015-11-19 23:07:20 +00:00
2020-10-06 17:50:02 +00:00
.exit
2015-11-19 23:07:20 +00:00
pop af
ldh [hInMenu], a
2015-11-19 23:07:20 +00:00
ret
DebugColor_InitMonOrTrainerColor:
2015-11-19 23:07:20 +00:00
ld a, [wd002]
and a
2020-10-06 17:50:02 +00:00
jr nz, DebugColor_InitTrainerColor
2015-11-19 23:07:20 +00:00
ld hl, PokemonPalettes
; fallthrough
2015-11-19 23:07:20 +00:00
DebugColor_InitMonColor:
ld de, wOverworldMapBlocks
2015-11-19 23:07:20 +00:00
ld c, NUM_POKEMON + 1
2020-10-06 17:50:02 +00:00
.loop
2015-11-19 23:07:20 +00:00
push bc
push hl
2020-10-06 17:50:02 +00:00
call DebugColor_InitColor
2015-11-19 23:07:20 +00:00
pop hl
ld bc, 8
add hl, bc
pop bc
dec c
2020-10-06 17:50:02 +00:00
jr nz, .loop
2015-11-19 23:07:20 +00:00
ret
2020-10-06 17:50:02 +00:00
DebugColor_InitTrainerColor:
2015-11-19 23:07:20 +00:00
ld hl, TrainerPalettes
ld de, wOverworldMapBlocks
2015-11-19 23:07:20 +00:00
ld c, NUM_TRAINER_CLASSES
2020-10-06 17:50:02 +00:00
.loop
2015-11-19 23:07:20 +00:00
push bc
push hl
2020-10-06 17:50:02 +00:00
call DebugColor_InitColor
2015-11-19 23:07:20 +00:00
pop hl
ld bc, 4
add hl, bc
pop bc
dec c
2020-10-06 17:50:02 +00:00
jr nz, .loop
2015-11-19 23:07:20 +00:00
ret
2020-10-06 17:50:02 +00:00
DebugColor_InitColor:
ld a, BANK(PokemonPalettes) ; aka BANK(TrainerPalettes)
2015-11-19 23:07:20 +00:00
call GetFarByte
ld [de], a
inc de
inc hl
2020-10-06 17:50:02 +00:00
ld a, BANK(PokemonPalettes) ; aka BANK(TrainerPalettes)
2015-11-19 23:07:20 +00:00
call GetFarByte
ld [de], a
inc de
inc hl
2020-10-06 17:50:02 +00:00
ld a, BANK(PokemonPalettes) ; aka BANK(TrainerPalettes)
2015-11-19 23:07:20 +00:00
call GetFarByte
ld [de], a
inc de
inc hl
2020-10-06 17:50:02 +00:00
ld a, BANK(PokemonPalettes) ; aka BANK(TrainerPalettes)
2015-11-19 23:07:20 +00:00
call GetFarByte
ld [de], a
inc de
ret
2020-10-06 17:50:02 +00:00
DebugColor_InitVRAM:
ld a, BANK(vTiles3)
ldh [rVBK], a
2020-10-06 17:50:02 +00:00
ld hl, vTiles3
ld bc, sScratch - vTiles3
2015-11-19 23:07:20 +00:00
xor a
call ByteFill
2020-10-06 17:50:02 +00:00
ld a, BANK(vTiles0)
ldh [rVBK], a
2017-12-28 12:32:33 +00:00
ld hl, vTiles0
ld bc, sScratch - vTiles0
2015-11-19 23:07:20 +00:00
xor a
call ByteFill
2020-10-06 17:50:02 +00:00
hlcoord 0, 0, wAttrmap
2015-11-19 23:07:20 +00:00
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
xor a
call ByteFill
2020-10-06 17:50:02 +00:00
2015-11-19 23:07:20 +00:00
hlcoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
xor a
call ByteFill
2020-10-06 17:50:02 +00:00
2015-11-19 23:07:20 +00:00
call ClearSprites
ret
2020-10-06 17:50:02 +00:00
DebugColor_LoadGFX:
ld hl, DebugColor_GFX
ld de, vTiles2 tile DEBUGTEST_TICKS_1
ld bc, 22 tiles
2015-11-19 23:07:20 +00:00
call CopyBytes
2020-10-06 17:50:02 +00:00
ld hl, DebugColor_UpArrowGFX
2017-12-28 12:32:33 +00:00
ld de, vTiles0
ld bc, 1 tiles
2015-11-19 23:07:20 +00:00
call CopyBytes
2020-10-06 17:50:02 +00:00
; Invert the font colors.
2015-11-19 23:07:20 +00:00
call LoadStandardFont
2017-12-28 12:32:33 +00:00
ld hl, vTiles1
2020-10-06 17:50:02 +00:00
ld bc, $80 tiles
.loop
2015-11-19 23:07:20 +00:00
ld a, [hl]
xor $ff
ld [hli], a
dec bc
ld a, c
or b
2020-10-06 17:50:02 +00:00
jr nz, .loop
2015-11-19 23:07:20 +00:00
ret
2020-10-06 17:50:02 +00:00
DebugColor_InitPalettes:
ldh a, [hCGB]
2015-11-19 23:07:20 +00:00
and a
ret z
2020-10-06 17:50:02 +00:00
ldh a, [rSVBK]
2015-11-19 23:07:20 +00:00
push af
ld a, BANK(wBGPals2)
ldh [rSVBK], a
2020-10-06 17:50:02 +00:00
2018-03-03 00:39:16 +00:00
ld hl, Palette_DebugBG
2018-01-01 14:08:21 +00:00
ld de, wBGPals2
2017-12-16 03:36:33 +00:00
ld bc, 16 palettes
2015-11-19 23:07:20 +00:00
call CopyBytes
2020-10-06 17:50:02 +00:00
ld a, 1 << rBGPI_AUTO_INCREMENT
ldh [rBGPI], a
2018-03-03 00:39:16 +00:00
ld hl, Palette_DebugBG
ld c, 8 palettes
2015-11-19 23:07:20 +00:00
xor a
2020-10-06 17:50:02 +00:00
.bg_loop
ldh [rBGPD], a
2015-11-19 23:07:20 +00:00
dec c
2020-10-06 17:50:02 +00:00
jr nz, .bg_loop
ld a, 1 << rOBPI_AUTO_INCREMENT
ldh [rOBPI], a
2018-03-03 00:39:16 +00:00
ld hl, Palette_DebugOB
ld c, 8 palettes
2020-10-06 17:50:02 +00:00
.ob_loop
2015-11-19 23:07:20 +00:00
ld a, [hli]
ldh [rOBPD], a
2015-11-19 23:07:20 +00:00
dec c
2020-10-06 17:50:02 +00:00
jr nz, .ob_loop
2015-11-19 23:07:20 +00:00
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
2020-10-06 17:50:02 +00:00
2015-11-19 23:07:20 +00:00
pop af
ldh [rSVBK], a
2015-11-19 23:07:20 +00:00
ret
2018-06-24 14:09:41 +00:00
Palette_DebugBG:
INCLUDE "gfx/debug/bg.pal"
2015-11-19 23:07:20 +00:00
2018-06-24 14:09:41 +00:00
Palette_DebugOB:
INCLUDE "gfx/debug/ob.pal"
2015-11-19 23:07:20 +00:00
2020-10-06 17:50:02 +00:00
DebugColorMain:
2015-11-19 23:07:20 +00:00
call JoyTextDelay
ld a, [wJumptableIndex]
cp DEBUGCOLORMAIN_INITTMHM
2020-10-22 16:55:46 +00:00
jr nc, .no_start_select
2015-11-19 23:07:20 +00:00
ld hl, hJoyLast
ld a, [hl]
and SELECT
2020-10-06 17:50:02 +00:00
jr nz, .NextMon
2015-11-19 23:07:20 +00:00
ld a, [hl]
and START
2020-10-06 17:50:02 +00:00
jr nz, .PreviousMon
2015-11-19 23:07:20 +00:00
2020-10-22 16:55:46 +00:00
.no_start_select
jumptable .Jumptable, wJumptableIndex
2015-11-19 23:07:20 +00:00
.NextMon:
2020-10-06 17:50:02 +00:00
call DebugColor_BackupSpriteColors
call .SetMaxNum
2015-11-19 23:07:20 +00:00
ld e, a
ld a, [wcf66]
inc a
cp e
2020-10-06 17:50:02 +00:00
jr c, .SwitchMon
2015-11-19 23:07:20 +00:00
xor a
2020-10-06 17:50:02 +00:00
jr .SwitchMon
2015-11-19 23:07:20 +00:00
.PreviousMon:
2020-10-06 17:50:02 +00:00
call DebugColor_BackupSpriteColors
2015-11-19 23:07:20 +00:00
ld a, [wcf66]
dec a
2020-10-06 17:50:02 +00:00
cp -1
jr nz, .SwitchMon
call .SetMaxNum
2015-11-19 23:07:20 +00:00
dec a
.SwitchMon:
2015-11-19 23:07:20 +00:00
ld [wcf66], a
ld a, DEBUGCOLORMAIN_INITSCREEN
2015-11-19 23:07:20 +00:00
ld [wJumptableIndex], a
ret
.SetMaxNum:
2015-11-19 23:07:20 +00:00
; Looping back around the pic set.
ld a, [wd002]
and a
2020-10-06 17:50:02 +00:00
jr nz, .trainer
; mon
2015-11-19 23:07:20 +00:00
ld a, NUM_POKEMON ; CELEBI
ret
2020-10-06 17:50:02 +00:00
.trainer
2015-11-19 23:07:20 +00:00
ld a, NUM_TRAINER_CLASSES - 1 ; MYSTICALMAN
ret
.Jumptable:
; entries correspond to DEBUGCOLORMAIN_* constants
2020-10-06 17:50:02 +00:00
dw DebugColor_InitScreen
dw DebugColor_UpdateScreen
dw DebugColor_UpdatePalettes
dw DebugColor_Joypad
dw DebugColor_InitTMHM
dw DebugColor_TMHMJoypad
2015-11-19 23:07:20 +00:00
2020-10-06 17:50:02 +00:00
DebugColor_InitScreen:
2015-11-19 23:07:20 +00:00
xor a
ldh [hBGMapMode], a
2015-11-19 23:07:20 +00:00
hlcoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
ld a, DEBUGTEST_BLACK
2015-11-19 23:07:20 +00:00
call ByteFill
hlcoord 1, 3
lb bc, 7, 18
ld a, DEBUGTEST_WHITE
call DebugColor_FillBoxWithByte
2015-11-19 23:07:20 +00:00
hlcoord 11, 0
lb bc, 2, 3
ld a, DEBUGTEST_LIGHT
call DebugColor_FillBoxWithByte
2015-11-19 23:07:20 +00:00
hlcoord 16, 0
lb bc, 2, 3
ld a, DEBUGTEST_DARK
call DebugColor_FillBoxWithByte
2020-10-06 17:50:02 +00:00
call DebugColor_LoadRGBMeter
call DebugColor_SetRGBMeter
2015-11-19 23:07:20 +00:00
ld a, [wcf66]
inc a
2018-01-23 22:39:09 +00:00
ld [wCurPartySpecies], a
ld [wDeciramBuffer], a
2015-11-19 23:07:20 +00:00
hlcoord 0, 1
ld de, wDeciramBuffer
2015-11-19 23:07:20 +00:00
lb bc, PRINTNUM_LEADINGZEROS | 1, 3
call PrintNum
ld a, [wd002]
and a
2020-10-06 17:50:02 +00:00
jr nz, .trainer
; mon
2020-10-06 17:50:02 +00:00
ld a, UNOWN_A
2018-01-23 22:39:09 +00:00
ld [wUnownLetter], a
2015-11-19 23:07:20 +00:00
call GetPokemonName
hlcoord 4, 1
call PlaceString
xor a
ld [wBoxAlignment], a
2015-11-19 23:07:20 +00:00
hlcoord 12, 3
call _PrepMonFrontpic
2017-12-28 12:32:33 +00:00
ld de, vTiles2 tile $31
predef GetMonBackpic
2015-11-19 23:07:20 +00:00
ld a, $31
ldh [hGraphicStartTile], a
2015-11-19 23:07:20 +00:00
hlcoord 2, 4
lb bc, 6, 6
predef PlaceGraphic
2020-10-06 17:50:02 +00:00
2015-11-19 23:07:20 +00:00
ld a, [wd003]
and a
jr z, .normal
; shiny
ld de, .ShinyText
jr .place_text
.normal
ld de, .NormalText
.place_text
2015-11-19 23:07:20 +00:00
hlcoord 7, 17
call PlaceString
hlcoord 0, 17
ld de, .SwitchText
2015-11-19 23:07:20 +00:00
call PlaceString
2020-10-06 17:50:02 +00:00
jr .done
2015-11-19 23:07:20 +00:00
2020-10-06 17:50:02 +00:00
.trainer
ld a, [wDeciramBuffer]
2018-01-23 22:39:09 +00:00
ld [wTrainerClass], a
2017-12-24 17:47:30 +00:00
callfar GetTrainerAttributes
2018-01-23 22:39:09 +00:00
ld de, wStringBuffer1
2015-11-19 23:07:20 +00:00
hlcoord 4, 1
call PlaceString
2017-12-28 12:32:33 +00:00
ld de, vTiles2
callfar GetTrainerPic
2015-11-19 23:07:20 +00:00
xor a
2018-01-23 22:39:09 +00:00
ld [wTempEnemyMonSpecies], a
ldh [hGraphicStartTile], a
2015-11-19 23:07:20 +00:00
hlcoord 2, 3
lb bc, 7, 7
predef PlaceGraphic
2015-11-19 23:07:20 +00:00
2020-10-06 17:50:02 +00:00
.done
ld a, DEBUGCOLORMAIN_UPDATESCREEN
2015-11-19 23:07:20 +00:00
ld [wJumptableIndex], a
ret
.ShinyText:
2020-10-06 17:50:02 +00:00
db "レア", DEBUGTEST_BLACK, DEBUGTEST_BLACK, "@" ; Rare (shiny)
2015-11-19 23:07:20 +00:00
.NormalText:
2020-10-06 17:50:02 +00:00
db "ノーマル@" ; Normal
.SwitchText:
2020-10-06 17:50:02 +00:00
db DEBUGTEST_A, "きりかえ▶@" ; (A) Switches
DebugColor_LoadRGBMeter:
decoord 0, 11, wAttrmap
2015-11-19 23:07:20 +00:00
hlcoord 2, 11
ld a, 1
call .load_meter
decoord 0, 13, wAttrmap
2015-11-19 23:07:20 +00:00
hlcoord 2, 13
ld a, 2
call .load_meter
decoord 0, 15, wAttrmap
2015-11-19 23:07:20 +00:00
hlcoord 2, 15
ld a, 3
.load_meter:
2015-11-19 23:07:20 +00:00
push af
ld a, DEBUGTEST_TICKS_1
2015-11-19 23:07:20 +00:00
ld [hli], a
2020-10-06 17:50:02 +00:00
ld bc, 15
ld a, DEBUGTEST_TICKS_2
2015-11-19 23:07:20 +00:00
call ByteFill
ld l, e
ld h, d
pop af
2020-10-06 17:50:02 +00:00
ld bc, 20 * 2
2015-11-19 23:07:20 +00:00
call ByteFill
ret
2020-10-06 17:50:02 +00:00
DebugColor_SetRGBMeter:
2015-11-19 23:07:20 +00:00
ld a, [wcf66]
inc a
ld l, a
2020-10-06 17:50:02 +00:00
ld h, 0
2015-11-19 23:07:20 +00:00
add hl, hl
add hl, hl
ld de, wOverworldMapBlocks
2015-11-19 23:07:20 +00:00
add hl, de
ld de, wc608
ld bc, 4
call CopyBytes
xor a
ld [wcf64], a
ld [wcf65], a
ld de, wc608
2020-10-06 17:50:02 +00:00
call DebugColor_CalculateRGB
2015-11-19 23:07:20 +00:00
ret
DebugColor_UpdateScreen:
ldh a, [hCGB]
2015-11-19 23:07:20 +00:00
and a
2020-10-06 17:50:02 +00:00
jr z, .sgb
2020-10-06 17:50:02 +00:00
ld a, 2
ldh [hBGMapMode], a
2015-11-19 23:07:20 +00:00
call DelayFrame
call DelayFrame
call DelayFrame
2020-10-06 17:50:02 +00:00
.sgb
2015-11-19 23:07:20 +00:00
call WaitBGMap
ld a, DEBUGCOLORMAIN_UPDATEPALETTES
2015-11-19 23:07:20 +00:00
ld [wJumptableIndex], a
ret
DebugColor_UpdatePalettes:
ldh a, [hCGB]
2015-11-19 23:07:20 +00:00
and a
2020-10-06 17:50:02 +00:00
jr z, .sgb
; cgb
ldh a, [rSVBK]
2015-11-19 23:07:20 +00:00
push af
ld a, BANK(wBGPals2)
ldh [rSVBK], a
2020-10-06 17:50:02 +00:00
2018-01-01 14:08:21 +00:00
ld hl, wBGPals2
2015-11-19 23:07:20 +00:00
ld de, wc608
ld c, 1
call DebugColor_LoadPalettes_White_Col1_Col2_Black
2015-11-19 23:07:20 +00:00
hlcoord 10, 2
ld de, wc608
call DebugColor_PrintHexColor
2015-11-19 23:07:20 +00:00
hlcoord 15, 2
ld de, wc608 + 2
call DebugColor_PrintHexColor
2020-08-03 21:41:01 +00:00
ld a, TRUE
ldh [hCGBPalUpdate], a
2020-10-06 17:50:02 +00:00
ld a, DEBUGCOLORMAIN_JOYPAD
2015-11-19 23:07:20 +00:00
ld [wJumptableIndex], a
2020-10-06 17:50:02 +00:00
2015-11-19 23:07:20 +00:00
pop af
ldh [rSVBK], a
2015-11-19 23:07:20 +00:00
ret
2020-10-06 17:50:02 +00:00
.sgb
ld hl, wSGBPals
ld a, 1
2015-11-19 23:07:20 +00:00
ld [hli], a
ld a, LOW(PALRGB_WHITE)
2015-11-19 23:07:20 +00:00
ld [hli], a
ld a, HIGH(PALRGB_WHITE)
2015-11-19 23:07:20 +00:00
ld [hli], a
ld a, [wc608]
ld [hli], a
ld a, [wc608 + 1]
ld [hli], a
ld a, [wc608 + 2]
ld [hli], a
ld a, [wc608 + 3]
ld [hli], a
xor a
ld [hli], a
ld [hli], a
2015-11-19 23:07:20 +00:00
ld [hl], a
ld hl, wSGBPals
call DebugColor_PushSGBPals
2015-11-19 23:07:20 +00:00
hlcoord 10, 2
ld de, wc608
call DebugColor_PrintHexColor
2015-11-19 23:07:20 +00:00
hlcoord 15, 2
ld de, wc608 + 2
call DebugColor_PrintHexColor
2020-10-06 17:50:02 +00:00
ld a, DEBUGCOLORMAIN_JOYPAD
2015-11-19 23:07:20 +00:00
ld [wJumptableIndex], a
ret
DebugColor_PrintHexColor:
2015-11-19 23:07:20 +00:00
inc hl
inc hl
inc hl
2015-11-19 23:07:20 +00:00
ld a, [de]
call .place_tile
2015-11-19 23:07:20 +00:00
ld a, [de]
swap a
call .place_tile
2015-11-19 23:07:20 +00:00
inc de
ld a, [de]
call .place_tile
2015-11-19 23:07:20 +00:00
ld a, [de]
swap a
.place_tile:
2015-11-19 23:07:20 +00:00
and $f
add DEBUGTEST_0
2015-11-19 23:07:20 +00:00
ld [hld], a
ret
DebugColor_Joypad:
ldh a, [hJoyLast]
2015-11-19 23:07:20 +00:00
and B_BUTTON
jr nz, .tmhm
ldh a, [hJoyLast]
2015-11-19 23:07:20 +00:00
and A_BUTTON
jr nz, .toggle_shiny
2015-11-19 23:07:20 +00:00
ld a, [wcf64]
maskbits 4 ; .PointerTable length
2015-11-19 23:07:20 +00:00
ld e, a
ld d, 0
ld hl, .PointerTable
2015-11-19 23:07:20 +00:00
add hl, de
add hl, de
2015-11-19 23:07:20 +00:00
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
2015-11-19 23:07:20 +00:00
.tmhm
; Enter the TM/HM checker.
ld a, DEBUGCOLORMAIN_INITTMHM
2015-11-19 23:07:20 +00:00
ld [wJumptableIndex], a
ret
.toggle_shiny
; Toggle between the normal and shiny mon colors.
2015-11-19 23:07:20 +00:00
ld a, [wd002]
and a
ret nz
2015-11-19 23:07:20 +00:00
ld a, [wd003]
2020-10-06 17:50:02 +00:00
xor %00000100
2015-11-19 23:07:20 +00:00
ld [wd003], a
ld c, a
ld b, 0
ld hl, PokemonPalettes
add hl, bc
call DebugColor_InitMonColor
ld a, DEBUGCOLORMAIN_INITSCREEN
2015-11-19 23:07:20 +00:00
ld [wJumptableIndex], a
ret
.PointerTable:
2020-10-06 17:50:02 +00:00
dw DebugColor_SelectColorBox
dw DebugColor_ChangeRedValue
dw DebugColor_ChangeGreenValue
dw DebugColor_ChangeBlueValue
2015-11-19 23:07:20 +00:00
2020-10-06 17:50:02 +00:00
DebugColor_SelectColorBox:
2015-11-19 23:07:20 +00:00
ld hl, hJoyLast
ld a, [hl]
and D_DOWN
2020-10-06 17:50:02 +00:00
jr nz, DebugColor_NextRGBColor
2015-11-19 23:07:20 +00:00
ld a, [hl]
and D_LEFT
jr nz, .light
2015-11-19 23:07:20 +00:00
ld a, [hl]
and D_RIGHT
jr nz, .dark
2015-11-19 23:07:20 +00:00
ret
.light
2015-11-19 23:07:20 +00:00
xor a
ld [wcf65], a
ld de, wc608
2020-10-06 17:50:02 +00:00
call DebugColor_CalculateRGB
2015-11-19 23:07:20 +00:00
ret
.dark
ld a, TRUE
2015-11-19 23:07:20 +00:00
ld [wcf65], a
ld de, wc608 + 2
2020-10-06 17:50:02 +00:00
call DebugColor_CalculateRGB
2015-11-19 23:07:20 +00:00
ret
2020-10-06 17:50:02 +00:00
DebugColor_ChangeRedValue:
2015-11-19 23:07:20 +00:00
ld hl, hJoyLast
ld a, [hl]
and D_DOWN
2020-10-06 17:50:02 +00:00
jr nz, DebugColor_NextRGBColor
2015-11-19 23:07:20 +00:00
ld a, [hl]
and D_UP
2020-10-06 17:50:02 +00:00
jr nz, DebugColor_PreviousRGBColor
2015-11-19 23:07:20 +00:00
ld hl, wc608 + 10
jr DebugColor_UpdateRGBColor
2015-11-19 23:07:20 +00:00
2020-10-06 17:50:02 +00:00
DebugColor_ChangeGreenValue:
2015-11-19 23:07:20 +00:00
ld hl, hJoyLast
ld a, [hl]
and D_DOWN
2020-10-06 17:50:02 +00:00
jr nz, DebugColor_NextRGBColor
2015-11-19 23:07:20 +00:00
ld a, [hl]
and D_UP
2020-10-06 17:50:02 +00:00
jr nz, DebugColor_PreviousRGBColor
2015-11-19 23:07:20 +00:00
ld hl, wc608 + 11
jr DebugColor_UpdateRGBColor
2015-11-19 23:07:20 +00:00
2020-10-06 17:50:02 +00:00
DebugColor_ChangeBlueValue:
2015-11-19 23:07:20 +00:00
ld hl, hJoyLast
ld a, [hl]
and D_UP
2020-10-06 17:50:02 +00:00
jr nz, DebugColor_PreviousRGBColor
2015-11-19 23:07:20 +00:00
ld hl, wc608 + 12
DebugColor_UpdateRGBColor:
ldh a, [hJoyLast]
2015-11-19 23:07:20 +00:00
and D_RIGHT
jr nz, .increment
ldh a, [hJoyLast]
2015-11-19 23:07:20 +00:00
and D_LEFT
jr nz, .decrement
2015-11-19 23:07:20 +00:00
ret
.increment
2015-11-19 23:07:20 +00:00
ld a, [hl]
2020-10-06 17:50:02 +00:00
cp 31
2015-11-19 23:07:20 +00:00
ret nc
inc [hl]
2020-10-06 17:50:02 +00:00
jr .done
2015-11-19 23:07:20 +00:00
.decrement
2015-11-19 23:07:20 +00:00
ld a, [hl]
and a
ret z
dec [hl]
.done
2020-10-06 17:50:02 +00:00
call DebugColor_CalculatePalette
ld a, DEBUGCOLORMAIN_UPDATEPALETTES
2015-11-19 23:07:20 +00:00
ld [wJumptableIndex], a
ret
2020-10-06 17:50:02 +00:00
DebugColor_PreviousRGBColor:
2015-11-19 23:07:20 +00:00
ld hl, wcf64
dec [hl]
ret
2020-10-06 17:50:02 +00:00
DebugColor_NextRGBColor:
2015-11-19 23:07:20 +00:00
ld hl, wcf64
inc [hl]
ret
DebugColor_InitTMHM:
2015-11-19 23:07:20 +00:00
hlcoord 0, 10
2020-10-06 17:50:02 +00:00
ld bc, SCREEN_WIDTH * 8
ld a, DEBUGTEST_BLACK
2015-11-19 23:07:20 +00:00
call ByteFill
hlcoord 2, 12
2020-10-06 17:50:02 +00:00
ld de, DebugColor_AreYouFinishedString
2015-11-19 23:07:20 +00:00
call PlaceString
xor a
ld [wd004], a
call DebugColor_PrintTMHMMove
ld a, DEBUGCOLORMAIN_TMHMJOYPAD
2015-11-19 23:07:20 +00:00
ld [wJumptableIndex], a
ret
DebugColor_TMHMJoypad:
2015-11-19 23:07:20 +00:00
ld hl, hJoyPressed
ld a, [hl]
and B_BUTTON
2020-10-06 17:50:02 +00:00
jr nz, .cancel
call .scroll
2015-11-19 23:07:20 +00:00
ret
2020-10-06 17:50:02 +00:00
.cancel
ld a, DEBUGCOLORMAIN_INITSCREEN
2015-11-19 23:07:20 +00:00
ld [wJumptableIndex], a
ret
2020-10-06 17:50:02 +00:00
.exit ; unreferenced
2015-11-19 23:07:20 +00:00
ld hl, wJumptableIndex
set 7, [hl]
ret
.scroll:
2015-11-19 23:07:20 +00:00
ld hl, hJoyLast
ld a, [hl]
and D_UP
2020-10-06 17:50:02 +00:00
jr nz, .up
2015-11-19 23:07:20 +00:00
ld a, [hl]
and D_DOWN
2020-10-06 17:50:02 +00:00
jr nz, .down
2015-11-19 23:07:20 +00:00
ret
2020-10-06 17:50:02 +00:00
.up
2015-11-19 23:07:20 +00:00
ld a, [wd004]
2020-10-06 17:50:02 +00:00
cp NUM_TM_HM_TUTOR - 1
jr z, .wrap_down
2015-11-19 23:07:20 +00:00
inc a
2020-10-06 17:50:02 +00:00
jr .done
2015-11-19 23:07:20 +00:00
2020-10-06 17:50:02 +00:00
.wrap_down
2015-11-19 23:07:20 +00:00
xor a
2020-10-06 17:50:02 +00:00
jr .done
2015-11-19 23:07:20 +00:00
2020-10-06 17:50:02 +00:00
.down
2015-11-19 23:07:20 +00:00
ld a, [wd004]
and a
2020-10-06 17:50:02 +00:00
jr z, .wrap_up
2015-11-19 23:07:20 +00:00
dec a
2020-10-06 17:50:02 +00:00
jr .done
2015-11-19 23:07:20 +00:00
2020-10-06 17:50:02 +00:00
.wrap_up
ld a, NUM_TM_HM_TUTOR - 1
2015-11-19 23:07:20 +00:00
2020-10-06 17:50:02 +00:00
.done
2015-11-19 23:07:20 +00:00
ld [wd004], a
call DebugColor_PrintTMHMMove
2015-11-19 23:07:20 +00:00
ret
DebugColor_PrintTMHMMove:
2015-11-19 23:07:20 +00:00
hlcoord 10, 11
call .ClearRow
2015-11-19 23:07:20 +00:00
hlcoord 10, 12
call .ClearRow
2015-11-19 23:07:20 +00:00
hlcoord 10, 13
call .ClearRow
2015-11-19 23:07:20 +00:00
hlcoord 10, 14
call .ClearRow
2015-11-19 23:07:20 +00:00
ld a, [wd004]
inc a
ld [wTempTMHM], a
predef GetTMHMMove
ld a, [wTempTMHM]
ld [wPutativeTMHMMove], a
2015-11-19 23:07:20 +00:00
call GetMoveName
hlcoord 10, 12
call PlaceString
2015-11-19 23:07:20 +00:00
ld a, [wd004]
call .GetNumberedTMHM
2018-01-23 22:39:09 +00:00
ld [wCurItem], a
predef CanLearnTMHMMove
2015-11-19 23:07:20 +00:00
ld a, c
and a
ld de, .AbleText
2020-10-06 17:50:02 +00:00
jr nz, .place_string
ld de, .NotAbleText
2020-10-06 17:50:02 +00:00
.place_string
2015-11-19 23:07:20 +00:00
hlcoord 10, 14
call PlaceString
ret
.AbleText:
2020-10-06 17:50:02 +00:00
db "おぼえられる@" ; Learnable
.NotAbleText:
2020-10-06 17:50:02 +00:00
db "おぼえられない@" ; Not learnable
2015-11-19 23:07:20 +00:00
.GetNumberedTMHM:
2020-10-06 17:50:02 +00:00
cp NUM_TMS
jr c, .tm
; hm - skip two gap items
2015-11-19 23:07:20 +00:00
inc a
inc a
2020-10-06 17:50:02 +00:00
.tm
add TM01
2015-11-19 23:07:20 +00:00
ret
.ClearRow:
ld bc, 10
ld a, DEBUGTEST_BLACK
2015-11-19 23:07:20 +00:00
call ByteFill
ret
2020-10-06 17:50:02 +00:00
DebugColor_CalculatePalette:
2015-11-19 23:07:20 +00:00
ld a, [wc608 + 10]
2020-10-06 17:50:02 +00:00
and %00011111
2015-11-19 23:07:20 +00:00
ld e, a
ld a, [wc608 + 11]
2020-10-06 17:50:02 +00:00
and %00000111
2015-11-19 23:07:20 +00:00
sla a
swap a
or e
ld e, a
ld a, [wc608 + 11]
2020-10-06 17:50:02 +00:00
and %00011000
2015-11-19 23:07:20 +00:00
sla a
swap a
ld d, a
ld a, [wc608 + 12]
2020-10-06 17:50:02 +00:00
and %00011111
2015-11-19 23:07:20 +00:00
sla a
sla a
or d
ld d, a
ld a, [wcf65]
and a
jr z, .light
2020-10-06 17:50:02 +00:00
; dark
2015-11-19 23:07:20 +00:00
ld a, e
ld [wc608 + 2], a
ld a, d
ld [wc608 + 3], a
ret
.light
2015-11-19 23:07:20 +00:00
ld a, e
ld [wc608], a
ld a, d
ld [wc608 + 1], a
ret
2020-10-06 17:50:02 +00:00
DebugColor_CalculateRGB:
2015-11-19 23:07:20 +00:00
ld a, [de]
2020-10-06 17:50:02 +00:00
and %00011111
2015-11-19 23:07:20 +00:00
ld [wc608 + 10], a
ld a, [de]
2020-10-06 17:50:02 +00:00
and %11100000
2015-11-19 23:07:20 +00:00
swap a
srl a
ld b, a
inc de
ld a, [de]
2020-10-06 17:50:02 +00:00
and %00000011
2015-11-19 23:07:20 +00:00
swap a
srl a
or b
ld [wc608 + 11], a
ld a, [de]
2020-10-06 17:50:02 +00:00
and %01111100
2015-11-19 23:07:20 +00:00
srl a
srl a
ld [wc608 + 12], a
ret
2020-10-06 17:50:02 +00:00
DebugColor_BackupSpriteColors:
2015-11-19 23:07:20 +00:00
ld a, [wcf66]
inc a
ld l, a
2020-10-06 17:50:02 +00:00
ld h, 0
2015-11-19 23:07:20 +00:00
add hl, hl
add hl, hl
2020-10-06 17:50:02 +00:00
ld de, wOverworldMapBlocks ; MonPalette
2015-11-19 23:07:20 +00:00
add hl, de
ld e, l
ld d, h
ld hl, wc608
ld bc, 4
call CopyBytes
ret
DebugColor_LoadPalettes_White_Col1_Col2_Black:
2020-10-06 17:50:02 +00:00
.loop
ld a, LOW(PALRGB_WHITE)
2015-11-19 23:07:20 +00:00
ld [hli], a
ld a, HIGH(PALRGB_WHITE)
2015-11-19 23:07:20 +00:00
ld [hli], a
rept 4
2015-11-19 23:07:20 +00:00
ld a, [de]
inc de
ld [hli], a
endr
2015-11-19 23:07:20 +00:00
xor a
ld [hli], a
ld [hli], a
2015-11-19 23:07:20 +00:00
dec c
2020-10-06 17:50:02 +00:00
jr nz, .loop
2015-11-19 23:07:20 +00:00
ret
DebugColor_FillBoxWithByte:
2015-11-19 23:07:20 +00: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:
2015-11-19 23:07:20 +00:00
ld a, [wcfbe]
push af
set 7, a
ld [wcfbe], a
call _DebugColor_PushSGBPals
2015-11-19 23:07:20 +00:00
pop af
ld [wcfbe], a
ret
_DebugColor_PushSGBPals:
2015-11-19 23:07:20 +00:00
ld a, [hl]
and $7
ret z
ld b, a
2020-10-06 17:50:02 +00:00
.loop
2015-11-19 23:07:20 +00:00
push bc
xor a
ldh [rJOYP], a
2015-11-19 23:07:20 +00:00
ld a, $30
ldh [rJOYP], a
2015-11-19 23:07:20 +00:00
ld b, $10
2020-10-06 17:50:02 +00:00
.loop2
2015-11-19 23:07:20 +00:00
ld e, $8
ld a, [hli]
ld d, a
2020-10-06 17:50:02 +00:00
.loop3
2015-11-19 23:07:20 +00:00
bit 0, d
ld a, $10
2020-10-06 17:50:02 +00:00
jr nz, .okay
2015-11-19 23:07:20 +00:00
ld a, $20
2020-10-06 17:50:02 +00:00
.okay
ldh [rJOYP], a
2015-11-19 23:07:20 +00:00
ld a, $30
ldh [rJOYP], a
2015-11-19 23:07:20 +00:00
rr d
dec e
2020-10-06 17:50:02 +00:00
jr nz, .loop3
2015-11-19 23:07:20 +00:00
dec b
2020-10-06 17:50:02 +00:00
jr nz, .loop2
2015-11-19 23:07:20 +00:00
ld a, $20
ldh [rJOYP], a
2015-11-19 23:07:20 +00:00
ld a, $30
ldh [rJOYP], a
2015-11-19 23:07:20 +00:00
ld de, 7000
2020-10-06 17:50:02 +00:00
.wait
2015-11-19 23:07:20 +00:00
nop
nop
nop
dec de
ld a, d
or e
2020-10-06 17:50:02 +00:00
jr nz, .wait
2015-11-19 23:07:20 +00:00
pop bc
dec b
2020-10-06 17:50:02 +00:00
jr nz, .loop
2015-11-19 23:07:20 +00:00
ret
2020-10-06 17:50:02 +00:00
DebugColor_PlaceCursor:
ld a, DEBUGTEST_BLACK
2015-11-19 23:07:20 +00: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 23:07:20 +00:00
ld a, [wJumptableIndex]
cp DEBUGCOLORMAIN_JOYPAD
2020-10-06 17:50:02 +00:00
jr nz, .clearsprites
2015-11-19 23:07:20 +00:00
ld a, [wcf64]
and a
2020-10-22 16:55:46 +00:00
jr z, .place_cursor
2015-11-19 23:07:20 +00:00
dec a
hlcoord 1, 11
ld bc, 2 * SCREEN_WIDTH
call AddNTimes
2020-10-06 17:50:02 +00:00
ld [hl], "▶"
2015-11-19 23:07:20 +00:00
2020-10-22 16:55:46 +00:00
.place_cursor
2015-11-19 23:07:20 +00:00
ld a, [wcf65]
and a
jr z, .light
; dark
2015-11-19 23:07:20 +00:00
hlcoord 15, 0
2020-10-06 17:50:02 +00:00
jr .place
.light
2015-11-19 23:07:20 +00:00
hlcoord 10, 0
2020-10-06 17:50:02 +00:00
.place
ld [hl], "▶"
ld b, $70 ; initial tile id
ld c, 5 ; initial palette
ld hl, wVirtualOAM
2015-11-19 23:07:20 +00:00
ld de, wc608 + 10
2020-10-06 17:50:02 +00:00
call .placesprite
2015-11-19 23:07:20 +00:00
ld de, wc608 + 11
2020-10-06 17:50:02 +00:00
call .placesprite
2015-11-19 23:07:20 +00:00
ld de, wc608 + 12
2020-10-06 17:50:02 +00:00
call .placesprite
2015-11-19 23:07:20 +00:00
ret
.placesprite:
2015-11-19 23:07:20 +00:00
ld a, b
2018-01-10 18:47:57 +00:00
ld [hli], a ; y
2015-11-19 23:07:20 +00:00
ld a, [de]
add a
add a
2018-01-10 18:47:57 +00:00
add 3 * TILE_WIDTH
ld [hli], a ; x
2015-11-19 23:07:20 +00:00
xor a
2018-01-10 18:47:57 +00:00
ld [hli], a ; tile id
2015-11-19 23:07:20 +00:00
ld a, c
2018-01-10 18:47:57 +00:00
ld [hli], a ; attributes
ld a, 2 * TILE_WIDTH
2015-11-19 23:07:20 +00:00
add b
ld b, a
inc c
ret
.clearsprites:
2015-11-19 23:07:20 +00:00
call ClearSprites
ret
2020-10-06 17:50:02 +00: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 23:07:20 +00:00
db "@"
DebugColor_UpArrowGFX:
INCBIN "gfx/debug/up_arrow.2bpp"
2020-10-06 17:50:02 +00:00
DebugColor_GFX:
2015-11-19 23:07:20 +00:00
INCBIN "gfx/debug/color_test.2bpp"
TilesetColorPicker:
; A debug menu to test tileset palettes at runtime.
2020-10-06 17:50:02 +00:00
; dummied out
2015-11-19 23:07:20 +00:00
ret
2015-11-19 23:07:20 +00:00
xor a
ld [wJumptableIndex], a
ld [wcf64], a
ld [wcf65], a
ld [wcf66], a
ldh [hMapAnims], a
2015-11-19 23:07:20 +00:00
call ClearSprites
call OverworldTextModeSwitch
2015-12-11 21:59:40 +00:00
call WaitBGMap2
2015-11-19 23:07:20 +00:00
xor a
ldh [hBGMapMode], a
2020-10-06 17:50:02 +00:00
ld de, DebugColor_GFX
ld hl, vTiles2 tile DEBUGTEST_TICKS_1
2020-10-06 17:50:02 +00:00
lb bc, BANK(DebugColor_GFX), 22
2015-11-19 23:07:20 +00:00
call Request2bpp
ld de, DebugColor_UpArrowGFX
2017-12-28 12:32:33 +00:00
ld hl, vTiles1
lb bc, BANK(DebugColor_UpArrowGFX), 1
2015-11-19 23:07:20 +00:00
call Request2bpp
2017-12-28 12:32:33 +00:00
ld a, HIGH(vBGMap1)
ldh [hBGMapAddress + 1], a
2015-11-19 23:07:20 +00:00
hlcoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
ld a, DEBUGTEST_BLACK
2015-11-19 23:07:20 +00:00
call ByteFill
hlcoord 0, 0, wAttrmap
2015-11-19 23:07:20 +00:00
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
ld a, PAL_BG_TEXT
2015-11-19 23:07:20 +00: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 21:59:40 +00:00
call WaitBGMap2
2015-11-19 23:07:20 +00:00
ld [wJumptableIndex], a
ld a, $40
ldh [hWY], a
2015-11-19 23:07:20 +00:00
ret
DebugTileset_DrawColorSwatch:
2015-11-19 23:07:20 +00:00
hlcoord 0, 0
call _DebugColor_DrawSwatch
2015-11-19 23:07:20 +00:00
DebugColor_DrawAttributeSwatch:
2015-11-19 23:07:20 +00:00
ld a, [wcf64]
hlcoord 0, 0, wAttrmap
2015-11-19 23:07:20 +00:00
_DebugColor_DrawSwatch:
; Fills a 4x3 box at de with byte a.
2015-11-19 23:07:20 +00:00
add hl, de
rept 4
ld [hli], a
endr
rept 2
ld bc, SCREEN_WIDTH - 4
2015-11-19 23:07:20 +00:00
add hl, bc
rept 4
ld [hli], a
endr
endr
ret
DebugTileset_LoadRGBMeter:
2015-11-19 23:07:20 +00:00
hlcoord 2, 4
2020-10-06 17:50:02 +00:00
call .Place
2015-11-19 23:07:20 +00:00
hlcoord 2, 6
2020-10-06 17:50:02 +00:00
call .Place
2015-11-19 23:07:20 +00:00
hlcoord 2, 8
2020-10-06 17:50:02 +00:00
.Place:
ld a, DEBUGTEST_TICKS_1
2015-11-19 23:07:20 +00:00
ld [hli], a
ld bc, 15
ld a, DEBUGTEST_TICKS_2
2015-11-19 23:07:20 +00:00
call ByteFill
ret
DebugTileset_LoadPalettes:
ldh a, [rSVBK]
2015-11-19 23:07:20 +00:00
push af
ld a, BANK(wBGPals1)
ldh [rSVBK], a
2020-10-06 17:50:02 +00:00
2015-11-19 23:07:20 +00:00
ld a, [wcf64]
ld l, a
2020-10-06 17:50:02 +00:00
ld h, 0
2015-11-19 23:07:20 +00:00
add hl, hl
add hl, hl
add hl, hl
2018-01-01 14:08:21 +00:00
ld de, wBGPals1
2015-11-19 23:07:20 +00:00
add hl, de
ld de, wc608
ld bc, 1 palettes
2015-11-19 23:07:20 +00:00
call CopyBytes
ld de, wc608
2020-10-06 17:50:02 +00:00
call DebugColor_CalculateRGB
2015-11-19 23:07:20 +00:00
pop af
ldh [rSVBK], a
2015-11-19 23:07:20 +00:00
ret
2020-10-06 17:50:02 +00:00
DebugColorMain2: ; unreferenced
2015-11-19 23:07:20 +00:00
ld hl, hJoyLast
ld a, [hl]
and SELECT
jr nz, .loop7
ld a, [hl]
and B_BUTTON
jr nz, .cancel
call DebugTileset_Joypad
2015-11-19 23:07:20 +00:00
ret
.loop7
ld hl, wcf64
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 23:07:20 +00: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 23:07:20 +00:00
push af
ld a, BANK(wBGPals2)
ldh [rSVBK], a
2018-01-01 14:08:21 +00:00
ld hl, wBGPals2
2015-11-19 23:07:20 +00:00
ld a, [wcf64]
2018-01-01 13:47:16 +00:00
ld bc, 1 palettes
2015-11-19 23:07:20 +00:00
call AddNTimes
ld de, wc608
2018-01-01 13:47:16 +00:00
ld bc, 1 palettes
2015-11-19 23:07:20 +00:00
call CopyBytes
2015-11-19 23:07:20 +00:00
pop af
ldh [rSVBK], a
2020-10-06 17:50:02 +00:00
ld a, 2
ldh [hBGMapMode], a
2015-11-19 23:07:20 +00:00
ld c, 3
call DelayFrames
2020-10-06 17:50:02 +00:00
ld a, 1
ldh [hBGMapMode], a
2015-11-19 23:07:20 +00:00
ret
.cancel
2015-11-19 23:07:20 +00:00
call ClearSprites
ldh a, [hWY]
2020-10-06 17:50:02 +00:00
xor %11010000
ldh [hWY], a
2015-11-19 23:07:20 +00:00
ret
DebugTileset_UpdatePalettes:
ldh a, [rSVBK]
2015-11-19 23:07:20 +00:00
push af
ld a, BANK(wBGPals2)
ldh [rSVBK], a
2018-01-01 14:08:21 +00:00
ld hl, wBGPals2
2015-11-19 23:07:20 +00:00
ld a, [wcf64]
2018-01-01 13:47:16 +00:00
ld bc, 1 palettes
2015-11-19 23:07:20 +00:00
call AddNTimes
ld e, l
ld d, h
ld hl, wc608
2018-01-01 13:47:16 +00:00
ld bc, 1 palettes
2015-11-19 23:07:20 +00:00
call CopyBytes
2015-11-19 23:07:20 +00:00
hlcoord 1, 0
ld de, wc608
call DebugColor_PrintHexColor
2015-11-19 23:07:20 +00:00
hlcoord 6, 0
ld de, wc608 + 2
call DebugColor_PrintHexColor
2015-11-19 23:07:20 +00:00
hlcoord 11, 0
ld de, wc608 + 4
call DebugColor_PrintHexColor
2015-11-19 23:07:20 +00:00
hlcoord 16, 0
ld de, wc608 + 6
call DebugColor_PrintHexColor
2015-11-19 23:07:20 +00:00
pop af
ldh [rSVBK], a
2020-08-03 21:41:01 +00:00
ld a, TRUE
ldh [hCGBPalUpdate], a
2015-11-19 23:07:20 +00:00
call DelayFrame
ret
DebugTileset_Joypad:
2015-11-19 23:07:20 +00:00
ld a, [wcf65]
maskbits 4 ; .PointerTable length
2015-11-19 23:07:20 +00:00
ld e, a
ld d, 0
2020-10-06 17:50:02 +00:00
ld hl, .PointerTable
2015-11-19 23:07:20 +00:00
add hl, de
add hl, de
2015-11-19 23:07:20 +00:00
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
2015-11-19 23:07:20 +00:00
2020-10-06 17:50:02 +00:00
.PointerTable:
dw DebugTileset_SelectColorBox
dw DebugTileset_ChangeRedValue
dw DebugTileset_ChangeGreenValue
dw DebugTileset_ChangeBlueValue
2015-11-19 23:07:20 +00:00
DebugTileset_SelectColorBox:
2015-11-19 23:07:20 +00:00
ld hl, hJoyLast
ld a, [hl]
and D_DOWN
jr nz, DebugTileset_NextRGBColor
2015-11-19 23:07:20 +00:00
ld a, [hl]
and D_LEFT
2020-10-06 17:50:02 +00:00
jr nz, .left
2015-11-19 23:07:20 +00:00
ld a, [hl]
and D_RIGHT
2020-10-06 17:50:02 +00:00
jr nz, .right
2015-11-19 23:07:20 +00:00
ret
2020-10-06 17:50:02 +00:00
.left
2015-11-19 23:07:20 +00:00
ld a, [wcf66]
dec a
2020-10-06 17:50:02 +00:00
jr .done
2015-11-19 23:07:20 +00:00
2020-10-06 17:50:02 +00:00
.right
2015-11-19 23:07:20 +00:00
ld a, [wcf66]
inc a
2020-10-06 17:50:02 +00:00
.done
2015-11-19 23:07:20 +00:00
and $3
ld [wcf66], a
ld e, a
2020-10-06 17:50:02 +00:00
ld d, 0
2015-11-19 23:07:20 +00:00
ld hl, wc608
add hl, de
add hl, de
2015-11-19 23:07:20 +00:00
ld e, l
ld d, h
2020-10-06 17:50:02 +00:00
call DebugColor_CalculateRGB
2015-11-19 23:07:20 +00:00
ret
DebugTileset_ChangeRedValue:
2015-11-19 23:07:20 +00:00
ld hl, hJoyLast
ld a, [hl]
and D_DOWN
jr nz, DebugTileset_NextRGBColor
2015-11-19 23:07:20 +00:00
ld a, [hl]
and D_UP
jr nz, DebugTileset_PreviousRGBColor
2015-11-19 23:07:20 +00:00
ld hl, wc608 + 10
jr DebugTileset_UpdateRGBColor
2015-11-19 23:07:20 +00:00
DebugTileset_ChangeGreenValue:
2015-11-19 23:07:20 +00:00
ld hl, hJoyLast
ld a, [hl]
and D_DOWN
jr nz, DebugTileset_NextRGBColor
2015-11-19 23:07:20 +00:00
ld a, [hl]
and D_UP
jr nz, DebugTileset_PreviousRGBColor
2015-11-19 23:07:20 +00:00
ld hl, wc608 + 11
jr DebugTileset_UpdateRGBColor
2015-11-19 23:07:20 +00:00
DebugTileset_ChangeBlueValue:
2015-11-19 23:07:20 +00:00
ld hl, hJoyLast
ld a, [hl]
and D_UP
jr nz, DebugTileset_PreviousRGBColor
2015-11-19 23:07:20 +00:00
ld hl, wc608 + 12
DebugTileset_UpdateRGBColor:
ldh a, [hJoyLast]
2015-11-19 23:07:20 +00:00
and D_RIGHT
jr nz, .increment
ldh a, [hJoyLast]
2015-11-19 23:07:20 +00:00
and D_LEFT
jr nz, .decrement
2015-11-19 23:07:20 +00:00
ret
.increment
2015-11-19 23:07:20 +00:00
ld a, [hl]
2020-10-06 17:50:02 +00:00
cp 31
2015-11-19 23:07:20 +00:00
ret nc
inc [hl]
2020-10-06 17:50:02 +00:00
jr .done
2015-11-19 23:07:20 +00:00
.decrement
2015-11-19 23:07:20 +00:00
ld a, [hl]
and a
ret z
dec [hl]
2020-10-06 17:50:02 +00:00
.done
call DebugTileset_CalculatePalette
call DebugTileset_UpdatePalettes
2015-11-19 23:07:20 +00:00
ret
DebugTileset_PreviousRGBColor:
2015-11-19 23:07:20 +00:00
ld hl, wcf65
dec [hl]
ret
DebugTileset_NextRGBColor:
2015-11-19 23:07:20 +00:00
ld hl, wcf65
inc [hl]
ret
DebugTileset_CalculatePalette:
2015-11-19 23:07:20 +00:00
ld a, [wc608 + 10]
2020-10-06 17:50:02 +00:00
and %00011111
2015-11-19 23:07:20 +00:00
ld e, a
ld a, [wc608 + 11]
2020-10-06 17:50:02 +00:00
and %0000111
2015-11-19 23:07:20 +00:00
sla a
swap a
or e
ld e, a
ld a, [wc608 + 11]
2020-10-06 17:50:02 +00:00
and %00011000
2015-11-19 23:07:20 +00:00
sla a
swap a
ld d, a
ld a, [wc608 + 12]
2020-10-06 17:50:02 +00:00
and %00011111
2015-11-19 23:07:20 +00:00
sla a
sla a
or d
ld d, a
ld a, [wcf66]
ld c, a
2020-10-06 17:50:02 +00:00
ld b, 0
2015-11-19 23:07:20 +00:00
ld hl, wc608
add hl, bc
add hl, bc
2015-11-19 23:07:20 +00:00
ld a, e
ld [hli], a
ld [hl], d
ret
2020-10-06 17:50:02 +00:00
; unused
2015-11-19 23:07:20 +00:00
ret
2020-10-06 17:50:02 +00:00
; unused
2015-11-19 23:07:20 +00:00
ret