foxygit / fake-08-xbox360 Log in
commit cf623b9453c1914f8bd9cb37bf9637cedb804c58
Author:     Jon Bell <j.to.the.bell@gmail.com>
AuthorDate: Sun Jan 30 21:36:41 2022 -0700
Commit:     Jon Bell <j.to.the.bell@gmail.com>
CommitDate: Sun Jan 30 21:36:41 2022 -0700

    Untested changes to miyoo mini audio

    Mostly from @eggs, with a few tweaks to try to build with multiple
    toolchains
---
 platform/miyoomini/Makefile                 | 19 ++++++++++++++-----
 platform/miyoomini/source/MiyooMiniHost.cpp | 19 ++++++++-----------
 platform/miyoomini/source/ao.c              |  8 ++++++--
 3 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/platform/miyoomini/Makefile b/platform/miyoomini/Makefile
index 7cbac3a..c25edd7 100644
--- a/platform/miyoomini/Makefile
+++ b/platform/miyoomini/Makefile
@@ -11,26 +11,35 @@ BUILD		:=	build
 SOURCES		:=	${SOURCES} source
 INCLUDES	:=	${INCLUDES} source

+TOOLCHAIN   := union
+
+
+ifeq ($(TOOLCHAIN),union)
 #---------------------------------------------------------------------------------
 # union toolchain (has these in PATH)
 #---------------------------------------------------------------------------------
-
 CC = arm-linux-gnueabihf-gcc
 CXX = arm-linux-gnueabihf-g++
 STRIP = arm-linux-gnueabihf-strip

+else
 #---------------------------------------------------------------------------------
-# other toolchain. possible TODO: detect/parameterize
+# other toolchain. possible TODO: detect instead of manually changing?
 #---------------------------------------------------------------------------------
-#CC = /opt/miyoomini/bin/arm-linux-gnueabihf-gcc
-#CXX = /opt/miyoomini/bin/arm-linux-gnueabihf-g++
-#STRIP = /opt/miyoomini/bin/arm-linux-gnueabihf-strip
+CC = /opt/miyoomini/bin/arm-linux-gnueabihf-gcc
+CXX = /opt/miyoomini/bin/arm-linux-gnueabihf-g++
+STRIP = /opt/miyoomini/bin/arm-linux-gnueabihf-strip
+endif

 CC = $(CXX)

 CFLAGS	:=	-Wall -Ofast -ffunction-sections -Iinc -D_BITTBOY -DVER_STR=\"$(APP_VERSION)\" -marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -march=armv7ve \
 			$(DEFINES)

+ifeq ($(TOOLCHAIN),union)
+CFLAGS	+=	-DUNIONTOOLCHAIN=1
+endif
+
 CFLAGS	+=	$(INCLUDE)

 CXXFLAGS	:= $(CFLAGS) -fno-rtti -std=gnu++17
diff --git a/platform/miyoomini/source/MiyooMiniHost.cpp b/platform/miyoomini/source/MiyooMiniHost.cpp
index 551fabd..b419b1e 100644
--- a/platform/miyoomini/source/MiyooMiniHost.cpp
+++ b/platform/miyoomini/source/MiyooMiniHost.cpp
@@ -13,12 +13,11 @@ using namespace std;
 #include "../../../source/nibblehelpers.h"
 #include "../../../source/logger.h"
 #include "../../../source/filehelpers.h"
+#include "ao.h"

 // sdl
 #include <SDL/SDL.h>

-#include "ao.h"
-
 #define SCREEN_SIZE_X 640
 #define SCREEN_SIZE_Y 480

@@ -90,7 +89,7 @@ void postFlipFunction(){

 void audioCleanup(){
     AO_PauseAudio(1);
-
+
     audioInitialized = false;

     AO_CloseAudio();
@@ -99,7 +98,7 @@ void audioCleanup(){

 void FillAudioDeviceBuffer(void* UserData, Uint8* DeviceBuffer, int Length)
 {
-    _audio->FillAudioBuffer(DeviceBuffer, 0, Length / 4);
+    _audio->FillMonoAudioBuffer(DeviceBuffer, 0, Length / 2);
 }

 void audioSetup(){
@@ -108,14 +107,12 @@ void audioSetup(){
     SDL_memset(&want, 0, sizeof(want));
     want.freq = SAMPLERATE;
     want.format = AUDIO_S16LSB;
-    want.channels = 2;
-    want.samples = 4096;
+    want.channels = 1;
+    want.samples = 512;
     want.callback = FillAudioDeviceBuffer;

-
     AO_OpenAudio(&want);
     AO_PauseAudio(0);
-
     audioInitialized = true;
 }

@@ -195,7 +192,7 @@ void Host::oneTimeSetup(Color* paletteColors, Audio* audio){
     SDL_WM_SetCaption("FAKE-08", NULL);
     SDL_ShowCursor(SDL_DISABLE);

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

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

@@ -252,9 +249,9 @@ void Host::changeStretch(){
         StretchOption newStretch = stretch;

         if (stretch == StretchAndOverflow) {
-            newStretch = PixelPerfect;
+            newStretch = PixelPerfectStretch;
         }
-        else if (stretch == PixelPerfect) {
+        else if (stretch == PixelPerfectStretch) {
             newStretch = StretchToFill;
         }
         else{
diff --git a/platform/miyoomini/source/ao.c b/platform/miyoomini/source/ao.c
index 343645b..5d1914f 100644
--- a/platform/miyoomini/source/ao.c
+++ b/platform/miyoomini/source/ao.c
@@ -4,11 +4,15 @@
 #include <pthread.h>
 #include <linux/input.h>
 #include <SDL/SDL.h>
+#if UNIONTOOLCHAIN
 #include <mi_sys.h>
 #include <mi_ao.h>
+#else
+#include <sdkdir/mi_sys.h>
+#include <sdkdir/mi_ao.h>
+#endif

-#define	NUM_FRAMES		4	// 8192/(512*2*2)
-//#define	NUM_FRAMES		2
+#define	NUM_FRAMES		2	// 512(samples)*2(16bit) *2 = 2048 bytes
 #define	USLEEP_MIN		0	// Threshold time for reading ahead without usleep
 					//	when the time remaining until the next frame is less
 					// (usleep resolution is 10000us(10ms) in the case of miyoomini)