shithub: pokecrystal

Download patch

ref: 94ae404732b512c60cf82111bb2f65013fdfbf39
parent: fc61d58dc45e1a205ab63cdb7a8df62450383bf9
author: Rangi <remy.oukaour+rangi42@gmail.com>
date: Tue Jan 23 05:46:26 EST 2018

Separate data/mon_menu.asm

--- a/constants/gfx_constants.asm
+++ b/constants/gfx_constants.asm
@@ -8,6 +8,7 @@
 
 PALRGB_WHITE EQUS "palred 31 + palgreen 31 + palblue 31" ; $7fff
 
+
 SCREEN_WIDTH  EQU 20 ; tiles
 SCREEN_HEIGHT EQU 18 ; tiles
 SCREEN_WIDTH_PX  EQU SCREEN_WIDTH  * TILE_WIDTH ; pixels
@@ -18,11 +19,13 @@
 WMISC_WIDTH   EQU 6 * 4
 WMISC_HEIGHT  EQU 5 * 4
 
+
 HP_BAR_LENGTH  EQU 6 ; tiles
 EXP_BAR_LENGTH EQU 8 ; tiles
 HP_BAR_LENGTH_PX  EQU HP_BAR_LENGTH  * TILE_WIDTH ; pixels
 EXP_BAR_LENGTH_PX EQU EXP_BAR_LENGTH * TILE_WIDTH ; pixels
 
+
 ; sprite_oam_struct members (see macros/wram.asm)
 	const_def
 	const SPRITEOAMSTRUCT_YCOORD     ; 0
@@ -31,3 +34,16 @@
 	const SPRITEOAMSTRUCT_ATTRIBUTES ; 3
 SPRITEOAMSTRUCT_LENGTH EQU const_value
 NUM_SPRITE_OAM_STRUCTS EQU 40 ; see Sprites
+
+
+; PokeAnims indexes (see engine/pic_animation.asm)
+	const_def
+	const ANIM_MON_SLOW
+	const ANIM_MON_NORMAL
+	const ANIM_MON_MENU
+	const ANIM_MON_TRADE
+	const ANIM_MON_EVOLVE
+	const ANIM_MON_HATCH
+	const ANIM_MON_UNUSED
+	const ANIM_MON_EGG1
+	const ANIM_MON_EGG2
--- a/constants/menu_constants.asm
+++ b/constants/menu_constants.asm
@@ -31,3 +31,37 @@
 	shift_const SCROLLINGMENU_ENABLE_FUNCTION3
 	shift_const SCROLLINGMENU_ENABLE_START
 	shift_const SCROLLINGMENU_ENABLE_SELECT
+
+
+; MonMenuOptions indexes (see data/mon_menu.asm)
+; used by PokemonActionSubmenu (see engine/start_menu.asm)
+const_value set 1
+; moves
+	const MONMENUITEM_CUT        ; 1
+	const MONMENUITEM_FLY        ; 2
+	const MONMENUITEM_SURF       ; 3
+	const MONMENUITEM_STRENGTH   ; 4
+	const MONMENUITEM_WATERFALL  ; 5
+	const MONMENUITEM_FLASH      ; 6
+	const MONMENUITEM_WHIRLPOOL  ; 7
+	const MONMENUITEM_DIG        ; 8
+	const MONMENUITEM_TELEPORT   ; 9
+	const MONMENUITEM_SOFTBOILED ; 10
+	const MONMENUITEM_HEADBUTT   ; 11
+	const MONMENUITEM_ROCKSMASH  ; 12
+	const MONMENUITEM_MILKDRINK  ; 13
+	const MONMENUITEM_SWEETSCENT ; 14
+; options
+	const MONMENUITEM_STATS      ; 15
+	const MONMENUITEM_SWITCH     ; 16
+	const MONMENUITEM_ITEM       ; 17
+	const MONMENUITEM_CANCEL     ; 18
+	const MONMENUITEM_MOVE       ; 19
+	const MONMENUITEM_MAIL       ; 20
+	const MONMENUITEM_ERROR      ; 21
+
+; MonMenuOptions categories
+MONMENU_FIELD_MOVE EQU 0
+MONMENU_MENUOPTION EQU 1
+
+NUM_MONMENU_ITEMS EQU 8
--- a/constants/pokemon_data_constants.asm
+++ b/constants/pokemon_data_constants.asm
@@ -142,52 +142,6 @@
 	const ATK_EQ_DEF
 
 
-; PokeAnims indexes (see engine/pic_animation.asm)
-	const_def
-	const ANIM_MON_SLOW
-	const ANIM_MON_NORMAL
-	const ANIM_MON_MENU
-	const ANIM_MON_TRADE
-	const ANIM_MON_EVOLVE
-	const ANIM_MON_HATCH
-	const ANIM_MON_UNUSED
-	const ANIM_MON_EGG1
-	const ANIM_MON_EGG2
-
-
-; MonMenuOptions indexes (see engine/mon_menu.asm)
-const_value set 1
-; moves
-	const MONMENU_CUT        ; 1
-	const MONMENU_FLY        ; 2
-	const MONMENU_SURF       ; 3
-	const MONMENU_STRENGTH   ; 4
-	const MONMENU_WATERFALL  ; 5
-	const MONMENU_FLASH      ; 6
-	const MONMENU_WHIRLPOOL  ; 7
-	const MONMENU_DIG        ; 8
-	const MONMENU_TELEPORT   ; 9
-	const MONMENU_SOFTBOILED ; 10
-	const MONMENU_HEADBUTT   ; 11
-	const MONMENU_ROCKSMASH  ; 12
-	const MONMENU_MILKDRINK  ; 13
-	const MONMENU_SWEETSCENT ; 14
-; options
-	const MONMENU_STATS      ; 15
-	const MONMENU_SWITCH     ; 16
-	const MONMENU_ITEM       ; 17
-	const MONMENU_CANCEL     ; 18
-	const MONMENU_MOVE       ; 19
-	const MONMENU_MAIL       ; 20
-	const MONMENU_ERROR      ; 21
-
-; MonMenuOptions types
-MONMENU_FIELD_MOVE EQU 0
-MONMENU_MENUOPTION EQU 1
-
-NUM_MONMENU_ITEMS EQU 8
-
-
 ; wild data
 
 NUM_GRASSMON EQU 7 ; data/wild/*_grass.asm table size
--- /dev/null
+++ b/data/mon_menu.asm
@@ -1,0 +1,48 @@
+; MonMenuOptionStrings indexes
+const_value set 1
+	const MONMENUVALUE_STATS  ; 1
+	const MONMENUVALUE_SWITCH ; 2
+	const MONMENUVALUE_ITEM   ; 3
+	const MONMENUVALUE_CANCEL ; 4
+	const MONMENUVALUE_MOVE   ; 5
+	const MONMENUVALUE_MAIL   ; 6
+	const MONMENUVALUE_ERROR  ; 7
+
+MonMenuOptionStrings: ; 24caf
+; entries correspond to MONMENUVALUE_* constants
+	db "STATS@"
+	db "SWITCH@"
+	db "ITEM@"
+	db "CANCEL@"
+	db "MOVE@"
+	db "MAIL@"
+	db "ERROR!@"
+; 24cd9
+
+MonMenuOptions: ; 24cd9
+; category, item, value; actions are in PokemonActionSubmenu (see engine/start_menu.asm)
+; moves
+	db MONMENU_FIELD_MOVE, MONMENUITEM_CUT,        CUT
+	db MONMENU_FIELD_MOVE, MONMENUITEM_FLY,        FLY
+	db MONMENU_FIELD_MOVE, MONMENUITEM_SURF,       SURF
+	db MONMENU_FIELD_MOVE, MONMENUITEM_STRENGTH,   STRENGTH
+	db MONMENU_FIELD_MOVE, MONMENUITEM_FLASH,      FLASH
+	db MONMENU_FIELD_MOVE, MONMENUITEM_WATERFALL,  WATERFALL
+	db MONMENU_FIELD_MOVE, MONMENUITEM_WHIRLPOOL,  WHIRLPOOL
+	db MONMENU_FIELD_MOVE, MONMENUITEM_DIG,        DIG
+	db MONMENU_FIELD_MOVE, MONMENUITEM_TELEPORT,   TELEPORT
+	db MONMENU_FIELD_MOVE, MONMENUITEM_SOFTBOILED, SOFTBOILED
+	db MONMENU_FIELD_MOVE, MONMENUITEM_HEADBUTT,   HEADBUTT
+	db MONMENU_FIELD_MOVE, MONMENUITEM_ROCKSMASH,  ROCK_SMASH
+	db MONMENU_FIELD_MOVE, MONMENUITEM_MILKDRINK,  MILK_DRINK
+	db MONMENU_FIELD_MOVE, MONMENUITEM_SWEETSCENT, SWEET_SCENT
+; options
+	db MONMENU_MENUOPTION, MONMENUITEM_STATS,      MONMENUVALUE_STATS
+	db MONMENU_MENUOPTION, MONMENUITEM_SWITCH,     MONMENUVALUE_SWITCH
+	db MONMENU_MENUOPTION, MONMENUITEM_ITEM,       MONMENUVALUE_ITEM
+	db MONMENU_MENUOPTION, MONMENUITEM_CANCEL,     MONMENUVALUE_CANCEL
+	db MONMENU_MENUOPTION, MONMENUITEM_MOVE,       MONMENUVALUE_MOVE
+	db MONMENU_MENUOPTION, MONMENUITEM_MAIL,       MONMENUVALUE_MAIL
+	db MONMENU_MENUOPTION, MONMENUITEM_ERROR,      MONMENUVALUE_ERROR
+	db -1
+; 24d19
--- a/engine/mon_menu.asm
+++ b/engine/mon_menu.asm
@@ -1,40 +1,5 @@
-MonMenuOptionStrings: ; 24caf
-	db "STATS@"
-	db "SWITCH@"
-	db "ITEM@"
-	db "CANCEL@"
-	db "MOVE@"
-	db "MAIL@"
-	db "ERROR!@"
-; 24cd9
+INCLUDE "data/mon_menu.asm"
 
-MonMenuOptions: ; 24cd9
-; moves
-	db MONMENU_FIELD_MOVE, MONMENU_CUT,        CUT
-	db MONMENU_FIELD_MOVE, MONMENU_FLY,        FLY
-	db MONMENU_FIELD_MOVE, MONMENU_SURF,       SURF
-	db MONMENU_FIELD_MOVE, MONMENU_STRENGTH,   STRENGTH
-	db MONMENU_FIELD_MOVE, MONMENU_FLASH,      FLASH
-	db MONMENU_FIELD_MOVE, MONMENU_WATERFALL,  WATERFALL
-	db MONMENU_FIELD_MOVE, MONMENU_WHIRLPOOL,  WHIRLPOOL
-	db MONMENU_FIELD_MOVE, MONMENU_DIG,        DIG
-	db MONMENU_FIELD_MOVE, MONMENU_TELEPORT,   TELEPORT
-	db MONMENU_FIELD_MOVE, MONMENU_SOFTBOILED, SOFTBOILED
-	db MONMENU_FIELD_MOVE, MONMENU_HEADBUTT,   HEADBUTT
-	db MONMENU_FIELD_MOVE, MONMENU_ROCKSMASH,  ROCK_SMASH
-	db MONMENU_FIELD_MOVE, MONMENU_MILKDRINK,  MILK_DRINK
-	db MONMENU_FIELD_MOVE, MONMENU_SWEETSCENT, SWEET_SCENT
-; options
-	db MONMENU_MENUOPTION, MONMENU_STATS,      1 ; STATS
-	db MONMENU_MENUOPTION, MONMENU_SWITCH,     2 ; SWITCH
-	db MONMENU_MENUOPTION, MONMENU_ITEM,       3 ; ITEM
-	db MONMENU_MENUOPTION, MONMENU_CANCEL,     4 ; CANCEL
-	db MONMENU_MENUOPTION, MONMENU_MOVE,       5 ; MOVE
-	db MONMENU_MENUOPTION, MONMENU_MAIL,       6 ; MAIL
-	db MONMENU_MENUOPTION, MONMENU_ERROR,      7 ; ERROR!
-	db -1
-; 24d19
-
 MonSubmenu: ; 24d19
 	xor a
 	ld [hBGMapMode], a
@@ -95,7 +60,7 @@
 	jr .loop
 
 .cancel
-	ld a, MONMENU_CANCEL ; CANCEL
+	ld a, MONMENUITEM_CANCEL
 	ret
 
 .select
@@ -111,7 +76,7 @@
 
 PopulateMonMenu: ; 24d91
 	call MenuBoxCoord2Tile
-	ld bc, $2a ; 42
+	ld bc, 2 * SCREEN_WIDTH + 2
 	add hl, bc
 	ld de, Buffer2
 .loop
@@ -124,7 +89,7 @@
 	call GetMonMenuString
 	pop hl
 	call PlaceString
-	ld bc, $28 ; 40
+	ld bc, 2 * SCREEN_WIDTH
 	add hl, bc
 	pop de
 	jr .loop
@@ -136,7 +101,7 @@
 	call IsInArray
 	dec hl
 	ld a, [hli]
-	cp 1
+	cp MONMENU_MENUOPTION
 	jr z, .NotMove
 	inc hl
 	ld a, [hl]
@@ -188,11 +153,11 @@
 	jr nz, .loop
 
 .skip_moves
-	ld a, MONMENU_STATS
+	ld a, MONMENUITEM_STATS
 	call AddMonMenuItem
-	ld a, MONMENU_SWITCH
+	ld a, MONMENUITEM_SWITCH
 	call AddMonMenuItem
-	ld a, MONMENU_MOVE
+	ld a, MONMENUITEM_MOVE
 	call AddMonMenuItem
 	ld a, [wLinkMode]
 	and a
@@ -203,9 +168,9 @@
 	ld d, [hl]
 	farcall ItemIsMail
 	pop hl
-	ld a, MONMENU_MAIL
+	ld a, MONMENUITEM_MAIL
 	jr c, .ok
-	ld a, MONMENU_ITEM
+	ld a, MONMENUITEM_ITEM
 
 .ok
 	call AddMonMenuItem
@@ -214,7 +179,7 @@
 	ld a, [Buffer1]
 	cp NUM_MONMENU_ITEMS
 	jr z, .ok2
-	ld a, MONMENU_CANCEL
+	ld a, MONMENUITEM_CANCEL
 	call AddMonMenuItem
 
 .ok2
@@ -222,11 +187,11 @@
 	ret
 
 .egg
-	ld a, MONMENU_STATS
+	ld a, MONMENUITEM_STATS
 	call AddMonMenuItem
-	ld a, MONMENU_SWITCH
+	ld a, MONMENUITEM_SWITCH
 	call AddMonMenuItem
-	ld a, MONMENU_CANCEL
+	ld a, MONMENUITEM_CANCEL
 	call AddMonMenuItem
 	call TerminateMonSubmenu
 	ret
@@ -265,7 +230,7 @@
 TerminateMonSubmenu: ; 24e76
 	ld a, [Buffer1]
 	ld e, a
-	ld d, $0
+	ld d, 0
 	ld hl, Buffer2
 	add hl, de
 	ld [hl], -1
@@ -280,7 +245,7 @@
 	ld e, a
 	inc a
 	ld [Buffer1], a
-	ld d, $0
+	ld d, 0
 	ld hl, Buffer2
 	add hl, de
 	pop af
--- a/engine/start_menu.asm
+++ b/engine/start_menu.asm
@@ -729,26 +729,26 @@
 	ret
 
 .Actions:
-	dbw MONMENU_CUT,        MonMenu_Cut
-	dbw MONMENU_FLY,        MonMenu_Fly
-	dbw MONMENU_SURF,       MonMenu_Surf
-	dbw MONMENU_STRENGTH,   MonMenu_Strength
-	dbw MONMENU_FLASH,      MonMenu_Flash
-	dbw MONMENU_WHIRLPOOL,  MonMenu_Whirlpool
-	dbw MONMENU_DIG,        MonMenu_Dig
-	dbw MONMENU_TELEPORT,   MonMenu_Teleport
-	dbw MONMENU_SOFTBOILED, MonMenu_Softboiled_MilkDrink
-	dbw MONMENU_MILKDRINK,  MonMenu_Softboiled_MilkDrink
-	dbw MONMENU_HEADBUTT,   MonMenu_Headbutt
-	dbw MONMENU_WATERFALL,  MonMenu_Waterfall
-	dbw MONMENU_ROCKSMASH,  MonMenu_RockSmash
-	dbw MONMENU_SWEETSCENT, MonMenu_SweetScent
-	dbw MONMENU_STATS,      OpenPartyStats
-	dbw MONMENU_SWITCH,     SwitchPartyMons
-	dbw MONMENU_ITEM,       GiveTakePartyMonItem
-	dbw MONMENU_CANCEL,     CancelPokemonAction
-	dbw MONMENU_MOVE,       ManagePokemonMoves
-	dbw MONMENU_MAIL,       MonMailAction
+	dbw MONMENUITEM_CUT,        MonMenu_Cut
+	dbw MONMENUITEM_FLY,        MonMenu_Fly
+	dbw MONMENUITEM_SURF,       MonMenu_Surf
+	dbw MONMENUITEM_STRENGTH,   MonMenu_Strength
+	dbw MONMENUITEM_FLASH,      MonMenu_Flash
+	dbw MONMENUITEM_WHIRLPOOL,  MonMenu_Whirlpool
+	dbw MONMENUITEM_DIG,        MonMenu_Dig
+	dbw MONMENUITEM_TELEPORT,   MonMenu_Teleport
+	dbw MONMENUITEM_SOFTBOILED, MonMenu_Softboiled_MilkDrink
+	dbw MONMENUITEM_MILKDRINK,  MonMenu_Softboiled_MilkDrink
+	dbw MONMENUITEM_HEADBUTT,   MonMenu_Headbutt
+	dbw MONMENUITEM_WATERFALL,  MonMenu_Waterfall
+	dbw MONMENUITEM_ROCKSMASH,  MonMenu_RockSmash
+	dbw MONMENUITEM_SWEETSCENT, MonMenu_SweetScent
+	dbw MONMENUITEM_STATS,      OpenPartyStats
+	dbw MONMENUITEM_SWITCH,     SwitchPartyMons
+	dbw MONMENUITEM_ITEM,       GiveTakePartyMonItem
+	dbw MONMENUITEM_CANCEL,     CancelPokemonAction
+	dbw MONMENUITEM_MOVE,       ManagePokemonMoves
+	dbw MONMENUITEM_MAIL,       MonMailAction
 ; 12aec