for (y=0;y<224;y++) PicoLine(y);\r
}\r
\r
-int PicoGetStat(pstat_t which)\r
+void PicoGetInternal(pint_t which, pint_ret_t *r)\r
{\r
switch (which)\r
{\r
- case PS_PAL: return Pico.m.pal;\r
- case PS_40_CELL: return Pico.video.reg[12]&1;\r
- case PS_240_LINES: return Pico.m.pal && (Pico.video.reg[1]&8);\r
+ case PI_ROM: r->vptr = Pico.rom; break;\r
+ case PI_ISPAL: r->vint = Pico.m.pal; break;\r
+ case PI_IS40_CELL: r->vint = Pico.video.reg[12]&1; break;\r
+ case PI_IS240_LINES: r->vint = Pico.m.pal && (Pico.video.reg[1]&8); break;\r
}\r
- return 0;\r
}\r
\r
// callback to output message from emu\r
extern int PicoPad[2]; // Joypads, format is MXYZ SACB RLDU\r
extern void (*PicoWriteSound)(int len); // called once per frame at the best time to send sound buffer (PsndOut) to hardware\r
extern void (*PicoMessage)(const char *msg); // callback to output text message from emu\r
-typedef enum { PS_PAL, PS_40_CELL, PS_240_LINES } pstat_t;\r
-int PicoGetStat(pstat_t which);\r
+typedef enum { PI_ROM, PI_ISPAL, PI_IS40_CELL, PI_IS240_LINES } pint_t;\r
+typedef union { int vint; void *vptr; } pint_ret_t;\r
+void PicoGetInternal(pint_t which, pint_ret_t *ret);\r
\r
// cd/Pico.c\r
extern void (*PicoMCDopenTray)(void);\r
* (c)
*/
+#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "config.h"
+#include "lprintf.h"
+
+static char *mystrip(char *str);
+
+#ifndef _MSC_VER
+
#include "menu.h"
#include "emu.h"
-#include "lprintf.h"
#include <Pico/Pico.h>
extern menu_entry opt_entries[];
#define NL "\r\n"
-static char *mystrip(char *str)
-{
- int i, len;
-
- len = strlen(str);
- for (i = 0; i < len; i++)
- if (str[i] != ' ') break;
- if (i > 0) memmove(str, str + i, len - i + 1);
-
- len = strlen(str);
- for (i = len - 1; i >= 0; i--)
- if (str[i] != ' ') break;
- str[i+1] = 0;
-
- return str;
-}
-
-
static int seek_sect(FILE *f, const char *section)
{
char line[128], *tmp;
return ret;
}
-
int config_readsect(const char *fname, const char *section)
{
- char line[128], *var, *val, *tmp;
- int len, i, ret;
+ char line[128], *var, *val;
FILE *f;
+ int ret;
f = fopen(fname, "r");
if (f == NULL) return -1;
while (!feof(f))
{
- tmp = fgets(line, sizeof(line), f);
- if (tmp == NULL) break;
-
- if (line[0] == '[') break; // other section
-
- // strip comments, linefeed, spaces..
- len = strlen(line);
- for (i = 0; i < len; i++)
- if (line[i] == '#' || line[i] == '\r' || line[i] == '\n') { line[i] = 0; break; }
- mystrip(line);
- len = strlen(line);
- if (len <= 0) continue;
-
- // get var and val
- for (i = 0; i < len; i++)
- if (line[i] == '=') break;
- if (i >= len || strchr(&line[i+1], '=') != NULL) {
- lprintf("config_readsect: can't parse: %s\n", line);
- continue;
- }
- line[i] = 0;
- var = line;
- val = &line[i+1];
- mystrip(var);
- mystrip(val);
- if (strlen(var) == 0 || (strlen(val) == 0 && strncasecmp(var, "bind", 4) != 0)) {
- lprintf("config_readsect: something's empty: \"%s\" = \"%s\"\n", var, val);
- continue;
- }
+ ret = config_get_var_val(f, line, sizeof(line), &var, &val);
+ if (ret == 0) break;
+ if (ret == -1) continue;
parse(var, val);
}
return 0;
}
+#endif // _MSC_VER
+
+static char *mystrip(char *str)
+{
+ int i, len;
+
+ len = strlen(str);
+ for (i = 0; i < len; i++)
+ if (str[i] != ' ') break;
+ if (i > 0) memmove(str, str + i, len - i + 1);
+
+ len = strlen(str);
+ for (i = len - 1; i >= 0; i--)
+ if (str[i] != ' ') break;
+ str[i+1] = 0;
+
+ return str;
+}
+
+/* returns:
+ * 0 - EOF, end
+ * 1 - parsed ok
+ * -1 - failed to parse line
+ */
+int config_get_var_val(void *file, char *line, int lsize, char **rvar, char **rval)
+{
+ char *var, *val, *tmp;
+ FILE *f = file;
+ int len, i;
+
+ tmp = fgets(line, lsize, f);
+ if (tmp == NULL) return 0;
+
+ if (line[0] == '[') return 0; // other section
+
+ // strip comments, linefeed, spaces..
+ len = strlen(line);
+ for (i = 0; i < len; i++)
+ if (line[i] == '#' || line[i] == '\r' || line[i] == '\n') { line[i] = 0; break; }
+ mystrip(line);
+ len = strlen(line);
+ if (len <= 0) return -1;;
+
+ // get var and val
+ for (i = 0; i < len; i++)
+ if (line[i] == '=') break;
+ if (i >= len || strchr(&line[i+1], '=') != NULL) {
+ lprintf("config_readsect: can't parse: %s\n", line);
+ return -1;
+ }
+ line[i] = 0;
+ var = line;
+ val = &line[i+1];
+ mystrip(var);
+ mystrip(val);
+
+#ifndef _MSC_VER
+ if (strlen(var) == 0 || (strlen(val) == 0 && strncasecmp(var, "bind", 4) != 0)) {
+ lprintf("config_readsect: something's empty: \"%s\" = \"%s\"\n", var, val);
+ return -1;;
+ }
+#endif
+
+ *rvar = var;
+ *rval = val;
+ return 1;
+}
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
int config_writesect(const char *fname, const char *section);
int config_writelrom(const char *fname);
int config_readsect(const char *fname, const char *section);
int config_readlrom(const char *fname);
int config_havesect(const char *fname, const char *section);
+int config_get_var_val(void *file, char *line, int lsize, char **rvar, char **rval);
+
+#ifdef __cplusplus
+}
+#endif
\r
static void PostProcess()\r
{\r
- static int lock_to_1_1_prev = 0, is_40_prev = 0;\r
- int is_40 = PicoGetStat(PS_40_CELL);\r
+ static int lock_to_1_1_prev = 0, is_40_prev = -1;\r
+ int is_40;\r
+ PicoGetInternal(PI_IS40_CELL, (pint_ret_t *)&is_40);\r
if (lock_to_1_1)\r
{\r
if (is_40 != is_40_prev || !lock_to_1_1_prev)\r
#include <crtdbg.h>\r
#include <commdlg.h>\r
#include "../../common/readpng.h"\r
+#include "../../common/config.h"\r
\r
char *romname=NULL;\r
HWND FrameWnd=NULL;\r
static HBITMAP ppad_bmp = 0;\r
static HBITMAP ppage_bmps[7] = { 0, };\r
static char rom_name[0x20*3+1];\r
+static int main_wnd_as_pad = 0;\r
\r
static void UpdateRect()\r
{\r
\r
static int extract_rom_name(char *dest, const unsigned char *src, int len)\r
{\r
- char *p = dest, s_old = 0;\r
+ char *p = dest, s_old = 0x20;\r
int i;\r
\r
for (i = len - 1; i >= 0; i--)\r
return p - dest;\r
}\r
\r
+static void check_name_alias(const char *afname)\r
+{\r
+ char buff[256], *var, *val;\r
+ FILE *f;\r
+ int ret;\r
+\r
+ f = fopen(afname, "r");\r
+ if (f == NULL) return;\r
+\r
+ while (1)\r
+ {\r
+ ret = config_get_var_val(f, buff, sizeof(buff), &var, &val);\r
+ if (ret == 0) break;\r
+ if (ret == -1) continue;\r
+\r
+ if (strcmp(rom_name, var) == 0) {\r
+ lprintf("rom aliased: \"%s\" -> \"%s\"\n", rom_name, val);\r
+ strncpy(rom_name, val, sizeof(rom_name));\r
+ break;\r
+ }\r
+ }\r
+ fclose(f);\r
+}\r
\r
static HBITMAP png2hb(const char *fname, int is_480)\r
{\r
return bmp;\r
}\r
\r
-static void PrepareForROM(unsigned char *rom_data)\r
+static void PrepareForROM(void)\r
{\r
+ unsigned char *rom_data = NULL;\r
int i, ret, show = PicoAHW & PAHW_PICO;\r
+ \r
+ PicoGetInternal(PI_ROM, (pint_ret_t *) &rom_data);\r
EnableMenuItem(mmain, 2, MF_BYPOSITION|(show ? MF_ENABLED : MF_GRAYED));\r
ShowWindow(PicoPadWnd, show ? SW_SHOWNA : SW_HIDE);\r
ShowWindow(PicoSwWnd, show ? SW_SHOWNA : SW_HIDE);\r
ppad_bmp = png2hb(path, 0);\r
}\r
\r
+ strcpy(p, "pico\\alias.txt");\r
+ check_name_alias(path);\r
+\r
for (i = 0; i < 7; i++) {\r
if (ppage_bmps[i] != NULL) DeleteObject(ppage_bmps[i]);\r
sprintf(p, "pico\\%s_%i.png", rom_name, i);\r
ppage_bmps[i] = png2hb(path, 1);\r
}\r
+ // games usually don't have page 6, so just duplicate page 5.\r
+ if (ppage_bmps[6] == NULL && ppage_bmps[5] != NULL) {\r
+ sprintf(p, "pico\\%s_5.png", rom_name);\r
+ ppage_bmps[6] = png2hb(path, 1);\r
+ }\r
}\r
}\r
\r
PicoCartUnload();\r
PicoCartInsert(rom_data_new, rom_size);\r
\r
- PrepareForROM(rom_data_new);\r
+ PrepareForROM();\r
\r
rom_loaded = 1;\r
romname = rompath;\r
ShowWindow((LOWORD(wparam)&1) ? PicoPadWnd : PicoSwWnd, i ? SW_SHOWNA : SW_HIDE);\r
CheckMenuItem(mpicohw, LOWORD(wparam), i ? MF_CHECKED : MF_UNCHECKED);\r
return 0;\r
+ case 1212:\r
+ main_wnd_as_pad = !main_wnd_as_pad;\r
+ CheckMenuItem(mpicohw, 1212, main_wnd_as_pad ? MF_CHECKED : MF_UNCHECKED);\r
+ return 0;\r
case 1220:\r
case 1221:\r
case 1222:\r
PicoPicohw.pen_pos[1] |= 0x8000;\r
PicoPadAdd = 0;\r
break;\r
+ case WM_LBUTTONDOWN: PicoPadAdd |= 0x20; return 0;\r
+ case WM_LBUTTONUP: PicoPadAdd &= ~0x20; return 0;\r
+ case WM_MOUSEMOVE:\r
+ if (!main_wnd_as_pad) break;\r
+ PicoPicohw.pen_pos[0] = 0x03c + (320 * LOWORD(lparam) / (FrameRectMy.right - FrameRectMy.left));\r
+ PicoPicohw.pen_pos[1] = 0x1fc + (232 * HIWORD(lparam) / (FrameRectMy.bottom - FrameRectMy.top));\r
+ SetTimer(FrameWnd, 100, 1000, NULL);\r
+ break;\r
}\r
\r
return DefWindowProc(hwnd,msg,wparam,lparam);\r
if (ppage_bmps[PicoPicohw.page] == NULL)\r
{\r
SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));\r
- SetTextColor(hdc, RGB(255, 255, 255));\r
- SetBkColor(hdc, RGB(0, 0, 0));\r
+ SetTextColor(hdc, RGB(255, 255, 255));\r
+ SetBkColor(hdc, RGB(0, 0, 0));\r
TextOut(hdc, 2, 2, "missing PNGs for", 16);\r
TextOut(hdc, 2, 18, rom_name, strlen(rom_name));\r
}\r
mpicohw = CreateMenu();\r
InsertMenu(mpicohw, -1, MF_BYPOSITION|MF_STRING, 1210, "Show &Storyware");\r
InsertMenu(mpicohw, -1, MF_BYPOSITION|MF_STRING, 1211, "Show &Drawing pad");\r
+ InsertMenu(mpicohw, -1, MF_BYPOSITION|MF_STRING, 1212, "&Main window as pad");\r
InsertMenu(mpicohw, -1, MF_BYPOSITION|MF_SEPARATOR, 0, NULL);\r
InsertMenu(mpicohw, -1, MF_BYPOSITION|MF_STRING, 1220, "Title page (&0)");\r
InsertMenu(mpicohw, -1, MF_BYPOSITION|MF_STRING, 1221, "Page &1");\r
# common\r
#OBJS += platform\common\emu.obj platform\common\menu.obj platform\common\fonts.obj \r
# platform\common\mp3_helix.obj\r
-OBJ = $(OBJ) $(R)platform\common\readpng.obj\r
+OBJ = $(OBJ) $(R)platform\common\readpng.obj $(R)platform\common\config.obj\r
\r
# Pico\r
OBJ = $(OBJ) $(R)Pico\Area.obj $(R)Pico\Cart.obj $(R)Pico\Memory.obj $(R)Pico\Misc.obj $(R)Pico\Pico.obj $(R)Pico\Sek.obj \\r
1.40a - Tasco Deluxe's dithering fix.\r
1.40b - Perspective fix thanks to Pierpaolo Prazzoli's info.\r
1.45 - Added preliminary Sega Pico emulation.\r
+1.45a - Few bugfixes and additions.\r
\r
\r
Controls\r
-#define VERSION "1.45"\r
+#define VERSION "1.45a"\r
\r