Index: Daodan/build.bat
===================================================================
--- Daodan/build.bat	(revision 322)
+++ Daodan/build.bat	(revision 323)
@@ -1,1 +1,1 @@
-gcc -O3 -s -Wall -shared -fomit-frame-pointer -o build\binkw32.dll src\Oni_Symbols.S src\Daodan.c src\Daodan_DLLStubs.c src\Daodan_Patch.c src\Daodan_Utility.c src\daodan_gl.c
+gcc -O3 -s -Wall -shared -fomit-frame-pointer -o build\binkw32.dll src\Oni_Symbols.S src\Daodan.c src\Daodan_DLLStubs.c src\Daodan_Patch.c src\Daodan_Utility.c src\Daodan_Win32.c src\daodan_gl.c -lgdi32
Index: Daodan/src/Daodan.c
===================================================================
--- Daodan/src/Daodan.c	(revision 322)
+++ Daodan/src/Daodan.c	(revision 323)
@@ -2,4 +2,5 @@
 #include "Daodan_Patch.h"
 #include "Daodan_Utility.h"
+#include "Daodan_Win32.h"
 
 #include "Oni.h"
@@ -82,4 +83,7 @@
 	DDrPatch_MakeJump(UUrMachineTime_Sixtieths, DDrMachineTime_Sixtieths);
 	
+	// Windowed mode
+	DDrPatch_MakeJump(ONrPlatform_Initialize, DDrPlatform_Initialize);
+	
 	ONiMain(argc, argv);
 }
Index: Daodan/src/Daodan_Win32.c
===================================================================
--- Daodan/src/Daodan_Win32.c	(revision 322)
+++ Daodan/src/Daodan_Win32.c	(revision 323)
@@ -0,0 +1,44 @@
+#include <windows.h>
+
+#include "Daodan.h"
+#include "Daodan_Win32.h"
+
+#include "Oni.h"
+
+short ONICALL DDrPlatform_Initialize(ONtPlatformData *PlatformData)
+{
+	WNDCLASSEX WndClass;
+	RECT Rect;
+	const int Width = 640, Height = 480;
+
+	PlatformData->Instance = g_Instance;
+
+	WndClass.cbSize = sizeof(WndClass);
+	WndClass.style = WS_OVERLAPPED | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | CS_VREDRAW | CS_HREDRAW | CS_OWNDC;
+	WndClass.cbClsExtra = 0;
+	WndClass.cbWndExtra = 0;
+	WndClass.hInstance = PlatformData->Instance;
+	WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
+	WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
+	WndClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
+	WndClass.hbrBackground = GetStockObject(BLACK_BRUSH);
+	WndClass.lpszMenuName = NULL;
+	WndClass.lpszClassName = "ONI ";
+	WndClass.lpfnWndProc = ONrPlatform_WindowProc;
+
+	RegisterClassEx(&WndClass);
+	
+	Rect.left = (GetSystemMetrics(SM_CXSCREEN) / 2) - (Width / 2);
+	Rect.top = (GetSystemMetrics(SM_CYSCREEN) / 2) - (Height / 2);
+	Rect.right = Rect.left + Width;
+	Rect.bottom = Rect.top + Height;
+	AdjustWindowRect(&Rect, WndClass.style, FALSE);
+
+	PlatformData->Window = CreateWindowEx(0, "ONI ", "ONI ", WS_POPUP, Rect.left, Rect.top, Rect.right - Rect.left, Rect.bottom - Rect.top, NULL, NULL, PlatformData->Instance, NULL);
+	ShowWindow(PlatformData->Window, SW_SHOWNORMAL);
+	UpdateWindow(PlatformData->Window);
+
+	ShowCursor(FALSE);
+
+	return 0;
+}
Index: Daodan/src/Daodan_Win32.h
===================================================================
--- Daodan/src/Daodan_Win32.h	(revision 322)
+++ Daodan/src/Daodan_Win32.h	(revision 323)
@@ -0,0 +1,10 @@
+#pragma once
+#ifndef DAODAN_WIN32_H
+#define DAODAN_WIN32_H
+
+#include "Daodan.h"
+#include "Oni.h"
+
+short ONICALL DDrPlatform_Initialize(ONtPlatformData *PlatformData);
+
+#endif
Index: Daodan/src/Oni.h
===================================================================
--- Daodan/src/Oni.h	(revision 322)
+++ Daodan/src/Oni.h	(revision 323)
@@ -11,4 +11,7 @@
 void __cdecl ONiMain(int ArgCount, char *ArgList[]);
 short ONICALL ONrPlatform_Initialize(ONtPlatformData *PlatformData);
+LRESULT CALLBACK ONrPlatform_WindowProc(HWND Window, UINT Message, WPARAM WParam, LPARAM LParam);
+
+extern HINSTANCE g_Instance;
 
 #endif
Index: Daodan/src/Oni_Symbols.S
===================================================================
--- Daodan/src/Oni_Symbols.S	(revision 322)
+++ Daodan/src/Oni_Symbols.S	(revision 323)
@@ -12,4 +12,8 @@
 // Oni Engine
 symbol ( _ONiMain                            , 0x000d3280 )
+symbol ( @ONrPlatform_Initialize@4           , 0x0010f670 )
+symbol ( _ONrPlatform_WindowProc@16          , 0x0010f7a0 )
+
+symbol ( _g_Instance                         , 0x0021f9e4 )
 
 // BFW_Utility
