pokecrystal-board/engine/color.asm

1371 lines
18 KiB
NASM
Raw Normal View History

INCLUDE "engine/sgb_layouts.asm"
2015-11-01 15:13:31 -08:00
SHINY_ATK_BIT EQU 5
SHINY_DEF_VAL EQU 10
SHINY_SPD_VAL EQU 10
SHINY_SPC_VAL EQU 10
CheckShininess:
; Check if a mon is shiny by DVs at bc.
; Return carry if shiny.
ld l, c
ld h, b
; Attack
ld a, [hl]
2015-11-01 15:13:31 -08:00
and 1 << SHINY_ATK_BIT
jr z, .NotShiny
; Defense
ld a, [hli]
and $f
2015-11-01 15:13:31 -08:00
cp SHINY_DEF_VAL
jr nz, .NotShiny
; Speed
ld a, [hl]
and $f0
2015-11-01 15:13:31 -08:00
cp SHINY_SPD_VAL << 4
jr nz, .NotShiny
; Special
ld a, [hl]
and $f
2015-11-01 15:13:31 -08:00
cp SHINY_SPC_VAL
jr nz, .NotShiny
.Shiny:
scf
ret
.NotShiny:
and a
ret
2017-12-25 09:41:31 -08:00
; unreferenced
CheckContestMon:
; Check a mon's DVs at hl in the bug catching contest.
; Return carry if its DVs are good enough to place in the contest.
; Attack
ld a, [hl]
cp 10 << 4
jr c, .Bad
; Defense
ld a, [hli]
and $f
cp 10
jr c, .Bad
; Speed
ld a, [hl]
cp 10 << 4
jr c, .Bad
; Special
ld a, [hl]
and $f
cp 10
jr c, .Bad
.Good:
scf
ret
.Bad:
and a
ret
Function8aa4:
; XXX
push de
push bc
ld hl, PalPacket_9ce6
ld de, wSGBPals
2015-11-16 13:01:45 -08:00
ld bc, PALPACKET_LENGTH
call CopyBytes
pop bc
pop de
ld a, c
ld [wSGBPals + 3], a
ld a, b
ld [wSGBPals + 4], a
ld a, e
ld [wSGBPals + 5], a
ld a, d
ld [wSGBPals + 6], a
ld hl, wSGBPals
call PushSGBPals_
ld hl, BlkPacket_9a86
call PushSGBPals_
ret
InitPartyMenuPalettes:
ld hl, PalPacket_9c56 + 1
call CopyFourPalettes
2015-12-28 07:57:04 -08:00
call InitPartyMenuOBPals
2015-12-16 18:57:42 -08:00
call WipeAttrMap
ret
2017-12-25 09:41:31 -08:00
; SGB layout for SCGB_PARTY_MENU_HP_PALS
SGB_ApplyPartyMenuHPPals: ; 8ade
2015-12-22 19:19:33 -08:00
ld hl, wHPPals
ld a, [wSGBPals]
ld e, a
ld d, $0
add hl, de
ld e, l
ld d, h
ld a, [de]
and a
ld e, $5
jr z, .okay
dec a
ld e, $a
jr z, .okay
ld e, $f
.okay
push de
ld hl, wSGBPals + 10
2015-12-09 15:25:44 -08:00
ld bc, $6
ld a, [wSGBPals]
call AddNTimes
pop de
ld [hl], e
ret
Function8b07:
2016-01-04 05:43:55 -08:00
; Unreferenced
call CheckCGB
ret z
2016-05-05 12:07:37 -07:00
; CGB only
2016-01-04 05:43:55 -08:00
ld hl, .BGPal
2018-01-01 06:08:21 -08:00
ld de, wBGPals1
2015-12-09 15:25:44 -08:00
ld bc, 1 palettes
ld a, $5
call FarCopyWRAM
2016-01-04 05:43:55 -08:00
ld hl, .OBPal
2018-01-01 06:08:21 -08:00
ld de, wOBPals1
2015-12-09 15:25:44 -08:00
ld bc, 1 palettes
ld a, $5
call FarCopyWRAM
2015-12-16 18:57:42 -08:00
call ApplyPals
ld a, $1
ld [hCGBPalUpdate], a
ret
.BGPal:
RGB 31, 31, 31
RGB 18, 23, 31
RGB 15, 20, 31
RGB 00, 00, 00
2015-12-09 15:25:44 -08:00
.OBPal:
RGB 31, 31, 31
RGB 31, 31, 12
RGB 08, 16, 28
RGB 00, 00, 00
2015-12-09 15:25:44 -08:00
Function8b3f:
2016-01-04 05:43:55 -08:00
; Unreferenced
call CheckCGB
ret nz
ld a, [hSGB]
and a
ret z
ld hl, BlkPacket_9a86
jp PushSGBPals_
Function8b4d:
; XXX
call CheckCGB
2016-01-04 05:43:55 -08:00
jr nz, .cgb
ld a, [hSGB]
and a
ret z
ld hl, PalPacket_9c26
jp PushSGBPals_
2016-01-04 05:43:55 -08:00
.cgb
2018-01-01 06:08:21 -08:00
ld de, wOBPals1
ld a, $3b
call GetPredefPal
jp LoadHLPaletteIntoDE
Function8b67:
; XXX
call CheckCGB
2016-01-04 05:43:55 -08:00
jr nz, .cgb
ld a, [hSGB]
and a
ret z
ld hl, PalPacket_9c36
jp PushSGBPals_
2016-01-04 05:43:55 -08:00
.cgb
2018-01-01 06:08:21 -08:00
ld de, wOBPals1
ld a, $3c
call GetPredefPal
jp LoadHLPaletteIntoDE
Function8b81:
; XXX
call CheckCGB
jr nz, .cgb
ld a, [hSGB]
and a
ret z
ld a, c
push af
ld hl, PalPacket_9ce6
ld de, wSGBPals
2015-11-16 13:01:45 -08:00
ld bc, PALPACKET_LENGTH
call CopyBytes
pop af
2015-12-16 18:57:42 -08:00
call GetMonPalettePointer_
ld a, [hli]
ld [wSGBPals + 3], a
ld a, [hli]
ld [wSGBPals + 4], a
ld a, [hli]
ld [wSGBPals + 5], a
ld a, [hl]
ld [wSGBPals + 6], a
ld hl, wSGBPals
jp PushSGBPals_
.cgb
2018-01-01 06:08:21 -08:00
ld de, wOBPals1
ld a, c
2015-12-16 18:57:42 -08:00
call GetMonPalettePointer_
call LoadPalette_White_Col1_Col2_Black
ret
LoadTrainerClassPaletteAsNthBGPal:
ld a, [TrainerClass]
2015-12-16 18:57:42 -08:00
call GetTrainerPalettePointer
ld a, e
jr got_palette_pointer_8bd7
LoadMonPaletteAsNthBGPal:
ld a, [CurPartySpecies]
2015-12-16 18:57:42 -08:00
call GetMonPalettePointer
ld a, e
bit 7, a
jr z, got_palette_pointer_8bd7
and $7f
inc hl
inc hl
inc hl
inc hl
got_palette_pointer_8bd7
push hl
2018-01-01 06:08:21 -08:00
ld hl, wBGPals1
ld de, 1 palettes
.loop
and a
jr z, .got_addr
add hl, de
dec a
jr .loop
.got_addr
ld e, l
ld d, h
pop hl
2015-12-16 18:57:42 -08:00
call LoadPalette_White_Col1_Col2_Black
ret
Function8bec:
; XXX
ld a, [hCGB]
and a
jr nz, .cgb
ld hl, PlayerLightScreenCount
jp PushSGBPals_
.cgb
ld a, [EnemyLightScreenCount] ; col
ld c, a
ld a, [EnemyReflectCount] ; row
hlcoord 0, 0, AttrMap
ld de, SCREEN_WIDTH
.loop
and a
jr z, .done
add hl, de
dec a
jr .loop
.done
ld b, $0
add hl, bc
lb bc, 6, 4
ld a, [EnemySafeguardCount] ; value
and $3
2015-11-12 21:49:27 -08:00
call FillBoxCGB
call CopyTilemapAtOnce
ret
ApplyMonOrTrainerPals:
call CheckCGB
ret z
ld a, e
and a
jr z, .get_trainer
ld a, [CurPartySpecies]
2015-12-16 18:57:42 -08:00
call GetMonPalettePointer_
jr .load_palettes
.get_trainer
ld a, [TrainerClass]
2015-12-16 18:57:42 -08:00
call GetTrainerPalettePointer
.load_palettes
2018-01-01 06:08:21 -08:00
ld de, wBGPals1
2015-12-16 18:57:42 -08:00
call LoadPalette_White_Col1_Col2_Black
call WipeAttrMap
call ApplyAttrMap
call ApplyPals
ret
ApplyHPBarPals:
ld a, [wWhichHPBar]
and a
jr z, .Enemy
cp $1
jr z, .Player
cp $2
jr z, .PartyMenu
ret
.Enemy:
2018-01-01 06:08:21 -08:00
ld de, wBGPals2 palette PAL_BATTLE_BG_ENEMY_HP + 2
jr .okay
.Player:
2018-01-01 06:08:21 -08:00
ld de, wBGPals2 palette PAL_BATTLE_BG_PLAYER_HP + 2
.okay
ld l, c
ld h, $0
add hl, hl
2015-12-26 18:59:03 -08:00
add hl, hl
2017-12-15 19:36:33 -08:00
ld bc, HPBarPals
add hl, bc
ld bc, 4
ld a, $5
call FarCopyWRAM
ld a, $1
ld [hCGBPalUpdate], a
ret
.PartyMenu:
ld e, c
inc e
hlcoord 11, 1, AttrMap
ld bc, 2 * SCREEN_WIDTH
ld a, [CurPartyMon]
.loop
and a
jr z, .done
add hl, bc
dec a
jr .loop
.done
lb bc, 2, 8
ld a, e
2015-11-12 21:49:27 -08:00
call FillBoxCGB
ret
LoadStatsScreenPals:
call CheckCGB
ret z
2015-12-22 19:19:33 -08:00
ld hl, StatsScreenPals
ld b, 0
dec c
add hl, bc
2015-12-26 18:59:03 -08:00
add hl, bc
ld a, [rSVBK]
push af
ld a, $5
ld [rSVBK], a
ld a, [hli]
2018-01-01 06:08:21 -08:00
ld [wBGPals1 palette 0], a
ld [wBGPals1 palette 2], a
ld a, [hl]
2018-01-01 06:08:21 -08:00
ld [wBGPals1 palette 0 + 1], a
ld [wBGPals1 palette 2 + 1], a
pop af
ld [rSVBK], a
2015-12-16 18:57:42 -08:00
call ApplyPals
ld a, $1
ret
LoadMailPalettes:
ld l, e
ld h, 0
add hl, hl
add hl, hl
add hl, hl
ld de, .MailPals
add hl, de
call CheckCGB
jr nz, .cgb
push hl
ld hl, PalPacket_9ce6
ld de, wSGBPals
2015-11-16 13:01:45 -08:00
ld bc, PALPACKET_LENGTH
call CopyBytes
pop hl
inc hl
2015-12-26 18:59:03 -08:00
inc hl
ld a, [hli]
ld [wSGBPals + 3], a
ld a, [hli]
ld [wSGBPals + 4], a
ld a, [hli]
ld [wSGBPals + 5], a
ld a, [hli]
ld [wSGBPals + 6], a
ld hl, wSGBPals
call PushSGBPals_
ld hl, BlkPacket_9a86
call PushSGBPals_
ret
.cgb
2018-01-01 06:08:21 -08:00
ld de, wBGPals1
2015-12-09 15:25:44 -08:00
ld bc, 1 palettes
ld a, $5
call FarCopyWRAM
2015-12-16 18:57:42 -08:00
call ApplyPals
call WipeAttrMap
call ApplyAttrMap
ret
.MailPals:
2017-12-15 19:36:33 -08:00
INCLUDE "data/palettes/mail.pal"
2015-12-09 15:25:44 -08:00
INCLUDE "engine/cgb_layouts.asm"
Function95f0:
; XXX
ld hl, .Palette
2018-01-01 06:08:21 -08:00
ld de, wBGPals1
2017-12-25 09:41:31 -08:00
ld bc, 1 palettes
ld a, $5
call FarCopyWRAM
2015-12-16 18:57:42 -08:00
call ApplyPals
call WipeAttrMap
call ApplyAttrMap
ret
.Palette:
RGB 31, 31, 31
RGB 09, 31, 31
RGB 10, 12, 31
RGB 00, 03, 19
2015-12-09 15:25:44 -08:00
CopyFourPalettes:
2018-01-01 06:08:21 -08:00
ld de, wBGPals1
ld c, $4
2013-12-24 14:11:52 -08:00
CopyPalettes:
.loop
push bc
ld a, [hli]
push hl
call GetPredefPal
call LoadHLPaletteIntoDE
pop hl
inc hl
pop bc
dec c
jr nz, .loop
ret
GetPredefPal:
ld l, a
ld h, $0
add hl, hl
2016-05-05 12:07:37 -07:00
add hl, hl
add hl, hl
2017-12-15 19:36:33 -08:00
ld bc, PredefPals
add hl, bc
ret
LoadHLPaletteIntoDE:
ld a, [rSVBK]
push af
ld a, $5
ld [rSVBK], a
ld c, $8
.loop
ld a, [hli]
ld [de], a
inc de
dec c
jr nz, .loop
pop af
ld [rSVBK], a
ret
LoadPalette_White_Col1_Col2_Black:
ld a, [rSVBK]
push af
ld a, $5
ld [rSVBK], a
2015-12-16 18:57:42 -08:00
ld a, LOW(palred 31 + palgreen 31 + palblue 31)
ld [de], a
inc de
ld a, HIGH(palred 31 + palgreen 31 + palblue 31)
ld [de], a
inc de
2015-12-16 18:57:42 -08:00
ld c, 2 * 2
.loop
ld a, [hli]
ld [de], a
inc de
dec c
jr nz, .loop
2015-12-16 18:57:42 -08:00
xor a
ld [de], a
inc de
ld [de], a
inc de
2015-12-16 18:57:42 -08:00
pop af
ld [rSVBK], a
ret
FillBoxCGB:
.row
push bc
push hl
.col
ld [hli], a
dec c
jr nz, .col
pop hl
ld bc, SCREEN_WIDTH
add hl, bc
pop bc
dec b
jr nz, .row
ret
ResetBGPals:
push af
push bc
push de
push hl
ld a, [rSVBK]
push af
ld a, $5
ld [rSVBK], a
2018-01-01 06:08:21 -08:00
ld hl, wBGPals1
2017-12-25 09:41:31 -08:00
ld c, 1 palettes
2015-11-20 12:15:32 -08:00
.loop
ld a, $ff
ld [hli], a
ld [hli], a
ld [hli], a
ld [hli], a
xor a
ld [hli], a
ld [hli], a
ld [hli], a
ld [hli], a
dec c
2015-11-20 12:15:32 -08:00
jr nz, .loop
pop af
ld [rSVBK], a
pop hl
pop de
pop bc
pop af
ret
WipeAttrMap:
hlcoord 0, 0, AttrMap
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
xor a
call ByteFill
ret
ApplyPals:
2018-01-01 06:08:21 -08:00
ld hl, wBGPals1
ld de, wBGPals2
2015-12-09 15:25:44 -08:00
ld bc, 16 palettes
ld a, $5
call FarCopyWRAM
ret
ApplyAttrMap:
ld a, [rLCDC]
2017-12-29 09:53:21 -08:00
bit rLCDC_ENABLE, a
2015-12-16 18:57:42 -08:00
jr z, .UpdateVBank1
ld a, [hBGMapMode]
push af
ld a, $2
ld [hBGMapMode], a
call DelayFrame
call DelayFrame
call DelayFrame
call DelayFrame
pop af
ld [hBGMapMode], a
ret
.UpdateVBank1:
hlcoord 0, 0, AttrMap
2015-11-20 08:47:52 -08:00
debgcoord 0, 0
2015-12-16 18:57:42 -08:00
ld b, SCREEN_HEIGHT
ld a, $1
ld [rVBK], a
2015-12-16 18:57:42 -08:00
.row
ld c, SCREEN_WIDTH
.col
ld a, [hli]
ld [de], a
inc de
dec c
2015-12-16 18:57:42 -08:00
jr nz, .col
ld a, BG_MAP_WIDTH - SCREEN_WIDTH
add e
2015-12-16 18:57:42 -08:00
jr nc, .okay
inc d
2015-12-16 18:57:42 -08:00
.okay
ld e, a
dec b
2015-12-16 18:57:42 -08:00
jr nz, .row
ld a, $0
ld [rVBK], a
ret
2017-12-25 09:41:31 -08:00
; CGB layout for SCGB_PARTY_MENU_HP_PALS
CGB_ApplyPartyMenuHPPals: ; 96f3
2015-12-22 19:19:33 -08:00
ld hl, wHPPals
ld a, [wSGBPals]
ld e, a
ld d, $0
add hl, de
ld e, l
ld d, h
ld a, [de]
inc a
ld e, a
hlcoord 11, 2, AttrMap
2015-12-22 19:19:33 -08:00
ld bc, 2 * SCREEN_WIDTH
ld a, [wSGBPals]
2015-12-22 19:19:33 -08:00
.loop
and a
2015-12-22 19:19:33 -08:00
jr z, .done
add hl, bc
dec a
2015-12-22 19:19:33 -08:00
jr .loop
.done
lb bc, 2, 8
ld a, e
2015-11-12 21:49:27 -08:00
call FillBoxCGB
ret
InitPartyMenuOBPals:
2017-12-15 19:36:33 -08:00
ld hl, PartyMenuOBPals
2018-01-01 06:08:21 -08:00
ld de, wOBPals1
2015-12-09 15:25:44 -08:00
ld bc, 2 palettes
ld a, $5
call FarCopyWRAM
ret
GetBattlemonBackpicPalettePointer:
push de
2017-12-24 09:47:30 -08:00
farcall GetPartyMonDVs
ld c, l
ld b, h
ld a, [TempBattleMonSpecies]
2015-12-16 18:57:42 -08:00
call GetPlayerOrMonPalettePointer
pop de
ret
GetEnemyFrontpicPalettePointer:
push de
2017-12-24 09:47:30 -08:00
farcall GetEnemyMonDVs
ld c, l
ld b, h
ld a, [TempEnemyMonSpecies]
2015-12-16 18:57:42 -08:00
call GetFrontpicPalettePointer
pop de
ret
GetPlayerOrMonPalettePointer:
and a
2015-12-16 18:57:42 -08:00
jp nz, GetMonNormalOrShinyPalettePointer
2015-10-24 07:34:19 -07:00
ld a, [wPlayerSpriteSetupFlags]
2015-11-16 13:01:45 -08:00
bit 2, a ; transformed to male
2015-10-24 07:34:19 -07:00
jr nz, .male
ld a, [wPlayerGender]
and a
2015-10-24 07:34:19 -07:00
jr z, .male
ld hl, KrisPalette
ret
2015-10-24 07:34:19 -07:00
.male
ld hl, PlayerPalette
ret
GetFrontpicPalettePointer:
and a
2015-12-16 18:57:42 -08:00
jp nz, GetMonNormalOrShinyPalettePointer
ld a, [TrainerClass]
GetTrainerPalettePointer:
ld l, a
ld h, 0
add hl, hl
add hl, hl
ld bc, TrainerPalettes
add hl, bc
ret
GetMonPalettePointer_:
2015-12-16 18:57:42 -08:00
call GetMonPalettePointer
ret
Function9779: mobile
call CheckCGB
ret z
2017-12-25 09:41:31 -08:00
ld hl, BattleObjectPals
ld a, $90
ld [rOBPI], a
2015-12-16 18:57:42 -08:00
ld c, 6 palettes
.loop
ld a, [hli]
ld [rOBPD], a
dec c
2015-12-16 18:57:42 -08:00
jr nz, .loop
2017-12-25 09:41:31 -08:00
ld hl, BattleObjectPals
2018-01-01 06:08:21 -08:00
ld de, wOBPals1 palette 2
2015-12-09 15:25:44 -08:00
ld bc, 2 palettes
ld a, $5
call FarCopyWRAM
ret
2017-12-25 09:41:31 -08:00
BattleObjectPals:
INCLUDE "data/palettes/battle_objects.pal"
2015-12-09 15:25:44 -08:00
Function97cc:
; XXX
call CheckCGB
ret z
ld a, $90
ld [rOBPI], a
ld a, $1c
call GetPredefPal
call .PushPalette
ld a, $21
call GetPredefPal
call .PushPalette
ret
.PushPalette:
2015-12-16 18:57:42 -08:00
ld c, 1 palettes
.loop
ld a, [hli]
ld [rOBPD], a
dec c
jr nz, .loop
ret
GetMonPalettePointer:
ld l, a
ld h, $0
add hl, hl
add hl, hl
add hl, hl
ld bc, PokemonPalettes
add hl, bc
ret
GetMonNormalOrShinyPalettePointer:
push bc
2015-12-16 18:57:42 -08:00
call GetMonPalettePointer
pop bc
push hl
call CheckShininess
pop hl
ret nc
2015-07-20 19:18:18 -07:00
rept 4
inc hl
2015-07-20 19:18:18 -07:00
endr
ret
PushSGBPals_:
ld a, [wcfbe]
push af
set 7, a
ld [wcfbe], a
2016-01-04 05:43:55 -08:00
call PushSGBPals
pop af
ld [wcfbe], a
ret
PushSGBPals:
ld a, [hl]
and $7
ret z
ld b, a
.loop
push bc
xor a
ld [rJOYP], a
ld a, $30
ld [rJOYP], a
ld b, $10
.loop2
ld e, $8
ld a, [hli]
ld d, a
.loop3
bit 0, d
ld a, $10
jr nz, .okay
ld a, $20
.okay
ld [rJOYP], a
ld a, $30
ld [rJOYP], a
rr d
dec e
jr nz, .loop3
dec b
jr nz, .loop2
ld a, $20
ld [rJOYP], a
ld a, $30
ld [rJOYP], a
2015-12-22 19:19:33 -08:00
call SGBDelayCycles
pop bc
dec b
jr nz, .loop
ret
2016-05-05 12:07:37 -07:00
InitSGBBorder:
call CheckCGB
ret nz
2016-05-05 12:07:37 -07:00
; SGB/DMG only
di
ld a, [wcfbe]
push af
set 7, a
ld [wcfbe], a
xor a
ld [rJOYP], a
ld [hSGB], a
call PushSGBBorderPalsAndWait
2016-05-05 12:07:37 -07:00
jr nc, .skip
ld a, $1
ld [hSGB], a
call _InitSGBBorderPals
call SGBBorder_PushBGPals
2015-12-22 19:19:33 -08:00
call SGBDelayCycles
call SGB_ClearVRAM
call PushSGBBorder
2015-12-22 19:19:33 -08:00
call SGBDelayCycles
call SGB_ClearVRAM
ld hl, PalPacket_9d66
2016-01-04 05:43:55 -08:00
call PushSGBPals
2016-05-05 12:07:37 -07:00
.skip
pop af
ld [wcfbe], a
ei
ret
2016-05-05 12:07:37 -07:00
InitCGBPals::
call CheckCGB
ret z
2016-05-05 12:07:37 -07:00
; CGB only
ld a, $1
ld [rVBK], a
2017-12-28 04:32:33 -08:00
ld hl, vTiles0
2016-01-04 05:43:55 -08:00
ld bc, $200 tiles
xor a
call ByteFill
ld a, $0
ld [rVBK], a
ld a, 1 << rBGPI_AUTO_INCREMENT
ld [rBGPI], a
2016-01-04 05:43:55 -08:00
ld c, 4 * 8
.bgpals_loop
ld a, LOW(palred 31 + palgreen 31 + palblue 31)
ld [rBGPD], a
ld a, HIGH(palred 31 + palgreen 31 + palblue 31)
ld [rBGPD], a
dec c
2016-01-04 05:43:55 -08:00
jr nz, .bgpals_loop
ld a, 1 << rOBPI_AUTO_INCREMENT
ld [rOBPI], a
2016-01-04 05:43:55 -08:00
ld c, 4 * 8
.obpals_loop
ld a, LOW(palred 31 + palgreen 31 + palblue 31)
ld [rOBPD], a
ld a, HIGH(palred 31 + palgreen 31 + palblue 31)
ld [rOBPD], a
dec c
2016-01-04 05:43:55 -08:00
jr nz, .obpals_loop
ld a, [rSVBK]
push af
ld a, $5
ld [rSVBK], a
2018-01-01 06:08:21 -08:00
ld hl, wBGPals1
2016-01-04 05:43:55 -08:00
call .LoadWhitePals
2018-01-01 06:08:21 -08:00
ld hl, wBGPals2
2016-01-04 05:43:55 -08:00
call .LoadWhitePals
pop af
ld [rSVBK], a
ret
.LoadWhitePals:
2016-01-04 05:43:55 -08:00
ld c, 4 * 16
2015-11-20 12:15:32 -08:00
.loop
ld a, LOW(palred 31 + palgreen 31 + palblue 31)
ld [hli], a
ld a, HIGH(palred 31 + palgreen 31 + palblue 31)
ld [hli], a
dec c
2015-11-20 12:15:32 -08:00
jr nz, .loop
ret
_InitSGBBorderPals:
2016-01-04 05:43:55 -08:00
ld hl, .PalPacketPointerTable
ld c, 9
.loop
push bc
ld a, [hli]
push hl
ld h, [hl]
ld l, a
2016-01-04 05:43:55 -08:00
call PushSGBPals
pop hl
inc hl
pop bc
dec c
2016-01-04 05:43:55 -08:00
jr nz, .loop
ret
.PalPacketPointerTable:
dw PalPacket_9d56
dw PalPacket_9d76
dw PalPacket_9d86
dw PalPacket_9d96
dw PalPacket_9da6
dw PalPacket_9db6
dw PalPacket_9dc6
dw PalPacket_9dd6
dw PalPacket_9de6
Function9911:
; XXX
di
xor a
ld [rJOYP], a
ld hl, PalPacket_9d56
2016-01-04 05:43:55 -08:00
call PushSGBPals
call PushSGBBorder
2015-12-22 19:19:33 -08:00
call SGBDelayCycles
call SGB_ClearVRAM
ld hl, PalPacket_9d66
2016-01-04 05:43:55 -08:00
call PushSGBPals
ei
ret
PushSGBBorder:
2016-01-04 05:43:55 -08:00
call .LoadSGBBorderPointers
push de
call SGBBorder_YetMorePalPushing
pop hl
call SGBBorder_MorePalPushing
ret
.LoadSGBBorderPointers:
2013-12-13 17:49:01 -08:00
ld hl, SGBBorder
ld de, SGBBorderMap
ret
SGB_ClearVRAM:
ld hl, VRAM_Begin
ld bc, VRAM_End - VRAM_Begin
xor a
call ByteFill
ret
PushSGBBorderPalsAndWait:
ld hl, PalPacket_9d26
2016-01-04 05:43:55 -08:00
call PushSGBPals
2015-12-22 19:19:33 -08:00
call SGBDelayCycles
ld a, [rJOYP]
and $3
cp $3
jr nz, .carry
ld a, $20
ld [rJOYP], a
ld a, [rJOYP]
2015-12-26 18:59:03 -08:00
ld a, [rJOYP]
2015-12-22 19:19:33 -08:00
call SGBDelayCycles
call SGBDelayCycles
ld a, $30
ld [rJOYP], a
2015-12-22 19:19:33 -08:00
call SGBDelayCycles
call SGBDelayCycles
ld a, $10
ld [rJOYP], a
2015-07-20 19:18:18 -07:00
rept 6
ld a, [rJOYP]
2015-07-20 19:18:18 -07:00
endr
2015-12-22 19:19:33 -08:00
call SGBDelayCycles
call SGBDelayCycles
ld a, $30
ld [rJOYP], a
ld a, [rJOYP]
ld a, [rJOYP]
ld a, [rJOYP]
2015-12-22 19:19:33 -08:00
call SGBDelayCycles
call SGBDelayCycles
ld a, [rJOYP]
and $3
cp $3
jr nz, .carry
call .FinalPush
and a
ret
.carry
call .FinalPush
scf
ret
.FinalPush:
ld hl, PalPacket_9d16
2016-01-04 05:43:55 -08:00
call PushSGBPals
2015-12-22 19:19:33 -08:00
jp SGBDelayCycles
SGBBorder_PushBGPals:
call DisableLCD
2016-05-05 12:07:37 -07:00
ld a, %11100100
ld [rBGP], a
2017-12-15 19:36:33 -08:00
ld hl, PredefPals
2017-12-28 04:32:33 -08:00
ld de, vTiles1
ld bc, $100 tiles
call CopyData
call DrawDefaultTiles
2017-12-29 10:22:33 -08:00
ld a, LCDC_DEFAULT
ld [rLCDC], a
ld hl, PalPacket_9d06
2016-01-04 05:43:55 -08:00
call PushSGBPals
xor a
ld [rBGP], a
ret
SGBBorder_MorePalPushing:
call DisableLCD
ld a, $e4
ld [rBGP], a
2017-12-28 04:32:33 -08:00
ld de, vTiles1
2015-11-16 13:01:45 -08:00
ld bc, 20 tiles
call CopyData
2016-01-04 05:43:55 -08:00
ld b, 18
.loop
push bc
2015-12-09 15:25:44 -08:00
ld bc, $c
call CopyData
2015-12-09 15:25:44 -08:00
ld bc, $28
call ClearBytes
2015-12-09 15:25:44 -08:00
ld bc, $c
call CopyData
pop bc
dec b
jr nz, .loop
2015-12-09 15:25:44 -08:00
ld bc, $140
call CopyData
ld bc, Start
call ClearBytes
2015-12-09 15:25:44 -08:00
ld bc, 16 palettes
call CopyData
call DrawDefaultTiles
2017-12-29 10:22:33 -08:00
ld a, LCDC_DEFAULT
ld [rLCDC], a
ld hl, PalPacket_9d46
2016-01-04 05:43:55 -08:00
call PushSGBPals
xor a
ld [rBGP], a
ret
SGBBorder_YetMorePalPushing:
call DisableLCD
2016-01-04 05:43:55 -08:00
ld a, %11100100
ld [rBGP], a
2017-12-28 04:32:33 -08:00
ld de, vTiles1
ld b, $80
.loop
push bc
2016-01-04 05:43:55 -08:00
ld bc, 1 tiles
call CopyData
2016-01-04 05:43:55 -08:00
ld bc, 1 tiles
call ClearBytes
pop bc
dec b
jr nz, .loop
call DrawDefaultTiles
2017-12-29 10:22:33 -08:00
ld a, LCDC_DEFAULT
ld [rLCDC], a
ld hl, PalPacket_9d36
2016-01-04 05:43:55 -08:00
call PushSGBPals
xor a
ld [rBGP], a
ret
CopyData: ; 0x9a52
; copy bc bytes of data from hl to de
2016-05-05 12:07:37 -07:00
.loop
ld a, [hli]
ld [de], a
inc de
dec bc
ld a, c
or b
2016-05-05 12:07:37 -07:00
jr nz, .loop
ret
; 0x9a5b
ClearBytes: ; 0x9a5b
; clear bc bytes of data starting from de
2016-05-05 12:07:37 -07:00
.loop
xor a
ld [de], a
inc de
dec bc
ld a, c
or b
2016-05-05 12:07:37 -07:00
jr nz, .loop
ret
; 0x9a64
DrawDefaultTiles: ; 0x9a64
; Draw 240 tiles (2/3 of the screen) from tiles in VRAM
2015-11-20 08:47:52 -08:00
hlbgcoord 0, 0 ; BG Map 0
2016-01-04 05:43:55 -08:00
ld de, BG_MAP_WIDTH - SCREEN_WIDTH
ld a, $80 ; starting tile
ld c, 12 + 1
.line
ld b, 20
.tile
ld [hli], a
inc a
dec b
jr nz, .tile
; next line
add hl, de
dec c
jr nz, .line
ret
; 0x9a7a
SGBDelayCycles:
2015-12-22 19:19:33 -08:00
ld de, 7000
.wait
nop
nop
nop
dec de
ld a, d
or e
2015-12-22 19:19:33 -08:00
jr nz, .wait
ret
2017-12-25 09:41:31 -08:00
INCLUDE "data/palettes/blk_packets.asm"
INCLUDE "data/palettes/pal_packets.asm"
2017-12-15 19:36:33 -08:00
PredefPals:
INCLUDE "data/palettes/predef.pal"
2015-12-09 15:25:44 -08:00
2017-12-15 19:36:33 -08:00
INCLUDE "data/sgb_border_map.asm"
SGBBorderPalettes:
2017-12-15 19:36:33 -08:00
INCLUDE "data/palettes/sgb_border.pal"
2015-12-09 15:25:44 -08:00
SGBBorder:
INCBIN "gfx/sgb/sgb_border.2bpp"
2017-12-15 19:36:33 -08:00
HPBarPals:
2017-12-25 09:41:31 -08:00
INCLUDE "data/palettes/hp_bar.pal"
2017-12-15 19:36:33 -08:00
ExpBarPalette:
2017-12-25 09:41:31 -08:00
INCLUDE "data/palettes/exp_bar.pal"
INCLUDE "data/pokemon/palettes.asm"
INCLUDE "data/trainers/palettes.asm"
LoadMapPals:
2017-12-24 09:47:30 -08:00
farcall LoadSpecialMapPalette
jr c, .got_pals
; Which palette group is based on whether we're outside or inside
ld a, [wEnvironment]
2014-03-01 22:22:33 -08:00
and 7
ld e, a
2014-03-01 22:22:33 -08:00
ld d, 0
2017-12-25 09:41:31 -08:00
ld hl, EnvironmentColorsPointers
add hl, de
2015-12-26 18:59:03 -08:00
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
; Futher refine by time of day
ld a, [TimeOfDayPal]
2014-03-01 22:22:33 -08:00
and 3
add a
add a
add a
ld e, a
2014-03-01 22:22:33 -08:00
ld d, 0
add hl, de
ld e, l
ld d, h
; Switch to palettes WRAM bank
ld a, [rSVBK]
push af
ld a, $5
ld [rSVBK], a
2018-01-01 06:08:21 -08:00
ld hl, wBGPals1
ld b, 8
.outer_loop
ld a, [de] ; lookup index for TilesetBGPalette
push de
push hl
ld l, a
2014-03-01 22:22:33 -08:00
ld h, 0
add hl, hl
add hl, hl
add hl, hl
ld de, TilesetBGPalette
add hl, de
ld e, l
ld d, h
pop hl
ld c, 1 palettes
.inner_loop
ld a, [de]
inc de
ld [hli], a
dec c
jr nz, .inner_loop
pop de
inc de
dec b
jr nz, .outer_loop
pop af
ld [rSVBK], a
.got_pals
ld a, [TimeOfDayPal]
2014-03-01 22:22:33 -08:00
and 3
ld bc, 8 palettes
ld hl, MapObjectPals
call AddNTimes
2018-01-01 06:08:21 -08:00
ld de, wOBPals1
ld bc, 8 palettes
2018-01-01 06:08:21 -08:00
ld a, BANK(wOBPals1)
call FarCopyWRAM
ld a, [wEnvironment]
cp TOWN
jr z, .outside
cp ROUTE
ret nz
.outside
ld a, [MapGroup]
ld l, a
ld h, 0
add hl, hl
add hl, hl
add hl, hl
ld de, RoofPals
add hl, de
ld a, [TimeOfDayPal]
and 3
cp NITE_F
jr c, .morn_day
2015-07-20 19:18:18 -07:00
rept 4
inc hl
2015-07-20 19:18:18 -07:00
endr
.morn_day
2018-01-01 06:08:21 -08:00
ld de, wBGPals1 palette PAL_BG_ROOF + 2
ld bc, 4
ld a, $5
call FarCopyWRAM
ret
2017-12-25 09:41:31 -08:00
INCLUDE "data/maps/environment_colors.asm"
2014-03-01 22:22:33 -08:00
Palette_b309: ; b309 mobile
2014-03-01 22:22:33 -08:00
RGB 31, 31, 31
RGB 31, 19, 24
RGB 30, 10, 06
RGB 00, 00, 00
2015-12-09 15:25:44 -08:00
Palette_b311: ; b311 not mobile
2014-03-01 22:22:33 -08:00
RGB 31, 31, 31
RGB 17, 19, 31
RGB 14, 16, 31
RGB 00, 00, 00
2015-12-09 15:25:44 -08:00
TilesetBGPalette:
2017-12-25 09:41:31 -08:00
INCLUDE "data/palettes/overworld/tileset_bg.pal"
MapObjectPals::
2017-12-25 09:41:31 -08:00
INCLUDE "data/palettes/overworld/map_objects.pal"
RoofPals:
2017-12-25 09:41:31 -08:00
INCLUDE "data/palettes/overworld/roofs.pal"
2016-06-06 15:23:00 -07:00
DiplomaPalettes:
2017-12-15 19:36:33 -08:00
INCLUDE "data/palettes/diploma.pal"
2017-12-15 19:36:33 -08:00
PartyMenuOBPals:
INCLUDE "data/palettes/party_menu.pal"
Palettes_b6f1:
2017-12-25 09:41:31 -08:00
INCLUDE "data/palettes/unknown/b6f1.pal"
Palettes_b719:
2017-12-25 09:41:31 -08:00
INCLUDE "data/palettes/unknown/b719.pal"
2015-12-09 15:25:44 -08:00
MalePokegearPals:
2017-12-15 19:36:33 -08:00
INCLUDE "data/palettes/pokegear.pal"
2015-12-09 15:25:44 -08:00
FemalePokegearPals:
2017-12-15 19:36:33 -08:00
INCLUDE "data/palettes/pokegear_f.pal"
2015-12-09 15:25:44 -08:00
Palettes_b789:
2017-12-25 09:41:31 -08:00
INCLUDE "data/palettes/unknown/b789.pal"
2015-12-09 15:25:44 -08:00
2017-12-10 17:50:08 -08:00
SlotMachinePals:
2017-12-15 19:36:33 -08:00
INCLUDE "data/palettes/slot_machine.pal"