start decompiling overworld.s

This commit is contained in:
DizzyEggg 2018-02-12 15:01:43 +01:00
parent a4787bc06a
commit 382442c4c8
27 changed files with 675 additions and 1163 deletions

View File

@ -14665,7 +14665,7 @@ sub_819672C: @ 819672C
ldrh r2, [r0, 0xA]
ldrh r1, [r0, 0xC]
adds r0, r2, 0
bl get_mapheader_by_bank_and_number
bl Overworld_GetMapHeaderByGroupAndId
ldrb r0, [r0, 0x14]
pop {r1}
bx r1

View File

@ -18683,7 +18683,7 @@ _081A4294:
adds r0, r3, r4
ldrh r1, [r0]
movs r0, 0x20
bl sav12_xor_set
bl SetGameStat
ldr r1, [r7]
adds r0, r1, r6
adds r0, r4
@ -31002,7 +31002,7 @@ sub_81AA810: @ 81AA810
ldrb r1, [r3]
adds r1, 0x2C
movs r0, 0x19
bl get_mapheader_by_bank_and_number
bl Overworld_GetMapHeaderByGroupAndId
adds r5, r0, 0
movs r7, 0
ldr r1, [r5, 0x4]

View File

@ -45,13 +45,13 @@ _0813BFCA:
bge _0813BFCA
movs r0, 0x17
movs r1, 0
bl sav12_xor_set
bl SetGameStat
movs r0, 0x18
movs r1, 0
bl sav12_xor_set
bl SetGameStat
movs r0, 0x19
movs r1, 0
bl sav12_xor_set
bl SetGameStat
pop {r4,r5}
pop {r0}
bx r0

View File

@ -2006,7 +2006,7 @@ _0809CF20:
bl sub_8084D5C
ldrb r0, [r5, 0x7]
ldrb r1, [r5, 0x6]
bl get_mapheader_by_bank_and_number
bl Overworld_GetMapHeaderByGroupAndId
ldr r1, [r0, 0x4]
ldrb r0, [r5, 0x5]
ldr r1, [r1, 0x8]

View File

@ -2008,7 +2008,7 @@ _080B6A64:
lsls r0, 24
cmp r0, 0
bne _080B6A8A
bl flag_var_implications_of_teleport_
bl Overworld_ResetStateAfterFly
bl warp_in
ldr r0, =c2_load_new_map
bl SetMainCallback2
@ -4881,7 +4881,7 @@ _080B81B8:
lsrs r0, 24
cmp r0, 0x1
bne _080B81E6
bl copy_saved_warp3_bank_and_enter_x_to_warp1
bl Overworld_SetWarpDestToLastHealLoc
bl warp_in
ldr r0, =c2_load_new_map
bl SetMainCallback2
@ -5211,7 +5211,7 @@ _080B8484:
thumb_func_start sub_80B849C
sub_80B849C: @ 80B849C
push {r4,lr}
bl sav1_map_get_light_level
bl Overworld_GetMapTypeOfSaveblockLocation
lsls r0, 24
lsrs r0, 24
bl is_light_level_1_2_3_5_or_6

View File

@ -7855,7 +7855,7 @@ pal_fill_for_maplights: @ 80AF040
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24
bl sav1_map_get_light_level
bl Overworld_GetMapTypeOfSaveblockLocation
adds r1, r0, 0
lsls r1, 24
lsrs r1, 24
@ -7910,7 +7910,7 @@ pal_fill_black: @ 80AF0A0
thumb_func_start sub_80AF0B4
sub_80AF0B4: @ 80AF0B4
push {r4,lr}
bl sav1_map_get_light_level
bl Overworld_GetMapTypeOfSaveblockLocation
adds r4, r0, 0
lsls r4, 24
lsrs r4, 24

View File

@ -11,7 +11,7 @@ mapconnection_get_mapheader: @ 8087D44
ldrb r2, [r0, 0x8]
ldrb r1, [r0, 0x9]
adds r0, r2, 0
bl get_mapheader_by_bank_and_number
bl Overworld_GetMapHeaderByGroupAndId
pop {r1}
bx r1
thumb_func_end mapconnection_get_mapheader

View File

@ -217,7 +217,7 @@ sub_8137304: @ 8137304
bl get_map_light_from_warp0
lsls r0, 24
lsrs r6, r0, 24
bl sav1_map_get_light_level
bl Overworld_GetMapTypeOfSaveblockLocation
lsls r0, 24
lsrs r5, r0, 24
movs r3, 0

File diff suppressed because it is too large Load Diff

View File

@ -10032,7 +10032,7 @@ _081B557C:
asrs r1, 24
lsls r1, 16
lsrs r1, 16
bl get_mapheader_by_bank_and_number
bl Overworld_GetMapHeaderByGroupAndId
adds r1, r0, 0
ldr r0, =gStringVar1
ldrb r1, [r1, 0x14]
@ -10057,7 +10057,7 @@ _081B55B8:
asrs r1, 24
lsls r1, 16
lsrs r1, 16
bl get_mapheader_by_bank_and_number
bl Overworld_GetMapHeaderByGroupAndId
adds r1, r0, 0
ldr r0, =gStringVar1
ldrb r1, [r1, 0x14]

View File

@ -308,7 +308,7 @@ _0813CCB8:
ldr r1, [r5]
ldrb r0, [r1, 0x10]
ldrb r1, [r1, 0x11]
bl get_mapheader_by_bank_and_number
bl Overworld_GetMapHeaderByGroupAndId
ldr r1, [r5]
ldrb r0, [r0, 0x14]
strh r0, [r1, 0x12]
@ -360,7 +360,7 @@ sub_813CD04: @ 813CD04
strb r3, [r1, 0x11]
adds r0, r5, 0
adds r1, r3, 0
bl get_mapheader_by_bank_and_number
bl Overworld_GetMapHeaderByGroupAndId
ldrb r0, [r0, 0x14]
bl CorrectSpecialMapSecId
ldr r2, [r4]
@ -496,7 +496,7 @@ sub_813CE34: @ 813CE34
lsrs r0, 24
lsls r1, 24
lsrs r1, 24
bl get_mapheader_by_bank_and_number
bl Overworld_GetMapHeaderByGroupAndId
ldrb r0, [r0, 0x14]
pop {r1}
bx r1

View File

@ -8095,7 +8095,7 @@ sub_81CB0C8: @ 81CB0C8
ldrh r2, [r0, 0xA]
ldrh r1, [r0, 0xC]
adds r0, r2, 0
bl get_mapheader_by_bank_and_number
bl Overworld_GetMapHeaderByGroupAndId
ldrb r0, [r0, 0x14]
pop {r1}
bx r1
@ -30295,7 +30295,7 @@ sub_81D6120: @ 81D6120
push {lr}
movs r0, 0x1A
movs r1, 0x40
bl get_mapheader_by_bank_and_number
bl Overworld_GetMapHeaderByGroupAndId
ldr r0, [r0, 0x4]
ldr r0, [r0, 0x8]
adds r0, 0x8
@ -30334,7 +30334,7 @@ _081D6162:
adds r0, r1
ldrh r1, [r0]
movs r0, 0x1A
bl get_mapheader_by_bank_and_number
bl Overworld_GetMapHeaderByGroupAndId
ldr r0, [r0, 0x4]
ldr r0, [r0, 0x8]
_081D6176:

View File

@ -44,7 +44,7 @@ _0813776C:
ldrb r0, [r2, 0x11]
orrs r1, r0
movs r0, 0x1
bl sav12_xor_set
bl SetGameStat
_0813778E:
bl sub_8076D48
ldr r0, =gSaveBlock2Ptr

View File

@ -376,7 +376,7 @@ _0813574C:
thumb_func_start hm2_dig
hm2_dig: @ 8135760
push {lr}
bl flagmods_08054D70
bl Overworld_ResetStateAfterDigEscRope
movs r0, 0x26
bl FieldEffectStart
bl GetCursorSelectionMonId

View File

@ -2570,7 +2570,7 @@ sub_8141800: @ 8141800
movs r0, 0x1E
ldrsh r1, [r4, r0]
movs r0, 0x1D
bl sav12_xor_set
bl SetGameStat
_08141848:
ldr r1, =sub_8141A18
ldr r2, =0x0000ffff

View File

@ -1287,12 +1287,12 @@ EverGrandeCity_HallOfFame_EventScript_271851:: @ 8271851
setvar VAR_0x40D3, 1
return
EverGrandeCity_HallOfFame_EventScript_271857:: @ 8271857
EventScript_WhiteOut:: @ 8271857
call EverGrandeCity_HallOfFame_EventScript_2718CC
goto EverGrandeCity_HallOfFame_EventScript_271862
goto EventScript_271862
end
EverGrandeCity_HallOfFame_EventScript_271862:: @ 8271862
EventScript_271862:: @ 8271862
compare VAR_0x4096, 1
goto_eq EverGrandeCity_HallOfFame_EventScript_271884
compare VAR_0x4096, 2

View File

@ -1,52 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
.align 2, 0
gUnknown_08339D3C:: @ 8339D3C
.4byte 0xFFFFFF, 0xFFFFFFFF, 0x4B0, 0xE10, 0x4B0, 0x960, 0x32, 0x50, 0xFFFFFFD4, 0x2C
gUnknown_08339D64:: @ 8339D64
.4byte 0, 0
.4byte 0, 1
.4byte 0, -1
.4byte -1, 0
.4byte 1, 0
.4byte -1, 1
.4byte 1, 1
.4byte -1, -1
.4byte 1, -1
gUnknown_08339DAC:: @ 8339DAC
.4byte 0x1F8
.4byte 0x11D1
.4byte 0x21C2
.4byte 0x31E3
gUnknown_08339DBC:: @ 8339DBC
.4byte REG_WIN0H
.4byte 0xa2600001
.byte 1, 0
.align 2
gUnknown_08339DC8:: @ 8339DC8
.4byte sub_80879D8
.4byte sub_80879F8
.4byte sub_80879FC
gUnknown_08339DD4:: @ 8339DD4
.4byte sub_8087A1C
.4byte sub_8087A20
.4byte sub_8087A20
.4byte sub_8087A20
.4byte sub_8087A20
.4byte sub_8087A1C
.4byte sub_8087A1C
.4byte sub_8087A88
.4byte sub_8087A88
.4byte sub_8087A88
.4byte sub_8087A88
gUnknown_08339E00:: @ 8339E00
.4byte sub_8087AA0
.4byte sub_8087AA8

View File

@ -51,9 +51,10 @@
#define GAME_STAT_USED_DAYCARE 47
#define GAME_STAT_RODE_CABLE_CAR 48
#define GAME_STAT_ENTERED_HOT_SPRINGS 49
#define GAME_STAT_50 50
#define GAME_STAT_51 51
/*TODO: add new stats added in Emerald*/
#define NUM_USED_GAME_STATS 52
#define NUM_GAME_STATS 64
#endif // GUARD_CONSTANTS_GAME_STAT_H

View File

@ -618,7 +618,7 @@ struct SaveBlock1
/*0x04*/ struct WarpData location;
/*0x0C*/ struct WarpData warp1;
/*0x14*/ struct WarpData warp2;
/*0x1C*/ struct WarpData warp3;
/*0x1C*/ struct WarpData lastHealLocation;
/*0x24*/ struct WarpData warp4;
/*0x2C*/ u16 battleMusic;
/*0x2E*/ u8 weather;
@ -705,6 +705,23 @@ struct SaveBlock1
extern struct SaveBlock1* gSaveBlock1Ptr;
struct MapPosition
{
s16 x;
s16 y;
u8 height;
};
struct UnkStruct_8054FF8
{
u8 a;
u8 b;
u8 c;
u8 d;
struct MapPosition sub;
u16 field_C;
};
struct Bitmap // TODO: Find a better spot for this
{
u8* pixels;

View File

@ -25,11 +25,49 @@ struct UCoords32
extern struct LinkPlayerMapObject gLinkPlayerMapObjects[4];
extern MainCallback gFieldCallback;
void DoWhiteOut(void);
void Overworld_ResetStateAfterFly(void);
void Overworld_ResetStateAfterTeleport(void);
void Overworld_ResetStateAfterDigEscRope(void);
void sub_8084788(void);
void ResetGameStats(void);
void IncrementGameStat(u8 index);
u32 GetGameStat(u8 index);
void SetGameStat(u8 index, u32 value);
void ApplyNewEncryptionKeyToGameStats(u32 newKey);
void LoadMapObjTemplatesFromHeader(void);
void LoadSaveblockMapObjScripts(void);
void Overworld_SetMapObjTemplateCoords(u8 localId, s16 x, s16 y);
void Overworld_SetMapObjTemplateMovementType(u8 localId, u8 movementType);
void mapdata_load_assets_to_gpu_and_full_redraw(void);
struct MapData *get_mapdata_header(void);
void ApplyCurrentWarp(void);
void set_warp2_warp3_to_neg_1(void);
void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
bool32 warp_data_is_not_neg_1(struct WarpData *warp);
struct MapHeader *const Overworld_GetMapHeaderByGroupAndId(u16 mapGroup, u16 mapNum);
struct MapHeader *const warp1_get_mapheader(void);
void set_current_map_header_from_sav1_save_old_name(void);
void LoadSaveblockMapHeader(void);
void update_camera_pos_from_warpid(void);
void warp_in(void);
void Overworld_SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
void warp1_set_2(s8 mapGroup, s8 mapNum, s8 warpId);
void saved_warp2_set(int unused, s8 mapGroup, s8 mapNum, s8 warpId);
void saved_warp2_set_2(int unused, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
void copy_saved_warp2_bank_and_enter_x_to_warp1(u8 unused);
void sub_8084CCC(u8 a1);
void Overworld_SetWarpDestToLastHealLoc(void);
void Overworld_SetHealLocationWarp(u8 healLocationId);
void sub_8084D5C(s16 a1, s16 a2);
void sub_8084DD4(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
// to erase later
u8 GetMapTypeByGroupAndId(s8 mapGroup, s8 mapNum);
u8 Overworld_GetMapTypeOfSaveblockLocation(void);
void Overworld_SetMapObjTemplateCoords(u8, s16, s16);
void Overworld_SetMapObjTemplateMovementType(u8, u8);
void Overworld_SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
void saved_warp2_set(int unused, s8 mapGroup, s8 mapNum, s8 warpId);
void saved_warp2_set_2(int unused, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
void Overworld_SetHealLocationWarp(u8);
@ -37,25 +75,18 @@ void sub_8084DD4(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y);
void sub_8084E2C(s8, s8, s8, s8, s8);
void sub_8084E80(s8, s8, s8, s8, s8);
void sub_8084EBC(s16, s16);
void player_avatar_init_params_reset(void);
bool8 Overworld_MapTypeAllowsTeleportAndFly(u8 mapType);
void Overworld_ResetStateAfterTeleport(void);
void Overworld_SetFlashLevel(s32 a1);
//u8 Overworld_GetFlashLevel(void);
void sub_8085524(u16);
void Overworld_SetSavedMusic(u16);
void Overworld_ChangeMusicToDefault(void);
void Overworld_ChangeMusicTo(u16);
bool32 is_c1_link_related_active(void);
extern u16 gUnknown_03005DA8;
void strange_npc_table_clear(void);
const struct MapHeader *get_mapheader_by_bank_and_number(u16, u16);
void FieldObjectMoveDestCoords(struct MapObject *, u32, s16 *, s16 *);
void sub_8086230(void);
void c2_exit_to_overworld_2_switch(void);
@ -71,13 +102,11 @@ void copy_saved_warp2_bank_and_enter_x_to_warp1(u8 unused);
void mapldr_default(void);
u8 get_map_light_from_warp0(void);
bool8 is_light_level_1_2_3_5_or_6(u8 a1);
bool32 sub_80875C8(void);
bool32 sub_8087634(void);
bool32 sub_808766C(void);
void IncrementGameStat(u8);
u32 GetGameStat(u8);
void CB2_OverworldBasic(void);
#endif //GUARD_ROM4_H

View File

@ -86,6 +86,7 @@ SECTIONS {
src/berry_blender.o(.text);
src/play_time.o(.text);
src/new_game.o(.text);
src/overworld.o(.text);
asm/overworld.o(.text);
asm/fieldmap.o(.text);
src/metatile_behavior.o(.text);
@ -393,7 +394,7 @@ SECTIONS {
data/trade.o(.rodata);
src/berry_blender.o(.rodata);
src/new_game.o(.rodata);
data/overworld.o(.rodata);
src/overworld.o(.rodata);
data/tilesets.o(.rodata);
data/maps.o(.rodata);
data/fieldmap.o(.rodata);

View File

@ -76,7 +76,7 @@ extern bool8 sub_81B1250(void); // ?
extern bool8 InBattlePike(void);
extern bool8 InBattlePyramid(void);
extern u16 GetBattlePyramidPickupItemId(void);
extern u8 sav1_map_get_light_level(void);
extern u8 Overworld_GetMapTypeOfSaveblockLocation(void);
extern u8 sub_813B21C(void);
extern u16 get_unknown_box_id(void);
@ -10578,7 +10578,7 @@ static void atkEF_handleballthrow(void)
ballMultiplier = 10;
break;
case ITEM_DIVE_BALL:
if (sav1_map_get_light_level() == 5)
if (Overworld_GetMapTypeOfSaveblockLocation() == 5)
ballMultiplier = 35;
else
ballMultiplier = 10;

View File

@ -1673,7 +1673,7 @@ struct MapObjectTemplate *GetFieldObjectTemplateByLocalIdAndMap(u8 localId, u8 m
}
else
{
mapHeader = get_mapheader_by_bank_and_number(mapGroup, mapNum);
mapHeader = Overworld_GetMapHeaderByGroupAndId(mapGroup, mapNum);
templates = mapHeader->events->mapObjects;
count = mapHeader->events->mapObjectCount;
}

View File

@ -85,7 +85,7 @@ extern void sub_81C59BC(void);
extern void sub_81AB9A8(u8);
extern void sub_81ABA88(u8);
extern void sub_80B7CC8(void);
extern void flagmods_08054D70(void);
extern void Overworld_ResetStateAfterDigEscRope(void);
extern u8* sub_806CF78(u16);
extern void sub_81B89F0(void);
extern u8 GetItemEffectType(u16);
@ -904,7 +904,7 @@ void task08_080A1C44(u8 taskId)
void re_escape_rope(u8 taskId)
{
flagmods_08054D70();
Overworld_ResetStateAfterDigEscRope();
sub_80FE058();
gTasks[taskId].data[0] = 0;
DisplayItemMessageOnField(taskId, gStringVar4, task08_080A1C44);

View File

@ -1,10 +1,82 @@
// Includes
#include "global.h"
#include "overworld.h"
#include "battle_setup.h"
#include "berry.h"
// #include "cable_club.h"
#include "clock.h"
#include "event_data.h"
#include "field_camera.h"
// #include "field_control_avatar.h"
#include "field_effect.h"
#include "field_fadetransition.h"
#include "field_ground_effect.h"
#include "field_map_obj.h"
#include "field_map_obj_helpers.h"
#include "field_message_box.h"
#include "field_player_avatar.h"
#include "field_screen_effect.h"
// #include "field_special_scene.h"
#include "field_specials.h"
#include "field_tasks.h"
#include "field_weather.h"
#include "fieldmap.h"
// #include "fldeff_flash.h"
#include "heal_location.h"
#include "link.h"
#include "load_save.h"
#include "main.h"
#include "m4a.h"
#include "constants/maps.h"
#include "map_name_popup.h"
#include "menu.h"
#include "metatile_behavior.h"
#include "new_game.h"
#include "palette.h"
#include "play_time.h"
#include "random.h"
#include "roamer.h"
// #include "rotating_gate.h"
#include "safari_zone.h"
#include "script.h"
// #include "script_pokemon_80C4.h"
#include "secret_base.h"
#include "constants/songs.h"
#include "sound.h"
#include "constants/species.h"
#include "start_menu.h"
#include "task.h"
// #include "tileset_anim.h"
#include "time_events.h"
#include "tv.h"
#include "scanline_effect.h"
#include "wild_encounter.h"
#include "bg.h"
#include "money.h"
// Static type declarations
// event scripts
extern const u8 EventScript_WhiteOut[];
extern const u8 EventScript_271862[];
// Static RAM declarations
// vars
extern struct MapData * const gMapAttributes[];
extern struct MapHeader * const * const gMapGroups[];
extern s32 gMaxFlashLevel;
// functions
extern void HealPlayerParty(void);
extern void move_tilemap_camera_to_upper_left_corner(void);
extern void cur_mapheader_run_tileset_funcs_after_some_cpuset(void);
extern void DrawWholeMapView(void);
extern void copy_map_tileset1_tileset2_to_vram(struct MapData *);
extern void apply_map_tileset1_tileset2_palette(struct MapData *);
extern void ResetCyclingRoadChallengeData(void);
extern void ApplyNewEncryptionKeyToWord(u32 *word, u32 newKey);
// this file's functions
static void Overworld_ResetStateAfterWhiteOut(void);
void ChooseAmbientCrySpecies(void);
// IWRAM bss vars
IWRAM_DATA void *gUnknown_03000E0C;
IWRAM_DATA u8 gUnknown_03000E10[4];
IWRAM_DATA u8 (*gUnknown_03000E14)(u32);
@ -12,8 +84,463 @@ IWRAM_DATA u8 gUnknown_03000E18;
IWRAM_DATA u8 gUnknown_03000E19;
IWRAM_DATA void *rom4_c_unused_03000e1c;
// Static ROM declarations
// EWRAM vars
EWRAM_DATA struct WarpData gUnknown_020322DC = {0};
EWRAM_DATA struct WarpData gWarpDestination = {0}; // new warp position
EWRAM_DATA struct WarpData gUnknown_020322EC = {0};
EWRAM_DATA struct WarpData gUnknown_020322F4 = {0};
EWRAM_DATA u16 gLastMapSectionId = 0;
// EWRAM_DATA struct UnkPlayerStruct gUnknown_02029810 = {0};
// EWRAM_DATA u16 sAmbientCrySpecies = 0;
// EWRAM_DATA bool8 sIsAmbientCryWaterMon = FALSE;
// EWRAM_DATA struct LinkPlayerMapObject gLinkPlayerMapObjects[4] = {0};
// .rodata
// const rom data
const struct WarpData sDummyWarpData =
{
.mapGroup = -1,
.mapNum = -1,
.warpId = -1,
.x = -1,
.y = -1,
};
// .text
const u8 sUnusedData[] =
{
0xB0, 0x04, 0x00, 0x00,
0x10, 0x0E, 0x00, 0x00,
0xB0, 0x04, 0x00, 0x00,
0x60, 0x09, 0x00, 0x00,
0x32, 0x00, 0x00, 0x00,
0x50, 0x00, 0x00, 0x00,
0xD4, 0xFF, 0xFF, 0xFF,
0x2C, 0x00, 0x00, 0x00,
};
const struct UCoords32 gUnknown_08339D64[] =
{
{ 0, 0},
{ 0, 1},
{ 0, -1},
{-1, 0},
{ 1, 0},
{-1, 1},
{ 1, 1},
{-1, -1},
{ 1, -1},
};
const struct BgTemplate gUnknown_08339DAC[] =
{
{
.bg = 0,
.charBaseIndex = 2,
.mapBaseIndex = 31,
.screenSize = 0,
.paletteMode = 0,
.priority = 0,
.baseTile = 0
},
{
.bg = 1,
.charBaseIndex = 0,
.mapBaseIndex = 29,
.screenSize = 0,
.paletteMode = 0,
.priority = 1,
.baseTile = 0
},
{
.bg = 2,
.charBaseIndex = 0,
.mapBaseIndex = 28,
.screenSize = 0,
.paletteMode = 0,
.priority = 2,
.baseTile = 0
},
{
.bg = 3,
.charBaseIndex = 0,
.mapBaseIndex = 30,
.screenSize = 0,
.paletteMode = 0,
.priority = 3,
.baseTile = 0
}
};
const struct ScanlineEffectParams gUnknown_08339DBC =
{
(void *)REG_ADDR_WIN0H,
((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1,
1,
0,
};
u8 sub_80879D8(struct LinkPlayerMapObject *, struct MapObject *, u8);
u8 sub_80879F8(struct LinkPlayerMapObject *, struct MapObject *, u8);
u8 sub_80879FC(struct LinkPlayerMapObject *, struct MapObject *, u8);
u8 (*const gUnknown_08339DC8[])(struct LinkPlayerMapObject *, struct MapObject *, u8) =
{
sub_80879D8,
sub_80879F8,
sub_80879FC,
};
u8 sub_8087A1C(struct LinkPlayerMapObject *, struct MapObject *, u8);
u8 sub_8087A20(struct LinkPlayerMapObject *, struct MapObject *, u8);
u8 sub_8087A88(struct LinkPlayerMapObject *, struct MapObject *, u8);
u8 (*const gUnknown_08339DD4[])(struct LinkPlayerMapObject *, struct MapObject *, u8) =
{
sub_8087A1C,
sub_8087A20,
sub_8087A20,
sub_8087A20,
sub_8087A20,
sub_8087A1C,
sub_8087A1C,
sub_8087A88,
sub_8087A88,
sub_8087A88,
sub_8087A88,
};
void sub_8087AA0(struct LinkPlayerMapObject *, struct MapObject *);
void sub_8087AA8(struct LinkPlayerMapObject *, struct MapObject *);
void (*const gUnknown_08339E00[])(struct LinkPlayerMapObject *, struct MapObject *) =
{
sub_8087AA0,
sub_8087AA8,
};
// code
void DoWhiteOut(void)
{
ScriptContext2_RunNewScript(EventScript_WhiteOut);
SetMoney(&gSaveBlock1Ptr->money, GetMoney(&gSaveBlock1Ptr->money) / 2);
HealPlayerParty();
Overworld_ResetStateAfterWhiteOut();
Overworld_SetWarpDestToLastHealLoc();
warp_in();
}
void Overworld_ResetStateAfterFly(void)
{
player_avatar_init_params_reset();
FlagClear(FLAG_SYS_CYCLING_ROAD);
FlagClear(FLAG_SYS_CRUISE_MODE);
FlagClear(FLAG_SYS_SAFARI_MODE);
FlagClear(FLAG_SYS_USE_STRENGTH);
FlagClear(FLAG_SYS_USE_FLASH);
}
void Overworld_ResetStateAfterTeleport(void)
{
player_avatar_init_params_reset();
FlagClear(FLAG_SYS_CYCLING_ROAD);
FlagClear(FLAG_SYS_CRUISE_MODE);
FlagClear(FLAG_SYS_SAFARI_MODE);
FlagClear(FLAG_SYS_USE_STRENGTH);
FlagClear(FLAG_SYS_USE_FLASH);
ScriptContext2_RunNewScript(EventScript_271862);
}
void Overworld_ResetStateAfterDigEscRope(void)
{
player_avatar_init_params_reset();
FlagClear(FLAG_SYS_CYCLING_ROAD);
FlagClear(FLAG_SYS_CRUISE_MODE);
FlagClear(FLAG_SYS_SAFARI_MODE);
FlagClear(FLAG_SYS_USE_STRENGTH);
FlagClear(FLAG_SYS_USE_FLASH);
}
static void Overworld_ResetStateAfterWhiteOut(void)
{
player_avatar_init_params_reset();
FlagClear(FLAG_SYS_CYCLING_ROAD);
FlagClear(FLAG_SYS_CRUISE_MODE);
FlagClear(FLAG_SYS_SAFARI_MODE);
FlagClear(FLAG_SYS_USE_STRENGTH);
FlagClear(FLAG_SYS_USE_FLASH);
if (VarGet(VAR_0x4039) == 1)
{
VarSet(VAR_0x4039, 0);
VarSet(VAR_0x4037, 0);
}
}
void sub_8084788(void)
{
FlagClear(FLAG_SYS_SAFARI_MODE);
ChooseAmbientCrySpecies();
ResetCyclingRoadChallengeData();
UpdateLocationHistoryForRoamer();
RoamerMoveToOtherLocationSet();
}
void ResetGameStats(void)
{
s32 i;
for (i = 0; i < NUM_GAME_STATS; i++)
SetGameStat(i, 0);
}
void IncrementGameStat(u8 index)
{
if (index < NUM_USED_GAME_STATS)
{
u32 statVal = GetGameStat(index);
if (statVal < 0xFFFFFF)
statVal++;
else
statVal = 0xFFFFFF;
SetGameStat(index, statVal);
}
}
u32 GetGameStat(u8 index)
{
if (index >= NUM_USED_GAME_STATS)
return 0;
return gSaveBlock1Ptr->gameStats[index] ^ gSaveBlock2Ptr->encryptionKey;
}
void SetGameStat(u8 index, u32 value)
{
if (index < NUM_USED_GAME_STATS)
gSaveBlock1Ptr->gameStats[index] = value ^ gSaveBlock2Ptr->encryptionKey;
}
void ApplyNewEncryptionKeyToGameStats(u32 newKey)
{
u8 i;
for (i = 0; i < NUM_GAME_STATS; i++)
ApplyNewEncryptionKeyToWord(&gSaveBlock1Ptr->gameStats[i], newKey);
}
void LoadMapObjTemplatesFromHeader(void)
{
// Clear map object templates
CpuFill32(0, gSaveBlock1Ptr->mapObjectTemplates, sizeof(gSaveBlock1Ptr->mapObjectTemplates));
// Copy map header events to save block
CpuCopy32(gMapHeader.events->mapObjects,
gSaveBlock1Ptr->mapObjectTemplates,
gMapHeader.events->mapObjectCount * sizeof(struct MapObjectTemplate));
}
void LoadSaveblockMapObjScripts(void)
{
struct MapObjectTemplate *mapHeaderObjTemplates = gMapHeader.events->mapObjects;
struct MapObjectTemplate *savObjTemplates = gSaveBlock1Ptr->mapObjectTemplates;
s32 i;
for (i = 0; i < 64; i++)
savObjTemplates[i].script = mapHeaderObjTemplates[i].script;
}
void Overworld_SetMapObjTemplateCoords(u8 localId, s16 x, s16 y)
{
s32 i;
struct MapObjectTemplate *savObjTemplates = gSaveBlock1Ptr->mapObjectTemplates;
for (i = 0; i < 64; i++)
{
struct MapObjectTemplate *mapObjectTemplate = &savObjTemplates[i];
if (mapObjectTemplate->localId == localId)
{
mapObjectTemplate->x = x;
mapObjectTemplate->y = y;
return;
}
}
}
void Overworld_SetMapObjTemplateMovementType(u8 localId, u8 movementType)
{
s32 i;
struct MapObjectTemplate *savObjTemplates = gSaveBlock1Ptr->mapObjectTemplates;
for (i = 0; i < 64; i++)
{
struct MapObjectTemplate *mapObjectTemplate = &savObjTemplates[i];
if (mapObjectTemplate->localId == localId)
{
mapObjectTemplate->movementType = movementType;
return;
}
}
}
void mapdata_load_assets_to_gpu_and_full_redraw(void)
{
move_tilemap_camera_to_upper_left_corner();
copy_map_tileset1_tileset2_to_vram(gMapHeader.mapData);
apply_map_tileset1_tileset2_palette(gMapHeader.mapData);
DrawWholeMapView();
cur_mapheader_run_tileset_funcs_after_some_cpuset();
}
struct MapData *get_mapdata_header(void)
{
u16 mapDataId = gSaveBlock1Ptr->mapDataId;
if (mapDataId)
return gMapAttributes[mapDataId - 1];
return NULL;
}
void ApplyCurrentWarp(void)
{
gUnknown_020322DC = gSaveBlock1Ptr->location;
gSaveBlock1Ptr->location = gWarpDestination;
gUnknown_020322EC = sDummyWarpData;
gUnknown_020322F4 = sDummyWarpData;
}
void set_warp2_warp3_to_neg_1(void)
{
gUnknown_020322EC = sDummyWarpData;
gUnknown_020322F4 = sDummyWarpData;
}
void SetWarpData(struct WarpData *warp, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
{
warp->mapGroup = mapGroup;
warp->mapNum = mapNum;
warp->warpId = warpId;
warp->x = x;
warp->y = y;
}
bool32 warp_data_is_not_neg_1(struct WarpData *warp)
{
if (warp->mapGroup != -1)
return FALSE;
if (warp->mapNum != -1)
return FALSE;
if (warp->warpId != -1)
return FALSE;
if (warp->x != -1)
return FALSE;
if (warp->y != -1)
return FALSE;
return TRUE;
}
struct MapHeader *const Overworld_GetMapHeaderByGroupAndId(u16 mapGroup, u16 mapNum)
{
return gMapGroups[mapGroup][mapNum];
}
struct MapHeader *const warp1_get_mapheader(void)
{
return Overworld_GetMapHeaderByGroupAndId(gWarpDestination.mapGroup, gWarpDestination.mapNum);
}
void set_current_map_header_from_sav1_save_old_name(void)
{
gLastMapSectionId = gMapHeader.regionMapSectionId;
gMapHeader = *Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum);
gSaveBlock1Ptr->mapDataId = gMapHeader.mapDataId;
gMapHeader.mapData = get_mapdata_header();
}
void LoadSaveblockMapHeader(void)
{
gMapHeader = *Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum);
gMapHeader.mapData = get_mapdata_header();
}
void update_camera_pos_from_warpid(void)
{
if (gSaveBlock1Ptr->location.warpId >= 0 && gSaveBlock1Ptr->location.warpId < gMapHeader.events->warpCount)
{
gSaveBlock1Ptr->pos.x = gMapHeader.events->warps[gSaveBlock1Ptr->location.warpId].x;
gSaveBlock1Ptr->pos.y = gMapHeader.events->warps[gSaveBlock1Ptr->location.warpId].y;
}
else if (gSaveBlock1Ptr->location.x >= 0 && gSaveBlock1Ptr->location.y >= 0)
{
gSaveBlock1Ptr->pos.x = gSaveBlock1Ptr->location.x;
gSaveBlock1Ptr->pos.y = gSaveBlock1Ptr->location.y;
}
else
{
gSaveBlock1Ptr->pos.x = gMapHeader.mapData->width / 2;
gSaveBlock1Ptr->pos.y = gMapHeader.mapData->height / 2;
}
}
void warp_in(void)
{
ApplyCurrentWarp();
set_current_map_header_from_sav1_save_old_name();
update_camera_pos_from_warpid();
}
void Overworld_SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
{
SetWarpData(&gWarpDestination, mapGroup, mapNum, warpId, x, y);
}
void warp1_set_2(s8 mapGroup, s8 mapNum, s8 warpId)
{
Overworld_SetWarpDestination(mapGroup, mapNum, warpId, -1, -1);
}
void saved_warp2_set(int unused, s8 mapGroup, s8 mapNum, s8 warpId)
{
SetWarpData(&gSaveBlock1Ptr->warp2, mapGroup, mapNum, warpId, gSaveBlock1Ptr->pos.x, gSaveBlock1Ptr->pos.y);
}
void saved_warp2_set_2(int unused, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
{
SetWarpData(&gSaveBlock1Ptr->warp2, mapGroup, mapNum, warpId, x, y);
}
void copy_saved_warp2_bank_and_enter_x_to_warp1(u8 unused)
{
gWarpDestination = gSaveBlock1Ptr->warp2;
}
void sub_8084CCC(u8 a1)
{
const struct HealLocation *warp = GetHealLocationPointer(a1);
if (warp)
Overworld_SetWarpDestination(warp->group, warp->map, -1, warp->x, warp->y);
}
void Overworld_SetWarpDestToLastHealLoc(void)
{
gWarpDestination = gSaveBlock1Ptr->lastHealLocation;
}
void Overworld_SetHealLocationWarp(u8 healLocationId)
{
const struct HealLocation *healLocation = GetHealLocationPointer(healLocationId);
if (healLocation != NULL)
SetWarpData(&gSaveBlock1Ptr->lastHealLocation, healLocation->group, healLocation->map, -1, healLocation->x, healLocation->y);
}
void sub_8084D5C(s16 a1, s16 a2)
{
u8 currMapType = Overworld_GetMapTypeOfSaveblockLocation();
u8 destMapType = GetMapTypeByGroupAndId(gWarpDestination.mapGroup, gWarpDestination.mapNum);
if (is_light_level_1_2_3_5_or_6(currMapType) && is_light_level_1_2_3_5_or_6(destMapType) != TRUE)
sub_8084DD4(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, a1 - 7, a2 - 6);
}
void sub_8084DD4(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
{
SetWarpData(&gSaveBlock1Ptr->warp4, mapGroup, mapNum, warpId, x, y);
}

View File

@ -881,7 +881,7 @@ static void RegionMap_InitializeStateBasedOnPlayerLocation(void)
return;
}
switch (get_map_light_level_by_bank_and_number(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum))
switch (GetMapTypeByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum))
{
default:
case 1:
@ -904,7 +904,7 @@ static void RegionMap_InitializeStateBasedOnPlayerLocation(void)
case 7:
if (gMapHeader.flags & 0x02)
{
mapHeader = get_mapheader_by_bank_and_number(gSaveBlock1Ptr->warp4.mapGroup, gSaveBlock1Ptr->warp4.mapNum);
mapHeader = Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->warp4.mapGroup, gSaveBlock1Ptr->warp4.mapNum);
gRegionMap->mapSecId = mapHeader->regionMapSectionId;
gRegionMap->playerIsInCave = TRUE;
mapWidth = mapHeader->mapData->width;
@ -923,7 +923,7 @@ static void RegionMap_InitializeStateBasedOnPlayerLocation(void)
}
break;
case 9:
mapHeader = get_mapheader_by_bank_and_number((u16)gSaveBlock1Ptr->warp2.mapGroup, (u16)gSaveBlock1Ptr->warp2.mapNum);
mapHeader = Overworld_GetMapHeaderByGroupAndId((u16)gSaveBlock1Ptr->warp2.mapGroup, (u16)gSaveBlock1Ptr->warp2.mapNum);
gRegionMap->mapSecId = mapHeader->regionMapSectionId;
gRegionMap->playerIsInCave = TRUE;
mapWidth = mapHeader->mapData->width;
@ -937,12 +937,12 @@ static void RegionMap_InitializeStateBasedOnPlayerLocation(void)
if (gRegionMap->mapSecId != MAPSEC_DYNAMIC)
{
storedWarp = &gSaveBlock1Ptr->warp4;
mapHeader = get_mapheader_by_bank_and_number(storedWarp->mapGroup, storedWarp->mapNum);
mapHeader = Overworld_GetMapHeaderByGroupAndId(storedWarp->mapGroup, storedWarp->mapNum);
}
else
{
storedWarp = &gSaveBlock1Ptr->warp2;
mapHeader = get_mapheader_by_bank_and_number(storedWarp->mapGroup, storedWarp->mapNum);
mapHeader = Overworld_GetMapHeaderByGroupAndId(storedWarp->mapGroup, storedWarp->mapNum);
gRegionMap->mapSecId = mapHeader->regionMapSectionId;
}
if (RegionMap_IsPlayerInCave(gRegionMap->mapSecId))
@ -1065,7 +1065,7 @@ static void RegionMap_InitializeStateBasedOnSSTidalLocation(void)
break;
default:
case 0:
mapHeader = get_mapheader_by_bank_and_number(mapGroup, mapNum);
mapHeader = Overworld_GetMapHeaderByGroupAndId(mapGroup, mapNum);
gRegionMap->mapSecId = mapHeader->regionMapSectionId;
dimensionScale = mapHeader->mapData->width / gRegionMapEntries[gRegionMap->mapSecId].width;

View File

@ -214,21 +214,9 @@ gUnknown_020322D5: @ 20322D5
gUnknown_020322D8: @ 20322D8
.space 0x4
gUnknown_020322DC: @ 20322DC
.space 0x8
gUnknown_020322E4: @ 20322E4
.space 0x8
gUnknown_020322EC: @ 20322EC
.space 0x8
gUnknown_020322F4: @ 20322F4
.space 0x8
gUnknown_020322FC: @ 20322FC
.space 0x4
.include "src/overworld.o"
.align 2
gUnknown_02032300: @ 2032300
.space 0x4