-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
binjgb.patch
24 lines (24 loc) · 1008 Bytes
/
binjgb.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
diff --git a/src/emulator.c b/src/emulator.c
index 0329ccf..a91ef67 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -5209,13 +5209,15 @@ void emulator_render_vram(Emulator* e, u32* buffer) {
void emulator_render_background(Emulator* e, u32* buffer, int type) {
memset(buffer, 0, sizeof(u32) * 256 * 256);
int bank = 0;
- int tile_map = (type & 1) ? 0x400 : 0;
+ int tile_map = 0x1800 + ((type & 1) ? 0x400 : 0);
for (int ty = 0; ty < 32; ty++) {
for (int tx = 0; tx < 32; tx++) {
+ u8 tile = VRAM.data[tile_map + tx + ty * 32];
+ int offset = 0;
+ if(tile < 128)
+ offset = (LCDC.bg_tile_data_select == TILE_DATA_8000_8FFF) ? 0 : 0x1000;
for (int row = 0; row < 8; row++) {
- int tile = VRAM.data[0x1800 + tile_map + tx + ty * 32];
- // TODO: LCDC bit 4
- int n = tile * 16 + row * 2;
+ int n = offset + tile * 16 + row * 2;
u8 a = VRAM.data[n];
u8 b = VRAM.data[n + 1];
for (int x = 0; x < 8; x++) {