Index: Daodan/BFW_Utility.h
===================================================================
--- Daodan/BFW_Utility.h	(revision 269)
+++ Daodan/BFW_Utility.h	(revision 269)
@@ -0,0 +1,11 @@
+#pragma once
+#ifndef BFW_UTILITY_H
+#define BFW_UTILITY_H
+
+#include <stdio.h>
+
+void __cdecl UUrStartupMessage(const char* fmt, ...);
+
+extern FILE* ONgFileStartup;
+
+#endif
Index: Daodan/Daodan.c
===================================================================
--- Daodan/Daodan.c	(revision 269)
+++ Daodan/Daodan.c	(revision 269)
@@ -0,0 +1,70 @@
+#include "Daodan.h"
+#include "Daodan_Patch.h"
+#include "Daodan_Utility.h"
+
+#include "BFW_Utility.h"
+
+HMODULE DDrDLLModule;
+HMODULE DDrONiModule;
+
+bool DDrPatch_Init()
+{
+	// Font texture cache doubled
+	DDrPatch_Byte ((void*)0x00400000 + 0x00020ea7, 0x20);
+	DDrPatch_Byte ((void*)0x00400000 + 0x00020f4a, 0x40);
+	
+	// Now supports textures up to 512x512
+	DDrPatch_Byte ((void*)0x00400000 + 0x00005251, 0x10);
+	
+	// Non-"_Final" levels are now valid
+	DDrPatch_Byte ((void*)0x00400000 + 0x000206a8, 0x01);
+	
+	// Pathfinding grid cache size x8
+	DDrPatch_Byte ((void*)0x00400000 + 0x0010b03b, 0x20);
+	DDrPatch_Byte ((void*)0x00400000 + 0x0010b04c, 0x20);
+	
+	// Projectile awareness fixed
+	DDrPatch_Byte ((void*)0x00400000 + 0x0009c07c, 0x6c);
+	DDrPatch_Byte ((void*)0x00400000 + 0x0009c080, 0x70);
+	DDrPatch_Byte ((void*)0x00400000 + 0x0009c084, 0x74);
+	DDrPatch_Byte ((void*)0x00400000 + 0x0009c110, 0x6c);
+	
+	// Forced DirectInput (for Windows NT)
+	DDrPatch_Byte ((void*)0x00400000 + 0x00002e6d, 0xeb);
+	
+	// Makes wp_fadetime actually have a function
+	const char fadetime_patch[] = { 0x66, 0x8B, 0x1D, 0xC4, 0x7D, 0x62, 0x00, 0x66, 0x89, 0x5E, 0x46, 0x5B, 0x5E, 0x83, 0xC4, 0x14, 0xC3 };
+	DDrPatch_Const((void*)0x00400000 + 0x0011a889, fadetime_patch);
+	DDrPatch_Byte ((void*)0x00400000 + 0x0011a560, 31);
+	
+	// Sets the fadetime to 4800 by default
+	DDrPatch_Int16((void*)0x00400000 + 0x0011ab0e, 0x12c0);
+	
+	// Hackish fix for Konoko not kicking guns
+	const char kickgun_patch[] = { 0x00, 0x05, 0x00, 0x00, 0x00, 0xC7, 0x05, 0x1C, 0xC9, 0x5E, 0x00, 0x70, 0xB8, 0x43, 0x00, 0xC7, 0x05, 0x20, 0xC9, 0x5E, 0x00, 0x20, 0xBE, 0x43 };
+	DDrPatch_Const((void*)0x00400000 + 0x000dc420, kickgun_patch);
+	
+	// Cooldown timer exploit fix ^_^
+	const char cooldown_patch[] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 };
+	DDrPatch_Const((void*)0x00400000 + 0x0011a825, cooldown_patch);
+	
+	const char throwtest_patch[] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 };
+	DDrPatch_Const((void*)0x00400000 + 0x000dc190, throwtest_patch);
+	
+	return true;
+}
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
+{
+	switch (fdwReason)
+	{
+		case DLL_PROCESS_ATTACH:
+			DDrDLLModule = hinstDLL;
+			DDrONiModule = GetModuleHandle(NULL);
+			
+			DDrPatch_MakeJump(UUrStartupMessage, DDrStartupMessage);
+			DDrPatch_Init();
+			break;
+	}
+	return TRUE;
+}
Index: Daodan/Daodan.h
===================================================================
--- Daodan/Daodan.h	(revision 269)
+++ Daodan/Daodan.h	(revision 269)
@@ -0,0 +1,11 @@
+#pragma once
+#ifndef DAODAN_H
+#define DAODAN_H
+
+#include <windows.h>
+#include <stdbool.h>
+
+extern HMODULE DDrDLLModule;
+extern HMODULE DDrONiModule;
+
+#endif
Index: Daodan/Daodan_DLLStubs.c
===================================================================
--- Daodan/Daodan_DLLStubs.c	(revision 269)
+++ Daodan/Daodan_DLLStubs.c	(revision 269)
@@ -0,0 +1,23 @@
+
+__declspec(dllexport) void VTPauseSampling() {return;}
+__declspec(dllexport) void VTResumeSampling() {return;}
+
+__declspec(dllexport) int __stdcall _BinkBufferClose(int arg1) {return 0;}
+__declspec(dllexport) int __stdcall _BinkNextFrame(int arg1) {return 0;}
+__declspec(dllexport) int __stdcall _BinkBufferLock(int arg1) {return 0;}
+__declspec(dllexport) int __stdcall _BinkDoFrame(int arg1) {return 0;}
+__declspec(dllexport) int __stdcall _BinkWait(int arg1) {return 0;}
+__declspec(dllexport) int __stdcall _BinkBufferUnlock(int arg1) {return 0;}
+__declspec(dllexport) int __stdcall _BinkCopyToBuffer(int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7) {return 0;}
+__declspec(dllexport) int __stdcall _BinkBufferSetOffset(int arg1, int arg2, int arg3) {return 0;}
+__declspec(dllexport) int __stdcall _BinkBufferOpen(int arg1, int arg2, int arg3, int arg4) {return 0;}
+__declspec(dllexport) int __stdcall _BinkClose(int arg1) {return 0;}
+__declspec(dllexport) int __stdcall _BinkSetVolume(int arg1, int arg2) {return 0;}
+__declspec(dllexport) int __stdcall _BinkSetSoundOnOff(int arg1, int arg2) {return 0;}
+__declspec(dllexport) int __stdcall _BinkOpen(int arg1, int arg2) {return 0;}
+__declspec(dllexport) int __stdcall _BinkSetSoundSystem(int arg1, int arg2) {return 0;}
+__declspec(dllexport) int __stdcall _BinkOpenDirectSound(int arg1) {return 0;}
+__declspec(dllexport) int __stdcall _BinkBufferBlit(int arg1, int arg2, int arg3) {return 0;}
+__declspec(dllexport) int __stdcall _BinkGetRects(int arg1, int arg2) {return 0;}
+__declspec(dllexport) int __stdcall _BinkService(int arg1) {return 0;}
+__declspec(dllexport) int __stdcall _BinkSetIOSize(int arg1) {return 0;}
Index: Daodan/Daodan_Patch.c
===================================================================
--- Daodan/Daodan_Patch.c	(revision 269)
+++ Daodan/Daodan_Patch.c	(revision 269)
@@ -0,0 +1,88 @@
+#include "Daodan_Patch.h"
+#include <windows.h>
+
+bool DDrPatch_MakeJump(void* from, void* to)
+{
+	DWORD oldp;
+	
+	if (VirtualProtect(from, 5, PAGE_EXECUTE_READWRITE, &oldp))
+	{
+		*(char*)from++ = 0xe9; // jmp rel32
+		*(int*)from = (unsigned int)to - (unsigned int)from - 4;
+		VirtualProtect(from, 5, oldp, &oldp);
+		return true;
+	}
+	else
+		return false;
+}
+
+bool DDrPatch_MakeCall(void* from, void* to)
+{
+	DWORD oldp;
+	
+	if (VirtualProtect(from, 5, PAGE_EXECUTE_READWRITE, &oldp))
+	{
+		*(char*)from++ = 0xe8; // call rel32
+		*(int*)from = (unsigned int)to - (unsigned int)from - 4;
+		VirtualProtect(from, 5, oldp, &oldp);
+		return true;
+	}
+	else
+		return false;
+}
+
+bool DDrPatch_String(char* dest, const char* string, int length)
+{
+	DWORD oldp;
+	
+	if (VirtualProtect(dest, length, PAGE_EXECUTE_READWRITE, &oldp))
+	{
+		memcpy(dest, string, length);
+		VirtualProtect(dest, length, oldp, &oldp);
+		return true;
+	}
+	else
+		return false;
+}
+
+bool DDrPatch_Byte(char* dest, char value)
+{
+	DWORD oldp;
+	
+	if (VirtualProtect(dest, 1, PAGE_EXECUTE_READWRITE, &oldp))
+	{
+		*dest = value;
+		VirtualProtect(dest, 1, oldp, &oldp);
+		return true;
+	}
+	else
+		return false;
+}
+
+bool DDrPatch_Int32(int* dest, int value)
+{
+	DWORD oldp;
+	
+	if (VirtualProtect(dest, 4, PAGE_EXECUTE_READWRITE, &oldp))
+	{
+		*dest = value;
+		VirtualProtect(dest, 4, oldp, &oldp);
+		return true;
+	}
+	else
+		return false;
+}
+
+bool DDrPatch_Int16(short* dest, short value)
+{
+	DWORD oldp;
+	
+	if (VirtualProtect(dest, 2, PAGE_EXECUTE_READWRITE, &oldp))
+	{
+		*dest = value;
+		VirtualProtect(dest, 2, oldp, &oldp);
+		return true;
+	}
+	else
+		return false;
+}
Index: Daodan/Daodan_Patch.h
===================================================================
--- Daodan/Daodan_Patch.h	(revision 269)
+++ Daodan/Daodan_Patch.h	(revision 269)
@@ -0,0 +1,16 @@
+#pragma once
+#ifndef DAODAN_PATCH_H
+#define DAODAN_PATCH_H
+
+#include <stdbool.h>
+
+#define DDrPatch_Const(d, c) DDrPatch_String(d, c, sizeof(c))
+
+bool DDrPatch_MakeJump(void* from, void* to);
+bool DDrPatch_MakeCall(void* from, void* to);
+bool DDrPatch_String(char* dest, const char* string, int length);
+bool DDrPatch_Byte(char* dest, char value);
+bool DDrPatch_Int32(int* dest, int value);
+bool DDrPatch_Int16(short* dest, short value);
+
+#endif
Index: Daodan/Daodan_Utility.c
===================================================================
--- Daodan/Daodan_Utility.c	(revision 269)
+++ Daodan/Daodan_Utility.c	(revision 269)
@@ -0,0 +1,26 @@
+#include <stdlib.h>
+#include <stdarg.h>
+#include "oni_stdio.h"
+
+#include "Daodan_Utility.h"
+#include "BFW_Utility.h"
+
+void __cdecl DDrStartupMessage(const char* fmt, ...)
+{
+	va_list ap;
+	va_start(ap, fmt);
+	char* buffer = malloc(vsnprintf(NULL, 0, fmt, ap) + 1);
+	
+	vsprintf(buffer, fmt, ap);
+	va_end(ap);
+
+	if (!ONgFileStartup)
+		if (!(ONgFileStartup = oni_fopen("startup.txt", "w")))
+			return;
+
+	oni_fprintf(ONgFileStartup, "%s\n", buffer);
+	free(buffer);
+	
+	oni_fflush(ONgFileStartup);
+	return;
+}
Index: Daodan/Daodan_Utility.h
===================================================================
--- Daodan/Daodan_Utility.h	(revision 269)
+++ Daodan/Daodan_Utility.h	(revision 269)
@@ -0,0 +1,7 @@
+#pragma once
+#ifndef DAODAN_UTILITY_H
+#define DAODAN_UTILITY_H
+
+void __cdecl DDrStartupMessage(const char* fmt, ...);
+
+#endif
Index: Daodan/Oni_PatchLocations.h
===================================================================
--- Daodan/Oni_PatchLocations.h	(revision 269)
+++ Daodan/Oni_PatchLocations.h	(revision 269)
@@ -0,0 +1,7 @@
+#pragma once
+#ifndef ONI_PATCHLOCATIONS_H
+#define ONI_PATCHLOCATIONS_H
+
+
+
+#endif
Index: Daodan/Oni_Symbols.S
===================================================================
--- Daodan/Oni_Symbols.S	(revision 269)
+++ Daodan/Oni_Symbols.S	(revision 269)
@@ -0,0 +1,56 @@
+#define symbol(name, value) .global name; .set name, 0x00400000 + value
+
+// Patch locations
+// Font texture cache doubled
+symbol ( Patch_FontCache1      , 0x00020ea7 )
+symbol ( Patch_FontCache2      , 0x00020f4a )
+
+// Now supports textures up to 512x512
+symbol ( Patch_TextureSize     , 0x00005251 )
+
+// Non-"_Final" levels are now valid
+symbol ( Patch_LevelPlugins    , 0x000206a8 )
+
+// Pathfinding grid cache size x8
+symbol ( Patch_PathFind1       , 0x0010b03b )
+symbol ( Patch_PathFind2       , 0x0010b04c )
+
+// Projectile awareness fixed
+symbol ( Patch_Projectile1     , 0x0009c07c )
+symbol ( Patch_Projectile2     , 0x0009c080 )
+symbol ( Patch_Projectile3     , 0x0009c084 )
+symbol ( Patch_Projectile4     , 0x0009c110 )
+
+// Forced DirectInput (for Windows NT)
+symbol ( Patch_DInput          , 0x00002e6d )
+
+// Makes wp_fadetime actually have a function
+symbol ( Patch_WP_Fadetime1    , 0x0011a889 )
+symbol ( Patch_WP_Fadetime2    , 0x0011a560 )
+
+// Weapon fadetime
+symbol ( Patch_Fadetime        , 0x0011ab0e )
+
+// Kicking guns fix
+symbol ( Patch_GunsKick        , 0x000DC420 )
+
+// Cooldown timer exploit fix ^_^
+symbol ( Patch_Cooldown        , 0x0011A825 )
+
+// Replaces the pointer door_drawframes with the pointer for the "Last Man Standing" cheat.
+symbol ( Patch_Door_DFramesPtr , 0x000D8AA0 )
+
+// Replaces the variable name "door_drawframes" with the variable name "chr_lms"
+symbol ( Patch_Door_DFramesStr , 0x0015058C )
+
+// Replaces the description "draws doorframes for all unplaced doors(1 null)" with "turns on Last Man Standing mode(9 nulls)" 
+symbol ( Patch_Door_DFramesDes , 0x00150564 )
+
+// MSVC6.0 stdlib
+symbol ( _oni_fopen            , 0x0011ea9f )
+symbol ( _oni_fprintf          , 0x0011ebbf )
+symbol ( _oni_fflush           , 0x0011eab2 )
+
+// BFW_Utility
+symbol ( _UUrStartupMessage    , 0x00024860 )
+symbol ( _ONgFileStartup       , 0x001711b8 )
Index: Daodan/build.bat
===================================================================
--- Daodan/build.bat	(revision 269)
+++ Daodan/build.bat	(revision 269)
@@ -0,0 +1,1 @@
+gcc -O3 -s -Wall -shared -o binkw32.dll Oni_Symbols.S Daodan.c Daodan_DLLStubs.c Daodan_Patch.c Daodan_Utility.c
Index: Daodan/oni_stdio.h
===================================================================
--- Daodan/oni_stdio.h	(revision 269)
+++ Daodan/oni_stdio.h	(revision 269)
@@ -0,0 +1,11 @@
+#pragma once
+#ifndef ONI_STDIO_H
+#define ONI_STDIO_H
+
+#include <stdio.h>
+
+FILE* __cdecl oni_fopen(const char*, const char*);
+int   __cdecl oni_fprintf(FILE*, const char*, ...);
+int   __cdecl oni_fflush(FILE*);
+
+#endif
