ac6502 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/README.md +12 -12
  2. package/dist/components/CPU.d.ts +162 -0
  3. package/dist/components/Cart.d.ts +9 -0
  4. package/dist/components/IO/ACIA.d.ts +76 -0
  5. package/dist/components/IO/ACIA.js +282 -0
  6. package/dist/components/IO/ACIA.js.map +1 -0
  7. package/dist/components/IO/Attachments/Attachment.d.ts +112 -0
  8. package/dist/components/IO/Attachments/Attachment.js +71 -0
  9. package/dist/components/IO/Attachments/Attachment.js.map +1 -0
  10. package/dist/components/IO/Attachments/JoystickAttachment.d.ts +53 -0
  11. package/dist/components/IO/Attachments/JoystickAttachment.js +90 -0
  12. package/dist/components/IO/Attachments/JoystickAttachment.js.map +1 -0
  13. package/dist/components/IO/Attachments/KeyboardEncoderAttachment.d.ts +63 -0
  14. package/dist/components/IO/Attachments/KeyboardEncoderAttachment.js +489 -0
  15. package/dist/components/IO/Attachments/KeyboardEncoderAttachment.js.map +1 -0
  16. package/dist/components/IO/Attachments/KeyboardMatrixAttachment.d.ts +44 -0
  17. package/dist/components/IO/Attachments/KeyboardMatrixAttachment.js +274 -0
  18. package/dist/components/IO/Attachments/KeyboardMatrixAttachment.js.map +1 -0
  19. package/dist/components/IO/Attachments/KeypadAttachment.d.ts +47 -0
  20. package/dist/components/IO/Attachments/KeypadAttachment.js +141 -0
  21. package/dist/components/IO/Attachments/KeypadAttachment.js.map +1 -0
  22. package/dist/components/IO/Attachments/LCDAttachment.d.ts +110 -0
  23. package/dist/components/IO/Attachments/LCDAttachment.js +716 -0
  24. package/dist/components/IO/Attachments/LCDAttachment.js.map +1 -0
  25. package/dist/components/IO/Attachments/SNESAttachment.d.ts +85 -0
  26. package/dist/components/IO/Attachments/SNESAttachment.js +184 -0
  27. package/dist/components/IO/Attachments/SNESAttachment.js.map +1 -0
  28. package/dist/components/IO/DevOutputBoard.d.ts +19 -0
  29. package/dist/components/IO/DevOutputBoard.js +33 -0
  30. package/dist/components/IO/DevOutputBoard.js.map +1 -0
  31. package/dist/components/IO/Empty.d.ts +9 -0
  32. package/dist/components/IO/Empty.js +5 -7
  33. package/dist/components/IO/Empty.js.map +1 -1
  34. package/dist/components/IO/EmptyCard.d.ts +9 -0
  35. package/dist/components/IO/GPIOAttachments/GPIOAttachment.d.ts +112 -0
  36. package/dist/components/IO/GPIOAttachments/GPIOJoystickAttachment.d.ts +53 -0
  37. package/dist/components/IO/GPIOAttachments/GPIOKeyboardEncoderAttachment.d.ts +63 -0
  38. package/dist/components/IO/GPIOAttachments/GPIOKeyboardMatrixAttachment.d.ts +44 -0
  39. package/dist/components/IO/GPIOAttachments/GPIOKeypadAttachment.d.ts +47 -0
  40. package/dist/components/IO/GPIOAttachments/GPIOLCDAttachment.d.ts +110 -0
  41. package/dist/components/IO/GPIOCard.d.ts +105 -0
  42. package/dist/components/IO/GPIOCard.js.map +1 -1
  43. package/dist/components/IO/RAMBank.d.ts +37 -0
  44. package/dist/components/IO/RAMBank.js +63 -0
  45. package/dist/components/IO/RAMBank.js.map +1 -0
  46. package/dist/components/IO/RAMCard.d.ts +37 -0
  47. package/dist/components/IO/RTC.d.ts +107 -0
  48. package/dist/components/IO/RTC.js +483 -0
  49. package/dist/components/IO/RTC.js.map +1 -0
  50. package/dist/components/IO/RTCCard.d.ts +107 -0
  51. package/dist/components/IO/SerialCard.d.ts +76 -0
  52. package/dist/components/IO/Sound.d.ts +120 -0
  53. package/dist/components/IO/Sound.js +622 -0
  54. package/dist/components/IO/Sound.js.map +1 -0
  55. package/dist/components/IO/SoundCard.d.ts +120 -0
  56. package/dist/components/IO/Storage.d.ts +74 -0
  57. package/dist/components/IO/Storage.js +409 -0
  58. package/dist/components/IO/Storage.js.map +1 -0
  59. package/dist/components/IO/StorageCard.d.ts +74 -0
  60. package/dist/components/IO/Terminal.d.ts +19 -0
  61. package/dist/components/IO/Terminal.js +33 -0
  62. package/dist/components/IO/Terminal.js.map +1 -0
  63. package/dist/components/IO/VIA.d.ts +105 -0
  64. package/dist/components/IO/VIA.js +597 -0
  65. package/dist/components/IO/VIA.js.map +1 -0
  66. package/dist/components/IO/Video.d.ts +141 -0
  67. package/dist/components/IO/Video.js +630 -0
  68. package/dist/components/IO/Video.js.map +1 -0
  69. package/dist/components/IO/VideoCard.d.ts +141 -0
  70. package/dist/components/IO.d.ts +8 -0
  71. package/dist/components/Machine.d.ts +62 -0
  72. package/dist/components/Machine.js +260 -153
  73. package/dist/components/Machine.js.map +1 -1
  74. package/dist/components/RAM.d.ts +9 -0
  75. package/dist/components/ROM.d.ts +9 -0
  76. package/dist/index.d.ts +2 -0
  77. package/dist/index.js +61 -28
  78. package/dist/index.js.map +1 -1
  79. package/dist/lib.d.ts +22 -0
  80. package/dist/lib.js +47 -0
  81. package/dist/lib.js.map +1 -0
  82. package/dist/tests/CPU.test.d.ts +1 -0
  83. package/dist/tests/Cart.test.d.ts +1 -0
  84. package/dist/tests/IO/ACIA.test.d.ts +1 -0
  85. package/dist/tests/IO/ACIA.test.js +423 -0
  86. package/dist/tests/IO/ACIA.test.js.map +1 -0
  87. package/dist/tests/IO/Attachments/Attachment.test.d.ts +1 -0
  88. package/dist/tests/IO/Attachments/Attachment.test.js +339 -0
  89. package/dist/tests/IO/Attachments/Attachment.test.js.map +1 -0
  90. package/dist/tests/IO/Attachments/JoystickAttachment.test.d.ts +1 -0
  91. package/dist/tests/IO/Attachments/JoystickAttachment.test.js +126 -0
  92. package/dist/tests/IO/Attachments/JoystickAttachment.test.js.map +1 -0
  93. package/dist/tests/IO/Attachments/KeyboardEncoderAttachment.test.d.ts +1 -0
  94. package/dist/tests/IO/Attachments/KeyboardEncoderAttachment.test.js +779 -0
  95. package/dist/tests/IO/Attachments/KeyboardEncoderAttachment.test.js.map +1 -0
  96. package/dist/tests/IO/Attachments/KeyboardMatrixAttachment.test.d.ts +1 -0
  97. package/dist/tests/IO/Attachments/KeyboardMatrixAttachment.test.js +355 -0
  98. package/dist/tests/IO/Attachments/KeyboardMatrixAttachment.test.js.map +1 -0
  99. package/dist/tests/IO/Attachments/KeypadAttachment.test.d.ts +1 -0
  100. package/dist/tests/IO/Attachments/KeypadAttachment.test.js +323 -0
  101. package/dist/tests/IO/Attachments/KeypadAttachment.test.js.map +1 -0
  102. package/dist/tests/IO/Attachments/LCDAttachment.test.d.ts +1 -0
  103. package/dist/tests/IO/Attachments/LCDAttachment.test.js +627 -0
  104. package/dist/tests/IO/Attachments/LCDAttachment.test.js.map +1 -0
  105. package/dist/tests/IO/Attachments/SNESAttachment.test.d.ts +1 -0
  106. package/dist/tests/IO/Attachments/SNESAttachment.test.js +331 -0
  107. package/dist/tests/IO/Attachments/SNESAttachment.test.js.map +1 -0
  108. package/dist/tests/IO/Empty.test.d.ts +1 -0
  109. package/dist/tests/IO/Empty.test.js +121 -0
  110. package/dist/tests/IO/Empty.test.js.map +1 -0
  111. package/dist/tests/IO/GPIOAttachments/GPIOAttachment.test.d.ts +1 -0
  112. package/dist/tests/IO/GPIOAttachments/GPIOJoystickAttachment.test.d.ts +1 -0
  113. package/dist/tests/IO/GPIOAttachments/GPIOKeyboardEncoderAttachment.test.d.ts +1 -0
  114. package/dist/tests/IO/GPIOAttachments/GPIOKeyboardMatrixAttachment.test.d.ts +1 -0
  115. package/dist/tests/IO/GPIOAttachments/GPIOKeypadAttachment.test.d.ts +1 -0
  116. package/dist/tests/IO/GPIOAttachments/GPIOLCDAttachment.test.d.ts +1 -0
  117. package/dist/tests/IO/GPIOCard.test.d.ts +1 -0
  118. package/dist/tests/IO/GPIOCard.test.js.map +1 -1
  119. package/dist/tests/IO/RAMBank.test.d.ts +1 -0
  120. package/dist/tests/IO/RAMBank.test.js +229 -0
  121. package/dist/tests/IO/RAMBank.test.js.map +1 -0
  122. package/dist/tests/IO/RAMCard.test.d.ts +1 -0
  123. package/dist/tests/IO/RTC.test.d.ts +1 -0
  124. package/dist/tests/IO/RTC.test.js +177 -0
  125. package/dist/tests/IO/RTC.test.js.map +1 -0
  126. package/dist/tests/IO/RTCCard.test.d.ts +1 -0
  127. package/dist/tests/IO/SerialCard.test.d.ts +1 -0
  128. package/dist/tests/IO/Sound.test.d.ts +1 -0
  129. package/dist/tests/IO/Sound.test.js +528 -0
  130. package/dist/tests/IO/Sound.test.js.map +1 -0
  131. package/dist/tests/IO/SoundCard.test.d.ts +1 -0
  132. package/dist/tests/IO/Storage.test.d.ts +1 -0
  133. package/dist/tests/IO/Storage.test.js +656 -0
  134. package/dist/tests/IO/Storage.test.js.map +1 -0
  135. package/dist/tests/IO/StorageCard.test.d.ts +1 -0
  136. package/dist/tests/IO/VIA.test.d.ts +1 -0
  137. package/dist/tests/IO/VIA.test.js +503 -0
  138. package/dist/tests/IO/VIA.test.js.map +1 -0
  139. package/dist/tests/IO/Video.test.d.ts +1 -0
  140. package/dist/tests/IO/Video.test.js +549 -0
  141. package/dist/tests/IO/Video.test.js.map +1 -0
  142. package/dist/tests/IO/VideoCard.test.d.ts +1 -0
  143. package/dist/tests/Machine.test.d.ts +1 -0
  144. package/dist/tests/Machine.test.js +27 -42
  145. package/dist/tests/Machine.test.js.map +1 -1
  146. package/dist/tests/RAM.test.d.ts +1 -0
  147. package/dist/tests/ROM.test.d.ts +1 -0
  148. package/package.json +5 -3
  149. package/src/components/IO/{SerialCard.ts → ACIA.ts} +2 -2
  150. package/src/components/IO/{GPIOAttachments/GPIOAttachment.ts → Attachments/Attachment.ts} +2 -2
  151. package/src/components/IO/{GPIOAttachments/GPIOJoystickAttachment.ts → Attachments/JoystickAttachment.ts} +3 -3
  152. package/src/components/IO/{GPIOAttachments/GPIOKeyboardEncoderAttachment.ts → Attachments/KeyboardEncoderAttachment.ts} +3 -3
  153. package/src/components/IO/{GPIOAttachments/GPIOKeyboardMatrixAttachment.ts → Attachments/KeyboardMatrixAttachment.ts} +5 -5
  154. package/src/components/IO/{GPIOAttachments/GPIOKeypadAttachment.ts → Attachments/KeypadAttachment.ts} +3 -3
  155. package/src/components/IO/{GPIOAttachments/GPIOLCDAttachment.ts → Attachments/LCDAttachment.ts} +7 -7
  156. package/src/components/IO/{EmptyCard.ts → Empty.ts} +1 -1
  157. package/src/components/IO/{RAMCard.ts → RAMBank.ts} +8 -8
  158. package/src/components/IO/{RTCCard.ts → RTC.ts} +1 -1
  159. package/src/components/IO/{SoundCard.ts → Sound.ts} +2 -2
  160. package/src/components/IO/{StorageCard.ts → Storage.ts} +70 -73
  161. package/src/components/IO/Terminal.ts +34 -0
  162. package/src/components/IO/{GPIOCard.ts → VIA.ts} +64 -64
  163. package/src/components/IO/{VideoCard.ts → Video.ts} +1 -1
  164. package/src/components/Machine.ts +286 -160
  165. package/src/index.ts +65 -35
  166. package/src/lib.ts +27 -0
  167. package/src/tests/IO/{SerialCard.test.ts → ACIA.test.ts} +5 -5
  168. package/src/tests/IO/{GPIOAttachments/GPIOAttachment.test.ts → Attachments/Attachment.test.ts} +12 -12
  169. package/src/tests/IO/{GPIOAttachments/GPIOJoystickAttachment.test.ts → Attachments/JoystickAttachment.test.ts} +23 -23
  170. package/src/tests/IO/{GPIOAttachments/GPIOKeyboardEncoderAttachment.test.ts → Attachments/KeyboardEncoderAttachment.test.ts} +4 -4
  171. package/src/tests/IO/{GPIOAttachments/GPIOKeyboardMatrixAttachment.test.ts → Attachments/KeyboardMatrixAttachment.test.ts} +5 -5
  172. package/src/tests/IO/{GPIOAttachments/GPIOKeypadAttachment.test.ts → Attachments/KeypadAttachment.test.ts} +38 -38
  173. package/src/tests/IO/{GPIOAttachments/GPIOLCDAttachment.test.ts → Attachments/LCDAttachment.test.ts} +12 -12
  174. package/src/tests/IO/Empty.test.ts +143 -0
  175. package/src/tests/IO/{RAMCard.test.ts → RAMBank.test.ts} +33 -33
  176. package/src/tests/IO/{RTCCard.test.ts → RTC.test.ts} +6 -6
  177. package/src/tests/IO/{SoundCard.test.ts → Sound.test.ts} +6 -6
  178. package/src/tests/IO/{StorageCard.test.ts → Storage.test.ts} +34 -25
  179. package/src/tests/IO/{GPIOCard.test.ts → VIA.test.ts} +7 -7
  180. package/src/tests/IO/{VideoCard.test.ts → Video.test.ts} +13 -13
  181. package/src/tests/Machine.test.ts +31 -38
  182. package/tsconfig.json +1 -0
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AttachmentBase = void 0;
4
+ /**
5
+ * Base abstract class for GPIO attachments with common functionality
6
+ */
7
+ class AttachmentBase {
8
+ constructor(priority, ca1Interrupt = false, ca2Interrupt = false, cb1Interrupt = false, cb2Interrupt = false) {
9
+ this.priority = priority;
10
+ this.enabled = true;
11
+ this.ca1Interrupt = ca1Interrupt;
12
+ this.ca2Interrupt = ca2Interrupt;
13
+ this.cb1Interrupt = cb1Interrupt;
14
+ this.cb2Interrupt = cb2Interrupt;
15
+ }
16
+ reset() {
17
+ this.enabled = true;
18
+ this.ca1Interrupt = false;
19
+ this.ca2Interrupt = false;
20
+ this.cb1Interrupt = false;
21
+ this.cb2Interrupt = false;
22
+ }
23
+ tick(cpuFrequency) {
24
+ // Default: no action
25
+ }
26
+ readPortA(ddr, or) {
27
+ return 0xFF;
28
+ }
29
+ readPortB(ddr, or) {
30
+ return 0xFF;
31
+ }
32
+ writePortA(value, ddr) {
33
+ // Default: no action
34
+ }
35
+ writePortB(value, ddr) {
36
+ // Default: no action
37
+ }
38
+ isEnabled() {
39
+ return this.enabled;
40
+ }
41
+ getPriority() {
42
+ return this.priority;
43
+ }
44
+ clearInterrupts(ca1, ca2, cb1, cb2) {
45
+ if (ca1)
46
+ this.ca1Interrupt = false;
47
+ if (ca2)
48
+ this.ca2Interrupt = false;
49
+ if (cb1)
50
+ this.cb1Interrupt = false;
51
+ if (cb2)
52
+ this.cb2Interrupt = false;
53
+ }
54
+ updateControlLines(ca1, ca2, cb1, cb2) {
55
+ // Default: no action
56
+ }
57
+ hasCA1Interrupt() {
58
+ return this.ca1Interrupt;
59
+ }
60
+ hasCA2Interrupt() {
61
+ return this.ca2Interrupt;
62
+ }
63
+ hasCB1Interrupt() {
64
+ return this.cb1Interrupt;
65
+ }
66
+ hasCB2Interrupt() {
67
+ return this.cb2Interrupt;
68
+ }
69
+ }
70
+ exports.AttachmentBase = AttachmentBase;
71
+ //# sourceMappingURL=Attachment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Attachment.js","sourceRoot":"","sources":["../../../../src/components/IO/Attachments/Attachment.ts"],"names":[],"mappings":";;;AAoGA;;GAEG;AACH,MAAsB,cAAc;IAQlC,YACE,QAAgB,EAChB,eAAwB,KAAK,EAC7B,eAAwB,KAAK,EAC7B,eAAwB,KAAK,EAC7B,eAAwB,KAAK;QAE7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QACnB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QACnB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAA;QACzB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAA;QACzB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAA;QACzB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAA;IAC3B,CAAC;IAED,IAAI,CAAC,YAAoB;QACvB,qBAAqB;IACvB,CAAC;IAED,SAAS,CAAC,GAAW,EAAE,EAAU;QAC/B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,SAAS,CAAC,GAAW,EAAE,EAAU;QAC/B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,UAAU,CAAC,KAAa,EAAE,GAAW;QACnC,qBAAqB;IACvB,CAAC;IAED,UAAU,CAAC,KAAa,EAAE,GAAW;QACnC,qBAAqB;IACvB,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;IAED,eAAe,CAAC,GAAY,EAAE,GAAY,EAAE,GAAY,EAAE,GAAY;QACpE,IAAI,GAAG;YAAE,IAAI,CAAC,YAAY,GAAG,KAAK,CAAA;QAClC,IAAI,GAAG;YAAE,IAAI,CAAC,YAAY,GAAG,KAAK,CAAA;QAClC,IAAI,GAAG;YAAE,IAAI,CAAC,YAAY,GAAG,KAAK,CAAA;QAClC,IAAI,GAAG;YAAE,IAAI,CAAC,YAAY,GAAG,KAAK,CAAA;IACpC,CAAC;IAED,kBAAkB,CAAC,GAAY,EAAE,GAAY,EAAE,GAAY,EAAE,GAAY;QACvE,qBAAqB;IACvB,CAAC;IAED,eAAe;QACb,OAAO,IAAI,CAAC,YAAY,CAAA;IAC1B,CAAC;IAED,eAAe;QACb,OAAO,IAAI,CAAC,YAAY,CAAA;IAC1B,CAAC;IAED,eAAe;QACb,OAAO,IAAI,CAAC,YAAY,CAAA;IAC1B,CAAC;IAED,eAAe;QACb,OAAO,IAAI,CAAC,YAAY,CAAA;IAC1B,CAAC;CACF;AArFD,wCAqFC"}
@@ -0,0 +1,53 @@
1
+ import { AttachmentBase } from './Attachment';
2
+ /**
3
+ * JoystickAttachment - Emulates a joystick/gamepad connected to GPIO port
4
+ *
5
+ * Buttons are active-low (0 = pressed, 1 = released)
6
+ * Can be attached to either Port A or Port B
7
+ */
8
+ export declare class JoystickAttachment extends AttachmentBase {
9
+ static readonly BUTTON_UP = 1;
10
+ static readonly BUTTON_DOWN = 2;
11
+ static readonly BUTTON_LEFT = 4;
12
+ static readonly BUTTON_RIGHT = 8;
13
+ static readonly BUTTON_A = 16;
14
+ static readonly BUTTON_B = 32;
15
+ static readonly BUTTON_SELECT = 64;
16
+ static readonly BUTTON_START = 128;
17
+ private buttonState;
18
+ private attachedToPortA;
19
+ constructor(attachToPortA?: boolean, priority?: number);
20
+ reset(): void;
21
+ readPortA(ddr: number, or: number): number;
22
+ readPortB(ddr: number, or: number): number;
23
+ /**
24
+ * Update the joystick button state
25
+ * @param buttons - Button state byte (1 = pressed, 0 = released)
26
+ */
27
+ updateJoystick(buttons: number): void;
28
+ /**
29
+ * Get the current button state
30
+ * @returns The button state byte
31
+ */
32
+ getButtonState(): number;
33
+ /**
34
+ * Check if a specific button is pressed
35
+ * @param button - Button bit mask to check
36
+ * @returns true if button is pressed
37
+ */
38
+ isButtonPressed(button: number): boolean;
39
+ /**
40
+ * Press a button (set its bit)
41
+ * @param button - Button bit mask to press
42
+ */
43
+ pressButton(button: number): void;
44
+ /**
45
+ * Release a button (clear its bit)
46
+ * @param button - Button bit mask to release
47
+ */
48
+ releaseButton(button: number): void;
49
+ /**
50
+ * Clear all button presses
51
+ */
52
+ releaseAllButtons(): void;
53
+ }
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JoystickAttachment = void 0;
4
+ const Attachment_1 = require("./Attachment");
5
+ /**
6
+ * JoystickAttachment - Emulates a joystick/gamepad connected to GPIO port
7
+ *
8
+ * Buttons are active-low (0 = pressed, 1 = released)
9
+ * Can be attached to either Port A or Port B
10
+ */
11
+ class JoystickAttachment extends Attachment_1.AttachmentBase {
12
+ constructor(attachToPortA = true, priority = 0) {
13
+ // Call parent constructor with priority and no control line interrupts
14
+ super(priority, false, false, false, false);
15
+ this.attachedToPortA = attachToPortA;
16
+ this.buttonState = 0x00;
17
+ this.reset();
18
+ }
19
+ reset() {
20
+ super.reset();
21
+ this.buttonState = 0x00;
22
+ }
23
+ readPortA(ddr, or) {
24
+ if (this.attachedToPortA) {
25
+ // Return inverted button state (active-low)
26
+ return (~this.buttonState) & 0xFF;
27
+ }
28
+ return 0xFF;
29
+ }
30
+ readPortB(ddr, or) {
31
+ if (!this.attachedToPortA) {
32
+ // Return inverted button state (active-low)
33
+ return (~this.buttonState) & 0xFF;
34
+ }
35
+ return 0xFF;
36
+ }
37
+ /**
38
+ * Update the joystick button state
39
+ * @param buttons - Button state byte (1 = pressed, 0 = released)
40
+ */
41
+ updateJoystick(buttons) {
42
+ this.buttonState = buttons & 0xFF;
43
+ }
44
+ /**
45
+ * Get the current button state
46
+ * @returns The button state byte
47
+ */
48
+ getButtonState() {
49
+ return this.buttonState;
50
+ }
51
+ /**
52
+ * Check if a specific button is pressed
53
+ * @param button - Button bit mask to check
54
+ * @returns true if button is pressed
55
+ */
56
+ isButtonPressed(button) {
57
+ return (this.buttonState & button) !== 0;
58
+ }
59
+ /**
60
+ * Press a button (set its bit)
61
+ * @param button - Button bit mask to press
62
+ */
63
+ pressButton(button) {
64
+ this.buttonState |= button;
65
+ }
66
+ /**
67
+ * Release a button (clear its bit)
68
+ * @param button - Button bit mask to release
69
+ */
70
+ releaseButton(button) {
71
+ this.buttonState &= ~button;
72
+ }
73
+ /**
74
+ * Clear all button presses
75
+ */
76
+ releaseAllButtons() {
77
+ this.buttonState = 0x00;
78
+ }
79
+ }
80
+ exports.JoystickAttachment = JoystickAttachment;
81
+ // Joystick button bit masks
82
+ JoystickAttachment.BUTTON_UP = 0x01;
83
+ JoystickAttachment.BUTTON_DOWN = 0x02;
84
+ JoystickAttachment.BUTTON_LEFT = 0x04;
85
+ JoystickAttachment.BUTTON_RIGHT = 0x08;
86
+ JoystickAttachment.BUTTON_A = 0x10;
87
+ JoystickAttachment.BUTTON_B = 0x20;
88
+ JoystickAttachment.BUTTON_SELECT = 0x40;
89
+ JoystickAttachment.BUTTON_START = 0x80;
90
+ //# sourceMappingURL=JoystickAttachment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JoystickAttachment.js","sourceRoot":"","sources":["../../../../src/components/IO/Attachments/JoystickAttachment.ts"],"names":[],"mappings":";;;AAAA,6CAA6C;AAE7C;;;;;GAKG;AACH,MAAa,kBAAmB,SAAQ,2BAAc;IAcpD,YAAY,gBAAyB,IAAI,EAAE,WAAmB,CAAC;QAC7D,uEAAuE;QACvE,KAAK,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;QAC3C,IAAI,CAAC,eAAe,GAAG,aAAa,CAAA;QACpC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA;QACvB,IAAI,CAAC,KAAK,EAAE,CAAA;IACd,CAAC;IAED,KAAK;QACH,KAAK,CAAC,KAAK,EAAE,CAAA;QACb,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA;IACzB,CAAC;IAED,SAAS,CAAC,GAAW,EAAE,EAAU;QAC/B,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACzB,4CAA4C;YAC5C,OAAO,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAA;QACnC,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,SAAS,CAAC,GAAW,EAAE,EAAU;QAC/B,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1B,4CAA4C;YAC5C,OAAO,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,IAAI,CAAA;QACnC,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;;OAGG;IACH,cAAc,CAAC,OAAe;QAC5B,IAAI,CAAC,WAAW,GAAG,OAAO,GAAG,IAAI,CAAA;IACnC,CAAC;IAED;;;OAGG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,CAAA;IACzB,CAAC;IAED;;;;OAIG;IACH,eAAe,CAAC,MAAc;QAC5B,OAAO,CAAC,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;IAC1C,CAAC;IAED;;;OAGG;IACH,WAAW,CAAC,MAAc;QACxB,IAAI,CAAC,WAAW,IAAI,MAAM,CAAA;IAC5B,CAAC;IAED;;;OAGG;IACH,aAAa,CAAC,MAAc;QAC1B,IAAI,CAAC,WAAW,IAAI,CAAC,MAAM,CAAA;IAC7B,CAAC;IAED;;OAEG;IACH,iBAAiB;QACf,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA;IACzB,CAAC;;AAzFH,gDA0FC;AAzFC,4BAA4B;AACZ,4BAAS,GAAG,IAAI,CAAA;AAChB,8BAAW,GAAG,IAAI,CAAA;AAClB,8BAAW,GAAG,IAAI,CAAA;AAClB,+BAAY,GAAG,IAAI,CAAA;AACnB,2BAAQ,GAAG,IAAI,CAAA;AACf,2BAAQ,GAAG,IAAI,CAAA;AACf,gCAAa,GAAG,IAAI,CAAA;AACpB,+BAAY,GAAG,IAAI,CAAA"}
@@ -0,0 +1,63 @@
1
+ import { AttachmentBase } from './Attachment';
2
+ /**
3
+ * KeyboardEncoderAttachment - Emulates a keyboard encoder that provides ASCII-encoded
4
+ * key data on both GPIO ports A and B.
5
+ *
6
+ * This attachment uses the VIA control lines to signal data availability:
7
+ * - CA2 LOW enables Port A
8
+ * - CB2 LOW enables Port B
9
+ * - CA1 interrupt signals data ready on Port A
10
+ * - CB1 interrupt signals data ready on Port B
11
+ *
12
+ * The encoder supports extensive modifier key combinations:
13
+ * - MENU key: 0x80 (alone), 0x90 (with Alt)
14
+ * - Function keys F1-F15: 0x81-0x8F (alone), 0x91-0x9F (with Alt)
15
+ * - Ctrl combinations: Control codes 0x00-0x1F
16
+ * - Alt+Shift: Extended character set 0xA0-0xFF
17
+ * - Alt: Extended character set 0xE0-0xFF
18
+ * - Shift: Uppercase letters and shifted symbols
19
+ */
20
+ export declare class KeyboardEncoderAttachment extends AttachmentBase {
21
+ private asciiDataA;
22
+ private dataReadyA;
23
+ private interruptPendingA;
24
+ private enabledA;
25
+ private asciiDataB;
26
+ private dataReadyB;
27
+ private interruptPendingB;
28
+ private enabledB;
29
+ private shiftPressed;
30
+ private ctrlPressed;
31
+ private altPressed;
32
+ private menuPressed;
33
+ private stateCA1;
34
+ private stateCA2;
35
+ private stateCB1;
36
+ private stateCB2;
37
+ constructor(priority?: number);
38
+ reset(): void;
39
+ readPortA(ddrA: number, orA: number): number;
40
+ readPortB(ddrB: number, orB: number): number;
41
+ updateControlLines(ca1: boolean, ca2: boolean, cb1: boolean, cb2: boolean): void;
42
+ hasCA1Interrupt(): boolean;
43
+ hasCB1Interrupt(): boolean;
44
+ clearInterrupts(ca1: boolean, ca2: boolean, cb1: boolean, cb2: boolean): void;
45
+ /**
46
+ * Map a USB HID keycode to ASCII with modifier keys applied
47
+ */
48
+ private mapKeyWithModifiers;
49
+ /**
50
+ * Update the keyboard state based on a USB HID key press or release
51
+ * @param usbHidKeycode USB HID keycode
52
+ * @param pressed true for key press, false for key release
53
+ */
54
+ updateKey(usbHidKeycode: number, pressed: boolean): void;
55
+ /**
56
+ * Check if Port A has data ready
57
+ */
58
+ hasDataReadyA(): boolean;
59
+ /**
60
+ * Check if Port B has data ready
61
+ */
62
+ hasDataReadyB(): boolean;
63
+ }