Skip to content

Commit

Permalink
Add variable sprite slots like Gen 2 has
Browse files Browse the repository at this point in the history
  • Loading branch information
JustRegularLuna committed Nov 11, 2015
1 parent 1826a1f commit 828b7f4
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 1 deletion.
7 changes: 7 additions & 0 deletions constants/sprite_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ const_value = 1
const SPRITE_POKEY
const SPRITE_DITTO

; Variable Sprite IDs Here
VAR_SPRITE_1 EQU $F1
VAR_SPRITE_2 EQU $F2
VAR_SPRITE_3 EQU $F3
VAR_SPRITE_4 EQU $F4
VAR_SPRITE_5 EQU $F5
VAR_SPRITE_6 EQU $F6

; different kinds of people events
ITEM EQU $80
Expand Down
9 changes: 9 additions & 0 deletions data/default_var_sprites.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
VarSpriteTable:
; Determines the default IDs of the variable sprite slots
db SPRITE_LASS ; VAR_SPRITE_1
db SPRITE_LASS ; VAR_SPRITE_2
db SPRITE_LASS ; VAR_SPRITE_3
db SPRITE_LASS ; VAR_SPRITE_4
db SPRITE_LASS ; VAR_SPRITE_5
db SPRITE_LASS ; VAR_SPRITE_6
VarSpriteTableEnd:
37 changes: 37 additions & 0 deletions engine/overworld/map_sprites.asm
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ LoadMapSpriteTilePatterns: ; 17871 (5:7871)
push af
ld a,[hl] ; $C2XE (sprite picture ID)
ld b,a ; b = current sprite picture ID
; add variable sprite IDs
cp VAR_SPRITE_1
jr c, .notVarSprite
call GetVarSpriteIDs
.notVarSprite
cp a,SPRITE_BALL ; is it a 4-tile sprite?
jr c,.notFourTileSprite
pop af
Expand Down Expand Up @@ -437,4 +442,36 @@ GetSplitMapSpriteSetID: ; 17a1a (5:7a1a)
ld a,$01
ret

GetVarSpriteIDs:
cp VAR_SPRITE_1
jr nz, .next1
ld a, [wVarSprite1]
jr .done
.next1
cp VAR_SPRITE_2
jr nz, .next2
ld a, [wVarSprite2]
jr .done
.next2
cp VAR_SPRITE_3
jr nz, .next3
ld a, [wVarSprite3]
jr .done
.next3
cp VAR_SPRITE_4
jr nz, .next4
ld a, [wVarSprite4]
jr .done
.next4
cp VAR_SPRITE_5
jr nz, .next5
ld a, [wVarSprite5]
jr .done
.next5
;VAR_SPRITE_6
ld a, [wVarSprite6]
.done
ld b, a
ret

INCLUDE "data/sprite_sets.asm"
9 changes: 9 additions & 0 deletions main.asm
Original file line number Diff line number Diff line change
Expand Up @@ -4479,12 +4479,21 @@ InitPlayerData2:
ld [hli], a
ld [hl], a

; Initialize the variable sprites
ld hl, VarSpriteTable
ld de, wVarSprites
ld bc, VarSpriteTableEnd - VarSpriteTable
call CopyData

; Initialize map script numbers
xor a
ld hl, W_GAMEPROGRESSFLAGS
ld bc, W_GAMEPROGRESSFLAGSEND - W_GAMEPROGRESSFLAGS ; originally $c8
call FillMemory ; clear all game progress flags

jp InitializeMissableObjectsFlags
INCLUDE "data/default_var_sprites.asm"

InitializeEmptyList:
xor a ; count
Expand Down
21 changes: 20 additions & 1 deletion wram.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1903,11 +1903,30 @@ W_SEAFOAMISLANDS5CURSCRIPT:: ; d668
W_ROUTE18GATECURSCRIPT:: ; d669
ds 1
; unused
ds 140
ds 134

W_GAMEPROGRESSFLAGSEND::



; variable sprites can be changed with scripts
; useful in the same way it was in Gen 2
; sprites don't update until the map is reloaded
; see "data/default_var_sprites.asm"
wVarSprites::
wVarSprite1::
ds 1
wVarSprite2::
ds 1
wVarSprite3::
ds 1
wVarSprite4::
ds 1
wVarSprite5::
ds 1
wVarSprite6::
ds 1

wCurTrainerName::
; used to store individual trainer names
ds 13
Expand Down

0 comments on commit 828b7f4

Please sign in to comment.