18#define C8_CLOCK_SPEED 1000
23#define C8_STACK_SIZE 16
28#define C8_MODE_CHIP8 0
33#define C8_MODE_SCHIP 1
38#define C8_MODE_XOCHIP 2
43#define C8_FLAG_DEBUG 0x1
48#define C8_FLAG_VERBOSE 0x2
53#define C8_FLAG_QUIRK_BITWISE 0x4
58#define C8_FLAG_QUIRK_DRAW 0x8
63#define C8_FLAG_QUIRK_LOADSTORE 0x10
68#define C8_FLAG_QUIRK_SHIFT 0x20
73#define C8_FLAG_QUIRK_JUMP 0x40
C8 * c8_init(const char *, int)
Initialize and return a C8 with the given flags.
Definition: chip8.c:46
void c8_deinit(C8 *)
Deinitialize graphics and free c8.
Definition: chip8.c:29
int c8_load_palette_s(C8 *, char *)
Load palette from the given string into colors.
Definition: chip8.c:78
void c8_load_quirks(C8 *, const char *)
Load quirk flags from string.
Definition: chip8.c:143
#define C8_STACK_SIZE
Maximum stack size.
Definition: chip8.h:23
void c8_simulate(C8 *)
Main interpreter simulation loop. Exits when c8->running is 0.
Definition: chip8.c:208
int c8_load_palette_f(C8 *, const char *)
Load palette from the given path into colors.
Definition: chip8.c:111
int c8_load_rom(C8 *, const char *)
Load a ROM to c8->mem at path addr.
Definition: chip8.c:175
const char * c8_version(void)
Get the version of libc8.
Definition: chip8.c:295
#define C8_MEMSIZE
Total memory size.
Definition: common.h:74
Represents a graphics display.
Definition: graphics.h:70
Represents current state of the CHIP-8 interpreter.
Definition: chip8.h:79
int draw
Need to draw? (1 or 0)
Definition: chip8.h:99
uint16_t I
Address register.
Definition: chip8.h:88
int mode
Interpreter mode (C8_MODE_CHIP8, C8_MODE_SCHIP, C8_MODE_XOCHIP)
Definition: chip8.h:100
int waitingForKey
Waiting for keypress?
Definition: chip8.h:92
C8_Display display
Graphics display.
Definition: chip8.h:94
int running
Interpreter running state.
Definition: chip8.h:93
int VK
Register to store next keypress.
Definition: chip8.h:90
int flags
CLI flags.
Definition: chip8.h:95
int cs
Instructions to execute per second.
Definition: chip8.h:91
uint8_t dt
Delay timer.
Definition: chip8.h:84
uint8_t sp
Stack pointer.
Definition: chip8.h:83
uint16_t pc
Program counter.
Definition: chip8.h:87
uint8_t st
Sound timer.
Definition: chip8.h:85