Skip to content

Commit 4fb67d2

Browse files
committed
get rid of all remaining C++ code.
1 parent 9c8d360 commit 4fb67d2

File tree

20 files changed

+264
-242
lines changed

20 files changed

+264
-242
lines changed

libretro.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ unsigned retro_api_version() { return RETRO_API_VERSION; }
8888

8989

9090

91-
void S9xProcessSound (unsigned int);
91+
void S9xProcessSound (unsigned int samples);
9292

9393
char *rom_filename = NULL;
9494
char *SDD1_pack = NULL;
@@ -105,7 +105,7 @@ static u8 Buf[MAX_BUFFER_SIZE];
105105
#define FIXED_POINT_SHIFT 16
106106
#define FIXED_POINT_REMAINDER 0xffff
107107

108-
void S9xMessage (int /*type*/, int /*number*/, const char *message)
108+
void S9xMessage (int type, int number, const char *message)
109109
{
110110
#if 1
111111
#define MAX_MESSAGE_LEN (36 * 3)
@@ -226,7 +226,7 @@ void S9xDeinitUpdate (int width, int height)
226226

227227
#endif
228228

229-
void _makepath (char *path, const char *, const char *dir,
229+
void _makepath (char *path, const char *drive, const char *dir,
230230
const char *fname, const char *ext)
231231
{
232232
if (dir && *dir)
@@ -419,7 +419,7 @@ void init_sfc_setting(void)
419419

420420
void S9xAutoSaveSRAM ()
421421
{
422-
Memory.SaveSRAM (S9xGetFilename (".srm"));
422+
SaveSRAM (S9xGetFilename (".srm"));
423423
}
424424

425425
int game_load_state(char* file)
@@ -456,13 +456,13 @@ int load_gamepak(const char* file)
456456
{
457457
CPU.Flags = 0;
458458
// mdelay(50); // Delete this delay
459-
if (!Memory.LoadROM (file))
459+
if (!LoadROM (file))
460460
return -1;
461461
S9xReset ();
462462

463463
Settings.FrameTime = (Settings.PAL ? Settings.FrameTimePAL : Settings.FrameTimeNTSC);
464464

465-
Memory.LoadSRAM (S9xGetFilename (".srm"));
465+
LoadSRAM (S9xGetFilename (".srm"));
466466
S9xLoadCheatFile (S9xGetFilename (".chb")); // cheat binary file, as opposed to text
467467

468468
return 0;
@@ -486,7 +486,7 @@ void retro_init (void)
486486

487487
init_sfc_setting();
488488

489-
if (!Memory.Init () || !S9xInitAPU())
489+
if (!Init () || !S9xInitAPU())
490490
OutOfMemory ();
491491

492492
S9xInitDisplay ();
@@ -654,7 +654,7 @@ static unsigned int LastSoundEmissionTime = 0;
654654
*/
655655
static unsigned int SoundEmissionTimeError = 0;
656656

657-
void S9xProcessSound (unsigned int)
657+
void S9xProcessSound (unsigned int samples)
658658
{
659659

660660
}
@@ -839,7 +839,7 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code)
839839
bool retro_load_game(const struct retro_game_info *game)
840840

841841
{
842-
Memory.LoadROM(game->path);
842+
LoadROM(game->path);
843843
return true;
844844
}
845845

source/65c816.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ typedef union
154154
uint16 W;
155155
} pair;
156156

157-
struct SRegisters{
157+
typedef struct {
158158
uint8 PB;
159159
uint8 DB;
160160
pair P;
@@ -164,7 +164,7 @@ struct SRegisters{
164164
pair X;
165165
pair Y;
166166
uint16 PC;
167-
};
167+
}SRegisters;
168168

169169
#endif
170170

source/apu.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@
9292

9393
#include "spc700.h"
9494

95-
struct SIAPU
95+
typedef struct
9696
{
9797
uint8 *PC;
98-
struct SAPURegisters Registers;
98+
SAPURegisters Registers;
9999
uint8 *RAM;
100100
uint8 *DirectPage;
101101
bool8 APUExecuting;
@@ -111,9 +111,9 @@ struct SIAPU
111111
uint32 Scanline;
112112
int32 OneCycle;
113113
int32 TwoCycles;
114-
};
114+
}SIAPU;
115115

116-
struct SAPU
116+
typedef struct
117117
{
118118
int32 Cycles;
119119
bool8 ShowROM;
@@ -126,10 +126,10 @@ struct SAPU
126126
uint16 TimerTarget [3];
127127
bool8 TimerEnabled [3];
128128
bool8 TimerValueWritten [3];
129-
};
129+
}SAPU;
130130

131-
struct SAPU APU;
132-
struct SIAPU IAPU;
131+
SAPU APU;
132+
SIAPU IAPU;
133133
extern int spc_is_dumping;
134134
extern int spc_is_dumping_temp;
135135
extern uint8 spc_dump_dsp[0x100];

source/cheats2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ extern SCheatData Cheat;
9898
void S9xInitCheatData ()
9999
{
100100
Cheat.RAM = Memory.RAM;
101-
Cheat.SRAM = SRAM;
101+
Cheat.SRAM = Memory.SRAM;
102102
Cheat.FillRAM = Memory.FillRAM;
103103
}
104104

source/cpuexec.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,19 @@
101101
if (CPU.Cycles >= CPU.NextEvent) \
102102
S9xDoHBlankProcessing_NoSFX ();
103103

104-
struct SOpcodes {
104+
typedef struct {
105105
#ifdef __WIN32__
106106
void (__cdecl *S9xOpcode)( void);
107107
#else
108108
void (*S9xOpcode)( void);
109109
#endif
110-
};
110+
}SOpcodes;
111111

112-
struct SICPU
112+
typedef struct
113113
{
114114
uint8 *Speed;
115-
struct SOpcodes *S9xOpcodes;
116-
struct SRegisters Registers;
115+
SOpcodes *S9xOpcodes;
116+
SRegisters Registers;
117117
uint8 _Carry;
118118
uint8 _Zero;
119119
uint8 _Negative;
@@ -124,7 +124,7 @@ struct SICPU
124124
uint32 Frame;
125125
uint32 Scanline;
126126
uint32 FrameAdvanceCount;
127-
};
127+
}SICPU;
128128

129129
void S9xMainLoop (void);
130130
void S9xReset (void);
@@ -134,13 +134,13 @@ void S9xDoHBlankProcessing_NoSFX ();
134134
void S9xClearIRQ (uint32);
135135
void S9xSetIRQ (uint32);
136136

137-
extern struct SOpcodes S9xOpcodesE1 [256];
138-
extern struct SOpcodes S9xOpcodesM1X1 [256];
139-
extern struct SOpcodes S9xOpcodesM1X0 [256];
140-
extern struct SOpcodes S9xOpcodesM0X1 [256];
141-
extern struct SOpcodes S9xOpcodesM0X0 [256];
137+
extern SOpcodes S9xOpcodesE1 [256];
138+
extern SOpcodes S9xOpcodesM1X1 [256];
139+
extern SOpcodes S9xOpcodesM1X0 [256];
140+
extern SOpcodes S9xOpcodesM0X1 [256];
141+
extern SOpcodes S9xOpcodesM0X0 [256];
142142

143-
extern struct SICPU ICPU;
143+
extern SICPU ICPU;
144144

145145
STATIC inline void S9xUnpackStatus()
146146
{

source/cpuops.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3362,7 +3362,7 @@ static void Op0CM0 (void)
33623362

33633363
#ifdef CPU_SHUTDOWN
33643364
#ifndef SA1_OPCODES
3365-
inline void CPUShutdown()
3365+
static inline void CPUShutdown()
33663366
{
33673367
if (Settings.Shutdown && CPU.PC == CPU.WaitAddress)
33683368
{
@@ -5025,7 +5025,7 @@ static void Op42 (void)
50255025
/*****************************************************************************/
50265026
/* CPU-S9xOpcodes Definitions */
50275027
/*****************************************************************************/
5028-
struct SOpcodes S9xOpcodesM1X1[256] =
5028+
SOpcodes S9xOpcodesM1X1[256] =
50295029
{
50305030
{Op00}, {Op01M1}, {Op02}, {Op03M1}, {Op04M1},
50315031
{Op05M1}, {Op06M1}, {Op07M1}, {Op08}, {Op09M1},
@@ -5081,7 +5081,7 @@ struct SOpcodes S9xOpcodesM1X1[256] =
50815081
{OpFFM1}
50825082
};
50835083

5084-
struct SOpcodes S9xOpcodesE1[256] =
5084+
SOpcodes S9xOpcodesE1[256] =
50855085
{
50865086
{Op00}, {Op01M1}, {Op02}, {Op03M1}, {Op04M1},
50875087
{Op05M1}, {Op06M1}, {Op07M1}, {Op08E1}, {Op09M1},
@@ -5137,7 +5137,7 @@ struct SOpcodes S9xOpcodesE1[256] =
51375137
{OpFFM1}
51385138
};
51395139

5140-
struct SOpcodes S9xOpcodesM1X0[256] =
5140+
SOpcodes S9xOpcodesM1X0[256] =
51415141
{
51425142
{Op00}, {Op01M1}, {Op02}, {Op03M1}, {Op04M1},
51435143
{Op05M1}, {Op06M1}, {Op07M1}, {Op08}, {Op09M1},
@@ -5193,7 +5193,7 @@ struct SOpcodes S9xOpcodesM1X0[256] =
51935193
{OpFFM1}
51945194
};
51955195

5196-
struct SOpcodes S9xOpcodesM0X0[256] =
5196+
SOpcodes S9xOpcodesM0X0[256] =
51975197
{
51985198
{Op00}, {Op01M0}, {Op02}, {Op03M0}, {Op04M0},
51995199
{Op05M0}, {Op06M0}, {Op07M0}, {Op08}, {Op09M0},
@@ -5249,7 +5249,7 @@ struct SOpcodes S9xOpcodesM0X0[256] =
52495249
{OpFFM0}
52505250
};
52515251

5252-
struct SOpcodes S9xOpcodesM0X1[256] =
5252+
SOpcodes S9xOpcodesM0X1[256] =
52535253
{
52545254
{Op00}, {Op01M0}, {Op02}, {Op03M0}, {Op04M0},
52555255
{Op05M0}, {Op06M0}, {Op07M0}, {Op08}, {Op09M0},

source/dsp1.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ uint8 DSP3GetByte(uint16 address);
105105
void DSP4SetByte(uint8 byte, uint16 address);
106106
uint8 DSP4GetByte(uint16 address);
107107

108-
struct SDSP1 {
108+
typedef struct{
109109
bool8 waiting4command;
110110
bool8 first_parameter;
111111
uint8 command;
@@ -116,12 +116,12 @@ struct SDSP1 {
116116
uint8 parameters [512];
117117
//output was 512 for DSP-2 work, updated to reflect current thinking on DSP-3
118118
uint8 output [512];
119-
};
119+
}SDSP1;
120120

121121
void S9xResetDSP1 ();
122122
uint8 S9xGetDSP (uint16 Address);
123123
void S9xSetDSP (uint8 Byte, uint16 Address);
124-
extern struct SDSP1 DSP1;
124+
extern SDSP1 DSP1;
125125

126126
//extern struct SDSP1 DSP1;
127127

source/gfx.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ GFX.X2 [((((C1) & RGB_REMOVE_LOW_BITS_MASK) + \
245245
((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1) + \
246246
((C1) & (C2) & RGB_LOW_BITS_MASK)]
247247
#else
248-
inline uint16 COLOR_ADD (uint16, uint16);
248+
static inline uint16 COLOR_ADD (uint16, uint16);
249249

250-
inline uint16 COLOR_ADD (uint16 C1, uint16 C2)
250+
static inline uint16 COLOR_ADD (uint16 C1, uint16 C2)
251251
{
252252
if (C1 == 0)
253253
return C2;

source/globals.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,19 @@ char String[513];
106106

107107
struct Missing missing;
108108

109-
struct SICPU ICPU;
109+
SICPU ICPU;
110110

111-
struct SCPUState CPU;
111+
SCPUState CPU;
112112

113-
struct SAPU APU;
113+
SAPU APU;
114114

115-
struct SIAPU IAPU;
115+
SIAPU IAPU;
116116

117-
struct SSettings Settings;
117+
SSettings Settings;
118118

119-
struct SDSP1 DSP1;
119+
SDSP1 DSP1;
120120

121-
struct SSA1 SA1;
121+
SSA1 SA1;
122122

123123
SSoundData SoundData;
124124

@@ -127,16 +127,16 @@ SnesModel M2SNES={2,4,3};
127127
SnesModel* Model=&M1SNES;
128128

129129

130-
uint8 *SRAM = NULL;
131-
uint8 *ROM = NULL;
132-
uint8 *RegRAM = NULL;
130+
uint8 *SRAM_g = NULL;
131+
uint8 *ROM_g = NULL;
132+
uint8 *RegRAM_g = NULL;
133133
uint8 *C4RAM = NULL;
134134

135135
long OpAddress = 0;
136136

137137
CMemory Memory;
138138

139-
struct SSNESGameFixes SNESGameFixes;
139+
SSNESGameFixes SNESGameFixes;
140140

141141
uint8 OpenBus = 0;
142142

source/port.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,5 +288,15 @@ void MixSound(void);
288288
#define STATIC static
289289
#endif
290290

291+
#if defined(_MSC_VER) && !defined(SN_TARGET_PS3)
292+
/* Hack applied for MSVC when compiling in C89 mode
293+
* as it isn't C99-compliant. */
294+
#define bool unsigned char
295+
#define true 1
296+
#define false 0
297+
#else
298+
#include <stdbool.h>
299+
#endif
300+
291301
#endif
292302

0 commit comments

Comments
 (0)