From e64f849394e7e5aa53a812709b4a6f3b92e2c72e Mon Sep 17 00:00:00 2001 From: Sean Ramey Date: Thu, 25 Mar 2021 02:14:14 -0500 Subject: [PATCH 1/5] Rename pc.c -> 86box.c --- src/{pc.c => 86box.c} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{pc.c => 86box.c} (100%) diff --git a/src/pc.c b/src/86box.c similarity index 100% rename from src/pc.c rename to src/86box.c From 95a1ba4d3c55c118bf6d881d3ef5a5518418f881 Mon Sep 17 00:00:00 2001 From: Sean Ramey Date: Thu, 25 Mar 2021 02:41:57 -0500 Subject: [PATCH 2/5] Changes to 86box.c for easier merge later. --- src/86box.c | 783 ++++++++++++++++++++++++++-------------------------- 1 file changed, 393 insertions(+), 390 deletions(-) diff --git a/src/86box.c b/src/86box.c index 4a1161221..a15e9db91 100644 --- a/src/86box.c +++ b/src/86box.c @@ -83,11 +83,11 @@ /* Stuff that used to be globally declared in plat.h but is now extern there and declared here instead. */ -int dopause, /* system is paused */ - doresize, /* screen resize requested */ - quited; /* system exit requested */ +int dopause; /* system is paused */ +int doresize; /* screen resize requested */ +int is_quit; /* system exit requested */ uint64_t timer_freq; -char emu_version[200]; /* version ID string */ +char emu_version[200]; /* version ID string */ #ifdef MTR_ENABLED int tracing_on = 0; @@ -112,52 +112,55 @@ uint64_t source_hwnd = 0; wchar_t log_path[1024] = { L'\0'}; /* (O) full path of logfile */ /* Configuration values. */ -int window_w, window_h, /* (C) window size and */ - window_x, window_y, /* position info */ - window_remember, - vid_resize, /* (C) allow resizing */ - invert_display = 0, /* (C) invert the display */ - suppress_overscan = 0; /* (C) suppress overscans */ +int window_w; /* (C) window size and */ +int window_h; /* position info */ +int window_x; +int window_y; +int window_remember; +int vid_resize; /* (C) allow resizing */ +int invert_display = 0; /* (C) invert the display */ +int suppress_overscan = 0; /* (C) suppress overscans */ int scale = 0; /* (C) screen scale factor */ int dpi_scale = 0; /* (C) DPI scaling of the emulated screen */ int vid_api = 0; /* (C) video renderer */ -int vid_cga_contrast = 0, /* (C) video */ - video_fullscreen = 0, /* (C) video */ - video_fullscreen_scale = 0, /* (C) video */ - video_fullscreen_first = 0, /* (C) video */ - enable_overscan = 0, /* (C) video */ - force_43 = 0; /* (C) video */ -int serial_enabled[SERIAL_MAX] = {0,0}, /* (C) enable serial ports */ - bugger_enabled = 0, /* (C) enable ISAbugger */ - postcard_enabled = 0, /* (C) enable POST card */ - isamem_type[ISAMEM_MAX] = { 0,0,0,0 }, /* (C) enable ISA mem cards */ - isartc_type = 0; /* (C) enable ISA RTC card */ +int vid_cga_contrast = 0; /* (C) video */ +int video_fullscreen = 0; /* (C) video */ +int video_fullscreen_scale = 0; /* (C) video */ +int video_fullscreen_first = 0; /* (C) video */ +int enable_overscan = 0; /* (C) video */ +int force_43 = 0; /* (C) video */ +int serial_enabled[SERIAL_MAX] = {0,0}; /* (C) enable serial ports */ +int bugger_enabled = 0; /* (C) enable ISAbugger */ +int postcard_enabled = 0; /* (C) enable POST card */ +int isamem_type[ISAMEM_MAX] = { 0,0,0,0 }; /* (C) enable ISA mem cards */ +int isartc_type = 0; /* (C) enable ISA RTC card */ int gfxcard = 0; /* (C) graphics/video card */ -int sound_is_float = 1, /* (C) sound uses FP values */ - GAMEBLASTER = 0, /* (C) sound option */ - GUS = 0, /* (C) sound option */ - SSI2001 = 0, /* (C) sound option */ - voodoo_enabled = 0; /* (C) video option */ +int sound_is_float = 1; /* (C) sound uses FP values */ +int GAMEBLASTER = 0; /* (C) sound option */ +int GUS = 0; /* (C) sound option */ +int SSI2001 = 0; /* (C) sound option */ +int voodoo_enabled = 0; /* (C) video option */ uint32_t mem_size = 0; /* (C) memory size */ -int cpu_use_dynarec = 0, /* (C) cpu uses/needs Dyna */ - cpu = 0, /* (C) cpu type */ - fpu_type = 0; /* (C) fpu type */ +int cpu_use_dynarec = 0; /* (C) cpu uses/needs Dyna */ +int cpu = 0; /* (C) cpu type */ +int fpu_type = 0; /* (C) fpu type */ int time_sync = 0; /* (C) enable time sync */ -int confirm_reset = 1, /* (C) enable reset confirmation */ - confirm_exit = 1, /* (C) enable exit confirmation */ - confirm_save = 1; /* (C) enable save confirmation */ +int confirm_reset = 1; /* (C) enable reset confirmation */ +int confirm_exit = 1; /* (C) enable exit confirmation */ +int confirm_save = 1; /* (C) enable save confirmation */ #ifdef USE_DISCORD int enable_discord = 0; /* (C) enable Discord integration */ #endif int enable_crashdump = 0; /* (C) enable crash dump */ /* Statistics. */ -extern int - mmuflush, - readlnum, - writelnum; +extern int mmuflush; +extern int readlnum; +extern int writelnum; -int fps, framecount; /* emulator % */ +/* emulator % */ +int fps; +int framecount; extern int CPUID; extern int output; @@ -167,16 +170,16 @@ wchar_t exe_path[2048]; /* path (dir) of executable */ wchar_t usr_path[1024]; /* path (dir) of user data */ wchar_t cfg_path[1024]; /* full path of config file */ FILE *stdlog = NULL; /* file to log output to */ -int scrnsz_x = SCREEN_RES_X, /* current screen size, X */ - scrnsz_y = SCREEN_RES_Y; /* current screen size, Y */ +int scrnsz_x = SCREEN_RES_X; /* current screen size, X */ +int scrnsz_y = SCREEN_RES_Y; /* current screen size, Y */ int config_changed; /* config has changed */ int title_update; int framecountx = 0; -int unscaled_size_x = SCREEN_RES_X, /* current unscaled size X */ - unscaled_size_y = SCREEN_RES_Y, /* current unscaled size Y */ - efscrnsz_y = SCREEN_RES_Y; +int unscaled_size_x = SCREEN_RES_X; /* current unscaled size X */ +int unscaled_size_y = SCREEN_RES_Y; /* current unscaled size Y */ +int efscrnsz_y = SCREEN_RES_Y; static wchar_t mouse_msg[2][200]; @@ -200,12 +203,12 @@ void pclog_ex(const char *fmt, va_list ap) { #ifndef RELEASE_BUILD - char temp[1024]; + char temp[1024]; - if (strcmp(fmt, "") == 0) + if (strcmp(fmt, "") == 0) return; - if (stdlog == NULL) { + if (stdlog == NULL) { if (log_path[0] != L'\0') { stdlog = plat_fopen(log_path, L"w"); if (stdlog == NULL) @@ -213,21 +216,21 @@ pclog_ex(const char *fmt, va_list ap) } else { stdlog = stdout; } - } + } - vsprintf(temp, fmt, ap); - if (suppr_seen && ! strcmp(buff, temp)) { + vsprintf(temp, fmt, ap); + if (suppr_seen && ! strcmp(buff, temp)) { seen++; - } else { + } else { if (suppr_seen && seen) { fprintf(stdlog, "*** %d repeats ***\n", seen); } seen = 0; strcpy(buff, temp); fprintf(stdlog, temp, ap); - } + } - fflush(stdlog); + fflush(stdlog); #endif } @@ -236,7 +239,7 @@ void pclog_toggle_suppr(void) { #ifndef RELEASE_BUILD - suppr_seen ^= 1; + suppr_seen ^= 1; #endif } @@ -246,11 +249,11 @@ void pclog(const char *fmt, ...) { #ifndef RELEASE_BUILD - va_list ap; + va_list ap; - va_start(ap, fmt); - pclog_ex(fmt, ap); - va_end(ap); + va_start(ap, fmt); + pclog_ex(fmt, ap); + va_end(ap); #endif } @@ -259,13 +262,13 @@ pclog(const char *fmt, ...) void fatal(const char *fmt, ...) { - char temp[1024]; - va_list ap; - char *sp; + char temp[1024]; + va_list ap; + char *sp; - va_start(ap, fmt); + va_start(ap, fmt); - if (stdlog == NULL) { + if (stdlog == NULL) { if (log_path[0] != L'\0') { stdlog = plat_fopen(log_path, L"w"); if (stdlog == NULL) @@ -273,33 +276,33 @@ fatal(const char *fmt, ...) } else { stdlog = stdout; } - } + } - vsprintf(temp, fmt, ap); - fprintf(stdlog, "%s", temp); - fflush(stdlog); - va_end(ap); + vsprintf(temp, fmt, ap); + fprintf(stdlog, "%s", temp); + fflush(stdlog); + va_end(ap); - nvr_save(); + nvr_save(); - config_save(); + config_save(); #ifdef ENABLE_808X_LOG - dumpregs(1); + dumpregs(1); #endif - /* Make sure the message does not have a trailing newline. */ - if ((sp = strchr(temp, '\n')) != NULL) *sp = '\0'; + /* Make sure the message does not have a trailing newline. */ + if ((sp = strchr(temp, '\n')) != NULL) *sp = '\0'; - /* Cleanly terminate all of the emulator's components so as - to avoid things like threads getting stuck. */ - do_stop(); + /* Cleanly terminate all of the emulator's components so as + to avoid things like threads getting stuck. */ + do_stop(); - ui_msgbox(MBX_ERROR | MBX_FATAL | MBX_ANSI, temp); + ui_msgbox(MBX_ERROR | MBX_FATAL | MBX_ANSI, temp); - fflush(stdlog); + fflush(stdlog); - exit(-1); + exit(-1); } @@ -310,13 +313,13 @@ int pc_do_log = ENABLE_PC_LOG; static void pc_log(const char *fmt, ...) { - va_list ap; + va_list ap; - if (pc_do_log) { + if (pc_do_log) { va_start(ap, fmt); pclog_ex(fmt, ap); va_end(ap); - } + } } #else #define pc_log(fmt, ...) @@ -333,31 +336,31 @@ pc_log(const char *fmt, ...) int pc_init(int argc, wchar_t *argv[]) { - wchar_t path[2048]; + wchar_t path[2048]; wchar_t *cfg = NULL, *p; - char temp[128]; - struct tm *info; - time_t now; - int c; - uint32_t *uid, *shwnd; + char temp[128]; + struct tm *info; + time_t now; + int c; + uint32_t *uid, *shwnd; - /* Grab the executable's full path. */ - plat_get_exe_name(exe_path, sizeof_w(exe_path)-1); - p = plat_get_filename(exe_path); - *p = L'\0'; + /* Grab the executable's full path. */ + plat_get_exe_name(exe_path, sizeof_w(exe_path)-1); + p = plat_get_filename(exe_path); + *p = L'\0'; - /* - * Get the current working directory. - * - * This is normally the directory from where the - * program was run. If we have been started via - * a shortcut (desktop icon), however, the CWD - * could have been set to something else. - */ - plat_getcwd(usr_path, sizeof_w(usr_path)-1); - memset(path, 0x00, sizeof(path)); + /* + * Get the current working directory. + * + * This is normally the directory from where the + * program was run. If we have been started via + * a shortcut (desktop icon), however, the CWD + * could have been set to something else. + */ + plat_getcwd(usr_path, sizeof_w(usr_path)-1); + memset(path, 0x00, sizeof(path)); - for (c=1; ccpu_type >= CPU_286) + if (cpu_s->cpu_type >= CPU_286) pit_set_clock(cpu_s->rspeed); - else + else pit_set_clock(14318184.0); } @@ -553,11 +556,11 @@ pc_speed_changed(void) void pc_full_speed(void) { - if (! atfullspeed) { + if (! atfullspeed) { pc_log("Set fullspeed - %i %i\n", is386, AT); pc_speed_changed(); - } - atfullspeed = 1; + } + atfullspeed = 1; } @@ -565,25 +568,25 @@ pc_full_speed(void) int pc_init_modules(void) { - int c, m; - wchar_t temp[512]; - char tempc[512]; + int c, m; + wchar_t temp[512]; + char tempc[512]; - pc_log("Scanning for ROM images:\n"); - c = m = 0; - while (machine_get_internal_name_ex(m) != NULL) { + pc_log("Scanning for ROM images:\n"); + c = m = 0; + while (machine_get_internal_name_ex(m) != NULL) { c += machine_available(m); m++; - } - if (c == 0) { + } + if (c == 0) { /* No usable ROMs found, aborting. */ return(0); - } - pc_log("A total of %d ROM sets have been loaded.\n", c); + } + pc_log("A total of %d ROM sets have been loaded.\n", c); - /* Load the ROMs for the selected machine. */ - if (! machine_available(machine)) { - swprintf(temp, sizeof(temp), plat_get_string(IDS_2063), machine_getname()); + /* Load the ROMs for the selected machine. */ + if (! machine_available(machine)) { + swprintf(temp, sizeof(temp), plat_get_string(IDS_2063), machine_getname()); c = 0; machine = -1; while (machine_get_internal_name_ex(c) != NULL) { @@ -600,13 +603,13 @@ pc_init_modules(void) exit(-1); return(0); } - } + } - /* Make sure we have a usable video card. */ - if (! video_card_available(gfxcard)) { + /* Make sure we have a usable video card. */ + if (! video_card_available(gfxcard)) { memset(tempc, 0, sizeof(tempc)); device_get_name(video_card_getdevice(gfxcard), 0, tempc); - swprintf(temp, sizeof(temp), plat_get_string(IDS_2064), tempc); + swprintf(temp, sizeof(temp), plat_get_string(IDS_2064), tempc); c = 0; while (video_get_internal_name(c) != NULL) { gfxcard = -1; @@ -623,44 +626,44 @@ pc_init_modules(void) exit(-1); return(0); } - } + } - atfullspeed = 0; + atfullspeed = 0; - random_init(); + random_init(); - mem_init(); + mem_init(); #ifdef USE_DYNAREC - codegen_init(); + codegen_init(); #endif - keyboard_init(); - joystick_init(); + keyboard_init(); + joystick_init(); - video_init(); + video_init(); - fdd_init(); + fdd_init(); - sound_init(); + sound_init(); - hdc_init(); + hdc_init(); - video_reset_close(); + video_reset_close(); - return(1); + return(1); } void pc_send_ca(uint16_t sc) { - keyboard_input(1, 0x1D); /* Ctrl key pressed */ - keyboard_input(1, 0x38); /* Alt key pressed */ - keyboard_input(1, sc); - keyboard_input(0, sc); - keyboard_input(0, 0x38); /* Alt key released */ - keyboard_input(0, 0x1D); /* Ctrl key released */ + keyboard_input(1, 0x1D); /* Ctrl key pressed */ + keyboard_input(1, 0x38); /* Alt key pressed */ + keyboard_input(1, sc); + keyboard_input(0, sc); + keyboard_input(0, 0x38); /* Alt key released */ + keyboard_input(0, 0x1D); /* Ctrl key released */ } @@ -668,7 +671,7 @@ pc_send_ca(uint16_t sc) void pc_send_cad(void) { - pc_send_ca(0xE053); + pc_send_ca(0xE053); } @@ -676,49 +679,49 @@ pc_send_cad(void) void pc_send_cae(void) { - pc_send_ca(1); + pc_send_ca(1); } void pc_reset_hard_close(void) { - ui_sb_set_ready(0); + ui_sb_set_ready(0); - /* Close all the memory mappings. */ - mem_close(); + /* Close all the memory mappings. */ + mem_close(); - network_timer_stop(); + network_timer_stop(); - /* Turn off timer processing to avoid potential segmentation faults. */ - timer_close(); + /* Turn off timer processing to avoid potential segmentation faults. */ + timer_close(); - suppress_overscan = 0; + suppress_overscan = 0; - nvr_save(); - nvr_close(); + nvr_save(); + nvr_close(); - mouse_close(); + mouse_close(); - lpt_devices_close(); + lpt_devices_close(); - device_close_all(); + device_close_all(); - scsi_device_close_all(); + scsi_device_close_all(); - midi_close(); + midi_close(); - cdrom_close(); + cdrom_close(); - zip_close(); + zip_close(); - mo_close(); + mo_close(); - scsi_disk_close(); + scsi_disk_close(); - closeal(); + closeal(); - video_reset_close(); + video_reset_close(); } @@ -731,110 +734,110 @@ pc_reset_hard_close(void) void pc_reset_hard_init(void) { - wchar_t wcpufamily[2048], wcpu[2048], wmachine[2048], *wcp; + wchar_t wcpufamily[2048], wcpu[2048], wmachine[2048], *wcp; - /* - * First, we reset the modules that are not part of - * the actual machine, but which support some of the - * modules that are. - */ + /* + * First, we reset the modules that are not part of + * the actual machine, but which support some of the + * modules that are. + */ - /* Reset the general machine support modules. */ - io_init(); + /* Reset the general machine support modules. */ + io_init(); - /* Turn on and (re)initialize timer processing. */ - timer_init(); + /* Turn on and (re)initialize timer processing. */ + timer_init(); - device_init(); + device_init(); - sound_reset(); + sound_reset(); - scsi_device_init(); + scsi_device_init(); - /* Initialize the actual machine and its basic modules. */ - machine_init(); + /* Initialize the actual machine and its basic modules. */ + machine_init(); - /* Reset and reconfigure the serial ports. */ - serial_standalone_init(); + /* Reset and reconfigure the serial ports. */ + serial_standalone_init(); - /* Reset and reconfigure the Sound Card layer. */ - sound_card_reset(); + /* Reset and reconfigure the Sound Card layer. */ + sound_card_reset(); - /* Reset any ISA memory cards. */ - isamem_reset(); - - /* Reset any ISA RTC cards. */ - isartc_reset(); + /* Reset any ISA memory cards. */ + isamem_reset(); - fdc_card_init(); - - fdd_reset(); + /* Reset any ISA RTC cards. */ + isartc_reset(); - /* - * Once the machine has been initialized, all that remains - * should be resetting all devices set up for it, to their - * current configurations ! - * - * For now, we will call their reset functions here, but - * that will be a call to device_reset_all() later ! - */ + fdc_card_init(); - /* Reset some basic devices. */ - speaker_init(); - lpt_devices_init(); - shadowbios = 0; + fdd_reset(); - /* - * Reset the mouse, this will attach it to any port needed. - */ - mouse_reset(); + /* + * Once the machine has been initialized, all that remains + * should be resetting all devices set up for it, to their + * current configurations ! + * + * For now, we will call their reset functions here, but + * that will be a call to device_reset_all() later ! + */ - /* Reset the Hard Disk Controller module. */ - hdc_reset(); - /* Reset and reconfigure the SCSI layer. */ - scsi_card_init(); + /* Reset some basic devices. */ + speaker_init(); + lpt_devices_init(); + shadowbios = 0; - cdrom_hard_reset(); + /* + * Reset the mouse, this will attach it to any port needed. + */ + mouse_reset(); - zip_hard_reset(); + /* Reset the Hard Disk Controller module. */ + hdc_reset(); + /* Reset and reconfigure the SCSI layer. */ + scsi_card_init(); - mo_hard_reset(); + cdrom_hard_reset(); - scsi_disk_hard_reset(); + zip_hard_reset(); - /* Reset and reconfigure the Network Card layer. */ - network_reset(); + mo_hard_reset(); - if (joystick_type) + scsi_disk_hard_reset(); + + /* Reset and reconfigure the Network Card layer. */ + network_reset(); + + if (joystick_type) gameport_update_joystick_type(); - ui_sb_update_panes(); + ui_sb_update_panes(); - if (config_changed) { - config_save(); + if (config_changed) { + config_save(); config_changed = 0; - } else + } else ui_sb_set_ready(1); - /* Needs the status bar... */ - if (bugger_enabled) - device_add(&bugger_device); - if (postcard_enabled) - device_add(&postcard_device); + /* Needs the status bar... */ + if (bugger_enabled) + device_add(&bugger_device); + if (postcard_enabled) + device_add(&postcard_device); - /* Reset the CPU module. */ - resetx86(); - dma_reset(); - pic_reset(); - cpu_cache_int_enabled = cpu_cache_ext_enabled = 0; + /* Reset the CPU module. */ + resetx86(); + dma_reset(); + pic_reset(); + cpu_cache_int_enabled = cpu_cache_ext_enabled = 0; - atfullspeed = 0; - pc_full_speed(); + atfullspeed = 0; + pc_full_speed(); - cycles = cycles_main = 0; + cycles = cycles_main = 0; - mbstowcs(wmachine, machine_getname(), strlen(machine_getname())+1); + mbstowcs(wmachine, machine_getname(), strlen(machine_getname())+1); mbstowcs(wcpufamily, cpu_f->name, strlen(cpu_f->name)+1); wcp = wcschr(wcpufamily, L'('); @@ -853,103 +856,103 @@ pc_reset_hard_init(void) void pc_reset_hard(void) { - pc_reset_hard_close(); + pc_reset_hard_close(); - pc_reset_hard_init(); + pc_reset_hard_init(); } void pc_close(thread_t *ptr) { - int i; + int i; - /* Wait a while so things can shut down. */ - plat_delay_ms(200); + /* Wait a while so things can shut down. */ + plat_delay_ms(200); - /* Claim the video blitter. */ - startblit(); + /* Claim the video blitter. */ + startblit(); - /* Terminate the main thread. */ - if (ptr != NULL) { + /* Terminate the main thread. */ + if (ptr != NULL) { thread_kill(ptr); /* Wait some more. */ plat_delay_ms(200); - } + } #if (defined(USE_DYNAREC) && defined(USE_NEW_DYNAREC)) - codegen_close(); + codegen_close(); #endif - nvr_save(); + nvr_save(); - config_save(); + config_save(); - plat_mouse_capture(0); + plat_mouse_capture(0); - /* Close all the memory mappings. */ - mem_close(); + /* Close all the memory mappings. */ + mem_close(); - network_timer_stop(); + network_timer_stop(); - /* Turn off timer processing to avoid potential segmentation faults. */ - timer_close(); + /* Turn off timer processing to avoid potential segmentation faults. */ + timer_close(); - lpt_devices_close(); + lpt_devices_close(); - for (i=0; irspeed / 100); - mouse_process(); - joystick_process(); + /* Run a block of code. */ + cpu_exec(cpu_s->rspeed / 100); + mouse_process(); + joystick_process(); - /* Done with this frame, update statistics. */ - framecount++; - if (++framecountx >= 100) { - framecountx = 0; - frames = 0; - } + /* Done with this frame, update statistics. */ + framecount++; + if (++framecountx >= 100) { + framecountx = 0; + frames = 0; + } - if (title_update) { - swprintf(temp, sizeof_w(temp), mouse_msg[!!mouse_capture], fps); - ui_window_title(temp); - title_update = 0; - } + if (title_update) { + swprintf(temp, sizeof_w(temp), mouse_msg[!!mouse_capture], fps); + ui_window_title(temp); + title_update = 0; + } } @@ -957,66 +960,66 @@ pc_run(void) void pc_onesec(void) { - fps = framecount; - framecount = 0; + fps = framecount; + framecount = 0; - title_update = 1; + title_update = 1; } void set_screen_size(int x, int y) { - int owsx = scrnsz_x; - int owsy = scrnsz_y; - int temp_overscan_x = overscan_x; - int temp_overscan_y = overscan_y; - double dx, dy, dtx, dty; + int owsx = scrnsz_x; + int owsy = scrnsz_y; + int temp_overscan_x = overscan_x; + int temp_overscan_y = overscan_y; + double dx, dy, dtx, dty; - /* Make sure we keep usable values. */ + /* Make sure we keep usable values. */ #if 0 - pc_log("SetScreenSize(%d, %d) resize=%d\n", x, y, vid_resize); + pc_log("SetScreenSize(%d, %d) resize=%d\n", x, y, vid_resize); #endif - if (x < 320) x = 320; - if (y < 200) y = 200; - if (x > 2048) x = 2048; - if (y > 2048) y = 2048; + if (x < 320) x = 320; + if (y < 200) y = 200; + if (x > 2048) x = 2048; + if (y > 2048) y = 2048; - /* Save the new values as "real" (unscaled) resolution. */ - unscaled_size_x = x; - efscrnsz_y = y; + /* Save the new values as "real" (unscaled) resolution. */ + unscaled_size_x = x; + efscrnsz_y = y; - if (suppress_overscan) - temp_overscan_x = temp_overscan_y = 0; + if (suppress_overscan) + temp_overscan_x = temp_overscan_y = 0; - if (force_43) { - dx = (double)x; - dtx = (double)temp_overscan_x; + if (force_43) { + dx = (double)x; + dtx = (double)temp_overscan_x; - dy = (double)y; - dty = (double)temp_overscan_y; + dy = (double)y; + dty = (double)temp_overscan_y; - /* Account for possible overscan. */ - if (!(video_is_ega_vga()) && (temp_overscan_y == 16)) { - /* CGA */ - dy = (((dx - dtx) / 4.0) * 3.0) + dty; - } else if (!(video_is_ega_vga()) && (temp_overscan_y < 16)) { - /* MDA/Hercules */ - dy = (x / 4.0) * 3.0; - } else { - if (enable_overscan) { - /* EGA/(S)VGA with overscan */ - dy = (((dx - dtx) / 4.0) * 3.0) + dty; - } else { - /* EGA/(S)VGA without overscan */ - dy = (x / 4.0) * 3.0; - } - } - unscaled_size_y = (int)dy; - } else + /* Account for possible overscan. */ + if (!(video_is_ega_vga()) && (temp_overscan_y == 16)) { + /* CGA */ + dy = (((dx - dtx) / 4.0) * 3.0) + dty; + } else if (!(video_is_ega_vga()) && (temp_overscan_y < 16)) { + /* MDA/Hercules */ + dy = (x / 4.0) * 3.0; + } else { + if (enable_overscan) { + /* EGA/(S)VGA with overscan */ + dy = (((dx - dtx) / 4.0) * 3.0) + dty; + } else { + /* EGA/(S)VGA without overscan */ + dy = (x / 4.0) * 3.0; + } + } + unscaled_size_y = (int)dy; + } else unscaled_size_y = efscrnsz_y; - switch(scale) { + switch(scale) { case 0: /* 50% */ scrnsz_x = (unscaled_size_x>>1); scrnsz_y = (unscaled_size_y>>1); @@ -1036,12 +1039,12 @@ set_screen_size(int x, int y) scrnsz_x = (unscaled_size_x<<1); scrnsz_y = (unscaled_size_y<<1); break; - } + } - /* If the resolution has changed, let the main thread handle it. */ - if ((owsx != scrnsz_x) || (owsy != scrnsz_y)) + /* If the resolution has changed, let the main thread handle it. */ + if ((owsx != scrnsz_x) || (owsy != scrnsz_y)) doresize = 1; - else + else doresize = 0; } @@ -1049,26 +1052,26 @@ set_screen_size(int x, int y) void reset_screen_size(void) { - set_screen_size(unscaled_size_x, efscrnsz_y); + set_screen_size(unscaled_size_x, efscrnsz_y); } void set_screen_size_natural(void) { - set_screen_size(unscaled_size_x, unscaled_size_y); + set_screen_size(unscaled_size_x, unscaled_size_y); } int get_actual_size_x(void) { - return(unscaled_size_x); + return(unscaled_size_x); } int get_actual_size_y(void) { - return(efscrnsz_y); + return(efscrnsz_y); } From 692a4eef4f3f579db453c9a68b043c4acdd71d40 Mon Sep 17 00:00:00 2001 From: Sean Ramey Date: Thu, 25 Mar 2021 03:08:50 -0500 Subject: [PATCH 3/5] Fix build because of changed file name. --- src/win/Makefile.mingw | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/win/Makefile.mingw b/src/win/Makefile.mingw index f7491d742..043dd3861 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -41,7 +41,7 @@ ifeq ($(DEV_BUILD), y) endif ifndef CYRIX_6X86 CYRIX_6X86 := y - endif + endif ifndef GUSMAX GUSMAX := y endif @@ -336,7 +336,7 @@ ifeq ($(X64), y) ifeq ($(OPTIM), y) DFLAGS := -march=native else - DFLAGS := + DFLAGS := endif else ifeq ($(OPTIM), y) @@ -609,7 +609,7 @@ CXXFLAGS := $(CFLAGS) ######################################################################### # Create the (final) list of objects to build. # ######################################################################### -MAINOBJ := pc.o config.o random.o timer.o io.o acpi.o apm.o dma.o ddma.o \ +MAINOBJ := 86box.o config.o random.o timer.o io.o acpi.o apm.o dma.o ddma.o \ nmi.o pic.o pit.o port_92.o ppi.o pci.o mca.o \ usb.o device.o nvr.o nvr_at.o nvr_ps2.o \ $(VNCOBJ) @@ -687,10 +687,10 @@ HDDOBJ := hdd.o \ hdc_xtide.o hdc_ide.o \ hdc_ide_opti611.o \ hdc_ide_cmd640.o hdc_ide_sff8038i.o - + MINIVHDOBJ := cwalk.o libxml2_encoding.o minivhd_convert.o \ minivhd_create.o minivhd_io.o minivhd_manage.o \ - minivhd_struct_rw.o minivhd_util.o + minivhd_struct_rw.o minivhd_util.o CDROMOBJ := cdrom.o \ cdrom_image_backend.o cdrom_image.o @@ -719,7 +719,7 @@ NETOBJ := network.o \ PRINTOBJ := png.o prt_cpmap.o \ prt_escp.o prt_text.o prt_ps.o - + SNDOBJ := sound.o \ openal.o \ snd_opl.o snd_opl_nuked.o \ From ce4a97967f847269175580caadeef422d767deb7 Mon Sep 17 00:00:00 2001 From: Sean Ramey Date: Thu, 25 Mar 2021 03:13:33 -0500 Subject: [PATCH 4/5] Fix Cmake build because of renamed file. --- src/CMakeLists.txt | 4 ++-- src/win/CMakeLists.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3e0b0515d..245c696a8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,7 +14,7 @@ # # WIN32 marks us as a GUI app on Windows -add_executable(86Box WIN32 pc.c config.c random.c timer.c io.c acpi.c apm.c +add_executable(86Box WIN32 86box.c config.c random.c timer.c io.c acpi.c apm.c dma.c ddma.c nmi.c pic.c pit.c port_92.c ppi.c pci.c mca.c usb.c device.c nvr.c nvr_at.c nvr_ps2.c) @@ -119,4 +119,4 @@ add_subdirectory(sio) add_subdirectory(scsi) add_subdirectory(sound) add_subdirectory(video) -add_subdirectory(win) \ No newline at end of file +add_subdirectory(win) diff --git a/src/win/CMakeLists.txt b/src/win/CMakeLists.txt index f8c248ae3..dd5e7b28c 100644 --- a/src/win/CMakeLists.txt +++ b/src/win/CMakeLists.txt @@ -38,11 +38,11 @@ else() endif() if(DISCORD) - # PUBLIC due to config.c and pc.c + # PUBLIC due to config.c and 86box.c target_compile_definitions(ui PUBLIC USE_DISCORD) target_sources(ui PRIVATE win_discord.c) endif() target_link_libraries(86Box advapi32 comctl32 comdlg32 gdi32 shell32 iphlpapi - dxguid imm32 hid setupapi uxtheme version winmm psapi) \ No newline at end of file + dxguid imm32 hid setupapi uxtheme version winmm psapi) From 8d9a3f02eaa176c973a609364d059aff80ece5f8 Mon Sep 17 00:00:00 2001 From: Sean Ramey Date: Thu, 25 Mar 2021 03:20:25 -0500 Subject: [PATCH 5/5] Fix build due to renamed variable. quited -> is_quit --- src/include/86box/plat.h | 2 +- src/win/win.c | 14 +++++++------- src/win/win_ui.c | 14 +++++++------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/include/86box/plat.h b/src/include/86box/plat.h index af7434d09..a93118223 100644 --- a/src/include/86box/plat.h +++ b/src/include/86box/plat.h @@ -64,7 +64,7 @@ extern "C" { /* Global variables residing in the platform module. */ extern int dopause, /* system is paused */ doresize, /* screen resize requested */ - quited, /* system exit requested */ + is_quit, /* system exit requested */ mouse_capture; /* mouse is captured in app */ #ifdef MTR_ENABLED diff --git a/src/win/win.c b/src/win/win.c index a47de48c0..155498abb 100644 --- a/src/win/win.c +++ b/src/win/win.c @@ -402,7 +402,7 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpszArg, int nCmdShow) free(argw); return(1); } - + /* Enable crash dump services. */ if (enable_crashdump) InitCrashDump(); @@ -431,7 +431,7 @@ main_thread(void *param) title_update = 1; old_time = GetTickCount(); drawits = frames = 0; - while (!quited) { + while (!is_quit) { /* See if it is time to run a frame of code. */ new_time = GetTickCount(); drawits += (new_time - old_time); @@ -474,7 +474,7 @@ do_start(void) LARGE_INTEGER qpc; /* We have not stopped yet. */ - quited = 0; + is_quit = 0; /* Initialize the high-precision timer. */ timeBeginPeriod(1); @@ -483,7 +483,7 @@ do_start(void) win_log("Main timer precision: %llu\n", timer_freq); /* Start the emulator, really. */ - thMain = thread_create(main_thread, &quited); + thMain = thread_create(main_thread, &is_quit); SetThreadPriority(thMain, THREAD_PRIORITY_HIGHEST); } @@ -492,7 +492,7 @@ do_start(void) void do_stop(void) { - quited = 1; + is_quit = 1; plat_delay_ms(100); @@ -719,7 +719,7 @@ plat_get_ticks(void) LARGE_INTEGER EndingTime, ElapsedMicroseconds; if (first_use) { - QueryPerformanceFrequency(&Frequency); + QueryPerformanceFrequency(&Frequency); QueryPerformanceCounter(&StartingTime); first_use = 0; } @@ -911,7 +911,7 @@ plat_setfullscreen(int on) temp_y = unscaled_size_y; } - /* Main Window. */ + /* Main Window. */ ResizeWindowByClientArea(hwndMain, temp_x, temp_y + sbar_height); } diff --git a/src/win/win_ui.c b/src/win/win_ui.c index 7f7f66e5e..dbd35429b 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -118,7 +118,7 @@ int win_get_system_metrics(int index, int dpi) { if (pAreDpiAwarenessContextsEqual(c, DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2)) return pGetSystemMetricsForDpi(index, dpi); } - + return GetSystemMetrics(index); } @@ -312,7 +312,7 @@ LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) if (nCode < 0 || nCode != HC_ACTION || (!mouse_capture && !video_fullscreen)) return(CallNextHookEx(hKeyboardHook, nCode, wParam, lParam)); - + p = (KBDLLHOOKSTRUCT*)lParam; /* disable alt-tab */ @@ -666,7 +666,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case IDM_VID_FS_FULL: case IDM_VID_FS_43: - case IDM_VID_FS_KEEPRATIO: + case IDM_VID_FS_KEEPRATIO: case IDM_VID_FS_INT: CheckMenuItem(hmenu, IDM_VID_FS_FULL+video_fullscreen_scale, MF_UNCHECKED); video_fullscreen_scale = LOWORD(wParam) - IDM_VID_FS_FULL; @@ -888,7 +888,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) else if ((wParam >= 0x8000) && (wParam <= 0x80ff)) ui_sb_timer_callback(wParam & 0xff); break; - + case WM_LEAVEFULLSCREEN: plat_setfullscreen(0); config_save(); @@ -1332,16 +1332,16 @@ ui_init(int nCmdShow) do_start(); /* Run the message loop. It will run until GetMessage() returns 0 */ - while (! quited) { + while (! is_quit) { bRet = GetMessage(&messages, NULL, 0, 0); - if ((bRet == 0) || quited) break; + if ((bRet == 0) || is_quit) break; if (bRet == -1) { fatal("bRet is -1\n"); } if (messages.message == WM_QUIT) { - quited = 1; + is_quit = 1; break; }