@4bitlabs/sci0 1.0.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 (144) hide show
  1. package/LICENSE.txt +10 -0
  2. package/README.md +85 -0
  3. package/dist/.tscache +1 -0
  4. package/dist/index.d.ts +14 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +50 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/models/cel.d.ts +9 -0
  9. package/dist/models/cel.d.ts.map +1 -0
  10. package/dist/models/cel.js +3 -0
  11. package/dist/models/cel.js.map +1 -0
  12. package/dist/models/cursor.d.ts +7 -0
  13. package/dist/models/cursor.d.ts.map +1 -0
  14. package/dist/models/cursor.js +3 -0
  15. package/dist/models/cursor.js.map +1 -0
  16. package/dist/models/draw-command.d.ts +43 -0
  17. package/dist/models/draw-command.d.ts.map +1 -0
  18. package/dist/models/draw-command.js +10 -0
  19. package/dist/models/draw-command.js.map +1 -0
  20. package/dist/models/font-face.d.ts +6 -0
  21. package/dist/models/font-face.d.ts.map +1 -0
  22. package/dist/models/font-face.js +3 -0
  23. package/dist/models/font-face.js.map +1 -0
  24. package/dist/models/resource-header.d.ts +7 -0
  25. package/dist/models/resource-header.d.ts.map +1 -0
  26. package/dist/models/resource-header.js +3 -0
  27. package/dist/models/resource-header.js.map +1 -0
  28. package/dist/models/resource-id.d.ts +10 -0
  29. package/dist/models/resource-id.d.ts.map +1 -0
  30. package/dist/models/resource-id.js +66 -0
  31. package/dist/models/resource-id.js.map +1 -0
  32. package/dist/models/resource-map.d.ts +6 -0
  33. package/dist/models/resource-map.d.ts.map +1 -0
  34. package/dist/models/resource-map.js +3 -0
  35. package/dist/models/resource-map.js.map +1 -0
  36. package/dist/models/resource-type.d.ts +24 -0
  37. package/dist/models/resource-type.d.ts.map +1 -0
  38. package/dist/models/resource-type.js +26 -0
  39. package/dist/models/resource-type.js.map +1 -0
  40. package/dist/models/view.d.ts +7 -0
  41. package/dist/models/view.d.ts.map +1 -0
  42. package/dist/models/view.js +3 -0
  43. package/dist/models/view.js.map +1 -0
  44. package/dist/parsers/cel.d.ts +3 -0
  45. package/dist/parsers/cel.d.ts.map +1 -0
  46. package/dist/parsers/cel.js +34 -0
  47. package/dist/parsers/cel.js.map +1 -0
  48. package/dist/parsers/compression.d.ts +2 -0
  49. package/dist/parsers/compression.d.ts.map +1 -0
  50. package/dist/parsers/compression.js +36 -0
  51. package/dist/parsers/compression.js.map +1 -0
  52. package/dist/parsers/cursor.d.ts +15 -0
  53. package/dist/parsers/cursor.d.ts.map +1 -0
  54. package/dist/parsers/cursor.js +36 -0
  55. package/dist/parsers/cursor.js.map +1 -0
  56. package/dist/parsers/font.d.ts +7 -0
  57. package/dist/parsers/font.d.ts.map +1 -0
  58. package/dist/parsers/font.js +38 -0
  59. package/dist/parsers/font.js.map +1 -0
  60. package/dist/parsers/mapping.d.ts +4 -0
  61. package/dist/parsers/mapping.d.ts.map +1 -0
  62. package/dist/parsers/mapping.js +36 -0
  63. package/dist/parsers/mapping.js.map +1 -0
  64. package/dist/parsers/pic/handlers.d.ts +9 -0
  65. package/dist/parsers/pic/handlers.d.ts.map +1 -0
  66. package/dist/parsers/pic/handlers.js +205 -0
  67. package/dist/parsers/pic/handlers.js.map +1 -0
  68. package/dist/parsers/pic/index.d.ts +2 -0
  69. package/dist/parsers/pic/index.d.ts.map +1 -0
  70. package/dist/parsers/pic/index.js +6 -0
  71. package/dist/parsers/pic/index.js.map +1 -0
  72. package/dist/parsers/pic/op-codes.d.ts +32 -0
  73. package/dist/parsers/pic/op-codes.d.ts.map +1 -0
  74. package/dist/parsers/pic/op-codes.js +44 -0
  75. package/dist/parsers/pic/op-codes.js.map +1 -0
  76. package/dist/parsers/pic/parser.d.ts +3 -0
  77. package/dist/parsers/pic/parser.d.ts.map +1 -0
  78. package/dist/parsers/pic/parser.js +28 -0
  79. package/dist/parsers/pic/parser.js.map +1 -0
  80. package/dist/parsers/pic/pic-state.d.ts +8 -0
  81. package/dist/parsers/pic/pic-state.d.ts.map +1 -0
  82. package/dist/parsers/pic/pic-state.js +17 -0
  83. package/dist/parsers/pic/pic-state.js.map +1 -0
  84. package/dist/parsers/pic/points.d.ts +6 -0
  85. package/dist/parsers/pic/points.d.ts.map +1 -0
  86. package/dist/parsers/pic/points.js +53 -0
  87. package/dist/parsers/pic/points.js.map +1 -0
  88. package/dist/parsers/resource-header.d.ts +4 -0
  89. package/dist/parsers/resource-header.d.ts.map +1 -0
  90. package/dist/parsers/resource-header.js +16 -0
  91. package/dist/parsers/resource-header.js.map +1 -0
  92. package/dist/parsers/view.d.ts +3 -0
  93. package/dist/parsers/view.d.ts.map +1 -0
  94. package/dist/parsers/view.js +27 -0
  95. package/dist/parsers/view.js.map +1 -0
  96. package/dist/screen/buffer.d.ts +7 -0
  97. package/dist/screen/buffer.d.ts.map +1 -0
  98. package/dist/screen/buffer.js +31 -0
  99. package/dist/screen/buffer.js.map +1 -0
  100. package/dist/screen/circles.d.ts +3 -0
  101. package/dist/screen/circles.d.ts.map +1 -0
  102. package/dist/screen/circles.js +87 -0
  103. package/dist/screen/circles.js.map +1 -0
  104. package/dist/screen/default-palette.d.ts +2 -0
  105. package/dist/screen/default-palette.d.ts.map +1 -0
  106. package/dist/screen/default-palette.js +10 -0
  107. package/dist/screen/default-palette.js.map +1 -0
  108. package/dist/screen/index.d.ts +3 -0
  109. package/dist/screen/index.d.ts.map +1 -0
  110. package/dist/screen/index.js +8 -0
  111. package/dist/screen/index.js.map +1 -0
  112. package/dist/screen/noise.d.ts +3 -0
  113. package/dist/screen/noise.d.ts.map +1 -0
  114. package/dist/screen/noise.js +24 -0
  115. package/dist/screen/noise.js.map +1 -0
  116. package/dist/screen/render-cel.d.ts +9 -0
  117. package/dist/screen/render-cel.d.ts.map +1 -0
  118. package/dist/screen/render-cel.js +24 -0
  119. package/dist/screen/render-cel.js.map +1 -0
  120. package/dist/screen/render-pic.d.ts +14 -0
  121. package/dist/screen/render-pic.d.ts.map +1 -0
  122. package/dist/screen/render-pic.js +104 -0
  123. package/dist/screen/render-pic.js.map +1 -0
  124. package/dist/screen/sci0-screen-impl.d.ts +7 -0
  125. package/dist/screen/sci0-screen-impl.d.ts.map +1 -0
  126. package/dist/screen/sci0-screen-impl.js +113 -0
  127. package/dist/screen/sci0-screen-impl.js.map +1 -0
  128. package/dist/screen/screen.d.ts +13 -0
  129. package/dist/screen/screen.d.ts.map +1 -0
  130. package/dist/screen/screen.js +3 -0
  131. package/dist/screen/screen.js.map +1 -0
  132. package/dist/stream/index.d.ts +2 -0
  133. package/dist/stream/index.d.ts.map +1 -0
  134. package/dist/stream/index.js +6 -0
  135. package/dist/stream/index.js.map +1 -0
  136. package/dist/stream/mapping-parser.d.ts +3 -0
  137. package/dist/stream/mapping-parser.d.ts.map +1 -0
  138. package/dist/stream/mapping-parser.js +44 -0
  139. package/dist/stream/mapping-parser.js.map +1 -0
  140. package/dist/utils/repeat.d.ts +2 -0
  141. package/dist/utils/repeat.d.ts.map +1 -0
  142. package/dist/utils/repeat.js +8 -0
  143. package/dist/utils/repeat.js.map +1 -0
  144. package/package.json +33 -0
@@ -0,0 +1,3 @@
1
+ import { DrawCommand } from '../../models/draw-command';
2
+ export declare const parseFrom: (data: Uint8Array) => DrawCommand[];
3
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/parsers/pic/parser.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAKxD,eAAO,MAAM,SAAS,SAAU,UAAU,KAAG,WAAW,EAqBvD,CAAC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseFrom = void 0;
4
+ const readers_1 = require("@4bitlabs/readers");
5
+ const handlers_1 = require("./handlers");
6
+ const pic_state_1 = require("./pic-state");
7
+ const op_codes_1 = require("./op-codes");
8
+ const parseFrom = (data) => {
9
+ const commands = [];
10
+ const br = (0, readers_1.createBitReader)(data, { mode: 'msb' });
11
+ const state = (0, pic_state_1.createPicState)(data);
12
+ while (true) {
13
+ const op = br.read32(8);
14
+ if (!(0, op_codes_1.isOpCode)(op))
15
+ throw new Error(`Unrecognized opcode: 0x${op.toString(16)}`);
16
+ const handler = handlers_1.CodeHandlers[op];
17
+ if (!handler)
18
+ throw new Error(`Unhandled opcode: 0x${op.toString(16)}`);
19
+ const next = handler(br, state);
20
+ if (next === handlers_1.IS_DONE)
21
+ break;
22
+ if (next)
23
+ commands.push(...next);
24
+ }
25
+ return commands;
26
+ };
27
+ exports.parseFrom = parseFrom;
28
+ //# sourceMappingURL=parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/parsers/pic/parser.ts"],"names":[],"mappings":";;;AAAA,+CAAoD;AAGpD,yCAAmD;AACnD,2CAA6C;AAC7C,yCAAsC;AAE/B,MAAM,SAAS,GAAG,CAAC,IAAgB,EAAiB,EAAE;IAC3D,MAAM,QAAQ,GAAkB,EAAE,CAAC;IAEnC,MAAM,EAAE,GAAG,IAAA,yBAAe,EAAC,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAClD,MAAM,KAAK,GAAG,IAAA,0BAAc,EAAC,IAAI,CAAC,CAAC;IAEnC,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAExB,IAAI,CAAC,IAAA,mBAAQ,EAAC,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,0BAA0B,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAE/D,MAAM,OAAO,GAAG,uBAAY,CAAC,EAAE,CAAC,CAAC;QACjC,IAAI,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,uBAAuB,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QAExE,MAAM,IAAI,GAAG,OAAO,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QAChC,IAAI,IAAI,KAAK,kBAAO;YAAE,MAAM;QAC5B,IAAI,IAAI;YAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AArBW,QAAA,SAAS,aAqBpB"}
@@ -0,0 +1,8 @@
1
+ import { DrawCodes, DrawMode, PatternCode } from '../../models/draw-command';
2
+ export interface PicState {
3
+ drawMode: DrawMode;
4
+ drawCodes: DrawCodes;
5
+ patternCode: PatternCode;
6
+ }
7
+ export declare const createPicState: (data: Uint8Array) => PicState;
8
+ //# sourceMappingURL=pic-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pic-state.d.ts","sourceRoot":"","sources":["../../../src/parsers/pic/pic-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7E,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;CAC1B;AASD,eAAO,MAAM,cAAc,SAAU,UAAU,KAAG,QAIhD,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPicState = void 0;
4
+ const draw_command_1 = require("../../models/draw-command");
5
+ const DEFAULT_PALETTE = [
6
+ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc,
7
+ 0xdd, 0xee, 0x88, 0x88, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x88, 0x88, 0xf9,
8
+ 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0x08, 0x91, 0x2a, 0x3b, 0x4c, 0x5d, 0x6e,
9
+ 0x88,
10
+ ];
11
+ const createPicState = (data) => ({
12
+ drawMode: draw_command_1.DrawMode.Visual | draw_command_1.DrawMode.Priority,
13
+ drawCodes: [0, 0, 0],
14
+ patternCode: [0, false, false],
15
+ });
16
+ exports.createPicState = createPicState;
17
+ //# sourceMappingURL=pic-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pic-state.js","sourceRoot":"","sources":["../../../src/parsers/pic/pic-state.ts"],"names":[],"mappings":";;;AAAA,4DAA6E;AAQ7E,MAAM,eAAe,GAAG;IACtB,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC5E,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC5E,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC5E,IAAI;CACL,CAAC;AAEK,MAAM,cAAc,GAAG,CAAC,IAAgB,EAAY,EAAE,CAAC,CAAC;IAC7D,QAAQ,EAAE,uBAAQ,CAAC,MAAM,GAAG,uBAAQ,CAAC,QAAQ;IAC7C,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IACpB,WAAW,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC;CAC/B,CAAC,CAAC;AAJU,QAAA,cAAc,kBAIxB"}
@@ -0,0 +1,6 @@
1
+ import { ReadonlyVec2, vec2 } from 'gl-matrix';
2
+ import { BitReader } from '@4bitlabs/readers';
3
+ export declare const getPoint24: (br: BitReader, out: vec2) => vec2;
4
+ export declare const getPoint16: (br: BitReader, out: vec2, ref: ReadonlyVec2) => vec2;
5
+ export declare const getPoint8: (br: BitReader, out: vec2, ref: ReadonlyVec2) => vec2;
6
+ //# sourceMappingURL=points.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"points.d.ts","sourceRoot":"","sources":["../../../src/parsers/pic/points.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAY9C,eAAO,MAAM,UAAU,OAAQ,SAAS,OAAO,IAAI,KAAG,IAKrD,CAAC;AASF,eAAO,MAAM,UAAU,OACjB,SAAS,OACR,IAAI,OACJ,YAAY,KAChB,IASF,CAAC;AASF,eAAO,MAAM,SAAS,OAChB,SAAS,OACR,IAAI,OACJ,YAAY,KAChB,IAaF,CAAC"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPoint8 = exports.getPoint16 = exports.getPoint24 = void 0;
4
+ const gl_matrix_1 = require("gl-matrix");
5
+ // getPoint24 gets reads an absolute position from the
6
+ // bit-stream. The format is 24-bits long:
7
+ //
8
+ // bits |
9
+ // 0-3 | high nybble of x-position
10
+ // 4-7 | high nybble of y-position
11
+ // 8-15 | low byte of x-position
12
+ // 16-23 | low byte of y-position
13
+ //
14
+ const getPoint24 = (br, out) => {
15
+ const code = br.read32(24);
16
+ const x = ((code & 0xf00000) >>> 12) | ((code & 0xff00) >>> 8);
17
+ const y = ((code & 0x0f0000) >>> 8) | ((code & 0x00ff) >>> 0);
18
+ return gl_matrix_1.vec2.set(out, x, y);
19
+ };
20
+ exports.getPoint24 = getPoint24;
21
+ // getPoint16 reads a medium length delta from the bit-stream.
22
+ // The total PayloadBytes is 16-bits long:
23
+ //
24
+ // bits |
25
+ // 0-7 | y-delta
26
+ // 8-15 | x-delta
27
+ //
28
+ const getPoint16 = (br, out, ref) => {
29
+ const y = br.read32(8);
30
+ const absY = y & 127;
31
+ const dy = (y & 128) !== 0 ? -absY : absY;
32
+ const x = br.read32(8);
33
+ const dx = x > 127 ? x - 256 : x;
34
+ return gl_matrix_1.vec2.set(out, ref[0] + dx, ref[1] + dy);
35
+ };
36
+ exports.getPoint16 = getPoint16;
37
+ // getPoint8 reads a medium length delta from the bit-stream.
38
+ // The total PayloadBytes is 8-bits long:
39
+ //
40
+ // bits |
41
+ // 0-3 | y-delta
42
+ // 4-7 | x-delta
43
+ //
44
+ const getPoint8 = (br, out, ref) => {
45
+ const code = br.read32(8);
46
+ const xSign = ((code >>> 4) & 0b1000) !== 0;
47
+ const ySign = ((code >>> 0) & 0b1000) !== 0;
48
+ const dx = (code >>> 4) & 0b111;
49
+ const dy = (code >>> 0) & 0b111;
50
+ return gl_matrix_1.vec2.set(out, ref[0] + (xSign ? -dx : dx), ref[1] + (ySign ? -dy : dy));
51
+ };
52
+ exports.getPoint8 = getPoint8;
53
+ //# sourceMappingURL=points.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"points.js","sourceRoot":"","sources":["../../../src/parsers/pic/points.ts"],"names":[],"mappings":";;;AAAA,yCAA+C;AAG/C,sDAAsD;AACtD,0CAA0C;AAC1C,EAAE;AACF,UAAU;AACV,oCAAoC;AACpC,oCAAoC;AACpC,iCAAiC;AACjC,iCAAiC;AACjC,EAAE;AAEK,MAAM,UAAU,GAAG,CAAC,EAAa,EAAE,GAAS,EAAQ,EAAE;IAC3D,MAAM,IAAI,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC3B,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAA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AM,CAAC,CAAC,CAAC,CAAC;IAE1B,MAAM,KAAK,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,KAAK,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,EAAE,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC;IAChC,MAAM,EAAE,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC;IAEhC,OAAO,gBAAI,CAAC,GAAG,CACb,GAAG,EACH,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAC3B,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAC5B,CAAC;AACJ,CAAC,CAAC;AAjBW,QAAA,SAAS,aAiBpB"}
@@ -0,0 +1,4 @@
1
+ import { ResourceHeader } from '../models/resource-header';
2
+ export declare const parseHeaderFrom: (bytes: Uint8Array) => ResourceHeader;
3
+ export declare const getPayloadLength: ({ packedSize }: ResourceHeader) => number;
4
+ //# sourceMappingURL=resource-header.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-header.d.ts","sourceRoot":"","sources":["../../src/parsers/resource-header.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,eAAO,MAAM,eAAe,UAAW,UAAU,KAAG,cAQnD,CAAC;AAEF,eAAO,MAAM,gBAAgB,mBAAoB,cAAc,WAC/C,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPayloadLength = exports.parseHeaderFrom = void 0;
4
+ const parseHeaderFrom = (bytes) => {
5
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
6
+ return {
7
+ id: view.getUint16(0, true),
8
+ packedSize: view.getUint16(2, true),
9
+ actualSize: view.getUint16(4, true),
10
+ compression: view.getUint16(6, true),
11
+ };
12
+ };
13
+ exports.parseHeaderFrom = parseHeaderFrom;
14
+ const getPayloadLength = ({ packedSize }) => packedSize - 4;
15
+ exports.getPayloadLength = getPayloadLength;
16
+ //# sourceMappingURL=resource-header.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-header.js","sourceRoot":"","sources":["../../src/parsers/resource-header.ts"],"names":[],"mappings":";;;AAEO,MAAM,eAAe,GAAG,CAAC,KAAiB,EAAkB,EAAE;IACnE,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAC5E,OAAO;QACL,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC;QAC3B,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC;QACnC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC;QACnC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC;KACrC,CAAC;AACJ,CAAC,CAAC;AARW,QAAA,eAAe,mBAQ1B;AAEK,MAAM,gBAAgB,GAAG,CAAC,EAAE,UAAU,EAAkB,EAAE,EAAE,CACjE,UAAU,GAAG,CAAC,CAAC;AADJ,QAAA,gBAAgB,oBACZ"}
@@ -0,0 +1,3 @@
1
+ import { View } from '../models/view';
2
+ export declare const parseFrom: (source: Uint8Array) => View;
3
+ //# sourceMappingURL=view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/parsers/view.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAa,MAAM,gBAAgB,CAAC;AAEjD,eAAO,MAAM,SAAS,WAAY,UAAU,SAkC3C,CAAC"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseFrom = void 0;
4
+ const repeat_1 = require("../utils/repeat");
5
+ const cel_1 = require("./cel");
6
+ const parseFrom = (source) => {
7
+ const view = new DataView(source.buffer, source.byteOffset, source.byteLength);
8
+ const groupCount = view.getUint16(0, true);
9
+ const mirrored = view.getUint16(2, true);
10
+ return (0, repeat_1.repeat)(groupCount, (groupIdx) => {
11
+ const groupOffset = view.getUint16(8 + groupIdx * 2, true);
12
+ const groupView = new DataView(source.buffer, source.byteOffset + groupOffset);
13
+ const frameCount = groupView.getUint16(0, true);
14
+ const isMirrored = (mirrored & (1 << groupIdx)) !== 0;
15
+ const frames = (0, repeat_1.repeat)(frameCount, (frameIdx) => {
16
+ const frameOffset = groupView.getUint16(frameIdx * 2 + 4, true);
17
+ const frameView = new DataView(source.buffer, source.byteOffset + frameOffset);
18
+ return (0, cel_1.parseCel)(frameView);
19
+ });
20
+ return {
21
+ frames,
22
+ isMirrored,
23
+ };
24
+ });
25
+ };
26
+ exports.parseFrom = parseFrom;
27
+ //# sourceMappingURL=view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.js","sourceRoot":"","sources":["../../src/parsers/view.ts"],"names":[],"mappings":";;;AAAA,4CAAyC;AACzC,+BAAiC;AAG1B,MAAM,SAAS,GAAG,CAAC,MAAkB,EAAQ,EAAE;IACpD,MAAM,IAAI,GAAG,IAAI,QAAQ,CACvB,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,UAAU,EACjB,MAAM,CAAC,UAAU,CAClB,CAAC;IAEF,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IAEzC,OAAO,IAAA,eAAM,EAAY,UAAU,EAAE,CAAC,QAAQ,EAAE,EAAE;QAChD,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,QAAQ,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;QAE3D,MAAM,SAAS,GAAG,IAAI,QAAQ,CAC5B,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,UAAU,GAAG,WAAW,CAChC,CAAC;QACF,MAAM,UAAU,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QAChD,MAAM,UAAU,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC;QAEtD,MAAM,MAAM,GAAG,IAAA,eAAM,EAAC,UAAU,EAAE,CAAC,QAAQ,EAAE,EAAE;YAC7C,MAAM,WAAW,GAAG,SAAS,CAAC,SAAS,CAAC,QAAQ,GAAG,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;YAChE,MAAM,SAAS,GAAG,IAAI,QAAQ,CAC5B,MAAM,CAAC,MAAM,EACb,MAAM,CAAC,UAAU,GAAG,WAAW,CAChC,CAAC;YACF,OAAO,IAAA,cAAQ,EAAC,SAAS,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;QAEH,OAAO;YACL,MAAM;YACN,UAAU;SACX,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAlCW,QAAA,SAAS,aAkCpB"}
@@ -0,0 +1,7 @@
1
+ import { ImageDataLike } from '@4bitlabs/image';
2
+ import { Screen } from './screen';
3
+ export interface Buffer extends Screen {
4
+ image: ImageDataLike;
5
+ }
6
+ export declare const createBuffer: (empty: number, bitsPerPixel: 8 | 32) => Buffer;
7
+ //# sourceMappingURL=buffer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../../src/screen/buffer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAuB,MAAM,EAAE,MAAM,UAAU,CAAC;AAGvD,MAAM,WAAW,MAAO,SAAQ,MAAM;IACpC,KAAK,EAAE,aAAa,CAAC;CACtB;AAED,eAAO,MAAM,YAAY,UAAW,MAAM,gBAAgB,CAAC,GAAG,EAAE,KAAG,MA6BlE,CAAC"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createBuffer = void 0;
4
+ const sci0_screen_impl_1 = require("./sci0-screen-impl");
5
+ const createBuffer = (empty, bitsPerPixel) => {
6
+ const bbp = bitsPerPixel / 8;
7
+ const buffer = new ArrayBuffer(320 * 190 * bbp);
8
+ const pixels = bitsPerPixel === 32
9
+ ? new Uint32Array(buffer, 0, 320 * 190)
10
+ : new Uint8ClampedArray(buffer, 0, 320 * 190);
11
+ for (let i = 0; i < pixels.length; i++)
12
+ pixels[i] = empty;
13
+ const plot = (pos, color) => {
14
+ const [x, y] = pos;
15
+ pixels[320 * y + x] = 0xff000000 | color;
16
+ };
17
+ const isFillable = (x, y) => pixels[x + y * 320] === empty;
18
+ return {
19
+ plot,
20
+ brush: (0, sci0_screen_impl_1.createBrush)(plot, [320, 190]),
21
+ fill: (0, sci0_screen_impl_1.createFloodFill)(plot, isFillable, [320, 190]),
22
+ line: (0, sci0_screen_impl_1.createLine)(plot),
23
+ image: {
24
+ data: new Uint8ClampedArray(buffer),
25
+ width: 320,
26
+ height: 190,
27
+ },
28
+ };
29
+ };
30
+ exports.createBuffer = createBuffer;
31
+ //# sourceMappingURL=buffer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buffer.js","sourceRoot":"","sources":["../../src/screen/buffer.ts"],"names":[],"mappings":";;;AAIA,yDAA8E;AAMvE,MAAM,YAAY,GAAG,CAAC,KAAa,EAAE,YAAoB,EAAU,EAAE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CAAC;AACJ,CAAC,CAAC;AA7BW,QAAA,YAAY,gBA6BvB"}
@@ -0,0 +1,3 @@
1
+ declare const circleBitmaps: number[][];
2
+ export default circleBitmaps;
3
+ //# sourceMappingURL=circles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"circles.d.ts","sourceRoot":"","sources":["../../src/screen/circles.ts"],"names":[],"mappings":"AACA,QAAA,MAAM,aAAa,EAAE,MAAM,EAAE,EAoF5B,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // prettier-ignore
4
+ const circleBitmaps = [
5
+ [
6
+ 0b1
7
+ ],
8
+ [
9
+ 0b010,
10
+ 0b111,
11
+ 0b010,
12
+ ],
13
+ [
14
+ 0b01110,
15
+ 0b11111,
16
+ 0b11111,
17
+ 0b11111,
18
+ 0b01110,
19
+ ],
20
+ [
21
+ 0b0011100,
22
+ 0b0111110,
23
+ 0b1111111,
24
+ 0b1111111,
25
+ 0b1111111,
26
+ 0b0111110,
27
+ 0b0011100,
28
+ ],
29
+ [
30
+ 0b000111000,
31
+ 0b011111110,
32
+ 0b111111111,
33
+ 0b111111111,
34
+ 0b111111111,
35
+ 0b111111111,
36
+ 0b111111111,
37
+ 0b011111110,
38
+ 0b000111000,
39
+ ],
40
+ [
41
+ 0b00001110000,
42
+ 0b00111111100,
43
+ 0b01111111110,
44
+ 0b01111111110,
45
+ 0b11111111111,
46
+ 0b11111111111,
47
+ 0b11111111111,
48
+ 0b01111111110,
49
+ 0b01111111110,
50
+ 0b00111111100,
51
+ 0b00011111000,
52
+ ],
53
+ [
54
+ 0b0000111110000,
55
+ 0b0011111111100,
56
+ 0b0111111111110,
57
+ 0b0111111111110,
58
+ 0b1111111111111,
59
+ 0b1111111111111,
60
+ 0b1111111111111,
61
+ 0b1111111111111,
62
+ 0b1111111111111,
63
+ 0b0111111111110,
64
+ 0b0111111111110,
65
+ 0b0011111111100,
66
+ 0b0000111110000,
67
+ ],
68
+ [
69
+ 0b000001111100000,
70
+ 0b000111111111000,
71
+ 0b001111111111100,
72
+ 0b011111111111110,
73
+ 0b011111111111110,
74
+ 0b111111111111111,
75
+ 0b111111111111111,
76
+ 0b111111111111111,
77
+ 0b111111111111111,
78
+ 0b111111111111111,
79
+ 0b011111111111110,
80
+ 0b011111111111110,
81
+ 0b001111111111100,
82
+ 0b000111111111000,
83
+ 0b000001111100000,
84
+ ],
85
+ ];
86
+ exports.default = circleBitmaps;
87
+ //# sourceMappingURL=circles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"circles.js","sourceRoot":"","sources":["../../src/screen/circles.ts"],"names":[],"mappings":";;AAAA,kBAAkB;AAClB,MAAM,aAAa,GAAe;IAChC;QACE,GAAG;KACJ;IACD;QACE,KAAK;QACL,KAAK;QACL,KAAK;KACN;IAED;QACE,OAAO;QACP,OAAO;QACP,OAAO;QACP,OAAO;QACP,OAAO;KACR;IAED;QACE,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;QACT,SAAS;KACV;IAED;QACE,WAAW;QACX,WAAW;QACX,WAAW;QACX,WAAW;QACX,WAAW;QACX,WAAW;QACX,WAAW;QACX,WAAW;QACX,WAAW;KACZ;IACD;QACE,aAAa;QACb,aAAa;QACb,aAAa;QACb,aAAa;QACb,aAAa;QACb,aAAa;QACb,aAAa;QACb,aAAa;QACb,aAAa;QACb,aAAa;QACb,aAAa;KACd;IACD;QACE,eAAe;QACf,eAAe;QACf,eAAe;QACf,eAAe;QACf,eAAe;QACf,eAAe;QACf,eAAe;QACf,eAAe;QACf,eAAe;QACf,eAAe;QACf,eAAe;QACf,eAAe;QACf,eAAe;KAChB;IACD;QACE,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;QACjB,iBAAiB;KAClB;CACF,CAAC;AAEF,kBAAe,aAAa,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const DEFAULT_PALETTE: number[];
2
+ //# sourceMappingURL=default-palette.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-palette.d.ts","sourceRoot":"","sources":["../../src/screen/default-palette.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,UAK3B,CAAC"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_PALETTE = void 0;
4
+ exports.DEFAULT_PALETTE = [
5
+ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc,
6
+ 0xdd, 0xee, 0x88, 0x88, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x88, 0x88, 0xf9,
7
+ 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, 0x08, 0x91, 0x2a, 0x3b, 0x4c, 0x5d, 0x6e,
8
+ 0x88,
9
+ ];
10
+ //# sourceMappingURL=default-palette.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"default-palette.js","sourceRoot":"","sources":["../../src/screen/default-palette.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG;IAC7B,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC5E,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC5E,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;IAC5E,IAAI;CACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { renderPic } from './render-pic';
2
+ export { renderCel } from './render-cel';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/screen/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderCel = exports.renderPic = void 0;
4
+ var render_pic_1 = require("./render-pic");
5
+ Object.defineProperty(exports, "renderPic", { enumerable: true, get: function () { return render_pic_1.renderPic; } });
6
+ var render_cel_1 = require("./render-cel");
7
+ Object.defineProperty(exports, "renderCel", { enumerable: true, get: function () { return render_cel_1.renderCel; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/screen/index.ts"],"names":[],"mappings":";;;AAAA,2CAAyC;AAAhC,uGAAA,SAAS,OAAA;AAClB,2CAAyC;AAAhC,uGAAA,SAAS,OAAA"}
@@ -0,0 +1,3 @@
1
+ export declare const NOISE: boolean[];
2
+ export declare const NOISE_OFFSETS: number[];
3
+ //# sourceMappingURL=noise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"noise.d.ts","sourceRoot":"","sources":["../../src/screen/noise.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,KAAK,EAAE,OAAO,EAI6C,CAAC;AAEzE,eAAO,MAAM,aAAa,EAAE,MAAM,EAWjC,CAAC"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NOISE_OFFSETS = exports.NOISE = void 0;
4
+ const BYTE = Array(8)
5
+ .fill(0)
6
+ .map((_, i) => i);
7
+ exports.NOISE = [
8
+ 0x20, 0x94, 0x02, 0x24, 0x90, 0x82, 0xa4, 0xa2, 0x82, 0x09, 0x0a, 0x22, 0x12,
9
+ 0x10, 0x42, 0x14, 0x91, 0x4a, 0x91, 0x11, 0x08, 0x12, 0x25, 0x10, 0x22, 0xa8,
10
+ 0x14, 0x24, 0x00, 0x50, 0x24, 0x04,
11
+ ].flatMap((it) => BYTE.map((idx) => ((it >>> (7 - idx)) & 0b1) === 0b1));
12
+ exports.NOISE_OFFSETS = [
13
+ 0x00, 0x18, 0x30, 0xc4, 0xdc, 0x65, 0xeb, 0x48, 0x60, 0xbd, 0x89, 0x04, 0x0a,
14
+ 0xf4, 0x7d, 0x6d, 0x85, 0xb0, 0x8e, 0x95, 0x1f, 0x22, 0x0d, 0xdf, 0x2a, 0x78,
15
+ 0xd5, 0x73, 0x1c, 0xb4, 0x40, 0xa1, 0xb9, 0x3c, 0xca, 0x58, 0x92, 0x34, 0xcc,
16
+ 0xce, 0xd7, 0x42, 0x90, 0x0f, 0x8b, 0x7f, 0x32, 0xed, 0x5c, 0x9d, 0xc8, 0x99,
17
+ 0xad, 0x4e, 0x56, 0xa6, 0xf7, 0x68, 0xb7, 0x25, 0x82, 0x37, 0x3a, 0x51, 0x69,
18
+ 0x26, 0x38, 0x52, 0x9e, 0x9a, 0x4f, 0xa7, 0x43, 0x10, 0x80, 0xee, 0x3d, 0x59,
19
+ 0x35, 0xcf, 0x79, 0x74, 0xb5, 0xa2, 0xb1, 0x96, 0x23, 0xe0, 0xbe, 0x05, 0xf5,
20
+ 0x6e, 0x19, 0xc5, 0x66, 0x49, 0xf0, 0xd1, 0x54, 0xa9, 0x70, 0x4b, 0xa4, 0xe2,
21
+ 0xe6, 0xe5, 0xab, 0xe4, 0xd2, 0xaa, 0x4c, 0xe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
@@ -0,0 +1,9 @@
1
+ import { ImageDataLike } from '@4bitlabs/image';
2
+ import { Cel } from '../models/cel';
3
+ interface RenderCelOptions {
4
+ palette?: Uint32Array;
5
+ transparent?: number;
6
+ }
7
+ export declare const renderCel: (cel: Cel, options?: RenderCelOptions) => ImageDataLike;
8
+ export {};
9
+ //# sourceMappingURL=render-cel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-cel.d.ts","sourceRoot":"","sources":["../../src/screen/render-cel.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,UAAU,gBAAgB;IACxB,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAKD,eAAO,MAAM,SAAS,QACf,GAAG,YACC,gBAAgB,KACxB,aAoBF,CAAC"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderCel = void 0;
4
+ const color_1 = require("@4bitlabs/color");
5
+ const DEFAULT_PALETTE = color_1.RAW_CGA;
6
+ const TRANS = 0x00000000;
7
+ const renderCel = (cel, options = {}) => {
8
+ const { palette = DEFAULT_PALETTE, transparent = TRANS } = options;
9
+ const size = cel.width * cel.height;
10
+ const input = new Uint8Array(cel.data, 0, size);
11
+ const buffer = new ArrayBuffer(size * 4);
12
+ const output = new Uint32Array(buffer, 0, size);
13
+ for (let i = 0; i < size; i++) {
14
+ const val = input[i];
15
+ output[i] = val !== cel.keyColor ? palette[val] : transparent;
16
+ }
17
+ return {
18
+ data: new Uint8ClampedArray(buffer, 0, size * 4),
19
+ width: cel.width,
20
+ height: cel.height,
21
+ };
22
+ };
23
+ exports.renderCel = renderCel;
24
+ //# sourceMappingURL=render-cel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-cel.js","sourceRoot":"","sources":["../../src/screen/render-cel.ts"],"names":[],"mappings":";;;AAAA,2CAA0C;AAU1C,MAAM,eAAe,GAAG,eAAO,CAAC;AAChC,MAAM,KAAK,GAAG,UAAU,CAAC;AAElB,MAAM,SAAS,GAAG,CACvB,GAAQ,EACR,UAA4B,EAAE,EACf,EAAE;IACjB,MAAM,EAAE,OAAO,GAAG,eAAe,EAAE,WAAW,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IAEnE,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,MAAM,CAAC;IAEpC,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;IAEhD,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC;IACzC,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;IAEhD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9B,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACrB,MAAM,CAAC,CAAC,CAAC,GAAG,GAAG,KAAK,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;IAChE,CAAC;IAED,OAAO;QACL,IAAI,EAAE,IAAI,iBAAiB,CAAC,MAAM,EAAE,CAAC,EAAE,IAAI,GAAG,CAAC,CAAC;QAChD,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,MAAM,EAAE,GAAG,CAAC,MAAM;KACnB,CAAC;AACJ,CAAC,CAAC;AAvBW,QAAA,SAAS,aAuBpB"}
@@ -0,0 +1,14 @@
1
+ import { ImageFilter, ImageDataLike } from '@4bitlabs/image';
2
+ import { DrawCommand } from '../models/draw-command';
3
+ interface RenderOptions {
4
+ forcePal?: 0 | 1 | 2 | 3 | undefined;
5
+ pipeline?: ImageFilter[];
6
+ }
7
+ interface RenderResult {
8
+ visible: ImageDataLike;
9
+ priority: ImageDataLike;
10
+ control: ImageDataLike;
11
+ }
12
+ export declare const renderPic: (commands: DrawCommand[], options?: RenderOptions) => RenderResult;
13
+ export {};
14
+ //# sourceMappingURL=render-pic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-pic.d.ts","sourceRoot":"","sources":["../../src/screen/render-pic.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAoB,MAAM,iBAAiB,CAAC;AAG/E,OAAO,EAAE,WAAW,EAAY,MAAM,wBAAwB,CAAC;AAM/D,UAAU,aAAa;IACrB,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;CAC1B;AAED,UAAU,YAAY;IACpB,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,aAAa,CAAC;IACxB,OAAO,EAAE,aAAa,CAAC;CACxB;AAED,eAAO,MAAM,SAAS,aACV,WAAW,EAAE,YACd,aAAa,KACrB,YAgGF,CAAC"}
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderPic = void 0;
4
+ const buffer_1 = require("./buffer");
5
+ const image_1 = require("@4bitlabs/image");
6
+ const color_1 = require("@4bitlabs/color");
7
+ const draw_command_1 = require("../models/draw-command");
8
+ const default_palette_1 = require("./default-palette");
9
+ const classicDitherer = (0, image_1.createDitherizer)(color_1.BuiltinDitherPairs.CLASSIC);
10
+ const renderPic = (commands, options = {}) => {
11
+ const { forcePal } = options;
12
+ const visible = (0, buffer_1.createBuffer)(0xff0000ff, 32);
13
+ const priority = (0, buffer_1.createBuffer)(0x00, 8);
14
+ const control = (0, buffer_1.createBuffer)(0x00, 8);
15
+ const palettes = [
16
+ Uint8Array.from(default_palette_1.DEFAULT_PALETTE),
17
+ Uint8Array.from(default_palette_1.DEFAULT_PALETTE),
18
+ Uint8Array.from(default_palette_1.DEFAULT_PALETTE),
19
+ Uint8Array.from(default_palette_1.DEFAULT_PALETTE),
20
+ ];
21
+ commands.forEach((cmd) => {
22
+ const [mode] = cmd;
23
+ switch (mode) {
24
+ case 'SET_PALETTE': {
25
+ const [, idx, palette] = cmd;
26
+ palettes[idx] = palette;
27
+ return;
28
+ }
29
+ case 'UPDATE_PALETTE': {
30
+ const [, entries] = cmd;
31
+ entries.forEach(([pal, idx, color]) => {
32
+ const palette = Uint8Array.from(palettes[pal]);
33
+ palette[idx] = color;
34
+ palettes[pal] = palette;
35
+ });
36
+ return;
37
+ }
38
+ case 'FILL': {
39
+ const [, drawMode, drawCodes, pos] = cmd;
40
+ if ((drawMode & draw_command_1.DrawMode.Visual) !== draw_command_1.DrawMode.Visual)
41
+ return;
42
+ const pal = (drawCodes[0] / 40) >>> 0;
43
+ const idx = drawCodes[0] % 40 >>> 0;
44
+ if (pal !== 0)
45
+ console.log(pal);
46
+ const color = palettes[forcePal !== null && forcePal !== void 0 ? forcePal : pal][idx];
47
+ const [x, y] = pos;
48
+ visible.fill([x, y], color);
49
+ break;
50
+ }
51
+ case 'PLINE': {
52
+ const [, drawMode, drawCodes, ...points] = cmd;
53
+ if ((drawMode & draw_command_1.DrawMode.Visual) !== draw_command_1.DrawMode.Visual)
54
+ return;
55
+ const pal = (drawCodes[0] / 40) >>> 0;
56
+ const idx = drawCodes[0] % 40 >>> 0;
57
+ if (pal !== 0)
58
+ console.log(pal);
59
+ const color = palettes[forcePal !== null && forcePal !== void 0 ? forcePal : pal][idx];
60
+ for (let p = 0; p < points.length - 1; p++)
61
+ visible.line(points[p], points[p + 1], color);
62
+ break;
63
+ }
64
+ case 'BRUSH': {
65
+ const [, drawMode, drawCodes, patternCode, textureCode, pos] = cmd;
66
+ if ((drawMode & draw_command_1.DrawMode.Visual) !== draw_command_1.DrawMode.Visual)
67
+ return;
68
+ const pal = (drawCodes[0] / 40) >>> 0;
69
+ const idx = drawCodes[0] % 40 >>> 0;
70
+ if (pal !== 0)
71
+ console.log(pal);
72
+ const color = palettes[forcePal !== null && forcePal !== void 0 ? forcePal : pal][idx];
73
+ visible.brush(pos, ...patternCode, textureCode, color);
74
+ break;
75
+ }
76
+ case 'CEL': {
77
+ const [, drawMode, pos, cel] = cmd;
78
+ if ((drawMode & draw_command_1.DrawMode.Visual) !== draw_command_1.DrawMode.Visual)
79
+ return;
80
+ const data = new Uint8Array(cel.data);
81
+ for (let y = pos[1]; y < pos[1] + cel.height; y++)
82
+ for (let x = pos[0]; x < pos[0] + cel.width; x++) {
83
+ if (x >= 320 || y >= 190)
84
+ continue;
85
+ const color = data[x + y * cel.width];
86
+ if (color === cel.keyColor)
87
+ continue;
88
+ visible.plot([x, y], color | (color << 4));
89
+ }
90
+ break;
91
+ }
92
+ default:
93
+ console.log('unhandled opcode', mode);
94
+ }
95
+ });
96
+ const { pipeline = [classicDitherer] } = options;
97
+ return {
98
+ visible: pipeline.reduce((prev, op) => op(prev), visible.image),
99
+ priority: priority.image,
100
+ control: control.image,
101
+ };
102
+ };
103
+ exports.renderPic = renderPic;
104
+ //# sourceMappingURL=render-pic.js.map