Correct emulation of color masks
This commit is contained in:
parent
389d8ae045
commit
4b93f89763
45
Core/sgb.c
45
Core/sgb.c
@ -23,7 +23,7 @@ enum {
|
|||||||
typedef enum {
|
typedef enum {
|
||||||
MASK_DISABLED,
|
MASK_DISABLED,
|
||||||
MASK_FREEZE,
|
MASK_FREEZE,
|
||||||
MASK_COLOR_3,
|
MASK_BLACK,
|
||||||
MASK_COLOR_0,
|
MASK_COLOR_0,
|
||||||
} mask_mode_t;
|
} mask_mode_t;
|
||||||
|
|
||||||
@ -404,24 +404,10 @@ void GB_sgb_render(GB_gameboy_t *gb)
|
|||||||
|
|
||||||
if (!gb->screen || !gb->rgb_encode_callback) return;
|
if (!gb->screen || !gb->rgb_encode_callback) return;
|
||||||
|
|
||||||
switch ((mask_mode_t) gb->sgb->mask_mode) {
|
if (gb->sgb->mask_mode != MASK_FREEZE) {
|
||||||
case MASK_DISABLED:
|
|
||||||
memcpy(gb->sgb->effective_screen_buffer,
|
memcpy(gb->sgb->effective_screen_buffer,
|
||||||
gb->sgb->screen_buffer,
|
gb->sgb->screen_buffer,
|
||||||
sizeof(gb->sgb->effective_screen_buffer));
|
sizeof(gb->sgb->effective_screen_buffer));
|
||||||
break;
|
|
||||||
case MASK_FREEZE:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MASK_COLOR_3:
|
|
||||||
memset(gb->sgb->effective_screen_buffer,
|
|
||||||
3,
|
|
||||||
sizeof(gb->sgb->effective_screen_buffer));
|
|
||||||
break;
|
|
||||||
case MASK_COLOR_0:
|
|
||||||
memset(gb->sgb->effective_screen_buffer,
|
|
||||||
0,
|
|
||||||
sizeof(gb->sgb->effective_screen_buffer));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gb->sgb->vram_transfer_countdown) {
|
if (gb->sgb->vram_transfer_countdown) {
|
||||||
@ -496,6 +482,9 @@ void GB_sgb_render(GB_gameboy_t *gb)
|
|||||||
else {
|
else {
|
||||||
uint32_t *output = &gb->screen[48 + 40 * 256];
|
uint32_t *output = &gb->screen[48 + 40 * 256];
|
||||||
uint8_t *input = gb->sgb->effective_screen_buffer;
|
uint8_t *input = gb->sgb->effective_screen_buffer;
|
||||||
|
switch ((mask_mode_t) gb->sgb->mask_mode) {
|
||||||
|
case MASK_DISABLED:
|
||||||
|
case MASK_FREEZE: {
|
||||||
for (unsigned y = 0; y < 144; y++) {
|
for (unsigned y = 0; y < 144; y++) {
|
||||||
for (unsigned x = 0; x < 160; x++) {
|
for (unsigned x = 0; x < 160; x++) {
|
||||||
uint8_t palette = gb->sgb->attribute_map[x / 8 + y / 8 * 20] & 3;
|
uint8_t palette = gb->sgb->attribute_map[x / 8 + y / 8 * 20] & 3;
|
||||||
@ -503,6 +492,30 @@ void GB_sgb_render(GB_gameboy_t *gb)
|
|||||||
}
|
}
|
||||||
output += 256 - 160;
|
output += 256 - 160;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MASK_BLACK:
|
||||||
|
{
|
||||||
|
uint32_t black = convert_rgb15(gb, 0);
|
||||||
|
for (unsigned y = 0; y < 144; y++) {
|
||||||
|
for (unsigned x = 0; x < 160; x++) {
|
||||||
|
*(output++) = black;
|
||||||
|
}
|
||||||
|
output += 256 - 160;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MASK_COLOR_0:
|
||||||
|
{
|
||||||
|
for (unsigned y = 0; y < 144; y++) {
|
||||||
|
for (unsigned x = 0; x < 160; x++) {
|
||||||
|
*(output++) = colors[0];
|
||||||
|
}
|
||||||
|
output += 256 - 160;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t border_colors[16 * 4];
|
uint32_t border_colors[16 * 4];
|
||||||
|
Loading…
Reference in New Issue
Block a user