tmp: add cpu info
This commit is contained in:
parent
8980edacbe
commit
0f6dc75913
|
@ -647,7 +647,7 @@ pub const PSR = extern union {
|
|||
}
|
||||
};
|
||||
|
||||
const Mode = enum(u5) {
|
||||
pub const Mode = enum(u5) {
|
||||
User = 0b10000,
|
||||
Fiq = 0b10001,
|
||||
Irq = 0b10010,
|
||||
|
@ -656,7 +656,7 @@ const Mode = enum(u5) {
|
|||
Undefined = 0b11011,
|
||||
System = 0b11111,
|
||||
|
||||
fn toString(self: Mode) []const u8 {
|
||||
pub fn toString(self: Mode) []const u8 {
|
||||
return switch (self) {
|
||||
.User => "usr",
|
||||
.Fiq => "fiq",
|
||||
|
|
156
src/platform.zig
156
src/platform.zig
|
@ -260,25 +260,156 @@ pub const Gui = struct {
|
|||
}
|
||||
|
||||
fn draw(self: *Self, tex_id: GLuint, cpu: *const Arm7tdmi) void {
|
||||
_ = cpu;
|
||||
const Mode = @import("core/cpu.zig").Mode;
|
||||
const win_scale = config.config().host.win_scale;
|
||||
|
||||
{
|
||||
const w = @intToFloat(f32, gba_width * win_scale);
|
||||
const h = @intToFloat(f32, gba_height * win_scale);
|
||||
|
||||
_ = zgui.begin("Game Boy Advance Screen", .{ .flags = .{ .no_resize = true, .always_auto_resize = true } });
|
||||
defer zgui.end();
|
||||
|
||||
const img_args = .{
|
||||
.w = @intToFloat(f32, gba_width * win_scale),
|
||||
.h = @intToFloat(f32, gba_height * win_scale),
|
||||
.uv0 = .{ 0.0, 1.0 },
|
||||
.uv1 = .{ 1.0, 0.0 },
|
||||
};
|
||||
|
||||
zgui.image(@intToPtr(*anyopaque, tex_id), img_args);
|
||||
zgui.image(@intToPtr(*anyopaque, tex_id), .{ .w = w, .h = h, .uv0 = .{ 0, 1 }, .uv1 = .{ 1, 0 } });
|
||||
}
|
||||
|
||||
{
|
||||
_ = zgui.begin("Emulator Performance", .{});
|
||||
_ = zgui.begin("Information", .{});
|
||||
defer zgui.end();
|
||||
|
||||
{
|
||||
var i: usize = 0;
|
||||
while (i < 8) : (i += 1) {
|
||||
zgui.text("R{}: 0x{X:0>8}", .{ i, cpu.r[i] });
|
||||
|
||||
zgui.sameLine(.{});
|
||||
|
||||
const prefix = if (8 + i < 10) " " else "";
|
||||
zgui.text("{s}R{}: 0x{X:0>8}", .{ prefix, 8 + i, cpu.r[8 + i] });
|
||||
}
|
||||
}
|
||||
|
||||
zgui.separator();
|
||||
|
||||
{
|
||||
const maybe_mode = std.meta.intToEnum(Mode, cpu.cpsr.mode.read()) catch null;
|
||||
const mode = if (maybe_mode) |mode| mode.toString() else "???";
|
||||
const w = 9.0;
|
||||
const h = 15.0;
|
||||
|
||||
zgui.text("CPSR: 0x{X:0>8}", .{cpu.cpsr.raw});
|
||||
|
||||
zgui.sameLine(.{});
|
||||
_ = zgui.selectable("N", .{ .w = w, .h = h, .selected = cpu.cpsr.n.read() });
|
||||
|
||||
zgui.sameLine(.{});
|
||||
_ = zgui.selectable("Z", .{ .w = w, .h = h, .selected = cpu.cpsr.z.read() });
|
||||
|
||||
zgui.sameLine(.{});
|
||||
_ = zgui.selectable("C", .{ .w = w, .h = h, .selected = cpu.cpsr.c.read() });
|
||||
|
||||
zgui.sameLine(.{});
|
||||
_ = zgui.selectable("V", .{ .w = w, .h = h, .selected = cpu.cpsr.v.read() });
|
||||
|
||||
zgui.sameLine(.{});
|
||||
zgui.text("{s}", .{mode});
|
||||
}
|
||||
|
||||
{
|
||||
const maybe_mode = std.meta.intToEnum(Mode, cpu.spsr.mode.read()) catch null;
|
||||
const mode = if (maybe_mode) |mode| mode.toString() else "???";
|
||||
const w = 9.0;
|
||||
const h = 15.0;
|
||||
|
||||
zgui.text("SPSR: 0x{X:0>8}", .{cpu.spsr.raw});
|
||||
|
||||
zgui.sameLine(.{});
|
||||
_ = zgui.selectable("N", .{ .w = w, .h = h, .selected = cpu.spsr.n.read() });
|
||||
|
||||
zgui.sameLine(.{});
|
||||
_ = zgui.selectable("Z", .{ .w = w, .h = h, .selected = cpu.spsr.z.read() });
|
||||
|
||||
zgui.sameLine(.{});
|
||||
_ = zgui.selectable("C", .{ .w = w, .h = h, .selected = cpu.spsr.c.read() });
|
||||
|
||||
zgui.sameLine(.{});
|
||||
_ = zgui.selectable("V", .{ .w = w, .h = h, .selected = cpu.spsr.v.read() });
|
||||
|
||||
zgui.sameLine(.{});
|
||||
zgui.text("{s}", .{mode});
|
||||
}
|
||||
|
||||
{
|
||||
// const ime = cpu.bus.io.ime;
|
||||
const ir = cpu.bus.io.ie;
|
||||
// const ie = cpu.bus.io.ie;
|
||||
const h = 15.0;
|
||||
const w = 9.0;
|
||||
const ww = 9.0 * 2 + 3.5;
|
||||
|
||||
{
|
||||
zgui.text("IRQ", .{});
|
||||
|
||||
zgui.sameLine(.{});
|
||||
_ = zgui.selectable("VBL", .{ .w = ww, .h = h, .selected = ir.vblank.read() });
|
||||
|
||||
zgui.sameLine(.{});
|
||||
_ = zgui.selectable("HBL", .{ .w = ww, .h = h, .selected = ir.hblank.read() });
|
||||
|
||||
zgui.sameLine(.{});
|
||||
_ = zgui.selectable("VCT", .{ .w = ww, .h = h, .selected = ir.coincidence.read() });
|
||||
|
||||
{
|
||||
zgui.sameLine(.{});
|
||||
_ = zgui.text("T", .{});
|
||||
|
||||
zgui.sameLine(.{});
|
||||
_ = zgui.selectable("0", .{ .w = w, .h = h, .selected = ir.tm0_overflow.read() });
|
||||
|
||||
zgui.sameLine(.{});
|
||||
_ = zgui.selectable("1", .{ .w = w, .h = h, .selected = ir.tm1_overflow.read() });
|
||||
|
||||
zgui.sameLine(.{});
|
||||
_ = zgui.selectable("2", .{ .w = w, .h = h, .selected = ir.tm2_overflow.read() });
|
||||
|
||||
zgui.sameLine(.{});
|
||||
_ = zgui.selectable("3", .{ .w = w, .h = h, .selected = ir.tm3_overflow.read() });
|
||||
}
|
||||
|
||||
zgui.sameLine(.{});
|
||||
_ = zgui.selectable("SRL", .{ .w = ww, .h = h, .selected = ir.serial.read() });
|
||||
|
||||
{
|
||||
zgui.sameLine(.{});
|
||||
_ = zgui.text("DMA", .{});
|
||||
|
||||
zgui.sameLine(.{});
|
||||
_ = zgui.selectable("0", .{ .w = w, .h = h, .selected = ir.dma0.read() });
|
||||
|
||||
zgui.sameLine(.{});
|
||||
_ = zgui.selectable("1", .{ .w = w, .h = h, .selected = ir.dma1.read() });
|
||||
|
||||
zgui.sameLine(.{});
|
||||
_ = zgui.selectable("2", .{ .w = w, .h = h, .selected = ir.dma2.read() });
|
||||
|
||||
zgui.sameLine(.{});
|
||||
_ = zgui.selectable("3", .{ .w = w, .h = h, .selected = ir.dma3.read() });
|
||||
}
|
||||
|
||||
zgui.sameLine(.{});
|
||||
_ = zgui.selectable("KPD", .{ .w = ww, .h = h, .selected = ir.keypad.read() });
|
||||
|
||||
zgui.sameLine(.{});
|
||||
_ = zgui.selectable("GPK", .{ .w = ww, .h = h, .selected = ir.game_pak.read() });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
zgui.separator();
|
||||
|
||||
{
|
||||
_ = zgui.begin("Performance", .{});
|
||||
defer zgui.end();
|
||||
|
||||
const tmp = blk: {
|
||||
var buf: [0x400]u32 = undefined;
|
||||
|
@ -307,6 +438,8 @@ pub const Gui = struct {
|
|||
const x_args = .{ .flags = .{ .no_grid_lines = true, .no_tick_labels = true, .no_tick_marks = true } };
|
||||
|
||||
if (zgui.plot.beginPlot("Emulation FPS", .{ .w = 0.0, .flags = .{ .no_title = true, .no_frame = true } })) {
|
||||
defer zgui.plot.endPlot();
|
||||
|
||||
zgui.plot.setupLegend(.{ .north = true, .east = true }, .{});
|
||||
zgui.plot.setupAxis(.x1, x_args);
|
||||
zgui.plot.setupAxis(.y1, y_args);
|
||||
|
@ -315,7 +448,6 @@ pub const Gui = struct {
|
|||
zgui.plot.setupFinish();
|
||||
|
||||
zgui.plot.plotLineValues("FPS", u32, .{ .v = values[0..len] });
|
||||
zgui.plot.endPlot();
|
||||
}
|
||||
|
||||
const stats: struct { u32, u32, u32 } = blk: {
|
||||
|
@ -336,8 +468,6 @@ pub const Gui = struct {
|
|||
zgui.text("Average: {:0>3} fps", .{stats[0]});
|
||||
zgui.text(" Median: {:0>3} fps", .{stats[1]});
|
||||
zgui.text(" 1% Low: {:0>3} fps", .{stats[2]});
|
||||
|
||||
defer zgui.end();
|
||||
}
|
||||
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue