Corrected BG enable's behavior (Fixes visual glitch with Krusty's Funhouse)
This commit is contained in:
parent
42c01a21b2
commit
52ed2ca55e
@ -144,31 +144,29 @@ static uint32_t get_pixel(GB_gameboy_t *gb, uint8_t x, uint8_t y)
|
|||||||
return gb->sprite_palletes_rgb[sprite_palette * 4 + sprite_pixel];
|
return gb->sprite_palletes_rgb[sprite_palette * 4 + sprite_pixel];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bg_enabled) {
|
if (bg_enabled) {
|
||||||
return gb->background_palletes_rgb[0];
|
if (gb->io_registers[GB_IO_LCDC] & 0x10) {
|
||||||
}
|
tile_address = tile * 0x10;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tile_address = (int8_t) tile * 0x10 + 0x1000;
|
||||||
|
}
|
||||||
|
if (attributes & 0x8) {
|
||||||
|
tile_address += 0x2000;
|
||||||
|
}
|
||||||
|
|
||||||
if (gb->io_registers[GB_IO_LCDC] & 0x10) {
|
if (attributes & 0x20) {
|
||||||
tile_address = tile * 0x10;
|
x = ~x;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
tile_address = (int8_t) tile * 0x10 + 0x1000;
|
|
||||||
}
|
|
||||||
if (attributes & 0x8) {
|
|
||||||
tile_address += 0x2000;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (attributes & 0x20) {
|
if (attributes & 0x40) {
|
||||||
x = ~x;
|
y = ~y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (attributes & 0x40) {
|
background_pixel = (((gb->vram[tile_address + (y & 7) * 2 ] >> ((~x)&7)) & 1 ) |
|
||||||
y = ~y;
|
((gb->vram[tile_address + (y & 7) * 2 + 1] >> ((~x)&7)) & 1) << 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
background_pixel = (((gb->vram[tile_address + (y & 7) * 2 ] >> ((~x)&7)) & 1 ) |
|
|
||||||
((gb->vram[tile_address + (y & 7) * 2 + 1] >> ((~x)&7)) & 1) << 1 );
|
|
||||||
|
|
||||||
if (priority && sprite_pixel && !background_pixel) {
|
if (priority && sprite_pixel && !background_pixel) {
|
||||||
if (!gb->cgb_mode) {
|
if (!gb->cgb_mode) {
|
||||||
sprite_pixel = (gb->io_registers[use_obp1? GB_IO_OBP1:GB_IO_OBP0] >> (sprite_pixel << 1)) & 3;
|
sprite_pixel = (gb->io_registers[use_obp1? GB_IO_OBP1:GB_IO_OBP0] >> (sprite_pixel << 1)) & 3;
|
||||||
|
Loading…
Reference in New Issue
Block a user