diff --git a/lib/waterfoul/cpu.rb b/lib/waterfoul/cpu.rb index ac263e6..2d30f0b 100644 --- a/lib/waterfoul/cpu.rb +++ b/lib/waterfoul/cpu.rb @@ -125,7 +125,7 @@ module Waterfoul # master disable interrupts @ime = false push_onto_stack @pc - if_reg = $mmu.read_byte 0xFF0F + if_reg = $mmu.read_memory_byte 0xFF0F case interrupt when Interrupt::INTERRUPT_VBLANK @pc = 0x40 diff --git a/lib/waterfoul/instructions/misc.rb b/lib/waterfoul/instructions/misc.rb index f211195..0f4601c 100644 --- a/lib/waterfoul/instructions/misc.rb +++ b/lib/waterfoul/instructions/misc.rb @@ -19,7 +19,7 @@ module Waterfoul # Halt CPU & LCD display until button pressed. # @flags - - - - def halt - @pre_halt_interrupt = $mmu.read_byte(0xFF0F) + @pre_halt_interrupt = $mmu.read_memory_byte(0xFF0F) @halt = true end diff --git a/lib/waterfoul/interrupt.rb b/lib/waterfoul/interrupt.rb index 520dc16..8a2cf4c 100644 --- a/lib/waterfoul/interrupt.rb +++ b/lib/waterfoul/interrupt.rb @@ -14,13 +14,13 @@ module Waterfoul # def self.request_interrupt(interrupt) - if_reg = $mmu.read_byte IF_REG_MEM_LOC + if_reg = $mmu.read_memory_byte IF_REG_MEM_LOC $mmu.write_byte IF_REG_MEM_LOC, (if_reg | interrupt) end def self.pending_interrupt - ie_reg = $mmu.read_byte IE_REG_MEM_LOC - if_reg = $mmu.read_byte IF_REG_MEM_LOC + ie_reg = $mmu.read_memory_byte IE_REG_MEM_LOC + if_reg = $mmu.read_memory_byte IF_REG_MEM_LOC pending_interrupts = if_reg & ie_reg if pending_interrupts & INTERRUPT_VBLANK == INTERRUPT_VBLANK diff --git a/lib/waterfoul/io/lcd_control.rb b/lib/waterfoul/io/lcd_control.rb index d58b852..ac318d0 100644 --- a/lib/waterfoul/io/lcd_control.rb +++ b/lib/waterfoul/io/lcd_control.rb @@ -44,7 +44,7 @@ module Waterfoul private def lcdc - $mmu.read_byte LCDC_MEM_LOC + $mmu.read_memory_byte LCDC_MEM_LOC end end end diff --git a/lib/waterfoul/ppu.rb b/lib/waterfoul/ppu.rb index cca7638..f018b81 100644 --- a/lib/waterfoul/ppu.rb +++ b/lib/waterfoul/ppu.rb @@ -128,7 +128,7 @@ module Waterfoul end def update_stat_mode - stat = $mmu.read_byte 0xFF41 + stat = $mmu.read_memory_byte 0xFF41 new_stat = (stat & 0xFC) | (@mode & 0x3) $mmu.write_byte 0xFF41, new_stat end @@ -140,8 +140,8 @@ module Waterfoul # if the LCDC window enable bit flag is not set return if @window_line > 143 || !IO::LCDControl.window_enabled? - window_pos_x = $mmu.read_byte(0xFF4B) - 7 - window_pos_y = $mmu.read_byte(0xFF4A) + window_pos_x = $mmu.read_memory_byte(0xFF4B) - 7 + window_pos_y = $mmu.read_memory_byte(0xFF4A) # don't render if the window is outside the bounds of the screen return if window_pos_x > 159 || window_pos_y > 143 || window_pos_y > line @@ -206,14 +206,14 @@ module Waterfoul 39.downto(0) do |sprite| sprite_offset = sprite * 4 - sprite_y = $mmu.read_byte(0xFE00 + sprite_offset) - 16 + sprite_y = $mmu.read_memory_byte(0xFE00 + sprite_offset) - 16 next if sprite_y > line || (sprite_y + sprite_size) <= line - sprite_x = $mmu.read_byte(0xFE00 + sprite_offset + 1) - 8 + sprite_x = $mmu.read_memory_byte(0xFE00 + sprite_offset + 1) - 8 next if sprite_x < -7 || sprite_x >= Screen::SCREEN_WIDTH - sprite_tile_offset = ($mmu.read_byte(0xFE00 + sprite_offset + 2) & (sprite_size == 16 ? 0xFE : 0xFF)) * 16 - sprite_flags = $mmu.read_byte(0xFE00 + sprite_offset + 3) + sprite_tile_offset = ($mmu.read_memory_byte(0xFE00 + sprite_offset + 2) & (sprite_size == 16 ? 0xFE : 0xFF)) * 16 + sprite_flags = $mmu.read_memory_byte(0xFE00 + sprite_offset + 3) x_flip = sprite_flags & 0x20 == 0x20 ? true : false y_flip = sprite_flags & 0x40 == 0x40 ? true : false #above_bg = sprite_flags & 0x80 == 0x80 ? true : false @@ -269,9 +269,9 @@ module Waterfoul tiles_select = IO::LCDControl.bg_tile_select map_select = IO::LCDControl.bg_map_select # x pixel offset - scx = $mmu.read_byte 0xFF43 + scx = $mmu.read_memory_byte 0xFF43 # y pixel offset - scy = $mmu.read_byte 0xFF42 + scy = $mmu.read_memory_byte 0xFF42 # line with y offset line_adjusted = (line + scy) & 0xFF # get position of tile row to read @@ -332,8 +332,8 @@ module Waterfoul def compare_lylc if IO::LCDControl.screen_enabled? - lyc = $mmu.read_byte 0xFF45 - stat = $mmu.read_byte 0xFF41 + lyc = $mmu.read_memory_byte 0xFF45 + stat = $mmu.read_memory_byte 0xFF41 if lyc == current_line stat = stat | 0x4 @@ -345,7 +345,7 @@ module Waterfoul end def current_line - $mmu.read_byte LCDC_Y_COORDINATE_MEM_LOC + $mmu.read_memory_byte LCDC_Y_COORDINATE_MEM_LOC end def reset_current_line diff --git a/lib/waterfoul/timer.rb b/lib/waterfoul/timer.rb index dff3ab9..88c1b4d 100644 --- a/lib/waterfoul/timer.rb +++ b/lib/waterfoul/timer.rb @@ -27,9 +27,9 @@ module Waterfoul end def inc_tima_register - tima = $mmu.read_byte 0xFF05 + tima = $mmu.read_memory_byte 0xFF05 if tima == 0xFF - tima = $mmu.read_byte 0xFF06 + tima = $mmu.read_memory_byte 0xFF06 Interrupt.request_interrupt(Interrupt::INTERRUPT_TIMER) else tima += 1 @@ -39,7 +39,7 @@ module Waterfoul end def inc_div_register - div = $mmu.read_byte 0xFF04 + div = $mmu.read_memory_byte 0xFF04 div = (div + 1) & 0xFF $mmu.write_byte 0xFF04, div, hardware_operation: true @div_cycles -= DIV_INC_TIME @@ -52,7 +52,7 @@ module Waterfoul end def update - @register = $mmu.read_byte 0xFF07 + @register = $mmu.read_memory_byte 0xFF07 end def running?