ac6502 1.3.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +139 -32
- package/dist/components/IO/ACIA.d.ts +76 -0
- package/dist/components/IO/ACIA.js +282 -0
- package/dist/components/IO/ACIA.js.map +1 -0
- package/dist/components/IO/Attachments/Attachment.d.ts +112 -0
- package/dist/components/IO/Attachments/Attachment.js +71 -0
- package/dist/components/IO/Attachments/Attachment.js.map +1 -0
- package/dist/components/IO/Attachments/JoystickAttachment.d.ts +53 -0
- package/dist/components/IO/Attachments/JoystickAttachment.js +90 -0
- package/dist/components/IO/Attachments/JoystickAttachment.js.map +1 -0
- package/dist/components/IO/Attachments/KeyboardEncoderAttachment.d.ts +63 -0
- package/dist/components/IO/Attachments/KeyboardEncoderAttachment.js +489 -0
- package/dist/components/IO/Attachments/KeyboardEncoderAttachment.js.map +1 -0
- package/dist/components/IO/Attachments/KeyboardMatrixAttachment.d.ts +44 -0
- package/dist/components/IO/Attachments/KeyboardMatrixAttachment.js +274 -0
- package/dist/components/IO/Attachments/KeyboardMatrixAttachment.js.map +1 -0
- package/dist/components/IO/Attachments/KeypadAttachment.d.ts +47 -0
- package/dist/components/IO/Attachments/KeypadAttachment.js +141 -0
- package/dist/components/IO/Attachments/KeypadAttachment.js.map +1 -0
- package/dist/components/IO/Attachments/LCDAttachment.d.ts +110 -0
- package/dist/components/IO/Attachments/LCDAttachment.js +716 -0
- package/dist/components/IO/Attachments/LCDAttachment.js.map +1 -0
- package/dist/components/IO/Attachments/SNESAttachment.d.ts +85 -0
- package/dist/components/IO/Attachments/SNESAttachment.js +184 -0
- package/dist/components/IO/Attachments/SNESAttachment.js.map +1 -0
- package/dist/components/IO/Empty.d.ts +9 -0
- package/dist/components/IO/Empty.js +5 -7
- package/dist/components/IO/Empty.js.map +1 -1
- package/dist/components/IO/GPIOCard.d.ts +5 -5
- package/dist/components/IO/GPIOCard.js.map +1 -1
- package/dist/components/IO/RAMBank.d.ts +37 -0
- package/dist/components/IO/RAMBank.js +63 -0
- package/dist/components/IO/RAMBank.js.map +1 -0
- package/dist/components/IO/RTC.d.ts +107 -0
- package/dist/components/IO/RTC.js +483 -0
- package/dist/components/IO/RTC.js.map +1 -0
- package/dist/components/IO/Sound.d.ts +120 -0
- package/dist/components/IO/Sound.js +622 -0
- package/dist/components/IO/Sound.js.map +1 -0
- package/dist/components/IO/Storage.d.ts +74 -0
- package/dist/components/IO/Storage.js +409 -0
- package/dist/components/IO/Storage.js.map +1 -0
- package/dist/components/IO/Terminal.d.ts +19 -0
- package/dist/components/IO/Terminal.js +33 -0
- package/dist/components/IO/Terminal.js.map +1 -0
- package/dist/components/IO/VIA.d.ts +105 -0
- package/dist/components/IO/VIA.js +597 -0
- package/dist/components/IO/VIA.js.map +1 -0
- package/dist/components/IO/Video.d.ts +141 -0
- package/dist/components/IO/Video.js +630 -0
- package/dist/components/IO/Video.js.map +1 -0
- package/dist/components/Machine.d.ts +20 -24
- package/dist/components/Machine.js +249 -166
- package/dist/components/Machine.js.map +1 -1
- package/dist/index.js +28 -14
- package/dist/index.js.map +1 -1
- package/dist/lib.d.ts +16 -16
- package/dist/lib.js +32 -32
- package/dist/lib.js.map +1 -1
- package/dist/tests/IO/ACIA.test.d.ts +1 -0
- package/dist/tests/IO/ACIA.test.js +423 -0
- package/dist/tests/IO/ACIA.test.js.map +1 -0
- package/dist/tests/IO/Attachments/Attachment.test.d.ts +1 -0
- package/dist/tests/IO/Attachments/Attachment.test.js +339 -0
- package/dist/tests/IO/Attachments/Attachment.test.js.map +1 -0
- package/dist/tests/IO/Attachments/JoystickAttachment.test.d.ts +1 -0
- package/dist/tests/IO/Attachments/JoystickAttachment.test.js +126 -0
- package/dist/tests/IO/Attachments/JoystickAttachment.test.js.map +1 -0
- package/dist/tests/IO/Attachments/KeyboardEncoderAttachment.test.d.ts +1 -0
- package/dist/tests/IO/Attachments/KeyboardEncoderAttachment.test.js +779 -0
- package/dist/tests/IO/Attachments/KeyboardEncoderAttachment.test.js.map +1 -0
- package/dist/tests/IO/Attachments/KeyboardMatrixAttachment.test.d.ts +1 -0
- package/dist/tests/IO/Attachments/KeyboardMatrixAttachment.test.js +355 -0
- package/dist/tests/IO/Attachments/KeyboardMatrixAttachment.test.js.map +1 -0
- package/dist/tests/IO/Attachments/KeypadAttachment.test.d.ts +1 -0
- package/dist/tests/IO/Attachments/KeypadAttachment.test.js +323 -0
- package/dist/tests/IO/Attachments/KeypadAttachment.test.js.map +1 -0
- package/dist/tests/IO/Attachments/LCDAttachment.test.d.ts +1 -0
- package/dist/tests/IO/Attachments/LCDAttachment.test.js +627 -0
- package/dist/tests/IO/Attachments/LCDAttachment.test.js.map +1 -0
- package/dist/tests/IO/Attachments/SNESAttachment.test.d.ts +1 -0
- package/dist/tests/IO/Attachments/SNESAttachment.test.js +331 -0
- package/dist/tests/IO/Attachments/SNESAttachment.test.js.map +1 -0
- package/dist/tests/IO/Empty.test.d.ts +1 -0
- package/dist/tests/IO/Empty.test.js +121 -0
- package/dist/tests/IO/Empty.test.js.map +1 -0
- package/dist/tests/IO/GPIOCard.test.js.map +1 -1
- package/dist/tests/IO/RAMBank.test.d.ts +1 -0
- package/dist/tests/IO/RAMBank.test.js +229 -0
- package/dist/tests/IO/RAMBank.test.js.map +1 -0
- package/dist/tests/IO/RTC.test.d.ts +1 -0
- package/dist/tests/IO/RTC.test.js +177 -0
- package/dist/tests/IO/RTC.test.js.map +1 -0
- package/dist/tests/IO/Sound.test.d.ts +1 -0
- package/dist/tests/IO/Sound.test.js +528 -0
- package/dist/tests/IO/Sound.test.js.map +1 -0
- package/dist/tests/IO/Storage.test.d.ts +1 -0
- package/dist/tests/IO/Storage.test.js +656 -0
- package/dist/tests/IO/Storage.test.js.map +1 -0
- package/dist/tests/IO/VIA.test.d.ts +1 -0
- package/dist/tests/IO/VIA.test.js +503 -0
- package/dist/tests/IO/VIA.test.js.map +1 -0
- package/dist/tests/IO/Video.test.d.ts +1 -0
- package/dist/tests/IO/Video.test.js +549 -0
- package/dist/tests/IO/Video.test.js.map +1 -0
- package/dist/tests/Machine.test.js +27 -42
- package/dist/tests/Machine.test.js.map +1 -1
- package/package.json +1 -1
- package/src/components/IO/{SerialCard.ts → ACIA.ts} +2 -2
- package/src/components/IO/{GPIOAttachments/GPIOAttachment.ts → Attachments/Attachment.ts} +2 -2
- package/src/components/IO/{GPIOAttachments/GPIOJoystickAttachment.ts → Attachments/JoystickAttachment.ts} +3 -3
- package/src/components/IO/{GPIOAttachments/GPIOKeyboardEncoderAttachment.ts → Attachments/KeyboardEncoderAttachment.ts} +3 -3
- package/src/components/IO/{GPIOAttachments/GPIOKeyboardMatrixAttachment.ts → Attachments/KeyboardMatrixAttachment.ts} +5 -5
- package/src/components/IO/{GPIOAttachments/GPIOKeypadAttachment.ts → Attachments/KeypadAttachment.ts} +3 -3
- package/src/components/IO/{GPIOAttachments/GPIOLCDAttachment.ts → Attachments/LCDAttachment.ts} +7 -7
- package/src/components/IO/{EmptyCard.ts → Empty.ts} +1 -1
- package/src/components/IO/{RAMCard.ts → RAMBank.ts} +8 -8
- package/src/components/IO/{RTCCard.ts → RTC.ts} +1 -1
- package/src/components/IO/{SoundCard.ts → Sound.ts} +2 -2
- package/src/components/IO/{StorageCard.ts → Storage.ts} +70 -73
- package/src/components/IO/{DevOutputBoard.ts → Terminal.ts} +2 -2
- package/src/components/IO/{GPIOCard.ts → VIA.ts} +64 -64
- package/src/components/IO/{VideoCard.ts → Video.ts} +1 -1
- package/src/components/Machine.ts +276 -176
- package/src/index.ts +34 -21
- package/src/lib.ts +16 -16
- package/src/tests/IO/{SerialCard.test.ts → ACIA.test.ts} +5 -5
- package/src/tests/IO/{GPIOAttachments/GPIOAttachment.test.ts → Attachments/Attachment.test.ts} +12 -12
- package/src/tests/IO/{GPIOAttachments/GPIOJoystickAttachment.test.ts → Attachments/JoystickAttachment.test.ts} +23 -23
- package/src/tests/IO/{GPIOAttachments/GPIOKeyboardEncoderAttachment.test.ts → Attachments/KeyboardEncoderAttachment.test.ts} +4 -4
- package/src/tests/IO/{GPIOAttachments/GPIOKeyboardMatrixAttachment.test.ts → Attachments/KeyboardMatrixAttachment.test.ts} +5 -5
- package/src/tests/IO/{GPIOAttachments/GPIOKeypadAttachment.test.ts → Attachments/KeypadAttachment.test.ts} +38 -38
- package/src/tests/IO/{GPIOAttachments/GPIOLCDAttachment.test.ts → Attachments/LCDAttachment.test.ts} +12 -12
- package/src/tests/IO/Empty.test.ts +143 -0
- package/src/tests/IO/{RAMCard.test.ts → RAMBank.test.ts} +33 -33
- package/src/tests/IO/{RTCCard.test.ts → RTC.test.ts} +6 -6
- package/src/tests/IO/{SoundCard.test.ts → Sound.test.ts} +6 -6
- package/src/tests/IO/{StorageCard.test.ts → Storage.test.ts} +34 -25
- package/src/tests/IO/{GPIOCard.test.ts → VIA.test.ts} +7 -7
- package/src/tests/IO/{VideoCard.test.ts → Video.test.ts} +13 -13
- package/src/tests/Machine.test.ts +31 -38
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for devices that can be attached to GPIO ports
|
|
3
|
+
*/
|
|
4
|
+
export interface Attachment {
|
|
5
|
+
/**
|
|
6
|
+
* Reset the attachment to its initial state
|
|
7
|
+
*/
|
|
8
|
+
reset(): void;
|
|
9
|
+
/**
|
|
10
|
+
* Update the attachment state based on CPU clock ticks
|
|
11
|
+
* @param cpuFrequency - The CPU frequency in Hz
|
|
12
|
+
*/
|
|
13
|
+
tick(cpuFrequency: number): void;
|
|
14
|
+
/**
|
|
15
|
+
* Read data from Port A
|
|
16
|
+
* @param ddr - Data Direction Register value
|
|
17
|
+
* @param or - Output Register value
|
|
18
|
+
* @returns The data to be read from the port
|
|
19
|
+
*/
|
|
20
|
+
readPortA(ddr: number, or: number): number;
|
|
21
|
+
/**
|
|
22
|
+
* Read data from Port B
|
|
23
|
+
* @param ddr - Data Direction Register value
|
|
24
|
+
* @param or - Output Register value
|
|
25
|
+
* @returns The data to be read from the port
|
|
26
|
+
*/
|
|
27
|
+
readPortB(ddr: number, or: number): number;
|
|
28
|
+
/**
|
|
29
|
+
* Write data to Port A
|
|
30
|
+
* @param value - The value being written
|
|
31
|
+
* @param ddr - Data Direction Register value
|
|
32
|
+
*/
|
|
33
|
+
writePortA(value: number, ddr: number): void;
|
|
34
|
+
/**
|
|
35
|
+
* Write data to Port B
|
|
36
|
+
* @param value - The value being written
|
|
37
|
+
* @param ddr - Data Direction Register value
|
|
38
|
+
*/
|
|
39
|
+
writePortB(value: number, ddr: number): void;
|
|
40
|
+
/**
|
|
41
|
+
* Check if the attachment is enabled
|
|
42
|
+
* @returns true if enabled, false otherwise
|
|
43
|
+
*/
|
|
44
|
+
isEnabled(): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Get the priority of this attachment (lower values = higher priority)
|
|
47
|
+
* @returns The priority value
|
|
48
|
+
*/
|
|
49
|
+
getPriority(): number;
|
|
50
|
+
/**
|
|
51
|
+
* Clear interrupt flags
|
|
52
|
+
* @param ca1 - Clear CA1 interrupt
|
|
53
|
+
* @param ca2 - Clear CA2 interrupt
|
|
54
|
+
* @param cb1 - Clear CB1 interrupt
|
|
55
|
+
* @param cb2 - Clear CB2 interrupt
|
|
56
|
+
*/
|
|
57
|
+
clearInterrupts(ca1: boolean, ca2: boolean, cb1: boolean, cb2: boolean): void;
|
|
58
|
+
/**
|
|
59
|
+
* Update control line states
|
|
60
|
+
* @param ca1 - CA1 control line state
|
|
61
|
+
* @param ca2 - CA2 control line state
|
|
62
|
+
* @param cb1 - CB1 control line state
|
|
63
|
+
* @param cb2 - CB2 control line state
|
|
64
|
+
*/
|
|
65
|
+
updateControlLines(ca1: boolean, ca2: boolean, cb1: boolean, cb2: boolean): void;
|
|
66
|
+
/**
|
|
67
|
+
* Check if CA1 interrupt is pending
|
|
68
|
+
* @returns true if interrupt is pending
|
|
69
|
+
*/
|
|
70
|
+
hasCA1Interrupt(): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Check if CA2 interrupt is pending
|
|
73
|
+
* @returns true if interrupt is pending
|
|
74
|
+
*/
|
|
75
|
+
hasCA2Interrupt(): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Check if CB1 interrupt is pending
|
|
78
|
+
* @returns true if interrupt is pending
|
|
79
|
+
*/
|
|
80
|
+
hasCB1Interrupt(): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Check if CB2 interrupt is pending
|
|
83
|
+
* @returns true if interrupt is pending
|
|
84
|
+
*/
|
|
85
|
+
hasCB2Interrupt(): boolean;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Base abstract class for GPIO attachments with common functionality
|
|
89
|
+
*/
|
|
90
|
+
export declare abstract class AttachmentBase implements Attachment {
|
|
91
|
+
protected priority: number;
|
|
92
|
+
protected enabled: boolean;
|
|
93
|
+
protected ca1Interrupt: boolean;
|
|
94
|
+
protected ca2Interrupt: boolean;
|
|
95
|
+
protected cb1Interrupt: boolean;
|
|
96
|
+
protected cb2Interrupt: boolean;
|
|
97
|
+
constructor(priority: number, ca1Interrupt?: boolean, ca2Interrupt?: boolean, cb1Interrupt?: boolean, cb2Interrupt?: boolean);
|
|
98
|
+
reset(): void;
|
|
99
|
+
tick(cpuFrequency: number): void;
|
|
100
|
+
readPortA(ddr: number, or: number): number;
|
|
101
|
+
readPortB(ddr: number, or: number): number;
|
|
102
|
+
writePortA(value: number, ddr: number): void;
|
|
103
|
+
writePortB(value: number, ddr: number): void;
|
|
104
|
+
isEnabled(): boolean;
|
|
105
|
+
getPriority(): number;
|
|
106
|
+
clearInterrupts(ca1: boolean, ca2: boolean, cb1: boolean, cb2: boolean): void;
|
|
107
|
+
updateControlLines(ca1: boolean, ca2: boolean, cb1: boolean, cb2: boolean): void;
|
|
108
|
+
hasCA1Interrupt(): boolean;
|
|
109
|
+
hasCA2Interrupt(): boolean;
|
|
110
|
+
hasCB1Interrupt(): boolean;
|
|
111
|
+
hasCB2Interrupt(): boolean;
|
|
112
|
+
}
|
|
@@ -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
|
+
}
|