forked from VCCE/VCC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVccHeadless.cpp
More file actions
103 lines (85 loc) · 1.73 KB
/
VccHeadless.cpp
File metadata and controls
103 lines (85 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include "VccHeadless.h"
#include "BuildConfig.h"
#include "CommandLine.h"
#include "DirectDrawInterface.h"
#include "Vcc.h"
#include "audio.h"
#include "coco3.h"
#include "config.h"
#include "defines.h"
#include "pakinterface.h"
#include "throttle.h"
#include <cstring>
namespace
{
bool g_headlessInitialized = false;
}
int vcc_headless_init(void)
{
if (g_headlessInitialized)
return 1;
memset(&CmdArg, 0, sizeof(CmdArg));
Cls(0, &EmuState);
EmuState.Throttle = 0;
EmuState.WindowHandle = nullptr;
EmuState.WindowSize.w = VCC::DefaultWidth;
EmuState.WindowSize.h = VCC::DefaultHeight;
EmuState.Exiting = false;
LoadConfig(&EmuState);
EmuState.FullScreen = 1;
if (!CreateNullWindow(&EmuState))
return 0;
InitSound();
LoadModule();
SetClockSpeed(1);
EmuState.EmulationRunning = 1;
DoCls(&EmuState);
DoHardReset(&EmuState);
g_headlessInitialized = true;
return 1;
}
void vcc_headless_shutdown(void)
{
if (!g_headlessInitialized)
return;
EmuState.EmulationRunning = 0;
EmuState.Exiting = true;
CloseScreen();
g_headlessInitialized = false;
}
int vcc_headless_reset(void)
{
if (!g_headlessInitialized && !vcc_headless_init())
return 0;
DoCls(&EmuState);
DoHardReset(&EmuState);
return 1;
}
int vcc_headless_step_frame(void)
{
if (!g_headlessInitialized && !vcc_headless_init())
return 0;
StartRender();
RenderFrame(&EmuState);
EndRender(1);
GetModuleStatus(&EmuState);
return 1;
}
const uint32_t* vcc_headless_framebuffer(void)
{
if (!g_headlessInitialized)
return nullptr;
return EmuState.PTRsurface32;
}
int vcc_headless_frame_width(void)
{
return VCC::DefaultWidth;
}
int vcc_headless_frame_height(void)
{
return VCC::DefaultHeight;
}
int vcc_headless_frame_stride(void)
{
return VCC::DefaultWidth;
}