summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/constants.asm19
-rw-r--r--src/constants/gfx_constants.asm17
-rw-r--r--src/constants/misc_constants.asm14
-rw-r--r--src/engine/bank3.asm26
-rw-r--r--src/engine/bank4.asm28
-rw-r--r--src/engine/home.asm18
-rw-r--r--src/macros/wram.asm19
-rw-r--r--src/wram.asm30
8 files changed, 106 insertions, 65 deletions
diff --git a/src/constants.asm b/src/constants.asm
index 392c8ca..90c6a06 100644
--- a/src/constants.asm
+++ b/src/constants.asm
@@ -1,13 +1,14 @@
-INCLUDE "constants/map_constants.asm"
-INCLUDE "constants/music_constants.asm"
-INCLUDE "constants/text_constants.asm"
-INCLUDE "constants/duel_constants.asm"
-INCLUDE "constants/npc_constants.asm"
+INCLUDE "constants/booster_constants.asm"
INCLUDE "constants/card_constants.asm"
-INCLUDE "constants/deck_constants.asm"
INCLUDE "constants/card_data_constants.asm"
-INCLUDE "constants/misc_constants.asm"
+INCLUDE "constants/deck_constants.asm"
+INCLUDE "constants/duel_constants.asm"
+INCLUDE "constants/gfx_constants.asm"
INCLUDE "constants/hardware_constants.asm"
-INCLUDE "constants/sgb_constants.asm"
+INCLUDE "constants/map_constants.asm"
+INCLUDE "constants/misc_constants.asm"
+INCLUDE "constants/music_constants.asm"
+INCLUDE "constants/npc_constants.asm"
INCLUDE "constants/overworld_script_constants.asm"
-INCLUDE "constants/booster_constants.asm"
+INCLUDE "constants/sgb_constants.asm"
+INCLUDE "constants/text_constants.asm"
diff --git a/src/constants/gfx_constants.asm b/src/constants/gfx_constants.asm
new file mode 100644
index 0000000..fbcbdda
--- /dev/null
+++ b/src/constants/gfx_constants.asm
@@ -0,0 +1,17 @@
+; screen size
+SCREEN_WIDTH EQU 20 ; tiles
+SCREEN_HEIGHT EQU 18 ; tiles
+
+; background map size
+BG_MAP_WIDTH EQU 32 ; tiles
+BG_MAP_HEIGHT EQU 32 ; tiles
+
+; cgb palette size
+CGB_PAL_SIZE EQU 8 ; bytes
+
+; tile size
+TILE_SIZE EQU 16 ; bytes
+
+; wram sprite buffer
+SPRITE_BUFFER_CAPACITY EQU 16 ; sprites
+SPRITE_DATA_LENGTH EQU 16 ; bytes of data per sprite
diff --git a/src/constants/misc_constants.asm b/src/constants/misc_constants.asm
index 50bb03c..11693b4 100644
--- a/src/constants/misc_constants.asm
+++ b/src/constants/misc_constants.asm
@@ -1,17 +1,3 @@
-; screen size
-SCREEN_WIDTH EQU 20 ; tiles
-SCREEN_HEIGHT EQU 18 ; tiles
-
-; background map size
-BG_MAP_WIDTH EQU 32 ; tiles
-BG_MAP_HEIGHT EQU 32 ; tiles
-
-; cgb palette size
-CGB_PAL_SIZE EQU 8 ; bytes
-
-; tile size
-TILE_SIZE EQU 16 ; bytes
-
; console types (for wConsole)
CONSOLE_DMG EQU $00
CONSOLE_SGB EQU $01
diff --git a/src/engine/bank3.asm b/src/engine/bank3.asm
index 68fb245..b7038eb 100644
--- a/src/engine/bank3.asm
+++ b/src/engine/bank3.asm
@@ -580,7 +580,7 @@ Func_c4b9: ; c4b9 (3:44b9)
ld [wd337], a
ld a, $0
farcall Func_1299f
- ld a, [wd4cf]
+ ld a, [wWhichSprite]
ld [wd336], a
ld b, $2
ld a, [wCurMap]
@@ -607,7 +607,7 @@ Func_c4b9: ; c4b9 (3:44b9)
Func_c510: ; c510 (3:4510)
ld a, [wd336]
- ld [wd4cf], a
+ ld [wWhichSprite], a
ld a, [wd335]
bit 4, a
ret nz
@@ -630,7 +630,7 @@ Func_c510: ; c510 (3:4510)
Func_c53d: ; c53d (3:453d)
ld a, [wd336]
- ld [wd4cf], a
+ ld [wWhichSprite], a
ld a, [wd335]
bit 0, a
call nz, Func_c687
@@ -641,7 +641,7 @@ Func_c53d: ; c53d (3:453d)
Func_c554: ; c554 (3:4554)
ld a, [wd336]
- ld [wd4cf], a
+ ld [wWhichSprite], a
ld a, [wCurMap]
cp OVERWORLD_MAP
jr nz, .asm_c566
@@ -657,7 +657,7 @@ Func_c554: ; c554 (3:4554)
ld a, [wSCYBuffer]
ld e, a
ld c, $2
- call ModifyUnknownOAMBufferProperty
+ call GetSpriteBufferProperty
ld a, [wd332]
sub d
add $8
@@ -681,7 +681,7 @@ Func_c58b: ; c58b (3:458b)
and $10
push af
ld c, $f
- call ModifyUnknownOAMBufferProperty
+ call GetSpriteBufferProperty
pop af
ld a, [hl]
jr z, .asm_c5a7
@@ -740,7 +740,7 @@ Unknown_c5e5: ; c5e5 (3:45e5)
Func_c5e9: ; c5e9 (3:45e9)
push bc
ld a, [wd336]
- ld [wd4cf], a
+ ld [wWhichSprite], a
ld a, [wd337]
ld b, a
ld a, [wd334]
@@ -759,7 +759,7 @@ Func_c5fe: ; c5fe (3:45fe)
StartScriptedMovement: ; c607 (3:4607)
push bc
ld a, [wd336]
- ld [wd4cf], a
+ ld [wWhichSprite], a
ld a, [$d339]
call FindScriptedMovementWithOffset
call AttemptScriptedMovement
@@ -789,10 +789,10 @@ AttemptScriptedMovement: ; c619 (3:4619)
ld a, $10
ld [wd338], a
ld c, $f
- call ModifyUnknownOAMBufferProperty
+ call GetSpriteBufferProperty
set 2, [hl]
ld c, $e
- call ModifyUnknownOAMBufferProperty
+ call GetSpriteBufferProperty
ld a, $4
ld [hl], a
.quit_movement
@@ -917,12 +917,12 @@ Func_c6dc: ; c6dc (3:46dc)
Func_c6f7: ; c6f7 (3:46f7)
ld a, [wd336]
- ld [wd4cf], a
+ ld [wWhichSprite], a
ld c, $f
- call ModifyUnknownOAMBufferProperty
+ call GetSpriteBufferProperty
res 2, [hl]
ld c, $e
- call ModifyUnknownOAMBufferProperty
+ call GetSpriteBufferProperty
ld a, $ff
ld [hl], a
ret
diff --git a/src/engine/bank4.asm b/src/engine/bank4.asm
index 757c670..b2facda 100644
--- a/src/engine/bank4.asm
+++ b/src/engine/bank4.asm
@@ -345,7 +345,7 @@ Func_10e28: ; 10e28 (4:4e28)
Func_10e55: ; 10e55 (4:4e55)
ld a, [wd336]
- ld [wd4cf], a
+ ld [wWhichSprite], a
ld a, [wd33e]
or a
jr nz, .asm_10e65
@@ -496,7 +496,7 @@ Func_10fbc: ; 10fbc (4:4fbc)
ld a, $25
farcall Func_1299f
ld c, $2
- call ModifyUnknownOAMBufferProperty
+ call GetSpriteBufferProperty
ld a, $80
ld [hli], a
ld a, $10
@@ -518,7 +518,7 @@ Func_10fde: ; 10fde (4:4fde)
ld [wd33e], a
ld a, $25
call Func_1299f
- ld a, [wd4cf]
+ ld a, [wWhichSprite]
ld [wd33b], a
ld b, $35
ld a, [wConsole]
@@ -534,14 +534,14 @@ Func_10fde: ; 10fde (4:4fde)
or a
jr nz, .asm_11015
ld c, $f
- call ModifyUnknownOAMBufferProperty
+ call GetSpriteBufferProperty
set 7, [hl]
.asm_11015
ret
Func_11016: ; 11016 (4:5016)
ld a, [wd33b]
- ld [wd4cf], a
+ ld [wWhichSprite], a
ld a, [wd33c]
inc a
call Func_12ab5
@@ -551,9 +551,9 @@ Func_11024: ; 11024 (4:5024)
ld a, $57
call PlaySFX
ld a, [wd336]
- ld [wd4cf], a
+ ld [wWhichSprite], a
ld c, $f
- call ModifyUnknownOAMBufferProperty
+ call GetSpriteBufferProperty
set 2, [hl]
ld hl, Unknown_1229f
ld a, [wd33d]
@@ -583,7 +583,7 @@ Func_11024: ; 11024 (4:5024)
Func_11060: ; 11060 (4:5060)
ld a, [wd336]
- ld [wd4cf], a
+ ld [wWhichSprite], a
ld a, [wd341]
or a
jp nz, Func_11184
@@ -626,7 +626,7 @@ Func_110a6: ; 110a6 (4:50a6)
push hl
push bc
ld c, $2
- call ModifyUnknownOAMBufferProperty
+ call GetSpriteBufferProperty
pop bc
ld a, b
sub [hl]
@@ -766,7 +766,7 @@ Func_11184: ; 11184 (4:5184)
ld a, [wd348]
ld e, a
ld c, $2
- call ModifyUnknownOAMBufferProperty
+ call GetSpriteBufferProperty
ld a, [wd343]
add d
ld d, a
@@ -1192,7 +1192,7 @@ Func_1299f: ; 1299f (4:699f)
call Func_12c05
ld [wd5d3], a
xor a
- ld [wd4cf], a
+ ld [wWhichSprite], a
call Func_3db7
ld bc, $0010
.asm_129bb
@@ -1200,9 +1200,9 @@ Func_1299f: ; 1299f (4:699f)
or a
jr z, .asm_129cf
add hl, bc
- ld a, [wd4cf]
+ ld a, [wWhichSprite]
inc a
- ld [wd4cf], a
+ ld [wWhichSprite], a
cp $10
jr nz, .asm_129bb
rst $38
@@ -1254,7 +1254,7 @@ Func_12ab5: ; 12ab5 (4:6ab5)
push hl
push af
ld c, $5
- call ModifyUnknownOAMBufferProperty
+ call GetSpriteBufferProperty
pop af
cp [hl]
pop hl
diff --git a/src/engine/home.asm b/src/engine/home.asm
index 35e4bd5..d11c4c0 100644
--- a/src/engine/home.asm
+++ b/src/engine/home.asm
@@ -8038,18 +8038,18 @@ Func_3d72: ; 3d72 (0:3d72)
Func_3db7: ; 3db7 (0:3db7)
push bc
ld c, $0
- call ModifyUnknownOAMBufferProperty
+ call GetSpriteBufferProperty
pop bc
ret
-; this needs to be determined after we learn more about the buffer.
-ModifyUnknownOAMBufferProperty: ; 3dbf (0:3dbf)
- ld a, [wd4cf]
- cp $10
- jr c, .asm_3dc9
+; read property (byte) c from a sprite in wSpriteBuffer identified by wWhichSprite
+GetSpriteBufferProperty: ; 3dbf (0:3dbf)
+ ld a, [wWhichSprite]
+ cp SPRITE_BUFFER_CAPACITY
+ jr c, .got_sprite
rst $38
- ld a, $f
-.asm_3dc9
+ ld a, SPRITE_BUFFER_CAPACITY - 1 ; default to last sprite
+.got_sprite
push bc
swap a
push af
@@ -8059,7 +8059,7 @@ ModifyUnknownOAMBufferProperty: ; 3dbf (0:3dbf)
and $f0
or c
ld c, a
- ld hl, wOAMBuffer
+ ld hl, wSpriteBuffer
add hl, bc
pop bc
ret
diff --git a/src/macros/wram.asm b/src/macros/wram.asm
index cea20fa..8b3f306 100644
--- a/src/macros/wram.asm
+++ b/src/macros/wram.asm
@@ -40,3 +40,22 @@ move_data_struct: MACRO
\1Unknown1:: db
\1Animation:: db
ENDM
+
+sprite_buffer_struct: MACRO
+\1Property1:: ds 1
+\1Property2:: ds 1
+\1Property3:: ds 1
+\1Property4:: ds 1
+\1Property5:: ds 1
+\1Property6:: ds 1
+\1Property7:: ds 1
+\1Property8:: ds 1
+\1Property9:: ds 1
+\1Property10:: ds 1
+\1Property11:: ds 1
+\1Property12:: ds 1
+\1Property13:: ds 1
+\1Property14:: ds 1
+\1Property15:: ds 1
+\1Property16:: ds 1
+ENDM \ No newline at end of file
diff --git a/src/wram.asm b/src/wram.asm
index 0a92ff2..70ac991 100644
--- a/src/wram.asm
+++ b/src/wram.asm
@@ -1174,13 +1174,31 @@ wd4ca:: ; d4ca
wd4cb:: ; d4cb
ds $4
-; some sort of control bit for the OAMBuffer
-wd4cf:: ; d4cf
- ds $1
-; this might be more of an animation buffer as I can't find any properties like which tile sprites go where.
-wOAMBuffer:: ; d4d0
- ds $103
+; used as an index to manipulate a sprite from wSpriteBuffer
+wWhichSprite:: ; d4cf
+ ds $1
+
+; 16-byte data for up to 16 sprites
+wSpriteBuffer:: ; d4d0
+ sprite_buffer_struct wSprite1
+ sprite_buffer_struct wSprite2
+ sprite_buffer_struct wSprite3
+ sprite_buffer_struct wSprite4
+ sprite_buffer_struct wSprite5
+ sprite_buffer_struct wSprite6
+ sprite_buffer_struct wSprite7
+ sprite_buffer_struct wSprite8
+ sprite_buffer_struct wSprite9
+ sprite_buffer_struct wSprite10
+ sprite_buffer_struct wSprite11
+ sprite_buffer_struct wSprite12
+ sprite_buffer_struct wSprite13
+ sprite_buffer_struct wSprite14
+ sprite_buffer_struct wSprite15
+ sprite_buffer_struct wSprite16
+
+ ds $3
wd5d3:: ; d5d3
ds $4