Organize the engine/ directory

This is an informed attempt at reorganizing the engine/ directory by
creating categorized subdirectories, in order to make it easier to
navigate and find things.

The directories created are as follows:
* engine/game: Contains all "minigames", things like the unown puzzle
and slot machine.
* engine/gfx: Contains all handling of graphics. From loading palettes
to playing animations.
* engine/link: Contains all multiplayer functionality.
* engine/menu: Contains all generic/misc. menus and menu code.
Other, more specialized menus are in their own subdirectories (pokedex,
pokegear, party menu, etc).
* engine/overworld: Contains all handling of the overworld. From loading
and connecting maps to wild encounters and the scripting engine.
* engine/pokegear: In the same vein as engine/pokedex, except it could
use some more splitting up.
* engine/pokemon: Contains everything related to manipulating pokemon
data. From the pokemon storage system to evolution and mail.
* engine/printer: Contains everything related to printing things as well
as the printer communication.
* engine/title: Contains intro sequences, title screens and credits.
This commit is contained in:
mid-kid
2018-03-13 13:07:16 +01:00
parent 12070ca500
commit baa0dc5a96
106 changed files with 104 additions and 104 deletions

1033
engine/gfx/cgb_layouts.asm Normal file

File diff suppressed because it is too large Load Diff

1356
engine/gfx/color.asm Normal file

File diff suppressed because it is too large Load Diff

325
engine/gfx/crystal_layouts.asm Executable file
View File

@@ -0,0 +1,325 @@
GetMysteryGift_MobileAdapterLayout: ; 4930f (mobile)
ld a, b
cp SCGB_RAM
jr nz, .not_ram
ld a, [wSGBPredef]
.not_ram
push af
farcall ResetBGPals
pop af
ld l, a
ld h, 0
add hl, hl
ld de, .dw
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
ld de, .done
push de
jp hl
.done
ret
; 49330 (12:5330)
.dw ; 49330
dw MG_Mobile_Layout00
dw MG_Mobile_Layout01
dw MG_Mobile_Layout02
; 49336
MG_Mobile_Layout_FillBox: ; 49336
.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
; 49346
MG_Mobile_Layout_WipeAttrMap: ; 49346 (12:5346)
hlcoord 0, 0, wAttrMap
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
xor a
call ByteFill
ret
MG_Mobile_Layout_LoadPals: ; 49351 (12:5351)
ld de, wBGPals1
ld hl, Palette_MysteryGiftMobile
ld bc, 5 palettes
ld a, BANK(wBGPals1)
call FarCopyWRAM
ld de, wBGPals1 palette PAL_BG_TEXT
ld hl, Palette_TextBG7
ld bc, 1 palettes
ld a, BANK(wBGPals1)
call FarCopyWRAM
ret
MG_Mobile_Layout00: ; 4936e (12:536e)
call MG_Mobile_Layout_LoadPals
call MG_Mobile_Layout_WipeAttrMap
call MG_Mobile_Layout_CreatePalBoxes
farcall ApplyAttrMap
farcall ApplyPals
ret
MG_Mobile_Layout_CreatePalBoxes: ; 49384 (12:5384)
hlcoord 0, 0, wAttrMap
lb bc, 4, 1
ld a, $1
call MG_Mobile_Layout_FillBox
lb bc, 2, 1
ld a, $2
call MG_Mobile_Layout_FillBox
lb bc, 6, 1
ld a, $3
call MG_Mobile_Layout_FillBox
hlcoord 1, 0, wAttrMap
ld a, $1
lb bc, 3, 18
call MG_Mobile_Layout_FillBox
lb bc, 2, 18
ld a, $2
call MG_Mobile_Layout_FillBox
lb bc, 12, 18
ld a, $3
call MG_Mobile_Layout_FillBox
hlcoord 19, 0, wAttrMap
lb bc, 4, 1
ld a, $1
call MG_Mobile_Layout_FillBox
lb bc, 2, 1
ld a, $2
call MG_Mobile_Layout_FillBox
lb bc, 6, 1
ld a, $3
call MG_Mobile_Layout_FillBox
hlcoord 0, 12, wAttrMap
ld bc, 6 * SCREEN_WIDTH
ld a, $7
call ByteFill
ret
; 493e1 (12:53e1)
Palette_MysteryGiftMobile: ; 493e1
INCLUDE "gfx/mystery_gift/mg_mobile.pal"
; 49409
LoadOW_BGPal7:: ; 49409
ld hl, Palette_TextBG7
ld de, wBGPals1 palette PAL_BG_TEXT
ld bc, 1 palettes
ld a, BANK(wBGPals1)
call FarCopyWRAM
ret
; 49418
Palette_TextBG7: ; 49418
INCLUDE "gfx/font/bg_text.pal"
; 49420
Function49420:: ; 49420 (12:5420)
ld hl, MansionPalette1 + 8 palettes
ld de, wBGPals1 palette PAL_BG_ROOF
ld bc, 1 palettes
ld a, BANK(wBGPals1)
call FarCopyWRAM
ret
; 4942f (12:542f)
MG_Mobile_Layout01: ; 4942f
call MG_Mobile_Layout_LoadPals
ld de, wBGPals1 palette PAL_BG_TEXT
ld hl, .Palette_49478
ld bc, 1 palettes
ld a, BANK(wBGPals1)
call FarCopyWRAM
call MG_Mobile_Layout_WipeAttrMap
hlcoord 0, 0, wAttrMap
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
xor a
call ByteFill
hlcoord 0, 14, wAttrMap
ld bc, 4 * SCREEN_WIDTH
ld a, $7
call ByteFill
ld a, [wd002]
bit 6, a
jr z, .asm_49464
call Function49480
jr .asm_49467
.asm_49464
call Function49496
.asm_49467
farcall ApplyAttrMap
farcall ApplyPals
ld a, $1
ld [hCGBPalUpdate], a
ret
; 49478
.Palette_49478: ; 49478
RGB 31, 31, 31
RGB 26, 31, 00
RGB 20, 16, 03
RGB 00, 00, 00
; 49480
Function49480: ; 49480
hlcoord 0, 0, wAttrMap
lb bc, 4, SCREEN_WIDTH
ld a, $7
call MG_Mobile_Layout_FillBox
hlcoord 0, 2, wAttrMap
ld a, $4
ld [hl], a
hlcoord 19, 2, wAttrMap
ld [hl], a
ret
; 49496
Function49496: ; 49496
hlcoord 0, 0, wAttrMap
lb bc, 2, SCREEN_WIDTH
ld a, $7
call MG_Mobile_Layout_FillBox
hlcoord 0, 1, wAttrMap
ld a, $4
ld [hl], a
hlcoord 19, 1, wAttrMap
ld [hl], a
ret
; 494ac
INCLUDE "engine/gfx/tileset_palettes.asm"
MG_Mobile_Layout02: ; 49706
ld hl, .Palette_49732
ld de, wBGPals1
ld bc, 1 palettes
ld a, BANK(wBGPals1)
call FarCopyWRAM
farcall ApplyPals
call MG_Mobile_Layout_WipeAttrMap
farcall ApplyAttrMap
ld hl, .Palette_4973a
ld de, wOBPals1
ld bc, 1 palettes
ld a, BANK(wOBPals1)
call FarCopyWRAM
ret
; 49732
.Palette_49732: ; 49732
RGB 31, 31, 31
RGB 23, 16, 07
RGB 23, 07, 07
RGB 03, 07, 20
; 4973a
.Palette_4973a: ; 4973a
RGB 00, 00, 00
RGB 07, 05, 31
RGB 14, 18, 31
RGB 31, 31, 31
; 49742
Function49742: ; 49742
ld hl, .Palette_49757
ld de, wBGPals1
ld bc, 8 palettes
ld a, BANK(wBGPals1)
call FarCopyWRAM
farcall ApplyPals
ret
; 49757
.Palette_49757: ; 49757
INCLUDE "gfx/unknown/49757.pal"
; 49797
_InitMG_Mobile_LinkTradePalMap: ; 49797
hlcoord 0, 0, wAttrMap
lb bc, 16, 2
ld a, $4
call MG_Mobile_Layout_FillBox
ld a, $3
ldcoord_a 0, 1, wAttrMap
ldcoord_a 0, 14, wAttrMap
hlcoord 2, 0, wAttrMap
lb bc, 8, 18
ld a, $5
call MG_Mobile_Layout_FillBox
hlcoord 2, 8, wAttrMap
lb bc, 8, 18
ld a, $6
call MG_Mobile_Layout_FillBox
hlcoord 0, 16, wAttrMap
lb bc, 2, SCREEN_WIDTH
ld a, $4
call MG_Mobile_Layout_FillBox
ld a, $3
lb bc, 6, 1
hlcoord 6, 1, wAttrMap
call MG_Mobile_Layout_FillBox
ld a, $3
lb bc, 6, 1
hlcoord 17, 1, wAttrMap
call MG_Mobile_Layout_FillBox
ld a, $3
lb bc, 6, 1
hlcoord 6, 9, wAttrMap
call MG_Mobile_Layout_FillBox
ld a, $3
lb bc, 6, 1
hlcoord 17, 9, wAttrMap
call MG_Mobile_Layout_FillBox
ld a, $2
hlcoord 2, 16, wAttrMap
ld [hli], a
ld a, $7
ld [hli], a
ld [hli], a
ld [hli], a
ld a, $2
ld [hl], a
hlcoord 2, 17, wAttrMap
ld a, $3
ld bc, 6
call ByteFill
ret
; 49811
LoadTradeRoomBGPals: ; 49811
ld hl, TradeRoomPalette
ld de, wBGPals1 palette PAL_BG_GREEN
ld bc, 6 palettes
ld a, BANK(wBGPals1)
call FarCopyWRAM
farcall ApplyPals
ret
; 49826
TradeRoomPalette: ; 49826
INCLUDE "gfx/trade/border.pal"
; 49856
InitMG_Mobile_LinkTradePalMap: ; 49856
call _InitMG_Mobile_LinkTradePalMap
ret
; 4985a
; unused
INCLUDE "gfx/unknown/4985a.asm"

View File

@@ -0,0 +1,368 @@
EvolutionAnimation: ; 4e5e1
push hl
push de
push bc
ld a, [wCurSpecies]
push af
ld a, [rOBP0]
push af
ld a, [wBaseDexNo]
push af
call .EvolutionAnimation
pop af
ld [wBaseDexNo], a
pop af
ld [rOBP0], a
pop af
ld [wCurSpecies], a
pop bc
pop de
pop hl
ld a, [wEvolutionCanceled]
and a
ret z
scf
ret
; 4e607
.EvolutionAnimation: ; 4e607
ld a, %11100100
ld [rOBP0], a
ld de, MUSIC_NONE
call PlayMusic
farcall ClearSpriteAnims
ld de, .GFX
ld hl, vTiles0
lb bc, BANK(.GFX), 8
call Request2bpp
xor a
ld [wLowHealthAlarm], a
call WaitBGMap
xor a
ld [hBGMapMode], a
ld a, [wEvolutionOldSpecies]
ld [wPlayerHPPal], a
ld c, $0
call .GetSGBLayout
ld a, [wEvolutionOldSpecies]
ld [wCurPartySpecies], a
ld [wCurSpecies], a
call .PlaceFrontpic
ld de, vTiles2
ld hl, vTiles2 tile $31
ld bc, 7 * 7
call Request2bpp
ld a, 7 * 7
ld [wEvolutionPicOffset], a
call .ReplaceFrontpic
ld a, [wEvolutionNewSpecies]
ld [wCurPartySpecies], a
ld [wCurSpecies], a
call .LoadFrontpic
ld a, [wEvolutionOldSpecies]
ld [wCurPartySpecies], a
ld [wCurSpecies], a
ld a, $1
ld [hBGMapMode], a
call .check_statused
jr c, .skip_cry
ld a, [wEvolutionOldSpecies]
call PlayMonCry
.skip_cry
ld de, MUSIC_EVOLUTION
call PlayMusic
ld c, 80
call DelayFrames
ld c, $1
call .GetSGBLayout
call .AnimationSequence
jr c, .cancel_evo
ld a, -7 * 7
ld [wEvolutionPicOffset], a
call .ReplaceFrontpic
xor a
ld [wEvolutionCanceled], a
ld a, [wEvolutionNewSpecies]
ld [wPlayerHPPal], a
ld c, $0
call .GetSGBLayout
call .PlayEvolvedSFX
farcall ClearSpriteAnims
call .check_statused
jr c, .no_anim
ld a, [wBoxAlignment]
push af
ld a, $1
ld [wBoxAlignment], a
ld a, [wCurPartySpecies]
push af
ld a, [wPlayerHPPal]
ld [wCurPartySpecies], a
hlcoord 7, 2
ld d, $0
ld e, ANIM_MON_EVOLVE
predef AnimateFrontpic
pop af
ld [wCurPartySpecies], a
pop af
ld [wBoxAlignment], a
ret
.no_anim
ret
.cancel_evo
ld a, $1
ld [wEvolutionCanceled], a
ld a, [wEvolutionOldSpecies]
ld [wPlayerHPPal], a
ld c, $0
call .GetSGBLayout
call .PlayEvolvedSFX
farcall ClearSpriteAnims
call .check_statused
ret c
ld a, [wPlayerHPPal]
call PlayMonCry
ret
; 4e703
.GetSGBLayout: ; 4e703
ld b, SCGB_EVOLUTION
jp GetSGBLayout
; 4e708
.PlaceFrontpic: ; 4e708
call GetBaseData
hlcoord 7, 2
jp PrepMonFrontpic
; 4e711
.LoadFrontpic: ; 4e711
call GetBaseData
ld a, $1
ld [wBoxAlignment], a
ld de, vTiles2
predef GetAnimatedFrontpic
xor a
ld [wBoxAlignment], a
ret
; 4e726
.AnimationSequence: ; 4e726
call ClearJoypad
lb bc, 1, 2 * 7 ; flash b times, wait c frames in between
.loop
push bc
call .WaitFrames_CheckPressedB
pop bc
jr c, .exit_sequence
push bc
call .Flash
pop bc
inc b
dec c
dec c
jr nz, .loop
and a
ret
.exit_sequence
scf
ret
; 4e741
.Flash: ; 4e741
ld a, -7 * 7 ; new stage
ld [wEvolutionPicOffset], a
call .ReplaceFrontpic
ld a, 7 * 7 ; previous stage
ld [wEvolutionPicOffset], a
call .ReplaceFrontpic
dec b
jr nz, .Flash
ret
; 4e755
.ReplaceFrontpic: ; 4e755
push bc
xor a
ld [hBGMapMode], a
hlcoord 7, 2
lb bc, 7, 7
ld de, SCREEN_WIDTH - 7
.loop1
push bc
.loop2
ld a, [wEvolutionPicOffset]
add [hl]
ld [hli], a
dec c
jr nz, .loop2
pop bc
add hl, de
dec b
jr nz, .loop1
ld a, $1
ld [hBGMapMode], a
call WaitBGMap
pop bc
ret
; 4e779
.WaitFrames_CheckPressedB: ; 4e779
call DelayFrame
push bc
call JoyTextDelay
ld a, [hJoyDown]
pop bc
and B_BUTTON
jr nz, .pressed_b
.loop3
dec c
jr nz, .WaitFrames_CheckPressedB
and a
ret
.pressed_b
ld a, [wForceEvolution]
and a
jr nz, .loop3
scf
ret
; 4e794
.check_statused ; 4e794
ld a, [wCurPartyMon]
ld hl, wPartyMon1Species
call GetPartyLocation
ld b, h
ld c, l
farcall CheckFaintedFrzSlp
ret
; 4e7a6
.PlayEvolvedSFX: ; 4e7a6
ld a, [wEvolutionCanceled]
and a
ret nz
ld de, SFX_EVOLVED
call PlaySFX
ld hl, wJumptableIndex
ld a, [hl]
push af
ld [hl], $0
.loop4
call .balls_of_light
jr nc, .done
call .AnimateBallsOfLight
jr .loop4
.done
ld c, 32
.loop5
call .AnimateBallsOfLight
dec c
jr nz, .loop5
pop af
ld [wJumptableIndex], a
ret
; 4e7cf
.balls_of_light ; 4e7cf
ld hl, wJumptableIndex
ld a, [hl]
cp 32
ret nc
ld d, a
inc [hl]
and $1
jr nz, .done_balls
ld e, $0
call .GenerateBallOfLight
ld e, $10
call .GenerateBallOfLight
.done_balls
scf
ret
; 4e7e8
.GenerateBallOfLight: ; 4e7e8
push de
depixel 9, 11
ld a, SPRITE_ANIM_INDEX_EVOLUTION_BALL_OF_LIGHT
call _InitSpriteAnimStruct
ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
add hl, bc
ld a, [wJumptableIndex]
and %1110
sla a
pop de
add e
ld [hl], a
ld hl, SPRITEANIMSTRUCT_TILE_ID
add hl, bc
ld [hl], $0
ld hl, SPRITEANIMSTRUCT_0C
add hl, bc
ld [hl], $10
ret
; 4e80c
.AnimateBallsOfLight: ; 4e80c
push bc
callfar PlaySpriteAnimations
; a = (([hVBlankCounter] + 4) / 2) % NUM_PALETTES
ld a, [hVBlankCounter]
and %1110
srl a
inc a
inc a
and $7
ld b, a
ld hl, wVirtualOAMSprite00Attributes
ld c, NUM_SPRITE_OAM_STRUCTS
.loop6
ld a, [hl]
or b
ld [hli], a ; attributes
rept SPRITEOAMSTRUCT_LENGTH + -1
inc hl
endr
dec c
jr nz, .loop6
pop bc
call DelayFrame
ret
; 4e831
.GFX:
INCBIN "gfx/evo/bubble_large.2bpp"
INCBIN "gfx/evo/bubble.2bpp"

149
engine/gfx/gbc_only.asm Normal file
View File

@@ -0,0 +1,149 @@
GBCOnlyScreen: ; 4ea82
ld a, [hCGB]
and a
ret nz
ld de, MUSIC_NONE
call PlayMusic
call ClearTileMap
ld hl, GBCOnlyGFX
ld de, wGBCOnlyDecompressBuffer
ld a, [rSVBK]
push af
ld a, 0 ; this has the same effect as selecting bank 1
ld [rSVBK], a
call Decompress
pop af
ld [rSVBK], a
ld de, wGBCOnlyDecompressBuffer
ld hl, vTiles2
lb bc, BANK(GBCOnlyGFX), 84
call Get2bpp
ld de, Font
ld hl, vTiles1
lb bc, BANK(Font), $80
call Get1bpp
call DrawGBCOnlyScreen
call WaitBGMap
; better luck next time
.loop
call DelayFrame
jr .loop
; 4eac5
DrawGBCOnlyScreen: ; 4eac5
call DrawGBCOnlyBorder
; Pokemon
hlcoord 3, 2
ld b, 14
ld c, 4
ld a, $8
call DrawGBCOnlyGraphic
; Crystal
hlcoord 5, 6
ld b, 10
ld c, 2
ld a, $40
call DrawGBCOnlyGraphic
ld de, GBCOnlyString
hlcoord 1, 10
call PlaceString
ret
; 4eaea
DrawGBCOnlyBorder: ; 4eaea
hlcoord 0, 0
ld [hl], 0 ; top-left
inc hl
ld a, 1 ; top
call .FillRow
ld [hl], 2 ; top-right
hlcoord 0, 1
ld a, 3 ; left
call .FillColumn
hlcoord 19, 1
ld a, 4 ; right
call .FillColumn
hlcoord 0, 17
ld [hl], 5 ; bottom-left
inc hl
ld a, 6 ; bottom
call .FillRow
ld [hl], 7 ; bottom-right
ret
; 4eb15
.FillRow: ; 4eb15
ld c, SCREEN_WIDTH - 2
.next_column
ld [hli], a
dec c
jr nz, .next_column
ret
; 4eb1c
.FillColumn: ; 4eb1c
ld de, SCREEN_WIDTH
ld c, SCREEN_HEIGHT - 2
.next_row
ld [hl], a
add hl, de
dec c
jr nz, .next_row
ret
; 4eb27
DrawGBCOnlyGraphic: ; 4eb27
ld de, SCREEN_WIDTH
.y
push bc
push hl
.x
ld [hli], a
inc a
dec b
jr nz, .x
pop hl
add hl, de
pop bc
dec c
jr nz, .y
ret
; 4eb38
GBCOnlyString: ; 4eb38
db "This Game Pak is"
next "designed only for"
next "use on the"
next "Game Boy Color.@"
; 4eb76
GBCOnlyGFX: ; 4eb76
INCBIN "gfx/sgb/gbc_only.2bpp.lz"
; 4f0bc

156
engine/gfx/load_font.asm Normal file
View File

@@ -0,0 +1,156 @@
INCLUDE "gfx/font.asm"
; This and the following two functions are unreferenced.
; Debug, perhaps?
Unreferenced_fb434:
db 0
Unreferenced_Functionfb435: ; 4b435
ld a, [Unreferenced_fb434]
and a
jp nz, Get1bpp_2
jp Get1bpp
; fb43f
Unreferenced_Functionfb43f: ; fb43f
ld a, [Unreferenced_fb434]
and a
jp nz, Get2bpp_2
jp Get2bpp
; End unreferenced block
; fb449
_LoadStandardFont:: ; fb449
ld de, Font
ld hl, vTiles1
lb bc, BANK(Font), 128 ; "A" to "9"
ld a, [rLCDC]
bit rLCDC_ENABLE, a
jp z, Copy1bpp
ld de, Font
ld hl, vTiles1
lb bc, BANK(Font), 32 ; "A" to "]"
call Get1bpp_2
ld de, Font + 32 * LEN_1BPP_TILE
ld hl, vTiles1 tile $20
lb bc, BANK(Font), 32 ; "a" to $bf
call Get1bpp_2
ld de, Font + 64 * LEN_1BPP_TILE
ld hl, vTiles1 tile $40
lb bc, BANK(Font), 32 ; "Ä" to "←"
call Get1bpp_2
ld de, Font + 96 * LEN_1BPP_TILE
ld hl, vTiles1 tile $60
lb bc, BANK(Font), 32 ; "'" to "9"
call Get1bpp_2
ret
; fb48a
_LoadFontsExtra1:: ; fb48a
ld de, FontsExtra_SolidBlackGFX
ld hl, vTiles2 tile "■" ; $60
lb bc, BANK(FontsExtra_SolidBlackGFX), 1
call Get1bpp_2
ld de, PokegearPhoneIconGFX
ld hl, vTiles2 tile "☎" ; $62
lb bc, BANK(PokegearPhoneIconGFX), 1
call Get2bpp_2
ld de, FontExtra + 3 tiles ; "<BOLD_D>"
ld hl, vTiles2 tile "<BOLD_D>"
lb bc, BANK(FontExtra), 22 ; "<BOLD_D>" to "ぉ"
call Get2bpp_2
jr LoadFrame
; fb4b0
_LoadFontsExtra2:: ; fb4b0
ld de, FontsExtra2_UpArrowGFX
ld hl, vTiles2 tile "▲" ; $61
ld b, BANK(FontsExtra2_UpArrowGFX)
ld c, 1
call Get2bpp_2
ret
; fb4be
_LoadFontsBattleExtra:: ; fb4be
ld de, FontBattleExtra
ld hl, vTiles2 tile $60
lb bc, BANK(FontBattleExtra), 25
call Get2bpp_2
jr LoadFrame
; fb4cc
LoadFrame: ; fb4cc
ld a, [wTextBoxFrame]
maskbits NUM_FRAMES
ld bc, 6 * LEN_1BPP_TILE
ld hl, Frames
call AddNTimes
ld d, h
ld e, l
ld hl, vTiles2 tile "┌" ; $79
lb bc, BANK(Frames), 6 ; "┌" to "┘"
call Get1bpp_2
ld hl, vTiles2 tile " " ; $7f
ld de, TextBoxSpaceGFX
lb bc, BANK(TextBoxSpaceGFX), 1
call Get1bpp_2
ret
; fb4f2
LoadBattleFontsHPBar: ; fb4f2
ld de, FontBattleExtra
ld hl, vTiles2 tile $60
lb bc, BANK(FontBattleExtra), 12
call Get2bpp_2
ld hl, vTiles2 tile $70
ld de, FontBattleExtra + 16 tiles ; "<DO>"
lb bc, BANK(FontBattleExtra), 3 ; "<DO>" to "『"
call Get2bpp_2
call LoadFrame
LoadHPBar: ; fb50d
ld de, EnemyHPBarBorderGFX
ld hl, vTiles2 tile $6c
lb bc, BANK(EnemyHPBarBorderGFX), 4
call Get1bpp_2
ld de, HPExpBarBorderGFX
ld hl, vTiles2 tile $73
lb bc, BANK(HPExpBarBorderGFX), 6
call Get1bpp_2
ld de, ExpBarGFX
ld hl, vTiles2 tile $55
lb bc, BANK(ExpBarGFX), 9
call Get2bpp_2
ld de, MobilePhoneTilesGFX + 7 tiles ; mobile phone icon
ld hl, vTiles2 tile $5e
lb bc, BANK(MobilePhoneTilesGFX), 2
call Get2bpp_2
ret
; fb53e
StatsScreen_LoadFont: ; fb53e
call _LoadFontsBattleExtra
ld de, EnemyHPBarBorderGFX
ld hl, vTiles2 tile $6c
lb bc, BANK(EnemyHPBarBorderGFX), 4
call Get1bpp_2
ld de, HPExpBarBorderGFX
ld hl, vTiles2 tile $78
lb bc, BANK(HPExpBarBorderGFX), 1
call Get1bpp_2
ld de, HPExpBarBorderGFX + 3 * LEN_1BPP_TILE
ld hl, vTiles2 tile $76
lb bc, BANK(HPExpBarBorderGFX), 2
call Get1bpp_2
ld de, ExpBarGFX
ld hl, vTiles2 tile $55
lb bc, BANK(ExpBarGFX), 8
call Get2bpp_2
LoadStatsScreenPageTilesGFX: ; fb571
ld de, StatsScreenPageTilesGFX
ld hl, vTiles2 tile $31
lb bc, BANK(StatsScreenPageTilesGFX), 17
call Get2bpp_2
ret
; fb57e

491
engine/gfx/load_pics.asm Executable file
View File

@@ -0,0 +1,491 @@
GetUnownLetter: ; 51040
; Return Unown letter in wUnownLetter based on DVs at hl
; Take the middle 2 bits of each DV and place them in order:
; atk def spd spc
; .ww..xx. .yy..zz.
; atk
ld a, [hl]
and %01100000
sla a
ld b, a
; def
ld a, [hli]
and %00000110
swap a
srl a
or b
ld b, a
; spd
ld a, [hl]
and %01100000
swap a
sla a
or b
ld b, a
; spc
ld a, [hl]
and %00000110
srl a
or b
; Divide by 10 to get 0-25
ld [hDividend + 3], a
xor a
ld [hDividend], a
ld [hDividend + 1], a
ld [hDividend + 2], a
ld a, $ff / NUM_UNOWN + 1
ld [hDivisor], a
ld b, 4
call Divide
; Increment to get 1-26
ld a, [hQuotient + 2]
inc a
ld [wUnownLetter], a
ret
GetMonFrontpic: ; 51077
ld a, [wCurPartySpecies]
ld [wCurSpecies], a
call IsAPokemon
ret c
ld a, [rSVBK]
push af
call _GetFrontpic
pop af
ld [rSVBK], a
ret
GetAnimatedFrontpic: ; 5108b
ld a, [wCurPartySpecies]
ld [wCurSpecies], a
call IsAPokemon
ret c
ld a, [rSVBK]
push af
xor a
ld [hBGMapMode], a
call _GetFrontpic
call GetAnimatedEnemyFrontpic
pop af
ld [rSVBK], a
ret
_GetFrontpic: ; 510a5
push de
call GetBaseData
ld a, [wBasePicSize]
and $f
ld b, a
push bc
call GetFrontpicPointer
ld a, BANK(wDecompressEnemyFrontpic)
ld [rSVBK], a
ld a, b
ld de, wDecompressEnemyFrontpic
call FarDecompress
pop bc
ld hl, wDecompressScratch
ld de, wDecompressEnemyFrontpic
call PadFrontpic
pop hl
push hl
ld de, wDecompressScratch
ld c, 7 * 7
ld a, [hROMBank]
ld b, a
call Get2bpp
pop hl
ret
GetFrontpicPointer: ; 510d7
ld a, [wCurPartySpecies]
cp UNOWN
jr z, .unown
ld a, [wCurPartySpecies]
ld d, BANK(PokemonPicPointers)
jr .ok
.unown
ld a, [wUnownLetter]
ld d, BANK(UnownPicPointers)
.ok
ld hl, PokemonPicPointers ; UnownPicPointers
dec a
ld bc, 6
call AddNTimes
ld a, d
call GetFarByte
call FixPicBank
push af
inc hl
ld a, d
call GetFarHalfword
pop bc
ret
GetAnimatedEnemyFrontpic: ; 51103
ld a, BANK(vTiles3)
ld [rVBK], a
push hl
ld de, wDecompressScratch
ld c, 7 * 7
ld a, [hROMBank]
ld b, a
call Get2bpp
pop hl
ld de, 7 * 7 tiles
add hl, de
push hl
ld a, BANK(wBasePicSize)
ld hl, wBasePicSize
call GetFarWRAMByte
pop hl
and $f
ld de, wDecompressEnemyFrontpic + 5 * 5 tiles
ld c, 5 * 5
cp 5
jr z, .got_dims
ld de, wDecompressEnemyFrontpic + 6 * 6 tiles
ld c, 6 * 6
cp 6
jr z, .got_dims
ld de, wDecompressEnemyFrontpic + 7 * 7 tiles
ld c, 7 * 7
.got_dims
push hl
push bc
call LoadFrontpicTiles
pop bc
pop hl
ld de, wDecompressScratch
ld a, [hROMBank]
ld b, a
call Get2bpp
xor a
ld [rVBK], a
ret
LoadFrontpicTiles: ; 5114f
ld hl, wDecompressScratch
swap c
ld a, c
and $f
ld b, a
ld a, c
and $f0
ld c, a
push bc
call LoadOrientedFrontpic
pop bc
.loop
push bc
ld c, 0
call LoadOrientedFrontpic
pop bc
dec b
jr nz, .loop
ret
GetMonBackpic: ; 5116c
ld a, [wCurPartySpecies]
call IsAPokemon
ret c
ld a, [wCurPartySpecies]
ld b, a
ld a, [wUnownLetter]
ld c, a
ld a, [rSVBK]
push af
ld a, BANK(wDecompressScratch)
ld [rSVBK], a
push de
; These are assumed to be at the same address in their respective banks.
ld hl, PokemonPicPointers ; UnownPicPointers
ld a, b
ld d, BANK(PokemonPicPointers)
cp UNOWN
jr nz, .ok
ld a, c
ld d, BANK(UnownPicPointers)
.ok
dec a
ld bc, 6
call AddNTimes
ld bc, 3
add hl, bc
ld a, d
call GetFarByte
call FixPicBank
push af
inc hl
ld a, d
call GetFarHalfword
ld de, wDecompressScratch
pop af
call FarDecompress
ld hl, wDecompressScratch
ld c, 6 * 6
call FixBackpicAlignment
pop hl
ld de, wDecompressScratch
ld a, [hROMBank]
ld b, a
call Get2bpp
pop af
ld [rSVBK], a
ret
FixPicBank: ; 511c5
; This is a thing for some reason.
PICS_FIX EQU $36
GLOBAL PICS_FIX
push hl
push bc
sub BANK(Pics_1) - PICS_FIX
ld c, a
ld b, 0
ld hl, .PicsBanks
add hl, bc
ld a, [hl]
pop bc
pop hl
ret
.PicsBanks: ; 511d4
db BANK(Pics_1) + 0
db BANK(Pics_1) + 1
db BANK(Pics_1) + 2
db BANK(Pics_1) + 3
db BANK(Pics_1) + 4
db BANK(Pics_1) + 5
db BANK(Pics_1) + 6
db BANK(Pics_1) + 7
db BANK(Pics_1) + 8
db BANK(Pics_1) + 9
db BANK(Pics_1) + 10
db BANK(Pics_1) + 11
db BANK(Pics_1) + 12
db BANK(Pics_1) + 13
db BANK(Pics_1) + 14
db BANK(Pics_1) + 15
db BANK(Pics_1) + 16
db BANK(Pics_1) + 17
db BANK(Pics_1) + 18
db BANK(Pics_1) + 19
db BANK(Pics_1) + 20
db BANK(Pics_1) + 21
db BANK(Pics_1) + 22
db BANK(Pics_1) + 23
Function511ec: ; 511ec
ld a, c
push de
ld hl, PokemonPicPointers
dec a
ld bc, 6
call AddNTimes
ld a, BANK(PokemonPicPointers)
call GetFarByte
call FixPicBank
push af
inc hl
ld a, BANK(PokemonPicPointers)
call GetFarHalfword
pop af
pop de
call FarDecompress
ret
GetTrainerPic: ; 5120d
ld a, [wTrainerClass]
and a
ret z
cp NUM_TRAINER_CLASSES
ret nc
call WaitBGMap
xor a
ld [hBGMapMode], a
ld hl, TrainerPicPointers
ld a, [wTrainerClass]
dec a
ld bc, 3
call AddNTimes
ld a, [rSVBK]
push af
ld a, BANK(wDecompressScratch)
ld [rSVBK], a
push de
ld a, BANK(TrainerPicPointers)
call GetFarByte
call FixPicBank
push af
inc hl
ld a, BANK(TrainerPicPointers)
call GetFarHalfword
pop af
ld de, wDecompressScratch
call FarDecompress
pop hl
ld de, wDecompressScratch
ld c, 7 * 7
ld a, [hROMBank]
ld b, a
call Get2bpp
pop af
ld [rSVBK], a
call WaitBGMap
ld a, $1
ld [hBGMapMode], a
ret
DecompressGet2bpp: ; 5125d
; Decompress lz data from b:hl to scratch space at 6:d000, then copy it to address de.
ld a, [rSVBK]
push af
ld a, BANK(wDecompressScratch)
ld [rSVBK], a
push de
push bc
ld a, b
ld de, wDecompressScratch
call FarDecompress
pop bc
ld de, wDecompressScratch
pop hl
ld a, [hROMBank]
ld b, a
call Get2bpp
pop af
ld [rSVBK], a
ret
FixBackpicAlignment: ; 5127c
push de
push bc
ld a, [wBoxAlignment]
and a
jr z, .keep_dims
ld a, c
cp 7 * 7
ld de, 7 * 7 tiles
jr z, .got_dims
cp 6 * 6
ld de, 6 * 6 tiles
jr z, .got_dims
ld de, 5 * 5 tiles
.got_dims
ld a, [hl]
ld b, 0
ld c, 8
.loop
rra
rl b
dec c
jr nz, .loop
ld a, b
ld [hli], a
dec de
ld a, e
or d
jr nz, .got_dims
.keep_dims
pop bc
pop de
ret
PadFrontpic: ; 512ab
; pads frontpic to fill 7x7 box
ld a, b
cp 6
jr z, .six
cp 5
jr z, .five
.seven_loop
ld c, $70
call LoadOrientedFrontpic
dec b
jr nz, .seven_loop
ret
.six
ld c, $70
xor a
call .Fill
.six_loop
ld c, $10
xor a
call .Fill
ld c, $60
call LoadOrientedFrontpic
dec b
jr nz, .six_loop
ret
.five
ld c, $70
xor a
call .Fill
.five_loop
ld c, $20
xor a
call .Fill
ld c, $50
call LoadOrientedFrontpic
dec b
jr nz, .five_loop
ld c, $70
xor a
call .Fill
ret
.Fill:
ld [hli], a
dec c
jr nz, .Fill
ret
LoadOrientedFrontpic: ; 512f2
ld a, [wBoxAlignment]
and a
jr nz, .x_flip
.left_loop
ld a, [de]
inc de
ld [hli], a
dec c
jr nz, .left_loop
ret
.x_flip
push bc
.right_loop
ld a, [de]
inc de
ld b, a
xor a
rept 8
rr b
rla
endr
ld [hli], a
dec c
jr nz, .right_loop
pop bc
ret

View File

@@ -0,0 +1,86 @@
SwapTextboxPalettes:: ; 4c000
hlcoord 0, 0
decoord 0, 0, wAttrMap
ld b, SCREEN_HEIGHT
.loop
push bc
ld c, SCREEN_WIDTH
.innerloop
ld a, [hl]
push hl
srl a
jr c, .UpperNybble
ld hl, wTilesetPalettes
add [hl]
ld l, a
ld a, [wTilesetPalettes + 1]
adc 0
ld h, a
ld a, [hl]
and $f
jr .next
.UpperNybble:
ld hl, wTilesetPalettes
add [hl]
ld l, a
ld a, [wTilesetPalettes + 1]
adc 0
ld h, a
ld a, [hl]
swap a
and $f
.next
pop hl
ld [de], a
res 7, [hl]
inc hl
inc de
dec c
jr nz, .innerloop
pop bc
dec b
jr nz, .loop
ret
ScrollBGMapPalettes:: ; 4c03f
ld hl, wBGMapBuffer
ld de, wBGMapPalBuffer
.loop
ld a, [hl]
push hl
srl a
jr c, .UpperNybble
; .LowerNybble
ld hl, wTilesetPalettes
add [hl]
ld l, a
ld a, [wTilesetPalettes + 1]
adc 0
ld h, a
ld a, [hl]
and $f
jr .next
.UpperNybble:
ld hl, wTilesetPalettes
add [hl]
ld l, a
ld a, [wTilesetPalettes + 1]
adc 0
ld h, a
ld a, [hl]
swap a
and $f
.next
pop hl
ld [de], a
res 7, [hl]
inc hl
inc de
dec c
jr nz, .loop
ret

View File

@@ -0,0 +1,20 @@
LoadMapGroupRoof:: ; 1c000
ld a, [wMapGroup]
ld e, a
ld d, 0
ld hl, MapGroupRoofs
add hl, de
ld a, [hl]
cp -1
ret z
ld hl, Roofs
ld bc, 9 tiles
call AddNTimes
ld de, vTiles2 tile $0a
ld bc, 9 tiles
call CopyBytes
ret
; 1c021
INCLUDE "data/maps/roofs.asm"

471
engine/gfx/mon_icons.asm Executable file
View File

@@ -0,0 +1,471 @@
LoadOverworldMonIcon: ; 8e82b
ld a, e
call ReadMonMenuIcon
ld l, a
ld h, 0
add hl, hl
ld de, IconPointers
add hl, de
ld a, [hli]
ld e, a
ld d, [hl]
ld b, BANK(Icons)
ld c, 8
ret
; 8e83f
LoadMenuMonIcon: ; 8e83f
push hl
push de
push bc
call .LoadIcon
pop bc
pop de
pop hl
ret
; 8e849
.LoadIcon: ; 8e849
ld d, 0
ld hl, .Jumptable
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
; 8e854
.Jumptable: ; 8e854 (23:6854)
dw PartyMenu_InitAnimatedMonIcon ; party menu
dw NamingScreen_InitAnimatedMonIcon ; naming screen
dw MoveList_InitAnimatedMonIcon ; moves (?)
dw Trade_LoadMonIconGFX ; trade
dw Mobile_InitAnimatedMonIcon ; mobile
dw Mobile_InitPartyMenuBGPal71 ; mobile
dw .GetPartyMenuMonIcon ; unused
.GetPartyMenuMonIcon: ; 8e862 (23:6862)
call InitPartyMenuIcon
call .GetPartyMonItemGFX
call SetPartyMonIconAnimSpeed
ret
.GetPartyMonItemGFX: ; 8e86c (23:686c)
push bc
ld a, [hObjectStructIndexBuffer]
ld hl, wPartyMon1Item
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
pop bc
ld a, [hl]
and a
jr z, .no_item
push hl
push bc
ld d, a
callfar ItemIsMail
pop bc
pop hl
jr c, .not_mail
ld a, $6
jr .got_tile
.not_mail
ld a, $5
; jr .got_tile
.no_item
ld a, $4
.got_tile
ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
add hl, bc
ld [hl], a
ret
Mobile_InitAnimatedMonIcon: ; 8e898 (23:6898)
call PartyMenu_InitAnimatedMonIcon
ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
add hl, bc
ld a, SPRITE_ANIM_SEQ_NULL
ld [hl], a
ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc
ld a, 9 * 8
ld [hl], a
ld hl, SPRITEANIMSTRUCT_YCOORD
add hl, bc
ld a, 9 * 8
ld [hl], a
ret
Mobile_InitPartyMenuBGPal71: ; 8e8b1 (23:68b1)
call InitPartyMenuIcon
call SetPartyMonIconAnimSpeed
ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
add hl, bc
ld a, SPRITE_ANIM_SEQ_NULL
ld [hl], a
ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc
ld a, 3 * 8
ld [hl], a
ld hl, SPRITEANIMSTRUCT_YCOORD
add hl, bc
ld a, 12 * 8
ld [hl], a
ld a, c
ld [wc608], a
ld a, b
ld [wc608 + 1], a
ret
PartyMenu_InitAnimatedMonIcon: ; 8e8d5 (23:68d5)
call InitPartyMenuIcon
call .SpawnItemIcon
call SetPartyMonIconAnimSpeed
ret
.SpawnItemIcon: ; 8e8df (23:68df)
push bc
ld a, [hObjectStructIndexBuffer]
ld hl, wPartyMon1Item
ld bc, PARTYMON_STRUCT_LENGTH
call AddNTimes
pop bc
ld a, [hl]
and a
ret z
push hl
push bc
ld d, a
callfar ItemIsMail
pop bc
pop hl
jr c, .mail
ld a, SPRITE_ANIM_FRAMESET_PARTY_MON_WITH_ITEM
jr .okay
.mail
ld a, SPRITE_ANIM_FRAMESET_PARTY_MON_WITH_MAIL
.okay
ld hl, SPRITEANIMSTRUCT_FRAMESET_ID
add hl, bc
ld [hl], a
ret
InitPartyMenuIcon: ; 8e908 (23:6908)
ld a, [wCurIconTile]
push af
ld a, [hObjectStructIndexBuffer]
ld hl, wPartySpecies
ld e, a
ld d, $0
add hl, de
ld a, [hl]
call ReadMonMenuIcon
ld [wCurIcon], a
call GetMemIconGFX
ld a, [hObjectStructIndexBuffer]
; y coord
add a
add a
add a
add a
add $1c
ld d, a
; x coord
ld e, $10
; type is partymon icon
ld a, SPRITE_ANIM_INDEX_PARTY_MON
call InitSpriteAnimStruct
pop af
ld hl, SPRITEANIMSTRUCT_TILE_ID
add hl, bc
ld [hl], a
ret
SetPartyMonIconAnimSpeed: ; 8e936 (23:6936)
push bc
ld a, [hObjectStructIndexBuffer]
ld b, a
call .getspeed
ld a, b
pop bc
ld hl, SPRITEANIMSTRUCT_DURATIONOFFSET
add hl, bc
ld [hl], a
rlca
rlca
ld hl, SPRITEANIMSTRUCT_0D
add hl, bc
ld [hl], a
ret
.getspeed ; 8e94c (23:694c)
farcall PlacePartymonHPBar
call GetHPPal
ld e, d
ld d, 0
ld hl, .speeds
add hl, de
ld b, [hl]
ret
; 8e95e (23:695e)
.speeds ; 8e95e
db $00 ; HP_GREEN
db $40 ; HP_YELLOW
db $80 ; HP_RED
; 8e961
NamingScreen_InitAnimatedMonIcon: ; 8e961 (23:6961)
ld a, [wd265]
call ReadMonMenuIcon
ld [wCurIcon], a
xor a
call GetIconGFX
depixel 4, 4, 4, 0
ld a, SPRITE_ANIM_INDEX_PARTY_MON
call InitSpriteAnimStruct
ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
add hl, bc
ld [hl], SPRITE_ANIM_SEQ_NULL
ret
MoveList_InitAnimatedMonIcon: ; 8e97d (23:697d)
ld a, [wd265]
call ReadMonMenuIcon
ld [wCurIcon], a
xor a
call GetIconGFX
ld d, 3 * 8 + 2 ; depixel 3, 4, 2, 4
ld e, 4 * 8 + 4
ld a, SPRITE_ANIM_INDEX_PARTY_MON
call InitSpriteAnimStruct
ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
add hl, bc
ld [hl], SPRITE_ANIM_SEQ_NULL
ret
Trade_LoadMonIconGFX: ; 8e99a (23:699a)
ld a, [wd265]
call ReadMonMenuIcon
ld [wCurIcon], a
ld a, $62
ld [wCurIconTile], a
call GetMemIconGFX
ret
GetSpeciesIcon: ; 8e9ac
; Load species icon into VRAM at tile a
push de
ld a, [wd265]
call ReadMonMenuIcon
ld [wCurIcon], a
pop de
ld a, e
call GetIconGFX
ret
; 8e9bc
FlyFunction_GetMonIcon: ; 8e9bc (23:69bc)
push de
ld a, [wd265]
call ReadMonMenuIcon
ld [wCurIcon], a
pop de
ld a, e
call GetIcon_a
ret
; 8e9cc (23:69cc)
Unreferenced_GetMonIcon2: ; 8e9cc
push de
ld a, [wd265]
call ReadMonMenuIcon
ld [wCurIcon], a
pop de
call GetIcon_de
ret
; 8e9db
GetMemIconGFX: ; 8e9db (23:69db)
ld a, [wCurIconTile]
GetIconGFX: ; 8e9de
call GetIcon_a
ld de, 8 tiles
add hl, de
ld de, HeldItemIcons
lb bc, BANK(HeldItemIcons), 2
call GetGFXUnlessMobile
ld a, [wCurIconTile]
add 10
ld [wCurIconTile], a
ret
HeldItemIcons:
INCBIN "gfx/icons/mail.2bpp"
INCBIN "gfx/icons/item.2bpp"
; 8ea17
GetIcon_de: ; 8ea17
; Load icon graphics into VRAM starting from tile de.
ld l, e
ld h, d
jr GetIcon
GetIcon_a: ; 8ea1b
; Load icon graphics into VRAM starting from tile a.
ld l, a
ld h, 0
GetIcon: ; 8ea1e
; Load icon graphics into VRAM starting from tile hl.
; One tile is 16 bytes long.
rept 4
add hl, hl
endr
ld de, vTiles0
add hl, de
push hl
; The icons are contiguous, in order and of the same
; size, so the pointer table is somewhat redundant.
ld a, [wCurIcon]
push hl
ld l, a
ld h, 0
add hl, hl
ld de, IconPointers
add hl, de
ld a, [hli]
ld e, a
ld d, [hl]
pop hl
lb bc, BANK(Icons), 8
call GetGFXUnlessMobile
pop hl
ret
; 8ea3f
GetGFXUnlessMobile: ; 8ea3f
ld a, [wLinkMode]
cp LINK_MOBILE
jp nz, Request2bpp
jp Get2bpp_2
; 8ea4a
FreezeMonIcons: ; 8ea4a
ld hl, wSpriteAnimationStructs
ld e, PARTY_LENGTH
ld a, [wMenuCursorY]
ld d, a
.loop
ld a, [hl]
and a
jr z, .next
cp d
jr z, .loadwithtwo
ld a, SPRITE_ANIM_SEQ_NULL
jr .ok
.loadwithtwo
ld a, SPRITE_ANIM_SEQ_PARTY_MON_SWITCH
.ok
push hl
ld c, l
ld b, h
ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
add hl, bc
ld [hl], a
pop hl
.next
ld bc, $10
add hl, bc
dec e
jr nz, .loop
ret
; 8ea71
UnfreezeMonIcons: ; 8ea71
ld hl, wSpriteAnimationStructs
ld e, PARTY_LENGTH
.loop
ld a, [hl]
and a
jr z, .next
push hl
ld c, l
ld b, h
ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
add hl, bc
ld [hl], SPRITE_ANIM_SEQ_PARTY_MON
pop hl
.next
ld bc, $10
add hl, bc
dec e
jr nz, .loop
ret
; 8ea8c (23:6a8c)
HoldSwitchmonIcon: ; 8ea8c
ld hl, wSpriteAnimationStructs
ld e, PARTY_LENGTH
ld a, [wSwitchMon]
ld d, a
.loop
ld a, [hl]
and a
jr z, .next
cp d
jr z, .is_switchmon
ld a, SPRITE_ANIM_SEQ_PARTY_MON_SELECTED
jr .join_back
.is_switchmon
ld a, SPRITE_ANIM_SEQ_PARTY_MON_SWITCH
.join_back
push hl
ld c, l
ld b, h
ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID
add hl, bc
ld [hl], a
pop hl
.next
ld bc, $10
add hl, bc
dec e
jr nz, .loop
ret
ReadMonMenuIcon: ; 8eab3
cp EGG
jr z, .egg
dec a
ld hl, MonMenuIcons
ld e, a
ld d, 0
add hl, de
ld a, [hl]
ret
.egg
ld a, ICON_EGG
ret
; 8eac4
INCLUDE "data/pokemon/menu_icons.asm"
INCLUDE "data/icon_pointers.asm"
INCLUDE "gfx/icons.asm"

1141
engine/gfx/pic_animation.asm Normal file

File diff suppressed because it is too large Load Diff

224
engine/gfx/player_gfx.asm Normal file
View File

@@ -0,0 +1,224 @@
Unreferenced_Function88248: ; 88248
ld c, CAL
ld a, [wPlayerGender]
bit PLAYERGENDER_FEMALE_F, a
jr z, .okay
ld c, KAREN
.okay
ld a, c
ld [wTrainerClass], a
ret
MovePlayerPicRight: ; 88258
hlcoord 6, 4
ld de, 1
jr MovePlayerPic
MovePlayerPicLeft: ; 88260
hlcoord 13, 4
ld de, -1
; fallthrough
MovePlayerPic: ; 88266
; Move player pic at hl by de * 7 tiles.
ld c, $8
.loop
push bc
push hl
push de
xor a
ld [hBGMapMode], a
lb bc, 7, 7
predef PlaceGraphic
xor a
ld [hBGMapThird], a
call WaitBGMap
call DelayFrame
pop de
pop hl
add hl, de
pop bc
dec c
ret z
push hl
push bc
ld a, l
sub e
ld l, a
ld a, h
sbc d
ld h, a
lb bc, 7, 7
call ClearBox
pop bc
pop hl
jr .loop
ShowPlayerNamingChoices: ; 88297
ld hl, ChrisNameMenuHeader
ld a, [wPlayerGender]
bit PLAYERGENDER_FEMALE_F, a
jr z, .GotGender
ld hl, KrisNameMenuHeader
.GotGender:
call LoadMenuHeader
call VerticalMenu
ld a, [wMenuCursorY]
dec a
call CopyNameFromMenu
call CloseWindow
ret
INCLUDE "data/player_names.asm"
GetPlayerNameArray: ; 88318 This Function is never called
ld hl, wPlayerName
ld de, MalePlayerNameArray
ld a, [wPlayerGender]
bit PLAYERGENDER_FEMALE_F, a
jr z, .done
ld de, FemalePlayerNameArray
.done
call InitName
ret
GetPlayerIcon: ; 8832c
; Get the player icon corresponding to gender
; Male
ld de, ChrisSpriteGFX
ld b, BANK(ChrisSpriteGFX)
ld a, [wPlayerGender]
bit PLAYERGENDER_FEMALE_F, a
jr z, .done
; Female
ld de, KrisSpriteGFX
ld b, BANK(KrisSpriteGFX)
.done
ret
GetCardPic: ; 8833e
ld hl, ChrisCardPic
ld a, [wPlayerGender]
bit PLAYERGENDER_FEMALE_F, a
jr z, .GotClass
ld hl, KrisCardPic
.GotClass:
ld de, vTiles2 tile $00
ld bc, $23 tiles
ld a, BANK(ChrisCardPic) ; BANK(KrisCardPic)
call FarCopyBytes
ld hl, CardGFX
ld de, vTiles2 tile $23
ld bc, 6 tiles
ld a, BANK(CardGFX)
call FarCopyBytes
ret
ChrisCardPic: ; 88365
INCBIN "gfx/trainer_card/chris_card.2bpp"
KrisCardPic: ; 88595
INCBIN "gfx/trainer_card/kris_card.2bpp"
CardGFX: ; 887c5
INCBIN "gfx/trainer_card/trainer_card.2bpp"
GetPlayerBackpic: ; 88825
ld a, [wPlayerGender]
bit PLAYERGENDER_FEMALE_F, a
jr z, GetChrisBackpic
call GetKrisBackpic
ret
GetChrisBackpic: ; 88830
ld hl, ChrisBackpic
ld b, BANK(ChrisBackpic)
ld de, vTiles2 tile $31
ld c, 7 * 7
predef DecompressGet2bpp
ret
HOF_LoadTrainerFrontpic: ; 88840
call WaitBGMap
xor a
ld [hBGMapMode], a
ld e, 0
ld a, [wPlayerGender]
bit PLAYERGENDER_FEMALE_F, a
jr z, .GotClass
ld e, 1
.GotClass:
ld a, e
ld [wTrainerClass], a
ld de, ChrisPic
ld a, [wPlayerGender]
bit PLAYERGENDER_FEMALE_F, a
jr z, .GotPic
ld de, KrisPic
.GotPic:
ld hl, vTiles2
ld b, BANK(ChrisPic) ; BANK(KrisPic)
ld c, 7 * 7
call Get2bpp
call WaitBGMap
ld a, $1
ld [hBGMapMode], a
ret
DrawIntroPlayerPic: ; 88874
; Draw the player pic at (6,4).
; Get class
ld e, CHRIS
ld a, [wPlayerGender]
bit PLAYERGENDER_FEMALE_F, a
jr z, .GotClass
ld e, KRIS
.GotClass:
ld a, e
ld [wTrainerClass], a
; Load pic
ld de, ChrisPic
ld a, [wPlayerGender]
bit PLAYERGENDER_FEMALE_F, a
jr z, .GotPic
ld de, KrisPic
.GotPic:
ld hl, vTiles2
ld b, BANK(ChrisPic) ; BANK(KrisPic)
ld c, 7 * 7 ; dimensions
call Get2bpp
; Draw
xor a
ld [hGraphicStartTile], a
hlcoord 6, 4
lb bc, 7, 7
predef PlaceGraphic
ret
ChrisPic: ; 888a9
INCBIN "gfx/player/chris.2bpp"
KrisPic: ; 88bb9
INCBIN "gfx/player/kris.2bpp"
GetKrisBackpic: ; 88ec9
; Kris's backpic is uncompressed.
ld de, KrisBackpic
ld hl, vTiles2 tile $31
lb bc, BANK(KrisBackpic), 7 * 7 ; dimensions
call Get2bpp
ret
KrisBackpic: ; 88ed6
INCBIN "gfx/player/kris_back.2bpp"

605
engine/gfx/sgb_layouts.asm Normal file

File diff suppressed because it is too large Load Diff

889
engine/gfx/sprite_anims.asm Executable file

File diff suppressed because it is too large Load Diff

677
engine/gfx/sprites.asm Executable file

File diff suppressed because it is too large Load Diff

1060
engine/gfx/tileset_anims.asm Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,151 @@
LoadSpecialMapPalette: ; 494ac
ld a, [wMapTileset]
cp TILESET_POKECOM_CENTER
jr z, .pokecom_2f
cp TILESET_BATTLE_TOWER
jr z, .battle_tower
cp TILESET_ICE_PATH
jr z, .ice_path
cp TILESET_HOUSE
jr z, .house
cp TILESET_RADIO_TOWER
jr z, .radio_tower
cp TILESET_MANSION
jr z, .mansion_mobile
jr .do_nothing
.pokecom_2f
call LoadPokeComPalette
scf
ret
.battle_tower
call LoadBattleTowerPalette
scf
ret
.ice_path
ld a, [wEnvironment]
and $7
cp INDOOR ; Hall of Fame
jr z, .do_nothing
call LoadIcePathPalette
scf
ret
.house
call LoadHousePalette
scf
ret
.radio_tower
call LoadRadioTowerPalette
scf
ret
.mansion_mobile
call LoadMansionPalette
scf
ret
.do_nothing
and a
ret
; 494f2
LoadPokeComPalette: ; 494f2
ld a, BANK(wBGPals1)
ld de, wBGPals1
ld hl, PokeComPalette
ld bc, 8 palettes
call FarCopyWRAM
ret
; 49501
PokeComPalette: ; 49501
INCLUDE "gfx/tilesets/pokecom_center.pal"
; 49541
LoadBattleTowerPalette: ; 49541
ld a, BANK(wBGPals1)
ld de, wBGPals1
ld hl, BattleTowerPalette
ld bc, 8 palettes
call FarCopyWRAM
ret
; 49550
BattleTowerPalette: ; 49550
INCLUDE "gfx/tilesets/battle_tower.pal"
; 49590
LoadIcePathPalette: ; 49590
ld a, BANK(wBGPals1)
ld de, wBGPals1
ld hl, IcePathPalette
ld bc, 8 palettes
call FarCopyWRAM
ret
; 4959f
IcePathPalette: ; 4959f
INCLUDE "gfx/tilesets/ice_path.pal"
; 495df
LoadHousePalette: ; 495df
ld a, BANK(wBGPals1)
ld de, wBGPals1
ld hl, HousePalette
ld bc, 8 palettes
call FarCopyWRAM
ret
; 495ee
HousePalette: ; 495ee
INCLUDE "gfx/tilesets/house.pal"
; 4962e
LoadRadioTowerPalette: ; 4962e
ld a, BANK(wBGPals1)
ld de, wBGPals1
ld hl, RadioTowerPalette
ld bc, 8 palettes
call FarCopyWRAM
ret
; 4963d
RadioTowerPalette: ; 4963d
INCLUDE "gfx/tilesets/radio_tower.pal"
; 4967d
MansionPalette1: ; 4967d
INCLUDE "gfx/tilesets/mansion_1.pal"
; 496c5
LoadMansionPalette: ; 496c5
ld a, BANK(wBGPals1)
ld de, wBGPals1
ld hl, MansionPalette1
ld bc, 8 palettes
call FarCopyWRAM
ld a, BANK(wBGPals1)
ld de, wBGPals1 palette PAL_BG_YELLOW
ld hl, MansionPalette2
ld bc, 1 palettes
call FarCopyWRAM
ld a, BANK(wBGPals1)
ld de, wBGPals1 palette PAL_BG_WATER
ld hl, MansionPalette1 + 6 palettes
ld bc, 1 palettes
call FarCopyWRAM
ld a, BANK(wBGPals1)
ld de, wBGPals1 palette PAL_BG_ROOF
ld hl, MansionPalette1 + 8 palettes
ld bc, 1 palettes
call FarCopyWRAM
ret
; 496fe
MansionPalette2: ; 496fe
INCLUDE "gfx/tilesets/mansion_2.pal"
; 49706

View File

@@ -0,0 +1,415 @@
DummyPredef35: ; 8c000
DummyPredef36:
ret
UpdateTimeOfDayPal:: ; 8c001
call UpdateTime
ld a, [wTimeOfDay]
ld [wCurTimeOfDay], a
call GetTimePalette
ld [wTimeOfDayPal], a
ret
; 8c011
_TimeOfDayPals:: ; 8c011
; return carry if pals are changed
; forced pals?
ld hl, wTimeOfDayPalFlags
bit 7, [hl]
jr nz, .dontchange
; do we need to bother updating?
ld a, [wTimeOfDay]
ld hl, wCurTimeOfDay
cp [hl]
jr z, .dontchange
; if so, the time of day has changed
ld a, [wTimeOfDay]
ld [wCurTimeOfDay], a
; get palette id
call GetTimePalette
; same palette as before?
ld hl, wTimeOfDayPal
cp [hl]
jr z, .dontchange
; update palette id
ld [wTimeOfDayPal], a
; save bg palette 7
ld hl, wBGPals1 palette PAL_BG_TEXT
; save wram bank
ld a, [rSVBK]
ld b, a
ld a, BANK(wBGPals1)
ld [rSVBK], a
; push palette
ld c, NUM_PAL_COLORS
.push
ld d, [hl]
inc hl
ld e, [hl]
inc hl
push de
dec c
jr nz, .push
; restore wram bank
ld a, b
ld [rSVBK], a
; update sgb pals
ld b, SCGB_MAPPALS
call GetSGBLayout
; restore bg palette 7
ld hl, wOBPals1 - 1 ; last byte in wBGPals1
; save wram bank
ld a, [rSVBK]
ld d, a
ld a, BANK(wOBPals1)
ld [rSVBK], a
; pop palette
ld e, NUM_PAL_COLORS
.pop
pop bc
ld [hl], c
dec hl
ld [hl], b
dec hl
dec e
jr nz, .pop
; restore wram bank
ld a, d
ld [rSVBK], a
; update palettes
call _UpdateTimePals
call DelayFrame
; successful change
scf
ret
.dontchange
; no change occurred
and a
ret
; 8c070
_UpdateTimePals:: ; 8c070
ld c, $9 ; normal
call GetTimePalFade
call DmgToCgbTimePals
ret
; 8c079
FadeInPalettes:: ; 8c079
ld c, $12
call GetTimePalFade
ld b, $4
call ConvertTimePalsDecHL
ret
; 8c084
FadeOutPalettes:: ; 8c084
call FillWhiteBGColor
ld c, $9
call GetTimePalFade
ld b, $4
call ConvertTimePalsIncHL
ret
; 8c092
BattleTowerFade: ; 8c092
call FillWhiteBGColor
ld c, $9
call GetTimePalFade
ld b, $4
.asm_8c09c
call DmgToCgbTimePals
inc hl
inc hl
inc hl
ld c, $7
call DelayFrames
dec b
jr nz, .asm_8c09c
ret
; 8c0ab
FadeInQuickly: ; 8c0ab
ld c, $0
call GetTimePalFade
ld b, $4
call ConvertTimePalsIncHL
ret
; 8c0b6
FadeBlackQuickly: ; 8c0b6
ld c, $9
call GetTimePalFade
ld b, $4
call ConvertTimePalsDecHL
ret
; 8c0c1
FillWhiteBGColor: ; 8c0c1
ld a, [rSVBK]
push af
ld a, BANK(wBGPals1)
ld [rSVBK], a
ld hl, wBGPals1
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
ld hl, wBGPals1 + 1 palettes
ld c, 6
.loop
ld a, e
ld [hli], a
ld a, d
ld [hli], a
rept 6
inc hl
endr
dec c
jr nz, .loop
pop af
ld [rSVBK], a
ret
; 8c0e5
ReplaceTimeOfDayPals: ; 8c0e5
ld hl, .BrightnessLevels
ld a, [wMapTimeOfDay]
cp $4 ; Dark cave, needs Flash
jr z, .DarkCave
and $7
add l
ld l, a
ld a, $0
adc h
ld h, a
ld a, [hl]
ld [wTimeOfDayPalset], a
ret
.DarkCave:
ld a, [wStatusFlags]
bit STATUSFLAGS_FLASH_F, a
jr nz, .UsedFlash
ld a, %11111111 ; 3, 3, 3, 3
ld [wTimeOfDayPalset], a
ret
.UsedFlash:
ld a, %10101010 ; 2, 2, 2, 2
ld [wTimeOfDayPalset], a
ret
; 8c10f (23:410f)
.BrightnessLevels: ; 8c10f
dc 3, 2, 1, 0
dc 1, 1, 1, 1
dc 2, 2, 2, 2
dc 0, 0, 0, 0
dc 3, 3, 3, 3
dc 3, 2, 1, 0
dc 3, 2, 1, 0
dc 3, 2, 1, 0
; 8c117
GetTimePalette: ; 8c117
ld a, [wTimeOfDay]
ld e, a
ld d, 0
ld hl, .TimePalettes
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
; 8c126
.TimePalettes:
dw .MorningPalette
dw .DayPalette
dw .NitePalette
dw .DarknessPalette
.MorningPalette:
ld a, [wTimeOfDayPalset]
and %00000011 ; 0
ret
.DayPalette:
ld a, [wTimeOfDayPalset]
and %00001100 ; 1
srl a
srl a
ret
.NitePalette:
ld a, [wTimeOfDayPalset]
and %00110000 ; 2
swap a
ret
.DarknessPalette:
ld a, [wTimeOfDayPalset]
and %11000000 ; 3
rlca
rlca
ret
; 8c14e
DmgToCgbTimePals: ; 8c14e
push hl
push de
ld a, [hli]
call DmgToCgbBGPals
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
call DmgToCgbObjPals
pop de
pop hl
ret
; 8c15e
ConvertTimePalsIncHL: ; 8c15e
.loop
call DmgToCgbTimePals
inc hl
inc hl
inc hl
ld c, 2
call DelayFrames
dec b
jr nz, .loop
ret
; 8c16d
ConvertTimePalsDecHL: ; 8c16d
.loop
call DmgToCgbTimePals
dec hl
dec hl
dec hl
ld c, 2
call DelayFrames
dec b
jr nz, .loop
ret
; 8c17c
GetTimePalFade: ; 8c17c
; check cgb
ld a, [hCGB]
and a
jr nz, .cgb
; else: dmg
; index
ld a, [wTimeOfDayPal]
and %11
; get fade table
push bc
ld c, a
ld b, $0
ld hl, .dmgfades
add hl, bc
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
pop bc
; get place in fade table
ld b, $0
add hl, bc
ret
.cgb
ld hl, .cgbfade
ld b, $0
add hl, bc
ret
.dmgfades
dw .morn
dw .day
dw .nite
dw .darkness
.morn
db %11111111, %11111111, %11111111
db %11111110, %11111110, %11111110
db %11111001, %11100100, %11100100
db %11100100, %11010000, %11010000
db %10010000, %10000000, %10000000
db %01000000, %01000000, %01000000
db %00000000, %00000000, %00000000
.day
db %11111111, %11111111, %11111111
db %11111110, %11111110, %11111110
db %11111001, %11100100, %11100100
db %11100100, %11010000, %11010000
db %10010000, %10000000, %10000000
db %01000000, %01000000, %01000000
db %00000000, %00000000, %00000000
.nite
db %11111111, %11111111, %11111111
db %11111110, %11111110, %11111110
db %11111001, %11100100, %11100100
db %11101001, %11010000, %11010000
db %10010000, %10000000, %10000000
db %01000000, %01000000, %01000000
db %00000000, %00000000, %00000000
.darkness
db %11111111, %11111111, %11111111
db %11111110, %11111110, %11111111
db %11111110, %11100100, %11111111
db %11111101, %11010000, %11111111
db %11111101, %10000000, %11111111
db %00000000, %01000000, %00000000
db %00000000, %00000000, %00000000
.cgbfade
db %11111111, %11111111, %11111111
db %11111110, %11111110, %11111110
db %11111001, %11111001, %11111001
db %11100100, %11100100, %11100100
db %10010000, %10010000, %10010000
db %01000000, %01000000, %01000000
db %00000000, %00000000, %00000000
; 8c20f

1646
engine/gfx/trade_animation.asm Executable file

File diff suppressed because it is too large Load Diff