Skip to content

Commit

Permalink
Fullscreen mode code refactoring (fixes issues)
Browse files Browse the repository at this point in the history
  • Loading branch information
8bitbubsy committed Mar 18, 2024
1 parent d8e9f47 commit 1997f3e
Show file tree
Hide file tree
Showing 14 changed files with 310 additions and 241 deletions.
17 changes: 3 additions & 14 deletions release/macos/protracker.ini
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
; 1X = 320x255 (no scaling)
; 2X = 640x510
; 3X = 960x765
; 4x = 1280x1020
; 4X = 1280x1020
; ...and so on up to 16X
; (width = 320*x, height = 255*x)
;
Expand All @@ -57,26 +57,15 @@ FULLSCREEN=FALSE
; Syntax: NEAREST, LINEAR, BEST
; Default value: NEAREST
; Comment: Setting it to LINEAR or BEST will smooth out the pixels
; and make them less grainy.
; and make them less grainy. It will result in a blurry image, though.
;
PIXELFILTER=NEAREST

; Integer scaling of pixels
; Syntax: TRUE or FALSE
; Default value: TRUE
; Comment: If the image is not completely stretched out vertically
; in fullscreen mode, disabling this option will make it do so.
; The aspect ratio will be maintained. However, the pixels might not
; look perfect. This is best used together with PIXELFILTER=LINEAR
; (or BEST). The image will look blurry though...
;
INTEGERSCALING=TRUE

; Make fullscreen mode completely stretch out the image to fit the whole screen
; Syntax: TRUE or FALSE
; Default value: FALSE
; Comment: Setting this to TRUE will in most cases ruin the aspect
; ratio of the image. Please look at the INTEGERSCALING option as well.
; ratio of the image.
;
FULLSCREENSTRETCH=FALSE

Expand Down
17 changes: 3 additions & 14 deletions release/other/protracker.ini
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
; 1X = 320x255 (no scaling)
; 2X = 640x510
; 3X = 960x765
; 4x = 1280x1020
; 4X = 1280x1020
; ...and so on up to 16X
; (width = 320*x, height = 255*x)
;
Expand All @@ -57,26 +57,15 @@ FULLSCREEN=FALSE
; Syntax: NEAREST, LINEAR, BEST
; Default value: NEAREST
; Comment: Setting it to LINEAR or BEST will smooth out the pixels
; and make them less grainy.
; and make them less grainy. It will result in a blurry image, though.
;
PIXELFILTER=NEAREST

; Integer scaling of pixels
; Syntax: TRUE or FALSE
; Default value: TRUE
; Comment: If the image is not completely stretched out vertically
; in fullscreen mode, disabling this option will make it do so.
; The aspect ratio will be maintained. However, the pixels might not
; look perfect. This is best used together with PIXELFILTER=LINEAR
; (or BEST). The image will look blurry though...
;
INTEGERSCALING=TRUE

; Make fullscreen mode completely stretch out the image to fit the whole screen
; Syntax: TRUE or FALSE
; Default value: FALSE
; Comment: Setting this to TRUE will in most cases ruin the aspect
; ratio of the image. Please look at the INTEGERSCALING option as well.
; ratio of the image.
;
FULLSCREENSTRETCH=FALSE

Expand Down
17 changes: 3 additions & 14 deletions release/win32/protracker.ini
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
; 1X = 320x255 (no scaling)
; 2X = 640x510
; 3X = 960x765
; 4x = 1280x1020
; 4X = 1280x1020
; ...and so on up to 16X
; (width = 320*x, height = 255*x)
;
Expand All @@ -57,26 +57,15 @@ FULLSCREEN=FALSE
; Syntax: NEAREST, LINEAR, BEST
; Default value: NEAREST
; Comment: Setting it to LINEAR or BEST will smooth out the pixels
; and make them less grainy.
; and make them less grainy. It will result in a blurry image, though.
;
PIXELFILTER=NEAREST

; Integer scaling of pixels
; Syntax: TRUE or FALSE
; Default value: TRUE
; Comment: If the image is not completely stretched out vertically
; in fullscreen mode, disabling this option will make it do so.
; The aspect ratio will be maintained. However, the pixels might not
; look perfect. This is best used together with PIXELFILTER=LINEAR
; (or BEST). The image will look blurry though...
;
INTEGERSCALING=TRUE

; Make fullscreen mode completely stretch out the image to fit the whole screen
; Syntax: TRUE or FALSE
; Default value: FALSE
; Comment: Setting this to TRUE will in most cases ruin the aspect
; ratio of the image. Please look at the INTEGERSCALING option as well.
; ratio of the image.
;
FULLSCREENSTRETCH=FALSE

Expand Down
17 changes: 3 additions & 14 deletions release/win64/protracker.ini
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
; 1X = 320x255 (no scaling)
; 2X = 640x510
; 3X = 960x765
; 4x = 1280x1020
; 4X = 1280x1020
; ...and so on up to 16X
; (width = 320*x, height = 255*x)
;
Expand All @@ -57,26 +57,15 @@ FULLSCREEN=FALSE
; Syntax: NEAREST, LINEAR, BEST
; Default value: NEAREST
; Comment: Setting it to LINEAR or BEST will smooth out the pixels
; and make them less grainy.
; and make them less grainy. It will result in a blurry image, though.
;
PIXELFILTER=NEAREST

; Integer scaling of pixels
; Syntax: TRUE or FALSE
; Default value: TRUE
; Comment: If the image is not completely stretched out vertically
; in fullscreen mode, disabling this option will make it do so.
; The aspect ratio will be maintained. However, the pixels might not
; look perfect. This is best used together with PIXELFILTER=LINEAR
; (or BEST). The image will look blurry though...
;
INTEGERSCALING=TRUE

; Make fullscreen mode completely stretch out the image to fit the whole screen
; Syntax: TRUE or FALSE
; Default value: FALSE
; Comment: Setting this to TRUE will in most cases ruin the aspect
; ratio of the image. Please look at the INTEGERSCALING option as well.
; ratio of the image.
;
FULLSCREENSTRETCH=FALSE

Expand Down
11 changes: 11 additions & 0 deletions src/pt2_askbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ uint32_t askBox(uint32_t dialogType, const char *statusText)
{
SDL_Event event;

beginFPSCounter();
sinkVisualizerBars();
updateChannelSyncBuffer();
readMouseXY();
Expand Down Expand Up @@ -408,13 +409,22 @@ uint32_t askBox(uint32_t dialogType, const char *statusText)
}
else if (event.type == SDL_MOUSEBUTTONUP)
{
#if defined __APPLE__ && defined __aarch64__
armMacGhostMouseCursorFix();
#endif
mouse.buttonWaitCounter = 0;
mouse.buttonWaiting = false;
buttonToRepeat = -1;

if (event.button.button == SDL_BUTTON_LEFT)
mouse.leftButtonPressed = false;
}
#if defined __APPLE__ && defined __aarch64__
else if (event.type == SDL_MOUSEMOTION)
{
armMacGhostMouseCursorFix();
}
#endif
}

if (!mouse.buttonWaiting && buttonToRepeat > -1)
Expand All @@ -437,6 +447,7 @@ uint32_t askBox(uint32_t dialogType, const char *statusText)
updateMouseCounters();
renderFrame2();
flipFrame();
endFPSCounter();
}

mouse.leftButtonPressed = false;
Expand Down
2 changes: 1 addition & 1 deletion src/pt2_header.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "pt2_unicode.h"
#include "pt2_palette.h"

#define PROG_VER_STR "1.66"
#define PROG_VER_STR "1.67"

#ifdef _WIN32
#define DIR_DELIMITER '\\'
Expand Down
24 changes: 15 additions & 9 deletions src/pt2_keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,6 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode)
if (scancode == SDL_SCANCODE_F11 && !keyb.leftAltPressed)
{
toggleFullscreen();

// prevent fullscreen toggle from firing twice on certain SDL2 Linux ports
#ifdef __unix__
SDL_Delay(100);
#endif
return;
}

Expand Down Expand Up @@ -2071,12 +2066,23 @@ void keyDownHandler(SDL_Scancode scancode, SDL_Keycode keycode)
}
else if (keyb.leftCtrlPressed)
{
toggleLEDFilter();
if (keyb.shiftPressed)
{
resetFPSCounter();

if (audio.ledFilterEnabled)
displayMsg("LED FILTER ON");
video.debug ^= 1;
if (!video.debug)
displayMainScreen();
}
else
displayMsg("LED FILTER OFF");
{
toggleLEDFilter();

if (audio.ledFilterEnabled)
displayMsg("LED FILTER ON");
else
displayMsg("LED FILTER OFF");
}
}
else if (keyb.leftAltPressed)
{
Expand Down
11 changes: 11 additions & 0 deletions src/pt2_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ int main(int argc, char *argv[])
// XXX: if you change anything in the main loop, make sure it goes in the askBox()(pt2_askbox.c) loop too, if needed
while (editor.programRunning)
{
beginFPSCounter();
handleThreadedAskBox();
sinkVisualizerBars();
updateChannelSyncBuffer();
Expand All @@ -364,6 +365,7 @@ int main(int argc, char *argv[])

renderFrame();
flipFrame();
endFPSCounter();
}

cleanUp();
Expand Down Expand Up @@ -448,6 +450,9 @@ static void handleInput(void)
}
else if (event.type == SDL_MOUSEBUTTONUP)
{
#if defined __APPLE__ && defined __aarch64__
armMacGhostMouseCursorFix();
#endif
mouseButtonUpHandler(event.button.button);

if (ui.introTextShown)
Expand All @@ -463,6 +468,12 @@ static void handleInput(void)
if (ui.sampleMarkingPos == -1 && !ui.forceSampleDrag && !ui.forceVolDrag && !ui.forceSampleEdit)
mouseButtonDownHandler(event.button.button);
}
#if defined __APPLE__ && defined __aarch64__
else if (event.type == SDL_MOUSEMOTION)
{
armMacGhostMouseCursorFix();
}
#endif

if (ui.throwExit)
{
Expand Down

0 comments on commit 1997f3e

Please sign in to comment.