const std = @import("std"); const options = @import("options"); const rom_count = options.roms.len; pub const ROM = struct { name: []const u8, data: []const u8, }; pub fn listROMs() [options.roms.len]ROM { var roms: [options.roms.len]ROM = undefined; for (0.., options.roms) |i, file| { const extension = std.mem.lastIndexOfScalar(u8, file, '.') orelse file.len; const slash = std.mem.lastIndexOfScalar(u8, file, '/') orelse -1; const name = file[(slash+1)..extension]; roms[i] = ROM{ .name = name, .data = @embedFile(file) }; } return roms; } pub fn findIndexbyName(roms: []const ROM, name: []const u8) ?usize { for (0.., roms) |i, rom| { if (std.mem.eql(u8, rom.name, name)) { return i; } } return null; }