From 20a88946d418c08e1602db557de90b84a6000ec8 Mon Sep 17 00:00:00 2001 From: RSDuck Date: Fri, 12 Feb 2021 14:19:15 +0100 Subject: [PATCH] adapt to latest changes upstream --- src/GPU.cpp | 3 ++ src/GPU2D.h | 68 ------------------------------ src/GPU2D_NeonSoft.cpp | 2 +- src/GPU2D_NeonSoft.h | 72 ++++++++++++++++++++++++++++++++ src/frontend/switch/Platform.cpp | 13 ++++-- 5 files changed, 86 insertions(+), 72 deletions(-) create mode 100644 src/GPU2D_NeonSoft.h diff --git a/src/GPU.cpp b/src/GPU.cpp index 3ff14a2705..2350a15bab 100644 --- a/src/GPU.cpp +++ b/src/GPU.cpp @@ -22,6 +22,9 @@ #include "GPU.h" #include "GPU2D_Soft.h" +#ifdef NEONSOFTGPU_ENABLED +#include "GPU2D_NeonSoft.h" +#endif namespace GPU { diff --git a/src/GPU2D.h b/src/GPU2D.h index 2707a23817..d75eb00e2e 100644 --- a/src/GPU2D.h +++ b/src/GPU2D.h @@ -124,72 +124,4 @@ class GPU2D virtual void MosaicXSizeChanged() = 0; }; -#ifdef NEONSOFTGPU_ENABLED -class GPU2D_NeonSoft : public GPU2D -{ -public: - GPU2D_NeonSoft(u32 num); - ~GPU2D_NeonSoft() override {} - - void DrawScanline(u32 line) override; - void DrawSprites(u32 line) override; - -protected: - void MosaicXSizeChanged() {} - -private: - u32 BGOBJLine[272*2] __attribute__((aligned (16))); - u32* _3DLine; - - u32 OBJLine[272*2] __attribute__((aligned (16))); - u8 OBJIndex[256]; - - u8 WindowMask[272] __attribute__((aligned (16))); - u8 OBJWindow[272] __attribute__((aligned (16))); - - u8 MosaicTable[16][256]; - u8* CurBGXMosaicTable; - u8* CurOBJXMosaicTable; - - u32 NumSprites[4]; - u32 NumSpritesPerLayer[4]; - u8 SpriteCache[4][128]; - - bool SkipRendering; - bool _3DSemiTransparencies; - bool SemiTransBitmapSprites; - bool SemiTransTileSprites; - - template - void ApplyColorEffect(); - - void PalettiseRange(u32 start); - - void InterleaveSprites(u32 prio); - - void DoCapture(u32 line, u32 width); - - template - void DrawScanlineBGMode(u32 line); - void DrawScanlineBGMode6(u32 line); - void DrawScanlineBGMode7(u32 line); - void DrawScanline_BGOBJ(u32 line); - - void DrawBG_3D(); - template - void DrawBG_Text(u32 line, u32 bgnum); - template - void DrawBG_Affine(u32 line, u32 bgnum); - template - void DrawBG_Extended(u32 line, u32 bgnum); - template - void DrawBG_Large(u32 line); - - template - void DrawSprite_Normal(u32 num, u32 width, u32 height, s32 xpos, s32 ypos); - template - void DrawSprite_Rotscale(u32 num, u32 boundwidth, u32 boundheight, u32 width, u32 height, s32 xpos, s32 ypos); -}; -#endif - #endif diff --git a/src/GPU2D_NeonSoft.cpp b/src/GPU2D_NeonSoft.cpp index 9fc6122ec2..92caa24412 100644 --- a/src/GPU2D_NeonSoft.cpp +++ b/src/GPU2D_NeonSoft.cpp @@ -1,4 +1,4 @@ -#include "GPU2D.h" +#include "GPU2D_NeonSoft.h" #include "NDS.h" #include "GPU.h" diff --git a/src/GPU2D_NeonSoft.h b/src/GPU2D_NeonSoft.h new file mode 100644 index 0000000000..94d968b011 --- /dev/null +++ b/src/GPU2D_NeonSoft.h @@ -0,0 +1,72 @@ +#ifndef GPU2D_NEONSOFT +#define GPU2D_NEONSOFT + +#include "GPU2D.h" + +class GPU2D_NeonSoft : public GPU2D +{ +public: + GPU2D_NeonSoft(u32 num); + ~GPU2D_NeonSoft() override {} + + void DrawScanline(u32 line) override; + void DrawSprites(u32 line) override; + +protected: + void MosaicXSizeChanged() {} + +private: + u32 BGOBJLine[272*2] __attribute__((aligned (16))); + u32* _3DLine; + + u32 OBJLine[272*2] __attribute__((aligned (16))); + u8 OBJIndex[256]; + + u8 WindowMask[272] __attribute__((aligned (16))); + u8 OBJWindow[272] __attribute__((aligned (16))); + + u8 MosaicTable[16][256]; + u8* CurBGXMosaicTable; + u8* CurOBJXMosaicTable; + + u32 NumSprites[4]; + u32 NumSpritesPerLayer[4]; + u8 SpriteCache[4][128]; + + bool SkipRendering; + bool _3DSemiTransparencies; + bool SemiTransBitmapSprites; + bool SemiTransTileSprites; + + template + void ApplyColorEffect(); + + void PalettiseRange(u32 start); + + void InterleaveSprites(u32 prio); + + void DoCapture(u32 line, u32 width); + + template + void DrawScanlineBGMode(u32 line); + void DrawScanlineBGMode6(u32 line); + void DrawScanlineBGMode7(u32 line); + void DrawScanline_BGOBJ(u32 line); + + void DrawBG_3D(); + template + void DrawBG_Text(u32 line, u32 bgnum); + template + void DrawBG_Affine(u32 line, u32 bgnum); + template + void DrawBG_Extended(u32 line, u32 bgnum); + template + void DrawBG_Large(u32 line); + + template + void DrawSprite_Normal(u32 num, u32 width, u32 height, s32 xpos, s32 ypos); + template + void DrawSprite_Rotscale(u32 num, u32 boundwidth, u32 boundheight, u32 width, u32 height, s32 xpos, s32 ypos); +}; + +#endif \ No newline at end of file diff --git a/src/frontend/switch/Platform.cpp b/src/frontend/switch/Platform.cpp index aef834d432..9fa59d330b 100644 --- a/src/frontend/switch/Platform.cpp +++ b/src/frontend/switch/Platform.cpp @@ -55,19 +55,26 @@ void Sleep(u64 usecs) svcSleepThread(usecs * 1000); } +struct ThreadEntryData +{ + std::function EntryPoint; +}; + void ThreadEntry(void* param) { - ((void (*)())param)(); + ThreadEntryData* entryData = (ThreadEntryData*)param; + entryData->EntryPoint(); + delete entryData; } #define STACK_SIZE (1024 * 1024 * 4) int nextCore = 0; -Thread* Thread_Create(void (*func)()) +Thread* Thread_Create(std::function func) { ::Thread* thread = new ::Thread(); - threadCreate(thread, ThreadEntry, (void*)func, NULL, STACK_SIZE, 0x1F, nextCore); + threadCreate(thread, ThreadEntry, new ThreadEntryData{func}, NULL, STACK_SIZE, 0x1F, nextCore); // this relies on the order of thread creation, very bad nextCore = 2; threadStart(thread);