binji / binjgb

Gameboy emulator implemented in C, that also runs in the browser
https://binji.github.io/binjgb/
MIT License
534 stars 61 forks source link

Segmentation fault when trying to run on OSX #16

Closed aconbere closed 5 years ago

aconbere commented 5 years ago
[anders/fix_compile_errors_on_osx] % ./bin/binjgb ~/Projects/blarggs-tests/cpu_instrs/source/test.gb
title: ""
cgb flag: CGB_FLAG_SUPPORTED
sgb flag: SGB_FLAG_NONE
cart type: CART_TYPE_MBC1
rom size: ROM_SIZE_32K
ext ram size: EXT_RAM_SIZE_NONE
header checksum: 0x66 [OK]
GL_VERTEX_SHADER ERROR: ERROR: 0:1: '' :  version '130' is not supported
ERROR: 0:2: '' :  #version required and missing.
ERROR: 0:2: 'attribute' : syntax error: syntax error

zsh: segmentation fault  ./bin/binjgb ~/Projects/blarggs-tests/cpu_instrs/source/test.gb

It appears to originate in the hard coding of the GL_VERTEX_SHADER version: https://github.com/binji/binjgb/blob/master/src/host-ui-imgui.cc#L116

However bumping that to version 150 which I believe is the current version available on my machine moves the error to an attribute syntax error:

GL_VERTEX_SHADER ERROR: ERROR: 0:2: 'attribute' : syntax error: syntax error
binji commented 5 years ago

Does #17 fix this for you?

aconbere commented 5 years ago

Ha, I was just testing this morning. I think there's one more bug where texture2D is deprecated (now called just texture). But with that change it now runs.

Window is a bit oddly sized, but maybe that's expected?

screen shot 2018-11-14 at 9 02 40 am
aconbere commented 5 years ago

3a1c729772b48ca44aeaff17090c7ffe3509dfb4 fixes the issue :)

binji commented 5 years ago

Hm, weird. I wonder if it has to do with using SDLWINDOW_HIGHDPI in the window creation call.

binji commented 5 years ago

Yep, seems to. I tested on my Mac laptop, this change should fix it!

aconbere commented 5 years ago

@binji Works! And now in debug mode I actually get all the debug tools :)

The funny thing about all of this is I ended up here following a lead in a reddit comment (from you) saying that your emulator had good instruction logging. I'm trying to get a personal emulator over the finish line where there's a bug in some instruction and I just can't quite figure out which one. Whatever it is prevents a successful from of blargg's test suite and so I'm a bit stumped.

What I've got now is a way to run my emulator against a file that tracks known good register states and will compare its incremental state to those and log when it differs so that I can dig into exactly where it goes off the rails.

Anyway, appreciate how quickly you've been responding here, and I've nearly got my state file built from your emulator :)

binji commented 5 years ago

Awesome, glad I can help. As you probably noticed, I don't really work on this much anymore. But it's always nice to have people show interest :-)

Gonna close this issue, since it seems MacOS is working well now.