Skip to content

Commit e1ddbf3

Browse files
committed
posx/posy args added to soso to support window placement
1 parent 055456a commit e1ddbf3

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

doomgeneric/doomgeneric_soso.c

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//doomgeneric for soso os
22

33
#include "doomkeys.h"
4-
4+
#include "m_argv.h"
55
#include "doomgeneric.h"
66

77
#include <stdio.h>
@@ -22,6 +22,9 @@ static unsigned short s_KeyQueue[KEYQUEUE_SIZE];
2222
static unsigned int s_KeyQueueWriteIndex = 0;
2323
static unsigned int s_KeyQueueReadIndex = 0;
2424

25+
static unsigned int s_PositionX = 0;
26+
static unsigned int s_PositionY = 0;
27+
2528
static unsigned char convertToDoomKey(unsigned char scancode)
2629
{
2730
unsigned char key = 0;
@@ -133,6 +136,21 @@ void DG_Init()
133136
//enter non-blocking mode
134137
syscall_ioctl(KeyboardFd, 1, (void*)1);
135138
}
139+
140+
int argPosX = 0;
141+
int argPosY = 0;
142+
143+
argPosX = M_CheckParmWithArgs("-posx", 1);
144+
if (argPosX > 0)
145+
{
146+
sscanf(myargv[argPosX + 1], "%d", &s_PositionX);
147+
}
148+
149+
argPosY = M_CheckParmWithArgs("-posy", 1);
150+
if (argPosY > 0)
151+
{
152+
sscanf(myargv[argPosY + 1], "%d", &s_PositionY);
153+
}
136154
}
137155

138156
static void handleKeyInput()
@@ -173,7 +191,7 @@ void DG_DrawFrame()
173191

174192
for (int i = 0; i < DOOMGENERIC_RESY; ++i)
175193
{
176-
memcpy(FrameBuffer + i * screenWidth, DG_ScreenBuffer + i * DOOMGENERIC_RESX, DOOMGENERIC_RESX * 4);
194+
memcpy(FrameBuffer + s_PositionX + (i + s_PositionY) * screenWidth, DG_ScreenBuffer + i * DOOMGENERIC_RESX, DOOMGENERIC_RESX * 4);
177195
}
178196
}
179197

@@ -213,4 +231,4 @@ int DG_GetKey(int* pressed, unsigned char* doomKey)
213231

214232
void DG_SetWindowTitle(const char * title)
215233
{
216-
}
234+
}

0 commit comments

Comments
 (0)