diff --git a/Makefile b/Makefile index 2b997fee59..87bd771b08 100644 --- a/Makefile +++ b/Makefile @@ -142,6 +142,7 @@ ROMTESTHYDRA := tools/mgba-rom-test-hydra/mgba-rom-test-hydra$(EXE) PERL := perl +# Inclusive list. If you don't want a tool to be built, don't add it here. TOOLDIRS := tools/aif2pcm tools/bin2c tools/gbafix tools/gbagfx tools/jsonproc tools/mapjson tools/mid2agb tools/preproc tools/ramscrgen tools/rsfont tools/scaninc CHECKTOOLDIRS = tools/patchelf tools/mgba-rom-test-hydra TOOLBASE = $(TOOLDIRS:tools/%=%) diff --git a/asm/macros/event.inc b/asm/macros/event.inc index 49a97a2477..78d3037aeb 100644 --- a/asm/macros/event.inc +++ b/asm/macros/event.inc @@ -1582,15 +1582,15 @@ .4byte \value .endm - @ Sets the eventLegal bit for the Pokemon in the specified slot of the player's party. - .macro setmoneventlegal slot:req + @ Sets the modernFatefulEncounter bit for the Pokemon in the specified slot of the player's party. + .macro setmodernfatefulencounter slot:req .byte 0xcd .2byte \slot .endm - @ Checks if the eventLegal bit is set for the Pokemon in the specified slot of the player's party. If it isn't set, + @ Checks if the modernFatefulEncounter bit is set for the Pokemon in the specified slot of the player's party. If it isn't set, @ VAR_RESULT is TRUE. If the bit is set (or if the specified slot is empty or invalid), VAR_RESULT is FALSE. - .macro checkmoneventlegal slot:req + .macro checkmodernfatefulencounter slot:req .byte 0xce .2byte \slot .endm @@ -1938,12 +1938,12 @@ closebraillemessage .endm - @ Creates an "event legal" Pokémon for an encounter + @ Creates a Pokémon with the modernFatefulEncounter bit set for an encounter .macro seteventmon species:req, level:req, item=ITEM_NONE setvar VAR_0x8004, \species setvar VAR_0x8005, \level setvar VAR_0x8006, \item - special CreateEventLegalEnemyMon + special CreateEnemyEventMon .endm @ Set up a totem boost for the next battle. diff --git a/asm/macros/map.inc b/asm/macros/map.inc index 662257e416..21445138de 100644 --- a/asm/macros/map.inc +++ b/asm/macros/map.inc @@ -19,11 +19,11 @@ .4byte \script .endm - @ Defines an object event template for map data. Mirrors the struct layout of ObjectEventTemplate in include/global.fieldmap.h - .macro object_event index:req, gfx:req, inConnection:req, x:req, y:req, elevation:req, movement_type:req, x_radius:req, y_radius:req, trainer_type:req, sight_radius_tree_etc:req, script:req, event_flag:req + @ Defines an object event template for map data, to be used by a normal object. Mirrors the struct layout of ObjectEventTemplate in include/global.fieldmap.h + .macro object_event index:req, gfx:req, x:req, y:req, elevation:req, movement_type:req, x_radius:req, y_radius:req, trainer_type:req, sight_radius_tree_etc:req, script:req, event_flag:req .byte \index .byte \gfx - .byte \inConnection + .byte OBJ_KIND_NORMAL .space 1 @ Padding .2byte \x, \y .byte \elevation @@ -38,6 +38,22 @@ inc _num_npcs .endm + @ Defines an object event template for map data, to be used by a clone object. Mirrors the struct layout of ObjectEventTemplate in include/global.fieldmap.h + @ NOTE: The handling for this type of event does not exist in Emerald by default; it is exclusive to FRLG. + .macro clone_event index:req, gfx:req, x:req, y:req, target_local_id:req, target_map_id:req + .byte \index + .byte \gfx + .byte OBJ_KIND_CLONE + .space 1 @ Padding + .2byte \x, \y + .byte \target_local_id + .space 3 @ Padding + .2byte \target_map_id & 0xFF @ map num + .2byte \target_map_id >> 8 @ map group + .space 8 @ Padding + inc _num_npcs + .endm + @ Defines a warp event for map data. Mirrors the struct layout of WarpEvent in include/global.fieldmap.h .macro warp_def x:req, y:req, elevation:req, warpId:req, map_id:req .2byte \x, \y @@ -49,12 +65,12 @@ .endm @ Defines a coord event for map data. Mirrors the struct layout of CoordEvent in include/global.fieldmap.h - .macro coord_event x:req, y:req, elevation:req, trigger:req, index:req, script:req + .macro coord_event x:req, y:req, elevation:req, var:req, varValue:req, script:req .2byte \x, \y .byte \elevation .space 1 @ Padding - .2byte \trigger - .2byte \index + .2byte \var + .2byte \varValue .space 2 @ Padding .4byte \script inc _num_traps diff --git a/data/maps/PetalburgWoods/map.json b/data/maps/PetalburgWoods/map.json index 4179d81957..2979e7e469 100644 --- a/data/maps/PetalburgWoods/map.json +++ b/data/maps/PetalburgWoods/map.json @@ -168,7 +168,7 @@ "trainer_type": "TRAINER_TYPE_NONE", "trainer_sight_or_berry_tree_id": "0", "script": "PetalburgWoods_EventScript_ItemParalyzeHeal", - "flag": "FLAG_ITEM_PETALBURD_WOODS_PARALYZE_HEAL" + "flag": "FLAG_ITEM_PETALBURG_WOODS_PARALYZE_HEAL" }, { "graphics_id": "OBJ_EVENT_GFX_GIRL_2", diff --git a/data/maps/Route110/map.json b/data/maps/Route110/map.json index 630b20bd37..2b52164113 100644 --- a/data/maps/Route110/map.json +++ b/data/maps/Route110/map.json @@ -288,7 +288,7 @@ "trainer_type": "TRAINER_TYPE_NONE", "trainer_sight_or_berry_tree_id": "0", "script": "Route110_EventScript_ItemRareCandy", - "flag": "FLAG_ITEM_ROUTE_109_RARE_CANDY" + "flag": "FLAG_ITEM_ROUTE_110_RARE_CANDY" }, { "graphics_id": "OBJ_EVENT_GFX_CYCLING_TRIATHLETE_M", diff --git a/data/maps/Route114/map.json b/data/maps/Route114/map.json index 10f15233c9..17c483c0fa 100644 --- a/data/maps/Route114/map.json +++ b/data/maps/Route114/map.json @@ -503,7 +503,7 @@ "y": 30, "elevation": 3, "item": "ITEM_REVIVE", - "flag": "FLAG_HIDDEN_ITEM_ROUTE_113_REVIVE" + "flag": "FLAG_HIDDEN_ITEM_ROUTE_114_REVIVE" } ] } diff --git a/data/script_cmd_table.inc b/data/script_cmd_table.inc index 51b7f966e4..f50ce5322b 100644 --- a/data/script_cmd_table.inc +++ b/data/script_cmd_table.inc @@ -1,232 +1,232 @@ .align 2 gScriptCmdTable:: - .4byte ScrCmd_nop @ 0x00 - .4byte ScrCmd_nop1 @ 0x01 - .4byte ScrCmd_end @ 0x02 - .4byte ScrCmd_return @ 0x03 - .4byte ScrCmd_call @ 0x04 - .4byte ScrCmd_goto @ 0x05 - .4byte ScrCmd_goto_if @ 0x06 - .4byte ScrCmd_call_if @ 0x07 - .4byte ScrCmd_gotostd @ 0x08 - .4byte ScrCmd_callstd @ 0x09 - .4byte ScrCmd_gotostd_if @ 0x0a - .4byte ScrCmd_callstd_if @ 0x0b - .4byte ScrCmd_returnram @ 0x0c - .4byte ScrCmd_endram @ 0x0d - .4byte ScrCmd_setmysteryeventstatus @ 0x0e - .4byte ScrCmd_loadword @ 0x0f - .4byte ScrCmd_loadbyte @ 0x10 - .4byte ScrCmd_setptr @ 0x11 - .4byte ScrCmd_loadbytefromptr @ 0x12 - .4byte ScrCmd_setptrbyte @ 0x13 - .4byte ScrCmd_copylocal @ 0x14 - .4byte ScrCmd_copybyte @ 0x15 - .4byte ScrCmd_setvar @ 0x16 - .4byte ScrCmd_addvar @ 0x17 - .4byte ScrCmd_subvar @ 0x18 - .4byte ScrCmd_copyvar @ 0x19 - .4byte ScrCmd_setorcopyvar @ 0x1a - .4byte ScrCmd_compare_local_to_local @ 0x1b - .4byte ScrCmd_compare_local_to_value @ 0x1c - .4byte ScrCmd_compare_local_to_ptr @ 0x1d - .4byte ScrCmd_compare_ptr_to_local @ 0x1e - .4byte ScrCmd_compare_ptr_to_value @ 0x1f - .4byte ScrCmd_compare_ptr_to_ptr @ 0x20 - .4byte ScrCmd_compare_var_to_value @ 0x21 - .4byte ScrCmd_compare_var_to_var @ 0x22 - .4byte ScrCmd_callnative @ 0x23 - .4byte ScrCmd_gotonative @ 0x24 - .4byte ScrCmd_special @ 0x25 - .4byte ScrCmd_specialvar @ 0x26 - .4byte ScrCmd_waitstate @ 0x27 - .4byte ScrCmd_delay @ 0x28 - .4byte ScrCmd_setflag @ 0x29 - .4byte ScrCmd_clearflag @ 0x2a - .4byte ScrCmd_checkflag @ 0x2b - .4byte ScrCmd_initclock @ 0x2c - .4byte ScrCmd_dotimebasedevents @ 0x2d - .4byte ScrCmd_gettime @ 0x2e - .4byte ScrCmd_playse @ 0x2f - .4byte ScrCmd_waitse @ 0x30 - .4byte ScrCmd_playfanfare @ 0x31 - .4byte ScrCmd_waitfanfare @ 0x32 - .4byte ScrCmd_playbgm @ 0x33 - .4byte ScrCmd_savebgm @ 0x34 - .4byte ScrCmd_fadedefaultbgm @ 0x35 - .4byte ScrCmd_fadenewbgm @ 0x36 - .4byte ScrCmd_fadeoutbgm @ 0x37 - .4byte ScrCmd_fadeinbgm @ 0x38 - .4byte ScrCmd_warp @ 0x39 - .4byte ScrCmd_warpsilent @ 0x3a - .4byte ScrCmd_warpdoor @ 0x3b - .4byte ScrCmd_warphole @ 0x3c - .4byte ScrCmd_warpteleport @ 0x3d - .4byte ScrCmd_setwarp @ 0x3e - .4byte ScrCmd_setdynamicwarp @ 0x3f - .4byte ScrCmd_setdivewarp @ 0x40 - .4byte ScrCmd_setholewarp @ 0x41 - .4byte ScrCmd_getplayerxy @ 0x42 - .4byte ScrCmd_getpartysize @ 0x43 - .4byte ScrCmd_additem @ 0x44 - .4byte ScrCmd_removeitem @ 0x45 - .4byte ScrCmd_checkitemspace @ 0x46 - .4byte ScrCmd_checkitem @ 0x47 - .4byte ScrCmd_checkitemtype @ 0x48 - .4byte ScrCmd_addpcitem @ 0x49 - .4byte ScrCmd_checkpcitem @ 0x4a - .4byte ScrCmd_adddecoration @ 0x4b - .4byte ScrCmd_removedecoration @ 0x4c - .4byte ScrCmd_checkdecor @ 0x4d - .4byte ScrCmd_checkdecorspace @ 0x4e - .4byte ScrCmd_applymovement @ 0x4f - .4byte ScrCmd_applymovementat @ 0x50 - .4byte ScrCmd_waitmovement @ 0x51 - .4byte ScrCmd_waitmovementat @ 0x52 - .4byte ScrCmd_removeobject @ 0x53 - .4byte ScrCmd_removeobjectat @ 0x54 - .4byte ScrCmd_addobject @ 0x55 - .4byte ScrCmd_addobjectat @ 0x56 - .4byte ScrCmd_setobjectxy @ 0x57 - .4byte ScrCmd_showobjectat @ 0x58 - .4byte ScrCmd_hideobjectat @ 0x59 - .4byte ScrCmd_faceplayer @ 0x5a - .4byte ScrCmd_turnobject @ 0x5b - .4byte ScrCmd_trainerbattle @ 0x5c - .4byte ScrCmd_dotrainerbattle @ 0x5d - .4byte ScrCmd_gotopostbattlescript @ 0x5e - .4byte ScrCmd_gotobeatenscript @ 0x5f - .4byte ScrCmd_checktrainerflag @ 0x60 - .4byte ScrCmd_settrainerflag @ 0x61 - .4byte ScrCmd_cleartrainerflag @ 0x62 - .4byte ScrCmd_setobjectxyperm @ 0x63 - .4byte ScrCmd_copyobjectxytoperm @ 0x64 - .4byte ScrCmd_setobjectmovementtype @ 0x65 - .4byte ScrCmd_waitmessage @ 0x66 - .4byte ScrCmd_message @ 0x67 - .4byte ScrCmd_closemessage @ 0x68 - .4byte ScrCmd_lockall @ 0x69 - .4byte ScrCmd_lock @ 0x6a - .4byte ScrCmd_releaseall @ 0x6b - .4byte ScrCmd_release @ 0x6c - .4byte ScrCmd_waitbuttonpress @ 0x6d - .4byte ScrCmd_yesnobox @ 0x6e - .4byte ScrCmd_multichoice @ 0x6f - .4byte ScrCmd_multichoicedefault @ 0x70 - .4byte ScrCmd_multichoicegrid @ 0x71 - .4byte ScrCmd_drawbox @ 0x72 - .4byte ScrCmd_erasebox @ 0x73 - .4byte ScrCmd_drawboxtext @ 0x74 - .4byte ScrCmd_showmonpic @ 0x75 - .4byte ScrCmd_hidemonpic @ 0x76 - .4byte ScrCmd_showcontestpainting @ 0x77 - .4byte ScrCmd_braillemessage @ 0x78 - .4byte ScrCmd_givemon @ 0x79 - .4byte ScrCmd_giveegg @ 0x7a - .4byte ScrCmd_setmonmove @ 0x7b - .4byte ScrCmd_checkpartymove @ 0x7c - .4byte ScrCmd_bufferspeciesname @ 0x7d - .4byte ScrCmd_bufferleadmonspeciesname @ 0x7e - .4byte ScrCmd_bufferpartymonnick @ 0x7f - .4byte ScrCmd_bufferitemname @ 0x80 - .4byte ScrCmd_bufferdecorationname @ 0x81 - .4byte ScrCmd_buffermovename @ 0x82 - .4byte ScrCmd_buffernumberstring @ 0x83 - .4byte ScrCmd_bufferstdstring @ 0x84 - .4byte ScrCmd_bufferstring @ 0x85 - .4byte ScrCmd_pokemart @ 0x86 - .4byte ScrCmd_pokemartdecoration @ 0x87 - .4byte ScrCmd_pokemartdecoration2 @ 0x88 - .4byte ScrCmd_playslotmachine @ 0x89 - .4byte ScrCmd_setberrytree @ 0x8a - .4byte ScrCmd_choosecontestmon @ 0x8b - .4byte ScrCmd_startcontest @ 0x8c - .4byte ScrCmd_showcontestresults @ 0x8d - .4byte ScrCmd_contestlinktransfer @ 0x8e - .4byte ScrCmd_random @ 0x8f - .4byte ScrCmd_addmoney @ 0x90 - .4byte ScrCmd_removemoney @ 0x91 - .4byte ScrCmd_checkmoney @ 0x92 - .4byte ScrCmd_showmoneybox @ 0x93 - .4byte ScrCmd_hidemoneybox @ 0x94 - .4byte ScrCmd_updatemoneybox @ 0x95 - .4byte ScrCmd_getpokenewsactive @ 0x96 - .4byte ScrCmd_fadescreen @ 0x97 - .4byte ScrCmd_fadescreenspeed @ 0x98 - .4byte ScrCmd_setflashlevel @ 0x99 - .4byte ScrCmd_animateflash @ 0x9a - .4byte ScrCmd_messageautoscroll @ 0x9b - .4byte ScrCmd_dofieldeffect @ 0x9c - .4byte ScrCmd_setfieldeffectargument @ 0x9d - .4byte ScrCmd_waitfieldeffect @ 0x9e - .4byte ScrCmd_setrespawn @ 0x9f - .4byte ScrCmd_checkplayergender @ 0xa0 - .4byte ScrCmd_playmoncry @ 0xa1 - .4byte ScrCmd_setmetatile @ 0xa2 - .4byte ScrCmd_resetweather @ 0xa3 - .4byte ScrCmd_setweather @ 0xa4 - .4byte ScrCmd_doweather @ 0xa5 - .4byte ScrCmd_setstepcallback @ 0xa6 - .4byte ScrCmd_setmaplayoutindex @ 0xa7 - .4byte ScrCmd_setobjectsubpriority @ 0xa8 - .4byte ScrCmd_resetobjectsubpriority @ 0xa9 - .4byte ScrCmd_createvobject @ 0xaa - .4byte ScrCmd_turnvobject @ 0xab - .4byte ScrCmd_opendoor @ 0xac - .4byte ScrCmd_closedoor @ 0xad - .4byte ScrCmd_waitdooranim @ 0xae - .4byte ScrCmd_setdooropen @ 0xaf - .4byte ScrCmd_setdoorclosed @ 0xb0 - .4byte ScrCmd_addelevmenuitem @ 0xb1 - .4byte ScrCmd_showelevmenu @ 0xb2 - .4byte ScrCmd_checkcoins @ 0xb3 - .4byte ScrCmd_addcoins @ 0xb4 - .4byte ScrCmd_removecoins @ 0xb5 - .4byte ScrCmd_setwildbattle @ 0xb6 - .4byte ScrCmd_dowildbattle @ 0xb7 - .4byte ScrCmd_setvaddress @ 0xb8 - .4byte ScrCmd_vgoto @ 0xb9 - .4byte ScrCmd_vcall @ 0xba - .4byte ScrCmd_vgoto_if @ 0xbb - .4byte ScrCmd_vcall_if @ 0xbc - .4byte ScrCmd_vmessage @ 0xbd - .4byte ScrCmd_vbuffermessage @ 0xbe - .4byte ScrCmd_vbufferstring @ 0xbf - .4byte ScrCmd_showcoinsbox @ 0xc0 - .4byte ScrCmd_hidecoinsbox @ 0xc1 - .4byte ScrCmd_updatecoinsbox @ 0xc2 - .4byte ScrCmd_incrementgamestat @ 0xc3 - .4byte ScrCmd_setescapewarp @ 0xc4 - .4byte ScrCmd_waitmoncry @ 0xc5 - .4byte ScrCmd_bufferboxname @ 0xc6 - .4byte ScrCmd_nop1 @ 0xc7 - .4byte ScrCmd_nop1 @ 0xc8 - .4byte ScrCmd_nop1 @ 0xc9 - .4byte ScrCmd_nop1 @ 0xca - .4byte ScrCmd_nop1 @ 0xcb - .4byte ScrCmd_nop1 @ 0xcc - .4byte ScrCmd_setmoneventlegal @ 0xcd - .4byte ScrCmd_checkmoneventlegal @ 0xce - .4byte ScrCmd_trywondercardscript @ 0xcf - .4byte ScrCmd_nop1 @ 0xd0 - .4byte ScrCmd_warpspinenter @ 0xd1 - .4byte ScrCmd_setmonmetlocation @ 0xd2 - .4byte ScrCmd_moverotatingtileobjects @ 0xd3 - .4byte ScrCmd_turnrotatingtileobjects @ 0xd4 - .4byte ScrCmd_initrotatingtilepuzzle @ 0xd5 - .4byte ScrCmd_freerotatingtilepuzzle @ 0xd6 - .4byte ScrCmd_warpmossdeepgym @ 0xd7 - .4byte ScrCmd_selectapproachingtrainer @ 0xd8 - .4byte ScrCmd_lockfortrainer @ 0xd9 - .4byte ScrCmd_closebraillemessage @ 0xda - .4byte ScrCmd_messageinstant @ 0xdb - .4byte ScrCmd_fadescreenswapbuffers @ 0xdc - .4byte ScrCmd_buffertrainerclassname @ 0xdd - .4byte ScrCmd_buffertrainername @ 0xde - .4byte ScrCmd_pokenavcall @ 0xdf - .4byte ScrCmd_warpwhitefade @ 0xe0 - .4byte ScrCmd_buffercontestname @ 0xe1 - .4byte ScrCmd_bufferitemnameplural @ 0xe2 + .4byte ScrCmd_nop @ 0x00 + .4byte ScrCmd_nop1 @ 0x01 + .4byte ScrCmd_end @ 0x02 + .4byte ScrCmd_return @ 0x03 + .4byte ScrCmd_call @ 0x04 + .4byte ScrCmd_goto @ 0x05 + .4byte ScrCmd_goto_if @ 0x06 + .4byte ScrCmd_call_if @ 0x07 + .4byte ScrCmd_gotostd @ 0x08 + .4byte ScrCmd_callstd @ 0x09 + .4byte ScrCmd_gotostd_if @ 0x0a + .4byte ScrCmd_callstd_if @ 0x0b + .4byte ScrCmd_returnram @ 0x0c + .4byte ScrCmd_endram @ 0x0d + .4byte ScrCmd_setmysteryeventstatus @ 0x0e + .4byte ScrCmd_loadword @ 0x0f + .4byte ScrCmd_loadbyte @ 0x10 + .4byte ScrCmd_setptr @ 0x11 + .4byte ScrCmd_loadbytefromptr @ 0x12 + .4byte ScrCmd_setptrbyte @ 0x13 + .4byte ScrCmd_copylocal @ 0x14 + .4byte ScrCmd_copybyte @ 0x15 + .4byte ScrCmd_setvar @ 0x16 + .4byte ScrCmd_addvar @ 0x17 + .4byte ScrCmd_subvar @ 0x18 + .4byte ScrCmd_copyvar @ 0x19 + .4byte ScrCmd_setorcopyvar @ 0x1a + .4byte ScrCmd_compare_local_to_local @ 0x1b + .4byte ScrCmd_compare_local_to_value @ 0x1c + .4byte ScrCmd_compare_local_to_ptr @ 0x1d + .4byte ScrCmd_compare_ptr_to_local @ 0x1e + .4byte ScrCmd_compare_ptr_to_value @ 0x1f + .4byte ScrCmd_compare_ptr_to_ptr @ 0x20 + .4byte ScrCmd_compare_var_to_value @ 0x21 + .4byte ScrCmd_compare_var_to_var @ 0x22 + .4byte ScrCmd_callnative @ 0x23 + .4byte ScrCmd_gotonative @ 0x24 + .4byte ScrCmd_special @ 0x25 + .4byte ScrCmd_specialvar @ 0x26 + .4byte ScrCmd_waitstate @ 0x27 + .4byte ScrCmd_delay @ 0x28 + .4byte ScrCmd_setflag @ 0x29 + .4byte ScrCmd_clearflag @ 0x2a + .4byte ScrCmd_checkflag @ 0x2b + .4byte ScrCmd_initclock @ 0x2c + .4byte ScrCmd_dotimebasedevents @ 0x2d + .4byte ScrCmd_gettime @ 0x2e + .4byte ScrCmd_playse @ 0x2f + .4byte ScrCmd_waitse @ 0x30 + .4byte ScrCmd_playfanfare @ 0x31 + .4byte ScrCmd_waitfanfare @ 0x32 + .4byte ScrCmd_playbgm @ 0x33 + .4byte ScrCmd_savebgm @ 0x34 + .4byte ScrCmd_fadedefaultbgm @ 0x35 + .4byte ScrCmd_fadenewbgm @ 0x36 + .4byte ScrCmd_fadeoutbgm @ 0x37 + .4byte ScrCmd_fadeinbgm @ 0x38 + .4byte ScrCmd_warp @ 0x39 + .4byte ScrCmd_warpsilent @ 0x3a + .4byte ScrCmd_warpdoor @ 0x3b + .4byte ScrCmd_warphole @ 0x3c + .4byte ScrCmd_warpteleport @ 0x3d + .4byte ScrCmd_setwarp @ 0x3e + .4byte ScrCmd_setdynamicwarp @ 0x3f + .4byte ScrCmd_setdivewarp @ 0x40 + .4byte ScrCmd_setholewarp @ 0x41 + .4byte ScrCmd_getplayerxy @ 0x42 + .4byte ScrCmd_getpartysize @ 0x43 + .4byte ScrCmd_additem @ 0x44 + .4byte ScrCmd_removeitem @ 0x45 + .4byte ScrCmd_checkitemspace @ 0x46 + .4byte ScrCmd_checkitem @ 0x47 + .4byte ScrCmd_checkitemtype @ 0x48 + .4byte ScrCmd_addpcitem @ 0x49 + .4byte ScrCmd_checkpcitem @ 0x4a + .4byte ScrCmd_adddecoration @ 0x4b + .4byte ScrCmd_removedecoration @ 0x4c + .4byte ScrCmd_checkdecor @ 0x4d + .4byte ScrCmd_checkdecorspace @ 0x4e + .4byte ScrCmd_applymovement @ 0x4f + .4byte ScrCmd_applymovementat @ 0x50 + .4byte ScrCmd_waitmovement @ 0x51 + .4byte ScrCmd_waitmovementat @ 0x52 + .4byte ScrCmd_removeobject @ 0x53 + .4byte ScrCmd_removeobjectat @ 0x54 + .4byte ScrCmd_addobject @ 0x55 + .4byte ScrCmd_addobjectat @ 0x56 + .4byte ScrCmd_setobjectxy @ 0x57 + .4byte ScrCmd_showobjectat @ 0x58 + .4byte ScrCmd_hideobjectat @ 0x59 + .4byte ScrCmd_faceplayer @ 0x5a + .4byte ScrCmd_turnobject @ 0x5b + .4byte ScrCmd_trainerbattle @ 0x5c + .4byte ScrCmd_dotrainerbattle @ 0x5d + .4byte ScrCmd_gotopostbattlescript @ 0x5e + .4byte ScrCmd_gotobeatenscript @ 0x5f + .4byte ScrCmd_checktrainerflag @ 0x60 + .4byte ScrCmd_settrainerflag @ 0x61 + .4byte ScrCmd_cleartrainerflag @ 0x62 + .4byte ScrCmd_setobjectxyperm @ 0x63 + .4byte ScrCmd_copyobjectxytoperm @ 0x64 + .4byte ScrCmd_setobjectmovementtype @ 0x65 + .4byte ScrCmd_waitmessage @ 0x66 + .4byte ScrCmd_message @ 0x67 + .4byte ScrCmd_closemessage @ 0x68 + .4byte ScrCmd_lockall @ 0x69 + .4byte ScrCmd_lock @ 0x6a + .4byte ScrCmd_releaseall @ 0x6b + .4byte ScrCmd_release @ 0x6c + .4byte ScrCmd_waitbuttonpress @ 0x6d + .4byte ScrCmd_yesnobox @ 0x6e + .4byte ScrCmd_multichoice @ 0x6f + .4byte ScrCmd_multichoicedefault @ 0x70 + .4byte ScrCmd_multichoicegrid @ 0x71 + .4byte ScrCmd_drawbox @ 0x72 + .4byte ScrCmd_erasebox @ 0x73 + .4byte ScrCmd_drawboxtext @ 0x74 + .4byte ScrCmd_showmonpic @ 0x75 + .4byte ScrCmd_hidemonpic @ 0x76 + .4byte ScrCmd_showcontestpainting @ 0x77 + .4byte ScrCmd_braillemessage @ 0x78 + .4byte ScrCmd_givemon @ 0x79 + .4byte ScrCmd_giveegg @ 0x7a + .4byte ScrCmd_setmonmove @ 0x7b + .4byte ScrCmd_checkpartymove @ 0x7c + .4byte ScrCmd_bufferspeciesname @ 0x7d + .4byte ScrCmd_bufferleadmonspeciesname @ 0x7e + .4byte ScrCmd_bufferpartymonnick @ 0x7f + .4byte ScrCmd_bufferitemname @ 0x80 + .4byte ScrCmd_bufferdecorationname @ 0x81 + .4byte ScrCmd_buffermovename @ 0x82 + .4byte ScrCmd_buffernumberstring @ 0x83 + .4byte ScrCmd_bufferstdstring @ 0x84 + .4byte ScrCmd_bufferstring @ 0x85 + .4byte ScrCmd_pokemart @ 0x86 + .4byte ScrCmd_pokemartdecoration @ 0x87 + .4byte ScrCmd_pokemartdecoration2 @ 0x88 + .4byte ScrCmd_playslotmachine @ 0x89 + .4byte ScrCmd_setberrytree @ 0x8a + .4byte ScrCmd_choosecontestmon @ 0x8b + .4byte ScrCmd_startcontest @ 0x8c + .4byte ScrCmd_showcontestresults @ 0x8d + .4byte ScrCmd_contestlinktransfer @ 0x8e + .4byte ScrCmd_random @ 0x8f + .4byte ScrCmd_addmoney @ 0x90 + .4byte ScrCmd_removemoney @ 0x91 + .4byte ScrCmd_checkmoney @ 0x92 + .4byte ScrCmd_showmoneybox @ 0x93 + .4byte ScrCmd_hidemoneybox @ 0x94 + .4byte ScrCmd_updatemoneybox @ 0x95 + .4byte ScrCmd_getpokenewsactive @ 0x96 + .4byte ScrCmd_fadescreen @ 0x97 + .4byte ScrCmd_fadescreenspeed @ 0x98 + .4byte ScrCmd_setflashlevel @ 0x99 + .4byte ScrCmd_animateflash @ 0x9a + .4byte ScrCmd_messageautoscroll @ 0x9b + .4byte ScrCmd_dofieldeffect @ 0x9c + .4byte ScrCmd_setfieldeffectargument @ 0x9d + .4byte ScrCmd_waitfieldeffect @ 0x9e + .4byte ScrCmd_setrespawn @ 0x9f + .4byte ScrCmd_checkplayergender @ 0xa0 + .4byte ScrCmd_playmoncry @ 0xa1 + .4byte ScrCmd_setmetatile @ 0xa2 + .4byte ScrCmd_resetweather @ 0xa3 + .4byte ScrCmd_setweather @ 0xa4 + .4byte ScrCmd_doweather @ 0xa5 + .4byte ScrCmd_setstepcallback @ 0xa6 + .4byte ScrCmd_setmaplayoutindex @ 0xa7 + .4byte ScrCmd_setobjectsubpriority @ 0xa8 + .4byte ScrCmd_resetobjectsubpriority @ 0xa9 + .4byte ScrCmd_createvobject @ 0xaa + .4byte ScrCmd_turnvobject @ 0xab + .4byte ScrCmd_opendoor @ 0xac + .4byte ScrCmd_closedoor @ 0xad + .4byte ScrCmd_waitdooranim @ 0xae + .4byte ScrCmd_setdooropen @ 0xaf + .4byte ScrCmd_setdoorclosed @ 0xb0 + .4byte ScrCmd_addelevmenuitem @ 0xb1 + .4byte ScrCmd_showelevmenu @ 0xb2 + .4byte ScrCmd_checkcoins @ 0xb3 + .4byte ScrCmd_addcoins @ 0xb4 + .4byte ScrCmd_removecoins @ 0xb5 + .4byte ScrCmd_setwildbattle @ 0xb6 + .4byte ScrCmd_dowildbattle @ 0xb7 + .4byte ScrCmd_setvaddress @ 0xb8 + .4byte ScrCmd_vgoto @ 0xb9 + .4byte ScrCmd_vcall @ 0xba + .4byte ScrCmd_vgoto_if @ 0xbb + .4byte ScrCmd_vcall_if @ 0xbc + .4byte ScrCmd_vmessage @ 0xbd + .4byte ScrCmd_vbuffermessage @ 0xbe + .4byte ScrCmd_vbufferstring @ 0xbf + .4byte ScrCmd_showcoinsbox @ 0xc0 + .4byte ScrCmd_hidecoinsbox @ 0xc1 + .4byte ScrCmd_updatecoinsbox @ 0xc2 + .4byte ScrCmd_incrementgamestat @ 0xc3 + .4byte ScrCmd_setescapewarp @ 0xc4 + .4byte ScrCmd_waitmoncry @ 0xc5 + .4byte ScrCmd_bufferboxname @ 0xc6 + .4byte ScrCmd_nop1 @ 0xc7 + .4byte ScrCmd_nop1 @ 0xc8 + .4byte ScrCmd_nop1 @ 0xc9 + .4byte ScrCmd_nop1 @ 0xca + .4byte ScrCmd_nop1 @ 0xcb + .4byte ScrCmd_nop1 @ 0xcc + .4byte ScrCmd_setmonmodernfatefulencounter @ 0xcd + .4byte ScrCmd_checkmonmodernfatefulencounter @ 0xce + .4byte ScrCmd_trywondercardscript @ 0xcf + .4byte ScrCmd_nop1 @ 0xd0 + .4byte ScrCmd_warpspinenter @ 0xd1 + .4byte ScrCmd_setmonmetlocation @ 0xd2 + .4byte ScrCmd_moverotatingtileobjects @ 0xd3 + .4byte ScrCmd_turnrotatingtileobjects @ 0xd4 + .4byte ScrCmd_initrotatingtilepuzzle @ 0xd5 + .4byte ScrCmd_freerotatingtilepuzzle @ 0xd6 + .4byte ScrCmd_warpmossdeepgym @ 0xd7 + .4byte ScrCmd_selectapproachingtrainer @ 0xd8 + .4byte ScrCmd_lockfortrainer @ 0xd9 + .4byte ScrCmd_closebraillemessage @ 0xda + .4byte ScrCmd_messageinstant @ 0xdb + .4byte ScrCmd_fadescreenswapbuffers @ 0xdc + .4byte ScrCmd_buffertrainerclassname @ 0xdd + .4byte ScrCmd_buffertrainername @ 0xde + .4byte ScrCmd_pokenavcall @ 0xdf + .4byte ScrCmd_warpwhitefade @ 0xe0 + .4byte ScrCmd_buffercontestname @ 0xe1 + .4byte ScrCmd_bufferitemnameplural @ 0xe2 gScriptCmdTableEnd:: .4byte ScrCmd_nop diff --git a/data/scripts/gift_pichu.inc b/data/scripts/gift_pichu.inc index d2cd381b53..56c1e52349 100644 --- a/data/scripts/gift_pichu.inc +++ b/data/scripts/gift_pichu.inc @@ -29,7 +29,7 @@ SurfPichu_FullParty: SurfPichu_GiveEgg: giveegg SPECIES_PICHU - setmoneventlegal VAR_GIFT_PICHU_SLOT + setmodernfatefulencounter VAR_GIFT_PICHU_SLOT setmonmetlocation VAR_GIFT_PICHU_SLOT, METLOC_FATEFUL_ENCOUNTER vgoto_if_eq VAR_GIFT_PICHU_SLOT, 1, SurfPichu_Slot1 vgoto_if_eq VAR_GIFT_PICHU_SLOT, 2, SurfPichu_Slot2 diff --git a/data/specials.inc b/data/specials.inc index 8e81ff847b..3d08eef4c6 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -489,7 +489,7 @@ gSpecials:: def_special ScrollableMultichoice_ClosePersistentMenu def_special DoDeoxysRockInteraction def_special SetDeoxysRockPalette - def_special CreateEventLegalEnemyMon + def_special CreateEnemyEventMon def_special StartMirageTowerDisintegration def_special StartMirageTowerShake def_special StartMirageTowerFossilFallAndSink diff --git a/graphics/battle_anims/sprites/black_ball.bin b/graphics/battle_anims/sprites/black_ball.bin deleted file mode 100644 index 4a6592a8ed..0000000000 Binary files a/graphics/battle_anims/sprites/black_ball.bin and /dev/null differ diff --git a/graphics/battle_anims/sprites/black_ball.pal b/graphics/battle_anims/sprites/black_ball.pal new file mode 100644 index 0000000000..57e320140e --- /dev/null +++ b/graphics/battle_anims/sprites/black_ball.pal @@ -0,0 +1,19 @@ +JASC-PAL +0100 +16 +156 205 98 +156 205 98 +156 205 98 +131 205 131 +156 205 0 +24 0 106 +156 8 98 +0 213 131 +24 197 0 +164 8 106 +156 8 98 +164 8 106 +156 205 131 +24 213 98 +156 8 106 +164 205 98 diff --git a/graphics/battle_anims/unused/line_sketch_2.pal b/graphics/battle_anims/unused/line_sketch_2.pal new file mode 100644 index 0000000000..17cce5c65e --- /dev/null +++ b/graphics/battle_anims/unused/line_sketch_2.pal @@ -0,0 +1,19 @@ +JASC-PAL +0100 +16 +0 0 0 +0 0 255 +0 255 255 +148 255 255 +148 205 255 +148 156 255 +0 0 0 +0 0 0 +0 0 0 +255 0 8 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +0 0 0 +255 255 255 diff --git a/graphics/battle_anims/unused/line_sketch_2_pal.bin b/graphics/battle_anims/unused/line_sketch_2_pal.bin deleted file mode 100644 index 15379a9cea..0000000000 Binary files a/graphics/battle_anims/unused/line_sketch_2_pal.bin and /dev/null differ diff --git a/graphics/union_room_chat/unk_palette2.pal b/graphics/union_room_chat/chat_messages_window.pal similarity index 100% rename from graphics/union_room_chat/unk_palette2.pal rename to graphics/union_room_chat/chat_messages_window.pal diff --git a/graphics/union_room_chat/window_1.pal b/graphics/union_room_chat/input_text.pal similarity index 100% rename from graphics/union_room_chat/window_1.pal rename to graphics/union_room_chat/input_text.pal diff --git a/graphics/union_room_chat/border.bin b/graphics/union_room_chat/keyboard.bin similarity index 100% rename from graphics/union_room_chat/border.bin rename to graphics/union_room_chat/keyboard.bin diff --git a/graphics/union_room_chat/border.png b/graphics/union_room_chat/keyboard.png similarity index 100% rename from graphics/union_room_chat/border.png rename to graphics/union_room_chat/keyboard.png diff --git a/graphics/union_room_chat/r_button.png b/graphics/union_room_chat/r_button.png index 168a293f35..06079ca211 100644 Binary files a/graphics/union_room_chat/r_button.png and b/graphics/union_room_chat/r_button.png differ diff --git a/graphics/union_room_chat/unk_palette1.pal b/graphics/union_room_chat/unused.pal similarity index 100% rename from graphics/union_room_chat/unk_palette1.pal rename to graphics/union_room_chat/unused.pal diff --git a/graphics/union_room_chat/window_2.pal b/graphics/union_room_chat/window_2.pal deleted file mode 100644 index a8c95a3c04..0000000000 --- a/graphics/union_room_chat/window_2.pal +++ /dev/null @@ -1,19 +0,0 @@ -JASC-PAL -0100 -16 -156 197 98 -41 131 222 -0 82 172 -197 255 106 -172 230 49 -246 246 213 -255 49 49 -255 148 148 -131 164 213 -238 238 90 -65 65 65 -115 115 115 -172 172 172 -230 230 255 -0 0 0 -255 255 255 diff --git a/include/battle.h b/include/battle.h index 1ae49b1a2c..83b552e7e1 100644 --- a/include/battle.h +++ b/include/battle.h @@ -853,7 +853,7 @@ struct MonSpritesGfx u8 *byte[MAX_BATTLERS_COUNT]; } sprites; struct SpriteTemplate templates[MAX_BATTLERS_COUNT]; - struct SpriteFrameImage frameImages[MAX_BATTLERS_COUNT][4]; + struct SpriteFrameImage frameImages[MAX_BATTLERS_COUNT][MAX_MON_PIC_FRAMES]; u8 unusedArr[0x80]; u8 *barFontGfx; void *unusedPtr; diff --git a/include/constants/event_objects.h b/include/constants/event_objects.h index 8278c6a66b..c8fa942655 100644 --- a/include/constants/event_objects.h +++ b/include/constants/event_objects.h @@ -288,6 +288,9 @@ #define FIRST_DECORATION_SPRITE_GFX OBJ_EVENT_GFX_PICHU_DOLL +#define OBJ_KIND_NORMAL 0 +#define OBJ_KIND_CLONE 255 // Exclusive to FRLG + // Special object event local ids #define OBJ_EVENT_ID_PLAYER 0xFF #define OBJ_EVENT_ID_CAMERA 0x7F diff --git a/include/constants/flags.h b/include/constants/flags.h index 4e108e1fe9..99a8377a75 100644 --- a/include/constants/flags.h +++ b/include/constants/flags.h @@ -580,7 +580,7 @@ #define FLAG_HIDDEN_ITEM_ROUTE_121_HP_UP (FLAG_HIDDEN_ITEMS_START + 0x27) #define FLAG_HIDDEN_ITEM_ROUTE_121_NUGGET (FLAG_HIDDEN_ITEMS_START + 0x28) #define FLAG_HIDDEN_ITEM_ROUTE_123_REVIVE (FLAG_HIDDEN_ITEMS_START + 0x29) -#define FLAG_HIDDEN_ITEM_ROUTE_113_REVIVE (FLAG_HIDDEN_ITEMS_START + 0x2A) +#define FLAG_HIDDEN_ITEM_ROUTE_114_REVIVE (FLAG_HIDDEN_ITEMS_START + 0x2A) #define FLAG_HIDDEN_ITEM_LILYCOVE_CITY_PP_UP (FLAG_HIDDEN_ITEMS_START + 0x2B) #define FLAG_HIDDEN_ITEM_ROUTE_104_SUPER_POTION (FLAG_HIDDEN_ITEMS_START + 0x2C) #define FLAG_HIDDEN_ITEM_ROUTE_116_SUPER_POTION (FLAG_HIDDEN_ITEMS_START + 0x2D) @@ -1051,7 +1051,7 @@ #define FLAG_ITEM_ROUTE_105_IRON 0x3EB #define FLAG_ITEM_ROUTE_106_PROTEIN 0x3EC #define FLAG_ITEM_ROUTE_109_PP_UP 0x3ED -#define FLAG_ITEM_ROUTE_109_RARE_CANDY 0x3EE +#define FLAG_ITEM_ROUTE_110_RARE_CANDY 0x3EE #define FLAG_ITEM_ROUTE_110_DIRE_HIT 0x3EF #define FLAG_ITEM_ROUTE_111_TM37 0x3F0 #define FLAG_ITEM_ROUTE_111_STARDUST 0x3F1 @@ -1162,7 +1162,7 @@ #define FLAG_ITEM_ROUTE_103_GUARD_SPEC 0x45A #define FLAG_ITEM_ROUTE_104_X_ACCURACY 0x45B #define FLAG_ITEM_MAUVILLE_CITY_X_SPEED 0x45C -#define FLAG_ITEM_PETALBURD_WOODS_PARALYZE_HEAL 0x45D +#define FLAG_ITEM_PETALBURG_WOODS_PARALYZE_HEAL 0x45D #define FLAG_ITEM_ROUTE_115_GREAT_BALL 0x45E #define FLAG_ITEM_SAFARI_ZONE_NORTH_CALCIUM 0x45F #define FLAG_ITEM_MT_PYRE_3F_SUPER_REPEL 0x460 diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h index 35eca5bbc4..821ab351c5 100644 --- a/include/constants/pokemon.h +++ b/include/constants/pokemon.h @@ -331,6 +331,14 @@ #define MON_PIC_HEIGHT 64 #define MON_PIC_SIZE (MON_PIC_WIDTH * MON_PIC_HEIGHT / 2) +// Most pokemon have 2 frames (a default and an alternate for their animation). +// There are 4 exceptions: +// - Castform has 4 frames, 1 for each form +// - Deoxys has 2 frames, 1 for each form +// - Spinda has 1 frame, presumably to avoid the work of animating its spots +// - Unown has 1 frame, presumably to avoid the work of animating all 28 of its forms +#define MAX_MON_PIC_FRAMES 4 + #define BATTLE_ALIVE_EXCEPT_ACTIVE 0 #define BATTLE_ALIVE_ATK_SIDE 1 #define BATTLE_ALIVE_DEF_SIDE 2 diff --git a/include/data.h b/include/data.h index b018da3f3b..79f6a3715a 100644 --- a/include/data.h +++ b/include/data.h @@ -7,6 +7,13 @@ #define MAX_TRAINER_ITEMS 4 +#define TRAINER_PIC_WIDTH 64 +#define TRAINER_PIC_HEIGHT 64 +#define TRAINER_PIC_SIZE (TRAINER_PIC_WIDTH * TRAINER_PIC_HEIGHT / 2) + +// Red and Leaf's back pics have 5 frames, but this is presumably irrelevant in the places this is used. +#define MAX_TRAINER_PIC_FRAMES 4 + enum { BATTLER_AFFINE_NORMAL, BATTLER_AFFINE_EMERGE, diff --git a/include/global.fieldmap.h b/include/global.fieldmap.h index 26e5c44bf1..d8fea5b23c 100644 --- a/include/global.fieldmap.h +++ b/include/global.fieldmap.h @@ -67,7 +67,7 @@ struct ObjectEventTemplate { /*0x00*/ u8 localId; /*0x01*/ u8 graphicsId; - /*0x02*/ u8 inConnection; // Leftover from FRLG + /*0x02*/ u8 kind; // Always OBJ_KIND_NORMAL in Emerald. /*0x03*/ //u8 padding1; /*0x04*/ s16 x; /*0x06*/ s16 y; diff --git a/include/graphics.h b/include/graphics.h index f00c727884..ce393c4d56 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -10359,10 +10359,10 @@ extern const u32 gUsePokeblockCondition_Gfx[]; extern const u16 gUnionRoomChat_Background_Pal[]; extern const u32 gUnionRoomChat_Background_Gfx[]; extern const u32 gUnionRoomChat_Background_Tilemap[]; -extern const u16 gUnionRoomChat_Window_Pal1[]; -extern const u16 gUnionRoomChat_Window_Pal2[]; -extern const u32 gUnionRoomChat_Border_Gfx[]; -extern const u32 gUnionRoomChat_Border_Tilemap[]; +extern const u16 gUnionRoomChat_InputText_Pal[]; +extern const u16 gUnionRoomChat_Keyboard_Pal[]; +extern const u32 gUnionRoomChat_Keyboard_Gfx[]; +extern const u32 gUnionRoomChat_Keyboard_Tilemap[]; extern const u32 gUnionRoomChat_RButtonLabels[]; // Use Pokeblock diff --git a/include/pokemon.h b/include/pokemon.h index 6d27d30c0c..cbfd194c67 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -75,7 +75,7 @@ enum { MON_DATA_SPATK, MON_DATA_SPDEF, MON_DATA_MAIL, - MON_DATA_SPECIES2, + MON_DATA_SPECIES_OR_EGG, MON_DATA_IVS, MON_DATA_CHAMPION_RIBBON, MON_DATA_WINNING_RIBBON, @@ -90,7 +90,7 @@ enum { MON_DATA_EARTH_RIBBON, MON_DATA_WORLD_RIBBON, MON_DATA_UNUSED_RIBBONS, - MON_DATA_EVENT_LEGAL, + MON_DATA_MODERN_FATEFUL_ENCOUNTER, MON_DATA_KNOWN_MOVES, MON_DATA_RIBBON_COUNT, MON_DATA_RIBBONS, @@ -153,27 +153,34 @@ struct PokemonSubstruct3 /* 0x07 */ u32 isEgg:1; /* 0x07 */ u32 unused2:1; - /* 0x08 */ u32 coolRibbon:3; - /* 0x08 */ u32 beautyRibbon:3; - /* 0x08 */ u32 cuteRibbon:3; - /* 0x09 */ u32 smartRibbon:3; - /* 0x09 */ u32 toughRibbon:3; - /* 0x09 */ u32 championRibbon:1; - /* 0x0A */ u32 winningRibbon:1; - /* 0x0A */ u32 victoryRibbon:1; - /* 0x0A */ u32 artistRibbon:1; - /* 0x0A */ u32 effortRibbon:1; - /* 0x0A */ u32 marineRibbon:1; // never distributed - /* 0x0A */ u32 landRibbon:1; // never distributed - /* 0x0A */ u32 skyRibbon:1; // never distributed - /* 0x0A */ u32 countryRibbon:1; // distributed during Pokémon Festa '04 and '05 to tournament winners - /* 0x0B */ u32 nationalRibbon:1; - /* 0x0B */ u32 earthRibbon:1; - /* 0x0B */ u32 worldRibbon:1; // distributed during Pokémon Festa '04 and '05 to tournament winners - /* 0x0B */ u32 unusedRibbons:2; // discarded in Gen 4 + /* 0x08 */ u32 coolRibbon:3; // Stores the highest contest rank achieved in the Cool category. + /* 0x08 */ u32 beautyRibbon:3; // Stores the highest contest rank achieved in the Beauty category. + /* 0x08 */ u32 cuteRibbon:3; // Stores the highest contest rank achieved in the Cute category. + /* 0x09 */ u32 smartRibbon:3; // Stores the highest contest rank achieved in the Smart category. + /* 0x09 */ u32 toughRibbon:3; // Stores the highest contest rank achieved in the Tough category. + /* 0x09 */ u32 championRibbon:1; // Given when defeating the Champion. Because both RSE and FRLG use it, later generations don't specify from which region it comes from. + /* 0x0A */ u32 winningRibbon:1; // Given at the Battle Tower's Level 50 challenge by winning a set of seven battles that extends the current streak to 56 or more. + /* 0x0A */ u32 victoryRibbon:1; // Given at the Battle Tower's Level 100 challenge by winning a set of seven battles that extends the current streak to 56 or more. + /* 0x0A */ u32 artistRibbon:1; // Given at the Contest Hall by winning a Master Rank contest with at least 800 points, and agreeing to have the Pokémon's portrait placed in the museum after being offered. + /* 0x0A */ u32 effortRibbon:1; // Given at Slateport's market to Pokémon with maximum EVs. + /* 0x0A */ u32 marineRibbon:1; // Never distributed. + /* 0x0A */ u32 landRibbon:1; // Never distributed. + /* 0x0A */ u32 skyRibbon:1; // Never distributed. + /* 0x0A */ u32 countryRibbon:1; // Distributed during Pokémon Festa '04 and '05 to tournament winners. + /* 0x0B */ u32 nationalRibbon:1; // Given to purified Shadow Pokémon in Colosseum/XD. + /* 0x0B */ u32 earthRibbon:1; // Given to teams that have beaten Mt. Battle's 100-battle challenge in Colosseum/XD. + /* 0x0B */ u32 worldRibbon:1; // Distributed during Pokémon Festa '04 and '05 to tournament winners. + /* 0x0B */ u32 unusedRibbons:2; // Discarded in Gen 4. /* 0x0B */ u32 abilityNum:2; - /* 0x0B */ u32 eventLegal:1; // controls Mew & Deoxys obedience; if set, Pokémon is a fateful encounter in Gen 4+; set for in-game event island legendaries, some distributed events, and Pokémon from XD: Gale of Darkness. -}; /* size = 12 */ + + // The functionality of this bit changed in FRLG: + // In RS, this bit does nothing, is never set, & is accidentally unset when hatching Eggs. + // In FRLG & Emerald, this controls Mew & Deoxys obedience and whether they can be traded. + // If set, a Pokémon is a fateful encounter in FRLG's summary screen if hatched & for all Pokémon in Gen 4+ summary screens. + // Set for in-game event island legendaries, events distributed after a certain date, & Pokémon from XD: Gale of Darkness. + // Not to be confused with METLOC_FATEFUL_ENCOUNTER. + /* 0x0B */ u32 modernFatefulEncounter:1; +}; // Number of bytes in the largest Pokémon substruct. // They are assumed to be the same size, and will be padded to @@ -425,11 +432,10 @@ void CreateBattleTowerMon_HandleLevel(struct Pokemon *mon, struct BattleTowerPok void CreateApprenticeMon(struct Pokemon *mon, const struct Apprentice *src, u8 monId); void CreateMonWithEVSpreadNatureOTID(struct Pokemon *mon, u16 species, u8 level, u8 nature, u8 fixedIV, u8 evSpread, u32 otId); void ConvertPokemonToBattleTowerPokemon(struct Pokemon *mon, struct BattleTowerPokemon *dest); -void CreateEventLegalMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId); bool8 ShouldIgnoreDeoxysForm(u8 caseId, u8 battlerId); u16 GetUnionRoomTrainerPic(void); u16 GetUnionRoomTrainerClass(void); -void CreateEventLegalEnemyMon(void); +void CreateEnemyEventMon(void); void CalculateMonStats(struct Pokemon *mon); void BoxMonToMon(const struct BoxPokemon *src, struct Pokemon *dest); u8 GetLevelFromMonExp(struct Pokemon *mon); diff --git a/include/trade.h b/include/trade.h index d63749653a..6b621038fc 100644 --- a/include/trade.h +++ b/include/trade.h @@ -12,8 +12,8 @@ extern const struct WindowTemplate gTradeEvolutionSceneYesNoWindowTemplate; s32 GetGameProgressForLinkTrade(void); void CB2_StartCreateTradeMenu(void); void CB2_LinkTrade(void); -int CanRegisterMonForTradingBoard(struct RfuGameCompatibilityData player, u16 species2, u16 species, bool8 isEventLegal); -int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct RfuGameCompatibilityData partner, u16 playerSpecies2, u16 partnerSpecies, u8 requestedType, u16 playerSpecies, bool8 isEventLegal); +int CanRegisterMonForTradingBoard(struct RfuGameCompatibilityData player, u16 species2, u16 species, bool8 isModernFatefulEncounter); +int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct RfuGameCompatibilityData partner, u16 playerSpecies2, u16 partnerSpecies, u8 requestedType, u16 playerSpecies, bool8 isModernFatefulEncounter); int CanSpinTradeMon(struct Pokemon *, u16); void InitTradeSequenceBgGpuRegs(void); void LinkTradeDrawWindow(void); diff --git a/make_tools.mk b/make_tools.mk index 5a5291b77b..c2c5a800cf 100644 --- a/make_tools.mk +++ b/make_tools.mk @@ -1,5 +1,6 @@ MAKEFLAGS += --no-print-directory +# Inclusive list. If you don't want a tool to be built, don't add it here. TOOLDIRS := tools/aif2pcm tools/bin2c tools/gbafix tools/gbagfx tools/jsonproc tools/mapjson tools/mid2agb tools/preproc tools/ramscrgen tools/rsfont tools/scaninc .PHONY: all $(TOOLDIRS) diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index b439278190..e8512affa2 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -112,9 +112,9 @@ static bool8 ShouldSwitchIfWonderGuard(void) { if (GetMonData(&party[i], MON_DATA_HP) == 0) continue; - if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_NONE) + if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE) continue; - if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG) + if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG) continue; if (i == gBattlerPartyIndexes[gActiveBattler]) continue; @@ -198,9 +198,9 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void) if (GetMonData(&party[i], MON_DATA_HP) == 0) continue; - if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_NONE) + if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE) continue; - if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG) + if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG) continue; if (i == gBattlerPartyIndexes[battlerIn1]) continue; @@ -295,8 +295,8 @@ static bool8 ShouldSwitchIfGameStatePrompt(void) //Look for mon in party that is able to be switched into and has ability that sets terrain if (GetMonData(&party[i], MON_DATA_HP) != 0 - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_NONE - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_EGG + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG && i != gBattlerPartyIndexes[gActiveBattler] && i != gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)] && IsBattlerGrounded(gActiveBattler) @@ -570,9 +570,9 @@ static bool8 FindMonWithFlagsAndSuperEffective(u16 flags, u8 moduloPercent) if (GetMonData(&party[i], MON_DATA_HP) == 0) continue; - if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_NONE) + if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE) continue; - if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG) + if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG) continue; if (i == gBattlerPartyIndexes[battlerIn1]) continue; @@ -662,9 +662,9 @@ bool32 ShouldSwitch(void) { if (GetMonData(&party[i], MON_DATA_HP) == 0) continue; - if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_NONE) + if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE) continue; - if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG) + if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG) continue; if (i == gBattlerPartyIndexes[battlerIn1]) continue; @@ -1066,8 +1066,8 @@ static bool8 ShouldUseItem(void) for (i = 0; i < PARTY_SIZE; i++) { if (GetMonData(&party[i], MON_DATA_HP) != 0 - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_NONE - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_EGG) + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG) { validMons++; } diff --git a/src/battle_ai_util.c b/src/battle_ai_util.c index 495e2ea1db..523d9229f4 100644 --- a/src/battle_ai_util.c +++ b/src/battle_ai_util.c @@ -3375,8 +3375,8 @@ s32 CountUsablePartyMons(u8 battlerId) { if (i != battlerOnField1 && i != battlerOnField2 && GetMonData(&party[i], MON_DATA_HP) != 0 - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_NONE - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_EGG) + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG) { ret++; } @@ -3399,8 +3399,8 @@ bool32 IsPartyFullyHealedExceptBattler(u8 battlerId) { if (i != gBattlerPartyIndexes[battlerId] && GetMonData(&party[i], MON_DATA_HP) != 0 - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_NONE - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_EGG + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG && GetMonData(&party[i], MON_DATA_HP) < GetMonData(&party[i], MON_DATA_MAX_HP)) return FALSE; } diff --git a/src/battle_anim_effects_2.c b/src/battle_anim_effects_2.c index 8aaab10a5c..f9879583a6 100755 --- a/src/battle_anim_effects_2.c +++ b/src/battle_anim_effects_2.c @@ -3059,7 +3059,7 @@ void AnimTask_LoadMusicNotesPals(u8 taskId) for (i = 1; i < NUM_MUSIC_NOTE_PAL_TAGS; i++) paletteNums[i] = AllocSpritePalette(ANIM_SPRITES_START - i); - gMonSpritesGfxPtr->buffer = AllocZeroed(0x2000); + gMonSpritesGfxPtr->buffer = AllocZeroed(MON_PIC_SIZE * MAX_MON_PIC_FRAMES); LZDecompressWram(gBattleAnimSpritePal_MusicNotes2, gMonSpritesGfxPtr->buffer); for (i = 0; i < NUM_MUSIC_NOTE_PAL_TAGS; i++) LoadPalette(&gMonSpritesGfxPtr->buffer[i * 32], (u16)(OBJ_PLTT_ID(paletteNums[i])), PLTT_SIZE_4BPP); diff --git a/src/battle_anim_mons.c b/src/battle_anim_mons.c index 17b04cc2b8..7f38da7cb5 100644 --- a/src/battle_anim_mons.c +++ b/src/battle_anim_mons.c @@ -2138,7 +2138,7 @@ u8 CreateAdditionalMonSpriteForMoveAnim(u16 species, bool8 isBackpic, u8 id, s16 u16 palette = AllocSpritePalette(sSpriteTemplates_MoveEffectMons[id].paletteTag); if (gMonSpritesGfxPtr != NULL && gMonSpritesGfxPtr->buffer == NULL) - gMonSpritesGfxPtr->buffer = AllocZeroed(0x2000); + gMonSpritesGfxPtr->buffer = AllocZeroed(MON_PIC_SIZE * MAX_MON_PIC_FRAMES); if (!isBackpic) { LoadCompressedPalette(GetMonSpritePalFromSpeciesAndPersonality(species, trainerId, personality), OBJ_PLTT_ID(palette), PLTT_SIZE_4BPP); diff --git a/src/battle_anim_utility_funcs.c b/src/battle_anim_utility_funcs.c index c569d54e86..b946cc0505 100644 --- a/src/battle_anim_utility_funcs.c +++ b/src/battle_anim_utility_funcs.c @@ -906,7 +906,7 @@ void AnimTask_GetFieldTerrain(u8 taskId) void AnimTask_AllocBackupPalBuffer(u8 taskId) { - gMonSpritesGfxPtr->buffer = AllocZeroed(0x2000); + gMonSpritesGfxPtr->buffer = AllocZeroed(MON_PIC_SIZE * MAX_MON_PIC_FRAMES); DestroyAnimVisualTask(taskId); } diff --git a/src/battle_controllers.c b/src/battle_controllers.c index 0814f6d126..d5d3e479e0 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -589,10 +589,10 @@ static void InitLinkBtlControllers(void) bool32 IsValidForBattle(struct Pokemon *mon) { - u32 species = GetMonData(mon, MON_DATA_SPECIES2); + u32 species = GetMonData(mon, MON_DATA_SPECIES_OR_EGG); return (species != SPECIES_NONE && species != SPECIES_EGG && GetMonData(mon, MON_DATA_HP) != 0 - && GetMonData(mon, MON_DATA_IS_EGG) == 0); + && GetMonData(mon, MON_DATA_IS_EGG) == FALSE); } static void SetBattlePartyIds(void) diff --git a/src/battle_main.c b/src/battle_main.c index 96b2e90a5e..60cf55f35e 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -623,33 +623,33 @@ static void CB2_InitBattleInternal(void) gBattleCommunication[MULTIUSE_STATE] = 0; } -#define BUFFER_PARTY_VS_SCREEN_STATUS(party, flags, i) \ - for ((i) = 0; (i) < PARTY_SIZE; (i)++) \ - { \ - u16 species = GetMonData(&(party)[(i)], MON_DATA_SPECIES2); \ - u16 hp = GetMonData(&(party)[(i)], MON_DATA_HP); \ - u32 status = GetMonData(&(party)[(i)], MON_DATA_STATUS); \ - \ - if (species == SPECIES_NONE) \ - continue; \ - \ - /* Is healthy mon? */ \ - if (species != SPECIES_EGG && hp != 0 && status == 0) \ - (flags) |= 1 << (i) * 2; \ - \ - if (species == SPECIES_NONE) /* Redundant */ \ - continue; \ - \ - /* Is Egg or statused? */ \ - if (hp != 0 && (species == SPECIES_EGG || status != 0)) \ - (flags) |= 2 << (i) * 2; \ - \ - if (species == SPECIES_NONE) /* Redundant */ \ - continue; \ - \ - /* Is fainted? */ \ - if (species != SPECIES_EGG && hp == 0) \ - (flags) |= 3 << (i) * 2; \ +#define BUFFER_PARTY_VS_SCREEN_STATUS(party, flags, i) \ + for ((i) = 0; (i) < PARTY_SIZE; (i)++) \ + { \ + u16 species = GetMonData(&(party)[(i)], MON_DATA_SPECIES_OR_EGG); \ + u16 hp = GetMonData(&(party)[(i)], MON_DATA_HP); \ + u32 status = GetMonData(&(party)[(i)], MON_DATA_STATUS); \ + \ + if (species == SPECIES_NONE) \ + continue; \ + \ + /* Is healthy mon? */ \ + if (species != SPECIES_EGG && hp != 0 && status == 0) \ + (flags) |= 1 << (i) * 2; \ + \ + if (species == SPECIES_NONE) /* Redundant */ \ + continue; \ + \ + /* Is Egg or statused? */ \ + if (hp != 0 && (species == SPECIES_EGG || status != 0)) \ + (flags) |= 2 << (i) * 2; \ + \ + if (species == SPECIES_NONE) /* Redundant */ \ + continue; \ + \ + /* Is fainted? */ \ + if (species != SPECIES_EGG && hp == 0) \ + (flags) |= 3 << (i) * 2; \ } // For Vs Screen at link battle start @@ -3443,8 +3443,8 @@ static void DoBattleIntro(void) for (i = 0; i < PARTY_SIZE; i++) { - if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_NONE - || GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_EGG) + if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE + || GetMonData(&gEnemyParty[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG) { hpStatus[i].hp = HP_EMPTY_SLOT; hpStatus[i].status = 0; @@ -3462,8 +3462,8 @@ static void DoBattleIntro(void) for (i = 0; i < PARTY_SIZE; i++) { - if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_NONE - || GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_EGG) + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE + || GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG) { hpStatus[i].hp = HP_EMPTY_SLOT; hpStatus[i].status = 0; @@ -5257,8 +5257,8 @@ static void HandleEndTurn_FinishBattle(void) // Recalculate the stats of every party member before the end for (i = 0; i < PARTY_SIZE; i++) { - if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) != SPECIES_NONE - && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) != SPECIES_EGG) + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE + && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG) { CalculateMonStats(&gPlayerParty[i]); } diff --git a/src/battle_message.c b/src/battle_message.c index 29580ded00..7bec30786f 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -3895,7 +3895,7 @@ static u32 GetEnemyMonCount(u32 firstId, u32 lastId, bool32 onlyAlive) for (i = firstId; i < lastId; i++) { - u32 species = GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2, NULL); + u32 species = GetMonData(&gEnemyParty[i], MON_DATA_SPECIES_OR_EGG, NULL); if (species != SPECIES_NONE && species != SPECIES_EGG && (!onlyAlive || GetMonData(&gEnemyParty[i], MON_DATA_HP, NULL))) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 2d9f6f6c18..6b3b3ed4a6 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -7511,8 +7511,8 @@ static void Cmd_getmoneyreward(void) s32 i, count; for (i = 0; i < PARTY_SIZE; i++) { - if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) != SPECIES_NONE - && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) != SPECIES_EGG) + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE + && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG) { if (GetMonData(&gPlayerParty[i], MON_DATA_LEVEL) > sPartyLevel) sPartyLevel = GetMonData(&gPlayerParty[i], MON_DATA_LEVEL); @@ -7607,8 +7607,8 @@ static void Cmd_drawpartystatussummary(void) for (i = 0; i < PARTY_SIZE; i++) { - if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_NONE - || GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG) + if (GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE + || GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG) { hpStatuses[i].hp = 0xFFFF; hpStatuses[i].status = 0; @@ -8650,7 +8650,7 @@ static bool32 CanTeleport(u8 battlerId) for (i = 0; i < PARTY_SIZE; i++) { - species = GetMonData(&party[i], MON_DATA_SPECIES2); + species = GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG); if (species != SPECIES_NONE && species != SPECIES_EGG && GetMonData(&party[i], MON_DATA_HP) != 0) count++; } @@ -13463,7 +13463,7 @@ static void Cmd_healpartystatus(void) for (i = 0; i < PARTY_SIZE; i++) { - u16 species = GetMonData(&party[i], MON_DATA_SPECIES2); + u16 species = GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG); u8 abilityNum = GetMonData(&party[i], MON_DATA_ABILITY_NUM); if (species != SPECIES_NONE && species != SPECIES_EGG) @@ -14075,8 +14075,8 @@ static void Cmd_trydobeatup(void) for (;gBattleCommunication[0] < PARTY_SIZE; gBattleCommunication[0]++) { if (GetMonData(&party[gBattleCommunication[0]], MON_DATA_HP) - && GetMonData(&party[gBattleCommunication[0]], MON_DATA_SPECIES2) - && GetMonData(&party[gBattleCommunication[0]], MON_DATA_SPECIES2) != SPECIES_EGG + && GetMonData(&party[gBattleCommunication[0]], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE + && GetMonData(&party[gBattleCommunication[0]], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG && !GetMonData(&party[gBattleCommunication[0]], MON_DATA_STATUS)) break; } @@ -14764,9 +14764,9 @@ static void Cmd_assistattackselect(void) { if (monId == gBattlerPartyIndexes[gBattlerAttacker]) continue; - if (GetMonData(&party[monId], MON_DATA_SPECIES2) == SPECIES_NONE) + if (GetMonData(&party[monId], MON_DATA_SPECIES_OR_EGG) == SPECIES_NONE) continue; - if (GetMonData(&party[monId], MON_DATA_SPECIES2) == SPECIES_EGG) + if (GetMonData(&party[monId], MON_DATA_SPECIES_OR_EGG) == SPECIES_EGG) continue; for (moveId = 0; moveId < MAX_MON_MOVES; moveId++) @@ -14997,7 +14997,7 @@ static void Cmd_pickup(void) bool32 isInPyramid = InBattlePyramid_(); for (i = 0; i < PARTY_SIZE; i++) { - species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG); heldItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); lvlDivBy10 = (GetMonData(&gPlayerParty[i], MON_DATA_LEVEL)-1) / 10; //Moving this here makes it easier to add in abilities like Honey Gather. if (lvlDivBy10 > 9) diff --git a/src/battle_setup.c b/src/battle_setup.c index b0b068ef39..220edd394a 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -741,7 +741,7 @@ static u16 GetSumOfPlayerPartyLevel(u8 numMons) for (i = 0; i < PARTY_SIZE; i++) { - u32 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + u32 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG); if (species != SPECIES_EGG && species != SPECIES_NONE && GetMonData(&gPlayerParty[i], MON_DATA_HP) != 0) { diff --git a/src/battle_tower.c b/src/battle_tower.c index f66c8c1f7a..9300756561 100644 --- a/src/battle_tower.c +++ b/src/battle_tower.c @@ -3381,7 +3381,7 @@ s32 GetHighestLevelInPlayerParty(void) for (i = 0; i < PARTY_SIZE; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, NULL) - && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) != SPECIES_EGG) + && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG, NULL) != SPECIES_EGG) { s32 level = GetMonData(&gPlayerParty[i], MON_DATA_LEVEL, NULL); if (level > highestLevel) diff --git a/src/battle_util.c b/src/battle_util.c index 5ccb0b237b..d7f3a767ba 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -3929,8 +3929,8 @@ bool8 HasNoMonsToSwitch(u8 battler, u8 partyIdBattlerOn1, u8 partyIdBattlerOn2) for (i = 0; i < PARTY_SIZE; i++) { if (GetMonData(&party[i], MON_DATA_HP) != 0 - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_NONE - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_EGG + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG && i != partyIdBattlerOn1 && i != partyIdBattlerOn2 && i != *(gBattleStruct->monToSwitchIntoId + flankId) && i != playerId[gBattleStruct->monToSwitchIntoId]) break; @@ -3948,8 +3948,8 @@ bool8 HasNoMonsToSwitch(u8 battler, u8 partyIdBattlerOn1, u8 partyIdBattlerOn2) for (i = playerId * MULTI_PARTY_SIZE; i < playerId * MULTI_PARTY_SIZE + MULTI_PARTY_SIZE; i++) { if (GetMonData(&party[i], MON_DATA_HP) != 0 - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_NONE - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_EGG) + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG) break; } return (i == playerId * MULTI_PARTY_SIZE + MULTI_PARTY_SIZE); @@ -3988,8 +3988,8 @@ bool8 HasNoMonsToSwitch(u8 battler, u8 partyIdBattlerOn1, u8 partyIdBattlerOn2) for (i = playerId * MULTI_PARTY_SIZE; i < playerId * MULTI_PARTY_SIZE + MULTI_PARTY_SIZE; i++) { if (GetMonData(&party[i], MON_DATA_HP) != 0 - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_NONE - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_EGG) + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG) break; } return (i == playerId * MULTI_PARTY_SIZE + MULTI_PARTY_SIZE); @@ -4006,8 +4006,8 @@ bool8 HasNoMonsToSwitch(u8 battler, u8 partyIdBattlerOn1, u8 partyIdBattlerOn2) for (i = playerId; i < playerId + MULTI_PARTY_SIZE; i++) { if (GetMonData(&party[i], MON_DATA_HP) != 0 - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_NONE - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_EGG) + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG) break; } return (i == playerId + 3); @@ -4035,8 +4035,8 @@ bool8 HasNoMonsToSwitch(u8 battler, u8 partyIdBattlerOn1, u8 partyIdBattlerOn2) for (i = 0; i < PARTY_SIZE; i++) { if (GetMonData(&party[i], MON_DATA_HP) != 0 - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_NONE - && GetMonData(&party[i], MON_DATA_SPECIES2) != SPECIES_EGG + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE + && GetMonData(&party[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG && i != partyIdBattlerOn1 && i != partyIdBattlerOn2 && i != *(gBattleStruct->monToSwitchIntoId + flankId) && i != playerId[gBattleStruct->monToSwitchIntoId]) break; @@ -8029,14 +8029,14 @@ u32 GetMoveTarget(u16 move, u8 setTarget) return targetBattler; } -static bool32 IsMonEventLegal(u8 battlerId) +static bool32 IsBattlerModernFatefulEncounter(u8 battlerId) { if (GetBattlerSide(battlerId) == B_SIDE_OPPONENT) return TRUE; if (GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES, NULL) != SPECIES_DEOXYS && GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES, NULL) != SPECIES_MEW) return TRUE; - return GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_EVENT_LEGAL, NULL); + return GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_MODERN_FATEFUL_ENCOUNTER, NULL); } u8 IsMonDisobedient(void) @@ -8051,7 +8051,7 @@ u8 IsMonDisobedient(void) if (GetBattlerSide(gBattlerAttacker) == B_SIDE_OPPONENT) return 0; - if (IsMonEventLegal(gBattlerAttacker)) // only false if illegal Mew or Deoxys + if (IsBattlerModernFatefulEncounter(gBattlerAttacker)) // only false if illegal Mew or Deoxys { if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && GetBattlerPosition(gBattlerAttacker) == 2) return 0; diff --git a/src/bike.c b/src/bike.c index 8f3faa2da0..10596418fd 100644 --- a/src/bike.c +++ b/src/bike.c @@ -863,23 +863,23 @@ static u8 Bike_DPadToDirection(u16 heldKeys) static u8 GetBikeCollision(u8 direction) { - u8 metatitleBehavior; + u8 metatileBehavior; struct ObjectEvent *playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; s16 x = playerObjEvent->currentCoords.x; s16 y = playerObjEvent->currentCoords.y; MoveCoords(direction, &x, &y); - metatitleBehavior = MapGridGetMetatileBehaviorAt(x, y); - return GetBikeCollisionAt(playerObjEvent, x, y, direction, metatitleBehavior); + metatileBehavior = MapGridGetMetatileBehaviorAt(x, y); + return GetBikeCollisionAt(playerObjEvent, x, y, direction, metatileBehavior); } -static u8 GetBikeCollisionAt(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 direction, u8 metatitleBehavior) +static u8 GetBikeCollisionAt(struct ObjectEvent *objectEvent, s16 x, s16 y, u8 direction, u8 metatileBehavior) { - u8 collision = CheckForObjectEventCollision(objectEvent, x, y, direction, metatitleBehavior); + u8 collision = CheckForObjectEventCollision(objectEvent, x, y, direction, metatileBehavior); if (collision > COLLISION_OBJECT_EVENT) return collision; - if (collision == COLLISION_NONE && IsRunningDisallowedByMetatile(metatitleBehavior)) + if (collision == COLLISION_NONE && IsRunningDisallowedByMetatile(metatileBehavior)) collision = COLLISION_IMPASSABLE; if (collision) diff --git a/src/braille_puzzles.c b/src/braille_puzzles.c index 6b5d66d315..3487428495 100644 --- a/src/braille_puzzles.c +++ b/src/braille_puzzles.c @@ -93,11 +93,11 @@ bool8 CheckRelicanthWailord(void) { // Emerald change: why did they flip it? // First comes Wailord - if (GetMonData(&gPlayerParty[0], MON_DATA_SPECIES2, 0) == SPECIES_WAILORD) + if (GetMonData(&gPlayerParty[0], MON_DATA_SPECIES_OR_EGG, 0) == SPECIES_WAILORD) { CalculatePlayerPartyCount(); // Last comes Relicanth - if (GetMonData(&gPlayerParty[gPlayerPartyCount - 1], MON_DATA_SPECIES2, 0) == SPECIES_RELICANTH) + if (GetMonData(&gPlayerParty[gPlayerPartyCount - 1], MON_DATA_SPECIES_OR_EGG, 0) == SPECIES_RELICANTH) return TRUE; } return FALSE; diff --git a/src/data.c b/src/data.c index 4b216cfd25..08b2c96e05 100644 --- a/src/data.c +++ b/src/data.c @@ -48,68 +48,68 @@ const struct SpriteFrameImage gBattlerPicTable_OpponentRight[] = const struct SpriteFrameImage gTrainerBackPicTable_Brendan[] = { - gTrainerBackPic_Brendan, 0x0800, - gTrainerBackPic_Brendan + 0x0800, 0x0800, - gTrainerBackPic_Brendan + 0x1000, 0x0800, - gTrainerBackPic_Brendan + 0x1800, 0x0800, + gTrainerBackPic_Brendan + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE, + gTrainerBackPic_Brendan + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE, + gTrainerBackPic_Brendan + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE, + gTrainerBackPic_Brendan + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE, }; const struct SpriteFrameImage gTrainerBackPicTable_May[] = { - gTrainerBackPic_May, 0x0800, - gTrainerBackPic_May + 0x0800, 0x0800, - gTrainerBackPic_May + 0x1000, 0x0800, - gTrainerBackPic_May + 0x1800, 0x0800, + gTrainerBackPic_May + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE, + gTrainerBackPic_May + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE, + gTrainerBackPic_May + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE, + gTrainerBackPic_May + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE, }; const struct SpriteFrameImage gTrainerBackPicTable_Red[] = { - gTrainerBackPic_Red, 0x0800, - gTrainerBackPic_Red + 0x0800, 0x0800, - gTrainerBackPic_Red + 0x1000, 0x0800, - gTrainerBackPic_Red + 0x1800, 0x0800, - gTrainerBackPic_Red + 0x2000, 0x0800, + gTrainerBackPic_Red + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE, + gTrainerBackPic_Red + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE, + gTrainerBackPic_Red + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE, + gTrainerBackPic_Red + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE, + gTrainerBackPic_Red + TRAINER_PIC_SIZE * 4, TRAINER_PIC_SIZE, }; const struct SpriteFrameImage gTrainerBackPicTable_Leaf[] = { - gTrainerBackPic_Leaf, 0x0800, - gTrainerBackPic_Leaf + 0x0800, 0x0800, - gTrainerBackPic_Leaf + 0x1000, 0x0800, - gTrainerBackPic_Leaf + 0x1800, 0x0800, - gTrainerBackPic_Leaf + 0x2000, 0x0800, + gTrainerBackPic_Leaf + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE, + gTrainerBackPic_Leaf + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE, + gTrainerBackPic_Leaf + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE, + gTrainerBackPic_Leaf + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE, + gTrainerBackPic_Leaf + TRAINER_PIC_SIZE * 4, TRAINER_PIC_SIZE, }; const struct SpriteFrameImage gTrainerBackPicTable_RubySapphireBrendan[] = { - gTrainerBackPic_RubySapphireBrendan, 0x0800, - gTrainerBackPic_RubySapphireBrendan + 0x0800, 0x0800, - gTrainerBackPic_RubySapphireBrendan + 0x1000, 0x0800, - gTrainerBackPic_RubySapphireBrendan + 0x1800, 0x0800, + gTrainerBackPic_RubySapphireBrendan + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE, + gTrainerBackPic_RubySapphireBrendan + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE, + gTrainerBackPic_RubySapphireBrendan + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE, + gTrainerBackPic_RubySapphireBrendan + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE, }; const struct SpriteFrameImage gTrainerBackPicTable_RubySapphireMay[] = { - gTrainerBackPic_RubySapphireMay, 0x0800, - gTrainerBackPic_RubySapphireMay + 0x0800, 0x0800, - gTrainerBackPic_RubySapphireMay + 0x1000, 0x0800, - gTrainerBackPic_RubySapphireMay + 0x1800, 0x0800, + gTrainerBackPic_RubySapphireMay + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE, + gTrainerBackPic_RubySapphireMay + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE, + gTrainerBackPic_RubySapphireMay + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE, + gTrainerBackPic_RubySapphireMay + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE, }; const struct SpriteFrameImage gTrainerBackPicTable_Wally[] = { - gTrainerBackPic_Wally, 0x0800, - gTrainerBackPic_Wally + 0x0800, 0x0800, - gTrainerBackPic_Wally + 0x1000, 0x0800, - gTrainerBackPic_Wally + 0x1800, 0x0800, + gTrainerBackPic_Wally + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE, + gTrainerBackPic_Wally + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE, + gTrainerBackPic_Wally + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE, + gTrainerBackPic_Wally + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE, }; const struct SpriteFrameImage gTrainerBackPicTable_Steven[] = { - gTrainerBackPic_Steven, 0x0800, - gTrainerBackPic_Steven + 0x0800, 0x0800, - gTrainerBackPic_Steven + 0x1000, 0x0800, - gTrainerBackPic_Steven + 0x1800, 0x0800, + gTrainerBackPic_Steven + TRAINER_PIC_SIZE * 0, TRAINER_PIC_SIZE, + gTrainerBackPic_Steven + TRAINER_PIC_SIZE * 1, TRAINER_PIC_SIZE, + gTrainerBackPic_Steven + TRAINER_PIC_SIZE * 2, TRAINER_PIC_SIZE, + gTrainerBackPic_Steven + TRAINER_PIC_SIZE * 3, TRAINER_PIC_SIZE, }; static const union AnimCmd sAnim_GeneralFrame0[] = @@ -290,7 +290,7 @@ static const union AnimCmd sAnim_MonPic_3[] = ANIMCMD_END, }; -const union AnimCmd *const gAnims_MonPic[] = +const union AnimCmd *const gAnims_MonPic[MAX_MON_PIC_FRAMES] = { sAnim_MonPic_0, sAnim_MonPic_1, diff --git a/src/data/trainer_graphics/back_pic_tables.h b/src/data/trainer_graphics/back_pic_tables.h index 1dbffba428..524d48d480 100644 --- a/src/data/trainer_graphics/back_pic_tables.h +++ b/src/data/trainer_graphics/back_pic_tables.h @@ -13,18 +13,48 @@ const struct MonCoords gTrainerBackPicCoords[] = // this table goes functionally unused, since none of these pics are compressed // and the place they would get extracted to gets overwritten later anyway // the casts are so they'll play nice with the strict struct definition -#define TRAINER_BACK_SPRITE(trainerPic, sprite, size) [TRAINER_BACK_PIC_##trainerPic] = {(const u32 *)sprite, size, TRAINER_BACK_PIC_##trainerPic} - const struct CompressedSpriteSheet gTrainerBackPicTable[] = { - TRAINER_BACK_SPRITE(BRENDAN, gTrainerBackPic_Brendan, 0x2000), - TRAINER_BACK_SPRITE(MAY, gTrainerBackPic_May, 0x2000), - TRAINER_BACK_SPRITE(RED, gTrainerBackPic_Red, 0x2800), - TRAINER_BACK_SPRITE(LEAF, gTrainerBackPic_Leaf, 0x2800), - TRAINER_BACK_SPRITE(RUBY_SAPPHIRE_BRENDAN, gTrainerBackPic_RubySapphireBrendan, 0x2000), - TRAINER_BACK_SPRITE(RUBY_SAPPHIRE_MAY, gTrainerBackPic_RubySapphireMay, 0x2000), - TRAINER_BACK_SPRITE(WALLY, gTrainerBackPic_Wally, 0x2000), - TRAINER_BACK_SPRITE(STEVEN, gTrainerBackPic_Steven, 0x2000), + [TRAINER_BACK_PIC_BRENDAN] = { + .data = (const u32 *)gTrainerBackPic_Brendan, + .size = TRAINER_PIC_SIZE * ARRAY_COUNT(gTrainerBackPicTable_Brendan), + .tag = TRAINER_BACK_PIC_BRENDAN, + }, + [TRAINER_BACK_PIC_MAY] = { + .data = (const u32 *)gTrainerBackPic_May, + .size = TRAINER_PIC_SIZE * ARRAY_COUNT(gTrainerBackPicTable_May), + .tag = TRAINER_BACK_PIC_MAY, + }, + [TRAINER_BACK_PIC_RED] = { + .data = (const u32 *)gTrainerBackPic_Red, + .size = TRAINER_PIC_SIZE * ARRAY_COUNT(gTrainerBackPicTable_Red), + .tag = TRAINER_BACK_PIC_RED, + }, + [TRAINER_BACK_PIC_LEAF] = { + .data = (const u32 *)gTrainerBackPic_Leaf, + .size = TRAINER_PIC_SIZE * ARRAY_COUNT(gTrainerBackPicTable_Leaf), + .tag = TRAINER_BACK_PIC_LEAF, + }, + [TRAINER_BACK_PIC_RUBY_SAPPHIRE_BRENDAN] = { + .data = (const u32 *)gTrainerBackPic_RubySapphireBrendan, + .size = TRAINER_PIC_SIZE * ARRAY_COUNT(gTrainerBackPicTable_RubySapphireBrendan), + .tag = TRAINER_BACK_PIC_RUBY_SAPPHIRE_BRENDAN, + }, + [TRAINER_BACK_PIC_RUBY_SAPPHIRE_MAY] = { + .data = (const u32 *)gTrainerBackPic_RubySapphireMay, + .size = TRAINER_PIC_SIZE * ARRAY_COUNT(gTrainerBackPicTable_RubySapphireMay), + .tag = TRAINER_BACK_PIC_RUBY_SAPPHIRE_MAY, + }, + [TRAINER_BACK_PIC_WALLY] = { + .data = (const u32 *)gTrainerBackPic_Wally, + .size = TRAINER_PIC_SIZE * ARRAY_COUNT(gTrainerBackPicTable_Wally), + .tag = TRAINER_BACK_PIC_WALLY, + }, + [TRAINER_BACK_PIC_STEVEN] = { + .data = (const u32 *)gTrainerBackPic_Steven, + .size = TRAINER_PIC_SIZE * ARRAY_COUNT(gTrainerBackPicTable_Steven), + .tag = TRAINER_BACK_PIC_STEVEN, + }, }; #define TRAINER_BACK_PAL(trainerPic, pal) [TRAINER_BACK_PIC_##trainerPic] = {pal, TRAINER_BACK_PIC_##trainerPic} diff --git a/src/data/trainer_graphics/front_pic_tables.h b/src/data/trainer_graphics/front_pic_tables.h index e751f3c1d2..dd4aa26de0 100644 --- a/src/data/trainer_graphics/front_pic_tables.h +++ b/src/data/trainer_graphics/front_pic_tables.h @@ -99,99 +99,99 @@ const struct MonCoords gTrainerFrontPicCoords[] = const struct CompressedSpriteSheet gTrainerFrontPicTable[] = { - TRAINER_SPRITE(HIKER, gTrainerFrontPic_Hiker, 0x800), - TRAINER_SPRITE(AQUA_GRUNT_M, gTrainerFrontPic_AquaGruntM, 0x800), - TRAINER_SPRITE(POKEMON_BREEDER_F, gTrainerFrontPic_PokemonBreederF, 0x800), - TRAINER_SPRITE(COOLTRAINER_M, gTrainerFrontPic_CoolTrainerM, 0x800), - TRAINER_SPRITE(BIRD_KEEPER, gTrainerFrontPic_BirdKeeper, 0x800), - TRAINER_SPRITE(COLLECTOR, gTrainerFrontPic_Collector, 0x800), - TRAINER_SPRITE(AQUA_GRUNT_F, gTrainerFrontPic_AquaGruntF, 0x800), - TRAINER_SPRITE(SWIMMER_M, gTrainerFrontPic_SwimmerM, 0x800), - TRAINER_SPRITE(MAGMA_GRUNT_M, gTrainerFrontPic_MagmaGruntM, 0x800), - TRAINER_SPRITE(EXPERT_M, gTrainerFrontPic_ExpertM, 0x800), - TRAINER_SPRITE(AQUA_ADMIN_M, gTrainerFrontPic_AquaAdminM, 0x800), - TRAINER_SPRITE(BLACK_BELT, gTrainerFrontPic_BlackBelt, 0x800), - TRAINER_SPRITE(AQUA_ADMIN_F, gTrainerFrontPic_AquaAdminF, 0x800), - TRAINER_SPRITE(AQUA_LEADER_ARCHIE, gTrainerFrontPic_AquaLeaderArchie, 0x800), - TRAINER_SPRITE(HEX_MANIAC, gTrainerFrontPic_HexManiac, 0x800), - TRAINER_SPRITE(AROMA_LADY, gTrainerFrontPic_AromaLady, 0x800), - TRAINER_SPRITE(RUIN_MANIAC, gTrainerFrontPic_RuinManiac, 0x800), - TRAINER_SPRITE(INTERVIEWER, gTrainerFrontPic_Interviewer, 0x800), - TRAINER_SPRITE(TUBER_F, gTrainerFrontPic_TuberF, 0x800), - TRAINER_SPRITE(TUBER_M, gTrainerFrontPic_TuberM, 0x800), - TRAINER_SPRITE(COOLTRAINER_F, gTrainerFrontPic_CoolTrainerF, 0x800), - TRAINER_SPRITE(LADY, gTrainerFrontPic_Lady, 0x800), - TRAINER_SPRITE(BEAUTY, gTrainerFrontPic_Beauty, 0x800), - TRAINER_SPRITE(RICH_BOY, gTrainerFrontPic_RichBoy, 0x800), - TRAINER_SPRITE(EXPERT_F, gTrainerFrontPic_ExpertF, 0x800), - TRAINER_SPRITE(POKEMANIAC, gTrainerFrontPic_Pokemaniac, 0x800), - TRAINER_SPRITE(MAGMA_GRUNT_F, gTrainerFrontPic_MagmaGruntF, 0x800), - TRAINER_SPRITE(GUITARIST, gTrainerFrontPic_Guitarist, 0x800), - TRAINER_SPRITE(KINDLER, gTrainerFrontPic_Kindler, 0x800), - TRAINER_SPRITE(CAMPER, gTrainerFrontPic_Camper, 0x800), - TRAINER_SPRITE(PICNICKER, gTrainerFrontPic_Picnicker, 0x800), - TRAINER_SPRITE(BUG_MANIAC, gTrainerFrontPic_BugManiac, 0x800), - TRAINER_SPRITE(POKEMON_BREEDER_M, gTrainerFrontPic_PokemonBreederM, 0x800), - TRAINER_SPRITE(PSYCHIC_M, gTrainerFrontPic_PsychicM, 0x800), - TRAINER_SPRITE(PSYCHIC_F, gTrainerFrontPic_PsychicF, 0x800), - TRAINER_SPRITE(GENTLEMAN, gTrainerFrontPic_Gentleman, 0x800), - TRAINER_SPRITE(ELITE_FOUR_SIDNEY, gTrainerFrontPic_EliteFourSidney, 0x800), - TRAINER_SPRITE(ELITE_FOUR_PHOEBE, gTrainerFrontPic_EliteFourPhoebe, 0x800), - TRAINER_SPRITE(ELITE_FOUR_GLACIA, gTrainerFrontPic_EliteFourGlacia, 0x800), - TRAINER_SPRITE(ELITE_FOUR_DRAKE, gTrainerFrontPic_EliteFourDrake, 0x800), - TRAINER_SPRITE(LEADER_ROXANNE, gTrainerFrontPic_LeaderRoxanne, 0x800), - TRAINER_SPRITE(LEADER_BRAWLY, gTrainerFrontPic_LeaderBrawly, 0x800), - TRAINER_SPRITE(LEADER_WATTSON, gTrainerFrontPic_LeaderWattson, 0x800), - TRAINER_SPRITE(LEADER_FLANNERY, gTrainerFrontPic_LeaderFlannery, 0x800), - TRAINER_SPRITE(LEADER_NORMAN, gTrainerFrontPic_LeaderNorman, 0x800), - TRAINER_SPRITE(LEADER_WINONA, gTrainerFrontPic_LeaderWinona, 0x800), - TRAINER_SPRITE(LEADER_TATE_AND_LIZA, gTrainerFrontPic_LeaderTateAndLiza, 0x800), - TRAINER_SPRITE(LEADER_JUAN, gTrainerFrontPic_LeaderJuan, 0x800), - TRAINER_SPRITE(SCHOOL_KID_M, gTrainerFrontPic_SchoolKidM, 0x800), - TRAINER_SPRITE(SCHOOL_KID_F, gTrainerFrontPic_SchoolKidF, 0x800), - TRAINER_SPRITE(SR_AND_JR, gTrainerFrontPic_SrAndJr, 0x1000), - TRAINER_SPRITE(POKEFAN_M, gTrainerFrontPic_PokefanM, 0x1000), - TRAINER_SPRITE(POKEFAN_F, gTrainerFrontPic_PokefanF, 0x800), - TRAINER_SPRITE(YOUNGSTER, gTrainerFrontPic_Youngster, 0x800), - TRAINER_SPRITE(CHAMPION_WALLACE, gTrainerFrontPic_ChampionWallace, 0x1000), - TRAINER_SPRITE(FISHERMAN, gTrainerFrontPic_Fisherman, 0x800), - TRAINER_SPRITE(CYCLING_TRIATHLETE_M, gTrainerFrontPic_CyclingTriathleteM, 0x1000), - TRAINER_SPRITE(CYCLING_TRIATHLETE_F, gTrainerFrontPic_CyclingTriathleteF, 0x800), - TRAINER_SPRITE(RUNNING_TRIATHLETE_M, gTrainerFrontPic_RunningTriathleteM, 0x800), - TRAINER_SPRITE(RUNNING_TRIATHLETE_F, gTrainerFrontPic_RunningTriathleteF, 0x800), - TRAINER_SPRITE(SWIMMING_TRIATHLETE_M, gTrainerFrontPic_SwimmingTriathleteM, 0x800), - TRAINER_SPRITE(SWIMMING_TRIATHLETE_F, gTrainerFrontPic_SwimmingTriathleteF, 0x800), - TRAINER_SPRITE(DRAGON_TAMER, gTrainerFrontPic_DragonTamer, 0x800), - TRAINER_SPRITE(NINJA_BOY, gTrainerFrontPic_NinjaBoy, 0x800), - TRAINER_SPRITE(BATTLE_GIRL, gTrainerFrontPic_BattleGirl, 0x1000), - TRAINER_SPRITE(PARASOL_LADY, gTrainerFrontPic_ParasolLady, 0x800), - TRAINER_SPRITE(SWIMMER_F, gTrainerFrontPic_SwimmerF, 0x800), - TRAINER_SPRITE(TWINS, gTrainerFrontPic_Twins, 0x800), - TRAINER_SPRITE(SAILOR, gTrainerFrontPic_Sailor, 0x800), - TRAINER_SPRITE(MAGMA_ADMIN, gTrainerFrontPic_MagmaAdmin, 0x800), - TRAINER_SPRITE(WALLY, gTrainerFrontPic_Wally, 0x800), - TRAINER_SPRITE(BRENDAN, gTrainerFrontPic_Brendan, 0x800), - TRAINER_SPRITE(MAY, gTrainerFrontPic_May, 0x800), - TRAINER_SPRITE(BUG_CATCHER, gTrainerFrontPic_BugCatcher, 0x800), - TRAINER_SPRITE(POKEMON_RANGER_M, gTrainerFrontPic_PokemonRangerM, 0x800), - TRAINER_SPRITE(POKEMON_RANGER_F, gTrainerFrontPic_PokemonRangerF, 0x800), - TRAINER_SPRITE(MAGMA_LEADER_MAXIE, gTrainerFrontPic_MagmaLeaderMaxie, 0x800), - TRAINER_SPRITE(LASS, gTrainerFrontPic_Lass, 0x800), - TRAINER_SPRITE(YOUNG_COUPLE, gTrainerFrontPic_YoungCouple, 0x800), - TRAINER_SPRITE(OLD_COUPLE, gTrainerFrontPic_OldCouple, 0x800), - TRAINER_SPRITE(SIS_AND_BRO, gTrainerFrontPic_SisAndBro, 0x800), - TRAINER_SPRITE(STEVEN, gTrainerFrontPic_Steven, 0x800), - TRAINER_SPRITE(SALON_MAIDEN_ANABEL, gTrainerFrontPic_SalonMaidenAnabel, 0x800), - TRAINER_SPRITE(DOME_ACE_TUCKER, gTrainerFrontPic_DomeAceTucker, 0x800), - TRAINER_SPRITE(PALACE_MAVEN_SPENSER, gTrainerFrontPic_PalaceMavenSpenser, 0x800), - TRAINER_SPRITE(ARENA_TYCOON_GRETA, gTrainerFrontPic_ArenaTycoonGreta, 0x1000), - TRAINER_SPRITE(FACTORY_HEAD_NOLAND, gTrainerFrontPic_FactoryHeadNoland, 0x800), - TRAINER_SPRITE(PIKE_QUEEN_LUCY, gTrainerFrontPic_PikeQueenLucy, 0x800), - TRAINER_SPRITE(PYRAMID_KING_BRANDON, gTrainerFrontPic_PyramidKingBrandon, 0x800), - TRAINER_SPRITE(RED, gTrainerFrontPic_Red, 0x800), - TRAINER_SPRITE(LEAF, gTrainerFrontPic_Leaf, 0x800), - TRAINER_SPRITE(RS_BRENDAN, gTrainerFrontPic_RubySapphireBrendan, 0x800), - TRAINER_SPRITE(RS_MAY, gTrainerFrontPic_RubySapphireMay, 0x800), + TRAINER_SPRITE(HIKER, gTrainerFrontPic_Hiker, TRAINER_PIC_SIZE), + TRAINER_SPRITE(AQUA_GRUNT_M, gTrainerFrontPic_AquaGruntM, TRAINER_PIC_SIZE), + TRAINER_SPRITE(POKEMON_BREEDER_F, gTrainerFrontPic_PokemonBreederF, TRAINER_PIC_SIZE), + TRAINER_SPRITE(COOLTRAINER_M, gTrainerFrontPic_CoolTrainerM, TRAINER_PIC_SIZE), + TRAINER_SPRITE(BIRD_KEEPER, gTrainerFrontPic_BirdKeeper, TRAINER_PIC_SIZE), + TRAINER_SPRITE(COLLECTOR, gTrainerFrontPic_Collector, TRAINER_PIC_SIZE), + TRAINER_SPRITE(AQUA_GRUNT_F, gTrainerFrontPic_AquaGruntF, TRAINER_PIC_SIZE), + TRAINER_SPRITE(SWIMMER_M, gTrainerFrontPic_SwimmerM, TRAINER_PIC_SIZE), + TRAINER_SPRITE(MAGMA_GRUNT_M, gTrainerFrontPic_MagmaGruntM, TRAINER_PIC_SIZE), + TRAINER_SPRITE(EXPERT_M, gTrainerFrontPic_ExpertM, TRAINER_PIC_SIZE), + TRAINER_SPRITE(AQUA_ADMIN_M, gTrainerFrontPic_AquaAdminM, TRAINER_PIC_SIZE), + TRAINER_SPRITE(BLACK_BELT, gTrainerFrontPic_BlackBelt, TRAINER_PIC_SIZE), + TRAINER_SPRITE(AQUA_ADMIN_F, gTrainerFrontPic_AquaAdminF, TRAINER_PIC_SIZE), + TRAINER_SPRITE(AQUA_LEADER_ARCHIE, gTrainerFrontPic_AquaLeaderArchie, TRAINER_PIC_SIZE), + TRAINER_SPRITE(HEX_MANIAC, gTrainerFrontPic_HexManiac, TRAINER_PIC_SIZE), + TRAINER_SPRITE(AROMA_LADY, gTrainerFrontPic_AromaLady, TRAINER_PIC_SIZE), + TRAINER_SPRITE(RUIN_MANIAC, gTrainerFrontPic_RuinManiac, TRAINER_PIC_SIZE), + TRAINER_SPRITE(INTERVIEWER, gTrainerFrontPic_Interviewer, TRAINER_PIC_SIZE), + TRAINER_SPRITE(TUBER_F, gTrainerFrontPic_TuberF, TRAINER_PIC_SIZE), + TRAINER_SPRITE(TUBER_M, gTrainerFrontPic_TuberM, TRAINER_PIC_SIZE), + TRAINER_SPRITE(COOLTRAINER_F, gTrainerFrontPic_CoolTrainerF, TRAINER_PIC_SIZE), + TRAINER_SPRITE(LADY, gTrainerFrontPic_Lady, TRAINER_PIC_SIZE), + TRAINER_SPRITE(BEAUTY, gTrainerFrontPic_Beauty, TRAINER_PIC_SIZE), + TRAINER_SPRITE(RICH_BOY, gTrainerFrontPic_RichBoy, TRAINER_PIC_SIZE), + TRAINER_SPRITE(EXPERT_F, gTrainerFrontPic_ExpertF, TRAINER_PIC_SIZE), + TRAINER_SPRITE(POKEMANIAC, gTrainerFrontPic_Pokemaniac, TRAINER_PIC_SIZE), + TRAINER_SPRITE(MAGMA_GRUNT_F, gTrainerFrontPic_MagmaGruntF, TRAINER_PIC_SIZE), + TRAINER_SPRITE(GUITARIST, gTrainerFrontPic_Guitarist, TRAINER_PIC_SIZE), + TRAINER_SPRITE(KINDLER, gTrainerFrontPic_Kindler, TRAINER_PIC_SIZE), + TRAINER_SPRITE(CAMPER, gTrainerFrontPic_Camper, TRAINER_PIC_SIZE), + TRAINER_SPRITE(PICNICKER, gTrainerFrontPic_Picnicker, TRAINER_PIC_SIZE), + TRAINER_SPRITE(BUG_MANIAC, gTrainerFrontPic_BugManiac, TRAINER_PIC_SIZE), + TRAINER_SPRITE(POKEMON_BREEDER_M, gTrainerFrontPic_PokemonBreederM, TRAINER_PIC_SIZE), + TRAINER_SPRITE(PSYCHIC_M, gTrainerFrontPic_PsychicM, TRAINER_PIC_SIZE), + TRAINER_SPRITE(PSYCHIC_F, gTrainerFrontPic_PsychicF, TRAINER_PIC_SIZE), + TRAINER_SPRITE(GENTLEMAN, gTrainerFrontPic_Gentleman, TRAINER_PIC_SIZE), + TRAINER_SPRITE(ELITE_FOUR_SIDNEY, gTrainerFrontPic_EliteFourSidney, TRAINER_PIC_SIZE), + TRAINER_SPRITE(ELITE_FOUR_PHOEBE, gTrainerFrontPic_EliteFourPhoebe, TRAINER_PIC_SIZE), + TRAINER_SPRITE(ELITE_FOUR_GLACIA, gTrainerFrontPic_EliteFourGlacia, TRAINER_PIC_SIZE), + TRAINER_SPRITE(ELITE_FOUR_DRAKE, gTrainerFrontPic_EliteFourDrake, TRAINER_PIC_SIZE), + TRAINER_SPRITE(LEADER_ROXANNE, gTrainerFrontPic_LeaderRoxanne, TRAINER_PIC_SIZE), + TRAINER_SPRITE(LEADER_BRAWLY, gTrainerFrontPic_LeaderBrawly, TRAINER_PIC_SIZE), + TRAINER_SPRITE(LEADER_WATTSON, gTrainerFrontPic_LeaderWattson, TRAINER_PIC_SIZE), + TRAINER_SPRITE(LEADER_FLANNERY, gTrainerFrontPic_LeaderFlannery, TRAINER_PIC_SIZE), + TRAINER_SPRITE(LEADER_NORMAN, gTrainerFrontPic_LeaderNorman, TRAINER_PIC_SIZE), + TRAINER_SPRITE(LEADER_WINONA, gTrainerFrontPic_LeaderWinona, TRAINER_PIC_SIZE), + TRAINER_SPRITE(LEADER_TATE_AND_LIZA, gTrainerFrontPic_LeaderTateAndLiza, TRAINER_PIC_SIZE), + TRAINER_SPRITE(LEADER_JUAN, gTrainerFrontPic_LeaderJuan, TRAINER_PIC_SIZE), + TRAINER_SPRITE(SCHOOL_KID_M, gTrainerFrontPic_SchoolKidM, TRAINER_PIC_SIZE), + TRAINER_SPRITE(SCHOOL_KID_F, gTrainerFrontPic_SchoolKidF, TRAINER_PIC_SIZE), + TRAINER_SPRITE(SR_AND_JR, gTrainerFrontPic_SrAndJr, TRAINER_PIC_SIZE * 2), + TRAINER_SPRITE(POKEFAN_M, gTrainerFrontPic_PokefanM, TRAINER_PIC_SIZE * 2), + TRAINER_SPRITE(POKEFAN_F, gTrainerFrontPic_PokefanF, TRAINER_PIC_SIZE), + TRAINER_SPRITE(YOUNGSTER, gTrainerFrontPic_Youngster, TRAINER_PIC_SIZE), + TRAINER_SPRITE(CHAMPION_WALLACE, gTrainerFrontPic_ChampionWallace, TRAINER_PIC_SIZE * 2), + TRAINER_SPRITE(FISHERMAN, gTrainerFrontPic_Fisherman, TRAINER_PIC_SIZE), + TRAINER_SPRITE(CYCLING_TRIATHLETE_M, gTrainerFrontPic_CyclingTriathleteM, TRAINER_PIC_SIZE * 2), + TRAINER_SPRITE(CYCLING_TRIATHLETE_F, gTrainerFrontPic_CyclingTriathleteF, TRAINER_PIC_SIZE), + TRAINER_SPRITE(RUNNING_TRIATHLETE_M, gTrainerFrontPic_RunningTriathleteM, TRAINER_PIC_SIZE), + TRAINER_SPRITE(RUNNING_TRIATHLETE_F, gTrainerFrontPic_RunningTriathleteF, TRAINER_PIC_SIZE), + TRAINER_SPRITE(SWIMMING_TRIATHLETE_M, gTrainerFrontPic_SwimmingTriathleteM, TRAINER_PIC_SIZE), + TRAINER_SPRITE(SWIMMING_TRIATHLETE_F, gTrainerFrontPic_SwimmingTriathleteF, TRAINER_PIC_SIZE), + TRAINER_SPRITE(DRAGON_TAMER, gTrainerFrontPic_DragonTamer, TRAINER_PIC_SIZE), + TRAINER_SPRITE(NINJA_BOY, gTrainerFrontPic_NinjaBoy, TRAINER_PIC_SIZE), + TRAINER_SPRITE(BATTLE_GIRL, gTrainerFrontPic_BattleGirl, TRAINER_PIC_SIZE * 2), + TRAINER_SPRITE(PARASOL_LADY, gTrainerFrontPic_ParasolLady, TRAINER_PIC_SIZE), + TRAINER_SPRITE(SWIMMER_F, gTrainerFrontPic_SwimmerF, TRAINER_PIC_SIZE), + TRAINER_SPRITE(TWINS, gTrainerFrontPic_Twins, TRAINER_PIC_SIZE), + TRAINER_SPRITE(SAILOR, gTrainerFrontPic_Sailor, TRAINER_PIC_SIZE), + TRAINER_SPRITE(MAGMA_ADMIN, gTrainerFrontPic_MagmaAdmin, TRAINER_PIC_SIZE), + TRAINER_SPRITE(WALLY, gTrainerFrontPic_Wally, TRAINER_PIC_SIZE), + TRAINER_SPRITE(BRENDAN, gTrainerFrontPic_Brendan, TRAINER_PIC_SIZE), + TRAINER_SPRITE(MAY, gTrainerFrontPic_May, TRAINER_PIC_SIZE), + TRAINER_SPRITE(BUG_CATCHER, gTrainerFrontPic_BugCatcher, TRAINER_PIC_SIZE), + TRAINER_SPRITE(POKEMON_RANGER_M, gTrainerFrontPic_PokemonRangerM, TRAINER_PIC_SIZE), + TRAINER_SPRITE(POKEMON_RANGER_F, gTrainerFrontPic_PokemonRangerF, TRAINER_PIC_SIZE), + TRAINER_SPRITE(MAGMA_LEADER_MAXIE, gTrainerFrontPic_MagmaLeaderMaxie, TRAINER_PIC_SIZE), + TRAINER_SPRITE(LASS, gTrainerFrontPic_Lass, TRAINER_PIC_SIZE), + TRAINER_SPRITE(YOUNG_COUPLE, gTrainerFrontPic_YoungCouple, TRAINER_PIC_SIZE), + TRAINER_SPRITE(OLD_COUPLE, gTrainerFrontPic_OldCouple, TRAINER_PIC_SIZE), + TRAINER_SPRITE(SIS_AND_BRO, gTrainerFrontPic_SisAndBro, TRAINER_PIC_SIZE), + TRAINER_SPRITE(STEVEN, gTrainerFrontPic_Steven, TRAINER_PIC_SIZE), + TRAINER_SPRITE(SALON_MAIDEN_ANABEL, gTrainerFrontPic_SalonMaidenAnabel, TRAINER_PIC_SIZE), + TRAINER_SPRITE(DOME_ACE_TUCKER, gTrainerFrontPic_DomeAceTucker, TRAINER_PIC_SIZE), + TRAINER_SPRITE(PALACE_MAVEN_SPENSER, gTrainerFrontPic_PalaceMavenSpenser, TRAINER_PIC_SIZE), + TRAINER_SPRITE(ARENA_TYCOON_GRETA, gTrainerFrontPic_ArenaTycoonGreta, TRAINER_PIC_SIZE * 2), + TRAINER_SPRITE(FACTORY_HEAD_NOLAND, gTrainerFrontPic_FactoryHeadNoland, TRAINER_PIC_SIZE), + TRAINER_SPRITE(PIKE_QUEEN_LUCY, gTrainerFrontPic_PikeQueenLucy, TRAINER_PIC_SIZE), + TRAINER_SPRITE(PYRAMID_KING_BRANDON, gTrainerFrontPic_PyramidKingBrandon, TRAINER_PIC_SIZE), + TRAINER_SPRITE(RED, gTrainerFrontPic_Red, TRAINER_PIC_SIZE), + TRAINER_SPRITE(LEAF, gTrainerFrontPic_Leaf, TRAINER_PIC_SIZE), + TRAINER_SPRITE(RS_BRENDAN, gTrainerFrontPic_RubySapphireBrendan, TRAINER_PIC_SIZE), + TRAINER_SPRITE(RS_MAY, gTrainerFrontPic_RubySapphireMay, TRAINER_PIC_SIZE), }; #define TRAINER_PAL(trainerPic, pal) [TRAINER_PIC_##trainerPic] = {pal, TRAINER_PIC_##trainerPic} diff --git a/src/daycare.c b/src/daycare.c index cabecc8ea5..803c0cacf9 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -729,7 +729,7 @@ static void BuildEggMoveset(struct Pokemon *egg, struct BoxPokemon *father, stru for (j = 0; j < NUM_TECHNICAL_MACHINES + NUM_HIDDEN_MACHINES; j++) { u16 moveId = ItemIdToBattleMoveId(ITEM_TM01 + j); - if (sHatchedEggFatherMoves[i] == moveId && CanLearnTeachableMove(GetMonData(egg, MON_DATA_SPECIES2), moveId)) + if (sHatchedEggFatherMoves[i] == moveId && CanLearnTeachableMove(GetMonData(egg, MON_DATA_SPECIES_OR_EGG), moveId)) { if (GiveMoveToMon(egg, sHatchedEggFatherMoves[i]) == MON_HAS_MAX_MOVES) DeleteFirstMoveAndGiveMoveToMon(egg, sHatchedEggFatherMoves[i]); diff --git a/src/debug.c b/src/debug.c index 301bae51df..5c14dbfb0f 100644 --- a/src/debug.c +++ b/src/debug.c @@ -1149,8 +1149,8 @@ static void DebugAction_Util_PoisonMons(u8 taskId) for (i = 0; i < PARTY_SIZE; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, 0) - && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) != SPECIES_NONE - && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) != SPECIES_EGG) + && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE + && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG) { u32 curStatus = STATUS1_POISON; SetMonData(&gPlayerParty[i], MON_DATA_STATUS, &curStatus); diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c index e23c04c1ad..8d47595c8b 100644 --- a/src/dodrio_berry_picking.c +++ b/src/dodrio_berry_picking.c @@ -2906,7 +2906,7 @@ void IsDodrioInParty(void) for (i = 0; i < PARTY_SIZE; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_SANITY_HAS_SPECIES) - && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_DODRIO) + && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG) == SPECIES_DODRIO) { gSpecialVar_Result = TRUE; return; diff --git a/src/egg_hatch.c b/src/egg_hatch.c index 3a5937ba4d..fe50c80f41 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -313,7 +313,7 @@ static void CreateHatchedMon(struct Pokemon *egg, struct Pokemon *temp) { u16 species; u32 personality, pokerus; - u8 i, friendship, language, gameMet, markings, isEventLegal; + u8 i, friendship, language, gameMet, markings, isModernFatefulEncounter; u16 moves[MAX_MON_MOVES]; u32 ivs[NUM_STATS]; @@ -332,7 +332,7 @@ static void CreateHatchedMon(struct Pokemon *egg, struct Pokemon *temp) gameMet = GetMonData(egg, MON_DATA_MET_GAME); markings = GetMonData(egg, MON_DATA_MARKINGS); pokerus = GetMonData(egg, MON_DATA_POKERUS); - isEventLegal = GetMonData(egg, MON_DATA_EVENT_LEGAL); + isModernFatefulEncounter = GetMonData(egg, MON_DATA_MODERN_FATEFUL_ENCOUNTER); CreateMon(temp, species, EGG_HATCH_LEVEL, USE_RANDOM_IVS, TRUE, personality, OT_ID_PLAYER_ID, 0); @@ -350,7 +350,7 @@ static void CreateHatchedMon(struct Pokemon *egg, struct Pokemon *temp) friendship = 120; SetMonData(temp, MON_DATA_FRIENDSHIP, &friendship); SetMonData(temp, MON_DATA_POKERUS, &pokerus); - SetMonData(temp, MON_DATA_EVENT_LEGAL, &isEventLegal); + SetMonData(temp, MON_DATA_MODERN_FATEFUL_ENCOUNTER, &isModernFatefulEncounter); *egg = *temp; } diff --git a/src/event_object_movement.c b/src/event_object_movement.c index e1a02e3ee5..9b8cc1ac35 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -1499,7 +1499,7 @@ u8 SpawnSpecialObjectEventParameterized(u8 graphicsId, u8 movementBehavior, u8 l y -= MAP_OFFSET; objectEventTemplate.localId = localId; objectEventTemplate.graphicsId = graphicsId; - objectEventTemplate.inConnection = 0; + objectEventTemplate.kind = OBJ_KIND_NORMAL; objectEventTemplate.x = x; objectEventTemplate.y = y; objectEventTemplate.elevation = elevation; diff --git a/src/field_poison.c b/src/field_poison.c index fcb47acdb8..f254a6d142 100644 --- a/src/field_poison.c +++ b/src/field_poison.c @@ -19,7 +19,7 @@ static bool32 IsMonValidSpecies(struct Pokemon *pokemon) { - u16 species = GetMonData(pokemon, MON_DATA_SPECIES2); + u16 species = GetMonData(pokemon, MON_DATA_SPECIES_OR_EGG); if (species == SPECIES_NONE || species == SPECIES_EGG) return FALSE; diff --git a/src/field_specials.c b/src/field_specials.c index 3996b739ac..6fdec2a5f0 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -1448,7 +1448,7 @@ bool8 IsStarterInParty(void) u8 partyCount = CalculatePlayerPartyCount(); for (i = 0; i < partyCount; i++) { - if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) == starter) + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG, NULL) == starter) return TRUE; } return FALSE; @@ -1541,8 +1541,8 @@ u8 GetLeadMonIndex(void) u8 partyCount = CalculatePlayerPartyCount(); for (i = 0; i < partyCount; i++) { - if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) != SPECIES_EGG - && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) != SPECIES_NONE) + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG, NULL) != SPECIES_EGG + && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG, NULL) != SPECIES_NONE) return i; } return 0; @@ -1550,7 +1550,7 @@ u8 GetLeadMonIndex(void) u16 ScriptGetPartyMonSpecies(void) { - return GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPECIES2, NULL); + return GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPECIES_OR_EGG, NULL); } // Removed for Emerald diff --git a/src/frontier_util.c b/src/frontier_util.c index 0fe2c94ea0..85e016a26b 100644 --- a/src/frontier_util.c +++ b/src/frontier_util.c @@ -1990,7 +1990,7 @@ static void CheckPartyIneligibility(void) numEligibleMons = 0; do { - u16 species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES2); + u16 species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES_OR_EGG); u16 heldItem = GetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM); u8 level = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL); u16 hp = GetMonData(&gPlayerParty[monId], MON_DATA_HP); diff --git a/src/graphics.c b/src/graphics.c index 61d0fdf757..e7a0cbe642 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -340,7 +340,7 @@ const u32 gBattleAnimSpriteGfx_BlackSmoke[] = INCBIN_U32("graphics/battle_anims/ const u32 gBattleAnimSpritePal_BlackSmoke[] = INCBIN_U32("graphics/battle_anims/sprites/black_smoke.gbapal.lz"); const u32 gBattleAnimSpriteGfx_BlackBall[] = INCBIN_U32("graphics/battle_anims/sprites/black_ball.4bpp.lz"); -const u32 gBattleAnimSpritePal_BlackBall[] = INCBIN_U32("graphics/battle_anims/sprites/black_ball.bin"); +const u32 gBattleAnimSpritePal_BlackBall[] = INCBIN_U32("graphics/battle_anims/sprites/black_ball.gbapal.lz"); const u32 gBattleAnimSpritePal_Glass[] = INCBIN_U32("graphics/battle_anims/sprites/glass.gbapal.lz"); const u32 gBattleAnimSpriteGfx_Glass[] = INCBIN_U32("graphics/battle_anims/sprites/glass.4bpp.lz"); @@ -576,7 +576,7 @@ const u16 gBattleAnimUnused_Unknown2[] = INCBIN_U16("graphics/battle_anims/unuse const u16 gBattleAnimUnused_Unknown3[] = INCBIN_U16("graphics/battle_anims/unused/unknown_3.bin"); const u32 gBattleAnimUnusedGfx_LineSketch2[] = INCBIN_U32("graphics/battle_anims/unused/line_sketch_2.8bpp.lz"); -const u16 gBattleAnimUnusedPal_LineSketch2[] = INCBIN_U16("graphics/battle_anims/unused/line_sketch_2_pal.bin"); +const u16 gBattleAnimUnusedPal_LineSketch2[] = INCBIN_U16("graphics/battle_anims/unused/line_sketch_2.gbapal.lz"); const u32 gBattleAnimUnusedTilemap_LineSketch2[] = INCBIN_U32("graphics/battle_anims/unused/line_sketch_2.bin.lz"); const u32 gBattleAnimSpriteGfx_BlueLines[] = INCBIN_U32("graphics/battle_anims/sprites/blue_lines.4bpp.lz"); @@ -1917,10 +1917,10 @@ const u32 gNamingScreenKeyboardSymbols_Tilemap[] = INCBIN_U32("graphics/naming_s const u16 gUnionRoomChat_Background_Pal[] = INCBIN_U16("graphics/union_room_chat/background.gbapal"); const u32 gUnionRoomChat_Background_Gfx[] = INCBIN_U32("graphics/union_room_chat/background.4bpp.lz"); const u32 gUnionRoomChat_Background_Tilemap[] = INCBIN_U32("graphics/union_room_chat/background.bin.lz"); -const u16 gUnionRoomChat_Window_Pal1[] = INCBIN_U16("graphics/union_room_chat/window_1.gbapal"); -const u16 gUnionRoomChat_Window_Pal2[] = INCBIN_U16("graphics/union_room_chat/window_2.gbapal"); -const u32 gUnionRoomChat_Border_Gfx[] = INCBIN_U32("graphics/union_room_chat/border.4bpp.lz"); -const u32 gUnionRoomChat_Border_Tilemap[] = INCBIN_U32("graphics/union_room_chat/border.bin.lz"); +const u16 gUnionRoomChat_InputText_Pal[] = INCBIN_U16("graphics/union_room_chat/input_text.gbapal"); +const u16 gUnionRoomChat_Keyboard_Pal[] = INCBIN_U16("graphics/union_room_chat/keyboard.gbapal"); +const u32 gUnionRoomChat_Keyboard_Gfx[] = INCBIN_U32("graphics/union_room_chat/keyboard.4bpp.lz"); +const u32 gUnionRoomChat_Keyboard_Tilemap[] = INCBIN_U32("graphics/union_room_chat/keyboard.bin.lz"); const u32 gUnionRoomChat_RButtonLabels[] = INCBIN_U32("graphics/union_room_chat/r_button_labels.4bpp.lz"); const u16 gTilesetPalettes_General[][16] = diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index 2be4132f5b..402db27a15 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -445,7 +445,7 @@ static void Task_Hof_InitMonData(u8 taskId) u8 nick[POKEMON_NAME_LENGTH + 2]; if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES)) { - sHofMonPtr->mon[i].species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + sHofMonPtr->mon[i].species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG); sHofMonPtr->mon[i].tid = GetMonData(&gPlayerParty[i], MON_DATA_OT_ID); sHofMonPtr->mon[i].personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY); sHofMonPtr->mon[i].lvl = GetMonData(&gPlayerParty[i], MON_DATA_LEVEL); diff --git a/src/menu_specialized.c b/src/menu_specialized.c index 5422087bfc..802d1aec32 100644 --- a/src/menu_specialized.c +++ b/src/menu_specialized.c @@ -1077,7 +1077,7 @@ void GetConditionMenuMonGfx(void *tilesDst, void *palDst, u16 boxId, u16 monId, if (partyId != numMons) { - u16 species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES2, NULL); + u16 species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES_OR_EGG, NULL); u32 trainerId = GetBoxOrPartyMonData(boxId, monId, MON_DATA_OT_ID, NULL); u32 personality = GetBoxOrPartyMonData(boxId, monId, MON_DATA_PERSONALITY, NULL); diff --git a/src/mystery_event_script.c b/src/mystery_event_script.c index d1b514a173..124ababa45 100644 --- a/src/mystery_event_script.c +++ b/src/mystery_event_script.c @@ -319,7 +319,7 @@ bool8 MEScrCmd_givepokemon(struct ScriptContext *ctx) void *mailPtr = (void *)(data + sizeof(struct Pokemon)); pokemon = *(struct Pokemon *)pokemonPtr; - species = GetMonData(&pokemon, MON_DATA_SPECIES2); + species = GetMonData(&pokemon, MON_DATA_SPECIES_OR_EGG); if (species == SPECIES_EGG) StringCopyN(gStringVar1, gText_EggNickname, POKEMON_NAME_LENGTH + 1); diff --git a/src/party_menu.c b/src/party_menu.c index 8debf9f3c7..9a04f4c503 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -2035,7 +2035,7 @@ static u8 CanTeachMove(struct Pokemon *mon, u16 move) { if (GetMonData(mon, MON_DATA_IS_EGG)) return CANNOT_LEARN_MOVE_IS_EGG; - else if (!CanLearnTeachableMove(GetMonData(mon, MON_DATA_SPECIES2), move)) + else if (!CanLearnTeachableMove(GetMonData(mon, MON_DATA_SPECIES_OR_EGG), move)) return CANNOT_LEARN_MOVE; else if (MonKnowsMove(mon, move) == TRUE) return ALREADY_KNOWS_MOVE; @@ -3584,11 +3584,11 @@ static void CursorCb_Store(u8 taskId) // Register mon for the Trading Board in Union Room static void CursorCb_Register(u8 taskId) { - u16 species2 = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES2); + u16 species2 = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES_OR_EGG); u16 species = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES); - u8 isEventLegal = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_EVENT_LEGAL); + u8 isModernFatefulEncounter = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_MODERN_FATEFUL_ENCOUNTER); - switch (CanRegisterMonForTradingBoard(*(struct RfuGameCompatibilityData *)GetHostRfuGameData(), species2, species, isEventLegal)) + switch (CanRegisterMonForTradingBoard(*(struct RfuGameCompatibilityData *)GetHostRfuGameData(), species2, species, isModernFatefulEncounter)) { case CANT_REGISTER_MON_NOW: StringExpandPlaceholders(gStringVar4, gText_PkmnCantBeTradedNow); @@ -3614,10 +3614,10 @@ static void CursorCb_Register(u8 taskId) static void CursorCb_Trade1(u8 taskId) { - u16 species2 = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES2); + u16 species2 = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES_OR_EGG); u16 species = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_SPECIES); - u8 isEventLegal = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_EVENT_LEGAL); - u32 stringId = GetUnionRoomTradeMessageId(*(struct RfuGameCompatibilityData *)GetHostRfuGameData(), gRfuPartnerCompatibilityData, species2, gUnionRoomOfferedSpecies, gUnionRoomRequestedMonType, species, isEventLegal); + u8 isModernFatefulEncounter = GetMonData(&gPlayerParty[gPartyMenu.slotId], MON_DATA_MODERN_FATEFUL_ENCOUNTER); + u32 stringId = GetUnionRoomTradeMessageId(*(struct RfuGameCompatibilityData *)GetHostRfuGameData(), gRfuPartnerCompatibilityData, species2, gUnionRoomOfferedSpecies, gUnionRoomRequestedMonType, species, isModernFatefulEncounter); if (stringId != UR_TRADE_MSG_NONE) { @@ -3923,7 +3923,7 @@ static void CreatePartyMonIconSprite(struct Pokemon *mon, struct PartyMenuBox *m { u16 species2; - species2 = GetMonData(mon, MON_DATA_SPECIES2); + species2 = GetMonData(mon, MON_DATA_SPECIES_OR_EGG); CreatePartyMonIconSpriteParameterized(species2, GetMonData(mon, MON_DATA_PERSONALITY), menuBox, 1); UpdatePartyMonHPBar(menuBox->monSpriteId, mon); } diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c index 9a7ce414d6..7b61eec478 100644 --- a/src/pokeblock_feed.c +++ b/src/pokeblock_feed.c @@ -725,14 +725,14 @@ static bool8 LoadMonAndSceneGfx(struct Pokemon *mon) { case 0: // Load mon gfx - species = GetMonData(mon, MON_DATA_SPECIES2); + species = GetMonData(mon, MON_DATA_SPECIES_OR_EGG); personality = GetMonData(mon, MON_DATA_PERSONALITY); HandleLoadSpecialPokePic(TRUE, gMonSpritesGfxPtr->sprites.ptr[B_POSITION_OPPONENT_LEFT], species, personality); sPokeblockFeed->loadGfxState++; break; case 1: // Load mon palette - species = GetMonData(mon, MON_DATA_SPECIES2); + species = GetMonData(mon, MON_DATA_SPECIES_OR_EGG); personality = GetMonData(mon, MON_DATA_PERSONALITY); trainerId = GetMonData(mon, MON_DATA_OT_ID); palette = GetMonSpritePalStructFromOtIdPersonality(species, trainerId, personality); @@ -907,7 +907,7 @@ static void Task_FadeOutPokeblockFeed(u8 taskId) static u8 CreateMonSprite(struct Pokemon *mon) { - u16 species = GetMonData(mon, MON_DATA_SPECIES2); + u16 species = GetMonData(mon, MON_DATA_SPECIES_OR_EGG); u8 spriteId = CreateSprite(&gMultiuseSpriteTemplate, MON_X, MON_Y, 2); sPokeblockFeed->species = species; diff --git a/src/pokemon.c b/src/pokemon.c index 71dcb5bcbc..79ccb616f1 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -3938,12 +3938,12 @@ void ConvertPokemonToBattleTowerPokemon(struct Pokemon *mon, struct BattleTowerP GetMonData(mon, MON_DATA_NICKNAME, dest->nickname); } -void CreateEventLegalMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId) +static void CreateEventMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFixedPersonality, u32 fixedPersonality, u8 otIdType, u32 fixedOtId) { - bool32 isEventLegal = TRUE; + bool32 isModernFatefulEncounter = TRUE; CreateMon(mon, species, level, fixedIV, hasFixedPersonality, fixedPersonality, otIdType, fixedOtId); - SetMonData(mon, MON_DATA_EVENT_LEGAL, &isEventLegal); + SetMonData(mon, MON_DATA_MODERN_FATEFUL_ENCOUNTER, &isModernFatefulEncounter); } // If FALSE, should load this game's Deoxys form. If TRUE, should load normal Deoxys form @@ -4033,14 +4033,14 @@ u16 GetUnionRoomTrainerClass(void) return gFacilityClassToTrainerClass[gUnionRoomFacilityClasses[arrId]]; } -void CreateEventLegalEnemyMon(void) +void CreateEnemyEventMon(void) { s32 species = gSpecialVar_0x8004; s32 level = gSpecialVar_0x8005; s32 itemId = gSpecialVar_0x8006; ZeroEnemyPartyMons(); - CreateEventLegalMon(&gEnemyParty[0], species, level, USE_RANDOM_IVS, FALSE, 0, OT_ID_PLAYER_ID, 0); + CreateEventMon(&gEnemyParty[0], species, level, USE_RANDOM_IVS, FALSE, 0, OT_ID_PLAYER_ID, 0); if (itemId) { u8 heldItem[2]; @@ -4939,10 +4939,10 @@ u32 GetBoxMonData(struct BoxPokemon *boxMon, s32 field, u8 *data) case MON_DATA_UNUSED_RIBBONS: retVal = substruct3->unusedRibbons; break; - case MON_DATA_EVENT_LEGAL: - retVal = substruct3->eventLegal; + case MON_DATA_MODERN_FATEFUL_ENCOUNTER: + retVal = substruct3->modernFatefulEncounter; break; - case MON_DATA_SPECIES2: + case MON_DATA_SPECIES_OR_EGG: retVal = substruct0->species; if (substruct0->species && (substruct3->isEgg || boxMon->isBadEgg)) retVal = SPECIES_EGG; @@ -5069,7 +5069,7 @@ void SetMonData(struct Pokemon *mon, s32 field, const void *dataArg) case MON_DATA_MAIL: SET8(mon->mail); break; - case MON_DATA_SPECIES2: + case MON_DATA_SPECIES_OR_EGG: break; default: SetBoxMonData(&mon->box, field, data); @@ -5323,8 +5323,8 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg) case MON_DATA_UNUSED_RIBBONS: SET8(substruct3->unusedRibbons); break; - case MON_DATA_EVENT_LEGAL: - SET8(substruct3->eventLegal); + case MON_DATA_MODERN_FATEFUL_ENCOUNTER: + SET8(substruct3->modernFatefulEncounter); break; case MON_DATA_IVS: { @@ -5446,9 +5446,9 @@ u8 GetMonsStateToDoubles(void) for (i = 0; i < gPlayerPartyCount; i++) { - if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) != SPECIES_EGG + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG, NULL) != SPECIES_EGG && GetMonData(&gPlayerParty[i], MON_DATA_HP, NULL) != 0 - && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL) != SPECIES_NONE) + && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG, NULL) != SPECIES_NONE) aliveCount++; } @@ -5462,7 +5462,7 @@ u8 GetMonsStateToDoubles_2(void) for (i = 0; i < PARTY_SIZE; i++) { - u32 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2, NULL); + u32 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG, NULL); if (species != SPECIES_EGG && species != SPECIES_NONE && GetMonData(&gPlayerParty[i], MON_DATA_HP, NULL) != 0) aliveCount++; @@ -7153,7 +7153,7 @@ void AdjustFriendship(struct Pokemon *mon, u8 event) if (ShouldSkipFriendshipChange()) return; - species = GetMonData(mon, MON_DATA_SPECIES2, 0); + species = GetMonData(mon, MON_DATA_SPECIES_OR_EGG, 0); heldItem = GetMonData(mon, MON_DATA_HELD_ITEM, 0); if (heldItem == ITEM_ENIGMA_BERRY_E_READER) @@ -7590,7 +7590,7 @@ u8 GetNumberOfRelearnableMoves(struct Pokemon *mon) u16 learnedMoves[MAX_MON_MOVES]; u16 moves[MAX_LEVEL_UP_MOVES]; u8 numMoves = 0; - u16 species = GetMonData(mon, MON_DATA_SPECIES2, 0); + u16 species = GetMonData(mon, MON_DATA_SPECIES_OR_EGG, 0); u8 level = GetMonData(mon, MON_DATA_LEVEL, 0); int i, j, k; @@ -7759,7 +7759,7 @@ static void Task_PlayMapChosenOrBattleBGM(u8 taskId) const u32 *GetMonFrontSpritePal(struct Pokemon *mon) { - u16 species = GetMonData(mon, MON_DATA_SPECIES2, 0); + u16 species = GetMonData(mon, MON_DATA_SPECIES_OR_EGG, 0); u32 otId = GetMonData(mon, MON_DATA_OT_ID, 0); u32 personality = GetMonData(mon, MON_DATA_PERSONALITY, 0); return GetMonSpritePalFromSpeciesAndPersonality(species, otId, personality); @@ -7791,7 +7791,7 @@ const u32 *GetMonSpritePalFromSpeciesAndPersonality(u16 species, u32 otId, u32 p const struct CompressedSpritePalette *GetMonSpritePalStruct(struct Pokemon *mon) { - u16 species = GetMonData(mon, MON_DATA_SPECIES2, 0); + u16 species = GetMonData(mon, MON_DATA_SPECIES_OR_EGG, 0); u32 otId = GetMonData(mon, MON_DATA_OT_ID, 0); u32 personality = GetMonData(mon, MON_DATA_PERSONALITY, 0); return GetMonSpritePalStructFromOtIdPersonality(species, otId, personality); @@ -8281,8 +8281,6 @@ static bool8 ShouldSkipFriendshipChange(void) #define ALLOC_FAIL_BUFFER (1 << 0) #define ALLOC_FAIL_STRUCT (1 << 1) #define GFX_MANAGER_ACTIVE 0xA3 // Arbitrary value -#define GFX_MANAGER_SPR_SIZE (MON_PIC_SIZE * 4) // Only Castform uses more than MON_PIC_SIZE, despite not displaying its forms. -#define GFX_MANAGER_NUM_FRAMES 4 // Only 2 frames are needed static void InitMonSpritesGfx_Battle(struct MonSpritesGfxManager* gfx) { @@ -8329,7 +8327,7 @@ struct MonSpritesGfxManager *CreateMonSpritesGfxManager(u8 managerId, u8 mode) case MON_SPR_GFX_MODE_FULL_PARTY: gfx->numSprites = PARTY_SIZE + 1; gfx->numSprites2 = PARTY_SIZE + 1; - gfx->numFrames = GFX_MANAGER_NUM_FRAMES; + gfx->numFrames = MAX_MON_PIC_FRAMES; gfx->dataSize = 1; gfx->mode = MON_SPR_GFX_MODE_FULL_PARTY; break; @@ -8338,14 +8336,14 @@ struct MonSpritesGfxManager *CreateMonSpritesGfxManager(u8 managerId, u8 mode) default: gfx->numSprites = MAX_BATTLERS_COUNT; gfx->numSprites2 = MAX_BATTLERS_COUNT; - gfx->numFrames = GFX_MANAGER_NUM_FRAMES; + gfx->numFrames = MAX_MON_PIC_FRAMES; gfx->dataSize = 1; gfx->mode = MON_SPR_GFX_MODE_NORMAL; break; } // Set up sprite / sprite pointer buffers - gfx->spriteBuffer = AllocZeroed(gfx->dataSize * GFX_MANAGER_SPR_SIZE * gfx->numSprites); + gfx->spriteBuffer = AllocZeroed(gfx->dataSize * MON_PIC_SIZE * MAX_MON_PIC_FRAMES * gfx->numSprites); gfx->spritePointers = AllocZeroed(gfx->numSprites * 32); // ? Only * 4 is necessary, perhaps they were thinking bits. if (gfx->spriteBuffer == NULL || gfx->spritePointers == NULL) { @@ -8354,7 +8352,7 @@ struct MonSpritesGfxManager *CreateMonSpritesGfxManager(u8 managerId, u8 mode) else { for (i = 0; i < gfx->numSprites; i++) - gfx->spritePointers[i] = gfx->spriteBuffer + (gfx->dataSize * GFX_MANAGER_SPR_SIZE * i); + gfx->spritePointers[i] = gfx->spriteBuffer + (gfx->dataSize * MON_PIC_SIZE * MAX_MON_PIC_FRAMES * i); } // Set up sprite structs diff --git a/src/pokemon_jump.c b/src/pokemon_jump.c index f7438f1395..aba3e9d31c 100755 --- a/src/pokemon_jump.c +++ b/src/pokemon_jump.c @@ -2536,7 +2536,7 @@ void IsPokemonJumpSpeciesInParty(void) { if (GetMonData(&gPlayerParty[i], MON_DATA_SANITY_HAS_SPECIES)) { - u16 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + u16 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG); if (IsSpeciesAllowedInPokemonJump(species)) { gSpecialVar_Result = TRUE; @@ -2896,7 +2896,7 @@ static void CreateJumpMonSprite(struct PokemonJumpGfx *jumpGfx, struct PokemonJu u8 spriteId; spriteTemplate = sSpriteTemplate_JumpMon; - buffer = Alloc(0x2000); + buffer = Alloc(MON_PIC_SIZE * MAX_MON_PIC_FRAMES); unusedBuffer = Alloc(MON_PIC_SIZE); if (multiplayerId == GetPokeJumpMultiplayerId()) subpriority = 3; diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index d83533d59e..7d9f71f55e 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -551,7 +551,7 @@ struct PokemonStorageSystemData u16 *displayMonTilePtr; struct Sprite *displayMonSprite; u16 displayMonPalBuffer[0x40]; - u8 tileBuffer[MON_PIC_SIZE * 4]; // 4x the size of a 'Mon sprite to account for Castform + u8 tileBuffer[MON_PIC_SIZE * MAX_MON_PIC_FRAMES]; u8 itemIconBuffer[0x800]; u8 wallpaperBgTilemapBuffer[0x1000]; u8 displayMenuTilemapBuffer[0x800]; @@ -4444,7 +4444,7 @@ static u8 GetMonIconPriorityByCursorPos(void) static void CreateMovingMonIcon(void) { u32 personality = GetMonData(&sStorage->movingMon, MON_DATA_PERSONALITY); - u16 species = GetMonData(&sStorage->movingMon, MON_DATA_SPECIES2); + u16 species = GetMonData(&sStorage->movingMon, MON_DATA_SPECIES_OR_EGG); u8 priority = GetMonIconPriorityByCursorPos(); sStorage->movingMonSprite = CreateMonIconSprite(species, personality, 0, 0, priority, 7); @@ -4466,7 +4466,7 @@ static void InitBoxMonSprites(u8 boxId) { for (j = 0; j < IN_BOX_COLUMNS; j++) { - species = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_SPECIES2); + species = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_SPECIES_OR_EGG); if (species != SPECIES_NONE) { personality = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_PERSONALITY); @@ -4494,7 +4494,7 @@ static void InitBoxMonSprites(u8 boxId) static void CreateBoxMonIconAtPos(u8 boxPosition) { - u16 species = GetCurrentBoxMonData(boxPosition, MON_DATA_SPECIES2); + u16 species = GetCurrentBoxMonData(boxPosition, MON_DATA_SPECIES_OR_EGG); if (species != SPECIES_NONE) { @@ -4728,7 +4728,7 @@ static void GetIncomingBoxMonData(u8 boxId) { for (j = 0; j < IN_BOX_COLUMNS; j++) { - sStorage->boxSpecies[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_SPECIES2); + sStorage->boxSpecies[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_SPECIES_OR_EGG); if (sStorage->boxSpecies[boxPosition] != SPECIES_NONE) sStorage->boxPersonalities[boxPosition] = GetBoxMonDataAt(boxId, boxPosition, MON_DATA_PERSONALITY); boxPosition++; @@ -4756,14 +4756,14 @@ static void SetBoxMonIconObjMode(u8 boxPosition, u8 objMode) static void CreatePartyMonsSprites(bool8 visible) { u16 i, count; - u16 species = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES2); + u16 species = GetMonData(&gPlayerParty[0], MON_DATA_SPECIES_OR_EGG); u32 personality = GetMonData(&gPlayerParty[0], MON_DATA_PERSONALITY); sStorage->partySprites[0] = CreateMonIconSprite(species, personality, 104, 64, 1, 12); count = 1; for (i = 1; i < PARTY_SIZE; i++) { - species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG); if (species != SPECIES_NONE) { personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY); @@ -6914,7 +6914,7 @@ static void SetDisplayMonData(void *pokemon, u8 mode) { struct Pokemon *mon = (struct Pokemon *)pokemon; - sStorage->displayMonSpecies = GetMonData(mon, MON_DATA_SPECIES2); + sStorage->displayMonSpecies = GetMonData(mon, MON_DATA_SPECIES_OR_EGG); if (sStorage->displayMonSpecies != SPECIES_NONE) { sanityIsBadEgg = GetMonData(mon, MON_DATA_SANITY_IS_BAD_EGG); @@ -6937,7 +6937,7 @@ static void SetDisplayMonData(void *pokemon, u8 mode) { struct BoxPokemon *boxMon = (struct BoxPokemon *)pokemon; - sStorage->displayMonSpecies = GetBoxMonData(pokemon, MON_DATA_SPECIES2); + sStorage->displayMonSpecies = GetBoxMonData(pokemon, MON_DATA_SPECIES_OR_EGG); if (sStorage->displayMonSpecies != SPECIES_NONE) { u32 otId = GetBoxMonData(boxMon, MON_DATA_OT_ID); @@ -8485,7 +8485,7 @@ static void MultiMove_DeselectRow(u8 row, u8 minColumn, u8 maxColumn) static void MultiMove_SetIconToBg(u8 x, u8 y) { u8 position = x + (IN_BOX_COLUMNS * y); - u16 species = GetCurrentBoxMonData(position, MON_DATA_SPECIES2); + u16 species = GetCurrentBoxMonData(position, MON_DATA_SPECIES_OR_EGG); u32 personality = GetCurrentBoxMonData(position, MON_DATA_PERSONALITY); if (species != SPECIES_NONE) @@ -8510,7 +8510,7 @@ static void MultiMove_SetIconToBg(u8 x, u8 y) static void MultiMove_ClearIconFromBg(u8 x, u8 y) { u8 position = x + (IN_BOX_COLUMNS * y); - u16 species = GetCurrentBoxMonData(position, MON_DATA_SPECIES2); + u16 species = GetCurrentBoxMonData(position, MON_DATA_SPECIES_OR_EGG); if (species != SPECIES_NONE) { diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index 2d42002adb..3313076262 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -1474,7 +1474,7 @@ static bool8 ExtractMonDataToSummaryStruct(struct Pokemon *mon) { case 0: sum->species = GetMonData(mon, MON_DATA_SPECIES); - sum->species2 = GetMonData(mon, MON_DATA_SPECIES2); + sum->species2 = GetMonData(mon, MON_DATA_SPECIES_OR_EGG); sum->exp = GetMonData(mon, MON_DATA_EXP); sum->level = GetMonData(mon, MON_DATA_LEVEL); sum->abilityNum = GetMonData(mon, MON_DATA_ABILITY_NUM); diff --git a/src/pokenav_conditions.c b/src/pokenav_conditions.c index 0477ebbf52..3c06f6c649 100644 --- a/src/pokenav_conditions.c +++ b/src/pokenav_conditions.c @@ -531,7 +531,7 @@ static void ConditionGraphDrawMonPic(s16 listId, u8 loadId) boxId = monListPtr->monData[listId].boxId; monId = monListPtr->monData[listId].monId; - species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES2, NULL); + species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES_OR_EGG, NULL); tid = GetBoxOrPartyMonData(boxId, monId, MON_DATA_OT_ID, NULL); personality = GetBoxOrPartyMonData(boxId, monId, MON_DATA_PERSONALITY, NULL); LoadSpecialPokePic(menu->monPicGfx[loadId], species, personality, TRUE); diff --git a/src/pokenav_match_call_gfx.c b/src/pokenav_match_call_gfx.c index 626e584b70..1747d3ef0b 100755 --- a/src/pokenav_match_call_gfx.c +++ b/src/pokenav_match_call_gfx.c @@ -49,7 +49,7 @@ struct Pokenav_MatchCallGfx u8 unusedTilemapBuffer[BG_SCREEN_SIZE]; u8 bgTilemapBuffer2[BG_SCREEN_SIZE]; u8 *trainerPicGfxPtr; - u8 trainerPicGfx[0x800]; + u8 trainerPicGfx[TRAINER_PIC_SIZE]; u8 trainerPicPal[0x20]; }; diff --git a/src/roulette.c b/src/roulette.c index 283cceebfe..06561f7988 100644 --- a/src/roulette.c +++ b/src/roulette.c @@ -1144,7 +1144,7 @@ static void InitRouletteTableData(void) for (i = 0; i < PARTY_SIZE; i++) { - switch (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2)) + switch (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG)) { case SPECIES_SHROOMISH: sRoulette->partySpeciesFlags |= HAS_SHROOMISH; diff --git a/src/scrcmd.c b/src/scrcmd.c index 7b51df9f92..3a5a17fa82 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -2225,21 +2225,21 @@ bool8 ScrCmd_lockfortrainer(struct ScriptContext *ctx) } } -// This command will set a Pokémon's eventLegal bit; there is no similar command to clear it. -bool8 ScrCmd_setmoneventlegal(struct ScriptContext *ctx) +// This command will set a Pokémon's modernFatefulEncounter bit; there is no similar command to clear it. +bool8 ScrCmd_setmonmodernfatefulencounter(struct ScriptContext *ctx) { - bool8 isEventLegal = TRUE; + bool8 isModernFatefulEncounter = TRUE; u16 partyIndex = VarGet(ScriptReadHalfword(ctx)); - SetMonData(&gPlayerParty[partyIndex], MON_DATA_EVENT_LEGAL, &isEventLegal); + SetMonData(&gPlayerParty[partyIndex], MON_DATA_MODERN_FATEFUL_ENCOUNTER, &isModernFatefulEncounter); return FALSE; } -bool8 ScrCmd_checkmoneventlegal(struct ScriptContext *ctx) +bool8 ScrCmd_checkmonmodernfatefulencounter(struct ScriptContext *ctx) { u16 partyIndex = VarGet(ScriptReadHalfword(ctx)); - gSpecialVar_Result = GetMonData(&gPlayerParty[partyIndex], MON_DATA_EVENT_LEGAL, NULL); + gSpecialVar_Result = GetMonData(&gPlayerParty[partyIndex], MON_DATA_MODERN_FATEFUL_ENCOUNTER, NULL); return FALSE; } diff --git a/src/script_pokemon_util.c b/src/script_pokemon_util.c index e33c8ffcad..15d5b2e5d2 100755 --- a/src/script_pokemon_util.c +++ b/src/script_pokemon_util.c @@ -128,7 +128,7 @@ static bool8 CheckPartyMonHasHeldItem(u16 item) for(i = 0; i < PARTY_SIZE; i++) { - u16 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + u16 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG); if (species != SPECIES_NONE && species != SPECIES_EGG && GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM) == item) return TRUE; } diff --git a/src/trade.c b/src/trade.c index 1f9e688863..b09cc5af73 100644 --- a/src/trade.c +++ b/src/trade.c @@ -564,7 +564,7 @@ static void CB2_CreateTradeMenu(void) for (i = 0; i < sTradeMenu->partyCounts[TRADE_PLAYER]; i++) { struct Pokemon *mon = &gPlayerParty[i]; - sTradeMenu->partySpriteIds[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2), + sTradeMenu->partySpriteIds[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES_OR_EGG), SpriteCB_MonIcon, (sTradeMonSpriteCoords[i][0] * 8) + 14, (sTradeMonSpriteCoords[i][1] * 8) - 12, @@ -575,7 +575,7 @@ static void CB2_CreateTradeMenu(void) for (i = 0; i < sTradeMenu->partyCounts[TRADE_PARTNER]; i++) { struct Pokemon *mon = &gEnemyParty[i]; - sTradeMenu->partySpriteIds[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + sTradeMenu->partySpriteIds[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES_OR_EGG, NULL), SpriteCB_MonIcon, (sTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, (sTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, @@ -753,7 +753,7 @@ static void CB2_ReturnToTradeMenu(void) for (i = 0; i < sTradeMenu->partyCounts[TRADE_PLAYER]; i++) { struct Pokemon *mon = &gPlayerParty[i]; - sTradeMenu->partySpriteIds[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + sTradeMenu->partySpriteIds[TRADE_PLAYER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES_OR_EGG, NULL), SpriteCB_MonIcon, (sTradeMonSpriteCoords[i][0] * 8) + 14, (sTradeMonSpriteCoords[i][1] * 8) - 12, @@ -764,7 +764,7 @@ static void CB2_ReturnToTradeMenu(void) for (i = 0; i < sTradeMenu->partyCounts[TRADE_PARTNER]; i++) { struct Pokemon *mon = &gEnemyParty[i]; - sTradeMenu->partySpriteIds[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES2, NULL), + sTradeMenu->partySpriteIds[TRADE_PARTNER][i] = CreateMonIcon(GetMonData(mon, MON_DATA_SPECIES_OR_EGG, NULL), SpriteCB_MonIcon, (sTradeMonSpriteCoords[i + PARTY_SIZE][0] * 8) + 14, (sTradeMonSpriteCoords[i + PARTY_SIZE][1] * 8) - 12, @@ -1573,7 +1573,7 @@ static u8 CheckValidityOfTradeMons(u8 *aliveMons, u8 playerPartyCount, u8 player // Partner cant trade illegitimate Deoxys or Mew if (partnerSpecies == SPECIES_DEOXYS || partnerSpecies == SPECIES_MEW) { - if (!GetMonData(&gEnemyParty[partnerMonIdx], MON_DATA_EVENT_LEGAL)) + if (!GetMonData(&gEnemyParty[partnerMonIdx], MON_DATA_MODERN_FATEFUL_ENCOUNTER)) return PARTNER_MON_INVALID; } @@ -2380,7 +2380,7 @@ static void SaveTradeGiftRibbons(void) { if (gSaveBlock1Ptr->giftRibbons[i] == 0 && sTradeMenu->giftRibbons[i] != 0) { - if (sTradeMenu->giftRibbons[i] < 64) + if (sTradeMenu->giftRibbons[i] < MAX_GIFT_RIBBON) gSaveBlock1Ptr->giftRibbons[i] = sTradeMenu->giftRibbons[i]; } } @@ -2395,7 +2395,7 @@ static u32 CanTradeSelectedMon(struct Pokemon *playerParty, int partyCount, int for (i = 0; i < partyCount; i++) { - species2[i] = GetMonData(&playerParty[i], MON_DATA_SPECIES2); + species2[i] = GetMonData(&playerParty[i], MON_DATA_SPECIES_OR_EGG); species[i] = GetMonData(&playerParty[i], MON_DATA_SPECIES); } @@ -2426,7 +2426,7 @@ static u32 CanTradeSelectedMon(struct Pokemon *playerParty, int partyCount, int if (species[monIdx] == SPECIES_DEOXYS || species[monIdx] == SPECIES_MEW) { - if (!GetMonData(&playerParty[monIdx], MON_DATA_EVENT_LEGAL)) + if (!GetMonData(&playerParty[monIdx], MON_DATA_MODERN_FATEFUL_ENCOUNTER)) return CANT_TRADE_INVALID_MON; } @@ -2495,17 +2495,17 @@ s32 GetGameProgressForLinkTrade(void) return TRADE_BOTH_PLAYERS_READY; } -static bool32 IsDeoxysOrMewUntradable(u16 species, bool8 isEventLegal) +static bool32 IsDeoxysOrMewUntradable(u16 species, bool8 isModernFatefulEncounter) { if (species == SPECIES_DEOXYS || species == SPECIES_MEW) { - if (!isEventLegal) + if (!isModernFatefulEncounter) return TRUE; } return FALSE; } -int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct RfuGameCompatibilityData partner, u16 playerSpecies2, u16 partnerSpecies, u8 requestedType, u16 playerSpecies, bool8 isEventLegal) +int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct RfuGameCompatibilityData partner, u16 playerSpecies2, u16 partnerSpecies, u8 requestedType, u16 playerSpecies, bool8 isModernFatefulEncounter) { bool8 playerHasNationalDex = player.hasNationalDex; bool8 playerCanLinkNationally = player.canLinkNationally; @@ -2524,7 +2524,7 @@ int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct Rf } // Cannot trade illegitimate Deoxys/Mew - if (IsDeoxysOrMewUntradable(playerSpecies, isEventLegal)) + if (IsDeoxysOrMewUntradable(playerSpecies, isModernFatefulEncounter)) return UR_TRADE_MSG_MON_CANT_BE_TRADED; // Can't trade specific species @@ -2571,11 +2571,11 @@ int GetUnionRoomTradeMessageId(struct RfuGameCompatibilityData player, struct Rf return UR_TRADE_MSG_NONE; } -int CanRegisterMonForTradingBoard(struct RfuGameCompatibilityData player, u16 species2, u16 species, bool8 isEventLegal) +int CanRegisterMonForTradingBoard(struct RfuGameCompatibilityData player, u16 species2, u16 species, bool8 isModernFatefulEncounter) { bool8 hasNationalDex = player.hasNationalDex; - if (IsDeoxysOrMewUntradable(species, isEventLegal)) + if (IsDeoxysOrMewUntradable(species, isModernFatefulEncounter)) return CANT_REGISTER_MON_NOW; // Can't trade specific species @@ -2605,7 +2605,7 @@ int CanSpinTradeMon(struct Pokemon *mon, u16 monIdx) // Make Eggs not count for numMonsLeft for (i = 0; i < gPlayerPartyCount; i++) { - speciesArray[i] = GetMonData(&mon[i], MON_DATA_SPECIES2); + speciesArray[i] = GetMonData(&mon[i], MON_DATA_SPECIES_OR_EGG); if (speciesArray[i] == SPECIES_EGG) speciesArray[i] = SPECIES_NONE; } @@ -2815,7 +2815,7 @@ static void LoadTradeMonPic(u8 whichParty, u8 state) switch (state) { case 0: - species = GetMonData(mon, MON_DATA_SPECIES2); + species = GetMonData(mon, MON_DATA_SPECIES_OR_EGG); personality = GetMonData(mon, MON_DATA_PERSONALITY); HandleLoadSpecialPokePic(TRUE, gMonSpritesGfxPtr->sprites.ptr[whichParty * 2 + B_POSITION_OPPONENT_LEFT], species, personality); diff --git a/src/trainer_pokemon_sprites.c b/src/trainer_pokemon_sprites.c index 7707e59cc1..14849c19e5 100644 --- a/src/trainer_pokemon_sprites.c +++ b/src/trainer_pokemon_sprites.c @@ -9,6 +9,12 @@ #include "pokemon.h" #include "constants/trainers.h" +#define PICS_COUNT 8 + +// Needs to be large enough to store either a decompressed pokemon pic or trainer pic +#define PIC_SPRITE_SIZE max(MON_PIC_SIZE, TRAINER_PIC_SIZE) +#define MAX_PIC_FRAMES max(MAX_MON_PIC_FRAMES, MAX_TRAINER_PIC_FRAMES) + struct PicData { u8 *frames; @@ -18,8 +24,6 @@ struct PicData u8 active; }; -#define PICS_COUNT 8 - static EWRAM_DATA struct SpriteTemplate sCreatingSpriteTemplate = {}; static EWRAM_DATA struct PicData sSpritePics[PICS_COUNT] = {}; @@ -138,11 +142,11 @@ static u16 CreatePicSprite(u16 species, u32 otId, u32 personality, bool8 isFront if (i == PICS_COUNT) return 0xFFFF; - framePics = Alloc(4 * 0x800); + framePics = Alloc(PIC_SPRITE_SIZE * MAX_PIC_FRAMES); if (!framePics) return 0xFFFF; - images = Alloc(4 * sizeof(struct SpriteFrameImage)); + images = Alloc(sizeof(struct SpriteFrameImage) * MAX_PIC_FRAMES); if (!images) { Free(framePics); @@ -153,10 +157,10 @@ static u16 CreatePicSprite(u16 species, u32 otId, u32 personality, bool8 isFront // debug trap? return 0xFFFF; } - for (j = 0; j < 4; j ++) + for (j = 0; j < MAX_PIC_FRAMES; j ++) { - images[j].data = framePics + 0x800 * j; - images[j].size = 0x800; + images[j].data = framePics + PIC_SPRITE_SIZE * j; + images[j].size = PIC_SPRITE_SIZE; } sCreatingSpriteTemplate.tileTag = TAG_NONE; sCreatingSpriteTemplate.oam = &sOamData_Normal; @@ -193,7 +197,7 @@ u16 CreateMonPicSprite_Affine(u16 species, u32 otId, u32 personality, u8 flags, if (i == PICS_COUNT) return 0xFFFF; - framePics = Alloc(4 * MON_PIC_SIZE); + framePics = Alloc(MON_PIC_SIZE * MAX_MON_PIC_FRAMES); if (!framePics) return 0xFFFF; @@ -206,7 +210,7 @@ u16 CreateMonPicSprite_Affine(u16 species, u32 otId, u32 personality, u8 flags, { type = flags; } - images = Alloc(4 * sizeof(struct SpriteFrameImage)); + images = Alloc(sizeof(struct SpriteFrameImage) * MAX_MON_PIC_FRAMES); if (!images) { Free(framePics); @@ -217,7 +221,7 @@ u16 CreateMonPicSprite_Affine(u16 species, u32 otId, u32 personality, u8 flags, // debug trap? return 0xFFFF; } - for (j = 0; j < 4; j ++) + for (j = 0; j < MAX_MON_PIC_FRAMES; j ++) { images[j].data = framePics + MON_PIC_SIZE * j; images[j].size = MON_PIC_SIZE; @@ -291,10 +295,10 @@ static u16 CreateTrainerCardSprite(u16 species, u32 otId, u32 personality, bool8 { u8 *framePics; - framePics = Alloc(4 * 0x800); + framePics = Alloc(TRAINER_PIC_SIZE * MAX_TRAINER_PIC_FRAMES); if (framePics && !DecompressPic(species, personality, isFrontPic, framePics, isTrainer)) { - BlitBitmapRectToWindow(windowId, framePics, 0, 0, 0x40, 0x40, destX, destY, 0x40, 0x40); + BlitBitmapRectToWindow(windowId, framePics, 0, 0, TRAINER_PIC_WIDTH, TRAINER_PIC_HEIGHT, destX, destY, TRAINER_PIC_WIDTH, TRAINER_PIC_HEIGHT); LoadPicPaletteBySlot(species, otId, personality, paletteSlot, isTrainer); Free(framePics); return 0; diff --git a/src/union_room.c b/src/union_room.c index 3739c59527..38f2b22fa8 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -4176,7 +4176,7 @@ static s32 IsRequestedTradeInPlayerParty(u32 type, u32 species) { for (i = 0; i < gPlayerPartyCount; i++) { - species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG); if (species == SPECIES_EGG) return UR_TRADE_MATCH; } @@ -4186,7 +4186,7 @@ static s32 IsRequestedTradeInPlayerParty(u32 type, u32 species) { for (i = 0; i < gPlayerPartyCount; i++) { - species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG); if (gSpeciesInfo[species].types[0] == type || gSpeciesInfo[species].types[1] == type) return UR_TRADE_MATCH; } @@ -4319,7 +4319,7 @@ static bool32 HasAtLeastTwoMonsOfLevel30OrLower(void) for (i = 0; i < gPlayerPartyCount; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_LEVEL) <= UNION_ROOM_MAX_LEVEL - && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) != SPECIES_EGG) + && GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG) count++; } @@ -4348,7 +4348,7 @@ void Script_ResetUnionRoomTrade(void) static bool32 RegisterTradeMonAndGetIsEgg(u32 monId, struct UnionRoomTrade *trade) { - trade->playerSpecies = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES2); + trade->playerSpecies = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES_OR_EGG); trade->playerLevel = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL); trade->playerPersonality = GetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY); if (trade->playerSpecies == SPECIES_EGG) @@ -4359,7 +4359,7 @@ static bool32 RegisterTradeMonAndGetIsEgg(u32 monId, struct UnionRoomTrade *trad static void RegisterTradeMon(u32 monId, struct UnionRoomTrade *trade) { - trade->species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES2); + trade->species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES_OR_EGG); trade->level = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL); trade->personality = GetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY); } @@ -4390,7 +4390,7 @@ static u32 GetPartyPositionOfRegisteredMon(struct UnionRoomTrade *trade, u8 mult cur_personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY); if (cur_personality != personality) continue; - cur_species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + cur_species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG); if (cur_species != species) continue; response = i; diff --git a/src/union_room_chat.c b/src/union_room_chat.c old mode 100755 new mode 100644 index 5d91e264a0..253e025689 --- a/src/union_room_chat.c +++ b/src/union_room_chat.c @@ -173,8 +173,7 @@ struct UnionRoomChatDisplay u8 bg1Buffer[BG_SCREEN_SIZE]; u8 bg3Buffer[BG_SCREEN_SIZE]; u8 bg2Buffer[BG_SCREEN_SIZE]; - u8 unk2128[0x20]; - u8 unk2148[0x20]; + u8 textEntryTiles[TILE_SIZE_4BPP * 2]; }; struct UnionRoomChatSprites @@ -254,11 +253,11 @@ static void FreeSprites(void); static void ResetGpuBgState(void); static void SetBgTilemapBuffers(void); static void ClearBg0(void); -static void LoadChatWindowBorderGfx(void); +static void LoadKeyboardWindowGfx(void); static void LoadChatWindowGfx(void); static void LoadChatUnkPalette(void); static void LoadChatMessagesWindow(void); -static void LoadKeyboardWindow(void); +static void DrawKeyboardWindow(void); static void LoadKeyboardSwapWindow(void); static void LoadTextEntryWindow(void); static void CreateKeyboardCursorSprite(void); @@ -527,8 +526,8 @@ static const u8 *const sUnionRoomKeyboardText[UNION_ROOM_KB_PAGE_COUNT - 1][UNIO } }; -static const u16 sUnk_Palette1[] = INCBIN_U16("graphics/union_room_chat/unk_palette1.gbapal"); -static const u16 sUnk_Palette2[] = INCBIN_U16("graphics/union_room_chat/unk_palette2.gbapal"); +static const u16 sUnusedPalette[] = INCBIN_U16("graphics/union_room_chat/unused.gbapal"); // Loaded but never apparently used +static const u16 sChatMessagesWindow_Pal[] = INCBIN_U16("graphics/union_room_chat/chat_messages_window.gbapal"); static const struct BgTemplate sBgTemplates[] = { { @@ -759,15 +758,15 @@ static const u32 sTextEntryArrowTiles[] = INCBIN_U32("graphics/union_room_chat/t static const u32 sRButtonGfxTiles[] = INCBIN_U32("graphics/union_room_chat/r_button.4bpp.lz"); static const struct CompressedSpriteSheet sSpriteSheets[] = { - {sKeyboardCursorTiles, 0x1000, 0}, - {sTextEntryArrowTiles, 0x0040, 1}, - {sTextEntryCursorTiles, 0x0040, 2}, - {sRButtonGfxTiles, 0x0080, 3}, - {gUnionRoomChat_RButtonLabels, 0x0400, 4} + {.data = sKeyboardCursorTiles, .size = 0x1000, .tag = GFXTAG_KEYBOARD_CURSOR}, + {.data = sTextEntryArrowTiles, .size = 0x0040, .tag = GFXTAG_TEXT_ENTRY_ARROW}, + {.data = sTextEntryCursorTiles, .size = 0x0040, .tag = GFXTAG_TEXT_ENTRY_CURSOR}, + {.data = sRButtonGfxTiles, .size = 0x0080, .tag = GFXTAG_RBUTTON_ICON}, + {.data = gUnionRoomChat_RButtonLabels, .size = 0x0400, .tag = GFXTAG_RBUTTON_LABELS} }; static const struct SpritePalette sSpritePalette = { - sUnionRoomChatInterfacePal, 0 + .data = sUnionRoomChatInterfacePal, .tag = PALTAG_INTERFACE }; static const struct OamData sOam_KeyboardCursor = { @@ -970,7 +969,7 @@ static void CB2_LoadInterface(void) sChat->handleInputTask = CreateTask(Task_HandlePlayerInput, 8); sChat->receiveMessagesTask = CreateTask(Task_ReceiveChatMessage, 7); LoadWirelessStatusIndicatorSpriteGfx(); - CreateWirelessStatusIndicatorSprite(232, 150); + CreateWirelessStatusIndicatorSprite(DISPLAY_WIDTH - 8, DISPLAY_HEIGHT - 10); } break; } @@ -1759,7 +1758,7 @@ static void RegisterTextAtRow(void) static void ResetMessageEntryBuffer(void) { sChat->messageEntryBuffer[0] = EOS; - sChat->lastBufferCursorPos = 15; + sChat->lastBufferCursorPos = MAX_MESSAGE_LENGTH; sChat->bufferCursorPos = 0; } @@ -2063,10 +2062,10 @@ static void Task_ReceiveChatMessage(u8 taskId) tState = 3; // fall through case 3: - for (; tI < 5 && ((tBlockReceivedStatus >> tI) & 1) == 0; tI++) + for (; tI < MAX_RFU_PLAYERS && ((tBlockReceivedStatus >> tI) & 1) == 0; tI++) ; - if (tI == 5) + if (tI == MAX_RFU_PLAYERS) { tState = 1; return; @@ -2254,7 +2253,7 @@ static bool32 Display_LoadGfx(u8 *state) ClearBg0(); break; case 2: - LoadChatWindowBorderGfx(); + LoadKeyboardWindowGfx(); break; case 3: LoadChatWindowGfx(); @@ -2264,7 +2263,7 @@ static bool32 Display_LoadGfx(u8 *state) break; case 5: LoadChatMessagesWindow(); - LoadKeyboardWindow(); + DrawKeyboardWindow(); LoadKeyboardSwapWindow(); LoadTextEntryWindow(); break; @@ -3063,12 +3062,12 @@ static void ClearBg0(void) CopyBgTilemapBufferToVram(0); } -static void LoadChatWindowBorderGfx(void) +static void LoadKeyboardWindowGfx(void) { - LoadPalette(gUnionRoomChat_Window_Pal2, BG_PLTT_ID(7), PLTT_SIZE_4BPP); - LoadPalette(gUnionRoomChat_Window_Pal1, BG_PLTT_ID(12), PLTT_SIZE_4BPP); - DecompressAndCopyTileDataToVram(1, gUnionRoomChat_Border_Gfx, 0, 0, 0); - CopyToBgTilemapBuffer(1, gUnionRoomChat_Border_Tilemap, 0, 0); + LoadPalette(gUnionRoomChat_Keyboard_Pal, BG_PLTT_ID(7), PLTT_SIZE_4BPP); + LoadPalette(gUnionRoomChat_InputText_Pal, BG_PLTT_ID(12), PLTT_SIZE_4BPP); + DecompressAndCopyTileDataToVram(1, gUnionRoomChat_Keyboard_Gfx, 0, 0, 0); + CopyToBgTilemapBuffer(1, gUnionRoomChat_Keyboard_Tilemap, 0, 0); CopyBgTilemapBufferToVram(1); } @@ -3080,8 +3079,12 @@ static void LoadChatWindowGfx(void) ptr = DecompressAndCopyTileDataToVram(2, gUnionRoomChat_Background_Gfx, 0, 0, 0); if (ptr) { - CpuFastCopy(&ptr[0x220], sDisplay->unk2128, sizeof(sDisplay->unk2128)); - CpuFastCopy(&ptr[0x420], sDisplay->unk2148, sizeof(sDisplay->unk2148)); + // The below is nonsense. Tiles 0x11 and 0x21 of the background tileset are + // the second half of "OK" and the "T" in "START" in the instructions header. + // They're later blitted onto the text entry window, then immediately cleared. + // The window has a different palette as well, so the tiles would appear mostly black anyway. + CpuFastCopy(&ptr[0x11 * TILE_SIZE_4BPP], &sDisplay->textEntryTiles[TILE_SIZE_4BPP * 0], TILE_SIZE_4BPP); + CpuFastCopy(&ptr[0x21 * TILE_SIZE_4BPP], &sDisplay->textEntryTiles[TILE_SIZE_4BPP * 1], TILE_SIZE_4BPP); } CopyToBgTilemapBuffer(2, gUnionRoomChat_Background_Tilemap, 0, 0); @@ -3090,19 +3093,19 @@ static void LoadChatWindowGfx(void) static void LoadChatUnkPalette(void) { - LoadPalette(sUnk_Palette1, BG_PLTT_ID(8), sizeof(sUnk_Palette1)); - RequestDma3Fill(0, (void *)BG_CHAR_ADDR(1) + 0x20, 0x20, 1); + LoadPalette(sUnusedPalette, BG_PLTT_ID(8), sizeof(sUnusedPalette)); + RequestDma3Fill(0, (void *)BG_CHAR_ADDR(1) + TILE_SIZE_4BPP, TILE_SIZE_4BPP, 1); } static void LoadChatMessagesWindow(void) { - LoadPalette(sUnk_Palette2, BG_PLTT_ID(15), sizeof(sUnk_Palette2)); + LoadPalette(sChatMessagesWindow_Pal, BG_PLTT_ID(15), sizeof(sChatMessagesWindow_Pal)); PutWindowTilemap(WIN_CHAT_HISTORY); FillWindowPixelBuffer(WIN_CHAT_HISTORY, PIXEL_FILL(1)); CopyWindowToVram(WIN_CHAT_HISTORY, COPYWIN_FULL); } -static void LoadKeyboardWindow(void) +static void DrawKeyboardWindow(void) { PutWindowTilemap(WIN_KEYBOARD); PrintCurrentKeyboardPage(); @@ -3116,8 +3119,9 @@ static void LoadTextEntryWindow(void) unused[0] = 0; unused[1] = 0xFF; + // Pointless, cleared below. The tiles are nonsense anyway, see LoadChatWindowGfx. for (i = 0; i < MAX_MESSAGE_LENGTH; i++) - BlitBitmapToWindow(WIN_TEXT_ENTRY, sDisplay->unk2128, i * 8, 0, 8, 16); + BlitBitmapToWindow(WIN_TEXT_ENTRY, sDisplay->textEntryTiles, i * 8, 0, 8, 16); FillWindowPixelBuffer(WIN_TEXT_ENTRY, PIXEL_FILL(0)); PutWindowTilemap(WIN_TEXT_ENTRY); @@ -3129,7 +3133,7 @@ static void LoadKeyboardSwapWindow(void) FillWindowPixelBuffer(WIN_SWAP_MENU, PIXEL_FILL(1)); LoadUserWindowBorderGfx(WIN_SWAP_MENU, 1, BG_PLTT_ID(13)); LoadUserWindowBorderGfx_(WIN_SWAP_MENU, 0xA, BG_PLTT_ID(2)); - LoadPalette(gStandardMenuPalette, BG_PLTT_ID(14), PLTT_SIZE_4BPP); + LoadPalette(gStandardMenuPalette, BG_PLTT_ID(14), PLTT_SIZE_4BPP); } static void InitScanlineEffect(void) diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index be6fc89349..b64ac4152b 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -88,7 +88,7 @@ struct UsePokeblockMenu { u32 unused; u16 partyPalettes[PARTY_SIZE][0x40]; - u8 partySheets[NUM_SELECTIONS_LOADED][0x2000]; + u8 partySheets[NUM_SELECTIONS_LOADED][MON_PIC_SIZE * MAX_MON_PIC_FRAMES]; u8 unusedBuffer[0x1000]; u8 tilemapBuffer[BG_SCREEN_SIZE + 2]; u8 selectionIconSpriteIds[PARTY_SIZE + 1]; diff --git a/tools/mapjson/mapjson.cpp b/tools/mapjson/mapjson.cpp index dc8b9080a5..754154efb7 100644 --- a/tools/mapjson/mapjson.cpp +++ b/tools/mapjson/mapjson.cpp @@ -29,6 +29,7 @@ using json11::Json; #include "mapjson.h" +string version; string read_text_file(string filepath) { ifstream in_file(filepath); @@ -61,7 +62,7 @@ void write_text_file(string filepath, string text) { } -string json_to_string(const Json &data, const string &field = "") { +string json_to_string(const Json &data, const string &field = "", bool silent = false) { const Json value = !field.empty() ? data[field] : data; string output = ""; switch (value.type()) { @@ -75,12 +76,14 @@ string json_to_string(const Json &data, const string &field = "") { output = value.bool_value() ? "TRUE" : "FALSE"; break; default:{ - string s = !field.empty() ? ("Value for '" + field + "'") : "JSON field"; - FATAL_ERROR("%s is unexpected type; expected string, number, or bool.\n", s.c_str()); + if (!silent) { + string s = !field.empty() ? ("Value for '" + field + "'") : "JSON field"; + FATAL_ERROR("%s is unexpected type; expected string, number, or bool.\n", s.c_str()); + } } } - if (output.empty()){ + if (!silent && output.empty()) { string s = !field.empty() ? ("Value for '" + field + "'") : "JSON field"; FATAL_ERROR("%s cannot be empty.\n", s.c_str()); } @@ -88,14 +91,14 @@ string json_to_string(const Json &data, const string &field = "") { return output; } -string generate_map_header_text(Json map_data, Json layouts_data, string version) { +string generate_map_header_text(Json map_data, Json layouts_data) { string map_layout_id = json_to_string(map_data, "layout"); vector matched; - for (auto &field : layouts_data["layouts"].array_items()) { - if (map_layout_id == json_to_string(field, "id")) - matched.push_back(field); + for (auto &layout : layouts_data["layouts"].array_items()) { + if (map_layout_id == json_to_string(layout, "id", true)) + matched.push_back(layout); } if (matched.size() != 1) @@ -123,28 +126,33 @@ string generate_map_header_text(Json map_data, Json layouts_data, string version text << "\t.4byte " << mapName << "_MapScripts\n"; if (map_data.object_items().find("connections") != map_data.object_items().end() - && map_data["connections"].array_items().size() > 0) + && map_data["connections"].array_items().size() > 0 && json_to_string(map_data, "connections_no_include", true) != "TRUE") text << "\t.4byte " << mapName << "_MapConnections\n"; else - text << "\t.4byte 0x0\n"; + text << "\t.4byte NULL\n"; text << "\t.2byte " << json_to_string(map_data, "music") << "\n" << "\t.2byte " << json_to_string(layout, "id") << "\n" << "\t.byte " << json_to_string(map_data, "region_map_section") << "\n" << "\t.byte " << json_to_string(map_data, "requires_flash") << "\n" << "\t.byte " << json_to_string(map_data, "weather") << "\n" - << "\t.byte " << json_to_string(map_data, "map_type") << "\n" - << "\t.2byte 0\n"; + << "\t.byte " << json_to_string(map_data, "map_type") << "\n"; + + if (version != "firered") + text << "\t.2byte 0\n"; if (version == "ruby") text << "\t.byte " << json_to_string(map_data, "show_map_name") << "\n"; - else if (version == "emerald") + else if (version == "emerald" || version == "firered") text << "\tmap_header_flags " << "allow_cycling=" << json_to_string(map_data, "allow_cycling") << ", " << "allow_escaping=" << json_to_string(map_data, "allow_escaping") << ", " << "allow_running=" << json_to_string(map_data, "allow_running") << ", " << "show_map_name=" << json_to_string(map_data, "show_map_name") << "\n"; + if (version == "firered") + text << "\t.byte " << json_to_string(map_data, "floor_number") << "\n"; + text << "\t.byte " << json_to_string(map_data, "battle_scene") << "\n\n"; return text.str(); @@ -193,22 +201,36 @@ string generate_map_events_text(Json map_data) { text << objects_label << ":\n"; for (unsigned int i = 0; i < map_data["object_events"].array_items().size(); i++) { auto obj_event = map_data["object_events"].array_items()[i]; - text << "\tobject_event " << i + 1 << ", " - << json_to_string(obj_event, "graphics_id") << ", 0, " - << json_to_string(obj_event, "x") << ", " - << json_to_string(obj_event, "y") << ", " - << json_to_string(obj_event, "elevation") << ", " - << json_to_string(obj_event, "movement_type") << ", " - << json_to_string(obj_event, "movement_range_x") << ", " - << json_to_string(obj_event, "movement_range_y") << ", " - << json_to_string(obj_event, "trainer_type") << ", " - << json_to_string(obj_event, "trainer_sight_or_berry_tree_id") << ", " - << json_to_string(obj_event, "script") << ", " - << json_to_string(obj_event, "flag") << "\n"; + string type = json_to_string(obj_event, "type", true); + + // If no type field is present, assume it's a regular object event. + if (type == "" || type == "object") { + text << "\tobject_event " << i + 1 << ", " + << json_to_string(obj_event, "graphics_id") << ", " + << json_to_string(obj_event, "x") << ", " + << json_to_string(obj_event, "y") << ", " + << json_to_string(obj_event, "elevation") << ", " + << json_to_string(obj_event, "movement_type") << ", " + << json_to_string(obj_event, "movement_range_x") << ", " + << json_to_string(obj_event, "movement_range_y") << ", " + << json_to_string(obj_event, "trainer_type") << ", " + << json_to_string(obj_event, "trainer_sight_or_berry_tree_id") << ", " + << json_to_string(obj_event, "script") << ", " + << json_to_string(obj_event, "flag") << "\n"; + } else if (type == "clone") { + text << "\tclone_event " << i + 1 << ", " + << json_to_string(obj_event, "graphics_id") << ", " + << json_to_string(obj_event, "x") << ", " + << json_to_string(obj_event, "y") << ", " + << json_to_string(obj_event, "target_local_id") << ", " + << json_to_string(obj_event, "target_map") << "\n"; + } else { + FATAL_ERROR("Unknown object event type '%s'. Expected 'object' or 'clone'.\n", type.c_str()); + } } text << "\n"; } else { - objects_label = "0x0"; + objects_label = "NULL"; } if (map_data["warp_events"].array_items().size() > 0) { @@ -224,14 +246,15 @@ string generate_map_events_text(Json map_data) { } text << "\n"; } else { - warps_label = "0x0"; + warps_label = "NULL"; } if (map_data["coord_events"].array_items().size() > 0) { coords_label = mapName + "_MapCoordEvents"; text << coords_label << ":\n"; for (auto &coord_event : map_data["coord_events"].array_items()) { - if (json_to_string(coord_event, "type") == "trigger") { + string type = json_to_string(coord_event, "type"); + if (type == "trigger") { text << "\tcoord_event " << json_to_string(coord_event, "x") << ", " << json_to_string(coord_event, "y") << ", " @@ -240,24 +263,27 @@ string generate_map_events_text(Json map_data) { << json_to_string(coord_event, "var_value") << ", " << json_to_string(coord_event, "script") << "\n"; } - else if (coord_event["type"] == "weather") { + else if (type == "weather") { text << "\tcoord_weather_event " << json_to_string(coord_event, "x") << ", " << json_to_string(coord_event, "y") << ", " << json_to_string(coord_event, "elevation") << ", " << json_to_string(coord_event, "weather") << "\n"; + } else { + FATAL_ERROR("Unknown coord event type '%s'. Expected 'trigger' or 'weather'.\n", type.c_str()); } } text << "\n"; } else { - coords_label = "0x0"; + coords_label = "NULL"; } if (map_data["bg_events"].array_items().size() > 0) { bgs_label = mapName + "_MapBGEvents"; text << bgs_label << ":\n"; for (auto &bg_event : map_data["bg_events"].array_items()) { - if (bg_event["type"] == "sign") { + string type = json_to_string(bg_event, "type"); + if (type == "sign") { text << "\tbg_sign_event " << json_to_string(bg_event, "x") << ", " << json_to_string(bg_event, "y") << ", " @@ -265,25 +291,33 @@ string generate_map_events_text(Json map_data) { << json_to_string(bg_event, "player_facing_dir") << ", " << json_to_string(bg_event, "script") << "\n"; } - else if (bg_event["type"] == "hidden_item") { + else if (type == "hidden_item") { text << "\tbg_hidden_item_event " << json_to_string(bg_event, "x") << ", " << json_to_string(bg_event, "y") << ", " << json_to_string(bg_event, "elevation") << ", " << json_to_string(bg_event, "item") << ", " - << json_to_string(bg_event, "flag") << "\n"; + << json_to_string(bg_event, "flag"); + if (version == "firered") { + text << ", " + << json_to_string(bg_event, "quantity") << ", " + << json_to_string(bg_event, "underfoot"); + } + text << "\n"; } - else if (bg_event["type"] == "secret_base") { + else if (type == "secret_base") { text << "\tbg_secret_base_event " << json_to_string(bg_event, "x") << ", " << json_to_string(bg_event, "y") << ", " << json_to_string(bg_event, "elevation") << ", " << json_to_string(bg_event, "secret_base_id") << "\n"; + } else { + FATAL_ERROR("Unknown bg event type '%s'. Expected 'sign', 'hidden_item', or 'secret_base'.\n", type.c_str()); } } text << "\n"; } else { - bgs_label = "0x0"; + bgs_label = "NULL"; } text << mapName << "_MapEvents::\n" @@ -299,7 +333,7 @@ string get_directory_name(string filename) { return filename.substr(0, dir_pos + 1); } -void process_map(string map_filepath, string layouts_filepath, string version) { +void process_map(string map_filepath, string layouts_filepath) { string mapdata_err, layouts_err; string mapdata_json_text = read_text_file(map_filepath); @@ -313,7 +347,7 @@ void process_map(string map_filepath, string layouts_filepath, string version) { if (layouts_data == Json()) FATAL_ERROR("%s\n", layouts_err.c_str()); - string header_text = generate_map_header_text(map_data, layouts_data, version); + string header_text = generate_map_header_text(map_data, layouts_data); string events_text = generate_map_events_text(map_data); string connections_text = generate_map_connections_text(map_data); @@ -498,6 +532,7 @@ string generate_layout_headers_text(Json layouts_data) { text << "@\n@ DO NOT MODIFY THIS FILE! It is auto-generated from data/layouts/layouts.json\n@\n\n"; for (auto &layout : layouts_data["layouts"].array_items()) { + if (layout == Json::object()) continue; string layoutName = json_to_string(layout, "name"); string border_label = layoutName + "_Border"; string blockdata_label = layoutName + "_Blockdata"; @@ -512,7 +547,13 @@ string generate_layout_headers_text(Json layouts_data) { << "\t.4byte " << border_label << "\n" << "\t.4byte " << blockdata_label << "\n" << "\t.4byte " << json_to_string(layout, "primary_tileset") << "\n" - << "\t.4byte " << json_to_string(layout, "secondary_tileset") << "\n\n"; + << "\t.4byte " << json_to_string(layout, "secondary_tileset") << "\n"; + if (version == "firered") { + text << "\t.byte " << json_to_string(layout, "border_width") << "\n" + << "\t.byte " << json_to_string(layout, "border_height") << "\n" + << "\t.2byte 0\n"; + } + text << "\n"; } return text.str(); @@ -526,8 +567,11 @@ string generate_layouts_table_text(Json layouts_data) { text << "\t.align 2\n" << json_to_string(layouts_data, "layouts_table_label") << "::\n"; - for (auto &layout : layouts_data["layouts"].array_items()) - text << "\t.4byte " << json_to_string(layout, "name") << "\n"; + for (auto &layout : layouts_data["layouts"].array_items()) { + string layout_name = json_to_string(layout, "name", true); + if (layout_name.empty()) layout_name = "NULL"; + text << "\t.4byte " << layout_name << "\n"; + } return text.str(); } @@ -540,9 +584,12 @@ string generate_layouts_constants_text(Json layouts_data) { text << "//\n// DO NOT MODIFY THIS FILE! It is auto-generated from data/layouts/layouts.json\n//\n\n"; - int i = 0; - for (auto &layout : layouts_data["layouts"].array_items()) - text << "#define " << json_to_string(layout, "id") << " " << ++i << "\n"; + int i = 1; + for (auto &layout : layouts_data["layouts"].array_items()) { + if (layout != Json::object()) + text << "#define " << json_to_string(layout, "id") << " " << i << "\n"; + i++; + } text << "\n#endif // GUARD_CONSTANTS_LAYOUTS_H\n"; @@ -573,9 +620,9 @@ int main(int argc, char *argv[]) { FATAL_ERROR("USAGE: mapjson [options]\n"); char *version_arg = argv[2]; - string version(version_arg); - if (version != "emerald" && version != "ruby") - FATAL_ERROR("ERROR: must be 'emerald' or 'ruby'.\n"); + version = string(version_arg); + if (version != "emerald" && version != "ruby" && version != "firered") + FATAL_ERROR("ERROR: must be 'emerald', 'firered', or 'ruby'.\n"); char *mode_arg = argv[1]; string mode(mode_arg); @@ -589,7 +636,7 @@ int main(int argc, char *argv[]) { string filepath(argv[3]); string layouts_filepath(argv[4]); - process_map(filepath, layouts_filepath, version); + process_map(filepath, layouts_filepath); } else if (mode == "groups") { if (argc != 4) diff --git a/tools/preproc/asm_file.cpp b/tools/preproc/asm_file.cpp index af16e232d3..04a7410e00 100644 --- a/tools/preproc/asm_file.cpp +++ b/tools/preproc/asm_file.cpp @@ -41,6 +41,8 @@ AsmFile::AsmFile(std::string filename) : m_filename(filename) if (m_size < 0) FATAL_ERROR("File size of \"%s\" is less than zero.\n", filename.c_str()); + else if (m_size == 0) + return; // Empty file m_buffer = new char[m_size + 1]; @@ -73,7 +75,7 @@ AsmFile::AsmFile(AsmFile&& other) : m_filename(std::move(other.m_filename)) AsmFile::~AsmFile() { - delete[] m_buffer; + if (m_size > 0) delete[] m_buffer; } // Removes comments to simplify further processing. diff --git a/tools/scaninc/asm_file.cpp b/tools/scaninc/asm_file.cpp index 109e604a22..d2cc624ee5 100644 --- a/tools/scaninc/asm_file.cpp +++ b/tools/scaninc/asm_file.cpp @@ -36,6 +36,11 @@ AsmFile::AsmFile(std::string path) m_size = std::ftell(fp); + if (m_size < 0) + FATAL_ERROR("File size of \"%s\" is less than zero.\n", path.c_str()); + else if (m_size == 0) + return; // Empty file + m_buffer = new char[m_size]; std::rewind(fp); @@ -51,7 +56,7 @@ AsmFile::AsmFile(std::string path) AsmFile::~AsmFile() { - delete[] m_buffer; + if (m_size > 0) delete[] m_buffer; } IncDirectiveType AsmFile::ReadUntilIncDirective(std::string &path)