-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGame.h
51 lines (40 loc) · 1.07 KB
/
Game.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
41
42
43
44
45
46
47
48
49
50
51
#include <SDL2/SDL.h>
#include <SDL2/SDL_mixer.h>
#include <sys/time.h>
#include "CPU.h"
//Controls the CPU, renders game to window, handles key events
class Game
{
private:
CPU cpu;
double lastTimer;
double nextInterrupt;
int whichInterrupt;
const int SCREEN_WIDTH = 256;
const int SCREEN_HEIGHT = 224;
//track sound state
unsigned char lastSoundPort3;
unsigned char lastSoundPort5;
bool loopUFOSound;
bool exit;
std::array<Mix_Chunk*, 9> sounds;
SDL_Event keyEvent;
SDL_Window* mainWin;
SDL_Renderer* renderer;
SDL_Texture* windowTexture;
SDL_Rect flipRect;
uint* pixelBuffer;
public:
Game();
void pollKeyboard();
void copyToPixelBuffer();
void initVideo();
void updateWindow();
void clearPixelBuffer();
void rotatePixelBuffer();
void initSound();
void playSounds();
void runCPU();
double getTimeUsec();
bool isRunning();
};