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.
- package/README.md +12 -12
- package/dist/components/CPU.d.ts +162 -0
- package/dist/components/Cart.d.ts +9 -0
- 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/DevOutputBoard.d.ts +19 -0
- package/dist/components/IO/DevOutputBoard.js +33 -0
- package/dist/components/IO/DevOutputBoard.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/EmptyCard.d.ts +9 -0
- package/dist/components/IO/GPIOAttachments/GPIOAttachment.d.ts +112 -0
- package/dist/components/IO/GPIOAttachments/GPIOJoystickAttachment.d.ts +53 -0
- package/dist/components/IO/GPIOAttachments/GPIOKeyboardEncoderAttachment.d.ts +63 -0
- package/dist/components/IO/GPIOAttachments/GPIOKeyboardMatrixAttachment.d.ts +44 -0
- package/dist/components/IO/GPIOAttachments/GPIOKeypadAttachment.d.ts +47 -0
- package/dist/components/IO/GPIOAttachments/GPIOLCDAttachment.d.ts +110 -0
- package/dist/components/IO/GPIOCard.d.ts +105 -0
- 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/RAMCard.d.ts +37 -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/RTCCard.d.ts +107 -0
- package/dist/components/IO/SerialCard.d.ts +76 -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/SoundCard.d.ts +120 -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/StorageCard.d.ts +74 -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/IO/VideoCard.d.ts +141 -0
- package/dist/components/IO.d.ts +8 -0
- package/dist/components/Machine.d.ts +62 -0
- package/dist/components/Machine.js +260 -153
- package/dist/components/Machine.js.map +1 -1
- package/dist/components/RAM.d.ts +9 -0
- package/dist/components/ROM.d.ts +9 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +61 -28
- package/dist/index.js.map +1 -1
- package/dist/lib.d.ts +22 -0
- package/dist/lib.js +47 -0
- package/dist/lib.js.map +1 -0
- package/dist/tests/CPU.test.d.ts +1 -0
- package/dist/tests/Cart.test.d.ts +1 -0
- 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/GPIOAttachments/GPIOAttachment.test.d.ts +1 -0
- package/dist/tests/IO/GPIOAttachments/GPIOJoystickAttachment.test.d.ts +1 -0
- package/dist/tests/IO/GPIOAttachments/GPIOKeyboardEncoderAttachment.test.d.ts +1 -0
- package/dist/tests/IO/GPIOAttachments/GPIOKeyboardMatrixAttachment.test.d.ts +1 -0
- package/dist/tests/IO/GPIOAttachments/GPIOKeypadAttachment.test.d.ts +1 -0
- package/dist/tests/IO/GPIOAttachments/GPIOLCDAttachment.test.d.ts +1 -0
- package/dist/tests/IO/GPIOCard.test.d.ts +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/RAMCard.test.d.ts +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/RTCCard.test.d.ts +1 -0
- package/dist/tests/IO/SerialCard.test.d.ts +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/SoundCard.test.d.ts +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/StorageCard.test.d.ts +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/IO/VideoCard.test.d.ts +1 -0
- package/dist/tests/Machine.test.d.ts +1 -0
- package/dist/tests/Machine.test.js +27 -42
- package/dist/tests/Machine.test.js.map +1 -1
- package/dist/tests/RAM.test.d.ts +1 -0
- package/dist/tests/ROM.test.d.ts +1 -0
- package/package.json +5 -3
- 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/Terminal.ts +34 -0
- 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 +286 -160
- package/src/index.ts +65 -35
- package/src/lib.ts +27 -0
- 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
- package/tsconfig.json +1 -0
package/README.md
CHANGED
|
@@ -183,18 +183,18 @@ src/
|
|
|
183
183
|
│ ├── Cart.ts # Cartridge support
|
|
184
184
|
│ ├── IO.ts # I/O interface
|
|
185
185
|
│ └── IO/ # I/O peripheral implementations
|
|
186
|
-
│ ├──
|
|
187
|
-
│ ├──
|
|
188
|
-
│ ├──
|
|
189
|
-
│ ├──
|
|
190
|
-
│ ├──
|
|
191
|
-
│ ├──
|
|
192
|
-
│ ├──
|
|
193
|
-
│ └──
|
|
194
|
-
│ ├──
|
|
195
|
-
│ ├──
|
|
196
|
-
│ ├──
|
|
197
|
-
│ └──
|
|
186
|
+
│ ├── VIA.ts
|
|
187
|
+
│ ├── RAMBank.ts
|
|
188
|
+
│ ├── RTC.ts
|
|
189
|
+
│ ├── ACIA.ts
|
|
190
|
+
│ ├── Sound.ts
|
|
191
|
+
│ ├── Storage.ts
|
|
192
|
+
│ ├── Video.ts
|
|
193
|
+
│ └── Attachments/
|
|
194
|
+
│ ├── Attachment.ts
|
|
195
|
+
│ ├── JoystickAttachment.ts
|
|
196
|
+
│ ├── KeyboardEncoderAttachment.ts
|
|
197
|
+
│ └── KeyboardMatrixAttachment.ts
|
|
198
198
|
└── tests/ # Comprehensive test suite
|
|
199
199
|
```
|
|
200
200
|
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
export interface CPUInstruction {
|
|
2
|
+
name: string;
|
|
3
|
+
cycles: number;
|
|
4
|
+
opcode: () => number;
|
|
5
|
+
addrMode: () => number;
|
|
6
|
+
}
|
|
7
|
+
export declare class CPU {
|
|
8
|
+
static C: number;
|
|
9
|
+
static Z: number;
|
|
10
|
+
static I: number;
|
|
11
|
+
static D: number;
|
|
12
|
+
static B: number;
|
|
13
|
+
static U: number;
|
|
14
|
+
static V: number;
|
|
15
|
+
static N: number;
|
|
16
|
+
private fetched;
|
|
17
|
+
private temp;
|
|
18
|
+
private addrAbs;
|
|
19
|
+
private addrRel;
|
|
20
|
+
private opcode;
|
|
21
|
+
cyclesRem: number;
|
|
22
|
+
cycles: number;
|
|
23
|
+
a: number;
|
|
24
|
+
x: number;
|
|
25
|
+
y: number;
|
|
26
|
+
pc: number;
|
|
27
|
+
sp: number;
|
|
28
|
+
st: number;
|
|
29
|
+
read: (address: number) => number;
|
|
30
|
+
write: (address: number, data: number) => void;
|
|
31
|
+
constructor(read: (address: number) => number, write: (address: number, data: number) => void);
|
|
32
|
+
reset(): void;
|
|
33
|
+
irq(): void;
|
|
34
|
+
nmi(): void;
|
|
35
|
+
tick(): void;
|
|
36
|
+
step(): number;
|
|
37
|
+
private fetch;
|
|
38
|
+
private getFlag;
|
|
39
|
+
private setFlag;
|
|
40
|
+
private incPC;
|
|
41
|
+
private decPC;
|
|
42
|
+
private incSP;
|
|
43
|
+
private decSP;
|
|
44
|
+
private IMP;
|
|
45
|
+
private IMM;
|
|
46
|
+
private ZP0;
|
|
47
|
+
private ZPX;
|
|
48
|
+
private ZPY;
|
|
49
|
+
private REL;
|
|
50
|
+
private ABS;
|
|
51
|
+
private ABX;
|
|
52
|
+
private ABY;
|
|
53
|
+
private IND;
|
|
54
|
+
private IZX;
|
|
55
|
+
private IZY;
|
|
56
|
+
private IAX;
|
|
57
|
+
private ZPR;
|
|
58
|
+
private ADC;
|
|
59
|
+
private AND;
|
|
60
|
+
private ASL;
|
|
61
|
+
private BCC;
|
|
62
|
+
private BCS;
|
|
63
|
+
private BEQ;
|
|
64
|
+
private BIT;
|
|
65
|
+
private BMI;
|
|
66
|
+
private BNE;
|
|
67
|
+
private BPL;
|
|
68
|
+
private BRK;
|
|
69
|
+
private BVC;
|
|
70
|
+
private BVS;
|
|
71
|
+
private CLC;
|
|
72
|
+
private CLD;
|
|
73
|
+
private CLI;
|
|
74
|
+
private CLV;
|
|
75
|
+
private CMP;
|
|
76
|
+
private CPX;
|
|
77
|
+
private CPY;
|
|
78
|
+
private DEC;
|
|
79
|
+
private DEX;
|
|
80
|
+
private DEY;
|
|
81
|
+
private EOR;
|
|
82
|
+
private INC;
|
|
83
|
+
private INX;
|
|
84
|
+
private INY;
|
|
85
|
+
private JMP;
|
|
86
|
+
private JSR;
|
|
87
|
+
private LDA;
|
|
88
|
+
private LDX;
|
|
89
|
+
private LDY;
|
|
90
|
+
private LSR;
|
|
91
|
+
private NOP;
|
|
92
|
+
private ORA;
|
|
93
|
+
private PHA;
|
|
94
|
+
private PHP;
|
|
95
|
+
private PLA;
|
|
96
|
+
private PLP;
|
|
97
|
+
private ROL;
|
|
98
|
+
private ROR;
|
|
99
|
+
private RTI;
|
|
100
|
+
private RTS;
|
|
101
|
+
private SBC;
|
|
102
|
+
private SEC;
|
|
103
|
+
private SED;
|
|
104
|
+
private SEI;
|
|
105
|
+
private STA;
|
|
106
|
+
private STX;
|
|
107
|
+
private STY;
|
|
108
|
+
private TAX;
|
|
109
|
+
private TAY;
|
|
110
|
+
private TSX;
|
|
111
|
+
private TXA;
|
|
112
|
+
private TXS;
|
|
113
|
+
private TYA;
|
|
114
|
+
private BRA;
|
|
115
|
+
private PHX;
|
|
116
|
+
private PHY;
|
|
117
|
+
private PLX;
|
|
118
|
+
private PLY;
|
|
119
|
+
private STZ;
|
|
120
|
+
private TRB;
|
|
121
|
+
private TSB;
|
|
122
|
+
private STP;
|
|
123
|
+
private WAI;
|
|
124
|
+
private BBR;
|
|
125
|
+
private BBR0;
|
|
126
|
+
private BBR1;
|
|
127
|
+
private BBR2;
|
|
128
|
+
private BBR3;
|
|
129
|
+
private BBR4;
|
|
130
|
+
private BBR5;
|
|
131
|
+
private BBR6;
|
|
132
|
+
private BBR7;
|
|
133
|
+
private BBS;
|
|
134
|
+
private BBS0;
|
|
135
|
+
private BBS1;
|
|
136
|
+
private BBS2;
|
|
137
|
+
private BBS3;
|
|
138
|
+
private BBS4;
|
|
139
|
+
private BBS5;
|
|
140
|
+
private BBS6;
|
|
141
|
+
private BBS7;
|
|
142
|
+
private RMB;
|
|
143
|
+
private RMB0;
|
|
144
|
+
private RMB1;
|
|
145
|
+
private RMB2;
|
|
146
|
+
private RMB3;
|
|
147
|
+
private RMB4;
|
|
148
|
+
private RMB5;
|
|
149
|
+
private RMB6;
|
|
150
|
+
private RMB7;
|
|
151
|
+
private SMB;
|
|
152
|
+
private SMB0;
|
|
153
|
+
private SMB1;
|
|
154
|
+
private SMB2;
|
|
155
|
+
private SMB3;
|
|
156
|
+
private SMB4;
|
|
157
|
+
private SMB5;
|
|
158
|
+
private SMB6;
|
|
159
|
+
private SMB7;
|
|
160
|
+
private XXX;
|
|
161
|
+
instructionTable: CPUInstruction[];
|
|
162
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { IO } from '../IO';
|
|
2
|
+
/**
|
|
3
|
+
* ACIA - Emulates a 6551 ACIA (Asynchronous Communications Interface Adapter)
|
|
4
|
+
*
|
|
5
|
+
* Register Map:
|
|
6
|
+
* $00: Data Register (read/write)
|
|
7
|
+
* $01: Status Register (read) / Programmed Reset (write)
|
|
8
|
+
* $02: Command Register (write)
|
|
9
|
+
* $03: Control Register (write)
|
|
10
|
+
*/
|
|
11
|
+
export declare class ACIA implements IO {
|
|
12
|
+
raiseIRQ: () => void;
|
|
13
|
+
raiseNMI: () => void;
|
|
14
|
+
transmit?: (data: number) => void;
|
|
15
|
+
private dataRegister;
|
|
16
|
+
private statusRegister;
|
|
17
|
+
private commandRegister;
|
|
18
|
+
private controlRegister;
|
|
19
|
+
private transmitBuffer;
|
|
20
|
+
private receiveBuffer;
|
|
21
|
+
private parityError;
|
|
22
|
+
private framingError;
|
|
23
|
+
private overrun;
|
|
24
|
+
private irqFlag;
|
|
25
|
+
private echoMode;
|
|
26
|
+
private cycleCounter;
|
|
27
|
+
private baudRate;
|
|
28
|
+
/**
|
|
29
|
+
* Read from ACIA register
|
|
30
|
+
*/
|
|
31
|
+
read(address: number): number;
|
|
32
|
+
/**
|
|
33
|
+
* Write to ACIA register
|
|
34
|
+
*/
|
|
35
|
+
write(address: number, data: number): void;
|
|
36
|
+
/**
|
|
37
|
+
* Read data from receive buffer
|
|
38
|
+
*/
|
|
39
|
+
private readData;
|
|
40
|
+
/**
|
|
41
|
+
* Write data to transmit buffer
|
|
42
|
+
*/
|
|
43
|
+
private writeData;
|
|
44
|
+
/**
|
|
45
|
+
* Read status register
|
|
46
|
+
*/
|
|
47
|
+
private readStatus;
|
|
48
|
+
/**
|
|
49
|
+
* Write to command register
|
|
50
|
+
*/
|
|
51
|
+
private writeCommand;
|
|
52
|
+
/**
|
|
53
|
+
* Write to control register
|
|
54
|
+
*/
|
|
55
|
+
private writeControl;
|
|
56
|
+
/**
|
|
57
|
+
* Get baud rate from control register code
|
|
58
|
+
*/
|
|
59
|
+
private getBaudRate;
|
|
60
|
+
/**
|
|
61
|
+
* Programmed reset
|
|
62
|
+
*/
|
|
63
|
+
private programmedReset;
|
|
64
|
+
/**
|
|
65
|
+
* Tick - emulate ACIA timing
|
|
66
|
+
*/
|
|
67
|
+
tick(frequency: number): void;
|
|
68
|
+
/**
|
|
69
|
+
* Reset the ACIA
|
|
70
|
+
*/
|
|
71
|
+
reset(coldStart: boolean): void;
|
|
72
|
+
/**
|
|
73
|
+
* Receive data from external source
|
|
74
|
+
*/
|
|
75
|
+
onData(data: number): void;
|
|
76
|
+
}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ACIA = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* ACIA - Emulates a 6551 ACIA (Asynchronous Communications Interface Adapter)
|
|
6
|
+
*
|
|
7
|
+
* Register Map:
|
|
8
|
+
* $00: Data Register (read/write)
|
|
9
|
+
* $01: Status Register (read) / Programmed Reset (write)
|
|
10
|
+
* $02: Command Register (write)
|
|
11
|
+
* $03: Control Register (write)
|
|
12
|
+
*/
|
|
13
|
+
class ACIA {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.raiseIRQ = () => { };
|
|
16
|
+
this.raiseNMI = () => { };
|
|
17
|
+
// Registers
|
|
18
|
+
this.dataRegister = 0;
|
|
19
|
+
this.statusRegister = 0x10; // Transmit Data Register Empty
|
|
20
|
+
this.commandRegister = 0;
|
|
21
|
+
this.controlRegister = 0;
|
|
22
|
+
// Buffers
|
|
23
|
+
this.transmitBuffer = [];
|
|
24
|
+
this.receiveBuffer = [];
|
|
25
|
+
// Status flags
|
|
26
|
+
this.parityError = false;
|
|
27
|
+
this.framingError = false;
|
|
28
|
+
this.overrun = false;
|
|
29
|
+
this.irqFlag = false;
|
|
30
|
+
this.echoMode = false;
|
|
31
|
+
// Timing
|
|
32
|
+
this.cycleCounter = 0;
|
|
33
|
+
this.baudRate = 115200;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Read from ACIA register
|
|
37
|
+
*/
|
|
38
|
+
read(address) {
|
|
39
|
+
const register = address & 0x03;
|
|
40
|
+
switch (register) {
|
|
41
|
+
case 0x00: // Data Register
|
|
42
|
+
return this.readData();
|
|
43
|
+
case 0x01: // Status Register
|
|
44
|
+
return this.readStatus();
|
|
45
|
+
case 0x02: // Command Register
|
|
46
|
+
return this.commandRegister;
|
|
47
|
+
case 0x03: // Control Register
|
|
48
|
+
return this.controlRegister;
|
|
49
|
+
default:
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Write to ACIA register
|
|
55
|
+
*/
|
|
56
|
+
write(address, data) {
|
|
57
|
+
const register = address & 0x03;
|
|
58
|
+
switch (register) {
|
|
59
|
+
case 0x00: // Data Register
|
|
60
|
+
this.writeData(data);
|
|
61
|
+
break;
|
|
62
|
+
case 0x01: // Programmed Reset
|
|
63
|
+
this.programmedReset();
|
|
64
|
+
break;
|
|
65
|
+
case 0x02: // Command Register
|
|
66
|
+
this.writeCommand(data);
|
|
67
|
+
break;
|
|
68
|
+
case 0x03: // Control Register
|
|
69
|
+
this.writeControl(data);
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Read data from receive buffer
|
|
75
|
+
*/
|
|
76
|
+
readData() {
|
|
77
|
+
if (this.receiveBuffer.length > 0) {
|
|
78
|
+
const data = this.receiveBuffer.shift();
|
|
79
|
+
this.dataRegister = data;
|
|
80
|
+
// Update status: clear Receive Data Register Full
|
|
81
|
+
this.statusRegister &= ~0x08;
|
|
82
|
+
// Check for overrun if more data arrives
|
|
83
|
+
if (this.receiveBuffer.length === 0) {
|
|
84
|
+
this.overrun = false;
|
|
85
|
+
this.statusRegister &= ~0x04;
|
|
86
|
+
}
|
|
87
|
+
// Clear IRQ if receive IRQ was enabled
|
|
88
|
+
if ((this.commandRegister & 0x04) && this.receiveBuffer.length === 0) {
|
|
89
|
+
this.irqFlag = false;
|
|
90
|
+
this.statusRegister &= ~0x80;
|
|
91
|
+
}
|
|
92
|
+
return data;
|
|
93
|
+
}
|
|
94
|
+
return this.dataRegister;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Write data to transmit buffer
|
|
98
|
+
*/
|
|
99
|
+
writeData(data) {
|
|
100
|
+
this.transmitBuffer.push(data & 0xFF);
|
|
101
|
+
// Clear Transmit Data Register Empty flag
|
|
102
|
+
this.statusRegister &= ~0x10;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Read status register
|
|
106
|
+
*/
|
|
107
|
+
readStatus() {
|
|
108
|
+
let status = 0;
|
|
109
|
+
// Bit 0: Parity Error
|
|
110
|
+
if (this.parityError)
|
|
111
|
+
status |= 0x01;
|
|
112
|
+
// Bit 1: Framing Error
|
|
113
|
+
if (this.framingError)
|
|
114
|
+
status |= 0x02;
|
|
115
|
+
// Bit 2: Overrun
|
|
116
|
+
if (this.overrun)
|
|
117
|
+
status |= 0x04;
|
|
118
|
+
// Bit 3: Receive Data Register Full
|
|
119
|
+
if (this.receiveBuffer.length > 0)
|
|
120
|
+
status |= 0x08;
|
|
121
|
+
// Bit 4: Transmit Data Register Empty
|
|
122
|
+
if (this.transmitBuffer.length === 0)
|
|
123
|
+
status |= 0x10;
|
|
124
|
+
// Bit 5: Data Carrier Detect (DCD) - always clear (connected)
|
|
125
|
+
status &= ~0x20;
|
|
126
|
+
// Bit 6: Data Set Ready (DSR) - always set (ready)
|
|
127
|
+
status |= 0x40;
|
|
128
|
+
// Bit 7: Interrupt (IRQ)
|
|
129
|
+
if (this.irqFlag)
|
|
130
|
+
status |= 0x80;
|
|
131
|
+
this.statusRegister = status;
|
|
132
|
+
return status;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Write to command register
|
|
136
|
+
*/
|
|
137
|
+
writeCommand(data) {
|
|
138
|
+
this.commandRegister = data & 0xFF;
|
|
139
|
+
// Bits 0-1: DTR control
|
|
140
|
+
// const dtrControl = data & 0x03
|
|
141
|
+
// Bit 2: Receive IRQ Enable
|
|
142
|
+
const receiveIRQEnabled = (data & 0x04) !== 0;
|
|
143
|
+
// Bits 3-4: Transmit control and IRQ enable
|
|
144
|
+
// const transmitControl = (data >> 3) & 0x03
|
|
145
|
+
// Bit 5: Echo mode
|
|
146
|
+
this.echoMode = (data & 0x20) !== 0;
|
|
147
|
+
// Bits 6-7: Parity control
|
|
148
|
+
// const parityControl = (data >> 6) & 0x03
|
|
149
|
+
// Handle receive IRQ
|
|
150
|
+
if (receiveIRQEnabled && this.receiveBuffer.length > 0) {
|
|
151
|
+
this.irqFlag = true;
|
|
152
|
+
this.statusRegister |= 0x80;
|
|
153
|
+
this.raiseIRQ();
|
|
154
|
+
}
|
|
155
|
+
else if (!receiveIRQEnabled) {
|
|
156
|
+
this.irqFlag = false;
|
|
157
|
+
this.statusRegister &= ~0x80;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Write to control register
|
|
162
|
+
*/
|
|
163
|
+
writeControl(data) {
|
|
164
|
+
this.controlRegister = data & 0xFF;
|
|
165
|
+
// Bits 0-3: Baud rate
|
|
166
|
+
const baudRateCode = data & 0x0F;
|
|
167
|
+
this.baudRate = this.getBaudRate(baudRateCode);
|
|
168
|
+
// Bit 4: Receiver clock source (internal/external)
|
|
169
|
+
const receiverClockSource = (data & 0x10) !== 0;
|
|
170
|
+
// Bits 5-6: Word length (5, 6, 7, or 8 bits)
|
|
171
|
+
const wordLength = ((data >> 5) & 0x03) + 5;
|
|
172
|
+
// Bit 7: Stop bits (1 or 2)
|
|
173
|
+
const stopBits = (data & 0x80) ? 2 : 1;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Get baud rate from control register code
|
|
177
|
+
*/
|
|
178
|
+
getBaudRate(code) {
|
|
179
|
+
const baudRates = [
|
|
180
|
+
115200, // 0000 (actually 16x external clock, using 115200 as default)
|
|
181
|
+
50, // 0001
|
|
182
|
+
75, // 0010
|
|
183
|
+
110, // 0011
|
|
184
|
+
135, // 0100
|
|
185
|
+
150, // 0101
|
|
186
|
+
300, // 0110
|
|
187
|
+
600, // 0111
|
|
188
|
+
1200, // 1000
|
|
189
|
+
1800, // 1001
|
|
190
|
+
2400, // 1010
|
|
191
|
+
3600, // 1011
|
|
192
|
+
4800, // 1100
|
|
193
|
+
7200, // 1101
|
|
194
|
+
9600, // 1110
|
|
195
|
+
19200 // 1111
|
|
196
|
+
];
|
|
197
|
+
return baudRates[code] || 115200;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Programmed reset
|
|
201
|
+
*/
|
|
202
|
+
programmedReset() {
|
|
203
|
+
this.statusRegister = 0x10; // Transmit Data Register Empty
|
|
204
|
+
this.parityError = false;
|
|
205
|
+
this.framingError = false;
|
|
206
|
+
this.overrun = false;
|
|
207
|
+
this.irqFlag = false;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Tick - emulate ACIA timing
|
|
211
|
+
*/
|
|
212
|
+
tick(frequency) {
|
|
213
|
+
this.cycleCounter++;
|
|
214
|
+
// Calculate cycles per byte: (CPU_CLOCK / baud_rate) * bits_per_frame
|
|
215
|
+
// Assuming 10 bits per frame (1 start + 8 data + 1 stop)
|
|
216
|
+
const cyclesPerByte = Math.floor((frequency / this.baudRate) * 10);
|
|
217
|
+
// Simulate transmission based on actual baud rate
|
|
218
|
+
if (this.cycleCounter >= cyclesPerByte && this.transmitBuffer.length > 0) {
|
|
219
|
+
this.cycleCounter = 0;
|
|
220
|
+
// Transmit one byte
|
|
221
|
+
const byte = this.transmitBuffer.shift();
|
|
222
|
+
if (byte !== undefined && this.transmit) {
|
|
223
|
+
this.transmit(byte);
|
|
224
|
+
}
|
|
225
|
+
// Set Transmit Data Register Empty if buffer is empty
|
|
226
|
+
if (this.transmitBuffer.length === 0) {
|
|
227
|
+
this.statusRegister |= 0x10;
|
|
228
|
+
// Trigger transmit complete IRQ if enabled
|
|
229
|
+
if ((this.commandRegister & 0x18) === 0x08) {
|
|
230
|
+
this.irqFlag = true;
|
|
231
|
+
this.statusRegister |= 0x80;
|
|
232
|
+
this.raiseIRQ();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Reset the ACIA
|
|
239
|
+
*/
|
|
240
|
+
reset(coldStart) {
|
|
241
|
+
this.dataRegister = 0;
|
|
242
|
+
this.statusRegister = 0x10; // Transmit Data Register Empty
|
|
243
|
+
this.commandRegister = 0;
|
|
244
|
+
this.controlRegister = 0;
|
|
245
|
+
this.transmitBuffer = [];
|
|
246
|
+
this.receiveBuffer = [];
|
|
247
|
+
this.parityError = false;
|
|
248
|
+
this.framingError = false;
|
|
249
|
+
this.overrun = false;
|
|
250
|
+
this.irqFlag = false;
|
|
251
|
+
this.echoMode = false;
|
|
252
|
+
this.cycleCounter = 0;
|
|
253
|
+
this.baudRate = 115200;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Receive data from external source
|
|
257
|
+
*/
|
|
258
|
+
onData(data) {
|
|
259
|
+
if (this.receiveBuffer.length > 0 && (this.statusRegister & 0x08)) {
|
|
260
|
+
// Overrun condition: data arrives before previous data was read
|
|
261
|
+
this.overrun = true;
|
|
262
|
+
this.statusRegister |= 0x04;
|
|
263
|
+
}
|
|
264
|
+
this.receiveBuffer.push(data & 0xFF);
|
|
265
|
+
// Set Receive Data Register Full flag
|
|
266
|
+
this.statusRegister |= 0x08;
|
|
267
|
+
// Trigger receive IRQ if enabled
|
|
268
|
+
if (this.commandRegister & 0x04) {
|
|
269
|
+
this.irqFlag = true;
|
|
270
|
+
this.statusRegister |= 0x80;
|
|
271
|
+
this.raiseIRQ();
|
|
272
|
+
}
|
|
273
|
+
// Echo mode: automatically transmit received data
|
|
274
|
+
if (this.echoMode) {
|
|
275
|
+
this.transmitBuffer.push(data & 0xFF);
|
|
276
|
+
// Clear Transmit Data Register Empty flag
|
|
277
|
+
this.statusRegister &= ~0x10;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
exports.ACIA = ACIA;
|
|
282
|
+
//# sourceMappingURL=ACIA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ACIA.js","sourceRoot":"","sources":["../../../src/components/IO/ACIA.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;GAQG;AACH,MAAa,IAAI;IAAjB;QAEE,aAAQ,GAAG,GAAG,EAAE,GAAE,CAAC,CAAA;QACnB,aAAQ,GAAG,GAAG,EAAE,GAAE,CAAC,CAAA;QAGnB,YAAY;QACJ,iBAAY,GAAW,CAAC,CAAA;QACxB,mBAAc,GAAW,IAAI,CAAA,CAAE,+BAA+B;QAC9D,oBAAe,GAAW,CAAC,CAAA;QAC3B,oBAAe,GAAW,CAAC,CAAA;QAEnC,UAAU;QACF,mBAAc,GAAa,EAAE,CAAA;QAC7B,kBAAa,GAAa,EAAE,CAAA;QAEpC,eAAe;QACP,gBAAW,GAAY,KAAK,CAAA;QAC5B,iBAAY,GAAY,KAAK,CAAA;QAC7B,YAAO,GAAY,KAAK,CAAA;QACxB,YAAO,GAAY,KAAK,CAAA;QACxB,aAAQ,GAAY,KAAK,CAAA;QAEjC,SAAS;QACD,iBAAY,GAAW,CAAC,CAAA;QACxB,aAAQ,GAAW,MAAM,CAAA;IA0SnC,CAAC;IAxSC;;OAEG;IACH,IAAI,CAAC,OAAe;QAClB,MAAM,QAAQ,GAAG,OAAO,GAAG,IAAI,CAAA;QAE/B,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,IAAI,EAAE,gBAAgB;gBACzB,OAAO,IAAI,CAAC,QAAQ,EAAE,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GAAG,MAAM,CAAA;IACxB,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAY;QACjB,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,EAAE,CAAC;YAClE,gEAAgE;YAChE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;YACnB,IAAI,CAAC,cAAc,IAAI,IAAI,CAAA;QAC7B,CAAC;QAED,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAA;QAEpC,sCAAsC;QACtC,IAAI,CAAC,cAAc,IAAI,IAAI,CAAA;QAE3B,iCAAiC;QACjC,IAAI,IAAI,CAAC,eAAe,GAAG,IAAI,EAAE,CAAC;YAChC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;YACnB,IAAI,CAAC,cAAc,IAAI,IAAI,CAAA;YAC3B,IAAI,CAAC,QAAQ,EAAE,CAAA;QACjB,CAAC;QAED,kDAAkD;QAClD,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAA;YACrC,0CAA0C;YAC1C,IAAI,CAAC,cAAc,IAAI,CAAC,IAAI,CAAA;QAC9B,CAAC;IACH,CAAC;CACF;AAnUD,oBAmUC"}
|
|
@@ -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
|
+
}
|