Adding block discrimination mechanism for light states

This commit is contained in:
Sergio Martin 2024-01-20 18:30:24 +01:00
parent e376b69d84
commit 3b4a530d42
27 changed files with 75 additions and 48 deletions

View File

@ -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<uint8_t *>(&result));

View File

@ -79,15 +79,15 @@ int main(int argc, char *argv[])
std::string expectedROMSHA1 = scriptJson["Expected ROM SHA1"].get<std::string>();
// Parsing disabled blocks in lite state serialization
std::vector<std::string> 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<std::string> 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<std::string>());
liteStateDisabledBlocksOutput += entry.get<std::string>() + 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<std::string>());
stateDisabledBlocksOutput += entry.get<std::string>() + 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);

View File

@ -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" ]
}

View File

@ -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" ]
}

View File

@ -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" ]
}

View File

@ -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" ]
}

View File

@ -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": [ ]
}

View File

@ -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": [ ]
}

View File

@ -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": [ ]
}

View File

@ -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": [ ]
}

View File

@ -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": [ ]
}

View File

@ -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": [ ]
}

View File

@ -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": [ ]
}

View File

@ -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": [ ]
}

View File

@ -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": [ ]
}

View File

@ -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": [ ]
}

View File

@ -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": [ ]
}

View File

@ -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": [ ]
}

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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": [ ]
}

View File

@ -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": [ ]
}

View File

@ -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": [ ]
}

View File

@ -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": [ ]
}

View File

@ -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": [ ]
}

View File

@ -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": [ ]
}

View File

@ -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": [ ]
}