ref: 72c4f9e04a33925f99d685e68f580ee29f865e22
parent: 3bf8325edddb03753fa63f0dfb39cedcd1d2faca
author: Remy Oukaour <remy.oukaour@gmail.com>
date: Thu Jan 18 10:58:55 EST 2018
More constants, related to map objects
--- a/constants/map_data_constants.asm
+++ b/constants/map_data_constants.asm
@@ -3,6 +3,7 @@
GROUP_NONE EQU 0
MAP_NONE EQU 0
+
; map header struct members (see data/maps/definitions.asm)
const_def
const MAPDEF_MAPDATA_BANK ; 0
@@ -67,6 +68,75 @@
shift_const NORTH
+; SpawnPoints indexes (see data/maps/spawn_points.asm)
+const_value = -1
+ const SPAWN_N_A
+ const SPAWN_HOME
+ const SPAWN_DEBUG
+; kanto
+ const SPAWN_PALLET
+ const SPAWN_VIRIDIAN
+ const SPAWN_PEWTER
+ const SPAWN_CERULEAN
+ const SPAWN_ROCK_TUNNEL
+ const SPAWN_VERMILION
+ const SPAWN_LAVENDER
+ const SPAWN_SAFFRON
+ const SPAWN_CELADON
+ const SPAWN_FUCHSIA
+ const SPAWN_CINNABAR
+ const SPAWN_INDIGO
+; johto
+ const SPAWN_NEW_BARK
+ const SPAWN_CHERRYGROVE
+ const SPAWN_VIOLET
+ const SPAWN_UNION_CAVE
+ const SPAWN_AZALEA
+ const SPAWN_CIANWOOD
+ const SPAWN_GOLDENROD
+ const SPAWN_OLIVINE
+ const SPAWN_ECRUTEAK
+ const SPAWN_MAHOGANY
+ const SPAWN_LAKE
+ const SPAWN_BLACKTHORN
+ const SPAWN_MT_SILVER
+ const SPAWN_FAST_SHIP
+NUM_SPAWNS EQU const_value
+
+
+; outdoor sprite limits (see engine/overworld.asm)
+MAX_OUTDOOR_SPRITES EQU 23
+SPRITE_GFX_LIST_CAPACITY EQU $20
+
+
+; map_object struct members (see macros/wram.asm)
+ const_def
+ const MAPOBJECT_OBJECT_STRUCT_ID ; 0
+ const MAPOBJECT_SPRITE ; 1
+ const MAPOBJECT_Y_COORD ; 2
+ const MAPOBJECT_X_COORD ; 3
+ const MAPOBJECT_MOVEMENT ; 4
+ const MAPOBJECT_RADIUS ; 5
+ const MAPOBJECT_HOUR ; 6
+ const MAPOBJECT_TIMEOFDAY ; 7
+ const MAPOBJECT_COLOR ; 8
+ const MAPOBJECT_RANGE ; 9
+ const MAPOBJECT_SCRIPT_POINTER ; a
+ const MAPOBJECT_POINTER_HI ; b
+ const MAPOBJECT_EVENT_FLAG ; c
+ const MAPOBJECT_FLAG_HI ; d
+ const MAPOBJECT_E ; unused
+ const MAPOBJECT_F ; unused
+OBJECT_LENGTH EQU const_value
+
+MAPOBJECT_SCREEN_HEIGHT EQU 11
+MAPOBJECT_SCREEN_WIDTH EQU 12
+
+; NPCs disappear if standing on tile $60-$7f or $e0-$ff,
+; since those IDs are for text characters and textbox frames.
+MAPOBJECT_VISIBLE_TILE_LIMIT EQU $60
+
+
; object_struct members (see macros/wram.asm)
const_def
const OBJECT_SPRITE ; 00
@@ -106,29 +176,6 @@
OBJECT_STRUCT_LENGTH EQU 40
NUM_OBJECT_STRUCTS EQU 13 ; see ObjectStructs
-; map_object struct members (see macros/wram.asm)
- const_def
- const MAPOBJECT_OBJECT_STRUCT_ID ; 0
- const MAPOBJECT_SPRITE ; 1
- const MAPOBJECT_Y_COORD ; 2
- const MAPOBJECT_X_COORD ; 3
- const MAPOBJECT_MOVEMENT ; 4
- const MAPOBJECT_RADIUS ; 5
- const MAPOBJECT_HOUR ; 6
- const MAPOBJECT_TIMEOFDAY ; 7
- const MAPOBJECT_COLOR ; 8
- const MAPOBJECT_RANGE ; 9
- const MAPOBJECT_SCRIPT_POINTER ; a
- const MAPOBJECT_POINTER_HI ; b
- const MAPOBJECT_EVENT_FLAG ; c
- const MAPOBJECT_FLAG_HI ; d
- const MAPOBJECT_E ; unused
- const MAPOBJECT_F ; unused
-OBJECT_LENGTH EQU const_value
-
-MAPOBJECT_SCREEN_HEIGHT EQU 11
-MAPOBJECT_SCREEN_WIDTH EQU 12
-
; object_struct OBJECT_FACING values
OW_DOWN EQU DOWN << 2
OW_UP EQU UP << 2
@@ -140,44 +187,3 @@
FIXED_FACING EQU 2
SLIDING EQU 3
EMOTE_OBJECT EQU 7
-
-
-; see engine/overworld.asm
-MAX_OUTDOOR_SPRITES EQU 23
-SPRITE_GFX_LIST_CAPACITY EQU $20
-
-
-; SpawnPoints indexes (see data/maps/spawn_points.asm)
-const_value = -1
- const SPAWN_N_A
- const SPAWN_HOME
- const SPAWN_DEBUG
-; kanto
- const SPAWN_PALLET
- const SPAWN_VIRIDIAN
- const SPAWN_PEWTER
- const SPAWN_CERULEAN
- const SPAWN_ROCK_TUNNEL
- const SPAWN_VERMILION
- const SPAWN_LAVENDER
- const SPAWN_SAFFRON
- const SPAWN_CELADON
- const SPAWN_FUCHSIA
- const SPAWN_CINNABAR
- const SPAWN_INDIGO
-; johto
- const SPAWN_NEW_BARK
- const SPAWN_CHERRYGROVE
- const SPAWN_VIOLET
- const SPAWN_UNION_CAVE
- const SPAWN_AZALEA
- const SPAWN_CIANWOOD
- const SPAWN_GOLDENROD
- const SPAWN_OLIVINE
- const SPAWN_ECRUTEAK
- const SPAWN_MAHOGANY
- const SPAWN_LAKE
- const SPAWN_BLACKTHORN
- const SPAWN_MT_SILVER
- const SPAWN_FAST_SHIP
-NUM_SPAWNS EQU const_value
--- a/engine/map_objects.asm
+++ b/engine/map_objects.asm
@@ -2089,6 +2089,7 @@
; vtile, palette, movement
db $00, PAL_OW_SILVER, SPRITEMOVEDATA_SHADOW
; 5538
+
SpawnStrengthBoulderDust: ; 5538
push bc
ld de, .BoulderDustObject
@@ -2100,6 +2101,7 @@
.BoulderDustObject:
db $00, PAL_OW_SILVER, SPRITEMOVEDATA_BOULDERDUST
; 5547
+
SpawnEmote: ; 5547
push bc
ld de, .EmoteObject
@@ -2111,6 +2113,7 @@
.EmoteObject:
db $00, PAL_OW_SILVER, SPRITEMOVEDATA_EMOTE
; 5556
+
ShakeGrass: ; 5556
push bc
ld de, .data_5562
@@ -2122,6 +2125,7 @@
.data_5562
db $00, PAL_OW_TREE, SPRITEMOVEDATA_GRASS
; 5565
+
ShakeScreen: ; 5565
push bc
push af
@@ -2359,7 +2363,7 @@
cp d
jr z, .equal_x
jr nc, .nope
- add $b
+ add MAPOBJECT_SCREEN_WIDTH - 1
cp d
jr c, .nope
.equal_x
@@ -2367,7 +2371,7 @@
cp e
jr z, .equal_y
jr nc, .nope
- add $a
+ add MAPOBJECT_SCREEN_HEIGHT - 1
cp e
jr c, .nope
.equal_y
@@ -2406,7 +2410,7 @@
srl a
cp SCREEN_WIDTH
jr c, .ok3
- sub $20
+ sub BG_MAP_WIDTH
.ok3
ld [hUsedSpriteIndex], a
ld a, [wPlayerBGMapOffsetY]
@@ -2433,9 +2437,9 @@
srl a
srl a
srl a
- cp $12
+ cp SCREEN_HEIGHT
jr c, .ok6
- sub $20
+ sub BG_MAP_HEIGHT
.ok6
ld [hUsedSpriteTile], a
ld hl, OBJECT_PALETTE
@@ -2457,7 +2461,7 @@
ld a, [hUsedSpriteTile]
add e
dec a
- cp $12
+ cp SCREEN_HEIGHT
jr nc, .ok9
ld b, a
.next
@@ -2464,7 +2468,7 @@
ld a, [hUsedSpriteIndex]
add d
dec a
- cp $14
+ cp SCREEN_WIDTH
jr nc, .ok8
ld c, a
push bc
@@ -2471,7 +2475,7 @@
call Coord2Tile
pop bc
ld a, [hl]
- cp $60
+ cp MAPOBJECT_VISIBLE_TILE_LIMIT
jr nc, .nope
.ok8
dec d
@@ -2876,10 +2880,12 @@
ret
; 5991
-InitSprites: ; 5991
+
PRIORITY_LOW EQU $10
PRIORITY_NORM EQU $20
PRIORITY_HIGH EQU $30
+
+InitSprites: ; 5991
call .DeterminePriorities
ld c, PRIORITY_HIGH
call .InitSpritesByPriority
@@ -3069,7 +3075,7 @@
ld a, [hFFC2]
or e
.nope2
- and %11110000
+ and OBP_NUM | X_FLIP | Y_FLIP | PRIORITY
or d
ld [bc], a ; attributes
inc c