-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathChipInterpreterHandler.h
40 lines (36 loc) · 1.13 KB
/
ChipInterpreterHandler.h
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
//
// Created by vincenzo on 08/10/22.
//
#ifndef CHIPEMULATOR_CHIPINTERPRETERHANDLER_H
#define CHIPEMULATOR_CHIPINTERPRETERHANDLER_H
#include "ChipInterpreter.h"
#include "SdlChipDisplay.h"
#include "DisplayTextureHandler.h"
#include "Rom.h"
#include "KeyBindings.h"
#include "SoundEngine.h"
#include <fstream>
class ChipInterpreterHandler : public Drawable, private SoundObserver{
public:
explicit ChipInterpreterHandler(int frequency){
executionPeriodMs=(1/(float)frequency);
};
void loadRom(Rom& rom);
void handleExecution();
void handleEvents(SDL_Event &e);
void draw() override;
private:
void startSound() override;
void stopSound() override;
Keyboard keyboard;
KeyBindings keyBindings;
DisplayTextureHandler textureHandler;
SdlChipDisplay display=SdlChipDisplay(&textureHandler);
ChipInterpreter interpreter=ChipInterpreter(&display,&keyboard, this);
uint64_t currentTime=SDL_GetPerformanceCounter();
float timerRefreshPeriod=1/(float)60;
uint64_t lastExecution=0;
uint64_t lastTimerUpdate=0;
float executionPeriodMs;
};
#endif //CHIPEMULATOR_CHIPINTERPRETERHANDLER_H