Skip to content

Commit

Permalink
Cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Sep 18, 2021
1 parent 72d32ef commit b631efb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 71 deletions.
65 changes: 5 additions & 60 deletions mednafen/state.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static INLINE void FlipByteOrder(uint8_t *src, uint32_t count)
}
#endif

int32_t smem_read(StateMem *st, void *buffer, uint32_t len)
static int32_t smem_read(StateMem *st, void *buffer, uint32_t len)
{
if ((len + st->loc) > st->len)
return 0;
Expand All @@ -132,7 +132,7 @@ int32_t smem_read(StateMem *st, void *buffer, uint32_t len)
return(len);
}

int32_t smem_write(StateMem *st, void *buffer, uint32_t len)
static int32_t smem_write(StateMem *st, void *buffer, uint32_t len)
{
if ((len + st->loc) > st->malloced)
{
Expand All @@ -152,15 +152,7 @@ int32_t smem_write(StateMem *st, void *buffer, uint32_t len)
return(len);
}

int32_t smem_putc(StateMem *st, int value)
{
uint8_t tmpval = value;
if(smem_write(st, &tmpval, 1) != 1)
return(-1);
return(1);
}

int32_t smem_seek(StateMem *st, uint32_t offset, int whence)
static int32_t smem_seek(StateMem *st, uint32_t offset, int whence)
{
switch(whence)
{
Expand All @@ -181,16 +173,10 @@ int32_t smem_seek(StateMem *st, uint32_t offset, int whence)
return(-1);
}

if(st->loc < 0)
{
st->loc = 0;
return(-1);
}

return(0);
}

int smem_write32le(StateMem *st, uint32_t b)
static int smem_write32le(StateMem *st, uint32_t b)
{
uint8_t s[4];
s[0]=b;
Expand All @@ -200,7 +186,7 @@ int smem_write32le(StateMem *st, uint32_t b)
return((smem_write(st, s, 4)<4)?0:4);
}

int smem_read32le(StateMem *st, uint32_t *b)
static int smem_read32le(StateMem *st, uint32_t *b)
{
uint8_t s[4];

Expand Down Expand Up @@ -356,47 +342,6 @@ static SFORMAT *FindSF(const char *name, SFORMAT *sf)
return NULL;
}

// Fast raw chunk reader
static void DOReadChunk(StateMem *st, SFORMAT *sf)
{
/* Size can sometimes be zero, so also check for the text name.
* These two should both be zero only at the end of a struct.
*/

while(sf->size || sf->name)
{
int32_t bytesize;

if(!sf->size || !sf->v)
{
sf++;
continue;
}

if(sf->size == (uint32_t) ~0) // Link to another SFORMAT struct
{
DOReadChunk(st, (SFORMAT *)sf->v);
sf++;
continue;
}

bytesize = sf->size;

/* Loading raw data, bool types are stored as they appear in memory,
* not as single bytes in the full state format.
*
* In the SFORMAT structure, the size member for bool entries is
* the number of bool elements, not the total in-memory size,
* so we adjust it here.
*/
if(sf->flags & MDFNSTATE_BOOL)
bytesize *= sizeof(bool);

smem_read(st, (uint8_t *)sf->v, bytesize);
sf++;
}
}

static int ReadStateChunk(StateMem *st, SFORMAT *sf, int size)
{
int temp = st->loc;
Expand Down
9 changes: 0 additions & 9 deletions mednafen/state.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ typedef struct
extern "C" {
#endif

/* Eh, we abuse the smem_* in-memory stream code
* in a few other places. :) */
int32_t smem_read(StateMem *st, void *buffer, uint32_t len);
int32_t smem_write(StateMem *st, void *buffer, uint32_t len);
int32_t smem_putc(StateMem *st, int value);
int32_t smem_seek(StateMem *st, uint32_t offset, int whence);
int smem_write32le(StateMem *st, uint32_t b);
int smem_read32le(StateMem *st, uint32_t *b);

int MDFNSS_SaveSM(void *st, int, int, const void*, const void*, const void*);
int MDFNSS_LoadSM(void *st, int, int);

Expand Down
4 changes: 2 additions & 2 deletions mednafen/wswan/v30mz.c
Original file line number Diff line number Diff line change
Expand Up @@ -808,8 +808,8 @@ static void DoOP(uint8 opcode)
}
} OP_EPILOGUE;

OP( 0xd4, i_aam ) { uint32 mult=FETCH; mult=0; I.regs.b[AH] = I.regs.b[AL] / 10; I.regs.b[AL] %= 10; SetSZPF_Word(I.regs.w[AW]); CLK(17); } OP_EPILOGUE;
OP( 0xd5, i_aad ) { uint32 mult=FETCH; mult=0; I.regs.b[AL] = I.regs.b[AH] * 10 + I.regs.b[AL]; I.regs.b[AH] = 0; SetSZPF_Byte(I.regs.b[AL]); CLK(6); } OP_EPILOGUE;
OP( 0xd4, i_aam ) { I.regs.b[AH] = I.regs.b[AL] / 10; I.regs.b[AL] %= 10; SetSZPF_Word(I.regs.w[AW]); CLK(17); } OP_EPILOGUE;
OP( 0xd5, i_aad ) { I.regs.b[AL] = I.regs.b[AH] * 10 + I.regs.b[AL]; I.regs.b[AH] = 0; SetSZPF_Byte(I.regs.b[AL]); CLK(6); } OP_EPILOGUE;
OP( 0xd6, i_setalc ) { I.regs.b[AL] = (CF)?0xff:0x00; CLK(3); } OP_EPILOGUE;
OP( 0xd7, i_trans ) { uint32 dest = (I.regs.w[BW]+I.regs.b[AL])&0xffff; I.regs.b[AL] = GetMemB(DS0, dest); CLK(5); } OP_EPILOGUE;

Expand Down

0 comments on commit b631efb

Please sign in to comment.