Skip to content

Commit

Permalink
Add more blargg tests, using gzip to compress log file
Browse files Browse the repository at this point in the history
  • Loading branch information
StardustGogeta committed Jun 22, 2024
1 parent 51bf0e4 commit b89e285
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
target_link_libraries(main PRIVATE stdc++exp) # For <print>
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()
Expand All @@ -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
)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/core/ppu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/cpu/cpu_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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();
}

Expand Down
Binary file not shown.
19 changes: 19 additions & 0 deletions test/sources.txt
Original file line number Diff line number Diff line change
@@ -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 <log file> -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

0 comments on commit b89e285

Please sign in to comment.