8b99ab90 |
1 | // (c) Copyright 2007 notaz, All rights reserved. |
2 | // Free for non-commercial use. |
3 | |
4 | // For commercial use, separate licencing terms must be obtained. |
5 | |
110df09c |
6 | #include <string.h> |
1820b5a7 |
7 | #include "psp.h" |
8 | #include "emu.h" |
9 | #include "menu.h" |
4b167c12 |
10 | #include "mp3.h" |
1820b5a7 |
11 | #include "../common/menu.h" |
7d4906bf |
12 | #include "../common/emu.h" |
1820b5a7 |
13 | #include "../common/lprintf.h" |
9caf44b5 |
14 | #include "version.h" |
1820b5a7 |
15 | |
2445b7cb |
16 | #ifdef GPROF |
110df09c |
17 | #include <pspprof.h> |
18 | #endif |
19 | |
2445b7cb |
20 | #ifdef GCOV |
110df09c |
21 | #include <stdio.h> |
22 | #include <stdlib.h> |
23 | |
24 | void dummy(void) |
1820b5a7 |
25 | { |
110df09c |
26 | engineState = atoi(romFileName); |
27 | setbuf(NULL, NULL); |
28 | getenv(NULL); |
29 | } |
30 | #endif |
4b167c12 |
31 | |
2445b7cb |
32 | int pico_main(void) |
110df09c |
33 | { |
9caf44b5 |
34 | lprintf("\nPicoDrive v" VERSION " " __DATE__ " " __TIME__ "\n"); |
1820b5a7 |
35 | psp_init(); |
7d4906bf |
36 | emu_ReadConfig(0, 0); |
1820b5a7 |
37 | emu_Init(); |
38 | menu_init(); |
110df09c |
39 | // moved to emu_Loop(), after CPU clock change.. |
40 | //mp3_init(); |
1820b5a7 |
41 | |
42 | engineState = PGS_Menu; |
43 | |
44 | for (;;) |
45 | { |
46 | switch (engineState) |
47 | { |
48 | case PGS_Menu: |
2445b7cb |
49 | #ifndef GPROF |
1820b5a7 |
50 | menu_loop(); |
110df09c |
51 | #else |
52 | strcpy(romFileName, currentConfig.lastRomFile); |
53 | engineState = PGS_ReloadRom; |
54 | #endif |
1820b5a7 |
55 | break; |
56 | |
57 | case PGS_ReloadRom: |
4b167c12 |
58 | if (emu_ReloadRom()) { |
1820b5a7 |
59 | engineState = PGS_Running; |
4b167c12 |
60 | if (mp3_last_error != 0) |
61 | engineState = PGS_Menu; // send to menu to display mp3 error |
62 | } else { |
1820b5a7 |
63 | lprintf("PGS_ReloadRom == 0\n"); |
64 | engineState = PGS_Menu; |
65 | } |
1820b5a7 |
66 | break; |
67 | |
7d0143a2 |
68 | case PGS_Suspending: |
69 | psp_wait_suspend(); |
70 | break; |
71 | |
1820b5a7 |
72 | case PGS_RestartRun: |
73 | engineState = PGS_Running; |
74 | |
75 | case PGS_Running: |
7d4906bf |
76 | emu_Loop(); |
2445b7cb |
77 | #ifdef GPROF |
110df09c |
78 | goto endloop; |
79 | #endif |
1820b5a7 |
80 | break; |
81 | |
82 | case PGS_Quit: |
83 | goto endloop; |
84 | |
85 | default: |
86 | lprintf("engine got into unknown state (%i), exitting\n", engineState); |
87 | goto endloop; |
88 | } |
89 | } |
90 | |
91 | endloop: |
92 | |
110df09c |
93 | mp3_deinit(); |
1820b5a7 |
94 | emu_Deinit(); |
2445b7cb |
95 | #ifdef GPROF |
110df09c |
96 | gprof_cleanup(); |
97 | #endif |
2445b7cb |
98 | #ifndef GCOV |
1820b5a7 |
99 | psp_finish(); |
110df09c |
100 | #endif |
1820b5a7 |
101 | |
102 | return 0; |
103 | } |
104 | |