cleaned some #ifdef windows code out of fceu.cpp
spiffied a few docs
This commit is contained in:
parent
3a1a7df520
commit
775c886a88
4
driver.h
4
driver.h
|
@ -321,10 +321,10 @@ void FCEUD_DebugBreakpoint();
|
||||||
//(we should move the code in the win driver that does this to the shared area)
|
//(we should move the code in the win driver that does this to the shared area)
|
||||||
void FCEUD_TraceInstruction();
|
void FCEUD_TraceInstruction();
|
||||||
|
|
||||||
//the driver might should update its NTView
|
//the driver might should update its NTView (only used if debugging support is compiled in)
|
||||||
void FCEUD_UpdateNTView(int scanline, int drawall);
|
void FCEUD_UpdateNTView(int scanline, int drawall);
|
||||||
|
|
||||||
//the driver might should update its PPUView
|
//the driver might should update its PPUView (only used if debugging support is compiled in)
|
||||||
void FCEUD_UpdatePPUView(int scanline, int drawall);
|
void FCEUD_UpdatePPUView(int scanline, int drawall);
|
||||||
|
|
||||||
#endif /* __DRIVER_H_ */
|
#endif /* __DRIVER_H_ */
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
|
|
||||||
#include "../../types.h"
|
#include "../../types.h"
|
||||||
#include "../../fceu.h"
|
#include "../../fceu.h"
|
||||||
|
#include "../../state.h"
|
||||||
#include "ppuview.h"
|
#include "ppuview.h"
|
||||||
#include "debugger.h"
|
#include "debugger.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
@ -346,6 +347,74 @@ void _updateMemWatch() {
|
||||||
//but soon we will do more!
|
//but soon we will do more!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _USE_SHARED_MEMORY_
|
||||||
|
HANDLE mapGameMemBlock;
|
||||||
|
HANDLE mapRAM;
|
||||||
|
HANDLE mapBotInput;
|
||||||
|
uint32 *BotInput;
|
||||||
|
void win_AllocBuffers(uint8 **GameMemBlock, uint8 **RAM) {
|
||||||
|
|
||||||
|
mapGameMemBlock = CreateFileMapping((HANDLE)0xFFFFFFFF,NULL,PAGE_READWRITE, 0, 131072,"fceu.GameMemBlock");
|
||||||
|
if(mapGameMemBlock == NULL || GetLastError() == ERROR_ALREADY_EXISTS)
|
||||||
|
{
|
||||||
|
//mbg 7/38/06 - is this the proper error handling?
|
||||||
|
//do we need to indicate to user somehow that this failed in this emu instance?
|
||||||
|
CloseHandle(mapGameMemBlock);
|
||||||
|
mapGameMemBlock = NULL;
|
||||||
|
*GameMemBlock = (uint8 *) malloc(131072);
|
||||||
|
*RAM = (uint8 *) malloc(2048);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*GameMemBlock = (uint8 *)MapViewOfFile(mapGameMemBlock, FILE_MAP_WRITE, 0, 0, 0);
|
||||||
|
|
||||||
|
// set up shared memory mappings
|
||||||
|
mapRAM = CreateFileMapping((HANDLE)0xFFFFFFFF,NULL,PAGE_READWRITE, 0, 0x800,"fceu.RAM");
|
||||||
|
*RAM = (uint8 *)MapViewOfFile(mapRAM, FILE_MAP_WRITE, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Give RAM pointer to state structure
|
||||||
|
//mbg 7/28/06 - wtf?
|
||||||
|
extern SFORMAT SFCPU[];
|
||||||
|
SFCPU[6].v = *RAM;
|
||||||
|
|
||||||
|
//Bot input
|
||||||
|
mapBotInput = CreateFileMapping((HANDLE)0xFFFFFFFF,NULL,PAGE_READWRITE,0, 4096, "fceu.BotInput");
|
||||||
|
BotInput = (uint32 *) MapViewOfFile(mapBotInput, FILE_MAP_WRITE, 0, 0, 0);
|
||||||
|
BotInput[0] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void win_FreeBuffers(uint8 *GameMemBlock, uint8 *RAM) {
|
||||||
|
//clean up shared memory
|
||||||
|
if(mapRAM)
|
||||||
|
{
|
||||||
|
UnmapViewOfFile(mapRAM);
|
||||||
|
CloseHandle(mapRAM);
|
||||||
|
RAM = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
free(RAM);
|
||||||
|
RAM = NULL;
|
||||||
|
}
|
||||||
|
if(mapGameMemBlock)
|
||||||
|
{
|
||||||
|
UnmapViewOfFile(mapGameMemBlock);
|
||||||
|
CloseHandle(mapGameMemBlock);
|
||||||
|
GameMemBlock = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
free(GameMemBlock);
|
||||||
|
GameMemBlock = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
UnmapViewOfFile(mapBotInput);
|
||||||
|
CloseHandle(mapBotInput);
|
||||||
|
BotInput = NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int main(int argc,char *argv[])
|
int main(int argc,char *argv[])
|
||||||
{
|
{
|
||||||
char *t;
|
char *t;
|
||||||
|
@ -359,6 +428,7 @@ int main(int argc,char *argv[])
|
||||||
|
|
||||||
if(!FCEUI_Initialize())
|
if(!FCEUI_Initialize())
|
||||||
goto doexito;
|
goto doexito;
|
||||||
|
|
||||||
ApplyDefaultCommandMapping();
|
ApplyDefaultCommandMapping();
|
||||||
|
|
||||||
srand(GetTickCount()); // rand() is used for some GUI sillyness.
|
srand(GetTickCount()); // rand() is used for some GUI sillyness.
|
||||||
|
@ -423,6 +493,12 @@ doloopy:
|
||||||
uint8 *gfx=0;
|
uint8 *gfx=0;
|
||||||
int32 *sound=0;
|
int32 *sound=0;
|
||||||
int32 ssize=0;
|
int32 ssize=0;
|
||||||
|
|
||||||
|
#ifdef _USE_SHARED_MEMORY_
|
||||||
|
UpdateBasicBot();
|
||||||
|
#endif
|
||||||
|
FCEU_UpdateBot();
|
||||||
|
|
||||||
FCEUI_Emulate(&gfx, &sound, &ssize, 0);
|
FCEUI_Emulate(&gfx, &sound, &ssize, 0);
|
||||||
xbsave = gfx;
|
xbsave = gfx;
|
||||||
FCEUD_Update(gfx, sound, ssize);
|
FCEUD_Update(gfx, sound, ssize);
|
||||||
|
|
|
@ -37,6 +37,7 @@ DSBUFFERDESC DSBufferDesc;
|
||||||
WAVEFORMATEX wfa;
|
WAVEFORMATEX wfa;
|
||||||
WAVEFORMATEX wf;
|
WAVEFORMATEX wf;
|
||||||
|
|
||||||
|
//bittag=1 -> 8bit output
|
||||||
int bittage;
|
int bittage;
|
||||||
static int mute=0; /* TODO: add to config? add to GUI. */
|
static int mute=0; /* TODO: add to config? add to GUI. */
|
||||||
|
|
||||||
|
|
130
fceu.cpp
130
fceu.cpp
|
@ -22,11 +22,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#ifdef _USE_SHARED_MEMORY_
|
|
||||||
#include <windows.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "x6502.h"
|
#include "x6502.h"
|
||||||
#include "fceu.h"
|
#include "fceu.h"
|
||||||
|
@ -35,25 +30,23 @@
|
||||||
#include "netplay.h"
|
#include "netplay.h"
|
||||||
#include "general.h"
|
#include "general.h"
|
||||||
#include "endian.h"
|
#include "endian.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
#include "cart.h"
|
#include "cart.h"
|
||||||
#include "nsf.h"
|
#include "nsf.h"
|
||||||
#include "fds.h"
|
#include "fds.h"
|
||||||
#include "ines.h"
|
#include "ines.h"
|
||||||
#include "unif.h"
|
#include "unif.h"
|
||||||
#include "cheat.h"
|
#include "cheat.h"
|
||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
#include "state.h"
|
#include "state.h"
|
||||||
#include "movie.h"
|
#include "movie.h"
|
||||||
#include "video.h"
|
#include "video.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "crc32.h"
|
#include "crc32.h"
|
||||||
#include "vsuni.h"
|
#include "vsuni.h"
|
||||||
#ifdef _USE_SHARED_MEMORY_
|
|
||||||
#include "drivers/win/basicbot.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint64 timestampbase;
|
uint64 timestampbase;
|
||||||
|
|
||||||
|
@ -177,21 +170,35 @@ void FASTAPASS(3) SetWriteHandler(int32 start, int32 end, writefunc func)
|
||||||
BWrite[x]=func;
|
BWrite[x]=func;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _USE_SHARED_MEMORY_
|
|
||||||
HANDLE mapGameMemBlock;
|
|
||||||
uint8 *GameMemBlock;
|
uint8 *GameMemBlock;
|
||||||
HANDLE mapRAM;
|
|
||||||
uint8 *RAM;
|
uint8 *RAM;
|
||||||
HANDLE mapBotInput;
|
|
||||||
uint32 *BotInput;
|
//---------
|
||||||
#else
|
//windows might need to allocate these differently, so we have some special code
|
||||||
uint8 GameMemBlock[131072];
|
|
||||||
uint8 RAM[0x800];
|
static void AllocBuffers() {
|
||||||
#endif //_USE_SHARED_MEMORY_
|
#ifdef _USE_SHARED_MEMORY_
|
||||||
|
void win_AllocBuffers(uint8 **GameMemBlock, uint8 **RAM);
|
||||||
|
win_AllocBuffers(&GameMemBlock, &RAM);
|
||||||
|
#else
|
||||||
|
GameMemBlock = (uint8*)FCEU_gmalloc(131072);
|
||||||
|
RAM = (uint8*)FCEU_gmalloc(0x800);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static void FreeBuffers() {
|
||||||
|
#ifdef _USE_SHARED_MEMORY_
|
||||||
|
void win_FreeBuffers(uint8 *GameMemBlock, uint8 *RAM);
|
||||||
|
win_FreeBuffers(GameMemBlock, RAM);
|
||||||
|
#else
|
||||||
|
FCEU_free(GameMemBlock);
|
||||||
|
FCEU_free(RAM);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
//------
|
||||||
|
|
||||||
uint8 PAL=0;
|
uint8 PAL=0;
|
||||||
|
|
||||||
|
|
||||||
static DECLFW(BRAML)
|
static DECLFW(BRAML)
|
||||||
{
|
{
|
||||||
RAM[A]=V;
|
RAM[A]=V;
|
||||||
|
@ -342,38 +349,11 @@ FCEUGI *FCEUI_LoadGame(const char *name, int OverwriteVidMode)
|
||||||
|
|
||||||
int FCEUI_Initialize(void)
|
int FCEUI_Initialize(void)
|
||||||
{
|
{
|
||||||
#ifdef _USE_SHARED_MEMORY_
|
|
||||||
// set up shared memory mappings
|
|
||||||
mapGameMemBlock = CreateFileMapping((HANDLE)0xFFFFFFFF,NULL,PAGE_READWRITE, 0, 131072,"fceu.GameMemBlock");
|
|
||||||
if(mapGameMemBlock == NULL || GetLastError() == ERROR_ALREADY_EXISTS)
|
|
||||||
{
|
|
||||||
CloseHandle(mapGameMemBlock);
|
|
||||||
mapGameMemBlock = NULL;
|
|
||||||
GameMemBlock = (uint8 *) malloc(131072);
|
|
||||||
RAM = (uint8 *) malloc(2048);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GameMemBlock = (uint8 *)MapViewOfFile(mapGameMemBlock, FILE_MAP_WRITE, 0, 0, 0);
|
|
||||||
|
|
||||||
// set up shared memory mappings
|
|
||||||
mapRAM = CreateFileMapping((HANDLE)0xFFFFFFFF,NULL,PAGE_READWRITE, 0, 0x800,"fceu.RAM");
|
|
||||||
RAM = (uint8 *)MapViewOfFile(mapRAM, FILE_MAP_WRITE, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Give RAM pointer to state structure
|
|
||||||
extern SFORMAT SFCPU[];
|
|
||||||
SFCPU[6].v = RAM;
|
|
||||||
|
|
||||||
//Bot input
|
|
||||||
mapBotInput = CreateFileMapping((HANDLE)0xFFFFFFFF,NULL,PAGE_READWRITE,0, 4096, "fceu.BotInput");
|
|
||||||
BotInput = (uint32 *) MapViewOfFile(mapBotInput, FILE_MAP_WRITE, 0, 0, 0);
|
|
||||||
BotInput[0] = 0;
|
|
||||||
|
|
||||||
#endif //_USE_SHARED_MEMORY_
|
|
||||||
|
|
||||||
if(!FCEU_InitVirtualVideo())
|
if(!FCEU_InitVirtualVideo())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
AllocBuffers();
|
||||||
|
|
||||||
memset(&FSettings,0,sizeof(FSettings));
|
memset(&FSettings,0,sizeof(FSettings));
|
||||||
FSettings.UsrFirstSLine[0]=8;
|
FSettings.UsrFirstSLine[0]=8;
|
||||||
FSettings.UsrFirstSLine[1]=0;
|
FSettings.UsrFirstSLine[1]=0;
|
||||||
|
@ -389,36 +369,7 @@ void FCEUI_Kill(void)
|
||||||
{
|
{
|
||||||
FCEU_KillVirtualVideo();
|
FCEU_KillVirtualVideo();
|
||||||
FCEU_KillGenie();
|
FCEU_KillGenie();
|
||||||
|
FreeBuffers();
|
||||||
#ifdef _USE_SHARED_MEMORY_
|
|
||||||
//clean up shared memory
|
|
||||||
if(mapRAM)
|
|
||||||
{
|
|
||||||
UnmapViewOfFile(mapRAM);
|
|
||||||
CloseHandle(mapRAM);
|
|
||||||
RAM = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
free(RAM);
|
|
||||||
RAM = NULL;
|
|
||||||
}
|
|
||||||
if(mapGameMemBlock)
|
|
||||||
{
|
|
||||||
UnmapViewOfFile(mapGameMemBlock);
|
|
||||||
CloseHandle(mapGameMemBlock);
|
|
||||||
GameMemBlock = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
free(GameMemBlock);
|
|
||||||
GameMemBlock = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
UnmapViewOfFile(mapBotInput);
|
|
||||||
CloseHandle(mapBotInput);
|
|
||||||
BotInput = NULL;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int rapidAlternator = 0;
|
int rapidAlternator = 0;
|
||||||
|
@ -479,12 +430,6 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski
|
||||||
{
|
{
|
||||||
int r,ssize;
|
int r,ssize;
|
||||||
|
|
||||||
#ifdef _USE_SHARED_MEMORY_
|
|
||||||
UpdateBasicBot();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
FCEU_UpdateBot();
|
|
||||||
|
|
||||||
if(EmulationPaused&2)
|
if(EmulationPaused&2)
|
||||||
EmulationPaused &= ~1; // clear paused flag temporarily (frame advance)
|
EmulationPaused &= ~1; // clear paused flag temporarily (frame advance)
|
||||||
else if(EmulationPaused&1 || FCEU_BotMode())
|
else if(EmulationPaused&1 || FCEU_BotMode())
|
||||||
|
@ -525,11 +470,12 @@ void FCEUI_Emulate(uint8 **pXBuf, int32 **SoundBuf, int32 *SoundBufSize, int ski
|
||||||
if(EmulationPaused&2)
|
if(EmulationPaused&2)
|
||||||
{
|
{
|
||||||
EmulationPaused = 1; // restore paused flag
|
EmulationPaused = 1; // restore paused flag
|
||||||
#ifdef WIN32
|
//mbg merge 7/28/06 don't like the looks of this...
|
||||||
#define SO_MUTEFA 16
|
//#ifdef WIN32
|
||||||
extern int soundoptions;
|
// #define SO_MUTEFA 16
|
||||||
if(soundoptions&SO_MUTEFA)
|
// extern int soundoptions;
|
||||||
#endif
|
// if(soundoptions&SO_MUTEFA)
|
||||||
|
//#endif
|
||||||
*SoundBufSize=0; // keep sound muted
|
*SoundBufSize=0; // keep sound muted
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue