Skip to content

Commit

Permalink
beta 10.5
Browse files Browse the repository at this point in the history
  • Loading branch information
DerKoun committed May 26, 2021
1 parent 9aff32c commit d2d7815
Show file tree
Hide file tree
Showing 10 changed files with 222 additions and 42 deletions.
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# bsnes-hd *beta 10.4*
# bsnes-hd *beta 10.5*

- [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 @@ -14,7 +14,7 @@

## What is it?

bsnes-hd (called "*HD Mode 7 mod, for bsnes*" in early betas) is a fork of bsnes (great SNES emulator by *byuu*) that adds HD video features, such as:
bsnes-hd (called "*HD Mode 7 mod, for bsnes*" in early betas) is a fork of bsnes (great SNES emulator by *Near*) that adds HD video features, such as:

### HD Mode 7

Expand Down Expand Up @@ -187,12 +187,10 @@ At that maximum width *352* is the only coordinate that places a large object (w

### Setting override files

Along with widescreen patches you can override certain settings via a file with the same name as the ROM and the extension ".bso". It is searched in the same way as patches.
Along with (or instead of) widescreen patches you can override certain settings via a file with the same name as the ROM and the extension ".bso". It is searched in the same way as patches. The easiest way is to place it in the same folder as the ROM.

The file must contain alternating letters and numbers, each pair overriding a setting.

**Please note** that this does not work in the libretro core and that the overrides are not cleared when you change the ROM, so restarting the emulator is highly recommended.

#### Settings

| Description | Letter | Values |
Expand All @@ -203,17 +201,16 @@ The file must contain alternating letters and numbers, each pair overriding a se
| 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*) |
| pixel aspect ratio correction | p | 0:off 1:on |
| overscan | o | 0:off(216 lines(5th HD)) 1:on(224 lines) |
| 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*) |

#### Widescreen Aspect Ratio values

Values of 200 and less specify the widescreen extension on each side in pixel columns. It is recommended to use values dividable by as large a power of 2 as possible, at least by 4.
Values of 200 and less specify the widescreen extension on each side in pixel columns. The value is rounded to a multiple of 8.

Values larger than 200 specify the aspect ratio as (horizontal*100+vertical), e.g. 16:10, 16:9, 2:1 and 21:9 as 1610, 1609, 201 and 2109, respectively. From this AR the widescreen extension is computed in the same way as for ARs specified in the settings dialog, except that arbitrary ARs can be specified here.
Values larger than 200 specify the aspect ratio as (horizontal*100+vertical), e.g. 16:10, 16:9, 2:1 and 21:9 as 1610, 1609, 201 and 2109, respectively. From this AR the widescreen extension is computed in the same way as for ARs specified in the settings dialog, except that arbitrary ARs can be specified here. The resulting additional columns are rounded to a multiple of 8.

#### Widescreen Background

Expand All @@ -228,6 +225,12 @@ Values from 1-10 and 11-20 enable lines and darkening respectively. The values i

1-3 and 4-6 trigger auto an on respectively. In both cases the 3 settings are in the order: wide, medium, narrow.

#### Stretch Windowing

A value of 2 causes all windowing coordinates to be stretched, i.e. their distance from 128 is doubled.
This allows widescreen patches to extend windowing effects into the widescreen areas at the cost of precision.
But it also requires the patch to adapt all windowing coordinates in the ROM.

#### Sample

To force enable widescreen, including for sprites and setting a widescreen extension of 64 the file can simply be:
Expand Down
4 changes: 2 additions & 2 deletions bsnes/emulator/emulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ using namespace nall;

namespace Emulator {
static const string Name = "bsnes-hd beta";
static const string Version = "10.4";//bsnes/target-bsnes/presentation/presentation.cpp:create:about:setVersion
static const string Author = "DerKoun(byuu)";
static const string Version = "10.5";//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
2 changes: 1 addition & 1 deletion bsnes/sfc/ppu-fast/line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ auto PPU::Line::render(bool fieldID) -> void {
if (hd && ppu.wsBgCol() && ppu.widescreen() > 0) {
for(uint x = xa; x < xb; x++) {
int cx = (x % ((256+2*ppu.widescreen()) * scale)) - (ppu.widescreen() * scale);
if (cx >= 0 && cx <= (256 * scale)) {
if (cx >= 0 && cx < (256 * scale)) {
above[x] = {Source::COL, 0, aboveColor};
below[x] = {Source::COL, 0, belowColors[x / ((256+2*ppufast.widescreen()) * scale)]};
} else {
Expand Down
8 changes: 4 additions & 4 deletions bsnes/sfc/ppu-fast/ppu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,10 +375,10 @@ struct PPU : PPUcounter {

struct Mode7LineGroups {
int count = -1;
int startLine[32];
int endLine[32];
int startLerpLine[32];
int endLerpLine[32];
int startLine[240];
int endLine[240];
int startLerpLine[240];
int endLerpLine[240];
} mode7LineGroups;
};

Expand Down
6 changes: 3 additions & 3 deletions bsnes/target-bsnes/presentation/presentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ auto Presentation::create() -> void {

helpMenu.setText(tr("Help"));
documentation.setIcon(Icon::Application::Browser).setText({tr("bsnes documentation"), " ..."}).onActivate([&] {
invoke("https://byuu.org/doc/bsnes");
invoke("https://bsnes.dev");
});
documentationHd.setIcon(Icon::Application::Browser).setText({tr("bsnes-hd documentation"), " ..."}).onActivate([&] {
invoke("https://github.com/DerKoun/bsnes-hd");
Expand All @@ -204,9 +204,9 @@ auto Presentation::create() -> void {
.setLogo(Resource::Logo)
.setDescription("Super Nintendo emulator")
.setVersion("114.3")//bsnes/emulator/emulator.hpp:Emulator:Version
.setAuthor("byuu")
.setAuthor("Near")
.setLicense("GPLv3")
.setWebsite("https://byuu.org")
.setWebsite("https://near.sh/")
.setAlignment(*this)
.show();
});
Expand Down
14 changes: 7 additions & 7 deletions bsnes/target-bsnes/program/hacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,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
// 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 '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 @@ -193,7 +193,7 @@ auto Program::hackCompatibility() -> void {
case 'O': //Overlock CPU percentage
emulator->configure("Hacks/CPU/Overclock", n );
break;
case 'S': //Stretch Window [EXPERIMENTAL!! DO NOT USE!!]
case 'S': //Stretch Window [for widescreen patches only]
emulator->configure("Hacks/PPU/Mode7/Strwin", n == 2 );
break;
}
Expand Down
187 changes: 183 additions & 4 deletions bsnes/target-libretro/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <nall/encode/rle.hpp>
#include <nall/encode/zip.hpp>
#include <nall/hash/crc16.hpp>
#include <nall/beat/single/apply.hpp>
using namespace nall;

#include <heuristics/heuristics.hpp>
Expand Down Expand Up @@ -40,12 +41,15 @@ struct Program : Emulator::Platform
auto loadBSMemory(string location) -> bool;

auto save() -> void;

auto openRomSuperFamicom(string name, vfs::file::mode mode) -> shared_pointer<vfs::file>;
auto openRomGameBoy(string name, vfs::file::mode mode) -> shared_pointer<vfs::file>;
auto openRomBSMemory(string name, vfs::file::mode mode) -> shared_pointer<vfs::file>;

auto hackPatchMemory(vector<uint8_t>& data) -> void;

auto applyPatchBPS(vector<uint8_t>& data, string location) -> bool;
vector<uint8_t> rso;

string base_name;

Expand Down Expand Up @@ -225,6 +229,118 @@ auto Program::load() -> void {
if (title == "ニチブツ・アーケード・クラシックス") emulator->configure("Hacks/Entropy", "None");
}

// setting override processing (copied from standalone target)
if(rso) {
int i = 0;
int v = 0;
int c = -1;
int n = 0;
bool e = true;
while (i < rso.size()) {
v = rso[i++];
if (v == '%') {
e = !e;
}
if (!e) {
continue;
}
if ((v >= 'a' && v <= 'z') || (v >= 'A' && v <= 'Z')) {
c = v;
} else if (c > -1 && v >= '0' && v <= '9') {
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 'w': //widescreenMode 0:none 1:on 2:mode7
emulator->configure("Hacks/PPU/Mode7/WsMode", n == 1 ? 2 : (n == 2 ? 1 : 0));
break;
case 'W': //WSaspectRatio int [<=200:wsExt, >200:ar]
emulator->configure("Hacks/PPU/Mode7/Widescreen", n);
break;
case 's': //WSsprites 0:safe 1:unsafe 2:clip
emulator->configure("Hacks/PPU/Mode7/Wsobj", n == 1 ? 1 : (n == 2 ? 3 : 0));
break;
case 'i': //igwin 0:none 1:outside 2:outside&always 3:all
emulator->configure("Hacks/PPU/Mode7/Igwin", n > 3 ? 0 : n);
break;
case 'I': //igwinx int
emulator->configure("Hacks/PPU/Mode7/Igwinx", n > 255 ? 128 : n);
break;
case 'b': //bg1WS 0:off 1:on 2:auto(h+v)
emulator->configure("Hacks/PPU/Mode7/Wsbg1",
n >= 1000 ? n : //above/below line (processed later)
(n == 1 ? 1 : //on
(n == 2 ? 16 : //auto H+V
(n == 3 ? 15 : //auto H
(n == 10 ? 12 : //crop
(n == 11 ? 13 : //crop auto
(n == 20 ? 14 : //disable
0)))))) //off
);
break;
case 'B': //bg2WS 0:off 1:on 2:auto(h+v)
emulator->configure("Hacks/PPU/Mode7/Wsbg2",
n >= 1000 ? n : //above/below line (processed later)
(n == 1 ? 1 : //on
(n == 2 ? 16 : //auto H+V
(n == 3 ? 15 : //auto H
(n == 10 ? 12 : //crop
(n == 11 ? 13 : //crop auto
(n == 20 ? 14 : //disable
0)))))) //off
);
break;
case 'c': //bg3WS 0:off 1:on 2:auto(h+v)
emulator->configure("Hacks/PPU/Mode7/Wsbg3",
n >= 1000 ? n : //above/below line (processed later)
(n == 1 ? 1 : //on
(n == 2 ? 16 : //auto H+V
(n == 3 ? 15 : //auto H
(n == 10 ? 12 : //crop
(n == 11 ? 13 : //crop auto
(n == 20 ? 14 : //disable
0)))))) //off
);
break;
case 'C': //bg4WS 0:off 1:on 2:auto(h+v)
emulator->configure("Hacks/PPU/Mode7/Wsbg4",
n >= 1000 ? n : //above/below line (processed later)
(n == 1 ? 1 : //on
(n == 2 ? 16 : //auto H+V
(n == 3 ? 15 : //auto H
(n == 10 ? 12 : //crop
(n == 11 ? 13 : //crop auto
(n == 20 ? 14 : //disable
0)))))) //off
);
break;
case 'm': //wsMarker 0:off 1-10:lines 11-20:darken, wsMarkerAlpha 1-10/11-20:opaque-transparent
emulator->configure("Hacks/PPU/Mode7/WsMarker", n < 1 || n > 20 ? 0 : (n - 1) / 10 + 1);
emulator->configure("Hacks/PPU/Mode7/WsMarkerAlpha", (n - 1) % 10 + 1);
break;
case 'P': //Perspective 0:off 1-3:auto 4-6+:on (wide, medium, narrow)
emulator->configure("Hacks/PPU/Mode7/Perspective", n < 1 || n > 6 ? 0 : n );
break;
case 'O': //Overlock CPU percentage
emulator->configure("Hacks/CPU/Overclock", n );
break;
case 'S': //Stretch Window [for widescreen patches only]
emulator->configure("Hacks/PPU/Mode7/Strwin", n == 2 );
break;
}
c = -1;
n = 0;
}
}
}
}
// END OF setting override processing (copied from standalone target)

emulator->power();
}

Expand Down Expand Up @@ -492,8 +608,33 @@ auto Program::loadSuperFamicom(string location) -> bool

if(rom.size() < 0x8000) return false;

//assume ROM and IPS agree on whether a copier header is present
//superFamicom.patched = applyPatchIPS(rom, location);
// soft patching (copied from standalone target)
// note: soft patching should be done via the libretro frontend
// so this is only a workaround until that is possible
if(!superFamicom.patched) superFamicom.patched = applyPatchBPS(rom, location);
// END OF soft patching (copied from standalone target)

// setting override loading (copied from standalone target)
if(location.endsWith("/")) {
rso = file::read({location, "gamesettings.bso"});
} else if(location.iendsWith(".zip")) {
Decode::ZIP archive;
if(archive.open(location)) {
for(auto& file : archive.file) {
if(file.name.iendsWith(".bso")) {
rso = archive.extract(file);
break;
}
}
}
if(!rso) rso = file::read({Location::path(location),
Location::prefix(Location::file(location)), ".bso"});
} else {
rso = file::read({Location::path(location),
Location::prefix(Location::file(location)), ".bso"});
}
// END OF setting override loading (copied from standalone target)

if((rom.size() & 0x7fff) == 512) {
//remove copier header
memory::move(&rom[0], &rom[512], rom.size() - 512);
Expand Down Expand Up @@ -752,4 +893,42 @@ auto decodeGB(string& code) -> bool {

//unrecognized code format
return false;
}
}

// soft patching (copied from standalone target), note: soft patching should be done via the libretro frontend, so this is only a workaround until that is possible
auto Program::applyPatchBPS(vector<uint8_t>& input, string location) -> bool {
vector<uint8_t> patch;

if(location.endsWith("/")) {
patch = file::read({location, "patch.bps"});
} else if(location.iendsWith(".zip")) {
Decode::ZIP archive;
if(archive.open(location)) {
for(auto& file : archive.file) {
if(file.name.iendsWith(".bps")) {
patch = archive.extract(file);
break;
}
}
}
if(!patch) patch = file::read({Location::path(location),
Location::prefix(Location::file(location)), ".bps"});
} else {
patch = file::read({Location::path(location),
Location::prefix(Location::file(location)), ".bps"});
}

if(!patch) return false;

string manifest;
string error;
if(auto output = Beat::Single::apply(input, patch, manifest, error)) {
if(!error) {
input = move(*output);
return true;
}
}

return false;
}
// END OF soft patching (copied from standalone target)
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ W : 1609 % aspect ratio 16:9 %
P : 0 % disable pixel aspect ratio correction %
s : 1 % widescreen sprites/objects %
b : 2 % background layer 1 auto widescreen %
B : 2 % background layer 2 auto widescreen %
B : 1 % background layer 2 on %
c : 2032 % background layer 3 widescreen below line 32 %
C : 2 % background layer 4 auto widescreen %
i : 0 % disable ignore window %
m : 0 % disable widescreen markers %
O : 120 % overclock CPU to 120 percent %
O : 200 % overclock CPU to 200 percent %
S : 2 % stretch windowing effects %
Loading

0 comments on commit d2d7815

Please sign in to comment.