Skip to content

Instantly share code, notes, and snippets.

@scheibo
Created July 31, 2024 19:03
Show Gist options
  • Save scheibo/b21f57aa2d659fe6055f7a58e85b1199 to your computer and use it in GitHub Desktop.
Save scheibo/b21f57aa2d659fe6055f7a58e85b1199 to your computer and use it in GitHub Desktop.
delta
const endian = @import("builtin").cpu.arch.endian();
var bytes: usize = 0;
const a = std.mem.toBytes(copy)[0..376];
const b = std.mem.toBytes(battle.*)[0..376];
var diffs: [128]u8 = undefined;
var i: usize = 0;
var j: usize = 0;
while (i < 376) : (i += 2) {
const ai = std.mem.bytesAsValue(u16, a[i .. i + 2]).*;
if (ai != std.mem.bytesAsValue(u16, b[i .. i + 2]).*) {
std.mem.writeInt(u16, diffs[j..], ai, endian);
j += 2;
diffs[j] = i;
j += 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment