-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
39 lines (32 loc) · 1.18 KB
/
main.cpp
File metadata and controls
39 lines (32 loc) · 1.18 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
#include <memory>
#include <fstream>
#include <filesystem>
#include "NobleDesktop.h"
#include "../NobleVM/VirtualMachine.h"
Noble::VM::Frame LoadFrame(const std::string& frameName)
{
Noble::VM::Frame frame;
if (std::ifstream opsFile(frameName + ".naf"); opsFile.is_open())
{
std::filesystem::path opsPath { frameName + ".naf" };
ulong opsSize = file_size(opsPath);
opsFile.read(reinterpret_cast<std::ifstream::char_type*>(&frame.ops), opsSize);
frame.numOps = opsSize;
}
if (std::ifstream constantsFile(frameName + ".ndf"); constantsFile.is_open())
{
std::filesystem::path dataPath { frameName + ".ndf" };
ulong dataSize = file_size(dataPath);
constantsFile.read(reinterpret_cast<std::ifstream::char_type*>(&frame.constants), dataSize);
frame.numConstants = dataSize;
}
return frame;
}
int main(int argc, char** argv)
{
const std::unique_ptr<Noble::VM::VirtualMachineGraphics> graphics = std::make_unique<Noble::Desktop::NobleDesktop>();
Noble::VM::VirtualMachine virtualMachine(graphics.get());
Noble::VM::Frame frame = LoadFrame("test");
virtualMachine.RunFrame(frame);
return 0;
}