frontend: logging updates
[pcsx_rearmed.git] / frontend / main.c
index d46e536..8b35b09 100644 (file)
@@ -48,7 +48,7 @@ extern int iUseInterpolation;
 extern int iXAPitch;
 extern int iVolume;
 
-int ready_to_go;
+int ready_to_go, g_resetting;
 unsigned long gpuDisp;
 char cfgfile_basename[MAXPATHLEN];
 int state_slot;
@@ -146,7 +146,6 @@ void emu_set_default_config(void)
        // try to set sane config on which most games work
        Config.Xa = Config.Cdda = Config.Sio =
        Config.SpuIrq = Config.RCntFix = Config.VSyncWA = 0;
-       Config.CdrReschedule = 0;
        Config.PsxAuto = 1;
 
        pl_rearmed_cbs.gpu_neon.allow_interlace = 2; // auto
@@ -312,12 +311,19 @@ do_state_slot:
        hud_new_msg = 3;
 }
 
+static char basic_lcase(char c)
+{
+       if ('A' <= c && c <= 'Z')
+               return c - 'A' + 'a';
+       return c;
+}
+
 static int cdidcmp(const char *id1, const char *id2)
 {
        while (*id1 != 0 && *id2 != 0) {
                if (*id1 == '_') { id1++; continue; }
                if (*id2 == '_') { id2++; continue; }
-               if (*id1 != *id2)
+               if (basic_lcase(*id1) != basic_lcase(*id2))
                        break;
                id1++;
                id2++;
@@ -448,6 +454,8 @@ int emu_core_preinit(void)
 
 int emu_core_init(void)
 {
+       SysPrintf("Starting PCSX-ReARMed " REV "\n");
+
        CheckSubDir();
        check_memcards();
 
@@ -547,7 +555,8 @@ int main(int argc, char *argv[])
        plat_init();
        menu_init(); // loads config
 
-       emu_core_init();
+       if (emu_core_init() != 0)
+               return 1;
 
        if (psxout)
                Config.PsxOut = 1;
@@ -670,6 +679,7 @@ void SysReset() {
        // so we need to prevent updateLace() call..
        void *real_lace = GPU_updateLace;
        GPU_updateLace = dummy_lace;
+       g_resetting = 1;
 
        // reset can run code, timing must be set
        pl_timing_prepare(Config.PsxType);
@@ -680,6 +690,7 @@ void SysReset() {
        CDR_stop();
 
        GPU_updateLace = real_lace;
+       g_resetting = 0;
 }
 
 void SysClose() {
@@ -753,6 +764,8 @@ int emu_load_state(int slot)
        return LoadState(fname);
 }
 
+#ifndef ANDROID
+
 void SysPrintf(const char *fmt, ...) {
        va_list list;
 
@@ -761,16 +774,31 @@ void SysPrintf(const char *fmt, ...) {
        va_end(list);
 }
 
+#else
+
+#include <android/log.h>
+
+void SysPrintf(const char *fmt, ...) {
+       va_list list;
+
+       va_start(list, fmt);
+       __android_log_vprint(ANDROID_LOG_INFO, "PCSX", fmt, list);
+       va_end(list);
+}
+
+#endif
+
 void SysMessage(const char *fmt, ...) {
-        va_list list;
-        char msg[512];
+       va_list list;
+       char msg[512];
+       int ret;
 
-        va_start(list, fmt);
-        vsnprintf(msg, sizeof(msg), fmt, list);
-        va_end(list);
+       va_start(list, fmt);
+       ret = vsnprintf(msg, sizeof(msg), fmt, list);
+       va_end(list);
 
-        if (msg[strlen(msg) - 1] == '\n')
-                msg[strlen(msg) - 1] = 0;
+       if (ret < sizeof(msg) && msg[ret - 1] == '\n')
+               msg[ret - 1] = 0;
 
        SysPrintf("%s\n", msg);
 }