shithub: pokecrystal

Download patch

ref: 417937cffc2a7c3cfac49f3b00caf1a856d0a925
parent: cc95d1208d4a6b8291a5430a8d652a9337074788
author: Remy Oukaour <remy.oukaour@gmail.com>
date: Wed Jan 10 08:47:57 EST 2018

Resolve #461

--- a/constants/gfx_constants.asm
+++ b/constants/gfx_constants.asm
@@ -20,3 +20,12 @@
 EXP_BAR_LENGTH_PX EQU EXP_BAR_LENGTH * TILE_WIDTH ; pixels
 
 PALPACKET_LENGTH EQU $10
+
+; sprite_oam_struct members (see macros/wram.asm)
+	const_def
+	const SPRITEOAMSTRUCT_YCOORD     ; 0
+	const SPRITEOAMSTRUCT_XCOORD     ; 1
+	const SPRITEOAMSTRUCT_TILE_ID    ; 2
+	const SPRITEOAMSTRUCT_ATTRIBUTES ; 3
+SPRITEOAMSTRUCT_LENGTH EQU const_value
+NUM_SPRITE_OAM_STRUCTS EQU 40 ; see Sprites
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -9329,27 +9329,27 @@
 ; 3fc5b
 
 .LoadTrainerBackpicAsOAM: ; 3fc5b
-	ld hl, Sprites
+	ld hl, Sprite01
 	xor a
 	ld [hMapObjectIndexBuffer], a
-	ld b, $6
-	ld e, 21 * 8
+	ld b, 6
+	ld e, (SCREEN_WIDTH + 1) * TILE_WIDTH
 .outer_loop
-	ld c, $3
-	ld d, 8 * 8
+	ld c, 3
+	ld d, 8 * TILE_WIDTH
 .inner_loop
-	ld [hl], d
+	ld [hl], d ; y
 	inc hl
-	ld [hl], e
+	ld [hl], e ; x
 	inc hl
 	ld a, [hMapObjectIndexBuffer]
-	ld [hli], a
+	ld [hli], a ; tile id
 	inc a
 	ld [hMapObjectIndexBuffer], a
-	ld a, $1
-	ld [hli], a
+	ld a, PAL_BATTLE_OB_PLAYER
+	ld [hli], a ; attributes
 	ld a, d
-	add $8
+	add 1 * TILE_WIDTH
 	ld d, a
 	dec c
 	jr nz, .inner_loop
@@ -9357,7 +9357,7 @@
 	add $3
 	ld [hMapObjectIndexBuffer], a
 	ld a, e
-	add $8
+	add 1 * TILE_WIDTH
 	ld e, a
 	dec b
 	jr nz, .outer_loop
--- a/engine/battle/sliding_intro.asm
+++ b/engine/battle/sliding_intro.asm
@@ -60,9 +60,9 @@
 ; 4e9d6
 
 .subfunction3 ; 4e9d6
-	ld hl, Sprites + 1 ; x pixel
+	ld hl, Sprite01XCoord
 	ld c, $12 ; 18
-	ld de, $4
+	ld de, SPRITEOAMSTRUCT_LENGTH
 .loop3
 	dec [hl]
 	dec [hl]
--- a/engine/battle/trainer_huds.asm
+++ b/engine/battle/trainer_huds.asm
@@ -28,7 +28,7 @@
 	ld [hl], a
 	ld a, 8
 	ld [wPlaceBallsDirection], a
-	ld hl, Sprites
+	ld hl, Sprite01
 	jp LoadTrainerHudOAM
 ; 2c03a
 
@@ -44,7 +44,7 @@
 	ld [hl], 4 * 8
 	ld a, -8
 	ld [wPlaceBallsDirection], a
-	ld hl, Sprites + PARTY_LENGTH * 4
+	ld hl, Sprite07
 	jp LoadTrainerHudOAM
 ; 2c059
 
@@ -193,7 +193,7 @@
 	ld [hl], 8 * 8
 	ld a, $8
 	ld [wPlaceBallsDirection], a
-	ld hl, Sprites
+	ld hl, Sprite01
 	call LoadTrainerHudOAM
 
 	ld hl, OTPartyMon1HP
@@ -203,7 +203,7 @@
 	ld a, 10 * 8
 	ld [hli], a
 	ld [hl], 13 * 8
-	ld hl, Sprites + PARTY_LENGTH * 4
+	ld hl, Sprite07
 	jp LoadTrainerHudOAM
 ; 2c143
 
@@ -212,13 +212,13 @@
 	ld c, PARTY_LENGTH
 .loop
 	ld a, [wPlaceBallsY]
-	ld [hli], a
+	ld [hli], a ; y
 	ld a, [wPlaceBallsX]
-	ld [hli], a
+	ld [hli], a ; x
 	ld a, [de]
-	ld [hli], a
-	ld a, $3
-	ld [hli], a
+	ld [hli], a ; tile id
+	ld a, PAL_BATTLE_OB_YELLOW
+	ld [hli], a ; attributes
 	ld a, [wPlaceBallsX]
 	ld b, a
 	ld a, [wPlaceBallsDirection]
--- a/engine/battle_anims/anim_commands.asm
+++ b/engine/battle_anims/anim_commands.asm
@@ -258,15 +258,15 @@
 	bit 3, a
 	jr z, .delete
 
-	ld hl, Sprites + 3
-	ld c, (SpritesEnd - Sprites) / 4
+	ld hl, Sprite01Attributes
+	ld c, NUM_SPRITE_OAM_STRUCTS
 .loop
 	ld a, [hl]
 	and $f0
 	ld [hli], a
+rept SPRITEOAMSTRUCT_LENGTH +- 1
 	inc hl
-	inc hl
-	inc hl
+endr
 	dec c
 	jr nz, .loop
 	ret
--- /dev/null
+++ b/engine/battle_anims/core.asm
@@ -1,0 +1,314 @@
+QueueBattleAnimation: ; cc9a1 (33:49a1)
+	ld hl, ActiveAnimObjects
+	ld e, 10
+.loop
+	ld a, [hl]
+	and a
+	jr z, .done
+	ld bc, BATTLEANIMSTRUCT_LENGTH
+	add hl, bc
+	dec e
+	jr nz, .loop
+	scf
+	ret
+
+.done
+	ld c, l
+	ld b, h
+	ld hl, wNumActiveBattleAnims
+	inc [hl]
+	call InitBattleAnimation
+	ret
+
+DeinitBattleAnimation: ; cc9bd
+	ld hl, BATTLEANIMSTRUCT_INDEX
+	add hl, bc
+	ld [hl], $0
+	ret
+
+; cc9c4
+
+InitBattleAnimation: ; cc9c4 (33:49c4)
+	ld a, [wBattleAnimTemp0]
+	ld e, a
+	ld d, 0
+	ld hl, BattleAnimObjects
+rept 6
+	add hl, de
+endr
+	ld e, l
+	ld d, h
+	ld hl, BATTLEANIMSTRUCT_INDEX
+	add hl, bc
+	ld a, [wNumActiveBattleAnims]
+	ld [hli], a ; Index
+	ld a, [de]
+	inc de
+	ld [hli], a ; 01
+	ld a, [de]
+	inc de
+	ld [hli], a ; 02
+	ld a, [de]
+	inc de
+	ld [hli], a ; Frameset ID
+	ld a, [de]
+	inc de
+	ld [hli], a ; Function
+	ld a, [de]
+	inc de
+	ld [hli], a ; 05
+	ld a, [de]
+	call GetBattleAnimTileOffset
+	ld [hli], a ; Tile ID
+	ld a, [wBattleAnimTemp1]
+	ld [hli], a ; X Coord
+	ld a, [wBattleAnimTemp2]
+	ld [hli], a ; Y Coord
+	xor a
+	ld [hli], a ; X Offset
+	ld [hli], a ; Y Offset
+	ld a, [wBattleAnimTemp3]
+	ld [hli], a ; 0b
+	xor a
+	ld [hli], a ; 0c
+	dec a
+	ld [hli], a ; 0d
+	xor a
+	ld [hli], a ; 0e
+	ld [hli], a ; 0f
+	ld [hl], a  ; 10
+	ret
+
+BattleAnimOAMUpdate: ; cca09
+	call InitBattleAnimBuffer
+	call GetBattleAnimFrame
+	cp -3
+	jp z, .done
+	cp -4
+	jp z, .delete
+	push af
+	ld hl, wBattleAnimTempOAMFlags
+	ld a, [wBattleAnimTempAddSubFlags]
+	xor [hl]
+	and $e0
+	ld [hl], a
+	pop af
+	push bc
+	call GetBattleAnimOAMPointer
+	ld a, [wBattleAnimTempTileID]
+	add [hl]
+	ld [wBattleAnimTempTileID], a
+	inc hl
+	ld a, [hli]
+	ld c, a
+	ld a, [hli]
+	ld h, [hl]
+	ld l, a
+	ld a, [wBattleAnimOAMPointerLo]
+	ld e, a
+	ld d, HIGH(Sprites)
+.loop
+	ld a, [wBattleAnimTempYCoord]
+	ld b, a
+	ld a, [wBattleAnimTempYOffset]
+	add b
+	ld b, a
+	push hl
+	ld a, [hl]
+	ld hl, wBattleAnimTempOAMFlags
+	bit 6, [hl]
+	jr z, .no_yflip
+	add $8
+	xor $ff
+	inc a
+
+.no_yflip
+	pop hl
+	add b
+	ld [de], a
+	inc hl
+	inc de
+	ld a, [wBattleAnimTempXCoord]
+	ld b, a
+	ld a, [wBattleAnimTempXOffset]
+	add b
+	ld b, a
+	push hl
+	ld a, [hl]
+	ld hl, wBattleAnimTempOAMFlags
+	bit 5, [hl]
+	jr z, .no_xflip
+	add $8
+	xor $ff
+	inc a
+
+.no_xflip
+	pop hl
+	add b
+	ld [de], a
+	inc hl
+	inc de
+	ld a, [wBattleAnimTempTileID]
+	add $31
+	add [hl]
+	ld [de], a
+	inc hl
+	inc de
+	ld a, [wBattleAnimTempOAMFlags]
+	ld b, a
+	ld a, [hl]
+	xor b
+	and $e0
+	ld b, a
+	ld a, [hl]
+	and $10
+	or b
+	ld b, a
+	ld a, [wBattleAnimTempPalette]
+	and $f
+	or b
+	ld [de], a
+	inc hl
+	inc de
+	ld a, e
+	ld [wBattleAnimOAMPointerLo], a
+	cp $a0
+	jr nc, .exit_set_carry
+	dec c
+	jr nz, .loop
+	pop bc
+	jr .done
+
+.delete
+	call DeinitBattleAnimation
+
+.done
+	and a
+	ret
+
+.exit_set_carry
+	pop bc
+	scf
+	ret
+
+; ccaaa
+
+InitBattleAnimBuffer: ; ccaaa
+	ld hl, BATTLEANIMSTRUCT_01
+	add hl, bc
+	ld a, [hl]
+	and %10000000
+	ld [wBattleAnimTempOAMFlags], a
+	xor a
+	ld [wBattleAnimTempAddSubFlags], a
+	ld hl, BATTLEANIMSTRUCT_PALETTE
+	add hl, bc
+	ld a, [hl]
+	ld [wBattleAnimTempPalette], a
+	ld hl, BATTLEANIMSTRUCT_02
+	add hl, bc
+	ld a, [hl]
+	ld [wBattleAnimTempField02], a
+	ld hl, BATTLEANIMSTRUCT_TILEID
+	add hl, bc
+	ld a, [hli]
+	ld [wBattleAnimTempTileID], a
+	ld a, [hli]
+	ld [wBattleAnimTempXCoord], a
+	ld a, [hli]
+	ld [wBattleAnimTempYCoord], a
+	ld a, [hli]
+	ld [wBattleAnimTempXOffset], a
+	ld a, [hli]
+	ld [wBattleAnimTempYOffset], a
+	ld a, [hBattleTurn]
+	and a
+	ret z
+	ld hl, BATTLEANIMSTRUCT_01
+	add hl, bc
+	ld a, [hl]
+	ld [wBattleAnimTempOAMFlags], a
+	bit 0, [hl]
+	ret z
+	ld hl, BATTLEANIMSTRUCT_XCOORD
+	add hl, bc
+	ld a, [hli]
+	ld d, a
+	ld a, (-10 * 8) + 4
+	sub d
+	ld [wBattleAnimTempXCoord], a
+	ld a, [hli]
+	ld d, a
+	ld a, [wBattleAnimTempField02]
+	cp $ff
+	jr nz, .check_kinesis_softboiled_milkdrink
+	ld a, 5 * 8
+	add d
+	jr .done
+
+.check_kinesis_softboiled_milkdrink
+	sub d
+	push af
+	ld a, [FXAnimID + 1]
+	or a
+	jr nz, .no_sub
+	ld a, [FXAnimID]
+	cp KINESIS
+	jr z, .kinesis
+	cp SOFTBOILED
+	jr z, .softboiled
+	cp MILK_DRINK
+	jr nz, .no_sub
+.kinesis
+.softboiled
+.milk_drink
+	pop af
+	sub 1 * 8
+	jr .done
+
+.no_sub
+	pop af
+.done
+	ld [wBattleAnimTempYCoord], a
+	ld a, [hli]
+	xor $ff
+	inc a
+	ld [wBattleAnimTempXOffset], a
+	ret
+
+; ccb31
+
+GetBattleAnimTileOffset: ; ccb31 (33:4b31)
+	push hl
+	push bc
+	ld hl, wBattleAnimTileDict
+	ld b, a
+	ld c, 10 / 2
+.loop
+	ld a, [hli]
+	cp b
+	jr z, .load
+	inc hl
+	dec c
+	jr nz, .loop
+	xor a
+	jr .done
+
+.load
+	ld a, [hl]
+.done
+	pop bc
+	pop hl
+	ret
+
+_ExecuteBGEffects: ; ccb48
+	callfar ExecuteBGEffects
+	ret
+
+; ccb4f
+
+_QueueBGEffect: ; ccb4f (33:4b4f)
+	callfar QueueBGEffect
+	ret
+
+; ccb56 (33:4b56)
--- a/engine/battle_anims/engine.asm
+++ /dev/null
@@ -1,314 +1,0 @@
-QueueBattleAnimation: ; cc9a1 (33:49a1)
-	ld hl, ActiveAnimObjects
-	ld e, 10
-.loop
-	ld a, [hl]
-	and a
-	jr z, .done
-	ld bc, BATTLEANIMSTRUCT_LENGTH
-	add hl, bc
-	dec e
-	jr nz, .loop
-	scf
-	ret
-
-.done
-	ld c, l
-	ld b, h
-	ld hl, wNumActiveBattleAnims
-	inc [hl]
-	call InitBattleAnimation
-	ret
-
-DeinitBattleAnimation: ; cc9bd
-	ld hl, BATTLEANIMSTRUCT_INDEX
-	add hl, bc
-	ld [hl], $0
-	ret
-
-; cc9c4
-
-InitBattleAnimation: ; cc9c4 (33:49c4)
-	ld a, [wBattleAnimTemp0]
-	ld e, a
-	ld d, 0
-	ld hl, BattleAnimObjects
-rept 6
-	add hl, de
-endr
-	ld e, l
-	ld d, h
-	ld hl, BATTLEANIMSTRUCT_INDEX
-	add hl, bc
-	ld a, [wNumActiveBattleAnims]
-	ld [hli], a ; Index
-	ld a, [de]
-	inc de
-	ld [hli], a ; 01
-	ld a, [de]
-	inc de
-	ld [hli], a ; 02
-	ld a, [de]
-	inc de
-	ld [hli], a ; Frameset ID
-	ld a, [de]
-	inc de
-	ld [hli], a ; Function
-	ld a, [de]
-	inc de
-	ld [hli], a ; 05
-	ld a, [de]
-	call GetBattleAnimTileOffset
-	ld [hli], a ; Tile ID
-	ld a, [wBattleAnimTemp1]
-	ld [hli], a ; X Coord
-	ld a, [wBattleAnimTemp2]
-	ld [hli], a ; Y Coord
-	xor a
-	ld [hli], a ; X Offset
-	ld [hli], a ; Y Offset
-	ld a, [wBattleAnimTemp3]
-	ld [hli], a ; 0b
-	xor a
-	ld [hli], a ; 0c
-	dec a
-	ld [hli], a ; 0d
-	xor a
-	ld [hli], a ; 0e
-	ld [hli], a ; 0f
-	ld [hl], a  ; 10
-	ret
-
-BattleAnimOAMUpdate: ; cca09
-	call InitBattleAnimBuffer
-	call GetBattleAnimFrame
-	cp -3
-	jp z, .done
-	cp -4
-	jp z, .delete
-	push af
-	ld hl, wBattleAnimTempOAMFlags
-	ld a, [wBattleAnimTempAddSubFlags]
-	xor [hl]
-	and $e0
-	ld [hl], a
-	pop af
-	push bc
-	call GetBattleAnimOAMPointer
-	ld a, [wBattleAnimTempTileID]
-	add [hl]
-	ld [wBattleAnimTempTileID], a
-	inc hl
-	ld a, [hli]
-	ld c, a
-	ld a, [hli]
-	ld h, [hl]
-	ld l, a
-	ld a, [wBattleAnimOAMPointerLo]
-	ld e, a
-	ld d, HIGH(Sprites)
-.loop
-	ld a, [wBattleAnimTempYCoord]
-	ld b, a
-	ld a, [wBattleAnimTempYOffset]
-	add b
-	ld b, a
-	push hl
-	ld a, [hl]
-	ld hl, wBattleAnimTempOAMFlags
-	bit 6, [hl]
-	jr z, .no_yflip
-	add $8
-	xor $ff
-	inc a
-
-.no_yflip
-	pop hl
-	add b
-	ld [de], a
-	inc hl
-	inc de
-	ld a, [wBattleAnimTempXCoord]
-	ld b, a
-	ld a, [wBattleAnimTempXOffset]
-	add b
-	ld b, a
-	push hl
-	ld a, [hl]
-	ld hl, wBattleAnimTempOAMFlags
-	bit 5, [hl]
-	jr z, .no_xflip
-	add $8
-	xor $ff
-	inc a
-
-.no_xflip
-	pop hl
-	add b
-	ld [de], a
-	inc hl
-	inc de
-	ld a, [wBattleAnimTempTileID]
-	add $31
-	add [hl]
-	ld [de], a
-	inc hl
-	inc de
-	ld a, [wBattleAnimTempOAMFlags]
-	ld b, a
-	ld a, [hl]
-	xor b
-	and $e0
-	ld b, a
-	ld a, [hl]
-	and $10
-	or b
-	ld b, a
-	ld a, [wBattleAnimTempPalette]
-	and $f
-	or b
-	ld [de], a
-	inc hl
-	inc de
-	ld a, e
-	ld [wBattleAnimOAMPointerLo], a
-	cp $a0
-	jr nc, .exit_set_carry
-	dec c
-	jr nz, .loop
-	pop bc
-	jr .done
-
-.delete
-	call DeinitBattleAnimation
-
-.done
-	and a
-	ret
-
-.exit_set_carry
-	pop bc
-	scf
-	ret
-
-; ccaaa
-
-InitBattleAnimBuffer: ; ccaaa
-	ld hl, BATTLEANIMSTRUCT_01
-	add hl, bc
-	ld a, [hl]
-	and %10000000
-	ld [wBattleAnimTempOAMFlags], a
-	xor a
-	ld [wBattleAnimTempAddSubFlags], a
-	ld hl, BATTLEANIMSTRUCT_PALETTE
-	add hl, bc
-	ld a, [hl]
-	ld [wBattleAnimTempPalette], a
-	ld hl, BATTLEANIMSTRUCT_02
-	add hl, bc
-	ld a, [hl]
-	ld [wBattleAnimTempField02], a
-	ld hl, BATTLEANIMSTRUCT_TILEID
-	add hl, bc
-	ld a, [hli]
-	ld [wBattleAnimTempTileID], a
-	ld a, [hli]
-	ld [wBattleAnimTempXCoord], a
-	ld a, [hli]
-	ld [wBattleAnimTempYCoord], a
-	ld a, [hli]
-	ld [wBattleAnimTempXOffset], a
-	ld a, [hli]
-	ld [wBattleAnimTempYOffset], a
-	ld a, [hBattleTurn]
-	and a
-	ret z
-	ld hl, BATTLEANIMSTRUCT_01
-	add hl, bc
-	ld a, [hl]
-	ld [wBattleAnimTempOAMFlags], a
-	bit 0, [hl]
-	ret z
-	ld hl, BATTLEANIMSTRUCT_XCOORD
-	add hl, bc
-	ld a, [hli]
-	ld d, a
-	ld a, (-10 * 8) + 4
-	sub d
-	ld [wBattleAnimTempXCoord], a
-	ld a, [hli]
-	ld d, a
-	ld a, [wBattleAnimTempField02]
-	cp $ff
-	jr nz, .check_kinesis_softboiled_milkdrink
-	ld a, 5 * 8
-	add d
-	jr .done
-
-.check_kinesis_softboiled_milkdrink
-	sub d
-	push af
-	ld a, [FXAnimID + 1]
-	or a
-	jr nz, .no_sub
-	ld a, [FXAnimID]
-	cp KINESIS
-	jr z, .kinesis
-	cp SOFTBOILED
-	jr z, .softboiled
-	cp MILK_DRINK
-	jr nz, .no_sub
-.kinesis
-.softboiled
-.milk_drink
-	pop af
-	sub 1 * 8
-	jr .done
-
-.no_sub
-	pop af
-.done
-	ld [wBattleAnimTempYCoord], a
-	ld a, [hli]
-	xor $ff
-	inc a
-	ld [wBattleAnimTempXOffset], a
-	ret
-
-; ccb31
-
-GetBattleAnimTileOffset: ; ccb31 (33:4b31)
-	push hl
-	push bc
-	ld hl, wBattleAnimTileDict
-	ld b, a
-	ld c, 10 / 2
-.loop
-	ld a, [hli]
-	cp b
-	jr z, .load
-	inc hl
-	dec c
-	jr nz, .loop
-	xor a
-	jr .done
-
-.load
-	ld a, [hl]
-.done
-	pop bc
-	pop hl
-	ret
-
-_ExecuteBGEffects: ; ccb48
-	callfar ExecuteBGEffects
-	ret
-
-; ccb4f
-
-_QueueBGEffect: ; ccb4f (33:4b4f)
-	callfar QueueBGEffect
-	ret
-
-; ccb56 (33:4b56)
--- a/engine/billspc.asm
+++ b/engine/billspc.asm
@@ -1502,7 +1502,7 @@
 
 .place_cursor
 	ld hl, .OAM
-	ld de, Sprites
+	ld de, Sprite01
 .loop
 	ld a, [hl]
 	cp -1
@@ -1512,9 +1512,9 @@
 	swap a
 	add [hl]
 	inc hl
-	ld [de], a
+	ld [de], a ; y
 	inc de
-rept 3
+rept SPRITEOAMSTRUCT_LENGTH +- 1
 	ld a, [hli]
 	ld [de], a
 	inc de
@@ -1552,7 +1552,7 @@
 
 BillsPC_UpdateInsertCursor: ; e2e8c
 	ld hl, .OAM
-	ld de, Sprites
+	ld de, Sprite01
 .loop
 	ld a, [hl]
 	cp -1
@@ -1562,9 +1562,9 @@
 	swap a
 	add [hl]
 	inc hl
-	ld [de], a
+	ld [de], a ; y
 	inc de
-rept 3
+rept SPRITEOAMSTRUCT_LENGTH +- 1
 	ld a, [hli]
 	ld [de], a
 	inc de
--- a/engine/card_flip.asm
+++ b/engine/card_flip.asm
@@ -594,23 +594,23 @@
 ; e0509 (38:4509)
 
 CardFlip_CopyOAM: ; e0509
-	ld de, Sprites
+	ld de, Sprite01
 	ld a, [hli]
 .loop
 	push af
 	ld a, [hli]
 	add b
-	ld [de], a
+	ld [de], a ; y
 	inc de
 	ld a, [hli]
 	add c
-	ld [de], a
+	ld [de], a ; x
 	inc de
 	ld a, [hli]
-	ld [de], a
+	ld [de], a ; tile id
 	inc de
 	ld a, [hli]
-	ld [de], a
+	ld [de], a ; attributes
 	inc de
 	pop af
 	dec a
@@ -619,11 +619,11 @@
 ; e0521
 
 CardFlip_ShiftDigitsLeftTwoPixels: ; e0521 (38:4521)
-	ld de, vTiles1 tile ("0" & $7f)
-	ld hl, vTiles1 tile ("0" & $7f) + 2
+	ld de, vTiles0 tile "0"
+	ld hl, vTiles0 tile "0" + 2
 	ld bc, 10 tiles - 2
 	call CopyBytes
-	ld hl, vTiles1 tile $7f + 1 tiles - 2
+	ld hl, vTiles0 tile "9" + 1 tiles - 2
 	xor a
 	ld [hli], a
 	ld [hl], a
--- a/engine/debug.asm
+++ b/engine/debug.asm
@@ -1016,17 +1016,17 @@
 
 .asm_81fb7
 	ld a, b
-	ld [hli], a
+	ld [hli], a ; y
 	ld a, [de]
 	add a
 	add a
-	add $18
-	ld [hli], a
+	add 3 * TILE_WIDTH
+	ld [hli], a ; x
 	xor a
-	ld [hli], a
+	ld [hli], a ; tile id
 	ld a, c
-	ld [hli], a
-	ld a, $10
+	ld [hli], a ; attributes
+	ld a, 2 * TILE_WIDTH
 	add b
 	ld b, a
 	inc c
--- a/engine/events/celebi.asm
+++ b/engine/events/celebi.asm
@@ -43,26 +43,26 @@
 .done
 	pop af
 	ld [VramState], a
-	call .RefreshPlayerSprite_ClearAllOthers
+	call .RestorePlayerSprite_DespawnLeaves
 	call CelebiEvent_SetBattleType
 	ret
 
 ; 498f9
 
-.RefreshPlayerSprite_ClearAllOthers: ; 498f9
-	ld hl, Sprites + 2
+.RestorePlayerSprite_DespawnLeaves: ; 498f9
+	ld hl, Sprite01TileID
 	xor a
-	ld c, $4
+	ld c, 4
 .OAMloop:
-	ld [hli], a
+	ld [hli], a ; tile id
+rept SPRITEOAMSTRUCT_LENGTH +- 1
 	inc hl
-	inc hl
-	inc hl
+endr
 	inc a
 	dec c
 	jr nz, .OAMloop
-	ld hl, Sprites + 4 * 4
-	ld bc, 36 * 4
+	ld hl, Sprite05
+	ld bc, SpritesEnd - Sprite05
 	xor a
 	call ByteFill
 	ret
--- a/engine/events/field_moves.asm
+++ b/engine/events/field_moves.asm
@@ -62,8 +62,8 @@
 	xor a
 	ld [hBGMapMode], a
 	farcall ClearSpriteAnims
-	ld hl, Sprites + 36 * 4
-	ld bc, SpritesEnd - (Sprites + 36 * 4)
+	ld hl, Sprite37
+	ld bc, SpritesEnd - Sprite37
 	xor a
 	call ByteFill
 	ld de, Font
@@ -393,19 +393,19 @@
 	ret
 
 .RestorePlayerSprite_DespawnLeaves: ; 8cb82 (23:4b82)
-	ld hl, Sprites + 2 ; Tile ID
+	ld hl, Sprite01TileID
 	xor a
-	ld c, $4
-.loop2
-	ld [hli], a
+	ld c, 4
+.OAMloop
+	ld [hli], a ; tile id
+rept SPRITEOAMSTRUCT_LENGTH +- 1
 	inc hl
-	inc hl
-	inc hl
+endr
 	inc a
 	dec c
-	jr nz, .loop2
-	ld hl, Sprites + 4 * 4
-	ld bc, SpritesEnd - (Sprites + 4 * 4)
+	jr nz, .OAMloop
+	ld hl, Sprite05
+	ld bc, SpritesEnd - Sprite05
 	xor a
 	call ByteFill
 	ret
--- a/engine/events/heal_machine_anim.asm
+++ b/engine/events/heal_machine_anim.asm
@@ -73,13 +73,13 @@
 	call .LoadPalettes
 	ld de, .HealMachineGFX
 	ld hl, vTiles0 tile $7c
-	lb bc, BANK(.HealMachineGFX), $2
+	lb bc, BANK(.HealMachineGFX), 2
 	call Request2bpp
 	ret
 ; 12393
 
 .PC_LoadBallsOntoMachine: ; 12393
-	ld hl, Sprites + $80
+	ld hl, Sprite33
 	ld de, .PC_ElmsLab_OAM
 	call .PlaceHealingMachineTile
 	call .PlaceHealingMachineTile
@@ -86,7 +86,7 @@
 	jr .LoadBallsOntoMachine
 
 .HOF_LoadBallsOntoMachine: ; 123a1
-	ld hl, Sprites + $80
+	ld hl, Sprite33
 	ld de, .HOF_OAM
 
 .LoadBallsOntoMachine: ; 123a7
@@ -249,17 +249,17 @@
 	ld a, [de]
 	add c
 	inc de
-	ld [hli], a
+	ld [hli], a ; y
 	ld a, [de]
 	add b
 	inc de
-	ld [hli], a
+	ld [hli], a ; x
 	ld a, [de]
 	inc de
-	ld [hli], a
+	ld [hli], a ; tile id
 	ld a, [de]
 	inc de
-	ld [hli], a
+	ld [hli], a ; attributes
 	pop bc
 	ret
 ; 124c1
--- a/engine/evolution_animation.asm
+++ b/engine/evolution_animation.asm
@@ -346,15 +346,15 @@
 	inc a
 	and $7
 	ld b, a
-	ld hl, Sprites + 3 ; attributes
-	ld c, 40
+	ld hl, Sprite01Attributes
+	ld c, NUM_SPRITE_OAM_STRUCTS
 .loop6
 	ld a, [hl]
 	or b
-	ld [hli], a
+	ld [hli], a ; attributes
+rept SPRITEOAMSTRUCT_LENGTH +- 1
 	inc hl
-	inc hl
-	inc hl
+endr
 	dec c
 	jr nz, .loop6
 	pop bc
--- a/engine/intro_menu.asm
+++ b/engine/intro_menu.asm
@@ -971,7 +971,7 @@
 	ld hl, vTiles0
 	call Request2bpp
 
-	ld hl, Sprites
+	ld hl, Sprite01
 	ld de, .sprites
 	ld a, [de]
 	inc de
@@ -980,19 +980,19 @@
 .loop
 	ld a, [de]
 	inc de
-	ld [hli], a
+	ld [hli], a ; y
 	ld a, [de]
 	inc de
-	ld [hli], a
+	ld [hli], a ; x
 	ld a, [de]
 	inc de
-	ld [hli], a
+	ld [hli], a ; tile id
 
-	ld b, 0
+	ld b, PAL_OW_RED
 	ld a, [wPlayerGender]
 	bit 0, a
 	jr z, .male
-	ld b, 1
+	ld b, PAL_OW_BLUE
 .male
 	ld a, b
 
@@ -1004,6 +1004,7 @@
 
 .sprites ; 61fe
 	db 4
+	; y pxl, x pxl, tile offset
 	db  9 * 8 + 4,  9 * 8, 0
 	db  9 * 8 + 4, 10 * 8, 1
 	db 10 * 8 + 4,  9 * 8, 2
--- a/engine/map_objects.asm
+++ b/engine/map_objects.asm
@@ -2793,6 +2793,7 @@
 	db SPRITEMOVEDATA_STANDING_LEFT
 	db SPRITEMOVEDATA_STANDING_RIGHT
 ; 5920
+
 _UpdateSprites:: ; 5920
 	ld a, [VramState]
 	bit 0, a
@@ -2814,7 +2815,7 @@
 	bit 1, a
 	ld b, LOW(SpritesEnd)
 	jr z, .ok
-	ld b, 28 * 4
+	ld b, 28 * SPRITEOAMSTRUCT_LENGTH
 .ok
 	ld a, [hUsedSpriteIndex]
 	cp b
@@ -2821,11 +2822,11 @@
 	ret nc
 	ld l, a
 	ld h, HIGH(Sprites)
-	ld de, 4
+	ld de, SPRITEOAMSTRUCT_LENGTH
 	ld a, b
-	ld c, SCREEN_HEIGHT_PX + 16
+	ld c, SCREEN_HEIGHT_PX + 2 * TILE_WIDTH
 .loop
-	ld [hl], c
+	ld [hl], c ; y
 	add hl, de
 	cp l
 	jr nz, .loop
@@ -3042,12 +3043,12 @@
 	ld a, [hFFC0]
 	add [hl]
 	inc hl
-	ld [bc], a
+	ld [bc], a ; y
 	inc c
 	ld a, [hFFBF]
 	add [hl]
 	inc hl
-	ld [bc], a
+	ld [bc], a ; x
 	inc c
 	ld e, [hl]
 	inc hl
@@ -3058,7 +3059,7 @@
 .nope1
 	add [hl]
 	inc hl
-	ld [bc], a
+	ld [bc], a ; tile id
 	inc c
 	ld a, e
 	bit 1, a
@@ -3068,7 +3069,7 @@
 .nope2
 	and %11110000
 	or d
-	ld [bc], a
+	ld [bc], a ; attributes
 	inc c
 	ld a, [hUsedSpriteTile]
 	dec a
--- a/engine/mystery_gift.asm
+++ b/engine/mystery_gift.asm
@@ -1456,26 +1456,26 @@
 	jr asm_105726
 
 Function1056eb: ; 1056eb (41:56eb)
-	ld c, $10
-.asm_1056ed
-	ld hl, Sprites
-	ld b, $8
-.asm_1056f2
+	ld c, 16
+.loop
+	ld hl, Sprite01YCoord
+	ld b, 8
+.dec_y_loop
 	dec [hl]
-rept 4
+rept SPRITEOAMSTRUCT_LENGTH
 	inc hl
 endr
 	dec b
-	jr nz, .asm_1056f2
-	ld hl, Sprites + $20
-	ld b, $8
-.asm_1056ff
+	jr nz, .dec_y_loop
+	ld hl, Sprite09YCoord
+	ld b, 8
+.inc_y_loop
 	inc [hl]
-rept 4
+rept SPRITEOAMSTRUCT_LENGTH
 	inc hl
 endr
 	dec b
-	jr nz, .asm_1056ff
+	jr nz, .inc_y_loop
 	dec c
 	ret z
 	push bc
@@ -1482,7 +1482,7 @@
 	ld c, 4
 	call DelayFrames
 	pop bc
-	jr .asm_1056ed
+	jr .loop
 
 Function105712: ; 105712 (41:5712)
 	call Function105777
@@ -1580,7 +1580,7 @@
 	ld a, BANK(MysteryGiftJP_GFX)
 	lb bc, 4, 0
 	call FarCopyBytes
-	ld hl, MysteryGiftJP_GFX + $400
+	ld hl, MysteryGiftJP_GFX + $40 tiles
 	ld de, vTiles0 tile $00
 	ld a, BANK(MysteryGiftJP_GFX)
 	ld bc, $80
@@ -1656,9 +1656,9 @@
 	ld [hl], $3c
 	hlcoord 17, 15
 	ld [hl], $3e
-	ld de, Sprites
+	ld de, Sprite01
 	ld hl, .OAM_data
-	ld bc, $40
+	ld bc, 16 * SPRITEOAMSTRUCT_LENGTH
 	call CopyBytes
 	call EnableLCD
 	call WaitBGMap
--- a/engine/pokedex.asm
+++ b/engine/pokedex.asm
@@ -2050,7 +2050,7 @@
 	dsprite  5,  0, 19, -2, $32, 7 | X_FLIP | Y_FLIP
 	dsprite  5,  0, 20, -2, $31, 7 | X_FLIP | Y_FLIP
 	dsprite  4,  0, 20, -2, $30, 7 | X_FLIP | Y_FLIP
-	db $ff
+	db -1
 
 .CursorAtTopOAM: ; 411c8
 ; OAM data for when the cursor is at the top of the list. The tiles at the top
@@ -2079,7 +2079,7 @@
 	dsprite  5,  0, 19, -2, $32, 7 | X_FLIP | Y_FLIP
 	dsprite  5,  0, 20, -2, $31, 7 | X_FLIP | Y_FLIP
 	dsprite  4,  0, 20, -2, $30, 7 | X_FLIP | Y_FLIP
-	db $ff
+	db -1
 
 Pokedex_PutNewModeABCModeCursorOAM: ; 41229 (10:5229)
 	ld hl, .CursorOAM
@@ -2107,7 +2107,7 @@
 	dsprite  5,  3, 18,  0, $32, 7 | X_FLIP | Y_FLIP
 	dsprite  5,  3, 19,  0, $31, 7 | X_FLIP | Y_FLIP
 	dsprite  4,  3, 19,  0, $30, 7 | X_FLIP | Y_FLIP
-	db $ff
+	db -1
 
 Pokedex_UpdateSearchResultsCursorOAM: ; 41281 (10:5281)
 	ld a, [wCurrentDexMode]
@@ -2142,28 +2142,28 @@
 	dsprite  5,  3, 19, -2, $32, 7 | X_FLIP | Y_FLIP
 	dsprite  5,  3, 20, -2, $31, 7 | X_FLIP | Y_FLIP
 	dsprite  4,  3, 20, -2, $30, 7 | X_FLIP | Y_FLIP
-	db $ff
+	db -1
 
 Pokedex_LoadCursorOAM: ; 412f1 (10:52f1)
-	ld de, Sprites
+	ld de, Sprite01
 .loop
 	ld a, [hl]
-	cp $ff
+	cp -1
 	ret z
 	ld a, [wDexListingCursor]
 	and $7
 	swap a
-	add [hl]
+	add [hl] ; y
 	inc hl
 	ld [de], a
 	inc de
-	ld a, [hli]
+	ld a, [hli] ; x
 	ld [de], a
 	inc de
-	ld a, [hli]
+	ld a, [hli] ; tile id
 	ld [de], a
 	inc de
-	ld a, [hli]
+	ld a, [hli] ; attributes
 	ld [de], a
 	inc de
 	jr .loop
--- a/engine/pokedex_2.asm
+++ b/engine/pokedex_2.asm
@@ -41,15 +41,15 @@
 DoDexSearchSlowpokeFrame: ; 44207
 	ld a, [wDexSearchSlowpokeFrame]
 	ld hl, .SlowpokeSpriteData
-	ld de, Sprites
+	ld de, Sprite01
 .loop
 	ld a, [hli]
 	cp -1
 	ret z
-	ld [de], a
+	ld [de], a ; y
 	inc de
 	ld a, [hli]
-	ld [de], a
+	ld [de], a ; x
 	inc de
 	ld a, [wDexSearchSlowpokeFrame]
 	ld b, a
@@ -57,10 +57,10 @@
 	add b
 	add [hl]
 	inc hl
-	ld [de], a
+	ld [de], a ; tile id
 	inc de
 	ld a, [hli]
-	ld [de], a
+	ld [de], a ; attributes
 	inc de
 	jr .loop
 
--- a/engine/pokegear.asm
+++ b/engine/pokegear.asm
@@ -2596,7 +2596,7 @@
 	ld e, a
 	farcall FindNest ; load nest landmarks into TileMap[0,0]
 	decoord 0, 0
-	ld hl, Sprites
+	ld hl, Sprite01
 .nestloop
 	ld a, [de]
 	and a
@@ -2609,14 +2609,14 @@
 	; load into OAM
 	ld a, d
 	sub 4
-	ld [hli], a
+	ld [hli], a ; y
 	ld a, e
 	sub 4
-	ld [hli], a
-	ld a, $7f ; nest icon in this context
-	ld [hli], a
+	ld [hli], a ; x
+	ld a, $7f ; nest icon
+	ld [hli], a ; tile id
 	xor a
-	ld [hli], a
+	ld [hli], a ; attributes
 	; next
 	pop de
 	inc de
@@ -2640,37 +2640,37 @@
 	ld c, e
 	ld b, d
 	ld de, .PlayerOAM
-	ld hl, Sprites
+	ld hl, Sprite01
 .ShowPlayerLoop:
 	ld a, [de]
 	cp $80
 	jr z, .clear_oam
 	add b
-	ld [hli], a
+	ld [hli], a ; y
 	inc de
 	ld a, [de]
 	add c
-	ld [hli], a
+	ld [hli], a ; x
 	inc de
 	ld a, [de]
 	add $78 ; where the player's sprite is loaded
-	ld [hli], a
+	ld [hli], a ; tile id
 	inc de
 	push bc
-	ld c, 0 ; RED
+	ld c, PAL_OW_RED
 	ld a, [wPlayerGender]
 	bit 0, a
-	jr z, .got_gender
-	inc c   ; BLUE
-.got_gender
+	jr z, .male
+	inc c ; PAL_OW_BLUE
+.male
 	ld a, c
-	ld [hli], a
+	ld [hli], a ; attributes
 	pop bc
 	jr .ShowPlayerLoop
 
 .clear_oam
-	ld hl, Sprites + 4 * 4
-	ld bc, SpritesEnd - (Sprites + 4 * 4)
+	ld hl, Sprite05
+	ld bc, SpritesEnd - Sprite05
 	xor a
 	call ByteFill
 	ret
@@ -2678,10 +2678,11 @@
 ; 91e9c
 
 .PlayerOAM: ; 91e9c
-	db -1 * 8, -1 * 8,  0 ; top left
-	db -1 * 8,  0 * 8,  1 ; top right
-	db  0 * 8, -1 * 8,  2 ; bottom left
-	db  0 * 8,  0 * 8,  3 ; bottom right
+	; y pxl, x pxl, tile offset
+	db -1 * 8, -1 * 8, 0 ; top left
+	db -1 * 8,  0 * 8, 1 ; top right
+	db  0 * 8, -1 * 8, 2 ; bottom left
+	db  0 * 8,  0 * 8, 3 ; bottom right
 	db $80 ; terminator
 ; 91ea9
 
--- a/engine/routines/loadpushoam.asm
+++ b/engine/routines/loadpushoam.asm
@@ -13,7 +13,7 @@
 .PushOAM: ; 403f
 	ld a, HIGH(Sprites)
 	ld [rDMA], a
-	ld a, (SpritesEnd - Sprites) / 4 ; 40
+	ld a, NUM_SPRITE_OAM_STRUCTS
 .pushoam_loop
 	dec a
 	jr nz, .pushoam_loop
--- a/engine/routines/switchpartymons.asm
+++ b/engine/routines/switchpartymons.asm
@@ -25,13 +25,13 @@
 	ld a, " "
 	call ByteFill
 	pop af
-	ld hl, Sprites
-	ld bc, $10
+	ld hl, Sprite01
+	ld bc, 4 * SPRITEOAMSTRUCT_LENGTH
 	call AddNTimes
-	ld de, $4
-	ld c, $4
+	ld de, SPRITEOAMSTRUCT_LENGTH
+	ld c, 4
 .gfx_loop
-	ld [hl], $a0
+	ld [hl], SCREEN_WIDTH_PX ; y (off-screen)
 	add hl, de
 	dec c
 	jr nz, .gfx_loop
--- a/engine/slot_machine.asm
+++ b/engine/slot_machine.asm
@@ -260,15 +260,15 @@
 	inc [hl]
 	and $7
 	ret nz
-	ld hl, Sprites + 16 * 4 + 2
-	ld c, 40 - 16
+	ld hl, Sprite17TileID
+	ld c, NUM_SPRITE_OAM_STRUCTS - 16
 .loop
 	ld a, [hl]
-	xor $20
-	ld [hli], a
+	xor %00100000
+	ld [hli], a ; tile id
+rept SPRITEOAMSTRUCT_LENGTH +- 1
 	inc hl
-	inc hl
-	inc hl
+endr
 	dec c
 	jr nz, .loop
 	ret
@@ -670,7 +670,7 @@
 	ld bc, wReel1
 	ld hl, REEL_OAM_ADDR
 	add hl, bc
-	ld de, Sprites + 16 * 4
+	ld de, Sprite17
 	ld [hl], e
 	inc hl
 	ld [hl], d
@@ -688,7 +688,7 @@
 	ld bc, wReel2
 	ld hl, REEL_OAM_ADDR
 	add hl, bc
-	ld de, Sprites + 24 * 4
+	ld de, Sprite25
 	ld [hl], e
 	inc hl
 	ld [hl], d
@@ -706,7 +706,7 @@
 	ld bc, wReel3
 	ld hl, REEL_OAM_ADDR
 	add hl, bc
-	ld de, Sprites + 32 * 4
+	ld de, Sprite33
 	ld [hl], e
 	inc hl
 	ld [hl], d
@@ -821,34 +821,34 @@
 	ld l, a
 .loop
 	ld a, [wCurrReelYCoord]
-	ld [hli], a
+	ld [hli], a ; y
 	ld a, [wCurrReelXCoord]
-	ld [hli], a
+	ld [hli], a ; x
 	ld a, [de]
-	ld [hli], a
+	ld [hli], a ; tile id
 	srl a
 	srl a
-	set 7, a
-	ld [hli], a
+	set OAM_PRIORITY, a
+	ld [hli], a ; attributes
 
 	ld a, [wCurrReelYCoord]
-	ld [hli], a
+	ld [hli], a ; y
 	ld a, [wCurrReelXCoord]
-	add 1 * 8
-	ld [hli], a
+	add 1 * TILE_WIDTH
+	ld [hli], a ; x
 	ld a, [de]
 	inc a
 	inc a
-	ld [hli], a
+	ld [hli], a ; tile id
 	srl a
 	srl a
-	set 7, a
-	ld [hli], a
+	set OAM_PRIORITY, a
+	ld [hli], a ; attributes
 	inc de
 	ld a, [wCurrReelYCoord]
-	sub 2 * 8
+	sub 2 * TILE_WIDTH
 	ld [wCurrReelYCoord], a
-	cp 2 * 8
+	cp 2 * TILE_WIDTH
 	jr nz, .loop
 	ret
 
--- a/engine/sprites.asm
+++ b/engine/sprites.asm
@@ -100,11 +100,11 @@
 
 	ld a, [wCurrSpriteOAMAddr]
 	ld l, a
-	ld h, HIGH(Sprites + 16 * 4)
+	ld h, HIGH(Sprite17)
 
 .loop2 ; Clear (Sprites + [wCurrSpriteOAMAddr] --> Sprites + $40)
 	ld a, l
-	cp LOW(Sprites + 16 * 4)
+	cp LOW(Sprite17)
 	jr nc, .done
 	xor a
 	ld [hli], a
@@ -650,8 +650,8 @@
 ; 8e7c6
 
 .AnimateFrame: ; 8e7c6
-	ld hl, Sprites
-	ld c, $8
+	ld hl, Sprite01
+	ld c, 8 ; number of animated circles
 .anim_loop
 	ld a, c
 	and a
@@ -669,8 +669,8 @@
 	call Sprites_Sine
 	pop hl
 	pop de
-	add 13 * 8
-	ld [hli], a
+	add 13 * TILE_WIDTH
+	ld [hli], a ; y
 
 	pop af
 	push de
@@ -678,13 +678,13 @@
 	call Sprites_Cosine
 	pop hl
 	pop de
-	add 10 * 8 + 4
-	ld [hli], a
+	add 10 * TILE_WIDTH + 4
+	ld [hli], a ; x
 
 	ld a, $0
-	ld [hli], a
+	ld [hli], a ; tile id
 	ld a, PAL_BATTLE_OB_BLUE
-	ld [hli], a
+	ld [hli], a ; attributes
 	jr .anim_loop
 ; 8e7f4
 
--- a/engine/title.asm
+++ b/engine/title.asm
@@ -323,7 +323,7 @@
 ; 10ef06
 
 InitializeBackground: ; 10ef06
-	ld hl, Sprites
+	ld hl, Sprite01
 	ld d, -$22
 	ld e, $0
 	ld c, 5
@@ -344,17 +344,17 @@
 	ld b, $40
 .loop2
 	ld a, d
-	ld [hli], a
+	ld [hli], a ; y
 	ld a, b
-	ld [hli], a
+	ld [hli], a ; x
 	add $8
 	ld b, a
 	ld a, e
-	ld [hli], a
+	ld [hli], a ; tile id
 	inc e
 	inc e
-	ld a, $80
-	ld [hli], a
+	ld a, 0 | BEHIND_BG
+	ld [hli], a ; attributes
 	dec c
 	jr nz, .loop2
 	ret
@@ -366,9 +366,9 @@
 
 ; Stop at y=6
 ; y is really from the bottom of the sprite, which is two tiles high
-	ld hl, Sprites
+	ld hl, Sprite01YCoord
 	ld a, [hl]
-	cp 6 + $10
+	cp 6 + 2 * TILE_WIDTH
 	ret z
 
 ; Move all 30 parts of the crystal down by 2
@@ -376,10 +376,10 @@
 .loop
 	ld a, [hl]
 	add 2
-	ld [hli], a
+	ld [hli], a ; y
+rept SPRITEOAMSTRUCT_LENGTH +- 1
 	inc hl
-	inc hl
-	inc hl
+endr
 	dec c
 	jr nz, .loop
 
--- a/engine/trainer_card.asm
+++ b/engine/trainer_card.asm
@@ -470,8 +470,8 @@
 	ld d, a
 	ld a, [de]
 	ld c, a
-	ld de, Sprites
-	ld b, 8
+	ld de, Sprite01
+	ld b, NUM_JOHTO_BADGES
 .loop
 	srl c
 	push bc
@@ -512,27 +512,27 @@
 	ld hl, .facing2
 .loop2
 	ld a, [hli]
-	cp $ff
+	cp -1
 	ret z
 	add b
-	ld [de], a
+	ld [de], a ; y
 	inc de
 
 	ld a, [hli]
 	add c
-	ld [de], a
+	ld [de], a ; x
 	inc de
 
 	ld a, [wcf65]
 	and $7f
 	add [hl]
-	ld [de], a
+	ld [de], a ; tile id
 	inc hl
 	inc de
 
 	ld a, [wcf66]
 	add [hl]
-	ld [de], a
+	ld [de], a ; attributes
 	inc hl
 	inc de
 	jr .loop2
@@ -540,18 +540,17 @@
 ; 254a7 (9:54a7)
 
 .facing1 ; 254a7
-	; y, x, tile, OAM attributes
-	db 0, 0, 0, 0
-	db 0, 8, 1, 0
-	db 8, 0, 2, 0
-	db 8, 8, 3, 0
+	dsprite  0,  0,  0,  0, $00, 0
+	dsprite  0,  0,  1,  0, $01, 0
+	dsprite  1,  0,  0,  0, $02, 0
+	dsprite  1,  0,  1,  0, $03, 0
 	db -1
 
 .facing2 ; 254b8
-	db 0, 0, 1, X_FLIP
-	db 0, 8, 0, X_FLIP
-	db 8, 0, 3, X_FLIP
-	db 8, 8, 2, X_FLIP
+	dsprite  0,  0,  0,  0, $01, 0 | X_FLIP
+	dsprite  0,  0,  1,  0, $00, 0 | X_FLIP
+	dsprite  1,  0,  0,  0, $03, 0 | X_FLIP
+	dsprite  1,  0,  1,  0, $02, 0 | X_FLIP
 	db -1
 
 TrainerCard_JohtoBadgesOAM: ; 254c9
--- a/engine/unown_puzzle.asm
+++ b/engine/unown_puzzle.asm
@@ -549,25 +549,25 @@
 	ld hl, .OAM_NotHoldingPiece
 
 .load
-	ld de, Sprites
+	ld de, Sprite01
 .loop
 	ld a, [hli]
 	cp -1
 	ret z
 	add b
-	ld [de], a
+	ld [de], a ; y
 	inc de
 	ld a, [hli]
 	add c
-	ld [de], a
+	ld [de], a ; x
 	inc de
 	ld a, [wd002]
 	add [hl]
-	ld [de], a
+	ld [de], a ; tile id
 	inc hl
 	inc de
 	ld a, [hli]
-	ld [de], a
+	ld [de], a ; attributes
 	inc de
 	jr .loop
 ; e150f
--- a/engine/unused_title.asm
+++ b/engine/unused_title.asm
@@ -32,7 +32,7 @@
 
 	ld hl, UnusedTitleBG_Tilemap
 	debgcoord 0, 0
-	ld bc, 32 * 32
+	ld bc, BG_MAP_WIDTH * BG_MAP_HEIGHT
 .copy
 	ld a, 0
 	ld [rVBK], a
@@ -49,8 +49,8 @@
 	jr nz, .copy
 
 	ld hl, UnusedTitleFG_OAM
-	ld de, Sprites
-	ld bc, $a0
+	ld de, Sprite01
+	ld bc, SPRITEOAMSTRUCT_LENGTH * NUM_SPRITE_OAM_STRUCTS
 	call CopyBytes
 
 	call EnableLCD
--- a/home.asm
+++ b/home.asm
@@ -182,12 +182,12 @@
 
 HideSprites:: ; 3016
 ; Set all OAM y-positions to 160 to hide them offscreen
-	ld hl, Sprites
-	ld de, 4 ; length of an OAM struct
-	ld b, (SpritesEnd - Sprites) / 4 ; number of OAM structs
-	ld a, 160 ; y
+	ld hl, Sprite01YCoord
+	ld de, SPRITEOAMSTRUCT_LENGTH
+	ld b, NUM_SPRITE_OAM_STRUCTS
+	ld a, SCREEN_WIDTH_PX
 .loop
-	ld [hl], a
+	ld [hl], a ; y
 	add hl, de
 	dec b
 	jr nz, .loop
--- a/home/audio.asm
+++ b/home/audio.asm
@@ -506,16 +506,16 @@
 ; Places a BCD number at the
 ; upper center of the screen.
 ; Unreferenced.
-	ld a, 4 * 8
-	ld [Sprites + 38 * 4], a
-	ld [Sprites + 39 * 4], a
-	ld a, 10 * 8
-	ld [Sprites + 38 * 4 + 1], a
-	ld a, 11 * 8
-	ld [Sprites + 39 * 4 + 1], a
+	ld a, 4 * TILE_WIDTH
+	ld [Sprite39YCoord], a
+	ld [Sprite40YCoord], a
+	ld a, 10 * TILE_WIDTH
+	ld [Sprite39XCoord], a
+	ld a, 11 * TILE_WIDTH
+	ld [Sprite40XCoord], a
 	xor a
-	ld [Sprites + 38 * 4 + 3], a
-	ld [Sprites + 39 * 4 + 3], a
+	ld [Sprite39Attributes], a
+	ld [Sprite40Attributes], a
 	ld a, [wc296]
 	cp 100
 	jr nc, .max
@@ -525,17 +525,17 @@
 	swap a
 	and $f
 	add "0"
-	ld [Sprites + 38 * 4 + 2], a
+	ld [Sprite39TileID], a
 	ld a, b
 	and $f
 	add "0"
-	ld [Sprites + 39 * 4 + 2], a
+	ld [Sprite40TileID], a
 	ret
 
 .max
 	ld a, "9"
-	ld [Sprites + 38 * 4 + 2], a
-	ld [Sprites + 39 * 4 + 2], a
+	ld [Sprite39TileID], a
+	ld [Sprite40TileID], a
 	ret
 ; 3dde
 
--- a/macros/wram.asm
+++ b/macros/wram.asm
@@ -339,6 +339,19 @@
 	ds 2
 ENDM
 
+sprite_oam_struct: MACRO
+\1YCoord::     db
+\1XCoord::     db
+\1TileID::     db
+\1Attributes:: db
+; bit 7: priority
+; bit 6: y flip
+; bit 5: x flip
+; bit 4: pal # (non-cgb)
+; bit 3: vram bank (cgb only)
+; bit 2-0: pal # (cgb only)
+ENDM
+
 sprite_anim_struct: MACRO
 \1Index::          db
 \1FramesetID::     db
--- a/main.asm
+++ b/main.asm
@@ -400,7 +400,7 @@
 
 INCLUDE "engine/events/bug_contest/display_stats.asm"
 INCLUDE "engine/battle_anims/anim_commands.asm"
-INCLUDE "engine/battle_anims/engine.asm"
+INCLUDE "engine/battle_anims/core.asm"
 INCLUDE "data/battle_anims/objects.asm"
 INCLUDE "engine/battle_anims/functions.asm"
 INCLUDE "engine/battle_anims/helpers.asm"
--- a/mobile/mobile_22.asm
+++ b/mobile/mobile_22.asm
@@ -572,7 +572,7 @@
 ; Clears the Sprites array
 	push af
 	ld hl, Sprites
-	ld d, $10 * 6
+	ld d, 24 * SPRITEOAMSTRUCT_LENGTH
 	xor a
 .loop
 	ld [hli], a
@@ -1924,7 +1924,7 @@
 	ld a, [hli]
 	ld h, [hl]
 	ld l, a
-	ld de, Sprites
+	ld de, Sprite01
 .asm_89bb4
 	ld a, [hli]
 	cp $ff
@@ -1934,19 +1934,19 @@
 .asm_89bbb
 	push hl
 	ld a, [hli]
-	ld [de], a
+	ld [de], a ; y
 	inc de
 	ld a, [hli]
 	add b
-	ld [de], a
+	ld [de], a ; x
 	inc de
-	ld a, $8
+	ld a, $08
 	add b
 	ld b, a
-	ld a, [hli]
+	ld a, [hli] ; tile id
 	ld [de], a
 	inc de
-	ld a, [hli]
+	ld a, [hli] ; attributes
 	ld [de], a
 	inc de
 	pop hl
@@ -2014,10 +2014,10 @@
 	pop de
 	ret
 .asm_89c4f
-	ld hl, Sprites
+	ld hl, Sprite01
 	push de
 	ld a, b
-	ld [hli], a
+	ld [hli], a ; y
 	ld d, $8
 	ld a, e
 	and a
@@ -2029,11 +2029,11 @@
 	jr nz, .asm_89c5c
 .asm_89c60
 	pop de
-	ld [hli], a
+	ld [hli], a ; x
 	ld a, d
-	ld [hli], a
+	ld [hli], a ; tile id
 	xor a
-	ld [hli], a
+	ld [hli], a ; attributes
 	ret
 
 Function89c67: ; 89c67 (22:5c67)
@@ -2124,7 +2124,7 @@
 	ld c, a
 	ld e, $2
 	ld a, $2
-	ld hl, Sprites
+	ld hl, Sprite01
 .asm_89cee
 	push af
 	push bc
@@ -2131,13 +2131,13 @@
 	ld d, $4
 .asm_89cf2
 	ld a, b
-	ld [hli], a
+	ld [hli], a ; y
 	ld a, c
-	ld [hli], a
+	ld [hli], a ; x
 	ld a, e
-	ld [hli], a
+	ld [hli], a ; tile id
 	ld a, $1
-	ld [hli], a
+	ld [hli], a ; attributes
 	ld a, $8
 	add c
 	ld c, a
@@ -3301,7 +3301,7 @@
 	ld [hli], a
 	ld hl, Sprites
 	xor a
-	ld bc, $20
+	ld bc, 8 * SPRITEOAMSTRUCT_LENGTH
 	call ByteFill
 	ret
 
--- a/mobile/mobile_45_sprite_engine.asm
+++ b/mobile/mobile_45_sprite_engine.asm
@@ -22,8 +22,8 @@
 	xor a
 	ld [wc305], a
 	ld a, $a0
-	ld hl, Sprites + 31 * 4
-	ld bc, 8 * 4
+	ld hl, Sprite32
+	ld bc, 8 * SPRITEOAMSTRUCT_LENGTH
 	call ByteFill
 	ret
 
@@ -34,8 +34,8 @@
 	and a
 	ret z
 	ld a, $a0
-	ld hl, Sprites + 31 * 4
-	ld bc, 8 * 4
+	ld hl, Sprite32
+	ld bc, 8 * SPRITEOAMSTRUCT_LENGTH
 	call ByteFill
 	call Function115e22
 	ld a, [wc309]
@@ -50,7 +50,7 @@
 	ld d, a
 	push de
 	pop hl
-	ld de, Sprites + 31 * 4
+	ld de, Sprite32
 	ld a, [wc307]
 	ld c, a
 	ld a, [wc308]
@@ -60,17 +60,17 @@
 	push af
 	ld a, [hli]
 	add b
-	ld [de], a
+	ld [de], a ; y
 	inc de
 	ld a, [hli]
 	add c
-	ld [de], a
+	ld [de], a ; x
 	inc de
 	ld a, [hli]
-	ld [de], a
+	ld [de], a ; tile id
 	inc de
 	ld a, [hli]
-	ld [de], a
+	ld [de], a ; attributes
 	inc de
 	pop af
 	dec a
@@ -361,7 +361,7 @@
 	jr c, .asm_1161b4
 	ld a, $a0
 	ld hl, Sprites
-	ld bc, $0064
+	ld bc, 25 * SPRITEOAMSTRUCT_LENGTH
 	call ByteFill
 
 .asm_1161b4
@@ -586,22 +586,22 @@
 	ld e, a
 	ld a, [hli]
 	sub e
-	ld de, Sprites + $24
+	ld de, Sprite10
 .asm_116321
 	push af
 	ld a, [hli]
 	add b
-	ld [de], a
+	ld [de], a ; y
 	inc de
 	ld a, [hli]
 	add c
-	ld [de], a
+	ld [de], a ; x
 	inc de
 	ld a, [hli]
-	ld [de], a
+	ld [de], a ; tile id
 	inc de
 	ld a, [hli]
-	ld [de], a
+	ld [de], a ; attributes
 	inc de
 	pop af
 	dec a
@@ -627,22 +627,22 @@
 	ld e, a
 	ld a, [hli]
 	sub e
-	ld de, Sprites
+	ld de, Sprite01
 .asm_11635a
 	push af
 	ld a, [hli]
 	add b
-	ld [de], a
+	ld [de], a ; y
 	inc de
 	ld a, [hli]
 	add c
-	ld [de], a
+	ld [de], a ; x
 	inc de
 	ld a, [hli]
-	ld [de], a
+	ld [de], a ; tile id
 	inc de
 	ld a, [hli]
-	ld [de], a
+	ld [de], a ; attributes
 	inc de
 	pop af
 	dec a
@@ -669,7 +669,7 @@
 	ld [rSVBK], a
 	ld a, $a0
 	ld hl, Sprites
-	ld bc, 16 * 4
+	ld bc, 16 * SPRITEOAMSTRUCT_LENGTH
 	call ByteFill
 	ld a, $90
 	ld [hWY], a
@@ -697,7 +697,7 @@
 	ld [rSVBK], a
 	ld a, $a0
 	ld hl, Sprites
-	ld bc, 16 * 4
+	ld bc, 16 * SPRITEOAMSTRUCT_LENGTH
 	call ByteFill
 	call DelayFrame
 	farcall Function14146
--- a/mobile/mobile_46.asm
+++ b/mobile/mobile_46.asm
@@ -6930,7 +6930,7 @@
 	db $39 ; 13
 
 Function11b397: ; 11b397
-	ld de, Sprites
+	ld de, Sprite01
 .loop
 	ld a, [hl]
 	cp $ff
@@ -6939,20 +6939,20 @@
 	and $7
 	swap a
 	add [hl]
-	inc hl ; 1
-	ld [de], a
+	inc hl
+	ld [de], a ; y
 	inc de
 
-	ld a, [hli] ; 2
-	ld [de], a
+	ld a, [hli]
+	ld [de], a ; x
 	inc de
 
 	ld a, [bc]
 	inc bc
-	ld [de], a
+	ld [de], a ; tile id
 	inc de
-	ld a, $5 ; OBPal 5
-	ld [de], a
+	ld a, $5
+	ld [de], a ; attributes
 	inc de
 	jr .loop
 ; 11b3b6
@@ -6989,7 +6989,7 @@
 ; 11b3d9
 
 Function11b3d9: ; 11b3d9
-	ld de, Sprites + 28 * 4
+	ld de, Sprite29
 	push de
 	ld a, [wc7d2]
 	dec a
--- a/wram.asm
+++ b/wram.asm
@@ -303,20 +303,46 @@
 SECTION "Sprites", WRAM0
 
 Sprites:: ; c400
-; 4 bytes per sprite
-; 40 sprites
-; struct:
-;	y (px)
-;	x (px)
-;	tile id
-;	attributes:
-;		bit 7: priority
-;		bit 6: y flip
-;		bit 5: x flip
-;		bit 4: pal # (non-cgb)
-;		bit 3: vram bank (cgb only)
-;		bit 2-0: pal # (cgb only)
-	ds 4 * 40
+Sprite01:: sprite_oam_struct Sprite01
+Sprite02:: sprite_oam_struct Sprite02
+Sprite03:: sprite_oam_struct Sprite03
+Sprite04:: sprite_oam_struct Sprite04
+Sprite05:: sprite_oam_struct Sprite05
+Sprite06:: sprite_oam_struct Sprite06
+Sprite07:: sprite_oam_struct Sprite07
+Sprite08:: sprite_oam_struct Sprite08
+Sprite09:: sprite_oam_struct Sprite09
+Sprite10:: sprite_oam_struct Sprite10
+Sprite11:: sprite_oam_struct Sprite11
+Sprite12:: sprite_oam_struct Sprite12
+Sprite13:: sprite_oam_struct Sprite13
+Sprite14:: sprite_oam_struct Sprite14
+Sprite15:: sprite_oam_struct Sprite15
+Sprite16:: sprite_oam_struct Sprite16
+Sprite17:: sprite_oam_struct Sprite17
+Sprite18:: sprite_oam_struct Sprite18
+Sprite19:: sprite_oam_struct Sprite19
+Sprite20:: sprite_oam_struct Sprite20
+Sprite21:: sprite_oam_struct Sprite21
+Sprite22:: sprite_oam_struct Sprite22
+Sprite23:: sprite_oam_struct Sprite23
+Sprite24:: sprite_oam_struct Sprite24
+Sprite25:: sprite_oam_struct Sprite25
+Sprite26:: sprite_oam_struct Sprite26
+Sprite27:: sprite_oam_struct Sprite27
+Sprite28:: sprite_oam_struct Sprite28
+Sprite29:: sprite_oam_struct Sprite29
+Sprite30:: sprite_oam_struct Sprite30
+Sprite31:: sprite_oam_struct Sprite31
+Sprite32:: sprite_oam_struct Sprite32
+Sprite33:: sprite_oam_struct Sprite33
+Sprite34:: sprite_oam_struct Sprite34
+Sprite35:: sprite_oam_struct Sprite35
+Sprite36:: sprite_oam_struct Sprite36
+Sprite37:: sprite_oam_struct Sprite37
+Sprite38:: sprite_oam_struct Sprite38
+Sprite39:: sprite_oam_struct Sprite39
+Sprite40:: sprite_oam_struct Sprite40
 SpritesEnd::