diff --git a/git/minui-menu-sgb.png b/git/minui-menu-sgb.png new file mode 100644 index 0000000..7c2d741 Binary files /dev/null and b/git/minui-menu-sgb.png differ diff --git a/src/common/api.c b/src/common/api.c index a288ae9..5b52ea6 100644 --- a/src/common/api.c +++ b/src/common/api.c @@ -168,11 +168,23 @@ SDL_Surface* GFX_init(int mode) { gfx.vinfo.yres_virtual = VIRTUAL_HEIGHT; gfx.vinfo.xoffset = 0; gfx.vinfo.yoffset = 0; - ioctl(gfx.fb0_fd, FBIOPUT_VSCREENINFO, &gfx.vinfo); + if (ioctl(gfx.fb0_fd, FBIOPUT_VSCREENINFO, &gfx.vinfo)) LOG_info("FBIOPUT_VSCREENINFO failed %s\n", strerror(errno)); + + // printf("bits_per_pixel: %i\n", gfx.vinfo.bits_per_pixel); + // printf("xres: %i\n", gfx.vinfo.xres); + // printf("yres: %i\n", gfx.vinfo.yres); + // printf("xres_virtual: %i\n", gfx.vinfo.xres_virtual); + // printf("yres_virtual: %i\n", gfx.vinfo.yres_virtual); + // printf("xoffset: %i\n", gfx.vinfo.xoffset); + // printf("yoffset: %i\n", gfx.vinfo.yoffset); + // printf("activate: %i\n", gfx.vinfo.activate); + // printf("vmode: %i\n", gfx.vinfo.vmode); + // printf("sync: %i\n", gfx.vinfo.sync); + // fflush(stdout); struct owlfb_sync_info sinfo; sinfo.enabled = 1; - ioctl(gfx.fb0_fd, OWLFB_VSYNC_EVENT_EN, &sinfo); + if (ioctl(gfx.fb0_fd, OWLFB_VSYNC_EVENT_EN, &sinfo)) LOG_info("OWLFB_VSYNC_EVENT_EN failed %s\n", strerror(errno)); gfx.page = 1; // start on the backbuffer gfx.fb0_buffer = mmap(0, VIRTUAL_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, gfx.fb0_fd, 0); @@ -229,6 +241,17 @@ void GFX_quit(void) { GFX_clearAll(); munmap(gfx.fb0_buffer, VIRTUAL_SIZE); + + // restore for other binaries + gfx.vinfo.bits_per_pixel = FIXED_DEPTH; + gfx.vinfo.xres = FIXED_WIDTH; + gfx.vinfo.yres = FIXED_HEIGHT; + gfx.vinfo.xres_virtual = FIXED_WIDTH; + gfx.vinfo.yres_virtual = FIXED_HEIGHT; + gfx.vinfo.xoffset = 0; + gfx.vinfo.yoffset = 0; + if (ioctl(gfx.fb0_fd, FBIOPUT_VSCREENINFO, &gfx.vinfo)) LOG_info("FBIOPUT_VSCREENINFO failed %s\n", strerror(errno)); + close(gfx.fb0_fd); SDL_Quit(); } @@ -279,13 +302,13 @@ SDL_Surface* GFX_resize(int w, int h, int pitch) { void GFX_flip(SDL_Surface* screen) { // point framebuffer at the first line of the backbuffer gfx.vinfo.yoffset = gfx.page * PAGE_HEIGHT; - ioctl(gfx.fb0_fd, gfx.resized ? FBIOPUT_VSCREENINFO : FBIOPAN_DISPLAY, &gfx.vinfo); + if (ioctl(gfx.fb0_fd, gfx.resized ? FBIOPUT_VSCREENINFO : FBIOPAN_DISPLAY, &gfx.vinfo)) LOG_info("FBIOPUT_VSCREENINFO failed %s\n", strerror(errno)); gfx.resized = 0; if (gfx.vsync!=VSYNC_OFF) { // this limiting condition helps SuperFX chip games if (gfx.vsync==VSYNC_STRICT || frame_start==0 || SDL_GetTicks()-frame_startcallback; - // } else { - // puts("missing audo_buffer_status callback"); - // core.audio_buffer_status = NULL; - // } - // fflush(stdout); - break; - } - // TODO: not used by gambatte - case RETRO_ENVIRONMENT_SET_MINIMUM_AUDIO_LATENCY: { /* 63 */ - // TODO: unused? - // puts("RETRO_ENVIRONMENT_SET_MINIMUM_AUDIO_LATENCY"); - // - // const unsigned *latency_ms = (const unsigned *)data; - // if (latency_ms) { - // unsigned frames = *latency_ms * core.fps / 1000; - // if (frames < 30) - // audio_buffer_size_override = frames; - // printf("audio_buffer_size_override = %i (unused?)\n", frames); - // else - // PA_WARN("Audio buffer change out of range (%d), ignored\n", frames); - // } - break; - } - + // TODO: used by mgba, (but only during frameskip?) + // case RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK: { /* 62 */ + // LOG_info("RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK\n"); + // const struct retro_audio_buffer_status_callback *cb = (const struct retro_audio_buffer_status_callback *)data; + // if (cb) { + // LOG_info("has audo_buffer_status callback\n"); + // core.audio_buffer_status = cb->callback; + // } else { + // LOG_info("no audo_buffer_status callback\n"); + // core.audio_buffer_status = NULL; + // } + // break; + // } + // TODO: used by mgba, (but only during frameskip?) + // case RETRO_ENVIRONMENT_SET_MINIMUM_AUDIO_LATENCY: { /* 63 */ + // LOG_info("RETRO_ENVIRONMENT_SET_MINIMUM_AUDIO_LATENCY\n"); + // + // const unsigned *latency_ms = (const unsigned *)data; + // if (latency_ms) { + // unsigned frames = *latency_ms * core.fps / 1000; + // if (frames < 30) + // // audio_buffer_size_override = frames; + // LOG_info("audio_buffer_size_override = %i (unused?)\n", frames); + // else + // LOG_info("Audio buffer change out of range (%d), ignored\n", frames); + // } + // break; + // } + // TODO: RETRO_ENVIRONMENT_SET_FASTFORWARDING_OVERRIDE 64 case RETRO_ENVIRONMENT_SET_CONTENT_INFO_OVERRIDE: { /* 65 */ // const struct retro_system_content_info_override* info = (const struct retro_system_content_info_override* )data; @@ -3917,6 +3914,7 @@ int main(int argc , char* argv[]) { while (!quit) { GFX_startFrame(); + // if (core.audio_buffer_status) core.audio_buffer_status(true, 100, false); core.run(); limitFF(); diff --git a/src/minui/makefile b/src/minui/makefile index 3f48c14..b246416 100644 --- a/src/minui/makefile +++ b/src/minui/makefile @@ -8,6 +8,8 @@ CC = $(CROSS_COMPILE)gcc CFLAGS = -marm -mtune=cortex-a9 -mfpu=neon-fp16 -mfloat-abi=hard -march=armv7-a -fomit-frame-pointer CFLAGS += -I. -I../common -DPLATFORM=\"$(UNION_PLATFORM)\" LDFLAGS = -ldl -lSDL -lSDL_image -lSDL_ttf -lmsettings -lpthread +# CFLAGS += -fsanitize=address -fno-common +# LDFLAGS += -lasan all: $(CC) main.c ../common/utils.c ../common/api.c -o $(TARGET) $(CFLAGS) $(LDFLAGS)