shithub: ft2-clone

Download patch

ref: f5334d8324dae71325c59b559ab8fcceb8695fd8
parent: 4bcb5aa6a4d868649e795885d85182e3a452693b
author: Olav Sørensen <olav.sorensen@live.no>
date: Sun Feb 14 07:42:24 EST 2021

Remove unsuitable quit messages + code cleanup

Also handle "waitVBL on minimize" quirk when rendering sysreqs.

--- a/src/ft2_events.c
+++ b/src/ft2_events.c
@@ -54,7 +54,7 @@
 
 static void handleInput(void);
 
-// usleep() implementation for Windows
+// usleep() implementation for Windows (Warning: This might not be future-safe!)
 #ifdef _WIN32
 void usleep(uint32_t usec)
 {
@@ -392,6 +392,29 @@
 #endif
 }
 
+void handleWaitVblQuirk(SDL_Event *event)
+{
+	if (event->type == SDL_WINDOWEVENT)
+	{
+		if (event->window.event == SDL_WINDOWEVENT_HIDDEN)
+			video.windowHidden = true;
+		else if (event->window.event == SDL_WINDOWEVENT_SHOWN)
+			video.windowHidden = false;
+
+		if (video.vsync60HzPresent)
+		{
+			/* If we minimize the window and vsync is present, vsync is temporarily turned off.
+			** recalc waitVBL() vars so that it can sleep properly in said mode.
+			*/
+			if (event->window.event == SDL_WINDOWEVENT_MINIMIZED ||
+				event->window.event == SDL_WINDOWEVENT_FOCUS_LOST)
+			{
+				setupWaitVBL();
+			}
+		}
+	}
+}
+
 static void handleInput(void)
 {
 	SDL_Event event;
@@ -401,25 +424,7 @@
 
 	while (SDL_PollEvent(&event))
 	{
-		if (event.type == SDL_WINDOWEVENT)
-		{
-			if (event.window.event == SDL_WINDOWEVENT_HIDDEN)
-				video.windowHidden = true;
-			else if (event.window.event == SDL_WINDOWEVENT_SHOWN)
-				video.windowHidden = false;
-
-			if (video.vsync60HzPresent)
-			{
-				/* if we minimize the window and vsync is present, vsync is temporarily turned off.
-				** recalc waitVBL() vars so that it can sleep properly in said mode.
-				*/
-				if (event.window.event == SDL_WINDOWEVENT_MINIMIZED ||
-					event.window.event == SDL_WINDOWEVENT_FOCUS_LOST)
-				{
-					setupWaitVBL();
-				}
-			}
-		}
+		handleWaitVblQuirk(&event);
 
 		if (editor.busy)
 		{
--- a/src/ft2_events.h
+++ b/src/ft2_events.h
@@ -1,5 +1,6 @@
 #pragma once
 
+#include <SDL2/SDL.h>
 #include <stdint.h>
 #include <stdbool.h>
 
@@ -15,6 +16,7 @@
 void readInput(void);
 void handleEvents(void);
 void setupCrashHandler(void);
+void handleWaitVblQuirk(SDL_Event *event);
 #ifdef _WIN32
 bool handleSingleInstancing(int32_t argc, char **argv);
 void closeSingleInstancing(void);
--- a/src/ft2_scopes.c
+++ b/src/ft2_scopes.c
@@ -589,12 +589,12 @@
 		if (time64 < timeNext64)
 		{
 			time64 = timeNext64 - time64;
-			if (time64 > UINT32_MAX)
-				time64 = UINT32_MAX;
+			if (time64 > INT32_MAX)
+				time64 = INT32_MAX;
 
-			const uint32_t diff32 = (uint32_t)time64;
+			const int32_t diff32 = (int32_t)time64;
 
-			// convert to microseconds and round to integer
+			// convert and round to microseconds
 			const int32_t time32 = (int32_t)((diff32 * editor.dPerfFreqMulMicro) + 0.5);
 
 			// delay until we have reached the next frame
--- a/src/ft2_sysreqs.c
+++ b/src/ft2_sysreqs.c
@@ -8,6 +8,7 @@
 #include "ft2_video.h"
 #include "ft2_sysreqs.h"
 #include "ft2_structs.h"
+#include "ft2_events.h"
 
 #define SYSTEM_REQUEST_H 67
 #define SYSTEM_REQUEST_Y 249
@@ -22,7 +23,7 @@
 	{ "OK", "","","","" },
 	{ "OK", "Cancel", "","","" },
 	{ "Yes", "No", "","","" },
-	{ "=(", "Rules","","","" },
+	{ "","","","","" }, // deprecated
 	{ "All", "Song", "Instruments", "Cancel", "" },
 	{ "Read left", "Read right", "Convert", "", "" },
 	{ "OK", "","","","" },
@@ -36,7 +37,7 @@
 	{ SDLK_o, 0,      0,      0,      0 },
 	{ SDLK_o, SDLK_c, 0,      0,      0 },
 	{ SDLK_y, SDLK_n, 0,      0,      0 },
-	{ SDLK_s, SDLK_r, 0,      0,      0 },
+	{ 0, 0, 0, 0, 0 }, // deprecated
 	{ SDLK_a, SDLK_s, SDLK_i, SDLK_c, 0 },
 	{ SDLK_l, SDLK_r, SDLK_c, 0,      0 },
 	{ SDLK_o, 0,      0,      0,      0 },
@@ -51,27 +52,22 @@
 	uint8_t typ;
 } quitType_t;
 
-#define QUIT_MESSAGES 16
+#define QUIT_MESSAGES 11
 
-// 8bitbubsy: Removed the MS-DOS ones...
+// 8bitbubsy: Removed unsuitable/offensive ones...
 static quitType_t quitMessage[QUIT_MESSAGES] =
 {
 	{ "Do you really want to quit?", 2 },
-	{ "Musicians, press >Cancel<.  Lamers, press >OK<", 1 },
 	{ "Tired already?", 2 },
 	{ "Dost thou wish to leave with such hasty abandon?", 2 },
 	{ "So, you think you can quit this easily, huh?", 2 },
 	{ "Hey, what is the matter? You are not quiting now, are you?", 2 },
 	{ "Rome was not built in one day! Quit really?", 2 },
-	{ "For Work and Worry, press YES.  For Delectation and Demos, press NO.", 2 },
 	{ "Did you really press the right key?", 2 },
-	{ "You are a lamer, aren't you? Press >OK< to confirm.", 1 },
 	{ "Hope ya did some good. Press >OK< to quit.", 1 },
 	{ "Quit? Only for a good reason you are allowed to press >OK<.", 1 },
 	{ "Are we at the end of a Fasttracker round?", 2 },
-	{ "Are you just another boring user?", 2 },
 	{ "Hope you're doing the compulsory \"Exit ceremony\" before pressing >OK<.", 1 },
-	{ "Fasttracker...", 3 }
 };
 
 static void drawWindow(uint16_t w)
@@ -266,6 +262,8 @@
 
 		while (SDL_PollEvent(&inputEvent))
 		{
+			handleWaitVblQuirk(&inputEvent);
+
 			if (inputEvent.type == SDL_KEYDOWN)
 			{
 				if (inputEvent.key.keysym.sym == SDLK_ESCAPE)
@@ -479,6 +477,8 @@
 
 		while (SDL_PollEvent(&inputEvent))
 		{
+			handleWaitVblQuirk(&inputEvent);
+
 			if (inputEvent.type == SDL_TEXTINPUT)
 			{
 				if (editor.editTextFlag)
--- a/src/ft2_video.c
+++ b/src/ft2_video.c
@@ -717,10 +717,10 @@
 	if (time64 < timeNext64)
 	{
 		time64 = timeNext64 - time64;
-		if (time64 > UINT32_MAX)
-			time64 = UINT32_MAX;
+		if (time64 > INT32_MAX)
+			time64 = INT32_MAX;
 
-		const uint32_t diff32 = (uint32_t)time64;
+		const int32_t diff32 = (int32_t)time64;
 
 		// convert and round to microseconds
 		const int32_t time32 = (int32_t)((diff32 * editor.dPerfFreqMulMicro) + 0.5);