From 72ecca03bb63753f329aeec86d9f4c28a2b43a51 Mon Sep 17 00:00:00 2001 From: Extrems Date: Fri, 23 Jan 2026 18:19:12 -0500 Subject: [PATCH] Routine maintenance --- source/fceugx.cpp | 13 ++++--------- source/fileop.cpp | 8 ++------ source/gcvideo.cpp | 42 +++++++++++----------------------------- source/mem2.cpp | 9 +-------- source/networkop.cpp | 7 +++---- source/preferences.cpp | 2 +- source/utils/oggplayer.c | 2 +- source/utils/vm/vm.h | 4 ++-- source/vmalloc.cpp | 2 -- 9 files changed, 25 insertions(+), 64 deletions(-) diff --git a/source/fceugx.cpp b/source/fceugx.cpp index d058d4b2..51607e74 100644 --- a/source/fceugx.cpp +++ b/source/fceugx.cpp @@ -118,7 +118,7 @@ void ExitApp() ExitCleanup(); if(ShutdownRequested) { - SYS_ResetSystem(SYS_POWEROFF_STANDBY, 0, 0); + SYS_ResetSystem(SYS_POWEROFF_STANDBY, 0, FALSE); } else if(GCSettings.AutoloadGame) { if( !!*(u32*)0x80001800 ) @@ -129,7 +129,7 @@ void ExitApp() else { // Wii channel support - SYS_ResetSystem( SYS_RETURNTOMENU, 0, 0 ); + SYS_ResetSystem(SYS_RETURNTOMENU, 0, FALSE); } } else { @@ -154,16 +154,11 @@ void ExitApp() if(GCSettings.ExitAction == 1) // Exit to Menu { - #ifdef HW_RVL - SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0); - #else - #define SOFTRESET_ADR ((volatile u32*)0xCC003024) - *SOFTRESET_ADR = 0x00000000; - #endif + SYS_ResetSystem(SYS_RETURNTOMENU, 0, FALSE); } else if(GCSettings.ExitAction == 2) // Shutdown Wii { - SYS_ResetSystem(SYS_POWEROFF_STANDBY, 0, 0); + SYS_ResetSystem(SYS_POWEROFF_STANDBY, 0, FALSE); } else // Exit to Loader { diff --git a/source/fileop.cpp b/source/fileop.cpp index ee77c4a2..8e0ef4e3 100644 --- a/source/fileop.cpp +++ b/source/fileop.cpp @@ -275,7 +275,7 @@ static bool MountFAT(int device, int silent) while(retry) { - if(disc->startup(disc) && fatMountSimple(name, disc)) + if(fatMountSimple(name, disc)) mounted = true; if(mounted || silent) @@ -325,12 +325,8 @@ bool MountDVD(bool silent) #ifdef HW_DOL DVD_Mount(); - s32 dvdstatus = DVD_GetDriveStatus(); - - if (dvdstatus == DVD_STATE_NO_DISK) -#else - if(!dvd->isInserted(dvd)) #endif + if(!dvd->isInserted(dvd)) { if(silent) break; diff --git a/source/gcvideo.cpp b/source/gcvideo.cpp index 8b48ed34..1af6f600 100644 --- a/source/gcvideo.cpp +++ b/source/gcvideo.cpp @@ -245,9 +245,7 @@ void SyncSpeed() /**************************************************************************** * VideoThreading ***************************************************************************/ -#define TSTACK 16384 static lwp_t vbthread = LWP_THREAD_NULL; -static unsigned char vbstack[TSTACK]; /**************************************************************************** * vbgetback @@ -388,7 +386,7 @@ void StopGX() GX_AbortFrame(); GX_Flush(); - VIDEO_SetBlack(TRUE); + VIDEO_SetBlack(true); VIDEO_Flush(); } @@ -454,25 +452,13 @@ static GXRModeObj * FindVideoMode() mode = &TVNtsc480Prog; break; case 3: // PAL (50Hz) - mode = &TVPal528IntDf; + mode = &TVPal576IntDfScale; break; case 4: // PAL (60Hz) mode = &TVEurgb60Hz480IntDf; break; default: mode = VIDEO_GetPreferredMode(NULL); - - if(mode == &TVPal576IntDfScale) - mode = &TVPal528IntDf; - - #ifdef HW_DOL - /* we have component cables, but the preferred mode is interlaced - * why don't we switch into progressive? - * on the Wii, the user can do this themselves on their Wii Settings */ - if(VIDEO_HaveComponentCable()) - mode = &TVNtsc480Prog; - #endif - break; } @@ -513,7 +499,7 @@ static GXRModeObj * FindVideoMode() } // check for progressive scan - if (mode->viTVMode == VI_TVMODE_NTSC_PROG) + if ((mode->viTVMode & 3) == VI_PROGRESSIVE) progressive = true; else progressive = false; @@ -559,15 +545,9 @@ static void SetupVideoMode(GXRModeObj * mode) VIDEO_ClearFrameBuffer (mode, xfb[1], COLOR_BLACK); VIDEO_SetNextFramebuffer (xfb[0]); - VIDEO_SetBlack (FALSE); + VIDEO_SetBlack (false); VIDEO_Flush (); - VIDEO_WaitVSync (); - - if (mode->viTVMode & VI_NON_INTERLACE) - VIDEO_WaitVSync(); - else - while (VIDEO_GetNextField()) - VIDEO_WaitVSync(); + VIDEO_WaitForFlush (); VIDEO_SetPostRetraceCallback ((VIRetraceCallback)copy_to_xfb); vmode = mode; @@ -602,13 +582,13 @@ InitGCVideo () #endif SetupVideoMode(rmode); - LWP_CreateThread (&vbthread, vbgetback, NULL, vbstack, TSTACK, 68); + LWP_CreateThread (&vbthread, vbgetback, NULL, NULL, 0, 68); // Initialize GX GXColor background = { 0, 0, 0, 0xff }; memset (&gp_fifo, 0, DEFAULT_FIFO_SIZE); GX_Init (&gp_fifo, DEFAULT_FIFO_SIZE); - GX_SetCopyClear (background, 0x00ffffff); + GX_SetCopyClear (background, GX_MAX_Z24); GX_SetDispCopyGamma (GX_GM_1_0); GX_SetCullMode (GX_CULL_NONE); } @@ -669,7 +649,7 @@ ResetVideo_Emu () SetupVideoMode(rmode); // reconfigure VI GXColor background = {0, 0, 0, 255}; - GX_SetCopyClear (background, 0x00ffffff); + GX_SetCopyClear (background, GX_MAX_Z24); // reconfigure GX GX_SetViewport (0, 0, rmode->fbWidth, rmode->efbHeight, 0, 1); @@ -707,7 +687,7 @@ ResetVideo_Emu () GX_InvalidateTexAll (); GX_InitTexObj (&texobj, texturemem, TEX_WIDTH, TEX_HEIGHT, GX_TF_RGB565, GX_CLAMP, GX_CLAMP, GX_FALSE); // initialize the texture obj we are going to use if (!(GCSettings.render&1)) - GX_InitTexObjLOD(&texobj,GX_NEAR,GX_NEAR_MIP_NEAR,2.5,9.0,0.0,GX_FALSE,GX_FALSE,GX_ANISO_1); // original/unfiltered video mode: force texture filtering OFF + GX_InitTexObjFilterMode(&texobj,GX_NEAR,GX_NEAR); // original/unfiltered video mode: force texture filtering OFF GX_LoadTexObj (&texobj, GX_TEXMAP0); memset(texturemem, 0, TEX_WIDTH * TEX_HEIGHT * 2); // clear texture memory } @@ -1000,7 +980,7 @@ ResetVideo_Menu () // clears the bg to color and clears the z buffer GXColor background = {0, 0, 0, 255}; - GX_SetCopyClear (background, 0x00ffffff); + GX_SetCopyClear (background, GX_MAX_Z24); yscale = GX_GetYScaleFactor(vmode->efbHeight,vmode->xfbHeight); xfbHeight = GX_SetDispCopyYScale(yscale); @@ -1062,7 +1042,7 @@ void Menu_Render() GX_DrawDone(); VIDEO_SetNextFramebuffer(xfb[whichfb]); VIDEO_Flush(); - VIDEO_WaitVSync(); + VIDEO_WaitForFlush(); } /**************************************************************************** diff --git a/source/mem2.cpp b/source/mem2.cpp index aeb937de..1b97350a 100644 --- a/source/mem2.cpp +++ b/source/mem2.cpp @@ -11,22 +11,15 @@ #ifdef HW_RVL -#include #include #include -#include static heap_cntrl mem2_heap; u32 InitMem2Manager () { int size = (10*1024*1024); - u32 level; - _CPU_ISR_Disable(level); - size &= ~0x1f; // round down, because otherwise we may exceed the area - void *mem2_heap_ptr = (void *)((u32)SYS_GetArena2Hi()-size); - SYS_SetArena2Hi(mem2_heap_ptr); - _CPU_ISR_Restore(level); + void *mem2_heap_ptr = SYS_AllocArenaMem2Hi(size, 32); size = __lwp_heap_init(&mem2_heap, mem2_heap_ptr, size, 32); return size; } diff --git a/source/networkop.cpp b/source/networkop.cpp index 4d1e407a..98244081 100644 --- a/source/networkop.cpp +++ b/source/networkop.cpp @@ -34,7 +34,6 @@ static int netHalt = 0; ***************************************************************************/ static lwp_t networkthread = LWP_THREAD_NULL; -static u8 netstack[32768] ATTRIBUTE_ALIGN (32); static void * netcb (void *arg) { @@ -97,7 +96,7 @@ static void * netcb (void *arg) hostip.s_addr = net_gethostip(); if (hostip.s_addr) { - strcpy(wiiIP, inet_ntoa(hostip)); + inet_ntoa_r(hostip, wiiIP, sizeof(wiiIP)); networkInit = true; prevInit = true; } @@ -117,7 +116,7 @@ void StartNetworkThread() netHalt = 0; if(networkthread == LWP_THREAD_NULL) - LWP_CreateThread(&networkthread, netcb, NULL, netstack, 8192, 40); + LWP_CreateThread(&networkthread, netcb, NULL, NULL, 0, 40); else LWP_ResumeThread(networkthread); } @@ -133,7 +132,7 @@ void StopNetworkThread() return; netHalt = 2; - LWP_ResumeThread(networkthread); + LWP_ContinueThread(networkthread); // wait for thread to finish LWP_JoinThread(networkthread, NULL); diff --git a/source/preferences.cpp b/source/preferences.cpp index 01353294..0180aefc 100644 --- a/source/preferences.cpp +++ b/source/preferences.cpp @@ -456,7 +456,7 @@ DefaultSettings () if(GCSettings.language == LANG_TRAD_CHINESE) GCSettings.language = LANG_SIMP_CHINESE; #else - GCSettings.language = LANG_ENGLISH; + GCSettings.language = SYS_GetLanguage() + LANG_ENGLISH; #endif GCSettings.LoadMethod = DEVICE_AUTO; // Auto, SD, DVD, USB, Network (SMB) diff --git a/source/utils/oggplayer.c b/source/utils/oggplayer.c index 3f7de9a9..05067426 100644 --- a/source/utils/oggplayer.c +++ b/source/utils/oggplayer.c @@ -278,7 +278,7 @@ static private_data_ogg private_ogg; #define STACKSIZE 8192 -static u8 oggplayer_stack[STACKSIZE]; +static u8 oggplayer_stack[STACKSIZE] ATTRIBUTE_ALIGN(8); static lwpq_t oggplayer_queue = LWP_TQUEUE_NULL; static lwp_t h_oggplayer = LWP_THREAD_NULL; static int ogg_thread_running = 0; diff --git a/source/utils/vm/vm.h b/source/utils/vm/vm.h index 1a86163d..fcfcfc49 100644 --- a/source/utils/vm/vm.h +++ b/source/utils/vm/vm.h @@ -15,8 +15,8 @@ #define KB (1024) #define MB (1024*KB) -#define MRAM_BACKING (4*MB) // Use 2MB to page our 16MB -#define ARAM_RESERVED (64*KB) // Reserved for DSP/AESND/etc +#define MRAM_BACKING (4*MB) // Use 4MB to page our 16MB +#define ARAM_RESERVED (16*KB) // Reserved for DSP #define ARAM_VM_BASE (0x7F000000) // Map ARAM to here #define ARAM_START (ARAM_RESERVED + ARAM_VM_BASE) #define ARAM_SIZE ((16*MB) - ARAM_RESERVED) // ARAM is ~16MB diff --git a/source/vmalloc.cpp b/source/vmalloc.cpp index dd10c1fa..d8e016fa 100644 --- a/source/vmalloc.cpp +++ b/source/vmalloc.cpp @@ -10,10 +10,8 @@ #ifdef USE_VM -#include #include #include -#include #include "utils/vm/vm.h" static heap_cntrl vm_heap;