From 3b4a530d42cc209d53fb70497c9cce2324c59a0f Mon Sep 17 00:00:00 2001 From: Sergio Martin Date: Sat, 20 Jan 2024 18:30:24 +0100 Subject: [PATCH] Adding block discrimination mechanism for light states --- source/emuInstance.hpp | 6 +-- source/tester.cpp | 47 ++++++++++--------- tests/arkanoid/warpless.test | 2 +- tests/arkanoid/warps.test | 3 +- tests/castlevania1/anyPercent.test | 3 +- tests/castlevania1/pacifist.test | 3 +- tests/galaga/anyPercent.test | 3 +- tests/ironSword/anyPercent.test | 3 +- tests/metroid/playaround.test | 3 +- tests/nigelMansell/anyPercent.test | 3 +- tests/ninjaGaiden/anyPercent.test | 3 +- tests/ninjaGaiden/pacifist.test | 3 +- tests/ninjaGaiden2/anyPercent.test | 3 +- tests/ninjaGaiden2/pacifist.test | 3 +- tests/novaTheSquirrel/anyPercent.test | 3 +- tests/princeOfPersia/anyPercent.test | 3 +- tests/saintSeiyaKanketsuHen/anyPercent.test | 3 +- tests/saintSeiyaOugonDensetsu/anyPercent.test | 3 +- tests/saiyuukiWorld/anyPercent.test | 1 + tests/saiyuukiWorld/lastHalf.test | 1 + tests/solarJetman/anyPercent.test | 3 +- tests/sprilo/anyPercent.test | 3 +- tests/superMarioBros/warpless.test | 3 +- tests/superMarioBros/warps.test | 3 +- tests/superMarioBros3/warps.test | 3 +- tests/superOffroad/anyPercent.test | 3 +- tests/tennis/anyPercent.test | 3 +- 27 files changed, 75 insertions(+), 48 deletions(-) diff --git a/source/emuInstance.hpp b/source/emuInstance.hpp index 0ae877a..8878578 100644 --- a/source/emuInstance.hpp +++ b/source/emuInstance.hpp @@ -91,9 +91,9 @@ class EmuInstance MetroHash128 hash; hash.Update(getLowMem(), _LOW_MEM_SIZE); - hash.Update(getHighMem(), _HIGH_MEM_SIZE); - hash.Update(getNametableMem(), _NAMETABLES_MEM_SIZE); - hash.Update(getChrMem(), getChrMemSize()); + // hash.Update(getHighMem(), _HIGH_MEM_SIZE); + // hash.Update(getNametableMem(), _NAMETABLES_MEM_SIZE); + // hash.Update(getChrMem(), getChrMemSize()); hash_t result; hash.Finalize(reinterpret_cast(&result)); diff --git a/source/tester.cpp b/source/tester.cpp index 59cc9f9..db9ffca 100644 --- a/source/tester.cpp +++ b/source/tester.cpp @@ -79,15 +79,15 @@ int main(int argc, char *argv[]) std::string expectedROMSHA1 = scriptJson["Expected ROM SHA1"].get(); // Parsing disabled blocks in lite state serialization - std::vector liteStateDisabledBlocks; - std::string liteStateDisabledBlocksOutput; - if (scriptJson.contains("Disable Lite State Blocks") == false) EXIT_WITH_ERROR("Script file missing 'Disable Lite State Blocks' entry\n"); - if (scriptJson["Disable Lite State Blocks"].is_array() == false) EXIT_WITH_ERROR("Script file 'Disable Lite State Blocks' is not an array\n"); - for (const auto& entry : scriptJson["Disable Lite State Blocks"]) + std::vector stateDisabledBlocks; + std::string stateDisabledBlocksOutput; + if (scriptJson.contains("Disable State Blocks") == false) EXIT_WITH_ERROR("Script file missing 'Disable State Blocks' entry\n"); + if (scriptJson["Disable State Blocks"].is_array() == false) EXIT_WITH_ERROR("Script file 'Disable State Blocks' is not an array\n"); + for (const auto& entry : scriptJson["Disable State Blocks"]) { - if (entry.is_string() == false) EXIT_WITH_ERROR("Script file 'Disable Lite State Blocks' entry is not a string\n"); - liteStateDisabledBlocks.push_back(entry.get()); - liteStateDisabledBlocksOutput += entry.get() + std::string(" "); + if (entry.is_string() == false) EXIT_WITH_ERROR("Script file 'Disable State Blocks' entry is not a string\n"); + stateDisabledBlocks.push_back(entry.get()); + stateDisabledBlocksOutput += entry.get() + std::string(" "); } // Creating emulator instance @@ -99,6 +99,9 @@ int main(int argc, char *argv[]) auto e = quickerNES::QuickerNESInstance(); #endif + // Disabling requested blocks from light state serialization + for (const auto& block : stateDisabledBlocks) e.disableLiteStateBlock(block); + // Loading ROM File e.loadROMFile(romFilePath); @@ -111,9 +114,6 @@ int main(int argc, char *argv[]) // Getting initial hash auto initialHash = e.getStateHash(); - // Getting full state size - const auto fullStateSize = e.getFullStateSize(); - // Getting lite state size const auto liteStateSize = e.getLiteStateSize(); @@ -138,17 +138,20 @@ int main(int argc, char *argv[]) // Printing test information printf("[] -----------------------------------------\n"); - printf("[] Running Script: '%s'\n", scriptFilePath.c_str()); - printf("[] Cycle Type: '%s'\n", cycleType.c_str()); - printf("[] Emulation Core: '%s'\n", emulationCoreName.c_str()); - printf("[] ROM File: '%s'\n", romFilePath.c_str()); - printf("[] ROM SHA1: '%s'\n", romSHA1.c_str()); - printf("[] Sequence File: '%s'\n", sequenceFilePath.c_str()); - printf("[] Sequence Length: %lu\n", sequenceLength); - printf("[] Initial State Hash: 0x%lX%lX\n", initialHash.first, initialHash.second); - printf("[] Full State Size: %lu bytes\n", fullStateSize); - printf("[] Lite State Size: %lu bytes\n", liteStateSize); - printf("[] Lite State Disabled Blocks: [ %s ]\n", liteStateDisabledBlocksOutput.c_str()); + printf("[] Running Script: '%s'\n", scriptFilePath.c_str()); + printf("[] Cycle Type: '%s'\n", cycleType.c_str()); + printf("[] Emulation Core: '%s'\n", emulationCoreName.c_str()); + printf("[] ROM File: '%s'\n", romFilePath.c_str()); + printf("[] ROM SHA1: '%s'\n", romSHA1.c_str()); + printf("[] Sequence File: '%s'\n", sequenceFilePath.c_str()); + printf("[] Sequence Length: %lu\n", sequenceLength); + printf("[] Initial State Hash: 0x%lX%lX\n", initialHash.first, initialHash.second); + #ifdef _USE_QUICKNES + printf("[] State Size: %lu bytes\n", e.getFullStateSize()); + #endif + #ifdef _USE_QUICKERNES + printf("[] State Size: %lu bytes - Disabled Blocks: [ %s ]\n", e.getLiteStateSize(), stateDisabledBlocksOutput.c_str()); + #endif printf("[] ********** Running Test **********\n"); fflush(stdout); diff --git a/tests/arkanoid/warpless.test b/tests/arkanoid/warpless.test index e4a8946..7478ef2 100644 --- a/tests/arkanoid/warpless.test +++ b/tests/arkanoid/warpless.test @@ -3,5 +3,5 @@ "Expected ROM SHA1": "B2B30C4F30DD853C215C17B0C67CFE63D61A3062", "Initial State File": "", "Sequence File": "warpless.sol", - "Disable Lite State Blocks": [ ] + "Disable State Blocks": [ "SRAM", "CHRR", "NTAB", "SPRT", "MAPR", "CTRL", "APUR" ] } diff --git a/tests/arkanoid/warps.test b/tests/arkanoid/warps.test index 2cf1843..397eff1 100644 --- a/tests/arkanoid/warps.test +++ b/tests/arkanoid/warps.test @@ -2,5 +2,6 @@ "Rom File": "../roms/Arkanoid (U) [!].nes", "Expected ROM SHA1": "B2B30C4F30DD853C215C17B0C67CFE63D61A3062", "Initial State File": "", - "Sequence File": "warps.sol" + "Sequence File": "warps.sol", + "Disable State Blocks": [ "SRAM", "CHRR", "NTAB", "SPRT", "MAPR", "CTRL", "APUR" ] } diff --git a/tests/castlevania1/anyPercent.test b/tests/castlevania1/anyPercent.test index ef42c08..b6d7a54 100644 --- a/tests/castlevania1/anyPercent.test +++ b/tests/castlevania1/anyPercent.test @@ -2,5 +2,6 @@ "Rom File": "../roms/Castlevania (U) (PRG0) [!].nes", "Expected ROM SHA1": "A31B8BD5B370A9103343C866F3C2B2998E889341", "Initial State File": "", - "Sequence File": "anyPercent.sol" + "Sequence File": "anyPercent.sol", + "Disable State Blocks": [ "SRAM", "CHRR", "NTAB", "SPRT", "CTRL" ] } diff --git a/tests/castlevania1/pacifist.test b/tests/castlevania1/pacifist.test index cfef218..7c80858 100644 --- a/tests/castlevania1/pacifist.test +++ b/tests/castlevania1/pacifist.test @@ -3,5 +3,6 @@ "Expected ROM SHA1": "A31B8BD5B370A9103343C866F3C2B2998E889341", "Initial State File": "", "Verification State File": "pacifist.final.state", - "Sequence File": "pacifist.sol" + "Sequence File": "pacifist.sol", + "Disable State Blocks": [ "SRAM", "CHRR", "NTAB", "SPRT", "CTRL" ] } diff --git a/tests/galaga/anyPercent.test b/tests/galaga/anyPercent.test index fa768b1..4d13a0a 100644 --- a/tests/galaga/anyPercent.test +++ b/tests/galaga/anyPercent.test @@ -2,5 +2,6 @@ "Rom File": "../roms/Galaga - Demons of Death (U) [!].nes", "Expected ROM SHA1": "DA54C223D79FA59EB95437854B677CF69B5CAC8A", "Initial State File": "", - "Sequence File": "anyPercent.sol" + "Sequence File": "anyPercent.sol", + "Disable State Blocks": [ ] } diff --git a/tests/ironSword/anyPercent.test b/tests/ironSword/anyPercent.test index c72fe69..979ee99 100644 --- a/tests/ironSword/anyPercent.test +++ b/tests/ironSword/anyPercent.test @@ -2,5 +2,6 @@ "Rom File": "../roms/Ironsword - Wizards & Warriors II (U) [!].nes", "Expected ROM SHA1": "97B79E432F62403FB9F877090850C41112A9A168", "Initial State File": "", - "Sequence File": "anyPercent.sol" + "Sequence File": "anyPercent.sol", + "Disable State Blocks": [ ] } diff --git a/tests/metroid/playaround.test b/tests/metroid/playaround.test index 4238241..26bbebe 100644 --- a/tests/metroid/playaround.test +++ b/tests/metroid/playaround.test @@ -2,5 +2,6 @@ "Rom File": "../roms/Metroid (U) (PRG0) [!].nes", "Expected ROM SHA1": "ECF39EC5A33E6A6F832F03E8FFC61C5D53F4F90B", "Initial State File": "", - "Sequence File": "playaround.sol" + "Sequence File": "playaround.sol", + "Disable State Blocks": [ ] } diff --git a/tests/nigelMansell/anyPercent.test b/tests/nigelMansell/anyPercent.test index dfdaade..652245e 100644 --- a/tests/nigelMansell/anyPercent.test +++ b/tests/nigelMansell/anyPercent.test @@ -2,5 +2,6 @@ "Rom File": "../roms/Nigel Mansell's World Championship Challenge (U) [!].nes", "Expected ROM SHA1": "BBE5CF2DFA0B5422776A530D6F1B617238A8569F", "Initial State File": "", - "Sequence File": "anyPercent.sol" + "Sequence File": "anyPercent.sol", + "Disable State Blocks": [ ] } diff --git a/tests/ninjaGaiden/anyPercent.test b/tests/ninjaGaiden/anyPercent.test index 29e4331..59955cb 100644 --- a/tests/ninjaGaiden/anyPercent.test +++ b/tests/ninjaGaiden/anyPercent.test @@ -2,5 +2,6 @@ "Rom File": "../roms/Ninja Gaiden (U) [!].nes", "Expected ROM SHA1": "CA513F841D75EFEB33BB8099FB02BEEB39F6BB9C", "Initial State File": "", - "Sequence File": "anyPercent.sol" + "Sequence File": "anyPercent.sol", + "Disable State Blocks": [ ] } diff --git a/tests/ninjaGaiden/pacifist.test b/tests/ninjaGaiden/pacifist.test index fceaa97..49d2741 100644 --- a/tests/ninjaGaiden/pacifist.test +++ b/tests/ninjaGaiden/pacifist.test @@ -2,5 +2,6 @@ "Rom File": "../roms/Ninja Gaiden (U) [!].nes", "Expected ROM SHA1": "CA513F841D75EFEB33BB8099FB02BEEB39F6BB9C", "Initial State File": "", - "Sequence File": "pacifist.sol" + "Sequence File": "pacifist.sol", + "Disable State Blocks": [ ] } diff --git a/tests/ninjaGaiden2/anyPercent.test b/tests/ninjaGaiden2/anyPercent.test index 587249b..22d90b0 100644 --- a/tests/ninjaGaiden2/anyPercent.test +++ b/tests/ninjaGaiden2/anyPercent.test @@ -2,5 +2,6 @@ "Rom File": "../roms/Ninja Gaiden II - The Dark Sword of Chaos (U) [!].nes", "Expected ROM SHA1": "B1796660E4A4CEFC72181D4BF4F97999BC048A77", "Initial State File": "", - "Sequence File": "anyPercent.sol" + "Sequence File": "anyPercent.sol", + "Disable State Blocks": [ ] } diff --git a/tests/ninjaGaiden2/pacifist.test b/tests/ninjaGaiden2/pacifist.test index dee408d..7c99047 100644 --- a/tests/ninjaGaiden2/pacifist.test +++ b/tests/ninjaGaiden2/pacifist.test @@ -2,5 +2,6 @@ "Rom File": "../roms/Ninja Gaiden II - The Dark Sword of Chaos (U) [!].nes", "Expected ROM SHA1": "B1796660E4A4CEFC72181D4BF4F97999BC048A77", "Initial State File": "", - "Sequence File": "pacifist.sol" + "Sequence File": "pacifist.sol", + "Disable State Blocks": [ ] } diff --git a/tests/novaTheSquirrel/anyPercent.test b/tests/novaTheSquirrel/anyPercent.test index e7085ab..4c4a330 100644 --- a/tests/novaTheSquirrel/anyPercent.test +++ b/tests/novaTheSquirrel/anyPercent.test @@ -2,5 +2,6 @@ "Rom File": "../roms/nova.nes", "Expected ROM SHA1": "B6B07EE76492ED475F39167C89B342353F999231", "Initial State File": "", - "Sequence File": "anyPercent.sol" + "Sequence File": "anyPercent.sol", + "Disable State Blocks": [ ] } diff --git a/tests/princeOfPersia/anyPercent.test b/tests/princeOfPersia/anyPercent.test index 82d1af0..0db346b 100644 --- a/tests/princeOfPersia/anyPercent.test +++ b/tests/princeOfPersia/anyPercent.test @@ -2,5 +2,6 @@ "Rom File": "../roms/Prince of Persia (U) [!].nes", "Expected ROM SHA1": "6B58F149F34FA829135619C58700CAAA95B9CDE3", "Initial State File": "", - "Sequence File": "anyPercent.sol" + "Sequence File": "anyPercent.sol", + "Disable State Blocks": [ ] } diff --git a/tests/saintSeiyaKanketsuHen/anyPercent.test b/tests/saintSeiyaKanketsuHen/anyPercent.test index 431e6f5..e6d287c 100644 --- a/tests/saintSeiyaKanketsuHen/anyPercent.test +++ b/tests/saintSeiyaKanketsuHen/anyPercent.test @@ -2,5 +2,6 @@ "Rom File": "../roms/Saint Seiya - Ougon Densetsu Kanketsu Hen (J) [!].nes", "Expected ROM SHA1": "F871D9B3DAFDDCDAD5F2ACD71044292E5169064E", "Initial State File": "", - "Sequence File": "anyPercent.sol" + "Sequence File": "anyPercent.sol", + "Disable State Blocks": [ ] } diff --git a/tests/saintSeiyaOugonDensetsu/anyPercent.test b/tests/saintSeiyaOugonDensetsu/anyPercent.test index d69b8a7..45aa8cc 100644 --- a/tests/saintSeiyaOugonDensetsu/anyPercent.test +++ b/tests/saintSeiyaOugonDensetsu/anyPercent.test @@ -2,5 +2,6 @@ "Rom File": "../roms/Saint Seiya - Ougon Densetsu (J) [!].nes", "Expected ROM SHA1": "3F3B499CF50386084E053BCA096AE8E52330CFAE", "Initial State File": "", - "Sequence File": "anyPercent.sol" + "Sequence File": "anyPercent.sol", + "Disable State Blocks": [ ] } diff --git a/tests/saiyuukiWorld/anyPercent.test b/tests/saiyuukiWorld/anyPercent.test index 493fd3f..d96367a 100644 --- a/tests/saiyuukiWorld/anyPercent.test +++ b/tests/saiyuukiWorld/anyPercent.test @@ -3,5 +3,6 @@ "Expected ROM SHA1": "C2F12D915A4D0B1FFDF8A64AE1092CE6A2D08770", "Initial State File": "", "Sequence File": "anyPercent.sol", + "Disable State Blocks": [ ], "Credits": "https://tasvideos.org/4422M by aiqiyou & J.Y" } diff --git a/tests/saiyuukiWorld/lastHalf.test b/tests/saiyuukiWorld/lastHalf.test index ae3d654..ac5ef78 100644 --- a/tests/saiyuukiWorld/lastHalf.test +++ b/tests/saiyuukiWorld/lastHalf.test @@ -3,5 +3,6 @@ "Expected ROM SHA1": "C2F12D915A4D0B1FFDF8A64AE1092CE6A2D08770", "Initial State File": "lastHalf.state", "Sequence File": "anyPercent.sol", + "Disable State Blocks": [ ], "Credits": "https://tasvideos.org/4422M by aiqiyou & J.Y" } diff --git a/tests/solarJetman/anyPercent.test b/tests/solarJetman/anyPercent.test index 9d3bae5..352f02b 100644 --- a/tests/solarJetman/anyPercent.test +++ b/tests/solarJetman/anyPercent.test @@ -2,5 +2,6 @@ "Rom File": "../roms/Solar Jetman - Hunt for the Golden Warpship (U) [!].nes", "Expected ROM SHA1": "872B91A2F7A2F635061EF43F79E7F7E9F59F5C50", "Initial State File": "", - "Sequence File": "anyPercent.sol" + "Sequence File": "anyPercent.sol", + "Disable State Blocks": [ ] } diff --git a/tests/sprilo/anyPercent.test b/tests/sprilo/anyPercent.test index c8e3328..f1e28e7 100644 --- a/tests/sprilo/anyPercent.test +++ b/tests/sprilo/anyPercent.test @@ -2,5 +2,6 @@ "Rom File": "../roms/sprilo.nes", "Expected ROM SHA1": "6EC09B9B51320A536A786D3D4719432B714C5779", "Initial State File": "", - "Sequence File": "anyPercent.sol" + "Sequence File": "anyPercent.sol", + "Disable State Blocks": [ ] } diff --git a/tests/superMarioBros/warpless.test b/tests/superMarioBros/warpless.test index 0838d00..c8db3fc 100644 --- a/tests/superMarioBros/warpless.test +++ b/tests/superMarioBros/warpless.test @@ -2,5 +2,6 @@ "Rom File": "../roms/Super Mario Bros. (W) [!].nes", "Expected ROM SHA1": "EA343F4E445A9050D4B4FBAC2C77D0693B1D0922", "Initial State File": "", - "Sequence File": "warpless.sol" + "Sequence File": "warpless.sol", + "Disable State Blocks": [ ] } diff --git a/tests/superMarioBros/warps.test b/tests/superMarioBros/warps.test index d591ad3..848e3ad 100644 --- a/tests/superMarioBros/warps.test +++ b/tests/superMarioBros/warps.test @@ -2,5 +2,6 @@ "Rom File": "../roms/Super Mario Bros. (W) [!].nes", "Expected ROM SHA1": "EA343F4E445A9050D4B4FBAC2C77D0693B1D0922", "Initial State File": "", - "Sequence File": "warps.sol" + "Sequence File": "warps.sol", + "Disable State Blocks": [ ] } diff --git a/tests/superMarioBros3/warps.test b/tests/superMarioBros3/warps.test index a242afa..519501c 100644 --- a/tests/superMarioBros3/warps.test +++ b/tests/superMarioBros3/warps.test @@ -2,5 +2,6 @@ "Rom File": "../roms/Super Mario Bros. 3 (U) (PRG0) [!].nes", "Expected ROM SHA1": "A03E7E526E79DF222E048AE22214BCA2BC49C449", "Initial State File": "", - "Sequence File": "warps.sol" + "Sequence File": "warps.sol", + "Disable State Blocks": [ ] } diff --git a/tests/superOffroad/anyPercent.test b/tests/superOffroad/anyPercent.test index c69074e..6f1dd17 100644 --- a/tests/superOffroad/anyPercent.test +++ b/tests/superOffroad/anyPercent.test @@ -2,5 +2,6 @@ "Rom File": "../roms/Ivan 'Ironman' Stewart's Super Off Road (USA).nes", "Expected ROM SHA1": "57919B685B55EE3ED3AD98FB1D25626B98BE7D39", "Initial State File": "", - "Sequence File": "anyPercent.sol" + "Sequence File": "anyPercent.sol", + "Disable State Blocks": [ ] } diff --git a/tests/tennis/anyPercent.test b/tests/tennis/anyPercent.test index 8a8816f..12a3dad 100644 --- a/tests/tennis/anyPercent.test +++ b/tests/tennis/anyPercent.test @@ -2,5 +2,6 @@ "Rom File": "../roms/Tennis (JU) [!].nes", "Expected ROM SHA1": "80D99C035E6A5AB9718E413EC25CBE094F085962", "Initial State File": "", - "Sequence File": "anyPercent.sol" + "Sequence File": "anyPercent.sol", + "Disable State Blocks": [ ] }