2026-09-27 11:48:14 +02:00
|
|
|
#include "remorse/animation_archive.h"
|
2026-09-26 21:58:01 +02:00
|
|
|
#include "remorse/collision.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/entity_dispatch_entry.h"
|
2026-09-26 19:20:20 +02:00
|
|
|
#include "remorse/fixed_map.h"
|
2026-09-27 11:48:14 +02:00
|
|
|
#include "remorse/isometric_controls.h"
|
2026-09-26 19:20:20 +02:00
|
|
|
#include "remorse/map_renderer.h"
|
|
|
|
|
#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>
|
2026-09-25 21:41:20 +02:00
|
|
|
#include <cstring>
|
|
|
|
|
#include <stdexcept>
|
|
|
|
|
#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()
|
|
|
|
|
{
|
|
|
|
|
remorse::EntityDispatchEntryBase entry{};
|
2026-09-25 21:41:20 +02:00
|
|
|
remorse::u16 groupCounts[32]{};
|
|
|
|
|
for (remorse::u8& byte : entry.bytes) {
|
|
|
|
|
byte = 0xa5;
|
|
|
|
|
}
|
|
|
|
|
assert(remorse::EntityDispatchEntry::initBase(&entry, 1, groupCounts) == &entry);
|
|
|
|
|
assert(entry.bytes[0x00] == 0x06 && entry.bytes[0x01] == 0x3b);
|
|
|
|
|
assert(entry.bytes[0x09] == 0xa5);
|
|
|
|
|
assert(entry.bytes[0x1e] == 0x10 && entry.bytes[0x1f] == 0x2d);
|
|
|
|
|
assert(entry.bytes[0x28] == 0xfe && entry.bytes[0x29] == 0x3a);
|
|
|
|
|
for (remorse::u16 offset : {remorse::u16{0x02}, remorse::u16{0x04}, remorse::u16{0x0a}, remorse::u16{0x12}, remorse::u16{0x16}, remorse::u16{0x1a}, remorse::u16{0x20}, remorse::u16{0x26}, remorse::u16{0x2a}, remorse::u16{0x30}}) {
|
|
|
|
|
assert(entry.bytes[offset] == 0 && entry.bytes[offset + 1] == 0);
|
|
|
|
|
}
|
|
|
|
|
assert(entry.bytes[0x06] == 1 && entry.bytes[0x07] == 0);
|
|
|
|
|
assert(entry.bytes[0x08] == 1 && groupCounts[1] == 1);
|
|
|
|
|
assert(entry.bytes[0x18] == 1 && entry.bytes[0x19] == 0);
|
|
|
|
|
assert(remorse::EntityDispatchEntry::initBase(nullptr, 1, groupCounts) == nullptr);
|
|
|
|
|
assert(groupCounts[1] == 1);
|
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
|
|
|
|
|
|
|
|
remorse::EntityDispatchEntry::setSourceType(entry, 0x1234);
|
|
|
|
|
assert(entry.bytes[0x04] == 0x34);
|
|
|
|
|
assert(entry.bytes[0x05] == 0x12);
|
|
|
|
|
|
|
|
|
|
remorse::EntityDispatchEntry::setEventTypeChecked(entry, 0x00f2);
|
|
|
|
|
assert(entry.bytes[0x06] == 0xf2);
|
|
|
|
|
assert(entry.bytes[0x07] == 0x00);
|
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
|
|
|
remorse::EntityDispatchEntry::setEventTypeChecked(entry, 0x0fff);
|
|
|
|
|
assert(entry.bytes[0x06] == 0xff && entry.bytes[0x07] == 0x0f);
|
|
|
|
|
bool invalidEventType = false;
|
|
|
|
|
try {
|
|
|
|
|
remorse::EntityDispatchEntry::setEventTypeChecked(entry, 0x1000);
|
|
|
|
|
} catch (const std::invalid_argument&) {
|
|
|
|
|
invalidEventType = true;
|
|
|
|
|
}
|
|
|
|
|
assert(invalidEventType && entry.bytes[0x06] == 0 && entry.bytes[0x07] == 0x10);
|
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
|
|
|
|
2026-09-25 21:41:20 +02:00
|
|
|
remorse::EntityDispatchEntry::sleep(entry, 0x12345678, 0x0001003c);
|
|
|
|
|
assert(entry.bytes[0x18] == 0x01 && entry.bytes[0x19] == 0x10);
|
|
|
|
|
assert(entry.bytes[0x0a] == 0x78 && entry.bytes[0x0b] == 0x56);
|
|
|
|
|
assert(entry.bytes[0x0c] == 0x34 && entry.bytes[0x0d] == 0x12);
|
|
|
|
|
assert(entry.bytes[0x0e] == 0x3c && entry.bytes[0x0f] == 0x00);
|
|
|
|
|
assert(entry.bytes[0x10] == 0x01 && entry.bytes[0x11] == 0x00);
|
|
|
|
|
|
|
|
|
|
remorse::EntityDispatchEntry::setGroupId(entry, 3, groupCounts);
|
|
|
|
|
assert(groupCounts[1] == 0 && groupCounts[3] == 1);
|
|
|
|
|
entry.bytes[0x08] = 0xe3;
|
|
|
|
|
remorse::EntityDispatchEntry::setGroupId(entry, 3, groupCounts);
|
|
|
|
|
assert(entry.bytes[0x08] == 0xe3 && groupCounts[3] == 1);
|
|
|
|
|
|
|
|
|
|
remorse::EntityDispatchEntry::setGroupId(entry, 3, groupCounts);
|
|
|
|
|
assert(groupCounts[3] == 1);
|
|
|
|
|
|
|
|
|
|
remorse::EntityDispatchEntry::setGroupId(entry, 4, groupCounts);
|
|
|
|
|
assert(entry.bytes[0x08] == 4 && groupCounts[3] == 0 && groupCounts[4] == 1);
|
|
|
|
|
|
|
|
|
|
for (remorse::u8 invalidId : {remorse::u8{0}, remorse::u8{32}}) {
|
|
|
|
|
bool rejected = false;
|
|
|
|
|
try {
|
|
|
|
|
remorse::EntityDispatchEntry::setGroupId(entry, invalidId, groupCounts);
|
|
|
|
|
} catch (const std::invalid_argument&) {
|
|
|
|
|
rejected = true;
|
|
|
|
|
}
|
|
|
|
|
assert(rejected && entry.bytes[0x08] == 4 && groupCounts[4] == 1);
|
|
|
|
|
}
|
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
|
|
|
|
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
|
|
|
remorse::ProcessKernel incrementKernel;
|
|
|
|
|
incrementKernel.setActiveGroup(4);
|
|
|
|
|
remorse::EntityDispatchEntry::incrementGroupId(entry, incrementKernel, groupCounts);
|
|
|
|
|
assert(entry.bytes[0x08] == 5 && groupCounts[4] == 0 && groupCounts[5] == 1);
|
|
|
|
|
assert(incrementKernel.activeGroup() == 5 && incrementKernel.groupSelectionPending());
|
|
|
|
|
bool wrongActiveGroup = false;
|
|
|
|
|
try {
|
|
|
|
|
remorse::EntityDispatchEntry::incrementGroupId(entry, incrementKernel, groupCounts);
|
|
|
|
|
} catch (const std::invalid_argument&) {
|
|
|
|
|
wrongActiveGroup = true;
|
|
|
|
|
}
|
|
|
|
|
assert(!wrongActiveGroup && entry.bytes[0x08] == 6 && incrementKernel.activeGroup() == 6);
|
|
|
|
|
incrementKernel.setActiveGroup(7);
|
|
|
|
|
try {
|
|
|
|
|
remorse::EntityDispatchEntry::incrementGroupId(entry, incrementKernel, groupCounts);
|
|
|
|
|
} catch (const std::invalid_argument&) {
|
|
|
|
|
wrongActiveGroup = true;
|
|
|
|
|
}
|
|
|
|
|
assert(wrongActiveGroup && entry.bytes[0x08] == 6 && groupCounts[6] == 1);
|
|
|
|
|
remorse::EntityDispatchEntry::setGroupId(entry, 29, groupCounts);
|
|
|
|
|
incrementKernel.setActiveGroup(29);
|
|
|
|
|
bool groupLimitReached = false;
|
|
|
|
|
try {
|
|
|
|
|
remorse::EntityDispatchEntry::incrementGroupId(entry, incrementKernel, groupCounts);
|
|
|
|
|
} catch (const std::invalid_argument&) {
|
|
|
|
|
groupLimitReached = true;
|
|
|
|
|
}
|
|
|
|
|
assert(groupLimitReached && entry.bytes[0x08] == 29 && groupCounts[29] == 1);
|
2026-09-25 21:41:20 +02:00
|
|
|
|
|
|
|
|
remorse::ProcessKernel kernel;
|
|
|
|
|
kernel.setLastAllocationSize(sizeof(entry));
|
|
|
|
|
assert(kernel.addProcess(entry) == 0);
|
|
|
|
|
assert(entry.bytes[0x02] == 0 && entry.bytes[0x03] == 0);
|
|
|
|
|
assert(kernel.processAt(0) == &entry);
|
|
|
|
|
assert(kernel.allocationSizeAt(0) == 0x32);
|
|
|
|
|
assert(kernel.processCount() == 1 && kernel.capacity() == 30);
|
|
|
|
|
assert(std::strcmp(kernel.processNameAt(0), "Default") == 0);
|
|
|
|
|
remorse::EntityDispatchEntryBase second{};
|
|
|
|
|
kernel.setMarkNewProcesses(true);
|
|
|
|
|
assert(kernel.addProcess(second) == 1);
|
|
|
|
|
assert(second.bytes[0x02] == 1 && second.bytes[0x03] == 0);
|
|
|
|
|
assert(kernel.allocationSizeAt(1) == 0);
|
|
|
|
|
assert(second.bytes[0x19] == 0x02 && kernel.newlyCreatedCount() == 1);
|
|
|
|
|
kernel.setMarkNewProcesses(false);
|
|
|
|
|
kernel.clearProcessSlot(1);
|
|
|
|
|
assert(kernel.processAt(1) == nullptr && kernel.allocationSizeAt(1) == 0);
|
|
|
|
|
assert(kernel.processNameAt(1) == nullptr && kernel.processCount() == 2);
|
|
|
|
|
remorse::EntityDispatchEntryBase reused{};
|
|
|
|
|
assert(kernel.addProcess(reused) == 1 && kernel.processAt(1) == &reused);
|
|
|
|
|
std::vector<remorse::EntityDispatchEntryBase> additional(29);
|
|
|
|
|
for (auto& process : additional) {
|
|
|
|
|
kernel.addProcess(process);
|
|
|
|
|
}
|
|
|
|
|
assert(kernel.processAt(30) == &additional.back());
|
|
|
|
|
assert(kernel.capacity() == 60 && kernel.processCount() == 32);
|
|
|
|
|
|
|
|
|
|
remorse::ProcessKernel createdKernel;
|
|
|
|
|
remorse::u16 createdGroups[32]{};
|
|
|
|
|
auto* created = createdKernel.createProcess(2, createdGroups);
|
|
|
|
|
assert(created != nullptr && createdKernel.processAt(0) == created);
|
|
|
|
|
assert(createdKernel.processCount() == 1 && createdKernel.allocationSizeAt(0) == 0x32);
|
|
|
|
|
assert(created->bytes[0x02] == 0 && created->bytes[0x03] == 0);
|
|
|
|
|
assert(created->bytes[0x08] == 2 && createdGroups[2] == 1);
|
|
|
|
|
createdKernel.setSyncContext(true, 1);
|
|
|
|
|
auto* next = createdKernel.createProcess(2, createdGroups);
|
|
|
|
|
assert(createdKernel.processAt(1) == next && createdGroups[2] == 2);
|
|
|
|
|
assert(next->bytes[0x02] == 1 && next->bytes[0x03] == 0);
|
|
|
|
|
assert(next->bytes[0x16] == 0);
|
|
|
|
|
createdKernel.setSyncContext(true, 0);
|
|
|
|
|
auto* syncing = createdKernel.createProcess(2, createdGroups);
|
|
|
|
|
assert(createdKernel.processAt(2) == syncing && createdGroups[2] == 3);
|
|
|
|
|
assert(syncing->bytes[0x16] == 0x40 && syncing->bytes[0x17] == 0);
|
|
|
|
|
|
2026-10-04 18:11:16 +02:00
|
|
|
remorse::ProcessKernel usecodeKernel;
|
|
|
|
|
remorse::u16 usecodeGroups[32]{};
|
|
|
|
|
for (int index = 0; index < 3; ++index) {
|
|
|
|
|
usecodeKernel.createProcess(1, usecodeGroups);
|
|
|
|
|
}
|
|
|
|
|
auto* usecodeContext = usecodeKernel.createUsecodeProcess(1, usecodeGroups);
|
|
|
|
|
const remorse::u16 usecodeProcessId = static_cast<remorse::u16>(
|
|
|
|
|
usecodeContext->base.bytes[2] | (static_cast<remorse::u16>(usecodeContext->base.bytes[3]) << 8));
|
|
|
|
|
assert(usecodeKernel.allocationSizeAt(usecodeProcessId) == 0x124 &&
|
|
|
|
|
std::strcmp(usecodeKernel.processNameAt(usecodeProcessId), "Usecode") == 0);
|
|
|
|
|
assert(usecodeKernel.setProcessInfo(usecodeProcessId, 0x0207, 0x1234));
|
|
|
|
|
int usecodeRuns = 0;
|
|
|
|
|
usecodeKernel.scanRunnableProcesses(1, [](remorse::EntityDispatchEntryBase& process, void* context) {
|
|
|
|
|
auto& scan = *static_cast<int*>(context);
|
|
|
|
|
if (process.bytes[2] == 3 && process.bytes[3] == 0) {
|
|
|
|
|
++scan;
|
|
|
|
|
}
|
|
|
|
|
}, &usecodeRuns);
|
|
|
|
|
assert(usecodeRuns == 1 && usecodeKernel.processAt(usecodeProcessId) == &usecodeContext->base);
|
|
|
|
|
usecodeKernel.terminateProcess(usecodeProcessId, usecodeGroups);
|
|
|
|
|
assert(usecodeKernel.processAt(usecodeProcessId) == &usecodeContext->base &&
|
|
|
|
|
(usecodeContext->base.bytes[0x16] & 0x08) != 0 &&
|
|
|
|
|
usecodeKernel.processCount() == 3 && usecodeGroups[1] == 3);
|
|
|
|
|
usecodeKernel.clearTerminatedProcesses();
|
|
|
|
|
assert(usecodeKernel.processAt(usecodeProcessId) == nullptr &&
|
|
|
|
|
usecodeKernel.terminatedProcessCount() == 0);
|
|
|
|
|
|
2026-09-25 21:41:20 +02:00
|
|
|
createdKernel.setSyncContext(true, 1);
|
|
|
|
|
next->bytes[0x18] |= 0x02;
|
|
|
|
|
auto* retiring = createdKernel.createProcess(2, createdGroups);
|
|
|
|
|
assert(createdKernel.processAt(3) == retiring && createdKernel.processCount() == 4);
|
|
|
|
|
assert(next->bytes[0x18] == 0x07 && retiring->bytes[0x16] == 0x40);
|
|
|
|
|
createdKernel.terminateProcess(3, createdGroups);
|
|
|
|
|
assert(createdKernel.processAt(3) == retiring && (retiring->bytes[0x16] & 0x08) != 0);
|
|
|
|
|
assert(createdKernel.processCount() == 3 && createdKernel.terminatedProcessCount() == 1);
|
|
|
|
|
assert(createdGroups[2] == 3);
|
|
|
|
|
bool alreadyTerminated = false;
|
|
|
|
|
try {
|
|
|
|
|
createdKernel.terminateProcess(3, createdGroups);
|
|
|
|
|
} catch (const std::logic_error&) {
|
|
|
|
|
alreadyTerminated = true;
|
|
|
|
|
}
|
|
|
|
|
assert(alreadyTerminated && createdGroups[2] == 3 && createdKernel.terminatedProcessCount() == 1);
|
|
|
|
|
createdKernel.setSyncContext(true, 3);
|
|
|
|
|
auto* afterTerminated = createdKernel.createProcess(2, createdGroups);
|
|
|
|
|
assert((retiring->bytes[0x18] & 0x04) == 0 && (afterTerminated->bytes[0x16] & 0x40) != 0);
|
|
|
|
|
createdKernel.terminateProcess(4, createdGroups);
|
|
|
|
|
createdKernel.clearTerminatedProcesses();
|
|
|
|
|
assert(createdKernel.processAt(3) == nullptr && createdKernel.allocationSizeAt(3) == 0);
|
|
|
|
|
assert(createdKernel.processNameAt(3) == nullptr && createdKernel.terminatedProcessCount() == 0);
|
|
|
|
|
auto* recycled = createdKernel.createProcess(2, createdGroups);
|
|
|
|
|
assert(createdKernel.processAt(3) == recycled && recycled->bytes[0x02] == 3);
|
|
|
|
|
assert(createdKernel.processCount() == 4 && createdGroups[2] == 4);
|
|
|
|
|
|
|
|
|
|
auto* immediate = createdKernel.createProcess(2, createdGroups);
|
|
|
|
|
immediate->bytes[0x18] |= 0x04;
|
|
|
|
|
createdKernel.terminateProcess(4, createdGroups);
|
|
|
|
|
assert(createdKernel.processAt(4) == nullptr && createdKernel.processCount() == 4);
|
|
|
|
|
assert(createdKernel.terminatedProcessCount() == 0 && createdGroups[2] == 4);
|
|
|
|
|
|
|
|
|
|
remorse::ProcessKernel fullKernel;
|
|
|
|
|
std::vector<remorse::EntityDispatchEntryBase> fullTable(1020);
|
|
|
|
|
for (auto& process : fullTable) {
|
|
|
|
|
fullKernel.addProcess(process);
|
|
|
|
|
}
|
|
|
|
|
remorse::u16 fullGroups[32]{};
|
|
|
|
|
bool exhausted = false;
|
|
|
|
|
try {
|
|
|
|
|
fullKernel.createProcess(2, fullGroups);
|
|
|
|
|
} catch (const std::overflow_error&) {
|
|
|
|
|
exhausted = true;
|
|
|
|
|
}
|
|
|
|
|
assert(exhausted && fullKernel.processCount() == 1020 && fullGroups[2] == 0);
|
|
|
|
|
exhausted = false;
|
|
|
|
|
try {
|
|
|
|
|
fullKernel.createKeyboardProcess(2, fullGroups);
|
|
|
|
|
} catch (const std::overflow_error&) {
|
|
|
|
|
exhausted = true;
|
|
|
|
|
}
|
|
|
|
|
assert(exhausted && fullKernel.processCount() == 1020 && fullGroups[2] == 0);
|
|
|
|
|
exhausted = false;
|
|
|
|
|
try {
|
|
|
|
|
fullKernel.createSystemTimerProcess(2, fullGroups);
|
|
|
|
|
} catch (const std::overflow_error&) {
|
|
|
|
|
exhausted = true;
|
|
|
|
|
}
|
|
|
|
|
assert(exhausted && fullKernel.processCount() == 1020 && fullGroups[2] == 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
|
|
|
remorse::ProcessKernel groupKernel;
|
|
|
|
|
remorse::u16 groupTable[32]{};
|
|
|
|
|
for (int index = 0; index < 3; ++index) {
|
|
|
|
|
groupKernel.createProcess(1, groupTable);
|
|
|
|
|
}
|
|
|
|
|
groupKernel.createProcess(2, groupTable);
|
|
|
|
|
groupKernel.createProcess(3, groupTable);
|
|
|
|
|
groupKernel.createProcess(30, groupTable);
|
|
|
|
|
groupKernel.createProcess(31, groupTable);
|
|
|
|
|
groupKernel.refreshActiveGroup(groupTable);
|
|
|
|
|
assert(groupKernel.activeGroup() == 1 && !groupKernel.groupSelectionPending());
|
|
|
|
|
groupKernel.setActiveGroup(4);
|
|
|
|
|
assert(groupKernel.activeGroup() == 4 && groupKernel.groupSelectionPending());
|
|
|
|
|
groupKernel.refreshActiveGroup(groupTable);
|
|
|
|
|
assert(groupKernel.activeGroup() == 3 && !groupKernel.groupSelectionPending());
|
|
|
|
|
groupKernel.terminateProcess(4, groupTable);
|
|
|
|
|
groupKernel.clearTerminatedProcesses();
|
|
|
|
|
groupKernel.refreshActiveGroup(groupTable);
|
|
|
|
|
assert(groupKernel.activeGroup() == 2 && !groupKernel.groupSelectionPending());
|
|
|
|
|
for (remorse::u8 invalidGroup : {remorse::u8{0}, remorse::u8{32}}) {
|
|
|
|
|
bool rejected = false;
|
|
|
|
|
try {
|
|
|
|
|
groupKernel.setActiveGroup(invalidGroup);
|
|
|
|
|
} catch (const std::invalid_argument&) {
|
|
|
|
|
rejected = true;
|
|
|
|
|
}
|
|
|
|
|
assert(rejected && groupKernel.activeGroup() == 2 && !groupKernel.groupSelectionPending());
|
|
|
|
|
}
|
|
|
|
|
groupKernel.setActiveGroup(30);
|
|
|
|
|
groupKernel.refreshActiveGroup(groupTable);
|
|
|
|
|
assert(groupKernel.activeGroup() == 30 && groupKernel.groupSelectionPending());
|
|
|
|
|
|
2026-09-25 21:41:20 +02:00
|
|
|
remorse::ProcessKernel scheduler;
|
|
|
|
|
remorse::u16 scheduledGroups[32]{};
|
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(scheduler.activeGroup() == 1 && !scheduler.groupSelectionPending());
|
|
|
|
|
scheduler.setActiveGroup(1);
|
|
|
|
|
assert(!scheduler.groupSelectionPending());
|
2026-09-25 21:41:20 +02:00
|
|
|
auto* otherGroup = scheduler.createProcess(1, scheduledGroups);
|
|
|
|
|
auto* matching = scheduler.createProcess(2, scheduledGroups);
|
|
|
|
|
auto* syncingProcess = scheduler.createProcess(2, scheduledGroups);
|
|
|
|
|
auto* specialGroup = scheduler.createProcess(30, scheduledGroups);
|
|
|
|
|
syncingProcess->bytes[0x16] = 0x40;
|
|
|
|
|
std::vector<remorse::u16> ran;
|
|
|
|
|
auto recordRun = [](remorse::EntityDispatchEntryBase& process, void* context) {
|
|
|
|
|
auto& ids = *static_cast<std::vector<remorse::u16>*>(context);
|
|
|
|
|
ids.push_back(static_cast<remorse::u16>(process.bytes[0x02] | process.bytes[0x03] << 8));
|
|
|
|
|
};
|
|
|
|
|
scheduler.scanRunnableProcesses(2, recordRun, &ran);
|
|
|
|
|
assert((ran == std::vector<remorse::u16>{1, 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
|
|
|
assert(scheduler.activeGroup() == 2 && scheduler.groupSelectionPending());
|
2026-09-25 21:41:20 +02:00
|
|
|
assert(syncingProcess->bytes[0x16] == 0 && otherGroup->bytes[0x16] == 0);
|
|
|
|
|
ran.clear();
|
|
|
|
|
matching->bytes[0x16] = 1;
|
|
|
|
|
scheduler.scanRunnableProcesses(2, recordRun, &ran);
|
|
|
|
|
assert((ran == std::vector<remorse::u16>{2, 3}));
|
|
|
|
|
assert(specialGroup->bytes[0x08] == 30);
|
|
|
|
|
|
2026-10-04 18:11:16 +02:00
|
|
|
remorse::ProcessKernel automaticGroupKernel;
|
|
|
|
|
remorse::u16 automaticGroupCounts[32]{};
|
|
|
|
|
automaticGroupKernel.createProcess(3, automaticGroupCounts);
|
|
|
|
|
std::vector<remorse::u16> automaticGroupRuns;
|
|
|
|
|
automaticGroupKernel.scanRunnableProcesses(2, recordRun, &automaticGroupRuns);
|
|
|
|
|
assert(automaticGroupRuns.empty() && automaticGroupKernel.activeGroup() == 3 &&
|
|
|
|
|
!automaticGroupKernel.groupSelectionPending());
|
|
|
|
|
automaticGroupKernel.scanRunnableProcesses(3, recordRun, &automaticGroupRuns);
|
|
|
|
|
assert((automaticGroupRuns == std::vector<remorse::u16>{0}));
|
|
|
|
|
|
2026-09-25 21:41:20 +02:00
|
|
|
remorse::ProcessKernel spawningKernel;
|
|
|
|
|
remorse::u16 spawningGroups[32]{};
|
|
|
|
|
spawningKernel.createProcess(1, spawningGroups);
|
|
|
|
|
auto* spawningProcess = spawningKernel.createProcess(2, spawningGroups);
|
|
|
|
|
spawningProcess->bytes[0x18] |= 0x02;
|
|
|
|
|
struct SpawnContext {
|
|
|
|
|
remorse::ProcessKernel* kernel;
|
|
|
|
|
remorse::u16 (*groups)[32];
|
|
|
|
|
remorse::EntityDispatchEntryBase* spawned = nullptr;
|
|
|
|
|
int runs = 0;
|
|
|
|
|
} spawnContext{&spawningKernel, &spawningGroups};
|
|
|
|
|
auto spawnRun = [](remorse::EntityDispatchEntryBase&, void* context) {
|
|
|
|
|
auto& state = *static_cast<SpawnContext*>(context);
|
|
|
|
|
++state.runs;
|
|
|
|
|
if (state.spawned == nullptr) {
|
|
|
|
|
state.spawned = state.kernel->createProcess(2, *state.groups);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
spawningKernel.scanRunnableProcesses(2, spawnRun, &spawnContext);
|
|
|
|
|
assert(spawnContext.runs == 1 && spawnContext.spawned == spawningKernel.processAt(2));
|
|
|
|
|
assert(spawningProcess->bytes[0x18] == 0x07 && spawnContext.spawned->bytes[0x16] == 0);
|
|
|
|
|
|
2026-09-26 19:20:20 +02:00
|
|
|
remorse::ProcessKernel itemSpawnKernel;
|
|
|
|
|
remorse::u16 itemSpawnGroups[32]{};
|
|
|
|
|
for (int index = 0; index < 3; ++index) {
|
|
|
|
|
itemSpawnKernel.createProcess(1, itemSpawnGroups);
|
|
|
|
|
}
|
|
|
|
|
auto* itemSpawner = itemSpawnKernel.createProcess(2, itemSpawnGroups);
|
|
|
|
|
itemSpawner->bytes[0x18] |= 0x02;
|
|
|
|
|
struct ItemSpawnContext {
|
|
|
|
|
remorse::ProcessKernel* kernel;
|
|
|
|
|
remorse::u16 (*groups)[32];
|
|
|
|
|
remorse::EntityDispatchEntryBase* spawned = nullptr;
|
|
|
|
|
int spawnedRuns = 0;
|
|
|
|
|
} itemSpawnContext{&itemSpawnKernel, &itemSpawnGroups};
|
|
|
|
|
auto spawnItemRun = [](remorse::EntityDispatchEntryBase& process, void* context) {
|
|
|
|
|
auto& state = *static_cast<ItemSpawnContext*>(context);
|
|
|
|
|
if (process.bytes[0] == remorse::ItemProcess::vtableOffset % 256) {
|
|
|
|
|
++state.spawnedRuns;
|
|
|
|
|
} else if (state.spawned == nullptr && process.bytes[2] == 3) {
|
|
|
|
|
state.spawned = state.kernel->createItemProcess(2, 0x100, *state.groups);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
itemSpawnKernel.scanRunnableProcesses(2, spawnItemRun, &itemSpawnContext);
|
|
|
|
|
assert(itemSpawnContext.spawned && itemSpawnContext.spawnedRuns == 0 &&
|
|
|
|
|
(itemSpawnContext.spawned->bytes[0x16] & 0x40) == 0);
|
|
|
|
|
itemSpawnKernel.scanRunnableProcesses(2, spawnItemRun, &itemSpawnContext);
|
|
|
|
|
assert(itemSpawnContext.spawnedRuns == 1);
|
|
|
|
|
|
2026-09-25 21:41:20 +02:00
|
|
|
remorse::ProcessKernel retiringKernel;
|
|
|
|
|
remorse::u16 retiringGroups[32]{};
|
|
|
|
|
for (int index = 0; index < 3; ++index) {
|
|
|
|
|
retiringKernel.createProcess(1, retiringGroups);
|
|
|
|
|
}
|
|
|
|
|
retiringKernel.createProcess(2, retiringGroups);
|
|
|
|
|
struct RetireContext {
|
|
|
|
|
remorse::ProcessKernel* kernel;
|
|
|
|
|
remorse::u16 (*groups)[32];
|
|
|
|
|
} retireContext{&retiringKernel, &retiringGroups};
|
|
|
|
|
auto retireRun = [](remorse::EntityDispatchEntryBase& process, void* context) {
|
|
|
|
|
auto& state = *static_cast<RetireContext*>(context);
|
|
|
|
|
state.kernel->terminateProcess(static_cast<remorse::u16>(process.bytes[0x02]), *state.groups);
|
|
|
|
|
};
|
|
|
|
|
retiringKernel.scanRunnableProcesses(2, retireRun, &retireContext);
|
|
|
|
|
assert(retiringKernel.processAt(3) == nullptr && retiringKernel.terminatedProcessCount() == 0);
|
|
|
|
|
assert(retiringKernel.processCount() == 3 && retiringGroups[2] == 0);
|
|
|
|
|
|
|
|
|
|
remorse::ProcessKernel sleepingKernel;
|
|
|
|
|
remorse::u16 sleepingGroups[32]{};
|
|
|
|
|
auto* sleeper = sleepingKernel.createProcess(2, sleepingGroups);
|
|
|
|
|
remorse::EntityDispatchEntry::sleep(*sleeper, 100, 60);
|
|
|
|
|
ran.clear();
|
|
|
|
|
sleepingKernel.scanRunnableProcesses(2, recordRun, &ran, 160);
|
|
|
|
|
assert(ran.empty() && sleeper->bytes[0x19] == 0x10);
|
|
|
|
|
sleepingKernel.scanRunnableProcesses(2, recordRun, &ran, 161);
|
|
|
|
|
assert((ran == std::vector<remorse::u16>{0}));
|
|
|
|
|
assert(sleeper->bytes[0x19] == 0);
|
|
|
|
|
for (remorse::u16 offset = 0x0a; offset < 0x12; ++offset) {
|
|
|
|
|
assert(sleeper->bytes[offset] == 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
|
|
|
remorse::ProcessKernel timedPassKernel;
|
|
|
|
|
remorse::u16 timedPassGroups[32]{};
|
|
|
|
|
auto* timedPassSleeper = timedPassKernel.createProcess(1, timedPassGroups);
|
|
|
|
|
timedPassKernel.createSystemTimerProcess(1, timedPassGroups);
|
|
|
|
|
timedPassKernel.deliverSystemTimerEvent();
|
|
|
|
|
remorse::EntityDispatchEntry::sleep(*timedPassSleeper, 1, 1);
|
|
|
|
|
std::vector<remorse::u16> timedPassRuns;
|
|
|
|
|
const auto advanceTimer = [](void* context) {
|
|
|
|
|
static_cast<remorse::ProcessKernel*>(context)->deliverSystemTimerEvent();
|
|
|
|
|
};
|
|
|
|
|
assert(timedPassKernel.runTimedSchedulerPass(1, recordRun, &timedPassRuns,
|
|
|
|
|
advanceTimer, &timedPassKernel) == 1);
|
|
|
|
|
assert(timedPassRuns.empty() && timedPassKernel.systemTimerTick() == 2);
|
|
|
|
|
assert(timedPassKernel.runTimedSchedulerPass(1, recordRun, &timedPassRuns,
|
|
|
|
|
advanceTimer, &timedPassKernel) == 1);
|
|
|
|
|
assert(timedPassRuns.empty() && timedPassKernel.systemTimerTick() == 3);
|
|
|
|
|
assert(timedPassKernel.runTimedSchedulerPass(1, recordRun, &timedPassRuns,
|
|
|
|
|
advanceTimer, &timedPassKernel) == 1);
|
|
|
|
|
assert((timedPassRuns == std::vector<remorse::u16>{0}));
|
|
|
|
|
|
2026-09-25 21:41:20 +02:00
|
|
|
remorse::ProcessKernel standKernel;
|
|
|
|
|
remorse::u16 standGroups[32]{};
|
|
|
|
|
standKernel.createProcess(2, standGroups);
|
|
|
|
|
assert(!standKernel.itemHasProcess(0x1234) && !standKernel.itemHasProcess(0x1235));
|
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
|
|
|
bool oversizedStandRejected = false;
|
|
|
|
|
try {
|
|
|
|
|
standKernel.createStandProcess(2, 0x2400, standGroups);
|
|
|
|
|
} catch (const std::out_of_range&) {
|
|
|
|
|
oversizedStandRejected = true;
|
|
|
|
|
}
|
|
|
|
|
assert(oversizedStandRejected && standGroups[2] == 1 && standKernel.processCount() == 1);
|
2026-09-25 21:41:20 +02:00
|
|
|
auto* standEntry = standKernel.createStandProcess(2, 0x1234, standGroups);
|
|
|
|
|
auto* standing = &standEntry->base;
|
|
|
|
|
assert(standKernel.processAt(1) == standing && standKernel.allocationSizeAt(1) == 0x42);
|
|
|
|
|
assert(std::strcmp(standKernel.processNameAt(1), "Stand") == 0 && standGroups[2] == 2);
|
|
|
|
|
assert(standing->bytes[0] == 0x0f && standing->bytes[1] == 0x1f);
|
|
|
|
|
assert(standing->bytes[0x04] == 0x34 && standing->bytes[0x05] == 0x12);
|
|
|
|
|
assert(standing->bytes[0x06] == 0x58 && standing->bytes[0x07] == 0x02);
|
|
|
|
|
assert(standing->bytes[0x17] == 0x03 && standEntry->extra[0] == 0x01 && standEntry->extra[1] == 0x01);
|
|
|
|
|
assert(standEntry->extra[0x0e] == 0x34 && standEntry->extra[0x0f] == 0x12);
|
|
|
|
|
assert(standKernel.itemHasProcess(0x1234) && !standKernel.itemHasProcess(0x1235));
|
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
|
|
|
|
|
|
|
|
remorse::ProcessKernel cachedItemKernel;
|
|
|
|
|
remorse::u16 cachedItemGroups[32]{};
|
|
|
|
|
for (int index = 0; index < 3; ++index) {
|
|
|
|
|
cachedItemKernel.createProcess(1, cachedItemGroups);
|
|
|
|
|
}
|
|
|
|
|
auto* itemProcess = cachedItemKernel.createItemProcess(1, 0x100, cachedItemGroups);
|
|
|
|
|
assert(cachedItemKernel.processAt(3) == itemProcess && cachedItemKernel.allocationSizeAt(3) == 0x32);
|
|
|
|
|
assert(std::strcmp(cachedItemKernel.processNameAt(3), "ItemProcess") == 0);
|
|
|
|
|
assert(itemProcess->bytes[0] == 0x2f && itemProcess->bytes[1] == 0x10);
|
|
|
|
|
assert(itemProcess->bytes[4] == 0 && itemProcess->bytes[5] == 1);
|
|
|
|
|
assert(itemProcess->bytes[6] == 0xf1 && itemProcess->bytes[7] == 0);
|
|
|
|
|
assert(cachedItemKernel.itemHasProcess(0x100) && cachedItemKernel.itemProcessTypes(0x100) == 2);
|
|
|
|
|
assert(cachedItemGroups[1] == 4);
|
2026-09-26 19:20:20 +02:00
|
|
|
assert(cachedItemKernel.findProcessForItemAndType(0x100, 0xf1) == itemProcess);
|
|
|
|
|
assert(cachedItemKernel.findProcessForItemAndType(0, 0x0c) == itemProcess);
|
|
|
|
|
assert(cachedItemKernel.findProcessForItemAndType(0x101, 0xf1) == nullptr);
|
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
|
|
|
auto* sharedItemProcess = cachedItemKernel.createItemProcess(1, 0x100, cachedItemGroups);
|
2026-09-26 19:20:20 +02:00
|
|
|
assert(cachedItemKernel.findProcessForItemAndType(0x100, 0xf1) == itemProcess);
|
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(cachedItemKernel.itemProcessTypes(0x100) == 2);
|
|
|
|
|
cachedItemKernel.setProcessSourceType(*sharedItemProcess, 0x101);
|
|
|
|
|
assert(cachedItemKernel.itemHasProcess(0x100) && cachedItemKernel.itemHasProcess(0x101));
|
|
|
|
|
assert(cachedItemKernel.itemProcessTypes(0x100) == 2 && cachedItemKernel.itemProcessTypes(0x101) == 2);
|
|
|
|
|
cachedItemKernel.setProcessEventTypeChecked(*sharedItemProcess, 0xf2);
|
|
|
|
|
assert(cachedItemKernel.itemProcessTypes(0x101) == 4);
|
|
|
|
|
cachedItemKernel.setProcessSourceType(*sharedItemProcess, 0);
|
|
|
|
|
assert(!cachedItemKernel.itemHasProcess(0x101) && cachedItemKernel.itemProcessTypes(0x101) == 0);
|
|
|
|
|
cachedItemKernel.setProcessSourceType(*sharedItemProcess, 0x102);
|
|
|
|
|
assert(cachedItemKernel.itemHasProcess(0x102) && cachedItemKernel.itemProcessTypes(0x102) == 4);
|
|
|
|
|
cachedItemKernel.setProcessSourceType(*sharedItemProcess, 0x23ff);
|
|
|
|
|
assert(cachedItemKernel.itemHasProcess(0x23ff) && cachedItemKernel.itemProcessTypes(0x23ff) == 4);
|
|
|
|
|
bool invalidItemNumber = false;
|
|
|
|
|
try {
|
|
|
|
|
cachedItemKernel.setProcessSourceType(*sharedItemProcess, 0x2400);
|
|
|
|
|
} catch (const std::out_of_range&) {
|
|
|
|
|
invalidItemNumber = true;
|
|
|
|
|
}
|
|
|
|
|
assert(invalidItemNumber && cachedItemKernel.itemHasProcess(0x23ff));
|
|
|
|
|
assert(!cachedItemKernel.itemHasProcess(0x2400) && cachedItemKernel.itemProcessTypes(0x2400) == 0);
|
|
|
|
|
cachedItemKernel.setProcessSourceType(*sharedItemProcess, 0x102);
|
|
|
|
|
cachedItemKernel.terminateProcess(4, cachedItemGroups);
|
|
|
|
|
cachedItemKernel.clearTerminatedProcesses();
|
|
|
|
|
assert(!cachedItemKernel.itemHasProcess(0x102) && cachedItemKernel.itemProcessTypes(0x102) == 0);
|
|
|
|
|
bool missingReleaseRejected = false;
|
|
|
|
|
try {
|
|
|
|
|
remorse::ItemProcess::run(*itemProcess, cachedItemKernel, cachedItemGroups, nullptr, nullptr);
|
|
|
|
|
} catch (const std::invalid_argument&) {
|
|
|
|
|
missingReleaseRejected = true;
|
|
|
|
|
}
|
|
|
|
|
assert(missingReleaseRejected && cachedItemKernel.itemHasProcess(0x100) && cachedItemGroups[1] == 4);
|
|
|
|
|
remorse::u16 releasedItem = 0;
|
|
|
|
|
struct ItemRunContext {
|
|
|
|
|
remorse::ProcessKernel* kernel;
|
|
|
|
|
remorse::u16 (*groups)[32];
|
|
|
|
|
remorse::u16* released;
|
|
|
|
|
} itemRunContext{&cachedItemKernel, &cachedItemGroups, &releasedItem};
|
|
|
|
|
cachedItemKernel.scanRunnableProcesses(1, [](remorse::EntityDispatchEntryBase& process, void* context) {
|
|
|
|
|
auto& state = *static_cast<ItemRunContext*>(context);
|
|
|
|
|
if (process.bytes[0] == 0x2f && process.bytes[1] == 0x10) {
|
|
|
|
|
remorse::ItemProcess::run(process, *state.kernel, *state.groups,
|
|
|
|
|
[](remorse::u16 itemNumber, remorse::u32 eventMask, remorse::u16 eventId, void* result) {
|
|
|
|
|
assert(eventMask == 0x200 && eventId == 9);
|
|
|
|
|
*static_cast<remorse::u16*>(result) = itemNumber;
|
|
|
|
|
},
|
|
|
|
|
state.released);
|
|
|
|
|
}
|
|
|
|
|
}, &itemRunContext);
|
|
|
|
|
assert(releasedItem == 0x100 && !cachedItemKernel.itemHasProcess(0x100));
|
2026-09-26 19:20:20 +02:00
|
|
|
assert(cachedItemKernel.findProcessForItemAndType(0x100, 0xf1) == nullptr);
|
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(cachedItemKernel.itemProcessTypes(0x100) == 0);
|
|
|
|
|
assert(cachedItemKernel.processAt(3) == nullptr && cachedItemGroups[1] == 3);
|
2026-09-25 21:41:20 +02:00
|
|
|
bool itemTeardownRejected = false;
|
|
|
|
|
try {
|
|
|
|
|
standKernel.terminateProcess(1, standGroups);
|
|
|
|
|
} catch (const std::logic_error&) {
|
|
|
|
|
itemTeardownRejected = true;
|
|
|
|
|
}
|
|
|
|
|
assert(itemTeardownRejected && standGroups[2] == 2 && standKernel.processAt(1) == standing);
|
2026-09-26 19:20:20 +02:00
|
|
|
remorse::ProcessKernel gravityKernel;
|
|
|
|
|
remorse::u16 gravityGroups[32]{};
|
|
|
|
|
for (int index = 0; index < 3; ++index) {
|
|
|
|
|
gravityKernel.createProcess(1, gravityGroups);
|
|
|
|
|
}
|
|
|
|
|
const auto gravityId = gravityKernel.hurlItem(1, 0x100, 2, -3, 4, 2, 10, gravityGroups);
|
|
|
|
|
auto* gravityEntry = gravityKernel.processAt(gravityId);
|
|
|
|
|
assert(gravityEntry && gravityKernel.allocationSizeAt(gravityId) == 0x42);
|
|
|
|
|
assert(std::strcmp(gravityKernel.processNameAt(gravityId), "Gravity") == 0);
|
|
|
|
|
assert(gravityKernel.findProcessForItemAndType(0x100, 0x203) == gravityEntry);
|
|
|
|
|
assert(gravityEntry->bytes[0] == 0x10 && gravityEntry->bytes[1] == 0x06);
|
|
|
|
|
assert(gravityEntry->bytes[0x32] == 2 && gravityEntry->bytes[0x34] == 0xfd &&
|
|
|
|
|
gravityEntry->bytes[0x35] == 0xff && gravityEntry->bytes[0x36] == 4);
|
|
|
|
|
assert(gravityEntry->bytes[0x38] == 2 && gravityEntry->bytes[0x3b] == 200);
|
|
|
|
|
assert((gravityEntry->bytes[0x19] & 0x10) != 0 && gravityEntry->bytes[0x0a] == 10 &&
|
|
|
|
|
gravityEntry->bytes[0x0e] == 20 && gravityGroups[1] == 4);
|
|
|
|
|
assert(gravityKernel.hurlItem(1, 0x100, -4, 5, -2, 99, 11, gravityGroups) == gravityId);
|
|
|
|
|
assert(gravityEntry->bytes[0x32] == 0xfe && gravityEntry->bytes[0x33] == 0xff &&
|
|
|
|
|
gravityEntry->bytes[0x34] == 2 && gravityEntry->bytes[0x36] == 2 &&
|
|
|
|
|
gravityEntry->bytes[0x38] == 2 && gravityGroups[1] == 4);
|
|
|
|
|
bool invalidHurlRejected = false;
|
|
|
|
|
try {
|
|
|
|
|
gravityKernel.hurlItem(1, 0x2400, 0, 0, 0, 2, 10, gravityGroups);
|
|
|
|
|
} catch (const std::out_of_range&) {
|
|
|
|
|
invalidHurlRejected = true;
|
|
|
|
|
}
|
|
|
|
|
assert(invalidHurlRejected && gravityGroups[1] == 4);
|
|
|
|
|
int gravityRuns = 0;
|
|
|
|
|
auto countGravityRun = [](remorse::EntityDispatchEntryBase& process, void* context) {
|
|
|
|
|
if (process.bytes[0] == 0x10 && process.bytes[1] == 0x06) {
|
|
|
|
|
++*static_cast<int*>(context);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
gravityKernel.scanRunnableProcesses(1, countGravityRun, &gravityRuns, 30);
|
|
|
|
|
assert(gravityRuns == 0);
|
|
|
|
|
gravityKernel.scanRunnableProcesses(1, countGravityRun, &gravityRuns, 31);
|
|
|
|
|
assert(gravityRuns == 1 && gravityKernel.itemHasProcess(0x100));
|
|
|
|
|
remorse::StagedFixedMapItem fallingItem{};
|
|
|
|
|
fallingItem.itemNumber = 0x100;
|
|
|
|
|
fallingItem.data.x = 100;
|
|
|
|
|
fallingItem.data.y = 100;
|
|
|
|
|
fallingItem.data.z = 10;
|
|
|
|
|
remorse::LiveFixedMapItems fallingItems({fallingItem});
|
|
|
|
|
auto approveGravity = [](remorse::u16 itemNumber, const remorse::WorldPoint& from,
|
|
|
|
|
const remorse::WorldPoint& to, void* context) {
|
|
|
|
|
++*static_cast<int*>(context);
|
|
|
|
|
return itemNumber == 0x100 && from.x == 100 && from.y == 100 && from.z == 10 &&
|
|
|
|
|
to.x == 98 && to.y == 102 && to.z == 12;
|
|
|
|
|
};
|
|
|
|
|
int sweepCalls = 0;
|
|
|
|
|
assert(!gravityKernel.runUnobstructedGravity(gravityId, fallingItems, 1, 31, nullptr, nullptr));
|
|
|
|
|
assert(sweepCalls == 0 && fallingItems.findItem(0x100)->data.x == 100);
|
|
|
|
|
auto rejectGravity = [](remorse::u16, const remorse::WorldPoint&, const remorse::WorldPoint&,
|
|
|
|
|
void* context) {
|
|
|
|
|
++*static_cast<int*>(context);
|
|
|
|
|
return false;
|
|
|
|
|
};
|
|
|
|
|
assert(!gravityKernel.runUnobstructedGravity(gravityId, fallingItems, 1, 31,
|
|
|
|
|
rejectGravity, &sweepCalls));
|
|
|
|
|
assert(sweepCalls == 1 && fallingItems.findItem(0x100)->data.x == 100 &&
|
|
|
|
|
gravityEntry->bytes[0x36] == 2 && (gravityEntry->bytes[0x19] & 0x10) == 0);
|
|
|
|
|
assert(gravityKernel.runUnobstructedGravity(gravityId, fallingItems, 1, 31,
|
|
|
|
|
approveGravity, &sweepCalls));
|
|
|
|
|
assert(sweepCalls == 2 && fallingItems.findItem(0x100)->data.x == 98 &&
|
|
|
|
|
fallingItems.findItem(0x100)->data.y == 102 && fallingItems.findItem(0x100)->data.z == 12);
|
|
|
|
|
assert(gravityEntry->bytes[0x36] == 0 && gravityEntry->bytes[0x37] == 0 &&
|
|
|
|
|
(gravityEntry->bytes[0x19] & 0x10) != 0 && gravityEntry->bytes[0x0e] == 4);
|
|
|
|
|
assert(!gravityKernel.runUnobstructedGravity(gravityId, fallingItems, 1, 32,
|
|
|
|
|
approveGravity, &sweepCalls) && sweepCalls == 2);
|
|
|
|
|
remorse::ProcessKernel horizontalKernel;
|
|
|
|
|
remorse::u16 horizontalGroups[32]{};
|
|
|
|
|
for (int index = 0; index < 3; ++index) {
|
|
|
|
|
horizontalKernel.createProcess(1, horizontalGroups);
|
|
|
|
|
}
|
|
|
|
|
const auto horizontalId = horizontalKernel.hurlItem(1, 0x100, 2, 0, 0, 2, 0, horizontalGroups);
|
|
|
|
|
remorse::StagedFixedMapItem supportedItem = fallingItem;
|
|
|
|
|
supportedItem.data.shape = 1;
|
|
|
|
|
supportedItem.data.z = 72;
|
|
|
|
|
supportedItem.itemNumber = 0x101;
|
|
|
|
|
fallingItem.data.shape = 1;
|
|
|
|
|
fallingItem.data.z = 80;
|
|
|
|
|
remorse::LiveFixedMapItems horizontalItems({fallingItem, supportedItem});
|
|
|
|
|
std::vector<remorse::ShapeTypeInfo> horizontalShapes(2);
|
|
|
|
|
horizontalShapes[1].x = 1;
|
|
|
|
|
horizontalShapes[1].y = 1;
|
|
|
|
|
horizontalShapes[1].z = 1;
|
|
|
|
|
horizontalKernel.scanRunnableProcesses(1, countGravityRun, &gravityRuns, 21);
|
|
|
|
|
struct HorizontalSweep {
|
|
|
|
|
remorse::ProcessKernel* kernel;
|
|
|
|
|
int calls = 0;
|
|
|
|
|
} horizontalSweep{&horizontalKernel};
|
|
|
|
|
auto approveHorizontal = [](remorse::u16 itemNumber, const remorse::WorldPoint& from,
|
|
|
|
|
const remorse::WorldPoint& to, void* context) {
|
|
|
|
|
auto& state = *static_cast<HorizontalSweep*>(context);
|
|
|
|
|
++state.calls;
|
|
|
|
|
return itemNumber == 0x100 && from.x == 100 && from.z == 80 && to.x == 102 &&
|
|
|
|
|
to.z == 80 && state.kernel->findProcessForItemAndType(0x101, 0xf1) != nullptr;
|
|
|
|
|
};
|
|
|
|
|
assert(!horizontalKernel.runUnobstructedGravity(horizontalId, horizontalItems, 1, 21,
|
|
|
|
|
approveHorizontal, &horizontalSweep));
|
|
|
|
|
assert(horizontalSweep.calls == 0 && horizontalKernel.processCount() == 4);
|
|
|
|
|
auto rejectHorizontal = [](remorse::u16, const remorse::WorldPoint&,
|
|
|
|
|
const remorse::WorldPoint&, void* context) {
|
|
|
|
|
++static_cast<HorizontalSweep*>(context)->calls;
|
|
|
|
|
return false;
|
|
|
|
|
};
|
|
|
|
|
assert(!horizontalKernel.runUnobstructedGravity(horizontalId, horizontalItems, 1, 21,
|
|
|
|
|
rejectHorizontal, &horizontalSweep, &horizontalShapes, &horizontalGroups));
|
|
|
|
|
assert(horizontalSweep.calls == 1 && horizontalItems.findItem(0x100)->data.x == 100 &&
|
|
|
|
|
horizontalKernel.findProcessForItemAndType(0x101, 0xf1) != nullptr &&
|
|
|
|
|
horizontalKernel.processCount() == 5);
|
|
|
|
|
assert(horizontalKernel.runUnobstructedGravity(horizontalId, horizontalItems, 1, 21,
|
|
|
|
|
approveHorizontal, &horizontalSweep, &horizontalShapes, &horizontalGroups));
|
|
|
|
|
assert(horizontalSweep.calls == 2 && horizontalItems.findItem(0x100)->data.x == 102 &&
|
|
|
|
|
horizontalKernel.processCount() == 6);
|
|
|
|
|
assert(horizontalKernel.processAt(horizontalId)->bytes[0x36] == 0xfe &&
|
|
|
|
|
horizontalKernel.processAt(horizontalId)->bytes[0x37] == 0xff);
|
2026-09-26 21:58:01 +02:00
|
|
|
remorse::ProcessKernel resolvedKernel;
|
|
|
|
|
remorse::u16 resolvedGroups[32]{};
|
|
|
|
|
for (int index = 0; index < 3; ++index) {
|
|
|
|
|
resolvedKernel.createProcess(1, resolvedGroups);
|
|
|
|
|
}
|
|
|
|
|
remorse::StagedFixedMapItem movingGravityItem = fallingItem;
|
|
|
|
|
movingGravityItem.data.x = 512;
|
|
|
|
|
movingGravityItem.data.y = 512;
|
|
|
|
|
movingGravityItem.data.z = 80;
|
|
|
|
|
movingGravityItem.data.shape = 1;
|
|
|
|
|
auto gravityWall = movingGravityItem;
|
|
|
|
|
gravityWall.itemNumber = 0x101;
|
|
|
|
|
gravityWall.data.x = 600;
|
|
|
|
|
gravityWall.data.shape = 2;
|
|
|
|
|
remorse::LiveFixedMapItems resolvedItems({movingGravityItem, gravityWall});
|
|
|
|
|
std::vector<remorse::ShapeTypeInfo> resolvedShapes(3);
|
|
|
|
|
resolvedShapes[1].x = resolvedShapes[1].y = resolvedShapes[1].z = 2;
|
|
|
|
|
resolvedShapes[2] = resolvedShapes[1];
|
|
|
|
|
resolvedShapes[2].flags = 2;
|
|
|
|
|
const remorse::FastAreaRange resolvedFastArea{-128, 128, -128, 128};
|
|
|
|
|
const auto resolvedId = resolvedKernel.hurlItem(1, 0x100, 100, 0, 2, 2, 0, resolvedGroups);
|
|
|
|
|
assert(!resolvedKernel.runResolvedGravity(resolvedId, resolvedItems,
|
|
|
|
|
resolvedShapes, resolvedFastArea, 1, 0, resolvedGroups));
|
|
|
|
|
resolvedKernel.scanRunnableProcesses(1, countGravityRun, &gravityRuns, 21);
|
|
|
|
|
assert(resolvedKernel.runResolvedGravity(resolvedId, resolvedItems,
|
|
|
|
|
resolvedShapes, resolvedFastArea, 1, 21, resolvedGroups));
|
|
|
|
|
assert(resolvedItems.findItem(0x100)->data.x == 568 &&
|
|
|
|
|
resolvedItems.findItem(0x100)->data.z == 81);
|
|
|
|
|
const auto* resolvedProcess = resolvedKernel.processAt(resolvedId);
|
|
|
|
|
assert(resolvedProcess->bytes[0x32] == 0xe7 && resolvedProcess->bytes[0x33] == 0xff &&
|
|
|
|
|
resolvedProcess->bytes[0x36] == 0 && (resolvedProcess->bytes[0x19] & 0x10) != 0 &&
|
|
|
|
|
resolvedProcess->bytes[0x0e] == 4);
|
|
|
|
|
assert(!resolvedKernel.runResolvedGravity(resolvedId, resolvedItems,
|
|
|
|
|
resolvedShapes, resolvedFastArea, 1, 22, resolvedGroups));
|
|
|
|
|
resolvedKernel.scanRunnableProcesses(1, countGravityRun, &gravityRuns, 26);
|
|
|
|
|
assert(!resolvedKernel.runResolvedGravity(resolvedId, resolvedItems,
|
|
|
|
|
resolvedShapes, {2, 2, 0, 0}, 1, 26, resolvedGroups));
|
|
|
|
|
assert(resolvedItems.findItem(0x100)->data.x == 568 &&
|
|
|
|
|
resolvedKernel.processAt(resolvedId)->bytes[0x32] == 0xe7);
|
|
|
|
|
assert(resolvedKernel.runResolvedGravity(resolvedId, resolvedItems,
|
|
|
|
|
resolvedShapes, resolvedFastArea, 1, 26, resolvedGroups));
|
|
|
|
|
assert(resolvedItems.findItem(0x100)->data.x == 543 &&
|
|
|
|
|
resolvedItems.findItem(0x100)->data.z == 81 &&
|
|
|
|
|
resolvedKernel.processAt(resolvedId)->bytes[0x36] == 0xfe);
|
|
|
|
|
assert(resolvedKernel.scanResolvedGravity(1, resolvedItems, resolvedShapes,
|
|
|
|
|
resolvedFastArea, 1, 30, resolvedGroups) == 0);
|
|
|
|
|
assert(resolvedKernel.scanResolvedGravity(1, resolvedItems, resolvedShapes,
|
|
|
|
|
resolvedFastArea, 1, 31, resolvedGroups) == 1);
|
|
|
|
|
assert(resolvedItems.findItem(0x100)->data.x == 518 &&
|
|
|
|
|
resolvedItems.findItem(0x100)->data.z == 79);
|
|
|
|
|
assert(resolvedKernel.scanResolvedGravity(1, resolvedItems, resolvedShapes,
|
|
|
|
|
resolvedFastArea, 1, 31, resolvedGroups) == 0);
|
|
|
|
|
remorse::ProcessKernel verticalKernel;
|
|
|
|
|
remorse::u16 verticalGroups[32]{};
|
|
|
|
|
for (int index = 0; index < 3; ++index) {
|
|
|
|
|
verticalKernel.createProcess(1, verticalGroups);
|
|
|
|
|
}
|
|
|
|
|
movingGravityItem.data.z = 40;
|
|
|
|
|
gravityWall.data.x = 512;
|
|
|
|
|
gravityWall.data.z = 20;
|
|
|
|
|
remorse::LiveFixedMapItems verticalItems({movingGravityItem, gravityWall});
|
|
|
|
|
const auto verticalId = verticalKernel.hurlItem(1, 0x100, 0, 0, -20, 2, 0, verticalGroups);
|
|
|
|
|
verticalKernel.scanRunnableProcesses(1, countGravityRun, &gravityRuns, 21);
|
|
|
|
|
assert(!verticalKernel.runResolvedGravity(verticalId, verticalItems,
|
|
|
|
|
resolvedShapes, resolvedFastArea, 1, 21, verticalGroups));
|
|
|
|
|
assert(verticalItems.findItem(0x100)->data.z == 40 &&
|
|
|
|
|
verticalKernel.processAt(verticalId)->bytes[0x36] == 0xec &&
|
|
|
|
|
(verticalKernel.processAt(verticalId)->bytes[0x19] & 0x10) == 0);
|
2026-09-26 19:20:20 +02:00
|
|
|
gravityKernel.terminateProcess(gravityId, gravityGroups);
|
|
|
|
|
assert(gravityKernel.findProcessForItemAndType(0x100, 0x203) == nullptr);
|
|
|
|
|
gravityKernel.clearTerminatedProcesses();
|
|
|
|
|
assert(gravityKernel.processAt(gravityId) == nullptr && !gravityKernel.itemHasProcess(0x100));
|
|
|
|
|
assert(gravityKernel.hurlItem(1, 0x100, 0, 0, 0, 2, 31, gravityGroups) == gravityId);
|
|
|
|
|
remorse::ProcessKernel externalGravityKernel;
|
|
|
|
|
remorse::u16 externalGravityGroups[32]{};
|
|
|
|
|
for (int index = 0; index < 3; ++index) {
|
|
|
|
|
externalGravityKernel.createProcess(1, externalGravityGroups);
|
|
|
|
|
}
|
|
|
|
|
auto* externalGravity = externalGravityKernel.createProcess(1, externalGravityGroups);
|
|
|
|
|
externalGravityKernel.setProcessSourceType(*externalGravity, 0x101);
|
|
|
|
|
externalGravityKernel.setProcessEventTypeChecked(*externalGravity, 0x203);
|
|
|
|
|
bool unownedGravityRejected = false;
|
|
|
|
|
try {
|
|
|
|
|
externalGravityKernel.hurlItem(1, 0x101, 1, 0, 0, 2, 0, externalGravityGroups);
|
|
|
|
|
} catch (const std::logic_error&) {
|
|
|
|
|
unownedGravityRejected = true;
|
|
|
|
|
}
|
|
|
|
|
assert(unownedGravityRejected && externalGravityGroups[1] == 4);
|
2026-09-25 21:41:20 +02:00
|
|
|
struct StandContext {
|
|
|
|
|
remorse::u32 tick;
|
|
|
|
|
bool visible;
|
|
|
|
|
remorse::u16 activity = 0;
|
|
|
|
|
bool currentActivity = false;
|
|
|
|
|
bool canSee = false;
|
|
|
|
|
remorse::u16 startedNpc = 0;
|
|
|
|
|
remorse::u16 startedActivity = 0;
|
|
|
|
|
int starts = 0;
|
|
|
|
|
int runs = 0;
|
|
|
|
|
remorse::StandProcessEntry* entry = nullptr;
|
|
|
|
|
remorse::NpcBehaviorServices* services = nullptr;
|
|
|
|
|
} standContext{99, false};
|
|
|
|
|
remorse::NpcBehaviorServices standServices{
|
|
|
|
|
[](remorse::u16 npcNumber, void* context) {
|
|
|
|
|
assert(npcNumber == 0x1234);
|
|
|
|
|
return static_cast<StandContext*>(context)->visible;
|
|
|
|
|
},
|
|
|
|
|
[](remorse::u16 npcNumber, void* context) {
|
|
|
|
|
assert(npcNumber == 0x1234);
|
|
|
|
|
return static_cast<StandContext*>(context)->activity;
|
|
|
|
|
},
|
|
|
|
|
[](remorse::u16 npcNumber, remorse::u16 activity, void* context) {
|
|
|
|
|
assert(npcNumber == 0x1234 && activity == 0x71);
|
|
|
|
|
return static_cast<StandContext*>(context)->currentActivity;
|
|
|
|
|
},
|
|
|
|
|
[](remorse::u16 npcNumber, void* context) {
|
|
|
|
|
assert(npcNumber == 0x1234);
|
|
|
|
|
return static_cast<StandContext*>(context)->canSee;
|
|
|
|
|
},
|
|
|
|
|
[](remorse::u16 npcNumber, remorse::u16 activity, void* context) {
|
|
|
|
|
auto& state = *static_cast<StandContext*>(context);
|
|
|
|
|
state.startedNpc = npcNumber;
|
|
|
|
|
state.startedActivity = activity;
|
|
|
|
|
++state.starts;
|
|
|
|
|
},
|
|
|
|
|
&standContext
|
|
|
|
|
};
|
|
|
|
|
standContext.entry = standEntry;
|
|
|
|
|
standContext.services = &standServices;
|
|
|
|
|
auto standRun = [](remorse::EntityDispatchEntryBase& process, void* context) {
|
|
|
|
|
auto& state = *static_cast<StandContext*>(context);
|
|
|
|
|
if (process.bytes[0] != 0x0f || process.bytes[1] != 0x1f) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
++state.runs;
|
|
|
|
|
remorse::StandProcess::run(*state.entry, *state.services, state.tick);
|
|
|
|
|
};
|
|
|
|
|
standKernel.scanRunnableProcesses(2, standRun, &standContext, standContext.tick);
|
|
|
|
|
assert(standContext.runs == 1 && standing->bytes[0x19] == 0x10);
|
|
|
|
|
assert(standing->bytes[0x0a] == 99 && standing->bytes[0x0e] == 60);
|
|
|
|
|
assert(standContext.starts == 0);
|
|
|
|
|
standContext.tick = 159;
|
|
|
|
|
standKernel.scanRunnableProcesses(2, standRun, &standContext, standContext.tick);
|
|
|
|
|
assert(standContext.runs == 1 && standing->bytes[0x19] == 0x10);
|
|
|
|
|
standContext.tick = 160;
|
|
|
|
|
standContext.visible = true;
|
|
|
|
|
standContext.activity = 0x71;
|
|
|
|
|
standContext.canSee = true;
|
|
|
|
|
standKernel.scanRunnableProcesses(2, standRun, &standContext, standContext.tick);
|
|
|
|
|
assert(standContext.runs == 2 && standing->bytes[0x19] == 0 && standing->bytes[0x0e] == 0);
|
|
|
|
|
assert(standContext.starts == 1 && standContext.startedNpc == 0x1234 && standContext.startedActivity == 0x71);
|
|
|
|
|
standContext.tick = 161;
|
|
|
|
|
standContext.currentActivity = true;
|
|
|
|
|
standKernel.scanRunnableProcesses(2, standRun, &standContext, standContext.tick);
|
|
|
|
|
assert(standContext.runs == 3 && standContext.starts == 1 && standing->bytes[0x0e] == 60);
|
|
|
|
|
|
|
|
|
|
remorse::ProcessKernel itemKernel;
|
|
|
|
|
remorse::u16 itemGroups[32]{};
|
|
|
|
|
for (int index = 0; index < 3; ++index) {
|
|
|
|
|
itemKernel.createProcess(1, itemGroups);
|
|
|
|
|
}
|
|
|
|
|
auto* firstStand = itemKernel.createStandProcess(2, 0x1234, itemGroups);
|
|
|
|
|
auto* secondStand = itemKernel.createStandProcess(2, 0x1234, itemGroups);
|
|
|
|
|
auto* otherStand = itemKernel.createStandProcess(2, 0x1235, itemGroups);
|
|
|
|
|
assert(itemKernel.itemHasProcess(0x1234) && itemKernel.itemHasProcess(0x1235));
|
|
|
|
|
itemKernel.terminateProcess(3, itemGroups);
|
|
|
|
|
assert(itemKernel.itemHasProcess(0x1234) && itemKernel.processAt(3) == &firstStand->base);
|
|
|
|
|
itemKernel.clearTerminatedProcesses();
|
|
|
|
|
assert(itemKernel.processAt(3) == nullptr && itemKernel.itemHasProcess(0x1234));
|
|
|
|
|
secondStand->base.bytes[0x18] |= 0x04;
|
|
|
|
|
itemKernel.terminateProcess(4, itemGroups);
|
|
|
|
|
assert(itemKernel.processAt(4) == nullptr && !itemKernel.itemHasProcess(0x1234));
|
|
|
|
|
assert(itemKernel.itemHasProcess(0x1235) && itemKernel.processAt(5) == &otherStand->base);
|
|
|
|
|
assert(itemGroups[2] == 1 && itemKernel.processCount() == 4);
|
|
|
|
|
|
|
|
|
|
remorse::SystemTimerProcessEntry systemTimer{};
|
|
|
|
|
systemTimer.extra[0x0e] = 0xff;
|
|
|
|
|
systemTimer.extra[0x0f] = 0xff;
|
|
|
|
|
assert(remorse::SystemTimerProcess::tick(systemTimer) == 0xffff);
|
|
|
|
|
remorse::SystemTimerProcess::increment(systemTimer);
|
|
|
|
|
assert(remorse::SystemTimerProcess::tick(systemTimer) == 0x10000);
|
|
|
|
|
assert(systemTimer.extra[0x0e] == 0 && systemTimer.extra[0x0f] == 0);
|
|
|
|
|
assert(systemTimer.extra[0x10] == 1 && systemTimer.extra[0x11] == 0);
|
|
|
|
|
|
|
|
|
|
remorse::ProcessKernel timerKernel;
|
|
|
|
|
remorse::u16 timerGroups[32]{};
|
|
|
|
|
bool missingTimerRejected = false;
|
|
|
|
|
try {
|
|
|
|
|
timerKernel.deliverSystemTimerEvent();
|
|
|
|
|
} catch (const std::logic_error&) {
|
|
|
|
|
missingTimerRejected = true;
|
|
|
|
|
}
|
|
|
|
|
assert(missingTimerRejected);
|
|
|
|
|
for (int index = 0; index < 3; ++index) {
|
|
|
|
|
timerKernel.createProcess(1, timerGroups);
|
|
|
|
|
}
|
|
|
|
|
auto* registeredTimer = timerKernel.createSystemTimerProcess(1, timerGroups);
|
|
|
|
|
assert(timerKernel.processAt(3) == ®isteredTimer->base);
|
|
|
|
|
assert(timerKernel.allocationSizeAt(3) == 0x4a && timerGroups[1] == 4);
|
|
|
|
|
assert(std::strcmp(timerKernel.processNameAt(3), "SystemTimer") == 0);
|
|
|
|
|
assert(registeredTimer->base.bytes[0x16] == 3 && registeredTimer->base.bytes[0x17] == 0x27);
|
|
|
|
|
assert(registeredTimer->base.bytes[0x18] == 1 && registeredTimer->extra[0] == 2);
|
|
|
|
|
assert(registeredTimer->extra[4] == 0x3c && timerKernel.systemTimerTick() == 0);
|
|
|
|
|
registeredTimer->base.bytes[0x17] &= static_cast<remorse::u8>(~0x04);
|
|
|
|
|
bool registrationRejected = false;
|
|
|
|
|
try {
|
|
|
|
|
timerKernel.deliverSystemTimerEvent();
|
|
|
|
|
} catch (const std::logic_error&) {
|
|
|
|
|
registrationRejected = true;
|
|
|
|
|
}
|
|
|
|
|
assert(registrationRejected && timerKernel.systemTimerTick() == 0);
|
|
|
|
|
registeredTimer->base.bytes[0x17] |= 0x04;
|
|
|
|
|
bool duplicateTimerRejected = false;
|
|
|
|
|
try {
|
|
|
|
|
timerKernel.createSystemTimerProcess(1, timerGroups);
|
|
|
|
|
} catch (const std::logic_error&) {
|
|
|
|
|
duplicateTimerRejected = true;
|
|
|
|
|
}
|
|
|
|
|
assert(duplicateTimerRejected && timerGroups[1] == 4);
|
|
|
|
|
bool timerTeardownRejected = false;
|
|
|
|
|
try {
|
|
|
|
|
timerKernel.terminateProcess(3, timerGroups);
|
|
|
|
|
} catch (const std::logic_error&) {
|
|
|
|
|
timerTeardownRejected = true;
|
|
|
|
|
}
|
|
|
|
|
assert(timerTeardownRejected && timerGroups[1] == 4);
|
|
|
|
|
auto* timedStand = timerKernel.createStandProcess(1, 7, timerGroups);
|
|
|
|
|
remorse::EntityDispatchEntry::sleep(timedStand->base, timerKernel.systemTimerTick(), 60);
|
|
|
|
|
for (int tick = 0; tick < 60; ++tick) {
|
|
|
|
|
timerKernel.deliverSystemTimerEvent();
|
|
|
|
|
}
|
|
|
|
|
ran.clear();
|
|
|
|
|
timerKernel.scanRunnableProcesses(1, recordRun, &ran, timerKernel.systemTimerTick());
|
|
|
|
|
assert(ran.size() == 3 && timedStand->base.bytes[0x19] == 0x10);
|
|
|
|
|
timerKernel.deliverSystemTimerEvent();
|
|
|
|
|
ran.clear();
|
|
|
|
|
timerKernel.scanRunnableProcesses(1, recordRun, &ran, timerKernel.systemTimerTick());
|
|
|
|
|
assert((ran == std::vector<remorse::u16>{0, 1, 2, 4}));
|
|
|
|
|
assert(timedStand->base.bytes[0x19] == 0 && timerKernel.systemTimerTick() == 61);
|
|
|
|
|
|
|
|
|
|
auto* keyboard = timerKernel.createKeyboardProcess(1, timerGroups);
|
|
|
|
|
assert(timerKernel.processAt(5) == &keyboard->base && timerKernel.allocationSizeAt(5) == 0x36);
|
|
|
|
|
assert(std::strcmp(timerKernel.processNameAt(5), "KeyboardProcess") == 0);
|
|
|
|
|
assert(keyboard->base.bytes[0x16] == 3 && keyboard->base.bytes[0x17] == 1);
|
|
|
|
|
assert(keyboard->base.bytes[0x18] == 0x81 && keyboard->base.bytes[0x19] == 1);
|
|
|
|
|
assert(keyboard->extra[0] == 0 && keyboard->extra[3] == 0 && timerGroups[1] == 6);
|
|
|
|
|
bool duplicateKeyboardRejected = false;
|
|
|
|
|
try {
|
|
|
|
|
timerKernel.createKeyboardProcess(1, timerGroups);
|
|
|
|
|
} catch (const std::logic_error&) {
|
|
|
|
|
duplicateKeyboardRejected = true;
|
|
|
|
|
}
|
|
|
|
|
assert(duplicateKeyboardRejected && timerGroups[1] == 6);
|
|
|
|
|
bool keyboardTeardownRejected = false;
|
|
|
|
|
try {
|
|
|
|
|
timerKernel.terminateProcess(5, timerGroups);
|
|
|
|
|
} catch (const std::logic_error&) {
|
|
|
|
|
keyboardTeardownRejected = true;
|
|
|
|
|
}
|
|
|
|
|
assert(keyboardTeardownRejected && timerGroups[1] == 6);
|
|
|
|
|
|
|
|
|
|
auto* keyDaemon = timerKernel.createKeyDaemonProcess(1, timerGroups);
|
|
|
|
|
assert(timerKernel.processAt(6) == &keyDaemon->base && timerKernel.allocationSizeAt(6) == 0x40);
|
|
|
|
|
assert(std::strcmp(timerKernel.processNameAt(6), "KeyDaemon") == 0);
|
|
|
|
|
assert(keyDaemon->base.bytes[0x16] == 3 && keyDaemon->base.bytes[0x17] == 0x27);
|
|
|
|
|
assert(keyDaemon->extra[0] == 2 && keyDaemon->extra[4] == 0x2d && timerGroups[1] == 7);
|
|
|
|
|
bool duplicateDaemonRejected = false;
|
|
|
|
|
try {
|
|
|
|
|
timerKernel.createKeyDaemonProcess(1, timerGroups);
|
|
|
|
|
} catch (const std::logic_error&) {
|
|
|
|
|
duplicateDaemonRejected = true;
|
|
|
|
|
}
|
|
|
|
|
assert(duplicateDaemonRejected && timerGroups[1] == 7);
|
|
|
|
|
bool daemonTeardownRejected = false;
|
|
|
|
|
try {
|
|
|
|
|
timerKernel.terminateProcess(6, timerGroups);
|
|
|
|
|
} catch (const std::logic_error&) {
|
|
|
|
|
daemonTeardownRejected = true;
|
|
|
|
|
}
|
|
|
|
|
assert(daemonTeardownRejected && timerGroups[1] == 7);
|
|
|
|
|
|
|
|
|
|
remorse::KeyEvent keyboardEvent{0x41, 0x1e, 1, 2, 3, 1, 4, 5};
|
|
|
|
|
const remorse::KeyEvent lastEvent{0x42, 0x30, 6, 7, 8, 9, 10, 11};
|
|
|
|
|
keyboard->extra[0] = 0x31;
|
|
|
|
|
assert(!remorse::KeyboardProcess::handleKeyEvent(*keyboard, 0x11, 0, keyboardEvent, lastEvent));
|
|
|
|
|
assert(!remorse::KeyboardProcess::handleKeyEvent(*keyboard, 0x10, 1, keyboardEvent, lastEvent));
|
|
|
|
|
assert(keyboardEvent.character == 0x41 && keyboard->extra[0] == 0x31);
|
|
|
|
|
keyboardEvent.field8 = 0;
|
|
|
|
|
assert(!remorse::KeyboardProcess::handleKeyEvent(*keyboard, 0x10, 0, keyboardEvent, lastEvent));
|
|
|
|
|
keyboardEvent.field8 = 1;
|
|
|
|
|
keyboardEvent.character = 0;
|
|
|
|
|
assert(!remorse::KeyboardProcess::handleKeyEvent(*keyboard, 0x10, 0, keyboardEvent, lastEvent));
|
|
|
|
|
keyboardEvent.character = 0x41;
|
|
|
|
|
assert(remorse::KeyboardProcess::handleKeyEvent(*keyboard, 0x10, 0, keyboardEvent, lastEvent));
|
2026-09-27 11:48:14 +02:00
|
|
|
remorse::ProcessKernel inputKernel;
|
|
|
|
|
assert(!inputKernel.popPendingKeyEvent());
|
|
|
|
|
for (remorse::u8 index = 0; index < 31; ++index) {
|
|
|
|
|
remorse::KeyEvent queued{};
|
|
|
|
|
queued.scanCode = index;
|
|
|
|
|
assert(inputKernel.queuePendingKeyEvent(queued));
|
|
|
|
|
}
|
|
|
|
|
assert(inputKernel.pendingKeyEventCount() == 31);
|
|
|
|
|
assert(!inputKernel.queuePendingKeyEvent({}));
|
|
|
|
|
assert(inputKernel.pendingKeyEventOverflowed());
|
|
|
|
|
for (remorse::u8 index = 0; index < 31; ++index) {
|
|
|
|
|
const auto queued = inputKernel.popPendingKeyEvent();
|
|
|
|
|
assert(queued && queued->scanCode == index);
|
|
|
|
|
}
|
|
|
|
|
assert(inputKernel.pendingKeyEventCount() == 0 && !inputKernel.pendingKeyEventOverflowed());
|
|
|
|
|
remorse::KeyEvent wrapped{};
|
|
|
|
|
wrapped.scanCode = 0x47;
|
|
|
|
|
assert(inputKernel.queuePendingKeyEvent(wrapped));
|
|
|
|
|
assert(inputKernel.popPendingKeyEvent()->scanCode == 0x47);
|
|
|
|
|
remorse::u16 inputGroups[32]{};
|
|
|
|
|
auto* inputKeyboard = inputKernel.createKeyboardProcess(1, inputGroups);
|
|
|
|
|
auto* inputController = inputKernel.createControllerProcess(1, inputGroups);
|
|
|
|
|
assert(inputController && inputController->base.bytes[0x00] == 0xa6 &&
|
|
|
|
|
inputController->base.bytes[0x01] == 0x3a);
|
|
|
|
|
assert(inputController->base.bytes[0x17] == 0x03 && inputController->extra[4] == 0x3c);
|
|
|
|
|
assert(!inputKeyboard->extra[0]);
|
|
|
|
|
assert(inputKernel.queuePendingKeyEvent(wrapped));
|
|
|
|
|
wrapped.scanCode = 0x48;
|
|
|
|
|
assert(inputKernel.queuePendingKeyEvent(wrapped));
|
|
|
|
|
std::vector<remorse::u8> deliveredScans;
|
|
|
|
|
inputKernel.dispatchPendingKeyEvents([](remorse::EntityDispatchEntryBase& process,
|
|
|
|
|
remorse::u16 selector, remorse::u16 filter, remorse::KeyEvent& event, void* context) {
|
|
|
|
|
assert(selector == 0x10 && filter == 0);
|
|
|
|
|
assert(process.bytes[0x00] == 0xa6);
|
|
|
|
|
static_cast<std::vector<remorse::u8>*>(context)->push_back(event.scanCode);
|
|
|
|
|
}, &deliveredScans);
|
|
|
|
|
assert((deliveredScans == std::vector<remorse::u8>{0x47, 0x48}));
|
|
|
|
|
assert(inputKernel.pendingKeyEventCount() == 0);
|
|
|
|
|
remorse::ControllerMovementState deliveredMovement;
|
|
|
|
|
wrapped.scanCode = 0x48;
|
|
|
|
|
wrapped.field8 = 1;
|
|
|
|
|
assert(inputKernel.queuePendingKeyEvent(wrapped));
|
|
|
|
|
inputKernel.dispatchPendingKeyEvents([](remorse::EntityDispatchEntryBase& process,
|
|
|
|
|
remorse::u16 selector, remorse::u16 filter, remorse::KeyEvent& event, void* context) {
|
|
|
|
|
assert(process.bytes[0] == 0xa6 && selector == 0x10 && filter == 0);
|
|
|
|
|
static_cast<remorse::ControllerMovementState*>(context)->handleDirectionalKey(
|
|
|
|
|
event.scanCode, event.modifiers, event.field8 != 0);
|
|
|
|
|
}, &deliveredMovement);
|
|
|
|
|
assert(deliveredMovement.request().animation == 1 && deliveredMovement.request().direction == 14);
|
|
|
|
|
wrapped.field8 = 0;
|
|
|
|
|
assert(inputKernel.queuePendingKeyEvent(wrapped));
|
|
|
|
|
inputKernel.dispatchPendingKeyEvents([](remorse::EntityDispatchEntryBase&,
|
|
|
|
|
remorse::u16, remorse::u16, remorse::KeyEvent& event, void* context) {
|
|
|
|
|
static_cast<remorse::ControllerMovementState*>(context)->handleDirectionalKey(
|
|
|
|
|
event.scanCode, event.modifiers, event.field8 != 0);
|
|
|
|
|
}, &deliveredMovement);
|
|
|
|
|
assert(deliveredMovement.request().animation == 0);
|
2026-09-25 21:41:20 +02:00
|
|
|
assert(std::memcmp(&keyboardEvent, &lastEvent, sizeof(keyboardEvent)) == 0);
|
|
|
|
|
assert(keyboard->extra[0] == 0x21);
|
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
|
|
|
|
2026-09-27 11:48:14 +02:00
|
|
|
remorse::ProcessKernel animationKernel;
|
|
|
|
|
remorse::u16 animationGroups[32]{};
|
|
|
|
|
for (int reservedSlot = 0; reservedSlot < 3; ++reservedSlot) {
|
|
|
|
|
animationKernel.createProcess(1, animationGroups);
|
|
|
|
|
}
|
|
|
|
|
remorse::AnimationClip walking{};
|
|
|
|
|
walking.header = {17, 4, 0, 0};
|
|
|
|
|
walking.frameCount = 17;
|
|
|
|
|
auto* animation = animationKernel.createAnimPrimitiveProcess(1, 1, 1, 6, walking, animationGroups);
|
|
|
|
|
assert(animationKernel.processAt(3) == &animation->base);
|
|
|
|
|
assert(animationKernel.allocationSizeAt(3) == 0x5b && animationGroups[1] == 4);
|
|
|
|
|
assert(animationKernel.findProcessForItemAndType(1, 0xf0) == &animation->base);
|
|
|
|
|
assert(animation->base.bytes[0] == 0x57 && animation->base.bytes[1] == 0x2a);
|
|
|
|
|
assert(animation->base.bytes[0x16] == 0 && animation->base.bytes[0x17] == 0x08);
|
|
|
|
|
assert(animation->extra[0] == 1 && animation->extra[4] == 1 && animation->extra[6] == 6);
|
|
|
|
|
assert(animation->extra[7] == 17 && animation->extra[0x18] == 17 && animation->extra[0x19] == 4);
|
|
|
|
|
remorse::LiveFixedMapItems animationItems({});
|
|
|
|
|
assert(animationItems.initializeAvatar());
|
|
|
|
|
assert(animationKernel.startAnimPrimitiveProcess(3, animationItems, walking));
|
|
|
|
|
const auto* npcAnimation = animationItems.findNpcAnimation(1);
|
|
|
|
|
assert(npcAnimation && npcAnimation->lastAnimation == 1 && npcAnimation->frame == 0);
|
|
|
|
|
assert(!animationKernel.startAnimPrimitiveProcess(3, animationItems, walking));
|
|
|
|
|
auto* repeatedWalk = animationKernel.createAnimPrimitiveProcess(1, 1, 1, 6, walking, animationGroups);
|
|
|
|
|
assert(animationKernel.startAnimPrimitiveProcess(4, animationItems, walking));
|
|
|
|
|
assert(repeatedWalk->base.bytes[0x3a] == 1 && animationItems.findNpcAnimation(1)->frame == 1);
|
|
|
|
|
auto* turning = animationKernel.createAnimPrimitiveProcess(1, 1, 0, 6, walking, animationGroups);
|
|
|
|
|
assert(animationKernel.startAnimPrimitiveProcess(5, animationItems, walking));
|
|
|
|
|
assert(turning->base.bytes[0x3a] == 1 && animationItems.findNpcAnimation(1)->frame == 0);
|
|
|
|
|
remorse::StagedFixedMapItem animationSpawn{};
|
|
|
|
|
animationSpawn.data.x = 512;
|
|
|
|
|
animationSpawn.data.y = 512;
|
|
|
|
|
assert(animationItems.teleportAvatar(animationSpawn, 1));
|
|
|
|
|
walking.frames.resize(17 * 8);
|
|
|
|
|
auto& nextWalkFrame = walking.frames[3 * 17 + 1];
|
|
|
|
|
nextWalkFrame.bytes[4] = 1;
|
|
|
|
|
nextWalkFrame.bytes[5] = 2;
|
|
|
|
|
std::vector<remorse::ShapeTypeInfo> animationShapes(2);
|
|
|
|
|
animationShapes[1].x = animationShapes[1].y = animationShapes[1].z = 2;
|
|
|
|
|
auto& movingNpc = *animationItems.editNpcAnimation(1);
|
|
|
|
|
movingNpc.lastAnimation = 1;
|
|
|
|
|
movingNpc.frame = 0;
|
|
|
|
|
const auto animationArea = remorse::calculateFastAreaRange({512, 512, 0});
|
|
|
|
|
assert(animationKernel.advanceGroundedAnimPrimitive(3, animationItems,
|
|
|
|
|
walking, animationShapes, animationArea) == true);
|
|
|
|
|
assert(animationItems.findItem(1)->data.x == 514 && animationItems.findItem(1)->data.y == 514);
|
|
|
|
|
assert(movingNpc.frame == 1);
|
|
|
|
|
nextWalkFrame.bytes[4] = 100;
|
|
|
|
|
movingNpc.frame = 0;
|
|
|
|
|
remorse::StagedFixedMapItem animationWall{};
|
|
|
|
|
animationWall.itemNumber = 0x100;
|
|
|
|
|
animationWall.data.shape = 2;
|
|
|
|
|
animationWall.data.x = 650;
|
|
|
|
|
animationWall.data.y = 650;
|
|
|
|
|
animationShapes.push_back(animationShapes[1]);
|
|
|
|
|
animationShapes[2].flags = 2;
|
|
|
|
|
assert(animationItems.insertItem(animationWall));
|
|
|
|
|
assert(animationKernel.advanceGroundedAnimPrimitive(3, animationItems,
|
|
|
|
|
walking, animationShapes, animationArea) == false);
|
|
|
|
|
assert(animationItems.findItem(1)->data.x == 514 && movingNpc.frame == 0);
|
|
|
|
|
assert(animation->extra[0x0a] == 1);
|
|
|
|
|
walking.header[1] = 5;
|
|
|
|
|
nextWalkFrame.bytes[4] = 1;
|
|
|
|
|
auto* twoStepWalk = animationKernel.createAnimPrimitiveProcess(1, 1, 1, 6, walking, animationGroups);
|
|
|
|
|
assert(animationKernel.startAnimPrimitiveProcess(6, animationItems, walking));
|
|
|
|
|
assert(movingNpc.frame == 8 && twoStepWalk->extra[7] == 17);
|
|
|
|
|
movingNpc.frame = 16;
|
|
|
|
|
assert(animationKernel.advanceGroundedAnimPrimitive(6, animationItems,
|
|
|
|
|
walking, animationShapes, animationArea) == true);
|
|
|
|
|
assert(movingNpc.frame == 1 && animationItems.findItem(1)->data.x == 516);
|
|
|
|
|
twoStepWalk->base.bytes[0x18] |= 4;
|
|
|
|
|
animationKernel.terminateProcess(6, animationGroups);
|
|
|
|
|
assert(animationKernel.processAt(6) == nullptr && animationKernel.allocationSizeAt(6) == 0);
|
|
|
|
|
assert(animationGroups[1] == 6 && animationKernel.itemHasProcess(1));
|
|
|
|
|
|
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
|
|
|
return 0;
|
|
|
|
|
}
|