From 93a6318a427aecd6f5c2d5cbbea2f1378b3530a6 Mon Sep 17 00:00:00 2001 From: mtabachenko Date: Tue, 10 Feb 2009 12:54:10 +0000 Subject: [PATCH] -fix render & OSD (moved to gpu.cpp) --- desmume/src/GPU.cpp | 50 ++++++++++++++++++++++++++++++++++++ desmume/src/GPU.h | 4 +++ desmume/src/GPU_osd.cpp | 47 +-------------------------------- desmume/src/NDSSystem.cpp | 6 +++-- desmume/src/windows/main.cpp | 6 ++++- 5 files changed, 64 insertions(+), 49 deletions(-) diff --git a/desmume/src/GPU.cpp b/desmume/src/GPU.cpp index f711b67f6..fee6a9953 100644 --- a/desmume/src/GPU.cpp +++ b/desmume/src/GPU.cpp @@ -90,6 +90,8 @@ OSDCLASS *osd = NULL; OSDCLASS *osdA = NULL; OSDCLASS *osdB = NULL; +u16 gpu_angle = 0; + const short sizeTab[4][4][2] = { {{256,256}, {512, 256}, {256, 512}, {512, 512}}, @@ -3355,6 +3357,54 @@ void GPU::setAffineStart(int layer, int xy, u32 val) else affineInfo[layer-2].y = val; } +void gpu_UpdateRender() +{ + int x = 0, y = 0; + u16 *src = (u16*)GPU_tempScreen; + u16 *dst = (u16*)GPU_screen; + + switch (gpu_angle) + { + case 0: + memcpy(dst, src, 256*192*4); + break; + + case 90: + for(y = 0; y < 384; y++) + { + for(x = 0; x < 256; x++) + { + dst[(383 - y) + (x * 384)] = src[x + (y * 256)]; + } + } + break; + case 180: + for(y = 0; y < 384; y++) + { + for(x = 0; x < 256; x++) + { + dst[(255 - x) + ((383 - y) * 256)] = src[x + (y * 256)]; + } + } + break; + case 270: + for(y = 0; y < 384; y++) + { + for(x = 0; x < 256; x++) + { + dst[y + ((255 - x) * 384)] = src[x + (y * 256)]; + } + } + default: + break; + } +} + +void gpu_SetRotateScreen(u16 angle) +{ + gpu_angle = angle; +} + //here is an old bg mosaic with some old code commented out. I am going to leave it here for a while to look at it //sometimes in case I find a problem with the mosaic. //static void __setFinalColorBck(GPU *gpu, u32 passing, u8 bgnum, u8 *dst, u16 color, u16 x, bool opaque) diff --git a/desmume/src/GPU.h b/desmume/src/GPU.h index beb36d51f..96667d4ee 100644 --- a/desmume/src/GPU.h +++ b/desmume/src/GPU.h @@ -912,5 +912,9 @@ void SetupFinalPixelBlitter (GPU *gpu); #define GPU_setBGxHOFS(bg, gpu, val) gpu->dispx_st->dispx_BGxOFS[bg].BGxHOFS = (val & 0x1F) #define GPU_setBGxVOFS(bg, gpu, val) gpu->dispx_st->dispx_BGxOFS[bg].BGxVOFS = (val & 0x1F) +// render +void gpu_UpdateRender(); +void gpu_SetRotateScreen(u16 angle); + #endif diff --git a/desmume/src/GPU_osd.cpp b/desmume/src/GPU_osd.cpp index 530ad033c..ebd08f53a 100644 --- a/desmume/src/GPU_osd.cpp +++ b/desmume/src/GPU_osd.cpp @@ -143,55 +143,10 @@ void OSDCLASS::setColor(u16 col) void OSDCLASS::update() // don't optimized { - //if (!needUpdate) return; // don't update if buffer empty (speed up) + if (!needUpdate) return; // don't update if buffer empty (speed up) - int x, y; - u16 *src = (u16*)GPU_tempScreen; u16 *dst = (u16*)GPU_screen; - switch(rotAngle) - { - case 0: - for(y = 0; y < 384; y++) - { - for(x = 0; x < 256; x++) - { - dst[x + (y * 256)] = src[x + (y * 256)]; - } - } - break; - - case 90: - for(y = 0; y < 384; y++) - { - for(x = 0; x < 256; x++) - { - dst[(383 - y) + (x * 384)] = src[x + (y * 256)]; - } - } - break; - - case 180: - for(y = 0; y < 384; y++) - { - for(x = 0; x < 256; x++) - { - dst[(255 - x) + ((383 - y) * 256)] = src[x + (y * 256)]; - } - } - break; - - case 270: - for(y = 0; y < 384; y++) - { - for(x = 0; x < 256; x++) - { - dst[y + ((255 - x) * 384)] = src[x + (y * 256)]; - } - } - break; - } - if (mode!=255) dst+=offset*512; diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index 0c5ad38ee..e9121ba37 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -1217,7 +1217,7 @@ u32 NDS_exec(s32 nb) nds.lignerendu = FALSE; if(nds.VCount==192) { - //osdA->update(); //================================= this is don't correct, need swap engine + //osdA->update(); gfx3d_VBlankSignal(); T1WriteWord(ARM9Mem.ARM9_REG, 4, T1ReadWord(ARM9Mem.ARM9_REG, 4) | 1); @@ -1257,7 +1257,8 @@ u32 NDS_exec(s32 nb) else if(nds.VCount==263) { //osd->update(); - //osdB->update(); //================================= this is don't correct, need swap engine + //osdB->update(); + gpu_UpdateRender(); nds.nextHBlank = 3168; nds.VCount = 0; @@ -1783,6 +1784,7 @@ u32 NDS_exec(s32 nb) } // if(!nds.sleeping) else { + gpu_UpdateRender(); if((MMU.reg_IE[1] & MMU.reg_IF[1]) & (1<<22)) { nds.sleeping = FALSE; diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index 21a6ee872..5778f253a 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -621,7 +621,7 @@ void Display() ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags=DDSD_ALL; res=IDirectDrawSurface7_Lock(lpBackSurface,NULL,&ddsd,DDLOCK_WAIT, NULL); - + if (res == DD_OK) { char* buffer = (char*)ddsd.lpSurface; @@ -1231,6 +1231,8 @@ int WINAPI WinMain (HINSTANCE hThisInstance, exit(-1); } + gpu_SetRotateScreen(GPU_rotation); + /* default the firmware settings, they may get changed later */ NDS_FillDefaultFirmwareConfigData( &win_fw_config); @@ -1605,6 +1607,8 @@ void SetRotate(HWND hwnd, int rot) MainWindow->checkMenu(IDC_ROTATE180, MF_BYCOMMAND | ((GPU_rotation==180)?MF_CHECKED:MF_UNCHECKED)); MainWindow->checkMenu(IDC_ROTATE270, MF_BYCOMMAND | ((GPU_rotation==270)?MF_CHECKED:MF_UNCHECKED)); WritePrivateProfileInt("Video","Window Rotate",GPU_rotation,IniName); + + gpu_SetRotateScreen(GPU_rotation); } static void AviEnd()