Add comprehensive tests for entity dispatch, file system, fixed map, flex archive, isometric controls, and crash setup
- Enhance `entity_dispatch_entry_tests.cpp` with additional assertions for event type checks, group ID increments, and error handling. - Refactor `file_system_tests.cpp` to streamline probe execution and enhance output validation. - Extend `fixed_map_tests.cpp` to cover retail map loading, item classification, and process creation scenarios. - Introduce new checks in `flex_archive_tests.cpp` for usecode loading and event handling, ensuring robust validation of game data. - Add tests in `isometric_controls_tests.cpp` for controller direction mapping based on scan codes. - Implement `test_crash_setup.cpp` to initialize crash diagnostics for improved error handling during tests.
This commit is contained in:
parent
202679f857
commit
c346b0e1a7
17 changed files with 1207 additions and 92 deletions
|
|
@ -7,6 +7,7 @@
|
|||
#include "remorse/palette.h"
|
||||
#include "remorse/runtime.h"
|
||||
#include "remorse/type_flags.h"
|
||||
#include "remorse/usecode_archive.h"
|
||||
|
||||
#include <filesystem>
|
||||
#include <iostream>
|
||||
|
|
@ -27,7 +28,7 @@ int main(int argc, char** argv)
|
|||
remorse::printStartupReport(*manifest);
|
||||
remorse::ProcessKernel kernel;
|
||||
remorse::u16 groupCounts[32]{};
|
||||
const auto* entry = kernel.createProcess(1, groupCounts);
|
||||
auto* entry = kernel.createProcess(1, groupCounts);
|
||||
std::cout << "Registered process ID: " << (entry ? entry->bytes[0x02] : 0) << '\n';
|
||||
for (int index = 0; index < 3; ++index) {
|
||||
kernel.createProcess(1, groupCounts);
|
||||
|
|
@ -57,20 +58,25 @@ int main(int argc, char** argv)
|
|||
kernel.deliverSystemTimerEvent();
|
||||
}
|
||||
scanContext.timerTick = kernel.systemTimerTick();
|
||||
kernel.scanRunnableProcesses(1, [](remorse::EntityDispatchEntryBase& process, void* context) {
|
||||
const remorse::u32 schedulerElapsed = kernel.runTimedSchedulerPass(1, [](remorse::EntityDispatchEntryBase& process, void* context) {
|
||||
auto& scan = *static_cast<ScanContext*>(context);
|
||||
if (process.bytes[0] == 0x0f && process.bytes[1] == 0x1f) {
|
||||
remorse::StandProcess::run(*scan.standing, *scan.npcServices, scan.timerTick);
|
||||
} else {
|
||||
++scan.hostCallbacks;
|
||||
}
|
||||
}, &scanContext, scanContext.timerTick);
|
||||
}, &scanContext);
|
||||
kernel.refreshActiveGroup(groupCounts);
|
||||
remorse::EntityDispatchEntry::incrementGroupId(*entry, kernel, groupCounts);
|
||||
std::cout << "Advanced process group: " << static_cast<int>(kernel.activeGroup()) << '\n';
|
||||
std::cout << "Scheduler scan host callbacks: " << scanContext.hostCallbacks << '\n';
|
||||
std::cout << "Scheduler pass elapsed ticks: " << schedulerElapsed << '\n';
|
||||
std::cout << "StandProcess Run sleep ticks: " << static_cast<int>(reused->base.bytes[0x0e]) << '\n';
|
||||
|
||||
const auto gameDataRoot = remorse::findGameDataRoot(std::filesystem::current_path());
|
||||
std::cout << "Game data root: " << (gameDataRoot ? gameDataRoot->path.string() : "not found") << '\n';
|
||||
if (gameDataRoot) {
|
||||
std::optional<remorse::StagedFixedMapItem> firstStagedItem;
|
||||
const auto palettePath = remorse::resolveGameDataPath(*gameDataRoot, std::filesystem::path("STATIC") / "GAMEPAL.PAL");
|
||||
const auto paletteBytes = palettePath ? remorse::readBinaryFile(*palettePath) : std::nullopt;
|
||||
std::cout << "GAMEPAL.PAL bytes: " << (paletteBytes ? paletteBytes->size() : 0) << '\n';
|
||||
|
|
@ -92,6 +98,33 @@ int main(int argc, char** argv)
|
|||
if (map && !map->entries.empty()) {
|
||||
std::cout << "FIXED.DAT first non-empty map: " << index << '\n';
|
||||
std::cout << "FIXED.DAT first non-empty entries: " << map->entries.size() << '\n';
|
||||
const auto items = remorse::stageFixedMapItems(*map);
|
||||
if (items && !items->empty()) {
|
||||
firstStagedItem = items->front();
|
||||
struct ItemScanContext {
|
||||
remorse::ProcessKernel* kernel;
|
||||
remorse::u16 (*groups)[32];
|
||||
remorse::u16 releaseEventItem = 0;
|
||||
} itemScan{&kernel, &groupCounts};
|
||||
auto* itemProcess = kernel.createItemProcess(kernel.activeGroup(), items->front().itemNumber, groupCounts);
|
||||
const remorse::u16 itemProcessId = static_cast<remorse::u16>(
|
||||
itemProcess->bytes[2] | (static_cast<remorse::u16>(itemProcess->bytes[3]) << 8));
|
||||
kernel.scanRunnableProcesses(kernel.activeGroup(), [](remorse::EntityDispatchEntryBase& process, void* context) {
|
||||
auto& scan = *static_cast<ItemScanContext*>(context);
|
||||
if (process.bytes[0] == 0x2f && process.bytes[1] == 0x10) {
|
||||
remorse::ItemProcess::run(process, *scan.kernel, *scan.groups,
|
||||
[](remorse::u16 itemNumber, remorse::u32 eventMask, remorse::u16 eventId, void* releaseContext) {
|
||||
if (eventMask == 0x200 && eventId == 9) {
|
||||
static_cast<ItemScanContext*>(releaseContext)->releaseEventItem = itemNumber;
|
||||
}
|
||||
}, &scan);
|
||||
}
|
||||
}, &itemScan, kernel.systemTimerTick());
|
||||
kernel.refreshActiveGroup(groupCounts);
|
||||
std::cout << "Staged retail item shape: " << items->front().data.shape << '\n';
|
||||
std::cout << "ItemProcess release event boundary item: " << itemScan.releaseEventItem << '\n';
|
||||
std::cout << "ItemProcess terminated: " << (kernel.processAt(itemProcessId) == nullptr) << '\n';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -104,6 +137,26 @@ int main(int argc, char** argv)
|
|||
const auto typeFlagPath = remorse::resolveGameDataPath(*gameDataRoot, std::filesystem::path("STATIC") / "TYPEFLAG.DAT");
|
||||
const auto typeFlags = typeFlagPath ? remorse::loadTypeFlags(*typeFlagPath) : std::nullopt;
|
||||
std::cout << "TYPEFLAG.DAT shapes: " << (typeFlags ? typeFlags->size() : 0) << '\n';
|
||||
if (firstStagedItem && typeFlags && firstStagedItem->data.shape < typeFlags->size()) {
|
||||
const auto area = remorse::itemFindAreaAroundItem(
|
||||
*firstStagedItem, (*typeFlags)[firstStagedItem->data.shape]);
|
||||
std::cout << "Staged item ItemFind blocks: " << remorse::itemFindBlockOrder(area).size() << '\n';
|
||||
}
|
||||
|
||||
const auto usecodePath = remorse::resolveGameDataPath(*gameDataRoot, std::filesystem::path("USECODE") / "EUSECODE.FLX");
|
||||
const auto usecodeArchive = usecodePath ? remorse::loadFlexArchive(*usecodePath) : std::nullopt;
|
||||
const auto eventClass = usecodeArchive ? remorse::loadUsecodeClass(*usecodeArchive, 0x361) : std::nullopt;
|
||||
const auto eventBody = eventClass ? remorse::readUsecodeEventBody(*eventClass, 0x0a) : std::nullopt;
|
||||
std::cout << "EUSECODE EVENT slot 0x0a body bytes: " << (eventBody ? eventBody->bytes.size() : 0) << '\n';
|
||||
if (firstStagedItem && typeFlags && usecodeArchive && firstStagedItem->data.shape < typeFlags->size()) {
|
||||
const auto& item = *firstStagedItem;
|
||||
const remorse::UsecodeItemIdentity identity{item.itemNumber, item.data.shape,
|
||||
item.data.flags, item.data.quality, (*typeFlags)[item.data.shape].family, false};
|
||||
const remorse::UsecodeClassBases bases{0, 0x800, 0x900};
|
||||
const auto itemClass = remorse::loadUsecodeClass(*usecodeArchive,
|
||||
remorse::selectUsecodeClassId(identity, bases));
|
||||
std::cout << "Staged item USECODE class: " << (itemClass ? itemClass->name : "not present") << '\n';
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue