Optimize code (#1060)

This commit is contained in:
bladeoner 2023-03-17 17:14:53 +01:00 committed by GitHub
parent c4633bad27
commit 4e73f18af9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 27 additions and 58 deletions

View File

@ -1307,7 +1307,7 @@ void S9xInitBSX (void)
uint8 *header = r1 ? Memory.ROM + 0x7FC0 : Memory.ROM + 0xFFC0;
FlashMode = (header[0x18] & 0xEF) == 0x20 ? FALSE : TRUE;
FlashSize = (header[0x19] & 0x20) ? PSRAM_SIZE : FLASH_SIZE;
FlashSize = FLASH_SIZE;
// Fix Block Allocation Flags
// (for games that don't have it setup properly,
@ -1376,38 +1376,12 @@ void S9xResetBSX (void)
BSX.out_index = 0;
memset(BSX.output, 0, sizeof(BSX.output));
if(bsxBiosLoadFailed) {
BSX.MMC[0x02] = FlashMode ? 0x80: 0;
// starting from the bios
BSX.MMC[0x02] = BSX.MMC[0x03] = BSX.MMC[0x05] = BSX.MMC[0x06] = 0x80;
BSX.MMC[0x09] = BSX.MMC[0x0B] = 0x80;
// per bios: run from psram or flash card
if (FlashSize == PSRAM_SIZE)
{
memcpy(PSRAM, FlashROM, PSRAM_SIZE);
BSX.MMC[0x01] = 0x80;
BSX.MMC[0x03] = 0x80;
BSX.MMC[0x04] = 0x80;
BSX.MMC[0x0C] = 0x80;
BSX.MMC[0x0D] = 0x80;
}
else
{
BSX.MMC[0x03] = 0x80;
BSX.MMC[0x05] = 0x80;
BSX.MMC[0x06] = 0x80;
BSX.MMC[0x09] = BSX.MMC[0x0B] = 0x80;
}
BSX.MMC[0x0E] = 0x80;
}
else {
// starting from the bios
BSX.MMC[0x02] = BSX.MMC[0x03] = BSX.MMC[0x05] = BSX.MMC[0x06] = 0x80;
BSX.MMC[0x09] = BSX.MMC[0x0B] = 0x80;
BSX.MMC[0x07] = BSX.MMC[0x08] = 0x80;
BSX.MMC[0x0E] = 0x80;
}
BSX.MMC[0x07] = BSX.MMC[0x08] = 0x80;
BSX.MMC[0x0E] = 0x80;
// default register values
BSX.PPU[0x2196 - BSXPPUBASE] = 0x10;

View File

@ -4,7 +4,6 @@
For further information, consult the LICENSE file in the root directory.
\*****************************************************************************/
#ifndef _CPUOPS_H_
#define _CPUOPS_H_

View File

@ -137,7 +137,7 @@ static const char *font[] =
" .###. .###. .###. .###. ",
" .##. .##. .#####. .#. ",
" .#. .#. ..... . ",
" . . ",
" . . ",
" ",
//2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678
" ",

View File

@ -1925,7 +1925,7 @@ bool8 CMemory::LoadSRTC (void)
return (FALSE);
if (fread(RTCData.reg, 1, 20, fp) < 20)
memset (RTCData.reg, 0, 20);
memset (RTCData.reg, 0, 20);
fclose(fp);
return (TRUE);
@ -1955,7 +1955,7 @@ void CMemory::ClearSRAM (bool8 onlyNonSavedSRAM)
return;
// TODO: If SRAM size changes change this value as well
memset(SRAM, SNESGameFixes.SRAMInitialValue, (32,0x80000));
memset(SRAM, SNESGameFixes.SRAMInitialValue, 0x80000);
}
bool8 CMemory::LoadSRAM (const char *filename)
@ -2622,7 +2622,7 @@ void CMemory::InitROM (void)
SET_UI_COLOR(255, 255, 0);
}
// Use slight blue tint to indicate ROM was patched.
// Use slight blue tint to indicate ROM was patched.
if (Settings.IsPatched)
{
Settings.DisplayColor = BUILD_PIXEL(26, 26, 31);
@ -3769,7 +3769,6 @@ void CMemory::ApplyROMFixes (void)
if (Timings.DMACPUSync != 18)
printf("DMA sync: %d\n", Timings.DMACPUSync);
// SRAM initial value
if (match_na("HITOMI3"))
{

View File

@ -393,7 +393,7 @@ static void flush_movie (void)
fseek(Movie.File, Movie.ControllerDataOffset, SEEK_SET);
if (!fwrite(Movie.InputBuffer, 1, Movie.BytesPerSample * (Movie.MaxSample + 1), Movie.File))
printf ("Movie flush failed.\n");
printf ("Movie flush failed.\n");
}
static void truncate_movie (void)
@ -405,7 +405,7 @@ static void truncate_movie (void)
return;
if (ftruncate(fileno(Movie.File), Movie.ControllerDataOffset + Movie.BytesPerSample * (Movie.MaxSample + 1)))
printf ("Couldn't truncate file.\n");
printf ("Couldn't truncate file.\n");
}
static int read_movie_header (FILE *fd, SMovie *movie)
@ -492,7 +492,7 @@ static void write_movie_header (FILE *fd, SMovie *movie)
}
if (!fwrite(buf, 1, SMV_HEADER_SIZE, fd))
printf ("Couldn't write movie header.\n");
printf ("Couldn't write movie header.\n");
}
static void write_movie_extrarominfo (FILE *fd, SMovie *movie)
@ -762,7 +762,7 @@ int S9xMovieCreate (const char *filename, uint8 controllers_mask, uint8 opts, co
}
if (!fwrite(meta_buf, sizeof(uint16), metadata_length, fd))
printf ("Failed writing movie metadata.\n");
printf ("Failed writing movie metadata.\n");
}
Movie.ROMCRC32 = Memory.ROMCRC32;
@ -930,7 +930,7 @@ void S9xMovieUpdate (bool addFrame)
Movie.MaxFrame = ++Movie.CurrentFrame;
if (!fwrite((Movie.InputBufferPtr - Movie.BytesPerSample), 1, Movie.BytesPerSample, Movie.File))
printf ("Error writing control data.\n");
printf ("Error writing control data.\n");
break;
}
@ -956,7 +956,7 @@ void S9xMovieUpdateOnReset (void)
Movie.MaxFrame = ++Movie.CurrentFrame;
if (!fwrite((Movie.InputBufferPtr - Movie.BytesPerSample), 1, Movie.BytesPerSample, Movie.File))
printf ("Failed writing reset data.\n");
printf ("Failed writing reset data.\n");
}
}

View File

@ -99,11 +99,7 @@ __extension__
#endif
typedef long long int64;
typedef unsigned long long uint64;
#ifdef PTR_NOT_INT
typedef size_t pint;
#else // __PTR_NOT_INT
typedef size_t pint;
#endif // __PTR_NOT_INT
#endif // __WIN32__
#endif // HAVE_STDINT_H
#endif // snes9x_types_defined

View File

@ -125,6 +125,7 @@ void S9xSA1MainLoop (void)
S9xSA1Opcode_IRQ();
}
}
#undef CPU
int cycles = CPU.Cycles * 3;
#define CPU SA1

View File

@ -305,9 +305,9 @@ struct SSettings
bool8 OpenGLEnable;
float SuperFXSpeedPerLine;
bool8 SeparateEchoBuffer;
bool8 SeparateEchoBuffer;
uint32 SuperFXClockMultiplier;
int OverclockMode;
int OverclockMode;
int OneClockCycle;
int OneSlowClockCycle;
int TwoClockCycles;