2018-06-24 07:09:41 -07:00
|
|
|
GetEmote2bpp:
|
2015-11-12 21:49:27 -08:00
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rVBK], a
|
2015-11-12 21:49:27 -08:00
|
|
|
call Get2bpp
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rVBK], a
|
2015-11-12 21:49:27 -08:00
|
|
|
ret
|
|
|
|
|
2020-06-16 16:38:00 -07:00
|
|
|
_UpdatePlayerSprite::
|
2015-11-12 21:49:27 -08:00
|
|
|
call GetPlayerSprite
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wUsedSprites]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hUsedSpriteIndex], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wUsedSprites + 1]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hUsedSpriteTile], a
|
2015-11-14 20:02:38 -08:00
|
|
|
call GetUsedSprite
|
2015-11-12 21:49:27 -08:00
|
|
|
ret
|
|
|
|
|
2020-06-16 08:28:52 -07:00
|
|
|
_RefreshSprites: ; mobile
|
2015-11-12 21:49:27 -08:00
|
|
|
ld hl, wSpriteFlags
|
|
|
|
ld a, [hl]
|
|
|
|
push af
|
|
|
|
res 7, [hl]
|
|
|
|
set 6, [hl]
|
2018-01-24 08:17:05 -08:00
|
|
|
call LoadUsedSpritesGFX
|
2015-11-12 21:49:27 -08:00
|
|
|
pop af
|
|
|
|
ld [wSpriteFlags], a
|
|
|
|
ret
|
|
|
|
|
2020-06-16 08:28:52 -07:00
|
|
|
_ClearSprites: ; mobile
|
2015-11-12 21:49:27 -08:00
|
|
|
ld hl, wSpriteFlags
|
|
|
|
ld a, [hl]
|
|
|
|
push af
|
|
|
|
set 7, [hl]
|
|
|
|
res 6, [hl]
|
2018-01-24 08:17:05 -08:00
|
|
|
call LoadUsedSpritesGFX
|
2015-11-12 21:49:27 -08:00
|
|
|
pop af
|
|
|
|
ld [wSpriteFlags], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
RefreshSprites::
|
2015-11-12 21:49:27 -08:00
|
|
|
call .Refresh
|
2018-01-24 08:17:05 -08:00
|
|
|
call LoadUsedSpritesGFX
|
2015-11-12 21:49:27 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.Refresh:
|
2015-11-12 21:49:27 -08:00
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld bc, wUsedSpritesEnd - wUsedSprites
|
|
|
|
ld hl, wUsedSprites
|
2015-11-12 21:49:27 -08:00
|
|
|
call ByteFill
|
|
|
|
call GetPlayerSprite
|
|
|
|
call AddMapSprites
|
|
|
|
call LoadAndSortSprites
|
|
|
|
ret
|
|
|
|
|
2024-03-08 09:56:26 -08:00
|
|
|
DeterminePlayerSprite:
|
|
|
|
; Return player's sprite in c and a.
|
2017-12-28 04:15:46 -08:00
|
|
|
ld a, [wPlayerGender]
|
2024-03-08 09:56:26 -08:00
|
|
|
ld e, PLAYERDATA_STATE_SPRITES
|
|
|
|
call GetPlayerField
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wPlayerState]
|
2015-11-12 21:49:27 -08:00
|
|
|
ld c, a
|
|
|
|
.loop
|
|
|
|
ld a, [hli]
|
|
|
|
cp c
|
|
|
|
jr z, .good
|
|
|
|
inc hl
|
2018-01-10 19:53:42 -08:00
|
|
|
cp -1
|
2015-11-12 21:49:27 -08:00
|
|
|
jr nz, .loop
|
|
|
|
|
|
|
|
; Any player state not in the array defaults to Chris's sprite.
|
|
|
|
xor a ; ld a, PLAYER_NORMAL
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wPlayerState], a
|
2015-11-12 21:49:27 -08:00
|
|
|
ld a, SPRITE_CHRIS
|
2024-03-08 09:56:26 -08:00
|
|
|
ret
|
2015-11-12 21:49:27 -08:00
|
|
|
|
|
|
|
.good
|
|
|
|
ld a, [hl]
|
2024-03-08 09:56:26 -08:00
|
|
|
ld c, a
|
|
|
|
ret
|
2015-11-12 21:49:27 -08:00
|
|
|
|
2024-03-08 09:56:26 -08:00
|
|
|
GetPlayerSprite:
|
|
|
|
; Get player's sprite in a.
|
|
|
|
call DeterminePlayerSprite
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wUsedSprites + 0], a
|
|
|
|
ld [wPlayerSprite], a
|
|
|
|
ld [wPlayerObjectSprite], a
|
2015-11-12 21:49:27 -08:00
|
|
|
ret
|
|
|
|
|
2018-01-25 19:19:24 -08:00
|
|
|
INCLUDE "data/sprites/player_sprites.asm"
|
2015-11-12 21:49:27 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AddMapSprites:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wMapGroup]
|
2015-11-12 21:49:27 -08:00
|
|
|
dec a
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
2024-02-26 13:09:32 -08:00
|
|
|
ld hl, MapSprites
|
2015-11-12 21:49:27 -08:00
|
|
|
add hl, bc
|
2016-05-04 08:46:23 -07:00
|
|
|
add hl, bc
|
2015-11-12 21:49:27 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
.loop
|
|
|
|
ld a, [hli]
|
2023-07-26 01:30:47 -07:00
|
|
|
and a
|
|
|
|
ret z
|
2015-11-12 21:49:27 -08:00
|
|
|
call AddSpriteGFX
|
2023-07-26 01:30:47 -07:00
|
|
|
jr .loop
|
2015-11-12 21:49:27 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
LoadUsedSpritesGFX:
|
2016-01-06 04:44:50 -08:00
|
|
|
ld a, MAPCALLBACK_SPRITES
|
2015-11-12 21:49:27 -08:00
|
|
|
call RunMapCallback
|
2015-11-14 20:02:38 -08:00
|
|
|
call GetUsedSprites
|
2020-06-17 19:12:04 -07:00
|
|
|
call LoadMiscTiles
|
2015-11-12 21:49:27 -08:00
|
|
|
ret
|
|
|
|
|
2020-06-17 19:12:04 -07:00
|
|
|
LoadMiscTiles:
|
2015-11-12 21:49:27 -08:00
|
|
|
ld a, [wSpriteFlags]
|
|
|
|
bit 6, a
|
|
|
|
ret nz
|
2015-11-14 20:02:38 -08:00
|
|
|
|
|
|
|
ld c, EMOTE_SHADOW
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall LoadEmote
|
2017-12-24 10:08:38 -08:00
|
|
|
call GetMapEnvironment
|
2015-11-12 21:49:27 -08:00
|
|
|
call CheckOutdoorMap
|
2017-12-08 21:50:59 -08:00
|
|
|
ld c, EMOTE_GRASS_RUSTLE
|
2015-11-12 21:49:27 -08:00
|
|
|
jr z, .outdoor
|
2015-11-14 20:02:38 -08:00
|
|
|
ld c, EMOTE_BOULDER_DUST
|
2015-11-12 21:49:27 -08:00
|
|
|
.outdoor
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall LoadEmote
|
2015-11-12 21:49:27 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SafeGetSprite:
|
2015-11-12 21:49:27 -08:00
|
|
|
push hl
|
|
|
|
call GetSprite
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetSprite:
|
2015-11-12 21:49:27 -08:00
|
|
|
call GetMonSprite
|
|
|
|
ret c
|
|
|
|
|
2017-12-26 09:50:32 -08:00
|
|
|
ld hl, OverworldSprites + SPRITEDATA_ADDR
|
2015-11-12 21:49:27 -08:00
|
|
|
dec a
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
2017-12-26 09:50:32 -08:00
|
|
|
ld a, NUM_SPRITEDATA_FIELDS
|
2015-11-12 21:49:27 -08:00
|
|
|
call AddNTimes
|
|
|
|
; load the address into de
|
|
|
|
ld a, [hli]
|
|
|
|
ld e, a
|
|
|
|
ld a, [hli]
|
|
|
|
ld d, a
|
|
|
|
; load the length into c
|
|
|
|
ld a, [hli]
|
|
|
|
swap a
|
|
|
|
ld c, a
|
|
|
|
; load the sprite bank into both b and h
|
|
|
|
ld b, [hl]
|
|
|
|
ld a, [hli]
|
|
|
|
; load the sprite type into l
|
|
|
|
ld l, [hl]
|
|
|
|
ld h, a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetMonSprite:
|
2015-11-12 21:49:27 -08:00
|
|
|
; Return carry if a monster sprite was loaded.
|
|
|
|
|
|
|
|
cp SPRITE_POKEMON
|
|
|
|
jr c, .Normal
|
2017-12-10 10:37:15 -08:00
|
|
|
cp SPRITE_DAY_CARE_MON_1
|
2018-02-04 19:45:04 -08:00
|
|
|
jr z, .BreedMon1
|
2017-12-10 10:37:15 -08:00
|
|
|
cp SPRITE_DAY_CARE_MON_2
|
2018-02-04 19:45:04 -08:00
|
|
|
jr z, .BreedMon2
|
2015-11-12 21:49:27 -08:00
|
|
|
cp SPRITE_VARS
|
|
|
|
jr nc, .Variable
|
|
|
|
jr .Icon
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Normal:
|
2015-11-12 21:49:27 -08:00
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Icon:
|
2015-11-12 21:49:27 -08:00
|
|
|
sub SPRITE_POKEMON
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
ld hl, SpriteMons
|
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
jr .Mon
|
|
|
|
|
2018-02-04 19:45:04 -08:00
|
|
|
.BreedMon1
|
2015-11-12 21:49:27 -08:00
|
|
|
ld a, [wBreedMon1Species]
|
|
|
|
jr .Mon
|
|
|
|
|
2018-02-04 19:45:04 -08:00
|
|
|
.BreedMon2
|
2015-11-12 21:49:27 -08:00
|
|
|
ld a, [wBreedMon2Species]
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Mon:
|
2015-11-12 21:49:27 -08:00
|
|
|
ld e, a
|
|
|
|
and a
|
|
|
|
jr z, .NoBreedmon
|
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall LoadOverworldMonIcon
|
2015-11-12 21:49:27 -08:00
|
|
|
|
2020-06-17 19:12:04 -07:00
|
|
|
ld l, WALKING_SPRITE
|
2015-11-12 21:49:27 -08:00
|
|
|
ld h, 0
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.Variable:
|
2015-11-12 21:49:27 -08:00
|
|
|
sub SPRITE_VARS
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wVariableSprites
|
2015-11-12 21:49:27 -08:00
|
|
|
add hl, de
|
|
|
|
ld a, [hl]
|
|
|
|
and a
|
|
|
|
jp nz, GetMonSprite
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.NoBreedmon:
|
2020-06-17 19:12:04 -07:00
|
|
|
ld a, WALKING_SPRITE
|
|
|
|
ld l, WALKING_SPRITE
|
2015-11-12 21:49:27 -08:00
|
|
|
ld h, 0
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
_DoesSpriteHaveFacings::
|
2015-11-12 21:49:27 -08:00
|
|
|
; Checks to see whether we can apply a facing to a sprite.
|
|
|
|
; Returns carry unless the sprite is a Pokemon or a Still Sprite.
|
|
|
|
cp SPRITE_POKEMON
|
|
|
|
jr nc, .only_down
|
|
|
|
|
|
|
|
push hl
|
|
|
|
push bc
|
2017-12-26 09:50:32 -08:00
|
|
|
ld hl, OverworldSprites + SPRITEDATA_TYPE
|
2015-11-12 21:49:27 -08:00
|
|
|
dec a
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
2017-12-26 09:50:32 -08:00
|
|
|
ld a, NUM_SPRITEDATA_FIELDS
|
2015-11-12 21:49:27 -08:00
|
|
|
call AddNTimes
|
|
|
|
ld a, [hl]
|
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
cp STILL_SPRITE
|
|
|
|
jr nz, .only_down
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.only_down
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
_GetSpritePalette::
|
2015-11-12 21:49:27 -08:00
|
|
|
ld a, c
|
|
|
|
call GetMonSprite
|
|
|
|
jr c, .is_pokemon
|
|
|
|
|
2017-12-26 09:50:32 -08:00
|
|
|
ld hl, OverworldSprites + SPRITEDATA_PALETTE
|
2015-11-12 21:49:27 -08:00
|
|
|
dec a
|
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
2017-12-26 09:50:32 -08:00
|
|
|
ld a, NUM_SPRITEDATA_FIELDS
|
2015-11-12 21:49:27 -08:00
|
|
|
call AddNTimes
|
|
|
|
ld c, [hl]
|
|
|
|
ret
|
|
|
|
|
|
|
|
.is_pokemon
|
|
|
|
xor a
|
|
|
|
ld c, a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
LoadAndSortSprites:
|
2015-11-12 21:49:27 -08:00
|
|
|
call LoadSpriteGFX
|
|
|
|
call ArrangeUsedSprites
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
AddSpriteGFX:
|
2015-11-12 21:49:27 -08:00
|
|
|
; Add any new sprite ids to a list of graphics to be loaded.
|
|
|
|
; Return carry if the list is full.
|
|
|
|
|
|
|
|
push hl
|
|
|
|
push bc
|
|
|
|
ld b, a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wUsedSprites + 2
|
2015-11-12 21:49:27 -08:00
|
|
|
ld c, SPRITE_GFX_LIST_CAPACITY - 1
|
|
|
|
.loop
|
|
|
|
ld a, [hl]
|
|
|
|
cp b
|
|
|
|
jr z, .exists
|
|
|
|
and a
|
|
|
|
jr z, .new
|
|
|
|
inc hl
|
2016-05-04 08:46:23 -07:00
|
|
|
inc hl
|
2015-11-12 21:49:27 -08:00
|
|
|
dec c
|
|
|
|
jr nz, .loop
|
|
|
|
|
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
|
|
|
.exists
|
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.new
|
|
|
|
ld [hl], b
|
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
LoadSpriteGFX:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wUsedSprites
|
2015-11-12 21:49:27 -08:00
|
|
|
ld b, SPRITE_GFX_LIST_CAPACITY
|
|
|
|
.loop
|
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
jr z, .done
|
|
|
|
push hl
|
|
|
|
call .LoadSprite
|
|
|
|
pop hl
|
|
|
|
ld [hli], a
|
|
|
|
dec b
|
|
|
|
jr nz, .loop
|
|
|
|
|
|
|
|
.done
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.LoadSprite:
|
2023-09-02 04:01:45 -07:00
|
|
|
push bc
|
2015-11-12 21:49:27 -08:00
|
|
|
call GetSprite
|
2023-09-02 04:01:45 -07:00
|
|
|
pop bc
|
2015-11-12 21:49:27 -08:00
|
|
|
ld a, l
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ArrangeUsedSprites:
|
2015-11-12 21:49:27 -08:00
|
|
|
; Get the length of each sprite and space them out in VRAM.
|
|
|
|
; Crystal introduces a second table in VRAM bank 0.
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wUsedSprites
|
2015-11-12 21:49:27 -08:00
|
|
|
ld c, SPRITE_GFX_LIST_CAPACITY
|
|
|
|
ld b, 0
|
2016-04-10 11:42:14 -07:00
|
|
|
.FirstTableLength:
|
2015-11-12 21:49:27 -08:00
|
|
|
; Keep going until the end of the list.
|
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
jr z, .quit
|
|
|
|
|
|
|
|
ld a, [hl]
|
|
|
|
call GetSpriteLength
|
|
|
|
|
|
|
|
; Spill over into the second table after $80 tiles.
|
|
|
|
add b
|
|
|
|
cp $80
|
|
|
|
jr z, .loop
|
|
|
|
jr nc, .SecondTable
|
|
|
|
|
|
|
|
.loop
|
|
|
|
ld [hl], b
|
|
|
|
inc hl
|
|
|
|
ld b, a
|
|
|
|
|
|
|
|
; Assumes the next table will be reached before c hits 0.
|
|
|
|
dec c
|
|
|
|
jr nz, .FirstTableLength
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.SecondTable:
|
2015-11-12 21:49:27 -08:00
|
|
|
; The second tile table starts at tile $80.
|
|
|
|
ld b, $80
|
|
|
|
dec hl
|
2016-04-10 11:42:14 -07:00
|
|
|
.SecondTableLength:
|
2015-11-12 21:49:27 -08:00
|
|
|
; Keep going until the end of the list.
|
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
jr z, .quit
|
|
|
|
|
|
|
|
ld a, [hl]
|
|
|
|
call GetSpriteLength
|
|
|
|
|
2023-09-02 04:01:45 -07:00
|
|
|
; Don't go any further than the second row in the second table.
|
2015-11-12 21:49:27 -08:00
|
|
|
add b
|
2023-09-02 04:01:45 -07:00
|
|
|
cp $a0 + 1
|
|
|
|
jr nc, .quit
|
2015-11-12 21:49:27 -08:00
|
|
|
|
|
|
|
ld [hl], b
|
|
|
|
ld b, a
|
|
|
|
inc hl
|
|
|
|
|
|
|
|
dec c
|
|
|
|
jr nz, .SecondTableLength
|
|
|
|
|
|
|
|
.quit
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetSpriteLength:
|
2015-11-12 21:49:27 -08:00
|
|
|
; Return the length of sprite type a in tiles.
|
|
|
|
|
|
|
|
cp WALKING_SPRITE
|
|
|
|
jr z, .AnyDirection
|
|
|
|
cp STANDING_SPRITE
|
|
|
|
jr z, .AnyDirection
|
|
|
|
cp STILL_SPRITE
|
|
|
|
jr z, .OneDirection
|
|
|
|
|
|
|
|
ld a, 12
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.AnyDirection:
|
2015-11-12 21:49:27 -08:00
|
|
|
ld a, 12
|
|
|
|
ret
|
|
|
|
|
2016-04-10 11:42:14 -07:00
|
|
|
.OneDirection:
|
2015-11-12 21:49:27 -08:00
|
|
|
ld a, 4
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetUsedSprites:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wUsedSprites
|
2015-11-12 21:49:27 -08:00
|
|
|
ld c, SPRITE_GFX_LIST_CAPACITY
|
2015-11-14 20:02:38 -08:00
|
|
|
|
2015-11-12 21:49:27 -08:00
|
|
|
.loop
|
|
|
|
ld a, [wSpriteFlags]
|
|
|
|
res 5, a
|
|
|
|
ld [wSpriteFlags], a
|
2015-11-14 20:02:38 -08:00
|
|
|
|
2015-11-12 21:49:27 -08:00
|
|
|
ld a, [hli]
|
|
|
|
and a
|
|
|
|
jr z, .done
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hUsedSpriteIndex], a
|
2015-11-14 20:02:38 -08:00
|
|
|
|
2015-11-12 21:49:27 -08:00
|
|
|
ld a, [hli]
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hUsedSpriteTile], a
|
2015-11-14 20:02:38 -08:00
|
|
|
|
2015-11-12 21:49:27 -08:00
|
|
|
bit 7, a
|
|
|
|
jr z, .dont_set
|
2015-11-14 20:02:38 -08:00
|
|
|
|
2015-11-12 21:49:27 -08:00
|
|
|
ld a, [wSpriteFlags]
|
2015-11-14 20:02:38 -08:00
|
|
|
set 5, a ; load VBank0
|
2015-11-12 21:49:27 -08:00
|
|
|
ld [wSpriteFlags], a
|
|
|
|
|
|
|
|
.dont_set
|
|
|
|
push bc
|
|
|
|
push hl
|
2015-11-14 20:02:38 -08:00
|
|
|
call GetUsedSprite
|
2015-11-12 21:49:27 -08:00
|
|
|
pop hl
|
|
|
|
pop bc
|
|
|
|
dec c
|
|
|
|
jr nz, .loop
|
|
|
|
|
|
|
|
.done
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetUsedSprite:
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hUsedSpriteIndex]
|
2015-11-12 21:49:27 -08:00
|
|
|
call SafeGetSprite
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hUsedSpriteTile]
|
2015-11-12 21:49:27 -08:00
|
|
|
call .GetTileAddr
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
|
|
|
ld a, [wSpriteFlags]
|
|
|
|
bit 7, a
|
|
|
|
jr nz, .skip
|
|
|
|
call .CopyToVram
|
|
|
|
|
|
|
|
.skip
|
|
|
|
pop bc
|
|
|
|
ld l, c
|
|
|
|
ld h, $0
|
|
|
|
rept 4
|
|
|
|
add hl, hl
|
|
|
|
endr
|
|
|
|
pop de
|
|
|
|
add hl, de
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
pop hl
|
2015-11-14 20:02:38 -08:00
|
|
|
|
2015-11-12 21:49:27 -08:00
|
|
|
ld a, [wSpriteFlags]
|
|
|
|
bit 5, a
|
|
|
|
jr nz, .done
|
|
|
|
bit 6, a
|
|
|
|
jr nz, .done
|
2015-11-14 20:02:38 -08:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hUsedSpriteIndex]
|
2015-11-12 21:49:27 -08:00
|
|
|
call _DoesSpriteHaveFacings
|
|
|
|
jr c, .done
|
2015-11-14 20:02:38 -08:00
|
|
|
|
2015-11-12 21:49:27 -08:00
|
|
|
ld a, h
|
2019-02-06 20:52:50 -08:00
|
|
|
add HIGH(vTiles1 - vTiles0)
|
2015-11-12 21:49:27 -08:00
|
|
|
ld h, a
|
|
|
|
call .CopyToVram
|
|
|
|
|
|
|
|
.done
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.GetTileAddr:
|
2015-11-12 21:49:27 -08:00
|
|
|
; Return the address of tile (a) in (hl).
|
|
|
|
and $7f
|
|
|
|
ld l, a
|
|
|
|
ld h, 0
|
|
|
|
rept 4
|
|
|
|
add hl, hl
|
|
|
|
endr
|
|
|
|
ld a, l
|
2017-12-28 04:32:33 -08:00
|
|
|
add LOW(vTiles0)
|
2015-11-12 21:49:27 -08:00
|
|
|
ld l, a
|
|
|
|
ld a, h
|
2017-12-28 04:32:33 -08:00
|
|
|
adc HIGH(vTiles0)
|
2015-11-12 21:49:27 -08:00
|
|
|
ld h, a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.CopyToVram:
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [rVBK]
|
2015-11-12 21:49:27 -08:00
|
|
|
push af
|
|
|
|
ld a, [wSpriteFlags]
|
|
|
|
bit 5, a
|
|
|
|
ld a, $1
|
|
|
|
jr z, .bankswitch
|
|
|
|
ld a, $0
|
|
|
|
|
|
|
|
.bankswitch
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rVBK], a
|
2015-11-12 21:49:27 -08:00
|
|
|
call Get2bpp
|
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rVBK], a
|
2015-11-12 21:49:27 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
LoadEmote::
|
2015-11-12 21:49:27 -08:00
|
|
|
; Get the address of the pointer to emote c.
|
|
|
|
ld a, c
|
2021-03-03 19:22:41 -08:00
|
|
|
ld bc, EMOTE_LENGTH
|
2017-12-26 09:50:32 -08:00
|
|
|
ld hl, Emotes
|
2015-11-12 21:49:27 -08:00
|
|
|
call AddNTimes
|
|
|
|
; Load the emote address into de
|
|
|
|
ld e, [hl]
|
|
|
|
inc hl
|
|
|
|
ld d, [hl]
|
|
|
|
; load the length of the emote (in tiles) into c
|
|
|
|
inc hl
|
|
|
|
ld c, [hl]
|
|
|
|
swap c
|
|
|
|
; load the emote pointer bank into b
|
|
|
|
inc hl
|
|
|
|
ld b, [hl]
|
|
|
|
; load the VRAM destination into hl
|
|
|
|
inc hl
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
; if the emote has a length of 0, do not proceed (error handling)
|
|
|
|
ld a, c
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
call GetEmote2bpp
|
|
|
|
ret
|
|
|
|
|
2018-01-10 15:10:01 -08:00
|
|
|
INCLUDE "data/sprites/emotes.asm"
|
2015-11-12 21:49:27 -08:00
|
|
|
|
2018-01-10 15:10:01 -08:00
|
|
|
INCLUDE "data/sprites/sprite_mons.asm"
|
2015-11-12 21:49:27 -08:00
|
|
|
|
2024-02-26 13:09:32 -08:00
|
|
|
INCLUDE "data/maps/sprites.asm"
|
2015-11-12 21:49:27 -08:00
|
|
|
|
2018-01-10 15:10:01 -08:00
|
|
|
INCLUDE "data/sprites/sprites.asm"
|