diff --git a/.gitmodules b/.gitmodules index e4695a9..15089b6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ [submodule "lib/SDL.zig"] path = lib/SDL.zig url = https://github.com/MasterQ32/SDL.zig -[submodule "lib/zig-toml"] - path = lib/zig-toml - url = https://github.com/aeronavery/zig-toml [submodule "lib/zgui"] path = lib/zgui url = https://git.musuka.dev/paoda/zgui diff --git a/README.md b/README.md index d6ee836..7a0bac0 100644 --- a/README.md +++ b/README.md @@ -84,14 +84,16 @@ Most recently built on Zig [v0.11.0-dev.3299+34865d693](https://github.com/zigla Dependency | Source --- | --- -SDL.zig | known-folders | nfd-zig | +SDL.zig | +tomlz | +zba-gdbstub | +zba-util | zgui | zig-clap | zig-datetime | -zig-toml | -`bitfields.zig` | [https://github.com/FlorenceOS/Florence](https://github.com/FlorenceOS/Florence/blob/aaa5a9e568/lib/util/bitfields.zig) +`bitfield.zig` | [https://github.com/FlorenceOS/Florence](https://github.com/FlorenceOS/Florence/blob/aaa5a9e568/lib/util/bitfields.zig) `gl.zig` | Use `git submodule update --init` from the project root to pull the git relevant git submodules diff --git a/build.zig b/build.zig index c2c72e4..3e04ad6 100644 --- a/build.zig +++ b/build.zig @@ -29,6 +29,7 @@ pub fn build(b: *std.Build) void { exe.addModule("clap", b.dependency("zig-clap", .{}).module("clap")); // https://github.com/Hejsil/zig-clap exe.addModule("gdbstub", b.dependency("zba-gdbstub", .{}).module("gdbstub")); // https://git.musuka.dev/paoda/zba-gdbstub exe.addModule("zba-util", b.dependency("zba-util", .{}).module("zba-util")); // https://git.musuka.dev/paoda/zba-util + exe.addModule("tomlz", b.dependency("tomlz", .{}).module("tomlz")); // https://github.com/mattyhall/tomlz // https://github.com/fabioarnold/nfd-zig const nfd_dep = b.dependency("nfd", .{ .target = target, .optimize = optimize }); @@ -46,7 +47,6 @@ pub fn build(b: *std.Build) void { zgui_pkg.link(exe); exe.addAnonymousModule("bitfield", .{ .source_file = .{ .path = "lib/bitfield.zig" } }); // https://github.com/FlorenceOS/ - exe.addAnonymousModule("toml", .{ .source_file = .{ .path = "lib/zig-toml/src/toml.zig" } }); // https://github.com/aeronavery/zig-toml exe.addAnonymousModule("gl", .{ .source_file = .{ .path = "lib/gl.zig" } }); // https://github.com/MasterQ32/zig-opengl b.installArtifact(exe); diff --git a/build.zig.zon b/build.zig.zon index 0c3b3fb..1f2cec1 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -26,5 +26,9 @@ .url = "https://git.musuka.dev/paoda/zba-util/archive/e616cf09e53f5c402c8f040d14baa211683e70e3.tar.gz", .hash = "1220b80b2c0989dcc47275ab9d7d70da4858ef3c1fe1f934e8d838e65028127f6ef3", }, + .tomlz = .{ + .url = "https://github.com/mattyhall/tomlz/archive/4928d38e9bb682a9966ffe7f41230435d0111b1e.tar.gz", + .hash = "12202b57d7b46fff8d16a17371c4f9b711a56b866f0cd11844e4243c09343a2c4c6d", + }, }, } diff --git a/example.toml b/example.toml index 74a88a8..bc1cb6a 100644 --- a/example.toml +++ b/example.toml @@ -1,4 +1,4 @@ -[Host] +[host] # Using nearest-neighbour scaling, how many times the native resolution # of the game bow should the screen be? win_scale = 3 @@ -7,7 +7,7 @@ vsync = true # Mute ZBA mute = false -[Guest] +[guest] # Sync Emulation to Audio audio_sync = true # Sync Emulation to Video @@ -17,7 +17,7 @@ force_rtc = false # Skip BIOS skip_bios = false -[Debug] +[debug] # Enable detailed CPU logs cpu_trace = false # When false and builtin.mode == .Debug, ZBA will panic diff --git a/lib/zig-toml b/lib/zig-toml deleted file mode 160000 index 016b8bc..0000000 --- a/lib/zig-toml +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 016b8bcf98e50ae9408f6a9606bbec5a9bc6f677 diff --git a/src/config.zig b/src/config.zig index 329d65d..2d4b907 100644 --- a/src/config.zig +++ b/src/config.zig @@ -1,5 +1,5 @@ const std = @import("std"); -const toml = @import("toml"); +const tomlz = @import("tomlz"); const Allocator = std.mem.Allocator; @@ -7,6 +7,7 @@ const log = std.log.scoped(.Config); var state: Config = .{}; const Config = struct { + // FIXME: tomlz expects these to be case sensitive host: Host = .{}, guest: Guest = .{}, debug: Debug = .{}, @@ -58,29 +59,5 @@ pub fn load(allocator: Allocator, file_path: []const u8) !void { const contents = try config_file.readToEndAlloc(allocator, try config_file.getEndPos()); defer allocator.free(contents); - var parser = try toml.parseFile(allocator, file_path); - defer parser.deinit(); - - const table = try parser.parse(); - defer table.deinit(); - - // TODO: Report unknown config options - - if (table.keys.get("Host")) |host| { - if (host.Table.keys.get("win_scale")) |scale| state.host.win_scale = scale.Integer; - if (host.Table.keys.get("vsync")) |vsync| state.host.vsync = vsync.Boolean; - if (host.Table.keys.get("mute")) |mute| state.host.mute = mute.Boolean; - } - - if (table.keys.get("Guest")) |guest| { - if (guest.Table.keys.get("audio_sync")) |sync| state.guest.audio_sync = sync.Boolean; - if (guest.Table.keys.get("video_sync")) |sync| state.guest.video_sync = sync.Boolean; - if (guest.Table.keys.get("force_rtc")) |forced| state.guest.force_rtc = forced.Boolean; - if (guest.Table.keys.get("skip_bios")) |skip| state.guest.skip_bios = skip.Boolean; - } - - if (table.keys.get("Debug")) |debug| { - if (debug.Table.keys.get("cpu_trace")) |trace| state.debug.cpu_trace = trace.Boolean; - if (debug.Table.keys.get("unhandled_io")) |unhandled| state.debug.unhandled_io = unhandled.Boolean; - } + state = try tomlz.parser.decode(Config, allocator, contents); } diff --git a/src/imgui.zig b/src/imgui.zig index d7da187..e5b5ea9 100644 --- a/src/imgui.zig +++ b/src/imgui.zig @@ -179,14 +179,6 @@ pub fn draw(state: *State, win_dim: Dimensions, tex_id: GLuint, cpu: *Arm7tdmi) _ = zgui.begin("Dependencies", .{ .popen = &state.win_stat.show_deps }); defer zgui.end(); - zgui.bulletText("SDL.zig by Felix Queißner", .{}); - { - zgui.indent(.{}); - defer zgui.unindent(.{}); - - zgui.bulletText("SDL by Sam Lantinga", .{}); - } - zgui.bulletText("known-folders by ziglibs", .{}); zgui.bulletText("nfd-zig by Fabio Arnold", .{}); { @@ -195,6 +187,16 @@ pub fn draw(state: *State, win_dim: Dimensions, tex_id: GLuint, cpu: *Arm7tdmi) zgui.bulletText("nativefiledialog by Michael Labbe", .{}); } + + zgui.bulletText("SDL.zig by Felix Queißner", .{}); + { + zgui.indent(.{}); + defer zgui.unindent(.{}); + + zgui.bulletText("SDL by Sam Lantinga", .{}); + } + + zgui.bulletText("tomlz by Matthew Hall", .{}); zgui.bulletText("zba-gdbstub by Rekai Musuka", .{}); zgui.bulletText("zba-util by Rekai Musuka", .{}); zgui.bulletText("zgui by Michal Ziulek", .{}); @@ -206,6 +208,9 @@ pub fn draw(state: *State, win_dim: Dimensions, tex_id: GLuint, cpu: *Arm7tdmi) } zgui.bulletText("zig-clap by Jimmi Holst Christensen", .{}); zgui.bulletText("zig-datetime by Jairus Martin", .{}); + + zgui.newLine(); + zgui.bulletText("bitfield.zig by Hannes Bredberg and FlorenceOS contributors", .{}); zgui.bulletText("zig-opengl by Felix Queißner", .{}); { zgui.indent(.{}); @@ -213,8 +218,6 @@ pub fn draw(state: *State, win_dim: Dimensions, tex_id: GLuint, cpu: *Arm7tdmi) zgui.bulletText("OpenGL-Registry by The Khronos Group", .{}); } - zgui.bulletText("zig-toml by Aeron Avery", .{}); - zgui.bulletText("bitfield.zig by Hannes Bredberg and FlorenceOS contributors", .{}); } if (state.win_stat.show_regs) {