diff --git a/engine/lib/p2/src/structures/xxd.zig b/engine/lib/p2/src/structures/xxd.zig index 06c8e2f..a698c51 100644 --- a/engine/lib/p2/src/structures/xxd.zig +++ b/engine/lib/p2/src/structures/xxd.zig @@ -34,6 +34,7 @@ const ColorOp = struct { count: u32 = 0, pub const reset = @This(){ .count = 0, .color = .default }; + pub const green = @This(){ .count = 0, .color = .green }; pub fn colorAscii(self: @This()) []const u8 { switch (self.color) { @@ -115,8 +116,11 @@ pub fn xxdWrite2(writer: *std.Io.Writer, bytes: []const u8, options: XxdOptions) } if (i % bytesPerWord == 0) word += 1; if (word % options.wordsPerGroup == 0) group += 1; + const op = if (i % 2 == 0) ColorOp.reset else ColorOp.green; + try writer.writeAll(op.colorAscii()); try writeByteAsHex2(@intCast(i), writer, true); } + try writer.writeAll(ColorOp.reset.colorAscii()); } try writer.writeByte('\n'); @@ -277,8 +281,8 @@ inline fn writeByteAsHex(byte: u8, writer: *std.Io.Writer, options: XxdOptions, try writer.writeAll(&.{ digits[byte >> 4], digits[byte & 0xf] }); } -/// warning, needs 64k on your stack -pub fn debug_printBytes(bytes: []const u8, options: XxdOptions) void { +/// warning! needs 64k on your stack +pub fn printBytes(bytes: []const u8, options: XxdOptions) void { var workBuffer: [64 * 1024]u8 = undefined; var fba = std.heap.FixedBufferAllocator.init(&workBuffer); @@ -290,5 +294,11 @@ pub fn debug_printBytes(bytes: []const u8, options: XxdOptions) void { } pub inline fn print(bytes: []const u8, baseAddress: usize) void { - debug_printBytes(bytes, XxdOptions{ .baseAddress = baseAddress }); + printBytes(bytes, XxdOptions{ .baseAddress = baseAddress }); +} + +pub inline fn printStruct(s: anytype) void { + std.debug.print("{s}: size:{d} bytes\n\n", .{ @typeName(@TypeOf(s)), @sizeOf(@TypeOf(s)) }); + + print(std.mem.asBytes(&s), 0); } diff --git a/engine/lib/slugger/src/reader.zig b/engine/lib/slugger/src/reader.zig index d9a1271..1014dea 100644 --- a/engine/lib/slugger/src/reader.zig +++ b/engine/lib/slugger/src/reader.zig @@ -1,6 +1,7 @@ -pub fn sluggerReaderTest(dir: *std.Io.Dir, pathname: []const u8) !void { +pub fn sluggerReaderTest(dir: *const std.Io.Dir, pathname: []const u8) !void { const io = std.testing.io; + std.debug.print("starting reader test... \n", .{}); const f = try dir.openFile(io, pathname, .{}); _ = f; } diff --git a/engine/lib/slugger/src/slugger.zig b/engine/lib/slugger/src/slugger.zig index 098db55..264b2a8 100644 --- a/engine/lib/slugger/src/slugger.zig +++ b/engine/lib/slugger/src/slugger.zig @@ -1190,11 +1190,11 @@ test "testing" { defer loggerFile.destroy(); // new decode from log file test - const f = try tdir.openFile(io, "test2.slg", .{}); - _ = f; + try reader.sluggerReaderTest(&tdir, "test2.slg"); } } +pub const reader = @import("reader.zig"); pub const sluggerformat = @import("sluggerformat.zig"); const p2 = @import("p2"); const std = @import("std"); diff --git a/engine/lib/slugger/src/sluggerformat.zig b/engine/lib/slugger/src/sluggerformat.zig index 2f43c2e..4120c4e 100644 --- a/engine/lib/slugger/src/sluggerformat.zig +++ b/engine/lib/slugger/src/sluggerformat.zig @@ -279,9 +279,8 @@ const SlugOutput = struct { try entry.marshalToWriter(&frame.writer); // const end = frame.written().len; - // xxd.print(frame.written()[start..end], start); - // std.debug.print("\n", .{}); + // xxd.printStruct(self.*); self.entriesWritten += 1; }