GPU:
- Do heavy code cleanup. - Encapsulate higher level GPU functions into the new GPUSubsystem class.
This commit is contained in:
parent
d5280f82b0
commit
88006197b9
1182
desmume/src/GPU.cpp
1182
desmume/src/GPU.cpp
File diff suppressed because it is too large
Load Diff
|
@ -687,10 +687,36 @@ typedef struct
|
|||
class GPUEngineBase
|
||||
{
|
||||
private:
|
||||
static CACHE_ALIGN u16 _fadeInColors[17][0x8000];
|
||||
static CACHE_ALIGN u16 _fadeOutColors[17][0x8000];
|
||||
static CACHE_ALIGN u8 _blendTable555[17][17][32][32];
|
||||
|
||||
static struct MosaicLookup {
|
||||
|
||||
struct TableEntry {
|
||||
u8 begin, trunc;
|
||||
} table[16][256];
|
||||
|
||||
MosaicLookup() {
|
||||
for(int m=0;m<16;m++)
|
||||
for(int i=0;i<256;i++) {
|
||||
int mosaic = m+1;
|
||||
TableEntry &te = table[m][i];
|
||||
te.begin = (i%mosaic==0);
|
||||
te.trunc = i/mosaic*mosaic;
|
||||
}
|
||||
}
|
||||
|
||||
TableEntry *width, *height;
|
||||
int widthValue, heightValue;
|
||||
|
||||
} _mosaicLookup;
|
||||
|
||||
CACHE_ALIGN u16 _sprColor[GPU_FRAMEBUFFER_NATIVE_WIDTH];
|
||||
CACHE_ALIGN u8 _sprAlpha[GPU_FRAMEBUFFER_NATIVE_WIDTH];
|
||||
CACHE_ALIGN u8 _sprType[GPU_FRAMEBUFFER_NATIVE_WIDTH];
|
||||
CACHE_ALIGN u8 _sprPrio[GPU_FRAMEBUFFER_NATIVE_WIDTH];
|
||||
CACHE_ALIGN u8 _sprWin[GPU_FRAMEBUFFER_NATIVE_WIDTH];
|
||||
|
||||
bool _enableLayer[5];
|
||||
itemsForPriority_t _itemsForPriority[NB_PRIORITIES];
|
||||
|
@ -776,6 +802,8 @@ private:
|
|||
u8 _BLDALPHA_EVB;
|
||||
u8 _BLDY_EVY;
|
||||
|
||||
void _InitLUTs();
|
||||
|
||||
void _MosaicSpriteLinePixel(const size_t x, u16 l, u16 *dst, u8 *dst_alpha, u8 *typeTab, u8 *prioTab);
|
||||
void _MosaicSpriteLine(u16 l, u16 *dst, u8 *dst_alpha, u8 *typeTab, u8 *prioTab);
|
||||
|
||||
|
@ -831,8 +859,11 @@ public:
|
|||
|
||||
void SetVideoProp(const u32 ctrlBits);
|
||||
void SetBGProp(const size_t num, const u16 ctrlBits);
|
||||
void SetDISPCAPCNT(u32 val);
|
||||
|
||||
void RenderLine(const u16 l, u16 *dstLine, const size_t dstLineWidth, const size_t dstLineCount);
|
||||
void RenderLine(const u16 l, bool skip);
|
||||
void RenderLine_Layer(const u16 l, u16 *dstLine, const size_t dstLineWidth, const size_t dstLineCount);
|
||||
void RenderLine_MasterBrightness(u16 *dstLine, const size_t dstLineWidth, const size_t dstLineCount);
|
||||
|
||||
// some structs are becoming redundant
|
||||
// some functions too (no need to recopy some vars as it is done by MMU)
|
||||
|
@ -879,33 +910,15 @@ public:
|
|||
|
||||
bool need_update_winh[2];
|
||||
|
||||
static struct MosaicLookup {
|
||||
|
||||
struct TableEntry {
|
||||
u8 begin, trunc;
|
||||
} table[16][256];
|
||||
|
||||
MosaicLookup() {
|
||||
for(int m=0;m<16;m++)
|
||||
for(int i=0;i<256;i++) {
|
||||
int mosaic = m+1;
|
||||
TableEntry &te = table[m][i];
|
||||
te.begin = (i%mosaic==0);
|
||||
te.trunc = i/mosaic*mosaic;
|
||||
}
|
||||
}
|
||||
|
||||
TableEntry *width, *height;
|
||||
int widthValue, heightValue;
|
||||
|
||||
} mosaicLookup;
|
||||
|
||||
struct AffineInfo {
|
||||
AffineInfo() : x(0), y(0) {}
|
||||
u32 x, y;
|
||||
} affineInfo[2];
|
||||
|
||||
void SetLayerState(const size_t layerIndex, bool theState);
|
||||
bool GetEnableState();
|
||||
void SetEnableState(bool theState);
|
||||
bool GetLayerEnableState(const size_t layerIndex);
|
||||
void SetLayerEnableState(const size_t layerIndex, bool theState);
|
||||
|
||||
template<bool BACKDROP, bool USECUSTOMVRAM, int FUNCNUM> FORCEINLINE void ____setFinalColorBck(const u16 color, const size_t srcX);
|
||||
template<bool MOSAIC, bool BACKDROP> FORCEINLINE void __setFinalColorBck(u16 color, const size_t srcX, const bool opaque);
|
||||
|
@ -926,8 +939,8 @@ public:
|
|||
void HandleDisplayModeVRAM(u16 *dstLine, const size_t l, const size_t dstLineWidth, const size_t dstLineCount);
|
||||
void HandleDisplayModeMainMemory(u16 *dstLine, const size_t l, const size_t dstLineWidth, const size_t dstLineCount);
|
||||
|
||||
u32 GetHOFS(const size_t bg);
|
||||
u32 GetVOFS(const size_t bg);
|
||||
u32 GetHOFS(const size_t bg) const;
|
||||
u32 GetVOFS(const size_t bg) const;
|
||||
|
||||
void UpdateBLDALPHA();
|
||||
void SetBLDALPHA(const u16 val);
|
||||
|
@ -964,10 +977,10 @@ public:
|
|||
void SetWINOUT(const u8 val);
|
||||
void SetWINOBJ(const u8 val);
|
||||
|
||||
int GetFinalColorBckFuncID();
|
||||
int GetFinalColorBckFuncID() const;
|
||||
void SetFinalColorBckFuncID(int funcID);
|
||||
|
||||
NDSDisplayID GetDisplayByID();
|
||||
NDSDisplayID GetDisplayByID() const;
|
||||
void SetDisplayByID(const NDSDisplayID theDisplayID);
|
||||
|
||||
void SetCustomFramebufferSize(size_t w, size_t h);
|
||||
|
@ -976,31 +989,6 @@ public:
|
|||
void REG_DISPx_pack_test();
|
||||
};
|
||||
|
||||
extern u16 *GPU_screen; // TODO: Old pointer - need to eliminate direct reference in frontends
|
||||
|
||||
size_t GPU_GetFramebufferWidth();
|
||||
size_t GPU_GetFramebufferHeight();
|
||||
void GPU_SetFramebufferSize(size_t w, size_t h);
|
||||
|
||||
// Normally, the GPUs will automatically blit their native buffers to the master
|
||||
// framebuffer at the end of V-blank so that all rendered graphics are contained
|
||||
// within a single common buffer. This is necessary for when someone wants to read
|
||||
// the NDS framebuffers, but the reader can only read a single buffer at a time.
|
||||
// Certain functions, such as taking screenshots, as well as many frontends running
|
||||
// the NDS video displays, require that they read from only a single buffer.
|
||||
//
|
||||
// However, if GPU_SetWillAutoBlitNativeToCustomBuffer() is passed "false", then the
|
||||
// frontend becomes responsible for calling NDS_GetDisplayInfo() and reading the
|
||||
// native and custom buffers properly for each display. If a single buffer is still
|
||||
// needed for certain cases, then the frontend must manually call
|
||||
// GPU::BlitNativeToCustomFramebuffer() for each GPU before reading the master framebuffer.
|
||||
bool GPU_GetWillAutoBlitNativeToCustomBuffer();
|
||||
void GPU_SetWillAutoBlitNativeToCustomBuffer(const bool willAutoBlit);
|
||||
|
||||
void GPU_UpdateVRAM3DUsageProperties(VRAM3DUsageProperties &outProperty);
|
||||
|
||||
const NDSDisplayInfo& NDS_GetDisplayInfo(); // Frontends need to call this whenever they need to read the video buffers from the emulator core
|
||||
|
||||
class NDSDisplay
|
||||
{
|
||||
private:
|
||||
|
@ -1010,32 +998,84 @@ private:
|
|||
public:
|
||||
NDSDisplay();
|
||||
NDSDisplay(const NDSDisplayID displayID);
|
||||
NDSDisplay(const NDSDisplayID displayID, const GPUCoreID coreID);
|
||||
NDSDisplay(const NDSDisplayID displayID, GPUEngineBase *theEngine);
|
||||
|
||||
GPUEngineBase* GetEngine();
|
||||
void SetEngine(GPUEngineBase *theEngine);
|
||||
|
||||
GPUCoreID GetEngineID();
|
||||
void SetEngineByID(const GPUCoreID theID);
|
||||
};
|
||||
|
||||
struct NDS_Screen
|
||||
class GPUSubsystem
|
||||
{
|
||||
GPUEngineBase *gpu;
|
||||
private:
|
||||
GPUEngineBase *_engineMain;
|
||||
GPUEngineBase *_engineSub;
|
||||
NDSDisplay *_displayMain;
|
||||
NDSDisplay *_displayTouch;
|
||||
|
||||
bool _willAutoBlitNativeToCustomBuffer;
|
||||
VRAM3DUsageProperties _VRAM3DUsage;
|
||||
u16 *_customVRAM;
|
||||
u16 *_customVRAMBlank;
|
||||
|
||||
CACHE_ALIGN u16 _nativeFramebuffer[GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT * 2];
|
||||
u16 *_customFramebuffer;
|
||||
|
||||
NDSDisplayInfo _displayInfo;
|
||||
|
||||
public:
|
||||
GPUSubsystem();
|
||||
~GPUSubsystem();
|
||||
|
||||
void Reset();
|
||||
VRAM3DUsageProperties& GetVRAM3DUsageProperties();
|
||||
const NDSDisplayInfo& GetDisplayInfo(); // Frontends need to call this whenever they need to read the video buffers from the emulator core
|
||||
void SetDisplayDidCustomRender(NDSDisplayID displayID, bool theState);
|
||||
|
||||
GPUEngineBase* GetEngineMain();
|
||||
GPUEngineBase* GetEngineSub();
|
||||
NDSDisplay* GetDisplayMain();
|
||||
NDSDisplay* GetDisplayTouch();
|
||||
|
||||
u16* GetNativeFramebuffer();
|
||||
u16* GetNativeFramebuffer(const NDSDisplayID theDisplayID);
|
||||
u16* GetCustomFramebuffer();
|
||||
u16* GetCustomFramebuffer(const NDSDisplayID theDisplayID);
|
||||
|
||||
u16* GetCustomVRAMBuffer();
|
||||
u16* GetCustomVRAMBlankBuffer();
|
||||
|
||||
size_t GetCustomFramebufferWidth() const;
|
||||
size_t GetCustomFramebufferHeight() const;
|
||||
void SetCustomFramebufferSize(size_t w, size_t h);
|
||||
|
||||
void UpdateVRAM3DUsageProperties();
|
||||
|
||||
// Normally, the GPUs will automatically blit their native buffers to the master
|
||||
// framebuffer at the end of V-blank so that all rendered graphics are contained
|
||||
// within a single common buffer. This is necessary for when someone wants to read
|
||||
// the NDS framebuffers, but the reader can only read a single buffer at a time.
|
||||
// Certain functions, such as taking screenshots, as well as many frontends running
|
||||
// the NDS video displays, require that they read from only a single buffer.
|
||||
//
|
||||
// However, if SetWillAutoBlitNativeToCustomBuffer() is passed "false", then the
|
||||
// frontend becomes responsible for calling GetDisplayInfo() and reading the native
|
||||
// and custom buffers properly for each display. If a single buffer is still needed
|
||||
// for certain cases, then the frontend must manually call
|
||||
// GPUEngineBase::BlitNativeToCustomFramebuffer() for each GPU before reading the
|
||||
// master framebuffer.
|
||||
bool GetWillAutoBlitNativeToCustomBuffer() const;
|
||||
void SetWillAutoBlitNativeToCustomBuffer(const bool willAutoBlit);
|
||||
|
||||
void RenderLine(const u16 l, bool skip = false);
|
||||
void ClearWithColor(const u16 colorBGRA5551);
|
||||
};
|
||||
|
||||
extern NDS_Screen MainScreen;
|
||||
extern NDS_Screen SubScreen;
|
||||
extern NDSDisplay MainDisplay;
|
||||
extern NDSDisplay TouchDisplay;
|
||||
|
||||
int Screen_Init();
|
||||
void Screen_Reset(void);
|
||||
void Screen_DeInit(void);
|
||||
|
||||
extern GPUSubsystem *GPU;
|
||||
extern MMU_struct MMU;
|
||||
|
||||
void GPU_set_DISPCAPCNT(u32 val);
|
||||
void GPU_RenderLine(NDS_Screen *screen, const u16 l, bool skip = false);
|
||||
|
||||
inline FragmentColor MakeFragmentColor(const u8 r, const u8 g, const u8 b, const u8 a)
|
||||
{
|
||||
FragmentColor ret;
|
||||
|
|
|
@ -1848,14 +1848,14 @@ static void writereg_POWCNT1(const int size, const u32 adr, const u32 val) {
|
|||
if(nds.power1.dispswap)
|
||||
{
|
||||
//printf("Main core on top (vcount=%d)\n",nds.VCount);
|
||||
MainDisplay.SetEngineByID(GPUCOREID_MAIN);
|
||||
TouchDisplay.SetEngineByID(GPUCOREID_SUB);
|
||||
GPU->GetDisplayMain()->SetEngineByID(GPUCOREID_MAIN);
|
||||
GPU->GetDisplayTouch()->SetEngineByID(GPUCOREID_SUB);
|
||||
}
|
||||
else
|
||||
{
|
||||
//printf("Main core on bottom (vcount=%d)\n",nds.VCount);
|
||||
MainDisplay.SetEngineByID(GPUCOREID_SUB);
|
||||
TouchDisplay.SetEngineByID(GPUCOREID_MAIN);
|
||||
GPU->GetDisplayMain()->SetEngineByID(GPUCOREID_SUB);
|
||||
GPU->GetDisplayTouch()->SetEngineByID(GPUCOREID_MAIN);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -3285,7 +3285,10 @@ void FASTCALL _MMU_ARM9_write08(u32 adr, u8 val)
|
|||
MMU_new.write_dma(ARMCPU_ARM9,8,adr,val);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
GPUEngineBase *mainEngine = GPU->GetEngineMain();
|
||||
GPUEngineBase *subEngine = GPU->GetEngineSub();
|
||||
|
||||
switch(adr)
|
||||
{
|
||||
case REG_SQRTCNT: printf("ERROR 8bit SQRTCNT WRITE\n"); return;
|
||||
|
@ -3326,116 +3329,116 @@ void FASTCALL _MMU_ARM9_write08(u32 adr, u8 val)
|
|||
break;
|
||||
|
||||
case REG_DISPA_WIN0H:
|
||||
MainScreen.gpu->SetWIN0_H1(val);
|
||||
mainEngine->SetWIN0_H1(val);
|
||||
break ;
|
||||
case REG_DISPA_WIN0H+1:
|
||||
MainScreen.gpu->SetWIN0_H0(val);
|
||||
mainEngine->SetWIN0_H0(val);
|
||||
break ;
|
||||
case REG_DISPA_WIN1H:
|
||||
MainScreen.gpu->SetWIN1_H1(val);
|
||||
mainEngine->SetWIN1_H1(val);
|
||||
break ;
|
||||
case REG_DISPA_WIN1H+1:
|
||||
MainScreen.gpu->SetWIN1_H0(val);
|
||||
mainEngine->SetWIN1_H0(val);
|
||||
break ;
|
||||
|
||||
case REG_DISPB_WIN0H:
|
||||
SubScreen.gpu->SetWIN0_H1(val);
|
||||
subEngine->SetWIN0_H1(val);
|
||||
break ;
|
||||
case REG_DISPB_WIN0H+1:
|
||||
SubScreen.gpu->SetWIN0_H0(val);
|
||||
subEngine->SetWIN0_H0(val);
|
||||
break ;
|
||||
case REG_DISPB_WIN1H:
|
||||
SubScreen.gpu->SetWIN1_H1(val);
|
||||
subEngine->SetWIN1_H1(val);
|
||||
break ;
|
||||
case REG_DISPB_WIN1H+1:
|
||||
SubScreen.gpu->SetWIN1_H0(val);
|
||||
subEngine->SetWIN1_H0(val);
|
||||
break ;
|
||||
|
||||
case REG_DISPA_WIN0V:
|
||||
MainScreen.gpu->SetWIN0_V1(val) ;
|
||||
mainEngine->SetWIN0_V1(val) ;
|
||||
break ;
|
||||
case REG_DISPA_WIN0V+1:
|
||||
MainScreen.gpu->SetWIN0_V0(val) ;
|
||||
mainEngine->SetWIN0_V0(val) ;
|
||||
break ;
|
||||
case REG_DISPA_WIN1V:
|
||||
MainScreen.gpu->SetWIN1_V1(val) ;
|
||||
mainEngine->SetWIN1_V1(val) ;
|
||||
break ;
|
||||
case REG_DISPA_WIN1V+1:
|
||||
MainScreen.gpu->SetWIN1_V0(val) ;
|
||||
mainEngine->SetWIN1_V0(val) ;
|
||||
break ;
|
||||
|
||||
case REG_DISPB_WIN0V:
|
||||
SubScreen.gpu->SetWIN0_V1(val);
|
||||
subEngine->SetWIN0_V1(val);
|
||||
break ;
|
||||
case REG_DISPB_WIN0V+1:
|
||||
SubScreen.gpu->SetWIN0_V0(val);
|
||||
subEngine->SetWIN0_V0(val);
|
||||
break ;
|
||||
case REG_DISPB_WIN1V:
|
||||
SubScreen.gpu->SetWIN1_V1(val);
|
||||
subEngine->SetWIN1_V1(val);
|
||||
break ;
|
||||
case REG_DISPB_WIN1V+1:
|
||||
SubScreen.gpu->SetWIN1_V0(val);
|
||||
subEngine->SetWIN1_V0(val);
|
||||
break ;
|
||||
|
||||
case REG_DISPA_WININ:
|
||||
MainScreen.gpu->SetWININ0(val);
|
||||
mainEngine->SetWININ0(val);
|
||||
break ;
|
||||
case REG_DISPA_WININ+1:
|
||||
MainScreen.gpu->SetWININ1(val);
|
||||
mainEngine->SetWININ1(val);
|
||||
break ;
|
||||
case REG_DISPA_WINOUT:
|
||||
MainScreen.gpu->SetWINOUT(val);
|
||||
mainEngine->SetWINOUT(val);
|
||||
break ;
|
||||
case REG_DISPA_WINOUT+1:
|
||||
MainScreen.gpu->SetWINOBJ(val);
|
||||
mainEngine->SetWINOBJ(val);
|
||||
break ;
|
||||
|
||||
case REG_DISPB_WININ:
|
||||
SubScreen.gpu->SetWININ0(val);
|
||||
subEngine->SetWININ0(val);
|
||||
break ;
|
||||
case REG_DISPB_WININ+1:
|
||||
SubScreen.gpu->SetWININ1(val);
|
||||
subEngine->SetWININ1(val);
|
||||
break ;
|
||||
case REG_DISPB_WINOUT:
|
||||
SubScreen.gpu->SetWINOUT(val);
|
||||
subEngine->SetWINOUT(val);
|
||||
break ;
|
||||
case REG_DISPB_WINOUT+1:
|
||||
SubScreen.gpu->SetWINOBJ(val);
|
||||
subEngine->SetWINOBJ(val);
|
||||
break ;
|
||||
|
||||
case REG_DISPA_BLDCNT:
|
||||
MainScreen.gpu->SetBLDCNT_HIGH(val);
|
||||
mainEngine->SetBLDCNT_HIGH(val);
|
||||
break;
|
||||
case REG_DISPA_BLDCNT+1:
|
||||
MainScreen.gpu->SetBLDCNT_LOW(val);
|
||||
mainEngine->SetBLDCNT_LOW(val);
|
||||
break;
|
||||
|
||||
case REG_DISPB_BLDCNT:
|
||||
SubScreen.gpu->SetBLDCNT_HIGH(val);
|
||||
subEngine->SetBLDCNT_HIGH(val);
|
||||
break;
|
||||
case REG_DISPB_BLDCNT+1:
|
||||
SubScreen.gpu->SetBLDCNT_LOW(val);
|
||||
subEngine->SetBLDCNT_LOW(val);
|
||||
break;
|
||||
|
||||
case REG_DISPA_BLDALPHA:
|
||||
MainScreen.gpu->SetBLDALPHA_EVA(val);
|
||||
mainEngine->SetBLDALPHA_EVA(val);
|
||||
break;
|
||||
case REG_DISPA_BLDALPHA+1:
|
||||
MainScreen.gpu->SetBLDALPHA_EVB(val);
|
||||
mainEngine->SetBLDALPHA_EVB(val);
|
||||
break;
|
||||
|
||||
case REG_DISPB_BLDALPHA:
|
||||
SubScreen.gpu->SetBLDALPHA_EVA(val);
|
||||
subEngine->SetBLDALPHA_EVA(val);
|
||||
break;
|
||||
case REG_DISPB_BLDALPHA+1:
|
||||
SubScreen.gpu->SetBLDALPHA_EVB(val);
|
||||
subEngine->SetBLDALPHA_EVB(val);
|
||||
break;
|
||||
|
||||
case REG_DISPA_BLDY:
|
||||
MainScreen.gpu->SetBLDY_EVY(val);
|
||||
mainEngine->SetBLDY_EVY(val);
|
||||
break ;
|
||||
case REG_DISPB_BLDY:
|
||||
SubScreen.gpu->SetBLDY_EVY(val);
|
||||
subEngine->SetBLDY_EVY(val);
|
||||
break;
|
||||
|
||||
case REG_AUXSPICNT:
|
||||
|
@ -3569,6 +3572,10 @@ void FASTCALL _MMU_ARM9_write16(u32 adr, u16 val)
|
|||
gfx3d_UpdateToonTable((adr & 0x3F) >> 1, val);
|
||||
return;
|
||||
}
|
||||
|
||||
GPUEngineBase *mainEngine = GPU->GetEngineMain();
|
||||
GPUEngineBase *subEngine = GPU->GetEngineSub();
|
||||
|
||||
// Address is an IO register
|
||||
switch(adr)
|
||||
{
|
||||
|
@ -3584,22 +3591,22 @@ void FASTCALL _MMU_ARM9_write16(u32 adr, u16 val)
|
|||
val &= 0x7F7F;
|
||||
break;
|
||||
|
||||
case REG_DISPA_BG2XL: MainScreen.gpu->setAffineStartWord(2,0,val,0); break;
|
||||
case REG_DISPA_BG2XH: MainScreen.gpu->setAffineStartWord(2,0,val,1); break;
|
||||
case REG_DISPA_BG2YL: MainScreen.gpu->setAffineStartWord(2,1,val,0); break;
|
||||
case REG_DISPA_BG2YH: MainScreen.gpu->setAffineStartWord(2,1,val,1); break;
|
||||
case REG_DISPA_BG3XL: MainScreen.gpu->setAffineStartWord(3,0,val,0); break;
|
||||
case REG_DISPA_BG3XH: MainScreen.gpu->setAffineStartWord(3,0,val,1); break;
|
||||
case REG_DISPA_BG3YL: MainScreen.gpu->setAffineStartWord(3,1,val,0); break;
|
||||
case REG_DISPA_BG3YH: MainScreen.gpu->setAffineStartWord(3,1,val,1); break;
|
||||
case REG_DISPB_BG2XL: SubScreen.gpu->setAffineStartWord(2,0,val,0); break;
|
||||
case REG_DISPB_BG2XH: SubScreen.gpu->setAffineStartWord(2,0,val,1); break;
|
||||
case REG_DISPB_BG2YL: SubScreen.gpu->setAffineStartWord(2,1,val,0); break;
|
||||
case REG_DISPB_BG2YH: SubScreen.gpu->setAffineStartWord(2,1,val,1); break;
|
||||
case REG_DISPB_BG3XL: SubScreen.gpu->setAffineStartWord(3,0,val,0); break;
|
||||
case REG_DISPB_BG3XH: SubScreen.gpu->setAffineStartWord(3,0,val,1); break;
|
||||
case REG_DISPB_BG3YL: SubScreen.gpu->setAffineStartWord(3,1,val,0); break;
|
||||
case REG_DISPB_BG3YH: SubScreen.gpu->setAffineStartWord(3,1,val,1); break;
|
||||
case REG_DISPA_BG2XL: mainEngine->setAffineStartWord(2,0,val,0); break;
|
||||
case REG_DISPA_BG2XH: mainEngine->setAffineStartWord(2,0,val,1); break;
|
||||
case REG_DISPA_BG2YL: mainEngine->setAffineStartWord(2,1,val,0); break;
|
||||
case REG_DISPA_BG2YH: mainEngine->setAffineStartWord(2,1,val,1); break;
|
||||
case REG_DISPA_BG3XL: mainEngine->setAffineStartWord(3,0,val,0); break;
|
||||
case REG_DISPA_BG3XH: mainEngine->setAffineStartWord(3,0,val,1); break;
|
||||
case REG_DISPA_BG3YL: mainEngine->setAffineStartWord(3,1,val,0); break;
|
||||
case REG_DISPA_BG3YH: mainEngine->setAffineStartWord(3,1,val,1); break;
|
||||
case REG_DISPB_BG2XL: subEngine->setAffineStartWord(2,0,val,0); break;
|
||||
case REG_DISPB_BG2XH: subEngine->setAffineStartWord(2,0,val,1); break;
|
||||
case REG_DISPB_BG2YL: subEngine->setAffineStartWord(2,1,val,0); break;
|
||||
case REG_DISPB_BG2YH: subEngine->setAffineStartWord(2,1,val,1); break;
|
||||
case REG_DISPB_BG3XL: subEngine->setAffineStartWord(3,0,val,0); break;
|
||||
case REG_DISPB_BG3XH: subEngine->setAffineStartWord(3,0,val,1); break;
|
||||
case REG_DISPB_BG3YL: subEngine->setAffineStartWord(3,1,val,0); break;
|
||||
case REG_DISPB_BG3YH: subEngine->setAffineStartWord(3,1,val,1); break;
|
||||
|
||||
case REG_DISPA_DISP3DCNT: writereg_DISP3DCNT(16,adr,val); return;
|
||||
|
||||
|
@ -3661,25 +3668,25 @@ void FASTCALL _MMU_ARM9_write16(u32 adr, u16 val)
|
|||
return;
|
||||
|
||||
case REG_DISPA_BLDCNT:
|
||||
MainScreen.gpu->SetBLDCNT(val);
|
||||
mainEngine->SetBLDCNT(val);
|
||||
break ;
|
||||
case REG_DISPB_BLDCNT:
|
||||
SubScreen.gpu->SetBLDCNT(val);
|
||||
subEngine->SetBLDCNT(val);
|
||||
break ;
|
||||
case REG_DISPA_BLDALPHA:
|
||||
MainScreen.gpu->SetBLDALPHA(val);
|
||||
mainEngine->SetBLDALPHA(val);
|
||||
break ;
|
||||
case REG_DISPB_BLDALPHA:
|
||||
SubScreen.gpu->SetBLDALPHA(val);
|
||||
subEngine->SetBLDALPHA(val);
|
||||
break ;
|
||||
case REG_DISPA_BLDY:
|
||||
MainScreen.gpu->SetBLDY_EVY(val);
|
||||
mainEngine->SetBLDY_EVY(val);
|
||||
break ;
|
||||
case REG_DISPB_BLDY:
|
||||
SubScreen.gpu->SetBLDY_EVY(val);
|
||||
subEngine->SetBLDY_EVY(val);
|
||||
break;
|
||||
case REG_DISPA_MASTERBRIGHT:
|
||||
MainScreen.gpu->SetMasterBrightness(val);
|
||||
mainEngine->SetMasterBrightness(val);
|
||||
break;
|
||||
/*
|
||||
case REG_DISPA_MOSAIC:
|
||||
|
@ -3715,34 +3722,34 @@ void FASTCALL _MMU_ARM9_write16(u32 adr, u16 val)
|
|||
// break;
|
||||
|
||||
case REG_DISPA_WIN0H:
|
||||
MainScreen.gpu->SetWIN0_H(val);
|
||||
mainEngine->SetWIN0_H(val);
|
||||
break ;
|
||||
case REG_DISPA_WIN1H:
|
||||
MainScreen.gpu->SetWIN1_H(val);
|
||||
mainEngine->SetWIN1_H(val);
|
||||
break ;
|
||||
case REG_DISPB_WIN0H:
|
||||
SubScreen.gpu->SetWIN0_H(val);
|
||||
subEngine->SetWIN0_H(val);
|
||||
break ;
|
||||
case REG_DISPB_WIN1H:
|
||||
SubScreen.gpu->SetWIN1_H(val);
|
||||
subEngine->SetWIN1_H(val);
|
||||
break ;
|
||||
case REG_DISPA_WIN0V:
|
||||
MainScreen.gpu->SetWIN0_V(val);
|
||||
mainEngine->SetWIN0_V(val);
|
||||
break ;
|
||||
case REG_DISPA_WIN1V:
|
||||
MainScreen.gpu->SetWIN1_V(val);
|
||||
mainEngine->SetWIN1_V(val);
|
||||
break ;
|
||||
case REG_DISPB_WIN0V:
|
||||
SubScreen.gpu->SetWIN0_V(val);
|
||||
subEngine->SetWIN0_V(val);
|
||||
break ;
|
||||
case REG_DISPB_WIN1V:
|
||||
SubScreen.gpu->SetWIN1_V(val);
|
||||
subEngine->SetWIN1_V(val);
|
||||
break ;
|
||||
case REG_DISPA_WININ:
|
||||
MainScreen.gpu->SetWININ(val);
|
||||
mainEngine->SetWININ(val);
|
||||
break ;
|
||||
case REG_DISPA_WINOUT:
|
||||
MainScreen.gpu->SetWINOUT16(val);
|
||||
mainEngine->SetWINOUT16(val);
|
||||
break ;
|
||||
|
||||
/* case REG_DISPB_BG0HOFS:
|
||||
|
@ -3771,14 +3778,14 @@ void FASTCALL _MMU_ARM9_write16(u32 adr, u16 val)
|
|||
break;*/
|
||||
|
||||
case REG_DISPB_WININ:
|
||||
SubScreen.gpu->SetWININ(val);
|
||||
subEngine->SetWININ(val);
|
||||
break ;
|
||||
case REG_DISPB_WINOUT:
|
||||
SubScreen.gpu->SetWINOUT16(val);
|
||||
subEngine->SetWINOUT16(val);
|
||||
break ;
|
||||
|
||||
case REG_DISPB_MASTERBRIGHT:
|
||||
SubScreen.gpu->SetMasterBrightness(val);
|
||||
subEngine->SetMasterBrightness(val);
|
||||
break;
|
||||
|
||||
case REG_POWCNT1:
|
||||
|
@ -3808,42 +3815,42 @@ void FASTCALL _MMU_ARM9_write16(u32 adr, u16 val)
|
|||
|
||||
case REG_DISPA_BG0CNT :
|
||||
//GPULOG("MAIN BG0 SETPROP 16B %08X\r\n", val);
|
||||
MainScreen.gpu->SetBGProp(0, val);
|
||||
mainEngine->SetBGProp(0, val);
|
||||
T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x8, val);
|
||||
return;
|
||||
case REG_DISPA_BG1CNT :
|
||||
//GPULOG("MAIN BG1 SETPROP 16B %08X\r\n", val);
|
||||
MainScreen.gpu->SetBGProp(1, val);
|
||||
mainEngine->SetBGProp(1, val);
|
||||
T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xA, val);
|
||||
return;
|
||||
case REG_DISPA_BG2CNT :
|
||||
//GPULOG("MAIN BG2 SETPROP 16B %08X\r\n", val);
|
||||
MainScreen.gpu->SetBGProp(2, val);
|
||||
mainEngine->SetBGProp(2, val);
|
||||
T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xC, val);
|
||||
return;
|
||||
case REG_DISPA_BG3CNT :
|
||||
//GPULOG("MAIN BG3 SETPROP 16B %08X\r\n", val);
|
||||
MainScreen.gpu->SetBGProp(3, val);
|
||||
mainEngine->SetBGProp(3, val);
|
||||
T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0xE, val);
|
||||
return;
|
||||
case REG_DISPB_BG0CNT :
|
||||
//GPULOG("SUB BG0 SETPROP 16B %08X\r\n", val);
|
||||
SubScreen.gpu->SetBGProp(0, val);
|
||||
subEngine->SetBGProp(0, val);
|
||||
T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1008, val);
|
||||
return;
|
||||
case REG_DISPB_BG1CNT :
|
||||
//GPULOG("SUB BG1 SETPROP 16B %08X\r\n", val);
|
||||
SubScreen.gpu->SetBGProp(1, val);
|
||||
subEngine->SetBGProp(1, val);
|
||||
T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x100A, val);
|
||||
return;
|
||||
case REG_DISPB_BG2CNT :
|
||||
//GPULOG("SUB BG2 SETPROP 16B %08X\r\n", val);
|
||||
SubScreen.gpu->SetBGProp(2, val);
|
||||
subEngine->SetBGProp(2, val);
|
||||
T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x100C, val);
|
||||
return;
|
||||
case REG_DISPB_BG3CNT :
|
||||
//GPULOG("SUB BG3 SETPROP 16B %08X\r\n", val);
|
||||
SubScreen.gpu->SetBGProp(3, val);
|
||||
subEngine->SetBGProp(3, val);
|
||||
T1WriteWord(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x100E, val);
|
||||
return;
|
||||
|
||||
|
@ -3898,28 +3905,28 @@ void FASTCALL _MMU_ARM9_write16(u32 adr, u16 val)
|
|||
case REG_DISPA_DISPCNT :
|
||||
{
|
||||
u32 v = (T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0) & 0xFFFF0000) | val;
|
||||
MainScreen.gpu->SetVideoProp(v);
|
||||
mainEngine->SetVideoProp(v);
|
||||
T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0, v);
|
||||
return;
|
||||
}
|
||||
case REG_DISPA_DISPCNT+2 :
|
||||
{
|
||||
u32 v = (T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0) & 0xFFFF) | ((u32) val << 16);
|
||||
MainScreen.gpu->SetVideoProp(v);
|
||||
mainEngine->SetVideoProp(v);
|
||||
T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0, v);
|
||||
}
|
||||
return;
|
||||
case REG_DISPA_DISPCAPCNT :
|
||||
{
|
||||
u32 v = (T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x64) & 0xFFFF0000) | val;
|
||||
GPU_set_DISPCAPCNT(v);
|
||||
mainEngine->SetDISPCAPCNT(v);
|
||||
T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x64, v);
|
||||
return;
|
||||
}
|
||||
case REG_DISPA_DISPCAPCNT + 2:
|
||||
{
|
||||
u32 v = (T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x64) & 0xFFFF) | ((u32)val << 16);
|
||||
GPU_set_DISPCAPCNT(v);
|
||||
mainEngine->SetDISPCAPCNT(v);
|
||||
T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x64, v);
|
||||
return;
|
||||
}
|
||||
|
@ -3927,7 +3934,7 @@ void FASTCALL _MMU_ARM9_write16(u32 adr, u16 val)
|
|||
case REG_DISPB_DISPCNT :
|
||||
{
|
||||
u32 v = (T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1000) & 0xFFFF0000) | val;
|
||||
SubScreen.gpu->SetVideoProp(v);
|
||||
subEngine->SetVideoProp(v);
|
||||
T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1000, v);
|
||||
return;
|
||||
}
|
||||
|
@ -3935,7 +3942,7 @@ void FASTCALL _MMU_ARM9_write16(u32 adr, u16 val)
|
|||
{
|
||||
//emu_halt();
|
||||
u32 v = (T1ReadLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1000) & 0xFFFF) | ((u32) val << 16);
|
||||
SubScreen.gpu->SetVideoProp(v);
|
||||
subEngine->SetVideoProp(v);
|
||||
T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1000, v);
|
||||
return;
|
||||
}
|
||||
|
@ -4083,6 +4090,9 @@ void FASTCALL _MMU_ARM9_write32(u32 adr, u32 val)
|
|||
MMU_new.write_dma(ARMCPU_ARM9,32,adr,val);
|
||||
return;
|
||||
}
|
||||
|
||||
GPUEngineBase *mainEngine = GPU->GetEngineMain();
|
||||
GPUEngineBase *subEngine = GPU->GetEngineSub();
|
||||
|
||||
switch(adr)
|
||||
{
|
||||
|
@ -4123,28 +4133,28 @@ void FASTCALL _MMU_ARM9_write32(u32 adr, u32 val)
|
|||
MMU_new.gxstat.write32(val);
|
||||
break;
|
||||
case REG_DISPA_BG2XL:
|
||||
MainScreen.gpu->setAffineStart(2,0,val);
|
||||
mainEngine->setAffineStart(2,0,val);
|
||||
return;
|
||||
case REG_DISPA_BG2YL:
|
||||
MainScreen.gpu->setAffineStart(2,1,val);
|
||||
mainEngine->setAffineStart(2,1,val);
|
||||
return;
|
||||
case REG_DISPB_BG2XL:
|
||||
SubScreen.gpu->setAffineStart(2,0,val);
|
||||
subEngine->setAffineStart(2,0,val);
|
||||
return;
|
||||
case REG_DISPB_BG2YL:
|
||||
SubScreen.gpu->setAffineStart(2,1,val);
|
||||
subEngine->setAffineStart(2,1,val);
|
||||
return;
|
||||
case REG_DISPA_BG3XL:
|
||||
MainScreen.gpu->setAffineStart(3,0,val);
|
||||
mainEngine->setAffineStart(3,0,val);
|
||||
return;
|
||||
case REG_DISPA_BG3YL:
|
||||
MainScreen.gpu->setAffineStart(3,1,val);
|
||||
mainEngine->setAffineStart(3,1,val);
|
||||
return;
|
||||
case REG_DISPB_BG3XL:
|
||||
SubScreen.gpu->setAffineStart(3,0,val);
|
||||
subEngine->setAffineStart(3,0,val);
|
||||
return;
|
||||
case REG_DISPB_BG3YL:
|
||||
SubScreen.gpu->setAffineStart(3,1,val);
|
||||
subEngine->setAffineStart(3,1,val);
|
||||
return;
|
||||
|
||||
// Alpha test reference value - Parameters:1
|
||||
|
@ -4187,77 +4197,77 @@ void FASTCALL _MMU_ARM9_write32(u32 adr, u32 val)
|
|||
|
||||
case REG_DISPA_WININ:
|
||||
{
|
||||
MainScreen.gpu->SetWININ(val & 0xFFFF) ;
|
||||
MainScreen.gpu->SetWINOUT16((val >> 16) & 0xFFFF) ;
|
||||
mainEngine->SetWININ(val & 0xFFFF) ;
|
||||
mainEngine->SetWINOUT16((val >> 16) & 0xFFFF) ;
|
||||
break;
|
||||
}
|
||||
case REG_DISPB_WININ:
|
||||
{
|
||||
SubScreen.gpu->SetWININ(val & 0xFFFF) ;
|
||||
SubScreen.gpu->SetWINOUT16((val >> 16) & 0xFFFF) ;
|
||||
subEngine->SetWININ(val & 0xFFFF) ;
|
||||
subEngine->SetWINOUT16((val >> 16) & 0xFFFF) ;
|
||||
break;
|
||||
}
|
||||
|
||||
case REG_DISPA_WIN0H:
|
||||
{
|
||||
MainScreen.gpu->SetWIN0_H(val & 0xFFFF);
|
||||
MainScreen.gpu->SetWIN1_H(val >> 16);
|
||||
mainEngine->SetWIN0_H(val & 0xFFFF);
|
||||
mainEngine->SetWIN1_H(val >> 16);
|
||||
break;
|
||||
}
|
||||
case REG_DISPA_WIN0V:
|
||||
{
|
||||
MainScreen.gpu->SetWIN0_V(val & 0xFFFF);
|
||||
MainScreen.gpu->SetWIN1_V(val >> 16);
|
||||
mainEngine->SetWIN0_V(val & 0xFFFF);
|
||||
mainEngine->SetWIN1_V(val >> 16);
|
||||
break;
|
||||
}
|
||||
case REG_DISPB_WIN0H:
|
||||
{
|
||||
SubScreen.gpu->SetWIN0_H(val & 0xFFFF);
|
||||
SubScreen.gpu->SetWIN1_H(val >> 16);
|
||||
subEngine->SetWIN0_H(val & 0xFFFF);
|
||||
subEngine->SetWIN1_H(val >> 16);
|
||||
break;
|
||||
}
|
||||
case REG_DISPB_WIN0V:
|
||||
{
|
||||
SubScreen.gpu->SetWIN0_V(val & 0xFFFF);
|
||||
SubScreen.gpu->SetWIN1_V(val >> 16);
|
||||
subEngine->SetWIN0_V(val & 0xFFFF);
|
||||
subEngine->SetWIN1_V(val >> 16);
|
||||
break;
|
||||
}
|
||||
|
||||
case REG_DISPA_MASTERBRIGHT:
|
||||
MainScreen.gpu->SetMasterBrightness(val & 0xFFFF);
|
||||
mainEngine->SetMasterBrightness(val & 0xFFFF);
|
||||
break;
|
||||
case REG_DISPB_MASTERBRIGHT:
|
||||
SubScreen.gpu->SetMasterBrightness(val & 0xFFFF);
|
||||
subEngine->SetMasterBrightness(val & 0xFFFF);
|
||||
break;
|
||||
|
||||
case REG_DISPA_BLDCNT:
|
||||
{
|
||||
MainScreen.gpu->SetBLDCNT(val & 0xFFFF);
|
||||
MainScreen.gpu->SetBLDALPHA(val >> 16);
|
||||
mainEngine->SetBLDCNT(val & 0xFFFF);
|
||||
mainEngine->SetBLDALPHA(val >> 16);
|
||||
break;
|
||||
}
|
||||
case REG_DISPB_BLDCNT:
|
||||
{
|
||||
SubScreen.gpu->SetBLDCNT(val & 0xFFFF);
|
||||
SubScreen.gpu->SetBLDALPHA(val >> 16);
|
||||
subEngine->SetBLDCNT(val & 0xFFFF);
|
||||
subEngine->SetBLDALPHA(val >> 16);
|
||||
break;
|
||||
}
|
||||
|
||||
case REG_DISPA_BLDY:
|
||||
MainScreen.gpu->SetBLDY_EVY(val & 0xFFFF);
|
||||
mainEngine->SetBLDY_EVY(val & 0xFFFF);
|
||||
break ;
|
||||
case REG_DISPB_BLDY:
|
||||
SubScreen.gpu->SetBLDY_EVY(val & 0xFFFF);
|
||||
subEngine->SetBLDY_EVY(val & 0xFFFF);
|
||||
break;
|
||||
|
||||
case REG_DISPA_DISPCNT :
|
||||
MainScreen.gpu->SetVideoProp(val);
|
||||
mainEngine->SetVideoProp(val);
|
||||
//GPULOG("MAIN INIT 32B %08X\r\n", val);
|
||||
T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0, val);
|
||||
return;
|
||||
|
||||
case REG_DISPB_DISPCNT :
|
||||
SubScreen.gpu->SetVideoProp(val);
|
||||
subEngine->SetVideoProp(val);
|
||||
//GPULOG("SUB INIT 32B %08X\r\n", val);
|
||||
T1WriteLong(MMU.MMU_MEM[ARMCPU_ARM9][0x40], 0x1000, val);
|
||||
return;
|
||||
|
@ -4348,29 +4358,29 @@ void FASTCALL _MMU_ARM9_write32(u32 adr, u32 val)
|
|||
return;
|
||||
case REG_DISPA_DISPCAPCNT :
|
||||
//INFO("MMU write32: REG_DISPA_DISPCAPCNT 0x%X\n", val);
|
||||
GPU_set_DISPCAPCNT(val);
|
||||
mainEngine->SetDISPCAPCNT(val);
|
||||
T1WriteLong(MMU.ARM9_REG, 0x64, val);
|
||||
return;
|
||||
|
||||
case REG_DISPA_BG0CNT :
|
||||
MainScreen.gpu->SetBGProp(0, (val & 0xFFFF));
|
||||
MainScreen.gpu->SetBGProp(1, (val >> 16));
|
||||
mainEngine->SetBGProp(0, (val & 0xFFFF));
|
||||
mainEngine->SetBGProp(1, (val >> 16));
|
||||
//if((val>>16)==0x400) emu_halt();
|
||||
T1WriteLong(MMU.ARM9_REG, 8, val);
|
||||
return;
|
||||
case REG_DISPA_BG2CNT :
|
||||
MainScreen.gpu->SetBGProp(2, (val & 0xFFFF));
|
||||
MainScreen.gpu->SetBGProp(3, (val >> 16));
|
||||
mainEngine->SetBGProp(2, (val & 0xFFFF));
|
||||
mainEngine->SetBGProp(3, (val >> 16));
|
||||
T1WriteLong(MMU.ARM9_REG, 0xC, val);
|
||||
return;
|
||||
case REG_DISPB_BG0CNT :
|
||||
SubScreen.gpu->SetBGProp(0, (val & 0xFFFF));
|
||||
SubScreen.gpu->SetBGProp(1, (val >> 16));
|
||||
subEngine->SetBGProp(0, (val & 0xFFFF));
|
||||
subEngine->SetBGProp(1, (val >> 16));
|
||||
T1WriteLong(MMU.ARM9_REG, 0x1008, val);
|
||||
return;
|
||||
case REG_DISPB_BG2CNT :
|
||||
SubScreen.gpu->SetBGProp(2, (val & 0xFFFF));
|
||||
SubScreen.gpu->SetBGProp(3, (val >> 16));
|
||||
subEngine->SetBGProp(2, (val & 0xFFFF));
|
||||
subEngine->SetBGProp(3, (val >> 16));
|
||||
T1WriteLong(MMU.ARM9_REG, 0x100C, val);
|
||||
return;
|
||||
case REG_DISPA_DISPMMEMFIFO:
|
||||
|
|
|
@ -146,10 +146,7 @@ int NDS_Init()
|
|||
|
||||
//got to print this somewhere..
|
||||
printf("%s\n", EMU_DESMUME_NAME_AND_VERSION());
|
||||
|
||||
if (Screen_Init() != 0)
|
||||
return -1;
|
||||
|
||||
|
||||
{
|
||||
char buf[MAX_PATH];
|
||||
memset(buf, 0, MAX_PATH);
|
||||
|
@ -171,6 +168,13 @@ int NDS_Init()
|
|||
NDS_ARM7.SetBaseMemoryInterfaceData(NULL);
|
||||
NDS_ARM7.ResetMemoryInterfaceToBase();
|
||||
|
||||
if (GPU != NULL)
|
||||
{
|
||||
delete GPU;
|
||||
}
|
||||
|
||||
GPU = new GPUSubsystem;
|
||||
|
||||
if (SPU_Init(SNDCORE_DUMMY, 740) != 0)
|
||||
return -1;
|
||||
|
||||
|
@ -186,7 +190,10 @@ void NDS_DeInit(void)
|
|||
{
|
||||
gameInfo.closeROM();
|
||||
SPU_DeInit();
|
||||
Screen_DeInit();
|
||||
|
||||
delete GPU;
|
||||
GPU = NULL;
|
||||
|
||||
MMU_DeInit();
|
||||
WIFI_DeInit();
|
||||
|
||||
|
@ -787,7 +794,8 @@ public:
|
|||
}
|
||||
void Advance()
|
||||
{
|
||||
bool capturing = (MainScreen.gpu->dispCapCnt.enabled || (MainScreen.gpu->dispCapCnt.val & 0x80000000));
|
||||
const GPUEngineBase *mainEngine = GPU->GetEngineMain();
|
||||
bool capturing = (mainEngine->dispCapCnt.enabled || (mainEngine->dispCapCnt.val & 0x80000000));
|
||||
|
||||
if(capturing && consecutiveNonCaptures > 30)
|
||||
{
|
||||
|
@ -798,7 +806,7 @@ public:
|
|||
SkipNext2DFrame = false;
|
||||
nextSkip = false;
|
||||
}
|
||||
else if((lastDisplayTarget != MainScreen.gpu->GetDisplayByID()) && lastSkip && !skipped)
|
||||
else if((lastDisplayTarget != mainEngine->GetDisplayByID()) && lastSkip && !skipped)
|
||||
{
|
||||
// if we're switching from not skipping to skipping
|
||||
// and the screens are also switching around this frame,
|
||||
|
@ -813,7 +821,7 @@ public:
|
|||
else if(!(consecutiveNonCaptures > 9000)) // arbitrary cap to avoid eventual wrap
|
||||
consecutiveNonCaptures++;
|
||||
|
||||
lastDisplayTarget = MainScreen.gpu->GetDisplayByID();
|
||||
lastDisplayTarget = mainEngine->GetDisplayByID();
|
||||
lastSkip = skipped;
|
||||
skipped = nextSkip;
|
||||
nextSkip = false;
|
||||
|
@ -1258,15 +1266,6 @@ void Sequencer::init()
|
|||
#endif
|
||||
}
|
||||
|
||||
//this isnt helping much right now. work on it later
|
||||
//#include "utils/task.h"
|
||||
//Task taskSubGpu(true);
|
||||
//void* renderSubScreen(void*)
|
||||
//{
|
||||
// GPU_RenderLine(&SubScreen, nds.VCount, SkipCur2DFrame);
|
||||
// return NULL;
|
||||
//}
|
||||
|
||||
static void execHardware_hblank()
|
||||
{
|
||||
//this logic keeps moving around.
|
||||
|
@ -1276,11 +1275,8 @@ static void execHardware_hblank()
|
|||
//scroll regs for the next scanline
|
||||
if(nds.VCount<192)
|
||||
{
|
||||
//taskSubGpu.execute(renderSubScreen,NULL);
|
||||
GPU_RenderLine(&MainScreen, nds.VCount, frameSkipper.ShouldSkip2D());
|
||||
GPU_RenderLine(&SubScreen, nds.VCount, frameSkipper.ShouldSkip2D());
|
||||
//taskSubGpu.finish();
|
||||
|
||||
GPU->RenderLine(nds.VCount, frameSkipper.ShouldSkip2D());
|
||||
|
||||
//trigger hblank dmas
|
||||
//but notice, we do that just after we finished drawing the line
|
||||
//(values copied by this hdma should not be used until the next scanline)
|
||||
|
@ -1330,10 +1326,10 @@ static void execHardware_hstart_vblankEnd()
|
|||
//some emulation housekeeping
|
||||
frameSkipper.Advance();
|
||||
|
||||
if (GPU_GetWillAutoBlitNativeToCustomBuffer())
|
||||
if (GPU->GetWillAutoBlitNativeToCustomBuffer())
|
||||
{
|
||||
MainScreen.gpu->BlitNativeToCustomFramebuffer();
|
||||
SubScreen.gpu->BlitNativeToCustomFramebuffer();
|
||||
GPU->GetEngineMain()->BlitNativeToCustomFramebuffer();
|
||||
GPU->GetEngineSub()->BlitNativeToCustomFramebuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2533,7 +2529,7 @@ void NDS_Reset()
|
|||
// Init calibration info
|
||||
memcpy(&TSCal, firmware->getTouchCalibrate(), sizeof(TSCalInfo));
|
||||
|
||||
Screen_Reset();
|
||||
GPU->Reset();
|
||||
|
||||
WIFI_Reset();
|
||||
memcpy(FW_Mac, (MMU.fw.data + 0x36), 6);
|
||||
|
@ -2903,15 +2899,15 @@ void NDS_suspendProcessingInput(bool suspend)
|
|||
|
||||
void NDS_swapScreen()
|
||||
{
|
||||
if (MainDisplay.GetEngineID() == GPUCOREID_MAIN)
|
||||
if (GPU->GetDisplayMain()->GetEngineID() == GPUCOREID_MAIN)
|
||||
{
|
||||
MainDisplay.SetEngineByID(GPUCOREID_SUB);
|
||||
TouchDisplay.SetEngineByID(GPUCOREID_MAIN);
|
||||
GPU->GetDisplayMain()->SetEngineByID(GPUCOREID_SUB);
|
||||
GPU->GetDisplayTouch()->SetEngineByID(GPUCOREID_MAIN);
|
||||
}
|
||||
else
|
||||
{
|
||||
MainDisplay.SetEngineByID(GPUCOREID_MAIN);
|
||||
TouchDisplay.SetEngineByID(GPUCOREID_SUB);
|
||||
GPU->GetDisplayMain()->SetEngineByID(GPUCOREID_MAIN);
|
||||
GPU->GetDisplayTouch()->SetEngineByID(GPUCOREID_SUB);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -371,6 +371,7 @@ resizeWindow( u16 width, u16 height, GLuint *screen_texture) {
|
|||
static void
|
||||
opengl_Draw( GLuint *texture, int software_convert) {
|
||||
GLenum errCode;
|
||||
u16 *gpuFramebuffer = GPU->GetNativeFramebuffer();
|
||||
|
||||
/* Clear The Screen And The Depth Buffer */
|
||||
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||
|
@ -385,9 +386,9 @@ opengl_Draw( GLuint *texture, int software_convert) {
|
|||
u8 converted[256 * 384 * 3];
|
||||
|
||||
for ( i = 0; i < (256 * 384); i++) {
|
||||
converted[(i * 3) + 0] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 0) & 0x1f) << 3;
|
||||
converted[(i * 3) + 1] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 5) & 0x1f) << 3;
|
||||
converted[(i * 3) + 2] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 10) & 0x1f) << 3;
|
||||
converted[(i * 3) + 0] = ((gpuFramebuffer[i] >> 0) & 0x1f) << 3;
|
||||
converted[(i * 3) + 1] = ((gpuFramebuffer[i] >> 5) & 0x1f) << 3;
|
||||
converted[(i * 3) + 2] = ((gpuFramebuffer[i] >> 10) & 0x1f) << 3;
|
||||
}
|
||||
|
||||
glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 256, 384,
|
||||
|
@ -399,7 +400,7 @@ opengl_Draw( GLuint *texture, int software_convert) {
|
|||
glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 256, 384,
|
||||
GL_RGBA,
|
||||
GL_UNSIGNED_SHORT_1_5_5_5_REV,
|
||||
&GPU_screen);
|
||||
gpuFramebuffer);
|
||||
}
|
||||
|
||||
if ((errCode = glGetError()) != GL_NO_ERROR) {
|
||||
|
@ -445,7 +446,7 @@ static void
|
|||
Draw( void) {
|
||||
SDL_Surface *rawImage;
|
||||
|
||||
rawImage = SDL_CreateRGBSurfaceFrom((void*)&GPU_screen, 256, 384, 16, 512, 0x001F, 0x03E0, 0x7C00, 0);
|
||||
rawImage = SDL_CreateRGBSurfaceFrom((void*)GPU->GetNativeFramebuffer(), 256, 384, 16, 512, 0x001F, 0x03E0, 0x7C00, 0);
|
||||
if(rawImage == NULL) return;
|
||||
|
||||
SDL_BlitSurface(rawImage, 0, surface, 0);
|
||||
|
@ -488,7 +489,7 @@ static void desmume_cycle(struct ctrls_event_config * cfg)
|
|||
}
|
||||
|
||||
#ifdef HAVE_LIBAGG
|
||||
T_AGG_RGB555 agg_targetScreen_cli((u8 *)GPU_screen, 256, 384, 512);
|
||||
T_AGG_RGB555 agg_targetScreen_cli((u8 *)GPU->GetNativeFramebuffer(), 256, 384, 512);
|
||||
#endif
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
|
|
|
@ -19,13 +19,6 @@
|
|||
#include <pthread.h>
|
||||
#include <libkern/OSAtomic.h>
|
||||
|
||||
enum GPUType
|
||||
{
|
||||
DS_GPU_TYPE_MAIN = 0,
|
||||
DS_GPU_TYPE_SUB,
|
||||
DS_GPU_TYPE_MAIN_AND_SUB
|
||||
};
|
||||
|
||||
@interface CocoaDSGPU : NSObject
|
||||
{
|
||||
UInt32 gpuStateFlags;
|
||||
|
@ -66,11 +59,8 @@ enum GPUType
|
|||
@property (assign) BOOL render3DFragmentSamplingHack;
|
||||
|
||||
- (BOOL) gpuStateByBit:(const UInt32)stateBit;
|
||||
- (BOOL) isGPUTypeDisplayed:(const NSInteger)theGpuType;
|
||||
- (void) hideGPUType:(const NSInteger)theGpuType;
|
||||
- (void) showGPUType:(const NSInteger)theGpuType;
|
||||
|
||||
- (NSString *) render3DRenderingEngineString;
|
||||
- (void) clearWithColor:(const uint16_t)colorBGRA5551;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -79,12 +69,6 @@ extern "C"
|
|||
{
|
||||
#endif
|
||||
|
||||
void GPU_FillScreenWithBGRA5551(const uint16_t colorValue);
|
||||
void SetGPULayerState(const GPUType gpuType, const unsigned int i, const bool state);
|
||||
bool GetGPULayerState(const GPUType gpuType, const unsigned int i);
|
||||
void SetGPUDisplayState(const GPUType gpuType, const bool state);
|
||||
bool GetGPUDisplayState(const GPUType gpuType);
|
||||
|
||||
bool OSXOpenGLRendererInit();
|
||||
bool OSXOpenGLRendererBegin();
|
||||
void OSXOpenGLRendererEnd();
|
||||
|
|
|
@ -104,8 +104,7 @@ GPU3DInterface *core3DList[] = {
|
|||
&OSXOpenGLRendererEnd,
|
||||
&OSXOpenGLRendererFramebufferDidResize);
|
||||
|
||||
GPU_SetWillAutoBlitNativeToCustomBuffer(false);
|
||||
GPU_FillScreenWithBGRA5551(0x8000);
|
||||
GPU->SetWillAutoBlitNativeToCustomBuffer(false);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -151,14 +150,14 @@ GPU3DInterface *core3DList[] = {
|
|||
- (void) setGpuDimensions:(NSSize)theDimensions
|
||||
{
|
||||
pthread_rwlock_wrlock(self.rwlockProducer);
|
||||
GPU_SetFramebufferSize(theDimensions.width, theDimensions.height);
|
||||
GPU->SetCustomFramebufferSize(theDimensions.width, theDimensions.height);
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
}
|
||||
|
||||
- (NSSize) gpuDimensions
|
||||
{
|
||||
pthread_rwlock_rdlock(self.rwlockProducer);
|
||||
const NSSize dimensions = NSMakeSize(GPU_GetFramebufferWidth(), GPU_GetFramebufferHeight());
|
||||
const NSSize dimensions = NSMakeSize(GPU->GetCustomFramebufferWidth(), GPU->GetCustomFramebufferHeight());
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
return dimensions;
|
||||
|
@ -375,7 +374,7 @@ GPU3DInterface *core3DList[] = {
|
|||
- (void) setLayerMainGPU:(BOOL)gpuState
|
||||
{
|
||||
pthread_rwlock_wrlock(self.rwlockProducer);
|
||||
SetGPUDisplayState(DS_GPU_TYPE_MAIN, (gpuState) ? true : false);
|
||||
GPU->GetEngineMain()->SetEnableState((gpuState) ? true : false);
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
OSSpinLockLock(&spinlockGpuState);
|
||||
|
@ -386,7 +385,7 @@ GPU3DInterface *core3DList[] = {
|
|||
- (BOOL) layerMainGPU
|
||||
{
|
||||
pthread_rwlock_rdlock(self.rwlockProducer);
|
||||
const BOOL gpuState = GetGPUDisplayState(DS_GPU_TYPE_MAIN) ? YES : NO;
|
||||
const BOOL gpuState = GPU->GetEngineMain()->GetEnableState() ? YES : NO;
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
return gpuState;
|
||||
|
@ -395,7 +394,7 @@ GPU3DInterface *core3DList[] = {
|
|||
- (void) setLayerMainBG0:(BOOL)layerState
|
||||
{
|
||||
pthread_rwlock_wrlock(self.rwlockProducer);
|
||||
SetGPULayerState(DS_GPU_TYPE_MAIN, 0, (layerState) ? true : false);
|
||||
GPU->GetEngineMain()->SetLayerEnableState(0, (layerState) ? true : false);
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
OSSpinLockLock(&spinlockGpuState);
|
||||
|
@ -406,7 +405,7 @@ GPU3DInterface *core3DList[] = {
|
|||
- (BOOL) layerMainBG0
|
||||
{
|
||||
pthread_rwlock_rdlock(self.rwlockProducer);
|
||||
const BOOL layerState = GetGPULayerState(DS_GPU_TYPE_MAIN, 0) ? YES : NO;
|
||||
const BOOL layerState = GPU->GetEngineMain()->GetLayerEnableState(0);
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
return layerState;
|
||||
|
@ -415,7 +414,7 @@ GPU3DInterface *core3DList[] = {
|
|||
- (void) setLayerMainBG1:(BOOL)layerState
|
||||
{
|
||||
pthread_rwlock_wrlock(self.rwlockProducer);
|
||||
SetGPULayerState(DS_GPU_TYPE_MAIN, 1, (layerState) ? true : false);
|
||||
GPU->GetEngineMain()->SetLayerEnableState(1, (layerState) ? true : false);
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
OSSpinLockLock(&spinlockGpuState);
|
||||
|
@ -426,7 +425,7 @@ GPU3DInterface *core3DList[] = {
|
|||
- (BOOL) layerMainBG1
|
||||
{
|
||||
pthread_rwlock_rdlock(self.rwlockProducer);
|
||||
const BOOL layerState = GetGPULayerState(DS_GPU_TYPE_MAIN, 1) ? YES : NO;
|
||||
const BOOL layerState = GPU->GetEngineMain()->GetLayerEnableState(1);
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
return layerState;
|
||||
|
@ -435,7 +434,7 @@ GPU3DInterface *core3DList[] = {
|
|||
- (void) setLayerMainBG2:(BOOL)layerState
|
||||
{
|
||||
pthread_rwlock_wrlock(self.rwlockProducer);
|
||||
SetGPULayerState(DS_GPU_TYPE_MAIN, 2, (layerState) ? true : false);
|
||||
GPU->GetEngineMain()->SetLayerEnableState(2, (layerState) ? true : false);
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
OSSpinLockLock(&spinlockGpuState);
|
||||
|
@ -446,7 +445,7 @@ GPU3DInterface *core3DList[] = {
|
|||
- (BOOL) layerMainBG2
|
||||
{
|
||||
pthread_rwlock_rdlock(self.rwlockProducer);
|
||||
const BOOL layerState = GetGPULayerState(DS_GPU_TYPE_MAIN, 2) ? YES : NO;
|
||||
const BOOL layerState = GPU->GetEngineMain()->GetLayerEnableState(2);
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
return layerState;
|
||||
|
@ -455,7 +454,7 @@ GPU3DInterface *core3DList[] = {
|
|||
- (void) setLayerMainBG3:(BOOL)layerState
|
||||
{
|
||||
pthread_rwlock_wrlock(self.rwlockProducer);
|
||||
SetGPULayerState(DS_GPU_TYPE_MAIN, 3, (layerState) ? true : false);
|
||||
GPU->GetEngineMain()->SetLayerEnableState(3, (layerState) ? true : false);
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
OSSpinLockLock(&spinlockGpuState);
|
||||
|
@ -466,7 +465,7 @@ GPU3DInterface *core3DList[] = {
|
|||
- (BOOL) layerMainBG3
|
||||
{
|
||||
pthread_rwlock_rdlock(self.rwlockProducer);
|
||||
const BOOL layerState = GetGPULayerState(DS_GPU_TYPE_MAIN, 3) ? YES : NO;
|
||||
const BOOL layerState = GPU->GetEngineMain()->GetLayerEnableState(3);
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
return layerState;
|
||||
|
@ -475,7 +474,7 @@ GPU3DInterface *core3DList[] = {
|
|||
- (void) setLayerMainOBJ:(BOOL)layerState
|
||||
{
|
||||
pthread_rwlock_wrlock(self.rwlockProducer);
|
||||
SetGPULayerState(DS_GPU_TYPE_MAIN, 4, (layerState) ? true : false);
|
||||
GPU->GetEngineMain()->SetLayerEnableState(4, (layerState) ? true : false);
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
OSSpinLockLock(&spinlockGpuState);
|
||||
|
@ -486,7 +485,7 @@ GPU3DInterface *core3DList[] = {
|
|||
- (BOOL) layerMainOBJ
|
||||
{
|
||||
pthread_rwlock_rdlock(self.rwlockProducer);
|
||||
const BOOL layerState = GetGPULayerState(DS_GPU_TYPE_MAIN, 4) ? YES : NO;
|
||||
const BOOL layerState = GPU->GetEngineMain()->GetLayerEnableState(4);
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
return layerState;
|
||||
|
@ -495,7 +494,7 @@ GPU3DInterface *core3DList[] = {
|
|||
- (void) setLayerSubGPU:(BOOL)gpuState
|
||||
{
|
||||
pthread_rwlock_wrlock(self.rwlockProducer);
|
||||
SetGPUDisplayState(DS_GPU_TYPE_SUB, (gpuState) ? true : false);
|
||||
GPU->GetEngineSub()->SetEnableState((gpuState) ? true : false);
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
OSSpinLockLock(&spinlockGpuState);
|
||||
|
@ -506,7 +505,7 @@ GPU3DInterface *core3DList[] = {
|
|||
- (BOOL) layerSubGPU
|
||||
{
|
||||
pthread_rwlock_rdlock(self.rwlockProducer);
|
||||
const BOOL gpuState = GetGPUDisplayState(DS_GPU_TYPE_SUB) ? YES : NO;
|
||||
const BOOL gpuState = GPU->GetEngineSub()->GetEnableState() ? YES : NO;
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
return gpuState;
|
||||
|
@ -515,7 +514,7 @@ GPU3DInterface *core3DList[] = {
|
|||
- (void) setLayerSubBG0:(BOOL)layerState
|
||||
{
|
||||
pthread_rwlock_wrlock(self.rwlockProducer);
|
||||
SetGPULayerState(DS_GPU_TYPE_SUB, 0, (layerState) ? true : false);
|
||||
GPU->GetEngineSub()->SetLayerEnableState(0, (layerState) ? true : false);
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
OSSpinLockLock(&spinlockGpuState);
|
||||
|
@ -526,7 +525,7 @@ GPU3DInterface *core3DList[] = {
|
|||
- (BOOL) layerSubBG0
|
||||
{
|
||||
pthread_rwlock_rdlock(self.rwlockProducer);
|
||||
const BOOL layerState = GetGPULayerState(DS_GPU_TYPE_SUB, 0) ? YES : NO;
|
||||
const BOOL layerState = GPU->GetEngineSub()->GetLayerEnableState(0);
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
return layerState;
|
||||
|
@ -535,7 +534,7 @@ GPU3DInterface *core3DList[] = {
|
|||
- (void) setLayerSubBG1:(BOOL)layerState
|
||||
{
|
||||
pthread_rwlock_wrlock(self.rwlockProducer);
|
||||
SetGPULayerState(DS_GPU_TYPE_SUB, 1, (layerState) ? true : false);
|
||||
GPU->GetEngineSub()->SetLayerEnableState(1, (layerState) ? true : false);
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
OSSpinLockLock(&spinlockGpuState);
|
||||
|
@ -546,7 +545,7 @@ GPU3DInterface *core3DList[] = {
|
|||
- (BOOL) layerSubBG1
|
||||
{
|
||||
pthread_rwlock_rdlock(self.rwlockProducer);
|
||||
const BOOL layerState = GetGPULayerState(DS_GPU_TYPE_SUB, 1) ? YES : NO;
|
||||
const BOOL layerState = GPU->GetEngineSub()->GetLayerEnableState(1);
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
return layerState;
|
||||
|
@ -555,7 +554,7 @@ GPU3DInterface *core3DList[] = {
|
|||
- (void) setLayerSubBG2:(BOOL)layerState
|
||||
{
|
||||
pthread_rwlock_wrlock(self.rwlockProducer);
|
||||
SetGPULayerState(DS_GPU_TYPE_SUB, 2, (layerState) ? true : false);
|
||||
GPU->GetEngineSub()->SetLayerEnableState(2, (layerState) ? true : false);
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
OSSpinLockLock(&spinlockGpuState);
|
||||
|
@ -566,7 +565,7 @@ GPU3DInterface *core3DList[] = {
|
|||
- (BOOL) layerSubBG2
|
||||
{
|
||||
pthread_rwlock_rdlock(self.rwlockProducer);
|
||||
const BOOL layerState = GetGPULayerState(DS_GPU_TYPE_SUB, 2) ? YES : NO;
|
||||
const BOOL layerState = GPU->GetEngineSub()->GetLayerEnableState(2);
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
return layerState;
|
||||
|
@ -575,7 +574,7 @@ GPU3DInterface *core3DList[] = {
|
|||
- (void) setLayerSubBG3:(BOOL)layerState
|
||||
{
|
||||
pthread_rwlock_wrlock(self.rwlockProducer);
|
||||
SetGPULayerState(DS_GPU_TYPE_SUB, 3, (layerState) ? true : false);
|
||||
GPU->GetEngineSub()->SetLayerEnableState(3, (layerState) ? true : false);
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
OSSpinLockLock(&spinlockGpuState);
|
||||
|
@ -586,7 +585,7 @@ GPU3DInterface *core3DList[] = {
|
|||
- (BOOL) layerSubBG3
|
||||
{
|
||||
pthread_rwlock_rdlock(self.rwlockProducer);
|
||||
const BOOL layerState = GetGPULayerState(DS_GPU_TYPE_SUB, 3) ? YES : NO;
|
||||
const BOOL layerState = GPU->GetEngineSub()->GetLayerEnableState(3);
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
return layerState;
|
||||
|
@ -595,7 +594,7 @@ GPU3DInterface *core3DList[] = {
|
|||
- (void) setLayerSubOBJ:(BOOL)layerState
|
||||
{
|
||||
pthread_rwlock_wrlock(self.rwlockProducer);
|
||||
SetGPULayerState(DS_GPU_TYPE_SUB, 4, (layerState) ? true : false);
|
||||
GPU->GetEngineSub()->SetLayerEnableState(4, (layerState) ? true : false);
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
OSSpinLockLock(&spinlockGpuState);
|
||||
|
@ -606,7 +605,7 @@ GPU3DInterface *core3DList[] = {
|
|||
- (BOOL) layerSubOBJ
|
||||
{
|
||||
pthread_rwlock_rdlock(self.rwlockProducer);
|
||||
const BOOL layerState = GetGPULayerState(DS_GPU_TYPE_SUB, 4) ? YES : NO;
|
||||
const BOOL layerState = GPU->GetEngineSub()->GetLayerEnableState(4);
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
return layerState;
|
||||
|
@ -617,93 +616,6 @@ GPU3DInterface *core3DList[] = {
|
|||
return ([self gpuStateFlags] & (1 << stateBit)) ? YES : NO;
|
||||
}
|
||||
|
||||
- (BOOL) isGPUTypeDisplayed:(const NSInteger)theGpuType
|
||||
{
|
||||
BOOL result = NO;
|
||||
const UInt32 flags = [self gpuStateFlags];
|
||||
|
||||
switch (theGpuType)
|
||||
{
|
||||
case DS_GPU_TYPE_MAIN:
|
||||
if (flags & GPUSTATE_MAIN_GPU_MASK)
|
||||
{
|
||||
result = YES;
|
||||
}
|
||||
break;
|
||||
|
||||
case DS_GPU_TYPE_SUB:
|
||||
if (flags & GPUSTATE_SUB_GPU_MASK)
|
||||
{
|
||||
result = YES;
|
||||
}
|
||||
break;
|
||||
|
||||
case DS_GPU_TYPE_MAIN_AND_SUB:
|
||||
if (flags & (GPUSTATE_MAIN_GPU_MASK | GPUSTATE_SUB_GPU_MASK))
|
||||
{
|
||||
result = YES;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (void) hideGPUType:(const NSInteger)theGpuType
|
||||
{
|
||||
UInt32 flags = [self gpuStateFlags];
|
||||
|
||||
switch (theGpuType)
|
||||
{
|
||||
case DS_GPU_TYPE_MAIN:
|
||||
flags &= ~GPUSTATE_MAIN_GPU_MASK;
|
||||
break;
|
||||
|
||||
case DS_GPU_TYPE_SUB:
|
||||
flags &= ~GPUSTATE_SUB_GPU_MASK;
|
||||
break;
|
||||
|
||||
case DS_GPU_TYPE_MAIN_AND_SUB:
|
||||
flags &= ~GPUSTATE_MAIN_GPU_MASK;
|
||||
flags &= ~GPUSTATE_SUB_GPU_MASK;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
[self setGpuStateFlags:flags];
|
||||
}
|
||||
|
||||
- (void) showGPUType:(const NSInteger)theGpuType
|
||||
{
|
||||
UInt32 flags = [self gpuStateFlags];
|
||||
|
||||
switch (theGpuType)
|
||||
{
|
||||
case DS_GPU_TYPE_MAIN:
|
||||
flags |= GPUSTATE_MAIN_GPU_MASK;
|
||||
break;
|
||||
|
||||
case DS_GPU_TYPE_SUB:
|
||||
flags |= GPUSTATE_SUB_GPU_MASK;
|
||||
break;
|
||||
|
||||
case DS_GPU_TYPE_MAIN_AND_SUB:
|
||||
flags |= GPUSTATE_MAIN_GPU_MASK;
|
||||
flags |= GPUSTATE_SUB_GPU_MASK;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
[self setGpuStateFlags:flags];
|
||||
}
|
||||
|
||||
- (NSString *) render3DRenderingEngineString
|
||||
{
|
||||
NSString *theString = @"Uninitialized";
|
||||
|
@ -724,164 +636,15 @@ GPU3DInterface *core3DList[] = {
|
|||
return theString;
|
||||
}
|
||||
|
||||
- (void) clearWithColor:(const uint16_t)colorBGRA5551
|
||||
{
|
||||
pthread_rwlock_wrlock(self.rwlockProducer);
|
||||
GPU->ClearWithColor(colorBGRA5551);
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
void SetGPULayerState(const GPUType gpuType, const unsigned int i, const bool state)
|
||||
{
|
||||
GPUEngineBase *theGpu = NULL;
|
||||
|
||||
// Check bounds on the layer index.
|
||||
if (i > 4)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (gpuType)
|
||||
{
|
||||
case DS_GPU_TYPE_SUB:
|
||||
theGpu = SubScreen.gpu;
|
||||
break;
|
||||
|
||||
case DS_GPU_TYPE_MAIN:
|
||||
theGpu = MainScreen.gpu;
|
||||
break;
|
||||
|
||||
case DS_GPU_TYPE_MAIN_AND_SUB:
|
||||
SetGPULayerState(DS_GPU_TYPE_SUB, i, state); // Recursive call
|
||||
theGpu = MainScreen.gpu;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (theGpu != NULL)
|
||||
{
|
||||
theGpu->SetLayerState(i, state);
|
||||
}
|
||||
}
|
||||
|
||||
bool GetGPULayerState(const GPUType gpuType, const unsigned int i)
|
||||
{
|
||||
bool theState = false;
|
||||
|
||||
// Check bounds on the layer index.
|
||||
if (i > 4)
|
||||
{
|
||||
return theState;
|
||||
}
|
||||
|
||||
switch (gpuType)
|
||||
{
|
||||
case DS_GPU_TYPE_SUB:
|
||||
if (SubScreen.gpu != NULL)
|
||||
{
|
||||
theState = CommonSettings.dispLayers[SubScreen.gpu->core][i];
|
||||
}
|
||||
break;
|
||||
|
||||
case DS_GPU_TYPE_MAIN:
|
||||
if (MainScreen.gpu != NULL)
|
||||
{
|
||||
theState = CommonSettings.dispLayers[MainScreen.gpu->core][i];
|
||||
}
|
||||
break;
|
||||
|
||||
case DS_GPU_TYPE_MAIN_AND_SUB:
|
||||
if (SubScreen.gpu != NULL && MainScreen.gpu != NULL)
|
||||
{
|
||||
theState = (CommonSettings.dispLayers[SubScreen.gpu->core][i] && CommonSettings.dispLayers[MainScreen.gpu->core][i]);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return theState;
|
||||
}
|
||||
|
||||
void SetGPUDisplayState(const GPUType gpuType, const bool state)
|
||||
{
|
||||
switch (gpuType)
|
||||
{
|
||||
case DS_GPU_TYPE_SUB:
|
||||
CommonSettings.showGpu.sub = state;
|
||||
break;
|
||||
|
||||
case DS_GPU_TYPE_MAIN:
|
||||
CommonSettings.showGpu.main = state;
|
||||
break;
|
||||
|
||||
case DS_GPU_TYPE_MAIN_AND_SUB:
|
||||
CommonSettings.showGpu.sub = state;
|
||||
CommonSettings.showGpu.main = state;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool GetGPUDisplayState(const GPUType gpuType)
|
||||
{
|
||||
bool theState = false;
|
||||
|
||||
switch (gpuType)
|
||||
{
|
||||
case DS_GPU_TYPE_SUB:
|
||||
theState = CommonSettings.showGpu.sub;
|
||||
break;
|
||||
|
||||
case DS_GPU_TYPE_MAIN:
|
||||
theState = CommonSettings.showGpu.main;
|
||||
break;
|
||||
|
||||
case DS_GPU_TYPE_MAIN_AND_SUB:
|
||||
theState = (CommonSettings.showGpu.sub && CommonSettings.showGpu.main);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return theState;
|
||||
}
|
||||
|
||||
void GPU_FillScreenWithBGRA5551(const uint16_t colorValue)
|
||||
{
|
||||
const NDSDisplayInfo &dispInfo = NDS_GetDisplayInfo();
|
||||
const size_t pixCountNative = GPU_FRAMEBUFFER_NATIVE_WIDTH * GPU_FRAMEBUFFER_NATIVE_HEIGHT;
|
||||
const size_t pixCountCustom = dispInfo.customWidth * dispInfo.customHeight;
|
||||
|
||||
#ifdef __APPLE__
|
||||
const uint16_t colorValuePattern[] = {colorValue, colorValue, colorValue, colorValue, colorValue, colorValue, colorValue, colorValue};
|
||||
|
||||
memset_pattern16(MainScreen.gpu->nativeBuffer, colorValuePattern, pixCountNative * sizeof(uint16_t));
|
||||
memset_pattern16(SubScreen.gpu->nativeBuffer, colorValuePattern, pixCountNative * sizeof(uint16_t));
|
||||
|
||||
if (pixCountCustom % 16 == 0)
|
||||
{
|
||||
memset_pattern16(MainScreen.gpu->customBuffer, colorValuePattern, pixCountCustom * sizeof(uint16_t));
|
||||
memset_pattern16(SubScreen.gpu->customBuffer, colorValuePattern, pixCountCustom * sizeof(uint16_t));
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
for (size_t i = 0; i < pixCountNative; i++)
|
||||
{
|
||||
MainScreen.gpu->nativeBuffer[i] = colorValue;
|
||||
SubScreen.gpu->nativeBuffer[i] = colorValue;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < pixCountCustom; i++)
|
||||
{
|
||||
MainScreen.gpu->customBuffer[i] = colorValue;
|
||||
SubScreen.gpu->customBuffer[i] = colorValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CGLContextObj OSXOpenGLRendererContext = NULL;
|
||||
CGLPBufferObj OSXOpenGLRendererPBuffer = NULL;
|
||||
|
||||
|
|
|
@ -909,7 +909,6 @@ volatile bool execute = true;
|
|||
|
||||
pthread_mutex_lock(&threadParam.mutexThreadExecute);
|
||||
NDS_Reset();
|
||||
GPU_FillScreenWithBGRA5551(0xFFFF);
|
||||
pthread_mutex_unlock(&threadParam.mutexThreadExecute);
|
||||
|
||||
[self restoreCoreState];
|
||||
|
|
|
@ -538,7 +538,7 @@
|
|||
- (NSSize) displaySize
|
||||
{
|
||||
pthread_rwlock_rdlock(self.rwlockProducer);
|
||||
NSSize size = NSMakeSize((CGFloat)GPU_GetFramebufferWidth(), (displayMode == DS_DISPLAY_TYPE_DUAL) ? (CGFloat)(GPU_GetFramebufferHeight() * 2): (CGFloat)GPU_GetFramebufferHeight());
|
||||
NSSize size = NSMakeSize((CGFloat)GPU->GetCustomFramebufferWidth(), (displayMode == DS_DISPLAY_TYPE_DUAL) ? (CGFloat)(GPU->GetCustomFramebufferHeight() * 2): (CGFloat)GPU->GetCustomFramebufferHeight());
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
return size;
|
||||
|
@ -676,7 +676,7 @@
|
|||
|
||||
- (NSBitmapImageRep *) bitmapImageRep
|
||||
{
|
||||
const NDSDisplayInfo &dispInfo = NDS_GetDisplayInfo();
|
||||
const NDSDisplayInfo &dispInfo = GPU->GetDisplayInfo();
|
||||
const NSInteger dispMode = [self displayMode];
|
||||
|
||||
uint16_t *displayBuffer = dispInfo.masterCustomBuffer;
|
||||
|
@ -700,9 +700,10 @@
|
|||
}
|
||||
|
||||
uint32_t *bitmapData = (uint32_t *)[imageRep bitmapData];
|
||||
|
||||
pthread_rwlock_rdlock(self.rwlockProducer);
|
||||
MainScreen.gpu->BlitNativeToCustomFramebuffer();
|
||||
SubScreen.gpu->BlitNativeToCustomFramebuffer();
|
||||
GPU->GetEngineMain()->BlitNativeToCustomFramebuffer();
|
||||
GPU->GetEngineSub()->BlitNativeToCustomFramebuffer();
|
||||
RGB555ToRGBA8888Buffer(displayBuffer, bitmapData, (w * h));
|
||||
pthread_rwlock_unlock(self.rwlockProducer);
|
||||
|
||||
|
@ -796,7 +797,7 @@
|
|||
|
||||
pthread_rwlock_rdlock(self.rwlockProducer);
|
||||
|
||||
const NDSDisplayInfo &dispInfo = NDS_GetDisplayInfo();
|
||||
const NDSDisplayInfo &dispInfo = GPU->GetDisplayInfo();
|
||||
const NSInteger dispMode = [self displayMode];
|
||||
const uint16_t newGpuWidth = dispInfo.customWidth;
|
||||
const uint16_t newGpuHeight = dispInfo.customHeight;
|
||||
|
|
|
@ -279,7 +279,7 @@ volatile bool execute = true;
|
|||
|
||||
- (const void *)videoBuffer
|
||||
{
|
||||
return GPU_screen;
|
||||
return GPU->GetNativeFramebuffer();
|
||||
}
|
||||
|
||||
- (GLenum)pixelFormat
|
||||
|
|
|
@ -1798,7 +1798,6 @@
|
|||
// Update the UI to indicate that a ROM has indeed been loaded.
|
||||
[self updateAllWindowTitles];
|
||||
|
||||
GPU_FillScreenWithBGRA5551(0xFFFF);
|
||||
for (DisplayWindowController *windowController in windowList)
|
||||
{
|
||||
[CocoaDSUtil messageSendOneWay:[[windowController cdsVideoOutput] receivePort] msgID:MESSAGE_REPROCESS_AND_REDRAW];
|
||||
|
@ -1829,6 +1828,7 @@
|
|||
{
|
||||
BOOL result = NO;
|
||||
|
||||
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
|
||||
[self setCurrentSaveStateURL:nil];
|
||||
|
||||
isSaveStateEdited = NO;
|
||||
|
@ -1876,7 +1876,7 @@
|
|||
// Update the UI to indicate that the ROM has finished unloading.
|
||||
[self updateAllWindowTitles];
|
||||
|
||||
GPU_FillScreenWithBGRA5551(0x8000);
|
||||
[[cdsCore cdsGPU] clearWithColor:0x8000];
|
||||
for (DisplayWindowController *windowController in windowList)
|
||||
{
|
||||
[CocoaDSUtil messageSendOneWay:[[windowController cdsVideoOutput] receivePort] msgID:MESSAGE_REPROCESS_AND_REDRAW];
|
||||
|
@ -1894,7 +1894,6 @@
|
|||
[[windowController window] displayIfNeeded];
|
||||
}
|
||||
|
||||
CocoaDSCore *cdsCore = (CocoaDSCore *)[cdsCoreController content];
|
||||
[cdsCore setSlot1StatusText:NSSTRING_STATUS_EMULATION_NOT_RUNNING];
|
||||
[[cdsCore cdsController] reset];
|
||||
[[cdsCore cdsController] updateMicLevel];
|
||||
|
@ -2196,7 +2195,6 @@
|
|||
[[cdsCore cdsGPU] setRender3DMultisample:[[NSUserDefaults standardUserDefaults] boolForKey:@"Render3D_Multisample"]];
|
||||
[[cdsCore cdsGPU] setRender3DFragmentSamplingHack:[[NSUserDefaults standardUserDefaults] boolForKey:@"Render3D_FragmentSamplingHack"]];
|
||||
[[cdsCore cdsGPU] setGpuScale:(NSUInteger)[[NSUserDefaults standardUserDefaults] integerForKey:@"Render3D_ScalingFactor"]];
|
||||
GPU_FillScreenWithBGRA5551(0x8000); // Fill the GPU framebuffer with black after the GPU scaling factor is set.
|
||||
|
||||
// Set the stylus options per user preferences.
|
||||
[[cdsCore cdsController] setStylusPressure:[[NSUserDefaults standardUserDefaults] integerForKey:@"Emulation_StylusPressure"]];
|
||||
|
|
|
@ -2325,7 +2325,7 @@ void gfx3d_VBlankEndSignal(bool skipFrame)
|
|||
|
||||
if (!CommonSettings.showGpu.main)
|
||||
{
|
||||
memset(gfx3d_colorRGBA6665, 0, GPU_GetFramebufferWidth() * GPU_GetFramebufferHeight() * sizeof(FragmentColor));
|
||||
memset(gfx3d_colorRGBA6665, 0, GPU->GetCustomFramebufferWidth() * GPU->GetCustomFramebufferHeight() * sizeof(FragmentColor));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2440,13 +2440,13 @@ void gfx3d_glGetLightColor(const size_t index, u32 &dst)
|
|||
const FragmentColor* gfx3d_GetLineDataRGBA6665(const size_t line)
|
||||
{
|
||||
CurrentRenderer->RenderFinish();
|
||||
return (gfx3d_colorRGBA6665 + (line * GPU_GetFramebufferWidth()));
|
||||
return (gfx3d_colorRGBA6665 + (line * GPU->GetCustomFramebufferWidth()));
|
||||
}
|
||||
|
||||
const u16* gfx3d_GetLineDataRGBA5551(const size_t line)
|
||||
{
|
||||
CurrentRenderer->RenderFinish();
|
||||
return (gfx3d_colorRGBA5551 + (line * GPU_GetFramebufferWidth()));
|
||||
return (gfx3d_colorRGBA5551 + (line * GPU->GetCustomFramebufferWidth()));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -221,15 +221,16 @@ static void Printscreen()
|
|||
gchar *filename;
|
||||
GError *error = NULL;
|
||||
u8 *rgb;
|
||||
u16 *gpuFramebuffer = GPU->GetNativeFramebuffer();
|
||||
static int seq = 0;
|
||||
|
||||
rgb = (u8 *) malloc(SCREENS_PIXEL_SIZE*3);
|
||||
if (!rgb)
|
||||
return;
|
||||
for (int i = 0; i < SCREENS_PIXEL_SIZE; i++) {
|
||||
rgb[(i * 3) + 0] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 0) & 0x1f) << 3;
|
||||
rgb[(i * 3) + 1] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 5) & 0x1f) << 3;
|
||||
rgb[(i * 3) + 2] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 10) & 0x1f) << 3;
|
||||
rgb[(i * 3) + 0] = ((gpuFramebuffer[i] >> 0) & 0x1f) << 3;
|
||||
rgb[(i * 3) + 1] = ((gpuFramebuffer[i] >> 5) & 0x1f) << 3;
|
||||
rgb[(i * 3) + 2] = ((gpuFramebuffer[i] >> 10) & 0x1f) << 3;
|
||||
}
|
||||
|
||||
screenshot = gdk_pixbuf_new_from_data(rgb,
|
||||
|
@ -523,18 +524,18 @@ void on_wgt_Exec_toggled (GtkToggleToolButton *toggletoolbutton, gpointer user
|
|||
|
||||
|
||||
/* LAYERS ***** ***** ***** ***** */
|
||||
static void change_bgx_layer(int layer, gboolean state, NDS_Screen scr) {
|
||||
static void change_bgx_layer(int layer, gboolean state, GPUEngineBase *gpuEngine) {
|
||||
//if(!desmume_running()) return;
|
||||
|
||||
scr.gpu->SetLayerState(layer, (state) ? true : false);
|
||||
gpuEngine->SetLayerEnableState(layer, (state) ? true : false);
|
||||
|
||||
//fprintf(stderr,"Changed Layer %s to %d\n",layer,state);
|
||||
}
|
||||
void on_wc_1_BGXX_toggled (GtkToggleButton *togglebutton, gpointer user_data) {
|
||||
int layer = dyn_CAST(int,user_data);
|
||||
change_bgx_layer(layer, gtk_toggle_button_get_active(togglebutton), MainScreen);
|
||||
change_bgx_layer(layer, gtk_toggle_button_get_active(togglebutton), GPU->GetEngineMain());
|
||||
}
|
||||
void on_wc_2_BGXX_toggled (GtkToggleButton *togglebutton, gpointer user_data) {
|
||||
int layer = dyn_CAST(int,user_data);
|
||||
change_bgx_layer(layer, gtk_toggle_button_get_active(togglebutton), SubScreen);
|
||||
change_bgx_layer(layer, gtk_toggle_button_get_active(togglebutton), GPU->GetEngineSub());
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ static void decode_screen () {
|
|||
|
||||
int x,y, m, W,H,L,BL;
|
||||
u32 image[RAW_H*2][RAW_W], pix;
|
||||
u16 * pixel = (u16*)&GPU_screen;
|
||||
u16 * pixel = GPU->GetNativeFramebuffer();
|
||||
u32 * rgb32 = &on_screen_image32[0];
|
||||
|
||||
/* decode colors */
|
||||
|
|
|
@ -237,14 +237,16 @@ static void my_gl_Texture2D() {
|
|||
|
||||
static void
|
||||
my_gl_ScreenTex( int software_convert) {
|
||||
u16 *gpuFramebuffer = GPU->GetNativeFramebuffer();
|
||||
|
||||
if ( software_convert) {
|
||||
u8 converted[256 * 384 * 3];
|
||||
int i;
|
||||
|
||||
for ( i = 0; i < (256 * 384); i++) {
|
||||
converted[(i * 3) + 0] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 0) & 0x1f) << 3;
|
||||
converted[(i * 3) + 1] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 5) & 0x1f) << 3;
|
||||
converted[(i * 3) + 2] = ((*((u16 *)&GPU_screen[(i<<1)]) >> 10) & 0x1f) << 3;
|
||||
converted[(i * 3) + 0] = ((gpuFramebuffer[i] >> 0) & 0x1f) << 3;
|
||||
converted[(i * 3) + 1] = ((gpuFramebuffer[i] >> 5) & 0x1f) << 3;
|
||||
converted[(i * 3) + 2] = ((gpuFramebuffer[i] >> 10) & 0x1f) << 3;
|
||||
}
|
||||
|
||||
glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 256, 384,
|
||||
|
@ -256,7 +258,7 @@ my_gl_ScreenTex( int software_convert) {
|
|||
glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, 256, 384,
|
||||
GL_RGBA,
|
||||
GL_UNSIGNED_SHORT_1_5_5_5_REV,
|
||||
&GPU_screen);
|
||||
gpuFramebuffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,7 +301,7 @@ gboolean screen (GtkWidget * widget, int viewportscreen) {
|
|||
if (desmume_running()) {
|
||||
|
||||
// master bright
|
||||
gpu = ((screen)?SubScreen:MainScreen).gpu;
|
||||
gpu = (screen) ? GPU->GetEngineSub() : GPU->GetEngineMain();
|
||||
|
||||
switch (gpu->MasterBrightMode)
|
||||
{
|
||||
|
|
|
@ -1411,8 +1411,6 @@ static void Reset()
|
|||
bool shouldBeRunning = desmume_running();
|
||||
Pause();
|
||||
NDS_Reset();
|
||||
// Clear the NDS screen
|
||||
memset(GPU_screen, 0xFF, GPU_GetFramebufferWidth() * GPU_GetFramebufferHeight() * 2 * sizeof(u16));
|
||||
RedrawScreen();
|
||||
if (shouldBeRunning) {
|
||||
Launch();
|
||||
|
@ -1549,7 +1547,7 @@ static inline void RGB555ToBGRA8888Buffer(const uint16_t *__restrict__ srcBuffer
|
|||
|
||||
static inline void gpu_screen_to_rgb(u32* dst)
|
||||
{
|
||||
RGB555ToRGBA8888Buffer((u16*)GPU_screen, dst, 256 * 384);
|
||||
RGB555ToRGBA8888Buffer(GPU->GetNativeFramebuffer(), dst, 256 * 384);
|
||||
}
|
||||
|
||||
static inline void drawScreen(cairo_t* cr, u32* buf, gint w, gint h) {
|
||||
|
@ -1674,7 +1672,7 @@ static gboolean ExposeDrawingArea (GtkWidget *widget, GdkEventExpose *event, gpo
|
|||
}
|
||||
|
||||
static void RedrawScreen() {
|
||||
RGB555ToBGRA8888Buffer((u16*)GPU_screen, video->GetSrcBufferPtr(), 256 * 384);
|
||||
RGB555ToBGRA8888Buffer(GPU->GetNativeFramebuffer(), video->GetSrcBufferPtr(), 256 * 384);
|
||||
#ifdef HAVE_LIBAGG
|
||||
aggDraw.hud->attach((u8*)video->GetSrcBufferPtr(), 256, 384, 1024);
|
||||
osd->update();
|
||||
|
@ -2127,14 +2125,14 @@ static void ToggleLayerVisibility(GtkToggleAction* action, gpointer data)
|
|||
case MAIN_BG_2:
|
||||
case MAIN_BG_3:
|
||||
case MAIN_OBJ:
|
||||
MainScreen.gpu->SetLayerState(Layer, (active == TRUE) ? true : false);
|
||||
GPU->GetEngineMain()->SetLayerEnableState(Layer, (active == TRUE) ? true : false);
|
||||
break;
|
||||
case SUB_BG_0:
|
||||
case SUB_BG_1:
|
||||
case SUB_BG_2:
|
||||
case SUB_BG_3:
|
||||
case SUB_OBJ:
|
||||
SubScreen.gpu->SetLayerState(Layer-SUB_BG_0, (active == TRUE) ? true : false);
|
||||
GPU->GetEngineSub()->SetLayerEnableState(Layer-SUB_BG_0, (active == TRUE) ? true : false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -2458,7 +2456,7 @@ gboolean EmuLoop(gpointer data)
|
|||
desmume_cycle(); /* Emule ! */
|
||||
|
||||
_updateDTools();
|
||||
avout_x264.updateVideo((u16*)GPU_screen);
|
||||
avout_x264.updateVideo(GPU->GetNativeFramebuffer());
|
||||
RedrawScreen();
|
||||
|
||||
if (!config.fpslimiter || keys_latch & KEYMASK_(KEY_BOOST - 1)) {
|
||||
|
|
|
@ -2228,7 +2228,7 @@ public:
|
|||
char temp [256];
|
||||
sprintf(temp, " " /*"mismatch at "*/ "byte %d(0x%X at 0x%X): %d(0x%X) != %d(0x%X)\n", i, i, dst, *src,*src, *dst,*dst);
|
||||
|
||||
if(ptr == GPU_screen || ptr == gfx3d_colorRGBA6665) // ignore screen-only differences since frame skipping can cause them and it's probably ok
|
||||
if(ptr == GPU->GetNativeFramebuffer() || ptr == GPU->GetCustomFramebuffer() || ptr == gfx3d_colorRGBA6665) // ignore screen-only differences since frame skipping can cause them and it's probably ok
|
||||
break;
|
||||
|
||||
differences.push_back(temp); // <-- probably the best place for a breakpoint
|
||||
|
|
|
@ -106,7 +106,7 @@ bool Video::setFilter(VideoFilterTypeID filterID) {
|
|||
}
|
||||
|
||||
unsigned int* Video::runFilter() {
|
||||
RGB555ToRGBA8888Buffer((u16*)GPU_screen, this->mFilter.GetSrcBufferPtr(), 256 * 384);
|
||||
RGB555ToRGBA8888Buffer(GPU->GetNativeFramebuffer(), this->mFilter.GetSrcBufferPtr(), 256 * 384);
|
||||
unsigned int* buf = this->mFilter.RunFilter();
|
||||
this->screenBufferUpdated(buf, this->getDstSize(), this->getDstScale());
|
||||
return buf;
|
||||
|
|
|
@ -95,7 +95,7 @@ bool NDS_3D_ChangeCore(int newCore)
|
|||
return result;
|
||||
}
|
||||
|
||||
Render3DError error = newRenderer->SetFramebufferSize(GPU_GetFramebufferWidth(), GPU_GetFramebufferHeight());
|
||||
Render3DError error = newRenderer->SetFramebufferSize(GPU->GetCustomFramebufferWidth(), GPU->GetCustomFramebufferHeight());
|
||||
if (error != RENDER3DERROR_NOERR)
|
||||
{
|
||||
return result;
|
||||
|
@ -218,7 +218,6 @@ Render3D::Render3D()
|
|||
Render3D::~Render3D()
|
||||
{
|
||||
free_aligned(_framebufferColor);
|
||||
TexCache_Reset();
|
||||
}
|
||||
|
||||
RendererID Render3D::GetRenderID()
|
||||
|
|
|
@ -162,13 +162,13 @@ void HK_QuickScreenShot(int param, bool justPressed)
|
|||
case path.PNG:
|
||||
{
|
||||
strcat(buffer, ".png");
|
||||
NDS_WritePNG(buffer, GPU_screen);
|
||||
NDS_WritePNG(buffer, GPU->GetNativeFramebuffer());
|
||||
}
|
||||
break;
|
||||
case path.BMP:
|
||||
{
|
||||
strcat(buffer, ".bmp");
|
||||
NDS_WriteBMP(buffer, GPU_screen);
|
||||
NDS_WriteBMP(buffer, GPU->GetNativeFramebuffer());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -220,9 +220,9 @@ void HK_PrintScreen(int param, bool justPressed)
|
|||
filename = outFilename;
|
||||
|
||||
if(toupper(strright(filename,4)) == ".PNG")
|
||||
NDS_WritePNG(filename.c_str(), GPU_screen);
|
||||
NDS_WritePNG(filename.c_str(), GPU->GetNativeFramebuffer());
|
||||
else if(toupper(strright(filename,4)) == ".BMP")
|
||||
NDS_WriteBMP(filename.c_str(), GPU_screen);
|
||||
NDS_WriteBMP(filename.c_str(), GPU->GetNativeFramebuffer());
|
||||
}
|
||||
|
||||
if(unpause) NDS_UnPause(false);
|
||||
|
|
|
@ -816,7 +816,7 @@ void ToDSScreenRelativeCoords(s32& x, s32& y, int whichScreen)
|
|||
}
|
||||
|
||||
// finally, make it relative to the correct screen
|
||||
const bool isMainGPUFirst = (MainDisplay.GetEngineID() == GPUCOREID_MAIN);
|
||||
const bool isMainGPUFirst = (GPU->GetDisplayMain()->GetEngineID() == GPUCOREID_MAIN);
|
||||
|
||||
if (video.layout == 0 || video.layout == 2)
|
||||
{
|
||||
|
@ -1656,7 +1656,7 @@ static void OGL_DoDisplay()
|
|||
|
||||
|
||||
RECT srcRects [2];
|
||||
const bool isMainGPUFirst = (MainDisplay.GetEngineID() == GPUCOREID_MAIN);
|
||||
const bool isMainGPUFirst = (GPU->GetDisplayMain()->GetEngineID() == GPUCOREID_MAIN);
|
||||
|
||||
if(video.swap == 0)
|
||||
{
|
||||
|
@ -1774,7 +1774,7 @@ static void DD_DoDisplay()
|
|||
|
||||
RECT* dstRects [2] = {&MainScreenRect, &SubScreenRect};
|
||||
RECT* srcRects [2];
|
||||
const bool isMainGPUFirst = (MainDisplay.GetEngineID() == GPUCOREID_MAIN);
|
||||
const bool isMainGPUFirst = (GPU->GetDisplayMain()->GetEngineID() == GPUCOREID_MAIN);
|
||||
|
||||
if(video.swap == 0)
|
||||
{
|
||||
|
@ -1999,7 +1999,7 @@ void Display()
|
|||
{
|
||||
if(CommonSettings.single_core())
|
||||
{
|
||||
video.srcBuffer = (u8*)GPU_screen;
|
||||
video.srcBuffer = (u8*)GPU->GetNativeFramebuffer();
|
||||
DoDisplay(true);
|
||||
}
|
||||
else
|
||||
|
@ -2019,7 +2019,7 @@ void Display()
|
|||
newestDisplayBuffer += diff;
|
||||
else newestDisplayBuffer = (currDisplayBuffer+2)%3;
|
||||
|
||||
memcpy(displayBuffers[newestDisplayBuffer],GPU_screen,256*192*4);
|
||||
memcpy(displayBuffers[newestDisplayBuffer],GPU->GetNativeFramebuffer(),256*192*4);
|
||||
|
||||
g_mutex_unlock(display_mutex);
|
||||
}
|
||||
|
@ -2119,7 +2119,7 @@ static void StepRunLoop_Core()
|
|||
win_sound_samplecounter = DESMUME_SAMPLE_RATE/60;
|
||||
}
|
||||
inFrameBoundary = true;
|
||||
DRV_AviVideoUpdate((u16*)GPU_screen);
|
||||
DRV_AviVideoUpdate(GPU->GetNativeFramebuffer());
|
||||
|
||||
extern bool rewinding;
|
||||
|
||||
|
@ -2143,7 +2143,7 @@ static void StepRunLoop_Paused()
|
|||
// periodically update single-core OSD when paused and in the foreground
|
||||
if(CommonSettings.single_core() && GetActiveWindow() == mainLoopData.hwnd)
|
||||
{
|
||||
video.srcBuffer = (u8*)GPU_screen;
|
||||
video.srcBuffer = (u8*)GPU->GetNativeFramebuffer();
|
||||
DoDisplay(true);
|
||||
}
|
||||
|
||||
|
@ -3263,6 +3263,7 @@ int _main()
|
|||
CommonSettings.wifi.infraBridgeAdapter = GetPrivateProfileInt("Wifi", "BridgeAdapter", 0, IniName);
|
||||
|
||||
NDS_Init();
|
||||
GPU->ClearWithColor(0xFFFF);
|
||||
|
||||
#ifdef GDB_STUB
|
||||
gdbstub_mutex_init();
|
||||
|
@ -4045,7 +4046,7 @@ void CloseRom()
|
|||
|
||||
// clear screen so the last frame we rendered doesn't stick around
|
||||
// (TODO: maybe NDS_Reset should do this?)
|
||||
memset(GPU_screen, 0xFF, GPU_GetFramebufferWidth() * GPU_GetFramebufferHeight() * 2 * sizeof(u16));
|
||||
GPU->ClearWithColor(0xFFFF);
|
||||
|
||||
InvalidateRect(MainWindow->getHWnd(), NULL, TRUE); // make sure the window refreshes with the cleared screen
|
||||
|
||||
|
@ -4238,7 +4239,7 @@ void ScreenshotToClipboard(bool extraInfo)
|
|||
bmi.bV4Height = -384;
|
||||
|
||||
FillRect(hMemDC, &rc, (HBRUSH)GetStockObject(WHITE_BRUSH));
|
||||
SetDIBitsToDevice(hMemDC, 0, 0, 256, 384, 0, 0, 0, 384, &GPU_screen[0], (BITMAPINFO*)&bmi, DIB_RGB_COLORS);
|
||||
SetDIBitsToDevice(hMemDC, 0, 0, 256, 384, 0, 0, 0, 384, GPU->GetNativeFramebuffer(), (BITMAPINFO*)&bmi, DIB_RGB_COLORS);
|
||||
|
||||
if(extraInfo)
|
||||
{
|
||||
|
@ -4382,10 +4383,10 @@ void SaveWindowPos(HWND hwnd)
|
|||
|
||||
static void TwiddleLayer(UINT ctlid, int core, int layer)
|
||||
{
|
||||
GPUEngineBase *gpu = ((GPUCoreID)core == GPUCOREID_MAIN) ? MainScreen.gpu : SubScreen.gpu;
|
||||
GPUEngineBase *gpu = ((GPUCoreID)core == GPUCOREID_MAIN) ? GPU->GetEngineMain() : GPU->GetEngineSub();
|
||||
|
||||
const bool newLayerState = !CommonSettings.dispLayers[core][layer];
|
||||
gpu->SetLayerState(layer, newLayerState);
|
||||
gpu->SetLayerEnableState(layer, newLayerState);
|
||||
MainWindow->checkMenu(ctlid, newLayerState);
|
||||
}
|
||||
|
||||
|
@ -5023,7 +5024,7 @@ DOKEYDOWN:
|
|||
{
|
||||
if(CommonSettings.single_core())
|
||||
{
|
||||
video.srcBuffer = (u8*)GPU_screen;
|
||||
video.srcBuffer = (u8*)GPU->GetNativeFramebuffer();
|
||||
DoDisplay(true);
|
||||
}
|
||||
}
|
||||
|
@ -5138,7 +5139,7 @@ DOKEYDOWN:
|
|||
}
|
||||
else
|
||||
{
|
||||
const bool isMainGPUFirst = (MainDisplay.GetEngineID() == GPUCOREID_MAIN);
|
||||
const bool isMainGPUFirst = (GPU->GetDisplayMain()->GetEngineID() == GPUCOREID_MAIN);
|
||||
if ((video.layout == 2) && ((video.swap == 0) || (video.swap == 2 && isMainGPUFirst) || (video.swap == 3 && !isMainGPUFirst))) return 0;
|
||||
|
||||
ToDSScreenRelativeCoords(x,y,1);
|
||||
|
|
|
@ -45,8 +45,8 @@ struct mapview_struct
|
|||
//we're going to make a copy of the gpu so that we don't wreck affine scroll params
|
||||
//hopefully we won't mess up anything else
|
||||
GPUEngineBase *realGpu;
|
||||
if(lcd) realGpu = SubScreen.gpu;
|
||||
else realGpu = MainScreen.gpu;
|
||||
if(lcd) realGpu = GPU->GetEngineSub();
|
||||
else realGpu = GPU->GetEngineMain();
|
||||
GPUEngineBase &gpu = *realGpu;
|
||||
|
||||
//forgive the gyrations, some of this junk in here is to remind us of gyrations we might have to go
|
||||
|
@ -100,13 +100,13 @@ LRESULT MapView_OnPaint(mapview_struct * win, HWND hwnd, WPARAM wParam, LPARAM l
|
|||
|
||||
if(win->lcd)
|
||||
{
|
||||
lg = SubScreen.gpu->BGSize[win->map][0];
|
||||
ht = SubScreen.gpu->BGSize[win->map][1];
|
||||
lg = GPU->GetEngineSub()->BGSize[win->map][0];
|
||||
ht = GPU->GetEngineSub()->BGSize[win->map][1];
|
||||
}
|
||||
else
|
||||
{
|
||||
lg = MainScreen.gpu->BGSize[win->map][0];
|
||||
ht = MainScreen.gpu->BGSize[win->map][1];
|
||||
lg = GPU->GetEngineMain()->BGSize[win->map][0];
|
||||
ht = GPU->GetEngineMain()->BGSize[win->map][1];
|
||||
}
|
||||
bmi.bV4Width = lg;
|
||||
bmi.bV4Height = -ht;
|
||||
|
@ -133,7 +133,7 @@ LRESULT MapView_OnPaint(mapview_struct * win, HWND hwnd, WPARAM wParam, LPARAM l
|
|||
sprintf(text, "extended slot %d", (bgcnt&(1<<13))?3:1);
|
||||
break;
|
||||
default :
|
||||
sprintf(text, "extended slot %d", MainScreen.gpu->BGExtPalSlot[win->map]);
|
||||
sprintf(text, "extended slot %d", GPU->GetEngineMain()->BGExtPalSlot[win->map]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -155,14 +155,14 @@ LRESULT MapView_OnPaint(mapview_struct * win, HWND hwnd, WPARAM wParam, LPARAM l
|
|||
sprintf(text, "0x%08X", (int)(0x6000000 + 0x800*((bgcnt>>8)&0x1F) + win->lcd*0x200000 + ((dispcnt>>27)&7)*0x10000));
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_SCR), text);
|
||||
|
||||
//sprintf(text, "%d x %d", MainScreen.gpu->BGPA[win->map], MainScreen.gpu->BGPB[win->map]);
|
||||
sprintf(text, "%d x %d", (int)MainScreen.gpu->BGSize[win->map][0], (int)MainScreen.gpu->BGSize[win->map][1]);
|
||||
//sprintf(text, "%d x %d", GPU->GetEngineMain()->BGPA[win->map], GPU->GetEngineMain()->BGPB[win->map]);
|
||||
sprintf(text, "%d x %d", (int)GPU->GetEngineMain()->BGSize[win->map][0], (int)GPU->GetEngineMain()->BGSize[win->map][1]);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_MSIZE), text);
|
||||
|
||||
//if (win->map==2) {
|
||||
// parms = &(MainScreen.gpu->dispx_st)->dispx_BG2PARMS;
|
||||
// parms = &(GPU->GetEngineMain()->dispx_st)->dispx_BG2PARMS;
|
||||
//} else {
|
||||
// parms = &(MainScreen.gpu->dispx_st)->dispx_BG3PARMS;
|
||||
// parms = &(GPU->GetEngineMain()->dispx_st)->dispx_BG3PARMS;
|
||||
//}
|
||||
//sprintf(text, "%d x %d", parms->BGxX, parms->BGxY);
|
||||
SetWindowText(GetDlgItem(hwnd, IDC_SCROLL), "useless");
|
||||
|
|
|
@ -280,7 +280,7 @@ BOOL CALLBACK ViewOAMProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
|
|||
OAMView = new oamview_struct;
|
||||
memset(OAMView, 0, sizeof(oamview_struct));
|
||||
OAMView->oam = MMU.ARM9_OAM;
|
||||
OAMView->gpu = MainScreen.gpu;
|
||||
OAMView->gpu = GPU->GetEngineMain();
|
||||
OAMView->scale = 2;
|
||||
OAMView->border = true;
|
||||
|
||||
|
@ -391,12 +391,12 @@ BOOL CALLBACK ViewOAMProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
|
|||
case 0 :
|
||||
OAMView->oam = MMU.ARM9_OAM;
|
||||
OAMView->num = 0;
|
||||
OAMView->gpu = MainScreen.gpu;
|
||||
OAMView->gpu = GPU->GetEngineMain();
|
||||
break;
|
||||
case 1 :
|
||||
OAMView->oam = (MMU.ARM9_OAM+0x400);
|
||||
OAMView->num = 0;
|
||||
OAMView->gpu = SubScreen.gpu;
|
||||
OAMView->gpu = GPU->GetEngineSub();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue