Skip to content

Commit

Permalink
beta 10.3
Browse files Browse the repository at this point in the history
  • Loading branch information
DerKoun committed Feb 18, 2020
1 parent 3a74cbe commit 87173e8
Show file tree
Hide file tree
Showing 14 changed files with 253 additions and 60 deletions.
93 changes: 93 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: CI

on:
push:
pull_request:

jobs:
Windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Build
run: mingw32-make -j $env:NUMBER_OF_PROCESSORS -C bsnes
- name: Prepare artifacts
run: |
mkdir bsnes/out/pack
unzip packraw.zip -d bsnes/out/pack
cp README.md bsnes/out/pack
cp bsnes/out/bsnes.exe bsnes/out/pack
mv bsnes/out/pack/bsnes.exe bsnes/out/pack/bsnes_hd.exe
- name: Upload artifacts
uses: actions/[email protected]
with:
name: bsnes_hd_build-${{ runner.os }}
path: bsnes\out\pack

Linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- 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 zip
- name: Build
run: make -j $(nproc) -C bsnes
- name: Prepare artifacts
run: |
mkdir bsnes/out/pack
unzip packraw.zip -d bsnes/out/pack
cp README.md bsnes/out/pack
cp -R bsnes/out/*bsnes* bsnes/out/pack
mv bsnes/out/pack/bsnes bsnes/out/pack/bsnes_hd
- name: Upload artifacts
uses: actions/[email protected]
with:
name: bsnes_hd_build-${{ runner.os }}
path: bsnes/out/pack

macOS:
runs-on: macos
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Build
run: make -j $(sysctl -n hw.ncpu) -C bsnes
- name: Prepare artifacts
run: |
mkdir bsnes/out/pack
unzip packraw.zip -d bsnes/out/pack
cp README.md bsnes/out/pack
cp -R bsnes/out/*bsnes* bsnes/out/pack
mv bsnes/out/pack/bsnes.app bsnes/out/pack/bsnes_hd.app
- name: Upload artifacts
uses: actions/[email protected]
with:
name: bsnes_hd_build-${{ runner.os }}
path: bsnes/out/pack

macOS-libretro:
runs-on: macos
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Build
run: make -j $(sysctl -n hw.ncpu) -C bsnes target=libretro
- name: Prepare artifacts
run: |
mkdir bsnes/out/pack
cp README.md bsnes/out/pack
cp LICENSE bsnes/out/pack
cp -R bsnes/out/*bsnes* bsnes/out/pack
- name: Upload artifacts
uses: actions/[email protected]
with:
name: bsnes_hd_libretro_build-${{ runner.os }}
path: bsnes/out/pack
60 changes: 55 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# bsnes-hd *beta 10.2*
# bsnes-hd *beta 10.3*

- [downloads](https://github.com/DerKoun/bsnes-hd/releases) for the latest betas
- [GitHub project](https://github.com/DerKoun/bsnes-hd) for source code, issues, feature requests, ...
Expand Down Expand Up @@ -166,19 +166,69 @@ The amount of neighboring lines used to smooth Window effects, like iris transit

In *bsnes* the overscan setting allows switching between cropping 8 and 0 lines form top and bottom, which are unused due to the way TVs in the time of the SNES worked. In *bsnes-hd* it switches between 12 and 8 lines, defaulting to 12 (*off*). This cuts of 4 lines on both sides that technically contain content, but should not cut important information as these lines are still in an area that wasn't safe to use (12 lines is 5%). The reason to do is that the resulting height of 216 is exactly a 5th of 1080, so you can integer scale to HD and 4K resolutions, e.g. *5x* at *16:9* is exactly *1080 HD* with every Mode 7 pixel rendered specifically.

### Settings / Output / (Pixel) Aspect Correction

Renamed Aspect Correction to Pixel Aspect Correction to avoid confusion with the widescreen aspect ratio.

## Widescreen Technical

### Dimensions

The amount of pixel columns added to both sides for the various aspect ratios are, depending on some settings:
- overscan *off*, aspect correction *off*: (4:3, 16), (16:10, 44), (16:9, 64), (2:1, 88), (21:9, 124).
- overscan *on*, aspect correction *off*: (4:3, 20), (16:10, 52), (16:9, 72), (2:1, 96), (21:9, 132).
- overscan *on*, aspect correction *on*: (4:3, 0), (16:10, 24), (16:9, 44), (2:1, 64), (21:9, 96).
- overscan *off*, pixel aspect correction *off*: (4:3, 16), (16:10, 44), (16:9, 64), (2:1, 88), (21:9, 124).
- overscan *on*, pixel aspect correction *off*: (4:3, 20), (16:10, 52), (16:9, 72), (2:1, 96), (21:9, 132).
- overscan *on*, pixel aspect correction *on*: (4:3, 0), (16:10, 24), (16:9, 44), (2:1, 64), (21:9, 96).

### Maximum width for objects/sprites

The maximum width for widescreen areas that still can have places objects in them is *96* (exactly 2:1 AR with overscan *on* and aspect correction *off* or 21:9 with overscan *on* and aspect correction *on*).
The maximum width for widescreen areas that still can have places objects in them is *96* (exactly 2:1 AR with overscan *on* and pixel aspect correction *off* or 21:9 with overscan *on* and pixel aspect correction *on*).

### Object/sprite wrap-around

At that maximum width *352* is the only coordinate that places a large object (width 64) entirely off screen. Smaller value make it reach into the screen from the right, larger ones from the left.

### 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.

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 |
| ----------------------------------- | ------- | ----------------------------------------------- |
| 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:off 1:on 2:auto(horizontal and vertical) |
| 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 |

#### Widescreen 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 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.

#### Sample

To force enable widescreen, including for sprites and setting a widescreen extension of 64 the file can simply be:
```
w1s1W64
```
Any character that is not a letter or digit is ignored. So you can also do:
```
w : 1
s : 1
W : 64
```
Only the last letter before a number is taken into account, basically allowing comments:
```
widescreen always on: w: 1
widescreen sprites on: s: 1
widescreen extension : W:64
```
22 changes: 0 additions & 22 deletions appveyor.yml

This file was deleted.

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.2";//bsnes/target-bsnes/presentation/presentation.cpp:create:about:setVersion
static const string Version = "10.3";//bsnes/target-bsnes/presentation/presentation.cpp:create:about:setVersion
static const string Author = "DerKoun(byuu)";
static const string License = "GPLv3";
static const string Website = "https://github.com/DerKoun/bsnes-hd";
Expand Down
3 changes: 3 additions & 0 deletions bsnes/emulator/hdtoolkit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ namespace HdToolkit {
val *= 7;
val /= 8;
}
if (val <= 256) {
return 0;
}
val -= 256;
val /= 2;
val /= 4;
Expand Down
2 changes: 1 addition & 1 deletion bsnes/sfc/interface/configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct Configuration {
bool blurEmulation = true;
bool colorEmulation = true;
uint saturation = 100;
uint gamma = 150;
uint gamma = 100;
uint luminance = 100;
} video;

Expand Down
3 changes: 3 additions & 0 deletions bsnes/sfc/ppu-fast/background.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ auto PPU::Line::renderBackground(PPU::IO::Background& self, uint8 source) -> voi
// In hires mode non-hires backgrounds seem to be rendered on every second pixel (see water in Kirby)
if(self.aboveEnable && !windowAbove[ppufast.winXad(x, false)]) plotHD(above, x, source, mosaicPriority, mctc, true, true);
if(self.aboveEnable && !windowAbove[ppufast.winXad(x, false)]) plotHD(below, x, source, mosaicPriority, mctc, true, true);
// So we force low priority for half of every pixel
if(self.aboveEnable && !windowAbove[ppufast.winXad(x, false)]) plotHD(above, x, source, self.priority[0], mctc, true, false);
if(self.aboveEnable && !windowAbove[ppufast.winXad(x, false)]) plotHD(below, x, source, self.priority[0], mctc, true, false);
} else {
if(self.aboveEnable && !windowAbove[ppufast.winXad(x, false)]) plotAbove(x, source, mosaicPriority, mctc);
if(self.belowEnable && !windowBelow[ppufast.winXad(x, true)]) plotBelow(x, source, mosaicPriority, mctc);
Expand Down
16 changes: 8 additions & 8 deletions bsnes/sfc/ppu-fast/line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ auto PPU::Line::flush() -> void {
for(uint r : range(32)) {
for(uint g : range(32)) {
for(uint b : range(32)) {
double dr = r << 3;
double dg = g << 3;
double db = b << 3;
double dr = r * 255.0 / 31.0;
double dg = g * 255.0 / 31.0;
double db = b * 255.0 / 31.0;

if(saturation != 100) {
double satVal = saturation / 100.0;
double grayInv = (dr + dg + db) / 3 * max(0.0, 1.0 - saturation / 100.0);
double grayInv = (dr + dg + db) / 3 * max(0.0, 1.0 - satVal);
dr = dr * satVal + grayInv;
dg = dg * satVal + grayInv;
db = db * satVal + grayInv;
}

if(gamma != 100) {
double reciprocal = 1.0 / 255.0;
double gamVal = gamma / 100.0;
dr = 255.0 * pow(dr * reciprocal, gamVal);
dg = 255.0 * pow(dg * reciprocal, gamVal);
db = 255.0 * pow(db * reciprocal, gamVal);
double reciprocal = 1.0 / 127.0;
dr = dr > 127.0 ? dr : 127.0 * pow(dr * reciprocal, gamVal);
dg = dg > 127.0 ? dg : 127.0 * pow(dg * reciprocal, gamVal);
db = db > 127.0 ? db : 127.0 * pow(db * reciprocal, gamVal);
}

if(luminance != 100) {
Expand Down
2 changes: 1 addition & 1 deletion bsnes/target-bsnes/presentation/presentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ auto Presentation::create() -> void {
if(settings.video.output == "Center") centerViewport.setChecked();
if(settings.video.output == "Scale") scaleViewport.setChecked();
if(settings.video.output == "Stretch") stretchViewport.setChecked();
aspectCorrection.setText("Aspect Correction").setChecked(settings.video.aspectCorrection).onToggle([&] {
aspectCorrection.setText("Pixel Aspect Correction").setChecked(settings.video.aspectCorrection).onToggle([&] {
settings.video.aspectCorrection = aspectCorrection.checked();
emulator->configure("Video/AspectCorrection", settings.video.aspectCorrection);
resizeWindow();
Expand Down
84 changes: 84 additions & 0 deletions bsnes/target-bsnes/program/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,90 @@ auto Program::loadSuperFamicom(string location) -> bool {
offset += size;
}

// load and apply simple settings override file (if found)
vector<uint8_t> rso;
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(path("gamesettings", location, ".bso"));
} else {
rso = file::read(path("gamesettings", location, ".bso"));
}
if(rso) {
int i = 0;
int v = 0;
int c = -1;
int n = 0;
while (i < rso.size()) {
v = rso[i];
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+1 == rso.size() || rso[i+1] < '0' || rso[i+1] > '9') {
switch (c) {
case 'p': //pixelAspectCorrect 0:off 1:on
settings.video.aspectCorrection = n == 1;
emulator->configure("Video/AspectCorrection", settings.video.aspectCorrection);
break;
case 'o': //overscan 0:216 1:224 (2:240 3:240f)
settings.video.overscan = n == 1;
emulator->configure("Video/Overscan", settings.video.overscan);
break;
case 'w': //widescreenMode 0:none 1:on 2:mode7
settings.emulator.hack.ppu.mode7.wsMode = n == 1 ? 2 : (n == 2 ? 1 : 0);
emulator->configure("Hacks/PPU/Mode7/WsMode", settings.emulator.hack.ppu.mode7.wsMode);
break;
case 'W': //WSaspectRatio int [<=200:wsExt, >200:ar]
settings.emulator.hack.ppu.mode7.widescreen = n;
emulator->configure("Hacks/PPU/Mode7/Widescreen", settings.emulator.hack.ppu.mode7.widescreen);
break;
case 's': //WSsprites 0:safe 1:unsafe 2:clip
settings.emulator.hack.ppu.mode7.wsobj = n == 1 ? 1 : (n == 2 ? 3 : 0);
emulator->configure("Hacks/PPU/Mode7/Wsobj", settings.emulator.hack.ppu.mode7.wsobj);
break;
case 'i': //igwin 0:none 1:outside 2:outside&always 3:all
settings.emulator.hack.ppu.mode7.igwin = n > 3 ? 0 : n;
emulator->configure("Hacks/PPU/Mode7/Igwin", settings.emulator.hack.ppu.mode7.igwin);
break;
case 'I': //igwinx int
settings.emulator.hack.ppu.mode7.igwinx = n > 255 ? 128 : n;
emulator->configure("Hacks/PPU/Mode7/Igwinx", settings.emulator.hack.ppu.mode7.igwinx);
break;
case 'b': //bg1WS 0:off 1:on 2:auto(h+v)
settings.emulator.hack.ppu.mode7.wsbg1 = n == 1 ? 1 : (n == 2 ? 16 : 0);
emulator->configure("Hacks/PPU/Mode7/Wsbg1", settings.emulator.hack.ppu.mode7.wsbg1);
break;
case 'B': //bg2WS 0:off 1:on 2:auto(h+v)
settings.emulator.hack.ppu.mode7.wsbg2 = n == 1 ? 1 : (n == 2 ? 16 : 0);
emulator->configure("Hacks/PPU/Mode7/Wsbg2", settings.emulator.hack.ppu.mode7.wsbg2);
break;
case 'c': //bg3WS 0:off 1:on 2:auto(h+v)
settings.emulator.hack.ppu.mode7.wsbg3 = n == 1 ? 1 : (n == 2 ? 16 : 0);
emulator->configure("Hacks/PPU/Mode7/Wsbg3", settings.emulator.hack.ppu.mode7.wsbg3);
break;
case 'C': //bg4WS 0:off 1:on 2:auto(h+v)
settings.emulator.hack.ppu.mode7.wsbg4 = n == 1 ? 1 : (n == 2 ? 16 : 0);
emulator->configure("Hacks/PPU/Mode7/Wsbg4", settings.emulator.hack.ppu.mode7.wsbg4);
break;
}
c = -1;
n = 0;
}
}
i++;
}
}

return true;
}

Expand Down
18 changes: 0 additions & 18 deletions bsnes/target-bsnes/program/hacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,6 @@ auto Program::hackCompatibility() -> void {
emulator->configure("Hacks/PPU/Fast", fastPPU);
emulator->configure("Hacks/PPU/NoSpriteLimit", fastPPUNoSpriteLimit);
emulator->configure("Hacks/PPU/RenderCycle", renderCycle);
emulator->configure("Hacks/PPU/Mode7/Scale", settings.emulator.hack.ppu.mode7.scale);
emulator->configure("Hacks/PPU/Mode7/Perspective", settings.emulator.hack.ppu.mode7.perspective);
emulator->configure("Hacks/PPU/Mode7/Widescreen", settings.emulator.hack.ppu.mode7.widescreen);
emulator->configure("Hacks/PPU/Mode7/Wsbg1", settings.emulator.hack.ppu.mode7.wsbg1);
emulator->configure("Hacks/PPU/Mode7/Wsbg2", settings.emulator.hack.ppu.mode7.wsbg2);
emulator->configure("Hacks/PPU/Mode7/Wsbg3", settings.emulator.hack.ppu.mode7.wsbg3);
emulator->configure("Hacks/PPU/Mode7/Wsbg4", settings.emulator.hack.ppu.mode7.wsbg4);
emulator->configure("Hacks/PPU/Mode7/Wsobj", settings.emulator.hack.ppu.mode7.wsobj);
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/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);
emulator->configure("Hacks/PPU/Mode7/WsBgCol", settings.emulator.hack.ppu.mode7.wsBgCol);
emulator->configure("Hacks/PPU/Mode7/WsMarker", settings.emulator.hack.ppu.mode7.wsMarker);
emulator->configure("Hacks/PPU/Mode7/WsMarkerAlpha", settings.emulator.hack.ppu.mode7.wsMarkerAlpha);
emulator->configure("Hacks/PPU/Mode7/Supersample", settings.emulator.hack.ppu.mode7.supersample);
emulator->configure("Hacks/PPU/Mode7/Mosaic", settings.emulator.hack.ppu.mode7.mosaic);
emulator->configure("Hacks/DSP/Fast", fastDSP);
emulator->configure("Hacks/DSP/Cubic", settings.emulator.hack.dsp.cubic);
emulator->configure("Hacks/Coprocessor/DelayedSync", coprocessorDelayedSync);
Expand Down
Loading

0 comments on commit 87173e8

Please sign in to comment.