main.c 2.1 KB

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