mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-08-16 15:34:46 +02:00
Update to v106r84 release.
byuu says: Changelog: - fixed a few TLCS900H CPU and disassembler bugs - hooked up a basic Neo Geo Pocket emulator skeleton and memory map; can run a few instructions from the BIOS - emulated the flash memory used by Neo Geo Pocket games - added sourcery to the higan source archives - fixed ternary expressions in sfc/ppu-fast [hex_usr]
This commit is contained in:
26
sourcery/GNUmakefile
Normal file
26
sourcery/GNUmakefile
Normal file
@@ -0,0 +1,26 @@
|
||||
name := sourcery
|
||||
build := stable
|
||||
flags += -I..
|
||||
|
||||
nall.path := ../nall
|
||||
include $(nall.path)/GNUmakefile
|
||||
|
||||
objects := obj/sourcery.o
|
||||
|
||||
obj/sourcery.o: sourcery.cpp
|
||||
|
||||
all: $(objects)
|
||||
$(info Linking out/$(name) ...)
|
||||
+@$(compiler) -o out/$(name) $(objects) $(options)
|
||||
|
||||
verbose: nall.verbose all;
|
||||
|
||||
clean:
|
||||
$(call delete,obj/*)
|
||||
$(call delete,out/*)
|
||||
|
||||
install: all
|
||||
cp out/$(name) $(prefix)/bin/$(name)
|
||||
|
||||
uninstall:
|
||||
rm -f $(prefix)/bin/$(name)
|
93
sourcery/sourcery.cpp
Normal file
93
sourcery/sourcery.cpp
Normal file
@@ -0,0 +1,93 @@
|
||||
#include <nall/nall.hpp>
|
||||
using namespace nall;
|
||||
|
||||
struct Sourcery {
|
||||
auto main(Arguments arguments) -> void;
|
||||
auto parse(Markup::Node&) -> void;
|
||||
|
||||
private:
|
||||
string pathname;
|
||||
file_buffer source;
|
||||
file_buffer header;
|
||||
};
|
||||
|
||||
auto Sourcery::main(Arguments arguments) -> void {
|
||||
if(arguments.size() != 3) return print("usage: sourcery resource.bml resource.cpp resource.hpp\n");
|
||||
|
||||
string markupName = arguments.take();
|
||||
string sourceName = arguments.take();
|
||||
string headerName = arguments.take();
|
||||
if(!markupName.endsWith(".bml")) return print("error: arguments in incorrect order\n");
|
||||
if(!sourceName.endsWith(".cpp")) return print("error: arguments in incorrect order\n");
|
||||
if(!headerName.endsWith(".hpp")) return print("error: arguments in incorrect order\n");
|
||||
|
||||
string markup = string::read(markupName);
|
||||
if(!markup) return print("error: unable to read resource manifest\n");
|
||||
|
||||
pathname = Location::path(markupName);
|
||||
if(!source.open(sourceName, file::mode::write)) return print("error: unable to write source file\n");
|
||||
if(!header.open(headerName, file::mode::write)) return print("error: unable to write header file\n");
|
||||
|
||||
source.print("#include \"", headerName, "\"\n");
|
||||
source.print("\n");
|
||||
|
||||
auto document = BML::unserialize(markup);
|
||||
parse(document);
|
||||
}
|
||||
|
||||
auto Sourcery::parse(Markup::Node& root) -> void {
|
||||
for(auto node : root) {
|
||||
if(node.name() == "namespace") {
|
||||
header.print("namespace ", node["name"].text(), " {\n");
|
||||
source.print("namespace ", node["name"].text(), " {\n");
|
||||
parse(node);
|
||||
header.print("}\n");
|
||||
source.print("}\n");
|
||||
} else if(node.name() == "binary") {
|
||||
string filename{pathname, node["file"].text()};
|
||||
if(!file::exists(filename)) {
|
||||
print("warning: binary file ", node["file"].text(), " not found\n");
|
||||
continue;
|
||||
}
|
||||
auto buffer = file::read(filename);
|
||||
header.print("extern const unsigned char ", node["name"].text(), "[", buffer.size(), "];\n");
|
||||
source.print("const unsigned char ", node["name"].text(), "[", buffer.size(), "] = {\n");
|
||||
buffer.foreach([&](uint offset, int data) {
|
||||
if((offset & 31) == 0) source.print(" ");
|
||||
source.print(data, ",");
|
||||
if((offset & 31) == 31) source.print("\n");
|
||||
});
|
||||
if(buffer.size() & 31) source.print("\n");
|
||||
source.print("};\n");
|
||||
} else if(node.name() == "string") {
|
||||
string filename{pathname, node["file"].text()};
|
||||
if(!file::exists(filename)) {
|
||||
print("warning: string file ", node["file"].text(), " not found\n");
|
||||
continue;
|
||||
}
|
||||
auto buffer = file::read(filename);
|
||||
header.print("extern const char ", node["name"].text(), "[", buffer.size() + 1, "];\n");
|
||||
source.print("const char ", node["name"].text(), "[", buffer.size() + 1, "] =\n");
|
||||
buffer.foreach([&](uint offset, char data) {
|
||||
if((offset & 127) == 0) source.print(" \"");
|
||||
if(!data) source.print("\\0");
|
||||
else if(data == '\\') source.print("\\\\");
|
||||
else if(data == '\"') source.print("\\\"");
|
||||
else if(data == '\?') source.print("\\\?");
|
||||
else if(data == '\r') source.print("\\r");
|
||||
else if(data == '\n') source.print("\\n");
|
||||
else if(data == '\t') source.print("\\t");
|
||||
else if(data <= 0x1f || data >= 0x7f) source.print("\\x", hex(data, 2L));
|
||||
else source.print(data);
|
||||
if((offset & 127) == 127) source.print("\"\n");
|
||||
});
|
||||
if(buffer.size() & 127) source.print("\"\n");
|
||||
source.print(";\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include <nall/main.hpp>
|
||||
auto nall::main(Arguments arguments) -> void {
|
||||
Sourcery().main(arguments);
|
||||
}
|
Reference in New Issue
Block a user