mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 07:17:45 -04:00
updating win32 port
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@338 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
10d84cb275
commit
4b2b67ebc7
8 changed files with 125 additions and 129 deletions
|
@ -75,7 +75,7 @@ int DirectInit()
|
|||
|
||||
ret=TexScreenInit(); if (ret) return 1;
|
||||
|
||||
FontInit();
|
||||
//FontInit();
|
||||
|
||||
Device->SetRenderState(D3DRS_LIGHTING,0); // Turn off lighting
|
||||
|
||||
|
@ -87,8 +87,8 @@ int DirectInit()
|
|||
|
||||
void DirectExit()
|
||||
{
|
||||
FontExit();
|
||||
TexScreenExit();
|
||||
//FontExit();
|
||||
//TexScreenExit();
|
||||
|
||||
RELEASE(VertexBuffer)
|
||||
RELEASE(DirectBack)
|
||||
|
|
|
@ -1,39 +1,17 @@
|
|||
|
||||
#include "app.h"
|
||||
|
||||
extern "C" {
|
||||
struct Pico
|
||||
{
|
||||
unsigned char ram[0x10000]; // 0x00000 scratch ram
|
||||
unsigned short vram[0x8000]; // 0x10000
|
||||
unsigned char zram[0x2000]; // 0x20000 Z80 ram
|
||||
unsigned char ioports[0x10];
|
||||
unsigned int pad[0x3c]; // unused
|
||||
unsigned short cram[0x40]; // 0x22100
|
||||
unsigned short vsram[0x40]; // 0x22180
|
||||
|
||||
unsigned char *rom; // 0x22200
|
||||
unsigned int romsize; // 0x22204
|
||||
|
||||
// struct PicoMisc m;
|
||||
// struct PicoVideo video;
|
||||
};
|
||||
extern struct Pico Pico;
|
||||
}
|
||||
|
||||
unsigned short *EmuScreen=NULL;
|
||||
extern "C" unsigned short *framebuff=NULL;
|
||||
int EmuWidth=0,EmuHeight=0;
|
||||
static int frame=0;
|
||||
static int EmuScan(unsigned int num, void *sdata);
|
||||
unsigned char *PicoDraw2FB = NULL;
|
||||
|
||||
int EmuInit()
|
||||
{
|
||||
int len=0;
|
||||
|
||||
// PicoOpt=-1;
|
||||
// PsndRate=44100; PsndLen=DSoundSeg;
|
||||
|
||||
PicoInit();
|
||||
|
||||
// Allocate screen:
|
||||
|
@ -43,6 +21,8 @@ int EmuInit()
|
|||
framebuff=(unsigned short *)malloc((8+320)*(8+224+8)*2);
|
||||
memset(EmuScreen,0,len);
|
||||
|
||||
PicoDraw2FB = (unsigned char *)framebuff;
|
||||
PicoDrawSetColorFormat(1);
|
||||
PicoScan=EmuScan;
|
||||
|
||||
return 0;
|
||||
|
@ -70,7 +50,7 @@ static int EmuScan(unsigned int num, void *sdata)
|
|||
pd=EmuScreen+(num<<8)+(num<<6); end=pd+320;
|
||||
ps=(unsigned short *)sdata;
|
||||
|
||||
do { *pd++=(unsigned short)PicoCram(*ps++); } while (pd<end);
|
||||
do { *pd++=*ps++; } while (pd<end);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -92,21 +72,26 @@ int EmuFrame()
|
|||
frame++;
|
||||
PsndOut=(short *)DSoundNext; PicoFrame(); PsndOut=NULL;
|
||||
|
||||
// rendermode2
|
||||
if(PicoOpt&0x10) {
|
||||
unsigned short *pd=EmuScreen;
|
||||
unsigned char *ps=(unsigned char*)framebuff+328*8;
|
||||
|
||||
unsigned short palHigh[0x40];
|
||||
for(int i = 0; i < 0x40; i++)
|
||||
palHigh[i]=(unsigned short)PicoCram(Pico.cram[i]);
|
||||
|
||||
for(int y=0; y < 224; y++) {
|
||||
ps+=8;
|
||||
for(int x=0; x < 320; x++)
|
||||
*pd++=palHigh[*ps++];
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int mp3_get_offset(void) // 0-1023
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mp3_update(int *buffer, int length, int stereo)
|
||||
{
|
||||
}
|
||||
|
||||
void mp3_start_play(FILE *f, int pos)
|
||||
{
|
||||
}
|
||||
|
||||
int mp3_get_bitrate(FILE *f, int size)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ static int DeviceRead()
|
|||
}
|
||||
else if(!sblobked && GetAsyncKeyState(VK_ESCAPE)) {
|
||||
DSoundMute();
|
||||
FILE *rom = 0;
|
||||
pm_file *rom = 0;
|
||||
OPENFILENAME of; ZeroMemory(&of, sizeof(OPENFILENAME));
|
||||
of.lStructSize = sizeof(OPENFILENAME);
|
||||
of.lpstrFilter = "ROMs\0*.smd;*.bin;*.gen\0";
|
||||
|
@ -135,27 +135,17 @@ static int DeviceRead()
|
|||
of.nMaxFile = MAX_PATH;
|
||||
of.Flags = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
|
||||
GetOpenFileName(&of);
|
||||
rom = fopen(romname, "rb");
|
||||
rom = pm_open(romname);
|
||||
DSoundUnMute();
|
||||
if(!rom) return 1;
|
||||
PicoCartLoad(rom, &rom_data, &rom_size);
|
||||
PicoCartInsert(rom_data, rom_size);
|
||||
fclose(rom);
|
||||
sblobked = 1;
|
||||
}
|
||||
else if(!sblobked && GetAsyncKeyState(VK_BACK)) {
|
||||
if(frameStep) frameStep=0;
|
||||
else fastForward^=1;
|
||||
sblobked = 1;
|
||||
}
|
||||
else if(!sblobked && GetAsyncKeyState(VK_OEM_5)) {
|
||||
frameStep=3;
|
||||
pm_close(rom);
|
||||
sblobked = 1;
|
||||
}
|
||||
else
|
||||
sblobked = GetAsyncKeyState(VK_F6) | GetAsyncKeyState(VK_F9) |
|
||||
GetAsyncKeyState(VK_TAB) | GetAsyncKeyState(VK_ESCAPE) |
|
||||
GetAsyncKeyState(VK_BACK) | GetAsyncKeyState(VK_OEM_5);
|
||||
GetAsyncKeyState(VK_TAB) | GetAsyncKeyState(VK_ESCAPE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,19 +1,6 @@
|
|||
#include "app.h"
|
||||
#include "FileMenu.h"
|
||||
//#include "FileMenu.h"
|
||||
|
||||
// sram
|
||||
struct PicoSRAM
|
||||
{
|
||||
unsigned char *data; // actual data
|
||||
unsigned int start; // start address in 68k address space
|
||||
unsigned int end;
|
||||
unsigned char resize; // 1=SRAM size changed and needs to be reallocated on PicoReset
|
||||
unsigned char reg_back; // copy of Pico.m.sram_reg to set after reset
|
||||
unsigned char changed;
|
||||
unsigned char pad;
|
||||
};
|
||||
|
||||
extern "C" PicoSRAM SRam;
|
||||
extern char *romname;
|
||||
int fastForward=0;
|
||||
int frameStep=0;
|
||||
|
@ -21,7 +8,7 @@ int frameStep=0;
|
|||
char LoopQuit=0;
|
||||
static FILE *DebugFile=NULL;
|
||||
int LoopMode=0;
|
||||
static void UpdateSound();
|
||||
static void UpdateSound(int len);
|
||||
|
||||
int LoopInit()
|
||||
{
|
||||
|
@ -35,14 +22,14 @@ int LoopInit()
|
|||
//PsndLen=PsndRate/60; // calculated later by pico itself
|
||||
|
||||
// Init Direct3D:
|
||||
ret=DirectInit(); if (ret) return 1;
|
||||
ret=DirectInit(); if (ret) { error("Direct3D init failed"); return 1; }
|
||||
InputInit();
|
||||
|
||||
// Init DirectSound:
|
||||
//DSoundInit();
|
||||
|
||||
ret=EmuInit(); if (ret) return 1;
|
||||
FileMenu.init();
|
||||
//FileMenu.init();
|
||||
|
||||
LoopMode=8;
|
||||
PicoWriteSound = UpdateSound;
|
||||
|
@ -50,39 +37,13 @@ int LoopInit()
|
|||
return 0;
|
||||
}
|
||||
|
||||
void preLoopInit()
|
||||
{
|
||||
romname[strlen(romname)-3] = 0;
|
||||
strcat(romname, "srm");
|
||||
int sram_size = SRam.end-SRam.start+1;
|
||||
if(SRam.reg_back & 4) sram_size=0x2000;
|
||||
FILE *f = fopen(romname, "rb");
|
||||
if(f && SRam.data)
|
||||
fread(SRam.data, 1, sram_size, f);
|
||||
if(f) fclose(f);
|
||||
}
|
||||
|
||||
extern "C" char *debugString();
|
||||
|
||||
void LoopExit()
|
||||
{
|
||||
dprintf(debugString());
|
||||
|
||||
romname[strlen(romname)-3] = 0;
|
||||
strcat(romname, "srm");
|
||||
int sram_size = SRam.end-SRam.start+1;
|
||||
if(SRam.reg_back & 4) sram_size=0x2000;
|
||||
for(; sram_size > 0; sram_size--)
|
||||
if(SRam.data[sram_size-1]) break;
|
||||
if(sram_size) {
|
||||
FILE *f = fopen(romname, "wb");
|
||||
if(f) {
|
||||
fwrite(SRam.data, 1, sram_size, f);
|
||||
fclose(f);
|
||||
}
|
||||
}
|
||||
|
||||
FileMenu.exit();
|
||||
//FileMenu.exit();
|
||||
EmuExit();
|
||||
DSoundExit(); PsndLen=0;
|
||||
InputExit();
|
||||
|
@ -113,6 +74,7 @@ static int DoGame()
|
|||
}
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
/*
|
||||
static int MenuUpdate()
|
||||
{
|
||||
int delta=0;
|
||||
|
@ -149,6 +111,7 @@ static int MenuRender()
|
|||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
|
@ -161,9 +124,9 @@ static int ModeUpdate()
|
|||
|
||||
if (DSoundNext) memset(DSoundNext,0,PsndLen<<2);
|
||||
|
||||
if (LoopMode==2) { FileMenu.scan(); LoopMode++; return 0; }
|
||||
if (LoopMode==3) { MenuUpdate(); return 0; }
|
||||
if (LoopMode==4) { LightCalUpdate(); return 0; }
|
||||
// if (LoopMode==2) { FileMenu.scan(); LoopMode++; return 0; }
|
||||
// if (LoopMode==3) { MenuUpdate(); return 0; }
|
||||
// if (LoopMode==4) { LightCalUpdate(); return 0; }
|
||||
|
||||
LoopMode=2; // Unknown mode, go to rom menu
|
||||
return 0;
|
||||
|
@ -173,13 +136,13 @@ static int ModeUpdate()
|
|||
static int ModeRender()
|
||||
{
|
||||
DirectScreen();
|
||||
if (LoopMode==3) MenuRender();
|
||||
if (LoopMode==4) LightCalRender();
|
||||
// if (LoopMode==3) MenuRender();
|
||||
// if (LoopMode==4) LightCalRender();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void UpdateSound()
|
||||
static void UpdateSound(int len)
|
||||
{
|
||||
if(fastForward) return;
|
||||
while (DSoundUpdate()) { Sleep(1); }
|
||||
|
@ -206,6 +169,7 @@ int LoopCode()
|
|||
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
#if 0
|
||||
extern "C" int dprintf(char *format, ...)
|
||||
{
|
||||
char *name=NULL;
|
||||
|
@ -229,6 +193,7 @@ extern "C" int dprintf(char *format, ...)
|
|||
va_end(val);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
extern "C" int dprintf2(char *format, ...)
|
||||
{
|
||||
|
@ -242,3 +207,4 @@ extern "C" int dprintf2(char *format, ...)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -113,13 +113,16 @@ int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR cmdline,int)
|
|||
DWORD tid=0;
|
||||
HANDLE thread=NULL;
|
||||
|
||||
FrameInit();
|
||||
ret=LoopInit(); if (ret) { LoopExit(); return 1; }
|
||||
|
||||
// notaz: load rom
|
||||
static char rompath[MAX_PATH]; rompath[0] = 0;
|
||||
strcpy(rompath, cmdline + (cmdline[0] == '\"' ? 1 : 0));
|
||||
if(rompath[strlen(rompath)-1] == '\"') rompath[strlen(rompath)-1] = 0;
|
||||
|
||||
FILE *rom = 0;
|
||||
if(strlen(rompath) > 4) rom = fopen(rompath, "rb");
|
||||
pm_file *rom = 0;
|
||||
if(strlen(rompath) > 4) rom = pm_open(rompath);
|
||||
if(!rom) {
|
||||
OPENFILENAME of; ZeroMemory(&of, sizeof(OPENFILENAME));
|
||||
of.lStructSize = sizeof(OPENFILENAME);
|
||||
|
@ -128,7 +131,7 @@ int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR cmdline,int)
|
|||
of.nMaxFile = MAX_PATH;
|
||||
of.Flags = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
|
||||
if(!GetOpenFileName(&of)) return 1;
|
||||
rom = fopen(rompath, "rb");
|
||||
rom = pm_open(rompath);
|
||||
if(!rom) return 1;
|
||||
}
|
||||
romname = rompath;
|
||||
|
@ -137,17 +140,13 @@ int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR cmdline,int)
|
|||
//RDebug::Print(_L("PicoCartLoad() failed."));
|
||||
//goto cleanup;
|
||||
}
|
||||
|
||||
FrameInit();
|
||||
ret=LoopInit(); if (ret) { LoopExit(); return 1; }
|
||||
pm_close(rom);
|
||||
|
||||
PicoCartInsert(rom_data, rom_size);
|
||||
|
||||
// only now we got the mode (pal/ntsc), so init sound now
|
||||
DSoundInit();
|
||||
|
||||
preLoopInit();
|
||||
|
||||
// Make another thread to run LoopCode():
|
||||
LoopQuit=0;
|
||||
thread=CreateThread(NULL,0,ThreadCode,NULL,0,&tid);
|
||||
|
@ -174,5 +173,10 @@ int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR cmdline,int)
|
|||
_CrtDumpMemoryLeaks();
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern void error(char *text)
|
||||
{
|
||||
MessageBox(FrameWnd, text, "Error", 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
57
platform/win32/GenaDrive/Makefile.vc
Normal file
57
platform/win32/GenaDrive/Makefile.vc
Normal file
|
@ -0,0 +1,57 @@
|
|||
# Makefile for MS Visual C
|
||||
|
||||
R=..\..\..\
|
||||
|
||||
CFLAGS=/nologo /W2 /O2 /D "_CRT_SECURE_NO_WARNINGS" -I. -I$(R)
|
||||
|
||||
LDFLAGS=/nologo /machine:I386 /opt:nowin98 /out:PicoDrive.exe
|
||||
|
||||
CFLAGS=$(CFLAGS) /DEMU_F68K
|
||||
|
||||
CFLAGS=$(CFLAGS) /D_USE_CZ80
|
||||
|
||||
# emu
|
||||
OBJ = Emu.obj Input.obj Main.obj Direct.obj DSound.obj Loop.obj TexScreen.obj
|
||||
|
||||
# not used: Rom.obj Font.obj FileMenu.obj LightCal.obj
|
||||
|
||||
# common
|
||||
#OBJS += platform\common\emu.obj platform\common\menu.obj platform\common\fonts.obj
|
||||
# platform\common\readpng.obj platform\common\mp3_helix.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 \
|
||||
$(R)Pico\VideoPort.obj $(R)Pico\Draw2.obj $(R)Pico\Draw.obj $(R)Pico\Patch.obj
|
||||
# Pico - CD
|
||||
OBJ = $(OBJ) $(R)Pico\cd\Pico.obj $(R)Pico\cd\Memory.obj $(R)Pico\cd\Sek.obj $(R)Pico\cd\LC89510.obj \
|
||||
$(R)Pico\cd\cd_sys.obj $(R)Pico\cd\cd_file.obj $(R)Pico\cd\gfx_cd.obj \
|
||||
$(R)Pico\cd\Area.obj $(R)Pico\cd\Misc.obj $(R)Pico\cd\pcm.obj $(R)Pico\cd\buffering.obj
|
||||
# Pico - sound
|
||||
OBJ = $(OBJ) $(R)Pico\sound\sound.obj $(R)Pico\sound\sn76496.obj $(R)Pico\sound\ym2612.obj $(R)Pico\sound\mix.obj
|
||||
# Pico - carthw
|
||||
OBJ = $(OBJ) $(R)Pico\carthw\svp\svp.obj $(R)Pico\carthw\svp\Memory.obj $(R)Pico\carthw\svp\ssp16.obj
|
||||
# zlib
|
||||
OBJ = $(OBJ) $(R)zlib\gzio.obj $(R)zlib\inffast.obj $(R)zlib\inflate.obj $(R)zlib\inftrees.obj $(R)zlib\trees.obj \
|
||||
$(R)zlib\deflate.obj $(R)zlib\crc32.obj $(R)zlib\adler32.obj $(R)zlib\zutil.obj $(R)zlib\compress.obj $(R)zlib\uncompr.obj
|
||||
# unzip
|
||||
OBJ = $(OBJ) $(R)unzip\unzip.obj $(R)unzip\unzip_stream.obj
|
||||
# CPU cores
|
||||
OBJ = $(OBJ) $(R)cpu\fame\famec.obj
|
||||
# z80
|
||||
OBJ = $(OBJ) $(R)cpu\cz80\cz80.obj
|
||||
|
||||
|
||||
.c.obj:
|
||||
cl $(CFLAGS) /c $< /Fo$@
|
||||
|
||||
.cpp.obj:
|
||||
cl $(CFLAGS) /c $< /Fo$@
|
||||
|
||||
|
||||
ALL : PicoDrive.exe
|
||||
|
||||
PicoDrive.exe : $(OBJ)
|
||||
link.exe $(LDFLAGS) $(OBJ) gdi32.lib user32.lib advapi32.lib d3d8.lib d3dx8.lib dsound.lib comdlg32.lib
|
||||
|
||||
clean:
|
||||
-del $(OBJ) PicoDrive.exe
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
#include <d3dx8.h>
|
||||
|
||||
#include "Pico.h"
|
||||
#include <Pico/Pico.h>
|
||||
|
||||
#define PI 3.14159265f
|
||||
|
||||
|
@ -53,19 +53,20 @@ int LightCalUpdate();
|
|||
int LightCalRender();
|
||||
|
||||
// Loop.cpp
|
||||
void preLoopInit();
|
||||
extern char LoopQuit;
|
||||
extern int LoopMode;
|
||||
|
||||
int LoopInit();
|
||||
void LoopExit();
|
||||
int LoopCode();
|
||||
//extern "C" int dprintf(char *format, ...);
|
||||
extern "C" int dprintf2(char *format, ...);
|
||||
|
||||
// Main.cpp
|
||||
extern HWND FrameWnd;
|
||||
extern int MainWidth,MainHeight;
|
||||
extern char AppName[];
|
||||
extern "C" int dprintf(char *format, ...);
|
||||
extern void error(char *text);
|
||||
|
||||
// Rom.cpp
|
||||
extern unsigned char *RomData;
|
||||
|
|
|
@ -7,19 +7,12 @@
|
|||
#define START_ROW 0 // which row of tiles to start rendering at?
|
||||
#define END_ROW 28 // ..end
|
||||
|
||||
#define mix_32_to_16l_stereo_lvl mix_32_to_16l_stereo
|
||||
|
||||
// pico.c
|
||||
#define CAN_HANDLE_240_LINES 0
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// common debug
|
||||
int dprintf (char *format, ...);
|
||||
int dprintf2(char *format, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // End of extern "C"
|
||||
#endif
|
||||
#define dprintf
|
||||
#define strcasecmp stricmp
|
||||
|
||||
#endif //PORT_CONFIG_H
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue