aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authoraliaspider2014-10-29 06:47:46 +0100
committeraliaspider2014-10-29 06:47:46 +0100
commit761d752569b9bad6bdb755e91ca9e345cfb2788d (patch)
tree5eaa11c172c08039757d6bee1a3641e051462d3a /source
parenta6dc7abc9b8cc3986eda5a84141da7dc9e4e8f1a (diff)
downloadsnesemu-761d752569b9bad6bdb755e91ca9e345cfb2788d.tar.gz
snesemu-761d752569b9bad6bdb755e91ca9e345cfb2788d.tar.bz2
snesemu-761d752569b9bad6bdb755e91ca9e345cfb2788d.zip
C++ cleanups. (in progress)
Diffstat (limited to 'source')
-rw-r--r--source/apu.c17
-rw-r--r--source/apu.h6
-rw-r--r--source/apumem.h2
-rw-r--r--source/c4.c4
-rw-r--r--source/c4.h4
-rw-r--r--source/c4emu.c59
-rw-r--r--source/cheats.c6
-rw-r--r--source/cheats.h25
-rw-r--r--source/cheats2.c16
-rw-r--r--source/clip.c25
-rw-r--r--source/cpu.c2
-rw-r--r--source/cpuexec.h2
-rw-r--r--source/cpuops.c2
-rw-r--r--source/display.h2
-rw-r--r--source/dma.c51
-rw-r--r--source/dma.h2
-rw-r--r--source/dsp1.c11
-rw-r--r--source/dsp1.h2
-rw-r--r--source/dsp4emu.c51
-rw-r--r--source/getset.h5
-rw-r--r--source/gfx.h7
-rw-r--r--source/globals.c10
-rw-r--r--source/memmap.c16
-rw-r--r--source/memmap.h148
-rw-r--r--source/missing.h2
-rw-r--r--source/obc1.c4
-rw-r--r--source/obc1.h2
-rw-r--r--source/port.h22
-rw-r--r--source/ppu.c6
-rw-r--r--source/ppu.h24
-rw-r--r--source/sa1.h3
-rw-r--r--source/sa1cpu.c2
-rw-r--r--source/sar.h8
-rw-r--r--source/sdd1emu.h7
-rw-r--r--source/seta.c2
-rw-r--r--source/seta.h4
-rw-r--r--source/seta018.c2
-rw-r--r--source/snaporig.c4
-rw-r--r--source/snaporig.h2
-rw-r--r--source/snapshot.c2
-rw-r--r--source/snapshot.h2
-rw-r--r--source/snes9x.h18
-rw-r--r--source/soundux.c4
-rw-r--r--source/soundux.h8
-rw-r--r--source/spc700.h2
-rw-r--r--source/spc7110.c14
-rw-r--r--source/spc7110.h2
47 files changed, 285 insertions, 336 deletions
diff --git a/source/apu.c b/source/apu.c
index ee41096..e117bd8 100644
--- a/source/apu.c
+++ b/source/apu.c
@@ -101,7 +101,7 @@
/* For note-triggered SPC dump support */
#include "snapshot.h"
-extern "C" {const char *S9xGetFilenameInc (const char *);}
+const char *S9xGetFilenameInc (const char *);
int spc_is_dumping=0;
int spc_is_dumping_temp;
@@ -133,12 +133,12 @@ void S9xDeinitAPU ()
}
}
-EXTERN_C uint8 APUROM [64];
+uint8 APUROM [64];
void S9xResetAPU ()
{
- int i;
+ int i,j;
Settings.APUEnabled = Settings.NextAPUEnabled;
@@ -186,7 +186,7 @@ void S9xResetAPU ()
APU.TimerTarget [i] = 0;
APU.Timer [i] = 0;
}
- for (int j = 0; j < 0x80; j++)
+ for (j = 0; j < 0x80; j++)
APU.DSP [j] = 0;
IAPU.TwoCycles = IAPU.OneCycle * 2;
@@ -248,8 +248,9 @@ void S9xSetAPUDSP (uint8 byte)
case APU_NON:
if (byte != APU.DSP [APU_NON])
{
+ int c;
uint8 mask = 1;
- for (int c = 0; c < 8; c++, mask <<= 1)
+ for (c = 0; c < 8; c++, mask <<= 1)
{
int type;
@@ -297,8 +298,9 @@ void S9xSetAPUDSP (uint8 byte)
case APU_KOFF:
// if (byte)
{
+ int c;
uint8 mask = 1;
- for (int c = 0; c < 8; c++, mask <<= 1)
+ for (c = 0; c < 8; c++, mask <<= 1)
{
if ((byte & mask) != 0)
{
@@ -340,8 +342,9 @@ void S9xSetAPUDSP (uint8 byte)
}
if (byte)
{
+ int c;
uint8 mask = 1;
- for (int c = 0; c < 8; c++, mask <<= 1)
+ for (c = 0; c < 8; c++, mask <<= 1)
{
if ((byte & mask) != 0)
{
diff --git a/source/apu.h b/source/apu.h
index b675dfd..7cce703 100644
--- a/source/apu.h
+++ b/source/apu.h
@@ -128,8 +128,8 @@ struct SAPU
bool8 TimerValueWritten [3];
};
-EXTERN_C struct SAPU APU;
-EXTERN_C struct SIAPU IAPU;
+struct SAPU APU;
+struct SIAPU IAPU;
extern int spc_is_dumping;
extern int spc_is_dumping_temp;
extern uint8 spc_dump_dsp[0x100];
@@ -147,7 +147,6 @@ STATIC inline void S9xAPUPackStatus()
(IAPU._Zero & 0x80) | (IAPU._Overflow << 6);
}
-START_EXTERN_C
void S9xResetAPU (void);
bool8 S9xInitAPU ();
void S9xDeinitAPU ();
@@ -164,7 +163,6 @@ void S9xPrintAPUState ();
extern uint16 S9xAPUCycles [256]; // Scaled cycle lengths
extern uint16 S9xAPUCycleLengths [256]; // Raw data.
extern void (*S9xApuOpcodes [256]) (void);
-END_EXTERN_C
#define APU_VOL_LEFT 0x00
diff --git a/source/apumem.h b/source/apumem.h
index 573b52c..4d79cf6 100644
--- a/source/apumem.h
+++ b/source/apumem.h
@@ -90,10 +90,8 @@
#ifndef _apumemory_h_
#define _apumemory_h_
-START_EXTERN_C
extern uint8 W4;
extern uint8 APUROM[64];
-END_EXTERN_C
uint8 S9xAPUGetByteZ (uint8 Address)
{
diff --git a/source/c4.c b/source/c4.c
index 8774f46..cda3e11 100644
--- a/source/c4.c
+++ b/source/c4.c
@@ -90,7 +90,7 @@
#include <stdlib.h>
#include "c4.h"
#include "memmap.h"
-extern "C" {
+
short C4WFXVal;
short C4WFYVal;
@@ -233,5 +233,5 @@ void C4LoaDMem(char *C4RAM)
READ_WORD(C4RAM+0x1f43));
}
#endif
-}//end extern C
+
diff --git a/source/c4.h b/source/c4.h
index f7957d4..4f73f13 100644
--- a/source/c4.h
+++ b/source/c4.h
@@ -91,8 +91,6 @@
#include "port.h"
-extern "C" {
-
extern int16 C4WFXVal;
extern int16 C4WFYVal;
extern int16 C4WFZVal;
@@ -118,7 +116,5 @@ void C4Op0D();
extern int16 C4CosTable[];
extern int16 C4SinTable[];
-}
-
#endif
diff --git a/source/c4emu.c b/source/c4emu.c
index f188853..0eb3237 100644
--- a/source/c4emu.c
+++ b/source/c4emu.c
@@ -127,8 +127,9 @@ static uint8 C4TestPattern [12 * 4] =
static void C4ConvOAM(void){
+ uint8 *i;
uint8 *OAMptr=Memory.C4RAM+(Memory.C4RAM[0x626]<<2);
- for(uint8 *i=Memory.C4RAM+0x1fd; i>OAMptr; i-=4){
+ for(i=Memory.C4RAM+0x1fd; i>OAMptr; i-=4){
// Clear OAM-to-be
*i=0xe0;
}
@@ -144,11 +145,12 @@ static void C4ConvOAM(void){
OAMptr2=Memory.C4RAM+0x200+(Memory.C4RAM[0x626]>>2);
if(Memory.C4RAM[0x0620]!=0){
+ int prio,i;
SprCount=128-Memory.C4RAM[0x626];
uint8 offset=(Memory.C4RAM[0x626]&3)*2;
- for(int prio=0x30; prio>=0; prio-=0x10){
+ for(prio=0x30; prio>=0; prio-=0x10){
uint8 *srcptr=Memory.C4RAM+0x220;
- for(int i=Memory.C4RAM[0x0620]; i>0 && SprCount>0; i--, srcptr+=16){
+ for(i=Memory.C4RAM[0x0620]; i>0 && SprCount>0; i--, srcptr+=16){
if((srcptr[4]&0x30)!=prio) continue;
SprX=READ_WORD(srcptr)-globalX;
SprY=READ_WORD(srcptr+2)-globalY;
@@ -157,8 +159,9 @@ static void C4ConvOAM(void){
uint8 *sprptr=S9xGetMemPointer(READ_3WORD(srcptr+7));
if(*sprptr!=0){
+ int SprCnt;
int16 X, Y;
- for(int SprCnt=*sprptr++; SprCnt>0 && SprCount>0; SprCnt--, sprptr+=4){
+ for(SprCnt=*sprptr++; SprCnt>0 && SprCount>0; SprCnt--, sprptr+=4){
X=(int8)sprptr[1];
if(SprAttr&0x40){ // flip X
X=-X-((sprptr[0]&0x20)?16:8);
@@ -241,10 +244,10 @@ static void C4DoScaleRotate(int row_padding){
C=(int16)(-XScale);
D=0;
} else {
- A=(int16)SAR(C4CosTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*XScale, 15);
- B=(int16)(-SAR(C4SinTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*YScale, 15));
- C=(int16)SAR(C4SinTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*XScale, 15);
- D=(int16)SAR(C4CosTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*YScale, 15);
+ A=(int16)SAR16(C4CosTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*XScale, 15);
+ B=(int16)(-SAR16(C4SinTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*YScale, 15));
+ C=(int16)SAR16(C4SinTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*XScale, 15);
+ D=(int16)SAR16(C4CosTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*YScale, 15);
}
// Calculate Pixel Resolution
@@ -272,11 +275,12 @@ static void C4DoScaleRotate(int row_padding){
uint32 X, Y;
uint8 byte;
int outidx=0;
+ int x,y;
uint8 bit=0x80;
- for(int y=0; y<h; y++){
+ for(y=0; y<h; y++){
X=LineX;
Y=LineY;
- for(int x=0; x<w; x++){
+ for(x=0; x<w; x++){
if((X>>12)>=w || (Y>>12)>=h){
byte=0;
} else {
@@ -342,7 +346,8 @@ static void C4DrawLine(int32 X1, int32 Y1, int16 Z1,
Y2=(int16)C4WFYVal;
// render line
- for(int i=C4WFDist?C4WFDist:1; i>0; i--)
+ int i;
+ for(i=C4WFDist?C4WFDist:1; i>0; i--)
{ //.loop
if(X1>0xff && Y1>0xff && X1<0x6000 && Y1<0x6000)
{
@@ -367,7 +372,8 @@ static void C4DrawWireFrame(void)
int16 X2, Y2, Z2;
uint8 Color;
- for(int i=Memory.C4RAM[0x0295]; i>0; i--, line+=5){
+ int i;
+ for(i=Memory.C4RAM[0x0295]; i>0; i--, line+=5){
if(line[0]==0xff && line[1]==0xff){
uint8 *tmp=line-5;
while(line[2]==0xff && line[3]==0xff) tmp-=5;
@@ -394,10 +400,12 @@ static void C4TransformLines(void){
C4WFDist=Memory.C4RAM[0x1f89];
C4WFScale=Memory.C4RAM[0x1f8c];
+ int i;
+
// transform vertices
uint8 *ptr=Memory.C4RAM;
{
- for(int i=READ_WORD(Memory.C4RAM+0x1f80); i>0; i--, ptr+=0x10)
+ for(i=READ_WORD(Memory.C4RAM+0x1f80); i>0; i--, ptr+=0x10)
{
C4WFXVal=READ_WORD(ptr+1);
C4WFYVal=READ_WORD(ptr+5);
@@ -416,10 +424,11 @@ static void C4TransformLines(void){
WRITE_WORD(Memory.C4RAM+0x602+8, 0x60);
WRITE_WORD(Memory.C4RAM+0x605+8, 0x40);
- ptr=Memory.C4RAM+0xb02;
+ ptr=Memory.C4RAM+0xb02;
uint8 *ptr2=Memory.C4RAM;
{
- for(int i=READ_WORD(Memory.C4RAM+0xb00); i>0; i--, ptr+=2, ptr2+=8)
+ int i;
+ for(i=READ_WORD(Memory.C4RAM+0xb00); i>0; i--, ptr+=2, ptr2+=8)
{
C4WFXVal=READ_WORD(Memory.C4RAM+(ptr[0]<<4)+1);
C4WFYVal=READ_WORD(Memory.C4RAM+(ptr[0]<<4)+5);
@@ -446,10 +455,11 @@ static void C4BitPlaneWave(){
uint16 mask1=0xc0c0;
uint16 mask2=0x3f3f;
- for(int j=0; j<0x10; j++){
+ int i,j;
+ for(j=0; j<0x10; j++){
do {
int16 height=-((int8)Memory.C4RAM[waveptr+0xb00])-16;
- for(int i=0; i<40; i++){
+ for(i=0; i<40; i++){
uint16 tmp=READ_WORD(dst+bmpdata[i]) & mask2;
if(height>=0){
if(height<8){
@@ -468,8 +478,9 @@ static void C4BitPlaneWave(){
dst+=16;
do {
+ int i;
int16 height=-((int8)Memory.C4RAM[waveptr+0xb00])-16;
- for(int i=0; i<40; i++){
+ for(i=0; i<40; i++){
uint16 tmp=READ_WORD(dst+bmpdata[i]) & mask2;
if(height>=0){
if(height<8){
@@ -509,10 +520,10 @@ static void C4SprDisintegrate()
src=Memory.C4RAM+0x600;
memset(Memory.C4RAM, 0, width*height/2);
-
- for(uint32 y=StartY, i=0; i<height; i++, y+=scaleY)
+ uint32 x,y,i,j;
+ for( y=StartY, i=0; i<height; i++, y+=scaleY)
{
- for(uint32 x=StartX, j=0; j<width; j++, x+=scaleX)
+ for(x=StartX, j=0; j<width; j++, x+=scaleX)
{
if((x>>8)<width && (y>>8)<height && (y>>8)*width+(x>>8)<0x2000)
{
@@ -648,7 +659,8 @@ void S9xSetC4 (uint8 byte, uint16 Address)
int32 tan2=(C4CosTable[angle2]!=0)?((((int32)C4SinTable[angle2])<<16)/C4CosTable[angle2]):0x80000000;
int16 y = READ_WORD(Memory.C4RAM+0x1f83) - READ_WORD(Memory.C4RAM+0x1f89);
int16 left, right;
- for(int j=0; j<225; j++)
+ int j;
+ for(j=0; j<225; j++)
{
if(y>=0)
{
@@ -713,8 +725,9 @@ void S9xSetC4 (uint8 byte, uint16 Address)
case 0x40: // Sum
{
+ int i;
uint16 sum=0;
- for(int i=0; i<0x800; sum+=Memory.C4RAM[i++]);
+ for(i=0; i<0x800; sum+=Memory.C4RAM[i++]);
WRITE_WORD(Memory.C4RAM+0x1f80, sum);
}
break;
diff --git a/source/cheats.c b/source/cheats.c
index 9c4a8f2..060d2ba 100644
--- a/source/cheats.c
+++ b/source/cheats.c
@@ -95,7 +95,8 @@
static bool8 S9xAllHex (const char *code, int len)
{
- for (int i = 0; i < len; i++)
+ int i;
+ for (i = 0; i < len; i++)
if ((code [i] < '0' || code [i] > '9') &&
(code [i] < 'a' || code [i] > 'f') &&
(code [i] < 'A' || code [i] > 'F'))
@@ -158,7 +159,8 @@ const char *S9xGameGenieToRaw (const char *code, uint32 *address, uint8 *byte)
static char *real_hex = "0123456789ABCDEF";
static char *genie_hex = "DF4709156BC8A23E";
- for (int i = 2; i < 10; i++)
+ int i;
+ for (i = 2; i < 10; i++)
{
if (islower (new_code [i]))
new_code [i] = toupper (new_code [i]);
diff --git a/source/cheats.h b/source/cheats.h
index 2b2687b..c3b38d5 100644
--- a/source/cheats.h
+++ b/source/cheats.h
@@ -89,14 +89,10 @@
#ifndef _CHEATS_H_
#define _CHEATS_H_
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#define MAX_SFCCHEAT_NAME 48
#define MAX_CHEATS_T 800
-struct SCheat
+typedef struct
{
uint32 address;
uint8 byte;
@@ -104,12 +100,12 @@ struct SCheat
bool8 enabled;
bool8 saved;
char name[MAX_SFCCHEAT_NAME];
-};
+}SCheat;
-struct SCheatData
+typedef struct
{
- struct SCheat c [MAX_CHEATS_T];
+ SCheat c [MAX_CHEATS_T];
uint32 num_cheats;
uint8 CWRAM [0x20000];
uint8 CSRAM [0x10000];
@@ -120,7 +116,7 @@ struct SCheatData
uint32 WRAM_BITS [0x20000 >> 3];
uint32 SRAM_BITS [0x10000 >> 3];
uint32 IRAM_BITS [0x2000 >> 3];
-};
+}SCheatData;
typedef enum
{
@@ -153,16 +149,13 @@ void S9xDeleteCheat (uint32 which1);
bool8 S9xLoadCheatFile (const char *filename);
bool8 S9xSaveCheatFile (const char *filename);
-void S9xStartCheatSearch (struct SCheatData *cheats);
-void S9xSearchForChange (struct SCheatData *cheats, S9xCheatComparisonType cmp,
+void S9xStartCheatSearch (SCheatData *cheats);
+void S9xSearchForChange (SCheatData *cheats, S9xCheatComparisonType cmp,
S9xCheatDataSize size, bool8 is_signed, bool8 update);
-void S9xSearchForValue (struct SCheatData *cheats, S9xCheatComparisonType cmp,
+void S9xSearchForValue (SCheatData *cheats, S9xCheatComparisonType cmp,
S9xCheatDataSize size, uint32 value,
bool8 is_signed, bool8 update);
-void S9xOutputCheatSearchResults (struct SCheatData *cheats);
+void S9xOutputCheatSearchResults (SCheatData *cheats);
-#ifdef __cplusplus
-}
-#endif
#endif
diff --git a/source/cheats2.c b/source/cheats2.c
index 59855b9..d45e229 100644
--- a/source/cheats2.c
+++ b/source/cheats2.c
@@ -98,7 +98,7 @@ extern SCheatData Cheat;
void S9xInitCheatData ()
{
Cheat.RAM = Memory.RAM;
- Cheat.SRAM = ::SRAM;
+ Cheat.SRAM = SRAM;
Cheat.FillRAM = Memory.FillRAM;
}
@@ -168,7 +168,7 @@ void S9xRemoveCheat (uint32 which1)
int block = (address >> MEMMAP_SHIFT) & MEMMAP_MASK;
uint8 *ptr = Memory.Map [block];
- if (ptr >= (uint8 *) CMemory::MAP_LAST)
+ if (ptr >= (uint8 *) MAP_LAST)
*(ptr + (address & 0xffff)) = Cheat.c [which1].saved_byte;
else
S9xSetByte (Cheat.c [which1].saved_byte, address);
@@ -187,7 +187,7 @@ void S9xApplyCheat (uint32 which1)
int block = (address >> MEMMAP_SHIFT) & MEMMAP_MASK;
uint8 *ptr = Memory.Map [block];
- if (ptr >= (uint8 *) CMemory::MAP_LAST)
+ if (ptr >= (uint8 *) MAP_LAST)
*(ptr + (address & 0xffff)) = Cheat.c [which1].byte;
else
S9xSetByte (Cheat.c [which1].byte, address);
@@ -196,9 +196,10 @@ void S9xApplyCheat (uint32 which1)
void S9xApplyCheats ()
{
+ uint32 i;
if (Settings.ApplyCheats)
{
- for (uint32 i = 0; i < Cheat.num_cheats; i++)
+ for (i = 0; i < Cheat.num_cheats; i++)
if (Cheat.c [i].enabled)
S9xApplyCheat (i);
}
@@ -206,9 +207,10 @@ void S9xApplyCheats ()
void S9xRemoveCheats ()
{
- for (uint32 i = 0; i < Cheat.num_cheats; i++)
- if (Cheat.c [i].enabled)
- S9xRemoveCheat (i);
+ uint32 i;
+ for (i = 0; i < Cheat.num_cheats; i++)
+ if (Cheat.c [i].enabled)
+ S9xRemoveCheat (i);
}
bool8 S9xLoadCheatFile (const char *filename)
diff --git a/source/clip.c b/source/clip.c
index 7147abf..c2af922 100644
--- a/source/clip.c
+++ b/source/clip.c
@@ -136,13 +136,14 @@ static int BandCompare (const void *d1, const void *d2)
void ComputeClipWindows ()
{
struct ClipData *pClip = &IPPU.Clip [0];
+ int c,w,i;
// Loop around the main screen then the sub-screen.
- for (int c = 0; c < 2; c++, pClip++)
+ for (c = 0; c < 2; c++, pClip++)
{
// Loop around the colour window then a clip window for each of the
// background layers.
- for (int w = 5; w >= 0; w--)
+ for (w = 5; w >= 0; w--)
{
pClip->Count[w] = 0;
@@ -154,7 +155,7 @@ void ComputeClipWindows ()
{
// The whole of the main screen is switched off,
// completely clip everything.
- for (int i = 0; i < 6; i++)
+ for (i = 0; i < 6; i++)
{
IPPU.Clip [c].Count [i] = 1;
IPPU.Clip [c].Left [0][i] = 1;
@@ -172,7 +173,8 @@ void ComputeClipWindows ()
{
// The sub-screen is switched off, completely
// clip everything.
- for (int i = 0; i < 6; i++)
+ int i;
+ for (i = 0; i < 6; i++)
{
IPPU.Clip [1].Count [i] = 1;
IPPU.Clip [1].Left [0][i] = 1;
@@ -608,7 +610,8 @@ void ComputeClipWindows ()
}
else
{
- for (int j = 0; j < B; j++)
+ int j;
+ for (j = 0; j < B; j++)
{
pClip->Left[j][w] = Bands[j].Left;
pClip->Right[j][w] = Bands[j].Right;
@@ -662,7 +665,8 @@ void ComputeClipWindows ()
}
else
{
- for (uint32 j = 0; j < Window1Enabled; j++)
+ uint32 j;
+ for (j = 0; j < Window1Enabled; j++)
{
pClip->Left [j][w] = Win1[j].Left;
pClip->Right [j][w] = Win1[j].Right;
@@ -711,7 +715,8 @@ void ComputeClipWindows ()
}
else
{
- for (uint32 j = 0; j < Window2Enabled; j++)
+ uint32 j;
+ for (j = 0; j < Window2Enabled; j++)
{
pClip->Left [j][w] = Win2[j].Left;
pClip->Right [j][w] = Win2[j].Right;
@@ -728,8 +733,9 @@ void ComputeClipWindows ()
// the same as the colour window.
if (pClip->Count [w] == 0)
{
+ uint32 i;
pClip->Count [w] = pClip->Count [5];
- for (uint32 i = 0; i < pClip->Count [w]; i++)
+ for (i = 0; i < pClip->Count [w]; i++)
{
pClip->Left [i][w] = pClip->Left [i][5];
pClip->Right [i][w] = pClip->Right [i][5];
@@ -739,7 +745,8 @@ void ComputeClipWindows ()
{
// Intersect the colour window with the bg's
// own clip window.
- for (uint32 i = 0; i < pClip->Count [w]; i++)
+ uint32 i;
+ for (i = 0; i < pClip->Count [w]; i++)
{
uint32 j;
for (j = 0; j < pClip->Count [5]; j++)
diff --git a/source/cpu.c b/source/cpu.c
index 2f9b4ae..51adb61 100644
--- a/source/cpu.c
+++ b/source/cpu.c
@@ -165,11 +165,9 @@ void S9xResetCPU ()
}
#ifdef ZSNES_FX
-START_EXTERN_C
void S9xResetSuperFX ();
bool8 WinterGold = 0;
extern uint8 *C4Ram;
-END_EXTERN_C
#endif
void S9xReset (void)
diff --git a/source/cpuexec.h b/source/cpuexec.h
index dab9099..67ac5a9 100644
--- a/source/cpuexec.h
+++ b/source/cpuexec.h
@@ -126,7 +126,6 @@ struct SICPU
uint32 FrameAdvanceCount;
};
-START_EXTERN_C
void S9xMainLoop (void);
void S9xReset (void);
void S9xSoftReset (void);
@@ -142,7 +141,6 @@ extern struct SOpcodes S9xOpcodesM0X1 [256];
extern struct SOpcodes S9xOpcodesM0X0 [256];
extern struct SICPU ICPU;
-END_EXTERN_C
STATIC inline void S9xUnpackStatus()
{
diff --git a/source/cpuops.c b/source/cpuops.c
index 9dc7f0c..445c439 100644
--- a/source/cpuops.c
+++ b/source/cpuops.c
@@ -105,7 +105,7 @@
#include "cpumacro.h"
#include "apu.h"
-EXTERN_C long OpAddress;
+long OpAddress;
// For use with the opcodes whose functions here examine the OpAddress.
static void OpAddressPassthrough (long Addr)
diff --git a/source/display.h b/source/display.h
index fb01934..b044746 100644
--- a/source/display.h
+++ b/source/display.h
@@ -90,7 +90,6 @@
#ifndef _DISPLAY_H_
#define _DISPLAY_H_
-START_EXTERN_C
// Routines the port specific code has to implement
void S9xTextMode ();
void S9xGraphicsMode ();
@@ -130,7 +129,6 @@ const char *S9xGetROMDirectory ();
const char *S9xGetSRAMFilename ();
const char *S9xGetFilename (const char *extension);
const char *S9xGetFilenameInc (const char *);
-END_EXTERN_C
#endif
diff --git a/source/dma.c b/source/dma.c
index 71f8e03..517bf4c 100644
--- a/source/dma.c
+++ b/source/dma.c
@@ -257,8 +257,9 @@ void S9xDoDMA (uint8 Channel)
uint8 *p = Memory.SDD1LoggedData;
bool8 found = FALSE;
uint8 SDD1Bank = Memory.FillRAM [0x4804 + ((d->ABank - 0xc0) >> 4)] | 0xf0;
-
- for (uint32 i = 0; i < Memory.SDD1LoggedDataCount; i++, p += 8)
+
+ uint32 i;
+ for (i = 0; i < Memory.SDD1LoggedDataCount; i++, p += 8)
{
if (*p == d->ABank ||
*(p + 1) == (d->AAddress >> 8) &&
@@ -303,7 +304,7 @@ void S9xDoDMA (uint8 Channel)
}
else
{
- spc7110_dma=new uint8[d->TransferBytes];
+ spc7110_dma=(uint8*)malloc(d->TransferBytes);
j=DECOMP_BUFFER_SIZE-i;
memcpy(spc7110_dma, &s7r.bank50[i], j);
memcpy(&spc7110_dma[j],s7r.bank50,d->TransferBytes-j);
@@ -332,7 +333,7 @@ void S9xDoDMA (uint8 Channel)
int char_line_bytes = bytes_per_char * num_chars;
uint32 addr = (d->AAddress / char_line_bytes) * char_line_bytes;
uint8 *base = GetBasePointer ((d->ABank << 16) + addr) + addr;
- uint8 *buffer = &Memory.ROM [CMemory::MAX_ROM_SIZE - 0x10000];
+ uint8 *buffer = &Memory.ROM [MAX_ROM_SIZE - 0x10000];
uint8 *p = buffer;
uint32 inc = char_line_bytes - (d->AAddress % char_line_bytes);
uint32 char_count = inc / bytes_per_char;
@@ -350,14 +351,16 @@ void S9xDoDMA (uint8 Channel)
for (i = 0; i < count; i += inc, base += char_line_bytes,
inc = char_line_bytes, char_count = num_chars)
{
+ uint32 j;
uint8 *line = base + (num_chars - char_count) * 2;
- for (uint32 j = 0; j < char_count && p - buffer < count;
+ for (j = 0; j < char_count && p - buffer < count;
j++, line += 2)
{
+ int b,l;
uint8 *q = line;
- for (int l = 0; l < 8; l++, q += bytes_per_line)
+ for (l = 0; l < 8; l++, q += bytes_per_line)
{
- for (int b = 0; b < 2; b++)
+ for (b = 0; b < 2; b++)
{
uint8 r = *(q + b);
*(p + 0) = (*(p + 0) << 1) | ((r >> 0) & 1);
@@ -378,14 +381,16 @@ void S9xDoDMA (uint8 Channel)
for (i = 0; i < count; i += inc, base += char_line_bytes,
inc = char_line_bytes, char_count = num_chars)
{
- uint8 *line = base + (num_chars - char_count) * 4;
- for (uint32 j = 0; j < char_count && p - buffer < count;
+ uint32 j;
+ uint8 *line = base + (num_chars - char_count) * 4;
+ for (j = 0; j < char_count && p - buffer < count;
j++, line += 4)
{
uint8 *q = line;
- for (int l = 0; l < 8; l++, q += bytes_per_line)
+ int b,l;
+ for (l = 0; l < 8; l++, q += bytes_per_line)
{
- for (int b = 0; b < 4; b++)
+ for (b = 0; b < 4; b++)
{
uint8 r = *(q + b);
*(p + 0) = (*(p + 0) << 1) | ((r >> 0) & 1);
@@ -408,13 +413,15 @@ void S9xDoDMA (uint8 Channel)
inc = char_line_bytes, char_count = num_chars)
{
uint8 *line = base + (num_chars - char_count) * 8;
- for (uint32 j = 0; j < char_count && p - buffer < count;
+ uint32 j;
+ for (j = 0; j < char_count && p - buffer < count;
j++, line += 8)
{
uint8 *q = line;
- for (int l = 0; l < 8; l++, q += bytes_per_line)
+ int b,l;
+ for (l = 0; l < 8; l++, q += bytes_per_line)
{
- for (int b = 0; b < 8; b++)
+ for (b = 0; b < 8; b++)
{
uint8 r = *(q + b);
*(p + 0) = (*(p + 0) << 1) | ((r >> 0) & 1);
@@ -460,7 +467,7 @@ void S9xDoDMA (uint8 Channel)
if (in_sa1_dma)
{
- base = &Memory.ROM [CMemory::MAX_ROM_SIZE - 0x10000];
+ base = &Memory.ROM [MAX_ROM_SIZE - 0x10000];
p = 0;
}
@@ -815,7 +822,7 @@ void S9xDoDMA (uint8 Channel)
if(Settings.SPC7110&&spc7110_dma)
{
if(spc7110_dma&&s7_wrap)
- delete [] spc7110_dma;
+ free(spc7110_dma);
}
update_address:
@@ -850,7 +857,8 @@ void S9xStartHDMA ()
IPPU.HDMAStarted = TRUE;
- for (uint8 i = 0; i < 8; i++)
+ uint8 i;
+ for (i = 0; i < 8; i++)
{
if (IPPU.HDMA & (1 << i))
{
@@ -870,13 +878,14 @@ void S9xStartHDMA ()
uint8 S9xDoHDMA (uint8 byte)
{
- struct SDMA *p = &DMA [0];
+ SDMA *p = &DMA [0];
int d = 0;
CPU.InDMA = TRUE;
CPU.Cycles+=ONE_CYCLE*3;
- for (uint8 mask = 1; mask; mask <<= 1, p++, d++)
+ uint8 mask;
+ for (mask = 1; mask; mask <<= 1, p++, d++)
{
if (byte & mask)
{
@@ -1076,7 +1085,7 @@ uint8 S9xDoHDMA (uint8 byte)
void S9xResetDMA ()
{
- int d;
+ int c,d;
for (d = 0; d < 8; d++)
{
DMA [d].TransferDirection = FALSE;
@@ -1090,7 +1099,7 @@ void S9xResetDMA ()
DMA [d].BAddress = 0xff;
DMA [d].TransferBytes = 0xffff;
}
- for (int c = 0x4300; c < 0x4380; c += 0x10)
+ for (c = 0x4300; c < 0x4380; c += 0x10)
{
for (d = c; d < c + 12; d++)
Memory.FillRAM [d] = 0xff;
diff --git a/source/dma.h b/source/dma.h
index a95f20e..8628774 100644
--- a/source/dma.h
+++ b/source/dma.h
@@ -90,12 +90,10 @@
#ifndef _DMA_H_
#define _DMA_H_
-START_EXTERN_C
void S9xResetDMA (void);
uint8 S9xDoHDMA (uint8);
void S9xStartHDMA ();
void S9xDoDMA (uint8);
-END_EXTERN_C
#endif
diff --git a/source/dsp1.c b/source/dsp1.c
index 4e32a54..d54b48f 100644
--- a/source/dsp1.c
+++ b/source/dsp1.c
@@ -1179,7 +1179,8 @@ uint8 DSP3GetByte(uint16 address)
#endif
-struct SDSP4 {
+typedef struct
+{
bool8 waiting4command;
bool8 half_command;
uint16 command;
@@ -1189,11 +1190,11 @@ struct SDSP4 {
uint32 out_index;
uint8 parameters [512];
uint8 output [512];
-};
+}SDSP4;
SDSP4 DSP4;
-#include "dsp4emu.cpp"
+#include "dsp4emu.c"
bool DSP4_init=FALSE;
@@ -1280,7 +1281,7 @@ void DSP4SetByte(uint8 byte, uint16 address)
multiplier = DSP4_READ_WORD(0);
multiplicand = DSP4_READ_WORD(2);
- DSP4_Multiply(multiplicand,multiplier,product);
+ product = DSP4_Multiply(multiplicand,multiplier);
DSP4.out_count = 4;
DSP4_WRITE_WORD(0,product);
@@ -1298,7 +1299,7 @@ void DSP4SetByte(uint8 byte, uint16 address)
c = DSP4_READ_WORD(2);
d = DSP4_READ_WORD(0);
- DSP4_UnknownOP11(a,b,c,d,m);
+ m = DSP4_UnknownOP11(a,b,c,d);
DSP4.out_count = 2;
DSP4_WRITE_WORD(0,m);
diff --git a/source/dsp1.h b/source/dsp1.h
index 269f4ad..05a706b 100644
--- a/source/dsp1.h
+++ b/source/dsp1.h
@@ -118,12 +118,10 @@ struct SDSP1 {
uint8 output [512];
};
-START_EXTERN_C
void S9xResetDSP1 ();
uint8 S9xGetDSP (uint16 Address);
void S9xSetDSP (uint8 Byte, uint16 Address);
extern struct SDSP1 DSP1;
-END_EXTERN_C
//extern struct SDSP1 DSP1;
diff --git a/source/dsp4emu.c b/source/dsp4emu.c
index b36cadb..3e85ee3 100644
--- a/source/dsp4emu.c
+++ b/source/dsp4emu.c
@@ -88,6 +88,7 @@
*******************************************************************************/
#include "dsp4.h"
+#include "memmap.h"
#define DSP4_READ_WORD(x) \
READ_WORD(DSP4.parameters+x)
@@ -102,14 +103,14 @@
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
-void DSP4_Multiply(short Multiplicand, short Multiplier, int &Product)
+int DSP4_Multiply(short Multiplicand, short Multiplier)
{
- Product = Multiplicand * Multiplier;
+ return Multiplicand * Multiplier;
}
-void DSP4_UnknownOP11(short A, short B, short C, short D, short &M)
+short DSP4_UnknownOP11(short A, short B, short C, short D)
{
- M = ((A * 0x0155 >> 2) & 0xf000) | ((B * 0x0155 >> 6) & 0x0f00) |
+ return ((A * 0x0155 >> 2) & 0xf000) | ((B * 0x0155 >> 6) & 0x0f00) |
((C * 0x0155 >> 10) & 0x00f0) | ((D * 0x0155 >> 14) & 0x000f);
}
@@ -204,17 +205,23 @@ void DSP4_Op01()
DSP4.in_index = 2;
DSP4.in_count = 8;
- DSP4_WAIT(2) resume2:
+ DSP4_WAIT(2)
- ////////////////////////////////////////////////////
+ ////////////////////////////////////////////////////
// process one iteration of projection
// inspect inputs
- int16 plane = DSP4_READ_WORD(0);
+ int16 plane;
+
int16 index, lcv;
- int16 py_dy=0, px_dx=0;
+ int16 py_dy, px_dx;
int16 y_out, x_out;
+ resume2:
+ plane = DSP4_READ_WORD(0);
+ py_dy=0;
+ px_dx=0;
+
// ignore invalid data
if((uint16) plane == 0x8001) continue;
@@ -406,7 +413,7 @@ void DSP4_Op07()
DSP4.in_index = 2;
DSP4.in_count = 12;
- DSP4_WAIT(2) resume2:
+ DSP4_WAIT(2)
////////////////////////////////////////////////////
// process one loop of projection
@@ -414,7 +421,11 @@ void DSP4_Op07()
int16 plane;
int16 index,lcv;
int16 y_out,x_out;
- int16 py_dy=0,px_dx=0;
+ int16 py_dy,px_dx;
+
+ resume2:
+ py_dy=0;
+ px_dx=0;
// debug
++block;
@@ -952,17 +963,24 @@ void DSP4_Op0D()
DSP4.in_index = 2;
DSP4.in_count = 8;
- DSP4_WAIT(2) resume2:
+ DSP4_WAIT(2)
////////////////////////////////////////////////////
// project section of the track
// inspect inputs
- int16 plane = DSP4_READ_WORD(0);
+ int16 plane;
int16 index, lcv;
- int16 py_dy=0, px_dx=0;
+ int16 py_dy, px_dx;
int16 y_out, x_out;
+ resume2:
+
+ plane = DSP4_READ_WORD(0);
+ py_dy=0;
+ px_dx=0;
+
+
// ignore invalid data
if((uint16) plane == 0x8001) continue;
@@ -1250,10 +1268,13 @@ sprite_found:
// grab a few remaining vehicle values
DSP4.in_count = 4;
- DSP4_WAIT(4) resume4:
+ DSP4_WAIT(4)
// store final values
- int height = DSP4_READ_WORD(0);
+ int height;
+
+ resume4:
+ height = DSP4_READ_WORD(0);
sprite_offset = DSP4_READ_WORD(2);
// vertical lift factor
diff --git a/source/getset.h b/source/getset.h
index f37779e..de8991c 100644
--- a/source/getset.h
+++ b/source/getset.h
@@ -98,10 +98,7 @@
#include "obc1.h"
#include "seta.h"
-extern "C"
-{
- extern uint8 OpenBus;
-}
+extern uint8 OpenBus;
uint8 S9xGetByte (uint32 Address)
{
diff --git a/source/gfx.h b/source/gfx.h
index 2cc95ef..1b545f7 100644
--- a/source/gfx.h
+++ b/source/gfx.h
@@ -93,7 +93,6 @@
#include "port.h"
#include "snes9x.h"
-START_EXTERN_C
void S9xStartScreenRefresh ();
void S9xDrawScanLine (uint8 Line);
void S9xEndScreenRefresh ();
@@ -112,8 +111,6 @@ bool8 S9xInitUpdate (void);
void S9xDeinitUpdate (int width, int height);
void S9xSyncSpeed ();
-END_EXTERN_C
-
struct SGFX{
// Initialize these variables
uint8 *Screen;
@@ -179,7 +176,7 @@ struct SLineData {
#define V_FLIP 0x8000
#define BLANK_TILE 2
-struct SBG
+typedef struct
{
uint32 TileSize;
uint32 BitShift;
@@ -195,7 +192,7 @@ struct SBG
uint8 *Buffer;
uint8 *Buffered;
bool8 DirectColourMode;
-};
+}SBG;
struct SLineMatrixData
{
diff --git a/source/globals.c b/source/globals.c
index 670dc92..a1c108e 100644
--- a/source/globals.c
+++ b/source/globals.c
@@ -102,7 +102,6 @@
#include "sa1.h"
#include "spc7110.h"
-START_EXTERN_C
char String[513];
struct Missing missing;
@@ -141,15 +140,10 @@ struct SSNESGameFixes SNESGameFixes;
uint8 OpenBus = 0;
-
-END_EXTERN_C
-
#ifndef ZSNES_FX
struct FxInit_s SuperFX;
#else
-START_EXTERN_C
uint8 *SFXPlotTable = NULL;
-END_EXTERN_C
#endif
struct SPPU PPU;
@@ -289,7 +283,6 @@ uint32 TailMask [5] = {
#endif
};
-START_EXTERN_C
uint8 APUROM [64] =
{
0xCD,0xEF,0xBD,0xE8,0x00,0xC6,0x1D,0xD0,0xFC,0x8F,0xAA,0xF4,0x8F,
@@ -344,6 +337,3 @@ uint16 S9xAPUCycles [256] =
/* e0 */ 2, 8, 4, 5, 3, 4, 3, 6, 2, 4, 5, 3, 4, 3, 4, 3,
/* f0 */ 2, 8, 4, 5, 4, 5, 5, 6, 3, 4, 5, 4, 2, 2, 4, 3
};
-
-END_EXTERN_C
-
diff --git a/source/memmap.c b/source/memmap.c
index c102128..2fb0dbc 100644
--- a/source/memmap.c
+++ b/source/memmap.c
@@ -125,9 +125,7 @@
#include "fxemu.h"
extern struct FxInit_s SuperFX;
#else
-START_EXTERN_C
extern uint8 *SFXPlotTable;
-END_EXTERN_C
#endif
#ifndef SET_UI_COLOR
@@ -4237,7 +4235,7 @@ static long ReadInt (FILE *f, unsigned nbytes)
#define IPS_EOF 0x00454F46l
void CMemory::CheckForIPSPatch (const char *rom_filename, bool8 header,
- int32 &rom_size)
+ int32* rom_size)
{
char dir [_MAX_DIR + 1];
char drive [_MAX_DRIVE + 1];
@@ -4297,8 +4295,8 @@ void CMemory::CheckForIPSPatch (const char *rom_filename, bool8 header,
goto err_eof;
ROM [ofs++] = (uint8) rchar;
}
- if (ofs > rom_size)
- rom_size = ofs;
+ if (ofs > *rom_size)
+ *rom_size = ofs;
}
else
{
@@ -4316,17 +4314,17 @@ void CMemory::CheckForIPSPatch (const char *rom_filename, bool8 header,
while (rlen--)
ROM [ofs++] = (uint8) rchar;
- if (ofs > rom_size)
- rom_size = ofs;
+ if (ofs > *rom_size)
+ *rom_size = ofs;
}
}
// Check if ROM image needs to be truncated
ofs = ReadInt (patch_file, 3);
- if (ofs != -1 && ofs - offset < rom_size)
+ if (ofs != -1 && ofs - offset < *rom_size)
{
// Need to truncate ROM image
- rom_size = ofs - offset;
+ *rom_size = ofs - offset;
}
fclose (patch_file);
return;
diff --git a/source/memmap.h b/source/memmap.h
index ff216a0..9186f32 100644
--- a/source/memmap.h
+++ b/source/memmap.h
@@ -137,68 +137,68 @@
#define BIGFIRST 2
#define SMALLFIRST 3
-class CMemory {
-public:
- bool8 LoadROM (const char *);
- uint32 FileLoader (uint8* buffer, const char* filename, int32 maxsize);
- void InitROM (bool8);
- bool8 LoadSRAM (const char *);
- bool8 SaveSRAM (const char *);
- bool8 Init ();
- void Deinit ();
- void FreeSDD1Data ();
-
- void WriteProtectROM ();
- void FixROMSpeed ();
- void MapRAM ();
- void MapExtraRAM ();
- char *Safe (const char *);
-
- void BSLoROMMap();
- void JumboLoROMMap (bool8);
- void LoROMMap ();
- void LoROM24MBSMap ();
- void SRAM512KLoROMMap ();
+bool8 LoadROM (const char *);
+uint32 FileLoader (uint8* buffer, const char* filename, int32 maxsize);
+void InitROM (bool8);
+bool8 LoadSRAM (const char *);
+bool8 SaveSRAM (const char *);
+bool8 Init ();
+void Deinit ();
+void FreeSDD1Data ();
+
+void WriteProtectROM ();
+void FixROMSpeed ();
+void MapRAM ();
+void MapExtraRAM ();
+char *Safe (const char *);
+
+void BSLoROMMap();
+void JumboLoROMMap (bool8);
+void LoROMMap ();
+void LoROM24MBSMap ();
+void SRAM512KLoROMMap ();
// void SRAM1024KLoROMMap ();
- void SufamiTurboLoROMMap ();
- void HiROMMap ();
- void SuperFXROMMap ();
- void TalesROMMap (bool8);
- void AlphaROMMap ();
- void SA1ROMMap ();
- void BSHiROMMap ();
- void SPC7110HiROMMap();
- void SPC7110Sram(uint8);
- void SetaDSPMap();
- bool8 AllASCII (uint8 *b, int size);
- int ScoreHiROM (bool8 skip_header, int32 offset=0);
- int ScoreLoROM (bool8 skip_header, int32 offset=0);
+void SufamiTurboLoROMMap ();
+void HiROMMap ();
+void SuperFXROMMap ();
+void TalesROMMap (bool8);
+void AlphaROMMap ();
+void SA1ROMMap ();
+void BSHiROMMap ();
+void SPC7110HiROMMap();
+void SPC7110Sram(uint8);
+void SetaDSPMap();
+bool8 AllASCII (uint8 *b, int size);
+int ScoreHiROM (bool8 skip_header, int32 offset);
+int ScoreLoROM (bool8 skip_header, int32 offset);
#if 0
- void SufamiTurboAltROMMap();
+void SufamiTurboAltROMMap();
#endif
- void ApplyROMFixes ();
- void CheckForIPSPatch (const char *rom_filename, bool8 header,
- int32 &rom_size);
-
- const char *TVStandard ();
- const char *Speed ();
- const char *StaticRAMSize ();
- const char *MapType ();
- const char *MapMode ();
- const char *KartContents ();
- const char *Size ();
- const char *Headers ();
- const char *ROMID ();
- const char *CompanyID ();
- void ParseSNESHeader(uint8*);
- enum {
- MAP_PPU, MAP_CPU, MAP_DSP, MAP_LOROM_SRAM, MAP_HIROM_SRAM,
- MAP_NONE, MAP_DEBUG, MAP_C4, MAP_BWRAM, MAP_BWRAM_BITMAP,
- MAP_BWRAM_BITMAP2, MAP_SA1RAM, MAP_SPC7110_ROM, MAP_SPC7110_DRAM,
- MAP_RONLY_SRAM, MAP_OBC_RAM, MAP_SETA_DSP, MAP_SETA_RISC, MAP_LAST
- };
- enum { MAX_ROM_SIZE = 0x800000 };
-
+void ApplyROMFixes ();
+void CheckForIPSPatch (const char *rom_filename, bool8 header,
+ int32* rom_size);
+
+const char *TVStandard ();
+const char *Speed ();
+const char *StaticRAMSize ();
+const char *MapType ();
+const char *MapMode ();
+const char *KartContents ();
+const char *Size ();
+const char *Headers ();
+const char *ROMID ();
+const char *CompanyID ();
+void ParseSNESHeader(uint8*);
+enum {
+MAP_PPU, MAP_CPU, MAP_DSP, MAP_LOROM_SRAM, MAP_HIROM_SRAM,
+MAP_NONE, MAP_DEBUG, MAP_C4, MAP_BWRAM, MAP_BWRAM_BITMAP,
+MAP_BWRAM_BITMAP2, MAP_SA1RAM, MAP_SPC7110_ROM, MAP_SPC7110_DRAM,
+MAP_RONLY_SRAM, MAP_OBC_RAM, MAP_SETA_DSP, MAP_SETA_RISC, MAP_LAST
+};
+enum { MAX_ROM_SIZE = 0x800000 };
+
+typedef struct
+{
uint8 *RAM;
uint8 *ROM;
uint8 *VRAM;
@@ -237,28 +237,14 @@ public:
uint8 ROMRegion;
uint32 ROMCRC32;
uint8 ExtendedFormat;
-#if 0
- bool8 SufamiTurbo;
- char Slot1Filename [_MAX_PATH];
- char Slot2Filename [_MAX_PATH];
- uint8* ROMOffset1;
- uint8* ROMOffset2;
- uint8* SRAMOffset1;
- uint8* SRAMOffset2;
- uint32 Slot1Size;
- uint32 Slot2Size;
- uint32 Slot1SRAMSize;
- uint32 Slot2SRAMSize;
- uint8 SlotContents;
-#endif
uint8 *BSRAM;
- void ResetSpeedMap();
#if 0
bool8 LoadMulti (const char *,const char *,const char *);
#endif
-};
+}CMemory;
+
+void ResetSpeedMap();
-START_EXTERN_C
extern CMemory Memory;
extern uint8 *SRAM;
extern uint8 *ROM;
@@ -268,11 +254,9 @@ bool8 LoadZip(const char* zipname,
int32 *TotalFileSize,
int32 *headers,
uint8 *buffer);
-END_EXTERN_C
-extern "C" {
- void S9xAutoSaveSRAM ();
-}
+
+void S9xAutoSaveSRAM ();
#ifdef NO_INLINE_SET_GET
uint8 S9xGetByte (uint32 Address);
@@ -283,9 +267,7 @@ void S9xSetPCBase (uint32 Address);
uint8 *S9xGetMemPointer (uint32 Address);
uint8 *GetBasePointer (uint32 Address);
-extern "C" {
- extern uint8 OpenBus;
-}
+extern uint8 OpenBus;
#else
#define INLINE inline
diff --git a/source/missing.h b/source/missing.h
index 66ca71e..f3858b3 100644
--- a/source/missing.h
+++ b/source/missing.h
@@ -159,6 +159,6 @@ struct Missing
uint16 unknowndsp_write;
};
-EXTERN_C struct Missing missing;
+struct Missing missing;
#endif
diff --git a/source/obc1.c b/source/obc1.c
index 763e7cc..2761f77 100644
--- a/source/obc1.c
+++ b/source/obc1.c
@@ -96,8 +96,6 @@ int OBC1_Address;
int OBC1_BasePtr;
int OBC1_Shift;
-extern "C"
-{
uint8 GetOBC1 (uint16 Address)
{
switch(Address) {
@@ -200,5 +198,3 @@ void ResetOBC1()
memset(OBC1_RAM, 0x00, 0x2000);
}
-
-}
diff --git a/source/obc1.h b/source/obc1.h
index 82ce89f..706fa9e 100644
--- a/source/obc1.h
+++ b/source/obc1.h
@@ -90,13 +90,11 @@
#ifndef _OBC1_H_
#define _OBC1_H_
-START_EXTERN_C
uint8 GetOBC1 (uint16 Address);
void SetOBC1 (uint8 Byte, uint16 Address);
uint8 *GetBasePointerOBC1(uint32 Address);
uint8 *GetMemPointerOBC1(uint32 Address);
void ResetOBC1();//bool8 full);
-END_EXTERN_C
#endif
diff --git a/source/port.h b/source/port.h
index 44a6cdf..9583a74 100644
--- a/source/port.h
+++ b/source/port.h
@@ -200,22 +200,6 @@ typedef __int64 int64;
#define FALSE 0
#endif
-#ifdef STORM
-#define EXTERN_C
-#define START_EXTERN_C
-#define END_EXTERN_C
-#else
-#if defined(__cplusplus) || defined(c_plusplus)
-#define EXTERN_C extern "C"
-#define START_EXTERN_C extern "C" {
-#define END_EXTERN_C }
-#else
-#define EXTERN_C extern
-#define START_EXTERN_C
-#define END_EXTERN_C
-#endif
-#endif
-
#ifndef __WIN32__
#ifndef PATH_MAX
@@ -239,11 +223,11 @@ void _splitpath (const char *path, char *drive, char *dir, char *fname,
#define strncasecmp strnicmp
#endif
-EXTERN_C void S9xGenerateSound ();
+void S9xGenerateSound ();
#ifdef STORM
-EXTERN_C int soundsignal;
-EXTERN_C void MixSound(void);
+int soundsignal;
+void MixSound(void);
/* Yes, CHECK_SOUND is getting defined correctly! */
#define CHECK_SOUND if (Settings.APUEnabled) if(SetSignalPPC(0L, soundsignal) & soundsignal) MixSound
#else
diff --git a/source/ppu.c b/source/ppu.c
index 4717f1d..4a22ede 100644
--- a/source/ppu.c
+++ b/source/ppu.c
@@ -106,8 +106,8 @@
#include "fxinst.h"
extern struct FxInit_s SuperFX;
#else
-EXTERN_C void S9xSuperFXWriteReg (uint8, uint32);
-EXTERN_C uint8 S9xSuperFXReadReg (uint32);
+void S9xSuperFXWriteReg (uint8, uint32);
+uint8 S9xSuperFXReadReg (uint32);
#endif
uint32 justifiers=0xFFFF00AA;
@@ -2518,7 +2518,7 @@ void S9xUpdateJustifiers()
bool offscreen=JustifierOffscreen();
- JustifierButtons(justifiers);
+ JustifierButtons(&justifiers);
// if(p1count==32)
// {
last_p1=!last_p1;
diff --git a/source/ppu.h b/source/ppu.h
index 8f8b8e7..efb892e 100644
--- a/source/ppu.h
+++ b/source/ppu.h
@@ -115,7 +115,7 @@ struct ClipData {
uint32 Right [6][6];
};
-struct InternalPPU {
+typedef struct {
bool8 ColorsChanged;
uint8 HDMA;
bool8 HDMAStarted;
@@ -157,7 +157,7 @@ struct InternalPPU {
int PrevMouseX[2];
int PrevMouseY[2];
struct ClipData Clip [2];
-};
+} InternalPPU;
struct SOBJ
{
@@ -171,7 +171,7 @@ struct SOBJ
uint8 Size;
};
-struct SPPU {
+typedef struct{
uint8 BGMode;
uint8 BG3Priority;
uint8 Brightness;
@@ -269,14 +269,14 @@ struct SPPU {
uint8 BGnxOFSbyte;
uint8 OpenBus1;
uint8 OpenBus2;
-};
+}SPPU;
#define CLIP_OR 0
#define CLIP_AND 1
#define CLIP_XOR 2
#define CLIP_XNOR 3
-struct SDMA {
+typedef struct {
bool8 TransferDirection;
bool8 AAddressFixed;
bool8 AAddressDecrement;
@@ -297,9 +297,8 @@ struct SDMA {
uint8 Repeat;
uint8 LineCount;
uint8 FirstLine;
-};
+}SDMA;
-START_EXTERN_C
void S9xUpdateScreen ();
void S9xResetPPU ();
void S9xSoftResetPPU ();
@@ -319,10 +318,9 @@ uint8 S9xGetC4 (uint16 Address);
void S9xSetC4RAM (uint8 Byte, uint16 Address);
uint8 S9xGetC4RAM (uint16 Address);
-extern struct SPPU PPU;
-extern struct SDMA DMA [8];
-extern struct InternalPPU IPPU;
-END_EXTERN_C
+extern SPPU PPU;
+extern SDMA DMA [8];
+extern InternalPPU IPPU;
#include "gfx.h"
#include "memmap.h"
@@ -333,11 +331,9 @@ typedef struct{
uint8 _5A22;
} SnesModel;
-START_EXTERN_C
extern SnesModel* Model;
extern SnesModel M1SNES;
extern SnesModel M2SNES;
-END_EXTERN_C
#define MAX_5C77_VERSION 0x01
#define MAX_5C78_VERSION 0x03
@@ -356,7 +352,7 @@ extern void REGISTER_2122(uint8 Byte);
extern void REGISTER_2180(uint8 Byte);
//Platform specific input functions used by PPU.CPP
-void JustifierButtons(uint32&);
+void JustifierButtons(uint32 *);
bool JustifierOffscreen();
#endif
diff --git a/source/sa1.h b/source/sa1.h
index 708fb68..a58cd2c 100644
--- a/source/sa1.h
+++ b/source/sa1.h
@@ -91,6 +91,7 @@
#define _sa1_h_
#include "memmap.h"
+#include "cpuexec.h"
struct SSA1Registers {
uint8 PB;
@@ -159,7 +160,6 @@ struct SSA1 {
#define SA1CheckFlag(f) (SA1.Registers.PL & (f))
-START_EXTERN_C
uint8 S9xSA1GetByte (uint32);
uint16 S9xSA1GetWord (uint32);
void S9xSA1SetByte (uint8, uint32);
@@ -178,7 +178,6 @@ void S9xSA1MainLoop ();
void S9xSA1Init ();
void S9xFixSA1AfterSnapshotLoad ();
void S9xSA1ExecuteDuringSleep ();
-END_EXTERN_C
#define SNES_IRQ_SOURCE (1 << 7)
#define TIMER_IRQ_SOURCE (1 << 6)
diff --git a/source/sa1cpu.c b/source/sa1cpu.c
index 299aab3..de8a094 100644
--- a/source/sa1cpu.c
+++ b/source/sa1cpu.c
@@ -200,7 +200,7 @@
#undef VAR_CYCLES
#define SA1_OPCODES
-#include "cpuops.cpp"
+#include "cpuops.c"
void S9xSA1MainLoop ()
{
diff --git a/source/sar.h b/source/sar.h
index c5e34f4..7f6e847 100644
--- a/source/sar.h
+++ b/source/sar.h
@@ -104,28 +104,28 @@
#define SAR(b, n) ((b)>>(n))
#else
-static inline int8 SAR(const int8 b, const int n){
+static inline int8 SAR8(const int8 b, const int n){
#ifndef RIGHTSHIFT_INT8_IS_SAR
if(b<0) return (b>>n)|(-1<<(8-n));
#endif
return b>>n;
}
-static inline int16 SAR(const int16 b, const int n){
+static inline int16 SAR16(const int16 b, const int n){
#ifndef RIGHTSHIFT_INT16_IS_SAR
if(b<0) return (b>>n)|(-1<<(16-n));
#endif
return b>>n;
}
-static inline int32 SAR(const int32 b, const int n){
+static inline int32 SAR32(const int32 b, const int n){
#ifndef RIGHTSHIFT_INT32_IS_SAR
if(b<0) return (b>>n)|(-1<<(32-n));
#endif
return b>>n;
}
-static inline int64 SAR(const int64 b, const int n){
+static inline int64 SAR64(const int64 b, const int n){
#ifndef RIGHTSHIFT_INT64_IS_SAR
if(b<0) return (b>>n)|(-1<<(64-n));
#endif
diff --git a/source/sdd1emu.h b/source/sdd1emu.h
index 829ac4a..4e95a0e 100644
--- a/source/sdd1emu.h
+++ b/source/sdd1emu.h
@@ -89,16 +89,11 @@
#ifndef SDD1EMU_H
#define SDD1EMU_H
-/* for START_EXTERN_C/END_EXTERN_C */
-#include "port.h"
-
-START_EXTERN_C
+//#include "port.h"
void SDD1_decompress(uint8 *out, uint8 *in, int output_length);
void SDD1_init(uint8 *in);
uint8 SDD1_get_byte(void);
-END_EXTERN_C
-
#endif
diff --git a/source/seta.c b/source/seta.c
index 4e7d208..e5df1f6 100644
--- a/source/seta.c
+++ b/source/seta.c
@@ -91,7 +91,6 @@
void (*SetSETA)(uint32, uint8)=&S9xSetST010;
uint8 (*GetSETA)(uint32)=&S9xGetST010;
-extern "C"{
uint8 S9xGetSetaDSP(uint32 Address)
{
return GetSETA(Address);
@@ -101,5 +100,4 @@ void S9xSetSetaDSP(uint8 Byte, uint32 Address)
{
SetSETA(Address, Byte);
}
-}
diff --git a/source/seta.h b/source/seta.h
index f857636..34d04d1 100644
--- a/source/seta.h
+++ b/source/seta.h
@@ -97,9 +97,6 @@
#define ST_011 0x02
#define ST_018 0x03
-
-extern "C"
-{
uint8 S9xGetSetaDSP(uint32 Address);
void S9xSetSetaDSP(uint8 byte,uint32 Address);
uint8 S9xGetST018(uint32 Address);
@@ -109,7 +106,6 @@ uint8 S9xGetST010(uint32 Address);
void S9xSetST010(uint32 Address, uint8 Byte);
uint8 S9xGetST011(uint32 Address);
void S9xSetST011(uint32 Address, uint8 Byte);
-}
extern void (*SetSETA)(uint32, uint8);
extern uint8 (*GetSETA)(uint32);
diff --git a/source/seta018.c b/source/seta018.c
index cafca06..75b02b2 100644
--- a/source/seta018.c
+++ b/source/seta018.c
@@ -93,7 +93,6 @@ ST018_Regs ST018;
static int line; // line counter
-extern "C"{
uint8 S9xGetST018(uint32 Address)
{
uint8 t = 0; // Initialise to some value for the compiler
@@ -250,5 +249,4 @@ void S9xSetST018(uint8 Byte, uint32 Address)
}
}
}
-}
diff --git a/source/snaporig.c b/source/snaporig.c
index 69ff33e..add1c09 100644
--- a/source/snaporig.c
+++ b/source/snaporig.c
@@ -161,9 +161,9 @@ static int ReadBlock (const char *key, void *block, int max_len, STREAM snap)
if (rem)
{
- char *junk = new char [rem];
+ char *junk = (char*)malloc(rem);
READ_STREAM (junk, rem, snap);
- delete[] junk;
+ free(junk);
}
return (SUCCESS);
diff --git a/source/snaporig.h b/source/snaporig.h
index a796c08..cc9c09e 100644
--- a/source/snaporig.h
+++ b/source/snaporig.h
@@ -92,7 +92,7 @@
#define ORIG_SNAPSHOT_MAGIC "#!snes96"
#define ORIG_SNAPSHOT_VERSION 4
-EXTERN_C bool8 S9xLoadOrigSnapshot (const char *filename);
+bool8 S9xLoadOrigSnapshot (const char *filename);
struct SOrigCPUState{
uint32 Flags;
diff --git a/source/snapshot.c b/source/snapshot.c
index ac4abe4..0cc5a9a 100644
--- a/source/snapshot.c
+++ b/source/snapshot.c
@@ -117,11 +117,9 @@
extern uint8 *SRAM;
#ifdef ZSNES_FX
-START_EXTERN_C
void S9xSuperFXPreSaveState ();
void S9xSuperFXPostSaveState ();
void S9xSuperFXPostLoadState ();
-END_EXTERN_C
#endif
bool8 S9xUnfreezeZSNES (const char *filename);
diff --git a/source/snapshot.h b/source/snapshot.h
index 1843bfe..cb65c6c 100644
--- a/source/snapshot.h
+++ b/source/snapshot.h
@@ -102,7 +102,6 @@
#define WRONG_MOVIE_SNAPSHOT (-4)
#define NOT_A_MOVIE_SNAPSHOT (-5)
-START_EXTERN_C
bool8 S9xFreezeGame (const char *filename);
bool8 S9xUnfreezeGame (const char *filename);
bool8 Snapshot (const char *filename);
@@ -110,7 +109,6 @@ bool8 S9xLoadSnapshot (const char *filename);
bool8 S9xSPCDump (const char *filename);
void S9xFreezeToStream (STREAM);
int S9xUnfreezeFromStream (STREAM);
-END_EXTERN_C
#endif
diff --git a/source/snes9x.h b/source/snes9x.h
index 95a38e3..1747389 100644
--- a/source/snes9x.h
+++ b/source/snes9x.h
@@ -95,16 +95,20 @@
#include <stdlib.h>
#include <stdint.h>
+#if defined(_MSC_VER) && !defined(SN_TARGET_PS3)
+/* Hack applied for MSVC when compiling in C89 mode
+ * as it isn't C99-compliant. */
+#define bool unsigned char
+#define true 1
+#define false 0
+#else
+#include <stdbool.h>
+#endif
+
//#include "fs_api.h"
//#include "ds2_malloc.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
extern int cprintf(const char *fmt, ...);
-#ifdef __cplusplus
-}
-#endif
#ifdef __WIN32__
#include "..\wsnes9x.h"
@@ -392,7 +396,6 @@ struct SSNESGameFixes
bool8 EchoOnlyOutput;
};
-START_EXTERN_C
extern struct SSettings Settings;
extern struct SCPUState CPU;
extern struct SSNESGameFixes SNESGameFixes;
@@ -401,7 +404,6 @@ extern char String [513];
void S9xExit ();
void S9xMessage (int type, int number, const char *message);
void S9xLoadSDD1Data ();
-END_EXTERN_C
void S9xSetPause (uint32 mask);
void S9xClearPause (uint32 mask);
diff --git a/source/soundux.c b/source/soundux.c
index 10e0130..7e69c4d 100644
--- a/source/soundux.c
+++ b/source/soundux.c
@@ -157,8 +157,8 @@ static int32 noise_gen;
#define VOL_DIV16 0x0080
#define ENVX_SHIFT 24
-extern "C" void DecodeBlockAsm (int8 *, int16 *, int32 *, int32 *);
-extern "C" void DecodeBlockAsm2 (int8 *, int16 *, int32 *, int32 *);
+void DecodeBlockAsm (int8 *, int16 *, int32 *, int32 *);
+void DecodeBlockAsm2 (int8 *, int16 *, int32 *, int32 *);
// F is channel's current frequency and M is the 16-bit modulation waveform
// from the previous channel multiplied by the current envelope volume level.
diff --git a/source/soundux.h b/source/soundux.h
index 2426070..7e77d4f 100644
--- a/source/soundux.h
+++ b/source/soundux.h
@@ -138,7 +138,7 @@ typedef struct {
uint32 err_rate;
} SoundStatus;
-EXTERN_C SoundStatus so;
+SoundStatus so;
typedef struct {
@@ -200,7 +200,7 @@ typedef struct
int noise_hertz;
} SSoundData;
-EXTERN_C SSoundData SoundData;
+SSoundData SoundData;
void S9xSetEightBitConsoleSound (bool8 Enabled);
@@ -237,8 +237,8 @@ void S9xPlaySample (int channel);
void S9xFixEnvelope (int channel, uint8 gain, uint8 adsr1, uint8 adsr2);
void S9xStartSample (int channel);
-EXTERN_C void S9xMixSamples (uint8 *buffer, int sample_count);
-EXTERN_C void S9xMixSamplesO (uint8 *buffer, int sample_count, int byte_offset);
+void S9xMixSamples (uint8 *buffer, int sample_count);
+void S9xMixSamplesO (uint8 *buffer, int sample_count, int byte_offset);
bool8 S9xOpenSoundDevice (int, bool8, int);
void S9xSetPlaybackRate (uint32 rate);
#endif
diff --git a/source/spc700.h b/source/spc700.h
index 29f071b..b38c814 100644
--- a/source/spc700.h
+++ b/source/spc700.h
@@ -160,7 +160,7 @@ struct SAPURegisters{
// 1.953us := 1.024065.54MHz
#ifdef SPCTOOL
-EXTERN_C int32 ESPC (int32);
+int32 ESPC (int32);
#define APU_EXECUTE() \
{ \
diff --git a/source/spc7110.c b/source/spc7110.c
index 3ae0cfd..f296fc2 100644
--- a/source/spc7110.c
+++ b/source/spc7110.c
@@ -109,8 +109,8 @@
#define FREEZEFOLDER S9xGetSnapshotDirectory ()
#endif
-extern "C" const char *S9xGetFilename (const char *);
-extern "C" char *osd_GetPackDir();
+const char *S9xGetFilename (const char *);
+char *osd_GetPackDir();
//really not needed, but usually MS adds the _ to POSIX functions,
//while *nix doesn't, so this was to "un-M$" the function.
#define splitpath _splitpath
@@ -522,7 +522,6 @@ void GetPackData()
}
}
-extern "C"{
//reads SPC7110 and RTC registers.
uint8 S9xGetSPC7110(uint16 Address)
{
@@ -898,7 +897,7 @@ uint8 S9xGetSPC7110(uint16 Address)
return 0x00;
}
}
-}
+
void S9xSetSPC7110 (uint8 data, uint16 Address)
{
switch(Address)
@@ -1399,7 +1398,7 @@ void S9xSetSPC7110 (uint8 data, uint16 Address)
//16 BIT MULTIPLIER: ($FF00) high byte, defval:00
}
}
-extern "C"{
+
//emulate the SPC7110's ability to remap banks Dx, Ex, and Fx.
uint8 S9xGetSPC7110Byte(uint32 Address)
{
@@ -1421,7 +1420,7 @@ uint8 S9xGetSPC7110Byte(uint32 Address)
i+=s7r.DataRomOffset;
return ROM[i];
}
-}
+
/**********************************************************************************************/
/* S9xSRTCDaysInMonth() */
/* Return the number of days in a specific month for a certain year */
@@ -1603,7 +1602,6 @@ void S9xUpdateRTC ()
}
}
}
-extern "C"{
//allows DMA from the ROM (is this even possible on the SPC7110?
uint8* Get7110BasePtr(uint32 Address)
@@ -1625,8 +1623,6 @@ uint8* Get7110BasePtr(uint32 Address)
i+=Address&0x000F0000;
return &ROM[i];
}
-//end extern
-}
//loads the index into memory.
//index.bin is little-endian
diff --git a/source/spc7110.h b/source/spc7110.h
index 48368f5..7fd1602 100644
--- a/source/spc7110.h
+++ b/source/spc7110.h
@@ -101,11 +101,9 @@ extern uint16 cacheMegs;
void Del7110Gfx(void);
void Close7110Gfx(void);
void Drop7110Gfx(void);
-extern "C"{
uint8 S9xGetSPC7110(uint16 Address);
uint8 S9xGetSPC7110Byte(uint32 Address);
uint8* Get7110BasePtr(uint32);
-}
void S9xSetSPC7110 (uint8 data, uint16 Address);
void S9xSpc7110Init();
uint8* Get7110BasePtr(uint32);