static int LoopLen=0,LoopWrite=0; // Next position in loop to write\r
\r
short *DSoundNext=NULL; // Buffer for next sound data to put in loop\r
-//int DSoundSeg=0; // Seg length in samples\r
\r
static int LoopBlank()\r
{\r
DWORD play=0;\r
int pos=0;\r
\r
- if (LoopBuffer==NULL) return 1;\r
+ if (LoopBuffer==NULL) return -1;\r
\r
LoopBuffer->GetCurrentPosition(&play,NULL);\r
pos=play>>((PicoOpt&8) ? 2 : 1);\r
\r
void DSoundMute()\r
{\r
+ if (LoopBuffer==NULL) return;\r
LoopBuffer->Stop();\r
}\r
\r
void DSoundUnMute()\r
{\r
+ if (LoopBuffer==NULL) return;\r
LoopBuffer->Play(0,0,DSBPLAY_LOOPING);\r
}\r
{\r
D3DPRESENT_PARAMETERS d3dpp; \r
D3DDISPLAYMODE mode;\r
- int i=0,ret=0;\r
+ D3DDEVTYPE dt = D3DDEVTYPE_HAL;\r
+ int i,u,ret=0;\r
\r
memset(&d3dpp,0,sizeof(d3dpp));\r
memset(&mode,0,sizeof(mode));\r
#endif\r
\r
// Try to create a device with hardware vertex processing:\r
- for (i=0;i<4;i++)\r
+ for (u=0;u<2;u++)\r
{\r
- int behave=D3DCREATE_HARDWARE_VERTEXPROCESSING;\r
-\r
-#ifdef _XBOX\r
- if (i==1)\r
+ for (i=0;i<4;i++)\r
{\r
- // If 60Hz didn't work, try PAL 50Hz instead:\r
- d3dpp.FullScreen_RefreshRateInHz=0;\r
- d3dpp.BackBufferHeight=MainHeight=576;\r
- }\r
-#endif\r
+ int behave=D3DCREATE_HARDWARE_VERTEXPROCESSING;\r
\r
- // Try software vertex processing:\r
- if (i==2) behave=D3DCREATE_MIXED_VERTEXPROCESSING;\r
- if (i==3) behave=D3DCREATE_SOFTWARE_VERTEXPROCESSING;\r
+ // Try software vertex processing:\r
+ if (i==1) behave=D3DCREATE_MIXED_VERTEXPROCESSING;\r
+ if (i==2) behave=D3DCREATE_SOFTWARE_VERTEXPROCESSING;\r
\r
- Direct3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,FrameWnd,behave,&d3dpp,&Device);\r
+ Direct3D->CreateDevice(D3DADAPTER_DEFAULT,dt,FrameWnd,behave,&d3dpp,&Device);\r
+ if (Device) break;\r
+ }\r
if (Device) break;\r
+ dt = D3DDEVTYPE_REF;\r
}\r
\r
if (Device==NULL) return 1;\r
int DirectScreen()\r
{\r
unsigned char *lock=NULL;\r
+ int ret;\r
\r
// Copy the screen to the screen texture:\r
#ifdef _XBOX\r
TexScreenSwizzle();\r
#else\r
- TexScreenLinear();\r
+ ret=TexScreenLinear();\r
+ if (ret) dprintf2("TexScreenLinear failed\n");\r
#endif\r
\r
SetupMatrices();\r
MakeVertexList();\r
\r
// Copy vertices in:\r
- VertexBuffer->Lock(0,sizeof(VertexList),&lock,0); if (lock==NULL) return 1;\r
+ VertexBuffer->Lock(0,sizeof(VertexList),&lock,0);\r
+ if (lock==NULL) { dprintf2("VertexBuffer->Lock failed\n"); return 1; }\r
memcpy(lock,VertexList,sizeof(VertexList));\r
VertexBuffer->Unlock();\r
\r
- Device->SetTexture(0,TexScreen);\r
- Device->SetStreamSource(0,VertexBuffer,sizeof(CustomVertex));\r
- Device->SetVertexShader(D3DFVF_CUSTOMVERTEX);\r
- Device->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,2);\r
- \r
+ ret=Device->SetTexture(0,TexScreen);\r
+ if (ret) dprintf2("SetTexture failed\n");\r
+ ret=Device->SetStreamSource(0,VertexBuffer,sizeof(CustomVertex));\r
+ if (ret) dprintf2("SetStreamSource failed\n");\r
+ ret=Device->SetVertexShader(D3DFVF_CUSTOMVERTEX);\r
+ if (ret) dprintf2("SetVertexShader failed\n");\r
+ ret=Device->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,2);\r
+ if (ret) dprintf2("DrawPrimitive failed\n");\r
+\r
return 0;\r
}\r
#include "app.h"\r
\r
unsigned short *EmuScreen=NULL;\r
-extern "C" unsigned short *framebuff=NULL;\r
int EmuWidth=0,EmuHeight=0;\r
-static int frame=0;\r
static int EmuScan(unsigned int num, void *sdata);\r
unsigned char *PicoDraw2FB = NULL;\r
\r
EmuWidth=320; EmuHeight=224;\r
len=EmuWidth*EmuHeight; len<<=1;\r
EmuScreen=(unsigned short *)malloc(len); if (EmuScreen==NULL) return 1;\r
- framebuff=(unsigned short *)malloc((8+320)*(8+224+8)*2);\r
+ PicoDraw2FB=(unsigned char *)malloc((8+320)*(8+224+8)*2);\r
memset(EmuScreen,0,len);\r
\r
- PicoDraw2FB = (unsigned char *)framebuff;\r
PicoDrawSetColorFormat(1);\r
PicoScan=EmuScan;\r
\r
{\r
//RomFree();\r
free(EmuScreen); EmuScreen=NULL; // Deallocate screen\r
- free(framebuff);\r
+ free(PicoDraw2FB);\r
EmuWidth=EmuHeight=0;\r
\r
PicoExit();\r
pd=EmuScreen+(num<<8)+(num<<6); end=pd+320;\r
ps=(unsigned short *)sdata;\r
\r
- do { *pd++=*ps++; } while (pd<end);\r
+ do { *pd++=0xf800;/**ps++;*/ } while (pd<end);\r
\r
return 0;\r
}\r
\r
PicoPad[0]=input;\r
\r
- frame++;\r
PsndOut=(short *)DSoundNext; PicoFrame(); PsndOut=NULL;\r
\r
return 0;\r
#include "app.h"\r
#include <commdlg.h>\r
\r
-extern char *romname;\r
-extern unsigned char *rom_data;\r
-extern unsigned int rom_size;\r
-extern int fastForward;\r
-extern int frameStep;\r
-extern int emu_frame;\r
-\r
struct Input Inp;\r
\r
// --------------------- XBox Input -----------------------------\r
else if(!sblobked && GetAsyncKeyState(VK_TAB)) {\r
PicoReset(0);\r
sblobked = 1;\r
- emu_frame = 0;\r
}\r
- else if(!sblobked && GetAsyncKeyState(VK_ESCAPE)) {\r
- DSoundMute();\r
+ else if(!sblobked && GetAsyncKeyState(VK_ESCAPE))\r
+ {\r
+ unsigned char *rom_data;\r
+ unsigned int rom_size;\r
+ DSoundMute();\r
pm_file *rom = 0;\r
OPENFILENAME of; ZeroMemory(&of, sizeof(OPENFILENAME));\r
- of.lStructSize = sizeof(OPENFILENAME);\r
- of.lpstrFilter = "ROMs\0*.smd;*.bin;*.gen\0";\r
- of.lpstrFile = romname; romname[0] = 0;\r
- of.nMaxFile = MAX_PATH;\r
- of.Flags = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;\r
- GetOpenFileName(&of);\r
- rom = pm_open(romname);\r
- DSoundUnMute();\r
- if(!rom) return 1;\r
+ of.lStructSize = sizeof(OPENFILENAME);\r
+ of.lpstrFilter = "ROMs\0*.smd;*.bin;*.gen\0";\r
+ of.lpstrFile = romname; romname[0] = 0;\r
+ of.nMaxFile = MAX_PATH;\r
+ of.Flags = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;\r
+ GetOpenFileName(&of);\r
+ rom = pm_open(romname);\r
+ DSoundUnMute();\r
+ if(!rom) return 1;\r
PicoCartLoad(rom, &rom_data, &rom_size);\r
PicoCartInsert(rom_data, rom_size);\r
- pm_close(rom);\r
- sblobked = 1;\r
+ pm_close(rom);\r
+ sblobked = 1;\r
}\r
else\r
sblobked = GetAsyncKeyState(VK_F6) | GetAsyncKeyState(VK_F9) |\r
#include "app.h"\r
//#include "FileMenu.h"\r
\r
-extern char *romname;\r
-int fastForward=0;\r
-int frameStep=0;\r
-\r
char LoopQuit=0;\r
static FILE *DebugFile=NULL;\r
int LoopMode=0;\r
// bits LSb->MSb:\r
// enable_ym2612&dac, enable_sn76496, enable_z80, stereo_sound;\r
// alt_renderer, 6button_gamepad, accurate_timing, accurate_sprites\r
- PicoOpt=0x1f;\r
+ PicoOpt=0xbccf;\r
PsndRate=44100;\r
- //PsndLen=PsndRate/60; // calculated later by pico itself\r
\r
// Init Direct3D:\r
ret=DirectInit(); if (ret) { error("Direct3D init failed"); return 1; }\r
\r
// ----------------------------------------------------------------\r
\r
-int emu_frame = 0;\r
-\r
static int DoGame()\r
{\r
- if(fastForward) { PicoSkipFrame+=1; PicoSkipFrame&=7; }\r
- else PicoSkipFrame=0;\r
-\r
- if(frameStep==1) return 0;\r
- else if(frameStep==3) frameStep=1;\r
-\r
EmuFrame();\r
- emu_frame++;\r
\r
if (Inp.held[7]==1) LoopMode=2; // Right thumb = Toggle Menu\r
\r
\r
static void UpdateSound(int len)\r
{\r
- if(fastForward) return;\r
- while (DSoundUpdate()) { Sleep(1); }\r
- while (DSoundUpdate()==0) { }\r
+ while (DSoundUpdate() > 0) { Sleep(1); }\r
+ while (DSoundUpdate()== 0) { }\r
}\r
\r
int LoopCode()\r
-\r
#include "app.h"\r
+#include "version.h"\r
#include <crtdbg.h>\r
#include <commdlg.h>\r
\r
\r
int MainWidth=720,MainHeight=480;\r
\r
-char AppName[]="GenaDrive";\r
-\r
-#ifdef STARSCREAM\r
- extern "C" int SekReset();\r
-#endif\r
-\r
-// ------------------------------------ XBox Main ------------------------------------------\r
-#ifdef _XBOX\r
-\r
-static int MainCode()\r
-{\r
- int ret=0;\r
-\r
- ret=LoopInit(); if (ret) { LoopExit(); return 1; }\r
-\r
- LoopQuit=0; LoopCode();\r
- LoopExit();\r
-\r
- return 0;\r
-}\r
-\r
-int __cdecl main()\r
-{\r
- LD_LAUNCH_DASHBOARD launch;\r
-\r
- MainCode();\r
-\r
- // Go back to dashboard:\r
- memset(&launch,0,sizeof(launch));\r
- launch.dwReason=XLD_LAUNCH_DASHBOARD_MAIN_MENU;\r
- XLaunchNewImage(NULL,(LAUNCH_DATA *)&launch);\r
-}\r
-#endif\r
-\r
-// ----------------------------------- Windows Main ----------------------------------------\r
-#ifndef _XBOX\r
// Window proc for the frame window:\r
static LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)\r
{\r
top-=height; top>>=1;\r
\r
// Create the window:\r
- FrameWnd=CreateWindow(wc.lpszClassName,AppName,style|WS_VISIBLE,\r
+ FrameWnd=CreateWindow(wc.lpszClassName,"PicoDrive " VERSION,style|WS_VISIBLE,\r
left,top,width,height,NULL,NULL,NULL,NULL);\r
\r
return 0;\r
return 0;\r
}\r
\r
-// starscream needs this\r
-unsigned char *rom_data = 0;\r
-unsigned int rom_size = 0;\r
-\r
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR cmdline,int)\r
{\r
MSG msg;\r
int ret=0;\r
DWORD tid=0;\r
HANDLE thread=NULL;\r
+ unsigned char *rom_data = 0;\r
+ unsigned int rom_size = 0;\r
\r
FrameInit();\r
- ret=LoopInit(); if (ret) { LoopExit(); return 1; }\r
+ ret=LoopInit(); if (ret) goto end0;\r
\r
// notaz: load rom\r
static char rompath[MAX_PATH]; rompath[0] = 0;\r
if(strlen(rompath) > 4) rom = pm_open(rompath);\r
if(!rom) {\r
OPENFILENAME of; ZeroMemory(&of, sizeof(OPENFILENAME));\r
- of.lStructSize = sizeof(OPENFILENAME);\r
- of.lpstrFilter = "ROMs\0*.smd;*.bin;*.gen\0";\r
- of.lpstrFile = rompath; rompath[0] = 0;\r
- of.nMaxFile = MAX_PATH;\r
- of.Flags = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;\r
- if(!GetOpenFileName(&of)) return 1;\r
- rom = pm_open(rompath);\r
- if(!rom) return 1;\r
+ of.lStructSize = sizeof(OPENFILENAME);\r
+ of.lpstrFilter = "ROMs\0*.smd;*.bin;*.gen;*.zip\0";\r
+ of.lpstrFile = rompath; rompath[0] = 0;\r
+ of.nMaxFile = MAX_PATH;\r
+ of.Flags = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;\r
+ if(!GetOpenFileName(&of)) goto end0;\r
+ rom = pm_open(rompath);\r
+ if(!rom) goto end0;\r
}\r
romname = rompath;\r
\r
- if(PicoCartLoad(rom, &rom_data, &rom_size)) {\r
- //RDebug::Print(_L("PicoCartLoad() failed."));\r
- //goto cleanup;\r
- }\r
+ ret=PicoCartLoad(rom, &rom_data, &rom_size);\r
pm_close(rom);\r
+ if (ret) {\r
+ error("failed to load ROM");\r
+ goto end0;\r
+ }\r
\r
PicoCartInsert(rom_data, rom_size);\r
\r
// only now we got the mode (pal/ntsc), so init sound now\r
- DSoundInit();\r
+ ret=DSoundInit();\r
+ if (ret) error("Failed to init DirectSound"); // warning\r
\r
// Make another thread to run LoopCode():\r
LoopQuit=0;\r
LoopQuit=1; WaitForSingleObject(thread,5000);\r
CloseHandle(thread); thread=NULL;\r
\r
+end0:\r
LoopExit();\r
DestroyWindow(FrameWnd);\r
\r
{\r
MessageBox(FrameWnd, text, "Error", 0);\r
}\r
-#endif\r
\r
int y=0,line=0;\r
unsigned short *ps=NULL;\r
\r
- TexScreen->LockRect(0,&lock,NULL,0); if (lock.pBits==NULL) return 1;\r
+ TexScreen->LockRect(0,&lock,NULL,0);\r
+ if (lock.pBits==NULL) return 1;\r
\r
dest=(unsigned char *)lock.pBits;\r
ps=EmuScreen;\r
\r
for (x=0; x<EmuWidth; x++,addr+=2)\r
{\r
- *(unsigned int *)(dest+addr)=*ps++;\r
+ *(unsigned int *)(dest+addr)=0xf0f0f0f0;//*ps++;\r
}\r
}\r
\r
\r
#include <stdio.h>\r
\r
-#ifdef _XBOX\r
-#include <xtl.h>\r
-#endif\r
-\r
-#ifndef _XBOX\r
#define WIN32_LEAN_AND_MEAN\r
#include <windows.h>\r
#include <d3d8.h>\r
-#endif\r
\r
#include <d3dx8.h>\r
\r
\r
#define RELEASE(x) if (x) x->Release(); x=NULL;\r
\r
-#ifdef _XBOX\r
-#define HOME "d:\\"\r
-#else\r
-#define HOME ".\\"\r
-#endif\r
\r
// Emu.cpp\r
extern unsigned short *EmuScreen;\r
extern "C" int dprintf2(char *format, ...);\r
\r
// Main.cpp\r
+extern char *romname;\r
extern HWND FrameWnd;\r
extern int MainWidth,MainHeight;\r
-extern char AppName[];\r
extern void error(char *text);\r
\r
// Rom.cpp\r
--- /dev/null
+#define VERSION "1.40"\r
+\r