clarify PicoDrive's license
[picodrive.git] / platform / psp / main.c
... / ...
CommitLineData
1/*
2 * PicoDrive
3 * (C) notaz, 2007,2008
4 *
5 * This work is licensed under the terms of MAME license.
6 * See COPYING file in the top-level directory.
7 */
8
9#include <string.h>
10#include "psp.h"
11#include "emu.h"
12#include "menu.h"
13#include "mp3.h"
14#include "../common/menu.h"
15#include "../common/emu.h"
16#include "../common/config.h"
17#include "../common/lprintf.h"
18
19#ifdef GPROF
20#include <pspprof.h>
21#endif
22
23#ifdef GCOV
24#include <stdio.h>
25#include <stdlib.h>
26
27void dummy(void)
28{
29 engineState = atoi(rom_fname_reload);
30 setbuf(NULL, NULL);
31 getenv(NULL);
32}
33#endif
34
35int pico_main(void)
36{
37 psp_init();
38
39 emu_prepareDefaultConfig();
40 emu_ReadConfig(0, 0);
41 config_readlrom(PicoConfigFile);
42
43 emu_Init();
44 menu_init();
45 // moved to emu_Loop(), after CPU clock change..
46 //mp3_init();
47
48 engineState = PGS_Menu;
49
50 for (;;)
51 {
52 switch (engineState)
53 {
54 case PGS_Menu:
55#ifndef GPROF
56 menu_loop();
57#else
58 strcpy(rom_fname_reload, rom_fname_loaded);
59 engineState = PGS_ReloadRom;
60#endif
61 break;
62
63 case PGS_ReloadRom:
64 if (emu_reload_rom(rom_fname_reload)) {
65 engineState = PGS_Running;
66 if (mp3_last_error != 0)
67 engineState = PGS_Menu; // send to menu to display mp3 error
68 } else {
69 lprintf("PGS_ReloadRom == 0\n");
70 engineState = PGS_Menu;
71 }
72 break;
73
74 case PGS_Suspending:
75 while (engineState == PGS_Suspending)
76 psp_wait_suspend();
77 break;
78
79 case PGS_SuspendWake:
80 psp_unhandled_suspend = 0;
81 psp_resume_suspend();
82 emu_HandleResume();
83 engineState = engineStateSuspend;
84 break;
85
86 case PGS_RestartRun:
87 engineState = PGS_Running;
88
89 case PGS_Running:
90 if (psp_unhandled_suspend) {
91 psp_unhandled_suspend = 0;
92 psp_resume_suspend();
93 emu_HandleResume();
94 break;
95 }
96 pemu_loop();
97#ifdef GPROF
98 goto endloop;
99#endif
100 break;
101
102 case PGS_Quit:
103 goto endloop;
104
105 default:
106 lprintf("engine got into unknown state (%i), exitting\n", engineState);
107 goto endloop;
108 }
109 }
110
111 endloop:
112
113 mp3_deinit();
114 emu_Deinit();
115#ifdef GPROF
116 gprof_cleanup();
117#endif
118#ifndef GCOV
119 psp_finish();
120#endif
121
122 return 0;
123}
124