Skip to content

Commit

Permalink
adapt to latest changes upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
RSDuck committed Feb 12, 2021
1 parent 514e48e commit 20a8894
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 72 deletions.
3 changes: 3 additions & 0 deletions src/GPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#include "GPU.h"

#include "GPU2D_Soft.h"
#ifdef NEONSOFTGPU_ENABLED
#include "GPU2D_NeonSoft.h"
#endif

namespace GPU
{
Expand Down
68 changes: 0 additions & 68 deletions src/GPU2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <bool Enable3DBlend, int SecondSrcBlend>
void ApplyColorEffect();

void PalettiseRange(u32 start);

void InterleaveSprites(u32 prio);

void DoCapture(u32 line, u32 width);

template<u32 bgmode>
void DrawScanlineBGMode(u32 line);
void DrawScanlineBGMode6(u32 line);
void DrawScanlineBGMode7(u32 line);
void DrawScanline_BGOBJ(u32 line);

void DrawBG_3D();
template <bool mosaic>
void DrawBG_Text(u32 line, u32 bgnum);
template <bool mosaic>
void DrawBG_Affine(u32 line, u32 bgnum);
template <bool mosaic>
void DrawBG_Extended(u32 line, u32 bgnum);
template <bool mosaic>
void DrawBG_Large(u32 line);

template <bool window>
void DrawSprite_Normal(u32 num, u32 width, u32 height, s32 xpos, s32 ypos);
template <bool window>
void DrawSprite_Rotscale(u32 num, u32 boundwidth, u32 boundheight, u32 width, u32 height, s32 xpos, s32 ypos);
};
#endif

#endif
2 changes: 1 addition & 1 deletion src/GPU2D_NeonSoft.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "GPU2D.h"
#include "GPU2D_NeonSoft.h"

#include "NDS.h"
#include "GPU.h"
Expand Down
72 changes: 72 additions & 0 deletions src/GPU2D_NeonSoft.h
Original file line number Diff line number Diff line change
@@ -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 <bool Enable3DBlend, int SecondSrcBlend>
void ApplyColorEffect();

void PalettiseRange(u32 start);

void InterleaveSprites(u32 prio);

void DoCapture(u32 line, u32 width);

template<u32 bgmode>
void DrawScanlineBGMode(u32 line);
void DrawScanlineBGMode6(u32 line);
void DrawScanlineBGMode7(u32 line);
void DrawScanline_BGOBJ(u32 line);

void DrawBG_3D();
template <bool mosaic>
void DrawBG_Text(u32 line, u32 bgnum);
template <bool mosaic>
void DrawBG_Affine(u32 line, u32 bgnum);
template <bool mosaic>
void DrawBG_Extended(u32 line, u32 bgnum);
template <bool mosaic>
void DrawBG_Large(u32 line);

template <bool window>
void DrawSprite_Normal(u32 num, u32 width, u32 height, s32 xpos, s32 ypos);
template <bool window>
void DrawSprite_Rotscale(u32 num, u32 boundwidth, u32 boundheight, u32 width, u32 height, s32 xpos, s32 ypos);
};

#endif
13 changes: 10 additions & 3 deletions src/frontend/switch/Platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,26 @@ void Sleep(u64 usecs)
svcSleepThread(usecs * 1000);
}

struct ThreadEntryData
{
std::function<void()> 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<void()> 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);
Expand Down

0 comments on commit 20a8894

Please sign in to comment.