@sculptr/px608 0.0.0-stage → 1.1.1

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 (3) hide show
  1. package/README.md +2 -2
  2. package/dist/index.js +618 -0
  3. package/package.json +38 -4
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
- # Temporary Holding Version
1
+ # 608
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Gives back the pixels some games cut off the bottom of the screen (800x600 instead of 800x608).
package/dist/index.js ADDED
@@ -0,0 +1,618 @@
1
+ //#region node_modules/@sculptr/sdk/dist/index.js
2
+ var e = function(e) {
3
+ let { identity: t, hostApi: n, prefix: r, objects: i, internalReceive: a, internalCreate: o, normalizeEventName: s, context: c, queue: l, scratch: u } = e, d = /* @__PURE__ */ new Map();
4
+ for (let e of i) for (let n of Object.keys(e.receive ?? {})) {
5
+ let r = s(n), i = d.get(r);
6
+ if (i) throw Error(`mod ${t.id}: both ${i} and ${e.name} receive ${JSON.stringify(r)}. They would race for each message; give it to one of them.`);
7
+ d.set(r, e.name);
8
+ }
9
+ for (let e of Object.keys(a)) d.set(e, `${r}inbox`);
10
+ let f = (e, t) => `while (ds_list_size(${l(e)}) > 0) {
11
+ ${u("pl")} = ds_list_find_value(${l(e)}, 0);
12
+ ds_list_delete(${l(e)}, 0);
13
+ ${t}
14
+ }`;
15
+ if (d.size > 0) {
16
+ let e = [...d.keys()], t = e.map((e, t) => `${t === 0 ? "if" : "else if"} (${u("ev")} == "${e}") ds_list_add(${l(e)}, ${u("pl")});`).join("\n"), i = Object.entries(a).map(([e, t]) => f(e, t)).join("\n");
17
+ n.resource.create({
18
+ kind: "object",
19
+ name: `${r}inbox`,
20
+ persistent: !0,
21
+ visible: !1,
22
+ depth: 0,
23
+ events: {
24
+ create: e.map((e) => `${l(e)} = ds_list_create();`).join("\n") + o,
25
+ step: i || void 0,
26
+ beginStep: `${n.gml.receive(u("m"))}
27
+ while (${u("m")} != "") {
28
+ ${u("at")} = string_pos(" ", ${u("m")});
29
+ if (${u("at")} > 1) {
30
+ ${u("ev")} = string_copy(${u("m")}, 1, ${u("at")} - 1);
31
+ ${u("pl")} = string_delete(${u("m")}, 1, ${u("at")});
32
+ ${t}
33
+ }
34
+ ${n.gml.receive(u("m"))}
35
+ }`
36
+ }
37
+ });
38
+ }
39
+ for (let e of i) {
40
+ let t = (t) => t?.(c(e)), i = [Object.entries(e.receive ?? {}).map(([t, n]) => f(s(t), n({
41
+ ...c(e),
42
+ payload: u("pl")
43
+ }))).join("\n"), t(e.events?.step)].filter(Boolean).join("\n"), a = {};
44
+ for (let [n, r] of [
45
+ ["create", t(e.events?.create)],
46
+ ["beginStep", t(e.events?.beginStep)],
47
+ ["step", i || void 0],
48
+ ["endStep", t(e.events?.endStep)],
49
+ ["draw", t(e.events?.draw)],
50
+ ["destroy", t(e.events?.destroy)]
51
+ ]) r && (a[n] = r);
52
+ n.resource.create({
53
+ kind: "object",
54
+ name: `${r}o_${e.name}`,
55
+ depth: e.depth,
56
+ persistent: e.persistent,
57
+ visible: e.visible,
58
+ events: a
59
+ });
60
+ }
61
+ }, t = function(e) {
62
+ let t = -1, n = (e) => {
63
+ switch (e.k) {
64
+ case "arg":
65
+ e.index !== null && e.index < 16 && (t = Math.max(t, e.index));
66
+ break;
67
+ case "field":
68
+ n(e.of);
69
+ break;
70
+ case "index":
71
+ n(e.of), e.at.forEach(n);
72
+ break;
73
+ case "op":
74
+ e.args.forEach(n);
75
+ break;
76
+ case "call": e.args.forEach(n);
77
+ }
78
+ }, r = (e) => {
79
+ for (let t of e) t.k === "assign" ? (n(t.target), n(t.value)) : t.k === "call" ? n(t.call) : t.k === "if" ? (n(t.cond), r(t.then), r(t.else)) : t.k === "with" ? (n(t.target), r(t.body)) : t.k === "loop" ? r(t.body) : t.k === "switch" ? (n(t.value), t.bodies.forEach(r)) : t.k === "exit" && t.value && n(t.value);
80
+ };
81
+ return r(e), t;
82
+ }, n = /^[A-Za-z][A-Za-z0-9_-]*$/u, r = /^[A-Za-z][A-Za-z0-9_]*$/u, i = /^[A-Za-z0-9_.-]+$/u, a = function(e) {
83
+ e.hooks.forEach(({ script: n, wrap: r }, i) => {
84
+ let a = `${e.prefix}__orig${i}_${n}`, o = t(e.content.scripts.find((e) => e.name === n)?.body ?? []) + 1, s = `${e.prefix}__fwd${i}`, c = `global.${e.prefix}__hc${i}`, l = `global.${e.prefix}__ha${i}`, u = `global.${e.prefix}__hi${i}`, d = Array.from({ length: 17 }, (e, t) => {
85
+ let n = Array.from({ length: t }, (e, t) => `${l}[${t}]`).join(", ");
86
+ return ` case ${t}: return ${a}(${n});`;
87
+ }).join("\n");
88
+ e.hostApi.resource.create({
89
+ kind: "script",
90
+ name: s,
91
+ source: `switch (${c}) {\n${d}\n}\nreturn 0;`
92
+ });
93
+ let f = r({
94
+ engine: e.hostApi.target.engine,
95
+ original: {
96
+ call: (...e) => e.length === 0 ? `${s}()` : `${a}(${e.join(", ")})`,
97
+ arg: (e) => e >= 0 && e < 16 ? `argument${e}` : `argument[${e}]`,
98
+ argumentCount: "argument_count"
99
+ },
100
+ send: e.send,
101
+ call: e.call
102
+ });
103
+ e.hostApi.resource.create({
104
+ kind: "hook",
105
+ script: n,
106
+ original: a,
107
+ source: `
108
+ ${c} = argument_count;
109
+ ${u} = 0;
110
+ while (${u} < argument_count) {
111
+ ${l}[${u}] = argument[${u}];
112
+ ${u} += 1;
113
+ }
114
+ ${o > 0 ? `if (0) { ${l}[${o - 1}] = argument${o - 1}; }\n` : ""}${f}`
115
+ });
116
+ });
117
+ };
118
+ function o(e) {
119
+ switch (e.k) {
120
+ case "assign": return e.target.k === "var" ? `an assignment to ${e.target.name}` : "an assignment";
121
+ case "call": return `a call to ${e.call.name}`;
122
+ case "exit": return e.value ? "a return" : "an exit";
123
+ default: return `a ${e.k} statement`;
124
+ }
125
+ }
126
+ function s(e, t) {
127
+ let n = t.at.at;
128
+ if (n === void 0) throw Error(`mod ${e}: cannot insert at ${o(t.at)} -- this game's engine could not place it, so there is nothing to insert around. Statements without a place include the parts of a \`for\` header and temporaries a decompiler invented.`);
129
+ if (t.place !== "before" && t.place !== "after" && t.place !== "instead") throw Error(`mod ${e}: an insertion's place is "before", "after" or "instead", not ${JSON.stringify(t.place)}`);
130
+ if (t.place === "after" && t.at.k === "exit") throw Error(`mod ${e}: nothing follows ${o(t.at)}, so there is no "after" to insert at. Use "before" to run something on the way out.`);
131
+ return n;
132
+ }
133
+ var c = function(e) {
134
+ let t = /* @__PURE__ */ new Map();
135
+ for (let n of e.inserts) {
136
+ let r = n.body({
137
+ engine: e.hostApi.target.engine,
138
+ send: e.send,
139
+ call: e.call
140
+ }), i = t.get(r);
141
+ i === void 0 && (i = `${e.prefix}__ins${t.size}`, t.set(r, i), e.hostApi.resource.create({
142
+ kind: "script",
143
+ name: i,
144
+ source: r
145
+ })), e.hostApi.resource.create({
146
+ kind: "insert",
147
+ at: n.at,
148
+ place: n.place,
149
+ call: i
150
+ });
151
+ }
152
+ }, l = function(e) {
153
+ for (let t of e.scripts) {
154
+ let n = {};
155
+ (t.args ?? []).forEach((i, a) => {
156
+ if (!r.test(i)) throw Error(`mod ${e.identity.id}: script ${JSON.stringify(t.name)} has an argument called ${JSON.stringify(i)}, which is not a usable name`);
157
+ n[i] = `argument${a}`;
158
+ }), e.hostApi.resource.create({
159
+ kind: "script",
160
+ name: `${e.prefix}s_${t.name}`,
161
+ source: t.body({
162
+ engine: e.hostApi.target.engine,
163
+ a: n,
164
+ send: e.send,
165
+ call: e.call
166
+ })
167
+ });
168
+ }
169
+ }, u = 15e3, d = 2e3, f = (e) => e[0] === 137 && e[1] === 80 ? {
170
+ extension: "png",
171
+ type: "image/png"
172
+ } : e[0] === 255 && e[1] === 216 ? {
173
+ extension: "jpg",
174
+ type: "image/jpeg"
175
+ } : e[0] === 66 && e[1] === 77 ? {
176
+ extension: "bmp",
177
+ type: "image/bmp"
178
+ } : null, p = class extends Error {
179
+ constructor() {
180
+ super("superseded by a newer load after the game restarted");
181
+ }
182
+ }, m = async function(e) {
183
+ if (typeof e != "string") return e instanceof Uint8Array ? e : new Uint8Array(e);
184
+ if (e.startsWith("data:")) {
185
+ let t = e.indexOf(",");
186
+ if (t < 0) throw Error("that data: URI has no comma in it");
187
+ let n = e.slice(0, t), r = e.slice(t + 1);
188
+ if (!n.endsWith(";base64")) return new TextEncoder().encode(decodeURIComponent(r));
189
+ let i = atob(r), a = new Uint8Array(i.length);
190
+ for (let e = 0; e < i.length; e += 1) a[e] = i.charCodeAt(e);
191
+ return a;
192
+ }
193
+ let t = await fetch(e, { cache: "no-store" });
194
+ if (!t.ok) throw Error(`${e}: ${t.status}`);
195
+ return new Uint8Array(await t.arrayBuffer());
196
+ }, h = async function(e, t) {
197
+ if (typeof OffscreenCanvas == "function" && typeof createImageBitmap == "function") {
198
+ let n = await Promise.all(e.map((e, t) => {
199
+ let n = f(e);
200
+ if (!n) throw Error(`frame ${t + 1} is not a PNG, JPEG or BMP`);
201
+ return createImageBitmap(new Blob([e], { type: n.type }));
202
+ })), r = n[0];
203
+ for (let [e, t] of n.entries()) if (t.width !== r.width || t.height !== r.height) throw Error(`frame ${e + 1} is ${t.width}x${t.height} but frame 1 is ${r.width}x${r.height}; every frame of a sprite is the same size`);
204
+ let i = t ? Math.min(1, t / Math.max(r.width, r.height)) : 1, a = Math.max(1, Math.round(r.width * i)), o = Math.max(1, Math.round(r.height * i)), s = new OffscreenCanvas(a * n.length, o), c = s.getContext("2d");
205
+ return n.forEach((e, t) => {
206
+ c.drawImage(e, t * a, 0, a, o), e.close();
207
+ }), new Uint8Array(await (await s.convertToBlob({ type: "image/png" })).arrayBuffer());
208
+ }
209
+ throw Error("this host has no canvas to compose a sprite strip with");
210
+ }, g = async function(e, t, n) {
211
+ if (typeof OffscreenCanvas == "function" && typeof createImageBitmap == "function") {
212
+ let r = await createImageBitmap(new Blob([e], { type: t })), i = n ? Math.min(1, n / Math.max(r.width, r.height)) : 1, a = Math.max(1, Math.round(r.width * i)), o = Math.max(1, Math.round(r.height * i)), s = new OffscreenCanvas(a, o);
213
+ return s.getContext("2d").drawImage(r, 0, 0, a, o), r.close(), new Uint8Array(await (await s.convertToBlob({ type: "image/png" })).arrayBuffer());
214
+ }
215
+ throw Error("this host has no canvas to re-encode a picture with");
216
+ }, _ = (e) => e === "gm8" ? "temp_directory + \"\\\"" : "game_save_id", v = {
217
+ put: "__spr_put",
218
+ ok: "__spr_ok",
219
+ failed: "__spr_failed",
220
+ hello: "__spr_hello",
221
+ where: "__spr_where"
222
+ }, y = function(e) {
223
+ let t = null, n = "", r, i = new Promise((e) => {
224
+ r = e;
225
+ }), a = Promise.resolve(), o = new Promise((t) => {
226
+ e.hostApi.on("start", t);
227
+ }), s = async function(t, n) {
228
+ let r = Array.isArray(t) ? t : [t];
229
+ if (r.length === 0) throw Error("there is no picture in that list");
230
+ let i = await Promise.all(r.map((e) => m(e))), a = n.frames ?? 1;
231
+ if (i.length > 1) return {
232
+ bytes: await h(i, n.maxSize),
233
+ extension: "png",
234
+ frames: i.length * a
235
+ };
236
+ let o = i[0], s = f(o);
237
+ if (!s) throw Error("those bytes are not a PNG, JPEG or BMP");
238
+ let c = e.hostApi.target.engine === "gms" && s.extension !== "png", l = n.maxSize !== void 0;
239
+ return !c && !l ? {
240
+ bytes: o,
241
+ extension: s.extension,
242
+ frames: a
243
+ } : {
244
+ bytes: await g(o, s.type, n.maxSize),
245
+ extension: "png",
246
+ frames: a
247
+ };
248
+ }, c = function(n, r, i, a) {
249
+ return new Promise((o, s) => {
250
+ let c = (e, n) => {
251
+ clearTimeout(d), t = null, e ? s(e) : o(n);
252
+ };
253
+ t = {
254
+ slot: n,
255
+ done: (e) => c(null, e),
256
+ failed: (e) => c(Error(e)),
257
+ abandon: () => c(new p())
258
+ };
259
+ let l = r.origin ?? {
260
+ x: 0,
261
+ y: 0
262
+ };
263
+ e.sendInternal(v.put, `${n} ${i} ${l.x} ${l.y} ${a}`);
264
+ let d = setTimeout(() => c(/* @__PURE__ */ Error(`the game never answered about ${a}`)), u);
265
+ });
266
+ };
267
+ return {
268
+ loadSprite: function(t, r, l, u = () => !0) {
269
+ let f = async () => {
270
+ let a = await s(l, r);
271
+ if (await o, await Promise.race([i, new Promise((e) => {
272
+ setTimeout(e, d);
273
+ })]), !u()) throw new p();
274
+ let f = await e.hostApi.files.write(`${t}.${a.extension}`, a.bytes, n);
275
+ if (!u()) throw new p();
276
+ return c(t, r, a.frames, f);
277
+ }, m = a.then(f, f);
278
+ return a = m.catch(() => {}), m;
279
+ },
280
+ where: (e) => {
281
+ n = e, r();
282
+ },
283
+ done: (e, n) => {
284
+ t?.slot === e && t.done(n);
285
+ },
286
+ failed: (e, n) => {
287
+ t?.slot === e && t.failed(n);
288
+ },
289
+ abandon: () => t?.abandon()
290
+ };
291
+ }, b = function(e) {
292
+ let { hostApi: t, prefix: n, sprites: r, payload: i, sendInternalGml: a } = e;
293
+ if (r.length === 0) return {};
294
+ let o = (e) => `global.${n}__${e}`, s = `${n}__sprfield`, c = `${n}__sprrest`;
295
+ t.resource.create({
296
+ kind: "script",
297
+ name: s,
298
+ source: `${o("fs")} = argument0;
299
+ ${o("fn")} = 1;
300
+ while (${o("fn")} < argument1) {
301
+ ${o("fat")} = string_pos(" ", ${o("fs")});
302
+ if (${o("fat")} == 0) return "";
303
+ ${o("fs")} = string_delete(${o("fs")}, 1, ${o("fat")});
304
+ ${o("fn")} += 1;
305
+ }
306
+ ${o("fat")} = string_pos(" ", ${o("fs")});
307
+ if (${o("fat")} > 0) ${o("fs")} = string_copy(${o("fs")}, 1, ${o("fat")} - 1);
308
+ return ${o("fs")};`
309
+ }), t.resource.create({
310
+ kind: "script",
311
+ name: c,
312
+ source: `${o("rs")} = argument0;
313
+ ${o("rn")} = 1;
314
+ while (${o("rn")} < argument1) {
315
+ ${o("rat")} = string_pos(" ", ${o("rs")});
316
+ if (${o("rat")} == 0) return "";
317
+ ${o("rs")} = string_delete(${o("rs")}, 1, ${o("rat")});
318
+ ${o("rn")} += 1;
319
+ }
320
+ return ${o("rs")};`
321
+ });
322
+ let l = t.target.engine === "gm8" ? `if (!file_exists(${o("sprfile")})) {
323
+ ${a(v.failed, `${o("sprslot")} + " nothing at " + ${o("sprfile")}`)}
324
+ exit;
325
+ }` : "", u = r.map(({ name: e }) => `if (${o("sprslot")} == "${e}") {
326
+ if (is_real(global.${n}spr_${e}) && global.${n}spr_${e} >= 0) sprite_delete(global.${n}spr_${e});
327
+ global.${n}spr_${e} = ${o("sprnew")};
328
+ }`).join(" else ");
329
+ return { [v.put]: `${o("sprslot")} = ${s}(${i}, 1);
330
+ ${o("sprimgs")} = real(${s}(${i}, 2));
331
+ ${o("sprox")} = real(${s}(${i}, 3));
332
+ ${o("sproy")} = real(${s}(${i}, 4));
333
+ ${o("sprfile")} = ${c}(${i}, 5);
334
+ ${l}
335
+ // is_real first: a game script named sprite_add shadows the builtin.
336
+ ${o("sprnew")} = sprite_add(${o("sprfile")}, ${o("sprimgs")}, false, false, ${o("sprox")}, ${o("sproy")});
337
+ if (is_real(${o("sprnew")}) && ${o("sprnew")} >= 0) {
338
+ ${u}
339
+ ${a(v.ok, `${o("sprslot")} + " " + string(sprite_get_width(${o("sprnew")})) + " " + string(sprite_get_height(${o("sprnew")}))`)}
340
+ } else {
341
+ ${a(v.failed, `${o("sprslot")} + " sprite_add answered " + string(${o("sprnew")})`)}
342
+ }` };
343
+ }, x = function(e) {
344
+ let { engine: t, prefix: n, sprites: r, sendInternalGml: i } = e;
345
+ return r.length === 0 ? "" : `
346
+ ${r.map(({ name: e }) => `global.${n}spr_${e} = -1;`).join("\n")}
347
+ ${i(v.where, _(t))}
348
+ ${i(v.hello)}`;
349
+ }, S = function(e) {
350
+ let { identity: t, sprites: n, shown: r, spriteLoader: i, handlers: a } = e;
351
+ if (n.length === 0) return;
352
+ a.set(v.where, [(e) => i.where(e)]);
353
+ let o = 0;
354
+ a.set(v.hello, [() => {
355
+ if (o += 1, o === 1 || r.size === 0) return;
356
+ i.abandon();
357
+ let e = o, a = () => e === o;
358
+ for (let [e, o] of r) {
359
+ let r = n.find((t) => t.name === e)?.options ?? {};
360
+ i.loadSprite(e, r, o, a).catch((n) => {
361
+ n instanceof p || console.error(`[${t.id}] sprite ${JSON.stringify(e)} is gone:`, n);
362
+ });
363
+ }
364
+ }]), a.set(v.ok, [(e) => {
365
+ let [t, n, r] = e.split(" ");
366
+ i.done(t ?? "", {
367
+ width: Number(n),
368
+ height: Number(r)
369
+ });
370
+ }]), a.set(v.failed, [(e) => {
371
+ let t = e.indexOf(" ");
372
+ i.failed(t < 0 ? e : e.slice(0, t), t < 0 ? "the game refused the picture" : e.slice(t + 1));
373
+ }]);
374
+ }, C = function(e) {
375
+ let t = (e.split(/[/.]/u).pop() ?? e).replaceAll(/[^A-Za-z0-9]/gu, "").slice(0, 12), n = 2166136261;
376
+ for (let t = 0; t < e.length; t += 1) n = Math.imul(n ^ e.charCodeAt(t), 16777619);
377
+ return `m${t}_${((n >>> 0) % 65536).toString(16).padStart(4, "0")}_`;
378
+ }, w = function(t) {
379
+ return { activate(o) {
380
+ let u = o.identity, d = C(u.id), f = [], p = [], m = [], h = [], g = [], _ = /* @__PURE__ */ new Map(), v = !0, w = (e) => {
381
+ if (!n.test(e)) throw Error(`mod ${u.id}: ${JSON.stringify(e)} is not a usable event name (letters, digits, - and _, starting with a letter)`);
382
+ return e.replaceAll("-", "_");
383
+ }, T = (e) => `${d}__${e}`, E = (e) => {
384
+ let t = {};
385
+ for (let n of e.vars ?? []) {
386
+ if (!r.test(n)) throw Error(`mod ${u.id}: ${JSON.stringify(n)} is not a usable variable name (letters, digits and _, starting with a letter)`);
387
+ t[n] = `${d}v_${n}`;
388
+ }
389
+ return t;
390
+ }, D = (e) => `global.${d}q_${e}`, O = (e, t = "") => o.send(`${e} ${t}`), k = (e, t) => o.gml.send(t ? `"${e} " + (${t})` : `"${e} "`), A = (e, t) => k(w(e), t), j = (e, ...t) => {
391
+ if (!p.some((t) => t.name === e)) throw Error(`mod ${u.id}: call(${JSON.stringify(e)}) names a script this mod never declared. It has: ${p.map((e) => e.name).join(", ") || "none"}`);
392
+ return `${d}s_${e}(${t.join(", ")})`;
393
+ }, M = (e) => ({
394
+ engine: o.target.engine,
395
+ v: E(e),
396
+ send: A,
397
+ call: j
398
+ }), N = y({
399
+ hostApi: o,
400
+ identity: u,
401
+ sendInternal: O
402
+ }), P = /* @__PURE__ */ new Map(), F = o.game;
403
+ t({
404
+ engine: o.target.engine,
405
+ call: j,
406
+ ui: o.ui,
407
+ getPlayer: () => o.getPlayer(),
408
+ onPlayerChange: (e) => o.on("player", e),
409
+ content: F,
410
+ resource: {
411
+ object: { create(e) {
412
+ if (!v) throw Error(`mod ${u.id}: objects can only be declared while the mod is built`);
413
+ f.push(e);
414
+ } },
415
+ script: {
416
+ create(e) {
417
+ if (!v) throw Error(`mod ${u.id}: scripts can only be declared while the mod is built`);
418
+ if (!r.test(e.name)) throw Error(`mod ${u.id}: ${JSON.stringify(e.name)} is not a usable script name (letters, digits and _, starting with a letter)`);
419
+ if (p.some((t) => t.name === e.name)) throw Error(`mod ${u.id}: two scripts are called ${JSON.stringify(e.name)}`);
420
+ p.push(e);
421
+ },
422
+ hook(e, t) {
423
+ if (!v) throw Error(`mod ${u.id}: hooks can only be declared while the mod is built`);
424
+ h.push({
425
+ script: e,
426
+ wrap: t
427
+ });
428
+ },
429
+ insert(e) {
430
+ if (!v) throw Error(`mod ${u.id}: insertions can only be declared while the mod is built`);
431
+ g.push({
432
+ at: s(u.id, e),
433
+ place: e.place,
434
+ body: e.body
435
+ });
436
+ }
437
+ },
438
+ sprite: { create(e, t = {}) {
439
+ if (!v) throw Error(`mod ${u.id}: sprites can only be declared while the mod is built`);
440
+ if (!r.test(e)) throw Error(`mod ${u.id}: ${JSON.stringify(e)} is not a usable sprite name (letters, digits and _, starting with a letter)`);
441
+ if (m.some((t) => t.name === e)) throw Error(`mod ${u.id}: two sprites are called ${JSON.stringify(e)}`);
442
+ return m.push({
443
+ name: e,
444
+ options: t
445
+ }), {
446
+ id: `global.${d}spr_${e}`,
447
+ load: (n) => (P.set(e, n), N.loadSprite(e, t, n))
448
+ };
449
+ } }
450
+ },
451
+ on(e, t) {
452
+ let n = w(e), r = _.get(n);
453
+ r ? r.push(t) : _.set(n, [t]);
454
+ },
455
+ onStart(e) {
456
+ o.on("start", e);
457
+ },
458
+ scratchPath(e) {
459
+ if (!i.test(e)) throw Error(`mod ${u.id}: ${JSON.stringify(e)} is not a usable scratch file name (letters, digits, _ . and -)`);
460
+ return o.target.engine === "gm8" ? `temp_directory + "\\${d}${e}"` : `"${d}${e}"`;
461
+ },
462
+ send(e, t = "") {
463
+ o.send(`${w(e)} ${t}`);
464
+ }
465
+ }), v = !1, c({
466
+ identity: u,
467
+ inserts: g,
468
+ prefix: d,
469
+ hostApi: o,
470
+ send: A,
471
+ call: j
472
+ }), l({
473
+ identity: u,
474
+ scripts: p,
475
+ hostApi: o,
476
+ prefix: d,
477
+ send: A,
478
+ call: j
479
+ }), a({
480
+ identity: u,
481
+ hooks: h,
482
+ content: F,
483
+ hostApi: o,
484
+ prefix: d,
485
+ send: A,
486
+ call: j
487
+ }), e({
488
+ identity: u,
489
+ hostApi: o,
490
+ prefix: d,
491
+ objects: f,
492
+ internalReceive: b({
493
+ hostApi: o,
494
+ prefix: d,
495
+ sprites: m,
496
+ payload: T("pl"),
497
+ sendInternalGml: k
498
+ }),
499
+ internalCreate: x({
500
+ engine: o.target.engine,
501
+ prefix: d,
502
+ sprites: m,
503
+ sendInternalGml: k
504
+ }),
505
+ normalizeEventName: w,
506
+ context: M,
507
+ queue: D,
508
+ scratch: T
509
+ }), S({
510
+ identity: u,
511
+ sprites: m,
512
+ shown: P,
513
+ spriteLoader: N,
514
+ handlers: _
515
+ }), o.on("message", (e) => {
516
+ let t = e.indexOf(" "), n = t < 0 ? e : e.slice(0, t), r = t < 0 ? "" : e.slice(t + 1), i = _.get(n);
517
+ if (i) for (let e of i) new Promise((t) => {
518
+ t(e(r));
519
+ }).catch((e) => {
520
+ console.error(`[${u.id}] handling ${n} failed:`, e);
521
+ });
522
+ });
523
+ } };
524
+ }, T = 32, E = 8, D = w((e) => {
525
+ if (e.engine !== "gm8") {
526
+ console.warn("[608] only GameMaker 8 games are supported");
527
+ return;
528
+ }
529
+ let t = (e) => `((${e} + ${T} - 1) div ${T}) * ${T}`;
530
+ e.resource.object.create({
531
+ name: "fit",
532
+ vars: ["sent"],
533
+ events: {
534
+ create: ({ v: e }) => `${e.sent} = "";`,
535
+ beginStep: ({ v: e, send: n }) => `
536
+ var vf_i, vf_grew, vf_was_w, vf_was_h, vf_w, vf_h, vf_rw, vf_rh, vf_ww, vf_wh, vf_msg;
537
+
538
+ vf_grew = 0;
539
+ vf_was_w = 0;
540
+ vf_was_h = 0;
541
+ vf_w = 0;
542
+ vf_h = 0;
543
+
544
+ if (!view_enabled) {
545
+ // The region is the room. Nothing to round up means nothing to do -- and in particular no
546
+ // view where the game asked for none.
547
+ vf_w = ${t("room_width")};
548
+ vf_h = ${t("room_height")};
549
+ if (vf_w == room_width && vf_h == room_height) exit;
550
+
551
+ // The other seven first: see the comment at the top about writes past the end.
552
+ for (vf_i = 1; vf_i < ${E}; vf_i += 1) view_visible[vf_i] = 0;
553
+
554
+ // Every field, because what is stored in a view the room never used is stale.
555
+ view_xview[0] = 0;
556
+ view_yview[0] = 0;
557
+ view_wview[0] = vf_w;
558
+ view_hview[0] = vf_h;
559
+ view_xport[0] = 0;
560
+ view_yport[0] = 0;
561
+ view_wport[0] = vf_w;
562
+ view_hport[0] = vf_h;
563
+ view_angle[0] = 0;
564
+ view_object[0] = -1;
565
+ view_visible[0] = 1;
566
+ view_enabled = 1;
567
+
568
+ vf_was_w = room_width;
569
+ vf_was_h = room_height;
570
+ vf_grew = 1;
571
+ } else {
572
+ for (vf_i = 0; vf_i < ${E}; vf_i += 1) {
573
+ if (view_visible[vf_i]) {
574
+ vf_was_w = max(vf_was_w, view_xport[vf_i] + view_wport[vf_i]);
575
+ vf_was_h = max(vf_was_h, view_yport[vf_i] + view_hport[vf_i]);
576
+ if (view_wview[vf_i] == view_wport[vf_i] && (view_wview[vf_i] mod ${T}) != 0) {
577
+ view_wview[vf_i] = ${t("view_wview[vf_i]")};
578
+ view_wport[vf_i] = view_wview[vf_i];
579
+ vf_grew = 1;
580
+ }
581
+ if (view_hview[vf_i] == view_hport[vf_i] && (view_hview[vf_i] mod ${T}) != 0) {
582
+ view_hview[vf_i] = ${t("view_hview[vf_i]")};
583
+ view_hport[vf_i] = view_hview[vf_i];
584
+ vf_grew = 1;
585
+ }
586
+ vf_w = max(vf_w, view_xport[vf_i] + view_wport[vf_i]);
587
+ vf_h = max(vf_h, view_yport[vf_i] + view_hport[vf_i]);
588
+ }
589
+ }
590
+ if (!vf_grew) exit;
591
+ }
592
+
593
+ vf_rw = window_get_region_width();
594
+ vf_rh = window_get_region_height();
595
+ if (vf_rw != vf_w || vf_rh != vf_h) {
596
+ vf_ww = window_get_width();
597
+ vf_wh = window_get_height();
598
+ window_set_region_size(vf_w, vf_h, true);
599
+ // Only when the window *was* the region. Anywhere else -- a fixed scale, fullscreen on an
600
+ // installed copy -- the two differ on purpose and the engine scales between them.
601
+ if (vf_ww == vf_rw && vf_wh == vf_rh) window_set_size(vf_w, vf_h);
602
+ }
603
+
604
+ vf_msg = string(vf_was_w) + "x" + string(vf_was_h)
605
+ + " " + string(vf_w) + "x" + string(vf_h);
606
+ if (vf_msg != ${e.sent}) {
607
+ ${e.sent} = vf_msg;
608
+ ${n("grew", "vf_msg")}
609
+ }
610
+ `
611
+ }
612
+ }), e.on("grew", (e) => {
613
+ let [t, n] = e.split(" ");
614
+ console.log(`[608] ${t} -> ${n}`);
615
+ });
616
+ });
617
+ //#endregion
618
+ export { D as default };
package/package.json CHANGED
@@ -1,6 +1,40 @@
1
1
  {
2
2
  "name": "@sculptr/px608",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.1.1",
4
+ "displayName": "608",
5
+ "description": "Give back the pixels some games cut off the bottom of the screen",
6
+ "keywords": [
7
+ "gamemaker",
8
+ "mod",
9
+ "sculptr"
10
+ ],
11
+ "homepage": "https://github.com/QuentinJanuel/sculptr-608#readme",
12
+ "bugs": "https://github.com/QuentinJanuel/sculptr-608/issues",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/QuentinJanuel/sculptr-608.git"
16
+ },
17
+ "type": "module",
18
+ "main": "dist/index.js",
19
+ "scripts": {
20
+ "dev": "concurrently -k \"vite build --watch\" \"vite preview\"",
21
+ "build": "vite build",
22
+ "typecheck": "tsc --noEmit",
23
+ "prepublishOnly": "vite build"
24
+ },
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "devDependencies": {
32
+ "@types/node": "^24.13.4",
33
+ "concurrently": "^10.0.5",
34
+ "typescript": "^7.0.2",
35
+ "vite": "^8.3.0"
36
+ },
37
+ "dependencies": {
38
+ "@sculptr/sdk": "^2.16.0"
39
+ }
40
+ }