Skip to content

Commit

Permalink
v107.7
Browse files Browse the repository at this point in the history
I've started on a new multi-system emulator, byuu.
It will share all cores with higan, and as such will be focused on accuracy and self-documenting code foremost.
But unlike higan, I will do everything possible to make the program featureful and easy to use.
The way I'm doing this is through a translation layer to abstract higan's tree-view into a list-view.
The list-view is similar to higan v106 and earlier. I'm also going to add more ease-of-use improvements from bsnes.
The list-view will sacrifice support for extreme edge cases, but should more than make up for it in ease of use.
bsnes' success greatly exceeded my expectations, and resulted in many improvements to higan's SNES core as well.
But unfortunately, bsnes is for the SNES only, and I just don't have the bandwidth to maintain 24 emulator projects.
As such, the goal of this project is to try and create an easy-to-use alternative for *all* of my emulator cores.
Right now, I'm maintaining this as an alternate user interface target inside the higan source tree.
Long-term, the intention is that higan and byuu will be equal emulators, rather than one being a superset of the other.
I don't know how that final form will look just yet, but for now, this will at least allow me to keep the history in Git.
I do ask that binaries not be distributed of byuu until the software is ready for release.
I wouldn't even recommend using it. It's not really functional at all yet. But it'll get there over time.
  • Loading branch information
byuu committed Jan 30, 2020
1 parent 88758a0 commit 1ed1e05
Show file tree
Hide file tree
Showing 41 changed files with 1,210 additions and 29 deletions.
1 change: 1 addition & 0 deletions higan/GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
target := higan
#target := byuu
build := performance
openmp := false
local := true
Expand Down
13 changes: 11 additions & 2 deletions higan/System/Super Famicom/boards.bml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
database
revision: 2020-01-01
revision: 2020-01-21

//Boards (Production)

database
revision: 2020-01-01
revision: 2020-01-21

board: BANDAI-PT-923
memory type=ROM content=Program
Expand Down Expand Up @@ -544,6 +544,15 @@ board: SHVC-LDH3C-01
map address=00-3f,80-bf:4840-4842
memory type=RTC content=Time manufacturer=Epson

board: SHVC-LJ3M-01
memory type=ROM content=Program
map address=00-3f:8000-ffff base=0x400000
map address=40-7d:0000-ffff base=0x400000
map address=80-bf:8000-ffff mask=0xc00000
map address=c0-ff:0000-ffff mask=0xc00000
memory type=RAM content=Save
map address=80-bf:6000-7fff mask=0xe000

board: SHVC-LN3B-01
memory type=RAM content=Save
map address=00-3f,80-bf:6000-7fff mask=0xe000
Expand Down
3 changes: 2 additions & 1 deletion higan/emulator/emulator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <nall/any.hpp>
#include <nall/array.hpp>
#include <nall/chrono.hpp>
#include <nall/directory.hpp>
#include <nall/dl.hpp>
#include <nall/endian.hpp>
#include <nall/image.hpp>
Expand Down Expand Up @@ -39,7 +40,7 @@ using namespace nall;

namespace higan {
static const string Name = "higan";
static const string Version = "107.6";
static const string Version = "107.7";
static const string Author = "byuu";
static const string License = "GPLv3";
static const string Website = "https://byuu.org";
Expand Down
3 changes: 3 additions & 0 deletions higan/emulator/interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ struct Interface {
//state functions
virtual auto serialize() -> serializer { return {}; }
virtual auto unserialize(serializer&) -> bool { return false; }

//debugging functions
virtual auto exportMemory() -> bool { return false; }
};

}
7 changes: 5 additions & 2 deletions higan/emulator/node/event/instruction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@ struct Instruction : Event {

auto notify(string_view instruction, string_view context, string_view extra = {}) -> void {
if(_omitted) {
PlatformLog({_component, " [Omitted: ", _omitted, "]\n"});
PlatformLog({
//_component, " ",
"[Omitted: ", _omitted, "]\n"}
);
_omitted = 0;
}

string output{
_component, " ",
//_component, " ",
hex(_address, _addressBits + 3 >> 2), " ",
instruction, " ",
context, " ",
Expand Down
2 changes: 1 addition & 1 deletion higan/emulator/node/object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ struct Object : shared_pointer_this<Object> {
}

template<typename T = Node::Object>
auto find(string name) -> Node::Object {
auto find(string name) -> T {
using Type = typename T::type;
for(auto& node : _nodes) {
if(node->identity() == Type::identifier && node->_name == name) return node;
Expand Down
7 changes: 7 additions & 0 deletions higan/sfc/interface/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,11 @@ auto SuperFamicomInterface::unserialize(serializer& s) -> bool {
return system.unserialize(s);
}

auto SuperFamicomInterface::exportMemory() -> bool {
directory::create("/tmpfs/Memory/Super Famicom/");
file::write("/tmpfs/Memory/Super Famicom/wram.bin", {cpu.wram, 128 * 1024});
file::write("/tmpfs/Memory/Super Famicom/vram.bin", {ppu.vram.data, 64 * 1024});
return true;
}

}
2 changes: 2 additions & 0 deletions higan/sfc/interface/interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ struct SuperFamicomInterface : Interface {

auto serialize() -> serializer override;
auto unserialize(serializer&) -> bool override;

auto exportMemory() -> bool override;
};

}
Expand Down
3 changes: 1 addition & 2 deletions higan/sfc/ppu/background.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ auto PPU::Background::scanline() -> void {
mosaic.hoffset = 0;

renderingIndex = 0;
pixelCounter = io.hoffset & 7;

opt.hoffset = 0;
opt.voffset = 0;

pixelCounter = io.hoffset & 7;
}

//H = 56
Expand Down
2 changes: 1 addition & 1 deletion higan/sfc/ppu/ppu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ struct PPU : Thread, PPUcounter {
friend class PPU::Window;
friend class PPU::Screen;
friend class System;
friend class PPUfast;
friend class SuperFamicomInterface;
};

extern PPU ppu;
61 changes: 61 additions & 0 deletions higan/target-byuu/GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name := byuu

hiro.path := ../hiro
hiro.resource := $(ui)/resource/byuu.rc
include $(hiro.path)/GNUmakefile

ruby.path := ../ruby
include $(ruby.path)/GNUmakefile

objects += ui-byuu ui-resource ui-emulator ui-program ui-presentation
objects := $(objects:%=obj/%.o)

obj/ui-byuu.o: $(ui)/byuu.cpp
obj/ui-resource.o: $(ui)/resource/resource.cpp
obj/ui-emulator.o: $(ui)/emulator/emulator.cpp
obj/ui-program.o: $(ui)/program/program.cpp
obj/ui-presentation.o: $(ui)/presentation/presentation.cpp

all: $(hiro.objects) $(ruby.objects) $(objects)
$(info Linking out/$(name) ...)
+@$(compiler) -o out/$(name) $(hiro.objects) $(ruby.objects) $(objects) $(hiro.options) $(ruby.options) $(options)
ifeq ($(platform),macos)
rm -rf out/$(name).app
mkdir -p out/$(name).app/Contents/MacOS/
mkdir -p out/$(name).app/Contents/Resources/
mv out/$(name) out/$(name).app/Contents/MacOS/$(name)
cp $(ui)/resource/$(name).plist out/$(name).app/Contents/Info.plist
sips -s format icns $(ui)/resource/$(name).png --out out/$(name).app/Contents/Resources/$(name).icns
endif

verbose: hiro.verbose ruby.verbose nall.verbose all;

install: all
ifeq ($(platform),windows)
mkdir -p $(prefix)/$(name)/
else ifeq ($(shell id -un),root)
$(error "make install should not be run as root")
else ifeq ($(platform),macos)
mkdir -p ~/Library/Application\ Support/$(name)/
cp -R out/$(name).app /Applications/$(name).app
else ifneq ($(filter $(platform),linux bsd),)
mkdir -p $(prefix)/bin/
mkdir -p $(prefix)/share/applications/
mkdir -p $(prefix)/share/icons/
mkdir -p $(prefix)/share/$(name)/
cp out/$(name) $(prefix)/bin/$(name)
cp $(ui)/resource/$(name).desktop $(prefix)/share/applications/$(name).desktop
cp $(ui)/resource/$(name).png $(prefix)/share/icons/$(name).png
endif

uninstall:
ifeq ($(platform),windows)
else ifeq ($(shell id -un),root)
$(error "make uninstall should not be run as root")
else ifeq ($(platform),macos)
rm -rf /Applications/$(name).app
else ifneq ($(filter $(platform),linux bsd),)
rm -f $(prefix)/bin/$(name)
rm -f $(prefix)/share/applications/$(name).desktop
rm -f $(prefix)/share/icons/$(name).png
endif
36 changes: 36 additions & 0 deletions higan/target-byuu/byuu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include "byuu.hpp"

namespace ruby {
Video video;
Audio audio;
Input input;
}

#include <nall/main.hpp>
auto nall::main(Arguments arguments) -> void {
Application::setName("byuu");
Application::setScreenSaver(false);

Emulator::construct();
Instances::presentation.construct();

if(!Path::user().find("byuu")) {
MessageDialog()
.setTitle("byuu")
.setText({
"Note: this is pre-alpha software!\n"
"Development literally just started.\n\n"
"Please do not distribute binaries of byuu.\n"
"Please do not report any bugs.\n"
"Please don't even run this at all!\n"
"If you do so anyway, the consequences are on you."
})
.information();
}

program.create();
Application::onMain({&Program::main, &program});
Application::run();

Instances::presentation.destruct();
}
20 changes: 20 additions & 0 deletions higan/target-byuu/byuu.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <ruby/ruby.hpp>
//using namespace ruby;

#include <hiro/hiro.hpp>
using namespace hiro;

#include <emulator/emulator.hpp>

#include <nall/instance.hpp>

namespace ruby {
extern Video video;
extern Audio audio;
extern Input input;
}

#include "resource/resource.hpp"
#include "emulator/emulator.hpp"
#include "program/program.hpp"
#include "presentation/presentation.hpp"
28 changes: 28 additions & 0 deletions higan/target-byuu/emulator/emulator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "../byuu.hpp"
#include "famicom.cpp"

vector<shared_pointer<Emulator::Instance>> emulators;
shared_pointer<Emulator::Instance> emulator;

namespace Emulator {

auto construct() -> void {
#ifdef CORE_FC
emulators.append(new Emulator::Famicom);
#endif
}

auto Instance::load(const string& name, const vector<uint8_t>& data) -> void {
game.name = name;
game.data = data;

auto system = higan::Node::System::create();
system->setName(interface->name());
auto configuration = higan::Node::serialize(system);
interface->load(root, configuration);

load();
interface->power();
}

}
39 changes: 39 additions & 0 deletions higan/target-byuu/emulator/emulator.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
namespace Emulator {

struct Instance {
auto load(const string& name, const vector<uint8_t>& data) -> void;
virtual auto load() -> void = 0;
virtual auto load(higan::Node::Object, string name, vfs::file::mode mode, bool required) -> shared_pointer<vfs::file> = 0;

struct Port {
string name;
};

struct Game {
string name;
string manifest;
vector<uint8_t> data;
};

shared_pointer<higan::Interface> interface;
string name;
string abbreviation;
vector<string> extensions;
vector<Port> ports;

higan::Node::Object root;
Game game;
};

auto construct() -> void;

struct Famicom : Instance {
Famicom();
auto load() -> void;
auto load(higan::Node::Object, string name, vfs::file::mode mode, bool required) -> shared_pointer<vfs::file>;
};

}

extern vector<shared_pointer<Emulator::Instance>> emulators;
extern shared_pointer<Emulator::Instance> emulator;
50 changes: 50 additions & 0 deletions higan/target-byuu/emulator/famicom.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include <fc/interface/interface.hpp>

namespace Emulator {

Famicom::Famicom() {
interface = new higan::Famicom::FamicomInterface;
name = "Nintendo";
abbreviation = "NES";
extensions = {"nes"};

{ Port port;
port.name = "Controller Port 1";
ports.append(port);
}

{ Port port;
port.name = "Controller Port 2";
ports.append(port);
}
}

auto Famicom::load() -> void {
if(auto port = root->find<higan::Node::Port>("Cartridge Slot")) {
auto peripheral = port->allocate();
peripheral->setAttribute("id", "rom");
peripheral->setAttribute("location", game.name);
port->connect(peripheral);
}
}

auto Famicom::load(higan::Node::Object node, string name, vfs::file::mode mode, bool required) -> shared_pointer<vfs::file> {
auto document = BML::unserialize(game.manifest);
auto headerSize = document["game/board/memory(content=iNES,type=ROM)/size"].natural();
auto programSize = document["game/board/memory(content=Program,type=ROM)/size"].natural();
auto characterSize = document["game/board/memory(content=Character,type=ROM)/size"].natural();

if(name == "program.rom") {
uint address = headerSize;
return vfs::memory::file::open(game.data.data() + address, programSize);
}

if(name == "character.rom") {
uint address = headerSize + programSize;
return vfs::memory::file::open(game.data.data() + address, characterSize);
}

return {};
}

}
Loading

0 comments on commit 1ed1e05

Please sign in to comment.