From e1ddbf30a099d80591506038972a7f739d910650 Mon Sep 17 00:00:00 2001 From: ozkl Date: Fri, 6 Sep 2019 12:01:15 +0300 Subject: [PATCH] posx/posy args added to soso to support window placement --- doomgeneric/doomgeneric_soso.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/doomgeneric/doomgeneric_soso.c b/doomgeneric/doomgeneric_soso.c index 86d1941..3912964 100644 --- a/doomgeneric/doomgeneric_soso.c +++ b/doomgeneric/doomgeneric_soso.c @@ -1,7 +1,7 @@ //doomgeneric for soso os #include "doomkeys.h" - +#include "m_argv.h" #include "doomgeneric.h" #include @@ -22,6 +22,9 @@ static unsigned short s_KeyQueue[KEYQUEUE_SIZE]; static unsigned int s_KeyQueueWriteIndex = 0; static unsigned int s_KeyQueueReadIndex = 0; +static unsigned int s_PositionX = 0; +static unsigned int s_PositionY = 0; + static unsigned char convertToDoomKey(unsigned char scancode) { unsigned char key = 0; @@ -133,6 +136,21 @@ void DG_Init() //enter non-blocking mode syscall_ioctl(KeyboardFd, 1, (void*)1); } + + int argPosX = 0; + int argPosY = 0; + + argPosX = M_CheckParmWithArgs("-posx", 1); + if (argPosX > 0) + { + sscanf(myargv[argPosX + 1], "%d", &s_PositionX); + } + + argPosY = M_CheckParmWithArgs("-posy", 1); + if (argPosY > 0) + { + sscanf(myargv[argPosY + 1], "%d", &s_PositionY); + } } static void handleKeyInput() @@ -173,7 +191,7 @@ void DG_DrawFrame() for (int i = 0; i < DOOMGENERIC_RESY; ++i) { - memcpy(FrameBuffer + i * screenWidth, DG_ScreenBuffer + i * DOOMGENERIC_RESX, DOOMGENERIC_RESX * 4); + memcpy(FrameBuffer + s_PositionX + (i + s_PositionY) * screenWidth, DG_ScreenBuffer + i * DOOMGENERIC_RESX, DOOMGENERIC_RESX * 4); } } @@ -213,4 +231,4 @@ int DG_GetKey(int* pressed, unsigned char* doomKey) void DG_SetWindowTitle(const char * title) { -} \ No newline at end of file +}