ref: 48db6daef9741aafaf0ff339c01f9e7920089f8e
parent: 496502b3dc16318cf59dd41d8462330f66cd19d6
author: yenatch <[email protected]>
date: Sun Dec 22 15:47:57 EST 2013
overworld object struct constants
--- a/constants/map_constants.asm
+++ b/constants/map_constants.asm
@@ -1767,3 +1767,19 @@
GATE EQU 6
DUNGEON EQU 7
+; object struct
+OBJECT_SPRITE EQU $2
+OBJECT_FLAGS EQU $5
+OBJECT_PALETTE EQU $6
+OBJECT_FACING EQU $d
+OBJECT_STANDING_TILE EQU $e
+OBJECT_NEXT_TILE EQU $f
+OBJECT_MAP_X EQU $10
+OBJECT_MAP_Y EQU $11
+OBJECT_NEXT_MAP_X EQU $12
+OBJECT_NEXT_MAP_Y EQU $13
+OBJECT_SPRITE_X EQU $17
+OBJECT_SPRITE_Y EQU $18
+OBJECT_SPRITE_X_OFFSET EQU $19
+OBJECT_SPRITE_Y_OFFSET EQU $1a
+
--- a/main.asm
+++ b/main.asm
@@ -3421,20 +3421,23 @@
Function59a4: ; 59a4
xor a
ld hl, $c2eb
- ld bc, $000d
+ ld bc, 13
call ByteFill
ld d, 0
- ld bc, $d4d6
+ ld bc, ObjectStructs
ld hl, $c2eb
.asm_59b6
push hl
call Function1af1
jr z, .asm_59d9
- ld hl, $000d
+
+ ld hl, OBJECT_FACING
add hl, bc
ld a, [hl]
- cp $ff
+ cp -1
jr z, .asm_59d9
+
+; Define the sprite priority.
ld e, $10
ld hl, $0005
add hl, bc
@@ -3447,7 +3450,7 @@
jr .asm_59e2
.asm_59d9
- ld hl, $0028
+ ld hl, ObjectStruct2 - ObjectStruct1
add hl, bc
ld b, h
ld c, l
@@ -3455,7 +3458,7 @@
jr .asm_59ec
.asm_59e2
- ld hl, $0028
+ ld hl, ObjectStruct2 - ObjectStruct1
add hl, bc
ld b, h
ld c, l
@@ -3474,13 +3477,14 @@
Function59f3: ; 59f3
ld hl, $c2eb
-.asm_59f6
+.next
ld a, [hli]
ld d, a
and $f0
ret z
cp c
- jr nz, .asm_59f6
+ jr nz, .next
+
push bc
push hl
ld a, d
@@ -3489,11 +3493,11 @@
call Function5a0d
pop hl
pop bc
- jr .asm_59f6
+ jr .next
; 5a0d
Function5a0d: ; 5a0d
- ld hl, $0002
+ ld hl, OBJECT_SPRITE
add hl, bc
ld a, [hl]
and $7f
@@ -3518,7 +3522,7 @@
or $10
.asm_5a2e
- ld hl, $0006
+ ld hl, OBJECT_PALETTE
add hl, bc
ld d, a
ld a, [hl]
@@ -3533,34 +3537,37 @@
.asm_5a3f
ld [$ffc2], a
- ld hl, $0017
+ ld hl, OBJECT_SPRITE_X
add hl, bc
ld a, [hl]
- ld hl, $0019
+ ld hl, OBJECT_SPRITE_X_OFFSET
add hl, bc
add [hl]
+
add 8
+
ld e, a
ld a, [$d14c]
add e
ld [$ffbf], a
- ld hl, $0018
+ ld hl, OBJECT_SPRITE_Y
add hl, bc
ld a, [hl]
- ld hl, $001a
+ ld hl, OBJECT_SPRITE_Y_OFFSET
add hl, bc
add [hl]
- add $c
+ add 12
+
ld e, a
ld a, [$d14d]
add e
ld [$ffc0], a
- ld hl, $000d
+ ld hl, OBJECT_FACING
add hl, bc
ld a, [hl]
cp -1
--- a/wram.asm
+++ b/wram.asm
@@ -1637,6 +1637,8 @@
ds 10
+ObjectStructs:
+
PlayerStruct: ; d4d6
ds 2
PlayerSprite: ; d4d8
@@ -1659,7 +1661,9 @@
; 4 spinning
; 6 fishing
ds 1
- ds 2
+ ds 1
+PlayerFacing: ; d4e3
+ ds 1
StandingTile: ; d4e4
ds 1
StandingTile2: ; d4e5