summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTauwasser <Tauwasser@tauwasser.eu>2018-05-31 14:45:54 +0200
committerTauwasser <Tauwasser@tauwasser.eu>2018-05-31 14:45:54 +0200
commit8a1fcb95a5db9c70746ad3171e9c18614e4138c7 (patch)
treea037edfbdaaa7513bed07aa781f9c6156a10b026
parent83bf91908554ae1ec1f6d287679e58987ed3bc0a (diff)
home/pokemon: disassemble Pokémon sprite uncompression routine
Signed-off-by: Tauwasser <Tauwasser@tauwasser.eu>
-rw-r--r--gfx/pokemon/annon_pics.asm1
-rw-r--r--home/pokemon.asm57
-rw-r--r--shim.sym3
-rw-r--r--wram.asm5
4 files changed, 63 insertions, 3 deletions
diff --git a/gfx/pokemon/annon_pics.asm b/gfx/pokemon/annon_pics.asm
index 2f92fbe..86aca48 100644
--- a/gfx/pokemon/annon_pics.asm
+++ b/gfx/pokemon/annon_pics.asm
@@ -1,3 +1,4 @@
+AnnonPics::
AnnonAPicFront:: INCBIN "gfx/pokemon/annon_a/front.pic"
AnnonAPicBack:: INCBIN "gfx/pokemon/annon_a/back.pic"
AnnonBPicFront:: INCBIN "gfx/pokemon/annon_b/front.pic"
diff --git a/home/pokemon.asm b/home/pokemon.asm
index d38e1a0..9b1eec2 100644
--- a/home/pokemon.asm
+++ b/home/pokemon.asm
@@ -43,9 +43,64 @@ GetMonHeader:: ; 3a4b (0:3a4b)
pop bc
ret
-SECTION "3B3F", ROM0[$3b3f]
+SECTION "3AED", ROM0[$3aed]
+; Uncompresses the front or back sprite of the specified mon
+; assumes the corresponding mon header is already loaded
+; hl contains offset to sprite pointer ($b for front or $d for back)
+UncompressMonSprite:: ; 3aed (0:3aed)
+ ld a, [wMonDexIndex]
+ and a
+ ret z
+ ld bc, wMonHeader
+ add hl, bc
+ cp DEX_ANNON
+ jr z, .uncompress_annon
+ ld a, [hli]
+ ld [wSpriteInputPtr], a
+ ld a, [hl]
+ ld [wSpriteInputPtr + 1], a
+ ld hl, MonSpriteBankList
+ ld a, [wMonDexIndex]
+ ld b, a
+ ; get Pokémon picture bank pointer from list
+.loop
+ ld a, BANK(MonSpriteBankList)
+ call GetFarByte
+ inc hl
+ inc hl
+ cp b
+ jr c, .loop
+ dec hl
+ ld a, BANK(MonSpriteBankList)
+ call GetFarByte
+ jp UncompressSpriteData
+.uncompress_annon
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [wAnnonID]
+ dec a
+ add a
+ add a
+ ld c, a
+ ld b, $00
+ add hl, bc
+ ld a, BANK(AnnonPicPtrs)
+ call GetFarByte
+ ld [wSpriteInputPtr], a
+ inc hl
+ ld a, BANK(AnnonPicPtrs)
+ call GetFarByte
+ ld [wSpriteInputPtr + 1], a
+ ld a, BANK(AnnonPics)
+ jp UncompressSpriteData
+
+; Uncompress Pokémon Front Srite for
+; mon currently loaded in wMonHeader
+; to 0x9000
; de: destination location
+; returns the sprite dimension in c
LoadMonFrontSprite:: ; 3b3f
push de
ld hl, wMonHFrontSprite - wMonHeader
diff --git a/shim.sym b/shim.sym
index dd77bba..78b313c 100644
--- a/shim.sym
+++ b/shim.sym
@@ -32,7 +32,6 @@
00:3655 SetHPPal.done
00:36C8 NamesPointers
00:36E0 GetName
-00:3AED UncompressMonSprite
00:3D86 WaitSFX
00:3D87 WaitSFX.wait
00:3DA5 MaxVolume
@@ -68,6 +67,8 @@
0e:4ba0 LoadTrainerClassName.got_name
0e:4ba9 LoadTrainerClass
+10:40A6 ShowPokedexMenu
+
14:6D75 PokemonNames
23:4349 OverworldFadeOut
diff --git a/wram.asm b/wram.asm
index c750a93..001481f 100644
--- a/wram.asm
+++ b/wram.asm
@@ -82,7 +82,7 @@ wLYOverrides:: ; c600
ds SCREEN_HEIGHT_PX
SECTION "CB56", WRAM0[$CB5B]
-wcb5b:: ds 1
+wcb5b:: ds 1 ; multipurpose, also wName, wMonDexIndex2
wNameCategory:: ds 1
SECTION "CB62", WRAM0[$CB62]
@@ -143,6 +143,9 @@ wPredefBC:: ; cd54
wFarCallBCBuffer:: ; cd54
dw
+SECTION "CD78", WRAM0[$CD78]
+
+wMonDexIndex: ds 1 ; cd78
SECTION "CE00", WRAM0[$CE00]