deltabeard / Peanut-GB

A Game Boy (DMG) emulator single header library written in C99. Performance is prioritised over accuracy.
https://projects.deltabeard.com/peanutgb/
283 stars 40 forks source link

core: add selectable, internal peripheral support #18

Open deltabeard opened 5 years ago

deltabeard commented 5 years ago

Implement peripherals that may be connected to the Game Boy serial port. Then allow the front-end to select which peripheral is connected.

Example below:


enum serial_peripherals {
SERIAL_NOT_CONNECTED, /* Emulate no serial device connected (Default). */
SERIAL_PRINTER, /* Emulate printer connected. */
SERIAL_EXTERNAL /* Send serial output to front-end (eg. for multiplayer). */
};

/* Must be set before switching to printer peripheral. */
int gb_serial_printer_init((void printer_output)(gb_t *gb, uint8_t *buffer));

/* To set the connected peripheral. Returns error if peripheral not initialised. */
int gb_serial_set_peripheral(enum serial_peripherals);