Remove indoor sprites (#7), and improve overworld sprite sorting in VRAM (#2)

This commit is contained in:
xCrystal 2023-07-26 10:30:47 +02:00
parent 2d5bd722cd
commit 15f452ff26
3 changed files with 12 additions and 123 deletions

View File

@ -82,5 +82,3 @@ DEF SPAWN_N_A EQU -1
const_def const_def
const FLY_1 const FLY_1
DEF NUM_FLYPOINTS EQU const_value DEF NUM_FLYPOINTS EQU const_value
DEF MAX_OUTDOOR_SPRITES EQU 23 ; see engine/overworld/overworld.asm

View File

@ -10,26 +10,17 @@ OutdoorSprites:
Level1GroupSprites: Level1GroupSprites:
; Level2GroupSprites: ; Level2GroupSprites:
db SPRITE_SUICUNE
db SPRITE_SILVER_TROPHY
db SPRITE_FAMICOM
db SPRITE_POKEDEX
db SPRITE_WILL
db SPRITE_KAREN
db SPRITE_NURSE
db SPRITE_OLD_LINK_RECEPTIONIST
db SPRITE_BIG_LAPRAS
db SPRITE_BIG_ONIX
db SPRITE_SUDOWOODO
db SPRITE_BIG_SNORLAX
db SPRITE_TEACHER
db SPRITE_FISHER
db SPRITE_YOUNGSTER db SPRITE_YOUNGSTER
db SPRITE_BLUE
db SPRITE_GRAMPS
db SPRITE_BUG_CATCHER db SPRITE_BUG_CATCHER
db SPRITE_FISHER
db SPRITE_COOLTRAINER_M
db SPRITE_COOLTRAINER_F db SPRITE_COOLTRAINER_F
db SPRITE_SWIMMER_GIRL db SPRITE_SUPER_NERD
db SPRITE_SWIMMER_GUY db SPRITE_GRAMPS
db SPRITE_TEACHER
db SPRITE_LASS
; max 9 of 9 walking sprites
db SPRITE_POKE_BALL db SPRITE_POKE_BALL
db SPRITE_FRUIT_TREE db SPRITE_FRUIT_TREE
db SPRITE_ROCK
db 0 ; end

View File

@ -92,32 +92,6 @@ GetPlayerSprite:
INCLUDE "data/sprites/player_sprites.asm" INCLUDE "data/sprites/player_sprites.asm"
AddMapSprites: AddMapSprites:
call GetMapEnvironment
call CheckOutdoorMap
jr z, .outdoor
call AddIndoorSprites
ret
.outdoor
call AddOutdoorSprites
ret
AddIndoorSprites:
ld hl, wMap1ObjectSprite
ld a, 1
.loop
push af
ld a, [hl]
call AddSpriteGFX
ld de, MAPOBJECT_LENGTH
add hl, de
pop af
inc a
cp NUM_OBJECTS
jr nz, .loop
ret
AddOutdoorSprites:
ld a, [wMapGroup] ld a, [wMapGroup]
dec a dec a
ld c, a ld c, a
@ -128,15 +102,12 @@ AddOutdoorSprites:
ld a, [hli] ld a, [hli]
ld h, [hl] ld h, [hl]
ld l, a ld l, a
ld c, MAX_OUTDOOR_SPRITES
.loop .loop
push bc
ld a, [hli] ld a, [hli]
and a
ret z
call AddSpriteGFX call AddSpriteGFX
pop bc jr .loop
dec c
jr nz, .loop
ret
LoadUsedSpritesGFX: LoadUsedSpritesGFX:
ld a, MAPCALLBACK_SPRITES ld a, MAPCALLBACK_SPRITES
@ -303,7 +274,6 @@ _GetSpritePalette::
LoadAndSortSprites: LoadAndSortSprites:
call LoadSpriteGFX call LoadSpriteGFX
call SortUsedSprites
call ArrangeUsedSprites call ArrangeUsedSprites
ret ret
@ -369,76 +339,6 @@ LoadSpriteGFX:
ld a, l ld a, l
ret ret
SortUsedSprites:
; Bubble-sort sprites by type.
; Run backwards through wUsedSprites to find the last one.
ld c, SPRITE_GFX_LIST_CAPACITY
ld de, wUsedSprites + (SPRITE_GFX_LIST_CAPACITY - 1) * 2
.FindLastSprite:
ld a, [de]
and a
jr nz, .FoundLastSprite
dec de
dec de
dec c
jr nz, .FindLastSprite
.FoundLastSprite:
dec c
jr z, .quit
; If the length of the current sprite is
; higher than a later one, swap them.
inc de
ld hl, wUsedSprites + 1
.CheckSprite:
push bc
push de
push hl
.CheckFollowing:
ld a, [de]
cp [hl]
jr nc, .loop
; Swap the two sprites.
ld b, a
ld a, [hl]
ld [hl], b
ld [de], a
dec de
dec hl
ld a, [de]
ld b, a
ld a, [hl]
ld [hl], b
ld [de], a
inc de
inc hl
; Keep doing this until everything's in order.
.loop
dec de
dec de
dec c
jr nz, .CheckFollowing
pop hl
inc hl
inc hl
pop de
pop bc
dec c
jr nz, .CheckSprite
.quit
ret
ArrangeUsedSprites: ArrangeUsedSprites:
; Get the length of each sprite and space them out in VRAM. ; Get the length of each sprite and space them out in VRAM.
; Crystal introduces a second table in VRAM bank 0. ; Crystal introduces a second table in VRAM bank 0.