mirror of
https://github.com/colby-swandale/waterfoul
synced 2024-12-26 21:58:54 +01:00
Use read_memory_byte for all reads of addresses over 0xFE00
This commit is contained in:
parent
89aaa3e2cb
commit
c3e8074f96
6 changed files with 22 additions and 22 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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?
|
||||
|
|
Loading…
Reference in a new issue