mirror of
https://github.com/colby-swandale/waterfoul
synced 2024-12-28 22:24:09 +01:00
64 lines
1.6 KiB
Ruby
64 lines
1.6 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe Waterfoul::MMU do
|
|
subject { Waterfoul::MMU.new }
|
|
|
|
describe '#write_byte' do
|
|
context 'writing to 0xFFFFFF' do
|
|
it 'raises an exception' do
|
|
expect { subject.write_byte(0xFFFFFF, 0x1) }.to raise_error Waterfoul::MemoryOutOfBounds
|
|
end
|
|
end
|
|
|
|
context 'when writing to -0x1' do
|
|
it 'raises an exception' do
|
|
expect { subject.write_byte(-0x1, 0x1) }.to raise_error Waterfoul::MemoryOutOfBounds
|
|
end
|
|
end
|
|
end
|
|
|
|
describe '#read_byte' do
|
|
context 'reading from 0xFFFFFF' do
|
|
it 'raises an exception' do
|
|
expect { subject.read_byte(0xFFFFFF) }.to raise_error Waterfoul::MemoryOutOfBounds
|
|
end
|
|
end
|
|
|
|
context 'reading from -0x1' do
|
|
it 'raises an exception' do
|
|
expect { subject.read_byte(-0x1) }.to raise_error Waterfoul::MemoryOutOfBounds
|
|
end
|
|
end
|
|
end
|
|
|
|
describe 'DIV register' do
|
|
before { subject.write_byte 0xFF04, 0x25, hardware_operation: true }
|
|
it 'resets when written to' do
|
|
subject.write_byte 0xFF04, 0x35
|
|
expect(subject.read_byte(0xFF04)).to eq 0
|
|
end
|
|
end
|
|
|
|
describe '#read_word' do
|
|
before do
|
|
subject.write_byte 0xFFFF, 0x1
|
|
subject.write_byte 0xFFFE, 0x1
|
|
end
|
|
|
|
it 'reads two bytes from memory into a word' do
|
|
expect(subject.read_word(0xFFFE)).to eq 0x2
|
|
end
|
|
end
|
|
|
|
describe '#write_word' do
|
|
it 'writes 2 bytes into 2 1 byte parts' do
|
|
subject.write_word 0xFF40, 0xFFAA
|
|
expect(subject[0xFF40]).to eq 0xAA
|
|
expect(subject[0xFF41]).to eq 0xFF
|
|
end
|
|
end
|
|
|
|
context 'DMA transfer' do
|
|
|
|
end
|
|
end
|