mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-22 14:23:44 -07:00
Its working but more work is needed.
This commit is contained in:
parent
4aeed97e3a
commit
ed929a2942
13 changed files with 208 additions and 17 deletions
|
@ -29,26 +29,26 @@
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#ifndef CONFIG_FILE_H
|
||||
#define CONFIG_FILE_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
@ -35,3 +38,5 @@ namespace Ship {
|
|||
mINI::INIFile File;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#ifndef GAME_VERSION_H
|
||||
#define GAME_VERSION_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#define OOT_NTSC_10 0xEC7011B7
|
||||
|
@ -17,4 +20,6 @@
|
|||
#define OOT_PAL_GC_MQ_DBG 0x917D18F6
|
||||
#define OOT_IQUE_TW 0x3D81FB3E
|
||||
#define OOT_IQUE_CN 0xB1E1E07B
|
||||
#define OOT_UNKNOWN 0xFFFFFFFF
|
||||
#define OOT_UNKNOWN 0xFFFFFFFF
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#ifndef GLOBAL_CTX_2
|
||||
#define GLOBAL_CTX_2
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -38,4 +41,6 @@ namespace Ship {
|
|||
std::string PatchesPath;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -38,19 +38,19 @@
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Testing|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -2405,6 +2405,7 @@ void Heaps_Free(void);
|
|||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#undef this
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
#ifndef STDDEF_H
|
||||
#define STDDEF_H
|
||||
|
||||
#ifndef __cplusplus
|
||||
#define NULL ((void*)0)
|
||||
#else
|
||||
#define NULL nullptr
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#define size_t unsigned long
|
||||
#define ssize_t long
|
||||
|
|
|
@ -29,14 +29,14 @@
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<EnableASAN>false</EnableASAN>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<EnableASAN>false</EnableASAN>
|
||||
|
@ -44,13 +44,13 @@
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
|
@ -180,6 +180,7 @@
|
|||
<ClCompile Include="soh\Enhancements\debugger\debugSaveEditor.cpp" />
|
||||
<ClCompile Include="soh\Enhancements\debugger\ImGuiHelpers.cpp" />
|
||||
<ClCompile Include="soh\Enhancements\gameconsole.c" />
|
||||
<ClCompile Include="soh\Enhancements\savestates.cpp" />
|
||||
<ClCompile Include="soh\GbiWrap.cpp" />
|
||||
<ClCompile Include="soh\gu_pc.c" />
|
||||
<ClCompile Include="soh\OTRGlobals.cpp" />
|
||||
|
@ -926,6 +927,7 @@
|
|||
<ClInclude Include="soh\Enhancements\cvar.h" />
|
||||
<ClInclude Include="soh\Enhancements\debugconsole.h" />
|
||||
<ClInclude Include="soh\Enhancements\debugger\colViewer.h" />
|
||||
<ClInclude Include="soh\Enhancements\savestates.h" />
|
||||
<ClInclude Include="soh\Enhancements\debugger\debugger.h" />
|
||||
<ClInclude Include="soh\Enhancements\debugger\debugSaveEditor.h" />
|
||||
<ClInclude Include="soh\Enhancements\debugger\ImGuiHelpers.h" />
|
||||
|
|
|
@ -2190,6 +2190,9 @@
|
|||
<ClCompile Include="soh\Enhancements\debugger\ImGuiHelpers.cpp">
|
||||
<Filter>Source Files\soh\Enhancements\debugger</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="soh\Enhancements\savestates.cpp">
|
||||
<Filter>Source Files\soh\Enhancements</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="src\overlays\actors\ovl_kaleido_scope\z_kaleido_scope.h">
|
||||
|
@ -3740,6 +3743,9 @@
|
|||
<ClInclude Include="soh\util.h">
|
||||
<Filter>Header Files\soh</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="soh\Enhancements\savestates.h">
|
||||
<Filter>Header Files\soh\Enhancements</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="soh\Enhancements\debugger\colViewer.h">
|
||||
<Filter>Header Files\soh\Enhancements\debugger</Filter>
|
||||
</ClInclude>
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
#include "debugconsole.h"
|
||||
#include "../libultraship/SohImGuiImpl.h"
|
||||
#include "savestates.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
|
||||
#define Path _Path
|
||||
#define PATH_HACK
|
||||
#include <Utils/StringHelper.h>
|
||||
|
@ -303,6 +306,17 @@ static bool EntranceHandler(const std::vector<std::string>& args) {
|
|||
gSaveContext.nextTransition = 11;
|
||||
}
|
||||
|
||||
static bool SaveStateHandler(const std::vector<std::string>& args) {
|
||||
SaveState::Save(0);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
static bool LoadStateHandler(const std::vector<std::string>& args) {
|
||||
SaveState::Load(0);
|
||||
return CMD_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
#define VARTYPE_INTEGER 0
|
||||
#define VARTYPE_FLOAT 1
|
||||
#define VARTYPE_STRING 2
|
||||
|
@ -416,11 +430,10 @@ void DebugConsole_Init(void) {
|
|||
{ { "slot", ArgumentType::NUMBER }, { "item id", ArgumentType::NUMBER } } });
|
||||
CMD_REGISTER("entrance",
|
||||
{ EntranceHandler, "Sends player to the entered entrance (hex)", { { "entrance", ArgumentType::NUMBER } } });
|
||||
}
|
||||
|
||||
template <typename Numeric> bool is_number(const std::string& s) {
|
||||
Numeric n;
|
||||
return ((std::istringstream(s) >> n >> std::ws).eof());
|
||||
CMD_REGISTER("save_state", { SaveStateHandler, "Save a state." });
|
||||
CMD_REGISTER("load_state", { LoadStateHandler, "Load a state." });
|
||||
DebugConsole_LoadCVars();
|
||||
}
|
||||
|
||||
void DebugConsole_LoadCVars()
|
||||
|
|
84
soh/soh/Enhancements/savestates.cpp
Normal file
84
soh/soh/Enhancements/savestates.cpp
Normal file
|
@ -0,0 +1,84 @@
|
|||
#include "savestates.h"
|
||||
|
||||
#include "GameVersions.h"
|
||||
#include <variables.h>
|
||||
//#include "global.h"
|
||||
//#include <soh/OTRGlobals.h>
|
||||
|
||||
std::array<SaveState*, 3> gSaveStates;
|
||||
|
||||
|
||||
SaveState::SaveState() {
|
||||
|
||||
}
|
||||
#if 0
|
||||
|
||||
SaveState::~SaveState() {
|
||||
}
|
||||
#endif
|
||||
|
||||
void SaveState::Init(void) {
|
||||
gSaveStates[0] = nullptr;
|
||||
gSaveStates[1] = nullptr;
|
||||
gSaveStates[2] = nullptr;
|
||||
}
|
||||
|
||||
void SaveState::WriteHeader(SaveStateHeader& header) {
|
||||
//OTRGlobals::Instance->context->GetResourceManager()->GetGameVersion();
|
||||
// header.gameVersion = ResourceMgr_GetGameVersion();
|
||||
}
|
||||
|
||||
extern "C" MtxF* sMatrixStack; // "Matrix_stack"
|
||||
extern "C" MtxF* sCurrentMatrix; // "Matrix_now"
|
||||
extern "C" LightsBuffer sLightsBuffer;
|
||||
|
||||
extern "C" SaveStateReturn SaveState::Save(unsigned int slot) {
|
||||
if (slot > 2) {
|
||||
return SaveStateReturn::FAIL_INVALID_SLOT;
|
||||
}
|
||||
if (gSaveStates[slot] == nullptr) {
|
||||
gSaveStates[slot] = new SaveState;
|
||||
if (gSaveStates[slot] == nullptr) {
|
||||
return SaveStateReturn::FAIL_NO_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
gSaveStates[slot]->stateHeader.gameVersion = 0;
|
||||
gSaveStates[slot]->stateHeader.stateVersion = 0;
|
||||
|
||||
memcpy(&gSaveStates[slot]->sysHeapCopy, &gSystemHeap, 1024 * 1024 * 4 /* sizeof(gSystemHeap) */);
|
||||
memcpy(&gSaveStates[slot]->saveContextCopy, &gSaveContext, sizeof(gSaveContext));
|
||||
memcpy(&gSaveStates[slot]->gameInfoCopy, gGameInfo, sizeof(*gGameInfo));
|
||||
// memcpy(&gSaveStates[slot]->audioContextCopy, &gAudioContext, sizeof(AudioContext));
|
||||
memcpy(&gSaveStates[slot]->lightBufferCopy, &sLightsBuffer, sizeof(sLightsBuffer));
|
||||
memcpy(&gSaveStates[slot]->mtxStackCopy, &sMatrixStack, sizeof(MtxF) * 20);
|
||||
memcpy(&gSaveStates[slot]->currentMtxCopy, &sCurrentMatrix, sizeof(MtxF));
|
||||
//TODO RNG seed
|
||||
|
||||
return SaveStateReturn::SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
SaveStateReturn SaveState::Load(unsigned int slot) {
|
||||
if (slot > 2) {
|
||||
return SaveStateReturn::FAIL_INVALID_SLOT;
|
||||
}
|
||||
if (gSaveStates[slot] == nullptr) {
|
||||
return SaveStateReturn::FAIL_STATE_EMPTY;
|
||||
}
|
||||
|
||||
//gSaveStates[slot]->stateHeader.gameVersion = 0;
|
||||
//gSaveStates[slot]->stateHeader.stateVersion = 0;
|
||||
|
||||
memcpy(&gSystemHeap, &gSaveStates[slot]->sysHeapCopy, 1024 * 1024 * 4);
|
||||
memcpy(&gSaveContext, &gSaveStates[slot]->saveContextCopy, sizeof(gSaveContext));
|
||||
memcpy(gGameInfo, &gSaveStates[slot]->gameInfoCopy, sizeof(*gGameInfo));
|
||||
//memcpy(&gAudioContext, &gSaveStates[slot]->audioContextCopy, sizeof(AudioContext));
|
||||
memcpy(&sLightsBuffer, &gSaveStates[slot]->lightBufferCopy, sizeof(sLightsBuffer));
|
||||
memcpy(&sMatrixStack, &gSaveStates[slot]->mtxStackCopy, sizeof(MtxF) * 20);
|
||||
memcpy(&sCurrentMatrix, &gSaveStates[slot]->currentMtxCopy, sizeof(MtxF));
|
||||
//TODO RNG seed
|
||||
|
||||
|
||||
return SaveStateReturn::SUCCESS;
|
||||
}
|
60
soh/soh/Enhancements/savestates.h
Normal file
60
soh/soh/Enhancements/savestates.h
Normal file
|
@ -0,0 +1,60 @@
|
|||
#ifndef SAVE_STATES_H
|
||||
#define SAVE_STATES_H
|
||||
#include "z64.h"
|
||||
#include "z64save.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <array>
|
||||
|
||||
// FROM z_lights.c
|
||||
// I didn't feel like moving it into a header file.
|
||||
#define LIGHTS_BUFFER_SIZE 32
|
||||
//#define LIGHTS_BUFFER_SIZE 1024 // Kill me
|
||||
|
||||
typedef struct {
|
||||
/* 0x000 */ s32 numOccupied;
|
||||
/* 0x004 */ s32 searchIndex;
|
||||
/* 0x008 */ LightNode buf[LIGHTS_BUFFER_SIZE];
|
||||
} LightsBuffer; // size = 0x188
|
||||
|
||||
|
||||
enum class SaveStateReturn {
|
||||
SUCCESS,
|
||||
FAIL_INVALID_SLOT,
|
||||
FAIL_NO_MEMORY,
|
||||
FAIL_STATE_EMPTY,
|
||||
};
|
||||
|
||||
typedef struct SaveStateHeader {
|
||||
uint32_t stateVersion;
|
||||
uint32_t gameVersion;
|
||||
} SaveStateHeader;
|
||||
|
||||
class SaveState {
|
||||
public:
|
||||
SaveState();
|
||||
~SaveState() = delete;
|
||||
SaveState& operator=(const SaveState& rhs) = delete;
|
||||
SaveState(const SaveState& rhs) = delete;
|
||||
|
||||
void Init(void);
|
||||
static SaveStateReturn Save(unsigned int slot);
|
||||
static SaveStateReturn Load(unsigned int slot);
|
||||
|
||||
private:
|
||||
static void WriteHeader(SaveStateHeader& header);
|
||||
static void ReadHeader(SaveStateHeader& header);
|
||||
SaveStateHeader stateHeader;
|
||||
unsigned char sysHeapCopy[1024 * 1024 * 4]; //TODO, make a macro for this
|
||||
SaveContext saveContextCopy;
|
||||
GameInfo gameInfoCopy;
|
||||
LightsBuffer lightBufferCopy;
|
||||
//AudioContext audioContextCopy;
|
||||
std::array<MtxF,20> mtxStackCopy; // always 20 matricies
|
||||
MtxF currentMtxCopy;
|
||||
uint32_t rngSeed;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,3 +1,6 @@
|
|||
#ifndef OTR_GLOBALS_H
|
||||
#define OTR_GLOBALS_H
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "GlobalCtx2.h"
|
||||
|
@ -68,3 +71,5 @@ void AudioPlayer_Play(const uint8_t* buf, uint32_t len);
|
|||
void AudioMgr_CreateNextAudioBuffer(s16* samples, u32 num_samples);
|
||||
int Controller_ShouldRumble(size_t i);
|
||||
#endif
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue