ac6502 1.8.0 → 1.9.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 +9 -9
- package/dist/components/IO/ACIA.d.ts +1 -1
- package/dist/components/IO/ACIA.js +1 -1
- package/dist/components/IO/Attachments/LCDAttachment.d.ts +1 -1
- package/dist/components/IO/Attachments/LCDAttachment.js +1 -1
- package/dist/components/IO/RTC.d.ts +1 -1
- package/dist/components/IO/RTC.js +3 -3
- package/dist/components/IO/RTC.js.map +1 -1
- package/dist/components/IO/VIA.d.ts +3 -3
- package/dist/components/IO/VIA.js +10 -8
- package/dist/components/IO/VIA.js.map +1 -1
- package/dist/components/IO/Video.js +3 -2
- package/dist/components/IO/Video.js.map +1 -1
- package/dist/components/Machine.js +14 -4
- package/dist/components/Machine.js.map +1 -1
- package/dist/index.js +3 -32
- package/dist/index.js.map +1 -1
- package/dist/lib.d.ts +0 -1
- package/dist/lib.js +1 -3
- package/dist/lib.js.map +1 -1
- package/dist/tests/IO/ACIA.test.js +1 -1
- package/dist/tests/IO/ACIA.test.js.map +1 -1
- package/dist/tests/IO/RTC.test.js +1 -1
- package/dist/tests/IO/RTC.test.js.map +1 -1
- package/dist/tests/IO/VIA.test.js +1 -1
- package/dist/tests/IO/VIA.test.js.map +1 -1
- package/package.json +1 -1
- package/src/components/IO/ACIA.ts +1 -1
- package/src/components/IO/Attachments/LCDAttachment.ts +1 -1
- package/src/components/IO/RTC.ts +3 -3
- package/src/components/IO/VIA.ts +10 -8
- package/src/components/IO/Video.ts +3 -2
- package/src/components/Machine.ts +16 -4
- package/src/index.ts +3 -34
- package/src/lib.ts +0 -1
- package/src/tests/IO/ACIA.test.ts +1 -1
- package/src/tests/IO/RTC.test.ts +1 -1
- package/src/tests/IO/VIA.test.ts +1 -1
- package/src/components/IO/Terminal.ts +0 -34
|
@@ -15,7 +15,6 @@ import { JoystickAttachment } from './IO/Attachments/JoystickAttachment'
|
|
|
15
15
|
import { LCDAttachment } from './IO/Attachments/LCDAttachment'
|
|
16
16
|
import { KeypadAttachment } from './IO/Attachments/KeypadAttachment'
|
|
17
17
|
import { Empty } from './IO/Empty'
|
|
18
|
-
import { Terminal } from './IO/Terminal'
|
|
19
18
|
import { IO } from './IO'
|
|
20
19
|
|
|
21
20
|
export class Machine {
|
|
@@ -146,23 +145,36 @@ export class Machine {
|
|
|
146
145
|
const rtc = new RTC()
|
|
147
146
|
const storage = new Storage()
|
|
148
147
|
const via = new VIA()
|
|
148
|
+
const sound = new Sound()
|
|
149
|
+
const video = new Video()
|
|
149
150
|
|
|
150
151
|
this.io1 = new RAMBank()
|
|
151
152
|
this.io2 = new RAMBank()
|
|
152
153
|
this.io3 = rtc
|
|
153
154
|
this.io4 = storage
|
|
154
155
|
this.io6 = via
|
|
155
|
-
this.io7 =
|
|
156
|
-
this.io8 =
|
|
156
|
+
this.io7 = sound
|
|
157
|
+
this.io8 = video
|
|
157
158
|
|
|
158
159
|
// Connect RTC IRQ/NMI to CPU
|
|
159
160
|
rtc.raiseIRQ = () => this.cpu.irq()
|
|
160
161
|
rtc.raiseNMI = () => this.cpu.nmi()
|
|
161
162
|
|
|
162
|
-
// Connect
|
|
163
|
+
// Connect Video IRQ/NMI to CPU
|
|
164
|
+
video.raiseIRQ = () => this.cpu.irq()
|
|
165
|
+
video.raiseNMI = () => this.cpu.nmi()
|
|
166
|
+
|
|
167
|
+
// Connect GPIO VIA IRQ/NMI to CPU
|
|
163
168
|
via.raiseIRQ = () => this.cpu.irq()
|
|
164
169
|
via.raiseNMI = () => this.cpu.nmi()
|
|
165
170
|
|
|
171
|
+
// Connect Sound pushSamples callback
|
|
172
|
+
sound.pushSamples = (samples: Float32Array) => {
|
|
173
|
+
if (this.play) {
|
|
174
|
+
this.play(samples)
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
166
178
|
// Create standard GPIO attachments
|
|
167
179
|
this.keyboardMatrixAttachment = new KeyboardMatrixAttachment(10)
|
|
168
180
|
this.keyboardEncoderAttachment = new KeyboardEncoderAttachment(20)
|
package/src/index.ts
CHANGED
|
@@ -5,14 +5,13 @@ import { Machine } from './components/Machine'
|
|
|
5
5
|
import { Command, Option } from 'commander'
|
|
6
6
|
import { SerialPort } from 'serialport'
|
|
7
7
|
import { Video } from './components/IO/Video'
|
|
8
|
-
import { Terminal } from './components/IO/Terminal'
|
|
9
8
|
import { Storage } from './components/IO/Storage'
|
|
10
9
|
import { Sound } from './components/IO/Sound'
|
|
11
10
|
import sdl from '@kmamal/sdl'
|
|
12
11
|
import { readFile, writeFile } from 'fs/promises'
|
|
13
12
|
import { existsSync } from 'fs'
|
|
14
13
|
|
|
15
|
-
const VERSION = '1.
|
|
14
|
+
const VERSION = '1.9.1'
|
|
16
15
|
const WIDTH = 320
|
|
17
16
|
const HEIGHT = 240
|
|
18
17
|
|
|
@@ -364,40 +363,10 @@ class Emulator {
|
|
|
364
363
|
this.window.render(WIDTH, HEIGHT, WIDTH * 4, 'rgba32', Video.buffer)
|
|
365
364
|
}
|
|
366
365
|
} else if (this.options.target === 'dev') {
|
|
367
|
-
const
|
|
368
|
-
const rgbaBuffer = Buffer.alloc(WIDTH * HEIGHT * 4)
|
|
366
|
+
const video = this.machine.io8 as Video
|
|
369
367
|
this.machine.render = () => {
|
|
370
368
|
if (!this.window) { return }
|
|
371
|
-
|
|
372
|
-
for (let i = 0; i < WIDTH * HEIGHT; i++) {
|
|
373
|
-
const v = src[i]
|
|
374
|
-
const off = i * 4
|
|
375
|
-
const r3 = (v >> 5) & 0x07
|
|
376
|
-
const g3 = (v >> 2) & 0x07
|
|
377
|
-
const b2 = v & 0x03
|
|
378
|
-
rgbaBuffer[off] = (r3 << 5) | (r3 << 2) | (r3 >> 1)
|
|
379
|
-
rgbaBuffer[off + 1] = (g3 << 5) | (g3 << 2) | (g3 >> 1)
|
|
380
|
-
rgbaBuffer[off + 2] = (b2 << 6) | (b2 << 4) | (b2 << 2) | b2
|
|
381
|
-
rgbaBuffer[off + 3] = 0xFF
|
|
382
|
-
}
|
|
383
|
-
this.window.render(WIDTH, HEIGHT, WIDTH * 4, 'rgba32', rgbaBuffer)
|
|
384
|
-
|
|
385
|
-
// Synthesize and play any queued VTAC bell tones
|
|
386
|
-
if (this.machine.play && this.audioDevice) {
|
|
387
|
-
const sampleRate = this.audioDevice.frequency
|
|
388
|
-
while (devBoard.vtac.hasQueuedBells()) {
|
|
389
|
-
const bell = devBoard.vtac.getNextBell()
|
|
390
|
-
if (bell) {
|
|
391
|
-
const numSamples = Math.floor((bell.duration / 60) * sampleRate)
|
|
392
|
-
const samples = new Float32Array(numSamples)
|
|
393
|
-
const twoPiF = 2 * Math.PI * bell.frequency
|
|
394
|
-
for (let i = 0; i < numSamples; i++) {
|
|
395
|
-
samples[i] = Math.sin(twoPiF * i / sampleRate)
|
|
396
|
-
}
|
|
397
|
-
this.machine.play(samples)
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
}
|
|
369
|
+
this.window.render(WIDTH, HEIGHT, WIDTH * 4, 'rgba32', video.buffer)
|
|
401
370
|
}
|
|
402
371
|
}
|
|
403
372
|
|
package/src/lib.ts
CHANGED
|
@@ -15,7 +15,6 @@ export { ACIA } from './components/IO/ACIA'
|
|
|
15
15
|
export { SIDVoice, Sound } from './components/IO/Sound'
|
|
16
16
|
export { Storage } from './components/IO/Storage'
|
|
17
17
|
export { Video } from './components/IO/Video'
|
|
18
|
-
export { Terminal } from './components/IO/Terminal'
|
|
19
18
|
|
|
20
19
|
// GPIO attachments
|
|
21
20
|
export type { Attachment } from './components/IO/Attachments/Attachment'
|
|
@@ -141,7 +141,7 @@ describe('ACIA (6551 ACIA)', () => {
|
|
|
141
141
|
const mockIRQ = jest.fn()
|
|
142
142
|
serialCard.raiseIRQ = mockIRQ
|
|
143
143
|
|
|
144
|
-
serialCard.write(0x02, 0x02) // RIIE=1: receive IRQ disabled (
|
|
144
|
+
serialCard.write(0x02, 0x02) // RIIE=1: receive IRQ disabled (R6551: bit1=1 disables)
|
|
145
145
|
serialCard.onData(0x42)
|
|
146
146
|
|
|
147
147
|
expect(mockIRQ).not.toHaveBeenCalled()
|
package/src/tests/IO/RTC.test.ts
CHANGED
|
@@ -18,7 +18,7 @@ const setTime = (rtc: RTC, values: {
|
|
|
18
18
|
rtc.write(0x02, values.hours)
|
|
19
19
|
rtc.write(0x03, values.dayOfWeek)
|
|
20
20
|
rtc.write(0x04, values.date)
|
|
21
|
-
rtc.write(0x05, values.month) // EOSC=0: oscillator enabled (DS1511Y default)
|
|
21
|
+
rtc.write(0x05, values.month) // EOSC=0: oscillator enabled (DS1511Y+ default)
|
|
22
22
|
rtc.write(0x06, values.year)
|
|
23
23
|
rtc.write(0x07, values.century)
|
|
24
24
|
rtc.write(0x0f, 0x00) // Clear TE: falling edge commits user to internal
|
package/src/tests/IO/VIA.test.ts
CHANGED
|
@@ -49,7 +49,7 @@ const createMockAttachment = (options: {
|
|
|
49
49
|
} as Attachment & { setPortAValue: (v: number) => void; setPortBValue: (v: number) => void }
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
describe('VIA (
|
|
52
|
+
describe('VIA (6522 VIA)', () => {
|
|
53
53
|
let gpio: VIA
|
|
54
54
|
|
|
55
55
|
beforeEach(() => {
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { IO } from '../IO'
|
|
2
|
-
import { VTAC } from 'vtac-terminal'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Terminal - Emulates the VTAC fantasy terminal
|
|
6
|
-
*
|
|
7
|
-
* Register Map:
|
|
8
|
-
* $00: Data / Status Register
|
|
9
|
-
* Write: sends byte to VTAC for processing
|
|
10
|
-
* Read: always returns 0 (bit 7 is a busy flag on the real device; busy is never set here)
|
|
11
|
-
*/
|
|
12
|
-
export class Terminal implements IO {
|
|
13
|
-
|
|
14
|
-
raiseIRQ = () => {}
|
|
15
|
-
raiseNMI = () => {}
|
|
16
|
-
|
|
17
|
-
readonly vtac: VTAC = new VTAC()
|
|
18
|
-
|
|
19
|
-
read(address: number): number {
|
|
20
|
-
// Status register: bit 7 is busy flag on real device, never busy in emulation
|
|
21
|
-
return 0
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
write(address: number, data: number): void {
|
|
25
|
-
const register = address & 0x00
|
|
26
|
-
if (register === 0x00) {
|
|
27
|
-
this.vtac.parse(data)
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
tick(frequency: number): void {}
|
|
32
|
-
reset(coldStart: boolean): void {}
|
|
33
|
-
|
|
34
|
-
}
|