Merge pull request #325 from retro-wertz/SysPrintf_to_retro_log
authorhizzlekizzle <hizzlekizzle@users.noreply.github.com>
Fri, 2 Aug 2019 13:38:48 +0000 (08:38 -0500)
committerGitHub <noreply@github.com>
Fri, 2 Aug 2019 13:38:48 +0000 (08:38 -0500)
SysPrintf to retro_log and silence some warnings

12 files changed:
frontend/libretro.c
frontend/libretro_core_options.h
frontend/main.c
include/config.h
libpcsxcore/cdriso.c
libpcsxcore/debug.c
libpcsxcore/misc.c
libpcsxcore/plugins.c
libpcsxcore/r3000a.c
libpcsxcore/socket.c
maemo/main.c
plugins/dfxvideo/soft.c

index e48069a..b8d17ab 100644 (file)
@@ -2286,3 +2286,15 @@ int usleep (unsigned long us)
    sceKernelDelayThread(us);
 }
 #endif
+
+void SysPrintf(const char *fmt, ...) {
+       va_list list;
+       char msg[512];
+
+       va_start(list, fmt);
+       vsprintf(msg, fmt, list);
+       va_end(list);
+
+       if (log_cb)
+               log_cb(RETRO_LOG_INFO, "%s", msg);
+}
index bdc214f..6513e1c 100644 (file)
@@ -663,7 +663,7 @@ struct retro_core_option_definition option_defs_us[] = {
    },
 #endif /* DRC_DISABLE */
 
-   { NULL, NULL, NULL, { NULL, NULL }, NULL },
+   { NULL, NULL, NULL, { {0} }, NULL },
 };
 
 /* RETRO_LANGUAGE_JAPANESE */
@@ -1183,7 +1183,7 @@ struct retro_core_option_definition option_defs_tr[] = {
    },
 #endif /* DRC_DISABLE */
 
-   { NULL, NULL, NULL, { NULL, NULL }, NULL },
+   { NULL, NULL, NULL, { {0} }, NULL },
 };
 
 
index 860dec0..c0bfd0f 100644 (file)
@@ -795,6 +795,7 @@ int emu_load_state(int slot)
        return LoadState(fname);
 }
 
+#ifndef HAVE_LIBRETRO
 #ifndef ANDROID
 
 void SysPrintf(const char *fmt, ...) {
@@ -819,6 +820,7 @@ void SysPrintf(const char *fmt, ...) {
 }
 
 #endif
+#endif /* HAVE_LIBRETRO */
 
 void SysMessage(const char *fmt, ...) {
        va_list list;
index ce2f3ea..362e4a4 100644 (file)
@@ -1,2 +1,2 @@
 #define MAXPATHLEN 256
-#define PACKAGE_VERSION "1.9"
+#define PCSX_VERSION "1.9"
index 975105e..daed921 100644 (file)
@@ -1349,6 +1349,7 @@ static long CALLBACK ISOopen(void) {
        boolean isMode1ISO = FALSE;
        char alt_bin_filename[MAXPATHLEN];
        const char *bin_filename;
+       char image_str[1024] = {0};
 
        if (cdHandle != NULL) {
                return 0; // it's already open
@@ -1361,7 +1362,7 @@ static long CALLBACK ISOopen(void) {
                return -1;
        }
 
-       SysPrintf(_("Loaded CD Image: %s"), GetIsoFile());
+       sprintf(image_str, "Loaded CD Image: %s", GetIsoFile());
 
        cddaBigEndian = FALSE;
        subChanMixed = FALSE;
@@ -1374,40 +1375,40 @@ static long CALLBACK ISOopen(void) {
        cdimg_read_func = cdread_normal;
 
        if (parsetoc(GetIsoFile()) == 0) {
-               SysPrintf("[+toc]");
+               strcat(image_str, "[+toc]");
        }
        else if (parseccd(GetIsoFile()) == 0) {
-               SysPrintf("[+ccd]");
+               strcat(image_str, "[+ccd]");
        }
        else if (parsemds(GetIsoFile()) == 0) {
-               SysPrintf("[+mds]");
+               strcat(image_str, "[+mds]");
        }
        else if (parsecue(GetIsoFile()) == 0) {
-               SysPrintf("[+cue]");
+               strcat(image_str, "[+cue]");
        }
        if (handlepbp(GetIsoFile()) == 0) {
-               SysPrintf("[pbp]");
+               strcat(image_str, "[+pbp]");
                CDR_getBuffer = ISOgetBuffer_compr;
                cdimg_read_func = cdread_compressed;
        }
        else if (handlecbin(GetIsoFile()) == 0) {
-               SysPrintf("[cbin]");
+               strcat(image_str, "[+cbin]");
                CDR_getBuffer = ISOgetBuffer_compr;
                cdimg_read_func = cdread_compressed;
        }
 #ifdef HAVE_CHD
        else if (handlechd(GetIsoFile()) == 0) {
-               SysPrintf("[chd]");
+               strcat(image_str, "[+chd]");
                CDR_getBuffer = ISOgetBuffer_chd;
                cdimg_read_func = cdread_chd;
        }
 #endif
 
        if (!subChanMixed && opensubfile(GetIsoFile()) == 0) {
-               SysPrintf("[+sub]");
+               strcat(image_str, "[+sub]");
        }
        if (opensbifile(GetIsoFile()) == 0) {
-               SysPrintf("[+sbi]");
+               strcat(image_str, "[+sbi]");
        }
 
        fseeko(cdHandle, 0, SEEK_END);
@@ -1445,13 +1446,13 @@ static long CALLBACK ISOopen(void) {
                fseek(cdHandle, 0, SEEK_SET);
                fread(&modeTest, 4, 1, cdHandle);
                if (SWAP32(modeTest) != 0xffffff00) {
-                       SysPrintf("[2048]");
+                       strcat(image_str, "[2048]");
                        isMode1ISO = TRUE;
                }
        }
        fseek(cdHandle, 0, SEEK_SET);
 
-       SysPrintf(".\n");
+       SysPrintf("%s.\n", image_str);
 
        PrintTracks();
 
index 763dc45..4ba7f57 100644 (file)
@@ -445,7 +445,7 @@ static void ProcessCommands() {
             sprintf(reply, "200 %s\r\n", arguments == NULL ? "OK" : arguments);
             break;
         case 0x101:
-            sprintf(reply, "201 %s\r\n", PACKAGE_VERSION);
+            sprintf(reply, "201 %s\r\n", PCSX_VERSION);
             break;
         case 0x102:
             sprintf(reply, "202 1.0\r\n");
index bb34e5b..433d4be 100644 (file)
@@ -557,7 +557,7 @@ struct PcsxSaveFuncs SaveFuncs = {
        zlib_open, zlib_read, zlib_write, zlib_seek, zlib_close
 };
 
-static const char PcsxHeader[32] = "STv4 PCSX v" PACKAGE_VERSION;
+static const char PcsxHeader[32] = "STv4 PCSX v" PCSX_VERSION;
 
 // Savestate Versioning!
 // If you make changes to the savestate version, please increment the value below.
index afe3f3b..4f52ed2 100644 (file)
@@ -1141,11 +1141,11 @@ void ReleasePlugins() {
 
        if (Config.UseNet && hNETDriver != NULL) NET_shutdown(); 
 
-       if (hCDRDriver != NULL) SysCloseLibrary(hCDRDriver); hCDRDriver = NULL;
-       if (hGPUDriver != NULL) SysCloseLibrary(hGPUDriver); hGPUDriver = NULL;
-       if (hSPUDriver != NULL) SysCloseLibrary(hSPUDriver); hSPUDriver = NULL;
-       if (hPAD1Driver != NULL) SysCloseLibrary(hPAD1Driver); hPAD1Driver = NULL;
-       if (hPAD2Driver != NULL) SysCloseLibrary(hPAD2Driver); hPAD2Driver = NULL;
+       if (hCDRDriver != NULL) { SysCloseLibrary(hCDRDriver); hCDRDriver = NULL; }
+       if (hGPUDriver != NULL) { SysCloseLibrary(hGPUDriver); hGPUDriver = NULL; }
+       if (hSPUDriver != NULL) { SysCloseLibrary(hSPUDriver); hSPUDriver = NULL; }
+       if (hPAD1Driver != NULL) { SysCloseLibrary(hPAD1Driver); hPAD1Driver = NULL; }
+       if (hPAD2Driver != NULL) { SysCloseLibrary(hPAD2Driver); hPAD2Driver = NULL; }
 
        if (Config.UseNet && hNETDriver != NULL) {
                SysCloseLibrary(hNETDriver); hNETDriver = NULL;
@@ -1164,7 +1164,7 @@ void ReleasePlugins() {
 int ReloadCdromPlugin()
 {
        if (hCDRDriver != NULL || cdrIsoActive()) CDR_shutdown();
-       if (hCDRDriver != NULL) SysCloseLibrary(hCDRDriver); hCDRDriver = NULL;
+       if (hCDRDriver != NULL) { SysCloseLibrary(hCDRDriver); hCDRDriver = NULL; }
 
        if (UsingIso()) {
                LoadCDRplugin(NULL);
index 22341c5..0433c20 100644 (file)
@@ -30,7 +30,7 @@ R3000Acpu *psxCpu = NULL;
 psxRegisters psxRegs;
 
 int psxInit() {
-       SysPrintf(_("Running PCSX Version %s (%s).\n"), PACKAGE_VERSION, __DATE__);
+       SysPrintf(_("Running PCSX Version %s (%s).\n"), PCSX_VERSION, __DATE__);
 
 #ifdef PSXREC
        if (Config.Cpu == CPU_INTERPRETER) {
index c408bc3..df768e6 100644 (file)
@@ -135,7 +135,7 @@ void GetClient() {
     }
 #endif
 
-    sprintf(hello, "000 PCSX Version %s - Debug console\r\n", PACKAGE_VERSION);
+    sprintf(hello, "000 PCSX Version %s - Debug console\r\n", PCSX_VERSION);
     WriteSocket(hello, strlen(hello));
     ptr = 0;
 }
index c382c51..50e129e 100644 (file)
@@ -54,7 +54,7 @@ static void ChangeWorkingDirectory(char *exe)
 
 void PrintHelp()
 {
-       printf("PCSX-ReARMed version %s for Maemo\n\n", PACKAGE_VERSION);
+       printf("PCSX-ReARMed version %s for Maemo\n\n", PCSX_VERSION);
 
        printf("Usage:\n");
        printf("  pcsx [options] -cdfile FILE\n\n");
index c1c3bef..1b22ed5 100644 (file)
@@ -6316,6 +6316,7 @@ static void DrawSoftwareSpriteMirror(unsigned char * baseAddr,int32_t w,int32_t
     sprtYa=(sprtY<<10);
     clutP=(clutY0<<10)+clutX0;
     for (sprCY=0;sprCY<sprtH;sprCY++)
+    {
      for (sprCX=0;sprCX<sprtW;sprCX++)
       {
        tC= psxVub[((textY0+(sprCY*lYDir))<<11) + textX0 +(sprCX*lXDir)];
@@ -6323,28 +6324,33 @@ static void DrawSoftwareSpriteMirror(unsigned char * baseAddr,int32_t w,int32_t
        GetTextureTransColG_SPR(&psxVuw[sprA],GETLE16(&psxVuw[clutP+((tC>>4)&0xf)]));
        GetTextureTransColG_SPR(&psxVuw[sprA+1],GETLE16(&psxVuw[clutP+(tC&0xf)]));
       }
+    }
     return;
 
    case 1: 
 
     clutP>>=1;
     for(sprCY=0;sprCY<sprtH;sprCY++)
+    {
      for(sprCX=0;sprCX<sprtW;sprCX++)
       { 
        tC = psxVub[((textY0+(sprCY*lYDir))<<11)+(GlobalTextAddrX<<1) + textX0 + (sprCX*lXDir)] & 0xff;
        GetTextureTransColG_SPR(&psxVuw[((sprtY+sprCY)<<10)+sprtX + sprCX],psxVuw[clutP+tC]);
       }
-     return;
+    }
+    return;
 
    case 2:
 
     for (sprCY=0;sprCY<sprtH;sprCY++)
+    {
      for (sprCX=0;sprCX<sprtW;sprCX++)
       { 
        GetTextureTransColG_SPR(&psxVuw[((sprtY+sprCY)<<10)+sprtX+sprCX],
            GETLE16(&psxVuw[((textY0+(sprCY*lYDir))<<10)+GlobalTextAddrX + textX0 +(sprCX*lXDir)]));
       }
-     return;
+    }
+    return;
   }
 }