Skip to content

Commit

Permalink
Setting to disable BSX BIOS. ConvertTile split into multiple function…
Browse files Browse the repository at this point in the history
…s. A few other changes.
  • Loading branch information
jamsilva committed Sep 28, 2023
1 parent b7ae062 commit 86bab70
Show file tree
Hide file tree
Showing 9 changed files with 526 additions and 439 deletions.
10 changes: 10 additions & 0 deletions libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,16 @@ static void check_variables(bool first_run)
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
frameskip_threshold = strtol(var.value, NULL, 10);

var.key = "chimerasnes_bsx_bios";
var.value = NULL;
Settings.LoadBSXBIOS = false;

if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (!strcmp(var.value, "load"))
Settings.LoadBSXBIOS = true;
}

var.key = "chimerasnes_overclock_cycles";
var.value = NULL;

Expand Down
13 changes: 13 additions & 0 deletions libretro_core_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,19 @@ struct retro_core_option_v2_definition option_defs_us[] =
},
"33"
},
{
"chimerasnes_bsx_bios",
"Load the BSX BIOS",
NULL,
"Many BSX games can run without the BSX BIOS. By disabling it the emulator will boot directly into the game.",
NULL,
NULL,
{
{ "skip", "Skip" },
{ "load", "Load (if available)" },
},
"skip"
},
{
"chimerasnes_overclock_cycles",
"Reduce Slowdown (Unsafe, Restart)",
Expand Down
4 changes: 4 additions & 0 deletions source/bsx.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,10 @@ static bool BSX_LoadBIOS()
const char* dir = GetBIOSDir();
uint32_t dirlen = strlen(dir);
uint32_t slashlen = strlen(SLASH_STR);

if (!Settings.LoadBSXBIOS)
return false;

memcpy(pathp, dir, dirlen);
pathp += dirlen;
memcpy(pathp, SLASH_STR, slashlen);
Expand Down
3 changes: 2 additions & 1 deletion source/chisnes.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ typedef struct
bool Shutdown : 1;
bool SecretOfEvermoreHack : 1;
bool GetSetDMATimingHacks : 1;
uint8_t _SSettings_PAD1 : 2;
bool LoadBSXBIOS : 1;
uint8_t _SSettings_PAD1 : 1;
uint8_t OneCycle;
uint8_t SlowOneCycle;
uint8_t TwoCycles;
Expand Down
3 changes: 3 additions & 0 deletions source/gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "cheats.h"
#include "math.h"
#include "pixform.h"
#include "tile.h"

#define M7 19

Expand Down Expand Up @@ -827,6 +828,7 @@ static void DrawOBJS(bool OnMain, uint8_t D)
int32_t clipcount;
uint32_t Y, Offset;
BG.BitShift = 4;
SelectConvertTile();
BG.TileShift = 5;
BG.TileAddress = PPU.OBJNameBase;
BG.StartPalette = 128;
Expand Down Expand Up @@ -1774,6 +1776,7 @@ static void DrawBackground(uint32_t BGMode, uint32_t bg, uint8_t Z1, uint8_t Z2)
GFX.PixSize = 1;
BG.TileSize = 8 << PPU.BG[bg].BGSize;
BG.BitShift = BitShifts[BGMode][bg];
SelectConvertTile();
BG.TileShift = TileShifts[BGMode][bg];
BG.TileAddress = PPU.BG[bg].NameBase << 1;
BG.NameSelect = 0;
Expand Down
2 changes: 2 additions & 0 deletions source/globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ CMemory* MemoryPtr = NULL;
SPPU PPU;
InternalPPU IPPU;

uint8_t (*ConvertTile)(uint8_t*, uint32_t);

SDMA DMA[8];

uint8_t* HDMAMemPointers[8];
Expand Down
122 changes: 73 additions & 49 deletions source/memmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1722,7 +1722,7 @@ void ApplyROMFixes()
match_na("PRIMAL RAGE") ||
match_na("CLAY FIGHTER") ||
match_na("ClayFighter 2") ||
strncasecmp(Memory.ROMName, "MADDEN", 6) == 0 ||
!strncasecmp(Memory.ROMName, "MADDEN", 6) ||
match_na("NHL") ||
match_na("WeaponLord") ||
match_na("N-Warp Daisakusen") ||
Expand All @@ -1747,42 +1747,43 @@ void ApplyROMFixes()

void APUTimingHacks()
{
if (match_id("CQ ") || /* Stunt Racer FX */
strncmp(Memory.ROMId, "JG", 2) == 0 || /* Illusion of Gaia */
match_na("GAIA GENSOUKI 1 JPN"))
if (match_id("CQ ") || /* Stunt Racer FX */
match_id("JG") || /* Illusion of Gaia */
match_na("GAIA GENSOUKI 1 JPN")) /* Illusion of Gaia J */
IAPU.OneCycle = 13;
else if (!strcmp(Memory.ROMName, "UMIHARAKAWASE"))
else if (!strcmp(Memory.ROMName, "UMIHARAKAWASE")) /* Umihara Kawase */
IAPU.OneCycle = 20;
else if (match_id("AVCJ") || /* RENDERING RANGER R2 */
match_na("THE FISHING MASTER") || /* Mark Davis - needs >= actual APU timing. (21 is .002 Mhz slower) */
!strncmp(Memory.ROMId, "ARF", 3) || /* Star Ocean */
!strncmp(Memory.ROMId, "ATV", 3) || /* Tales of Phantasia */
!strncasecmp(Memory.ROMName, "ActRaiser", 9) || /* Act Raiser 1 & 2 */
match_na("SOULBLAZER - 1 USA") || match_na("SOULBLADER - 1") || /* Soulblazer */
!strncmp(Memory.ROMId, "AQT", 3) || /* Terranigma */
!strncmp(Memory.ROMId, "E9 ", 3) || /* Robotrek */
match_na("SLAP STICK 1 JPN") ||
!strncmp(Memory.ROMId, "APR", 3) || /* ZENNIHON PURORESU2 */
!strncmp(Memory.ROMId, "A4B", 3) || /* Bomberman 4 */
!strncmp(Memory.ROMId, "Y7 ", 3) || /* UFO KAMEN YAKISOBAN */
!strncmp(Memory.ROMId, "Y9 ", 3) || /* Panic Bomber World */
!strncmp(Memory.ROMId, "APB", 3) ||
((!strncmp(Memory.ROMName, "Parlor", 6) ||
match_na("HEIWA Parlor!Mini8") ||
match_na("SANKYO Fever! \xCC\xA8\xB0\xCA\xDE\xB0!")) &&
Memory.CompanyId == 0x168) ||
else if (match_id("AVCJ") || /* Rendering Ranger R2 */
match_na("THE FISHING MASTER") || /* Mark Davis - needs >= actual APU timing. (21 is .002 Mhz slower) */
match_id("ARF") || /* Star Ocean */
match_id("ATV") || /* Tales of Phantasia */
!strncasecmp(Memory.ROMName, "ActRaiser", 9) || /* Act Raiser 1 & 2 */
match_na("SOULBLAZER - 1 USA") || /* Soulblazer */
match_na("SOULBLADER - 1") || /* Soulblazer J */
match_id("AQT") || /* Terranigma */
match_id("E9 ") || /* Robotrek */
match_na("SLAP STICK 1 JPN") || /* Robotrek J */
match_id("APR") || /* ZENNIHON PURORESU2 */
match_id("A4B") || /* Bomberman 4 */
match_id("Y7 ") || /* UFO KAMEN YAKISOBAN */
match_id("Y9 ") || /* Panic Bomber World */
match_id("APB") ||
((match_na("Parlor") ||
match_na("HEIWA Parlor!Mini8") ||
match_na("SANKYO Fever! \xCC\xA8\xB0\xCA\xDE\xB0!")) &&
Memory.CompanyId == 0x168) ||
match_na("DARK KINGDOM") ||
match_na("ZAN3 SFC") ||
match_na("HIOUDEN") ||
match_na("\xC3\xDD\xBC\xC9\xB3\xC0") || /* Tenshi no Uta */
match_na("\xC3\xDD\xBC\xC9\xB3\xC0") || /* Tenshi no Uta */
match_na("FORTUNE QUEST") ||
match_na("FISHING TO BASSING") ||
match_na("TokyoDome '95Battle 7") ||
match_na("OHMONO BLACKBASS") ||
match_na("SWORD WORLD SFC") ||
match_na("MASTERS") || /* Augusta 2 J */
match_na("SFC \xB6\xD2\xDD\xD7\xB2\xC0\xDE\xB0") || /* Kamen Rider */
match_na("LETs PACHINKO(")) /* A set of BS games */
match_na("MASTERS") || /* Harukanaru Augusta 2 */
match_na("SFC \xB6\xD2\xDD\xD7\xB2\xC0\xDE\xB0") || /* Kamen Rider */
match_na("LETs PACHINKO(")) /* A set of Pachinko BSX games */
IAPU.OneCycle = 15;
else
IAPU.OneCycle = DEFAULT_ONE_APU_CYCLE;
Expand All @@ -1794,30 +1795,29 @@ void HDMATimingHacks()
Settings.GetSetDMATimingHacks = false;

/* A Couple of HDMA related hacks - Lantus */
if (match_na("SFX SUPERBUTOUDEN2") ||
match_na("ALIEN vs. PREDATOR") ||
match_na("ALIENS vs. PREDATOR") ||
match_na("STONE PROTECTORS") ||
match_na("SUPER BATTLETANK 2"))
Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 130) / 100;
else if (match_na("HOME IMPROVEMENT"))
Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 200) / 100;
else if (match_id("ASRJ")) /* Street Racer */
if (match_id("ASRJ")) /* Street Racer */
Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 95) / 100;
else if (match_na("\x0bd\x0da\x0b2\x0d4\x0b0\x0bd\x0de"))
Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 101) / 100;
else if (match_id("A3R") || /* Power Rangers Fight */
match_id("AJE")) /* Clock Tower */
Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 103) / 100;
else if (match_id("A9D") || /* Start Trek: Deep Sleep 9 */
match_id("A3M")) /* Mortal Kombat 3. Fixes cut off speech sample */
Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 110) / 100;
else if (match_na("\x0bd\x0da\x0b2\x0d4\x0b0\x0bd\x0de"))
Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 101) / 100;
else if (match_na("ALIEN vs. PREDATOR") ||
match_na("ALIENS vs. PREDATOR") ||
match_na("STONE PROTECTORS") ||
match_na("SUPER BATTLETANK 2"))
Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 130) / 100;
else if (match_na("HOME IMPROVEMENT"))
Settings.H_Max = (SNES_CYCLES_PER_SCANLINE * 200) / 100;

Settings.HBlankStart = (256 * Settings.H_Max) / SNES_MAX_HCOUNTER;

if ((match_na("\?\?\?\?\?\?\?!") && Settings.Chip == DSP_1) || /* Ace O Nerae */
match_na("BATMAN returns") || /* Batman Returns */
match_na("BS ZELDA REMIX")) /* BS Zelda MottZilla */
if ((match_na("??????\?!") && Settings.Chip == DSP_1) || /* Ace O Nerae */
match_na("BATMAN returns") || /* Batman Returns */
match_na("BS ZELDA REMIX")) /* BS Zelda MottZilla */
Settings.GetSetDMATimingHacks = true;
}

Expand All @@ -1839,7 +1839,9 @@ void SA1ShutdownAddressHacks()
SA1.WaitByteAddress1 = Memory.FillRAM + 0x3000;
}
else if (match_id("A2DJ")) /* Derby Jockey 2 (J) */
{
SA1.WaitPC = 0x8b62;
}
else if (match_id("AZIJ")) /* Dragon Ball Z - Hyper Dimension (J) */
{
SA1.WaitPC = 0x8083;
Expand Down Expand Up @@ -1869,14 +1871,23 @@ void SA1ShutdownAddressHacks()
SA1.WaitByteAddress2 = Memory.SRAM + 0x1004;
}
else if (match_id("AITJ")) /* Takemiya Masaki Kudan no Igo Taishou (J) */
{
SA1.WaitPC = 0x80b7;
}
else if (match_id("AJ6J")) /* J. League '96 Dream Stadium (J) */
{
SA1.WaitPC = 0xf74a;
}
else if (match_id("AJUJ")) /* Jumpin' Derby (J) */
{
SA1.WaitPC = 0xd926;
}
else if (match_id("AKAJ")) /* Kakinoki Shougi (J) */
{
SA1.WaitPC = 0xf070;
else if (match_id("AFJJ") || match_id("AFJE")) /* Hoshi no Kirby 3 (J), Kirby's Dream Land 3 (U) */
}
else if (match_id("AFJJ") || /* Hoshi no Kirby 3 (J) */
match_id("AFJE")) /* Kirby's Dream Land 3 (U) */
{
SA1.WaitPC = 0x82d4;
SA1.WaitByteAddress1 = Memory.SRAM + 0x72a4;
Expand All @@ -1893,7 +1904,8 @@ void SA1ShutdownAddressHacks()
SA1.WaitByteAddress1 = Memory.FillRAM + 0x300a;
SA1.WaitByteAddress2 = Memory.FillRAM + 0x300e;
}
else if (match_id("ARWJ") || match_id("ARWE")) /* Super Mario RPG (J), (U) */
else if (match_id("ARWJ") || /* Super Mario RPG (J) */
match_id("ARWE")) /* Super Mario RPG (U) */
{
SA1.WaitPC = 0x816f;
SA1.WaitByteAddress1 = Memory.FillRAM + 0x3000;
Expand All @@ -1909,20 +1921,20 @@ void SA1ShutdownAddressHacks()
SA1.WaitByteAddress1 = Memory.FillRAM + 0x37b4;
}
else if (match_id("AJOJ")) /* Jikkyou Oshaberi Parodius (J) */
{
SA1.WaitPC = 0x84e5;
}
else if (match_id("APBJ")) /* Super Bomberman - Panic Bomber W (J) */
{
SA1.WaitPC = 0x857a;
}
else if (match_id("AONJ")) /* Pebble Beach no Hatou New - Tournament Edition (J) */
{
SA1.WaitPC = 0xdf33;
SA1.WaitByteAddress1 = Memory.FillRAM + 0x37b4;
}
else if (match_id("AEPE")) /* PGA European Tour (U) */
{
SA1.WaitPC = 0x3700;
SA1.WaitByteAddress1 = Memory.FillRAM + 0x3102;
}
else if (match_id("A3GE")) /* PGA Tour 96 (U) */
else if (match_id("AEPE") || /* PGA European Tour (U) */
match_id("A3GE")) /* PGA Tour 96 (U) */
{
SA1.WaitPC = 0x3700;
SA1.WaitByteAddress1 = Memory.FillRAM + 0x3102;
Expand All @@ -1933,32 +1945,44 @@ void SA1ShutdownAddressHacks()
SA1.WaitByteAddress1 = Memory.FillRAM + 0x3000;
}
else if (match_id("AGFJ")) /* SD F-1 Grand Prix (J) */
{
SA1.WaitPC = 0x81bc;
}
else if (match_id("ASYJ")) /* Saikousoku Shikou Shougi Mahjong (J) */
{
SA1.WaitPC = 0xf2cc;
SA1.WaitByteAddress1 = Memory.SRAM + 0x7ffe;
SA1.WaitByteAddress2 = Memory.SRAM + 0x7ffc;
}
else if (match_id("AX2J")) /* Shougi Saikyou II (J) */
{
SA1.WaitPC = 0xd675;
}
else if (match_id("A4WJ")) /* Mini Yonku Shining Scorpion - Let's & Go!! (J) */
{
SA1.WaitPC = 0x48be;
}
else if (match_id("AHJJ")) /* Shin Shougi Club (J) */
{
SA1.WaitPC = 0x002a;
SA1.WaitByteAddress1 = Memory.SRAM + 0x0806;
SA1.WaitByteAddress2 = Memory.SRAM + 0x0808;
}
else if (match_id("AMSJ")) /* ショウギサイキョウ */
{
SA1.WaitPC = 0xCD6A;
}
else if (match_id("IL")) /* ハブメイジンノオモシロショウギ */
{
SA1.WaitPC = 0x8549;
}
else if (match_id("ALXJ")) /* MASOUKISHIN */
{
SA1.WaitPC = 0xEC9C;
SA1.WaitByteAddress1 = Memory.FillRAM + 0x3072;
}
else if (match_id("A3IJ")) /* SUPER SHOGI3 */
{
SA1.WaitPC = 0xF669;
}
}
Loading

0 comments on commit 86bab70

Please sign in to comment.