#pragma once namespace openroller::psp { constexpr int kScreenWidth = 480; constexpr int kScreenHeight = 272; constexpr int kLogicalWidth = 720; constexpr int kLogicalHeight = 1280; constexpr float kLogicalScale = 3.0f / 8.0f; constexpr int kScaledWidth = 270; constexpr int kBorder = (kScreenHeight - kScaledWidth) / 2; enum class TateSide { Clockwise, CounterClockwise, }; struct Point { float x; float y; }; inline Point toScreen(float logicalX, float logicalY, TateSide side) { if (side == TateSide::Clockwise) { return { static_cast(kScreenWidth) - logicalY * kLogicalScale, static_cast(kBorder) + logicalX * kLogicalScale, }; } return { logicalY * kLogicalScale, static_cast(kBorder + kScaledWidth) - logicalX * kLogicalScale, }; } inline Point screenDirectionToLogical(float screenX, float screenY, TateSide side) { if (side == TateSide::Clockwise) { return {screenY, -screenX}; } return {-screenY, screenX}; } } // namespace openroller::psp