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