- 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.
60 lines
No EOL
3 KiB
C++
60 lines
No EOL
3 KiB
C++
#include "remorse/isometric_controls.h"
|
|
#include "remorse/map_renderer.h"
|
|
|
|
#include <cassert>
|
|
|
|
int main()
|
|
{
|
|
assert(remorse::controllerWalkRequested(0));
|
|
assert(!remorse::controllerWalkRequested(0x01));
|
|
assert(!remorse::controllerWalkRequested(0x02));
|
|
assert(!remorse::controllerWalkRequested(0x40));
|
|
assert(remorse::controllerWalkRequested(0x41));
|
|
assert(remorse::controllerWalkRequested(0x42));
|
|
constexpr remorse::u8 scans[] = {0x47, 0x48, 0x49, 0x4b, 0x4d, 0x4f, 0x50, 0x51};
|
|
constexpr remorse::u8 directions[] = {12, 14, 0, 10, 2, 8, 6, 4};
|
|
for (std::size_t index = 0; index < std::size(scans); ++index) {
|
|
assert(remorse::controllerDirectionFromScan(scans[index]) == directions[index]);
|
|
}
|
|
assert(!remorse::controllerDirectionFromScan(0x52));
|
|
constexpr remorse::s32 originX = 1024;
|
|
constexpr remorse::s32 originY = 2048;
|
|
const remorse::ScreenPoint origin = remorse::projectToScreen({originX, originY, 0});
|
|
|
|
const auto east = remorse::worldPositionAtScreenOffset(originX, originY, 1.0, 0.0);
|
|
const remorse::ScreenPoint eastProjection = remorse::projectToScreen({
|
|
static_cast<remorse::s32>(east.x), static_cast<remorse::s32>(east.y), 0});
|
|
assert(eastProjection.x - origin.x == 1);
|
|
assert(eastProjection.y - origin.y == 0);
|
|
|
|
const auto north = remorse::worldPositionAtScreenOffset(originX, originY, 0.0, -1.0);
|
|
const remorse::ScreenPoint northProjection = remorse::projectToScreen({
|
|
static_cast<remorse::s32>(north.x), static_cast<remorse::s32>(north.y), 0});
|
|
assert(northProjection.x - origin.x == 0);
|
|
assert(northProjection.y - origin.y == -1);
|
|
|
|
const auto west = remorse::worldPositionAtScreenOffset(originX, originY, -1.0, 0.0);
|
|
const remorse::ScreenPoint westProjection = remorse::projectToScreen({
|
|
static_cast<remorse::s32>(west.x), static_cast<remorse::s32>(west.y), 0});
|
|
assert(westProjection.x - origin.x == -1);
|
|
assert(westProjection.y - origin.y == 0);
|
|
|
|
const auto south = remorse::worldPositionAtScreenOffset(originX, originY, 0.0, 1.0);
|
|
const remorse::ScreenPoint southProjection = remorse::projectToScreen({
|
|
static_cast<remorse::s32>(south.x), static_cast<remorse::s32>(south.y), 0});
|
|
assert(southProjection.x - origin.x == 0);
|
|
assert(southProjection.y - origin.y == 1);
|
|
remorse::AnimationFrameMetadata forwardFrame{};
|
|
forwardFrame.bytes[4] = 6;
|
|
const auto forward = remorse::hostMovementStep(forwardFrame, 6, false);
|
|
assert(forward && forward->x > 0 && forward->y > 0);
|
|
remorse::AnimationFrameMetadata reverseFrame{};
|
|
reverseFrame.bytes[4] = 0xfe;
|
|
reverseFrame.bytes[5] = 3;
|
|
const auto authoredReverse = remorse::decodeAnimationDisplacement(reverseFrame, 6, false);
|
|
const auto hostReverse = remorse::hostMovementStep(reverseFrame, 6, false);
|
|
assert(authoredReverse && authoredReverse->x < 0 && authoredReverse->y < 0);
|
|
assert(hostReverse && hostReverse->x == 0 && hostReverse->y == 0);
|
|
assert(hostReverse->z == authoredReverse->z && hostReverse->onGround == authoredReverse->onGround);
|
|
return 0;
|
|
} |