mask off arguments for write hadlers
[gpsp.git] / main.c
diff --git a/main.c b/main.c
index b9606db..340b0be 100644 (file)
--- a/main.c
+++ b/main.c
@@ -43,18 +43,10 @@ u32 global_cycles_per_instruction = 1;
 u32 random_skip = 0;
 u32 fps_debug = 0;
 
-#ifdef GP2X_BUILD
 u32 frameskip_value = 2;
 
-u64 frame_count_initial_timestamp = 0;
 u64 last_frame_interval_timestamp;
 
-void gp2x_init(void);
-void gp2x_quit(void);
-#else
-
-u32 frameskip_value = 4;
-#endif
 u32 skip_next_frame = 0;
 
 u32 frameskip_counter = 0;
@@ -90,7 +82,7 @@ u32 clock_speed = 200;
 #else
 u32 clock_speed = 333;
 #endif
-u8 main_path[512];
+char main_path[512];
 
 void trigger_ext_event();
 
@@ -139,7 +131,7 @@ void trigger_ext_event();
     }                                                                         \
   }                                                                           \
 
-u8 *file_ext[] = { ".gba", ".bin", ".zip", NULL };
+static const char *file_ext[] = { ".gba", ".bin", ".zip", NULL };
 
 #ifdef ARM_ARCH
 void ChangeWorkingDirectory(char *exe)
@@ -186,21 +178,12 @@ void init_main()
 
 int main(int argc, char *argv[])
 {
-  u32 i;
-  u32 vcount = 0;
-  u32 ticks;
-  u32 dispstat;
-  u8 load_filename[512];
-  u8 bios_filename[512];
-
 #ifdef PSP_BUILD
   sceKernelRegisterSubIntrHandler(PSP_VBLANK_INT, 0,
    vblank_interrupt_handler, NULL);
   sceKernelEnableSubIntr(PSP_VBLANK_INT, 0);
 #endif
 
-  extern char *cpu_mode_names[];
-
   init_gamepak_buffer();
 
   // Copy the directory path of the executable into main_path
@@ -211,22 +194,22 @@ int main(int argc, char *argv[])
 #endif
 
   getcwd(main_path, 512);
-  load_config_file();
-
-  gamepak_filename[0] = 0;
 
 #ifdef PSP_BUILD
   delay_us(2500000);
 #endif
 
-#ifdef GP2X_BUILD
-  // Overclocking GP2X and MMU patch goes here
-  gp2x_init();
+#ifndef PC_BUILD
+  gpsp_plat_init();
 #endif
+  load_config_file();
+
+  gamepak_filename[0] = 0;
 
   init_video();
 
 #ifdef GP2X_BUILD
+  char bios_filename[512];
   sprintf(bios_filename, "%s/%s", main_path, "gba_bios.bin");
   if(load_bios(bios_filename) == -1)
 #else
@@ -244,7 +227,11 @@ int main(int argc, char *argv[])
     debug_screen_printl("a860e8c0b6d573d191e4ec7db1b1e4f6                  ");
     debug_screen_printl("                                                  ");
     debug_screen_printl("When you do get it name it gba_bios.bin and put it");
+#ifdef PND_BUILD
+    debug_screen_printl("in <CD card>/pandora/appdata/gpsp/ .              ");
+#else
     debug_screen_printl("in the same directory as gpSP.                    ");
+#endif
     debug_screen_printl("                                                  ");
     debug_screen_printl("Press any button to exit.                         ");
 
@@ -296,8 +283,8 @@ int main(int argc, char *argv[])
   {
     if(load_gamepak(argv[1]) == -1)
     {
-#ifdef PC_BUILD
-      printf("Failed to load gamepak %s, exiting.\n", load_filename);
+#ifndef PSP_BUILD
+      printf("Failed to load gamepak %s, exiting.\n", argv[1]);
 #endif
       exit(-1);
     }
@@ -310,6 +297,7 @@ int main(int argc, char *argv[])
   }
   else
   {
+    char load_filename[512];
     if(load_file(file_ext, load_filename) == -1)
     {
       menu(copy_screen());
@@ -318,7 +306,7 @@ int main(int argc, char *argv[])
     {
       if(load_gamepak(load_filename) == -1)
       {
-#ifdef PC_BUILD
+#ifndef PSP_BUILD
         printf("Failed to load gamepak %s, exiting.\n", load_filename);
 #endif
         exit(-1);
@@ -341,10 +329,6 @@ int main(int argc, char *argv[])
   execute_arm_translate(execute_cycles);
 #else
 
-#ifdef GP2X_BUILD
-  get_ticks_us(&frame_count_initial_timestamp);
-#endif
-
 /*  u8 current_savestate_filename[512];
   get_savestate_filename_noshot(savestate_slot,
    current_savestate_filename);
@@ -401,7 +385,7 @@ void trigger_ext_event()
   static u32 event_number = 0;
   static u64 benchmark_ticks[16];
   u64 new_ticks;
-  u8 current_savestate_filename[512];
+  char current_savestate_filename[512];
 
   return;
 
@@ -614,9 +598,11 @@ u32 update_gba()
           if(fps_debug)
           {
             char print_buffer[32];
-            sprintf(print_buffer, "%d (%d)", fps, frames_drawn);
+            sprintf(print_buffer, "%2d (%2d)", fps, frames_drawn);
             print_string(print_buffer, 0xFFFF, 0x000, 0, 0);
           }
+          if(!synchronize_flag)
+            print_string("-FF-", 0xFFFF, 0x000, 216, 0);
 
           update_screen();
 
@@ -670,10 +656,6 @@ u32 update_gba()
   return execute_cycles;
 }
 
-u64 last_screen_timestamp = 0;
-u32 frame_speed = 15000;
-
-
 #ifdef PSP_BUILD
 
 u32 real_frame_count = 0;
@@ -693,7 +675,6 @@ void synchronize()
 
   if(!synchronize_flag)
   {
-    print_string("--FF--", 0xFFFF, 0x000, 0, 0);
     used_frameskip = 4;
     virtual_frame_count = real_frame_count - 1;
   }
@@ -868,8 +849,8 @@ void quit()
 #else
   SDL_Quit();
 
-#ifdef GP2X_BUILD
-  gp2x_quit();
+#ifndef PC_BUILD
+  gpsp_plat_quit();
 #endif
 
   exit(0);
@@ -886,7 +867,7 @@ void reset_gba()
 
 #ifdef PSP_BUILD
 
-u32 file_length(u8 *filename, s32 dummy)
+u32 file_length(char *filename, s32 dummy)
 {
   SceIoStat stats;
   sceIoGetstat(filename, &stats);
@@ -908,7 +889,7 @@ void get_ticks_us(u64 *tick_return)
 
 #else
 
-u32 file_length(u8 *dummy, FILE *fp)
+u32 file_length(char *dummy, FILE *fp)
 {
   u32 length;
 
@@ -928,7 +909,7 @@ void delay_us(u32 us_count)
 
 void get_ticks_us(u64 *ticks_return)
 {
-  *ticks_return = (SDL_GetTicks() * 1000);
+  *ticks_return = (u64)SDL_GetTicks() * 1000;
 }
 
 #else
@@ -952,9 +933,9 @@ void get_ticks_us(u64 *ticks_return)
 
 #endif
 
-void change_ext(u8 *src, u8 *buffer, u8 *extension)
+void change_ext(const char *src, char *buffer, const char *extension)
 {
-  u8 *dot_position;
+  char *dot_position;
   strcpy(buffer, src);
   dot_position = strrchr(buffer, '.');