summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
Diffstat (limited to 'src/code')
-rw-r--r--src/code/code_n64dd_800AD4C0.c1
-rw-r--r--src/code/game.c35
-rw-r--r--src/code/z_play.c88
-rw-r--r--src/code/z_room.c27
4 files changed, 139 insertions, 12 deletions
diff --git a/src/code/code_n64dd_800AD4C0.c b/src/code/code_n64dd_800AD4C0.c
index 315b6fdd1..ed1477f93 100644
--- a/src/code/code_n64dd_800AD4C0.c
+++ b/src/code/code_n64dd_800AD4C0.c
@@ -3,7 +3,6 @@
#include "n64dd.h"
// TODO functions of unknown prototype
-extern char func_801C8510_unknown[];
extern char osGetIntMask[];
extern char osSetTime[];
diff --git a/src/code/game.c b/src/code/game.c
index 3fe16c818..ffb8bc847 100644
--- a/src/code/game.c
+++ b/src/code/game.c
@@ -1,8 +1,9 @@
#include "global.h"
-#if OOT_DEBUG
#include "fault.h"
-#endif
#include "terminal.h"
+#if PLATFORM_N64
+#include "n64dd.h"
+#endif
#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128"
@@ -70,7 +71,11 @@ void GameState_SetFBFilter(Gfx** gfxP) {
}
void func_800C4344(GameState* gameState) {
-#if OOT_DEBUG
+#if PLATFORM_N64
+ if (B_80121AE2 != 0) {
+ func_801C86F0_unknown();
+ }
+#elif OOT_DEBUG
Input* selectedInput;
s32 hexDumpSize;
u16 inputCompareValue;
@@ -238,6 +243,12 @@ void func_800C49F4(GraphicsContext* gfxCtx) {
newDlist = Gfx_Open(polyOpaP = POLY_OPA_DISP);
gSPDisplayList(OVERLAY_DISP++, newDlist);
+#if PLATFORM_N64
+ if (B_80121AE2 != 0) {
+ func_801C7760_unknown(&newDlist);
+ }
+#endif
+
gSPEndDisplayList(newDlist++);
Gfx_Close(polyOpaP, newDlist);
POLY_OPA_DISP = newDlist;
@@ -258,6 +269,15 @@ void GameState_Update(GameState* gameState) {
gameState->main(gameState);
+#if PLATFORM_N64
+ if (B_80121AE2 != 0) {
+ func_801C86F0_unknown();
+ }
+ if ((B_80121AF0 != NULL) && (B_80121AF0->unk_74 != NULL)) {
+ B_80121AF0->unk_74(gameState);
+ }
+#endif
+
func_800C4344(gameState);
#if OOT_DEBUG
@@ -356,7 +376,11 @@ void GameState_InitArena(GameState* gameState, size_t size) {
} else {
THA_Init(&gameState->tha, NULL, 0);
PRINTF(T("ハイラル確保失敗\n", "Failure to secure Hyrule\n"));
+#if PLATFORM_N64
+ HUNGUP_AND_CRASH("../game.c", 985);
+#else
HUNGUP_AND_CRASH("../game.c", 999);
+#endif
}
}
@@ -396,7 +420,12 @@ void GameState_Realloc(GameState* gameState, size_t size) {
#if OOT_DEBUG
SystemArena_Display();
#endif
+
+#if PLATFORM_N64
+ HUNGUP_AND_CRASH("../game.c", 1030);
+#else
HUNGUP_AND_CRASH("../game.c", 1044);
+#endif
}
}
diff --git a/src/code/z_play.c b/src/code/z_play.c
index 0c106f610..084ef4ddc 100644
--- a/src/code/z_play.c
+++ b/src/code/z_play.c
@@ -1,11 +1,12 @@
#include "global.h"
-#if OOT_DEBUG
#include "fault.h"
-#endif
#include "quake.h"
#include "terminal.h"
#include "versions.h"
+#if PLATFORM_N64
+#include "n64dd.h"
+#endif
#include "z64frame_advance.h"
@@ -175,7 +176,9 @@ void Play_SetupTransition(PlayState* this, s32 transitionType) {
break;
default:
-#if OOT_VERSION < GC_EU_MQ_DBG
+#if PLATFORM_N64
+ HUNGUP_AND_CRASH("../z_play.c", 2269);
+#elif OOT_VERSION < GC_EU_MQ_DBG
HUNGUP_AND_CRASH("../z_play.c", 2287);
#elif OOT_VERSION < GC_JP_CE
HUNGUP_AND_CRASH("../z_play.c", 2290);
@@ -239,6 +242,12 @@ void Play_Destroy(GameState* thisx) {
KaleidoManager_Destroy();
ZeldaArena_Cleanup();
+#if PLATFORM_N64
+ if ((B_80121AF0 != NULL) && (B_80121AF0->unk_14 != NULL)) {
+ B_80121AF0->unk_14(this);
+ }
+#endif
+
#if OOT_DEBUG
Fault_RemoveClient(&D_801614B8);
#endif
@@ -268,6 +277,13 @@ void Play_Init(GameState* thisx) {
#endif
GameState_Realloc(&this->state, 0x1D4790);
+
+#if PLATFORM_N64
+ if ((B_80121AF0 != NULL) && (B_80121AF0->unk_10 != NULL)) {
+ B_80121AF0->unk_10(this);
+ }
+#endif
+
KaleidoManager_Init(this);
View_Init(&this->view, gfxCtx);
Audio_SetExtraFilter(0);
@@ -360,6 +376,7 @@ void Play_Init(GameState* thisx) {
PRINTF("\nSCENE_NO=%d COUNTER=%d\n", ((void)0, gSaveContext.save.entranceIndex), gSaveContext.sceneLayer);
+#if PLATFORM_GC
// When entering Gerudo Valley in the credits, trigger the GC emulator to play the ending movie.
// The emulator constantly checks whether PC is 0x81000000, so this works even though it's not a valid address.
if ((gEntranceTable[((void)0, gSaveContext.save.entranceIndex)].sceneId == SCENE_GERUDO_VALLEY) &&
@@ -368,8 +385,17 @@ void Play_Init(GameState* thisx) {
((void (*)(void))0x81000000)();
PRINTF(T("出戻り?\n", "Return?\n"));
}
+#endif
+#if PLATFORM_N64
+ if ((B_80121AF0 != NULL && B_80121AF0->unk_54 != NULL && B_80121AF0->unk_54(this))) {
+ } else {
+ Cutscene_HandleEntranceTriggers(this);
+ }
+#else
Cutscene_HandleEntranceTriggers(this);
+#endif
+
KaleidoScopeCall_Init(this);
Interface_Init(this);
@@ -1058,6 +1084,10 @@ skip:
}
void Play_DrawOverlayElements(PlayState* this) {
+#if PLATFORM_N64
+ s32 pad;
+#endif
+
if (IS_PAUSED(&this->pauseCtx)) {
KaleidoScopeCall_Draw(this);
}
@@ -1147,7 +1177,12 @@ void Play_Draw(PlayState* this) {
TransitionFade_Draw(&this->transitionFadeFlash, &gfxP);
- if (gVisMonoColor.a > 0) {
+#if PLATFORM_N64
+ if (gVisMonoColor.a != 0)
+#else
+ if (gVisMonoColor.a > 0)
+#endif
+ {
gPlayVisMono.vis.primColor.rgba = gVisMonoColor.rgba;
VisMono_Draw(&gPlayVisMono, &gfxP);
}
@@ -1457,6 +1492,19 @@ void* Play_LoadFile(PlayState* this, RomFile* file) {
return allocp;
}
+#if PLATFORM_N64
+void* Play_LoadFileFromDiskDrive(PlayState* this, RomFile* file) {
+ u32 size;
+ void* allocp;
+
+ size = file->vromEnd - file->vromStart;
+ allocp = THA_AllocTailAlign16(&this->state.tha, size);
+ func_801C8510_unknown(allocp, file->vromStart, size);
+
+ return allocp;
+}
+#endif
+
void Play_InitEnvironment(PlayState* this, s16 skyboxId) {
Skybox_Init(&this->state, &this->skyboxCtx, skyboxId);
Environment_Init(this, &this->envCtx, 0);
@@ -1485,24 +1533,52 @@ void Play_InitScene(PlayState* this, s32 spawn) {
}
void Play_SpawnScene(PlayState* this, s32 sceneId, s32 spawn) {
- SceneTableEntry* scene = &gSceneTable[sceneId];
+ SceneTableEntry* scene;
u32 size;
+#if PLATFORM_N64
+ if ((B_80121AF0 != NULL) && (B_80121AF0->unk_48 != NULL)) {
+ scene = B_80121AF0->unk_48(sceneId, gSceneTable);
+ } else {
+ scene = &gSceneTable[sceneId];
+ scene->unk_13 = 0;
+ }
+#else
+ scene = &gSceneTable[sceneId];
scene->unk_13 = 0;
+#endif
+
this->loadedScene = scene;
this->sceneId = sceneId;
this->sceneDrawConfig = scene->drawConfig;
PRINTF("\nSCENE SIZE %fK\n", (scene->sceneFile.vromEnd - scene->sceneFile.vromStart) / 1024.0f);
+#if PLATFORM_N64
+ if ((B_80121AF0 != NULL) && (scene->unk_12 > 0)) {
+ this->sceneSegment = Play_LoadFileFromDiskDrive(this, &scene->sceneFile);
+ scene->unk_13 = 1;
+ } else {
+ this->sceneSegment = Play_LoadFile(this, &scene->sceneFile);
+ scene->unk_13 = 0;
+ }
+#else
this->sceneSegment = Play_LoadFile(this, &scene->sceneFile);
scene->unk_13 = 0;
+#endif
+
ASSERT(this->sceneSegment != NULL, "this->sceneSegment != NULL", "../z_play.c", 4960);
gSegments[2] = VIRTUAL_TO_PHYSICAL(this->sceneSegment);
Play_InitScene(this, spawn);
+#if PLATFORM_N64
+ if ((B_80121AF0 != NULL) && (B_80121AF0->unk_0C != NULL)) {
+ B_80121AF0->unk_0C(this);
+ }
+#endif
+
size = func_80096FE8(this, &this->roomCtx);
PRINTF("ROOM SIZE=%fK\n", size / 1024.0f);
@@ -1798,11 +1874,13 @@ void Play_LoadToLastEntrance(PlayState* this) {
(this->sceneId == SCENE_INSIDE_GANONS_CASTLE_COLLAPSE) || (this->sceneId == SCENE_GANON_BOSS)) {
this->nextEntranceIndex = ENTR_GANONS_TOWER_COLLAPSE_EXTERIOR_0;
Item_Give(this, ITEM_SWORD_MASTER);
+#if OOT_VERSION >= PAL_1_1
} else if ((gSaveContext.save.entranceIndex == ENTR_HYRULE_FIELD_11) ||
(gSaveContext.save.entranceIndex == ENTR_HYRULE_FIELD_12) ||
(gSaveContext.save.entranceIndex == ENTR_HYRULE_FIELD_13) ||
(gSaveContext.save.entranceIndex == ENTR_HYRULE_FIELD_15)) {
this->nextEntranceIndex = ENTR_HYRULE_FIELD_6;
+#endif
} else {
this->nextEntranceIndex = gSaveContext.save.entranceIndex;
}
diff --git a/src/code/z_room.c b/src/code/z_room.c
index a660d41a3..2b727deea 100644
--- a/src/code/z_room.c
+++ b/src/code/z_room.c
@@ -1,5 +1,9 @@
#include "global.h"
+#include "fault.h"
#include "terminal.h"
+#if PLATFORM_N64
+#include "n64dd.h"
+#endif
Vec3f D_801270A0 = { 0.0f, 0.0f, 0.0f };
@@ -295,6 +299,7 @@ void Room_DrawBackground2D(Gfx** gfxP, void* tex, void* tlut, u16 width, u16 hei
bg = (uObjBg*)(gfx + 1);
gSPBranchList(gfx, (Gfx*)(bg + 1));
+ gfx = (Gfx*)(bg + 1);
bg->b.imageX = 0;
bg->b.imageW = width * (1 << 2);
@@ -309,8 +314,6 @@ void Room_DrawBackground2D(Gfx** gfxP, void* tex, void* tlut, u16 width, u16 hei
bg->b.imagePal = 0;
bg->b.imageFlip = 0;
- gfx = (Gfx*)(bg + 1);
-
if (fmt == G_IM_FMT_CI) {
gDPLoadTLUT(gfx++, tlutCount, 256, tlut);
} else {
@@ -441,7 +444,11 @@ RoomShapeImageMultiBgEntry* Room_GetImageMultiBgEntry(RoomShapeImageMulti* roomS
PRINTF(VT_COL(RED, WHITE) T("z_room.c:カメラIDに一致するデータが存在しません camid=%d\n",
"z_room.c: Data consistent with camera id does not exist camid=%d\n") VT_RST,
bgCamIndex);
+#if PLATFORM_N64
+ Fault_AddHungupAndCrash("../z_room.c", 721);
+#else
LogUtils_HungupThread("../z_room.c", 726);
+#endif
return NULL;
}
@@ -521,7 +528,11 @@ void Room_DrawImage(PlayState* play, Room* room, u32 flags) {
} else if (roomShape->amountType == ROOM_SHAPE_IMAGE_AMOUNT_MULTI) {
Room_DrawImageMulti(play, room, flags);
} else {
+#if PLATFORM_N64
+ Fault_AddHungupAndCrash("../z_room.c", 836);
+#else
LogUtils_HungupThread("../z_room.c", 841);
+#endif
}
}
@@ -610,10 +621,20 @@ s32 func_8009728C(PlayState* play, RoomContext* roomCtx, s32 roomNum) {
(void*)ALIGN16((uintptr_t)roomCtx->bufPtrs[roomCtx->unk_30] - ((size + 8) * roomCtx->unk_30 + 7));
osCreateMesgQueue(&roomCtx->loadQueue, &roomCtx->loadMsg, 1);
+
+#if PLATFORM_N64
+ if ((B_80121AF0 != NULL) && (B_80121AF0->unk_08 != NULL)) {
+ B_80121AF0->unk_08(play, roomCtx, roomNum);
+ } else {
+ DMA_REQUEST_ASYNC(&roomCtx->dmaRequest, roomCtx->unk_34, play->roomList[roomNum].vromStart, size, 0,
+ &roomCtx->loadQueue, NULL, "../z_room.c", 1036);
+ }
+#else
DMA_REQUEST_ASYNC(&roomCtx->dmaRequest, roomCtx->unk_34, play->roomList[roomNum].vromStart, size, 0,
&roomCtx->loadQueue, NULL, "../z_room.c", 1036);
- roomCtx->unk_30 ^= 1;
+#endif
+ roomCtx->unk_30 ^= 1;
return true;
}