Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch for binjgb and appling it in build script #54

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading