diff --git a/data/maps/BattleFrontier_BattleDomeBattleRoom/scripts.inc b/data/maps/BattleFrontier_BattleDomeBattleRoom/scripts.inc index b01d5314b..f9cc466a2 100644 --- a/data/maps/BattleFrontier_BattleDomeBattleRoom/scripts.inc +++ b/data/maps/BattleFrontier_BattleDomeBattleRoom/scripts.inc @@ -563,7 +563,7 @@ BattleFrontier_BattleDomeBattleRoom_EventScript_AddSemifinalAudience:: @ 824C594 createvobject OBJ_EVENT_GFX_HEX_MANIAC, 28, 5, 2, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_SCHOOL_KID_M, 29, 5, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_MART_EMPLOYEE, 30, 6, 2, 3, DIR_SOUTH - createvobject OBJ_EVENT_GFX_WOMAN_5, 31, 8, 2, 3, 1 + createvobject OBJ_EVENT_GFX_WOMAN_5, 31, 8, 2, 3, DIR_SOUTH return BattleFrontier_BattleDomeBattleRoom_EventScript_AddFinalAudience:: @ 824C652 diff --git a/data/maps/BattleFrontier_BattleTowerLobby/scripts.inc b/data/maps/BattleFrontier_BattleTowerLobby/scripts.inc index 465b04f78..5bc18e000 100644 --- a/data/maps/BattleFrontier_BattleTowerLobby/scripts.inc +++ b/data/maps/BattleFrontier_BattleTowerLobby/scripts.inc @@ -3,6 +3,8 @@ .set LOCALID_ATTENDANT_MULTIS, 8 .set LOCALID_ATTENDANT_LINK_MULTIS, 9 +@ Note: LOCALID_BATTLE_TOWER_LOBBY_REPORTER is a local id for this map used elsewhere. It's defined in event_objects.h + BattleFrontier_BattleTowerLobby_MapScripts:: @ 823E67B map_script MAP_SCRIPT_ON_RESUME, BattleFrontier_BattleTowerLobby_OnResume map_script MAP_SCRIPT_ON_TRANSITION, BattleFrontier_BattleTowerLobby_OnTransition diff --git a/data/maps/BirthIsland_Exterior/scripts.inc b/data/maps/BirthIsland_Exterior/scripts.inc index 5871709ac..58a74f8c4 100644 --- a/data/maps/BirthIsland_Exterior/scripts.inc +++ b/data/maps/BirthIsland_Exterior/scripts.inc @@ -1,6 +1,7 @@ -.set LOCALID_DEOXYS_ROCK, 1 .set LOCALID_DEOXYS, 2 +@ Note: LOCALID_BIRTH_ISLAND_EXTERIOR_ROCK is a local id for this map used elsewhere. It's defined in event_objects.h + BirthIsland_Exterior_MapScripts:: @ 8267F15 map_script MAP_SCRIPT_ON_TRANSITION, BirthIsland_Exterior_OnTransition map_script MAP_SCRIPT_ON_RESUME, BirthIsland_Exterior_OnResume @@ -68,9 +69,9 @@ BirthIsland_Exterior_EventScript_NotSolved3:: @ 8267FBF BirthIsland_Exterior_EventScript_Deoxys:: @ 8267FC1 waitse - setfieldeffectargument 0, LOCALID_DEOXYS_ROCK - setfieldeffectargument 1, 58 - setfieldeffectargument 2, 26 + setfieldeffectargument 0, LOCALID_BIRTH_ISLAND_EXTERIOR_ROCK + setfieldeffectargument 1, MAP_NUM(BIRTH_ISLAND_EXTERIOR) + setfieldeffectargument 2, MAP_GROUP(BIRTH_ISLAND_EXTERIOR) dofieldeffect FLDEFF_DESTROY_DEOXYS_ROCK playbgm MUS_RG_ENCOUNTER_DEOXYS, FALSE waitfieldeffect FLDEFF_DESTROY_DEOXYS_ROCK diff --git a/data/maps/FarawayIsland_Interior/scripts.inc b/data/maps/FarawayIsland_Interior/scripts.inc index 108bc12e6..59a90e357 100644 --- a/data/maps/FarawayIsland_Interior/scripts.inc +++ b/data/maps/FarawayIsland_Interior/scripts.inc @@ -1,4 +1,4 @@ -.set LOCALID_MEW, 1 +@ Note: LOCALID_FARAWAY_ISLAND_MEW is a local id for this map used elsewhere. It's defined in event_objects.h FarawayIsland_Interior_MapScripts:: @ 8267CFA map_script MAP_SCRIPT_ON_RESUME, FarawayIsland_Interior_OnResume @@ -58,13 +58,13 @@ FarawayIsland_Interior_OnFrame: @ 8267D98 FarawayIsland_Interior_EventScript_FindMew:: @ 8267DA2 lockall playse SE_PIN - applymovement LOCALID_MEW, Common_Movement_ExclamationMark + applymovement LOCALID_FARAWAY_ISLAND_MEW, Common_Movement_ExclamationMark waitmovement 0 - applymovement LOCALID_MEW, Common_Movement_Delay48 + applymovement LOCALID_FARAWAY_ISLAND_MEW, Common_Movement_Delay48 waitmovement 0 - applymovement LOCALID_MEW, FarawayIsland_Interior_Movement_MewMoveAndHide + applymovement LOCALID_FARAWAY_ISLAND_MEW, FarawayIsland_Interior_Movement_MewMoveAndHide waitmovement 0 - copyobjectxytoperm LOCALID_MEW + copyobjectxytoperm LOCALID_FARAWAY_ISLAND_MEW setvar VAR_TEMP_1, 1 releaseall end @@ -120,7 +120,7 @@ FarawayIsland_Interior_Movement_MewFloatUpEast: @ 8267DEB FarawayIsland_Interior_EventScript_Mew:: @ 8267DF2 lock faceplayer - applymovement LOCALID_MEW, FarawayIsland_Interior_Movement_MewAppear + applymovement LOCALID_FARAWAY_ISLAND_MEW, FarawayIsland_Interior_Movement_MewAppear waitmovement 0 setvar VAR_0x8004, 0 special SetMewAboveGrass @@ -171,22 +171,22 @@ FarawayIsland_Interior_EventScript_PlayerOrMewRan:: @ 8267EA4 end FarawayIsland_Interior_EventScript_FoundMewNorth:: @ 8267EAF - applymovement LOCALID_MEW, FarawayIsland_Interior_Movement_MewFloatUpNorth + applymovement LOCALID_FARAWAY_ISLAND_MEW, FarawayIsland_Interior_Movement_MewFloatUpNorth waitmovement 0 return FarawayIsland_Interior_EventScript_FoundMewSouth:: @ 8267EBA - applymovement LOCALID_MEW, FarawayIsland_Interior_Movement_MewFloatUpSouth + applymovement LOCALID_FARAWAY_ISLAND_MEW, FarawayIsland_Interior_Movement_MewFloatUpSouth waitmovement 0 return FarawayIsland_Interior_EventScript_FoundMewWest:: @ 8267EC5 - applymovement LOCALID_MEW, FarawayIsland_Interior_Movement_MewFloatUpWest + applymovement LOCALID_FARAWAY_ISLAND_MEW, FarawayIsland_Interior_Movement_MewFloatUpWest waitmovement 0 return FarawayIsland_Interior_EventScript_FoundMewEast:: @ 8267ED0 - applymovement LOCALID_MEW, FarawayIsland_Interior_Movement_MewFloatUpEast + applymovement LOCALID_FARAWAY_ISLAND_MEW, FarawayIsland_Interior_Movement_MewFloatUpEast waitmovement 0 return @@ -194,7 +194,7 @@ FarawayIsland_Interior_EventScript_HideMewWhenGrassCut:: @ 8267EDB lockall fadescreenswapbuffers FADE_TO_BLACK setflag FLAG_HIDE_MEW - removeobject LOCALID_MEW + removeobject LOCALID_FARAWAY_ISLAND_MEW fadescreenswapbuffers FADE_FROM_BLACK msgbox FarawayIsland_Interior_Text_TheFeelingOfBeingWatchedFaded, MSGBOX_DEFAULT closemessage diff --git a/data/maps/Route111/scripts.inc b/data/maps/Route111/scripts.inc index 322c9a2b7..428011645 100644 --- a/data/maps/Route111/scripts.inc +++ b/data/maps/Route111/scripts.inc @@ -2,9 +2,10 @@ .set LOCALID_VICTORIA, 2 .set LOCALID_VIVI, 3 .set LOCALID_VICKY, 4 -.set LOCALID_PLAYER_FALLING, 45 .set LOCALID_ROCK_SMASH_MAN, 46 +@ Note: LOCALID_ROUTE111_PLAYER_FALLING is a local id for this map used elsewhere. It's defined in event_objects.h + Route111_MapScripts:: @ 81F0CA7 map_script MAP_SCRIPT_ON_LOAD, Route111_OnLoad map_script MAP_SCRIPT_ON_TRANSITION, Route111_OnTransition @@ -127,11 +128,11 @@ Route111_EventScript_MirageTowerDisappear:: @ 81F0E60 waitstate delay 24 playse SE_FALL - addobject LOCALID_PLAYER_FALLING + addobject LOCALID_ROUTE111_PLAYER_FALLING special StartPlayerDescendMirageTower waitstate showobjectat OBJ_EVENT_ID_PLAYER, MAP_LITTLEROOT_TOWN - removeobject LOCALID_PLAYER_FALLING + removeobject LOCALID_ROUTE111_PLAYER_FALLING delay 16 turnobject OBJ_EVENT_ID_PLAYER, DIR_NORTH delay 16 diff --git a/data/maps/UnionRoom/scripts.inc b/data/maps/UnionRoom/scripts.inc index f25e7acb6..13d7e1007 100644 --- a/data/maps/UnionRoom/scripts.inc +++ b/data/maps/UnionRoom/scripts.inc @@ -1,11 +1,4 @@ -.set LOCALID_UR_PLAYER_4, 2 -.set LOCALID_UR_PLAYER_8, 3 -.set LOCALID_UR_PLAYER_7, 4 -.set LOCALID_UR_PLAYER_6, 5 -.set LOCALID_UR_PLAYER_5, 6 -.set LOCALID_UR_PLAYER_3, 7 -.set LOCALID_UR_PLAYER_2, 8 -.set LOCALID_UR_PLAYER_1, 9 +@ Note: LOCALID_UNION_ROOM_PLAYER_# are local ids for this map used elsewhere. They're defined in event_objects.h UnionRoom_MapScripts:: @ 823D1A6 map_script MAP_SCRIPT_ON_RESUME, UnionRoom_OnResume @@ -21,14 +14,14 @@ UnionRoom_OnResume: @ 823D1B1 setflag FLAG_HIDE_UNION_ROOM_PLAYER_6 setflag FLAG_HIDE_UNION_ROOM_PLAYER_7 setflag FLAG_HIDE_UNION_ROOM_PLAYER_8 - removeobject LOCALID_UR_PLAYER_1 - removeobject LOCALID_UR_PLAYER_2 - removeobject LOCALID_UR_PLAYER_3 - removeobject LOCALID_UR_PLAYER_4 - removeobject LOCALID_UR_PLAYER_5 - removeobject LOCALID_UR_PLAYER_6 - removeobject LOCALID_UR_PLAYER_7 - removeobject LOCALID_UR_PLAYER_8 + removeobject LOCALID_UNION_ROOM_PLAYER_1 + removeobject LOCALID_UNION_ROOM_PLAYER_2 + removeobject LOCALID_UNION_ROOM_PLAYER_3 + removeobject LOCALID_UNION_ROOM_PLAYER_4 + removeobject LOCALID_UNION_ROOM_PLAYER_5 + removeobject LOCALID_UNION_ROOM_PLAYER_6 + removeobject LOCALID_UNION_ROOM_PLAYER_7 + removeobject LOCALID_UNION_ROOM_PLAYER_8 special RunUnionRoom end diff --git a/graphics/misc/fossil.png b/graphics/misc/fossil.png deleted file mode 100644 index f92649e98..000000000 Binary files a/graphics/misc/fossil.png and /dev/null differ diff --git a/include/constants/event_objects.h b/include/constants/event_objects.h index 7a224940f..1958c792e 100644 --- a/include/constants/event_objects.h +++ b/include/constants/event_objects.h @@ -279,7 +279,37 @@ #define FIRST_DECORATION_SPRITE_GFX OBJ_EVENT_GFX_PICHU_DOLL +// Special object event local ids #define OBJ_EVENT_ID_PLAYER 0xFF #define OBJ_EVENT_ID_CAMERA 0x7F +// Object event local ids referenced in C files +#define LOCALID_ROUTE111_PLAYER_FALLING 45 +#define LOCALID_BIRTH_ISLAND_EXTERIOR_ROCK 1 +#define LOCALID_FARAWAY_ISLAND_MEW 1 +#define LOCALID_UNION_ROOM_PLAYER_4 2 +#define LOCALID_UNION_ROOM_PLAYER_8 3 +#define LOCALID_UNION_ROOM_PLAYER_7 4 +#define LOCALID_UNION_ROOM_PLAYER_6 5 +#define LOCALID_UNION_ROOM_PLAYER_5 6 +#define LOCALID_UNION_ROOM_PLAYER_3 7 +#define LOCALID_UNION_ROOM_PLAYER_2 8 +#define LOCALID_UNION_ROOM_PLAYER_1 9 +#define LOCALID_BATTLE_TOWER_LOBBY_REPORTER 5 +#define LOCALID_TRUCK_BOX_TOP 1 +#define LOCALID_TRUCK_BOX_BOTTOM_L 2 +#define LOCALID_TRUCK_BOX_BOTTOM_R 3 +#define LOCALID_OLDALE_MART_CLERK 1 +#define LOCALID_LAVARIDGE_MART_CLERK 1 +#define LOCALID_FALLARBOR_MART_CLERK 1 +#define LOCALID_VERDANTURF_MART_CLERK 1 +#define LOCALID_PETALBURG_MART_CLERK 1 +#define LOCALID_SLATEPORT_MART_CLERK 1 +#define LOCALID_MAUVILLE_MART_CLERK 1 +#define LOCALID_RUSTBORO_MART_CLERK 1 +#define LOCALID_FORTREE_MART_CLERK 1 +#define LOCALID_MOSSDEEP_MART_CLERK 1 +#define LOCALID_SOOTOPOLIS_MART_CLERK 1 +#define LOCALID_BATTLE_FRONTIER_MART_CLERK 1 + #endif // GUARD_CONSTANTS_EVENT_OBJECTS_H diff --git a/src/faraway_island.c b/src/faraway_island.c index bc0814652..51ab8def4 100755 --- a/src/faraway_island.c +++ b/src/faraway_island.c @@ -38,7 +38,7 @@ static const s16 sFarawayIslandRockCoords[4][2] = static u8 GetMewObjectEventId(void) { u8 objectEventId; - TryGetObjectEventIdByLocalIdAndMap(1, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &objectEventId); + TryGetObjectEventIdByLocalIdAndMap(LOCALID_FARAWAY_ISLAND_MEW, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &objectEventId); return objectEventId; } diff --git a/src/field_special_scene.c b/src/field_special_scene.c index 6b41c5423..3c7016bd1 100644 --- a/src/field_special_scene.c +++ b/src/field_special_scene.c @@ -72,12 +72,12 @@ void Task_Truck1(u8 taskId) s16 cameraXpan = 0, cameraYpan = 0; s16 box1, box2, box3; - box1 = GetTruckBoxMovement(data[0] + 30) * 4; // top box. - SetObjectEventSpritePosByLocalIdAndMap(1, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, 3 - cameraXpan, box1 + 3); - box2 = GetTruckBoxMovement(data[0]) * 2; // bottom left box. - SetObjectEventSpritePosByLocalIdAndMap(2, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -cameraXpan, box2 - 3); - box3 = GetTruckBoxMovement(data[0]) * 4; // bottom right box. - SetObjectEventSpritePosByLocalIdAndMap(3, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -3 - cameraXpan, box3); + box1 = GetTruckBoxMovement(data[0] + 30) * 4; + SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_TOP, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, 3 - cameraXpan, box1 + 3); + box2 = GetTruckBoxMovement(data[0]) * 2; + SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_BOTTOM_L, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -cameraXpan, box2 - 3); + box3 = GetTruckBoxMovement(data[0]) * 4; + SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_BOTTOM_R, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -3 - cameraXpan, box3); if (++data[0] == SECONDS(500)) // this will never run data[0] = 0; // reset the timer if it gets stuck. @@ -116,11 +116,11 @@ void Task_Truck2(u8 taskId) cameraYpan = GetTruckCameraBobbingY(data[2]); SetCameraPanning(cameraXpan, cameraYpan); box1 = GetTruckBoxMovement(data[2] + 30) * 4; - SetObjectEventSpritePosByLocalIdAndMap(1, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, 3 - cameraXpan, box1 + 3); + SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_TOP, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, 3 - cameraXpan, box1 + 3); box2 = GetTruckBoxMovement(data[2]) * 2; - SetObjectEventSpritePosByLocalIdAndMap(2, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -cameraXpan, box2 - 3); + SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_BOTTOM_L, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -cameraXpan, box2 - 3); box3 = GetTruckBoxMovement(data[2]) * 4; - SetObjectEventSpritePosByLocalIdAndMap(3, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -3 - cameraXpan, box3); + SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_BOTTOM_R, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -3 - cameraXpan, box3); } } @@ -147,9 +147,9 @@ static void Task_Truck3(u8 taskId) cameraXpan = gTruckCamera_HorizontalTable[data[1]]; cameraYpan = 0; SetCameraPanning(cameraXpan, 0); - SetObjectEventSpritePosByLocalIdAndMap(1, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, 3 - cameraXpan, cameraYpan + 3); - SetObjectEventSpritePosByLocalIdAndMap(2, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -cameraXpan, cameraYpan - 3); - SetObjectEventSpritePosByLocalIdAndMap(3, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -3 - cameraXpan, cameraYpan); + SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_TOP, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, 3 - cameraXpan, cameraYpan + 3); + SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_BOTTOM_L, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -cameraXpan, cameraYpan - 3); + SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_BOTTOM_R, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -3 - cameraXpan, cameraYpan); } } @@ -242,9 +242,9 @@ void EndTruckSequence(u8 taskId) { if (!FuncIsActiveTask(Task_HandleTruckSequence)) { - SetObjectEventSpritePosByLocalIdAndMap(1, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, 3, 3); - SetObjectEventSpritePosByLocalIdAndMap(2, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, 0, -3); - SetObjectEventSpritePosByLocalIdAndMap(3, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -3, 0); + SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_TOP, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, 3, 3); + SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_BOTTOM_L, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, 0, -3); + SetObjectEventSpritePosByLocalIdAndMap(LOCALID_TRUCK_BOX_BOTTOM_R, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, -3, 0); } } diff --git a/src/field_specials.c b/src/field_specials.c index 13fad83b1..83857e1ff 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -3429,7 +3429,7 @@ static void ChangeDeoxysRockLevel(u8 rockLevel) { u8 objectEventId; LoadPalette(&sDeoxysRockPalettes[rockLevel], 0x1A0, 8); - TryGetObjectEventIdByLocalIdAndMap(1, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &objectEventId); + TryGetObjectEventIdByLocalIdAndMap(LOCALID_BIRTH_ISLAND_EXTERIOR_ROCK, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &objectEventId); if (rockLevel == 0) PlaySE(SE_M_CONFUSE_RAY); @@ -3437,9 +3437,9 @@ static void ChangeDeoxysRockLevel(u8 rockLevel) PlaySE(SE_RG_DEOXYS_MOVE); CreateTask(WaitForDeoxysRockMovement, 8); - gFieldEffectArguments[0] = 1; - gFieldEffectArguments[1] = 58; - gFieldEffectArguments[2] = 26; + gFieldEffectArguments[0] = LOCALID_BIRTH_ISLAND_EXTERIOR_ROCK; + gFieldEffectArguments[1] = MAP_NUM(BIRTH_ISLAND_EXTERIOR); + gFieldEffectArguments[2] = MAP_GROUP(BIRTH_ISLAND_EXTERIOR); gFieldEffectArguments[3] = sDeoxysRockCoords[rockLevel][0]; gFieldEffectArguments[4] = sDeoxysRockCoords[rockLevel][1]; @@ -3686,18 +3686,18 @@ u32 GetMartEmployeeObjectEventId(void) { static const u8 sPokeMarts[][3] = { - { MAP_GROUP(OLDALE_TOWN_MART), MAP_NUM(OLDALE_TOWN_MART), 1 }, - { MAP_GROUP(LAVARIDGE_TOWN_MART), MAP_NUM(LAVARIDGE_TOWN_MART), 1 }, - { MAP_GROUP(FALLARBOR_TOWN_MART), MAP_NUM(FALLARBOR_TOWN_MART), 1 }, - { MAP_GROUP(VERDANTURF_TOWN_MART), MAP_NUM(VERDANTURF_TOWN_MART), 1 }, - { MAP_GROUP(PETALBURG_CITY_MART), MAP_NUM(PETALBURG_CITY_MART), 1 }, - { MAP_GROUP(SLATEPORT_CITY_MART), MAP_NUM(SLATEPORT_CITY_MART), 1 }, - { MAP_GROUP(MAUVILLE_CITY_MART), MAP_NUM(MAUVILLE_CITY_MART), 1 }, - { MAP_GROUP(RUSTBORO_CITY_MART), MAP_NUM(RUSTBORO_CITY_MART), 1 }, - { MAP_GROUP(FORTREE_CITY_MART), MAP_NUM(FORTREE_CITY_MART), 1 }, - { MAP_GROUP(MOSSDEEP_CITY_MART), MAP_NUM(MOSSDEEP_CITY_MART), 1 }, - { MAP_GROUP(SOOTOPOLIS_CITY_MART), MAP_NUM(SOOTOPOLIS_CITY_MART), 1 }, - { MAP_GROUP(BATTLE_FRONTIER_MART), MAP_NUM(BATTLE_FRONTIER_MART), 1 } + { MAP_GROUP(OLDALE_TOWN_MART), MAP_NUM(OLDALE_TOWN_MART), LOCALID_OLDALE_MART_CLERK }, + { MAP_GROUP(LAVARIDGE_TOWN_MART), MAP_NUM(LAVARIDGE_TOWN_MART), LOCALID_LAVARIDGE_MART_CLERK }, + { MAP_GROUP(FALLARBOR_TOWN_MART), MAP_NUM(FALLARBOR_TOWN_MART), LOCALID_FALLARBOR_MART_CLERK }, + { MAP_GROUP(VERDANTURF_TOWN_MART), MAP_NUM(VERDANTURF_TOWN_MART), LOCALID_VERDANTURF_MART_CLERK }, + { MAP_GROUP(PETALBURG_CITY_MART), MAP_NUM(PETALBURG_CITY_MART), LOCALID_PETALBURG_MART_CLERK }, + { MAP_GROUP(SLATEPORT_CITY_MART), MAP_NUM(SLATEPORT_CITY_MART), LOCALID_SLATEPORT_MART_CLERK }, + { MAP_GROUP(MAUVILLE_CITY_MART), MAP_NUM(MAUVILLE_CITY_MART), LOCALID_MAUVILLE_MART_CLERK }, + { MAP_GROUP(RUSTBORO_CITY_MART), MAP_NUM(RUSTBORO_CITY_MART), LOCALID_RUSTBORO_MART_CLERK }, + { MAP_GROUP(FORTREE_CITY_MART), MAP_NUM(FORTREE_CITY_MART), LOCALID_FORTREE_MART_CLERK }, + { MAP_GROUP(MOSSDEEP_CITY_MART), MAP_NUM(MOSSDEEP_CITY_MART), LOCALID_MOSSDEEP_MART_CLERK }, + { MAP_GROUP(SOOTOPOLIS_CITY_MART), MAP_NUM(SOOTOPOLIS_CITY_MART), LOCALID_SOOTOPOLIS_MART_CLERK }, + { MAP_GROUP(BATTLE_FRONTIER_MART), MAP_NUM(BATTLE_FRONTIER_MART), LOCALID_BATTLE_FRONTIER_MART_CLERK } }; u8 i; diff --git a/src/item_menu_icons.c b/src/item_menu_icons.c index d15409226..c728a720f 100644 --- a/src/item_menu_icons.c +++ b/src/item_menu_icons.c @@ -244,7 +244,7 @@ static const struct OamData sBerryPicRotatingOamData = .affineParam = 0 }; -static const union AnimCmd sSpriteAnim_857FBD8[] = +static const union AnimCmd sAnim_BerryPic[] = { ANIMCMD_FRAME(0, 0), ANIMCMD_END @@ -252,7 +252,7 @@ static const union AnimCmd sSpriteAnim_857FBD8[] = static const union AnimCmd *const sBerryPicSpriteAnimTable[] = { - sSpriteAnim_857FBD8 + sAnim_BerryPic }; static const struct SpriteFrameImage sBerryPicSpriteImageTable[] = diff --git a/src/mirage_tower.c b/src/mirage_tower.c index d18ddcc0f..9f91dff50 100644 --- a/src/mirage_tower.c +++ b/src/mirage_tower.c @@ -14,12 +14,14 @@ #include "sprite.h" #include "task.h" #include "window.h" +#include "constants/event_objects.h" #include "constants/maps.h" #include "constants/rgb.h" #include "constants/songs.h" #include "constants/metatile_labels.h" -struct MirageTowerPulseBlend { +struct MirageTowerPulseBlend +{ u8 taskId; struct PulseBlend pulseBlend; }; @@ -37,59 +39,51 @@ struct BgRegOffsets u16 bgVOFS; }; -struct Struct203CF10 +struct FallAnim_Tower { - u8 *buffer; - u8 currIndex; + u8 *disintegrateRand; + u8 disintegrateIdx; }; -struct DynamicSpriteFrameImage -{ - u8 *data; - u16 size; -}; - -struct Struct203CF0C +struct FallAnim_Fossil { u8 *frameImageTiles; - struct DynamicSpriteFrameImage *frameImage; + struct SpriteFrameImage *frameImage; u8 spriteId; - u16 *unkC; - u16 unk10; + u16 *disintegrateRand; + u16 disintegrateIdx; }; +#define TAG_CEILING_CRUMBLE 4000 + #define MIRAGE_TOWER_GFX_LENGTH (sizeof(sBlankTile_Gfx) + sizeof(sMirageTower_Gfx)) -#define ROOT_FOSSIL_GFX_LENGTH sizeof(sRootFossil_Gfx) -#define ROOT_FOSSIL_GFX_RANDOMIZER_LENGTH 0x100 +#define FOSSIL_DISINTEGRATE_LENGTH 0x100 -// extern data -extern const struct SpriteSheet gMirageTowerCeilingCrumbleSpriteSheets[]; -extern const s16 sCeilingCrumblePositions[][3]; +static const struct SpriteSheet sCeilingCrumbleSpriteSheets[]; +static const s16 sCeilingCrumblePositions[][3]; -// static functions -static void PlayerDescendMirageTower(u8 taskId); -static void DoScreenShake(u8 taskId); +static void PlayerDescendMirageTower(u8); +static void DoScreenShake(u8); static void IncrementCeilingCrumbleFinishedCount(void); -static void WaitCeilingCrumble(u8 taskId); -static void FinishCeilingCrumbleTask(u8 taskId); +static void WaitCeilingCrumble(u8); +static void FinishCeilingCrumbleTask(u8); static void CreateCeilingCrumbleSprites(void); -static void MoveCeilingCrumbleSprite(struct Sprite* sprite); -static void DoMirageTowerDisintegration(u8 taskId); -static void InitMirageTowerShake(u8 taskId); -static void DoFossilFallAndSink(u8 taskId); -static void sub_81BF248(struct Sprite *); -static void sub_81BF2B8(u8* a, u16 b, u8 c, u8 d, u8 e); +static void SpriteCB_CeilingCrumble(struct Sprite*); +static void DoMirageTowerDisintegration(u8); +static void InitMirageTowerShake(u8); +static void Task_FossilFallAndSink(u8); +static void SpriteCB_FallingFossil(struct Sprite *); +static void UpdateDisintegrationEffect(u8*, u16, u8, u8, u8); -// rodata static const u8 sBlankTile_Gfx[32] = {0}; static const u8 sMirageTower_Gfx[] = INCBIN_U8("graphics/misc/mirage_tower.4bpp"); static const u16 sMirageTowerTilemap[] = INCBIN_U16("graphics/misc/mirage_tower.bin"); -static const u16 sRootFossil_Pal[] = INCBIN_U16("graphics/misc/fossil.gbapal"); -static const u8 sRootFossil_Gfx[] = INCBIN_U8("graphics/misc/fossil.4bpp"); +static const u16 sFossil_Pal[] = INCBIN_U16("graphics/object_events/pics/misc/fossil.gbapal"); // Unused +static const u8 sFossil_Gfx[] = INCBIN_U8("graphics/object_events/pics/misc/fossil.4bpp"); // Duplicate of gObjectEventPic_Fossil static const u8 sMirageTowerCrumbles_Gfx[] = INCBIN_U8("graphics/misc/mirage_tower_crumbles.4bpp"); static const u16 sMirageTowerCrumbles_Palette[] = INCBIN_U16("graphics/misc/mirage_tower_crumbles.gbapal"); -const s16 sCeilingCrumblePositions[][3] = +static const s16 sCeilingCrumblePositions[][3] = { { 0, 10, 65}, { 17, 3, 50}, @@ -101,10 +95,10 @@ const s16 sCeilingCrumblePositions[][3] = {-24, -4, 65}, }; -const struct SpriteSheet gMirageTowerCeilingCrumbleSpriteSheets[] = +static const struct SpriteSheet sCeilingCrumbleSpriteSheets[] = { - {sMirageTowerCrumbles_Gfx, 0x0080, 4000}, - {NULL} + {sMirageTowerCrumbles_Gfx, 0x80, TAG_CEILING_CRUMBLE}, + {} }; static const struct MetatileCoords sInvisibleMirageTowerMetatiles[] = @@ -129,13 +123,13 @@ static const struct MetatileCoords sInvisibleMirageTowerMetatiles[] = {20, 58, METATILE_General_SandPit_Center}, }; -static const union AnimCmd gSpriteAnim_8617DEC[] = +static const union AnimCmd sAnim_FallingFossil[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -static const struct OamData gOamData_8617DF4 = +static const struct OamData sOamData_FallingFossil = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -152,14 +146,20 @@ static const struct OamData gOamData_8617DF4 = .affineParam = 0, }; -static const union AnimCmd *const gSpriteAnimTable_8617DFC[] = +static const union AnimCmd *const sAnims_FallingFossil[] = { - gSpriteAnim_8617DEC, + sAnim_FallingFossil, }; -static const struct SpriteTemplate gUnknown_08617E00 = +static const struct SpriteTemplate sSpriteTemplate_FallingFossil = { - 0xFFFF, 0xFFFF, &gOamData_8617DF4, gSpriteAnimTable_8617DFC, NULL, gDummySpriteAffineAnimTable, SpriteCallbackDummy + .tileTag = 0xFFFF, + .paletteTag = 0xFFFF, + .oam = &sOamData_FallingFossil, + .anims = sAnims_FallingFossil, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy }; const struct PulseBlendSettings gMirageTowerPulseBlendSettings = { @@ -174,18 +174,18 @@ const struct PulseBlendSettings gMirageTowerPulseBlendSettings = { .unk7_7 = 1, }; -static const union AnimCmd sCeilingCrumble2AnimCmd[] = +static const union AnimCmd sAnim_CeilingCrumbleSmall[] = { ANIMCMD_FRAME(0, 12), ANIMCMD_JUMP(0), }; -static const union AnimCmd *const sCeilingCrumble2AnimCmds[] = +static const union AnimCmd *const sAnims_CeilingCrumbleSmall[] = { - sCeilingCrumble2AnimCmd, + sAnim_CeilingCrumbleSmall, }; -static const struct OamData sCeilingCrumble2OamData = +static const struct OamData sOamData_CeilingCrumbleSmall = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -202,28 +202,28 @@ static const struct OamData sCeilingCrumble2OamData = .affineParam = 0, }; -static const struct SpriteTemplate sCeilingCrumbleSpriteTemplate2 = { - .tileTag = 4000, +static const struct SpriteTemplate sSpriteTemplate_CeilingCrumbleSmall = { + .tileTag = TAG_CEILING_CRUMBLE, .paletteTag = 0xFFFF, - .oam = &sCeilingCrumble2OamData, - .anims = sCeilingCrumble2AnimCmds, + .oam = &sOamData_CeilingCrumbleSmall, + .anims = sAnims_CeilingCrumbleSmall, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = MoveCeilingCrumbleSprite + .callback = SpriteCB_CeilingCrumble }; -static const union AnimCmd sCeilingCrumble1AnimCmd[] = +static const union AnimCmd sAnim_CeilingCrumbleLarge[] = { ANIMCMD_FRAME(0, 12), ANIMCMD_JUMP(0), }; -static const union AnimCmd *const sCeilingCrumble1AnimCmds[] = +static const union AnimCmd *const sAnims_CeilingCrumbleLarge[] = { - sCeilingCrumble1AnimCmd, + sAnim_CeilingCrumbleLarge, }; -static const struct OamData sCeilingCrumble1OamData = +static const struct OamData sOamData_CeilingCrumbleLarge = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -240,24 +240,26 @@ static const struct OamData sCeilingCrumble1OamData = .affineParam = 0, }; -static const struct SpriteTemplate sCeilingCrumbleSpriteTemplate1 = { - .tileTag = 4000, +static const struct SpriteTemplate sSpriteTemplate_CeilingCrumbleLarge = { + .tileTag = TAG_CEILING_CRUMBLE, .paletteTag = 0xFFFF, - .oam = &sCeilingCrumble1OamData, - .anims = sCeilingCrumble1AnimCmds, + .oam = &sOamData_CeilingCrumbleLarge, + .anims = sAnims_CeilingCrumbleLarge, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = MoveCeilingCrumbleSprite + .callback = SpriteCB_CeilingCrumble }; EWRAM_DATA static u8* sMirageTowerGfxBuffer = NULL; EWRAM_DATA static u8* sMirageTowerTilemapBuffer = NULL; -EWRAM_DATA static struct Struct203CF0C *sUnknown_0203CF0C = NULL; -EWRAM_DATA static struct Struct203CF10 *sUnknown_0203CF10 = NULL; +EWRAM_DATA static struct FallAnim_Fossil *sFallingFossil = NULL; +EWRAM_DATA static struct FallAnim_Tower *sFallingTower = NULL; EWRAM_DATA static struct BgRegOffsets *sBgShakeOffsets = NULL; -EWRAM_DATA struct MirageTowerPulseBlend *sMirageTowerPulseBlend = NULL; +EWRAM_DATA static struct MirageTowerPulseBlend *sMirageTowerPulseBlend = NULL; -static u16 gUnknown_030012A8[8]; +// Holds data about the disintegration effect for Mirage Tower / the unchosen fossil. +// Never read, presumably for debugging +static u16 sDebug_DisintegrationData[8]; bool8 IsMirageTowerVisible(void) { @@ -319,6 +321,7 @@ void SetMirageTowerVisibility(void) if (VarGet(VAR_MIRAGE_TOWER_STATE)) { + // Mirage Tower event has already been completed, hide it FlagClear(FLAG_MIRAGE_TOWER_VISIBLE); return; } @@ -343,32 +346,40 @@ void StartPlayerDescendMirageTower(void) CreateTask(PlayerDescendMirageTower, 8); } +// As the tower disintegrates, a duplicate object event of the player +// is created at the top of the tower and moved down to show the player falling static void PlayerDescendMirageTower(u8 taskId) { u8 objectEventId; - struct ObjectEvent *fakePlayerObjectEvent; - struct ObjectEvent *playerObjectEvent; + struct ObjectEvent *fallingPlayer; + struct ObjectEvent *player; - TryGetObjectEventIdByLocalIdAndMap(45, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &objectEventId); - fakePlayerObjectEvent = &gObjectEvents[objectEventId]; - gSprites[fakePlayerObjectEvent->spriteId].pos2.y += 4; - playerObjectEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; - if ((gSprites[fakePlayerObjectEvent->spriteId].pos1.y + gSprites[fakePlayerObjectEvent->spriteId].pos2.y) >= - (gSprites[playerObjectEvent->spriteId].pos1.y + gSprites[playerObjectEvent->spriteId].pos2.y)) + TryGetObjectEventIdByLocalIdAndMap(LOCALID_ROUTE111_PLAYER_FALLING, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &objectEventId); + fallingPlayer = &gObjectEvents[objectEventId]; + gSprites[fallingPlayer->spriteId].pos2.y += 4; + player = &gObjectEvents[gPlayerAvatar.objectEventId]; + if ((gSprites[fallingPlayer->spriteId].pos1.y + gSprites[fallingPlayer->spriteId].pos2.y) >= + (gSprites[player->spriteId].pos1.y + gSprites[player->spriteId].pos2.y)) { DestroyTask(taskId); EnableBothScriptContexts(); } } +#define tXShakeOffset data[0] +#define tTimer data[1] +#define tNumShakes data[2] +#define tShakeDelay data[3] +#define tYShakeOffset data[4] + static void StartScreenShake(u8 yShakeOffset, u8 xShakeOffset, u8 numShakes, u8 shakeDelay) { u8 taskId = CreateTask(DoScreenShake, 9); - gTasks[taskId].data[0] = xShakeOffset; - gTasks[taskId].data[1] = 0; - gTasks[taskId].data[2] = numShakes; - gTasks[taskId].data[3] = shakeDelay; - gTasks[taskId].data[4] = yShakeOffset; + gTasks[taskId].tXShakeOffset = xShakeOffset; + gTasks[taskId].tTimer = 0; + gTasks[taskId].tNumShakes = numShakes; + gTasks[taskId].tShakeDelay = shakeDelay; + gTasks[taskId].tYShakeOffset = yShakeOffset; SetCameraPanningCallback(NULL); PlaySE(SE_M_STRENGTH); } @@ -378,15 +389,15 @@ static void DoScreenShake(u8 taskId) s16 *data; data = gTasks[taskId].data; - data[1]++; - if (data[1] % data[3] == 0) + tTimer++; + if (tTimer % tShakeDelay == 0) { - data[1] = 0; - data[2]--; - data[0] = -data[0]; - data[4] = -data[4]; - SetCameraPanning(data[0], data[4]); - if (data[2] == 0) + tTimer = 0; + tNumShakes--; + tXShakeOffset = -tXShakeOffset; + tYShakeOffset = -tYShakeOffset; + SetCameraPanning(tXShakeOffset, tYShakeOffset); + if (tNumShakes == 0) { IncrementCeilingCrumbleFinishedCount(); DestroyTask(taskId); @@ -395,6 +406,12 @@ static void DoScreenShake(u8 taskId) } } +#undef tXShakeOffset +#undef tTimer +#undef tNumShakes +#undef tShakeDelay +#undef tYShakeOffset + static void IncrementCeilingCrumbleFinishedCount(void) { u8 taskId = FindTaskIdByFunc(WaitCeilingCrumble); @@ -404,7 +421,7 @@ static void IncrementCeilingCrumbleFinishedCount(void) void DoMirageTowerCeilingCrumble(void) { - LoadSpriteSheets(gMirageTowerCeilingCrumbleSpriteSheets); + LoadSpriteSheets(sCeilingCrumbleSpriteSheets); CreateCeilingCrumbleSprites(); CreateTask(WaitCeilingCrumble, 8); StartScreenShake(2, 1, 16, 3); @@ -421,7 +438,7 @@ static void WaitCeilingCrumble(u8 taskId) static void FinishCeilingCrumbleTask(u8 taskId) { - FreeSpriteTilesByTag(4000); + FreeSpriteTilesByTag(TAG_CEILING_CRUMBLE); DestroyTask(taskId); EnableBothScriptContexts(); } @@ -433,21 +450,21 @@ static void CreateCeilingCrumbleSprites(void) for (i = 0; i < 8; i++) { - spriteId = CreateSprite(&sCeilingCrumbleSpriteTemplate1, sCeilingCrumblePositions[i][0] + 120, sCeilingCrumblePositions[i][1], 8); + spriteId = CreateSprite(&sSpriteTemplate_CeilingCrumbleLarge, sCeilingCrumblePositions[i][0] + 120, sCeilingCrumblePositions[i][1], 8); gSprites[spriteId].oam.priority = 0; gSprites[spriteId].oam.paletteNum = 0; gSprites[spriteId].data[0] = i; } for (i = 0; i < 8; i++) { - spriteId = CreateSprite(&sCeilingCrumbleSpriteTemplate2, sCeilingCrumblePositions[i][0] + 115, sCeilingCrumblePositions[i][1] - 3, 8); + spriteId = CreateSprite(&sSpriteTemplate_CeilingCrumbleSmall, sCeilingCrumblePositions[i][0] + 115, sCeilingCrumblePositions[i][1] - 3, 8); gSprites[spriteId].oam.priority = 0; gSprites[spriteId].oam.paletteNum = 0; gSprites[spriteId].data[0] = i; } } -static void MoveCeilingCrumbleSprite(struct Sprite* sprite) +static void SpriteCB_CeilingCrumble(struct Sprite* sprite) { sprite->data[1] += 2; sprite->pos2.y = sprite->data[1] / 2; @@ -478,7 +495,7 @@ void StartMirageTowerShake(void) void StartMirageTowerFossilFallAndSink(void) { - CreateTask(DoFossilFallAndSink, 9); + CreateTask(Task_FossilFallAndSink, 9); } static void SetBgShakeOffsets(void) @@ -501,42 +518,44 @@ static void UpdateBgShake(u8 taskId) } } +#define tState data[0] + static void InitMirageTowerShake(u8 taskId) { u8 zero; - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { case 0: FreeAllWindowBuffers(); SetBgAttribute(0, BG_ATTR_PRIORITY, 2); - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; break; case 1: sMirageTowerGfxBuffer = (u8 *)AllocZeroed(MIRAGE_TOWER_GFX_LENGTH); sMirageTowerTilemapBuffer = (u8 *)AllocZeroed(BG_SCREEN_SIZE); ChangeBgX(0, 0, 0); ChangeBgY(0, 0, 0); - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; break; case 2: CpuSet(sBlankTile_Gfx, sMirageTowerGfxBuffer, MIRAGE_TOWER_GFX_LENGTH / 2); LoadBgTiles(0, sMirageTowerGfxBuffer, MIRAGE_TOWER_GFX_LENGTH, 0); - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; break; case 3: SetBgTilemapBuffer(0, sMirageTowerTilemapBuffer); CopyToBgTilemapBufferRect_ChangePalette(0, &sMirageTowerTilemap, 12, 29, 6, 12, 17); CopyBgTilemapBufferToVram(0); - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; break; case 4: ShowBg(0); - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; break; case 5: SetInvisibleMirageTowerMetatiles(); - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; break; case 6: sBgShakeOffsets = Alloc(sizeof(*sBgShakeOffsets)); @@ -558,27 +577,29 @@ static void DoMirageTowerDisintegration(u8 taskId) u16 i; u8 index; - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { case 1: - sUnknown_0203CF10 = AllocZeroed(OUTER_BUFFER_LENGTH * sizeof(struct Struct203CF10)); + sFallingTower = AllocZeroed(OUTER_BUFFER_LENGTH * sizeof(struct FallAnim_Tower)); break; case 3: if (gTasks[taskId].data[3] <= (OUTER_BUFFER_LENGTH - 1)) { if (gTasks[taskId].data[1] > 1) { + // Initialize disintegration pattern index = gTasks[taskId].data[3]; - sUnknown_0203CF10[index].buffer = Alloc(INNER_BUFFER_LENGTH); + sFallingTower[index].disintegrateRand = Alloc(INNER_BUFFER_LENGTH); for (i = 0; i <= (INNER_BUFFER_LENGTH - 1); i++) - sUnknown_0203CF10[index].buffer[i] = i; + sFallingTower[index].disintegrateRand[i] = i; + + // Randomize disintegration pattern for (i = 0; i <= (INNER_BUFFER_LENGTH - 1); i++) { u16 rand1, rand2, temp; - - rand1 = Random() % 0x30; - rand2 = Random() % 0x30; - SWAP(sUnknown_0203CF10[index].buffer[rand2], sUnknown_0203CF10[index].buffer[rand1], temp); + rand1 = Random() % INNER_BUFFER_LENGTH; + rand2 = Random() % INNER_BUFFER_LENGTH; + SWAP(sFallingTower[index].disintegrateRand[rand2], sFallingTower[index].disintegrateRand[rand1], temp); } if (gTasks[taskId].data[3] <= (OUTER_BUFFER_LENGTH - 1)) gTasks[taskId].data[3]++; @@ -591,20 +612,20 @@ static void DoMirageTowerDisintegration(u8 taskId) { for (j = 0; j < 1; j++) { - sub_81BF2B8(sMirageTowerGfxBuffer, - ((((OUTER_BUFFER_LENGTH - 1) - i) * INNER_BUFFER_LENGTH) + sUnknown_0203CF10[i].buffer[(sUnknown_0203CF10[i].currIndex)++]), + UpdateDisintegrationEffect(sMirageTowerGfxBuffer, + (OUTER_BUFFER_LENGTH - 1 - i) * INNER_BUFFER_LENGTH + sFallingTower[i].disintegrateRand[sFallingTower[i].disintegrateIdx++], 0, INNER_BUFFER_LENGTH, 1); } - if (sUnknown_0203CF10[i].currIndex > (INNER_BUFFER_LENGTH - 1)) + if (sFallingTower[i].disintegrateIdx > (INNER_BUFFER_LENGTH - 1)) { - FREE_AND_SET_NULL(sUnknown_0203CF10[i].buffer); + FREE_AND_SET_NULL(sFallingTower[i].disintegrateRand); gTasks[taskId].data[2]++; if ((i % 2) == 1) sBgShakeOffsets->bgVOFS--; } } LoadBgTiles(0, sMirageTowerGfxBuffer, MIRAGE_TOWER_GFX_LENGTH, 0); - if (sUnknown_0203CF10[OUTER_BUFFER_LENGTH - 1].currIndex > (INNER_BUFFER_LENGTH - 1)) + if (sFallingTower[OUTER_BUFFER_LENGTH - 1].disintegrateIdx > INNER_BUFFER_LENGTH - 1) break; return; case 4: @@ -617,7 +638,7 @@ static void DoMirageTowerDisintegration(u8 taskId) break; case 5: FREE_AND_SET_NULL(sBgShakeOffsets); - FREE_AND_SET_NULL(sUnknown_0203CF10); + FREE_AND_SET_NULL(sFallingTower); FREE_AND_SET_NULL(sMirageTowerGfxBuffer); FREE_AND_SET_NULL(sMirageTowerTilemapBuffer); break; @@ -635,127 +656,128 @@ static void DoMirageTowerDisintegration(u8 taskId) EnableBothScriptContexts(); break; } - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; } -static void DoFossilFallAndSink(u8 taskId) +static void Task_FossilFallAndSink(u8 taskId) { u16 i; u8 *buffer; - switch (gTasks[taskId].data[0]) + switch (gTasks[taskId].tState) { case 1: - sUnknown_0203CF0C = AllocZeroed(sizeof(*sUnknown_0203CF0C)); - sUnknown_0203CF0C->frameImageTiles = AllocZeroed(ROOT_FOSSIL_GFX_LENGTH); - sUnknown_0203CF0C->frameImage = AllocZeroed(sizeof(*sUnknown_0203CF0C->frameImage)); - sUnknown_0203CF0C->unkC = AllocZeroed(ROOT_FOSSIL_GFX_RANDOMIZER_LENGTH * sizeof(u16)); - sUnknown_0203CF0C->unk10 = 0; + sFallingFossil = AllocZeroed(sizeof(*sFallingFossil)); + sFallingFossil->frameImageTiles = AllocZeroed(sizeof(sFossil_Gfx)); + sFallingFossil->frameImage = AllocZeroed(sizeof(*sFallingFossil->frameImage)); + sFallingFossil->disintegrateRand = AllocZeroed(FOSSIL_DISINTEGRATE_LENGTH * sizeof(u16)); + sFallingFossil->disintegrateIdx = 0; break; case 2: - buffer = sUnknown_0203CF0C->frameImageTiles; - for (i = 0; i < ROOT_FOSSIL_GFX_LENGTH; i++, buffer++) - *buffer = sRootFossil_Gfx[i]; + buffer = sFallingFossil->frameImageTiles; + for (i = 0; i < sizeof(sFossil_Gfx); i++, buffer++) + *buffer = sFossil_Gfx[i]; break; case 3: - sUnknown_0203CF0C->frameImage->data = sUnknown_0203CF0C->frameImageTiles; - sUnknown_0203CF0C->frameImage->size = ROOT_FOSSIL_GFX_LENGTH; + sFallingFossil->frameImage->data = sFallingFossil->frameImageTiles; + sFallingFossil->frameImage->size = sizeof(sFossil_Gfx); break; case 4: { - struct SpriteTemplate fossilTemplate; - - fossilTemplate = gUnknown_08617E00; - fossilTemplate.images = (struct SpriteFrameImage *)(sUnknown_0203CF0C->frameImage); - sUnknown_0203CF0C->spriteId = CreateSprite(&fossilTemplate, 128, -16, 1); - gSprites[sUnknown_0203CF0C->spriteId].centerToCornerVecX = 0; - gSprites[sUnknown_0203CF0C->spriteId].data[0] = gSprites[sUnknown_0203CF0C->spriteId].pos1.x; - gSprites[sUnknown_0203CF0C->spriteId].data[1] = 1; + struct SpriteTemplate fossilTemplate = sSpriteTemplate_FallingFossil; + fossilTemplate.images = sFallingFossil->frameImage; + sFallingFossil->spriteId = CreateSprite(&fossilTemplate, 128, -16, 1); + gSprites[sFallingFossil->spriteId].centerToCornerVecX = 0; + gSprites[sFallingFossil->spriteId].data[0] = gSprites[sFallingFossil->spriteId].pos1.x; + gSprites[sFallingFossil->spriteId].data[1] = 1; } case 5: - for (i = 0; i < ROOT_FOSSIL_GFX_RANDOMIZER_LENGTH; i++) - sUnknown_0203CF0C->unkC[i] = i; + // Initialize disintegration pattern + for (i = 0; i < FOSSIL_DISINTEGRATE_LENGTH; i++) + sFallingFossil->disintegrateRand[i] = i; break; case 6: - for (i = 0; i < (ROOT_FOSSIL_GFX_RANDOMIZER_LENGTH * sizeof(u16)); i++) + // Randomize disintegration pattern + for (i = 0; i < FOSSIL_DISINTEGRATE_LENGTH * sizeof(u16); i++) { u16 rand1, rand2, temp; - - rand1 = Random() % 0x100; - rand2 = Random() % 0x100; - SWAP(sUnknown_0203CF0C->unkC[rand2], sUnknown_0203CF0C->unkC[rand1], temp); + rand1 = Random() % FOSSIL_DISINTEGRATE_LENGTH; + rand2 = Random() % FOSSIL_DISINTEGRATE_LENGTH; + SWAP(sFallingFossil->disintegrateRand[rand2], sFallingFossil->disintegrateRand[rand1], temp); } - gSprites[sUnknown_0203CF0C->spriteId].callback = sub_81BF248; + gSprites[sFallingFossil->spriteId].callback = SpriteCB_FallingFossil; break; case 7: - if (gSprites[sUnknown_0203CF0C->spriteId].callback != SpriteCallbackDummy) + // Wait for fossil to finish falling / disintegrating + if (gSprites[sFallingFossil->spriteId].callback != SpriteCallbackDummy) return; - DestroySprite(&gSprites[sUnknown_0203CF0C->spriteId]); - FREE_AND_SET_NULL(sUnknown_0203CF0C->unkC);; - FREE_AND_SET_NULL(sUnknown_0203CF0C->frameImage); - FREE_AND_SET_NULL(sUnknown_0203CF0C->frameImageTiles); - FREE_AND_SET_NULL(sUnknown_0203CF0C); + DestroySprite(&gSprites[sFallingFossil->spriteId]); + FREE_AND_SET_NULL(sFallingFossil->disintegrateRand);; + FREE_AND_SET_NULL(sFallingFossil->frameImage); + FREE_AND_SET_NULL(sFallingFossil->frameImageTiles); + FREE_AND_SET_NULL(sFallingFossil); break; case 8: EnableBothScriptContexts(); break; } - - gTasks[taskId].data[0]++; + gTasks[taskId].tState++; } -static void sub_81BF248(struct Sprite *sprite) +static void SpriteCB_FallingFossil(struct Sprite *sprite) { - if (sUnknown_0203CF0C->unk10 >= (ROOT_FOSSIL_GFX_RANDOMIZER_LENGTH)) + if (sFallingFossil->disintegrateIdx >= FOSSIL_DISINTEGRATE_LENGTH) { + // End animation sprite->callback = SpriteCallbackDummy; } else if (sprite->pos1.y >= 96) { + // Fossil has reached the ground, update disintegration animation u8 i; for (i = 0; i < 2; i++) - sub_81BF2B8(sUnknown_0203CF0C->frameImageTiles, sUnknown_0203CF0C->unkC[sUnknown_0203CF0C->unk10++], 0, 16, 0); + UpdateDisintegrationEffect(sFallingFossil->frameImageTiles, sFallingFossil->disintegrateRand[sFallingFossil->disintegrateIdx++], 0, 16, 0); StartSpriteAnim(sprite, 0); } else { + // Fossil is still falling sprite->pos1.y++; } } -static void sub_81BF2B8(u8* a, u16 b, u8 c, u8 d, u8 e) +static void UpdateDisintegrationEffect(u8* tiles, u16 randId, u8 c, u8 size, u8 offset) { - u8 r5, r4, r0, r2; - u16 var, var2; - u8 r2_1, r4_1; - u8 b2, c2; + u8 heightTiles, height, widthTiles, width; + u16 var, baseOffset; + u8 col, row; + u8 flag, tileMask; - r4 = b / d; - gUnknown_030012A8[0] = r4; + height = randId / size; + sDebug_DisintegrationData[0] = height; - r2 = b % d; - gUnknown_030012A8[1] = r2; + width = randId % size; + sDebug_DisintegrationData[1] = width; - r4_1 = r4 & 7; - r2_1 = r2 & 7; - gUnknown_030012A8[2] = r4 & 7; //should be using r4_1, but that doesn't match - gUnknown_030012A8[3] = r2 & 7; //" + row = height & 7; + col = width & 7; + sDebug_DisintegrationData[2] = height & 7; + sDebug_DisintegrationData[3] = width & 7; - r0 = r2 / 8; - r5 = r4 / 8; - - gUnknown_030012A8[4] = r2 / 8; //should be using r0, but that doesn't match - gUnknown_030012A8[5] = r4 / 8; //should be using r5, but that doesn't match + widthTiles = width / 8; + heightTiles = height / 8; + sDebug_DisintegrationData[4] = width / 8; + sDebug_DisintegrationData[5] = height / 8; - var = (d / 8) * (r5 * 64) + (r0 * 64); - gUnknown_030012A8[6] = var; + var = (size / 8) * (heightTiles * 64) + (widthTiles * 64); + sDebug_DisintegrationData[6] = var; - var2 = var + ((r4_1 * 8) + r2_1); - var2 /= 2; - gUnknown_030012A8[7] = var + ((r4_1 * 8) + r2_1); //should be using var2 with var2 being divided afterwards, but that doesn't match + baseOffset = var + ((row * 8) + col); + baseOffset /= 2; + sDebug_DisintegrationData[7] = var + ((row * 8) + col); - b2 = ((b % 2) ^ 1); - c2 = (c << (b2 << 2)) | 15 << (((b2 ^ 1) << 2)); - a[var2 + (e * 32)] &= c2; + flag = ((randId % 2) ^ 1); + tileMask = (c << (flag << 2)) | 15 << (((flag ^ 1) << 2)); + tiles[baseOffset + (offset * 32)] &= tileMask; } diff --git a/src/pokeblock.c b/src/pokeblock.c index daf50a612..fad6858ec 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -264,7 +264,7 @@ static const union AnimCmd *const sSpriteAnimTable_PokeblockCase[] = sSpriteAnim_PokeblockCase }; -static const union AffineAnimCmd sSpriteAffineAnim_85B26C8[] = +static const union AffineAnimCmd sAffineAnim_PokeblockCaseShake[] = { AFFINEANIMCMD_FRAME(0, 0, -2, 2), AFFINEANIMCMD_FRAME(0, 0, 2, 4), @@ -273,9 +273,9 @@ static const union AffineAnimCmd sSpriteAffineAnim_85B26C8[] = AFFINEANIMCMD_END }; -static const union AffineAnimCmd *const sSpriteAffineAnimTable_85B26F0[] = +static const union AffineAnimCmd *const sAffineAnims_PokeblockCaseShake[] = { - sSpriteAffineAnim_85B26C8 + sAffineAnim_PokeblockCaseShake }; const struct CompressedSpriteSheet gPokeblockCase_SpriteSheet = @@ -955,7 +955,7 @@ static void SpriteCB_ShakePokeblockCase(struct Sprite *sprite) { case 0: sprite->oam.affineMode = ST_OAM_AFFINE_NORMAL; - sprite->affineAnims = sSpriteAffineAnimTable_85B26F0; + sprite->affineAnims = sAffineAnims_PokeblockCaseShake; InitSpriteAffineAnim(sprite); sprite->sState = 1; sprite->sTimer = 0; diff --git a/src/tv.c b/src/tv.c index b7b490aa3..14a0dc53f 100644 --- a/src/tv.c +++ b/src/tv.c @@ -36,6 +36,7 @@ #include "data.h" #include "constants/battle_frontier.h" #include "constants/contest.h" +#include "constants/event_objects.h" #include "constants/items.h" #include "constants/layouts.h" #include "constants/lilycove_lady.h" @@ -3421,7 +3422,7 @@ void GetMomOrDadStringForTVMessage(void) void HideBattleTowerReporter(void) { VarSet(VAR_BRAVO_TRAINER_BATTLE_TOWER_ON, 0); - RemoveObjectEventByLocalIdAndMap(5, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup); + RemoveObjectEventByLocalIdAndMap(LOCALID_BATTLE_TOWER_LOBBY_REPORTER, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup); FlagSet(FLAG_HIDE_BATTLE_TOWER_REPORTER); } diff --git a/src/union_room_player_avatar.c b/src/union_room_player_avatar.c index c012fd84d..671290e21 100644 --- a/src/union_room_player_avatar.c +++ b/src/union_room_player_avatar.c @@ -77,18 +77,27 @@ static const u8 sNextFacingDirection[] = { [DIR_EAST] = DIR_NORTH }; -// Local id 1 is the Nurse/Attendant, 2-9 are link players -static const u8 sUnionRoomLocalIds[] = { 9, 8, 7, 2, 6, 5, 4, 3 }; +static const u8 sUnionRoomLocalIds[] = { + LOCALID_UNION_ROOM_PLAYER_1, + LOCALID_UNION_ROOM_PLAYER_2, + LOCALID_UNION_ROOM_PLAYER_3, + LOCALID_UNION_ROOM_PLAYER_4, + LOCALID_UNION_ROOM_PLAYER_5, + LOCALID_UNION_ROOM_PLAYER_6, + LOCALID_UNION_ROOM_PLAYER_7, + LOCALID_UNION_ROOM_PLAYER_8 +}; -static const u16 sUnknown[] = { - 0x2BF, - 0x2C0, - 0x2C1, - 0x2C2, - 0x2C3, - 0x2C4, - 0x2C5, - 0x2C6 +// Unused +static const u16 sHidePlayerFlags[] = { + FLAG_HIDE_UNION_ROOM_PLAYER_1, + FLAG_HIDE_UNION_ROOM_PLAYER_2, + FLAG_HIDE_UNION_ROOM_PLAYER_3, + FLAG_HIDE_UNION_ROOM_PLAYER_4, + FLAG_HIDE_UNION_ROOM_PLAYER_5, + FLAG_HIDE_UNION_ROOM_PLAYER_6, + FLAG_HIDE_UNION_ROOM_PLAYER_7, + FLAG_HIDE_UNION_ROOM_PLAYER_8 }; static const u8 sMovement_UnionPlayerExit[2] = {