the great colors caper

This commit is contained in:
Shoofle 2025-12-20 16:25:50 -05:00
parent 430baf4a92
commit 74e80f6480
13 changed files with 495 additions and 234 deletions

View File

@ -30,6 +30,11 @@ TheHighPriestess:
ld [hl+], a ; CVS timer for smoke
ld [hl+], a
ld [hl+], a ; CVS+2 frame of smoke
;else write a 1 to two tiles' bg color values in vram bank 1...
ld a, 1
call SetTilePaletteForSmoke
ret
.fUpdate:
ld hl, CVS

View File

@ -31,6 +31,8 @@ TheHierophant:
ld [hl+], a ; CVS timer for halo
ld [hl+], a
ld [hl+], a ; CVS+2 frame of halo
ret
.fUpdate:
ld hl, CVS
@ -89,51 +91,50 @@ TheHierophant:
.fPrintPrep: ret
.halo ; 5 tall 7 wide sprites
db $00, $2a, $2b, $1c, $2c, $2d, $00
db $19, $1d, $1e, $00, $1f, $20, $00
db $2e, $21, $22, $00, $23, $24, $1a
db $2f, $30, $25, $00, $26, $27, $31
db $28, $00, $00, $00, $00, $1b, $32
db $00, $2a, $2b, $1c, $2c, $2d, $00
db $19, $03, $02, $00, $0a, $0b, $00
db $2e, $04, $01, $00, $29, $08, $1a
db $2f, $30, $05, $00, $06, $07, $31
db $28, $00, $00, $00, $00, $1b, $32
db $00, $2a, $2b, $1c, $2c, $2d, $00
db $19, $0e, $0f, $00, $10, $16, $00
db $2e, $0c, $0d, $00, $09, $15, $18
db $2f, $17, $11, $00, $12, $13, $14
db $28, $00, $00, $00, $00, $1b, $32
db $00, $2a, $2b, $1c, $2c, $2d, $00
db $19, $03, $02, $00, $0a, $0b, $00
db $2e, $04, $01, $00, $29, $08, $1a
db $2f, $30, $05, $00, $06, $07, $31
db $28, $00, $00, $00, $00, $1b, $32
db $00, $29, $2a, $1b, $2b, $2c, $00
db $18, $1c, $1d, $00, $1e, $1f, $00
db $2d, $20, $21, $00, $22, $23, $19
db $2e, $2f, $24, $00, $25, $26, $30
db $27, $00, $00, $00, $00, $1a, $31
db $00, $29, $2a, $1b, $2b, $2c, $00
db $18, $03, $02, $00, $0a, $0b, $00
db $2d, $04, $01, $00, $28, $08, $19
db $2e, $2f, $05, $00, $06, $07, $30
db $27, $00, $00, $00, $00, $1a, $31
db $00, $29, $2a, $1b, $2b, $2c, $00
db $18, $0e, $0f, $00, $10, $16, $00
db $2d, $0c, $0d, $00, $09, $15, $17
db $2e, $32, $11, $00, $12, $13, $14
db $27, $00, $00, $00, $00, $1a, $31
db $00, $29, $2a, $1b, $2b, $2c, $00
db $18, $03, $02, $00, $0a, $0b, $00
db $2d, $04, $01, $00, $28, $08, $19
db $2e, $2f, $05, $00, $06, $07, $30
db $27, $00, $00, $00, $00, $1a, $31
.SpriteTiles:
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $34,$40,$14,$60,$1c,$20,$0c,$70,$7c,$80,$cc,$00,$6c,$00,$3c,$00
db $80,$40,$00,$80,$00,$00,$00,$00,$00,$f8,$f0,$0c,$dc,$00,$74,$80
db $19,$20,$3b,$40,$76,$81,$5c,$82,$f8,$05,$90,$09,$f0,$09,$a0,$10
db $60,$10,$c0,$20,$40,$20,$c0,$20,$80,$43,$83,$4c,$80,$70,$80,$60
db $1e,$00,$26,$00,$3f,$00,$07,$00,$03,$04,$00,$03,$00,$00,$00,$00
db $60,$10,$c0,$20,$40,$20,$c0,$20,$80,$43,$83,$4c,$8c,$70,$88,$70
db $1e,$00,$06,$00,$1f,$00,$07,$00,$03,$04,$00,$03,$00,$00,$00,$00
db $02,$00,$02,$00,$03,$00,$06,$01,$0c,$02,$00,$0c,$00,$00,$00,$00
db $4e,$01,$f8,$06,$c0,$38,$00,$c0,$00,$00,$00,$00,$00,$00,$00,$00
db $80,$00,$80,$00,$80,$00,$80,$00,$00,$80,$80,$60,$e0,$18,$f8,$06
db $03,$00,$02,$00,$02,$00,$03,$00,$03,$00,$00,$00,$01,$00,$03,$00
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$03,$03,$00,$03,$00
db $30,$40,$1c,$20,$0c,$10,$00,$00,$00,$60,$60,$80,$e0,$00,$20,$10
db $60,$10,$c0,$20,$40,$20,$c0,$21,$81,$4e,$8f,$70,$b0,$40,$80,$60
db $60,$10,$c0,$20,$40,$20,$c0,$21,$81,$4e,$8f,$70,$bc,$40,$b8,$40
db $6c,$80,$64,$80,$3c,$40,$7c,$80,$ec,$00,$5c,$00,$74,$00,$34,$00
db $19,$20,$3b,$40,$76,$81,$5c,$83,$f8,$07,$91,$0a,$f0,$09,$a0,$11
db $80,$40,$00,$80,$00,$00,$00,$f0,$f0,$0c,$dc,$00,$9c,$00,$f4,$00
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$03,$03,$00,$03,$00,$02,$00
db $3e,$00,$2a,$00,$23,$00,$05,$00,$06,$00,$03,$04,$00,$00,$00,$00
db $1e,$00,$0a,$00,$03,$00,$05,$00,$06,$00,$03,$04,$00,$00,$00,$00
db $01,$00,$07,$00,$05,$00,$03,$00,$0e,$01,$0c,$02,$00,$00,$00,$00
db $23,$00,$ee,$01,$f8,$06,$c0,$38,$00,$c0,$00,$00,$00,$00,$00,$00
db $20,$c0,$20,$c0,$20,$40,$20,$40,$20,$40,$60,$80,$40,$80,$40,$80
db $80,$00,$80,$00,$00,$00,$80,$00,$80,$60,$e0,$18,$f8,$06,$ae,$01
db $30,$40,$1c,$20,$0c,$10,$00,$60,$60,$80,$e0,$00,$80,$00,$b0,$08
db $80,$60,$80,$40,$80,$40,$80,$40,$80,$40,$c0,$00,$00,$00,$00,$00
db $00,$00,$00,$00,$00,$00,$00,$00,$20,$40,$20,$40,$20,$40,$20,$c0
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$00,$01,$01,$02,$01,$02
db $00,$00,$00,$00,$00,$00,$00,$00,$20,$40,$20,$40,$20,$40,$20,$40
@ -143,11 +144,11 @@ TheHierophant:
db $80,$40,$00,$80,$00,$00,$00,$00,$00,$e0,$60,$98,$38,$c4,$3c,$40
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$03,$03,$00
db $30,$40,$1c,$20,$0c,$10,$00,$00,$00,$00,$00,$60,$60,$80,$c0,$20
db $60,$10,$c0,$20,$40,$20,$c0,$20,$80,$40,$80,$41,$80,$48,$80,$70
db $60,$10,$c0,$20,$40,$20,$c0,$20,$80,$40,$80,$43,$80,$4c,$88,$70
db $18,$20,$0c,$30,$0c,$10,$04,$18,$04,$78,$7c,$80,$6c,$00,$1c,$00
db $00,$00,$03,$00,$01,$00,$03,$00,$02,$01,$02,$01,$03,$00,$03,$00
db $80,$00,$80,$00,$00,$80,$00,$80,$00,$00,$00,$c0,$c0,$30,$70,$0c
db $26,$00,$3e,$00,$0f,$30,$03,$0c,$00,$03,$00,$00,$00,$00,$00,$00
db $06,$00,$1e,$00,$0f,$10,$03,$0c,$00,$03,$00,$00,$00,$00,$00,$00
db $01,$00,$07,$00,$07,$00,$00,$07,$00,$0c,$00,$00,$00,$00,$00,$00
db $bc,$03,$e0,$1c,$00,$e0,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $03,$04,$01,$02,$01,$02,$00,$01,$00,$00,$00,$00,$00,$00,$00,$00
@ -161,6 +162,7 @@ TheHierophant:
db $80,$40,$80,$40,$80,$40,$80,$40,$80,$40,$c0,$00,$00,$00,$00,$00
db $20,$c0,$20,$40,$20,$40,$20,$40,$20,$40,$60,$80,$40,$80,$40,$80
db $c0,$00,$80,$00,$80,$00,$80,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $80,$70,$80,$40,$80,$40,$80,$40,$80,$40,$c0,$00,$00,$00,$00,$00
.SpriteTilesEnd:
.KeyArtTiles:

View File

@ -35,6 +35,9 @@ TheChariot:
ld [hl+], a ; CVS+2 frame of horses
ld a, 1
ld [hl+], a
ld a, $80
call SetTileAttributesForTails
ret
.fUpdate:
ld hl, CVS
@ -140,6 +143,7 @@ TheChariot:
.fDraw: ret
.fPrintPrep: ret
.horse1 ;; 8 by 4

View File

@ -5,6 +5,7 @@ vAsyncHL: dw
vAsyncDE: dw
vAsyncBC: dw
vAsyncPC: dw
vAsyncRVBK: dw
vAsyncMainSP: dw
vAsyncThreadSP: dw
vAsyncIsBusy: db
@ -68,6 +69,9 @@ Async_Spawn:
ld a, h
ld [vAsyncAF+1], a
ld a, [rVBK]
ld [vAsyncRVBK], a
; save main sp
ld hl, sp+0
ld a, l
@ -120,6 +124,9 @@ Async_Spawn:
ld h, a
push hl
ld a, [vAsyncRVBK]
push af
; save current sp to vAsyncThreadSP
ld hl, sp+0
ld a, l
@ -176,6 +183,9 @@ Async_Spawn:
ld a, [vAsyncBC+1]
ld b, a
ld a, [vAsyncRVBK]
ld [rVBK], a
pop af
reti
@ -189,6 +199,8 @@ Async_EnterThread:
push bc
push de
push hl
ld a, [rVBK]
push af
;af, de, bc, hl, c113 (SMC interrupt pc), 004b (hardwired interrput pc), outer context pc
@ -204,6 +216,7 @@ Async_EnterThread:
; save main thread stack pointer
ld [vAsyncMainSP], sp
; 12 cycless
; load side thread stack pointer
ld a, [vAsyncThreadSP] ; 4
@ -212,7 +225,8 @@ Async_EnterThread:
ld h, a ; 1
ld sp, hl ; 2
; 12 cycles
pop af
ld [rVBK], a
; pop registers
; canonical ordering to push should be: AF, BC, DE, HL,
; pop is HL, DE, BC, AF
@ -235,6 +249,8 @@ Async_ExitThread:
push bc
push de
push hl
ld a, [rVBK]
push af
ld a, LOW(Async_EnterThread)
ld [INTERRUPT_LCD], a
@ -253,6 +269,8 @@ Async_ExitThread:
ld h, a
ld sp, hl
pop af
ld [rVBK], a
; pop registers
; canonical ordering to push should be: AF, BC, DE, HL,
; pop is HL, DE, BC, AF
@ -285,10 +303,11 @@ Async_EarlyReturn:
ld h, a
ld sp, hl
; restore the pre-interrupt registers, return and enable interrupts
pop af
pop de
pop bc
ld [rVBK], a
pop hl
pop bc
pop de
pop af
reti

View File

@ -399,6 +399,17 @@ CardInit:
ldh [rOBP0], a
call AdjustOBP0
di
; reset the card-specific background tile attributes for the two cards that use them
ld a, 0
call SetTilePaletteForSmoke
ei
nop
di
ld a, 0
call SetTileAttributesForTails
ei
call CARD_INIT - 1
ld a, [vCurrentCardReversed]
@ -712,3 +723,82 @@ WriteRightEdgeMaskIfNecessary:
inc e
ret
SetTileAttributesForTails:
ld e, a ; save the argument (what to write at the two tiles we care about)
ld a, 0
ld hl, rDeviceType
cp a, [hl]
ret z ; if we're on a DMG, we're done
di
ld a, 1
ld [rVBK], a
; these just so happen to be unchanged by flips, so this doesn't need to take
; into accuont whether the card is flipped or not?
ld a, e
ld [_SCRN0 + 32*8 + 2], a
ld [_SCRN0 + 32*8 + 3], a
ld [_SCRN0 + 32*9 + 2], a
ld [_SCRN0 + 32*9 + 3], a
ld [_SCRN0 + 32*8 + 6], a
ld [_SCRN0 + 32*8 + 7], a
ld [_SCRN0 + 32*9 + 6], a
ld [_SCRN0 + 32*9 + 7], a
ld a, 0
ld [rVBK], a
ei
ret
SetTilePaletteForSmoke:
ld e, a ; save the argument (what to write at the tiles we care about)
ld a, 0
ld hl, rDeviceType
cp a, [hl]
ret z ; if we're on a DMG, we're done
di
ld a, 1
ld [rVBK], a
ld a, [vCurrentCardReversed]
cp a, 0
jp z, .upright
.reversed
ld a, 0
ld [_SCRN0 + 32*2 + 3], a
ld [_SCRN0 + 32*2 + 4], a
ld [_SCRN0 + 32*2 + 5], a
ld [_SCRN0 + 32*2 + 6], a
ld a, e
ld [_SCRN0 + 32*15 + 3], a
ld [_SCRN0 + 32*15 + 4], a
ld [_SCRN0 + 32*15 + 5], a
ld [_SCRN0 + 32*15 + 6], a
jp .done
.upright
ld a, e
ld [_SCRN0 + 32*2 + 3], a
ld [_SCRN0 + 32*2 + 4], a
ld [_SCRN0 + 32*2 + 5], a
ld [_SCRN0 + 32*2 + 6], a
ld a, 0
ld [_SCRN0 + 32*15 + 3], a
ld [_SCRN0 + 32*15 + 4], a
ld [_SCRN0 + 32*15 + 5], a
ld [_SCRN0 + 32*15 + 6], a
.done
ld a, 0
ld [rVBK], a
ei
ret

View File

@ -29,6 +29,7 @@ CardReadSetup:
ret
.asyncTask:
ld hl, CardRead.UITilemap ; origin
ld de, _SCRN0 ; destination
ld b, 18 ; height

View File

@ -91,10 +91,6 @@ MainMenuSetup:
; that should be just about 2/3 of L !
ld [vFrameCount3], a
ld a, 0
ld [vFrameCountSquares], a
ld a, %11100100
ldh [rBGP], a
@ -108,6 +104,12 @@ MainMenuSetup:
ret
.asyncTask:
ld d, 0
ld hl, _SCRN0
ld b, 20
ld c, 16
call ScreenShuffle.SetCardTilesAttributes
ld hl, MainUITilemap
ld de, _SCRN0
ld b, 18
@ -357,7 +359,7 @@ MainMenuDraw:
ld c, 32
; find the location of the last selected caret and make it blank
ld hl, _SCRN0 + 32*11 + 3 - 64
ld hl, _SCRN0 + 32*9 + 3
ld a, [vMenuIndexPrevious]
inc a
.findLastCaret
@ -369,7 +371,7 @@ MainMenuDraw:
;find the location of the new selected caret and make it a caret
; bc contains 32 (row stride of bgmap)
ld hl, _SCRN0 + 32*11 + 3 - 64
ld hl, _SCRN0 + 32*9 + 3
ld a, [vMenuIndex]
inc a
.findNewCaret

View File

@ -28,6 +28,40 @@ ScreenShuffle:
dw ShuffleDraw
dw ShuffleTeardown
.SetCardTilesAttributes:
; sets an attribute flag (passed as d) on all the cards in the BigCard area
ld a, [rDeviceType]
cp a, 0
ret z
ld a, 1
ld [rVBK], a
:
ld a, d
push bc
:
ld [hl+], a
dec c
jp nz, :-
pop bc
ld a, 32
sub a, c
add a, l
ld l, a
ld a, 0
adc a, h
ld h, a
dec b
jp nz, :--
ld a, 0
ld [rVBK], a
ret
ShuffleSetup:
ld a, [SHUFFLED_DECK]
dec a
@ -61,10 +95,14 @@ ShuffleSetup:
call AdjustOBP0
ret
.asyncTask
ld d, 2
ld hl, _SCRN0 + 32*6 + 7
ld b, 10
ld c, 6
call ScreenShuffle.SetCardTilesAttributes
ld hl, CardBackSprites24Copy ; source
ld de, _VRAM + TileStartCardBackSprites24*$10; destination of copy
ld bc, CardBackSprites24CopyEnd - CardBackSprites24Copy ; length to copy
@ -124,6 +162,7 @@ ShuffleSetup:
ld de, _SCRN0 + 32*2 + 6
call PrintString
ret
ShuffleUpdate:
@ -224,7 +263,6 @@ ShuffleButtonHandler:
ret
CenterButtonHandler:
ld hl, rMYBTNP
: bit 0, [hl]
jp z, :+
@ -348,36 +386,33 @@ ShuffleAnimate:
HideSprites:
ld hl, MY_OAM
.testTile
ld a, [hl]
ld a, [hl+] ; checking first byte, and incrementnig to second
cp a, (2+6)*8 ; y < 5*8 => skip
jp c, .goToNextTile
jp c, .goToNextTile1
cp a, (2+7+8)*8 ; y > (5+8)*8 => skip
jp nc, .goToNextTile
jp nc, .goToNextTile1
inc hl
ld a, [hl] ; x value
dec hl
ld a, [hl+] ; checking second byte (x value) and nicrementing to third
cp a, (1+7)*8 ; x < 7*8 => skip
jp c, .goToNextTile
jp c, .goToNextTile2
cp a, (1+12)*8 ; x > 12*8 => skip
jp nc, .goToNextTile
jp nc, .goToNextTile2
inc hl
inc hl
inc hl
set OAMB_PRI, [hl]
dec hl
dec hl
dec hl
.goToNextTile
inc hl
inc hl
inc hl
inc hl
inc hl ; do nothing with third byte
set OAMB_PRI, [hl] ; changing fouurth byte
jp .goToNextTile3
.goToNextTile1
inc hl ; point to tile id
.goToNextTile2
inc hl ; point to attribute
.goToNextTile3
inc hl ; point to next oam record
ld a, $A0
cp a, l
jp nz, .testTile
jp nc, .testTile
ret
@ -444,7 +479,7 @@ UpdateEdges:
DoSomeShuffling:
rept 26 ; every time we shuffle do 20 swaps
rept 26 ; every time we shuffle do 26 swaps, so three steps = fully shuffled
call OneSwap
endr
ld hl, vShuffleCount
@ -504,6 +539,7 @@ OneSwap: ; shuffles once and decrements vshuffleindex
ret
ShuffleNextStates:
db 13,
db S_Center

View File

@ -25,6 +25,11 @@ SpreadSelectSetup:
ret
.asyncTask: ; setup task to be executed async
ld d, 0
ld hl, _SCRN0 + 32*6 + 7
ld b, 10
ld c, 6
call ScreenShuffle.SetCardTilesAttributes
ld a, HIGH(ZEROES)
ld de, SAFE_DMA_LOCATION

Binary file not shown.

78
card_art/SpriteTiles.asm Normal file
View File

@ -0,0 +1,78 @@
; original export script by gabriel reis, modified by shoofle
SpriteTiles:
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $34,$40,$14,$60,$1c,$20,$0c,$70,$7c,$80,$cc,$00,$6c,$00,$3c,$00
db $80,$40,$00,$80,$00,$00,$00,$00,$00,$f8,$f0,$0c,$dc,$00,$74,$80
db $19,$20,$3b,$40,$76,$81,$5c,$82,$f8,$05,$90,$09,$f0,$09,$a0,$10
db $60,$10,$c0,$20,$40,$20,$c0,$20,$80,$43,$83,$4c,$8c,$70,$88,$70
db $1e,$00,$06,$00,$1f,$00,$07,$00,$03,$04,$00,$03,$00,$00,$00,$00
db $02,$00,$02,$00,$03,$00,$06,$01,$0c,$02,$00,$0c,$00,$00,$00,$00
db $4e,$01,$f8,$06,$c0,$38,$00,$c0,$00,$00,$00,$00,$00,$00,$00,$00
db $80,$00,$80,$00,$80,$00,$80,$00,$00,$80,$80,$60,$e0,$18,$f8,$06
db $03,$00,$02,$00,$02,$00,$03,$00,$03,$00,$00,$00,$01,$00,$03,$00
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$03,$03,$00,$03,$00
db $30,$40,$1c,$20,$0c,$10,$00,$00,$00,$60,$60,$80,$e0,$00,$20,$10
db $60,$10,$c0,$20,$40,$20,$c0,$21,$81,$4e,$8f,$70,$bc,$40,$b8,$40
db $6c,$80,$64,$80,$3c,$40,$7c,$80,$ec,$00,$5c,$00,$74,$00,$34,$00
db $19,$20,$3b,$40,$76,$81,$5c,$83,$f8,$07,$91,$0a,$f0,$09,$a0,$11
db $80,$40,$00,$80,$00,$00,$00,$f0,$f0,$0c,$dc,$00,$9c,$00,$f4,$00
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$03,$03,$00,$03,$00,$02,$00
db $1e,$00,$0a,$00,$03,$00,$05,$00,$06,$00,$03,$04,$00,$00,$00,$00
db $01,$00,$07,$00,$05,$00,$03,$00,$0e,$01,$0c,$02,$00,$00,$00,$00
db $23,$00,$ee,$01,$f8,$06,$c0,$38,$00,$c0,$00,$00,$00,$00,$00,$00
db $20,$c0,$20,$c0,$20,$40,$20,$40,$20,$40,$60,$80,$40,$80,$40,$80
db $80,$00,$80,$00,$00,$00,$80,$00,$80,$60,$e0,$18,$f8,$06,$ae,$01
db $30,$40,$1c,$20,$0c,$10,$00,$60,$60,$80,$e0,$00,$80,$00,$b0,$08
db $00,$00,$00,$00,$00,$00,$00,$00,$20,$40,$20,$40,$20,$40,$20,$c0
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$01,$00,$01,$01,$02,$01,$02
db $00,$00,$00,$00,$00,$00,$00,$00,$20,$40,$20,$40,$20,$40,$20,$40
db $00,$01,$00,$01,$01,$02,$01,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $00,$c0,$80,$00,$80,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $19,$20,$3b,$40,$76,$81,$5c,$82,$f8,$05,$90,$08,$f0,$08,$a0,$10
db $80,$40,$00,$80,$00,$00,$00,$00,$00,$e0,$60,$98,$38,$c4,$3c,$40
db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$03,$03,$00
db $30,$40,$1c,$20,$0c,$10,$00,$00,$00,$00,$00,$60,$60,$80,$c0,$20
db $60,$10,$c0,$20,$40,$20,$c0,$20,$80,$40,$80,$43,$80,$4c,$88,$70
db $18,$20,$0c,$30,$0c,$10,$04,$18,$04,$78,$7c,$80,$6c,$00,$1c,$00
db $00,$00,$03,$00,$01,$00,$03,$00,$02,$01,$02,$01,$03,$00,$03,$00
db $80,$00,$80,$00,$00,$80,$00,$80,$00,$00,$00,$c0,$c0,$30,$70,$0c
db $06,$00,$1e,$00,$0f,$10,$03,$0c,$00,$03,$00,$00,$00,$00,$00,$00
db $01,$00,$07,$00,$07,$00,$00,$07,$00,$0c,$00,$00,$00,$00,$00,$00
db $bc,$03,$e0,$1c,$00,$e0,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $03,$04,$01,$02,$01,$02,$00,$01,$00,$00,$00,$00,$00,$00,$00,$00
db $01,$00,$01,$00,$02,$00,$03,$00,$01,$00,$03,$00,$01,$00,$02,$00
db $00,$00,$00,$00,$00,$00,$00,$01,$01,$02,$03,$04,$06,$08,$0f,$10
db $00,$07,$07,$18,$1f,$60,$75,$80,$e7,$00,$bc,$03,$70,$0c,$c0,$30
db $00,$3c,$3c,$03,$1f,$00,$03,$00,$0e,$00,$07,$08,$01,$06,$00,$01
db $00,$00,$00,$00,$00,$c0,$c0,$30,$70,$08,$58,$04,$dc,$00,$6c,$80
db $03,$04,$03,$04,$02,$04,$02,$04,$07,$08,$04,$08,$06,$08,$04,$08
db $06,$08,$04,$08,$06,$08,$04,$08,$07,$08,$03,$04,$02,$04,$03,$04
db $80,$40,$80,$40,$80,$40,$80,$40,$80,$40,$c0,$00,$00,$00,$00,$00
db $20,$c0,$20,$40,$20,$40,$20,$40,$20,$40,$60,$80,$40,$80,$40,$80
db $c0,$00,$80,$00,$80,$00,$80,$00,$00,$00,$00,$00,$00,$00,$00,$00
db $80,$70,$80,$40,$80,$40,$80,$40,$80,$40,$c0,$00,$00,$00,$00,$00
Sprites:
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $29, $2a, $1b, $2b, $2c, $00
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $18, $1c, $1d, $00, $1e, $1f, $00
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $2d, $20, $21, $00, $22, $23, $19
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $2e, $2f, $24, $00, $25, $26, $30
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $27, $00, $00, $00, $00, $1a, $31
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $29, $2a, $1b, $2b, $2c, $00
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $18, $03, $02, $00, $0a, $0b, $00
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $2d, $04, $01, $00, $28, $08, $19
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $2e, $2f, $05, $00, $06, $07, $30
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $27, $00, $00, $00, $00, $1a, $31
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $29, $2a, $1b, $2b, $2c, $00
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $18, $0e, $0f, $00, $10, $16, $00
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $2d, $0c, $0d, $00, $09, $15, $17
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $2e, $32, $11, $00, $12, $13, $14
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $27, $00, $00, $00, $00, $1a, $31
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00
db $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00, $00

331
main.asm
View File

@ -283,10 +283,16 @@ EntryPoint:
ldh [rOBP0], a
call AdjustBGP
call AdjustOBP0
call AdjustExtraBGPs
ld a, LCDCF_BLK21 | LCDCF_ON | LCDCF_BGON | LCDCF_OBJON
ldh [rLCDC], a
; set the frame cuont of squares before we change scene.
; this is sort of a screen-specific variable but sort of not
; if it wern't kept present, it would reset every time we load main menu?
ld a, 0
ld [vFrameCountSquares], a
; set up our scene handle
ld hl, ScreenMainMenu
call ChangeScene
@ -429,22 +435,145 @@ ArrayClamp:
dec a
ret
AdjustBGP: ; copies the palettes from the DMG mode to the CGB mode
AdjustBGP:
ld b, 0
ld hl, DefaultPaletteBGP
ld de, rBGP
call AdjustBGPGeneral
ret
AdjustExtraBGPs:
; okay say the background palette is colors b0, b1, b2, b3,
; and object palette is o0, o1, o2, o3.
; this sets BGP1 to be b0, b1, o2, b3 jsut for use in the high priestess, where
; we need some background tiles to look like object tiles.
ld b, 8
ld hl, SpecialtyPaletteBGP
ld de, DefaultOrder
call AdjustBGPGeneral
ld b, 16
ld hl, DefaultPaletteOBP0
ld de, DefaultOrder
call AdjustBGPGeneral
ret
AdjustOBP0:
ld b, 0
ld hl, DefaultPaletteOBP0
ld de, rOBP0
call AdjustOBPGeneral
ret
AdjustOBP1:
ld b, 8
ld hl, DefaultPaletteOBP1
ld de, rOBP1
call AdjustOBPGeneral
ret
DefaultOrder:
db %11_10_01_00
AdjustOBPGeneral:
; load a palette from somewhere into palette memory, dereferencing by a DMG-style
; color order register
; b=index of first color in palette memory
; hl=palette to use?
; de=register to reorder based on
ld a, [rDeviceType]
cp a, 0
ret z ; if we're in DMG mode, we don't need to do anything. else...
ld a, %1000_0000 ; we want to start at bgp color zero and autoincrement BGPI_AUTOINC
ldh [rBCPS], a ; set that
ld a, b
or a, $80 ; set the autoincremen flag
ldh [rOCPS], a
; assume we've just set rBGP to something like %11_10_01_00
ld b, 0
ldh a, [rBGP]
push hl
ld a, [de]
and a, %00000011
ld c, a
sla c
ld hl, DefaultPaletteBGP
pop hl
push hl
add hl, bc
ld a, [hl+]
ldh [rOCPD], a
ld a, [hl]
ldh [rOCPD], a
ld a, [de]
and a, %00001100
ld c, a
sra c
pop hl
push hl
add hl, bc ; index into bgp palette so now hl points to color x1 of default bgp
ld a, [hl+]
ldh [rOCPD], a
ld a, [hl]
ldh [rOCPD], a
ld a, [de]
and a, %00110000
ld c, a
swap c
sla c
pop hl
push hl
add hl, bc ; index into bgp palette so now hl points to color x2 of default bgp
ld a, [hl+]
ldh [rOCPD], a
ld a, [hl]
ldh [rOCPD], a
ld a, [de]
and a, %11000000
ld c, a
swap c
sra c
pop hl
add hl, bc ; index into bgp palette so now hl points to color x3 of default bgp
ld a, [hl+]
ldh [rOCPD], a
ld a, [hl]
ldh [rOCPD], a
ret
AdjustBGPGeneral:
; b=index of first color in palette memory
; hl=palette to use?
; de=register to reorder based on
ld a, [rDeviceType]
cp a, 0
ret z ; if we're in DMG mode, we don't need to do anything. else...
ld a, b ; we want to start at bgp color zero and autoincrement BGPI_AUTOINC
or a, $80
ldh [rBCPS], a ; set that
push hl
; assume we've just set rBGP to something like %11_10_01_00
ld b, 0
ld a, [de]
and a, %00000011
ld c, a
sla c
pop hl
push hl
add hl, bc ; index into bgp palette so now hl points to color x0 of default bgp
ld a, [hl+]
@ -453,25 +582,27 @@ AdjustBGP: ; copies the palettes from the DMG mode to the CGB mode
ldh [rBCPD], a
ld b, 0
ldh a, [rBGP]
ld a, [de]
and a, %00001100
ld c, a
sra c
ld hl, DefaultPaletteBGP
pop hl
push hl
add hl, bc ; index into bgp palette so now hl points to color x1 of default bgp
ld a, [hl+]
ldh [rBCPD], a
ld [rBCPD], a
ld a, [hl]
ldh [rBCPD], a
ld [rBCPD], a
ld b, 0
ldh a, [rBGP]
ld a, [de]
and a, %00110000
ld c, a
swap c
sla c
ld hl, DefaultPaletteBGP
pop hl
push hl
add hl, bc ; index into bgp palette so now hl points to color x2 of default bgp
ld a, [hl+]
@ -480,12 +611,12 @@ AdjustBGP: ; copies the palettes from the DMG mode to the CGB mode
ldh [rBCPD], a
ld b, 0
ldh a, [rBGP]
ld a, [de]
and a, %11000000
ld c, a
swap c
sra c
ld hl, DefaultPaletteBGP
pop hl
add hl, bc ; index into bgp palette so now hl points to color x3 of default bgp
ld a, [hl+]
@ -495,154 +626,42 @@ AdjustBGP: ; copies the palettes from the DMG mode to the CGB mode
ret
AdjustOBP0:
ld a, [rDeviceType]
cp a, 0
ret z ; if we're in DMG mode, we don't need to do anything. else...
ld a, %1000_0000 ; we want to start at obp color zero and autoincrement BGPI_AUTOINC
ldh [rOCPS], a ; set that
ld b, 0
; assume we've just set rOBP0 to something like %11_10_01_00
ldh a, [rOBP0]
and a, %00000011
ld c, a
sla c
ld hl, DefaultPaletteOBP0
add hl, bc
ld a, [hl+]
ldh [rOCPD], a
ld a, [hl]
ldh [rOCPD], a
ld a, [rOBP0]
and a, %00001100
ld c, a
sra c
ld hl, DefaultPaletteOBP0
add hl, bc ; index into bgp palette so now hl points to color x1 of default bgp
ld a, [hl+]
ldh [rOCPD], a
ld a, [hl]
ldh [rOCPD], a
ldh a, [rOBP0]
and a, %00110000
ld c, a
swap c
sla c
ld hl, DefaultPaletteOBP0
add hl, bc ; index into bgp palette so now hl points to color x2 of default bgp
ld a, [hl+]
ldh [rOCPD], a
ld a, [hl]
ldh [rOCPD], a
ldh a, [rOBP0]
and a, %11000000
ld c, a
swap c
sra c
ld hl, DefaultPaletteOBP0
add hl, bc ; index into bgp palette so now hl points to color x3 of default bgp
ld a, [hl+]
ldh [rOCPD], a
ld a, [hl]
ldh [rOCPD], a
ret
AdjustOBP1:
ld a, [rDeviceType]
cp a, 0
ret z ; if we're in DMG mode, we don't need to do anything. else...
ldh a, [rOBP1]
ld d, a ; take d from a, assuming a is a palette we wanted to use
ld a, %1000_1000 ; we want to start at obp palette 0b1000 (byte 8, bc 4 colors and 2 bytes per color?) and autoincrement BGPI_AUTOINC
ldh [rOCPS], a ; set that
ld b, 0
;ldh a, [rOBP1]
;ld d, a
; assume we've just set rOBP1 to something like %11_10_01_00
ld a, d
and a, %00000011
ld c, a
sla c
ld hl, DefaultPaletteOBP1
add hl, bc
ld a, [hl+]
ldh [rOCPD], a
ld a, [hl]
ldh [rOCPD], a
ld a, d
and a, %00001100
ld c, a
sra c
ld hl, DefaultPaletteOBP1
add hl, bc ; index into bgp palette so now hl points to color x1 of default bgp
ld a, [hl+]
ldh [rOCPD], a
ld a, [hl]
ldh [rOCPD], a
ld a, d
and a, %00110000
ld c, a
swap c
sla c
ld hl, DefaultPaletteOBP1
add hl, bc ; index into bgp palette so now hl points to color x2 of default bgp
ld a, [hl+]
ldh [rOCPD], a
ld a, [hl]
ldh [rOCPD], a
ld a, d
and a, %11000000
ld c, a
swap c
sra c
ld hl, DefaultPaletteOBP1
add hl, bc ; index into bgp palette so now hl points to color x3 of default bgp
ld a, [hl+]
ldh [rOCPD], a
ld a, [hl]
ldh [rOCPD], a
ret
; convert 3 bytes of RGB into the format 0b0_Bbbbb_Ggggg_Rrrrr (capitals MSB)
; and write a dw storing it
macro GBColorFromRGB
def red = (\1 >> 19)
;println "r is {red}"
def green = (\1 & 0xFF00) >> 11
;println "g is {green}"
def blue = (\1 & 0xFF) >> 3
;println "b is {blue}"
def code = (blue << 10) | (green << 5) | red
;println "combined value is {016b:code}"
dw code
endm
DefaultPaletteBGP:
; palette to use for everything
GBColorFromRGB $FFFFFF
GBColorFromRGB $9785ff
GBColorFromRGB $6714ff
GBColorFromRGB $000000
DefaultPaletteOBP0:
DefaultPaletteOBP1:
; colors are dw %0_Bbbbb_Ggggg_Rrrrr (capitals indicate MSB)
; palette to use for everything
dw %0_11111_11111_11111 ;GBCColorFromRGB(0xFFFFFF)
dw %0_11101_10000_10010 ;GBCColorFromRGB(0x63A5FF)
dw %0_11011_00000_01110 ;GBCColorFromRGB(0x0000FF)
dw %0_00000_00000_00000 ;GBCColorFromRGB(0x000000)
; a different reddish palette
GBColorFromRGB $FFFFFF
GBColorFromRGB $ff7214
GBColorFromRGB $d13400
GBColorFromRGB $000000
dw %0_11111_11111_11111 ; GBCColorFromRGB(0xFFFFFF)
dw %0_10000_10000_11111 ; GBCColorFromRGB(0xFF8484)
dw %0_00111_00111_10010 ;GBCColorFromRGB(0x943A3A)
dw %0_00000_00000_00000 ; GBCColorFromRGB(0x000000)
SpecialtyPaletteBGP: ; a palette to use for those times we want to have some parts
; of the background look like objects
GBColorFromRGB $ffffff
GBColorFromRGB $ff7214
GBColorFromRGB $6714ff
GBColorFromRGB $000000
PassList: ; hl has the address of a list. step past it.
ld b, 0

Binary file not shown.