mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-06 15:48:05 -04:00
initial import
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@2 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
2cadbd5e56
commit
cc68a136aa
341 changed files with 180839 additions and 0 deletions
130
platform/win32/GenaDrive/DSound.cpp
Normal file
130
platform/win32/GenaDrive/DSound.cpp
Normal file
|
@ -0,0 +1,130 @@
|
|||
|
||||
#include "app.h"
|
||||
|
||||
#ifndef _XBOX
|
||||
#pragma warning (disable:4201)
|
||||
#include <mmsystem.h>
|
||||
#include <dsound.h>
|
||||
#endif
|
||||
|
||||
static IDirectSound *DSound=NULL;
|
||||
static IDirectSoundBuffer *LoopBuffer=NULL;
|
||||
static int LoopLen=0,LoopWrite=0; // Next position in loop to write
|
||||
|
||||
short *DSoundNext=NULL; // Buffer for next sound data to put in loop
|
||||
//int DSoundSeg=0; // Seg length in samples
|
||||
|
||||
static int LoopBlank()
|
||||
{
|
||||
void *mema=NULL,*memb=NULL;
|
||||
DWORD sizea=0,sizeb=0;
|
||||
|
||||
LoopBuffer->Lock(0,LoopLen<<2, &mema,&sizea, &memb,&sizeb, 0);
|
||||
|
||||
if (mema) memset(mema,0,sizea);
|
||||
|
||||
LoopBuffer->Unlock(mema,sizea, memb,sizeb);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DSoundInit()
|
||||
{
|
||||
DSBUFFERDESC dsbd;
|
||||
WAVEFORMATEX wfx;
|
||||
|
||||
memset(&dsbd,0,sizeof(dsbd));
|
||||
memset(&wfx,0,sizeof(wfx));
|
||||
|
||||
// Make wave format:
|
||||
wfx.wFormatTag=WAVE_FORMAT_PCM;
|
||||
wfx.nChannels=(unsigned short)((PicoOpt&8) ? 2 : 1); // Stereo/mono
|
||||
wfx.nSamplesPerSec=PsndRate;
|
||||
wfx.wBitsPerSample=16;
|
||||
|
||||
wfx.nBlockAlign=(WORD)((wfx.nChannels*wfx.wBitsPerSample)>>3);
|
||||
wfx.nAvgBytesPerSec=wfx.nBlockAlign*wfx.nSamplesPerSec;
|
||||
|
||||
// Make buffer for the next seg to put into the loop:
|
||||
DSoundNext=(short *)malloc(PsndLen<<2); if (DSoundNext==NULL) return 1;
|
||||
memset(DSoundNext,0,PsndLen<<2);
|
||||
|
||||
// Create the DirectSound interface:
|
||||
DirectSoundCreate(NULL,&DSound,NULL);
|
||||
if (DSound==NULL) return 1;
|
||||
|
||||
LoopLen=PsndLen<<1; // 2 segs
|
||||
|
||||
#ifndef _XBOX
|
||||
LoopLen<<=1; // 4 segs
|
||||
DSound->SetCooperativeLevel(FrameWnd,DSSCL_PRIORITY);
|
||||
dsbd.dwFlags=DSBCAPS_GLOBALFOCUS; // Play in background
|
||||
#endif
|
||||
|
||||
// Create the looping buffer:
|
||||
dsbd.dwSize=sizeof(dsbd);
|
||||
dsbd.dwBufferBytes=LoopLen<<wfx.nChannels; // 16bit stereo?
|
||||
dsbd.lpwfxFormat=&wfx;
|
||||
|
||||
DSound->CreateSoundBuffer(&dsbd,&LoopBuffer,NULL);
|
||||
if (LoopBuffer==NULL) return 1;
|
||||
|
||||
LoopBlank();
|
||||
LoopBuffer->Play(0,0,DSBPLAY_LOOPING);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DSoundExit()
|
||||
{
|
||||
if (LoopBuffer) LoopBuffer->Stop();
|
||||
RELEASE(LoopBuffer)
|
||||
RELEASE(DSound)
|
||||
free(DSoundNext); DSoundNext=NULL;
|
||||
}
|
||||
|
||||
static int WriteSeg()
|
||||
{
|
||||
void *mema=NULL,*memb=NULL;
|
||||
DWORD sizea=0,sizeb=0;
|
||||
|
||||
// Lock the segment at 'LoopWrite' and copy the next segment in
|
||||
LoopBuffer->Lock(LoopWrite<<((PicoOpt&8) ? 2 : 1),PsndLen<<((PicoOpt&8) ? 2 : 1), &mema,&sizea, &memb,&sizeb, 0);
|
||||
|
||||
if (mema) memcpy(mema,DSoundNext,sizea);
|
||||
|
||||
LoopBuffer->Unlock(mema,sizea, memb,0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DSoundUpdate()
|
||||
{
|
||||
DWORD play=0;
|
||||
int pos=0;
|
||||
|
||||
if (LoopBuffer==NULL) return 1;
|
||||
|
||||
LoopBuffer->GetCurrentPosition(&play,NULL);
|
||||
pos=play>>((PicoOpt&8) ? 2 : 1);
|
||||
|
||||
// 'LoopWrite' is the next seg in the loop that we want to write
|
||||
// First check that the sound 'play' pointer has moved out of it:
|
||||
if (pos>=LoopWrite && pos<LoopWrite+PsndLen) return 1; // No, it hasn't
|
||||
|
||||
WriteSeg();
|
||||
|
||||
// Advance LoopWrite to next seg:
|
||||
LoopWrite+=PsndLen; if (LoopWrite+PsndLen>LoopLen) LoopWrite=0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DSoundMute()
|
||||
{
|
||||
LoopBuffer->Stop();
|
||||
}
|
||||
|
||||
void DSoundUnMute()
|
||||
{
|
||||
LoopBuffer->Play(0,0,DSBPLAY_LOOPING);
|
||||
}
|
210
platform/win32/GenaDrive/Direct.cpp
Normal file
210
platform/win32/GenaDrive/Direct.cpp
Normal file
|
@ -0,0 +1,210 @@
|
|||
|
||||
#include "app.h"
|
||||
|
||||
static IDirect3D8 *Direct3D=NULL;
|
||||
IDirect3DDevice8 *Device=NULL;
|
||||
IDirect3DSurface8 *DirectBack=NULL; // Back Buffer
|
||||
|
||||
static IDirect3DVertexBuffer8 *VertexBuffer=NULL;
|
||||
|
||||
struct CustomVertex
|
||||
{
|
||||
float x,y,z; // Vertex cordinates
|
||||
unsigned int colour;
|
||||
float u,v; // Texture coordinates
|
||||
};
|
||||
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)
|
||||
|
||||
static CustomVertex VertexList[4];
|
||||
|
||||
int DirectInit()
|
||||
{
|
||||
D3DPRESENT_PARAMETERS d3dpp;
|
||||
D3DDISPLAYMODE mode;
|
||||
int i=0,ret=0;
|
||||
|
||||
memset(&d3dpp,0,sizeof(d3dpp));
|
||||
memset(&mode,0,sizeof(mode));
|
||||
|
||||
Direct3D=Direct3DCreate8(D3D_SDK_VERSION); if (Direct3D==NULL) return 1;
|
||||
|
||||
// Set up the structure used to create the D3D device:
|
||||
d3dpp.BackBufferWidth =MainWidth;
|
||||
d3dpp.BackBufferHeight=MainHeight;
|
||||
d3dpp.BackBufferCount =1;
|
||||
d3dpp.SwapEffect=D3DSWAPEFFECT_DISCARD;
|
||||
|
||||
#ifdef _XBOX
|
||||
d3dpp.BackBufferFormat=D3DFMT_X8R8G8B8;
|
||||
d3dpp.FullScreen_RefreshRateInHz=60;
|
||||
#else
|
||||
Direct3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&mode);
|
||||
d3dpp.BackBufferFormat=mode.Format;
|
||||
d3dpp.Windowed=1;
|
||||
#endif
|
||||
|
||||
// Try to create a device with hardware vertex processing:
|
||||
for (i=0;i<4;i++)
|
||||
{
|
||||
int behave=D3DCREATE_HARDWARE_VERTEXPROCESSING;
|
||||
|
||||
#ifdef _XBOX
|
||||
if (i==1)
|
||||
{
|
||||
// If 60Hz didn't work, try PAL 50Hz instead:
|
||||
d3dpp.FullScreen_RefreshRateInHz=0;
|
||||
d3dpp.BackBufferHeight=MainHeight=576;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Try software vertex processing:
|
||||
if (i==2) behave=D3DCREATE_MIXED_VERTEXPROCESSING;
|
||||
if (i==3) behave=D3DCREATE_SOFTWARE_VERTEXPROCESSING;
|
||||
|
||||
Direct3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,FrameWnd,behave,&d3dpp,&Device);
|
||||
if (Device) break;
|
||||
}
|
||||
|
||||
if (Device==NULL) return 1;
|
||||
|
||||
Device->GetBackBuffer(0,D3DBACKBUFFER_TYPE_MONO,&DirectBack);
|
||||
if (DirectBack==NULL) return 1;
|
||||
|
||||
Device->CreateVertexBuffer(sizeof(VertexList),0,D3DFVF_CUSTOMVERTEX,D3DPOOL_DEFAULT,&VertexBuffer);
|
||||
if (VertexBuffer==NULL) return 1;
|
||||
|
||||
ret=TexScreenInit(); if (ret) return 1;
|
||||
|
||||
FontInit();
|
||||
|
||||
Device->SetRenderState(D3DRS_LIGHTING,0); // Turn off lighting
|
||||
|
||||
// Set up texture modes:
|
||||
Device->SetTextureStageState(0,D3DTSS_ADDRESSU,D3DTADDRESS_CLAMP);
|
||||
Device->SetTextureStageState(0,D3DTSS_ADDRESSV,D3DTADDRESS_CLAMP);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DirectExit()
|
||||
{
|
||||
FontExit();
|
||||
TexScreenExit();
|
||||
|
||||
RELEASE(VertexBuffer)
|
||||
RELEASE(DirectBack)
|
||||
RELEASE(Device)
|
||||
RELEASE(Direct3D)
|
||||
}
|
||||
|
||||
|
||||
static int MakeVertexList()
|
||||
{
|
||||
struct CustomVertex *vert=NULL,*pv=NULL;
|
||||
float dist=0.0f;
|
||||
float scalex=0.0f,scaley=0.0f;
|
||||
unsigned int colour=0xffffff;
|
||||
float right=0.0f,bottom=0.0f;
|
||||
|
||||
if (LoopMode!=8) colour=0x102040;
|
||||
|
||||
dist=10.0f; scalex=dist*1.3333f; scaley=dist;
|
||||
|
||||
scalex*=640.0f/(float)MainWidth;
|
||||
scaley*=448.0f/(float)MainHeight;
|
||||
|
||||
vert=VertexList;
|
||||
|
||||
// Put the vertices for the corners of the screen:
|
||||
pv=vert;
|
||||
pv->z=dist;
|
||||
pv->x=-scalex; pv->y=scaley;
|
||||
pv->colour=colour; pv++;
|
||||
|
||||
*pv=vert[0]; pv->x= scalex; pv->y= scaley; pv++;
|
||||
*pv=vert[0]; pv->x=-scalex; pv->y=-scaley; pv++;
|
||||
*pv=vert[0]; pv->x= scalex; pv->y=-scaley; pv++;
|
||||
|
||||
// Find where the screen images ends on the texture
|
||||
right =(float)EmuWidth /(float)TexWidth;
|
||||
bottom=(float)EmuHeight/(float)TexHeight;
|
||||
|
||||
// Write texture coordinates:
|
||||
pv=vert;
|
||||
pv->u=0.0f; pv->v=0.00f; pv++;
|
||||
pv->u=right; pv->v=0.00f; pv++;
|
||||
pv->u=0.0f; pv->v=bottom; pv++;
|
||||
pv->u=right; pv->v=bottom; pv++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DirectClear(unsigned int colour)
|
||||
{
|
||||
Device->Clear(0,NULL,D3DCLEAR_TARGET,colour,1.0f,0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DirectPresent()
|
||||
{
|
||||
Device->Present(NULL,NULL,NULL,NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int SetupMatrices()
|
||||
{
|
||||
D3DXVECTOR3 eye ( 0.0f, 0.0f, 0.0f );
|
||||
D3DXVECTOR3 look( 0.0f, 0.0f, 0.0f );
|
||||
D3DXVECTOR3 up ( 0.0f, 1.0f, 0.0f );
|
||||
D3DXMATRIX mat;
|
||||
float nudgex=0.0f,nudgey=0.0f;
|
||||
|
||||
memset(&mat,0,sizeof(mat));
|
||||
|
||||
mat.m[0][0]=mat.m[1][1]=mat.m[2][2]=mat.m[3][3]=1.0f;
|
||||
Device->SetTransform(D3DTS_WORLD,&mat);
|
||||
|
||||
look.x=(float)Inp.axis[2]/2457.6f;
|
||||
look.y=(float)Inp.axis[3]/2457.6f;
|
||||
look.z=10.0f;
|
||||
|
||||
// Nudge pixels to the centre of each screen pixel:
|
||||
nudgex=13.3333f/(float)(MainWidth <<1);
|
||||
nudgey=10.0000f/(float)(MainHeight<<1);
|
||||
eye.x +=nudgex; eye.y +=nudgey;
|
||||
look.x+=nudgex; look.y+=nudgey;
|
||||
|
||||
D3DXMatrixLookAtLH(&mat,&eye,&look,&up);
|
||||
Device->SetTransform(D3DTS_VIEW,&mat);
|
||||
|
||||
D3DXMatrixPerspectiveFovLH(&mat, 0.5f*PI, 1.3333f, 0.2f, 1000.0f);
|
||||
Device->SetTransform(D3DTS_PROJECTION,&mat);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DirectScreen()
|
||||
{
|
||||
unsigned char *lock=NULL;
|
||||
|
||||
// Copy the screen to the screen texture:
|
||||
#ifdef _XBOX
|
||||
TexScreenSwizzle();
|
||||
#else
|
||||
TexScreenLinear();
|
||||
#endif
|
||||
|
||||
SetupMatrices();
|
||||
|
||||
MakeVertexList();
|
||||
|
||||
// Copy vertices in:
|
||||
VertexBuffer->Lock(0,sizeof(VertexList),&lock,0); if (lock==NULL) return 1;
|
||||
memcpy(lock,VertexList,sizeof(VertexList));
|
||||
VertexBuffer->Unlock();
|
||||
|
||||
Device->SetTexture(0,TexScreen);
|
||||
Device->SetStreamSource(0,VertexBuffer,sizeof(CustomVertex));
|
||||
Device->SetVertexShader(D3DFVF_CUSTOMVERTEX);
|
||||
Device->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,2);
|
||||
|
||||
return 0;
|
||||
}
|
112
platform/win32/GenaDrive/Emu.cpp
Normal file
112
platform/win32/GenaDrive/Emu.cpp
Normal file
|
@ -0,0 +1,112 @@
|
|||
|
||||
#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);
|
||||
|
||||
int EmuInit()
|
||||
{
|
||||
int len=0;
|
||||
|
||||
// PicoOpt=-1;
|
||||
// PsndRate=44100; PsndLen=DSoundSeg;
|
||||
|
||||
PicoInit();
|
||||
|
||||
// Allocate screen:
|
||||
EmuWidth=320; EmuHeight=224;
|
||||
len=EmuWidth*EmuHeight; len<<=1;
|
||||
EmuScreen=(unsigned short *)malloc(len); if (EmuScreen==NULL) return 1;
|
||||
framebuff=(unsigned short *)malloc((8+320)*(8+224+8)*2);
|
||||
memset(EmuScreen,0,len);
|
||||
|
||||
PicoScan=EmuScan;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void EmuExit()
|
||||
{
|
||||
//RomFree();
|
||||
free(EmuScreen); EmuScreen=NULL; // Deallocate screen
|
||||
free(framebuff);
|
||||
EmuWidth=EmuHeight=0;
|
||||
|
||||
PicoExit();
|
||||
}
|
||||
|
||||
// Megadrive scanline callback:
|
||||
static int EmuScan(unsigned int num, void *sdata)
|
||||
{
|
||||
unsigned short *pd=NULL,*end=NULL;
|
||||
unsigned short *ps=NULL;
|
||||
|
||||
if (num>=(unsigned int)EmuHeight) return 0;
|
||||
|
||||
// Copy scanline to screen buffer:
|
||||
pd=EmuScreen+(num<<8)+(num<<6); end=pd+320;
|
||||
ps=(unsigned short *)sdata;
|
||||
|
||||
do { *pd++=(unsigned short)PicoCram(*ps++); } while (pd<end);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int EmuFrame()
|
||||
{
|
||||
char map[12]={0,1,2,3,8,9,10,4,11,12,13,14}; // Joypads, format is UDLR BCAS ZYXM
|
||||
int a=0,input=0;
|
||||
|
||||
// Set Megadrive buttons:
|
||||
for (a=0;a<12;a++)
|
||||
{
|
||||
int m=map[a];
|
||||
if (m>=0) if (Inp.button[m]>30) input|=1<<a;
|
||||
}
|
||||
|
||||
PicoPad[0]=input;
|
||||
|
||||
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;
|
||||
}
|
188
platform/win32/GenaDrive/FileMenu.cpp
Normal file
188
platform/win32/GenaDrive/FileMenu.cpp
Normal file
|
@ -0,0 +1,188 @@
|
|||
|
||||
#include "app.h"
|
||||
#include "FileMenu.h"
|
||||
|
||||
class FileMenu FileMenu;
|
||||
|
||||
FileMenu::FileMenu()
|
||||
{
|
||||
memset(this,0,sizeof(*this));
|
||||
}
|
||||
|
||||
int FileMenu::init()
|
||||
{
|
||||
memset(this,0,sizeof(*this));
|
||||
strcpy(currentPath,HOME "roms");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FileMenu::scan()
|
||||
{
|
||||
char path[260];
|
||||
|
||||
memset(path,0,sizeof(path));
|
||||
|
||||
// Scan for all the roms in the current directory:
|
||||
nameReset();
|
||||
|
||||
sprintf(path,"%.240s\\*.bin", currentPath); nameFind(path);
|
||||
sprintf(path,"%.240s\\*.smd", currentPath); nameFind(path);
|
||||
sprintf(path,"%.240s\\*.zip",currentPath); nameFind(path);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FileMenu::exit()
|
||||
{
|
||||
free(nameList);
|
||||
memset(this,0,sizeof(*this));
|
||||
}
|
||||
|
||||
int FileMenu::render()
|
||||
{
|
||||
int x=0,y=0;
|
||||
int pos=0,index=0;
|
||||
WCHAR text[64];
|
||||
int height=24;
|
||||
|
||||
memset(text,0,sizeof(text));
|
||||
|
||||
x=120; y=224;
|
||||
y-=(choiceFocus*height)>>8;
|
||||
|
||||
while (pos<nameSize)
|
||||
{
|
||||
char *name=NULL;
|
||||
|
||||
name=nameList+pos;
|
||||
|
||||
if (y>-height && y<MainHeight)
|
||||
{
|
||||
unsigned int colour=0xffffff;
|
||||
|
||||
// If this line is visible:
|
||||
wsprintfW(text,L"%.42S",name);
|
||||
if (index==(choiceFocus>>8)) colour=0x00ff40;
|
||||
|
||||
FontSetColour(colour);
|
||||
FontText(text,x,y);
|
||||
}
|
||||
|
||||
y+=height;
|
||||
pos+=strlen(name)+1; // Skip to next string
|
||||
index++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FileMenu::scroll(int amount)
|
||||
{
|
||||
int max=0;
|
||||
|
||||
choiceFocus+=amount;
|
||||
|
||||
max=nameCount<<8;
|
||||
if (choiceFocus<0) choiceFocus=0;
|
||||
if (choiceFocus>=max) choiceFocus=max-1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get the currently highlighted filename
|
||||
int FileMenu::getFilePath(char *path)
|
||||
{
|
||||
int focus=0;
|
||||
int pos=0;
|
||||
char *name=NULL;
|
||||
|
||||
// Find where the user is focused
|
||||
focus=choiceFocus>>8;
|
||||
pos=nameOffset(focus); if (pos<0) return 1;
|
||||
|
||||
name=nameList+pos;
|
||||
|
||||
// Return path and name:
|
||||
sprintf(path,"%.128s\\%.128s",currentPath,name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
int FileMenu::nameReset()
|
||||
{
|
||||
free(nameList); nameList=NULL;
|
||||
nameSize=nameMax=nameCount=0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FileMenu::nameFind(char *path)
|
||||
{
|
||||
HANDLE find=NULL;
|
||||
WIN32_FIND_DATA wfd;
|
||||
|
||||
memset(&wfd,0,sizeof(wfd));
|
||||
|
||||
find=FindFirstFile(path,&wfd);
|
||||
if (find==INVALID_HANDLE_VALUE) return 1;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
nameAdd(wfd.cFileName); // Add the name to the list
|
||||
|
||||
if (FindNextFile(find,&wfd)==0) break;
|
||||
}
|
||||
|
||||
FindClose(find);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FileMenu::nameAdd(char *entry)
|
||||
{
|
||||
int len=0;
|
||||
|
||||
len=strlen(entry);
|
||||
// Check we have room for this entry:
|
||||
if (nameSize+len+1>nameMax) nameSizeUp();
|
||||
if (nameSize+len+1>nameMax) return 1;
|
||||
|
||||
// Add entry with zero at the end:
|
||||
memcpy(nameList+nameSize,entry,len);
|
||||
nameSize+=len+1;
|
||||
nameCount++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FileMenu::nameSizeUp()
|
||||
{
|
||||
|
||||
void *mem=NULL;
|
||||
int add=256;
|
||||
|
||||
// Allocate more memory for the list:
|
||||
mem=realloc(nameList,nameMax+add); if (mem==NULL) return 1;
|
||||
|
||||
nameList=(char *)mem;
|
||||
memset(nameList+nameMax,0,add); // Blank new memory
|
||||
nameMax+=add;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FileMenu::nameOffset(int index)
|
||||
{
|
||||
int pos=0,i=0;
|
||||
|
||||
while (pos<nameSize)
|
||||
{
|
||||
char *name=nameList+pos;
|
||||
|
||||
if (i==index) return pos;
|
||||
|
||||
pos+=strlen(name)+1; // Skip to next string
|
||||
i++;
|
||||
}
|
||||
|
||||
return -1; // Unknown index
|
||||
}
|
29
platform/win32/GenaDrive/FileMenu.h
Normal file
29
platform/win32/GenaDrive/FileMenu.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
|
||||
// FileMenu.cpp
|
||||
class FileMenu
|
||||
{
|
||||
public:
|
||||
FileMenu();
|
||||
int init();
|
||||
int scan();
|
||||
void exit();
|
||||
int render();
|
||||
int scroll(int amount);
|
||||
int getFilePath(char *name);
|
||||
|
||||
private:
|
||||
int nameReset();
|
||||
int nameFind(char *path);
|
||||
int nameAdd(char *entry);
|
||||
int nameSizeUp();
|
||||
int nameOffset(int index);
|
||||
|
||||
char currentPath[260];
|
||||
char *nameList;
|
||||
int nameSize,nameMax;
|
||||
int nameCount;
|
||||
|
||||
int choiceFocus;
|
||||
};
|
||||
|
||||
extern class FileMenu FileMenu;
|
85
platform/win32/GenaDrive/Font.cpp
Normal file
85
platform/win32/GenaDrive/Font.cpp
Normal file
|
@ -0,0 +1,85 @@
|
|||
|
||||
#include "app.h"
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
#ifdef _XBOX
|
||||
|
||||
#include <xfont.h>
|
||||
static XFONT *Font=NULL;
|
||||
|
||||
int FontInit()
|
||||
{
|
||||
XFONT_OpenDefaultFont(&Font); if (Font==NULL) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FontExit()
|
||||
{
|
||||
}
|
||||
|
||||
int FontSetColour(unsigned int colour)
|
||||
{
|
||||
Font->SetTextColor(colour);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FontText(WCHAR *text,int dx,int dy)
|
||||
{
|
||||
if (Font==NULL || DirectBack==NULL) return 1;
|
||||
|
||||
Font->TextOut(DirectBack,text,~0U,dx,dy);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------------
|
||||
#ifndef _XBOX
|
||||
|
||||
static ID3DXFont *Font=NULL;
|
||||
static unsigned int FontColour=0;
|
||||
|
||||
int FontInit()
|
||||
{
|
||||
LOGFONT lf;
|
||||
|
||||
memset(&lf,0,sizeof(lf));
|
||||
strcpy(lf.lfFaceName,"Arial");
|
||||
lf.lfHeight=24;
|
||||
D3DXCreateFontIndirect(Device,&lf,&Font);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FontExit()
|
||||
{
|
||||
RELEASE(Font);
|
||||
}
|
||||
|
||||
int FontSetColour(unsigned int colour)
|
||||
{
|
||||
FontColour=0xff000000|colour;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int FontText(WCHAR *text,int dx,int dy)
|
||||
{
|
||||
RECT rect={0,0,0,0};
|
||||
|
||||
if (Font==NULL || DirectBack==NULL) return 1;
|
||||
|
||||
Font->Begin();
|
||||
rect.left=dx;
|
||||
rect.top=dy;
|
||||
rect.right=MainWidth;
|
||||
rect.bottom=MainHeight;
|
||||
|
||||
Font->DrawTextW(text,-1,&rect,DT_LEFT,FontColour);
|
||||
Font->End();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
308
platform/win32/GenaDrive/GenaDrive.dsp
Normal file
308
platform/win32/GenaDrive/GenaDrive.dsp
Normal file
|
@ -0,0 +1,308 @@
|
|||
# Microsoft Developer Studio Project File - Name="GenaDrive" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=GenaDrive - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "GenaDrive.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "GenaDrive.mak" CFG="GenaDrive - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "GenaDrive - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "GenaDrive - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "GenaDrive - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MT /W4 /GX /O2 /I "..\..\..\Pico" /I ".\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "EMU_M68K" /D "_USE_MZ80" /FR /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x809 /d "NDEBUG"
|
||||
# ADD RSC /l 0x809 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 gdi32.lib user32.lib advapi32.lib d3d8.lib d3dx8.lib dsound.lib comdlg32.lib /nologo /subsystem:windows /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "GenaDrive - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "..\..\..\Pico" /I ".\\" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "DEBUG" /D "EMU_M68K" /D "_USE_MZ80" /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x809 /d "_DEBUG"
|
||||
# ADD RSC /l 0x809 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 user32.lib gdi32.lib advapi32.lib d3d8.lib d3dx8.lib dsound.lib comdlg32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "GenaDrive - Win32 Release"
|
||||
# Name "GenaDrive - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Emu.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\GenaDrive.txt
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Input.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\LightCal.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Loop.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Main.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Makefile
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\app.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "DirectX"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Direct.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DSound.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FileMenu.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\FileMenu.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Font.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\TexScreen.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Pico"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Group "sound"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Pico\sound\driver.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Pico\sound\sn76496.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Pico\sound\sn76496.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Pico\sound\sound.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Pico\sound\sound.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Pico\sound\ym2612.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Pico\sound\ym2612.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Pico\Area.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Pico\Cart.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Pico\Draw.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Pico\Draw2.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Pico\Memory.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Pico\Misc.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Pico\Pico.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Pico\Pico.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Pico\PicoInt.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Pico\Sek.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Pico\Utils.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\Pico\VideoPort.c
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "cores"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Group "musashi"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\cpu\musashi\m68k.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\cpu\musashi\m68kconf.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\cpu\musashi\m68kcpu.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\cpu\musashi\m68kcpu.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\cpu\musashi\m68kdasm.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\cpu\musashi\m68kopac.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\cpu\musashi\m68kopdm.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\cpu\musashi\m68kopnz.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\cpu\musashi\m68kops.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\cpu\musashi\m68kops.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\cpu\mz80\mz80.obj
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\cpu\a68k\a68k.obj
|
||||
|
||||
!IF "$(CFG)" == "GenaDrive - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "GenaDrive - Win32 Debug"
|
||||
|
||||
# PROP Exclude_From_Build 1
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
118
platform/win32/GenaDrive/GenaDrive.txt
Normal file
118
platform/win32/GenaDrive/GenaDrive.txt
Normal file
|
@ -0,0 +1,118 @@
|
|||
|
||||
__________________________________________________________________________________________
|
||||
|
||||
______ _______ __ _ _______ ______ ______ _____ _ _ _______
|
||||
| ____ |______ | \ | |_____| | \ |_____/ | \ / |______
|
||||
|_____| |______ | \_| | | |_____/ | \_ __|__ \/ |______
|
||||
|
||||
G E N A D R I V E
|
||||
|
||||
|
||||
GenaDrive is a Genesis / MegaDrive emulator for the XBox.
|
||||
|
||||
|
||||
#include <std_disclaimer.h>
|
||||
I do not accept responsibility for any effects, adverse or otherwise, that
|
||||
this code may have on you, your computer, your sanity, your dog... etc.
|
||||
You can use this software freely as long as you don't use it commercially.
|
||||
__________________________________________________________________________________________
|
||||
|
||||
Weird Name?
|
||||
|
||||
GenaDrive is a porn-star emulator, based on legendary porn star Jenna Ja... no not really.
|
||||
GenaDrive (one word, capital G, capital D), is pronounced "Jen-A-Drive".
|
||||
|
||||
(Think 'MegaDrive' but with 'Gen' instead of 'Meg'.)
|
||||
|
||||
__________________________________________________________________________________________
|
||||
|
||||
What's New
|
||||
|
||||
v0.004
|
||||
* Merged the PicoDrive and GenaDrive 'Pico' directories, with ifdefs for
|
||||
EMU_C68K (Cyclone) and EMU_A68K.
|
||||
|
||||
v0.003 - Added .SMD support
|
||||
|
||||
v0.002 - First release
|
||||
|
||||
__________________________________________________________________________________________
|
||||
|
||||
Okay but what is it?
|
||||
|
||||
GenaDrive is a partially-complete MegaDrive emulator for the XBox. It emulates the
|
||||
hardware of the MegaDrive console on the XBox. Basically, it makes your XBox act like
|
||||
a MegaDrive.
|
||||
|
||||
It actually uses the same code-base as my Pocket PC 'PicoDrive' emulator, but instead
|
||||
of an ARM-optimized 68000 emulator it uses (naturally) an Intel-optimized one - A68K
|
||||
from the MAME project.
|
||||
|
||||
__________________________________________________________________________________________
|
||||
|
||||
How to use
|
||||
|
||||
Put the emulator (default.xbe) in a directory such as e:\Emulators\GenaDrive\
|
||||
Make sure there is a directory e:\Emulators\GenaDrive\Roms
|
||||
Put your rom images there.
|
||||
|
||||
Run GenaDrive.
|
||||
If it doesn't work, try running 'xbepatch' on the XBE first to convert it to a retail XBE.
|
||||
|
||||
This is minimal zip support, though there must be no other files in each zip.
|
||||
|
||||
Run the emulator and you will see a list of rom images. Push up/down and press A
|
||||
to select a rom image.
|
||||
Click the Right thumbstick in to pause and return to the menu.
|
||||
|
||||
To exit the emulator hold L and R and press Black, or press Back+Start.
|
||||
|
||||
This is just an early version so there's quite a few things missing or not up to scratch,
|
||||
e.g. sound, z80, joypad 2
|
||||
|
||||
__________________________________________________________________________________________
|
||||
|
||||
What's currently emulated:
|
||||
|
||||
68000 : Yes
|
||||
|
||||
VDP
|
||||
Scroll A/B : Yes
|
||||
Line Scroll : Yes
|
||||
Sprites : Sort of
|
||||
Window : Not yet
|
||||
H-Ints/HV Counter : Not yet
|
||||
|
||||
Sound:
|
||||
Z80 : Not yet (faked)
|
||||
YM2151 : Not yet
|
||||
PSG : Not yet
|
||||
|
||||
Compatibility: ~50% ?
|
||||
|
||||
__________________________________________________________________________________________
|
||||
|
||||
Web page and contact info:
|
||||
|
||||
I (Dave) can be reached at the usual spot, my web-page is:
|
||||
|
||||
http://www.finalburn.com/
|
||||
|
||||
And my e-mail address is as follows, just change the (atsymbol) to @
|
||||
|
||||
dev(atsymbol)finalburn.com
|
||||
|
||||
NB - I had to shut down the 'dave' mailbox so it's now 'dev', because the 'dave'
|
||||
e-mail address was printed everywhere and spambots logged it and spammed it to death! :P
|
||||
So if you must quote it, please quote it as above... or better yet just link to my webpage.
|
||||
|
||||
Thanks to:
|
||||
Mike Coates and Darren Olafson once again for A68K
|
||||
Sam for getting me set up on my XBox!
|
||||
Charles Macdonald, for researching just about every console ever
|
||||
MameDev+FBA, for keeping on going and going and going
|
||||
XPort for loads of great XBox emulators
|
||||
|
||||
...and anyone else I forgot!
|
||||
|
||||
__________________________________________________________________________________________
|
247
platform/win32/GenaDrive/Input.cpp
Normal file
247
platform/win32/GenaDrive/Input.cpp
Normal file
|
@ -0,0 +1,247 @@
|
|||
|
||||
#include "app.h"
|
||||
#include <commdlg.h>
|
||||
|
||||
extern char *romname;
|
||||
extern unsigned char *rom_data;
|
||||
extern unsigned int rom_size;
|
||||
extern int fastForward;
|
||||
extern int frameStep;
|
||||
extern int emu_frame;
|
||||
|
||||
struct Input Inp;
|
||||
|
||||
// --------------------- XBox Input -----------------------------
|
||||
#ifdef _XBOX
|
||||
static HANDLE GamePad=NULL;
|
||||
static XINPUT_STATE Pad;
|
||||
|
||||
static int DeadZone(short *paxis)
|
||||
{
|
||||
int zone=0x2000;
|
||||
int a=*paxis;
|
||||
|
||||
if (a<-zone) a+=zone;
|
||||
else if (a> zone) a-=zone; else a=0;
|
||||
|
||||
*paxis=(short)a;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int DeviceRead()
|
||||
{
|
||||
int but=0,a=0;
|
||||
|
||||
memset(Inp.axis, 0,sizeof(Inp.axis));
|
||||
memset(Inp.button,0,sizeof(Inp.button));
|
||||
|
||||
if (GamePad==NULL) GamePad=XInputOpen(XDEVICE_TYPE_GAMEPAD,0,XDEVICE_NO_SLOT,NULL);
|
||||
if (GamePad==NULL) return 1;
|
||||
|
||||
// Read XBox joypad:
|
||||
XInputGetState(GamePad,&Pad);
|
||||
|
||||
// Get analog axes:
|
||||
Inp.axis[0]=Pad.Gamepad.sThumbLX;
|
||||
Inp.axis[1]=Pad.Gamepad.sThumbLY;
|
||||
Inp.axis[2]=Pad.Gamepad.sThumbRX;
|
||||
Inp.axis[3]=Pad.Gamepad.sThumbRY;
|
||||
|
||||
for (a=0;a<4;a++) DeadZone(Inp.axis+a);
|
||||
|
||||
// Get digital buttons:
|
||||
but=Pad.Gamepad.wButtons;
|
||||
for (a=0;a<8;a++)
|
||||
{
|
||||
if (but&(1<<a)) Inp.button[a]=0xff;
|
||||
}
|
||||
|
||||
// Get analog buttons:
|
||||
memcpy(Inp.button+8, Pad.Gamepad.bAnalogButtons, 8);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// --------------------- Windows Input -----------------------------
|
||||
|
||||
#ifndef _XBOX
|
||||
|
||||
static int DeviceRead()
|
||||
{
|
||||
int push=0x6000;
|
||||
int axis[]={0,0,0,0};
|
||||
int i=0;
|
||||
|
||||
memset(Inp.axis, 0,sizeof(Inp.axis));
|
||||
memset(Inp.button,0,sizeof(Inp.button));
|
||||
|
||||
if (GetForegroundWindow()!=FrameWnd) return 1;
|
||||
|
||||
if (GetAsyncKeyState(VK_LEFT )) axis[0]-=push;
|
||||
if (GetAsyncKeyState(VK_RIGHT)) axis[0]+=push;
|
||||
if (GetAsyncKeyState(VK_DOWN )) axis[1]-=push;
|
||||
if (GetAsyncKeyState(VK_UP )) axis[1]+=push;
|
||||
for (i=0;i<4;i++) Inp.axis[i]=(short)axis[i];
|
||||
|
||||
if (GetAsyncKeyState(VK_RETURN)) Inp.button[4]=0xff; // Start
|
||||
//if (GetAsyncKeyState(VK_ESCAPE)) Inp.button[7]=0xff; // Right thumb
|
||||
|
||||
if (GetAsyncKeyState('Z')) Inp.button[10]=0xff;
|
||||
if (GetAsyncKeyState('X')) Inp.button[ 8]=0xff;
|
||||
if (GetAsyncKeyState('C')) Inp.button[ 9]=0xff;
|
||||
|
||||
if (GetAsyncKeyState('A')) Inp.button[13]=0xff;
|
||||
if (GetAsyncKeyState('S')) Inp.button[12]=0xff;
|
||||
if (GetAsyncKeyState('D')) Inp.button[11]=0xff;
|
||||
if (GetAsyncKeyState('F')) Inp.button[14]=0xff;
|
||||
|
||||
static int sblobked = 0;
|
||||
if(!sblobked && GetAsyncKeyState(VK_F6)) {
|
||||
FILE *PmovFile;
|
||||
romname[strlen(romname)-3] = 0;
|
||||
strcat(romname, "mds");
|
||||
PmovFile = fopen(romname, "wb");
|
||||
if(PmovFile) {
|
||||
PmovState(5, PmovFile);
|
||||
fclose(PmovFile);
|
||||
}
|
||||
sblobked = 1;
|
||||
}
|
||||
else if(!sblobked && GetAsyncKeyState(VK_F9)) {
|
||||
FILE *PmovFile;
|
||||
romname[strlen(romname)-3] = 0;
|
||||
strcat(romname, "mds");
|
||||
PmovFile = fopen(romname, "rb");
|
||||
if(PmovFile) {
|
||||
PmovState(6, PmovFile);
|
||||
fclose(PmovFile);
|
||||
}
|
||||
sblobked = 1;
|
||||
}
|
||||
else if(!sblobked && GetAsyncKeyState(VK_TAB)) {
|
||||
PicoReset(0);
|
||||
sblobked = 1;
|
||||
emu_frame = 0;
|
||||
}
|
||||
else if(!sblobked && GetAsyncKeyState(VK_ESCAPE)) {
|
||||
DSoundMute();
|
||||
FILE *rom = 0;
|
||||
OPENFILENAME of; ZeroMemory(&of, sizeof(OPENFILENAME));
|
||||
of.lStructSize = sizeof(OPENFILENAME);
|
||||
of.lpstrFilter = "ROMs\0*.smd;*.bin;*.gen\0";
|
||||
of.lpstrFile = romname; romname[0] = 0;
|
||||
of.nMaxFile = MAX_PATH;
|
||||
of.Flags = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
|
||||
GetOpenFileName(&of);
|
||||
rom = fopen(romname, "rb");
|
||||
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;
|
||||
sblobked = 1;
|
||||
}
|
||||
else
|
||||
sblobked = GetAsyncKeyState(VK_F6) | GetAsyncKeyState(VK_F9) |
|
||||
GetAsyncKeyState(VK_TAB) | GetAsyncKeyState(VK_ESCAPE) |
|
||||
GetAsyncKeyState(VK_BACK) | GetAsyncKeyState(VK_OEM_5);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int InputInit()
|
||||
{
|
||||
memset(&Inp,0,sizeof(Inp));
|
||||
#ifdef _XBOX
|
||||
memset(&Pad,0,sizeof(Pad));
|
||||
XInitDevices(0,NULL);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void InputExit()
|
||||
{
|
||||
#ifdef _XBOX
|
||||
if (GamePad) XInputClose(GamePad);
|
||||
GamePad=NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
int InputUpdate()
|
||||
{
|
||||
int i=0;
|
||||
int push=0x2000;
|
||||
|
||||
DeviceRead(); // Read XBox or PC device
|
||||
|
||||
// Use left analog for left digital too:
|
||||
if (Inp.axis[1]>= push) Inp.button[0]|=0xff; // Up
|
||||
if (Inp.axis[1]<=-push) Inp.button[1]|=0xff; // Down
|
||||
if (Inp.axis[0]<=-push) Inp.button[2]|=0xff; // Left
|
||||
if (Inp.axis[0]>= push) Inp.button[3]|=0xff; // Right
|
||||
|
||||
// Update debounce/time held information:
|
||||
for (i=0;i<sizeof(Inp.held);i++)
|
||||
{
|
||||
if (Inp.held[i]==0)
|
||||
{
|
||||
if (Inp.button[i]>30) Inp.held[i]=1; // Just pressed
|
||||
}
|
||||
else
|
||||
{
|
||||
// Is the button still being held down?
|
||||
Inp.held[i]++;
|
||||
if (Inp.held[i]>=0x80) Inp.held[i]&=0xbf; // (Keep looping around)
|
||||
|
||||
if (Inp.button[i]<25) Inp.held[i]=0; // No
|
||||
}
|
||||
}
|
||||
|
||||
// Work out some key repeat values:
|
||||
for (i=0;i<sizeof(Inp.repeat);i++)
|
||||
{
|
||||
char rep=0;
|
||||
int held=Inp.held[i];
|
||||
|
||||
if (held==1) rep=1;
|
||||
if (held>=0x20 && (held&1)) rep=1;
|
||||
|
||||
Inp.repeat[i]=rep;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Set Lightgun calibration values:
|
||||
int InputLightCal(int cx,int cy,int ux,int uy)
|
||||
{
|
||||
#ifdef _XBOX
|
||||
XINPUT_LIGHTGUN_CALIBRATION_OFFSETS cal;
|
||||
|
||||
memset(&cal,0,sizeof(cal));
|
||||
|
||||
cal.wCenterX =(WORD)cx;
|
||||
cal.wCenterY =(WORD)cy;
|
||||
cal.wUpperLeftX=(WORD)ux;
|
||||
cal.wUpperLeftY=(WORD)uy;
|
||||
XInputSetLightgunCalibration(GamePad,&cal);
|
||||
|
||||
#endif
|
||||
|
||||
(void)(cx+cy+ux+uy);
|
||||
|
||||
return 0;
|
||||
}
|
102
platform/win32/GenaDrive/LightCal.cpp
Normal file
102
platform/win32/GenaDrive/LightCal.cpp
Normal file
|
@ -0,0 +1,102 @@
|
|||
|
||||
#include "app.h"
|
||||
|
||||
struct Target
|
||||
{
|
||||
int sx,sy; // Onscreen coordinates
|
||||
int dx,dy; // Device values
|
||||
};
|
||||
|
||||
struct Target Targ[2]=
|
||||
{
|
||||
{0,0, 0,0},
|
||||
{0,0, 0,0}
|
||||
};
|
||||
static int LightState=0;
|
||||
|
||||
struct Calib
|
||||
{
|
||||
float ax,bx;
|
||||
float ay,by;
|
||||
};
|
||||
static struct Calib Cal={0.0f,0.0f,0.0f,0.0f};
|
||||
|
||||
int LightCalReset()
|
||||
{
|
||||
LightState=0;
|
||||
|
||||
memset(Targ,0,sizeof(Targ));
|
||||
Targ[0].sx=MainWidth >>1;
|
||||
Targ[0].sy=MainHeight>>1;
|
||||
Targ[1].sy=Targ[0].sy-MainHeight*61/160;
|
||||
Targ[1].sx=Targ[0].sx-MainWidth *61/160;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LightCalUpdate()
|
||||
{
|
||||
int i=0;
|
||||
struct Target *pt=NULL;
|
||||
|
||||
if (Inp.held[4]==1) LoopMode=3;
|
||||
|
||||
if (Inp.held[8]==1)
|
||||
{
|
||||
i=LightState&1;
|
||||
pt=Targ+i;
|
||||
|
||||
pt->dx=Inp.axis[0];
|
||||
pt->dy=Inp.axis[1];
|
||||
|
||||
if (i==1)
|
||||
{
|
||||
int num=0,den=0;
|
||||
|
||||
// rx= a + b*x - work out a and b:
|
||||
num=Targ[0].sx-Targ[1].sx;
|
||||
den=Targ[0].dx-Targ[1].dx;
|
||||
if (den) Cal.bx=(float)num/(float)den;
|
||||
Cal.ax=(float)Targ[0].sx-Cal.bx*(float)Targ[0].dx;
|
||||
|
||||
num=Targ[0].sy-Targ[1].sy;
|
||||
den=Targ[0].dy-Targ[1].dy;
|
||||
if (den) Cal.by=(float)num/(float)den;
|
||||
Cal.ay=(float)Targ[0].sy-Cal.by*(float)Targ[0].dy;
|
||||
}
|
||||
|
||||
LightState++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int LightCalRender()
|
||||
{
|
||||
int i=0;
|
||||
struct Target *pt=NULL;
|
||||
float fx=0.0f,fy=0.0f;
|
||||
|
||||
DirectClear(0xffffff);
|
||||
|
||||
WCHAR text[80]={0};
|
||||
wsprintfW(text,L"LightGun Calibration");
|
||||
FontSetColour(0x0000ff);
|
||||
FontText(text,240,48);
|
||||
|
||||
wsprintfW(text,L"Start to quit, B to call InputLightCal");
|
||||
FontSetColour(0x004000);
|
||||
FontText(text,64,120);
|
||||
|
||||
i=LightState&1;
|
||||
pt=Targ+i;
|
||||
FontSetColour(0);
|
||||
FontText(L"X", pt->sx-8, pt->sy-12);
|
||||
|
||||
fx=Cal.ax+Cal.bx*(float)Inp.axis[0];
|
||||
fy=Cal.ay+Cal.by*(float)Inp.axis[1];
|
||||
|
||||
FontSetColour(0xff0000);
|
||||
FontText(L"+", (int)fx-8,(int)fy-12);
|
||||
|
||||
return 0;
|
||||
}
|
244
platform/win32/GenaDrive/Loop.cpp
Normal file
244
platform/win32/GenaDrive/Loop.cpp
Normal file
|
@ -0,0 +1,244 @@
|
|||
#include "app.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;
|
||||
|
||||
char LoopQuit=0;
|
||||
static FILE *DebugFile=NULL;
|
||||
int LoopMode=0;
|
||||
static void UpdateSound();
|
||||
|
||||
int LoopInit()
|
||||
{
|
||||
int ret=0;
|
||||
|
||||
// bits LSb->MSb:
|
||||
// enable_ym2612&dac, enable_sn76496, enable_z80, stereo_sound;
|
||||
// alt_renderer, 6button_gamepad, accurate_timing, accurate_sprites
|
||||
PicoOpt=0x1f;
|
||||
PsndRate=44100;
|
||||
//PsndLen=PsndRate/60; // calculated later by pico itself
|
||||
|
||||
// Init Direct3D:
|
||||
ret=DirectInit(); if (ret) return 1;
|
||||
InputInit();
|
||||
|
||||
// Init DirectSound:
|
||||
//DSoundInit();
|
||||
|
||||
ret=EmuInit(); if (ret) return 1;
|
||||
FileMenu.init();
|
||||
|
||||
LoopMode=8;
|
||||
PicoWriteSound = UpdateSound;
|
||||
|
||||
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();
|
||||
EmuExit();
|
||||
DSoundExit(); PsndLen=0;
|
||||
InputExit();
|
||||
DirectExit();
|
||||
|
||||
if (DebugFile) fclose(DebugFile);
|
||||
DebugFile=NULL;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
int emu_frame = 0;
|
||||
|
||||
static int DoGame()
|
||||
{
|
||||
if(fastForward) { PicoSkipFrame+=1; PicoSkipFrame&=7; }
|
||||
else PicoSkipFrame=0;
|
||||
|
||||
if(frameStep==1) return 0;
|
||||
else if(frameStep==3) frameStep=1;
|
||||
|
||||
EmuFrame();
|
||||
emu_frame++;
|
||||
|
||||
if (Inp.held[7]==1) LoopMode=2; // Right thumb = Toggle Menu
|
||||
|
||||
return 0;
|
||||
}
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
static int MenuUpdate()
|
||||
{
|
||||
int delta=0;
|
||||
|
||||
if (Inp.repeat[0]) delta-=0x100;
|
||||
if (Inp.repeat[1]) delta+=0x100;
|
||||
|
||||
if (Inp.button[14]>30) delta-=Inp.button[14]-30;
|
||||
if (Inp.button[15]>30) delta+=Inp.button[15]-30;
|
||||
|
||||
if (delta) FileMenu.scroll(delta);
|
||||
|
||||
if (Inp.held[8]==1 || Inp.held[10]==1 || Inp.held[4]==1) // A, X or Start
|
||||
{
|
||||
//RomFree();
|
||||
//FileMenu.getFilePath(RomName);
|
||||
//RomLoad();
|
||||
//LoopMode=8; // Go to game
|
||||
}
|
||||
|
||||
if (Inp.held[7]==1) LoopMode=8; // Right thumb = Toggle Menu
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int MenuRender()
|
||||
{
|
||||
WCHAR text[80]={0};
|
||||
wsprintfW(text,L"%.40S v%x.%.3x",AppName,PicoVer>>12,PicoVer&0xfff);
|
||||
FontSetColour(0x60c0ff);
|
||||
FontText(text,64,48);
|
||||
|
||||
FileMenu.render();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
static int ModeUpdate()
|
||||
{
|
||||
if (Inp.held[14] && Inp.held[15] && Inp.held[12]==1) LoopQuit=1; // L+R+black to quit:
|
||||
if (Inp.button[4]>30 && Inp.button[5]>30) LoopQuit=1; // Start and back to quit
|
||||
|
||||
if (LoopMode==8) { DoGame(); return 0; }
|
||||
|
||||
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; }
|
||||
|
||||
LoopMode=2; // Unknown mode, go to rom menu
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int ModeRender()
|
||||
{
|
||||
DirectScreen();
|
||||
if (LoopMode==3) MenuRender();
|
||||
if (LoopMode==4) LightCalRender();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void UpdateSound()
|
||||
{
|
||||
if(fastForward) return;
|
||||
while (DSoundUpdate()) { Sleep(1); }
|
||||
while (DSoundUpdate()==0) { }
|
||||
}
|
||||
|
||||
int LoopCode()
|
||||
{
|
||||
|
||||
// Main loop:
|
||||
while (!LoopQuit)
|
||||
{
|
||||
InputUpdate();
|
||||
|
||||
DirectClear(0);
|
||||
ModeUpdate();
|
||||
ModeRender();
|
||||
DirectPresent();
|
||||
// UpdateSound();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
extern "C" int dprintf(char *format, ...)
|
||||
{
|
||||
char *name=NULL;
|
||||
va_list val=NULL;
|
||||
|
||||
#ifdef _XBOX
|
||||
name="d:\\zout.txt";
|
||||
#else
|
||||
name="zout.txt";
|
||||
#endif
|
||||
|
||||
if (DebugFile==NULL) DebugFile=fopen(name,"wt");
|
||||
if (DebugFile==NULL) return 1;
|
||||
|
||||
fprintf(DebugFile, "%05i: ", emu_frame);
|
||||
va_start(val,format);
|
||||
vfprintf(DebugFile,format,val);
|
||||
fprintf(DebugFile, "\n");
|
||||
fflush(DebugFile);
|
||||
|
||||
va_end(val);
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int dprintf2(char *format, ...)
|
||||
{
|
||||
char str[512];
|
||||
va_list val=NULL;
|
||||
|
||||
va_start(val,format);
|
||||
vsprintf(str,format,val);
|
||||
va_end(val);
|
||||
OutputDebugString(str);
|
||||
|
||||
return 0;
|
||||
}
|
178
platform/win32/GenaDrive/Main.cpp
Normal file
178
platform/win32/GenaDrive/Main.cpp
Normal file
|
@ -0,0 +1,178 @@
|
|||
|
||||
#include "app.h"
|
||||
#include <crtdbg.h>
|
||||
#include <commdlg.h>
|
||||
|
||||
char *romname;
|
||||
HWND FrameWnd=NULL;
|
||||
|
||||
int MainWidth=720,MainHeight=480;
|
||||
|
||||
char AppName[]="GenaDrive";
|
||||
|
||||
#ifdef STARSCREAM
|
||||
extern "C" int SekReset();
|
||||
#endif
|
||||
|
||||
// ------------------------------------ XBox Main ------------------------------------------
|
||||
#ifdef _XBOX
|
||||
|
||||
static int MainCode()
|
||||
{
|
||||
int ret=0;
|
||||
|
||||
ret=LoopInit(); if (ret) { LoopExit(); return 1; }
|
||||
|
||||
LoopQuit=0; LoopCode();
|
||||
LoopExit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int __cdecl main()
|
||||
{
|
||||
LD_LAUNCH_DASHBOARD launch;
|
||||
|
||||
MainCode();
|
||||
|
||||
// Go back to dashboard:
|
||||
memset(&launch,0,sizeof(launch));
|
||||
launch.dwReason=XLD_LAUNCH_DASHBOARD_MAIN_MENU;
|
||||
XLaunchNewImage(NULL,(LAUNCH_DATA *)&launch);
|
||||
}
|
||||
#endif
|
||||
|
||||
// ----------------------------------- Windows Main ----------------------------------------
|
||||
#ifndef _XBOX
|
||||
// Window proc for the frame window:
|
||||
static LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam)
|
||||
{
|
||||
if (msg==WM_CLOSE) { PostQuitMessage(0); return 0; }
|
||||
if (msg==WM_DESTROY) FrameWnd=NULL; // Blank handle
|
||||
|
||||
return DefWindowProc(hwnd,msg,wparam,lparam);
|
||||
}
|
||||
|
||||
static int FrameInit()
|
||||
{
|
||||
WNDCLASS wc;
|
||||
RECT rect={0,0,0,0};
|
||||
int style=0;
|
||||
int left=0,top=0,width=0,height=0;
|
||||
|
||||
memset(&wc,0,sizeof(wc));
|
||||
|
||||
// Register the window class:
|
||||
wc.lpfnWndProc=WndProc;
|
||||
wc.hInstance=GetModuleHandle(NULL);
|
||||
wc.hCursor=LoadCursor(NULL,IDC_ARROW);
|
||||
wc.hbrBackground=CreateSolidBrush(0);
|
||||
wc.lpszClassName="MainFrame";
|
||||
RegisterClass(&wc);
|
||||
|
||||
rect.right =320;//MainWidth;
|
||||
rect.bottom=224;//MainHeight;
|
||||
|
||||
// Adjust size of windows based on borders:
|
||||
style=WS_OVERLAPPEDWINDOW;
|
||||
AdjustWindowRect(&rect,style,0);
|
||||
width =rect.right-rect.left;
|
||||
height=rect.bottom-rect.top;
|
||||
|
||||
// Place window in the centre of the screen:
|
||||
SystemParametersInfo(SPI_GETWORKAREA,0,&rect,0);
|
||||
left=rect.left+rect.right;
|
||||
top=rect.top+rect.bottom;
|
||||
|
||||
left-=width; left>>=1;
|
||||
top-=height; top>>=1;
|
||||
|
||||
// Create the window:
|
||||
FrameWnd=CreateWindow(wc.lpszClassName,AppName,style|WS_VISIBLE,
|
||||
left,top,width,height,NULL,NULL,NULL,NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// --------------------
|
||||
|
||||
static DWORD WINAPI ThreadCode(void *)
|
||||
{
|
||||
LoopCode();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// starscream needs this
|
||||
unsigned char *rom_data = 0;
|
||||
unsigned int rom_size = 0;
|
||||
|
||||
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR cmdline,int)
|
||||
{
|
||||
MSG msg;
|
||||
int ret=0;
|
||||
DWORD tid=0;
|
||||
HANDLE thread=NULL;
|
||||
|
||||
// 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");
|
||||
if(!rom) {
|
||||
OPENFILENAME of; ZeroMemory(&of, sizeof(OPENFILENAME));
|
||||
of.lStructSize = sizeof(OPENFILENAME);
|
||||
of.lpstrFilter = "ROMs\0*.smd;*.bin;*.gen\0";
|
||||
of.lpstrFile = rompath; rompath[0] = 0;
|
||||
of.nMaxFile = MAX_PATH;
|
||||
of.Flags = OFN_FILEMUSTEXIST|OFN_HIDEREADONLY;
|
||||
if(!GetOpenFileName(&of)) return 1;
|
||||
rom = fopen(rompath, "rb");
|
||||
if(!rom) return 1;
|
||||
}
|
||||
romname = rompath;
|
||||
|
||||
if(PicoCartLoad(rom, &rom_data, &rom_size)) {
|
||||
//RDebug::Print(_L("PicoCartLoad() failed."));
|
||||
//goto cleanup;
|
||||
}
|
||||
|
||||
FrameInit();
|
||||
ret=LoopInit(); if (ret) { LoopExit(); return 1; }
|
||||
|
||||
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);
|
||||
|
||||
// Main window loop:
|
||||
for (;;)
|
||||
{
|
||||
GetMessage(&msg,NULL,0,0);
|
||||
if (msg.message==WM_QUIT) break;
|
||||
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
// Signal thread to quit and wait for it to exit:
|
||||
LoopQuit=1; WaitForSingleObject(thread,5000);
|
||||
CloseHandle(thread); thread=NULL;
|
||||
|
||||
LoopExit();
|
||||
DestroyWindow(FrameWnd);
|
||||
|
||||
free(rom_data);
|
||||
|
||||
_CrtDumpMemoryLeaks();
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
143
platform/win32/GenaDrive/Rom.cpp
Normal file
143
platform/win32/GenaDrive/Rom.cpp
Normal file
|
@ -0,0 +1,143 @@
|
|||
|
||||
#include "app.h"
|
||||
#include "Unzip.h"
|
||||
|
||||
unsigned char *RomData=NULL;
|
||||
int RomLen=0;
|
||||
char RomName[260]="";
|
||||
|
||||
|
||||
static int Byteswap(unsigned char *data,int len)
|
||||
{
|
||||
int i=0;
|
||||
|
||||
if (len<2) return 1; // Too short
|
||||
|
||||
do
|
||||
{
|
||||
unsigned short *pd=(unsigned short *)(data+i);
|
||||
int word=*pd; // Get word
|
||||
|
||||
word=(word<<8)|(word>>8); // Byteswap it
|
||||
*pd=(unsigned short)word; // Put word
|
||||
i+=2;
|
||||
}
|
||||
while (i+2<=len);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Interleve a 16k block and byteswap
|
||||
static int InterleveBlock(unsigned char *dest,unsigned char *src)
|
||||
{
|
||||
int i=0;
|
||||
for (i=0;i<0x2000;i++) dest[(i<<1) ]=src[ i]; // Odd
|
||||
for (i=0;i<0x2000;i++) dest[(i<<1)+1]=src[0x2000+i]; // Even
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Decode a SMD file
|
||||
static int DecodeSmd(unsigned char *data,int len)
|
||||
{
|
||||
unsigned char *temp=NULL;
|
||||
int i=0;
|
||||
|
||||
temp=(unsigned char *)malloc(0x4000);
|
||||
if (temp==NULL) return 1;
|
||||
memset(temp,0,0x4000);
|
||||
|
||||
// Interleve each 16k block and shift down by 0x200:
|
||||
for (i=0; i+0x4200<=len; i+=0x4000)
|
||||
{
|
||||
InterleveBlock(temp,data+0x200+i); // Interleve 16k to temporary buffer
|
||||
memcpy(data+i,temp,0x4000); // Copy back in
|
||||
}
|
||||
|
||||
free(temp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int RomLoad()
|
||||
{
|
||||
FILE *file=NULL;
|
||||
char *name=NULL;
|
||||
int nameLen=0;
|
||||
int fileLen=0,space=0;
|
||||
Unzip unzip;
|
||||
|
||||
name=RomName;
|
||||
|
||||
file=fopen(name,"rb"); if (file==NULL) return 1;
|
||||
|
||||
nameLen=strlen(name);
|
||||
if (stricmp(name+nameLen-4,".zip")==0) unzip.file=file; // Open as zip file
|
||||
|
||||
if (unzip.file)
|
||||
{
|
||||
int ret=0;
|
||||
|
||||
ret=unzip.fileOpen(); // Get first entry
|
||||
if (ret==0)
|
||||
{
|
||||
fileLen=unzip.dataLen; // Length of file
|
||||
// Switch to using the name in the zip file:
|
||||
name=unzip.name; nameLen=strlen(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
unzip.file=NULL;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// Find out the length of the file:
|
||||
fseek(file,0,SEEK_END); fileLen=ftell(file);
|
||||
fseek(file,0,SEEK_SET);
|
||||
}
|
||||
|
||||
// Allocate space for it:
|
||||
space=(fileLen+0x3fff)&~0x3fff;
|
||||
|
||||
RomData=(unsigned char *)malloc(space);
|
||||
if (RomData==NULL) { fclose(file); return 1; }
|
||||
memset(RomData,0,space);
|
||||
|
||||
// Read in file:
|
||||
if (unzip.file) unzip.fileDecode(RomData);
|
||||
else fread(RomData,1,fileLen,file);
|
||||
|
||||
unzip.fileClose();
|
||||
|
||||
fclose(file);
|
||||
unzip.file=file=NULL;
|
||||
|
||||
RomLen=fileLen;
|
||||
|
||||
// Check for SMD:
|
||||
if ((fileLen&0x3fff)==0x200)
|
||||
{
|
||||
// Decode and byteswap:
|
||||
DecodeSmd(RomData,RomLen);
|
||||
RomLen-=0x200;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Just byteswap:
|
||||
Byteswap(RomData,RomLen);
|
||||
}
|
||||
|
||||
PicoCartInsert(RomData,RomLen);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RomFree()
|
||||
{
|
||||
// PicoCartInsert(NULL,0); // Unplug rom
|
||||
|
||||
if (RomData) free(RomData);
|
||||
RomData=NULL; RomLen=0;
|
||||
memset(RomName,0,sizeof(RomName));
|
||||
}
|
||||
|
107
platform/win32/GenaDrive/TexScreen.cpp
Normal file
107
platform/win32/GenaDrive/TexScreen.cpp
Normal file
|
@ -0,0 +1,107 @@
|
|||
|
||||
#include "app.h"
|
||||
|
||||
IDirect3DTexture8 *TexScreen=NULL;
|
||||
int TexWidth=0,TexHeight=0;
|
||||
|
||||
// Blank the texture:
|
||||
static int TexBlank()
|
||||
{
|
||||
D3DLOCKED_RECT lock={0,NULL};
|
||||
unsigned char *dest=NULL;
|
||||
int y=0,line=0;
|
||||
|
||||
TexScreen->LockRect(0,&lock,NULL,0); if (lock.pBits==NULL) return 1;
|
||||
|
||||
dest=(unsigned char *)lock.pBits;
|
||||
for (y=0; y<TexHeight; y++,line+=lock.Pitch)
|
||||
{
|
||||
memset(dest+line,0,TexWidth<<1);
|
||||
}
|
||||
|
||||
TexScreen->UnlockRect(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int TexScreenInit()
|
||||
{
|
||||
TexWidth =512;
|
||||
TexHeight=512;
|
||||
|
||||
Device->CreateTexture(TexWidth,TexHeight,1,0,D3DFMT_R5G6B5,D3DPOOL_MANAGED,&TexScreen);
|
||||
if (TexScreen==NULL) return 1;
|
||||
|
||||
TexBlank();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void TexScreenExit()
|
||||
{
|
||||
RELEASE(TexScreen)
|
||||
TexWidth=TexHeight=0;
|
||||
}
|
||||
|
||||
// Copy screen to a swizzled texture
|
||||
int TexScreenSwizzle()
|
||||
{
|
||||
D3DLOCKED_RECT lock={0,NULL};
|
||||
unsigned char *dest=NULL;
|
||||
int y=0,sy=0,mask=0;
|
||||
unsigned short *ps=NULL;
|
||||
|
||||
mask=TexWidth*TexHeight-1;
|
||||
|
||||
TexScreen->LockRect(0,&lock,NULL,0); if (lock.pBits==NULL) return 1;
|
||||
|
||||
dest=(unsigned char *)lock.pBits;
|
||||
ps=EmuScreen;
|
||||
|
||||
// Write to swizzled locations:
|
||||
for (y=0,sy=0; y<EmuHeight; y++,sy++)
|
||||
{
|
||||
int x=0,sx=0;
|
||||
sy|=0x55555555;
|
||||
|
||||
for (x=0,sx=0; x<EmuWidth; x++,sx++)
|
||||
{
|
||||
int addr=0;
|
||||
|
||||
sx|=0xaaaaaaaa;
|
||||
addr=sx&sy&mask; // Calculate swizzled address
|
||||
|
||||
((unsigned short *)dest)[addr]=*ps++;
|
||||
}
|
||||
}
|
||||
|
||||
TexScreen->UnlockRect(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Copy screen to a linear texture:
|
||||
int TexScreenLinear()
|
||||
{
|
||||
D3DLOCKED_RECT lock={0,NULL};
|
||||
unsigned char *dest=NULL;
|
||||
int y=0,line=0;
|
||||
unsigned short *ps=NULL;
|
||||
|
||||
TexScreen->LockRect(0,&lock,NULL,0); if (lock.pBits==NULL) return 1;
|
||||
|
||||
dest=(unsigned char *)lock.pBits;
|
||||
ps=EmuScreen;
|
||||
|
||||
for (y=0; y<EmuHeight; y++,line+=lock.Pitch)
|
||||
{
|
||||
int x=0;
|
||||
int addr=line;
|
||||
|
||||
for (x=0; x<EmuWidth; x++,addr+=2)
|
||||
{
|
||||
*(unsigned int *)(dest+addr)=*ps++;
|
||||
}
|
||||
}
|
||||
|
||||
TexScreen->UnlockRect(0);
|
||||
return 0;
|
||||
}
|
109
platform/win32/GenaDrive/Unzip.cpp
Normal file
109
platform/win32/GenaDrive/Unzip.cpp
Normal file
|
@ -0,0 +1,109 @@
|
|||
|
||||
|
||||
#include "app.h"
|
||||
#include "Unzip.h"
|
||||
#include "zlib.h"
|
||||
|
||||
// Decompress a 'deflate' compressed buffer
|
||||
static int Inflate(unsigned char *dest,int destLen, unsigned char *src,int srcLen)
|
||||
{
|
||||
z_stream stream;
|
||||
|
||||
memset(&stream,0,sizeof(stream));
|
||||
|
||||
stream.next_in =src;
|
||||
stream.avail_in =srcLen;
|
||||
stream.next_out =dest;
|
||||
stream.avail_out=destLen;
|
||||
inflateInit2(&stream,-15);
|
||||
inflate(&stream,Z_FINISH);
|
||||
inflateEnd(&stream);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int Get32(unsigned char *src)
|
||||
{
|
||||
return src[0] | (src[1]<<8) | (src[2]<<16) | (src[3]<<24);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
Unzip::Unzip()
|
||||
{
|
||||
memset(this,0,sizeof(*this));
|
||||
}
|
||||
|
||||
int Unzip::gotoFirstFile()
|
||||
{
|
||||
headerPos=0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Unzip::fileOpen()
|
||||
{
|
||||
int ret=0,okay=0;
|
||||
|
||||
fseek(file,headerPos,SEEK_SET);
|
||||
|
||||
// Read in file entry header:
|
||||
ret=fread(head,1,sizeof(head),file);
|
||||
if (ret!=sizeof(head)) return 1;
|
||||
|
||||
// Check header:
|
||||
if (head[0]=='P' && head[1]=='K' && head[2]==3 && head[3]==4) okay=1;
|
||||
if (okay==0) return 1;
|
||||
|
||||
// Get compressed and uncompressed sizes:
|
||||
srcLen =Get32(head+0x12);
|
||||
dataLen=Get32(head+0x16);
|
||||
|
||||
// Get size of name and extra fields:
|
||||
nameLen=Get32(head+0x1a);
|
||||
extraLen=nameLen>>16; nameLen&=0xffff;
|
||||
|
||||
// Read in name:
|
||||
name=(char *)malloc(nameLen+1); if (name==NULL) return 1;
|
||||
memset(name,0,nameLen+1);
|
||||
fread(name,1,nameLen,file);
|
||||
|
||||
// Find position of compressed data in the file
|
||||
compPos=headerPos+sizeof(head);
|
||||
compPos+=nameLen+extraLen;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Unzip::fileClose()
|
||||
{
|
||||
free(name); name=NULL;
|
||||
|
||||
// Go to next header:
|
||||
headerPos=compPos+srcLen;
|
||||
|
||||
srcLen=dataLen=0;
|
||||
nameLen=extraLen=0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Unzip::fileDecode(unsigned char *data)
|
||||
{
|
||||
unsigned char *src=NULL;
|
||||
|
||||
// Go to compressed data:
|
||||
fseek(file,compPos,SEEK_SET);
|
||||
|
||||
// Allocate memory:
|
||||
src=(unsigned char *)malloc(srcLen);
|
||||
if (src==NULL) { fclose(file); return 1; }
|
||||
memset(src,0,srcLen);
|
||||
|
||||
// Read in compressed version and decompress
|
||||
fread(src,1,srcLen,file);
|
||||
|
||||
Inflate(data,dataLen, src,srcLen);
|
||||
|
||||
free(src); src=NULL; srcLen=0;
|
||||
|
||||
return 0;
|
||||
}
|
23
platform/win32/GenaDrive/Unzip.h
Normal file
23
platform/win32/GenaDrive/Unzip.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
|
||||
|
||||
class Unzip
|
||||
{
|
||||
public:
|
||||
Unzip();
|
||||
FILE *file; // Zip file current open
|
||||
unsigned char head[0x1e]; // Zip entry header
|
||||
int dataLen; // Zip entry dest (uncompressed) size
|
||||
|
||||
char *name; // Name of entry
|
||||
|
||||
int gotoFirstFile();
|
||||
int fileOpen();
|
||||
int fileClose();
|
||||
int fileDecode(unsigned char *data);
|
||||
|
||||
private:
|
||||
int srcLen; // Zip entry source (compressed) size
|
||||
int nameLen,extraLen; // Length of name field and extra fields
|
||||
int headerPos; // Position of file entry header (PK... etc)
|
||||
int compPos; // Position of compressed data
|
||||
};
|
108
platform/win32/GenaDrive/app.h
Normal file
108
platform/win32/GenaDrive/app.h
Normal file
|
@ -0,0 +1,108 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef _XBOX
|
||||
#include <xtl.h>
|
||||
#endif
|
||||
|
||||
#ifndef _XBOX
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <d3d8.h>
|
||||
#endif
|
||||
|
||||
#include <d3dx8.h>
|
||||
|
||||
#include "Pico.h"
|
||||
|
||||
#define PI 3.14159265f
|
||||
|
||||
#define RELEASE(x) if (x) x->Release(); x=NULL;
|
||||
|
||||
#ifdef _XBOX
|
||||
#define HOME "d:\\"
|
||||
#else
|
||||
#define HOME ".\\"
|
||||
#endif
|
||||
|
||||
// Emu.cpp
|
||||
extern unsigned short *EmuScreen;
|
||||
extern int EmuWidth,EmuHeight;
|
||||
int EmuInit();
|
||||
void EmuExit();
|
||||
int EmuRomLoad(char *name);
|
||||
int EmuFrame();
|
||||
|
||||
// Input.cpp
|
||||
struct Input
|
||||
{
|
||||
short axis[4];
|
||||
unsigned char button[16];
|
||||
unsigned char held[16]; // How long has the button been held
|
||||
char repeat[16]; // Auto-repeat
|
||||
};
|
||||
extern struct Input Inp;
|
||||
int InputInit();
|
||||
void InputExit();
|
||||
int InputUpdate();
|
||||
int InputLightCal(int cx,int cy,int ux,int uy);
|
||||
|
||||
// LightCal.cpp
|
||||
int LightCalReset();
|
||||
int LightCalUpdate();
|
||||
int LightCalRender();
|
||||
|
||||
// Loop.cpp
|
||||
void preLoopInit();
|
||||
extern char LoopQuit;
|
||||
extern int LoopMode;
|
||||
|
||||
int LoopInit();
|
||||
void LoopExit();
|
||||
int LoopCode();
|
||||
|
||||
// Main.cpp
|
||||
extern HWND FrameWnd;
|
||||
extern int MainWidth,MainHeight;
|
||||
extern char AppName[];
|
||||
extern "C" int dprintf(char *format, ...);
|
||||
|
||||
// Rom.cpp
|
||||
extern unsigned char *RomData;
|
||||
extern int RomLen;
|
||||
extern char RomName[260];
|
||||
int RomLoad();
|
||||
void RomFree();
|
||||
|
||||
// --------------------------------------------
|
||||
// Direct.cpp
|
||||
extern IDirect3DDevice8 *Device;
|
||||
extern IDirect3DSurface8 *DirectBack; // Back Buffer
|
||||
int DirectInit();
|
||||
int DirectClear(unsigned int colour);
|
||||
int DirectScreen();
|
||||
int DirectPresent();
|
||||
void DirectExit();
|
||||
|
||||
// DSound.cpp:
|
||||
int DSoundInit();
|
||||
void DSoundExit();
|
||||
int DSoundUpdate();
|
||||
extern short *DSoundNext; // Buffer for next sound data to put in loop
|
||||
//extern int DSoundSeg; // Seg length in samples
|
||||
void DSoundMute();
|
||||
void DSoundUnMute();
|
||||
|
||||
// Font.cpp
|
||||
int FontInit();
|
||||
void FontExit();
|
||||
int FontSetColour(unsigned int colour);
|
||||
int FontText(WCHAR *,int,int);
|
||||
|
||||
// TexScreen.cpp
|
||||
extern IDirect3DTexture8 *TexScreen;
|
||||
extern int TexWidth,TexHeight;
|
||||
int TexScreenInit();
|
||||
void TexScreenExit();
|
||||
int TexScreenSwizzle();
|
||||
int TexScreenLinear();
|
27
platform/win32/GenaDrive/port_config.h
Normal file
27
platform/win32/GenaDrive/port_config.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
// port specific settings
|
||||
|
||||
#ifndef PORT_CONFIG_H
|
||||
#define PORT_CONFIG_H
|
||||
|
||||
#define CPU_CALL __fastcall
|
||||
|
||||
// draw2.c
|
||||
#define START_ROW 0 // which row of tiles to start rendering at?
|
||||
#define END_ROW 28 // ..end
|
||||
|
||||
// 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
|
||||
|
||||
#endif //PORT_CONFIG_H
|
323
platform/win32/GenaDrive/zconf.h
Normal file
323
platform/win32/GenaDrive/zconf.h
Normal file
|
@ -0,0 +1,323 @@
|
|||
/* zconf.h -- configuration of the zlib compression library
|
||||
* Copyright (C) 1995-2003 Jean-loup Gailly.
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* @(#) $Id$ */
|
||||
|
||||
#ifndef ZCONF_H
|
||||
#define ZCONF_H
|
||||
|
||||
/*
|
||||
* If you *really* need a unique prefix for all types and library functions,
|
||||
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
|
||||
*/
|
||||
#ifdef Z_PREFIX
|
||||
# define deflateInit_ z_deflateInit_
|
||||
# define deflate z_deflate
|
||||
# define deflateEnd z_deflateEnd
|
||||
# define inflateInit_ z_inflateInit_
|
||||
# define inflate z_inflate
|
||||
# define inflateEnd z_inflateEnd
|
||||
# define deflateInit2_ z_deflateInit2_
|
||||
# define deflateSetDictionary z_deflateSetDictionary
|
||||
# define deflateCopy z_deflateCopy
|
||||
# define deflateReset z_deflateReset
|
||||
# define deflatePrime z_deflatePrime
|
||||
# define deflateParams z_deflateParams
|
||||
# define deflateBound z_deflateBound
|
||||
# define inflateInit2_ z_inflateInit2_
|
||||
# define inflateSetDictionary z_inflateSetDictionary
|
||||
# define inflateSync z_inflateSync
|
||||
# define inflateSyncPoint z_inflateSyncPoint
|
||||
# define inflateCopy z_inflateCopy
|
||||
# define inflateReset z_inflateReset
|
||||
# define compress z_compress
|
||||
# define compress2 z_compress2
|
||||
# define compressBound z_compressBound
|
||||
# define uncompress z_uncompress
|
||||
# define adler32 z_adler32
|
||||
# define crc32 z_crc32
|
||||
# define get_crc_table z_get_crc_table
|
||||
|
||||
# define Byte z_Byte
|
||||
# define uInt z_uInt
|
||||
# define uLong z_uLong
|
||||
# define Bytef z_Bytef
|
||||
# define charf z_charf
|
||||
# define intf z_intf
|
||||
# define uIntf z_uIntf
|
||||
# define uLongf z_uLongf
|
||||
# define voidpf z_voidpf
|
||||
# define voidp z_voidp
|
||||
#endif
|
||||
|
||||
#if defined(__MSDOS__) && !defined(MSDOS)
|
||||
# define MSDOS
|
||||
#endif
|
||||
#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
|
||||
# define OS2
|
||||
#endif
|
||||
#if defined(_WINDOWS) && !defined(WINDOWS)
|
||||
# define WINDOWS
|
||||
#endif
|
||||
#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
|
||||
# define WIN32
|
||||
#endif
|
||||
#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
|
||||
# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
|
||||
# ifndef SYS16BIT
|
||||
# define SYS16BIT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Compile with -DMAXSEG_64K if the alloc function cannot allocate more
|
||||
* than 64k bytes at a time (needed on systems with 16-bit int).
|
||||
*/
|
||||
#ifdef SYS16BIT
|
||||
# define MAXSEG_64K
|
||||
#endif
|
||||
#ifdef MSDOS
|
||||
# define UNALIGNED_OK
|
||||
#endif
|
||||
|
||||
#ifdef __STDC_VERSION__
|
||||
# ifndef STDC
|
||||
# define STDC
|
||||
# endif
|
||||
# if __STDC_VERSION__ >= 199901L
|
||||
# ifndef STDC99
|
||||
# define STDC99
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
|
||||
# define STDC
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
|
||||
# define STDC
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
|
||||
# define STDC
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
|
||||
# define STDC
|
||||
#endif
|
||||
|
||||
#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
|
||||
# define STDC
|
||||
#endif
|
||||
|
||||
#ifndef STDC
|
||||
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
|
||||
# define const /* note: need a more gentle solution here */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Some Mac compilers merge all .h files incorrectly: */
|
||||
#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
|
||||
# define NO_DUMMY_DECL
|
||||
#endif
|
||||
|
||||
/* Maximum value for memLevel in deflateInit2 */
|
||||
#ifndef MAX_MEM_LEVEL
|
||||
# ifdef MAXSEG_64K
|
||||
# define MAX_MEM_LEVEL 8
|
||||
# else
|
||||
# define MAX_MEM_LEVEL 9
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Maximum value for windowBits in deflateInit2 and inflateInit2.
|
||||
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
|
||||
* created by gzip. (Files created by minigzip can still be extracted by
|
||||
* gzip.)
|
||||
*/
|
||||
#ifndef MAX_WBITS
|
||||
# define MAX_WBITS 15 /* 32K LZ77 window */
|
||||
#endif
|
||||
|
||||
/* The memory requirements for deflate are (in bytes):
|
||||
(1 << (windowBits+2)) + (1 << (memLevel+9))
|
||||
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
|
||||
plus a few kilobytes for small objects. For example, if you want to reduce
|
||||
the default memory requirements from 256K to 128K, compile with
|
||||
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
|
||||
Of course this will generally degrade compression (there's no free lunch).
|
||||
|
||||
The memory requirements for inflate are (in bytes) 1 << windowBits
|
||||
that is, 32K for windowBits=15 (default value) plus a few kilobytes
|
||||
for small objects.
|
||||
*/
|
||||
|
||||
/* Type declarations */
|
||||
|
||||
#ifndef OF /* function prototypes */
|
||||
# ifdef STDC
|
||||
# define OF(args) args
|
||||
# else
|
||||
# define OF(args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* The following definitions for FAR are needed only for MSDOS mixed
|
||||
* model programming (small or medium model with some far allocations).
|
||||
* This was tried only with MSC; for other MSDOS compilers you may have
|
||||
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
|
||||
* just define FAR to be empty.
|
||||
*/
|
||||
#ifdef SYS16BIT
|
||||
# if defined(M_I86SM) || defined(M_I86MM)
|
||||
/* MSC small or medium model */
|
||||
# define SMALL_MEDIUM
|
||||
# ifdef _MSC_VER
|
||||
# define FAR _far
|
||||
# else
|
||||
# define FAR far
|
||||
# endif
|
||||
# endif
|
||||
# if (defined(__SMALL__) || defined(__MEDIUM__))
|
||||
/* Turbo C small or medium model */
|
||||
# define SMALL_MEDIUM
|
||||
# ifdef __BORLANDC__
|
||||
# define FAR _far
|
||||
# else
|
||||
# define FAR far
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(WINDOWS) || defined(WIN32)
|
||||
/* If building or using zlib as a DLL, define ZLIB_DLL.
|
||||
* This is not mandatory, but it offers a little performance increase.
|
||||
*/
|
||||
# ifdef ZLIB_DLL
|
||||
# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
|
||||
# ifdef ZLIB_INTERNAL
|
||||
# define ZEXTERN extern __declspec(dllexport)
|
||||
# else
|
||||
# define ZEXTERN extern __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
# endif /* ZLIB_DLL */
|
||||
/* If building or using zlib with the WINAPI/WINAPIV calling convention,
|
||||
* define ZLIB_WINAPI.
|
||||
* Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
|
||||
*/
|
||||
# ifdef ZLIB_WINAPI
|
||||
# ifdef FAR
|
||||
# undef FAR
|
||||
# endif
|
||||
# include <windows.h>
|
||||
/* No need for _export, use ZLIB.DEF instead. */
|
||||
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
|
||||
# define ZEXPORT WINAPI
|
||||
# ifdef WIN32
|
||||
# define ZEXPORTVA WINAPIV
|
||||
# else
|
||||
# define ZEXPORTVA FAR CDECL
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (__BEOS__)
|
||||
# ifdef ZLIB_DLL
|
||||
# ifdef ZLIB_INTERNAL
|
||||
# define ZEXPORT __declspec(dllexport)
|
||||
# define ZEXPORTVA __declspec(dllexport)
|
||||
# else
|
||||
# define ZEXPORT __declspec(dllimport)
|
||||
# define ZEXPORTVA __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef ZEXTERN
|
||||
# define ZEXTERN extern
|
||||
#endif
|
||||
#ifndef ZEXPORT
|
||||
# define ZEXPORT
|
||||
#endif
|
||||
#ifndef ZEXPORTVA
|
||||
# define ZEXPORTVA
|
||||
#endif
|
||||
|
||||
#ifndef FAR
|
||||
# define FAR
|
||||
#endif
|
||||
|
||||
#if !defined(__MACTYPES__)
|
||||
typedef unsigned char Byte; /* 8 bits */
|
||||
#endif
|
||||
typedef unsigned int uInt; /* 16 bits or more */
|
||||
typedef unsigned long uLong; /* 32 bits or more */
|
||||
|
||||
#ifdef SMALL_MEDIUM
|
||||
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
|
||||
# define Bytef Byte FAR
|
||||
#else
|
||||
typedef Byte FAR Bytef;
|
||||
#endif
|
||||
typedef char FAR charf;
|
||||
typedef int FAR intf;
|
||||
typedef uInt FAR uIntf;
|
||||
typedef uLong FAR uLongf;
|
||||
|
||||
#ifdef STDC
|
||||
typedef void const *voidpc;
|
||||
typedef void FAR *voidpf;
|
||||
typedef void *voidp;
|
||||
#else
|
||||
typedef Byte const *voidpc;
|
||||
typedef Byte FAR *voidpf;
|
||||
typedef Byte *voidp;
|
||||
#endif
|
||||
|
||||
#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */
|
||||
# include <sys/types.h> /* for off_t */
|
||||
# include <unistd.h> /* for SEEK_* and off_t */
|
||||
# ifdef VMS
|
||||
# include <unixio.h> /* for off_t */
|
||||
# endif
|
||||
# define z_off_t off_t
|
||||
#endif
|
||||
#ifndef SEEK_SET
|
||||
# define SEEK_SET 0 /* Seek from beginning of file. */
|
||||
# define SEEK_CUR 1 /* Seek from current position. */
|
||||
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
|
||||
#endif
|
||||
#ifndef z_off_t
|
||||
# define z_off_t long
|
||||
#endif
|
||||
|
||||
#if defined(__OS400__)
|
||||
#define NO_vsnprintf
|
||||
#endif
|
||||
|
||||
#if defined(__MVS__)
|
||||
# define NO_vsnprintf
|
||||
# ifdef FAR
|
||||
# undef FAR
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* MVS linker does not support external names larger than 8 bytes */
|
||||
#if defined(__MVS__)
|
||||
# pragma map(deflateInit_,"DEIN")
|
||||
# pragma map(deflateInit2_,"DEIN2")
|
||||
# pragma map(deflateEnd,"DEEND")
|
||||
# pragma map(deflateBound,"DEBND")
|
||||
# pragma map(inflateInit_,"ININ")
|
||||
# pragma map(inflateInit2_,"ININ2")
|
||||
# pragma map(inflateEnd,"INEND")
|
||||
# pragma map(inflateSync,"INSY")
|
||||
# pragma map(inflateSetDictionary,"INSEDI")
|
||||
# pragma map(compressBound,"CMBND")
|
||||
# pragma map(inflate_table,"INTABL")
|
||||
# pragma map(inflate_fast,"INFA")
|
||||
# pragma map(inflate_copyright,"INCOPY")
|
||||
#endif
|
||||
|
||||
#endif /* ZCONF_H */
|
1200
platform/win32/GenaDrive/zlib.h
Normal file
1200
platform/win32/GenaDrive/zlib.h
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue