diff options
41 files changed, 2652 insertions, 2695 deletions
@@ -94,8 +94,6 @@ $(BUILD)/%.o: %.asm | $$(dir $$@) $(BUILD)/gfx/sgb/sgb_border_alt.2bpp: tools/gfx += --trim-whitespace $(BUILD)/gfx/sgb/sgb_border_gold.2bpp: tools/gfx += --trim-whitespace $(BUILD)/gfx/sgb/sgb_border_silver.2bpp: tools/gfx += --trim-whitespace -$(BUILD)/gfx/title/title_gold.2bpp: tools/gfx += --trim-whitespace -$(BUILD)/gfx/title/title_silver.2bpp: tools/gfx += --trim-whitespace $(BUILD)/gfx/trainer_card/leaders.2bpp: tools/gfx += --trim-whitespace $(BUILD)/gfx/trainer_card/trainer_card.2bpp: tools/gfx += --trim-whitespace $(BUILD)/gfx/pokegear/town_map.2bpp: tools/gfx += --trim-trailing diff --git a/constants.asm b/constants.asm index 66383ba..538941e 100644 --- a/constants.asm +++ b/constants.asm @@ -22,6 +22,7 @@ INCLUDE "constants/palette_constants.asm" INCLUDE "constants/music_constants.asm" INCLUDE "constants/landmark_constants.asm" INCLUDE "constants/map_constants.asm" +INCLUDE "constants/map_setup_constants.asm" INCLUDE "constants/tileset_constants.asm" INCLUDE "constants/map_data_constants.asm" @@ -31,5 +32,4 @@ INCLUDE "constants/misc_constants.asm" INCLUDE "constants/battle_anim_constants.asm" INCLUDE "constants/menu_constants.asm" -INCLUDE "constants/sgb_constants.asm" -INCLUDE "constants/map_object_constants.asm" +INCLUDE "constants/wram_constants.asm" diff --git a/constants/item_data_constants.asm b/constants/item_data_constants.asm index bf8516d..297ffc5 100755 --- a/constants/item_data_constants.asm +++ b/constants/item_data_constants.asm @@ -42,88 +42,4 @@ NUM_POCKETS EQU const_value MAX_ITEMS EQU 20
MAX_KEY_ITEMS EQU 20
-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
-
-
+MAX_PC_ITEMS EQU 50
\ No newline at end of file diff --git a/constants/map_object_constants.asm b/constants/map_object_constants.asm deleted file mode 100644 index c9bce93..0000000 --- a/constants/map_object_constants.asm +++ /dev/null @@ -1,72 +0,0 @@ - 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/map_setup_constants.asm b/constants/map_setup_constants.asm new file mode 100644 index 0000000..046fc65 --- /dev/null +++ b/constants/map_setup_constants.asm @@ -0,0 +1,10 @@ + + const_def $f1 + const MAPSETUP_CONTINUE ; $f1 + const MAPSETUP_F2 + const MAPSETUP_RELOADMAP ; $f3 + const MAPSETUP_F4 + const MAPSETUP_F5 ; Note: entry is duplicate of $F4 + const MAPSETUP_WARP ; $f6 + const MAPSETUP_CONNECTION ; $f7 + const MAPSETUP_F8 diff --git a/constants/sgb_constants.asm b/constants/sgb_constants.asm deleted file mode 100644 index 69fe02f..0000000 --- a/constants/sgb_constants.asm +++ /dev/null @@ -1,150 +0,0 @@ -; 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/constants/wram_constants.asm b/constants/wram_constants.asm new file mode 100644 index 0000000..a5e3044 --- /dev/null +++ b/constants/wram_constants.asm @@ -0,0 +1,8 @@ +; wWalkingDirection:: + const_def -1 + const STANDING ; -1 + const DOWN ; 0 + const UP ; 1 + const LEFT ; 2 + const RIGHT ; 3 +NUM_DIRECTIONS EQU const_value
\ No newline at end of file diff --git a/data/items/attributes.asm b/data/items/attributes.asm deleted file mode 100644 index 4308b44..0000000 --- a/data/items/attributes.asm +++ /dev/null @@ -1,520 +0,0 @@ -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 58b2de9..0b980b5 100644 --- a/data/predef_pointers.inc +++ b/data/predef_pointers.inc @@ -40,10 +40,10 @@ GiveItemPredef:: add_predef Functiondf91 add_predef Function1128f add_predef Function112c1 - add_predef Function28c98 + add_predef LinkTextboxAtHL add_predef Function2d663 add_predef Function3d5ce - add_predef PlaceGraphic + add_predef Function3f019 add_predef Function3f068 ; 20 add_predef Function3f04a add_predef Function3d08c @@ -98,4 +98,4 @@ GiveItemPredef:: add_predef Functioncc000_2 add_predef Functionfdb66 add_predef Function1240b - dbw $ff, InexplicablyEmptyFunction + dbw $ff, InexplicablyEmptyFunction ; 56 diff --git a/engine/battle_anims/bg_effects.asm b/engine/battle_anims/bg_effects.asm index 7e51b03..746c979 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, [wSGB] + ld a, [wcccf] and a ret diff --git a/engine/link/place_waiting_text.asm b/engine/link/place_waiting_text.asm index bfe9d7e..a9f712e 100644 --- a/engine/link/place_waiting_text.asm +++ b/engine/link/place_waiting_text.asm @@ -13,10 +13,7 @@ PlaceWaitingText:: ; 1:4000 jr .textbox_done .link_textbox - ; TODO - ; predef Predef_LinkTextbox - ld a, $1c - call Predef + predef LinkTextboxAtHL .textbox_done hlcoord 4, 11 ld de, .Waiting diff --git a/engine/math/math.asm b/engine/math/math.asm deleted file mode 100644 index 4395009..0000000 --- a/engine/math/math.asm +++ /dev/null @@ -1,200 +0,0 @@ -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 961b83b..e90bafc 100644 --- a/engine/title.asm +++ b/engine/title.asm @@ -2,17 +2,641 @@ INCLUDE "constants.asm" SECTION "Title screen", ROMX[$5D8C], BANK[$01] -IntroSequence:: ; 5d8c - ; TODO +IntroSequence:: + callab GameFreakIntro ; Bank $39 + jr c, TitleSequenceStart + ld a, [wTitleSequenceOpeningType] + and a + jr z, .opening_sequence + +.pikachu_minigame + callab PikachuMiniGame ; Bank $38 + jr TitleSequenceStart +.opening_sequence + callab OpeningCutscene ; Bank $39 + +TitleSequenceStart:: + call TitleSequenceInit + callab SetTitleBGDecorationBorder ; Bank $02 + +.loop + call TitleScreenMain + jr nc, .loop + + call ClearPalettesAndWait + call ClearSprites + ld a, $01 + ldh [hBGMapMode], a + call ClearTileMap + call UpdateTimePals + + ld a, [wJumptableIndex + 1] + ld e, a + ld d, 0 + ld hl, TitleScreenJumpTable + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + + jp hl + +TitleScreenJumpTable:: + dw MainMenu + dw DebugMenu + dw SRAMClearMenu + dw IntroSequence + +TitleSequenceInit:: + call ClearPalettes + + xor a + ldh [hMapAnims], a + ldh [hSCY], a + ldh [hSCX], a + + ld de, MUSIC_NONE ; Stop the music. + call PlayMusic + + call ClearTileMap + call DisableLCD + call ClearSprites + + callba InitEffectObject ; Bank $23 + ld hl, vChars0 + ld bc, vBGMap0 - vChars0 + +.clear_loop + ld [hl], $00 + inc hl + dec bc + ld a, b + or c + jr nz, .clear_loop + + ld hl, TitleScreenGFX + ld de, vChars2 + 65 tiles + ld bc, 13 tiles + ld a, BANK(TitleScreenGFX) + call FarCopyData + + ld hl, TitleScreenVersionGFX + ld de, vChars2 + 96 tiles + ld bc, 24 tiles + ld a, BANK(TitleScreenVersionGFX) + call FarCopyData + + ld hl, TitleScreenHoOhGFX + ld de, vChars2 + ld bc, 49 tiles + ld a, BANK(TitleScreenHoOhGFX) + call FarCopyData + + ld hl, TitleScreenLogoGFX + ld de, vChars1 + ld bc, 58 tiles + ld a, BANK(TitleScreenLogoGFX) + call FarCopyData + + ld hl, TitleScreenGoldLogoGFX + ld de, vChars0 + 186 tiles + ld bc, 20 tiles + ld a, BANK(TitleScreenGoldLogoGFX) + call FarCopyData + + call SetTitleGfx + ld hl, wTileMapBackup + ld a, $24 + ld [hli], a + ld a, $00 + ld [hli], a + + ld hl, vBGMap0 + ld bc, 128 tiles + ld a, " " + call ByteFill + + ld b, $06 + call GetSGBLayout + call EnableLCD + ld a, $01 + ldh [hBGMapMode], a + call WaitBGMap + xor a + ldh [hBGMapMode], a + ld hl, wJumptableIndex + ld [hli], a ; (Possibly wJumptableIndex from Crystal) + ld [hli], a ; (Possibly wIntroSceneFrameCounter from Crystal) + ld [hli], a ; (Possibly wTitleScreenTimer from Crystal) + ld [hl], a ; (Possibly wTitleScreenTimer + 1 from Crystal) + + call .load_position_table + + + ld a, %00011010 + ldh [rBGP], a + ld a, %11100100 + ldh [rOBP0], a + ret + +.load_position_table: + ld hl, FirePositionTable + ld c, 6 ; Load 6 flying objects on the screen. + +.set_fire_note_loop + push bc + ld e, [hl] + inc hl + ld d, [hl] + inc hl + push hl + ld a, $2E ; Title fire/note object effect type? + call InitSpriteAnimStruct + pop hl + pop bc + dec c + jr nz, .set_fire_note_loop + ret + +FirePositionTable:: + dw $4CE0 + dw $58A0 + dw $6490 + dw $70D0 + dw $7CB0 + dw $8800 + +TitleFireGFX:: INCBIN "gfx/title/fire.2bpp" ; 5EB8-5F37 +TitleNotesGFX:: INCBIN "gfx/title/notes.2bpp" ; 5F38=5FB7 + +TitleScreenMain:: + ld a, [wJumptableIndex] + bit 7, a + jr nz, .exit + call TitleScreenSequence + callba EffectObjectJumpNoDelay ; Bank $23 + call DelayFrame + and a + ret + +.exit + scf + ret + +TitleScreenSequence:: + ld e, a + ld d, 0 + ld hl, TitleScreenSequenceTable + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + jp hl + +TitleScreenSequenceTable:: + dw TitleSeq_Start + dw TitleSeq_LoadPokemonLogo + dw TitleSeq_IncreaseJumpTableIndex + dw TitleSeq_IncreaseJumpTableIndex + dw TitleSeq_MoveTitle + dw TitleSeq_MoveTitleEnd + dw TitleSeq_InitFlashTitle + dw TitleSeq_FlashTitle + + dw TitleSeq_PMJapaneseChara + dw TitleSeq_IncreaseJumpTableIndex + dw TitleSeq_IncreaseJumpTableIndex + dw TitleSeq_IncreaseJumpTableIndex + dw TitleSeq_WaitForNextSequence + dw TitleSeq_PMSubtitle + dw TitleSeq_IncreaseJumpTableIndex + dw TitleSeq_IncreaseJumpTableIndex + + dw TitleSeq_IncreaseJumpTableIndex + dw TitleSeq_WaitForNextSequence + dw TitleSeq_Version + dw TitleSeq_IncreaseJumpTableIndex + dw TitleSeq_IncreaseJumpTableIndex + dw TitleSeq_IncreaseJumpTableIndex + dw TitleSeq_WaitForNextSequence + dw TitleSeq_CopyRight + + dw TitleSeq_IncreaseJumpTableIndex + dw TitleSeq_IncreaseJumpTableIndex + dw TitleSeq_IncreaseJumpTableIndex + dw TitleSeq_WaitForNextSequence + dw TitleSeq_HoOh + dw TitleSeq_IncreaseJumpTableIndex + dw TitleSeq_IncreaseJumpTableIndex + dw TitleSeq_IncreaseJumpTableIndex + + dw TitleSeq_WaitForNextSequence + dw TitleSeq_PressButtonInit + dw TitleSeq_TitleScreenInputAndTimeout + dw TitleSeq_FadeMusicOut + +TitleSeq_IncreaseJumpTableIndex:: + ld hl, wJumptableIndex + inc [hl] + ret + +TitleSeq_WaitForNextSequence:: + xor a + ldh [hBGMapMode], a + ld hl, wJumptableIndex + 2 + ld a, [hl] + and a + jr z, .next_seq + dec [hl] + ret + +.next_seq + call TitleSeq_IncreaseJumpTableIndex + ret + +TitleSeq_LoadPokemonLogo:: + call PrintPokemonLogo + call TitleSeq_IncreaseJumpTableIndex + ld a, $01 + ldh [hBGMapMode], a + ret + +TitleSeq_Start:: + call TitleSeq_IncreaseJumpTableIndex + push de + ld de, $002D + call PlaySFX ; Play "Swish" sound + pop de + ld a, $80 + ld [wJumptableIndex + 2], a + call SetLYOverrides + ld a, $43 + ldh [hLCDCPointer], a + ret + +TitleSeq_MoveTitle:: + xor a + ldh [hBGMapMode], a + ld hl, wJumptableIndex + 2 + ld a, [hl] + and a + jr z, .nextseq + add $04 + ld [hl], a + ld e, a +.wait + ldh a, [rLY] + cp $40 + jr c, .wait + ld a, e + call SetLYOverrides + ret + +.nextseq + call TitleSeq_IncreaseJumpTableIndex + ret + +TitleSeq_MoveTitleEnd:: + xor a + ldh [hLCDCPointer], a + call TitleSeq_IncreaseJumpTableIndex + ld de, MUSIC_TITLE + call PlayMusic ; Play "Title Theme" + ret + +TitleSeq_InitFlashTitle:: + call TitleSeq_IncreaseJumpTableIndex + ld a, %00011010 + ld [wJumptableIndex + 2], a + ld a, 6 + ld [wJumptableIndex + 3], a + ret + +TitleSeq_FlashTitle:: + ld hl, wJumptableIndex + 3 + ld a, [hl] + and a + jr z, .exit + dec [hl] + ld a, [wJumptableIndex + 2] + xor %00011010 + ld [wJumptableIndex +2 ], a + ldh [rBGP], a + call DelayFrame + call DelayFrame + ret + +.exit + call TitleSeq_IncreaseJumpTableIndex + ld a, %11100100 + ldh [rBGP], a + ret + +TitleSeq_PMJapaneseChara:: + call PrintPMJapaneseChara + ld a, $10 + ld [wJumptableIndex + 2], a + call TitleSeq_IncreaseJumpTableIndex + ld a, $01 + ldh [hBGMapMode], a + ret + +TitleSeq_PMSubtitle:: + call PrintPMSubtitle + ld a, $10 + ld [wJumptableIndex + 2], a + call TitleSeq_IncreaseJumpTableIndex + ld a, $01 + ldh [hBGMapMode], a + ret + +TitleSeq_Version:: + call PrintVersion + ld a, $10 + ld [wJumptableIndex + 2], a + call TitleSeq_IncreaseJumpTableIndex + ld a, $01 + ldh [hBGMapMode], a + ret + +TitleSeq_CopyRight:: + call PrintCopyRight + ld a, $10 + ld [wJumptableIndex + 2], a + call TitleSeq_IncreaseJumpTableIndex + ld a, $01 + ldh [hBGMapMode], a + ret + +TitleSeq_HoOh:: + call Set_HoOh + ld a, $10 + ld [wJumptableIndex + 2], a + call TitleSeq_IncreaseJumpTableIndex + ld a, $01 + ldh [hBGMapMode], a + ret + +TitleSeq_PressButtonInit:: + ld hl, wJumptableIndex + inc [hl] + ld hl, wJumptableIndex + 2 + ld de, DecodeNybble0Table - 3 ; DecodeNybble0Table - 3 = $0C00 + ld [hl], e + inc hl + ld [hl], d + ret + +TitleSeq_TitleScreenInputAndTimeout:: + ld hl, wJumptableIndex + 2 + ld e, [hl] + inc hl + ld d, [hl] + ld a, e + or d + jr z, .psbtn_reset + dec de + ld [hl], d + dec hl + ld [hl], e + call GetJoypad + ld hl, hJoyState + ld a, [hl] + and D_UP | B_BUTTON | SELECT ; UP + B + SELECT brings you to the SRAM clear screen. + cp D_UP | B_BUTTON | SELECT + jr z, .psbtn_sramclear + ld a, [hl] + and SELECT ; SELECT will bring you to the debug menu. + jr nz, .psbtn_gotodebug + ld a, [hl] + and $09 + ret z + +.psbtn_play + ld a, $00 ; MainMenu + jr .psbtn_nextseq + +.psbtn_gotodebug +if DEBUG + ld a, $01 ; DebugMenu + jr .psbtn_nextseq +else + ret +endc + +.psbtn_sramclear + ld a, $02 + +.psbtn_nextseq + ld [wJumptableIndex + 1], a + ld hl, wJumptableIndex + set 7, [hl] + ret + +.psbtn_reset + ld hl, wJumptableIndex + inc [hl] + xor a + ld [wMusicFadeID], a + ld [wMusicFadeID + 1], a + ld hl, wMusicFade + ld [hl], 8 + ret + +TitleSeq_FadeMusicOut:: + ld a, [wMusicFade] + and a + ret nz + ld a, 3 + ld [wJumptableIndex + 1], a + ld hl, wJumptableIndex + set 7, [hl] + ret + +SetLYOverrides:: + ld hl, wLYOverrides + ld c, $30 +.setly_loop + ld [hli], a + dec c + jr nz, .setly_loop + ret + +PrintPMSubtitle:: + coord hl, 2, 6 + ld b, 15 + ld a, $69 + jr LoadPrintArea + +PrintVersion:: + coord hl, 4, 1 + ld b, $09 + ld a, $60 + +LoadPrintArea:: + ld [hli], a + inc a + dec b + jr nz, LoadPrintArea + ret + +PrintPMJapaneseChara:: + coord hl, 15, 2 + ld a, "こ" + lb bc, 4, 4 + jr PrintBoxArea + +PrintPokemonLogo:: + coord hl, 15, 3 + ld [hl], $B8 + coord hl, 15, 4 + ld [hl], $B9 + coord hl, 1, 2 + ld a, $80 + ld bc, $0E04 + +PrintBoxArea:: + ld de, SCREEN_WIDTH + push bc + push hl + +.xloop + ld [hli], a + inc a + dec b + jr nz, .xloop + pop hl + add hl, de + pop bc + dec c + jr nz, PrintBoxArea + ret + +PrintCopyRight:: + coord hl, 3, 17 + ld a, $41 + ld b, $0D + +.loop + ld [hli], a + inc a + dec b + jr nz, .loop + ret + +SRAMClearMenu:: + call ClearTileMap + call GetMemSGBLayout + call LoadFont + call LoadFontExtra + ld hl, SRAMClear_Message + call PrintText + ld hl, SRAMClear_WinPOS + call CopyMenuHeader + call VerticalMenu + jp c, Init + ld a, [wMenuCursorY] + cp $01 + jp z, Init + + callab InitAllSRAMBanks ; Bank $05 + jp Init + +SRAMClear_Message:: + db "<NULL>すべての セーブデータエりアを" + db "<LINE>クりア しますか?<DONE>" + +SRAMClear_WinPOS:: + db 0 + db 7,14,11,19 + dw SRAMClear_TextChoice ; menu data + db 1 ; default option + +SRAMClear_TextChoice:: + db %11000000 + db 2 + db "いいえ@" + db "はい@" + +IntroCopyRightInfo:: + call ClearTileMap + call LoadFontExtra + ld de, TitleScreenGFX + ld hl, $9600 + lb bc, BANK(TitleScreenGFX), $19 + call Request2bpp + + coord hl, 5, 7 + ld de, IntroCopyRightInfo_Text + jp PlaceString + +IntroCopyRightInfo_Text:: + db $60, $61, $62, $63, $6D, $6E, $6F, $70, $71, $72, $4E ; "(C)1997 Nintendo\n" + db $60, $61, $62, $63, $73, $74, $75, $76, $77, $78, $6B, $6C, $4E ; "(C)1997 Creatures Inc.\n" + db $60, $61, $62, $63, $64, $65, $66, $67, $68, $69, $6A, $6B, $6C, $50 ; "(C)1997 GAME FREAK Inc.{EOL}" + +Set_HoOh:: + coord hl, 7, 9 + ld de, $000D + ld a, $00 + ld b, $07 +.loop + ld c, $07 +.loop2 + ld [hli], a + inc a + dec c + jr nz, .loop2 + add hl, de + dec b + jr nz, .loop + ret + +; Unused code, looks like it sets the font type for the logo? +SetTitleFont:: + ld de, vChars1 + ld hl, TitleScreenLogoGFX + ld bc, 130 tiles + ld a, $04 + jp FarCopyDataDouble + +; Sets the type of art that will be displayed on the title screen +; depending on wTitleSequenceOpeningType. +SetTitleGfx:: + ld hl, wTitleSequenceOpeningType + ld a, [hl] + xor $01 + ld [hl], a + jr nz, .flame + +.note + ld hl, TitleNotesGFX + jr SetTitleGfxNext + +.flame + ld hl, TitleFireGFX +SetTitleGfxNext:: + ld de, vChars0 + ld c, $80 +.loop + ld a, [hli] + ld [de], a + inc de + dec c + jr nz, .loop + ret if DEBUG SECTION "Title screen TEMPORARY", ROMX[$62A5],BANK[1] ; TODO: merge this with the main section above else SECTION "Title screen TEMPORARY", ROMX[$62A2],BANK[1] ; TODO: merge this with the main section above endc + -GameInit:: ; 62a5 +GameInit:: call ClearWindowData ld a, $23 ld [wce5f], a @@ -1,11 +1,5 @@ INCLUDE "constants.asm" -SECTION "Title Screen Sprites", ROMX[$5EB8], BANK[$01] -TitleFireGFX:: -INCBIN "gfx/title/fire.2bpp" -TitleNotesGFX:: -INCBIN "gfx/title/notes.2bpp" - SECTION "Mon Nest Icon", ROMX[$4A0F], BANK[$02] PokedexNestIconGFX:: INCBIN "gfx/pokegear/dexmap_nest_icon.1bpp" @@ -25,6 +19,10 @@ SECTION "Pokegear GFX", ROMX[$4F32], BANK[$02] PokegearGFX:: INCBIN "gfx/pokegear/pokegear.2bpp" +SECTION "Title Screen BG Decoration Border", ROMX[$51FB], BANK[$02] +TitleBGDecorationBorder:: +INCBIN "gfx/title/titlebgdecoration.2bpp" + SECTION "Super Palettes", ROMX[$5B4C], BANK[$02] INCLUDE "data/pokemon/palettes.inc" INCLUDE "data/super_palettes.inc" @@ -42,11 +40,18 @@ INCBIN "gfx/sgb/sgb_border_silver.2bpp" endc SECTION "Title Screen GFX", ROMX[$47CF], BANK[$04] -TitleScreenGFX:: if def(GOLD) -INCBIN "gfx/title/title_gold.2bpp" +TitleScreenGFX:: INCBIN "gfx/title/title.2bpp" +TitleScreenVersionGFX:: INCBIN "gfx/title/title_gold_version.2bpp" +TitleScreenHoOhGFX:: INCBIN "gfx/title/title_hooh.2bpp" +TitleScreenLogoGFX:: INCBIN "gfx/title/title_logo.2bpp" +TitleScreenGoldLogoGFX:: INCBIN "gfx/title/title_goldlogo.2bpp" else -INCBIN "gfx/title/title_silver.2bpp" +TitleScreenGFX:: INCBIN "gfx/title/title.2bpp" +TitleScreenVersionGFX:: INCBIN "gfx/title/title_silver_version.2bpp" +TitleScreenHoOhGFX:: INCBIN "gfx/title/title_hooh.2bpp" +TitleScreenLogoGFX:: INCBIN "gfx/title/title_logo.2bpp" +TitleScreenGoldLogoGFX:: INCBIN "gfx/title/title_silverlogo.2bpp" endc SECTION "Mail Icon GFX", ROMX[$5BB1], BANK[$04] @@ -58,7 +63,7 @@ TrainerCardGFX:: INCBIN "gfx/trainer_card/trainer_card.2bpp" TrainerCardColonGFX:: INCBIN "gfx/trainer_card/colon.2bpp" ; 0x013381--0x013391 TrainerCardIDNoGFX:: INCBIN "gfx/trainer_card/id_no.2bpp" ; 0x013391--0x0133B1 TrainerCardIDNoGFXEnd:: -TrainerCardLeadersGFX:: INCBIN "gfx/trainer_card/leaders.2bpp" ; 0x0133B1--0x013BA1 +TrainerCardLeadersGFX:: INCBIN "gfx/trainer_card/leaders.2bpp" ; 0x0133B1--0x133BA1 if DEBUG || def(GOLD) db $18, $00 ; leftover of previous graphics else diff --git a/gfx/title/title.png b/gfx/title/title.png Binary files differnew file mode 100644 index 0000000..58a8274 --- /dev/null +++ b/gfx/title/title.png diff --git a/gfx/title/title_gold_version.png b/gfx/title/title_gold_version.png Binary files differnew file mode 100644 index 0000000..e55f741 --- /dev/null +++ b/gfx/title/title_gold_version.png diff --git a/gfx/title/title_goldlogo.png b/gfx/title/title_goldlogo.png Binary files differnew file mode 100644 index 0000000..cb6b12d --- /dev/null +++ b/gfx/title/title_goldlogo.png diff --git a/gfx/title/title_hooh.png b/gfx/title/title_hooh.png Binary files differnew file mode 100644 index 0000000..c24e79b --- /dev/null +++ b/gfx/title/title_hooh.png diff --git a/gfx/title/title_logo.png b/gfx/title/title_logo.png Binary files differnew file mode 100644 index 0000000..79a7184 --- /dev/null +++ b/gfx/title/title_logo.png diff --git a/gfx/title/title_silver_version.png b/gfx/title/title_silver_version.png Binary files differnew file mode 100644 index 0000000..2d6d8d0 --- /dev/null +++ b/gfx/title/title_silver_version.png diff --git a/gfx/title/title_silverlogo.png b/gfx/title/title_silverlogo.png Binary files differnew file mode 100644 index 0000000..ffeda09 --- /dev/null +++ b/gfx/title/title_silverlogo.png diff --git a/gfx/title/titlebgdecoration.png b/gfx/title/titlebgdecoration.png Binary files differnew file mode 100644 index 0000000..c57bdd4 --- /dev/null +++ b/gfx/title/titlebgdecoration.png diff --git a/home/init.asm b/home/init.asm index 98fa129..17971c7 100644 --- a/home/init.asm +++ b/home/init.asm @@ -52,7 +52,7 @@ Init: ; 052f ld [rOBP1], a ld [rTMA], a ld [rTAC], a - ld [wcc38], a ; Useless, since WRAM gets cleared right after + ld [wTitleSequenceOpeningType], a ; Useless, since WRAM gets cleared right after ld a, 1 << rTAC_ON | rTAC_4096_HZ ld [rTAC], a ld a, 1 << rLCDC_ENABLE diff --git a/home/map.asm b/home/map.asm index 8ec34be..7244fb1 100644 --- a/home/map.asm +++ b/home/map.asm @@ -26,6 +26,11 @@ RunMapScript:: ; 20ff pop hl ret +; TODO: is this used? +WriteIntod637:: ; 2117 + push af + ; TODO: figure out what variables are concerned here + SECTION "ClearMapBuffer", ROM0[$2123] ClearMapBuffer:: ; 00:2123 ld hl, wMapBuffer @@ -33,3 +38,1857 @@ ClearMapBuffer:: ; 00:2123 ld a, 0 call ByteFill ret + +SetUpMapBuffer:: ; 212f + call ClearMapBuffer + ldh a, [hROMBank] + push af + ld a, BANK(UnknownMapBufferPointers) + call Bankswitch + ld hl, UnknownMapBufferPointers + ld a, [wMapGroup] + ld b, a + ld a, [wMapId] + ld c, a +.search + ld a, [hli] + cp $FF + jr z, .done + cp b + jr nz, .next_with_id + ld a, [hli] + cp c + jr nz, .next_without_id + + ; Match found! + ld de, wMapScriptNumberLocation + call GetMapScriptNumber ; Read map script from pointed location + call CopyWord ; Copy map script pointer + ld de, wUnknownMapPointer + call CopyWord + +.done + pop af + call Bankswitch + ret + +.next_with_id + ld de, 7 + add hl, de + jr .search + +.next_without_id + ld de, 6 + add hl, de + jr .search + +GetMapScriptNumber:: ; 2171 + push hl + ld a, [hli] + ld h, [hl] + ld l, a + ld a, [hl] + ld [wMapScriptNumber], a + pop hl + ret + +CopyWord:: ; 217b + ld a, [hli] + ld [de], a + ld a, [hli] + inc de + ld [de], a + ret + + +SetMapScriptNumber:: ; 2181 + ld [wMapScriptNumber], a + ret + +IncMapScriptNumber:: ; 2185 + ld hl, wMapScriptNumber + inc [hl] + ret + +DecMapScriptNumber:: ; 218a + ld hl, wMapScriptNumber + dec [hl] + ret + +WriteBackMapScriptNumber:: ; 218f + ld a, [wMapScriptNumberLocation] + ld l, a + ld a, [wMapScriptNumberLocation + 1] + ld h, a + ld a, [wMapScriptNumber] + ld [hl], a + ret + + +GetMapPointer:: ; 219c + ld a, [wMapGroup] + ld b, a + ld a, [wMapId] + ld c, a +GetAnyMapPointer:: ; 21a4 + push bc + dec b + ld c, b + ld b, 0 + ld hl, MapGroupPointers + add hl, bc + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + pop bc + dec c + ld b, 0 + ld a, 8 + call AddNTimes + ret + + +SwitchToMapBank:: ; 21bb + ld a, [wMapGroup] + ld b, a + ld a, [wMapId] + ld c, a +SwitchToAnyMapBank:: ; 21c3 + push hl + ld a, BANK(MapGroupPointers) + call Bankswitch + call GetAnyMapPointer + ld a, [hl] + call Bankswitch + pop hl + ret + + +CopyMapPartial:: ; 213d + ldh a, [hROMBank] + push af + ld a, BANK(MapGroupPointers) + call Bankswitch + call GetMapPointer + ld de, wMapPartial + ld bc, wMapPartialEnd - wMapPartial + call CopyBytes + pop af + call Bankswitch + ret + +GetMapAttributesPointer:: ; 21eb + push bc + ldh a, [hROMBank] + push af + ld a, BANK(MapGroupPointers) + call Bankswitch + ld a, [wMapGroup] + ld b, a + ld a, [wMapId] + ld c, a + call GetAnyMapPointer + ld bc, 3 ; TODO: constantify this + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + pop af + call Bankswitch + pop bc + ret + +GetMapEnvironment:: ; 220c + push hl + push bc + ldh a, [hROMBank] + push af + ld a, BANK(MapGroupPointers) + call Bankswitch + call GetMapPointer + ld bc, 2 ; TODO: constantify this + add hl, bc + ld b, [hl] + pop af + call Bankswitch + ld a, b + pop bc + pop hl + ret + +GetAnyMapEnvironment:: ; 2226 + ldh a, [hROMBank] + push af + ld a, BANK(MapGroupPointers) + call Bankswitch + call GetAnyMapPointer + ld bc, 2 ; TODO: constantify this + add hl, bc + ld b, [hl] + pop af + call Bankswitch + ld a, b + ret + +GetWorldMapLocation:: ; 223c + ldh a, [hROMBank] + push af + ld a, BANK(MapGroupPointers) + call Bankswitch + call GetAnyMapPointer + ld bc, 5 ; TODO: constantify this + add hl, bc + ld b, [hl] + pop af + call Bankswitch + ld a, b + ret + + +EmptyFunction2252:: ; 2252 + ret + + +LoadMap:: ; 2253 + ldh a, [hMapEntryMethod] + and a ; Possible bug: if the entry method is $X0, this will overflow + ret z + and $0F + dec a + ld hl, .jumptable + call CallJumptable + xor a + ldh [hMapEntryMethod], a + scf + ret + +.jumptable + dw MapSetup_Continue + dw MapSetup_22af ; TODO + dw MapSetup_Reload + dw MapSetup_22de ; TODO + dw MapSetup_22de ; TODO + dw MapSetup_Warp + dw MapSetup_Connection + dw MapSetup_2275 ; TODO + + +MapSetup_2275:: ; 2275 + ldh a, [hROMBank] + push af + call MapSetup_22af ; TODO + pop af + call Bankswitch + ret + +MapSetup_Reload:: ; 2280 + call DisableLCD + call DisableAudio + call VolumeOff + call SwitchToMapBank + call LoadGraphics + call ChangeMap + call SaveScreen + call LoadMapTimeOfDay + call EnableLCD + call PlayMapMusic + ld a, $88 ; TODO: constantify this + ld [wMusicFade], a + ld b, 9 ; TODO: constantify this + call GetSGBLayout + call LoadWildMons + call FadeIn + ret + +MapSetup_22af:: ; 22af + call DisableLCD + call DisableAudio + call VolumeOff + call SwitchToMapBank + call SetUpMapBuffer + call InitUnknownBuffercc9e + call LoadGraphics + call ChangeMap + call LoadMapTimeOfDay + call EnableLCD + call PlayMapMusic + ld a, $88 ; TODO: constantify this + ld [wMusicFade], a + ld b, 9 ; TODO: constantify this + call GetSGBLayout + call FadeIn + ret + +MapSetup_22de:: ; 22de + callab OverworldFadeOut + +MapSetup_Continue:: ; 22e6 + call DisableLCD + call DisableAudio + call VolumeOff + callab DebugWarp + call CopyMapPartialAndAttributes + call SetUpMapBuffer + call InitUnknownBuffercc9e + call RefreshPlayerCoords + call GetCoordOfUpperLeftCorner + call LoadGraphics + call ChangeMap + call LoadMapTimeOfDay + call InitializeVisibleSprites + call EnableLCD + call PlayMapMusic + ld a, $88 ; TODO: constantify this + ld [wMusicFade], a + ld b, 9 ; TODO: constantify this + call GetSGBLayout + call LoadWildMons + call $242C ; TODO + call FadeIn + ret + +MapSetup_Warp:: ; 232c + callab OverworldFadeOut + call DisableLCD + call Function27C7 ; TODO + ld a, [wNextWarp] + ld [wWarpNumber], a + ld a, [wNextMapGroup] + ld [wMapGroup], a + ld a, [wNextMapId] + ld [wMapId], a + call CopyMapPartialAndAttributes + call SetUpMapBuffer + call InitUnknownBuffercc9e + call RestoreFacingAfterWarp + call RefreshPlayerCoords + call LoadGraphics + call ChangeMap + call LoadMapTimeOfDay + call InitializeVisibleSprites + call EnableLCD + call PlayMapMusic + ld b, 9 ; TODO: constantify this + call GetSGBLayout + call LoadWildMons + call FadeIn + call Function2407 ; TODO + ret + +LoadMapTimeOfDay:: ; 237c + callab ReplaceTimeOfDayPals + call LoadMapPart + call .ClearBGMap + call .PushAttrMap + ret + +.ClearBGMap ; 238e + ld a, HIGH(vBGMap0) + ld [wBGMapAnchor + 1], a + xor a ; LOW(vBGMap0) + ld [wBGMapAnchor], a + ldh [hSCY], a + ldh [hSCX], a + + ld a, "■" + ld bc, vBGMap1 - vBGMap0 + hlbgcoord 0, 0 + call ByteFill + ret + +.PushAttrMap ; 23a7 + decoord 0, 0 + hlbgcoord 0, 0 + ld c, SCREEN_WIDTH + ld b, SCREEN_HEIGHT +.row + push bc +.column + ld a, [de] + inc de + ld [hli], a + dec c + jr nz, .column + ld bc, BG_MAP_WIDTH - SCREEN_WIDTH + add hl, bc + pop bc + dec b + jr nz, .row + ret + +LoadWildMons:: ; 23c1 + callab _LoadWildMons + ret + +LoadGraphics:: ; 23ca + call LoadTileset + call LoadTilesetGFX + callba RefreshSprites + call LoadFontExtra + ret + +InitializeVisibleSprites:: ; 23dc + callab _InitializeVisibleSprites + ret + +FadeIn:: ; 23e5 ; This is not OverworldFadeIn, but I don't know what it is + call Function202c ; TODO + call RefreshTiles + ld hl, wVramState + set 0, [hl] + call Function2407 + callab _UpdateSprites + call DelayFrame + callab OverworldFadeIn + ret + +Function2407:: ; 2407 + ; TODO + + +SECTION "Map stuff", ROM0[$2439] +MapSetup_Connection:: ; 2439 + call EnterMapConnection + call CopyMapPartialAndAttributes + call SetUpMapBuffer + call InitUnknownBuffercc9e + call RefreshPlayerCoords + call InitializeVisibleSprites + call ChangeMap + call SaveScreen + call FadeToMapMusic + ld b, 9 ; TODO: constantify this + call GetSGBLayout + call LoadWildMons + scf + ret + +CheckMovingOffEdgeOfMap:: ; 245e + ld a, [wPlayerStepDirection] + cp STANDING + ret z + and a ; DOWN + jr z, .down + cp UP + jr z, .up + cp LEFT + jr z, .left + cp RIGHT + jr z, .right + and a + ret + +.down + ld a, [wPlayerStandingMapY] + sub 4 + ld b, a + ld a, [wMapHeight] + add a + cp b + jr z, .ok + and a + ret + +.up + ld a, [wPlayerStandingMapY] + sub 4 + cp -1 + jr z, .ok + and a + ret + +.left + ld a, [wPlayerStandingMapX] + sub 4 + cp -1 + jr z, .ok + and a + ret + +.right + ld a, [wPlayerStandingMapX] + sub 4 + ld b, a + ld a, [wMapWidth] + add a + cp b + jr z, .ok + and a + ret + +.ok + ld a, MAPSETUP_CONNECTION + ldh [hMapEntryMethod], a + scf + ret + +EnterMapConnection: ; 24af +; Return carry if a connection has been entered. + ld a, [wPlayerStepDirection] + and a + jp z, .south + cp UP + jp z, .north + cp LEFT + jp z, .west + cp RIGHT + jp z, .east + ret + +.west + ld a, [wWestConnectedMapGroup] + ld [wMapGroup], a + ld a, [wWestConnectedMapNumber] + ld [wMapId], a + ld a, [wWestConnectionStripXOffset] + ld [wXCoord], a + ld a, [wWestConnectionStripYOffset] + ld hl, wYCoord + add [hl] + ld [hl], a + ld c, a + ld hl, wWestConnectionWindow + ld a, [hli] + ld h, [hl] + ld l, a + srl c + jr z, .skip_to_load + ld a, [wWestConnectedMapWidth] + add 6 + ld e, a + ld d, 0 + +.loop + add hl, de + dec c + jr nz, .loop + +.skip_to_load + ld a, l + ld [wOverworldMapAnchor], a + ld a, h + ld [wOverworldMapAnchor + 1], a + jp .done + +.east + ld a, [wEastConnectedMapGroup] + ld [wMapGroup], a + ld a, [wEastConnectedMapNumber] + ld [wMapId], a + ld a, [wEastConnectionStripXOffset] + ld [wXCoord], a + ld a, [wEastConnectionStripYOffset] + ld hl, wYCoord + add [hl] + ld [hl], a + ld c, a + ld hl, wEastConnectionWindow + ld a, [hli] + ld h, [hl] + ld l, a + srl c + jr z, .skip_to_load2 + ld a, [wEastConnectedMapWidth] + add 6 + ld e, a + ld d, 0 + +.loop2 + add hl, de + dec c + jr nz, .loop2 + +.skip_to_load2 + ld a, l + ld [wOverworldMapAnchor], a + ld a, h + ld [wOverworldMapAnchor + 1], a + jp .done + +.north + ld a, [wNorthConnectedMapGroup] + ld [wMapGroup], a + ld a, [wNorthConnectedMapNumber] + ld [wMapId], a + ld a, [wNorthConnectionStripYOffset] + ld [wYCoord], a + ld a, [wNorthConnectionStripXOffset] + ld hl, wXCoord + add [hl] + ld [hl], a + ld c, a + ld hl, wNorthConnectionWindow + ld a, [hli] + ld h, [hl] + ld l, a + ld b, 0 + srl c + add hl, bc + ld a, l + ld [wOverworldMapAnchor], a + ld a, h + ld [wOverworldMapAnchor + 1], a + jp .done + +.south + ld a, [wSouthConnectedMapGroup] + ld [wMapGroup], a + ld a, [wSouthConnectedMapNumber] + ld [wMapId], a + ld a, [wSouthConnectionStripYOffset] + ld [wYCoord], a + ld a, [wSouthConnectionStripXOffset] + ld hl, wXCoord + add [hl] + ld [hl], a + ld c, a + ld hl, wSouthConnectionWindow + ld a, [hli] + ld h, [hl] + ld l, a + ld b, 0 + srl c + add hl, bc + ld a, l + ld [wOverworldMapAnchor], a + ld a, h + ld [wOverworldMapAnchor + 1], a +.done + scf + ret + + +WarpCheck:: ; 259f + call GetDestinationWarpPointer + ret nc + ld a, [hli] + ld [wNextWarp], a + ld a, [hli] + ld [wNextMapGroup], a + ld a, [hli] + ld [wNextMapId], a + ld a, c + ld [wPrevWarp], a + ld a, MAPSETUP_WARP + ldh [hMapEntryMethod], a + scf + ret + +GetDestinationWarpPointer: ; 25b9 + ld a, [wPlayerStandingMapY] + sub 4 + ld d, a + ld a, [wPlayerStandingMapX] + sub 4 + ld e, a + ld a, [wCurrMapWarpCount] + ld c, a + and a + ret z + + ld hl, wCurrMapWarps +.next + ld a, [hli] + cp d + jr nz, .nope + ld a, [hl] + cp e + jr z, .found_warp +.nope + push de + ld de, 4 ; TODO: constantify this + add hl, de + pop de + dec c + jr nz, .next + xor a + ret + +.found_warp + ld a, [wCurrMapWarpCount] + inc a + sub c + ld c, a + inc hl + scf + ret + + +CopyMapPartialAndAttributes:: ; 25ea + call SwitchToMapBank + call CopyAndReadHeaders + call ReadObjectEvents + ret + +CopyAndReadHeaders:: ; 25f4 + call CopyMapPartial + call GetMapAttributesPointer + ld hl, wMapAttributesPtr + ld a, [hli] + ld h, [hl] + ld l, a + ld de, wMapAttributes + ld c, wMapAttributesEnd - wMapAttributes +.copy + ld a, [hli] + ld [de], a + inc de + dec c + jr nz, .copy + call GetMapConnections + ld hl, wMapObjectsPtr + ld a, [hli] + ld h, [hl] + ld l, a + inc hl + inc hl + call ReadWarps + call ReadSigns + ret + +GetMapConnections:: ; 261d + ld a, $ff + ld [wNorthConnectedMapGroup], a + ld [wSouthConnectedMapGroup], a + ld [wWestConnectedMapGroup], a + ld [wEastConnectedMapGroup], a + + ld a, [wMapConnections] + ld b, a + bit 3, b + jr z, .no_north + ld de, wNorthMapConnection + call GetMapConnection +.no_north + + bit 2, b + jr z, .no_south + ld de, wSouthMapConnection + call GetMapConnection +.no_south + + bit 1, b + jr z, .no_west + ld de, wWestMapConnection + call GetMapConnection +.no_west + + bit 0, b + jr z, .no_east + ld de, wEastMapConnection + call GetMapConnection +.no_east + + ret + +GetMapConnection:: ; 2658 + ld c, wSouthMapConnection - wNorthMapConnection +.copy + ld a, [hli] + ld [de], a + inc de + dec c + jr nz, .copy + ret + + +ReadWarps:: ; 2661 + ld a, [hli] + ld [wCurrMapWarpCount], a + and a + ret z + ld c, a + ld de, wCurrMapWarps +.next + ld b, 5 ; TODO: constantify this +.copy + ld a, [hli] + ld [de], a + inc de + dec b + jr nz, .copy + inc hl + inc hl + dec c + jr nz, .next + ret + + +ReadSigns:: ; 2679 + ld a, [hli] + ld [wCurrMapSignCount], a + and a + ret z + ld c, a + ld de, wCurrMapSigns +.next + ld b, 4 +.copy + ld a, [hli] + ld [de], a + inc de + dec b + jr nz, .copy + dec c + jr nz, .next + ret + + +ReadObjectEvents:: ; 268f + push hl + call ClearObjectStructs + pop de + ld hl, wMap2Object + ld a, [de] + inc de + ld [wCurrMapObjectCount], a + and a + jr z, .skip + + ld c, a +.next + push bc + push hl + ld a, $ff + ld [hli], a + ld b, wMap2ObjectUnused - wMap2ObjectSprite +.copy + ld a, [de] + inc de + ld [hli], a + dec b + jr nz, .copy + pop hl + ld bc, wMap3Object - wMap2Object + add hl, bc + pop bc + dec c + jr nz, .next + +.skip + ld a, [wCurrMapObjectCount] + ld c, a + ld a, 16 ; 16 objects -- but this causes an overflow, since we only start from object 2 + sub c + jr z, .finish + ld bc, 1 + add hl, bc ; Very thorough optimization. Don't do this at home, kids. + ld bc, wMap3Object - wMap2Object +.clear + ld [hl], 0 + add hl, bc + dec a + jr nz, .clear + +.finish + ld h, d + ld l, e + ret + +ClearObjectStructs:: ; 26cf + xor a + ld [$CE7F], a ; TODO + ld hl, wObject1Struct + ld de, wObject2Struct - wObject1Struct + ld c, 7 +.clear_struct + ld [hl], a + add hl, de + dec c + jr nz, .clear_struct + + ld hl, $D00F ; TODO + ld de, 16 + ld c, 4 + xor a +.clear_unk ; TODO + ld [hl], a + add hl, de + dec c + jr nz, .clear_unk + ret + + +ReadWord:: ; 26ef ; TODO: is this used? + ld e, [hl] + inc hl + ld d, [hl] + inc hl + ret + + +InitUnknownBuffercc9e:: ; 26f4 + xor a + ld hl, wUnknownWordcc9c + ld [hli], a + ld [hli], a + ld hl, wUnknownBuffercc9e ; useless + ld bc, 14 ; TODO: constantify this + ld a, $ff + call ByteFill + ld hl, wUnknownMapPointer + ld e, [hl] + inc hl + ld d, [hl] + ld a, e + or d + jr z, .null + + ld a, [wMapBuffer] + ld l, a + ld h, 0 + add hl, hl + add hl, hl + add hl, de + inc hl + inc hl + ld c, [hl] + inc hl + ld b, [hl] + ld de, wUnknownBuffercc9e - 2 +.next + ld a, [bc] + inc bc + cp $ff ; Could have used one of the `inc a` below + jr z, .done + inc a + inc a + and $0f + ld l, a + ld h, 0 + add hl, de + ld [hl], 0 + jr .next + +.null + ld hl, wUnknownBuffercc9e + ld bc, 14 ; TODO: constantify this + xor a + call ByteFill +.done + ret + + +RestoreFacingAfterWarp:: ; 273d + ld hl, wMapObjectsPtr + ld a, [hli] + ld h, [hl] + ld l, a + ; Point to 1st warp + inc hl + inc hl + inc hl + ld a, [wWarpNumber] + dec a + ld c, a + ld b, 0 + ld a, 7 ; Size of warp ; TODO: constantify this + call AddNTimes + ld a, [hli] + ld [wYCoord], a + ld a, [hli] + ld [wXCoord], a + call GetCoordOfUpperLeftCorner + ret + + +Function275e:: ; 275e ; TODO: is this used? + inc hl + inc hl + inc hl + ld a, [hli] + ld [wOverworldMapAnchor], a + ld a, [hl] + ld [wOverworldMapAnchor + 1], a + ld a, [wYCoord] + and 1 + ld [wMetatileStandingY], a + ld a, [wXCoord] + and 1 + ld [wMetatileStandingX], a + ret + + +GetCoordOfUpperLeftCorner:: ; 277a + ld hl, wOverworldMap + ld a, [wXCoord] + bit 0, a + jr nz, .increment_then_halve1 + srl a + add a, 1 + jr .resume + +.increment_then_halve1 + add a, 1 + srl a + +.resume + ld c, a + ld b, 0 + add hl, bc + ld a, [wMapWidth] + add a, 6 + ld c, a + ld b, 0 + ld a, [wYCoord] + bit 0, a + jr nz, .increment_then_halve2 + srl a + add a, 1 + jr .resume2 + +.increment_then_halve2 + add a, 1 + srl a + +.resume2 + call AddNTimes + ld a, l + ld [wOverworldMapAnchor], a + ld a, h + ld [wOverworldMapAnchor + 1], a + ld a, [wYCoord] + and 1 + ld [wMetatileStandingY], a + ld a, [wXCoord] + and 1 + ld [wMetatileStandingX], a + ret + +Function27C7:: ; 27c7 ; TODO + call GetMapEnvironment + cp 2 + jr z, .interior + cp 1 + jr z, .interior + ret +.interior + ld a, [wNextMapGroup] + ld b, a + ld a, [wNextMapId] + ld c, a + call GetAnyMapEnvironment + cp 3 + jr z, .exterior + cp 4 + jr z, .exterior + cp 6 + jr z, .exterior + ret + +.exterior + ld hl, $D4B2 ; TODO: figure out what this is + ld a, [wPrevWarp] + ld [hli], a + ld a, [wMapGroup] + ld [hli], a + ld a, [wMapId] + ld [hli], a + ret + +LoadMapPart:: ; 27fb + callab UpdateTimeOfDayPal + + ldh a, [hROMBank] + push af + ld a, [wTilesetBank] + call Bankswitch + + call LoadMetatiles + ld a, "■" + hlcoord 0, 0 + ld bc, SCREEN_WIDTH * SCREEN_HEIGHT + call ByteFill + + call ApplyFlashlight + + pop af + call Bankswitch + ret + +LoadMetatiles:: ; 2822 + ld a, [wOverworldMapAnchor] + ld e, a + ld a, [wOverworldMapAnchor + 1] + ld d, a + ld hl, wTileMapBackup + ld b, 5 ; TODO: constantify this +.row + push de + push hl + ld c, 6 ; TODO: constantify this +.tile + push bc + push de + push hl + ld a, [de] + ld c, a + call DrawMetatile + pop hl + ld bc, 4 + add hl, bc + pop de + inc de + pop bc + dec c + jr nz, .tile + pop hl + ld de, BG_MAP_WIDTH * 3 + add hl, de + pop de + ld a, [wMapWidth] + add a, 6 + add a, e + ld e, a + jr nc, .nocarry + inc d +.nocarry + dec b + jr nz, .row + ret + +ApplyFlashlight:: ; 285a + ld hl, wTileMapBackup + ld a, [wMetatileStandingY] + and a + jr z, .top_row + ld bc, $30 ; TODO: constantify this + add hl, bc +.top_row + ld a, [wMetatileStandingX] + and a + jr z, .left_col + inc hl + inc hl +.left_col + + ldh a, [hOverworldFlashlightEffect] + and a + jr z, .no_flashlight + cp 1 + jr z, .force_1 + cp 2 + jr z, .force_2 + cp 3 + jr z, .force_3 + jp .force_9001 + +.no_flashlight + ld de, wTileMap + ld b, SCREEN_HEIGHT ; TODO: constantify this +.row + ld c, SCREEN_WIDTH +.tile + ld a, [hli] + ld [de], a + inc de + dec c + jr nz, .tile + + ld a, l + add a, 4 + ld l, a + jr nc, .nocarry + inc h +.nocarry + dec b + jr nz, .row + ret + +; redraw_with_flashlight force +; force = 1, 2 or 3 +; 0 and 4 have special handling, see above and below +redraw_with_flashlight: MACRO + decoord \1 * 2, \1 * 2 + ld bc, \1 * $32 ; TODO: constantify the $32 + add hl, bc + ld c, SCREEN_HEIGHT - \1 * 4 +.row\1 + ld b, SCREEN_HEIGHT - \1 * 4 +.tile\1 + ld a, [hli] + ld [de], a + inc de + dec b + jr nz, .tile\1 + ld a, l + add a, 6 + \1 * 4 + ld l, a + jr nc, .nohlcarry\1 + inc h +.nohlcarry\1 + ld a, e + add a, 2 + \1 * 4 + ld e, a + jr nc, .nodecarry\1 + inc d +.nodecarry\1 + dec c + jr nz, .row\1 +ENDM + +.force_1 ; 289b + redraw_with_flashlight 1 + ret + +.force_2 ; 28be + redraw_with_flashlight 2 + ret + +.force_3 ; 28e1 + redraw_with_flashlight 3 + ret + +.force_9001 ; 2904 + ; Actually force 4, but this also applies to larger values + decoord 4 * 2, 4 * 2 + ld bc, 4 * $32 ; TODO: constantify the $32 + add hl, bc + ld a, [hli] + ld [de], a + inc de + ld a, [hli] + ld [de], a + ld bc, 6 + 4 * 4 + add hl, bc + ld a, e + add a, 2 + 4 * 4 + 1 ; Compensate missing `inc de` + ld e, a + jr nc, .nocarry9001 + inc d +.nocarry9001 + ld a, [hli] + ld [de], a + inc de + ld a, [hli] + ld [de], a + ret + +DrawMetatile:: ; 2921 + push hl + ld hl, wTilesetBlocksAddress + ld a, [hli] + ld h, [hl] + ld l, a + swap c + ld a, c + and $0f + ld b, a + ld a, c + and $f0 + ld c, a + add hl, bc + pop de + lb bc, $14, 4 ; TODO: constantify $14 +.row +REPT 4 + ld a, [hli] + ld [de], a + inc de +ENDR + ld a, e + add a, b + ld e, a + jr nc, .nocarry + inc d +.nocarry + dec c + jr nz, .row + ret + + +ChangeMap:: ; 294d + ld hl, wOverworldMap + ld bc, wOverworldMapEnd - wOverworldMap + ld a, 0 + call ByteFill + + ld hl, wOverworldMap + ld a, [wMapWidth] + ldh [hConnectedMapWidth], a + add a, 6 + ldh [hConnectionStripLength], a + ld c, a + ld b, 0 + add hl, bc + add hl, bc + add hl, bc + ld c, 3 + add hl, bc + + ld a, [wMapBlocksPointer] + ld e, a + ld a, [wMapBlocksPointer + 1] + ld d, a + ld a, [wMapHeight] + ld b, a +.row + push hl + ldh a, [hConnectedMapWidth] + ld c, a +.col + ld a, [de] + inc de + ld [hli], a + dec c + jr nz, .col + pop hl + ldh a, [hConnectionStripLength] + add l + ld l, a + jr nc, .okay + inc h +.okay + dec b + jr nz, .row + +; FillMapConnections:: ; 298e + + ld a, [wNorthConnectedMapGroup] + cp $ff + jr z, .south + ld b, a + ld a, [wNorthConnectedMapNumber] + ld c, a + call SwitchToAnyMapBank + + ld a, [wNorthConnectionStripPointer] + ld l, a + ld a, [wNorthConnectionStripPointer + 1] + ld h, a + ld a, [wNorthConnectionStripLocation] + ld e, a + ld a, [wNorthConnectionStripLocation + 1] + ld d, a + ld a, [wNorthConnectionStripLength] + ldh [hConnectionStripLength], a + ld a, [wNorthConnectedMapWidth] + ldh [hConnectedMapWidth], a + call FillNorthConnectionStrip + +.south + ld a, [wSouthConnectedMapGroup] + cp $ff + jr z, .west + ld b, a + ld a, [wSouthConnectedMapNumber] + ld c, a + call SwitchToAnyMapBank + + ld a, [wSouthConnectionStripPointer] + ld l, a + ld a, [wSouthConnectionStripPointer + 1] + ld h, a + ld a, [wSouthConnectionStripLocation] + ld e, a + ld a, [wSouthConnectionStripLocation + 1] + ld d, a + ld a, [wSouthConnectionStripLength] + ldh [hConnectionStripLength], a + ld a, [wSouthConnectedMapWidth] + ldh [hConnectedMapWidth], a + call FillSouthConnectionStrip + +.west + ld a, [wWestConnectedMapGroup] + cp $ff + jr z, .east + ld b, a + ld a, [wWestConnectedMapNumber] + ld c, a + call SwitchToAnyMapBank + + ld a, [wWestConnectionStripPointer] + ld l, a + ld a, [wWestConnectionStripPointer + 1] + ld h, a + ld a, [wWestConnectionStripLocation] + ld e, a + ld a, [wWestConnectionStripLocation + 1] + ld d, a + ld a, [wWestConnectionStripLength] + ld b, a + ld a, [wWestConnectedMapWidth] + ldh [hConnectionStripLength], a + call FillWestConnectionStrip + +.east + ld a, [wEastConnectedMapGroup] + cp $ff + jr z, .done + ld b, a + ld a, [wEastConnectedMapNumber] + ld c, a + call SwitchToAnyMapBank + + ld a, [wEastConnectionStripPointer] + ld l, a + ld a, [wEastConnectionStripPointer + 1] + ld h, a + ld a, [wEastConnectionStripLocation] + ld e, a + ld a, [wEastConnectionStripLocation + 1] + ld d, a + ld a, [wEastConnectionStripLength] + ld b, a + ld a, [wEastConnectedMapWidth] + ldh [hConnectionStripLength], a + call FillEastConnectionStrip + +.done + ret + +FillNorthConnectionStrip:: +FillSouthConnectionStrip:: ; 2a3d + + ld c, 3 +.y + push de + + push hl + ldh a, [hConnectionStripLength] + ld b, a +.x + ld a, [hli] + ld [de], a + inc de + dec b + jr nz, .x + pop hl + + ldh a, [hConnectedMapWidth] + ld e, a + ld d, 0 + add hl, de + pop de + + ld a, [wMapWidth] + add a, 6 + add e + ld e, a + jr nc, .okay + inc d +.okay + dec c + jr nz, .y + ret +; 25f6 + +FillWestConnectionStrip:: +FillEastConnectionStrip:: ; 2a60 + +.loop + ld a, [wMapWidth] + add a, 6 + ldh [hConnectedMapWidth], a + + push de + + push hl + ld a, [hli] + ld [de], a + inc de + ld a, [hli] + ld [de], a + inc de + ld a, [hli] + ld [de], a + inc de + pop hl + + ldh a, [hConnectionStripLength] + ld e, a + ld d, 0 + add hl, de + pop de + + ldh a, [hConnectedMapWidth] + add e + ld e, a + jr nc, .okay + inc d +.okay + dec b + jr nz, .loop + ret + + +SECTION "LoadTilesetGFX", ROM0[$2D26] +LoadTilesetGFX:: ; 2d26 + call GetMapEnvironment + cp 1 ; TODO: constantify this + jr z, .exterior + cp 2 ; TODO: constantify this + jr z, .exterior + ld a, [wMapTileset] + cp $1B ; TODO: constantify this + jr z, .exterior + + ld a, [wTilesetTilesAddress] + ld e, a + ld a, [wTilesetTilesAddress + 1] + ld d, a + ld hl, vTileset + ld a, [wTilesetBank] + ld b, a + ld c, $60 + call Get2bpp + xor a + ldh [hTileAnimFrame], a + ret + +.exterior + ld de, CommonExteriorTiles ; TODO: maybe find a better name + ld hl, vTileset + lb bc, BANK(CommonExteriorTiles), $20 + call Get2bpp + + ld a, [wTilesetTilesAddress] + ld e, a + ld a, [wTilesetTilesAddress + 1] + ld d, a + ld hl, vExteriorTileset + ld a, [wTilesetBank] + ld b, a + ld c, $40 + call Get2bpp + xor a + ldh [hTileAnimFrame], a + ret + + +RefreshPlayerCoords:: ; 2d74 + ld a, [wXCoord] + add a, 4 + ld d, a + ld hl, wPlayerStandingMapX + sub [hl] + ld [hl], d + ld hl, wPlayerObjectXCoord + ld [hl], d + ld hl, wPlayerLastMapX + ld [hl], d + ld d, a + ld a, [wYCoord] + add a, 4 + ld e, a + ld hl, wPlayerStandingMapY + sub [hl] + ld [hl], e + ld hl, wPlayerObjectYCoord + ld [hl], e + ld hl, wPlayerLastMapY + ld [hl], e + ld e, a + + ld a, [wObjectFollow_Leader] + cp 1 + ret nz + ld a, [wObjectFollow_Follower] + and a + ret z + + ; This piece of code has been removed in pokegold (note that the conditions above were altered, as well) + call GetObjectStruct + ld hl, 16 ; TODO: constantify this + add hl, bc + ld a, [hl] + add a, d + ld [hl], a + ld [wMap1ObjectXCoord], a + ld hl, 18 ; TODO: constantify this + add hl, bc + ld a, [hl] + add a, d + ld [hl], a + ld hl, 17 ; TODO: constantify this + add hl, bc + ld a, [hl] + add a, e + ld [hl], a + ld [wMap1ObjectYCoord], a + ld hl, 19 + add hl, bc + ld a, [hl] + add a, e + ld [hl], a + ret + + +BufferScreen:: ; 2dcd + ld hl, wOverworldMapAnchor + ld a, [hli] + ld h, [hl] + ld l, a + ld de, wScreenSave + ld c, 5 + ld b, 6 +.row + push bc + push hl +.col + ld a, [hli] + ld [de], a + inc de + dec b + jr nz, .col + pop hl + ld a, [wMapWidth] + add a, 6 + ld c, a + ld b, 0 + add hl, bc + pop bc + dec c + jr nz, .row + ret + +SaveScreen:: ; 2df1 + ld hl, wOverworldMapAnchor + ld a, [hli] + ld h, [hl] + ld l, a + ld de, wScreenSave + ld a, [wMapWidth] + add 6 + ldh [hMapObjectIndexBuffer], a + ld a, [wPlayerStepDirection] + and a + jr z, .down + cp UP + jr z, .up + cp LEFT + jr z, .left + cp RIGHT + jr z, .right + ret + +.up + ld de, wScreenSave + 6 + ldh a, [hMapObjectIndexBuffer] + ld c, a + ld b, 0 + add hl, bc + jr .vertical + +.down + ld de, wScreenSave +.vertical + ld b, 6 + ld c, 4 + jr .load_neighbor + +.left + ld de, wScreenSave + 1 + inc hl + jr .horizontal + +.right + ld de, wScreenSave +.horizontal + ld b, 5 + ld c, 5 + +.load_neighbor ; 2e35 +.row + push bc + push hl + push de +.col + ld a, [de] + inc de + ld [hli], a + dec b + jr nz, .col + pop de + ld a, e + add a, 6 + ld e, a + jr nc, .okay + inc d + +.okay + pop hl + ldh a, [hConnectionStripLength] + ld c, a + ld b, 0 + add hl, bc + pop bc + dec c + jr nz, .row + ret + + +RefreshTiles:: ; 2e52 + call .left_right + call .up_down + ld a, [wPlayerStandingMapX] + ld d, a + ld a, [wPlayerStandingMapY] + ld e, a + call GetCoordTile + ld [wPlayerStandingTile], a + ret + +.up_down ; 2e67 + ld a, [wPlayerStandingMapX] + ld d, a + ld a, [wPlayerStandingMapY] + ld e, a + push de + inc e + call GetCoordTile + ld [wTileDown], a + pop de + dec e + call GetCoordTile + ld [wTileUp], a + ret + +.left_right ; 2e80 + ld a, [wPlayerStandingMapX] + ld d, a + ld a, [wPlayerStandingMapY] + ld e, a + push de + dec d + call GetCoordTile + ld [wTileLeft], a + pop de + inc d + call GetCoordTile + ld [wTileRight], a + ret + + +GetFacingTileCoord:: ; 2e99 + ld a, [wPlayerWalking] ; TODO: wPlayerDirection in Crystal. Not here? + and %1100 + srl a + srl a + ld l, a + ld h, 0 + add hl, hl + add hl, hl + ld de, .directions + add hl, de + + ld d, [hl] + inc hl + ld e, [hl] + inc hl + ld a, [hli] + ld h, [hl] + ld l, a + + ld a, [wPlayerStandingMapX] + add a, d + ld d, a + ld a, [wPlayerStandingMapY] + add a, e + ld e, a + ld a, [hl] + ret + +.directions + db 0, 1 + dw wTileDown + + db 0, -1 + dw wTileUp + + db -1, 0 + dw wTileLeft + + db 1, 0 + dw wTileRight + +GetCoordTile:: ; 2ece +; Get the collision byte for tile d, e + call GetBlockLocation + ld a, [hl] + and a + jr z, .nope + ld l, a + ld h, 0 + add hl, hl + add hl, hl + ld a, [wTilesetCollisionAddress] + ld c, a + ld a, [wTilesetCollisionAddress + 1] + ld b, a + add hl, bc + rr d + jr nc, .nocarry + inc hl + +.nocarry + rr e + jr nc, .nocarry2 + inc hl + inc hl + +.nocarry2 + ld a, [wTilesetBank] + call GetFarByte + ret + +.nope + ld a, -1 + ret + +GetBlockLocation:: ; 2ef8 + ld a, [wMapWidth] + add a, 6 + ld c, a + ld b, 0 + ld hl, wOverworldMap + 1 + add hl, bc + ld a, e + srl a + jr z, .nope + and a +.loop + srl a + jr nc, .ok + add hl, bc + +.ok + sla c + rl b + and a + jr nz, .loop + +.nope + ld c, d + srl c + ld b, 0 + add hl, bc + ret + + +SECTION "LoadTileset", ROM0[$2F48] +LoadTileset:: ; 2f48 + push hl + push bc + + ld hl, Tilesets + ld bc, wTilesetEnd - wTileset + ld a, [wMapTileset] + call AddNTimes + + ld de, wTileset + ld bc, wTilesetEnd - wTileset + + ld a, BANK(Tilesets) + call FarCopyBytes + + ld a, 1 + ldh [hMapAnims], a + xor a + ldh [hTileAnimFrame], a + + pop bc + pop hl + ret diff --git a/home/map_objects.asm b/home/map_objects.asm deleted file mode 100644 index 70cba50..0000000 --- a/home/map_objects.asm +++ /dev/null @@ -1,676 +0,0 @@ -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 deleted file mode 100644 index 8b3db6f..0000000 --- a/home/math.asm +++ /dev/null @@ -1,25 +0,0 @@ -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 2d8f1f3..64d3f9a 100644 --- a/home/menu.asm +++ b/home/menu.asm @@ -210,15 +210,15 @@ Function1e8a:: ; 00:1e8a ldh [hBGMapMode], a xor a call OpenSRAM - call GetWindowStackTop + call Function1cae ld a, l ld [wWindowStackPointer], a ld a, h ld [wWindowStackPointer + 1], a - call PopWindow + call Function1c7a ld d, h ld e, l - call RestoreTileBackup + call Function1c60 call CloseSRAM ld hl, wWindowStackSize dec [hl] @@ -271,7 +271,7 @@ GetMenuIndexSet:: ; 00:1ec3 Function1ee9:: ; 1ee9 call MenuBoxCoord2Tile - call GetMenuBoxDims + call Function1c86 ld a, [wMenuDataItems] add a cp b diff --git a/home/menu_window.asm b/home/menu_window.asm deleted file mode 100644 index c4d3842..0000000 --- a/home/menu_window.asm +++ /dev/null @@ -1,246 +0,0 @@ -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 OverworldTextModeSwitch - - 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 deleted file mode 100644 index 3eabb12..0000000 --- a/home/misc_32c8.asm +++ /dev/null @@ -1,98 +0,0 @@ -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 deleted file mode 100644 index e84e552..0000000 --- a/home/mon_stats.asm +++ /dev/null @@ -1,82 +0,0 @@ -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 0a17688..e8b4eeb 100644 --- a/home/print_text.asm +++ b/home/print_text.asm @@ -48,23 +48,4 @@ PrintLetterDelay:: ; 33a3 (0:33a3) pop de pop hl ret -; 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 +; 0x33e3
\ No newline at end of file diff --git a/home/scrolling_menu.asm b/home/scrolling_menu.asm deleted file mode 100644 index 28d3d3e..0000000 --- a/home/scrolling_menu.asm +++ /dev/null @@ -1,93 +0,0 @@ -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 deleted file mode 100644 index ca97f42..0000000 --- a/home/tilemap.asm +++ /dev/null @@ -1,70 +0,0 @@ -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:: - 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 deleted file mode 100644 index 54aea4d..0000000 --- a/home/unknown_388f.asm +++ /dev/null @@ -1,101 +0,0 @@ -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 Function2117 - 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 Function2117 - ret - -Function391f:: - ret - -Function3910:: - ld a, [wcd5d] - cp $1 - jr z, .asm_392d - ld a, $4 - call Function2117 - 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 880513b..6591da2 100644 --- a/home/util.asm +++ b/home/util.asm @@ -1,59 +1,12 @@ INCLUDE "constants.asm" if DEBUG -SECTION "Misc Utility Functions", ROM0[$33EF] +SECTION "Misc Utility Functions", ROM0[$341F] else -SECTION "Misc Utility Functions", ROM0[$33B3] +SECTION "Misc Utility Functions", ROM0[$33E3] endc -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 +_341F:: ; 341f ; Returns hl + a * 6 and a ret z @@ -86,35 +39,3 @@ 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,9 +57,7 @@ hJoyDebounceSrc:: db ; ffa5 hJoypadState2:: db ; ffa6 - ds 6 ; TODO -hGraphicStartTile:: db ; ffad -hMoveMon:: db + ds 8 ; TODO UNION @@ -98,37 +96,11 @@ 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 5e39410..05bb7b1 100644 --- a/macros/farcall.asm +++ b/macros/farcall.asm @@ -12,7 +12,7 @@ callab: MACRO ; address, bank ENDM homecall: MACRO - ldh a, [hROMBank] + ld a, [hROMBank] push af ld a, BANK(\1) call Bankswitch diff --git a/macros/wram.asm b/macros/wram.asm index 96cf5e8..cb0d3f1 100644 --- a/macros/wram.asm +++ b/macros/wram.asm @@ -309,6 +309,7 @@ map_object: MACRO \1ObjectRange:: ds 1 \1ObjectScript:: ds 2 \1ObjectEventFlag:: ds 2 +\1ObjectUnused:: ds 2 endm @@ -371,13 +372,3 @@ 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,17 +1,35 @@ ; 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:2117 Function2117 -00:23DC LoadWildMons -00:23E5 FadeIn ; This is not OverworldFadeIn, but I don't know what it is -00:27FB OverworldTextModeSwitch + 00:2C05 StartMenuCheck -00:3111 Function3111 00:3171 Function3171 -00:3233 Function3233 -00:323E Function323e -00:3240 Function3240 +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:39BA PlayCry +00:3CA8 InitSpriteAnimStruct 00:3D86 WaitSFX 00:3D87 WaitSFX.wait 00:3DA5 MaxVolume @@ -29,38 +47,34 @@ 00:3E2E GetMapMusic.unk_3E2E 00:3E32 Unk_3E32 + 01:4031 Function4031 -01:40EB Function40eb -01:5007 Function5007 -01:5190 Function5190 +01:4031 DebugMenu +01:5190 _UpdateSprites 01:53CC MainMenu 01:5D27 Function5d27 -01:6114 TitleScreenInputAndTimeout 01:63D8 ReanchorBGMap_NoOAMUpdate 01:6437 LoadFonts_NoOAMUpdate 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 02:4C7C DrawMap 02:4DC2 TownMapGfx 02:4F32 PokegearRadioGfx +02:51D2 SetTitleBGDecorationBorder 02:528B Function928b 02:5695 CheckSGB 03:4791 DebugWarp 03:479F DebugWarp.Destinations +03:488D Tilesets 03:4D33 Functioncd33 03:4D6F Functioncd6f 03:4DE3 Functioncde3 @@ -84,7 +98,6 @@ 04:528F Function1128f 04:52C1 Function112c1 -04:530A Function1130a 04:5677 DoPlayerMovement 04:5DBE DisplayStartMenu 04:640B Function1240b @@ -92,12 +105,12 @@ 05:4000 Function14000 05:400A GetPlayerSprite -05:4036 AddMapSprites +05:4036 RefreshSprites 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 05:457A Function1457a 05:45B8 Function145b8 @@ -110,27 +123,15 @@ ; 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 Function28c98 +0A:4C98 LinkTextboxAtHL 0A:4D6E Function28d6e 0A:4DA4 Function28da4 0B:5663 Function2d663 +0C:7C00 CommonExteriorTiles + 0E:4B78 LoadTrainerClassName 0E:4BA0 LoadTrainerClassName.got_name 0E:4BA9 LoadTrainerClass @@ -143,9 +144,8 @@ 0F:691E Function3e91e 0F:6963 Function3e963 0F:69A9 _LoadWildMons -0F:6E3E Function3ee3e 0F:6F19 Function3ef19 -0F:7019 PlaceGraphic +0F:7019 Function3f019 0F:704A Function3f04a 0F:7068 Function3f068 @@ -184,9 +184,9 @@ 23:44BE Function8c4be 23:4940 Function8c940 23:49C6 Function8c9c6 -23:4D0C Function8cd0c -23:60CC MenuMonIconGfx -23:71CB Function_8f1cb +23:4CFD InitEffectObject +23:4d13 EffectObjectJumpNoDelay +23:60cc MenuMonIconGfx 24:4000 SetClockDialog 24:4239 SlotMachineGame @@ -435,7 +435,9 @@ 36:73E8 MtFujiRoute_MapAttributes 36:7444 FontoRoute5_MapAttributes 36:7530 BullForestRoute3_MapAttributes - +38:4000 PikachuMiniGame +39:4000 GameFreakIntro +39:432F OpeningCutscene 3A:441D Functione841d 3A:45D8 Functione85d8 3A:47F9 Functione87f9 @@ -455,6 +457,7 @@ 3F:6750 PicTestMenu 3F:6755 PicTestMenu.loop +00:CB6F wPlayerStepDirection 00:CC22 wMenuData3 00:CE67 wPlayerName @@ -464,7 +467,6 @@ 01:D264 wPlayerBikeSurfState ; The starting house's map script number is stored at d29a. Others are probably nearby. 01:D35F wOptions -01:D656 wMapGroup -01:D657 wMapId +01:D513 wWarpNumber 01:D7D2 wPartyMonOT 01:DA3B wOTPartyMonOT @@ -34,7 +34,12 @@ vNPCSprites2:: ; 8800 ds $80 tiles vTileset:: ; 9000 - ds $80 tiles +; ds $60 tiles + ds $20 tiles + +vExteriorTileset:: ; 9200 + ds $40 tiles +vTilesetEnd:: ; 9600 NEXTU @@ -94,22 +94,21 @@ wWhichPicTest:: ; c40b ENDU -SECTION "Unknown map buffer?", WRAM0[$C5E8] +SECTION "Map buffer", WRAM0[$C5E8] wMapBuffer:: wMapScriptNumber:: db ; c5e8 wMapScriptNumberLocation:: dw ; c5e9 wUnknownMapPointer:: dw ; c5eb ; TODO -wc5ed:: db ; c5ed - ds 18 ; TODO + ds 19 ; TODO wMapBufferEnd:: ; c600 UNION -wOverworldMapBlocks:: ; c600 +wOverworldMap:: ; c600 ds $514 ; TODO: constantify this -wOverworldMapBlocksEnd:: ; cb14 +wOverworldMapEnd:: ; cb14 NEXTU @@ -216,10 +215,14 @@ wPlayerLinkAction:: db ; cb51 wLinkTimeoutFrames:: dw ; cb56 wcb58:: ds 2 ; cb58 -wMonType:: db ; cb5a +; cb5a + ds 1 ; TODO wCurSpecies:: db ; cb5b wNamedObjectTypeBuffer:: db ; cb5c +SECTION "CB5E", WRAM0[$CB5E] +wJumptableIndex:: ds 4 + SECTION "CB62", WRAM0[$CB62] wVBCopySize:: ds 1 ; cb62 @@ -229,18 +232,12 @@ wVBCopyDoubleSize:: ds 1 ; cb67 wVBCopyDoubleSrc:: ds 2 ; cb68 wVBCopyDoubleDst:: ds 2 ; cb6a -SECTION "CB71", WRAM0[$CB70] - -wcb70:: db +SECTION "CB71", WRAM0[$CB71] 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] @@ -249,6 +246,9 @@ wTileUp:: db ; cb91 wTileLeft:: db ; cb92 wTileRight:: db ; cb93 +wScreenSave:: ; cb94 + ds 6 * 5 + SECTION "CBD2", WRAM0[$CBD2] wcbd2:: ; cbd2 ds $14 @@ -280,7 +280,7 @@ wMenuCursorBuffer:: db ; cc09 ds 8 ; TODO wMenuData2:: -wMenuDataFlags:: db ; cc12 + db ; cc12 wMenuDataItems:: db ; cc13 wMenuDataIndicesPointer:: dw ; cc14 wMenuDataDisplayFunctionPointer:: dw ; cc16 @@ -298,7 +298,9 @@ wVBlankOccurred: db ; cc33 ds 4 -wcc38:: ; cc38 ; TODO: wceeb in pokegold, what is this? +;Controls what type of opening (fire/notes) you get. +wcc38:: +wTitleSequenceOpeningType:: ; cc38 db wDebugWarpSelection:: ; cc39 @@ -306,15 +308,15 @@ wDebugWarpSelection:: ; cc39 ds 6 -wcc40:: ; cc40 +wSGB:: ; cc40 db SECTION "CC9C", WRAM0[$CC9C] -wUnknownWordCC9C:: ; cc9c +wUnknownWordcc9c:: ; cc9c dw -wUnknownBufferCC9E:: ; cc9e +wUnknownBuffercc9e:: ; cc9e ds 14 @@ -347,7 +349,7 @@ wOBP1:: db ; cccc SECTION "CCCE", WRAM0[$CCCE] wDisableVBlankWYUpdate:: db ; ccce -wSGB:: db +wcccf:: db SECTION "CD26", WRAM0[$CD26] @@ -391,10 +393,7 @@ wFarCallBCBuffer:: ; cd54 dw ds 3 ; TODO -wVramState:: db ; cd59 - - ds 3 ; TODO -wcd5d:: db ; cd5d +wVramState:: db SECTION "CD72", WRAM0[$CD72] wcd72:: dw ; cd72 @@ -413,7 +412,6 @@ wItemQuantityBuffer:: db ; cd7e SECTION "CDBA", WRAM0[$CDBA] wItemAttributeParamBuffer:: db ; cdba -wCurPartyLevel:: db ; cdbb SECTION "CDBD", WRAM0[$CDBD] @@ -423,11 +421,13 @@ wLinkMode:: db ; cdbd ; 02 - ; 03 - -wTargetMapUnk:: db ; cdbe ; TODO: Probably warp ID, check -wTargetMapGroup:: db ; cdbf -wTargetMapId:: db ; cdc0 -; cdc1 - ds $c +wNextWarp:: db ; cdbe +wNextMapGroup:: db ; cdbf +wNextMapId:: db ; cdc0 +wPrevWarp:: db ; cdc1 + + ds 11 + wLinkBattleRNs:: ds 10 ; cdcd ; cddd @@ -547,31 +547,33 @@ wObjectFollow_Leader:: ; ce76 db wObjectFollow_Follower:: ; ce77 db -wCenteredObject:: ; ce78 - db -wFollowerMovementQueueLength:: ; ce79 - db -wFollowMovementQueue:: ; ce7a - ds 5 - -wObjectStructs:: ; ce7f -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 + + +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 wObjectStructsEnd:: ; d00f -wCmdQueue:: ; d00f -wCmdQueueEntry1:: ds 16 -wCmdQueueEntry2:: ds 16 -wCmdQueueEntry3:: ds 16 -wCmdQueueEntry4:: ds 16 +; 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 wMapObjects:: ; d04f wPlayerObject:: map_object wPlayer @@ -637,10 +639,8 @@ wBallQuantities:: db ; d1df SECTION "Rival's Name", WRAM0[$D258] wRivalsName:: ds 6 ; d258 -SECTION "D4AB", WRAM0[$D4A9] +SECTION "D4AB", WRAM0[$D4AB] -wd4a9:: db ; d4a9 - ds 1 ; TODO wJoypadFlags:: db ; d4ab ; 76543210 ; ||||\__/ @@ -673,8 +673,6 @@ ENDR wCurrMapObjectCount:: ; d5f6 db -SECTION "D637", WRAM0[$D637] -wd637:: db ; d637 SECTION "Used sprites", WRAM0[$D643] @@ -687,7 +685,10 @@ wUsedSprites:: ; d645 wUsedSpritesEnd:: ; d651 -SECTION "Map header", WRAM0[$D658] +SECTION "Map header", WRAM0[$D656] + +wMapGroup:: db ; d656 +wMapId:: db ; d657 wOverworldMapAnchor:: ; d658 dw @@ -695,8 +696,8 @@ wOverworldMapAnchor:: ; d658 wYCoord:: db ; d65a wXCoord:: db ; d65b -wMetaTileStandingY:: db ; d65c -wMetaTileStandingX:: db ; d65d +wMetatileStandingY:: db ; d65c +wMetatileStandingX:: db ; d65d ; d65f ds 1 ; TODO |