Add a method to read directly the memory

This commit is contained in:
Benoit Daloze 2017-03-05 16:51:18 +01:00
parent d4c2f76bc1
commit e774ff97be
3 changed files with 6 additions and 2 deletions

View file

@ -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?

View file

@ -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)

View file

@ -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)