diff --git a/desmume/src/GPU.cpp b/desmume/src/GPU.cpp index ac7a6a9d6..395021691 100644 --- a/desmume/src/GPU.cpp +++ b/desmume/src/GPU.cpp @@ -206,7 +206,6 @@ void GPU_Reset(GPU *g, u8 l) g->core = l; g->BGSize[0][0] = g->BGSize[1][0] = g->BGSize[2][0] = g->BGSize[3][0] = 256; g->BGSize[0][1] = g->BGSize[1][1] = g->BGSize[2][1] = g->BGSize[3][1] = 256; - g->dispOBJ = g->dispBG[0] = g->dispBG[1] = g->dispBG[2] = g->dispBG[3] = TRUE; g->spriteRenderMode = GPU::SPRITE_1D; @@ -247,11 +246,11 @@ static void GPU_resortBGs(GPU *gpu) #define OP ^ ! // if we untick boxes, layers become invisible //#define OP && - gpu->LayersEnable[0] = gpu->dispBG[0] OP(cnt->BG0_Enable/* && !(cnt->BG0_3D && (gpu->core==0))*/); - gpu->LayersEnable[1] = gpu->dispBG[1] OP(cnt->BG1_Enable); - gpu->LayersEnable[2] = gpu->dispBG[2] OP(cnt->BG2_Enable); - gpu->LayersEnable[3] = gpu->dispBG[3] OP(cnt->BG3_Enable); - gpu->LayersEnable[4] = gpu->dispOBJ OP(cnt->OBJ_Enable); + gpu->LayersEnable[0] = CommonSettings.dispLayers[gpu->core][0] OP(cnt->BG0_Enable/* && !(cnt->BG0_3D && (gpu->core==0))*/); + gpu->LayersEnable[1] = CommonSettings.dispLayers[gpu->core][1] OP(cnt->BG1_Enable); + gpu->LayersEnable[2] = CommonSettings.dispLayers[gpu->core][2] OP(cnt->BG2_Enable); + gpu->LayersEnable[3] = CommonSettings.dispLayers[gpu->core][3] OP(cnt->BG3_Enable); + gpu->LayersEnable[4] = CommonSettings.dispLayers[gpu->core][4] OP(cnt->OBJ_Enable); // KISS ! lower priority first, if same then lower num for (i=0;idispOBJ = 0; - else gpu->dispBG[num] = 0; + CommonSettings.dispLayers[gpu->core][num] = false; GPU_resortBGs(gpu); } void GPU_addBack(GPU * gpu, u8 num) { - //REG_DISPx_pack_test(gpu); - if (num == 4) gpu->dispOBJ = 1; - else gpu->dispBG[num] = 1; + CommonSettings.dispLayers[gpu->core][num] = true; GPU_resortBGs(gpu); } diff --git a/desmume/src/GPU.h b/desmume/src/GPU.h index 018661464..c3da7f448 100644 --- a/desmume/src/GPU.h +++ b/desmume/src/GPU.h @@ -691,9 +691,6 @@ struct GPU //FIFO fifo; - BOOL dispBG[4]; - BOOL dispOBJ; - u8 bgPrio[5]; BOOL bg0HasHighestPrio; diff --git a/desmume/src/NDSSystem.cpp b/desmume/src/NDSSystem.cpp index 1ceeaffcb..179a87355 100644 --- a/desmume/src/NDSSystem.cpp +++ b/desmume/src/NDSSystem.cpp @@ -2050,6 +2050,10 @@ void NDS_Reset() TotalLagFrames = 0; } + //spu must reset early on, since it will crash due to keeping a pointer into MMU memory for the sample pointers. yuck! + SPU_Reset(); + + MMU_Reset(); NDS_ARM7.BIOS_loaded = false; @@ -2351,7 +2355,6 @@ void NDS_Reset() Screen_Reset(); gfx3d_reset(); gpu3D->NDS_3D_Reset(); - SPU_Reset(); WIFI_Reset(); diff --git a/desmume/src/NDSSystem.h b/desmume/src/NDSSystem.h index 62f4b4861..9905c410d 100644 --- a/desmume/src/NDSSystem.h +++ b/desmume/src/NDSSystem.h @@ -508,6 +508,10 @@ extern struct TCommonSettings { for(int i=0;i<16;i++) spu_muteChannels[i] = false; + + for(int g=0;g<2;g++) + for(int x=0;x<5;x++) + dispLayers[g][x]=true; } bool GFX3D_HighResolutionInterpolateColor; bool GFX3D_EdgeMark; @@ -532,6 +536,8 @@ extern struct TCommonSettings { int num_cores; bool single_core() { return num_cores==1; } bool rigorous_timing; + + bool dispLayers[2][5]; FAST_ALIGN bool advanced_timing; diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index e57716e8a..7f7ea7af8 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -3556,6 +3556,23 @@ void SaveWindowPos(HWND hwnd) } +static void TwiddleLayer(UINT ctlid, int core, int layer) +{ + GPU* gpu = core==0?MainScreen.gpu:SubScreen.gpu; + if(CommonSettings.dispLayers[core][layer]) + { + GPU_remove(gpu,layer); + MainWindow->checkMenu(ctlid, false); + } + else + { + GPU_addBack(gpu,layer); + MainWindow->checkMenu(ctlid, true); + } + +} + + //======================================================================================== LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { @@ -4766,128 +4783,16 @@ DOKEYDOWN: WritePrivateProfileInt("Display","SubGpu",CommonSettings.showGpu.sub?1:0,IniName); return 0; - case IDM_MOBJ: - if(MainScreen.gpu->dispOBJ) - { - GPU_remove(MainScreen.gpu, 4); - MainWindow->checkMenu(IDM_MOBJ, false); - } - else - { - GPU_addBack(MainScreen.gpu, 4); - MainWindow->checkMenu(IDM_MOBJ, true); - } - return 0; - - case IDM_MBG0 : - if(MainScreen.gpu->dispBG[0]) - { - GPU_remove(MainScreen.gpu, 0); - MainWindow->checkMenu(IDM_MBG0, false); - } - else - { - GPU_addBack(MainScreen.gpu, 0); - MainWindow->checkMenu(IDM_MBG0, true); - } - return 0; - case IDM_MBG1 : - if(MainScreen.gpu->dispBG[1]) - { - GPU_remove(MainScreen.gpu, 1); - MainWindow->checkMenu(IDM_MBG1, false); - } - else - { - GPU_addBack(MainScreen.gpu, 1); - MainWindow->checkMenu(IDM_MBG1, true); - } - return 0; - case IDM_MBG2 : - if(MainScreen.gpu->dispBG[2]) - { - GPU_remove(MainScreen.gpu, 2); - MainWindow->checkMenu(IDM_MBG2, false); - } - else - { - GPU_addBack(MainScreen.gpu, 2); - MainWindow->checkMenu(IDM_MBG2, true); - } - return 0; - case IDM_MBG3 : - if(MainScreen.gpu->dispBG[3]) - { - GPU_remove(MainScreen.gpu, 3); - MainWindow->checkMenu(IDM_MBG3, false); - } - else - { - GPU_addBack(MainScreen.gpu, 3); - MainWindow->checkMenu(IDM_MBG3, true); - } - return 0; - - case IDM_SOBJ: - if(SubScreen.gpu->dispOBJ) - { - GPU_remove(SubScreen.gpu, 4); - MainWindow->checkMenu(IDM_SOBJ, false); - } - else - { - GPU_addBack(SubScreen.gpu, 4); - MainWindow->checkMenu(IDM_SOBJ, true); - } - return 0; - case IDM_SBG0 : - if(SubScreen.gpu->dispBG[0]) - { - GPU_remove(SubScreen.gpu, 0); - MainWindow->checkMenu(IDM_SBG0, false); - } - else - { - GPU_addBack(SubScreen.gpu, 0); - MainWindow->checkMenu(IDM_SBG0, true); - } - return 0; - case IDM_SBG1 : - if(SubScreen.gpu->dispBG[1]) - { - GPU_remove(SubScreen.gpu, 1); - MainWindow->checkMenu(IDM_SBG1, false); - } - else - { - GPU_addBack(SubScreen.gpu, 1); - MainWindow->checkMenu(IDM_SBG1, true); - } - return 0; - case IDM_SBG2 : - if(SubScreen.gpu->dispBG[2]) - { - GPU_remove(SubScreen.gpu, 2); - MainWindow->checkMenu(IDM_SBG2, false); - } - else - { - GPU_addBack(SubScreen.gpu, 2); - MainWindow->checkMenu(IDM_SBG2, true); - } - return 0; - case IDM_SBG3 : - if(SubScreen.gpu->dispBG[3]) - { - GPU_remove(SubScreen.gpu, 3); - MainWindow->checkMenu(IDM_SBG3, false); - } - else - { - GPU_addBack(SubScreen.gpu, 3); - MainWindow->checkMenu(IDM_SBG3, true); - } - return 0; + case IDM_MBG0: TwiddleLayer(IDM_MBG0,0,0); return 0; + case IDM_MBG1: TwiddleLayer(IDM_MBG1,0,1); return 0; + case IDM_MBG2: TwiddleLayer(IDM_MBG2,0,2); return 0; + case IDM_MBG3: TwiddleLayer(IDM_MBG3,0,3); return 0; + case IDM_MOBJ: TwiddleLayer(IDM_MOBJ,0,4); return 0; + case IDM_SBG0: TwiddleLayer(IDM_SBG0,0,0); return 0; + case IDM_SBG1: TwiddleLayer(IDM_SBG1,0,1); return 0; + case IDM_SBG2: TwiddleLayer(IDM_SBG2,0,2); return 0; + case IDM_SBG3: TwiddleLayer(IDM_SBG3,0,3); return 0; + case IDM_SOBJ: TwiddleLayer(IDM_SOBJ,0,4); return 0; case IDM_PAUSE: TogglePause();