bus (feat): add cycle accuracy
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
102
tests/bus.cc
102
tests/bus.cc
@@ -26,12 +26,18 @@ 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);
|
||||
|
||||
@@ -40,9 +46,25 @@ 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);
|
||||
|
||||
@@ -51,9 +73,25 @@ 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);
|
||||
|
||||
@@ -62,9 +100,25 @@ 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);
|
||||
|
||||
@@ -73,9 +127,25 @@ 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);
|
||||
|
||||
@@ -84,6 +154,20 @@ 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) {
|
||||
@@ -116,22 +200,4 @@ TEST_CASE("rom", TAG) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(BusFixture, "Halfword", TAG) {
|
||||
CHECK(bus->read_halfword(0x202FED9) == 0);
|
||||
|
||||
bus->write_halfword(0x202FED9, 0x1A4A);
|
||||
CHECK(bus->read_halfword(0x202FED9) == 0x1A4A);
|
||||
CHECK(bus->read_word(0x202FED9) == 0x1A4A);
|
||||
CHECK(bus->read_byte(0x202FED9) == 0x4A);
|
||||
}
|
||||
|
||||
TEST_CASE_METHOD(BusFixture, "Word", TAG) {
|
||||
CHECK(bus->read_word(0x600EE34) == 0);
|
||||
|
||||
bus->write_word(0x600EE34, 0x3ACC491D);
|
||||
CHECK(bus->read_word(0x600EE34) == 0x3ACC491D);
|
||||
CHECK(bus->read_halfword(0x600EE34) == 0x491D);
|
||||
CHECK(bus->read_byte(0x600EE34) == 0x1D);
|
||||
}
|
||||
|
||||
#undef TAG
|
||||
|
Reference in New Issue
Block a user