diff --git a/.gitignore b/.gitignore index ce5bd54..aee1c75 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,8 @@ Doxyfile !test/blargg_instr_test-v5/rom_singles !test/**/*.nes !test/**/*.log +!test/**/*.gz +!test/sources.txt # SDL files lib/SDL2/docs diff --git a/CMakeLists.txt b/CMakeLists.txt index a9e44e5..8fe6c16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,6 +64,14 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") target_link_libraries(main PRIVATE stdc++exp) # For endif() +add_custom_command( + OUTPUT blargg_cpu_test5_official.log + COMMAND gzip -kd ${CMAKE_SOURCE_DIR}/test/blargg_cpu_test5_official.log.gz +) +add_custom_target(blargg_cpu_test5_official DEPENDS blargg_cpu_test5_official.log) + +add_dependencies(main blargg_cpu_test5_official) + add_subdirectory(lib) enable_testing() @@ -83,7 +91,7 @@ add_test(NAME blargg_cpu_test5_official_execute COMMAND main CPU_TEST blargg5off set_tests_properties(blargg_cpu_test5_official_execute PROPERTIES TIMEOUT 20) add_test( NAME blargg_cpu_test5_official_match - COMMAND diff ${CMAKE_SOURCE_DIR}/test/blargg5Log.txt - ${CMAKE_SOURCE_DIR}/test/blargg_cpu_test5_official.log - --strip-trailing-cr + COMMAND python ${CMAKE_SOURCE_DIR}/test/logCompare.py + ${CMAKE_SOURCE_DIR}/test/blargg5Log.txt + ${CMAKE_SOURCE_DIR}/test/blargg_cpu_test5_official.log ) diff --git a/README.md b/README.md index 881539e..54d1f3a 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ An incomplete NES emulator made using SDL2 and C++23. - ~~Basic source code layout~~ - ~~ROM file input and processing~~ - ~~Continuous integration / static analysis tool setup~~ -- ~~Official CPU opcode emulation~~ +- Official CPU opcode emulation - Full unofficial CPU opcode emulation - ~~Finish nestest support~~ - Additional CPU tests diff --git a/src/core/ppu.cpp b/src/core/ppu.cpp index 75f8a2b..71c7a19 100644 --- a/src/core/ppu.cpp +++ b/src/core/ppu.cpp @@ -102,7 +102,8 @@ void PPU::cycle() { writeRegister(0x2, readRegister(0x2) | 0x80); } if (scanline == 261 && cyclesOnLine == 0) { - // Clear the vblank value on the second cycle of this line + // Clear the vblank bit on the second cycle of this line + // TODO: Also clear sprite overflow bit? writeRegister(0x2, readRegister(0x2) & ~0x80); } } diff --git a/src/cpu/cpu_test.cpp b/src/cpu/cpu_test.cpp index 75c137e..34a0e14 100644 --- a/src/cpu/cpu_test.cpp +++ b/src/cpu/cpu_test.cpp @@ -5,7 +5,7 @@ struct TestCases { static const int NINTENDULATOR_OFFSET = 14; // This is how many cycles get added to the CPU in Nintendulator static const int NESTEST = 26555; - static const int BLARGG_TEST5_OFFICIAL = 3294894; + static const int BLARGG_TEST5_OFFICIAL = 3294894; // TODO: Update this to the full value }; auto now() { @@ -104,7 +104,7 @@ void runBlarggCpuTest5Official() { std::this_thread::yield(); } - for (int i = 0; i < TestCases::BLARGG_TEST5_OFFICIAL - TestCases::NINTENDULATOR_OFFSET; i++) { + for (int i = 0; i < 3698351 - TestCases::NINTENDULATOR_OFFSET; i++) { nes->cpu->cycle(); } diff --git a/test/blargg_cpu_test5_official.log b/test/blargg_cpu_test5_official.log.gz similarity index 61% rename from test/blargg_cpu_test5_official.log rename to test/blargg_cpu_test5_official.log.gz index 6ece782..7d185f7 100644 Binary files a/test/blargg_cpu_test5_official.log and b/test/blargg_cpu_test5_official.log.gz differ diff --git a/test/sources.txt b/test/sources.txt new file mode 100644 index 0000000..e5ffc94 --- /dev/null +++ b/test/sources.txt @@ -0,0 +1,19 @@ +nestest.nes - + From http://nickmass.com/images/nestest.nes + Found at https://www.nesdev.org/wiki/Emulator_tests +nestest.log - + From https://www.qmtpro.com/~nes/misc/nestest.log + Found at https://www.nesdev.org/wiki/Emulator_tests + +blargg_cpu_test5_official.nes - From https://github.com/christopherpow/nes-test-roms/tree/master/blargg_nes_cpu_test5 +blargg_cpu_test5.nes - From https://github.com/christopherpow/nes-test-roms/tree/master/blargg_nes_cpu_test5 +Log files for blargg tests generated from Nintendulator via following process: +- Load ROM +- Open CPU debugger window +- Press "Power", then "Reset", then "Start Log" +- Run CPU until completion, then stop +- Press "Stop Log" and retrieve log file +When file is too large to store in one piece, broken into segments via `split -b 95M -d segment` and rejoined with `cat segment* > joined`. + +blargg_instr_test-v5 - From https://web.archive.org/web/20190319194832/http://blargg.8bitalley.com/nes-tests/instr_test-v5.zip +