From 8890281b58a94a7d0db963774518716eeaa53019 Mon Sep 17 00:00:00 2001 From: waltje Date: Sat, 21 Oct 2017 20:29:11 -0400 Subject: [PATCH] Minor cleanups. Logfile now has a header. We no longer log the entire config file, use -C (--dumpcfg) to enable that. --- src/86box.h | 3 ++- src/config.c | 7 +++--- src/pc.c | 53 +++++++++++++++++++------------------------- src/plat.h | 23 ++++++++----------- src/win/win_thread.c | 21 ++++++------------ 5 files changed, 45 insertions(+), 62 deletions(-) diff --git a/src/86box.h b/src/86box.h index 69435018f..42d1f9133 100644 --- a/src/86box.h +++ b/src/86box.h @@ -8,7 +8,7 @@ * * Main include file for the application. * - * Version: @(#)86box.h 1.0.6 2017/10/18 + * Version: @(#)86box.h 1.0.7 2017/10/21 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -58,6 +58,7 @@ extern "C" { /* Global variables. */ extern int dump_on_exit; /* (O) dump regs on exit*/ +extern int do_dump_config; /* (O) dump cfg after load */ extern int start_in_fullscreen; /* (O) start in fullscreen */ extern int window_w, window_h, /* (C) window size and */ diff --git a/src/config.c b/src/config.c index 97b99055c..0bd449d5c 100644 --- a/src/config.c +++ b/src/config.c @@ -8,7 +8,7 @@ * * Configuration file handler. * - * Version: @(#)config.c 1.0.25 2017/10/19 + * Version: @(#)config.c 1.0.25 2017/10/21 * * Authors: Sarah Walker, * Miran Grca, @@ -328,8 +328,9 @@ config_read(wchar_t *fn) } (void)fclose(f); - - config_dump(); + + if (do_dump_config) + config_dump(); return(1); } diff --git a/src/pc.c b/src/pc.c index 177c6d123..470ae2803 100644 --- a/src/pc.c +++ b/src/pc.c @@ -8,7 +8,7 @@ * * Main emulator module where most things are controlled. * - * Version: @(#)pc.c 1.0.29 2017/10/19 + * Version: @(#)pc.c 1.0.31 2017/10/21 * * Authors: Sarah Walker, * Miran Grca, @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "86box.h" #include "config.h" @@ -79,6 +80,7 @@ /* Commandline options. */ int dump_on_exit = 0; /* (O) dump regs on exit */ +int do_dump_config = 0; /* (O) dump config on load */ int start_in_fullscreen = 0; /* (O) start in fullscreen */ /* Configuration values. */ @@ -286,6 +288,9 @@ int pc_init(int argc, wchar_t *argv[]) { wchar_t *cfg = NULL, *p; + char temp[128]; + struct tm *info; + time_t now; int c; /* Grab the executable's full path. */ @@ -310,11 +315,15 @@ usage: printf("\nUsage: 86box [options] [cfg-file]\n\n"); printf("Valid options are:\n\n"); printf("-? or --help - show this information\n"); + printf("-C or --dumpcfg - dump config file after loading\n"); printf("-D or --dump - dump memory on exit\n"); printf("-F or --fullscreen - start in fullscreen mode\n"); printf("-P or --vmpath path - set 'path' to be root for vm\n"); printf("\nA config file can be specified. If none is, the default file will be used.\n"); return(0); + } else if (!wcscasecmp(argv[c], L"--dumpcfg") || + !wcscasecmp(argv[c], L"-C")) { + do_dump_config = 1; } else if (!wcscasecmp(argv[c], L"--dump") || !wcscasecmp(argv[c], L"-D")) { dump_on_exit = 1; @@ -342,14 +351,7 @@ usage: cfg = argv[c++]; if (c != argc) goto usage; - /* - * This is where we start outputting to the log file, - * if there is one. Maybe we should log a header with - * application build info and such? --FvK - */ - /* Make sure cfg_path has a trailing backslash. */ - pclog("exe_path=%ls\n", exe_path); if ((cfg_path[wcslen(cfg_path)-1] != L'\\') && (cfg_path[wcslen(cfg_path)-1] != L'/')) { #ifdef WIN32 @@ -358,7 +360,6 @@ usage: wcscat(cfg_path, L"/"); #endif } - pclog("cfg_path=%ls\n", cfg_path); if (cfg != NULL) { /* @@ -383,6 +384,19 @@ usage: plat_append_filename(config_file_default, cfg_path, CONFIG_FILE_W, 511); } + /* + * This is where we start outputting to the log file, + * if there is one. Create a little info header first. + */ + (void)time(&now); + info = localtime(&now); + strftime(temp, sizeof(temp), "%Y/%m/%d %H:%M:%S", info); + pclog("#\n# %ls v%ls logfile, created %s\n#\n", + EMU_NAME_W, EMU_VERSION_W, temp); + pclog("# Emulator path: %ls\n", exe_path); + pclog("# Userfiles path: %ls\n", cfg_path); + pclog("# Configuration file: %ls\n#\n\n", config_file_default); + /* * We are about to read the configuration file, which MAY * put data into global variables (the hard- and floppy @@ -946,28 +960,7 @@ pc_thread(void *param) /* If needed, hand a screen resize. */ if (!video_fullscreen && doresize && (scrnsz_x>0) && (scrnsz_y>0)) { -#if 1 plat_resize(scrnsz_x, scrnsz_y); -#else - SendMessage(hwndSBAR, SB_GETBORDERS, 0, (LPARAM)sb_borders); - GetWindowRect(hwndMain, &r); - MoveWindow(hwndRender, 0, 0, scrnsz_x, scrnsz_y, TRUE); - GetWindowRect(hwndRender, &r); - MoveWindow(hwndSBAR, - 0, r.bottom+GetSystemMetrics(SM_CYEDGE), - scrnsz_x, 17, TRUE); - GetWindowRect(hwndMain, &r); - - MoveWindow(hwndMain, r.left, r.top, - scrnsz_x+(GetSystemMetrics(vid_resize ? SM_CXSIZEFRAME : SM_CXFIXEDFRAME) * 2), - scrnsz_y+(GetSystemMetrics(SM_CYEDGE)*2)+(GetSystemMetrics(vid_resize?SM_CYSIZEFRAME:SM_CYFIXEDFRAME)*2)+GetSystemMetrics(SM_CYMENUSIZE)+GetSystemMetrics(SM_CYCAPTION)+17+sb_borders[1]+1, - TRUE); - - if (mousecapture) { - GetWindowRect(hwndRender, &r); - ClipCursor(&r); - } -#endif doresize = 0; } diff --git a/src/plat.h b/src/plat.h index bbcd23a7c..1aa76b2f5 100644 --- a/src/plat.h +++ b/src/plat.h @@ -8,7 +8,7 @@ * * Define the various platform support functions. * - * Version: @(#)plat.h 1.0.11 2017/10/18 + * Version: @(#)plat.h 1.0.12 2017/10/19 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -38,7 +38,6 @@ GLOBAL int dopause, /* system is paused */ quited, /* system exit requested */ leave_fullscreen_flag; /* windowed-mode requested */ GLOBAL uint64_t timer_freq; -//GLOBAL int efwinsizey; GLOBAL int infocus; GLOBAL int mousecapture; @@ -99,28 +98,24 @@ typedef void thread_t; typedef void event_t; typedef void mutex_t; -extern thread_t *thread_create(void (*thread_rout)(void *param), void *param); -extern void thread_kill(thread_t *handle); - +extern thread_t *thread_create(void (*thread_func)(void *param), void *param); +extern void thread_kill(thread_t *arg); extern int thread_wait(thread_t *arg, int timeout); -extern void thread_sleep(int t); - extern event_t *thread_create_event(void); -extern void thread_set_event(event_t *event); -extern void thread_reset_event(event_t *_event); -extern int thread_wait_event(event_t *event, int timeout); -extern void thread_destroy_event(event_t *_event); +extern void thread_set_event(event_t *arg); +extern void thread_reset_event(event_t *arg); +extern int thread_wait_event(event_t *arg, int timeout); +extern void thread_destroy_event(event_t *arg); extern mutex_t *thread_create_mutex(wchar_t *name); -extern void thread_close_mutex(mutex_t *mutex); -extern int thread_wait_mutex(mutex_t *mutex); +extern void thread_close_mutex(mutex_t *arg); +extern int thread_wait_mutex(mutex_t *arg); extern int thread_release_mutex(mutex_t *mutex); /* Other stuff. */ extern void startblit(void); extern void endblit(void); -extern void leave_fullscreen(void); extern void take_screenshot(void); #ifdef __cplusplus diff --git a/src/win/win_thread.c b/src/win/win_thread.c index fba58f0b8..e5ecdb074 100644 --- a/src/win/win_thread.c +++ b/src/win/win_thread.c @@ -8,7 +8,7 @@ * * Implement threads and mutexes for the Win32 platform. * - * Version: @(#)win_thread.c 1.0.4 2017/10/16 + * Version: @(#)win_thread.c 1.0.5 2017/10/19 * * Authors: Sarah Walker, * Fred N. van Kempen, @@ -36,26 +36,19 @@ typedef struct { } win_event_t; -void * -thread_create(void (*thread_rout)(void *param), void *param) +thread_t * +thread_create(void (*func)(void *param), void *param) { - return((void *)_beginthread(thread_rout, 0, param)); + return((thread_t *)_beginthread(func, 0, param)); } void -thread_kill(void *handle) +thread_kill(void *arg) { - if (handle == NULL) return; + if (arg == NULL) return; - TerminateThread(handle, 0); -} - - -void -thread_sleep(int t) -{ - Sleep(t); + TerminateThread(arg, 0); }