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
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <filesystem>
|
|
|
|
|
#include <optional>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#include "remorse/compat.h"
|
|
|
|
|
|
|
|
|
|
namespace remorse {
|
|
|
|
|
|
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
|
|
|
struct ShapeTypeInfo;
|
2026-09-26 19:50:26 +02:00
|
|
|
struct WorldRect;
|
2026-09-27 11:48:14 +02:00
|
|
|
struct GlobObject;
|
2026-09-26 19:20:20 +02:00
|
|
|
class ProcessKernel;
|
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
|
|
|
|
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
|
|
|
struct FixedMapEntry {
|
|
|
|
|
u16 x = 0;
|
|
|
|
|
u16 y = 0;
|
|
|
|
|
u8 z = 0;
|
|
|
|
|
u16 shape = 0;
|
|
|
|
|
u8 frame = 0;
|
|
|
|
|
u16 flags = 0;
|
|
|
|
|
u16 quality = 0;
|
|
|
|
|
u8 npcNumber = 0;
|
|
|
|
|
u8 mapNumber = 0;
|
|
|
|
|
u16 next = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct FixedMap {
|
|
|
|
|
u32 index = 0;
|
|
|
|
|
std::vector<FixedMapEntry> entries;
|
|
|
|
|
};
|
|
|
|
|
|
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
|
|
|
struct StagedFixedMapItem {
|
|
|
|
|
u16 itemNumber = 0;
|
|
|
|
|
std::size_t recordIndex = 0;
|
|
|
|
|
FixedMapEntry data;
|
|
|
|
|
};
|
|
|
|
|
|
2026-09-26 19:20:20 +02:00
|
|
|
struct StagedContainedFixedMapItem {
|
|
|
|
|
u16 itemNumber = 0;
|
|
|
|
|
u16 parentItemNumber = 0;
|
|
|
|
|
std::size_t recordIndex = 0;
|
2026-10-04 18:11:16 +02:00
|
|
|
FixedMapEntry data;
|
2026-09-26 19:20:20 +02:00
|
|
|
};
|
|
|
|
|
|
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
|
|
|
struct ItemFindArea {
|
|
|
|
|
u16 minX = 0;
|
|
|
|
|
u16 minY = 0;
|
|
|
|
|
u16 maxX = 0;
|
|
|
|
|
u16 maxY = 0;
|
|
|
|
|
};
|
|
|
|
|
|
2026-09-26 19:20:20 +02:00
|
|
|
struct StagedItemBlockChains {
|
|
|
|
|
std::vector<u16> heads;
|
|
|
|
|
std::vector<u16> next;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ItemFindZCandidate {
|
|
|
|
|
u16 itemNumber = 0;
|
|
|
|
|
u8 matchType = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum class ItemGrabActionKind {
|
|
|
|
|
Hurl,
|
|
|
|
|
CreateProcess
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ItemGrabAction {
|
|
|
|
|
u16 itemNumber = 0;
|
|
|
|
|
ItemGrabActionKind kind = ItemGrabActionKind::Hurl;
|
|
|
|
|
};
|
|
|
|
|
|
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
|
|
|
struct FixedMapArchive {
|
|
|
|
|
u32 mapCount = 0;
|
|
|
|
|
std::vector<u8> bytes;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
std::optional<FixedMapArchive> loadFixedMapArchive(const std::filesystem::path& path);
|
|
|
|
|
std::optional<FixedMap> loadFixedMap(const FixedMapArchive& archive, u32 mapIndex);
|
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
|
|
|
std::optional<std::vector<StagedFixedMapItem>> stageFixedMapItems(const FixedMap& map);
|
2026-09-27 11:48:14 +02:00
|
|
|
std::optional<StagedFixedMapItem> findTeleportEgg(
|
|
|
|
|
const std::vector<StagedFixedMapItem>& items, const std::vector<ShapeTypeInfo>& shapes, u8 eggId);
|
2026-10-06 21:07:35 +02:00
|
|
|
std::optional<StagedFixedMapItem> findNearbyActiveTeleportEgg(const StagedFixedMapItem& origin,
|
|
|
|
|
const std::vector<StagedFixedMapItem>& items, const std::vector<ShapeTypeInfo>& shapes,
|
|
|
|
|
u8 currentMapNumber);
|
2026-09-26 19:20:20 +02:00
|
|
|
std::optional<std::vector<StagedContainedFixedMapItem>> stageContainedFixedMapItems(
|
|
|
|
|
const FixedMap& map, const std::vector<ShapeTypeInfo>& shapes);
|
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
|
|
|
std::optional<StagedFixedMapItem> nearestStagedFixedMapItem(
|
|
|
|
|
const std::vector<StagedFixedMapItem>& items, s32 worldX, s32 worldY, s32 maxDistance);
|
|
|
|
|
bool itemGrabCanCreateProcess(const StagedFixedMapItem& item);
|
2026-09-26 19:20:20 +02:00
|
|
|
bool itemFallStartsHurl(const ShapeTypeInfo& shape);
|
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
|
|
|
u8 classifyItemFindZMatch(const StagedFixedMapItem& origin, const ShapeTypeInfo& originShape,
|
|
|
|
|
const StagedFixedMapItem& candidate, const ShapeTypeInfo& candidateShape, u8 zMatchFlags);
|
|
|
|
|
ItemFindArea itemFindAreaAroundItem(const StagedFixedMapItem& origin, const ShapeTypeInfo& originShape);
|
|
|
|
|
std::vector<u16> itemFindBlockOrder(const ItemFindArea& area);
|
2026-09-26 19:20:20 +02:00
|
|
|
std::optional<StagedItemBlockChains> buildStagedItemBlockChains(const std::vector<StagedFixedMapItem>& items);
|
|
|
|
|
std::vector<u16> itemFindCandidateOrder(const ItemFindArea& area, const StagedItemBlockChains& chains);
|
|
|
|
|
std::optional<std::vector<ItemFindZCandidate>> itemFindZMatches(const StagedFixedMapItem& origin,
|
|
|
|
|
const std::vector<StagedFixedMapItem>& items, const std::vector<ShapeTypeInfo>& shapes, u8 zMatchFlags);
|
|
|
|
|
std::optional<std::vector<ItemFindZCandidate>> itemGrabSearchCandidates(const StagedFixedMapItem& origin,
|
|
|
|
|
const std::vector<StagedFixedMapItem>& items, const std::vector<ShapeTypeInfo>& shapes);
|
|
|
|
|
std::optional<std::vector<ItemGrabAction>> planItemGrabActions(const StagedFixedMapItem& origin,
|
|
|
|
|
const std::vector<StagedFixedMapItem>& items, const std::vector<ShapeTypeInfo>& shapes);
|
|
|
|
|
std::optional<std::vector<u16>> dispatchStagedItemGrab(const StagedFixedMapItem& origin,
|
|
|
|
|
const std::vector<StagedFixedMapItem>& items, const std::vector<ShapeTypeInfo>& shapes,
|
|
|
|
|
ProcessKernel& kernel, u16 (&groupCounts)[32], u32 timerTick);
|
|
|
|
|
|
2026-09-27 11:48:14 +02:00
|
|
|
struct NpcAnimationState {
|
|
|
|
|
u16 lastAnimation = 0xffff;
|
|
|
|
|
u8 frame = 0;
|
|
|
|
|
u8 moreFlags = 0;
|
|
|
|
|
};
|
|
|
|
|
|
2026-09-26 19:20:20 +02:00
|
|
|
class LiveFixedMapItems {
|
|
|
|
|
public:
|
2026-09-26 19:50:26 +02:00
|
|
|
explicit LiveFixedMapItems(std::vector<StagedFixedMapItem> items,
|
|
|
|
|
std::vector<StagedContainedFixedMapItem> containedItems = {});
|
2026-09-27 11:48:14 +02:00
|
|
|
bool initializeAvatar();
|
|
|
|
|
bool teleportAvatar(const StagedFixedMapItem& egg, u8 mapNumber);
|
2026-09-26 19:20:20 +02:00
|
|
|
const StagedFixedMapItem* findItem(u16 itemNumber) const;
|
2026-09-27 11:48:14 +02:00
|
|
|
const std::vector<StagedFixedMapItem>& mapItems() const noexcept { return items_; }
|
|
|
|
|
const NpcAnimationState* findNpcAnimation(u16 itemNumber) const;
|
|
|
|
|
NpcAnimationState* editNpcAnimation(u16 itemNumber);
|
2026-09-26 19:50:26 +02:00
|
|
|
u16 containedParent(u16 itemNumber) const;
|
2026-10-04 18:11:16 +02:00
|
|
|
std::vector<u16> containedChildren(u16 parentItemNumber) const;
|
2026-09-26 19:20:20 +02:00
|
|
|
std::optional<StagedFixedMapItem> nearestItem(s32 worldX, s32 worldY, s32 maxDistance) const;
|
2026-09-26 19:50:26 +02:00
|
|
|
std::optional<std::vector<u16>> sweepCandidateIds(const WorldRect& area, u16 excludedItemNumber) const;
|
|
|
|
|
std::optional<u16> allocateItem(StagedFixedMapItem item);
|
2026-09-26 19:20:20 +02:00
|
|
|
bool insertItem(StagedFixedMapItem item);
|
2026-10-04 18:11:16 +02:00
|
|
|
bool moveItemIntoContainer(u16 itemNumber, u16 containerItemNumber,
|
|
|
|
|
const std::vector<ShapeTypeInfo>& shapes);
|
|
|
|
|
bool moveContainedItemToWorld(u16 itemNumber, u16 x, u16 y, u8 z);
|
|
|
|
|
bool releaseItem(u16 itemNumber, const ProcessKernel& kernel);
|
2026-09-27 11:48:14 +02:00
|
|
|
std::optional<std::vector<u16>> hatchGlobEgg(u16 eggItemNumber, const GlobObject& glob,
|
|
|
|
|
const std::vector<ShapeTypeInfo>& shapes);
|
|
|
|
|
bool isGlobHatched(u16 eggItemNumber) const;
|
2026-10-06 00:01:20 +02:00
|
|
|
bool setItemShape(u16 itemNumber, u16 shape);
|
2026-10-04 18:11:16 +02:00
|
|
|
bool setItemFrame(u16 itemNumber, u8 frame);
|
2026-09-26 19:20:20 +02:00
|
|
|
bool moveItem(u16 itemNumber, u16 x, u16 y, u8 z);
|
|
|
|
|
std::optional<std::vector<u16>> grabItem(u16 itemNumber, const std::vector<ShapeTypeInfo>& shapes,
|
|
|
|
|
ProcessKernel& kernel, u16 (&groupCounts)[32], u32 timerTick) const;
|
|
|
|
|
std::optional<std::vector<u16>> moveApprovedItem(u16 itemNumber, u16 x, u16 y, u8 z,
|
|
|
|
|
const std::vector<ShapeTypeInfo>& shapes, ProcessKernel& kernel,
|
|
|
|
|
u16 (&groupCounts)[32], u32 timerTick);
|
|
|
|
|
|
|
|
|
|
private:
|
2026-10-04 18:11:16 +02:00
|
|
|
bool unlinkContainedItem(u16 itemNumber);
|
|
|
|
|
void refreshContainerQuality(u16 parentItemNumber);
|
|
|
|
|
bool insertContainedItemAtHead(u16 parentItemNumber, u16 itemNumber);
|
2026-09-26 19:20:20 +02:00
|
|
|
std::vector<StagedFixedMapItem> items_;
|
2026-09-27 11:48:14 +02:00
|
|
|
std::optional<StagedFixedMapItem> avatar_;
|
|
|
|
|
std::vector<NpcAnimationState> npcAnimations_;
|
2026-09-26 19:50:26 +02:00
|
|
|
std::vector<bool> allocatedIds_;
|
2026-09-27 11:48:14 +02:00
|
|
|
std::vector<bool> hatchedGlobIds_;
|
2026-09-26 19:50:26 +02:00
|
|
|
std::vector<u16> parentById_;
|
2026-10-04 18:11:16 +02:00
|
|
|
std::vector<std::optional<FixedMapEntry>> containedItemData_;
|
|
|
|
|
std::vector<u16> containedNextById_;
|
|
|
|
|
std::vector<u16> containedHeadById_;
|
|
|
|
|
std::vector<u16> containedTailById_;
|
|
|
|
|
std::vector<u16> freeItemIds_;
|
2026-09-26 19:50:26 +02:00
|
|
|
u16 nextFreeItemNumber_ = 0x100;
|
2026-09-26 19:20:20 +02:00
|
|
|
};
|
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
|
|
|
|
|
|
|
|
} // namespace remorse
|