Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Bus from './nes/bus.js';
- import RP2C02 from './nes/2c02.js';
- import RP2A03 from './nes/2a03.js';
- import MCS6502 from './6502.js';
- export default (rom, {Hz}) => {
- const ram = [/* TODO */];
- const bus = Bus(rom, ram);
- const [
- processor,
- graphics,
- sound
- ] = [
- MCS6502(bus),
- RP2C02(bus),
- RP2A03(bus),
- ];
- return {
- data: {
- cpu: processor.data,
- ppu: graphics.data,
- apu: sound.data
- },
- emulate: (state, ms) => {
- const length = 1 + ms*Hz/1000;
- const frames = Array.from({length});
- const {
- cpu: [cpu],
- ppu: [ppu, frame],
- apu: [apu]
- } = frames.reduce(a => ({
- cpu: processor.emulate(a.cpu, 0),
- ppu: graphics.emulate(a.ppu),
- apu: sound.emulate(a.apu)
- }), state);
- return {
- frame,
- //cc,
- state: {
- cpu,
- ppu,
- apu
- },
- ms: frames.reduce(T => T - 1000/Hz, ms)
- };
- }
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement