Compare commits

3 Commits

Author SHA1 Message Date
49b0620c48 style(imgui): use orelse instead of if () || 2023-03-17 11:34:38 -05:00
a6a9e3ac72 chore(imgui): change size of histogram 2023-03-17 11:26:14 -05:00
aeefff86f8 chore: update dependencies 2023-03-16 00:27:08 -05:00
5 changed files with 19 additions and 20 deletions

View File

@@ -21,8 +21,8 @@ const gba_height = @import("core/ppu.zig").height;
const log = std.log.scoped(.Imgui);
// TODO: Document how I decided on this value (I forgot 😅)
const histogram_len = 0x400;
// two seconds worth of fps values into the past
const histogram_len = 0x80;
/// Immediate-Mode GUI State
pub const State = struct {
@@ -37,10 +37,7 @@ pub const State = struct {
var title: [12:0]u8 = [_:0]u8{0} ** 12;
std.mem.copy(u8, &title, "[No Title]");
return .{
.title = title,
.fps_hist = RingBuffer(u32).init(history),
};
return .{ .title = title, .fps_hist = RingBuffer(u32).init(history) };
}
pub fn deinit(self: *@This(), allocator: Allocator) void {
@@ -67,17 +64,19 @@ pub fn draw(state: *State, tex_id: GLuint, cpu: *Arm7tdmi) void {
break :blk;
};
if (maybe_path) |file_path| {
defer nfd.freePath(file_path);
log.info("user chose: \"{s}\"", .{file_path});
const file_path = maybe_path orelse {
log.warn("did not receive a file path", .{});
break :blk;
};
defer nfd.freePath(file_path);
emu.replaceGamepak(cpu, file_path) catch |e| {
log.err("failed to replace GamePak: {}", .{e});
break :blk;
};
log.info("user chose: \"{s}\"", .{file_path});
emu.replaceGamepak(cpu, file_path) catch |e| {
log.err("failed to replace GamePak: {}", .{e});
break :blk;
};
state.title = cpu.bus.pak.title ++ [_:0]u8{};
}
state.title = cpu.bus.pak.title ++ [_:0]u8{};
}
}
@@ -130,7 +129,7 @@ pub fn draw(state: *State, tex_id: GLuint, cpu: *Arm7tdmi) void {
defer zgui.end();
const tmp = blk: {
var buf: [0x400]u32 = undefined;
var buf: [histogram_len]u32 = undefined;
const len = state.fps_hist.copy(&buf);
break :blk .{ buf, len };