fix bad offset for ECHO ram, emulate Input and other MMU fixes

This commit is contained in:
Colby 2016-08-01 20:05:53 +10:00
parent abefb6da56
commit 03de70423b

View file

@ -35,6 +35,8 @@ module Waterfoul
raise MemoryOutOfBounds if i > MEMORY_SIZE || i < 0 raise MemoryOutOfBounds if i > MEMORY_SIZE || i < 0
case i case i
when 0xFF00
0xFF
when 0x0000...0x8000 # ROM Bank 0 + n when 0x0000...0x8000 # ROM Bank 0 + n
if @map_boot_rom && i <= BOOT_ROM_END_MEM_LOC if @map_boot_rom && i <= BOOT_ROM_END_MEM_LOC
BootROM[i] BootROM[i]
@ -48,7 +50,7 @@ module Waterfoul
when 0xC000...0xE000 # Internal RAM when 0xC000...0xE000 # Internal RAM
@memory[i] @memory[i]
when 0xE000...0xFE00 # Internal RAM (shadow) when 0xE000...0xFE00 # Internal RAM (shadow)
@memory[i - 0x1000] @memory[i - 0x2000]
when 0xFE00..0xFFFF # Graphics (OAM), IO, Zero-page when 0xFE00..0xFFFF # Graphics (OAM), IO, Zero-page
@memory[i] @memory[i]
end end
@ -68,6 +70,7 @@ module Waterfoul
@map_boot_rom = false if v == 0x1 && @map_boot_rom @map_boot_rom = false if v == 0x1 && @map_boot_rom
when 0xFF46 # DMA transfer when 0xFF46 # DMA transfer
dma_transfer v dma_transfer v
@memory[i] = v
when 0xFF04 # reset divider register when 0xFF04 # reset divider register
@memory[i] = 0 @memory[i] = 0
when 0x0...0x8000 # ROM Bank 0 + n when 0x0...0x8000 # ROM Bank 0 + n
@ -79,7 +82,7 @@ module Waterfoul
when 0xC000...0xE000 # Internal RAM when 0xC000...0xE000 # Internal RAM
@memory[i] = v @memory[i] = v
when 0xE000...0xFE00 # Internal RAM (Shadow) when 0xE000...0xFE00 # Internal RAM (Shadow)
@memory[i - 0x1000] = v @memory[i - 0x2000] = v
when 0xFE00..0xFFFF # Graphics (OAM), IO, Zero Page when 0xFE00..0xFFFF # Graphics (OAM), IO, Zero Page
@memory[i] = v @memory[i] = v
end end
@ -111,9 +114,11 @@ module Waterfoul
def dma_transfer(start) def dma_transfer(start)
addr = start << 8 addr = start << 8
0.upto(0xA0) do |i| if addr >= 0x8000 && addr < 0xE000
sprite_byte = $mmu.read_byte(addr + i) 0.upto(0x9F) do |i|
self[0xFE00 + i] = sprite_byte sprite_byte = $mmu.read_byte(addr + i)
self[0xFE00 + i] = sprite_byte
end
end end
end end
end end