-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
36 lines (32 loc) · 1013 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const CPU = require('./cpu/cpu.js');
const GPU = require('./gpu.js');
const MMU = require('./memory_controller.js');
const CC = require('./cartridge_controller.js');
const convertHrtime = require('convert-hrtime');
let cartridge = new CC("./cartridges/cpu_instrs.gb");
// let cartridge = new CC("cpu_test");
let gpu = new GPU();
let mmu = new MMU(cartridge, gpu);
let cpu = new CPU(mmu, gpu);
cartridge.extract_rom();
var cl = 70224;
var start_time = process.hrtime();
while(true){
// cpu.print_state();
// if(cpu.cycles > 800000000) break;
try{
let elapsed = cpu.tick();
gpu.tick(elapsed);
} catch(e){
console.error(e);
cpu.print_state();
// cpu.print_f_ram();
break;
}
}
let up_seconds = convertHrtime(process.hrtime(start_time)).seconds;
let frames = cpu.cycles / 70224;
console.log(`Up time: ${up_seconds}`);
console.log(`Frames: ${frames}`);
console.log(`Average FPS: ${frames / up_seconds}`);
console.log(`GPU Frames: ${gpu.frames}`);