This commit is contained in:
louist103 2022-05-01 11:39:58 -04:00
commit 75ccabe198
2 changed files with 17 additions and 9 deletions

View file

@ -7,6 +7,7 @@
#include "spdlog/spdlog.h" #include "spdlog/spdlog.h"
#include <soh/OTRGlobals.h> #include <soh/OTRGlobals.h>
#include <soh/OTRAudio.h>
#include "z64.h" #include "z64.h"
#include "z64save.h" #include "z64save.h"
@ -14,7 +15,6 @@
#include <functions.h> #include <functions.h>
#include "z64map_mark.h" #include "z64map_mark.h"
extern "C" GlobalContext* gGlobalCtx; extern "C" GlobalContext* gGlobalCtx;
// FROM z_lights.c // FROM z_lights.c
@ -155,8 +155,6 @@ unsigned int SaveStateMgr::GetCurrentSlot(void) {
} }
void SaveStateMgr::ProcessSaveStateRequests(void) { void SaveStateMgr::ProcessSaveStateRequests(void) {
std::unique_lock<std::mutex> Lock(this->mutex);
while (!this->requests.empty()) { while (!this->requests.empty()) {
const auto& request = this->requests.front(); const auto& request = this->requests.front();
@ -187,8 +185,6 @@ SaveStateReturn SaveStateMgr::AddRequest(const SaveStateRequest request) {
return SaveStateReturn::FAIL_WRONG_GAMESTATE; return SaveStateReturn::FAIL_WRONG_GAMESTATE;
} }
std::unique_lock<std::mutex> Lock(this->mutex);
switch (request.type) { switch (request.type) {
case RequestType::SAVE: case RequestType::SAVE:
requests.push(request); requests.push(request);
@ -210,6 +206,7 @@ SaveStateReturn SaveStateMgr::AddRequest(const SaveStateRequest request) {
} }
void SaveState::Save(void) { void SaveState::Save(void) {
std::unique_lock<std::mutex> Lock(audio.mutex);
memcpy(&info->sysHeapCopy, gSystemHeap, SYSTEM_HEAP_SIZE /* sizeof(gSystemHeap) */); memcpy(&info->sysHeapCopy, gSystemHeap, SYSTEM_HEAP_SIZE /* sizeof(gSystemHeap) */);
memcpy(&info->audioHeapCopy, gAudioHeap, AUDIO_HEAP_SIZE /* sizeof(gAudioContext) */); memcpy(&info->audioHeapCopy, gAudioHeap, AUDIO_HEAP_SIZE /* sizeof(gAudioContext) */);
@ -237,12 +234,15 @@ void SaveState::Save(void) {
memcpy(&info->lightBufferCopy, &sLightsBuffer, sizeof(sLightsBuffer)); memcpy(&info->lightBufferCopy, &sLightsBuffer, sizeof(sLightsBuffer));
memcpy(&info->mtxStackCopy, &sMatrixStack, sizeof(MtxF) * 20); memcpy(&info->mtxStackCopy, &sMatrixStack, sizeof(MtxF) * 20);
memcpy(&info->currentMtxCopy, &sCurrentMatrix, sizeof(MtxF)); memcpy(&info->currentMtxCopy, &sCurrentMatrix, sizeof(MtxF));
//Various static data
info->blueWarpTimerCopy = sWarpTimerTarget; info->blueWarpTimerCopy = sWarpTimerTarget;
info->sLoadedMarkDataTableCopy = sLoadedMarkDataTable; info->sLoadedMarkDataTableCopy = sLoadedMarkDataTable;
} }
void SaveState::Load(void) { void SaveState::Load(void) {
std::unique_lock<std::mutex> Lock(audio.mutex);
memcpy(gSystemHeap, &info->sysHeapCopy, SYSTEM_HEAP_SIZE); memcpy(gSystemHeap, &info->sysHeapCopy, SYSTEM_HEAP_SIZE);
memcpy(gAudioHeap, &info->audioHeapCopy, AUDIO_HEAP_SIZE); memcpy(gAudioHeap, &info->audioHeapCopy, AUDIO_HEAP_SIZE);
@ -270,7 +270,7 @@ void SaveState::Load(void) {
memcpy(gAudioSfxSwapMode, &info->gAudioSfxSwapMode_copy, memcpy(gAudioSfxSwapMode, &info->gAudioSfxSwapMode_copy,
sizeof(info->gAudioSfxSwapMode_copy)); sizeof(info->gAudioSfxSwapMode_copy));
//Various static data
D_801755D0 = info->D_801755D0_copy; D_801755D0 = info->D_801755D0_copy;
sLoadedMarkDataTable = info->sLoadedMarkDataTableCopy; sLoadedMarkDataTable = info->sLoadedMarkDataTableCopy;
} }

View file

@ -4804,7 +4804,7 @@ s32 func_8083ADD4(GlobalContext* globalCtx, Player* this) {
void func_8083AE40(Player* this, s16 objectId) { void func_8083AE40(Player* this, s16 objectId) {
s32 pad; s32 pad;
u32 size; size_t size;
if (objectId != OBJECT_INVALID) { if (objectId != OBJECT_INVALID) {
this->giObjectLoading = true; this->giObjectLoading = true;
@ -4815,7 +4815,7 @@ void func_8083AE40(Player* this, s16 objectId) {
LOG_HEX("size", size, "../z_player.c", 9090); LOG_HEX("size", size, "../z_player.c", 9090);
ASSERT(size <= 1024 * 8, "size <= 1024 * 8", "../z_player.c", 9091); ASSERT(size <= 1024 * 8, "size <= 1024 * 8", "../z_player.c", 9091);
DmaMgr_SendRequest2(&this->giObjectDmaRequest, (u32)this->giObjectSegment, gObjectTable[objectId].vromStart, DmaMgr_SendRequest2(&this->giObjectDmaRequest, (uint32_t)this->giObjectSegment, gObjectTable[objectId].vromStart,
size, 0, &this->giObjectLoadQueue, NULL, "../z_player.c", 9099); size, 0, &this->giObjectLoadQueue, NULL, "../z_player.c", 9099);
} }
} }
@ -10758,6 +10758,14 @@ void Player_Update(Actor* thisx, GlobalContext* globalCtx) {
Input sp44; Input sp44;
Actor* dog; Actor* dog;
int bp = 0;
if (bp) {
func_8083A098(this, gPlayerAnim_003458, globalCtx);
// bp = 0;
return;
}
if (func_8084FCAC(this, globalCtx)) { if (func_8084FCAC(this, globalCtx)) {
if (gSaveContext.dogParams < 0) { if (gSaveContext.dogParams < 0) {
if (Object_GetIndex(&globalCtx->objectCtx, OBJECT_DOG) < 0) { if (Object_GetIndex(&globalCtx->objectCtx, OBJECT_DOG) < 0) {