minor psp fixes
[picodrive.git] / platform / psp / main.c
1 #include <string.h>
2 #include "psp.h"
3 #include "emu.h"
4 #include "menu.h"
5 #include "mp3.h"
6 #include "../common/menu.h"
7 #include "../common/emu.h"
8 #include "../common/lprintf.h"
9 #include "version.h"
10
11 #define GPROF 0
12 #define GCOV 0
13
14 #if GPROF
15 #include <pspprof.h>
16 #endif
17
18 #if GCOV
19 #include <stdio.h>
20 #include <stdlib.h>
21
22 void dummy(void)
23 {
24         engineState = atoi(romFileName);
25         setbuf(NULL, NULL);
26         getenv(NULL);
27 }
28 #endif
29
30 int main()
31 {
32         lprintf("\nPicoDrive v" VERSION " " __DATE__ " " __TIME__ "\n");
33         psp_init();
34         emu_ReadConfig(0, 0);
35         emu_Init();
36         menu_init();
37         // moved to emu_Loop(), after CPU clock change..
38         //mp3_init();
39
40         engineState = PGS_Menu;
41
42         for (;;)
43         {
44                 switch (engineState)
45                 {
46                         case PGS_Menu:
47 #if !GPROF
48                                 menu_loop();
49 #else
50                                 strcpy(romFileName, currentConfig.lastRomFile);
51                                 engineState = PGS_ReloadRom;
52 #endif
53                                 break;
54
55                         case PGS_ReloadRom:
56                                 if (emu_ReloadRom()) {
57                                         engineState = PGS_Running;
58                                         if (mp3_last_error != 0)
59                                                 engineState = PGS_Menu; // send to menu to display mp3 error
60                                 } else {
61                                         lprintf("PGS_ReloadRom == 0\n");
62                                         engineState = PGS_Menu;
63                                 }
64                                 break;
65
66                         case PGS_RestartRun:
67                                 engineState = PGS_Running;
68
69                         case PGS_Running:
70                                 emu_Loop();
71 #if GPROF
72                                 goto endloop;
73 #endif
74                                 break;
75
76                         case PGS_Quit:
77                                 goto endloop;
78
79                         default:
80                                 lprintf("engine got into unknown state (%i), exitting\n", engineState);
81                                 goto endloop;
82                 }
83         }
84
85         endloop:
86
87         mp3_deinit();
88         emu_Deinit();
89 #if GPROF
90         gprof_cleanup();
91 #endif
92 #if !GCOV
93         psp_finish();
94 #endif
95
96         return 0;
97 }
98