libc8
CHIP-8 utility library
|
#include "chip8.h"
#include "decode.h"
#include "font.h"
#include "private/debug.h"
#include "private/exception.h"
#include "private/util.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Macros | |
#define | DEBUG(c) (c->flags & C8_FLAG_DEBUG) |
#define | VERBOSE(c) (c->flags & C8_FLAG_VERBOSE) |
#define | QUIRK_BITWISE(c) |
#define | QUIRK_DRAW(c) |
#define | QUIRK_LOADSTORE(c) |
#define | QUIRK_SHIFT(c) |
#define | BORROWS(x, y) ((((int) x) - y) < 0) |
#define | CARRIES(x, y) ((((int) x) + y) > UINT8_MAX) |
Functions | |
void | c8_deinit (c8_t *c8) |
Deinitialize graphics and free c8. More... | |
c8_t * | c8_init (const char *path, int flags) |
Initialize and return a c8_t with the given flags. More... | |
int | c8_load_palette_s (c8_t *c8, char *s) |
Load palette from the given string into colors . More... | |
int | c8_load_palette_f (c8_t *c8, const char *path) |
Load palette from the given path into colors . More... | |
void | c8_load_quirks (c8_t *c8, const char *s) |
Load quirk flags from string. More... | |
void | c8_simulate (c8_t *c8) |
Main interpreter simulation loop. Exits when c8->running is 0. More... | |
Stuff for simulating and modifying c8_t
s.
#define BORROWS | ( | x, | |
y | |||
) | ((((int) x) - y) < 0) |
#define CARRIES | ( | x, | |
y | |||
) | ((((int) x) + y) > UINT8_MAX) |
#define DEBUG | ( | c | ) | (c->flags & C8_FLAG_DEBUG) |
#define QUIRK_BITWISE | ( | c | ) |
#define QUIRK_DRAW | ( | c | ) |
#define QUIRK_LOADSTORE | ( | c | ) |
#define QUIRK_SHIFT | ( | c | ) |
#define VERBOSE | ( | c | ) | (c->flags & C8_FLAG_VERBOSE) |
c8_t * c8_init | ( | const char * | path, |
int | flags | ||
) |
Initialize and return a c8_t
with the given flags.
This function allocates memory for a new c8_t
with all values set to 0 or their default values, adds the font to memory, inititializes the graphics system, and returns a pointer to the c8_t
.
path | path to ROM file |
flags | flags |
c8_t
. int c8_load_palette_f | ( | c8_t * | c8, |
const char * | path | ||
) |
Load palette from the given path into colors
.
c8 | where to store the color codes |
path | palette file location |
int c8_load_palette_s | ( | c8_t * | c8, |
char * | s | ||
) |
Load palette from the given string into colors
.
c8 | where to store the color codes |
s | string to load |
void c8_load_quirks | ( | c8_t * | c8, |
const char * | s | ||
) |
Load quirk flags from string.
c8 | where to store flags |
s | string to get quirks from |