From 6757a7652aaf512f978c8a043c74e85bd606697d Mon Sep 17 00:00:00 2001 From: Zeta_Null Date: Sun, 21 Jul 2024 16:57:20 -0400 Subject: [PATCH] SGB color mode stuff! dark caves don't currently work correctly, need to look into a fix --- data/tilesets/nihon_snowy_collision.asm | 2 +- engine/battle/battle_transition.asm | 4 +- engine/events/heal_machine_anim.asm | 3 +- engine/gfx/cgb_layouts.asm | 86 +++++++++++++++++++++++++ engine/menus/options_menu.asm | 2 +- engine/menus/start_menu.asm | 4 +- engine/tilesets/tileset_anims.asm | 13 ++-- gfx/sgb/predef.pal | 2 +- 8 files changed, 102 insertions(+), 14 deletions(-) diff --git a/data/tilesets/nihon_snowy_collision.asm b/data/tilesets/nihon_snowy_collision.asm index 5d011e9..32b1b77 100644 --- a/data/tilesets/nihon_snowy_collision.asm +++ b/data/tilesets/nihon_snowy_collision.asm @@ -11,7 +11,7 @@ tilecoll WALL, WALL, WALL, WALL ; 0a tilecoll WALL, WALL, WALL, WALL ; 0b tilecoll WALL, DOOR, FLOOR, FLOOR ; 0c - tilecoll FLOOR, FLOOR, FLOOR, FLOOR ; 0d + tilecoll WALL, WALL, FLOOR, FLOOR ; 0d tilecoll WALL, WALL, WALL, DOOR ; 0e tilecoll WALL, WALL, WALL, WALL ; 0f tilecoll WALL, WALL, WALL, WALL ; 10 diff --git a/engine/battle/battle_transition.asm b/engine/battle/battle_transition.asm index 74c5304..185995a 100644 --- a/engine/battle/battle_transition.asm +++ b/engine/battle/battle_transition.asm @@ -645,8 +645,8 @@ StartTrainerBattle_LoadPokeBallGraphics: dec b jr nz, .tile_loop - ldh a, [hCGB] - and a + ld a, [wOptions2] + and 1 << MENU_ACCOUNT jr nz, .cgb ld a, 1 ldh [hBGMapMode], a diff --git a/engine/events/heal_machine_anim.asm b/engine/events/heal_machine_anim.asm index a6f0496..dd848e8 100644 --- a/engine/events/heal_machine_anim.asm +++ b/engine/events/heal_machine_anim.asm @@ -155,7 +155,8 @@ INCBIN "gfx/overworld/heal_machine.2bpp" dbsprite 11, 7, 5, 1, $7d, PAL_OW_TREE | OBP_NUM .LoadPalettes: - call IsCGB + ld a, [wOptions2] + and 1 << MENU_ACCOUNT jr nz, .cgb ld a, %11100000 ldh [rOBP1], a diff --git a/engine/gfx/cgb_layouts.asm b/engine/gfx/cgb_layouts.asm index e205733..c91faf9 100644 --- a/engine/gfx/cgb_layouts.asm +++ b/engine/gfx/cgb_layouts.asm @@ -531,10 +531,94 @@ _CGB_Diploma: ret _CGB_MapPals: + ld a, [wOptions2] + and 1 << MENU_ACCOUNT + jr z, .SGBmode + ld a, [wOptions2] + and 1 << MENU_ACCOUNT + jr nz, .GBCmode + ret + +.GBCmode: call LoadMapPals ld a, SCGB_MAPPALS ld [wDefaultSGBLayout], a ret + +.SGBmode: + ; Get SGB palette + call SGBLayoutJumptable.GetMapPalsIndex + call GetPredefPal + ld de, wBGPals1 +; Copy 7 BG palettes + ld b, 7 +.bg_loop + call .LoadHLBGPaletteIntoDE + dec b + jr nz, .bg_loop +; Copy PAL_BG_TEXT and 6 OB palettes + ld b, 7 +.ob_loop + call .LoadHLOBPaletteIntoDE + dec b + jr nz, .ob_loop +; Copy PAL_OW_TREE and PAL_OW_ROCK + call .LoadHLBGPaletteIntoDE + call .LoadHLBGPaletteIntoDE + ld a, SCGB_MAPPALS + ld [wDefaultSGBLayout], a + ret + +.LoadHLBGPaletteIntoDE: +; morn/day: shades 0, 1, 2, 3 -> 0, 1, 2, 3 +; nite: shades 0, 1, 2, 3 -> 1, 2, 2, 3 + push hl + ld a, [wTimeOfDayPal] + cp NITE_F + jr c, .bg_morn_day + inc hl + inc hl + call .LoadHLColorIntoDE + call .LoadHLColorIntoDE + dec hl + dec hl + call .LoadHLColorIntoDE + call .LoadHLColorIntoDE +.bg_done + pop hl + ret + +.bg_morn_day + call LoadHLPaletteIntoDE + jr .bg_done + +.LoadHLOBPaletteIntoDE: +; shades 0, 1, 2, 3 -> 0, 0, 1, 3 + push hl + call .LoadHLColorIntoDE + dec hl + dec hl + call .LoadHLColorIntoDE + call .LoadHLColorIntoDE + inc hl + inc hl + call .LoadHLColorIntoDE + pop hl + ret + +.LoadHLColorIntoDE: + ldh a, [rSVBK] + push af + ld a, BANK(wBGPals1) + ldh [rSVBK], a +rept PAL_COLOR_SIZE + ld a, [hli] + ld [de], a + inc de +endr + pop af + ldh [rSVBK], a + ret _CGB_PartyMenu: ld hl, PalPacket_PartyMenu + 1 @@ -627,6 +711,8 @@ _CGB_UnownPuzzle: ret _CGB_TrainerCard: + ld a, [wOptions2] + and 1 << MENU_ACCOUNT ld de, wBGPals1 xor a ; CHRIS call GetTrainerPalettePointer diff --git a/engine/menus/options_menu.asm b/engine/menus/options_menu.asm index 3d83a97..d1ec83e 100644 --- a/engine/menus/options_menu.asm +++ b/engine/menus/options_menu.asm @@ -85,7 +85,7 @@ StringOptions: db " :" db "PRINT" db " :" - db "MENU ACCOUNT" + db "GBC COLORS" db " :" db "FRAME" db " :TYPE" diff --git a/engine/menus/start_menu.asm b/engine/menus/start_menu.asm index 84636e0..3fe9084 100644 --- a/engine/menus/start_menu.asm +++ b/engine/menus/start_menu.asm @@ -381,8 +381,8 @@ endr jp TextboxPalette .IsMenuAccountOn: - ld a, [wOptions2] - and 1 << MENU_ACCOUNT +; ld a, [wOptions2] +; and 1 << MENU_ACCOUNT ret .DrawBugContestStatusBox: diff --git a/engine/tilesets/tileset_anims.asm b/engine/tilesets/tileset_anims.asm index a74cf86..cfcb539 100644 --- a/engine/tilesets/tileset_anims.asm +++ b/engine/tilesets/tileset_anims.asm @@ -717,8 +717,8 @@ AnimateFlowerTile: ; CGB has different tile graphics for flowers ld e, a - ldh a, [hCGB] - and 1 + ld a, [wOptions2] + and 1 << MENU_ACCOUNT add e ; hl = .FlowerTileFrames + a * 16 @@ -738,6 +738,7 @@ AnimateFlowerTile: INCBIN "gfx/tilesets/flower/cgb_1.2bpp" INCBIN "gfx/tilesets/flower/dmg_2.2bpp" INCBIN "gfx/tilesets/flower/cgb_2.2bpp" + AnimateLavaBubbleTile1: ; Save the stack pointer in bc for WriteTile to restore @@ -950,8 +951,8 @@ AnimateWaterPalette: ; Transition between color values 0-2 for color 0 in palette 3. ; Don't update the palette on DMG - ldh a, [hCGB] - and a + ld a, [wOptions2] + and 1 << MENU_ACCOUNT ret z ; Don't update a non-standard palette order @@ -1013,8 +1014,8 @@ AnimateWaterPalette: FlickeringCaveEntrancePalette: ; Don't update the palette on DMG - ldh a, [hCGB] - and a + ld a, [wOptions2] + and 1 << MENU_ACCOUNT ret z ; Don't update a non-standard palette order diff --git a/gfx/sgb/predef.pal b/gfx/sgb/predef.pal index 152047f..c98ddd7 100644 --- a/gfx/sgb/predef.pal +++ b/gfx/sgb/predef.pal @@ -23,7 +23,6 @@ RGB 31,31,31, 31,20,20, 15,20,31, 00,00,00 ; PREDEFPAL_LAKE_OF_RAGE RGB 31,31,31, 26,26,26, 15,20,31, 00,00,00 ; PREDEFPAL_SILVER_CAVE RGB 31,31,31, 21,14,09, 15,20,20, 00,00,00 ; PREDEFPAL_DUNGEONS - RGB 31,31,31, 12,28,22, 15,20,20, 00,00,00 ; PREDEFPAL_SILENT_HILLS RGB 31,31,31, 29,26,18, 15,20,31, 00,00,00 ; PREDEFPAL_CITRINE (temp) RGB 31,31,31, 29,26,18, 15,20,31, 00,00,00 ; PREDEFPAL_ONE_ISLAND (temp) RGB 31,31,31, 29,26,18, 15,20,31, 00,00,00 ; PREDEFPAL_TWO_ISLAND (temp) @@ -32,6 +31,7 @@ RGB 31,31,31, 29,26,18, 15,20,31, 00,00,00 ; PREDEFPAL_FIVE_ISLAND (temp) RGB 31,31,31, 29,26,18, 15,20,31, 00,00,00 ; PREDEFPAL_SIX_ISLAND (temp) RGB 31,31,31, 29,26,18, 15,20,31, 00,00,00 ; PREDEFPAL_SEVEN_ISLAND (temp) + RGB 31,31,31, 12,28,22, 15,20,20, 00,00,00 ; PREDEFPAL_SILENT_HILLS RGB 31,31,31, 18,14,31, 15,20,20, 00,00,00 ; PREDEFPAL_BLUE_FOREST RGB 31,31,31, 12,28,22, 15,20,20, 00,00,00 ; PREDEFPAL_NITE RGB 31,31,31, 07,07,07, 02,03,03, 00,00,00 ; PREDEFPAL_BLACKOUT