UIQ3 update, some makefile unification, rm old configs, stuff
authornotaz <notasas@gmail.com>
Thu, 21 Aug 2008 10:45:54 +0000 (10:45 +0000)
committernotaz <notasas@gmail.com>
Thu, 21 Aug 2008 10:45:54 +0000 (10:45 +0000)
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@569 be3aeb3a-fb24-0410-a615-afba39da0efa

66 files changed:
Pico/Draw.c
Pico/Pico.c
Pico/cd/buffering.c
Pico/cd/cue.c
platform/common/common_arm.mak [new file with mode: 0644]
platform/common/config.c
platform/common/emu.c
platform/common/emu.h
platform/common/menu.c
platform/common/menu.h
platform/gizmondo/Makefile
platform/gizmondo/emu.c
platform/gizmondo/main.c
platform/gizmondo/menu.c
platform/gizmondo/port_config.h
platform/gp2x/Makefile
platform/gp2x/emu.c
platform/gp2x/main.c
platform/gp2x/menu.c
platform/gp2x/port_config.h
platform/pandora/emu.c
platform/pandora/main.c
platform/pandora/port_config.h
platform/psp/emu.c
platform/psp/main.c
platform/psp/menu.c
platform/psp/port_config.h
platform/uiq3/App.cpp
platform/uiq3/App.h
platform/uiq3/Dialogs.cpp
platform/uiq3/Dialogs.h
platform/uiq3/Engine.cpp
platform/uiq3/Engine.h
platform/uiq3/Makefile
platform/uiq3/Makefile.old [new file with mode: 0644]
platform/uiq3/_out/Makefile [deleted file]
platform/uiq3/_out/PicoDrive.pkg [deleted file]
platform/uiq3/_out/PicoDrive.zip [deleted file]
platform/uiq3/_out/PicoDrive_gcce.pkg [deleted file]
platform/uiq3/config.txt [moved from platform/uiq3/_out/config.txt with 100% similarity]
platform/uiq3/emu.c [new file with mode: 0644]
platform/uiq3/emu.h [new file with mode: 0644]
platform/uiq3/engine/audio_mediaserver.cpp
platform/uiq3/engine/audio_mediaserver.h
platform/uiq3/engine/blit.s
platform/uiq3/engine/debug.cpp
platform/uiq3/engine/debug.h
platform/uiq3/engine/main.cpp
platform/uiq3/engine/vid.cpp
platform/uiq3/makezip.cmd [deleted file]
platform/uiq3/picodrive.hrh [moved from platform/uiq3/PicoDrive.hrh with 83% similarity]
platform/uiq3/picodrive.pkg [new file with mode: 0644]
platform/uiq3/port_config.h
platform/uiq3/port_config.s
platform/uiq3/qconn.cmd [deleted file]
platform/uiq3/qlog.cmd [deleted file]
platform/uiq3/qup.cmd [deleted file]
platform/uiq3/rsc/PicoDrive_loc.rss [deleted file]
platform/uiq3/rsc/picodrive.rss [moved from platform/uiq3/rsc/PicoDrive.rss with 88% similarity]
platform/uiq3/rsc/picodrive_loc.rss [new file with mode: 0644]
platform/uiq3/rsc/picodrive_reg.rss [moved from platform/uiq3/rsc/PicoDrive_reg.rss with 83% similarity]
platform/uiq3/uiq3.mak [new file with mode: 0644]
platform/uiq3/version.h
unzip/unzip.c
unzip/unzip_stream.c
zlib/zconf.h

index 6d64cd6..7dadb4b 100644 (file)
@@ -1444,7 +1444,7 @@ void PicoDrawSync(int to, int blank_last_line)
   }\r
 \r
 #if !CAN_HANDLE_240_LINES\r
-  if (DrawScanline >= 224) DrawScanline = 240, return;\r
+  if (DrawScanline >= 224) { DrawScanline = 240; return; }\r
 #endif\r
 \r
   // last line\r
index 6bf28b6..296d5d5 100644 (file)
@@ -49,6 +49,7 @@ void PicoExit(void)
 {\r
   if (PicoAHW & PAHW_MCD)\r
     PicoExitMCD();\r
+  PicoCartUnload();\r
   z80_exit();\r
 \r
   if (SRam.data) free(SRam.data); SRam.data=0;\r
index 826184b..e0e888d 100644 (file)
@@ -12,7 +12,7 @@ static int hits, reads;
 
 void PicoCDBufferInit(void)
 {
-       void *tmp;
+       void *tmp = NULL;
 
        prev_lba = 0x80000000;
        hits = reads = 0;
index 84deba7..d02062c 100644 (file)
@@ -9,6 +9,9 @@
 #ifdef _MSC_VER
 #define snprintf _snprintf
 #endif
+#ifdef UIQ3
+#define snprintf(b,s,...) sprintf(b,##__VA_ARGS__)
+#endif
 
 static char *mystrip(char *str)
 {
diff --git a/platform/common/common_arm.mak b/platform/common/common_arm.mak
new file mode 100644 (file)
index 0000000..5308fb3
--- /dev/null
@@ -0,0 +1,66 @@
+.c.o:
+       @echo ">>>" $<
+       $(CC) $(CFLAGS) $(DEFINC) -c $< -o $@
+
+.S.o:
+       @echo ">>>" $<
+       $(CC) $(SFLAGS) $(DEFINC) -c $< -o $@
+
+
+../../tools/textfilter: ../../tools/textfilter.c
+       make -C ../../tools/ textfilter
+
+clean_prof:
+       find ../.. -name '*.gcno' -delete
+       find ../.. -name '*.gcda' -delete
+
+mkdirs:
+       mkdir -p $(DIRS)
+
+# deps
+Pico/carthw/svp/compiler.o : ../../Pico/carthw/svp/ssp16.o ../../Pico/carthw/svp/gen_arm.c
+Pico/Pico.o Pico/cd/Pico.o : ../../Pico/PicoFrameHints.c ../../Pico/PicoInt.h
+Pico/Memory.o Pico/cd/Memory.o : ../../Pico/MemoryCmn.c ../../Pico/PicoInt.h
+
+# individual rules
+Pico/draw_asm.o : ../../Pico/Draw.s
+       @echo ">>>" $@
+       $(AS) $(ASFLAGS) $< -o $@
+Pico/draw2_asm.o : ../../Pico/Draw2.s
+       @echo ">>>" $@
+       $(AS) $(ASFLAGS) $< -o $@
+Pico/memory_asm.o : ../../Pico/Memory.s
+       @echo ">>>" $@
+       $(AS) $(ASFLAGS) $< -o $@
+Pico/sound/ym2612_asm.o : ../../Pico/sound/ym2612.s
+       @echo ">>>" $@
+       $(AS) $(ASFLAGS) $< -o $@
+Pico/sound/mix_asm.o : ../../Pico/sound/mix.s
+       @echo ">>>" $@
+       $(AS) $(ASFLAGS) $< -o $@
+Pico/misc_asm.o : ../../Pico/Misc.s
+       @echo ">>>" $@
+       $(AS) $(ASFLAGS) $< -o $@
+Pico/cd/pico_asm.o : ../../Pico/cd/Pico.s
+       @echo ">>>" $@
+       $(AS) $(ASFLAGS) $< -o $@
+Pico/cd/memory_asm.o : ../../Pico/cd/Memory.s
+       @echo ">>>" $@
+       $(AS) $(ASFLAGS) $< -o $@
+Pico/cd/misc_asm.o : ../../Pico/cd/Misc.s
+       @echo ">>>" $@
+       $(AS) $(ASFLAGS) $< -o $@
+#Pico/carthw/svp/stub_arm.o : ../../Pico/carthw/svp/stub_arm.S
+#      @echo ">>>" $@
+#      $(GCC) $(CFLAGS) $(DEFINC) -c $< -o $@
+
+# build Cyclone
+cpu/Cyclone/proj/Cyclone.s:
+       @echo building Cyclone...
+       @make -C ../../cpu/Cyclone/proj CONFIG_FILE=config_pico.h
+
+# build helix libs
+../common/helix/$(CROSS)helix-mp3.a:
+       make -C ../common/helix clean all
+
+
index eb6cedb..f8fe5d0 100644 (file)
@@ -1,11 +1,14 @@
 /*
  * Human-readable config file management for PicoDrive
- * (c)
+ * (c) notaz, 2008
  */
 
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
+#ifdef UIQ3
+#include <unistd.h>
+#endif
 #include "config.h"
 #include "lprintf.h"
 
@@ -205,6 +208,7 @@ static void custom_write(FILE *f, const menu_entry *me, int no_def)
 }
 
 
+#if PLAT_HAVE_JOY
 static const char *joyKeyNames[32] =
 {
        "UP", "DOWN", "LEFT", "RIGHT", "b1", "b2", "b3", "b4",
@@ -212,31 +216,40 @@ static const char *joyKeyNames[32] =
        "b13", "b14", "b15", "b16", "b17", "b19", "b19", "b20",
        "b21", "b22", "b23", "b24", "b25", "b26", "b27", "b28"
 };
+#endif
 
 static void keys_write(FILE *fn, const char *bind_str, const int binds[32],
-               const int def_binds[32], const char * const names[32], int no_defaults)
+               const int def_binds[32], const char * const names[32], int key_count, int no_defaults)
 {
        int t, i;
-       char act[48];
+       char act[48], name[32];
 
-       for (t = 0; t < 32; t++)
+       for (t = 0; t < key_count; t++)
        {
                act[0] = act[31] = 0;
                if (no_defaults && binds[t] == def_binds[t])
                        continue;
-               if (strcmp(names[t], "???") == 0) continue;
 #ifdef __GP2X__
                if (strcmp(names[t], "SELECT") == 0) continue;
 #endif
+               if (t >= 32 || names[t] == NULL || strcmp(names[t], "???") == 0) {
+                       if ((t >= '0' && t <= '9') || (t >= 'a' && t <= 'z') || (t >= 'A' && t <= 'Z'))
+                               sprintf(name, "%c", t);
+                       else
+                               sprintf(name, "\\x%02x", t);
+               }
+               else
+                       strcpy(name, names[t]);
+
                if (binds[t] == 0 && def_binds[t] != 0) {
-                       fprintf(fn, "%s %s =" NL, bind_str, names[t]); // no binds
+                       fprintf(fn, "%s %s =" NL, bind_str, name); // no binds
                        continue;
                }
 
                for (i = 0; i < sizeof(me_ctrl_actions) / sizeof(me_ctrl_actions[0]); i++) {
                        if (me_ctrl_actions[i].mask & binds[t]) {
                                strncpy(act, me_ctrl_actions[i].name, 31);
-                               fprintf(fn, "%s %s = player%i %s" NL, bind_str, names[t],
+                               fprintf(fn, "%s %s = player%i %s" NL, bind_str, name,
                                        ((binds[t]>>16)&1)+1, mystrip(act));
                        }
                }
@@ -244,7 +257,7 @@ static void keys_write(FILE *fn, const char *bind_str, const int binds[32],
                for (i = 0; emuctrl_actions[i].name != NULL; i++) {
                        if (emuctrl_actions[i].mask & binds[t]) {
                                strncpy(act, emuctrl_actions[i].name, 31);
-                               fprintf(fn, "%s %s = %s" NL, bind_str, names[t], mystrip(act));
+                               fprintf(fn, "%s %s = %s" NL, bind_str, name, mystrip(act));
                        }
                }
        }
@@ -281,8 +294,9 @@ static int default_var(const menu_entry *me)
                case MA_CDOPT_LEDS:
                        return defaultConfig.EmuOpt;
 
-               case MA_CTRL_TURBO_RATE:
-                       return defaultConfig.turbo_rate;
+               case MA_CTRL_TURBO_RATE: return defaultConfig.turbo_rate;
+               case MA_OPT_SCALING:     return defaultConfig.scaling;
+               case MA_OPT_ROTATION:    return defaultConfig.rotation;
 
                case MA_OPT_SAVE_SLOT:
                default:
@@ -384,11 +398,13 @@ write:
        }
 
        // save key config
-       keys_write(fn, "bind", currentConfig.KeyBinds, defaultConfig.KeyBinds, keyNames, no_defaults);
-       keys_write(fn, "bind_joy0", currentConfig.JoyBinds[0], defaultConfig.JoyBinds[0], joyKeyNames, 1);
-       keys_write(fn, "bind_joy1", currentConfig.JoyBinds[1], defaultConfig.JoyBinds[1], joyKeyNames, 1);
-       keys_write(fn, "bind_joy2", currentConfig.JoyBinds[2], defaultConfig.JoyBinds[2], joyKeyNames, 1);
-       keys_write(fn, "bind_joy3", currentConfig.JoyBinds[3], defaultConfig.JoyBinds[3], joyKeyNames, 1);
+       keys_write(fn, "bind", currentConfig.KeyBinds, defaultConfig.KeyBinds, keyNames, PLAT_MAX_KEYS, no_defaults);
+#if PLAT_HAVE_JOY
+       keys_write(fn, "bind_joy0", currentConfig.JoyBinds[0], defaultConfig.JoyBinds[0], joyKeyNames, 32, 1);
+       keys_write(fn, "bind_joy1", currentConfig.JoyBinds[1], defaultConfig.JoyBinds[1], joyKeyNames, 32, 1);
+       keys_write(fn, "bind_joy2", currentConfig.JoyBinds[2], defaultConfig.JoyBinds[2], joyKeyNames, 32, 1);
+       keys_write(fn, "bind_joy3", currentConfig.JoyBinds[3], defaultConfig.JoyBinds[3], joyKeyNames, 32, 1);
+#endif
 
 #ifndef PSP
        if (section == NULL)
@@ -423,7 +439,7 @@ int config_writelrom(const char *fname)
        int size;
        FILE *f;
 
-       if (strlen(lastRomFile) == 0) return -1;
+       if (strlen(loadedRomFName) == 0) return -1;
 
        f = fopen(fname, "r");
        if (f != NULL)
@@ -456,7 +472,7 @@ int config_writelrom(const char *fname)
                fwrite(old_data, 1, optr - old_data, f);
                free(old_data);
        }
-       fprintf(f, "LastUsedROM = %s" NL, lastRomFile);
+       fprintf(f, "LastUsedROM = %s" NL, loadedRomFName);
        fclose(f);
        return 0;
 }
@@ -487,9 +503,9 @@ int config_readlrom(const char *fname)
                tmp++;
                mystrip(tmp);
 
-               len = sizeof(lastRomFile);
-               strncpy(lastRomFile, tmp, len);
-               lastRomFile[len-1] = 0;
+               len = sizeof(loadedRomFName);
+               strncpy(loadedRomFName, tmp, len);
+               loadedRomFName[len-1] = 0;
                ret = 0;
                break;
        }
@@ -686,16 +702,29 @@ static int custom_read(menu_entry *me, const char *var, const char *val)
 
 static unsigned int keys_encountered = 0;
 
-static void keys_parse(const char *var, const char *val, int binds[32], const char * const names[32])
+static void keys_parse(const char *var, const char *val, int binds[32],
+       const char * const names[32], int max_keys)
 {
        int t, i;
        unsigned int player;
 
        for (t = 0; t < 32; t++)
        {
-               if (strcmp(names[t], var) == 0) break;
+               if (names[t] && strcmp(names[t], var) == 0) break;
        }
-       if (t == 32) {
+       if (t == 32)
+       {
+               int len = strlen(var);
+               if (len == 1) t = var[0];
+               else if (len >= 4 && var[0] == '\\' && var[1] == 'x') {
+                       char *p;
+                       t = (int)strtoul(var + 2, &p, 16);
+                       if (*p != 0) t = max_keys; // parse failed
+               }
+               else
+                       t = max_keys; // invalid
+       }
+       if (t < 0 || t >= max_keys) {
                lprintf("unhandled bind \"%s\"\n", var);
                return;
        }
@@ -732,7 +761,7 @@ fail:
 
 #define try_joy_parse(num) { \
        if (strncasecmp(var, "bind_joy"#num " ", 10) == 0) { \
-               keys_parse(var + 10, val, currentConfig.JoyBinds[num], joyKeyNames); \
+               keys_parse(var + 10, val, currentConfig.JoyBinds[num], joyKeyNames, 32); \
                return; \
        } \
 }
@@ -752,13 +781,15 @@ static void parse(const char *var, const char *val)
 
        // key binds
        if (strncasecmp(var, "bind ", 5) == 0) {
-               keys_parse(var + 5, val, currentConfig.KeyBinds, keyNames);
+               keys_parse(var + 5, val, currentConfig.KeyBinds, keyNames, PLAT_MAX_KEYS);
                return;
        }
+#if PLAT_HAVE_JOY
        try_joy_parse(0)
        try_joy_parse(1)
        try_joy_parse(2)
        try_joy_parse(3)
+#endif
 
        for (t = 0; t < sizeof(cfg_opts) / sizeof(cfg_opts[0]) && ret == 0; t++)
        {
index 494484b..7dbac50 100644 (file)
 char *PicoConfigFile = "config.cfg";\r
 currentConfig_t currentConfig, defaultConfig;\r
 int rom_loaded = 0;\r
-char noticeMsg[64];\r
+char noticeMsg[64] = { 0, };\r
 int state_slot = 0;\r
 int config_slot = 0, config_slot_current = 0;\r
-char lastRomFile[512];\r
+char loadedRomFName[512] = { 0, };\r
 int kb_combo_keys = 0, kb_combo_acts = 0;      // keys and actions which need button combos\r
 int pico_inp_mode = 0;\r
 \r
@@ -37,10 +37,8 @@ unsigned char *movie_data = NULL;
 static int movie_size = 0;\r
 \r
 // provided by platform code:\r
-extern char romFileName[];\r
 extern void emu_noticeMsgUpdated(void);\r
-extern void emu_getMainDir(char *dst, int len);\r
-extern void emu_setDefaultConfig(void);\r
+extern int  emu_getMainDir(char *dst, int len);\r
 extern void menu_romload_prepare(const char *rom_name);\r
 extern void menu_romload_end(void);\r
 \r
@@ -51,17 +49,17 @@ static void strlwr_(char* string)
        while ( (*string++ = (char)tolower(*string)) );\r
 }\r
 \r
-static int try_rfn_cut(void)\r
+static int try_rfn_cut(char *fname)\r
 {\r
        FILE *tmp;\r
        char *p;\r
 \r
-       p = romFileName + strlen(romFileName) - 1;\r
-       for (; p > romFileName; p--)\r
+       p = fname + strlen(fname) - 1;\r
+       for (; p > fname; p--)\r
                if (*p == '.') break;\r
        *p = 0;\r
 \r
-       if((tmp = fopen(romFileName, "rb"))) {\r
+       if((tmp = fopen(fname, "rb"))) {\r
                fclose(tmp);\r
                return 1;\r
        }\r
@@ -147,20 +145,20 @@ static int emu_isBios(const char *name)
 \r
 static unsigned char id_header[0x100];\r
 \r
-/* checks if romFileName points to valid MegaCD image\r
+/* checks if fname points to valid MegaCD image\r
  * if so, checks for suitable BIOS */\r
-int emu_cdCheck(int *pregion)\r
+int emu_cdCheck(int *pregion, char *fname_in)\r
 {\r
        unsigned char buf[32];\r
        pm_file *cd_f;\r
        int region = 4; // 1: Japan, 4: US, 8: Europe\r
-       char ext[5], *fname = romFileName;\r
+       char ext[5], *fname = fname_in;\r
        cue_track_type type = CT_UNKNOWN;\r
        cue_data_t *cue_data = NULL;\r
 \r
-       get_ext(romFileName, ext);\r
+       get_ext(fname_in, ext);\r
        if (strcasecmp(ext, ".cue") == 0) {\r
-               cue_data = cue_parse(romFileName);\r
+               cue_data = cue_parse(fname_in);\r
                if (cue_data != NULL) {\r
                        fname = cue_data->tracks[1].fname;\r
                        type  = cue_data->tracks[1].type;\r
@@ -248,7 +246,7 @@ static int extract_text(char *dest, const unsigned char *src, int len, int swab)
 \r
 char *emu_makeRomId(void)\r
 {\r
-       static char id_string[3+0x11+0x11+0x30+16];\r
+       static char id_string[3+0xe*3+0x3*3+0x30*3+3];\r
        int pos, swab = 1;\r
 \r
        if (PicoAHW & PAHW_MCD) {\r
@@ -268,18 +266,36 @@ char *emu_makeRomId(void)
        return id_string;\r
 }\r
 \r
-int emu_ReloadRom(void)\r
+// buffer must be at least 150 byte long\r
+void emu_getGameName(char *str150)\r
+{\r
+       int ret, swab = (PicoAHW & PAHW_MCD) ? 0 : 1;\r
+       char *s, *d;\r
+\r
+       ret = extract_text(str150, id_header + 0x50, 0x30, swab); // overseas name\r
+\r
+       for (s = d = str150 + 1; s < str150+ret; s++)\r
+       {\r
+               if (*s == 0) break;\r
+               if (*s != ' ' || d[-1] != ' ')\r
+                       *d++ = *s;\r
+       }\r
+       *d = 0;\r
+}\r
+\r
+// note: this function might mangle rom_fname\r
+int emu_ReloadRom(char *rom_fname)\r
 {\r
        unsigned int rom_size = 0;\r
-       char *used_rom_name = romFileName;\r
+       char *used_rom_name = rom_fname;\r
        unsigned char *rom_data = NULL;\r
        char ext[5];\r
        pm_file *rom = NULL;\r
        int ret, cd_state, cd_region, cfg_loaded = 0;\r
 \r
-       lprintf("emu_ReloadRom(%s)\n", romFileName);\r
+       lprintf("emu_ReloadRom(%s)\n", rom_fname);\r
 \r
-       get_ext(romFileName, ext);\r
+       get_ext(rom_fname, ext);\r
 \r
        // detect wrong extensions\r
        if (!strcmp(ext, ".srm") || !strcmp(ext, "s.gz") || !strcmp(ext, ".mds")) { // s.gz ~ .mds.gz\r
@@ -298,7 +314,7 @@ int emu_ReloadRom(void)
        {\r
                // check for both gmv and rom\r
                int dummy;\r
-               FILE *movie_file = fopen(romFileName, "rb");\r
+               FILE *movie_file = fopen(rom_fname, "rb");\r
                if(!movie_file) {\r
                        sprintf(menuErrorMsg, "Failed to open movie.");\r
                        return 0;\r
@@ -323,29 +339,29 @@ int emu_ReloadRom(void)
                        sprintf(menuErrorMsg, "Invalid GMV file.");\r
                        return 0;\r
                }\r
-               dummy = try_rfn_cut() || try_rfn_cut();\r
+               dummy = try_rfn_cut(rom_fname) || try_rfn_cut(rom_fname);\r
                if (!dummy) {\r
                        sprintf(menuErrorMsg, "Could't find a ROM for movie.");\r
                        return 0;\r
                }\r
-               get_ext(romFileName, ext);\r
+               get_ext(rom_fname, ext);\r
        }\r
-       else if (!strcmp(ext, ".pat")) {\r
+       else if (!strcmp(ext, ".pat"))\r
+       {\r
                int dummy;\r
-               PicoPatchLoad(romFileName);\r
-               dummy = try_rfn_cut() || try_rfn_cut();\r
+               PicoPatchLoad(rom_fname);\r
+               dummy = try_rfn_cut(rom_fname) || try_rfn_cut(rom_fname);\r
                if (!dummy) {\r
                        sprintf(menuErrorMsg, "Could't find a ROM to patch.");\r
                        return 0;\r
                }\r
-               get_ext(romFileName, ext);\r
+               get_ext(rom_fname, ext);\r
        }\r
 \r
-       if ((PicoAHW & PAHW_MCD) && Pico_mcd != NULL)\r
-               Stop_CD();\r
+       emu_shutdownMCD();\r
 \r
        // check for MegaCD image\r
-       cd_state = emu_cdCheck(&cd_region);\r
+       cd_state = emu_cdCheck(&cd_region, rom_fname);\r
        if (cd_state >= 0 && cd_state != CIT_NOT_CD)\r
        {\r
                PicoAHW |= PAHW_MCD;\r
@@ -422,7 +438,7 @@ int emu_ReloadRom(void)
 \r
        // insert CD if it was detected\r
        if (cd_state != CIT_NOT_CD) {\r
-               ret = Insert_CD(romFileName, cd_state);\r
+               ret = Insert_CD(rom_fname, cd_state);\r
                if (ret != 0) {\r
                        sprintf(menuErrorMsg, "Insert_CD() failed, invalid CD image?");\r
                        lprintf("%s\n", menuErrorMsg);\r
@@ -468,11 +484,11 @@ int emu_ReloadRom(void)
        emu_noticeMsgUpdated();\r
 \r
        // load SRAM for this ROM\r
-       if (currentConfig.EmuOpt & 1)\r
+       if (currentConfig.EmuOpt & EOPT_USE_SRAM)\r
                emu_SaveLoadGame(1, 1);\r
 \r
-       strncpy(lastRomFile, romFileName, sizeof(lastRomFile)-1);\r
-       lastRomFile[sizeof(lastRomFile)-1] = 0;\r
+       strncpy(loadedRomFName, rom_fname, sizeof(loadedRomFName)-1);\r
+       loadedRomFName[sizeof(loadedRomFName)-1] = 0;\r
        rom_loaded = 1;\r
        return 1;\r
 \r
@@ -484,18 +500,30 @@ fail:
 }\r
 \r
 \r
+void emu_shutdownMCD(void)\r
+{\r
+       if ((PicoAHW & PAHW_MCD) && Pico_mcd != NULL)\r
+               Stop_CD();\r
+       PicoAHW &= ~PAHW_MCD;\r
+}\r
+\r
 static void romfname_ext(char *dst, const char *prefix, const char *ext)\r
 {\r
        char *p;\r
        int prefix_len = 0;\r
 \r
        // make save filename\r
-       for (p = romFileName+strlen(romFileName)-1; p >= romFileName && *p != '/'; p--); p++;\r
+       p = loadedRomFName+strlen(loadedRomFName)-1;\r
+       for (; p >= loadedRomFName && *p != PATH_SEP_C; p--); p++;\r
        *dst = 0;\r
        if (prefix) {\r
-               strcpy(dst, prefix);\r
-               prefix_len = strlen(prefix);\r
+               int len = emu_getMainDir(dst, 512);\r
+               strcpy(dst + len, prefix);\r
+               prefix_len = len + strlen(prefix);\r
        }\r
+#ifdef UIQ3\r
+       else p = loadedRomFName; // backward compatibility\r
+#endif\r
        strncpy(dst + prefix_len, p, 511-prefix_len);\r
        dst[511-8] = 0;\r
        if (dst[strlen(dst)-4] == '.') dst[strlen(dst)-4] = 0;\r
@@ -505,7 +533,9 @@ static void romfname_ext(char *dst, const char *prefix, const char *ext)
 \r
 static void make_config_cfg(char *cfg)\r
 {\r
-       strncpy(cfg, PicoConfigFile, 511);\r
+       int len;\r
+       len = emu_getMainDir(cfg, 512);\r
+       strncpy(cfg + len, PicoConfigFile, 512-6-1-len);\r
        if (config_slot != 0)\r
        {\r
                char *p = strrchr(cfg, '.');\r
@@ -515,10 +545,34 @@ static void make_config_cfg(char *cfg)
        cfg[511] = 0;\r
 }\r
 \r
+void emu_packConfig(void)\r
+{\r
+       currentConfig.s_PicoOpt = PicoOpt;\r
+       currentConfig.s_PsndRate = PsndRate;\r
+       currentConfig.s_PicoRegion = PicoRegionOverride;\r
+       currentConfig.s_PicoAutoRgnOrder = PicoAutoRgnOrder;\r
+       currentConfig.s_PicoCDBuffers = PicoCDBuffers;\r
+}\r
+\r
+void emu_unpackConfig(void)\r
+{\r
+       PicoOpt = currentConfig.s_PicoOpt;\r
+       PsndRate = currentConfig.s_PsndRate;\r
+       PicoRegionOverride = currentConfig.s_PicoRegion;\r
+       PicoAutoRgnOrder = currentConfig.s_PicoAutoRgnOrder;\r
+       PicoCDBuffers = currentConfig.s_PicoCDBuffers;\r
+}\r
+\r
+static void emu_setDefaultConfig(void)\r
+{\r
+       memcpy(&currentConfig, &defaultConfig, sizeof(currentConfig));\r
+       emu_unpackConfig();\r
+}\r
+\r
+\r
 int emu_ReadConfig(int game, int no_defaults)\r
 {\r
        char cfg[512];\r
-       FILE *f;\r
        int ret;\r
 \r
        if (!game)\r
@@ -554,37 +608,7 @@ int emu_ReadConfig(int game, int no_defaults)
                        ret = config_readsect("game_def.cfg", sect);\r
                }\r
 \r
-               if (ret != 0)\r
-               {\r
-                       // fall back to old game specific cfg\r
-                       char extbuf[16];\r
-                       if (config_slot != 0)\r
-                               sprintf(extbuf, ".%i.pbcfg", config_slot);\r
-                       else strcpy(extbuf, ".pbcfg");\r
-                       romfname_ext(cfg, "cfg/", extbuf);\r
-                       f = fopen(cfg, "rb");\r
-                       if (!f) {\r
-                               romfname_ext(cfg, NULL, ".pbcfg");\r
-                               f = fopen(cfg, "rb");\r
-                       }\r
-                       if (f) {\r
-                               int bread;\r
-                               fseek(f, 512, SEEK_SET); // skip unused lrom buffer\r
-                               bread = fread(&currentConfig, 1, sizeof(currentConfig), f);\r
-                               lprintf("emu_ReadConfig: %s %s\n", cfg, bread > 0 ? "(ok)" : "(failed)");\r
-                               fclose(f);\r
-                               ret = 0;\r
-                       }\r
-\r
-                       if (ret == 0) {\r
-                               PicoOpt = currentConfig.s_PicoOpt;\r
-                               PsndRate = currentConfig.s_PsndRate;\r
-                               PicoRegionOverride = currentConfig.s_PicoRegion;\r
-                               PicoAutoRgnOrder = currentConfig.s_PicoAutoRgnOrder;\r
-                               // PicoCDBuffers = currentConfig.s_PicoCDBuffers; // ignore in this case\r
-                       }\r
-               }\r
-               else\r
+               if (ret == 0)\r
                {\r
                        lprintf("loaded cfg from sect \"%s\"\n", sect);\r
                }\r
@@ -618,14 +642,7 @@ int emu_WriteConfig(int is_game)
 \r
        if (!is_game)\r
        {\r
-               strncpy(cfg, PicoConfigFile, 511);\r
-               if (config_slot != 0)\r
-               {\r
-                       char *p = strrchr(cfg, '.');\r
-                       if (p == NULL) p = cfg + strlen(cfg);\r
-                       sprintf(p, ".%i.cfg", config_slot);\r
-               }\r
-               cfg[511] = 0;\r
+               make_config_cfg(cfg);\r
                write_lrom = 1;\r
        } else {\r
                if (config_slot != 0)\r
@@ -648,6 +665,7 @@ int emu_WriteConfig(int is_game)
 }\r
 \r
 \r
+#ifndef UIQ3\r
 void emu_textOut8(int x, int y, const char *text)\r
 {\r
        int i,l,len=strlen(text);\r
@@ -694,6 +712,7 @@ void emu_textOut16(int x, int y, const char *text)
                screen += 8;\r
        }\r
 }\r
+#endif\r
 \r
 #ifdef PSP\r
 #define MAX_COMBO_KEY 23\r
@@ -802,7 +821,7 @@ char *emu_GetSaveFName(int load, int is_sram, int slot)
 \r
        if (is_sram)\r
        {\r
-               romfname_ext(saveFname, (PicoAHW&1) ? "brm/" : "srm/", (PicoAHW&1) ? ".brm" : ".srm");\r
+               romfname_ext(saveFname, (PicoAHW&1) ? "brm"PATH_SEP : "srm"PATH_SEP, (PicoAHW&1) ? ".brm" : ".srm");\r
                if (load) {\r
                        if (try_ropen_file(saveFname)) return saveFname;\r
                        // try in current dir..\r
@@ -815,19 +834,21 @@ char *emu_GetSaveFName(int load, int is_sram, int slot)
        {\r
                ext[0] = 0;\r
                if(slot > 0 && slot < 10) sprintf(ext, ".%i", slot);\r
-               strcat(ext, (currentConfig.EmuOpt & 8) ? ".mds.gz" : ".mds");\r
+               strcat(ext, (currentConfig.EmuOpt & EOPT_GZIP_SAVES) ? ".mds.gz" : ".mds");\r
 \r
-               romfname_ext(saveFname, "mds/", ext);\r
+               romfname_ext(saveFname, "mds" PATH_SEP, ext);\r
                if (load) {\r
                        if (try_ropen_file(saveFname)) return saveFname;\r
                        romfname_ext(saveFname, NULL, ext);\r
                        if (try_ropen_file(saveFname)) return saveFname;\r
-                       if (currentConfig.EmuOpt & 8) {\r
+                       // no gzipped states, search for non-gzipped\r
+                       if (currentConfig.EmuOpt & EOPT_GZIP_SAVES)\r
+                       {\r
                                ext[0] = 0;\r
                                if(slot > 0 && slot < 10) sprintf(ext, ".%i", slot);\r
                                strcat(ext, ".mds");\r
 \r
-                               romfname_ext(saveFname, "mds/", ext);\r
+                               romfname_ext(saveFname, "mds"PATH_SEP, ext);\r
                                if (try_ropen_file(saveFname)) return saveFname;\r
                                romfname_ext(saveFname, NULL, ext);\r
                                if (try_ropen_file(saveFname)) return saveFname;\r
index 7c5e89b..555df3a 100644 (file)
@@ -3,7 +3,18 @@
 
 // For commercial use, separate licencing terms must be obtained.
 
-typedef struct {
+#include "port_config.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define EOPT_USE_SRAM     (1<<0)
+#define EOPT_SHOW_FPS     (1<<1)
+#define EOPT_EN_SOUND     (1<<2)
+#define EOPT_GZIP_SAVES   (1<<3)
+
+typedef struct _currentConfig_t {
        // char lastRomFile[512];
        int EmuOpt;             // LSb->MSb: use_sram, show_fps, enable_sound, gzip_saves,
                                        // squidgehack, no_save_cfg_on_exit, <unused>, 16_bit_mode
@@ -13,15 +24,18 @@ typedef struct {
        int s_PicoOpt;          // for old cfg files only
        int s_PsndRate;
        int s_PicoRegion;
+       int s_PicoAutoRgnOrder;
+       int s_PicoCDBuffers;
        int Frameskip;
        int CPUclock;
-       int KeyBinds[32];
+       int KeyBinds[PLAT_MAX_KEYS];
        int volume;
        int gamma;
+#if PLAT_HAVE_JOY
        int JoyBinds[4][32];
-       int s_PicoAutoRgnOrder;
-       int s_PicoCDBuffers;
-       int scaling; // gp2x: 0=center, 1=hscale, 2=hvscale, 3=hsoftscale; psp: bilinear filtering
+#endif
+       int scaling;  // gp2x: 0=center, 1=hscale, 2=hvscale, 3=hsoftscale; psp: bilinear filtering
+       int rotation; // for UIQ
        float scale; // psp: screen scale
        float hscale32, hscale40; // psp: horizontal scale
        int gamma2;  // psp: black level
@@ -35,12 +49,12 @@ extern char noticeMsg[64];
 extern int state_slot;
 extern int config_slot, config_slot_current;
 extern unsigned char *movie_data;
-extern char lastRomFile[512];
+extern char loadedRomFName[512];               // last loaded ROM filename
 extern int kb_combo_keys, kb_combo_acts;       // keys and actions which need button combos
 extern int pico_inp_mode;
 
 
-int   emu_ReloadRom(void);
+int   emu_ReloadRom(char *rom_fname);
 int   emu_SaveLoadGame(int load, int sram);
 int   emu_ReadConfig(int game, int no_defaults);
 int   emu_WriteConfig(int game);
@@ -48,17 +62,26 @@ char *emu_GetSaveFName(int load, int is_sram, int slot);
 int   emu_checkSaveFile(int slot);
 void  emu_setSaveStateCbs(int gz);
 void  emu_updateMovie(void);
-int   emu_cdCheck(int *pregion);
+int   emu_cdCheck(int *pregion, char *fname_in);
 int   emu_findBios(int region, char **bios_file);
 void  emu_textOut8 (int x, int y, const char *text);
 void  emu_textOut16(int x, int y, const char *text);
 char *emu_makeRomId(void);
+void  emu_getGameName(char *str150);
 void  emu_findKeyBindCombos(void);
 void  emu_forcedFrame(int opts);
 void  emu_changeFastForward(int set_on);
 void  emu_RunEventsPico(unsigned int events);
 void  emu_DoTurbo(int *pad, int acts);
+void  emu_packConfig(void);
+void  emu_unpackConfig(void);
+void  emu_shutdownMCD(void);
 
 extern const char * const keyNames[];
 void  emu_prepareDefaultConfig(void);
 void  emu_platformDebugCat(char *str);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
index 0f3fb61..169b892 100644 (file)
@@ -39,6 +39,8 @@ me_bind_action me_ctrl_actions[15] =
 };\r
 \r
 \r
+#ifndef UIQ3\r
+\r
 static unsigned char menu_font_data[10240];\r
 static int menu_text_color = 0xffff; // default to white\r
 static int menu_sel_color = -1; // disabled\r
@@ -331,28 +333,6 @@ int me_process(menu_entry *entries, int count, menu_id id, int is_next)
        }\r
 }\r
 \r
-const char *me_region_name(unsigned int code, int auto_order)\r
-{\r
-       static const char *names[] = { "Auto", "      Japan NTSC", "      Japan PAL", "      USA", "      Europe" };\r
-       static const char *names_short[] = { "", " JP", " JP", " US", " EU" };\r
-       int u, i = 0;\r
-       if (code) {\r
-               code <<= 1;\r
-               while((code >>= 1)) i++;\r
-               if (i > 4) return "unknown";\r
-               return names[i];\r
-       } else {\r
-               static char name[24];\r
-               strcpy(name, "Auto:");\r
-               for (u = 0; u < 3; u++) {\r
-                       i = 0; code = ((auto_order >> u*4) & 0xf) << 1;\r
-                       while((code >>= 1)) i++;\r
-                       strcat(name, names_short[i]);\r
-               }\r
-               return name;\r
-       }\r
-}\r
-\r
 // ------------ debug menu ------------\r
 \r
 #include <sys/stat.h>\r
@@ -472,4 +452,30 @@ void debug_menu_loop(void)
        }\r
 }\r
 \r
+#endif // !UIQ3\r
+\r
+// ------------ util ------------\r
+\r
+const char *me_region_name(unsigned int code, int auto_order)\r
+{\r
+       static const char *names[] = { "Auto", "      Japan NTSC", "      Japan PAL", "      USA", "      Europe" };\r
+       static const char *names_short[] = { "", " JP", " JP", " US", " EU" };\r
+       int u, i = 0;\r
+       if (code) {\r
+               code <<= 1;\r
+               while((code >>= 1)) i++;\r
+               if (i > 4) return "unknown";\r
+               return names[i];\r
+       } else {\r
+               static char name[24];\r
+               strcpy(name, "Auto:");\r
+               for (u = 0; u < 3; u++) {\r
+                       i = 0; code = ((auto_order >> u*4) & 0xf) << 1;\r
+                       while((code >>= 1)) i++;\r
+                       strcat(name, names_short[i]);\r
+               }\r
+               return name;\r
+       }\r
+}\r
+\r
 \r
index 7a4213d..b17f2dd 100644 (file)
@@ -52,6 +52,7 @@ typedef enum
        MA_OPT_SAVECFG_GAME,
        MA_OPT_LOADCFG,
        MA_OPT_INTERLACED,      /* giz */
+       MA_OPT_ROTATION,        /* uiq */
        MA_OPT2_GAMMA,
        MA_OPT2_A_SN_GAMMA,
        MA_OPT2_DBLBUFF,        /* giz */
index e75c71c..0e37e2d 100644 (file)
@@ -28,8 +28,9 @@ ifeq "$(profile)" "2"
 COPT_COMMON += -fprofile-use\r
 endif\r
 CFLAGS = $(COPT_COMMON) -mcpu=arm920t -mtune=arm920t\r
+SFLAGS = $(CFLAGS)\r
 ASFLAGS = -mcpu=arm920t -mfloat-abi=soft\r
-GCC = $(CROSS)gcc\r
+CC = $(CROSS)gcc\r
 STRIP = $(CROSS)strip\r
 AS = $(CROSS)as\r
 LD = $(CROSS)ld\r
@@ -115,7 +116,7 @@ all: mkdirs PicoDrive.exe readme.txt
 \r
 PicoDrive.exe : $(OBJS) ../common/helix/$(CROSS)helix-mp3.a\r
        @echo ">>>" $@\r
-       $(GCC) -o $@ -static $(CFLAGS) $^ -lm -lpng -Lkgsdk/ -lKGSDK -Wl,-Map=PicoDrive.map \\r
+       $(CC) -o $@ -static $(CFLAGS) $^ -lm -lpng -Lkgsdk/ -lKGSDK -Wl,-Map=PicoDrive.map \\r
                2>&1 | grep -v ".idata$$4" # | grep -v "supports interworking, whereas"\r
 ifeq ($(DEBUG),)\r
        $(STRIP) $@\r
@@ -125,66 +126,10 @@ ifeq "$(profile)" "1"
 endif\r
 \r
 \r
-.c.o:\r
-       @echo ">>>" $<\r
-       $(GCC) $(CFLAGS) $(DEFINC) -c $< -o $@\r
-#.s.o:\r
-#      @echo $<\r
-#      $(GCC) $(CFLAGS) $(DEFINC) -c $< -o $@\r
-\r
-mkdirs:\r
-       mkdir -p $(DIRS)\r
-\r
-Pico/carthw/svp/compiler.o : ../../Pico/carthw/svp/ssp16.o ../../Pico/carthw/svp/gen_arm.c\r
-\r
-Pico/draw_asm.o : ../../Pico/Draw.s\r
-       @echo ">>>" $@\r
-       @$(AS) $(ASFLAGS) $< -o $@\r
-Pico/draw2_asm.o : ../../Pico/Draw2.s\r
-       @echo ">>>" $@\r
-       @$(AS) $(ASFLAGS) $< -o $@\r
-Pico/memory_asm.o : ../../Pico/Memory.s\r
-       @echo ">>>" $@\r
-       @$(AS) $(ASFLAGS) $< -o $@\r
-Pico/sound/ym2612_asm.o : ../../Pico/sound/ym2612.s\r
-       @echo ">>>" $@\r
-       @$(AS) $(ASFLAGS) $< -o $@\r
-Pico/sound/mix_asm.o : ../../Pico/sound/mix.s\r
-       @echo ">>>" $@\r
-       @$(AS) $(ASFLAGS) $< -o $@\r
-Pico/misc_asm.o : ../../Pico/Misc.s\r
-       @echo ">>>" $@\r
-       @$(AS) $(ASFLAGS) $< -o $@\r
-Pico/cd/pico_asm.o : ../../Pico/cd/Pico.s\r
-       @echo ">>>" $@\r
-       @$(AS) $(ASFLAGS) $< -o $@\r
-Pico/cd/memory_asm.o : ../../Pico/cd/Memory.s\r
-       @echo ">>>" $@\r
-       @$(AS) $(ASFLAGS) $< -o $@\r
-Pico/cd/misc_asm.o : ../../Pico/cd/Misc.s\r
-       @echo ">>>" $@\r
-       @$(AS) $(ASFLAGS) $< -o $@\r
-Pico/carthw/svp/stub_arm.o : ../../Pico/carthw/svp/stub_arm.S\r
-       @echo ">>>" $@\r
-       $(GCC) $(CFLAGS) $(DEFINC) -c $< -o $@\r
-\r
-# build Cyclone\r
-cpu/Cyclone/proj/Cyclone.s:\r
-       @echo building Cyclone...\r
-       @make -C ../../cpu/Cyclone/proj CONFIG_FILE=config_pico.h\r
-\r
-Pico/Pico.o Pico/cd/Pico.o: ../../Pico/PicoFrameHints.c ../../Pico/PicoInt.h\r
-Pico/Memory.o Pico/cd/Memory.o : ../../Pico/MemoryCmn.c ../../Pico/PicoInt.h\r
-\r
-# build helix libs\r
-../common/helix/$(CROSS)helix-mp3.a:\r
-       make -C ../common/helix clean all\r
-\r
 readme.txt: ../../tools/textfilter ../base_readme.txt\r
        ../../tools/textfilter ../base_readme.txt $@ GIZ\r
 \r
-../../tools/textfilter: ../../tools/textfilter.c\r
-       make -C ../../tools/ textfilter\r
+include ../common/common_arm.mak\r
 \r
 \r
 # cleanup\r
@@ -194,10 +139,6 @@ tidy:
        @$(RM) $(OBJS)\r
 \r
 \r
-clean_prof:\r
-       find ../.. -name '*.gcno' -delete\r
-       find ../.. -name '*.gcda' -delete\r
-\r
 up: PicoDrive.exe\r
        synce-pcp -d 3 PicoDrive.exe ":/SD Card/emus/PicoDrive/PicoDrive.exe"\r
 \r
index cde2e47..ee5a105 100644 (file)
@@ -45,9 +45,11 @@ void emu_noticeMsgUpdated(void)
        noticeMsgTime = GetTickCount();
 }
 
-void emu_getMainDir(char *dst, int len)
+int emu_getMainDir(char *dst, int len)
 {
        if (len > 0) *dst = 0;
+
+       return 0;
 }
 
 static void emu_msg_cb(const char *msg)
@@ -143,16 +145,6 @@ void emu_prepareDefaultConfig(void)
        defaultConfig.turbo_rate = 15;
 }
 
-void emu_setDefaultConfig(void)
-{
-       memcpy(&currentConfig, &defaultConfig, sizeof(currentConfig));
-       PicoOpt = currentConfig.s_PicoOpt;
-       PsndRate = currentConfig.s_PsndRate;
-       PicoRegionOverride = currentConfig.s_PicoRegion;
-       PicoAutoRgnOrder = currentConfig.s_PicoAutoRgnOrder;
-       PicoCDBuffers = currentConfig.s_PicoCDBuffers;
-}
-
 
 static int EmuScanBegin16(unsigned int num)
 {
index 7b2dc91..801fbc8 100644 (file)
@@ -34,7 +34,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdL
                                break;\r
 \r
                        case PGS_ReloadRom:\r
-                               if (emu_ReloadRom())\r
+                               if (emu_ReloadRom(romFileName))\r
                                        engineState = PGS_Running;\r
                                else {\r
                                        lprintf("PGS_ReloadRom == 0\n");\r
index 9643a16..50de347 100644 (file)
@@ -813,7 +813,7 @@ menu_entry cdopt_entries[] =
        { NULL,                        MB_NONE,  MA_CDOPT_TESTBIOS_EUR, NULL, 0, 0, 0, 1, 0 },\r
        { NULL,                        MB_NONE,  MA_CDOPT_TESTBIOS_JAP, NULL, 0, 0, 0, 1, 0 },\r
        { "CD LEDs",                   MB_ONOFF, MA_CDOPT_LEDS,         &currentConfig.EmuOpt,  0x0400, 0, 0, 1, 1 },\r
-       { "CDDA audio (using mp3s)",   MB_ONOFF, MA_CDOPT_CDDA,         &PicoOpt, 0x0800, 0, 0, 1, 1 },\r
+       { "CDDA audio",                MB_ONOFF, MA_CDOPT_CDDA,         &PicoOpt, 0x0800, 0, 0, 1, 1 },\r
        { "PCM audio",                 MB_ONOFF, MA_CDOPT_PCM,          &PicoOpt, 0x0400, 0, 0, 1, 1 },\r
        { NULL,                        MB_NONE,  MA_CDOPT_READAHEAD,    NULL, 0, 0, 0, 1, 1 },\r
        { "SaveRAM cart",              MB_ONOFF, MA_CDOPT_SAVERAM,      &PicoOpt, 0x8000, 0, 0, 1, 1 },\r
@@ -1438,10 +1438,10 @@ static void menu_loop_root(void)
                                {\r
                                        char curr_path[MAX_PATH], *selfname;\r
                                        FILE *tstf;\r
-                                       if ( (tstf = fopen(lastRomFile, "rb")) )\r
+                                       if ( (tstf = fopen(loadedRomFName, "rb")) )\r
                                        {\r
                                                fclose(tstf);\r
-                                               strcpy(curr_path, lastRomFile);\r
+                                               strcpy(curr_path, loadedRomFName);\r
                                        }\r
                                        else\r
                                                getcwd(curr_path, MAX_PATH);\r
@@ -1586,10 +1586,10 @@ int menu_loop_tray(void)
 \r
        menu_gfx_prepare();\r
 \r
-       if ( (tstf = fopen(lastRomFile, "rb")) )\r
+       if ( (tstf = fopen(loadedRomFName, "rb")) )\r
        {\r
                fclose(tstf);\r
-               strcpy(curr_path, lastRomFile);\r
+               strcpy(curr_path, loadedRomFName);\r
        }\r
        else\r
        {\r
@@ -1613,7 +1613,7 @@ int menu_loop_tray(void)
                                        if (selfname) {\r
                                                int ret = -1;\r
                                                cd_img_type cd_type;\r
-                                               cd_type = emu_cdCheck(NULL);\r
+                                               cd_type = emu_cdCheck(NULL, romFileName);\r
                                                if (cd_type != CIT_NOT_CD)\r
                                                        ret = Insert_CD(romFileName, cd_type);\r
                                                if (ret != 0) {\r
index d913855..0079f68 100644 (file)
 //#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__)\r
 #define dprintf(x...)\r
 \r
+// platform\r
+#define PLAT_MAX_KEYS 32\r
+#define PLAT_HAVE_JOY 0\r
+#define PATH_SEP      "/" // because of cegcc\r
+#define PATH_SEP_C    '/'\r
+\r
 #endif //PORT_CONFIG_H\r
index 57bd810..06761a3 100644 (file)
@@ -44,16 +44,17 @@ endif
 ifeq "$(profile)" "2"\r
 COPT_COMMON += -fprofile-use\r
 endif\r
-COPT = $(COPT_COMMON) -mtune=arm920t\r
-ASOPT = -mcpu=arm920t -mfloat-abi=soft\r
-GCC = $(CROSS)gcc\r
+CFLAGS = $(COPT_COMMON) -mcpu=arm920t -mtune=arm920t\r
+SFLAGS = $(CFLAGS)\r
+ASFLAGS = -mcpu=arm920t -mfloat-abi=soft\r
+CC = $(CROSS)gcc\r
 STRIP = $(CROSS)strip\r
 AS = $(CROSS)as\r
 LD = $(CROSS)ld\r
 OBJCOPY = $(CROSS)objcopy\r
 \r
 # frontend\r
-OBJS += main.o menu.o gp2x.o usbjoy.o emu.o squidgehack.o cpuctrl.o\r
+OBJS += main.o menu.o gp2x.o usbjoy.o emu.o squidgehack.o cpuctrl.o asm_utils.o\r
 # 940 core control\r
 OBJS += 940ctl.o\r
 \r
@@ -149,7 +150,7 @@ all: mkdirs PicoDrive.gpe
 \r
 PicoDrive.gpe : $(OBJS) ../common/helix/$(CROSS)helix-mp3.a\r
        @echo ">>>" $@\r
-       $(GCC) -o $@ $(COPT) $^ -lm -lpng -Wl,-Map=PicoDrive.map\r
+       $(CC) -o $@ $(CFLAGS) $^ -lm -lpng -Wl,-Map=PicoDrive.map\r
 ifeq ($(DEBUG),)\r
        $(STRIP) $@\r
 endif\r
@@ -168,75 +169,10 @@ tidy:
 #      @make -C ../../cpu/Cyclone/proj -f Makefile.linux clean\r
 \r
 \r
-clean_prof:\r
-       find ../.. -name '*.gcno' -delete\r
-       find ../.. -name '*.gcda' -delete\r
-\r
-\r
-mkdirs:\r
-       mkdir -p $(DIRS)\r
-\r
-.c.o:\r
-       @echo ">>>" $<\r
-       $(GCC) $(COPT) $(DEFINC) -c $< -o $@\r
-.s.o:\r
-       @echo ">>>" $<\r
-       $(GCC) $(COPT) $(DEFINC) -c $< -o $@\r
-.S.o:\r
-       @echo ">>>" $<\r
-       $(GCC) $(COPT) $(DEFINC) -c $< -o $@\r
-\r
-Pico/carthw/svp/compiler.o : ../../Pico/carthw/svp/ssp16.o ../../Pico/carthw/svp/gen_arm.c\r
-\r
-Pico/draw_asm.o : ../../Pico/Draw.s\r
-       @echo ">>>" $<\r
-       $(AS) $(ASOPT) $< -o $@\r
-Pico/draw2_asm.o : ../../Pico/Draw2.s\r
-       @echo ">>>" $<\r
-       $(AS) $(ASOPT) $< -o $@\r
-Pico/memory_asm.o : ../../Pico/Memory.s\r
-       @echo ">>>" $<\r
-       $(AS) $(ASOPT) $< -o $@\r
-Pico/sound/ym2612_asm.o : ../../Pico/sound/ym2612.s\r
-       @echo ">>>" $<\r
-       $(AS) $(ASOPT) $< -o $@\r
-Pico/sound/mix_asm.o : ../../Pico/sound/mix.s\r
-       @echo ">>>" $<\r
-       $(AS) $(ASOPT) $< -o $@\r
-Pico/misc_asm.o : ../../Pico/Misc.s\r
-       @echo ">>>" $<\r
-       $(AS) $(ASOPT) $< -o $@\r
-Pico/cd/pico_asm.o : ../../Pico/cd/Pico.s\r
-       @echo ">>>" $<\r
-       $(AS) $(ASOPT) $< -o $@\r
-Pico/cd/memory_asm.o : ../../Pico/cd/Memory.s\r
-       @echo ">>>" $<\r
-       $(AS) $(ASOPT) $< -o $@\r
-Pico/cd/misc_asm.o : ../../Pico/cd/Misc.s\r
-       @echo ">>>" $<\r
-       $(AS) $(ASOPT) $< -o $@\r
-\r
-# build Cyclone\r
-../../cpu/Cyclone/proj/Cyclone.s :\r
-       @echo building Cyclone...\r
-       @make -C ../../cpu/Cyclone/proj CONFIG_FILE=config_pico.h\r
-\r
-../../cpu/musashi/m68kops.c :\r
-       @make -C ../../cpu/musashi\r
-\r
-Pico/Pico.o Pico/cd/Pico.o: ../../Pico/PicoFrameHints.c ../../Pico/PicoInt.h\r
-Pico/Memory.o Pico/cd/Memory.o : ../../Pico/MemoryCmn.c ../../Pico/PicoInt.h\r
-\r
-# build helix libs\r
-../common/helix/$(CROSS)helix-mp3.a:\r
-       make -C ../common/helix clean all\r
-\r
 readme.txt: ../../tools/textfilter ../base_readme.txt\r
        ../../tools/textfilter ../base_readme.txt $@ GP2X\r
 \r
-../../tools/textfilter: ../../tools/textfilter.c\r
-       make -C ../../tools/ textfilter\r
-\r
+include ../common/common_arm.mak\r
 \r
 # ----------- release -----------\r
 ifneq ($(findstring rel,$(MAKECMDGOALS)),)\r
index 12d70e3..c225f18 100644 (file)
@@ -49,7 +49,6 @@ static short __attribute__((aligned(4))) sndBuffer[2*44100/50];
 static struct timeval noticeMsgTime = { 0, 0 };        // when started showing\r
 static int osd_fps_x;\r
 static int gp2x_old_gamma = 100;\r
-char noticeMsg[64];                    // notice msg to draw\r
 unsigned char *PicoDraw2FB = NULL;  // temporary buffer for alt renderer\r
 int reset_timing = 0;\r
 \r
@@ -66,7 +65,7 @@ void emu_noticeMsgUpdated(void)
        gettimeofday(&noticeMsgTime, 0);\r
 }\r
 \r
-void emu_getMainDir(char *dst, int len)\r
+int emu_getMainDir(char *dst, int len)\r
 {\r
        extern char **g_argv;\r
        int j;\r
@@ -77,6 +76,8 @@ void emu_getMainDir(char *dst, int len)
        dst[len] = 0;\r
        for (j = strlen(dst); j > 0; j--)\r
                if (dst[j] == '/') { dst[j+1] = 0; break; }\r
+\r
+       return j + 1;\r
 }\r
 \r
 void emu_Init(void)\r
@@ -167,16 +168,6 @@ void emu_prepareDefaultConfig(void)
        defaultConfig.turbo_rate = 15;\r
 }\r
 \r
-void emu_setDefaultConfig(void)\r
-{\r
-       memcpy(&currentConfig, &defaultConfig, sizeof(currentConfig));\r
-       PicoOpt = currentConfig.s_PicoOpt;\r
-       PsndRate = currentConfig.s_PsndRate;\r
-       PicoRegionOverride = currentConfig.s_PicoRegion;\r
-       PicoAutoRgnOrder = currentConfig.s_PicoAutoRgnOrder;\r
-       PicoCDBuffers = currentConfig.s_PicoCDBuffers;\r
-}\r
-\r
 void osd_text(int x, int y, const char *text)\r
 {\r
        int len = strlen(text)*8;\r
index 50210f6..bdf90d5 100644 (file)
@@ -118,7 +118,7 @@ int main(int argc, char *argv[])
 \r
        if (engineState == PGS_ReloadRom)\r
        {\r
-               if (emu_ReloadRom()) {\r
+               if (emu_ReloadRom(romFileName)) {\r
                        engineState = PGS_Running;\r
                        if (load_state_slot >= 0) {\r
                                state_slot = load_state_slot;\r
@@ -136,7 +136,7 @@ int main(int argc, char *argv[])
                                break;\r
 \r
                        case PGS_ReloadRom:\r
-                               if (emu_ReloadRom())\r
+                               if (emu_ReloadRom(romFileName))\r
                                        engineState = PGS_Running;\r
                                else {\r
                                        printf("PGS_ReloadRom == 0\n");\r
index 1dc829a..b7bd3f1 100644 (file)
@@ -901,7 +901,7 @@ menu_entry cdopt_entries[] =
        { NULL,                        MB_NONE,  MA_CDOPT_TESTBIOS_EUR, NULL, 0, 0, 0, 1, 0 },\r
        { NULL,                        MB_NONE,  MA_CDOPT_TESTBIOS_JAP, NULL, 0, 0, 0, 1, 0 },\r
        { "CD LEDs",                   MB_ONOFF, MA_CDOPT_LEDS,         &currentConfig.EmuOpt, 0x0400, 0, 0, 1, 1 },\r
-       { "CDDA audio (using mp3s)",   MB_ONOFF, MA_CDOPT_CDDA,         &PicoOpt, 0x0800, 0, 0, 1, 1 },\r
+       { "CDDA audio",                MB_ONOFF, MA_CDOPT_CDDA,         &PicoOpt, 0x0800, 0, 0, 1, 1 },\r
        { "PCM audio",                 MB_ONOFF, MA_CDOPT_PCM,          &PicoOpt, 0x0400, 0, 0, 1, 1 },\r
        { NULL,                        MB_NONE,  MA_CDOPT_READAHEAD,    NULL, 0, 0, 0, 1, 1 },\r
        { "SaveRAM cart",              MB_ONOFF, MA_CDOPT_SAVERAM,      &PicoOpt, 0x8000, 0, 0, 1, 1 },\r
@@ -1551,10 +1551,10 @@ static void menu_loop_root(void)
                                {\r
                                        char curr_path[PATH_MAX], *selfname;\r
                                        FILE *tstf;\r
-                                       if ( (tstf = fopen(lastRomFile, "rb")) )\r
+                                       if ( (tstf = fopen(loadedRomFName, "rb")) )\r
                                        {\r
                                                fclose(tstf);\r
-                                               strcpy(curr_path, lastRomFile);\r
+                                               strcpy(curr_path, loadedRomFName);\r
                                        }\r
                                        else\r
                                                getcwd(curr_path, PATH_MAX);\r
@@ -1694,10 +1694,10 @@ int menu_loop_tray(void)
        gp2x_memset_all_buffers(0, 0, 320*240*2);\r
        menu_gfx_prepare();\r
 \r
-       if ( (tstf = fopen(lastRomFile, "rb")) )\r
+       if ( (tstf = fopen(loadedRomFName, "rb")) )\r
        {\r
                fclose(tstf);\r
-               strcpy(curr_path, lastRomFile);\r
+               strcpy(curr_path, loadedRomFName);\r
        }\r
        else\r
        {\r
@@ -1721,7 +1721,7 @@ int menu_loop_tray(void)
                                        if (selfname) {\r
                                                int ret = -1;\r
                                                cd_img_type cd_type;\r
-                                               cd_type = emu_cdCheck(NULL);\r
+                                               cd_type = emu_cdCheck(NULL, romFileName);\r
                                                if (cd_type != CIT_NOT_CD)\r
                                                        ret = Insert_CD(romFileName, cd_type);\r
                                                if (ret != 0) {\r
index 22b43cd..9dc2c6a 100644 (file)
 //#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__)\r
 #define dprintf(x...)\r
 \r
+// platform\r
+#define PLAT_MAX_KEYS 32\r
+#define PLAT_HAVE_JOY 1\r
+#define PATH_SEP      "/"\r
+#define PATH_SEP_C    '/'\r
+\r
 #endif //PORT_CONFIG_H\r
index 633d027..2d873df 100644 (file)
@@ -48,7 +48,6 @@ char romFileName[PATH_MAX];
 static short __attribute__((aligned(4))) sndBuffer[2*44100/50];\r
 static struct timeval noticeMsgTime = { 0, 0 };        // when started showing\r
 static int osd_fps_x;\r
-char noticeMsg[64];                    // notice msg to draw\r
 unsigned char *PicoDraw2FB = NULL;  // temporary buffer for alt renderer\r
 int reset_timing = 0;\r
 \r
@@ -65,7 +64,7 @@ void emu_noticeMsgUpdated(void)
        gettimeofday(&noticeMsgTime, 0);\r
 }\r
 \r
-void emu_getMainDir(char *dst, int len)\r
+int emu_getMainDir(char *dst, int len)\r
 {\r
        extern char **g_argv;\r
        int j;\r
@@ -76,6 +75,8 @@ void emu_getMainDir(char *dst, int len)
        dst[len] = 0;\r
        for (j = strlen(dst); j > 0; j--)\r
                if (dst[j] == '/') { dst[j+1] = 0; break; }\r
+\r
+       return j + 1;\r
 }\r
 \r
 void emu_Init(void)\r
@@ -151,16 +152,6 @@ void emu_prepareDefaultConfig(void)
        defaultConfig.turbo_rate = 15;\r
 }\r
 \r
-void emu_setDefaultConfig(void)\r
-{\r
-       memcpy(&currentConfig, &defaultConfig, sizeof(currentConfig));\r
-       PicoOpt = currentConfig.s_PicoOpt;\r
-       PsndRate = currentConfig.s_PsndRate;\r
-       PicoRegionOverride = currentConfig.s_PicoRegion;\r
-       PicoAutoRgnOrder = currentConfig.s_PicoAutoRgnOrder;\r
-       PicoCDBuffers = currentConfig.s_PicoCDBuffers;\r
-}\r
-\r
 static void textOut16(int x, int y, const char *text)\r
 {\r
        int i,l,len=strlen(text);\r
index 010bff9..5fecb4a 100644 (file)
@@ -92,7 +92,7 @@ int main(int argc, char *argv[])
 \r
        if (engineState == PGS_ReloadRom)\r
        {\r
-               if (emu_ReloadRom()) {\r
+               if (emu_ReloadRom(romFileName)) {\r
                        engineState = PGS_Running;\r
                        if (load_state_slot >= 0) {\r
                                state_slot = load_state_slot;\r
@@ -110,7 +110,7 @@ int main(int argc, char *argv[])
                                break;\r
 \r
                        case PGS_ReloadRom:\r
-                               if (emu_ReloadRom())\r
+                               if (emu_ReloadRom(romFileName))\r
                                        engineState = PGS_Running;\r
                                else {\r
                                        printf("PGS_ReloadRom == 0\n");\r
index 22b43cd..9dc2c6a 100644 (file)
 //#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__)\r
 #define dprintf(x...)\r
 \r
+// platform\r
+#define PLAT_MAX_KEYS 32\r
+#define PLAT_HAVE_JOY 1\r
+#define PATH_SEP      "/"\r
+#define PATH_SEP_C    '/'\r
+\r
 #endif //PORT_CONFIG_H\r
index b050419..d3e6317 100644 (file)
@@ -54,9 +54,10 @@ void emu_noticeMsgUpdated(void)
        noticeMsgTime = sceKernelGetSystemTimeLow();
 }
 
-void emu_getMainDir(char *dst, int len)
+int emu_getMainDir(char *dst, int len)
 {
        if (len > 0) *dst = 0;
+       return 0;
 }
 
 static void osd_text(int x, const char *text, int is_active, int clear_all)
@@ -155,16 +156,6 @@ void emu_prepareDefaultConfig(void)
        defaultConfig.turbo_rate = 15;
 }
 
-void emu_setDefaultConfig(void)
-{
-       memcpy(&currentConfig, &defaultConfig, sizeof(currentConfig));
-       PicoOpt = currentConfig.s_PicoOpt;
-       PsndRate = currentConfig.s_PsndRate;
-       PicoRegionOverride = currentConfig.s_PicoRegion;
-       PicoAutoRgnOrder = currentConfig.s_PicoAutoRgnOrder;
-       PicoCDBuffers = currentConfig.s_PicoCDBuffers;
-}
-
 
 extern void amips_clut(unsigned short *dst, unsigned char *src, unsigned short *pal, int count);
 extern void amips_clut_6bit(unsigned short *dst, unsigned char *src, unsigned short *pal, int count);
index a2e99aa..e0698d5 100644 (file)
@@ -52,13 +52,13 @@ int pico_main(void)
 #ifndef GPROF
                                menu_loop();
 #else
-                               strcpy(romFileName, lastRomFile);
+                               strcpy(romFileName, loadedRomFName);
                                engineState = PGS_ReloadRom;
 #endif
                                break;
 
                        case PGS_ReloadRom:
-                               if (emu_ReloadRom()) {
+                               if (emu_ReloadRom(romFileName)) {
                                        engineState = PGS_Running;
                                        if (mp3_last_error != 0)
                                                engineState = PGS_Menu; // send to menu to display mp3 error
index d348a57..0e578b1 100644 (file)
@@ -825,7 +825,7 @@ menu_entry cdopt_entries[] =
        { NULL,                        MB_NONE,  MA_CDOPT_TESTBIOS_EUR, NULL, 0, 0, 0, 1, 0 },
        { NULL,                        MB_NONE,  MA_CDOPT_TESTBIOS_JAP, NULL, 0, 0, 0, 1, 0 },
        { "CD LEDs",                   MB_ONOFF, MA_CDOPT_LEDS,         &currentConfig.EmuOpt,  0x0400, 0, 0, 1, 1 },
-       { "CDDA audio (using mp3s)",   MB_ONOFF, MA_CDOPT_CDDA,         &PicoOpt, 0x0800, 0, 0, 1, 1 },
+       { "CDDA audio",                MB_ONOFF, MA_CDOPT_CDDA,         &PicoOpt, 0x0800, 0, 0, 1, 1 },
        { "PCM audio",                 MB_ONOFF, MA_CDOPT_PCM,          &PicoOpt, 0x0400, 0, 0, 1, 1 },
        { NULL,                        MB_NONE,  MA_CDOPT_READAHEAD,    NULL, 0, 0, 0, 1, 1 },
        { "SaveRAM cart",              MB_ONOFF, MA_CDOPT_SAVERAM,      &PicoOpt, 0x8000, 0, 0, 1, 1 },
@@ -1632,10 +1632,10 @@ static void menu_loop_root(void)
                                {
                                        char curr_path[PATH_MAX], *selfname;
                                        FILE *tstf;
-                                       if ( (tstf = fopen(lastRomFile, "rb")) )
+                                       if ( (tstf = fopen(loadedRomFName, "rb")) )
                                        {
                                                fclose(tstf);
-                                               strcpy(curr_path, lastRomFile);
+                                               strcpy(curr_path, loadedRomFName);
                                        }
                                        else
                                                getcwd(curr_path, PATH_MAX);
@@ -1777,10 +1777,10 @@ int menu_loop_tray(void)
 
        menu_gfx_prepare();
 
-       if ( (tstf = fopen(lastRomFile, "rb")) )
+       if ( (tstf = fopen(loadedRomFName, "rb")) )
        {
                fclose(tstf);
-               strcpy(curr_path, lastRomFile);
+               strcpy(curr_path, loadedRomFName);
        }
        else
        {
@@ -1804,7 +1804,7 @@ int menu_loop_tray(void)
                                        if (selfname) {
                                                int ret = -1;
                                                cd_img_type cd_type;
-                                               cd_type = emu_cdCheck(NULL);
+                                               cd_type = emu_cdCheck(NULL, romFileName);
                                                if (cd_type != CIT_NOT_CD)
                                                        ret = Insert_CD(romFileName, cd_type);
                                                if (ret != 0) {
index 56513c0..4659b62 100644 (file)
@@ -28,4 +28,10 @@ extern void blit1(void);
 //#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__)\r
 #define dprintf(x...)\r
 \r
+// platform\r
+#define PLAT_MAX_KEYS 32\r
+#define PLAT_HAVE_JOY 0\r
+#define PATH_SEP      "/"\r
+#define PATH_SEP_C    '/'\r
+\r
 #endif //PORT_CONFIG_H\r
index 74e7d24..68a802c 100644 (file)
@@ -12,9 +12,9 @@
  *\r
  *******************************************************************/\r
 \r
-#include "app.h"\r
+#include "App.h"\r
 // #include "picodriven.mbg" // bitmap identifiers\r
-#include <PicoDrive.RSG> // resource include\r
+#include "rsc/picodrive.rsg" // resource include\r
 #include <eikenv.h>\r
 #include <qbtselectdlg.h>\r
 //#include <gulutil.h>\r
 #include <eikedwin.h>\r
 #include <s32strm.h>\r
 \r
-#include <QikAppUi.h>\r
-#include <QikEditCategoryObserver.h>\r
-#include <QikSelectFileDlg.h>\r
-#include <QikCommand.h>\r
+#include <qikappui.h>\r
+#include <qikeditcategoryobserver.h>\r
+#include <qikselectfiledlg.h>\r
+#include <qikcommand.h>\r
 \r
 #include "Dialogs.h"\r
 #include "engine/debug.h"\r
-\r
+#include "../common/emu.h"\r
+#include "emu.h"\r
 \r
 \r
 ////////////////////////////////////////////////////////////////\r
@@ -161,37 +162,37 @@ void CPicolAppView::HandleCommandL(CQikCommand& aCommand)
                        break;\r
 \r
                case EEikCmdPicoFrameskipAuto:\r
-                       iCurrentConfig.iFrameskip = TPicoConfig::PFSkipAuto;\r
-                       iQikAppUi.Document()->SaveL();\r
+                       currentConfig.Frameskip = -1;\r
+                       emu_WriteConfig(0);\r
                        break;\r
 \r
                case EEikCmdPicoFrameskip0:\r
-                       iCurrentConfig.iFrameskip = 0;\r
-                       iQikAppUi.Document()->SaveL();\r
+                       currentConfig.Frameskip = 0;\r
+                       emu_WriteConfig(0);\r
                        break;\r
 \r
                case EEikCmdPicoFrameskip1:\r
-                       iCurrentConfig.iFrameskip = 1;\r
-                       iQikAppUi.Document()->SaveL();\r
+                       currentConfig.Frameskip = 1;\r
+                       emu_WriteConfig(0);\r
                        break;\r
 \r
                case EEikCmdPicoFrameskip2:\r
-                       iCurrentConfig.iFrameskip = 2;\r
-                       iQikAppUi.Document()->SaveL();\r
+                       currentConfig.Frameskip = 2;\r
+                       emu_WriteConfig(0);\r
                        break;\r
 \r
                case EEikCmdPicoFrameskip4:\r
-                       iCurrentConfig.iFrameskip = 4;\r
-                       iQikAppUi.Document()->SaveL();\r
+                       currentConfig.Frameskip = 4;\r
+                       emu_WriteConfig(0);\r
                        break;\r
 \r
                case EEikCmdPicoFrameskip8:\r
-                       iCurrentConfig.iFrameskip = 8;\r
-                       iQikAppUi.Document()->SaveL();\r
+                       currentConfig.Frameskip = 8;\r
+                       emu_WriteConfig(0);\r
                        break;\r
 \r
                case EEikCmdExit:\r
-                       iQikAppUi.Document()->SaveL();\r
+                       emu_Deinit();\r
                        CPicoGameSession::freeResources();\r
                        //break; // this is intentional\r
 \r
@@ -214,11 +215,14 @@ void CPicolAppView::DisplayOpenROMDialogL()
        CleanupStack::PushL(fileArray);\r
        _LIT16(KDlgTitle, "Select a ROM file");\r
 \r
+       TPtrC8 text8((TUint8*) loadedRomFName);\r
+       iCurrentConfig.iLastROMFile.Copy(text8);\r
+\r
        if( CQikSelectFileDlg::RunDlgLD( *mimeArray, *fileArray, &KDlgTitle, &iCurrentConfig.iLastROMFile) )\r
        {\r
                CEikonEnv::Static()->BusyMsgL(_L("Loading ROM"));\r
                TPtrC16 file = (*fileArray)[0];\r
-               iCurrentConfig.iLastROMFile.Copy(file);\r
+               //iCurrentConfig.iLastROMFile.Copy(file);\r
 \r
                // push the config first\r
                CPicoGameSession::Do(PicoMsgSetAppView, this);\r
@@ -271,7 +275,7 @@ void CPicolAppView::DisplayOpenROMDialogL()
                                CEikonEnv::Static()->InfoWinL(_L("Error"), _L("Failed to start soundsystem, disabled sound."));\r
                                break;\r
                }\r
-               if(res == 6 || res == 7) iCurrentConfig.iFlags &= ~4;\r
+               if(res == 6 || res == 7) currentConfig.EmuOpt &= ~EOPT_EN_SOUND;\r
 \r
                if(iROMLoaded) {\r
                        if(iTitleAdded)\r
@@ -287,11 +291,13 @@ void CPicolAppView::DisplayOpenROMDialogL()
 \r
 void CPicolAppView::DisplayConfigDialogL()\r
 {\r
-       CPicoConfigDialog* configDialog = new(ELeave)CPicoConfigDialog(iCurrentConfig);\r
+       CPicoConfigDialog* configDialog = new(ELeave)CPicoConfigDialog(currentConfig);\r
+       emu_packConfig();\r
        configDialog->ExecuteLD(R_PICO_CONFIG);\r
+       emu_unpackConfig();\r
+       emu_WriteConfig(0);\r
 \r
-       CPicoGameSession::Do(PicoMsgConfigChange, &iCurrentConfig);\r
-       iQikAppUi.Document()->SaveL();\r
+       CPicoGameSession::Do(PicoMsgConfigChange, &currentConfig);\r
 }\r
 \r
 \r
@@ -311,13 +317,13 @@ void CPicolAppView::DisplayAboutDialogL()
 }\r
 \r
 #ifdef __DEBUG_PRINT\r
-extern "C" char *debugString();\r
+extern "C" char *PDebugMain();\r
 #endif\r
 \r
 void CPicolAppView::DisplayDebugDialogL()\r
 {\r
 #ifdef __DEBUG_PRINT\r
-       CDebugDialog* dialog = new (ELeave) CDebugDialog(debugString());\r
+       CDebugDialog* dialog = new (ELeave) CDebugDialog(PDebugMain());\r
 \r
        dialog->PrepareLC(R_PICO_DEBUG);\r
        dialog->RunLD();\r
@@ -348,7 +354,7 @@ void CPicolAppView::UpdateCommandList()
        cmd_resume->SetDimmed(dimmed);\r
 \r
        // frameskip\r
-       TInt fs_index = iCurrentConfig.iFrameskip + 1;\r
+       TInt fs_index = currentConfig.Frameskip + 1;\r
        if (fs_index >= 0 && fs_index < 10 && cmd_fs[fs_index])\r
        {\r
                cmd_fs[fs_index]->SetChecked(ETrue);\r
@@ -384,7 +390,6 @@ void CPicolAppUi::ConstructL()
 CPicolDocument::CPicolDocument(CQikApplication& aApp)\r
 : CQikDocument(aApp)\r
 {\r
-       iCurrentConfig.SetDefaults();\r
 }\r
 \r
 CQikAppUi* CPicolDocument::CreateAppUiL()\r
@@ -397,6 +402,7 @@ Called by the framework when ::SaveL has been called.
 */\r
 void CPicolDocument::StoreL(CStreamStore& aStore, CStreamDictionary& aStreamDic) const\r
 {\r
+#if 0\r
        RStoreWriteStream stream;\r
 \r
        TStreamId preferenceId = stream.CreateLC(aStore);\r
@@ -408,7 +414,7 @@ void CPicolDocument::StoreL(CStreamStore& aStore, CStreamDictionary& aStreamDic)
        // Ensures that any buffered data is written to aStore\r
        stream.CommitL();\r
        CleanupStack::PopAndDestroy(); // stream\r
-\r
+#endif\r
 /*\r
        // tmp\r
        TInt res;\r
@@ -427,6 +433,7 @@ Loads the application data from disk, i.e. domain data and preferences.
 */\r
 void CPicolDocument::RestoreL(const CStreamStore& aStore, const CStreamDictionary& aStreamDic)\r
 { \r
+#if 0\r
        // Find the stream ID of the model data from the stream dictionary:\r
        TStreamId preferenceId(aStreamDic.At(KUidPicolStore));\r
        RStoreReadStream stream;\r
@@ -438,7 +445,7 @@ void CPicolDocument::RestoreL(const CStreamStore& aStore, const CStreamDictionar
        }\r
 \r
        CleanupStack::PopAndDestroy(); // stream\r
-\r
+#endif\r
 \r
        // tmp\r
 /*     TInt res;\r
@@ -475,9 +482,15 @@ TUid CPicolApplication::AppDllUid() const
 }\r
 \r
 \r
+extern "C" TInt my_SetExceptionHandler(TInt, TExceptionHandler, TUint32);\r
+\r
 GLDEF_C TInt E32Main()\r
 {\r
+       // doesn't work :(\r
        User::SetExceptionHandler(ExceptionHandler, (TUint32) -1);\r
+//     my_SetExceptionHandler(KCurrentThreadHandle, ExceptionHandler, 0xffffffff);\r
+\r
+       emu_Init();\r
 \r
        return EikStart::RunApplication(NewApplication);\r
 }\r
index 9dcb572..2c1543f 100644 (file)
 #include <coemain.h>\r
 \r
 #include <qikappui.h>\r
-#include <QikApplication.h>\r
-#include <QikViewBase.h>\r
+#include <qikapplication.h>\r
+#include <qikviewbase.h>\r
 //#include <eikapp.h>\r
-#include <QikDocument.h>\r
+#include <qikdocument.h>\r
 \r
 #include "Engine.h"\r
 #include "picodrive.hrh"\r
@@ -41,11 +41,12 @@ const TUid KUidPicolStore    = { 0x00000011 }; // store stream UID
 //};\r
 \r
 \r
+extern "C" struct _currentConfig_t;\r
 \r
 class CPicolAppView : public CQikViewBase\r
 {\r
 public:\r
-       static CPicolAppView* NewLC(CQikAppUi& aAppUi, TPicoConfigaCurrentConfig);\r
+       static CPicolAppView* NewLC(CQikAppUi& aAppUi, TPicoConfig &aCurrentConfig);\r
        ~CPicolAppView();\r
 \r
        // from CQikViewBase\r
@@ -53,12 +54,12 @@ public:
        void HandleCommandL(CQikCommand& aCommand);\r
        void UpdateCommandList();\r
 \r
-protected: \r
+protected:\r
        // from CQikViewBase\r
        void ViewConstructL();\r
-       \r
+\r
 private:\r
-       CPicolAppView(CQikAppUi& aAppUi, TPicoConfigaCurrentConfig);\r
+       CPicolAppView(CQikAppUi& aAppUi, TPicoConfig &aCurrentConfig);\r
        void ConstructL();\r
 \r
 protected:             // new stuf\r
@@ -71,7 +72,7 @@ protected:            // new stuf
        void RunGameL();*/\r
 \r
 private:\r
-       TPicoConfig&            iCurrentConfig;\r
+       TPicoConfig                     &iCurrentConfig;\r
        TBool                           iROMLoaded;\r
        TBool                           iTitleAdded;\r
 };\r
@@ -95,7 +96,7 @@ public:
        void StoreL(CStreamStore& aStore, CStreamDictionary& aStreamDic) const;\r
        void RestoreL(const CStreamStore& aStore, const CStreamDictionary& aStreamDic);\r
 \r
-       TPicoConfig                     iCurrentConfig;\r
+       TPicoConfig                     iCurrentConfig;\r
 \r
 private: // from CQikDocument\r
        CQikAppUi* CreateAppUiL();\r
index 60b8685..4440bdf 100644 (file)
 #include <qikvertoptionbuttonlist.h> // CEikHorOptionButtonList\r
 #include <eikopbut.h>   // CEikOptionButton\r
 #include <eikedwin.h>   // CEikEdwin\r
-#include <QuartzKeys.h> // EQuartzKeyTwoWayDown\r
+#include <quartzkeys.h> // EQuartzKeyTwoWayDown\r
 \r
-#include <QikCommand.h>\r
+#include <qikcommand.h>\r
+#include "../common/emu.h"\r
 \r
 \r
 /************************************************\r
@@ -35,7 +36,7 @@
  *\r
  ************************************************/\r
 \r
-CPicoConfigDialog::CPicoConfigDialog(TPicoConfig &cfg) : config(cfg)\r
+CPicoConfigDialog::CPicoConfigDialog(_currentConfig_t &cfg) : config(cfg)\r
 {\r
 }\r
 \r
@@ -44,7 +45,7 @@ void CPicoConfigDialog::PostLayoutDynInitL()
        CEikHorOptionButtonList *buttons_rot   = (CEikHorOptionButtonList*) Control( ECtlOptRotation );\r
        CEikHorOptionButtonList *buttons_disp  = (CEikHorOptionButtonList*) Control( ECtlOptScreenMode );\r
        CEikCheckBox            *chkbox_altrend= (CEikCheckBox*)            Control( ECtlOptUseAltRend );\r
-       CEikCheckBox            *chkbox_acctmng= (CEikCheckBox*)            Control( ECtlOptUseAccTiming );\r
+//     CEikCheckBox            *chkbox_acctmng= (CEikCheckBox*)            Control( ECtlOptUseAccTiming );\r
        CEikCheckBox            *chkbox_sram   = (CEikCheckBox*)            Control( ECtlOptUseSRAM );\r
        CEikCheckBox            *chkbox_fps    = (CEikCheckBox*)            Control( ECtlOptShowFPS );\r
        CEikCheckBox            *chkbox_sound  = (CEikCheckBox*)            Control( ECtlOptEnableSound );\r
@@ -54,41 +55,59 @@ void CPicoConfigDialog::PostLayoutDynInitL()
        CEikChoiceListBase      *combo_sndq    = (CEikChoiceListBase*)      Control( ECtlOptSndQuality );\r
        CEikCheckBox            *chkbox_6bpad  = (CEikCheckBox*)            Control( ECtlOpt6ButtonPad );\r
        CEikCheckBox            *chkbox_gzipst = (CEikCheckBox*)            Control( ECtlOptGzipStates );\r
-       CEikCheckBox            *chkbox_accsprt= (CEikCheckBox*)            Control( ECtlOptUseAccSprites );\r
+//     CEikCheckBox            *chkbox_accsprt= (CEikCheckBox*)            Control( ECtlOptUseAccSprites );\r
        CEikChoiceListBase      *combo_region  = (CEikChoiceListBase*)      Control( ECtlOptRegion );\r
        CEikOptionButton        *opt_fit2      = (CEikOptionButton*)        buttons_disp->ComponentControl( TPicoConfig::PMFit2 );\r
-\r
-       buttons_rot ->SetButtonById(ECtlOptRotation0 + config.iScreenRotation);\r
-       buttons_disp->SetButtonById(ECtlOptScreenModeCenter + config.iScreenMode);\r
-       chkbox_sram   ->SetState(config.iFlags & 1     ? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
-       chkbox_fps    ->SetState(config.iFlags & 2     ? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
-       chkbox_sound  ->SetState(config.iFlags & 4     ? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
-       chkbox_gzipst ->SetState(config.iFlags & 0x80  ? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
-       chkbox_z80    ->SetState(config.iPicoOpt & 4   ? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
-       chkbox_ym2612 ->SetState(config.iPicoOpt & 1   ? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
-       chkbox_sn76496->SetState(config.iPicoOpt & 2   ? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
-       chkbox_altrend->SetState(config.iPicoOpt & 0x10? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
-       chkbox_6bpad  ->SetState(config.iPicoOpt & 0x20? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
-       chkbox_acctmng->SetState(config.iPicoOpt & 0x40? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
-       chkbox_accsprt->SetState(config.iPicoOpt & 0x80? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
+       CEikCheckBox            *chkbox_cdda   = (CEikCheckBox*)            Control( ECtlOptCDcdda );\r
+       CEikCheckBox            *chkbox_pcm    = (CEikCheckBox*)            Control( ECtlOptCDpcm );\r
+       CEikCheckBox            *chkbox_ramcart= (CEikCheckBox*)            Control( ECtlOptCDramcart );\r
+       CEikCheckBox            *chkbox_sclrot = (CEikCheckBox*)            Control( ECtlOptCDscalerot );\r
+       CEikCheckBox            *chkbox_bsync  = (CEikCheckBox*)            Control( ECtlOptCDbettersync );\r
+\r
+       buttons_rot ->SetButtonById(ECtlOptRotation0 + config.rotation);\r
+       buttons_disp->SetButtonById(ECtlOptScreenModeCenter + config.scaling);\r
+       chkbox_sram   ->SetState(config.EmuOpt & 1     ? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
+       chkbox_fps    ->SetState(config.EmuOpt & 2     ? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
+       chkbox_sound  ->SetState(config.EmuOpt & 4     ? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
+       chkbox_gzipst ->SetState(config.EmuOpt & 8     ? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
+       chkbox_z80    ->SetState(config.s_PicoOpt& 4   ? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
+       chkbox_ym2612 ->SetState(config.s_PicoOpt& 1   ? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
+       chkbox_sn76496->SetState(config.s_PicoOpt& 2   ? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
+       chkbox_altrend->SetState(config.s_PicoOpt& 0x10? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
+       chkbox_6bpad  ->SetState(config.s_PicoOpt& 0x20? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
+//     chkbox_acctmng->SetState(config.s_PicoOpt& 0x40? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
+//     chkbox_accsprt->SetState(config.s_PicoOpt& 0x80? CEikButtonBase::ESet : CEikButtonBase::EClear);\r
+       chkbox_cdda   ->SetState(config.s_PicoOpt&0x0800?CEikButtonBase::ESet : CEikButtonBase::EClear);\r
+       chkbox_pcm    ->SetState(config.s_PicoOpt&0x0400?CEikButtonBase::ESet : CEikButtonBase::EClear);\r
+       chkbox_ramcart->SetState(config.s_PicoOpt&0x8000?CEikButtonBase::ESet : CEikButtonBase::EClear);\r
+       chkbox_sclrot ->SetState(config.s_PicoOpt&0x1000?CEikButtonBase::ESet : CEikButtonBase::EClear);\r
+       chkbox_bsync  ->SetState(config.s_PicoOpt&0x2000?CEikButtonBase::ESet : CEikButtonBase::EClear);\r
 \r
        // dim "fit2" if we are not in 0 or 180 mode\r
-       if(config.iScreenRotation != TPicoConfig::PRot0 && config.iScreenRotation != TPicoConfig::PRot180) opt_fit2->SetDimmed(ETrue);\r
+       if (config.rotation != TPicoConfig::PRot0 && config.rotation != TPicoConfig::PRot180)\r
+               opt_fit2->SetDimmed(ETrue);\r
        // dim some stuff for alternative renderer\r
-       if(config.iPicoOpt & 0x10) {\r
+       if (config.s_PicoOpt & 0x10) {\r
                // dim accurate sprites\r
-               chkbox_accsprt->SetState(CEikButtonBase::EClear);\r
-               chkbox_accsprt->SetDimmed(ETrue);\r
+               //chkbox_accsprt->SetState(CEikButtonBase::EClear);\r
+               //chkbox_accsprt->SetDimmed(ETrue);\r
                // dim fit\r
                if(buttons_rot->LabeledButtonId() == ECtlOptRotation0 || buttons_rot->LabeledButtonId() == ECtlOptRotation180)\r
                        ((CEikOptionButton*)(buttons_disp->ComponentControl(TPicoConfig::PMFit)))->SetDimmed(ETrue);\r
        }\r
 \r
-       TInt sel = (config.iPicoOpt&8) ? 5 : 0;\r
-       sel+= (config.iFlags>>3)&7;\r
+       TInt sel = 0;\r
+       switch (config.s_PsndRate) {\r
+               case 11025: sel = 1; break;\r
+               case 16000: sel = 2; break;\r
+               case 22050: sel = 3; break;\r
+               case 44100: sel = 4; break;\r
+       }\r
+       sel += (config.s_PicoOpt&8) ? 5 : 0;\r
        if (sel >= 10) sel = 0;\r
        combo_sndq->SetCurrentItem(sel);\r
-       switch(config.PicoRegion) {\r
+\r
+       switch(config.s_PicoRegion) {\r
                case 1: sel = 4; break;\r
                case 2: sel = 3; break;\r
                case 4: sel = 2; break;\r
@@ -105,7 +124,7 @@ TBool CPicoConfigDialog::OkToExitL(TInt aButtonId)
        CEikHorOptionButtonList *buttons_rot   = (CEikHorOptionButtonList*) Control( ECtlOptRotation );\r
        CEikHorOptionButtonList *buttons_disp  = (CEikHorOptionButtonList*) Control( ECtlOptScreenMode );\r
        CEikCheckBox            *chkbox_altrend= (CEikCheckBox*)            Control( ECtlOptUseAltRend );\r
-       CEikCheckBox            *chkbox_acctmng= (CEikCheckBox*)            Control( ECtlOptUseAccTiming );\r
+//     CEikCheckBox            *chkbox_acctmng= (CEikCheckBox*)            Control( ECtlOptUseAccTiming );\r
        CEikCheckBox            *chkbox_sram   = (CEikCheckBox*)            Control( ECtlOptUseSRAM );\r
        CEikCheckBox            *chkbox_fps    = (CEikCheckBox*)            Control( ECtlOptShowFPS );\r
        CEikCheckBox            *chkbox_sound  = (CEikCheckBox*)            Control( ECtlOptEnableSound );\r
@@ -115,35 +134,50 @@ TBool CPicoConfigDialog::OkToExitL(TInt aButtonId)
        CEikChoiceListBase      *combo_sndq    = (CEikChoiceListBase*)      Control( ECtlOptSndQuality );\r
        CEikCheckBox            *chkbox_6bpad  = (CEikCheckBox*)            Control( ECtlOpt6ButtonPad );\r
        CEikCheckBox            *chkbox_gzipst = (CEikCheckBox*)            Control( ECtlOptGzipStates );\r
-       CEikCheckBox            *chkbox_accsprt= (CEikCheckBox*)            Control( ECtlOptUseAccSprites );\r
+//     CEikCheckBox            *chkbox_accsprt= (CEikCheckBox*)            Control( ECtlOptUseAccSprites );\r
        CEikChoiceListBase      *combo_region  = (CEikChoiceListBase*)      Control( ECtlOptRegion );\r
-\r
-       config.iScreenRotation = (TPicoConfig::TPicoScreenRotation) (buttons_rot->LabeledButtonId() - ECtlOptRotation0);\r
-       config.iScreenMode = (TPicoConfig::TPicoScreenMode) (buttons_disp->LabeledButtonId() - ECtlOptScreenModeCenter);\r
-\r
-       if(chkbox_sram   ->State() == CEikButtonBase::ESet) config.iFlags |= 1;     else config.iFlags   &= ~1;\r
-       if(chkbox_fps    ->State() == CEikButtonBase::ESet) config.iFlags |= 2;     else config.iFlags   &= ~2;\r
-       if(chkbox_sound  ->State() == CEikButtonBase::ESet) config.iFlags |= 4;     else config.iFlags   &= ~4;\r
-       if(chkbox_gzipst ->State() == CEikButtonBase::ESet) config.iFlags |= 0x80;  else config.iFlags   &= ~0x80;\r
-       if(chkbox_z80    ->State() == CEikButtonBase::ESet) config.iPicoOpt |= 4;   else config.iPicoOpt &= ~4;\r
-       if(chkbox_ym2612 ->State() == CEikButtonBase::ESet) config.iPicoOpt |= 1;   else config.iPicoOpt &= ~1;\r
-       if(chkbox_sn76496->State() == CEikButtonBase::ESet) config.iPicoOpt |= 2;   else config.iPicoOpt &= ~2;\r
-       if(chkbox_altrend->State() == CEikButtonBase::ESet) config.iPicoOpt |= 0x10;else config.iPicoOpt &= ~0x10;\r
-       if(chkbox_6bpad  ->State() == CEikButtonBase::ESet) config.iPicoOpt |= 0x20;else config.iPicoOpt &= ~0x20;\r
-       if(chkbox_acctmng->State() == CEikButtonBase::ESet) config.iPicoOpt |= 0x40;else config.iPicoOpt &= ~0x40;\r
-       if(chkbox_accsprt->State() == CEikButtonBase::ESet) config.iPicoOpt |= 0x80;else config.iPicoOpt &= ~0x80;\r
+       CEikCheckBox            *chkbox_cdda   = (CEikCheckBox*)            Control( ECtlOptCDcdda );\r
+       CEikCheckBox            *chkbox_pcm    = (CEikCheckBox*)            Control( ECtlOptCDpcm );\r
+       CEikCheckBox            *chkbox_ramcart= (CEikCheckBox*)            Control( ECtlOptCDramcart );\r
+       CEikCheckBox            *chkbox_sclrot = (CEikCheckBox*)            Control( ECtlOptCDscalerot );\r
+       CEikCheckBox            *chkbox_bsync  = (CEikCheckBox*)            Control( ECtlOptCDbettersync );\r
+\r
+       config.rotation = (TPicoConfig::TPicoScreenRotation) (buttons_rot->LabeledButtonId() - ECtlOptRotation0);\r
+       config.scaling  = (TPicoConfig::TPicoScreenMode) (buttons_disp->LabeledButtonId() - ECtlOptScreenModeCenter);\r
+\r
+       if(chkbox_sram   ->State() == CEikButtonBase::ESet) config.EmuOpt |= 1;     else config.EmuOpt   &= ~1;\r
+       if(chkbox_fps    ->State() == CEikButtonBase::ESet) config.EmuOpt |= 2;     else config.EmuOpt   &= ~2;\r
+       if(chkbox_sound  ->State() == CEikButtonBase::ESet) config.EmuOpt |= 4;     else config.EmuOpt   &= ~4;\r
+       if(chkbox_gzipst ->State() == CEikButtonBase::ESet) config.EmuOpt |= 8;     else config.EmuOpt   &= ~8;\r
+       if(chkbox_z80    ->State() == CEikButtonBase::ESet) config.s_PicoOpt|= 4;   else config.s_PicoOpt&= ~4;\r
+       if(chkbox_ym2612 ->State() == CEikButtonBase::ESet) config.s_PicoOpt|= 1;   else config.s_PicoOpt&= ~1;\r
+       if(chkbox_sn76496->State() == CEikButtonBase::ESet) config.s_PicoOpt|= 2;   else config.s_PicoOpt&= ~2;\r
+       if(chkbox_altrend->State() == CEikButtonBase::ESet) config.s_PicoOpt|= 0x10;else config.s_PicoOpt&= ~0x10;\r
+       if(chkbox_6bpad  ->State() == CEikButtonBase::ESet) config.s_PicoOpt|= 0x20;else config.s_PicoOpt&= ~0x20;\r
+//     if(chkbox_acctmng->State() == CEikButtonBase::ESet) config.s_PicoOpt|= 0x40;else config.s_PicoOpt&= ~0x40;\r
+//     if(chkbox_accsprt->State() == CEikButtonBase::ESet) config.s_PicoOpt|= 0x80;else config.s_PicoOpt&= ~0x80;\r
+       if(chkbox_cdda   ->State() == CEikButtonBase::ESet) config.s_PicoOpt |= 0x0800; else config.s_PicoOpt&= ~0x0800;\r
+       if(chkbox_pcm    ->State() == CEikButtonBase::ESet) config.s_PicoOpt |= 0x0400; else config.s_PicoOpt&= ~0x0400;\r
+       if(chkbox_ramcart->State() == CEikButtonBase::ESet) config.s_PicoOpt |= 0x8000; else config.s_PicoOpt&= ~0x8000;\r
+       if(chkbox_sclrot ->State() == CEikButtonBase::ESet) config.s_PicoOpt |= 0x1000; else config.s_PicoOpt&= ~0x1000;\r
+       if(chkbox_bsync  ->State() == CEikButtonBase::ESet) config.s_PicoOpt |= 0x2000; else config.s_PicoOpt&= ~0x2000;\r
 \r
        TInt sel = combo_sndq->CurrentItem();\r
-       if(sel >= 5) { config.iPicoOpt |= 8; sel-=5; } else config.iPicoOpt &= ~8;\r
-       config.iFlags &= ~0x38;\r
-       config.iFlags |= (sel<<3)&0x38;\r
-\r
-       switch(combo_region->CurrentItem()) {\r
-               case 4: config.PicoRegion = 1; break;\r
-               case 3: config.PicoRegion = 2; break;\r
-               case 2: config.PicoRegion = 4; break;\r
-               case 1: config.PicoRegion = 8; break;\r
-               default:config.PicoRegion = 0; // auto\r
+       if(sel >= 5) { config.s_PicoOpt |= 8; sel-=5; } else config.s_PicoOpt &= ~8;\r
+       switch (sel) {\r
+               default:config.s_PsndRate =  8000; break;\r
+               case 1: config.s_PsndRate = 11025; break;\r
+               case 2: config.s_PsndRate = 16000; break;\r
+               case 3: config.s_PsndRate = 22050; break;\r
+               case 4: config.s_PsndRate = 44100; break;\r
+       }\r
+\r
+       switch (combo_region->CurrentItem()) {\r
+               case 4: config.s_PicoRegion = 1; break;\r
+               case 3: config.s_PicoRegion = 2; break;\r
+               case 2: config.s_PicoRegion = 4; break;\r
+               case 1: config.s_PicoRegion = 8; break;\r
+               default:config.s_PicoRegion = 0; // auto\r
        }\r
 \r
        return ETrue;\r
@@ -152,7 +186,8 @@ TBool CPicoConfigDialog::OkToExitL(TInt aButtonId)
 // simple GUI stuff needs lots of code\r
 void CPicoConfigDialog::HandleControlStateChangeL(TInt aControlId)\r
 {\r
-       if(aControlId == ECtlOptEnableSound) {\r
+       if (aControlId == ECtlOptEnableSound)\r
+       {\r
                CEikCheckBox *chkbox_sound  = (CEikCheckBox*) Control( ECtlOptEnableSound );\r
                CEikCheckBox *chkbox_z80    = (CEikCheckBox*) Control( ECtlOptEmulateZ80 );\r
                CEikCheckBox *chkbox_ym2612 = (CEikCheckBox*) Control( ECtlOptEmulateYM2612 );\r
@@ -179,9 +214,11 @@ void CPicoConfigDialog::HandleControlStateChangeL(TInt aControlId)
                                chkbox_sn76496->DrawDeferred();\r
                        }\r
                }\r
-       } else if(aControlId == ECtlOptUseAltRend || aControlId == ECtlOptRotation) {\r
+       }\r
+       else if(aControlId == ECtlOptUseAltRend || aControlId == ECtlOptRotation)\r
+       {\r
                CEikCheckBox            *chkbox_altrend= (CEikCheckBox*)            Control( ECtlOptUseAltRend );\r
-               CEikCheckBox            *chkbox_accsprt= (CEikCheckBox*)            Control( ECtlOptUseAccSprites );\r
+//             CEikCheckBox            *chkbox_accsprt= (CEikCheckBox*)            Control( ECtlOptUseAccSprites );\r
                CEikHorOptionButtonList *buttons_rot   = (CEikHorOptionButtonList*) Control( ECtlOptRotation );\r
                CEikHorOptionButtonList *buttons_disp  = (CEikHorOptionButtonList*) Control( ECtlOptScreenMode );\r
                CEikOptionButton        *opt_fit       = (CEikOptionButton*)        buttons_disp->ComponentControl( TPicoConfig::PMFit );\r
@@ -189,14 +226,14 @@ void CPicoConfigDialog::HandleControlStateChangeL(TInt aControlId)
 \r
                TBool dimmed = chkbox_altrend->State() == CEikButtonBase::ESet;\r
                // show/hide more stuff for alternative renderer\r
-               chkbox_accsprt->SetDimmed(dimmed);\r
+//             chkbox_accsprt->SetDimmed(dimmed);\r
                if(buttons_rot->LabeledButtonId() == ECtlOptRotation0 || buttons_rot->LabeledButtonId() == ECtlOptRotation180) {\r
                        opt_fit->SetDimmed(dimmed);\r
                        if(dimmed && buttons_disp->LabeledButtonId() == ECtlOptScreenModeFit)\r
                                buttons_disp->SetButtonById(ECtlOptScreenModeFit2);\r
                }\r
                else opt_fit->SetDimmed(EFalse);\r
-               chkbox_accsprt->DrawDeferred();\r
+//             chkbox_accsprt->DrawDeferred();\r
                buttons_disp->DrawDeferred();\r
 \r
                if(buttons_rot->LabeledButtonId() == ECtlOptRotation0 || buttons_rot->LabeledButtonId() == ECtlOptRotation180) {\r
index 7184f94..cd865ec 100644 (file)
@@ -25,7 +25,7 @@
 #include <eikchkbx.h>\r
 #include <eikedwob.h>\r
 \r
-#include <QikSimpleDialog.h>\r
+#include <qiksimpledialog.h>\r
 \r
 \r
 /************************************************\r
  *\r
  ************************************************/\r
 \r
-class TPicoConfig;\r
+extern "C" struct _currentConfig_t;\r
 \r
 class CPicoConfigDialog : public CEikDialog\r
 {\r
 public:\r
-       CPicoConfigDialog(TPicoConfig &cfg);\r
+       CPicoConfigDialog(_currentConfig_t &cfg);\r
 \r
 protected: // framework\r
     void PostLayoutDynInitL();\r
        void HandleControlStateChangeL(TInt aControlId);\r
        TBool OkToExitL(TInt aButtonId);\r
 \r
-       TPicoConfig &config;\r
+       _currentConfig_t &config;\r
 };\r
 \r
 \r
index 5e21b91..ee9b6a5 100644 (file)
 #include <string.h>\r
 \r
 #include "version.h"\r
-#include "../../pico/picoInt.h"\r
+#include <Pico/PicoInt.h>\r
+#include "../common/emu.h"\r
 #include "engine/debug.h"\r
-#include "app.h"\r
+#include "App.h"\r
 \r
 // this is where we start to break a bunch of symbian rules\r
 extern TInt machineUid;\r
 extern int gamestate, gamestate_next;\r
-extern TPicoConfig *currentConfig;\r
+extern char *loadrom_fname;\r
+extern int   loadrom_result;\r
 extern const char *actionNames[];\r
-RSemaphore pauseSemaphore;\r
 RSemaphore initSemaphore;\r
-const char *RomFileName = 0;\r
+RSemaphore pauseSemaphore;\r
+RSemaphore loadWaitSemaphore;\r
 int pico_was_reset = 0;\r
-unsigned char *rom_data = 0;\r
 static CPicolAppView *appView = 0;\r
 \r
 \r
 TInt CPicoGameSession::Do(const TPicoServRqst what, TAny *param)\r
 {\r
-       switch (what) {\r
+       switch (what)\r
+       {\r
                case PicoMsgLoadState: \r
-                       if(!rom_data) return -1; // no ROM\r
-                       return saveLoadGame(1);\r
+                       if(!rom_loaded) return -1; // no ROM\r
+                       return emu_SaveLoadGame(1, 0);\r
 \r
                case PicoMsgSaveState:\r
-                       if(!rom_data) return -1;\r
-                       return saveLoadGame(0);\r
+                       if(!rom_loaded) return -1;\r
+                       return emu_SaveLoadGame(0, 0);\r
 \r
                case PicoMsgLoadROM:\r
                        return loadROM((TPtrC16 *)param);\r
                \r
                case PicoMsgResume:\r
-                       DEBUGPRINT(_L("resume with rom %08x"), rom_data);\r
-                       if(rom_data) {\r
+                       DEBUGPRINT(_L("resume"));\r
+                       if(rom_loaded) {\r
                                return ChangeRunState(PGS_Running);\r
                        }\r
                        return 1;\r
 \r
                case PicoMsgReset: \r
-                       if(rom_data) {\r
+                       if(rom_loaded) {\r
                                PicoReset();\r
                                pico_was_reset = 1;\r
                                return ChangeRunState(PGS_Running);\r
@@ -104,6 +106,8 @@ TInt CPicoGameSession::StartEmuThread()
        initSemaphore.CreateLocal(0);\r
        if (pauseSemaphore.Handle() <= 0)\r
                pauseSemaphore.CreateLocal(0);\r
+       if (loadWaitSemaphore.Handle() <= 0)\r
+               loadWaitSemaphore.CreateLocal(0);\r
 \r
        RThread thread;\r
        if(iThreadWatcher && (res = thread.Open(iThreadWatcher->iTid)) == KErrNone) {\r
@@ -118,7 +122,6 @@ TInt CPicoGameSession::StartEmuThread()
                thread.Close();\r
        }\r
 \r
-       //semaphore.CreateLocal(0); // create a semaphore so we know when thread init is finished\r
        res=thread.Create(_L("PicoEmuThread"),   // create new server thread\r
                EmuThreadFunction, // thread's main function\r
                KDefaultStackSize,\r
@@ -134,7 +137,7 @@ TInt CPicoGameSession::StartEmuThread()
                iThreadWatcher = CThreadWatcher::NewL(thread.Id());\r
                thread.Resume(); // start it going\r
                DEBUGPRINT(_L("initSemaphore.Wait()"));\r
-               res = initSemaphore.Wait(1000*1000); // wait until it's initialized\r
+               res = initSemaphore.Wait(3*1000*1000); // wait until it's initialized\r
                DEBUGPRINT(_L("initSemaphore resume, ExitReason() == %i"), thread.ExitReason());\r
                res |= thread.ExitReason();\r
                thread.Close(); // we're no longer interested in the other thread\r
@@ -164,96 +167,34 @@ TInt CPicoGameSession::ChangeRunState(TPicoGameState newstate, TPicoGameState ne
 \r
 TInt CPicoGameSession::loadROM(TPtrC16 *pptr)\r
 {\r
-       TInt res, i;\r
-       char buff[0x31];\r
+       TInt ret;\r
+       char buff[150];\r
 \r
-       if(rom_data) {\r
-               // save SRAM for previous ROM\r
-               if(currentConfig->iFlags & 1)\r
-                       saveLoadGame(0, 1);\r
-       }\r
-\r
-       RomFileName = 0;\r
-       if(rom_data) {\r
-               free(rom_data);\r
-               rom_data = 0;\r
-       }\r
+       // make sure emu thread is ok\r
+       ret = ChangeRunState(PGS_Paused);\r
+       if(ret) return ret;\r
 \r
        // read the contents of the client pointer into a TPtr.\r
        static TBuf8<KMaxFileName> writeBuf;\r
        writeBuf.Copy(*pptr);\r
 \r
-       // detect wrong extensions (.srm and .mds)\r
-       TBuf8<5> ext;\r
-       ext.Copy(writeBuf.Right(4));\r
-       ext.LowerCase();\r
-       if(!strcmp((char *)ext.PtrZ(), ".srm") || !strcmp((char *)ext.PtrZ(), "s.gz") || // .mds.gz\r
-          !strcmp((char *)ext.PtrZ(), ".mds")) {\r
-               return PicoErrNotRom;\r
-       }\r
-\r
-       FILE *rom = fopen((char *) writeBuf.PtrZ(), "rb");\r
-       if(!rom) {\r
-               DEBUGPRINT(_L("failed to open rom."));\r
-               return PicoErrRomOpenFailed;\r
-       }\r
-\r
-       // make sure emu thread is ok\r
-       res = ChangeRunState(PGS_Paused);\r
-       if(res) {\r
-               fclose(rom);\r
-               return res;\r
-       }\r
+       // push the emu thead to a load state. This is done so that it owns all file handles.\r
+       // If successful, in will enter PGS_Running state by itself.\r
+       loadrom_fname = (char *)writeBuf.PtrZ();\r
+       loadrom_result = 0;\r
+       ret = ChangeRunState(PGS_ReloadRom);\r
+       if(ret) return ret;\r
 \r
-       unsigned int rom_size = 0;\r
-       // zipfile support\r
-       if(!strcmp((char *)ext.PtrZ(), ".zip")) {\r
-               fclose(rom);\r
-               res = CartLoadZip((const char *) writeBuf.PtrZ(), &rom_data, &rom_size);\r
-               if(res) {\r
-                       DEBUGPRINT(_L("CartLoadZip() failed (%i)"), res);\r
-                       return res;\r
-               }\r
-       } else {\r
-               if( (res = PicoCartLoad(rom, &rom_data, &rom_size)) ) {\r
-                       DEBUGPRINT(_L("PicoCartLoad() failed (%i)"), res);\r
-                       fclose(rom);\r
-                       return PicoErrOutOfMem;\r
-               }\r
-               fclose(rom);\r
-       }\r
+       loadWaitSemaphore.Wait(20*1000*1000);\r
 \r
-       // detect wrong files (Pico crashes on very small files), also see if ROM EP is good\r
-       if(rom_size <= 0x200 || strncmp((char *)rom_data, "Pico", 4) == 0 ||\r
-         ((*(TUint16 *)(rom_data+4)<<16)|(*(TUint16 *)(rom_data+6))) >= (int)rom_size) {\r
-               free(rom_data);\r
-               rom_data = 0;\r
+       if (loadrom_result == 0)\r
                return PicoErrNotRom;\r
-       }\r
 \r
-       DEBUGPRINT(_L("PicoCartInsert(0x%08X, %d);"), rom_data, rom_size);\r
-       if(PicoCartInsert(rom_data, rom_size)) {\r
-               return PicoErrOutOfMem;\r
-       }\r
-\r
-       pico_was_reset = 1;\r
-\r
-       // global ROM file name for later use\r
-       RomFileName = (const char *) writeBuf.PtrZ();\r
-\r
-       // name from the ROM itself\r
-       for(i = 0; i < 0x30; i++)\r
-               buff[i] = rom_data[0x150 + (i^1)]; // unbyteswap\r
-       for(buff[i] = 0, i--; i >= 0; i--) {\r
-               if(buff[i] != ' ') break;\r
-               buff[i] = 0;\r
-       }\r
+       emu_getGameName(buff);\r
        TPtrC8 buff8((TUint8*) buff);\r
        iRomInternalName.Copy(buff8);\r
 \r
-       // load SRAM for this ROM\r
-       if(currentConfig->iFlags & 1)\r
-               saveLoadGame(1, 1);\r
+       DEBUGPRINT(_L("done waiting for ROM load"));\r
 \r
        // debug\r
        #ifdef __DEBUG_PRINT\r
@@ -262,8 +203,6 @@ TInt CPicoGameSession::loadROM(TPtrC16 *pptr)
        User::AllocSize(mem);\r
        DEBUGPRINT(_L("comm:   cels=%d, size=%d KB"), cells, mem/1024);\r
        ChangeRunState(PGS_DebugHeap, PGS_Running);\r
-       #else\r
-       ChangeRunState(PGS_Running);\r
        #endif\r
 \r
        return 0;\r
@@ -272,23 +211,9 @@ TInt CPicoGameSession::loadROM(TPtrC16 *pptr)
 \r
 TInt CPicoGameSession::changeConfig(TPicoConfig *aConfig)\r
 {\r
-       DEBUGPRINT(_L("got new config."));\r
-\r
-       currentConfig = aConfig;\r
-\r
-       // set PicoOpt and rate\r
-       PicoRegionOverride = currentConfig->PicoRegion;\r
-       PicoOpt = currentConfig->iPicoOpt;\r
-       switch((currentConfig->iFlags>>3)&7) {\r
-               case 1:  PsndRate=11025; break;\r
-               case 2:  PsndRate=16000; break;\r
-               case 3:  PsndRate=22050; break;\r
-               case 4:  PsndRate=44100; break;\r
-               default: PsndRate= 8000; break;\r
-       }\r
-\r
        // 6 button pad, enable XYZM config if needed\r
-       if(PicoOpt & 0x20) {\r
+       if (PicoOpt & POPT_6BTN_PAD)\r
+       {\r
                actionNames[8]  = "Z";\r
                actionNames[9]  = "Y";\r
                actionNames[10] = "X";\r
@@ -298,16 +223,15 @@ TInt CPicoGameSession::changeConfig(TPicoConfig *aConfig)
        }\r
 \r
        // if we are in center 90||270 modes, we can bind renderer switcher\r
-       if(currentConfig->iScreenMode == TPicoConfig::PMFit &&\r
-               (currentConfig->iScreenRotation == TPicoConfig::PRot0 || currentConfig->iScreenRotation == TPicoConfig::PRot180))\r
-                                actionNames[25] = 0;\r
-                       else actionNames[25] = "RENDERER";\r
+       if (currentConfig.scaling == TPicoConfig::PMFit &&\r
+               (currentConfig.rotation == TPicoConfig::PRot0 || currentConfig.rotation == TPicoConfig::PRot180))\r
+                        actionNames[25] = 0;\r
+       else actionNames[25] = "RENDERER";\r
 \r
        return 0;\r
 }\r
 \r
 \r
-void MainOldCleanup(); // from main.cpp\r
 #ifdef __DEBUG_PRINT_FILE\r
 extern RMutex logMutex;\r
 #endif\r
@@ -346,7 +270,7 @@ void CPicoGameSession::freeResources()
 \r
        }\r
 \r
-       if(iThreadWatcher != NULL)\r
+       if (iThreadWatcher != NULL)\r
        {\r
                DEBUGPRINT(_L("delete iThreadWatcher"));\r
                delete iThreadWatcher;\r
@@ -354,12 +278,13 @@ void CPicoGameSession::freeResources()
                iThreadWatcher = NULL;\r
        }\r
 \r
-       MainOldCleanup();\r
-\r
        if (initSemaphore.Handle() > 0)\r
                initSemaphore.Close();\r
        if (pauseSemaphore.Handle() > 0)\r
                pauseSemaphore.Close();\r
+       if (loadWaitSemaphore.Handle() > 0)\r
+               loadWaitSemaphore.Close();\r
+       DEBUGPRINT(_L("freeResources() returning"));\r
 #ifdef __DEBUG_PRINT_FILE\r
        if (logMutex.Handle() > 0)\r
                logMutex.Close();\r
@@ -368,67 +293,7 @@ void CPicoGameSession::freeResources()
 \r
 TBool CPicoGameSession::iEmuRunning = EFalse;\r
 CThreadWatcher *CPicoGameSession::iThreadWatcher = 0;\r
-TBuf<0x30> CPicoGameSession::iRomInternalName;\r
-\r
-\r
-void TPicoConfig::SetDefaults()\r
-{\r
-       iLastROMFile.SetLength(0);\r
-       iScreenRotation = PRot270;\r
-       iScreenMode     = PMCenter;\r
-       iFlags          = 1; // use_sram\r
-       iPicoOpt        = 0; // all off\r
-       iFrameskip      = PFSkipAuto;\r
-\r
-       Mem::FillZ(iKeyBinds,  sizeof(iKeyBinds));\r
-       Mem::FillZ(iAreaBinds, sizeof(iAreaBinds));\r
-       iKeyBinds[0xd5] = 1<<26; // bind back\r
-}\r
-\r
-// load config\r
-void TPicoConfig::InternalizeL(RReadStream &aStream)\r
-{\r
-       TInt32 version, fname_len;\r
-       version = aStream.ReadInt32L();\r
-       fname_len       = aStream.ReadInt32L();\r
-\r
-       // not sure if this is safe\r
-       iLastROMFile.SetMax();\r
-       aStream.ReadL((TUint8 *) iLastROMFile.Ptr(), KMaxFileName*2);\r
-       iLastROMFile.SetLength(fname_len);\r
-\r
-       iScreenRotation = aStream.ReadInt32L();\r
-       iScreenMode     = aStream.ReadInt32L();\r
-       iFlags          = aStream.ReadUint32L();\r
-       iPicoOpt        = aStream.ReadInt32L();\r
-       iFrameskip      = aStream.ReadInt32L();\r
-\r
-       aStream.ReadL((TUint8 *)iKeyBinds,  sizeof(iKeyBinds));\r
-       aStream.ReadL((TUint8 *)iAreaBinds, sizeof(iAreaBinds));\r
-\r
-       PicoRegion      = aStream.ReadInt32L();\r
-}\r
-\r
-// save config\r
-void TPicoConfig::ExternalizeL(RWriteStream &aStream) const\r
-{\r
-       TInt version = (KPicoMajorVersionNumber<<24)+(KPicoMinorVersionNumber<<16);\r
-\r
-       aStream.WriteInt32L(version);\r
-       aStream.WriteInt32L(iLastROMFile.Length());\r
-       aStream.WriteL((const TUint8 *)iLastROMFile.Ptr(), KMaxFileName*2);\r
-\r
-       aStream.WriteInt32L(iScreenRotation);\r
-       aStream.WriteInt32L(iScreenMode);\r
-       aStream.WriteUint32L(iFlags);\r
-       aStream.WriteInt32L(iPicoOpt);\r
-       aStream.WriteInt32L(iFrameskip);\r
-\r
-       aStream.WriteL((const TUint8 *)iKeyBinds,  sizeof(iKeyBinds));\r
-       aStream.WriteL((const TUint8 *)iAreaBinds, sizeof(iAreaBinds));\r
-\r
-       aStream.WriteInt32L(PicoRegion);\r
-}\r
+TBuf<150> CPicoGameSession::iRomInternalName;\r
 \r
 \r
 // CThreadWatcher\r
@@ -482,3 +347,10 @@ void CThreadWatcher::DoCancel()
                thread.Close();\r
        }\r
 }\r
+\r
+extern "C" void cache_flush_d_inval_i(const void *start_addr, const void *end_addr)\r
+{\r
+       // TODO\r
+       User::IMB_Range((TAny *)start_addr, (TAny *)end_addr);\r
+}\r
+\r
index 19bd84e..b81b6af 100644 (file)
@@ -28,6 +28,7 @@ enum TPicoGameState {
        PGS_Quit,\r
        PGS_KeyConfig,\r
        PGS_DebugHeap,\r
+       PGS_ReloadRom,\r
 };\r
 \r
 enum TPicoServRqst {\r
@@ -81,9 +82,9 @@ struct TPicoKeyConfigEntry
 class TPicoConfig\r
 {\r
 public:\r
-       void SetDefaults();\r
-       void InternalizeL(RReadStream &aStream);\r
-       void ExternalizeL(RWriteStream &aStream) const;\r
+//     void SetDefaults();\r
+//     void InternalizeL(RReadStream &aStream);\r
+//     void ExternalizeL(RWriteStream &aStream) const;\r
 \r
        enum TPicoScreenRotation {\r
                PRot0,\r
@@ -102,18 +103,7 @@ public:
        };\r
 \r
 public:\r
-       TFileName                       iLastROMFile;\r
-\r
-       TInt32                          iScreenRotation;\r
-       TInt32                          iScreenMode;\r
-       TUint32                         iFlags;   // LSb->MSb: use_sram, show_fps, enable_sound, sound_rate(3bits), gzip_saves{=0x40}, dont_use_mot_vol\r
-    // enable_ym2612&dac, enable_sn76496, enable_z80, stereo_sound;\r
-    // alt_renderer, 6button_gamepad, accurate_timing\r
-       TInt32                          iPicoOpt;\r
-       TInt32                          iFrameskip;\r
-       TUint32                         iKeyBinds[256]; // a binding for every keycode\r
-       TUint32                         iAreaBinds[19];\r
-       TInt32                          PicoRegion;\r
+       TFileName                       iLastROMFile;   // used as tmp only\r
 };\r
 \r
 \r
@@ -141,7 +131,7 @@ public:
        static void freeResources();\r
 \r
        static TBool iEmuRunning;\r
-       static TBuf<0x30> iRomInternalName;\r
+       static TBuf<150> iRomInternalName;\r
 \r
 private:\r
        // services available\r
@@ -153,7 +143,4 @@ private:
        static CThreadWatcher *iThreadWatcher;\r
 };\r
 \r
-// global\r
-int saveLoadGame(int load, int sram=0);\r
-\r
 #endif\r
index fa14569..9e91127 100644 (file)
-# makefile for GCCE\r
+# makefile for uiq3_patcher_0_2.tar.gz\r
+export CROSS = arm-none-symbianelf-\r
+APPNAME = PicoDrive\r
+VER_MAJ = 1\r
+VER_MIN = 51\r
+VENDOR = notaz\r
+UID3 = A00010F3\r
+EPOCROOT = /opt/uiq3/\r
+EPOCLIBS = qikdlg.lib etext.lib bafl.lib efsrv.lib eikctl.lib ws32.lib \\r
+       eikdlg.lib gdi.lib estor.lib hal.lib mediaclient.lib mediaclientaudiostream.lib\r
+STACK = 0x3000\r
+HEAP = 0x10,0x1000000\r
+\r
 \r
 # settings\r
-#dprint = 1\r
 asm_memory = 1\r
 asm_render = 1\r
+asm_ym2612 = 1\r
+asm_misc = 1\r
+asm_cdpico = 1\r
+asm_cdmemory = 1\r
 asm_blit = 1\r
+use_cyclone = 1\r
 #use_musashi = 1\r
-#up = 1\r
-#sis = 1\r
-\r
-# targets\r
-all: $(EPOCROOT2)epoc32 MAKEDIRS RESOURCES PicoDrive.exe\r
-\r
-clean :\r
-       @perl -S ermdir.pl _build\r
-       @erase 2>>nul rsc\*.rsc\r
-       @erase 2>>nul rsc\*.rsg\r
-       @erase 2>>nul rsc\PicoDrive.mb?\r
-\r
-\r
-# paths\r
-$(EPOCROOT2)epoc32 :\r
-       @echo Please set EPOCROOT2 environmental variable to full path to your SDK\r
-       @echo with ending slash (something like C:\Uiq_21\)\r
-       @cd : 2> NUL # do something stupid to make it silently fail\r
-\r
-# resource compiler hates drive lettered paths\r
-EPOCROOT2_NODRV = $(filter \\%,$(subst :, ,$(EPOCROOT2)))\r
-EPOCLIB = $(EPOCROOT2)EPOC32\RELEASE\ARMV5\r
-\r
-# C/C++ Compiler\r
-CC=arm-none-symbianelf-gcc\r
-\r
-# Linker\r
-LD=arm-none-symbianelf-ld\r
-\r
-# Assembler\r
-ASM=arm-none-symbianelf-as\r
-\r
-# Archiver\r
-AR=arm-none-symbianelf-ar\r
-\r
-# Strip\r
-STRIP=arm-none-symbianelf-strip\r
-\r
-# gcc config\r
-GCCDEFINES = -DNDEBUG -D_UNICODE -D__GCCE__ -D__SYMBIAN32__ -D__EPOC32__ -D__MARM__ \\r
-               -D__EABI__ -D__MARM_ARMV5__ -D__EXE__ -D__SUPPORT_CPP_EXCEPTIONS__ \\r
-               -D__MARM_ARMV5__ -D__PRODUCT_INCLUDE__=\"$(EPOCROOT2)epoc32/include/variant/UIQ_3.0.hrh\"\r
-\r
-GCCDEFINES += -D_UNZIP_SUPPORT -D__BROKEN_FWRITE\r
-\r
-# 'CSL Arm Toolchain' stuff must be specified after Symbian includes\r
-GCCINCLUDES = -I "$(EPOCROOT2)epoc32\include\variant" -I "$(EPOCROOT2)EPOC32\INCLUDE" -I "$(EPOCROOT2)EPOC32\INCLUDE\LIBC" \\r
-               -I "$(EPOCROOT2)\CSL Arm Toolchain\lib\gcc\arm-none-symbianelf\3.4.3\include" -I.\r
-\r
-# -funit-at-a-time is not compatible with SDK, it either has linker problems or does not start on device\r
-GCCCOMMFLAGS = -Wall -Wno-unknown-pragmas -fexceptions -march=armv5t -mapcs -pipe -nostdinc -msoft-float \\r
-               $(GCCINCLUDES) -include "$(EPOCROOT2)EPOC32/INCLUDE/GCCE/GCCE.h" -marm\r
-\r
-GCCCPPFLAGS = -x c++ -Wno-ctor-dtor-privacy -O3 -fno-unit-at-a-time\r
-GCCCFLAGS = -x c -O3 -fno-unit-at-a-time\r
-\r
-GCCLDFLAGS = -L"$(EPOCROOT2)CSL Arm Toolchain\arm-none-symbianelf\lib" \\r
-               -L"$(EPOCROOT2)CSL Arm Toolchain\lib\gcc\arm-none-symbianelf\3.4.3" \\r
-               --target1-abs --no-undefined -nostdlib -shared -Ttext 0x8000 -Tdata 0x400000 --default-symver\r
-\r
-# libs\r
-LIBS = \\r
-       $(EPOCLIB)\LIB\ESTLIB.dso \\r
-       $(EPOCLIB)\urel\qikalloc.lib \\r
-       $(EPOCLIB)\LIB\euser.dso \\r
-       $(EPOCLIB)\LIB\apparc.dso \\r
-       $(EPOCLIB)\LIB\cone.dso \\r
-       $(EPOCLIB)\LIB\eikcore.dso \\r
-       $(EPOCLIB)\LIB\eikcoctl.dso \\r
-       $(EPOCLIB)\LIB\qikcore.dso \\r
-       $(EPOCLIB)\LIB\qikdlg.dso \\r
-       $(EPOCLIB)\LIB\etext.dso \\r
-       $(EPOCLIB)\LIB\bafl.dso \\r
-       $(EPOCLIB)\LIB\efsrv.dso \\r
-       $(EPOCLIB)\LIB\eikctl.dso \\r
-       $(EPOCLIB)\LIB\WS32.dso \\r
-       $(EPOCLIB)\LIB\EIKDLG.dso \\r
-       $(EPOCLIB)\LIB\GDI.dso \\r
-       $(EPOCLIB)\LIB\estor.dso \\r
-       $(EPOCLIB)\LIB\EZLIB.dso \\r
-       $(EPOCLIB)\LIB\HAL.dso \\r
-       $(EPOCLIB)\LIB\mediaclient.dso \\r
-       $(EPOCLIB)\LIB\mediaclientaudiostream.dso\r
-\r
-LIBS += \\r
-       $(EPOCLIB)\LIB\qikallocdll.dso \\r
-       $(EPOCLIB)\UREL\usrt2_2.lib \\r
-       $(EPOCLIB)\LIB\dfpaeabi.dso \\r
-       $(EPOCLIB)\LIB\dfprvct2_2.dso \\r
-       $(EPOCLIB)\LIB\drtaeabi.dso \\r
-       $(EPOCLIB)\LIB\scppnwdl.dso \\r
-       $(EPOCLIB)\LIB\drtrvct2_2.dso\r
 \r
 \r
 # objects\r
 \r
 # launcher\r
-OBJECTS += _build\App.o _build\Engine.o _build\Dialogs.o _build\CSimpleTextParser.o\r
+OBJ += App.o Engine.o Dialogs.o CSimpleTextParser.o emu.o\r
 # engine\r
-OBJECTS += _build\main.o _build\vid.o _build\polledas.o _build\audio_mediaserver.o _build\debug.o\r
-\r
+OBJ += engine/main.o engine/vid.o engine/polledas.o engine/audio_mediaserver.o engine/debug.o\r
+ifeq "$(asm_blit)" "1"\r
+OBJ += engine/blit_asm.o\r
+else\r
+OBJ += engine/blit.o\r
+endif\r
+# common\r
+OBJ += ../common/emu.o ../common/config.o ../common/menu.o ../common/mp3_helix.o\r
 # Pico\r
-OBJECTS += _build\Area.o _build\Cart.o _build\Utils.o _build\Memory.o _build\Misc.o \\r
-               _build\Pico.o _build\Sek.o _build\VideoPort.o _build\Draw2.o _build\Draw.o\r
+OBJ += Pico/Area.o Pico/Cart.o Pico/Memory.o Pico/Misc.o Pico/Pico.o Pico/Sek.o \\r
+               Pico/VideoPort.o Pico/Draw2.o Pico/Draw.o Pico/Patch.o Pico/Debug.o\r
+# Pico - CD\r
+OBJ += Pico/cd/Pico.o Pico/cd/Memory.o Pico/cd/Sek.o Pico/cd/LC89510.o \\r
+               Pico/cd/cd_sys.o Pico/cd/cd_file.o Pico/cd/cue.o Pico/cd/gfx_cd.o \\r
+               Pico/cd/Area.o Pico/cd/Misc.o Pico/cd/pcm.o Pico/cd/buffering.o\r
+# Pico - Pico\r
+OBJ += Pico/Pico/Pico.o Pico/Pico/Memory.o Pico/Pico/xpcm.o\r
+# Pico - carthw\r
+OBJ += Pico/carthw/carthw.o Pico/carthw/svp/svp.o Pico/carthw/svp/Memory.o \\r
+               Pico/carthw/svp/ssp16.o Pico/carthw/svp/compiler.o Pico/carthw/svp/stub_arm.o\r
+\r
 # asm stuff\r
 ifeq "$(asm_render)" "1"\r
-GCCDEFINES += -D_ASM_DRAW_C\r
-OBJECTS += _build\draw_asm.o _build\draw2_asm.o\r
+CFLAGS += -D_ASM_DRAW_C\r
+OBJ += Pico/draw_asm.o Pico/draw2_asm.o\r
 endif\r
 ifeq "$(asm_memory)" "1"\r
-GCCDEFINES += -D_ASM_MEMORY_C\r
-OBJECTS += _build\memory_asm.o\r
+CFLAGS += -D_ASM_MEMORY_C\r
+OBJ += Pico/memory_asm.o\r
 endif\r
-# Pico - sound\r
-OBJECTS += _build\sound.o _build\sn76496.o _build\ym2612.o\r
-# misc\r
-OBJECTS += _build\unzip.o _build\gzio_symb.o\r
-# CPU cores\r
-ifeq "$(use_musashi)" "1"\r
-GCCDEFINES += -DEMU_M68K\r
-OBJECTS += _build\m68kcpu.o _build\m68kopac.o _build\m68kopdm.o _build\m68kopnz.o _build\m68kops.o\r
-else\r
-GCCDEFINES += -DEMU_C68K\r
-OBJECTS += _build\Cyclone.o\r
+ifeq "$(asm_ym2612)" "1"\r
+CFLAGS += -D_ASM_YM2612_C\r
+OBJ += Pico/sound/ym2612_asm.o\r
 endif\r
-ifeq "$(asm_blit)" "1"\r
-OBJECTS += _build\blit_asm.o\r
-else\r
-OBJECTS += _build\blit.o\r
+ifeq "$(asm_misc)" "1"\r
+CFLAGS += -D_ASM_MISC_C\r
+OBJ += Pico/misc_asm.o\r
+OBJ += Pico/cd/misc_asm.o\r
 endif\r
-GCCDEFINES += -D_USE_DRZ80\r
-OBJECTS += _build\DrZ80.o\r
-GCCDEFINES += -D_ASM_YM2612_C\r
-OBJECTS += _build\ym2612_asm.o\r
-\r
-\r
-\r
-# dprint\r
-ifeq "$(dprint)" "1"\r
-GCCDEFINES += -D__DEBUG_PRINT\r
+ifeq "$(asm_cdpico)" "1"\r
+CFLAGS += -D_ASM_CD_PICO_C\r
+OBJ += Pico/cd/pico_asm.o\r
+endif\r
+ifeq "$(asm_cdmemory)" "1"\r
+CFLAGS += -D_ASM_CD_MEMORY_C\r
+OBJ += Pico/cd/memory_asm.o\r
 endif\r
 \r
-\r
-define crule\r
-       @echo * $<\r
-       @$(CC) -c $(GCCCOMMFLAGS) $(GCCDEFINES) $(GCCCFLAGS) $< -o $@\r
-endef\r
-\r
-define cpprule\r
-       @echo * $<\r
-       @$(CC) -c $(GCCCOMMFLAGS) $(GCCDEFINES) $(GCCCPPFLAGS) $< -o $@\r
-endef\r
-\r
-define asmrule\r
-       @echo * $<\r
-       @$(ASM) -marmv4t -mthumb-interwork -o $@ $^\r
-endef\r
-\r
-# object making rules\r
-_build\App.o     : App.cpp\r
-       $(cpprule)\r
-_build\Engine.o  : Engine.cpp\r
-       $(cpprule)\r
-_build\Dialogs.o : Dialogs.cpp\r
-       $(cpprule)\r
-_build\CSimpleTextParser.o : CSimpleTextParser.cpp\r
-       $(cpprule)\r
-\r
-_build\main.o    : engine\main.cpp\r
-       $(cpprule)\r
-_build\vid.o     : engine\vid.cpp\r
-       $(cpprule)\r
-_build\polledas.o: engine\polledas.cpp\r
-       $(cpprule)\r
-_build\audio_mediaserver.o : engine\audio_mediaserver.cpp\r
-       $(cpprule)\r
-_build\debug.o   : engine\debug.cpp\r
-       $(cpprule)\r
-_build\blit.o    : engine\blit.c\r
-       $(crule)\r
-\r
-_build\Area.o    : ..\..\Pico\Area.c\r
-       $(crule)\r
-_build\Cart.o    : ..\..\Pico\Cart.c\r
-       $(crule)\r
-_build\Draw.o    : ..\..\Pico\Draw.c\r
-       $(crule)\r
-_build\Draw2.o   : ..\..\Pico\Draw2.c\r
-       $(crule)\r
-_build\Memory.o  : ..\..\Pico\Memory.c\r
-       $(crule)\r
-_build\Misc.o    : ..\..\Pico\Misc.c\r
-       $(crule)\r
-_build\Pico.o    : ..\..\Pico\Pico.c\r
-       $(crule)\r
-_build\Sek.o     : ..\..\Pico\Sek.c\r
-       $(crule)\r
-_build\Utils.o   : ..\..\Pico\Utils.c\r
-       $(crule)\r
-_build\VideoPort.o : ..\..\Pico\VideoPort.c\r
-       $(crule)\r
-_build\sound.o   : ..\..\Pico\sound\sound.c\r
-       $(crule)\r
-_build\sn76496.o : ..\..\Pico\sound\sn76496.c\r
-       $(crule)\r
-_build\ym2612.o  : ..\..\Pico\sound\ym2612.c\r
-       $(crule)\r
-\r
-_build\unzip.o     : ..\..\unzip\unzip.c\r
-       $(crule)\r
-_build\gzio_symb.o : ..\..\zlib\gzio_symb.c\r
-       $(crule)\r
-\r
-_build\m68kcpu.o  : ..\..\musashi\m68kcpu.c\r
-       $(crule)\r
-_build\m68kopac.o : ..\..\musashi\m68kopac.c\r
-       $(crule)\r
-_build\m68kopdm.o : ..\..\musashi\m68kopdm.c\r
-       $(crule)\r
-_build\m68kopnz.o : ..\..\musashi\m68kopnz.c\r
-       $(crule)\r
-_build\m68kops.o  : ..\..\musashi\m68kops.c\r
-       $(crule)\r
-\r
-_build\Cyclone.o : ..\..\cpu\Cyclone\proj\Cyclone.s\r
-       $(asmrule)\r
-_build\DrZ80.o : ..\..\cpu\DrZ80\drz80.s\r
-       $(asmrule)\r
-_build\draw_asm.o : ..\..\Pico\draw.s\r
-       $(asmrule)\r
-_build\draw2_asm.o : ..\..\Pico\draw2.s\r
-       $(asmrule)\r
-_build\memory_asm.o : ..\..\Pico\memory.s\r
-       $(asmrule)\r
-_build\ym2612_asm.o : ..\..\Pico\sound\ym2612.s\r
-       $(asmrule)\r
-_build\blit_asm.o : engine\blit.s\r
-       $(asmrule)\r
-\r
-\r
-PicoDrive.exe : $(OBJECTS)\r
-       @echo * ld\r
-       @$(LD) $(GCCLDFLAGS) -soname PicoDrive{000a0000}[a00010f3].exe --entry _E32Startup -u _E32Startup \\r
-               $(EPOCROOT2)EPOC32\RELEASE\ARMV5\UREL\EEXE.LIB -o "_build\PicoDrive_elf.exe" -Map "_build\PicoDrive.exe.map" $(OBJECTS) $(LIBS) -lsupc++ -lgcc\r
-#      @echo * strip\r
-#      @$(STRIP) _build\PicoDrive_elf.exe\r
-       @echo * elf2e32\r
-       @elf2e32 --sid=0xa00010f3  --heap=0x00000100,0x00800000 --stack=0x00003000 \\r
-               --uid1=0x1000007a --uid2=0x100039ce --uid3=0xa00010f3 \\r
-               --capability=none --fpu=softvfp --targettype=EXE --output="$@" \\r
-               --elfinput="_build\PicoDrive_elf.exe" --linkas=PicoDrive{000a0000}[a00010f3].exe --libpath="$(EPOCLIB)\LIB"\r
-ifeq "$(sis)" "1"\r
-       @make -C _out\r
-ifeq "$(up)" "1"\r
-       @qup.cmd\r
+# Pico - sound\r
+OBJ += Pico/sound/sound.o\r
+OBJ += Pico/sound/mix_asm.o\r
+OBJ += Pico/sound/sn76496.o Pico/sound/ym2612.o\r
+# zlib\r
+OBJ += zlib/gzio.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o \\r
+       zlib/deflate.o zlib/crc32.o zlib/adler32.o zlib/zutil.o zlib/compress.o\r
+# unzip\r
+OBJ += unzip/unzip.o unzip/unzip_stream.o\r
+# CPU cores\r
+ifeq "$(use_musashi)" "1"\r
+CFLAGS += -DEMU_M68K\r
+OBJ += cpu/musashi/m68kops.o cpu/musashi/m68kcpu.o\r
 endif\r
+ifeq "$(use_cyclone)" "1"\r
+CFLAGS += -DEMU_C68K\r
+OBJ += cpu/Cyclone/proj/Cyclone.o cpu/Cyclone/tools/idle.o\r
 endif\r
-\r
-\r
-MAKEDIRS : _build\r
-\r
-_build :\r
-#      @echo * making build dir\r
-       @perl -S emkdir.pl $@\r
-\r
-\r
-# BitMap PicoDrive.mbm\r
-\r
-RESOURCES : rsc\PicoDrive.mbm rsc\PicoDrive.RSC rsc\PicoDrive_reg.RSC rsc\PicoDrive_loc.RSC rsc\PicoDrive.mbg\r
-\r
-rsc\PicoDrive.mbg : rsc\PicoDrive.mbm\r
-\r
-rsc\PicoDrive.mbm : rsc\pico18x18.bmp rsc\pico18x18m.bmp rsc\pico40x40.bmp rsc\pico40x40m.bmp rsc\pico64x64.bmp rsc\pico64x64m.bmp\r
-       @echo * $@\r
-       @perl -S epocmbm.pl -h"rsc\PicoDrive.mbg" -o"rsc\PicoDrive.mbm" -l"\Z\Resource\Apps\:rsc" \\r
-               -b"/c24rsc\pico18x18.bmp /8rsc\pico18x18m.bmp /c24rsc\pico40x40.bmp /8rsc\pico40x40m.bmp /c24rsc\pico64x64.bmp /8rsc\pico64x64m.bmp" -l"\Z\Resource\Apps\:rsc"\r
-       @perl -S ecopyfile.pl "rsc\PicoDrive.mbg" "$(EPOCROOT2)EPOC32\INCLUDE\PicoDrive.mbg"\r
-\r
-# Resource Z\Resource\Apps\PicoDrive.RSC\r
-\r
-rsc\PicoDrive.RSC : rsc\PicoDrive.rss picodrive.hrh\r
-       @echo * $@\r
-       @perl -S epocrc.pl -m045,046,047 -I "." -I- -I "$(EPOCROOT2_NODRV)EPOC32\include" -DLANGUAGE_SC -u "rsc\PicoDrive.rss" -o$@ \\r
-               -h"rsc\PicoDrive.rsg" -t"rsc" -l"Z\Resource\Apps:rsc"\r
-       @perl -S ecopyfile.pl "rsc\PicoDrive.rsg" "$(EPOCROOT2)EPOC32\INCLUDE\PicoDrive.RSG"\r
-\r
-# Resource Z\private\10003a3f\apps\PicoDrive_reg.RSC\r
-\r
-rsc\PicoDrive_reg.RSC : rsc\PicoDrive_reg.rss\r
-       @echo * $@\r
-       @perl -S epocrc.pl -m045,046,047 -I "." -I- -I "$(EPOCROOT2)EPOC32\include" -DLANGUAGE_SC -u "rsc\PicoDrive_reg.rss" -o$@ \\r
-       -t"rsc" -l"Z\private\10003a3f\apps:rsc"\r
-\r
-# Resource Z\Resource\Apps\PicoDrive_loc.RSC\r
-\r
-rsc\PicoDrive_loc.RSC : rsc\PicoDrive_loc.rss\r
-       @echo * $@\r
-       @perl -S epocrc.pl -m045,046,047 -I "." -I- -I "$(EPOCROOT2)EPOC32\include" -DLANGUAGE_SC -u "rsc\PicoDrive_loc.rss" -o$@ \\r
-               -t"rsc"  -l"Z\Resource\Apps:rsc"\r
+# drz80\r
+CFLAGS += -D_USE_DRZ80\r
+OBJ += cpu/DrZ80/drz80.o\r
+# helix\r
+OBJ += ../common/helix/$(CROSS)helix-mp3.a\r
+\r
+\r
+vpath %.c = ../..\r
+vpath %.s = ../..\r
+vpath %.S = ../..\r
+DIRS = platform platform/common Pico Pico/cd Pico/Pico Pico/sound Pico/carthw/svp \\r
+       zlib unzip cpu cpu/musashi cpu/Cyclone/proj cpu/Cyclone/tools cpu/mz80 cpu/DrZ80\r
+\r
+ICONS := $(shell echo rsc/*.bmp)\r
+APPICON = $(NAME).mbm\r
+RSCDIR = rsc\r
+REGDIR = rsc\r
+CFLAGS += -I./ -I../../\r
+CFLAGS += -DUIQ3 -DARM -DNO_SYNC\r
+CFLAGS += -D__DEBUG_PRINT\r
+CFLAGS += -mcpu=arm926ej-s -mtune=arm926ej-s -O3 -ftracer \\r
+               -fstrength-reduce -fomit-frame-pointer -fstrict-aliasing -ffast-math\r
+SFLAGS =  -march=armv5t -msoft-float -nostdinc\r
+ASFLAGS = -mcpu=arm926ej-s -mfloat-abi=soft\r
+export CFLAGS\r
+SRCRES := $(shell echo rsc/*.rss)\r
+EPOCRCFLAGS += -I./\r
+\r
+all: mkdirs sis\r
+\r
+include uiq3.mak\r
+include ../common/common_arm.mak\r
+\r
+\r
+$(NAME).mbg $(NAME).mbm : $(ICONS)\r
+       @echo "Creating multibitmap file..."\r
+       $(BMCONV) /h$(NAME).mbg $(NAME).mbm \\r
+               /c24rsc/pico18x18.bmp /8rsc/pico18x18m.bmp \\r
+               /c24rsc/pico40x40.bmp /8rsc/pico40x40m.bmp \\r
+               /c24rsc/pico64x64.bmp /8rsc/pico64x64m.bmp\r
+\r
+\r
+engine/blit_asm.o : engine/blit.s\r
+       @echo ">>>" $@\r
+       $(AS) $(ASFLAGS) $< -o $@\r
+\r
+# App.o can't be optimized\r
+#App.o : App.cpp\r
+#      $(CC) $(CXXFLAGS) -O0 -c $< -o $@\r
diff --git a/platform/uiq3/Makefile.old b/platform/uiq3/Makefile.old
new file mode 100644 (file)
index 0000000..fa14569
--- /dev/null
@@ -0,0 +1,307 @@
+# makefile for GCCE\r
+\r
+# settings\r
+#dprint = 1\r
+asm_memory = 1\r
+asm_render = 1\r
+asm_blit = 1\r
+#use_musashi = 1\r
+#up = 1\r
+#sis = 1\r
+\r
+# targets\r
+all: $(EPOCROOT2)epoc32 MAKEDIRS RESOURCES PicoDrive.exe\r
+\r
+clean :\r
+       @perl -S ermdir.pl _build\r
+       @erase 2>>nul rsc\*.rsc\r
+       @erase 2>>nul rsc\*.rsg\r
+       @erase 2>>nul rsc\PicoDrive.mb?\r
+\r
+\r
+# paths\r
+$(EPOCROOT2)epoc32 :\r
+       @echo Please set EPOCROOT2 environmental variable to full path to your SDK\r
+       @echo with ending slash (something like C:\Uiq_21\)\r
+       @cd : 2> NUL # do something stupid to make it silently fail\r
+\r
+# resource compiler hates drive lettered paths\r
+EPOCROOT2_NODRV = $(filter \\%,$(subst :, ,$(EPOCROOT2)))\r
+EPOCLIB = $(EPOCROOT2)EPOC32\RELEASE\ARMV5\r
+\r
+# C/C++ Compiler\r
+CC=arm-none-symbianelf-gcc\r
+\r
+# Linker\r
+LD=arm-none-symbianelf-ld\r
+\r
+# Assembler\r
+ASM=arm-none-symbianelf-as\r
+\r
+# Archiver\r
+AR=arm-none-symbianelf-ar\r
+\r
+# Strip\r
+STRIP=arm-none-symbianelf-strip\r
+\r
+# gcc config\r
+GCCDEFINES = -DNDEBUG -D_UNICODE -D__GCCE__ -D__SYMBIAN32__ -D__EPOC32__ -D__MARM__ \\r
+               -D__EABI__ -D__MARM_ARMV5__ -D__EXE__ -D__SUPPORT_CPP_EXCEPTIONS__ \\r
+               -D__MARM_ARMV5__ -D__PRODUCT_INCLUDE__=\"$(EPOCROOT2)epoc32/include/variant/UIQ_3.0.hrh\"\r
+\r
+GCCDEFINES += -D_UNZIP_SUPPORT -D__BROKEN_FWRITE\r
+\r
+# 'CSL Arm Toolchain' stuff must be specified after Symbian includes\r
+GCCINCLUDES = -I "$(EPOCROOT2)epoc32\include\variant" -I "$(EPOCROOT2)EPOC32\INCLUDE" -I "$(EPOCROOT2)EPOC32\INCLUDE\LIBC" \\r
+               -I "$(EPOCROOT2)\CSL Arm Toolchain\lib\gcc\arm-none-symbianelf\3.4.3\include" -I.\r
+\r
+# -funit-at-a-time is not compatible with SDK, it either has linker problems or does not start on device\r
+GCCCOMMFLAGS = -Wall -Wno-unknown-pragmas -fexceptions -march=armv5t -mapcs -pipe -nostdinc -msoft-float \\r
+               $(GCCINCLUDES) -include "$(EPOCROOT2)EPOC32/INCLUDE/GCCE/GCCE.h" -marm\r
+\r
+GCCCPPFLAGS = -x c++ -Wno-ctor-dtor-privacy -O3 -fno-unit-at-a-time\r
+GCCCFLAGS = -x c -O3 -fno-unit-at-a-time\r
+\r
+GCCLDFLAGS = -L"$(EPOCROOT2)CSL Arm Toolchain\arm-none-symbianelf\lib" \\r
+               -L"$(EPOCROOT2)CSL Arm Toolchain\lib\gcc\arm-none-symbianelf\3.4.3" \\r
+               --target1-abs --no-undefined -nostdlib -shared -Ttext 0x8000 -Tdata 0x400000 --default-symver\r
+\r
+# libs\r
+LIBS = \\r
+       $(EPOCLIB)\LIB\ESTLIB.dso \\r
+       $(EPOCLIB)\urel\qikalloc.lib \\r
+       $(EPOCLIB)\LIB\euser.dso \\r
+       $(EPOCLIB)\LIB\apparc.dso \\r
+       $(EPOCLIB)\LIB\cone.dso \\r
+       $(EPOCLIB)\LIB\eikcore.dso \\r
+       $(EPOCLIB)\LIB\eikcoctl.dso \\r
+       $(EPOCLIB)\LIB\qikcore.dso \\r
+       $(EPOCLIB)\LIB\qikdlg.dso \\r
+       $(EPOCLIB)\LIB\etext.dso \\r
+       $(EPOCLIB)\LIB\bafl.dso \\r
+       $(EPOCLIB)\LIB\efsrv.dso \\r
+       $(EPOCLIB)\LIB\eikctl.dso \\r
+       $(EPOCLIB)\LIB\WS32.dso \\r
+       $(EPOCLIB)\LIB\EIKDLG.dso \\r
+       $(EPOCLIB)\LIB\GDI.dso \\r
+       $(EPOCLIB)\LIB\estor.dso \\r
+       $(EPOCLIB)\LIB\EZLIB.dso \\r
+       $(EPOCLIB)\LIB\HAL.dso \\r
+       $(EPOCLIB)\LIB\mediaclient.dso \\r
+       $(EPOCLIB)\LIB\mediaclientaudiostream.dso\r
+\r
+LIBS += \\r
+       $(EPOCLIB)\LIB\qikallocdll.dso \\r
+       $(EPOCLIB)\UREL\usrt2_2.lib \\r
+       $(EPOCLIB)\LIB\dfpaeabi.dso \\r
+       $(EPOCLIB)\LIB\dfprvct2_2.dso \\r
+       $(EPOCLIB)\LIB\drtaeabi.dso \\r
+       $(EPOCLIB)\LIB\scppnwdl.dso \\r
+       $(EPOCLIB)\LIB\drtrvct2_2.dso\r
+\r
+\r
+# objects\r
+\r
+# launcher\r
+OBJECTS += _build\App.o _build\Engine.o _build\Dialogs.o _build\CSimpleTextParser.o\r
+# engine\r
+OBJECTS += _build\main.o _build\vid.o _build\polledas.o _build\audio_mediaserver.o _build\debug.o\r
+\r
+# Pico\r
+OBJECTS += _build\Area.o _build\Cart.o _build\Utils.o _build\Memory.o _build\Misc.o \\r
+               _build\Pico.o _build\Sek.o _build\VideoPort.o _build\Draw2.o _build\Draw.o\r
+# asm stuff\r
+ifeq "$(asm_render)" "1"\r
+GCCDEFINES += -D_ASM_DRAW_C\r
+OBJECTS += _build\draw_asm.o _build\draw2_asm.o\r
+endif\r
+ifeq "$(asm_memory)" "1"\r
+GCCDEFINES += -D_ASM_MEMORY_C\r
+OBJECTS += _build\memory_asm.o\r
+endif\r
+# Pico - sound\r
+OBJECTS += _build\sound.o _build\sn76496.o _build\ym2612.o\r
+# misc\r
+OBJECTS += _build\unzip.o _build\gzio_symb.o\r
+# CPU cores\r
+ifeq "$(use_musashi)" "1"\r
+GCCDEFINES += -DEMU_M68K\r
+OBJECTS += _build\m68kcpu.o _build\m68kopac.o _build\m68kopdm.o _build\m68kopnz.o _build\m68kops.o\r
+else\r
+GCCDEFINES += -DEMU_C68K\r
+OBJECTS += _build\Cyclone.o\r
+endif\r
+ifeq "$(asm_blit)" "1"\r
+OBJECTS += _build\blit_asm.o\r
+else\r
+OBJECTS += _build\blit.o\r
+endif\r
+GCCDEFINES += -D_USE_DRZ80\r
+OBJECTS += _build\DrZ80.o\r
+GCCDEFINES += -D_ASM_YM2612_C\r
+OBJECTS += _build\ym2612_asm.o\r
+\r
+\r
+\r
+# dprint\r
+ifeq "$(dprint)" "1"\r
+GCCDEFINES += -D__DEBUG_PRINT\r
+endif\r
+\r
+\r
+define crule\r
+       @echo * $<\r
+       @$(CC) -c $(GCCCOMMFLAGS) $(GCCDEFINES) $(GCCCFLAGS) $< -o $@\r
+endef\r
+\r
+define cpprule\r
+       @echo * $<\r
+       @$(CC) -c $(GCCCOMMFLAGS) $(GCCDEFINES) $(GCCCPPFLAGS) $< -o $@\r
+endef\r
+\r
+define asmrule\r
+       @echo * $<\r
+       @$(ASM) -marmv4t -mthumb-interwork -o $@ $^\r
+endef\r
+\r
+# object making rules\r
+_build\App.o     : App.cpp\r
+       $(cpprule)\r
+_build\Engine.o  : Engine.cpp\r
+       $(cpprule)\r
+_build\Dialogs.o : Dialogs.cpp\r
+       $(cpprule)\r
+_build\CSimpleTextParser.o : CSimpleTextParser.cpp\r
+       $(cpprule)\r
+\r
+_build\main.o    : engine\main.cpp\r
+       $(cpprule)\r
+_build\vid.o     : engine\vid.cpp\r
+       $(cpprule)\r
+_build\polledas.o: engine\polledas.cpp\r
+       $(cpprule)\r
+_build\audio_mediaserver.o : engine\audio_mediaserver.cpp\r
+       $(cpprule)\r
+_build\debug.o   : engine\debug.cpp\r
+       $(cpprule)\r
+_build\blit.o    : engine\blit.c\r
+       $(crule)\r
+\r
+_build\Area.o    : ..\..\Pico\Area.c\r
+       $(crule)\r
+_build\Cart.o    : ..\..\Pico\Cart.c\r
+       $(crule)\r
+_build\Draw.o    : ..\..\Pico\Draw.c\r
+       $(crule)\r
+_build\Draw2.o   : ..\..\Pico\Draw2.c\r
+       $(crule)\r
+_build\Memory.o  : ..\..\Pico\Memory.c\r
+       $(crule)\r
+_build\Misc.o    : ..\..\Pico\Misc.c\r
+       $(crule)\r
+_build\Pico.o    : ..\..\Pico\Pico.c\r
+       $(crule)\r
+_build\Sek.o     : ..\..\Pico\Sek.c\r
+       $(crule)\r
+_build\Utils.o   : ..\..\Pico\Utils.c\r
+       $(crule)\r
+_build\VideoPort.o : ..\..\Pico\VideoPort.c\r
+       $(crule)\r
+_build\sound.o   : ..\..\Pico\sound\sound.c\r
+       $(crule)\r
+_build\sn76496.o : ..\..\Pico\sound\sn76496.c\r
+       $(crule)\r
+_build\ym2612.o  : ..\..\Pico\sound\ym2612.c\r
+       $(crule)\r
+\r
+_build\unzip.o     : ..\..\unzip\unzip.c\r
+       $(crule)\r
+_build\gzio_symb.o : ..\..\zlib\gzio_symb.c\r
+       $(crule)\r
+\r
+_build\m68kcpu.o  : ..\..\musashi\m68kcpu.c\r
+       $(crule)\r
+_build\m68kopac.o : ..\..\musashi\m68kopac.c\r
+       $(crule)\r
+_build\m68kopdm.o : ..\..\musashi\m68kopdm.c\r
+       $(crule)\r
+_build\m68kopnz.o : ..\..\musashi\m68kopnz.c\r
+       $(crule)\r
+_build\m68kops.o  : ..\..\musashi\m68kops.c\r
+       $(crule)\r
+\r
+_build\Cyclone.o : ..\..\cpu\Cyclone\proj\Cyclone.s\r
+       $(asmrule)\r
+_build\DrZ80.o : ..\..\cpu\DrZ80\drz80.s\r
+       $(asmrule)\r
+_build\draw_asm.o : ..\..\Pico\draw.s\r
+       $(asmrule)\r
+_build\draw2_asm.o : ..\..\Pico\draw2.s\r
+       $(asmrule)\r
+_build\memory_asm.o : ..\..\Pico\memory.s\r
+       $(asmrule)\r
+_build\ym2612_asm.o : ..\..\Pico\sound\ym2612.s\r
+       $(asmrule)\r
+_build\blit_asm.o : engine\blit.s\r
+       $(asmrule)\r
+\r
+\r
+PicoDrive.exe : $(OBJECTS)\r
+       @echo * ld\r
+       @$(LD) $(GCCLDFLAGS) -soname PicoDrive{000a0000}[a00010f3].exe --entry _E32Startup -u _E32Startup \\r
+               $(EPOCROOT2)EPOC32\RELEASE\ARMV5\UREL\EEXE.LIB -o "_build\PicoDrive_elf.exe" -Map "_build\PicoDrive.exe.map" $(OBJECTS) $(LIBS) -lsupc++ -lgcc\r
+#      @echo * strip\r
+#      @$(STRIP) _build\PicoDrive_elf.exe\r
+       @echo * elf2e32\r
+       @elf2e32 --sid=0xa00010f3  --heap=0x00000100,0x00800000 --stack=0x00003000 \\r
+               --uid1=0x1000007a --uid2=0x100039ce --uid3=0xa00010f3 \\r
+               --capability=none --fpu=softvfp --targettype=EXE --output="$@" \\r
+               --elfinput="_build\PicoDrive_elf.exe" --linkas=PicoDrive{000a0000}[a00010f3].exe --libpath="$(EPOCLIB)\LIB"\r
+ifeq "$(sis)" "1"\r
+       @make -C _out\r
+ifeq "$(up)" "1"\r
+       @qup.cmd\r
+endif\r
+endif\r
+\r
+\r
+MAKEDIRS : _build\r
+\r
+_build :\r
+#      @echo * making build dir\r
+       @perl -S emkdir.pl $@\r
+\r
+\r
+# BitMap PicoDrive.mbm\r
+\r
+RESOURCES : rsc\PicoDrive.mbm rsc\PicoDrive.RSC rsc\PicoDrive_reg.RSC rsc\PicoDrive_loc.RSC rsc\PicoDrive.mbg\r
+\r
+rsc\PicoDrive.mbg : rsc\PicoDrive.mbm\r
+\r
+rsc\PicoDrive.mbm : rsc\pico18x18.bmp rsc\pico18x18m.bmp rsc\pico40x40.bmp rsc\pico40x40m.bmp rsc\pico64x64.bmp rsc\pico64x64m.bmp\r
+       @echo * $@\r
+       @perl -S epocmbm.pl -h"rsc\PicoDrive.mbg" -o"rsc\PicoDrive.mbm" -l"\Z\Resource\Apps\:rsc" \\r
+               -b"/c24rsc\pico18x18.bmp /8rsc\pico18x18m.bmp /c24rsc\pico40x40.bmp /8rsc\pico40x40m.bmp /c24rsc\pico64x64.bmp /8rsc\pico64x64m.bmp" -l"\Z\Resource\Apps\:rsc"\r
+       @perl -S ecopyfile.pl "rsc\PicoDrive.mbg" "$(EPOCROOT2)EPOC32\INCLUDE\PicoDrive.mbg"\r
+\r
+# Resource Z\Resource\Apps\PicoDrive.RSC\r
+\r
+rsc\PicoDrive.RSC : rsc\PicoDrive.rss picodrive.hrh\r
+       @echo * $@\r
+       @perl -S epocrc.pl -m045,046,047 -I "." -I- -I "$(EPOCROOT2_NODRV)EPOC32\include" -DLANGUAGE_SC -u "rsc\PicoDrive.rss" -o$@ \\r
+               -h"rsc\PicoDrive.rsg" -t"rsc" -l"Z\Resource\Apps:rsc"\r
+       @perl -S ecopyfile.pl "rsc\PicoDrive.rsg" "$(EPOCROOT2)EPOC32\INCLUDE\PicoDrive.RSG"\r
+\r
+# Resource Z\private\10003a3f\apps\PicoDrive_reg.RSC\r
+\r
+rsc\PicoDrive_reg.RSC : rsc\PicoDrive_reg.rss\r
+       @echo * $@\r
+       @perl -S epocrc.pl -m045,046,047 -I "." -I- -I "$(EPOCROOT2)EPOC32\include" -DLANGUAGE_SC -u "rsc\PicoDrive_reg.rss" -o$@ \\r
+       -t"rsc" -l"Z\private\10003a3f\apps:rsc"\r
+\r
+# Resource Z\Resource\Apps\PicoDrive_loc.RSC\r
+\r
+rsc\PicoDrive_loc.RSC : rsc\PicoDrive_loc.rss\r
+       @echo * $@\r
+       @perl -S epocrc.pl -m045,046,047 -I "." -I- -I "$(EPOCROOT2)EPOC32\include" -DLANGUAGE_SC -u "rsc\PicoDrive_loc.rss" -o$@ \\r
+               -t"rsc"  -l"Z\Resource\Apps:rsc"\r
diff --git a/platform/uiq3/_out/Makefile b/platform/uiq3/_out/Makefile
deleted file mode 100644 (file)
index 1e17672..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-all: PicoDrive.SIS\r
-\r
-PicoDrive.SIS: ..\PicoDrive.exe ..\rsc\PicoDrive.rsc ..\rsc\PicoDrive.mbm ..\rsc\PicoDrive_loc.rsc ..\rsc\PicoDrive_reg.rsc\r
-       makesis PicoDrive.pkg\r
-\r
-clean:\r
-       @erase 2>>nul PicoDrive.pkg\r
diff --git a/platform/uiq3/_out/PicoDrive.pkg b/platform/uiq3/_out/PicoDrive.pkg
deleted file mode 100644 (file)
index 63412a5..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-; \r
-\r
-; List of localised vendor names - one per language. At least one must be provided (English [EN]). \r
-; List must correspond to list of languages specified elsewhere in the .pkg\r
-%{"notaz"}\r
-\r
-; The non-localised, globally unique vendor name (mandatory)\r
-:"notaz"\r
-\r
-; Package header\r
-; Name, UID3, Major, Minor, Build, Package-type\r
-#{"PicoDrive"}, (0xA00010F3), 0, 96, 0, TYPE=SA\r
-\r
-; ProductID for UIQ 3.0\r
-; Product/platform version UID, Major, Minor, Build, Component name\r
-(0x101F6300), 3, 0, 0, {"UIQ30ProductID"}\r
-\r
-\r
-; Files to install for the application\r
-; If you move the example to another destination then you also need to change these paths.\r
-"..\PicoDrive.exe"-"!:\sys\bin\PicoDrive.exe"\r
-"..\rsc\PicoDrive.rsc"-"!:\resource\apps\PicoDrive.rsc"\r
-"..\rsc\PicoDrive.mbm"-"!:\resource\apps\PicoDrive.mbm"\r
-"..\rsc\PicoDrive_loc.rsc"-"!:\resource\apps\PicoDrive_loc.rsc"\r
-"..\rsc\PicoDrive_reg.rsc"-"!:\private\10003a3f\import\apps\PicoDrive_reg.rsc"\r
diff --git a/platform/uiq3/_out/PicoDrive.zip b/platform/uiq3/_out/PicoDrive.zip
deleted file mode 100644 (file)
index ccb557d..0000000
Binary files a/platform/uiq3/_out/PicoDrive.zip and /dev/null differ
diff --git a/platform/uiq3/_out/PicoDrive_gcce.pkg b/platform/uiq3/_out/PicoDrive_gcce.pkg
deleted file mode 100644 (file)
index 44c88f3..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-; \r
-\r
-; List of localised vendor names - one per language. At least one must be provided (English [EN]). \r
-; List must correspond to list of languages specified elsewhere in the .pkg\r
-%{"notaz"}\r
-\r
-; The non-localised, globally unique vendor name (mandatory)\r
-:"notaz"\r
-\r
-; Package header\r
-; Name, UID3, Major, Minor, Build, Package-type\r
-#{"PicoDrive"}, (0xA00010F3), 0, 92, 0, TYPE=SA\r
-\r
-; ProductID for UIQ 3.0\r
-; Product/platform version UID, Major, Minor, Build, Component name\r
-(0x101F6300), 3, 0, 0, {"UIQ30ProductID"}\r
-\r
-\r
-; Files to install for the application\r
-; If you move the example to another destination then you also need to change these paths.\r
-"..\..\..\..\..\..\UIQ3SDK\epoc32\release\gcce\urel\PicoDrive.exe"-"!:\sys\bin\PicoDrive.exe"\r
-"..\..\..\..\..\..\UIQ3SDK\epoc32\data\Z\Resource\Apps\PicoDrive.rsc"-"!:\resource\apps\PicoDrive.rsc"\r
-"..\..\..\..\..\..\UIQ3SDK\epoc32\data\Z\Resource\Apps\PicoDrive_loc.rsc"-"!:\resource\apps\PicoDrive_loc.rsc"\r
-"..\..\..\..\..\..\UIQ3SDK\epoc32\data\z\Private\10003a3f\Apps\PicoDrive_reg.rsc"-"!:\private\10003a3f\import\apps\PicoDrive_reg.rsc"\r
-"..\..\..\..\..\..\UIQ3SDK\epoc32\data\Z\Resource\Apps\PicoDrive.mbm"-"!:\resource\apps\PicoDrive.mbm"\r
diff --git a/platform/uiq3/emu.c b/platform/uiq3/emu.c
new file mode 100644 (file)
index 0000000..71bf872
--- /dev/null
@@ -0,0 +1,138 @@
+#include <string.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include "../common/emu.h"
+#include "../common/config.h"
+#include "../common/menu.h"
+#include "Pico/PicoInt.h"
+
+const char * const keyNames[] = {
+       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+       NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+};
+
+int emu_getMainDir(char *dst, int len)
+{
+       strcpy(dst, "D:\\other\\PicoDrive\\");
+       return strlen(dst);
+}
+
+void emu_Init(void)
+{
+       int ret;
+
+       // make dirs for saves, cfgs, etc.
+       ret = mkdir("D:\\other\\PicoDrive", 0777);
+       if (ret == 0)
+       {
+               mkdir("D:\\other\\PicoDrive\\mds", 0777);
+               mkdir("D:\\other\\PicoDrive\\srm", 0777);
+               mkdir("D:\\other\\PicoDrive\\brm", 0777);
+       }
+
+       emu_prepareDefaultConfig();
+       config_readlrom("D:\\other\\PicoDrive\\config.cfg");
+       emu_ReadConfig(0, 0);
+       //PicoInit();
+}
+
+void emu_Deinit(void)
+{
+       // saves volume and last ROM
+       emu_WriteConfig(0);
+       //PicoExit();
+}
+
+void menu_romload_prepare(const char *rom_name)
+{
+}
+
+void menu_romload_end(void)
+{
+}
+
+void emu_prepareDefaultConfig(void)
+{
+       memset(&defaultConfig, 0, sizeof(defaultConfig));
+       defaultConfig.EmuOpt    = 0x1d | 0x680; // | confirm_save, cd_leds, 16bit rend
+       defaultConfig.s_PicoOpt = 0x0f | POPT_EN_MCD_PCM|POPT_EN_MCD_CDDA|POPT_EN_SVP_DRC|POPT_ACC_SPRITES;
+       defaultConfig.s_PsndRate = 22050;
+       defaultConfig.s_PicoRegion = 0; // auto
+       defaultConfig.s_PicoAutoRgnOrder = 0x184; // US, EU, JP
+       defaultConfig.s_PicoCDBuffers = 0;
+       defaultConfig.Frameskip = -1; // auto
+       defaultConfig.volume = 80;
+       defaultConfig.scaling = 0;
+}
+
+/* used by config engine only, not actual menus */
+menu_entry opt_entries[] =
+{
+       { NULL,                        MB_NONE,  MA_OPT_RENDERER,      NULL, 0, 0, 0, 1, 1 },
+       { "Scaling",                   MB_RANGE, MA_OPT_SCALING,       &currentConfig.scaling,     0, 0, 2, 1, 1 },
+       { "Rotation",                  MB_RANGE, MA_OPT_ROTATION,      &currentConfig.rotation,    0, 0, 3, 1, 1 },
+       { "Accurate sprites",          MB_ONOFF, MA_OPT_ACC_SPRITES,   &PicoOpt, 0x080, 0, 0, 0, 1 },
+       { "Show FPS",                  MB_ONOFF, MA_OPT_SHOW_FPS,      &currentConfig.EmuOpt,  0x002, 0, 0, 1, 1 },
+       { NULL,                        MB_RANGE, MA_OPT_FRAMESKIP,     &currentConfig.Frameskip, 0, -1, 16, 1, 1 },
+       { "Enable sound",              MB_ONOFF, MA_OPT_ENABLE_SOUND,  &currentConfig.EmuOpt,  0x004, 0, 0, 1, 1 },
+       { NULL,                        MB_NONE,  MA_OPT_SOUND_QUALITY, NULL, 0, 0, 0, 1, 1 },
+       { NULL,                        MB_NONE,  MA_OPT_REGION,        NULL, 0, 0, 0, 1, 1 },
+       { "Use SRAM/BRAM savestates",  MB_ONOFF, MA_OPT_SRAM_STATES,   &currentConfig.EmuOpt,  0x001, 0, 0, 1, 1 },
+};
+
+#define OPT_ENTRY_COUNT (sizeof(opt_entries) / sizeof(opt_entries[0]))
+const int opt_entry_count = OPT_ENTRY_COUNT;
+
+menu_entry opt2_entries[] =
+{
+       { "Disable sprite limit",      MB_ONOFF, MA_OPT2_NO_SPRITE_LIM, &PicoOpt, 0x40000, 0, 0, 1, 1 },
+       { "Emulate Z80",               MB_ONOFF, MA_OPT2_ENABLE_Z80,    &PicoOpt, 0x00004, 0, 0, 1, 1 },
+       { "Emulate YM2612 (FM)",       MB_ONOFF, MA_OPT2_ENABLE_YM2612, &PicoOpt, 0x00001, 0, 0, 1, 1 },
+       { "Emulate SN76496 (PSG)",     MB_ONOFF, MA_OPT2_ENABLE_SN76496,&PicoOpt, 0x00002, 0, 0, 1, 1 },
+       { "gzip savestates",           MB_ONOFF, MA_OPT2_GZIP_STATES,   &currentConfig.EmuOpt, 0x0008, 0, 0, 1, 1 },
+       { "SVP dynarec",               MB_ONOFF, MA_OPT2_SVP_DYNAREC,   &PicoOpt, 0x20000, 0, 0, 1, 1 },
+       { "Disable idle loop patching",MB_ONOFF, MA_OPT2_NO_IDLE_LOOPS, &PicoOpt, 0x80000, 0, 0, 1, 1 },
+};
+
+#define OPT2_ENTRY_COUNT (sizeof(opt2_entries) / sizeof(opt2_entries[0]))
+const int opt2_entry_count = OPT2_ENTRY_COUNT;
+
+menu_entry cdopt_entries[] =
+{
+       { "CD LEDs",                   MB_ONOFF, MA_CDOPT_LEDS,         &currentConfig.EmuOpt, 0x0400, 0, 0, 1, 1 },
+       { "CDDA audio (using mp3s)",   MB_ONOFF, MA_CDOPT_CDDA,         &PicoOpt, 0x0800, 0, 0, 1, 1 },
+       { "PCM audio",                 MB_ONOFF, MA_CDOPT_PCM,          &PicoOpt, 0x0400, 0, 0, 1, 1 },
+       { NULL,                        MB_NONE,  MA_CDOPT_READAHEAD,    NULL, 0, 0, 0, 1, 1 },
+       { "SaveRAM cart",              MB_ONOFF, MA_CDOPT_SAVERAM,      &PicoOpt, 0x8000, 0, 0, 1, 1 },
+       { "Scale/Rot. fx (slow)",      MB_ONOFF, MA_CDOPT_SCALEROT_CHIP,&PicoOpt, 0x1000, 0, 0, 1, 1 },
+       { "Better sync (slow)",        MB_ONOFF, MA_CDOPT_BETTER_SYNC,  &PicoOpt, 0x2000, 0, 0, 1, 1 },
+};
+
+#define CDOPT_ENTRY_COUNT (sizeof(cdopt_entries) / sizeof(cdopt_entries[0]))
+const int cdopt_entry_count = CDOPT_ENTRY_COUNT;
+
+menu_entry ctrlopt_entries[] =
+{
+       { "6 button pad",              MB_ONOFF, MA_OPT_6BUTTON_PAD,   &PicoOpt, 0x020, 0, 0, 1, 1 },
+       { "Turbo rate",                MB_RANGE, MA_CTRL_TURBO_RATE,   &currentConfig.turbo_rate, 0, 1, 30, 1, 1 },
+};
+
+#define CTRLOPT_ENTRY_COUNT (sizeof(ctrlopt_entries) / sizeof(ctrlopt_entries[0]))
+const int ctrlopt_entry_count = CTRLOPT_ENTRY_COUNT;
+
+me_bind_action emuctrl_actions[] =
+{
+       { "Load State     ", 1<<28 },
+       { "Save State     ", 1<<27 },
+       { "Pause Emu      ", 1<<26 },
+       { "Switch Renderer", 1<<25 },
+       { "Prev save slot ", 1<<23 },
+       { "Next save slot ", 1<<22 },
+       { "Volume down    ", 1<<21 },
+       { "Volume up      ", 1<<20 },
+       { NULL,              0     }
+};
+
+
diff --git a/platform/uiq3/emu.h b/platform/uiq3/emu.h
new file mode 100644 (file)
index 0000000..c5710f2
--- /dev/null
@@ -0,0 +1,11 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void emu_Init(void);
+void emu_Deinit(void);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
index aff12d1..c9788d3 100644 (file)
@@ -15,6 +15,7 @@
 #include "audio_mediaserver.h"\r
 #include "debug.h"\r
 \r
+//#define DEBUG_UNDERFLOWS\r
 //#undef DEBUGPRINT\r
 //#define DEBUGPRINT(x...)\r
 \r
@@ -31,16 +32,16 @@ const TInt KMaxUnderflows = 50; // max underflows/API errors we are going allow
  *\r
  *******************************************/\r
 \r
-CGameAudioMS::CGameAudioMS(TInt aRate, TBool aStereo, TInt aWritesPerSec)\r
-: iRate(aRate), iStereo(aStereo), iWritesPerSec(aWritesPerSec)\r
+CGameAudioMS::CGameAudioMS(TInt aRate, TBool aStereo, TInt aWritesPerSec, TInt aVolume)\r
+: iRate(aRate), iStereo(aStereo), iWritesPerSec(aWritesPerSec), iVolume(aVolume)\r
 {\r
 }\r
 \r
 \r
-CGameAudioMS* CGameAudioMS::NewL(TInt aRate, TBool aStereo, TInt aWritesPerSec)\r
+CGameAudioMS* CGameAudioMS::NewL(TInt aRate, TBool aStereo, TInt aWritesPerSec, TInt aVolume)\r
 {\r
-       DEBUGPRINT(_L("CGameAudioMS::NewL(%i, %i, %i)"), aRate, aStereo, aWritesPerSec);\r
-       CGameAudioMS*           self = new(ELeave) CGameAudioMS(aRate, aStereo, aWritesPerSec);\r
+       DEBUGPRINT(_L("CGameAudioMS::NewL(%i, %i, %i, %i)"), aRate, aStereo, aWritesPerSec, aVolume);\r
+       CGameAudioMS*           self = new(ELeave) CGameAudioMS(aRate, aStereo, aWritesPerSec, aVolume);\r
        CleanupStack::PushL(self);\r
        self->ConstructL();\r
        CleanupStack::Pop();            // self\r
@@ -85,25 +86,29 @@ void CGameAudioMS::ConstructL()
        iMdaAudioDataSettings.iCaps       = TMdaAudioDataSettings::ESampleRateFixed | iMdaAudioDataSettings.iSampleRate;\r
        iMdaAudioDataSettings.iFlags      = TMdaAudioDataSettings::ENoNetworkRouting;\r
 \r
-       int pcmFrames = iRate / iWritesPerSec;\r
-       pcmFrames += iRate - (iRate / iWritesPerSec) * iWritesPerSec; // add division remainder too for our buffer size\r
-       iBufferedFrames = iWritesPerSec / KUpdatesPerSec;\r
+       iMaxWriteSamples = iRate / iWritesPerSec;\r
+       if (iRate % iWritesPerSec)\r
+               iMaxWriteSamples++;\r
+       int bufferedFrames = iWritesPerSec / KUpdatesPerSec;\r
 \r
-       TInt bytesPerFrame = pcmFrames << (iStereo?2:1);\r
+       iBufferSize = iMaxWriteSamples * (iStereo ? 4 : 2);\r
+       iBufferSize *= bufferedFrames;\r
        for (TInt i=0 ; i<KSoundBuffers ; i++)\r
        {\r
-               iSoundBuffers[i] = HBufC8::NewL(bytesPerFrame * iBufferedFrames);\r
-               iSoundBuffers[i]->Des().FillZ  (bytesPerFrame * iBufferedFrames);\r
+               iSoundBuffers[i] = HBufC8::NewL(iBufferSize);\r
+               iSoundBuffers[i]->Des().FillZ  (iBufferSize);\r
        }\r
 \r
        iCurrentBuffer = 0;\r
        iCurrentBufferSize = 0;\r
 \r
+       DEBUGPRINT(_L("sound: iMaxWriteSamples: %i, iBufferSize: %i"), iMaxWriteSamples, iBufferSize);\r
+\r
        // here we actually test if we can create and open CMdaAudioOutputStream at all, but really create and use it later.\r
        iMdaAudioOutputStream = CMdaAudioOutputStream::NewL(iListener, iServer);\r
-       if(iMdaAudioOutputStream) {\r
-               iVolume = iMdaAudioOutputStream->MaxVolume();\r
-               DEBUGPRINT(_L("MaxVolume: %i"), iVolume);\r
+       if (iMdaAudioOutputStream) {\r
+               if (iVolume < 0 || iVolume > iMdaAudioOutputStream->MaxVolume())\r
+                       iVolume = iMdaAudioOutputStream->MaxVolume();\r
                delete iMdaAudioOutputStream;\r
                iMdaAudioOutputStream = 0;\r
        }\r
@@ -113,11 +118,18 @@ void CGameAudioMS::ConstructL()
 // to be used when iSoundBuffers are used directly\r
 TInt16 *CGameAudioMS::NextFrameL(TInt aPcmFrames)\r
 {\r
-       iCurrentPosition   += aPcmFrames << (iStereo?1:0);\r
-       iCurrentBufferSize += aPcmFrames << (iStereo?2:1);\r
+       TInt mul = iStereo ? 4 : 2;\r
+       TInt bytes = aPcmFrames * mul;\r
+       iCurrentPosition   += bytes / 2;\r
+       iCurrentBufferSize += bytes;\r
 \r
-       if (++iFrameCount == iBufferedFrames)\r
+       if (aPcmFrames > iMaxWriteSamples) {\r
+               DEBUGPRINT(_L("too many samples: %i > %i"), aPcmFrames, iMaxWriteSamples);\r
+       }\r
+\r
+       if (iCurrentBufferSize + iMaxWriteSamples * mul > iBufferSize)\r
        {\r
+               //DEBUGPRINT(_L("write on iCurrentBufferSize %i"), iCurrentBufferSize);\r
                WriteBlockL();\r
        }\r
 \r
@@ -162,9 +174,9 @@ void CGameAudioMS::WriteBlockL()
                }\r
        }\r
 \r
-       iFrameCount = 0;\r
        if (++iCurrentBuffer == KSoundBuffers)\r
                iCurrentBuffer = 0;\r
+       iSoundBuffers[iCurrentBuffer]->Des().SetMax();\r
        iCurrentPosition = (TInt16*) iSoundBuffers[iCurrentBuffer]->Ptr();\r
        iCurrentBufferSize = 0;\r
 }\r
@@ -189,7 +201,6 @@ TInt16 *CGameAudioMS::ResumeL()
        iListener.iIsOpen = ETrue;\r
        iListener.iUnderflowed = 1;\r
        iListener.iLastError = 0;\r
-       iFrameCount = 0;\r
        iCurrentBufferSize = 0;\r
        iCurrentPosition = (TInt16*) iSoundBuffers[iCurrentBuffer]->Ptr();\r
        return iCurrentPosition;\r
@@ -198,7 +209,9 @@ TInt16 *CGameAudioMS::ResumeL()
 // handles underflow condition\r
 void CGameAudioMS::UnderflowedL()\r
 {\r
+#ifdef DEBUG_UNDERFLOWS\r
        DEBUGPRINT(_L("UnderflowedL()"));\r
+#endif\r
 \r
        if (iListener.iLastError != KErrUnderflow)\r
        {\r
@@ -243,23 +256,30 @@ void CGameAudioMS::WaitForOpenToCompleteL()
                User::LeaveIfError(KErrNotSupported);\r
 }\r
 \r
-void CGameAudioMS::ChangeVolume(TInt aUp)\r
+TInt CGameAudioMS::ChangeVolume(TInt aUp)\r
 {\r
        //DEBUGPRINT(_L("CGameAudioMS::ChangeVolume(%i)"), aUp);\r
 \r
        if (iMdaAudioOutputStream) {\r
                if (aUp) {\r
-                       if (iVolume < iMdaAudioOutputStream->MaxVolume()) iVolume+=5;\r
+                       iVolume += 5;\r
+                       if (iVolume > iMdaAudioOutputStream->MaxVolume())\r
+                               iVolume = iMdaAudioOutputStream->MaxVolume();\r
                } else {\r
-                       if (iVolume > 0) iVolume-=5;\r
+                       iVolume -= 5;\r
+                       if (iVolume < 0) iVolume = 0;\r
                }\r
                iMdaAudioOutputStream->SetVolume(iVolume);\r
        }\r
+\r
+       return iVolume;\r
 }\r
 \r
 void TGameAudioEventListener::MaoscOpenComplete(TInt aError)\r
 {\r
+#ifdef DEBUG_UNDERFLOWS\r
        DEBUGPRINT(_L("CGameAudioMS::MaoscOpenComplete, error=%d"), aError);\r
+#endif\r
 \r
        iIsOpen = ETrue;\r
        if(aError) {\r
@@ -284,7 +304,9 @@ void TGameAudioEventListener::MaoscBufferCopied(TInt aError, const TDesC8& aBuff
 \r
 void TGameAudioEventListener::MaoscPlayComplete(TInt aError)\r
 {\r
+#ifdef DEBUG_UNDERFLOWS\r
        DEBUGPRINT(_L("CGameAudioMS::MaoscPlayComplete: %i"), aError);\r
+#endif\r
        if(aError) {\r
                iLastError = aError;\r
                iUnderflowed++; // never happened to me while testing, but just in case\r
index 25d1027..fc94f7c 100644 (file)
 #ifndef __AUDIO_MEDIASERVER_H\r
 #define __AUDIO_MEDIASERVER_H\r
 \r
-#include <Mda\Common\Audio.h>\r
-#include <MdaAudioOutputStream.h>\r
+#include <mda/common/audio.h>\r
+#include <mdaaudiooutputstream.h>\r
 \r
 //#include "audio.h"\r
-#include "polledas.h"\r
+#include "PolledAS.h"\r
 \r
 const TInt KSoundBuffers = 4;\r
 \r
@@ -44,12 +44,12 @@ public:     // implements IGameAudio
        TInt16 *NextFrameL(TInt aPcmFrames);\r
        TInt16 *ResumeL();\r
        void Pause();\r
-       void ChangeVolume(TInt aUp);\r
+       TInt ChangeVolume(TInt aUp);\r
 \r
 public:\r
        ~CGameAudioMS();\r
-       CGameAudioMS(TInt aRate, TBool aStereo, TInt aWritesPerSec);\r
-       static CGameAudioMS* NewL(TInt aRate, TBool aStereo, TInt aWritesPerSec);\r
+       CGameAudioMS(TInt aRate, TBool aStereo, TInt aWritesPerSec, TInt aVolume);\r
+       static CGameAudioMS* NewL(TInt aRate, TBool aStereo, TInt aWritesPerSec, TInt aVolume);\r
 \r
 protected:\r
        void WriteBlockL();\r
@@ -70,12 +70,12 @@ protected:
        CPolledActiveScheduler  *iScheduler;\r
 \r
        HBufC8*                                 iSoundBuffers[KSoundBuffers];\r
-       TInt                                    iWritesPerSec;\r
-       TInt                                    iBufferedFrames;\r
+       TInt                                    iWritesPerSec;                  // fps, may be more actual writes\r
+       TInt                                    iMaxWriteSamples;               // max samples per write\r
        TInt16*                                 iCurrentPosition;\r
-       TInt                                    iCurrentBuffer;\r
-       TInt                                    iCurrentBufferSize;\r
-       TInt                                    iFrameCount;\r
+       TInt                                    iCurrentBuffer;                 // active buffer\r
+       TInt                                    iCurrentBufferSize;             // bytes filled in buffer\r
+       TInt                                    iBufferSize;\r
        CMdaServer*                             iServer;\r
 \r
        TInt64                                  iTime;\r
index 521c31a..c377a76 100644 (file)
@@ -1,3 +1,4 @@
+@ vim:filetype=armasm\r
 @ some color conversion and blitting routines\r
 \r
 @ (c) Copyright 2006, notaz\r
@@ -693,3 +694,13 @@ vidClear:
     orr     r12, #(240/16-1)<<16\r
     b       .loopVidClear\r
 \r
+@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r
+\r
+.equ EExecSetExceptionHandler, (90)\r
+\r
+.global my_SetExceptionHandler\r
+\r
+my_SetExceptionHandler:\r
+    mov     ip, lr\r
+    swi     EExecSetExceptionHandler\r
+\r
index c532187..81edbc5 100644 (file)
@@ -2,6 +2,9 @@
 #include <e32svr.h> // RDebug\r
 #include "debug.h"\r
 \r
+//#define LOG_FILE "C:\\logs\\pico.log"\r
+#define LOG_FILE _L("D:\\pico.log")\r
+\r
 #ifdef __WINS__\r
 \r
 void ExceptionHandler(TExcType exc) {}\r
@@ -40,6 +43,7 @@ static const wchar_t * const exception_names[] = {
 };\r
 \r
 \r
+#if 0\r
 static void getASpace(TUint *code_start, TUint *code_end, TUint *stack_start, TUint *stack_end)\r
 {\r
        TUint pc, sp;\r
@@ -63,22 +67,24 @@ static void getASpace(TUint *code_start, TUint *code_end, TUint *stack_start, TU
                chunk.Close();\r
        }\r
 }\r
+#endif\r
 \r
 // tmp\r
 #if defined(__DEBUG_PRINT)\r
-extern "C" char *debugString();\r
+extern "C" char *PDebugMain();\r
 #endif\r
 \r
 // our very own exception handler\r
 void ExceptionHandler(TExcType exc)\r
 {\r
+       DEBUGPRINT(_L("ExceptionHandler() called!!!")); // this seems to never be called\r
+\r
+#if 0\r
        TUint lr, sp, i;\r
        TUint stack_end = 0;                            // ending address of our stack chunk\r
        TUint code_start = 0, code_end = 0; // starting and ending addresses of our code chunk\r
        TUint guessed_address = 0;\r
 \r
-       DEBUGPRINT(_L("ExceptionHandler()")); // this seems to never be called\r
-\r
        asm volatile ("str lr, %0" : "=m" (lr) );\r
        asm volatile ("str sp, %0" : "=m" (sp) );\r
 \r
@@ -136,11 +142,11 @@ void ExceptionHandler(TExcType exc)
 \r
        // tmp\r
 #if defined(__DEBUG_PRINT)\r
-       char *ps, *cstr = debugString();\r
+       char *ps, *cstr = PDebugMain();\r
        for(ps = cstr; *ps; ps++) {\r
          if(*ps == '\n') {\r
            *ps = 0;\r
-           dprintf(cstr);\r
+           lprintf(cstr);\r
                cstr = ps+1;\r
          }\r
        }\r
@@ -154,42 +160,47 @@ void ExceptionHandler(TExcType exc)
        // more descriptive replacement of "KERN-EXEC 3" panic\r
        buff1.Format(_L("K-EX3: %S"), &ptrExc);\r
        User::Panic(buff1, exc);\r
+#endif\r
 }\r
 \r
 #endif // ifdef __WINS__\r
 \r
 \r
-#if defined(__DEBUG_PRINT) || defined(__WINS__)\r
-\r
-#ifndef __DLL__\r
-       // c string dumper for RDebug::Print()\r
-       static  TBuf<1024> sTextBuffer;\r
-       TDesC* DO_CONV(const char* s)\r
-       {\r
-               TPtrC8  text8((TUint8*) (s));\r
-               sTextBuffer.Copy(text8);\r
-               return &sTextBuffer;\r
-       }\r
-#endif\r
-\r
-#ifdef __DEBUG_PRINT_C\r
+#if 1 // def __DEBUG_PRINT_C\r
        #include <stdarg.h> // va_*\r
        #include <stdio.h>  // vsprintf\r
 \r
        // debug print from c code\r
-       extern "C" void dprintf(char *format, ...)\r
+       extern "C" void lprintf(char *format, ...)\r
        {\r
                va_list args;\r
                char    buffer[512];\r
+               int len;\r
 \r
                va_start(args,format);\r
-               vsprintf(buffer,format,args);\r
+               len = vsprintf(buffer,format,args);\r
                va_end(args);\r
+               if (buffer[len-1] == '\n')\r
+                       buffer[len-1] = 0;\r
 \r
                DEBUGPRINT(_L("%S"), DO_CONV(buffer));\r
        }\r
 #endif\r
 \r
+\r
+#if defined(__DEBUG_PRINT) || defined(__WINS__)\r
+\r
+#ifndef __DLL__\r
+       // c string dumper for RDebug::Print()\r
+       static  TBuf<1024> sTextBuffer;\r
+       TDesC* DO_CONV(const char* s)\r
+       {\r
+               TPtrC8  text8((TUint8*) (s));\r
+               sTextBuffer.Copy(text8);\r
+               return &sTextBuffer;\r
+       }\r
+#endif\r
+\r
 #ifdef __DEBUG_PRINT_FILE\r
        #include <f32file.h>\r
 \r
@@ -201,12 +212,12 @@ void ExceptionHandler(TExcType exc)
        {\r
                // try to open\r
                logMutex.CreateLocal();\r
-               RFs fserv;\r
+               /*RFs fserv;\r
                fserv.Connect();\r
                RFile logFile;\r
-               logFile.Replace(fserv, _L("C:\\logs\\pico.log"), EFileWrite|EFileShareAny);\r
+               logFile.Replace(fserv, LOG_FILE, EFileWrite|EFileShareAny);\r
                logFile.Close();\r
-               fserv.Close();\r
+               fserv.Close();*/\r
        }\r
 \r
        // debug print to file\r
@@ -225,7 +236,7 @@ void ExceptionHandler(TExcType exc)
 \r
                RThread thisThread;\r
                RFile logFile;\r
-               res = logFile.Open(fserv, _L("C:\\logs\\pico.log"), EFileWrite|EFileShareAny);\r
+               res = logFile.Open(fserv, LOG_FILE, EFileWrite|EFileShareAny);\r
                if(res) goto fail1;\r
 \r
                logFile.Size(size); logFile.Seek(ESeekStart, size);\r
index bcd8287..8f7bebf 100644 (file)
@@ -16,7 +16,7 @@
                #ifdef __cplusplus\r
                extern "C"\r
                #endif\r
-               void dprintf(char *format, ...);\r
+               void lprintf(char *format, ...);\r
        #endif\r
 #else\r
        #define DEBUGPRINT(x...)\r
index 93ef047..03c3e4f 100644 (file)
 #include "debug.h"\r
 #include "../Engine.h"\r
 \r
-#include "../../../pico/picoInt.h"\r
+#include <Pico/PicoInt.h>\r
+#include "../../common/emu.h"\r
+#include "../emu.h"\r
 #include "vid.h"\r
-#include "polledAS.h"\r
+#include "PolledAS.h"\r
 //#include "audio.h"\r
 #include "audio_mediaserver.h"\r
 \r
-#include <EZlib.h>\r
-#include "../../../zlib/gzio_symb.h"\r
+//#include <ezlib.h>\r
+#include <zlib/zlib.h>\r
 \r
 \r
 //#define BENCHMARK\r
@@ -78,21 +80,20 @@ const char *actionNames[] = {
 // globals are allowed, so why not to (ab)use them?\r
 //TInt machineUid = 0;\r
 int gamestate = PGS_Paused, gamestate_next = PGS_Paused;\r
-TPicoConfig *currentConfig = 0;\r
-static char noticeMsg[64];                                     // notice msg to draw\r
+char *loadrom_fname = NULL;\r
+int   loadrom_result = 0;\r
 static timeval noticeMsgTime = { 0, 0 };       // when started showing\r
 static CGameAudioMS *gameAudio = 0;                    // the audio object itself\r
-static int reset_timing, pico_was_reset;\r
-static int state_slot = 0;\r
-extern const char *RomFileName;\r
+static int reset_timing;\r
+extern int pico_was_reset;\r
 extern RSemaphore initSemaphore;\r
 extern RSemaphore pauseSemaphore;\r
+extern RSemaphore loadWaitSemaphore;\r
 \r
 // some forward declarations\r
 static void MainInit();\r
 static void MainExit();\r
 static void DumpMemInfo();\r
-void MainOldCleanup();\r
 \r
 \r
 class TPicoDirectScreenAccess : public MDirectScreenAccess\r
@@ -128,24 +129,8 @@ public:
 };\r
 \r
 \r
-static int snd_excess_add = 0, snd_excess_cnt = 0; // hack\r
-\r
-static void updateSound(void)\r
+static void updateSound(int len)\r
 {\r
-       int len = PsndLen;\r
-\r
-       snd_excess_cnt += snd_excess_add;\r
-       if (snd_excess_cnt >= 0x10000) {\r
-               snd_excess_cnt -= 0x10000;\r
-               if (PicoOpt&8) {\r
-                       PsndOut[len*2]   = PsndOut[len*2-2];\r
-                       PsndOut[len*2+1] = PsndOut[len*2-1];\r
-               } else {\r
-                       PsndOut[len]   = PsndOut[len-1];\r
-               }\r
-               len++;\r
-       }\r
-\r
        PsndOut = gameAudio->NextFrameL(len);\r
        if(!PsndOut) { // sound output problems?\r
                strcpy(noticeMsg, "SOUND@OUTPUT@ERROR;@SOUND@DISABLED");\r
@@ -190,12 +175,16 @@ static void TargetEpocGameL()
        MainInit();\r
        buff[0] = 0;\r
 \r
+       PicoInit();\r
+\r
        // just to keep the backlight on (works only on UIQ2)\r
        //blevent.Set(TRawEvent::EActive);\r
 \r
        // loop?\r
-       for(;;) {\r
-               if(gamestate == PGS_Running) {\r
+       for(;;)\r
+       {\r
+               if (gamestate == PGS_Running)\r
+               {\r
                        // switch context to other thread\r
                        User::After(50000);\r
                        // prepare window and stuff\r
@@ -217,15 +206,14 @@ static void TargetEpocGameL()
                        if(!noticeMsgTime.tv_sec && pico_was_reset)\r
                                gettimeofday(&noticeMsgTime, 0);\r
 \r
-                       if (PsndOut) {\r
-                               snd_excess_cnt = 0;\r
-                               snd_excess_add = ((PsndRate - PsndLen*target_fps)<<16) / target_fps;\r
-                       }\r
+                       // prepare CD buffer\r
+                       if (PicoAHW & PAHW_MCD) PicoCDBufferInit();\r
 \r
                        pico_was_reset = 0;\r
                        reset_timing = 1;\r
 \r
-                       while(gamestate == PGS_Running) {\r
+                       while (gamestate == PGS_Running)\r
+                       {\r
                                gettimeofday(&tval, 0);\r
                                if(reset_timing) {\r
                                        reset_timing = 0;\r
@@ -242,7 +230,8 @@ static void TargetEpocGameL()
                                }\r
 \r
                                // second changed?\r
-                               if(thissec != tval.tv_sec) {\r
+                               if (thissec != tval.tv_sec)\r
+                               {\r
 #ifdef BENCHMARK\r
                                        static int bench = 0, bench_fps = 0, bench_fps_s = 0, bfp = 0, bf[4];\r
                                        if(++bench == 10) {\r
@@ -254,14 +243,14 @@ static void TargetEpocGameL()
                                        bench_fps += frames_shown;\r
                                        sprintf(buff, "%02i/%02i/%02i", frames_shown, bench_fps_s, (bf[0]+bf[1]+bf[2]+bf[3])>>2);\r
 #else\r
-                                       if(currentConfig->iFlags & 2\r
+                                       if (currentConfig.EmuOpt & EOPT_SHOW_FPS\r
                                                sprintf(buff, "%02i/%02i", frames_shown, frames_done);\r
 #endif\r
 \r
 \r
                                        thissec = tval.tv_sec;\r
 \r
-                                       if(PsndOut == 0 && currentConfig->iFrameskip >= 0) {\r
+                                       if(PsndOut == 0 && currentConfig.Frameskip >= 0) {\r
                                                frames_done = frames_shown = 0;\r
                                        } else {\r
                                                // it is quite common for this implementation to leave 1 fame unfinished\r
@@ -278,8 +267,10 @@ static void TargetEpocGameL()
 \r
 \r
                                lim_time = (frames_done+1) * target_frametime;\r
-                               if(currentConfig->iFrameskip >= 0) { // frameskip enabled\r
-                                       for(i = 0; i < currentConfig->iFrameskip; i++) {\r
+                               if (currentConfig.Frameskip >= 0) // frameskip enabled\r
+                               {\r
+                                       for (i = 0; i < currentConfig.Frameskip && gamestate == PGS_Running; i++)\r
+                                       {\r
                                                CGameWindow::DoKeys();\r
                                                SkipFrame(); frames_done++;\r
                                                if (PsndOut) { // do framelimitting if sound is enabled\r
@@ -291,13 +282,17 @@ static void TargetEpocGameL()
                                                }\r
                                                lim_time += target_frametime;\r
                                        }\r
-                               } else if(tval.tv_usec > lim_time) { // auto frameskip\r
+                               }\r
+                               else if(tval.tv_usec > lim_time) { // auto frameskip\r
                                        // no time left for this frame - skip\r
                                        CGameWindow::DoKeys();\r
                                        SkipFrame(); frames_done++;\r
                                        continue;\r
                                }\r
 \r
+                               // we might have lost focus already\r
+                               if (gamestate != PGS_Running) break;\r
+\r
                                CGameWindow::DoKeys();\r
                                PicoFrame();\r
 \r
@@ -306,7 +301,7 @@ static void TargetEpocGameL()
                                if(thissec != tval.tv_sec) tval.tv_usec+=1000000;\r
 \r
                                // sleep if we are still too fast\r
-                               if(PsndOut != 0 || currentConfig->iFrameskip < 0)\r
+                               if(PsndOut != 0 || currentConfig.Frameskip < 0)\r
                                {\r
                                        // TODO: check if User::After() is accurate\r
                                        gettimeofday(&tval, 0);\r
@@ -324,18 +319,36 @@ static void TargetEpocGameL()
                                        vidDrawFrame(notice, buff, frames_shown);\r
 \r
                                frames_done++; frames_shown++;\r
-                       }\r
+                       } // while\r
+\r
+                       if (PicoAHW & PAHW_MCD) PicoCDBufferFree();\r
 \r
                        // save SRAM\r
-                       if((currentConfig->iFlags & 1) && SRam.changed) {\r
-                               saveLoadGame(0, 1);\r
+                       if ((currentConfig.EmuOpt & EOPT_USE_SRAM) && SRam.changed) {\r
+                               emu_SaveLoadGame(0, 1);\r
                                SRam.changed = 0;\r
                        }\r
+                       CPolledActiveScheduler::Instance()->Schedule();\r
                        CGameWindow::FreeResources();\r
-               } else if(gamestate == PGS_Paused) {\r
+               }\r
+               else if(gamestate == PGS_ReloadRom)\r
+               {\r
+                       loadrom_result = emu_ReloadRom(loadrom_fname);\r
+                       pico_was_reset = 1;\r
+                       if (loadrom_result)\r
+                               gamestate = PGS_Running;\r
+                       else\r
+                               gamestate = PGS_Paused;\r
+                       DEBUGPRINT(_L("done loading ROM, retval=%i"), loadrom_result);\r
+                       loadWaitSemaphore.Signal();\r
+                       User::After(50000);\r
+               }\r
+               else if(gamestate == PGS_Paused) {\r
                        DEBUGPRINT(_L("pausing.."));\r
                        pauseSemaphore.Wait();\r
-               } else if(gamestate == PGS_KeyConfig) {\r
+               }\r
+               else if(gamestate == PGS_KeyConfig)\r
+               {\r
                        // switch context to other thread\r
                        User::After(50000);\r
                        // prepare window and stuff\r
@@ -364,6 +377,10 @@ static void TargetEpocGameL()
                }\r
        }\r
 \r
+       // this thread has to close it's own handles,\r
+       // other one will crash trying to do that\r
+       PicoExit();\r
+\r
        MainExit();\r
 }\r
 \r
@@ -373,9 +390,6 @@ static void MainInit()
 {\r
        DEBUGPRINT(_L("\r\n\r\nstarting.."));\r
 \r
-       // our thread might have been crashed previously, so many other objects may be still floating around\r
-       MainOldCleanup();\r
-\r
        DEBUGPRINT(_L("CPolledActiveScheduler::NewL()"));\r
        CPolledActiveScheduler::NewL(); // create Polled AS for the sound engine\r
 \r
@@ -384,8 +398,7 @@ static void MainInit()
        DumpMemInfo();\r
 \r
        // try to start pico\r
-       DEBUGPRINT(_L("PicoInit();"));\r
-       PicoInit();\r
+       DEBUGPRINT(_L("PicoInit()"));\r
        PicoDrawSetColorFormat(2);\r
        PicoWriteSound = updateSound;\r
 \r
@@ -403,13 +416,6 @@ static void MainExit()
 \r
        DEBUGPRINT(_L("%i: cleaning up.."), (TInt32) thisThread.Id());\r
 \r
-       // save SRAM\r
-       if((currentConfig->iFlags & 1) && SRam.changed) {\r
-               saveLoadGame(0, 1);\r
-               SRam.changed = 0;\r
-       }\r
-\r
-       PicoExit();\r
 //     pauseSemaphore.Close();\r
 \r
        if(gameAudio) delete gameAudio;\r
@@ -418,20 +424,6 @@ static void MainExit()
        delete CPolledActiveScheduler::Instance();\r
 }\r
 \r
-void MainOldCleanup()\r
-{\r
-       DEBUGPRINT(_L("MainOldCleanup.."));\r
-\r
-       // There was previously a handle leak here, so thread stuff was not cleaned\r
-       // and I thought I would have to do it mself.\r
-\r
-       // clean any resources which might be left after a thread crash\r
-       //CGameWindow::FreeResources(ETrue);\r
-\r
-       //if(CPolledActiveScheduler::Instance())\r
-       //      delete CPolledActiveScheduler::Instance();\r
-}\r
-\r
 static void DumpMemInfo()\r
 {\r
        TInt    ramSize, ramSizeFree, romSize;\r
@@ -444,12 +436,20 @@ static void DumpMemInfo()
 }\r
 \r
 \r
+extern "C" TInt my_SetExceptionHandler(TInt, TExceptionHandler, TUint32);\r
+\r
 TInt EmuThreadFunction(TAny*)\r
 {\r
+       TInt ret;\r
        const TUint32 exs = KExceptionAbort|KExceptionKill|KExceptionUserInterrupt|KExceptionFpe|KExceptionFault|KExceptionInteger|KExceptionDebug;\r
        \r
-       DEBUGPRINT(_L("EmuThreadFunction()"));\r
-       User::SetExceptionHandler(ExceptionHandler, exs/*(TUint32) -1*/); // does not work?\r
+       DEBUGPRINT(_L("EmuThreadFunction(), def ExceptionHandler %08x, my %08x"),\r
+               User::ExceptionHandler(), ExceptionHandler);\r
+       User::SetJustInTime(1);\r
+       ret = User::SetExceptionHandler(ExceptionHandler, exs/*(TUint32) -1*/); // does not work :(\r
+       // my_SetExceptionHandler(KCurrentThreadHandle, ExceptionHandler, 0xffffffff);\r
+       DEBUGPRINT(_L("SetExceptionHandler %i, %08x"), ret, User::ExceptionHandler());\r
+       User::ModifyExceptionMask(0, exs);\r
 \r
        //TInt pc, sp;\r
        //asm volatile ("str pc, %0" : "=m" (pc) );\r
@@ -479,7 +479,7 @@ TInt EmuThreadFunction(TAny*)
 \r
        TRAPD(error, TargetEpocGameL());\r
 \r
-       __ASSERT_ALWAYS(!error, User::Panic(_L("Picosmall"), error));\r
+       __ASSERT_ALWAYS(!error, User::Panic(_L("PicoDrive"), error));\r
        delete cleanup;\r
 \r
        DEBUGPRINT(_L("exitting.."));   \r
@@ -586,17 +586,19 @@ void CGameWindow::ConstructResourcesL()
        // try to start the audio engine\r
        static int PsndRate_old = 0, PicoOpt_old = 0, pal_old = 0;\r
 \r
-       if(gamestate == PGS_Running && (currentConfig->iFlags & 4)) {\r
+       if (gamestate == PGS_Running && (currentConfig.EmuOpt & EOPT_EN_SOUND))\r
+       {\r
                TInt err = 0;\r
                if(PsndRate != PsndRate_old || (PicoOpt&11) != (PicoOpt_old&11) || Pico.m.pal != pal_old) {\r
                        // if rate changed, reset all enabled chips, else reset only those chips, which were recently enabled\r
                        //sound_reset(PsndRate != PsndRate_old ? PicoOpt : (PicoOpt&(PicoOpt^PicoOpt_old)));\r
-                       sound_rerate();\r
+                       PsndRerate(1);\r
                }\r
                if(!gameAudio || PsndRate != PsndRate_old || ((PicoOpt&8) ^ (PicoOpt_old&8)) || Pico.m.pal != pal_old) { // rate or stereo or pal/ntsc changed\r
                        if(gameAudio) delete gameAudio; gameAudio = 0;\r
                        DEBUGPRINT(_L("starting audio: %i len: %i stereo: %i, pal: %i"), PsndRate, PsndLen, PicoOpt&8, Pico.m.pal);\r
-                       TRAP(err, gameAudio = CGameAudioMS::NewL(PsndRate, (PicoOpt&8) ? 1 : 0, Pico.m.pal ? 50 : 60));\r
+                       TRAP(err, gameAudio = CGameAudioMS::NewL(PsndRate, (PicoOpt&8) ? 1 : 0,\r
+                                               Pico.m.pal ? 50 : 60, currentConfig.volume));\r
                }\r
                if( gameAudio) {\r
                        TRAP(err, PsndOut = gameAudio->ResumeL());\r
@@ -678,11 +680,6 @@ void CGameWindow::FreeResources()
        }\r
        \r
        vidFree();\r
-\r
-       // emu might change renderer by itself, so we may need to sync config\r
-       if(currentConfig && currentConfig->iPicoOpt != PicoOpt) {\r
-               currentConfig->iFlags |= 0x80;\r
-       }\r
 }\r
 \r
 \r
@@ -708,7 +705,7 @@ void CGameWindow::DoKeys(void)
                                const TPicoAreaConfigEntry *e = areaConfig + 1;\r
                                for(i = 0; !e->rect.IsEmpty(); e++, i++)\r
                                        if(e->rect.Contains(p)) {\r
-                                               areaActions = currentConfig->iAreaBinds[i];\r
+                                               areaActions = currentConfig.KeyBinds[i+256];\r
                                                break;\r
                                        }\r
                                //DEBUGPRINT(_L("pointer event: %i %i"), p.iX, p.iY);\r
@@ -767,7 +764,7 @@ void CGameWindow::DoKeys(void)
                for(i = 9; i >= 0; i--) {\r
                        int scan = pressedKeys[i];\r
                        if(scan) {\r
-                               if(keyFlags[scan] & 1) allActions |= currentConfig->iKeyBinds[scan];\r
+                               if(keyFlags[scan] & 1) allActions |= currentConfig.KeyBinds[scan];\r
                                if((keyFlags[scan]& 3)==3) forceUpdate = 1;\r
                                if(keyFlags[scan] & 2) keyFlags[scan] &= ~1;\r
                        }\r
@@ -807,7 +804,7 @@ void CGameWindow::DoKeysConfig(TUint &which)
                                        const TPicoAreaConfigEntry *e = areaConfig + 1;\r
                                        for(i = 0; e->rect != TRect(0,0,0,0); e++, i++)\r
                                                if(e->rect.Contains(p)) {\r
-                                                       currentConfig->iAreaBinds[i] ^= currentActCode;\r
+                                                       currentConfig.KeyBinds[i+256] ^= currentActCode;\r
                                                        break;\r
                                                }\r
                                }\r
@@ -822,7 +819,7 @@ void CGameWindow::DoKeysConfig(TUint &which)
                                if(which == 31) {\r
                                        gamestate = PGS_Paused;\r
                                } else if (scan < 256) {\r
-                                       if(!(keyFlags[scan]&0x40)) currentConfig->iKeyBinds[scan] ^= currentActCode;\r
+                                       if(!(keyFlags[scan]&0x40)) currentConfig.KeyBinds[scan] ^= currentActCode;\r
                                }\r
                        }\r
 \r
@@ -844,22 +841,22 @@ void CGameWindow::DoKeysConfig(TUint &which)
 \r
 void CGameWindow::RunEvents(TUint32 which)\r
 {\r
-       if(which & 0x4000) currentConfig->iFrameskip = -1;\r
-       if(which & 0x2000) currentConfig->iFrameskip =  8;\r
-       if(which & 0x1800) { // save or load (but not both)\r
+       if (which & 0x4000) currentConfig.Frameskip = -1;\r
+       if (which & 0x2000) currentConfig.Frameskip =  8;\r
+       if (which & 0x1800) { // save or load (but not both)\r
                if(PsndOut) gameAudio->Pause(); // this may take a while, so we pause sound output\r
 \r
                vidDrawNotice((which & 0x1000) ? "LOADING@GAME" : "SAVING@GAME");\r
-               saveLoadGame(which & 0x1000);\r
+               emu_SaveLoadGame(which & 0x1000, 0);\r
 \r
                if(PsndOut) PsndOut = gameAudio->ResumeL();\r
                reset_timing = 1;\r
        }\r
-       if(which & 0x0400) gamestate = PGS_Paused;\r
-       if(which & 0x0200) { // switch renderer\r
-               if(!(currentConfig->iScreenMode == TPicoConfig::PMFit &&\r
-                       (currentConfig->iScreenRotation == TPicoConfig::PRot0 || currentConfig->iScreenRotation == TPicoConfig::PRot180))) {\r
-\r
+       if (which & 0x0400) gamestate = PGS_Paused;\r
+       if (which & 0x0200) { // switch renderer\r
+               if (!(currentConfig.scaling == TPicoConfig::PMFit &&\r
+                       (currentConfig.rotation == TPicoConfig::PRot0 || currentConfig.rotation == TPicoConfig::PRot180)))\r
+               {\r
                        PicoOpt^=0x10;\r
                        vidInit(0, 1);\r
 \r
@@ -878,111 +875,20 @@ void CGameWindow::RunEvents(TUint32 which)
                sprintf(noticeMsg, "SAVE@SLOT@%i@SELECTED", state_slot);\r
                gettimeofday(&noticeMsgTime, 0);\r
        }\r
-       if(which & 0x0020) if(gameAudio) gameAudio->ChangeVolume(0);\r
-       if(which & 0x0010) if(gameAudio) gameAudio->ChangeVolume(1);\r
+       if(which & 0x0020) if(gameAudio) currentConfig.volume = gameAudio->ChangeVolume(0);\r
+       if(which & 0x0010) if(gameAudio) currentConfig.volume = gameAudio->ChangeVolume(1);\r
 }\r
 \r
 \r
-// must use wrappers, or else will run into some weird loader error (see pico/area.c)\r
-static size_t fRead2(void *p, size_t _s, size_t _n, void *file)\r
-{\r
-       return fread(p, _s, _n, (FILE *) file);\r
-}\r
-\r
-static size_t fWrite2(void *p, size_t _s, size_t _n, void *file)\r
-{\r
-       return fwrite(p, _s, _n, (FILE *) file);\r
-}\r
-\r
-static size_t gzRead2(void *p, size_t, size_t _n, void *file)\r
-{\r
-       return gzread(file, p, _n);\r
-}\r
-\r
-static size_t gzWrite2(void *p, size_t, size_t _n, void *file)\r
+extern "C" void emu_noticeMsgUpdated(void)\r
 {\r
-       return gzwrite(file, p, _n);\r
-}\r
-\r
-\r
-// this function is shared between both threads\r
-int saveLoadGame(int load, int sram)\r
-{\r
-       int res = 0;\r
-\r
-       if(!RomFileName) return -1;\r
-\r
-       // make save filename\r
-       char saveFname[KMaxFileName];\r
-       strcpy(saveFname, RomFileName);\r
-       saveFname[KMaxFileName-8] = 0;\r
-       if(saveFname[strlen(saveFname)-4] == '.') saveFname[strlen(saveFname)-4] = 0;\r
-       if(sram) strcat(saveFname, ".srm");\r
-       else {\r
-               if(state_slot > 0 && state_slot < 10) sprintf(saveFname, "%s.%i", saveFname, state_slot);\r
-               strcat(saveFname, ".mds");\r
-       }\r
-\r
-       DEBUGPRINT(_L("saveLoad (%i, %i): %S"), load, sram, DO_CONV(saveFname));\r
-\r
-       if(sram) {\r
-               FILE *sramFile;\r
-               int sram_size = SRam.end-SRam.start+1;\r
-               if(SRam.reg_back & 4) sram_size=0x2000;\r
-               if(!SRam.data) return 0; // SRam forcefully disabled for this game\r
-               if(load) {\r
-                       sramFile = fopen(saveFname, "rb");\r
-                       if(!sramFile) return -1;\r
-                       fread(SRam.data, 1, sram_size, sramFile);\r
-                       fclose(sramFile);\r
-               } else {\r
-                       // sram save needs some special processing\r
-                       // see if we have anything to save\r
-                       for(; sram_size > 0; sram_size--)\r
-                               if(SRam.data[sram_size-1]) break;\r
-                       \r
-                       if(sram_size) {\r
-                               sramFile = fopen(saveFname, "wb");\r
-                               res = fwrite(SRam.data, 1, sram_size, sramFile);\r
-                               res = (res != sram_size) ? -1 : 0;\r
-                               fclose(sramFile);\r
-                       }\r
-               }\r
-               return res;\r
-       } else {\r
-               void *PmovFile = NULL;\r
-               // try gzip first\r
-               if(currentConfig->iFlags & 0x80) {\r
-                       strcat(saveFname, ".gz");\r
-                       if( (PmovFile = gzopen(saveFname, load ? "rb" : "wb")) ) {\r
-                               areaRead  = gzRead2;\r
-                               areaWrite = gzWrite2;\r
-                               if(!load) gzsetparams(PmovFile, 9, Z_DEFAULT_STRATEGY);\r
-                       } else\r
-                               saveFname[strlen(saveFname)-3] = 0;\r
-               }\r
-               if(!PmovFile) { // gzip failed or was disabled\r
-                       if( (PmovFile = fopen(saveFname, load ? "rb" : "wb")) ) {\r
-                               areaRead  = fRead2;\r
-                               areaWrite = fWrite2;\r
-                       }\r
-               }\r
-               if(PmovFile) {\r
-                       PmovState(load ? 6 : 5, PmovFile); // load/save\r
-                       strcpy(noticeMsg, load ? "GAME@LOADED" : "GAME@SAVED");\r
-                       if(areaRead == gzRead2)\r
-                                gzclose(PmovFile);\r
-                       else fclose ((FILE *) PmovFile);\r
-                       PmovFile = 0;\r
-                       if (load) Pico.m.dirtyPal=1;\r
-               } else {\r
-                       strcpy(noticeMsg, load ? "LOAD@FAILED" : "SAVE@FAILED");\r
-                       res = -1;\r
-               }\r
-\r
-               gettimeofday(&noticeMsgTime, 0);\r
-               return res;\r
+       char *p = noticeMsg;\r
+       while (*p) {\r
+               if (*p == ' ') *p = '@';\r
+               if (*p < '0' || *p > 'Z') { *p = 0; break; }\r
+               p++;\r
        }\r
+       gettimeofday(&noticeMsgTime, 0);\r
 }\r
 \r
 // static class members\r
index 308b10b..bd1b3fd 100644 (file)
@@ -5,20 +5,20 @@
 \r
 #include "vid.h"\r
 #include "../Engine.h"\r
-#include "../../../pico/picoInt.h"\r
+#include <Pico/PicoInt.h>\r
+#include "../../common/emu.h"\r
 #include "blit.h"\r
 #include "debug.h"\r
 \r
 \r
 // global stuff\r
-extern TPicoConfig *currentConfig;\r
 extern TPicoAreaConfigEntry areaConfig[];\r
 extern const char *actionNames[];\r
 \r
 // main framebuffer\r
 static void *screenbuff = 0; // pointer to real device video memory\r
 //static\r
-extern "C" { unsigned char *framebuff = 0; }  // temporary buffer\r
+extern "C" { unsigned char *PicoDraw2FB = 0; }  // temporary buffer\r
 const int framebuffsize  = (8+320)*(8+240+8)*2+8*2; // actual framebuffer size (in bytes+to support new rendering mode)\r
 \r
 // drawer function pointers\r
@@ -87,35 +87,25 @@ static const unsigned long mask_numbers[] = {
 };\r
 \r
 \r
-////////////////////////////////\r
-// Cram functions\r
-\r
-static int EmuCramNull(int cram)\r
-{\r
-       User::Panic(_L("Cram called!!"), 0);\r
-       return cram;\r
-}\r
-\r
-\r
 ////////////////////////////////\r
 // PicoScan functions\r
 \r
-static int EmuScan8(unsigned int num, void *sdata)\r
+static int EmuScanBegin8(unsigned int num)\r
 {\r
-       DrawLineDest = framebuff + 328*(num+1) + 328*8 + 8;\r
+       DrawLineDest = PicoDraw2FB + 328*num + 328*8 + 8;\r
 \r
        return 0;\r
 }\r
 \r
 \r
-static int EmuScanFit0(unsigned int num, void *sdata)\r
+static int EmuScanEndFit0(unsigned int num)\r
 {\r
        // 0.75, 168 lines\r
 \r
        static int u = 0, num2 = 0;\r
        if(!num) u = num2 = 0;\r
 \r
-       DrawLineDest = framebuff + 328*(++num2) + 328*8 + 8;\r
+       DrawLineDest = PicoDraw2FB + 328*(++num2) + 328*8 + 8;\r
 \r
        u += 6666;\r
 \r
@@ -136,7 +126,7 @@ static int EmuScanFit0(unsigned int num, void *sdata)
 \r
 static void drawTextM2(int x, int y, const char *text)\r
 {\r
-       unsigned char *vidmem = framebuff + 328*8 + 8;\r
+       unsigned char *vidmem = PicoDraw2FB + 328*8 + 8;\r
        int charmask, i, cx = x, cy;\r
        unsigned char *l, *le;\r
 \r
@@ -164,7 +154,7 @@ static void drawTextM2(int x, int y, const char *text)
 \r
 static void drawTextM2Fat(int x, int y, const char *text)\r
 {\r
-       unsigned char *vidmem = framebuff + 328*8 + 8;\r
+       unsigned char *vidmem = PicoDraw2FB + 328*8 + 8;\r
        int charmask, i, cx = x&~1, cy;\r
        unsigned short *l, *le;\r
 \r
@@ -257,7 +247,7 @@ static void fillLocalPal(void)
                vidConvCpyRGB32(localPal, Pico.cram, 0x40);\r
                vidConvCpyRGB32sh(localPal+0x40, Pico.cram, 0x40);\r
                vidConvCpyRGB32hi(localPal+0x80, Pico.cram, 0x40);\r
-               blockcpy(localPal+0xc0, localPal+0x40, 0x40*4);\r
+               memcpy32(localPal+0xc0, localPal+0x40, 0x40);\r
                localPal[0xe0] = 0x00000000; // reserved pixels for OSD\r
                localPal[0xf0] = 0x00ee0000;\r
        } else if (rendstatus & 0x20) { // mid-frame palette changes\r
@@ -273,7 +263,7 @@ static void fillLocalPal(void)
 // note: the internal 8 pixel border is taken care by asm code\r
 static void vidBlit_90(int full)\r
 {\r
-       unsigned char *ps = framebuff+328*8;\r
+       unsigned char *ps = PicoDraw2FB+328*8;\r
        unsigned long *pd = (unsigned long *) screenbuff;\r
 \r
        if (Pico.m.dirtyPal) fillLocalPal();\r
@@ -291,7 +281,7 @@ static void vidBlit_90(int full)
 \r
 static void vidBlit_270(int full)\r
 {\r
-       unsigned char *ps = framebuff+328*8;\r
+       unsigned char *ps = PicoDraw2FB+328*8;\r
        unsigned long *pd = (unsigned long *) screenbuff;\r
 \r
        if (Pico.m.dirtyPal) fillLocalPal();\r
@@ -310,7 +300,7 @@ static void vidBlit_270(int full)
 \r
 static void vidBlitCenter_0(int full)\r
 {\r
-       unsigned char *ps = framebuff+328*8+8;\r
+       unsigned char *ps = PicoDraw2FB+328*8+8;\r
        unsigned long *pd = (unsigned long *) screenbuff;\r
 \r
        if (Pico.m.dirtyPal) fillLocalPal();\r
@@ -323,7 +313,7 @@ static void vidBlitCenter_0(int full)
 \r
 static void vidBlitCenter_180(int full)\r
 {\r
-       unsigned char *ps = framebuff+328*8+8;\r
+       unsigned char *ps = PicoDraw2FB+328*8+8;\r
        unsigned long *pd = (unsigned long *) screenbuff;\r
 \r
        if (Pico.m.dirtyPal) fillLocalPal();\r
@@ -339,8 +329,8 @@ static void vidBlitFit_0(int full)
        if (Pico.m.dirtyPal) fillLocalPal();\r
 \r
        if(Pico.video.reg[12]&1)\r
-                vidConvCpy_center2_40c_0(screenbuff, framebuff+328*8, localPal, 168);\r
-       else vidConvCpy_center2_32c_0(screenbuff, framebuff+328*8, localPal, 168);\r
+                vidConvCpy_center2_40c_0(screenbuff, PicoDraw2FB+328*8, localPal, 168);\r
+       else vidConvCpy_center2_32c_0(screenbuff, PicoDraw2FB+328*8, localPal, 168);\r
        if(full) vidClear((unsigned long *)screenbuff + 168*256, 320-168);\r
 }\r
 \r
@@ -350,8 +340,8 @@ static void vidBlitFit_180(int full)
        if (Pico.m.dirtyPal) fillLocalPal();\r
 \r
        if(Pico.video.reg[12]&1)\r
-            vidConvCpy_center2_40c_180(screenbuff, framebuff+328*8, localPal, 168);\r
-       else vidConvCpy_center2_32c_180(screenbuff, framebuff+328*8-64, localPal, 168);\r
+            vidConvCpy_center2_40c_180(screenbuff, PicoDraw2FB+328*8, localPal, 168);\r
+       else vidConvCpy_center2_32c_180(screenbuff, PicoDraw2FB+328*8-64, localPal, 168);\r
        if(full) vidClear((unsigned long *)screenbuff + 168*256, 320-168);\r
 }\r
 \r
@@ -361,8 +351,8 @@ static void vidBlitFit2_0(int full)
        if (Pico.m.dirtyPal) fillLocalPal();\r
 \r
        if(Pico.video.reg[12]&1)\r
-            vidConvCpy_center2_40c_0(screenbuff, framebuff+328*8, localPal, 224);\r
-       else vidConvCpy_center2_32c_0(screenbuff, framebuff+328*8, localPal, 224);\r
+            vidConvCpy_center2_40c_0(screenbuff, PicoDraw2FB+328*8, localPal, 224);\r
+       else vidConvCpy_center2_32c_0(screenbuff, PicoDraw2FB+328*8, localPal, 224);\r
        if(full) vidClear((unsigned long *)screenbuff + 224*256, 96);\r
 }\r
 \r
@@ -372,15 +362,15 @@ static void vidBlitFit2_180(int full)
        if (Pico.m.dirtyPal) fillLocalPal();\r
 \r
        if(Pico.video.reg[12]&1)\r
-            vidConvCpy_center2_40c_180(screenbuff, framebuff+328*8, localPal, 224);\r
-       else vidConvCpy_center2_32c_180(screenbuff, framebuff+328*8-64, localPal, 224);\r
+            vidConvCpy_center2_40c_180(screenbuff, PicoDraw2FB+328*8, localPal, 224);\r
+       else vidConvCpy_center2_32c_180(screenbuff, PicoDraw2FB+328*8-64, localPal, 224);\r
        if(full) vidClear((unsigned long *)screenbuff + 224*256, 96);\r
 }\r
 \r
 \r
 static void vidBlitCfg(void)\r
 {\r
-       unsigned short *ps = (unsigned short *) framebuff;\r
+       unsigned short *ps = (unsigned short *) PicoDraw2FB;\r
        unsigned long *pd = (unsigned long *) screenbuff;\r
        int i;\r
 \r
@@ -402,20 +392,17 @@ int vidInit(void *vidmem, int reinit)
        if(!reinit) {\r
                // prepare framebuffer\r
                screenbuff = vidmem;\r
-               framebuff = (unsigned char *) malloc(framebuffsize);\r
+               PicoDraw2FB = (unsigned char *) malloc(framebuffsize);\r
 \r
                if(!screenbuff) return KErrNotSupported;\r
-               if(!framebuff)  return KErrNoMemory;\r
-\r
-               memset(framebuff, 0, framebuffsize);\r
+               if(!PicoDraw2FB)  return KErrNoMemory;\r
 \r
-               // Cram function: go and hack Pico so it never gets called\r
-               PicoCram = EmuCramNull;\r
+               memset(PicoDraw2FB, 0, framebuffsize);\r
        }\r
 \r
        // select suitable blitters\r
        vidBlit = vidBlit_270;\r
-       PicoScan = EmuScan8;\r
+       PicoScanBegin = EmuScanBegin8;\r
        drawTextFps = drawTextFps0;\r
        drawTextNotice = drawTextNotice0;\r
 \r
@@ -424,12 +411,13 @@ int vidInit(void *vidmem, int reinit)
        localPal[0xf0] = 0x00ee0000;\r
 \r
        // setup all orientation related stuff\r
-       if(currentConfig->iScreenRotation == TPicoConfig::PRot0) {\r
-               if(currentConfig->iScreenMode == TPicoConfig::PMCenter) {\r
+       if (currentConfig.rotation == TPicoConfig::PRot0)\r
+       {\r
+               if (currentConfig.scaling == TPicoConfig::PMCenter) {\r
                        vidBlit = vidBlitCenter_0;\r
                        drawTextFps = drawTextFpsCenter0;\r
                        drawTextNotice = drawTextNoticeCenter0;\r
-               } else if(currentConfig->iScreenMode == TPicoConfig::PMFit2) {\r
+               } else if (currentConfig.scaling == TPicoConfig::PMFit2) {\r
                        vidBlit = vidBlitFit2_0;\r
                        drawTextFps = drawTextFpsFit2_0;\r
                        drawTextNotice = drawTextNoticeFit2_0;\r
@@ -437,16 +425,20 @@ int vidInit(void *vidmem, int reinit)
                        vidBlit = vidBlitFit_0;\r
                        drawTextFps = drawTextFpsFit0;\r
                        drawTextNotice = drawTextNoticeFit0;\r
-                       PicoScan = EmuScanFit0;\r
+                       PicoScanEnd = EmuScanEndFit0;\r
                }\r
-       } else if(currentConfig->iScreenRotation == TPicoConfig::PRot90) {\r
+       } else if (currentConfig.rotation == TPicoConfig::PRot90) {\r
                vidBlit = vidBlit_90;\r
-       } else if(currentConfig->iScreenRotation == TPicoConfig::PRot180) {\r
-               if(currentConfig->iScreenMode == TPicoConfig::PMCenter) {\r
+       }\r
+       else if (currentConfig.rotation == TPicoConfig::PRot180)\r
+       {\r
+               if (currentConfig.scaling == TPicoConfig::PMCenter)\r
+               {\r
                        vidBlit = vidBlitCenter_180;\r
                        drawTextFps = drawTextFpsCenter0;\r
                        drawTextNotice = drawTextNoticeCenter0;\r
-               } else if(currentConfig->iScreenMode == TPicoConfig::PMFit2) {\r
+               }\r
+               else if (currentConfig.scaling == TPicoConfig::PMFit2) {\r
                        vidBlit = vidBlitFit2_180;\r
                        drawTextFps = drawTextFpsFit2_0;\r
                        drawTextNotice = drawTextNoticeFit2_0;\r
@@ -454,9 +446,10 @@ int vidInit(void *vidmem, int reinit)
                        vidBlit = vidBlitFit_180;\r
                        drawTextFps = drawTextFpsFit0;\r
                        drawTextNotice = drawTextNoticeFit0;\r
-                       PicoScan = EmuScanFit0;\r
+                       PicoScanEnd = EmuScanEndFit0;\r
                }\r
-       } else if(currentConfig->iScreenRotation == TPicoConfig::PRot270) {\r
+       }\r
+       else if (currentConfig.rotation == TPicoConfig::PRot270) {\r
                vidBlit = vidBlit_270;\r
        }\r
 \r
@@ -469,16 +462,16 @@ int vidInit(void *vidmem, int reinit)
 \r
 void vidFree()\r
 {\r
-       free(framebuff);\r
-       framebuff = 0;\r
+       free(PicoDraw2FB);\r
+       PicoDraw2FB = 0;\r
 }\r
 \r
 void vidDrawFrame(char *noticeStr, char *fpsStr, int num)\r
 {\r
-       DrawLineDest = framebuff + 328*8 + 8;\r
+       DrawLineDest = PicoDraw2FB + 328*8 + 8;\r
 \r
 //     PicoFrame(); // moved to main loop\r
-       if(currentConfig->iFlags & 2)\r
+       if (currentConfig.EmuOpt & EOPT_SHOW_FPS)\r
                drawTextFps(fpsStr);\r
        drawTextNotice(noticeStr);\r
 \r
@@ -489,7 +482,7 @@ void vidDrawFrame(char *noticeStr, char *fpsStr, int num)
 \r
 static void drawText0(int x, int y, const char *text, long color)\r
 {\r
-       unsigned short *vidmem=(unsigned short *)framebuff;\r
+       unsigned short *vidmem=(unsigned short *)PicoDraw2FB;\r
        int charmask, i, cx = x, cy;\r
        unsigned short *l, *le, dmask=0x0333;\r
 \r
@@ -519,7 +512,7 @@ static void drawText0(int x, int y, const char *text, long color)
 // draws rect with width - 1 and height - 1\r
 static void drawRect(const TRect &rc, unsigned short color)\r
 {\r
-       unsigned short *vidmem=(unsigned short *)framebuff;\r
+       unsigned short *vidmem=(unsigned short *)PicoDraw2FB;\r
 \r
        if(rc.iTl.iX - rc.iBr.iX && rc.iTl.iY - rc.iBr.iY) {\r
                int stepX = rc.iTl.iX < rc.iBr.iX ? 1 : -1;\r
@@ -540,7 +533,7 @@ static void drawRect(const TRect &rc, unsigned short color)
 // draws fullsize filled rect\r
 static void drawRectFilled(const TRect rc, unsigned short color)\r
 {\r
-       unsigned short *vidmem=(unsigned short *)framebuff;\r
+       unsigned short *vidmem=(unsigned short *)PicoDraw2FB;\r
 \r
        if(rc.iTl.iX - rc.iBr.iX && rc.iTl.iY - rc.iBr.iY) {\r
                int stepX = rc.iTl.iX < rc.iBr.iX ? 1 : -1;\r
@@ -559,7 +552,7 @@ static void drawRectFilled(const TRect rc, unsigned short color)
 // direction: -1 left, 1 right\r
 static void drawArrow0(TPoint p, int direction, unsigned short color)\r
 {\r
-       unsigned short *vidmem=(unsigned short *)framebuff;\r
+       unsigned short *vidmem=(unsigned short *)PicoDraw2FB;\r
        int width = 15;\r
        int x = p.iX;\r
        int y = p.iY;\r
@@ -603,7 +596,7 @@ void vidKeyConfigFrame(const TUint whichAction)
        int i;\r
        char buttonNames[128];\r
        buttonNames[0] = 0;\r
-       memset(framebuff, 0, framebuffsize);\r
+       memset(PicoDraw2FB, 0, framebuffsize);\r
 \r
        unsigned long currentActCode = 1 << whichAction;\r
 \r
@@ -611,7 +604,7 @@ void vidKeyConfigFrame(const TUint whichAction)
        const TPicoAreaConfigEntry *e = areaConfig + 1; i = 0;\r
        while(e->rect != TRect(0,0,0,0)) { e++; i++; }\r
        for(e--, i--; e->rect != TRect(0,0,0,0); e--, i--)\r
-               drawRect(e->rect, (currentConfig->iAreaBinds[i] & currentActCode) ? color_red : color_red_dim);\r
+               drawRect(e->rect, (currentConfig.KeyBinds[i+256] & currentActCode) ? color_red : color_red_dim);\r
 \r
        // action name control\r
        drawRectFilled(TRect(72, 2, 168, 20), color_grey); // 96x14\r
@@ -621,14 +614,14 @@ void vidKeyConfigFrame(const TUint whichAction)
        drawText0(86, 9, actionNames[whichAction], color_red);\r
 \r
        // draw active button names if there are any\r
-       for(i = 0; i < 256; i++) {\r
-               if(currentConfig->iKeyBinds[i] & currentActCode) {\r
+       for (i = 0; i < 256; i++) {\r
+               if (currentConfig.KeyBinds[i] & currentActCode) {\r
                        if(buttonNames[0]) strcat(buttonNames, ";@");\r
                        strcat(buttonNames, vidGetScanName(i));\r
                }\r
        }\r
 \r
-       if(buttonNames[0]) {\r
+       if (buttonNames[0]) {\r
                buttonNames[61] = 0; // only 60 chars fit\r
                drawText0(6, 48, buttonNames, color_blue);\r
        }\r
@@ -638,7 +631,7 @@ void vidKeyConfigFrame(const TUint whichAction)
 \r
 void vidDrawNotice(const char *txt)\r
 {\r
-       if(framebuff) {\r
+       if(PicoDraw2FB) {\r
                drawTextNotice(txt);\r
                vidBlit(1);\r
        }\r
diff --git a/platform/uiq3/makezip.cmd b/platform/uiq3/makezip.cmd
deleted file mode 100644 (file)
index 2aea772..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-@cd _out\r
-@"C:\Program Files\arch\WinRAR\WinRAR.exe" a PicoDrive.zip PicoDrive.SIS config.txt ..\..\readme.txt\r
-@cd..\r
similarity index 83%
rename from platform/uiq3/PicoDrive.hrh
rename to platform/uiq3/picodrive.hrh
index 910fde8..445c7fb 100644 (file)
@@ -31,6 +31,7 @@ enum TAppMenuCommands
        // pages\r
        ECtlOptPageMain,\r
        ECtlOptPageSound,\r
+       ECtlOptPageMCD,\r
        ECtlOptPageMisc,\r
        // main page\r
        ECtlOptRotationLabel,\r
@@ -45,8 +46,8 @@ enum TAppMenuCommands
        ECtlOptScreenModeFit,\r
        ECtlOptScreenModeFit2,\r
        ECtlOptUseAltRend,\r
-       ECtlOptUseAccTiming,\r
-       ECtlOptUseAccSprites,\r
+//     ECtlOptUseAccTiming,\r
+//     ECtlOptUseAccSprites,\r
        ECtlOptShowFPS,\r
        // sound page\r
        ECtlOptEnableSound,\r
@@ -56,6 +57,13 @@ enum TAppMenuCommands
        ECtlOptEmulateSN76496,\r
        ECtlOptSndQLabel,\r
        ECtlOptSndQuality,\r
+       // MCD page\r
+       ECtlOptCDleds,\r
+       ECtlOptCDcdda,\r
+       ECtlOptCDpcm,\r
+       ECtlOptCDramcart,\r
+       ECtlOptCDscalerot,\r
+       ECtlOptCDbettersync,\r
        // misc page\r
        ECtlOpt6ButtonPad,\r
        ECtlOptGzipStates,\r
diff --git a/platform/uiq3/picodrive.pkg b/platform/uiq3/picodrive.pkg
new file mode 100644 (file)
index 0000000..c3e2de1
--- /dev/null
@@ -0,0 +1,9 @@
+%{"notaz"}
+:"notaz"
+#{"PicoDrive"}, (0xA00010F3), 1, 51, 0, TYPE=SA
+(0x101F6300), 3, 0, 0, {"UIQ30ProductID"}
+"picodrive.exe"-"!:\sys\bin\PicoDrive.exe"
+"rsc/picodrive.rsc"-"!:\resource\apps\PicoDrive.rsc"
+"picodrive.mbm"-"!:\resource\apps\PicoDrive.mbm"
+"rsc/picodrive_loc.rsc"-"!:\resource\apps\PicoDrive_loc.rsc"
+"rsc/picodrive_reg.rsc"-"!:\private\10003a3f\import\apps\PicoDrive_reg.rsc"
index 79f5fda..0686c26 100644 (file)
@@ -3,21 +3,32 @@
 #ifndef PORT_CONFIG_H\r
 #define PORT_CONFIG_H\r
 \r
+#define CASE_SENSITIVE_FS 0\r
+#define DONT_OPEN_MANY_FILES 0\r
+#define REDUCE_IO_CALLS 0\r
+#define SIMPLE_WRITE_SOUND 0\r
+\r
+// draw.c\r
+#define OVERRIDE_HIGHCOL 0\r
+\r
 // draw2.c\r
 #define START_ROW  0 // which row of tiles to start rendering at?\r
 #define END_ROW   28 // ..end\r
 \r
 // pico.c\r
-#define CAN_HANDLE_240_LINES   0 // fow now\r
-\r
-//#define dprintf(f,...) printf(f"\n",##__VA_ARGS__)\r
-#ifdef __DEBUG_PRINT\r
-#ifdef __cplusplus\r
-extern "C"\r
-#endif\r
-void dprintf(char *format, ...);\r
-#else\r
+#define CAN_HANDLE_240_LINES   0 // for now\r
+\r
+// logging emu events\r
+#define EL_LOGMASK (EL_STATUS|EL_IDLE) // (EL_STATUS|EL_ANOMALY|EL_UIO|EL_SRAMIO|EL_INTS|EL_CDPOLL) // xffff\r
+\r
+//extern void dprintf(char *format, ...);\r
+//#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__)\r
 #define dprintf(x...)\r
-#endif\r
 \r
-#endif //PORT_CONFIG_H\r
+// platform\r
+#define PLAT_MAX_KEYS (256+19)\r
+#define PLAT_HAVE_JOY 0\r
+#define PATH_SEP      "\\"\r
+#define PATH_SEP_C    '\\'\r
+\r
+#endif // PORT_CONFIG_H\r
index bc0f97f..3361f1a 100644 (file)
@@ -1,8 +1,13 @@
-@ .equiv START_ROW,    1\r
-@ .equiv END_ROW,              27\r
+@ vim:filetype=armasm\r
+\r
+@ .equiv START_ROW,         1\r
+@ .equiv END_ROW,          27\r
 @ one row means 8 pixels. If above example was used, (27-1)*8=208 lines would be rendered.\r
-.equiv START_ROW,              0\r
-.equiv END_ROW,                28\r
+.equiv START_ROW,               0\r
+.equiv END_ROW,                28\r
+\r
+.equiv OVERRIDE_HIGHCOL,        0\r
+.equiv UNALIGNED_DRAWLINEDEST,  0\r
 \r
 @ this should be set to one only for GP2X port\r
-.equiv EXTERNAL_YM2612, 0\r
+.equiv EXTERNAL_YM2612,         0\r
diff --git a/platform/uiq3/qconn.cmd b/platform/uiq3/qconn.cmd
deleted file mode 100644 (file)
index 429b196..0000000
+++ /dev/null
@@ -1 +0,0 @@
-@..\..\..\qconsole-1.60\qtty-1.60\release\qtty --qc-addr M600i --qc-channel 5 --user qconsole --pass server
\ No newline at end of file
diff --git a/platform/uiq3/qlog.cmd b/platform/uiq3/qlog.cmd
deleted file mode 100644 (file)
index c9e1542..0000000
+++ /dev/null
@@ -1 +0,0 @@
-@..\..\..\qconsole-1.60\qtty-1.60\release\qtty --qc-addr M600i --qc-channel 5 --user qconsole --pass server --cmds "cat c:\logs\pico.log" exit\r
diff --git a/platform/uiq3/qup.cmd b/platform/uiq3/qup.cmd
deleted file mode 100644 (file)
index de5594a..0000000
+++ /dev/null
@@ -1 +0,0 @@
-@..\..\..\qconsole-1.60\qtty-1.60\release\qtty --qc-addr M600i --qc-channel 5 --user qconsole --pass server --cmds "put c:\Shared\PicoDrive.SIS _out\PicoDrive.SIS" "rundoc c:\Shared\PicoDrive.SIS" exit\r
diff --git a/platform/uiq3/rsc/PicoDrive_loc.rss b/platform/uiq3/rsc/PicoDrive_loc.rss
deleted file mode 100644 (file)
index 2495e0b..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <AppInfo.rh>\r
-\r
-// This file localise the applications icons and caption\r
-RESOURCE LOCALISABLE_APP_INFO\r
-       {\r
-       caption_and_icon =\r
-               {\r
-               CAPTION_AND_ICON_INFO\r
-                       {\r
-                       caption = "PicoDrive";\r
-                       // Icons are used to represent applications in the \r
-                       // application launcher and application title bar.\r
-                       // The number_of_icons value identifies how many icons \r
-                       // that exist in the icon_file.\r
-                       number_of_icons = 3;\r
-                       // Using the application icons.\r
-                       icon_file = "\\Resource\\Apps\\PicoDrive.mbm";\r
-                       }\r
-               };\r
-       }\r
similarity index 88%
rename from platform/uiq3/rsc/PicoDrive.rss
rename to platform/uiq3/rsc/picodrive.rss
index 6bbef7c..eb5f5a6 100644 (file)
@@ -3,7 +3,7 @@ NAME PCDR
 #include <eikon.rh>\r
 #include <eikon.rsg>\r
 #include <qikon.rh>\r
-#include <QikCommand.rh>\r
+#include <qikcommand.rh>\r
 #include "picodrive.hrh"\r
 \r
 \r
@@ -89,7 +89,7 @@ RESOURCE QIK_COMMAND_LIST r_app_commands
                QIK_COMMAND { id=EEikCmdPicoSettings;      text="Settings";       type=EQikCommandTypeScreen; namedGroupId=EEikCmdPicoConfig; },\r
                QIK_COMMAND { id=EEikCmdHelpAbout;         text="About";          type=EQikCommandTypeScreen; namedGroupId=EEikCmdPicoConfig; },\r
 \r
-               QIK_COMMAND { id=EEikCmdPicoLoadROM;       text="Load new ROM";   type=EQikCommandTypeScreen; groupId=EEikCmdPicoResume; },\r
+               QIK_COMMAND { id=EEikCmdPicoLoadROM;       text="Load new ROM/ISO";type=EQikCommandTypeScreen; groupId=EEikCmdPicoResume; },\r
                QIK_COMMAND { id=EEikCmdPicoReset;         text="Reset game";     type=EQikCommandTypeScreen; groupId=EEikCmdPicoResume; },\r
                QIK_COMMAND { id=EEikCmdPicoLoadState;     text="Load state";     type=EQikCommandTypeScreen; groupId=EEikCmdPicoResume; },\r
                QIK_COMMAND { id=EEikCmdPicoSaveState;     text="Save state";     type=EQikCommandTypeScreen; groupId=EEikCmdPicoResume; },\r
@@ -137,6 +137,12 @@ RESOURCE ARRAY r_pico_config_pages
          lines = r_pico_config_page_sound;\r
       },\r
       PAGE\r
+      {\r
+         id    = ECtlOptPageMCD;\r
+         text  = "MegaCD";\r
+         lines = r_pico_config_page_mcd;\r
+      },\r
+      PAGE\r
       {\r
          id    = ECtlOptPageMisc;\r
          text  = "Misc";\r
@@ -151,7 +157,7 @@ RESOURCE ARRAY r_pico_config_page_main
    items = {\r
       DLG_LINE\r
       {\r
-             id      = ECtlOptRotationLabel;\r
+          id      = ECtlOptRotationLabel;\r
           type    = EEikCtLabel;\r
           prompt  = "Screen Rotation";\r
           control = LABEL { horiz_align = EEikLabelAlignHLeft; };\r
@@ -167,7 +173,7 @@ RESOURCE ARRAY r_pico_config_page_main
       },\r
       DLG_LINE\r
       {\r
-             id      = ECtlOptScreenModeLabel;\r
+          id      = ECtlOptScreenModeLabel;\r
           type    = EEikCtLabel;\r
           prompt  = "Screen Mode";\r
           control = LABEL { horiz_align = EEikLabelAlignHLeft; };\r
@@ -188,18 +194,6 @@ RESOURCE ARRAY r_pico_config_page_main
          prompt = "Fast renderer (inaccurate)";\r
       },\r
       DLG_LINE\r
-      {\r
-         id     = ECtlOptUseAccTiming;\r
-         type   = EEikCtCheckBox;\r
-         prompt = "Accurate timing (slower)";\r
-      },\r
-      DLG_LINE\r
-      {\r
-         id     = ECtlOptUseAccSprites;\r
-         type   = EEikCtCheckBox;\r
-         prompt = "Accurate sprites (slower)";\r
-      },\r
-      DLG_LINE\r
       {\r
          id     = ECtlOptShowFPS;\r
          type   = EEikCtCheckBox;\r
@@ -220,7 +214,7 @@ RESOURCE ARRAY r_pico_config_page_sound
       },\r
       DLG_LINE\r
       {\r
-            id      = ECtlOptChipSelLabel;\r
+         id      = ECtlOptChipSelLabel;\r
          type    = EEikCtLabel;\r
          prompt  = "Emulate these sound chips:";\r
          control = LABEL { horiz_align = EEikLabelAlignHLeft; };\r
@@ -245,7 +239,7 @@ RESOURCE ARRAY r_pico_config_page_sound
       },\r
       DLG_LINE\r
       {\r
-            id      = ECtlOptSndQLabel;\r
+         id      = ECtlOptSndQLabel;\r
          type    = EEikCtLabel;\r
          prompt  = "Quality (lowest is fastest)";\r
          control = LABEL { horiz_align = EEikLabelAlignHLeft; };\r
@@ -262,6 +256,43 @@ RESOURCE ARRAY r_pico_config_page_sound
 }\r
 \r
 \r
+RESOURCE ARRAY r_pico_config_page_mcd\r
+{\r
+   items = {\r
+      DLG_LINE\r
+      {\r
+         id     = ECtlOptCDcdda;\r
+         type   = EEikCtCheckBox;\r
+         prompt = "CDDA audio";\r
+      },\r
+      DLG_LINE\r
+      {\r
+         id     = ECtlOptCDpcm;\r
+         type   = EEikCtCheckBox;\r
+         prompt = "PCM audio";\r
+      },\r
+      DLG_LINE\r
+      {\r
+         id     = ECtlOptCDramcart;\r
+         type   = EEikCtCheckBox;\r
+         prompt = "SaveRAM cart";\r
+      },\r
+      DLG_LINE\r
+      {\r
+         id     = ECtlOptCDscalerot;\r
+         type   = EEikCtCheckBox;\r
+         prompt = "Scale/Rot. fx (slow)";\r
+      },\r
+      DLG_LINE\r
+      {\r
+         id     = ECtlOptCDbettersync;\r
+         type   = EEikCtCheckBox;\r
+         prompt = "Better sync (slow)";\r
+      }\r
+   };\r
+}\r
+\r
+\r
 RESOURCE ARRAY r_pico_config_page_misc\r
 {\r
    items = {\r
@@ -449,7 +480,7 @@ RESOURCE TBUF r_pico_text_about
                "<p><s=6> <p><f=Corinna><s=12>Version %S, by notaz."\\r
                "<p><s=5> <p><s=10>Port based on UIQ2 version, which is based on PicoDrive 0.030 for Pocket PC by Dave"\\r
                "<p><s=5> <p><f=Corinna><s=11><u>Email</u>: notasas@gmail.com"\\r
-               "<p><f=Corinna><s=10><u>Web</u>: http://notaz.atspace.com"\\r
+               "<p><f=Corinna><s=10><u>Web</u>: http://notaz.gp2x.de"\\r
                "<p><f=Corinna><s=10><u>Dave's Web</u>: http://www.finalburn.com";\r
 }\r
 \r
@@ -557,17 +588,22 @@ RESOURCE ARRAY r_pico_tbuf_credits
        LBUF{txt="- DrZ80, the Z80 emulator written in ARM assembly.";},\r
        LBUF{txt="Homepage: http://reesy.gp32x.de/";},\r
        LBUF{txt="";},\r
-       LBUF{txt="Tatsuyuki Satoh, Jarek Burczynski, MultiArcadeMachineEmulator (MAME) development";},\r
+       LBUF{txt="MultiArcadeMachineEmulator (MAME) development";},\r
        LBUF{txt="- software implementation of Yamaha FM sound generator and";},\r
        LBUF{txt="Texas Instruments SN76489 / SN76496 programmable tone / noise generator";},\r
        LBUF{txt="Homepage: http://www.mame.net/";},\r
        LBUF{txt="";},\r
+       LBUF{txt="Helix community";},\r
+       LBUF{txt="Helix mp3 decoder";},\r
+       LBUF{txt="";},\r
        LBUF{txt="Additional thanks:";},\r
        LBUF{txt="- Charles MacDonald (http://cgfm2.emuviews.com/) for old but still very useful info about genesis hardware.";},\r
        LBUF{txt="- Stéphane Dallongeville for creating Gens and making it open-source.";},\r
        LBUF{txt="- Steve Snake for all that he has done for Genesis emulation scene.";},\r
+       LBUF{txt="- Tasco Deluxe for his reverse engineering work on SVP and some mappers.";},\r
        LBUF{txt="- Bart Trzynadlowski for his SSFII and 68000 docs.";},\r
-       LBUF{txt="- Maze for his research (http://haze.mameworld.info).";},\r
+       LBUF{txt="- Haze for his research (http://haze.mameworld.info).";},\r
+       LBUF{txt="- Lordus, Exophase and Rokas for various ideas.";},\r
        LBUF{txt="- Mark and Jean-loup for zlib library.";},\r
        LBUF{txt="- Peter van Sebille for his various open-source Symbian projects to learn from.";},\r
        LBUF{txt="- Steve Fischer for his open-source Motorola projects.";},\r
diff --git a/platform/uiq3/rsc/picodrive_loc.rss b/platform/uiq3/rsc/picodrive_loc.rss
new file mode 100644 (file)
index 0000000..32b6475
--- /dev/null
@@ -0,0 +1,56 @@
+#include <appinfo.rh>\r
+#include <qikon.hrh>\r
+\r
+#define EViewIdPrimaryView 1\r
+\r
+// This file localise the applications icons and caption\r
+RESOURCE LOCALISABLE_APP_INFO\r
+{\r
+       caption_and_icon =\r
+       {\r
+               CAPTION_AND_ICON_INFO\r
+               {\r
+                       caption = "PicoDrive";\r
+                       // Icons are used to represent applications in the \r
+                       // application launcher and application title bar.\r
+                       // The number_of_icons value identifies how many icons \r
+                       // that exist in the icon_file.\r
+                       number_of_icons = 3;\r
+                       // Using the application icons.\r
+                       icon_file = "\\Resource\\Apps\\PicoDrive.mbm";\r
+               }\r
+       };\r
+\r
+       view_list =\r
+       {\r
+               VIEW_DATA\r
+               {\r
+                       uid=EViewIdPrimaryView;\r
+                       screen_mode=0;\r
+                       caption_and_icon =\r
+                       {\r
+                               CAPTION_AND_ICON_INFO\r
+                               {\r
+                                       caption = "PicoDrive";\r
+                                       number_of_icons = 3;\r
+                                       icon_file = "\\Resource\\Apps\\PicoDrive.mbm";\r
+                               }\r
+                       };   \r
+               },\r
+\r
+               VIEW_DATA\r
+               {\r
+                       uid=EViewIdPrimaryView;\r
+                       screen_mode=EQikScreenModeSmallPortrait;\r
+                       caption_and_icon =\r
+                       {\r
+                               CAPTION_AND_ICON_INFO\r
+                               {\r
+                                       caption = "PicoDrive";\r
+                                       number_of_icons = 3;\r
+                                       icon_file = "\\Resource\\Apps\\PicoDrive.mbm";\r
+                               }\r
+                       };   \r
+               }\r
+       };\r
+}\r
similarity index 83%
rename from platform/uiq3/rsc/PicoDrive_reg.rss
rename to platform/uiq3/rsc/picodrive_reg.rss
index 2b2e4d8..d95f515 100644 (file)
@@ -1,10 +1,10 @@
 // All registration files need to #include appinfo.rh. \r
-#include <AppInfo.rh>\r
+#include <appinfo.rh>\r
 \r
 // All registration files must define UID2, which is always \r
 // KUidAppRegistrationResourceFile, and UID3, which is the application's UID.\r
-UID2 KUidAppRegistrationResourceFile\r
-UID3 0xA00010F3 // application UID\r
+// ? UID2 KUidAppRegistrationResourceFile\r
+// ? UID3 0xA00010F3 // application UID\r
 \r
 // Registration file need to containo an APP_REGISTRATION_INFO resource that\r
 // minimally needs to provide the name of the application binary (using the \r
diff --git a/platform/uiq3/uiq3.mak b/platform/uiq3/uiq3.mak
new file mode 100644 (file)
index 0000000..6221f3f
--- /dev/null
@@ -0,0 +1,167 @@
+#######################################################################
+### App specific part - this must be defined
+#NAME="AnimatedStereogram"
+#VENDOR="Pal Szasz"
+#UID2=100039CE
+#UID3=E0004201
+#EPOCLIBS="euser.lib apparc.lib cone.lib eikcore.lib eikcoctl.lib qikcore.lib fbscli.lib estlib.lib"
+#EPOCROOT=/opt/space/uiq3/
+#######################################################################
+
+APPNAME ?= "UIQ3 Program"
+VENDOR ?= "Somebody"
+UID2 ?= 100039CE
+UID3 ?= E0001001
+VER_MAJ ?= 1
+VER_MIN ?= 0
+STACK ?= 0x1000
+HEAP ?= 0x1000,0x100000
+EPOCROOT ?= /opt/space/uiq3/
+GCCPREF ?= arm-none-symbianelf
+GCCPATH ?= $(EPOCROOT)/gcc
+GCCVER ?= 3.4.3
+
+export EPOCROOT
+
+NAME_ := $(shell echo $(APPNAME) | sed 's: ::g')
+NAME := $(shell perl -e "print lc(\"$(NAME_)\")")
+EPOCLIBS += euser.lib apparc.lib cone.lib eikcore.lib eikcoctl.lib qikcore.lib fbscli.lib estlib.lib qikallocdll.lib
+EPOCREL = $(EPOCROOT)/epoc32/release/armv5
+CC = $(GCCPREF)-gcc
+CXX = $(GCCPREF)-g++
+AS = $(GCCPREF)-as
+LD = $(GCCPREF)-ld
+ELF2E32 = elf2e32
+BMCONV = bmconv
+EPOCRC = EPOCROOT=$(EPOCROOT) epocrc
+
+PATH := $(EPOCROOT)/bin:$(GCCPATH)/bin:$(GCCPATH)/$(GCCPREF)/bin:$(PATH)
+
+# TODO: do we really need -mapcs?
+# -march=armv5t
+CFLAGS += -Wall -pipe -nostdinc -msoft-float
+CFLAGS += -DNDEBUG -D_UNICODE -D__GCCE__  -D__SYMBIAN32__ -D__EPOC32__ -D__MARM__
+CFLAGS += -D__EABI__ -D__MARM_ARMV5__ -D__EXE__ -D__SUPPORT_CPP_EXCEPTIONS__ -D__MARM_ARMV5__
+CFLAGS += -D__PRODUCT_INCLUDE__="$(EPOCROOT)/epoc32/include/variant/uiq_3.0.hrh"
+CFLAGS += -include $(EPOCROOT)/epoc32/include/gcce/gcce.h
+CFLAGS += -I$(EPOCROOT)/epoc32/include -I$(EPOCROOT)/epoc32/include/libc \
+               -I$(EPOCROOT)/epoc32/include/variant -I$(GCCPATH)/lib/gcc/arm-none-symbianelf/$(GCCVER)/include/
+# can't optimize .cpp without -fno-unit-at-a-time
+CXXFLAGS += $(CFLAGS) -c -x c++ -mapcs -Wno-ctor-dtor-privacy -Wno-unknown-pragmas -fexceptions -fno-unit-at-a-time
+
+LDFLAGS +=  -L$(GCCPATH)/lib -L$(GCCPATH)/lib/gcc/$(GCCPREF)/$(GCCVER) -L $(GCCPATH)/$(GCCPREF)/lib
+LDFLAGS +=  --target1-abs --no-undefined -nostdlib  -shared
+LDFLAGS +=  -Ttext 0x8000   -Tdata 0x400000 --default-symver
+LDFLAGS +=  -soname $(NAME){000a0000}\[$(UID3)\].exe --entry _E32Startup -u _E32Startup
+LDFLAGS +=  $(EPOCROOT)/epoc32/release/armv5/urel/eexe.lib
+LDFLAGS +=  -o $(NAME).elf.exe -Map $(NAME).exe.map
+LDFLAGS2 =  $(EPOCREL)/urel/qikalloc.lib $(EPOCREL)/lib/euser.dso
+LDFLAGS2 += $(shell for i in $(EPOCLIBS); do echo -n " $(EPOCREL)/lib/$${i%%.lib}.dso "; done)
+LDFLAGS2 += $(EPOCREL)/urel/usrt2_2.lib
+LDFLAGS2 += $(shell for i in dfpaeabi dfprvct2_2 drtaeabi scppnwdl drtrvct2_2; do echo -n "  $(EPOCREL)/lib/$$i.dso "; done)
+LDFLAGS2 += -lsupc++ -lgcc
+
+E32FLAGS += --sid=0x$(UID3) --uid1=0x1000007a --uid2=0x$(UID2) --uid3=0x$(UID3)
+E32FLAGS += --capability=none --fpu=softvfp --targettype=EXE
+E32FLAGS += --output=$(NAME).exe --elfinput=$(NAME).elf.exe
+E32FLAGS += --stack=$(STACK)
+E32FLAGS += --heap=$(HEAP)
+E32FLAGS += --linkas=$(NAME){000a0000}[$(UID3)].exe --libpath=$(EPOCREL)/lib
+
+EPOCRCFLAGS += -I../inc -I- -I$(EPOCROOT)/epoc32/include -I$(EPOCROOT)/epoc32/include/variant -DLANGUAGE_SC
+
+ICONS ?= $(shell echo ../data/appicon/*.bmp)
+APPICON ?= $(NAME)appicon.mbm
+RSCDIR ?= ../rsc
+REGDIR ?= ../reg
+
+SRCH += $(shell echo ../inc/*.h)
+SRC += $(shell echo ../src/*.cpp)
+SRCRES ?= $(shell echo $(RSCDIR)/*.rss $(RSCDIR)/*.rls $(REGDIR)/*.rss $(REGDIR)/*.rls)
+OBJ ?= $(SRC:.cpp=.o)
+
+.PHONY : all mbm icon_mbm rsc reg loc bin sis run
+
+#all : sis
+
+sis : $(NAME).sis
+
+icon_mbm : $(APPICON)
+
+mbm :
+
+$(NAME)appicon.mbg $(NAME)appicon.mbm : $(ICONS)
+       @echo "Creating multibitmap file..."
+       $(BMCONV) /h$(NAME)appicon.mbg $(NAME)appicon.mbm \
+               /c24../data/appicon/icon_small.bmp\
+               /8../data/appicon/icon_small_mask.bmp\
+               /c24../data/appicon/icon_large.bmp\
+               /8../data/appicon/icon_large_mask.bmp\
+               /c24../data/appicon/icon_xlarge.bmp\
+               /8../data/appicon/icon_xlarge_mask.bmp
+
+rsc : $(RSCDIR)/$(NAME).rsc
+
+$(RSCDIR)/$(NAME).rsc : $(RSCDIR)/$(NAME).rss # $(RSCDIR)/$(NAME).rls
+       @echo "Creating $@ ..."
+       $(EPOCRC) $(EPOCRCFLAGS) -I$(RSCDIR) -u $(RSCDIR)/$(NAME).rss \
+               -o$(RSCDIR)/$(NAME).rsc -h$(RSCDIR)/$(NAME).rsg -t/tmp -l$(RSCDIR)
+
+reg : $(REGDIR)/$(NAME)_reg.rsc
+
+$(REGDIR)/$(NAME)_reg.rsc : $(REGDIR)/$(NAME)_reg.rss
+       @echo "Creating $@ ..."
+       RC_UID2=0x101f8021 RC_UID3=0x$(UID3) $(EPOCRC) $(EPOCRCFLAGS) -I$(REGDIR) \
+               -u $(REGDIR)/$(NAME)_reg.rss -o$(REGDIR)/$(NAME)_reg.rsc -h$(REGDIR)/$(NAME)_reg.rsg -t/tmp  -l$(REGDIR)
+
+loc : $(REGDIR)/$(NAME)_loc.rsc
+
+$(REGDIR)/$(NAME)_loc.rsc : $(REGDIR)/$(NAME)_loc.rss
+       @echo "Creating $@ ..."
+       $(EPOCRC) $(EPOCRCFLAGS) -I$(REGDIR) \
+               -u $(REGDIR)/$(NAME)_loc.rss -o$(REGDIR)/$(NAME)_loc.rsc -h$(REGDIR)/$(NAME)_loc.rsg -t/tmp  -l$(REGDIR)
+
+bin : bin_elf
+       @echo "Elf -> E32"
+       $(ELF2E32) $(E32FLAGS)
+
+bin_elf : $(NAME).elf.exe
+
+$(NAME).elf.exe : $(OBJ) $(EXTRALIB)
+       @echo "Linking..."
+       $(LD) $(LDFLAGS) $(OBJ) $(EXTRALIB) $(LDFLAGS2)
+
+.cpp.o :
+       @echo "Compiling $< ..."
+       $(CXX) $(CXXFLAGS) -o $@ $<
+
+$(NAME).sis : icon_mbm mbm rsc reg loc bin
+       rm -f $(NAME).sis
+       makesis $(NAME).pkg
+       mv $(NAME).SIS $(NAME).sis
+
+#cat $(EPOCROOT)/extra/in.pkg extra.pkg | \
+#              sed "s:APPNAME:$(APPNAME):g" | \
+#              sed "s:NAME:$(NAME):g" | \
+#              sed "s:VER_MAJ:$(VER_MAJ):g" | \
+#              sed "s:VER_MIN:$(VER_MIN):g" | \
+#              sed "s:UID3:$(UID3):g" | \
+#              sed "s:VENDOR:$(VENDOR):g" > $(NAME).pkg
+
+run : sis
+       xterm -e "to-phone m600 $(NAME).sis"
+
+-include .deps
+
+.deps : $(SRC) $(SRCH)
+       echo > $@
+       $(CXX) -M -DDEPS $(SRC) $(CXXFLAGS) >> $@
+
+clean :
+       rm -f $(NAME).exe $(NAME).elf.exe $(OBJ) tags .deps $(NAME).exe.map
+       rm -f *.bkp ../src/*.bkp ../inc/*.bkp $(RSCDIR)/*.bkp $(REGDIR)/*.bkp
+       rm -f $(RSCDIR)/*.rsc $(RSCDIR)/*.rsg
+       rm -f $(REGDIR)/*.rsc $(REGDIR)/*.rsg
+       rm -f $(APPICON) $(NAME)appicon.mbg $(NAME).mbg
+
+
index 007068a..4388a01 100644 (file)
@@ -3,8 +3,8 @@
 #ifndef __VERSION_H\r
 #define __VERSION_H\r
 \r
-#define KPicoMajorVersionNumber 0\r
-#define KPicoMinorVersionNumber 96\r
+#define KPicoMajorVersionNumber 1\r
+#define KPicoMinorVersionNumber 51\r
 #define KPicoBuildNumber 0\r
 \r
 #endif                 /* __VERSION_H */\r
index c055969..ddf59aa 100644 (file)
@@ -5,11 +5,7 @@
 #include <ctype.h>\r
 #include <assert.h>\r
 \r
-#ifdef __SYMBIAN32__\r
-#include <ezlib.h>\r
-#else\r
 #include "zlib/zlib.h"\r
-#endif\r
 \r
 /* public globals */\r
 //int  gUnzipQuiet = 0;                /* flag controls error messages */\r
index 3e7919b..7f3e935 100644 (file)
@@ -6,11 +6,7 @@
 #include <string.h>
 #include <errno.h>
 
-#ifdef __SYMBIAN32__
-#include <ezlib.h>
-#else
 #include "zlib/zlib.h"
-#endif
 
 
 #define errormsg(str1,def,fname) printf("%s: " #def ": " str1 "\n", fname);
index 03a9431..6f799fd 100644 (file)
@@ -305,6 +305,10 @@ typedef uLong FAR uLongf;
 #  define NO_vsnprintf
 #endif
 
+#if defined(__EPOC32__)
+#  define NO_vsnprintf
+#endif
+
 #if defined(__MVS__)
 #  define NO_vsnprintf
 #  ifdef FAR