Skip to content

Commit

Permalink
patch for binjgb and appling it in build script (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
SelvinPL authored Sep 20, 2024
1 parent 49e1e0c commit e85af9e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
24 changes: 24 additions & 0 deletions binjgb.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,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++) {
3 changes: 3 additions & 0 deletions build-binjgb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ if [[ "$(which emsdk)" == "" ]]; then
fi

cd binjgb

patch -p1 < ../binjgb.patch

! mkdir out
cd out
cmake -E env LDFLAGS='-s EXPORT_ES6=1' \
Expand Down

0 comments on commit e85af9e

Please sign in to comment.