remove shared memory stuff

This commit is contained in:
zeromus 2011-03-18 00:59:55 +00:00
parent 0311add547
commit 873c9dd728
8 changed files with 1606 additions and 573 deletions

View File

@ -494,62 +494,6 @@ static void DriverKill(void)
ByebyeWindow();
}
#ifdef _USE_SHARED_MEMORY_
HANDLE mapGameMemBlock;
HANDLE mapRAM;
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)
*GameMemBlock = (uint8 *) malloc(131072);
else
if((*GameMemBlock = (uint8 *)MapViewOfFile(mapGameMemBlock, FILE_MAP_WRITE, 0, 0, 0)) == NULL)
{
CloseHandle(mapGameMemBlock);
mapGameMemBlock = NULL;
*GameMemBlock = (uint8 *) malloc(131072);
}
mapRAM = CreateFileMapping((HANDLE)0xFFFFFFFF,NULL,PAGE_READWRITE, 0, 0x800,"fceu.RAM");
if(mapRAM == NULL || GetLastError() == ERROR_ALREADY_EXISTS)
*RAM = (uint8 *) malloc(2048);
else
{
if((*RAM = (uint8 *)MapViewOfFile(mapRAM, FILE_MAP_WRITE, 0, 0, 0)) == NULL)
{
CloseHandle(mapRAM);
mapRAM = NULL;
*RAM = (uint8 *) malloc(2048);
}
}
}
void win_FreeBuffers(uint8 *GameMemBlock, uint8 *RAM)
{
//clean up shared memory
if(mapRAM)
{
CloseHandle(mapRAM);
mapRAM = NULL;
UnmapViewOfFile(RAM);
}
else
free(RAM);
RAM = NULL;
if(mapGameMemBlock)
{
CloseHandle(mapGameMemBlock);
mapGameMemBlock = NULL;
UnmapViewOfFile(GameMemBlock);
}
else
free(GameMemBlock);
GameMemBlock = NULL;
}
#endif
void do_exit()
{
DriverKill();

View File

@ -61,10 +61,6 @@ vmdef vmodes[11]={
PALETTEENTRY *color_palette;
#ifdef _USE_SHARED_MEMORY_
HANDLE mapColorPalette;
#endif //_USE_SHARED_MEMORY_
static int PaletteChanged=0;
LPDIRECTDRAWCLIPPER lpClipper=0;
@ -123,17 +119,7 @@ static int InitializeDDraw(int fs)
//only init the palette the first time through
if(firstInitialize) {
firstInitialize = false;
#ifdef _USE_SHARED_MEMORY_
mapColorPalette = CreateFileMapping(INVALID_HANDLE_VALUE,NULL,PAGE_READWRITE, 0, 256 * sizeof(PALETTEENTRY),"fceu.ColorPalette");
if(mapColorPalette == NULL || GetLastError() == ERROR_ALREADY_EXISTS)
{
CloseHandle(mapColorPalette);
mapColorPalette = NULL;
color_palette = (PALETTEENTRY*)malloc(256 * sizeof(PALETTEENTRY)); //mbg merge 7/18/06 added cast
}
else
color_palette = (PALETTEENTRY *)MapViewOfFile(mapColorPalette, FILE_MAP_WRITE, 0, 0, 0);
#endif
color_palette = (PALETTEENTRY*)malloc(256 * sizeof(PALETTEENTRY));
}
//(disvaccel&(1<<(fs?1:0)))?(GUID FAR *)DDCREATE_EMULATIONONLY:

View File

@ -375,14 +375,6 @@ void updateGameDependentMenus(unsigned int enable)
for (unsigned int i = 0; i < sizeof(menu_ids) / sizeof(*menu_ids); i++)
{
/*
adelikat: basicbot is gone
#ifndef _USE_SHARED_MEMORY_
if(simpled[x] == MENU_BASIC_BOT)
EnableMenuItem(fceumenu,menu_ids[i],MF_BYCOMMAND| MF_GRAYED);
else
#endif
*/
EnableMenuItem(fceumenu, menu_ids[i], MF_BYCOMMAND | (enable ? MF_ENABLED : MF_GRAYED));
}
}

View File

@ -328,29 +328,14 @@ uint8 *RAM;
static void AllocBuffers()
{
#ifdef _USE_SHARED_MEMORY_
void win_AllocBuffers(uint8 **GameMemBlock, uint8 **RAM);
win_AllocBuffers(&GameMemBlock, &RAM);
#else
GameMemBlock = (uint8*)FCEU_gmalloc(GAME_MEM_BLOCK_SIZE);
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
}
//------

View File

@ -23,10 +23,6 @@
#include <stdlib.h>
#include <string.h>
#ifdef _USE_SHARED_MEMORY_
#include <windows.h>
#endif
#include "types.h"
#include "x6502.h"
#include "fceu.h"
@ -55,9 +51,6 @@ uint8 *VROM = NULL;
iNES_HEADER head ;
#ifdef _USE_SHARED_MEMORY_
HANDLE mapROM = NULL, mapVROM = NULL;
#endif
static CartInfo iNESCart;
@ -125,35 +118,8 @@ void iNESGI(GI h) //bbit edited: removed static keyword
FCEU_SaveGameSave(&iNESCart);
if(iNESCart.Close) iNESCart.Close();
#ifdef _USE_SHARED_MEMORY_
if(ROM)
{
if(mapROM)
{
CloseHandle(mapROM);
mapROM = NULL;
UnmapViewOfFile(ROM);
}
else
free(ROM);
ROM = NULL;
}
if(VROM)
{
if(mapVROM)
{
CloseHandle(mapVROM);
mapVROM = NULL;
UnmapViewOfFile(VROM);
}
else
free(VROM);
VROM = NULL;
}
#else
if(ROM) {free(ROM); ROM = NULL;}
if(VROM) {free(VROM); VROM = NULL;}
#endif
if(MapClose) MapClose();
if(trainerpoo) {FCEU_gfree(trainerpoo);trainerpoo=0;}
}
@ -417,20 +383,7 @@ static void CheckHInfo(void)
if(moo[x].mapper&0x800 && VROM_size)
{
VROM_size=0;
#ifdef _USE_SHARED_MEMORY_
if(mapVROM)
{
CloseHandle(mapVROM);
UnmapViewOfFile(VROM);
mapVROM = NULL;
}
else
{
free(VROM);
}
#else
free(VROM);
#endif
VROM = NULL;
tofix|=8;
}
@ -734,63 +687,6 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode)
if(head.ROM_type&8) Mirroring=2;
#ifdef _USE_SHARED_MEMORY_
mapROM = CreateFileMapping((HANDLE)0xFFFFFFFF,NULL,PAGE_READWRITE, 0, ROM_size<<14,"fceu.ROM");
if(mapROM == NULL || GetLastError() == ERROR_ALREADY_EXISTS)
{
if((ROM = (uint8 *)FCEU_malloc(ROM_size<<14)) == NULL) return 0;
}
else
{
if((ROM = (uint8 *)MapViewOfFile(mapROM, FILE_MAP_WRITE, 0, 0, 0)) == NULL)
{
CloseHandle(mapROM);
mapROM = NULL;
if((ROM = (uint8 *)FCEU_malloc(ROM_size<<14)) == NULL) return 0;
}
}
if(VROM_size)
{
mapVROM = CreateFileMapping((HANDLE)0xFFFFFFFF,NULL,PAGE_READWRITE, 0, VROM_size<<13,"fceu.VROM");
if(mapVROM == NULL || GetLastError() == ERROR_ALREADY_EXISTS)
{
if((VROM=(uint8 *)FCEU_malloc(VROM_size<<13)) == NULL)
{
if(mapROM)
{
UnmapViewOfFile(mapROM);
mapROM = NULL;
CloseHandle(ROM);
}
else
free(ROM);
ROM = NULL;
return 0;
}
}
else
{
if((VROM = (uint8 *)MapViewOfFile(mapVROM, FILE_MAP_WRITE, 0, 0, 0)) == NULL)
{
CloseHandle(mapVROM);
mapVROM = NULL;
if((VROM=(uint8 *)FCEU_malloc(VROM_size<<13)) == NULL)
{
if(mapROM)
{
UnmapViewOfFile(mapROM);
mapROM = NULL;
CloseHandle(ROM);
}
else
free(ROM);
ROM = NULL;
return 0;
}
}
}
}
#else
if((ROM = (uint8 *)FCEU_malloc(ROM_size<<14)) == NULL) return 0;
if(VROM_size)
@ -802,7 +698,6 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode)
return 0;
}
}
#endif
memset(ROM,0xFF,ROM_size<<14);
if(VROM_size) memset(VROM,0xFF,VROM_size<<13);
if(head.ROM_type&4) /* Trainer */
@ -1499,26 +1394,7 @@ static int NewiNES_Init(int num)
{
CHRRAMSize=8192;
}
#ifdef _USE_SHARED_MEMORY_
mapVROM = CreateFileMapping((HANDLE)0xFFFFFFFF,NULL,PAGE_READWRITE, 0, CHRRAMSize,"fceu.VROM");
if(mapVROM == NULL || GetLastError() == ERROR_ALREADY_EXISTS)
{
CloseHandle(mapVROM);
mapVROM = NULL;
if((VROM = (uint8 *)FCEU_dmalloc(CHRRAMSize)) == NULL) return 0;
}
else
{
if((VROM = (uint8 *)MapViewOfFile(mapVROM, FILE_MAP_WRITE, 0, 0, 0)) == NULL)
{
CloseHandle(mapVROM);
mapVROM = NULL;
if((VROM = (uint8 *)FCEU_dmalloc(CHRRAMSize)) == NULL) return 0;
}
}
#else
if((VROM = (uint8 *)FCEU_dmalloc(CHRRAMSize)) == NULL) return 0;
#endif
UNIFchrrama=VROM;
SetupCartCHRMapping(0,VROM,CHRRAMSize,1);
AddExState(VROM,CHRRAMSize, 0, "CHRR");

View File

@ -87,10 +87,6 @@ static uint8 LastStrobe;
bool replaceP2StartWithMicrophone = false;
#ifdef _USE_SHARED_MEMORY_
static uint32 BotPointer = 0; //mbg merge 7/18/06 changed to uint32
#endif
//This function is a quick hack to get the NSF player to use emulated gamepad input.
uint8 FCEU_GetJoyJoy(void)
{

View File

@ -28,10 +28,6 @@
#include <stdarg.h>
#include <zlib.h>
#ifdef _USE_SHARED_MEMORY_
#include <windows.h>
#endif
#include "types.h"
#include "video.h"
#include "fceu.h"
@ -73,10 +69,6 @@ extern uint32 cur_input_display;
bool oldInputDisplay = false;
#ifdef _USE_SHARED_MEMORY_
HANDLE mapXBuf;
#endif
std::string AsSnapshotName =""; //adelikat:this will set the snapshot name when for s savesnapshot as function
void FCEUI_SetSnapshotAsName(std::string name) { AsSnapshotName = name; }
@ -114,38 +106,12 @@ int FCEU_InitVirtualVideo(void)
/* 256 bytes per scanline, * 240 scanline maximum, +16 for alignment,
*/
#ifdef _USE_SHARED_MEMORY_
mapXBuf = CreateFileMapping((HANDLE)0xFFFFFFFF,NULL,PAGE_READWRITE, 0, 256 * 256 + 16, "fceu.XBuf");
if(mapXBuf == NULL || GetLastError() == ERROR_ALREADY_EXISTS)
{
CloseHandle(mapXBuf);
mapXBuf = NULL;
XBuf = (uint8*) (FCEU_malloc(256 * 256 + 16));
XBackBuf = (uint8*) (FCEU_malloc(256 * 256 + 16));
}
else
{
XBuf = (uint8 *)MapViewOfFile(mapXBuf, FILE_MAP_WRITE, 0, 0, 0);
XBackBuf = (uint8*) (FCEU_malloc(256 * 256 + 16));
}
if (!XBuf || !XBackBuf)
{
return 0;
}
#else
if(!(XBuf= (uint8*) (FCEU_malloc(256 * 256 + 16))) ||
!(XBackBuf= (uint8*) (FCEU_malloc(256 * 256 + 16))))
{
return 0;
}
#endif //_USE_SHARED_MEMORY_
xbsave = XBuf;
if( sizeof(uint8*) == 4 )

File diff suppressed because it is too large Load Diff