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.
2026-09-26 15:36:11 +02:00
|
|
|
#include "remorse/entity_dispatch_entry.h"
|
Add core functionality for loading and processing game assets
- Implemented palette loading from binary files in `palette.cpp`.
- Added runtime utilities for reading text and JSON files in `runtime.cpp`.
- Created shape archive handling in `shape_archive.cpp`, including frame parsing and pixel decoding.
- Introduced type flag loading functionality in `type_flags.cpp`.
- Developed tests for combat tactics, entity dispatch entries, file system operations, fixed maps, flex archives, glob archives, map rendering, palette loading, shape archives, and type flags.
- Added a Python script for importing Ghidra-exported function slices with reporting capabilities.
2026-04-27 21:15:01 +02:00
|
|
|
#include "remorse/file_system.h"
|
|
|
|
|
#include "remorse/fixed_map.h"
|
2026-09-26 19:50:26 +02:00
|
|
|
#include "remorse/map_renderer.h"
|
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.
2026-09-26 15:36:11 +02:00
|
|
|
#include "remorse/type_flags.h"
|
Add core functionality for loading and processing game assets
- Implemented palette loading from binary files in `palette.cpp`.
- Added runtime utilities for reading text and JSON files in `runtime.cpp`.
- Created shape archive handling in `shape_archive.cpp`, including frame parsing and pixel decoding.
- Introduced type flag loading functionality in `type_flags.cpp`.
- Developed tests for combat tactics, entity dispatch entries, file system operations, fixed maps, flex archives, glob archives, map rendering, palette loading, shape archives, and type flags.
- Added a Python script for importing Ghidra-exported function slices with reporting capabilities.
2026-04-27 21:15:01 +02:00
|
|
|
|
|
|
|
|
#include <cassert>
|
|
|
|
|
#include <filesystem>
|
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.
2026-09-26 15:36:11 +02:00
|
|
|
#include <vector>
|
Add core functionality for loading and processing game assets
- Implemented palette loading from binary files in `palette.cpp`.
- Added runtime utilities for reading text and JSON files in `runtime.cpp`.
- Created shape archive handling in `shape_archive.cpp`, including frame parsing and pixel decoding.
- Introduced type flag loading functionality in `type_flags.cpp`.
- Developed tests for combat tactics, entity dispatch entries, file system operations, fixed maps, flex archives, glob archives, map rendering, palette loading, shape archives, and type flags.
- Added a Python script for importing Ghidra-exported function slices with reporting capabilities.
2026-04-27 21:15:01 +02:00
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
const auto root = remorse::findGameDataRoot(std::filesystem::current_path());
|
|
|
|
|
assert(root.has_value());
|
|
|
|
|
|
|
|
|
|
const auto fixedPath = remorse::resolveGameDataPath(*root, std::filesystem::path("STATIC") / "FIXED.DAT");
|
|
|
|
|
assert(fixedPath.has_value());
|
|
|
|
|
|
|
|
|
|
const auto archive = remorse::loadFixedMapArchive(*fixedPath);
|
|
|
|
|
assert(archive.has_value());
|
|
|
|
|
assert(archive->mapCount > 0);
|
|
|
|
|
|
|
|
|
|
const auto firstMap = remorse::loadFixedMap(*archive, 0);
|
|
|
|
|
assert(firstMap.has_value());
|
|
|
|
|
assert(firstMap->index == 0);
|
|
|
|
|
|
|
|
|
|
bool foundNonEmptyMap = false;
|
|
|
|
|
for (remorse::u32 index = 0; index < archive->mapCount; ++index) {
|
|
|
|
|
const auto map = remorse::loadFixedMap(*archive, index);
|
|
|
|
|
assert(map.has_value());
|
|
|
|
|
if (!map->entries.empty()) {
|
|
|
|
|
foundNonEmptyMap = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
assert(foundNonEmptyMap);
|
|
|
|
|
|
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.
2026-09-26 15:36:11 +02:00
|
|
|
const auto retailMap = remorse::loadFixedMap(*archive, 1);
|
|
|
|
|
assert(retailMap.has_value() && !retailMap->entries.empty());
|
|
|
|
|
const auto cachedItems = remorse::stageFixedMapItems(*retailMap);
|
|
|
|
|
assert(cachedItems.has_value() && !cachedItems->empty());
|
|
|
|
|
assert(cachedItems->back().itemNumber <= remorse::ProcessKernel::maxTrackedItemNumber);
|
|
|
|
|
const auto typeFlagPath = remorse::resolveGameDataPath(*root, std::filesystem::path("STATIC") / "TYPEFLAG.DAT");
|
|
|
|
|
const auto typeFlags = typeFlagPath ? remorse::loadTypeFlags(*typeFlagPath) : std::nullopt;
|
|
|
|
|
assert(typeFlags && cachedItems->front().data.shape < typeFlags->size());
|
2026-09-26 19:20:20 +02:00
|
|
|
const auto retailContained = remorse::stageContainedFixedMapItems(*retailMap, *typeFlags);
|
|
|
|
|
assert(retailContained && retailContained->empty());
|
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.
2026-09-26 15:36:11 +02:00
|
|
|
const auto& originShape = (*typeFlags)[cachedItems->front().data.shape];
|
|
|
|
|
auto origin = cachedItems->front();
|
|
|
|
|
origin.data.z = 80;
|
|
|
|
|
auto candidate = origin;
|
|
|
|
|
candidate.itemNumber = static_cast<remorse::u16>(origin.itemNumber + 1);
|
|
|
|
|
candidate.data.z = static_cast<remorse::u8>(origin.data.z + (originShape.z == 0 && (originShape.flags & 1) == 0 ? 1 : originShape.z * 8));
|
|
|
|
|
remorse::ShapeTypeInfo footprint{0, 0, 1, 1, 0, 0};
|
2026-09-26 19:20:20 +02:00
|
|
|
assert(!remorse::itemFallStartsHurl(footprint));
|
|
|
|
|
footprint.weight = 2;
|
|
|
|
|
assert(remorse::itemFallStartsHurl(footprint));
|
|
|
|
|
footprint.flags = 1;
|
|
|
|
|
assert(!remorse::itemFallStartsHurl(footprint));
|
|
|
|
|
footprint.flags = 0;
|
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.
2026-09-26 15:36:11 +02:00
|
|
|
assert(remorse::classifyItemFindZMatch(origin, originShape, candidate, footprint, 3) == 1);
|
|
|
|
|
assert(remorse::classifyItemFindZMatch(origin, originShape, candidate, footprint, 2) == 0);
|
|
|
|
|
candidate.data.z = 79;
|
|
|
|
|
assert(remorse::classifyItemFindZMatch(origin, originShape, candidate, footprint, 3) == 2);
|
|
|
|
|
remorse::ShapeTypeInfo flatShape{0, 1, 1, 1, 0, 0};
|
|
|
|
|
candidate.data.z = 80;
|
|
|
|
|
assert(remorse::classifyItemFindZMatch(origin, flatShape, candidate, flatShape, 3) == 1);
|
|
|
|
|
candidate.data.x = static_cast<remorse::u16>(origin.data.x + 16);
|
|
|
|
|
assert(remorse::classifyItemFindZMatch(origin, originShape, candidate, footprint, 3) == 0);
|
|
|
|
|
const auto retailSearchArea = remorse::itemFindAreaAroundItem(cachedItems->front(), originShape);
|
|
|
|
|
const auto retailSearchBlocks = remorse::itemFindBlockOrder(retailSearchArea);
|
|
|
|
|
assert(!retailSearchBlocks.empty() && retailSearchBlocks.front() ==
|
|
|
|
|
(retailSearchArea.minX >> 9) * 0x40 + (retailSearchArea.minY >> 9));
|
2026-09-26 19:20:20 +02:00
|
|
|
const auto retailChains = remorse::buildStagedItemBlockChains(*cachedItems);
|
|
|
|
|
assert(retailChains);
|
|
|
|
|
const auto retailCandidates = remorse::itemFindCandidateOrder(retailSearchArea, *retailChains);
|
|
|
|
|
std::size_t stagedItemsInAreaBlocks = 0;
|
|
|
|
|
for (const auto& item : *cachedItems) {
|
|
|
|
|
const auto block = (item.data.x >> 9) * 0x40 + (item.data.y >> 9);
|
|
|
|
|
for (const auto searchBlock : retailSearchBlocks) {
|
|
|
|
|
if (block == searchBlock) {
|
|
|
|
|
++stagedItemsInAreaBlocks;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
assert(!retailCandidates.empty() && retailCandidates.size() == stagedItemsInAreaBlocks);
|
|
|
|
|
const auto retailGrabCandidates = remorse::itemGrabSearchCandidates(cachedItems->front(), *cachedItems, *typeFlags);
|
|
|
|
|
const auto retailGrabActions = remorse::planItemGrabActions(cachedItems->front(), *cachedItems, *typeFlags);
|
|
|
|
|
assert(retailGrabCandidates && retailGrabCandidates->size() == 1);
|
|
|
|
|
assert(retailGrabActions && retailGrabActions->empty());
|
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.
2026-09-26 15:36:11 +02:00
|
|
|
origin.data.x = 511;
|
|
|
|
|
origin.data.y = 511;
|
|
|
|
|
const auto crossingArea = remorse::itemFindAreaAroundItem(origin, footprint);
|
|
|
|
|
assert(crossingArea.minX == 496 && crossingArea.minY == 496);
|
|
|
|
|
assert(crossingArea.maxX == 767 && crossingArea.maxY == 767);
|
|
|
|
|
assert((remorse::itemFindBlockOrder(crossingArea) == std::vector<remorse::u16>{0, 64, 1, 65}));
|
|
|
|
|
origin.data.x = 0;
|
|
|
|
|
origin.data.y = 0;
|
|
|
|
|
const auto edgeArea = remorse::itemFindAreaAroundItem(origin, footprint);
|
|
|
|
|
assert(edgeArea.minX == 0 && edgeArea.minY == 0);
|
|
|
|
|
assert((remorse::itemFindBlockOrder(edgeArea) == std::vector<remorse::u16>{0}));
|
2026-09-26 19:20:20 +02:00
|
|
|
std::vector<remorse::StagedFixedMapItem> blockItems(4);
|
|
|
|
|
blockItems[0].itemNumber = 0x100;
|
|
|
|
|
blockItems[0].data.x = 511;
|
|
|
|
|
blockItems[0].data.y = 511;
|
|
|
|
|
blockItems[1].itemNumber = 0x102;
|
|
|
|
|
blockItems[1].data.x = 512;
|
|
|
|
|
blockItems[1].data.y = 511;
|
|
|
|
|
blockItems[2].itemNumber = 0x103;
|
|
|
|
|
blockItems[2].data.x = 511;
|
|
|
|
|
blockItems[2].data.y = 511;
|
|
|
|
|
blockItems[3].itemNumber = 0x104;
|
|
|
|
|
blockItems[3].data.x = 512;
|
|
|
|
|
blockItems[3].data.y = 512;
|
|
|
|
|
const auto chains = remorse::buildStagedItemBlockChains(blockItems);
|
|
|
|
|
assert(chains && chains->heads[0] == 0x103 && chains->next[0x103] == 0x100);
|
|
|
|
|
assert((remorse::itemFindCandidateOrder(crossingArea, *chains) ==
|
|
|
|
|
std::vector<remorse::u16>{0x103, 0x100, 0x102, 0x104}));
|
|
|
|
|
blockItems[3].itemNumber = 0x103;
|
|
|
|
|
assert(!remorse::buildStagedItemBlockChains(blockItems));
|
|
|
|
|
blockItems[3].itemNumber = 0x104;
|
|
|
|
|
blockItems[3].data.x = 0x8000;
|
|
|
|
|
assert(!remorse::buildStagedItemBlockChains(blockItems));
|
|
|
|
|
blockItems[3].data.x = 512;
|
|
|
|
|
std::vector<remorse::ShapeTypeInfo> searchShapes(2, footprint);
|
|
|
|
|
auto searchOrigin = origin;
|
|
|
|
|
searchOrigin.itemNumber = 0x105;
|
|
|
|
|
searchOrigin.data.x = 511;
|
|
|
|
|
searchOrigin.data.y = 511;
|
|
|
|
|
searchOrigin.data.z = 80;
|
|
|
|
|
searchOrigin.data.shape = 1;
|
|
|
|
|
for (auto& item : blockItems) {
|
|
|
|
|
item.data.shape = 1;
|
|
|
|
|
}
|
|
|
|
|
blockItems[0].data.z = 81;
|
|
|
|
|
blockItems[1].data.z = 0;
|
|
|
|
|
blockItems[2].data.z = 79;
|
|
|
|
|
blockItems[3].data.z = 81;
|
|
|
|
|
blockItems.push_back(searchOrigin);
|
|
|
|
|
const auto zMatches = remorse::itemFindZMatches(searchOrigin, blockItems, searchShapes, 3);
|
|
|
|
|
assert(zMatches && zMatches->size() == 3);
|
|
|
|
|
assert((*zMatches)[0].itemNumber == 0x103 && (*zMatches)[0].matchType == 2);
|
|
|
|
|
assert((*zMatches)[1].itemNumber == 0x100 && (*zMatches)[1].matchType == 1);
|
|
|
|
|
assert((*zMatches)[2].itemNumber == 0x104 && (*zMatches)[2].matchType == 1);
|
|
|
|
|
const auto topMatches = remorse::itemFindZMatches(searchOrigin, blockItems, searchShapes, 1);
|
|
|
|
|
assert(topMatches && topMatches->size() == 2);
|
|
|
|
|
blockItems[3].data.x = 768;
|
|
|
|
|
searchShapes[1].x = 17;
|
|
|
|
|
assert(remorse::classifyItemFindZMatch(searchOrigin, searchShapes[1],
|
|
|
|
|
blockItems[3], searchShapes[1], 1) == 1);
|
|
|
|
|
const auto grabCandidates = remorse::itemGrabSearchCandidates(searchOrigin, blockItems, searchShapes);
|
|
|
|
|
assert(grabCandidates && grabCandidates->size() == 2);
|
|
|
|
|
assert((*grabCandidates)[0].itemNumber == 0x103 && (*grabCandidates)[0].matchType == 2);
|
|
|
|
|
assert((*grabCandidates)[1].itemNumber == 0x100 && (*grabCandidates)[1].matchType == 1);
|
|
|
|
|
const auto grabActions = remorse::planItemGrabActions(searchOrigin, blockItems, searchShapes);
|
|
|
|
|
assert(grabActions && grabActions->size() == 2);
|
|
|
|
|
assert((*grabActions)[0].itemNumber == 0x103 &&
|
|
|
|
|
(*grabActions)[0].kind == remorse::ItemGrabActionKind::CreateProcess);
|
|
|
|
|
assert((*grabActions)[1].itemNumber == 0x100 &&
|
|
|
|
|
(*grabActions)[1].kind == remorse::ItemGrabActionKind::Hurl);
|
|
|
|
|
remorse::ProcessKernel grabKernel;
|
|
|
|
|
remorse::u16 grabGroups[32]{};
|
|
|
|
|
for (int index = 0; index < 3; ++index) {
|
|
|
|
|
grabKernel.createProcess(1, grabGroups);
|
|
|
|
|
}
|
|
|
|
|
const auto dispatched = remorse::dispatchStagedItemGrab(searchOrigin, blockItems, searchShapes,
|
|
|
|
|
grabKernel, grabGroups, 12);
|
|
|
|
|
assert(dispatched && dispatched->size() == 2 && (*dispatched)[0] == 3 && (*dispatched)[1] == 4);
|
|
|
|
|
assert(grabKernel.findProcessForItemAndType(0x103, 0xf1) == grabKernel.processAt(3));
|
|
|
|
|
assert(grabKernel.findProcessForItemAndType(0x100, 0x203) == grabKernel.processAt(4));
|
|
|
|
|
const auto repeated = remorse::dispatchStagedItemGrab(searchOrigin, blockItems, searchShapes,
|
|
|
|
|
grabKernel, grabGroups, 13);
|
|
|
|
|
assert(repeated && repeated->size() == 2 && (*repeated)[0] == 5 && (*repeated)[1] == 4);
|
|
|
|
|
assert(grabGroups[1] == 6);
|
|
|
|
|
remorse::LiveFixedMapItems liveItems(blockItems);
|
|
|
|
|
remorse::ProcessKernel liveKernel;
|
|
|
|
|
remorse::u16 liveGroups[32]{};
|
|
|
|
|
for (int index = 0; index < 3; ++index) {
|
|
|
|
|
liveKernel.createProcess(1, liveGroups);
|
|
|
|
|
}
|
|
|
|
|
assert(!liveItems.findItem(0x106) && !liveItems.moveItem(0x106, 0, 0, 0));
|
|
|
|
|
assert(!liveItems.moveItem(0x100, 0x8000, 0, 0));
|
|
|
|
|
assert(liveItems.moveItem(0x100, 768, 511, 81));
|
|
|
|
|
assert(liveItems.findItem(0x100)->data.x == 768 && blockItems[0].data.x == 511);
|
2026-09-26 19:50:26 +02:00
|
|
|
const auto sweepBefore = liveItems.sweepCandidateIds({511, 511, 512, 512}, 0x105);
|
|
|
|
|
assert(sweepBefore && (*sweepBefore == std::vector<remorse::u16>{0x103, 0x102}));
|
|
|
|
|
assert(!liveItems.sweepCandidateIds({-1, 0, 512, 512}, 0x105));
|
2026-09-26 19:20:20 +02:00
|
|
|
assert(liveItems.nearestItem(768 * 2, 511 * 2, 0)->itemNumber == 0x100);
|
|
|
|
|
assert(!liveItems.nearestItem(511 * 2, 511 * 2, -1));
|
|
|
|
|
assert(!liveItems.grabItem(0x106, searchShapes, liveKernel, liveGroups, 14));
|
|
|
|
|
const auto liveDispatched = liveItems.grabItem(0x105, searchShapes, liveKernel, liveGroups, 14);
|
|
|
|
|
assert(liveDispatched && liveDispatched->size() == 1 && (*liveDispatched)[0] == 3);
|
|
|
|
|
assert(liveKernel.findProcessForItemAndType(0x103, 0xf1) == liveKernel.processAt(3));
|
|
|
|
|
assert(liveKernel.findProcessForItemAndType(0x100, 0x203) == nullptr);
|
|
|
|
|
assert(liveItems.moveItem(0x100, 768, 511, 255));
|
|
|
|
|
assert(liveItems.findItem(0x100)->data.z == 250);
|
|
|
|
|
remorse::LiveFixedMapItems reorderedItems(blockItems);
|
|
|
|
|
remorse::ProcessKernel reorderedKernel;
|
|
|
|
|
remorse::u16 reorderedGroups[32]{};
|
|
|
|
|
for (int index = 0; index < 3; ++index) {
|
|
|
|
|
reorderedKernel.createProcess(1, reorderedGroups);
|
|
|
|
|
}
|
|
|
|
|
assert(reorderedItems.moveItem(0x100, 511, 511, 81));
|
2026-09-26 19:50:26 +02:00
|
|
|
const auto sweepAfter = reorderedItems.sweepCandidateIds({511, 511, 512, 512}, 0x105);
|
|
|
|
|
assert(sweepAfter && (*sweepAfter == std::vector<remorse::u16>{0x100, 0x103, 0x102}));
|
2026-09-26 19:20:20 +02:00
|
|
|
const auto reorderedGrab = reorderedItems.grabItem(0x105, searchShapes,
|
|
|
|
|
reorderedKernel, reorderedGroups, 14);
|
|
|
|
|
assert(reorderedGrab && reorderedGrab->size() == 2 && (*reorderedGrab)[0] == 3 &&
|
|
|
|
|
(*reorderedGrab)[1] == 4);
|
|
|
|
|
assert(reorderedKernel.findProcessForItemAndType(0x100, 0x203) == reorderedKernel.processAt(3));
|
|
|
|
|
assert(reorderedKernel.findProcessForItemAndType(0x103, 0xf1) == reorderedKernel.processAt(4));
|
|
|
|
|
remorse::LiveFixedMapItems insertedItems(blockItems);
|
|
|
|
|
remorse::StagedFixedMapItem newItem = blockItems[2];
|
|
|
|
|
newItem.itemNumber = 0x106;
|
|
|
|
|
assert(!insertedItems.insertItem(blockItems[2]));
|
|
|
|
|
newItem.data.x = 0x8000;
|
|
|
|
|
assert(!insertedItems.insertItem(newItem));
|
|
|
|
|
newItem.data.x = 511;
|
|
|
|
|
assert(insertedItems.insertItem(newItem));
|
|
|
|
|
assert(insertedItems.findItem(0x106)->data.x == 511);
|
|
|
|
|
remorse::ProcessKernel insertedKernel;
|
|
|
|
|
remorse::u16 insertedGroups[32]{};
|
|
|
|
|
for (int index = 0; index < 3; ++index) {
|
|
|
|
|
insertedKernel.createProcess(1, insertedGroups);
|
|
|
|
|
}
|
|
|
|
|
const auto insertedGrab = insertedItems.grabItem(0x105, searchShapes,
|
|
|
|
|
insertedKernel, insertedGroups, 14);
|
|
|
|
|
assert(insertedGrab && insertedGrab->size() == 3 && (*insertedGrab)[0] == 3);
|
|
|
|
|
assert(insertedKernel.findProcessForItemAndType(0x106, 0xf1) == insertedKernel.processAt(3));
|
2026-09-26 19:50:26 +02:00
|
|
|
remorse::LiveFixedMapItems allocatedItems(blockItems, {{0x101, 0x100, 0}});
|
|
|
|
|
newItem.itemNumber = 0;
|
|
|
|
|
assert(!allocatedItems.findItem(0x101));
|
|
|
|
|
assert(allocatedItems.allocateItem(newItem) == 0x106);
|
|
|
|
|
assert(allocatedItems.findItem(0x106)->data.x == 511);
|
|
|
|
|
assert(allocatedItems.allocateItem(newItem) == 0x107);
|
|
|
|
|
newItem.data.x = 0x8000;
|
|
|
|
|
assert(!allocatedItems.allocateItem(newItem) && !allocatedItems.findItem(0x108));
|
2026-09-26 19:20:20 +02:00
|
|
|
remorse::LiveFixedMapItems movingItems(blockItems);
|
|
|
|
|
remorse::ProcessKernel movingKernel;
|
|
|
|
|
remorse::u16 movingGroups[32]{};
|
|
|
|
|
for (int index = 0; index < 3; ++index) {
|
|
|
|
|
movingKernel.createProcess(1, movingGroups);
|
|
|
|
|
}
|
|
|
|
|
const auto rejectedMove = movingItems.moveApprovedItem(0x105, 0x8000, 0, 0,
|
|
|
|
|
searchShapes, movingKernel, movingGroups, 14);
|
|
|
|
|
assert(!rejectedMove && movingItems.findItem(0x105)->data.x == 511 && movingKernel.processCount() == 3);
|
|
|
|
|
const auto approvedMove = movingItems.moveApprovedItem(0x105, 768, 768, 80,
|
|
|
|
|
searchShapes, movingKernel, movingGroups, 14);
|
|
|
|
|
assert(approvedMove && approvedMove->size() == 2 && (*approvedMove)[0] == 3 && (*approvedMove)[1] == 4);
|
|
|
|
|
assert(movingItems.findItem(0x105)->data.x == 768 && movingItems.findItem(0x105)->data.y == 768);
|
|
|
|
|
const auto afterMoveGrab = movingItems.grabItem(0x105, searchShapes, movingKernel, movingGroups, 15);
|
|
|
|
|
assert(afterMoveGrab && afterMoveGrab->empty());
|
|
|
|
|
blockItems[0].itemNumber = 0x2400;
|
|
|
|
|
const auto priorProcessCount = grabKernel.processCount();
|
|
|
|
|
assert(!remorse::dispatchStagedItemGrab(searchOrigin, blockItems, searchShapes,
|
|
|
|
|
grabKernel, grabGroups, 14));
|
|
|
|
|
assert(grabKernel.processCount() == priorProcessCount);
|
|
|
|
|
blockItems[0].itemNumber = 0x100;
|
|
|
|
|
blockItems[2].data.flags |= 2;
|
|
|
|
|
searchShapes[1].weight = 0;
|
|
|
|
|
const auto blockedActions = remorse::planItemGrabActions(searchOrigin, blockItems, searchShapes);
|
|
|
|
|
assert(blockedActions && blockedActions->empty());
|
|
|
|
|
searchShapes[1].x = 1;
|
|
|
|
|
searchOrigin.data.shape = 2;
|
|
|
|
|
assert(!remorse::itemFindZMatches(searchOrigin, blockItems, searchShapes, 3));
|
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.
2026-09-26 15:36:11 +02:00
|
|
|
candidate.itemNumber = 0;
|
|
|
|
|
assert(remorse::classifyItemFindZMatch(origin, originShape, candidate, footprint, 3) == 0);
|
|
|
|
|
assert(cachedItems->front().recordIndex < retailMap->entries.size());
|
2026-09-26 19:20:20 +02:00
|
|
|
const remorse::LiveFixedMapItems retailLiveItems(*cachedItems);
|
|
|
|
|
assert(retailLiveItems.findItem(cachedItems->front().itemNumber)->recordIndex ==
|
|
|
|
|
cachedItems->front().recordIndex);
|
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.
2026-09-26 15:36:11 +02:00
|
|
|
for (const auto& item : *cachedItems) {
|
|
|
|
|
const auto& record = retailMap->entries[item.recordIndex];
|
|
|
|
|
assert(record.shape != 0 && (record.flags & 8) == 0);
|
|
|
|
|
assert(item.data.x == record.x / 2 && item.data.y == record.y / 2);
|
|
|
|
|
assert(item.data.shape == record.shape);
|
|
|
|
|
assert(item.data.npcNumber == record.npcNumber);
|
|
|
|
|
assert(item.data.flags == (record.flags & ~1u));
|
|
|
|
|
}
|
|
|
|
|
remorse::ProcessKernel retailKernel;
|
|
|
|
|
remorse::u16 retailGroups[32]{};
|
|
|
|
|
for (int index = 0; index < 3; ++index) {
|
|
|
|
|
retailKernel.createProcess(1, retailGroups);
|
|
|
|
|
}
|
|
|
|
|
const auto retailItemNumber = cachedItems->front().itemNumber;
|
|
|
|
|
auto* retailProcess = retailKernel.createItemProcess(1, retailItemNumber, retailGroups);
|
|
|
|
|
assert(retailProcess->bytes[4] == static_cast<remorse::u8>(retailItemNumber));
|
|
|
|
|
assert(retailKernel.itemHasProcess(retailItemNumber));
|
|
|
|
|
struct RetailScan {
|
|
|
|
|
remorse::ProcessKernel* kernel;
|
|
|
|
|
remorse::u16 (*groups)[32];
|
|
|
|
|
remorse::u16 released = 0;
|
|
|
|
|
int releaseCount = 0;
|
|
|
|
|
} retailScan{&retailKernel, &retailGroups};
|
|
|
|
|
auto runRetailItem = [](remorse::EntityDispatchEntryBase& process, void* context) {
|
|
|
|
|
auto& scan = *static_cast<RetailScan*>(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) {
|
|
|
|
|
assert(eventMask == 0x200 && eventId == 9);
|
|
|
|
|
auto& result = *static_cast<RetailScan*>(releaseContext);
|
|
|
|
|
result.released = itemNumber;
|
|
|
|
|
++result.releaseCount;
|
|
|
|
|
}, &scan);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
retailKernel.scanRunnableProcesses(1, runRetailItem, &retailScan, 1);
|
|
|
|
|
retailKernel.scanRunnableProcesses(1, runRetailItem, &retailScan, 2);
|
|
|
|
|
assert(retailScan.released == retailItemNumber && retailScan.releaseCount == 1);
|
|
|
|
|
assert(retailKernel.processAt(3) == nullptr && !retailKernel.itemHasProcess(retailItemNumber));
|
|
|
|
|
assert(retailGroups[1] == 3);
|
|
|
|
|
remorse::FixedMap stagedMap;
|
|
|
|
|
stagedMap.entries.resize(4);
|
|
|
|
|
stagedMap.entries[1].shape = 16;
|
|
|
|
|
stagedMap.entries[2].shape = 16;
|
|
|
|
|
stagedMap.entries[2].flags = 8;
|
|
|
|
|
stagedMap.entries[3].shape = 16;
|
|
|
|
|
stagedMap.entries[3].flags = 1;
|
|
|
|
|
auto stagedItems = remorse::stageFixedMapItems(stagedMap);
|
|
|
|
|
assert(stagedItems && stagedItems->size() == 2);
|
|
|
|
|
assert((*stagedItems)[0].recordIndex == 1 && (*stagedItems)[0].itemNumber == 0x100);
|
|
|
|
|
assert((*stagedItems)[1].recordIndex == 3 && (*stagedItems)[1].itemNumber == 0x102);
|
|
|
|
|
assert((*stagedItems)[1].data.flags == 0);
|
2026-09-26 19:20:20 +02:00
|
|
|
remorse::FixedMap containedMap;
|
|
|
|
|
containedMap.index = 1;
|
|
|
|
|
containedMap.entries.resize(5);
|
|
|
|
|
for (auto& record : containedMap.entries) {
|
|
|
|
|
record.shape = 1;
|
|
|
|
|
}
|
|
|
|
|
containedMap.entries[1].flags = 8;
|
|
|
|
|
containedMap.entries[1].x = 2;
|
|
|
|
|
containedMap.entries[2].flags = 8;
|
|
|
|
|
containedMap.entries[2].x = 4;
|
|
|
|
|
containedMap.entries[3].flags = 8;
|
|
|
|
|
containedMap.entries[3].x = 2;
|
|
|
|
|
std::vector<remorse::ShapeTypeInfo> containerShapes(2);
|
|
|
|
|
containerShapes[1].family = 6;
|
|
|
|
|
const auto contained = remorse::stageContainedFixedMapItems(containedMap, containerShapes);
|
|
|
|
|
assert(contained && contained->size() == 3);
|
|
|
|
|
assert((*contained)[0].itemNumber == 0x101 && (*contained)[0].parentItemNumber == 0x100);
|
|
|
|
|
assert((*contained)[1].itemNumber == 0x102 && (*contained)[1].parentItemNumber == 0x101);
|
|
|
|
|
assert((*contained)[2].itemNumber == 0x103 && (*contained)[2].parentItemNumber == 0x100);
|
2026-09-26 19:50:26 +02:00
|
|
|
const auto directContainerItems = remorse::stageFixedMapItems(containedMap);
|
|
|
|
|
assert(directContainerItems && directContainerItems->size() == 2);
|
|
|
|
|
remorse::LiveFixedMapItems nestedItems(*directContainerItems, *contained);
|
|
|
|
|
assert(nestedItems.containedParent(0x101) == 0x100 &&
|
|
|
|
|
nestedItems.containedParent(0x102) == 0x101 && nestedItems.containedParent(0x103) == 0x100);
|
|
|
|
|
remorse::StagedFixedMapItem nestedNewItem = directContainerItems->front();
|
|
|
|
|
assert(nestedItems.allocateItem(nestedNewItem) == 0x105);
|
|
|
|
|
assert(!nestedItems.findItem(0x101) && !nestedItems.findItem(0x102) &&
|
|
|
|
|
!nestedItems.findItem(0x103) && nestedItems.findItem(0x105));
|
|
|
|
|
nestedNewItem.itemNumber = 0x101;
|
|
|
|
|
assert(nestedItems.insertItem(nestedNewItem));
|
|
|
|
|
assert(nestedItems.containedParent(0x101) == 0 && nestedItems.containedParent(0x102) == 0x101);
|
|
|
|
|
std::vector<remorse::StagedContainedFixedMapItem> fullItemRange;
|
|
|
|
|
for (remorse::u16 itemNumber = 0x101; itemNumber < 0x2800; ++itemNumber) {
|
|
|
|
|
fullItemRange.push_back({itemNumber, 0x100, 0});
|
|
|
|
|
}
|
|
|
|
|
remorse::LiveFixedMapItems exhaustedItems({directContainerItems->front()}, fullItemRange);
|
|
|
|
|
assert(!exhaustedItems.allocateItem(nestedNewItem));
|
|
|
|
|
assert(!exhaustedItems.findItem(0x101) && exhaustedItems.containedParent(0x101) == 0x100);
|
2026-09-26 19:20:20 +02:00
|
|
|
containerShapes[1].family = 0;
|
|
|
|
|
assert(!remorse::stageContainedFixedMapItems(containedMap, containerShapes));
|
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.
2026-09-26 15:36:11 +02:00
|
|
|
assert(remorse::itemGrabCanCreateProcess((*stagedItems)[0]));
|
|
|
|
|
(*stagedItems)[0].data.flags |= 0x02;
|
|
|
|
|
assert(!remorse::itemGrabCanCreateProcess((*stagedItems)[0]));
|
|
|
|
|
(*stagedItems)[0].data.x = 20;
|
|
|
|
|
(*stagedItems)[0].data.y = 10;
|
|
|
|
|
(*stagedItems)[1].data.x = 30;
|
|
|
|
|
(*stagedItems)[1].data.y = 10;
|
|
|
|
|
const auto nearby = remorse::nearestStagedFixedMapItem(*stagedItems, 59, 20, 16);
|
|
|
|
|
assert(nearby && nearby->itemNumber == 0x102);
|
|
|
|
|
assert(!remorse::nearestStagedFixedMapItem(*stagedItems, 100, 20, 16));
|
|
|
|
|
assert(!remorse::nearestStagedFixedMapItem(*stagedItems, 60, 20, -1));
|
|
|
|
|
remorse::FixedMap oversizedMap;
|
|
|
|
|
oversizedMap.entries.resize(0x2701);
|
|
|
|
|
for (auto& record : oversizedMap.entries) {
|
|
|
|
|
record.shape = 16;
|
|
|
|
|
}
|
|
|
|
|
assert(!remorse::stageFixedMapItems(oversizedMap).has_value());
|
|
|
|
|
remorse::FixedMap widerCacheMap;
|
|
|
|
|
widerCacheMap.entries.resize(0x2301);
|
|
|
|
|
for (auto& record : widerCacheMap.entries) {
|
|
|
|
|
record.shape = 16;
|
|
|
|
|
}
|
|
|
|
|
const auto widerCacheItems = remorse::stageFixedMapItems(widerCacheMap);
|
|
|
|
|
assert(widerCacheItems && widerCacheItems->back().itemNumber == 0x2400);
|
|
|
|
|
assert(widerCacheItems->back().itemNumber > remorse::ProcessKernel::maxTrackedItemNumber);
|
|
|
|
|
|
Add core functionality for loading and processing game assets
- Implemented palette loading from binary files in `palette.cpp`.
- Added runtime utilities for reading text and JSON files in `runtime.cpp`.
- Created shape archive handling in `shape_archive.cpp`, including frame parsing and pixel decoding.
- Introduced type flag loading functionality in `type_flags.cpp`.
- Developed tests for combat tactics, entity dispatch entries, file system operations, fixed maps, flex archives, glob archives, map rendering, palette loading, shape archives, and type flags.
- Added a Python script for importing Ghidra-exported function slices with reporting capabilities.
2026-04-27 21:15:01 +02:00
|
|
|
const auto outOfRange = remorse::loadFixedMap(*archive, archive->mapCount);
|
|
|
|
|
assert(!outOfRange.has_value());
|
|
|
|
|
return 0;
|
|
|
|
|
}
|