Clang buildfixes - step 1

This commit is contained in:
libretroadmin 2023-11-01 16:17:22 +01:00
parent e21bf74bdd
commit 9455d40922
22 changed files with 369 additions and 688 deletions

View File

@ -49,10 +49,9 @@ typedef enum {
EMU_LANG_UNKNOWN = -1
} EmuLanguageType;
void langInit();
void langInit(void);
int langSetLanguage(EmuLanguageType languageType);
EmuLanguageType langGetLanguage();
EmuLanguageType langGetLanguage(void);
EmuLanguageType langFromName(char* name, int translate);
const char* langToName(EmuLanguageType languageType, int translate);
EmuLanguageType langGetType(int i);

View File

@ -44,14 +44,7 @@ EmuLanguageType langGetType(int i)
return i == 0 ? EMU_LANG_ENGLISH : EMU_LANG_UNKNOWN;
}
void langInit() {
}
int langSetLanguage(EmuLanguageType languageType)
{
return languageType == EMU_LANG_ENGLISH ? 1 : 0;
}
void langInit(void) { }
//----------------------
// Generic lines

View File

@ -164,7 +164,7 @@ static void setDeviceInfo(BoardDeviceInfo* deviceInfo)
strcpy(deviceInfo->tapes[i].inZipName, properties->media.tapes[i].fileNameInZip);
}
deviceInfo->video.vdpSyncMode = properties->emulation.vdpSyncMode;
deviceInfo->video.vdpSyncMode = (VdpSyncMode)properties->emulation.vdpSyncMode;
}

View File

@ -79,7 +79,7 @@ ArchGlob* archGlob(const char* pattern, int flags)
strcat(path, wfd.cFileName);
glob->count++;
glob->pathVector = realloc(glob->pathVector, sizeof(char*) * glob->count);
glob->pathVector = (char**)realloc(glob->pathVector, sizeof(char*) * glob->count);
glob->pathVector[glob->count - 1] = path;
}
} while (FindNextFile(handle, &wfd));
@ -124,13 +124,10 @@ ArchGlob* archGlob(const char* pattern, int flags)
{
glob_t g;
ArchGlob* globHandle = NULL;
int rv;
int i;
rv = glob(pattern, GLOB_MARK, NULL, &g);
if (rv != 0) {
int rv = glob(pattern, GLOB_MARK, NULL, &g);
if (rv != 0)
return NULL;
}
globHandle = (ArchGlob*)calloc(1, sizeof(ArchGlob));
@ -139,18 +136,18 @@ ArchGlob* archGlob(const char* pattern, int flags)
int len = strlen(path);
if ((flags & ARCH_GLOB_DIRS) && path[len - 1] == '/') {
char* storePath = calloc(1, len);
char* storePath = (char*)calloc(1, len);
memcpy(storePath, path, len - 1);
globHandle->count++;
globHandle->pathVector = realloc(globHandle->pathVector, sizeof(char*) * globHandle->count);
globHandle->pathVector = (char**)realloc(globHandle->pathVector, sizeof(char*) * globHandle->count);
globHandle->pathVector[globHandle->count - 1] = storePath;
}
if ((flags & ARCH_GLOB_FILES) && path[len - 1] != '/') {
char* storePath = calloc(1, len + 1);
char* storePath = (char*)calloc(1, len + 1);
memcpy(storePath, path, len);
globHandle->count++;
globHandle->pathVector = realloc(globHandle->pathVector, sizeof(char*) * globHandle->count);
globHandle->pathVector = (char**)realloc(globHandle->pathVector, sizeof(char*) * globHandle->count);
globHandle->pathVector[globHandle->count - 1] = storePath;
}
}

View File

@ -97,9 +97,8 @@ static int checkCommandProgram(AmdFlash* rm)
if (rm->cmdIdx < 4) return 1;
if (((rm->writeProtectMask >> (rm->cmd[3].address / rm->sectorSize)) & 1) == 0) {
if (((rm->writeProtectMask >> (rm->cmd[3].address / rm->sectorSize)) & 1) == 0)
rm->romData[rm->cmd[3].address & (rm->flashSize - 1)] &= rm->cmd[3].value;
}
return 0;
}
@ -109,9 +108,8 @@ static int checkCommandManifacturer(AmdFlash* rm)
if (rm->cmdIdx > 1 && ((rm->cmd[1].address & 0x7ff) != rm->cmdAddr2 || rm->cmd[1].value != 0x55)) return 0;
if (rm->cmdIdx > 2 && ((rm->cmd[2].address & 0x7ff) != rm->cmdAddr1 || rm->cmd[2].value != 0x90)) return 0;
if (rm->cmdIdx == 3) {
if (rm->cmdIdx == 3)
rm->state = ST_IDENT;
}
if (rm->cmdIdx < 4) return 1;
return 0;
@ -121,7 +119,6 @@ UInt8 amdFlashRead(AmdFlash* rm, UInt32 address)
{
if (rm->state == ST_IDENT) {
rm->cmdIdx = 0;
// printf("R %.4x: XX\n", address);
switch (address & 0x03) {
case 0:
return 0x01;
@ -134,7 +131,6 @@ UInt8 amdFlashRead(AmdFlash* rm, UInt32 address)
}
return 0xff;
}
// printf("R %.4x: %.2x\n", address, rm->romData[address & (rm->flashSize - 1)]);
address &= rm->flashSize - 1;
@ -146,8 +142,6 @@ void amdFlashWrite(AmdFlash* rm, UInt32 address, UInt8 value)
if (rm->cmdIdx < sizeof(rm->cmd) / sizeof(rm->cmd[0])) {
int stateValid = 0;
// { static int x = 0; if (++x < 220) printf("W %.4x: %.2x %d\n", address, value, rm->cmdIdx);}
rm->cmd[rm->cmdIdx].address = address;
rm->cmd[rm->cmdIdx].value = value;
rm->cmdIdx++;
@ -244,19 +238,17 @@ AmdFlash* amdFlashCreate(AmdType type, int flashSize, int sectorSize, UInt32 wri
rm->flashSize = flashSize;
rm->sectorSize = sectorSize;
rm->romData = malloc(flashSize);
if (size >= flashSize) {
rm->romData = (UInt8*)malloc(flashSize);
if (size >= flashSize)
size = flashSize;
}
if (rm->sramFilename[0]) {
memset(rm->romData + size, 0xff, flashSize - size);
sramLoad(rm->sramFilename, rm->romData, rm->flashSize, NULL, 0);
}
if (size > 0) {
if (size > 0)
memcpy(rm->romData, romData, size);
}
#if 0
if (rm->sramFilename[0] && loadSram) {
sramLoad(rm->sramFilename, rm->romData, rm->flashSize, NULL, 0);
@ -268,8 +260,7 @@ AmdFlash* amdFlashCreate(AmdType type, int flashSize, int sectorSize, UInt32 wri
void amdFlashDestroy(AmdFlash* rm)
{
if (rm->sramFilename[0]) {
if (rm->sramFilename[0])
sramSave(rm->sramFilename, rm->romData, rm->flashSize, NULL, 0);
}
free(rm);
}

View File

@ -244,23 +244,20 @@ AtmelPerom* atmelPeromCreate(AmdType type, int flashSize, int sectorSize, UInt32
rm->flashSize = flashSize;
rm->sectorSize = sectorSize;
rm->romData = malloc(flashSize);
if (size >= flashSize) {
rm->romData = (UInt8*)malloc(flashSize);
if (size >= flashSize)
size = flashSize;
}
if (rm->sramFilename[0]) {
memset(rm->romData + size, 0xff, flashSize - size);
sramLoad(rm->sramFilename, rm->romData, rm->flashSize, NULL, 0);
}
if (size > 0) {
if (size > 0)
memcpy(rm->romData, romData, size);
}
#if 0
if (rm->sramFilename[0] && loadSram) {
if (rm->sramFilename[0] && loadSram)
sramLoad(rm->sramFilename, rm->romData, rm->flashSize, NULL, 0);
}
#endif
return rm;
@ -268,8 +265,7 @@ AtmelPerom* atmelPeromCreate(AmdType type, int flashSize, int sectorSize, UInt32
void atmelPeromDestroy(AtmelPerom* rm)
{
if (rm->sramFilename[0]) {
if (rm->sramFilename[0])
sramSave(rm->sramFilename, rm->romData, rm->flashSize, NULL, 0);
}
free(rm);
}

View File

@ -39,36 +39,34 @@ UInt8* romLoad(const char *fileName, const char *fileInZipFile, int* size)
UInt8* buf = NULL;
FILE *file;
if (fileName == NULL || strlen(fileName) == 0) {
if (!fileName || strlen(fileName) == 0)
goto error;
}
if (fileInZipFile != NULL && strlen(fileInZipFile) == 0) {
if (fileInZipFile && strlen(fileInZipFile) == 0)
fileInZipFile = NULL;
}
if (fileInZipFile != NULL) {
buf = zipLoadFile(fileName, fileInZipFile, size);
if (buf == NULL)
if (fileInZipFile)
{
buf = (UInt8*)zipLoadFile(fileName, fileInZipFile, size);
if (!buf)
goto error;
return buf;
}
file = fopen(fileName, "rb");
if (file == NULL) {
if (!file)
goto error;
}
fseek(file, 0, SEEK_END);
*size = ftell(file);
if (*size == 0) {
fclose(file);
return malloc(1);
return (UInt8*)malloc(1);
}
fseek(file, 0, SEEK_SET);
buf = malloc(*size);
buf = (UInt8*)malloc(*size);
*size = fread(buf, 1, *size, file);
fclose(file);
@ -80,4 +78,3 @@ error:
fflush(stdout);
return NULL;
}

View File

@ -48,8 +48,9 @@ typedef struct {
UInt8 ramData[0x2000];
} Ram1kBMirrored;
static void saveState(Ram1kBMirrored* rm)
static void ram1kb_saveState(void *data)
{
Ram1kBMirrored *rm = (Ram1kBMirrored*)data;
SaveState* state = saveStateOpenForWrite("mapperMirroredRam");
saveStateSet(state, "mask", rm->mask);
@ -58,8 +59,9 @@ static void saveState(Ram1kBMirrored* rm)
saveStateClose(state);
}
static void loadState(Ram1kBMirrored* rm)
static void ram1kb_loadState(void *data)
{
Ram1kBMirrored *rm = (Ram1kBMirrored*)data;
SaveState* state = saveStateOpenForRead("mapperMirroredRam");
rm->mask = saveStateGet(state, "mask", 0x400);
@ -68,8 +70,9 @@ static void loadState(Ram1kBMirrored* rm)
saveStateClose(state);
}
static void destroy(Ram1kBMirrored* rm)
static void ram1kb_destroy(void *data)
{
Ram1kBMirrored *rm = (Ram1kBMirrored*)data;
debugDeviceUnregister(rm->debugHandle);
slotUnregister(rm->slot, rm->sslot, 0);
@ -78,51 +81,52 @@ static void destroy(Ram1kBMirrored* rm)
free(rm);
}
static void getDebugInfo(Ram1kBMirrored* rm, DbgDevice* dbgDevice)
static void ram1kb_getDebugInfo(void *data, DbgDevice* dbgDevice)
{
Ram1kBMirrored *rm = (Ram1kBMirrored*)data;
dbgDeviceAddMemoryBlock(dbgDevice, langDbgMemRamNormal(), 0, 0, rm->mask + 1, rm->ramData);
}
static int dbgWriteMemory(Ram1kBMirrored* rm, char* name, void* data, int start, int size)
static int ram1kb_dbgWriteMemory(void *data1, char* name, void *data2, int start, int size)
{
if (strcmp(name, "Normal") || start + size >= (int)rm->mask) {
Ram1kBMirrored *rm = (Ram1kBMirrored*)data1;
if (strcmp(name, "Normal") || start + size >= (int)rm->mask)
return 0;
}
memcpy(rm->ramData + start, data, size);
memcpy(rm->ramData + start, data2, size);
return 1;
}
static UInt8 read(Ram1kBMirrored* rm, UInt16 address)
static UInt8 ram1kb_read(void *data, UInt16 address)
{
Ram1kBMirrored *rm = (Ram1kBMirrored*)data;
return rm->ramData[address & rm->mask];
}
static void write(Ram1kBMirrored* rm, UInt16 address, UInt8 value)
static void ram1kb_write(void *data, UInt16 address, UInt8 value)
{
Ram1kBMirrored *rm = (Ram1kBMirrored*)data;
rm->ramData[address & rm->mask] = value;
}
int ramMirroredCreate(int size, int slot, int sslot, int startPage,
UInt32 ramBlockSize, UInt8** ramPtr, UInt32* ramSize)
{
DeviceCallbacks callbacks = { destroy, NULL, saveState, loadState };
DebugCallbacks dbgCallbacks = { getDebugInfo, dbgWriteMemory, NULL, NULL };
DeviceCallbacks callbacks = { ram1kb_destroy, NULL, ram1kb_saveState, ram1kb_loadState };
DebugCallbacks dbgCallbacks = { ram1kb_getDebugInfo, ram1kb_dbgWriteMemory, NULL, NULL };
Ram1kBMirrored* rm;
int pages = size / 0x2000;
int i;
if (size > 0x10000 || (size & 0x1fff)) {
if (size > 0x10000 || (size & 0x1fff))
return 0;
}
// Start page must be zero (only full slot allowed)
if (startPage + pages > 8) {
if (startPage + pages > 8)
return 0;
}
rm = malloc(sizeof(Ram1kBMirrored));
rm = (Ram1kBMirrored*)malloc(sizeof(Ram1kBMirrored));
rm->mask = ramBlockSize - 1;
rm->slot = slot;
@ -134,22 +138,18 @@ int ramMirroredCreate(int size, int slot, int sslot, int startPage,
rm->debugHandle = debugDeviceRegister(DBGTYPE_RAM, langDbgDevRam(), &dbgCallbacks, rm);
for (i = 0; i < pages; i++) {
for (i = 0; i < pages; i++)
slotMapPage(slot, sslot, i + startPage, NULL, 0, 0);
}
rm->deviceHandle = deviceManagerRegister(ramBlockSize == 0x400 ? RAM_1KB_MIRRORED : RAM_2KB_MIRRORED,
&callbacks, rm);
slotRegister(slot, sslot, startPage, pages, read, read, write, destroy, rm);
slotRegister(slot, sslot, startPage, pages, ram1kb_read, ram1kb_read, ram1kb_write, ram1kb_destroy, rm);
if (ramPtr != NULL) {
if (ramPtr)
*ramPtr = rm->ramData;
}
if (ramSize != NULL) {
if (ramSize)
*ramSize = rm->pages * 0x2000;
}
return 1;
}

View File

@ -39,7 +39,6 @@
#include <string.h>
#include <stdio.h>
typedef struct {
int deviceHandle;
UInt8* ramData;
@ -54,10 +53,9 @@ typedef struct {
int size;
} RamMapper;
static void writeIo(RamMapper* rm, UInt16 page, UInt8 value);
static void saveState(RamMapper* rm)
static void rammapper_saveState(void *data)
{
RamMapper *rm = (RamMapper*)rm;
SaveState* state = saveStateOpenForWrite("mapperRam");
saveStateSet(state, "mask", rm->mask);
@ -69,39 +67,10 @@ static void saveState(RamMapper* rm)
saveStateClose(state);
}
static void loadState(RamMapper* rm)
static void rammapper_writeIo(void *data, UInt16 page, UInt8 value)
{
SaveState* state = saveStateOpenForRead("mapperRam");
int i;
rm->mask = saveStateGet(state, "mask", 0);
rm->dramMode = saveStateGet(state, "dramMode", 0);
saveStateGetBuffer(state, "port", rm->port, 4);
saveStateGetBuffer(state, "ramData", rm->ramData, 0x4000 * (rm->mask + 1));
saveStateClose(state);
#if 1
for (i = 0; i < 4; i++) {
writeIo(rm, i, rm->port[i]);
}
#else
ramMapperIoRemove(rm->handle);
rm->handle = ramMapperIoAdd(0x4000 * (rm->mask + 1), writeIo, rm);
for (i = 0; i < 4; i++) {
int value = ramMapperIoGetPortValue(i) & rm->mask;
int mapped = rm->dramMode && (rm->mask - value < 4) ? 0 : 1;
slotMapPage(rm->slot, rm->sslot, 2 * i, rm->ramData + 0x4000 * value, 1, mapped);
slotMapPage(rm->slot, rm->sslot, 2 * i + 1, rm->ramData + 0x4000 * value + 0x2000, 1, mapped);
}
#endif
}
static void writeIo(RamMapper* rm, UInt16 page, UInt8 value)
{
int baseAddr = 0x4000 * (value & rm->mask);
RamMapper *rm = (RamMapper*)rm;
int baseAddr = 0x4000 * (value & rm->mask);
rm->port[page] = value;
if (rm->dramMode && baseAddr >= (rm->size - 0x10000)) {
slotMapPage(rm->slot, rm->sslot, 2 * page, NULL, 0, 0);
@ -113,24 +82,55 @@ static void writeIo(RamMapper* rm, UInt16 page, UInt8 value)
}
}
static void setDram(RamMapper* rm, int enable)
static void rammapper_loadState(void *data)
{
int i;
RamMapper *rm = (RamMapper*)data;
SaveState* state = saveStateOpenForRead("mapperRam");
rm->mask = saveStateGet(state, "mask", 0);
rm->dramMode = saveStateGet(state, "dramMode", 0);
saveStateGetBuffer(state, "port", rm->port, 4);
saveStateGetBuffer(state, "ramData", rm->ramData, 0x4000 * (rm->mask + 1));
saveStateClose(state);
#if 1
for (i = 0; i < 4; i++)
rammapper_writeIo(rm, i, rm->port[i]);
#else
ramMapperIoRemove(rm->handle);
rm->handle = ramMapperIoAdd(0x4000 * (rm->mask + 1), rammapper_writeIo, rm);
for (i = 0; i < 4; i++) {
int value = ramMapperIoGetPortValue(i) & rm->mask;
int mapped = rm->dramMode && (rm->mask - value < 4) ? 0 : 1;
slotMapPage(rm->slot, rm->sslot, 2 * i, rm->ramData + 0x4000 * value, 1, mapped);
slotMapPage(rm->slot, rm->sslot, 2 * i + 1, rm->ramData + 0x4000 * value + 0x2000, 1, mapped);
}
#endif
}
static void rammapper_setDram(void *data, int enable)
{
int i;
RamMapper *rm = (RamMapper*)data;
rm->dramMode = enable;
for (i = 0; i < 4; i++) {
writeIo(rm, i, ramMapperIoGetPortValue(i));
}
for (i = 0; i < 4; i++)
rammapper_writeIo(rm, i, ramMapperIoGetPortValue(i));
}
static void reset(RamMapper* rm)
static void rammapper_reset(RamMapper* rm)
{
setDram(rm, 0);
rammapper_setDram(rm, 0);
}
static void destroy(RamMapper* rm)
static void rammapper_destroy(void *data)
{
RamMapper *rm = (RamMapper*)data;
debugDeviceUnregister(rm->debugHandle);
ramMapperIoRemove(rm->handle);
slotUnregister(rm->slot, rm->sslot, 0);
@ -141,26 +141,27 @@ static void destroy(RamMapper* rm)
free(rm);
}
static void getDebugInfo(RamMapper* rm, DbgDevice* dbgDevice)
static void rammapper_getDebugInfo(void *data, DbgDevice* dbgDevice)
{
RamMapper *rm = (RamMapper*)data;
dbgDeviceAddMemoryBlock(dbgDevice, langDbgMemRamMapped(), 0, 0, rm->size, rm->ramData);
}
static int dbgWriteMemory(RamMapper* rm, char* name, void* data, int start, int size)
static int rammapper_dbgWriteMemory(void *data1, char* name, void *data2, int start, int size)
{
if (strcmp(name, "Mapped") || start + size > rm->size) {
RamMapper *rm = (RamMapper*)data1;
if (strcmp(name, "Mapped") || start + size > rm->size)
return 0;
}
memcpy(rm->ramData + start, data, size);
memcpy(rm->ramData + start, data2, size);
return 1;
}
int ramMapperCreate(int size, int slot, int sslot, int startPage, UInt8** ramPtr, UInt32* ramSize)
{
DeviceCallbacks callbacks = { destroy, NULL, saveState, loadState };
DebugCallbacks dbgCallbacks = { getDebugInfo, dbgWriteMemory, NULL, NULL };
DeviceCallbacks callbacks = { rammapper_destroy, NULL, rammapper_saveState, rammapper_loadState };
DebugCallbacks dbgCallbacks = { rammapper_getDebugInfo, rammapper_dbgWriteMemory, NULL, NULL };
RamMapper* rm;
int pages = size / 0x4000;
int i;
@ -168,20 +169,18 @@ int ramMapperCreate(int size, int slot, int sslot, int startPage, UInt8** ramPtr
// Check that memory is a power of 2 and at least 64kB
for (i = 4; i < pages; i <<= 1);
if (i != pages) {
if (i != pages)
return 0;
}
size = pages * 0x4000;
// Start page must be zero (only full slot allowed)
if (startPage != 0) {
if (startPage != 0)
return 0;
}
rm = malloc(sizeof(RamMapper));
rm = (RamMapper*)malloc(sizeof(RamMapper));
rm->ramData = malloc(size);
rm->ramData = (UInt8*)malloc(size);
rm->size = size;
rm->slot = slot;
rm->sslot = sslot;
@ -190,23 +189,22 @@ int ramMapperCreate(int size, int slot, int sslot, int startPage, UInt8** ramPtr
memset(rm->ramData, 0xff, size);
rm->handle = ramMapperIoAdd(pages * 0x4000, writeIo, rm);
rm->handle = ramMapperIoAdd(pages * 0x4000, rammapper_writeIo, rm);
rm->debugHandle = debugDeviceRegister(DBGTYPE_RAM, langDbgDevRam(), &dbgCallbacks, rm);
rm->deviceHandle = deviceManagerRegister(RAM_MAPPER, &callbacks, rm);
slotRegister(slot, sslot, 0, 8, NULL, NULL, NULL, destroy, rm);
slotRegister(slot, sslot, 0, 8, NULL, NULL, NULL, rammapper_destroy, rm);
reset(rm);
rammapper_reset(rm);
if (ramPtr != NULL) {
// Main RAM
rm->dramHandle = panasonicDramRegister(setDram, rm);
rm->dramHandle = panasonicDramRegister(rammapper_setDram, rm);
*ramPtr = rm->ramData;
}
if (ramSize != NULL) {
if (ramSize != NULL)
*ramSize = size;
}
return 1;
}

View File

@ -63,16 +63,16 @@ static int ramMapperIoGetMask(RamMapperIo* rm)
int i;
for (i = 0; i < rm->count; i++) {
while (size < rm->mapperCb[i].size) {
while (size < rm->mapperCb[i].size)
size <<= 1;
}
}
return (size / 0x4000) - 1;
}
static void saveState(RamMapperIo* rm)
static void rammapperio_saveState(void *data)
{
RamMapperIo *rm = (RamMapperIo*)data;
SaveState* state = saveStateOpenForWrite("mapperRamIo");
saveStateSet(state, "port0", rm->port[0]);
saveStateSet(state, "port1", rm->port[1]);
@ -82,8 +82,9 @@ static void saveState(RamMapperIo* rm)
saveStateClose(state);
}
static void loadState(RamMapperIo* rm)
static void rammapperio_loadState(void *data)
{
RamMapperIo *rm = (RamMapperIo*)data;
SaveState* state = saveStateOpenForRead("mapperRamIo");
rm->port[0] = saveStateGet(state, "port0", 3);
rm->port[1] = saveStateGet(state, "port1", 2);
@ -95,8 +96,9 @@ static void loadState(RamMapperIo* rm)
saveStateClose(state);
}
static void destroy(RamMapperIo* rm)
static void rammapperio_destroy(void *data)
{
RamMapperIo *rm = (RamMapperIo*)data;
ioPortUnregister(0xfc);
ioPortUnregister(0xfd);
ioPortUnregister(0xfe);
@ -109,13 +111,15 @@ static void destroy(RamMapperIo* rm)
mapperIo = NULL;
}
static UInt8 read(RamMapperIo* rm, UInt16 ioPort)
static UInt8 rammapperio_read(void *data, UInt16 ioPort)
{
RamMapperIo *rm = (RamMapperIo*)data;
return rm->port[ioPort & 3] | ~rm->mask;
}
static void write(RamMapperIo* rm, UInt16 ioPort, UInt8 value)
static void rammapperio_write(void *data, UInt16 ioPort, UInt8 value)
{
RamMapperIo *rm = (RamMapperIo*)data;
ioPort &= 3;
if (rm->port[ioPort] != value) {
@ -124,31 +128,28 @@ static void write(RamMapperIo* rm, UInt16 ioPort, UInt8 value)
rm->port[ioPort] = value;
for (i = 0; i < rm->count; i++) {
if (rm->mapperCb[i].write != NULL) {
if (rm->mapperCb[i].write != NULL)
rm->mapperCb[i].write(rm->mapperCb[i].ref, ioPort, value);
}
}
}
}
static void getDebugInfo(RamMapperIo* rm, DbgDevice* dbgDevice)
static void rammapperio_getDebugInfo(void *data, DbgDevice* dbgDevice)
{
DbgIoPorts* ioPorts;
int i;
ioPorts = dbgDeviceAddIoPorts(dbgDevice, langDbgDevRamMapper(), 4);
for (i = 0; i < 4; i++) {
dbgIoPortsAddPort(ioPorts, i, 0xfc + i, DBG_IO_READWRITE, read(rm, 0xfc + i));
}
RamMapperIo *rm = (RamMapperIo*)data;
DbgIoPorts *ioPorts = dbgDeviceAddIoPorts(dbgDevice, langDbgDevRamMapper(), 4);
for (i = 0; i < 4; i++)
dbgIoPortsAddPort(ioPorts, i, 0xfc + i, DBG_IO_READWRITE, rammapperio_read(rm, 0xfc + i));
}
int ramMapperIoCreate()
{
RamMapperIo* rm;
DeviceCallbacks callbacks = { destroy, NULL, saveState, loadState };
DebugCallbacks dbgCallbacks = { getDebugInfo, NULL, NULL, NULL };
DeviceCallbacks callbacks = { rammapperio_destroy, NULL, rammapperio_saveState, rammapperio_loadState };
DebugCallbacks dbgCallbacks = { rammapperio_getDebugInfo, NULL, NULL, NULL };
rm = malloc(sizeof(RamMapperIo));
rm = (RamMapperIo*)malloc(sizeof(RamMapperIo));
rm->count = 0;
rm->mask = 0;
rm->handleCount = 0;
@ -161,10 +162,10 @@ int ramMapperIoCreate()
rm->deviceHandle = deviceManagerRegister(RAM_MAPPER, &callbacks, rm);
rm->debugHandle = debugDeviceRegister(DBGTYPE_BIOS, langDbgDevRamMapper(), &dbgCallbacks, rm);
ioPortRegister(0xfc, read, write, rm);
ioPortRegister(0xfd, read, write, rm);
ioPortRegister(0xfe, read, write, rm);
ioPortRegister(0xff, read, write, rm);
ioPortRegister(0xfc, rammapperio_read, rammapperio_write, rm);
ioPortRegister(0xfd, rammapperio_read, rammapperio_write, rm);
ioPortRegister(0xfe, rammapperio_read, rammapperio_write, rm);
ioPortRegister(0xff, rammapperio_read, rammapperio_write, rm);
mapperIo = rm;
@ -174,10 +175,8 @@ int ramMapperIoCreate()
int ramMapperIoGetPortValue(int ioPort)
{
RamMapperIo* rm = mapperIo;
if (rm == NULL) {
if (rm == NULL)
return 0xff;
}
return rm->port[ioPort & 3];
}

View File

@ -47,8 +47,9 @@ typedef struct {
UInt8 ramData[0x10000];
} RamNormal;
static void saveState(RamNormal* rm)
static void ramnormal_saveState(void *data)
{
RamNormal *rm = (RamNormal*)data;
SaveState* state = saveStateOpenForWrite("mapperNormalRam");
saveStateSet(state, "pages", rm->pages);
@ -57,10 +58,11 @@ static void saveState(RamNormal* rm)
saveStateClose(state);
}
static void loadState(RamNormal* rm)
static void ramnormal_loadState(void *data)
{
SaveState* state = saveStateOpenForRead("mapperNormalRam");
int i;
RamNormal *rm = (RamNormal*)data;
SaveState* state = saveStateOpenForRead("mapperNormalRam");
rm->pages = saveStateGet(state, "pages", 0);
@ -68,13 +70,16 @@ static void loadState(RamNormal* rm)
saveStateClose(state);
#if 0
for (i = 0; i < rm->pages; i++) {
// slotMapPage(rm->slot, rm->sslot, i + rm->startPage, rm->ramData + 0x2000 * i, 1, 1);
}
#endif
}
static void destroy(RamNormal* rm)
static void ramnormal_destroy(void *data)
{
RamNormal *rm = (RamNormal*)data;
debugDeviceUnregister(rm->debugHandle);
slotUnregister(rm->slot, rm->sslot, 0);
@ -83,40 +88,39 @@ static void destroy(RamNormal* rm)
free(rm);
}
static void getDebugInfo(RamNormal* rm, DbgDevice* dbgDevice)
static void ramnormal_getDebugInfo(void *data, DbgDevice* dbgDevice)
{
RamNormal *rm = (RamNormal*)data;
dbgDeviceAddMemoryBlock(dbgDevice, langDbgMemRamNormal(), 0, 0, rm->pages * 0x2000, rm->ramData);
}
static int dbgWriteMemory(RamNormal* rm, char* name, void* data, int start, int size)
static int ramnormal_dbgWriteMemory(void *data1, char* name, void* data2, int start, int size)
{
if (strcmp(name, "Normal") || start + size > rm->pages * 0x2000) {
RamNormal *rm = (RamNormal*)data1;
if (strcmp(name, "Normal") || start + size > rm->pages * 0x2000)
return 0;
}
memcpy(rm->ramData + start, data, size);
memcpy(rm->ramData + start, data2, size);
return 1;
}
int ramNormalCreate(int size, int slot, int sslot, int startPage, UInt8** ramPtr, UInt32* ramSize)
{
DeviceCallbacks callbacks = { destroy, NULL, saveState, loadState };
DebugCallbacks dbgCallbacks = { getDebugInfo, dbgWriteMemory, NULL, NULL };
DeviceCallbacks callbacks = { ramnormal_destroy, NULL, ramnormal_saveState, ramnormal_loadState };
DebugCallbacks dbgCallbacks = { ramnormal_getDebugInfo, ramnormal_dbgWriteMemory, NULL, NULL };
RamNormal* rm;
int pages = size / 0x2000;
int i;
if (size > 0x10000 || (size & 0x1fff)) {
if (size > 0x10000 || (size & 0x1fff))
return 0;
}
// Start page must be zero (only full slot allowed)
if (startPage + pages > 8) {
if (startPage + pages > 8)
return 0;
}
rm = malloc(sizeof(RamNormal));
rm = (RamNormal*)malloc(sizeof(RamNormal));
rm->slot = slot;
rm->sslot = sslot;
@ -127,20 +131,17 @@ int ramNormalCreate(int size, int slot, int sslot, int startPage, UInt8** ramPtr
rm->debugHandle = debugDeviceRegister(DBGTYPE_RAM, langDbgDevRam(), &dbgCallbacks, rm);
for (i = 0; i < pages; i++) {
for (i = 0; i < pages; i++)
slotMapPage(slot, sslot, i + startPage, rm->ramData + 0x2000 * i, 1, 1);
}
rm->deviceHandle = deviceManagerRegister(RAM_NORMAL, &callbacks, rm);
slotRegister(slot, sslot, startPage, pages, NULL, NULL, NULL, destroy, rm);
slotRegister(slot, sslot, startPage, pages, NULL, NULL, NULL, ramnormal_destroy, rm);
if (ramPtr != NULL) {
if (ramPtr)
*ramPtr = rm->ramData;
}
if (ramSize != NULL) {
if (ramSize)
*ramSize = pages * 0x2000;
}
return 1;
}

View File

@ -37,7 +37,7 @@
#include <stdio.h>
enum {
READ_SRAM,
READ_SRAM = 0,
READ_EMPTY,
READ_ROM
};
@ -70,17 +70,15 @@ static UInt32 panasonicSramMask = 0;
UInt8 panasonicSramGet(UInt32 address)
{
if (panasonicSramMask == 0) {
if (panasonicSramMask == 0)
return 0xff;
}
return panasonicSramData[address & panasonicSramMask];
}
void panasonicSramSet(UInt32 address, UInt8 value)
{
if (panasonicSramMask > 0) {
if (panasonicSramMask > 0)
panasonicSramData[address & panasonicSramMask] = value;
}
}
void panasonicSramCreate(UInt8* sram, UInt32 size)
@ -89,17 +87,17 @@ void panasonicSramCreate(UInt8* sram, UInt32 size)
panasonicSramMask = size - 1;
}
void panasonicSramDestroy()
void panasonicSramDestroy(void)
{
panasonicSramMask = 0;
}
static void changeBank(RomMapperA1FM* rm, int region, int bank);
static void saveState(RomMapperA1FM* rm)
static void rommappera1fm_saveState(void *data)
{
SaveState* state = saveStateOpenForWrite("mapperPanasonic");
RomMapperA1FM *rm = (RomMapperA1FM*)data;
SaveState* state = saveStateOpenForWrite("mapperPanasonic");
char tag[16];
int i;
@ -115,9 +113,10 @@ static void saveState(RomMapperA1FM* rm)
saveStateClose(state);
}
static void loadState(RomMapperA1FM* rm)
static void rommappera1fm_loadState(void *data)
{
SaveState* state = saveStateOpenForRead("mapperPanasonic");
RomMapperA1FM *rm = (RomMapperA1FM*)data;
SaveState* state = saveStateOpenForRead("mapperPanasonic");
int romMapper[8];
char tag[16];
int i;
@ -133,9 +132,8 @@ static void loadState(RomMapperA1FM* rm)
saveStateClose(state);
for (i = 0; i < 8; i++) {
for (i = 0; i < 8; i++)
changeBank(rm, i, romMapper[i]);
}
switch (rm->readSection) {
case READ_SRAM:
@ -150,8 +148,9 @@ static void loadState(RomMapperA1FM* rm)
}
}
static void destroy(RomMapperA1FM* rm)
static void rommappera1fm_destroy(void *data)
{
RomMapperA1FM *rm = (RomMapperA1FM*)data;
sramSave(rm->sramFilename, rm->sram, rm->sramSize, NULL, 0);
slotUnregister(rm->slot, rm->sslot, rm->startPage);
@ -168,7 +167,7 @@ static void changeBank(RomMapperA1FM* rm, int region, int bank)
{
UInt8* readBlock;
rm->romMapper[region] = bank;
rm->romMapper[region] = bank;
if (bank >= 0x80 && bank < 0x90) {
if (bank & 0x04) {
@ -197,35 +196,34 @@ static void changeBank(RomMapperA1FM* rm, int region, int bank)
readBlock = rm->romData + 0x2000 * (bank & 0x7f);
}
if (region >=6) {
if (region >=6)
readBlock = emptyRam;
}
slotMapPage(rm->slot, rm->sslot, region, readBlock, region != 3, 0);
}
static UInt8 read(RomMapperA1FM* rm, UInt16 address)
static UInt8 rommappera1fm_read(void *data, UInt16 address)
{
if ((rm->control & 0x04) && address >= 0x7ff0 && address < 0x7ff8) {
RomMapperA1FM *rm = (RomMapperA1FM*)data;
if ((rm->control & 0x04) && address >= 0x7ff0 && address < 0x7ff8)
return rm->romMapper[address & 7];
}
return rm->readBlock[address & 0x1fff];
}
static void write(RomMapperA1FM* rm, UInt16 address, UInt8 value)
static void rommappera1fm_write(void *data, UInt16 address, UInt8 value)
{
int bank;
RomMapperA1FM *rm = (RomMapperA1FM*)data;
if (address >= 0x6000 && address < 0x7ff0) {
static const int Regions[8] = { 2, 0, 3, 1, 4, -1, 5, -1 };
int region = Regions[(address >> 10) & 7];
if (region != -1) {
if (region != -1)
changeBank(rm, region, value);
}
return;
}
}
if (address == 0x7ff9) {
rm->control = value;
@ -240,15 +238,15 @@ static void write(RomMapperA1FM* rm, UInt16 address, UInt8 value)
}
}
static void reset(RomMapperA1FM* rm)
static void rommappera1fm_reset(void *data)
{
int i;
RomMapperA1FM *rm = (RomMapperA1FM*)data;
rm->control = 0;
for (i = 0; i < 6; i++) {
for (i = 0; i < 6; i++)
changeBank(rm, i, 0xa8);
}
changeBank(rm, 6, 0);
changeBank(rm, 7, 0);
}
@ -257,26 +255,25 @@ int romMapperA1FMCreate(const char* filename, UInt8* romData,
int size, int slot, int sslot, int startPage,
int sramSize)
{
DeviceCallbacks callbacks = { destroy, reset, saveState, loadState };
DeviceCallbacks callbacks = { rommappera1fm_destroy, rommappera1fm_reset, rommappera1fm_saveState, rommappera1fm_loadState };
RomMapperA1FM* rm;
char suffix[16];
if (size < 0x8000 || startPage != 0) {
if (size < 0x8000 || startPage != 0)
return 0;
}
memset(emptyRam, 0xff, sizeof(emptyRam));
rm = malloc(sizeof(RomMapperA1FM));
rm = (RomMapperA1FM*)malloc(sizeof(RomMapperA1FM));
rm->deviceHandle = deviceManagerRegister(ROM_PANASONIC8, &callbacks, rm);
slotRegister(slot, sslot, 0, 8, read, read, write, destroy, rm);
slotRegister(slot, sslot, 0, 8, rommappera1fm_read, rommappera1fm_read, rommappera1fm_write, rommappera1fm_destroy, rm);
rm->romData = malloc(size);
rm->romData = (UInt8*)malloc(size);
memcpy(rm->romData, romData, size);
rm->romSize = size;
rm->sramSize = sramSize;
rm->sram = malloc(sramSize);
rm->romSize = size;
rm->sramSize = sramSize;
rm->sram = (UInt8*)malloc(sramSize);
memset(rm->sram, 0xff, sramSize);
rm->maxSRAMBank = SRAM_BASE + sramSize / 0x2000;
memset(rm->romMapper, 0, sizeof(rm->romMapper));
@ -292,7 +289,7 @@ int romMapperA1FMCreate(const char* filename, UInt8* romData,
panasonicSramCreate(rm->sram, rm->sramSize);
reset(rm);
rommappera1fm_reset(rm);
return 1;
}

View File

@ -49,8 +49,9 @@ typedef struct {
int romMapper;
} RomMapperA1FMModem;
static void saveState(RomMapperA1FMModem* rm)
static void rommappera1fm_saveState(void *data)
{
RomMapperA1FMModem *rm = (RomMapperA1FMModem*)data;
SaveState* state = saveStateOpenForWrite("mapperPanasonicA1FM");
saveStateSet(state, "romMapper", rm->romMapper);
@ -58,18 +59,20 @@ static void saveState(RomMapperA1FMModem* rm)
saveStateClose(state);
}
static void loadState(RomMapperA1FMModem* rm)
static void rommappera1fm_loadState(void *data)
{
SaveState* state = saveStateOpenForRead("mapperPanasonicA1FM");
rm->romMapper = saveStateGet(state, "romMapper", 0);
RomMapperA1FMModem *rm = (RomMapperA1FMModem*)data;
SaveState* state = saveStateOpenForRead("mapperPanasonicA1FM");
rm->romMapper = saveStateGet(state, "romMapper", 0);
saveStateClose(state);
slotMapPage(rm->slot, rm->sslot, rm->startPage, rm->romData + rm->romMapper * 0x2000, 1, 0);
}
static void destroy(RomMapperA1FMModem* rm)
static void rommappera1fm_destroy(void *data)
{
RomMapperA1FMModem *rm = (RomMapperA1FMModem*)data;
slotUnregister(rm->slot, rm->sslot, rm->startPage);
deviceManagerUnregister(rm->deviceHandle);
@ -77,8 +80,9 @@ static void destroy(RomMapperA1FMModem* rm)
free(rm);
}
static UInt8 read(RomMapperA1FMModem* rm, UInt16 address)
static UInt8 rommappera1fm_read(void *data, UInt16 address)
{
RomMapperA1FMModem* rm = (RomMapperA1FMModem*)data;
address += 0x4000;
if (address >= 0x7fc0 && address < 0x7fd0) {
@ -95,8 +99,9 @@ static UInt8 read(RomMapperA1FMModem* rm, UInt16 address)
return panasonicSramGet(address & 0x1fff);
}
static void write(RomMapperA1FMModem* rm, UInt16 address, UInt8 value)
static void rommappera1fm_write(void *data, UInt16 address, UInt8 value)
{
RomMapperA1FMModem *rm = (RomMapperA1FMModem*)data;
address += 0x4000;
if (address >= 0x6000 && address < 0x8000) {
@ -109,8 +114,9 @@ static void write(RomMapperA1FMModem* rm, UInt16 address, UInt8 value)
}
}
static void reset(RomMapperA1FMModem* rm)
static void rommappera1fm_reset(void *data)
{
RomMapperA1FMModem *rm = (RomMapperA1FMModem*)data;
slotMapPage(rm->slot, rm->sslot, rm->startPage + 0, rm->romData + rm->romMapper * 0x2000, 1, 0);
slotMapPage(rm->slot, rm->sslot, rm->startPage + 1, NULL, 0, 0);
}
@ -118,15 +124,13 @@ static void reset(RomMapperA1FMModem* rm)
int romMapperA1FMModemCreate(const char* filename, UInt8* romData,
int size, int slot, int sslot, int startPage)
{
DeviceCallbacks callbacks = { destroy, reset, saveState, loadState };
RomMapperA1FMModem* rm;
rm = malloc(sizeof(RomMapperA1FMModem));
DeviceCallbacks callbacks = { rommappera1fm_destroy, rommappera1fm_reset, rommappera1fm_saveState, rommappera1fm_loadState };
RomMapperA1FMModem *rm = (RomMapperA1FMModem*)malloc(sizeof(RomMapperA1FMModem));
rm->deviceHandle = deviceManagerRegister(ROM_FSA1FMMODEM, &callbacks, rm);
slotRegister(slot, sslot, startPage, 2, read, read, write, destroy, rm);
slotRegister(slot, sslot, startPage, 2, rommappera1fm_read, rommappera1fm_read, rommappera1fm_write, rommappera1fm_destroy, rm);
rm->romData = malloc(size);
rm->romData = (UInt8*)malloc(size);
memcpy(rm->romData, romData, size);
rm->romSize = size;
rm->slot = slot;
@ -135,7 +139,7 @@ int romMapperA1FMModemCreate(const char* filename, UInt8* romData,
rm->romMapper = 0;
reset(rm);
rommappera1fm_reset(rm);
return 1;
}

View File

@ -147,9 +147,8 @@ static void write(RomMapperSunriseIde* rm, UInt16 address, UInt8 value)
}
if (rm->ideEnabled && (address & 0x3e00) == 0x3c00) {
if ((address & 1) == 0) {
if ((address & 1) == 0)
rm->writeLatch = value;
}
else {
sunriseIdeWrite(rm->ide, (value << 8) | rm->writeLatch);
}
@ -181,19 +180,15 @@ int romMapperSunriseIdeCreate(int hdId, const char* filename, UInt8* romData,
int i;
int origSize = size;
if (startPage != 0) {
if (startPage != 0)
return 0;
}
size = 0x4000;
while (size < origSize) {
while (size < origSize)
size *= 2;
}
if (romData == NULL) {
if (romData == NULL)
size = 0x80000;
}
rm = malloc(sizeof(RomMapperSunriseIde));
@ -203,12 +198,10 @@ int romMapperSunriseIdeCreate(int hdId, const char* filename, UInt8* romData,
rm->ide = sunriseIdeCreate(hdId);
rm->romData = calloc(1, size);
if (romData != NULL) {
if (romData != NULL)
memcpy(rm->romData, romData, origSize);
}
else {
else
memset(rm->romData, 0xff, size);
}
rm->romMask = size / 0x4000 - 1;
rm->slot = slot;
rm->sslot = sslot;
@ -216,9 +209,8 @@ int romMapperSunriseIdeCreate(int hdId, const char* filename, UInt8* romData,
rm->romMapper = 0;
for (i = 0; i < 8; i++) {
for (i = 0; i < 8; i++)
slotMapPage(rm->slot, rm->sslot, rm->startPage + i, NULL, 0, 0);
}
rm->ideEnabled = 1;
rm->romMapper = 0;

View File

@ -31,8 +31,6 @@
#include <string.h>
#include <stdio.h>
const char* sramCreateFilenameWithSuffix(const char* romFilename, char* suffix, char* ext)
{
static char SRAMfileName[512];
@ -78,6 +76,7 @@ const char* sramCreateFilenameWithSuffix(const char* romFilename, char* suffix,
const char* sramCreateFilename(const char* romFilename) {
return sramCreateFilenameWithSuffix(romFilename, "", NULL);
}
void sramLoad(const char* filename, UInt8* sram, int length, void* header, int headerLength) {
FILE* file;

View File

@ -79,12 +79,6 @@
#include <stdlib.h>
#include <string.h>
#define DBGLOG(fmt)
#define DBGLOG1(fmt, arg1)
#define DBGLOG2(fmt, arg1, arg2)
#define DBGLOG3(fmt, arg1, arg2, arg3)
#define DBGLOG4(fmt, arg1, arg2, arg3, arg4)
#define SPC_BANK 0x7f
typedef struct {
@ -115,8 +109,6 @@ static void setMapper(SramMapperMegaSCSI* rm, int page, UInt8 value)
int readFlag;
UInt8* adr;
DBGLOG2("setMapper: %x %x\n", page, value);
if (rm->type && (value & 0xc0) == 0x40) {
readFlag = 0;
writeFlag = 0;
@ -131,11 +123,8 @@ static void setMapper(SramMapperMegaSCSI* rm, int page, UInt8 value)
if (rm->mapper[page] != value) {
rm->mapper[page] = value;
DBGLOG4("bank change: p%x v%x r%d w%d\n", page, value, readFlag, writeFlag);
slotMapPage(rm->pSlot, rm->sSlot, rm->startPage + page,
adr, readFlag, writeFlag);
} else {
DBGLOG("bank not changed\n");
}
}
@ -166,9 +155,8 @@ static void saveState(SramMapperMegaSCSI* rm)
}
saveStateClose(state);
if (rm->type) {
if (rm->type)
mb89352SaveState(rm->spc);
}
}
static void loadState(SramMapperMegaSCSI* rm)
@ -177,8 +165,6 @@ static void loadState(SramMapperMegaSCSI* rm)
char tag[16];
int i;
DBGLOG("load State\n");
saveStateGetBuffer(state, "sramData", rm->sramData, rm->sramSize);
for (i = 0; i < 4; i++) {
@ -187,27 +173,23 @@ static void loadState(SramMapperMegaSCSI* rm)
}
saveStateClose(state);
if (rm->type) {
if (rm->type)
mb89352LoadState(rm->spc);
}
}
static void destroy(SramMapperMegaSCSI* rm)
{
if (!rm->isZip) {
if (!rm->isZip)
sramSave(rm->sramFilename, rm->sramData, rm->sramSize, NULL, 0);
}
slotUnregister(rm->pSlot, rm->sSlot, rm->startPage);
deviceManagerUnregister(rm->deviceHandle);
if (rm->type) {
if (rm->type)
mb89352Destroy(rm->spc);
}
if (rm->isAutoName) {
if (rm->isAutoName)
--autoNameCounter[rm->type][rm->element];
}
free(rm->sramData);
free(rm);
@ -221,15 +203,13 @@ static UInt8 read(SramMapperMegaSCSI* rm, UInt16 address)
address &= 0x1fff;
// SPC read
if (address < 0x1000) {
if (address < 0x1000)
// Data Register
return mb89352ReadDREG(rm->spc);
}
address &= 0x0f;
return mb89352ReadRegister(rm->spc, (UInt8)address);
} else {
return 0xff;
}
return 0xff;
}
static UInt8 peek(SramMapperMegaSCSI* rm, UInt16 address)
@ -246,10 +226,10 @@ static UInt8 peek(SramMapperMegaSCSI* rm, UInt16 address)
}
address &= 0x0f;
return mb89352PeekRegister(rm->spc, (UInt8)address);
} else {
return 0xff;
}
return 0xff;
}
static void write(SramMapperMegaSCSI* rm, UInt16 address, UInt8 value)
{
int page = (address >> 13);
@ -261,11 +241,10 @@ static void write(SramMapperMegaSCSI* rm, UInt16 address, UInt8 value)
if (rm->type && (rm->mapper[page] == SPC_BANK)){
address &= 0x1fff;
if (address < 0x1000) {
if (address < 0x1000)
mb89352WriteDREG(rm->spc, value);
} else {
else
mb89352WriteRegister(rm->spc, address & 0x0f, value);
}
}
}
@ -278,9 +257,8 @@ int sramMapperMegaSCSICreate(const char* filename, UInt8* buf, int size, int pSl
int i;
if (((size != 0x100000) && (size != 0x80000) &&
(size != 0x40000) && (size != 0x20000)) || (flag & ~0x81)) {
(size != 0x40000) && (size != 0x20000)) || (flag & ~0x81))
return 0;
}
rm = malloc(sizeof(SramMapperMegaSCSI));
rm->type = flag & 1;
@ -288,24 +266,22 @@ int sramMapperMegaSCSICreate(const char* filename, UInt8* buf, int size, int pSl
rm->deviceHandle = deviceManagerRegister(SRAM_MEGASCSI, &callbacks, rm);
if (rm->type) {
if (rm->type)
slotRegister(pSlot, sSlot, startPage, 4,
(SlotRead)read, (SlotRead)peek, (SlotWrite)write,
(SlotEject)destroy, rm);
} else {
else
slotRegister(pSlot, sSlot, startPage, 4, NULL, NULL, (SlotWrite)write,
(SlotEject)destroy, rm);
}
rm->pSlot = pSlot;
rm->sSlot = sSlot;
rm->startPage = startPage;
rm->mapperMask = ((size >> 13) - 1) | 0x80;
DBGLOG1("mapper mask: %x\n", (unsigned int)rm->mapperMask);
if (strlen(filename)) {
if (strlen(filename))
rm->isAutoName = 0;
} else {
else {
rm->element = EseRamSize(size);
rm->isAutoName = 1;
}

View File

@ -34,11 +34,11 @@
*/
static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)
{
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
/* POTENTIAL BUG: temp*(temp^1) may overflow in an
* unpredictable manner on 16-bit systems; not a problem
* with any known compiler so far, though */
temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
unsigned temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2;
return (int)(((temp * (temp ^ 1)) >> 8) & 0xff);
}
@ -87,13 +87,7 @@ static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned lon
# define ZCR_SEED2 3141592654UL /* use PI as default pattern */
# endif
static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting)
const char *passwd; /* password string */
unsigned char *buf; /* where to write header */
int bufSize;
unsigned long* pkeys;
const unsigned long* pcrc_32_tab;
unsigned long crcForCrypting;
static int crypthead(const char *passwd, unsigned char *buf, int bufSize, unsigned long *pkeys, const unsigned long *pcrc_32_tab, unsigned long crcForCrypting)
{
int n; /* index in random header */
int t; /* temporary */

View File

@ -65,10 +65,7 @@ int ZCALLBACK ferror_file_func OF((
voidpf stream));
voidpf ZCALLBACK fopen_file_func (opaque, filename, mode)
voidpf opaque;
const char* filename;
int mode;
voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char *filename, int mode)
{
FILE* file = NULL;
const char* mode_fopen = NULL;
@ -87,43 +84,23 @@ voidpf ZCALLBACK fopen_file_func (opaque, filename, mode)
}
uLong ZCALLBACK fread_file_func (opaque, stream, buf, size)
voidpf opaque;
voidpf stream;
void* buf;
uLong size;
uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void *buf, uLong size)
{
uLong ret;
ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
return ret;
return (uLong)fread(buf, 1, (size_t)size, (FILE *)stream);
}
uLong ZCALLBACK fwrite_file_func (opaque, stream, buf, size)
voidpf opaque;
voidpf stream;
const void* buf;
uLong size;
uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void *buf, uLong size)
{
uLong ret;
ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
return ret;
return (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream);
}
long ZCALLBACK ftell_file_func (opaque, stream)
voidpf opaque;
voidpf stream;
long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
{
long ret;
ret = ftell((FILE *)stream);
return ret;
return (long)ftell((FILE *)stream);
}
long ZCALLBACK fseek_file_func (opaque, stream, offset, origin)
voidpf opaque;
voidpf stream;
uLong offset;
int origin;
long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin)
{
int fseek_origin=0;
long ret;
@ -145,26 +122,17 @@ long ZCALLBACK fseek_file_func (opaque, stream, offset, origin)
return ret;
}
int ZCALLBACK fclose_file_func (opaque, stream)
voidpf opaque;
voidpf stream;
int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream)
{
int ret;
ret = fclose((FILE *)stream);
return ret;
return (int)fclose((FILE *)stream);
}
int ZCALLBACK ferror_file_func (opaque, stream)
voidpf opaque;
voidpf stream;
int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream)
{
int ret;
ret = ferror((FILE *)stream);
return ret;
return (int)ferror((FILE *)stream);
}
void fill_fopen_filefunc (pzlib_filefunc_def)
zlib_filefunc_def* pzlib_filefunc_def;
void fill_fopen_filefunc (zlib_filefunc_def *pzlib_filefunc_def)
{
pzlib_filefunc_def->zopen_file = fopen_file_func;
pzlib_filefunc_def->zread_file = fread_file_func;

View File

@ -162,16 +162,7 @@ typedef struct
IN assertion: the stream s has been sucessfully opened for reading.
*/
local int unzlocal_getByte OF((
const zlib_filefunc_def* pzlib_filefunc_def,
voidpf filestream,
int *pi));
local int unzlocal_getByte(pzlib_filefunc_def,filestream,pi)
const zlib_filefunc_def* pzlib_filefunc_def;
voidpf filestream;
int *pi;
local int unzlocal_getByte(const zlib_filefunc_def *pzlib_filefunc_def, voidpf filestream, int *pi)
{
unsigned char c;
int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1);
@ -193,22 +184,11 @@ local int unzlocal_getByte(pzlib_filefunc_def,filestream,pi)
/* ===========================================================================
Reads a long in LSB order from the given gz_stream. Sets
*/
local int unzlocal_getShort OF((
const zlib_filefunc_def* pzlib_filefunc_def,
voidpf filestream,
uLong *pX));
local int unzlocal_getShort (pzlib_filefunc_def,filestream,pX)
const zlib_filefunc_def* pzlib_filefunc_def;
voidpf filestream;
uLong *pX;
local int unzlocal_getShort (const zlib_filefunc_def *pzlib_filefunc_def, voidpf filestream, uLong *pX)
{
uLong x ;
int i;
int err;
err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
x = (uLong)i;
int err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
uLong x = (uLong)i;
if (err==UNZ_OK)
err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i);
@ -221,15 +201,7 @@ local int unzlocal_getShort (pzlib_filefunc_def,filestream,pX)
return err;
}
local int unzlocal_getLong OF((
const zlib_filefunc_def* pzlib_filefunc_def,
voidpf filestream,
uLong *pX));
local int unzlocal_getLong (pzlib_filefunc_def,filestream,pX)
const zlib_filefunc_def* pzlib_filefunc_def;
voidpf filestream;
uLong *pX;
local int unzlocal_getLong (const zlib_filefunc_def *pzlib_filefunc_def, voidpf filestream, uLong *pX)
{
uLong x ;
int i;
@ -259,9 +231,7 @@ local int unzlocal_getLong (pzlib_filefunc_def,filestream,pX)
/* My own strcmpi / strcasecmp */
local int strcmpcasenosensitive_internal (fileName1,fileName2)
const char* fileName1;
const char* fileName2;
local int strcmpcasenosensitive_internal (const char *fileName1, const char *fileName2)
{
for (;;)
{
@ -302,10 +272,7 @@ local int strcmpcasenosensitive_internal (fileName1,fileName2)
(like 1 on Unix, 2 on Windows)
*/
extern int ZEXPORT unzStringFileNameCompare (fileName1,fileName2,iCaseSensitivity)
const char* fileName1;
const char* fileName2;
int iCaseSensitivity;
extern int ZEXPORT unzStringFileNameCompare (const char *fileName1, const char *fileName2, int iCaseSensitivity)
{
if (iCaseSensitivity==0)
iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE;
@ -328,9 +295,7 @@ local uLong unzlocal_SearchCentralDir OF((
const zlib_filefunc_def* pzlib_filefunc_def,
voidpf filestream));
local uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream)
const zlib_filefunc_def* pzlib_filefunc_def;
voidpf filestream;
local uLong unzlocal_SearchCentralDir(const zlib_filefunc_def *pzlib_filefunc_def, voidpf filestream)
{
unsigned char* buf;
uLong uSizeFile;
@ -394,9 +359,7 @@ local uLong unzlocal_SearchCentralDir(pzlib_filefunc_def,filestream)
Else, the return value is a unzFile Handle, usable with other function
of this unzip package.
*/
extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def)
const char *path;
zlib_filefunc_def* pzlib_filefunc_def;
extern unzFile ZEXPORT unzOpen2 (const char *path, zlib_filefunc_def *pzlib_filefunc_def)
{
unz_s us;
unz_s *s;
@ -497,8 +460,7 @@ extern unzFile ZEXPORT unzOpen2 (path, pzlib_filefunc_def)
}
extern unzFile ZEXPORT unzOpen (path)
const char *path;
extern unzFile ZEXPORT unzOpen (const char *path)
{
return unzOpen2(path, NULL);
}
@ -508,8 +470,7 @@ extern unzFile ZEXPORT unzOpen (path)
If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
return UNZ_OK if there is no problem. */
extern int ZEXPORT unzClose (file)
unzFile file;
extern int ZEXPORT unzClose (unzFile file)
{
unz_s* s;
if (file==NULL)
@ -529,9 +490,7 @@ extern int ZEXPORT unzClose (file)
Write info about the ZipFile in the *pglobal_info structure.
No preparation of the structure is needed
return UNZ_OK if there is no problem. */
extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info)
unzFile file;
unz_global_info *pglobal_info;
extern int ZEXPORT unzGetGlobalInfo (unzFile file, unz_global_info *pglobal_info)
{
unz_s* s;
if (file==NULL)
@ -545,19 +504,16 @@ extern int ZEXPORT unzGetGlobalInfo (file,pglobal_info)
/*
Translate date/time from Dos format to tm_unz (readable more easilty)
*/
local void unzlocal_DosDateToTmuDate (ulDosDate, ptm)
uLong ulDosDate;
tm_unz* ptm;
local void unzlocal_DosDateToTmuDate (uLong ulDosDate, tm_unz *ptm)
{
uLong uDate;
uDate = (uLong)(ulDosDate>>16);
uLong uDate = (uLong)(ulDosDate>>16);
ptm->tm_mday = (uInt)(uDate&0x1f) ;
ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ;
ptm->tm_mon = (uInt)((((uDate)&0x1E0)/0x20)-1) ;
ptm->tm_year = (uInt)(((uDate&0x0FE00)/0x0200)+1980) ;
ptm->tm_hour = (uInt) ((ulDosDate &0xF800)/0x800);
ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ;
ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ;
ptm->tm_min = (uInt) ((ulDosDate&0x7E0)/0x20) ;
ptm->tm_sec = (uInt) (2*(ulDosDate&0x1f)) ;
}
/*
@ -574,21 +530,12 @@ local int unzlocal_GetCurrentFileInfoInternal OF((unzFile file,
char *szComment,
uLong commentBufferSize));
local int unzlocal_GetCurrentFileInfoInternal (file,
pfile_info,
pfile_info_internal,
szFileName, fileNameBufferSize,
extraField, extraFieldBufferSize,
szComment, commentBufferSize)
unzFile file;
unz_file_info *pfile_info;
unz_file_info_internal *pfile_info_internal;
char *szFileName;
uLong fileNameBufferSize;
void *extraField;
uLong extraFieldBufferSize;
char *szComment;
uLong commentBufferSize;
local int unzlocal_GetCurrentFileInfoInternal (unzFile file,
unz_file_info *pfile_info,
unz_file_info_internal *pfile_info_internal,
char *szFileName, uLong fileNameBufferSize,
void *extraField, uLong extraFieldBufferSize,
char *szComment, uLong commentBufferSize)
{
unz_s* s;
unz_file_info file_info;
@ -741,19 +688,11 @@ local int unzlocal_GetCurrentFileInfoInternal (file,
No preparation of the structure is needed
return UNZ_OK if there is no problem.
*/
extern int ZEXPORT unzGetCurrentFileInfo (file,
pfile_info,
szFileName, fileNameBufferSize,
extraField, extraFieldBufferSize,
szComment, commentBufferSize)
unzFile file;
unz_file_info *pfile_info;
char *szFileName;
uLong fileNameBufferSize;
void *extraField;
uLong extraFieldBufferSize;
char *szComment;
uLong commentBufferSize;
extern int ZEXPORT unzGetCurrentFileInfo (unzFile file,
unz_file_info *pfile_info,
char *szFileName, uLong fileNameBufferSize,
void *extraField, uLong extraFieldBufferSize,
char *szComment, uLong commentBufferSize)
{
return unzlocal_GetCurrentFileInfoInternal(file,pfile_info,NULL,
szFileName,fileNameBufferSize,
@ -765,8 +704,7 @@ extern int ZEXPORT unzGetCurrentFileInfo (file,
Set the current file of the zipfile to the first file.
return UNZ_OK if there is no problem
*/
extern int ZEXPORT unzGoToFirstFile (file)
unzFile file;
extern int ZEXPORT unzGoToFirstFile (unzFile file)
{
int err=UNZ_OK;
unz_s* s;
@ -787,8 +725,7 @@ extern int ZEXPORT unzGoToFirstFile (file)
return UNZ_OK if there is no problem
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
*/
extern int ZEXPORT unzGoToNextFile (file)
unzFile file;
extern int ZEXPORT unzGoToNextFile (unzFile file)
{
unz_s* s;
int err;
@ -821,10 +758,7 @@ extern int ZEXPORT unzGoToNextFile (file)
UNZ_OK if the file is found. It becomes the current file.
UNZ_END_OF_LIST_OF_FILE if the file is not found
*/
extern int ZEXPORT unzLocateFile (file, szFileName, iCaseSensitivity)
unzFile file;
const char *szFileName;
int iCaseSensitivity;
extern int ZEXPORT unzLocateFile (unzFile file, const char *szFileName, int iCaseSensitivity)
{
unz_s* s;
int err;
@ -900,9 +834,7 @@ typedef struct unz_file_pos_s
} unz_file_pos;
*/
extern int ZEXPORT unzGetFilePos(file, file_pos)
unzFile file;
unz_file_pos* file_pos;
extern int ZEXPORT unzGetFilePos(unzFile file, unz_file_pos *file_pos)
{
unz_s* s;
@ -918,9 +850,7 @@ extern int ZEXPORT unzGetFilePos(file, file_pos)
return UNZ_OK;
}
extern int ZEXPORT unzGoToFilePos(file, file_pos)
unzFile file;
unz_file_pos* file_pos;
extern int ZEXPORT unzGoToFilePos(unzFile file, unz_file_pos *file_pos)
{
unz_s* s;
int err;
@ -954,13 +884,9 @@ extern int ZEXPORT unzGoToFilePos(file, file_pos)
store in *piSizeVar the size of extra info in local header
(filename and size of extra field data)
*/
local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar,
poffset_local_extrafield,
psize_local_extrafield)
unz_s* s;
uInt* piSizeVar;
uLong *poffset_local_extrafield;
uInt *psize_local_extrafield;
local int unzlocal_CheckCurrentFileCoherencyHeader (unz_s *s, uInt *piSizeVar,
uLong *poffset_local_extrafield,
uInt *psize_local_extrafield)
{
uLong uMagic,uData,uFlags;
uLong size_filename;
@ -1044,12 +970,7 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar,
Open for reading data the current file in the zipfile.
If there is no error and the file is opened, the return value is UNZ_OK.
*/
extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
unzFile file;
int* method;
int* level;
int raw;
const char* password;
extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int *method, int *level, int raw, const char *password)
{
int err=UNZ_OK;
uInt iSizeVar;
@ -1130,7 +1051,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
pfile_in_zip_read_info->stream.zfree = (free_func)0;
pfile_in_zip_read_info->stream.opaque = (voidpf)0;
pfile_in_zip_read_info->stream.next_in = (voidpf)0;
pfile_in_zip_read_info->stream.next_in = (Bytef*)0;
pfile_in_zip_read_info->stream.avail_in = 0;
err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS);
@ -1189,24 +1110,17 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
return UNZ_OK;
}
extern int ZEXPORT unzOpenCurrentFile (file)
unzFile file;
extern int ZEXPORT unzOpenCurrentFile (unzFile file)
{
return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL);
}
extern int ZEXPORT unzOpenCurrentFilePassword (file, password)
unzFile file;
const char* password;
extern int ZEXPORT unzOpenCurrentFilePassword (unzFile file, const char *password)
{
return unzOpenCurrentFile3(file, NULL, NULL, 0, password);
}
extern int ZEXPORT unzOpenCurrentFile2 (file,method,level,raw)
unzFile file;
int* method;
int* level;
int raw;
extern int ZEXPORT unzOpenCurrentFile2 (unzFile file, int *method, int*level, int raw)
{
return unzOpenCurrentFile3(file, method, level, raw, NULL);
}
@ -1221,10 +1135,7 @@ extern int ZEXPORT unzOpenCurrentFile2 (file,method,level,raw)
return <0 with error code if there is an error
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
*/
extern int ZEXPORT unzReadCurrentFile (file, buf, len)
unzFile file;
voidp buf;
unsigned len;
extern int ZEXPORT unzReadCurrentFile (unzFile file, voidpf buf, unsigned len)
{
int err=UNZ_OK;
uInt iRead = 0;
@ -1382,8 +1293,7 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len)
/*
Give the current position in uncompressed data
*/
extern z_off_t ZEXPORT unztell (file)
unzFile file;
extern z_off_t ZEXPORT unztell (unzFile file)
{
unz_s* s;
file_in_zip_read_info_s* pfile_in_zip_read_info;
@ -1402,8 +1312,7 @@ extern z_off_t ZEXPORT unztell (file)
/*
return 1 if the end of file was reached, 0 elsewhere
*/
extern int ZEXPORT unzeof (file)
unzFile file;
extern int ZEXPORT unzeof (unzFile file)
{
unz_s* s;
file_in_zip_read_info_s* pfile_in_zip_read_info;
@ -1435,10 +1344,7 @@ extern int ZEXPORT unzeof (file)
the return value is the number of bytes copied in buf, or (if <0)
the error code
*/
extern int ZEXPORT unzGetLocalExtrafield (file,buf,len)
unzFile file;
voidp buf;
unsigned len;
extern int ZEXPORT unzGetLocalExtrafield (unzFile file, voidp buf, unsigned len)
{
unz_s* s;
file_in_zip_read_info_s* pfile_in_zip_read_info;
@ -1486,11 +1392,9 @@ extern int ZEXPORT unzGetLocalExtrafield (file,buf,len)
Close the file in zip opened with unzipOpenCurrentFile
Return UNZ_CRCERROR if all the file was read but the CRC is not good
*/
extern int ZEXPORT unzCloseCurrentFile (file)
unzFile file;
extern int ZEXPORT unzCloseCurrentFile (unzFile file)
{
int err=UNZ_OK;
unz_s* s;
file_in_zip_read_info_s* pfile_in_zip_read_info;
if (file==NULL)
@ -1529,10 +1433,7 @@ extern int ZEXPORT unzCloseCurrentFile (file)
uSizeBuf is the size of the szComment buffer.
return the number of byte copied or an error code <0
*/
extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf)
unzFile file;
char *szComment;
uLong uSizeBuf;
extern int ZEXPORT unzGetGlobalComment (unzFile file, char *szComment, uLong uSizeBuf)
{
int err=UNZ_OK;
unz_s* s;
@ -1561,8 +1462,7 @@ extern int ZEXPORT unzGetGlobalComment (file, szComment, uSizeBuf)
}
/* Additions by RX '2004 */
extern uLong ZEXPORT unzGetOffset (file)
unzFile file;
extern uLong ZEXPORT unzGetOffset (unzFile file)
{
unz_s* s;
@ -1577,9 +1477,7 @@ extern uLong ZEXPORT unzGetOffset (file)
return s->pos_in_central_dir;
}
extern int ZEXPORT unzSetOffset (file, pos)
unzFile file;
uLong pos;
extern int ZEXPORT unzSetOffset (unzFile file, uLong pos)
{
unz_s* s;
int err;

View File

@ -172,10 +172,9 @@ local linkedlist_datablock_internal* allocate_new_datablock()
return ldi;
}
local void free_datablock(ldi)
linkedlist_datablock_internal* ldi;
local void free_datablock(linkedlist_datablock_internal* ldi)
{
while (ldi!=NULL)
while (ldi)
{
linkedlist_datablock_internal* ldinext = ldi->next_datablock;
TRYFREE(ldi);
@ -183,32 +182,27 @@ local void free_datablock(ldi)
}
}
local void init_linkedlist(ll)
linkedlist_data* ll;
local void init_linkedlist(linkedlist_data* ll)
{
ll->first_block = ll->last_block = NULL;
}
local void free_linkedlist(ll)
linkedlist_data* ll;
local void free_linkedlist(linkedlist_data*ll)
{
free_datablock(ll->first_block);
ll->first_block = ll->last_block = NULL;
}
local int add_data_in_datablock(ll,buf,len)
linkedlist_data* ll;
const void* buf;
uLong len;
local int add_data_in_datablock(linkedlist_data*ll,const void *buf,uLong len)
{
linkedlist_datablock_internal* ldi;
const unsigned char* from_copy;
if (ll==NULL)
if (!ll)
return ZIP_INTERNALERROR;
if (ll->last_block == NULL)
if (!ll->last_block)
{
ll->first_block = ll->last_block = allocate_new_datablock();
if (ll->first_block == NULL)
@ -261,13 +255,7 @@ local int add_data_in_datablock(ll,buf,len)
nbByte == 1, 2 or 4 (byte, short or long)
*/
local int ziplocal_putValue OF((const zlib_filefunc_def* pzlib_filefunc_def,
voidpf filestream, uLong x, int nbByte));
local int ziplocal_putValue (pzlib_filefunc_def, filestream, x, nbByte)
const zlib_filefunc_def* pzlib_filefunc_def;
voidpf filestream;
uLong x;
int nbByte;
local int ziplocal_putValue (const zlib_filefunc_def *pzlib_filefunc_def, voidpf filestream, uLong x, int nbByte)
{
unsigned char buf[4];
int n;
@ -279,22 +267,15 @@ local int ziplocal_putValue (pzlib_filefunc_def, filestream, x, nbByte)
if (x != 0)
{ /* data overflow - hack for ZIP64 (X Roche) */
for (n = 0; n < nbByte; n++)
{
buf[n] = 0xff;
}
}
if (ZWRITE(*pzlib_filefunc_def,filestream,buf,nbByte)!=(uLong)nbByte)
return ZIP_ERRNO;
else
return ZIP_OK;
return ZIP_OK;
}
local void ziplocal_putValue_inmemory OF((void* dest, uLong x, int nbByte));
local void ziplocal_putValue_inmemory (dest, x, nbByte)
void* dest;
uLong x;
int nbByte;
local void ziplocal_putValue_inmemory (void *dest, uLong x, int nbByte)
{
unsigned char* buf=(unsigned char*)dest;
int n;
@ -315,9 +296,7 @@ local void ziplocal_putValue_inmemory (dest, x, nbByte)
/****************************************************************************/
local uLong ziplocal_TmzDateToDosDate(ptm,dosDate)
const tm_zip* ptm;
uLong dosDate;
local uLong ziplocal_TmzDateToDosDate(const tm_zip *ptm, uLong dosDate)
{
uLong year = (uLong)ptm->tm_year;
if (year>1980)
@ -332,15 +311,7 @@ local uLong ziplocal_TmzDateToDosDate(ptm,dosDate)
/****************************************************************************/
local int ziplocal_getByte OF((
const zlib_filefunc_def* pzlib_filefunc_def,
voidpf filestream,
int *pi));
local int ziplocal_getByte(pzlib_filefunc_def,filestream,pi)
const zlib_filefunc_def* pzlib_filefunc_def;
voidpf filestream;
int *pi;
local int ziplocal_getByte(const zlib_filefunc_def *pzlib_filefunc_def, voidpf filestream, int *pi)
{
unsigned char c;
int err = (int)ZREAD(*pzlib_filefunc_def,filestream,&c,1);
@ -362,22 +333,11 @@ local int ziplocal_getByte(pzlib_filefunc_def,filestream,pi)
/* ===========================================================================
Reads a long in LSB order from the given gz_stream. Sets
*/
local int ziplocal_getShort OF((
const zlib_filefunc_def* pzlib_filefunc_def,
voidpf filestream,
uLong *pX));
local int ziplocal_getShort (pzlib_filefunc_def,filestream,pX)
const zlib_filefunc_def* pzlib_filefunc_def;
voidpf filestream;
uLong *pX;
local int ziplocal_getShort (const zlib_filefunc_def *pzlib_filefunc_def, voidpf filestream, uLong *pX)
{
uLong x ;
int i;
int err;
err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
x = (uLong)i;
int err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
uLong x = (uLong)i;
if (err==ZIP_OK)
err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
@ -390,22 +350,11 @@ local int ziplocal_getShort (pzlib_filefunc_def,filestream,pX)
return err;
}
local int ziplocal_getLong OF((
const zlib_filefunc_def* pzlib_filefunc_def,
voidpf filestream,
uLong *pX));
local int ziplocal_getLong (pzlib_filefunc_def,filestream,pX)
const zlib_filefunc_def* pzlib_filefunc_def;
voidpf filestream;
uLong *pX;
local int ziplocal_getLong (const zlib_filefunc_def *pzlib_filefunc_def, voidpf filestream, uLong *pX)
{
uLong x ;
int i;
int err;
err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
x = (uLong)i;
int err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
uLong x = (uLong)i;
if (err==ZIP_OK)
err = ziplocal_getByte(pzlib_filefunc_def,filestream,&i);
@ -433,13 +382,7 @@ local int ziplocal_getLong (pzlib_filefunc_def,filestream,pX)
Locate the Central directory of a zipfile (at the end, just before
the global comment)
*/
local uLong ziplocal_SearchCentralDir OF((
const zlib_filefunc_def* pzlib_filefunc_def,
voidpf filestream));
local uLong ziplocal_SearchCentralDir(pzlib_filefunc_def,filestream)
const zlib_filefunc_def* pzlib_filefunc_def;
voidpf filestream;
local uLong ziplocal_SearchCentralDir(const zlib_filefunc_def *pzlib_filefunc_def, voidpf filestream)
{
unsigned char* buf;
uLong uSizeFile;
@ -496,17 +439,12 @@ local uLong ziplocal_SearchCentralDir(pzlib_filefunc_def,filestream)
#endif /* !NO_ADDFILEINEXISTINGZIP*/
/************************************************************/
extern zipFile ZEXPORT zipOpen2 (pathname, append, globalcomment, pzlib_filefunc_def)
const char *pathname;
int append;
zipcharpc* globalcomment;
zlib_filefunc_def* pzlib_filefunc_def;
extern zipFile ZEXPORT zipOpen2 (const char *pathname, int append, zipcharpc *globalcomment, zlib_filefunc_def *pzlib_filefunc_def)
{
zip_internal ziinit;
zip_internal* zi;
int err=ZIP_OK;
if (pzlib_filefunc_def==NULL)
fill_fopen_filefunc(&ziinit.z_filefunc);
else
@ -615,7 +553,7 @@ extern zipFile ZEXPORT zipOpen2 (pathname, append, globalcomment, pzlib_filefunc
if (size_comment>0)
{
ziinit.globalcomment = ALLOC(size_comment+1);
ziinit.globalcomment = (char*)ALLOC(size_comment+1);
if (ziinit.globalcomment)
{
size_comment = ZREAD(ziinit.z_filefunc, ziinit.filestream,ziinit.globalcomment,size_comment);
@ -680,35 +618,17 @@ extern zipFile ZEXPORT zipOpen2 (pathname, append, globalcomment, pzlib_filefunc
}
}
extern zipFile ZEXPORT zipOpen (pathname, append)
const char *pathname;
int append;
extern zipFile ZEXPORT zipOpen (const char *pathname, int append)
{
return zipOpen2(pathname,append,NULL,NULL);
}
extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi,
extrafield_local, size_extrafield_local,
extrafield_global, size_extrafield_global,
comment, method, level, raw,
windowBits, memLevel, strategy,
password, crcForCrypting)
zipFile file;
const char* filename;
const zip_fileinfo* zipfi;
const void* extrafield_local;
uInt size_extrafield_local;
const void* extrafield_global;
uInt size_extrafield_global;
const char* comment;
int method;
int level;
int raw;
int windowBits;
int memLevel;
int strategy;
const char* password;
uLong crcForCrypting;
extern int ZEXPORT zipOpenNewFileInZip3 (zipFile file, const char *filename, const zip_fileinfo *zipfi,
const void *extrafield_local, uInt size_extrafield_local,
const void *extrafield_global, uInt size_extrafield_global,
const char *comment, int method, int level, int raw,
int windowBits, int memLevel, int strategy,
const char *password, uLong crcForCrypting)
{
zip_internal* zi;
uInt size_filename;
@ -896,21 +816,10 @@ extern int ZEXPORT zipOpenNewFileInZip3 (file, filename, zipfi,
return err;
}
extern int ZEXPORT zipOpenNewFileInZip2(file, filename, zipfi,
extrafield_local, size_extrafield_local,
extrafield_global, size_extrafield_global,
comment, method, level, raw)
zipFile file;
const char* filename;
const zip_fileinfo* zipfi;
const void* extrafield_local;
uInt size_extrafield_local;
const void* extrafield_global;
uInt size_extrafield_global;
const char* comment;
int method;
int level;
int raw;
extern int ZEXPORT zipOpenNewFileInZip2(zipFile file, const char *filename, const zip_fileinfo *zipfi,
const void *extrafield_local, uInt size_extrafield_local,
const void *extrafield_global, uInt size_extrafield_global,
const char *comment, int method, int level, int raw)
{
return zipOpenNewFileInZip3 (file, filename, zipfi,
extrafield_local, size_extrafield_local,
@ -920,20 +829,10 @@ extern int ZEXPORT zipOpenNewFileInZip2(file, filename, zipfi,
NULL, 0);
}
extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi,
extrafield_local, size_extrafield_local,
extrafield_global, size_extrafield_global,
comment, method, level)
zipFile file;
const char* filename;
const zip_fileinfo* zipfi;
const void* extrafield_local;
uInt size_extrafield_local;
const void* extrafield_global;
uInt size_extrafield_global;
const char* comment;
int method;
int level;
extern int ZEXPORT zipOpenNewFileInZip (zipFile file, const char *filename, const zip_fileinfo *zipfi,
const void *extrafield_local, uInt size_extrafield_local,
const void *extrafield_global, uInt size_extrafield_global,
const char *comment, int method, int level)
{
return zipOpenNewFileInZip2 (file, filename, zipfi,
extrafield_local, size_extrafield_local,
@ -941,8 +840,7 @@ extern int ZEXPORT zipOpenNewFileInZip (file, filename, zipfi,
comment, method, level, 0);
}
local int zipFlushWriteBuffer(zi)
zip_internal* zi;
local int zipFlushWriteBuffer(zip_internal *zi)
{
int err=ZIP_OK;
@ -963,10 +861,7 @@ local int zipFlushWriteBuffer(zi)
return err;
}
extern int ZEXPORT zipWriteInFileInZip (file, buf, len)
zipFile file;
const void* buf;
unsigned len;
extern int ZEXPORT zipWriteInFileInZip (zipFile file, const void *buf, unsigned len)
{
zip_internal* zi;
int err=ZIP_OK;
@ -978,9 +873,9 @@ extern int ZEXPORT zipWriteInFileInZip (file, buf, len)
if (zi->in_opened_file_inzip == 0)
return ZIP_PARAMERROR;
zi->ci.stream.next_in = (void*)buf;
zi->ci.stream.next_in = (Bytef*)buf;
zi->ci.stream.avail_in = len;
zi->ci.crc32 = crc32(zi->ci.crc32,buf,len);
zi->ci.crc32 = crc32(zi->ci.crc32,(const Bytef*)buf,len);
while ((err==ZIP_OK) && (zi->ci.stream.avail_in>0))
{
@ -1028,10 +923,7 @@ extern int ZEXPORT zipWriteInFileInZip (file, buf, len)
return err;
}
extern int ZEXPORT zipCloseFileInZipRaw (file, uncompressed_size, crc32)
zipFile file;
uLong uncompressed_size;
uLong crc32;
extern int ZEXPORT zipCloseFileInZipRaw (zipFile file, uLong uncompressed_size, uLong crc32)
{
zip_internal* zi;
uLong compressed_size;
@ -1124,15 +1016,12 @@ extern int ZEXPORT zipCloseFileInZipRaw (file, uncompressed_size, crc32)
return err;
}
extern int ZEXPORT zipCloseFileInZip (file)
zipFile file;
extern int ZEXPORT zipCloseFileInZip (zipFile file)
{
return zipCloseFileInZipRaw (file,0,0);
}
extern int ZEXPORT zipClose (file, global_comment)
zipFile file;
const char* global_comment;
extern int ZEXPORT zipClose (zipFile file, const char *global_comment)
{
zip_internal* zi;
int err = 0;

View File

@ -152,7 +152,7 @@ MemZipFile* memZipFileCreate(const char* zipName)
{
if (memZipFiles[i] == NULL)
{
memZipFiles[i] = malloc(sizeof(MemZipFile));
memZipFiles[i] = (MemZipFile*)malloc(sizeof(MemZipFile));
strcpy(memZipFiles[i]->zipName, zipName);
memZipFiles[i]->count = 0;
return memZipFiles[i];
@ -202,20 +202,16 @@ int memFileSave(const char* zipName, const char* filename, int append, void* buf
memZipFile = NULL;
}
if (memZipFile == NULL)
{
if (!memZipFile)
memZipFile = memZipFileCreate(zipName);
}
if (memZipFile == NULL || memZipFile->count == MAX_FILES_IN_ZIP)
{
return 0;
}
memFile = malloc(sizeof(MemFile));
memFile->buffer = malloc(size);
memFile = (MemFile*)malloc(sizeof(MemFile));
memFile->buffer = (char*)malloc(size);
memcpy(memFile->buffer, buffer, size);
memFile->size = size;
memFile->size = size;
strcpy(memFile->filename, filename);
memZipFile->memFiles[memZipFile->count++] = memFile;
@ -519,12 +515,11 @@ void zipCacheReadOnlyZip(const char* zipName)
filesize = ftell(file);
fill_fopen_memfunc(&cacheFilefunc, filesize);
fseek(file, 0, SEEK_SET);
cacheData = malloc(filesize);
cacheData = (char*)malloc(filesize);
if( cacheData != NULL ) {
size_t size = fread(cacheData, 1, filesize, file);
if( size == filesize ) {
if( size == filesize )
strcpy(cacheFile, zipName);
}
}
fclose(file);
}
@ -704,8 +699,8 @@ char* zipGetFileList(const char* zipName, const char* ext, int* count) {
toLower(tmp);
if (strstr(tmp, extension) != NULL) {
int entryLen = strlen(tempName) + 1;
fileArray = realloc(fileArray, totalLen + entryLen + 1);
size_t entryLen = strlen(tempName) + 1;
fileArray = (char*)realloc(fileArray, totalLen + entryLen + 1);
strcpy(fileArray + totalLen, tempName);
totalLen += entryLen;
fileArray[totalLen] = '\0'; // double null termination at end
@ -918,9 +913,9 @@ void* zipCompress(void* buffer, int size, unsigned long* retSize)
void* retBuf;
*retSize = (size * 1001) / 1000 + 12;
retBuf = malloc(*retSize);
retBuf = malloc(*retSize);
if (compress(retBuf, retSize, buffer, size) != Z_OK) {
if (compress((Bytef*)retBuf, retSize, (const Bytef*)buffer, size) != Z_OK) {
free(retBuf);
retBuf = NULL;
}
@ -932,7 +927,7 @@ void* zipUncompress(void* buffer, int size, unsigned long* retSize)
{
void* retBuf = malloc(*retSize);
if (uncompress(retBuf, retSize, buffer, size) != Z_OK) {
if (uncompress((Bytef*)retBuf, retSize, (const Bytef*)buffer, size) != Z_OK) {
free(retBuf);
retBuf = NULL;
}

View File

@ -825,7 +825,7 @@ bool retro_load_game(const struct retro_game_info *info)
if (!info)
return false;
image_buffer = malloc(FB_MAX_LINE_WIDTH*FB_MAX_LINES*sizeof(uint16_t));
image_buffer = (uint16_t*)malloc(FB_MAX_LINE_WIDTH*FB_MAX_LINES*sizeof(uint16_t));
image_buffer_base_width = 272;
image_buffer_current_width = image_buffer_base_width;
image_buffer_height = 240;
@ -904,10 +904,8 @@ bool retro_load_game(const struct retro_game_info *info)
if (auto_rewind_cas)
tapeRewindNextInsert();
langSetLanguage(properties->language);
joystickPortSetType(0, properties->joy1.typeId);
joystickPortSetType(1, properties->joy2.typeId);
joystickPortSetType(0, (JoystickPortType)properties->joy1.typeId);
joystickPortSetType(1, (JoystickPortType)properties->joy2.typeId);
#if 0
printerIoSetType(properties->ports.Lpt.type, properties->ports.Lpt.fileName);
@ -1205,12 +1203,12 @@ int frameBufferGetScanline(void)
FrameBufferData* frameBufferDataCreate(int maxWidth, int maxHeight, int defaultHorizZoom)
{
return (void*)image_buffer;
return (FrameBufferData*)image_buffer;
}
FrameBufferData* frameBufferGetActive()
FrameBufferData* frameBufferGetActive(void)
{
return (void*)image_buffer;
return (FrameBufferData*)image_buffer;
}
void frameBufferSetLineCount(FrameBuffer* frameBuffer, int val)
@ -1332,7 +1330,7 @@ bool retro_unserialize(const void *data, size_t size)
data = (char*)data + sizeof(((MemFile*)0)->filename);
sz = * (int *)data;
data = (char*)data + sizeof(int);
zipSaveFile("mem0", filename, 1, data, sz );
zipSaveFile("mem0", filename, 1, (void*)data, sz );
data = (char*)data + sz;
}
saveStateCreateForRead("mem0");