dualcore integration in famc, bram cart C code, psp bugfixes
[libpicofe.git] / psp / main.c
1 #include "psp.h"
2 #include "emu.h"
3 #include "menu.h"
4 #include "mp3.h"
5 #include "../common/menu.h"
6 #include "../common/emu.h"
7 #include "../common/lprintf.h"
8 #include "version.h"
9
10 int main()
11 {
12         int mp3_ret;
13
14         lprintf("\nPicoDrive v" VERSION " " __DATE__ " " __TIME__ "\n");
15         psp_init();
16
17         emu_ReadConfig(0, 0);
18         emu_Init();
19         menu_init();
20         mp3_ret = mp3_init();
21
22         engineState = PGS_Menu;
23
24         for (;;)
25         {
26                 switch (engineState)
27                 {
28                         case PGS_Menu:
29                                 menu_loop();
30                                 break;
31
32                         case PGS_ReloadRom:
33                                 if (emu_ReloadRom()) {
34                                         engineState = PGS_Running;
35                                         if (mp3_last_error != 0)
36                                                 engineState = PGS_Menu; // send to menu to display mp3 error
37                                 } else {
38                                         lprintf("PGS_ReloadRom == 0\n");
39                                         engineState = PGS_Menu;
40                                 }
41                                 break;
42
43                         case PGS_RestartRun:
44                                 engineState = PGS_Running;
45
46                         case PGS_Running:
47                                 emu_Loop();
48                                 break;
49
50                         case PGS_Quit:
51                                 goto endloop;
52
53                         default:
54                                 lprintf("engine got into unknown state (%i), exitting\n", engineState);
55                                 goto endloop;
56                 }
57         }
58
59         endloop:
60
61         if (mp3_ret == 0) mp3_deinit();
62         emu_Deinit();
63         psp_finish();
64
65         return 0;
66 }
67