|
libc8
CHIP-8 utility library
|
Go to the source code of this file.
Data Structures | |
| struct | C8 |
| Represents current state of the CHIP-8 interpreter. More... | |
Macros | |
| #define | C8_CLOCK_SPEED 1000 |
| Maximum instructions to execute per second. | |
| #define | C8_STACK_SIZE 16 |
| Maximum stack size. | |
| #define | C8_MODE_CHIP8 0 |
| CHIP-8 execution mode. SCHIP and XO-CHIP instructions will throw an error. | |
| #define | C8_MODE_SCHIP 1 |
| SCHIP execution mode. | |
| #define | C8_MODE_XOCHIP 2 |
| XO-CHIP execution mode. | |
| #define | C8_FLAG_DEBUG 0x1 |
| Enable debug mode. | |
| #define | C8_FLAG_VERBOSE 0x2 |
| Print all instructions as they are executed. | |
| #define | C8_FLAG_QUIRK_BITWISE 0x4 |
| Enable the 'b' quirk (see main page/README). | |
| #define | C8_FLAG_QUIRK_DRAW 0x8 |
| Enable the 'd' quirk (see main page/README). | |
| #define | C8_FLAG_QUIRK_LOADSTORE 0x10 |
| Enable the 'l' quirk (see main page/README). | |
| #define | C8_FLAG_QUIRK_SHIFT 0x20 |
| Enable the 's' quirk (see main page/README). | |
| #define | C8_FLAG_QUIRK_JUMP 0x40 |
| Enable the 'j' quirk (see main page/README). | |
Functions | |
| void | c8_deinit (C8 *) |
| Deinitialize graphics and free c8. | |
| C8 * | c8_init (const char *, int) |
Initialize and return a C8 with the given flags. | |
| int | c8_load_palette_s (C8 *, char *) |
Load palette from the given string into colors. | |
| int | c8_load_palette_f (C8 *, const char *) |
Load palette from the given path into colors. | |
| void | c8_load_quirks (C8 *, const char *) |
| Load quirk flags from string. | |
| int | c8_load_rom (C8 *, const char *) |
Load a ROM to c8->mem at path addr. | |
| const char * | c8_version (void) |
| Get the version of libc8. | |
| void | c8_simulate (C8 *) |
Main interpreter simulation loop. Exits when c8->running is 0. | |
Stuff for simulating and modifying CHIP8s.
| #define C8_CLOCK_SPEED 1000 |
Maximum instructions to execute per second.
| #define C8_FLAG_DEBUG 0x1 |
Enable debug mode.
| #define C8_FLAG_QUIRK_BITWISE 0x4 |
Enable the 'b' quirk (see main page/README).
| #define C8_FLAG_QUIRK_DRAW 0x8 |
Enable the 'd' quirk (see main page/README).
| #define C8_FLAG_QUIRK_JUMP 0x40 |
Enable the 'j' quirk (see main page/README).
| #define C8_FLAG_QUIRK_LOADSTORE 0x10 |
Enable the 'l' quirk (see main page/README).
| #define C8_FLAG_QUIRK_SHIFT 0x20 |
Enable the 's' quirk (see main page/README).
| #define C8_FLAG_VERBOSE 0x2 |
Print all instructions as they are executed.
| #define C8_MODE_CHIP8 0 |
CHIP-8 execution mode. SCHIP and XO-CHIP instructions will throw an error.
| #define C8_MODE_SCHIP 1 |
SCHIP execution mode.
| #define C8_MODE_XOCHIP 2 |
XO-CHIP execution mode.
| #define C8_STACK_SIZE 16 |
Maximum stack size.
| C8 * c8_init | ( | const char * | path, |
| int | flags | ||
| ) |
Initialize and return a C8 with the given flags.
This function allocates memory for a new C8 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.
| path | path to ROM file |
| flags | flags |
C8. | int c8_load_palette_f | ( | C8 * | 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 * | 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 * | c8, |
| const char * | s | ||
| ) |
Load quirk flags from string.
| c8 | where to store flags |
| s | string to get quirks from |
| int c8_load_rom | ( | C8 * | c8, |
| const char * | addr | ||
| ) |
Load a ROM to c8->mem at path addr.
| c8 | C8 to store the ROM's contents |
| addr | path to the ROM |
| void c8_simulate | ( | C8 * | c8 | ) |
Main interpreter simulation loop. Exits when c8->running is 0.
| c8 | the C8 to simulate |
| const char * c8_version | ( | void | ) |
Get the version of libc8.