Make the ICD APIs pixel based

This commit is contained in:
Lior Halphon 2019-07-16 20:44:27 +03:00
parent 346e499602
commit ce9ce07817
3 changed files with 24 additions and 11 deletions

View File

@ -390,7 +390,9 @@ static void render_pixel_if_possible(GB_gameboy_t *gb)
}
}
else if (gb->model & GB_MODEL_NO_SFC_BIT) {
gb->icd_row[gb->position_in_line] = pixel;
if (gb->icd_pixel_callback) {
gb->icd_pixel_callback(gb, pixel);
}
}
else {
gb->screen[gb->position_in_line + gb->current_line * WIDTH] = gb->background_palettes_rgb[fifo_item->palette * 4 + pixel];
@ -409,7 +411,9 @@ static void render_pixel_if_possible(GB_gameboy_t *gb)
}
}
else if (gb->model & GB_MODEL_NO_SFC_BIT) {
gb->icd_row[gb->position_in_line] = pixel;
if (gb->icd_pixel_callback) {
gb->icd_pixel_callback(gb, pixel);
}
}
else {
gb->screen[gb->position_in_line + gb->current_line * WIDTH] = gb->sprite_palettes_rgb[oam_fifo_item->palette * 4 + pixel];
@ -897,8 +901,8 @@ void GB_display_run(GB_gameboy_t *gb, uint8_t cycles)
gb->mode_for_interrupt = 2;
/* TODO: Can this timing even be verified? */
if (gb->icd_row_callback) {
gb->icd_row_callback(gb, gb->icd_row);
if (gb->icd_hreset_callback) {
gb->icd_hreset_callback(gb);
}
}

View File

@ -925,11 +925,17 @@ void GB_set_joyp_write_callback(GB_gameboy_t *gb, GB_joyp_write_callback_t callb
gb->joyp_write_callback = callback;
}
void GB_set_icd_row_callback(GB_gameboy_t *gb, GB_icd_row_callback_t callback)
void GB_set_icd_pixel_callback(GB_gameboy_t *gb, GB_icd_pixel_callback_t callback)
{
gb->icd_row_callback = callback;
gb->icd_pixel_callback = callback;
}
void GB_set_icd_hreset_callback(GB_gameboy_t *gb, GB_icd_hreset_callback_t callback)
{
gb->icd_hreset_callback = callback;
}
void GB_set_icd_vreset_callback(GB_gameboy_t *gb, GB_icd_vreset_callback_t callback)
{
gb->icd_vreset_callback = callback;

View File

@ -243,7 +243,8 @@ typedef void (*GB_serial_transfer_bit_start_callback_t)(GB_gameboy_t *gb, bool b
typedef bool (*GB_serial_transfer_bit_end_callback_t)(GB_gameboy_t *gb);
typedef void (*GB_update_input_hint_callback_t)(GB_gameboy_t *gb);
typedef void (*GB_joyp_write_callback_t)(GB_gameboy_t *gb, uint8_t value);
typedef void (*GB_icd_row_callback_t)(GB_gameboy_t *gb, uint8_t *row);
typedef void (*GB_icd_pixel_callback_t)(GB_gameboy_t *gb, uint8_t row);
typedef void (*GB_icd_hreset_callback_t)(GB_gameboy_t *gb);
typedef void (*GB_icd_vreset_callback_t)(GB_gameboy_t *gb);
typedef struct {
@ -422,7 +423,6 @@ struct GB_gameboy_internal_s {
uint16_t serial_length;
uint8_t double_speed_alignment;
uint8_t serial_count;
uint8_t icd_row[160];
);
/* APU */
@ -451,7 +451,8 @@ struct GB_gameboy_internal_s {
/* The LCDC will skip the first frame it renders after turning it on.
On the CGB, a frame is not skipped if the previous frame was skipped as well.
See https://www.reddit.com/r/EmuDev/comments/6exyxu/ */
/* TODO: Drop this and properly emulate the dropped vreset signal*/
/* TODO: Drop this and properly emulate the dropped vreset signal*/
enum {
GB_FRAMESKIP_LCD_TURNED_ON, // On a DMG, the LCD renders a blank screen during this state,
// on a CGB, the previous frame is repeated (which might be
@ -538,7 +539,8 @@ struct GB_gameboy_internal_s {
GB_serial_transfer_bit_end_callback_t serial_transfer_bit_end_callback;
GB_update_input_hint_callback_t update_input_hint_callback;
GB_joyp_write_callback_t joyp_write_callback;
GB_icd_row_callback_t icd_row_callback;
GB_icd_pixel_callback_t icd_pixel_callback;
GB_icd_vreset_callback_t icd_hreset_callback;
GB_icd_vreset_callback_t icd_vreset_callback;
/* IR */
@ -701,7 +703,8 @@ void GB_disconnect_serial(GB_gameboy_t *gb);
/* For integration with SFC/SNES emulators */
void GB_set_joyp_write_callback(GB_gameboy_t *gb, GB_joyp_write_callback_t callback);
void GB_set_icd_row_callback(GB_gameboy_t *gb, GB_icd_row_callback_t callback);
void GB_set_icd_pixel_callback(GB_gameboy_t *gb, GB_icd_pixel_callback_t callback);
void GB_set_icd_hreset_callback(GB_gameboy_t *gb, GB_icd_hreset_callback_t callback);
void GB_set_icd_vreset_callback(GB_gameboy_t *gb, GB_icd_vreset_callback_t callback);
#ifdef GB_INTERNAL