mirror of
https://github.com/colby-swandale/waterfoul
synced 2024-12-26 21:58:54 +01:00
Reshape MMU#[] to share to move common accesses first
This commit is contained in:
parent
c1e927fc1d
commit
d4c2f76bc1
1 changed files with 5 additions and 12 deletions
|
@ -30,21 +30,14 @@ module Waterfoul
|
|||
def [](i)
|
||||
raise MemoryOutOfBounds if i > MEMORY_SIZE || i < 0
|
||||
|
||||
case i
|
||||
when 0xFF00
|
||||
if i == 0xFF00
|
||||
Input.read_keyboard @memory[i]
|
||||
when 0x0000...0x8000 # ROM Bank 0 + n
|
||||
@cartridge[i]
|
||||
when 0x8000...0xA000 # Video RAM
|
||||
elsif (0x8000...0xA000) === i or (0xC000...0xE000) === i or (0xFE00..0xFFFF) === i
|
||||
@memory[i]
|
||||
when 0xA000...0xC000 # RAM Bank
|
||||
@cartridge[i]
|
||||
when 0xC000...0xE000 # Internal RAM
|
||||
@memory[i]
|
||||
when 0xE000...0xFE00 # Internal RAM (shadow)
|
||||
elsif (0xE000...0xFE00) === i
|
||||
@memory[i - 0x2000]
|
||||
when 0xFE00..0xFFFF # Graphics (OAM), IO, Zero-page
|
||||
@memory[i]
|
||||
elsif (0x0000...0x8000) === i or (0xA000...0xC000) === i
|
||||
@cartridge[i]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue