Permalink
Browse files

(MSVC) MSVC commits

  • Loading branch information...
1 parent 9acfec0 commit c27850f0738410f23bb86b7d96f5765a857455f0 TwinAphex51224 committed Dec 27, 2011
View
105 libsnes-fceumm/libsnes.c
@@ -1,9 +1,27 @@
#include <stdio.h>
#include <stdint.h>
+#ifndef _MSC_VER
#include <stdbool.h>
+#else
+#define TRUE 1
+#define FALSE 0
+typedef unsigned char bool;
+#endif
#include <stdlib.h>
#include <string.h>
+#ifdef _MSC_VER
+#define snprintf _snprintf
+#endif
+
+#define LIBSNES_CORE 1
+
+#if defined(_MSC_VER) && defined(LIBSNES_CORE)
+#define EXPORT __declspec(dllexport)
+#else
+#define EXPORT
+#endif
+
#include "libsnes.h"
/* emulator-specific includes */
@@ -314,47 +332,47 @@ struct st_palettes palettes[] = {
}
};
-unsigned snes_library_revision_major(void)
+EXPORT unsigned snes_library_revision_major(void)
{
return 1;
}
-unsigned snes_library_revision_minor(void)
+EXPORT unsigned snes_library_revision_minor(void)
{
return 3;
}
-const char *snes_library_id(void)
+EXPORT const char *snes_library_id(void)
{
return "FCEUNext";
}
-void snes_set_video_refresh(snes_video_refresh_t cb)
+EXPORT void snes_set_video_refresh(snes_video_refresh_t cb)
{
video_cb = cb;
}
-void snes_set_audio_sample(snes_audio_sample_t cb)
+EXPORT void snes_set_audio_sample(snes_audio_sample_t cb)
{
audio_cb = cb;
}
-void snes_set_input_poll(snes_input_poll_t cb)
+EXPORT void snes_set_input_poll(snes_input_poll_t cb)
{
poll_cb = cb;
}
-void snes_set_input_state(snes_input_state_t cb)
+EXPORT void snes_set_input_state(snes_input_state_t cb)
{
input_cb = cb;
}
-void snes_set_controller_port_device(bool a, unsigned b)
+EXPORT void snes_set_controller_port_device(bool a, unsigned b)
{}
static char g_basename[1024];
-void snes_set_cartridge_basename(const char * path_)
+EXPORT void snes_set_cartridge_basename(const char * path_)
{
char path[1024], *split;
strncpy(path, path_, sizeof(path));
@@ -379,9 +397,9 @@ void snes_set_cartridge_basename(const char * path_)
/* SSNES extension.*/
static snes_environment_t environ_cb;
-void snes_set_environment(snes_environment_t cb) { environ_cb = cb; }
+EXPORT void snes_set_environment(snes_environment_t cb) { environ_cb = cb; }
-void snes_init(void)
+EXPORT void snes_init(void)
{
if (environ_cb)
{
@@ -429,14 +447,14 @@ static void fceu_init(void)
FCEUD_SoundToggle();
}
-void snes_term(void) {}
+EXPORT void snes_term(void) {}
-void snes_power(void)
+EXPORT void snes_power(void)
{
PowerNES();
}
-void snes_reset(void)
+EXPORT void snes_reset(void)
{
ResetNES();
}
@@ -476,7 +494,7 @@ static void update_input(void)
JSReturn = pad[0] | pad[1] << 8;
}
-void snes_run(void)
+EXPORT void snes_run(void)
{
unsigned i, y, x;
uint8_t *gfx;
@@ -500,7 +518,8 @@ void snes_run(void)
static unsigned serialize_size = 0;
-unsigned snes_serialize_size(void)
+
+EXPORT unsigned snes_serialize_size(void)
{
if (serialize_size == 0)
{
@@ -516,46 +535,48 @@ unsigned snes_serialize_size(void)
return serialize_size;
}
-bool snes_serialize(uint8_t *data, unsigned size)
+EXPORT bool snes_serialize(uint8_t *data, unsigned size)
{
if (size != snes_serialize_size())
- return false;
+ return FALSE;
memstream_set_buffer(data, size);
FCEUSS_Save();
- return true;
+ return TRUE;
}
-bool snes_unserialize(const uint8_t *data, unsigned size)
+EXPORT bool snes_unserialize(const uint8_t *data, unsigned size)
{
if (size != snes_serialize_size())
- return false;
+ return FALSE;
memstream_set_buffer((uint8_t*)data, size);
FCEUSS_Load();
- return true;
+ return TRUE;
}
-void snes_cheat_reset(void) {}
+EXPORT void snes_cheat_reset(void) {}
-void snes_cheat_set(unsigned a, bool b, const char* c) { }
+EXPORT void snes_cheat_set(unsigned a, bool b, const char* c) { }
-bool snes_load_cartridge_normal(const char* a, const uint8_t *rom_data, unsigned rom_size)
+EXPORT bool snes_load_cartridge_normal(const char* a, const uint8_t *rom_data, unsigned rom_size)
{
+ FILE *file;
+ char actual_path[512];
+
FCEUI_Initialize();
FCEUI_SetSoundVolume(256);
FCEUI_Sound(32050);
/* Append basename to detect certain ROM types from filename (Hack).*/
- char actual_path[512];
snprintf(actual_path, sizeof(actual_path), "FCEU_tmp_%s", g_basename);
fprintf(stderr, "[FCEU]: Using temp path: \"%s\"\n", actual_path);
- FILE *file = fopen(actual_path, "wb");
+ file = fopen(actual_path, "wb");
if (!file)
- return false;
+ return FALSE;
fwrite(rom_data, 1, rom_size, file);
fclose(file);
@@ -564,7 +585,9 @@ bool snes_load_cartridge_normal(const char* a, const uint8_t *rom_data, unsigned
#if !defined(__CELLOS_LV2__)
#if !defined(__LIBXENON__)
#if !defined(GEKKO)
+#if !defined(_MSC_VER)
unlink(actual_path);
+#endif
#endif
#endif
#endif
@@ -583,45 +606,45 @@ bool snes_load_cartridge_normal(const char* a, const uint8_t *rom_data, unsigned
environ_cb(SNES_ENVIRONMENT_SET_TIMING, &timing);
}
- return true;
+ return TRUE;
}
-bool snes_load_cartridge_bsx_slotted(
+EXPORT bool snes_load_cartridge_bsx_slotted(
const char* a, const uint8_t* b, unsigned c,
const char* d, const uint8_t* e, unsigned f
)
-{ return false; }
+{ return FALSE; }
-bool snes_load_cartridge_bsx(
+EXPORT bool snes_load_cartridge_bsx(
const char* a, const uint8_t * b, unsigned c,
const char* d, const uint8_t * e, unsigned f
)
-{ return false; }
+{ return FALSE; }
-bool snes_load_cartridge_sufami_turbo(
+EXPORT bool snes_load_cartridge_sufami_turbo(
const char* a, const uint8_t* b, unsigned c,
const char* d, const uint8_t* e, unsigned f,
const char* g, const uint8_t* h, unsigned i
)
-{ return false; }
+{ return FALSE; }
-bool snes_load_cartridge_super_game_boy(
+EXPORT bool snes_load_cartridge_super_game_boy(
const char* a, const uint8_t* b, unsigned c,
const char* d, const uint8_t* e, unsigned f
)
-{ return false; }
+{ return FALSE; }
-void snes_unload_cartridge(void)
+EXPORT void snes_unload_cartridge(void)
{
FCEUI_CloseGame();
}
-bool snes_get_region(void)
+EXPORT bool snes_get_region(void)
{
return FSettings.PAL ? SNES_REGION_PAL : SNES_REGION_NTSC;
}
-uint8_t *snes_get_memory_data(unsigned id)
+EXPORT uint8_t *snes_get_memory_data(unsigned id)
{
if (id != SNES_MEMORY_CARTRIDGE_RAM)
return NULL;
@@ -634,7 +657,7 @@ uint8_t *snes_get_memory_data(unsigned id)
return 0;
}
-unsigned snes_get_memory_size(unsigned id)
+EXPORT unsigned snes_get_memory_size(unsigned id)
{
if (id != SNES_MEMORY_CARTRIDGE_RAM)
return 0;
View
58 libsnes-fceumm/libsnes.h
@@ -85,68 +85,68 @@ struct snes_system_timing
typedef bool (*snes_environment_t)(unsigned cmd, void *data);
/* Must be called before calling snes_init().*/
-void snes_set_environment(snes_environment_t);
+EXPORT void snes_set_environment(snes_environment_t);
typedef void (*snes_video_refresh_t)(const uint16_t *data, unsigned width, unsigned height);
typedef void (*snes_audio_sample_t)(uint16_t left, uint16_t right);
typedef void (*snes_input_poll_t)(void);
typedef int16_t (*snes_input_state_t)(bool port, unsigned device, unsigned index, unsigned id);
-unsigned snes_library_revision_major(void);
-unsigned snes_library_revision_minor(void);
-const char *snes_library_id(void);
+EXPORT unsigned snes_library_revision_major(void);
+EXPORT unsigned snes_library_revision_minor(void);
+EXPORT const char *snes_library_id(void);
-void snes_set_video_refresh(snes_video_refresh_t);
-void snes_set_audio_sample(snes_audio_sample_t);
-void snes_set_input_poll(snes_input_poll_t);
-void snes_set_input_state(snes_input_state_t);
+EXPORT void snes_set_video_refresh(snes_video_refresh_t);
+EXPORT void snes_set_audio_sample(snes_audio_sample_t);
+EXPORT void snes_set_input_poll(snes_input_poll_t);
+EXPORT void snes_set_input_state(snes_input_state_t);
-void snes_set_controller_port_device(bool port, unsigned device);
-void snes_set_cartridge_basename(const char *basename);
+EXPORT void snes_set_controller_port_device(bool port, unsigned device);
+EXPORT void snes_set_cartridge_basename(const char *basename);
-void snes_init(void);
-void snes_term(void);
-void snes_power(void);
-void snes_reset(void);
-void snes_run(void);
+EXPORT void snes_init(void);
+EXPORT void snes_term(void);
+EXPORT void snes_power(void);
+EXPORT void snes_reset(void);
+EXPORT void snes_run(void);
-unsigned snes_serialize_size(void);
-bool snes_serialize(uint8_t *data, unsigned size);
-bool snes_unserialize(const uint8_t *data, unsigned size);
+EXPORT unsigned snes_serialize_size(void);
+EXPORT bool snes_serialize(uint8_t *data, unsigned size);
+EXPORT bool snes_unserialize(const uint8_t *data, unsigned size);
-void snes_cheat_reset(void);
-void snes_cheat_set(unsigned index, bool enabled, const char *code);
+EXPORT void snes_cheat_reset(void);
+EXPORT void snes_cheat_set(unsigned index, bool enabled, const char *code);
-bool snes_load_cartridge_normal(
+EXPORT bool snes_load_cartridge_normal(
const char *rom_xml, const uint8_t *rom_data, unsigned rom_size
);
-bool snes_load_cartridge_bsx_slotted(
+EXPORT bool snes_load_cartridge_bsx_slotted(
const char *rom_xml, const uint8_t *rom_data, unsigned rom_size,
const char *bsx_xml, const uint8_t *bsx_data, unsigned bsx_size
);
-bool snes_load_cartridge_bsx(
+EXPORT bool snes_load_cartridge_bsx(
const char *rom_xml, const uint8_t *rom_data, unsigned rom_size,
const char *bsx_xml, const uint8_t *bsx_data, unsigned bsx_size
);
-bool snes_load_cartridge_sufami_turbo(
+EXPORT bool snes_load_cartridge_sufami_turbo(
const char *rom_xml, const uint8_t *rom_data, unsigned rom_size,
const char *sta_xml, const uint8_t *sta_data, unsigned sta_size,
const char *stb_xml, const uint8_t *stb_data, unsigned stb_size
);
-bool snes_load_cartridge_super_game_boy(
+EXPORT bool snes_load_cartridge_super_game_boy(
const char *rom_xml, const uint8_t *rom_data, unsigned rom_size,
const char *dmg_xml, const uint8_t *dmg_data, unsigned dmg_size
);
-void snes_unload_cartridge(void);
+EXPORT void snes_unload_cartridge(void);
-bool snes_get_region(void);
-uint8_t* snes_get_memory_data(unsigned id);
-unsigned snes_get_memory_size(unsigned id);
+EXPORT bool snes_get_region(void);
+EXPORT uint8_t* snes_get_memory_data(unsigned id);
+EXPORT unsigned snes_get_memory_size(unsigned id);
#endif
View
7 libsnes-fceumm/memstream.c
@@ -1,9 +1,9 @@
-#include "memstream.h"
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
-#include <stdbool.h>
+#include "memstream.h"
static uint8_t *g_buffer = NULL;
static size_t g_size = 0;
@@ -46,10 +46,11 @@ size_t memstream_get_last_size(void)
memstream_t *memstream_open(bool writing)
{
+ memstream_t *stream;
if (!g_buffer || !g_size)
return NULL;
- memstream_t *stream = calloc(1, sizeof(*stream));
+ stream = (memstream_t*)calloc(1, sizeof(*stream));
memstream_init(stream, g_buffer, g_size, writing);
g_buffer = NULL;
g_size = 0;
View
14 libsnes-fceumm/memstream.h
@@ -1,13 +1,15 @@
#ifndef __MEMSTREAM_H
#define __MEMSTREAM_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#include <stddef.h>
#include <stdint.h>
+#ifndef _MSC_VER
#include <stdbool.h>
+#else
+#define TRUE 1
+#define FALSE 0
+typedef unsigned char bool;
+#endif
typedef struct memstream memstream_t;
@@ -25,8 +27,4 @@ int memstream_seek(memstream_t *stream, int offset, int whence);
void memstream_set_buffer(uint8_t *buffer, size_t size);
size_t memstream_get_last_size(void);
-#ifdef __cplusplus
-}
-#endif
-
#endif
View
2 src-fceumm/boards/117.c
@@ -36,11 +36,11 @@ static SFORMAT StateRegs[]=
static void Sync(void)
{
+ int i;
setprg8(0x8000,prgreg[0]);
setprg8(0xa000,prgreg[1]);
setprg8(0xc000,prgreg[2]);
setprg8(0xe000,prgreg[3]);
- int i;
for(i=0; i<8; i++)
setchr1(i<<10,chrreg[i]);
setmirror(mirror^1);
View
2 src-fceumm/boards/185.c
@@ -102,12 +102,12 @@ void Mapper185_Init(CartInfo *info)
void Mapper181_Init(CartInfo *info)
{
+ int x;
Sync=Sync181;
info->Power=MPower;
info->Close=MClose;
GameStateRestore=MRestore;
DummyCHR=(uint8*)FCEU_gmalloc(8192);
- int x;
for(x=0;x<8192;x++)
DummyCHR[x]=0xff;
SetupCartCHRMapping(0x10,DummyCHR,8192,0);
View
2 src-fceumm/boards/222.c
@@ -52,9 +52,9 @@ static void M222IRQ(void)
static void Sync(void)
{
+ int i;
setprg8(0x8000,prg_reg[0]);
setprg8(0xA000,prg_reg[1]);
- int i;
for(i=0; i<8; i++)
setchr1(i<<10,chr_reg[i]);
setmirror(mirr^1);
View
2 src-fceumm/boards/deirom.c
@@ -32,9 +32,9 @@ static SFORMAT DEI_StateRegs[]=
static void Sync(void)
{
+ int x;
setchr2(0x0000,DRegs[0]);
setchr2(0x0800,DRegs[1]);
- int x;
for(x=0;x<4;x++)
setchr1(0x1000+(x<<10),DRegs[2+x]);
setprg8(0x8000,DRegs[6]);
View
2 src-fceumm/boards/n106.c
@@ -362,10 +362,10 @@ static void DoNamcoSound(int32 *Wave, int Count)
static void Mapper19_StateRestore(int version)
{
+ int x;
SyncPRG();
FixNTAR();
FixCRR();
- int x;
for(x=0x40;x<0x80;x++)
FixCache(x,IRAM[x]);
}
View
3 src-fceumm/fceu.c
@@ -228,6 +228,7 @@ int FDSLoad(const char *name, FCEUFILE *fp);
FCEUGI *FCEUI_LoadGame(const char *name)
{
+ char *ipsfn;
FCEUFILE *fp;
ResetGameLoaded();
@@ -250,7 +251,7 @@ FCEUGI *FCEUI_LoadGame(const char *name)
GetFileBase(name);
- const char * ipsfn=FCEU_MakeFName(FCEUMKF_IPS,0,0);
+ ipsfn=FCEU_MakeFName(FCEUMKF_IPS,0,0);
fp=FCEU_fopen(name,ipsfn,"rb",0);
free(ipsfn);
View
10 src-fceumm/fds.c
@@ -739,16 +739,17 @@ static void PostSave(void)
int FDSLoad(const char *name, FCEUFILE *fp)
{
+ char *fn, *fn2;
FILE *zp;
int x;
+ FCEUFILE *tp;
FCEU_fseek(fp,0,SEEK_SET);
if(!SubLoad(fp))
return(0);
-
- const char * fn = FCEU_MakeFName(FCEUMKF_FDSROM,0,0);
+ fn = FCEU_MakeFName(FCEUMKF_FDSROM,0,0);
if(!(zp=fopen(fn,"rb")))
{
@@ -769,10 +770,7 @@ int FDSLoad(const char *name, FCEUFILE *fp)
}
fclose(zp);
-
-
- FCEUFILE *tp;
- const char *fn2 = FCEU_MakeFName(FCEUMKF_FDS,0,0);
+ fn2 = FCEU_MakeFName(FCEUMKF_FDS,0,0);
for(x=0;x<TotalSides;x++)
{
View
2 src-fceumm/file.c
@@ -21,7 +21,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifndef _MSC_VER
#include <unistd.h>
+#endif
#include "zlib.h"
#include "unzip.h"
View
2 src-fceumm/general.c
@@ -25,7 +25,9 @@
#include <sys/types.h>
#include <sys/stat.h>
+#ifndef _MSC_VER
#include <unistd.h>
+#endif
#include "types.h"
#include "fceu.h"
View
2 src-fceumm/mappers/27.c
@@ -4,8 +4,8 @@ static uint32 regchr[9];
static DECLFW(Mapper27_write)
{
+ int regnum;
A&=0xF00F;
- int regnum;
if((A>=0xB000) && (A<=0xE003)) {
regnum=((((A>>12)+1)&0x03)<<1)|((A&0x02)>>1);
if(A&1)
View
6 src-fceumm/state.c
@@ -24,7 +24,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifndef _MSC_VER
#include <unistd.h>
+#endif
#include "types.h"
#include "x6502.h"
@@ -378,7 +380,7 @@ void FCEUSS_Load(void)
uint8 header[16];
memstream_t *mem;
- mem = memstream_open(false);
+ mem = memstream_open(FALSE);
memstream_read(mem, header, 16);
@@ -409,7 +411,7 @@ void FCEUSS_Load(void)
void FCEUSS_Save(void)
{
- memstream_t *mem = memstream_open(true);
+ memstream_t *mem = memstream_open(TRUE);
uint32 totalsize;
uint8 header[16] = {0};
View
9 src-fceumm/types.h
@@ -22,7 +22,16 @@
#ifndef __FCEU_TYPES
#define __FCEU_TYPES
+#include <stdint.h>
+#ifndef _MSC_VER
#include <inttypes.h>
+#else
+typedef unsigned char bool;
+#endif
+
+#define TRUE 1
+#define FALSE 0
+
typedef int8_t int8;
typedef int16_t int16;
typedef int32_t int32;
View
2 utils/zlib/gzguts.h
@@ -26,7 +26,9 @@
# include <limits.h>
#endif
#include <fcntl.h>
+#ifndef _MSC_VER
#include <unistd.h>
+#endif
#ifdef NO_DEFLATE /* for compatibility with old definition */
# define NO_GZCOMPRESS

0 comments on commit c27850f

Please sign in to comment.