1.45a Pico win32, code move

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@457 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2008-05-22 20:52:23 +00:00
parent 582890c000
commit 4609d0cdb8
9 changed files with 158 additions and 67 deletions

View file

@ -56,8 +56,9 @@ static void UpdateSound(int len)
static void PostProcess()
{
static int lock_to_1_1_prev = 0, is_40_prev = 0;
int is_40 = PicoGetStat(PS_40_CELL);
static int lock_to_1_1_prev = 0, is_40_prev = -1;
int is_40;
PicoGetInternal(PI_IS40_CELL, (pint_ret_t *)&is_40);
if (lock_to_1_1)
{
if (is_40 != is_40_prev || !lock_to_1_1_prev)

View file

@ -3,6 +3,7 @@
#include <crtdbg.h>
#include <commdlg.h>
#include "../../common/readpng.h"
#include "../../common/config.h"
char *romname=NULL;
HWND FrameWnd=NULL;
@ -17,6 +18,7 @@ static int rom_loaded = 0;
static HBITMAP ppad_bmp = 0;
static HBITMAP ppage_bmps[7] = { 0, };
static char rom_name[0x20*3+1];
static int main_wnd_as_pad = 0;
static void UpdateRect()
{
@ -29,7 +31,7 @@ static void UpdateRect()
static int extract_rom_name(char *dest, const unsigned char *src, int len)
{
char *p = dest, s_old = 0;
char *p = dest, s_old = 0x20;
int i;
for (i = len - 1; i >= 0; i--)
@ -58,6 +60,29 @@ static int extract_rom_name(char *dest, const unsigned char *src, int len)
return p - dest;
}
static void check_name_alias(const char *afname)
{
char buff[256], *var, *val;
FILE *f;
int ret;
f = fopen(afname, "r");
if (f == NULL) return;
while (1)
{
ret = config_get_var_val(f, buff, sizeof(buff), &var, &val);
if (ret == 0) break;
if (ret == -1) continue;
if (strcmp(rom_name, var) == 0) {
lprintf("rom aliased: \"%s\" -> \"%s\"\n", rom_name, val);
strncpy(rom_name, val, sizeof(rom_name));
break;
}
}
fclose(f);
}
static HBITMAP png2hb(const char *fname, int is_480)
{
@ -89,9 +114,12 @@ static HBITMAP png2hb(const char *fname, int is_480)
return bmp;
}
static void PrepareForROM(unsigned char *rom_data)
static void PrepareForROM(void)
{
unsigned char *rom_data = NULL;
int i, ret, show = PicoAHW & PAHW_PICO;
PicoGetInternal(PI_ROM, (pint_ret_t *) &rom_data);
EnableMenuItem(mmain, 2, MF_BYPOSITION|(show ? MF_ENABLED : MF_GRAYED));
ShowWindow(PicoPadWnd, show ? SW_SHOWNA : SW_HIDE);
ShowWindow(PicoSwWnd, show ? SW_SHOWNA : SW_HIDE);
@ -121,11 +149,19 @@ static void PrepareForROM(unsigned char *rom_data)
ppad_bmp = png2hb(path, 0);
}
strcpy(p, "pico\\alias.txt");
check_name_alias(path);
for (i = 0; i < 7; i++) {
if (ppage_bmps[i] != NULL) DeleteObject(ppage_bmps[i]);
sprintf(p, "pico\\%s_%i.png", rom_name, i);
ppage_bmps[i] = png2hb(path, 1);
}
// games usually don't have page 6, so just duplicate page 5.
if (ppage_bmps[6] == NULL && ppage_bmps[5] != NULL) {
sprintf(p, "pico\\%s_5.png", rom_name);
ppage_bmps[6] = png2hb(path, 1);
}
}
}
@ -173,7 +209,7 @@ static void LoadROM(const char *cmdpath)
PicoCartUnload();
PicoCartInsert(rom_data_new, rom_size);
PrepareForROM(rom_data_new);
PrepareForROM();
rom_loaded = 1;
romname = rompath;
@ -231,6 +267,10 @@ static LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
ShowWindow((LOWORD(wparam)&1) ? PicoPadWnd : PicoSwWnd, i ? SW_SHOWNA : SW_HIDE);
CheckMenuItem(mpicohw, LOWORD(wparam), i ? MF_CHECKED : MF_UNCHECKED);
return 0;
case 1212:
main_wnd_as_pad = !main_wnd_as_pad;
CheckMenuItem(mpicohw, 1212, main_wnd_as_pad ? MF_CHECKED : MF_UNCHECKED);
return 0;
case 1220:
case 1221:
case 1222:
@ -269,6 +309,14 @@ static LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
PicoPicohw.pen_pos[1] |= 0x8000;
PicoPadAdd = 0;
break;
case WM_LBUTTONDOWN: PicoPadAdd |= 0x20; return 0;
case WM_LBUTTONUP: PicoPadAdd &= ~0x20; return 0;
case WM_MOUSEMOVE:
if (!main_wnd_as_pad) break;
PicoPicohw.pen_pos[0] = 0x03c + (320 * LOWORD(lparam) / (FrameRectMy.right - FrameRectMy.left));
PicoPicohw.pen_pos[1] = 0x1fc + (232 * HIWORD(lparam) / (FrameRectMy.bottom - FrameRectMy.top));
SetTimer(FrameWnd, 100, 1000, NULL);
break;
}
return DefWindowProc(hwnd,msg,wparam,lparam);
@ -319,8 +367,8 @@ static LRESULT CALLBACK PicoSwWndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lp
if (ppage_bmps[PicoPicohw.page] == NULL)
{
SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT));
SetTextColor(hdc, RGB(255, 255, 255));
SetBkColor(hdc, RGB(0, 0, 0));
SetTextColor(hdc, RGB(255, 255, 255));
SetBkColor(hdc, RGB(0, 0, 0));
TextOut(hdc, 2, 2, "missing PNGs for", 16);
TextOut(hdc, 2, 18, rom_name, strlen(rom_name));
}
@ -427,6 +475,7 @@ static int FrameInit()
mpicohw = CreateMenu();
InsertMenu(mpicohw, -1, MF_BYPOSITION|MF_STRING, 1210, "Show &Storyware");
InsertMenu(mpicohw, -1, MF_BYPOSITION|MF_STRING, 1211, "Show &Drawing pad");
InsertMenu(mpicohw, -1, MF_BYPOSITION|MF_STRING, 1212, "&Main window as pad");
InsertMenu(mpicohw, -1, MF_BYPOSITION|MF_SEPARATOR, 0, NULL);
InsertMenu(mpicohw, -1, MF_BYPOSITION|MF_STRING, 1220, "Title page (&0)");
InsertMenu(mpicohw, -1, MF_BYPOSITION|MF_STRING, 1221, "Page &1");

View file

@ -23,7 +23,7 @@ OBJ = Emu.obj Input.obj Main.obj Direct.obj DSound.obj Loop.obj
# common
#OBJS += platform\common\emu.obj platform\common\menu.obj platform\common\fonts.obj
# platform\common\mp3_helix.obj
OBJ = $(OBJ) $(R)platform\common\readpng.obj
OBJ = $(OBJ) $(R)platform\common\readpng.obj $(R)platform\common\config.obj
# Pico
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 \

View file

@ -21,6 +21,7 @@ Releases
1.40a - Tasco Deluxe's dithering fix.
1.40b - Perspective fix thanks to Pierpaolo Prazzoli's info.
1.45 - Added preliminary Sega Pico emulation.
1.45a - Few bugfixes and additions.
Controls

View file

@ -1,2 +1,2 @@
#define VERSION "1.45"
#define VERSION "1.45a"