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