-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcpu.h
82 lines (67 loc) · 2.82 KB
/
cpu.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
#ifndef _CPU_H_
#define _CPU_H_
#include "stdint.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "time.h"
#define PROGRAM_START 0x0200
#define FLAG_REG 15
#define MAX_INTEGER_8BIT 255
#define WIDTH 64
#define HEIGHT 32
extern uint8_t memory[4096]; // CHIP-8 has 4KB of RAM
extern uint8_t video_buffer[WIDTH * HEIGHT]; // video memory buffer to be drawn to screen
extern uint8_t keys[16]; // holds CHIP-8's 16 key states; value is 1 when key is pressed, 0 when released
/*
* CHIP-8 registers
*/
typedef struct registers {
// 16 data registers -- Note: V[15] is the flag register
uint8_t V[16];
uint16_t I; // address register - involved in mem. operations
uint16_t pc; // program counter
uint16_t sp; // stack pointer
} Chip8;
void fde_cycle(Chip8 * cpu_reg);
void initialize_cpu(Chip8 * cpu_reg);
void debugger(Chip8* cpu_reg, uint16_t opcode);
/****************************************************************/
/************* Chip-8 Intructions *************/
/****************************************************************/
void SYS_addr(uint16_t opcode, Chip8 * cpu_reg);
void CLS(uint16_t opcode, Chip8 * cpu_reg);
void RET(uint16_t opcode, Chip8 * cpu_reg);
void JP_addr(uint16_t opcode, Chip8 * cpu_reg);
void CALL_addr(uint16_t opcode, Chip8 * cpu_reg);
void SE_VX_byte(uint16_t opcode, Chip8 * cpu_reg);
void SNE_VX_byte(uint16_t opcode, Chip8 * cpu_reg);
void SE_VX_VY(uint16_t opcode, Chip8 * cpu_reg);
void LD_VX_byte(uint16_t opcode, Chip8 * cpu_reg);
void ADD_VX_byte(uint16_t opcode, Chip8 * cpu_reg);
void LD_VX_VY(uint16_t opcode, Chip8 * cpu_reg);
void OR_VX_VY(uint16_t opcode, Chip8 * cpu_reg);
void AND_VX_VY(uint16_t opcode, Chip8 * cpu_reg);
void XOR_VX_VY(uint16_t opcode, Chip8 * cpu_reg);
void ADD_VX_VY(uint16_t opcode, Chip8 * cpu_reg);
void SUB_VX_VY(uint16_t opcode, Chip8 * cpu_reg);
void SHR_VX_VY(uint16_t opcode, Chip8 * cpu_reg);
void SUBN_VX_VY(uint16_t opcode, Chip8 * cpu_reg);
void SHL_VX_VY(uint16_t opcode, Chip8 * cpu_reg);
void SNE_VX_VY(uint16_t opcode, Chip8 * cpu_reg);
void LD_I_addr(uint16_t opcode, Chip8 * cpu_reg);
void JP_V0_addr(uint16_t opcode, Chip8 * cpu_reg);
void RND_VX_byte(uint16_t opcode, Chip8 * cpu_reg);
void DRW_VX_VY_nibble(uint16_t opcode, Chip8 * cpu_reg);
void SKP_VX(uint16_t opcode, Chip8 * cpu_reg);
void SKNP_VX(uint16_t opcode, Chip8 * cpu_reg);
void LD_VX_DT(uint16_t opcode, Chip8 * cpu_reg);
void LD_VX_K(uint16_t opcode, Chip8 * cpu_reg);
void LD_DT_VX(uint16_t opcode, Chip8 * cpu_reg);
void LD_ST_VX(uint16_t opcode, Chip8 * cpu_reg);
void ADD_I_VX(uint16_t opcode, Chip8 * cpu_reg);
void LD_F_VX(uint16_t opcode, Chip8 * cpu_reg);
void LD_B_VX(uint16_t opcode, Chip8 * cpu_reg);
void LD_I_VX(uint16_t opcode, Chip8 * cpu_reg);
void LD_VX_I(uint16_t opcode, Chip8 * cpu_reg);
#endif