Commit c4638561 authored by Libretro-Admin's avatar Libretro-Admin
Browse files

Cleanups

parent b0560403
Pipeline #18072 passed with stages
in 1 minute and 25 seconds
......@@ -516,7 +516,7 @@ void retro_get_system_av_info(struct retro_system_av_info *info)
info->geometry.aspect_ratio = MEDNAFEN_CORE_GEOMETRY_ASPECT_RATIO;
}
void retro_deinit()
void retro_deinit(void)
{
if (surf)
{
......
......@@ -627,15 +627,12 @@ int MDFNI_SetCheat(uint32 which, const char *name, uint32 a, uint64 v, uint64 co
if(name)
{
char *t;
char *t;
if((t=(char *)realloc(next->name,strlen(name+1))))
{
next->name=t;
strcpy(next->name,name);
}
else
return(0);
if(!(t=(char *)realloc(next->name,strlen(name)+1)))
return 0;
next->name=t;
strcpy(next->name,name);
}
next->addr=a;
next->val=v;
......
......@@ -84,12 +84,6 @@ int32_t smem_seek(StateMem *st, uint32_t offset, int whence)
return(-1);
}
if(st->loc < 0)
{
st->loc = 0;
return(-1);
}
return(0);
}
......@@ -137,9 +131,7 @@ static bool SubWrite(StateMem *st, SFORMAT *sf, const char *name_prefix = NULL)
int32_t bytesize = sf->size;
char nameo[1 + 256];
int slen;
slen = snprintf(nameo + 1, 256, "%s%s", name_prefix ? name_prefix : "", sf->name);
int slen = snprintf(nameo + 1, 256, "%s%s", name_prefix ? name_prefix : "", sf->name);
nameo[0] = slen;
smem_write(st, nameo, 1 + nameo[0]);
......@@ -168,7 +160,6 @@ static bool SubWrite(StateMem *st, SFORMAT *sf, const char *name_prefix = NULL)
for(int32_t bool_monster = 0; bool_monster < bytesize; bool_monster++)
{
uint8_t tmp_bool = ((bool *)sf->v)[bool_monster];
//printf("Bool write: %.31s\n", sf->name);
smem_write(st, &tmp_bool, 1);
}
}
......@@ -207,11 +198,6 @@ static int WriteStateChunk(StateMem *st, const char *sname, SFORMAT *sf)
memset(sname_tmp, 0, sizeof(sname_tmp));
memcpy((char *)sname_tmp, sname, (sname_len < 32) ? sname_len : 32);
#ifndef NDEBUG
if(sname_len > 32)
printf("Warning: section name is too long: %s\n", sname);
#endif
smem_write(st, sname_tmp, 32);
smem_write32le(st, 0); // We'll come back and write this later.
......@@ -302,16 +288,10 @@ static int ReadStateChunk(StateMem *st, SFORMAT *sf, int size)
uint8_t toa[1 + 256]; // Don't change to char unless cast toa[0] to unsigned to smem_read() and other places.
if(smem_read(st, toa, 1) != 1)
{
puts("Unexpected EOF");
return(0);
}
if(smem_read(st, toa + 1, toa[0]) != toa[0])
{
puts("Unexpected EOF?");
return 0;
}
toa[1 + toa[0]] = 0;
......@@ -325,12 +305,8 @@ static int ReadStateChunk(StateMem *st, SFORMAT *sf, int size)
if(recorded_size != expected_size)
{
printf("Variable in save state wrong size: %s. Need: %d, got: %d\n", toa + 1, expected_size, recorded_size);
if(smem_seek(st, recorded_size, SEEK_CUR) < 0)
{
puts("Seek error");
return(0);
}
}
else
{
......@@ -358,12 +334,8 @@ static int ReadStateChunk(StateMem *st, SFORMAT *sf, int size)
}
else
{
printf("Unknown variable in save state: %s\n", toa + 1);
if(smem_seek(st, recorded_size, SEEK_CUR) < 0)
{
puts("Seek error");
return(0);
}
}
} // while(...)
......@@ -395,32 +367,20 @@ static int MDFNSS_StateAction_internal(void *st_p, int load, int data_only, SSDe
if(!strncmp(sname, section->name, 32))
{
if(!ReadStateChunk(st, section->sf, tmp_size))
{
printf("Error reading chunk: %s\n", section->name);
return(0);
}
found = 1;
break;
}
else
{
if(smem_seek(st, tmp_size, SEEK_CUR) < 0)
{
puts("Chunk seek failure");
return(0);
}
}
}
if(smem_seek(st, -total, SEEK_CUR) < 0)
{
puts("Reverse seek error");
return(0);
}
if(!found && !section->optional) // Not found. We are sad!
{
printf("Section missing: %.32s\n", section->name);
return(0);
}
}
else
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment