@lewismoten/gamemaker-sandbox-engine 0.0.0-stage → 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 (129) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/LICENSE +24 -0
  3. package/NOTICE.md +58 -0
  4. package/README.md +149 -2
  5. package/dist/assets/music.worklet-aD2x7RRM.js +466 -0
  6. package/dist/audio/cmfLoad.js +10 -0
  7. package/dist/audio/cmfPlayer.js +201 -0
  8. package/dist/audio/context.js +75 -0
  9. package/dist/audio/engine.js +173 -0
  10. package/dist/audio/mix.js +40 -0
  11. package/dist/audio/opl.js +245 -0
  12. package/dist/audio/output.js +40 -0
  13. package/dist/core/gameFiles.js +89 -0
  14. package/dist/engine/character.js +187 -0
  15. package/dist/engine/funcKeys.js +164 -0
  16. package/dist/engine/game.js +133 -0
  17. package/dist/engine/keys.js +68 -0
  18. package/dist/engine/machine.js +192 -0
  19. package/dist/engine/menus.js +135 -0
  20. package/dist/engine/monsters.js +259 -0
  21. package/dist/engine/playGain.js +10 -0
  22. package/dist/engine/playerLook.js +48 -0
  23. package/dist/engine/recorder.js +127 -0
  24. package/dist/engine/render.js +45 -0
  25. package/dist/engine/scene.js +324 -0
  26. package/dist/engine/scroll.js +79 -0
  27. package/dist/engine/showGraphic.js +107 -0
  28. package/dist/engine/slowPc.js +98 -0
  29. package/dist/engine/slowPcMusic.js +46 -0
  30. package/dist/engine/touch.js +61 -0
  31. package/dist/engine/world.js +205 -0
  32. package/dist/formats/binary.js +120 -0
  33. package/dist/formats/blocks.js +103 -0
  34. package/dist/formats/character.js +83 -0
  35. package/dist/formats/cmf.js +37 -0
  36. package/dist/formats/cmfEdit.js +154 -0
  37. package/dist/formats/cmfPreview.js +89 -0
  38. package/dist/formats/cmfSong.js +190 -0
  39. package/dist/formats/fli.js +340 -0
  40. package/dist/formats/fliFrames.js +34 -0
  41. package/dist/formats/fliLimits.js +54 -0
  42. package/dist/formats/game.js +198 -0
  43. package/dist/formats/gif.js +125 -0
  44. package/dist/formats/gifProgressive.js +99 -0
  45. package/dist/formats/graphicScripts.js +44 -0
  46. package/dist/formats/highscore.js +30 -0
  47. package/dist/formats/jpeg.js +359 -0
  48. package/dist/formats/map.js +38 -0
  49. package/dist/formats/monster.js +69 -0
  50. package/dist/formats/palette.js +58 -0
  51. package/dist/formats/recording.js +17 -0
  52. package/dist/formats/sound.js +44 -0
  53. package/dist/formats/voc.js +303 -0
  54. package/dist/gfx/colorVision.js +45 -0
  55. package/dist/gfx/cp437Glyphs.js +337 -0
  56. package/dist/gfx/font8x8.js +10 -0
  57. package/dist/gfx/screen.js +151 -0
  58. package/dist/index.js +15 -0
  59. package/dist/input/chords.js +46 -0
  60. package/dist/input/deskMouse.js +24 -0
  61. package/dist/input/keyboard.js +82 -0
  62. package/dist/input/scancodes.js +143 -0
  63. package/dist/player/fileExtensions.js +118 -0
  64. package/dist/player/patchRules.js +129 -0
  65. package/dist/player/patchTable.js +1753 -0
  66. package/dist/text/cp437.js +44 -0
  67. package/dist/types/audio/cmfLoad.d.ts +7 -0
  68. package/dist/types/audio/cmfPlayer.d.ts +69 -0
  69. package/dist/types/audio/context.d.ts +12 -0
  70. package/dist/types/audio/engine.d.ts +60 -0
  71. package/dist/types/audio/mix.d.ts +14 -0
  72. package/dist/types/audio/music.worklet.d.ts +22 -0
  73. package/dist/types/audio/opl.d.ts +37 -0
  74. package/dist/types/audio/output.d.ts +13 -0
  75. package/dist/types/core/gameFiles.d.ts +49 -0
  76. package/dist/types/engine/character.d.ts +30 -0
  77. package/dist/types/engine/funcKeys.d.ts +35 -0
  78. package/dist/types/engine/game.d.ts +57 -0
  79. package/dist/types/engine/keys.d.ts +17 -0
  80. package/dist/types/engine/machine.d.ts +103 -0
  81. package/dist/types/engine/menus.d.ts +46 -0
  82. package/dist/types/engine/monsters.d.ts +19 -0
  83. package/dist/types/engine/playGain.d.ts +11 -0
  84. package/dist/types/engine/playerLook.d.ts +44 -0
  85. package/dist/types/engine/recorder.d.ts +67 -0
  86. package/dist/types/engine/render.d.ts +8 -0
  87. package/dist/types/engine/scene.d.ts +188 -0
  88. package/dist/types/engine/scroll.d.ts +24 -0
  89. package/dist/types/engine/showGraphic.d.ts +39 -0
  90. package/dist/types/engine/slowPc.d.ts +124 -0
  91. package/dist/types/engine/slowPcMusic.d.ts +18 -0
  92. package/dist/types/engine/touch.d.ts +33 -0
  93. package/dist/types/engine/world.d.ts +237 -0
  94. package/dist/types/formats/binary.d.ts +44 -0
  95. package/dist/types/formats/blocks.d.ts +52 -0
  96. package/dist/types/formats/character.d.ts +65 -0
  97. package/dist/types/formats/cmf.d.ts +33 -0
  98. package/dist/types/formats/cmfEdit.d.ts +53 -0
  99. package/dist/types/formats/cmfPreview.d.ts +19 -0
  100. package/dist/types/formats/cmfSong.d.ts +74 -0
  101. package/dist/types/formats/fli.d.ts +56 -0
  102. package/dist/types/formats/fliFrames.d.ts +18 -0
  103. package/dist/types/formats/fliLimits.d.ts +13 -0
  104. package/dist/types/formats/game.d.ts +79 -0
  105. package/dist/types/formats/gif.d.ts +15 -0
  106. package/dist/types/formats/gifProgressive.d.ts +46 -0
  107. package/dist/types/formats/graphicScripts.d.ts +18 -0
  108. package/dist/types/formats/highscore.d.ts +10 -0
  109. package/dist/types/formats/jpeg.d.ts +20 -0
  110. package/dist/types/formats/map.d.ts +24 -0
  111. package/dist/types/formats/monster.d.ts +48 -0
  112. package/dist/types/formats/palette.d.ts +15 -0
  113. package/dist/types/formats/recording.d.ts +7 -0
  114. package/dist/types/formats/sound.d.ts +13 -0
  115. package/dist/types/formats/voc.d.ts +13 -0
  116. package/dist/types/gfx/colorVision.d.ts +26 -0
  117. package/dist/types/gfx/cp437Glyphs.d.ts +2 -0
  118. package/dist/types/gfx/font8x8.d.ts +2 -0
  119. package/dist/types/gfx/screen.d.ts +50 -0
  120. package/dist/types/index.d.ts +4 -0
  121. package/dist/types/input/chords.d.ts +22 -0
  122. package/dist/types/input/deskMouse.d.ts +14 -0
  123. package/dist/types/input/keyboard.d.ts +39 -0
  124. package/dist/types/input/scancodes.d.ts +3 -0
  125. package/dist/types/player/fileExtensions.d.ts +44 -0
  126. package/dist/types/player/patchRules.d.ts +24 -0
  127. package/dist/types/player/patchTable.d.ts +83 -0
  128. package/dist/types/text/cp437.d.ts +6 -0
  129. package/package.json +339 -4
@@ -0,0 +1,187 @@
1
+ import { CHARBL as j, MONBL as J, BLEN as r, SOLRIG as u, SOLLEF as l, SOLTOP as a, SOLBOT as k, BACKBL as y } from "../formats/blocks.js";
2
+ import { MAXFRAME as q, DIESEQ as Q, MAXSEQ as W, INF_REPEAT as N, DROPSEQ as A, IDLESEQ as L, PICKUPSEQ as R, HURTSEQ as z, MAXINV as E } from "../formats/character.js";
3
+ import { popKey as C, chrSeq as B, pushKey as V } from "./keys.js";
4
+ import { charBirthMon as Y } from "./monsters.js";
5
+ import { doSound as F, checkTouch as _, getTouchBlocks as I, checkSeqForTie as U, reallyCheckTouch as Z } from "./touch.js";
6
+ import { JSTICKKEY as M, shownBlock as $, mapBlock as w, bgBlock as G, SCRNBLEN as nn, SCRNBWID as en } from "./world.js";
7
+ import { LASTSND as X } from "../formats/sound.js";
8
+ import { LASTMM as cn, MLEN as h, MWID as g } from "../formats/map.js";
9
+ function O(e) {
10
+ const { chr: c } = e, t = c.sequences[c.cseq] ?? c.sequences[0];
11
+ if (c.cframe >= 0 && c.cframe < q) return t.frames[c.cframe];
12
+ if (c.cframe >= q) return { ...t.frames[q - 1], pic2: j + 1 };
13
+ const n = c.sequences[c.cseq - 1];
14
+ if (!n) return { x: 0, y: 0, orient: 0, pic1: 0, pic2: 0, pause: 0, extra: new Uint8Array(5) };
15
+ const i = n.frames[q - 1].extra, o = (f) => f & 255;
16
+ return {
17
+ x: (i[3] | i[4] << 8) << 16 >> 16,
18
+ y: n.key << 16 >> 16,
19
+ orient: o(n.sound) | o(n.on) << 8,
20
+ pic1: o(n.bloc) | o(n.ground) << 8,
21
+ pic2: o(n.jstkBut) | o(n.jstkMov) << 8,
22
+ pause: o(n.norepeat) | o(n.momentum) << 8,
23
+ extra: new Uint8Array(5)
24
+ };
25
+ }
26
+ function D(e) {
27
+ const { chr: c } = e;
28
+ for (; c.x[1] < 0; )
29
+ c.x[1] += r, c.x[0]--;
30
+ for (; c.x[1] >= r; )
31
+ c.x[1] -= r, c.x[0]++;
32
+ for (; c.y[1] < 0; )
33
+ c.y[1] += r, c.y[0]--;
34
+ for (; c.y[1] >= r; )
35
+ c.y[1] -= r, c.y[0]++;
36
+ }
37
+ function T(e) {
38
+ const { chr: c } = e;
39
+ c.x[0] >= h && (c.x[0] -= h), c.x[0] < 0 && (c.x[0] += h), c.y[0] >= g && (c.y[0] -= g), c.y[0] < 0 && (c.y[0] += g);
40
+ }
41
+ function tn(e, c) {
42
+ const { chr: t } = e, n = (f, v, S) => {
43
+ const b = f - v, p = b > 0 ? -(S - f + v) : S - v + f;
44
+ return Math.abs(p) > Math.abs(b) ? b : p;
45
+ }, i = -n(e.mx, t.x[0], h), o = -n(e.my, t.y[0], g);
46
+ c.tx < 0 && (i < 2 && t.x[1] <= Math.abs(c.tx) && (c.tx = -t.x[1]), i < 1 && (c.tx = 0)), i > nn - 2 && c.tx > 0 && (c.tx = 0), c.ty < 0 && (o < 2 && t.y[1] <= Math.abs(c.ty) && (c.ty = -t.y[1]), o < 1 && (c.ty = 0)), o > en - 2 && c.ty > 0 && (c.ty = 0);
47
+ }
48
+ const m = (e, c) => G(e, c).solid;
49
+ function on(e, c) {
50
+ const { chr: t } = e, n = [0, 0, 0, 0], i = c.blks[0][0] !== h ? 0 : 2;
51
+ return c.blknum[i + 1] !== y && (n[1] |= m(e, c.blknum[i + 1]) & k), n[0] |= m(e, c.blknum[i]) & u, i === 0 && (n[0] |= m(e, c.blknum[2]) & u), c.blknum[4] !== y && (c.blknum[5] !== y && (n[3] |= m(e, c.blknum[5]) & a), n[3] & a || (n[2] |= m(e, c.blknum[4]) & u)), n[0] & u && !(n[2] & u) && t.y[1] > r * 2 / 4 && (t.y[1] = r), !(n[0] & u) && n[2] & u && t.y[1] < r / 2 && (t.y[1] = 0), n[0] & u || n[2] & u ? l : 0;
52
+ }
53
+ function rn(e, c) {
54
+ const { chr: t } = e, n = [0, 0, 0, 0], i = c.blks[0][0] !== h ? 0 : 2;
55
+ return c.blknum[i + 1] !== y && (c.blknum[i] !== y && (n[0] |= m(e, c.blknum[i]) & k), n[0] & k || (n[1] |= m(e, c.blknum[i + 1]) & l)), i === 0 && (n[1] |= m(e, c.blknum[3]) & l), c.blknum[5] !== y && (c.blknum[4] !== y && (n[2] |= m(e, c.blknum[4]) & a), n[2] & a || (n[3] |= m(e, c.blknum[5]) & l)), n[1] & l && !(n[3] & l) && t.y[1] > r * 2 / 4 && (t.y[1] = r), !(n[1] & l) && n[3] & l && t.y[1] < r / 2 && (t.y[1] = 0), n[1] & l || n[3] & l ? u : 0;
56
+ }
57
+ function sn(e, c) {
58
+ const { chr: t } = e, n = [0, 0, 0, 0], i = c.blks[0][0] !== h ? 0 : 2;
59
+ return c.blknum[i] !== y && (c.blknum[4] !== y && (n[2] |= m(e, c.blknum[4]) & u), n[2] & u || (n[0] |= m(e, c.blknum[i]) & k)), c.blknum[i + 1] !== y && (c.blknum[5] !== y && (n[3] |= m(e, c.blknum[5]) & l), n[3] & l || (n[1] |= m(e, c.blknum[i + 1]) & k)), n[0] & k && !(n[1] & k) && t.x[1] > r * 2 / 4 && (t.x[1] = r), !(n[0] & k) && n[1] & k && t.x[1] < r / 2 && (t.x[1] = 0), n[0] & k || n[1] & k ? a : 0;
60
+ }
61
+ function fn(e, c) {
62
+ const { chr: t } = e, n = [0, 0, 0, 0], i = c.blks[0][0] !== h ? 0 : 2;
63
+ return c.blknum[4] !== y && (n[2] |= m(e, c.blknum[4]) & u, c.blknum[i] !== y && (n[0] |= m(e, c.blknum[i]) & u), n[2] & u && n[0] & u || (n[2] |= m(e, c.blknum[4]) & a)), c.blknum[5] !== y && (c.blknum[i + 1] !== y && (n[1] |= m(e, c.blknum[i + 1]) & l), n[3] |= m(e, c.blknum[5]) & l, n[1] & l & n[3] & l || (n[3] |= m(e, c.blknum[5]) & a)), n[2] & a && !(n[3] & a) && t.x[1] > r * 2 / 4 && (t.x[1] = r), !(n[2] & a) && n[3] & a && t.x[1] < r / 2 && (t.x[1] = 0), n[2] & a || n[3] & a ? k : 0;
64
+ }
65
+ function K(e, c, t, n) {
66
+ let i = 0;
67
+ return t > 0 && (i = fn(e, n)), t < 0 && (i = sn(e, n)), c > 0 && (i |= rn(e, n)), c < 0 && (i |= on(e, n)), i;
68
+ }
69
+ function H(e) {
70
+ const { chr: c } = e;
71
+ let t = c.y[0] + (c.y[1] > r / 2 ? 1 : 0), n = c.x[0] + (c.x[1] > r / 2 ? 1 : 0);
72
+ return t >= g && (t -= g), n >= h && (n -= h), $(e, w(e, n, t)).grav;
73
+ }
74
+ function P(e, c) {
75
+ const { ci: t } = e, n = H(e);
76
+ (e.monsolid & k || c & k) && t.gravy > 0 && (t.gravy = 0), (e.monsolid & a || c & a) && t.gravy < 0 && (t.gravy = 0), (e.monsolid & u || c & u) && t.gravx > 0 && (t.gravx = 0), (e.monsolid & l || c & l) && t.gravx < 0 && (t.gravx = 0), B(e).momentum || (n & k || n & a || (t.gravy = Math.trunc(t.gravy * 5 / 6)), n & l || n & u || (t.gravx = Math.trunc(t.gravx * 5 / 6)));
77
+ }
78
+ function un(e, c = !1) {
79
+ if (c)
80
+ return e.gclk = e.clock, !0;
81
+ if (e.clock < e.gclk + e.tune.gravityTicks) return !1;
82
+ e.gclk = e.clock;
83
+ const { ci: t } = e, n = H(e);
84
+ n & 4 && (t.gravy += 1), n & 1 && (t.gravy -= 1), n & 2 && (t.gravx += 1), n & 8 && (t.gravx -= 1);
85
+ const i = t.gravx !== 0 || t.gravy !== 0, o = e.tune.gravityCap;
86
+ return t.gravx = Math.max(-o, Math.min(o, t.gravx)), t.gravy = Math.max(-o, Math.min(o, t.gravy)), i;
87
+ }
88
+ function ln(e, c = !1) {
89
+ if (c)
90
+ return e.joyOldTime = e.clock, !1;
91
+ if (!e.jstickOn || !e.joystick || e.joyOldTime + 1 > e.clock) return !1;
92
+ e.joyOldTime = e.clock;
93
+ const t = e.joystick();
94
+ if (!t) return !1;
95
+ const { chr: n, ci: i } = e;
96
+ if (t.pos === 0 && t.buttons === 0)
97
+ return e.joyOldBut = 0, e.curkey === M && C(e, M), !1;
98
+ if (n.cseq === Q) return !1;
99
+ for (let o = 3; o < W; o++) {
100
+ const f = n.sequences[o];
101
+ if (f.jstkMov !== 0 && (f.jstkMov === 9 || f.jstkMov === t.pos) && !B(e).ground && i.meter[o] > 0 && i.seqon[o] && (f.jstkBut === 0 || t.buttons === 0 && f.jstkBut === 4 || t.buttons !== e.joyOldBut && f.jstkBut === t.buttons))
102
+ return e.joyOldBut = t.buttons, n.cseq !== o ? (e.curkey !== M && V(e), e.curkey = M, n.cframe = -1, n.cseq = o, i.nextAni = e.clock, f.sound < X && f.sound >= 0 && F(e, f.sound), !0) : !1;
103
+ }
104
+ return !1;
105
+ }
106
+ function mn(e) {
107
+ const { ci: c } = e;
108
+ if (c.inv[E - 1] !== y) return !1;
109
+ let t = 0;
110
+ for (; t < E && c.inv[t] !== y; ) t++;
111
+ const n = I(e);
112
+ for (let i = 0; i < 6; i++)
113
+ if (!(n.blks[i][0] === h || !G(e, n.blknum[i]).obj) && Z(e, n.blks[i][0], n.blks[i][1], n.blknum[i]) !== 2)
114
+ return c.inv[t] = n.blknum[i], U(e, n.blknum[i], !0), !0;
115
+ return !1;
116
+ }
117
+ async function an(e, c) {
118
+ const { ci: t, chr: n } = e;
119
+ e.ci.topthere = !1, e.ci.bottomthere = !1;
120
+ let i = !1;
121
+ for (; ; ) {
122
+ const o = await c();
123
+ if (o < 0) break;
124
+ if (t.inv[o] !== y) {
125
+ e.map[n.y[0] * h + n.x[0]] = t.inv[o], U(e, t.inv[o], !1);
126
+ for (let f = o; f < E - 1; f++) t.inv[f] = t.inv[f + 1];
127
+ t.inv[E - 1] = y, i = !0;
128
+ break;
129
+ }
130
+ }
131
+ return e.keydn[n.sequences[A].key >> 8] = 0, i;
132
+ }
133
+ async function qn(e, c) {
134
+ const { ci: t, chr: n } = e;
135
+ let i = 0, o = 0, f = !1, v = 0;
136
+ t.scrx = t.nextx, t.scry = t.nexty;
137
+ const S = un(e);
138
+ if (ln(e) && (t.update = !0), e.clock >= t.nextAni) {
139
+ const b = n.cframe, p = n.cseq;
140
+ if (n.cframe === -1) {
141
+ t.meter[n.cseq] < N && n.cseq > 4 && t.meter[n.cseq]--, n.cseq === A && !await an(e, c) && (n.cseq = L, e.keystkptr = 0, e.curkey = 0), n.cseq === R && !mn(e) && (n.cseq = L, e.keystkptr = 0, e.curkey = 0);
142
+ const s = B(e).sound;
143
+ s < X && s >= 0 && F(e, s);
144
+ }
145
+ let d = 0;
146
+ do {
147
+ for (n.cframe === 0 && v++, n.cframe++; (O(e).pic2 === j + 1 || n.cframe >= q) && d++ < 1e3; ) {
148
+ if (n.cseq === Q)
149
+ return n.cframe--, !0;
150
+ const x = B(e);
151
+ t.meter[n.cseq] <= 0 && n.cseq > 4 || n.cseq === z || n.cseq === A || n.cseq === R || x.norepeat || e.keydn[x.key >> 8] === 0 && e.curkey !== M || v > 1 ? (C(e, e.curkey), v = 0) : (n.cframe = 0, t.meter[n.cseq] < N && n.cseq > 4 && t.meter[n.cseq]--, x.frames[0].pic2 === j + 1 && (n.cseq === L ? x.frames[0].pic2 = 0 : C(e, e.curkey), v = 0));
152
+ }
153
+ const s = O(e);
154
+ t.nextAni = e.clock + s.pause, s.pic2 === J && !e.noMons ? (Y(e, n.x[0], n.y[0] + Math.trunc(s.y / r) - 1, s.pic1), o = 0) : (t.curtop = s.pic1, t.curbottom = s.pic2, B(e).momentum ? (t.gravx += s.x, t.gravy += s.y, (s.x !== 0 || s.y !== 0) && (t.netx = s.x, t.nety = s.y), i = 0, o = 0) : (i = s.x, o = s.y, (i !== 0 || o !== 0) && (f = !0, t.netx = i, t.nety = o)));
155
+ } while (O(e).pic2 > j && d++ < 1e3);
156
+ (n.cseq !== p || n.cframe !== b) && (t.update = !0);
157
+ }
158
+ if (i += t.gravx, o += t.gravy, f || S || e.monsolid || t.update) {
159
+ const b = { cx: n.x[1], cy: n.y[1], x: n.x[0], y: n.y[0] }, p = e.tune.maxSpeed, d = { tx: Math.max(-p, Math.min(p, i)), ty: Math.max(-p, Math.min(p, o)) };
160
+ if (tn(e, d), i = d.tx, o = d.ty, n.x[1] += i, n.y[1] += o, D(e), T(e), _(e), n.x[1] = b.cx, n.y[1] = b.cy, n.x[0] = b.x, n.y[0] = b.y, !e.noMons && e.mmSolid < cn) {
161
+ const x = e.mi[e.mmSolid];
162
+ e.monsolid & u && !(e.monsolid & l) && (n.x[1] = x.curx[1], n.x[0] = x.curx[0] - 1, i = 0), e.monsolid & l && !(e.monsolid & u) && (n.x[1] = x.curx[1], n.x[0] = x.curx[0] + 1, i = 0), e.monsolid & a && !(e.monsolid & k) && (n.y[1] = x.cury[1], n.y[0] = x.cury[0] + 1, o = 0), e.monsolid & k && !(e.monsolid & a) && (n.y[1] = x.cury[1], n.y[0] = x.cury[0] - 1, o = 0);
163
+ }
164
+ n.x[1] += i, D(e), T(e);
165
+ let s = K(e, i, 0, I(e));
166
+ for (P(e, s), s & u && (n.x[1] = 0), s & l && (n.x[0]++, n.x[1] = 0), n.y[1] += o; n.y[1] < 0; )
167
+ n.y[1] += r, n.y[0]--;
168
+ for (; n.y[1] >= r; )
169
+ n.y[1] -= r, n.y[0]++;
170
+ T(e), s = K(e, 0, o, I(e)), P(e, s), s & k && (n.y[1] = 0), s & a && (n.y[0]++, n.y[1] = 0), yn(e);
171
+ }
172
+ return !1;
173
+ }
174
+ function yn(e) {
175
+ const { chr: c, ci: t } = e;
176
+ let n = e.mx < c.x[0] ? (c.x[0] - e.mx) * r : (h + (c.x[0] - e.mx)) * r;
177
+ n += c.x[1], t.nextx = n - e.scroll.nx;
178
+ let i = e.my < c.y[0] ? (c.y[0] - e.my) * r : (g + (c.y[0] - e.my)) * r;
179
+ i += c.y[1], t.nexty = i - e.scroll.ny;
180
+ }
181
+ export {
182
+ O as currentFrame,
183
+ ln as handleJoystick,
184
+ un as moveCharGrav,
185
+ qn as moveChars,
186
+ yn as updateCharScreenPos
187
+ };
@@ -0,0 +1,164 @@
1
+ import { gVertMenu as S, gGet as M } from "./menus.js";
2
+ import { STOCK_LOOK as f } from "./playerLook.js";
3
+ import { match as m, displayFile as E, showGraphic as A, RGB_BLUE as T, RGB_YELLOW as K } from "./showGraphic.js";
4
+ import { BLEN as c, BACKBL as h } from "../formats/blocks.js";
5
+ import { INF_REPEAT as B } from "../formats/character.js";
6
+ import "../formats/binary.js";
7
+ const w = "savnames.dat";
8
+ function d(t, e, r, n) {
9
+ const [o, a, i, s] = r && n ? r.frame(`border.${n}.outer`) : [10, 10, 310, 190], [l, u, p, v] = r && n ? r.frame(`border.${n}.inner`) : [15, 15, 305, 185];
10
+ t.box(o, a, i, s, e), t.box(l, u, p, v, e);
11
+ }
12
+ function y(t, e, r) {
13
+ t.box(30, 30, 35 + 5 * (c + 5), 35 + 2 * (c + 5), r);
14
+ for (let n = 0; n < 2; n++)
15
+ for (let o = 0; o < 5; o++) {
16
+ t.box(34 + o * (c + 5), 34 + n * (c + 5), 35 + c + o * (c + 5), 35 + c + n * (c + 5), r);
17
+ const a = e.ci.inv[5 * n + o];
18
+ a !== h && e.bg[a] && t.drawBlock(35 + o * (c + 5), 35 + n * (c + 5), e.bg[a].pixels);
19
+ }
20
+ }
21
+ async function W(t, e, r, n, o = f) {
22
+ n && (d(t.screen, m(e.palette, T)), await E(t, "gmhelp.txt", m(e.palette, K), 30, e.palette, n)), r ? await A(t, r, { gamePalette: e.palette, look: o }) : (t.screen.write(40, 80, o.color(e.palette, "color.select.helpNone"), o.text("str.help.none")), await t.pauseTimeKey(o.seconds("timing.helpNone")));
23
+ }
24
+ function C(t, e, r) {
25
+ const n = r.color(e.palette, "color.select.status"), { ci: o } = e;
26
+ d(t, n, r, "invent"), y(t, e, n), t.write(40, 88, n, r.format("str.invent.score", o.score)), o.meter[3] !== B && t.write(40, 96, n, r.format("str.invent.money", o.meter[3] - 1)), t.write(40, 112, n, r.format("str.invent.hitpoints", o.hitpts)), t.write(40, 120, n, r.format("str.invent.lives", o.lives));
27
+ const a = e.clock, i = Math.trunc(a / 18) - Math.trunc(a / 1818), s = (Math.trunc(a * 100 / 18) - Math.trunc(a * 100 / 1818)) % 100;
28
+ t.write(40, 152, n, r.format("str.invent.time", i / 3600, i % 3600 / 60, i % 60, s));
29
+ }
30
+ async function j(t, e, r = f) {
31
+ C(t.screen, e, r), await t.pauseTimeKey();
32
+ }
33
+ const b = [
34
+ [
35
+ " G A M E - M A K E R",
36
+ " Version 3.00 ",
37
+ "",
38
+ "Recreational Software Designs",
39
+ "Box 1163, Amherst, NH, 03031",
40
+ "",
41
+ "This game was made with GAME-",
42
+ "MAKER. No programming needed!",
43
+ "Design your own worlds, mon- ",
44
+ "sters, characters, sounds... ",
45
+ "",
46
+ "This web edition runs it with",
47
+ "HTML canvas and Web Audio.",
48
+ "",
49
+ " MORE... "
50
+ ].map((t, e) => [40 + e * 8, t]),
51
+ ["Game-Maker software, documen-", "tation, and data files are", "COPYRIGHTED by Recreational", "Software Designs."].map((t, e) => [
52
+ 40 + e * 8,
53
+ t
54
+ ])
55
+ ];
56
+ function x(t, e) {
57
+ const r = t.about?.pages ?? b, n = [...r[e] ?? []], o = t.about?.origin;
58
+ if (o && e === r.length - 1) {
59
+ const a = Math.max(...n.map(([i]) => i), 32) + 16;
60
+ o.forEach((i, s) => n.push([Math.min(a, 184 - 8 * o.length) + s * 8, i]));
61
+ }
62
+ return n;
63
+ }
64
+ const L = (t) => (t.about?.pages ?? b).length;
65
+ function N(t, e, r, n = 0) {
66
+ const o = r.color(e, "color.select.aboutFrame"), a = r.color(e, "color.select.aboutText");
67
+ d(t, o, r, "about");
68
+ for (const [i, s] of x(r, n)) t.write(40, i, a, s);
69
+ return a;
70
+ }
71
+ async function Y(t, e, r = f) {
72
+ const n = N(t.screen, e.palette, r);
73
+ t.flushKeys(), await t.pauseTimeKey(r.seconds("timing.aboutPage1"));
74
+ for (let o = 1; o < L(r); o++) {
75
+ t.screen.boxFill(16, 16, 304, 184, 0);
76
+ for (const [a, i] of x(r, o)) t.screen.write(40, a, n, i);
77
+ await t.pauseTimeKey();
78
+ }
79
+ }
80
+ function R(t, e, r, n = 0, o = 0) {
81
+ const a = r.color(e.palette, "color.select.dropCursor"), i = r.color(e.palette, "color.select.dropFrame");
82
+ return t.clear(), d(t, i, r, "drop"), y(t, e, i), t.write(40, 104, i, r.text("str.drop.title")), t.write(40, 120, i, r.text("str.drop.help1")), t.write(40, 128, i, r.text("str.drop.help2")), t.write(40, 136, i, r.text("str.drop.help3")), g(t, n, o, a), a;
83
+ }
84
+ const g = (t, e, r, n) => t.box(33 + e * (c + 5), 33 + r * (c + 5), 36 + c + e * (c + 5), 36 + c + r * (c + 5), n);
85
+ function $(t, e, r = f) {
86
+ return t.waiting(() => G(t, e, r));
87
+ }
88
+ async function G(t, e, r) {
89
+ const n = R(t.screen, e, r);
90
+ let o = 0, a = 0;
91
+ const i = (s) => g(t.screen, o, a, s);
92
+ for (t.flushKeys(); ; ) {
93
+ for (const l of t.keyPollOnce?.() ?? []) t.keyboard.feed(l);
94
+ const s = t.keyboard.readKey();
95
+ if (t.takeClick()) {
96
+ const l = Math.floor((t.pointer.x - 34) / (c + 5)), u = Math.floor((t.pointer.y - 34) / (c + 5));
97
+ if (l >= 0 && l < 5 && u >= 0 && u < 2 && (i(0), [o, a] = [l, u], i(n), e.ci.inv[a * 5 + o] !== h))
98
+ return a * 5 + o;
99
+ }
100
+ if (!s) {
101
+ await t.frame();
102
+ continue;
103
+ }
104
+ if (s.ascii === 27) return -1;
105
+ if (s.ascii === 13) {
106
+ if (e.ci.inv[a * 5 + o] !== h) return a * 5 + o;
107
+ continue;
108
+ }
109
+ i(0), (s.scan === 72 || s.scan === 80) && (a ^= 1), s.scan === 75 && (o = (o + 4) % 5), s.scan === 77 && (o = (o + 1) % 5), i(n);
110
+ }
111
+ }
112
+ function O(t) {
113
+ const e = t.files.get(w), r = [];
114
+ for (let n = 0; n < 10; n++) {
115
+ let o = "";
116
+ for (let a = 0; a < 21; a++) {
117
+ const i = e?.[n * 21 + a] ?? 0;
118
+ if (!i) break;
119
+ o += String.fromCharCode(i);
120
+ }
121
+ r.push(o);
122
+ }
123
+ return r;
124
+ }
125
+ function D(t, e) {
126
+ const r = new Uint8Array(210);
127
+ e.forEach((n, o) => {
128
+ for (let a = 0; a < Math.min(20, n.length); a++) r[o * 21 + a] = n.charCodeAt(a) & 255;
129
+ }), t.files.set(w, r);
130
+ }
131
+ function q(t, e, r) {
132
+ t.write(e.num("layout.load.title.x"), e.num("layout.load.title.y"), e.color(r, "color.select.loadText"), e.text("str.load.title"));
133
+ }
134
+ function z(t, e, r) {
135
+ const n = e.color(r, "color.select.saveText");
136
+ t.write(e.num("layout.save.title.x"), e.num("layout.save.title.y"), n, e.text("str.save.title"));
137
+ for (let o = 0; o < 10; o++) t.write(73, 40 + o * 14, n, e.text("str.save.marker"));
138
+ }
139
+ function P(t, e, r, n, o) {
140
+ const a = e.color(r, o ? "color.select.saveSlots" : "color.select.loadSlots");
141
+ return n.forEach((i, s) => t.write(80, 40 + s * 14, a, i)), a;
142
+ }
143
+ async function J(t, e, r, n = f) {
144
+ const o = O(t), a = P(t.screen, n, e, o, r), i = n.color(e, r ? "color.select.saveMarker" : "color.select.loadMarker"), s = await S(t, 60, 35, 14, 10, i, 1 / 0, 1, !0, n.num("border.marker.width"));
145
+ if (!s || s > 10) return -1;
146
+ const l = s - 1;
147
+ if (!r) return l;
148
+ const u = t.screen.getCol(79, 40 + l * 14), p = await M(t, 80, 40 + l * 14, a, u, o[l], 20);
149
+ return p === null ? -1 : (o[l] = p, D(t, o), l);
150
+ }
151
+ export {
152
+ L as aboutPages,
153
+ Y as aboutScreen,
154
+ N as drawAbout,
155
+ R as drawDropPicker,
156
+ q as drawLoadHeading,
157
+ z as drawSaveHeading,
158
+ P as drawSaveSlots,
159
+ C as drawStatus,
160
+ W as helpScreen,
161
+ $ as pickDropSlot,
162
+ J as pickSaveSlot,
163
+ j as statusScreen
164
+ };
@@ -0,0 +1,133 @@
1
+ import { Recorder as P } from "./recorder.js";
2
+ import { startGameInits as E, playScene as N, sceneFile as h } from "./scene.js";
3
+ import { checkHighScores as v, showHighScores as S, drawDefaultScreen as L, drawMenu as T, menuMarker as x, gVertMenu as C, drawNoFile as m } from "./menus.js";
4
+ import { showGraphic as g } from "./showGraphic.js";
5
+ import { STOCK_LOOK as O, playerLook as K } from "./playerLook.js";
6
+ import { newCharInfo as M } from "./world.js";
7
+ import { parseGame as A, MAXSCENELINKS as p } from "../formats/game.js";
8
+ import { MLEN as F, MWID as G } from "../formats/map.js";
9
+ import { PALETTE_SIZE as I } from "../formats/palette.js";
10
+ import { gainAtEnd as H, newPlayGain as R } from "./playGain.js";
11
+ function D(e) {
12
+ return e.replace(/\.[^.]*$/, "").toLowerCase();
13
+ }
14
+ function W(e, u) {
15
+ const a = e.files.get(u);
16
+ if (!a) throw new Error(`Missing ${u}`);
17
+ return A(a);
18
+ }
19
+ async function B(e, u, a = {}) {
20
+ const d = W(e, u);
21
+ a.noSoundCard && (e.audio.musicEnabled = !1);
22
+ const o = {
23
+ m: e,
24
+ game: d,
25
+ gameName: D(u),
26
+ ci: M(),
27
+ colors: new Uint8Array(I),
28
+ rec: new P(),
29
+ sndClock: 1,
30
+ timerCounter: 1,
31
+ soundOn: !0,
32
+ musicOn: e.audio.musicEnabled,
33
+ speakerOnly: !!a.speakerOnly || !!a.noSoundCard,
34
+ joystick: a.joystick,
35
+ onFrame: a.onFrame,
36
+ speed: a.speed ?? {},
37
+ onPlayEnd: a.onPlayEnd,
38
+ onLifeLost: a.onLifeLost,
39
+ gmHelp: a.gmHelp,
40
+ look: K(a.player, a.playerAbout)
41
+ }, t = o.look, l = a.onTouched;
42
+ l && (o.onTouched = (n, c, f, b) => {
43
+ !o.rec.playing && l(n, c, f, b);
44
+ }), e.keyboard.attach(), e.keyPoll = (n) => o.rec.advanceWait(n), e.keyPollEnd = () => o.rec.finishWait(), e.keyPollOnce = () => o.rec.pollOnce(), a.onSession?.(o);
45
+ const i = (n, c) => h(d, n, c), r = (n, c, f) => g(e, n, { cols: c, pause: f, gamePalette: o.colors, look: t });
46
+ if (a.skipTitle)
47
+ e.want(i(0, 2), i(0, 3)), o.rec.initRecord(), await k(o, 0);
48
+ else {
49
+ if (e.want(i(0, 0), i(0, 2), i(0, 3)), await e.need(i(0, 1)), await e.audio.playSong(e.files.get(i(0, 1) ?? "")), i(0, 0) && await r(i(0, 0)), a.playback && o.rec.initPlayback(a.playback)) {
50
+ e.audio.stopSong(), await k(o, 0);
51
+ return;
52
+ }
53
+ if (a.record) {
54
+ e.audio.stopSong(), o.rec.initRecord(), await k(o, 0);
55
+ return;
56
+ }
57
+ }
58
+ const y = async () => {
59
+ await e.need(i(0, 3)), await e.audio.playSong(e.files.get(i(0, 3) ?? ""));
60
+ };
61
+ await y();
62
+ let w = 1, s;
63
+ for (; ; ) {
64
+ s ? (e.screen.restore(s.pixels), e.screen.setPalette(s.palette), o.colors = s.palette.slice()) : (i(0, 2) ? await r(i(0, 2), o.colors, 0) : L(e, o.colors), s = { pixels: e.screen.snapshot(), palette: e.screen.palette.slice() });
65
+ const n = () => s && e.screen.restore(s.pixels), c = T(e.screen, t, o.colors, d.scenes[0].desc), f = x(t);
66
+ switch (w = await C(e, f.x, f.y, f.dy, 6, c, f.idle, w, !1, f.width), w) {
67
+ case 1:
68
+ s = void 0, e.audio.stopSong(), o.rec.initRecord(), await k(o, 0), await y();
69
+ break;
70
+ case 2:
71
+ n(), i(0, 6) ? await r(i(0, 6)) : (m(e.screen, t, o.colors, "noInstructions"), await e.pauseTimeKey(t.seconds("timing.menuNoFile")));
72
+ break;
73
+ case 3:
74
+ n(), await e.need(i(0, 5)), await e.audio.playSong(e.files.get(i(0, 5) ?? "")), i(0, 4) ? await r(i(0, 4)) : (m(e.screen, t, o.colors, "noStoryline"), await e.pauseTimeKey(t.seconds("timing.menuNoFile")));
75
+ break;
76
+ case 4:
77
+ n(), i(0, 7) ? await r(i(0, 7)) : (m(e.screen, t, o.colors, "noCredits"), await e.pauseTimeKey(t.seconds("timing.menuNoFile")));
78
+ break;
79
+ case 5:
80
+ i(0, 8) ? await r(i(0, 8), o.colors, 0) : n(), await S(e, o.gameName, o.colors, -1, t);
81
+ break;
82
+ case 7:
83
+ await e.need(i(0, 11)), i(0, 11) && o.rec.initPlayback(e.files.get(i(0, 11))) && (s = void 0, e.audio.stopSong(), await k(o, 0), await y()), w = 1;
84
+ break;
85
+ default:
86
+ if (e.audio.stopSong(), a.onQuit && await a.onQuit()) {
87
+ w = 1, s = void 0, await y();
88
+ break;
89
+ }
90
+ return;
91
+ }
92
+ }
93
+ }
94
+ async function k(e, u) {
95
+ const { m: a, game: d } = e, o = e.look ?? O, t = (n, c) => h(d, n, c);
96
+ let l = u, i = 0;
97
+ E(e);
98
+ let r = d.scenes[0].links[l]?.toScene ?? 65535;
99
+ const y = d.scenes[r], w = d.scenes[0].links[l];
100
+ if (y && w)
101
+ for (const n of y.links)
102
+ n.toScene === 1 && n.from.x === w.from.x && n.from.y === w.from.y && (a.screen.setPalette(new Uint8Array(768).fill(63)), a.screen.setColor(0, 0, 0, 30), a.screen.clear(0), [
103
+ "Although you correctly drew",
104
+ "links between scenes, the",
105
+ 'character starts on the "game',
106
+ 'won" link, so the game would be',
107
+ "won before it starts. The link",
108
+ "is moved for now; fix it in the",
109
+ "integrator."
110
+ ].forEach((c, f) => a.screen.write(32, 40 + f * 10, 15, c)), await a.pauseTimeKey(120), n.from.x = (n.from.x + 10) % F, n.from.y = (n.from.y + 10) % G);
111
+ for (a.screen.clear(), e.rec.restart(); r < d.scenes.length && r !== 1; ) {
112
+ e.onScene?.(r), t(r, 9) && await g(a, t(r, 9), { gamePalette: e.colors, look: o });
113
+ const n = l, c = await N(e, r, i, l);
114
+ if (!c.ok || (c.doscene !== void 0 && (r = c.doscene), c.prevscene !== void 0 && (i = c.prevscene), l = c.link, a.flushKeys(), l > p)) break;
115
+ l !== p ? (t(r, 10) && await g(a, t(r, 10), { gamePalette: e.colors, look: o }), i = r, r = d.scenes[i].links[l].toScene) : l = n;
116
+ }
117
+ e.rec.pause(), r === 1 && (e.onScene?.(1), await a.need(t(1, 1)), await a.audio.playSong(a.files.get(t(1, 1) ?? "")), t(1, 0) && await g(a, t(1, 0), { gamePalette: e.colors, look: o })), l === p + 2 && (await a.need(t(1, 3)), await a.audio.playSong(a.files.get(t(1, 3) ?? "")), t(1, 2) && await g(a, t(1, 2), { gamePalette: e.colors, look: o })), a.screen.clear(), a.screen.setPalette(e.colors), a.flushKeys();
118
+ let s = e.ci.score;
119
+ if (e.rec.playing)
120
+ s = -1;
121
+ else {
122
+ e.onPlayEnd?.(s, r === 1 ? "won" : l === p + 2 ? "lost" : "quit", H(e.gain ?? R(), s));
123
+ const n = await v(a, e.gameName, e.colors, s, o);
124
+ n && a.files.set(`data${n}.rec`, e.rec.save());
125
+ }
126
+ t(0, 8) ? await g(a, t(0, 8), { cols: e.colors, pause: 0, gamePalette: e.colors, look: o }) : a.screen.clear(), await S(a, e.gameName, e.colors, s, o), a.audio.stopSong(), e.rec.stop();
127
+ }
128
+ export {
129
+ D as gameNameOf,
130
+ W as loadGameFile,
131
+ k as play,
132
+ B as runGame
133
+ };
@@ -0,0 +1,68 @@
1
+ import { IDLESEQ as c, MAXSEQ as a, DIESEQ as o } from "../formats/character.js";
2
+ import { MAXKEYS as n } from "./world.js";
3
+ function y(e) {
4
+ return e.chr.sequences[e.chr.cseq] ?? e.chr.sequences[0];
5
+ }
6
+ function u(e) {
7
+ const k = y(e);
8
+ return k.frames[Math.max(0, Math.min(k.frames.length - 1, e.chr.cframe))];
9
+ }
10
+ function m(e, k) {
11
+ const { chr: r, ci: s } = e;
12
+ if (k < 128) {
13
+ if (e.keydn[k] === 0) {
14
+ for (let t = 0; t < a; t++)
15
+ if (r.sequences[t].key >> 8 === k && r.cseq !== o && !y(e).ground && s.meter[t] > 0 && s.seqon[t] && e.keystkptr < n) {
16
+ e.keystack[e.keystkptr] = { key: e.curkey, seq: r.cseq, frame: r.cframe }, e.keystkptr++, e.keystkptr >= n && f(e), r.cseq = t, r.cframe = -1, s.nextAni = e.clock, e.curkey = k;
17
+ break;
18
+ }
19
+ e.keydn[k] = 1;
20
+ }
21
+ return;
22
+ }
23
+ if (k &= 127, e.keydn[k] !== 0) {
24
+ e.keydn[k] = 0;
25
+ for (let t = 0; t < e.keystkptr; t++) e.keystack[t].key === k && (e.keystack[t].key = 255);
26
+ if (k === e.curkey && e.keystkptr > 0 && !y(e).ground) {
27
+ for (; e.keystkptr > 0 && e.keystack[e.keystkptr - 1].key === 255; ) e.keystkptr--;
28
+ const t = e.keystack[Math.max(0, e.keystkptr - 1)];
29
+ e.curkey = t.key, r.cseq = t.seq, r.cframe = t.frame, s.update = !0, s.nextAni = e.clock, e.keystkptr = Math.max(0, e.keystkptr - 1);
30
+ }
31
+ r.cseq === c && (r.cframe = 0);
32
+ }
33
+ }
34
+ function f(e) {
35
+ let k = 0;
36
+ for (let r = 0; r < e.keystkptr; r++)
37
+ e.keystack[r].key !== 255 && (e.keystack[k++] = { ...e.keystack[r] });
38
+ e.keystkptr = k;
39
+ }
40
+ function h(e) {
41
+ e.keystkptr >= e.keystack.length && f(e), e.keystkptr >= e.keystack.length && (e.keystkptr = e.keystack.length - 1), e.keystack[e.keystkptr] = { key: e.curkey, seq: e.chr.cseq, frame: e.chr.cframe }, e.keystkptr++;
42
+ }
43
+ function q(e, k) {
44
+ const { chr: r, ci: s } = e;
45
+ for (let t = 0; t < e.keystkptr; t++) e.keystack[t].key === k && (e.keystack[t].key = 255);
46
+ for (; e.keystkptr > 0 && e.keystack[e.keystkptr - 1].key === 255; ) e.keystkptr--;
47
+ if (e.keystkptr === 0)
48
+ e.curkey = 0, r.cseq = c, r.cframe = 0;
49
+ else {
50
+ const t = e.keystack[e.keystkptr - 1];
51
+ e.curkey = t.key, r.cseq = t.seq, r.cframe = t.frame, e.keystkptr--, r.cseq === c && (r.cframe = 0);
52
+ }
53
+ s.update = !0, s.nextAni = e.clock;
54
+ }
55
+ function l(e) {
56
+ e.keydn.fill(0);
57
+ for (const k of e.keystack)
58
+ k.seq = 0, k.frame = 0, k.key = 255;
59
+ e.keystkptr = 0, e.curkey = 0;
60
+ }
61
+ export {
62
+ u as chrFrame,
63
+ y as chrSeq,
64
+ q as popKey,
65
+ h as pushKey,
66
+ l as resetKeys,
67
+ m as simKeyPress
68
+ };