]> git.0x19.co - doomgeneric-snom360/commitdiff
posx/posy args added to soso to support window placement
authorozkl <ozkl@users.noreply.github.com>
Fri, 6 Sep 2019 09:01:15 +0000 (12:01 +0300)
committerozkl <ozkl@users.noreply.github.com>
Fri, 6 Sep 2019 09:01:15 +0000 (12:01 +0300)
doomgeneric/doomgeneric_soso.c

index 86d19419b48b84fcf03c44c8c1a350a880fb25dd..3912964756a033cd1a6927934d4e2df40bf1867f 100644 (file)
@@ -1,7 +1,7 @@
 //doomgeneric for soso os
 
 #include "doomkeys.h"
-
+#include "m_argv.h"
 #include "doomgeneric.h"
 
 #include <stdio.h>
@@ -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
+}