diff --git a/lib/waterfoul.rb b/lib/waterfoul.rb index 296068f..b9da885 100644 --- a/lib/waterfoul.rb +++ b/lib/waterfoul.rb @@ -9,7 +9,7 @@ require "waterfoul/cpu" require "waterfoul/errors" require "waterfoul/sdl" require "waterfoul/screen" -require "waterfoul/gpu" +require "waterfoul/ppu" require "waterfoul/cartridge" require "waterfoul/emulator" require "waterfoul/input" diff --git a/lib/waterfoul/emulator.rb b/lib/waterfoul/emulator.rb index a53247a..7902742 100644 --- a/lib/waterfoul/emulator.rb +++ b/lib/waterfoul/emulator.rb @@ -10,7 +10,7 @@ module Waterfoul @cartridge = Cartridge.new rom @cpu = CPU.new @cpu = SkipBoot.set_state(@cpu) if options.has_key?('skip_boot') - @gpu = GPU.new + @ppu = PPU.new @screen = Screen.new end @@ -18,8 +18,8 @@ module Waterfoul $mmu.cartridge = @cartridge loop do @cpu.step - @gpu.step @cpu.m - @screen.render @gpu.framebuffer if @gpu.vblank? + @ppu.step @cpu.m + @screen.render @ppu.framebuffer if @ppu.vblank? end end end diff --git a/lib/waterfoul/helper.rb b/lib/waterfoul/helper.rb index eae555f..0119def 100644 --- a/lib/waterfoul/helper.rb +++ b/lib/waterfoul/helper.rb @@ -1,14 +1,10 @@ module Waterfoul module Helper - def pop_from_stack(word = true) if word - lower = $mmu.read_byte @sp - @sp += 1 - upper = $mmu.read_byte @sp - @sp += 1 - - (upper << 8) | lower + val = $mmu.read_word @sp + @sp += 2 + val else val = $mmu.read_byte @sp @sp += 1 diff --git a/lib/waterfoul/gpu.rb b/lib/waterfoul/ppu.rb similarity index 99% rename from lib/waterfoul/gpu.rb rename to lib/waterfoul/ppu.rb index 7921c77..5f944b8 100644 --- a/lib/waterfoul/gpu.rb +++ b/lib/waterfoul/ppu.rb @@ -1,7 +1,7 @@ require 'waterfoul/io/lcd_control' module Waterfoul - class GPU + class PPU include Helper attr_accessor :mode