bus: separate out read/write that count cycles
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
84
tests/bus.cc
84
tests/bus.cc
@@ -26,18 +26,12 @@ TEST_CASE("bios", TAG) {
|
||||
auto bus =
|
||||
Bus::init(std::move(bios), std::vector<uint8_t>(Header::HEADER_SIZE));
|
||||
|
||||
uint32_t cycles = bus->get_cycles();
|
||||
|
||||
CHECK(bus->read_byte(0) == 0xAC);
|
||||
CHECK(bus->read_byte(0x3FFF) == 0x48);
|
||||
CHECK(bus->read_byte(0x2A56) == 0x10);
|
||||
|
||||
CHECK(bus->get_cycles() == cycles + 3);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(BusFixture, "board wram", TAG) {
|
||||
uint32_t cycles = bus->get_cycles();
|
||||
|
||||
bus->write_byte(0x2000000, 0xAC);
|
||||
CHECK(bus->read_byte(0x2000000) == 0xAC);
|
||||
|
||||
@@ -46,25 +40,9 @@ TEST_CASE_METHOD(BusFixture, "board wram", TAG) {
|
||||
|
||||
bus->write_byte(0x2022A56, 0x10);
|
||||
CHECK(bus->read_byte(0x2022A56) == 0x10);
|
||||
|
||||
CHECK(bus->get_cycles() == cycles + 2 * 9);
|
||||
cycles = bus->get_cycles();
|
||||
|
||||
bus->write_halfword(0x2022A56, 0x1009);
|
||||
CHECK(bus->read_halfword(0x2022A56) == 0x1009);
|
||||
|
||||
CHECK(bus->get_cycles() == cycles + 2 * 3);
|
||||
cycles = bus->get_cycles();
|
||||
|
||||
bus->write_word(0x2022A56, 0x10FF9903);
|
||||
CHECK(bus->read_word(0x2022A56) == 0x10FF9903);
|
||||
|
||||
CHECK(bus->get_cycles() == cycles + 2 * 6);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(BusFixture, "chip wram", TAG) {
|
||||
uint32_t cycles = bus->get_cycles();
|
||||
|
||||
bus->write_byte(0x3000000, 0xAC);
|
||||
CHECK(bus->read_byte(0x3000000) == 0xAC);
|
||||
|
||||
@@ -73,25 +51,9 @@ TEST_CASE_METHOD(BusFixture, "chip wram", TAG) {
|
||||
|
||||
bus->write_byte(0x3002A56, 0x10);
|
||||
CHECK(bus->read_byte(0x3002A56) == 0x10);
|
||||
|
||||
CHECK(bus->get_cycles() == cycles + 2 * 3);
|
||||
cycles = bus->get_cycles();
|
||||
|
||||
bus->write_halfword(0x3002A56, 0xF0F0);
|
||||
CHECK(bus->read_halfword(0x3002A56) == 0xF0F0);
|
||||
|
||||
CHECK(bus->get_cycles() == cycles + 2);
|
||||
cycles = bus->get_cycles();
|
||||
|
||||
bus->write_word(0x3002A56, 0xF9399010);
|
||||
CHECK(bus->read_word(0x3002A56) == 0xF9399010);
|
||||
|
||||
CHECK(bus->get_cycles() == cycles + 2);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(BusFixture, "palette ram", TAG) {
|
||||
uint32_t cycles = bus->get_cycles();
|
||||
|
||||
bus->write_byte(0x5000000, 0xAC);
|
||||
CHECK(bus->read_byte(0x5000000) == 0xAC);
|
||||
|
||||
@@ -100,25 +62,9 @@ TEST_CASE_METHOD(BusFixture, "palette ram", TAG) {
|
||||
|
||||
bus->write_byte(0x5000156, 0x10);
|
||||
CHECK(bus->read_byte(0x5000156) == 0x10);
|
||||
|
||||
CHECK(bus->get_cycles() == cycles + 2 * 3);
|
||||
cycles = bus->get_cycles();
|
||||
|
||||
bus->write_halfword(0x5000156, 0xEEE1);
|
||||
CHECK(bus->read_halfword(0x5000156) == 0xEEE1);
|
||||
|
||||
CHECK(bus->get_cycles() == cycles + 2);
|
||||
cycles = bus->get_cycles();
|
||||
|
||||
bus->write_word(0x5000156, 0x938566E0);
|
||||
CHECK(bus->read_word(0x5000156) == 0x938566E0);
|
||||
|
||||
CHECK(bus->get_cycles() == cycles + 2 * 2);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(BusFixture, "video ram", TAG) {
|
||||
uint32_t cycles = bus->get_cycles();
|
||||
|
||||
bus->write_byte(0x6000000, 0xAC);
|
||||
CHECK(bus->read_byte(0x6000000) == 0xAC);
|
||||
|
||||
@@ -127,25 +73,9 @@ TEST_CASE_METHOD(BusFixture, "video ram", TAG) {
|
||||
|
||||
bus->write_byte(0x6012A56, 0x10);
|
||||
CHECK(bus->read_byte(0x6012A56) == 0x10);
|
||||
|
||||
CHECK(bus->get_cycles() == cycles + 2 * 3);
|
||||
cycles = bus->get_cycles();
|
||||
|
||||
bus->write_halfword(0x6012A56, 0xB100);
|
||||
CHECK(bus->read_halfword(0x6012A56) == 0xB100);
|
||||
|
||||
CHECK(bus->get_cycles() == cycles + 2);
|
||||
cycles = bus->get_cycles();
|
||||
|
||||
bus->write_word(0x6012A56, 0x9322093E);
|
||||
CHECK(bus->read_word(0x6012A56) == 0x9322093E);
|
||||
|
||||
CHECK(bus->get_cycles() == cycles + 2 * 2);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(BusFixture, "oam obj ram", TAG) {
|
||||
uint32_t cycles = bus->get_cycles();
|
||||
|
||||
bus->write_byte(0x7000000, 0xAC);
|
||||
CHECK(bus->read_byte(0x7000000) == 0xAC);
|
||||
|
||||
@@ -154,20 +84,6 @@ TEST_CASE_METHOD(BusFixture, "oam obj ram", TAG) {
|
||||
|
||||
bus->write_byte(0x7000156, 0x10);
|
||||
CHECK(bus->read_byte(0x7000156) == 0x10);
|
||||
|
||||
CHECK(bus->get_cycles() == cycles + 2 * 3);
|
||||
cycles = bus->get_cycles();
|
||||
|
||||
bus->write_halfword(0x7000156, 0x946C);
|
||||
CHECK(bus->read_halfword(0x7000156) == 0x946C);
|
||||
|
||||
CHECK(bus->get_cycles() == cycles + 2);
|
||||
cycles = bus->get_cycles();
|
||||
|
||||
bus->write_word(0x7000156, 0x93C5D1E0);
|
||||
CHECK(bus->read_word(0x7000156) == 0x93C5D1E0);
|
||||
|
||||
CHECK(bus->get_cycles() == cycles + 2);
|
||||
}
|
||||
|
||||
TEST_CASE("rom", TAG) {
|
||||
|
Reference in New Issue
Block a user