From c972a253ea69033521a0505b02bcc491551ed348 Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 11 Jul 2016 06:48:06 +0200 Subject: [PATCH] Saves NVR on exit, fatal, and before any kind of menu or configuration change triggered reset, rather than every second. Should improve performance and reduce disk writes. --- src/nvr.c | 1 - src/pc.c | 1 + src/rtc.c | 1 - src/win.c | 4 ++++ 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/nvr.c b/src/nvr.c index f9eea38e2..ef0932c9f 100644 --- a/src/nvr.c +++ b/src/nvr.c @@ -71,7 +71,6 @@ void nvr_onesec(void *p) { nvr_update_status = RTCUIP; if (!enable_sync) rtc_tick(); - nvr_dosave = 1; } } else if (nvr_onesec_cnt == 73) /* 73 of our cycles means 244+1984 us = update in progress time per the specification. */ diff --git a/src/pc.c b/src/pc.c index 61a8f5fb5..0cb9b0962 100644 --- a/src/pc.c +++ b/src/pc.c @@ -91,6 +91,7 @@ void fatal(const char *format, ...) vprintf(format, ap); va_end(ap); fflush(stdout); + savenvr(); dumppic(); dumpregs(); fflush(stdout); diff --git a/src/rtc.c b/src/rtc.c index 80a66843d..21a60e6a5 100644 --- a/src/rtc.c +++ b/src/rtc.c @@ -85,7 +85,6 @@ static void rtc_recalc() internal_clock.mon = 1; internal_clock.year++; } - nvr_dosave = 1; } /* Called when ticking the second */ diff --git a/src/win.c b/src/win.c index 9cd10e6a9..2384958a1 100644 --- a/src/win.c +++ b/src/win.c @@ -792,6 +792,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance, TerminateThread(mainthreadh,0); // pclog("Quited? %i\n",quited); // pclog("Closepc\n"); + savenvr(); if (save_window_pos && window_remember) saveconfig(); closepc(); @@ -957,6 +958,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM case IDM_FILE_RESET: pause=1; Sleep(100); + savenvr(); resetpc(); pause=0; break; @@ -964,12 +966,14 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM case IDM_FILE_HRESET: pause=1; Sleep(100); + savenvr(); resetpchard(); pause=0; break; case IDM_FILE_RESET_CAD: pause=1; Sleep(100); + savenvr(); resetpc_cad(); pause=0; break;