2020-12-13 19:47:30 +00:00
|
|
|
#include "frontends/common2/utils.h"
|
|
|
|
|
|
|
|
#include "linux/interface.h"
|
2021-05-05 15:56:10 +01:00
|
|
|
#include "linux/network/uthernet2.h"
|
2020-10-09 19:13:42 +01:00
|
|
|
|
|
|
|
#include "StdAfx.h"
|
|
|
|
#include "SaveState.h"
|
|
|
|
|
2020-12-13 19:47:30 +00:00
|
|
|
#include "Common.h"
|
|
|
|
#include "CardManager.h"
|
|
|
|
#include "Core.h"
|
|
|
|
#include "Disk.h"
|
|
|
|
#include "Mockingboard.h"
|
|
|
|
#include "SoundCore.h"
|
|
|
|
#include "Harddisk.h"
|
|
|
|
#include "Speaker.h"
|
|
|
|
#include "Log.h"
|
|
|
|
#include "CPU.h"
|
|
|
|
#include "Memory.h"
|
|
|
|
#include "LanguageCard.h"
|
|
|
|
#include "MouseInterface.h"
|
|
|
|
#include "ParallelPrinter.h"
|
|
|
|
#include "Video.h"
|
|
|
|
#include "NTSC.h"
|
|
|
|
#include "SaveState.h"
|
|
|
|
#include "RGBMonitor.h"
|
|
|
|
#include "Riff.h"
|
|
|
|
#include "Utilities.h"
|
2020-12-27 20:25:42 +00:00
|
|
|
#include "Interface.h"
|
2021-03-07 20:32:24 +00:00
|
|
|
#include "Debugger/Debug.h"
|
2021-04-17 19:07:21 +01:00
|
|
|
#include "Tfe/tfe.h"
|
2020-12-13 19:47:30 +00:00
|
|
|
|
2020-10-09 19:13:42 +01:00
|
|
|
#include <libgen.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2021-02-25 16:04:50 +00:00
|
|
|
namespace common2
|
2020-10-09 19:13:42 +01:00
|
|
|
{
|
2020-12-06 18:03:41 +00:00
|
|
|
|
2021-02-25 16:04:50 +00:00
|
|
|
void setSnapshotFilename(const std::string & filename, const bool load)
|
|
|
|
{
|
|
|
|
// same logic as qapple
|
|
|
|
// setting chdir allows to load relative disks from the snapshot file (tests?)
|
|
|
|
// but if the snapshot file itself is relative, it wont work after a chdir
|
|
|
|
// so we convert to absolute first
|
|
|
|
char * absPath = realpath(filename.c_str(), nullptr);
|
|
|
|
if (absPath)
|
2020-12-06 18:03:41 +00:00
|
|
|
{
|
2021-02-25 16:04:50 +00:00
|
|
|
char * temp = strdup(absPath);
|
|
|
|
const char * dir = dirname(temp);
|
|
|
|
// dir points inside temp!
|
|
|
|
chdir(dir);
|
|
|
|
Snapshot_SetFilename(absPath);
|
|
|
|
|
|
|
|
free(temp);
|
|
|
|
free(absPath);
|
|
|
|
|
|
|
|
if (load)
|
|
|
|
{
|
|
|
|
Snapshot_LoadState();
|
|
|
|
}
|
2020-12-06 18:03:41 +00:00
|
|
|
}
|
2020-10-09 19:13:42 +01:00
|
|
|
}
|
2020-12-13 19:47:30 +00:00
|
|
|
|
2021-03-27 18:47:40 +00:00
|
|
|
void InitialiseEmulator()
|
2021-02-25 16:04:50 +00:00
|
|
|
{
|
2020-12-13 19:47:30 +00:00
|
|
|
#ifdef RIFF_SPKR
|
2021-02-25 16:04:50 +00:00
|
|
|
RiffInitWriteFile("/tmp/Spkr.wav", SPKR_SAMPLE_RATE, 1);
|
2020-12-13 19:47:30 +00:00
|
|
|
#endif
|
|
|
|
#ifdef RIFF_MB
|
2021-02-25 16:04:50 +00:00
|
|
|
RiffInitWriteFile("/tmp/Mockingboard.wav", 44100, 2);
|
2020-12-13 19:47:30 +00:00
|
|
|
#endif
|
|
|
|
|
2021-02-25 16:04:50 +00:00
|
|
|
g_nAppMode = MODE_RUNNING;
|
|
|
|
LogFileOutput("Initialisation\n");
|
2020-12-13 19:47:30 +00:00
|
|
|
|
2021-02-25 16:04:50 +00:00
|
|
|
g_bFullSpeed = false;
|
2020-12-13 19:47:30 +00:00
|
|
|
|
2021-02-25 16:04:50 +00:00
|
|
|
LoadConfiguration();
|
|
|
|
SetCurrentCLK6502();
|
|
|
|
GetAppleWindowTitle();
|
|
|
|
GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES | DRAW_DISK_STATUS);
|
2020-12-13 19:47:30 +00:00
|
|
|
|
2021-02-25 16:04:50 +00:00
|
|
|
DSInit();
|
|
|
|
MB_Initialize();
|
|
|
|
SpkrInitialize();
|
2020-12-13 19:47:30 +00:00
|
|
|
|
2021-02-25 16:04:50 +00:00
|
|
|
MemInitialize();
|
2020-12-13 19:47:30 +00:00
|
|
|
|
2021-02-25 16:04:50 +00:00
|
|
|
GetCardMgr().GetDisk2CardMgr().Reset();
|
|
|
|
HD_Reset();
|
2021-05-05 15:56:10 +01:00
|
|
|
|
|
|
|
switch (tfe_enabled)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
tfe_init();
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
registerUthernet2();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-02-25 16:04:50 +00:00
|
|
|
Snapshot_Startup();
|
2021-03-07 20:32:24 +00:00
|
|
|
|
|
|
|
DebugInitialize();
|
2021-02-25 16:04:50 +00:00
|
|
|
}
|
2020-12-13 19:47:30 +00:00
|
|
|
|
2021-03-27 18:47:40 +00:00
|
|
|
void DestroyEmulator()
|
2020-12-13 19:47:30 +00:00
|
|
|
{
|
2021-02-25 16:04:50 +00:00
|
|
|
Snapshot_Shutdown();
|
|
|
|
CMouseInterface* pMouseCard = GetCardMgr().GetMouseCard();
|
|
|
|
if (pMouseCard)
|
|
|
|
{
|
|
|
|
pMouseCard->Reset();
|
|
|
|
}
|
|
|
|
MemDestroy();
|
|
|
|
|
|
|
|
SpkrDestroy();
|
|
|
|
MB_Destroy();
|
|
|
|
DSUninit();
|
2020-12-13 19:47:30 +00:00
|
|
|
|
2021-05-05 15:56:10 +01:00
|
|
|
unRegisterUthernet2();
|
2021-04-17 19:07:21 +01:00
|
|
|
tfe_shutdown();
|
2021-02-25 16:04:50 +00:00
|
|
|
HD_Destroy();
|
|
|
|
PrintDestroy();
|
|
|
|
CpuDestroy();
|
2021-05-23 20:06:36 +01:00
|
|
|
DebugDestroy();
|
2020-12-13 19:47:30 +00:00
|
|
|
|
2021-02-25 16:04:50 +00:00
|
|
|
GetCardMgr().GetDisk2CardMgr().Destroy();
|
|
|
|
RiffFinishWriteFile();
|
|
|
|
}
|
2020-12-13 19:47:30 +00:00
|
|
|
|
|
|
|
}
|