@lewismoten/gamemaker-sandbox-engine 3.1.0 → 3.3.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 (108) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/NOTICE.md +58 -753
  3. package/README.md +94 -10
  4. package/dist/assets/{music.worklet-NqOeNo6T.js → music.worklet-aD2x7RRM.js} +23 -21
  5. package/dist/audio/cmfLoad.js +10 -0
  6. package/dist/audio/cmfPlayer.js +201 -0
  7. package/dist/audio/context.js +75 -0
  8. package/dist/audio/engine.js +173 -0
  9. package/dist/audio/mix.js +40 -0
  10. package/dist/audio/opl.js +245 -0
  11. package/dist/audio/output.js +40 -0
  12. package/dist/core/gameFiles.js +89 -0
  13. package/dist/engine/character.js +187 -0
  14. package/dist/engine/funcKeys.js +164 -0
  15. package/dist/engine/game.js +133 -0
  16. package/dist/engine/keys.js +68 -0
  17. package/dist/engine/machine.js +192 -0
  18. package/dist/engine/menus.js +135 -0
  19. package/dist/engine/monsters.js +259 -0
  20. package/dist/engine/playGain.js +10 -0
  21. package/dist/engine/playerLook.js +48 -0
  22. package/dist/engine/recorder.js +127 -0
  23. package/dist/engine/render.js +45 -0
  24. package/dist/engine/scene.js +324 -0
  25. package/dist/engine/scroll.js +79 -0
  26. package/dist/engine/showGraphic.js +107 -0
  27. package/dist/engine/slowPc.js +98 -0
  28. package/dist/engine/slowPcMusic.js +46 -0
  29. package/dist/engine/touch.js +61 -0
  30. package/dist/engine/world.js +205 -0
  31. package/dist/formats/binary.js +120 -0
  32. package/dist/formats/blocks.js +103 -0
  33. package/dist/formats/character.js +83 -0
  34. package/dist/formats/cmf.js +37 -0
  35. package/dist/formats/cmfEdit.js +154 -0
  36. package/dist/formats/cmfPreview.js +89 -0
  37. package/dist/formats/cmfSong.js +190 -0
  38. package/dist/formats/fli.js +340 -0
  39. package/dist/formats/fliFrames.js +34 -0
  40. package/dist/formats/fliLimits.js +54 -0
  41. package/dist/formats/game.js +198 -0
  42. package/dist/formats/gif.js +125 -0
  43. package/dist/formats/gifProgressive.js +99 -0
  44. package/dist/formats/graphicScripts.js +44 -0
  45. package/dist/formats/highscore.js +30 -0
  46. package/dist/formats/jpeg.js +359 -0
  47. package/dist/formats/map.js +38 -0
  48. package/dist/formats/monster.js +69 -0
  49. package/dist/formats/palette.js +58 -0
  50. package/dist/formats/recording.js +17 -0
  51. package/dist/formats/sound.js +44 -0
  52. package/dist/formats/voc.js +303 -0
  53. package/dist/gfx/colorVision.js +45 -0
  54. package/dist/gfx/cp437Glyphs.js +337 -0
  55. package/dist/gfx/font8x8.js +10 -0
  56. package/dist/gfx/screen.js +151 -0
  57. package/dist/index.js +15 -0
  58. package/dist/input/chords.js +46 -0
  59. package/dist/input/deskMouse.js +24 -0
  60. package/dist/input/keyboard.js +82 -0
  61. package/dist/input/scancodes.js +143 -0
  62. package/dist/player/fileExtensions.js +118 -0
  63. package/dist/player/patchRules.js +129 -0
  64. package/dist/player/patchTable.js +1753 -0
  65. package/dist/text/cp437.js +44 -0
  66. package/dist/types/audio/cmfPlayer.d.ts +1 -1
  67. package/dist/types/audio/engine.d.ts +21 -0
  68. package/dist/types/audio/mix.d.ts +14 -0
  69. package/dist/types/audio/music.worklet.d.ts +8 -0
  70. package/dist/types/engine/character.d.ts +3 -3
  71. package/dist/types/engine/funcKeys.d.ts +8 -6
  72. package/dist/types/engine/game.d.ts +9 -4
  73. package/dist/types/engine/keys.d.ts +2 -2
  74. package/dist/types/engine/machine.d.ts +8 -4
  75. package/dist/types/engine/menus.d.ts +4 -4
  76. package/dist/types/engine/monsters.d.ts +1 -1
  77. package/dist/types/engine/playerLook.d.ts +20 -2
  78. package/dist/types/engine/recorder.d.ts +8 -1
  79. package/dist/types/engine/render.d.ts +2 -2
  80. package/dist/types/engine/scene.d.ts +41 -9
  81. package/dist/types/engine/scroll.d.ts +9 -1
  82. package/dist/types/engine/showGraphic.d.ts +2 -2
  83. package/dist/types/engine/slowPc.d.ts +64 -2
  84. package/dist/types/engine/slowPcMusic.d.ts +18 -0
  85. package/dist/types/engine/touch.d.ts +2 -2
  86. package/dist/types/engine/world.d.ts +28 -6
  87. package/dist/types/formats/cmfEdit.d.ts +53 -0
  88. package/dist/types/formats/cmfPreview.d.ts +19 -0
  89. package/dist/types/formats/cmfSong.d.ts +74 -0
  90. package/dist/types/formats/fli.d.ts +11 -0
  91. package/dist/types/formats/fliFrames.d.ts +18 -0
  92. package/dist/types/formats/fliLimits.d.ts +13 -0
  93. package/dist/types/formats/game.d.ts +7 -0
  94. package/dist/types/formats/gif.d.ts +1 -1
  95. package/dist/types/formats/gifProgressive.d.ts +46 -0
  96. package/dist/types/formats/jpeg.d.ts +20 -0
  97. package/dist/types/gfx/colorVision.d.ts +26 -0
  98. package/dist/types/gfx/screen.d.ts +4 -0
  99. package/dist/types/index.d.ts +4 -0
  100. package/dist/types/input/keyboard.d.ts +1 -1
  101. package/dist/types/{dosPlayer → player}/patchRules.d.ts +1 -1
  102. package/dist/types/{dosPlayer → player}/patchTable.d.ts +8 -5
  103. package/dist/types/text/cp437.d.ts +6 -0
  104. package/package.json +322 -9
  105. package/dist/engine.js +0 -5436
  106. package/dist/types/engine/package.d.ts +0 -4
  107. /package/dist/types/{project → core}/gameFiles.d.ts +0 -0
  108. /package/dist/types/{dosPlayer → player}/fileExtensions.d.ts +0 -0
@@ -0,0 +1,143 @@
1
+ const d = {
2
+ Escape: 1,
3
+ Digit1: 2,
4
+ Digit2: 3,
5
+ Digit3: 4,
6
+ Digit4: 5,
7
+ Digit5: 6,
8
+ Digit6: 7,
9
+ Digit7: 8,
10
+ Digit8: 9,
11
+ Digit9: 10,
12
+ Digit0: 11,
13
+ Minus: 12,
14
+ Equal: 13,
15
+ Backspace: 14,
16
+ Tab: 15,
17
+ KeyQ: 16,
18
+ KeyW: 17,
19
+ KeyE: 18,
20
+ KeyR: 19,
21
+ KeyT: 20,
22
+ KeyY: 21,
23
+ KeyU: 22,
24
+ KeyI: 23,
25
+ KeyO: 24,
26
+ KeyP: 25,
27
+ BracketLeft: 26,
28
+ BracketRight: 27,
29
+ Enter: 28,
30
+ NumpadEnter: 28,
31
+ ControlLeft: 29,
32
+ ControlRight: 29,
33
+ KeyA: 30,
34
+ KeyS: 31,
35
+ KeyD: 32,
36
+ KeyF: 33,
37
+ KeyG: 34,
38
+ KeyH: 35,
39
+ KeyJ: 36,
40
+ KeyK: 37,
41
+ KeyL: 38,
42
+ Semicolon: 39,
43
+ Quote: 40,
44
+ Backquote: 41,
45
+ ShiftLeft: 42,
46
+ Backslash: 43,
47
+ KeyZ: 44,
48
+ KeyX: 45,
49
+ KeyC: 46,
50
+ KeyV: 47,
51
+ KeyB: 48,
52
+ KeyN: 49,
53
+ KeyM: 50,
54
+ Comma: 51,
55
+ Period: 52,
56
+ Slash: 53,
57
+ NumpadDivide: 53,
58
+ ShiftRight: 54,
59
+ NumpadMultiply: 55,
60
+ AltLeft: 56,
61
+ AltRight: 56,
62
+ Space: 57,
63
+ CapsLock: 58,
64
+ F1: 59,
65
+ F2: 60,
66
+ F3: 61,
67
+ F4: 62,
68
+ F5: 63,
69
+ F6: 64,
70
+ F7: 65,
71
+ F8: 66,
72
+ F9: 67,
73
+ F10: 68,
74
+ NumLock: 69,
75
+ ScrollLock: 70,
76
+ Numpad7: 71,
77
+ Home: 71,
78
+ Numpad8: 72,
79
+ ArrowUp: 72,
80
+ Numpad9: 73,
81
+ PageUp: 73,
82
+ NumpadSubtract: 74,
83
+ Numpad4: 75,
84
+ ArrowLeft: 75,
85
+ Numpad5: 76,
86
+ Numpad6: 77,
87
+ ArrowRight: 77,
88
+ NumpadAdd: 78,
89
+ Numpad1: 79,
90
+ End: 79,
91
+ Numpad2: 80,
92
+ ArrowDown: 80,
93
+ Numpad3: 81,
94
+ PageDown: 81,
95
+ Numpad0: 82,
96
+ Insert: 82,
97
+ NumpadDecimal: 83,
98
+ Delete: 83,
99
+ F11: 87,
100
+ F12: 88
101
+ }, a = {
102
+ 1: "Esc",
103
+ 14: "Backspace",
104
+ 15: "Tab",
105
+ 28: "Enter",
106
+ 29: "Ctrl",
107
+ 42: "Left Shift",
108
+ 54: "Right Shift",
109
+ 56: "Alt",
110
+ 57: "Space",
111
+ 58: "Caps Lock",
112
+ 69: "Num Lock",
113
+ 70: "Scroll Lock",
114
+ 71: "Home / Pad 7",
115
+ 72: "Up / Pad 8",
116
+ 73: "PgUp / Pad 9",
117
+ 74: "Pad -",
118
+ 75: "Left / Pad 4",
119
+ 76: "Pad 5",
120
+ 77: "Right / Pad 6",
121
+ 78: "Pad +",
122
+ 79: "End / Pad 1",
123
+ 80: "Down / Pad 2",
124
+ 81: "PgDn / Pad 3",
125
+ 82: "Ins / Pad 0",
126
+ 83: "Del / Pad .",
127
+ 55: "Pad *"
128
+ }, i = "\0\x1B1234567890-=\b qwertyuiop[]\r\0asdfghjkl;'`\0\\zxcvbnm,./\0*\0 ";
129
+ function o(e) {
130
+ return i.charCodeAt(e & 127) || 0;
131
+ }
132
+ function r(e) {
133
+ if (!e) return "None";
134
+ if (a[e]) return a[e];
135
+ if (e >= 59 && e <= 68) return `F${e - 58}`;
136
+ const t = o(e);
137
+ return t > 32 ? String.fromCharCode(t).toUpperCase() : `Scan ${e}`;
138
+ }
139
+ export {
140
+ d as SCAN,
141
+ r as scanName,
142
+ o as scanToAscii
143
+ };
@@ -0,0 +1,118 @@
1
+ const l = [
2
+ { ext: "gam", label: "Game file", note: "The .EXE opens the game file named after itself with this extension.", offsets: [153270] },
3
+ { ext: "gif", label: "Pictures", note: "Shown as a GIF picture.", offsets: [153522] },
4
+ { ext: "bkd", label: "Backdrops", note: "Shown as a backdrop (a window of a picture).", offsets: [153527] },
5
+ { ext: "fli", label: "Animations", note: "Played as an animation.", offsets: [153532] },
6
+ { ext: "txt", label: "Text pages", note: "Shown as a text page. Text files the game doesn’t name keep .txt.", offsets: [153537] },
7
+ { ext: "lst", label: "Slide lists", note: "Shown as a slide show.", offsets: [153542] },
8
+ {
9
+ ext: "rec",
10
+ label: "Recordings",
11
+ note: "The demo, the high-score replays and the recording of each game the player makes.",
12
+ offsets: [153339, 153203, 153333, 153517]
13
+ },
14
+ { ext: "voc", label: "Voices", note: "The sound set names its voices without one; the player adds this.", offsets: [155720] },
15
+ { ext: "his", label: "High scores", note: "The high-score file, which the player makes.", offsets: [157891, 157959] },
16
+ { ext: "sav", label: "Saved games", note: "GAME0 to GAME9, which the player makes.", offsets: [153595, 153628] },
17
+ { ext: "dat", label: "Save names", note: "SAVNAMES, which the player makes. CONFIG.DAT keeps its name.", offsets: [153579, 153609] },
18
+ { ext: "pal", label: "Palettes", note: "", offsets: [] },
19
+ { ext: "map", label: "Maps", note: "", offsets: [] },
20
+ { ext: "bbl", label: "Background blocks", note: "", offsets: [] },
21
+ { ext: "mon", label: "Monsters", note: "", offsets: [] },
22
+ { ext: "mbl", label: "Monster blocks", note: "", offsets: [] },
23
+ { ext: "chr", label: "Characters", note: "", offsets: [] },
24
+ { ext: "cbl", label: "Character blocks", note: "", offsets: [] },
25
+ { ext: "snd", label: "Sound sets", note: "", offsets: [] },
26
+ { ext: "cmf", label: "Songs", note: "", offsets: [] }
27
+ ], a = new Map(l.map((e) => [e.ext, e])), i = "file.ext.", c = (e) => i + e;
28
+ function p(e) {
29
+ return e.startsWith(i) ? a.get(e.slice(i.length)) : void 0;
30
+ }
31
+ const b = /* @__PURE__ */ new Set(["exe", "com", "bat", "sys", "drv", "hlp", "cfg", "gmx", "zip"]), d = /^[a-z0-9_\-~!@#$^&()]{3}$/;
32
+ function h(e, o) {
33
+ if (typeof o != "string") return "not text";
34
+ const t = o.toLowerCase();
35
+ if (t.length !== 3) return "exactly 3 characters, as the extension it replaces";
36
+ if (!d.test(t)) return "letters, digits or _ - ~ ! @ # $ ^ & ( ) only";
37
+ if (t !== e && a.has(t)) return `.${t} is Game-Maker’s own extension for ${a.get(t).label.toLowerCase()}`;
38
+ if (b.has(t)) return `.${t} is a DOS or player file’s own`;
39
+ }
40
+ function x(e) {
41
+ const o = /* @__PURE__ */ new Map();
42
+ for (const t of l) {
43
+ const s = e?.[c(t.ext)];
44
+ typeof s == "string" && !h(t.ext, s) && s.toLowerCase() !== t.ext && o.set(t.ext, s.toLowerCase());
45
+ }
46
+ return o;
47
+ }
48
+ function g(e) {
49
+ const o = x(e), t = /* @__PURE__ */ new Map();
50
+ for (const [s, n] of o) {
51
+ const f = [...o].find(([r, m]) => m === n && r !== s)?.[0];
52
+ f && t.set(s, `${a.get(f).label} use .${n} too`);
53
+ }
54
+ return t;
55
+ }
56
+ function w(e) {
57
+ return Object.fromEntries(Object.entries(e).filter(([o]) => !o.startsWith(i)));
58
+ }
59
+ const u = (e, o) => e[o] === 46 ? String.fromCharCode(e[o + 1], e[o + 2], e[o + 3]).toLowerCase() : void 0;
60
+ function S(e, o) {
61
+ for (const [t, s] of x(o)) for (const n of a.get(t).offsets) for (let f = 0; f < 3; f++) e[n + 1 + f] = s.charCodeAt(f);
62
+ }
63
+ function E(e) {
64
+ const o = {}, t = [];
65
+ for (const s of l) {
66
+ if (!s.offsets.length) continue;
67
+ const n = s.offsets.map((r) => u(e, r)), f = n[0];
68
+ !f || n.some((r) => r !== f) || h(s.ext, f) || (t.push(s.ext), f !== s.ext && (o[c(s.ext)] = f));
69
+ }
70
+ return { patches: o, read: t };
71
+ }
72
+ function k(e, o) {
73
+ for (const t of o) for (const s of a.get(t).offsets) for (let n = 0; n < 3; n++) e[s + 1 + n] = t.charCodeAt(n);
74
+ }
75
+ function z(e) {
76
+ const o = {};
77
+ if (e.length !== 160598) return o;
78
+ for (const t of l) {
79
+ if (!t.offsets.length) continue;
80
+ let s = "";
81
+ for (let n = 0; n < 4 && e[t.offsets[0] + n]; n++) s += String.fromCharCode(e[t.offsets[0] + n]);
82
+ s = s.trim().toLowerCase(), s !== `.${t.ext}` && (o[`.${t.ext}`] = s === "." ? "" : s);
83
+ }
84
+ return o;
85
+ }
86
+ const C = {
87
+ gam: "z0g",
88
+ gif: "z0n",
89
+ bkd: "z0j",
90
+ fli: "z0p",
91
+ txt: "z0l",
92
+ rec: "z0r",
93
+ his: "z0h",
94
+ sav: "z0m",
95
+ pal: "z0i",
96
+ map: "z0b",
97
+ bbl: "z0a",
98
+ mon: "z0d",
99
+ mbl: "z0c",
100
+ chr: "z0f",
101
+ cbl: "z0e",
102
+ snd: "z0k",
103
+ cmf: "z0q"
104
+ };
105
+ export {
106
+ C as ACORD_EXTENSIONS,
107
+ l as EXT_KINDS,
108
+ c as extId,
109
+ p as extKind,
110
+ h as extValueProblem,
111
+ g as extensionClashes,
112
+ x as extensionMap,
113
+ E as readExtensions,
114
+ z as renamedExtensions,
115
+ w as withoutExtensions,
116
+ S as writeExtensions,
117
+ k as writeStockExtensions
118
+ };
@@ -0,0 +1,129 @@
1
+ import { PATCHES as b, COLOR_TARGETS as n, FKEY_OFF as g } from "./patchTable.js";
2
+ import { extKind as l, extValueProblem as w } from "./fileExtensions.js";
3
+ const k = new Map(b.map((o) => [o.id, o]));
4
+ function z(o) {
5
+ return k.get(o);
6
+ }
7
+ const p = /%[-+ #0]*\d*(?:\.\d+)?[lh]?[diouxXcs]/g;
8
+ function m(o) {
9
+ return o.match(p) ?? [];
10
+ }
11
+ const i = (o, t, s) => typeof o == "number" && Number.isInteger(o) && o >= t && o <= s;
12
+ function E(o, t) {
13
+ switch (o.kind) {
14
+ case "text":
15
+ case "format": {
16
+ if (typeof t != "string") return "not text";
17
+ if (t.length > o.length) return `longer than ${o.length} characters`;
18
+ if (/[^\x20-\x7e]/.test(t)) return "only plain letters, digits and punctuation (no accents or symbols past ~)";
19
+ const s = m(t), r = m(o.stock);
20
+ return s.join(`
21
+ `) !== r.join(`
22
+ `) ? `keep ${r.length ? r.join(" ") : "no % codes"} as they are` : t.replace(p, "").includes("%") ? "a % sign here would be read as a code" : void 0;
23
+ }
24
+ case "number":
25
+ return i(t, o.min, o.max) ? void 0 : `a whole number from ${o.min} to ${o.max}`;
26
+ case "rgb":
27
+ return Array.isArray(t) && t.length === 3 && t.every((s) => i(s, 0, 63)) ? void 0 : "three levels from 0 to 63";
28
+ case "select":
29
+ return typeof t == "string" && t in n ? void 0 : "one of the player’s colors";
30
+ case "frame": {
31
+ if (!Array.isArray(t) || t.length !== 4) return "four numbers";
32
+ const s = t.findIndex((r, e) => !i(r, 0, u(o, e)));
33
+ return s < 0 ? void 0 : `${["left", "top", "right", "bottom"][s]} from 0 to ${u(o, s)}`;
34
+ }
35
+ case "fkey":
36
+ return t === "off" || t === "on" ? void 0 : "on or off";
37
+ }
38
+ }
39
+ function u(o, t) {
40
+ return o.fields[t].size === 1 ? 127 : t % 2 === 0 ? 319 : 199;
41
+ }
42
+ function C(o, t) {
43
+ return o.kind === "text" || o.kind === "format" ? typeof t == "string" && t.trimEnd() === o.stock.trimEnd() : o.kind === "fkey" ? t === "on" : JSON.stringify(t) === JSON.stringify(o.stock);
44
+ }
45
+ function c(o, t, s) {
46
+ o[t.offset] = s & 255, t.size === 2 && (o[t.offset + 1] = s >> 8 & 255);
47
+ }
48
+ function a(o, t, s) {
49
+ return t.size === 2 ? o[t.offset] | o[t.offset + 1] << 8 : s ? o[t.offset] << 24 >> 24 : o[t.offset];
50
+ }
51
+ const d = (o, t, s) => c(o, { offset: t, size: 2 }, s), h = (o, t) => a(o, { offset: t, size: 2 }, !1);
52
+ function O(o, t, s) {
53
+ switch (t.kind) {
54
+ case "text":
55
+ case "format": {
56
+ const r = s.padEnd(t.length, " ");
57
+ for (let e = 0; e < t.length; e++) o[t.offset + e] = r.charCodeAt(e);
58
+ return;
59
+ }
60
+ case "number":
61
+ for (const r of t.fields) c(o, r, r.negate ? -s : s);
62
+ return;
63
+ case "rgb":
64
+ t.offsets.forEach((r, e) => o[r] = s[e]);
65
+ return;
66
+ case "select":
67
+ d(o, t.offset, n[s]);
68
+ return;
69
+ case "frame":
70
+ t.fields.forEach((r, e) => c(o, r, s[e]));
71
+ return;
72
+ case "fkey":
73
+ d(o, t.offset, s === "off" ? g : t.stock);
74
+ return;
75
+ }
76
+ }
77
+ function I(o, t) {
78
+ switch (t.kind) {
79
+ case "text":
80
+ case "format": {
81
+ let s = "";
82
+ for (let r = 0; r < t.length && o[t.offset + r]; r++) s += String.fromCharCode(o[t.offset + r]);
83
+ return s.trimEnd();
84
+ }
85
+ case "number": {
86
+ const s = t.fields.map((r) => {
87
+ const e = a(o, r, t.signed);
88
+ return r.negate ? -(r.size === 2 ? e << 16 >> 16 : e) : e;
89
+ });
90
+ return s.every((r) => r === s[0]) ? s[0] : void 0;
91
+ }
92
+ case "rgb":
93
+ return t.offsets.map((s) => o[s]);
94
+ case "select": {
95
+ const s = h(o, t.offset);
96
+ return Object.keys(n).find((r) => n[r] === s);
97
+ }
98
+ case "frame":
99
+ return t.fields.map((s) => a(o, s, !1));
100
+ case "fkey": {
101
+ const s = h(o, t.offset);
102
+ return s === g ? "off" : s === t.stock ? "on" : void 0;
103
+ }
104
+ }
105
+ }
106
+ function P(o, t) {
107
+ t.kind === "fkey" ? d(o, t.offset, t.stock) : O(o, t, t.stock);
108
+ }
109
+ function $(o) {
110
+ const t = {};
111
+ for (const [s, r] of Object.entries(o ?? {})) {
112
+ const e = k.get(s);
113
+ e && !E(e, r) && !C(e, r) && (t[s] = r);
114
+ const f = l(s);
115
+ f && !w(f.ext, r) && r.toLowerCase() !== f.ext && (t[s] = r.toLowerCase());
116
+ }
117
+ return t;
118
+ }
119
+ export {
120
+ $ as cleanPatches,
121
+ m as formatCodes,
122
+ u as frameLimit,
123
+ C as isStock,
124
+ z as patchEntry,
125
+ E as patchProblem,
126
+ I as readPatch,
127
+ O as writePatch,
128
+ P as writeStock
129
+ };