diff options
-rw-r--r-- | constants.asm | 2 | ||||
-rwxr-xr-x | constants/item_data_constants.asm | 86 | ||||
-rw-r--r-- | constants/map_object_constants.asm | 72 | ||||
-rw-r--r-- | constants/sgb_constants.asm | 150 | ||||
-rw-r--r-- | data/items/attributes.asm | 520 | ||||
-rw-r--r-- | data/predef_pointers.inc | 2 | ||||
-rw-r--r-- | engine/battle_anims/bg_effects.asm | 2 | ||||
-rw-r--r-- | engine/math/math.asm | 200 | ||||
-rw-r--r-- | engine/title.asm | 2 | ||||
-rw-r--r-- | home/map.asm | 6 | ||||
-rw-r--r-- | home/map_objects.asm | 676 | ||||
-rw-r--r-- | home/math.asm | 25 | ||||
-rw-r--r-- | home/menu.asm | 8 | ||||
-rw-r--r-- | home/menu_window.asm | 246 | ||||
-rw-r--r-- | home/misc_32c8.asm | 98 | ||||
-rw-r--r-- | home/mon_stats.asm | 82 | ||||
-rw-r--r-- | home/print_text.asm | 21 | ||||
-rw-r--r-- | home/scrolling_menu.asm | 93 | ||||
-rw-r--r-- | home/tilemap.asm | 70 | ||||
-rw-r--r-- | home/unknown_388f.asm | 101 | ||||
-rw-r--r-- | home/util.asm | 85 | ||||
-rw-r--r-- | hram.asm | 30 | ||||
-rw-r--r-- | macros/farcall.asm | 2 | ||||
-rw-r--r-- | macros/wram.asm | 10 | ||||
-rw-r--r-- | shim.sym | 61 | ||||
-rw-r--r-- | wram.asm | 82 |
26 files changed, 2653 insertions, 79 deletions
diff --git a/constants.asm b/constants.asm index 538941e..88dd7ee 100644 --- a/constants.asm +++ b/constants.asm @@ -33,3 +33,5 @@ INCLUDE "constants/misc_constants.asm" INCLUDE "constants/battle_anim_constants.asm" INCLUDE "constants/menu_constants.asm" INCLUDE "constants/wram_constants.asm" +INCLUDE "constants/sgb_constants.asm" +INCLUDE "constants/map_object_constants.asm" diff --git a/constants/item_data_constants.asm b/constants/item_data_constants.asm index 297ffc5..bf8516d 100755 --- a/constants/item_data_constants.asm +++ b/constants/item_data_constants.asm @@ -42,4 +42,88 @@ NUM_POCKETS EQU const_value MAX_ITEMS EQU 20
MAX_KEY_ITEMS EQU 20
-MAX_PC_ITEMS EQU 50
\ No newline at end of file +MAX_PC_ITEMS EQU 50
+
+; held item effects
+ const_def
+ const HELD_NONE
+ const HELD_BERRY
+ const HELD_2
+ const HELD_LEFTOVERS
+ const HELD_4
+ const HELD_5
+ const HELD_RESTORE_PP
+ const HELD_RESTORE_ALL_PP
+ const HELD_CLEANSE_TAG
+
+ const_def 10
+ const HELD_HEAL_POISON
+ const HELD_HEAL_FREEZE
+ const HELD_HEAL_BURN
+ const HELD_HEAL_SLEEP
+ const HELD_HEAL_PARALYZE
+ const HELD_HEAL_STATUS
+ const HELD_HEAL_CONFUSION
+
+ const_def 20
+ const HELD_PREVENT_POISON
+ const HELD_PREVENT_BURN
+ const HELD_PREVENT_FREEZE
+ const HELD_PREVENT_SLEEP
+ const HELD_PREVENT_PARALYZE
+ const HELD_PREVENT_CONFUSE
+
+ const_def 30
+ const HELD_30
+ const HELD_ATTACK_UP
+ const HELD_DEFENSE_UP
+ const HELD_SPEED_UP
+ const HELD_SP_ATTACK_UP
+ const HELD_SP_DEFENSE_UP
+ const HELD_ACCURACY_UP
+ const HELD_EVASION_UP
+ const HELD_38
+
+ const_def 40
+ const HELD_40
+ const HELD_41
+ const HELD_METAL_POWDER
+ const HELD_43
+ const HELD_44
+ const HELD_45
+ const HELD_46
+ const HELD_47
+ const HELD_48
+
+ const_def 50
+ const HELD_NORMAL_BOOST
+ const HELD_FIGHTING_BOOST
+ const HELD_FLYING_BOOST
+ const HELD_POISON_BOOST
+ const HELD_GROUND_BOOST
+ const HELD_ROCK_BOOST
+ const HELD_BUG_BOOST
+ const HELD_GHOST_BOOST
+ const HELD_FIRE_BOOST
+ const HELD_WATER_BOOST
+ const HELD_GRASS_BOOST
+ const HELD_ELECTRIC_BOOST
+ const HELD_PSYCHIC_BOOST
+ const HELD_ICE_BOOST
+ const HELD_DRAGON_BOOST
+ const HELD_DARK_BOOST
+ const HELD_STEEL_BOOST
+
+ const_def 70
+ const HELD_CATCH_CHANCE
+ const HELD_71
+ const HELD_ESCAPE
+ const HELD_CRITICAL_UP
+ const HELD_QUICK_CLAW
+ const HELD_FLINCH
+ const HELD_AMULET_COIN
+ const HELD_BRIGHTPOWDER
+ const HELD_78
+ const HELD_FOCUS_BAND
+
+
diff --git a/constants/map_object_constants.asm b/constants/map_object_constants.asm new file mode 100644 index 0000000..c9bce93 --- /dev/null +++ b/constants/map_object_constants.asm @@ -0,0 +1,72 @@ + rsreset +OBJECT_SPRITE rb 1 ; 00 +OBJECT_MAP_OBJECT_INDEX rb 1 ; 01 +OBJECT_SPRITE_TILE rb 1 ; 02 +OBJECT_MOVEMENTTYPE rb 1 ; 03 +OBJECT_FLAGS rw 1 ; 04 +OBJECT_PALETTE rb 1 ; 06 +OBJECT_DIRECTION_WALKING rb 1 ; 07 +OBJECT_FACING rb 1 ; 08 +OBJECT_STEP_TYPE rb 1 ; 09 +OBJECT_STEP_DURATION rb 1 ; 0a +OBJECT_ACTION rb 1 ; 0b +OBJECT_STEP_FRAME rb 1 ; 0c +OBJECT_FACING_STEP rb 1 ; 0d +OBJECT_NEXT_TILE rb 1 ; 0e +OBJECT_STANDING_TILE rb 1 ; 0f +OBJECT_NEXT_MAP_X rb 1 ; 10 +OBJECT_NEXT_MAP_Y rb 1 ; 11 +OBJECT_MAP_X rb 1 ; 12 +OBJECT_MAP_Y rb 1 ; 13 +OBJECT_INIT_X rb 1 ; 14 +OBJECT_INIT_Y rb 1 ; 15 +OBJECT_RADIUS rb 1 ; 16 +OBJECT_SPRITE_X rb 1 ; 17 +OBJECT_SPRITE_Y rb 1 ; 18 +OBJECT_SPRITE_X_OFFSET rb 1 ; 19 +OBJECT_SPRITE_Y_OFFSET rb 1 ; 1a +OBJECT_MOVEMENT_BYTE_INDEX rb 1 ; 1b +OBJECT_1C rb 1 ; 1c +OBJECT_1D rb 1 ; 1d +OBJECT_1E rb 1 ; 1e +OBJECT_1F rb 1 ; 1f +OBJECT_RANGE rb 1 ; 20 +OBJECT_DATA rb 7 ; 21 +OBJECT_LENGTH SET _RS + + rsreset +CMDQUEUE_UNK0 rb 16 +CMDQUEUE_ENTRY_SIZE SET _RS + + rsreset +MAPOBJECT_OBJECT_STRUCT_ID rb 1 ; 0 +MAPOBJECT_SPRITE rb 1 ; 1 +MAPOBJECT_Y_COORD rb 1 ; 2 +MAPOBJECT_X_COORD rb 1 ; 3 +MAPOBJECT_MOVEMENT rb 1 ; 4 +MAPOBJECT_RADIUS rb 1 ; 5 +MAPOBJECT_HOUR rb 1 ; 6 +MAPOBJECT_TIMEOFDAY rb 1 ; 7 +MAPOBJECT_COLOR rb 1 ; 8 +MAPOBJECT_RANGE rb 1 ; 9 +MAPOBJECT_SCRIPT_POINTER rb 1 ; a +MAPOBJECT_POINTER_HI rb 1 ; b +MAPOBJECT_EVENT_FLAG rw 1 +MAPOBJECT_E rb 1 ; unused +MAPOBJECT_F rb 1 ; unused +MAP_OBJECT_LENGTH SET _RS + + rsreset +MAPOBJECTTEMPLATE_SPRITE rb 1 ; 0 +MAPOBJECTTEMPLATE_Y_COORD rb 1 ; 1 +MAPOBJECTTEMPLATE_X_COORD rb 1 ; 2 +MAPOBJECTTEMPLATE_MOVEMENT rb 1 ; 3 +MAPOBJECTTEMPLATE_RADIUS rb 1 ; 4 +MAPOBJECTTEMPLATE_HOUR rb 1 ; 5 +MAPOBJECTTEMPLATE_TIMEOFDAY rb 1 ; 6 +MAPOBJECTTEMPLATE_COLOR rb 1 ; 7 +MAPOBJECTTEMPLATE_RANGE rb 1 ; 8 +MAPOBJECTTEMPLATE_SCRIPT_POINTER rb 1 ; 9 +MAPOBJECTTEMPLATE_POINTER_HI rb 1 ; a +MAPOBJECTTEMPLATE_EVENT_FLAG rw 1 ; b +MAP_OBJECT_TEMPLATE_LENGTH SET _RS diff --git a/constants/sgb_constants.asm b/constants/sgb_constants.asm new file mode 100644 index 0000000..69fe02f --- /dev/null +++ b/constants/sgb_constants.asm @@ -0,0 +1,150 @@ +; GetSGBLayout arguments (see engine/gfx/cgb_layouts.asm and engine/gfx/sgb_layouts.asm) + const_def + const SGB_BATTLE_GRAYSCALE + const SGB_BATTLE_COLORS + const SGB_POKEGEAR_PALS + const SGB_STATS_SCREEN_HP_PALS + const SGB_POKEDEX + const SGB_SLOT_MACHINE + const SGB_06 + const SGB_GS_INTRO + const SGB_DIPLOMA + const SGB_MAPPALS + const SGB_PARTY_MENU + const SGB_EVOLUTION + const SGB_GS_TITLE_SCREEN + const SGB_0D + const SGB_MOVE_LIST + const SGB_BETA_PIKACHU_MINIGAME + const SGB_POKEDEX_SEARCH_OPTION + const SGB_BETA_POKER + const SGB_POKEPIC + const SGB_13 + const SGB_PACKPALS + const SGB_TRAINER_CARD + const SGB_POKEDEX_UNOWN_MODE + const SGB_BILLS_PC + const SGB_UNOWN_PUZZLE + const SGB_GAMEFREAK_LOGO + const SGB_PLAYER_OR_MON_FRONTPIC_PALS + const SGB_TRADE_TUBE + const SGB_TRAINER_OR_MON_FRONTPIC_PALS + const SGB_MYSTERY_GIFT + const SGB_1E + +SGB_PARTY_MENU_HP_PALS EQU -4 +SGB_RAM EQU -1 + +; PredefPals indexes (see gfx/sgb/predef.pal) +; GetPredefPal arguments (see engine/gfx/color.asm) + const_def + const PREDEFPAL_00 + const PREDEFPAL_PALLET + const PREDEFPAL_VIRIDIAN + const PREDEFPAL_PEWTER + const PREDEFPAL_CERULEAN + const PREDEFPAL_LAVENDER + const PREDEFPAL_VERMILION + const PREDEFPAL_CELADON + const PREDEFPAL_FUCHSIA + const PREDEFPAL_CINNABAR + const PREDEFPAL_SAFFRON + const PREDEFPAL_INDIGO + const PREDEFPAL_NEW_BARK + const PREDEFPAL_CHERRYGROVE + const PREDEFPAL_VIOLET + const PREDEFPAL_AZALEA + const PREDEFPAL_GOLDENROD + const PREDEFPAL_ECRUTEAK + const PREDEFPAL_OLIVINE + const PREDEFPAL_CIANWOOD + const PREDEFPAL_MAHOGANY + const PREDEFPAL_BLACKTHORN + const PREDEFPAL_LAKE_OF_RAGE + const PREDEFPAL_SILVER_CAVE + const PREDEFPAL_DUNGEONS + const PREDEFPAL_NITE + const PREDEFPAL_BLACKOUT + const PREDEFPAL_DIPLOMA ; RB_MEWMON + const PREDEFPAL_TRADE_TUBE ; RB_BLUEMON + const PREDEFPAL_POKEDEX ; RB_REDMON + const PREDEFPAL_RB_CYANMON + const PREDEFPAL_RB_PURPLEMON + const PREDEFPAL_RB_BROWNMON + const PREDEFPAL_RB_GREENMON + const PREDEFPAL_RB_PINKMON + const PREDEFPAL_RB_YELLOWMON + const PREDEFPAL_CGB_BADGE ; RB_GREYMON + const PREDEFPAL_BETA_SHINY_MEWMON + const PREDEFPAL_BETA_SHINY_BLUEMON + const PREDEFPAL_BETA_SHINY_REDMON + const PREDEFPAL_BETA_SHINY_CYANMON + const PREDEFPAL_BETA_SHINY_PURPLEMON + const PREDEFPAL_BETA_SHINY_BROWNMON + const PREDEFPAL_BETA_SHINY_GREENMON + const PREDEFPAL_BETA_SHINY_PINKMON + const PREDEFPAL_BETA_SHINY_YELLOWMON + const PREDEFPAL_PARTY_ICON ; BETA_SHINY_GREYMON + const PREDEFPAL_HP_GREEN + const PREDEFPAL_HP_YELLOW + const PREDEFPAL_HP_RED + const PREDEFPAL_POKEGEAR + const PREDEFPAL_BETA_LOGO_1 + const PREDEFPAL_BETA_LOGO_2 + const PREDEFPAL_GS_INTRO_GAMEFREAK_LOGO + const PREDEFPAL_GS_INTRO_SHELLDER_LAPRAS + const PREDEFPAL_BETA_INTRO_LAPRAS + const PREDEFPAL_GS_INTRO_JIGGLYPUFF_PIKACHU_BG + const PREDEFPAL_GS_INTRO_JIGGLYPUFF_PIKACHU_OB + const PREDEFPAL_GS_INTRO_STARTERS_TRANSITION + const PREDEFPAL_BETA_INTRO_VENUSAUR + const PREDEFPAL_PACK ; GS_INTRO_CHARIZARD + const PREDEFPAL_SLOT_MACHINE_0 + const PREDEFPAL_SLOT_MACHINE_1 + const PREDEFPAL_SLOT_MACHINE_2 + const PREDEFPAL_SLOT_MACHINE_3 + const PREDEFPAL_BETA_POKER_0 + const PREDEFPAL_BETA_POKER_1 + const PREDEFPAL_BETA_POKER_2 + const PREDEFPAL_BETA_POKER_3 + const PREDEFPAL_BETA_RADIO + const PREDEFPAL_BETA_POKEGEAR + const PREDEFPAL_47 + const PREDEFPAL_GS_TITLE_SCREEN_0 + const PREDEFPAL_GS_TITLE_SCREEN_1 + const PREDEFPAL_GS_TITLE_SCREEN_2 + const PREDEFPAL_GS_TITLE_SCREEN_3 + const PREDEFPAL_UNOWN_PUZZLE + const PREDEFPAL_4D + const PREDEFPAL_GAMEFREAK_LOGO + +; SGB system command codes +; http://gbdev.gg8.se/wiki/articles/SGB_Functions#SGB_System_Command_Table + const_def + const SGB_PAL01 + const SGB_PAL23 + const SGB_PAL03 + const SGB_PAL12 + const SGB_ATTR_BLK + const SGB_ATTR_LIN + const SGB_ATTR_DIV + const SGB_ATTR_CHR + const SGB_SOUND + const SGB_SOU_TRN + const SGB_PAL_SET + const SGB_PAL_TRN + const SGB_ATRC_EN + const SGB_TEST_EN + const SGB_ICON_EN + const SGB_DATA_SND + const SGB_DATA_TRN + const SGB_MLT_REG + const SGB_JUMP + const SGB_CHR_TRN + const SGB_PCT_TRN + const SGB_ATTR_TRN + const SGB_ATTR_SET + const SGB_MASK_EN + const SGB_OBJ_TRN + +PALPACKET_LENGTH EQU $10 diff --git a/data/items/attributes.asm b/data/items/attributes.asm new file mode 100644 index 0000000..4308b44 --- /dev/null +++ b/data/items/attributes.asm @@ -0,0 +1,520 @@ +include "constants.asm" + +item_attribute: MACRO +; price, held effect, parameter, property, pocket, field menu, battle menu + dw \1 + db \2, \3, \4, \5 + dn \6, \7 +ENDM + +SECTION "Item Attributes", ROMX [$68f3], BANK [$01] + +ItemAttributes:: ; 68f3 +; ITEM_MASTER_BALL + item_attribute 0, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_CLOSE +; ITEM_ULTRA_BALL + item_attribute 1200, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_CLOSE +; ITEM_03 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_GREAT_BALL + item_attribute 600, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_CLOSE +; ITEM_POKE_BALL + item_attribute 200, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_CLOSE +; ITEM_TOWN_MAP + item_attribute 0, HELD_NONE, 0, CANT_TOSS, KEY_ITEM, ITEMMENU_CLOSE, ITEMMENU_NOUSE +; ITEM_BICYCLE + item_attribute 0, HELD_NONE, 0, CANT_TOSS, KEY_ITEM, ITEMMENU_CLOSE, ITEMMENU_NOUSE +; ITEM_MOON_STONE + item_attribute 0, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_NOUSE +; ITEM_ANTIDOTE + item_attribute 100, HELD_HEAL_POISON, 0, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_BURN_HEAL + item_attribute 250, HELD_HEAL_FREEZE, 0, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_ICE_HEAL + item_attribute 250, HELD_HEAL_BURN, 0, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_AWAKENING + item_attribute 250, HELD_HEAL_SLEEP, 0, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_PARLYZ_HEAL + item_attribute 200, HELD_HEAL_PARALYZE, 0, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_FULL_RESTORE + item_attribute 3000, HELD_2, 255, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_MAX_POTION + item_attribute 2500, HELD_BERRY, 255, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_HYPER_POTION + item_attribute 1200, HELD_BERRY, 200, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_SUPER_POTION + item_attribute 700, HELD_BERRY, 50, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_POTION + item_attribute 300, HELD_BERRY, 20, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_ESCAPE_ROPE + item_attribute 550, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_CLOSE, ITEMMENU_NOUSE +; ITEM_REPEL + item_attribute 350, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_CURRENT, ITEMMENU_NOUSE +; ITEM_MAX_ELIXER + item_attribute 4800, HELD_RESTORE_ALL_PP, 255, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_FIRE_STONE + item_attribute 2100, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_NOUSE +; ITEM_THUNDERSTONE + item_attribute 2100, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_NOUSE +; ITEM_WATER_STONE + item_attribute 2100, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_NOUSE +; ITEM_19 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_HP_UP + item_attribute 9800, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_NOUSE +; ITEM_PROTEIN + item_attribute 9800, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_NOUSE +; ITEM_IRON + item_attribute 9800, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_NOUSE +; ITEM_CARBOS + item_attribute 9800, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_NOUSE +; ITEM_1E + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_CALCIUM + item_attribute 9800, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_NOUSE +; ITEM_RARE_CANDY + item_attribute 4800, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_NOUSE +; ITEM_X_ACCURACY + item_attribute 950, HELD_ACCURACY_UP, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_CLOSE +; ITEM_LEAF_STONE + item_attribute 2100, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_NOUSE +; ITEM_23 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_NUGGET + item_attribute 10000, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_POKE_DOLL + item_attribute 1000, HELD_ESCAPE, 0, CANT_SELECT, ITEM, ITEMMENU_CLOSE, ITEMMENU_NOUSE +; ITEM_FULL_HEAL + item_attribute 600, HELD_HEAL_STATUS, 0, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_REVIVE + item_attribute 1500, HELD_5, 50, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_MAX_REVIVE + item_attribute 4000, HELD_5, 100, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_GUARD_SPEC + item_attribute 700, HELD_SP_DEFENSE_UP, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_CLOSE +; ITEM_SUPER_REPEL + item_attribute 500, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_CURRENT, ITEMMENU_NOUSE +; ITEM_MAX_REPEL + item_attribute 700, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_CURRENT, ITEMMENU_NOUSE +; ITEM_DIRE_HIT + item_attribute 650, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_CLOSE +; ITEM_2D + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_FRESH_WATER + item_attribute 200, HELD_BERRY, 50, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_SODA_POP + item_attribute 300, HELD_BERRY, 60, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_LEMONADE + item_attribute 350, HELD_BERRY, 80, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_X_ATTACK + item_attribute 500, HELD_ATTACK_UP, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_CLOSE +; ITEM_32 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_X_DEFEND + item_attribute 550, HELD_DEFENSE_UP, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_CLOSE +; ITEM_X_SPEED + item_attribute 350, HELD_SPEED_UP, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_CLOSE +; ITEM_X_SPECIAL + item_attribute 350, HELD_SP_ATTACK_UP, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_CLOSE +; ITEM_COIN_CASE + item_attribute 0, HELD_NONE, 0, CANT_TOSS, KEY_ITEM, ITEMMENU_CURRENT, ITEMMENU_NOUSE +; ITEM_ITEMFINDER + item_attribute 0, HELD_NONE, 0, CANT_TOSS, KEY_ITEM, ITEMMENU_CLOSE, ITEMMENU_NOUSE +; ITEM_POKE_FLUTE + item_attribute 0, HELD_NONE, 0, CANT_SELECT | CANT_TOSS, KEY_ITEM, ITEMMENU_CLOSE, ITEMMENU_CURRENT +; ITEM_EXP_SHARE + item_attribute 0, HELD_NONE, 0, CANT_SELECT | CANT_TOSS, KEY_ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_OLD_ROD + item_attribute 0, HELD_NONE, 0, CANT_TOSS, KEY_ITEM, ITEMMENU_CLOSE, ITEMMENU_NOUSE +; ITEM_GOOD_ROD + item_attribute 0, HELD_NONE, 0, CANT_TOSS, KEY_ITEM, ITEMMENU_CLOSE, ITEMMENU_NOUSE +; ITEM_3C + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_SUPER_ROD + item_attribute 0, HELD_NONE, 0, CANT_TOSS, KEY_ITEM, ITEMMENU_CLOSE, ITEMMENU_NOUSE +; ITEM_PP_UP + item_attribute 9800, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_NOUSE +; ITEM_ETHER + item_attribute 1200, HELD_RESTORE_PP, 10, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_MAX_ETHER + item_attribute 2400, HELD_RESTORE_PP, 255, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_ELIXER + item_attribute 2400, HELD_RESTORE_ALL_PP, 10, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_MYSTIC_PETAL + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_WHITE_FEATHER + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_CONFUSE_CLAW + item_attribute 10, HELD_78, 15, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_WISDOM_ORB + item_attribute 10, HELD_45, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_STEEL_SHELL + item_attribute 10, HELD_METAL_POWDER, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_UP_GRADE + item_attribute 10, HELD_48, 10, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_STRANGE_THREAD + item_attribute 10, HELD_BRIGHTPOWDER, 30, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_BIG_LEAF + item_attribute 10, HELD_GRASS_BOOST, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_QUICK_NEEDLE + item_attribute 10, HELD_QUICK_CLAW, 30, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_4B + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_SHARP_STONE + item_attribute 10, HELD_ROCK_BOOST, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_BLACK_FEATHER + item_attribute 10, HELD_FLYING_BOOST, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_SHARP_FANG + item_attribute 10, HELD_NORMAL_BOOST, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_SNAKESKIN + item_attribute 10, HELD_PREVENT_POISON, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_ELECTRIC_POUCH + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_TOXIC_NEEDLE + item_attribute 10, HELD_POISON_BOOST, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_KINGS_ROCK + item_attribute 10, HELD_FLINCH, 30, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_STRANGE_POWER + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_LIFE_TAG + item_attribute 10, HELD_4, 1, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_POISON_FANG + item_attribute 10, HELD_POISON_BOOST, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_CORDYCEPS + item_attribute 10000, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_DRAGON_FANG + item_attribute 10, HELD_DRAGON_BOOST, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_SILVERPOWDER + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_DIGGING_CLAW + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_5A + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_AMULET_COIN + item_attribute 10, HELD_AMULET_COIN, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_MIGRAINE_SEED + item_attribute 10, HELD_PSYCHIC_BOOST, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_COUNTER_CUFF + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_TALISMAN_TAG + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_STRANGE_WATER + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_TWISTEDSPOON + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_ATTACK_NEEDLE + item_attribute 10, HELD_BUG_BOOST, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_POWER_BRACER + item_attribute 10, HELD_FIGHTING_BOOST, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_HARD_STONE + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_64 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_JIGGLING_BALLOON + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_FIRE_MANE + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_SLOWPOKETAIL + item_attribute 10000, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_EARTH + item_attribute 10, HELD_PREVENT_PARALYZE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_STICK + item_attribute 10, HELD_NORMAL_BOOST, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_FLEE_FEATHER + item_attribute 10, HELD_71, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_ICE_FANG + item_attribute 10, HELD_ICE_BOOST, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_FOSSIL_SHARD + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_GROSS_GARBAGE + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_BIG_PEARL + item_attribute 15000, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_CHAMPION_BELT + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_TAG + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_SPELL_TAG + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_5_YEN_COIN + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_GUARD_THREAD + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_STIMULUS_ORB + item_attribute 10, HELD_PREVENT_SLEEP, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_CALM_BERRY + item_attribute 10, HELD_PREVENT_CONFUSE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_THICK_CLUB + item_attribute 10, HELD_GROUND_BOOST, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_FOCUS_ORB + item_attribute 10, HELD_FOCUS_BAND, 30, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_78 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_DETECT_ORB + item_attribute 10, HELD_EVASION_UP, 30, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_LONG_TONGUE + item_attribute 10, HELD_CATCH_CHANCE, 10, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_LOTTO_TICKET + item_attribute 10, HELD_NONE, 0, CANT_SELECT | CANT_TOSS, KEY_ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_EVERSTONE + item_attribute 0, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_SHARP_HORN + item_attribute 10, HELD_41, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_LUCKY_EGG + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_LONG_VINE + item_attribute 10, HELD_CATCH_CHANCE, 10, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_MOMS_LOVE + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_SMOKESCREEN + item_attribute 10, HELD_ESCAPE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_WET_HORN + item_attribute 10, HELD_WATER_BOOST, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_SKATEBOARD + item_attribute 0, HELD_NONE, 0, CANT_TOSS, KEY_ITEM, ITEMMENU_CLOSE, ITEMMENU_NOUSE +; ITEM_CRIMSON_JEWEL + item_attribute 12000, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_INVISIBLE_WALL + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_SHARP_SCYTHE + item_attribute 10, HELD_CRITICAL_UP, 30, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_87 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_ICE_BIKINI + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_THUNDER_FANG + item_attribute 10, HELD_ELECTRIC_BOOST, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_FIRE_CLAW + item_attribute 10, HELD_FIRE_BOOST, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_TWIN_HORNS + item_attribute 10, HELD_41, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_SPIKE + item_attribute 10, HELD_GHOST_BOOST, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_BERRY + item_attribute 100, HELD_BERRY, 20, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_APPLE + item_attribute 300, HELD_BERRY, 50, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_METAL_COAT + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_PRETTY_TAIL + item_attribute 10, HELD_PREVENT_POISON, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_WATER_TAIL + item_attribute 10, HELD_PREVENT_BURN, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_LEFTOVERS + item_attribute 10, HELD_LEFTOVERS, 30, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_ICE_WING + item_attribute 10, HELD_45, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_THUNDER_WING + item_attribute 10, HELD_43, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_FIRE_WING + item_attribute 10, HELD_SP_ATTACK_UP, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_96 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_DRAGON_SCALE + item_attribute 10, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_BERSERK_GENE + item_attribute 10, HELD_48, 20, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_HEART_STONE + item_attribute 2100, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_NOUSE +; ITEM_FIRE_TAIL + item_attribute 10, HELD_PREVENT_FREEZE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_THUNDER_TAIL + item_attribute 10, HELD_PREVENT_PARALYZE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_SACRED_ASH + item_attribute 10, HELD_5, 255, CANT_SELECT, ITEM, ITEMMENU_CLOSE, ITEMMENU_CLOSE +; ITEM_TM_HOLDER + item_attribute 0, HELD_NONE, 0, CANT_SELECT | CANT_TOSS, ITEM, 1, 1 +; ITEM_MAIL + item_attribute 0, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_BALL_HOLDER + item_attribute 0, HELD_NONE, 0, CANT_SELECT | CANT_TOSS, ITEM, 2, 2 +; ITEM_BAG + item_attribute 0, HELD_NONE, 0, CANT_SELECT | CANT_TOSS, KEY_ITEM, 3, 3 +; ITEM_IMPORTANT_BAG + item_attribute 0, HELD_NONE, 0, CANT_SELECT | CANT_TOSS, ITEM, 3, 3 +; ITEM_POISON_STONE + item_attribute 2100, HELD_NONE, 0, CANT_SELECT, ITEM, ITEMMENU_PARTY, ITEMMENU_NOUSE +; ITEM_A3 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_A4 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_A5 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_A6 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_A7 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_A8 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_A9 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_AA + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_AB + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_AC + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_AD + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_AE + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_AF + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_B0 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_B1 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_B2 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_B3 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_B4 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_B5 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_B6 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_B7 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_B8 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_B9 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_BA + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_BB + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_BC + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_BD + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_BE + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_BF + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_C0 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_C1 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_C2 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_C3 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_TM01 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM02 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM03 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM04 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_C8 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_TM05 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM06 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM07 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM08 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM09 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM10 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM11 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM12 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM13 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM14 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM15 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM16 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM17 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM18 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM19 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM20 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM21 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM22 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM23 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM24 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM25 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM26 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM27 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM28 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_E1 + item_attribute 0, HELD_NONE, 0, NO_LIMITS, 0, ITEMMENU_NOUSE, ITEMMENU_NOUSE +; ITEM_TM29 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM30 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM31 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM32 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM33 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM34 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM35 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM36 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM37 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM38 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM39 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM40 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM41 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM42 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM43 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM44 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM45 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM46 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM47 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM48 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM49 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_TM50 + item_attribute 1000, HELD_NONE, 0, CANT_SELECT, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_HM01 + item_attribute 0, HELD_NONE, 0, CANT_SELECT | CANT_TOSS, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_HM02 + item_attribute 0, HELD_NONE, 0, CANT_SELECT | CANT_TOSS, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_HM03 + item_attribute 0, HELD_NONE, 0, CANT_SELECT | CANT_TOSS, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_HM04 + item_attribute 0, HELD_NONE, 0, CANT_SELECT | CANT_TOSS, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_HM05 + item_attribute 0, HELD_NONE, 0, CANT_SELECT | CANT_TOSS, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_HM06 + item_attribute 0, HELD_NONE, 0, CANT_SELECT | CANT_TOSS, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY +; ITEM_HM07 + item_attribute 0, HELD_NONE, 0, CANT_SELECT | CANT_TOSS, TM_HM, ITEMMENU_PARTY, ITEMMENU_PARTY diff --git a/data/predef_pointers.inc b/data/predef_pointers.inc index 0b980b5..0b39ae2 100644 --- a/data/predef_pointers.inc +++ b/data/predef_pointers.inc @@ -43,7 +43,7 @@ GiveItemPredef:: add_predef LinkTextboxAtHL add_predef Function2d663 add_predef Function3d5ce - add_predef Function3f019 + add_predef PlaceGraphic add_predef Function3f068 ; 20 add_predef Function3f04a add_predef Function3d08c diff --git a/engine/battle_anims/bg_effects.asm b/engine/battle_anims/bg_effects.asm index 746c979..7e51b03 100644 --- a/engine/battle_anims/bg_effects.asm +++ b/engine/battle_anims/bg_effects.asm @@ -2357,7 +2357,7 @@ BGEffect_CheckFlyDigStatus: ; c8ccc (32:4ccc) ret BattleBGEffects_CheckSGB: ; c8ce3 (32:4ce3) - ld a, [wcccf] + ld a, [wSGB] and a ret diff --git a/engine/math/math.asm b/engine/math/math.asm new file mode 100644 index 0000000..4395009 --- /dev/null +++ b/engine/math/math.asm @@ -0,0 +1,200 @@ +include "constants.asm" + +SECTION "Multiply and Divide Engine", ROMX [$6810], BANK [$1] + +_Multiply:: ; 6810 + +; hMultiplier is one byte. + ld a, 8 + ld b, a + + xor a + ldh [hProduct], a + ldh [hMathBuffer + 1], a + ldh [hMathBuffer + 2], a + ldh [hMathBuffer + 3], a + ldh [hMathBuffer + 4], a + + +.loop + ldh a, [hMultiplier] + srl a + ldh [hMultiplier], a + jr nc, .next + + ldh a, [hMathBuffer + 4] + ld c, a + ldh a, [hMultiplicand + 2] + add c + ldh [hMathBuffer + 4], a + + ldh a, [hMathBuffer + 3] + ld c, a + ldh a, [hMultiplicand + 1] + adc c + ldh [hMathBuffer + 3], a + + ldh a, [hMathBuffer + 2] + ld c, a + ldh a, [hMultiplicand + 0] + adc c + ldh [hMathBuffer + 2], a + + ldh a, [hMathBuffer + 1] + ld c, a + ldh a, [hProduct] + adc c + ldh [hMathBuffer + 1], a + +.next + dec b + jr z, .done + + +; hMultiplicand <<= 1 + + ldh a, [hMultiplicand + 2] + add a + ldh [hMultiplicand + 2], a + + ldh a, [hMultiplicand + 1] + rla + ldh [hMultiplicand + 1], a + + ldh a, [hMultiplicand + 0] + rla + ldh [hMultiplicand + 0], a + + ldh a, [hProduct] + rla + ldh [hProduct], a + + jr .loop + + +.done + ldh a, [hMathBuffer + 4] + ldh [hProduct + 3], a + + ldh a, [hMathBuffer + 3] + ldh [hProduct + 2], a + + ldh a, [hMathBuffer + 2] + ldh [hProduct + 1], a + + ldh a, [hMathBuffer + 1] + ldh [hProduct + 0], a + + ret +; 6870 + + +_Divide:: ; 6870 + xor a + ldh [hMathBuffer + 0], a + ldh [hMathBuffer + 1], a + ldh [hMathBuffer + 2], a + ldh [hMathBuffer + 3], a + ldh [hMathBuffer + 4], a + + ld a, 9 + ld e, a + +.loop + ldh a, [hMathBuffer + 0] + ld c, a + ldh a, [hDividend + 1] + sub c + ld d, a + + ldh a, [hDivisor] + ld c, a + ldh a, [hDividend + 0] + sbc c + jr c, .next + + ldh [hDividend + 0], a + + ld a, d + ldh [hDividend + 1], a + + ldh a, [hMathBuffer + 4] + inc a + ldh [hMathBuffer + 4], a + + jr .loop + +.next + ld a, b + cp 1 + jr z, .done + + ldh a, [hMathBuffer + 4] + add a + ldh [hMathBuffer + 4], a + + ldh a, [hMathBuffer + 3] + rla + ldh [hMathBuffer + 3], a + + ldh a, [hMathBuffer + 2] + rla + ldh [hMathBuffer + 2], a + + ldh a, [hMathBuffer + 1] + rla + ldh [hMathBuffer + 1], a + + dec e + jr nz, .next2 + + ld e, 8 + ldh a, [hMathBuffer + 0] + ldh [hDivisor], a + xor a + ldh [hMathBuffer + 0], a + + ldh a, [hDividend + 1] + ldh [hDividend + 0], a + + ldh a, [hDividend + 2] + ldh [hDividend + 1], a + + ldh a, [hDividend + 3] + ldh [hDividend + 2], a + +.next2 + ld a, e + cp 1 + jr nz, .okay + dec b + +.okay + ldh a, [hDivisor] + srl a + ldh [hDivisor], a + + ldh a, [hMathBuffer + 0] + rr a + ldh [hMathBuffer + 0], a + + jr .loop + +.done + ldh a, [hDividend + 1] + ldh [hDivisor], a + + ldh a, [hMathBuffer + 4] + ldh [hDividend + 3], a + + ldh a, [hMathBuffer + 3] + ldh [hDividend + 2], a + + ldh a, [hMathBuffer + 2] + ldh [hDividend + 1], a + + ldh a, [hMathBuffer + 1] + ldh [hDividend + 0], a + + ret +; 68f3 diff --git a/engine/title.asm b/engine/title.asm index e90bafc..7f9d707 100644 --- a/engine/title.asm +++ b/engine/title.asm @@ -24,7 +24,7 @@ TitleSequenceStart:: call TitleScreenMain jr nc, .loop - call ClearPalettesAndWait + call ClearBGPalettes call ClearSprites ld a, $01 ldh [hBGMapMode], a diff --git a/home/map.asm b/home/map.asm index 3aa0c84..b8ddee5 100644 --- a/home/map.asm +++ b/home/map.asm @@ -27,7 +27,7 @@ RunMapScript:: ; 20ff ret ; TODO: is this used? -WriteIntod637:: ; 2118 +WriteIntod637:: ; 2117 push af ; TODO: figure out what variables are concerned here @@ -888,8 +888,8 @@ ReadObjectEvents:: ; 268f ClearObjectStructs:: ; 26cf xor a - ld [$CE7F], a ; TODO - ld hl, wObject1Struct + ld [wUnkObjectStruct], a ; TODO + ld hl, wObject2Struct ld de, wObject2Struct - wObject1Struct ld c, 7 .clear_struct diff --git a/home/map_objects.asm b/home/map_objects.asm new file mode 100644 index 0000000..70cba50 --- /dev/null +++ b/home/map_objects.asm @@ -0,0 +1,676 @@ +include "constants.asm" + +SECTION "Map Object Related Functions", ROM0 [$15b5] + +Function15b5:: ; 15b5 + callab Function8000 + ret + +GetMapObject:: ; 00:15be + ld hl, wMapObjects + ld bc, MAP_OBJECT_LENGTH + call AddNTimes + ld b, h + ld c, l + ret + +GetMapObjectAttrPtr:: ; 15ca + call GetMapObject + ld d, $0 + add hl, de + ret + +Function15d1:: ; 15d1 + ldh [hMapObjectIndexBuffer], a + call GetMapObject + call Function40eb + ret + +Function15da:: + ldh [hMapObjectIndexBuffer], a + callab Function8131 + ldh a, [hMapObjectIndexBuffer] + call GetMapObject + call Function40eb + ret + +Function15ed:: + ldh [hMapObjectIndexBuffer], a + call GetMapObject + ld a, $0 + ldh [hObjectStructIndexBuffer], a + ld de, wObjectStructs + callab Function813d + ret + +Function1602:: + ldh [hMapObjectIndexBuffer], a + call GetMapObject + ld a, $2 + ldh [hObjectStructIndexBuffer], a + ld de, wObject1Struct + callab Function813d + ret + +Function1617:: ; 00:1617 + ldh [hMapObjectIndexBuffer], a + call GetMapObject + ld hl, MAPOBJECT_OBJECT_STRUCT_ID + add hl, bc + ld a, [hl] + cp $ff + ret z + ld [hl], $ff + push af + ld d, a + ld a, [wObjectFollow_Leader] + cp d + jr nz, .asm_1633 + ld a, $ff + ld [wObjectFollow_Leader], a +.asm_1633: ; 00:1633 + ld a, [wObjectFollow_Follower] + cp d + jr nz, .asm_163e + ld a, $0 + ld [wObjectFollow_Follower], a +.asm_163e: ; 00:163e + pop af + call GetObjectStruct + ld bc, OBJECT_LENGTH + xor a + call ByteFill + ret + +Function164a:: + call Function1617 + callab Function8125 + ret + +Function1656:: + push hl + call GetMapObject + ld d, b + ld e, c + ld a, $ff + ld [de], a + inc de + pop hl + ld bc, MAP_OBJECT_TEMPLATE_LENGTH + call CopyBytes + ret + +Function1668:: + call GetMapObject + ld a, [wXCoord] + add $4 + ld hl, MAPOBJECT_X_COORD + add hl, bc + ld [hl], a + ld a, [wYCoord] + add $4 + ld hl, MAPOBJECT_Y_COORD + add hl, bc + ld [hl], a + ret + +Function1680:: + call CheckObjectVisibility + ret c + ld hl, OBJECT_NEXT_MAP_X + add hl, bc + ld d, [hl] + ld hl, OBJECT_NEXT_MAP_Y + add hl, bc + ld e, [hl] + ldh a, [hMapObjectIndexBuffer] + call GetMapObject + ld hl, MAPOBJECT_X_COORD + add hl, bc + ld [hl], d + ld hl, MAPOBJECT_Y_COORD + add hl, bc + ld [hl], e + and a + ret + +Function169f:: + call GetMapObject + ld hl, MAPOBJECT_OBJECT_STRUCT_ID + add hl, bc + ld a, [hl] + push af + ld [hl], $ff + inc hl + ld bc, MAP_OBJECT_LENGTH - 1 + xor a + call ByteFill + pop af + cp $ff + ret z + cp $a + ret nc + ld b, a + ld a, [wObjectFollow_Leader] + cp b + jr nz, .asm_16c5 + ld a, $ff + ld [wObjectFollow_Leader], a +.asm_16c5: ; 00:16c5 + ld a, b + call GetObjectStruct + ld bc, OBJECT_LENGTH + xor a + call ByteFill + ret + +LoadMovementDataPointer:: + ld [wMovementObject], a + ldh a, [hROMBank] + ld [wMovementDataBank], a + ld a, l + ld [wMovementDataAddr], a + ld a, h + ld [wMovementDataAddr + 1], a + ld a, [wMovementObject] + call CheckObjectVisibility + ret c + ld hl, $3 + add hl, bc + ld [hl], $19 + ld hl, $8 + add hl, bc + ld [hl], $0 + ld hl, wVramState + set 7, [hl] + and a + ret + +Function16fb:: + ld [wMovementObject], a + ldh a, [hROMBank] + ld [wMovementDataBank], a + ld a, l + ld [wMovementDataAddr], a + ld a, h + ld [wMovementDataAddr + 1], a + ld a, [wMovementObject] + call CheckObjectVisibility + jr c, .asm_171f + ld hl, OBJECT_MOVEMENTTYPE + add hl, bc + ld [hl], $19 + ld hl, OBJECT_FACING + add hl, bc + ld [hl], $0 +.asm_171f: ; 00:171f + ret + +CheckObjectVisibility:: ; 00:1720 + ldh [hMapObjectIndexBuffer], a + call GetMapObject + ld hl, MAPOBJECT_OBJECT_STRUCT_ID + add hl, bc + ld a, [hl] + cp $ff + jr z, .asm_1735 + ldh [hObjectStructIndexBuffer], a + call GetObjectStruct + and a + ret + +.asm_1735: ; 00:1735 + scf + ret + +PushToCmdQueue:: ; 1737 + push de + call GetCmdQueueEmptySlot + pop de + ret c + ld b, h + ld c, l + ld a, [de] + inc de + ld hl, $1 + add hl, bc + ld [hl], a + ld a, [de] + inc de + ld hl, $2 + add hl, bc + ld [hl], a + ld a, [de] + inc de + ld hl, $3 + add hl, bc + ld [hl], a + ld a, [de] + inc de + ld hl, $d + add hl, bc + ld [hl], a + ld a, [de] + inc de + ld hl, $e + add hl, bc + ld [hl], a + ld a, [de] + inc de + ld hl, $f + add hl, bc + ld [hl], a + ldh a, [hMapObjectIndexBuffer] + inc a + ld hl, $0 + add hl, bc + ld [hl], a + push bc + dec a + call GetObjectStruct + ld d, b + ld e, c + pop bc + ld hl, $18 + add hl, de + ld a, [hl] + ld hl, $4 + add hl, bc + ld [hl], a + ld hl, $19 + add hl, de + ld a, [hl] + ld hl, $5 + add hl, bc + ld [hl], a + ret + +GetCmdQueueEmptySlot:: ; 00:178e + ld hl, wCmdQueue + ld de, CMDQUEUE_ENTRY_SIZE + ld a, 1 +.asm_1796: ; 00:1796 + ldh [hObjectStructIndexBuffer], a + ld a, [hl] + and a + jr z, .asm_17a6 + add hl, de + ldh a, [hObjectStructIndexBuffer] + inc a + cp 4 + 1 + jr nz, .asm_1796 + scf + ret + +.asm_17a6: ; 00:17a6 + xor a + ret + +UpdateSprites:: ; 00:17a8 + ld a, [wVramState] + bit 0, a + ret z + callab Function5007 + callab Function5190 + ret + +GetObjectStruct:: ; 00:17bf + ld bc, $28 + ld hl, wObjectStructs + call AddNTimes + ld b, h + ld c, l + ret + +Function17cb:: + add $10 + ld e, a + ldh a, [hROMBank] + push af + ld a, BANK(Function862e) + call Bankswitch + call Function862e + pop af + call Bankswitch + ret + +Function17de:: + push hl + push bc + ld c, a + ld b, $ff + ld hl, .Data +.asm_17e6: ; 00:17e6 + ld a, [hli] + cp b + jr z, .asm_17ee + cp c + jr nz, .asm_17e6 + scf +.asm_17ee: ; 00:17ee + pop bc + pop hl + ret + +.Data: ; 00:17f1 + db $51, $55, $56, $57, $58, $5a, $5b, $ff + +Function17f9:: + call GetMapObject + ld hl, $0 + add hl, bc + ld a, [hl] + cp $ff + ret z + call GetObjectStruct + push bc + call Function1828 + pop bc + ld hl, $5 + add hl, bc + res 5, [hl] + ret + +Function1813:: + call GetMapObject + ld hl, $0 + add hl, bc + ld a, [hl] + cp $ff + ret z + call GetObjectStruct + ld hl, $5 + add hl, bc + set 5, [hl] + ret + +Function1828:: ; 00:1828 + ld bc, wObjectStructs + xor a +.asm_182c: ; 00:182c + push af + ld hl, OBJECT_SPRITE + add hl, bc + ld a, [hl] + and a + jr z, .asm_183b + ld hl, OBJECT_FLAGS + 1 + add hl, bc + set 5, [hl] +.asm_183b: ; 00:183b + ld hl, OBJECT_LENGTH + add hl, bc + ld b, h + ld c, l + pop af + inc a + cp 10 + jr nz, .asm_182c + ret + +Function1848:: + push bc + ld bc, wObjectStructs + xor a +.asm_184d: ; 00:184d + push af + ld hl, OBJECT_SPRITE + add hl, bc + ld a, [hl] + and a + jr z, .asm_185c + ld hl, OBJECT_FLAGS + 1 + add hl, bc + res 5, [hl] +.asm_185c: ; 00:185c + ld hl, OBJECT_LENGTH + add hl, bc + ld b, h + ld c, l + pop af + inc a + cp 10 + jr nz, .asm_184d + pop bc + ret + +Function186a:: + call GetMapObject + ld hl, $0 + add hl, bc + ld a, [hl] + cp $ff + ret z + call GetObjectStruct + ld hl, OBJECT_FLAGS + 1 + add hl, bc + res 5, [hl] + ret + +Function187f:: + xor a +.asm_1880: ; 00:1880 + push af + push hl + ld b, a + ldh a, [hROMBank] + push af + ld c, [hl] + inc hl + ld a, [hli] + ld h, [hl] + ld l, a + ld a, c + call Bankswitch + ld a, b + call ._hl_ + pop af + call Bankswitch + pop hl + pop af + inc a + cp 16 + jr nz, .asm_1880 + ret + +._hl_: ; 00:189f + jp hl + +Function18a0:: + ld a, [wcb70] + and a + ret z + ldh a, [hROMBank] + push af + ld a, BANK(Function83e8) + call Bankswitch + call Function83e8 + pop af + call Bankswitch + ret + +Function18b4:: + ld bc, wPlayerStruct + ld hl, OBJECT_FLAGS + add hl, bc + set 3, [hl] + set 2, [hl] + set 1, [hl] + ld hl, OBJECT_FLAGS + 1 + add hl, bc + set 5, [hl] + call Function18e5 + ret + +Function18cc:: + ld hl, wPlayerFlags + res 3, [hl] + res 2, [hl] + res 1, [hl] + ld hl, wPlayerFlags + 1 + res 5, [hl] + ld hl, wPlayerMovementType + ld [hl], $10 + ld hl, wPlayerDirection + ld [hl], $0 + ret + +Function18e5:: ; 00:18e5 + ld hl, OBJECT_DIRECTION_WALKING + add hl, bc + ld a, [hl] + srl a + srl a + and $3 + ld e, a + ld d, $0 + ld hl, .Data + add hl, de + ld a, [hl] + ld hl, OBJECT_MOVEMENTTYPE + add hl, bc + ld [hl], a + ld hl, OBJECT_FACING + add hl, bc + ld [hl], $0 + ret + +.Data: + db $05, $06, $07, $08 + +Function1908:: + call CheckObjectVisibility + ret c + push bc + call Function191d + pop bc + ld hl, OBJECT_FLAGS + add hl, bc + set 7, [hl] + ldh a, [hObjectStructIndexBuffer] + ld [wCenteredObject], a + ret + +Function191d:: ; 00:191d + ld a, [wCenteredObject] + cp $ff + ret z + call GetObjectStruct + ld hl, OBJECT_FLAGS + add hl, bc + res 7, [hl] + ld a, $ff + ld [wCenteredObject], a + ret + +; 1932 + +StartFollow:: + push bc + ld a, b + call SetLeaderIfVisible + pop bc + ld a, c + call SetFollowerIfVisible + callab QueueFollowerFirstStep + ret + +SetLeaderIfVisible:: ; 00:1945 + call CheckObjectVisibility + ret c + ldh a, [hObjectStructIndexBuffer] + ld [wObjectFollow_Leader], a + ret + +ResetLeader:: + xor a + ld [wObjectFollow_Leader], a + ret + +SetFollowerIfVisible:: ; 00:1954 + push af + call ResetFollower + pop af + call CheckObjectVisibility + ret c + ld hl, OBJECT_MOVEMENTTYPE + add hl, bc + ld [hl], $18 + ld hl, OBJECT_FACING + add hl, bc + ld [hl], $0 + ldh a, [hObjectStructIndexBuffer] + ld [wObjectFollow_Follower], a + ret + +ResetFollower:: ; 00:196f + ld a, [wObjectFollow_Follower] + and a + ret z + cp $ff + ret z + call GetObjectStruct + call Function18e5 + ret + +Function197e:: + call CheckObjectVisibility + ret c + ld hl, OBJECT_FLAGS + 1 + add hl, bc + res 0, [hl] + ret + +Function1989:: + call CheckObjectVisibility + ret c + ld hl, OBJECT_FLAGS + 1 + add hl, bc + set 0, [hl] + ret + +Function1994:: + call CheckObjectVisibility + ret c + ld hl, OBJECT_FLAGS + 1 + add hl, bc + res 4, [hl] + ret + +Function199f:: + call CheckObjectVisibility + ret c + ld hl, OBJECT_FLAGS + 1 + add hl, bc + set 4, [hl] + ret + +Function19aa:: + call CheckObjectVisibility + ret c + ld hl, OBJECT_FLAGS + 1 + add hl, bc + set 7, [hl] + ret + +Function19b5:: + call CheckObjectVisibility + ret c + ld hl, OBJECT_FLAGS + 1 + add hl, bc + res 7, [hl] + ret + +Function19c0:: + push de + call CheckObjectVisibility + pop de + ret c + ld a, d + add a + add a + and $c + ld hl, OBJECT_DIRECTION_WALKING + add hl, bc + ld [hl], a + ret diff --git a/home/math.asm b/home/math.asm new file mode 100644 index 0000000..8b3db6f --- /dev/null +++ b/home/math.asm @@ -0,0 +1,25 @@ +include "constants.asm" + +if DEBUG +SECTION "Math utility functions", ROM0 [$3380] +else +SECTION "Math utility functions", ROM0 [$3344] +endc + +Multiply:: + push hl + push bc + callab _Multiply + pop bc + pop hl + ret + +Divide:: + push hl + push de + push bc + homecall _Divide + pop bc + pop de + pop hl + ret diff --git a/home/menu.asm b/home/menu.asm index 64d3f9a..2d8f1f3 100644 --- a/home/menu.asm +++ b/home/menu.asm @@ -210,15 +210,15 @@ Function1e8a:: ; 00:1e8a ldh [hBGMapMode], a xor a call OpenSRAM - call Function1cae + call GetWindowStackTop ld a, l ld [wWindowStackPointer], a ld a, h ld [wWindowStackPointer + 1], a - call Function1c7a + call PopWindow ld d, h ld e, l - call Function1c60 + call RestoreTileBackup call CloseSRAM ld hl, wWindowStackSize dec [hl] @@ -271,7 +271,7 @@ GetMenuIndexSet:: ; 00:1ec3 Function1ee9:: ; 1ee9 call MenuBoxCoord2Tile - call Function1c86 + call GetMenuBoxDims ld a, [wMenuDataItems] add a cp b diff --git a/home/menu_window.asm b/home/menu_window.asm new file mode 100644 index 0000000..b5082ca --- /dev/null +++ b/home/menu_window.asm @@ -0,0 +1,246 @@ +include "constants.asm" + +SECTION "Menu Window Functions", ROM0 [$1bf4] + +PushWindow:: ; 00:1bf4 + ld hl, PlaceWaitingText + ld a, $9 + jp FarCall_hl + +ExitMenu:: ; 00:1bfc + push af + callab _ExitMenu + call Function1c0a + pop af + ret + +Function1c0a:: ; 00:1c0a + ld a, [wVramState] + bit 0, a + ret z + + xor a + call OpenSRAM + hlcoord 0, 0 + ld de, sSpriteBuffer0 + ld bc, $168 + call CopyBytes + call CloseSRAM + + call LoadMapPart + + xor a + call OpenSRAM + ld hl, sSpriteBuffer0 + decoord 0, 0 + ld bc, $168 +.asm_1c33: ; 00:1c33 + ld a, [hl] + cp $61 + jr c, .asm_1c39 + ld [de], a +.asm_1c39: ; 00:1c39 + inc hl + inc de + dec bc + ld a, c + or b + jr nz, .asm_1c33 + call CloseSRAM + + ret + +InitVerticalMenuCursor:: ; 00:1c44 + jpab _InitVerticalMenuCursor + +CloseWindow:: ; 00:1c4c + push af + call ExitMenu + call WaitBGMap + call UpdateSprites + pop af + ret + +Function1c58:: + jpab Function24185 + +RestoreTileBackup:: ; 00:1c60 + call MenuBoxCoord2Tile + call GetMenuBoxDims + inc b + inc c +.asm_1c68: ; 00:1c68 + push bc + push hl +.asm_1c6a: ; 00:1c6a + ld a, [de] + ld [hli], a + dec de + dec c + jr nz, .asm_1c6a + pop hl + ld bc, SCREEN_WIDTH + add hl, bc + pop bc + dec b + jr nz, .asm_1c68 + ret + +PopWindow:: ; 00:1c7a + ld b, $10 + ld de, wMenuDataHeader +.asm_1c7f: ; 00:1c7f + ld a, [hld] + ld [de], a + inc de + dec b + jr nz, .asm_1c7f + ret + +GetMenuBoxDims:: ; 00:1c86 + push hl + ld hl, wMenuBorderTopCoord + ld a, [hli] + ld b, a + ld a, [hli] + ld c, a + ld a, [hli] + sub b + ld b, a + ld a, [hli] + sub c + ld c, a + pop hl + ret + +CopyMenuData:: ; 00:1c96 + push hl + push de + push bc + push af + ld hl, wMenuDataPointer + ld a, [hli] + ld h, [hl] + ld l, a + ld de, wMenuDataFlags + ld bc, $10 + call CopyBytes + pop af + pop bc + pop de + pop hl + ret + +GetWindowStackTop:: ; 00:1cae + ld hl, wWindowStackPointer + ld a, [hli] + ld h, [hl] + ld l, a + inc hl + ld a, [hli] + ld h, [hl] + ld l, a + ret + +PlaceVerticalMenuItems:: ; 00:1cb9 + call CopyMenuData + ld hl, wMenuDataPointer + ld e, [hl] + inc hl + ld d, [hl] + call GetMenuTextStartCoord + call Coord2Tile ; hl now contains the tilemap address where we will start printing text. + inc de + ld a, [de] + inc de + ld b, a +.asm_1ccc: ; 00:1ccc + push bc + call PlaceString + inc de + ld bc, 2 * SCREEN_WIDTH + add hl, bc + pop bc + dec b + jr nz, .asm_1ccc + + ld a, [wMenuDataFlags] + bit 4, a + ret z + + call MenuBoxCoord2Tile + ld a, [de] + ld c, a + inc de + ld b, $0 + add hl, bc + jp PlaceString + +MenuBox:: ; 00:1ceb + call MenuBoxCoord2Tile + call GetMenuBoxDims + dec b + dec c + jp DrawTextBox + +GetMenuTextStartCoord:: ; 00:1cf6 + ld a, [wMenuBorderTopCoord] + ld b, a + inc b + ld a, [wMenuBorderLeftCoord] + ld c, a + inc c + ld a, [wMenuDataFlags] + bit 6, a + jr nz, .asm_1d08 + inc b +.asm_1d08: ; 00:1d08 + ld a, [wMenuDataFlags] + bit 7, a + jr z, .asm_1d10 + inc c +.asm_1d10: ; 00:1d10 + ret + +ClearMenuBoxInterior:: + call MenuBoxCoord2Tile + ld bc, SCREEN_WIDTH + 1 + add hl, bc + call GetMenuBoxDims + dec b + dec c + call ClearBox + ret + +ClearWholeMenuBox:: + call MenuBoxCoord2Tile + call GetMenuBoxDims + inc c + inc b + call ClearBox + ret + +MenuBoxCoord2Tile:: ; 00:1d2d + ld a, [wMenuBorderLeftCoord] + ld c, a + ld a, [wMenuBorderTopCoord] + ld b, a +Coord2Tile:: ; 00:1d35 + xor a + ld h, a + ld l, b + ld a, c + ld b, h + ld c, l + add hl, hl + add hl, hl + add hl, bc + add hl, hl + add hl, hl + ld c, a + xor a + ld b, a + add hl, bc + bccoord 0, 0 + add hl, bc + ret diff --git a/home/misc_32c8.asm b/home/misc_32c8.asm new file mode 100644 index 0000000..3eabb12 --- /dev/null +++ b/home/misc_32c8.asm @@ -0,0 +1,98 @@ +include "constants.asm" + +if DEBUG +SECTION "Unknown 32c8", ROM0[$32c8] +else +SECTION "Unknown 32c8", ROM0[$328c] +endc + +Function32c8:: + predef Functionce10 + ld a, b + and a + ret + +Function32d0:: + ld hl, .Data + ret + +.Data: ; 00:32d4 + db "@" + +SubtractSigned:: + sub b + ret nc + cpl + add $1 + scf + ret + +if DEBUG +SECTION "Unknown 3686", ROM0[$3686] +else +SECTION "Unknown 3686", ROM0[$364a] +endc + +GiveMonToPlayer:: ; 3686 +; Give to the player Pokemon of species b at level c. + ld a, b + ld [wMonDexIndex], a + ld a, c + ld [wCurPartyLevel], a + xor a + ld [wMonType], a + jpba Function1130a + +WaitPressedAny:: ; 369a +; Waits for one of the buttons in d to be pressed. +; If bc is negative, waits forever. +; Otherwise, times out after bc frames then returns z. + +; Reset hJoypadSum to clear button history + xor a + ldh [hJoypadSum], a +.loop: ; 00:369d +; Wait for joypad polling. + call DelayFrame + +; If any of the buttons in d were pressed, return nz. + ldh a, [hJoypadSum] + and a + jr z, .not_pressed + and d + ret nz +.not_pressed: ; 00:36a7 + +; If bc < 0, don't check timeout. + bit 7, b + jr nz, .loop + +; Count down to timeout. + dec bc + ld a, b + or c + jr nz, .loop + +; Return z, signifying that the request timed out. + ret + +CountSetBits:: ; 36b1 +; Count the number of bits set in b bytes at hl. +; Return to a, c, and wce37. + ld c, $0 +.asm_36b3: ; 00:36b3 + ld a, [hli] + ld e, a + ld d, $8 +.asm_36b7: ; 00:36b7 + srl e + ld a, $0 + adc c + ld c, a + dec d + jr nz, .asm_36b7 + dec b + jr nz, .asm_36b3 + ld a, c + ld [wce37], a + ret diff --git a/home/mon_stats.asm b/home/mon_stats.asm new file mode 100644 index 0000000..e84e552 --- /dev/null +++ b/home/mon_stats.asm @@ -0,0 +1,82 @@ +include "constants.asm" + +if DEBUG +SECTION "Mon Stats", ROM0 [$394b] +else +SECTION "Mon Stats", ROM0 [$390f] +endc + +DrawBattleHPBar:: + push hl + push de + push bc + ld a, $60 + ld [hli], a + ld a, $61 + ld [hli], a + push hl + ld a, $62 +.asm_3957: ; 00:3957 + ld [hli], a + dec d + jr nz, .asm_3957 + ld a, $6b + add b + ld [hl], a + pop hl + ld a, e + and a + jr nz, .asm_396a + ld a, c + and a + jr z, .asm_397d + ld e, $1 +.asm_396a: ; 00:396a + ld a, e + sub $8 + jr c, .asm_3979 + ld e, a + ld a, $6a + ld [hli], a + ld a, e + and a + jr z, .asm_397d + jr .asm_396a + +.asm_3979: ; 00:3979 + ld a, $62 + add e + ld [hl], a +.asm_397d: ; 00:397d + pop bc + pop de + pop hl + ret + +PrepMonFrontpic:: + ld a, $1 + ld [wSpriteFlipped], a +_PrepMonFrontpic:: + ld a, [wMonDexIndex] + and a + jr z, .asm_39a8 + cp 252 + jr nc, .asm_39a8 + push hl + ld de, vFrontPic + call LoadMonFrontSprite + pop hl + xor a + ldh [hGraphicStartTile], a + lb bc, 7, 7 + predef PlaceGraphic + xor a + ld [wSpriteFlipped], a + ret + +.asm_39a8: ; 00:39a8 + xor a + ld [wSpriteFlipped], a + inc a + ld [wMonDexIndex], a + ret diff --git a/home/print_text.asm b/home/print_text.asm index e8b4eeb..0a17688 100644 --- a/home/print_text.asm +++ b/home/print_text.asm @@ -48,4 +48,23 @@ PrintLetterDelay:: ; 33a3 (0:33a3) pop de pop hl ret -; 0x33e3
\ No newline at end of file +; 0x33e3 + +CopyDataUntil:: ; 33e3 +; Copy [hl .. bc) to de. + +; In other words, the source data is +; from hl up to but not including bc, +; and the destination is de. + +.asm_33e3: ; 00:33e3 + ld a, [hli] + ld [de], a + inc de + ld a, h + cp b + jr nz, .asm_33e3 + ld a, l + cp c + jr nz, .asm_33e3 + ret diff --git a/home/scrolling_menu.asm b/home/scrolling_menu.asm new file mode 100644 index 0000000..28d3d3e --- /dev/null +++ b/home/scrolling_menu.asm @@ -0,0 +1,93 @@ +include "constants.asm" + +if DEBUG +SECTION "Scrolling Menu", ROM0 [$3810] +else +SECTION "Scrolling Menu", ROM0 [$37D4] +endc + +Function3810:: + ld e, [hl] + inc hl + ld d, [hl] + inc hl + push hl + ld h, d + ld l, e + call CopyMenuHeader + pop hl + ld e, [hl] + inc hl + ld d, [hl] + inc hl + ld a, [de] + ld [wMenuCursorBuffer], a + push de + ld e, [hl] + inc hl + ld d, [hl] + inc hl + ld a, [de] + ld [wMenuScrollPosition], a + push de + call ScrollingMenu + pop de + ld a, [wMenuScrollPosition] + ld [de], a + pop de + ld a, [wMenuCursorY] + ld [de], a + ld a, [wMenuJoypad] + ret + +ScrollingMenu:: ; 00:383e + call CopyMenuData + ldh a, [hROMBank] + push af + + ld a, BANK(_InitScrollingMenu) ; and BANK(_ScrollingMenu) + call Bankswitch + + call _InitScrollingMenu + call SetPalettes + call _ScrollingMenu + + pop af + call Bankswitch + + ld a, [wMenuJoypad] + ret + +Function385a:: + push hl + jr asm_3865 + +Function385d:: + callab Function_8f1cb +asm_3865: ; 00:3865 + pop hl + call MenuTextBox + ld c, $0 + call Function3872 + call CloseWindow + ret + +Function3872:: ; 00:3872 + push bc + jr asm_387d + +Function3875:: + callab Function8cd0c +asm_387d: ; 00:387d + pop bc + call GetJoypad + ldh a, [hJoyDown] + and A_BUTTON | B_BUTTON + jr nz, .asm_388e + ld a, c + and a + jr z, Function3872 + dec c + jr z, Function3872 +.asm_388e: ; 00:388e + ret diff --git a/home/tilemap.asm b/home/tilemap.asm new file mode 100644 index 0000000..6d7ff38 --- /dev/null +++ b/home/tilemap.asm @@ -0,0 +1,70 @@ +include "constants.asm" + +if DEBUG +SECTION "Tilemap Functions", ROM0 [$360B] +else +SECTION "Tilemap Functions", ROM0 [$35CF] +endc + +Function360b:: + call ClearSprites + ld hl, wVramState + set 0, [hl] + call Function3657 + call LoadFontExtra + call GetMemSGBLayout + jr WaitBGMap + +ClearBGPalettes:: ; 361e + call ClearPalettes +WaitBGMap:: ; 00:3621 +; Tell VBlank to update BG Map + ld a, $1 + ldh [hBGMapMode], a +; Wait for it to do its magic + ld c, 3 + call DelayFrames + ret + +SetPalettes:: ; 00:362b + ld a, %11100100 + ldh [rBGP], a + ld a, %11010000 + ldh [rOBP0], a + ret + +ClearPalettes:: ; 00:3634 + xor a + ldh [rBGP], a + ldh [rOBP0], a + ldh [rOBP1], a + ret + +GetMemSGBLayout:: ; 00:363c + ld b, SGB_RAM +GetSGBLayout:: ; 00:363e + ld a, [wSGB] + and a + ret z + predef_jump Function928b + +SetHPPal:: ; 00:3648 + ld a, e + cp 27 ; 56.25% + ld d, $0 + jr nc, .done + cp 10 ; 20.83% + inc d + jr nc, .done + inc d +.done: ; 00:3655 + ld [hl], d + ret + +Function3657:: ; 00:3657 + call DisableLCD + callab Function140d9 + call LoadFont + call UpdateSprites + call EnableLCD + ret diff --git a/home/unknown_388f.asm b/home/unknown_388f.asm new file mode 100644 index 0000000..58c83fa --- /dev/null +++ b/home/unknown_388f.asm @@ -0,0 +1,101 @@ +include "constants.asm" + +if DEBUG +SECTION "Unknown 388F", ROM0 [$388F] +else +SECTION "Unknown 388F", ROM0 [$3853] +endc + + +Function388f:: + ret + +Function3890:: + callba Function14cac + ret + +Function3899:: + callba Function14dac + ret + +Function38a2:: + callba Function14dc4 + ret + +Function38ab:: + callba Function14ddd + ret + +Function38b4:: + callba Function14e00 + ret + +Function38bd:: + callba Function14e5f + ret + +Function38c6:: + callba Function14e27 + ret + +Function38cf:: + callba Function14e4a + ret + +Function38d8:: + ld hl, wc5ed + set 7, [hl] + ld a, $8 + ld [wd637], a + ret + +Function38e3:: + ldh a, [hJoyState] + and $f0 + ret z + call Function3233 + jp nz, Function323e + callab Function3ee3e + ld a, [wBattleMode] + and a + ret z + ld a, $3 + call WriteIntod637 + call Function3240 + ret + +Function3904:: + predef Function3ef19 + ld a, $f3 + ldh [hMapEntryMethod], a + ld hl, wd4a9 + set 5, [hl] + ld hl, wJoypadFlags + set 4, [hl] + set 6, [hl] + ld a, $b + call WriteIntod637 + ret + +Function391f:: + ret + +Function3910:: + ld a, [wcd5d] + cp $1 + jr z, .asm_392d + ld a, $4 + call WriteIntod637 + ret + +.asm_392d: ; 00:392d + ld hl, wJoypadFlags + res 4, [hl] + ld hl, .text + call Function3111 + call RotateFourPalettesLeft + jp Init + +.text: + text "つぎは がんばるぞ!!" + done diff --git a/home/util.asm b/home/util.asm index 6591da2..880513b 100644 --- a/home/util.asm +++ b/home/util.asm @@ -1,12 +1,59 @@ INCLUDE "constants.asm" if DEBUG -SECTION "Misc Utility Functions", ROM0[$341F] +SECTION "Misc Utility Functions", ROM0[$33EF] else -SECTION "Misc Utility Functions", ROM0[$33E3] +SECTION "Misc Utility Functions", ROM0[$33B3] endc -_341F:: ; 341f +Function33ef:: + ; hl = src + ; de = dest + ; b = y + ; c = x + push hl + push de + push bc + ld a, b + dec a + dec a + ld b, $0 +.asm_33f7: ; 00:33f7 + add hl, bc + dec a + jr nz, .asm_33f7 + pop bc + dec b + ld a, b + push hl + add hl, bc + ld d, h + ld e, l + pop hl +.asm_3403: ; 00:3403 + push af + push bc + call CopyBytes + pop bc + push bc + ld a, c + xor $ff + ld c, a + ld b, $ff + inc bc + add hl, bc + ld d, h + ld e, l + add hl, bc + pop bc + pop af + dec a + jr nz, .asm_3403 + pop hl + pop de + jp CopyBytes + +SkipNames:: ; 341f ; Returns hl + a * 6 and a ret z @@ -39,3 +86,35 @@ memcmp:: ; 3430 dec c jr nz, .loop ret + +Function3439:: ; 3439 +; Place 2x2 sprite from *de into OAM at slot a + ld h, HIGH(wVirtualOAM) + swap a + ld l, a + call .Load + push bc + ld a, $8 + add c + ld c, a + call .Load + pop bc + ld a, $8 + add b + ld b, a + call .Load + ld a, $8 + add c + ld c, a +.Load: ; 00:3455 + ld [hl], b + inc hl + ld [hl], c + inc hl + ld a, [de] + inc de + ld [hli], a + ld a, [de] + inc de + ld [hli], a + ret @@ -57,7 +57,9 @@ hJoyDebounceSrc:: db ; ffa5 hJoypadState2:: db ; ffa6 - ds 8 ; TODO + ds 6 ; TODO +hGraphicStartTile:: db ; ffad +hMoveMon:: db UNION @@ -96,11 +98,37 @@ hSpriteOffset:: ; ffb1 db ; TODO +UNION + +; ffb3 +hProduct:: +hDividend:: + ; ds 4 + db + +; ffb4 +hMultiplicand:: +hQuotient:: + ds 3 + +; ffb7 +hMultiplier:: +hDivisor:: +hRemainder:: + db + +; ffb8 +hMathBuffer:: + ds 5 + +NEXTU + hPrintNumLeadingDigit:: db ; ffb3 digit one place-value up hPrintNumDividend:: ds 3 ; ffb4 big-endian hPrintNumDivisor:: ds 3 ; ffb7 big-endian hPrintNumTemp:: ds 3 ; ffba big-endian +ENDU ds 19 ; TODO diff --git a/macros/farcall.asm b/macros/farcall.asm index 05bb7b1..5e39410 100644 --- a/macros/farcall.asm +++ b/macros/farcall.asm @@ -12,7 +12,7 @@ callab: MACRO ; address, bank ENDM homecall: MACRO - ld a, [hROMBank] + ldh a, [hROMBank] push af ld a, BANK(\1) call Bankswitch diff --git a/macros/wram.asm b/macros/wram.asm index cb0d3f1..da67ba5 100644 --- a/macros/wram.asm +++ b/macros/wram.asm @@ -372,3 +372,13 @@ warp_struct: MACRO \1MapGroup:: ds 1 \1MapNumber:: ds 1 ENDM + +ptrba: MACRO +\1Bank:: db +\1Addr:: dw +ENDM + +ptrab: MACRO +\1Addr:: dw +\1Bank:: db +ENDM @@ -1,33 +1,12 @@ ; ROM0 -00:15BE GetMapObject -00:1720 CheckObjectVisibility -00:17A8 UpdateSprites -00:17BF GetObjectStruct 00:1A7C Function1a7c -00:1BF4 PushWindow -00:1BFC ExitMenu -00:1C44 InitVerticalMenuCursor -00:1C4C CloseWindow -00:1C60 Function1c60 ; PopWindow? -00:1C7A Function1c7a ; HandleWindow? -00:1C86 Function1c86 -00:1C96 CopyMenuData -00:1CAE Function1cae ; PushWindow? -00:1CB9 PlaceVerticalMenuItems -00:1CEB MenuBox -00:1D2D MenuBoxCoord2Tile 00:202C Function202c - 00:2C05 StartMenuCheck +00:3111 Function3111 00:3171 Function3171 -00:361E ClearPalettesAndWait -00:3621 WaitBGMap -00:362B SetPalettes -00:3634 ClearPalettes -00:363C GetMemSGBLayout -00:363E GetSGBLayout -00:3648 SetHPPal -00:3655 SetHPPal.done +00:3233 Function3233 +00:323E Function323e +00:3240 Function3240 00:39BA PlayCry 00:3CA8 InitSpriteAnimStruct 00:3D86 WaitSFX @@ -47,10 +26,12 @@ 00:3E2E GetMapMusic.unk_3E2E 00:3E32 Unk_3E32 - 01:4031 Function4031 01:4031 DebugMenu +01:40EB Function40eb +01:5007 Function5007 01:5190 _UpdateSprites +01:5190 Function5190 01:53CC MainMenu 01:5D27 Function5d27 01:63D8 ReanchorBGMap_NoOAMUpdate @@ -58,10 +39,15 @@ 01:6445 Function6445 01:66B1 Function66b1 01:6713 Function6713 -01:68F3 ItemAttributes 02:4000 Function8000 02:4098 _InitializeVisibleSprites +02:4125 Function8125 +02:4131 Function8131 +02:413D Function813d +02:43E8 Function83e8 +02:45DF QueueFollowerFirstStep +02:462E Function862e 02:4786 Function8786 02:4856 DecompTownMapTilemap 02:48DA DecompTownMapTilemap.tilemap @@ -98,6 +84,7 @@ 04:528F Function1128f 04:52C1 Function112c1 +04:530A Function1130a 04:5677 DoPlayerMovement 04:5DBE DisplayStartMenu 04:640B Function1240b @@ -109,6 +96,7 @@ 05:404C CheckInteriorMap 05:405B AddIndoorSprites 05:40AA AddOutdoorSprites +05:40D9 Function140d9 05:40FB LoadUsedSpritesGfx ; TODO: maybe there's a better name 05:43B6 InitAllSRAMBanks 05:43E0 Function143e0 @@ -123,6 +111,20 @@ ; ptr Copied to c5eb ; word Unknown (2 bytes) 05:470E UnknownMapBufferPointers +05:4CAC Function14cac +05:4DAC Function14dac +05:4DC4 Function14dc4 +05:4DDD Function14ddd +05:4E00 Function14e00 +05:4E5F Function14e5f +05:4E27 Function14e27 +05:4E4A Function14e4a + +09:412C _ExitMenu +09:4185 Function24185 +09:4199 _InitVerticalMenuCursor +09:426A _InitScrollingMenu +09:4287 _ScrollingMenu 0A:4C98 LinkTextboxAtHL 0A:4D6E Function28d6e @@ -144,8 +146,9 @@ 0F:691E Function3e91e 0F:6963 Function3e963 0F:69A9 _LoadWildMons +0F:6E3E Function3ee3e 0F:6F19 Function3ef19 -0F:7019 Function3f019 +0F:7019 PlaceGraphic 0F:704A Function3f04a 0F:7068 Function3f068 @@ -185,8 +188,10 @@ 23:4940 Function8c940 23:49C6 Function8c9c6 23:4CFD InitEffectObject +23:4D0C Function8cd0c 23:4d13 EffectObjectJumpNoDelay 23:60cc MenuMonIconGfx +23:71CB Function_8f1cb 24:4000 SetClockDialog 24:4239 SlotMachineGame @@ -100,7 +100,8 @@ wMapBuffer:: wMapScriptNumber:: db ; c5e8 wMapScriptNumberLocation:: dw ; c5e9 wUnknownMapPointer:: dw ; c5eb ; TODO - ds 19 ; TODO +wc5ed:: db ; c5ed + ds 18 ; TODO wMapBufferEnd:: ; c600 @@ -215,8 +216,7 @@ wPlayerLinkAction:: db ; cb51 wLinkTimeoutFrames:: dw ; cb56 wcb58:: ds 2 ; cb58 -; cb5a - ds 1 ; TODO +wMonType:: db ; cb5a wCurSpecies:: db ; cb5b wNamedObjectTypeBuffer:: db ; cb5c @@ -232,12 +232,18 @@ wVBCopyDoubleSize:: ds 1 ; cb67 wVBCopyDoubleSrc:: ds 2 ; cb68 wVBCopyDoubleDst:: ds 2 ; cb6a -SECTION "CB71", WRAM0[$CB71] +SECTION "CB71", WRAM0[$CB70] + +wcb70:: db wVBCopyFarSize:: ds 1 ; cb71 wVBCopyFarSrc:: ds 2 ; cb72 wVBCopyFarDst:: ds 2 ; cb74 wVBCopyFarSrcBank:: ds 1 ; cb76 + db + +wMovementObject:: db ; cb78 + ptrba wMovementData ; cb79 SECTION "Collision buffer", WRAM0[$CB90] @@ -280,7 +286,7 @@ wMenuCursorBuffer:: db ; cc09 ds 8 ; TODO wMenuData2:: - db ; cc12 +wMenuDataFlags:: db ; cc12 wMenuDataItems:: db ; cc13 wMenuDataIndicesPointer:: dw ; cc14 wMenuDataDisplayFunctionPointer:: dw ; cc16 @@ -308,7 +314,7 @@ wDebugWarpSelection:: ; cc39 ds 6 -wSGB:: ; cc40 +wcc40:: ; cc40 db SECTION "CC9C", WRAM0[$CC9C] @@ -349,7 +355,7 @@ wOBP1:: db ; cccc SECTION "CCCE", WRAM0[$CCCE] wDisableVBlankWYUpdate:: db ; ccce -wcccf:: db +wSGB:: db SECTION "CD26", WRAM0[$CD26] @@ -393,7 +399,10 @@ wFarCallBCBuffer:: ; cd54 dw ds 3 ; TODO -wVramState:: db +wVramState:: db ; cd59 + + ds 3 ; TODO +wcd5d:: db ; cd5d SECTION "CD72", WRAM0[$CD72] wcd72:: dw ; cd72 @@ -412,6 +421,7 @@ wItemQuantityBuffer:: db ; cd7e SECTION "CDBA", WRAM0[$CDBA] wItemAttributeParamBuffer:: db ; cdba +wCurPartyLevel:: db ; cdbb SECTION "CDBD", WRAM0[$CDBD] @@ -547,33 +557,33 @@ wObjectFollow_Leader:: ; ce76 db wObjectFollow_Follower:: ; ce77 db - - -SECTION "Object structs", WRAM0[$CEA7] - -wObjectStructs:: ; cea7 -wPlayerStruct:: object_struct wPlayer -wObject0Struct:: object_struct wObject0 -wObject1Struct:: object_struct wObject1 -wObject2Struct:: object_struct wObject2 -wObject3Struct:: object_struct wObject3 -wObject4Struct:: object_struct wObject4 -wObject5Struct:: object_struct wObject5 -wObject6Struct:: object_struct wObject6 -wObject7Struct:: object_struct wObject7 +wCenteredObject:: ; ce78 + db +wFollowerMovementQueueLength:: ; ce79 + db +wFollowMovementQueue:: ; ce7a + ds 5 + +wObjectStructs:: ; ce7f +; Note: this might actually not be an object. TODO: Investigate (if indexing starts at 1, then this isn't an object) +; It might just be unused/a leftover. +wUnkObjectStruct:: object_struct wUnkObject ; ce7f +wPlayerStruct:: object_struct wPlayer ; cea7 +wObject1Struct:: object_struct wObject1 ; cecf +wObject2Struct:: object_struct wObject2 ; cef7 +wObject3Struct:: object_struct wObject3 ; cf1f +wObject4Struct:: object_struct wObject4 ; cf47 +wObject5Struct:: object_struct wObject5 ; cf6f +wObject6Struct:: object_struct wObject6 ; cf97 +wObject7Struct:: object_struct wObject7 ; cfbf +wObject8Struct:: object_struct wObject8 ; cfe7 wObjectStructsEnd:: ; d00f -; TODO: there are 4 structs of 16 bytes here, -; cleared by ClearObjectStructs. -; What are they? -; d00f - ds 16 -; d01f - ds 16 -; d02f - ds 16 -; d03f - ds 16 +wCmdQueue:: ; d00f +wCmdQueueEntry1:: ds 16 +wCmdQueueEntry2:: ds 16 +wCmdQueueEntry3:: ds 16 +wCmdQueueEntry4:: ds 16 wMapObjects:: ; d04f wPlayerObject:: map_object wPlayer @@ -639,8 +649,10 @@ wBallQuantities:: db ; d1df SECTION "Rival's Name", WRAM0[$D258] wRivalsName:: ds 6 ; d258 -SECTION "D4AB", WRAM0[$D4AB] +SECTION "D4AB", WRAM0[$D4A9] +wd4a9:: db ; d4a9 + ds 1 ; TODO wJoypadFlags:: db ; d4ab ; 76543210 ; ||||\__/ @@ -673,6 +685,8 @@ ENDR wCurrMapObjectCount:: ; d5f6 db +SECTION "D637", WRAM0[$D637] +wd637:: db ; d637 SECTION "Used sprites", WRAM0[$D643] |