(Android) Compiles and links wswan now

This commit is contained in:
twinaphex 2012-12-30 04:04:25 +01:00
parent 76ed3bca31
commit d2a7feab9a
23 changed files with 155 additions and 155 deletions

View File

@ -94,7 +94,7 @@ else ifeq ($(core), wswan)
CORE_SOURCES := $(CORE_DIR)/gfx.cpp \
$(CORE_DIR)/main.cpp \
$(CORE_DIR)/memory.cpp \
$(CORE_DIR)/wswan-memory.cpp \
$(CORE_DIR)/v30mz.cpp \
$(CORE_DIR)/sound.cpp \
$(CORE_DIR)/tcache.cpp \

View File

@ -104,7 +104,7 @@ else ifeq ($(core), wswan)
CORE_SOURCES := $(CORE_DIR)/gfx.cpp \
$(CORE_DIR)/main.cpp \
$(CORE_DIR)/memory.cpp \
$(CORE_DIR)/wswan-memory.cpp \
$(CORE_DIR)/v30mz.cpp \
$(CORE_DIR)/sound.cpp \
$(CORE_DIR)/tcache.cpp \

View File

@ -59,8 +59,6 @@
FileStream::FileStream(const char *path, const int mode): OpenedMode(mode)
{
path_save = std::string(path);
if(mode == MODE_WRITE)
fp = fopen(path, "wb");
else
@ -70,7 +68,7 @@ FileStream::FileStream(const char *path, const int mode): OpenedMode(mode)
{
ErrnoHolder ene(errno);
throw(MDFN_Error(ene.Errno(), _("Error opening file \"%s\": %s"), path_save.c_str(), ene.StrError()));
throw(MDFN_Error(ene.Errno(), _("Error opening file %s"), ene.StrError()));
}
}
@ -139,7 +137,7 @@ void FileStream::close(void)
{
ErrnoHolder ene(errno);
throw(MDFN_Error(ene.Errno(), _("Error closing opened file \"%s\": %s"), path_save.c_str(), ene.StrError()));
throw(MDFN_Error(ene.Errno(), _("Error closing opened file %s"), ene.StrError()));
}
}
}

View File

@ -48,7 +48,6 @@ class FileStream : public Stream
private:
FILE *fp;
std::string path_save;
const int OpenedMode;
};

View File

@ -61,8 +61,6 @@
FileWrapper::FileWrapper(const char *path, const int mode, const char *purpose) : OpenedMode(mode)
{
path_save = std::string(path);
if(mode == MODE_WRITE)
fp = fopen(path, "wb");
else
@ -72,7 +70,7 @@ FileWrapper::FileWrapper(const char *path, const int mode, const char *purpose)
{
ErrnoHolder ene(errno);
throw(MDFN_Error(ene.Errno(), _("Error opening file \"%s\": %s"), path_save.c_str(), ene.StrError()));
throw(MDFN_Error(ene.Errno(), _("Error opening file %s"), ene.StrError()));
}
}
@ -93,7 +91,7 @@ void FileWrapper::close(void)
{
ErrnoHolder ene(errno);
throw(MDFN_Error(ene.Errno(), _("Error closing opened file \"%s\": %s"), path_save.c_str(), ene.StrError()));
throw(MDFN_Error(ene.Errno(), _("Error closing opened file %s"), ene.StrError()));
}
}
}

View File

@ -51,7 +51,6 @@ class FileWrapper
FileWrapper(const FileWrapper &); // Copy constructor
FILE *fp;
std::string path_save;
const int OpenedMode;
};

View File

@ -26,8 +26,10 @@
#define MDFN_FILETYPE_PLAIN 0
bool MDFNFILE::ApplyIPS(FILE *ips)
bool MDFNFILE::ApplyIPS(void *unused)
{
(void)unused;
return 1;
}
@ -73,12 +75,11 @@ MDFNFILE::MDFNFILE()
location = 0;
}
MDFNFILE::MDFNFILE(const char *path, const FileExtensionSpecStruct *known_ext, const char *purpose)
MDFNFILE::MDFNFILE(const char *path, const void *known_ext, const char *purpose)
{
if(!Open(path, known_ext, purpose, false))
{
throw(MDFN_Error(0, "TODO ERROR"));
}
(void)known_ext;
if(!Open(path, known_ext, purpose, false))
throw(MDFN_Error(0, "TODO ERROR"));
}
@ -88,9 +89,10 @@ MDFNFILE::~MDFNFILE()
}
bool MDFNFILE::Open(const char *path, const FileExtensionSpecStruct *known_ext, const char *purpose, const bool suppress_notfound_pe)
bool MDFNFILE::Open(const char *path, const void *known_ext, const char *purpose, const bool suppress_notfound_pe)
{
FILE *fp;
(void)known_ext;
if(!(fp = fopen(path, "rb")))
{

View File

@ -12,17 +12,17 @@ class MDFNFILE
MDFNFILE();
// WIP constructors:
MDFNFILE(const char *path, const FileExtensionSpecStruct *known_ext, const char *purpose = NULL);
MDFNFILE(const char *path, const void *known_ext, const char *purpose = NULL);
~MDFNFILE();
bool Open(const char *path, const FileExtensionSpecStruct *known_ext, const char *purpose = NULL, const bool suppress_notfound_pe = FALSE);
INLINE bool Open(const std::string &path, const FileExtensionSpecStruct *known_ext, const char *purpose = NULL, const bool suppress_notfound_pe = FALSE)
bool Open(const char *path, const void *known_ext, const char *purpose = NULL, const bool suppress_notfound_pe = FALSE);
INLINE bool Open(const std::string &path, const void *known_ext, const char *purpose = NULL, const bool suppress_notfound_pe = FALSE)
{
return(Open(path.c_str(), known_ext, purpose, suppress_notfound_pe));
}
bool ApplyIPS(FILE *);
bool ApplyIPS(void*);
bool Close(void);
uint64 fread(void *ptr, size_t size, size_t nmemb);

View File

@ -24,7 +24,7 @@ void MDFN_DebugPrintReal(const char *file, const int line, const char *format, .
#define gettext_noop(format, ...) (format)
#define MDFN_DebugPrint(format, ...) MDFN_DebugPrintReal(__FILE__, __LINE__, format, ## __VA_ARGS__)
void MDFN_LoadGameCheats(FILE *override);
void MDFN_LoadGameCheats(void *override);
void MDFN_FlushGameCheats(int nosave);
#include "mednafen-driver.h"

View File

@ -191,25 +191,27 @@ static int AddCheatEntry(char *name, char *conditions, uint32 addr, uint64 val,
return(1);
}
static bool SeekToOurSection(FILE *fp) // Tentacle monster section aisle five, stale eggs and donkeys in aisle 2E.
static bool SeekToOurSection(void *fp_ptr)
{
char buf[2048];
FILE *fp = (FILE*)fp_ptr;
char buf[2048];
while(fgets(buf,2048,fp) > 0)
{
if(buf[0] == '[')
{
if(!strncmp((char *)buf + 1, md5_context::asciistr(MDFNGameInfo->MD5, 0).c_str(), 16))
return(1);
}
}
return(0);
while(fgets(buf,2048,fp) > 0)
{
if(buf[0] == '[')
{
if(!strncmp((char *)buf + 1, md5_context::asciistr(MDFNGameInfo->MD5, 0).c_str(), 16))
return(1);
}
}
return(0);
}
void MDFN_LoadGameCheats(FILE *override)
void MDFN_LoadGameCheats(void *override_ptr)
{
char linebuf[2048];
FILE *fp;
FILE *override = (FILE*)override_ptr;
unsigned int addr;
unsigned long long val;

View File

@ -3,11 +3,9 @@
#include <string>
#include "settings-common.h"
bool MDFN_LoadSettings(const char *path, const char *section = NULL, bool override = false);
bool MDFN_MergeSettings(const MDFNSetting *);
bool MDFN_MergeSettings(const std::vector<MDFNSetting> &);
bool MDFN_MergeSettings(const void*);
bool MDFN_MergeSettings(const std::vector<void> &);
bool MDFN_SaveSettings(const char *path);
void MDFN_KillSettings(void); // Free any resources acquired.

View File

@ -428,83 +428,86 @@ static int ReadStateChunk(StateMem *st, SFORMAT *sf, int size)
static int CurrentState = 0;
/* This function is called by the game driver(NES, GB, GBA) to save a state. */
int MDFNSS_StateAction(StateMem *st, int load, int data_only, std::vector <SSDescriptor> &sections)
int MDFNSS_StateAction(void *st_p, int load, int data_only, std::vector <SSDescriptor> &sections)
{
std::vector<SSDescriptor>::iterator section;
StateMem *st = (StateMem*)st_p;
std::vector<SSDescriptor>::iterator section;
if(load)
{
{
char sname[32];
for(section = sections.begin(); section != sections.end(); section++)
if(load)
{
int found = 0;
uint32 tmp_size;
uint32 total = 0;
while(smem_read(st, (uint8 *)sname, 32) == 32)
{
if(smem_read32le(st, &tmp_size) != 4)
return(0);
total += tmp_size + 32 + 4;
// Yay, we found the section
if(!strncmp(sname, section->name, 32))
{
if(!ReadStateChunk(st, section->sf, tmp_size))
{
printf("Error reading chunk: %s\n", section->name);
return(0);
char sname[32];
for(section = sections.begin(); section != sections.end(); section++)
{
int found = 0;
uint32 tmp_size;
uint32 total = 0;
while(smem_read(st, (uint8 *)sname, 32) == 32)
{
if(smem_read32le(st, &tmp_size) != 4)
return(0);
total += tmp_size + 32 + 4;
// Yay, we found the section
if(!strncmp(sname, section->name, 32))
{
if(!ReadStateChunk(st, section->sf, tmp_size))
{
printf("Error reading chunk: %s\n", section->name);
return(0);
}
found = 1;
break;
}
else
{
if(smem_seek(st, tmp_size, SEEK_CUR) < 0)
{
puts("Chunk seek failure");
return(0);
}
}
}
if(smem_seek(st, -total, SEEK_CUR) < 0)
{
puts("Reverse seek error");
return(0);
}
if(!found && !section->optional) // Not found. We are sad!
{
printf("Section missing: %.32s\n", section->name);
return(0);
}
}
}
}
else
{
for(section = sections.begin(); section != sections.end(); section++)
{
if(!WriteStateChunk(st, section->name, section->sf))
return(0);
}
found = 1;
break;
}
else
{
if(smem_seek(st, tmp_size, SEEK_CUR) < 0)
{
puts("Chunk seek failure");
return(0);
}
}
}
if(smem_seek(st, -total, SEEK_CUR) < 0)
{
puts("Reverse seek error");
return(0);
}
if(!found && !section->optional) // Not found. We are sad!
{
printf("Section missing: %.32s\n", section->name);
return(0);
}
}
}
}
else
{
for(section = sections.begin(); section != sections.end(); section++)
{
if(!WriteStateChunk(st, section->name, section->sf))
return(0);
}
}
return(1);
return(1);
}
int MDFNSS_StateAction(StateMem *st, int load, int data_only, SFORMAT *sf, const char *name, bool optional)
int MDFNSS_StateAction(void *st_p, int load, int data_only, SFORMAT *sf, const char *name, bool optional)
{
std::vector <SSDescriptor> love;
StateMem *st = (StateMem*)st_p;
std::vector <SSDescriptor> love;
love.push_back(SSDescriptor(sf, name, optional));
return(MDFNSS_StateAction(st, load, 0, love));
love.push_back(SSDescriptor(sf, name, optional));
return(MDFNSS_StateAction(st, load, 0, love));
}
int MDFNSS_SaveSM(StateMem *st, int, int, const MDFN_Surface*, const MDFN_Rect*, const MDFN_Rect*)
int MDFNSS_SaveSM(void *st_p, int, int, const void*, const void*, const void*)
{
StateMem *st = (StateMem*)st_p;
static const char *header_magic = "MDFNSVST";
uint8 header[32];
int neowidth = 0, neoheight = 0;
@ -527,17 +530,18 @@ int MDFNSS_SaveSM(StateMem *st, int, int, const MDFN_Surface*, const MDFN_Rect*,
return(1);
}
int MDFNSS_LoadSM(StateMem *st, int, int)
int MDFNSS_LoadSM(void *st_p, int, int)
{
uint8 header[32];
uint32 stateversion;
StateMem *st = (StateMem*)st_p;
uint8 header[32];
uint32 stateversion;
smem_read(st, header, 32);
smem_read(st, header, 32);
if(memcmp(header, "MEDNAFENSVESTATE", 16) && memcmp(header, "MDFNSVST", 8))
return(0);
if(memcmp(header, "MEDNAFENSVESTATE", 16) && memcmp(header, "MDFNSVST", 8))
return(0);
stateversion = MDFN_de32lsb(header + 16);
stateversion = MDFN_de32lsb(header + 16);
return(MDFNGameInfo->StateAction(st, stateversion, 0));
return(MDFNGameInfo->StateAction(st, stateversion, 0));
}

View File

@ -1,7 +1,6 @@
#ifndef _STATE_H
#define _STATE_H
#include "video.h"
#include "state-common.h"
typedef struct
@ -23,8 +22,8 @@ int32 smem_seek(StateMem *st, uint32 offset, int whence);
int smem_write32le(StateMem *st, uint32 b);
int smem_read32le(StateMem *st, uint32 *b);
int MDFNSS_SaveSM(StateMem *st, int, int, const MDFN_Surface*, const MDFN_Rect*, const MDFN_Rect*);
int MDFNSS_LoadSM(StateMem *st, int, int);
int MDFNSS_SaveSM(void *st, int, int, const void*, const void*, const void*);
int MDFNSS_LoadSM(void *st, int, int);
// Flag for a single, >= 1 byte native-endian variable
#define MDFNSTATE_RLSB 0x80000000
@ -118,7 +117,7 @@ class SSDescriptor
bool optional;
};
int MDFNSS_StateAction(StateMem *st, int load, int data_only, std::vector <SSDescriptor> &sections);
int MDFNSS_StateAction(StateMem *st, int load, int data_only, SFORMAT *sf, const char *name, bool optional = 0);
int MDFNSS_StateAction(void *st, int load, int data_only, std::vector <SSDescriptor> &sections);
int MDFNSS_StateAction(void *st, int load, int data_only, SFORMAT *sf, const char *name, bool optional = 0);
#endif

View File

@ -22,7 +22,7 @@
#include "v30mz.h"
#include "debug.h"
#include "dis/disasm.h"
#include "memory.h"
#include "wswan-memory.h"
#include "gfx.h"
#include <stdarg.h>
#include <trio/trio.h>

View File

@ -20,7 +20,7 @@
#include "wswan.h"
#include "eeprom.h"
#include "memory.h"
#include "wswan-memory.h"
#include <ctype.h>
namespace MDFN_IEN_WSWAN

View File

@ -20,7 +20,7 @@
#include "wswan.h"
#include "gfx.h"
#include "memory.h"
#include "wswan-memory.h"
#include "v30mz.h"
#include "rtc.h"
#include "../video.h"

View File

@ -31,7 +31,7 @@
#endif
#include "gfx.h"
#include "memory.h"
#include "wswan-memory.h"
#include "start.inc"
#include "sound.h"
#include "v30mz.h"

View File

@ -22,7 +22,7 @@
#include "wswan.h"
#include "sound.h"
#include "v30mz.h"
#include "memory.h"
#include "wswan-memory.h"
#include <blip/Blip_Buffer.h>

View File

@ -20,7 +20,7 @@
#include "wswan.h"
#include "gfx.h"
#include "memory.h"
#include "wswan-memory.h"
namespace MDFN_IEN_WSWAN
{

View File

@ -28,7 +28,7 @@
*/
#include "wswan.h"
#include "memory.h"
#include "wswan-memory.h"
#include <string.h>

View File

@ -20,7 +20,7 @@
#include "wswan.h"
#include "gfx.h"
#include "memory.h"
#include "wswan-memory.h"
#include "sound.h"
#include "eeprom.h"
#include "rtc.h"
@ -584,43 +584,44 @@ void WSwan_MemoryReset(void)
CommData = 0;
}
int WSwan_MemoryStateAction(StateMem *sm, int load, int data_only)
int WSwan_MemoryStateAction(void *sm_ptr, int load, int data_only)
{
SFORMAT StateRegs[] =
{
SFARRAYN(wsRAM, 65536, "RAM"),
SFARRAYN(sram_size ? wsSRAM : NULL, sram_size, "SRAM"),
SFVAR(ButtonWhich),
SFVAR(ButtonReadLatch),
SFVAR(WSButtonStatus),
SFVAR(DMASource),
SFVAR(DMADest),
SFVAR(DMALength),
SFVAR(DMAControl),
StateMem *sm = (StateMem*)sm_ptr;
SFORMAT StateRegs[] =
{
SFARRAYN(wsRAM, 65536, "RAM"),
SFARRAYN(sram_size ? wsSRAM : NULL, sram_size, "SRAM"),
SFVAR(ButtonWhich),
SFVAR(ButtonReadLatch),
SFVAR(WSButtonStatus),
SFVAR(DMASource),
SFVAR(DMADest),
SFVAR(DMALength),
SFVAR(DMAControl),
SFVAR(SoundDMASource),
SFVAR(SoundDMALength),
SFVAR(SoundDMAControl),
SFVAR(SoundDMASource),
SFVAR(SoundDMALength),
SFVAR(SoundDMAControl),
SFVAR(CommControl),
SFVAR(CommData),
SFVAR(CommControl),
SFVAR(CommData),
SFARRAY(BankSelector, 4),
SFARRAY(BankSelector, 4),
SFEND
};
SFEND
};
if(!MDFNSS_StateAction(sm, load, data_only, StateRegs, "MEMR"))
return(0);
if(!MDFNSS_StateAction(sm, load, data_only, StateRegs, "MEMR"))
return(0);
if(load)
{
for(uint32 A = 0xfe00; A <= 0xFFFF; A++)
{
WSwan_GfxWSCPaletteRAMWrite(A, wsRAM[A]);
}
}
return(1);
if(load)
{
for(uint32 A = 0xfe00; A <= 0xFFFF; A++)
{
WSwan_GfxWSCPaletteRAMWrite(A, wsRAM[A]);
}
}
return(1);
}
}

View File

@ -16,7 +16,7 @@ void WSwan_MemoryInit(bool lang, bool IsWSC, uint32 ssize, bool SkipSaveLoad);
void WSwan_MemoryKill(void);
void WSwan_CheckSoundDMA(void);
int WSwan_MemoryStateAction(StateMem *sm, int load, int data_only);
int WSwan_MemoryStateAction(void *sm_ptr, int load, int data_only);
void WSwan_MemoryReset(void);
void WSwan_writeport(uint32 IOPort, uint8 V);
uint8 WSwan_readport(uint32 number);

View File