Decompile field camera

This commit is contained in:
KDSKardabox 2018-04-18 17:42:41 +05:30
parent b818924feb
commit 7700fe61fe
15 changed files with 537 additions and 1202 deletions

File diff suppressed because it is too large Load Diff

View File

@ -63,6 +63,10 @@ enum
ACRO_TRANS_WHEELIE_LOWERING_MOVING,
};
// Exported RAM declarations
extern bool8 gUnusedBikeCameraAheadPanback;
// Exported ROM declarations
void MovePlayerOnBike(u8 direction, u16 newKeys, u16 heldKeys);
void Bike_TryAcroBikeHistoryUpdate(u16 newKeys, u16 heldKeys);
bool8 RS_IsRunningDisallowed(u8 tile);

View File

@ -6,22 +6,19 @@
struct CameraObject
{
void (*callback)(struct CameraObject *);
u32 unk4;
u32 spriteId;
s32 unk8;
s32 unkC;
s32 x;
s32 y;
};
extern struct CameraObject gUnknown_03005DD0;
// Exported RAM declarations
extern struct CameraObject gUnknown_03005DD0;
extern u16 gUnknown_03005DEC;
extern u16 gUnknown_03005DE8;
// Exported ROM declarations
void DrawWholeMapView(void);
void CurrentMapDrawMetatileAt(int x, int y);
void sub_8089C08(s16 *a0, s16 *a1);

View File

@ -91,6 +91,8 @@ void sub_808F23C(const struct MapObject *mapObject, u8 movementType);
void sub_808F208(const struct MapObject *mapObject);
void npc_coords_shift_still(struct MapObject *pObject);
void FieldObjectMoveDestCoords(struct MapObject *pObject, u32 unk_19, s16 *pInt, s16 *pInt1);
u8 AddCameraObject(u8 linkedSpriteId);
void UpdateFieldObjectsForCameraUpdate(s16 x, s16 y);
// Exported data declarations

View File

@ -16,5 +16,7 @@ s32 GetMapBorderIdAt(s16, s16);
bool32 CanCameraMoveInDirection(u8);
u16 GetBehaviorByMetatileId(u16 metatileId);
void sav1_camera_get_focus_coords(u16 *x, u16 *y);
u8 MapGridGetMetatileLayerTypeAt(s32 x, s32 y);
u8 CameraMove(s32 deltaX, s32 deltaY);
#endif //GUARD_FIELDMAP_H

View File

@ -15,9 +15,15 @@ struct LinkPlayerMapObject
u8 mode;
};
// Exported RAM declarations
extern struct WarpData gUnknown_020322DC;
extern struct LinkPlayerMapObject gLinkPlayerMapObjects[4];
extern u16 *gBGTilemapBuffers1;
extern u16 *gBGTilemapBuffers2;
extern u16 *gBGTilemapBuffers3;
// Exported ROM declarations
extern const struct UCoords32 gUnknown_08339D64[];
void DoWhiteOut(void);

8
include/rotating_gate.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef GUARD_ROTATING_GATE_H
#define GUARD_ROTATING_GATE_H
void RotatingGatePuzzleCameraUpdate(s16, s16);
void RotatingGate_InitPuzzleAndGraphics();
u32 CheckForRotatingGatePuzzleCollision(u8, s16, s16);
#endif // GUARD_ROTATING_GATE_H

View File

@ -89,7 +89,7 @@ SECTIONS {
src/overworld.o(.text);
asm/fieldmap.o(.text);
src/metatile_behavior.o(.text);
asm/field_camera.o(.text);
src/field_camera.o(.text);
src/field_door.o(.text);
asm/field_player_avatar.o(.text);
src/field_map_obj.o(.text);

View File

@ -12,7 +12,6 @@
extern bool8 gBikeCyclingChallenge;
extern u8 gBikeCollisions;
extern bool8 gUnknown_02037348;
extern u8 sub_8093514(u8 direction);
extern u8 sub_808B980(u8 direction);
@ -989,7 +988,7 @@ bool8 player_should_look_direction_be_enforced_upon_movement(void)
void GetOnOffBike(u8 transitionFlags)
{
gUnknown_02037348 = FALSE;
gUnusedBikeCameraAheadPanback = FALSE;
if (gPlayerAvatar.flags & (PLAYER_AVATAR_FLAG_MACH_BIKE | PLAYER_AVATAR_FLAG_ACRO_BIKE))
{

View File

@ -1305,12 +1305,12 @@ void sub_8128060(u8 taskId)
void ConfigureCameraObjectForPlacingDecoration(struct PlaceDecorationGraphicsDataBuffer *data, u8 decor)
{
sDecor_CameraSpriteObjectIdx1 = gSprites[gUnknown_03005DD0.unk4].data[0];
gUnknown_03005DD0.unk4 = gpu_pal_decompress_alloc_tag_and_upload(data, decor);
gSprites[gUnknown_03005DD0.unk4].oam.priority = 1;
gSprites[gUnknown_03005DD0.unk4].callback = sub_81292D0;
gSprites[gUnknown_03005DD0.unk4].pos1.x = gUnknown_085A7250[data->decoration->shape].x;
gSprites[gUnknown_03005DD0.unk4].pos1.y = gUnknown_085A7250[data->decoration->shape].y;
sDecor_CameraSpriteObjectIdx1 = gSprites[gUnknown_03005DD0.spriteId].data[0];
gUnknown_03005DD0.spriteId = gpu_pal_decompress_alloc_tag_and_upload(data, decor);
gSprites[gUnknown_03005DD0.spriteId].oam.priority = 1;
gSprites[gUnknown_03005DD0.spriteId].callback = sub_81292D0;
gSprites[gUnknown_03005DD0.spriteId].pos1.x = gUnknown_085A7250[data->decoration->shape].x;
gSprites[gUnknown_03005DD0.spriteId].pos1.y = gUnknown_085A7250[data->decoration->shape].y;
}
void SetUpPlacingDecorationPlayerAvatar(u8 taskId, struct PlaceDecorationGraphicsDataBuffer *data)
@ -1332,7 +1332,7 @@ void SetUpPlacingDecorationPlayerAvatar(u8 taskId, struct PlaceDecorationGraphic
}
gSprites[sDecor_CameraSpriteObjectIdx2].oam.priority = 1;
DestroySprite(&gSprites[sDecor_CameraSpriteObjectIdx1]);
sDecor_CameraSpriteObjectIdx1 = gUnknown_03005DD0.unk4;
sDecor_CameraSpriteObjectIdx1 = gUnknown_03005DD0.spriteId;
}
void sub_812826C(u8 taskId)
@ -2251,9 +2251,9 @@ bool8 sub_81299AC(u8 taskId)
void SetUpPuttingAwayDecorationPlayerAvatar(void)
{
player_get_direction_lower_nybble();
sDecor_CameraSpriteObjectIdx1 = gSprites[gUnknown_03005DD0.unk4].data[0];
sDecor_CameraSpriteObjectIdx1 = gSprites[gUnknown_03005DD0.spriteId].data[0];
sub_812A39C();
gUnknown_03005DD0.unk4 = CreateSprite(&gUnknown_085A7404, 0x78, 0x50, 0);
gUnknown_03005DD0.spriteId = CreateSprite(&gUnknown_085A7404, 0x78, 0x50, 0);
if (gSaveBlock2Ptr->playerGender == MALE)
{
sDecor_CameraSpriteObjectIdx2 = AddPseudoFieldObject(0xC1, SpriteCallbackDummy, 0x88, 0x48, 0);
@ -2264,7 +2264,7 @@ void SetUpPuttingAwayDecorationPlayerAvatar(void)
}
gSprites[sDecor_CameraSpriteObjectIdx2].oam.priority = 1;
DestroySprite(&gSprites[sDecor_CameraSpriteObjectIdx1]);
sDecor_CameraSpriteObjectIdx1 = gUnknown_03005DD0.unk4;
sDecor_CameraSpriteObjectIdx1 = gUnknown_03005DD0.spriteId;
gSprites[sDecor_CameraSpriteObjectIdx1].oam.priority = 1;
}

View File

@ -1,9 +1,18 @@
// Includes
#include "global.h"
#include "berry.h"
#include "bike.h"
#include "field_camera.h"
#include "field_player_avatar.h"
#include "fieldmap.h"
#include "field_map_obj.h"
#include "gpu_regs.h"
#include "menu.h"
#include "overworld.h"
#include "rotating_gate.h"
#include "sprite.h"
#include "text.h"
// Static type declarations
struct FieldCameraUnknownStruct
{
u8 unk0;
@ -13,16 +22,474 @@ struct FieldCameraUnknownStruct
bool8 unk4;
};
// Static RAM declarations
// static functions
static void RedrawMapSliceNorth(struct FieldCameraUnknownStruct *a, const struct MapData *mapData);
static void RedrawMapSliceSouth(struct FieldCameraUnknownStruct *a, const struct MapData *mapData);
static void RedrawMapSliceEast(struct FieldCameraUnknownStruct *a, const struct MapData *mapData);
static void RedrawMapSliceWest(struct FieldCameraUnknownStruct *a, const struct MapData *mapData);
static s32 MapPosToBgTilemapOffset(struct FieldCameraUnknownStruct *a, s32 x, s32 y);
static void DrawWholeMapViewInternal(int x, int y, const struct MapData *mapData);
static void DrawMetatileAt(const struct MapData *mapData, u16, int, int);
static void DrawMetatile(s32 a, u16 *b, u16 c);
static void CameraPanningCB_PanAhead(void);
IWRAM_DATA struct FieldCameraUnknownStruct gUnknown_03000E20;
IWRAM_DATA s16 gUnknown_03000E28;
IWRAM_DATA s16 gUnknown_03000E2A;
IWRAM_DATA u8 gUnknown_03000E2C;
IWRAM_DATA void (*gUnknown_03000E30)(void);
// IWRAM bss vars
static IWRAM_DATA struct FieldCameraUnknownStruct gUnknown_03000E20;
static IWRAM_DATA s16 gUnknown_03000E28;
static IWRAM_DATA s16 gUnknown_03000E2A;
static IWRAM_DATA u8 gUnknown_03000E2C;
static IWRAM_DATA void (*gUnknown_03000E30)(void);
// Static ROM declarations
// text
static void move_tilemap_camera_to_upper_left_corner_(struct FieldCameraUnknownStruct *a)
{
a->unk2 = 0;
a->unk3 = 0;
a->unk0 = 0;
a->unk1 = 0;
a->unk4 = TRUE;
}
// .rodata
static void tilemap_move_something(struct FieldCameraUnknownStruct *a, u32 b, u32 c)
{
a->unk2 += b;
a->unk2 %= 32;
a->unk3 += c;
a->unk3 %= 32;
}
static void coords8_add(struct FieldCameraUnknownStruct *a, u32 b, u32 c)
{
a->unk0 += b;
a->unk1 += c;
}
void move_tilemap_camera_to_upper_left_corner(void)
{
move_tilemap_camera_to_upper_left_corner_(&gUnknown_03000E20);
}
void FieldUpdateBgTilemapScroll(void)
{
u32 r4, r5;
r5 = gUnknown_03000E20.unk0 + gUnknown_03000E28;
r4 = gUnknown_03000E2A + gUnknown_03000E20.unk1 + 8;
SetGpuReg(REG_OFFSET_BG1HOFS, r5);
SetGpuReg(REG_OFFSET_BG1VOFS, r4);
SetGpuReg(REG_OFFSET_BG2HOFS, r5);
SetGpuReg(REG_OFFSET_BG2VOFS, r4);
SetGpuReg(REG_OFFSET_BG3HOFS, r5);
SetGpuReg(REG_OFFSET_BG3VOFS, r4);
}
void sub_8089C08(s16 *a, s16 *b)
{
*a = gUnknown_03000E20.unk0 + gUnknown_03000E28;
*b = gUnknown_03000E20.unk1 + gUnknown_03000E2A + 8;
}
void DrawWholeMapView(void)
{
DrawWholeMapViewInternal(gSaveBlock1Ptr->pos.x, gSaveBlock1Ptr->pos.y, gMapHeader.mapData);
gUnknown_03000E20.unk4 = TRUE;
}
static void DrawWholeMapViewInternal(int x, int y, const struct MapData *mapData)
{
u8 i;
u8 j;
u32 r6;
u8 temp;
for (i = 0; i < 32; i += 2)
{
temp = gUnknown_03000E20.unk3 + i;
if (temp >= 32)
temp -= 32;
r6 = temp * 32;
for (j = 0; j < 32; j += 2)
{
temp = gUnknown_03000E20.unk2 + j;
if (temp >= 32)
temp -= 32;
DrawMetatileAt(mapData, r6 + temp, x + j / 2, y + i / 2);
}
}
}
static void RedrawMapSlicesForCameraUpdate(struct FieldCameraUnknownStruct *a, int x, int y)
{
const struct MapData *mapData = gMapHeader.mapData;
if (x > 0)
RedrawMapSliceWest(a, mapData);
if (x < 0)
RedrawMapSliceEast(a, mapData);
if (y > 0)
RedrawMapSliceNorth(a, mapData);
if (y < 0)
RedrawMapSliceSouth(a, mapData);
a->unk4 = TRUE;
}
static void RedrawMapSliceNorth(struct FieldCameraUnknownStruct *a, const struct MapData *mapData)
{
u8 i;
u8 temp;
u32 r7;
temp = a->unk3 + 28;
if (temp >= 32)
temp -= 32;
r7 = temp * 32;
for (i = 0; i < 32; i += 2)
{
temp = a->unk2 + i;
if (temp >= 32)
temp -= 32;
DrawMetatileAt(mapData, r7 + temp, gSaveBlock1Ptr->pos.x + i / 2, gSaveBlock1Ptr->pos.y + 14);
}
}
static void RedrawMapSliceSouth(struct FieldCameraUnknownStruct *a, const struct MapData *mapData)
{
u8 i;
u8 temp;
u32 r7 = a->unk3 * 32;
for (i = 0; i < 32; i += 2)
{
temp = a->unk2 + i;
if (temp >= 32)
temp -= 32;
DrawMetatileAt(mapData, r7 + temp, gSaveBlock1Ptr->pos.x + i / 2, gSaveBlock1Ptr->pos.y);
}
}
static void RedrawMapSliceEast(struct FieldCameraUnknownStruct *a, const struct MapData *mapData)
{
u8 i;
u8 temp;
u32 r6 = a->unk2;
for (i = 0; i < 32; i += 2)
{
temp = a->unk3 + i;
if (temp >= 32)
temp -= 32;
DrawMetatileAt(mapData, temp * 32 + r6, gSaveBlock1Ptr->pos.x, gSaveBlock1Ptr->pos.y + i / 2);
}
}
static void RedrawMapSliceWest(struct FieldCameraUnknownStruct *a, const struct MapData *mapData)
{
u8 i;
u8 temp;
u8 r5 = a->unk2 + 28;
if (r5 >= 32)
r5 -= 32;
for (i = 0; i < 32; i += 2)
{
temp = a->unk3 + i;
if (temp >= 32)
temp -= 32;
DrawMetatileAt(mapData, temp * 32 + r5, gSaveBlock1Ptr->pos.x + 14, gSaveBlock1Ptr->pos.y + i / 2);
}
}
void CurrentMapDrawMetatileAt(int a, int b)
{
int offset = MapPosToBgTilemapOffset(&gUnknown_03000E20, a, b);
if (offset >= 0)
{
DrawMetatileAt(gMapHeader.mapData, offset, a, b);
gUnknown_03000E20.unk4 = TRUE;
}
}
void DrawDoorMetatileAt(int x, int y, u16 *arr)
{
int offset = MapPosToBgTilemapOffset(&gUnknown_03000E20, x, y);
if (offset >= 0)
{
DrawMetatile(1, arr, offset);
gUnknown_03000E20.unk4 = TRUE;
}
}
static void DrawMetatileAt(const struct MapData *mapData, u16 b, int c, int d)
{
u16 metatileId = MapGridGetMetatileIdAt(c, d);
u16 *metatiles;
if (metatileId > 1024)
metatileId = 0;
if (metatileId < 512)
metatiles = mapData->primaryTileset->metatiles;
else
{
metatiles = mapData->secondaryTileset->metatiles;
metatileId -= 512;
}
DrawMetatile(MapGridGetMetatileLayerTypeAt(c, d), metatiles + metatileId * 8, b);
}
static void DrawMetatile(s32 a, u16 *b, u16 c)
{
switch (a)
{
case 2:
gBGTilemapBuffers3[c] = b[0];
gBGTilemapBuffers3[c + 1] = b[1];
gBGTilemapBuffers3[c + 0x20] = b[2];
gBGTilemapBuffers3[c + 0x21] = b[3];
gBGTilemapBuffers1[c] = 0;
gBGTilemapBuffers1[c + 1] = 0;
gBGTilemapBuffers1[c + 0x20] = 0;
gBGTilemapBuffers1[c + 0x21] = 0;
gBGTilemapBuffers2[c] = b[4];
gBGTilemapBuffers2[c + 1] = b[5];
gBGTilemapBuffers2[c + 0x20] = b[6];
gBGTilemapBuffers2[c + 0x21] = b[7];
break;
case 1:
gBGTilemapBuffers3[c] = b[0];
gBGTilemapBuffers3[c + 1] = b[1];
gBGTilemapBuffers3[c + 0x20] = b[2];
gBGTilemapBuffers3[c + 0x21] = b[3];
gBGTilemapBuffers1[c] = b[4];
gBGTilemapBuffers1[c + 1] = b[5];
gBGTilemapBuffers1[c + 0x20] = b[6];
gBGTilemapBuffers1[c + 0x21] = b[7];
gBGTilemapBuffers2[c] = 0;
gBGTilemapBuffers2[c + 1] = 0;
gBGTilemapBuffers2[c + 0x20] = 0;
gBGTilemapBuffers2[c + 0x21] = 0;
break;
case 0:
gBGTilemapBuffers3[c] = 0x3014;
gBGTilemapBuffers3[c + 1] = 0x3014;
gBGTilemapBuffers3[c + 0x20] = 0x3014;
gBGTilemapBuffers3[c + 0x21] = 0x3014;
gBGTilemapBuffers1[c] = b[0];
gBGTilemapBuffers1[c + 1] = b[1];
gBGTilemapBuffers1[c + 0x20] = b[2];
gBGTilemapBuffers1[c + 0x21] = b[3];
gBGTilemapBuffers2[c] = b[4];
gBGTilemapBuffers2[c + 1] = b[5];
gBGTilemapBuffers2[c + 0x20] = b[6];
gBGTilemapBuffers2[c + 0x21] = b[7];
break;
}
schedule_bg_copy_tilemap_to_vram(1);
schedule_bg_copy_tilemap_to_vram(2);
schedule_bg_copy_tilemap_to_vram(3);
}
static s32 MapPosToBgTilemapOffset(struct FieldCameraUnknownStruct *a, s32 x, s32 y)
{
x -= gSaveBlock1Ptr->pos.x;
x *= 2;
if (x >= 32 || x < 0)
return -1;
x = x + a->unk2;
if (x >= 32)
x -= 32;
y = (y - gSaveBlock1Ptr->pos.y) * 2;
if (y >= 32 || y < 0)
return -1;
y = y + a->unk3;
if (y >= 32)
y -= 32;
return y * 32 + x;
}
static void CameraUpdateCallback(struct CameraObject *a)
{
if (a->spriteId != 0)
{
a->unk8 = gSprites[a->spriteId].data[2];
a->unkC = gSprites[a->spriteId].data[3];
}
}
void ResetCameraUpdateInfo(void)
{
gUnknown_03005DD0.unk8 = 0;
gUnknown_03005DD0.unkC = 0;
gUnknown_03005DD0.x = 0;
gUnknown_03005DD0.y = 0;
gUnknown_03005DD0.spriteId = 0;
gUnknown_03005DD0.callback = NULL;
}
u32 InitCameraUpdateCallback(u8 a)
{
if (gUnknown_03005DD0.spriteId != 0)
DestroySprite(&gSprites[gUnknown_03005DD0.spriteId]);
gUnknown_03005DD0.spriteId = AddCameraObject(a);
gUnknown_03005DD0.callback = CameraUpdateCallback;
return 0;
}
void CameraUpdate(void)
{
int deltaX;
int deltaY;
int r0;
int r1;
int r7;
int r8;
if (gUnknown_03005DD0.callback != NULL)
gUnknown_03005DD0.callback(&gUnknown_03005DD0);
r7 = gUnknown_03005DD0.unk8;
r8 = gUnknown_03005DD0.unkC;
deltaX = 0;
deltaY = 0;
r1 = gUnknown_03005DD0.x;
r0 = gUnknown_03005DD0.y;
if (r1 == 0 && r7 != 0)
{
if (r7 > 0)
deltaX = 1;
else
deltaX = -1;
}
if (r0 == 0 && r8 != 0)
{
if (r8 > 0)
deltaY = 1;
else
deltaY = -1;
}
if (r1 != 0 && r1 == -r7)
{
if (r7 > 0)
deltaX = 1;
else
deltaX = -1;
}
if (r0 != 0 && r0 == -r8)
{
if (r8 > 0)
deltaX = 1;
else
deltaX = -1;
}
gUnknown_03005DD0.x += r7;
gUnknown_03005DD0.x = gUnknown_03005DD0.x - 16 * (gUnknown_03005DD0.x / 16);
gUnknown_03005DD0.y += r8;
gUnknown_03005DD0.y = gUnknown_03005DD0.y - 16 * (gUnknown_03005DD0.y / 16);
if (deltaX != 0 || deltaY != 0)
{
CameraMove(deltaX, deltaY);
UpdateFieldObjectsForCameraUpdate(deltaX, deltaY);
RotatingGatePuzzleCameraUpdate(deltaX, deltaY);
ResetBerryTreeSparkleFlags();
tilemap_move_something(&gUnknown_03000E20, deltaX * 2, deltaY * 2);
RedrawMapSlicesForCameraUpdate(&gUnknown_03000E20, deltaX * 2, deltaY * 2);
}
coords8_add(&gUnknown_03000E20, r7, r8);
gUnknown_03005DEC -= r7;
gUnknown_03005DE8 -= r8;
}
void camera_move_and_redraw(int a, int b) //unused
{
CameraMove(a, b);
UpdateFieldObjectsForCameraUpdate(a, b);
DrawWholeMapView();
gUnknown_03005DEC -= a * 16;
gUnknown_03005DE8 -= b * 16;
}
void SetCameraPanningCallback(void (*a)(void))
{
gUnknown_03000E30 = a;
}
void SetCameraPanning(s16 a, s16 b)
{
gUnknown_03000E28 = a;
gUnknown_03000E2A = b + 32;
}
void InstallCameraPanAheadCallback(void)
{
gUnknown_03000E30 = CameraPanningCB_PanAhead;
gUnknown_03000E2C = 0;
gUnknown_03000E28 = 0;
gUnknown_03000E2A = 32;
}
void UpdateCameraPanning(void)
{
if (gUnknown_03000E30 != NULL)
gUnknown_03000E30();
//Update sprite offset of overworld objects
gSpriteCoordOffsetX = gUnknown_03005DEC - gUnknown_03000E28;
gSpriteCoordOffsetY = gUnknown_03005DE8 - gUnknown_03000E2A - 8;
}
static void CameraPanningCB_PanAhead(void)
{
u8 var;
if (gUnusedBikeCameraAheadPanback == FALSE)
{
InstallCameraPanAheadCallback();
}
else
{
// this code is never reached.
if (gPlayerAvatar.tileTransitionState == T_TILE_TRANSITION)
{
gUnknown_03000E2C ^= 1;
if (gUnknown_03000E2C == 0)
return;
}
else
{
gUnknown_03000E2C = 0;
}
var = player_get_direction_upper_nybble();
if (var == 2)
{
if (gUnknown_03000E2A > -8)
gUnknown_03000E2A -= 2;
}
else if (var == 1)
{
if (gUnknown_03000E2A < 72)
gUnknown_03000E2A += 2;
}
else if (gUnknown_03000E2A < 32)
{
gUnknown_03000E2A += 2;
}
else if (gUnknown_03000E2A > 32)
{
gUnknown_03000E2A -= 2;
}
}
}
// .text

View File

@ -89,9 +89,6 @@ extern const u16 gUnknown_82EC7C4[];
extern u16 gSaveFileStatus;
extern u16 gUnknown_03005DA8;
extern u8 *gUnknown_03005DA0;
extern u8 *gUnknown_03005D9C;
extern u8 *gUnknown_03005DA4;
extern bool8 (*gUnknown_03005DB0)(void);
extern u8 gUnknown_03005DB4;
extern u8 gFieldLinkPlayerCount;
@ -1422,12 +1419,12 @@ static void overworld_bg_setup(void)
SetBgAttribute(1, BG_CTRL_ATTR_PALETTEMODE, 1);
SetBgAttribute(2, BG_CTRL_ATTR_PALETTEMODE, 1);
SetBgAttribute(3, BG_CTRL_ATTR_PALETTEMODE, 1);
gUnknown_03005DA0 = AllocZeroed(0x800);
gUnknown_03005D9C = AllocZeroed(0x800);
gUnknown_03005DA4 = AllocZeroed(0x800);
SetBgTilemapBuffer(1, gUnknown_03005DA0);
SetBgTilemapBuffer(2, gUnknown_03005D9C);
SetBgTilemapBuffer(3, gUnknown_03005DA4);
gBGTilemapBuffers2 = AllocZeroed(0x800);
gBGTilemapBuffers1 = AllocZeroed(0x800);
gBGTilemapBuffers3 = AllocZeroed(0x800);
SetBgTilemapBuffer(1, gBGTilemapBuffers2);
SetBgTilemapBuffer(2, gBGTilemapBuffers1);
SetBgTilemapBuffer(3, gBGTilemapBuffers3);
sub_81971D0();
}
@ -1435,12 +1432,12 @@ void overworld_free_bg_tilemaps(void)
{
sub_81BE72C();
sub_81971F4();
if (gUnknown_03005DA4 != NULL)
FREE_AND_SET_NULL(gUnknown_03005DA4);
if (gUnknown_03005D9C != NULL)
FREE_AND_SET_NULL(gUnknown_03005D9C);
if (gUnknown_03005DA0 != NULL)
FREE_AND_SET_NULL(gUnknown_03005DA0);
if (gBGTilemapBuffers3 != NULL)
FREE_AND_SET_NULL(gBGTilemapBuffers3);
if (gBGTilemapBuffers1 != NULL)
FREE_AND_SET_NULL(gBGTilemapBuffers1);
if (gBGTilemapBuffers2 != NULL)
FREE_AND_SET_NULL(gBGTilemapBuffers2);
}
static void ResetSafariZoneFlag_(void)

View File

@ -17,10 +17,12 @@
#define GATE_ROT_ACW(arm, longArm) GATE_ROT(ROTATE_ANTICLOCKWISE, arm, longArm)
#define GATE_ROT_NONE 255
// static functions
static void SpriteCallback_RotatingGate(struct Sprite *sprite);
static u8 RotatingGate_CreateGate(u8 gateId, s16 deltaX, s16 deltaY);
static void RotatingGate_HideGatesOutsideViewport(struct Sprite *sprite);
// enums
enum
{
/*
@ -178,6 +180,7 @@ enum
PUZZLE_ROUTE110_TRICK_HOUSE_PUZZLE6,
};
// structure
struct RotatingGatePuzzle
{
s16 x;
@ -192,6 +195,7 @@ struct Coords8
s8 deltaY;
};
// .rodata
// Fortree
static const struct RotatingGatePuzzle sRotatingGate_FortreePuzzleConfig[] =
{
@ -614,10 +618,12 @@ static const u8 sRotatingGate_ArmLayout[][4 * 2] =
},
};
// ewram
static EWRAM_DATA u8 gRotatingGate_GateSpriteIds[ROTATING_GATE_PUZZLE_MAX] = {0};
static EWRAM_DATA const struct RotatingGatePuzzle *gRotatingGate_PuzzleConfig = NULL;
static EWRAM_DATA u8 gRotatingGate_PuzzleCount = 0;
// text
static s32 GetCurrentMapRotatingGatePuzzleType(void)
{
if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(FORTREE_CITY_GYM) &&

View File

@ -30,13 +30,13 @@ gPokemonStoragePtr: @ 3005D94
gInGameOpponentsNo: @ 3005D98
.space 0x4
gUnknown_03005D9C: @ 3005D9C
gBGTilemapBuffers1: @ 3005D9C
.space 0x4
gUnknown_03005DA0: @ 3005DA0
gBGTilemapBuffers2: @ 3005DA0
.space 0x4
gUnknown_03005DA4: @ 3005DA4
gBGTilemapBuffers3: @ 3005DA4
.space 0x4
gUnknown_03005DA8: @ 3005DA8

View File

@ -222,7 +222,7 @@ gCamera: @ 2037334
gUnknown_02037340: @ 2037340
.space 0x8
gUnknown_02037348: @ 2037348
gUnusedBikeCameraAheadPanback: @ 2037348
.space 0x4
gUnknown_0203734C: @ 203734C