diff --git a/build.zig b/build.zig index e6196e4..8fcaf28 100644 --- a/build.zig +++ b/build.zig @@ -8,7 +8,7 @@ const nfd = @import("lib/nfd-zig/build.zig"); pub fn build(b: *std.Build) void { // Minimum Zig Version - const min_ver = std.SemanticVersion.parse("0.11.0-dev.2168+322ace70f") catch return; // https://github.com/ziglang/zig/commit/322ace70f + const min_ver = std.SemanticVersion.parse("0.11.0-dev.2934+1b432072b") catch return; // https://github.com/ziglang/zig/commit/322ace70f if (builtin.zig_version.order(min_ver).compare(.lt)) { std.log.err("{s}", .{b.fmt("Zig v{} does not meet the minimum version requirement. (Zig v{})", .{ builtin.zig_version, min_ver })}); std.os.exit(1); diff --git a/lib/zba-util b/lib/zba-util index d5e66ca..c1388c7 160000 --- a/lib/zba-util +++ b/lib/zba-util @@ -1 +1 @@ -Subproject commit d5e66caf2180324d83ad9be30e887849f5ed74da +Subproject commit c1388c731820d9847c9d54f698c55e07752bc5ea diff --git a/src/core/bus/Ewram.zig b/src/core/bus/Ewram.zig index a1ad801..084084e 100644 --- a/src/core/bus/Ewram.zig +++ b/src/core/bus/Ewram.zig @@ -27,7 +27,7 @@ pub fn write(self: *const Self, comptime T: type, address: usize, value: T) void pub fn init(allocator: Allocator) !Self { const buf = try allocator.alloc(u8, ewram_size); - std.mem.set(u8, buf, 0); + @memset(buf, 0); return Self{ .buf = buf, @@ -36,7 +36,7 @@ pub fn init(allocator: Allocator) !Self { } pub fn reset(self: *Self) void { - std.mem.set(u8, self.buf, 0); + @memset(self.buf, 0); } pub fn deinit(self: *Self) void { diff --git a/src/core/bus/Iwram.zig b/src/core/bus/Iwram.zig index 0356460..075bb32 100644 --- a/src/core/bus/Iwram.zig +++ b/src/core/bus/Iwram.zig @@ -27,7 +27,7 @@ pub fn write(self: *const Self, comptime T: type, address: usize, value: T) void pub fn init(allocator: Allocator) !Self { const buf = try allocator.alloc(u8, iwram_size); - std.mem.set(u8, buf, 0); + @memset(buf, 0); return Self{ .buf = buf, @@ -36,7 +36,7 @@ pub fn init(allocator: Allocator) !Self { } pub fn reset(self: *Self) void { - std.mem.set(u8, self.buf, 0); + @memset(self.buf, 0); } pub fn deinit(self: *Self) void { diff --git a/src/core/bus/backup.zig b/src/core/bus/backup.zig index 8db2571..a4a1770 100644 --- a/src/core/bus/backup.zig +++ b/src/core/bus/backup.zig @@ -110,7 +110,7 @@ pub const Backup = struct { }; const buf = try allocator.alloc(u8, buf_size); - std.mem.set(u8, buf, 0xFF); + @memset(buf, 0xFF); var backup = Self{ .buf = buf, @@ -163,7 +163,7 @@ pub const Backup = struct { switch (self.kind) { .Sram, .Flash, .Flash1M => { if (self.buf.len == file_buf.len) { - std.mem.copy(u8, self.buf, file_buf); + @memcpy(self.buf, file_buf); return log.info("Loaded Save from {s}", .{file_path}); } @@ -174,7 +174,7 @@ pub const Backup = struct { self.eeprom.kind = if (file_buf.len == 0x200) .Small else .Large; self.buf = try allocator.alloc(u8, file_buf.len); - std.mem.copy(u8, self.buf, file_buf); + @memcpy(self.buf, file_buf); return log.info("Loaded Save from {s}", .{file_path}); } diff --git a/src/core/bus/backup/Flash.zig b/src/core/bus/backup/Flash.zig index b665b82..8998442 100644 --- a/src/core/bus/backup/Flash.zig +++ b/src/core/bus/backup/Flash.zig @@ -44,7 +44,7 @@ pub fn handleCommand(self: *Self, buf: []u8, byte: u8) void { 0xB0 => self.set_bank = true, 0x80 => self.prep_erase = true, 0x10 => { - std.mem.set(u8, buf, 0xFF); + @memset(buf, 0xFF); self.prep_erase = false; }, 0xA0 => self.prep_write = true, @@ -61,7 +61,7 @@ pub fn shouldEraseSector(self: *const Self, addr: usize, byte: u8) bool { pub fn erase(self: *Self, buf: []u8, sector: usize) void { const start = self.address() + (sector & 0xF000); - std.mem.set(u8, buf[start..][0..0x1000], 0xFF); + @memset(buf[start..][0..0x1000], 0xFF); self.prep_erase = false; self.state = .Ready; } diff --git a/src/core/bus/backup/eeprom.zig b/src/core/bus/backup/eeprom.zig index 5eecee4..2948b6a 100644 --- a/src/core/bus/backup/eeprom.zig +++ b/src/core/bus/backup/eeprom.zig @@ -58,7 +58,9 @@ pub const Eeprom = struct { log.err("Failed to resize EEPROM buf to {} bytes", .{len}); std.debug.panic("EEPROM entered irrecoverable state {}", .{e}); }; - std.mem.set(u8, buf.*, 0xFF); + + // FIXME: ptr to a slice? + @memset(buf.*, 0xFF); } } diff --git a/src/core/ppu.zig b/src/core/ppu.zig index 35cb7ad..1dc4068 100644 --- a/src/core/ppu.zig +++ b/src/core/ppu.zig @@ -266,7 +266,7 @@ pub const Ppu = struct { sched.push(.Draw, 240 * 4); // Add first PPU Event to Scheduler const sprites = try allocator.create([128]?Sprite); - std.mem.set(?Sprite, sprites, null); + @memset(sprites, null); return Self{ .vram = try Vram.init(allocator), @@ -307,7 +307,7 @@ pub const Ppu = struct { self.vcount = .{ .raw = 0x0000 }; self.scanline.reset(); - std.mem.set(?Sprite, self.scanline_sprites, null); + @memset(self.scanline_sprites, null); } pub fn deinit(self: *Self) void { @@ -744,7 +744,7 @@ pub const Ppu = struct { // Reset Current Scanline Pixel Buffer and list of fetched sprites // in prep for next scanline self.scanline.reset(); - std.mem.set(?Sprite, self.scanline_sprites, null); + @memset(self.scanline_sprites, null); } fn getBgr555(self: *Self, maybe_top: Scanline.Pixel, maybe_btm: Scanline.Pixel) u16 { @@ -1554,7 +1554,7 @@ const Scanline = struct { fn init(allocator: Allocator) !Self { const buf = try allocator.alloc(Pixel, width * 2); // Top & Bottom Scanline - std.mem.set(Pixel, buf, .unset); + @memset(buf, .unset); return .{ // Top & Bototm Layers @@ -1565,7 +1565,7 @@ const Scanline = struct { } fn reset(self: *Self) void { - std.mem.set(Pixel, self.buf, .unset); + @memset(self.buf, .unset); } fn deinit(self: *Self) void { diff --git a/src/core/ppu/Oam.zig b/src/core/ppu/Oam.zig index f09c0ff..981c862 100644 --- a/src/core/ppu/Oam.zig +++ b/src/core/ppu/Oam.zig @@ -29,13 +29,13 @@ pub fn write(self: *Self, comptime T: type, address: usize, value: T) void { pub fn init(allocator: Allocator) !Self { const buf = try allocator.alloc(u8, buf_len); - std.mem.set(u8, buf, 0); + @memset(buf, 0); return Self{ .buf = buf, .allocator = allocator }; } pub fn reset(self: *Self) void { - std.mem.set(u8, self.buf, 0); + @memset(self.buf, 0); } pub fn deinit(self: *Self) void { diff --git a/src/core/ppu/Palette.zig b/src/core/ppu/Palette.zig index 9e6f36a..6850db3 100644 --- a/src/core/ppu/Palette.zig +++ b/src/core/ppu/Palette.zig @@ -32,13 +32,13 @@ pub fn write(self: *Self, comptime T: type, address: usize, value: T) void { pub fn init(allocator: Allocator) !Self { const buf = try allocator.alloc(u8, buf_len); - std.mem.set(u8, buf, 0); + @memset(buf, 0); return Self{ .buf = buf, .allocator = allocator }; } pub fn reset(self: *Self) void { - std.mem.set(u8, self.buf, 0); + @memset(self.buf, 0); } pub fn deinit(self: *Self) void { diff --git a/src/core/ppu/Vram.zig b/src/core/ppu/Vram.zig index f148dc7..756d61e 100644 --- a/src/core/ppu/Vram.zig +++ b/src/core/ppu/Vram.zig @@ -40,13 +40,13 @@ pub fn write(self: *Self, comptime T: type, dispcnt: io.DisplayControl, address: pub fn init(allocator: Allocator) !Self { const buf = try allocator.alloc(u8, buf_len); - std.mem.set(u8, buf, 0); + @memset(buf, 0); return Self{ .buf = buf, .allocator = allocator }; } pub fn reset(self: *Self) void { - std.mem.set(u8, self.buf, 0); + @memset(self.buf, 0); } pub fn deinit(self: *Self) void { diff --git a/src/imgui.zig b/src/imgui.zig index d97bca7..a7910b7 100644 --- a/src/imgui.zig +++ b/src/imgui.zig @@ -220,7 +220,7 @@ pub fn draw(state: *State, tex_id: GLuint, cpu: *Arm7tdmi) void { const sorted = blk: { var buf: @TypeOf(values) = undefined; - std.mem.copy(u32, buf[0..len], values[0..len]); + @memcpy(buf[0..len], values[0..len]); std.sort.sort(u32, buf[0..len], {}, std.sort.asc(u32)); break :blk buf; @@ -279,7 +279,7 @@ pub fn draw(state: *State, tex_id: GLuint, cpu: *Arm7tdmi) void { var items: [20]Event = undefined; const len = scheduler.queue.len; - std.mem.copy(Event, &items, scheduler.queue.items); + @memcpy(&items, scheduler.queue.items); std.sort.sort(Event, items[0..len], {}, widgets.eventDesc(Event)); for (items[0..len]) |event| { diff --git a/src/util.zig b/src/util.zig index 9b6bbc9..498c481 100644 --- a/src/util.zig +++ b/src/util.zig @@ -260,7 +260,7 @@ pub const FrameBuffer = struct { pub fn init(allocator: Allocator, comptime len: comptime_int) !Self { const buf = try allocator.alloc(u8, len * 2); - std.mem.set(u8, buf, 0); + @memset(buf, 0); return .{ // Front and Back Framebuffers @@ -272,7 +272,7 @@ pub const FrameBuffer = struct { } pub fn reset(self: *Self) void { - std.mem.set(u8, self.buf, 0); + @memset(self.buf, 0); self.current = 0; }