Class: Rubyboy::EmulatorHeadless
- Inherits:
-
Object
- Object
- Rubyboy::EmulatorHeadless
- Defined in:
- lib/rubyboy/emulator_headless.rb
Instance Method Summary collapse
-
#initialize(rom_path) ⇒ EmulatorHeadless
constructor
A new instance of EmulatorHeadless.
- #step ⇒ Object
Constructor Details
#initialize(rom_path) ⇒ EmulatorHeadless
Returns a new instance of EmulatorHeadless.
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rubyboy/emulator_headless.rb', line 16 def initialize(rom_path) rom_data = File.open(rom_path, 'r') { _1.read.bytes } rom = Rom.new(rom_data) ram = Ram.new mbc = Cartridge::Factory.create(rom, ram) interrupt = Interrupt.new @ppu = Ppu.new(interrupt) @timer = Timer.new(interrupt) joypad = Joypad.new(interrupt) @apu = Apu.new bus = Bus.new(@ppu, rom, ram, mbc, @timer, interrupt, joypad, @apu) @cpu = Cpu.new(bus, interrupt) end |
Instance Method Details
#step ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/rubyboy/emulator_headless.rb', line 30 def step loop do cycles = @cpu.exec @timer.step(cycles) @apu.step(cycles) break if @ppu.step(cycles) end end |