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
- Multiplayer with items.
- Colorization.
- ...
- Implement better sound engine.
- Add more speed curves.
## License

View File

@ -113,9 +113,9 @@ sOption5::
sEasterM0:: db $C4, $C6, $C8, $CA, $CC ; MGB
sEasterM1:: db $C5, $C7, $C9, $CB, $CD
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
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
sEasterS1:: db $F7, $F9, $C9, $CB, $CD
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
wOuterReps:: ds 1
wInnerReps:: ds 1
wTitlePal:: ds 1
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::
; Bank 1
ld a, 1
@ -65,7 +87,7 @@ ToVRAM::
ldh [rHDMA5], a
; Bank 1
; Bank 0
ld a, 0
ldh [rVBK], a
ld a, HIGH(wShadowTilemap)
@ -78,8 +100,292 @@ ToVRAM::
ldh [rHDMA4], a
ld a, 39 | $80
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]
cp a, $11
ret nz
@ -317,78 +623,6 @@ GBCPalettes::
ld a, b
ldh [rBCPD], 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)
ld bc, %0111111111111111
@ -444,6 +678,57 @@ GBCGameplayInit::
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::
ld a, [wInitialA]
cp a, $11
@ -544,15 +829,11 @@ GBCGameplayProcess::
dec a
ld [wOuterReps], a
jr nz, .outer2
ret
GBCBlitField::
call ToVRAM
jp EventLoop
jp ToVRAM
ENDC

View File

@ -93,7 +93,6 @@ Main::
ld a, KEY1F_PREPARE
ldh [rKEY1], a
stop
call GBCPalettes
.notgbc
; 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
wSelected: ds 1
wSelected:: ds 1
SECTION "Title Functions", ROM0
@ -79,23 +79,23 @@ SwitchToTitle::
bit 0, a
jr nz, .agb
ld de, sEasterC0
ld hl, EASTER_0
ld hl, EASTER_0-1
ld bc, 12
call UnsafeMemCopy
ld de, sEasterC1
ld hl, EASTER_1
ld bc, 5
ld hl, EASTER_1-1
ld bc, 12
call UnsafeMemCopy
jr .oam
.agb
ld de, sEasterA0
ld hl, EASTER_0
ld hl, EASTER_0-1
ld bc, 12
call UnsafeMemCopy
ld de, sEasterA1
ld hl, EASTER_1
ld bc, 5
ld hl, EASTER_1-1
ld bc, 12
call UnsafeMemCopy
jr .oam
.noegg
@ -130,6 +130,8 @@ SwitchToTitle::
TitleEventLoopHandler::
call GBCTitleProcess
; Start game?
.abstart
ldh a, [hStartState]
@ -443,6 +445,8 @@ CheckLevelRange:
TitleVBlankHandler::
call ToATTR
ld a, TILE_UNSELECTED
ld hl, TITLE_OPTION_0
ld [hl], a