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)
|
def [](i)
|
||||||
raise MemoryOutOfBounds if i > MEMORY_SIZE || i < 0
|
raise MemoryOutOfBounds if i > MEMORY_SIZE || i < 0
|
||||||
|
|
||||||
case i
|
if i == 0xFF00
|
||||||
when 0xFF00
|
|
||||||
Input.read_keyboard @memory[i]
|
Input.read_keyboard @memory[i]
|
||||||
when 0x0000...0x8000 # ROM Bank 0 + n
|
elsif (0x8000...0xA000) === i or (0xC000...0xE000) === i or (0xFE00..0xFFFF) === i
|
||||||
@cartridge[i]
|
|
||||||
when 0x8000...0xA000 # Video RAM
|
|
||||||
@memory[i]
|
@memory[i]
|
||||||
when 0xA000...0xC000 # RAM Bank
|
elsif (0xE000...0xFE00) === i
|
||||||
@cartridge[i]
|
|
||||||
when 0xC000...0xE000 # Internal RAM
|
|
||||||
@memory[i]
|
|
||||||
when 0xE000...0xFE00 # Internal RAM (shadow)
|
|
||||||
@memory[i - 0x2000]
|
@memory[i - 0x2000]
|
||||||
when 0xFE00..0xFFFF # Graphics (OAM), IO, Zero-page
|
elsif (0x0000...0x8000) === i or (0xA000...0xC000) === i
|
||||||
@memory[i]
|
@cartridge[i]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue