-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.cpp
65 lines (54 loc) · 1.71 KB
/
App.cpp
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
//
// Created by vincenzo on 27/10/22.
//
#include "App.h"
App::~App() {
delete window;
soundEngine->removeSynth(&synth);
engine.removeDrawable(&crtFilter);
engine.removeDrawable(chipInterpreterHandler.get());
delete soundEngine;
}
App::App(int argc, char *argv[]) {
setupCommandlineParser(argc,argv);
setupWindow();
setupSoundEngine();
setupInterpreter();
setupRenderEngine();
}
void App::setupWindow() {
window=Window::getInstance();
}
void App::setupSoundEngine() {
soundEngine=SoundEngine::getInstance();
synth.setAmplitude(0.5);
soundEngine->addSynth(&synth,220);
}
void App::setupInterpreter() {
Rom rom(argParser->getRomPath());
chipInterpreterHandler=std::make_unique<ChipInterpreterHandler>(argParser->getFrequency());
chipInterpreterHandler->loadRom(rom);
}
void App::setupRenderEngine() {
engine.addDrawable(chipInterpreterHandler.get());
crtFilter.setCrossingLineEnabled(argParser->isCrossingLineEnabled());
crtFilter.setCrossingLineDirection(argParser->isCrossingLineDirection());
crtFilter.setHorizontalScanLinesEnabled(argParser->isHorizontalScanLinesEnabled());
crtFilter.setVerticalScanLinesEnabled(argParser->isVerticalScanLinesEnabled());
engine.addDrawable(&crtFilter);
}
void App::setupCommandlineParser(int argc, char *argv[]) {
argParser=std::make_unique<ArgParser>(argc, argv);
argParser->parse();
}
void App::run() {
while (window->isRunning()){
SDL_Event e;
while (SDL_PollEvent(&e) != 0) {
window->events(e);
chipInterpreterHandler->handleEvents(e);
}
chipInterpreterHandler->handleExecution();
engine.render();
}
}