foxygit / fake-08-xbox360 Log in
commit 14ff3591b637a63652014cd649e8545266bd7827
Author:     jtothebell <j.to.the.bell@gmail.com>
AuthorDate: Fri Apr 23 20:19:30 2021 -0600
Commit:     jtothebell <j.to.the.bell@gmail.com>
CommitDate: Fri Apr 23 20:19:30 2021 -0600

    Honor draw modes on Wii U

    also rename variable to drawmode on other platforms
---
 platform/3ds/source/3dsHost.cpp             |  4 +-
 platform/SDL2Common/source/sdl2basehost.cpp |  4 +-
 platform/wiiu/source/WiiUHost.cpp           | 86 +++++++++++++++++++++++++++--
 source/host.h                               |  2 +-
 4 files changed, 87 insertions(+), 9 deletions(-)

diff --git a/platform/3ds/source/3dsHost.cpp b/platform/3ds/source/3dsHost.cpp
index 8e83bb0..08bdc59 100644
--- a/platform/3ds/source/3dsHost.cpp
+++ b/platform/3ds/source/3dsHost.cpp
@@ -493,7 +493,7 @@ void Host::waitForTargetFps(){
 }


-void Host::drawFrame(uint8_t* picoFb, uint8_t* screenPaletteMap, uint8_t screenMode){
+void Host::drawFrame(uint8_t* picoFb, uint8_t* screenPaletteMap, uint8_t drawMode){
     size_t pixIdx = 0;

     for (pixIdx = 0; pixIdx < pico_pixel_buffer_size; pixIdx++){
@@ -517,7 +517,7 @@ void Host::drawFrame(uint8_t* picoFb, uint8_t* screenPaletteMap, uint8_t screenM
     flipHorizontal = 1;
     flipVertical = 1;

-    switch(screenMode){
+    switch(drawMode){
         case 1:
             screenModeScaleX = 2.0f;
             screenModeScaleY = 1.0f;
diff --git a/platform/SDL2Common/source/sdl2basehost.cpp b/platform/SDL2Common/source/sdl2basehost.cpp
index a24eb6b..417805d 100644
--- a/platform/SDL2Common/source/sdl2basehost.cpp
+++ b/platform/SDL2Common/source/sdl2basehost.cpp
@@ -298,7 +298,7 @@ void Host::waitForTargetFps(){
 }


-void Host::drawFrame(uint8_t* picoFb, uint8_t* screenPaletteMap, uint8_t screenMode){
+void Host::drawFrame(uint8_t* picoFb, uint8_t* screenPaletteMap, uint8_t drawMode){
     //clear screen to all black
     SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0);
     SDL_RenderClear(renderer);
@@ -321,7 +321,7 @@ void Host::drawFrame(uint8_t* picoFb, uint8_t* screenPaletteMap, uint8_t screenM
     SrcR.x = 0;
     SrcR.y = 0;

-    switch(screenMode){
+    switch(drawMode){
         case 1:
             SrcR.w = 64;
             SrcR.h = PicoScreenHeight;
diff --git a/platform/wiiu/source/WiiUHost.cpp b/platform/wiiu/source/WiiUHost.cpp
index bcf588d..71ed7a3 100644
--- a/platform/wiiu/source/WiiUHost.cpp
+++ b/platform/wiiu/source/WiiUHost.cpp
@@ -71,6 +71,9 @@ SDL_Event event;
 SDL_Renderer *renderer;
 SDL_Texture *texture = NULL;
 SDL_Rect DestR;
+SDL_Rect SrcR;
+double textureAngle;
+SDL_RendererFlip flip;
 SDL_AudioSpec want, have;
 SDL_AudioDeviceID dev;
 void *pixels;
@@ -84,10 +87,8 @@ SDL_Point touchLocation = { 128 / 2, 128 / 2 };
 void postFlipFunction(){
     //flush switch frame buffers
     // We're done rendering, so we end the frame here.
-
-
     SDL_UnlockTexture(texture);
-    SDL_RenderCopy(renderer, texture, NULL, &DestR);
+    SDL_RenderCopyEx(renderer, texture, &SrcR, &DestR, textureAngle, NULL, flip);

     SDL_RenderPresent(renderer);
 }
@@ -156,6 +157,14 @@ void _changeStretch(StretchOption newStretch){
     DestR.y = WIN_HEIGHT / 2 - screenHeight / 2;
     DestR.w = screenWidth;
     DestR.h = screenHeight;
+
+    SrcR.x = 0;
+    SrcR.y = 0;
+    SrcR.w = PicoScreenWidth;
+    SrcR.h = PicoScreenHeight;
+
+    textureAngle = 0;
+    flip = SDL_FLIP_NONE;
 }

 Host::Host() {
@@ -400,7 +409,7 @@ void Host::waitForTargetFps(){
 }


-void Host::drawFrame(uint8_t* picoFb, uint8_t* screenPaletteMap){
+void Host::drawFrame(uint8_t* picoFb, uint8_t* screenPaletteMap, uint8_t drawMode){
     //clear screen to all black
     SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0);
     SDL_RenderClear(renderer);
@@ -419,6 +428,75 @@ void Host::drawFrame(uint8_t* picoFb, uint8_t* screenPaletteMap){
             base[3] = col.Alpha;
         }
     }
+
+
+    SrcR.x = 0;
+    SrcR.y = 0;
+
+    switch(drawMode){
+        case 1:
+            SrcR.w = 64;
+            SrcR.h = PicoScreenHeight;
+            textureAngle = 0;
+            flip = SDL_FLIP_NONE;
+            break;
+        case 2:
+            SrcR.w = PicoScreenWidth;
+            SrcR.h = 64;
+            textureAngle = 0;
+            flip = SDL_FLIP_NONE;
+            break;
+        case 3:
+            SrcR.w = 64;
+            SrcR.h = 64;
+            textureAngle = 0;
+            flip = SDL_FLIP_NONE;
+            break;
+        //todo: mirroring
+        //case 4,6,7
+        case 129:
+            SrcR.w = PicoScreenWidth;
+            SrcR.h = PicoScreenHeight;
+            textureAngle = 0;
+            flip = SDL_FLIP_HORIZONTAL;
+            break;
+        case 130:
+            SrcR.w = PicoScreenWidth;
+            SrcR.h = PicoScreenHeight;
+            textureAngle = 0;
+            flip = SDL_FLIP_VERTICAL;
+            break;
+        case 131:
+            SrcR.w = PicoScreenWidth;
+            SrcR.h = PicoScreenHeight;
+            textureAngle = 0;
+            flip = (SDL_RendererFlip)(SDL_FLIP_HORIZONTAL | SDL_FLIP_VERTICAL);
+            break;
+        case 133:
+            SrcR.w = PicoScreenWidth;
+            SrcR.h = PicoScreenHeight;
+            textureAngle = 90;
+            flip = SDL_FLIP_NONE;
+            break;
+        case 134:
+            SrcR.w = PicoScreenWidth;
+            SrcR.h = PicoScreenHeight;
+            textureAngle = 180;
+            flip = SDL_FLIP_NONE;
+            break;
+        case 135:
+            SrcR.w = PicoScreenWidth;
+            SrcR.h = PicoScreenHeight;
+            textureAngle = 270;
+            flip = SDL_FLIP_NONE;
+            break;
+        default:
+            SrcR.w = PicoScreenWidth;
+            SrcR.h = PicoScreenHeight;
+            textureAngle = 0;
+            flip = SDL_FLIP_NONE;
+            break;
+    }


     postFlipFunction();
diff --git a/source/host.h b/source/host.h
index 9bd8a5b..f22b806 100644
--- a/source/host.h
+++ b/source/host.h
@@ -54,7 +54,7 @@ class Host {

     void waitForTargetFps();

-    void drawFrame(uint8_t* picoFb, uint8_t* screenPaletteMap, uint8_t screenMode);
+    void drawFrame(uint8_t* picoFb, uint8_t* screenPaletteMap, uint8_t drawMode);

     bool shouldFillAudioBuff();
     void* getAudioBufferPointer();