shithub: pokecrystal

Download patch

ref: 1a2bc578418612d074bd275c34a57e61b3d016b2
parent: 68e5a703cbf37597a729834b74b7545c9b0636cc
author: Remy Oukaour <[email protected]>
date: Wed Jan 10 21:35:46 EST 2018

Event script–related constants go in constants/script_constants.asm

--- a/constants/map_data_constants.asm
+++ b/constants/map_data_constants.asm
@@ -181,150 +181,3 @@
 	const SPAWN_MT_SILVER
 	const SPAWN_FAST_SHIP
 NUM_SPAWNS EQU const_value
-
-
-; treemon sets
-; TreeMons indexes (see data/wild/treemons.asm)
-	const_def
-	const TREEMON_SET_CITY
-	const TREEMON_SET_CANYON
-	const TREEMON_SET_AZALEA
-	const TREEMON_SET_ROUTE
-	const TREEMON_SET_KANTO
-	const TREEMON_SET_LAKE
-	const TREEMON_SET_FOREST
-	const TREEMON_SET_ROCK
-NUM_TREEMON_SETS EQU const_value
-
-; treemon scores
-	const_def
-	const TREEMON_SCORE_BAD  ; 0
-	const TREEMON_SCORE_GOOD ; 1
-	const TREEMON_SCORE_RARE ; 2
-
-
-; TryBGEvent arguments (see engine/events.asm)
-	const_def
-	const BGEVENT_READ
-	const BGEVENT_UP
-	const BGEVENT_DOWN
-	const BGEVENT_RIGHT
-	const BGEVENT_LEFT
-	const BGEVENT_IFSET
-	const BGEVENT_IFNOTSET
-	const BGEVENT_ITEM
-	const BGEVENT_COPY
-
-; object_event types
-; TryObjectEvent arguments (see engine/events.asm)
-	const_def
-	const OBJECTTYPE_SCRIPT
-	const OBJECTTYPE_ITEMBALL
-	const OBJECTTYPE_TRAINER
-	const OBJECTTYPE_3
-	const OBJECTTYPE_4
-	const OBJECTTYPE_5
-	const OBJECTTYPE_6
-
-
-; Emotes indexes (see data/sprites/emotes.asm)
-	const_def
-	const EMOTE_SHOCK ; 0
-	const EMOTE_QUESTION ; 1
-	const EMOTE_HAPPY ; 2
-	const EMOTE_SAD ; 3
-	const EMOTE_HEART ; 4
-	const EMOTE_BOLT ; 5
-	const EMOTE_SLEEP ; 6
-	const EMOTE_FISH ; 7
-	const EMOTE_SHADOW ; 8
-	const EMOTE_ROD ; 9
-	const EMOTE_BOULDER_DUST ; 10
-	const EMOTE_GRASS_RUSTLE ; 11
-EMOTE_MEM EQU -1
-
-; FruitTreeItems indexes (see data/items/fruit_trees.asm)
-; used by fruittree command
-const_value set 1
-	const FRUITTREE_ROUTE_29      ; 01
-	const FRUITTREE_ROUTE_30_1    ; 02
-	const FRUITTREE_ROUTE_38      ; 03
-	const FRUITTREE_ROUTE_46_1    ; 04
-	const FRUITTREE_ROUTE_30_2    ; 05
-	const FRUITTREE_ROUTE_33      ; 06
-	const FRUITTREE_ROUTE_31      ; 07
-	const FRUITTREE_ROUTE_43      ; 08
-	const FRUITTREE_VIOLET_CITY   ; 09
-	const FRUITTREE_ROUTE_46_2    ; 0a
-	const FRUITTREE_ROUTE_35      ; 0b
-	const FRUITTREE_ROUTE_45      ; 0c
-	const FRUITTREE_ROUTE_36      ; 0d
-	const FRUITTREE_ROUTE_26      ; 0e
-	const FRUITTREE_ROUTE_39      ; 0f
-	const FRUITTREE_ROUTE_44      ; 10
-	const FRUITTREE_ROUTE_37_1    ; 11
-	const FRUITTREE_ROUTE_37_2    ; 12
-	const FRUITTREE_ROUTE_37_3    ; 13
-	const FRUITTREE_AZALEA_TOWN   ; 14
-	const FRUITTREE_ROUTE_42_1    ; 15
-	const FRUITTREE_ROUTE_42_2    ; 16
-	const FRUITTREE_ROUTE_42_3    ; 17
-	const FRUITTREE_ROUTE_11      ; 18
-	const FRUITTREE_ROUTE_2       ; 19
-	const FRUITTREE_ROUTE_1       ; 1a
-	const FRUITTREE_ROUTE_8       ; 1b
-	const FRUITTREE_PEWTER_CITY_1 ; 1c
-	const FRUITTREE_PEWTER_CITY_2 ; 1d
-	const FRUITTREE_FUCHSIA_CITY  ; 1e
-NUM_FRUIT_TREES EQU const_value +- 1
-
-
-; ElevatorFloorNames indexes (see data/elevator_floors.asm)
-; used by elevfloor macro
-	const_def
-	const FLOOR_B4F
-	const FLOOR_B3F
-	const FLOOR_B2F
-	const FLOOR_B1F
-	const FLOOR_1F
-	const FLOOR_2F
-	const FLOOR_3F
-	const FLOOR_4F
-	const FLOOR_5F
-	const FLOOR_6F
-	const FLOOR_7F
-	const FLOOR_8F
-	const FLOOR_9F
-	const FLOOR_10F
-	const FLOOR_11F
-	const FLOOR_ROOF
-
-; command queue members
-CMDQUEUE_TYPE  EQU 0
-CMDQUEUE_ADDR  EQU 1
-CMDQUEUE_03    EQU 3
-CMDQUEUE_04    EQU 4
-CMDQUEUE_05    EQU 5
-CMDQUEUE_ENTRY_SIZE EQU 6
-CMDQUEUE_CAPACITY EQU 4
-
-; command queue types
-CMDQUEUE_STONETABLE EQU 2
-
-
-; used by Special_UnownPuzzle
-; LoadUnownPuzzlePiecesGFX.LZPointers indexes (see engine/unown_puzzle.asm)
-	const_def
-	const UNOWNPUZZLE_KABUTO     ; 0
-	const UNOWNPUZZLE_OMANYTE    ; 1
-	const UNOWNPUZZLE_AERODACTYL ; 2
-	const UNOWNPUZZLE_HO_OH      ; 3
-NUM_UNOWN_PUZZLES EQU const_value
-
-; used by Special_DisplayUnownWords
-; UnownWalls and MenuDataHeaders_UnownWalls indexes (see data/unown_walls.asm)
-	const_def
-	const UNOWNWORDS_ESCAPE ; 0
-	const UNOWNWORDS_LIGHT  ; 1
-	const UNOWNWORDS_WATER  ; 2
-	const UNOWNWORDS_HO_OH  ; 3
--- a/constants/pokemon_data_constants.asm
+++ b/constants/pokemon_data_constants.asm
@@ -123,38 +123,6 @@
 	const ATK_EQ_DEF
 
 
-; PP
-PP_UP_MASK EQU %11000000
-PP_UP_ONE  EQU %01000000
-PP_MASK    EQU %00111111
-
-
-; significant happiness values
-BASE_HAPPINESS        EQU 70
-FRIEND_BALL_HAPPINESS EQU 200
-HAPPINESS_TO_EVOLVE   EQU 220
-HAPPINESS_THRESHOLD_1 EQU 100
-HAPPINESS_THRESHOLD_2 EQU 200
-
-
-; wild data
-
-NUM_GRASSMON EQU 7 ; data/wild/*_grass.asm table size
-NUM_WATERMON EQU 3 ; data/wild/*_water.asm table size
-
-GRASS_WILDDATA_LENGTH EQU (NUM_GRASSMON * 2 + 1) * 3 + 2
-WATER_WILDDATA_LENGTH EQU (NUM_WATERMON * 2 + 1) * 1 + 2
-
-
-; swarms
-
-SWARM_DUNSPARCE EQU 0
-SWARM_YANMA     EQU 1
-
-FISHSWARM_QWILFISH EQU 1
-FISHSWARM_REMORAID EQU 2
-
-
 ; PokeAnims indexes (see engine/pic_animation.asm)
 	const_def
 	const ANIM_MON_SLOW
@@ -167,6 +135,7 @@
 	const ANIM_MON_EGG1
 	const ANIM_MON_EGG2
 
+
 ; MonMenuOptions indexes (see engine/mon_menu.asm)
 const_value set 1
 ; moves
@@ -198,3 +167,55 @@
 MONMENU_MENUOPTION EQU 1
 
 NUM_MONMENU_ITEMS EQU 8
+
+
+; treemon sets
+; TreeMons indexes (see data/wild/treemons.asm)
+	const_def
+	const TREEMON_SET_CITY
+	const TREEMON_SET_CANYON
+	const TREEMON_SET_AZALEA
+	const TREEMON_SET_ROUTE
+	const TREEMON_SET_KANTO
+	const TREEMON_SET_LAKE
+	const TREEMON_SET_FOREST
+	const TREEMON_SET_ROCK
+NUM_TREEMON_SETS EQU const_value
+
+; treemon scores
+	const_def
+	const TREEMON_SCORE_BAD  ; 0
+	const TREEMON_SCORE_GOOD ; 1
+	const TREEMON_SCORE_RARE ; 2
+
+
+; wild data
+
+NUM_GRASSMON EQU 7 ; data/wild/*_grass.asm table size
+NUM_WATERMON EQU 3 ; data/wild/*_water.asm table size
+
+GRASS_WILDDATA_LENGTH EQU (NUM_GRASSMON * 2 + 1) * 3 + 2
+WATER_WILDDATA_LENGTH EQU (NUM_WATERMON * 2 + 1) * 1 + 2
+
+
+; swarms
+
+SWARM_DUNSPARCE EQU 0
+SWARM_YANMA     EQU 1
+
+FISHSWARM_QWILFISH EQU 1
+FISHSWARM_REMORAID EQU 2
+
+
+; significant happiness values
+BASE_HAPPINESS        EQU 70
+FRIEND_BALL_HAPPINESS EQU 200
+HAPPINESS_TO_EVOLVE   EQU 220
+HAPPINESS_THRESHOLD_1 EQU 100
+HAPPINESS_THRESHOLD_2 EQU 200
+
+
+; PP
+PP_UP_MASK EQU %11000000
+PP_UP_ONE  EQU %01000000
+PP_MASK    EQU %00111111
--- a/constants/script_constants.asm
+++ b/constants/script_constants.asm
@@ -2,6 +2,7 @@
 PLAYER      EQU  0
 LAST_TALKED EQU -2
 
+
 ; GetVarAction arguments (see engine/variables.asm)
 	const_def
 	const VAR_STRINGBUFFER2    ; 00
@@ -38,6 +39,7 @@
 RETVAR_ADDR_DE EQU (1 << 6)
 RETVAR_EXECUTE EQU (2 << 6)
 
+
 ; PlayerEventScriptPointers indexes (see engine/events.asm)
 const_value set -1
 	const PLAYEREVENT_MAPSCRIPT
@@ -52,3 +54,132 @@
 	const PLAYEREVENT_HATCH
 	const PLAYEREVENT_JOYCHANGEFACING
 NUM_PLAYER_EVENTS EQU const_value
+
+
+; TryBGEvent arguments (see engine/events.asm)
+	const_def
+	const BGEVENT_READ
+	const BGEVENT_UP
+	const BGEVENT_DOWN
+	const BGEVENT_RIGHT
+	const BGEVENT_LEFT
+	const BGEVENT_IFSET
+	const BGEVENT_IFNOTSET
+	const BGEVENT_ITEM
+	const BGEVENT_COPY
+
+; object_event types
+; TryObjectEvent arguments (see engine/events.asm)
+	const_def
+	const OBJECTTYPE_SCRIPT
+	const OBJECTTYPE_ITEMBALL
+	const OBJECTTYPE_TRAINER
+	const OBJECTTYPE_3
+	const OBJECTTYPE_4
+	const OBJECTTYPE_5
+	const OBJECTTYPE_6
+
+
+; Emotes indexes (see data/sprites/emotes.asm)
+	const_def
+	const EMOTE_SHOCK ; 0
+	const EMOTE_QUESTION ; 1
+	const EMOTE_HAPPY ; 2
+	const EMOTE_SAD ; 3
+	const EMOTE_HEART ; 4
+	const EMOTE_BOLT ; 5
+	const EMOTE_SLEEP ; 6
+	const EMOTE_FISH ; 7
+	const EMOTE_SHADOW ; 8
+	const EMOTE_ROD ; 9
+	const EMOTE_BOULDER_DUST ; 10
+	const EMOTE_GRASS_RUSTLE ; 11
+EMOTE_MEM EQU -1
+
+
+; FruitTreeItems indexes (see data/items/fruit_trees.asm)
+; used by fruittree command
+const_value set 1
+	const FRUITTREE_ROUTE_29      ; 01
+	const FRUITTREE_ROUTE_30_1    ; 02
+	const FRUITTREE_ROUTE_38      ; 03
+	const FRUITTREE_ROUTE_46_1    ; 04
+	const FRUITTREE_ROUTE_30_2    ; 05
+	const FRUITTREE_ROUTE_33      ; 06
+	const FRUITTREE_ROUTE_31      ; 07
+	const FRUITTREE_ROUTE_43      ; 08
+	const FRUITTREE_VIOLET_CITY   ; 09
+	const FRUITTREE_ROUTE_46_2    ; 0a
+	const FRUITTREE_ROUTE_35      ; 0b
+	const FRUITTREE_ROUTE_45      ; 0c
+	const FRUITTREE_ROUTE_36      ; 0d
+	const FRUITTREE_ROUTE_26      ; 0e
+	const FRUITTREE_ROUTE_39      ; 0f
+	const FRUITTREE_ROUTE_44      ; 10
+	const FRUITTREE_ROUTE_37_1    ; 11
+	const FRUITTREE_ROUTE_37_2    ; 12
+	const FRUITTREE_ROUTE_37_3    ; 13
+	const FRUITTREE_AZALEA_TOWN   ; 14
+	const FRUITTREE_ROUTE_42_1    ; 15
+	const FRUITTREE_ROUTE_42_2    ; 16
+	const FRUITTREE_ROUTE_42_3    ; 17
+	const FRUITTREE_ROUTE_11      ; 18
+	const FRUITTREE_ROUTE_2       ; 19
+	const FRUITTREE_ROUTE_1       ; 1a
+	const FRUITTREE_ROUTE_8       ; 1b
+	const FRUITTREE_PEWTER_CITY_1 ; 1c
+	const FRUITTREE_PEWTER_CITY_2 ; 1d
+	const FRUITTREE_FUCHSIA_CITY  ; 1e
+NUM_FRUIT_TREES EQU const_value +- 1
+
+
+; ElevatorFloorNames indexes (see data/elevator_floors.asm)
+; used by elevfloor macro
+	const_def
+	const FLOOR_B4F
+	const FLOOR_B3F
+	const FLOOR_B2F
+	const FLOOR_B1F
+	const FLOOR_1F
+	const FLOOR_2F
+	const FLOOR_3F
+	const FLOOR_4F
+	const FLOOR_5F
+	const FLOOR_6F
+	const FLOOR_7F
+	const FLOOR_8F
+	const FLOOR_9F
+	const FLOOR_10F
+	const FLOOR_11F
+	const FLOOR_ROOF
+
+
+; command queue members
+CMDQUEUE_TYPE  EQU 0
+CMDQUEUE_ADDR  EQU 1
+CMDQUEUE_03    EQU 3
+CMDQUEUE_04    EQU 4
+CMDQUEUE_05    EQU 5
+CMDQUEUE_ENTRY_SIZE EQU 6
+CMDQUEUE_CAPACITY EQU 4
+
+; command queue types
+CMDQUEUE_STONETABLE EQU 2
+
+
+; used by Special_UnownPuzzle
+; LoadUnownPuzzlePiecesGFX.LZPointers indexes (see engine/unown_puzzle.asm)
+	const_def
+	const UNOWNPUZZLE_KABUTO     ; 0
+	const UNOWNPUZZLE_OMANYTE    ; 1
+	const UNOWNPUZZLE_AERODACTYL ; 2
+	const UNOWNPUZZLE_HO_OH      ; 3
+NUM_UNOWN_PUZZLES EQU const_value
+
+; used by Special_DisplayUnownWords
+; UnownWalls and MenuDataHeaders_UnownWalls indexes (see data/unown_walls.asm)
+	const_def
+	const UNOWNWORDS_ESCAPE ; 0
+	const UNOWNWORDS_LIGHT  ; 1
+	const UNOWNWORDS_WATER  ; 2
+	const UNOWNWORDS_HO_OH  ; 3
--- a/engine/variables.asm
+++ b/engine/variables.asm
@@ -35,9 +35,10 @@
 ; 80671 (20:4671)
 
 .VarActionTable: ; 80671
-; RETVAR_STRBUF2: copy [de] to StringBuffer2
-; RETVAR_ADDR_DE: return address in de
-; RETVAR_EXECUTE: call function
+; entries correspond to VAR_* constants
+	; RETVAR_STRBUF2: copy [de] to StringBuffer2
+	; RETVAR_ADDR_DE: return address in de
+	; RETVAR_EXECUTE: call function
 	dwb StringBuffer2,                  RETVAR_STRBUF2
 	dwb PartyCount,                     RETVAR_STRBUF2
 	dwb .BattleResult,                  RETVAR_EXECUTE
@@ -125,7 +126,7 @@
 	ret z
 	inc b
 	ld a, b
-	cp 26
+	cp NUM_UNOWN
 	jr c, .loop
 	ret
 ; 80715