emu.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #include <string.h>
  2. #include <sys/stat.h>
  3. #include <sys/types.h>
  4. #include "../common/emu.h"
  5. #include "../common/config.h"
  6. #include "../common/menu.h"
  7. #include "Pico/PicoInt.h"
  8. const char * const keyNames[] = {
  9. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  10. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  11. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  12. NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
  13. };
  14. int emu_getMainDir(char *dst, int len)
  15. {
  16. strcpy(dst, "D:\\other\\PicoDrive\\");
  17. return strlen(dst);
  18. }
  19. void emu_Init(void)
  20. {
  21. int ret;
  22. // make dirs for saves, cfgs, etc.
  23. ret = mkdir("D:\\other\\PicoDrive", 0777);
  24. if (ret == 0)
  25. {
  26. mkdir("D:\\other\\PicoDrive\\mds", 0777);
  27. mkdir("D:\\other\\PicoDrive\\srm", 0777);
  28. mkdir("D:\\other\\PicoDrive\\brm", 0777);
  29. }
  30. emu_prepareDefaultConfig();
  31. config_readlrom("D:\\other\\PicoDrive\\config.cfg");
  32. emu_ReadConfig(0, 0);
  33. //PicoInit();
  34. }
  35. void emu_Deinit(void)
  36. {
  37. // saves volume and last ROM
  38. emu_WriteConfig(0);
  39. //PicoExit();
  40. }
  41. void menu_romload_prepare(const char *rom_name)
  42. {
  43. }
  44. void menu_romload_end(void)
  45. {
  46. }
  47. void emu_prepareDefaultConfig(void)
  48. {
  49. memset(&defaultConfig, 0, sizeof(defaultConfig));
  50. defaultConfig.EmuOpt = 0x1d | 0x680; // | confirm_save, cd_leds, 16bit rend
  51. defaultConfig.s_PicoOpt = 0x0f | POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_SVP_DRC|POPT_ACC_SPRITES;
  52. defaultConfig.s_PsndRate = 22050;
  53. defaultConfig.s_PicoRegion = 0; // auto
  54. defaultConfig.s_PicoAutoRgnOrder = 0x184; // US, EU, JP
  55. defaultConfig.s_PicoCDBuffers = 0;
  56. defaultConfig.Frameskip = -1; // auto
  57. defaultConfig.volume = 80;
  58. defaultConfig.scaling = 0;
  59. }
  60. /* used by config engine only, not actual menus */
  61. menu_entry opt_entries[] =
  62. {
  63. { NULL, MB_NONE, MA_OPT_RENDERER, NULL, 0, 0, 0, 1, 1 },
  64. { "Scaling", MB_RANGE, MA_OPT_SCALING, &currentConfig.scaling, 0, 0, 2, 1, 1 },
  65. { "Rotation", MB_RANGE, MA_OPT_ROTATION, &currentConfig.rotation, 0, 0, 3, 1, 1 },
  66. { "Accurate sprites", MB_ONOFF, MA_OPT_ACC_SPRITES, &PicoOpt, 0x080, 0, 0, 0, 1 },
  67. { "Show FPS", MB_ONOFF, MA_OPT_SHOW_FPS, &currentConfig.EmuOpt, 0x002, 0, 0, 1, 1 },
  68. { NULL, MB_RANGE, MA_OPT_FRAMESKIP, &currentConfig.Frameskip, 0, -1, 16, 1, 1 },
  69. { "Enable sound", MB_ONOFF, MA_OPT_ENABLE_SOUND, &currentConfig.EmuOpt, 0x004, 0, 0, 1, 1 },
  70. { NULL, MB_NONE, MA_OPT_SOUND_QUALITY, NULL, 0, 0, 0, 1, 1 },
  71. { NULL, MB_NONE, MA_OPT_REGION, NULL, 0, 0, 0, 1, 1 },
  72. { "Use SRAM/BRAM savestates", MB_ONOFF, MA_OPT_SRAM_STATES, &currentConfig.EmuOpt, 0x001, 0, 0, 1, 1 },
  73. };
  74. #define OPT_ENTRY_COUNT (sizeof(opt_entries) / sizeof(opt_entries[0]))
  75. const int opt_entry_count = OPT_ENTRY_COUNT;
  76. menu_entry opt2_entries[] =
  77. {
  78. { "Disable sprite limit", MB_ONOFF, MA_OPT2_NO_SPRITE_LIM, &PicoOpt, 0x40000, 0, 0, 1, 1 },
  79. { "Emulate Z80", MB_ONOFF, MA_OPT2_ENABLE_Z80, &PicoOpt, 0x00004, 0, 0, 1, 1 },
  80. { "Emulate YM2612 (FM)", MB_ONOFF, MA_OPT2_ENABLE_YM2612, &PicoOpt, 0x00001, 0, 0, 1, 1 },
  81. { "Emulate SN76496 (PSG)", MB_ONOFF, MA_OPT2_ENABLE_SN76496,&PicoOpt, 0x00002, 0, 0, 1, 1 },
  82. { "gzip savestates", MB_ONOFF, MA_OPT2_GZIP_STATES, &currentConfig.EmuOpt, 0x0008, 0, 0, 1, 1 },
  83. { "SVP dynarec", MB_ONOFF, MA_OPT2_SVP_DYNAREC, &PicoOpt, 0x20000, 0, 0, 1, 1 },
  84. { "Disable idle loop patching",MB_ONOFF, MA_OPT2_NO_IDLE_LOOPS, &PicoOpt, 0x80000, 0, 0, 1, 1 },
  85. };
  86. #define OPT2_ENTRY_COUNT (sizeof(opt2_entries) / sizeof(opt2_entries[0]))
  87. const int opt2_entry_count = OPT2_ENTRY_COUNT;
  88. menu_entry cdopt_entries[] =
  89. {
  90. { "CD LEDs", MB_ONOFF, MA_CDOPT_LEDS, &currentConfig.EmuOpt, 0x0400, 0, 0, 1, 1 },
  91. { "CDDA audio (using mp3s)", MB_ONOFF, MA_CDOPT_CDDA, &PicoOpt, 0x0800, 0, 0, 1, 1 },
  92. { "PCM audio", MB_ONOFF, MA_CDOPT_PCM, &PicoOpt, 0x0400, 0, 0, 1, 1 },
  93. { NULL, MB_NONE, MA_CDOPT_READAHEAD, NULL, 0, 0, 0, 1, 1 },
  94. { "SaveRAM cart", MB_ONOFF, MA_CDOPT_SAVERAM, &PicoOpt, 0x8000, 0, 0, 1, 1 },
  95. { "Scale/Rot. fx (slow)", MB_ONOFF, MA_CDOPT_SCALEROT_CHIP,&PicoOpt, 0x1000, 0, 0, 1, 1 },
  96. { "Better sync (slow)", MB_ONOFF, MA_CDOPT_BETTER_SYNC, &PicoOpt, 0x2000, 0, 0, 1, 1 },
  97. };
  98. #define CDOPT_ENTRY_COUNT (sizeof(cdopt_entries) / sizeof(cdopt_entries[0]))
  99. const int cdopt_entry_count = CDOPT_ENTRY_COUNT;
  100. menu_entry ctrlopt_entries[] =
  101. {
  102. { "6 button pad", MB_ONOFF, MA_OPT_6BUTTON_PAD, &PicoOpt, 0x020, 0, 0, 1, 1 },
  103. { "Turbo rate", MB_RANGE, MA_CTRL_TURBO_RATE, &currentConfig.turbo_rate, 0, 1, 30, 1, 1 },
  104. };
  105. #define CTRLOPT_ENTRY_COUNT (sizeof(ctrlopt_entries) / sizeof(ctrlopt_entries[0]))
  106. const int ctrlopt_entry_count = CTRLOPT_ENTRY_COUNT;
  107. me_bind_action emuctrl_actions[] =
  108. {
  109. { "Load State ", 1<<28 },
  110. { "Save State ", 1<<27 },
  111. { "Pause Emu ", 1<<26 },
  112. { "Switch Renderer", 1<<25 },
  113. { "Prev save slot ", 1<<23 },
  114. { "Next save slot ", 1<<22 },
  115. { "Volume down ", 1<<21 },
  116. { "Volume up ", 1<<20 },
  117. { NULL, 0 }
  118. };