From 8435c09b6547fe3e22362b5cfda7b7e05c767b01 Mon Sep 17 00:00:00 2001 From: Daryl Date: Sun, 28 Jun 2020 21:24:42 -0600 Subject: [PATCH] BSX rom is now optional. if missing, it will load directly into the game. --- readme.txt | 4 ++-- source/filebrowser.cpp | 9 +++------ source/snes9x/bsx.cpp | 42 +++++++++++++++++++++++++++++++++++------- 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/readme.txt b/readme.txt index 6a723ce..b495a53 100644 --- a/readme.txt +++ b/readme.txt @@ -600,8 +600,8 @@ done you can proceed to run the emulator via the Homebrew Channel. -=[ Satellaview (BS-X) ]=- -Snes9x GX supports loading BS games. The BSX BIOS is required. -Download the English + No DRM BS-X ROM here: +Snes9x GX supports loading BS games. The BSX BIOS is not required. +If you wish to use one, download the English + No DRM BS-X ROM here: https://project.satellaview.org/downloads.htm Put it in your snes9xgx folder, renamed to BS-X.bin. diff --git a/source/filebrowser.cpp b/source/filebrowser.cpp index 8dc2400..28f36eb 100644 --- a/source/filebrowser.cpp +++ b/source/filebrowser.cpp @@ -49,6 +49,7 @@ bool inSz = false; unsigned long SNESROMSize = 0; bool loadingFile = false; +bool bsxBiosLoadFailed; extern bool isBSX(); @@ -377,9 +378,10 @@ static bool IsValidROM() if(p != NULL) { - if (strcasecmp(p, ".smc") == 0 || + if (strcasecmp(p, ".bs") == 0 || strcasecmp(p, ".fig") == 0 || strcasecmp(p, ".sfc") == 0 || + strcasecmp(p, ".smc") == 0 || strcasecmp(p, ".swc") == 0) { if(zippedFilename) free(zippedFilename); @@ -455,8 +457,6 @@ int BrowserLoadSz() return szfiles; } -static bool bsxBiosLoadFailed; - int WiiFileLoader() { size_t size; @@ -531,9 +531,6 @@ int BrowserLoadFile() { ErrorPrompt("Error loading game!"); } - else if(bsxBiosLoadFailed) { - ErrorPrompt("BS-X BIOS file not found!"); - } else { // load SRAM or snapshot diff --git a/source/snes9x/bsx.cpp b/source/snes9x/bsx.cpp index 6bffebc..4f4f504 100644 --- a/source/snes9x/bsx.cpp +++ b/source/snes9x/bsx.cpp @@ -14,6 +14,8 @@ #include "display.h" #include +extern bool bsxBiosLoadFailed; + //#define BSX_DEBUG #define BIOS_SIZE 0x100000 @@ -1209,7 +1211,7 @@ uint8 * S9xGetBasePointerBSX (uint32 address) static bool8 BSX_LoadBIOS (void) { #ifdef GEKKO - return FALSE; // We're not loading the BIOS! + return TRUE; // We're not loading the BIOS! #else FILE *fp; char path[PATH_MAX + 1], name[PATH_MAX + 1]; @@ -1305,7 +1307,7 @@ void S9xInitBSX (void) uint8 *header = r1 ? Memory.ROM + 0x7FC0 : Memory.ROM + 0xFFC0; FlashMode = (header[0x18] & 0xEF) == 0x20 ? FALSE : TRUE; - FlashSize = FLASH_SIZE; + FlashSize = (header[0x19] & 0x20) ? PSRAM_SIZE : FLASH_SIZE; // Fix Block Allocation Flags // (for games that don't have it setup properly, @@ -1374,12 +1376,38 @@ void S9xResetBSX (void) BSX.out_index = 0; memset(BSX.output, 0, sizeof(BSX.output)); - // starting from the bios - BSX.MMC[0x02] = BSX.MMC[0x03] = BSX.MMC[0x05] = BSX.MMC[0x06] = 0x80; - BSX.MMC[0x09] = BSX.MMC[0x0B] = 0x80; + if(bsxBiosLoadFailed) { + BSX.MMC[0x02] = FlashMode ? 0x80: 0; - BSX.MMC[0x07] = BSX.MMC[0x08] = 0x80; - BSX.MMC[0x0E] = 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; + } // default register values BSX.PPU[0x2196 - BSXPPUBASE] = 0x10;