#include "remorse/isometric_controls.h" #include "remorse/map_renderer.h" #include int main() { remorse::ControllerMovementState controller; assert(controller.request().animation == 0); controller.handleDirectionalKey(0x48, 0, true); assert(controller.request().animation == 1 && controller.request().direction == 14); controller.handleDirectionalKey(0x4d, 1, true); assert(controller.request().animation == 3 && controller.request().direction == 2); controller.handleDirectionalKey(0x4d, 1, false); assert(controller.request().animation == 3 && controller.request().direction == 14); controller.handleDirectionalKey(0x48, 0, false); assert(controller.request().animation == 0 && controller.request().direction == 14); controller.handleDirectionalKey(0x49, 0x20, true); assert(controller.request().animation == 0); controller.handleDirectionalKey(0x47, 0x40, true); assert(controller.request().animation == 3 && controller.request().direction == 12); controller.clear(); assert(controller.request().animation == 0); 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(east.x), static_cast(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(north.x), static_cast(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(west.x), static_cast(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(south.x), static_cast(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; }