foxygit / fake-08-xbox360 Log in
commit 5e2e981ca0dabbbe5aeb4aff5037a8056cea0338
Author:     jtothebell <j.to.the.bell@gmail.com>
AuthorDate: Sat Aug 7 18:56:00 2021 -0600
Commit:     jtothebell <j.to.the.bell@gmail.com>
CommitDate: Sat Aug 7 18:56:00 2021 -0600

    get sdl desktop host partially working again
---
 Makefile                              |  2 +-
 platform/SDL1_2/Makefile              |  2 +-
 platform/SDL1_2/source/SDL1_2Host.cpp | 27 +++++++++++++++++----------
 3 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/Makefile b/Makefile
index fa61219..d54598e 100644
--- a/Makefile
+++ b/Makefile
@@ -19,7 +19,7 @@ export INCLUDES  = ../../include ../../libs/z8lua ../../libs/utf8-util ../../lib

 all: 3ds switch wiiu sdl2

-clean: clean-tests clean-3ds clean-switch clean-wiiu clean-vita clean-sdl2
+clean: clean-tests clean-3ds clean-switch clean-wiiu clean-vita clean-sdl2 clean-sdl

 clean-3ds:
 	@$(MAKE) -C platform/3ds clean
diff --git a/platform/SDL1_2/Makefile b/platform/SDL1_2/Makefile
index bd8b382..cf77b16 100644
--- a/platform/SDL1_2/Makefile
+++ b/platform/SDL1_2/Makefile
@@ -21,7 +21,7 @@ CFLAGS	:=	-g -Wall -O2 -ffunction-sections \

 CFLAGS	+=	$(INCLUDE)

-CXXFLAGS	:= $(CFLAGS) -fno-rtti -fexceptions -std=gnu++11
+CXXFLAGS	:= $(CFLAGS) -fno-rtti -fexceptions -std=gnu++17

 LIBS	:= -lSDL -lSDL_gfx

diff --git a/platform/SDL1_2/source/SDL1_2Host.cpp b/platform/SDL1_2/source/SDL1_2Host.cpp
index 43854a4..21e4ba4 100644
--- a/platform/SDL1_2/source/SDL1_2Host.cpp
+++ b/platform/SDL1_2/source/SDL1_2Host.cpp
@@ -17,8 +17,8 @@ using namespace std;
 #include <SDL/SDL.h>
 #include <SDL/SDL_gfxBlitFunc.h>

-#define SCREEN_SIZE_X 512
-#define SCREEN_SIZE_Y 512
+#define SCREEN_SIZE_X 320
+#define SCREEN_SIZE_Y 240


 #define SAMPLERATE 22050
@@ -76,7 +76,7 @@ void postFlipFunction(){
     //    printf("blit failed : %d\n", res);
     //}

-    SDL_UpdateRect(window, 0, 0, 0, 0);
+    SDL_Flip(window);
 }


@@ -121,8 +121,12 @@ void audioSetup(){
 }


-Host::Host() { }
+Host::Host() {
+    std::string home = getenv("HOME");
+
+    _cartDirectory = home + "/p8carts";

+ }

 void Host::oneTimeSetup(Color* paletteColors, Audio* audio){
     if (SDL_Init(SDL_INIT_VIDEO) != 0)
@@ -133,7 +137,7 @@ void Host::oneTimeSetup(Color* paletteColors, Audio* audio){

     SDL_WM_SetCaption("FAKE-08", NULL);

-    int flags = SDL_HWSURFACE;
+    int flags = SDL_SWSURFACE;

     window = SDL_SetVideoMode(SCREEN_SIZE_X, SCREEN_SIZE_Y, 0, flags);

@@ -158,8 +162,8 @@ void Host::oneTimeSetup(Color* paletteColors, Audio* audio){
     SrcR.w = PicoScreenWidth;
     SrcR.h = PicoScreenHeight;

-    DestR.x = 0;
-    DestR.y = 0;
+    DestR.x = 96;
+    DestR.y = 56;
     DestR.w = SCREEN_SIZE_X;
     DestR.h = SCREEN_SIZE_Y;
 }
@@ -236,11 +240,10 @@ void Host::waitForTargetFps(){
 }


-void Host::drawFrame(uint8_t* picoFb, uint8_t* screenPaletteMap){
-
+void Host::drawFrame(uint8_t* picoFb, uint8_t* screenPaletteMap, uint8_t drawMode){
     pixels = texture->pixels;

-    for (int y = 0; y < PicoScreenHeight; y ++){
+    for (int y = 0; y < (PicoScreenHeight - 8); y ++){
         for (int x = 0; x < PicoScreenWidth; x ++){
             uint8_t c = getPixelNibble(x, y, picoFb);
             Color col = _paletteColors[screenPaletteMap[c]];
@@ -314,3 +317,7 @@ std::string Host::customBiosLua() {
         "exitbtn = \"close window\""
         "sizebtn = \"\"";
 }
+
+std::string Host::getCartDirectory() {
+    return _cartDirectory;
+}