Add light/dark modes.

This commit is contained in:
Randy Thiemann 2023-11-23 05:13:02 +01:00
parent 707274390d
commit 4ce49d6d94
8 changed files with 160 additions and 15 deletions

View File

@ -73,6 +73,8 @@ INCLUDE "globals.asm"
DEF_RGB555_FROM24 BLACK_F, $20, $20, $20
DEF_RGB555_FROM24 GOLD_0, $36, $2C, $05
DEF_RGB555_FROM24 GOLD_1, $99, $73, $16
DEF_RGB555_FROM24 WHITE_F, $FF, $FF, $FF
; Title Palettes.
DEF_RGB555_FROM24 TITLE_PAL0_0, 0, 0, 0
@ -214,7 +216,19 @@ GBCGameplayInit::
WRITEPAL_A 5, YELLOW_3_C, YELLOW_2_C, YELLOW_1_C, YELLOW_0_C
WRITEPAL_A 6, CYAN_3_C, CYAN_2_C, CYAN_1_C, CYAN_0_C
WRITEPAL_A 7, WHITE_C, GRAY_1_C, GRAY_0_C, BLACK_C
ld a, [wBGMode]
cp a, BG_MODE_DARK
jp nz, .postpalettes
WRITEPAL_B 0, BLACK_C, RED_2_C, RED_1_C, RED_0_C
WRITEPAL_B 1, BLACK_C, GREEN_2_C, GREEN_1_C, GREEN_0_C
WRITEPAL_B 2, BLACK_C, PURPLE_2_C, PURPLE_1_C, PURPLE_0_C
WRITEPAL_B 3, BLACK_C, BLUE_2_C, BLUE_1_C, BLUE_0_C
WRITEPAL_B 4, BLACK_C, ORANGE_2_C, ORANGE_1_C, ORANGE_0_C
WRITEPAL_B 5, BLACK_C, YELLOW_2_C, YELLOW_1_C, YELLOW_0_C
WRITEPAL_B 6, BLACK_C, CYAN_2_C, CYAN_1_C, CYAN_0_C
WRITEPAL_A 7, BLACK_C, GRAY_0_C, GRAY_1_C, WHITE_C
jp .postpalettes
.agb
WRITEPAL_A 0, RED_3_A, RED_2_A, RED_1_A, RED_0_A
WRITEPAL_A 1, GREEN_3_A, GREEN_2_A, GREEN_1_A, GREEN_0_A
@ -224,8 +238,36 @@ GBCGameplayInit::
WRITEPAL_A 5, YELLOW_3_A, YELLOW_2_A, YELLOW_1_A, YELLOW_0_A
WRITEPAL_A 6, CYAN_3_A, CYAN_2_A, CYAN_1_A, CYAN_0_A
WRITEPAL_A 7, WHITE_A, GRAY_1_A, GRAY_0_A, BLACK_A
ld a, [wBGMode]
cp a, BG_MODE_DARK
jp nz, .postpalettes
WRITEPAL_B 0, BLACK_A, RED_2_A, RED_1_A, RED_0_A
WRITEPAL_B 1, BLACK_A, GREEN_2_A, GREEN_1_A, GREEN_0_A
WRITEPAL_B 2, BLACK_A, PURPLE_2_A, PURPLE_1_A, PURPLE_0_A
WRITEPAL_B 3, BLACK_A, BLUE_2_A, BLUE_1_A, BLUE_0_A
WRITEPAL_B 4, BLACK_A, ORANGE_2_A, ORANGE_1_A, ORANGE_0_A
WRITEPAL_B 5, BLACK_A, YELLOW_2_A, YELLOW_1_A, YELLOW_0_A
WRITEPAL_B 6, BLACK_A, CYAN_2_A, CYAN_1_A, CYAN_0_A
WRITEPAL_A 7, BLACK_A, GRAY_1_A, GRAY_0_A, WHITE_A
.postpalettes
ldh a, [hBState]
and a, a
jp z, .skip
WRITEPAL_B 0, BLACK_C, RED_2_C, RED_1_C, RED_0_C
WRITEPAL_B 1, BLACK_C, GREEN_2_C, GREEN_1_C, GREEN_0_C
WRITEPAL_B 2, BLACK_C, PURPLE_2_C, PURPLE_1_C, PURPLE_0_C
WRITEPAL_B 3, BLACK_C, BLUE_2_C, BLUE_1_C, BLUE_0_C
WRITEPAL_B 4, BLACK_C, ORANGE_2_C, ORANGE_1_C, ORANGE_0_C
WRITEPAL_B 5, BLACK_C, YELLOW_2_C, YELLOW_1_C, YELLOW_0_C
WRITEPAL_B 6, BLACK_C, CYAN_2_C, CYAN_1_C, CYAN_0_C
WRITEPAL_B 7, BLACK_C, GRAY_0_C, GRAY_1_C, WHITE_C
.skip
; Copy the tilemap to shadow.
ld de, $9800
ld hl, wShadowTilemap
@ -528,6 +570,9 @@ GBCGameplayProcess::
ret
.black
ld a, [wBGMode]
cp a, BG_MODE_DARK
jr z, .white
ld a, OCPSF_AUTOINC | (7*8)+(3*2)
ldh [rOCPS], a
ld bc, BLACK_F_C
@ -538,6 +583,17 @@ GBCGameplayProcess::
ldh [rOCPD], a
ret
.white
ld a, OCPSF_AUTOINC | (7*8)+(3*2)
ldh [rOCPS], a
ld bc, WHITE_F_C
wait_vram
ld a, c
ldh [rOCPD], a
ld a, b
ldh [rOCPD], a
ret
GBCBigGameplayProcess::
ld a, [wInitialA]

View File

@ -166,6 +166,7 @@ DEF BANK_MUSIC_3 EQU 9
; Some useful palettes.
DEF PALETTE_REGULAR EQU %11100100
DEF PALETTE_INVERTED EQU %00011011
DEF PALETTE_INVERTED_L EQU %01101111
DEF PALETTE_MONO_0 EQU %11111111
DEF PALETTE_MONO_1 EQU %10101010
DEF PALETTE_MONO_2 EQU %01010101
@ -346,6 +347,10 @@ DEF FILTER_MODE_UDLR EQU 3
DEF FILTER_MODE_NONE EQU 4
DEF FILTER_MODE_COUNT EQU 5
DEF BG_MODE_LITE EQU 0
DEF BG_MODE_DARK EQU 1
DEF BG_MODE_COUNT EQU 2
; VRAM Offsets for gameplay tiles
DEF FIELD_RNG EQU $9852
DEF FIELD_ROT EQU $9892
@ -490,18 +495,19 @@ DEF TITLE_SETTINGS_TETRY EQU $99C0
DEF TITLE_SETTINGS_SEL_BACK EQU 6
DEF TITLE_PROFILE_OPTION_BASE EQU $9840
DEF TITLE_PROFILE_OPTIONS EQU 8
DEF TITLE_PROFILE_OPTIONS EQU 9
DEF TITLE_PROFILE_INDEX EQU $984F
DEF TITLE_PROFILE_NAME_0 EQU $986F
DEF TITLE_PROFILE_NAME_1 EQU $988F
DEF TITLE_PROFILE_NAME_2 EQU $98AF
DEF TITLE_PROFILE_BUTTONS EQU $98CF
DEF TITLE_PROFILE_FILTER EQU $98EF
DEF TITLE_PROFILE_RESET EQU $990F
DEF TITLE_PROFILE_BACK EQU $992F
DEF TITLE_PROFILE_BG EQU $990F
DEF TITLE_PROFILE_RESET EQU $992F
DEF TITLE_PROFILE_BACK EQU $994F
DEF TITLE_PROFILE_TETRY EQU $99C0
DEF TITLE_PROFILE_SEL_RESET EQU 6
DEF TITLE_PROFILE_SEL_BACK EQU 7
DEF TITLE_PROFILE_SEL_RESET EQU 7
DEF TITLE_PROFILE_SEL_BACK EQU 8
DEF TITLE_RECORDS_MODE EQU $9848
DEF TITLE_RECORDS_SCORE_BASE EQU $98A2

View File

@ -34,6 +34,7 @@ wRotModeState:: ds 1
wDropModeState:: ds 1
wSpeedCurveState:: ds 1
wAlways20GState:: ds 1
wBGMode:: ds 1
wInitialA:: ds 1
wInitialB:: ds 1
wInitialC:: ds 1

View File

@ -70,6 +70,10 @@ sFilterMode::
db "UDLR"
db "NONE"
sBGMode::
db "LITE"
db "DARK"
sTetryRNG::
db "THIS OPTION WILL"
db "CHANGE THE WAY "
@ -140,13 +144,19 @@ sTetryButtons::
db "THIS OPTION WILL"
db "CHANGE WHICH WAY"
db "THE BUTTONS RO- "
db "TATE THE PIECE "
db "TATE THE PIECE! "
sTetryFILTER::
db "THIS OPTION WILL"
db "DETERMINE WHICH "
db "D-PAD BUTTONS "
db "HAVE PRIORITY "
db "HAVE PRIORITY! "
sTetryBG::
db "THIS OPTION WILL"
db "CHANGE THE BACK-"
db "GROUND COLOR IN-"
db "GAME! "
sTetryReset::
db "THIS OPTION WILL"
@ -406,14 +416,14 @@ sTitleScreenProfileMap::
DB $00,$00,$00,$00,$5D,$01,$0F,$2A,$1B,$0C
DB $0F,$01,$11,$14,$17,$1F,$10,$1D,$28,$01
DB $01,$01,$01,$29,$00,$00,$00,$00,$00,$00
DB $00,$00,$00,$00,$00,$00,$5D,$01,$1D,$10
DB $1E,$10,$1F,$01,$1B,$1D,$1A,$11,$14,$17
DB $10,$01,$01,$01,$01,$01,$00,$00,$00,$00
DB $00,$00,$00,$00,$00,$00,$5D,$01,$0D,$0C
DB $0E,$16,$12,$1D,$1A,$20,$19,$0F,$01,$01
DB $28,$01,$01,$01,$01,$29,$00,$00,$00,$00
DB $00,$00,$00,$00,$00,$00,$00,$00,$5D,$01
DB $0D,$0C,$0E,$16,$01,$01,$01,$01,$01,$01
DB $01,$01,$01,$01,$01,$01,$01,$01,$00,$00
DB $1D,$10,$1E,$10,$1F,$01,$1B,$1D,$1A,$11
DB $14,$17,$10,$01,$01,$01,$01,$01,$00,$00
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
DB $01,$01,$01,$01,$01,$01,$01,$01,$01,$01
DB $5D,$01,$0D,$0C,$0E,$16,$01,$01,$01,$01
DB $01,$01,$01,$01,$01,$01,$01,$01,$01,$01
DB $00,$00,$00,$00,$00,$00,$00,$00,$00,$00
DB $00,$00,$01,$01,$01,$01,$01,$01,$01,$01

View File

@ -35,7 +35,8 @@ rSpeedCurveState\1:: ds 1
rAlways20GState\1:: ds 1
rSelectedStartLevel\1:: ds 2
rFilterMode\1:: ds 1
rUnused\1:: ds (64-12)
rBGMode\1:: ds 1
rUnused\1:: ds (64-13)
ENDU
ENDM
@ -55,7 +56,8 @@ rSpeedCurveState:: ds 1
rAlways20GState:: ds 1
rSelectedStartLevel:: ds 2
rFilterMode:: ds 1
rUnused:: ds (PROFILE_SIZE - 12) ; 12 = sum of the above
rBGMode:: ds 1
rUnused:: ds (PROFILE_SIZE - 13) ; 13 = sum of the above
ENDU
PROFILE 0
PROFILE 1
@ -125,6 +127,8 @@ TrustedLoad:
ld [wProfileName+2], a
ld a, [rFilterMode]
ldh [hFilterMode], a
ld a, [rBGMode]
ld [wBGMode], a
; Restore the start level.
ld b, BANK_OTHER
@ -277,6 +281,10 @@ InitializeSRAM:
ld [rFilterMode], a
ldh [hFilterMode], a
ld a, BG_MODE_LITE
ld [rBGMode], a
ld [wBGMode], a
; Set to the default start level.
ld hl, sDMGTSpeedCurve
ld a, l

View File

@ -125,11 +125,22 @@ SwitchToGameplayB:
call ApplyTells
; Set up the palettes.
ld a, [wBGMode]
cp a, BG_MODE_DARK
jr z, .dark
ld a, PALETTE_REGULAR
set_bg_palette
set_obj0_palette
ld a, PALETTE_LIGHTER_1
set_obj1_palette
jr .done
.dark
ld a, PALETTE_INVERTED
set_bg_palette
set_obj0_palette
ld a, PALETTE_INVERTED_L
set_obj1_palette
.done
; Initialize the RNG.
call RNGInit
@ -931,11 +942,22 @@ SwitchToGameplayBigB:
call ApplyTells
; Set up the palettes.
ld a, [wBGMode]
cp a, BG_MODE_DARK
jr z, .dark
ld a, PALETTE_REGULAR
set_bg_palette
set_obj0_palette
ld a, PALETTE_LIGHTER_1
set_obj1_palette
jr .done
.dark
ld a, PALETTE_INVERTED
set_bg_palette
set_obj0_palette
ld a, PALETTE_INVERTED_L
set_obj1_palette
.done
; Initialize the RNG.
call RNGInit

View File

@ -733,6 +733,20 @@ TitleVBlankHandlerB:
ld bc, 4
call UnsafeMemCopy
.bg
ld b, 0
ld a, [wBGMode]
add a, a
add a, a
ld c, a
ld hl, sBGMode
add hl, bc
ld d, h
ld e, l
ld hl, TITLE_PROFILE_BG
ld bc, 4
call UnsafeMemCopy
; Tetry!
ld a, [wSelected]
ld hl, sTetryProfileNumber
@ -1251,6 +1265,7 @@ ProfileHandleRight:
jp .l2
jp .buttons
jp .filter
jp .bg
no_jump
no_jump
@ -1322,6 +1337,19 @@ ProfileHandleRight:
ld [rFilterMode], a
ret
.bg
ld a, [wBGMode]
cp a, BG_MODE_COUNT-1
jr z, :+
inc a
ld [wBGMode], a
ld [rBGMode], a
ret
: xor a, a
ld [wBGMode], a
ld [rBGMode], a
ret
ProfileHandleLeft:
ld a, [wSelected]
@ -1346,6 +1374,7 @@ ProfileHandleLeft:
jp .l2
jp .buttons
jp .filter
jp .bg
no_jump
no_jump
@ -1417,6 +1446,19 @@ ProfileHandleLeft:
ld [rFilterMode], a
ret
.bg
ld a, [wBGMode]
or a, a
jr z, :+
dec a
ld [wBGMode], a
ld [rBGMode], a
ret
: ld a, BG_MODE_COUNT-1
ld [wBGMode], a
ld [rBGMode], a
ret
ProfileHandleDown:
ld a, [wSelected]