mirror of
https://github.com/DerKoun/bsnes-hd.git
synced 2024-05-16 11:10:51 -04:00
beta10.1 (libretro only)
This commit is contained in:
parent
6bf68d6c6f
commit
4413ef4e60
|
@ -1,4 +1,4 @@
|
|||
# bsnes-hd *beta 10*
|
||||
# bsnes-hd *beta 10.1*
|
||||
|
||||
- [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, ...
|
||||
|
@ -118,7 +118,7 @@ Specifies how translucent the widescreen markers are. (defaults to 1/1)
|
|||
Settings for the background layers.
|
||||
- **off**: no widescreen (e.g. for HUDs)
|
||||
- **on**: widescreen enabled
|
||||
- **< xy**/**> xy**: widescreen enabled above/below a certain scanline (for backgrounds that contain HUDs and backgrounds).
|
||||
- **< xy**/**> xy**: widescreen enabled above/below a certain scanline (for backgrounds that contain HUDs and backgrounds), e.g. for "*HyperZone*" at "*BG2: >80*".
|
||||
- **autoHor**: Disables widescreen for this background when it is as wide as the screen and has a horizontal position of 0.
|
||||
- **autoHor&Ver**(default): Disables widescreen for this background when it is as wide as the screen and has a horizontal and vertical position of 0.
|
||||
- **crop**: do not draw the left- and right-most 8 pixels (next to the widescreen areas) of the background (for backgrounds blanking some edge pixels, leaving black lines in widescreen, e.g. "*Top Gear 2*").
|
||||
|
|
|
@ -59,9 +59,6 @@ ui := target-$(target)
|
|||
include $(ui)/GNUmakefile
|
||||
-include obj/*.d
|
||||
|
||||
|
||||
delete = $(info Deleting $1 ...) @rm -f $1
|
||||
|
||||
clean:
|
||||
$(call delete,obj/*)
|
||||
$(call delete,out/*)
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#define double float
|
||||
|
||||
namespace Emulator {
|
||||
|
||||
#include "stream.cpp"
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#pragma once
|
||||
#define double float
|
||||
|
||||
#include <nall/dsp/iir/dc-removal.hpp>
|
||||
#include <nall/dsp/iir/one-pole.hpp>
|
||||
|
|
|
@ -6,7 +6,9 @@
|
|||
#include <nall/adaptive-array.hpp>
|
||||
#include <nall/any.hpp>
|
||||
#include <nall/chrono.hpp>
|
||||
#ifndef PLATFORM_HORIZON
|
||||
#include <nall/dl.hpp>
|
||||
#endif // PLATFORM_HORIZON
|
||||
#include <nall/endian.hpp>
|
||||
#include <nall/image.hpp>
|
||||
#include <nall/literals.hpp>
|
||||
|
@ -29,7 +31,7 @@ using namespace nall;
|
|||
|
||||
namespace Emulator {
|
||||
static const string Name = "bsnes-hd beta";
|
||||
static const string Version = "10";//bsnes/target-bsnes/presentation/presentation.cpp:create:about:setVersion
|
||||
static const string Version = "10.1";//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";
|
||||
|
|
|
@ -17,7 +17,7 @@ struct Platform {
|
|||
virtual auto open(uint id, string name, vfs::file::mode mode, bool required = false) -> shared_pointer<vfs::file> { return {}; }
|
||||
virtual auto load(uint id, string name, string type, vector<string> options = {}) -> Load { return {}; }
|
||||
virtual auto videoFrame(const uint32* data, uint pitch, uint width, uint height, uint scale) -> void {}
|
||||
virtual auto audioFrame(const float* samples, uint channels) -> void {}
|
||||
virtual auto audioFrame(const double* samples, uint channels) -> void {}
|
||||
virtual auto inputPoll(uint port, uint device, uint input) -> int16 { return 0; }
|
||||
virtual auto inputRumble(uint port, uint device, uint input, bool enable) -> void {}
|
||||
virtual auto dipSettings(Markup::Node node) -> uint { return 0; }
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
flags += -DGB_INTERNAL -DDISABLE_DEBUGGER -D_GNU_SOURCE -Wno-multichar
|
||||
options += -I../sameboy
|
||||
|
||||
objects += gb-apu gb-camera gb-display gb-gb gb-joypad gb-mbc
|
||||
objects += gb-memory gb-printer gb-random gb-rewind gb-save_state gb-sgb
|
||||
|
|
|
@ -20,7 +20,7 @@ auto ICD::ppuWrite(uint2 color) -> void {
|
|||
}
|
||||
|
||||
auto ICD::apuWrite(float left, float right) -> void {
|
||||
float samples[] = {left, right};
|
||||
double samples[] = {left, right};
|
||||
if(!system.runAhead) stream->write(samples);
|
||||
}
|
||||
|
||||
|
|
|
@ -257,14 +257,13 @@ auto Program::videoFrame(const uint32* data, uint pitch, uint width, uint height
|
|||
}
|
||||
}
|
||||
|
||||
auto Program::audioFrame(const float* samples, uint channels) -> void {
|
||||
auto Program::audioFrame(const double* samples, uint channels) -> void {
|
||||
if(mute) {
|
||||
double silence[] = {0.0, 0.0};
|
||||
return audio.output(silence);
|
||||
audio.output(silence);
|
||||
} else {
|
||||
audio.output(samples);
|
||||
}
|
||||
|
||||
double frame[] = {samples[0], samples[1]};
|
||||
audio.output(frame);
|
||||
}
|
||||
|
||||
auto Program::inputPoll(uint port, uint device, uint input) -> int16 {
|
||||
|
|
|
@ -10,7 +10,7 @@ struct Program : Lock, Emulator::Platform {
|
|||
auto open(uint id, string name, vfs::file::mode mode, bool required) -> shared_pointer<vfs::file> override;
|
||||
auto load(uint id, string name, string type, vector<string> options = {}) -> Emulator::Platform::Load override;
|
||||
auto videoFrame(const uint32* data, uint pitch, uint width, uint height, uint scale) -> void override;
|
||||
auto audioFrame(const float* samples, uint channels) -> void override;
|
||||
auto audioFrame(const double* samples, uint channels) -> void override;
|
||||
auto inputPoll(uint port, uint device, uint input) -> int16 override;
|
||||
auto inputRumble(uint port, uint device, uint input, bool enable) -> void override;
|
||||
|
||||
|
|
|
@ -9,6 +9,11 @@ ifeq ($(platform), ios-arm64)
|
|||
else ifeq ($(platform), tvos-arm64)
|
||||
flags += -fPIC -mtvos-version-min=11.0 -Wno-error=implicit-function-declaration -DHAVE_POSIX_MEMALIGN
|
||||
options += -dynamiclib
|
||||
else ifeq ($(platform), libnx)
|
||||
flags += -march=armv8-a+crc -mtune=cortex-a57 -mtp=soft -mcpu=cortex-a57+crc+fp+simd -DHAVE_POSIX_MEMALIGN
|
||||
flags += -O2 -ftree-vectorize -ffast-math -funsafe-math-optimizations -fPIE -I$(PORTLIBS)/include/ -I$(LIBNX)/include/ -ffunction-sections -fdata-sections -ftls-model=local-exec
|
||||
flags += -D__SWITCH__=1 -D__aarch64__=1 -DSWITCH -DHAVE_LIBNX
|
||||
name = $(name)_libnx
|
||||
endif
|
||||
|
||||
objects := libretro $(objects)
|
||||
|
@ -21,6 +26,8 @@ ifeq ($(platform),linux)
|
|||
$(strip $(compiler) -o out/$(name).so -shared $(objects) -Wl,--no-undefined -Wl,--version-script=target-libretro/link.T -lgomp -Wl,-Bdynamic $(options))
|
||||
else ifeq ($(platform),windows)
|
||||
$(strip $(compiler) -o out/$(name).dll -shared $(objects) -Wl,--no-undefined -Wl,--version-script=target-libretro/link.T -lgomp -Wl,-Bdynamic $(options))
|
||||
else ifeq ($(platform),libnx)
|
||||
$(strip $(AR) rcs out/$(name).a $(objects))
|
||||
else ifeq ($(platform),macos)
|
||||
$(strip $(compiler) -o out/$(name).dylib -shared $(objects) $(options))
|
||||
else ifeq ($(platform), ios-arm64)
|
||||
|
|
|
@ -32,6 +32,7 @@ static void audio_queue(int16_t left, int16_t right)
|
|||
#include "program.cpp"
|
||||
|
||||
static string sgb_bios;
|
||||
static vector<string> cheatList;
|
||||
|
||||
#define RETRO_DEVICE_JOYPAD_MULTITAP RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 0)
|
||||
#define RETRO_DEVICE_LIGHTGUN_SUPER_SCOPE RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_LIGHTGUN, 0)
|
||||
|
@ -853,10 +854,29 @@ RETRO_API bool retro_unserialize(const void *data, size_t size)
|
|||
|
||||
RETRO_API void retro_cheat_reset()
|
||||
{
|
||||
cheatList.reset();
|
||||
emulator->cheats(cheatList);
|
||||
}
|
||||
|
||||
RETRO_API void retro_cheat_set(unsigned index, bool enabled, const char *code)
|
||||
{
|
||||
string cheat = string(code);
|
||||
bool decoded = false;
|
||||
|
||||
if (program->gameBoy.program)
|
||||
{
|
||||
decoded = decodeGB(cheat);
|
||||
}
|
||||
else
|
||||
{
|
||||
decoded = decodeSNES(cheat);
|
||||
}
|
||||
|
||||
if (enabled && decoded)
|
||||
{
|
||||
cheatList.append(cheat);
|
||||
emulator->cheats(cheatList);
|
||||
}
|
||||
}
|
||||
|
||||
RETRO_API bool retro_load_game(const retro_game_info *game)
|
||||
|
|
|
@ -28,7 +28,7 @@ struct Program : Emulator::Platform
|
|||
auto open(uint id, string name, vfs::file::mode mode, bool required) -> shared_pointer<vfs::file> override;
|
||||
auto load(uint id, string name, string type, vector<string> options = {}) -> Emulator::Platform::Load override;
|
||||
auto videoFrame(const uint32* data, uint pitch, uint width, uint height, uint scale) -> void override;
|
||||
auto audioFrame(const float* samples, uint channels) -> void override;
|
||||
auto audioFrame(const double* samples, uint channels) -> void override;
|
||||
auto inputPoll(uint port, uint device, uint input) -> int16 override;
|
||||
auto inputRumble(uint port, uint device, uint input, bool enable) -> void override;
|
||||
|
||||
|
@ -146,12 +146,31 @@ auto Program::load() -> void {
|
|||
auto title = superFamicom.title;
|
||||
auto region = superFamicom.region;
|
||||
|
||||
//sometimes menu options are skipped over in the main menu with cycle-based joypad polling
|
||||
if(title == "Arcades Greatest Hits") emulator->configure("Hacks/CPU/FastJoypadPolling", true);
|
||||
|
||||
//the start button doesn't work in this game with cycle-based joypad polling
|
||||
if(title == "TAIKYOKU-IGO Goliath") emulator->configure("Hacks/CPU/FastJoypadPolling", true);
|
||||
|
||||
//holding up or down on the menu quickly cycles through options instead of stopping after each button press
|
||||
if(title == "WORLD MASTERS GOLF") emulator->configure("Hacks/CPU/FastJoypadPolling", true);
|
||||
|
||||
//relies on mid-scanline rendering techniques
|
||||
if(title == "AIR STRIKE PATROL" || title == "DESERT FIGHTER") emulator->configure("Hacks/PPU/Fast", false);
|
||||
|
||||
//the dialogue text is blurry due to an issue in the scanline-based renderer's color math support
|
||||
if(title == "マーヴェラス") emulator->configure("Hacks/PPU/Fast", false);
|
||||
|
||||
//stage 2 uses pseudo-hires in a way that's not compatible with the scanline-based renderer
|
||||
if(title == "SFC クレヨンシンチャン") emulator->configure("Hacks/PPU/Fast", false);
|
||||
|
||||
//title screen game select (after choosing a game) changes OAM tiledata address mid-frame
|
||||
//this is only supported by the cycle-based PPU renderer
|
||||
if(title == "Winter olympics") emulator->configure("Hacks/PPU/Fast", false);
|
||||
|
||||
//title screen shows remnants of the flag after choosing a language with the scanline-based renderer
|
||||
if(title == "WORLD CUP STRIKER") emulator->configure("Hacks/PPU/Fast", false);
|
||||
|
||||
//relies on cycle-accurate writes to the echo buffer
|
||||
if(title == "KOUSHIEN_2") emulator->configure("Hacks/DSP/Fast", false);
|
||||
|
||||
|
@ -165,13 +184,22 @@ auto Program::load() -> void {
|
|||
if(title == "ADVENTURES OF FRANKEN" && region == "PAL") emulator->configure("Hacks/PPU/RenderCycle", 32);
|
||||
|
||||
//fixes an errant scanline on the title screen due to writing to PPU registers too late
|
||||
if(title == "FIREPOWER 2000") emulator->configure("Hacks/PPU/RenderCycle", 32);
|
||||
if(title == "FIREPOWER 2000" || title == "SUPER SWIV") emulator->configure("Hacks/PPU/RenderCycle", 32);
|
||||
|
||||
//fixes an errant scanline on the title screen due to writing to PPU registers too late
|
||||
if(title == "NHL '94" || title == "NHL PROHOCKEY'94") emulator->configure("Hacks/PPU/RenderCycle", 32);
|
||||
|
||||
//fixes an errant scanline on the title screen due to writing to PPU registers too late
|
||||
if(title == "Sugoro Quest++") emulator->configure("Hacks/PPU/RenderCycle", 128);
|
||||
|
||||
if (emulator->configuration("Hacks/Hotfixes")) {
|
||||
if (title == "The Hurricanes") emulator->configure("Hacks/Entropy", "None");
|
||||
//this game transfers uninitialized memory into video RAM: this can cause a row of invalid tiles
|
||||
//to appear in the background of stage 12. this one is a bug in the original game, so only enable
|
||||
//it if the hotfixes option has been enabled.
|
||||
if(title == "The Hurricanes") emulator->configure("Hacks/Entropy", "None");
|
||||
|
||||
//Frisky Tom attract sequence sometimes hangs when WRAM is initialized to pseudo-random patterns
|
||||
if (title == "ニチブツ・アーケード・クラシックス") emulator->configure("Hacks/Entropy", "None");
|
||||
}
|
||||
|
||||
emulator->power();
|
||||
|
@ -216,7 +244,7 @@ static int16_t d2i16(double v)
|
|||
return int16_t(floor(v + 0.5));
|
||||
}
|
||||
|
||||
auto Program::audioFrame(const float* samples, uint channels) -> void
|
||||
auto Program::audioFrame(const double* samples, uint channels) -> void
|
||||
{
|
||||
int16_t left = d2i16(samples[0]);
|
||||
int16_t right = d2i16(samples[1]);
|
||||
|
@ -321,6 +349,17 @@ auto Program::openRomSuperFamicom(string name, vfs::file::mode mode) -> shared_p
|
|||
return vfs::memory::file::open(superFamicom.expansion.data(), superFamicom.expansion.size());
|
||||
}
|
||||
|
||||
if(name == "msu1/data.rom")
|
||||
{
|
||||
return vfs::fs::file::open({Location::notsuffix(superFamicom.location), ".msu"}, mode);
|
||||
}
|
||||
|
||||
if(name.match("msu1/track*.pcm"))
|
||||
{
|
||||
name.trimLeft("msu1/track", 1L);
|
||||
return vfs::fs::file::open({Location::notsuffix(superFamicom.location), name}, mode);
|
||||
}
|
||||
|
||||
if(name == "save.ram")
|
||||
{
|
||||
string save_path;
|
||||
|
@ -485,3 +524,172 @@ auto Program::hackPatchMemory(vector<uint8_t>& data) -> void
|
|||
if(data[0x4e9a] == 0x10) data[0x4e9a] = 0x80;
|
||||
}
|
||||
}
|
||||
|
||||
auto decodeSNES(string& code) -> bool {
|
||||
//Game Genie
|
||||
if(code.size() == 9 && code[4u] == '-') {
|
||||
//strip '-'
|
||||
code = {code.slice(0, 4), code.slice(5, 4)};
|
||||
//validate
|
||||
for(uint n : code) {
|
||||
if(n >= '0' && n <= '9') continue;
|
||||
if(n >= 'a' && n <= 'f') continue;
|
||||
return false;
|
||||
}
|
||||
//decode
|
||||
code.transform("df4709156bc8a23e", "0123456789abcdef");
|
||||
uint32_t r = toHex(code);
|
||||
//abcd efgh ijkl mnop qrst uvwx
|
||||
//ijkl qrst opab cduv wxef ghmn
|
||||
uint address =
|
||||
(!!(r & 0x002000) << 23) | (!!(r & 0x001000) << 22)
|
||||
| (!!(r & 0x000800) << 21) | (!!(r & 0x000400) << 20)
|
||||
| (!!(r & 0x000020) << 19) | (!!(r & 0x000010) << 18)
|
||||
| (!!(r & 0x000008) << 17) | (!!(r & 0x000004) << 16)
|
||||
| (!!(r & 0x800000) << 15) | (!!(r & 0x400000) << 14)
|
||||
| (!!(r & 0x200000) << 13) | (!!(r & 0x100000) << 12)
|
||||
| (!!(r & 0x000002) << 11) | (!!(r & 0x000001) << 10)
|
||||
| (!!(r & 0x008000) << 9) | (!!(r & 0x004000) << 8)
|
||||
| (!!(r & 0x080000) << 7) | (!!(r & 0x040000) << 6)
|
||||
| (!!(r & 0x020000) << 5) | (!!(r & 0x010000) << 4)
|
||||
| (!!(r & 0x000200) << 3) | (!!(r & 0x000100) << 2)
|
||||
| (!!(r & 0x000080) << 1) | (!!(r & 0x000040) << 0);
|
||||
uint data = r >> 24;
|
||||
code = {hex(address, 6L), "=", hex(data, 2L)};
|
||||
return true;
|
||||
}
|
||||
|
||||
//Pro Action Replay
|
||||
if(code.size() == 8) {
|
||||
//validate
|
||||
for(uint n : code) {
|
||||
if(n >= '0' && n <= '9') continue;
|
||||
if(n >= 'a' && n <= 'f') continue;
|
||||
return false;
|
||||
}
|
||||
//decode
|
||||
uint32_t r = toHex(code);
|
||||
uint address = r >> 8;
|
||||
uint data = r & 0xff;
|
||||
code = {hex(address, 6L), "=", hex(data, 2L)};
|
||||
return true;
|
||||
}
|
||||
|
||||
//higan: address=data
|
||||
if(code.size() == 9 && code[6u] == '=') {
|
||||
string nibbles = {code.slice(0, 6), code.slice(7, 2)};
|
||||
//validate
|
||||
for(uint n : nibbles) {
|
||||
if(n >= '0' && n <= '9') continue;
|
||||
if(n >= 'a' && n <= 'f') continue;
|
||||
return false;
|
||||
}
|
||||
//already in decoded form
|
||||
return true;
|
||||
}
|
||||
|
||||
//higan: address=compare?data
|
||||
if(code.size() == 12 && code[6u] == '=' && code[9u] == '?') {
|
||||
string nibbles = {code.slice(0, 6), code.slice(7, 2), code.slice(10, 2)};
|
||||
//validate
|
||||
for(uint n : nibbles) {
|
||||
if(n >= '0' && n <= '9') continue;
|
||||
if(n >= 'a' && n <= 'f') continue;
|
||||
return false;
|
||||
}
|
||||
//already in decoded form
|
||||
return true;
|
||||
}
|
||||
|
||||
//unrecognized code format
|
||||
return false;
|
||||
}
|
||||
|
||||
auto decodeGB(string& code) -> bool {
|
||||
auto nibble = [&](const string& s, uint index) -> uint {
|
||||
if(index >= s.size()) return 0;
|
||||
if(s[index] >= '0' && s[index] <= '9') return s[index] - '0';
|
||||
return s[index] - 'a' + 10;
|
||||
};
|
||||
|
||||
//Game Genie
|
||||
if(code.size() == 7 && code[3u] == '-') {
|
||||
code = {code.slice(0, 3), code.slice(4, 3)};
|
||||
//validate
|
||||
for(uint n : code) {
|
||||
if(n >= '0' && n <= '9') continue;
|
||||
if(n >= 'a' && n <= 'f') continue;
|
||||
return false;
|
||||
}
|
||||
uint data = nibble(code, 0) << 4 | nibble(code, 1) << 0;
|
||||
uint address = (nibble(code, 5) ^ 15) << 12 | nibble(code, 2) << 8 | nibble(code, 3) << 4 | nibble(code, 4) << 0;
|
||||
code = {hex(address, 4L), "=", hex(data, 2L)};
|
||||
return true;
|
||||
}
|
||||
|
||||
//Game Genie
|
||||
if(code.size() == 11 && code[3u] == '-' && code[7u] == '-') {
|
||||
code = {code.slice(0, 3), code.slice(4, 3), code.slice(8, 3)};
|
||||
//validate
|
||||
for(uint n : code) {
|
||||
if(n >= '0' && n <= '9') continue;
|
||||
if(n >= 'a' && n <= 'f') continue;
|
||||
return false;
|
||||
}
|
||||
uint data = nibble(code, 0) << 4 | nibble(code, 1) << 0;
|
||||
uint address = (nibble(code, 5) ^ 15) << 12 | nibble(code, 2) << 8 | nibble(code, 3) << 4 | nibble(code, 4) << 0;
|
||||
uint8_t t = nibble(code, 6) << 4 | nibble(code, 8) << 0;
|
||||
t = t >> 2 | t << 6;
|
||||
uint compare = t ^ 0xba;
|
||||
code = {hex(address, 4L), "=", hex(compare, 2L), "?", hex(data, 2L)};
|
||||
return true;
|
||||
}
|
||||
|
||||
//GameShark
|
||||
if(code.size() == 8) {
|
||||
//validate
|
||||
for(uint n : code) {
|
||||
if(n >= '0' && n <= '9') continue;
|
||||
if(n >= 'a' && n <= 'f') continue;
|
||||
return false;
|
||||
}
|
||||
//first two characters are the code type / VRAM bank, which is almost always 01.
|
||||
//other values are presumably supported, but I have no info on them, so they're not supported.
|
||||
if(code[0u] != '0') return false;
|
||||
if(code[1u] != '1') return false;
|
||||
uint data = toHex(code.slice(2, 2));
|
||||
uint16_t address = toHex(code.slice(4, 4));
|
||||
address = address >> 8 | address << 8;
|
||||
code = {hex(address, 4L), "=", hex(data, 2L)};
|
||||
return true;
|
||||
}
|
||||
|
||||
//higan: address=data
|
||||
if(code.size() == 7 && code[4u] == '=') {
|
||||
string nibbles = {code.slice(0, 4), code.slice(5, 2)};
|
||||
//validate
|
||||
for(uint n : nibbles) {
|
||||
if(n >= '0' && n <= '9') continue;
|
||||
if(n >= 'a' && n <= 'f') continue;
|
||||
return false;
|
||||
}
|
||||
//already in decoded form
|
||||
return true;
|
||||
}
|
||||
|
||||
//higan: address=compare?data
|
||||
if(code.size() == 10 && code[4u] == '=' && code[7u] == '?') {
|
||||
string nibbles = {code.slice(0, 4), code.slice(5, 2), code.slice(8, 2)};
|
||||
//validate
|
||||
for(uint n : nibbles) {
|
||||
if(n >= '0' && n <= '9') continue;
|
||||
if(n >= 'a' && n <= 'f') continue;
|
||||
return false;
|
||||
}
|
||||
//already in decoded form
|
||||
return true;
|
||||
}
|
||||
|
||||
//unrecognized code format
|
||||
return false;
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -30,6 +30,15 @@
|
|||
#define section(name) __declspec(allocate("." #name))
|
||||
#elif defined(__APPLE__)
|
||||
#define section(name) __attribute__((section("__TEXT,__" #name)))
|
||||
#elif defined(__SWITCH__)
|
||||
/*
|
||||
This is basically the same as the last case, however the "#" suffix will create a secondary .text section.
|
||||
Because of that, the toolchain will treat the section as non-executable. This might be related to the linker scripts
|
||||
used for libnx homebrew. The reason that this is a seperate ifdef, is purely to silence a cosmetic warn
|
||||
about ignoring the +w attribute on .text which would happen on other platforms under some conditions (said warning is by design
|
||||
when data is being merged like this into .text).
|
||||
*/
|
||||
#define section(name) __attribute__((section("." #name)))
|
||||
#else
|
||||
#define section(name) __attribute__((section("." #name "#")))
|
||||
#endif
|
||||
|
|
|
@ -34,15 +34,17 @@ ifeq ($(platform),)
|
|||
else
|
||||
$(error unknown platform, please specify manually.)
|
||||
endif
|
||||
endif
|
||||
|
||||
# common commands
|
||||
ifeq ($(uname),)
|
||||
delete = $(info Deleting $1 ...) @del /q $(subst /,\,$1)
|
||||
rdelete = $(info Deleting $1 ...) @del /s /q $(subst /,\,$1) && if exist $(subst /,\,$1) (rmdir /s /q $(subst /,\,$1))
|
||||
else
|
||||
delete = $(info Deleting $1 ...) @rm -f $1
|
||||
rdelete = $(info Deleting $1 ...) @rm -rf $1
|
||||
endif
|
||||
# common commands
|
||||
ifeq ($(shell echo ^^),^)
|
||||
# cmd
|
||||
delete = $(info Deleting $1 ...) @del /q $(subst /,\,$1)
|
||||
rdelete = $(info Deleting $1 ...) @del /s /q $(subst /,\,$1) && if exist $(subst /,\,$1) (rmdir /s /q $(subst /,\,$1))
|
||||
else
|
||||
# sh
|
||||
delete = $(info Deleting $1 ...) @rm -f $1
|
||||
rdelete = $(info Deleting $1 ...) @rm -rf $1
|
||||
endif
|
||||
|
||||
compiler.c = $(compiler) -x c -std=c11
|
||||
|
@ -66,6 +68,14 @@ ifeq ($(compiler),)
|
|||
compiler := clang++
|
||||
else ifeq ($(platform),linux)
|
||||
compiler := g++
|
||||
else ifeq ($(platform),libnx)
|
||||
include $(DEVKITPRO)/libnx/switch_rules
|
||||
PORTLIBS := $(PORTLIBS_PATH)/switch
|
||||
PATH := $(PORTLIBS)/bin:$(PATH)
|
||||
LIBNX ?= $(DEVKITPRO)/libnx
|
||||
compiler = $(CC) -std=gnu11
|
||||
compiler.cpp = $(CXX) -std=gnu++17
|
||||
openmp = false
|
||||
else ifeq ($(platform),bsd)
|
||||
compiler := g++8
|
||||
else
|
||||
|
@ -128,6 +138,11 @@ ifeq ($(platform),linux)
|
|||
options += -ldl
|
||||
endif
|
||||
|
||||
# libnx settings
|
||||
ifeq ($(platform),libnx)
|
||||
flags += -D__SWITCH__=1 -DSWITCH -DHAVE_LIBNX
|
||||
endif
|
||||
|
||||
# bsd settings
|
||||
ifeq ($(platform),bsd)
|
||||
flags += -I/usr/local/include
|
||||
|
|
|
@ -10,7 +10,11 @@
|
|||
#else
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#if defined(PLATFORM_HORIZON)
|
||||
#include <nall/horizon/mman.hpp>
|
||||
#else
|
||||
#include <sys/mman.h>
|
||||
#endif // PLATFORM_HORIZON
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
|
39
nall/horizon/mman.hpp
Normal file
39
nall/horizon/mman.hpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
// Workaround since we don't support file mappings on Horizon, but this is currently not functional.
|
||||
// To make it work, the file could be read when the file_map is opened
|
||||
#define PROT_READ 0b001
|
||||
#define PROT_WRITE 0b010
|
||||
#define PROT_EXEC 0b100
|
||||
#define MAP_PRIVATE 2
|
||||
#define MAP_FIXED 0x10
|
||||
#define MAP_ANONYMOUS 0x20
|
||||
#define MAP_FAILED ((void *)-1)
|
||||
#define MAP_SHARED 0
|
||||
|
||||
static inline void *mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset)
|
||||
{
|
||||
return malloc(len);
|
||||
}
|
||||
|
||||
static inline int mprotect(void *addr, size_t len, int prot)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int munmap(void *addr, size_t len)
|
||||
{
|
||||
free(addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -4,7 +4,7 @@ namespace nall {
|
|||
using uint = unsigned;
|
||||
|
||||
enum class Compiler : uint { Clang, GCC, Microsoft, Unknown };
|
||||
enum class Platform : uint { Windows, MacOS, Linux, BSD, Android, Unknown };
|
||||
enum class Platform : uint { Windows, MacOS, Linux, BSD, Android, Horizon, Unknown };
|
||||
enum class API : uint { Windows, Posix, Unknown };
|
||||
enum class DisplayServer : uint { Windows, Quartz, Xorg, Unknown };
|
||||
enum class Architecture : uint { x86, amd64, ARM32, ARM64, PPC32, PPC64, Unknown };
|
||||
|
@ -89,6 +89,13 @@ namespace nall {
|
|||
constexpr auto platform() -> Platform { return Platform::Android; }
|
||||
constexpr auto api() -> API { return API::Posix; }
|
||||
constexpr auto display() -> DisplayServer { return DisplayServer::Unknown; }
|
||||
#elif defined(__SWITCH__)
|
||||
#define PLATFORM_HORIZON
|
||||
#define API_POSIX
|
||||
#define DISPLAY_UNKNOWN
|
||||
constexpr auto platform() -> Platform { return Platform::Horizon; }
|
||||
constexpr auto api() -> API { return API::Posix; }
|
||||
constexpr auto display() -> DisplayServer { return DisplayServer::Unknown; }
|
||||
#elif defined(linux) || defined(__linux__)
|
||||
#define PLATFORM_LINUX
|
||||
#define API_POSIX
|
||||
|
@ -157,7 +164,7 @@ namespace nall {
|
|||
|
||||
namespace nall {
|
||||
|
||||
#if (defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN) || defined(__LITTLE_ENDIAN__) || defined(__i386__) || defined(__amd64__) || defined(_M_IX86) || defined(_M_AMD64)
|
||||
#if (defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && __BYTE_ORDER == __LITTLE_ENDIAN) || defined(__LITTLE_ENDIAN__) || defined(__i386__) || defined(__amd64__) || defined(_M_IX86) || defined(_M_AMD64) || defined(__aarch64__)
|
||||
#define ENDIAN_LSB
|
||||
constexpr auto endian() -> Endian { return Endian::LSB; }
|
||||
#elif (defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) && __BYTE_ORDER == __BIG_ENDIAN) || defined(__BIG_ENDIAN__) || defined(__powerpc__) || defined(_M_PPC)
|
||||
|
|
|
@ -24,7 +24,9 @@
|
|||
#include <nall/bit.hpp>
|
||||
#include <nall/chrono.hpp>
|
||||
#include <nall/directory.hpp>
|
||||
#if !defined(PLATFORM_HORIZON)
|
||||
#include <nall/dl.hpp>
|
||||
#endif // PLATFORM_HORIZON
|
||||
#include <nall/endian.hpp>
|
||||
#include <nall/file.hpp>
|
||||
#include <nall/file-buffer.hpp>
|
||||
|
|
|
@ -45,7 +45,9 @@ namespace Math {
|
|||
#include <sys/stat.h>
|
||||
|
||||
#if !defined(PLATFORM_WINDOWS)
|
||||
#if !defined(PLATFORM_HORIZON)
|
||||
#include <dlfcn.h>
|
||||
#endif // PLATFORM_HORIZON
|
||||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
|
|
|
@ -4,10 +4,11 @@
|
|||
|
||||
#include <nall/shared-memory.hpp>
|
||||
|
||||
#if defined(API_POSIX)
|
||||
#if defined(API_POSIX) && !defined(PLATFORM_HORIZON)
|
||||
#include <nall/posix/service.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(API_WINDOWS)
|
||||
// For Horizon we re-use the Windows stub
|
||||
#if defined(API_WINDOWS) || defined(PLATFORM_HORIZON)
|
||||
#include <nall/windows/service.hpp>
|
||||
#endif
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
#include <nall/memory.hpp>
|
||||
#include <nall/string.hpp>
|
||||
|
||||
#if defined(API_POSIX)
|
||||
#if defined(API_POSIX) && !defined(PLATFORM_HORIZON)
|
||||
#include <nall/posix/shared-memory.hpp>
|
||||
#endif
|
||||
|
||||
#if defined(API_WINDOWS)
|
||||
// For Horizon we re-use the Windows stub
|
||||
#if defined(API_WINDOWS) || defined(PLATFORM_HORIZON)
|
||||
#include <nall/windows/shared-memory.hpp>
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue