misc cleanup
This commit is contained in:
parent
a9fd90ad6a
commit
a39620bc99
4 changed files with 63 additions and 40 deletions
|
|
@ -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_start<FRAME_BUDGET) { // only wait if we're under frame budget
|
||||
ioctl(gfx.fb0_fd, OWLFB_WAITFORVSYNC, &_);
|
||||
if (ioctl(gfx.fb0_fd, OWLFB_WAITFORVSYNC, &_)) LOG_info("OWLFB_WAITFORVSYNC failed %s\n", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -299,7 +322,7 @@ void GFX_sync(void) {
|
|||
if (gfx.vsync!=VSYNC_OFF) {
|
||||
// this limiting condition helps SuperFX chip games
|
||||
if (gfx.vsync==VSYNC_STRICT || frame_start==0 || SDL_GetTicks()-frame_start<FRAME_BUDGET) { // only wait if we're under frame budget
|
||||
ioctl(gfx.fb0_fd, OWLFB_WAITFORVSYNC, &_);
|
||||
if (ioctl(gfx.fb0_fd, OWLFB_WAITFORVSYNC, &_)) LOG_info("OWLFB_WAITFORVSYNC failed %s\n", strerror(errno));
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -122,6 +122,8 @@ static struct Core {
|
|||
unsigned (*get_region)(void);
|
||||
void *(*get_memory_data)(unsigned id);
|
||||
size_t (*get_memory_size)(unsigned id);
|
||||
|
||||
// retro_audio_buffer_status_callback_t audio_buffer_status;
|
||||
} core;
|
||||
|
||||
///////////////////////////////////////
|
||||
|
|
@ -1225,8 +1227,6 @@ static bool set_rumble_state(unsigned port, enum retro_rumble_effect effect, uin
|
|||
VIB_setStrength(strength);
|
||||
}
|
||||
static bool environment_callback(unsigned cmd, void *data) { // copied from picoarch initially
|
||||
// printf("environment_callback: %i\n", cmd); fflush(stdout);
|
||||
|
||||
// LOG_info("environment_callback: %i\n", cmd);
|
||||
|
||||
switch(cmd) {
|
||||
|
|
@ -1342,7 +1342,7 @@ static bool environment_callback(unsigned cmd, void *data) { // copied from pico
|
|||
break;
|
||||
}
|
||||
// RETRO_ENVIRONMENT_GET_LANGUAGE 39
|
||||
case RETRO_ENVIRONMENT_GET_INPUT_BITMASKS: { /* 52 */
|
||||
case RETRO_ENVIRONMENT_GET_INPUT_BITMASKS: { /* 51 */
|
||||
bool *out = (bool *)data;
|
||||
if (out)
|
||||
*out = true;
|
||||
|
|
@ -1393,38 +1393,35 @@ static bool environment_callback(unsigned cmd, void *data) { // copied from pico
|
|||
break;
|
||||
}
|
||||
// TODO: RETRO_ENVIRONMENT_GET_MESSAGE_INTERFACE_VERSION 59
|
||||
// TODO: I'm not sure what uses this...not gambatte, not snes9x, not pcsx
|
||||
case RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK: { /* 62 */
|
||||
// puts("RETRO_ENVIRONMENT_SET_AUDIO_BUFFER_STATUS_CALLBACK");
|
||||
// const struct retro_audio_buffer_status_callback *cb =
|
||||
// (const struct retro_audio_buffer_status_callback *)data;
|
||||
// if (cb) {
|
||||
// puts("has audo_buffer_status callback");
|
||||
// core.audio_buffer_status = cb->callback;
|
||||
// } 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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue