pokered/engine/mon_party_sprites.asm

424 lines
7.8 KiB
NASM
Raw Normal View History

2014-05-22 22:13:20 +00:00
AnimatePartyMon_ForceSpeed1: ; 716f7 (1c:56f7)
xor a
2015-03-13 12:33:16 +00:00
ld [wCurrentMenuItem], a
2014-05-22 22:13:20 +00:00
ld b, a
inc a
jr GetAnimationSpeed
2015-08-12 09:16:56 +00:00
; wPartyMenuHPBarColors contains the party mon's health bar colors
2014-05-22 22:13:20 +00:00
; 0: green
; 1: yellow
; 2: red
AnimatePartyMon: ; 716ff (1c:56ff)
2015-08-12 09:16:56 +00:00
ld hl, wPartyMenuHPBarColors
2014-05-22 22:13:20 +00:00
ld a, [wCurrentMenuItem]
ld c, a
ld b, $0
add hl, bc
ld a, [hl]
GetAnimationSpeed: ; 7170a (1c:570a)
ld c, a
ld hl, PartyMonSpeeds
add hl, bc
2014-09-13 07:50:56 +00:00
ld a, [wOnSGB]
2014-05-22 22:13:20 +00:00
xor $1
add [hl]
ld c, a
add a
ld b, a
2015-07-13 20:35:35 +00:00
ld a, [wAnimCounter]
2014-05-22 22:13:20 +00:00
and a
jr z, .resetSprites
cp c
jr z, .animateSprite
.incTimer
inc a
cp b
2015-03-13 12:33:16 +00:00
jr nz, .skipResetTimer
xor a ; reset timer
.skipResetTimer
2015-07-13 20:35:35 +00:00
ld [wAnimCounter], a
2014-05-22 22:13:20 +00:00
jp DelayFrame
.resetSprites
push bc
ld hl, wcc5b
2014-05-22 22:13:20 +00:00
ld de, wOAMBuffer
ld bc, $60
call CopyData
pop bc
xor a
jr .incTimer
.animateSprite
push bc
ld hl, wOAMBuffer + $02 ; OAM tile id
2014-05-22 22:13:20 +00:00
ld bc, $10
ld a, [wCurrentMenuItem]
call AddNTimes
ld c, $40 ; amount to increase the tile id by
ld a, [hl]
cp $4 ; tile ID for SPRITE_BALL_M
jr z, .editCoords
cp $8 ; tile ID for SPRITE_HELIX
jr nz, .editTileIDS
; SPRITE_BALL_M and SPRITE_HELIX only shake up and down
.editCoords
dec hl
dec hl ; dec hl to the OAM y coord
ld c, $1 ; amount to increase the y coord by
; otherwise, load a second sprite frame
.editTileIDS
ld b, $4
ld de, $4
.loop
ld a, [hl]
add c
ld [hl], a
add hl, de
dec b
jr nz, .loop
pop bc
ld a, c
jr .incTimer
2015-03-13 12:33:16 +00:00
; 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.
2014-05-22 22:13:20 +00:00
PartyMonSpeeds: ; 71769 (1c:5769)
db $05,$10,$20
2015-03-14 02:22:55 +00:00
LoadMonPartySpriteGfx: ; 7176c (1c:576c)
2015-03-13 12:33:16 +00:00
; Load mon party sprite tile patterns into VRAM during V-blank.
ld hl, MonPartySpritePointers
2014-05-22 22:13:20 +00:00
ld a, $1c
2015-03-14 02:22:55 +00:00
LoadAnimSpriteGfx: ; 71771 (1c:5771)
2015-03-13 12:33:16 +00:00
; 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.
2014-05-22 22:13:20 +00:00
ld bc, $0
2015-03-13 12:33:16 +00:00
.loop
2014-05-22 22:13:20 +00:00
push af
push bc
push hl
add hl, bc
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
ld a, [hli]
ld c, a
ld a, [hli]
ld b, a
ld a, [hli]
ld h, [hl]
ld l, a
call CopyVideoData
pop hl
pop bc
ld a, $6
add c
ld c, a
pop af
dec a
2015-03-13 12:33:16 +00:00
jr nz, .loop
2014-05-22 22:13:20 +00:00
ret
2015-03-14 02:22:55 +00:00
LoadMonPartySpriteGfxWithLCDDisabled: ; 71791 (1c:5791)
2015-03-13 12:33:16 +00:00
; Load mon party sprite tile patterns into VRAM immediately by disabling the
; LCD.
2014-05-22 22:13:20 +00:00
call DisableLCD
2015-03-13 12:33:16 +00:00
ld hl, MonPartySpritePointers
2014-05-22 22:13:20 +00:00
ld a, $1c
ld bc, $0
.asm_7179c
push af
push bc
push hl
add hl, bc
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
push de
ld a, [hli]
ld c, a
swap c
ld b, $0
ld a, [hli]
ld e, [hl]
inc hl
ld d, [hl]
pop hl
call FarCopyData2
pop hl
pop bc
ld a, $6
add c
ld c, a
pop af
dec a
jr nz, .asm_7179c
jp EnableLCD
MonPartySpritePointers: ; 717c0 (1c:57c0)
dw SlowbroSprite + $c0
db $40 / $10 ; 40 bytes
db BANK(SlowbroSprite)
2014-05-29 08:31:46 +00:00
dw vSprites
2014-05-22 22:13:20 +00:00
dw BallSprite
db $80 / $10 ; $80 bytes
db BANK(BallSprite)
2014-05-29 08:31:46 +00:00
dw vSprites + $40
2014-05-22 22:13:20 +00:00
dw ClefairySprite + $c0
db $40 / $10 ; $40 bytes
db BANK(ClefairySprite)
2014-05-29 08:31:46 +00:00
dw vSprites + $c0
2014-05-22 22:13:20 +00:00
dw BirdSprite + $c0
db $40 / $10 ; $40 bytes
db BANK(BirdSprite)
2014-05-29 08:31:46 +00:00
dw vSprites + $100
2014-05-22 22:13:20 +00:00
dw SeelSprite
db $40 / $10 ; $40 bytes
db BANK(SeelSprite)
2014-05-29 08:31:46 +00:00
dw vSprites + $140
2014-05-22 22:13:20 +00:00
dw MonPartySprites + $40
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
2014-05-29 08:31:46 +00:00
dw vSprites + $180
2014-05-22 22:13:20 +00:00
dw MonPartySprites + $50
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
2014-05-29 08:31:46 +00:00
dw vSprites + $1a0
2014-05-22 22:13:20 +00:00
dw MonPartySprites + $60
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
2014-05-29 08:31:46 +00:00
dw vSprites + $1c0
2014-05-22 22:13:20 +00:00
dw MonPartySprites + $70
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
2014-05-29 08:31:46 +00:00
dw vSprites + $1e0
2014-05-22 22:13:20 +00:00
dw MonPartySprites + $80
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
2014-05-29 08:31:46 +00:00
dw vSprites + $200
2014-05-22 22:13:20 +00:00
dw MonPartySprites + $90
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
2014-05-29 08:31:46 +00:00
dw vSprites + $220
2014-05-22 22:13:20 +00:00
dw MonPartySprites + $A0
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
2014-05-29 08:31:46 +00:00
dw vSprites + $240
2014-05-22 22:13:20 +00:00
dw MonPartySprites + $B0
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
2014-05-29 08:31:46 +00:00
dw vSprites + $260
2014-05-22 22:13:20 +00:00
dw MonPartySprites + $100
db $40 / $10 ; $40 bytes
db BANK(MonPartySprites)
2014-05-29 08:31:46 +00:00
dw vSprites + $380
2014-05-22 22:13:20 +00:00
dw SlowbroSprite
db $40 / $10 ; $40 bytes
db BANK(SlowbroSprite)
2014-05-29 08:31:46 +00:00
dw vSprites + $400
2014-05-22 22:13:20 +00:00
dw BallSprite
db $80 / $10 ; $80 bytes
db BANK(BallSprite)
2014-05-29 08:31:46 +00:00
dw vSprites + $440
2014-05-22 22:13:20 +00:00
dw ClefairySprite
db $40 / $10 ; $40 bytes
db BANK(ClefairySprite)
2014-05-29 08:31:46 +00:00
dw vSprites + $4c0
2014-05-22 22:13:20 +00:00
dw BirdSprite
db $40 / $10 ; $40 bytes
db BANK(BirdSprite)
2014-05-29 08:31:46 +00:00
dw vSprites + $500
2014-05-22 22:13:20 +00:00
dw SeelSprite + $C0
db $40 / $10 ; $40 bytes
db BANK(SeelSprite)
2014-05-29 08:31:46 +00:00
dw vSprites + $540
2014-05-22 22:13:20 +00:00
dw MonPartySprites
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
2014-05-29 08:31:46 +00:00
dw vSprites + $580
2014-05-22 22:13:20 +00:00
dw MonPartySprites + $10
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
2014-05-29 08:31:46 +00:00
dw vSprites + $5a0
2014-05-22 22:13:20 +00:00
dw MonPartySprites + $20
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
2014-05-29 08:31:46 +00:00
dw vSprites + $5c0
2014-05-22 22:13:20 +00:00
dw MonPartySprites + $30
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
2014-05-29 08:31:46 +00:00
dw vSprites + $5E0
2014-05-22 22:13:20 +00:00
dw MonPartySprites + $C0
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
2014-05-29 08:31:46 +00:00
dw vSprites + $600
2014-05-22 22:13:20 +00:00
dw MonPartySprites + $D0
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
2014-05-29 08:31:46 +00:00
dw vSprites + $620
2014-05-22 22:13:20 +00:00
dw MonPartySprites + $E0
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
2014-05-29 08:31:46 +00:00
dw vSprites + $640
2014-05-22 22:13:20 +00:00
dw MonPartySprites + $F0
db $10 / $10 ; $10 bytes
db BANK(MonPartySprites)
2014-05-29 08:31:46 +00:00
dw vSprites + $660
2014-05-22 22:13:20 +00:00
dw MonPartySprites + $140
db $40 / $10 ; $40 bytes
db BANK(MonPartySprites)
2014-05-29 08:31:46 +00:00
dw vSprites + $780
2014-05-22 22:13:20 +00:00
2015-03-13 12:33:16 +00:00
WriteMonPartySpriteOAMByPartyIndex: ; 71868 (1c:5868)
; Write OAM blocks for the party mon in [hPartyMonIndex].
2014-05-22 22:13:20 +00:00
push hl
push de
push bc
2015-03-13 12:33:16 +00:00
ld a, [hPartyMonIndex]
ld hl, wPartySpecies
2014-05-22 22:13:20 +00:00
ld e, a
2015-03-13 12:33:16 +00:00
ld d, 0
2014-05-22 22:13:20 +00:00
add hl, de
ld a, [hl]
call GetPartyMonSpriteID
2015-07-14 02:24:07 +00:00
ld [wOAMBaseTile], a
2015-03-13 12:33:16 +00:00
call WriteMonPartySpriteOAM
2014-05-22 22:13:20 +00:00
pop bc
pop de
pop hl
ret
2015-03-14 22:25:21 +00:00
WriteMonPartySpriteOAMBySpecies: ; 71882 (1c:5882)
; Write OAM blocks for the party sprite of the species in
; [wMonPartySpriteSpecies].
2014-05-22 22:13:20 +00:00
xor a
2015-03-13 12:33:16 +00:00
ld [hPartyMonIndex], a
2015-03-14 22:25:21 +00:00
ld a, [wMonPartySpriteSpecies]
2014-05-22 22:13:20 +00:00
call GetPartyMonSpriteID
2015-07-14 02:24:07 +00:00
ld [wOAMBaseTile], a
2015-03-13 12:33:16 +00:00
jr WriteMonPartySpriteOAM
2014-05-22 22:13:20 +00:00
2015-03-13 12:33:16 +00:00
UnusedPartyMonSpriteFunction: ; 71890 (1c:5890)
2015-03-14 02:22:55 +00:00
; 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
2015-03-14 22:25:21 +00:00
; the mon party sprite associated with the species in [wcf91].
2015-03-14 02:22:55 +00:00
; However, its calculations are off and it loads garbage data.
ld a, [wcf91]
2014-05-22 22:13:20 +00:00
call GetPartyMonSpriteID
push af
2014-05-29 08:31:46 +00:00
ld hl, vSprites
2015-03-13 12:33:16 +00:00
call .LoadTilePatterns
2014-05-22 22:13:20 +00:00
pop af
add $54
2014-05-29 08:31:46 +00:00
ld hl, vSprites + $40
2015-03-13 12:33:16 +00:00
call .LoadTilePatterns
2014-05-22 22:13:20 +00:00
xor a
2015-03-14 22:25:21 +00:00
ld [wMonPartySpriteSpecies], a
jr WriteMonPartySpriteOAMBySpecies
2014-05-22 22:13:20 +00:00
2015-03-13 12:33:16 +00:00
.LoadTilePatterns ; 718ac (1c:58ac)
2014-05-22 22:13:20 +00:00
push hl
add a
ld c, a
2015-03-13 12:33:16 +00:00
ld b, 0
2014-05-22 22:13:20 +00:00
ld hl, MonPartySpritePointers
add hl, bc
add hl, bc
add hl, bc
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
ld a, [hli]
ld c, a
ld a, [hli]
ld b, a
pop hl
jp CopyVideoData
2015-03-13 12:33:16 +00:00
WriteMonPartySpriteOAM: ; 718c3 (1c:58c3)
; Write the OAM blocks for the first animation frame into the OAM buffer and
; make a copy at wcc5b.
2014-05-22 22:13:20 +00:00
push af
ld c, $10
2014-05-27 18:08:52 +00:00
ld h, wOAMBuffer / $100
2015-03-13 12:33:16 +00:00
ld a, [hPartyMonIndex]
2014-05-22 22:13:20 +00:00
swap a
ld l, a
add $10
ld b, a
pop af
2015-03-13 12:33:16 +00:00
cp SPRITE_HELIX << 2
jr z, .helix
call WriteSymmetricMonPartySpriteOAM
jr .makeCopy
.helix
call WriteAsymmetricMonPartySpriteOAM
; 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
2014-05-22 22:13:20 +00:00
ld hl, wOAMBuffer
ld de, wcc5b
2014-05-22 22:13:20 +00:00
ld bc, $60
jp CopyData
GetPartyMonSpriteID: ; 718e9 (1c:58e9)
ld [wd11e], a
predef IndexToPokedex
ld a, [wd11e]
2014-05-22 22:13:20 +00:00
ld c, a
dec a
srl a
2015-02-07 10:43:08 +00:00
ld hl, MonPartyData
2014-05-22 22:13:20 +00:00
ld e, a
2015-03-13 12:33:16 +00:00
ld d, 0
2014-05-22 22:13:20 +00:00
add hl, de
ld a, [hl]
bit 0, c
2015-03-13 12:33:16 +00:00
jr nz, .skipSwap
swap a ; use lower nybble if pokedex num is even
.skipSwap
2014-05-22 22:13:20 +00:00
and $f0
srl a
srl a
ret
INCLUDE "data/mon_party_sprites.asm"
MonPartySprites: ; 71959 (1c:5959)
INCBIN "gfx/mon_ow_sprites.2bpp"