libc8
CHIP-8 utility library
Loading...
Searching...
No Matches
graphics_ncurses.c File Reference
#include "../common.h"
#include "../graphics.h"
#include "exception.h"
#include <ncurses.h>
#include <string.h>

Functions

int c8_init_graphics (void)
 Initialize graphics system.
 
int c8_sound_play (void)
 Start playing the sound.
 
int c8_sound_stop (void)
 Stop the sound playing.
 
int c8_deinit_graphics (void)
 Deinitialize the graphics library.
 
int c8_render (C8_Display *display, int *colors)
 Render graphics.
 
int c8_tick (int *keys)
 Process keypresses.
 

Detailed Description

Note
NOT EXPORTED

ncurses graphics implementation. When NCURSES is defined, overrides weak graphics utility function definitions in graphics.c.

Function Documentation

◆ c8_deinit_graphics()

int c8_deinit_graphics ( void  )

Deinitialize the graphics library.

Deinitialize graphics system.

◆ c8_init_graphics()

int c8_init_graphics ( void  )

Initialize graphics system.

This function is weak and is overridden by internal/graphics_sdl.c by default. This can also be overridden by the user when compiling without SDL2 support.

This function should return 0 on success and a negative value on failure.

◆ c8_render()

int c8_render ( C8_Display display,
int *  colors 
)

Render graphics.

Render the given display to the ncurses window.

Parameters
displayC8_Display to render
colorscolors to render (UNUSED)
Returns
0 on success, non-zero on failure

◆ c8_sound_play()

int c8_sound_play ( void  )

Start playing the sound.

Stop sound.

Returns
0 if successful, error code otherwise.

◆ c8_sound_stop()

int c8_sound_stop ( void  )

Stop the sound playing.

Play sound.

Returns
0 if successful, error code otherwise.

◆ c8_tick()

int c8_tick ( int *  keys)

Process keypresses.

Grab current keypresses and delay execution to match clockspeed.

If a relevant key is pressed or released (see c8_keyMap in this file), this function will update keys accordingly.

Parameters
keyspointer to int arr of keys
Returns
-2 if quitting, -1 if no key was released, else returns value of key released.