Replace RoomDimensions with Tilemap (#730)

Failing to decompile [RenderTilemap](https://decomp.me/scratch/WigVS)
made me realise there were a few fields and structures I have always
been suspicious to be part of the same structure. After
cross-referencing overlapping fields from different structures, I was
able to merge `D_80073088`, `g_Camera`, `D_8007309C`, `g_CurrentRoom`
and `g_CurrentRoomTileLayout` into the new `g_Tilemap`.

I was forced to touch the majority of the code-base, which gave me the
opportunity to standardise some field names (e.g. from
`currentRoomTileLayout`, `roomLayout`, `layout`, `t` into `tilemap`),
remove some fake code, redundant code and adjust some symbols.
This commit is contained in:
Luciano Ciccariello 2023-11-04 16:43:45 +00:00 committed by GitHub
parent a052fffff4
commit 28b44193c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
59 changed files with 807 additions and 821 deletions

View File

@ -91,7 +91,7 @@ define link
$(LD) $(LD_FLAGS) -o $(2) \
-Map $(BUILD_DIR)/$(1).map \
-T $(BUILD_DIR)/$(1).ld \
-T $(CONFIG_DIR)/undefined_syms.$(VERSION).txt \
-T $(CONFIG_DIR)/symbols.$(VERSION).txt \
-T $(CONFIG_DIR)/undefined_syms_auto.$(VERSION).$(1).txt \
-T $(CONFIG_DIR)/undefined_funcs_auto.$(VERSION).$(1).txt
endef

View File

@ -42,12 +42,12 @@ g_Player_unk0C = 0x800729E0;
g_Player_unk10 = 0x800729E4;
D_80072F76 = 0x80072A2A;
D_80072F78 = 0x80072A2C;
g_CurrentRoomTileLayout = 0x80072B34;
g_Tilemap = 0x80072B34;
g_Camera = 0x80072B3C;
g_Camera_posX_i_hi = 0x80072B3E;
g_Camera_posY_i_hi = 0x80072B42;
g_CurrentRoom = 0x80072B50;
g_CurrentRoom_vSize = 0x80072B58;
g_Tilemap_vSize = 0x80072B58;
g_CurrentRoom_x = 0x80072B70;
g_CurrentRoom_y = 0x80072B74;
g_CurrentRoom_width = 0x80072B78;

View File

@ -689,6 +689,7 @@ g_api_unused134 = 0x8003C8A8;
g_api_unused138 = 0x8003C8AC;
g_api_unused13C = 0x8003C8B4;
g_GameTimer = 0x8003C8C4;
D_8003C908 = 0x8003C908;
_svm_damper = 0x8003C954;
g_Timer = 0x8003C998;
g_PlayableCharacter = 0x8003C9A0;
@ -813,32 +814,31 @@ g_EvSwCardErr = 0x8007306C;
g_EvSwCardTmo = 0x80073070;
g_EvSwCardNew = 0x80073078;
PadIdentifier = 0x80073080;
g_CurrentRoomTileLayout = 0x80073084;
g_Camera = 0x8007308C;
g_Camera_posX_i_hi = 0x8007308E;
g_Camera_posY_i_hi = 0x80073092;
g_CurrentRoom = 0x800730A0;
g_CurrentRoom_hSize = 0x800730A4;
g_CurrentRoom_vSize = 0x800730A8;
g_CurrentRoom_D_800730AC = 0x800730AC;
g_CurrentRoom_left = 0x800730B0;
g_CurrentRoom_top = 0x800730B4;
g_CurrentRoom_right = 0x800730B8;
g_CurrentRoom_bottom = 0x800730BC;
g_CurrentRoom_x = 0x800730C0;
g_CurrentRoom_y = 0x800730C4;
g_CurrentRoom_width = 0x800730C8;
g_CurrentRoom_height = 0x800730CC;
g_CurrentRoom_bg = 0x800730D8;
g_CurrentRoom_bg_0_tiledef = 0x800730DC;
g_CurrentRoom_bg_0_scrollX_i_hi = 0x800730E2;
g_CurrentRoom_bg_0_scrollY_i_hi = 0x800730E6;
g_CurrentRoom_bg_0_zPriority = 0x800730F0;
g_CurrentRoom_bg_0_D_800730F4 = 0x800730F4;
g_CurrentRoom_bg_0_w = 0x800730F8;
g_CurrentRoom_bg_0_h = 0x800730FC;
g_CurrentRoom_bg_0_D_80073100 = 0x80073100;
g_CurrentRoom_bg_0_flags = 0x80073104;
g_Tilemap = 0x80073084;
g_Tilemap_posX_i_hi = 0x8007308E;
g_Tilemap_posY_i_hi = 0x80073092;
g_Tilemap_flags = 0x800730A0;
g_Tilemap_hSize = 0x800730A4;
g_Tilemap_vSize = 0x800730A8;
g_Tilemap_unk8 = 0x800730AC;
g_Tilemap_left = 0x800730B0;
g_Tilemap_top = 0x800730B4;
g_Tilemap_right = 0x800730B8;
g_Tilemap_bottom = 0x800730BC;
g_Tilemap_x = 0x800730C0;
g_Tilemap_y = 0x800730C4;
g_Tilemap_width = 0x800730C8;
g_Tilemap_height = 0x800730CC;
g_Tilemap_bg = 0x800730D8;
g_Tilemap_bg_0_tiledef = 0x800730DC;
g_Tilemap_bg_0_scrollX_i_hi = 0x800730E2;
g_Tilemap_bg_0_scrollY_i_hi = 0x800730E6;
g_Tilemap_bg_0_zPriority = 0x800730F0;
g_Tilemap_bg_0_flags = 0x800730F4;
g_Tilemap_bg_0_w = 0x800730F8;
g_Tilemap_bg_0_h = 0x800730FC;
g_Tilemap_bg_0_D_80073100 = 0x80073100;
g_Tilemap_bg_0_flags = 0x80073104;
g_Entities = 0x800733D8;
PLAYER_posX_i_hi = 0x800733DA;
PLAYER_posY_val = 0x800733DC;

View File

@ -13,6 +13,7 @@ g_TrapDoorFlag = 0x8018123C;
UNK_Invincibility0 = 0x80181CC0;
c_GoldPrizes = 0x80182460;
g_Rooms = 0x80183CC4;
D_801B77CC = 0x801B77CC; // ignore:true
EntityCavernDoorVase = 0x801B77D4;
EntityUnkId12 = 0x801B78A8;
EntityBreakable = 0x801B7A64;

View File

@ -689,6 +689,7 @@ g_api_unused134 = 0x8003C8A8;
g_api_unused138 = 0x8003C8AC;
g_api_unused13C = 0x8003C8B4;
g_GameTimer = 0x8003C8C4;
D_8003C908 = 0x8003C908;
_svm_damper = 0x8003C954;
g_Timer = 0x8003C998;
g_PlayableCharacter = 0x8003C9A0;
@ -813,32 +814,31 @@ g_EvSwCardErr = 0x8007306C;
g_EvSwCardTmo = 0x80073070;
g_EvSwCardNew = 0x80073078;
PadIdentifier = 0x80073080;
g_CurrentRoomTileLayout = 0x80073084;
g_Camera = 0x8007308C;
g_Camera_posX_i_hi = 0x8007308E;
g_Camera_posY_i_hi = 0x80073092;
g_CurrentRoom = 0x800730A0;
g_CurrentRoom_hSize = 0x800730A4;
g_CurrentRoom_vSize = 0x800730A8;
g_CurrentRoom_D_800730AC = 0x800730AC;
g_CurrentRoom_left = 0x800730B0;
g_CurrentRoom_top = 0x800730B4;
g_CurrentRoom_right = 0x800730B8;
g_CurrentRoom_bottom = 0x800730BC;
g_CurrentRoom_x = 0x800730C0;
g_CurrentRoom_y = 0x800730C4;
g_CurrentRoom_width = 0x800730C8;
g_CurrentRoom_height = 0x800730CC;
g_CurrentRoom_bg = 0x800730D8;
g_CurrentRoom_bg_0_tiledef = 0x800730DC;
g_CurrentRoom_bg_0_scrollX_i_hi = 0x800730E2;
g_CurrentRoom_bg_0_scrollY_i_hi = 0x800730E6;
g_CurrentRoom_bg_0_zPriority = 0x800730F0;
g_CurrentRoom_bg_0_D_800730F4 = 0x800730F4;
g_CurrentRoom_bg_0_w = 0x800730F8;
g_CurrentRoom_bg_0_h = 0x800730FC;
g_CurrentRoom_bg_0_D_80073100 = 0x80073100;
g_CurrentRoom_bg_0_flags = 0x80073104;
g_Tilemap = 0x80073084;
g_Tilemap_posX_i_hi = 0x8007308E;
g_Tilemap_posY_i_hi = 0x80073092;
g_Tilemap_flags = 0x800730A0;
g_Tilemap_hSize = 0x800730A4;
g_Tilemap_vSize = 0x800730A8;
g_Tilemap_unk8 = 0x800730AC;
g_Tilemap_left = 0x800730B0;
g_Tilemap_top = 0x800730B4;
g_Tilemap_right = 0x800730B8;
g_Tilemap_bottom = 0x800730BC;
g_Tilemap_x = 0x800730C0;
g_Tilemap_y = 0x800730C4;
g_Tilemap_width = 0x800730C8;
g_Tilemap_height = 0x800730CC;
g_Tilemap_bg = 0x800730D8;
g_Tilemap_bg_0_tiledef = 0x800730DC;
g_Tilemap_bg_0_scrollX_i_hi = 0x800730E2;
g_Tilemap_bg_0_scrollY_i_hi = 0x800730E6;
g_Tilemap_bg_0_zPriority = 0x800730F0;
g_Tilemap_bg_0_flags = 0x800730F4;
g_Tilemap_bg_0_w = 0x800730F8;
g_Tilemap_bg_0_h = 0x800730FC;
g_Tilemap_bg_0_D_80073100 = 0x80073100;
g_Tilemap_bg_0_scrollKind = 0x80073104;
g_Entities = 0x800733D8;
PLAYER_posX_i_hi = 0x800733DA;
PLAYER_posY_val = 0x800733DC;

View File

@ -11,5 +11,3 @@ g_Status = 0x80097964;
g_CastleFlags = 0x8003BDEC;
D_8003C908 = 0x8003C908;
D_8017D000 = 0x8017D000;
D_801B77CC = 0x801B77CC;

View File

@ -115,6 +115,7 @@ typedef struct Primitive {
#define PALETTE_LEN ((COLORS_PER_PAL) * ((COLOR_BPP) / 8))
#define OTSIZE 0x200
#define MAXSPRT16 0x280
#define MAX_DRAW_MODES 0x400
// Width in pixel of how wide is the horizontal camera during normal game play
#define STAGE_WIDTH 256
@ -634,15 +635,15 @@ typedef struct GpuBuffer { // also called 'DB' in the PSY-Q samples
/* 0x0005C */ DISPENV disp; // display environment
/* 0x00074 */ DR_ENV env[0x10]; // packed drawing environment
/* 0x00474 */ u_long ot[OTSIZE]; // ordering table
/* 0x00474 */ DR_MODE drawModes[0x400]; // draw modes
/* 0x00474 */ DR_MODE drawModes[MAX_DRAW_MODES]; // draw modes
/* 0x03C74 */ POLY_GT4 polyGT4[0x300]; // textured quads
/* 0x0D874 */ POLY_G4 polyG4[0x100]; // untextured quads
/* 0x0FC74 */ POLY_GT3 polyGT3[0x30]; // textured triangles
/* 0x103F4 */ LINE_G2 lineG2[0x100]; // lines
/* 0x117F4 */ SPRT_16 sprite16[MAXSPRT16]; // 16x16 fixed-size sprites
/* 0x117F4 */ SPRT_16 sprite16[MAXSPRT16]; // tile map sprites
/* 0x13FF4 */ TILE tiles[GPU_MAX_TILE_COUNT]; // squared sprites
/* 0x14FF4 */ SPRT sprite[0x200]; // dynamic-size sprites
} GpuBuffer; /* size = 0x177F4 */
} GpuBuffer; // size=0x177F4
typedef struct {
/* 0x00 */ u32 drawModes;
@ -905,7 +906,7 @@ typedef struct {
/* 0x04 */ u32 top : 6;
/* 0x08 */ u32 right : 6;
/* 0x0C */ u32 bottom : 6;
/* 0x10 */ u8 flags : 8;
/* 0x10 */ u8 params : 8;
} LayoutRect; // size = 0x14
typedef struct {
@ -913,18 +914,7 @@ typedef struct {
/* 0x04 */ const TileDefinition* tileDef;
/* 0x08 */ const LayoutRect rect;
/* 0x0C */ const u16 zPriority;
/* 0x0E */ const u16 unkE;
} LayerDef2; // size = 0x10
typedef struct {
/* 0x00 */ const u16* layout;
/* 0x04 */ const TileDefinition* tileDef;
/* 0x08 */ const u8 left;
/* 0x09 */ const u8 top;
/* 0x0A */ const u8 right;
/* 0x0B */ const u8 bottom;
/* 0x0C */ const u16 zPriority;
/* 0x0E */ const u16 unkE;
/* 0x0E */ const u16 flags;
} LayerDef; // size = 0x10
typedef struct {
@ -1285,38 +1275,50 @@ typedef struct {
/* 0x0D */ u8 soundFrame;
} AnimSoundEvent;
#define TILE_SIZE 16
#define TILE_MASK 0x0F
#define N_HORIZ_TILES 17
#define N_VERTI_TILES 16
typedef struct {
/* 800730D8 0x00 */ u16* layout;
/* 800730DC 0x04 */ u32 tileDef;
/* 800730DC 0x04 */ TileDefinition* tileDef;
/* 800730E0 0x08 */ f32 scrollX;
/* 800730E4 0x0C */ f32 scrollY;
/* 800730E8 0x10 */ u32 D_800730E8;
/* 800730EC 0x14 */ u32 D_800730EC;
/* 800730F0 0x18 */ u32 zPriority;
/* 800730F4 0x1C */ u32 D_800730F4;
/* 800730F4 0x1C */ u32 flags;
/* 800730F8 0x20 */ u32 w;
/* 800730FC 0x24 */ u32 h;
/* 80073100 0x28 */ u32 D_80073100;
/* 80073104 0x2C */ u32 flags;
/* 80073104 0x2C */ u32 scrollKind;
} BgLayer; /* size=0x30 */
typedef struct {
/* 800730A0 0x00 */ s32 unk00;
/* 800730A4 0x04 */ s32 hSize;
/* 800730A8 0x08 */ s32 vSize;
/* 800730AC 0x0C */ s32 unk8;
/* 800730B0 0x10 */ s32 left;
/* 800730B4 0x14 */ s32 top;
/* 800730B8 0x18 */ s32 right;
/* 800730BC 0x1C */ s32 bottom;
/* 800730C0 0x20 */ s32 x;
/* 800730C4 0x24 */ s32 y;
/* 800730C8 0x28 */ s32 width;
/* 800730CC 0x2C */ s32 height;
/* 800730D0 0x30 */ s32 unk30;
/* 800730D4 0x34 */ s32 D_800730D4;
/* 800730D8 0x38 */ BgLayer bg[MAX_BG_LAYER_COUNT];
} RoomDimensions;
/* 80073084 */ u16* fg;
/* 80073088 */ TileDefinition* D_80073088;
/* 8007308C */ f32 cameraX;
/* 80073090 */ f32 cameraY;
/* 80073094 */ s32 D_80073094;
/* 80073098 */ s32 D_80073098;
/* 8007309C */ s32 zPriority;
/* 800730A0 */ s32 flags;
/* 800730A4 */ s32 hSize;
/* 800730A8 */ s32 vSize;
/* 800730AC */ s32 unk8;
/* 800730B0 */ s32 left;
/* 800730B4 */ s32 top;
/* 800730B8 */ s32 right;
/* 800730BC */ s32 bottom;
/* 800730C0 */ s32 x;
/* 800730C4 */ s32 y;
/* 800730C8 */ s32 width;
/* 800730CC */ s32 height;
/* 800730D0 */ s32 unk30;
/* 800730D4 */ s32 D_800730D4;
/* 800730D8 */ BgLayer bg[MAX_BG_LAYER_COUNT];
} Tilemap;
typedef struct {
/* D_8003C708 */ u16 flags;
@ -1504,11 +1506,8 @@ extern s32 D_80073074; // Probably also an Event?
extern Event g_EvSwCardNew; // 80073078
extern s32 D_8007307C; // Maybe also an Event?
extern s32 D_80073080;
extern TileDefinition* D_80073088;
extern Camera g_Camera;
extern s32 D_8007309C;
extern RoomDimensions g_CurrentRoom;
extern s32 g_CurrentRoom_vSize; // g_CurrentRoom.vSize
extern Tilemap g_Tilemap;
// Beginning of Player Character offset = 0x800733D8
extern Entity g_Entities[TOTAL_ENTITY_COUNT];
@ -1524,7 +1523,6 @@ extern Entity g_Entities[TOTAL_ENTITY_COUNT];
extern Entity D_80074C08[];
// *** ENTITY DIRECT ACCESS PROPERTIES END ***
extern Unkstruct8 g_CurrentRoomTileLayout;
extern Entity D_8007A958[]; // &g_Entities[160]
extern Entity D_8007C0D8[]; // &g_Entities[192]
extern Entity D_8007DE38[];

View File

@ -84,6 +84,8 @@
#define catPrim(p0, p1) setaddr(p0, p1)
#define termPrim(p) setaddr(p, 0xffffffff)
#define setSprt16(p) setlen(p, 3), setcode(p, 0x7c)
#define setSemiTrans(p, abe) \
((abe) ? setcode(p, getcode(p) | 0x02) : setcode(p, getcode(p) & ~0x02))

View File

@ -12,19 +12,6 @@ typedef struct {
/* 0x4 */ s32 y;
} Point32; // size = 0x8
typedef struct {
/* 0x00 */ u16* fg;
/* 0x04 */ u16* bg;
/* 0x08 */ u16 unk8;
/* 0x0A */ s16 unkA;
/* 0x0C */ u16 unkC;
/* 0x0E */ s16 unkE;
/* 0x10 */ char pad_10[0x30];
/* 0x40 */ s32 unk40;
/* 0x44 */ s32 unk44;
/* 0x48 */ s32 unk48;
} Unkstruct8; // size = 0x4C
typedef struct {
/* 0x00 */ u8 vabid;
/* 0x01 */ u8 prog;

View File

@ -606,69 +606,65 @@ void InitRenderer(void) {
void HideAllBackgroundLayers(void) {
s32 i;
g_CurrentRoom.unk00 = 0;
g_Tilemap.flags = 0;
for (i = 0; i < MAX_BG_LAYER_COUNT; i++) {
g_CurrentRoom.bg[i].D_800730F4 = 0;
g_Tilemap.bg[i].flags = 0;
}
}
INCLUDE_ASM("dra/nonmatchings/4A538", RenderTilemap);
void SetRoomForegroundLayer(LayerDef2* layerDef) {
void SetRoomForegroundLayer(LayerDef* layerDef) {
D_8003C708.flags = 0;
D_8013AED0 = 1;
D_80073088 = layerDef->tileDef;
if (g_CurrentRoom.hSize && g_CurrentRoom.vSize) {
}
g_CurrentRoom.unk00 = 0;
if (D_80073088 == 0) {
g_Tilemap.D_80073088 = layerDef->tileDef;
g_Tilemap.flags = 0;
if (g_Tilemap.D_80073088 == 0) {
return;
}
g_CurrentRoomTileLayout.fg = layerDef->layout;
D_8007309C = layerDef->zPriority;
if (layerDef->rect.flags & 0x40) {
D_8007309C = 0x60;
D_8003C708.flags = layerDef->rect.flags;
g_Tilemap.fg = layerDef->layout;
g_Tilemap.zPriority = layerDef->zPriority;
if (layerDef->rect.params & 0x40) {
g_Tilemap.zPriority = 0x60;
D_8003C708.flags = layerDef->rect.params;
D_8003C708.unk2 = 0;
D_8003C708.unk4 = 0;
D_8003C708.zPriority = layerDef->zPriority;
}
if (layerDef->rect.flags & 0x20) {
D_8007309C = 0x60;
D_8003C708.flags = layerDef->rect.flags;
if (layerDef->rect.params & 0x20) {
g_Tilemap.zPriority = 0x60;
D_8003C708.flags = layerDef->rect.params;
}
if (layerDef->rect.flags & 0x10) {
D_8007309C = 0x60;
if (layerDef->rect.params & 0x10) {
g_Tilemap.zPriority = 0x60;
D_8013AED0 = 0;
};
g_CurrentRoom.unk00 = layerDef->unkE;
g_CurrentRoom.left = layerDef->rect.left;
g_CurrentRoom.top = layerDef->rect.top;
g_CurrentRoom.right = layerDef->rect.right;
g_CurrentRoom.bottom = layerDef->rect.bottom;
g_CurrentRoom.hSize = g_CurrentRoom.right - g_CurrentRoom.left + 1;
g_CurrentRoom.vSize = g_CurrentRoom.bottom - g_CurrentRoom.top + 1;
g_CurrentRoom.y = 0;
g_CurrentRoom.x = 0;
g_CurrentRoom.width = g_CurrentRoom.hSize << 8;
g_CurrentRoom.height = g_CurrentRoom.vSize << 8;
g_CurrentRoom.unk8 = 1;
g_Tilemap.flags = layerDef->flags;
g_Tilemap.left = layerDef->rect.left;
g_Tilemap.top = layerDef->rect.top;
g_Tilemap.right = layerDef->rect.right;
g_Tilemap.bottom = layerDef->rect.bottom;
g_Tilemap.hSize = g_Tilemap.right - g_Tilemap.left + 1;
g_Tilemap.vSize = g_Tilemap.bottom - g_Tilemap.top + 1;
g_Tilemap.y = 0;
g_Tilemap.x = 0;
g_Tilemap.width = g_Tilemap.hSize << 8;
g_Tilemap.height = g_Tilemap.vSize << 8;
g_Tilemap.unk8 = 1;
}
void SetRoomBackgroundLayer(s32 index, LayerDef2* layerDef) {
g_CurrentRoom.bg[index].D_800730F4 = 0;
g_CurrentRoom.bg[index].tileDef = layerDef->tileDef;
g_CurrentRoom.bg[index].layout = layerDef->layout;
if (g_CurrentRoom.bg[index].tileDef != 0) {
g_CurrentRoom.bg[index].zPriority = layerDef->zPriority;
g_CurrentRoom.bg[index].D_800730F4 = layerDef->unkE;
g_CurrentRoom.bg[index].w =
layerDef->rect.right - layerDef->rect.left + 1;
g_CurrentRoom.bg[index].h =
layerDef->rect.bottom - layerDef->rect.top + 1;
g_CurrentRoom.bg[index].flags = layerDef->rect.flags;
g_CurrentRoom.bg[index].D_80073100 = 1;
void SetRoomBackgroundLayer(s32 index, LayerDef* layerDef) {
g_Tilemap.bg[index].flags = 0;
g_Tilemap.bg[index].tileDef = layerDef->tileDef;
g_Tilemap.bg[index].layout = layerDef->layout;
if (g_Tilemap.bg[index].tileDef != 0) {
g_Tilemap.bg[index].zPriority = layerDef->zPriority;
g_Tilemap.bg[index].flags = layerDef->flags;
g_Tilemap.bg[index].w = layerDef->rect.right - layerDef->rect.left + 1;
g_Tilemap.bg[index].h = layerDef->rect.bottom - layerDef->rect.top + 1;
g_Tilemap.bg[index].scrollKind = layerDef->rect.params;
g_Tilemap.bg[index].D_80073100 = 1;
}
}
@ -679,7 +675,7 @@ void LoadRoomLayer(s32 layerIndex) {
SetRoomBackgroundLayer(0, g_api.o.tileLayers[layerIndex].bg);
for (i = 1; i < MAX_BG_LAYER_COUNT; i++) {
g_CurrentRoom.bg[i].D_800730F4 = 0;
g_Tilemap.bg[i].flags = 0;
}
}

View File

@ -23,50 +23,50 @@ s32 func_800F087C(u32 chunkX, u32 chunkY) {
void func_800F0940(void) {
s32 temp;
switch (g_CurrentRoom.bg[0].flags) {
switch (g_Tilemap.bg[0].scrollKind) {
case 1:
g_CurrentRoom.bg[0].scrollX.i.hi = g_Camera.posX.i.hi;
g_CurrentRoom.bg[0].scrollY.i.hi = g_Camera.posY.i.hi;
g_Tilemap.bg[0].scrollX.i.hi = g_Tilemap.cameraX.i.hi;
g_Tilemap.bg[0].scrollY.i.hi = g_Tilemap.cameraY.i.hi;
return;
case 2:
g_CurrentRoom.bg[0].scrollX.i.hi = (g_Camera.posX.i.hi / 2);
g_CurrentRoom.bg[0].scrollY.i.hi = (g_Camera.posY.i.hi / 2) + 0x76;
g_Tilemap.bg[0].scrollX.i.hi = (g_Tilemap.cameraX.i.hi / 2);
g_Tilemap.bg[0].scrollY.i.hi = (g_Tilemap.cameraY.i.hi / 2) + 0x76;
return;
case 3:
g_CurrentRoom.bg[0].scrollX.i.hi = g_Camera.posX.i.hi / 2;
g_CurrentRoom.bg[0].scrollY.i.hi = g_Camera.posY.i.hi;
g_Tilemap.bg[0].scrollX.i.hi = g_Tilemap.cameraX.i.hi / 2;
g_Tilemap.bg[0].scrollY.i.hi = g_Tilemap.cameraY.i.hi;
return;
case 4:
g_CurrentRoom.bg[0].scrollX.i.hi = g_Camera.posX.i.hi;
g_CurrentRoom.bg[0].scrollY.i.hi = g_Camera.posY.i.hi / 2;
g_Tilemap.bg[0].scrollX.i.hi = g_Tilemap.cameraX.i.hi;
g_Tilemap.bg[0].scrollY.i.hi = g_Tilemap.cameraY.i.hi / 2;
if (g_StageId == STAGE_RCHI) {
g_CurrentRoom.bg[0].scrollY.i.hi += 0x80;
g_Tilemap.bg[0].scrollY.i.hi += 0x80;
}
return;
case 5:
g_CurrentRoom.bg[0].scrollX.i.hi = g_Camera.posX.i.hi / 2;
g_CurrentRoom.bg[0].scrollY.i.hi = g_Camera.posY.i.hi / 2;
g_Tilemap.bg[0].scrollX.i.hi = g_Tilemap.cameraX.i.hi / 2;
g_Tilemap.bg[0].scrollY.i.hi = g_Tilemap.cameraY.i.hi / 2;
if (g_StageId == STAGE_RDAI) {
g_CurrentRoom.bg[0].scrollX.i.hi += 0x80;
g_Tilemap.bg[0].scrollX.i.hi += 0x80;
}
return;
case 6:
g_CurrentRoom.bg[0].scrollX.i.hi = g_Camera.posX.i.hi / 2;
temp = (g_Camera.posY.i.hi / 2 - ((g_CurrentRoom.vSize - 1) << 7)) +
(g_CurrentRoom.bg[0].h << 7);
g_CurrentRoom.bg[0].scrollY.i.hi = temp;
g_Tilemap.bg[0].scrollX.i.hi = g_Tilemap.cameraX.i.hi / 2;
temp = (g_Tilemap.cameraY.i.hi / 2 - ((g_Tilemap.vSize - 1) << 7)) +
(g_Tilemap.bg[0].h << 7);
g_Tilemap.bg[0].scrollY.i.hi = temp;
if (g_StageId == STAGE_RDAI) {
g_CurrentRoom.bg[0].scrollX.i.hi += 0x80;
g_CurrentRoom.bg[0].scrollY.i.hi = g_Camera.posY.i.hi / 2;
g_Tilemap.bg[0].scrollX.i.hi += 0x80;
g_Tilemap.bg[0].scrollY.i.hi = g_Tilemap.cameraY.i.hi / 2;
}
return;
case 7:
g_CurrentRoom.bg[0].scrollY.i.hi = 4;
g_CurrentRoom.bg[0].scrollX.i.hi = g_Camera.posX.i.hi / 2;
g_Tilemap.bg[0].scrollY.i.hi = 4;
g_Tilemap.bg[0].scrollX.i.hi = g_Tilemap.cameraX.i.hi / 2;
return;
default:
g_CurrentRoom.bg[0].scrollX.i.hi = 0;
g_CurrentRoom.bg[0].scrollY.i.hi = 4;
g_Tilemap.bg[0].scrollX.i.hi = 0;
g_Tilemap.bg[0].scrollY.i.hi = 4;
return;
}
}
@ -122,8 +122,8 @@ s32 func_800F0CD8(s32 arg0) {
if (D_80097418 == 0) {
if (D_80097C98 == 2) {
var_v0 = SetNextRoomToLoad(
(g_Entities[0].posX.i.hi >> 8) + g_CurrentRoom.left,
(g_Entities[0].posY.i.hi >> 8) + g_CurrentRoom.top);
(g_Entities[0].posX.i.hi >> 8) + g_Tilemap.left,
(g_Entities[0].posY.i.hi >> 8) + g_Tilemap.top);
D_801375C0 = (u8)g_Entities[0].posX.i.hi;
D_801375C4 = (u8)g_Entities[0].posY.i.hi;
return var_v0;
@ -131,9 +131,9 @@ s32 func_800F0CD8(s32 arg0) {
if (arg0 == 0) {
goto block_25;
}
if (playerX < g_CurrentRoom.x) {
if (playerX < g_Tilemap.x) {
var_v0 = SetNextRoomToLoad(
g_CurrentRoom.left - 1, (playerY >> 8) + g_CurrentRoom.top);
g_Tilemap.left - 1, (playerY >> 8) + g_Tilemap.top);
if (var_v0) {
D_80072F98 = 1;
D_801375C0 = g_Entities[0].posX.i.hi + 0x100;
@ -141,11 +141,11 @@ s32 func_800F0CD8(s32 arg0) {
return var_v0;
}
g_Entities[0].posX.i.hi = 0;
playerX = g_CurrentRoom.x;
playerX = g_Tilemap.x;
}
if (playerX >= g_CurrentRoom.width) {
if (playerX >= g_Tilemap.width) {
var_v0 = SetNextRoomToLoad(
g_CurrentRoom.right + 1, (playerY >> 8) + g_CurrentRoom.top);
g_Tilemap.right + 1, (playerY >> 8) + g_Tilemap.top);
if (var_v0) {
D_80072F98 = 1;
D_801375C0 = g_Entities[0].posX.i.hi - 0x100;
@ -153,13 +153,13 @@ s32 func_800F0CD8(s32 arg0) {
return var_v0;
}
g_Entities[0].posX.i.hi = 0xFF;
playerX = g_CurrentRoom.width - 1;
playerX = g_Tilemap.width - 1;
}
}
if (D_80097424 == 0) {
if (playerY < g_CurrentRoom.y + 4) {
if (playerY < g_Tilemap.y + 4) {
temp_v0 = SetNextRoomToLoad(
(playerX >> 8) + g_CurrentRoom.left, g_CurrentRoom.top - 1);
(playerX >> 8) + g_Tilemap.left, g_Tilemap.top - 1);
if (temp_v0 != false) {
D_80072F98 = 2;
D_801375C0 = g_Entities[0].posX.i.hi;
@ -168,15 +168,15 @@ s32 func_800F0CD8(s32 arg0) {
return temp_v0;
}
g_Entities[0].posY.i.hi = 0;
playerY = g_CurrentRoom.y + 4;
playerY = g_Tilemap.y + 4;
}
var_s0 = 0x30;
if ((!(*g_Player.pl_vram_flag & 1)) && !(g_Player.unk0C & 3)) {
var_s0 = 0x18;
}
if (playerY >= ((g_CurrentRoom.height - var_s0) + 0x14)) {
if (playerY >= ((g_Tilemap.height - var_s0) + 0x14)) {
temp_v0 = SetNextRoomToLoad(
(playerX >> 8) + g_CurrentRoom.left, g_CurrentRoom.bottom + 1);
(playerX >> 8) + g_Tilemap.left, g_Tilemap.bottom + 1);
if (temp_v0 != false) {
D_80072F98 = 2;
D_801375C0 = g_Entities[0].posX.i.hi;
@ -186,73 +186,73 @@ s32 func_800F0CD8(s32 arg0) {
return temp_v0;
}
g_Entities[0].posY.i.hi = 0x10F - var_s0;
playerY = g_CurrentRoom.height - var_s0 + 0x13;
playerY = g_Tilemap.height - var_s0 + 0x13;
}
}
block_25:
temp_a1 = g_CurrentRoom.x + *D_8009740C;
temp_a1 = g_Tilemap.x + *D_8009740C;
if (playerX < temp_a1) {
if (arg0 != 0 && g_CurrentRoom.hSize != 1 &&
if (arg0 != 0 && g_Tilemap.hSize != 1 &&
temp_a1 < playerX + D_801375A4) {
g_Entities[0].posX.i.hi =
(u16)g_Entities[0].posX.i.hi +
(playerX + D_801375A4 - (g_CurrentRoom.x + *D_8009740C));
(playerX + D_801375A4 - (g_Tilemap.x + *D_8009740C));
}
g_Camera.posX.i.hi = g_CurrentRoom.x;
g_Tilemap.cameraX.i.hi = g_Tilemap.x;
} else {
temp_a1_2 = g_CurrentRoom.width + *D_8009740C - 0x100;
temp_a1_2 = g_Tilemap.width + *D_8009740C - 0x100;
if (temp_a1_2 < playerX) {
if (arg0 != 0 && g_CurrentRoom.hSize != 1 &&
if (arg0 != 0 && g_Tilemap.hSize != 1 &&
playerX + D_801375A4 < temp_a1_2) {
g_Entities[0].posX.i.hi =
((u16)g_Entities[0].posX.i.hi) +
(((playerX + D_801375A4) + 0x100) -
(g_CurrentRoom.width + (*D_8009740C)));
(g_Tilemap.width + (*D_8009740C)));
}
g_Camera.posX.i.hi = g_CurrentRoom.width - 0x100;
g_Tilemap.cameraX.i.hi = g_Tilemap.width - 0x100;
} else {
g_Camera.posX.i.hi = playerX - (*D_8009740C);
g_Tilemap.cameraX.i.hi = playerX - (*D_8009740C);
g_Entities[0].posX.i.hi = *D_8009740C;
}
}
if (D_8009741C != 0) {
if (playerY < g_CurrentRoom.y + 0x8C) {
g_Camera.posY.i.hi = g_CurrentRoom.y + 4;
g_Entities[0].posY.i.hi = playerY - g_Camera.posY.i.hi;
} else if (g_CurrentRoom.height - 0x74 < playerY) {
g_Camera.posY.i.hi = g_CurrentRoom.height - 0xFC;
g_Entities[0].posY.i.hi = playerY - g_Camera.posY.i.hi;
if (playerY < g_Tilemap.y + 0x8C) {
g_Tilemap.cameraY.i.hi = g_Tilemap.y + 4;
g_Entities[0].posY.i.hi = playerY - g_Tilemap.cameraY.i.hi;
} else if (g_Tilemap.height - 0x74 < playerY) {
g_Tilemap.cameraY.i.hi = g_Tilemap.height - 0xFC;
g_Entities[0].posY.i.hi = playerY - g_Tilemap.cameraY.i.hi;
} else {
g_Entities[0].posY.i.hi = 0x88;
g_Camera.posY.i.hi = playerY - 0x88;
g_Tilemap.cameraY.i.hi = playerY - 0x88;
}
} else {
new_var2 = 0x88;
if (playerY < g_CurrentRoom.y + 0x8C) {
if (g_Camera.posY.i.hi + new_var2 - playerY >= 4 &&
g_CurrentRoom.y + 8 < g_Camera.posY.i.hi) {
g_Camera.posY.i.hi -= 4;
if (playerY < g_Tilemap.y + 0x8C) {
if (g_Tilemap.cameraY.i.hi + new_var2 - playerY >= 4 &&
g_Tilemap.y + 8 < g_Tilemap.cameraY.i.hi) {
g_Tilemap.cameraY.i.hi -= 4;
g_Entities[0].posY.i.hi += 4;
} else if (
g_Camera.posY.i.hi < g_CurrentRoom.y && g_CurrentRoom.y != 0) {
g_Camera.posY.i.hi += 4;
g_Tilemap.cameraY.i.hi < g_Tilemap.y && g_Tilemap.y != 0) {
g_Tilemap.cameraY.i.hi += 4;
g_Entities[0].posY.i.hi -= 4;
} else {
g_Camera.posY.i.hi = g_CurrentRoom.y + 4;
g_Entities[0].posY.i.hi = playerY - g_Camera.posY.i.hi;
g_Tilemap.cameraY.i.hi = g_Tilemap.y + 4;
g_Entities[0].posY.i.hi = playerY - g_Tilemap.cameraY.i.hi;
}
} else {
g_Entities[0].posY.i.hi = g_Camera.posY.i.hi;
if (g_CurrentRoom.height - 0x74 < playerY) {
g_Camera.posY.i.hi = g_CurrentRoom.height - 0xFC;
g_Entities[0].posY.i.hi = playerY - g_Camera.posY.i.hi;
} else if (g_Camera.posY.i.hi + new_var2 - playerY >= 4) {
g_Camera.posY.i.hi -= 4;
g_Entities[0].posY.i.hi = g_Tilemap.cameraY.i.hi;
if (g_Tilemap.height - 0x74 < playerY) {
g_Tilemap.cameraY.i.hi = g_Tilemap.height - 0xFC;
g_Entities[0].posY.i.hi = playerY - g_Tilemap.cameraY.i.hi;
} else if (g_Tilemap.cameraY.i.hi + new_var2 - playerY >= 4) {
g_Tilemap.cameraY.i.hi -= 4;
g_Entities[0].posY.i.hi += 4;
} else {
g_Entities[0].posY.i.hi = 0x88;
g_Camera.posY.i.hi = playerY - 0x88;
g_Tilemap.cameraY.i.hi = playerY - 0x88;
}
}
}
@ -262,13 +262,13 @@ block_25:
void func_800F1424(void) {
if (g_pads[1].tapped & PAD_R1) {
g_CurrentRoom.unk00 ^= 2;
g_Tilemap.flags ^= 2;
}
if (g_pads[1].tapped & PAD_L1) {
g_CurrentRoom.unk00 ^= 1;
g_Tilemap.flags ^= 1;
}
if ((g_pads[1].tapped & PAD_L2) && (g_CurrentRoom.bg[0].tileDef != 0)) {
g_CurrentRoom.bg[0].D_800730F4 ^= 1;
if ((g_pads[1].tapped & PAD_L2) && (g_Tilemap.bg[0].tileDef != 0)) {
g_Tilemap.bg[0].flags ^= 1;
}
}
@ -283,13 +283,13 @@ void func_800F14CC(void) {
if (g_StageId & 0x20) {
PLAYER.posY.i.hi = 0xB4;
}
SetNextRoomToLoad(g_CurrentRoom.left, g_CurrentRoom.top);
SetNextRoomToLoad(g_Tilemap.left, g_Tilemap.top);
return;
}
if (D_8003C730 == 2) {
PLAYER.posX.i.hi = 0x74;
PLAYER.posY.i.hi = 0xA4;
SetNextRoomToLoad(g_CurrentRoom.left, g_CurrentRoom.top);
SetNextRoomToLoad(g_Tilemap.left, g_Tilemap.top);
return;
}
temp_a2 = &D_800A245C[D_8006C374];
@ -450,8 +450,8 @@ INCLUDE_ASM("dra/nonmatchings/5087C", func_800F1D54);
INCLUDE_ASM("dra/nonmatchings/5087C", func_800F1EB0);
void func_800F1FC4(s32 arg0) {
func_800F1EB0((playerX >> 8) + g_CurrentRoom.left,
(playerY >> 8) + g_CurrentRoom.top, arg0);
func_800F1EB0(
(playerX >> 8) + g_Tilemap.left, (playerY >> 8) + g_Tilemap.top, arg0);
}
void func_800F2014(void) {
@ -462,8 +462,8 @@ void func_800F2014(void) {
s32 currMapRect;
if ((D_8013AED0 != 0) && (g_StageId != STAGE_ST0)) {
x = (playerX >> 8) + g_CurrentRoom.left;
y = (playerY >> 8) + g_CurrentRoom.top;
x = (playerX >> 8) + g_Tilemap.left;
y = (playerY >> 8) + g_Tilemap.top;
idx = (x >> 2) + (y * 16);
subMap = 1 << ((3 - (x & 3)) * 2);
if (g_StageId & STAGE_INVERTEDCASTLE_FLAG) {
@ -545,8 +545,8 @@ void func_800F24F4(void) {
s32 phi_v1;
s32 phi_a0;
castleX = ((s32)playerX >> 8) + g_CurrentRoom.left;
castleY = ((s32)playerY >> 8) + g_CurrentRoom.top;
castleX = ((s32)playerX >> 8) + g_Tilemap.left;
castleY = ((s32)playerY >> 8) + g_Tilemap.top;
if (D_8003C708 & 0x20) {
phi_v1 = g_StageId;
if (phi_v1 == (STAGE_NO0 | STAGE_INVERTEDCASTLE_FLAG)) {

View File

@ -141,29 +141,28 @@ void func_800F298C(void) {
PLAYER.facingLeft = 1;
}
ptr_791c = &D_8009791C;
g_CurrentRoom.x =
((D_801375BC.def - 1)->tileLayoutId - g_CurrentRoom.left) << 8;
g_CurrentRoom.y =
((D_801375BC.def - 1)->tilesetId - g_CurrentRoom.top) << 8;
g_CurrentRoom.width =
(((D_801375BC.def - 1)->objGfxId - g_CurrentRoom.left) + 1) << 8;
g_CurrentRoom.height =
(((D_801375BC.def - 1)->objLayoutId - g_CurrentRoom.top) + 1) << 8;
g_Tilemap.x =
((D_801375BC.def - 1)->tileLayoutId - g_Tilemap.left) << 8;
g_Tilemap.y = ((D_801375BC.def - 1)->tilesetId - g_Tilemap.top) << 8;
g_Tilemap.width =
(((D_801375BC.def - 1)->objGfxId - g_Tilemap.left) + 1) << 8;
g_Tilemap.height =
(((D_801375BC.def - 1)->objLayoutId - g_Tilemap.top) + 1) << 8;
*ptr_791c = (playerX >> 8) + g_CurrentRoom.left;
D_80097920 = (playerY >> 8) + g_CurrentRoom.top;
*ptr_791c = (playerX >> 8) + g_Tilemap.left;
D_80097920 = (playerY >> 8) + g_Tilemap.top;
g_Camera.posX.i.hi = (*ptr_791c - g_CurrentRoom.left) << 8;
g_Camera.posY.i.hi = (D_80097920 - g_CurrentRoom.top) << 8;
g_Tilemap.cameraX.i.hi = (*ptr_791c - g_Tilemap.left) << 8;
g_Tilemap.cameraY.i.hi = (D_80097920 - g_Tilemap.top) << 8;
if (D_8003C730 == 2) {
g_CurrentRoom.height -= 0x100;
g_Tilemap.height -= 0x100;
PLAYER.facingLeft = 1;
g_CurrentRoom.bottom -= 1;
g_Tilemap.bottom -= 1;
}
if (D_8006C374 == 0x2C) {
g_CurrentRoom.y = 0x2FB;
g_CurrentRoom.height = 0x3FB;
g_Tilemap.y = 0x2FB;
g_Tilemap.height = 0x3FB;
g_StageId = STAGE_TOP;
}
if (D_80097C98 == 6) {
@ -174,8 +173,8 @@ void func_800F298C(void) {
}
func_800F0CD8(0);
func_800F0CD8(0);
D_80073074 = (s32)g_Camera.posX.i.hi;
D_8007307C = (s32)g_Camera.posY.i.hi;
D_80073074 = (s32)g_Tilemap.cameraX.i.hi;
D_8007307C = (s32)g_Tilemap.cameraY.i.hi;
g_api.o.InitRoomEntities(D_801375BC.def->objLayoutId);
g_api.o.Update();
g_api.o.Update();
@ -214,10 +213,10 @@ void func_800F298C(void) {
func_800F1424();
#endif
func_800F2014();
D_80097908 = g_Camera.posX.i.hi - D_80073074;
D_8009790C = g_Camera.posY.i.hi - D_8007307C;
D_80073074 = g_Camera.posX.i.hi;
D_8007307C = g_Camera.posY.i.hi;
D_80097908 = g_Tilemap.cameraX.i.hi - D_80073074;
D_8009790C = g_Tilemap.cameraY.i.hi - D_8007307C;
D_80073074 = g_Tilemap.cameraX.i.hi;
D_8007307C = g_Tilemap.cameraY.i.hi;
g_api.o.TestCollisions();
D_8013759C = PLAYER.posX.i.hi;
@ -292,8 +291,8 @@ void func_800F298C(void) {
playerY -= D_801375A8;
D_8013759C = PLAYER.posX.val;
D_801375A0 = PLAYER.posY.val;
D_801375AC = g_Camera.posX.i.hi;
D_801375B0 = g_Camera.posY.i.hi;
D_801375AC = g_Tilemap.cameraX.i.hi;
D_801375B0 = g_Tilemap.cameraY.i.hi;
if (*D_80097420 != 0) {
func_8010E0D0(*D_80097420);
@ -318,8 +317,8 @@ void func_800F298C(void) {
g_MenuStep = MENU_STEP_INIT;
return;
}
D_801375B4 = D_801375AC - g_Camera.posX.i.hi;
D_801375B8 = D_801375B0 - g_Camera.posY.i.hi;
D_801375B4 = D_801375AC - g_Tilemap.cameraX.i.hi;
D_801375B8 = D_801375B0 - g_Tilemap.cameraY.i.hi;
D_801375A4 = D_8013759C - PLAYER.posX.val;
D_801375A8 = D_801375A0 - PLAYER.posY.val;
D_801375A4 -= D_80097488;
@ -534,24 +533,26 @@ void func_800F298C(void) {
D_80137598 = 0;
}
layer = g_api.o.tileLayers[D_801375BC.def->tileLayoutId].fg;
if (layer->bottom & 0x80) {
D_801375BC.def = &g_api.o.rooms[layer->bottom & 0x7F].load;
if (layer->rect.params & 0x80) {
D_801375BC.def =
&g_api.o.rooms[layer->rect.params & 0x7F].load;
// TODO: !FAKE
// D_8009791C is probably part of a struct. see also
// (&g_Camera.posX)->i.hi seen elsewhere in this function.
// do-while prevents instruction reordering
// (&g_Tilemap.cameraX)->i.hi seen elsewhere
// in this function. do-while prevents instruction
// reordering
do {
D_8009791C = layer->zPriority;
} while (0);
D_80097920 = layer->unkE;
D_80097920 = layer->flags;
} else {
D_8009791C = (playerX >> 8) + g_CurrentRoom.left;
D_80097920 = (playerY >> 8) + g_CurrentRoom.top;
D_8009791C = (playerX >> 8) + g_Tilemap.left;
D_80097920 = (playerY >> 8) + g_Tilemap.top;
}
D_8013759C = PLAYER.posX.val;
D_801375A0 = PLAYER.posY.val;
PLAYER.posX.i.hi = D_801375C0 + g_Camera.posX.i.hi;
PLAYER.posY.i.hi = D_801375C4 + g_Camera.posY.i.hi;
PLAYER.posX.i.hi = D_801375C0 + g_Tilemap.cameraX.i.hi;
PLAYER.posY.i.hi = D_801375C4 + g_Tilemap.cameraY.i.hi;
if (D_8003C708.flags & 0x60) {
LoadGfxAsync(ANIMSET_DRA(1));
}
@ -576,37 +577,35 @@ void func_800F298C(void) {
if (D_8003C708.flags & 0x40) {
LoadGfxAsync(ANIMSET_DRA(4));
}
g_CurrentRoom.x =
((D_801375BC.def - 1)->tileLayoutId - g_CurrentRoom.left)
g_Tilemap.x =
((D_801375BC.def - 1)->tileLayoutId - g_Tilemap.left) << 8;
g_Tilemap.y =
((D_801375BC.def - 1)->tilesetId - g_Tilemap.top) << 8;
g_Tilemap.width =
(((D_801375BC.def - 1)->objGfxId - g_Tilemap.left) + 1)
<< 8;
g_CurrentRoom.y =
((D_801375BC.def - 1)->tilesetId - g_CurrentRoom.top) << 8;
g_CurrentRoom.width =
(((D_801375BC.def - 1)->objGfxId - g_CurrentRoom.left) + 1)
<< 8;
g_CurrentRoom.height =
(((D_801375BC.def - 1)->objLayoutId - g_CurrentRoom.top) +
1)
g_Tilemap.height =
(((D_801375BC.def - 1)->objLayoutId - g_Tilemap.top) + 1)
<< 8;
// permuter found this weird & -> thing, I don't know man
(&g_Camera.posX)->i.hi = (D_8009791C - g_CurrentRoom.left) << 8;
g_Camera.posY.i.hi = (D_80097920 - g_CurrentRoom.top) << 8;
playerX = PLAYER.posX.i.hi + g_Camera.posX.i.hi;
playerY = PLAYER.posY.i.hi + g_Camera.posY.i.hi;
(&g_Tilemap.cameraX)->i.hi = (D_8009791C - g_Tilemap.left) << 8;
g_Tilemap.cameraY.i.hi = (D_80097920 - g_Tilemap.top) << 8;
playerX = PLAYER.posX.i.hi + g_Tilemap.cameraX.i.hi;
playerY = PLAYER.posY.i.hi + g_Tilemap.cameraY.i.hi;
func_8011A9D8();
PLAYER.zPriority = g_unkGraphicsStruct.g_zEntityCenter.S16.unk0;
func_800F0CD8(0);
func_8010BFFC();
playerX = PLAYER.posX.i.hi + g_Camera.posX.i.hi;
playerY = PLAYER.posY.i.hi + g_Camera.posY.i.hi;
playerX = PLAYER.posX.i.hi + g_Tilemap.cameraX.i.hi;
playerY = PLAYER.posY.i.hi + g_Tilemap.cameraY.i.hi;
func_800F0CD8(0);
if (g_StageId == STAGE_RTOP) {
DestroyEntities(0x40);
for (i = 0; i < LEN(g_unkGraphicsStruct.D_8009742C); i++) {
g_unkGraphicsStruct.D_8009742C[i] = 0;
}
D_80073074 = (s32)g_Camera.posX.i.hi;
D_8007307C = (s32)g_Camera.posY.i.hi;
D_80073074 = (s32)g_Tilemap.cameraX.i.hi;
D_8007307C = (s32)g_Tilemap.cameraY.i.hi;
g_api.o.InitRoomEntities(D_801375BC.def->objLayoutId);
g_api.o.Update();
func_800F0CD8(0);
@ -658,8 +657,8 @@ void func_800F298C(void) {
for (i = 0; i < LEN(g_unkGraphicsStruct.D_8009742C); i++) {
g_unkGraphicsStruct.D_8009742C[i] = 0;
}
D_80073074 = g_Camera.posX.i.hi;
D_8007307C = g_Camera.posY.i.hi;
D_80073074 = g_Tilemap.cameraX.i.hi;
D_8007307C = g_Tilemap.cameraY.i.hi;
g_api.o.InitRoomEntities(D_801375BC.def->objLayoutId);
g_api.o.Update();
func_800F0CD8(0);
@ -669,8 +668,8 @@ void func_800F298C(void) {
g_unkGraphicsStruct.D_8009742C[i] = 0;
}
}
D_80073074 = g_Camera.posX.i.hi;
D_8007307C = g_Camera.posY.i.hi;
D_80073074 = g_Tilemap.cameraX.i.hi;
D_8007307C = g_Tilemap.cameraY.i.hi;
if (D_80097C98 == 2) {
D_80097C98 = 3;
func_800EA5AC(0x40, 0xFF, 0xFF, 0xFF);

View File

@ -293,7 +293,7 @@ void DrawEntitiesHitbox(s32 blendMode) {
g_GpuUsage.tile++;
}
if (g_GpuUsage.drawModes < 0x400) {
if (g_GpuUsage.drawModes < MAX_DRAW_MODES) {
SetDrawMode(drawMode, 0, 0, (blendMode - 1) << 5, &g_Vram.D_800ACD80);
AddPrim(&ot[otIdx], drawMode);
g_GpuUsage.drawModes++;

View File

@ -273,9 +273,9 @@ TeleportCheck GetTeleportToOtherCastle(void) {
// Check for X/Y boundaries in TOP
if (g_StageId == STAGE_TOP) {
xCheckTop = (g_CurrentRoom.left << 8) + playerX - 8000;
xCheckTop = g_Tilemap.left * 256 + playerX - 8000;
if (ABS(xCheckTop) < 4) {
yCheckTop = (g_CurrentRoom.top << 8) + playerY - 2127;
yCheckTop = g_Tilemap.top * 256 + playerY - 2127;
if (ABS(yCheckTop) < 4) {
return TELEPORT_CHECK_TO_RTOP;
}
@ -284,15 +284,15 @@ TeleportCheck GetTeleportToOtherCastle(void) {
// Check for X/Y boundaries in RTOP
if (g_StageId == STAGE_RTOP) {
xCheckRTop = (g_CurrentRoom.left << 8) + playerX - 8384;
xCheckRTop = g_Tilemap.left * 256 + playerX - 8384;
if (ABS(xCheckRTop) < 4) {
#if defined(VERSION_US)
yCheckRTop = (g_CurrentRoom.top << 8) + playerY - 14407;
yCheckRTop = g_Tilemap.top * 256 + playerY - 14407;
if (ABS(yCheckRTop) < 4) {
return TELEPORT_CHECK_TO_TOP;
}
#elif defined(VERSION_HD)
yCheckRTop = (g_CurrentRoom.top << 8) + playerY;
yCheckRTop = g_Tilemap.top * 256 + playerY;
if (ABS(yCheckRTop) - 14407 < 4) {
return TELEPORT_CHECK_TO_TOP;
}

View File

@ -349,14 +349,14 @@ void func_80115C50(void) {
s32 dist;
if (g_StageId == STAGE_TOP) {
dist = (g_CurrentRoom.left * 256) + playerX;
dist = g_Tilemap.left * 256 + playerX;
dist = ABS(dist);
if (dist - 8000 > 0) {
PLAYER.posX.i.hi--;
}
dist = (g_CurrentRoom.left * 256) + playerX;
dist = g_Tilemap.left * 256 + playerX;
dist = ABS(dist);
if (dist - 8000 < 0) {
@ -365,14 +365,14 @@ void func_80115C50(void) {
}
if (g_StageId == (STAGE_TOP | STAGE_INVERTEDCASTLE_FLAG)) {
dist = (g_CurrentRoom.left * 256) + playerX;
dist = g_Tilemap.left * 256 + playerX;
dist = ABS(dist);
if (dist - 8384 > 0) {
PLAYER.posX.i.hi--;
}
dist = (g_CurrentRoom.left * 256) + playerX;
dist = g_Tilemap.left * 256 + playerX;
dist = ABS(dist);
if (dist - 8384 < 0) {

View File

@ -56,17 +56,16 @@ void CheckCollision(s32 x, s32 y, Collider* res, s32 unk) {
u32 var_v0;
u8 colType;
absX = x + g_Camera.posX.i.hi;
absY = y + g_Camera.posY.i.hi;
absX = x + g_Tilemap.cameraX.i.hi;
absY = y + g_Tilemap.cameraY.i.hi;
new_var = 0x10;
if (absX < 0 || (u32)absX >= g_CurrentRoom.hSize << 8 || absY < 0 ||
(u32)absY >= g_CurrentRoom_vSize << 8) {
if (absX < 0 || (u32)absX >= g_Tilemap.hSize << 8 || absY < 0 ||
(u32)absY >= g_Tilemap.vSize << 8) {
colType = 0;
} else {
u16 colTile =
g_CurrentRoomTileLayout
.fg[(absX >> 4) + (absY >> 4) * g_CurrentRoom.hSize * new_var];
colType = D_80073088->collision[colTile];
g_Tilemap.fg[(absX >> 4) + (absY >> 4) * g_Tilemap.hSize * new_var];
colType = g_Tilemap.D_80073088->collision[colTile];
}
res->effects = 0;
res->unk4 = res->unk14 = -(absX & 0xF);

View File

@ -799,8 +799,8 @@ extern u8 D_801EC000[];
void InitializePads(void);
void ReadPads(void);
void ClearBackbuffer(void);
void SetRoomForegroundLayer(LayerDef2* layerDef);
void SetRoomBackgroundLayer(s32 index, LayerDef2* layerDef);
void SetRoomForegroundLayer(LayerDef* layerDef);
void SetRoomBackgroundLayer(s32 index, LayerDef* layerDef);
void CheckCollision(s32 x, s32 y, Collider* res, s32 unk);
void DemoInit(s32 arg0);
void DemoUpdate(void);

View File

@ -35,9 +35,9 @@ TeleportCheck GetTeleportToOtherCastle(void) {
// Check for X/Y boundaries in TOP
if (g_StageId == STAGE_TOP) {
xCheckTop = (g_CurrentRoom.left << 8) + playerX - 8000;
xCheckTop = (g_Tilemap.left << 8) + playerX - 8000;
if (ABS(xCheckTop) < 4) {
yCheckTop = (g_CurrentRoom.top << 8) + playerY - 2127;
yCheckTop = (g_Tilemap.top << 8) + playerY - 2127;
if (ABS(yCheckTop) < 4) {
return TELEPORT_CHECK_TO_RTOP;
}
@ -46,9 +46,9 @@ TeleportCheck GetTeleportToOtherCastle(void) {
// Check for X/Y boundaries in RTOP
if (g_StageId == STAGE_RTOP) {
xCheckRTop = (g_CurrentRoom.left << 8) + playerX - 8384;
xCheckRTop = (g_Tilemap.left << 8) + playerX - 8384;
if (ABS(xCheckRTop) < 4) {
yCheckRTop = (g_CurrentRoom.top << 8) + playerY;
yCheckRTop = (g_Tilemap.top << 8) + playerY;
if (ABS(yCheckRTop) - 14407 < 4) {
return TELEPORT_CHECK_TO_TOP;
}

View File

@ -136,14 +136,14 @@ void func_8015BB80(void) {
s32 dist;
if (g_StageId == STAGE_TOP) {
dist = (g_CurrentRoom.left * 256) + playerX;
dist = g_Tilemap.left * 256 + playerX;
dist = ABS(dist);
if (dist - 8000 > 0) {
PLAYER.posX.i.hi--;
}
dist = (g_CurrentRoom.left * 256) + playerX;
dist = g_Tilemap.left * 256 + playerX;
dist = ABS(dist);
if (dist - 8000 < 0) {
@ -152,14 +152,14 @@ void func_8015BB80(void) {
}
if (g_StageId == (STAGE_TOP | STAGE_INVERTEDCASTLE_FLAG)) {
dist = (g_CurrentRoom.left * 256) + playerX;
dist = g_Tilemap.left * 256 + playerX;
dist = ABS(dist);
if (dist - 8384 > 0) {
PLAYER.posX.i.hi--;
}
dist = (g_CurrentRoom.left * 256) + playerX;
dist = g_Tilemap.left * 256 + playerX;
dist = ABS(dist);
if (dist - 8384 < 0) {

View File

@ -442,8 +442,8 @@ void func_80169D74(Entity* entity) {
}
temp = entity->ext.generic.unk84;
ptr = temp.unk + ((u16)entity->ext.generic.unk80.modeS16.unk0 * 4);
entity->posX.i.hi = ptr[0] - g_Camera.posX.i.hi;
entity->posY.i.hi = ptr[1] - g_Camera.posY.i.hi;
entity->posX.i.hi = ptr[0] - g_Tilemap.cameraX.i.hi;
entity->posY.i.hi = ptr[1] - g_Tilemap.cameraY.i.hi;
entity->ext.generic.unk80.modeS16.unk0 =
(entity->ext.generic.unk80.modeS16.unk0 + 1) & 0x3F;
}

View File

@ -637,8 +637,8 @@ void StoreSaveData(SaveData* save, s32 block, s32 cardIcon) {
dst->info.endGameFlags = g_IsTimeAttackUnlocked;
dst->info.character = g_PlayableCharacter;
dst->info.nRoomsExplored = g_RoomCount;
dst->info.roomX = g_CurrentRoom.left;
dst->info.roomY = g_CurrentRoom.top;
dst->info.roomX = g_Tilemap.left;
dst->info.roomY = g_Tilemap.top;
dst->info.saveSize = sizeof(SaveData);
*dstStatus = g_Status;
@ -672,8 +672,8 @@ s32 LoadSaveData(SaveData* save) {
g_IsTimeAttackUnlocked = save->info.endGameFlags;
g_PlayableCharacter = save->info.character;
g_RoomCount = save->info.nRoomsExplored;
g_CurrentRoom.left = save->info.roomX;
g_CurrentRoom.top = save->info.roomY;
g_Tilemap.left = save->info.roomX;
g_Tilemap.top = save->info.roomY;
srcStatus = &save->status;
srcNav = &save->menuNavigation;

View File

@ -227,8 +227,8 @@ void func_8017160C(s32 amount, s32 entityId) {
entity->params = i + 1;
entity->facingLeft = facing;
}
*((s16*)(&entity->ext.generic.unkAC)) = g_Camera.posX.i.hi;
*((s16*)(&entity->ext.generic.unkAE)) = g_Camera.posY.i.hi;
*((s16*)(&entity->ext.generic.unkAC)) = g_Tilemap.cameraX.i.hi;
*((s16*)(&entity->ext.generic.unkAE)) = g_Tilemap.cameraY.i.hi;
}
}
@ -333,8 +333,8 @@ void func_801719E0(Entity* self) {
} else {
self->ext.fam.ent = &g_Entities[3 + self->ext.fam.unk82];
}
self->ext.fam.cameraX = g_Camera.posX.i.hi;
self->ext.fam.cameraY = g_Camera.posY.i.hi;
self->ext.fam.cameraX = g_Tilemap.cameraX.i.hi;
self->ext.fam.cameraY = g_Tilemap.cameraY.i.hi;
if (self->ext.fam.unk82 == 0) {
for (i = 0; i < 16; i++) {
@ -386,8 +386,8 @@ void func_801719E0(Entity* self) {
} else {
self->ext.fam.ent = &g_Entities[3 + self->ext.fam.unk82];
}
self->ext.fam.cameraX = g_Camera.posX.i.hi;
self->ext.fam.cameraY = g_Camera.posY.i.hi;
self->ext.fam.cameraX = g_Tilemap.cameraX.i.hi;
self->ext.fam.cameraY = g_Tilemap.cameraY.i.hi;
for (i = 0; i < 16; i++) {
if (PLAYER.facingLeft) {
@ -484,8 +484,8 @@ void func_80171ED4(s32 arg0) {
}
}
D_80174D3C = 0;
*(u16*)&e->ext.generic.unkAC = g_Camera.posX.i.hi;
*(u16*)&e->ext.generic.unkAE = g_Camera.posY.i.hi;
*(u16*)&e->ext.generic.unkAC = g_Tilemap.cameraX.i.hi;
*(u16*)&e->ext.generic.unkAE = g_Tilemap.cameraY.i.hi;
}
INCLUDE_ASM("asm/us/servant/tt_000/nonmatchings/10E8", func_80172120);
@ -764,14 +764,14 @@ void func_80174210(Entity* self, s32 arg1) {
D_801710A0 = 0;
return;
}
cameraX = g_Camera.posX.i.hi;
cameraY = g_Camera.posY.i.hi;
if (D_801710A0 != g_Servant || D_801710A4 != g_CurrentRoom.left ||
D_801710A8 != g_CurrentRoom.top) {
cameraX = g_Tilemap.cameraX.i.hi;
cameraY = g_Tilemap.cameraY.i.hi;
if (D_801710A0 != g_Servant || D_801710A4 != g_Tilemap.left ||
D_801710A8 != g_Tilemap.top) {
var_s1 = D_8017109C;
D_801710A0 = g_Servant;
D_801710A4 = g_CurrentRoom.left;
D_801710A8 = g_CurrentRoom.top;
D_801710A4 = g_Tilemap.left;
D_801710A8 = g_Tilemap.top;
if (D_80170760[1].unkC != -1) {
var_s2 = 1;
do {

View File

@ -11,7 +11,7 @@ void CreateEntityWhenInVerticalRange(LayoutEntity* layoutObj) {
s16 posY;
Entity* entity;
posY = g_Camera.posY.i.hi;
posY = g_Tilemap.cameraY.i.hi;
yClose = posY - 0x40;
yFar = posY + 0x120;
if (yClose < 0) {
@ -51,7 +51,7 @@ void CreateEntityWhenInHorizontalRange(LayoutEntity* layoutObj) {
s16 posX;
Entity* entity;
posX = g_Camera.posX.i.hi;
posX = g_Tilemap.cameraX.i.hi;
xClose = posX - 0x40;
xFar = posX + 0x140;
if (xClose < 0) {
@ -205,7 +205,7 @@ INCLUDE_ASM("asm/us/st/cen/nonmatchings/11280", func_80193184);
void InitRoomEntities(s32 objLayoutId) {
u16* pObjLayoutStart = D_801801EC[objLayoutId];
Unkstruct8* currentRoomTileLayout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
s16 temp_s0;
s16 arg0;
s16 i;
@ -230,7 +230,7 @@ void InitRoomEntities(s32 objLayoutId) {
D_8019C768 += i * 2 + 2;
D_8019C768 = (D_8019C768[1] << 0x10) + D_8019C768[0];
}
arg0 = currentRoomTileLayout->unkA;
arg0 = tilemap->cameraX.i.hi;
temp_s0 = arg0 + 0x140;
i = arg0 - 0x40;
if (i < 0) {
@ -241,7 +241,7 @@ void InitRoomEntities(s32 objLayoutId) {
D_8019C770 = 0;
func_80192D30(i);
func_80192DD4(temp_s0);
func_80192FE4(currentRoomTileLayout->unkE + 0x120);
func_80192FE4(tilemap->cameraY.i.hi + 0x120);
}
INCLUDE_ASM("asm/us/st/cen/nonmatchings/11280", func_80193410);

View File

@ -408,8 +408,8 @@ void func_8018E3E8(void) {
entity->posX.i.hi = *g_Dialogue.unk40++ | entity->posX.i.hi;
entity->posY.i.hi = *g_Dialogue.unk40++ * 0x10;
entity->posY.i.hi = *g_Dialogue.unk40++ | entity->posY.i.hi;
entity->posX.i.hi -= g_Camera.posX.i.hi;
entity->posY.i.hi -= g_Camera.posY.i.hi;
entity->posX.i.hi -= g_Tilemap.cameraX.i.hi;
entity->posY.i.hi -= g_Tilemap.cameraY.i.hi;
break;
case 1:
@ -465,19 +465,19 @@ void func_8018E6C4(u8 ySteps) {
INCLUDE_ASM("asm/us/st/cen/nonmatchings/D600", EntityUnkId16);
void func_8018F890(s16 arg0) {
s16 temp_v0 = arg0 - g_CurrentRoom.height;
s16 temp_v0 = arg0 - g_Tilemap.height;
if (temp_v0 > 1) {
g_CurrentRoom.height++;
g_Tilemap.height++;
} else if (temp_v0 < -1) {
g_CurrentRoom.height--;
g_Tilemap.height--;
} else {
g_CurrentRoom.height = arg0;
g_Tilemap.height = arg0;
}
}
void func_8018F8EC(u16 index) {
Unkstruct8* t = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
u16 tilePos = 0x5B6;
u16* tileLayoutPtr = &D_8018068C[index * 4];
s32 i;
@ -485,7 +485,7 @@ void func_8018F8EC(u16 index) {
for (i = 0; i < 2; i++) {
for (j = 0; j < 4; j++) {
t->fg[tilePos] = *tileLayoutPtr;
tilemap->fg[tilePos] = *tileLayoutPtr;
tileLayoutPtr++;
tilePos++;
}
@ -495,7 +495,7 @@ void func_8018F8EC(u16 index) {
// platform that lifts you into chamber, starts cutscene, gives you holy glasses
void EntityPlatform(Entity* self) {
Unkstruct8* roomLayout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
Entity* player = &PLAYER;
Primitive* prim;
s16 primIndex;
@ -507,8 +507,8 @@ void EntityPlatform(Entity* self) {
self->posY.i.hi -= 8;
temp_a1 = func_80195318(self, 0x20, 0x11, 4);
temp_s1 = player->posX.i.hi + g_Camera.posX.i.hi;
temp_v0 = self->posY.i.hi + g_Camera.posY.i.hi;
temp_s1 = player->posX.i.hi + g_Tilemap.cameraX.i.hi;
temp_v0 = self->posY.i.hi + g_Tilemap.cameraY.i.hi;
switch (self->step) {
case 0:
@ -597,11 +597,11 @@ void EntityPlatform(Entity* self) {
}
if (g_Player.D_80072EF4 == 0) {
g_Player.D_80072EF4 = 0x8000;
player->posX.i.hi = 384 - roomLayout->unkA;
player->posX.i.hi = 384 - tilemap->cameraX.i.hi;
self->step++;
g_api.PlaySfx(SE_CEN_ELEVATOR_MOVE);
D_8019D424 |= 1;
roomLayout->unk48 = ((s16)roomLayout->unkE + 0x100);
tilemap->height = ((s16)tilemap->cameraY.i.hi + 0x100);
func_8018F8EC(0);
}
g_Player.D_80072EFC = 1;
@ -610,7 +610,7 @@ void EntityPlatform(Entity* self) {
case 4:
g_Player.D_80072EF4 = 0;
g_Player.D_80072EFC = 1;
player->posX.i.hi = 384 - roomLayout->unkA;
player->posX.i.hi = 384 - tilemap->cameraX.i.hi;
if (temp_v0 > 496) {
self->posY.i.hi--;
player->posY.i.hi--;
@ -670,7 +670,7 @@ void EntityPlatform(Entity* self) {
case 8:
func_8018F890(0x300);
if (roomLayout->unk48 == 0x300) {
if (tilemap->height == 0x300) {
self->step++;
}
break;
@ -686,7 +686,7 @@ void EntityPlatform(Entity* self) {
prim->x0 = prim->x2 = temp_a0;
prim->x1 = prim->x3 = temp_v1_4;
prim->y0 = prim->y1 = self->posY.i.hi + 15;
prim->y2 = prim->y3 = 0x268 - roomLayout->unkE;
prim->y2 = prim->y3 = 0x268 - tilemap->cameraY.i.hi;
}
// Black layer that covers room interior and lights up when cutscene starts
@ -720,7 +720,7 @@ void EntityRoomDarkness(Entity* self) {
temp_t0 = self->posX.i.hi - 32;
temp_a0 = self->posX.i.hi + 32;
self->flags |= FLAG_HAS_PRIMS;
temp_v1 = 0x178 - g_Camera.posY.i.hi;
temp_v1 = 0x178 - g_Tilemap.cameraY.i.hi;
temp_v0 = temp_v1 - 0x58;
temp_a1 = temp_v1 + 0x68;
self->posY.i.hi = temp_v1;
@ -871,7 +871,7 @@ void EntityElevatorStationary(Entity* self) {
prim = prim->next;
}
if ((s16)(player->posY.i.hi + g_Camera.posY.i.hi) < 80) {
if ((s16)(player->posY.i.hi + g_Tilemap.cameraY.i.hi) < 80) {
self->posY.i.hi = player->posY.i.hi;
player->posX.i.hi = self->posX.i.hi;
self->animCurFrame = 10;
@ -903,7 +903,7 @@ void EntityElevatorStationary(Entity* self) {
case 0:
self->posY.val += FIX(0.5);
player->posY.i.hi++;
posY = g_Camera.posY.i.hi + self->posY.i.hi;
posY = g_Tilemap.cameraY.i.hi + self->posY.i.hi;
if ((g_Timer % 16) == 0) {
func_8019A328(SE_CEN_ELEVATOR_MOVE);
}

View File

@ -4,8 +4,8 @@ void CreateEntityFromLayout(Entity* entity, LayoutEntity* initDesc) {
DestroyEntity(entity);
entity->entityId = initDesc->entityId & 0x3FF;
entity->pfnUpdate = PfnEntityUpdates[entity->entityId - 1];
entity->posX.i.hi = initDesc->posX - g_Camera.posX.i.hi;
entity->posY.i.hi = initDesc->posY - g_Camera.posY.i.hi;
entity->posX.i.hi = initDesc->posX - g_Tilemap.cameraX.i.hi;
entity->posY.i.hi = initDesc->posY - g_Tilemap.cameraY.i.hi;
entity->params = initDesc->params;
entity->entityRoomIndex = initDesc->entityRoomIndex >> 8;
entity->unk68 = (initDesc->entityId >> 0xA) & 7;

View File

@ -44,15 +44,15 @@ void func_80191B44(Entity* entity) {
switch (temp_s1) {
case 4:
case 5:
if (g_CurrentRoom.x != 0) {
if (g_Tilemap.x != 0) {
return;
}
break;
case 6:
if (g_pads->pressed & PAD_TRIANGLE) {
g_CurrentRoom.x = 0;
g_CurrentRoom.width = 1280;
g_Tilemap.x = 0;
g_Tilemap.width = 1280;
entity->step++;
return;
}
@ -70,10 +70,10 @@ void func_80191B44(Entity* entity) {
unk = 8;
temp_s1 = (temp_s1 * unk) + phi_v1;
temp_v0_2 = &D_80180590[temp_s1];
g_CurrentRoom.x = *(temp_v0_2++);
g_CurrentRoom.y = *(temp_v0_2++);
g_CurrentRoom.width = *(temp_v0_2++);
g_CurrentRoom.height = *(temp_v0_2++);
g_Tilemap.x = *(temp_v0_2++);
g_Tilemap.y = *(temp_v0_2++);
g_Tilemap.width = *(temp_v0_2++);
g_Tilemap.height = *(temp_v0_2++);
}
} else {
InitializeEntity(D_801804A0);
@ -139,7 +139,7 @@ void EntityBackgroundClouds(Entity* self) {
prim->type = PRIM_G4;
prim->x0 = prim->x2 = 0;
prim->x1 = prim->x3 = 0x100;
prim->y0 = prim->y1 = 0x6E - g_Camera.posY.i.hi;
prim->y0 = prim->y1 = 0x6E - g_Tilemap.cameraY.i.hi;
prim->y2 = prim->y3 = 0xF0;
setRGB0(prim, 16, 16, 16);
prim->priority = 0x20;
@ -148,8 +148,8 @@ void EntityBackgroundClouds(Entity* self) {
LOW(prim->r2) = LOW(prim->r0);
LOW(prim->r3) = LOW(prim->r0);
prim = prim->next;
camX = -g_Camera.posX.i.hi;
camY = 32 - g_Camera.posY.i.hi;
camX = -g_Tilemap.cameraX.i.hi;
camY = 32 - g_Tilemap.cameraY.i.hi;
while (prim != 0) {
prim->x0 = prim->x2 = camX;
camX += 95;

View File

@ -113,7 +113,7 @@ void EntitySuccubusClone(Entity* self) {
InitializeEntity(D_801804F4);
self->hitboxState = 0;
velX = self->ext.succubus.clonePosX -
(self->posX.i.hi + g_Camera.posX.i.hi)
(self->posX.i.hi + g_Tilemap.cameraX.i.hi)
<< 0x10;
if (velX < 0) {
velX += 0x3F;

View File

@ -28,7 +28,8 @@ void EntityUnkId1C(Entity* self) {
case 0:
InitializeEntity(D_801804F4);
self->hitboxState = 0;
velX = self->ext.generic.unkA0 - (self->posX.i.hi + g_Camera.posX.i.hi)
velX =
self->ext.generic.unkA0 - (self->posX.i.hi + g_Tilemap.cameraX.i.hi)
<< 0x10;
if (velX < 0) {
velX += 0x3F;

View File

@ -11,7 +11,7 @@ void CreateEntityWhenInVerticalRange(LayoutEntity* layoutObj) {
s16 posY;
Entity* entity;
posY = g_Camera.posY.i.hi;
posY = g_Tilemap.cameraY.i.hi;
yClose = posY - 0x40;
yFar = posY + 0x120;
if (yClose < 0) {
@ -51,7 +51,7 @@ void CreateEntityWhenInHorizontalRange(LayoutEntity* layoutObj) {
s16 posX;
Entity* entity;
posX = g_Camera.posX.i.hi;
posX = g_Tilemap.cameraX.i.hi;
xClose = posX - 0x40;
xFar = posX + 0x140;
if (xClose < 0) {
@ -135,7 +135,7 @@ INCLUDE_ASM("asm/us/st/dre/nonmatchings/173C4", func_801992C8);
void InitRoomEntities(s32 objLayoutId) {
u16* pObjLayoutStart = D_80180220[objLayoutId];
Unkstruct8* currentRoomTileLayout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
s16 temp_s0;
s16 arg0;
s16 i;
@ -160,7 +160,7 @@ void InitRoomEntities(s32 objLayoutId) {
D_801A32C8 += i * 2 + 2;
D_801A32C8 = (D_801A32C8[1] << 0x10) + D_801A32C8[0];
}
arg0 = currentRoomTileLayout->unkA;
arg0 = tilemap->cameraX.i.hi;
temp_s0 = arg0 + 0x140;
i = arg0 - 0x40;
if (i < 0) {
@ -171,14 +171,14 @@ void InitRoomEntities(s32 objLayoutId) {
D_801A32D0 = 0;
func_80198E74(i);
func_80198F18(temp_s0);
func_80199128(currentRoomTileLayout->unkE + 0x120);
func_80199128(tilemap->cameraY.i.hi + 0x120);
}
void func_80199554(void) {
Unkstruct8* currentRoomTileLayout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
if (D_80097908 != 0) {
s16 tmp = g_Camera.posX.i.hi;
s16 tmp = tilemap->cameraX.i.hi;
if (D_80097908 > 0) {
func_80198F18(tmp + 0x140);
} else {
@ -187,7 +187,7 @@ void func_80199554(void) {
}
if (D_8009790C != 0) {
s16 tmp = currentRoomTileLayout->unkE;
s16 tmp = tilemap->cameraY.i.hi;
if (D_8009790C > 0) {
func_801991CC(tmp + 0x120);
} else {

View File

@ -113,8 +113,8 @@ void EntitySuccubus(Entity* self) {
case SUCCUBUS_CS_1: // Disguised as Lisa
if (g_CastleFlags[SeenCutscene] || (g_DemoMode != Demo_None)) {
self->facingLeft = 0;
self->posX.i.hi = 416 - g_Camera.posX.i.hi;
self->posY.i.hi = 175 - g_Camera.posY.i.hi;
self->posX.i.hi = 416 - g_Tilemap.cameraX.i.hi;
self->posY.i.hi = 175 - g_Tilemap.cameraY.i.hi;
SetStep(SUCCUBUS_CS_4);
self->step_s = 3;
}
@ -172,8 +172,8 @@ void EntitySuccubus(Entity* self) {
switch (self->step_s) {
case 0:
self->facingLeft = 0;
self->posX.i.hi = 416 - g_Camera.posX.i.hi;
self->posY.i.hi = 175 - g_Camera.posY.i.hi;
self->posX.i.hi = 416 - g_Tilemap.cameraX.i.hi;
self->posY.i.hi = 175 - g_Tilemap.cameraY.i.hi;
self->step_s++;
case 1:
@ -258,7 +258,7 @@ void EntitySuccubus(Entity* self) {
TIMEATTACK_EVENT_SUCCUBUS_DEFEAT, TIMEATTACK_SET_RECORD);
self->velocityX = 0;
self->velocityY = 0;
posY = self->posY.i.hi + g_Camera.posY.i.hi;
posY = self->posY.i.hi + g_Tilemap.cameraY.i.hi;
if (posY > 160) {
self->velocityY = FIX(-2);
self->step_s = 1;
@ -280,12 +280,12 @@ void EntitySuccubus(Entity* self) {
AnimateEntity(D_80180768, self);
MoveEntity();
self->velocityY += FIX(0.125);
posY = self->posY.i.hi + g_Camera.posY.i.hi;
posY = self->posY.i.hi + g_Tilemap.cameraY.i.hi;
if (posY >= 176) {
func_801A046C(NA_SE_SU_LANDING);
self->posY.i.hi = 175 - g_Camera.posY.i.hi;
self->posY.i.hi = 175 - g_Tilemap.cameraY.i.hi;
SetSubStep(SUCCUBUS_DYING_ANIM_1);
posX = self->posX.i.hi + g_Camera.posX.i.hi;
posX = self->posX.i.hi + g_Tilemap.cameraX.i.hi;
if (posX < 80) {
D_801816C4 = self->facingLeft = 1;
} else if (posX > 432) {
@ -408,7 +408,7 @@ void EntitySuccubus(Entity* self) {
}
}
posX = self->posX.i.hi + g_Camera.posX.i.hi;
posX = self->posX.i.hi + g_Tilemap.cameraX.i.hi;
if (self->facingLeft != 0) {
posX = 512 - posX;
}
@ -591,9 +591,9 @@ void EntitySuccubus(Entity* self) {
FntPrint("ng status\n");
}
posY = self->posY.i.hi + g_Camera.posY.i.hi;
posY = self->posY.i.hi + g_Tilemap.cameraY.i.hi;
if (posY > 176) {
self->posY.i.hi = 176 - g_Camera.posY.i.hi;
self->posY.i.hi = 176 - g_Tilemap.cameraY.i.hi;
}
if (g_Player.unk60 == 0) {
@ -675,7 +675,7 @@ void EntitySuccubus(Entity* self) {
case SUCCUBUS_CLONE_ATTACK:
switch (self->step_s) {
case SUCCUBUS_CLONE_ATTACK_CREATE_CLONES:
posX = self->posX.i.hi + g_Camera.posX.i.hi;
posX = self->posX.i.hi + g_Tilemap.cameraX.i.hi;
posX -= 192;
// left bound limit
@ -694,7 +694,7 @@ void EntitySuccubus(Entity* self) {
clonesShootOrder += temp * 7;
entity = &g_Entities[112];
temp = self->posX.i.hi + g_Camera.posX.i.hi;
temp = self->posX.i.hi + g_Tilemap.cameraX.i.hi;
for (i = 0; i < 6; i++, entity++, clonesShootOrder++, posX += 64) {
CreateEntityFromEntity(E_SUCCUBUS_CLONE, self, entity);
@ -934,18 +934,18 @@ void EntitySuccubus(Entity* self) {
}
break;
}
posX = self->posX.i.hi + g_Camera.posX.i.hi;
posY = self->posY.i.hi + g_Camera.posY.i.hi;
posX = self->posX.i.hi + g_Tilemap.cameraX.i.hi;
posY = self->posY.i.hi + g_Tilemap.cameraY.i.hi;
if (self->velocityX < 0) {
if (posX < 40) {
self->posX.i.hi = 40 - g_Camera.posX.i.hi;
self->posX.i.hi = 40 - g_Tilemap.cameraX.i.hi;
}
} else if (posX > 480) {
self->posX.i.hi = 480 - g_Camera.posX.i.hi;
self->posX.i.hi = 480 - g_Tilemap.cameraX.i.hi;
}
if ((self->velocityY < 0) && (posY < 48)) {
self->posY.i.hi = 48 - g_Camera.posY.i.hi;
self->posY.i.hi = 48 - g_Tilemap.cameraY.i.hi;
}
// TODO: !FAKE
hitbox = (s8*)&D_80180830[self->animCurFrame][D_801807F8];

View File

@ -11,7 +11,7 @@ void CreateEntityWhenInVerticalRange(LayoutEntity* layoutObj) {
s16 posY;
Entity* entity;
posY = g_Camera.posY.i.hi;
posY = g_Tilemap.cameraY.i.hi;
yClose = posY - 0x40;
yFar = posY + 0x120;
if (yClose < 0) {
@ -51,7 +51,7 @@ void CreateEntityWhenInHorizontalRange(LayoutEntity* layoutObj) {
s16 posX;
Entity* entity;
posX = g_Camera.posX.i.hi;
posX = g_Tilemap.cameraX.i.hi;
xClose = posX - 0x40;
xFar = posX + 0x140;
if (xClose < 0) {
@ -158,7 +158,7 @@ INCLUDE_ASM("asm/us/st/mad/nonmatchings/EDB8", func_80190C78);
void InitRoomEntities(s32 objLayoutId) {
u16* pObjLayoutStart = g_pStObjLayout[objLayoutId];
Unkstruct8* currentRoomTileLayout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
s16 temp_s0;
s16 arg0;
s16 i;
@ -183,7 +183,7 @@ void InitRoomEntities(s32 objLayoutId) {
D_801997DC += i * 2 + 2;
D_801997DC = (D_801997DC[1] << 0x10) + D_801997DC[0];
}
arg0 = currentRoomTileLayout->unkA;
arg0 = tilemap->cameraX.i.hi;
temp_s0 = arg0 + 0x140;
i = arg0 - 0x40;
if (i < 0) {
@ -194,14 +194,14 @@ void InitRoomEntities(s32 objLayoutId) {
D_801997E4 = 0;
func_80190838(i);
func_801908DC(temp_s0);
func_80190AD8(currentRoomTileLayout->unkE + 0x120);
func_80190AD8(tilemap->cameraY.i.hi + 0x120);
}
void func_80190F04(void) {
Unkstruct8* currentRoomTileLayout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
if (D_80097908 != 0) {
s16 tmp = g_Camera.posX.i.hi;
s16 tmp = tilemap->cameraX.i.hi;
if (D_80097908 > 0)
func_801908DC(tmp + 0x140);
else
@ -209,7 +209,7 @@ void func_80190F04(void) {
}
if (D_8009790C != 0) {
s16 tmp = currentRoomTileLayout->unkE;
s16 tmp = tilemap->cameraY.i.hi;
if (D_8009790C > 0)
func_80190B7C(tmp + 0x120);
else

View File

@ -40,15 +40,15 @@ void EntityUnkId12(Entity* entity) {
switch (temp_s1) {
case 4:
case 5:
if (g_CurrentRoom.x != 0) {
if (g_Tilemap.x != 0) {
return;
}
break;
case 6:
if (g_pads->pressed & PAD_TRIANGLE) {
g_CurrentRoom.x = 0;
g_CurrentRoom.width = 1280;
g_Tilemap.x = 0;
g_Tilemap.width = 1280;
entity->step++;
return;
}
@ -66,10 +66,10 @@ void EntityUnkId12(Entity* entity) {
unk = 8;
temp_s1 = (temp_s1 * unk) + phi_v1;
temp_v0_2 = &D_80180DD0[temp_s1];
g_CurrentRoom.x = *(temp_v0_2++);
g_CurrentRoom.y = *(temp_v0_2++);
g_CurrentRoom.width = *(temp_v0_2++);
g_CurrentRoom.height = *(temp_v0_2++);
g_Tilemap.x = *(temp_v0_2++);
g_Tilemap.y = *(temp_v0_2++);
g_Tilemap.width = *(temp_v0_2++);
g_Tilemap.height = *(temp_v0_2++);
}
} else {
InitializeEntity(D_80180AF4);
@ -291,7 +291,7 @@ void EntityCastleDoor(Entity* self) {
case 1:
tilePos = 0x445;
for (i = 0, tilePtr = D_80181120; i < 8; tilePtr++, i++) {
g_CurrentRoomTileLayout.fg[tilePos] = *tilePtr;
g_Tilemap.fg[tilePos] = *tilePtr;
tilePos += 0x20;
}
self->ext.castleDoor.rotZ = -0x380;
@ -323,7 +323,7 @@ void EntityCastleDoor(Entity* self) {
g_api.PlaySfx(SE_CASTLE_GATE_CLOSE);
tilePos = 0x445;
for (i = 0, tilePtr = D_80181130; i < 8; tilePtr++, i++) {
g_CurrentRoomTileLayout.fg[tilePos] = *tilePtr;
g_Tilemap.fg[tilePos] = *tilePtr;
tilePos += 0x20;
}
}
@ -333,7 +333,7 @@ void EntityCastleDoor(Entity* self) {
self->step++;
tilePos = 0x445;
for (i = 0, tilePtr = D_80181130; i < 8; tilePtr++, i++) {
g_CurrentRoomTileLayout.fg[tilePos] = *tilePtr;
g_Tilemap.fg[tilePos] = *tilePtr;
tilePos += 0x20;
}
break;
@ -536,7 +536,7 @@ void EntityTransparentWater(Entity* self) {
AnimateEntity(D_80181224, self);
var_a3 = -1 * g_Camera.posX.i.hi % 38;
var_a3 = -1 * g_Tilemap.cameraX.i.hi % 38;
var_a3 += 304;
if (self->params != 0) {
var_a3 = 96;
@ -686,7 +686,7 @@ void EntityCavernDoor(Entity* self) {
}
for (tilePos = 0x76, i = 0; i < 3; i++) {
g_CurrentRoomTileLayout.fg[tilePos] = *tileLayoutPtr;
g_Tilemap.fg[tilePos] = *tileLayoutPtr;
tileLayoutPtr++;
tilePos += 0x10;
}
@ -722,7 +722,7 @@ void EntityCavernDoor(Entity* self) {
for (tilePos = 0x76, tileLayoutPtr = &D_80181230[3], i = 0; i < temp;
tileLayoutPtr++, tilePos += 0x10, i++) {
g_CurrentRoomTileLayout.fg[tilePos] = *tileLayoutPtr;
g_Tilemap.fg[tilePos] = *tileLayoutPtr;
}
if (!(g_Timer & 1)) {
@ -809,8 +809,8 @@ void EntityClickSwitch(Entity* entity) {
if (temp_a0 != 0) {
player->posY.i.hi++;
entity->posY.val += FIX(0.75);
if ((g_Camera.posY.i.hi + entity->posY.i.hi) > 160) {
entity->posY.i.hi = 160 - g_Camera.posY.i.hi;
if ((g_Tilemap.cameraY.i.hi + entity->posY.i.hi) > 160) {
entity->posY.i.hi = 160 - g_Tilemap.cameraY.i.hi;
g_api.PlaySfx(SE_FLOOR_SWITCH_CLICK);
g_CastleFlags[0x31] = 1;
entity->step++;
@ -870,16 +870,16 @@ void EntityPathBlockSmallWeight(Entity* self) {
case 2:
self->posY.val += FIX(0.5);
if ((self->posY.i.hi + g_Camera.posY.i.hi) >= 175) {
self->posY.i.hi = 175 - g_Camera.posY.i.hi;
if ((self->posY.i.hi + g_Tilemap.cameraY.i.hi) >= 175) {
self->posY.i.hi = 175 - g_Tilemap.cameraY.i.hi;
self->step++;
}
break;
case 3:
for (var_a1 = 0x179, i = 0; i < 2; var_a1 -= 0x20, i++) {
g_CurrentRoomTileLayout.fg[var_a1] = 0x4FA;
g_CurrentRoomTileLayout.fg[var_a1 + 1] = 0x4FA;
g_Tilemap.fg[var_a1] = 0x4FA;
g_Tilemap.fg[var_a1 + 1] = 0x4FA;
}
self->step++;
break;
@ -945,9 +945,9 @@ void EntityPathBlockTallWeight(Entity* self) {
case 2:
self->posY.val -= FIX(0.5);
temp = self->posY.i.hi + g_Camera.posY.i.hi;
temp = self->posY.i.hi + g_Tilemap.cameraY.i.hi;
if (temp <= -16) {
self->posY.i.hi = -16 - g_Camera.posY.i.hi;
self->posY.i.hi = -16 - g_Tilemap.cameraY.i.hi;
self->step++;
}
break;
@ -955,7 +955,7 @@ void EntityPathBlockTallWeight(Entity* self) {
func_801B9C44(WEIGHT_TALL);
do {
temp = self->posY.i.hi + g_Camera.posY.i.hi;
temp = self->posY.i.hi + g_Tilemap.cameraY.i.hi;
} while (0);
var_v0 = 112 - temp;
var_a1 = 0x157;
@ -965,13 +965,13 @@ void EntityPathBlockTallWeight(Entity* self) {
}
for (temp_a2 = var_v0 >> 4, i = 0; i < temp_a2; var_a1 -= 0x20, i++) {
g_CurrentRoomTileLayout.fg[var_a1] = 0;
g_CurrentRoomTileLayout.fg[var_a1 + 1] = 0;
g_Tilemap.fg[var_a1] = 0;
g_Tilemap.fg[var_a1 + 1] = 0;
}
for (temp_a2 = 8 - temp_a2, i = 0; i < temp_a2; var_a1 -= 0x20, i++) {
g_CurrentRoomTileLayout.fg[var_a1] = 0x4FA;
g_CurrentRoomTileLayout.fg[var_a1 + 1] = 0x4FA;
g_Tilemap.fg[var_a1] = 0x4FA;
g_Tilemap.fg[var_a1 + 1] = 0x4FA;
}
}
@ -989,17 +989,17 @@ void EntityTrapDoor(Entity* entity) {
if (g_TrapDoorFlag == 0) {
if (PLAYER.posY.val < entity->posY.val) {
g_CurrentRoomTileLayout.fg[0xA8E / 2] = 0x129;
g_CurrentRoomTileLayout.fg[0xA90 / 2] = 0x132;
g_Tilemap.fg[0xA8E / 2] = 0x129;
g_Tilemap.fg[0xA90 / 2] = 0x132;
DestroyEntity(entity);
break;
}
g_CurrentRoomTileLayout.fg[0xA8E / 2] = 0x6C8;
g_CurrentRoomTileLayout.fg[0xA90 / 2] = 0x6C9;
g_Tilemap.fg[0xA8E / 2] = 0x6C8;
g_Tilemap.fg[0xA90 / 2] = 0x6C9;
} else {
entity->animCurFrame = 30;
g_CurrentRoomTileLayout.fg[0xA8E / 2] = 0x6C8;
g_CurrentRoomTileLayout.fg[0xA90 / 2] = 0x6C9;
g_Tilemap.fg[0xA8E / 2] = 0x6C8;
g_Tilemap.fg[0xA90 / 2] = 0x6C9;
entity->step = 128;
}
@ -1036,8 +1036,8 @@ void EntityMermanRockLeftSide(Entity* self) {
tileLayoutPtr = &D_8018127C;
tilePos = 0x1F1;
for (i = 0; i < 3; i++) {
g_CurrentRoom.bg[0].layout[tilePos] = *tileLayoutPtr;
g_CurrentRoom.bg[0].layout[tilePos + 1] = *(tileLayoutPtr + 3);
g_Tilemap.bg[0].layout[tilePos] = *tileLayoutPtr;
g_Tilemap.bg[0].layout[tilePos + 1] = *(tileLayoutPtr + 3);
tileLayoutPtr++;
tilePos += 0x30;
}
@ -1046,8 +1046,8 @@ void EntityMermanRockLeftSide(Entity* self) {
tileLayoutPtr = &D_80181264;
tilePos = 0x1F1;
for (i = 0; i < 3; i++) {
g_CurrentRoomTileLayout.fg[tilePos] = *tileLayoutPtr;
g_CurrentRoomTileLayout.fg[tilePos + 1] = *(tileLayoutPtr + 3);
g_Tilemap.fg[tilePos] = *tileLayoutPtr;
g_Tilemap.fg[tilePos + 1] = *(tileLayoutPtr + 3);
tileLayoutPtr++;
tilePos += 0x30;
}
@ -1061,8 +1061,8 @@ void EntityMermanRockLeftSide(Entity* self) {
tileLayoutPtr = &D_80181258[self->ext.generic.unk84.S16.unk0 * 6];
tilePos = 0x1F1;
for (i = 0; i < 3; i++) {
g_CurrentRoomTileLayout.fg[tilePos] = *tileLayoutPtr;
g_CurrentRoomTileLayout.fg[tilePos + 1] = *(tileLayoutPtr + 3);
g_Tilemap.fg[tilePos] = *tileLayoutPtr;
g_Tilemap.fg[tilePos + 1] = *(tileLayoutPtr + 3);
tileLayoutPtr++;
tilePos += 0x30;
}
@ -1135,8 +1135,8 @@ void EntityMermanRockRightSide(Entity* self) {
tileLayoutPtr = &D_801812B8;
tilePos = 0x1FD;
for (i = 0; i < 3; i++) {
g_CurrentRoom.bg[0].layout[tilePos] = *tileLayoutPtr;
g_CurrentRoom.bg[0].layout[tilePos + 1] = *(tileLayoutPtr + 3);
g_Tilemap.bg[0].layout[tilePos] = *tileLayoutPtr;
g_Tilemap.bg[0].layout[tilePos + 1] = *(tileLayoutPtr + 3);
tileLayoutPtr++;
tilePos += 0x30;
}
@ -1145,8 +1145,8 @@ void EntityMermanRockRightSide(Entity* self) {
tileLayoutPtr = &D_801812A0;
tilePos = 0x1FD;
for (i = 0; i < 3; i++) {
g_CurrentRoomTileLayout.fg[tilePos] = *tileLayoutPtr;
g_CurrentRoomTileLayout.fg[tilePos + 1] = *(tileLayoutPtr + 3);
g_Tilemap.fg[tilePos] = *tileLayoutPtr;
g_Tilemap.fg[tilePos + 1] = *(tileLayoutPtr + 3);
tileLayoutPtr++;
tilePos += 0x30;
}
@ -1160,8 +1160,8 @@ void EntityMermanRockRightSide(Entity* self) {
tileLayoutPtr = &D_80181294[(self->ext.generic.unk84.S16.unk0 * 6)];
tilePos = 0x1FD;
for (i = 0; i < 3; i++) {
g_CurrentRoomTileLayout.fg[tilePos] = *tileLayoutPtr;
g_CurrentRoomTileLayout.fg[tilePos + 1] = *(tileLayoutPtr + 3);
g_Tilemap.fg[tilePos] = *tileLayoutPtr;
g_Tilemap.fg[tilePos + 1] = *(tileLayoutPtr + 3);
tileLayoutPtr++;
tilePos += 0x30;
}
@ -1234,14 +1234,14 @@ void EntityUnkId26(Entity* self) {
for (tileLayoutPtr = &D_801812E2, i = 0; i < 3; i++) {
tileLayoutPos = 0x420 + i;
for (j = 0; j < 5; tileLayoutPos += 0x30, j++, tileLayoutPtr++) {
g_CurrentRoomTileLayout.fg[tileLayoutPos] = *tileLayoutPtr;
g_Tilemap.fg[tileLayoutPos] = *tileLayoutPtr;
}
}
for (tileLayoutPtr = &D_8018131E, i = 0; i < 3; i++) {
tileLayoutPos = 0x420 + i;
for (j = 0; j < 5; j++, tileLayoutPtr++) {
g_CurrentRoom.bg[0].layout[tileLayoutPos] = *tileLayoutPtr;
g_Tilemap.bg[0].layout[tileLayoutPos] = *tileLayoutPtr;
tileLayoutPos += 0x30;
}
}
@ -1324,19 +1324,19 @@ void EntityStairwayPiece(Entity* self, u8 arg1, u8 arg2, u8 arg3) {
InitializeEntity(D_80180ADC);
self->hitboxWidth = 8;
self->hitboxHeight = 8;
self->posX.i.hi = 1432 - g_Camera.posX.i.hi;
self->posY.i.hi = 200 - g_Camera.posY.i.hi;
self->posX.i.hi = 1432 - g_Tilemap.cameraX.i.hi;
self->posY.i.hi = 200 - g_Tilemap.cameraY.i.hi;
self->hitPoints = 16;
if (g_CastleFlags[stairwayPieceBroken]) {
self->hitboxState = 0;
g_CurrentRoomTileLayout.fg[0x4D9] = 0x3EE;
g_CurrentRoomTileLayout.fg[0x539] = 0x3D2;
g_Tilemap.fg[0x4D9] = 0x3EE;
g_Tilemap.fg[0x539] = 0x3D2;
self->step = 32;
break;
}
self->hitboxState = 2;
g_CurrentRoomTileLayout.fg[0x4D9] = 0x408;
g_CurrentRoomTileLayout.fg[0x539] = 0x40D;
g_Tilemap.fg[0x4D9] = 0x408;
g_Tilemap.fg[0x539] = 0x40D;
break;
case 1:
@ -1351,8 +1351,8 @@ void EntityStairwayPiece(Entity* self, u8 arg1, u8 arg2, u8 arg3) {
case 2:
g_api.PlaySfx(SE_WALL_BREAK);
g_CurrentRoomTileLayout.fg[0x4D9] = 0x3EE;
g_CurrentRoomTileLayout.fg[0x539] = 0x3D2;
g_Tilemap.fg[0x4D9] = 0x3EE;
g_Tilemap.fg[0x539] = 0x3D2;
g_CastleFlags[stairwayPieceBroken] = true;
newEntity = AllocEntity(&g_Entities[160], &g_Entities[192]);
@ -1380,10 +1380,10 @@ void EntityStairwayPiece(Entity* self, u8 arg1, u8 arg2, u8 arg3) {
self->ext.prim = prim;
self->flags |= FLAG_HAS_PRIMS;
func_801D6FCC(prim, primIndex);
v1 = D_80073088->gfxIndex[0x409];
v1 = g_Tilemap.D_80073088->gfxIndex[0x409];
arg1 = v1;
temp = D_80073088->gfxPage[0x409];
prim->clut = D_80073088->clut[0x409];
temp = g_Tilemap.D_80073088->gfxPage[0x409];
prim->clut = g_Tilemap.D_80073088->clut[0x409];
prim->tpage = temp + 8;
arg1 *= 16;
arg3 = 0xF;
@ -1526,7 +1526,7 @@ void EntityDeathSkySwirl(Entity* self) {
prim->priority = 0x1F;
prim->blendMode = 0;
}
g_CurrentRoom.bg[0].D_800730F4 &= 0xFFFE;
g_Tilemap.bg[0].flags &= 0xFFFE;
self->ext.deathSkySwirl.unk84 -= 32;
SetGeomScreen(256);
SetGeomOffset(128, 192);
@ -1604,8 +1604,8 @@ void EntitySwitch(Entity* entity) {
if (temp_a0 != 0) {
player->posY.i.hi++;
entity->posY.val += FIX(0.25);
if ((g_Camera.posY.i.hi + entity->posY.i.hi) > 193) {
entity->posY.i.hi = 193 - g_Camera.posY.i.hi;
if ((g_Tilemap.cameraY.i.hi + entity->posY.i.hi) > 193) {
entity->posY.i.hi = 193 - g_Tilemap.cameraY.i.hi;
g_CastleFlags[0x32] = 1;
g_api.PlaySfx(SE_BARRIER_MOVE_2);
entity->step++;
@ -1635,7 +1635,7 @@ void EntityHeartRoomGoldDoor(Entity* self) {
for (
tilePos = 0x48, i = 7, self->step = 128, self->animCurFrame = 0;
i >= 0; tilePos += 0x10, i--) {
g_CurrentRoomTileLayout.fg[tilePos] = 0;
g_Tilemap.fg[tilePos] = 0;
}
break;
}
@ -1664,7 +1664,7 @@ void EntityHeartRoomGoldDoor(Entity* self) {
for (tilePos = 0x48, temp = 0x4FA, i = 7; i >= 0; tilePos += 0x10,
i--) {
g_CurrentRoomTileLayout.fg[tilePos] = temp;
g_Tilemap.fg[tilePos] = temp;
}
break;
@ -1695,7 +1695,7 @@ void EntityHeartRoomGoldDoor(Entity* self) {
}
for (tilePos = 0x48, i = 0; i < temp; tilePos += 0x10, i++) {
g_CurrentRoomTileLayout.fg[tilePos] = 0;
g_Tilemap.fg[tilePos] = 0;
}
if (!(g_Timer & 1)) {
@ -1737,18 +1737,18 @@ void EntityUnkId49(Entity* entity) {
InitializeEntity(D_80180ADC);
break;
case 1:
temp = g_CurrentRoomTileLayout.fg[9];
g_CurrentRoomTileLayout.fg[6] = temp;
temp = g_CurrentRoomTileLayout.fg[10];
g_CurrentRoomTileLayout.fg[7] = temp;
temp = g_CurrentRoomTileLayout.fg[0x39];
g_CurrentRoomTileLayout.fg[0x36] = temp;
temp = g_CurrentRoomTileLayout.fg[0x3A];
g_CurrentRoomTileLayout.fg[0x37] = temp;
temp = g_CurrentRoomTileLayout.fg[0x69];
g_CurrentRoomTileLayout.fg[0x66] = temp;
temp = g_CurrentRoomTileLayout.fg[0x6A];
g_CurrentRoomTileLayout.fg[0x67] = temp;
temp = g_Tilemap.fg[9];
g_Tilemap.fg[6] = temp;
temp = g_Tilemap.fg[10];
g_Tilemap.fg[7] = temp;
temp = g_Tilemap.fg[0x39];
g_Tilemap.fg[0x36] = temp;
temp = g_Tilemap.fg[0x3A];
g_Tilemap.fg[0x37] = temp;
temp = g_Tilemap.fg[0x69];
g_Tilemap.fg[0x66] = temp;
temp = g_Tilemap.fg[0x6A];
g_Tilemap.fg[0x67] = temp;
entity->step++;
break;
}

View File

@ -3,7 +3,7 @@
// pushes alucard to the right
void EntityPushAlucard(Entity* entity) {
Entity* player = &PLAYER;
Unkstruct8* roomLayout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
switch (entity->step) {
case 0:
@ -19,7 +19,7 @@ void EntityPushAlucard(Entity* entity) {
case 1:
player->posX.val += 0x60000;
if (roomLayout->unkA > 0x800) {
if (tilemap->cameraX.i.hi > 0x800) {
g_Entities[UNK_ENTITY_1].ext.alucardController.unk7C = false;
g_Player.D_80072EF4 = 0x2000;
entity->step++;
@ -57,7 +57,7 @@ void EntityPushAlucard(Entity* entity) {
case 4:
player->posX.val += 0x48000;
if (roomLayout->unkA > 0xF80) {
if (tilemap->cameraX.i.hi > 0xF80) {
g_api.PlaySfx(SE_NO3_ALUCARD_JUMP);
g_Player.D_80072EF4 = 0x2040;
entity->ext.generic.unk7C.S8.unk0 = 0;
@ -102,7 +102,7 @@ void EntityCastleDoorTransition(Entity* entity) {
case 1:
player->posX.val += entity->ext.castleDoorTransition.playerVelocity;
g_Player.D_80072EFC = 1;
if ((player->posX.i.hi + g_Camera.posX.i.hi) > 120) {
if ((player->posX.i.hi + g_Tilemap.cameraX.i.hi) > 120) {
g_Player.D_80072EF4 = 0;
entity->step++;
}
@ -124,7 +124,7 @@ void EntityCastleDoorTransition(Entity* entity) {
// large foreground tree during intro
void EntityForegroundTree(Entity* self) {
Unkstruct8* currentRoomTileLayout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
Entity *EntRange, *ent, *ent2;
u16* ptrParams;
u16 temp_s4;
@ -168,7 +168,7 @@ void EntityForegroundTree(Entity* self) {
case 1:
self->posX.i.hi = 128;
temp_s4 = var_s3 * currentRoomTileLayout->unkA / 256 + 352;
temp_s4 = var_s3 * tilemap->cameraX.i.hi / 256 + 352;
if (temp_s4 >= *ptrParams) {
ent = AllocEntity(&g_Entities[192], &g_Entities[256]);
if (ent != NULL) {
@ -209,7 +209,7 @@ void EntityForegroundTree(Entity* self) {
}
void EntityUnkId50(Entity* self) {
Unkstruct8* roomLayout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
Entity* newEntity;
Entity* temp;
u16 temp_s3;
@ -243,7 +243,7 @@ void EntityUnkId50(Entity* self) {
case 1:
self->posX.i.hi = 128;
ptr = &D_801814EC[self->ext.et_801BCC4C.unk7C * 2];
var_v0 = roomLayout->unkA * 0xC0;
var_v0 = tilemap->cameraX.i.hi * 0xC0;
if (var_v0 < 0) {
var_v0 += 0xFF;
@ -268,7 +268,7 @@ void EntityUnkId50(Entity* self) {
INCLUDE_ASM("asm/us/st/no3/nonmatchings/3C4EC", EntityBackgroundPineTrees);
void EntityUnkId52(Entity* self) {
Unkstruct8* layout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
Entity* newEntity;
Entity* temp;
u16 temp_s3;
@ -301,7 +301,7 @@ void EntityUnkId52(Entity* self) {
self->posX.i.hi = 0x80;
ptr = &D_801817F8[self->ext.et_801BCC4C.unk7C];
var_v0 = layout->unkA * 0x18;
var_v0 = tilemap->cameraX.i.hi * 0x18;
if (var_v0 < 0) {
var_v0 += 0xFF;
}

View File

@ -2,7 +2,7 @@
// intro owl and leaves
void EntityFlyingOwlAndLeaves(Entity* entity) {
Unkstruct8* currentRoomTiles = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
Entity* newEntity;
u16 animFlag = true;
u16 i;
@ -69,7 +69,7 @@ void EntityFlyingOwlAndLeaves(Entity* entity) {
}
}
MoveEntity();
if ((entity->params == 0) && (currentRoomTiles->unkA > 0xD80)) {
if ((entity->params == 0) && (tilemap->cameraX.i.hi > 0xD80)) {
entity->step++;
}
if (entity->posX.i.hi > 288) {

View File

@ -6,7 +6,7 @@ void EntityRoomTransition2(Entity* self) {
// Used as both a loop variable and a temp
s32 localVar;
Entity* gents = g_Entities;
Unkstruct8* layout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
if (self->ext.roomTransition2.unk80 == 0 && self->step < 4) {
g_api.PlaySfx(SE_DEATH_AMBIENCE);
@ -17,7 +17,7 @@ void EntityRoomTransition2(Entity* self) {
switch (self->step) {
case 0:
InitializeEntity(D_80180AD0);
layout->unk40 = 0xFC;
tilemap->y = 0xFC;
g_Player.D_80072EF4 = 0x2000;
D_8003C8B8 = 0;
g_Player.D_80072EFC = 1;
@ -85,7 +85,7 @@ void EntityRoomTransition2(Entity* self) {
if (prim->r0 >= 240) {
self->step++;
DestroyEntity(&g_Entities[208]);
g_CurrentRoom.bg[0].D_800730F4 |= 1;
g_Tilemap.bg[0].flags |= 1;
g_api.PlaySfx(0xA1);
g_api.PlaySfx(0x30F);
}
@ -99,7 +99,7 @@ void EntityRoomTransition2(Entity* self) {
if (prim->r0 == 0) {
DestroyEntity(self);
gents = &g_Entities[192];
layout->unk40 = 0;
tilemap->y = 0;
D_8003C8B8 = 1;
DestroyEntity(gents);
CreateEntityFromCurrentEntity(E_ID_17, gents);

View File

@ -11,7 +11,7 @@ void CreateEntityWhenInVerticalRange(LayoutEntity* layoutObj) {
s16 posY;
Entity* entity;
posY = g_Camera.posY.i.hi;
posY = g_Tilemap.cameraY.i.hi;
yClose = posY - 0x40;
yFar = posY + 0x120;
if (yClose < 0) {
@ -51,7 +51,7 @@ void CreateEntityWhenInHorizontalRange(LayoutEntity* layoutObj) {
s16 posX;
Entity* entity;
posX = g_Camera.posX.i.hi;
posX = g_Tilemap.cameraX.i.hi;
xClose = posX - 0x40;
xFar = posX + 0x140;
if (xClose < 0) {
@ -231,7 +231,7 @@ void func_801C3B84(s16 arg0) {
void InitRoomEntities(s32 objLayoutId) {
u16* pObjLayoutStart = g_pStObjLayout[objLayoutId];
Unkstruct8* currentRoomTileLayout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
s16 temp_s0;
s16 arg0;
s16 i;
@ -256,7 +256,7 @@ void InitRoomEntities(s32 objLayoutId) {
D_801D7114 += i * 2 + 2;
D_801D7114 = (D_801D7114[1] << 0x10) + D_801D7114[0];
}
arg0 = currentRoomTileLayout->unkA;
arg0 = tilemap->cameraX.i.hi;
temp_s0 = arg0 + 0x140;
i = arg0 - 0x40;
if (i < 0) {
@ -267,7 +267,7 @@ void InitRoomEntities(s32 objLayoutId) {
D_801D711C = 0;
func_801C3730(i);
func_801C37D4(temp_s0);
func_801C39E4(currentRoomTileLayout->unkE + 0x120);
func_801C39E4(tilemap->cameraY.i.hi + 0x120);
}
void func_801C37D4(s16);
@ -276,10 +276,10 @@ void func_801C3A88(s16);
void func_801C3B84(s16);
void func_801C3E10(void) {
Unkstruct8* currentRoomTileLayout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
if (D_80097908 != 0) {
s16 tmp = g_Camera.posX.i.hi;
s16 tmp = tilemap->cameraX.i.hi;
if (D_80097908 > 0)
func_801C37D4(tmp + 0x140);
else
@ -287,9 +287,9 @@ void func_801C3E10(void) {
}
if (D_8009790C != 0) {
s16 tmp = currentRoomTileLayout->unkE;
s16 tmp = tilemap->cameraY.i.hi;
if (D_8009790C > 0)
func_801C3A88(currentRoomTileLayout->unkE + 0x120);
func_801C3A88(tilemap->cameraY.i.hi + 0x120);
else
func_801C3B84(tmp - 0x40);
}

View File

@ -673,8 +673,8 @@ void func_801CF5E0(Entity* self) {
return;
}
temp_v0 =
self->ext.generic.unk84.S16.unk0 - self->posX.i.hi - g_Camera.posX.i.hi;
temp_v0 = self->ext.generic.unk84.S16.unk0 - self->posX.i.hi -
g_Tilemap.cameraX.i.hi;
if (temp_v0 > 16) {
SetStep(3);
@ -896,7 +896,7 @@ INCLUDE_ASM("asm/us/st/no3/nonmatchings/48A84", EntityAlucardWaterEffect);
// ID 0x35
void EntitySplashWater(Entity* self) {
Unkstruct8* tileLayout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
u16 params = self->params;
u16 temp_s2 = params >> 0xB;
u16 temp_s5 = (params >> 8) & 7;
@ -929,7 +929,7 @@ void EntitySplashWater(Entity* self) {
self->primIndex = primIndex;
temp_t3 = self->posY.i.hi;
temp_t8 = self->posX.i.hi;
self->ext.waterEffects.unk82 = temp_t3 + tileLayout->unkE;
self->ext.waterEffects.unk82 = temp_t3 + tilemap->cameraY.i.hi;
for (i = 0; prim != NULL; i++) {
if (i % 2) {
prim->u0 = prim->u2 = prim2->u0;
@ -1065,7 +1065,7 @@ void EntitySplashWater(Entity* self) {
}
temp_t3 = self->ext.waterEffects.unk82 - self->posY.i.hi;
temp_t3 -= tileLayout->unkE;
temp_t3 -= tilemap->cameraY.i.hi;
prim = &g_PrimBuf[self->primIndex];
for (i = 0; prim != NULL; i++) {
@ -1094,7 +1094,7 @@ void EntitySplashWater(Entity* self) {
// ID 0x36
void EntitySurfacingWater(Entity* self) {
Unkstruct8* tileLayout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
s16 left, right, bottom;
Primitive* prim;
s16 primIndex;
@ -1135,7 +1135,7 @@ void EntitySurfacingWater(Entity* self) {
bottom = self->posY.i.hi;
left = right - 9;
right += 9;
self->ext.waterEffects.unk82 = self->posY.i.hi + g_Camera.posY.i.hi;
self->ext.waterEffects.unk82 = self->posY.i.hi + g_Tilemap.cameraY.i.hi;
for (i = 0; i < 2; i++) {
prim->u2 = 0;
@ -1192,14 +1192,14 @@ void EntitySurfacingWater(Entity* self) {
ptr = D_801813AC;
if (self->velocityX < 0) {
right += 6;
x = right - tileLayout->unkA;
x = right - tilemap->cameraX.i.hi;
if (self->posX.i.hi < x) {
DestroyEntity(self);
return;
}
} else {
ptr++;
temp3 = tileLayout->unkA + 6;
temp3 = tilemap->cameraX.i.hi + 6;
x = right;
x += (ptr[self->ext.waterEffects.unk88] - temp3);
if (self->posX.i.hi >= x) {
@ -1214,7 +1214,7 @@ void EntitySurfacingWater(Entity* self) {
x = self->posX.i.hi;
y = self->posY.i.hi;
bottom = tempv0 - y - tileLayout->unkE;
bottom = tempv0 - y - tilemap->cameraY.i.hi;
prim = &g_PrimBuf[self->primIndex];
temp_t0 = x - 9;
@ -1238,7 +1238,7 @@ void EntitySurfacingWater(Entity* self) {
prim = prim->next;
j++;
}
self->ext.waterEffects.unk82 = self->posY.i.hi + tileLayout->unkE;
self->ext.waterEffects.unk82 = self->posY.i.hi + tilemap->cameraY.i.hi;
}
// ID 0x37

View File

@ -113,9 +113,10 @@ void EntityZombieSpawner(Entity* self) {
// Zombies are prevented from spawning too close to the
// edges of the room.
distCameraEntity = g_Camera.posX.i.hi + newEntity->posX.i.hi;
if ((distCameraEntity < (g_CurrentRoom.x + 128)) ||
((g_CurrentRoom.width - 128) < distCameraEntity)) {
distCameraEntity =
g_Tilemap.cameraX.i.hi + newEntity->posX.i.hi;
if ((distCameraEntity < (g_Tilemap.x + 128)) ||
((g_Tilemap.width - 128) < distCameraEntity)) {
DestroyEntity(newEntity);
}
}

View File

@ -39,15 +39,15 @@ void func_801B2540(Entity* entity) {
switch (temp_s1) {
case 4:
case 5:
if (g_CurrentRoom.x != 0) {
if (g_Tilemap.x != 0) {
return;
}
break;
case 6:
if (g_pads->pressed & PAD_TRIANGLE) {
g_CurrentRoom.x = 0;
g_CurrentRoom.width = 1280;
g_Tilemap.x = 0;
g_Tilemap.width = 1280;
entity->step++;
return;
}
@ -65,10 +65,10 @@ void func_801B2540(Entity* entity) {
unk = 8;
temp_s1 = (temp_s1 * unk) + phi_v1;
temp_v0_2 = &D_80180DA8[temp_s1];
g_CurrentRoom.x = *(temp_v0_2++);
g_CurrentRoom.y = *(temp_v0_2++);
g_CurrentRoom.width = *(temp_v0_2++);
g_CurrentRoom.height = *(temp_v0_2++);
g_Tilemap.x = *(temp_v0_2++);
g_Tilemap.y = *(temp_v0_2++);
g_Tilemap.width = *(temp_v0_2++);
g_Tilemap.height = *(temp_v0_2++);
}
} else {
InitializeEntity(D_80180A84);
@ -273,7 +273,7 @@ void EntityCastleDoor(Entity* self) {
tilePos = 0x445;
for (i = 0, tilePtr = D_80180FF8; i < 8; tilePtr++, i++) {
g_CurrentRoomTileLayout.fg[tilePos] = *tilePtr;
g_Tilemap.fg[tilePos] = *tilePtr;
tilePos += 0x20;
}
}
@ -473,7 +473,7 @@ void EntityTransparentWater(Entity* self) {
AnimateEntity(D_801810EC, self);
var_a3 = -1 * g_Camera.posX.i.hi % 38;
var_a3 = -1 * g_Tilemap.cameraX.i.hi % 38;
var_a3 += 304;
if (self->params != 0) {
var_a3 = 96;
@ -624,7 +624,7 @@ void func_801B40F8(Entity* self) {
}
for (tilePos = 0x76, i = 0; i < 3; i++) {
g_CurrentRoomTileLayout.fg[tilePos] = *tileLayoutPtr;
g_Tilemap.fg[tilePos] = *tileLayoutPtr;
tileLayoutPtr++;
tilePos += 0x10;
}
@ -663,7 +663,7 @@ void func_801B40F8(Entity* self) {
for (tilePos = 0x76, tileLayoutPtr = &D_801810F8[3], i = 0; i < temp;
tileLayoutPtr++, tilePos += 0x10, i++) {
g_CurrentRoomTileLayout.fg[tilePos] = *tileLayoutPtr;
g_Tilemap.fg[tilePos] = *tileLayoutPtr;
}
if (!(g_Timer & 1)) {
@ -750,8 +750,8 @@ void EntityClickSwitch(Entity* entity) {
if (temp_a0 != 0) {
player->posY.i.hi++;
entity->posY.val += FIX(0.75);
if ((g_Camera.posY.i.hi + entity->posY.i.hi) > 160) {
entity->posY.i.hi = 160 - g_Camera.posY.i.hi;
if ((g_Tilemap.cameraY.i.hi + entity->posY.i.hi) > 160) {
entity->posY.i.hi = 160 - g_Tilemap.cameraY.i.hi;
g_api.PlaySfx(NA_SE_EV_SWITCH_CLICK);
g_CastleFlags[49] = 1;
entity->step++;
@ -797,8 +797,8 @@ void EntityPathBlockSmallWeight(Entity* self) {
poly = (POLY_GT4*)poly->tag;
}
self->posX.i.hi = 416 - g_Camera.posX.i.hi;
self->posY.i.hi = 64 - g_Camera.posY.i.hi;
self->posX.i.hi = 416 - g_Tilemap.cameraX.i.hi;
self->posY.i.hi = 64 - g_Tilemap.cameraY.i.hi;
if (g_CastleFlags[49] != 0) {
self->posY.i.hi += 111;
self->step = 3;
@ -813,17 +813,17 @@ void EntityPathBlockSmallWeight(Entity* self) {
case 2:
self->posY.val += FIX(0.5);
if ((self->posY.i.hi + g_Camera.posY.i.hi) >= 175) {
if ((self->posY.i.hi + g_Tilemap.cameraY.i.hi) >= 175) {
func_801C2598(0x63D);
self->posY.i.hi = 175 - g_Camera.posY.i.hi;
self->posY.i.hi = 175 - g_Tilemap.cameraY.i.hi;
self->step++;
}
break;
case 3:
for (var_a1 = 0x179, i = 0; i < 2; var_a1 -= 0x20, i++) {
g_CurrentRoomTileLayout.fg[var_a1] = 0x4FA;
g_CurrentRoomTileLayout.fg[var_a1 + 1] = 0x4FA;
g_Tilemap.fg[var_a1] = 0x4FA;
g_Tilemap.fg[var_a1 + 1] = 0x4FA;
}
self->step++;
break;
@ -890,9 +890,9 @@ void EntityPathBlockTallWeight(Entity* self) {
case 2:
self->posY.val -= FIX(0.5);
temp = self->posY.i.hi + g_Camera.posY.i.hi;
temp = self->posY.i.hi + g_Tilemap.cameraY.i.hi;
if (temp <= -16) {
self->posY.i.hi = -16 - g_Camera.posY.i.hi;
self->posY.i.hi = -16 - g_Tilemap.cameraY.i.hi;
self->step++;
}
break;
@ -900,7 +900,7 @@ void EntityPathBlockTallWeight(Entity* self) {
func_801B44B4(WEIGHT_TALL);
do {
temp = self->posY.i.hi + g_Camera.posY.i.hi;
temp = self->posY.i.hi + g_Tilemap.cameraY.i.hi;
} while (0);
var_v0 = 112 - temp;
var_a1 = 0x157;
@ -910,13 +910,13 @@ void EntityPathBlockTallWeight(Entity* self) {
}
for (temp_a2 = var_v0 >> 4, i = 0; i < temp_a2; var_a1 -= 0x20, i++) {
g_CurrentRoomTileLayout.fg[var_a1] = 0;
g_CurrentRoomTileLayout.fg[var_a1 + 1] = 0;
g_Tilemap.fg[var_a1] = 0;
g_Tilemap.fg[var_a1 + 1] = 0;
}
for (temp_a2 = 8 - temp_a2, i = 0; i < temp_a2; var_a1 -= 0x20, i++) {
g_CurrentRoomTileLayout.fg[var_a1] = 0x4FA;
g_CurrentRoomTileLayout.fg[var_a1 + 1] = 0x4FA;
g_Tilemap.fg[var_a1] = 0x4FA;
g_Tilemap.fg[var_a1 + 1] = 0x4FA;
}
}
@ -932,17 +932,17 @@ void EntityTrapDoor(Entity* entity) {
if (g_TrapDoorFlag == 0) {
if (PLAYER.posY.val < entity->posY.val) {
g_CurrentRoomTileLayout.fg[0xA8E / 2] = 0x129;
g_CurrentRoomTileLayout.fg[0xA90 / 2] = 0x132;
g_Tilemap.fg[0xA8E / 2] = 0x129;
g_Tilemap.fg[0xA90 / 2] = 0x132;
DestroyEntity(entity);
return;
}
g_CurrentRoomTileLayout.fg[0xA8E / 2] = 0x6C8;
g_CurrentRoomTileLayout.fg[0xA90 / 2] = 0x6C9;
g_Tilemap.fg[0xA8E / 2] = 0x6C8;
g_Tilemap.fg[0xA90 / 2] = 0x6C9;
} else {
entity->animCurFrame = 30;
g_CurrentRoomTileLayout.fg[0xA8E / 2] = 0x6C8;
g_CurrentRoomTileLayout.fg[0xA90 / 2] = 0x6C9;
g_Tilemap.fg[0xA8E / 2] = 0x6C8;
g_Tilemap.fg[0xA90 / 2] = 0x6C9;
entity->step = 128;
}
@ -980,8 +980,8 @@ void EntityMermanRockLeftSide(Entity* self) {
tileLayoutPtr = &D_80181144;
tilePos = 0x1F1;
for (i = 0; i < 3; i++) {
g_CurrentRoom.bg[0].layout[tilePos] = *tileLayoutPtr;
g_CurrentRoom.bg[0].layout[tilePos + 1] = *(tileLayoutPtr + 3);
g_Tilemap.bg[0].layout[tilePos] = *tileLayoutPtr;
g_Tilemap.bg[0].layout[tilePos + 1] = *(tileLayoutPtr + 3);
tileLayoutPtr++;
tilePos += 0x30;
}
@ -990,8 +990,8 @@ void EntityMermanRockLeftSide(Entity* self) {
tileLayoutPtr = &D_8018112C;
tilePos = 0x1F1;
for (i = 0; i < 3; i++) {
g_CurrentRoomTileLayout.fg[tilePos] = *tileLayoutPtr;
g_CurrentRoomTileLayout.fg[tilePos + 1] = *(tileLayoutPtr + 3);
g_Tilemap.fg[tilePos] = *tileLayoutPtr;
g_Tilemap.fg[tilePos + 1] = *(tileLayoutPtr + 3);
tileLayoutPtr++;
tilePos += 0x30;
}
@ -1005,8 +1005,8 @@ void EntityMermanRockLeftSide(Entity* self) {
tileLayoutPtr = &D_80181120[self->ext.generic.unk84.S16.unk0 * 6];
tilePos = 0x1F1;
for (i = 0; i < 3; i++) {
g_CurrentRoomTileLayout.fg[tilePos] = *tileLayoutPtr;
g_CurrentRoomTileLayout.fg[tilePos + 1] = *(tileLayoutPtr + 3);
g_Tilemap.fg[tilePos] = *tileLayoutPtr;
g_Tilemap.fg[tilePos + 1] = *(tileLayoutPtr + 3);
tileLayoutPtr++;
tilePos += 0x30;
}
@ -1079,8 +1079,8 @@ void EntityMermanRockRightSide(Entity* self) {
tileLayoutPtr = &D_80181180;
tilePos = 0x1FD;
for (i = 0; i < 3; i++) {
g_CurrentRoom.bg[0].layout[tilePos] = *tileLayoutPtr;
g_CurrentRoom.bg[0].layout[tilePos + 1] = *(tileLayoutPtr + 3);
g_Tilemap.bg[0].layout[tilePos] = *tileLayoutPtr;
g_Tilemap.bg[0].layout[tilePos + 1] = *(tileLayoutPtr + 3);
tileLayoutPtr++;
tilePos += 0x30;
}
@ -1089,8 +1089,8 @@ void EntityMermanRockRightSide(Entity* self) {
tileLayoutPtr = &D_80181168;
tilePos = 0x1FD;
for (i = 0; i < 3; i++) {
g_CurrentRoomTileLayout.fg[tilePos] = *tileLayoutPtr;
g_CurrentRoomTileLayout.fg[tilePos + 1] = *(tileLayoutPtr + 3);
g_Tilemap.fg[tilePos] = *tileLayoutPtr;
g_Tilemap.fg[tilePos + 1] = *(tileLayoutPtr + 3);
tileLayoutPtr++;
tilePos += 0x30;
}
@ -1104,8 +1104,8 @@ void EntityMermanRockRightSide(Entity* self) {
tileLayoutPtr = &D_8018115C[(self->ext.generic.unk84.S16.unk0 * 6)];
tilePos = 0x1FD;
for (i = 0; i < 3; i++) {
g_CurrentRoomTileLayout.fg[tilePos] = *tileLayoutPtr;
g_CurrentRoomTileLayout.fg[tilePos + 1] = *(tileLayoutPtr + 3);
g_Tilemap.fg[tilePos] = *tileLayoutPtr;
g_Tilemap.fg[tilePos + 1] = *(tileLayoutPtr + 3);
tileLayoutPtr++;
tilePos += 0x30;
}
@ -1178,14 +1178,14 @@ void func_801B5488(Entity* self) {
for (tileLayoutPtr = &D_801811AA, i = 0; i < 3; i++) {
tileLayoutPos = 0x420 + i;
for (j = 0; j < 5; tileLayoutPos += 0x30, j++, tileLayoutPtr++) {
g_CurrentRoomTileLayout.fg[tileLayoutPos] = *tileLayoutPtr;
g_Tilemap.fg[tileLayoutPos] = *tileLayoutPtr;
}
}
for (tileLayoutPtr = &D_801811E6, i = 0; i < 3; i++) {
tileLayoutPos = 0x420 + i;
for (j = 0; j < 5; j++, tileLayoutPtr++) {
g_CurrentRoom.bg[0].layout[tileLayoutPos] = *tileLayoutPtr;
g_Tilemap.bg[0].layout[tileLayoutPos] = *tileLayoutPtr;
tileLayoutPos += 0x30;
}
}
@ -1267,19 +1267,19 @@ void EntityStairwayPiece(Entity* self, u8 arg1, u8 arg2, u8 arg3) {
InitializeEntity(D_80180A6C);
self->hitboxWidth = 8;
self->hitboxHeight = 8;
self->posX.i.hi = 1432 - g_Camera.posX.i.hi;
self->posY.i.hi = 200 - g_Camera.posY.i.hi;
self->posX.i.hi = 1432 - g_Tilemap.cameraX.i.hi;
self->posY.i.hi = 200 - g_Tilemap.cameraY.i.hi;
self->hitPoints = 16;
if (g_CastleFlags[stairwayPieceBroken]) {
self->hitboxState = 0;
g_CurrentRoomTileLayout.fg[0x4D9] = 0x3EE;
g_CurrentRoomTileLayout.fg[0x539] = 0x3D2;
g_Tilemap.fg[0x4D9] = 0x3EE;
g_Tilemap.fg[0x539] = 0x3D2;
self->step = 32;
break;
}
self->hitboxState = 2;
g_CurrentRoomTileLayout.fg[0x4D9] = 0x408;
g_CurrentRoomTileLayout.fg[0x539] = 0x40D;
g_Tilemap.fg[0x4D9] = 0x408;
g_Tilemap.fg[0x539] = 0x40D;
break;
case 1:
@ -1294,8 +1294,8 @@ void EntityStairwayPiece(Entity* self, u8 arg1, u8 arg2, u8 arg3) {
case 2:
g_api.PlaySfx(0x644);
g_CurrentRoomTileLayout.fg[0x4D9] = 0x3EE;
g_CurrentRoomTileLayout.fg[0x539] = 0x3D2;
g_Tilemap.fg[0x4D9] = 0x3EE;
g_Tilemap.fg[0x539] = 0x3D2;
g_CastleFlags[stairwayPieceBroken] = true;
newEntity = AllocEntity(&g_Entities[160], &g_Entities[192]);
@ -1323,10 +1323,10 @@ void EntityStairwayPiece(Entity* self, u8 arg1, u8 arg2, u8 arg3) {
self->ext.prim = prim;
self->flags |= FLAG_HAS_PRIMS;
func_801D2684(prim, primIndex);
v1 = D_80073088->gfxIndex[0x409];
v1 = g_Tilemap.D_80073088->gfxIndex[0x409];
arg1 = v1;
temp = D_80073088->gfxPage[0x409];
prim->clut = D_80073088->clut[0x409];
temp = g_Tilemap.D_80073088->gfxPage[0x409];
prim->clut = g_Tilemap.D_80073088->clut[0x409];
prim->tpage = temp + 8;
arg1 *= 16;
arg3 = 0xF;
@ -1480,8 +1480,8 @@ void EntitySwitch(Entity* self) {
if (temp_a0 != 0) {
player->posY.i.hi++;
self->posY.val += FIX(0.25);
if ((g_Camera.posY.i.hi + self->posY.i.hi) > 193) {
self->posY.i.hi = 193 - g_Camera.posY.i.hi;
if ((g_Tilemap.cameraY.i.hi + self->posY.i.hi) > 193) {
self->posY.i.hi = 193 - g_Tilemap.cameraY.i.hi;
g_CastleFlags[50] = true;
g_api.PlaySfx(NA_SE_EV_SWITCH_CLICK);
self->step++;
@ -1510,7 +1510,7 @@ void EntityHeartRoomGoldDoor(Entity* self) {
for (
tilePos = 0x48, i = 7, self->step = 128, self->animCurFrame = 0;
i >= 0; tilePos += 0x10, i--) {
g_CurrentRoomTileLayout.fg[tilePos] = 0;
g_Tilemap.fg[tilePos] = 0;
}
break;
}
@ -1539,7 +1539,7 @@ void EntityHeartRoomGoldDoor(Entity* self) {
for (tilePos = 0x48, temp = 0x4FA, i = 7; i >= 0; tilePos += 0x10,
i--) {
g_CurrentRoomTileLayout.fg[tilePos] = temp;
g_Tilemap.fg[tilePos] = temp;
}
break;
@ -1573,7 +1573,7 @@ void EntityHeartRoomGoldDoor(Entity* self) {
}
for (tilePos = 0x48, i = 0; i < temp; tilePos += 0x10, i++) {
g_CurrentRoomTileLayout.fg[tilePos] = 0;
g_Tilemap.fg[tilePos] = 0;
}
if (!(g_Timer & 1)) {
@ -1616,18 +1616,18 @@ void EntityUnkId49(Entity* self) {
InitializeEntity(D_80180A6C);
break;
case 1:
temp = g_CurrentRoomTileLayout.fg[0x12 / 2];
g_CurrentRoomTileLayout.fg[0xC / 2] = temp;
temp = g_CurrentRoomTileLayout.fg[0x14 / 2];
g_CurrentRoomTileLayout.fg[0xE / 2] = temp;
temp = g_CurrentRoomTileLayout.fg[0x72 / 2];
g_CurrentRoomTileLayout.fg[0x6C / 2] = temp;
temp = g_CurrentRoomTileLayout.fg[0x74 / 2];
g_CurrentRoomTileLayout.fg[0x6E / 2] = temp;
temp = g_CurrentRoomTileLayout.fg[0xD2 / 2];
g_CurrentRoomTileLayout.fg[0xCC / 2] = temp;
temp = g_CurrentRoomTileLayout.fg[0xD4 / 2];
g_CurrentRoomTileLayout.fg[0xCE / 2] = temp;
temp = g_Tilemap.fg[0x12 / 2];
g_Tilemap.fg[0xC / 2] = temp;
temp = g_Tilemap.fg[0x14 / 2];
g_Tilemap.fg[0xE / 2] = temp;
temp = g_Tilemap.fg[0x72 / 2];
g_Tilemap.fg[0x6C / 2] = temp;
temp = g_Tilemap.fg[0x74 / 2];
g_Tilemap.fg[0x6E / 2] = temp;
temp = g_Tilemap.fg[0xD2 / 2];
g_Tilemap.fg[0xCC / 2] = temp;
temp = g_Tilemap.fg[0xD4 / 2];
g_Tilemap.fg[0xCE / 2] = temp;
self->step++;
break;
}

View File

@ -7,7 +7,7 @@ INCLUDE_ASM("asm/us/st/np3/nonmatchings/394F0", EntityNumericDamage);
void CreateEntityWhenInVerticalRange(LayoutEntity* layoutObj) {
Entity* entity;
s16 posY = g_Camera.posY.i.hi;
s16 posY = g_Tilemap.cameraY.i.hi;
s16 yClose = posY - 64;
s16 yFar = posY + 288;
@ -44,7 +44,7 @@ void CreateEntityWhenInVerticalRange(LayoutEntity* layoutObj) {
void CreateEntityWhenInHorizontalRange(LayoutEntity* layoutObj) {
Entity* entity;
s16 posX = g_Camera.posX.i.hi;
s16 posX = g_Tilemap.cameraX.i.hi;
s16 xClose = posX - 64;
s16 xFar = posX + 320;
@ -223,7 +223,7 @@ void func_801BB3F4(s16 arg0) {
void InitRoomEntities(s32 objLayoutId) {
u16* pObjLayoutStart = g_pStObjLayout[objLayoutId];
Unkstruct8* currentRoomTileLayout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
s16 temp_s0;
s16 arg0;
s16 i;
@ -248,7 +248,7 @@ void InitRoomEntities(s32 objLayoutId) {
D_801D276C += i * 2 + 2;
D_801D276C = (D_801D276C[1] << 0x10) + D_801D276C[0];
}
arg0 = currentRoomTileLayout->unkA;
arg0 = tilemap->cameraX.i.hi;
temp_s0 = arg0 + 0x140;
i = arg0 - 0x40;
if (i < 0) {
@ -259,14 +259,14 @@ void InitRoomEntities(s32 objLayoutId) {
D_801D2774 = 0;
func_801BAFA0(i);
func_801BB044(temp_s0);
func_801BB254(currentRoomTileLayout->unkE + 0x120);
func_801BB254(tilemap->cameraY.i.hi + 0x120);
}
void func_801BB680(void) {
Unkstruct8* currentRoomTileLayout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
if (D_80097908 != 0) {
s16 tmp = g_Camera.posX.i.hi;
s16 tmp = tilemap->cameraX.i.hi;
if (D_80097908 > 0)
func_801BB044(tmp + 320);
else
@ -274,9 +274,9 @@ void func_801BB680(void) {
}
if (D_8009790C != 0) {
s16 tmp = currentRoomTileLayout->unkE;
s16 tmp = tilemap->cameraY.i.hi;
if (D_8009790C > 0)
func_801BB2F8(currentRoomTileLayout->unkE + 288);
func_801BB2F8(tilemap->cameraY.i.hi + 288);
else
func_801BB3F4(tmp - 64);
}

View File

@ -35,7 +35,7 @@ typedef enum {
// EntitySplashWater ID 0x2D
void EntitySplashWater(Entity* self) {
Unkstruct8* tileLayout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
u16 params = self->params;
u16 temp_s2 = params >> 0xB;
u16 temp_s5 = (params >> 8) & 7;
@ -68,7 +68,7 @@ void EntitySplashWater(Entity* self) {
self->primIndex = primIndex;
temp_t3 = self->posY.i.hi;
temp_t8 = self->posX.i.hi;
self->ext.waterEffects.unk82 = temp_t3 + tileLayout->unkE;
self->ext.waterEffects.unk82 = temp_t3 + tilemap->cameraY.i.hi;
for (i = 0; prim != NULL; i++) {
if (i % 2) {
prim->u0 = prim->u2 = prim2->u0;
@ -204,7 +204,7 @@ void EntitySplashWater(Entity* self) {
}
temp_t3 = self->ext.waterEffects.unk82 - self->posY.i.hi;
temp_t3 -= tileLayout->unkE;
temp_t3 -= tilemap->cameraY.i.hi;
prim = &g_PrimBuf[self->primIndex];
for (i = 0; prim != NULL; i++) {
@ -233,7 +233,7 @@ void EntitySplashWater(Entity* self) {
// ID 0x2E
void EntitySurfacingWater(Entity* self) {
Unkstruct8* tileLayout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
s16 left, right, bottom;
Primitive* prim;
s16 primIndex;
@ -274,7 +274,7 @@ void EntitySurfacingWater(Entity* self) {
bottom = self->posY.i.hi;
left = right - 9;
right += 9;
self->ext.waterEffects.unk82 = self->posY.i.hi + g_Camera.posY.i.hi;
self->ext.waterEffects.unk82 = self->posY.i.hi + g_Tilemap.cameraY.i.hi;
for (i = 0; i < 2; i++) {
prim->u2 = 0;
@ -331,14 +331,14 @@ void EntitySurfacingWater(Entity* self) {
ptr = D_80181230;
if (self->velocityX < 0) {
right += 6;
x = right - tileLayout->unkA;
x = right - tilemap->cameraX.i.hi;
if (self->posX.i.hi < x) {
DestroyEntity(self);
return;
}
} else {
ptr++;
temp3 = tileLayout->unkA + 6;
temp3 = tilemap->cameraX.i.hi + 6;
x = right;
x += (ptr[self->ext.waterEffects.unk88] - temp3);
if (self->posX.i.hi >= x) {
@ -353,7 +353,7 @@ void EntitySurfacingWater(Entity* self) {
x = self->posX.i.hi;
y = self->posY.i.hi;
bottom = tempv0 - y - tileLayout->unkE;
bottom = tempv0 - y - tilemap->cameraY.i.hi;
prim = &g_PrimBuf[self->primIndex];
temp_t0 = x - 9;
@ -377,7 +377,7 @@ void EntitySurfacingWater(Entity* self) {
prim = prim->next;
j++;
}
self->ext.waterEffects.unk82 = self->posY.i.hi + tileLayout->unkE;
self->ext.waterEffects.unk82 = self->posY.i.hi + tilemap->cameraY.i.hi;
}
// ID 0x2F
@ -729,9 +729,9 @@ void EntityMerman2(Entity* self) {
}
pos = D_80181230;
pos += (self->params >> 8) & 1;
posY += g_Camera.posY.i.hi;
posY += g_Tilemap.cameraY.i.hi;
if (pos[4] < posY) {
self->posY.i.hi = pos[4] - g_Camera.posY.i.hi - 24;
self->posY.i.hi = pos[4] - g_Tilemap.cameraY.i.hi - 24;
}
if ((u8)self->ext.merman2.timer++ > 32) {
@ -807,7 +807,7 @@ void EntityMerman2(Entity* self) {
pos += (self->params >> 8) & 1;
posY = self->posY.i.hi;
posY -= 24;
camY = g_Camera.posY.i.hi + posY;
camY = g_Tilemap.cameraY.i.hi + posY;
if (camY < pos[3]) {
g_api.PlaySfx(NA_SE_EV_WATER_SPLASH);
newEntity = AllocEntity(D_8007DE38, &D_8007DE38[24]);
@ -1476,9 +1476,9 @@ void EntityMermanSpawner(Entity* self) {
if (!(g_Timer & 0x3F)) {
Entity* player = &PLAYER;
temp = g_Camera.posY.i.hi + player->posY.i.hi;
temp = g_Tilemap.cameraY.i.hi + player->posY.i.hi;
if (temp >= 256) {
temp_s0 = g_Camera.posX.i.hi + player->posX.i.hi;
temp_s0 = g_Tilemap.cameraX.i.hi + player->posX.i.hi;
temp_s0_2 = 128;
temp_s0_2 = temp_s0 - temp_s0_2 + Random();
temp_s0 = temp_s0_2 - 64;
@ -1492,8 +1492,8 @@ void EntityMermanSpawner(Entity* self) {
} else {
CreateEntityFromCurrentEntity(0x39, newEntity);
}
newEntity->posX.i.hi = temp_s0_2 - g_Camera.posX.i.hi;
newEntity->posY.i.hi = temp2 - g_Camera.posY.i.hi;
newEntity->posX.i.hi = temp_s0_2 - g_Tilemap.cameraX.i.hi;
newEntity->posY.i.hi = temp2 - g_Tilemap.cameraY.i.hi;
}
}
}

View File

@ -119,7 +119,7 @@ void EntityMerman(Entity* self) {
self->facingLeft = (GetSideToPlayer() & 1) ^ 1;
}
MoveEntity();
camY = g_Camera.posY.i.hi;
camY = g_Tilemap.cameraY.i.hi;
posX = self->posX.i.hi;
posY = self->posY.i.hi;
posY -= 24;
@ -131,9 +131,9 @@ void EntityMerman(Entity* self) {
pos = D_80181230;
pos += (self->params >> 8) & 1;
posY += g_Camera.posY.i.hi;
posY += g_Tilemap.cameraY.i.hi;
if (pos[4] < posY) {
self->posY.i.hi = pos[4] - g_Camera.posY.i.hi - 24;
self->posY.i.hi = pos[4] - g_Tilemap.cameraY.i.hi - 24;
}
if ((u8)self->ext.merman.timer2++ > 32) {
self->ext.merman.timer2 = 0;
@ -156,7 +156,7 @@ void EntityMerman(Entity* self) {
MoveEntity();
pos = D_80181230;
pos += (self->params >> 8) & 1;
camY = g_Camera.posY.i.hi;
camY = g_Tilemap.cameraY.i.hi;
posY = self->posY.i.hi;
posY -= 20;
posY += camY;

View File

@ -62,7 +62,7 @@ void EntityBoneScimitar(Entity* self) {
self->palette += self->params;
self->flags &= ~(FLAG_DESTROY_IF_BARELY_OUT_OF_CAMERA |
FLAG_DESTROY_IF_OUT_OF_CAMERA | 0xC00);
self->ext.generic.unk9C = g_Camera.posX.i.hi + self->posX.i.hi;
self->ext.generic.unk9C = g_Tilemap.cameraX.i.hi + self->posX.i.hi;
if (self->params & D_80182460) {
DestroyEntity(self);
return;
@ -199,7 +199,7 @@ void EntityBoneScimitar(Entity* self) {
switch (self->step_s) {
case BONE_SCIMITAR_WALK_RIGHT:
self->velocityX = FIX(0.5);
if (((s16)((g_Camera.posX.i.hi + self->posX.i.hi) -
if (((s16)((g_Tilemap.cameraX.i.hi + self->posX.i.hi) -
((u16)self->ext.generic.unk9C))) > 32) {
self->step_s++;
}
@ -207,7 +207,7 @@ void EntityBoneScimitar(Entity* self) {
case BONE_SCIMITAR_WALK_LEFT:
self->velocityX = FIX(-0.5);
if (((s16)((g_Camera.posX.i.hi + ((u16)self->posX.i.hi)) -
if (((s16)((g_Tilemap.cameraX.i.hi + ((u16)self->posX.i.hi)) -
((u16)self->ext.generic.unk9C))) < -32) {
self->step_s--;
}

View File

@ -111,9 +111,10 @@ void EntityZombieSpawner(Entity* self) {
// Zombies are prevented from spawning too close to the
// edges of the room.
distCameraEntity = g_Camera.posX.i.hi + newEntity->posX.i.hi;
if ((distCameraEntity < (g_CurrentRoom.x + 128)) ||
((g_CurrentRoom.width - 128) < distCameraEntity)) {
distCameraEntity =
g_Tilemap.cameraX.i.hi + newEntity->posX.i.hi;
if ((distCameraEntity < (g_Tilemap.x + 128)) ||
((g_Tilemap.width - 128) < distCameraEntity)) {
DestroyEntity(newEntity);
}
}

View File

@ -220,8 +220,8 @@ void EntityLeftSecretRoomWall(Entity* self, u16* tileLayoutPtr, s32 tilePos) {
tilePos = 0x260;
for (i = 0; i < 4; i++) {
g_CurrentRoomTileLayout.fg[tilePos] = *tileLayoutPtr;
g_CurrentRoomTileLayout.fg[tilePos + 1] = *(tileLayoutPtr + 1);
g_Tilemap.fg[tilePos] = *tileLayoutPtr;
g_Tilemap.fg[tilePos + 1] = *(tileLayoutPtr + 1);
tilePos += 0x10;
tileLayoutPtr += 2;
}
@ -244,8 +244,8 @@ void EntityLeftSecretRoomWall(Entity* self, u16* tileLayoutPtr, s32 tilePos) {
tilePos = 0x260;
for (i = 0; i < 4; i++) {
g_CurrentRoomTileLayout.fg[tilePos] = *tileLayoutPtr;
g_CurrentRoomTileLayout.fg[tilePos + 1] = *(tileLayoutPtr + 1);
g_Tilemap.fg[tilePos] = *tileLayoutPtr;
g_Tilemap.fg[tilePos + 1] = *(tileLayoutPtr + 1);
tileLayoutPtr += 2;
tilePos += 0x10;
}
@ -299,8 +299,8 @@ void EntityBottomSecretRoomFloor(
tilePos = 0x2E7;
for (i = 0; i < 2; i++) {
g_CurrentRoomTileLayout.fg[tilePos] = *tileLayoutPtr;
g_CurrentRoomTileLayout.fg[tilePos + 1] = *(tileLayoutPtr + 1);
g_Tilemap.fg[tilePos] = *tileLayoutPtr;
g_Tilemap.fg[tilePos + 1] = *(tileLayoutPtr + 1);
tileLayoutPtr += 2;
tilePos += 0x10;
}
@ -323,8 +323,8 @@ void EntityBottomSecretRoomFloor(
tilePos = 0x2E7;
for (i = 0; i < 2; i++) {
g_CurrentRoomTileLayout.fg[tilePos] = *tileLayoutPtr;
g_CurrentRoomTileLayout.fg[tilePos + 1] = *(tileLayoutPtr + 1);
g_Tilemap.fg[tilePos] = *tileLayoutPtr;
g_Tilemap.fg[tilePos + 1] = *(tileLayoutPtr + 1);
tileLayoutPtr += 2;
tilePos += 0x10;
}
@ -459,9 +459,9 @@ void func_801B1C18(Entity* self) {
player = &PLAYER;
player->posY.i.hi++;
self->posY.val += FIX(1.0);
temp = g_Camera.posY.i.hi + self->posY.i.hi;
temp = g_Tilemap.cameraY.i.hi + self->posY.i.hi;
if (temp > 468) {
self->posY.i.hi = 468 - g_Camera.posY.i.hi;
self->posY.i.hi = 468 - g_Tilemap.cameraY.i.hi;
D_80180EB4 ^= self->params;
self->step++;
}
@ -476,9 +476,9 @@ void func_801B1C18(Entity* self) {
case 3:
self->posY.val += 0xFFFF0000;
temp = g_Camera.posY.i.hi + self->posY.i.hi;
temp = g_Tilemap.cameraY.i.hi + self->posY.i.hi;
if (temp < 464) {
self->posY.i.hi = 464 - g_Camera.posY.i.hi;
self->posY.i.hi = 464 - g_Tilemap.cameraY.i.hi;
self->step = 1;
}
break;
@ -522,26 +522,26 @@ void func_801B1E54(Entity* self, s16 primIndex) {
poly->pad3 = 2;
if (self->params & D_80180EB4) {
self->posY.i.hi = 480 - g_Camera.posY.i.hi;
self->posY.i.hi = 480 - g_Tilemap.cameraY.i.hi;
self->ext.generic.unk88.S8.unk0 = 1;
} else {
self->posY.i.hi = 452 - g_Camera.posY.i.hi;
self->posY.i.hi = 452 - g_Tilemap.cameraY.i.hi;
self->ext.generic.unk88.S8.unk0 = 0;
}
case 1:
if (self->params & D_80180EB4) {
self->posY.val += FIX(1.0);
temp = g_Camera.posY.i.hi + self->posY.i.hi;
temp = g_Tilemap.cameraY.i.hi + self->posY.i.hi;
if (temp > 480) {
self->posY.i.hi = 480 - g_Camera.posY.i.hi;
self->posY.i.hi = 480 - g_Tilemap.cameraY.i.hi;
}
var_v1 = 1;
} else {
self->posY.val += 0xFFFF0000;
temp = g_Camera.posY.i.hi + self->posY.i.hi;
temp = g_Tilemap.cameraY.i.hi + self->posY.i.hi;
if (temp < 452) {
self->posY.i.hi = 452 - g_Camera.posY.i.hi;
self->posY.i.hi = 452 - g_Tilemap.cameraY.i.hi;
self->step = 1;
}
var_v1 = 0;
@ -556,7 +556,7 @@ void func_801B1E54(Entity* self, s16 primIndex) {
poly = (POLY_GT4*)(*((s32*)(&self->ext.generic.unk7C)));
poly->x0 = self->posX.i.hi - 16;
poly->y0 = self->posY.i.hi - 16;
temp = 480 - (g_Camera.posY.i.hi + self->posY.i.hi);
temp = 480 - (g_Tilemap.cameraY.i.hi + self->posY.i.hi);
D_801CB736[self->params] = temp;
}
@ -619,7 +619,7 @@ void EntityMoveableBox(Entity* self) {
func_801BCF74(&D_80180EB8);
if (self->params == 0) {
temp_v0_2 = self->posX.i.hi + g_Camera.posX.i.hi;
temp_v0_2 = self->posX.i.hi + g_Tilemap.cameraX.i.hi;
var_v1 = temp_v0_2 - 192;
var_v1 = ABS(var_v1);
var_v0 = temp_v0_2 - 256;
@ -636,7 +636,7 @@ void EntityMoveableBox(Entity* self) {
self->ext.generic.unk84.unk = var_s1;
if (var_s1 != 0) {
self->posY.i.hi =
(448 - D_801CB736[var_s1]) - g_Camera.posY.i.hi;
(448 - D_801CB736[var_s1]) - g_Tilemap.cameraY.i.hi;
}
}
break;
@ -766,7 +766,7 @@ void EntityCannon(Entity* self) {
prim->u1 = 0x40;
prim->v1 = 0x28;
prim->x0 = self->posX.i.hi - 8;
prim->y0 = 120 - g_Camera.posY.i.hi;
prim->y0 = 120 - g_Tilemap.cameraY.i.hi;
prim->priority = 0x78;
prim->blendMode = 2;
@ -833,7 +833,7 @@ void EntityCannonShot(Entity* self) {
case 1:
MoveEntity();
if ((self->posX.i.hi + g_Camera.posX.i.hi) < 112) {
if ((self->posX.i.hi + g_Tilemap.cameraX.i.hi) < 112) {
g_api.func_80102CD8(1);
newEntity = AllocEntity(&g_Entities[224], &g_Entities[256]);
if (newEntity != NULL) {
@ -860,7 +860,7 @@ void EntityCannonWall(Entity* self) {
cond = g_CastleFlags[131] != 0;
tileLayoutPtr = (-cond & 6) + &D_80180ED4[0];
for (tilePos = 0x46, i = 0; i < 6; i++, tileLayoutPtr++) {
g_CurrentRoomTileLayout.fg[tilePos] = *tileLayoutPtr;
g_Tilemap.fg[tilePos] = *tileLayoutPtr;
tilePos += 0x10;
}
@ -881,7 +881,7 @@ void EntityCannonWall(Entity* self) {
tileLayoutPtr = &D_80180EE0;
for (tilePos = 0x46, i = 0; i < 6; i++, tileLayoutPtr++) {
g_CurrentRoomTileLayout.fg[tilePos] = *tileLayoutPtr;
g_Tilemap.fg[tilePos] = *tileLayoutPtr;
tilePos += 0x10;
}
DestroyEntity(self);
@ -903,7 +903,7 @@ void func_801B2AD8(Entity* self) {
self->hitboxWidth = 6;
self->hitboxState = 1;
CreateEntityFromEntity(0x26, self, &self[-1]);
self[-1].posY.i.hi = 344 - g_Camera.posY.i.hi;
self[-1].posY.i.hi = 344 - g_Tilemap.cameraY.i.hi;
primIndex = g_api.AllocPrimitives(PRIM_GT4, 1);
if (primIndex == -1) {
@ -934,16 +934,16 @@ void func_801B2AD8(Entity* self) {
if (var_a0 != 0) {
self->posY.val += FIX(1.0);
temp = g_Camera.posY.i.hi + self->posY.i.hi;
temp = g_Tilemap.cameraY.i.hi + self->posY.i.hi;
if (temp > 376) {
self->posY.i.hi = 376 - g_Camera.posY.i.hi;
self->posY.i.hi = 376 - g_Tilemap.cameraY.i.hi;
}
g_CallElevator = true;
} else {
self->posY.val += 0xFFFF0000;
temp = g_Camera.posY.i.hi + self->posY.i.hi;
temp = g_Tilemap.cameraY.i.hi + self->posY.i.hi;
if (temp < 372) {
self->posY.i.hi = 372 - g_Camera.posY.i.hi;
self->posY.i.hi = 372 - g_Tilemap.cameraY.i.hi;
}
g_CallElevator = false;
}
@ -1009,7 +1009,7 @@ void EntityElevator2(Entity* self) {
player = PLAYER_CHARACTER;
if (g_CallElevator) {
self->posY.i.hi--;
camY = g_Camera.posY.i.hi;
camY = g_Tilemap.cameraY.i.hi;
if ((self->posY.i.hi + camY) < 96) {
self->posY.i.hi = 96 - camY;
} else if (temp != 0) {
@ -1018,7 +1018,7 @@ void EntityElevator2(Entity* self) {
}
} else {
self->posY.i.hi++;
camY = g_Camera.posY.i.hi;
camY = g_Tilemap.cameraY.i.hi;
if ((self->posY.i.hi + camY) > 216) {
self->posY.i.hi = 216 - camY;
} else if (temp != 0) {
@ -1051,7 +1051,8 @@ void func_801B2FD8(Entity* self) {
switch (self->step) {
case 0:
InitializeEntity(D_80180BF8);
self->ext.generic.unk80.modeS32 = self->posY.i.hi + g_Camera.posY.i.hi;
self->ext.generic.unk80.modeS32 =
self->posY.i.hi + g_Tilemap.cameraY.i.hi;
primIndex = g_api.AllocPrimitives(PRIM_GT4, 1);
if (primIndex == -1) {
DestroyEntity(self);
@ -1071,26 +1072,26 @@ void func_801B2FD8(Entity* self) {
prim->blendMode = 2;
posX = self->posX.i.hi;
posX += g_Camera.posX.i.hi;
posX += g_Tilemap.cameraX.i.hi;
posX >>= 4;
// TODO: !FAKE
camY = self->posY.i.hi;
posY = camY += 4;
posY = camY += g_Camera.posY.i.hi;
posY = camY += g_Tilemap.cameraY.i.hi;
camY = (camY >> 4) * g_CurrentRoom.hSize * 16;
g_CurrentRoomTileLayout.fg[posX + camY] = 0x5AF;
camY = (camY >> 4) * g_Tilemap.hSize * 16;
g_Tilemap.fg[posX + camY] = 0x5AF;
case 1:
if (temp != 0) {
player = &PLAYER;
player->posY.i.hi++;
self->posY.val += FIX(1.0);
posY = g_Camera.posY.i.hi + self->posY.i.hi;
posY = g_Tilemap.cameraY.i.hi + self->posY.i.hi;
if ((self->ext.generic.unk80.modeS32 + 4) < posY) {
self->posY.i.hi = (self->ext.generic.unk80.modeS16.unk0 + 4) -
g_Camera.posY.i.hi;
g_Tilemap.cameraY.i.hi;
self[1].ext.stub[0xC] = 1;
self->step++;
LOW(self[1].ext.stub[0x8]) ^= 1;
@ -1106,10 +1107,10 @@ void func_801B2FD8(Entity* self) {
case 2:
if (temp == 0) {
self->posY.val += ~0xFFFF;
posY = g_Camera.posY.i.hi + self->posY.i.hi;
posY = g_Tilemap.cameraY.i.hi + self->posY.i.hi;
if (posY < self->ext.generic.unk80.modeS32) {
self->posY.i.hi =
self->ext.generic.unk80.modeS16.unk0 - g_Camera.posY.i.hi;
self->posY.i.hi = self->ext.generic.unk80.modeS16.unk0 -
g_Tilemap.cameraY.i.hi;
self->step = 1;
}
}
@ -1137,16 +1138,17 @@ void EntityFloorSpikes(Entity* self) {
self->attackElement = 1;
self->attack = 7;
self->hitboxState = 1;
self->ext.generic.unk80.modeS32 = self->posY.i.hi + g_Camera.posY.i.hi;
self->ext.generic.unk80.modeS32 =
self->posY.i.hi + g_Tilemap.cameraY.i.hi;
temp = 4;
new_var = self->posY.i.hi - 4;
new_var += g_Camera.posY.i.hi;
tilePos = ((self->posX.i.hi - temp + g_Camera.posX.i.hi) >> 4) +
(((new_var >> 4) * g_CurrentRoom.hSize) * 16);
new_var += g_Tilemap.cameraY.i.hi;
tilePos = ((self->posX.i.hi - temp + g_Tilemap.cameraX.i.hi) >> 4) +
(((new_var >> 4) * g_Tilemap.hSize) * 16);
g_CurrentRoomTileLayout.fg[tilePos] = 0x102;
g_CurrentRoomTileLayout.fg[tilePos + 1] = 0x103;
g_Tilemap.fg[tilePos] = 0x102;
g_Tilemap.fg[tilePos + 1] = 0x103;
primIndex = g_api.AllocPrimitives(PRIM_GT4, 1);
if (primIndex == -1) {
DestroyEntity(self);
@ -1170,16 +1172,16 @@ void EntityFloorSpikes(Entity* self) {
self->hitboxState = 1;
if (self->ext.generic.unk84.unk != 0) {
self->posY.val += FIX(1.0);
new_var = g_Camera.posY.i.hi + self->posY.i.hi;
var_v1 = g_Camera.posY.i.hi;
new_var = g_Tilemap.cameraY.i.hi + self->posY.i.hi;
var_v1 = g_Tilemap.cameraY.i.hi;
if (new_var > self->ext.generic.unk80.modeS32) {
self->hitboxState = 0;
self->posY.i.hi = self->ext.generic.unk80.modeS16.unk0 - var_v1;
}
} else {
self->posY.val += 0xFFFF0000;
new_var = g_Camera.posY.i.hi + self->posY.i.hi;
var_v1 = g_Camera.posY.i.hi;
new_var = g_Tilemap.cameraY.i.hi + self->posY.i.hi;
var_v1 = g_Tilemap.cameraY.i.hi;
if (new_var < (self->ext.generic.unk80.modeS32 - 28)) {
self->posY.i.hi =
self->ext.generic.unk80.modeS16.unk0 - 28 - var_v1;

View File

@ -188,19 +188,19 @@ s32 EntitySlograSpecialCollision(u16* unused) {
MoveEntity();
g_CurrentEntity->velocityY += FIX(0.25);
slograPosX = g_CurrentEntity->posX.i.hi + g_Camera.posX.i.hi;
slograPosX = g_CurrentEntity->posX.i.hi + g_Tilemap.cameraX.i.hi;
if (g_CurrentEntity->velocityX > 0 && slograPosX > 896) {
g_CurrentEntity->posX.i.hi = 896 - g_Camera.posX.i.hi;
g_CurrentEntity->posX.i.hi = 896 - g_Tilemap.cameraX.i.hi;
}
if (g_CurrentEntity->velocityX < 0 && slograPosX < 64) {
g_CurrentEntity->posX.i.hi = 64 - g_Camera.posX.i.hi;
g_CurrentEntity->posX.i.hi = 64 - g_Tilemap.cameraX.i.hi;
}
if (g_CurrentEntity->posY.i.hi + g_Camera.posY.i.hi > 416) {
if (g_CurrentEntity->posY.i.hi + g_Tilemap.cameraY.i.hi > 416) {
ret = 1;
g_CurrentEntity->posY.i.hi = 416 - g_Camera.posY.i.hi;
g_CurrentEntity->posY.i.hi = 416 - g_Tilemap.cameraY.i.hi;
g_CurrentEntity->velocityX = 0;
g_CurrentEntity->velocityY = 0;
}
@ -502,8 +502,8 @@ void EntitySlogra(Entity* self) {
MoveEntity();
self->velocityY += FIX(0.25);
if (self->posY.i.hi + g_Camera.posY.i.hi > 416) {
self->posY.i.hi = 416 - g_Camera.posY.i.hi;
if (self->posY.i.hi + g_Tilemap.cameraY.i.hi > 416) {
self->posY.i.hi = 416 - g_Tilemap.cameraY.i.hi;
func_801C29B0(NA_SE_EN_SLOGRA_FLOOR_STOMP);
g_api.func_80102CD8(1);
self->ext.GS_Props.timer = 16;
@ -1204,18 +1204,18 @@ void EntityGaibon(Entity* self) {
}
if (!(self->flags & 0x100)) {
slograGaibonDistX = self->posX.i.hi + g_Camera.posX.i.hi;
slograGaibonDistY = self->posY.i.hi + g_Camera.posY.i.hi;
slograGaibonDistX = self->posX.i.hi + g_Tilemap.cameraX.i.hi;
slograGaibonDistY = self->posY.i.hi + g_Tilemap.cameraY.i.hi;
if (self->velocityX > 0 && slograGaibonDistX > 784) {
self->posX.i.hi = 784 - g_Camera.posX.i.hi;
self->posX.i.hi = 784 - g_Tilemap.cameraX.i.hi;
}
if (self->velocityX < 0 && slograGaibonDistX < 96) {
self->posX.i.hi = 96 - g_Camera.posX.i.hi;
self->posX.i.hi = 96 - g_Tilemap.cameraX.i.hi;
}
if (self->velocityY > 0 && slograGaibonDistY > 420) {
self->posY.i.hi = 420 - g_Camera.posY.i.hi;
self->posY.i.hi = 420 - g_Tilemap.cameraY.i.hi;
}
hitbox = &D_80181340[self->animCurFrame][D_80181310];

View File

@ -9,7 +9,8 @@ void func_801B6DE4(Entity* self) {
switch (self->step) {
case 0:
InitializeEntity(D_80180BF8);
self->ext.generic.unk80.modeS32 = self->posY.i.hi + g_Camera.posY.i.hi;
self->ext.generic.unk80.modeS32 =
self->posY.i.hi + g_Tilemap.cameraY.i.hi;
self->hitboxHeight = 8;
self->hitboxOffY = -22;
self->hitboxWidth = 6;
@ -38,10 +39,10 @@ void func_801B6DE4(Entity* self) {
case 1:
if (temp_s1 != 0) {
self->posY.val += FIX(1.0);
y = g_Camera.posY.i.hi + self->posY.i.hi;
y = g_Tilemap.cameraY.i.hi + self->posY.i.hi;
if ((self->ext.generic.unk80.modeS32 + 4) < y) {
self->posY.i.hi = (u16)(self->ext.generic.unk80.modeS16.unk0 -
(g_Camera.posY.i.hi - 4));
(g_Tilemap.cameraY.i.hi - 4));
self->step++;
func_801C29B0(NA_SE_EV_SWITCH_CLICK);
g_ElevatorTarget = self->params;
@ -52,10 +53,10 @@ void func_801B6DE4(Entity* self) {
case 2:
if (temp_s1 == 0) {
self->posY.val += 0xFFFF0000;
y = g_Camera.posY.i.hi + self->posY.i.hi;
y = g_Tilemap.cameraY.i.hi + self->posY.i.hi;
if (y < self->ext.generic.unk80.modeS32) {
self->posY.i.hi = (u16)(self->ext.generic.unk80.modeS16.unk0) -
g_Camera.posY.i.hi;
g_Tilemap.cameraY.i.hi;
self->step = 1;
}
}
@ -104,7 +105,7 @@ void EntityElevator(Entity* self) {
if (g_ElevatorTarget != 0) {
y = g_ElevatorTargetPos[g_ElevatorTarget];
self->posY.i.hi = y - g_Camera.posY.i.hi;
self->posY.i.hi = y - g_Tilemap.cameraY.i.hi;
} else {
g_ElevatorTarget = self->params;
}
@ -158,7 +159,7 @@ void EntityElevator(Entity* self) {
if (g_ElevatorTarget != self->ext.elevator.elevatorTarget) {
y = g_ElevatorTargetPos[g_ElevatorTarget];
y -= g_Camera.posY.i.hi;
y -= g_Tilemap.cameraY.i.hi;
if (y >= self->posY.i.hi) {
self->step = ELEVATOR_DESCEND;
} else {
@ -172,7 +173,7 @@ void EntityElevator(Entity* self) {
case ELEVATOR_ASCEND:
self->posY.i.hi--;
y = g_ElevatorTargetPos[self->ext.elevator.elevatorTarget] -
g_Camera.posY.i.hi;
g_Tilemap.cameraY.i.hi;
if (self->posY.i.hi >= y) {
if (temp != 0) {
g_api.func_8010DFF0(0, 1);
@ -188,7 +189,7 @@ void EntityElevator(Entity* self) {
case ELEVATOR_DESCEND:
self->posY.i.hi++;
y = g_ElevatorTargetPos[self->ext.elevator.elevatorTarget] -
g_Camera.posY.i.hi;
g_Tilemap.cameraY.i.hi;
if (y < self->posY.i.hi) {
self->posY.i.hi = y;
self->step = ELEVATOR_IDLE;

View File

@ -11,7 +11,7 @@ void CreateEntityWhenInVerticalRange(LayoutEntity* layoutObj) {
s16 posY;
Entity* entity;
posY = g_Camera.posY.i.hi;
posY = g_Tilemap.cameraY.i.hi;
yClose = posY - 0x40;
yFar = posY + 0x120;
if (yClose < 0) {
@ -51,7 +51,7 @@ void CreateEntityWhenInHorizontalRange(LayoutEntity* layoutObj) {
s16 posX;
Entity* entity;
posX = g_Camera.posX.i.hi;
posX = g_Tilemap.cameraX.i.hi;
xClose = posX - 0x40;
xFar = posX + 0x140;
if (xClose < 0) {
@ -229,7 +229,7 @@ void func_801BB80C(s16 arg0) {
void InitRoomEntities(s32 objLayoutId) {
u16* pObjLayoutStart = D_801808EC[objLayoutId];
Unkstruct8* currentRoomTileLayout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
s16 temp_s0;
s16 arg0;
s16 i;
@ -254,7 +254,7 @@ void InitRoomEntities(s32 objLayoutId) {
D_801CAA78 += i * 2 + 2;
D_801CAA78 = (D_801CAA78[1] << 0x10) + D_801CAA78[0];
}
arg0 = currentRoomTileLayout->unkA;
arg0 = tilemap->cameraX.i.hi;
temp_s0 = arg0 + 0x140;
i = arg0 - 0x40;
if (i < 0) {
@ -265,14 +265,14 @@ void InitRoomEntities(s32 objLayoutId) {
D_801CAA80 = 0;
func_801BB3B8(i);
func_801BB45C(temp_s0);
func_801BB66C(currentRoomTileLayout->unkE + 0x120);
func_801BB66C(tilemap->cameraY.i.hi + 0x120);
}
void func_801BBA98(void) {
Unkstruct8* currentRoomTileLayout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
if (D_80097908 != 0) {
s16 tmp = g_Camera.posX.i.hi;
s16 tmp = tilemap->cameraX.i.hi;
if (D_80097908 > 0)
func_801BB45C(tmp + 320);
else
@ -280,9 +280,9 @@ void func_801BBA98(void) {
}
if (D_8009790C != 0) {
s16 tmp = currentRoomTileLayout->unkE;
s16 tmp = tilemap->cameraY.i.hi;
if (D_8009790C > 0)
func_801BB710(currentRoomTileLayout->unkE + 288);
func_801BB710(tilemap->cameraY.i.hi + 288);
else
func_801BB80C(tmp - 64);
}

View File

@ -63,7 +63,7 @@ void EntityBoneScimitar(Entity* self) {
self->palette += self->params;
self->flags &= ~(FLAG_DESTROY_IF_BARELY_OUT_OF_CAMERA |
FLAG_DESTROY_IF_OUT_OF_CAMERA | 0xC00);
self->ext.generic.unk9C = g_Camera.posX.i.hi + self->posX.i.hi;
self->ext.generic.unk9C = g_Tilemap.cameraX.i.hi + self->posX.i.hi;
if (self->params & D_8018208C) {
DestroyEntity(self);
return;
@ -200,7 +200,7 @@ void EntityBoneScimitar(Entity* self) {
switch (self->step_s) {
case BONE_SCIMITAR_WALK_RIGHT:
self->velocityX = FIX(0.5);
if (((s16)((g_Camera.posX.i.hi + self->posX.i.hi) -
if (((s16)((g_Tilemap.cameraX.i.hi + self->posX.i.hi) -
((u16)self->ext.generic.unk9C))) > 32) {
self->step_s++;
}
@ -208,7 +208,7 @@ void EntityBoneScimitar(Entity* self) {
case BONE_SCIMITAR_WALK_LEFT:
self->velocityX = FIX(-0.5);
if (((s16)((g_Camera.posX.i.hi + ((u16)self->posX.i.hi)) -
if (((s16)((g_Tilemap.cameraX.i.hi + ((u16)self->posX.i.hi)) -
((u16)self->ext.generic.unk9C))) < -32) {
self->step_s--;
}

View File

@ -11,7 +11,7 @@ void CreateEntityWhenInVerticalRange(LayoutEntity* layoutObj) {
s16 posY;
Entity* entity;
posY = g_Camera.posY.i.hi;
posY = g_Tilemap.cameraY.i.hi;
yClose = posY - 0x40;
yFar = posY + 0x120;
if (yClose < 0) {
@ -51,7 +51,7 @@ void CreateEntityWhenInHorizontalRange(LayoutEntity* layoutObj) {
s16 posX;
Entity* entity;
posX = g_Camera.posX.i.hi;
posX = g_Tilemap.cameraX.i.hi;
xClose = posX - 0x40;
xFar = posX + 0x140;
if (xClose < 0) {

View File

@ -68,10 +68,10 @@ void EntityLockCamera(Entity* entity) {
if (entity->params & 0x100) {
temp_v1_2 = &D_80180664[(((temp_s1 & 0xFFFF) * 4) & 0xFFFF)];
g_CurrentRoom.x = *temp_v1_2++;
g_CurrentRoom.y = *temp_v1_2++;
g_CurrentRoom.width = *temp_v1_2++;
g_CurrentRoom.height = *temp_v1_2++;
g_Tilemap.x = *temp_v1_2++;
g_Tilemap.y = *temp_v1_2++;
g_Tilemap.width = *temp_v1_2++;
g_Tilemap.height = *temp_v1_2++;
DestroyEntity(entity);
return;
}
@ -85,10 +85,10 @@ void EntityLockCamera(Entity* entity) {
}
temp_v1_5 = &D_80180664[(phi_v1 + temp_s1 * 8) & 0xFFFF];
g_CurrentRoom.x = *temp_v1_5++;
g_CurrentRoom.y = *temp_v1_5++;
g_CurrentRoom.width = *temp_v1_5++;
g_CurrentRoom.height = *temp_v1_5++;
g_Tilemap.x = *temp_v1_5++;
g_Tilemap.y = *temp_v1_5++;
g_Tilemap.width = *temp_v1_5++;
g_Tilemap.height = *temp_v1_5++;
}
}
#endif
@ -261,8 +261,8 @@ void func_801A8620(Entity* entity) {
s32 params = (s16)entity->params;
FntPrint("set:%04x\n", params);
FntPrint("sx:%04x\n", g_CurrentRoom.left);
FntPrint("ex:%04x\n", g_CurrentRoom.right);
FntPrint("sx:%04x\n", g_Tilemap.left);
FntPrint("ex:%04x\n", g_Tilemap.right);
switch (entity->step) {
case 0:
@ -280,83 +280,83 @@ void func_801A8620(Entity* entity) {
switch (params) {
case 0:
if (playerX > 0x280) {
g_CurrentRoom.width = 0x280;
g_CurrentRoom.right--;
g_Tilemap.width = 0x280;
g_Tilemap.right--;
entity->step++;
}
break;
case 1:
if (playerX < 0x180) {
g_CurrentRoom.x = 0x180;
g_CurrentRoom.left++;
g_Tilemap.x = 0x180;
g_Tilemap.left++;
entity->step++;
}
break;
case 3:
if (playerX < 0x100) {
g_CurrentRoom.x = 0x100;
g_CurrentRoom.left++;
g_Tilemap.x = 0x100;
g_Tilemap.left++;
entity->step++;
}
break;
case 5:
if (playerX < 0x80) {
g_CurrentRoom.x = 0x80;
g_Tilemap.x = 0x80;
entity->step++;
}
break;
case 6:
if (playerX > 0x480) {
g_CurrentRoom.width = 0x480;
g_Tilemap.width = 0x480;
entity->step++;
}
break;
case 7:
if (playerX > 0x480) {
g_CurrentRoom.width = 0x480;
g_Tilemap.width = 0x480;
entity->step++;
}
break;
case 8:
if (playerX < 0x80) {
g_CurrentRoom.x = 0x80;
g_Tilemap.x = 0x80;
entity->step++;
}
break;
case 9:
if (playerX > 0x280) {
g_CurrentRoom.width = 0x280;
g_Tilemap.width = 0x280;
entity->step++;
}
break;
case 10:
if (playerX < 0x180) {
g_CurrentRoom.x = 0x180;
g_CurrentRoom.left++;
g_Tilemap.x = 0x180;
g_Tilemap.left++;
entity->step++;
}
break;
case 11:
if (playerX > 0x280) {
g_CurrentRoom.width = 0x280;
g_CurrentRoom.right--;
g_Tilemap.width = 0x280;
g_Tilemap.right--;
entity->step++;
}
break;
case 12:
if (playerX < 0x180) {
g_CurrentRoom.x = 0x180;
g_CurrentRoom.left++;
g_Tilemap.x = 0x180;
g_Tilemap.left++;
entity->step++;
}
break;
@ -366,8 +366,8 @@ void func_801A8620(Entity* entity) {
case 13:
case 14:
if (playerX > 0x300) {
g_CurrentRoom.width = 0x300;
g_CurrentRoom.right--;
g_Tilemap.width = 0x300;
g_Tilemap.right--;
entity->step++;
}
break;

View File

@ -186,7 +186,7 @@ void func_801AA218(s16 arg0) {
}
void EntityCutscene(Entity* self) {
Unkstruct8* roomLayout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
Entity* player = &PLAYER;
u16 posX;
@ -210,7 +210,7 @@ void EntityCutscene(Entity* self) {
case 1:
if (self->step_s != 0) {
if ((player->step < 3) || (player->step == 25)) {
posX = player->posX.i.hi + roomLayout->unkA;
posX = player->posX.i.hi + tilemap->cameraX.i.hi;
if (posX > 0x8000) {
posX = 0;
}
@ -225,7 +225,7 @@ void EntityCutscene(Entity* self) {
SetStep(2);
}
} else {
if ((player->posX.i.hi + roomLayout->unkA) < 0xE1) {
if ((player->posX.i.hi + tilemap->cameraX.i.hi) < 0xE1) {
D_8003C8B8 = 0;
self->step_s++;
}
@ -233,7 +233,7 @@ void EntityCutscene(Entity* self) {
break;
case 2:
posX = player->posX.i.hi + roomLayout->unkA;
posX = player->posX.i.hi + tilemap->cameraX.i.hi;
if (posX > 0x8000) {
posX = 0;
}
@ -250,7 +250,7 @@ void EntityCutscene(Entity* self) {
break;
case 3:
posX = player->posX.i.hi + roomLayout->unkA;
posX = player->posX.i.hi + tilemap->cameraX.i.hi;
if (posX > 0x8000) {
posX = 0;
}
@ -266,7 +266,7 @@ void EntityCutscene(Entity* self) {
g_Player.D_80072EFC = 1;
if (AnimateEntity(D_80180830, self) == 0) {
self->step++;
g_CurrentRoom.width = 0x100;
g_Tilemap.width = 0x100;
}
player->animCurFrame = self->animCurFrame;
break;

View File

@ -26,16 +26,16 @@ void EntitySecretButton(Entity* self) {
self->animCurFrame = 4;
self->hitboxState = 0;
self->palette += 1;
g_CurrentRoomTileLayout.fg[0x1C4] = 0;
g_Tilemap.fg[0x1C4] = 0;
self->step = 3;
break;
}
g_CurrentRoomTileLayout.fg[0x1C4] = 0x32F;
g_Tilemap.fg[0x1C4] = 0x32F;
break;
case 1:
if (self->hitFlags != 0) {
g_CurrentRoomTileLayout.fg[0x1C4] = 0;
g_Tilemap.fg[0x1C4] = 0;
self->animCurFrame = 4;
g_api.PlaySfx(0x644);
newEntity = AllocEntity(&g_Entities[224], &g_Entities[256]);
@ -156,9 +156,9 @@ void EntitySecretStairs(Entity* self) {
self->zPriority += 1;
for (tilePos = &D_801808B0; *tilePos != 0xFFFF; tilePos += 2) {
if (!g_isSecretStairsButtonPressed) {
g_CurrentRoomTileLayout.fg[*tilePos] = 0;
g_Tilemap.fg[*tilePos] = 0;
} else {
g_CurrentRoomTileLayout.fg[*tilePos] = *(tilePos + 1);
g_Tilemap.fg[*tilePos] = *(tilePos + 1);
}
}
@ -170,8 +170,8 @@ void EntitySecretStairs(Entity* self) {
if (g_isSecretStairsButtonPressed) {
temp_s0 = D_801808A0[self->params].x;
temp_s1 = D_801808A0[self->params].y;
self->posX.i.hi = temp_s0 - g_Camera.posX.i.hi;
self->posY.i.hi = temp_s1 - g_Camera.posY.i.hi;
self->posX.i.hi = temp_s0 - g_Tilemap.cameraX.i.hi;
self->posY.i.hi = temp_s1 - g_Tilemap.cameraY.i.hi;
self->step = 15;
break;
}
@ -214,8 +214,8 @@ void EntitySecretStairs(Entity* self) {
switch (self->step_s) {
case 0:
posX = g_Camera.posX.i.hi + self->posX.i.hi;
posY = g_Camera.posY.i.hi + self->posY.i.hi;
posX = g_Tilemap.cameraX.i.hi + self->posX.i.hi;
posY = g_Tilemap.cameraY.i.hi + self->posY.i.hi;
angle = ratan2(temp_s1 - posY, temp_s0 - posX);
self->velocityX = rcos(angle) * 12;
self->velocityY = rsin(angle) * 12;
@ -224,17 +224,17 @@ void EntitySecretStairs(Entity* self) {
case 1:
MoveEntity();
posX = g_Camera.posX.i.hi + self->posX.i.hi;
posX = g_Tilemap.cameraX.i.hi + self->posX.i.hi;
if (temp_s0 == posX) {
g_api.PlaySfx(0x64F);
self->posX.i.hi = temp_s0 - g_Camera.posX.i.hi;
self->posY.i.hi = temp_s1 - g_Camera.posY.i.hi;
self->posX.i.hi = temp_s0 - g_Tilemap.cameraX.i.hi;
self->posY.i.hi = temp_s1 - g_Tilemap.cameraY.i.hi;
if (self->params != 3) {
self[1].ext.stub[0x8] = 1;
} else {
tilePos = &D_801808B0;
while (*tilePos != 0xFFFF) {
g_CurrentRoomTileLayout.fg[*tilePos] = *(tilePos + 1);
g_Tilemap.fg[*tilePos] = *(tilePos + 1);
tilePos += 2;
}
}

View File

@ -11,7 +11,7 @@ void CreateEntityWhenInVerticalRange(LayoutEntity* layoutObj) {
s16 posY;
Entity* entity;
posY = g_Camera.posY.i.hi;
posY = g_Tilemap.cameraY.i.hi;
yClose = posY - 0x40;
yFar = posY + 0x120;
if (yClose < 0) {
@ -51,7 +51,7 @@ void CreateEntityWhenInHorizontalRange(LayoutEntity* layoutObj) {
s16 posX;
Entity* entity;
posX = g_Camera.posX.i.hi;
posX = g_Tilemap.cameraX.i.hi;
xClose = posX - 0x40;
xFar = posX + 0x140;
if (xClose < 0) {
@ -230,7 +230,7 @@ void func_801B3828(s16 arg0) {
void InitRoomEntities(s32 objLayoutId) {
u16* pObjLayoutStart = D_80180314[objLayoutId];
Unkstruct8* currentRoomTileLayout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
s16 temp_s0;
s16 arg0;
s16 i;
@ -255,7 +255,7 @@ void InitRoomEntities(s32 objLayoutId) {
D_801C00A4 += i * 2 + 2;
D_801C00A4 = (D_801C00A4[1] << 0x10) + D_801C00A4[0];
}
arg0 = currentRoomTileLayout->unkA;
arg0 = tilemap->cameraX.i.hi;
temp_s0 = arg0 + 0x140;
i = arg0 - 0x40;
if (i < 0) {
@ -266,14 +266,14 @@ void InitRoomEntities(s32 objLayoutId) {
D_801C00AC = 0;
func_801B33D4(i);
func_801B3478(temp_s0);
func_801B3688(currentRoomTileLayout->unkE + 0x120);
func_801B3688(tilemap->cameraY.i.hi + 0x120);
}
void func_801B3AB4(void) {
Unkstruct8* currentRoomTileLayout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
if (D_80097908 != 0) {
s16 tmp = g_Camera.posX.i.hi;
s16 tmp = tilemap->cameraX.i.hi;
if (D_80097908 > 0)
func_801B3478(tmp + 320);
else
@ -281,9 +281,9 @@ void func_801B3AB4(void) {
}
if (D_8009790C != 0) {
s16 tmp = currentRoomTileLayout->unkE;
s16 tmp = tilemap->cameraY.i.hi;
if (D_8009790C > 0)
func_801B372C(currentRoomTileLayout->unkE + 288);
func_801B372C(tilemap->cameraY.i.hi + 288);
else
func_801B3828(tmp - 64);
}

View File

@ -42,8 +42,8 @@ void Update(void) {
}
if ((unk34 & 0x02000000)) {
s16 posY = entity->posY.i.hi + g_Camera.posY.i.hi;
s16 test = (LOHU(g_CurrentRoom.vSize) * 256) + 128;
s16 posY = entity->posY.i.hi + g_Tilemap.cameraY.i.hi;
s16 test = (LOHU(g_Tilemap.vSize) * 256) + 128;
if (posY > test) {
DestroyEntity(entity);
continue;

View File

@ -1109,15 +1109,15 @@ void func_801870B0(Entity* entity) {
switch (temp_s1) {
case 4:
case 5:
if (g_CurrentRoom.x != 0) {
if (g_Tilemap.x != 0) {
return;
}
break;
case 6:
if (g_pads->pressed & PAD_TRIANGLE) {
g_CurrentRoom.x = 0;
g_CurrentRoom.width = 1280;
g_Tilemap.x = 0;
g_Tilemap.width = 1280;
entity->step++;
return;
}
@ -1135,10 +1135,10 @@ void func_801870B0(Entity* entity) {
unk = 8;
temp_s1 = (temp_s1 * unk) + phi_v1;
temp_v0_2 = &D_80180538[temp_s1];
g_CurrentRoom.x = *(temp_v0_2++);
g_CurrentRoom.y = *(temp_v0_2++);
g_CurrentRoom.width = *(temp_v0_2++);
g_CurrentRoom.height = *(temp_v0_2++);
g_Tilemap.x = *(temp_v0_2++);
g_Tilemap.y = *(temp_v0_2++);
g_Tilemap.width = *(temp_v0_2++);
g_Tilemap.height = *(temp_v0_2++);
}
} else {
InitializeEntity(D_80180488);
@ -1267,7 +1267,7 @@ void EntityWarpRoom(Entity* self) {
newEntity = AllocEntity(&g_Entities[0xA0], &g_Entities[0x100]);
if (newEntity != NULL) {
CreateEntityFromCurrentEntity(0x17, newEntity);
newEntity->posY.i.hi = 0xCC - g_Camera.posY.i.hi;
newEntity->posY.i.hi = 0xCC - g_Tilemap.cameraY.i.hi;
newEntity->posX.i.hi = (Random() & 0x7F) + 0x40;
}
}
@ -1279,7 +1279,7 @@ void EntityWarpRoom(Entity* self) {
D_80180648 = 0;
*D_8003BEBC |= 1;
*D_8003BEBC |= 1 << self->params;
moveX = g_Camera.posX.i.hi + (&PLAYER)->posX.i.hi;
moveX = g_Tilemap.cameraX.i.hi + (&PLAYER)->posX.i.hi;
if (moveX > 0x60 && moveX < 0xA0) {
g_Player.D_80072EFC = 0x10;
g_Player.D_80072EF4 = 0;
@ -1357,8 +1357,8 @@ void EntityWarpRoom(Entity* self) {
}
warpCoords = &D_8018065C[move_room];
moveX = warpCoords->x - g_CurrentRoom.left;
moveY = warpCoords->y - g_CurrentRoom.top;
moveX = warpCoords->x - g_Tilemap.left;
moveY = warpCoords->y - g_Tilemap.top;
D_80193AA0 = move_room;
FntPrint(D_80186E3C, move_room);
FntPrint(D_80186E4C, warpCoords->x, warpCoords->y);
@ -1413,8 +1413,8 @@ void EntityWarpRoom(Entity* self) {
default:
warpCoords = &D_8018065C[D_80193AA0];
moveX = warpCoords->x - g_CurrentRoom.left;
moveY = warpCoords->y - g_CurrentRoom.top;
moveX = warpCoords->x - g_Tilemap.left;
moveY = warpCoords->y - g_Tilemap.top;
FntPrint(D_80186E3C, D_80193AA0);
FntPrint(D_80186E4C, warpCoords->x, warpCoords->y);
FntPrint(D_80186E5C, moveX, moveY);
@ -1533,7 +1533,7 @@ void EntityWarpSmallRocks(Entity* entity) {
break;
case 5:
y_unk = &g_Camera.posY.i.hi;
y_unk = &g_Tilemap.cameraY.i.hi;
*(u32*)&entity->ext.generic.unk88 =
*(u32*)&entity->ext.generic.unk88 - 1;
if (*(u32*)&entity->ext.generic.unk88 == 0) {

View File

@ -30,7 +30,7 @@ void CreateEntityWhenInVerticalRange(LayoutEntity* layoutObj) {
s16 posY;
Entity* entity;
posY = g_Camera.posY.i.hi;
posY = g_Tilemap.cameraY.i.hi;
yClose = posY - 0x40;
yFar = posY + 0x120;
if (yClose < 0) {
@ -70,7 +70,7 @@ void CreateEntityWhenInHorizontalRange(LayoutEntity* layoutObj) {
s16 posX;
Entity* entity;
posX = g_Camera.posX.i.hi;
posX = g_Tilemap.cameraX.i.hi;
xClose = posX - 0x40;
xFar = posX + 0x140;
if (xClose < 0) {
@ -252,7 +252,7 @@ void func_8018A520(s16 arg0) {
void InitRoomEntities(s32 objLayoutId) {
u16* pObjLayoutStart = g_pStObjLayout[objLayoutId];
Unkstruct8* currentRoomTileLayout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
s16 temp_s0;
s16 arg0;
s16 i;
@ -277,7 +277,7 @@ void InitRoomEntities(s32 objLayoutId) {
D_80193AB4 += i * 2 + 2;
D_80193AB4 = (D_80193AB4[1] << 0x10) + D_80193AB4[0];
}
arg0 = currentRoomTileLayout->unkA;
arg0 = tilemap->cameraX.i.hi;
temp_s0 = arg0 + 0x140;
i = arg0 - 0x40;
if (i < 0) {
@ -288,14 +288,14 @@ void InitRoomEntities(s32 objLayoutId) {
D_80193ABC = 0;
func_8018A0CC(i);
func_8018A170(temp_s0);
func_8018A380(currentRoomTileLayout->unkE + 0x120);
func_8018A380(tilemap->cameraY.i.hi + 0x120);
}
void func_8018A7AC(void) {
Unkstruct8* currentRoomTileLayout = &g_CurrentRoomTileLayout;
Tilemap* tilemap = &g_Tilemap;
if (D_80097908 != 0) {
s16 tmp = g_Camera.posX.i.hi;
s16 tmp = tilemap->cameraX.i.hi;
if (D_80097908 > 0)
func_8018A170(tmp + 0x140);
else
@ -303,9 +303,9 @@ void func_8018A7AC(void) {
}
if (D_8009790C != 0) {
s16 tmp = currentRoomTileLayout->unkE;
s16 tmp = tilemap->cameraY.i.hi;
if (D_8009790C > 0)
func_8018A424(currentRoomTileLayout->unkE + 0x120);
func_8018A424(tilemap->cameraY.i.hi + 0x120);
else
func_8018A520(tmp - 0x40);
}

@ -1 +1 @@
Subproject commit 526eb8e029a8bd4039e9edc3d1f6ada6c479b512
Subproject commit ae43f009e319d55362423e2bc1fb96bc7d55aa47

View File

@ -154,15 +154,15 @@ u8 GetColType(s32 x, s32 y) {
absX = x + *cameraX;
absY = y + *cameraY;
new_var = 0x10;
if (absX < 0 || (u32)absX >= g_CurrentRoom.hSize << 8 || absY < 0 ||
(u32)absY >= g_CurrentRoom.vSize << 8) {
if (absX < 0 || (u32)absX >= g_Tilemap.hSize << 8 || absY < 0 ||
(u32)absY >= g_Tilemap.vSize << 8) {
colType = 0;
} else {
// 16x16 blocks
u16 colTile = g_CurrentRoomTileLayout
.fg[(absX >> 4) +
(((absY >> 4) * g_CurrentRoom.hSize) * new_var)];
u16 colTile =
g_Tilemap
.fg[(absX >> 4) + (((absY >> 4) * g_Tilemap.hSize) * new_var)];
TileDefinition* temp = (TileDefinition*)0x80073088;
colType = temp->collision[colTile];
}