Skip to content

Commit

Permalink
WiiU port is now working.
Browse files Browse the repository at this point in the history
  • Loading branch information
MaikelChan committed May 14, 2022
1 parent 97b278b commit d883afb
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 deletions.
1 change: 0 additions & 1 deletion PlumbersDontWearTies/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ bool Renderer::Initialize(SDL_Window* window, const std::string fontPath)

// Initialize SDL renderer

SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengles2");
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
if (renderer == nullptr)
{
Expand Down
30 changes: 23 additions & 7 deletions PlumbersDontWearTies/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@

#include <iostream>

//#include <switch.h>

constexpr const char* BASE_DATA_PATH = "sdmc:/PlumbersDontWearTies/";
#include <whb/proc.h>
#include <whb/sdcard.h>

int main(int argc, char** args)
{
Expand All @@ -23,7 +22,7 @@ int main(int argc, char** args)

// Create window

SDL_Window* window = SDL_CreateWindow("Plumbers Don't Wear Ties", 0, 0, 1920, 1080, 0);
SDL_Window* window = SDL_CreateWindow("Plumbers Don't Wear Ties", 0, 0, 1280, 720, 0);

if (window == nullptr)
{
Expand All @@ -32,9 +31,23 @@ int main(int argc, char** args)
return EXIT_FAILURE;
}

// Initialize SD card

if (!WHBMountSdCard())
{
Log::Print(LogTypes::Critical, "Could not mount SD card.");
SDL_Quit();
return EXIT_FAILURE;
}

char *sdRootPath = WHBGetSdCardMountPath();
Log::Print(LogTypes::Info, "SD root path: %s", sdRootPath);
char path[256];
sprintf(path, "%s/PlumbersDontWearTies/", sdRootPath);

// Initialize renderer

if (!Renderer::Initialize(window, std::string(BASE_DATA_PATH) + "Font.ttf"))
if (!Renderer::Initialize(window, std::string(path) + "Font.ttf"))
{
SDL_Quit();
return EXIT_FAILURE;
Expand All @@ -61,12 +74,12 @@ int main(int argc, char** args)

// Initialize the game

Game* game = new Game(BASE_DATA_PATH);
Game* game = new Game(std::string(path));
game->Start();

Uint64 previousTime = SDL_GetPerformanceCounter();

while (game->IsRunning())
while (game->IsRunning() && WHBProcIsRunning())
{
SDL_Event event;
while (SDL_PollEvent(&event))
Expand All @@ -86,9 +99,11 @@ int main(int argc, char** args)
game->Stop();
break;
case JOY_DOWN:
case DPAD_DOWN:
game->SelectNextDecision();
break;
case JOY_UP:
case DPAD_UP:
game->SelectPreviousDecision();
break;
case JOY_A:
Expand All @@ -115,6 +130,7 @@ int main(int argc, char** args)
SDL_JoystickClose(joystick);
Audio::Dispose();
Renderer::Dispose();
WHBUnmountSdCard();
SDL_DestroyWindow(window);
SDL_Quit();

Expand Down
24 changes: 14 additions & 10 deletions PlumbersDontWearTies/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@
// Button mapping:
// https://github.com/devkitPro/SDL/blob/switch-sdl2/src/joystick/switch/SDL_sysjoystick.c#L52

#define JOY_A 0
#define JOY_B 1
#define JOY_X 2
#define JOY_Y 3
#define JOY_PLUS 10
#define JOY_MINUS 11
#define JOY_LEFT 12
#define JOY_UP 13
#define JOY_RIGHT 14
#define JOY_DOWN 15
#define JOY_A 0
#define JOY_B 1
#define JOY_X 2
#define JOY_Y 3
#define JOY_PLUS 10
#define JOY_MINUS 11
#define DPAD_LEFT 12
#define DPAD_UP 13
#define DPAD_RIGHT 14
#define DPAD_DOWN 15
#define JOY_LEFT 16
#define JOY_UP 17
#define JOY_RIGHT 18
#define JOY_DOWN 19

int main(int argc, char** args);

0 comments on commit d883afb

Please sign in to comment.