foxygit / fake-08-xbox360 Log in
commit d010227a7fa43a02aa993675abd3ef57f1f890d8
Author:     Jon Bell <j.to.the.bell@gmail.com>
AuthorDate: Wed Feb 2 20:05:44 2022 -0700
Commit:     Jon Bell <j.to.the.bell@gmail.com>
CommitDate: Wed Feb 2 20:05:44 2022 -0700

    WIP getting miyoomini building on desktop again
---
 platform/SDL1_2/Makefile                    | 16 +++++++++-
 platform/miyoomini/source/MiyooMiniHost.cpp | 46 +++++++++++++++++++++++++++--
 2 files changed, 58 insertions(+), 4 deletions(-)

diff --git a/platform/SDL1_2/Makefile b/platform/SDL1_2/Makefile
index 041f5f4..61d8344 100644
--- a/platform/SDL1_2/Makefile
+++ b/platform/SDL1_2/Makefile
@@ -8,9 +8,12 @@
 #---------------------------------------------------------------------------------
 TARGET		:=	FAKE08
 BUILD		:=	build
-SOURCES		:=	${SOURCES} ../miyoomini/source source
+SOURCES		:=	${SOURCES} source
 INCLUDES	:=	${INCLUDES}

+IMITATE		:= miyoomini
+#IMITATE		:= bittboy
+
 #---------------------------------------------------------------------------------
 # options for code generation
 #---------------------------------------------------------------------------------
@@ -32,6 +35,17 @@ LIBS	:= -lSDL

 LDFLAGS	:= $(LIBS)

+ifeq ($(IMITATE),miyoomini)
+
+SOURCES += ../miyoomini/source/MiyooMiniHost.cpp
+CXXFLAGS += -D_DESKTOP
+
+else
+
+SOURCES += ../bittboy/source
+
+endif
+

 #---------------------------------------------------------------------------------
 # no real need to edit anything past this point unless you need to add additional
diff --git a/platform/miyoomini/source/MiyooMiniHost.cpp b/platform/miyoomini/source/MiyooMiniHost.cpp
index b419b1e..b89a563 100644
--- a/platform/miyoomini/source/MiyooMiniHost.cpp
+++ b/platform/miyoomini/source/MiyooMiniHost.cpp
@@ -1,5 +1,6 @@

 #include <stdio.h>
+#include <unistd.h>
 #include <string.h>
 #include <dirent.h>
 #include <errno.h>
@@ -13,7 +14,10 @@ using namespace std;
 #include "../../../source/nibblehelpers.h"
 #include "../../../source/logger.h"
 #include "../../../source/filehelpers.h"
+
+#ifndef _DESKTOP
 #include "ao.h"
+#endif

 // sdl
 #include <SDL/SDL.h>
@@ -88,11 +92,20 @@ void postFlipFunction(){
 }

 void audioCleanup(){
+    #ifdef _DESKTOP
+    SDL_PauseAudio(1);
+
+    audioInitialized = false;
+
+    SDL_CloseAudio();
+
+    #else
     AO_PauseAudio(1);

     audioInitialized = false;

     AO_CloseAudio();
+    #endif
 }


@@ -110,10 +123,23 @@ void audioSetup(){
     want.channels = 1;
     want.samples = 512;
     want.callback = FillAudioDeviceBuffer;
-
+
+    #ifdef _DESKTOP
+    int audioOpenRes = SDL_OpenAudio(&want, &have);
+    if (audioOpenRes < 0) {
+        Logger_Write("Failed to open audio: %s", SDL_GetError());
+    } else {
+        if (have.format != want.format) {
+            Logger_Write("We didn't get requested audio format.");
+        }
+        SDL_PauseAudio(0);
+        audioInitialized = true;
+    }
+    #else
     AO_OpenAudio(&want);
     AO_PauseAudio(0);
     audioInitialized = true;
+    #endif
 }

 void _setSourceRect(int xoffset, int yoffset) {
@@ -177,8 +203,19 @@ void _changeStretch(StretchOption newStretch){


 Host::Host() {
+    #ifdef _DESKTOP
+    std::string home = getenv("HOME");
+
+    _cartDirectory = home + "/p8carts";
+    _logFilePrefix = home + "/fake08";
+
+    #else
     _cartDirectory = "/mnt/SDCARD/Roms/PICO";
-    _logFilePrefix = "/mnt/SDCARD/Roms/PICO/";
+    char cwdbuf[256];
+	getcwd(cwdbuf, 255);
+	strcat(cwdbuf, "/");
+	_logFilePrefix = cwdbuf;
+    #endif

  }

@@ -249,10 +286,13 @@ void Host::changeStretch(){
         StretchOption newStretch = stretch;

         if (stretch == StretchAndOverflow) {
+            newStretch = StretchToFit;
+        }
+        if (stretch == StretchToFit) {
             newStretch = PixelPerfectStretch;
         }
         else if (stretch == PixelPerfectStretch) {
-            newStretch = StretchToFill;
+            newStretch = StretchAndOverflow;
         }
         else{
             newStretch = StretchAndOverflow;