mirror of
https://github.com/digarok/gsplus.git
synced 2024-11-28 04:49:18 +00:00
add scaling options and fix speedups
This commit is contained in:
parent
6ebebfa2e8
commit
7df808cf4a
@ -54,14 +54,18 @@ extern int g_fullscreen;
|
||||
extern int g_highdpi;
|
||||
extern int g_borderless;
|
||||
extern int g_resizeable;
|
||||
extern int g_noaspect;
|
||||
extern int g_novsync;
|
||||
extern int g_nohwaccel;
|
||||
extern int g_fullscreen_desktop;
|
||||
extern int g_screen_redraw_skip_amt;
|
||||
extern int g_use_dhr140;
|
||||
extern int g_use_bw_hires;
|
||||
extern int g_scanline_simulator;
|
||||
extern int g_startx;
|
||||
extern int g_starty;
|
||||
extern int g_startw;
|
||||
extern int g_starth;
|
||||
extern int g_joystick_number;
|
||||
extern int g_joystick_x_axis;
|
||||
extern int g_joystick_y_axis;
|
||||
@ -208,14 +212,18 @@ Cfg_menu g_cfg_uiless_menu[] = {
|
||||
{ "", KNMP(g_highdpi), CFGTYPE_INT },
|
||||
{ "", KNMP(g_borderless), CFGTYPE_INT },
|
||||
{ "", KNMP(g_resizeable), CFGTYPE_INT },
|
||||
{ "", KNMP(g_noaspect), CFGTYPE_INT },
|
||||
{ "", KNMP(g_novsync), CFGTYPE_INT },
|
||||
{ "", KNMP(g_nohwaccel), CFGTYPE_INT },
|
||||
{ "", KNMP(g_fullscreen_desktop), CFGTYPE_INT},
|
||||
{ "", KNMP(g_screen_redraw_skip_amt), CFGTYPE_INT },
|
||||
{ "", KNMP(g_use_dhr140), CFGTYPE_INT },
|
||||
{ "", KNMP(g_use_bw_hires), CFGTYPE_INT },
|
||||
{ "", KNMP(g_scanline_simulator), CFGTYPE_INT },
|
||||
{ "", KNMP(g_startx), CFGTYPE_INT },
|
||||
{ "", KNMP(g_starty), CFGTYPE_INT },
|
||||
{ "", KNMP(g_startw), CFGTYPE_INT },
|
||||
{ "", KNMP(g_starth), CFGTYPE_INT },
|
||||
{ "", KNMP(g_joystick_number), CFGTYPE_INT },
|
||||
{ "", KNMP(g_joystick_x_axis), CFGTYPE_INT },
|
||||
{ "", KNMP(g_joystick_y_axis), CFGTYPE_INT },
|
||||
|
@ -33,16 +33,22 @@ extern int g_use_bw_hires; // defined in video.c
|
||||
// Set starting X/Y positions
|
||||
extern int g_startx; // defined in video.c
|
||||
extern int g_starty; // defined in video.c
|
||||
extern int g_startw; // defined in video.c
|
||||
extern int g_starth; // defined in video.c
|
||||
// Use High DPI (Retina) display - SDL2
|
||||
extern int g_highdpi; // defined in video.c
|
||||
// Create borderless window - SDL2
|
||||
extern int g_borderless; // defined in video.c
|
||||
// Allow window resizing, dragging to scale - SDL2
|
||||
extern int g_resizeable; // defined in video.c
|
||||
// Allow the window scaling to be free from aspect contraints - SDL2
|
||||
extern int g_noaspect;
|
||||
// Don't explicitly set vsync present flag on renderer - SDL2
|
||||
extern int g_novsync; // defined in video.c
|
||||
// Don't explicitly set HW accelerator flag on renderer - SDL2
|
||||
extern int g_nohwaccel; // defined in video.c
|
||||
// Use SDL_WINDOW_FULLSCREEN_DESKTOP for fullscreen instead of switching modes
|
||||
extern int g_fullscreen_desktop;
|
||||
// Enable Dagen's scanline simulator (SDL2)
|
||||
extern int g_scanline_simulator; // defined in sim65816.c
|
||||
// Ethernet (interface?)
|
||||
@ -137,12 +143,18 @@ int parse_cli_options(int argc, char **argv) {
|
||||
} else if(!strcmp("-resizeable", argv[i])) {
|
||||
glogf("%s Window will be resizeable", parse_log_prefix);
|
||||
g_resizeable = 1;
|
||||
} else if(!strcmp("-noaspect", argv[i])) {
|
||||
glogf("%s Window will scale freely, without locking the aspect ratio", parse_log_prefix);
|
||||
g_noaspect = 1;
|
||||
} else if(!strcmp("-novsync", argv[i])) {
|
||||
glogf("%s Renderer skipping vsync flag", parse_log_prefix);
|
||||
g_novsync = 1;
|
||||
} else if(!strcmp("-nohwaccel", argv[i])) {
|
||||
glogf("%s Renderer skipping HW accel flag", parse_log_prefix);
|
||||
g_nohwaccel = 1;
|
||||
} else if(!strcmp("-fulldesk", argv[i])) {
|
||||
glogf("%s Using desktop fullscreen mode", parse_log_prefix);
|
||||
g_fullscreen_desktop = 1;
|
||||
} else if(!strcmp("-noignbadacc", argv[i])) {
|
||||
glogf("%s Not ignoring bad memory accesses", parse_log_prefix);
|
||||
g_ignore_bad_acc = 0;
|
||||
@ -214,72 +226,72 @@ int parse_cli_options(int argc, char **argv) {
|
||||
glogf("%s Setting joystick number %d", parse_log_prefix, tmp1);
|
||||
g_joystick_number = tmp1;
|
||||
i++;
|
||||
} else if(!strcmp("-joy_x", argv[i])) {
|
||||
} else if(!strcmp("-joy-x", argv[i])) {
|
||||
if((i+1) >= argc) {
|
||||
glogf("%s Error, option '-joy_x' missing argument", parse_log_prefix);
|
||||
glogf("%s Error, option '-joy-x' missing argument", parse_log_prefix);
|
||||
exit(1);
|
||||
}
|
||||
tmp1 = strtol(argv[i+1], 0, 0); // no bounds check, not sure what ids we get
|
||||
glogf("%s Setting joystick X axis %d", parse_log_prefix, tmp1);
|
||||
g_joystick_x_axis = tmp1;
|
||||
i++;
|
||||
} else if(!strcmp("-joy_y", argv[i])) {
|
||||
} else if(!strcmp("-joy-y", argv[i])) {
|
||||
if((i+1) >= argc) {
|
||||
glogf("%s Error, option '-joy_y' missing argument", parse_log_prefix);
|
||||
glogf("%s Error, option '-joy-y' missing argument", parse_log_prefix);
|
||||
exit(1);
|
||||
}
|
||||
tmp1 = strtol(argv[i+1], 0, 0); // no bounds check, not sure what ids we get
|
||||
glogf("%s Setting joystick Y axis %d", parse_log_prefix, tmp1);
|
||||
g_joystick_y_axis = tmp1;
|
||||
i++;
|
||||
} else if(!strcmp("-joy_x2", argv[i])) {
|
||||
} else if(!strcmp("-joy-x2", argv[i])) {
|
||||
if((i+1) >= argc) {
|
||||
glogf("%s Error, option '-joy_x2' missing argument", parse_log_prefix);
|
||||
glogf("%s Error, option '-joy-x2' missing argument", parse_log_prefix);
|
||||
exit(1);
|
||||
}
|
||||
tmp1 = strtol(argv[i+1], 0, 0); // no bounds check, not sure what ids we get
|
||||
glogf("%s Setting joystick X2 axis %d", parse_log_prefix, tmp1);
|
||||
g_joystick_x2_axis = tmp1;
|
||||
i++;
|
||||
} else if(!strcmp("-joy_y2", argv[i])) {
|
||||
} else if(!strcmp("-joy-y2", argv[i])) {
|
||||
if((i+1) >= argc) {
|
||||
glogf("%s Error, option '-joy_y2' missing argument", parse_log_prefix);
|
||||
glogf("%s Error, option '-joy-y2' missing argument", parse_log_prefix);
|
||||
exit(1);
|
||||
}
|
||||
tmp1 = strtol(argv[i+1], 0, 0); // no bounds check, not sure what ids we get
|
||||
glogf("%s Setting joystick Y2 axis %d", parse_log_prefix, tmp1);
|
||||
g_joystick_y2_axis = tmp1;
|
||||
i++;
|
||||
} else if(!strcmp("-joy_b0", argv[i])) {
|
||||
} else if(!strcmp("-joy-b0", argv[i])) {
|
||||
if((i+1) >= argc) {
|
||||
glogf("%s Error, option '-joy_b0' missing argument", parse_log_prefix);
|
||||
glogf("%s Error, option '-joy-b0' missing argument", parse_log_prefix);
|
||||
exit(1);
|
||||
}
|
||||
tmp1 = strtol(argv[i+1], 0, 0); // no bounds check, not sure what ids we get
|
||||
glogf("%s Setting joystick Button 0 to Gamepad %d", parse_log_prefix, tmp1);
|
||||
g_joystick_button_0 = tmp1;
|
||||
i++;
|
||||
} else if(!strcmp("-joy_b1", argv[i])) {
|
||||
} else if(!strcmp("-joy-b1", argv[i])) {
|
||||
if((i+1) >= argc) {
|
||||
glogf("%s Error, option '-joy_b1' missing argument", parse_log_prefix);
|
||||
glogf("%s Error, option '-joy-b1' missing argument", parse_log_prefix);
|
||||
exit(1);
|
||||
}
|
||||
tmp1 = strtol(argv[i+1], 0, 0); // no bounds check, not sure what ids we get
|
||||
glogf("%s Setting joystick Button 1 to Gamepad %d", parse_log_prefix, tmp1);
|
||||
g_joystick_button_1 = tmp1;
|
||||
i++;
|
||||
} else if(!strcmp("-joy_b2", argv[i])) {
|
||||
} else if(!strcmp("-joy-b2", argv[i])) {
|
||||
if((i+1) >= argc) {
|
||||
glogf("%s Error, option '-joy_b2' missing argument", parse_log_prefix);
|
||||
glogf("%s Error, option '-joy-b2' missing argument", parse_log_prefix);
|
||||
exit(1);
|
||||
}
|
||||
tmp1 = strtol(argv[i+1], 0, 0); // no bounds check, not sure what ids we get
|
||||
glogf("%s Setting joystick Button 2 to Gamepad %d", parse_log_prefix, tmp1);
|
||||
g_joystick_button_2 = tmp1;
|
||||
i++;
|
||||
} else if(!strcmp("-joy_b3", argv[i])) {
|
||||
} else if(!strcmp("-joy-b3", argv[i])) {
|
||||
if((i+1) >= argc) {
|
||||
glogf("%s Error, option '-joy_b3' missing argument", parse_log_prefix);
|
||||
glogf("%s Error, option '-joy-b3' missing argument", parse_log_prefix);
|
||||
exit(1);
|
||||
}
|
||||
tmp1 = strtol(argv[i+1], 0, 0); // no bounds check, not sure what ids we get
|
||||
@ -330,6 +342,24 @@ int parse_cli_options(int argc, char **argv) {
|
||||
glogf("%s Using %d as y val", parse_log_prefix, tmp1);
|
||||
g_starty = tmp1;
|
||||
i++;
|
||||
} else if(!strcmp("-sw", argv[i])) {
|
||||
if((i+1) >= argc) {
|
||||
glogf("%s Error, option '-sw' missing argument", parse_log_prefix);
|
||||
exit(1);
|
||||
}
|
||||
tmp1 = strtol(argv[i+1], 0, 0);
|
||||
glogf("%s Using %d as width val", parse_log_prefix, tmp1);
|
||||
g_startw = tmp1;
|
||||
i++;
|
||||
} else if(!strcmp("-sh", argv[i])) {
|
||||
if((i+1) >= argc) {
|
||||
glogf("%s Error, option '-sh' missing argument", parse_log_prefix);
|
||||
exit(1);
|
||||
}
|
||||
tmp1 = strtol(argv[i+1], 0, 0);
|
||||
glogf("%s Using %d as height val", parse_log_prefix, tmp1);
|
||||
g_starth = tmp1;
|
||||
i++;
|
||||
} else if(!strcmp("-config", argv[i])) { // Config file passed
|
||||
if((i+1) >= argc) {
|
||||
glogf("%s Error, option '-config' missing argument", parse_log_prefix);
|
||||
@ -399,7 +429,12 @@ void help_exit() {
|
||||
printf(" -scanline value Enable scanline simulator at value %%\n");
|
||||
printf(" -x value Open emulator window at x value\n");
|
||||
printf(" -y value Open emulator window at y value\n");
|
||||
printf(" -v value Set verbose flags to value\n\n");
|
||||
printf(" -sw value Scale window to sw pixels wide\n");
|
||||
printf(" -sh value Scale window to sh pixels high\n");
|
||||
printf(" -novsync Don't force emulator to sync each frame\n");
|
||||
printf(" -fulldesk Use desktop 'fake' fullscreen mode\n");
|
||||
|
||||
//printf(" -v value Set verbose flags to value\n\n");
|
||||
printf(" Note: The final argument, if not a flag, will be tried as a mountable device.\n\n");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -52,11 +52,15 @@ extern int g_fullscreen; // only checked at start if set via CLI, otherwise it'
|
||||
extern int g_highdpi;
|
||||
extern int g_borderless;
|
||||
extern int g_resizeable;
|
||||
extern int g_noaspect;
|
||||
extern int g_novsync;
|
||||
extern int g_nohwaccel;
|
||||
extern int g_fullscreen_desktop;
|
||||
extern int g_scanline_simulator;
|
||||
extern int g_startx;
|
||||
extern int g_starty;
|
||||
extern int g_startw;
|
||||
extern int g_starth;
|
||||
extern int g_screen_depth;
|
||||
extern int g_quit_sim_now;
|
||||
extern int g_border_sides_refresh_needed;
|
||||
@ -316,14 +320,13 @@ void dev_video_init_sdl() {
|
||||
more_flags |= SDL_WINDOW_RESIZABLE;
|
||||
}
|
||||
|
||||
|
||||
window = SDL_CreateWindow(
|
||||
window_title, // window title (GSport vX.X)
|
||||
window_title, // window title (GSport vX.X)
|
||||
startx,
|
||||
starty,
|
||||
BASE_WINDOW_WIDTH, // width, in pixels
|
||||
X_A2_WINDOW_HEIGHT, // height, in pixels
|
||||
SDL_WINDOW_OPENGL // flags - see below
|
||||
g_startw, // width, in pixels
|
||||
g_starth, // height, in pixels
|
||||
SDL_WINDOW_OPENGL // flags - see below
|
||||
| more_flags
|
||||
);
|
||||
|
||||
@ -352,7 +355,9 @@ void dev_video_init_sdl() {
|
||||
|
||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); // make the scaled rendering look smoother.
|
||||
// SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best"); // make the scaled rendering look smoother.
|
||||
SDL_RenderSetLogicalSize(renderer, BASE_WINDOW_WIDTH, X_A2_WINDOW_HEIGHT);
|
||||
if (!g_noaspect) {
|
||||
SDL_RenderSetLogicalSize(renderer, BASE_WINDOW_WIDTH, X_A2_WINDOW_HEIGHT);
|
||||
}
|
||||
|
||||
texture = SDL_CreateTexture(renderer,
|
||||
SDL_PIXELFORMAT_ARGB8888,
|
||||
@ -596,12 +601,13 @@ void handle_sdl_key_event(SDL_Event event) {
|
||||
if (!IsFullScreen(window)) {
|
||||
glog("Enable fullscreen");
|
||||
SDL_SetWindowGrab(window, true);
|
||||
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||
Uint32 fullmode = g_fullscreen_desktop ? SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_FULLSCREEN;
|
||||
SDL_SetWindowFullscreen(window, fullmode);
|
||||
} else {
|
||||
glog("Disable fullscreen");
|
||||
SDL_SetWindowFullscreen(window, 0);
|
||||
SDL_SetWindowGrab(window, false);
|
||||
SDL_SetWindowSize(window, BASE_WINDOW_WIDTH, X_A2_WINDOW_HEIGHT);
|
||||
SDL_SetWindowSize(window, g_startw, g_starth);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -619,8 +625,8 @@ void handle_sdl_key_event(SDL_Event event) {
|
||||
void handle_sdl_mouse_event(SDL_Event event) {
|
||||
int x, y;
|
||||
|
||||
x = event.motion.x * A2_WINDOW_WIDTH / BASE_WINDOW_WIDTH;
|
||||
y = event.motion.y * A2_WINDOW_HEIGHT / BASE_WINDOW_HEIGHT;
|
||||
x = event.motion.x * A2_WINDOW_WIDTH / g_startw;
|
||||
y = event.motion.y * A2_WINDOW_HEIGHT / g_starth;
|
||||
switch (event.type) {
|
||||
case SDL_MOUSEMOTION:
|
||||
update_mouse(x, y, 0, 0);
|
||||
@ -808,6 +814,17 @@ void debuginfo_renderer(SDL_Renderer *r) {
|
||||
}
|
||||
}
|
||||
|
||||
// as this is triggered when new images were pushed to backing buffer,
|
||||
// this is when we want to update frames.
|
||||
// putting it in x_push_done means we can skip frames that weren't changed.
|
||||
// the emulator will still run at whatever specified speed. but this way,
|
||||
// when running in faster 8mhz/unlimited modes, it won't be slowed down by
|
||||
// forcing every draw at 60FPS sync.
|
||||
void x_push_done() {
|
||||
void sdl_present_buffer();
|
||||
sdl_present_buffer();
|
||||
}
|
||||
|
||||
void sdl_present_buffer() {
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_RenderCopy(renderer, texture, NULL, NULL);
|
||||
@ -822,6 +839,7 @@ void sdl_present_buffer() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// BELOW ARE FUNCTIONS THAT ARE EITHER UNIMPLEMENTED, OR AR NOT RELEVANT TO
|
||||
// THIS DRIVER.
|
||||
|
||||
@ -832,13 +850,9 @@ void x_redraw_status_lines() { }
|
||||
void x_hide_pointer(int do_hide) { }
|
||||
void x_auto_repeat_on(int must) { }
|
||||
void x_auto_repeat_off(int must) { }
|
||||
// OG Adding release
|
||||
void x_release_kimage(Kimage* kimage_ptr) { }
|
||||
// OG Addding ratio
|
||||
int x_calc_ratio(float x,float y) { return 1; }
|
||||
void x_set_mask_and_shift(word32 x_mask, word32 *mask_ptr, int *shift_left_ptr, int *shift_right_ptr) { return; }
|
||||
void x_update_color(int col_num, int red, int green, int blue, word32 rgb) { }
|
||||
void x_update_physical_colormap() { }
|
||||
void show_xcolor_array() { }
|
||||
|
||||
void x_push_done() { }
|
||||
|
@ -1865,8 +1865,8 @@ extern int g_a2vid_palette;
|
||||
|
||||
extern int g_status_refresh_needed;
|
||||
|
||||
|
||||
void update_60hz(double dcycs, double dtime_now) {
|
||||
/* our main function that runs each 60Hz update cycle */
|
||||
void update_60hz(double dcycs, double dtime_now) {
|
||||
register word32 end_time;
|
||||
char status_buf[1024];
|
||||
char sim_mhz_buf[128];
|
||||
|
15
src/video.c
15
src/video.c
@ -91,11 +91,15 @@ int g_use_dhr140 = 0;
|
||||
int g_use_bw_hires = 0;
|
||||
int g_startx = WINDOWPOS_UNDEFINED;
|
||||
int g_starty = WINDOWPOS_UNDEFINED;
|
||||
int g_startw = BASE_WINDOW_WIDTH;
|
||||
int g_starth = X_A2_WINDOW_HEIGHT;
|
||||
int g_highdpi = 0;
|
||||
int g_borderless = 0;
|
||||
int g_resizeable = 0;
|
||||
int g_noaspect = 0;
|
||||
int g_novsync = 0;
|
||||
int g_nohwaccel = 0;
|
||||
int g_fullscreen_desktop = 0;
|
||||
|
||||
int g_a2_new_all_stat[200];
|
||||
int g_a2_cur_all_stat[200];
|
||||
@ -640,17 +644,6 @@ void video_update() {
|
||||
video_update_through_line(0);
|
||||
}
|
||||
|
||||
#if defined(HAVE_SDL)
|
||||
extern void sdl_present_buffer();
|
||||
sdl_present_buffer();
|
||||
#endif
|
||||
// OG Notify host that video has been uodated
|
||||
#if defined(ACTIVEGSPLUGIN) && defined(MAC)
|
||||
{
|
||||
extern void x_need2refresh();
|
||||
x_need2refresh();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user