mirror of
https://github.com/RetroDECK/Supermodel.git
synced 2025-04-10 19:15:14 +00:00
Added a debug option to load and render a single frame of graphics state from a save state file. Only available if compiled with DEBUG defined. Invoked using: -gfx-state=<file> on command line.
This commit is contained in:
parent
1265c8d184
commit
112777385e
168
Src/Model3/Model3GraphicsState.h
Normal file
168
Src/Model3/Model3GraphicsState.h
Normal file
|
@ -0,0 +1,168 @@
|
||||||
|
/**
|
||||||
|
** Supermodel
|
||||||
|
** A Sega Model 3 Arcade Emulator.
|
||||||
|
** Copyright 2011-2016 Bart Trzynadlowski, Nik Henson
|
||||||
|
**
|
||||||
|
** This file is part of Supermodel.
|
||||||
|
**
|
||||||
|
** Supermodel is free software: you can redistribute it and/or modify it under
|
||||||
|
** the terms of the GNU General Public License as published by the Free
|
||||||
|
** Software Foundation, either version 3 of the License, or (at your option)
|
||||||
|
** any later version.
|
||||||
|
**
|
||||||
|
** Supermodel is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||||
|
** more details.
|
||||||
|
**
|
||||||
|
** You should have received a copy of the GNU General Public License along
|
||||||
|
** with Supermodel. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
**/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Model3GraphicsState.h
|
||||||
|
*
|
||||||
|
* Minimalistic implementation of IEmulator designed to load and view graphics
|
||||||
|
* state.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INCLUDED_MODEL3GRAPHICSSTATE_H
|
||||||
|
#define INCLUDED_MODEL3GRAPHICSSTATE_H
|
||||||
|
|
||||||
|
#include "Model3/IEmulator.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* CModel3GraphicsState:
|
||||||
|
*
|
||||||
|
* Stores only graphics (tilegen and Real3D) state.
|
||||||
|
*/
|
||||||
|
class CModel3GraphicsState: public IEmulator, public IBus
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void SaveState(CBlockFile *SaveState)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadState(CBlockFile *SaveState)
|
||||||
|
{
|
||||||
|
m_real3D.LoadState(SaveState);
|
||||||
|
m_tileGen.LoadState(SaveState);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SaveNVRAM(CBlockFile *NVRAM)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadNVRAM(CBlockFile *NVRAM)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ClearNVRAM(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void RunFrame(void)
|
||||||
|
{
|
||||||
|
RenderFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderFrame(void)
|
||||||
|
{
|
||||||
|
BeginFrameVideo();
|
||||||
|
m_tileGen.BeginFrame();
|
||||||
|
m_real3D.BeginFrame();
|
||||||
|
m_real3D.RenderFrame();
|
||||||
|
m_real3D.EndFrame();
|
||||||
|
m_tileGen.EndFrame();
|
||||||
|
EndFrameVideo();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Reset(void)
|
||||||
|
{
|
||||||
|
// Load state
|
||||||
|
CBlockFile SaveState;
|
||||||
|
if (OKAY != SaveState.Load(m_stateFilePath.c_str()))
|
||||||
|
ErrorLog("Unable to load state from '%s'.", m_stateFilePath.c_str());
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LoadState(&SaveState);
|
||||||
|
SaveState.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const struct GameInfo * GetGameInfo(void)
|
||||||
|
{
|
||||||
|
return m_game;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LoadROMSet(const struct GameInfo *gameList, const char *zipFile)
|
||||||
|
{
|
||||||
|
// Load ROM
|
||||||
|
struct ROMMap map[] =
|
||||||
|
{
|
||||||
|
{ "VROM", m_vrom.get() },
|
||||||
|
{ NULL, NULL }
|
||||||
|
};
|
||||||
|
m_game = LoadROMSetFromZIPFile(map, gameList, zipFile, false);
|
||||||
|
if (NULL == m_game)
|
||||||
|
return ErrorLog("Failed to load ROM set.");
|
||||||
|
if (m_game->vromSize < 0x4000000) // VROM is actually 64 MB
|
||||||
|
CopyRegion(m_vrom.get(), m_game->vromSize, 0x4000000, m_vrom.get(), m_game->vromSize);
|
||||||
|
m_real3D.SetStep(m_game->step);
|
||||||
|
return OKAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AttachRenderers(CRender2D *render2D, IRender3D *render3D)
|
||||||
|
{
|
||||||
|
m_tileGen.AttachRenderer(render2D);
|
||||||
|
m_real3D.AttachRenderer(render3D);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AttachInputs(CInputs *InputsPtr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void AttachOutputs(COutputs *OutputsPtr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Init(void)
|
||||||
|
{
|
||||||
|
m_vrom.reset(new uint8_t[64*1024*1024], std::default_delete<uint8_t[]>());
|
||||||
|
m_irq.Init();
|
||||||
|
if (OKAY != m_tileGen.Init(&m_irq))
|
||||||
|
return FAIL;
|
||||||
|
if (OKAY != m_real3D.Init(m_vrom.get(), this, &m_irq, 0x100))
|
||||||
|
return FAIL;
|
||||||
|
return OKAY;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PauseThreads(void)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ResumeThreads(void)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CModel3GraphicsState(const std::string &filePath)
|
||||||
|
: m_stateFilePath(filePath)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~CModel3GraphicsState(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
const std::string m_stateFilePath;
|
||||||
|
std::shared_ptr<uint8_t> m_vrom;
|
||||||
|
const struct GameInfo *m_game;
|
||||||
|
CIRQ m_irq;
|
||||||
|
CTileGen m_tileGen;
|
||||||
|
CReal3D m_real3D;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // INCLUDED_CMODEL3GRAPHICSSTATE_H
|
|
@ -57,6 +57,10 @@
|
||||||
#include "WinOutputs.h"
|
#include "WinOutputs.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
#include "Model3/Model3GraphicsState.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
Error and Debug Logging
|
Error and Debug Logging
|
||||||
|
@ -1487,21 +1491,12 @@ int main(int argc, char **argv)
|
||||||
bool cmdPrintInputs = false;
|
bool cmdPrintInputs = false;
|
||||||
bool cmdConfigInputs = false;
|
bool cmdConfigInputs = false;
|
||||||
bool cmdDis = false;
|
bool cmdDis = false;
|
||||||
|
std::string gfxStatePath;
|
||||||
CINIFile CmdLine; // not associated with any files, only holds command line options
|
CINIFile CmdLine; // not associated with any files, only holds command line options
|
||||||
CmdLine.SetDefaultSectionName("Global"); // command line settings are global-level
|
CmdLine.SetDefaultSectionName("Global"); // command line settings are global-level
|
||||||
for (int i = 1; i < argc; i++)
|
for (int i = 1; i < argc; i++)
|
||||||
{
|
{
|
||||||
if (!strcmp(argv[i], "-new3d"))
|
if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "-?") || !strcmp(argv[i], "-help") || !strcmp(argv[i], "--help"))
|
||||||
{
|
|
||||||
unsigned n = 1;
|
|
||||||
CmdLine.Set("Global", "New3DEngine", n);
|
|
||||||
}
|
|
||||||
else if (!strcmp(argv[i], "-legacy3d"))
|
|
||||||
{
|
|
||||||
unsigned n = 0;
|
|
||||||
CmdLine.Set("Global", "New3DEngine", n);
|
|
||||||
}
|
|
||||||
else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "-?") || !strcmp(argv[i], "-help") || !strcmp(argv[i], "--help"))
|
|
||||||
{
|
{
|
||||||
Help();
|
Help();
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1661,6 +1656,16 @@ int main(int argc, char **argv)
|
||||||
else
|
else
|
||||||
CmdLine.Set("Global", "Crosshairs", x);
|
CmdLine.Set("Global", "Crosshairs", x);
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(argv[i], "-new3d"))
|
||||||
|
{
|
||||||
|
unsigned n = 1;
|
||||||
|
CmdLine.Set("Global", "New3DEngine", n);
|
||||||
|
}
|
||||||
|
else if (!strcmp(argv[i], "-legacy3d"))
|
||||||
|
{
|
||||||
|
unsigned n = 0;
|
||||||
|
CmdLine.Set("Global", "New3DEngine", n);
|
||||||
|
}
|
||||||
else if (!strncmp(argv[i], "-vert-shader", 12))
|
else if (!strncmp(argv[i], "-vert-shader", 12))
|
||||||
{
|
{
|
||||||
if (argv[i][12] == '\0')
|
if (argv[i][12] == '\0')
|
||||||
|
@ -1729,6 +1734,19 @@ int main(int argc, char **argv)
|
||||||
PrintGLInfo(true, false, false);
|
PrintGLInfo(true, false, false);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
|
else if (!strncmp(argv[i], "-gfx-state", 10))
|
||||||
|
{
|
||||||
|
if (argv[i][10] == '\0')
|
||||||
|
ErrorLog("'-gfx-state' requires a file path.");
|
||||||
|
else if (argv[i][10] != '=')
|
||||||
|
ErrorLog("Ignoring unrecognized option: %s", argv[i]);
|
||||||
|
else if (argv[i][10] == '\0')
|
||||||
|
ErrorLog("'-gfx-state' requires a file path.");
|
||||||
|
else
|
||||||
|
gfxStatePath.assign(&argv[i][11]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
else if (argv[i][0] == '-')
|
else if (argv[i][0] == '-')
|
||||||
ErrorLog("Ignoring unrecognized option: %s", argv[i]);
|
ErrorLog("Ignoring unrecognized option: %s", argv[i]);
|
||||||
else
|
else
|
||||||
|
@ -1748,7 +1766,11 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create Model 3 emulator
|
// Create Model 3 emulator
|
||||||
|
#ifdef DEBUG
|
||||||
|
IEmulator *Model3 = gfxStatePath.empty() ? static_cast<IEmulator *>(new CModel3()) : static_cast<IEmulator *>(new CModel3GraphicsState(gfxStatePath));
|
||||||
|
#else
|
||||||
IEmulator *Model3 = new CModel3();
|
IEmulator *Model3 = new CModel3();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Create input system (default is SDL) and debugger
|
// Create input system (default is SDL) and debugger
|
||||||
CInputSystem *InputSystem = NULL;
|
CInputSystem *InputSystem = NULL;
|
||||||
|
|
Loading…
Reference in a new issue