4 Commits

Author SHA1 Message Date
e43c4a2cb9 fix: re-enable scheduler view 2025-11-12 22:03:36 -06:00
276b928ee2 chore: link sdl3 to zgui for successful windows build 2025-11-12 19:34:25 -06:00
de711a37c2 chore: stop using local ver. of deps 2025-11-12 19:03:36 -06:00
38fabc92c5 chore: update readme 2025-11-12 18:51:58 -06:00
4 changed files with 41 additions and 39 deletions

View File

@@ -27,35 +27,9 @@ Finally it's worth noting that ZBA uses a TOML config file it'll store in your O
## Compiling
Most recently built on Zig [v0.11.0](https://github.com/ziglang/zig/tree/0.11.0)
Most recently built on Zig [v0.15.1](https://github.com/ziglang/zig/tree/0.15.1)
### Dependencies
Dependency | Source
--- | ---
known-folders | <https://github.com/ziglibs/known-folders>
nfd-zig | <https://github.com/fabioarnold/nfd-zig>
SDL.zig | <https://github.com/MasterQ32/SDL.zig>
tomlz | <https://github.com/mattyhall/tomlz>
zba-gdbstub | <https://github.com/paoda/zba-gdbstub>
zba-util | <https://git.musuka.dev/paoda/zba-util>
zgui | <https://github.com/michal-z/zig-gamedev/tree/main/libs/zgui>
zig-clap | <https://github.com/Hejsil/zig-clap>
zig-datetime | <https://github.com/frmdstryr/zig-datetime>
`bitfield.zig` | [https://github.com/FlorenceOS/Florence](https://github.com/FlorenceOS/Florence/blob/aaa5a9e568/lib/util/bitfields.zig)
`gl.zig` | <https://github.com/MasterQ32/zig-opengl>
Use `git submodule update --init` from the project root to pull the git relevant git submodules
Be sure to provide SDL2 using:
- Linux: Your distro's package manager
- macOS: ¯\\\_(ツ)_/¯ (try [this formula](https://formulae.brew.sh/formula/sdl2)?)
- Windows: [`vcpkg`](https://github.com/Microsoft/vcpkg) (install `sdl2:x64-windows`)
`SDL.zig` will provide a helpful compile error if the zig compiler is unable to find SDL2.
Once you've got all the dependencies, execute `zig build -Doptimize=ReleaseSafe`. The executable will be under `zig-out/bin` and the shared libraries (if enabled) under `zig-out/lib`. If working with shared libraries on windows, be sure to add all artifacts to the same directory. On Unix, you'll want to make use of `LD_PRELOAD`.
Run `zig build -Doptimize=ReleaseSafe`. The executable will be under `zig-out/bin` and the shared libraries (if enabled) under `zig-out/lib`. If working with shared libraries on windows, be sure to add all artifacts to the same directory. On Unix, you'll want to make use of `LD_PRELOAD`.
## Controls

View File

@@ -67,6 +67,8 @@ pub fn build(b: *std.Build) void {
const sdl_lib = sdl.artifact("SDL3");
const zgui_lib = zgui.artifact("imgui");
zgui_lib.linkLibrary(sdl_lib);
exe_mod.linkLibrary(sdl_lib);
exe_mod.linkLibrary(zgui_lib);

View File

@@ -11,9 +11,6 @@
.minimum_zig_version = "0.15.1",
.fingerprint = 0xcb596c7fbdb20efc,
.dependencies = .{
.zba_util = .{ .path = "../zba-util" },
.arm32 = .{ .path = "../arm32" },
.zba_gdbstub = .{ .path = "../zba-gdbstub" },
.known_folders = .{
.url = "git+https://github.com/ziglibs/known-folders.git#ab5cf5feb936fa3b72c95d3ad0c0c67791937ba1",
.hash = "known_folders-0.0.0-Fy-PJtTTAADUOhGKM0sxzG4eMkNQxRvx9e5dfHVyaeA3",
@@ -50,5 +47,17 @@
.url = "git+https://github.com/sam701/zig-toml?ref=zig-0.15#475b03c630c802f8b6bd3e239d8fc2279b4fadb8",
.hash = "toml-0.3.0-bV14BfV7AQD8DkuQI7skP8ekQTaBYKTO0MY_35Cw_EXo",
},
.zba_util = .{
.url = "git+https://git.musuka.dev/paoda/zba-util#d75962ac9bdf9b6f0d37e37d5097ea9bb9c16779",
.hash = "zba_util-0.0.0-SK3QiakqAABPCct0WbLsuHFfmxwzH99FmEVznCBKzdmR",
},
.arm32 = .{
.url = "git+https://git.musuka.dev/paoda/arm32#c9360e1e239300d8c80bcbc3a7494f015a82c4e1",
.hash = "arm32-0.0.0--_LW1VwTAgAbqwOzVfjnkClkwBrB8IZ1LSz8N4EoA3U3",
},
.zba_gdbstub = .{
.url = "git+https://git.musuka.dev/paoda/zba-gdbstub#7b77964e145ac874424a190ecd390596601a40d1",
.hash = "zba_gdbstub-0.0.0-KDf2GNiPAAAR5QuteF1MsN3XGElNvHLlRJ7O4PNFvTmK",
},
},
}

View File

@@ -358,14 +358,19 @@ pub fn draw(state: *State, sync: *Synchro, dim: Dimensions, cpu: *const Arm7tdmi
defer zgui.end();
const scheduler = cpu.sched;
_ = scheduler;
// zgui.text("tick: {X:0>16}", .{scheduler.now()});
zgui.text("tick: (TODO: FIX THIS)", .{});
const tick = scheduler.now();
// >> 24 becuase the ARM7TDMI runs at 2^24 Hz
const elapsed_str = std.mem.sliceTo(&printTime(tick >> 24), 0);
zgui.text("tick: 0x{X:0>16}", .{tick});
zgui.sameLine(.{});
zgui.text(" {s}s", .{elapsed_str});
zgui.separator();
const sched_ptr: *Scheduler = @ptrCast(@alignCast(cpu.sched.ptr));
const Event = std.meta.Child(@TypeOf(sched_ptr.queue.items));
const sched_ptr: *Scheduler = @ptrCast(@alignCast(scheduler.ptr));
const Event = @typeInfo(@TypeOf(sched_ptr.queue.items)).pointer.child;
var items: [20]Event = undefined;
const len = @min(sched_ptr.queue.items.len, items.len);
@@ -374,9 +379,7 @@ pub fn draw(state: *State, sync: *Synchro, dim: Dimensions, cpu: *const Arm7tdmi
std.mem.sort(Event, items[0..len], {}, widgets.eventDesc(Event));
for (items[0..len]) |event| {
// zgui.text("{X:0>16} | {?}", .{ event.tick, event.kind });
_ = event;
zgui.text("TODO: Fix This", .{});
zgui.text("0x{X:0>16} | {t}", .{ event.tick, event.kind });
}
}
@@ -535,3 +538,17 @@ fn handleTitle(title_opt: ?*const [12]u8) [12:0]u8 {
return title.* ++ [_:0]u8{};
}
fn printTime(seconds: u64) [0x20]u8 {
var str = [_]u8{0x0} ** 0x20;
var writer = std.Io.Writer.fixed(&str);
const hr = seconds / 3600;
const min = (seconds % 3600) / 60;
const sec = seconds % 60;
// longest string is "5124095576030431:00:15" which is 22 bytes
writer.print("{:0>2}:{:0>2}:{:0>2}", .{ hr, min, sec }) catch unreachable;
return str;
}