Backport code cleanup remove unused code

Backport all changes including November 18 2018.
This commit is contained in:
bladeoner 2018-11-20 12:13:06 +01:00
parent f41bd20108
commit 14036e6d54
11 changed files with 105 additions and 79 deletions

View File

@ -243,6 +243,7 @@ static const uint8 flashcard[20] =
0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
#if 0
static const uint8 init2192[32] = // FIXME
{
00, 00, 00, 00, 00, // unknown
@ -254,6 +255,7 @@ static const uint8 init2192[32] = // FIXME
10, 10, 10, 10, 10, // dummy
00, 00, 00, 00, 00, 00, 00, 00, 00
};
#endif
static bool8 FlashMode;
static uint32 FlashSize;

View File

@ -2468,11 +2468,11 @@ void S9xApplyCommand (s9xcommand_t cmd, int16 data1, int16 data2)
char drive[_MAX_DRIVE + 1], dir[_MAX_DIR + 1], def[_MAX_FNAME + 1], ext[_MAX_EXT + 1];
_splitpath(Memory.ROMFilename, drive, dir, def, ext);
snprintf(filename, PATH_MAX + 1, "%s%s%s.%.*s", S9xGetDirectory(SNAPSHOT_DIR), SLASH_STR, def, _MAX_EXT - 1, "oops");
ssnprintf(filename, PATH_MAX + 1, "%s%s%s.%.*s", S9xGetDirectory(SNAPSHOT_DIR), SLASH_STR, def, _MAX_EXT - 1, "oops");
if (S9xUnfreezeGame(filename))
{
snprintf(buf, 256, "%s.%.*s loaded", def, _MAX_EXT - 1, "oops");
ssnprintf(buf, 256, "%s.%.*s loaded", def, _MAX_EXT - 1, "oops");
S9xSetInfoString (buf);
}
else
@ -2505,11 +2505,11 @@ void S9xApplyCommand (s9xcommand_t cmd, int16 data1, int16 data2)
char drive[_MAX_DRIVE + 1], dir[_MAX_DIR + 1], def[_MAX_FNAME + 1], ext[_MAX_EXT + 1];
_splitpath(Memory.ROMFilename, drive, dir, def, ext);
snprintf(filename, PATH_MAX + 1, "%s%s%s.%03d", S9xGetDirectory(SNAPSHOT_DIR), SLASH_STR, def, i - QuickLoad000);
ssnprintf(filename, PATH_MAX + 1, "%s%s%s.%03d", S9xGetDirectory(SNAPSHOT_DIR), SLASH_STR, def, i - QuickLoad000);
if (S9xUnfreezeGame(filename))
{
snprintf(buf, 256, "%s.%03d loaded", def, i - QuickLoad000);
ssnprintf(buf, 256, "%s.%03d loaded", def, i - QuickLoad000);
S9xSetInfoString(buf);
}
else
@ -2534,9 +2534,9 @@ void S9xApplyCommand (s9xcommand_t cmd, int16 data1, int16 data2)
char drive[_MAX_DRIVE + 1], dir[_MAX_DIR + 1], def[_MAX_FNAME + 1], ext[_MAX_EXT + 1];
_splitpath(Memory.ROMFilename, drive, dir, def, ext);
snprintf(filename, PATH_MAX + 1, "%s%s%s.%03d", S9xGetDirectory(SNAPSHOT_DIR), SLASH_STR, def, i - QuickSave000);
ssnprintf(filename, PATH_MAX + 1, "%s%s%s.%03d", S9xGetDirectory(SNAPSHOT_DIR), SLASH_STR, def, i - QuickSave000);
snprintf(buf, 256, "%s.%03d saved", def, i - QuickSave000);
ssnprintf(buf, 256, "%s.%03d saved", def, i - QuickSave000);
S9xSetInfoString(buf);
S9xFreezeGame(filename);

View File

@ -308,8 +308,8 @@ void S9xMainLoop (void)
if (CPU.Flags & SCAN_KEYS_FLAG)
break;
register uint8 Op;
register struct SOpcodes *Opcodes;
uint8 Op;
struct SOpcodes *Opcodes;
if (CPU.PCBase)
{

View File

@ -699,12 +699,12 @@ void S9xUpdateScreen (void)
// ignoring the true, larger size of the buffer.
GFX.RealPPL = GFX.Pitch >> 1;
for (register int32 y = (int32) GFX.StartY - 1; y >= 0; y--)
for (int32 y = (int32) GFX.StartY - 1; y >= 0; y--)
{
register uint16 *p = GFX.Screen + y * GFX.PPL + 255;
register uint16 *q = GFX.Screen + y * GFX.RealPPL + 510;
uint16 *p = GFX.Screen + y * GFX.PPL + 255;
uint16 *q = GFX.Screen + y * GFX.RealPPL + 510;
for (register int x = 255; x >= 0; x--, p--, q -= 2)
for (int x = 255; x >= 0; x--, p--, q -= 2)
*q = *(q + 1) = *p;
}
@ -713,12 +713,12 @@ void S9xUpdateScreen (void)
else
#endif
// Have to back out of the regular speed hack
for (register uint32 y = 0; y < GFX.StartY; y++)
for (uint32 y = 0; y < GFX.StartY; y++)
{
register uint16 *p = GFX.Screen + y * GFX.PPL + 255;
register uint16 *q = GFX.Screen + y * GFX.PPL + 510;
uint16 *p = GFX.Screen + y * GFX.PPL + 255;
uint16 *q = GFX.Screen + y * GFX.PPL + 510;
for (register int x = 255; x >= 0; x--, p--, q -= 2)
for (int x = 255; x >= 0; x--, p--, q -= 2)
*q = *(q + 1) = *p;
}
@ -733,7 +733,7 @@ void S9xUpdateScreen (void)
GFX.PPL = GFX.RealPPL << 1;
GFX.DoInterlace = 2;
for (register int32 y = (int32) GFX.StartY - 2; y >= 0; y--)
for (int32 y = (int32) GFX.StartY - 2; y >= 0; y--)
memmove(GFX.Screen + (y + 1) * GFX.PPL, GFX.Screen + y * GFX.RealPPL, GFX.PPL * sizeof(uint16));
}
}
@ -1001,8 +1001,10 @@ static void SetupOBJ (void)
IPPU.OBJChanged = FALSE;
}
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC push_options
#pragma GCC optimize ("no-tree-vrp")
#endif
static void DrawOBJS (int D)
{
void (*DrawTile) (uint32, uint32, uint32, uint32) = NULL;
@ -1095,8 +1097,9 @@ static void DrawOBJS (int D)
}
}
}
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC pop_options
#endif
static void DrawBackground (int bg, uint8 Zh, uint8 Zl)
{

View File

@ -262,10 +262,12 @@ void S9xVideoLogger (void *pixels, int width, int height, int depth, int bytes_p
if (video)
{
char *data = (char *) pixels;
size_t ignore;
for (int i = 0; i < height; i++)
ignore = fwrite(data + i * bytes_per_line, depth, width, video);
{
if (!fwrite(data + i * bytes_per_line, depth, width, video))
printf ("Error writing video data.\n");
}
fflush(video);
fflush(audio);
@ -282,8 +284,8 @@ void S9xAudioLogger (void *samples, int length)
{
if (audio)
{
size_t ignore;
ignore = fwrite(samples, 1, length, audio);
if (!fwrite(samples, 1, length, audio))
printf ("Error writing audio data.\n");
}
}

View File

@ -2095,13 +2095,13 @@ bool8 CMemory::LoadGNEXT ()
bool8 CMemory::LoadSRTC (void)
{
FILE *fp;
size_t ignore;
fp = fopen(S9xGetFilename(".rtc", SRAM_DIR), "rb");
if (!fp)
return (FALSE);
ignore = fread(RTCData.reg, 1, 20, fp);
if (fread(RTCData.reg, 1, 20, fp) < 20)
memset (RTCData.reg, 0, 20);
fclose(fp);
return (TRUE);
@ -2110,13 +2110,15 @@ bool8 CMemory::LoadSRTC (void)
bool8 CMemory::SaveSRTC (void)
{
FILE *fp;
size_t ignore;
fp = fopen(S9xGetFilename(".rtc", SRAM_DIR), "wb");
if (!fp)
return (FALSE);
ignore = fwrite(RTCData.reg, 1, 20, fp);
if (fwrite(RTCData.reg, 1, 20, fp) < 20)
{
printf ("Failed to save clock data.\n");
}
fclose(fp);
return (TRUE);
@ -2243,8 +2245,8 @@ bool8 CMemory::SaveSRAM (const char *filename)
file = fopen(name, "wb");
if (file)
{
size_t ignore;
ignore = fwrite((char *) Multi.sramB, size, 1, file);
if (!fwrite((char *) Multi.sramB, size, 1, file))
printf ("Couldn't write to subcart SRAM file.\n");
fclose(file);
}
@ -2260,8 +2262,8 @@ bool8 CMemory::SaveSRAM (const char *filename)
file = fopen(sramName, "wb");
if (file)
{
size_t ignore;
ignore = fwrite((char *) SRAM, size, 1, file);
if (!fwrite((char *) SRAM, size, 1, file))
printf ("Couldn't write to SRAM file.\n");
fclose(file);
if (Settings.SRTC || Settings.SPC7110RTC)
@ -2289,11 +2291,11 @@ bool8 CMemory::SaveMPAK (const char *filename)
file = fopen(mempakName, "wb");
if (file)
{
size_t ignore;
ignore = fwrite((char *)Memory.ROM + Multi.cartOffsetB, size, 1, file);
size_t written;
written = fwrite((char *)Memory.ROM + Multi.cartOffsetB, size, 1, file);
fclose(file);
return (TRUE);
return (written > 0);
}
}
}

View File

@ -577,8 +577,8 @@ static void flush_movie (void)
write_movie_header(Movie.File, &Movie);
fseek(Movie.File, Movie.ControllerDataOffset, SEEK_SET);
size_t ignore;
ignore = fwrite(Movie.InputBuffer, 1, Movie.BytesPerSample * (Movie.MaxSample + 1), Movie.File);
if (!fwrite(Movie.InputBuffer, 1, Movie.BytesPerSample * (Movie.MaxSample + 1), Movie.File))
printf ("Movie flush failed.\n");
}
static void truncate_movie (void)
@ -589,8 +589,8 @@ static void truncate_movie (void)
if (Movie.SaveStateOffset > Movie.ControllerDataOffset)
return;
int ignore;
ignore = ftruncate(fileno(Movie.File), Movie.ControllerDataOffset + Movie.BytesPerSample * (Movie.MaxSample + 1));
if (ftruncate(fileno(Movie.File), Movie.ControllerDataOffset + Movie.BytesPerSample * (Movie.MaxSample + 1)))
printf ("Couldn't truncate file.\n");
}
static int read_movie_header (FILE *fd, SMovie *movie)
@ -645,7 +645,7 @@ static int read_movie_extrarominfo (FILE *fd, SMovie *movie)
ptr += 3; // zero bytes
movie->ROMCRC32 = Read32(ptr);
strncpy(movie->ROMName, (char *) ptr, 23);
sstrncpy(movie->ROMName, (char *) ptr, 23);
return (SUCCESS);
}
@ -676,8 +676,8 @@ static void write_movie_header (FILE *fd, SMovie *movie)
Write8(movie->PortIDs[p][i], ptr);
}
size_t ignore;
ignore = fwrite(buf, 1, SMV_HEADER_SIZE, fd);
if (!fwrite(buf, 1, SMV_HEADER_SIZE, fd))
printf ("Couldn't write movie header.\n");
}
static void write_movie_extrarominfo (FILE *fd, SMovie *movie)
@ -690,8 +690,7 @@ static void write_movie_extrarominfo (FILE *fd, SMovie *movie)
Write32(movie->ROMCRC32, ptr);
strncpy((char *) ptr, movie->ROMName, 23);
size_t ignore;
ignore = fwrite(buf, 1, SMV_EXTRAROMINFO_SIZE, fd);
fwrite(buf, 1, SMV_EXTRAROMINFO_SIZE, fd);
}
static void change_state (MovieState new_state)
@ -878,8 +877,12 @@ int S9xMovieOpen (const char *filename, bool8 read_only)
Movie.InputBufferPtr = Movie.InputBuffer;
reserve_buffer_space(Movie.BytesPerSample * (Movie.MaxSample + 1));
size_t ignore;
ignore = fread(Movie.InputBufferPtr, 1, Movie.BytesPerSample * (Movie.MaxSample + 1), fd);
if (!fread(Movie.InputBufferPtr, 1, Movie.BytesPerSample * (Movie.MaxSample + 1), fd))
{
printf ("Failed to read from movie file.\n");
fclose(fd);
return (WRONG_FORMAT);
}
// read "baseline" controller data
if (Movie.MaxSample && Movie.MaxFrame)
@ -943,8 +946,8 @@ int S9xMovieCreate (const char *filename, uint8 controllers_mask, uint8 opts, co
meta_buf[i * 2 + 1] = (uint8) ((c >> 8) & 0xff);
}
size_t ignore;
ignore = fwrite(meta_buf, sizeof(uint16), metadata_length, fd);
if (!fwrite(meta_buf, sizeof(uint16), metadata_length, fd))
printf ("Failed writing movie metadata.\n");
}
Movie.ROMCRC32 = Memory.ROMCRC32;
@ -1111,8 +1114,8 @@ void S9xMovieUpdate (bool addFrame)
if (addFrame)
Movie.MaxFrame = ++Movie.CurrentFrame;
size_t ignore;
ignore = fwrite((Movie.InputBufferPtr - Movie.BytesPerSample), 1, Movie.BytesPerSample, Movie.File);
if (!fwrite((Movie.InputBufferPtr - Movie.BytesPerSample), 1, Movie.BytesPerSample, Movie.File))
printf ("Error writing control data.\n");
break;
}
@ -1137,8 +1140,8 @@ void S9xMovieUpdateOnReset (void)
Movie.MaxSample = ++Movie.CurrentSample;
Movie.MaxFrame = ++Movie.CurrentFrame;
size_t ignore;
ignore = fwrite((Movie.InputBufferPtr - Movie.BytesPerSample), 1, Movie.BytesPerSample, Movie.File);
if (!fwrite((Movie.InputBufferPtr - Movie.BytesPerSample), 1, Movie.BytesPerSample, Movie.File))
printf ("Failed writing reset data.\n");
}
}

View File

@ -195,6 +195,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <limits.h>
#ifndef GEKKO
#include <memory.h>
@ -334,6 +335,20 @@ void SetInfoDlgColor(unsigned char, unsigned char, unsigned char);
#endif // __LIBRETRO__
#endif // __WIN32__
inline void ssnprintf(char *dst, size_t size, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
if (vsnprintf(dst, size, fmt, args) >= (int) size)
dst[size - 1] = '\0';
va_end(args);
}
inline void sstrncpy(char *dst, const char *src, size_t size)
{
strncpy(dst, src, size - 1);
dst[size - 1] = '\0';
}
#if defined(__DJGPP) || defined(__WIN32__)
#define SLASH_STR "\\"
#define SLASH_CHAR '\\'

View File

@ -323,8 +323,8 @@ void S9xSA1MainLoop (void)
S9xSA1Trace();
#endif
register uint8 Op;
register struct SOpcodes *Opcodes;
uint8 Op;
struct SOpcodes *Opcodes;
if (SA1.PCBase)
{

View File

@ -1199,7 +1199,7 @@ void S9xResetSaveTimer (bool8 dontsave)
char drive[_MAX_DRIVE + 1], dir[_MAX_DIR + 1], def[_MAX_FNAME + 1], ext[_MAX_EXT + 1];
_splitpath(Memory.ROMFilename, drive, dir, def, ext);
snprintf(filename, PATH_MAX + 1, "%s%s%s.%.*s", S9xGetDirectory(SNAPSHOT_DIR), SLASH_STR, def, _MAX_EXT - 1, "oops");
ssnprintf(filename, PATH_MAX + 1, "%s%s%s.%.*s", S9xGetDirectory(SNAPSHOT_DIR), SLASH_STR, def, _MAX_EXT - 1, "oops");
S9xMessage(S9X_INFO, S9X_FREEZE_FILE_INFO, SAVE_INFO_OOPS);
S9xFreezeGame(filename);
}
@ -2149,7 +2149,6 @@ static bool CheckBlockName(STREAM stream, const char *name, int &len)
{
char buffer[16];
len = 0;
long rewind = FIND_STREAM(stream);
size_t l = READ_STREAM(buffer, 11, stream);
buffer[l] = 0;

View File

@ -210,11 +210,11 @@ static uint8 hrbit_even[256];
void S9xInitTileRenderer (void)
{
register int i;
int i;
for (i = 0; i < 16; i++)
{
register uint32 b = 0;
uint32 b = 0;
#ifdef LSB_FIRST
if (i & 8)
@ -242,8 +242,8 @@ void S9xInitTileRenderer (void)
for (i = 0; i < 256; i++)
{
register uint8 m = 0;
register uint8 s = 0;
uint8 m = 0;
uint8 s = 0;
if (i & 0x80)
s |= 8;
@ -279,7 +279,7 @@ void S9xInitTileRenderer (void)
static uint8 ConvertTile2 (uint8 *pCache, uint32 TileAddr, uint32)
{
register uint8 *tp = &Memory.VRAM[TileAddr];
uint8 *tp = &Memory.VRAM[TileAddr];
uint32 *p = (uint32 *) pCache;
uint32 non_zero = 0;
uint8 line;
@ -288,7 +288,7 @@ static uint8 ConvertTile2 (uint8 *pCache, uint32 TileAddr, uint32)
{
uint32 p1 = 0;
uint32 p2 = 0;
register uint8 pix;
uint8 pix;
DOBIT( 0, 0);
DOBIT( 1, 1);
@ -302,7 +302,7 @@ static uint8 ConvertTile2 (uint8 *pCache, uint32 TileAddr, uint32)
static uint8 ConvertTile4 (uint8 *pCache, uint32 TileAddr, uint32)
{
register uint8 *tp = &Memory.VRAM[TileAddr];
uint8 *tp = &Memory.VRAM[TileAddr];
uint32 *p = (uint32 *) pCache;
uint32 non_zero = 0;
uint8 line;
@ -311,7 +311,7 @@ static uint8 ConvertTile4 (uint8 *pCache, uint32 TileAddr, uint32)
{
uint32 p1 = 0;
uint32 p2 = 0;
register uint8 pix;
uint8 pix;
DOBIT( 0, 0);
DOBIT( 1, 1);
@ -327,7 +327,7 @@ static uint8 ConvertTile4 (uint8 *pCache, uint32 TileAddr, uint32)
static uint8 ConvertTile8 (uint8 *pCache, uint32 TileAddr, uint32)
{
register uint8 *tp = &Memory.VRAM[TileAddr];
uint8 *tp = &Memory.VRAM[TileAddr];
uint32 *p = (uint32 *) pCache;
uint32 non_zero = 0;
uint8 line;
@ -336,7 +336,7 @@ static uint8 ConvertTile8 (uint8 *pCache, uint32 TileAddr, uint32)
{
uint32 p1 = 0;
uint32 p2 = 0;
register uint8 pix;
uint8 pix;
DOBIT( 0, 0);
DOBIT( 1, 1);
@ -364,7 +364,7 @@ static uint8 ConvertTile8 (uint8 *pCache, uint32 TileAddr, uint32)
static uint8 ConvertTile2h_odd (uint8 *pCache, uint32 TileAddr, uint32 Tile)
{
register uint8 *tp1 = &Memory.VRAM[TileAddr], *tp2;
uint8 *tp1 = &Memory.VRAM[TileAddr], *tp2;
uint32 *p = (uint32 *) pCache;
uint32 non_zero = 0;
uint8 line;
@ -378,7 +378,7 @@ static uint8 ConvertTile2h_odd (uint8 *pCache, uint32 TileAddr, uint32 Tile)
{
uint32 p1 = 0;
uint32 p2 = 0;
register uint8 pix;
uint8 pix;
DOBIT( 0, 0);
DOBIT( 1, 1);
@ -392,7 +392,7 @@ static uint8 ConvertTile2h_odd (uint8 *pCache, uint32 TileAddr, uint32 Tile)
static uint8 ConvertTile4h_odd (uint8 *pCache, uint32 TileAddr, uint32 Tile)
{
register uint8 *tp1 = &Memory.VRAM[TileAddr], *tp2;
uint8 *tp1 = &Memory.VRAM[TileAddr], *tp2;
uint32 *p = (uint32 *) pCache;
uint32 non_zero = 0;
uint8 line;
@ -406,7 +406,7 @@ static uint8 ConvertTile4h_odd (uint8 *pCache, uint32 TileAddr, uint32 Tile)
{
uint32 p1 = 0;
uint32 p2 = 0;
register uint8 pix;
uint8 pix;
DOBIT( 0, 0);
DOBIT( 1, 1);
@ -430,7 +430,7 @@ static uint8 ConvertTile4h_odd (uint8 *pCache, uint32 TileAddr, uint32 Tile)
static uint8 ConvertTile2h_even (uint8 *pCache, uint32 TileAddr, uint32 Tile)
{
register uint8 *tp1 = &Memory.VRAM[TileAddr], *tp2;
uint8 *tp1 = &Memory.VRAM[TileAddr], *tp2;
uint32 *p = (uint32 *) pCache;
uint32 non_zero = 0;
uint8 line;
@ -444,7 +444,7 @@ static uint8 ConvertTile2h_even (uint8 *pCache, uint32 TileAddr, uint32 Tile)
{
uint32 p1 = 0;
uint32 p2 = 0;
register uint8 pix;
uint8 pix;
DOBIT( 0, 0);
DOBIT( 1, 1);
@ -458,7 +458,7 @@ static uint8 ConvertTile2h_even (uint8 *pCache, uint32 TileAddr, uint32 Tile)
static uint8 ConvertTile4h_even (uint8 *pCache, uint32 TileAddr, uint32 Tile)
{
register uint8 *tp1 = &Memory.VRAM[TileAddr], *tp2;
uint8 *tp1 = &Memory.VRAM[TileAddr], *tp2;
uint32 *p = (uint32 *) pCache;
uint32 non_zero = 0;
uint8 line;
@ -472,7 +472,7 @@ static uint8 ConvertTile4h_even (uint8 *pCache, uint32 TileAddr, uint32 Tile)
{
uint32 p1 = 0;
uint32 p2 = 0;
register uint8 pix;
uint8 pix;
DOBIT( 0, 0);
DOBIT( 1, 1);
@ -750,8 +750,8 @@ void S9xSelectTileConverter (int depth, bool8 hires, bool8 sub, bool8 mosaic)
#define DRAW_TILE() \
uint8 *pCache; \
register int32 l; \
register uint8 *bp, Pix; \
int32 l; \
uint8 *bp, Pix; \
\
GET_CACHED_TILE(); \
if (IS_BLANK_TILE()) \
@ -845,8 +845,8 @@ void S9xSelectTileConverter (int depth, bool8 hires, bool8 sub, bool8 mosaic)
#define DRAW_TILE() \
uint8 *pCache; \
register int32 l; \
register uint8 *bp, Pix, w; \
int32 l; \
uint8 *bp, Pix, w; \
\
GET_CACHED_TILE(); \
if (IS_BLANK_TILE()) \
@ -957,8 +957,8 @@ void S9xSelectTileConverter (int depth, bool8 hires, bool8 sub, bool8 mosaic)
#define DRAW_TILE() \
uint8 *pCache; \
register int32 l, w; \
register uint8 Pix; \
int32 l, w; \
uint8 Pix; \
\
GET_CACHED_TILE(); \
if (IS_BLANK_TILE()) \
@ -1007,7 +1007,7 @@ void S9xSelectTileConverter (int depth, bool8 hires, bool8 sub, bool8 mosaic)
#define Pix 0
#define DRAW_TILE() \
register uint32 l, x; \
uint32 l, x; \
\
GFX.RealScreenColors = IPPU.ScreenColors; \
GFX.ScreenColors = GFX.ClipColors ? BlackColourMap : GFX.RealScreenColors; \