Skip to content

Commit

Permalink
beta 10.6
Browse files Browse the repository at this point in the history
  • Loading branch information
DerKoun committed Jun 17, 2021
1 parent d2d7815 commit de27b9e
Show file tree
Hide file tree
Showing 19 changed files with 288 additions and 92 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- name: Setup
run: |
sudo apt-get update
sudo apt-get -y install build-essential libgtk2.0-dev libpulse-dev mesa-common-dev libgtksourceview2.0-dev libcairo2-dev libsdl2-dev libxv-dev libao-dev libopenal-dev libudev-dev
sudo apt-get -y install build-essential libgtk2.0-dev libpulse-dev mesa-common-dev libcairo2-dev libsdl2-dev libxv-dev libao-dev libopenal-dev libudev-dev
- name: Build
run: make -j $(nproc) -C bsnes
- name: Prepare artifacts
Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
- name: Setup
run: |
sudo apt-get update
sudo apt-get -y install build-essential libgtk2.0-dev libpulse-dev mesa-common-dev libgtksourceview2.0-dev libcairo2-dev libsdl2-dev libxv-dev libao-dev libopenal-dev libudev-dev
sudo apt-get -y install build-essential libgtk2.0-dev libpulse-dev mesa-common-dev libcairo2-dev libsdl2-dev libxv-dev libao-dev libopenal-dev libudev-dev
- name: Build
run: make -j $(nproc) -C bsnes target=libretro
- name: Prepare artifacts
Expand Down
32 changes: 18 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# bsnes-hd *beta 10.5*
# bsnes-hd *beta 10.6*

- [downloads](https://github.com/DerKoun/bsnes-hd/releases) for the latest betas (there are only beta) / also on the libretro auto-updater
- [GitHub project](https://github.com/DerKoun/bsnes-hd) for source code, issues, feature requests, ...
Expand All @@ -19,8 +19,8 @@ bsnes-hd (called "*HD Mode 7 mod, for bsnes*" in early betas) is a fork of bsnes
### HD Mode 7

Rendering the rotated, scaled or pseudo perspective backgrounds at higher resolutions. This does not involve new custom imagery or upscaling algorithms. It is a higher resolution version of the process the SNES uses.
- [image comparison](http://www.framecompare.com/image-compare/screenshotcomparison/EB9MNNNU) (framecompare)
- [video comparison](https://www.youtube.com/watch?v=6VrzJ6Y1kjQ) by *reznoire* (youtube)
- [video demo](https://www.youtube.com/watch?v=IW7VOQKxtUQ) by *Emulators & Gameplay HD* (youtube)

### Widescreen

Expand Down Expand Up @@ -193,18 +193,22 @@ The file must contain alternating letters and numbers, each pair overriding a se

#### Settings

| Description | Letter | Values |
| ----------------------------------- | ------- | ----------------------------------------------- |
| widescreen mode | w | 0:off 1:on(always) 2:on(mode7) |
| widescreen sprites | s | 0:safe 1:unsafe(widescreen) 2:clip |
| widescreen aspect ratio | W | 0-200:widescreen-extension 201+:AR(*see below*) |
| widescreen background 1/2/3/4 | b/B/c/C | 0+:WS 10+:crop 20:disab 1000+:line(*see below*) |
| widescreen marker | m | 0:off 1+:line 11+:darken (*see below*) |
| mode 7 perspective correction | P | 0:off 1-3:auto 4-6+:on (*see below*) |
| ignore window | i | 0:none 1:outside 2:outside&always 3:all |
| ignore window fallback x-coordinate | I | 0-255:x-coordinate |
| overclock CPU | O | 100+:percentage(100 is normal) |
| stretch windowing | S | (*for widescreen patches only*, *see below*) |
| Description | Letter | Values |
| ----------------------------------- | ------- | ------------------------------------------------ |
| widescreen mode | w | 0:off 1:on(always) 2:on(mode7) |
| widescreen sprites | s | 0:safe 1:unsafe(widescreen) 2:clip |
| widescreen aspect ratio | W | 0-200:widescreen-extension 201+:AR (*see below*) |
| widescreen background 1/2/3/4 | b/B/c/C | 0+:WS 10+:crop 20:disab 1000+:line (*see below*) |
| widescreen marker | m | 0:off 1+:line 11+:darken (*see below*) |
| mode 7 perspective correction | P | 0:off 1-3:auto 4-6+:on (*see below*) |
| scale factor | f | 0:off 1-10:factor |
| disable sprite limit | l | 0:off 1:on |
| ignore window | i | 0:none 1:outside 2:outside&always 3:all |
| ignore window fallback x-coordinate | I | 0-255:x-coordinate |
| overclock CPU | O | 100+:percentage(100 is normal) |
| stretch windowing | S | (*for widescreen patches only*, *see below*) |
| pixel aspect ratio correction | p | 0:off 1:on (*libretro only*) |
| overscan | o | 0:off(216 / 5th HD) 1:on(224) (*libretro only*) |

#### Widescreen Aspect Ratio values

Expand Down
2 changes: 1 addition & 1 deletion bsnes/emulator/emulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ using namespace nall;

namespace Emulator {
static const string Name = "bsnes-hd beta";
static const string Version = "10.5";//bsnes/target-bsnes/presentation/presentation.cpp:create:about:setVersion
static const string Version = "10.6";//bsnes/target-bsnes/presentation/presentation.cpp:create:about:setVersion
static const string Author = "DerKoun(Near)";
static const string License = "GPLv3";
static const string Website = "https://github.com/DerKoun/bsnes-hd";
Expand Down
40 changes: 32 additions & 8 deletions bsnes/heuristics/super-famicom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,13 +433,7 @@ auto SuperFamicom::serial() const -> string {
}

auto SuperFamicom::romSize() const -> uint {
//subtract appended firmware size, if firmware is present
if((size() & 0x7fff) == 0x100) return size() - 0x100;
if((size() & 0x7fff) == 0xc00) return size() - 0xc00;
if((size() & 0x7fff) == 0x2000) return size() - 0x2000;
if((size() & 0xffff) == 0xd000) return size() - 0xd000;
if((size() & 0x3ffff) == 0x28000) return size() - 0x28000;
return size();
return size() - firmwareRomSize();
}

auto SuperFamicom::programRomSize() const -> uint {
Expand All @@ -459,8 +453,38 @@ auto SuperFamicom::expansionRomSize() const -> uint {
return 0;
}

//detect if any firmware is appended to the ROM image, and return its size if so
auto SuperFamicom::firmwareRomSize() const -> uint {
return size() - romSize();
auto cartridgeTypeLo = data[headerAddress + 0x26] & 15;
auto cartridgeTypeHi = data[headerAddress + 0x26] >> 4;
auto cartridgeSubType = data[headerAddress + 0x0f];

if(serial() == "042J" || (cartridgeTypeLo == 0x3 && cartridgeTypeHi == 0xe)) {
//Game Boy
if((size() & 0x7fff) == 0x100) return 0x100;
}

if(cartridgeTypeLo >= 0x3 && cartridgeTypeHi == 0xf && cartridgeSubType == 0x10) {
//Hitachi HG51BS169
if((size() & 0x7fff) == 0xc00) return 0xc00;
}

if(cartridgeTypeLo >= 0x3 && cartridgeTypeHi == 0x0) {
//NEC uPD7725
if((size() & 0x7fff) == 0x2000) return 0x2000;
}

if(cartridgeTypeLo >= 0x3 && cartridgeTypeHi == 0xf && cartridgeSubType == 0x01) {
//NEC uPD96050
if((size() & 0xffff) == 0xd000) return 0xd000;
}

if(cartridgeTypeLo >= 0x3 && cartridgeTypeHi == 0xf && cartridgeSubType == 0x02) {
//ARM6
if((size() & 0x3ffff) == 0x28000) return 0x28000;
}

return 0;
}

auto SuperFamicom::ramSize() const -> uint {
Expand Down
1 change: 1 addition & 0 deletions bsnes/sfc/interface/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ auto Configuration::process(Markup::Node document, bool load) -> void {
bind(natural, "Hacks/PPU/Mode7/Igwin", hacks.ppu.mode7.igwin);
bind(natural, "Hacks/PPU/Mode7/Igwinx", hacks.ppu.mode7.igwinx);
bind(boolean, "Hacks/PPU/Mode7/Strwin", hacks.ppu.mode7.strwin);
bind(natural, "Hacks/PPU/Mode7/VramExt", hacks.ppu.mode7.vramExt);
bind(natural, "Hacks/PPU/Mode7/BgGrad", hacks.ppu.mode7.bgGrad);
bind(natural, "Hacks/PPU/Mode7/WindRad", hacks.ppu.mode7.windRad);
bind(natural, "Hacks/PPU/Mode7/WsMode", hacks.ppu.mode7.wsMode);
Expand Down
1 change: 1 addition & 0 deletions bsnes/sfc/interface/configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ struct Configuration {
uint igwin = 1;
uint igwinx = 128;
bool strwin = false;
uint vramExt = 0x7fff;
uint bgGrad = 4;
uint windRad = 0;
uint wsMode = 1;
Expand Down
4 changes: 2 additions & 2 deletions bsnes/sfc/ppu-fast/background.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ auto PPU::Line::renderBackground(PPU::IO::Background& self, uint8 source) -> voi
tileNumber = (tileNumber & 0x03ff) + tiledataIndex & tileMask;

uint16 address;
address = (tileNumber << colorShift) + (voffset & 7 ^ mirrorY) & 0x7fff;
address = ppu.vramExt((tileNumber << colorShift) + (voffset & 7 ^ mirrorY)) /*& 0x7fff*/;

uint64 data;
data = (uint64)ppu.vram[address + 0] << 0;
Expand Down Expand Up @@ -196,5 +196,5 @@ auto PPU::Line::getTile(PPU::IO::Background& self, uint hoffset, uint voffset) -
uint offset = (tileY & 0x1f) << 5 | (tileX & 0x1f);
if(tileX & 0x20) offset += screenX;
if(tileY & 0x20) offset += screenY;
return ppu.vram[self.screenAddress + offset & 0x7fff];
return ppu.vram[ppu.vramExt(self.screenAddress + offset) /*& 0x7fff*/];
}
24 changes: 12 additions & 12 deletions bsnes/sfc/ppu-fast/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ auto PPU::latchCounters() -> void {
auto PPU::vramAddress() const -> uint {
uint address = io.vramAddress;
switch(io.vramMapping) {
case 0: return address & 0x7fff;
case 1: return address & 0x7f00 | address << 3 & 0x00f8 | address >> 5 & 7;
case 2: return address & 0x7e00 | address << 3 & 0x01f8 | address >> 6 & 7;
case 3: return address & 0x7c00 | address << 3 & 0x03f8 | address >> 7 & 7;
case 0: return ppu.vramExt(address & 0xffff /*0x7fff*/);
case 1: return ppu.vramExt(address & 0xff00 /*0x7f00*/| address << 3 & 0x00f8 | address >> 5 & 7);
case 2: return ppu.vramExt(address & 0xfe00 /*0x7e00*/| address << 3 & 0x01f8 | address >> 6 & 7);
case 3: return ppu.vramExt(address & 0xfc00 /*0x7c00*/| address << 3 & 0x03f8 | address >> 7 & 7);
}
unreachable;
}
Expand Down Expand Up @@ -263,37 +263,37 @@ auto PPU::writeIO(uint address, uint8 data) -> void {

case 0x2107: { //BG1SC
io.bg1.screenSize = data >> 0 & 3;
io.bg1.screenAddress = data << 8 & 0x7c00;
io.bg1.screenAddress = ppu.vramExt(data << 8 & 0xfc00) /*0x7c00*/;
return;
}

case 0x2108: { //BG2SC
io.bg2.screenSize = data >> 0 & 3;
io.bg2.screenAddress = data << 8 & 0x7c00;
io.bg2.screenAddress = ppu.vramExt(data << 8 & 0xfc00) /*0x7c00*/;
return;
}

case 0x2109: { //BG3SC
io.bg3.screenSize = data >> 0 & 3;
io.bg3.screenAddress = data << 8 & 0x7c00;
io.bg3.screenAddress = ppu.vramExt(data << 8 & 0xfc00) /*0x7c00*/;
return;
}

case 0x210a: { //BG4SC
io.bg4.screenSize = data >> 0 & 3;
io.bg4.screenAddress = data << 8 & 0x7c00;
io.bg4.screenAddress = ppu.vramExt(data << 8 & 0xfc00) /*0x7c00*/;
return;
}

case 0x210b: { //BG12NBA
io.bg1.tiledataAddress = data << 12 & 0x7000;
io.bg2.tiledataAddress = data << 8 & 0x7000;
io.bg1.tiledataAddress = ppu.vramExt(data << 12 & 0xf000) /*0x7000*/;
io.bg2.tiledataAddress = ppu.vramExt(data << 8 & 0xf000) /*0x7000*/;
return;
}

case 0x210c: { //BG34NBA
io.bg3.tiledataAddress = data << 12 & 0x7000;
io.bg4.tiledataAddress = data << 8 & 0x7000;
io.bg3.tiledataAddress = ppu.vramExt(data << 12 & 0xf000) /*0x7000*/;
io.bg4.tiledataAddress = ppu.vramExt(data << 8 & 0xf000) /*0x7000*/;
return;
}

Expand Down
2 changes: 1 addition & 1 deletion bsnes/sfc/ppu-fast/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ auto PPU::Line::renderObject(PPU::IO::Object& self) -> void {

uint mirrorX = !object.hflip ? tileX : tileWidth - 1 - tileX;
uint address = tiledataAddress + ((characterY + (characterX + mirrorX & 15)) << 4);
address = (address & 0x7ff0) + (y & 7);
address = ppu.vramExt((address & 0xfff0 /*0x7ff0*/) + (y & 7));
tile.data = ppu.vram[address + 0] << 0;
tile.data |= ppu.vram[address + 8] << 16;

Expand Down
1 change: 1 addition & 0 deletions bsnes/sfc/ppu-fast/ppu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ auto PPU::winXadHd(uint x, bool bel) const -> uint {
|| configuration.hacks.ppu.mode7.igwin >= 1 && ((bel ? io.col.window.belowMask : io.col.window.aboveMask) == 2)))
? configuration.hacks.ppu.mode7.igwinx * PPU::hdScale() : x; }
auto PPU::strwin() const -> bool { return configuration.hacks.ppu.mode7.strwin; }
auto PPU::vramExt(uint addr) const -> uint { return addr & configuration.hacks.ppu.mode7.vramExt; }
auto PPU::bgGrad() const -> uint { return !hd() ? 0 : configuration.hacks.ppu.mode7.bgGrad; }
auto PPU::windRad() const -> uint { return !hd() ? 0 : configuration.hacks.ppu.mode7.windRad; }
auto PPU::wsOverrideCandidate() const -> bool { return configuration.hacks.ppu.mode7.wsMode == 1; }
Expand Down
4 changes: 2 additions & 2 deletions bsnes/sfc/ppu-fast/ppu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//limitations:
//* mid-scanline effects not support
//* vertical mosaic coordinates are not exact
//* (hardware-mod) 128KB VRAM mode not supported

#define PPU PPUfast

Expand All @@ -25,6 +24,7 @@ struct PPU : PPUcounter {
alwaysinline auto winXad(uint x, bool bel) const -> uint;
alwaysinline auto winXadHd(uint x, bool bel) const -> uint;
alwaysinline auto strwin() const -> bool;
alwaysinline auto vramExt(uint addr) const -> uint;
alwaysinline auto bgGrad() const -> uint;
alwaysinline auto windRad() const -> uint;
alwaysinline auto wsOverrideCandidate() const -> bool;
Expand Down Expand Up @@ -287,7 +287,7 @@ struct PPU : PPUcounter {
Latch latch;
IO io;

uint16 vram[32 * 1024] = {};
uint16 vram[32 * 1024 * 2] = {}; //0-ffff
uint16 cgram[256] = {};
Object objects[128] = {};

Expand Down
27 changes: 21 additions & 6 deletions bsnes/target-bsnes/program/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,23 @@ auto Program::loadSuperFamicom(string location) -> bool {
rom.resize(rom.size() - 512);
}

if(!superFamicom.patched) superFamicom.patched = applyPatchIPS(rom, location);
if(!superFamicom.patched) superFamicom.patched = applyPatchBPS(rom, location);
if (!superFamicom.patched) {
bool p = applyPatchBPS(rom, location, "") || applyPatchIPS(rom, location, "");
superFamicom.patched = p;
if (p) {
p = applyPatchBPS(rom, location, "1") || applyPatchIPS(rom, location, "1");
if (p) {
p = applyPatchBPS(rom, location, "2") || applyPatchIPS(rom, location, "2");
if (p) {
p = applyPatchBPS(rom, location, "3") || applyPatchIPS(rom, location, "3");
if (p) {
p = applyPatchBPS(rom, location, "4") || applyPatchIPS(rom, location, "4");
}
}
}
}
}

auto heuristics = Heuristics::SuperFamicom(rom, location);
auto sha256 = Hash::SHA256(rom).digest();
superFamicom.title = heuristics.title();
Expand Down Expand Up @@ -199,7 +214,7 @@ auto Program::loadGameBoy(string location) -> bool {
}
if(rom.size() < 0x4000) return false;

gameBoy.patched = applyPatchIPS(rom, location) || applyPatchBPS(rom, location);
gameBoy.patched = applyPatchIPS(rom, location, "") || applyPatchBPS(rom, location, "");
auto heuristics = Heuristics::GameBoy(rom, location);
auto sha256 = Hash::SHA256(rom).digest();
if(auto document = BML::unserialize(string::read(locate("Database/Game Boy.bml")))) {
Expand Down Expand Up @@ -236,7 +251,7 @@ auto Program::loadBSMemory(string location) -> bool {
}
if(rom.size() < 0x8000) return false;

bsMemory.patched = applyPatchIPS(rom, location) || applyPatchBPS(rom, location);
bsMemory.patched = applyPatchIPS(rom, location, "") || applyPatchBPS(rom, location, "");
auto heuristics = Heuristics::BSMemory(rom, location);
auto sha256 = Hash::SHA256(rom).digest();
if(auto document = BML::unserialize(string::read(locate("Database/BS Memory.bml")))) {
Expand Down Expand Up @@ -266,7 +281,7 @@ auto Program::loadSufamiTurboA(string location) -> bool {
}
if(rom.size() < 0x20000) return false;

sufamiTurboA.patched = applyPatchIPS(rom, location) || applyPatchBPS(rom, location);
sufamiTurboA.patched = applyPatchIPS(rom, location, "") || applyPatchBPS(rom, location, "");
auto heuristics = Heuristics::SufamiTurbo(rom, location);
auto sha256 = Hash::SHA256(rom).digest();
if(auto document = BML::unserialize(string::read(locate("Database/Sufami Turbo.bml")))) {
Expand Down Expand Up @@ -296,7 +311,7 @@ auto Program::loadSufamiTurboB(string location) -> bool {
}
if(rom.size() < 0x20000) return false;

sufamiTurboB.patched = applyPatchIPS(rom, location) || applyPatchBPS(rom, location);
sufamiTurboB.patched = applyPatchIPS(rom, location, "") || applyPatchBPS(rom, location, "");
auto heuristics = Heuristics::SufamiTurbo(rom, location);
auto sha256 = Hash::SHA256(rom).digest();
if(auto document = BML::unserialize(string::read(locate("Database/Sufami Turbo.bml")))) {
Expand Down
22 changes: 16 additions & 6 deletions bsnes/target-bsnes/program/hacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ auto Program::hackCompatibility() -> void {
emulator->configure("Hacks/PPU/Mode7/Igwin", settings.emulator.hack.ppu.mode7.igwin);
emulator->configure("Hacks/PPU/Mode7/Igwinx", settings.emulator.hack.ppu.mode7.igwinx);
emulator->configure("Hacks/PPU/Mode7/Strwin", false);
emulator->configure("Hacks/PPU/Mode7/VramExt", 0x7fff);
emulator->configure("Hacks/PPU/Mode7/BgGrad", settings.emulator.hack.ppu.mode7.bgGrad);
emulator->configure("Hacks/PPU/Mode7/WindRad", settings.emulator.hack.ppu.mode7.windRad);
emulator->configure("Hacks/PPU/Mode7/WsMode", settings.emulator.hack.ppu.mode7.wsMode);
Expand Down Expand Up @@ -114,12 +115,12 @@ auto Program::hackCompatibility() -> void {
n = (n * 10) + (v - '0');
if (i == rso.size() || rso[i] < '0' || rso[i] > '9') {
switch (c) {
// case 'p': //pixelAspectCorrect 0:off 1:on
// emulator->configure("Video/AspectCorrection", n == 1);
// break;
// case 'o': //overscan 0:216 1:224 (2:240 3:240f)
// emulator->configure("Video/Overscan", n == 1);
// break;
// case 'p': //pixelAspectCorrect 0:off 1:on [libretro exclusive]
// aspectcorrection = n == 1;
// break;
// case 'o': //overscan 0:216 1:224 (2:240 3:240f) [libretro exclusive]
// overscan = n == 1;
// break;
case 'w': //widescreenMode 0:none 1:on 2:mode7
emulator->configure("Hacks/PPU/Mode7/WsMode", n == 1 ? 2 : (n == 2 ? 1 : 0));
break;
Expand Down Expand Up @@ -196,6 +197,15 @@ auto Program::hackCompatibility() -> void {
case 'S': //Stretch Window [for widescreen patches only]
emulator->configure("Hacks/PPU/Mode7/Strwin", n == 2 );
break;
case 'v': //VRAM extension
emulator->configure("Hacks/PPU/Mode7/VramExt", n > 0 ? 0xffff : 0x7fff );
break;
case 'f': //Scale factor 0:disable 1-10:scale
emulator->configure("Hacks/PPU/Mode7/Scale", n >= 0 && n <= 10 ? n : 2);
break;
case 'l': //Disable sprite limit
emulator->configure("Hacks/PPU/NoSpriteLimit", n == 1);
break;
}
c = -1;
n = 0;
Expand Down
Loading

0 comments on commit de27b9e

Please sign in to comment.