-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchip8.h
90 lines (84 loc) · 2.55 KB
/
chip8.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
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
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include<time.h>
#include<map>
#include<SDL2/SDL.h>
#define CLOCKSPEED 1000
class Chip8
{
unsigned short opcode;
unsigned char memory[4096];
unsigned char V[16];
unsigned short I;
unsigned short pc;
unsigned char delay_timer;
unsigned char sound_timer;
unsigned short stack[16];
unsigned short sp;
unsigned char key[16];
std::map<SDL_Keycode, short> keymap;
bool drawFlag;
public:
unsigned char gfx[32][64]; //Make this private later
int findSizeOfFile(FILE *fp);
void loadGame(char *path);
void clearScreen();
void skipIfVXEqualsNN();
void skipIfVXNotEqualsNN();
void skipIfVXEqualsVY();
void skipIfKeyEqualsVX();
void skipIfKeyNotEqualsVX();
void setVXToNN();
void addNNToVX();
void handleZero(short opcode);
void jumpToAddress();
void callSubroutine();
void returnFromSubroutine();
void handleOne(short opcode);
void handleTwo(short opcode);
void handleThree(short opcode);
void handleFour(short opcode);
void handleFive(short opcode);
void handleSix(short opcode);
void handleSeven(short opcode);
void setVXToVY();
void setVXToVXOrVY();
void setVXToVXAndVY();
void setVXToVXXOrVY();
void setVXToVXPlusVY();
void setVXToVXMinusVY();
void setVXToVYMinusVX();
void setVXToRightShiftVX();
void setVXToLeftShiftVX();
void setVXToDelay();
void setVXToKey();
void skipIfVXNotEqualsYY();
void setIToNNN();
void jumpToNNNPlusV0();
void setVXToRandAndNNN();
void drawAtVXVY();
void setIToSprite();
void handleEight(short opcode);
void handleNine(short opcode);
void handleA(short opcode);
void handleB(short opcode);
void handleC(short opcode);
void handleD(short opcode);
void handleE(short opcode);
void handleF(short opcode);
void setDelayToVX();
void setSoundToVX();
void setIToVXPlusI();
void storeBCDInI();
void storeV0toVX();
void fillV0ToVX();
void initialize();
void emulateCycle();
bool shouldDraw();
void setDraw(bool flag);
void inputCycle();
void setDelay(unsigned char value);
void setSound(unsigned char value);
void timerCycle();
};