-
Notifications
You must be signed in to change notification settings - Fork 833
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Benjamin Goldstein
committed
Nov 22, 2021
1 parent
c6cceb2
commit 881d60a
Showing
3 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./src/nes"; | ||
export * from "./src/controller"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export type ControllerKey = 1 | 2; | ||
|
||
export type ButtonKey = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7; | ||
|
||
export class Controller { | ||
state: number[]; | ||
buttonDown: (key: ControllerKey) => void; | ||
buttonUp: (key: ControllerKey) => void; | ||
|
||
static BUTTON_A = 0; | ||
static BUTTON_B = 1; | ||
static BUTTON_SELECT = 2; | ||
static BUTTON_START = 3; | ||
static BUTTON_UP = 4; | ||
static BUTTON_DOWN = 5; | ||
static BUTTON_LEFT = 6; | ||
static BUTTON_RIGHT = 7; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { ControllerKey, ButtonKey } from "./controller"; | ||
|
||
export interface EmulatorData { | ||
cpu: string; | ||
mmap: string; | ||
ppu: string; | ||
papu: string; | ||
} | ||
|
||
export interface NESOptions { | ||
onFrame?: (buffer: number[]) => void; | ||
onAudioSample?: (left: number, right: number) => void; | ||
onStatusUpdate?: (status: string) => void; | ||
onBatteryRamWrite?: (address: number, value: number) => void; | ||
preferredFrameRate?: number; | ||
emulateSound?: boolean; | ||
sampleRate?: number; | ||
} | ||
|
||
export class NES { | ||
constructor(opts: NESOptions); | ||
stop: () => void; | ||
reset: () => void; | ||
frame: () => void; | ||
buttonDown: (controller: ControllerKey, button: ButtonKey) => void; | ||
buttonUp: (controller: ControllerKey, button: ButtonKey) => void; | ||
zapperMove: (x: number, y: number) => void; | ||
zapperFireDown: () => void; | ||
zapperFireUp: () => void; | ||
getFPS: () => number; | ||
reloadROM: () => void; | ||
loadROM: (data: string | Buffer) => void; | ||
setFramerate: (rate: number) => void; | ||
toJSON: () => EmulatorData; | ||
fromJSON: (data: EmulatorData) => void; | ||
} |