Skip to content

Commit

Permalink
Add support for 4:3 aspect ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
olafkryus committed Dec 12, 2020
1 parent 396f551 commit d70868c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ some buffer overflows have been fixed.
| Alt+(Keypad) Plus | Increase window size |
| Alt+(Keypad) Minus | Decrease window size |
| Alt+R | Reset window if stretched |
| Alt+A | Toggle 4:3 aspect ratio |

## Build

Expand Down
15 changes: 13 additions & 2 deletions SDLPORT.PAS
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ implementation
xRes = 320;
yRes = 200;
targetFrames = 70;
aspect: real = xRes / yRes;
aspectRes: real = xRes / yRes;

var windowMultiplier: integer;
window: PSDL_Window;
Expand All @@ -41,6 +41,7 @@ implementation

windowResized: boolean;
fullScreen: boolean;
aspect: real;

timer: TSDL_TimerID;
frameCount, lastFrameCount, subFrameCount, lastFrameTick: LongInt;
Expand Down Expand Up @@ -92,7 +93,7 @@ end;

procedure ResetWindowSize;
begin
SDL_SetWindowSize(window, xRes * windowMultiplier, yRes * windowMultiplier);
SDL_SetWindowSize(window, xRes * windowMultiplier, Round(yRes * windowMultiplier * aspectRes / aspect));
windowResized := true;
end;

Expand All @@ -104,6 +105,7 @@ end;
procedure Init;
begin
windowMultiplier := 2;
aspect := aspectRes;

if SDL_Init( SDL_INIT_VIDEO or SDL_INIT_TIMER ) < 0 then HALT;

Expand Down Expand Up @@ -335,6 +337,15 @@ begin
exit
end;
end;
SDL_SCANCODE_A :
begin
if (aspect <> aspectRes) then
aspect := aspectRes
else
aspect := 4 / 3;
ResetWindowSize;
exit;
end;
end;
end;

Expand Down
1 change: 1 addition & 0 deletions SJ3.PAS
Original file line number Diff line number Diff line change
Expand Up @@ -5704,6 +5704,7 @@ begin
writeln(' * Alt+(Keypad) Plus : Increase window size');
writeln(' * Alt+(Keypad) Minus : Decrease window size');
writeln(' * Alt+R : Reset window if stretched');
writeln(' * Alt+A : Toggle 4:3 aspect ratio');
writeln('');
writeln('-------');
writeln('');
Expand Down

0 comments on commit d70868c

Please sign in to comment.