libc8
CHIP-8 utility library
|
#include <stdint.h>
Go to the source code of this file.
Data Structures | |
struct | c8_display_t |
Macros | |
#define | C8_LOW_DISPLAY_WIDTH 64 |
#define | C8_LOW_DISPLAY_HEIGHT 32 |
#define | C8_HIGH_DISPLAY_WIDTH 128 |
#define | C8_HIGH_DISPLAY_HEIGHT 64 |
#define | C8_DEFAULT_WINDOW_WIDTH 800 |
#define | C8_DEFAULT_WINDOW_HEIGHT 400 |
#define | C8_WINDOW_SCALE_X (C8_DEFAULT_WINDOW_WIDTH / C8_LOW_DISPLAY_WIDTH) |
#define | C8_WINDOW_SCALE_Y (C8_DEFAULT_WINDOW_HEIGHT / C8_LOW_DISPLAY_HEIGHT) |
#define | C8_DISPLAYMODE_LOW 0 |
#define | C8_DISPLAYMODE_HIGH 1 |
Functions | |
uint8_t * | c8_get_pixel (c8_display_t *, int, int) |
Get the value of (x,y) from display More... | |
void | c8_beep (void) |
void | c8_deinit_graphics (void) |
Deinitialize the graphics library. More... | |
uint8_t | c8_init_graphics (void) |
Initialize the graphics library. More... | |
void | c8_render (c8_display_t *, int *) |
int | c8_tick (int *, int) |
Process keypresses and delay based on clockspeed. More... | |
Function declarations for graphics display are here.
Only get_pixel
is strongly defined in graphics.c. Declarations are library agnostic so a different graphics backend can be used.
#define C8_DEFAULT_WINDOW_HEIGHT 400 |
#define C8_DEFAULT_WINDOW_WIDTH 800 |
#define C8_DISPLAYMODE_HIGH 1 |
#define C8_DISPLAYMODE_LOW 0 |
#define C8_HIGH_DISPLAY_HEIGHT 64 |
#define C8_HIGH_DISPLAY_WIDTH 128 |
#define C8_LOW_DISPLAY_HEIGHT 32 |
#define C8_LOW_DISPLAY_WIDTH 64 |
#define C8_WINDOW_SCALE_X (C8_DEFAULT_WINDOW_WIDTH / C8_LOW_DISPLAY_WIDTH) |
#define C8_WINDOW_SCALE_Y (C8_DEFAULT_WINDOW_HEIGHT / C8_LOW_DISPLAY_HEIGHT) |
void c8_beep | ( | void | ) |
void c8_deinit_graphics | ( | void | ) |
Deinitialize the graphics library.
uint8_t * c8_get_pixel | ( | c8_display_t * | display, |
int | x, | ||
int | y | ||
) |
Get the value of (x,y) from display
display | display_t to get pixel from |
x | the x value |
y | the y value |
display
uint8_t c8_init_graphics | ( | void | ) |
Initialize the graphics library.
void c8_render | ( | c8_display_t * | display, |
int * | colors | ||
) |
Render the given display to the SDL2 window.
display | display_t to render |
colors | colors to render |
int c8_tick | ( | int * | key, |
int | clockSpeed | ||
) |
Process keypresses and delay based on clockspeed.
If a relevant key is pressed or released (see keyMap
in this file), this function will update key
accordingly.
key | pointer to int arr of keys |
clockSpeed | instructions per second |