mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-12-25 02:31:50 +01:00
Optimize code (#1060)
This commit is contained in:
parent
c4633bad27
commit
4e73f18af9
@ -2,7 +2,7 @@
|
||||
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
||||
This file is licensed under the Snes9x License.
|
||||
For further information, consult the LICENSE file in the root directory.
|
||||
\*****************************************************************************/
|
||||
\*****************************************************************************/
|
||||
|
||||
#ifndef _65C816_H_
|
||||
#define _65C816_H_
|
||||
|
@ -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;
|
||||
|
@ -1406,7 +1406,7 @@ bOP(70Slow, RelativeSlow, CheckOverflow(), 0, CheckEmulation())
|
||||
static void Op82 (void)
|
||||
{
|
||||
S9xSetPCBase(ICPU.ShiftedPB + RelativeLong(JUMP));
|
||||
AddCycles(ONE_CYCLE);
|
||||
AddCycles(ONE_CYCLE);
|
||||
}
|
||||
|
||||
static void Op82Slow (void)
|
||||
|
@ -4,7 +4,6 @@
|
||||
For further information, consult the LICENSE file in the root directory.
|
||||
\*****************************************************************************/
|
||||
|
||||
|
||||
#ifndef _CPUOPS_H_
|
||||
#define _CPUOPS_H_
|
||||
|
||||
|
@ -137,7 +137,7 @@ static const char *font[] =
|
||||
" .###. .###. .###. .###. ",
|
||||
" .##. .##. .#####. .#. ",
|
||||
" .#. .#. ..... . ",
|
||||
" . . ",
|
||||
" . . ",
|
||||
" ",
|
||||
//2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678/2345678
|
||||
" ",
|
||||
|
@ -793,7 +793,7 @@ static void DrawOBJS (int D)
|
||||
BG.InterlaceLine = GFX.InterlaceFrame ? 8 : 0;
|
||||
GFX.Z1 = 2;
|
||||
int sprite_limit = (Settings.MaxSpriteTilesPerLine == 128) ? 128 : 32;
|
||||
|
||||
|
||||
for (uint32 Y = GFX.StartY, Offset = Y * GFX.PPL; Y <= GFX.EndY; Y++, Offset += GFX.PPL)
|
||||
{
|
||||
int I = 0;
|
||||
|
@ -1421,7 +1421,7 @@ bool8 CMemory::LoadROM (const char *filename)
|
||||
return FALSE;
|
||||
|
||||
S9xResetSaveTimer(FALSE); // reset oops timer here so that .oops file has rom name of previous rom
|
||||
|
||||
|
||||
int32 totalFileSize;
|
||||
|
||||
do
|
||||
@ -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)
|
||||
@ -2621,8 +2621,8 @@ void CMemory::InitROM (void)
|
||||
Settings.DisplayColor = BUILD_PIXEL(31, 31, 0);
|
||||
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);
|
||||
@ -3228,7 +3228,7 @@ void CMemory::Map_SA1LoROMMap (void)
|
||||
SA1.WriteMap[c + 0] = SA1.WriteMap[c + 0x800] = FillRAM + 0x3000;
|
||||
SA1.WriteMap[c + 1] = SA1.WriteMap[c + 0x801] = (uint8 *) MAP_NONE;
|
||||
}
|
||||
|
||||
|
||||
// SA-1 Banks 40->4f
|
||||
for (int c = 0x400; c < 0x500; c++)
|
||||
SA1.Map[c] = SA1.WriteMap[c] = (uint8*)MAP_HIROM_SRAM;
|
||||
@ -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"))
|
||||
{
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -786,7 +786,7 @@ uint8 S9xSA1GetByte (uint32 address)
|
||||
|
||||
case CMemory::MAP_BWRAM_BITMAP:
|
||||
SA1.Cycles += ONE_CYCLE * 2;
|
||||
|
||||
|
||||
address -= 0x600000;
|
||||
if (SA1.VirtualBitmapFormat == 2)
|
||||
return ((Memory.SRAM[(address >> 2) & 0x3ffff] >> ((address & 3) << 1)) & 3);
|
||||
@ -795,7 +795,7 @@ uint8 S9xSA1GetByte (uint32 address)
|
||||
|
||||
case CMemory::MAP_BWRAM_BITMAP2:
|
||||
SA1.Cycles += ONE_CYCLE * 2;
|
||||
|
||||
|
||||
address = (address & 0xffff) - 0x6000;
|
||||
if (SA1.VirtualBitmapFormat == 2)
|
||||
return ((SA1.BWRAM[(address >> 2) & 0x3ffff] >> ((address & 3) << 1)) & 3);
|
||||
|
@ -125,6 +125,7 @@ void S9xSA1MainLoop (void)
|
||||
S9xSA1Opcode_IRQ();
|
||||
}
|
||||
}
|
||||
|
||||
#undef CPU
|
||||
int cycles = CPU.Cycles * 3;
|
||||
#define CPU SA1
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user