@lewismoten/gamemaker-sandbox-tools 0.0.0-stage → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/LICENSE +24 -0
  3. package/NOTICE.md +121 -0
  4. package/README.md +362 -2
  5. package/dist/audio-files.js +82 -0
  6. package/dist/audio.js +25 -0
  7. package/dist/block-merge.js +43 -0
  8. package/dist/color-reduce.js +44 -0
  9. package/dist/colors.js +87 -0
  10. package/dist/delta.js +75 -0
  11. package/dist/disk-diff.js +220 -0
  12. package/dist/drawing.js +85 -0
  13. package/dist/embroidery/compile.js +85 -0
  14. package/dist/embroidery/dst.js +79 -0
  15. package/dist/embroidery/exp.js +26 -0
  16. package/dist/embroidery/fill.js +49 -0
  17. package/dist/embroidery/geom.js +82 -0
  18. package/dist/embroidery/pes.js +79 -0
  19. package/dist/embroidery/satin.js +29 -0
  20. package/dist/embroidery/simulate.js +30 -0
  21. package/dist/embroidery/strokeFont.js +253 -0
  22. package/dist/embroidery/svg.js +24 -0
  23. package/dist/embroidery/types.js +13 -0
  24. package/dist/embroidery/units.js +26 -0
  25. package/dist/embroidery/validate.js +15 -0
  26. package/dist/formats/blocks.js +1 -0
  27. package/dist/formats/character.js +1 -0
  28. package/dist/formats/cmf.js +1 -0
  29. package/dist/formats/fli.js +1 -0
  30. package/dist/formats/fliLimits.js +1 -0
  31. package/dist/formats/game.js +1 -0
  32. package/dist/formats/gif.js +1 -0
  33. package/dist/formats/graphicScripts.js +1 -0
  34. package/dist/formats/map.js +1 -0
  35. package/dist/formats/monster.js +1 -0
  36. package/dist/formats/palette.js +1 -0
  37. package/dist/formats/recording.js +1 -0
  38. package/dist/formats/sound.js +1 -0
  39. package/dist/formats/voc.js +1 -0
  40. package/dist/gif-shrink.js +56 -0
  41. package/dist/image/png.js +42 -0
  42. package/dist/images.js +88 -0
  43. package/dist/kit/actors.js +19 -0
  44. package/dist/kit/align.js +204 -0
  45. package/dist/kit/blit.js +45 -0
  46. package/dist/kit/blockRoles.js +97 -0
  47. package/dist/kit/clips.js +40 -0
  48. package/dist/kit/coverPaint.js +18 -0
  49. package/dist/kit/disk.js +76 -0
  50. package/dist/kit/fadeOut.js +13 -0
  51. package/dist/kit/fliClips.js +133 -0
  52. package/dist/kit/fliShrink.js +277 -0
  53. package/dist/kit/gameSim.js +235 -0
  54. package/dist/kit/hopBot.js +142 -0
  55. package/dist/kit/levelGen.js +1423 -0
  56. package/dist/kit/levelGrid.js +33 -0
  57. package/dist/kit/levelPicture.js +27 -0
  58. package/dist/kit/menuVersion.js +19 -0
  59. package/dist/kit/microText.js +35 -0
  60. package/dist/kit/mumble.js +74 -0
  61. package/dist/kit/music.js +8 -0
  62. package/dist/kit/palRamps.js +32 -0
  63. package/dist/kit/palette.js +49 -0
  64. package/dist/kit/pcText.js +72 -0
  65. package/dist/kit/photo.js +150 -0
  66. package/dist/kit/pixels.js +79 -0
  67. package/dist/kit/png.js +40 -0
  68. package/dist/kit/quantize.js +72 -0
  69. package/dist/kit/raytrace.js +379 -0
  70. package/dist/kit/recordedDemo.js +10 -0
  71. package/dist/kit/reel.js +77 -0
  72. package/dist/kit/road3d.js +67 -0
  73. package/dist/kit/routeChecks.js +8 -0
  74. package/dist/kit/saveSlots.js +11 -0
  75. package/dist/kit/sceneInit.js +13 -0
  76. package/dist/kit/sceneSim.js +112 -0
  77. package/dist/kit/screenText.js +15 -0
  78. package/dist/kit/sdftext.js +237 -0
  79. package/dist/kit/shading.js +69 -0
  80. package/dist/kit/song.js +251 -0
  81. package/dist/kit/songFx.js +179 -0
  82. package/dist/kit/sound.js +52 -0
  83. package/dist/kit/synthParts.js +20 -0
  84. package/dist/kit/tar.js +53 -0
  85. package/dist/kit/textBounds.js +84 -0
  86. package/dist/kit/textfit.js +246 -0
  87. package/dist/kit/transforms.js +57 -0
  88. package/dist/kit/tune.js +21 -0
  89. package/dist/look-alike.js +50 -0
  90. package/dist/menu-version.js +4 -0
  91. package/dist/mesh/colorBodies.js +137 -0
  92. package/dist/mesh/decimate.js +207 -0
  93. package/dist/mesh/meshCheck.js +51 -0
  94. package/dist/mesh/overhang.js +41 -0
  95. package/dist/mesh/sampledField.js +12 -0
  96. package/dist/mesh/stl.js +36 -0
  97. package/dist/mesh/surfaceNets.js +79 -0
  98. package/dist/mesh/tetraMesh.js +62 -0
  99. package/dist/mesh/threeMf.js +58 -0
  100. package/dist/mesh/zipFile.js +52 -0
  101. package/dist/microFont.js +101 -0
  102. package/dist/music/compose.js +72 -0
  103. package/dist/pack/meshPack.js +198 -0
  104. package/dist/pack/threeMfPack.js +92 -0
  105. package/dist/palette-reserve.js +116 -0
  106. package/dist/palettes.js +138 -0
  107. package/dist/release-notes.js +40 -0
  108. package/dist/simulation.js +18 -0
  109. package/dist/text.js +74 -0
  110. package/dist/types/audio.d.ts +4 -0
  111. package/dist/types/audioFiles.d.ts +22 -0
  112. package/dist/types/audioWav.d.ts +4 -0
  113. package/dist/types/blockMerge.d.ts +24 -0
  114. package/dist/types/colorReduce.d.ts +23 -0
  115. package/dist/types/colors.d.ts +26 -0
  116. package/dist/types/delta.d.ts +32 -0
  117. package/dist/types/diskDiff.d.ts +47 -0
  118. package/dist/types/drawing.d.ts +15 -0
  119. package/dist/types/embroidery/compile.d.ts +3 -0
  120. package/dist/types/embroidery/dst.d.ts +13 -0
  121. package/dist/types/embroidery/exp.d.ts +8 -0
  122. package/dist/types/embroidery/fill.d.ts +6 -0
  123. package/dist/types/embroidery/geom.d.ts +19 -0
  124. package/dist/types/embroidery/pes.d.ts +10 -0
  125. package/dist/types/embroidery/satin.d.ts +11 -0
  126. package/dist/types/embroidery/simulate.d.ts +19 -0
  127. package/dist/types/embroidery/strokeFont.d.ts +20 -0
  128. package/dist/types/embroidery/svg.d.ts +3 -0
  129. package/dist/types/embroidery/types.d.ts +70 -0
  130. package/dist/types/embroidery/units.d.ts +10 -0
  131. package/dist/types/embroidery/validate.d.ts +22 -0
  132. package/dist/types/formats/blocks.d.ts +1 -0
  133. package/dist/types/formats/character.d.ts +1 -0
  134. package/dist/types/formats/cmf.d.ts +1 -0
  135. package/dist/types/formats/fli.d.ts +1 -0
  136. package/dist/types/formats/fliLimits.d.ts +1 -0
  137. package/dist/types/formats/game.d.ts +1 -0
  138. package/dist/types/formats/gif.d.ts +1 -0
  139. package/dist/types/formats/graphicScripts.d.ts +1 -0
  140. package/dist/types/formats/map.d.ts +1 -0
  141. package/dist/types/formats/monster.d.ts +1 -0
  142. package/dist/types/formats/palette.d.ts +1 -0
  143. package/dist/types/formats/recording.d.ts +1 -0
  144. package/dist/types/formats/sound.d.ts +1 -0
  145. package/dist/types/formats/voc.d.ts +1 -0
  146. package/dist/types/gifShrink.d.ts +8 -0
  147. package/dist/types/image/animatedGif.d.ts +9 -0
  148. package/dist/types/image/png.d.ts +10 -0
  149. package/dist/types/image/surface.d.ts +26 -0
  150. package/dist/types/images.d.ts +13 -0
  151. package/dist/types/kit/actors.d.ts +7 -0
  152. package/dist/types/kit/align.d.ts +93 -0
  153. package/dist/types/kit/audioEvents.d.ts +26 -0
  154. package/dist/types/kit/blit.d.ts +20 -0
  155. package/dist/types/kit/blockRoles.d.ts +243 -0
  156. package/dist/types/kit/clips.d.ts +36 -0
  157. package/dist/types/kit/coverPaint.d.ts +7 -0
  158. package/dist/types/kit/disk.d.ts +15 -0
  159. package/dist/types/kit/fadeOut.d.ts +12 -0
  160. package/dist/types/kit/fliClips.d.ts +32 -0
  161. package/dist/types/kit/fliShrink.d.ts +149 -0
  162. package/dist/types/kit/gameSim.d.ts +112 -0
  163. package/dist/types/kit/hopBot.d.ts +72 -0
  164. package/dist/types/kit/laserClearance.d.ts +16 -0
  165. package/dist/types/kit/laserJoints.d.ts +39 -0
  166. package/dist/types/kit/laserLayout.d.ts +54 -0
  167. package/dist/types/kit/laserPixels.d.ts +52 -0
  168. package/dist/types/kit/laserPreview.d.ts +9 -0
  169. package/dist/types/kit/laserSvg.d.ts +35 -0
  170. package/dist/types/kit/levelGen/castle.d.ts +17 -0
  171. package/dist/types/kit/levelGen/dungeon.d.ts +11 -0
  172. package/dist/types/kit/levelGen/forest.d.ts +17 -0
  173. package/dist/types/kit/levelGen/furnish.d.ts +31 -0
  174. package/dist/types/kit/levelGen/grid.d.ts +46 -0
  175. package/dist/types/kit/levelGen/index.d.ts +138 -0
  176. package/dist/types/kit/levelGen/interior.d.ts +18 -0
  177. package/dist/types/kit/levelGen/jumpModel.d.ts +78 -0
  178. package/dist/types/kit/levelGen/needs.d.ts +44 -0
  179. package/dist/types/kit/levelGen/overworld.d.ts +21 -0
  180. package/dist/types/kit/levelGen/platform.d.ts +59 -0
  181. package/dist/types/kit/levelGen/platformCap.d.ts +13 -0
  182. package/dist/types/kit/levelGen/platformReach.d.ts +37 -0
  183. package/dist/types/kit/levelGen/props.d.ts +37 -0
  184. package/dist/types/kit/levelGen/town.d.ts +24 -0
  185. package/dist/types/kit/levelGrid.d.ts +16 -0
  186. package/dist/types/kit/levelPicture.d.ts +9 -0
  187. package/dist/types/kit/menuVersion.d.ts +7 -0
  188. package/dist/types/kit/microText.d.ts +18 -0
  189. package/dist/types/kit/mumble.d.ts +41 -0
  190. package/dist/types/kit/music.d.ts +1 -0
  191. package/dist/types/kit/palMerge.d.ts +10 -0
  192. package/dist/types/kit/palRamps.d.ts +28 -0
  193. package/dist/types/kit/palette.d.ts +16 -0
  194. package/dist/types/kit/pcText.d.ts +19 -0
  195. package/dist/types/kit/photo.d.ts +69 -0
  196. package/dist/types/kit/pixels.d.ts +26 -0
  197. package/dist/types/kit/png.d.ts +7 -0
  198. package/dist/types/kit/quantize.d.ts +20 -0
  199. package/dist/types/kit/raytrace.d.ts +169 -0
  200. package/dist/types/kit/recordedDemo.d.ts +1 -0
  201. package/dist/types/kit/reel.d.ts +34 -0
  202. package/dist/types/kit/road3d.d.ts +71 -0
  203. package/dist/types/kit/routeChecks.d.ts +6 -0
  204. package/dist/types/kit/saveSlots.d.ts +17 -0
  205. package/dist/types/kit/sceneInit.d.ts +11 -0
  206. package/dist/types/kit/sceneSim.d.ts +84 -0
  207. package/dist/types/kit/screenText.d.ts +3 -0
  208. package/dist/types/kit/sdftext.d.ts +34 -0
  209. package/dist/types/kit/shading.d.ts +23 -0
  210. package/dist/types/kit/shareBlocks.d.ts +20 -0
  211. package/dist/types/kit/song.d.ts +89 -0
  212. package/dist/types/kit/songFx.d.ts +99 -0
  213. package/dist/types/kit/sound.d.ts +29 -0
  214. package/dist/types/kit/synthParts.d.ts +7 -0
  215. package/dist/types/kit/tar.d.ts +13 -0
  216. package/dist/types/kit/textBounds.d.ts +51 -0
  217. package/dist/types/kit/textfit.d.ts +74 -0
  218. package/dist/types/kit/transforms.d.ts +8 -0
  219. package/dist/types/kit/tune.d.ts +6 -0
  220. package/dist/types/lookAlike.d.ts +31 -0
  221. package/dist/types/menuVersionEntry.d.ts +1 -0
  222. package/dist/types/mesh/colorBodies.d.ts +18 -0
  223. package/dist/types/mesh/decimate.d.ts +10 -0
  224. package/dist/types/mesh/fieldTrinket.d.ts +40 -0
  225. package/dist/types/mesh/figureShapes.d.ts +24 -0
  226. package/dist/types/mesh/mesh.d.ts +9 -0
  227. package/dist/types/mesh/meshCheck.d.ts +22 -0
  228. package/dist/types/mesh/overhang.d.ts +24 -0
  229. package/dist/types/mesh/pixelFigure.d.ts +41 -0
  230. package/dist/types/mesh/sampledField.d.ts +3 -0
  231. package/dist/types/mesh/sdfShapes.d.ts +20 -0
  232. package/dist/types/mesh/stl.d.ts +9 -0
  233. package/dist/types/mesh/strokeText.d.ts +8 -0
  234. package/dist/types/mesh/surfaceNets.d.ts +14 -0
  235. package/dist/types/mesh/tetraMesh.d.ts +4 -0
  236. package/dist/types/mesh/threeMf.d.ts +12 -0
  237. package/dist/types/mesh/trinketKinds.d.ts +72 -0
  238. package/dist/types/mesh/trinketTool.d.ts +26 -0
  239. package/dist/types/mesh/voxel.d.ts +10 -0
  240. package/dist/types/mesh/zipFile.d.ts +13 -0
  241. package/dist/types/microFont.d.ts +6 -0
  242. package/dist/types/music/compose.d.ts +51 -0
  243. package/dist/types/pack/meshPack.d.ts +26 -0
  244. package/dist/types/pack/threeMfPack.d.ts +11 -0
  245. package/dist/types/palettePresetData.d.ts +4 -0
  246. package/dist/types/palettePresets.d.ts +12 -0
  247. package/dist/types/paletteReserve.d.ts +52 -0
  248. package/dist/types/palettes.d.ts +4 -0
  249. package/dist/types/releaseNotes.d.ts +3 -0
  250. package/dist/types/simulation.d.ts +6 -0
  251. package/dist/types/text.d.ts +41 -0
  252. package/package.json +190 -4
@@ -0,0 +1,92 @@
1
+ import { packIndices as A, unpackIndices as x } from "./meshPack.js";
2
+ import { write3mf as M } from "../mesh/threeMf.js";
3
+ import { readZip as b } from "../mesh/zipFile.js";
4
+ function D(t, r) {
5
+ return b(M(t, r));
6
+ }
7
+ const y = 1295207751, w = (t) => t.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&amp;/g, "&"), E = (t) => t >= 0 ? t * 2 : -t * 2 - 1, N = (t) => t % 2 ? -(t + 1) / 2 : t / 2;
8
+ function p(t, r) {
9
+ for (let e = 0; e < t.length; e++) {
10
+ let o = t[e];
11
+ for (; o >= 128; )
12
+ r.push(o % 128 | 128), o = Math.floor(o / 128);
13
+ r.push(o);
14
+ }
15
+ }
16
+ function F(t) {
17
+ const r = w(/<metadata name="Title">([^<]*)<\/metadata>/.exec(t)?.[1] ?? ""), e = [...t.matchAll(/<base name="[^"]*" displaycolor="#([0-9A-F]{6})"\/>/g)].map(
18
+ (a) => [0, 2, 4].map((l) => parseInt(a[1].slice(l, l + 2), 16))
19
+ ), o = [];
20
+ for (const a of t.matchAll(/<object id="\d+" type="model" name="([^"]*)" pid="1" pindex="(\d+)">([\s\S]*?)<\/object>/g)) {
21
+ const l = e[Number(a[2])];
22
+ if (!l) throw new Error("A 3MF part names a color it does not have");
23
+ const i = [];
24
+ for (const c of a[3].matchAll(/<vertex x="([^"]+)" y="([^"]+)" z="([^"]+)"\/>/g)) i.push(...[c[1], c[2], c[3]].map((s) => Math.round(Number(s) * 1e3)));
25
+ const h = [];
26
+ for (const c of a[3].matchAll(/<triangle v1="(\d+)" v2="(\d+)" v3="(\d+)"\/>/g)) h.push(Number(c[1]), Number(c[2]), Number(c[3]));
27
+ o.push({ name: w(a[1]), color: l, ints: Int32Array.from(i), indices: Uint32Array.from(h) });
28
+ }
29
+ return { title: r, parts: o };
30
+ }
31
+ const v = (t) => t.parts.map((r) => ({ name: r.name, color: r.color, mesh: { positions: Float32Array.from(r.ints, (e) => e / 1e3), indices: r.indices } })), I = (t, r) => t.length === r.length && t.every((e, o) => e.name === r[o].name && e.data.length === r[o].data.length && e.data.every((a, l) => a === r[o].data[l]));
32
+ function j(t, r) {
33
+ const e = b(t, r), o = e.find((n) => n.name === "3D/3dmodel.model");
34
+ if (!o) throw new Error("No 3D/3dmodel.model in the file");
35
+ const a = F(new TextDecoder().decode(o.data));
36
+ if (!I(D(v(a), a.title), e)) throw new Error("This 3MF would not be made again the same: not one write3mf wrote");
37
+ const l = new TextEncoder(), i = [], h = (n) => {
38
+ const m = l.encode(n);
39
+ p([m.length], i), i.push(...m);
40
+ };
41
+ h(a.title), p([a.parts.length], i);
42
+ const c = [];
43
+ for (const n of a.parts) {
44
+ h(n.name), i.push(...n.color), p([n.ints.length / 3, n.indices.length / 3], i);
45
+ for (let f = 0; f < 3; f++) {
46
+ const u = [];
47
+ let g = 0;
48
+ for (let d = f; d < n.ints.length; d += 3)
49
+ u.push(E(n.ints[d] - g)), g = n.ints[d];
50
+ p(u, c);
51
+ }
52
+ const m = A(n.indices);
53
+ p([m.length], c);
54
+ for (const f of m) c.push(f);
55
+ }
56
+ const s = new Uint8Array(8 + i.length + c.length);
57
+ return new DataView(s.buffer).setUint32(0, y, !0), new DataView(s.buffer).setUint32(4, i.length, !0), s.set(i, 8), s.set(c, 8 + i.length), s;
58
+ }
59
+ function P(t) {
60
+ const r = new DataView(t.buffer, t.byteOffset, t.byteLength);
61
+ if (t.length < 8 || r.getUint32(0, !0) !== y) throw new Error("Not a packed 3MF");
62
+ let e = 8;
63
+ const o = () => {
64
+ let s = 0, n = 1;
65
+ for (; ; ) {
66
+ if (e >= t.length) throw new Error("Packed 3MF is cut short");
67
+ const m = t[e++];
68
+ if (s += (m & 127) * n, m < 128) return s;
69
+ n *= 128;
70
+ }
71
+ }, a = new TextDecoder(), l = () => {
72
+ const s = o(), n = a.decode(t.subarray(e, e + s));
73
+ return e += s, n;
74
+ }, i = l(), c = Array.from({ length: o() }, () => {
75
+ const s = l(), n = [t[e], t[e + 1], t[e + 2]];
76
+ return e += 3, { name: s, color: n, verts: o(), tris: o() };
77
+ }).map((s) => {
78
+ const n = new Int32Array(s.verts * 3);
79
+ for (let u = 0; u < 3; u++) {
80
+ let g = 0;
81
+ for (let d = u; d < n.length; d += 3) n[d] = g += N(o());
82
+ }
83
+ const m = o(), f = x(t.subarray(e, e + m), s.tris * 3);
84
+ return e += m, { name: s.name, color: s.color, ints: n, indices: f };
85
+ });
86
+ return { title: i, parts: v({ parts: c }) };
87
+ }
88
+ export {
89
+ j as pack3mf,
90
+ D as threeMfEntries,
91
+ P as unpack3mf
92
+ };
@@ -0,0 +1,116 @@
1
+ import { labOf as C, FLAG_MEAN as V, FLAG_WORST as X } from "./color-reduce.js";
2
+ const Y = 16, Z = 254, tt = 48;
3
+ function ot(p, r) {
4
+ const u = [], w = /* @__PURE__ */ new Set(), A = p.filter((s) => s.distinct > 0).sort((s, g) => g.distinct - s.distinct);
5
+ for (const s of A) {
6
+ const g = Math.min(s.distinct, tt);
7
+ let l;
8
+ for (let n = Y; n + g - 1 <= Z; n++) {
9
+ let d = 0, h = !1;
10
+ for (let i = n; i < n + g; i++) {
11
+ if (w.has(i)) {
12
+ h = !0;
13
+ break;
14
+ }
15
+ d += (r[i] ?? 0) + A.reduce((k, M) => M === s ? k : k + (M.usage[i] ?? 0), 0) - (s.usage[i] ?? 0) * 0.5;
16
+ }
17
+ !h && (!l || d < l.cost) && (l = { start: n, cost: d });
18
+ }
19
+ if (!l) continue;
20
+ let m = 0;
21
+ for (let n = l.start; n < l.start + g; n++)
22
+ w.add(n), m += (r[n] ?? 0) + A.reduce((d, h) => h === s ? d : d + (h.usage[n] ?? 0), 0);
23
+ u.push({ first: l.start, last: l.start + g - 1, role: s.role, conflicts: m });
24
+ }
25
+ return u.sort((s, g) => s.first - g.first);
26
+ }
27
+ const J = (p, r) => p[r * 3] << 12 | p[r * 3 + 1] << 6 | p[r * 3 + 2];
28
+ function st(p, r, u, w, A) {
29
+ const s = w - u + 1, g = new Set(p.flatMap((t) => t.palettes));
30
+ for (const t of g) {
31
+ if (!r.has(t)) return { ok: !1, why: `palette ${t} is missing` };
32
+ const e = A.get(t);
33
+ if (e) {
34
+ for (let a = u; a <= w; a++) if (e.has(a)) return { ok: !1, why: `${t} has other blocks drawing with color ${a}; reduce those colors first` };
35
+ }
36
+ }
37
+ const l = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
38
+ p.forEach((t) => {
39
+ const e = r.get(t.palettes[0]);
40
+ for (const a of t.shown)
41
+ for (const c of t.blocks[a]?.pixels ?? []) {
42
+ if (c === 0 || c === 255) continue;
43
+ const f = J(e, c);
44
+ l.set(f, (l.get(f) ?? 0) + 1), m.has(f) || m.set(f, { pal: e, index: c }), c >= u && c <= w && !n.has(f) && n.set(f, c);
45
+ }
46
+ });
47
+ const d = [...l.entries()].sort((t, e) => e[1] - t[1] || t[0] - e[0]), h = d.slice(0, s).map(([t]) => t), i = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Set();
48
+ for (const t of h) {
49
+ const e = n.get(t);
50
+ e !== void 0 && !k.has(e) && (i.set(t, e), k.add(e));
51
+ }
52
+ let M = u;
53
+ for (const t of h)
54
+ if (!i.has(t)) {
55
+ for (; k.has(M); ) M++;
56
+ i.set(t, M), k.add(M);
57
+ }
58
+ const K = (t) => C(m.get(t).pal, m.get(t).index), U = new Map(i);
59
+ for (const [t] of d.slice(s)) {
60
+ const e = K(t);
61
+ let a = h[0], c = 1 / 0;
62
+ for (const f of h) {
63
+ const o = K(f), b = Math.hypot(e[0] - o[0], e[1] - o[1], e[2] - o[2]);
64
+ b < c && (c = b, a = f);
65
+ }
66
+ U.set(t, i.get(a));
67
+ }
68
+ const Q = r.get(p[0].palettes[0]), R = new Uint8Array(s * 3);
69
+ R.set(Q.subarray(u * 3, (w + 1) * 3));
70
+ for (const t of h) R.set([t >> 12 & 63, t >> 6 & 63, t & 63], (i.get(t) - u) * 3);
71
+ const $ = /* @__PURE__ */ new Map();
72
+ for (const t of g) {
73
+ const e = r.get(t);
74
+ if (e.subarray(u * 3, (w + 1) * 3).every((c, f) => c === R[f])) continue;
75
+ const a = e.slice();
76
+ a.set(R, u * 3), $.set(t, a);
77
+ }
78
+ const W = /* @__PURE__ */ new Map(), I = [], j = [];
79
+ let z = 0, N = 0, O = 0;
80
+ return p.forEach((t, e) => {
81
+ const a = r.get(t.palettes[0]), c = /* @__PURE__ */ new Map(), f = (o) => o === 0 || o === 255 ? o : U.get(J(a, o)) ?? o;
82
+ for (let o = 0; o < t.blocks.length; o++) {
83
+ const b = t.blocks[o].pixels, B = t.shown.has(o), P = B ? b.map(f) : b;
84
+ if (!B) continue;
85
+ const D = P.some((_, x) => _ !== b[x]);
86
+ D && c.set(o, P);
87
+ let S = 0, y = 0, F = 0;
88
+ for (const _ of t.palettes) {
89
+ const x = r.get(_), G = $.get(_) ?? x;
90
+ for (let L = 0; L < b.length; L++) {
91
+ const [E, T] = [b[L], P[L]];
92
+ if (E === 255 || E === 0 || x[E * 3] === G[T * 3] && x[E * 3 + 1] === G[T * 3 + 1] && x[E * 3 + 2] === G[T * 3 + 2]) continue;
93
+ const [q, v] = [C(x, E), C(G, T)], H = Math.hypot(q[0] - v[0], q[1] - v[1], q[2] - v[2]);
94
+ S += H, y++, F = Math.max(F, H);
95
+ }
96
+ }
97
+ !D && !y || (I.push({ file: e, n: o, mean: y ? S / y : 0 }), y && (S / y > V || F > X) && j.push(o), z += S, N += y, O = Math.max(O, F));
98
+ }
99
+ W.set(e, c);
100
+ }), I.sort((t, e) => e.mean - t.mean), {
101
+ ok: !0,
102
+ pixels: W,
103
+ palettes: $,
104
+ score: { mean: N ? z / N : 0, worst: O, flagged: j },
105
+ changed: I,
106
+ used: h.length,
107
+ reduced: Math.max(0, d.length - s)
108
+ };
109
+ }
110
+ export {
111
+ Y as FIRST_FREE,
112
+ Z as LAST_FREE,
113
+ tt as RANGE_CAP,
114
+ ot as planRanges,
115
+ st as syncRange
116
+ };
@@ -0,0 +1,138 @@
1
+ import { colorRamp as s } from "./colors.js";
2
+ const l = `
3
+ 000000 404040 6c6c6c 909090 b0b0b0 c8c8c8 dcdcdc ececec
4
+ 444400 646410 848424 a0a034 b8b840 d0d050 e8e85c fcfc68
5
+ 702800 844414 985c28 ac783c bc8c4c cca05c dcb468 e8cc7c
6
+ 841800 983418 ac5030 c06848 d0805c e09470 eca880 fcbc94
7
+ 880000 9c2020 b03c3c c05858 d07070 e08888 eca0a0 fcb4b4
8
+ 78005c 8c2074 a03c88 b0589c c070b0 d084c0 dc9cd0 ecb0e0
9
+ 480078 602090 783ca4 8c58b8 a070cc b484dc c49cec d4b0fc
10
+ 140084 302098 4c3cac 6858c0 7c70d0 9488e0 a8a0ec bcb4fc
11
+ 000088 1c209c 3840b0 505cc0 6874d0 7c8ce0 90a4ec a4b8fc
12
+ 00187c 1c3890 3854a8 5070bc 6888cc 7c9cdc 90b4ec a4c8fc
13
+ 002c5c 1c4c78 386890 5084ac 689cc0 7cb4d4 90cce8 a4e0fc
14
+ 00402c 1c5c48 387c64 509c80 68b494 7cd0ac 90e4c0 a4fcd4
15
+ 003c00 205c20 407c40 5c9c5c 74b474 8cd08c a4e4a4 b8fcb8
16
+ 143800 345c1c 507c38 6c9850 84b468 9ccc7c b4e490 c8fca4
17
+ 2c3000 4c501c 687034 848c4c 9ca864 b4c078 ccd488 e0ec9c
18
+ 442800 644818 846830 a08444 b89c58 d0b46c e8cc7c fce08c
19
+ `, w = `
20
+ 000000 404040 6c6c6c 909090 b0b0b0 c8c8c8 dcdcdc ececec
21
+ 805800 947020 a8843c bc9c58 ccac70 dcc084 ecd09c fce0b0
22
+ 445c00 5c7820 74903c 8cac58 a0c070 b0d484 c0e89c d4fcb0
23
+ 703400 885020 a0683c b48458 c89870 dcac84 ecc09c fcd4b0
24
+ 006414 208034 3c9850 58b06c 70c484 84d89c 9ce8b4 b0fcc8
25
+ 700014 882034 a03c50 b4586c c87084 dc849c ec9cb4 fcb0c8
26
+ 005c5c 207474 3c8c8c 58a4a4 70b8b8 84c8c8 9cdcdc b0ecec
27
+ 70005c 842074 943c88 a8589c b470b0 c484c0 d09cd0 e0b0e0
28
+ 003c70 1c5888 3874a0 508cb4 68a4c8 7cb8dc 90ccec a4e0fc
29
+ 580070 6c2088 803ca0 9458b4 a470c8 b484dc c49cec d4b0fc
30
+ 002070 1c3c88 3858a0 5074b4 6888c8 7ca0dc 90b4ec a4c8fc
31
+ 3c0080 542094 6c3ca8 8058bc 9470cc a884dc b89cec c8b0fc
32
+ 000088 20209c 3c3cb0 5858c0 7070d0 8484e0 9c9cec b0b0fc
33
+ `, m = `
34
+ 575757 000c8e 0800a6 340096 550061 630015 5a0000 3c0e00
35
+ 112800 003b00 004200 003a05 002652 000000 a5a5a5 0041d9
36
+ 2f1eff 6704f2 9400b4 aa0057 a31800 803900 4b5b00 137600
37
+ 008100 007923 006288 ffffff 4a9fff 797eff af63ff dd55ff
38
+ f757c2 f76a63 dc8810 aea900 78c400 4ad211 2fcf64 2fbdc4
39
+ 414141 b9ddff cad1ff dec6ff f0c0ff fcc0ee fdc6ca f5d0aa
40
+ e4dd95 d0e892 bdeea2 b2eec0 b0e8e3 b3b3b3
41
+ `, i = `
42
+ 000000 ffffff fa3200 1de0ff a84bcc 68ba51 004ad0 ffe94d
43
+ ff5b00 c13e00 ff723e 605e62 8c937f b2ff90 458aff c3b8d7
44
+ `, t = (c) => c.trim().split(/\s+/).map((A) => [0, 2, 4].map((a) => parseInt(A.slice(a, a + 2), 16))), d = (c) => s(c, [0, 0, 0], [255, 255, 255]), r = () => Array.from({ length: 16 }, (c, A) => A === 6 ? [170, 85, 0] : [4, 2, 1].map((a) => (A & a ? 170 : 0) + (A & 8 ? 85 : 0))), e = (c, A, a, b, f, o) => ({
45
+ id: c,
46
+ name: A,
47
+ stem: a,
48
+ entries: b,
49
+ description: f,
50
+ colors: o
51
+ }), B = () => [
52
+ e("amber", "Monochrome amber", "monoamb", 32, "32 shades from black to warm amber.", () => s(32, [0, 0, 0], [255, 184, 48])),
53
+ e("green", "Monochrome green", "monogrn", 32, "32 shades from black to phosphor green.", () => s(32, [0, 0, 0], [64, 255, 96])),
54
+ e("white", "Monochrome white", "monowht", 32, "32 shades from black to white.", () => d(32)),
55
+ e(
56
+ "atari-ntsc",
57
+ "Atari 2600 NTSC",
58
+ "atntsc",
59
+ 128,
60
+ "128 TIA color slots, using Ricardo Cancho Niemietz’s RGB reference approximation.",
61
+ () => t(l)
62
+ ),
63
+ e("atari-pal", "Atari 2600 PAL", "atpal", 104, "104 colors after removing repeated gray columns from the PAL reference.", () => t(w)),
64
+ e("nes", "NES · 54 colors", "nes54", 54, "Persune’s unemphasized 2C02G US reference, adapted to VGA.", () => t(m)),
65
+ e("cga-cyan", "CGA cyan / magenta", "cga0", 4, "Black, bright cyan, bright magenta and white.", () => [r()[0], r()[11], r()[13], r()[15]]),
66
+ e("cga-green", "CGA green / red / brown", "cga1", 4, "Black, green, red and orange-brown, with the RGBI brown correction.", () => [
67
+ r()[0],
68
+ r()[2],
69
+ r()[4],
70
+ r()[6]
71
+ ]),
72
+ e("ega", "EGA · 16 colors", "ega16", 16, "The standard 16 RGBI colors, with brown corrected.", r),
73
+ e("ega-skin", "EGA + skin tones & hair", "egaskin", 28, "The 16 EGA colors plus three project-designed four-color skin and hair ramps.", () => [
74
+ ...r(),
75
+ ...s(4, [92, 48, 28], [255, 226, 194]),
76
+ ...s(4, [46, 26, 22], [163, 107, 74]),
77
+ ...s(4, [20, 15, 15], [158, 123, 60])
78
+ ]),
79
+ e(
80
+ "gameboy",
81
+ "Game Boy greens",
82
+ "gbgreen",
83
+ 5,
84
+ "Four project-designed LCD greens, plus black at index 0 for menus.",
85
+ () => s(4, [20, 52, 20], [188, 212, 96])
86
+ ),
87
+ e(
88
+ "sega",
89
+ "Sega Master System · 64 colors",
90
+ "sms64",
91
+ 64,
92
+ "SMS2 RGB colors: two bits per channel.",
93
+ () => Array.from({ length: 64 }, (c, A) => [(A & 3) * 85, (A >> 2 & 3) * 85, (A >> 4 & 3) * 85])
94
+ ),
95
+ e("c64", "Commodore 64 · 16 colors", "c64ntsc", 16, "Groepaz’s NTSC CXA2025 reference, with menu black normalized.", () => t(i)),
96
+ e(
97
+ "websafe",
98
+ "Web-safe · 216 colors",
99
+ "websafe",
100
+ 216,
101
+ "The six-level RGB cube, rounded to VGA’s channel levels.",
102
+ () => Array.from({ length: 216 }, (c, A) => [Math.floor(A / 36) * 51, Math.floor(A / 6) % 6 * 51, A % 6 * 51])
103
+ ),
104
+ ...[4, 8, 16, 32, 64, 128].map(
105
+ (c) => e(
106
+ `gray-${c}`,
107
+ `Grayscale · ${c} steps`,
108
+ `gray${c}`,
109
+ c,
110
+ c === 128 ? "128 steps; VGA can represent 64 distinct gray shades, so adjacent steps repeat." : `${c} evenly spaced gray shades.`,
111
+ () => d(c)
112
+ )
113
+ )
114
+ ];
115
+ let p;
116
+ const g = () => p ??= B(), P = () => Object.freeze(g().map(({ colors: c, ...A }) => Object.freeze(A))), C = /* @__PURE__ */ P();
117
+ function G(c) {
118
+ const A = g().find((o) => o.id === c);
119
+ if (!A) throw new RangeError(`Unknown palette preset: ${c}`);
120
+ const a = [...A.colors()], b = a.findIndex((o) => o.every((n) => n === 0));
121
+ b >= 0 && a.splice(b, 1), a.unshift([0, 0, 0]);
122
+ const f = new Uint8Array(768);
123
+ return a.slice(0, 255).forEach(
124
+ (o, n) => f.set(
125
+ o.map((h) => Math.round(h * 63 / 255)),
126
+ n * 3
127
+ )
128
+ ), f;
129
+ }
130
+ const D = "AAAAAAAHAAAKAAANAAASAAAXAAAcAAAhAAAmAAArAAAwAAA1AAA5AAA8AAA/Pz8hAAgAAA0AABIAABcAABwAACEAACYAACsAADAAADUAADoAAD8AAAkFAAwGABAIABgMACAQACgUADAYADgcAD8gGT8hID8mKz8rMD8wMj8yDBAAEBYAFBsAGCAAHCQAICkAJDAACBIABRMGAAwJABIOABgSAB4XACQbACofADEoADgqAD8wAAgIAAwMABISABcXABwcACEhACYmACsrADAwADU1ADo6AD8/GT8/Iz8/LT8/CAoQDhEcDhUcDhgcDhwcAAgLAAwQABEWABUcABskCAAADQAAEgAAFwAAHAAAIQAAJgAAKwAAMAAANQAAOgAAPwAADAMAEAUAGAgAIAkAKAsAMAwANw4APxAAFAADHAAGKgQJOQsPPA4SPxEVEAgAFgsAGg0AIBAAJBIALBYAMhkAOBwAPyAAPy0EDgcEEgkFFgsGGg0HHg8IIhEJJhMKKhULLhcMMhkNNhsOOSERPCUXPyobPy4jCAgADQ0AEhIAFxcAHBwBISEAJiYAKysAMDAANTUAOjoAPz8APz8QPz8YPz8gPz8oPz8wDg4IFhYMHBwOIiIRLCwWNjYbCQEADAMAEAQAFAUAGAYACgcEEAwIFBAMGBQQHBgUEAAQGAAYIQAhJgAmKwArMAAwNQA1OgA6PwA/DQAREQAVFQAcGgAhHwAmJAAsJwAyKgA4Lgg/LBUmDw8WFhYeGxsmICAsIyMxJiY1KSk4LCw8MDA/NTU/CAgIDQ0NEhISFxcXHBwcISEhJiYmKysrMDAwNTU1Ojo6Pz8/MhgbOBwgPyEhPyYmPysrPzIyEAAIGQANIQATKAAWLgAZNAAcOgAfPwAhPwokPxQnPxgsPxwwPx81PyY7Pyw/LT82Nj8qMDA/Mz8TPzotLTY/LT8/AAA/AAA/AAA/AAA/AAA/AAA/AAA/AAA/AAA/AAA/AAA/AAA/AAA/AAA/AAA/AAA/AAA/BgsX";
131
+ function I() {
132
+ return Uint8Array.from(atob(D), (c) => c.charCodeAt(0));
133
+ }
134
+ export {
135
+ C as PALETTE_PRESETS,
136
+ G as createPalettePreset,
137
+ I as libraryDefaultPalette
138
+ };
@@ -0,0 +1,40 @@
1
+ const s = [
2
+ ["gam", "game file", "game files"],
3
+ ["map", "map", "maps"],
4
+ ["bbl", "background block set", "background block sets"],
5
+ ["mbl", "monster block set", "monster block sets"],
6
+ ["cbl", "character block set", "character block sets"],
7
+ ["chr", "character", "characters"],
8
+ ["mon", "monster set", "monster sets"],
9
+ ["pal", "palette", "palettes"],
10
+ ["gif", "picture", "pictures"],
11
+ ["fli", "animation", "animations"],
12
+ ["voc", "sound", "sounds"],
13
+ ["text", "text file", "text files"]
14
+ ], h = ["other file", "other files"];
15
+ const d = (e) => e.toUpperCase(), a = (e) => {
16
+ const t = s.findIndex(([n]) => n === e);
17
+ return t < 0 ? s.length : t;
18
+ };
19
+ function m(e) {
20
+ const t = e.slice(0, 4).map(d).join(", ");
21
+ return e.length > 4 ? `${t} and ${e.length - 4} more` : t;
22
+ }
23
+ function c(e) {
24
+ const t = /* @__PURE__ */ new Map();
25
+ for (const n of e) {
26
+ const o = s.some(([r]) => r === n.kind) ? n.kind : "other";
27
+ t.set(o, [...t.get(o) ?? [], n.name]);
28
+ }
29
+ return [...t.entries()].sort((n, o) => a(n[0]) - a(o[0])).map(([n, o]) => {
30
+ const [r, i] = s.find(([l]) => l === n)?.slice(1) ?? h;
31
+ return `${o.length} ${o.length === 1 ? r : i} (${m(o)})`;
32
+ }).join(", ");
33
+ }
34
+ function p(e) {
35
+ const t = [];
36
+ return e.changed.length && t.push(`Changed ${c(e.changed)}.`), e.added.length && t.push(`Added ${c(e.added)}.`), e.removed.length && t.push(`Removed ${c(e.removed)}.`), t.join(" ");
37
+ }
38
+ export {
39
+ p as releaseNotes
40
+ };
@@ -0,0 +1,18 @@
1
+ import { Sim as r } from "./kit/sceneSim.js";
2
+ import { GameSim as m, TICKS_PER_SECOND as t, diskSim as n, readDisk as S } from "./kit/gameSim.js";
3
+ import { newCharInfo as f } from "@lewismoten/gamemaker-sandbox-engine/engine/world";
4
+ import { initializeScene as x, legacySceneInits as a } from "./kit/sceneInit.js";
5
+ import { expectScene as k } from "./kit/routeChecks.js";
6
+ import { changeBlocks as C } from "@lewismoten/gamemaker-sandbox-engine/engine/scene";
7
+ export {
8
+ m as GameSim,
9
+ r as Sim,
10
+ t as TICKS_PER_SECOND,
11
+ C as changeBlocks,
12
+ n as diskSim,
13
+ k as expectScene,
14
+ x as initializeScene,
15
+ a as legacySceneInits,
16
+ f as newCharInfo,
17
+ S as readDisk
18
+ };
package/dist/text.js ADDED
@@ -0,0 +1,74 @@
1
+ import { FONT_CP437 as T } from "@lewismoten/gamemaker-sandbox-engine/gfx/cp437Glyphs";
2
+ import { FONT_CP437 as z } from "@lewismoten/gamemaker-sandbox-engine/gfx/cp437Glyphs";
3
+ import { toCp437 as M, fromCp437 as P } from "@lewismoten/gamemaker-sandbox-engine/text/cp437";
4
+ import { fromCp437 as D, toCp437 as J } from "@lewismoten/gamemaker-sandbox-engine/text/cp437";
5
+ import { Pixels as N } from "./kit/pixels.js";
6
+ import { MICRO_SQUARE_GLYPHS as Y, MICRO_GLYPHS as k } from "./microFont.js";
7
+ function G(e) {
8
+ for (const t of e)
9
+ if (t.charCodeAt(0) >= 128 && M(t) === t && P(t) !== t) throw new RangeError(`No CP437 glyph for ${t}`);
10
+ const i = M(e), n = new Uint8Array(i.length);
11
+ for (let t = 0; t < i.length; t++) {
12
+ const o = i.charCodeAt(t);
13
+ if (o > 255) throw new RangeError(`No CP437 glyph for ${i[t]}`);
14
+ n[t] = o;
15
+ }
16
+ return n;
17
+ }
18
+ function H(e, i = "cp437") {
19
+ if (!Number.isInteger(e) || e < 0 || e > 255) throw new RangeError("Glyph code must be 0..255");
20
+ if (i === "cp437") return T.slice(e * 8, e * 8 + 8);
21
+ const n = i === "micro-square" ? Y : k, t = P(String.fromCharCode(e)), o = n[t] ?? n[t.toUpperCase()] ?? n["?"];
22
+ return Uint8Array.from({ length: 5 }, (f, r) => {
23
+ let a = 0;
24
+ for (let s = 0; s < 3; s++) o[r * 3 + s] === "1" && (a |= 1 << s);
25
+ return a;
26
+ });
27
+ }
28
+ function F(e, i, n = 1, t = 2) {
29
+ if (x(i), !Number.isInteger(n) || !Number.isInteger(t)) throw new RangeError("Shadow offsets must be integers");
30
+ const o = new N(e.w, e.h, 255);
31
+ for (let f = 0; f < e.h; f++) for (let r = 0; r < e.w; r++) e.get(r, f) !== 255 && o.set(r + n, f + t, i);
32
+ return o.blit(e, 0, 0, 255);
33
+ }
34
+ function x(e) {
35
+ if (!Number.isInteger(e) || e < 0 || e > 254) throw new RangeError("Ink must be a palette index 0..254");
36
+ }
37
+ function Q(e, i = {}) {
38
+ const { font: n = "cp437", color: t = 0, scale: o = 1, outline: f, shadow: r } = i;
39
+ if (x(t), f !== void 0 && x(f), r && x(r.color), !Number.isSafeInteger(o) || o < 1) throw new RangeError("Scale must be a positive integer");
40
+ const a = r?.dx ?? 1, s = r?.dy ?? 2;
41
+ if (!Number.isSafeInteger(a) || !Number.isSafeInteger(s)) throw new RangeError("Shadow offsets must be integers");
42
+ const y = typeof e == "string" ? e.replaceAll(`\r
43
+ `, `
44
+ `).split(`
45
+ `).map(G) : [e], R = Math.max(...y.map((h) => h.length));
46
+ if (!R) return { width: 0, height: 0, pixels: new Uint8Array(), originX: 0, originY: 0 };
47
+ const S = n === "cp437" ? 8 : 3, C = n === "cp437" ? 8 : 5, A = n === "cp437" ? 8 : 4, p = f === void 0 ? 0 : 1, E = Math.min(-p, r ? a : 0), I = Math.min(-p, r ? s : 0), _ = Math.max(p, r ? a : 0), v = Math.max(p, r ? s : 0), m = ((R - 1) * A + S) * o + _ - E, w = ((y.length - 1) * (C + 1) + C) * o + v - I, u = new N(m, w, 255);
48
+ y.forEach(
49
+ (h, c) => h.forEach((l, g) => {
50
+ H(l, n).forEach((U, O) => {
51
+ for (let b = 0; b < S; b++)
52
+ U & 1 << b && u.rect((g * A + b) * o - E, (c * (C + 1) + O) * o - I, o, o, t);
53
+ });
54
+ })
55
+ );
56
+ const d = new N(m, w, 255);
57
+ if (r && d.blit(F(u, r.color, a, s), 0, 0, 255), f !== void 0) {
58
+ for (let h = 0; h < w; h++)
59
+ for (let c = 0; c < m; c++)
60
+ if (u.get(c, h) !== 255) for (let l = -1; l <= 1; l++) for (let g = -1; g <= 1; g++) d.set(c + g, h + l, f);
61
+ }
62
+ return d.blit(u, 0, 0, 255), { width: m, height: w, pixels: d.px, originX: -E, originY: -I };
63
+ }
64
+ export {
65
+ z as FONT_CP437,
66
+ k as MICRO_GLYPHS,
67
+ Y as MICRO_SQUARE_GLYPHS,
68
+ F as dropShadow,
69
+ G as encodeText,
70
+ D as fromCp437,
71
+ H as glyphRows,
72
+ Q as renderText,
73
+ J as toCp437
74
+ };
@@ -0,0 +1,4 @@
1
+ export * from './music/compose.js';
2
+ export * from './kit/tune.js';
3
+ export * from './kit/sound.js';
4
+ export * from './kit/synthParts.js';
@@ -0,0 +1,22 @@
1
+ export interface AudioFileOptions {
2
+ /** Output mono sample rate. Defaults to Game-Maker's usual 11025 Hz. */
3
+ sampleRate?: number;
4
+ /** Executable name or path; FFmpeg is installed separately, never bundled. */
5
+ ffmpegPath?: string;
6
+ /** Maximum decoded mono samples (default 16 MiB). Exceeding it fails, never truncates. */
7
+ maxSamples?: number;
8
+ /** Maximum conversion time, in milliseconds (default 30000). */
9
+ timeoutMs?: number;
10
+ }
11
+ export interface VocFileOptions extends Omit<AudioFileOptions, 'maxSamples'> {
12
+ /** Maximum total VOC bytes, including headers (default 65535, the DOS size limit). */
13
+ maxBytes?: number;
14
+ }
15
+ /**
16
+ * Decode FLAC, Ogg, WAV or another FFmpeg-supported file to mono samples for encodeVoc.
17
+ * The unsigned-byte mapping deliberately inverts encodeVoc, retaining all original PCM
18
+ * values when lossless sources are decoded at their own sample rate. Other rates resample.
19
+ */
20
+ export declare function decodeAudioFile(file: string | URL, options?: AudioFileOptions): Float32Array;
21
+ /** Convert source audio to a native mono, unsigned 8-bit VOC, enforcing DOS's size limit. */
22
+ export declare function audioFileToVoc(file: string | URL, options?: VocFileOptions): Uint8Array;
@@ -0,0 +1,4 @@
1
+ export declare function pcm8Wav(bytes: Uint8Array): {
2
+ samples: Uint8Array;
3
+ sampleRate: number;
4
+ } | undefined;
@@ -0,0 +1,24 @@
1
+ import { type Block } from '@lewismoten/gamemaker-sandbox-engine/formats/blocks';
2
+ import type { GameMap } from '@lewismoten/gamemaker-sandbox-engine/formats/map';
3
+ export interface BblMergeInput {
4
+ keep: Block[];
5
+ drop: Block[];
6
+ /** The dropped set's maps (every map its scenes open); each is renumbered. */
7
+ dropMaps: GameMap[];
8
+ /** Block numbers of the dropped set its maps draw, with everything those turn into. */
9
+ dropUsed: ReadonlySet<number>;
10
+ /** Numbers that must keep their number in the dropped set (pickups, required and starting inventory, 0). */
11
+ dropPinned: ReadonlySet<number>;
12
+ /** Slots of the kept set that are in use (drawn, linked to, or pinned): never given away even if they look blank. */
13
+ keepUsed: ReadonlySet<number>;
14
+ }
15
+ export interface BblMerge {
16
+ blocks: Block[];
17
+ maps: GameMap[];
18
+ /** Where each of the dropped set's drawn blocks is now. */
19
+ at: Map<number, number>;
20
+ /** The dropped blocks that moved into a slot of their own (the others reuse a twin). */
21
+ fresh: number[];
22
+ }
23
+ /** The merge, or why the two sets can't share one file. */
24
+ export declare function mergeBackgroundSets(input: BblMergeInput): BblMerge | string;
@@ -0,0 +1,23 @@
1
+ import type { Block } from '@lewismoten/gamemaker-sandbox-engine/formats/blocks';
2
+ export declare const FLAG_MEAN = 6;
3
+ export declare const FLAG_WORST = 20;
4
+ type Lab = [number, number, number];
5
+ /** CIELAB of palette color `i` (palette bytes are 6-bit VGA values). */
6
+ export declare function labOf(palette: Uint8Array, i: number): Lab;
7
+ export interface ReduceScore {
8
+ /** Mean delta E over the pixels that changed color, and over every pixel of the changed blocks. */
9
+ mean: number;
10
+ worst: number;
11
+ /** Blocks that passed a threshold. */
12
+ flagged: number[];
13
+ }
14
+ export interface ReduceResult {
15
+ /** Block number to its new pixels, only for blocks that changed. */
16
+ changed: Map<number, Uint8Array>;
17
+ /** Each color index that moved and where it went. */
18
+ moves: Map<number, number>;
19
+ score: ReduceScore;
20
+ }
21
+ /** The blocks `which` with every pixel outside `allowed` (and not 0 or 255) moved to the nearest allowed color in `palettes[0]`; scored under every palette. */
22
+ export declare function reduceBlocks(blocks: Block[], which: Iterable<number>, palettes: Uint8Array[], allowed: ReadonlySet<number>): ReduceResult;
23
+ export {};
@@ -0,0 +1,26 @@
1
+ export type RGB = readonly [number, number, number];
2
+ /** Hue in degrees, saturation and value in 0..1. */
3
+ export type HSV = readonly [number, number, number];
4
+ /** Convert eight-bit RGB to hue, saturation and value without changing the input. */
5
+ export declare function rgbToHsv(color: RGB): [number, number, number];
6
+ /** Convert HSV to rounded eight-bit RGB; hue wraps around at 360 degrees. */
7
+ export declare function hsvToRgb(color: HSV): [number, number, number];
8
+ export type TimeOfDay = 'morning' | 'noon' | 'afternoon' | 'sunset' | 'night' | 'show';
9
+ export interface Lighting {
10
+ readonly mul: RGB;
11
+ readonly add: RGB;
12
+ }
13
+ /** Eight-bit RGB lighting presets; show is warm stage lighting. */
14
+ export declare const TIME_OF_DAY_LIGHT: Readonly<Record<TimeOfDay, Lighting>>;
15
+ /** Eight-bit sky ramp endpoints and optional middle stop, dark to light. */
16
+ export declare const TIME_OF_DAY_SKY: Readonly<Record<TimeOfDay, readonly [RGB, RGB, RGB?]>>;
17
+ /** Light one eight-bit RGB color, rounding and clamping each component. */
18
+ export declare function lightColor(color: RGB, lighting: TimeOfDay | Lighting): [number, number, number];
19
+ /** A pure eight-bit RGB ramp, including both endpoints; a middle stop falls at t=0.5. */
20
+ export declare function colorRamp(count: number, from: RGB, to: RGB, mid?: RGB): [number, number, number][];
21
+ /**
22
+ * Light a native 768-byte, six-bit VGA palette, without changing pixel indexes or the input.
23
+ * Indexes 0 (engine clear color) and 255 (transparent) are preserved by default. Supply
24
+ * your own list to protect glowing ramps, designer colors, or to adjust every entry ([]).
25
+ */
26
+ export declare function adjustPalette(palette: Uint8Array, lighting: TimeOfDay | Lighting, preserve?: readonly number[]): Uint8Array;
@@ -0,0 +1,32 @@
1
+ export type FileState = Uint8Array;
2
+ /** A file in a delta: new whole, changed by patches, or gone. */
3
+ export type FileDelta = {
4
+ kind: 'new';
5
+ bytes: Uint8Array;
6
+ } | {
7
+ kind: 'bytes';
8
+ length: number;
9
+ patches: {
10
+ at: number;
11
+ bytes: Uint8Array;
12
+ }[];
13
+ } | {
14
+ kind: 'lines';
15
+ start: number;
16
+ remove: number;
17
+ add: string[];
18
+ } | {
19
+ kind: 'gone';
20
+ };
21
+ /** What changed between two versions of a game: only the files that differ. */
22
+ export type Delta = Record<string, FileDelta>;
23
+ /** The difference that turns `from` (undefined: no such file) into `to` (undefined: removed); undefined when they are the same. */
24
+ export declare function diffFile(name: string, from: FileState | undefined, to: FileState | undefined): FileDelta | undefined;
25
+ /** The file after a delta; undefined when it is gone. */
26
+ export declare function patchFile(from: FileState | undefined, d: FileDelta): FileState | undefined;
27
+ /** The delta between two whole versions (file name to bytes). */
28
+ export declare function diffVersions(from: ReadonlyMap<string, FileState>, to: ReadonlyMap<string, FileState>): Delta;
29
+ /** A version with a delta applied. */
30
+ export declare function applyDelta(from: ReadonlyMap<string, FileState>, delta: Delta): Map<string, FileState>;
31
+ /** Bytes a delta takes to store (patch bytes, new files, added lines), to show what a version costs. */
32
+ export declare function deltaSize(delta: Delta): number;