Skip to content

Instantly share code, notes, and snippets.

@alcz alcz/boxedwine.sdl1.patch Secret
Created Mar 16, 2018

Embed
What would you like to do?
BoxedWine r694 with SDL1 Win32
diff --git a/source/kernel/devs/devdsp.c b/source/kernel/devs/devdsp.c
index bdde443..2ef5b23 100644
--- a/source/kernel/devs/devdsp.c
+++ b/source/kernel/devs/devdsp.c
@@ -135,8 +135,10 @@ void dspCheck();
U32 bytesPerSample(struct DspData* data) {
if (data->want.format == AUDIO_S16LSB || data->want.format == AUDIO_S16MSB || data->want.format == AUDIO_U16LSB || data->want.format == AUDIO_U16MSB)
return 2;
+#ifdef SDL2
else if (data->want.format == AUDIO_F32LSB)
return 4;
+#endif
else
return 1;
}
@@ -359,10 +361,12 @@ U32 dsp_ioctl(struct KThread* thread, struct FsOpenNode* node, U32 request) {
data->dspFmt = AFMT_U8;
data->want.format = AUDIO_U8;
break;
+#ifdef SDL2
case AFMT_FLOAT:
data->dspFmt = AFMT_FLOAT;
data->want.format = AUDIO_F32LSB;
break;
+#endif
}
if (write)
writed(thread, IOCTL_ARG1, data->dspFmt);
diff --git a/source/sdl/main.c b/source/sdl/main.c
index 39ddb87..33827a2 100644
--- a/source/sdl/main.c
+++ b/source/sdl/main.c
@@ -544,6 +544,7 @@ int main(int argc, char **argv) {
return 0;
}
+#ifdef SDL2
if (sdlFullScreen && !resolutionSet) {
SDL_DisplayMode mode;
if (!SDL_GetCurrentDisplayMode(0, &mode)) {
@@ -551,6 +552,7 @@ int main(int argc, char **argv) {
screenCy = mode.h;
}
}
+#endif
klog("Launching %s", argv[0]);
if (startProcess(workingDir, argc, (const char**)argv, envc, ppenv, userId, groupId, effectiveUserId, effectiveGroupId)) {
#ifdef __EMSCRIPTEN__
@@ -610,6 +612,7 @@ int main(int argc, char **argv) {
if (!sdlMouseButton(0, 1, e.motion.x, e.motion.y))
onMouseButtonUp(1);
}
+#ifdef SDL2
} else if (e.type == SDL_MOUSEWHEEL) {
// Handle up/down mouse wheel movements
int x, y;
@@ -617,6 +620,7 @@ int main(int argc, char **argv) {
if (!sdlMouseWheel(e.wheel.y*80, x, y)) {
onMouseWheel(e.wheel.y);
}
+#endif
} else if (e.type == SDL_KEYDOWN) {
if (e.key.keysym.sym==SDLK_SCROLLOCK) {
if (e.key.keysym.mod & KMOD_CTRL)
diff --git a/source/sdl/sdlwindows.c b/source/sdl/sdlwindows.c
index 0a337cb..de44d06 100644
--- a/source/sdl/sdlwindows.c
+++ b/source/sdl/sdlwindows.c
@@ -420,10 +420,12 @@ static void destroySDL2(struct KThread* thread) {
}
pblIteratorFree(it);
+#ifdef SDL2
if (sdlRenderer) {
SDL_DestroyRenderer(sdlRenderer);
sdlRenderer = 0;
}
+
if (thread->glContext) {
SDL_GL_DeleteContext(thread->glContext);
thread->glContext = 0;
@@ -433,6 +435,7 @@ static void destroySDL2(struct KThread* thread) {
SDL_GL_DeleteContext(sdlInitContext);
sdlInitContext = 0;
}
+#endif
#endif
if (sdlWindow) {
SDL_DestroyWindow(sdlWindow);
@@ -468,6 +471,7 @@ void sdlDeleteContext(struct KThread* thread, U32 context) {
return;
}
#endif
+#ifdef SDL2
struct KThread* contextThread = processGetThreadById(thread, thread->process, context);
if (contextThread && contextThread->glContext) {
SDL_GL_DeleteContext(contextThread->glContext);
@@ -477,13 +481,16 @@ void sdlDeleteContext(struct KThread* thread, U32 context) {
displayChanged(thread);
}
}
+#endif
}
void sdlUpdateContextForThread(struct KThread* thread) {
+#ifdef SDL2
if (thread->currentContext && thread->currentContext!=sdlCurrentContext) {
SDL_GL_MakeCurrent(sdlWindow, thread->glContext);
sdlCurrentContext = thread->glContext;
}
+#endif
}
#ifdef BOXEDWINE_VM
@@ -542,6 +549,7 @@ U32 sdlShareLists(struct KThread* thread, U32 srcContext, U32 destContext) {
}
#endif
{
+#ifdef SDL2
struct KThread* srcThread = processGetThreadById(thread, thread->process, srcContext);
struct KThread* destThread = processGetThreadById(thread, thread->process, destContext);
if (srcThread && destThread && srcThread->glContext && destThread->glContext) {
@@ -557,6 +565,7 @@ U32 sdlShareLists(struct KThread* thread, U32 srcContext, U32 destContext) {
//SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 0);
return 1;
}
+#endif
return 0;
}
}
@@ -617,7 +626,9 @@ U32 sdlCreateOpenglWindow(struct KThread* thread, struct Wnd* wnd, int major, in
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, wnd->pixelFormat->dwFlags & 1);
SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, (wnd->pixelFormat->dwFlags & 0x40)?0:1);
+#ifdef SDL2
SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
+#endif
firstWindowCreated = 1;
#ifdef SDL2
sdlWindow = SDL_CreateWindow("OpenGL Window", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, wnd->windowRect.right-wnd->windowRect.left, wnd->windowRect.bottom-wnd->windowRect.top, SDL_WINDOW_OPENGL|SDL_WINDOW_SHOWN);
@@ -738,9 +749,11 @@ static SDL_mutex* wndBltMutex;
#endif
void wndBlt(struct KThread* thread, U32 hwnd, U32 bits, S32 xOrg, S32 yOrg, U32 width, U32 height, U32 rect) {
+#ifdef SDL2
if (!sdlRenderer) {
return;
}
+#endif
#ifdef BOXEDWINE_VM
if (0) {
struct SdlCallback* callback = allocSdlCallback(thread);
@@ -846,7 +859,7 @@ void wndBlt(struct KThread* thread, U32 hwnd, U32 bits, S32 xOrg, S32 yOrg, U32
SDL_LockSurface(s);
}
for (y = 0; y < height; y++) {
- memcopyToNative(memory, bits+(height-y-1)*pitch, (U8*)(s->pixels)+y*s->pitch, pitch);
+ memcopyToNative(thread, bits+(height-y-1)*pitch, (U8*)(s->pixels)+y*s->pitch, pitch);
}
if (SDL_MUSTLOCK(s)) {
SDL_UnlockSurface(s);
@@ -873,8 +886,10 @@ U32 sdlUpdated;
void sdlDrawAllWindows(struct KThread* thread, U32 hWnd, int count) {
int i;
+#ifdef SDL2
if (!sdlRenderer)
return;
+#endif
#ifdef BOXEDWINE_VM
if (0) {
struct SdlCallback* callback = allocSdlCallback(thread);
@@ -913,7 +928,7 @@ void sdlDrawAllWindows(struct KThread* thread, U32 hWnd, int count) {
if (surface) {
SDL_FillRect(surface, NULL, SDL_MapRGB(surface->format, 58, 110, 165));
for (i=count-1;i>=0;i--) {
- struct Wnd* wnd = getWnd(readd(memory, hWnd+i*4));
+ struct Wnd* wnd = getWnd(readd(thread, hWnd+i*4));
if (wnd && wnd->sdlSurface) {
SDL_Rect dstrect;
dstrect.x = wnd->windowRect.left;
diff --git a/source/sdl/winedrv.c b/source/sdl/winedrv.c
index f78fa25..35e7fc3 100644
--- a/source/sdl/winedrv.c
+++ b/source/sdl/winedrv.c
@@ -337,9 +337,11 @@ void boxeddrv_ClipCursor(struct CPU* cpu) {
// INT CDECL drv_CountClipboardFormats(void)
void boxeddrv_CountClipboardFormats(struct CPU* cpu) {
+#ifdef SDL2
if (SDL_HasClipboardText())
EAX = 2; // CF_UNICODETEXT & CF_TEXT
else
+#endif
EAX = 0;
}
@@ -369,7 +371,9 @@ void boxeddrv_DestroyWindow(struct CPU* cpu) {
// void CDECL drv_EmptyClipboard(void)
void boxeddrv_EmptyClipboard(struct CPU* cpu) {
+#ifdef SDL2
SDL_SetClipboardText(NULL);
+#endif
}
//void CDECL drv_EndClipboardUpdate(void)
@@ -379,6 +383,7 @@ void boxeddrv_EndClipboardUpdate(struct CPU* cpu) {
// UINT CDECL drv_EnumClipboardFormats(UINT prev_format)
void boxeddrv_EnumClipboardFormats(struct CPU* cpu) {
+#ifdef SDL2
U32 prevFormat = ARG1;
if (SDL_HasClipboardText()) {
if (prevFormat == 0)
@@ -388,6 +393,7 @@ void boxeddrv_EnumClipboardFormats(struct CPU* cpu) {
else
EAX = 0;
} else
+#endif
EAX = 0;
}
@@ -494,6 +500,7 @@ void boxeddrv_EnumDisplaySettingsEx(struct CPU* cpu) {
// int CDECL drv_GetClipboardData(UINT desired_format, char* buffer, int bufferLen)
void boxeddrv_GetClipboardData(struct CPU* cpu) {
+#ifdef SDL2
U32 format = ARG1;
if ((format == CF_TEXT || format == CF_UNICODETEXT) && SDL_HasClipboardText()) {
@@ -510,7 +517,10 @@ void boxeddrv_GetClipboardData(struct CPU* cpu) {
writeNativeStringW(cpu->thread, ARG2, text);
EAX = 2*(len+1);
}
- } else {
+ } else {
+#else
+ {
+#endif
EAX = 0;
}
}
@@ -556,10 +566,12 @@ void boxeddrv_GetMonitorInfo(struct CPU* cpu) {
// BOOL CDECL drv_IsClipboardFormatAvailable(UINT desired_format)
void boxeddrv_IsClipboardFormatAvailable(struct CPU* cpu) {
+#ifdef SDL2
U32 format = ARG1;
if ((format == CF_TEXT || format == CF_UNICODETEXT) && SDL_HasClipboardText())
EAX = 1;
else
+#endif
EAX = 0;
}
@@ -583,6 +595,7 @@ void boxeddrv_SetCapture(struct CPU* cpu) {
// BOOL CDECL drv_SetClipboardData(UINT format_id, char* data, int len, BOOL owner)
void boxeddrv_SetClipboardData(struct CPU* cpu) {
+#ifdef SDL2
U32 format = ARG1;
char* text = 0;
int len = ARG3;
@@ -599,6 +612,9 @@ void boxeddrv_SetClipboardData(struct CPU* cpu) {
else
EAX = 0;
} else {
+#else
+ {
+#endif
EAX = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.