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
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { IO } from '../IO';
|
|
2
|
+
/**
|
|
3
|
+
* DS1511Y Real-Time Clock IC Emulation
|
|
4
|
+
*
|
|
5
|
+
* Register Map (0x00-0x1F):
|
|
6
|
+
* 0x00: Seconds (BCD, 00-59)
|
|
7
|
+
* 0x01: Minutes (BCD, 00-59)
|
|
8
|
+
* 0x02: Hours (BCD, 00-23)
|
|
9
|
+
* 0x03: Day of Week (1-7, 1=Sunday)
|
|
10
|
+
* 0x04: Date (BCD, 01-31)
|
|
11
|
+
* 0x05: Month (BCD, 01-12) + Control bits (EOSC, E32K)
|
|
12
|
+
* 0x06: Year (BCD, 00-99)
|
|
13
|
+
* 0x07: Century (BCD, 00-39)
|
|
14
|
+
* 0x08: Alarm Seconds (BCD, 00-59) + AM1 bit
|
|
15
|
+
* 0x09: Alarm Minutes (BCD, 00-59) + AM2 bit
|
|
16
|
+
* 0x0A: Alarm Hours (BCD, 00-23) + AM3 bit
|
|
17
|
+
* 0x0B: Alarm Day/Date + AM4, DY/DT bits
|
|
18
|
+
* 0x0C: Watchdog (0.1 Second and 0.01 Second)
|
|
19
|
+
* 0x0D: Watchdog (0.1 Second and Second)
|
|
20
|
+
* 0x0E: Control A (BLF1, BLF2, PBS, PAB, TDF, KSF, WDF, IRQF)
|
|
21
|
+
* 0x0F: Control B (TE, CS, BME, TPE, TIE, KIE, WDE, WDS)
|
|
22
|
+
* 0x10: RAM Address (Extended RAM Address pointer)
|
|
23
|
+
* 0x11: Reserved
|
|
24
|
+
* 0x12: Reserved
|
|
25
|
+
* 0x13: RAM Data (Extended RAM Data at address pointed to by 0x10)
|
|
26
|
+
*/
|
|
27
|
+
export declare class RTCCard implements IO {
|
|
28
|
+
raiseIRQ: () => void;
|
|
29
|
+
raiseNMI: () => void;
|
|
30
|
+
private userSeconds;
|
|
31
|
+
private userMinutes;
|
|
32
|
+
private userHours;
|
|
33
|
+
private userDayOfWeek;
|
|
34
|
+
private userDate;
|
|
35
|
+
private userMonth;
|
|
36
|
+
private monthControl;
|
|
37
|
+
private userYear;
|
|
38
|
+
private userCentury;
|
|
39
|
+
private internalSeconds;
|
|
40
|
+
private internalMinutes;
|
|
41
|
+
private internalHours;
|
|
42
|
+
private internalDayOfWeek;
|
|
43
|
+
private internalDate;
|
|
44
|
+
private internalMonth;
|
|
45
|
+
private internalYear;
|
|
46
|
+
private internalCentury;
|
|
47
|
+
private alarmSeconds;
|
|
48
|
+
private alarmMinutes;
|
|
49
|
+
private alarmHours;
|
|
50
|
+
private alarmDayDate;
|
|
51
|
+
private watchdog1;
|
|
52
|
+
private watchdog2;
|
|
53
|
+
private watchdogCounterCentis;
|
|
54
|
+
private watchdogCycleCounter;
|
|
55
|
+
private controlA;
|
|
56
|
+
private controlB;
|
|
57
|
+
private ramAddress;
|
|
58
|
+
private ramData;
|
|
59
|
+
private cycleCounter;
|
|
60
|
+
private cpuFrequency;
|
|
61
|
+
private transferCycleCounter;
|
|
62
|
+
private pendingUserToInternal;
|
|
63
|
+
private userSyncNeeded;
|
|
64
|
+
private lastTEEnabled;
|
|
65
|
+
constructor();
|
|
66
|
+
/**
|
|
67
|
+
* Initialize RTC with current system time
|
|
68
|
+
*/
|
|
69
|
+
private initializeWithCurrentTime;
|
|
70
|
+
/**
|
|
71
|
+
* Convert decimal to BCD (Binary Coded Decimal)
|
|
72
|
+
*/
|
|
73
|
+
private decimalToBCD;
|
|
74
|
+
/**
|
|
75
|
+
* Convert BCD to decimal
|
|
76
|
+
*/
|
|
77
|
+
private bcdToDecimal;
|
|
78
|
+
/**
|
|
79
|
+
* Get the number of days in a month
|
|
80
|
+
*/
|
|
81
|
+
private getDaysInMonth;
|
|
82
|
+
/**
|
|
83
|
+
* Get next day of week
|
|
84
|
+
*/
|
|
85
|
+
private getNextDayOfWeek;
|
|
86
|
+
private copyInternalToUser;
|
|
87
|
+
private copyUserToInternal;
|
|
88
|
+
private getTransferCyclesRequired;
|
|
89
|
+
private markUserTimeWrite;
|
|
90
|
+
/**
|
|
91
|
+
* Increment time by one second
|
|
92
|
+
*/
|
|
93
|
+
private incrementTime;
|
|
94
|
+
/**
|
|
95
|
+
* Check if alarm should trigger
|
|
96
|
+
*/
|
|
97
|
+
private checkAlarm;
|
|
98
|
+
private raiseInterruptIfEnabled;
|
|
99
|
+
private setKickstartFlag;
|
|
100
|
+
private decodeWatchdogCentis;
|
|
101
|
+
private reloadWatchdog;
|
|
102
|
+
private stepWatchdog;
|
|
103
|
+
read(address: number): number;
|
|
104
|
+
write(address: number, data: number): void;
|
|
105
|
+
tick(frequency: number): void;
|
|
106
|
+
reset(coldStart: boolean): void;
|
|
107
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { IO } from '../IO';
|
|
2
|
+
/**
|
|
3
|
+
* SerialCard - 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 SerialCard 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,120 @@
|
|
|
1
|
+
import { IO } from '../IO';
|
|
2
|
+
/**
|
|
3
|
+
* MOS 6581 SID (Sound Interface Device) Emulation
|
|
4
|
+
*
|
|
5
|
+
* Register Map ($00-$1C):
|
|
6
|
+
* Voice 1: $00-$06
|
|
7
|
+
* Voice 2: $07-$0D
|
|
8
|
+
* Voice 3: $0E-$14
|
|
9
|
+
* Filter: $15-$17
|
|
10
|
+
* Volume: $18
|
|
11
|
+
* Paddle: $19-$1A (read-only)
|
|
12
|
+
* OSC 3: $1B (read-only)
|
|
13
|
+
* ENV 3: $1C (read-only)
|
|
14
|
+
*
|
|
15
|
+
* Each voice has:
|
|
16
|
+
* Frequency (16-bit, lo/hi)
|
|
17
|
+
* Pulse Width (12-bit, lo/hi)
|
|
18
|
+
* Control Register (waveform select, gate, sync, ring mod, test)
|
|
19
|
+
* Attack/Decay (4-bit each)
|
|
20
|
+
* Sustain/Release (4-bit each)
|
|
21
|
+
*
|
|
22
|
+
* Waveforms: Triangle, Sawtooth, Pulse, Noise
|
|
23
|
+
* Filter: 12-bit cutoff, resonance, low/band/high-pass, voice routing
|
|
24
|
+
*
|
|
25
|
+
* Clock rate: ~1 MHz (NTSC: 1,022,727 Hz, PAL: 985,248 Hz)
|
|
26
|
+
* Output: mono audio samples passed via callback to the host emulator
|
|
27
|
+
*
|
|
28
|
+
* Reference: MOS 6581 SID datasheet, reSID by Dag Lem
|
|
29
|
+
*/
|
|
30
|
+
/** Default SID clock rate (NTSC) */
|
|
31
|
+
export declare const SID_CLOCK_NTSC = 1022727;
|
|
32
|
+
export declare const SID_CLOCK_PAL = 985248;
|
|
33
|
+
export declare const enum EnvelopeState {
|
|
34
|
+
ATTACK = 0,
|
|
35
|
+
DECAY = 1,
|
|
36
|
+
SUSTAIN = 2,
|
|
37
|
+
RELEASE = 3
|
|
38
|
+
}
|
|
39
|
+
export declare class SIDVoice {
|
|
40
|
+
accumulator: number;
|
|
41
|
+
frequency: number;
|
|
42
|
+
pulseWidth: number;
|
|
43
|
+
control: number;
|
|
44
|
+
prevGate: boolean;
|
|
45
|
+
noiseShift: number;
|
|
46
|
+
waveformOutput: number;
|
|
47
|
+
envelopeState: EnvelopeState;
|
|
48
|
+
envelopeLevel: number;
|
|
49
|
+
envelopeCounter: number;
|
|
50
|
+
attackRate: number;
|
|
51
|
+
decayRate: number;
|
|
52
|
+
sustainLevel: number;
|
|
53
|
+
releaseRate: number;
|
|
54
|
+
exponentialCounter: number;
|
|
55
|
+
exponentialCounterPeriod: number;
|
|
56
|
+
reset(): void;
|
|
57
|
+
}
|
|
58
|
+
export declare class Sound implements IO {
|
|
59
|
+
raiseIRQ: () => void;
|
|
60
|
+
raiseNMI: () => void;
|
|
61
|
+
/** Callback to push audio samples to the host emulator */
|
|
62
|
+
pushSamples?: (samples: Float32Array) => void;
|
|
63
|
+
/** Raw register file (write-only from CPU perspective, except reads at $19-$1C) */
|
|
64
|
+
private registers;
|
|
65
|
+
/** Three oscillator voices */
|
|
66
|
+
private voices;
|
|
67
|
+
/** Filter state */
|
|
68
|
+
private filterCutoff;
|
|
69
|
+
private filterResonance;
|
|
70
|
+
private filterRouting;
|
|
71
|
+
private filterMode;
|
|
72
|
+
private masterVolume;
|
|
73
|
+
/** Filter integrator state (continuous) */
|
|
74
|
+
private filterLP;
|
|
75
|
+
private filterBP;
|
|
76
|
+
private filterHP;
|
|
77
|
+
/** Cycle accumulator for sample rate conversion */
|
|
78
|
+
private cycleAccumulator;
|
|
79
|
+
/** Target audio sample rate */
|
|
80
|
+
sampleRate: number;
|
|
81
|
+
/** SID clock rate */
|
|
82
|
+
sidClock: number;
|
|
83
|
+
/** Internal sample buffer for pushing to host */
|
|
84
|
+
private sampleBuffer;
|
|
85
|
+
private sampleBufferIndex;
|
|
86
|
+
read(address: number): number;
|
|
87
|
+
write(address: number, data: number): void;
|
|
88
|
+
tick(frequency: number): void;
|
|
89
|
+
reset(coldStart: boolean): void;
|
|
90
|
+
private updateVoiceRegister;
|
|
91
|
+
private updateGlobalRegister;
|
|
92
|
+
private clockOneCycle;
|
|
93
|
+
private clockOscillator;
|
|
94
|
+
private generateWaveform;
|
|
95
|
+
private clockEnvelope;
|
|
96
|
+
/**
|
|
97
|
+
* Update the exponential counter period based on current envelope level.
|
|
98
|
+
* The real SID uses an exponential curve for decay/release by varying
|
|
99
|
+
* the counter period at specific envelope level thresholds.
|
|
100
|
+
*/
|
|
101
|
+
private updateExponentialPeriod;
|
|
102
|
+
private generateSample;
|
|
103
|
+
/**
|
|
104
|
+
* Convert the 11-bit filter cutoff register value to a frequency in Hz.
|
|
105
|
+
* The SID's cutoff mapping is complex and varies between chips.
|
|
106
|
+
* This approximation covers the usable range (~30 Hz to ~12 kHz).
|
|
107
|
+
*/
|
|
108
|
+
private computeFilterCutoff;
|
|
109
|
+
private flushSampleBuffer;
|
|
110
|
+
/** Get a voice for inspection */
|
|
111
|
+
getVoice(index: number): SIDVoice;
|
|
112
|
+
/** Get current register value */
|
|
113
|
+
getRegister(reg: number): number;
|
|
114
|
+
/** Get current filter cutoff frequency in Hz */
|
|
115
|
+
getFilterCutoffHz(): number;
|
|
116
|
+
/** Get master volume (0-15) */
|
|
117
|
+
getMasterVolume(): number;
|
|
118
|
+
/** Get filter routing bitmask */
|
|
119
|
+
getFilterRouting(): number;
|
|
120
|
+
}
|