diff --git a/lib/waterfoul/cpu.rb b/lib/waterfoul/cpu.rb index 2a94ce9..ac263e6 100644 --- a/lib/waterfoul/cpu.rb +++ b/lib/waterfoul/cpu.rb @@ -78,7 +78,7 @@ module Waterfoul end def check_halt - @halt = false if @pre_halt_interrupt != $mmu.read_byte(0xFF0F) + @halt = false if @pre_halt_interrupt != $mmu.read_memory_byte(0xFF0F) end def halted? diff --git a/lib/waterfoul/mmu.rb b/lib/waterfoul/mmu.rb index c299866..3ffbdcf 100644 --- a/lib/waterfoul/mmu.rb +++ b/lib/waterfoul/mmu.rb @@ -81,6 +81,10 @@ module Waterfoul alias_method :write_byte, :[]= alias_method :read_byte, :[] + def read_memory_byte(i) + @memory[i] + end + # read 2 bytes from memory def read_word(addr) self[addr] | (self[addr + 1] << 8) diff --git a/lib/waterfoul/ppu.rb b/lib/waterfoul/ppu.rb index 4d07a16..cca7638 100644 --- a/lib/waterfoul/ppu.rb +++ b/lib/waterfoul/ppu.rb @@ -304,7 +304,7 @@ module Waterfoul pixel = (byte_1 & (0x1 << (7 - pixelx)) > 0) ? 1 : 0 pixel |= (byte_2 & (0x1 << (7 - pixelx)) > 0) ? 2 : 0 position = line_width + buffer_addr - palette = $mmu.read_byte 0xFF47 + palette = $mmu.read_memory_byte 0xFF47 color = (palette >> (pixel * 2)) & 0x3 @framebuffer[position] = rgb(color)