ac6502 1.1.1 → 1.3.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/dist/components/CPU.d.ts +162 -0
- package/dist/components/Cart.d.ts +9 -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/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/RAMCard.d.ts +37 -0
- package/dist/components/IO/RTCCard.d.ts +107 -0
- package/dist/components/IO/SerialCard.d.ts +76 -0
- package/dist/components/IO/SoundCard.d.ts +120 -0
- package/dist/components/IO/SoundCard.js +2 -0
- package/dist/components/IO/SoundCard.js.map +1 -1
- package/dist/components/IO/StorageCard.d.ts +74 -0
- package/dist/components/IO/VideoCard.d.ts +141 -0
- package/dist/components/IO/VideoCard.js +19 -12
- package/dist/components/IO/VideoCard.js.map +1 -1
- package/dist/components/IO.d.ts +8 -0
- package/dist/components/Machine.d.ts +66 -0
- package/dist/components/Machine.js +38 -6
- 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 +35 -16
- 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/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/RAMCard.test.d.ts +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/SoundCard.test.d.ts +1 -0
- package/dist/tests/IO/StorageCard.test.d.ts +1 -0
- package/dist/tests/IO/VideoCard.test.d.ts +1 -0
- package/dist/tests/Machine.test.d.ts +1 -0
- 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/DevOutputBoard.ts +34 -0
- package/src/components/IO/SoundCard.ts +3 -0
- package/src/components/IO/VideoCard.ts +21 -12
- package/src/components/Machine.ts +40 -7
- package/src/index.ts +35 -18
- package/src/lib.ts +27 -0
- package/tsconfig.json +1 -0
package/src/index.ts
CHANGED
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
import figlet from 'figlet'
|
|
4
4
|
import { Machine } from './components/Machine'
|
|
5
|
-
import { Command } from 'commander'
|
|
5
|
+
import { Command, Option } from 'commander'
|
|
6
6
|
import { SerialPort } from 'serialport'
|
|
7
7
|
import { VideoCard } from './components/IO/VideoCard'
|
|
8
|
+
import { DevOutputBoard } from './components/IO/DevOutputBoard'
|
|
8
9
|
import { StorageCard } from './components/IO/StorageCard'
|
|
9
10
|
import { SoundCard } from './components/IO/SoundCard'
|
|
10
11
|
import sdl from '@kmamal/sdl'
|
|
11
12
|
|
|
12
|
-
const VERSION = '1.
|
|
13
|
+
const VERSION = '1.3.0'
|
|
13
14
|
const WIDTH = 320
|
|
14
15
|
const HEIGHT = 240
|
|
15
16
|
|
|
@@ -43,7 +44,7 @@ interface EmulatorOptions {
|
|
|
43
44
|
stopbits?: string
|
|
44
45
|
port?: string
|
|
45
46
|
storage?: string
|
|
46
|
-
|
|
47
|
+
target?: string
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
class Emulator {
|
|
@@ -58,7 +59,7 @@ class Emulator {
|
|
|
58
59
|
|
|
59
60
|
constructor(options: EmulatorOptions) {
|
|
60
61
|
this.options = options
|
|
61
|
-
this.machine = new Machine(options.
|
|
62
|
+
this.machine = new Machine(options.target ?? 'cob')
|
|
62
63
|
this.controllers = new Map()
|
|
63
64
|
this.joystickButtonStateA = 0x00
|
|
64
65
|
this.joystickButtonStateB = 0x00
|
|
@@ -104,7 +105,7 @@ class Emulator {
|
|
|
104
105
|
console.log('Loaded Cart: NONE')
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
if (this.options.storage &&
|
|
108
|
+
if (this.options.storage && this.options.target !== 'kim') {
|
|
108
109
|
await (this.machine.io4 as StorageCard).loadFromFile(this.options.storage)
|
|
109
110
|
}
|
|
110
111
|
}
|
|
@@ -183,7 +184,7 @@ class Emulator {
|
|
|
183
184
|
}
|
|
184
185
|
|
|
185
186
|
private setupAudio(): void {
|
|
186
|
-
if (this.options.kim) return
|
|
187
|
+
if (this.options.target === 'kim' || this.options.target === 'dev') return
|
|
187
188
|
try {
|
|
188
189
|
this.audioDevice = sdl.audio.openDevice({ type: 'playback' }, {
|
|
189
190
|
channels: AUDIO_CHANNELS as 1,
|
|
@@ -218,7 +219,7 @@ class Emulator {
|
|
|
218
219
|
}
|
|
219
220
|
|
|
220
221
|
private setupWindow(): void {
|
|
221
|
-
const isKIM = this.options.
|
|
222
|
+
const isKIM = this.options.target === 'kim'
|
|
222
223
|
const lcd = this.machine.lcdAttachment
|
|
223
224
|
|
|
224
225
|
// LCD dot-matrix rendering constants
|
|
@@ -238,7 +239,7 @@ class Emulator {
|
|
|
238
239
|
}
|
|
239
240
|
|
|
240
241
|
this.window = sdl.video.createWindow({
|
|
241
|
-
title:
|
|
242
|
+
title: `6502 Emulator (${(this.options.target ?? 'cob').toUpperCase()})`,
|
|
242
243
|
width: windowWidth * this.machine.scale,
|
|
243
244
|
height: windowHeight * this.machine.scale,
|
|
244
245
|
accelerated: true,
|
|
@@ -320,12 +321,28 @@ class Emulator {
|
|
|
320
321
|
|
|
321
322
|
this.window.render(renderWidth, renderHeight, renderWidth * 4, 'rgba32', rgbaBuffer)
|
|
322
323
|
}
|
|
323
|
-
} else {
|
|
324
|
+
} else if (this.options.target === 'cob' || this.options.target === 'vcs') {
|
|
324
325
|
const videoCard = this.machine.io8 as VideoCard
|
|
325
326
|
this.machine.render = () => {
|
|
326
327
|
if (!this.window) { return }
|
|
327
328
|
this.window.render(WIDTH, HEIGHT, WIDTH * 4, 'rgba32', videoCard.buffer)
|
|
328
329
|
}
|
|
330
|
+
} else if (this.options.target === 'dev') {
|
|
331
|
+
const devBoard = this.machine.io8 as DevOutputBoard
|
|
332
|
+
const rgbaBuffer = Buffer.alloc(WIDTH * HEIGHT * 4)
|
|
333
|
+
this.machine.render = () => {
|
|
334
|
+
if (!this.window) { return }
|
|
335
|
+
const src = devBoard.vtac.buffer
|
|
336
|
+
for (let i = 0; i < WIDTH * HEIGHT; i++) {
|
|
337
|
+
const v = src[i]
|
|
338
|
+
const off = i * 4
|
|
339
|
+
rgbaBuffer[off] = v
|
|
340
|
+
rgbaBuffer[off + 1] = v
|
|
341
|
+
rgbaBuffer[off + 2] = v
|
|
342
|
+
rgbaBuffer[off + 3] = 0xFF
|
|
343
|
+
}
|
|
344
|
+
this.window.render(WIDTH, HEIGHT, WIDTH * 4, 'rgba32', rgbaBuffer)
|
|
345
|
+
}
|
|
329
346
|
}
|
|
330
347
|
|
|
331
348
|
this.window.on('close', () => this.shutdown())
|
|
@@ -337,7 +354,7 @@ class Emulator {
|
|
|
337
354
|
}
|
|
338
355
|
|
|
339
356
|
private setupControllers(): void {
|
|
340
|
-
if (this.options.kim) return
|
|
357
|
+
if (this.options.target === 'kim') return
|
|
341
358
|
// Controller device add/remove handlers
|
|
342
359
|
(sdl.controller as any).on('deviceAdd', (device: any) => {
|
|
343
360
|
console.log(`Controller added: ${device.name || device.id}`)
|
|
@@ -513,7 +530,7 @@ class Emulator {
|
|
|
513
530
|
})
|
|
514
531
|
|
|
515
532
|
// Save storage data if path was provided
|
|
516
|
-
if (this.options.storage &&
|
|
533
|
+
if (this.options.storage && this.options.target !== 'kim') {
|
|
517
534
|
(this.machine.io4 as StorageCard).saveToFile(this.options.storage).then(() => {
|
|
518
535
|
process.exit(0)
|
|
519
536
|
}).catch(() => {
|
|
@@ -536,17 +553,17 @@ program
|
|
|
536
553
|
.description('Emulator for the A.C. Wright 6502 project.')
|
|
537
554
|
.version(VERSION, '-v, --version', 'Output the current emulator version')
|
|
538
555
|
.helpOption('-h, --help', 'Output help / options')
|
|
539
|
-
.option('-c, --cart <path>', 'Path to 32K Cart binary file')
|
|
540
|
-
.option('-f, --freq <freq>', 'Set the clock frequency in Hz', '2000000')
|
|
541
|
-
.option('-r, --rom <path>', 'Path to 32K ROM binary file')
|
|
542
|
-
.option('-s, --scale <scale>', 'Set the emulator scale', '2')
|
|
543
|
-
.option('-b, --baudrate <baudrate>', 'Baud Rate', '9600')
|
|
544
556
|
.option('-a, --parity <parity>', 'Parity (odd | even | none)', 'none')
|
|
557
|
+
.option('-b, --baudrate <baudrate>', 'Baud Rate', '9600')
|
|
558
|
+
.option('-c, --cart <path>', 'Path to 32K Cart binary file')
|
|
545
559
|
.option('-d, --databits <databits>', 'Data Bits (5 | 6 | 7 | 8)', '8')
|
|
546
|
-
.option('-
|
|
560
|
+
.option('-f, --freq <freq>', 'Set the clock frequency in Hz', '1000000')
|
|
547
561
|
.option('-p, --port <port>', 'Path to the serial port (e.g., /dev/ttyUSB0)')
|
|
562
|
+
.option('-r, --rom <path>', 'Path to 32K ROM binary file')
|
|
563
|
+
.option('-s, --scale <scale>', 'Set the emulator scale', '2')
|
|
548
564
|
.option('-S, --storage <path>', 'Path to storage data file for Compact Flash card persistence')
|
|
549
|
-
.option('-
|
|
565
|
+
.option('-t, --stopbits <stopbits>', 'Stop Bits (1 | 1.5 | 2)', '1')
|
|
566
|
+
.addOption(new Option('-T, --target <target>', 'System target').choices(['cob', 'vcs', 'kim', 'dev']).default('cob'))
|
|
550
567
|
.addHelpText('beforeAll', figlet.textSync('6502 Emulator', { font: 'cricket' }) + '\n' + `Version: ${VERSION} | A.C. Wright Design\n`)
|
|
551
568
|
.parse(process.argv)
|
|
552
569
|
|
package/src/lib.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Core components
|
|
2
|
+
export { Machine } from './components/Machine'
|
|
3
|
+
export { CPU } from './components/CPU'
|
|
4
|
+
export { RAM } from './components/RAM'
|
|
5
|
+
export { ROM } from './components/ROM'
|
|
6
|
+
export { Cart } from './components/Cart'
|
|
7
|
+
export type { IO } from './components/IO'
|
|
8
|
+
|
|
9
|
+
// IO cards
|
|
10
|
+
export { EmptyCard } from './components/IO/EmptyCard'
|
|
11
|
+
export { GPIOCard } from './components/IO/GPIOCard'
|
|
12
|
+
export { RAMCard } from './components/IO/RAMCard'
|
|
13
|
+
export { RTCCard } from './components/IO/RTCCard'
|
|
14
|
+
export { SerialCard } from './components/IO/SerialCard'
|
|
15
|
+
export { SIDVoice, SoundCard } from './components/IO/SoundCard'
|
|
16
|
+
export { StorageCard } from './components/IO/StorageCard'
|
|
17
|
+
export { VideoCard } from './components/IO/VideoCard'
|
|
18
|
+
export { DevOutputBoard } from './components/IO/DevOutputBoard'
|
|
19
|
+
|
|
20
|
+
// GPIO attachments
|
|
21
|
+
export type { GPIOAttachment } from './components/IO/GPIOAttachments/GPIOAttachment'
|
|
22
|
+
export { GPIOAttachmentBase } from './components/IO/GPIOAttachments/GPIOAttachment'
|
|
23
|
+
export { GPIOJoystickAttachment } from './components/IO/GPIOAttachments/GPIOJoystickAttachment'
|
|
24
|
+
export { GPIOKeyboardEncoderAttachment } from './components/IO/GPIOAttachments/GPIOKeyboardEncoderAttachment'
|
|
25
|
+
export { GPIOKeyboardMatrixAttachment } from './components/IO/GPIOAttachments/GPIOKeyboardMatrixAttachment'
|
|
26
|
+
export { GPIOKeypadAttachment } from './components/IO/GPIOAttachments/GPIOKeypadAttachment'
|
|
27
|
+
export { GPIOLCDAttachment } from './components/IO/GPIOAttachments/GPIOLCDAttachment'
|