47 lines
819 B
Dart
47 lines
819 B
Dart
import 'dart:typed_data';
|
|
|
|
import 'package:dartboy/emulator/bus.dart';
|
|
import 'package:dartboy/emulator/cpu.dart';
|
|
import 'package:dartboy/emulator/joypad.dart';
|
|
import 'package:dartboy/emulator/mbc.dart';
|
|
import 'package:dartboy/emulator/ppu.dart';
|
|
import 'package:dartboy/emulator/rom.dart';
|
|
|
|
class GameBoy {
|
|
GameBoy();
|
|
|
|
late Cpu cpu;
|
|
bool ready = false;
|
|
|
|
void load(Rom rom) {
|
|
final mbc = Mbc.fromRom(rom);
|
|
final ppu = Ppu();
|
|
final bus = Bus(ppu, mbc);
|
|
|
|
cpu = Cpu(bus: bus);
|
|
}
|
|
|
|
void reset() {
|
|
cpu.reset();
|
|
|
|
ready = true;
|
|
}
|
|
|
|
void press(JoypadKey key) {
|
|
cpu.bus.joypad.press(key);
|
|
}
|
|
|
|
void release(JoypadKey key) {
|
|
cpu.bus.joypad.release(key);
|
|
}
|
|
|
|
void tick() {
|
|
cpu.tick();
|
|
cpu.bus.tick();
|
|
}
|
|
|
|
Uint8List render() {
|
|
return cpu.bus.ppu.render();
|
|
}
|
|
}
|