Skip to content

Commit

Permalink
Dynamically change resolutions for docked mode on Switch
Browse files Browse the repository at this point in the history
  • Loading branch information
sacredbanana committed Feb 18, 2019
1 parent 7a32dee commit 28f9dcb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
3.2.0: 2019-12-17
3.2.0: 2019-12-18
* New audio device selectable in the setup menu: Adlib random instruments. This will play
the music tracks with randomly selected instruments. If you don't like the instrument settings
you can select it again and it will load a different random set.
* Changing audio settings now no longer requires you to quit the game. All changes are immediate
* Switch - Now dynamically switches to 1080p from 720p when connecting to the dock and vice versa.
The setup menu will also reflect the current mode.

3.1.2: 2019-02-08
* Upgraded the Adlib emulator to Ken's 64 bit compatible one resolving all music issues
Expand Down
6 changes: 2 additions & 4 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ Nintendo Switch instructions:
* Install DevKitPro
* Compile this project with `make -f Makefile.Switch`.
* Copy all the .kzp and .dat files from Ken's Labyrinth and place them in
the folder that contains the nro file.
* Put the `settings_switch.ini` file from this repository and place it in the
folder that contains the nro file.
the folder that contains the nro file.

Improvements over the original Ken's Labyrinth:

- Runs natively on 32-bit Windows, Unix or Nintendo Switch.
- Runs natively on 32-bit/64-bit Windows, Unix or Nintendo Switch.
- Supports big-endian CPUs.
- Uses OpenGL to provide hardware accelerated, anti-aliased graphics with
trilinear interpolation in true colour (where available).
Expand Down
8 changes: 8 additions & 0 deletions setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,9 @@ void setupinputdevices(void) {
}

void setupsetfullscreen(void) {
#ifdef __SWITCH__
return;
#endif
selectionmenu(2, fullscreenmenu, &fullscr, NULL);
}

Expand Down Expand Up @@ -978,8 +981,13 @@ static void draw_mainmenu(void) {
n += 12; textprint(51,n,lab3dversion?32:34);
strcpy(textbuf,"Configure Input");
n += 12; textprint(51,n,lab3dversion?32:34);
#ifdef __SWITCH__
sprintf(textbuf,"Window size: %dx%d %s", screenwidth,
screenheight, appletGetOperationMode() == AppletOperationMode_Handheld ? "Handheld" : "Dock");
#else
sprintf(textbuf,"Window size: %dx%d", window_width,
window_height);
#endif
n += 12; textprint(51,n,64);
strcpy(textbuf,"Display type: ");
strcat(textbuf,fullscreenmenu[fullscr]);
Expand Down
15 changes: 8 additions & 7 deletions subs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2740,7 +2740,8 @@ void introduction(K_INT16 songnum)
#ifdef __SWITCH__
void configureResolution()
{
int width, height;
// Get current console status
appletMainLoop();

// Calculate the target resolution depending on the operation mode:
// - In handheld mode, we render at 720p (which is the native screen resolution).
Expand All @@ -2749,12 +2750,12 @@ void configureResolution()
{
default:
case AppletOperationMode_Handheld:
width = 1280;
height = 720;
screenwidth = 1280;
screenheight = 720;
break;
case AppletOperationMode_Docked:
width = 1920;
height = 1080;
screenwidth = 1920;
screenheight = 1080;
break;
}

Expand All @@ -2763,8 +2764,8 @@ void configureResolution()
// remain unused when rendering at a smaller resolution than the framebuffer).
// Note that glViewport expects the coordinates of the bottom-left corner of
// the viewport, so we have to calculate that too.
nwindowSetCrop(win, 0, 0, width, height);
glViewport(0, 1080-height, width, height);
nwindowSetCrop(win, 0, 0, screenwidth, screenheight);
glViewport(0, 1080-screenheight, screenwidth, screenheight);
}
#endif

Expand Down

0 comments on commit 28f9dcb

Please sign in to comment.