Merge pull request #87 from YamaArashi/master

commented mon_party_sprites.asm
This commit is contained in:
yenatch 2015-03-14 02:08:30 -04:00
commit ec76703936
9 changed files with 92 additions and 62 deletions

View file

@ -92,7 +92,7 @@ DisplayNamingScreen: ; 6596 (1:6596)
call GoPAL_SET call GoPAL_SET
call LoadHpBarAndStatusTilePatterns call LoadHpBarAndStatusTilePatterns
call LoadEDTile call LoadEDTile
callba Func_7176c callba LoadMonPartySpriteGfx
hlCoord 0, 4 hlCoord 0, 4
ld b, $9 ld b, $9
ld c, $12 ld c, $12
@ -114,7 +114,7 @@ DisplayNamingScreen: ; 6596 (1:6596)
ld hl, wHPBarMaxHP + 1 ld hl, wHPBarMaxHP + 1
ld [hli], a ld [hli], a
ld [hli], a ld [hli], a
ld [W_SUBANIMTRANSFORM], a ld [wPartyMonAnimCounter], a
.asm_65ed .asm_65ed
call PrintAlphabet call PrintAlphabet
call GBPalNormal call GBPalNormal
@ -472,7 +472,7 @@ PrintNamingText: ; 68f8 (1:68f8)
ld a, [wcf91] ld a, [wcf91]
ld [wcd5d], a ld [wcd5d], a
push af push af
callba Func_71882 callba WriteMonPartySpriteOAMByMonID
pop af pop af
ld [wd11e], a ld [wd11e], a
call GetMonName call GetMonName

View file

@ -22,7 +22,7 @@ DrawPartyMenu_: ; 12cd2 (4:6cd2)
ld [H_AUTOBGTRANSFERENABLED],a ld [H_AUTOBGTRANSFERENABLED],a
call ClearScreen call ClearScreen
call UpdateSprites ; move sprites call UpdateSprites ; move sprites
callba Func_71791 ; load pokemon icon graphics callba LoadMonPartySpriteGfxWithLCDDisabled ; load pokemon icon graphics
RedrawPartyMenu_: ; 12ce3 (4:6ce3) RedrawPartyMenu_: ; 12ce3 (4:6ce3)
ld a,[wd07d] ld a,[wd07d]
@ -34,7 +34,7 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3)
ld de,wPartySpecies ld de,wPartySpecies
xor a xor a
ld c,a ld c,a
ld [$FF8C],a ; loop counter ld [hPartyMonIndex],a
ld [wcf2d],a ld [wcf2d],a
.loop .loop
ld a,[de] ld a,[de]
@ -49,11 +49,11 @@ RedrawPartyMenu_: ; 12ce3 (4:6ce3)
call GetPartyMonName call GetPartyMonName
pop hl pop hl
call PlaceString ; print the pokemon's name call PlaceString ; print the pokemon's name
callba Func_71868 ; place the appropriate pokemon icon callba WriteMonPartySpriteOAMByPartyIndex ; place the appropriate pokemon icon
ld a,[$FF8C] ; loop counter ld a,[hPartyMonIndex]
ld [wWhichPokemon],a ld [wWhichPokemon],a
inc a inc a
ld [$FF8C],a ld [hPartyMonIndex],a
call LoadMonData call LoadMonData
pop hl pop hl
push hl push hl

View file

@ -1,6 +1,6 @@
AnimatePartyMon_ForceSpeed1: ; 716f7 (1c:56f7) AnimatePartyMon_ForceSpeed1: ; 716f7 (1c:56f7)
xor a xor a
ld [wCurrentMenuItem], a ; wCurrentMenuItem ld [wCurrentMenuItem], a
ld b, a ld b, a
inc a inc a
jr GetAnimationSpeed jr GetAnimationSpeed
@ -27,7 +27,7 @@ GetAnimationSpeed: ; 7170a (1c:570a)
ld c, a ld c, a
add a add a
ld b, a ld b, a
ld a, [W_SUBANIMTRANSFORM] ; W_SUBANIMTRANSFORM ld a, [wPartyMonAnimCounter]
and a and a
jr z, .resetSprites jr z, .resetSprites
cp c cp c
@ -35,10 +35,10 @@ GetAnimationSpeed: ; 7170a (1c:570a)
.incTimer .incTimer
inc a inc a
cp b cp b
jr nz, .resetTimer jr nz, .skipResetTimer
xor a xor a ; reset timer
.resetTimer .skipResetTimer
ld [W_SUBANIMTRANSFORM], a ; W_SUBANIMTRANSFORM ld [wPartyMonAnimCounter], a
jp DelayFrame jp DelayFrame
.resetSprites .resetSprites
push bc push bc
@ -81,16 +81,24 @@ GetAnimationSpeed: ; 7170a (1c:570a)
ld a, c ld a, c
jr .incTimer jr .incTimer
; Party mon animations cycle between 2 frames.
; The members of the PartyMonSpeeds array specify the number of V-blanks
; that each frame lasts for green HP, yellow HP, and red HP in order.
; On the naming screen, the yellow HP speed is always used.
PartyMonSpeeds: ; 71769 (1c:5769) PartyMonSpeeds: ; 71769 (1c:5769)
db $05,$10,$20 db $05,$10,$20
Func_7176c: ; 7176c (1c:576c) LoadMonPartySpriteGfx: ; 7176c (1c:576c)
ld hl, MonPartySpritePointers ; $57c0 ; Load mon party sprite tile patterns into VRAM during V-blank.
ld hl, MonPartySpritePointers
ld a, $1c ld a, $1c
Func_71771: ; 71771 (1c:5771) LoadAnimSpriteGfx: ; 71771 (1c:5771)
; Load animated sprite tile patterns into VRAM during V-blank. hl is the address
; of an array of structures that contain arguments for CopyVideoData and a is
; the number of structures in the array.
ld bc, $0 ld bc, $0
.asm_71774 .loop
push af push af
push bc push bc
push hl push hl
@ -114,12 +122,14 @@ Func_71771: ; 71771 (1c:5771)
ld c, a ld c, a
pop af pop af
dec a dec a
jr nz, .asm_71774 jr nz, .loop
ret ret
Func_71791: ; 71791 (1c:5791) LoadMonPartySpriteGfxWithLCDDisabled: ; 71791 (1c:5791)
; Load mon party sprite tile patterns into VRAM immediately by disabling the
; LCD.
call DisableLCD call DisableLCD
ld hl, MonPartySpritePointers ; $57c0 ld hl, MonPartySpritePointers
ld a, $1c ld a, $1c
ld bc, $0 ld bc, $0
.asm_7179c .asm_7179c
@ -293,51 +303,57 @@ MonPartySpritePointers: ; 717c0 (1c:57c0)
db BANK(MonPartySprites) db BANK(MonPartySprites)
dw vSprites + $780 dw vSprites + $780
Func_71868: ; 71868 (1c:5868) WriteMonPartySpriteOAMByPartyIndex: ; 71868 (1c:5868)
; Write OAM blocks for the party mon in [hPartyMonIndex].
push hl push hl
push de push de
push bc push bc
ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c ld a, [hPartyMonIndex]
ld hl, wPartySpecies ld hl, wPartySpecies
ld e, a ld e, a
ld d, $0 ld d, 0
add hl, de add hl, de
ld a, [hl] ld a, [hl]
call GetPartyMonSpriteID call GetPartyMonSpriteID
ld [wcd5b], a ld [wcd5b], a
call Func_718c3 call WriteMonPartySpriteOAM
pop bc pop bc
pop de pop de
pop hl pop hl
ret ret
Func_71882: ; 71882 (1c:5882) WriteMonPartySpriteOAMByMonID: ; 71882 (1c:5882)
; Write OAM blocks for mon ID in [wcd5d].
xor a xor a
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c ld [hPartyMonIndex], a
ld a, [wcd5d] ld a, [wcd5d]
call GetPartyMonSpriteID call GetPartyMonSpriteID
ld [wcd5b], a ld [wcd5b], a
jr Func_718c3 jr WriteMonPartySpriteOAM
Func_71890: ; 71890 (1c:5890) UnusedPartyMonSpriteFunction: ; 71890 (1c:5890)
; This function is unused and doesn't appear to do anything useful. It looks
; like it may have been intended to load the tile patterns and OAM data for
; the mon party sprite associated with the mon ID in a.
; However, its calculations are off and it loads garbage data.
ld a, [wcf91] ld a, [wcf91]
call GetPartyMonSpriteID call GetPartyMonSpriteID
push af push af
ld hl, vSprites ld hl, vSprites
call Func_718ac call .LoadTilePatterns
pop af pop af
add $54 add $54
ld hl, vSprites + $40 ld hl, vSprites + $40
call Func_718ac call .LoadTilePatterns
xor a xor a
ld [wcd5d], a ld [wcd5d], a
jr Func_71882 jr WriteMonPartySpriteOAMByMonID
Func_718ac: ; 718ac (1c:58ac) .LoadTilePatterns ; 718ac (1c:58ac)
push hl push hl
add a add a
ld c, a ld c, a
ld b, $0 ld b, 0
ld hl, MonPartySpritePointers ld hl, MonPartySpritePointers
add hl, bc add hl, bc
add hl, bc add hl, bc
@ -353,23 +369,27 @@ Func_718ac: ; 718ac (1c:58ac)
pop hl pop hl
jp CopyVideoData jp CopyVideoData
Func_718c3: ; 718c3 (1c:58c3) WriteMonPartySpriteOAM: ; 718c3 (1c:58c3)
; Write the OAM blocks for the first animation frame into the OAM buffer and
; make a copy at wcc5b.
push af push af
ld c, $10 ld c, $10
ld h, wOAMBuffer / $100 ld h, wOAMBuffer / $100
ld a, [H_DOWNARROWBLINKCNT2] ; $ff8c ld a, [hPartyMonIndex]
swap a swap a
ld l, a ld l, a
add $10 add $10
ld b, a ld b, a
pop af pop af
cp $8 cp SPRITE_HELIX << 2
jr z, .asm_718da jr z, .helix
call Func_712a6 call WriteSymmetricMonPartySpriteOAM
jr .asm_718dd jr .makeCopy
.asm_718da .helix
call Func_71281 call WriteAsymmetricMonPartySpriteOAM
.asm_718dd ; Make a copy of the OAM buffer with the first animation frame written so that
; we can flip back to it from the second frame by copying it back.
.makeCopy
ld hl, wOAMBuffer ld hl, wOAMBuffer
ld de, wcc5b ld de, wcc5b
ld bc, $60 ld bc, $60
@ -384,13 +404,13 @@ GetPartyMonSpriteID: ; 718e9 (1c:58e9)
srl a srl a
ld hl, MonPartyData ld hl, MonPartyData
ld e, a ld e, a
ld d, $0 ld d, 0
add hl, de add hl, de
ld a, [hl] ld a, [hl]
bit 0, c bit 0, c
jr nz, .asm_71906 jr nz, .skipSwap
swap a swap a ; use lower nybble if pokedex num is even
.asm_71906 .skipSwap
and $f0 and $f0
srl a srl a
srl a srl a

View file

@ -389,7 +389,7 @@ Func_707b6: ; 707b6 (1c:47b6)
call CopyVideoData call CopyVideoData
ld a, $4 ld a, $4
ld hl, RedFishingTiles ; $4866 ld hl, RedFishingTiles ; $4866
call Func_71771 call LoadAnimSpriteGfx
ld a, [wSpriteStateData1 + 2] ld a, [wSpriteStateData1 + 2]
ld c, a ld c, a
ld b, $0 ld b, $0

View file

@ -444,12 +444,14 @@ Func_71279: ; 71279 (1c:5279)
ld c, l ld c, l
pop hl pop hl
Func_71281: ; 71281 (1c:5281) WriteAsymmetricMonPartySpriteOAM: ; 71281 (1c:5281)
; Writes 4 OAM blocks for a helix mon party sprite, since is does not have
; a vertical line of symmetry.
ld de, $202 ld de, $202
.asm_71284 .loop
push de push de
push bc push bc
.asm_71286 .innerLoop
ld a, b ld a, b
ld [hli], a ld [hli], a
ld a, c ld a, c
@ -465,24 +467,28 @@ Func_71281: ; 71281 (1c:5281)
add c add c
ld c, a ld c, a
dec e dec e
jr nz, .asm_71286 jr nz, .innerLoop
pop bc pop bc
pop de pop de
ld a, $8 ld a, $8
add b add b
ld b, a ld b, a
dec d dec d
jr nz, .asm_71284 jr nz, .loop
ret ret
Func_712a6: ; 712a6 (1c:52a6) WriteSymmetricMonPartySpriteOAM: ; 712a6 (1c:52a6)
; Writes 4 OAM blocks for a mon party sprite other than a helix. All the
; sprites other than the helix one have a vertical line of symmetry which allows
; the X-flip OAM bit to be used so that only 2 rather than 4 tile patterns are
; needed.
xor a xor a
ld [wcd5c], a ld [wcd5c], a
ld de, $202 ld de, $202
.asm_712ad .loop
push de push de
push bc push bc
.asm_712af .innerLoop
ld a, b ld a, b
ld [hli], a ld [hli], a
ld a, c ld a, c
@ -498,7 +504,7 @@ Func_712a6: ; 712a6 (1c:52a6)
add c add c
ld c, a ld c, a
dec e dec e
jr nz, .asm_712af jr nz, .innerLoop
pop bc pop bc
pop de pop de
push hl push hl
@ -510,7 +516,7 @@ Func_712a6: ; 712a6 (1c:52a6)
add b add b
ld b, a ld b, a
dec d dec d
jr nz, .asm_712ad jr nz, .loop
ret ret
Func_712d9: ; 712d9 (1c:52d9) Func_712d9: ; 712d9 (1c:52d9)

View file

@ -146,8 +146,8 @@ LoadTradingGFXAndMonNames: ; 411a1 (10:51a1)
Func_4120b: ; 4120b (10:520b) Func_4120b: ; 4120b (10:520b)
ld a, %11010000 ld a, %11010000
ld [rOBP1], a ld [rOBP1], a
ld b, BANK(Func_7176c) ld b, BANK(LoadMonPartySpriteGfx)
ld hl, Func_7176c ld hl, LoadMonPartySpriteGfx
jp Bankswitch jp Bankswitch
Trade_SwapNames: ; 41217 (10:5217) Trade_SwapNames: ; 41217 (10:5217)
@ -533,7 +533,7 @@ Func_414e8: ; 414e8 (10:54e8)
ret ret
Func_41505: ; 41505 (10:5505) Func_41505: ; 41505 (10:5505)
callba Func_71882 callba WriteMonPartySpriteOAMByMonID
call Func_41558 call Func_41558
Func_41510: ; 41510 (10:5510) Func_41510: ; 41510 (10:5510)

View file

@ -3923,7 +3923,7 @@ HandleMenuInputPokemonSelection:: ; 3ac2 (0:3ac2)
ld [H_DOWNARROWBLINKCNT2],a ; blinking down arrow timing value 2 ld [H_DOWNARROWBLINKCNT2],a ; blinking down arrow timing value 2
.loop1 .loop1
xor a xor a
ld [W_SUBANIMTRANSFORM],a ; counter for pokemon shaking animation ld [wPartyMonAnimCounter],a ; counter for pokemon shaking animation
call PlaceMenuCursor call PlaceMenuCursor
call Delay3 call Delay3
.loop2 .loop2

View file

@ -24,6 +24,8 @@ H_SPRITEINDEX EQU $FF8C
; DisplayTextID's argument ; DisplayTextID's argument
hSpriteIndexOrTextID EQU $FF8C hSpriteIndexOrTextID EQU $FF8C
hPartyMonIndex EQU $FF8C
; Multiplcation and division variables are meant ; Multiplcation and division variables are meant
; to overlap for back-to-back usage. Big endian. ; to overlap for back-to-back usage. Big endian.

View file

@ -1118,6 +1118,8 @@ wd08a:: ds 1
wTownMapSpriteBlinkingCounter:: ; d08b wTownMapSpriteBlinkingCounter:: ; d08b
wPartyMonAnimCounter:: ; d08b
W_SUBANIMTRANSFORM:: ; d08b W_SUBANIMTRANSFORM:: ; d08b
; controls what transformations are applied to the subanimation ; controls what transformations are applied to the subanimation
; 01: flip horizontally and vertically ; 01: flip horizontally and vertically