Skip to content

gb: add gb_init_ex() function for new features #144

Description

@deltabeard

An gb_init_ex() function will be created that takes in a struct as a parameter. Using a struct will allow for new fields to be added in new versions of Peanut-GB without the frontends requiring any update provided that all fields are initialised to 0. Hence, the value 0 is considered as an 'unset' value and Peanut-GB will either not enable the corresponding feature or will use default behaviour.

struct gb_s gb;
struct pgb_init i = { .ver = PGB_INIT_VERSION, .console_type = PGB_CONSOLE_DMG };
int ret = gb_init_ex(&gb, &i);

Where PGB_INIT_VERSION is initially 1, and will allow for future instances where the behaviour of existing fields might change.

The use of gb_init_ex will allow for new features to be added to Peanut-GB without API change, including Game Boy Color support.

This struct will initially include:

struct {
int ver;
pgb_console_type_e console_type; /* PGB_CONSOLE_DMG, PGB_CONSOLE_MGB. */
pgb_cgb_s cgb; /* Additional RAM required for CGB emulation. */
lcd_draw_line_fn lcd_draw_line;
pgb_bootrom_read_fn bootrom_read_fn; /* NULL or function that reads byte from bootrom that corresponds to console_type. */
/* Probably more to be added. */
} pgb_init;

Metadata

Metadata

Assignees

No one assigned

    Labels

    diff: complexA difficult issue; may require significant planning.enhancementNew feature or requestfeat: crucialFor significant tasks; expected to be fixed before next release.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions