From 254477d4d8881a0c41c8fae19f14dd533bbffca4 Mon Sep 17 00:00:00 2001 From: notaz Date: Sat, 27 Dec 2025 03:20:54 +0200 Subject: [PATCH] clean up some includes --- Makefile | 3 +++ frontend/libretro.c | 3 +++ frontend/main.c | 17 ++--------------- libpcsxcore/cdriso.c | 1 + libpcsxcore/cheat.c | 2 ++ libpcsxcore/debug.h | 5 ----- libpcsxcore/misc.c | 6 +++--- libpcsxcore/new_dynarec/emu_if.c | 1 + libpcsxcore/new_dynarec/new_dynarec.c | 3 ++- libpcsxcore/plugins.c | 2 ++ libpcsxcore/ppf.c | 2 ++ libpcsxcore/psxbios.c | 4 +++- libpcsxcore/psxcommon.c | 20 -------------------- libpcsxcore/psxcommon.h | 12 +----------- libpcsxcore/psxmem.c | 1 + libpcsxcore/r3000a.c | 7 ------- libpcsxcore/sio.c | 1 + libpcsxcore/system.h | 6 +++++- plugins/dfsound/externals.h | 5 ++++- 19 files changed, 36 insertions(+), 65 deletions(-) diff --git a/Makefile b/Makefile index 543685c8..179e22e8 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,9 @@ ifneq ($(ASSERTS), 1) CFLAGS += -DNDEBUG endif endif +ifeq ($(LOG_UNHANDLED), 1) +CFLAGS += -DLOG_UNHANDLED +endif ifndef NO_AUTODEPS AUTODEPFLAGS += -MMD -MP endif diff --git a/frontend/libretro.c b/frontend/libretro.c index 19deffe5..e3f60c38 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -8,9 +8,12 @@ #define _GNU_SOURCE 1 // strcasestr #include #include +#include #include #include #include +#include +#include #include #ifdef __MACH__ #include diff --git a/frontend/main.c b/frontend/main.c index 751c4520..b3f7ec20 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -437,14 +437,6 @@ int emu_core_preinit(void) // it may be redefined by -cfg on the command line strcpy(cfgfile_basename, "pcsx.cfg"); -#ifdef IOS - emuLog = fopen("/User/Documents/pcsxr.log", "w"); - if (emuLog == NULL) - emuLog = fopen("pcsxr.log", "w"); - if (emuLog == NULL) -#endif - emuLog = stdout; - log_wrong_cpu(); SetIsoFile(NULL); @@ -878,11 +870,6 @@ void SysClose() { ReleasePlugins(); StopDebugger(); - - if (emuLog != NULL && emuLog != stdout && emuLog != stderr) { - fclose(emuLog); - emuLog = NULL; - } } #ifndef HAVE_LIBRETRO @@ -892,9 +879,9 @@ void SysPrintf(const char *fmt, ...) { va_list list; va_start(list, fmt); - vfprintf(emuLog, fmt, list); + vfprintf(stdout, fmt, list); va_end(list); - fflush(emuLog); + //fflush(stdout); } #else diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c index a917b54d..e63feb49 100644 --- a/libpcsxcore/cdriso.c +++ b/libpcsxcore/cdriso.c @@ -24,6 +24,7 @@ #include "cdriso.h" #include "ppf.h" +#include #include #include #ifdef HAVE_CHD diff --git a/libpcsxcore/cheat.c b/libpcsxcore/cheat.c index 2727fd23..7b81737c 100644 --- a/libpcsxcore/cheat.c +++ b/libpcsxcore/cheat.c @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA */ +#include +#include #include "psxcommon.h" #include "r3000a.h" #include "psxmem.h" diff --git a/libpcsxcore/debug.h b/libpcsxcore/debug.h index 5c5336d4..9fcc41a6 100644 --- a/libpcsxcore/debug.h +++ b/libpcsxcore/debug.h @@ -61,11 +61,6 @@ char* disR3000AF(u32 code, u32 pc); //#define CDRCMD_DEBUG -#if defined (PSXCPU_LOG) || defined(PSXDMA_LOG) || defined(CDR_LOG) || defined(PSXHW_LOG) || \ - defined(PSXBIOS_LOG) || defined(PSXMEM_LOG) || defined(GTE_LOG) || defined(PAD_LOG) -#define EMU_LOG __Log -#endif - #ifdef __cplusplus } #endif diff --git a/libpcsxcore/misc.c b/libpcsxcore/misc.c index 33a4272e..145b964c 100644 --- a/libpcsxcore/misc.c +++ b/libpcsxcore/misc.c @@ -22,6 +22,8 @@ */ #include +#include +#include #include #include #include "misc.h" @@ -584,9 +586,7 @@ int Load(const char *ExePath) { goto fail_io; section_address = SWAPu32(section_address); section_size = SWAPu32(section_size); -#ifdef EMU_LOG - EMU_LOG("Loading %08X bytes from %08X to %08X\n", section_size, ftell(tmpFile), section_address); -#endif + //printf("Loading %08X bytes from %08X to %08X\n", section_size, ftell(tmpFile), section_address); mem = PSXM(section_address); if (mem != INVALID_PTR) { fread_to_ram(mem, section_size, 1, tmpFile); diff --git a/libpcsxcore/new_dynarec/emu_if.c b/libpcsxcore/new_dynarec/emu_if.c index d88e147a..7880e02a 100644 --- a/libpcsxcore/new_dynarec/emu_if.c +++ b/libpcsxcore/new_dynarec/emu_if.c @@ -6,6 +6,7 @@ */ #include +#include #include "emu_if.h" #include "pcsxmem.h" diff --git a/libpcsxcore/new_dynarec/new_dynarec.c b/libpcsxcore/new_dynarec/new_dynarec.c index 19df23a5..1111588c 100644 --- a/libpcsxcore/new_dynarec/new_dynarec.c +++ b/libpcsxcore/new_dynarec/new_dynarec.c @@ -18,6 +18,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include #include #include //include for uint64_t #include @@ -767,7 +768,7 @@ static attr_unused void check_for_block_changes(u_int start, u_int end) if (block->is_dirty) continue; if (memcmp(block->source, block->copy, block->len)) { - printf("bad block %08x-%08x %016llx %016llx @%08x\n", + SysPrintf("bad block %08x-%08x %016llx %016llx @%08x\n", block->start, block->start + block->len, *(long long *)block->source, *(long long *)block->copy, psxRegs.pc); fflush(stdout); diff --git a/libpcsxcore/plugins.c b/libpcsxcore/plugins.c index 3cf1cf61..62c15b5a 100644 --- a/libpcsxcore/plugins.c +++ b/libpcsxcore/plugins.c @@ -21,6 +21,8 @@ * Plugin library callback/access functions. */ +#include +#include #include "plugins.h" #include "cdriso.h" #include "cdrom-async.h" diff --git a/libpcsxcore/ppf.c b/libpcsxcore/ppf.c index 3dcf416e..8e90c67c 100644 --- a/libpcsxcore/ppf.c +++ b/libpcsxcore/ppf.c @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307 USA */ +#include +#include #include "psxcommon.h" #include "ppf.h" #include "misc.h" diff --git a/libpcsxcore/psxbios.c b/libpcsxcore/psxbios.c index fc04e113..7dd9f9ca 100644 --- a/libpcsxcore/psxbios.c +++ b/libpcsxcore/psxbios.c @@ -30,6 +30,9 @@ // TODO: implement all system calls, count the exact CPU cycles of system calls. +#include +#include +#include #include "psxbios.h" #include "psxhw.h" #include "gpu.h" @@ -38,7 +41,6 @@ #include "psxinterpreter.h" #include "psxevents.h" #include "cdrom.h" -#include #include #ifndef PSXBIOS_LOG diff --git a/libpcsxcore/psxcommon.c b/libpcsxcore/psxcommon.c index ada81a88..dae55140 100644 --- a/libpcsxcore/psxcommon.c +++ b/libpcsxcore/psxcommon.c @@ -25,10 +25,6 @@ #include "ppf.h" PcsxConfig Config; -boolean NetOpened = FALSE; - -int Log = 0; -FILE *emuLog = NULL; int EmuInit() { return psxInit(); @@ -60,19 +56,3 @@ void EmuUpdate() { pl_frame_limit(); } } - -void __Log(char *fmt, ...) { - va_list list; -#ifdef LOG_STDOUT - char tmp[1024]; -#endif - - va_start(list, fmt); -#ifndef LOG_STDOUT - vfprintf(emuLog, fmt, list); -#else - vsprintf(tmp, fmt, list); - SysPrintf(tmp); -#endif - va_end(list); -} diff --git a/libpcsxcore/psxcommon.h b/libpcsxcore/psxcommon.h index 22574f80..7b59c225 100644 --- a/libpcsxcore/psxcommon.h +++ b/libpcsxcore/psxcommon.h @@ -43,18 +43,13 @@ extern "C" { #endif // System includes -#include +//#include #include -#include #include #include -#include -#include -#include #ifndef __SWITCH__ #include #endif -#include // Define types typedef int8_t s8; @@ -107,11 +102,6 @@ typedef uint8_t boolean; #endif -extern FILE *emuLog; -extern int Log; - -void __Log(char *fmt, ...); - // lots of timing depends on this and makes or breaks compatibility, // don't change unless you're going to retest hundreds of games #define CYCLE_MULT_DEFAULT 175 diff --git a/libpcsxcore/psxmem.c b/libpcsxcore/psxmem.c index 13301992..9b783cb3 100644 --- a/libpcsxcore/psxmem.c +++ b/libpcsxcore/psxmem.c @@ -23,6 +23,7 @@ // TODO: Implement caches & cycle penalty. +#include #include "psxmem.h" #include "psxmem_map.h" #include "r3000a.h" diff --git a/libpcsxcore/r3000a.c b/libpcsxcore/r3000a.c index cfd1ab09..3298b766 100644 --- a/libpcsxcore/r3000a.c +++ b/libpcsxcore/r3000a.c @@ -53,8 +53,6 @@ int psxInit() { psxCpu = &psxInt; #endif - Log = 0; - if (psxMemInit() == -1) return -1; return psxCpu->Init(); @@ -96,11 +94,6 @@ void psxReset() { } if (Config.HLE || introBypassed) psxBiosSetupBootState(); - -#ifdef EMU_LOG - EMU_LOG("*BIOS END*\n"); -#endif - Log = 0; } void psxShutdown() { diff --git a/libpcsxcore/sio.c b/libpcsxcore/sio.c index c28c0554..5df9caf9 100644 --- a/libpcsxcore/sio.c +++ b/libpcsxcore/sio.c @@ -21,6 +21,7 @@ * SIO functions. */ +#include #include "misc.h" #include "psxcounters.h" #include "psxevents.h" diff --git a/libpcsxcore/system.h b/libpcsxcore/system.h index 4e65911a..54ac184b 100644 --- a/libpcsxcore/system.h +++ b/libpcsxcore/system.h @@ -44,8 +44,12 @@ void SysRunGui(); // Returns to the Gui void SysClose(); // Close mem and plugins // log if the game does something we don't handle (well) -//#define log_unhandled printf +#ifdef LOG_UNHANDLED +#include +#define log_unhandled printf +#else #define log_unhandled(...) +#endif #ifdef __cplusplus } diff --git a/plugins/dfsound/externals.h b/plugins/dfsound/externals.h index cf8b7183..aa0ddde5 100644 --- a/plugins/dfsound/externals.h +++ b/plugins/dfsound/externals.h @@ -24,8 +24,11 @@ // generic defines ///////////////////////////////////////////////////////// -//#define log_unhandled printf +#ifdef LOG_UNHANDLED +#define log_unhandled printf +#else #define log_unhandled(...) +#endif #ifdef __GNUC__ #define noinline __attribute__((noinline)) -- 2.47.3