https://github.com/mat-sz/6502
🖥️ 6502 emulator (TypeScript)
https://github.com/mat-sz/6502
6502 6502-processor emulator typescript
Last synced: about 1 year ago
JSON representation
🖥️ 6502 emulator (TypeScript)
- Host: GitHub
- URL: https://github.com/mat-sz/6502
- Owner: mat-sz
- License: bsd-3-clause-clear
- Created: 2020-01-20T18:08:45.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-01-29T22:22:04.000Z (about 6 years ago)
- Last Synced: 2025-01-10T03:35:08.762Z (about 1 year ago)
- Topics: 6502, 6502-processor, emulator, typescript
- Language: JavaScript
- Size: 124 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 6502
[](https://travis-ci.com/mat-sz/6502)
MOS Technology 6502 8-bit CPU emulator written in TypeScript.
Passes common test suites (AllSuiteA and 6502_functional_test).
## Installation
For some reason publishing a package called "6502" to NPM is not possible.
Because of this I include a transpiled version in the repo that will allow everyone to install the package with the following command:
```
yarn add mat-sz/6502
```
or, if you use npm:
```
npm install mat-sz/6502
```
## Usage
```js
import { MEMORY_SIZE, State, step } from "6502";
// Create 64k of RAM.
const memory = new Uint8Array(MEMORY_SIZE);
let state = new State();
let PC = 0;
state.PC = 0x0400;
memory.set(new Uint8Array(binary), 0x4000);
while (state.PC != PC) {
// Store old PC for infinite loop detection.
PC = state.PC;
// Step isn't a pure function yet, state will be mutated.
state = step(state,
(offset) => memory[offset], // getMemory = (offset) => value
(offset, value) => memory[offset] = value // setMemory = (offset, value) => void
);
}
```