From 66d785de11548e2d58db32075df7951e0187fff6 Mon Sep 17 00:00:00 2001 From: 4DBug Date: Sat, 31 Oct 2026 14:16:14 -0500 Subject: [PATCH] ws-arch2: d64 type annotations --- src/Formats/archive/d64/init.luau | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Formats/archive/d64/init.luau b/src/Formats/archive/d64/init.luau index 7f3d4f8..7322c15 100644 --- a/src/Formats/archive/d64/init.luau +++ b/src/Formats/archive/d64/init.luau @@ -34,7 +34,7 @@ export type EncodeOptions = { -- ------------------------------------------------------------------------------------------------ constants local TYPES = { [0] = "del", "seq", "prg", "usr", "rel", "cbm", "dir" } -local TYPE_CODE = { del = 0, seq = 1, prg = 2, usr = 3, rel = 4 } +local TYPE_CODE: { [string]: number } = { del = 0, seq = 1, prg = 2, usr = 3, rel = 4 } type Geometry = { kind: string, tracks: number, offsets: { number }, spt: { number }, dirTrack: number, total: number } @@ -57,8 +57,8 @@ end -- image sizes -> geometry (sizes with the error-info block appended too) local function detect(len: number): Geometry? - for _, g in { { "d64", 35 }, { "d64", 40 }, { "d64", 42 }, { "d71", 70 }, { "d81", 80 } } do - local geo = geometry(g[1], g[2]) + for _, g in { { "d64", 35 }, { "d64", 40 }, { "d64", 42 }, { "d71", 70 }, { "d81", 80 } } :: { { any } } do + local geo = geometry(g[1] :: string, g[2] :: number) local sectors = geo.total // 256 if len == geo.total or (g[1] ~= "d81" and len == geo.total + sectors) then return geo @@ -399,7 +399,7 @@ function D64.encode(value: any, opts: EncodeOptions?): (buffer?, Err.Err?) table.insert(dirSectors, nextS) end local e = dir + dirSector * 256 + slot * 32 - local ty = if type(f.entry.type) == "string" and TYPE_CODE[f.entry.type] then TYPE_CODE[f.entry.type] else 2 + local ty: number = if type(f.entry.type) == "string" and TYPE_CODE[f.entry.type] then TYPE_CODE[f.entry.type] :: number else 2 buffer.writeu8(img, e + 2, 0x80 + ty) buffer.writeu8(img, e + 3, first_t) buffer.writeu8(img, e + 4, first_s)