ref: 25984213e8b3e751e3bc5840c8ad13042ac21b42
parent: 527d14082914c733a5f60d7361db69897cc761d3
author: Olav Sørensen <olav.sorensen@live.no>
date: Mon May 11 17:06:31 EDT 2020
Pushed v1.16 code - Added two new entries to protracker.ini: FULLSCREEN (start in fullscreen mode) PIXELFILTER (smooth out upscaled pixels to make them less grainy) - Linux: Fixed the mouse not working with KMSDRM (hopefully) (also we don't really need doubles for mouse coord scaling, so we use floats instead)
--- a/release/macos/protracker.ini
+++ b/release/macos/protracker.ini
@@ -28,6 +28,20 @@
;
VIDEOSCALE=2X
+; Start in fullscreen mode
+; Syntax: TRUE or FALSE
+; Default value: FALSE
+;
+FULLSCREEN=FALSE
+
+; Filtering of upscaled pixels
+; Syntax: NEAREST, LINEAR, BEST
+; Default value: NEAREST
+; Comment: Setting it to LINEAR or BEST will smooth out the pixels
+; and make them less grainy.
+;
+PIXELFILTER=NEAREST
+
; Turn off vsync
; Syntax: TRUE or FALSE
; Default value: FALSE
@@ -41,10 +55,12 @@
; Default value: TRUE
; Comment: Disables software mouse and uses the mouse in your OS.
; This can feel more comfortable for some users because of less latency.
+; Some systems might need it to be set FALSE for the mouse to function
+; at all.
;
HWMOUSE=TRUE
-; Make fullscreen mode stretch out the image (will often look bad)
+; Make fullscreen mode stretch out the image to fit the whole screen
; Syntax: TRUE or FALSE
; Default value: FALSE
;
--- a/release/other/known bugs.txt
+++ b/release/other/known bugs.txt
@@ -1,4 +1,4 @@
-Windows (and probably Linux?):
+Windows (and possibly Linux?):
- The num lock key (which is used to set the current sample to 1 or 17) will
also toggle the num lock state, which means that some of the numpad keys
work like arrow keys instead. This makes the drumpad function useless! I
--- a/release/other/protracker.ini
+++ b/release/other/protracker.ini
@@ -28,6 +28,20 @@
;
VIDEOSCALE=2X
+; Start in fullscreen mode
+; Syntax: TRUE or FALSE
+; Default value: FALSE
+;
+FULLSCREEN=FALSE
+
+; Filtering of upscaled pixels
+; Syntax: NEAREST, LINEAR, BEST
+; Default value: NEAREST
+; Comment: Setting it to LINEAR or BEST will smooth out the pixels
+; and make them less grainy.
+;
+PIXELFILTER=NEAREST
+
; Turn off vsync
; Syntax: TRUE or FALSE
; Default value: FALSE
@@ -41,10 +55,12 @@
; Default value: TRUE
; Comment: Disables software mouse and uses the mouse in your OS.
; This can feel more comfortable for some users because of less latency.
+; Some systems might need it to be set FALSE for the mouse to function
+; at all.
;
HWMOUSE=TRUE
-; Make fullscreen mode stretch out the image (will often look bad)
+; Make fullscreen mode stretch out the image to fit the whole screen
; Syntax: TRUE or FALSE
; Default value: FALSE
;
--- a/release/win32/known bugs.txt
+++ b/release/win32/known bugs.txt
@@ -1,4 +1,4 @@
-Windows (and probably Linux?):
+Windows (and possibly Linux?):
- The num lock key (which is used to set the current sample to 1 or 17) will
also toggle the num lock state, which means that some of the numpad keys
work like arrow keys instead. This makes the drumpad function useless! I
--- a/release/win32/protracker.ini
+++ b/release/win32/protracker.ini
@@ -28,6 +28,20 @@
;
VIDEOSCALE=2X
+; Start in fullscreen mode
+; Syntax: TRUE or FALSE
+; Default value: FALSE
+;
+FULLSCREEN=FALSE
+
+; Filtering of upscaled pixels
+; Syntax: NEAREST, LINEAR, BEST
+; Default value: NEAREST
+; Comment: Setting it to LINEAR or BEST will smooth out the pixels
+; and make them less grainy.
+;
+PIXELFILTER=NEAREST
+
; Turn off vsync
; Syntax: TRUE or FALSE
; Default value: FALSE
@@ -41,10 +55,12 @@
; Default value: TRUE
; Comment: Disables software mouse and uses the mouse in your OS.
; This can feel more comfortable for some users because of less latency.
+; Some systems might need it to be set FALSE for the mouse to function
+; at all.
;
HWMOUSE=TRUE
-; Make fullscreen mode stretch out the image (will often look bad)
+; Make fullscreen mode stretch out the image to fit the whole screen
; Syntax: TRUE or FALSE
; Default value: FALSE
;
--- a/release/win64/known bugs.txt
+++ b/release/win64/known bugs.txt
@@ -1,4 +1,4 @@
-Windows (and probably Linux?):
+Windows (and possibly Linux?):
- The num lock key (which is used to set the current sample to 1 or 17) will
also toggle the num lock state, which means that some of the numpad keys
work like arrow keys instead. This makes the drumpad function useless! I
--- a/release/win64/protracker.ini
+++ b/release/win64/protracker.ini
@@ -28,6 +28,20 @@
;
VIDEOSCALE=2X
+; Start in fullscreen mode
+; Syntax: TRUE or FALSE
+; Default value: FALSE
+;
+FULLSCREEN=FALSE
+
+; Filtering of upscaled pixels
+; Syntax: NEAREST, LINEAR, BEST
+; Default value: NEAREST
+; Comment: Setting it to LINEAR or BEST will smooth out the pixels
+; and make them less grainy.
+;
+PIXELFILTER=NEAREST
+
; Turn off vsync
; Syntax: TRUE or FALSE
; Default value: FALSE
@@ -41,10 +55,12 @@
; Default value: TRUE
; Comment: Disables software mouse and uses the mouse in your OS.
; This can feel more comfortable for some users because of less latency.
+; Some systems might need it to be set FALSE for the mouse to function
+; at all.
;
HWMOUSE=TRUE
-; Make fullscreen mode stretch out the image (will often look bad)
+; Make fullscreen mode stretch out the image to fit the whole screen
; Syntax: TRUE or FALSE
; Default value: FALSE
;
--- a/src/pt2_config.c
+++ b/src/pt2_config.c
@@ -62,6 +62,8 @@
config.vsyncOff = false;
config.hwMouse = true;
config.sampleLowpass = true;
+ config.startInFullscreen = false;
+ config.pixelFilter = PIXELFILTER_NEAREST;
#ifndef _WIN32
getcwd(oldCwd, PATH_MAX);
@@ -229,6 +231,21 @@
{
if (!_strnicmp(&configLine[16], "TRUE", 4)) config.autoCloseDiskOp = true;
else if (!_strnicmp(&configLine[16], "FALSE", 5)) config.autoCloseDiskOp = false;
+ }
+
+ // FULLSCREEN
+ else if (!_strnicmp(configLine, "FULLSCREEN=", 11))
+ {
+ if (!_strnicmp(&configLine[11], "TRUE", 4)) config.startInFullscreen = true;
+ else if (!_strnicmp(&configLine[11], "FALSE", 5)) config.startInFullscreen = false;
+ }
+
+ // PIXELFILTER
+ else if (!_strnicmp(configLine, "PIXELFILTER=", 12))
+ {
+ if (!_strnicmp(&configLine[12], "NEAREST", 7)) config.pixelFilter = PIXELFILTER_NEAREST;
+ else if (!_strnicmp(&configLine[12], "LINEAR", 6)) config.pixelFilter = PIXELFILTER_LINEAR;
+ else if (!_strnicmp(&configLine[12], "BEST", 4)) config.pixelFilter = PIXELFILTER_BEST;
}
// COMPOMODE
--- a/src/pt2_config.h
+++ b/src/pt2_config.h
@@ -3,13 +3,21 @@
#include <stdint.h>
#include <stdbool.h>
+enum
+{
+ PIXELFILTER_NEAREST = 0,
+ PIXELFILTER_LINEAR = 1,
+ PIXELFILTER_BEST = 2
+};
+
typedef struct config_t
{
char *defModulesDir, *defSamplesDir;
bool dottedCenterFlag, pattDots, a500LowPassFilter, compoMode, autoCloseDiskOp, hideDiskOpDates, hwMouse;
bool transDel, fullScreenStretch, vsyncOff, modDot, blankZeroFlag, realVuMeters, rememberPlayMode;
- bool sampleLowpass;
+ bool sampleLowpass, startInFullscreen;
int8_t stereoSeparation, videoScaleFactor, accidental;
+ uint8_t pixelFilter;
uint16_t quantizeValue;
uint32_t soundFrequency, soundBufferSize;
} config_t;
--- a/src/pt2_header.h
+++ b/src/pt2_header.h
@@ -14,7 +14,7 @@
#include "pt2_unicode.h"
#include "pt2_palette.h"
-#define PROG_VER_STR "1.15"
+#define PROG_VER_STR "1.16"
#ifdef _WIN32
#define DIR_DELIMITER '\\'
--- a/src/pt2_main.c
+++ b/src/pt2_main.c
@@ -296,6 +296,9 @@
SDL_ShowWindow(video.window);
+ if (config.startInFullscreen)
+ toggleFullScreen();
+
changePathToHome(); // set path to home/user-dir now
diskOpSetInitPath(); // set path to custom path in config (if present)
--- a/src/pt2_mouse.c
+++ b/src/pt2_mouse.c
@@ -234,8 +234,8 @@
void updateMouseScaling(void)
{
- if (video.renderW > 0) video.dMouseXMul = (double)SCREEN_W / video.renderW;
- if (video.renderH > 0) video.dMouseYMul = (double)SCREEN_H / video.renderH;
+ if (video.renderW > 0) video.fMouseXMul = (float)SCREEN_W / video.renderW;
+ if (video.renderH > 0) video.fMouseYMul = (float)SCREEN_H / video.renderH;
}
void readMouseXY(void)
@@ -251,7 +251,10 @@
return;
}
- mouse.buttonState = SDL_GetGlobalMouseState(&mx, &my);
+ if (video.useDesktopMouseCoords)
+ mouse.buttonState = SDL_GetGlobalMouseState(&mx, &my);
+ else
+ mouse.buttonState = SDL_GetMouseState(&mx, &my);
if (video.fullscreen)
{
@@ -298,7 +301,7 @@
my -= video.renderY;
}
}
- else
+ else if (video.useDesktopMouseCoords)
{
// convert desktop coords to window coords
@@ -310,8 +313,8 @@
}
// multiply coords by video upscaling factors (don't round)
- mouse.x = (int32_t)(mx * video.dMouseXMul);
- mouse.y = (int32_t)(my * video.dMouseYMul);
+ mouse.x = (int32_t)(mx * video.fMouseXMul);
+ mouse.y = (int32_t)(my * video.fMouseYMul);
if (config.hwMouse)
{
--- a/src/pt2_structs.h
+++ b/src/pt2_structs.h
@@ -121,10 +121,10 @@
typedef struct video_t
{
- bool fullscreen, vsync60HzPresent, windowHidden;
+ bool fullscreen, vsync60HzPresent, windowHidden, useDesktopMouseCoords;
int32_t renderX, renderY, renderW, renderH, displayW, displayH;
int32_t xScale, yScale;
- double dMouseXMul, dMouseYMul;
+ float fMouseXMul, fMouseYMul;
SDL_PixelFormat *pixelFormat;
uint32_t *frameBuffer, *frameBufferUnaligned;
--- a/src/pt2_visuals.c
+++ b/src/pt2_visuals.c
@@ -2554,7 +2554,12 @@
SDL_SetRenderDrawBlendMode(video.renderer, SDL_BLENDMODE_NONE);
- SDL_SetHint("SDL_RENDER_SCALE_QUALITY", "nearest");
+ if (config.pixelFilter == PIXELFILTER_LINEAR)
+ SDL_SetHint("SDL_RENDER_SCALE_QUALITY", "linear");
+ else if (config.pixelFilter == PIXELFILTER_BEST)
+ SDL_SetHint("SDL_RENDER_SCALE_QUALITY", "best");
+ else
+ SDL_SetHint("SDL_RENDER_SCALE_QUALITY", "nearest");
video.texture = SDL_CreateTexture(video.renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, SCREEN_W, SCREEN_H);
if (video.texture == NULL)
@@ -2584,6 +2589,12 @@
SDL_ShowCursor(SDL_TRUE);
else
SDL_ShowCursor(SDL_FALSE);
+
+ // Workaround: SDL_GetGlobalMouseState() doesn't work with KMSDRM
+ video.useDesktopMouseCoords = true;
+ const char *videoDriver = SDL_GetCurrentVideoDriver();
+ if (videoDriver != NULL && strcmp("KMSDRM", videoDriver) == 0)
+ video.useDesktopMouseCoords = false;
return true;
}
--- a/vs2019_project/pt2-clone/protracker.ini
+++ b/vs2019_project/pt2-clone/protracker.ini
@@ -28,6 +28,20 @@
;
VIDEOSCALE=2X
+; Start in fullscreen mode
+; Syntax: TRUE or FALSE
+; Default value: FALSE
+;
+FULLSCREEN=FALSE
+
+; Filtering of upscaled pixels
+; Syntax: NEAREST, LINEAR, BEST
+; Default value: NEAREST
+; Comment: Setting it to LINEAR or BEST will smooth out the pixels
+; and make them less grainy.
+;
+PIXELFILTER=NEAREST
+
; Turn off vsync
; Syntax: TRUE or FALSE
; Default value: FALSE
@@ -41,10 +55,12 @@
; Default value: TRUE
; Comment: Disables software mouse and uses the mouse in your OS.
; This can feel more comfortable for some users because of less latency.
+; Some systems might need it to be set FALSE for the mouse to function
+; at all.
;
HWMOUSE=TRUE
-; Make fullscreen mode stretch out the image (will often look bad)
+; Make fullscreen mode stretch out the image to fit the whole screen
; Syntax: TRUE or FALSE
; Default value: FALSE
;