diff --git a/linux.md b/linux.md index 7fc031e5..4afe0ea3 100644 --- a/linux.md +++ b/linux.md @@ -91,7 +91,11 @@ See [sa2](source/frontends/sa2/README.md). ### ra2 -There is an initial [libretro](https://docs.libretro.com/development/cores/developing-cores/) core, with minimal keyboard support and upside down video. +There is an initial [libretro](https://docs.libretro.com/development/cores/developing-cores/) core. + +Keyboard works, but a lot of keys overlap with RetroArch shortcuts. + +Video works, but the vertical flip is done in software. Must be manually configured: ``cmake -DLIBRETRO_PATH=/path/to/libretro-common`` diff --git a/source/frontends/retro/game.cpp b/source/frontends/retro/game.cpp index 31b1a584..174cf093 100644 --- a/source/frontends/retro/game.cpp +++ b/source/frontends/retro/game.cpp @@ -112,7 +112,10 @@ namespace } -Game::Game() : mySpeed(true) +Game::Game() + : mySpeed(true) + , myWidth(GetFrameBufferWidth()) + , myHeight(GetFrameBufferHeight()) { EmulatorOptions options; options.memclear = g_nMemoryClearType; @@ -125,6 +128,9 @@ Game::Game() : mySpeed(true) InitializeRegistry(options); initialiseEmulator(); + + const size_t size = myWidth * myHeight * sizeof(bgra_t); + myVideoBuffer.resize(size); } Game::~Game() @@ -270,8 +276,18 @@ void Game::processKeyUp(unsigned keycode, uint32_t character, uint16_t key_modif void Game::drawVideoBuffer() { - const size_t pitch = GetFrameBufferWidth() * 4; - video_cb(g_pFramebufferbits, GetFrameBufferWidth(), GetFrameBufferHeight(), pitch); + const size_t pitch = myWidth * sizeof(bgra_t); + // this should not be necessary + // either libretro handles it + // or we should change AW + // but for now, there is no alternative + for (size_t row = 0; row < myHeight; ++row) + { + const uint8_t * src = g_pFramebufferbits + row * pitch; + uint8_t * dst = myVideoBuffer.data() + (myHeight - row - 1) * pitch; + memcpy(dst, src, pitch); + } + video_cb(myVideoBuffer.data(), myWidth, myHeight, pitch); } bool Game::loadGame(const char * path) diff --git a/source/frontends/retro/game.h b/source/frontends/retro/game.h index 9181f977..e68337da 100644 --- a/source/frontends/retro/game.h +++ b/source/frontends/retro/game.h @@ -20,7 +20,11 @@ public: private: Speed mySpeed; // fixed speed + const size_t myHeight; + const size_t myWidth; + static void processKeyDown(unsigned keycode, uint32_t character, uint16_t key_modifiers); static void processKeyUp(unsigned keycode, uint32_t character, uint16_t key_modifiers); + std::vector myVideoBuffer; };