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