Push colorization

This commit is contained in:
Randy Thiemann 2023-10-24 10:29:16 +02:00
parent 679a6ee907
commit 3829f62100
6 changed files with 377 additions and 94 deletions

Binary file not shown.

View File

@ -103,9 +103,8 @@ The game can be built using gnu make and the RGBDS toolchain.
## Future Goals ## Future Goals
- Multiplayer with items. - Implement better sound engine.
- Colorization. - Add more speed curves.
- ...
## License ## License

View File

@ -113,9 +113,9 @@ sOption5::
sEasterM0:: db $C4, $C6, $C8, $CA, $CC ; MGB sEasterM0:: db $C4, $C6, $C8, $CA, $CC ; MGB
sEasterM1:: db $C5, $C7, $C9, $CB, $CD sEasterM1:: db $C5, $C7, $C9, $CB, $CD
sEasterC0:: db $CE, $D0, $C8, $CA, $CC, $72, $74, $76, $78, $7A, $D6, $D7 ; CGB sEasterC0:: db $CE, $D0, $C8, $CA, $CC, $72, $74, $76, $78, $7A, $D6, $D7 ; CGB
sEasterC1:: db $CF, $D1, $C9, $CB, $CD sEasterC1:: db $CF, $D1, $C9, $CB, $CD, $73, $75, $77, $79, $7B, $01, $01
sEasterA0:: db $D2, $D4, $C8, $CA, $CC, $72, $74, $76, $78, $7A, $D6, $D7 ; AGB sEasterA0:: db $D2, $D4, $C8, $CA, $CC, $72, $74, $76, $78, $7A, $D6, $D7 ; AGB
sEasterA1:: db $D3, $D5, $C9, $CB, $CD sEasterA1:: db $D3, $D5, $C9, $CB, $CD, $73, $75, $77, $79, $7B, $01, $01
sEasterS0:: db $F6, $F8, $C8, $CA, $CC ; SGB sEasterS0:: db $F6, $F8, $C8, $CA, $CC ; SGB
sEasterS1:: db $F7, $F9, $C9, $CB, $CD sEasterS1:: db $F7, $F9, $C9, $CB, $CD
sPieceXOffsets:: ; How to draw each piece. X-offsets of the sprites. sPieceXOffsets:: ; How to draw each piece. X-offsets of the sprites.

View File

@ -44,11 +44,33 @@ wShadowTileAttrs:: ds 32*32
SECTION "GBC Variables", WRAM0 SECTION "GBC Variables", WRAM0
wOuterReps:: ds 1 wOuterReps:: ds 1
wInnerReps:: ds 1 wInnerReps:: ds 1
wTitlePal:: ds 1
SECTION "GBC Functions", ROM0 SECTION "GBC Functions", ROM0
ToATTR::
ld a, [wInitialA]
cp a, $11
ret nz
; Bank 1
ld a, 1
ldh [rVBK], a
ld a, HIGH(wShadowTileAttrs)
ldh [rHDMA1], a
ld a, LOW(wShadowTileAttrs)
ldh [rHDMA2], a
ld a, HIGH($9800)
ldh [rHDMA3], a
ld a, LOW($9800)
ldh [rHDMA4], a
ld a, 39
ldh [rHDMA5], a
ld a, 0
ldh [rVBK], a
ret
ToVRAM:: ToVRAM::
; Bank 1 ; Bank 1
ld a, 1 ld a, 1
@ -65,7 +87,7 @@ ToVRAM::
ldh [rHDMA5], a ldh [rHDMA5], a
; Bank 1 ; Bank 0
ld a, 0 ld a, 0
ldh [rVBK], a ldh [rVBK], a
ld a, HIGH(wShadowTilemap) ld a, HIGH(wShadowTilemap)
@ -78,8 +100,292 @@ ToVRAM::
ldh [rHDMA4], a ldh [rHDMA4], a
ld a, 39 | $80 ld a, 39 | $80
ldh [rHDMA5], a ldh [rHDMA5], a
jp EventLoop
GBCPalettes::
GBCTitleInit::
ld a, [wInitialA]
cp a, $11
ret nz
ld a, BCPSF_AUTOINC
ldh [rBCPS], a
ldh [rOCPS], a
; Pal 0 (red, I)
ld bc, %0000000000000000
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, R1
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, R2
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, R3
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
; Pal 1 (green, Z)
ld bc, %0000000000000000
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, G1
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, G2
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, G3
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
; Pal 2 (purple, S)
ld bc, %0000000000000000
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, R1 | B1
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, R2 | B2
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, R3 | B3
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
; Pal 3 (blue, J)
ld bc, %0000000000000000
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, B1
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, B2
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, B3
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
; Pal 4 (orange, L)
ld bc, %0000000000000000
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, R1 | G0
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, R2 | G1
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, R3 | G2
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
; Pal 5 (yellow, O)
ld bc, %0000000000000000
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, R1 | G1
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, R2 | G2
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, R3 | G3
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
; Pal 6 (cyan, T)
ld bc, %0000000000000000
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, B1 | G1
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, B2 | G2
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, B3 | G3
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
; Pal 7 (grayscale, inverted)
ld bc, %0000000000000000
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, %0010000100001000
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, %0100001000010000
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, %0111111111111111
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
; Copy the tilemap to shadow.
ld de, $9800
ld hl, wShadowTilemap
ld bc, 32*32
call UnsafeMemCopy
; Set attrs to pal 7 and copy to shadow.
ld a, 1
ldh [rVBK], a
ld d, $03
ld hl, $9800
ld bc, 32
call UnsafeMemSet
ld d, $01
ld bc, (5*32)
call UnsafeMemSet
ld d, $07
ld bc, (14*32)
call UnsafeMemSet
ld de, $9800
ld hl, wShadowTileAttrs
ld bc, 32*32
call UnsafeMemCopy
; Reset back to bank 0.
xor a, a
ldh [rVBK], a
; Save the current title palette.
ld a, $07
ld [wTitlePal], a
ret
GBCGameplayInit::
ld a, [wInitialA] ld a, [wInitialA]
cp a, $11 cp a, $11
ret nz ret nz
@ -317,78 +623,6 @@ GBCPalettes::
ld a, b ld a, b
ldh [rBCPD], a ldh [rBCPD], a
ldh [rOCPD], a ldh [rOCPD], a
ret
GBCTitleInit::
ld a, [wInitialA]
cp a, $11
ret nz
ld a, BCPSF_AUTOINC | (7*8)
ldh [rBCPS], a
ldh [rOCPS], a
; Pal 7 (grayscale, inverted)
ld bc, %0000000000000000
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, %0010000100001000
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, %0100001000010000
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
ld bc, %0111111111111111
ld a, c
ldh [rBCPD], a
ldh [rOCPD], a
ld a, b
ldh [rBCPD], a
ldh [rOCPD], a
; Copy the tilemap to shadow.
ld de, $9800
ld hl, wShadowTilemap
ld bc, 32*32
call UnsafeMemCopy
; Copy set attrs to pal 7 and copy to shadow.
ld a, 1
ldh [rVBK], a
ld d, $07
ld hl, $9800
ld bc, (32*32)
call UnsafeMemSet
ld de, $9800
ld hl, wShadowTileAttrs
ld bc, 32*32
call UnsafeMemCopy
; Reset back to bank 0.
xor a, a
ldh [rVBK], a
ret
GBCGameplayInit::
ld a, [wInitialA]
cp a, $11
ret nz
ld a, BCPSF_AUTOINC | (7*8)
ldh [rBCPS], a
ldh [rOCPS], a
; Pal 7 (grayscale) ; Pal 7 (grayscale)
ld bc, %0111111111111111 ld bc, %0111111111111111
@ -444,6 +678,57 @@ GBCGameplayInit::
ret ret
GBCTitleProcess::
ld a, [wInitialA]
cp a, $11
ret nz
; Wipe the palettes.
ld d, $03
ld hl, wShadowTileAttrs
ld bc, 32
call UnsafeMemSet
ld d, $07
ld hl, wShadowTileAttrs+32
ld bc, (19*32)
call UnsafeMemSet
; Palette for the title?
ldh a, [hFrameCtr]
and $0F
cp a, $01
jr nz, .noinc
ld a, [wTitlePal]
inc a
cp a, $07
jr c, .nores
ld a, $00
.nores
ld [wTitlePal], a
.noinc
; Set the palette for the title.
ld a, [wTitlePal]
ld d, a
ld hl, wShadowTileAttrs + (2*32)
ld bc, (4*32)
call UnsafeMemSet
; And the selected row.
ld a, [wSelected]
inc a
ld hl, wShadowTileAttrs + (5*32)
ld bc, 64
: add hl, bc
dec a
jr nz, :-
ld a, 3
ld d, a
ld bc, 32
call UnsafeMemSet
ret
GBCGameplayProcess:: GBCGameplayProcess::
ld a, [wInitialA] ld a, [wInitialA]
cp a, $11 cp a, $11
@ -544,15 +829,11 @@ GBCGameplayProcess::
dec a dec a
ld [wOuterReps], a ld [wOuterReps], a
jr nz, .outer2 jr nz, .outer2
ret ret
GBCBlitField:: GBCBlitField::
call ToVRAM jp ToVRAM
jp EventLoop
ENDC ENDC

View File

@ -93,7 +93,6 @@ Main::
ld a, KEY1F_PREPARE ld a, KEY1F_PREPARE
ldh [rKEY1], a ldh [rKEY1], a
stop stop
call GBCPalettes
.notgbc .notgbc
; We use a single set of tiles for the entire game, so we copy it at the start. ; We use a single set of tiles for the entire game, so we copy it at the start.

View File

@ -23,7 +23,7 @@ INCLUDE "globals.asm"
SECTION "Title Variables", WRAM0 SECTION "Title Variables", WRAM0
wSelected: ds 1 wSelected:: ds 1
SECTION "Title Functions", ROM0 SECTION "Title Functions", ROM0
@ -79,23 +79,23 @@ SwitchToTitle::
bit 0, a bit 0, a
jr nz, .agb jr nz, .agb
ld de, sEasterC0 ld de, sEasterC0
ld hl, EASTER_0 ld hl, EASTER_0-1
ld bc, 12 ld bc, 12
call UnsafeMemCopy call UnsafeMemCopy
ld de, sEasterC1 ld de, sEasterC1
ld hl, EASTER_1 ld hl, EASTER_1-1
ld bc, 5 ld bc, 12
call UnsafeMemCopy call UnsafeMemCopy
jr .oam jr .oam
.agb .agb
ld de, sEasterA0 ld de, sEasterA0
ld hl, EASTER_0 ld hl, EASTER_0-1
ld bc, 12 ld bc, 12
call UnsafeMemCopy call UnsafeMemCopy
ld de, sEasterA1 ld de, sEasterA1
ld hl, EASTER_1 ld hl, EASTER_1-1
ld bc, 5 ld bc, 12
call UnsafeMemCopy call UnsafeMemCopy
jr .oam jr .oam
.noegg .noegg
@ -130,6 +130,8 @@ SwitchToTitle::
TitleEventLoopHandler:: TitleEventLoopHandler::
call GBCTitleProcess
; Start game? ; Start game?
.abstart .abstart
ldh a, [hStartState] ldh a, [hStartState]
@ -443,6 +445,8 @@ CheckLevelRange:
TitleVBlankHandler:: TitleVBlankHandler::
call ToATTR
ld a, TILE_UNSELECTED ld a, TILE_UNSELECTED
ld hl, TITLE_OPTION_0 ld hl, TITLE_OPTION_0
ld [hl], a ld [hl], a