const c64 = @import("c64");

const Sector = struct { visits: u16, flags: u8 };

memory {
    region staging_ram: c64 at 0x9000 size 16;
    arena scratch in staging_ram;
}

fn show(sector: Sector) void {
    if (scratch.allocBytes(@sizeOf(Sector))) |bytes| {
        const word = sector.visits;
        const low = word & 0x00ff;
        const high = word >> 8;
        bytes[0] = low;
        bytes[1] = high;
        bytes[@offsetOf(Sector, "flags")] = sector.flags;
        c64.console.print("RECORD {x} {x} {x}\n", .{ bytes[0], bytes[1], bytes[2] });
        scratch.reset();
    } else {
        c64.console.print("SCRATCH FULL\n", .{});
    }
}

export fn main() void {
    c64.console.clear();
    show(Sector{ .visits = 0x0102, .flags = 4 });
    show(Sector{ .visits = 0x0103, .flags = 4 });
}
