final src and Makefile adjustments for PSP release
[picodrive.git] / platform / psp / main.c
CommitLineData
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
110df09c 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)
1820b5a7 28{
110df09c 29 engineState = atoi(romFileName);
30 setbuf(NULL, NULL);
31 getenv(NULL);
32}
33#endif
4b167c12 34
110df09c 35int main()
36{
9caf44b5 37 lprintf("\nPicoDrive v" VERSION " " __DATE__ " " __TIME__ "\n");
1820b5a7 38 psp_init();
7d4906bf 39 emu_ReadConfig(0, 0);
1820b5a7 40 emu_Init();
41 menu_init();
110df09c 42 // moved to emu_Loop(), after CPU clock change..
43 //mp3_init();
1820b5a7 44
45 engineState = PGS_Menu;
46
47 for (;;)
48 {
49 switch (engineState)
50 {
51 case PGS_Menu:
110df09c 52#if !GPROF
1820b5a7 53 menu_loop();
110df09c 54#else
55 strcpy(romFileName, currentConfig.lastRomFile);
56 engineState = PGS_ReloadRom;
57#endif
1820b5a7 58 break;
59
60 case PGS_ReloadRom:
4b167c12 61 if (emu_ReloadRom()) {
1820b5a7 62 engineState = PGS_Running;
4b167c12 63 if (mp3_last_error != 0)
64 engineState = PGS_Menu; // send to menu to display mp3 error
65 } else {
1820b5a7 66 lprintf("PGS_ReloadRom == 0\n");
67 engineState = PGS_Menu;
68 }
1820b5a7 69 break;
70
71 case PGS_RestartRun:
72 engineState = PGS_Running;
73
74 case PGS_Running:
7d4906bf 75 emu_Loop();
110df09c 76#if GPROF
77 goto endloop;
78#endif
1820b5a7 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
110df09c 92 mp3_deinit();
1820b5a7 93 emu_Deinit();
110df09c 94#if GPROF
95 gprof_cleanup();
96#endif
97#if !GCOV
1820b5a7 98 psp_finish();
110df09c 99#endif
1820b5a7 100
101 return 0;
102}
103