Index: Daodan/src/Daodan.c
===================================================================
--- Daodan/src/Daodan.c	(revision 993)
+++ Daodan/src/Daodan.c	(revision 994)
@@ -6,10 +6,11 @@
 #include "Daodan.h"
 #include "Daodan_Patch.h"
-#include "Daodan_Utility.h"
-#include "Daodan_Cheater.h"
-#include "Daodan_BSL.h"
-#include "Daodan_Console.h"
+#include "Patches/Utility.h"
+#include "Patches/Cheater.h"
+#include "Patches/BSL.h"
+#include "Patches/Console.h"
 #include "Daodan_Config.h"
-#include "patches/Patches.h"
+#include "Patches/Patches.h"
+#include "Patches/Localization.h"
 #include "bink-proxy.h"
 #include "_Version.h"
@@ -33,4 +34,5 @@
 	
 	DDrConfig(argc, argv);
+	DD_Localization();
 
 	if(GetKeyState(VK_SHIFT) & 0x8000) {
Index: Daodan/src/Daodan_BSL.c
===================================================================
--- Daodan/src/Daodan_BSL.c	(revision 993)
+++ 	(revision )
@@ -1,866 +1,0 @@
-#include <stdio.h>
-#include "stdint.h"
-#include <time.h>
-#include <math.h>
-#include "Inifile_Reader.h"
-#include "Daodan_BSL.h"
-#include "Daodan_Utility.h"
-#include "Daodan_Patch.h"
-#include "Daodan_Console.h"
-
-#include "Oni/Oni.h"
-
-#include "Daodan_Character.h"
-
-
-uint16_t ONICALL bsl_int32mul(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
-{
-	ret->val.value_int32 = args[0].val.value_int32 * args[1].val.value_int32;
-	ret->type = sl_int32;
-	return 0;
-}
-
-uint16_t ONICALL bsl_mul(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
-{
-	double val1;
-	double val2;
-	
-	if (args[0].type == sl_int32)
-		val1 = args[0].val.value_int32;
-	else
-		val1 = args[0].val.value_float;
-	
-	if (args[1].type == sl_int32)
-		val2 = args[1].val.value_int32;
-	else
-		val2 = args[1].val.value_float;
-	
-	ret->val.value_float = (float)(val1 * val2);
-	ret->type = sl_float;
-	return 0;
-}
-
-uint16_t ONICALL bsl_int32div(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
-{
-	ret->val.value_int32 = args[0].val.value_int32 / args[1].val.value_int32;
-	ret->type = sl_int32;
-	return 0;
-}
-uint16_t ONICALL bsl_div(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
-{
-	double val1;
-	double val2;
-	
-	if (args[0].type == sl_int32)
-		val1 = args[0].val.value_int32;
-	else
-		val1 = args[0].val.value_float;
-	
-	if (args[1].type == sl_int32)
-		val2 = args[1].val.value_int32;
-	else
-		val2 = args[1].val.value_float;
-	
-	ret->val.value_float = (float)(val1 / val2);
-	ret->type = sl_float;
-	return 0;
-}
-
-uint16_t ONICALL bsl_int32rand(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
-{
-	int32_t start = 0;
-	int32_t end = 0;
-	
-	if (args[0].val.value_int32 == args[1].val.value_int32)
-		return 1;
-	else if (args[0].val.value_int32 > args[1].val.value_int32)
-	{
-		start = args[1].val.value_int32;
-		end = args[0].val.value_int32;
-	}
-	else
-	{
-		start = args[0].val.value_int32;
-		end = args[1].val.value_int32;
-	}
-
-	ret->val.value_int32 = start + (rand() % (uint32_t)(end - start + 1));
-	ret->type = sl_int32;
-	return 0;
-}
-
-uint16_t ONICALL bsl_getkills(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
-{
-	int index;
-	if (numargs == 0) index = 0;
-	else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
-	else index = args[0].val.value_int32;
-	//killcount = ONgGameState->CharacterStorage[index].Kills;
-		//ONgGameState + index * 0x16A0 + 0x1260 + 0x1670;
-	ret->val.value_int32 = ONgGameState->CharacterStorage[index].Kills;
-	ret->type = sl_int32;
-	return 0;
-}
-
-uint16_t ONICALL bsl_getdamage(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
-{
-	int index;
-	if (numargs == 0) index = 0;
-	else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
-	else index = args[0].val.value_int32;
-	ret->val.value_int32 = ONgGameState->CharacterStorage[index].Damage;
-	ret->type = sl_int32;
-	return 0;
-}
-
-
-
-uint16_t ONICALL bsl_powerup(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
-{
-	int index;
-	void* returnval;
-	bool is_lsi = 0;
-	Character* Chr = ONgGameState->CharacterStorage;
-
-	if (numargs < 2 || args[1].type != sl_str32) return 1;
-	else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
-	else index = args[0].val.value_int32;
-
-	
-
-	if(!strcmp(args[1].val.value_str32,"ammo")) 
-	{
-		returnval = &(Chr[index].Inventory.AmmoUsed);
-	}
-	else if(!strcmp(args[1].val.value_str32,"hypo")) 
-	{
-		returnval = &(Chr[index].Inventory.HypoUsed);
-	}
-	else if(!strcmp(args[1].val.value_str32,"cells")) 
-	{
-		returnval = &(Chr[index].Inventory.CellsUsed);
-	}
-	else if(!strcmp(args[1].val.value_str32,"invis")) 
-	{
-		returnval = &(Chr[index].Inventory.CloakUsed);
-	}
-	else if(!strcmp(args[1].val.value_str32,"shield")) 
-	{
-		returnval = &(Chr[index].Inventory.ShieldUsed);
-	}
-	else if(!strcmp(args[1].val.value_str32,"lsi")) 
-	{
-		returnval = &(Chr[index].Inventory.hasLSI);
-		is_lsi = 1;
-	}
-//	else if(!strcmp(args[1].value_str32,"bossshield")) 
-//	{
-//		ret->value_int32 = Chr[index].Flags & char_bossshield;
-//		ret->type = sl_int32;
-//		if (numargs >=3) {
-//			if (Chr[index].Flags & char_bossshield) Chr[index].Flags = Chr[index].Flags & ~char_bossshield;
-//			else Chr[index].Flags = Chr[index].Flags | char_bossshield;
-//		}
-//		return 0;
-//	}
-	else return 1;
-	//todo, add setting
-	
-	if(is_lsi) ret->val.value_int32 = (int)*(bool*)returnval;
-	else	ret->val.value_int32 = *(int*)returnval;
-	ret->type = sl_int32;
-
-	if (numargs >= 3) 
-	{
-		if(is_lsi) *(bool*)returnval = args[2].val.value_int32;
-		else *(int*)returnval = args[2].val.value_int32;
-	}
-	
-	
-	return 0;
-}
-
-uint16_t ONICALL bsl_health(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
-{
-	int index;
-	Character* Chr;
-	int* health;
-	if (numargs == 0) index = 0;
-	else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
-	else index = args[0].val.value_int32;
-	Chr = ONgGameState->CharacterStorage;
-	health = &Chr[index].Health;
-
-	ret->val.value_int32 = *health;
-	ret->type = sl_int32;
-
-	if (args[1].val.value_int32) {
-		*health = args[1].val.value_int32;
-	}
-	ret->val.value_int32 = *health;
-	ret->type = sl_int32;
-	return 0;
-}
-
-uint16_t ONICALL bsl_regen(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
-{
-	int index;
-	Character* Chr;
-	if (numargs == 0) index = 0;
-	else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
-	else index = args[0].val.value_int32;
-	Chr = ONgGameState->CharacterStorage ;
-	
-	
-	/*
-	DDrConsole_PrintF("Character %s", Chr[index].Name);
-	DDrConsole_PrintF("Spawn %s", Chr[index].ScriptSpawn);
-	DDrConsole_PrintF("Death %s", Chr[index].ScriptDie);
-	DDrConsole_PrintF("Aware %s", Chr[index].ScriptAware);
-	DDrConsole_PrintF("Alarm %s", Chr[index].ScriptAlarm);
-	DDrConsole_PrintF("Hurt %s", Chr[index].ScriptHurt);
-	DDrConsole_PrintF("Defeat %s", Chr[index].ScriptDefeat);
-	DDrConsole_PrintF("NoAmmo %s", Chr[index].ScriptNoAmmo);
-	DDrConsole_PrintF("NoPath %s", Chr[index].ScriptNoPath);
-	*/
-	ret->val.value_int32 = Chr[index].RegenHax;
-	ret->type = sl_int32;
-
-	if (numargs >= 2) {
-		Chr[index].RegenHax = args[1].val.value_int32;
-	}
-	return 0;
-}
-
-//wow this is broken.
-uint16_t ONICALL bsl_distance(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) {
-	int index;
-	int index2;
-	Character* Chr = ONgGameState->CharacterStorage;
-	Character* Char1;
-	Character* Char2;
-
-	if (numargs < 2) return 1;
-
-	if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
-	else index = args[0].val.value_int32;
-	if (index == -1) index = args[0].val.value_int32;
-
-	if (args[1].type == sl_str32) index2 = DDrGetCharacterIndexFromName(args[1].val.value_str32);
-	else index2 = args[1].val.value_int32;
-	if (index2 == -1) index2 = args[1].val.value_int32;
-		Char1 = &Chr[index];
-	Char2 = &Chr[index2];
-
-
-	ret->val.value_float = sqrt( pow((Char1->Location.X - Char2->Location.X), 2) + pow((Char1->Location.Y - Char2->Location.Y), 2) + pow((Char1->Location.Z - Char2->Location.Z),2));
-	ret->type = sl_float;
-	return 0;
-}
-uint16_t ONICALL bsl_location(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) {
-	int index, i;
-	float* loc;
-	Character* Chr;
-		numargs = 0;
-	for(i = 0; args[i].type < sl_void; i++)
-	{
-		numargs++;
-	}
-
-
-	if (numargs < 2) return 1;
-	if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
-	else index = args[0].val.value_int32;
-	if (index == -1) index = args[0].val.value_int32;
-	Chr = ONgGameState->CharacterStorage;
-	if(numargs == 3)
-	{
-		if (!strcmp(args[1].val.value_str32,"X") || !strcmp(args[1].val.value_str32,"x"))
-			loc = &(Chr[index].Position.X);
-		else if (!strcmp(args[1].val.value_str32,"Y") || !strcmp(args[1].val.value_str32,"y"))
-			loc = &(Chr[index].Position.Y);
-		else if (!strcmp(args[1].val.value_str32,"Z") || !strcmp(args[1].val.value_str32,"z"))
-			loc = &(Chr[index].Position.Z);
-	}
-	else if (numargs == 4) {
-		ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]);
-		Chr[index].Location.X = args[1].val.value_float;
-		Chr[index].Location.Y = args[2].val.value_float;
-		Chr[index].Location.Z = args[3].val.value_float;
-		if(Active)
-		{
-			Active->PhyContext->Position = Chr[index].Location;
-		}
-		ret->val.value_float = 1;
-		ret->type = sl_float;
-		return 0;
-	}
-	else return 1;
-	
-	ret->val.value_float = *loc;
-	ret->type = sl_float;
-	
-	if(numargs == 3) {
-		//currently broken, does nothing.
-		*loc = args[2].val.value_float;
-	}
-	return 0;
-}
-
-uint16_t ONICALL bsl_maxhealth(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
-{
-	int index;
-	if (numargs == 0) index = 0;
-	else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
-	else index = args[0].val.value_int32;
-	if(1) {
-	Character* Chr = ONgGameState->CharacterStorage ;
-	int* maxhealth = &Chr[index].MaxHealth;
-	int oldmaxhealth = Chr[index].MaxHealth;
-	int oldhealth = Chr->Health;
-	if (numargs >= 2) {
-		*maxhealth = args[1].val.value_int32;
-	}
-	if (numargs >= 3 && args[2].val.value_bool) {
-		Chr->Health = (int)(((float)args[1].val.value_int32 / (float)oldmaxhealth) * (float)oldhealth);
-	}
-	ret->val.value_int32 = oldmaxhealth;
-	ret->type = sl_int32;
-	return 0;
-	}
-}
-
-uint16_t ONICALL bsl_getattacker(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
-{
-	//broken
-	
-	int index;
-	if (numargs == 0) index = 0;
-	else	if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
-	else index = args[0].val.value_int32;
-	if(1) {
-	Character* Chr = ONgGameState->CharacterStorage;
-	ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]);
-	if (!Active) return 1;
-//	ret->val.value_int32 = Active->LastDamageSourceCharacter;
-	ret->type = sl_int32;
-	return 0;
-	} 
-}
-
-
-
-uint16_t ONICALL bsl_chrname(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
-{
-	int index;
-	char* name;
-
-	if (numargs == 0) index = 0;
-	else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
-	else index = args[0].val.value_int32;
-	if (index == -1) {
-		ret->type = sl_str32;
-		ret->val.value_str32 = "NULL";
-		return 0;
-	}
-	name = (char*)(&ONgGameState->CharacterStorage[index].Name);
-	if (numargs == 2) {
-		strncpy(name, (char*)args[1].val.value_str32, 31);
-	}
-	
-	ret->type = sl_str32;
-	ret->val.value_str32 = name;
-	
-	return 0;
-}
-
-
-uint16_t ONICALL bsl_count(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
-{
-	//testing numargs...
-	ret->type = sl_int32;
-	ret->val.value_int32 = numargs;
-	return 0;
-}
-
-uint16_t ONICALL bsl_dprintcolored(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
-{
-	//TODO: figure out why our implementation of dprint shows after dev mode is turned off
-	RGBA color;
-	RGBA shade;
-	int i;
-	numargs = 0;
-	for(i = 0; args[i].type < sl_void; i++)
-	{
-		numargs++;
-	}
-	if(numargs == 0) return 0;
-	if(numargs > 1 ) color.R = (char)args[1].val.value_int32;
-	else color.R = 255;
-	if(numargs > 2 ) color.G = (char)args[2].val.value_int32;
-	else color.G = 255;
-	if(numargs > 3 ) color.B = (char)args[3].val.value_int32;
-	else color.B = 255;
-	color.A = 0;
-	if(numargs > 5 ) shade.R = (char)args[5].val.value_int32;
-	else shade.R = 0x3F;
-	if(numargs > 6 ) shade.G = (char)args[6].val.value_int32;
-	else shade.G = 0x3F;
-	if(numargs > 7 ) shade.B = (char)args[7].val.value_int32;
-	else shade.B = 0x3F;
-	shade.A = 0; 
-
-	DDrConsole_PrintColored(args[0].val.value_str32, 1, color, shade);
-	return 0;
-}
-
-
-uint16_t ONICALL bsl_nametoindex(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
-{
-
-	ret->type = sl_int32;
-	ret->val.value_int32 = DDrGetCharacterIndexFromName(args[0].val.value_str32);
-
-	return 0;
-}
-
-typedef struct {
-char Name[16];
-int Bit;
-} KeyBit;
-
-KeyBit Actions1[32] = {
-	{"Escape", Action_Escape},
-	{"Console", Action_Console},
-	{"PauseScreen", Action_PauseScreen},
-	{"Cutscene1", Action_Cutscene_1                },
-	{"Cutscene2", Action_Cutscene_2                },
-	{"F4", Action_F4                      },
-	{"F5", Action_F5                        },
-	{"F6", Action_F6                       },
-	{"F7", Action_F7                        },
-	{"F8", Action_F8                        },
-	{"StartRecord", Action_StartRecord        },       
-	{"StopRecord", Action_StopRecord            },    
-	{"PlayRecord", Action_PlayRecord              },  
-	{"F12", Action_F12                       },
-	{"Unknown1", Action_Unknown1               },  
-	{"LookMode", Action_LookMode           },
-	{"Screenshot", Action_Screenshot         },     
-	{"Unknown2", Action_Unknown2              },
-	{"Unknown3", Action_Unknown3              },   
-	{"Unknown4", Action_Unknown4                },
-	{"Unknown5", Action_Unknown5                },
-	{"Forward", Action_Forward                 },
-	{"Backward", Action_Backward                },
-	{"TurnLeft", Action_TurnLeft                },
-	{"TurnRight", Action_TurnRight               },
-	{"StepLeft", Action_StepLeft                },
-	{"StepRight", Action_StepRight               },
-	{"Jump", Action_Jump                    },
-	{"Crouch", Action_Crouch                  },
-	{"Punch",Action_Punch                   },
-	{"Kick", Action_Kick                    },
-	{"Block", Action_Block                   }
-};
-
-KeyBit Actions2[9] = {
-	{"Walk", Action2_Walk},
-	{"Action", Action2_Action},
-	{"Hypo", Action2_Hypo},
-	{"Reload", Action2_Reload                },
-	{"Swap", Action2_Swap                },
-	{"Drop", Action2_Drop                     },
-	{"Fire1", Action2_Fire1                       },
-	{"Fire2", Action2_Fire2                       },
-	{"Fire3", Action2_Fire3                       }
-};
-uint16_t ONICALL bsl_holdkey(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
-{
-	uint32_t index;
-	uint32_t i = 2;
-	uint32_t j = 0;
-	int Input1 = 0;
-	int Input2 = 0;
-	Character* Chr;
-	ActiveCharacter* Active;
-	if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
-	else index = args[0].val.value_int32;
-
-	Chr = &(ONgGameState->CharacterStorage[index]);
-	Active = ONrGetActiveCharacter(Chr);
-	if (!Active) return 1;
-
-	for(i = 1; i < numargs - 1; i++) {
-		for(j = 0; j < 32; j++) {
-			if(!strcmp(args[i].val.value_str32, Actions1[j].Name)) {
-				Input1 = Input1 | Actions1[j].Bit;
-			}
-		}
-		for(j = 0; j < 9; j++) {
-			if(!strcmp(args[i].val.value_str32, Actions2[j].Name)) { 
-				Input2 = Input2 | Actions2[j].Bit;
-			}
-		}
-	}
-	Active->Input.Current.Actions1 = Active->Input.Current.Actions1 | Input1;
-	Active->Input.Current.Actions2 = Active->Input.Current.Actions2 | Input2;
-	if( Input1 + Input2 == 0 ) {
-		DDrConsole_PrintF("Func \"%s\", File \"%s\", Line %d: semantic error, \"%s\": No valid keys given.", callinfo->name, callinfo->calllocation, callinfo->linenumber, callinfo->name);
-		return 0;
-	}
-	if (  args[numargs - 1].val.value_int32 <= 0) {
-		return 0;
-	}
-	else {
-		 args[numargs - 1].val.value_int32 -= 1;
-		*dontuse2 = 1;
-		*dontuse1 = 1;
-	}
-	return 0;
-}
-	
-uint16_t ONICALL bsl_isheld(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
-	{
-//		int index;
-//		if (numargs < 4) index = 0;
-//		else	if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
-//		else index = args[0].val.value_int32;
-
-//		Character* Chr = ONgGameState->CharacterStorage;
-//	ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]);
-//	if ((int)Active == 0) return 1;
-	uint32_t i = 2;
-	uint32_t j = 0;
-	int Input1 = 0;
-	int Input2 = 0;
-	for(i = 0; i < numargs; i++) {
-		for(j = 0; j < 32; j++) {
-			//DDrConsole_PrintF("Testing %s against %s 0x%x", args[i].val.value_str32, Actions1[j].Name, Actions1[j].Bit);
-			if(!strcmp(args[i].val.value_str32, Actions1[j].Name)) {
-				Input1 = Input1 | Actions1[j].Bit;
-				//DDrConsole_PrintF("Success!");
-			}
-			
-		}
-		for(j = 0; j < 9; j++) {
-			if(!strcmp(args[i].val.value_str32, Actions2[j].Name)) Input2 = Input2 | Actions2[j].Bit;
-	
-		}
-		}
-	//DDrConsole_PrintF("Testing: 0x%x Input: 0x%x",Input1, *(int*)(ONgGameState + 0xB8 + 0x10));
-	ret->val.value_int32 = 0;
-	ret->type = sl_int32;
-	if ( (ONgGameState->Input.Current.Actions1 == Input1)  && (ONgGameState->Input.Current.Actions2 == Input2)) ret->val.value_int32 = 1;
-	return 0;
-}
-
-uint16_t ONICALL bsl_waitforkey(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
-	{
-//		int index;
-//		if (numargs < 4) index = 0;
-//		else	if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
-//		else index = args[0].val.value_int32;
-
-//		Character* Chr = ONgGameState->CharacterStorage;
-//	ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]);
-//	if ((int)Active == 0) return 1;
-
-	int i = 2;
-	int j = 0;
-	int Input1 = 0;
-	int Input2 = 0;
-/*
-	numargs = 0;
-	for(i = 0; args[i].type <= sl_void; i++)
-	{
-		//DDrConsole_PrintF("%i", args[i].type );
-		numargs++;
-
-	}
-	if(numargs < 1 || args[0].val.value == 0)  return;
-	//for(i = 0; i < numargs; i++) {
-	*/
-	i = 0;
-		for(j = 0; j < 32; j++) {
-			//DDrConsole_PrintF("Testing %s against %s 0x%x", args[i].val.value_str32, Actions1[j].Name, Actions1[j].Bit);
-			if(!strcmp(args[i].val.value_str32, Actions1[j].Name)) {
-				Input1 = Input1 | Actions1[j].Bit;
-				//DDrConsole_PrintF("Success!");
-			}
-			
-		}
-		for(j = 0; j < 9; j++) {
-			if(!strcmp(args[i].val.value_str32, Actions2[j].Name)) Input2 = Input2 | Actions2[j].Bit;
-	
-		}
-	//	}
-	DDrConsole_PrintF("Waiting...");
-	if ( 
-		(( ONgGameState->Input.Current.Actions1 & Input1) == Input1)  && 
-		(( ONgGameState->Input.Current.Actions2 & Input2) == Input2) 
-	)
-	{
-	DDrConsole_PrintF("Found key!");
-	}
-	else {
-	//else (int)*ret = 1;
-	*dontuse2 = 1;
-	*dontuse1 = 1;
-	}
-	return 0;
-}
-
-
-uint16_t ONICALL bsl_sprintf(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
-{
-	char output[1024];
-	char buffer[1024];
-	unsigned int i;
-	char* placeinoutput = output;
-	char* placeininput = args[0].val.value_str32;
-	int formatnum = 0;
-	//fix the broken bsl numargs...
-	numargs = 0;
-	
-	for(i = 0; args[i].type < sl_void; i++)
-	{
-		numargs++;
-	}
-	
-	
-	if (numargs < 1)
-		return 1;
-	
-	while(1)
-	{
-		int size;
-		//s is the pointer to the args
-		char* s = strchr(placeininput , '%');
-		//we didnt find a %, break!
-		if(!s)
-		{
-			strcpy(placeinoutput, placeininput);
-			break;
-		}
-		size = (int)s - (int)placeininput ;
-		//we found one, so copy the portion of string
-		
-
-		
-		memcpy( placeinoutput,placeininput, size);
-		placeininput += size;
-		placeinoutput += size;
-
-		memset( placeinoutput, '%', (int)pow(2, formatnum));
-		placeinoutput += (int)pow(2, formatnum);
-
-
-		placeininput += 1;
-		*placeinoutput = 0;
-		formatnum++;
-		
-	}
-
-	for(i = 1; i < numargs; i++)	{
-		//sprintf(output, output, args[i].value_str32);
-		memcpy(buffer, output, 1024);
-		if(args[i].val.value == 0) break;
-		switch(args[i].type)
-		{
-		case sl_bool:
-		case sl_int32:
-			sprintf(output, buffer, args[i].val.value_int32);
-			break;
-		case sl_float:
-			sprintf(output, buffer, args[i].val.value_float);
-			break;
-		case sl_str32:
-			sprintf(output, buffer, args[i].val.value_str32);
-			break;
-		case sl_void:
-		default:
-			break;
-		}	
-	}
-	ret->val.value_str32 = output;
-	ret->type = sl_str32;
-	return 0;
-}
-
-// Widescreen patch for talking heads.
-uint16_t ONICALL cinematic_start_patch(sl_callinfo* callinfo, unsigned int numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
-{
-	args[1].val.value_int32 = (double)args[1].val.value_int32 / (double)(gl->DisplayMode.Width) * (4.0 / 3.0 * (double)(gl->DisplayMode.Height));
-	return ((sl_func)(OniExe + 0x000f3830))(callinfo, numargs, args, dontuse1, dontuse2, ret);
-}
-
-/*
-bool ini_inbsl = false;
-bool SLrIniCallback(char* section, bool newsection, char* name, char* value)
-{
-	if (newsection)
-		ini_inbsl = !_stricmp(section, "bsl");
-	
-	if (ini_inbsl)
-	{
-		char* type = value;
-		bool isptr = false;
-		sl_type bsl_type;
-		
-		if (value[0] == 'p' && value[1] == 't' && value[2] == 'r' && value[3] == ':')
-		{
-			isptr = true;
-			value += 4;
-		}
-		
-		
-		
-		for (; *type; type++)
-			if (*type == ':')
-			{
-				*type = '\0';
-				type++;
-				break;
-			}
-		
-		if (!*type)
-			STARTUPMESSAGE("Badly formed bsl definition for \"%s\"", name);
-		
-		if (!strcmp(type, "int"))
-			bsl_type = sl_int32;
-		else if (!strcmp(type, "string"))
-			bsl_type = sl_str32;
-		else if (!strcmp(type, "float"))
-			bsl_type = sl_float;
-		else if (!strcmp(type, "bool"))
-			bsl_type = sl_bool;
-		else
-		{
-			STARTUPMESSAGE("Unknown type in bsl definition for \"%s\"", name);
-			return true;
-		}
-		
-		if (isptr)
-		{
-			char* bsl_var = malloc(strlen(name) + 1);
-			memcpy(bsl_var, name, strlen(name) + 1);
-			switch (bsl_type)
-			{
-				case sl_int32:
-					SLrGlobalVariable_Register_Int32(bsl_var, "see daodan.ini", (int32_t*)(uint32_t)inifile_parseint(value, false));
-					break;
-				case sl_float:
-					SLrGlobalVariable_Register_Float(bsl_var, "see daodan.ini", (float*)(uint32_t)inifile_parseint(value, false));
-					break;
-				default:
-					break;
-			}
-		}
-		else
-		{
-			char* bsl_var = malloc(strlen(name) + 1 + sizeof(int32_t));
-			int32_t* bsl_val = (int32_t*)bsl_var;
-			bsl_var += sizeof(int32_t);
-			memcpy(bsl_var, name, strlen(name) + 1);
-			
-			switch (bsl_type)
-			{
-				case sl_int32:
-					*bsl_val = inifile_parseint(value, false);
-					SLrGlobalVariable_Register_Int32(bsl_var, "see daodan.ini", bsl_val);
-					break;
-				case sl_float:
-					break;
-				default:
-					break;
-			}
-		}
-	}
-	return true;
-}
-
-void SLrConfig()
-{
-	STARTUPMESSAGE("Re-parsing daodan.ini for bsl...", 0);
-	inifile_read("daodan.ini", SLrIniCallback);
-	STARTUPMESSAGE("Finished parsing", 0);
-}
-*/
-
-void ONICALL SLrDaodan_Register_ReturnType(char* name, char* desc, char* argfmt, sl_type type, sl_func callback) {
-	char argfmt2[512];
-	uint16_t errornum;
-	if (argfmt && strlen(argfmt) < 507) {
-		sprintf(argfmt2, "%s [|]", argfmt);
-		errornum = SLrScript_Command_Register_ReturnType(name, desc, argfmt2, type, callback);
-		if(errornum)
-		{
-			STARTUPMESSAGE("Registration of script command %s failed with error %i", name, errornum);
-		}
-	} else {
-		STARTUPMESSAGE("Registration of script command %s failed because of a too long argfmt", name);
-	}
-}
-
-void* TSrTest = 0;
-uint16_t ONICALL new_text(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
-{
-	void* TSFFTahoma;
-	int returnval;
-
-	if(!TSrTest){
-		TMrInstance_GetDataPtr( 'TSFF', "Tahoma", &TSFFTahoma);
-		returnval = TSrContext_New( TSFFTahoma, 7, 1, 1,  0, &TSrTest);
-	}
-	DDrPatch_MakeCall((void*)0x004FBCEA, (void*)DDrText_Hook);
-	
-	*dontuse2 = 1;
-	return 0;
-}
-
-void SLrDaodan_Initialize()
-{
-// 	SLrConfig();
-
-	SLrScript_Command_Register_Void("debug_daodan","Adds text to screen", "", new_text);
-
-	SLrScript_Command_Register_ReturnType("int32mul", "Multiplies two numbers", "n1:int n2:int", sl_int32, bsl_int32mul);
-	SLrScript_Command_Register_ReturnType("mul", "Multiplies two numbers", "[int1:int|float1:float] [int2:int|float2:float]", sl_float, bsl_mul);
-	SLrScript_Command_Register_ReturnType("int32div", "Divides two numbers", "n1:int n2:int", sl_int32, bsl_int32div);
-	SLrScript_Command_Register_ReturnType("div", "Divides two numbers", "[int1:int|float1:float] [int2:int|float2:float]", sl_float, bsl_div);
-	srand((uint32_t)time(NULL));
-	SLrScript_Command_Register_ReturnType("int32rand", "Returns a pseudo-random number between two numbers (inclusive).", "start:int end:int", sl_int32, bsl_int32rand);
-	SLrScript_Command_Register_ReturnType("d_getkills","Gets the number of kills a character has", "[ai_name:string | script_id:int] [|]", sl_int32, bsl_getkills);
-	SLrScript_Command_Register_ReturnType("d_getdamage","Gets the amount of damage a character has caused", "[ai_name:string | script_id:int]", sl_int32, bsl_getdamage);
-	SLrScript_Command_Register_ReturnType("d_name","Gets or sets a character's name", "[ai_name:string | script_id:int] [newname:string|]", sl_str32, bsl_chrname);
-	SLrScript_Command_Register_ReturnType("d_getindex","Converts a character's name to its index", "ai_name:string", sl_int32, bsl_nametoindex);
-	SLrScript_Command_Register_ReturnType("d_health","Gets or sets a character's health", "[ai_name:string | script_id:int] [newhealth:int]", sl_str32, bsl_health);
-	SLrScript_Command_Register_ReturnType("d_regen","Gets or sets a character's regeneration abilities", "[ai_name:string | script_id:int] [newhealth:int]", sl_str32, bsl_regen);
-	SLrScript_Command_Register_ReturnType("d_maxhealth","Gets or sets a character's maximum health", "[ai_name:string | script_id:int] [newmaxhealth:int] [scalehealth:bool]", sl_str32, bsl_maxhealth);
-	SLrScript_Command_Register_ReturnType("d_powerup","Gets or sets a character's powerups", "[ai_name:string | script_id:int] powerup:string", sl_int32, bsl_powerup);
-	//d_holdkey is broken!
-	SLrScript_Command_Register_ReturnType("d_holdkey","Makes a character hold a key", "[ai_name:string | script_id:int] frames:int keys:string", sl_int32, bsl_holdkey);
-	SLrScript_Command_Register_ReturnType("d_isheld","Checks if player is holding a key", "[ai_name:string | script_id:int] [keys:string]", sl_int32, bsl_isheld);
-	SLrScript_Command_Register_ReturnType("d_location","Returns the X, Y or Z coord of a character", "", sl_float, bsl_location);
-	SLrScript_Command_Register_ReturnType("d_distance","Returns the distance between two characters", "ai_name:string | script_id:int ai_name:string | script_id:int", sl_float, bsl_distance);
-	SLrScript_Command_Register_Void("d_waitforkey","Waits for a keypress from the player", "key:string", bsl_waitforkey);
-
-	//broken, only works for one damage type.
-	//SLrDaodan_Register_ReturnType("d_getattacker","Gets the last person to hurt a character", "[ai_name:string | script_id:int]", sl_int32, bsl_getattacker);
-	
-	//used for debugging.
-//	SLrDaodan_Register_ReturnType("d_active","Returns a hex offset. ;)", "[ai_name:string | script_id:int]", sl_int32, bsl_getactiveoffset);
-
-	SLrScript_Command_Register_Void("sprintf", "C-style sprintf.", "", bsl_sprintf);
-	SLrScript_Command_Register_ReturnType("st", "Prints to console in color", "", sl_void, bsl_dprintcolored);
-	SLrScript_Command_Register_ReturnType("d_dprint", "Prints to console in color", "", sl_void, bsl_dprintcolored);
-
-	SLrGlobalVariable_Register_Int32("show_triggervolumes", "Show trigger volumes", &OBJgTriggerVolume_Visible);
-}
-
-// Patch for cinematic_start to work on widescreen resolutions
-void SLrDaodan_Patch()
-{
-	DDrPatch_Int32((int*)(OniExe + 0x000f3755), (int)cinematic_start_patch);
-}
Index: Daodan/src/Daodan_BSL.h
===================================================================
--- Daodan/src/Daodan_BSL.h	(revision 993)
+++ 	(revision )
@@ -1,7 +1,0 @@
-#ifndef DAODAN_BSL_H
-#define DAODAN_BSL_H
-
-void SLrDaodan_Initialize();
-void SLrDaodan_Patch();
-
-#endif
Index: Daodan/src/Daodan_Character.c
===================================================================
--- Daodan/src/Daodan_Character.c	(revision 993)
+++ 	(revision )
@@ -1,31 +1,0 @@
-#include <stdlib.h>
-#include "Daodan_Character.h"
-
-#include "Oni/Oni.h"
-
-int DDr_TeamToTeamID(const char* team_string) //Already something like this in the engine, but I'm reimplementing it...
-{
-	if (!strcmp(team_string, "Konoko"))                  return team_konoko;
-	else if (!strcmp(team_string, "TCTF"))               return team_tctf;
-	else if (!strcmp(team_string, "Syndicate"))          return team_syndicate;
-	else if (!strcmp(team_string, "Neutral"))            return team_neutral;
-	else if (!strcmp(team_string, "SecurityGuard"))      return team_securityguard;
-	else if (!strcmp(team_string, "RogueKonoko"))        return team_roguekonoko;
-	else if (!strcmp(team_string, "Switzerland"))        return team_switzerland;
-	else if (!strcmp(team_string, "SyndicateAccessory")) return team_syndicateaccessory;
-	return team_neutral; //if you enter a bad teamname, return Neutral.....
-}
-
-uint32_t DDrGetCharacterIndexFromName(char* input) {
-	int i;
-	Character **characterlist = ONgGameState->PresentCharacterList;								//pointer to array of Character pointers
-	int total_characters = ONgGameState->PresentCharacterListCount;		//Max number of characters
-	for(i = 0; i < total_characters; i++) {
-		if (characterlist[i] != 0)							//anti Blam!
-			if (!strcmp(characterlist[i]->Name, input)) {	//checks for the same name
-			return characterlist[i]->Number;
-			}
-	}
-	return -1;													//not found :(
-}
-
Index: Daodan/src/Daodan_Character.h
===================================================================
--- Daodan/src/Daodan_Character.h	(revision 993)
+++ 	(revision )
@@ -1,9 +1,0 @@
-#ifndef DAODAN_CHARACTER_H
-#define DAODAN_CHARACTER_H
-
-#include "stdint.h"
-
-int DDr_TeamToTeamID(const char* team_string);
-uint32_t DDrGetCharacterIndexFromName(char* );
-
-#endif
Index: Daodan/src/Daodan_Cheater.c
===================================================================
--- Daodan/src/Daodan_Cheater.c	(revision 993)
+++ 	(revision )
@@ -1,296 +1,0 @@
-#include <string.h>
-#include "stdint.h"
-#include <math.h>
-
-#include "Oni/Oni.h"
-
-#include "_Version.h"
-
-#include "Daodan.h"
-#include "Daodan_Config.h"
-#include "Daodan_Cheater.h"
-
-union MSVC_EVIL_FLOAT_HACK
-{
-   unsigned __int8 Bytes[4];
-   float Value;
-};
-static union MSVC_EVIL_FLOAT_HACK INFINITY_HACK = {{0x00, 0x00, 0x80, 0x7F}};
-#define DD_INFINITY (INFINITY_HACK.Value)
-
-oniCheatCode DDr_CheatTable[] = {
-	{ "shapeshifter",     "Change Characters Enabled",       "Change Characters Disabled", cheat_shapeshifter     },
-	{ "liveforever",      "Invincibility Enabled",           "Invincibility Disabled",     cheat_liveforever      },
-	{ "touchofdeath",     "Omnipotence Enabled",             "Omnipotence Disabled",       cheat_touchofdeath     },
-	{ "canttouchthis",    "Unstoppable Enabled",             "Unstoppable Disabled",       cheat_canttouchthis    },
-	{ "fatloot",          "Fat Loot Received",               NULL,                         cheat_fatloot          },
-	{ "glassworld",       "Glass Furniture Enabled",         "Glass Furniture Disabled",   cheat_glassworld       },
-	{ "winlevel",         "Instantly Win Level",             NULL,                         cheat_winlevel         },
-	{ "loselevel",        "Instantly Lose Level",            NULL,                         cheat_loselevel        },
-	{ "bighead",          "Big Head Enabled",                "Big Head Disabled",          cheat_bighead          },
-	{ "minime",           "Mini Mode Enabled",               "Mini Mode Disabled",         cheat_minime           },
-	{ "superammo",        "Super Ammo Mode Enabled",         "Super Ammo Mode Disabled",   cheat_superammo        },
-	{ "thedayismine",     "Developer Access Enabled",        "Developer Access Disabled",  cheat_thedayismine     },
-	{ "reservoirdogs",    "Last Man Standing Enabled",       "Last Man Standing Disabled", cheat_reservoirdogs    },
-	{ "roughjustice",     "Gatling Guns Enabled",            "Gatling Guns Disabled",      cheat_roughjustice     },
-	{ "chenille",         "Daodan Power Enabled",            "Daodan Power Disabled",      cheat_chenille         },
-	{ "behemoth",         "Godzilla Mode Enabled",           "Godzilla Mode Disabled",     cheat_behemoth         },
-	{ "elderrune",        "Regeneration Enabled",            "Regeneration Disabled",      cheat_elderrune        },
-	{ "moonshadow",       "Phase Cloak Enabled",             "Phase Cloak Disabled",       cheat_moonshadow       },
-	{ "munitionfrenzy",   "Weapons Locker Created",          NULL,                         cheat_munitionfrenzy   },
-	{ "fistsoflegend",    "Fists Of Legend Enabled",         "Fists Of Legend Disabled",   cheat_fistsoflegend    },
-	{ "killmequick",      "Ultra Mode Enabled",              "Ultra Mode Disabled",        cheat_killmequick      },
-	{ "carousel",         "Slow Motion Enabled",             "Slow Motion Disabled",       cheat_carousel         },
-	{ "bigbadboss",       "Boss Shield Enabled",             "Boss Shield Disabled",       cheat_bigbadboss       },
-	{ "bulletproof",      "Force Field Enabled",             "Force Field Disabled",       cheat_bulletproof      },
-	{ "kangaroo",         "Kangaroo Jump Enabled",	         "Kangaroo Jump Disabled",     cheat_kangaroo         },
-	{ "marypoppins",      "Jet Pack Mode Enabled",           "Jet Pack Mode Disabled",     cheat_marypoppins      },
-	{ "buddha",           "Unkillable Enabled",              "Unkillable Disabled",        cheat_buddha           },
-	{ "shinobi",          "Ninja Mode Enabled (good luck!)", "Ninja Mode Disabled",        cheat_shinobi          },
-	{ "x",                "Developer Access Enabled",        "Developer Access Disabled",  cheat_x                },
-	{ "testcheat",        "Testing...",                      "",                           cheat_testcheat        },
-	{ "tellmetheversion", "Daodan v."DAODAN_VERSION_STRING"",                    "",                           cheat_tellmetheversion },
-	{0, 0, 0, 0}
-};
-
-
-
-// Just copied all these defines from the old daodan, they were originaly from SFeLi's code.
-
-#define GSA_camera        (0x00000080)
-#define GSA_player        (0x000000AC)
-#define GSA_carousel      (0x00000104) /* char */
-#define GSA_slowmotimer   (0x00000108)
-#define GSA_splashscreen  (0x00000118) /* char */
-
-#define CHR_flags         (0x00000004)
-#define CHR_flags2        (0x00000008)
-#define CHR_oncc          (0x0000000C)
-#define CHR_team          (0x00000012) /* short */
-#define CHR_name          (0x00000014) /* char[32] */
-#define CHR_scalemodel    (0x00000034)
-#define CHR_weapon1       (0x00000194)
-#define CHR_weapon2       (0x00000198)
-#define CHR_weapon3       (0x0000019C)
-#define CHR_shield_curr   (0x000001B6) /* short */
-#define CHR_shield        (0x000001B8) /* short */
-#define CHR_phasecloak    (0x000001BA) /* short */
-#define CHR_stats_kills   (0x00001670)
-#define CHR_stats_damage  (0x00001674)
-
-#define ONCC_jet_accel    (0x00000010) /* float */
-#define ONCC_jet_timer    (0x00000016) /* short */
-#define ONCC_height1      (0x00000018) /* float */
-#define ONCC_height2      (0x0000001C) /* float */
-#define ONCC_bodysize_min (0x00000C58) /* float */
-#define ONCC_bodysize_max (0x00000C8C) /* float */
-
-#define kangaroo_h     (short)(60)
-#define kangaroo_jp    (float)(0.06)
-#define marypoppins_jp (float)(0.14)
-
-uint16_t cheat_oldshield = 0;
-int32_t cheat_oldhealth = 1;
-int32_t cheat_oldmaxhealth = 1;
-float cheat_oldjet_accel = 0.03f;
-uint16_t cheat_oldjet_timer = 20;
-float cheat_oldheight1 = 45;
-float cheat_oldheight2 = 135;
-bool inc_fallingframes = true;
-
-uint8_t ONICALL DDrCheater(uint32_t cheat)
-{
-	switch (cheat)
-	{
-		case cheat_bigbadboss:
-		{
-			Character* player = ONgGameState->PlayerCharacter;
-			//char* player = *((char**)(ONgGameState + GSA_player));
-			if (player->Flags & chr_bossshield)
-			{
-				player->Flags = player->Flags & ~chr_bossshield;
-				return 0;
-			}
-			else
-			{
-				player->Flags = player->Flags | chr_bossshield;
-				return 1;
-			}
-		}
-		case cheat_bulletproof:
-		{
-			Character* player = ONgGameState->PlayerCharacter;
-			if (player->Flags  & chr_weaponimmune)
-			{
-				player->Flags  = player->Flags  & ~chr_weaponimmune;
-				player->Inventory.ShieldUsed  = cheat_oldshield;
-				return 0;
-			}
-			else
-			{
-				player->Flags  |=  chr_weaponimmune;
-				cheat_oldshield = player->Inventory.ShieldUsed;
-				player->Inventory.ShieldUsed = 100;
-				return 1;
-			}
-		}
-		case cheat_kangaroo:
-		{
-			Character* player = ONgGameState->PlayerCharacter;
-			//char* oncc = *(char**)(player + CHR_oncc);
-			if (!inc_fallingframes)
-				inc_fallingframes = true;
-			if (player->ONCC->JetpackTimer == kangaroo_h)
-			{
-				player->ONCC->JumpAcceleration = cheat_oldjet_accel;
-				player->ONCC->JetpackTimer  = cheat_oldjet_timer;
-				player->ONCC->MaxFallingHeightWithoutDamage = cheat_oldheight1;
-				player->ONCC->MaxFallingHeightWithDamage = cheat_oldheight2;
-				return 0;
-			}
-			else if ((unsigned short)player->ONCC->JetpackTimer == 0xFFFF)
-			{
-				player->ONCC->JumpAcceleration = kangaroo_jp;
-				player->ONCC->JetpackTimer  = kangaroo_h;
-				player->ONCC->MaxFallingHeightWithoutDamage = DD_INFINITY;
-				player->ONCC->MaxFallingHeightWithDamage  = DD_INFINITY;
-				return 1;
-			}
-			else
-			{
-				cheat_oldjet_accel = player->ONCC->JumpAcceleration;
-				cheat_oldjet_timer = player->ONCC->JetpackTimer;
-				cheat_oldheight1 = player->ONCC->MaxFallingHeightWithoutDamage ;
-				cheat_oldheight2 = player->ONCC->MaxFallingHeightWithDamage;
-				player->ONCC->JumpAcceleration = kangaroo_jp;
-				player->ONCC->JetpackTimer = kangaroo_h;
-				player->ONCC->MaxFallingHeightWithoutDamage  = DD_INFINITY;
-				player->ONCC->MaxFallingHeightWithDamage  = DD_INFINITY;
-				return 1;
-			}
-		}
-		case cheat_marypoppins:
-		{
-			Character* player = ONgGameState->PlayerCharacter;
-			if (!inc_fallingframes)
-			{
-				inc_fallingframes = true;
-				if ((unsigned short)player->ONCC->JetpackTimer == 0xFFFF)
-				{
-					player->ONCC->JumpAcceleration = cheat_oldjet_accel;
-					player->ONCC->JetpackTimer = cheat_oldjet_timer;
-					player->ONCC->MaxFallingHeightWithoutDamage = cheat_oldheight1;
-					player->ONCC->MaxFallingHeightWithDamage = cheat_oldheight2;
-				}
-				return 0;
-			}
-			else if (player->ONCC->JetpackTimer == kangaroo_h)
-			{
-				player->ONCC->JumpAcceleration = marypoppins_jp;
-				player->ONCC->JetpackTimer = 0xFFFF;
-				player->ONCC->MaxFallingHeightWithoutDamage = 0x7f800000;
-				player->ONCC->MaxFallingHeightWithDamage = 0x7f800000;
-				inc_fallingframes = false;
-				return 1;
-			}
-			else
-			{
-				cheat_oldjet_accel = player->ONCC->JumpAcceleration;
-				cheat_oldjet_timer = player->ONCC->JetpackTimer;
-				cheat_oldheight1 = player->ONCC->MaxFallingHeightWithoutDamage;
-				cheat_oldheight2 = player->ONCC->MaxFallingHeightWithDamage ;
-				player->ONCC->JumpAcceleration = marypoppins_jp;
-				player->ONCC->JetpackTimer = 0xFFFF;
-				player->ONCC->MaxFallingHeightWithoutDamage = 0x7f800000;
-				player->ONCC->MaxFallingHeightWithDamage = 0x7f800000;
-				inc_fallingframes = false;
-				return 1;
-			}
-		}
-		case cheat_buddha:
-		{
-			Character* player = ONgGameState->PlayerCharacter;
-			if (player->Flags& chr_unkillable)
-			{
-				player->Flags= player->Flags& ~chr_unkillable;
-				return 0;
-			}
-			else
-			{
-				player->Flags= player->Flags| chr_unkillable;
-				return 1;
-			}
-		}
-		case cheat_shinobi:
-		{
-			Character* player = ONgGameState->PlayerCharacter;
-			if (player->MaxHealth == 1)
-			{
-				player->Health = cheat_oldhealth;
-				player->MaxHealth = cheat_oldmaxhealth;
-				player->Flags = player->Flags & ~(chr_bossshield | chr_weaponimmune);
-				ai2_deaf = 0;
-				return 0;
-			}
-			else
-			{
-				cheat_oldhealth = player->Health;
-				cheat_oldmaxhealth = player->MaxHealth;
-				player->Health = 1;
-				player->MaxHealth = 1;
-				player->Flags = player->Flags | chr_bossshield | chr_weaponimmune;
-				ai2_deaf = 1;
-				return 1;
-			}
-			
-		}
-		case cheat_testcheat:
-		{
-			Character* player = ONgGameState->PlayerCharacter;
-			player->Flags = player->Flags | chr_noncombatant;
-			return 1;
-		}
-		case cheat_elderrune:
-		{
-			ConfigOption_t* co = DDrConfig_GetOptOfType("patch.bsl", C_BOOL);
-			if (co->value.intBoolVal)
-			{
-				int* Regeneration = &ONgGameState->PlayerCharacter->RegenHax;
-				if(*Regeneration)
-				{
-					*Regeneration = 0;
-					return 0;
-				}
-				else
-				{
-					*Regeneration = 1;
-					return 1;
-				}
-			}
-			else
-			{
-				return ONrCheater(cheat_elderrune);
-			}
-		}
-
-		case cheat_tellmetheversion:
-			return 1;
-		case cheat_x:
-			return ONrCheater(cheat_thedayismine);
-		default:
-			return ONrCheater(cheat);
-	}
-}
-
-void ONICALL DDrCheater_LevelLoad()
-{
-	inc_fallingframes = true;
-}
-
-// Biggest hack in the entire thing ^_^
-void __stdcall FallingFrames(void* Ebp)
-{
-	if (inc_fallingframes)
-		++*((unsigned int*)((char*)Ebp + 0xf6));
-}
- 
Index: Daodan/src/Daodan_Cheater.h
===================================================================
--- Daodan/src/Daodan_Cheater.h	(revision 993)
+++ 	(revision )
@@ -1,52 +1,0 @@
-#ifndef DAODAN_CHEATER_H
-#define DAODAN_CHEATER_H
-
-#include "Daodan.h"
-
-typedef struct {
-    const char* name;
-    const char* message_on;
-    const char* message_off;
-    int func;
-} oniCheatCode;
-
-enum {
-		cheat_shapeshifter,
-		cheat_liveforever,
-		cheat_touchofdeath,
-		cheat_canttouchthis,
-		cheat_fatloot,
-		cheat_glassworld,
-		cheat_winlevel,
-		cheat_loselevel,
-		cheat_bighead,
-		cheat_minime,
-		cheat_superammo,
-		cheat_thedayismine,
-		cheat_reservoirdogs,
-		cheat_roughjustice,
-		cheat_chenille,
-		cheat_behemoth,
-		cheat_elderrune,
-		cheat_moonshadow,
-		cheat_munitionfrenzy,
-		cheat_fistsoflegend,
-		cheat_killmequick,
-		cheat_carousel,
-		cheat_bigbadboss,
-		cheat_bulletproof,
-		cheat_kangaroo,
-		cheat_marypoppins,
-		cheat_buddha,
-		cheat_shinobi,
-		cheat_x,
-		cheat_testcheat,
-		cheat_tellmetheversion,
-};
-
-extern oniCheatCode DDr_CheatTable[];
-uint8_t ONICALL DDrCheater(uint32_t cheat);
-void __stdcall FallingFrames(void* Ebp);
-void ONICALL DDrCheater_LevelLoad();
-
-#endif
Index: Daodan/src/Daodan_Config.c
===================================================================
--- Daodan/src/Daodan_Config.c	(revision 993)
+++ Daodan/src/Daodan_Config.c	(revision 994)
@@ -1,11 +1,12 @@
 #include <windows.h>
 #include <string.h>
-
-#include "Daodan_Cheater.h"
+#include <time.h>
+
 #include "Daodan_Config.h"
 #include "Daodan_Patch.h"
-#include "Daodan_Utility.h"
+#include "Patches/Utility.h"
 
 #include "Oni/Oni.h"
+#include "_Version.h"
 
 #include "Inifile_Reader.h"
@@ -14,4 +15,10 @@
 
 static const char* iniName = "daodan.ini";
+static const char* helpFile = "daodan_help.txt";
+
+static const char* defaultSection = "options";
+
+void DDrConfig_PrintHelp();
+
 
 ConfigSection_t config[] = {
@@ -93,5 +100,5 @@
 			{.intBoolVal = true} },
 		{ "hdscreens_lowres",
-			"???",
+			"Allow HD screens with resolution < 1024*768.",
 			C_BOOL,
 			{.intBoolVal = true},
@@ -210,6 +217,11 @@
 			{.intBoolVal = true},
 			{.intBoolVal = true} },
+		{ "help",
+			"Generates this help file.",
+			C_CMD,
+			{.intBoolVal = 0},
+			{.callback = DDrConfig_PrintHelp} },
 		{ "ignore_private_data",
-			"???",
+			"? No effect ?",
 			EXT_BOOL,
 			{.intBoolVal = false },
@@ -256,8 +268,79 @@
 					STARTUPMESSAGE("Option %s.%s = %d (def %d)", config[s].name, co->name, *co->value.extBoolVal, co->defaultValue.intBoolVal);
 					break;
+				case C_CMD:
+					break;
 				default:
 					STARTUPMESSAGE("Option %s.%s = %d (def %d)", config[s].name, co->name, co->value.intBoolVal, co->defaultValue.intBoolVal);
 			}
 		}
+	}
+}
+
+void DDrConfig_PrintHelp()
+{
+	STARTUPMESSAGE("Writing Daodan help file (%s)", helpFile);
+
+	FILE* fp;
+	remove(helpFile);
+	fp = fopen(helpFile, "w");
+	if (fp)
+	{
+		time_t rawtime;
+		struct tm* timeinfo;
+		char buffer[80];
+		time(&rawtime);
+		timeinfo = localtime(&rawtime);
+		strftime(buffer, 80, "%Y-%m-%d %H:%M:%S", timeinfo);
+		
+		fprintf(fp, "Daodan help - generated on %s for Daodan v."DAODAN_VERSION_STRING"\n\n", buffer);
+		fprintf(fp, "List of Daodan configuration parameters:\n");
+		for (unsigned int s = 0; s < ARRAY_SIZE(config); s++) {
+			fprintf(fp, "    %s - %s:\n", config[s].name, config[s].description);
+			for (ConfigOption_t* co = config[s].options; co->name != 0; co++) {
+				char* name = co->name;
+				char* desc = co->description;
+				const char* tName = DDrConfig_GetOptionTypeName(co->type);
+				int boolV = co->defaultValue.intBoolVal;
+				char* val;
+				switch (co->type) {
+					case C_STRING:
+						val = co->defaultValue.stringVal;
+						break;
+					case EXT_BOOL:
+						val = (boolV ? "true" : "false");
+						break;
+					case C_BOOL:
+						val = (boolV ? "true" : "false");
+						break;
+					case C_CMD:
+						val = "";
+						break;
+					default:
+						val = malloc(20);
+						sprintf(val, "%d", boolV);
+				}
+				fprintf(fp, "        %-22s %6s=%-5s %s\n", name, tName, val, desc);
+			}
+			fprintf(fp, "\n");
+		}
+		fprintf(fp, "\nConfiguration parameters can be either set in daodan.ini or passed on command line.\n\n");
+		fprintf(fp, "In daodan.ini each section of parameters has its own section in the ini file started by [section name]. Parameters are given within that section by their name only, followed by an equals sign and the desired value. Example:\n");
+		fprintf(fp, "    [sectionX]\n    parameterName = false\n");
+		fprintf(fp, "\nTo pass the parameter on the command line:\n");
+		fprintf(fp, "    Oni.exe -sectionX.parameterName false\n");
+		fprintf(fp, "For bool parameters the value can be ommitted so it is regarded as \"true\":\n");
+		fprintf(fp, "    Oni.exe -sectionX.parameterName\n");
+		fprintf(fp, "To disable a bool parameter you can prefix \"no\" to the parameter name like this:\n");
+		fprintf(fp, "    Oni.exe -sectionX.noparameterName\n");
+		fprintf(fp, "If no section is given it is assumed to be \"%s\", e.g.\n", defaultSection);
+		fprintf(fp, "    Oni.exe -%s.parametername\n", defaultSection);
+		fprintf(fp, "can simply be written as\n");
+		fprintf(fp, "    Oni.exe -parametername\n");
+
+		fclose(fp);
+	}
+	else
+	{
+		STARTUPMESSAGE("Writing Daodan help file failed", 0);
 	}
 }
@@ -272,4 +355,6 @@
 		case C_STRING:
 			return "String";
+		case C_CMD:
+			return "Cmd";
 		case EXT_BOOL:
 			return "pBool";
@@ -322,4 +407,5 @@
 
 
+
 void DDrConfig_InitExtBools()
 {
@@ -335,5 +421,24 @@
 
 
-void DDrIniCallback(char* section, char* name, char* value)
+void DDrConfig_WriteTemplateIni()
+{
+	FILE* fp;
+	STARTUPMESSAGE("%s doesn't exist, creating", iniName);
+	fp = fopen(iniName, "w");
+	if (fp)
+	{
+		for (unsigned int s = 0; s < ARRAY_SIZE(config); s++) {
+			fprintf(fp, "[%s]\n", config[s].name);
+		}
+		fclose(fp);
+	}
+	else
+	{
+		STARTUPMESSAGE("Writing %s template file failed", iniName);
+	}
+}
+
+
+void DDrIniCallback(const char* section, const char* name, const char* value)
 {
 	static char curSection[20];
@@ -353,4 +458,5 @@
 	if (co)
 	{
+		char* buf = 0;
 		switch (co->type) {
 			case C_INT:
@@ -361,5 +467,10 @@
 				break;
 			case C_STRING:
-				co->value.stringVal = value;
+				buf = malloc(strlen(value)+1);
+				strcpy(buf, value);
+				co->value.stringVal = buf;
+				break;
+			case C_CMD:
+				co->value.callback();
 				break;
 			case EXT_BOOL:
@@ -372,26 +483,60 @@
 }
 
-void DDrConfig_WriteTemplateIni()
-{
-	FILE* fp;
-	STARTUPMESSAGE("%s doesn't exist, creating", iniName);
-	fp = fopen(iniName, "w");
-	if (fp)
+
+bool DDrConfig_ParseCommandLine(int argc, char* argv[])
+{
+	for (int i = 1; i < argc; i ++)
 	{
-		for (unsigned int s = 0; s < ARRAY_SIZE(config); s++) {
-			fprintf(fp, "[%s]\n", config[s].name);
-		}
-		fclose(fp);
-	}
-}
-
+		if (argv[i][0] == '-')
+		{
+			const char* section;
+			char* optionsep;
+			char* option;
+			bool invertedOption;
+
+			if ((optionsep = strchr(argv[i], '.')))
+			// Is "section.option"
+			{
+				*optionsep = 0;
+				option = optionsep+1;
+				section = argv[i]+1;
+			}
+			else
+			// Is just "option"
+			{
+				section = defaultSection;
+				option = argv[i]+1;
+			}
+
+			invertedOption = (option[0] == 'n' || option[0] == 'N') && (option[1] == 'o' || option[1] == 'O');
+			if (invertedOption)
+				option += 2;
+
+			if (i < (argc - 1) && argv[i+1][0] != '-')
+			// Has value in next field
+			{
+				DDrIniCallback(section, option, argv[++i]);
+			}
+			else
+			// Implicit value
+			{
+				DDrIniCallback(section, option, (invertedOption ? "false" : "true"));
+			}
+
+			if (optionsep)
+				*optionsep = '.';
+		}
+		else
+		{
+			STARTUPMESSAGE("Parse error \"%s\"", argv[i]);
+			return false;
+		}
+	}
+	return true;
+}
 
 void DDrConfig(int argc, char* argv[])
 {
-	int i;
-	char* section;
-	char* option;
-	bool falseoption;
-
+	STARTUPMESSAGE("Initializing standard booleans", 0);
 	DDrConfig_InitExtBools();
 
@@ -407,144 +552,8 @@
 
 	STARTUPMESSAGE("Parsing command line...", 0);
-	for (i = 1; i < argc; i ++)
-	{
-		if (argv[i][0] == '-')
-		{
-			section = argv[i] + 1;
-			if ((option = strchr(argv[i], '.')))
-			{
-				*option = '\0';
-				falseoption = (option[1] == 'n' || option[1] == 'N') && (option[2] == 'o' || option[2] == 'O');
-				if (i < (argc - 1) && argv[i + 1][0] != '-')
-					DDrIniCallback(section, option + 1, argv[++i]);
-				else
-					DDrIniCallback(section, option + (falseoption ? 3 : 1), (falseoption ? "false" : "true"));
-				*option = '.';
-			}
-			else
-			{
-				falseoption = (section[0] == 'n' || section[0] == 'N') && (section[1] == 'o' || section[1] == 'O');
-				if (i < (argc - 1) && argv[i + 1][0] != '-')
-					DDrIniCallback("options", section, argv[++i]);
-				else
-					DDrIniCallback("options", section + (falseoption ? 2 : 0), (falseoption ? "false" : "true"));
-			}
-		}
-		else
-		{
-			STARTUPMESSAGE("Parse error \"%s\"", argv[i]);
-			break;
-		}
-	}
+	DDrConfig_ParseCommandLine(argc, argv);
 	STARTUPMESSAGE("Finished parsing", 0);
-}
-
-
-/*
-		case s_language:
-			else if (!_stricmp(name, "blam"))
-				DDrPatch__strdup((int*)(OniExe + 0x0010fb73), value);
-			else if (!_stricmp(name, "damn"))
-				DDrPatch__strdup((int*)(OniExe + 0x0010fb6e), value);
-			else if (!_stricmp(name, "savepoint"))
-			{
-				char* str = _strdup(value);
-				DDrPatch_Int32((int*)(OniExe + 0x000fd730), (int)str);
-				DDrPatch_Int32((int*)(OniExe + 0x000fd738), (int)str);
-			}
-			else if (!_stricmp(name, "syndicatewarehouse"))
-			{
-				char* str = _strdup(value);
-				DDrPatch_Int32((int*)(OniExe + 0x000fd71a), (int)str);
-				DDrPatch_Int32((int*)(OniExe + 0x0010ef75), (int)str);
-			}
-			else if (!_stricmp(name, "shapeshifter_on"))
-				DDr_CheatTable[0].message_on = _strdup(value);
-			else if (!_stricmp(name, "shapeshifter_off"))
-				DDr_CheatTable[0].message_off = _strdup(value);
-			else if (!_stricmp(name, "liveforever_on"))
-				DDr_CheatTable[1].message_on = _strdup(value);
-			else if (!_stricmp(name, "liveforever_off"))
-				DDr_CheatTable[1].message_off = _strdup(value);
-			else if (!_stricmp(name, "touchofdeath_on"))
-				DDr_CheatTable[2].message_on = _strdup(value);
-			else if (!_stricmp(name, "touchofdeath_off"))
-				DDr_CheatTable[2].message_off = _strdup(value);
-			else if (!_stricmp(name, "canttouchthis_on"))
-				DDr_CheatTable[3].message_on = _strdup(value);
-			else if (!_stricmp(name, "canttouchthis_off"))
-				DDr_CheatTable[3].message_off = _strdup(value);
-			else if (!_stricmp(name, "fatloot_on"))
-				DDr_CheatTable[4].message_on = _strdup(value);
-			else if (!_stricmp(name, "glassworld_on"))
-				DDr_CheatTable[5].message_on = _strdup(value);
-			else if (!_stricmp(name, "glassworld_off"))
-				DDr_CheatTable[5].message_off = _strdup(value);
-			else if (!_stricmp(name, "winlevel_on"))
-				DDr_CheatTable[6].message_on = _strdup(value);
-			else if (!_stricmp(name, "loselevel_on"))
-				DDr_CheatTable[7].message_on = _strdup(value);
-			else if (!_stricmp(name, "bighead_on"))
-				DDr_CheatTable[8].message_on = _strdup(value);
-			else if (!_stricmp(name, "bighead_off"))
-				DDr_CheatTable[8].message_off = _strdup(value);
-			else if (!_stricmp(name, "minime_on"))
-				DDr_CheatTable[9].message_on = _strdup(value);
-			else if (!_stricmp(name, "minime_off"))
-				DDr_CheatTable[9].message_off = _strdup(value);
-			else if (!_stricmp(name, "superammo_on"))
-				DDr_CheatTable[10].message_on = _strdup(value);
-			else if (!_stricmp(name, "superammo_off"))
-				DDr_CheatTable[10].message_off = _strdup(value);
-			else if (!_stricmp(name, "devmode_on"))
-			{
-				char* str = _strdup(value);
-				DDr_CheatTable[11].message_on = str;
-				DDr_CheatTable[cheat_x].message_on = str;
-			}
-			else if (!_stricmp(name, "devmode_off"))
-			{
-				char* str = _strdup(value);
-				DDr_CheatTable[11].message_off = str;
-				DDr_CheatTable[cheat_x].message_off = str;
-			}
-			else if (!_stricmp(name, "reservoirdogs_on"))
-				DDr_CheatTable[12].message_on = _strdup(value);
-			else if (!_stricmp(name, "reservoirdogs_off"))
-				DDr_CheatTable[12].message_off = _strdup(value);
-			else if (!_stricmp(name, "roughjustice_on"))
-				DDr_CheatTable[13].message_on = _strdup(value);
-			else if (!_stricmp(name, "roughjustice_off"))
-				DDr_CheatTable[13].message_off = _strdup(value);
-			else if (!_stricmp(name, "chenille_on"))
-				DDr_CheatTable[14].message_on = _strdup(value);
-			else if (!_stricmp(name, "chenille_off"))
-				DDr_CheatTable[14].message_off = _strdup(value);
-			else if (!_stricmp(name, "behemoth_on"))
-				DDr_CheatTable[15].message_on = _strdup(value);
-			else if (!_stricmp(name, "behemoth_off"))
-				DDr_CheatTable[15].message_off = _strdup(value);
-			else if (!_stricmp(name, "elderrune_on"))
-				DDr_CheatTable[16].message_on = _strdup(value);
-			else if (!_stricmp(name, "elderrune_off"))
-				DDr_CheatTable[16].message_off = _strdup(value);
-			else if (!_stricmp(name, "moonshadow_on"))
-				DDr_CheatTable[17].message_on = _strdup(value);
-			else if (!_stricmp(name, "moonshadow_off"))
-				DDr_CheatTable[17].message_off = _strdup(value);
-			else if (!_stricmp(name, "munitionfrenzy_on"))
-				DDr_CheatTable[18].message_on = _strdup(value);
-			else if (!_stricmp(name, "fistsoflegend_on"))
-				DDr_CheatTable[19].message_on = _strdup(value);
-			else if (!_stricmp(name, "fistsoflegend_off"))
-				DDr_CheatTable[19].message_off = _strdup(value);
-			else if (!_stricmp(name, "killmequick_on"))
-				DDr_CheatTable[20].message_on = _strdup(value);
-			else if (!_stricmp(name, "killmequick_off"))
-				DDr_CheatTable[20].message_off = _strdup(value);
-			else if (!_stricmp(name, "carousel_on"))
-				DDr_CheatTable[21].message_on = _strdup(value);
-			else if (!_stricmp(name, "carousel_off"))
-				DDr_CheatTable[21].message_off = _strdup(value);
-*/	
-
+
+//	DDrConfig_Print();
+}
+
Index: Daodan/src/Daodan_Config.h
===================================================================
--- Daodan/src/Daodan_Config.h	(revision 993)
+++ Daodan/src/Daodan_Config.h	(revision 994)
@@ -4,5 +4,8 @@
 #include "stdint.h"
 
+typedef void (*cmd_callback)();
+
 typedef enum {
+	C_CMD,
 	C_BOOL,
 	C_INT,
@@ -15,4 +18,5 @@
 	uint8_t* extBoolVal;
 	char* stringVal;
+	cmd_callback callback;
 } OptionValue_t;
 
Index: Daodan/src/Daodan_Console.c
===================================================================
--- Daodan/src/Daodan_Console.c	(revision 993)
+++ 	(revision )
@@ -1,52 +1,0 @@
-#include <stdlib.h>
-#include <stdarg.h>
-
-#include "Daodan_Console.h"
-#include "Oni/Oni.h"
-
-void DDrConsole_Print(const char* text)
-{
-	COrTextArea_Print(COgConsoleLines, 1, COgDefaultTextShade, COgDefaultTextShadow, text, 0, COgFadeTimeValue);
-}
-
-void DDrConsole_PrintColored(const char* text, int priority, RGBA color, RGBA shade)
-{
-	int* intcolor = (int*)&color;
-	int* intshade = (int*)&shade;
-	COrTextArea_Print(COgConsoleLines, 1, *intcolor, *intshade, text, 0, COgFadeTimeValue);
-}
-
-void DDrConsole_PrintF(const char* fmt, ...)
-{
-	char* buffer;
-	va_list ap;
-	va_start(ap, fmt);
-	buffer = malloc(vsnprintf(NULL, 0, fmt, ap) + 1);
-	
-	vsprintf(buffer, fmt, ap);
-	va_end(ap);
-
-	DDrConsole_Print(buffer);
-	free(buffer);
-	return;
-}
-
-TStColorFormattingCharacter DDrDSayColors[] = {
-	{'r', 0, 0xFFEB5050},	//red
-	{'y', 0, 0xFFFCFF1C},	//yellow
-	{'b', 0, 0xFF93BBE9},	//blue
-	{'u', 0, 0xFFF67603},	//umber
-	{'g', 0, 0xFFA2DAA5},	//green
-	{'l', 0, 0xFFBE90D9},	//lilac
-	{'o', 0, 0xFFFBA500},	//orange
-	{'c', 0, 0xFF93EAEB},	//cyan
-								//New Colors Here...
-	{'k', 0, 0xFF000000},	//black
-	{'v', 0, 0xFFEB40EB},	//violet
-	{'w', 0, 0xFFFFFFFF},	//white...
-	{'e', 0, 0xFF505050},	//darkgrey
-	{'f', 0, 0xFFAAAAAA},	//grey
-	{0, 0, 0}							//POWER RANGERS GO!
-};
-
-		
Index: Daodan/src/Daodan_Console.h
===================================================================
--- Daodan/src/Daodan_Console.h	(revision 993)
+++ 	(revision )
@@ -1,36 +1,0 @@
-#ifndef DAODAN_CONSOLE_H
-#define DAODAN_CONSOLE_H
-
-#include "Daodan.h"
-
-typedef struct {
-	char B;
-	char G;
-	char R;
-	char A;
-} RGBA;
-
-
-typedef struct {
-	char A;
-	char R;
-	char G;
-	char B;
-} ARGB;
-
-typedef struct {
-	char Char;
-	short ignored;
-	int Color; //ARGB Color;
-} TStColorFormattingCharacter;
-
-extern TStColorFormattingCharacter* TStColorFormattingCharacters;
-extern TStColorFormattingCharacter DDrDSayColors[];
-
-void DDrConsole_Print(const char* text);
-
-void DDrConsole_PrintColored(const char* text, int priority, RGBA color, RGBA shade);
-
-void DDrConsole_PrintF(const char* fmt, ...);
-
-#endif
Index: Daodan/src/Daodan_GL.c
===================================================================
--- Daodan/src/Daodan_GL.c	(revision 993)
+++ 	(revision )
@@ -1,433 +1,0 @@
-#include <windows.h>
-#include <math.h>
-#include <GL/gl.h>
-#include <GL/glu.h>
-
-#include "Oni/Oni.h"
-
-#include "Daodan_Config.h"
-#include "Daodan_Utility.h"
-#include "Daodan_Win32.h"
-#include "Daodan_GL.h"
-
-static const M3tDisplayMode daodan_reslist[] =
-{
-	{ 640,  480,  0, 0 },
-	{ 720,  480,  0, 0 },
-	{ 720,  576,  0, 0 },
-	{ 768,  480,  0, 0 },
-	{ 800,  480,  0, 0 },
-	{ 800,  600,  0, 0 },
-	{ 852,  480,  0, 0 },
-	{ 856,  480,  0, 0 },
-	{ 960,  540,  0, 0 },
-	{ 960,  720,  0, 0 },
-	{ 1024, 576,  0, 0 },
-	{ 1024, 600,  0, 0 },
-	{ 1024, 640,  0, 0 },
-	{ 1024, 768,  0, 0 },
-	{ 1152, 768,  0, 0 },
-	{ 1152, 864,  0, 0 },
-	{ 1280, 720,  0, 0 },
-	{ 1280, 768,  0, 0 },
-	{ 1280, 800,  0, 0 },
-	{ 1280, 960,  0, 0 },
-	{ 1280, 1024, 0, 0 },
-	{ 1366, 768,  0, 0 },
-	{ 1400, 1050, 0, 0 },
-	{ 1440, 900,  0, 0 },
-	{ 1600, 900,  0, 0 },
-	{ 1600, 1200, 0, 0 },
-	{ 1920, 1080, 0, 0 },
-	{ 1920, 1200, 0, 0 },
-	{ 1920, 1440, 0, 0 },
-};
-
-static DWORD window_style, window_exstyle;
-
-// HACK: use additional device entries to store display modes. It would give us
-// 67 mode slots total (far more than enough). I absolutely have no idea where
-// Rossy got his 104 (it would take up to 0x660 bytes while the whole GL state
-// is only 0x63c bytes). Maybe it was just octal (67 + 1).
-// This hack would break (crash!) "m3_display_list" script command.
-#define DD_MAX_MODES ((offsetof(M3tDrawEngineCaps,__unknown) - \
-						offsetof(M3tDrawEngineCaps,DisplayDevices) - \
-						offsetof(M3tDisplayDevice,Modes)) / sizeof(M3tDisplayMode))
-
-// Former daodan_resdepths.
-#define DD_MIN_DEPTH 16
-
-unsigned short ONICALL DD_GLrEnumerateDisplayModes(M3tDisplayMode* modes)
-{
-	unsigned int vmodes = 0;
-	unsigned int screen_x = GetSystemMetrics(SM_CXSCREEN);
-	unsigned int screen_y = GetSystemMetrics(SM_CYSCREEN);
-	
-	unsigned int i;
-	signed int j;
-	
-	STARTUPMESSAGE("Listing display modes", 0);
-
-	memset(modes, 0, sizeof(M3tDisplayMode) * DD_MAX_MODES);
-
-	if (M3gResolutionSwitch)
-	{
-		// Enumerate in -switch mode. "67 slots ought to be enough for anybody".
-
-		DEVMODE dm;
-
-		dm.dmSize        = sizeof(dm);
-		dm.dmDriverExtra = 0;
-
-		for (i = 0; EnumDisplaySettings(NULL, i, &dm); ++i)
-		{
-			if (dm.dmBitsPerPel < DD_MIN_DEPTH || dm.dmPelsWidth < 640 || dm.dmPelsHeight < 480)
-				continue;
-			if (dm.dmPelsWidth < dm.dmPelsHeight)
-				continue;
-
-			// Already exists? Search backwards as modes are sorted most of the times
-			for (j = vmodes - 1; j >= 0; --j)
-				if (modes[j].Width == dm.dmPelsWidth && modes[j].Height == dm.dmPelsHeight &&
-					modes[j].Depth == dm.dmBitsPerPel)
-					break;
-
-			if (j >= 0)
-				continue; // We've found a match.
-
-			modes[vmodes].Width  = dm.dmPelsWidth;
-			modes[vmodes].Height = dm.dmPelsHeight;
-			modes[vmodes].Depth  = dm.dmBitsPerPel;
-
-			if (++vmodes >= DD_MAX_MODES)
-				break;
-		}
-	}
-	else
-	{
-		// In -noswitch we put predefined window sizes which don't overlap
-		// deskbar(s) plus one "native" fullscreen mode.
-
-		unsigned int workarea_width, workarea_height, frame_width, frame_height;
-		DWORD style, exstyle;
-		RECT rc;
-
-		if (SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0))
-		{
-			workarea_width  = rc.right - rc.left;
-			workarea_height = rc.bottom - rc.top;
-		}
-		else
-		{
-			workarea_width  = screen_x;
-			workarea_height = screen_y;
-		}
-
-		style   = (DWORD) GetWindowLongPtr(ONgPlatformData.Window, GWL_STYLE);
-		exstyle = (DWORD) GetWindowLongPtr(ONgPlatformData.Window, GWL_EXSTYLE);
-
-		// Calculate additional width and height for window borders. Don't
-		// bother with system metrics. Let Windows calculate this.
-		rc.left  = rc.top = 0;
-		rc.right = rc.bottom = 300;
-
-		if (AdjustWindowRectEx(&rc, style, FALSE, exstyle))
-		{
-			frame_width  = rc.right - rc.left - 300;
-			frame_height = rc.bottom - rc.top - 300;
-		}
-		else
-		{
-			frame_width  = 0;
-			frame_height = 0;
-		}
-
-		for (i = 0; i < sizeof(daodan_reslist) / sizeof(daodan_reslist[0]); ++i)
-		{
-			// Don't check the mode which has the same rect as screen. We would
-			// add it later as a special case.
-			if (daodan_reslist[i].Width == screen_x && daodan_reslist[i].Height == screen_y)
-				continue;
-			
-			if (daodan_reslist[i].Width + frame_width <= workarea_width &&
-				daodan_reslist[i].Height + frame_height <= workarea_height)
-			{
-				modes[vmodes] = daodan_reslist[i];
-				modes[vmodes].Depth = GLgInitialMode.dmBitsPerPel;
-
-				if (++vmodes >= DD_MAX_MODES)
-				{
-					--vmodes; // Remove the last mode to make room for "fullscreen" mode.
-					break;
-				}
-			}
-		}
-
-		modes[vmodes].Width  = GLgInitialMode.dmPelsWidth;
-		modes[vmodes].Height = GLgInitialMode.dmPelsHeight;
-		modes[vmodes].Depth  = GLgInitialMode.dmBitsPerPel;
-		++vmodes;
-	}
-
-	STARTUPMESSAGE("%u modes available:", vmodes);
-	for (i = 0; i < vmodes; ++i)
-		STARTUPMESSAGE("   %ux%ux%u", modes[i].Width, modes[i].Height, modes[i].Depth);
-
-	return vmodes;
-}
-
-// Sets a new display mode (if it is somehow different from a current mode).
-// NOTE: signature for this function was changed to simplify code.
-UUtBool DD_GLrPlatform_SetDisplayMode(M3tDisplayMode* mode)
-{
-	if (mode->Height < 480)
-		return UUcFalse;
-
-	if (M3gResolutionSwitch)
-	{
-		DEVMODE new_mode, cur_mode;
-
-		cur_mode.dmSize        = sizeof(cur_mode);
-		cur_mode.dmDriverExtra = 0;
-
-		// We don't need this check. Windows does this too (see CDS_RESET).
-		if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &cur_mode) ||
-			cur_mode.dmPelsWidth != mode->Width || cur_mode.dmPelsHeight !=  mode->Height ||
-			cur_mode.dmBitsPerPel != mode->Depth)
-		{
-			new_mode.dmSize       = sizeof(new_mode);
-			new_mode.dmFields     = DM_BITSPERPEL | DM_PELSHEIGHT | DM_PELSWIDTH;
-			new_mode.dmPelsWidth  = mode->Width;
-			new_mode.dmPelsHeight = mode->Height;
-			new_mode.dmBitsPerPel = mode->Depth;
-
-			if (ChangeDisplaySettings(&new_mode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
-				return UUcFalse;
-		}
-		
-		// We didn't change window size in DD_GLrPlatform_Initialize so we need
-		// to change it here.
-		SetWindowPos(ONgPlatformData.Window, NULL, 0, 0, mode->Width, mode->Height,
-			SWP_NOACTIVATE | SWP_NOSENDCHANGING | SWP_NOZORDER);
-
-		return UUcTrue;
-	}
-	else
-	{
-		unsigned screen_x, screen_y;
-		DWORD style, exstyle, new_style, new_exstyle;
-		DWORD flags;
-		RECT rc, workarea_rc;
-		POINT pt;
-
-		screen_x = GetSystemMetrics(SM_CXSCREEN);
-		screen_y = GetSystemMetrics(SM_CYSCREEN);
-
-		GetClientRect(ONgPlatformData.Window, &rc);
-		
-		// Don't do anything if the mode was not changed.
-		if (rc.right == mode->Width && rc.bottom == mode->Height)
-			return UUcTrue;
-
-		style   = (DWORD) GetWindowLongPtr(ONgPlatformData.Window, GWL_STYLE);
-		exstyle = (DWORD) GetWindowLongPtr(ONgPlatformData.Window, GWL_EXSTYLE);
-		flags   = SWP_NOACTIVATE | SWP_NOZORDER;
-
-		// Remember initial window style to correctly restore from fullscreen.
-		if (window_style == 0)
-		{
-			window_style = style;
-			window_exstyle = exstyle;
-		}
-
-		if (mode->Width == screen_x && mode->Height == screen_y)
-		{
-			// "Fullscreen" mode.
-			new_exstyle = exstyle & ~(WS_EX_CLIENTEDGE | WS_EX_DLGMODALFRAME | WS_EX_STATICEDGE | WS_EX_WINDOWEDGE);
-			new_style   = style & ~(WS_CAPTION | WS_BORDER | WS_THICKFRAME | WS_DLGFRAME);
-			new_style   = new_style | WS_POPUP;
-			rc.left     = 0;
-			rc.top      = 0;
-			rc.right    = mode->Width;
-			rc.bottom   = mode->Height;
-		}
-		else
-		{
-			ConfigOption_t* co = DDrConfig_GetOptOfType("options.border", C_BOOL);
-			if (co && co->value.intBoolVal)
-			{
-				pt.x = rc.left;
-				pt.y = rc.top;
-				ClientToScreen(ONgPlatformData.Window, &pt);
-			}
-			else
-			{
-				pt.x = screen_x / 2 - mode->Width / 2;
-				pt.y = screen_y / 2 - mode->Height / 2;
-			}
-
-			new_exstyle = window_exstyle;
-			new_style   = window_style;
-			rc.left     = pt.x;
-			rc.top      = pt.y;
-			rc.right    = rc.left + mode->Width;
-			rc.bottom   = rc.top + mode->Height;
-
-			AdjustWindowRectEx(&rc, new_style, FALSE, new_exstyle);
-
-			// Convert to width and height.
-			rc.right  -= rc.left;
-			rc.bottom -= rc.top;
-
-			if (SystemParametersInfo(SPI_GETWORKAREA, 0, &workarea_rc, 0))
-			{
-				// We try to keep window position, but we should prevent window
-				// from going off screen.
-
-				if (rc.left + rc.right > workarea_rc.right)
-					rc.left = workarea_rc.right - rc.right;
-				if (rc.top + rc.bottom > workarea_rc.bottom)
-					rc.top = workarea_rc.bottom - rc.bottom;
-
-				//  Titlebar should always be visible.
-
-				if (rc.left < workarea_rc.left)
-					rc.left = workarea_rc.left;
-				if (rc.top < workarea_rc.top)
-					rc.top = workarea_rc.top;
-			}
-		}
-
-		if (new_style != style)
-		{
-			SetWindowLongPtr(ONgPlatformData.Window, GWL_STYLE, (LONG_PTR) new_style);
-			flags |= SWP_FRAMECHANGED | SWP_DRAWFRAME;
-		}
-
-		if (new_exstyle != exstyle)
-		{
-			SetWindowLongPtr(ONgPlatformData.Window, GWL_EXSTYLE, (LONG_PTR) new_exstyle);
-			flags |= SWP_FRAMECHANGED | SWP_DRAWFRAME;
-		}
-
-		SetWindowPos(ONgPlatformData.Window, NULL, rc.left, rc.top, rc.right, rc.bottom, flags);
-		return UUcTrue;
-	}
-}
-
-static void ONICALL DD_GLiGamma_Restore(void)
-{
-	ConfigOption_t* co = DDrConfig_GetOptOfType("options.gamma", C_BOOL);
-	if (co->value.intBoolVal)
-	{
-		if (gl_api->wglSetDeviceGammaRamp3DFX)
-			gl_api->wglSetDeviceGammaRamp3DFX(gl->hDC, GLgInitialGammaRamp);
-		else
-			SetDeviceGammaRamp(gl->hDC, GLgInitialGammaRamp);
-	}
-}
-
-static void ONICALL DD_GLiGamma_Initialize(void)
-{
-	ConfigOption_t* co = DDrConfig_GetOptOfType("options.gamma", C_BOOL);
-	if (co->value.intBoolVal)
-	{
-		if (gl_api->wglSetDeviceGammaRamp3DFX)
-		{
-			UUrStartupMessage("Daodan: Using 3dfx gamma adjustment");
-			GLgGammaRampValid = gl_api->wglGetDeviceGammaRamp3DFX(gl->hDC, GLgInitialGammaRamp);
-		}
-		else
-		{
-			UUrStartupMessage("Daodan: Using Windows gamma adjustment");
-			GLgGammaRampValid = GetDeviceGammaRamp(gl->hDC, GLgInitialGammaRamp);
-		}
-
-		M3rSetGamma(ONrPersist_GetGamma());
-	}
-	else
-	{
-		GLgGammaRampValid = FALSE;
-	}
-}
- 
-// Disposes OpenGL engine. Called once.
-void ONICALL DD_GLrPlatform_Dispose(void)
-{
-	DEVMODE dm;
-	
-	DD_GLiGamma_Restore();
-
-	gl_api->wglMakeCurrent(NULL, NULL);
-	gl_api->wglDeleteContext(gl->hGLRC);
-	ReleaseDC(ONgPlatformData.Window, gl->hDC);
-
-	// Restore initial display mode if it does not match current mode.
-	
-	dm.dmSize        = sizeof(dm);
-	dm.dmDriverExtra = 0;
-	
-	if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm) ||
-		dm.dmPelsWidth != GLgInitialMode.dmPelsWidth ||
-		dm.dmPelsHeight != GLgInitialMode.dmPelsHeight ||
-		dm.dmBitsPerPel != GLgInitialMode.dmBitsPerPel)
-	{
-		ChangeDisplaySettings(&GLgInitialMode, 0);
-	}
-	
-	// (skipping SetWindowPos as it only adds flickering)
-	gl_unload_library();
-}
-
-// Initializes (and re-initializes) OpenGL.
-UUtBool ONICALL DD_GLrPlatform_Initialize(void)
-{
-	static const M3tDisplayMode FallbackMode = { 640, 480, 16, 0 };
-
-	if (!DD_GLrPlatform_SetDisplayMode(&gl->DisplayMode))
-	{
-		gl->DisplayMode = FallbackMode;
-		
-		if (!DD_GLrPlatform_SetDisplayMode(&gl->DisplayMode))
-		{
-			goto exit_err;
-		}
-	}
-
-	// (DD_GLrPlatform_SetDisplayMode updates a window rectangle for us)
-	
-	if (!gl->hDC && !(gl->hDC = GetDC(ONgPlatformData.Window)))
-	{
-		goto exit_err;
-	}
-
-	ConfigOption_t* co = DDrConfig_GetOptOfType("options.gamma", C_BOOL);
-	if (!M3gResolutionSwitch && co->value.intBoolVal)
-	{
-		UUrStartupMessage("Daodan: Ignoring gamma setting due to windowed mode");
-		co->value.intBoolVal = false;
-	}
-
-	DD_GLiGamma_Initialize();
-
-	// This creates a rendering context too.
-	if (!gl_platform_set_pixel_format(gl->hDC))
-	{
-		if (gl->DisplayMode.Depth != 16)
-		{
-			gl->DisplayMode.Depth = 16;
-			if (!DD_GLrPlatform_SetDisplayMode(&gl->DisplayMode))
-				goto exit_err;
-			
-			if (!gl_platform_set_pixel_format(gl->hDC))
-				goto exit_err;
-		}
-	}
-
-	return UUcTrue;
-
-exit_err:
-	AUrMessageBox(1, "Daodan: Failed to initialize OpenGL contexts; Oni will now exit.");
-	exit(0);
-	return 0;
-}
Index: Daodan/src/Daodan_GL.h
===================================================================
--- Daodan/src/Daodan_GL.h	(revision 993)
+++ 	(revision )
@@ -1,11 +1,0 @@
-#ifndef DAODAN_GL_H
-#define DAODAN_GL_H
-
-#include "Daodan.h"
-#include "Oni/Oni.h"
-
-unsigned short ONICALL DD_GLrEnumerateDisplayModes(M3tDisplayMode* modes);
-UUtBool ONICALL DD_GLrPlatform_Initialize(void);
-void ONICALL DD_GLrPlatform_Dispose(void);
-
-#endif
Index: Daodan/src/Daodan_Patch.c
===================================================================
--- Daodan/src/Daodan_Patch.c	(revision 993)
+++ Daodan/src/Daodan_Patch.c	(revision 994)
@@ -1,4 +1,4 @@
 #include "Daodan_Patch.h"
-#include "Daodan_Utility.h"
+#include "Patches/Utility.h"
 #include <beaengine/BeaEngine.h>
 
@@ -280,18 +280,4 @@
 }
 
-bool DDrPatch__strdup(int* dest, const char* value)
-{
-	DWORD oldp;
-	
-	if (VirtualProtect(dest, 4, PAGE_EXECUTE_READWRITE, &oldp))
-	{
-		*dest = (int)_strdup(value);
-		VirtualProtect(dest, 4, oldp, &oldp);
-		return true;
-	}
-	else
-		return false;
-}
-
 bool DDrPatch_NOOP(char* dest, unsigned int length)
 {
@@ -307,2 +293,36 @@
 		return false;
 }
+
+
+void DDrPatch_PrintDisasm(void* addr, int instLimit, int sizeLimit)
+{
+	DISASM MyDisasm;
+	int len = 0;
+	int size = 0;
+	int i = 0;
+
+	memset(&MyDisasm, 0, sizeof(DISASM));
+
+	MyDisasm.EIP = (UIntPtr) addr;
+
+	STARTUPMESSAGE("", 0);
+	STARTUPMESSAGE("Disassembly @ 0x%06x", addr);
+
+	if (sizeLimit <= 0)
+		sizeLimit = 20 * instLimit;
+
+	while ((i < instLimit) && (size < sizeLimit)) {
+		len = Disasm(&MyDisasm);
+		if (len != UNKNOWN_OPCODE) {
+			size += len;
+			STARTUPMESSAGE("    %s, Opcode: 0x%x, len: %d, branch: %d, to: 0x%06x", MyDisasm.CompleteInstr, MyDisasm.Instruction.Opcode, len, MyDisasm.Instruction.BranchType, MyDisasm.Instruction.AddrValue);
+			STARTUPMESSAGE("          Cat: 0x%04x, prefix count: %d", MyDisasm.Instruction.Category & 0xffff, MyDisasm.Prefix.Number );
+
+			MyDisasm.EIP += (UIntPtr)len;
+			i++;
+		}
+	};
+
+	STARTUPMESSAGE("", 0);
+}
+
Index: Daodan/src/Daodan_Patch.h
===================================================================
--- Daodan/src/Daodan_Patch.h	(revision 993)
+++ Daodan/src/Daodan_Patch.h	(revision 994)
@@ -15,6 +15,7 @@
 bool DDrPatch_Int32(int* dest, unsigned int value);
 bool DDrPatch_Int16(short* dest, unsigned short value);
-bool DDrPatch__strdup(int* dest, const char* value);
 bool DDrPatch_NOOP(char* dest, unsigned int length);
 
+void DDrPatch_PrintDisasm(void* addr, int instLimit, int sizeLimit);
+
 #endif
Index: Daodan/src/Daodan_Persistence.c
===================================================================
--- Daodan/src/Daodan_Persistence.c	(revision 993)
+++ 	(revision )
@@ -1,8 +1,0 @@
-#include "Daodan.h"
-#include "Daodan_Persistence.h"
-
-uint8_t ONICALL DDrPersist_GetWonGame()
-{
-	return 1;
-}
-
Index: Daodan/src/Daodan_Persistence.h
===================================================================
--- Daodan/src/Daodan_Persistence.h	(revision 993)
+++ 	(revision )
@@ -1,8 +1,0 @@
-#ifndef DAODAN_PERSISTENCE_H
-#define DAODAN_PERSISTENCE_H
-
-#include "Daodan.h"
-
-uint8_t ONICALL DDrPersist_GetWonGame();
-
-#endif
Index: Daodan/src/Daodan_Utility.c
===================================================================
--- Daodan/src/Daodan_Utility.c	(revision 993)
+++ 	(revision )
@@ -1,169 +1,0 @@
-#include <windows.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-#include "Daodan_Utility.h"
-#include "Oni/Oni.h"
-
-const double fps = 60.0;
-
-void __cdecl DDrStartupMessage(const char* fmt, ...)
-{
-
-	char* buffer;
-	va_list ap;
-	va_start(ap, fmt);
-
-	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;
-}
-
-int64_t ONICALL DDrMachineTime_Sixtieths()
-{
-	static uint32_t startticks = 0;
-	double ticks = 0;
-	
-	if (startticks)
-		ticks = GetTickCount() - startticks;
-	else
-		startticks = GetTickCount();
-	
-	return (int64_t)(ticks / 1000.0 * fps);
-}
-
-int64_t ONICALL DDrMachineTime_High()
-{
-//	LARGE_INTEGER PerfCount;
-//	
-//	if (!QueryPerformanceCounter(&PerfCount))
-//		PerfCount.QuadPart = GetTickCount();
-//	
-//	return PerfCount.QuadPart;
-	return GetTickCount();
-}
-
-double ONICALL DDrMachineTime_High_Frequency()
-{
-//	LARGE_INTEGER Frequency;
-//
-//	if (!QueryPerformanceFrequency(&Frequency))
-		return 1000.0;
-	
-//	return Frequency.QuadPart;
-}
-	
-void ONICALL DDrWeapon2Message(int* weapon, void* output_ptr) 
-{
-	char buffer[128] = {0};
-	char* weapon_string = (char*)(*(weapon + 1)+0x5C);
-	int16_t ammo = *(int16_t *)((int)weapon + 0x56);
-	int16_t maxammo = *(int16_t *)(*(weapon + 1)+0xC0);
-	float ratio = (float)ammo / (float)maxammo;
-	
-	char ammocolor;
-	if		(ratio >= .9)	ammocolor = 'g';
-	else if (ratio >= .5)	ammocolor = 'y';
-	else if (ratio >= .2)	ammocolor = 'o';
-	else					ammocolor = 'r';
-
-	DDrMake_Weapon_Message( weapon_string, buffer); //gets the name of the weapon and formats it...probably doesn't need to be in seperate func.
-	sprintf(SSrMessage_Find("autoprompt_weapon"), "%s |[%c.%i/%i]|", buffer, ammocolor, ammo, maxammo); //copies the new string to ONGS
-	ONiGameState_FindAutoPromptMessage("weapon", output_ptr);	//does what the code i replaced does. Basically tells the game to show the msg.
-}
-
-
-void ONICALL DDrMake_Weapon_Message(char* weapon_string, char* output_ptr) 
-{
-	char* weapon_msg = NULL;	//The normal "You have recieved X" message.
-	char weapon_name[64] = {'\0'};	//The stripped weapon name
-	//TODO, someday: dynamically detect different keybindings.
-	char default_msg[] = "Press [c.Q] to pick up weapon.";	//default return
-	
-	//Find the recieved message string
-	weapon_msg = SSrMessage_Find(weapon_string);
-	//this probably could be reorganized
-	if(weapon_msg) {	//SSrMsgblah returns NULL if it can't find the message key
-		memcpy(weapon_name, weapon_msg, (strstr(weapon_msg,"] ") - weapon_msg + 1)); //strips uneeded characters
-		sprintf(output_ptr, "Press [c.Q] to pick up %s", weapon_name);
-	}
-	else {
-		memcpy(output_ptr, default_msg, sizeof(default_msg));
-	}
-	
-}
-
-typedef struct
-{
-	uint16_t x;
-	uint16_t y;
-
-} IMtPoint2D;
-IMtPoint2D Point = {256, 250};
-extern void* TSrTest;
-extern void* TSrScores;
-unsigned int lastPasteTime;
-
-//TODO: Fix what happens when you hold down paste
-//Check if console is open
-void DDrPasteHack()
-{
-	COtTextArea* cons = *(COtTextArea**)0x00571B74;
-	char* clipboardText = 0;
-	if(ONgGameState->Input.Current.Actions1 & Action_Console && GetKeyState(0x56) & 0x80 && GetKeyState(VK_CONTROL) & 0x80 )
-	{
-		if(cons && cons->text_entries && cons->num_text_entries)
-		{
-			//why abs()? so we dont have to reset the timer after a level load.
-			if( abs(ONgGameState->GameTime - lastPasteTime) > 60) {
-				//DDrConsole_Print(cons->text_entries[0].text);
-				if(OpenClipboard(ONgPlatformData.Window))
-				{
-					unsigned short charsUsed = strlen(cons->text_entries[0].text);
-					//get rid of the v character
-					if(charsUsed) charsUsed--;
-					clipboardText = GetClipboardData(CF_TEXT);
-					if(clipboardText && strlen(clipboardText) + charsUsed < 502)
-					{
-						strcpy( cons->text_entries[0].text + charsUsed, clipboardText);
-						lastPasteTime = ONgGameState->GameTime;
-					}
-					CloseClipboard();
-				}
-
-			}
-			else
-			{
-				//need to hook whatever controls however often you can repeat characters...i guess.
-				//cons->text_entries[0].text[strlen(cons->text_entries[0].text) - 1] = 0;
-			}
-		}
-	}
-}
-
-void ONICALL DDrText_Hook()
-{
-
-	if(TSrTest)
-	{
-		TSrContext_DrawText(TSrTest, "FINALLY THIS BLOODY TEXT THING WORKS\n Gotta call it at the right point...", 128, 0, &Point);	
-
-	}
-
-
-	DDrPasteHack();
-	
-	COrConsole_StatusLine_Display();
-
-}
Index: Daodan/src/Daodan_Utility.h
===================================================================
--- Daodan/src/Daodan_Utility.h	(revision 993)
+++ 	(revision )
@@ -1,19 +1,0 @@
-#ifndef DAODAN_UTILITY_H
-#define DAODAN_UTILITY_H
-
-#include "Daodan.h"
-
-#define WHERESTR  "Daodan [%-22s:%4d ]: "
-#define WHEREARG  __FILE__, __LINE__
-#define DEBUGPRINT2(...)       DDrStartupMessage(__VA_ARGS__)
-#define STARTUPMESSAGE(_fmt, ...)  DEBUGPRINT2(WHERESTR _fmt, WHEREARG, __VA_ARGS__)
-
-
-void __cdecl DDrStartupMessage(const char* fmt, ...);
-int64_t ONICALL DDrMachineTime_High();
-double  ONICALL DDrMachineTime_High_Frequency();
-int64_t ONICALL DDrMachineTime_Sixtieths();
-void ONICALL DDrMake_Weapon_Message(char* weapon_string, char* output_ptr);
-void ONICALL DDrWeapon2Message(int* weapon, void* output_ptr);
-void ONICALL DDrText_Hook();
-#endif
Index: Daodan/src/Daodan_Win32.c
===================================================================
--- Daodan/src/Daodan_Win32.c	(revision 993)
+++ 	(revision )
@@ -1,183 +1,0 @@
-#include <windows.h>
-
-#include "Daodan.h"
-#include "Daodan_Config.h"
-#include "Daodan_Win32.h"
-
-#include "Oni/Oni.h"
-
-
-// LIrPlatform_Terminate wrapper. Removes any cursor clipping we've done. Doing
-// this is required for Windows 98 :-D
-void ONICALL DD_LIrPlatform_Terminate(void)
-{
-	ClipCursor(NULL);
-	LIrPlatform_Terminate();
-}
-
-// LIrPlatform_Mode_Set wrapper. Clips cursor to window bounds to
-// prevent loosing focus (mostly on Linux).
-void ONICALL DD_LIrPlatform_Mode_Set(unsigned int active_mode)
-{
-	DDmAssert(ONgPlatformData.Window);
-
-	if (active_mode)
-	{
-		RECT rc;
-		POINT pt;
-
-		pt.x = 0;
-		pt.y = 0;
-
-		if (GetClientRect(ONgPlatformData.Window, &rc) &&
-			ClientToScreen(ONgPlatformData.Window, &pt))
-		{
-			rc.left   += pt.x;
-			rc.top    += pt.y;
-			rc.right  += pt.x;
-			rc.bottom += pt.y;
-
-			ClipCursor(&rc);
-		}
-	}
-	else
-	{
-		ClipCursor(NULL);
-	}
-
-	LIrPlatform_Mode_Set(active_mode);
-}
-
-BOOL WINAPI DD_GetCursorPos(LPPOINT lpPoint)
-{
-	DDmAssert(ONgPlatformData.Window);
-	
-	return GetCursorPos(lpPoint) && ScreenToClient(ONgPlatformData.Window, lpPoint);
-}
-
-BOOL WINAPI DD_SetCursorPos(int X, int Y)
-{
-	POINT pt;
-	pt.x = X;
-	pt.y = Y;
-	
-	DDmAssert(ONgPlatformData.Window);
-	
-	return ClientToScreen(ONgPlatformData.Window, &pt) && SetCursorPos(pt.x, pt.y);
-}
-
-static LRESULT CALLBACK DD_ONrPlatform_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
-{
-	switch (uMsg)
-	{
-		case WM_SYSCOMMAND:
-			if (wParam == SC_SCREENSAVE)
-			{
-				// Prevent screen saver from starting when Oni has focus.
-				return 0;
-			}
-			break;
-		
-		case WM_PAINT:
-		{
-			PAINTSTRUCT ps;
-			BeginPaint(hWnd, &ps);
-			// Oni does a useless PatBlt here.
-			EndPaint(hWnd, &ps);
-			return 0;
-		}
-		
-		case WM_CLOSE:
-			// There's no way to reliably terminate a modal dialog.
-			// The following condition is (almost) always true.
-			if (WMgActive)
-				exit(0);
-
-			ONgTerminateGame = UUcTrue;
-			return 0;
-			
-		case WM_SETCURSOR:
-			// If a mouse is inside our client area, we hide cursor (always),
-			// otherwise we ask DefWindowProc to set an appropriate arrow for us.
-			if (LOWORD(lParam) == HTCLIENT)
-			{
-				SetCursor(NULL);
-				return TRUE;
-			}
-			
-			break;
-	}
-	
-	return ONrPlatform_WindowProc(hWnd, uMsg, wParam, lParam);
-}
-
-
-UUtError ONICALL DD_ONrPlatform_Initialize(ONtPlatformData *PlatformData)
-{
- 	WNDCLASSEX WndClass;
- 	RECT Rect;
- 	const int Width = 640, Height = 480;
-	DWORD window_style, window_style_ex;
- 
-	PlatformData->Instance = ONgInstance;
-	PlatformData->Window   = NULL;
-	
-	if (FindWindow("ONI ", "ONI "))
-	{
-		AUrMessageBox(1, "Daodan: There is already an instance of the game running.");
-		exit(0);
-	}
-	
-	WndClass.cbSize        = sizeof(WndClass);
-	WndClass.style         = CS_VREDRAW | CS_HREDRAW | CS_OWNDC;
-	WndClass.cbClsExtra    = 0;
-	WndClass.cbWndExtra    = 0;
-	WndClass.hInstance     = PlatformData->Instance;
-	WndClass.hCursor       = NULL; // To debug: LoadCursor(NULL, IDC_ARROW);
-	WndClass.hIcon         = LoadIcon(ONgInstance, MAKEINTRESOURCE(103));
-	WndClass.hIconSm       = LoadIcon(ONgInstance, MAKEINTRESOURCE(103));
-	WndClass.hbrBackground = GetStockObject(BLACK_BRUSH);
-	WndClass.lpszMenuName = NULL;
-	WndClass.lpszMenuName  = NULL;
- 	WndClass.lpszClassName = "ONI ";
-	WndClass.lpfnWndProc   = DD_ONrPlatform_WindowProc;
- 
- 	RegisterClassEx(&WndClass);
- 	
-	if (M3gResolutionSwitch)
-	{
-		// Do not allow border and topmost flag for a fullscreen window.
-		window_style    = WS_POPUP;
-		window_style_ex = 0;
-	}
-	else
-	{
-		ConfigOption_t* co = DDrConfig_GetOptOfType("options.border", C_BOOL);
-		int opt_border = 0;
-		if (co && co->value.intBoolVal)
-			opt_border = 1;
-		co = DDrConfig_GetOptOfType("options.topmost", C_BOOL);
-		int opt_topmost = 0;
-		if (co && co->value.intBoolVal)
-			opt_topmost = 1;
-
-		window_style    = (opt_border) ? WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_DLGFRAME | WS_MINIMIZEBOX : WS_POPUP;
-		window_style_ex = (opt_topmost) ? WS_EX_TOPMOST : 0;
-	}
-	
- 	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;
-	AdjustWindowRectEx(&Rect, window_style, FALSE, window_style_ex);
-	
-	PlatformData->Window = CreateWindowEx(window_style_ex, WndClass.lpszClassName, "ONI ", window_style,
-		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);
- 
-	return UUcError_None;
- }
-
Index: Daodan/src/Daodan_Win32.h
===================================================================
--- Daodan/src/Daodan_Win32.h	(revision 993)
+++ 	(revision )
@@ -1,13 +1,0 @@
-#ifndef DAODAN_WIN32_H
-#define DAODAN_WIN32_H
-
-#include "Daodan.h"
-#include "Oni/Oni.h"
-
-UUtError ONICALL DD_ONrPlatform_Initialize(ONtPlatformData *PlatformData);
-BOOL WINAPI DD_GetCursorPos(LPPOINT lpPoint);
-BOOL WINAPI DD_SetCursorPos(int X, int Y);
-void ONICALL DD_LIrPlatform_Mode_Set(unsigned int active_mode);
-void ONICALL DD_LIrPlatform_Terminate(void);
-
-#endif
Index: Daodan/src/Inifile_Reader.h
===================================================================
--- Daodan/src/Inifile_Reader.h	(revision 993)
+++ Daodan/src/Inifile_Reader.h	(revision 994)
@@ -4,7 +4,7 @@
 #include "stdint.h"
 
-typedef void (*inifile_callback)(char* section, char* name, char* value);
+typedef void (*inifile_callback)(const char* section, const char* name, const char* value);
 
-bool Inifile_Read(const char* filename, inifile_callback callback);
+bool Inifile_Read(const char* filename, const inifile_callback callback);
 
 #endif
Index: Daodan/src/Oni/Symbols_Var.h
===================================================================
--- Daodan/src/Oni/Symbols_Var.h	(revision 993)
+++ Daodan/src/Oni/Symbols_Var.h	(revision 994)
@@ -12,5 +12,5 @@
 
 // Option "debug" ... but what does it do?
-#define AKgDebug_DebugMaps	(*((onibool*)0x002b2204))
+#define AKgDebug_DebugMaps	(*((onibool*)0x006b2204))
 
 // Option "debugfiles" ... but what does it do?
Index: Daodan/src/Patches/BSL.c
===================================================================
--- Daodan/src/Patches/BSL.c	(revision 994)
+++ Daodan/src/Patches/BSL.c	(revision 994)
@@ -0,0 +1,772 @@
+#include <stdio.h>
+#include "stdint.h"
+#include <time.h>
+#include <math.h>
+
+#include "BSL.h"
+#include "Utility.h"
+#include "../Daodan_Patch.h"
+#include "Console.h"
+
+#include "../Oni/Oni.h"
+
+#include "Character.h"
+
+
+uint16_t ONICALL bsl_int32mul(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
+{
+	ret->val.value_int32 = args[0].val.value_int32 * args[1].val.value_int32;
+	ret->type = sl_int32;
+	return 0;
+}
+
+uint16_t ONICALL bsl_mul(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
+{
+	double val1;
+	double val2;
+	
+	if (args[0].type == sl_int32)
+		val1 = args[0].val.value_int32;
+	else
+		val1 = args[0].val.value_float;
+	
+	if (args[1].type == sl_int32)
+		val2 = args[1].val.value_int32;
+	else
+		val2 = args[1].val.value_float;
+	
+	ret->val.value_float = (float)(val1 * val2);
+	ret->type = sl_float;
+	return 0;
+}
+
+uint16_t ONICALL bsl_int32div(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
+{
+	ret->val.value_int32 = args[0].val.value_int32 / args[1].val.value_int32;
+	ret->type = sl_int32;
+	return 0;
+}
+uint16_t ONICALL bsl_div(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
+{
+	double val1;
+	double val2;
+	
+	if (args[0].type == sl_int32)
+		val1 = args[0].val.value_int32;
+	else
+		val1 = args[0].val.value_float;
+	
+	if (args[1].type == sl_int32)
+		val2 = args[1].val.value_int32;
+	else
+		val2 = args[1].val.value_float;
+	
+	ret->val.value_float = (float)(val1 / val2);
+	ret->type = sl_float;
+	return 0;
+}
+
+uint16_t ONICALL bsl_int32rand(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
+{
+	int32_t start = 0;
+	int32_t end = 0;
+	
+	if (args[0].val.value_int32 == args[1].val.value_int32)
+		return 1;
+	else if (args[0].val.value_int32 > args[1].val.value_int32)
+	{
+		start = args[1].val.value_int32;
+		end = args[0].val.value_int32;
+	}
+	else
+	{
+		start = args[0].val.value_int32;
+		end = args[1].val.value_int32;
+	}
+
+	ret->val.value_int32 = start + (rand() % (uint32_t)(end - start + 1));
+	ret->type = sl_int32;
+	return 0;
+}
+
+uint16_t ONICALL bsl_getkills(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
+{
+	int index;
+	if (numargs == 0) index = 0;
+	else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
+	else index = args[0].val.value_int32;
+	//killcount = ONgGameState->CharacterStorage[index].Kills;
+		//ONgGameState + index * 0x16A0 + 0x1260 + 0x1670;
+	ret->val.value_int32 = ONgGameState->CharacterStorage[index].Kills;
+	ret->type = sl_int32;
+	return 0;
+}
+
+uint16_t ONICALL bsl_getdamage(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
+{
+	int index;
+	if (numargs == 0) index = 0;
+	else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
+	else index = args[0].val.value_int32;
+	ret->val.value_int32 = ONgGameState->CharacterStorage[index].Damage;
+	ret->type = sl_int32;
+	return 0;
+}
+
+
+
+uint16_t ONICALL bsl_powerup(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
+{
+	int index;
+	void* returnval;
+	bool is_lsi = 0;
+	Character* Chr = ONgGameState->CharacterStorage;
+
+	if (numargs < 2 || args[1].type != sl_str32) return 1;
+	else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
+	else index = args[0].val.value_int32;
+
+	
+
+	if(!strcmp(args[1].val.value_str32,"ammo")) 
+	{
+		returnval = &(Chr[index].Inventory.AmmoUsed);
+	}
+	else if(!strcmp(args[1].val.value_str32,"hypo")) 
+	{
+		returnval = &(Chr[index].Inventory.HypoUsed);
+	}
+	else if(!strcmp(args[1].val.value_str32,"cells")) 
+	{
+		returnval = &(Chr[index].Inventory.CellsUsed);
+	}
+	else if(!strcmp(args[1].val.value_str32,"invis")) 
+	{
+		returnval = &(Chr[index].Inventory.CloakUsed);
+	}
+	else if(!strcmp(args[1].val.value_str32,"shield")) 
+	{
+		returnval = &(Chr[index].Inventory.ShieldUsed);
+	}
+	else if(!strcmp(args[1].val.value_str32,"lsi")) 
+	{
+		returnval = &(Chr[index].Inventory.hasLSI);
+		is_lsi = 1;
+	}
+//	else if(!strcmp(args[1].value_str32,"bossshield")) 
+//	{
+//		ret->value_int32 = Chr[index].Flags & char_bossshield;
+//		ret->type = sl_int32;
+//		if (numargs >=3) {
+//			if (Chr[index].Flags & char_bossshield) Chr[index].Flags = Chr[index].Flags & ~char_bossshield;
+//			else Chr[index].Flags = Chr[index].Flags | char_bossshield;
+//		}
+//		return 0;
+//	}
+	else return 1;
+	//todo, add setting
+	
+	if(is_lsi) ret->val.value_int32 = (int)*(bool*)returnval;
+	else	ret->val.value_int32 = *(int*)returnval;
+	ret->type = sl_int32;
+
+	if (numargs >= 3) 
+	{
+		if(is_lsi) *(bool*)returnval = args[2].val.value_int32;
+		else *(int*)returnval = args[2].val.value_int32;
+	}
+	
+	
+	return 0;
+}
+
+uint16_t ONICALL bsl_health(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
+{
+	int index;
+	Character* Chr;
+	int* health;
+	if (numargs == 0) index = 0;
+	else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
+	else index = args[0].val.value_int32;
+	Chr = ONgGameState->CharacterStorage;
+	health = &Chr[index].Health;
+
+	ret->val.value_int32 = *health;
+	ret->type = sl_int32;
+
+	if (args[1].val.value_int32) {
+		*health = args[1].val.value_int32;
+	}
+	ret->val.value_int32 = *health;
+	ret->type = sl_int32;
+	return 0;
+}
+
+uint16_t ONICALL bsl_regen(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
+{
+	int index;
+	Character* Chr;
+	if (numargs == 0) index = 0;
+	else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
+	else index = args[0].val.value_int32;
+	Chr = ONgGameState->CharacterStorage ;
+	
+	
+	/*
+	DDrConsole_PrintF("Character %s", Chr[index].Name);
+	DDrConsole_PrintF("Spawn %s", Chr[index].ScriptSpawn);
+	DDrConsole_PrintF("Death %s", Chr[index].ScriptDie);
+	DDrConsole_PrintF("Aware %s", Chr[index].ScriptAware);
+	DDrConsole_PrintF("Alarm %s", Chr[index].ScriptAlarm);
+	DDrConsole_PrintF("Hurt %s", Chr[index].ScriptHurt);
+	DDrConsole_PrintF("Defeat %s", Chr[index].ScriptDefeat);
+	DDrConsole_PrintF("NoAmmo %s", Chr[index].ScriptNoAmmo);
+	DDrConsole_PrintF("NoPath %s", Chr[index].ScriptNoPath);
+	*/
+	ret->val.value_int32 = Chr[index].RegenHax;
+	ret->type = sl_int32;
+
+	if (numargs >= 2) {
+		Chr[index].RegenHax = args[1].val.value_int32;
+	}
+	return 0;
+}
+
+//wow this is broken.
+uint16_t ONICALL bsl_distance(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) {
+	int index;
+	int index2;
+	Character* Chr = ONgGameState->CharacterStorage;
+	Character* Char1;
+	Character* Char2;
+
+	if (numargs < 2) return 1;
+
+	if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
+	else index = args[0].val.value_int32;
+	if (index == -1) index = args[0].val.value_int32;
+
+	if (args[1].type == sl_str32) index2 = DDrGetCharacterIndexFromName(args[1].val.value_str32);
+	else index2 = args[1].val.value_int32;
+	if (index2 == -1) index2 = args[1].val.value_int32;
+		Char1 = &Chr[index];
+	Char2 = &Chr[index2];
+
+
+	ret->val.value_float = sqrt( pow((Char1->Location.X - Char2->Location.X), 2) + pow((Char1->Location.Y - Char2->Location.Y), 2) + pow((Char1->Location.Z - Char2->Location.Z),2));
+	ret->type = sl_float;
+	return 0;
+}
+uint16_t ONICALL bsl_location(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) {
+	int index, i;
+	float* loc;
+	Character* Chr;
+		numargs = 0;
+	for(i = 0; args[i].type < sl_void; i++)
+	{
+		numargs++;
+	}
+
+
+	if (numargs < 2) return 1;
+	if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
+	else index = args[0].val.value_int32;
+	if (index == -1) index = args[0].val.value_int32;
+	Chr = ONgGameState->CharacterStorage;
+	if(numargs == 3)
+	{
+		if (!strcmp(args[1].val.value_str32,"X") || !strcmp(args[1].val.value_str32,"x"))
+			loc = &(Chr[index].Position.X);
+		else if (!strcmp(args[1].val.value_str32,"Y") || !strcmp(args[1].val.value_str32,"y"))
+			loc = &(Chr[index].Position.Y);
+		else if (!strcmp(args[1].val.value_str32,"Z") || !strcmp(args[1].val.value_str32,"z"))
+			loc = &(Chr[index].Position.Z);
+	}
+	else if (numargs == 4) {
+		ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]);
+		Chr[index].Location.X = args[1].val.value_float;
+		Chr[index].Location.Y = args[2].val.value_float;
+		Chr[index].Location.Z = args[3].val.value_float;
+		if(Active)
+		{
+			Active->PhyContext->Position = Chr[index].Location;
+		}
+		ret->val.value_float = 1;
+		ret->type = sl_float;
+		return 0;
+	}
+	else return 1;
+	
+	ret->val.value_float = *loc;
+	ret->type = sl_float;
+	
+	if(numargs == 3) {
+		//currently broken, does nothing.
+		*loc = args[2].val.value_float;
+	}
+	return 0;
+}
+
+uint16_t ONICALL bsl_maxhealth(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
+{
+	int index;
+	if (numargs == 0) index = 0;
+	else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
+	else index = args[0].val.value_int32;
+	if(1) {
+	Character* Chr = ONgGameState->CharacterStorage ;
+	int* maxhealth = &Chr[index].MaxHealth;
+	int oldmaxhealth = Chr[index].MaxHealth;
+	int oldhealth = Chr->Health;
+	if (numargs >= 2) {
+		*maxhealth = args[1].val.value_int32;
+	}
+	if (numargs >= 3 && args[2].val.value_bool) {
+		Chr->Health = (int)(((float)args[1].val.value_int32 / (float)oldmaxhealth) * (float)oldhealth);
+	}
+	ret->val.value_int32 = oldmaxhealth;
+	ret->type = sl_int32;
+	return 0;
+	}
+}
+
+uint16_t ONICALL bsl_getattacker(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
+{
+	//broken
+	
+	int index;
+	if (numargs == 0) index = 0;
+	else	if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
+	else index = args[0].val.value_int32;
+	if(1) {
+	Character* Chr = ONgGameState->CharacterStorage;
+	ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]);
+	if (!Active) return 1;
+//	ret->val.value_int32 = Active->LastDamageSourceCharacter;
+	ret->type = sl_int32;
+	return 0;
+	} 
+}
+
+
+
+uint16_t ONICALL bsl_chrname(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
+{
+	int index;
+	char* name;
+
+	if (numargs == 0) index = 0;
+	else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
+	else index = args[0].val.value_int32;
+	if (index == -1) {
+		ret->type = sl_str32;
+		ret->val.value_str32 = "NULL";
+		return 0;
+	}
+	name = (char*)(&ONgGameState->CharacterStorage[index].Name);
+	if (numargs == 2) {
+		strncpy(name, (char*)args[1].val.value_str32, 31);
+	}
+	
+	ret->type = sl_str32;
+	ret->val.value_str32 = name;
+	
+	return 0;
+}
+
+
+uint16_t ONICALL bsl_count(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
+{
+	//testing numargs...
+	ret->type = sl_int32;
+	ret->val.value_int32 = numargs;
+	return 0;
+}
+
+uint16_t ONICALL bsl_dprintcolored(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
+{
+	//TODO: figure out why our implementation of dprint shows after dev mode is turned off
+	RGBA color;
+	RGBA shade;
+	int i;
+	numargs = 0;
+	for(i = 0; args[i].type < sl_void; i++)
+	{
+		numargs++;
+	}
+	if(numargs == 0) return 0;
+	if(numargs > 1 ) color.R = (char)args[1].val.value_int32;
+	else color.R = 255;
+	if(numargs > 2 ) color.G = (char)args[2].val.value_int32;
+	else color.G = 255;
+	if(numargs > 3 ) color.B = (char)args[3].val.value_int32;
+	else color.B = 255;
+	color.A = 0;
+	if(numargs > 5 ) shade.R = (char)args[5].val.value_int32;
+	else shade.R = 0x3F;
+	if(numargs > 6 ) shade.G = (char)args[6].val.value_int32;
+	else shade.G = 0x3F;
+	if(numargs > 7 ) shade.B = (char)args[7].val.value_int32;
+	else shade.B = 0x3F;
+	shade.A = 0; 
+
+	DDrConsole_PrintColored(args[0].val.value_str32, 1, color, shade);
+	return 0;
+}
+
+
+uint16_t ONICALL bsl_nametoindex(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
+{
+
+	ret->type = sl_int32;
+	ret->val.value_int32 = DDrGetCharacterIndexFromName(args[0].val.value_str32);
+
+	return 0;
+}
+
+typedef struct {
+char Name[16];
+int Bit;
+} KeyBit;
+
+KeyBit Actions1[32] = {
+	{"Escape", Action_Escape},
+	{"Console", Action_Console},
+	{"PauseScreen", Action_PauseScreen},
+	{"Cutscene1", Action_Cutscene_1                },
+	{"Cutscene2", Action_Cutscene_2                },
+	{"F4", Action_F4                      },
+	{"F5", Action_F5                        },
+	{"F6", Action_F6                       },
+	{"F7", Action_F7                        },
+	{"F8", Action_F8                        },
+	{"StartRecord", Action_StartRecord        },       
+	{"StopRecord", Action_StopRecord            },    
+	{"PlayRecord", Action_PlayRecord              },  
+	{"F12", Action_F12                       },
+	{"Unknown1", Action_Unknown1               },  
+	{"LookMode", Action_LookMode           },
+	{"Screenshot", Action_Screenshot         },     
+	{"Unknown2", Action_Unknown2              },
+	{"Unknown3", Action_Unknown3              },   
+	{"Unknown4", Action_Unknown4                },
+	{"Unknown5", Action_Unknown5                },
+	{"Forward", Action_Forward                 },
+	{"Backward", Action_Backward                },
+	{"TurnLeft", Action_TurnLeft                },
+	{"TurnRight", Action_TurnRight               },
+	{"StepLeft", Action_StepLeft                },
+	{"StepRight", Action_StepRight               },
+	{"Jump", Action_Jump                    },
+	{"Crouch", Action_Crouch                  },
+	{"Punch",Action_Punch                   },
+	{"Kick", Action_Kick                    },
+	{"Block", Action_Block                   }
+};
+
+KeyBit Actions2[9] = {
+	{"Walk", Action2_Walk},
+	{"Action", Action2_Action},
+	{"Hypo", Action2_Hypo},
+	{"Reload", Action2_Reload                },
+	{"Swap", Action2_Swap                },
+	{"Drop", Action2_Drop                     },
+	{"Fire1", Action2_Fire1                       },
+	{"Fire2", Action2_Fire2                       },
+	{"Fire3", Action2_Fire3                       }
+};
+uint16_t ONICALL bsl_holdkey(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
+{
+	uint32_t index;
+	uint32_t i = 2;
+	uint32_t j = 0;
+	int Input1 = 0;
+	int Input2 = 0;
+	Character* Chr;
+	ActiveCharacter* Active;
+	if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
+	else index = args[0].val.value_int32;
+
+	Chr = &(ONgGameState->CharacterStorage[index]);
+	Active = ONrGetActiveCharacter(Chr);
+	if (!Active) return 1;
+
+	for(i = 1; i < numargs - 1; i++) {
+		for(j = 0; j < 32; j++) {
+			if(!strcmp(args[i].val.value_str32, Actions1[j].Name)) {
+				Input1 = Input1 | Actions1[j].Bit;
+			}
+		}
+		for(j = 0; j < 9; j++) {
+			if(!strcmp(args[i].val.value_str32, Actions2[j].Name)) { 
+				Input2 = Input2 | Actions2[j].Bit;
+			}
+		}
+	}
+	Active->Input.Current.Actions1 = Active->Input.Current.Actions1 | Input1;
+	Active->Input.Current.Actions2 = Active->Input.Current.Actions2 | Input2;
+	if( Input1 + Input2 == 0 ) {
+		DDrConsole_PrintF("Func \"%s\", File \"%s\", Line %d: semantic error, \"%s\": No valid keys given.", callinfo->name, callinfo->calllocation, callinfo->linenumber, callinfo->name);
+		return 0;
+	}
+	if (  args[numargs - 1].val.value_int32 <= 0) {
+		return 0;
+	}
+	else {
+		 args[numargs - 1].val.value_int32 -= 1;
+		*dontuse2 = 1;
+		*dontuse1 = 1;
+	}
+	return 0;
+}
+	
+uint16_t ONICALL bsl_isheld(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
+	{
+//		int index;
+//		if (numargs < 4) index = 0;
+//		else	if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
+//		else index = args[0].val.value_int32;
+
+//		Character* Chr = ONgGameState->CharacterStorage;
+//	ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]);
+//	if ((int)Active == 0) return 1;
+	uint32_t i = 2;
+	uint32_t j = 0;
+	int Input1 = 0;
+	int Input2 = 0;
+	for(i = 0; i < numargs; i++) {
+		for(j = 0; j < 32; j++) {
+			//DDrConsole_PrintF("Testing %s against %s 0x%x", args[i].val.value_str32, Actions1[j].Name, Actions1[j].Bit);
+			if(!strcmp(args[i].val.value_str32, Actions1[j].Name)) {
+				Input1 = Input1 | Actions1[j].Bit;
+				//DDrConsole_PrintF("Success!");
+			}
+			
+		}
+		for(j = 0; j < 9; j++) {
+			if(!strcmp(args[i].val.value_str32, Actions2[j].Name)) Input2 = Input2 | Actions2[j].Bit;
+	
+		}
+		}
+	//DDrConsole_PrintF("Testing: 0x%x Input: 0x%x",Input1, *(int*)(ONgGameState + 0xB8 + 0x10));
+	ret->val.value_int32 = 0;
+	ret->type = sl_int32;
+	if ( (ONgGameState->Input.Current.Actions1 == Input1)  && (ONgGameState->Input.Current.Actions2 == Input2)) ret->val.value_int32 = 1;
+	return 0;
+}
+
+uint16_t ONICALL bsl_waitforkey(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
+	{
+//		int index;
+//		if (numargs < 4) index = 0;
+//		else	if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
+//		else index = args[0].val.value_int32;
+
+//		Character* Chr = ONgGameState->CharacterStorage;
+//	ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]);
+//	if ((int)Active == 0) return 1;
+
+	int i = 2;
+	int j = 0;
+	int Input1 = 0;
+	int Input2 = 0;
+/*
+	numargs = 0;
+	for(i = 0; args[i].type <= sl_void; i++)
+	{
+		//DDrConsole_PrintF("%i", args[i].type );
+		numargs++;
+
+	}
+	if(numargs < 1 || args[0].val.value == 0)  return;
+	//for(i = 0; i < numargs; i++) {
+	*/
+	i = 0;
+		for(j = 0; j < 32; j++) {
+			//DDrConsole_PrintF("Testing %s against %s 0x%x", args[i].val.value_str32, Actions1[j].Name, Actions1[j].Bit);
+			if(!strcmp(args[i].val.value_str32, Actions1[j].Name)) {
+				Input1 = Input1 | Actions1[j].Bit;
+				//DDrConsole_PrintF("Success!");
+			}
+			
+		}
+		for(j = 0; j < 9; j++) {
+			if(!strcmp(args[i].val.value_str32, Actions2[j].Name)) Input2 = Input2 | Actions2[j].Bit;
+	
+		}
+	//	}
+	DDrConsole_PrintF("Waiting...");
+	if ( 
+		(( ONgGameState->Input.Current.Actions1 & Input1) == Input1)  && 
+		(( ONgGameState->Input.Current.Actions2 & Input2) == Input2) 
+	)
+	{
+	DDrConsole_PrintF("Found key!");
+	}
+	else {
+	//else (int)*ret = 1;
+	*dontuse2 = 1;
+	*dontuse1 = 1;
+	}
+	return 0;
+}
+
+
+uint16_t ONICALL bsl_sprintf(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
+{
+	char output[1024];
+	char buffer[1024];
+	unsigned int i;
+	char* placeinoutput = output;
+	char* placeininput = args[0].val.value_str32;
+	int formatnum = 0;
+	//fix the broken bsl numargs...
+	numargs = 0;
+	
+	for(i = 0; args[i].type < sl_void; i++)
+	{
+		numargs++;
+	}
+	
+	
+	if (numargs < 1)
+		return 1;
+	
+	while(1)
+	{
+		int size;
+		//s is the pointer to the args
+		char* s = strchr(placeininput , '%');
+		//we didnt find a %, break!
+		if(!s)
+		{
+			strcpy(placeinoutput, placeininput);
+			break;
+		}
+		size = (int)s - (int)placeininput ;
+		//we found one, so copy the portion of string
+		
+
+		
+		memcpy( placeinoutput,placeininput, size);
+		placeininput += size;
+		placeinoutput += size;
+
+		memset( placeinoutput, '%', (int)pow(2, formatnum));
+		placeinoutput += (int)pow(2, formatnum);
+
+
+		placeininput += 1;
+		*placeinoutput = 0;
+		formatnum++;
+		
+	}
+
+	for(i = 1; i < numargs; i++)	{
+		//sprintf(output, output, args[i].value_str32);
+		memcpy(buffer, output, 1024);
+		if(args[i].val.value == 0) break;
+		switch(args[i].type)
+		{
+		case sl_bool:
+		case sl_int32:
+			sprintf(output, buffer, args[i].val.value_int32);
+			break;
+		case sl_float:
+			sprintf(output, buffer, args[i].val.value_float);
+			break;
+		case sl_str32:
+			sprintf(output, buffer, args[i].val.value_str32);
+			break;
+		case sl_void:
+		default:
+			break;
+		}	
+	}
+	ret->val.value_str32 = output;
+	ret->type = sl_str32;
+	return 0;
+}
+
+// Widescreen patch for talking heads.
+uint16_t ONICALL cinematic_start_patch(sl_callinfo* callinfo, unsigned int numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
+{
+	args[1].val.value_int32 = (double)args[1].val.value_int32 / (double)(gl->DisplayMode.Width) * (4.0 / 3.0 * (double)(gl->DisplayMode.Height));
+	return ((sl_func)(OniExe + 0x000f3830))(callinfo, numargs, args, dontuse1, dontuse2, ret);
+}
+
+void ONICALL SLrDaodan_Register_ReturnType(char* name, char* desc, char* argfmt, sl_type type, sl_func callback) {
+	char argfmt2[512];
+	uint16_t errornum;
+	if (argfmt && strlen(argfmt) < 507) {
+		sprintf(argfmt2, "%s [|]", argfmt);
+		errornum = SLrScript_Command_Register_ReturnType(name, desc, argfmt2, type, callback);
+		if(errornum)
+		{
+			STARTUPMESSAGE("Registration of script command %s failed with error %i", name, errornum);
+		}
+	} else {
+		STARTUPMESSAGE("Registration of script command %s failed because of a too long argfmt", name);
+	}
+}
+
+void* TSrTest = 0;
+uint16_t ONICALL new_text(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
+{
+	void* TSFFTahoma;
+
+	if(!TSrTest){
+		TMrInstance_GetDataPtr( 'TSFF', "Tahoma", &TSFFTahoma);
+		TSrContext_New( TSFFTahoma, 7, 1, 1,  0, &TSrTest);
+	}
+	DDrPatch_MakeCall((void*)0x004FBCEA, (void*)DDrText_Hook);
+	
+	*dontuse2 = 1;
+	return 0;
+}
+
+void SLrDaodan_Initialize()
+{
+// 	SLrConfig();
+
+	SLrScript_Command_Register_Void("debug_daodan","Adds text to screen", "", new_text);
+
+	SLrScript_Command_Register_ReturnType("int32mul", "Multiplies two numbers", "n1:int n2:int", sl_int32, bsl_int32mul);
+	SLrScript_Command_Register_ReturnType("mul", "Multiplies two numbers", "[int1:int|float1:float] [int2:int|float2:float]", sl_float, bsl_mul);
+	SLrScript_Command_Register_ReturnType("int32div", "Divides two numbers", "n1:int n2:int", sl_int32, bsl_int32div);
+	SLrScript_Command_Register_ReturnType("div", "Divides two numbers", "[int1:int|float1:float] [int2:int|float2:float]", sl_float, bsl_div);
+	srand((uint32_t)time(NULL));
+	SLrScript_Command_Register_ReturnType("int32rand", "Returns a pseudo-random number between two numbers (inclusive).", "start:int end:int", sl_int32, bsl_int32rand);
+	SLrScript_Command_Register_ReturnType("d_getkills","Gets the number of kills a character has", "[ai_name:string | script_id:int] [|]", sl_int32, bsl_getkills);
+	SLrScript_Command_Register_ReturnType("d_getdamage","Gets the amount of damage a character has caused", "[ai_name:string | script_id:int]", sl_int32, bsl_getdamage);
+	SLrScript_Command_Register_ReturnType("d_name","Gets or sets a character's name", "[ai_name:string | script_id:int] [newname:string|]", sl_str32, bsl_chrname);
+	SLrScript_Command_Register_ReturnType("d_getindex","Converts a character's name to its index", "ai_name:string", sl_int32, bsl_nametoindex);
+	SLrScript_Command_Register_ReturnType("d_health","Gets or sets a character's health", "[ai_name:string | script_id:int] [newhealth:int]", sl_str32, bsl_health);
+	SLrScript_Command_Register_ReturnType("d_regen","Gets or sets a character's regeneration abilities", "[ai_name:string | script_id:int] [newhealth:int]", sl_str32, bsl_regen);
+	SLrScript_Command_Register_ReturnType("d_maxhealth","Gets or sets a character's maximum health", "[ai_name:string | script_id:int] [newmaxhealth:int] [scalehealth:bool]", sl_str32, bsl_maxhealth);
+	SLrScript_Command_Register_ReturnType("d_powerup","Gets or sets a character's powerups", "[ai_name:string | script_id:int] powerup:string", sl_int32, bsl_powerup);
+	//d_holdkey is broken!
+	SLrScript_Command_Register_ReturnType("d_holdkey","Makes a character hold a key", "[ai_name:string | script_id:int] frames:int keys:string", sl_int32, bsl_holdkey);
+	SLrScript_Command_Register_ReturnType("d_isheld","Checks if player is holding a key", "[ai_name:string | script_id:int] [keys:string]", sl_int32, bsl_isheld);
+	SLrScript_Command_Register_ReturnType("d_location","Returns the X, Y or Z coord of a character", "", sl_float, bsl_location);
+	SLrScript_Command_Register_ReturnType("d_distance","Returns the distance between two characters", "ai_name:string | script_id:int ai_name:string | script_id:int", sl_float, bsl_distance);
+	SLrScript_Command_Register_Void("d_waitforkey","Waits for a keypress from the player", "key:string", bsl_waitforkey);
+
+	//broken, only works for one damage type.
+	//SLrDaodan_Register_ReturnType("d_getattacker","Gets the last person to hurt a character", "[ai_name:string | script_id:int]", sl_int32, bsl_getattacker);
+	
+	//used for debugging.
+//	SLrDaodan_Register_ReturnType("d_active","Returns a hex offset. ;)", "[ai_name:string | script_id:int]", sl_int32, bsl_getactiveoffset);
+
+	SLrScript_Command_Register_Void("sprintf", "C-style sprintf.", "", bsl_sprintf);
+	SLrScript_Command_Register_ReturnType("st", "Prints to console in color", "", sl_void, bsl_dprintcolored);
+	SLrScript_Command_Register_ReturnType("d_dprint", "Prints to console in color", "", sl_void, bsl_dprintcolored);
+
+	SLrGlobalVariable_Register_Int32("show_triggervolumes", "Show trigger volumes", &OBJgTriggerVolume_Visible);
+}
+
+// Patch for cinematic_start to work on widescreen resolutions
+void SLrDaodan_Patch()
+{
+	DDrPatch_Int32((int*)(OniExe + 0x000f3755), (int)cinematic_start_patch);
+}
Index: Daodan/src/Patches/BSL.h
===================================================================
--- Daodan/src/Patches/BSL.h	(revision 994)
+++ Daodan/src/Patches/BSL.h	(revision 994)
@@ -0,0 +1,7 @@
+#ifndef BSL_H
+#define BSL_H
+
+void SLrDaodan_Initialize();
+void SLrDaodan_Patch();
+
+#endif
Index: Daodan/src/Patches/Character.c
===================================================================
--- Daodan/src/Patches/Character.c	(revision 994)
+++ Daodan/src/Patches/Character.c	(revision 994)
@@ -0,0 +1,31 @@
+#include <stdlib.h>
+#include "Character.h"
+
+#include "../Oni/Oni.h"
+
+int DDr_TeamToTeamID(const char* team_string) //Already something like this in the engine, but I'm reimplementing it...
+{
+	if (!strcmp(team_string, "Konoko"))                  return team_konoko;
+	else if (!strcmp(team_string, "TCTF"))               return team_tctf;
+	else if (!strcmp(team_string, "Syndicate"))          return team_syndicate;
+	else if (!strcmp(team_string, "Neutral"))            return team_neutral;
+	else if (!strcmp(team_string, "SecurityGuard"))      return team_securityguard;
+	else if (!strcmp(team_string, "RogueKonoko"))        return team_roguekonoko;
+	else if (!strcmp(team_string, "Switzerland"))        return team_switzerland;
+	else if (!strcmp(team_string, "SyndicateAccessory")) return team_syndicateaccessory;
+	return team_neutral; //if you enter a bad teamname, return Neutral.....
+}
+
+uint32_t DDrGetCharacterIndexFromName(char* input) {
+	int i;
+	Character **characterlist = ONgGameState->PresentCharacterList;								//pointer to array of Character pointers
+	int total_characters = ONgGameState->PresentCharacterListCount;		//Max number of characters
+	for(i = 0; i < total_characters; i++) {
+		if (characterlist[i] != 0)							//anti Blam!
+			if (!strcmp(characterlist[i]->Name, input)) {	//checks for the same name
+			return characterlist[i]->Number;
+			}
+	}
+	return -1;													//not found :(
+}
+
Index: Daodan/src/Patches/Character.h
===================================================================
--- Daodan/src/Patches/Character.h	(revision 994)
+++ Daodan/src/Patches/Character.h	(revision 994)
@@ -0,0 +1,9 @@
+#ifndef DD_CHARACTER_H
+#define DD_CHARACTER_H
+
+#include "stdint.h"
+
+int DDr_TeamToTeamID(const char* team_string);
+uint32_t DDrGetCharacterIndexFromName(char* );
+
+#endif
Index: Daodan/src/Patches/Cheater.c
===================================================================
--- Daodan/src/Patches/Cheater.c	(revision 994)
+++ Daodan/src/Patches/Cheater.c	(revision 994)
@@ -0,0 +1,296 @@
+#include <string.h>
+#include "stdint.h"
+#include <math.h>
+
+#include "../Oni/Oni.h"
+
+#include "../_Version.h"
+
+#include "../Daodan.h"
+#include "../Daodan_Config.h"
+#include "Cheater.h"
+
+union MSVC_EVIL_FLOAT_HACK
+{
+   unsigned __int8 Bytes[4];
+   float Value;
+};
+static union MSVC_EVIL_FLOAT_HACK INFINITY_HACK = {{0x00, 0x00, 0x80, 0x7F}};
+#define DD_INFINITY (INFINITY_HACK.Value)
+
+oniCheatCode DDr_CheatTable[] = {
+	{ "shapeshifter",     "Change Characters Enabled",       "Change Characters Disabled", cheat_shapeshifter     },
+	{ "liveforever",      "Invincibility Enabled",           "Invincibility Disabled",     cheat_liveforever      },
+	{ "touchofdeath",     "Omnipotence Enabled",             "Omnipotence Disabled",       cheat_touchofdeath     },
+	{ "canttouchthis",    "Unstoppable Enabled",             "Unstoppable Disabled",       cheat_canttouchthis    },
+	{ "fatloot",          "Fat Loot Received",               NULL,                         cheat_fatloot          },
+	{ "glassworld",       "Glass Furniture Enabled",         "Glass Furniture Disabled",   cheat_glassworld       },
+	{ "winlevel",         "Instantly Win Level",             NULL,                         cheat_winlevel         },
+	{ "loselevel",        "Instantly Lose Level",            NULL,                         cheat_loselevel        },
+	{ "bighead",          "Big Head Enabled",                "Big Head Disabled",          cheat_bighead          },
+	{ "minime",           "Mini Mode Enabled",               "Mini Mode Disabled",         cheat_minime           },
+	{ "superammo",        "Super Ammo Mode Enabled",         "Super Ammo Mode Disabled",   cheat_superammo        },
+	{ "thedayismine",     "Developer Access Enabled",        "Developer Access Disabled",  cheat_thedayismine     },
+	{ "reservoirdogs",    "Last Man Standing Enabled",       "Last Man Standing Disabled", cheat_reservoirdogs    },
+	{ "roughjustice",     "Gatling Guns Enabled",            "Gatling Guns Disabled",      cheat_roughjustice     },
+	{ "chenille",         "Daodan Power Enabled",            "Daodan Power Disabled",      cheat_chenille         },
+	{ "behemoth",         "Godzilla Mode Enabled",           "Godzilla Mode Disabled",     cheat_behemoth         },
+	{ "elderrune",        "Regeneration Enabled",            "Regeneration Disabled",      cheat_elderrune        },
+	{ "moonshadow",       "Phase Cloak Enabled",             "Phase Cloak Disabled",       cheat_moonshadow       },
+	{ "munitionfrenzy",   "Weapons Locker Created",          NULL,                         cheat_munitionfrenzy   },
+	{ "fistsoflegend",    "Fists Of Legend Enabled",         "Fists Of Legend Disabled",   cheat_fistsoflegend    },
+	{ "killmequick",      "Ultra Mode Enabled",              "Ultra Mode Disabled",        cheat_killmequick      },
+	{ "carousel",         "Slow Motion Enabled",             "Slow Motion Disabled",       cheat_carousel         },
+	{ "bigbadboss",       "Boss Shield Enabled",             "Boss Shield Disabled",       cheat_bigbadboss       },
+	{ "bulletproof",      "Force Field Enabled",             "Force Field Disabled",       cheat_bulletproof      },
+	{ "kangaroo",         "Kangaroo Jump Enabled",	         "Kangaroo Jump Disabled",     cheat_kangaroo         },
+	{ "marypoppins",      "Jet Pack Mode Enabled",           "Jet Pack Mode Disabled",     cheat_marypoppins      },
+	{ "buddha",           "Unkillable Enabled",              "Unkillable Disabled",        cheat_buddha           },
+	{ "shinobi",          "Ninja Mode Enabled (good luck!)", "Ninja Mode Disabled",        cheat_shinobi          },
+	{ "x",                "Developer Access Enabled",        "Developer Access Disabled",  cheat_x                },
+	{ "testcheat",        "Testing...",                      "",                           cheat_testcheat        },
+	{ "tellmetheversion", "Daodan v."DAODAN_VERSION_STRING"",                    "",                           cheat_tellmetheversion },
+	{0, 0, 0, 0}
+};
+
+
+
+// Just copied all these defines from the old daodan, they were originaly from SFeLi's code.
+
+#define GSA_camera        (0x00000080)
+#define GSA_player        (0x000000AC)
+#define GSA_carousel      (0x00000104) /* char */
+#define GSA_slowmotimer   (0x00000108)
+#define GSA_splashscreen  (0x00000118) /* char */
+
+#define CHR_flags         (0x00000004)
+#define CHR_flags2        (0x00000008)
+#define CHR_oncc          (0x0000000C)
+#define CHR_team          (0x00000012) /* short */
+#define CHR_name          (0x00000014) /* char[32] */
+#define CHR_scalemodel    (0x00000034)
+#define CHR_weapon1       (0x00000194)
+#define CHR_weapon2       (0x00000198)
+#define CHR_weapon3       (0x0000019C)
+#define CHR_shield_curr   (0x000001B6) /* short */
+#define CHR_shield        (0x000001B8) /* short */
+#define CHR_phasecloak    (0x000001BA) /* short */
+#define CHR_stats_kills   (0x00001670)
+#define CHR_stats_damage  (0x00001674)
+
+#define ONCC_jet_accel    (0x00000010) /* float */
+#define ONCC_jet_timer    (0x00000016) /* short */
+#define ONCC_height1      (0x00000018) /* float */
+#define ONCC_height2      (0x0000001C) /* float */
+#define ONCC_bodysize_min (0x00000C58) /* float */
+#define ONCC_bodysize_max (0x00000C8C) /* float */
+
+#define kangaroo_h     (short)(60)
+#define kangaroo_jp    (float)(0.06)
+#define marypoppins_jp (float)(0.14)
+
+uint16_t cheat_oldshield = 0;
+int32_t cheat_oldhealth = 1;
+int32_t cheat_oldmaxhealth = 1;
+float cheat_oldjet_accel = 0.03f;
+uint16_t cheat_oldjet_timer = 20;
+float cheat_oldheight1 = 45;
+float cheat_oldheight2 = 135;
+bool inc_fallingframes = true;
+
+uint8_t ONICALL DDrCheater(uint32_t cheat)
+{
+	switch (cheat)
+	{
+		case cheat_bigbadboss:
+		{
+			Character* player = ONgGameState->PlayerCharacter;
+			//char* player = *((char**)(ONgGameState + GSA_player));
+			if (player->Flags & chr_bossshield)
+			{
+				player->Flags = player->Flags & ~chr_bossshield;
+				return 0;
+			}
+			else
+			{
+				player->Flags = player->Flags | chr_bossshield;
+				return 1;
+			}
+		}
+		case cheat_bulletproof:
+		{
+			Character* player = ONgGameState->PlayerCharacter;
+			if (player->Flags  & chr_weaponimmune)
+			{
+				player->Flags  = player->Flags  & ~chr_weaponimmune;
+				player->Inventory.ShieldUsed  = cheat_oldshield;
+				return 0;
+			}
+			else
+			{
+				player->Flags  |=  chr_weaponimmune;
+				cheat_oldshield = player->Inventory.ShieldUsed;
+				player->Inventory.ShieldUsed = 100;
+				return 1;
+			}
+		}
+		case cheat_kangaroo:
+		{
+			Character* player = ONgGameState->PlayerCharacter;
+			//char* oncc = *(char**)(player + CHR_oncc);
+			if (!inc_fallingframes)
+				inc_fallingframes = true;
+			if (player->ONCC->JetpackTimer == kangaroo_h)
+			{
+				player->ONCC->JumpAcceleration = cheat_oldjet_accel;
+				player->ONCC->JetpackTimer  = cheat_oldjet_timer;
+				player->ONCC->MaxFallingHeightWithoutDamage = cheat_oldheight1;
+				player->ONCC->MaxFallingHeightWithDamage = cheat_oldheight2;
+				return 0;
+			}
+			else if ((unsigned short)player->ONCC->JetpackTimer == 0xFFFF)
+			{
+				player->ONCC->JumpAcceleration = kangaroo_jp;
+				player->ONCC->JetpackTimer  = kangaroo_h;
+				player->ONCC->MaxFallingHeightWithoutDamage = DD_INFINITY;
+				player->ONCC->MaxFallingHeightWithDamage  = DD_INFINITY;
+				return 1;
+			}
+			else
+			{
+				cheat_oldjet_accel = player->ONCC->JumpAcceleration;
+				cheat_oldjet_timer = player->ONCC->JetpackTimer;
+				cheat_oldheight1 = player->ONCC->MaxFallingHeightWithoutDamage ;
+				cheat_oldheight2 = player->ONCC->MaxFallingHeightWithDamage;
+				player->ONCC->JumpAcceleration = kangaroo_jp;
+				player->ONCC->JetpackTimer = kangaroo_h;
+				player->ONCC->MaxFallingHeightWithoutDamage  = DD_INFINITY;
+				player->ONCC->MaxFallingHeightWithDamage  = DD_INFINITY;
+				return 1;
+			}
+		}
+		case cheat_marypoppins:
+		{
+			Character* player = ONgGameState->PlayerCharacter;
+			if (!inc_fallingframes)
+			{
+				inc_fallingframes = true;
+				if ((unsigned short)player->ONCC->JetpackTimer == 0xFFFF)
+				{
+					player->ONCC->JumpAcceleration = cheat_oldjet_accel;
+					player->ONCC->JetpackTimer = cheat_oldjet_timer;
+					player->ONCC->MaxFallingHeightWithoutDamage = cheat_oldheight1;
+					player->ONCC->MaxFallingHeightWithDamage = cheat_oldheight2;
+				}
+				return 0;
+			}
+			else if (player->ONCC->JetpackTimer == kangaroo_h)
+			{
+				player->ONCC->JumpAcceleration = marypoppins_jp;
+				player->ONCC->JetpackTimer = 0xFFFF;
+				player->ONCC->MaxFallingHeightWithoutDamage = 0x7f800000;
+				player->ONCC->MaxFallingHeightWithDamage = 0x7f800000;
+				inc_fallingframes = false;
+				return 1;
+			}
+			else
+			{
+				cheat_oldjet_accel = player->ONCC->JumpAcceleration;
+				cheat_oldjet_timer = player->ONCC->JetpackTimer;
+				cheat_oldheight1 = player->ONCC->MaxFallingHeightWithoutDamage;
+				cheat_oldheight2 = player->ONCC->MaxFallingHeightWithDamage ;
+				player->ONCC->JumpAcceleration = marypoppins_jp;
+				player->ONCC->JetpackTimer = 0xFFFF;
+				player->ONCC->MaxFallingHeightWithoutDamage = 0x7f800000;
+				player->ONCC->MaxFallingHeightWithDamage = 0x7f800000;
+				inc_fallingframes = false;
+				return 1;
+			}
+		}
+		case cheat_buddha:
+		{
+			Character* player = ONgGameState->PlayerCharacter;
+			if (player->Flags& chr_unkillable)
+			{
+				player->Flags= player->Flags& ~chr_unkillable;
+				return 0;
+			}
+			else
+			{
+				player->Flags= player->Flags| chr_unkillable;
+				return 1;
+			}
+		}
+		case cheat_shinobi:
+		{
+			Character* player = ONgGameState->PlayerCharacter;
+			if (player->MaxHealth == 1)
+			{
+				player->Health = cheat_oldhealth;
+				player->MaxHealth = cheat_oldmaxhealth;
+				player->Flags = player->Flags & ~(chr_bossshield | chr_weaponimmune);
+				ai2_deaf = 0;
+				return 0;
+			}
+			else
+			{
+				cheat_oldhealth = player->Health;
+				cheat_oldmaxhealth = player->MaxHealth;
+				player->Health = 1;
+				player->MaxHealth = 1;
+				player->Flags = player->Flags | chr_bossshield | chr_weaponimmune;
+				ai2_deaf = 1;
+				return 1;
+			}
+			
+		}
+		case cheat_testcheat:
+		{
+			Character* player = ONgGameState->PlayerCharacter;
+			player->Flags = player->Flags | chr_noncombatant;
+			return 1;
+		}
+		case cheat_elderrune:
+		{
+			ConfigOption_t* co = DDrConfig_GetOptOfType("patch.bsl", C_BOOL);
+			if (co->value.intBoolVal)
+			{
+				int* Regeneration = &ONgGameState->PlayerCharacter->RegenHax;
+				if(*Regeneration)
+				{
+					*Regeneration = 0;
+					return 0;
+				}
+				else
+				{
+					*Regeneration = 1;
+					return 1;
+				}
+			}
+			else
+			{
+				return ONrCheater(cheat_elderrune);
+			}
+		}
+
+		case cheat_tellmetheversion:
+			return 1;
+		case cheat_x:
+			return ONrCheater(cheat_thedayismine);
+		default:
+			return ONrCheater(cheat);
+	}
+}
+
+void ONICALL DDrCheater_LevelLoad()
+{
+	inc_fallingframes = true;
+}
+
+// Biggest hack in the entire thing ^_^
+void __stdcall FallingFrames(void* Ebp)
+{
+	if (inc_fallingframes)
+		++*((unsigned int*)((char*)Ebp + 0xf6));
+}
+ 
Index: Daodan/src/Patches/Cheater.h
===================================================================
--- Daodan/src/Patches/Cheater.h	(revision 994)
+++ Daodan/src/Patches/Cheater.h	(revision 994)
@@ -0,0 +1,52 @@
+#ifndef CHEATER_H
+#define CHEATER_H
+
+#include "../Daodan.h"
+
+typedef struct {
+    const char* name;
+    const char* message_on;
+    const char* message_off;
+    int func;
+} oniCheatCode;
+
+enum {
+		cheat_shapeshifter,
+		cheat_liveforever,
+		cheat_touchofdeath,
+		cheat_canttouchthis,
+		cheat_fatloot,
+		cheat_glassworld,
+		cheat_winlevel,
+		cheat_loselevel,
+		cheat_bighead,
+		cheat_minime,
+		cheat_superammo,
+		cheat_thedayismine,
+		cheat_reservoirdogs,
+		cheat_roughjustice,
+		cheat_chenille,
+		cheat_behemoth,
+		cheat_elderrune,
+		cheat_moonshadow,
+		cheat_munitionfrenzy,
+		cheat_fistsoflegend,
+		cheat_killmequick,
+		cheat_carousel,
+		cheat_bigbadboss,
+		cheat_bulletproof,
+		cheat_kangaroo,
+		cheat_marypoppins,
+		cheat_buddha,
+		cheat_shinobi,
+		cheat_x,
+		cheat_testcheat,
+		cheat_tellmetheversion,
+};
+
+extern oniCheatCode DDr_CheatTable[];
+uint8_t ONICALL DDrCheater(uint32_t cheat);
+void __stdcall FallingFrames(void* Ebp);
+void ONICALL DDrCheater_LevelLoad();
+
+#endif
Index: Daodan/src/Patches/Console.c
===================================================================
--- Daodan/src/Patches/Console.c	(revision 994)
+++ Daodan/src/Patches/Console.c	(revision 994)
@@ -0,0 +1,52 @@
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include "Console.h"
+#include "../Oni/Oni.h"
+
+void DDrConsole_Print(const char* text)
+{
+	COrTextArea_Print(COgConsoleLines, 1, COgDefaultTextShade, COgDefaultTextShadow, text, 0, COgFadeTimeValue);
+}
+
+void DDrConsole_PrintColored(const char* text, int priority, RGBA color, RGBA shade)
+{
+	int* intcolor = (int*)&color;
+	int* intshade = (int*)&shade;
+	COrTextArea_Print(COgConsoleLines, 1, *intcolor, *intshade, text, 0, COgFadeTimeValue);
+}
+
+void DDrConsole_PrintF(const char* fmt, ...)
+{
+	char* buffer;
+	va_list ap;
+	va_start(ap, fmt);
+	buffer = malloc(vsnprintf(NULL, 0, fmt, ap) + 1);
+	
+	vsprintf(buffer, fmt, ap);
+	va_end(ap);
+
+	DDrConsole_Print(buffer);
+	free(buffer);
+	return;
+}
+
+TStColorFormattingCharacter DDrDSayColors[] = {
+	{'r', 0, 0xFFEB5050},	//red
+	{'y', 0, 0xFFFCFF1C},	//yellow
+	{'b', 0, 0xFF93BBE9},	//blue
+	{'u', 0, 0xFFF67603},	//umber
+	{'g', 0, 0xFFA2DAA5},	//green
+	{'l', 0, 0xFFBE90D9},	//lilac
+	{'o', 0, 0xFFFBA500},	//orange
+	{'c', 0, 0xFF93EAEB},	//cyan
+								//New Colors Here...
+	{'k', 0, 0xFF000000},	//black
+	{'v', 0, 0xFFEB40EB},	//violet
+	{'w', 0, 0xFFFFFFFF},	//white...
+	{'e', 0, 0xFF505050},	//darkgrey
+	{'f', 0, 0xFFAAAAAA},	//grey
+	{0, 0, 0}							//POWER RANGERS GO!
+};
+
+		
Index: Daodan/src/Patches/Console.h
===================================================================
--- Daodan/src/Patches/Console.h	(revision 994)
+++ Daodan/src/Patches/Console.h	(revision 994)
@@ -0,0 +1,36 @@
+#ifndef CONSOLE_H
+#define CONSOLE_H
+
+#include "../Daodan.h"
+
+typedef struct {
+	char B;
+	char G;
+	char R;
+	char A;
+} RGBA;
+
+
+typedef struct {
+	char A;
+	char R;
+	char G;
+	char B;
+} ARGB;
+
+typedef struct {
+	char Char;
+	short ignored;
+	int Color; //ARGB Color;
+} TStColorFormattingCharacter;
+
+extern TStColorFormattingCharacter* TStColorFormattingCharacters;
+extern TStColorFormattingCharacter DDrDSayColors[];
+
+void DDrConsole_Print(const char* text);
+
+void DDrConsole_PrintColored(const char* text, int priority, RGBA color, RGBA shade);
+
+void DDrConsole_PrintF(const char* fmt, ...);
+
+#endif
Index: Daodan/src/Patches/GL.c
===================================================================
--- Daodan/src/Patches/GL.c	(revision 994)
+++ Daodan/src/Patches/GL.c	(revision 994)
@@ -0,0 +1,433 @@
+#include <windows.h>
+#include <math.h>
+#include <GL/gl.h>
+#include <GL/glu.h>
+
+#include "../Oni/Oni.h"
+
+#include "../Daodan_Config.h"
+#include "Utility.h"
+#include "Win32.h"
+#include "GL.h"
+
+static const M3tDisplayMode daodan_reslist[] =
+{
+	{ 640,  480,  0, 0 },
+	{ 720,  480,  0, 0 },
+	{ 720,  576,  0, 0 },
+	{ 768,  480,  0, 0 },
+	{ 800,  480,  0, 0 },
+	{ 800,  600,  0, 0 },
+	{ 852,  480,  0, 0 },
+	{ 856,  480,  0, 0 },
+	{ 960,  540,  0, 0 },
+	{ 960,  720,  0, 0 },
+	{ 1024, 576,  0, 0 },
+	{ 1024, 600,  0, 0 },
+	{ 1024, 640,  0, 0 },
+	{ 1024, 768,  0, 0 },
+	{ 1152, 768,  0, 0 },
+	{ 1152, 864,  0, 0 },
+	{ 1280, 720,  0, 0 },
+	{ 1280, 768,  0, 0 },
+	{ 1280, 800,  0, 0 },
+	{ 1280, 960,  0, 0 },
+	{ 1280, 1024, 0, 0 },
+	{ 1366, 768,  0, 0 },
+	{ 1400, 1050, 0, 0 },
+	{ 1440, 900,  0, 0 },
+	{ 1600, 900,  0, 0 },
+	{ 1600, 1200, 0, 0 },
+	{ 1920, 1080, 0, 0 },
+	{ 1920, 1200, 0, 0 },
+	{ 1920, 1440, 0, 0 },
+};
+
+static DWORD window_style, window_exstyle;
+
+// HACK: use additional device entries to store display modes. It would give us
+// 67 mode slots total (far more than enough). I absolutely have no idea where
+// Rossy got his 104 (it would take up to 0x660 bytes while the whole GL state
+// is only 0x63c bytes). Maybe it was just octal (67 + 1).
+// This hack would break (crash!) "m3_display_list" script command.
+#define DD_MAX_MODES ((offsetof(M3tDrawEngineCaps,__unknown) - \
+						offsetof(M3tDrawEngineCaps,DisplayDevices) - \
+						offsetof(M3tDisplayDevice,Modes)) / sizeof(M3tDisplayMode))
+
+// Former daodan_resdepths.
+#define DD_MIN_DEPTH 16
+
+unsigned short ONICALL DD_GLrEnumerateDisplayModes(M3tDisplayMode* modes)
+{
+	unsigned int vmodes = 0;
+	unsigned int screen_x = GetSystemMetrics(SM_CXSCREEN);
+	unsigned int screen_y = GetSystemMetrics(SM_CYSCREEN);
+	
+	unsigned int i;
+	signed int j;
+	
+	STARTUPMESSAGE("Listing display modes", 0);
+
+	memset(modes, 0, sizeof(M3tDisplayMode) * DD_MAX_MODES);
+
+	if (M3gResolutionSwitch)
+	{
+		// Enumerate in -switch mode. "67 slots ought to be enough for anybody".
+
+		DEVMODE dm;
+
+		dm.dmSize        = sizeof(dm);
+		dm.dmDriverExtra = 0;
+
+		for (i = 0; EnumDisplaySettings(NULL, i, &dm); ++i)
+		{
+			if (dm.dmBitsPerPel < DD_MIN_DEPTH || dm.dmPelsWidth < 640 || dm.dmPelsHeight < 480)
+				continue;
+			if (dm.dmPelsWidth < dm.dmPelsHeight)
+				continue;
+
+			// Already exists? Search backwards as modes are sorted most of the times
+			for (j = vmodes - 1; j >= 0; --j)
+				if (modes[j].Width == dm.dmPelsWidth && modes[j].Height == dm.dmPelsHeight &&
+					modes[j].Depth == dm.dmBitsPerPel)
+					break;
+
+			if (j >= 0)
+				continue; // We've found a match.
+
+			modes[vmodes].Width  = dm.dmPelsWidth;
+			modes[vmodes].Height = dm.dmPelsHeight;
+			modes[vmodes].Depth  = dm.dmBitsPerPel;
+
+			if (++vmodes >= DD_MAX_MODES)
+				break;
+		}
+	}
+	else
+	{
+		// In -noswitch we put predefined window sizes which don't overlap
+		// deskbar(s) plus one "native" fullscreen mode.
+
+		unsigned int workarea_width, workarea_height, frame_width, frame_height;
+		DWORD style, exstyle;
+		RECT rc;
+
+		if (SystemParametersInfo(SPI_GETWORKAREA, 0, &rc, 0))
+		{
+			workarea_width  = rc.right - rc.left;
+			workarea_height = rc.bottom - rc.top;
+		}
+		else
+		{
+			workarea_width  = screen_x;
+			workarea_height = screen_y;
+		}
+
+		style   = (DWORD) GetWindowLongPtr(ONgPlatformData.Window, GWL_STYLE);
+		exstyle = (DWORD) GetWindowLongPtr(ONgPlatformData.Window, GWL_EXSTYLE);
+
+		// Calculate additional width and height for window borders. Don't
+		// bother with system metrics. Let Windows calculate this.
+		rc.left  = rc.top = 0;
+		rc.right = rc.bottom = 300;
+
+		if (AdjustWindowRectEx(&rc, style, FALSE, exstyle))
+		{
+			frame_width  = rc.right - rc.left - 300;
+			frame_height = rc.bottom - rc.top - 300;
+		}
+		else
+		{
+			frame_width  = 0;
+			frame_height = 0;
+		}
+
+		for (i = 0; i < sizeof(daodan_reslist) / sizeof(daodan_reslist[0]); ++i)
+		{
+			// Don't check the mode which has the same rect as screen. We would
+			// add it later as a special case.
+			if (daodan_reslist[i].Width == screen_x && daodan_reslist[i].Height == screen_y)
+				continue;
+			
+			if (daodan_reslist[i].Width + frame_width <= workarea_width &&
+				daodan_reslist[i].Height + frame_height <= workarea_height)
+			{
+				modes[vmodes] = daodan_reslist[i];
+				modes[vmodes].Depth = GLgInitialMode.dmBitsPerPel;
+
+				if (++vmodes >= DD_MAX_MODES)
+				{
+					--vmodes; // Remove the last mode to make room for "fullscreen" mode.
+					break;
+				}
+			}
+		}
+
+		modes[vmodes].Width  = GLgInitialMode.dmPelsWidth;
+		modes[vmodes].Height = GLgInitialMode.dmPelsHeight;
+		modes[vmodes].Depth  = GLgInitialMode.dmBitsPerPel;
+		++vmodes;
+	}
+
+	STARTUPMESSAGE("%u modes available:", vmodes);
+	for (i = 0; i < vmodes; ++i)
+		STARTUPMESSAGE("   %ux%ux%u", modes[i].Width, modes[i].Height, modes[i].Depth);
+
+	return vmodes;
+}
+
+// Sets a new display mode (if it is somehow different from a current mode).
+// NOTE: signature for this function was changed to simplify code.
+UUtBool DD_GLrPlatform_SetDisplayMode(M3tDisplayMode* mode)
+{
+	if (mode->Height < 480)
+		return UUcFalse;
+
+	if (M3gResolutionSwitch)
+	{
+		DEVMODE new_mode, cur_mode;
+
+		cur_mode.dmSize        = sizeof(cur_mode);
+		cur_mode.dmDriverExtra = 0;
+
+		// We don't need this check. Windows does this too (see CDS_RESET).
+		if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &cur_mode) ||
+			cur_mode.dmPelsWidth != mode->Width || cur_mode.dmPelsHeight !=  mode->Height ||
+			cur_mode.dmBitsPerPel != mode->Depth)
+		{
+			new_mode.dmSize       = sizeof(new_mode);
+			new_mode.dmFields     = DM_BITSPERPEL | DM_PELSHEIGHT | DM_PELSWIDTH;
+			new_mode.dmPelsWidth  = mode->Width;
+			new_mode.dmPelsHeight = mode->Height;
+			new_mode.dmBitsPerPel = mode->Depth;
+
+			if (ChangeDisplaySettings(&new_mode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
+				return UUcFalse;
+		}
+		
+		// We didn't change window size in DD_GLrPlatform_Initialize so we need
+		// to change it here.
+		SetWindowPos(ONgPlatformData.Window, NULL, 0, 0, mode->Width, mode->Height,
+			SWP_NOACTIVATE | SWP_NOSENDCHANGING | SWP_NOZORDER);
+
+		return UUcTrue;
+	}
+	else
+	{
+		unsigned screen_x, screen_y;
+		DWORD style, exstyle, new_style, new_exstyle;
+		DWORD flags;
+		RECT rc, workarea_rc;
+		POINT pt;
+
+		screen_x = GetSystemMetrics(SM_CXSCREEN);
+		screen_y = GetSystemMetrics(SM_CYSCREEN);
+
+		GetClientRect(ONgPlatformData.Window, &rc);
+		
+		// Don't do anything if the mode was not changed.
+		if (rc.right == mode->Width && rc.bottom == mode->Height)
+			return UUcTrue;
+
+		style   = (DWORD) GetWindowLongPtr(ONgPlatformData.Window, GWL_STYLE);
+		exstyle = (DWORD) GetWindowLongPtr(ONgPlatformData.Window, GWL_EXSTYLE);
+		flags   = SWP_NOACTIVATE | SWP_NOZORDER;
+
+		// Remember initial window style to correctly restore from fullscreen.
+		if (window_style == 0)
+		{
+			window_style = style;
+			window_exstyle = exstyle;
+		}
+
+		if (mode->Width == screen_x && mode->Height == screen_y)
+		{
+			// "Fullscreen" mode.
+			new_exstyle = exstyle & ~(WS_EX_CLIENTEDGE | WS_EX_DLGMODALFRAME | WS_EX_STATICEDGE | WS_EX_WINDOWEDGE);
+			new_style   = style & ~(WS_CAPTION | WS_BORDER | WS_THICKFRAME | WS_DLGFRAME);
+			new_style   = new_style | WS_POPUP;
+			rc.left     = 0;
+			rc.top      = 0;
+			rc.right    = mode->Width;
+			rc.bottom   = mode->Height;
+		}
+		else
+		{
+			ConfigOption_t* co = DDrConfig_GetOptOfType("options.border", C_BOOL);
+			if (co && co->value.intBoolVal)
+			{
+				pt.x = rc.left;
+				pt.y = rc.top;
+				ClientToScreen(ONgPlatformData.Window, &pt);
+			}
+			else
+			{
+				pt.x = screen_x / 2 - mode->Width / 2;
+				pt.y = screen_y / 2 - mode->Height / 2;
+			}
+
+			new_exstyle = window_exstyle;
+			new_style   = window_style;
+			rc.left     = pt.x;
+			rc.top      = pt.y;
+			rc.right    = rc.left + mode->Width;
+			rc.bottom   = rc.top + mode->Height;
+
+			AdjustWindowRectEx(&rc, new_style, FALSE, new_exstyle);
+
+			// Convert to width and height.
+			rc.right  -= rc.left;
+			rc.bottom -= rc.top;
+
+			if (SystemParametersInfo(SPI_GETWORKAREA, 0, &workarea_rc, 0))
+			{
+				// We try to keep window position, but we should prevent window
+				// from going off screen.
+
+				if (rc.left + rc.right > workarea_rc.right)
+					rc.left = workarea_rc.right - rc.right;
+				if (rc.top + rc.bottom > workarea_rc.bottom)
+					rc.top = workarea_rc.bottom - rc.bottom;
+
+				//  Titlebar should always be visible.
+
+				if (rc.left < workarea_rc.left)
+					rc.left = workarea_rc.left;
+				if (rc.top < workarea_rc.top)
+					rc.top = workarea_rc.top;
+			}
+		}
+
+		if (new_style != style)
+		{
+			SetWindowLongPtr(ONgPlatformData.Window, GWL_STYLE, (LONG_PTR) new_style);
+			flags |= SWP_FRAMECHANGED | SWP_DRAWFRAME;
+		}
+
+		if (new_exstyle != exstyle)
+		{
+			SetWindowLongPtr(ONgPlatformData.Window, GWL_EXSTYLE, (LONG_PTR) new_exstyle);
+			flags |= SWP_FRAMECHANGED | SWP_DRAWFRAME;
+		}
+
+		SetWindowPos(ONgPlatformData.Window, NULL, rc.left, rc.top, rc.right, rc.bottom, flags);
+		return UUcTrue;
+	}
+}
+
+static void ONICALL DD_GLiGamma_Restore(void)
+{
+	ConfigOption_t* co = DDrConfig_GetOptOfType("options.gamma", C_BOOL);
+	if (co->value.intBoolVal)
+	{
+		if (gl_api->wglSetDeviceGammaRamp3DFX)
+			gl_api->wglSetDeviceGammaRamp3DFX(gl->hDC, GLgInitialGammaRamp);
+		else
+			SetDeviceGammaRamp(gl->hDC, GLgInitialGammaRamp);
+	}
+}
+
+static void ONICALL DD_GLiGamma_Initialize(void)
+{
+	ConfigOption_t* co = DDrConfig_GetOptOfType("options.gamma", C_BOOL);
+	if (co->value.intBoolVal)
+	{
+		if (gl_api->wglSetDeviceGammaRamp3DFX)
+		{
+			STARTUPMESSAGE("Using 3dfx gamma adjustment", 0);
+			GLgGammaRampValid = gl_api->wglGetDeviceGammaRamp3DFX(gl->hDC, GLgInitialGammaRamp);
+		}
+		else
+		{
+			STARTUPMESSAGE("Using Windows gamma adjustment", 0);
+			GLgGammaRampValid = GetDeviceGammaRamp(gl->hDC, GLgInitialGammaRamp);
+		}
+
+		M3rSetGamma(ONrPersist_GetGamma());
+	}
+	else
+	{
+		GLgGammaRampValid = FALSE;
+	}
+}
+ 
+// Disposes OpenGL engine. Called once.
+void ONICALL DD_GLrPlatform_Dispose(void)
+{
+	DEVMODE dm;
+	
+	DD_GLiGamma_Restore();
+
+	gl_api->wglMakeCurrent(NULL, NULL);
+	gl_api->wglDeleteContext(gl->hGLRC);
+	ReleaseDC(ONgPlatformData.Window, gl->hDC);
+
+	// Restore initial display mode if it does not match current mode.
+	
+	dm.dmSize        = sizeof(dm);
+	dm.dmDriverExtra = 0;
+	
+	if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm) ||
+		dm.dmPelsWidth != GLgInitialMode.dmPelsWidth ||
+		dm.dmPelsHeight != GLgInitialMode.dmPelsHeight ||
+		dm.dmBitsPerPel != GLgInitialMode.dmBitsPerPel)
+	{
+		ChangeDisplaySettings(&GLgInitialMode, 0);
+	}
+	
+	// (skipping SetWindowPos as it only adds flickering)
+	gl_unload_library();
+}
+
+// Initializes (and re-initializes) OpenGL.
+UUtBool ONICALL DD_GLrPlatform_Initialize(void)
+{
+	static const M3tDisplayMode FallbackMode = { 640, 480, 16, 0 };
+
+	if (!DD_GLrPlatform_SetDisplayMode(&gl->DisplayMode))
+	{
+		gl->DisplayMode = FallbackMode;
+		
+		if (!DD_GLrPlatform_SetDisplayMode(&gl->DisplayMode))
+		{
+			goto exit_err;
+		}
+	}
+
+	// (DD_GLrPlatform_SetDisplayMode updates a window rectangle for us)
+	
+	if (!gl->hDC && !(gl->hDC = GetDC(ONgPlatformData.Window)))
+	{
+		goto exit_err;
+	}
+
+	ConfigOption_t* co = DDrConfig_GetOptOfType("options.gamma", C_BOOL);
+	if (!M3gResolutionSwitch && co->value.intBoolVal)
+	{
+		STARTUPMESSAGE("Ignoring gamma setting due to windowed mode", 0);
+		co->value.intBoolVal = false;
+	}
+
+	DD_GLiGamma_Initialize();
+
+	// This creates a rendering context too.
+	if (!gl_platform_set_pixel_format(gl->hDC))
+	{
+		if (gl->DisplayMode.Depth != 16)
+		{
+			gl->DisplayMode.Depth = 16;
+			if (!DD_GLrPlatform_SetDisplayMode(&gl->DisplayMode))
+				goto exit_err;
+			
+			if (!gl_platform_set_pixel_format(gl->hDC))
+				goto exit_err;
+		}
+	}
+
+	return UUcTrue;
+
+exit_err:
+	AUrMessageBox(1, "Daodan: Failed to initialize OpenGL contexts; Oni will now exit.");
+	exit(0);
+	return 0;
+}
Index: Daodan/src/Patches/GL.h
===================================================================
--- Daodan/src/Patches/GL.h	(revision 994)
+++ Daodan/src/Patches/GL.h	(revision 994)
@@ -0,0 +1,11 @@
+#ifndef DD_GL_H
+#define DD_GL_H
+
+#include "../Daodan.h"
+#include "../Oni/Oni.h"
+
+unsigned short ONICALL DD_GLrEnumerateDisplayModes(M3tDisplayMode* modes);
+UUtBool ONICALL DD_GLrPlatform_Initialize(void);
+void ONICALL DD_GLrPlatform_Dispose(void);
+
+#endif
Index: Daodan/src/Patches/Localization.c
===================================================================
--- Daodan/src/Patches/Localization.c	(revision 994)
+++ Daodan/src/Patches/Localization.c	(revision 994)
@@ -0,0 +1,159 @@
+#include "Localization.h"
+#include "../Daodan_Config.h"
+#include "../Daodan_Patch.h"
+#include "../Inifile_Reader.h"
+#include "Utility.h"
+#include "Cheater.h"
+
+#include <beaengine/BeaEngine.h>
+
+void LocalizationIniCallback(const char* section, const char* name, const char* value)
+{
+	if (!_stricmp(name, "blam"))
+	{
+		char* str = _strdup(value);
+		DDrPatch_Int32((int*)(OniExe + 0x0010fb73), (int)str);
+	}
+	else if (!_stricmp(name, "damn"))
+	{
+		char* str = _strdup(value);
+		DDrPatch_Int32((int*)(OniExe + 0x0010fb6e), (int)str);
+	}
+	else if (!_stricmp(name, "savepoint"))
+	{
+		char* str = malloc(strlen(value) + 10);
+		memset(str, ' ', 5);
+		strcpy(str+5, value);
+		strcpy(str + strlen(str), " %d");
+		bool b1 = DDrPatch_Int32((int*)(OniExe + 0x000fd730), (int)str);
+		bool b2 = DDrPatch_Int32((int*)(OniExe + 0x000fd738), (int)str);
+	}
+	else if (!_stricmp(name, "syndicatewarehouse"))
+	{
+		char* str = _strdup(value);
+		DDrPatch_Int32((int*)(OniExe + 0x000fd71a), (int)str);
+		DDrPatch_Int32((int*)(OniExe + 0x0010ef75), (int)str);
+	}
+	else if (!_stricmp(name, "shapeshifter_on"))
+		DDr_CheatTable[0].message_on = _strdup(value);
+	else if (!_stricmp(name, "shapeshifter_off"))
+		DDr_CheatTable[0].message_off = _strdup(value);
+	else if (!_stricmp(name, "liveforever_on"))
+		DDr_CheatTable[1].message_on = _strdup(value);
+	else if (!_stricmp(name, "liveforever_off"))
+		DDr_CheatTable[1].message_off = _strdup(value);
+	else if (!_stricmp(name, "touchofdeath_on"))
+		DDr_CheatTable[2].message_on = _strdup(value);
+	else if (!_stricmp(name, "touchofdeath_off"))
+		DDr_CheatTable[2].message_off = _strdup(value);
+	else if (!_stricmp(name, "canttouchthis_on"))
+		DDr_CheatTable[3].message_on = _strdup(value);
+	else if (!_stricmp(name, "canttouchthis_off"))
+		DDr_CheatTable[3].message_off = _strdup(value);
+	else if (!_stricmp(name, "fatloot_on"))
+		DDr_CheatTable[4].message_on = _strdup(value);
+	else if (!_stricmp(name, "glassworld_on"))
+		DDr_CheatTable[5].message_on = _strdup(value);
+	else if (!_stricmp(name, "glassworld_off"))
+		DDr_CheatTable[5].message_off = _strdup(value);
+	else if (!_stricmp(name, "winlevel_on"))
+		DDr_CheatTable[6].message_on = _strdup(value);
+	else if (!_stricmp(name, "loselevel_on"))
+		DDr_CheatTable[7].message_on = _strdup(value);
+	else if (!_stricmp(name, "bighead_on"))
+		DDr_CheatTable[8].message_on = _strdup(value);
+	else if (!_stricmp(name, "bighead_off"))
+		DDr_CheatTable[8].message_off = _strdup(value);
+	else if (!_stricmp(name, "minime_on"))
+		DDr_CheatTable[9].message_on = _strdup(value);
+	else if (!_stricmp(name, "minime_off"))
+		DDr_CheatTable[9].message_off = _strdup(value);
+	else if (!_stricmp(name, "superammo_on"))
+		DDr_CheatTable[10].message_on = _strdup(value);
+	else if (!_stricmp(name, "superammo_off"))
+		DDr_CheatTable[10].message_off = _strdup(value);
+	else if (!_stricmp(name, "devmode_on"))
+	{
+		char* str = _strdup(value);
+		DDr_CheatTable[11].message_on = str;
+		DDr_CheatTable[cheat_x].message_on = str;
+	}
+	else if (!_stricmp(name, "devmode_off"))
+	{
+		char* str = _strdup(value);
+		DDr_CheatTable[11].message_off = str;
+		DDr_CheatTable[cheat_x].message_off = str;
+	}
+	else if (!_stricmp(name, "reservoirdogs_on"))
+		DDr_CheatTable[12].message_on = _strdup(value);
+	else if (!_stricmp(name, "reservoirdogs_off"))
+		DDr_CheatTable[12].message_off = _strdup(value);
+	else if (!_stricmp(name, "roughjustice_on"))
+		DDr_CheatTable[13].message_on = _strdup(value);
+	else if (!_stricmp(name, "roughjustice_off"))
+		DDr_CheatTable[13].message_off = _strdup(value);
+	else if (!_stricmp(name, "chenille_on"))
+		DDr_CheatTable[14].message_on = _strdup(value);
+	else if (!_stricmp(name, "chenille_off"))
+		DDr_CheatTable[14].message_off = _strdup(value);
+	else if (!_stricmp(name, "behemoth_on"))
+		DDr_CheatTable[15].message_on = _strdup(value);
+	else if (!_stricmp(name, "behemoth_off"))
+		DDr_CheatTable[15].message_off = _strdup(value);
+	else if (!_stricmp(name, "elderrune_on"))
+		DDr_CheatTable[16].message_on = _strdup(value);
+	else if (!_stricmp(name, "elderrune_off"))
+		DDr_CheatTable[16].message_off = _strdup(value);
+	else if (!_stricmp(name, "moonshadow_on"))
+		DDr_CheatTable[17].message_on = _strdup(value);
+	else if (!_stricmp(name, "moonshadow_off"))
+		DDr_CheatTable[17].message_off = _strdup(value);
+	else if (!_stricmp(name, "munitionfrenzy_on"))
+		DDr_CheatTable[18].message_on = _strdup(value);
+	else if (!_stricmp(name, "fistsoflegend_on"))
+		DDr_CheatTable[19].message_on = _strdup(value);
+	else if (!_stricmp(name, "fistsoflegend_off"))
+		DDr_CheatTable[19].message_off = _strdup(value);
+	else if (!_stricmp(name, "killmequick_on"))
+		DDr_CheatTable[20].message_on = _strdup(value);
+	else if (!_stricmp(name, "killmequick_off"))
+		DDr_CheatTable[20].message_off = _strdup(value);
+	else if (!_stricmp(name, "carousel_on"))
+		DDr_CheatTable[21].message_on = _strdup(value);
+	else if (!_stricmp(name, "carousel_off"))
+		DDr_CheatTable[21].message_off = _strdup(value);
+}
+
+void DD_Localization()
+{
+	char* lang = DDrConfig_GetOptOfType("options.language", C_STRING)->value.stringVal;
+	char filename[50] = "daodan_locales/";
+	strcpy(filename + strlen(filename), lang);
+	strcpy(filename + strlen(filename), ".ini");
+//	STARTUPMESSAGE("Locale file: %s", filename);
+	if (_stricmp(lang, "en"))
+	{
+		STARTUPMESSAGE("Language: %s", lang);
+		uint32_t attr = GetFileAttributes("daodan_locales");
+		if (attr == INVALID_FILE_ATTRIBUTES)
+		{
+			STARTUPMESSAGE("Locales folder does not exist", 0);
+			return;
+		}
+		if ((attr & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY)
+		{
+			STARTUPMESSAGE("Locales folder does not exist", 0);
+			return;
+		}
+
+		if (GetFileAttributes(filename) == INVALID_FILE_ATTRIBUTES)
+		{
+			STARTUPMESSAGE("Locale file for language \"%s\" does not exist", lang);
+			return;
+		}
+
+		if (!Inifile_Read(filename, LocalizationIniCallback))
+			STARTUPMESSAGE("Error reading %s, check your syntax!", filename);
+	}
+}
+
Index: Daodan/src/Patches/Localization.h
===================================================================
--- Daodan/src/Patches/Localization.h	(revision 994)
+++ Daodan/src/Patches/Localization.h	(revision 994)
@@ -0,0 +1,6 @@
+#ifndef LOCALIZATION_H
+#define LOCALIZATION_H
+
+void DD_Localization();
+
+#endif
Index: Daodan/src/Patches/Patches.c
===================================================================
--- Daodan/src/Patches/Patches.c	(revision 994)
+++ Daodan/src/Patches/Patches.c	(revision 994)
@@ -0,0 +1,730 @@
+#include <windows.h>
+
+#include "../Daodan.h"
+#include "BSL.h"
+#include "Cheater.h"
+#include "../Daodan_Config.h"
+#include "GL.h"
+#include "../Daodan_Patch.h"
+#include "Utility.h"
+#include "Win32.h"
+
+#include "../Oni/Oni.h"
+
+typedef int (__cdecl *CHINESEPROC)(DWORD ThreadId); 
+
+// Hooked WMrSlider_SetRange() in ONiOGU_Options_InitDialog. Disables a gamma
+// slider in windowed mode.
+static void ONICALL DD_ONiOGU_GammaSlider_SetRange(void* window, int min_value, int max_value)
+{
+	ConfigOption_t* co = DDrConfig_GetOptOfType("options.gamma", C_BOOL);
+	WMrWindow_SetEnabled(window, M3gResolutionSwitch && co->value.intBoolVal);
+	WMrSlider_SetRange(window, min_value, max_value);
+}
+
+void ONICALL DD_M3rDraw_BigBitmap(M3tTextureMap_Big* inBigBitmap, const M3tPointScreen* inDestPoint, UUtUns16 inWidth, UUtUns16 inHeight, UUtUns32 inShade, UUtUns16 inAlpha) /* 0 - M3cMaxAlpha */
+{
+	UUtUns16 x;
+	UUtUns16 y;
+
+	UUtUns16 index;
+	UUtUns16 remaining_width;
+	UUtUns16 remaining_height;
+
+	M3tPointScreen dest_point;
+	dest_point.z = inDestPoint->z;
+	dest_point.invW = inDestPoint->invW;
+
+	index = 0;
+	remaining_height = inHeight;
+	dest_point.y = (UUtInt16)((UUtUns16)inDestPoint->y);
+	for (y = 0; y < inBigBitmap->num_y; y++)
+	{
+		remaining_width = inWidth;
+		dest_point.x = (UUtInt16)((UUtUns16)inDestPoint->x);
+		for (x = 0; x < inBigBitmap->num_x; x++)
+		{
+			UUtUns16 width;
+			UUtUns16 height;
+			
+			width = 256 < remaining_width ? 256 : remaining_width;
+			height = 256 < remaining_height ? 256 : remaining_height;
+            			
+			M3rDraw_Bitmap(inBigBitmap->textures[index], &dest_point, width, height, inShade, inAlpha);
+
+			dest_point.x += 256;
+			remaining_width -= 256;
+			index++;
+		}
+		dest_point.y += 256;
+		remaining_height -= 256;
+	}
+}
+
+
+uint8_t ONICALL DDrPersist_GetWonGame()
+{
+	return 1;
+}
+
+
+void ONICALL DDrShowResumeButton(void* window, int visibility)
+{
+	if (visibility)
+		WMrWindow_SetLocation(window, 150, 350);
+	WMrWindow_SetVisible(window, visibility);
+}
+
+
+/* Options always visible patch */
+void ONICALL DDrShowOptionsButton(void* window, int visibility)
+{
+	WMrWindow_SetVisible(window, 1);
+}
+
+void ONICALL DDrGame_Init()
+{
+	ConfigOption_t* co = DDrConfig_GetOptOfType("options.usedaodanbsl", C_BOOL);
+	if (co->value.intBoolVal)
+		SLrDaodan_Initialize();
+}
+
+
+//this was broken 
+FILE** _UUgError_WarningFile = (FILE**)0x005711B4;
+FILE* ONICALL DDrPrintWarning(int filename, int linenumber, unsigned __int16 errornum, int message)
+{
+	FILE *v4; // eax@1
+	FILE *result; // eax@4
+	char v6[512]; // [sp+0h] [bp-100h]@1
+	FILE* UUgError_WarningFile = *_UUgError_WarningFile;
+
+	if (filename && message && (strlen((const char*)filename)+strlen((const char*)message))<420) {
+		sprintf(
+			v6,
+			"Error %x reported from File: %s, Line: %d (message follows) \r\n%s",
+			errornum,
+			(const char*)filename,
+			linenumber,
+			(const char*)message);
+
+		if ( UUgError_WarningFile 
+			|| (UUgError_WarningFile = oni_fopen("debugger.txt", "wb"), UUgError_WarningFile ) )
+		{ 
+			oni_fprintf(UUgError_WarningFile, "%s\r\n", v6);
+			oni_fflush(UUgError_WarningFile);
+		}
+	}
+	//oni_fprintf(stdout, v6);
+	//sprintf(&v6, "%s", message);
+	*_UUgError_WarningFile = UUgError_WarningFile;
+	result = UUgError_WarningFile;
+	return result; 
+}
+
+_COrTextArea_Resize Oni_COrTextArea_Resize = (_COrTextArea_Resize)0;
+int16_t ONICALL DD_COrTextArea_Resize(void* inTextArea, UUtRect* inBounds, int16_t inNumTextEntries) {
+	if (inTextArea == COgCommandLine) {
+		inBounds->top -= 10;
+	} else if (inTextArea == COgConsoleLines) {
+		inBounds->bottom -= 10;
+	}
+	return Oni_COrTextArea_Resize(inTextArea, inBounds, inNumTextEntries);
+}
+
+#define IMcShade_Red (0xFFFF0000)
+#define IMcShade_Green (0xFF00FF00)
+#define IMcShade_Blue (0xFF0000FF)
+void ONICALL DD_OBJiTriggerVolume_Draw(OBJtObject* inObject, uint32_t inDrawFlags)
+{
+	UUtUns32				itr;
+	OBJtOSD_All				*inOSD = (OBJtOSD_All *) inObject->object_data;
+	OBJtOSD_TriggerVolume	*trigger_osd = &inOSD->osd.trigger_volume_osd;
+	M3tPoint3D				*points = trigger_osd->volume.worldPoints;
+	UUtUns32				shade = 0xFFFFFF;
+
+	if (!OBJgTriggerVolume_Visible) {
+		return;
+	}
+
+	if (OBJrTriggerVolume_IntersectsCharacter(inObject, trigger_osd->team_mask, ONgGameState->PlayerCharacter)) {
+		shade = IMcShade_Red;
+	}
+	else
+	{
+		shade = IMcShade_Blue;
+	}
+
+	M3rGeom_Line_Light(points + 0, points + 1, shade);
+	M3rGeom_Line_Light(points + 1, points + 3, shade);
+	M3rGeom_Line_Light(points + 3, points + 2, shade);
+	M3rGeom_Line_Light(points + 2, points + 0, shade);
+
+	M3rGeom_Line_Light(points + 4, points + 5, shade);
+	M3rGeom_Line_Light(points + 5, points + 7, shade);
+	M3rGeom_Line_Light(points + 7, points + 6, shade);
+	M3rGeom_Line_Light(points + 6, points + 4, shade);
+
+	M3rGeom_Line_Light(points + 0, points + 4, shade);
+	M3rGeom_Line_Light(points + 1, points + 5, shade);
+	M3rGeom_Line_Light(points + 3, points + 7, shade);
+	M3rGeom_Line_Light(points + 2, points + 6, shade);
+}
+
+_ONrMechanics_Register Oni_ONrMechanics_Register = (_ONrMechanics_Register)0;
+int16_t ONICALL DD_ONrMechanics_Register(uint32_t inObjectType, uint32_t inObjectTypeIndex, char* inGroupName,
+	uint32_t inSizeInMemory, OBJtMethods* inObjectMethods, uint32_t inFlags, void* inMechanicsMethods)
+{
+	if (strcmp("Trigger Volume", inGroupName) == 0) {
+		inObjectMethods->rDraw = DD_OBJiTriggerVolume_Draw;
+	}
+	return Oni_ONrMechanics_Register(inObjectType, inObjectTypeIndex, inGroupName, inSizeInMemory, inObjectMethods, inFlags, inMechanicsMethods);
+}
+
+_ONrGameState_HandleUtilityInput Oni_ONrGameState_HandleUtilityInput = (_ONrGameState_HandleUtilityInput)0;
+void ONICALL DD_ONrGameState_HandleUtilityInput(const void* inInput)
+{
+	Oni_ONrGameState_HandleUtilityInput(inInput);
+	
+	if (ONrDebugKey_WentDown(7)) {
+		OBJgTriggerVolume_Visible = !OBJgTriggerVolume_Visible;
+	}
+}
+
+
+int DD_Patch_DebugNameTextureInit(short width, short height, int type, int allocated, int flags, char* name, void** output)
+{
+	//flags = (1 << 10);
+	type = 1;
+	//DDrPatch_Byte( 0x005EB83C + 3, 0xff );
+	DDrPatch_Int32((int*)(OniExe + 0x001EB83C), 0xFF000000 );
+	return M3rTextureMap_New(width, height, type, allocated, flags, name, output);
+}
+
+short DD_Patch_DebugNameShadeHack( Character* Char )
+{
+	return TSrContext_SetShade(*(void**)(OniExe + 0x001EB844), ONrCharacter_GetHealthShade( Char->Health, Char->MaxHealth ));
+	//return TSrContext_SetShade(*(void**)0x005EB844, 0xFFFFFFFF);
+}
+
+
+// Disable UUrPlatform_Initalize/Terminate, this enables the Alt-Tab and the
+// Windows key but has the possible side effect of allowing the screensaver
+// to enable itself in-game.
+void DD_Patch_AltTab()
+{
+	// 0xC3 = ret, so makes those functions just have a "ret" instruction at their start
+	DDrPatch_Byte  ((char*)UUrPlatform_Initialize, 0xC3);
+	DDrPatch_Byte  ((char*)UUrPlatform_Terminate, 0xC3);
+}
+
+// Textures using ARGB8888 can be used
+void DD_Patch_ARGB8888()
+{
+	DDrPatch_Byte  ((char*)(OniExe + 0x00135af0), 0x07);
+	DDrPatch_Byte  ((char*)(OniExe + 0x00135af4), 0x0B);
+}
+
+// Fix BinkBufferInit() call in BKrMovie_Play() to use GDI (DIB) blitting
+// instead of DirectDraw; patch ONiRunGame to use the same method to play
+// outro (ie., BKrMovie_Play() instead of ONrMovie_Play_Hardware() as the
+// latter has problems on WINE).
+void DD_Patch_BinkPlay()
+{
+	// push BINKBUFFERAUTO -> push BINKBUFFERDIBSECTION.
+	DDrPatch_Byte((void*)(OniExe + 0x0008829b + 1), 0x02);
+	// call ONrMovie_Play_Hardware -> call ONrMovie_Play
+	DDrPatch_MakeCall((void*)(OniExe + 0x000d496f), ONrMovie_Play);
+}
+
+// Enables d_regen (unfinished) and prevents fly-in portraits from being
+// stretched when playing in widescreen resolutions. 
+void DD_Patch_BSL()
+{
+	//Calculating the value of the needed offset is much more reliable when the compiler does it for you.
+
+	//TODO: fix moonshadow.
+	Character * Chr = 0;
+	int NoPath = (int)&(Chr[0].RegenHax) & 0x000000FF;
+	const unsigned char regen_patch[] =
+	{0x90, 0x90, 0x90, 0x90, 0x90,				// mov    al, _WPgRegenerationCheat	-> NOOP
+	0x90, 0x90,									// test   al, al					-> NOOP
+	0x90, 0x90,									// jz	  short loc_51BB98			-> NOOP
+	0x8B, 0x86, (char)NoPath, 0x01, 0x00, 0x00, // mov     eax, [esi+Character.field_1E8]
+												//	-> mov     eax, [esi+Character.RegenHax]
+	0x85, 0xC0,									// test eax, eax
+	0x74, 0x21									// jnz 0x21 -> jz 0x21
+	};	
+	DDrPatch_Const((char*)(OniExe + 0x0011BB64), regen_patch);
+
+	// Patches for existing BSL functions
+	SLrDaodan_Patch();
+}
+
+// Adds new cheat codes if cheattable is also enabled
+void DD_Patch_Cheater()
+{
+	DDrPatch_MakeCall((void*)(OniExe + 0x000f618f), (void*)DDrCheater);
+	DDrPatch_Int16((short*)(OniExe + 0x000deb45), 0x5590);
+#if 1
+	DDrPatch_MakeCall((void*)(OniExe + 0x000deb47), (void*)FallingFrames);
+#endif
+	DDrPatch_MakeJump((void*)(OniExe + 0x0010f021), (void*)DDrCheater_LevelLoad);
+}
+
+// Cheats always enabled
+void DD_Patch_CheatsEnabled()
+{
+	DDrPatch_MakeJump((void*)ONrPersist_GetWonGame, (void*)DDrPersist_GetWonGame);
+}
+
+// Use Daodan's own cheattable
+void DD_Patch_CheatTable()
+{
+	DDrPatch_Int32 ((int*)(OniExe + 0x000f616b), (int)&DDr_CheatTable[0].name);
+	DDrPatch_Int32 ((int*)(OniExe + 0x000f617a), (int)&DDr_CheatTable[0].message_on);
+}
+
+// Load chinese font DLL if available
+void DD_Patch_Chinese()
+{
+	if (GetFileAttributes("xfhsm_oni.dll") != INVALID_FILE_ATTRIBUTES)
+	{
+		HMODULE dll;
+		DWORD err;
+
+ 		STARTUPMESSAGE("Loading chinese DLL", 0);
+		dll = LoadLibrary("xfhsm_oni.dll");
+		err = GetLastError();
+		if( dll )
+		{
+			void* proc = GetProcAddress( dll, "InstallHook" );
+			if(proc)
+			{
+				((CHINESEPROC)proc)(GetCurrentThreadId());
+			}
+		} else {
+			char msg[100];
+			FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0, msg, 100, NULL);
+			STARTUPMESSAGE("Loading DLL failed with error %i: %s", err, msg);
+		}
+	}
+}
+
+// Limit cursor to Oni's window
+void DD_Patch_ClipCursor()
+{
+	// LIrMode_Set: replace LIrPlatform_Mode_Set call with our hook.
+	DDrPatch_MakeCall((void*)(OniExe + 0x00003f9f), (void*) DD_LIrPlatform_Mode_Set);
+
+	// LIrMode_Set_Internal: replace LIrPlatform_Mode_Set call with our hook.
+	DDrPatch_MakeCall((void*)(OniExe + 0x00003fff), (void*) DD_LIrPlatform_Mode_Set);
+	
+	// LIrTermiante: replace LIrPlatform_Terminate call with our hook.
+	DDrPatch_MakeCall((void*)(OniExe + 0x000004cb8), (void*) DD_LIrPlatform_Terminate);
+}
+
+// Disables weapon cooldown exploit
+void DD_Patch_CooldownTimer()
+{
+	const unsigned 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 ((char*)(OniExe + 0x0011a825), cooldown_patch);
+}
+
+// Daodan device mode enumeration function
+void DD_Patch_DaodanDisplayEnum()
+{
+	DDrPatch_MakeJump((void*)gl_enumerate_valid_display_modes, (void*)DD_GLrEnumerateDisplayModes);
+}
+
+// Adds new BSL functions
+void DD_Patch_DaodanInit()
+{
+	DDrPatch_MakeCall((void*)(OniExe + 0x000d345a), (void*)DDrGame_Init);
+}
+
+// Forced DirectInput (for Windows NT)
+void DD_Patch_DirectInput()
+{
+	DDrPatch_Byte((char*)(OniExe + 0x00002e6d), 0xeb);
+}
+
+// Disable Oni's command line parser so it doesn't interfere with ours
+void DD_Patch_DisableCmdLine()
+{
+	// Replace start of OniParseCommandLine with XOR ax,ax; RET
+//	DDrPatch_Int32 ((int*)(OniExe + 0x000d3570), 0xc3c03366);
+	// Replace start of OniParseCommandLine with XOR eax,eax; RET
+	DDrPatch_Int32 ((int*)(OniExe + 0x000d3570), 0x00c3c033);
+}
+
+// Font texture cache doubled
+void DD_Patch_FontTextureCache()
+{
+	DDrPatch_Byte((char*)(OniExe + 0x00020ea7), 0x20);
+	DDrPatch_Byte((char*)(OniExe + 0x00020f4a), 0x40);
+}
+
+// Disable Oni's internal CLrGetCommandLine function (to eventually replace it with our own)
+void DD_Patch_GetCmdLine()
+{
+	DDrPatch_NOOP  ((char*)(OniExe + 0x000d3280), 51);
+}
+
+// Allow HD screens with resolution < 1024*768
+void DD_Patch_HDScreens_LowRes()
+{
+	DDrPatch_MakeJump((void*)M3rDraw_BigBitmap, (void*)DD_M3rDraw_BigBitmap);
+}
+
+void DD_Patch_HighresConsole() {
+	Oni_COrTextArea_Resize = DDrPatch_MakeDetour((void*)COrTextArea_Resize, (void*)DD_COrTextArea_Resize);
+}
+
+// Hackish fix for Konoko not kicking guns
+// Don't use this, it breaks stairs.
+void DD_Patch_KickGuns()
+{
+	const unsigned 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 ((char*)(OniExe + 0x000dc420), kickgun_patch);
+}
+
+// Disable loading the vtuneapi.dll
+void DD_Patch_KillVTune()
+{
+	DDrPatch_Byte  ((char*)(OniExe + 0x00026340), 0xC3);
+}
+
+// Now supports textures up to 512x512
+void DD_Patch_LargeTextures()
+{
+	DDrPatch_Byte  ((char*)(OniExe + 0x00005251), 0x10);
+}
+
+// Non-"_Final" levels are now valid
+void DD_Patch_LevelPlugins()
+{
+	DDrPatch_Byte  ((char*)(OniExe + 0x000206a8), 0x01);
+}
+
+// Weapon on ground shown with name and magazine contents
+void DD_Patch_NewWeap()
+{
+	//Makes it always say "Received weapon_name."
+	//Needs check for loc_4DFC66
+	//DDrPatch_NOOP((char*)(OniExe + 0x000E4DF8),2);
+
+	//Adds Weapon name and ammo meter to pickup autoprompt
+	DDrPatch_NOOP((char*)(OniExe + 0x000FAC73), 9);
+	DDrPatch_NOOP((char*)(OniExe + 0x000FAC80), 5);
+	DDrPatch_MakeCall((void*)(OniExe + 0xFAC85), (void*)DDrWeapon2Message);
+	
+	//Moves location of colors
+	//DDrPatch_Int32((int*)(OniExe + 0x0002E3D5), (int)&DDrDSayColors );
+	//DDrPatch_Int32((int*)(OniExe + 0x0002E3DA), (int)&DDrDSayColors );
+}
+
+// Disable Multi-byte character awareness patch (multiple language support)
+void DD_Patch_NoMultiByte()
+{
+	DDrPatch_Byte  ((char*)(OniExe + 0x0002d8f8), 0xeb);
+	DDrPatch_Byte  ((char*)(OniExe + 0x0002d9ad), 0xeb);
+	DDrPatch_Byte  ((char*)(OniExe + 0x0002dbe2), 0xeb);
+	DDrPatch_Byte  ((char*)(OniExe + 0x0002dec3), 0xeb);
+	DDrPatch_Byte  ((char*)(OniExe + 0x0002e2ab), 0xeb);
+	DDrPatch_Byte  ((char*)(OniExe + 0x0002e2c4), 0xeb);
+	DDrPatch_Byte  ((char*)(OniExe + 0x0002e379), 0xeb);
+	DDrPatch_Byte  ((char*)(OniExe + 0x0002e48c), 0xeb);
+	DDrPatch_Byte  ((char*)(OniExe + 0x0002e4d0), 0xeb);
+	DDrPatch_Byte  ((char*)(OniExe + 0x0002e4f4), 0xeb);
+	DDrPatch_Byte  ((char*)(OniExe + 0x0002e646), 0xeb);
+	DDrPatch_Byte  ((char*)(OniExe + 0x0002e695), 0xeb);
+	DDrPatch_Byte  ((char*)(OniExe + 0x0002e944), 0xeb);
+	DDrPatch_Byte  ((char*)(OniExe + 0x0002e95d), 0xeb);
+	DDrPatch_Byte  ((char*)(OniExe + 0x0002e98e), 0xeb);
+	DDrPatch_Byte  ((char*)(OniExe + 0x0002e9dc), 0xeb);
+}
+
+// Fix options not visible in main menu when a game was started
+void DD_Patch_OptionsVisible()
+{
+	DDrPatch_MakeCall((void*)(OniExe + 0x000d2d2d), DDrShowOptionsButton);
+	DDrPatch_MakeCall((void*)(OniExe + 0x000d2d43), DDrShowResumeButton);
+}
+
+// Unlocks particle action disabling/enabling bits for all events. (Will be
+// controlled by a command line switch when I figure out how to do that without
+// Win32 hacks.)
+void DD_Patch_ParticleDisableBit()
+{
+	DDrPatch_Int16 ((short*)(OniExe + 0x001b184), 0x9090);
+}
+
+// Pathfinding grid cache size x8
+void DD_Patch_PathFinding()
+{
+	const unsigned char pathfinding[2] = {0x90 , 0xE9 };
+	DDrPatch_Byte  ((char*)(OniExe + 0x0010b03b), 0x20);
+	DDrPatch_Byte  ((char*)(OniExe + 0x0010b04c), 0x20);
+
+	//other stuff
+	DDrPatch_Const((char*)(OniExe + 0x00040789), pathfinding);
+}
+
+// Projectile awareness fixed
+void DD_Patch_ProjAware()
+{
+	DDrPatch_Byte  ((char*)(OniExe + 0x0009c07c), 0x6c);
+	DDrPatch_Byte  ((char*)(OniExe + 0x0009c080), 0x70);
+	DDrPatch_Byte  ((char*)(OniExe + 0x0009c084), 0x74);
+	DDrPatch_Byte  ((char*)(OniExe + 0x0009c110), 0x6c);
+}
+
+// Safe startup message printer
+void DD_Patch_SafePrintf()
+{
+	DDrPatch_MakeJump((void*)UUrStartupMessage, (void*)DDrStartupMessage);
+}
+
+// Show all (also enemies') lasersights
+void DD_Patch_ShowAllLasersights()
+{
+	DDrPatch_NOOP((char*)(OniExe + 0x000E1957), 6 );
+}
+
+void DD_Patch_ShowTriggerVolumes()
+{
+	Oni_ONrMechanics_Register = DDrPatch_MakeDetour((void*)ONrMechanics_Register, (void*)DD_ONrMechanics_Register);
+	Oni_ONrGameState_HandleUtilityInput = DDrPatch_MakeDetour((void*)ONrGameState_HandleUtilityInput, (void*)DD_ONrGameState_HandleUtilityInput);
+}
+
+// Experiment with allowing enemies to be thrown over railings
+void DD_Patch_Throwtest()
+{
+	const unsigned char throwtest_patch[] = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 };
+	DDrPatch_Const((char*)(OniExe + 0x000dc190), throwtest_patch);
+}
+
+// DaodanGL with windowed mode support
+void DD_Patch_UseDaodanGL()
+{
+	// LIrPlatform_Mode_Set: GetWindowRect -> GetClientRect.
+	DDrPatch_NOOP((char*) OniExe + 0x00002dd6, 6);
+	DDrPatch_MakeCall((char*) OniExe + 0x00002dd6, (void*) GetClientRect);
+
+	// UUrWindow_GetSize: GetWindowRect -> GetClientRect.
+	DDrPatch_NOOP((char*) OniExe + 0x0002651c, 6);
+	DDrPatch_MakeCall((char*) OniExe + 0x0002651c, (void*) GetClientRect);
+
+	// LIrPlatform_PollInputForAction: fix GetCursorPos call to return client coordinates.
+	DDrPatch_NOOP((char*) OniExe + 0x000032cc, 6);
+	DDrPatch_MakeCall((char*) OniExe + 0x000032cc, (void*) DD_GetCursorPos);
+
+	// LIrPlatform_InputEvent_GetMouse: fix GetCursorPos call to return client coordinates.
+	DDrPatch_NOOP((char*) OniExe + 0x00002cc2, 6);
+	DDrPatch_MakeCall((char*) OniExe + 0x00002cc2, (void*) DD_GetCursorPos);
+
+	// LIrPlatform_PollInputForAction: translate SetCursorPos position to screen coordinates.
+	DDrPatch_NOOP((char*) OniExe + 0x000032b7, 6);
+	DDrPatch_MakeCall((char*) OniExe + 0x000032b7, (void*) DD_SetCursorPos);
+
+	// LIrPlatform_PollInputForAction: translate SetCursorPos position to screen coordinates.
+	DDrPatch_NOOP((char*) OniExe + 0x00003349, 6);
+	DDrPatch_MakeCall((char*) OniExe + 0x00003349, (void*) DD_SetCursorPos);
+
+	// Replace ONrPlatformInitialize.
+	DDrPatch_MakeJump((void*) ONrPlatform_Initialize, (void*) DD_ONrPlatform_Initialize);
+
+	// Replace gl_platform_initialize.
+	DDrPatch_MakeJump((void*) gl_platform_initialize, (void*) DD_GLrPlatform_Initialize);
+
+	// Replace gl_platform_dispose.
+	DDrPatch_MakeJump((void *) gl_platform_dispose, (void*) DD_GLrPlatform_Dispose);
+}
+
+// Performance patch
+void DD_Patch_UseGetTickCount()
+{
+	DDrPatch_MakeJump((void*)UUrMachineTime_High, (void*)DDrMachineTime_High);
+	DDrPatch_MakeJump((void*)UUrMachineTime_High_Frequency, (void*)DDrMachineTime_High_Frequency);
+	DDrPatch_MakeJump((void*)UUrMachineTime_Sixtieths, (void*)DDrMachineTime_Sixtieths);
+}
+
+// Adds working function for existing BSL command wp_fadetime, sets fade time to 4800
+void DD_Patch_WpFadetime()
+{
+	// Makes wp_fadetime actually have a function
+	const unsigned char fadetime_patch[] = { 0x66, 0x8B, 0x1D, 0xC4, 0x7D, 0x62, 0x00, 0x66, 0x89, 0x5E, 0x46, 0x5B, 0x5E, 0x83, 0xC4, 0x14, 0xC3 };
+	DDrPatch_Const ((char*)(OniExe + 0x0011a889), fadetime_patch);
+	DDrPatch_Byte  ((char*)(OniExe + 0x0011a560), 0x31);
+	
+	// Sets the fadetime to 4800 by default
+	DDrPatch_Int16 ((short*)(OniExe + 0x0011ab0e), 0x12c0);
+}
+
+// Disable gamma slider in options in windowed mode
+void DD_Patch_GammaSlider()
+{
+	DDrPatch_MakeCall((void*)(OniExe + 0x000d262c), (void*)DD_ONiOGU_GammaSlider_SetRange);
+}
+
+// Fix the warning print method
+void DD_Patch_PrintWarning()
+{
+	DDrPatch_MakeJump((void*)(OniExe + 0x000245A0), (void*)DDrPrintWarning);
+}
+
+//Fix crappy ai2_shownames
+void DD_Patch_ShowNames()
+{
+	//Set distance above head to 4.0
+	DDrPatch_Int32((int*)(OniExe + 0x0008C998), 0x005296C8);
+	//texture height
+	DDrPatch_Byte((char*)(OniExe + 0x0008C9DF), 0x3F );
+	//texture	width
+	DDrPatch_NOOP((char*)(OniExe + 0x0008C9CA), 6 );
+
+/*
+// Crashes game.
+	//Set the text color to whatever we like ;)
+	DDrPatch_NOOP((char*)(OniExe + 0x0008C898), 6 );
+	DDrPatch_Byte((char*)(OniExe + 0x0008C898), 0x8B );
+	DDrPatch_Byte((char*)(OniExe + 0x0008C899), 0xCE );
+
+	DDrPatch_MakeCall((void*)(OniExe + 0x0008C8A3), DD_Patch_DebugNameShadeHack);
+	
+	//Make the background black for additive blending
+	DDrPatch_MakeCall((void*)(OniExe + 0x0008C802), DD_Patch_DebugNameTextureInit );
+*/
+}
+
+/*
+void DD_Patch_ShowTriggerVolumes()
+{
+	DDrPatch_Int32((int*)(OniExe + 0x000cc9bb+4), (uint32_t)DD_OBJiTriggerVolume_Draw);
+}
+
+void DD_Patch_ShowFlags()
+{
+	DDrPatch_Int32((int*)(OniExe + 0x000c4ed4+4), (uint32_t)DD_OBJiFlag_Draw);
+}
+*/
+
+bool DD_Patch_Init()
+{
+	STARTUPMESSAGE("Patching engine", 0);
+	
+	if (DDrConfig_GetOptOfType("patches.alttab", C_BOOL)->value.intBoolVal)
+		DD_Patch_AltTab();
+	
+	if (DDrConfig_GetOptOfType("patches.argb8888", C_BOOL)->value.intBoolVal)
+		DD_Patch_ARGB8888();
+
+	if (DDrConfig_GetOptOfType("patches.binkplay", C_BOOL)->value.intBoolVal)
+		DD_Patch_BinkPlay();
+
+	if (DDrConfig_GetOptOfType("patches.bsl", C_BOOL)->value.intBoolVal)
+		DD_Patch_BSL();
+
+	if (DDrConfig_GetOptOfType("patches.cheater", C_BOOL)->value.intBoolVal)
+		DD_Patch_Cheater();
+
+	if (DDrConfig_GetOptOfType("patches.cheatsenabled", C_BOOL)->value.intBoolVal)
+		DD_Patch_CheatsEnabled();
+
+	if (DDrConfig_GetOptOfType("patches.cheattable", C_BOOL)->value.intBoolVal)
+		DD_Patch_CheatTable();
+	
+	if (DDrConfig_GetOptOfType("patches.chinese", C_BOOL)->value.intBoolVal)
+		DD_Patch_Chinese();
+
+	if (DDrConfig_GetOptOfType("patches.clipcursor", C_BOOL)->value.intBoolVal)
+		DD_Patch_ClipCursor();
+
+	if (DDrConfig_GetOptOfType("patches.cooldowntimer", C_BOOL)->value.intBoolVal)
+		DD_Patch_CooldownTimer();
+
+	if (DDrConfig_GetOptOfType("patches.daodandisplayenum", C_BOOL)->value.intBoolVal)
+		DD_Patch_DaodanDisplayEnum();
+	
+	if (DDrConfig_GetOptOfType("patches.directinput", C_BOOL)->value.intBoolVal)
+		DD_Patch_DirectInput();
+
+	if (DDrConfig_GetOptOfType("patches.disablecmdline", C_BOOL)->value.intBoolVal)
+		DD_Patch_DisableCmdLine();
+
+	if (DDrConfig_GetOptOfType("patches.fonttexturecache", C_BOOL)->value.intBoolVal)
+		DD_Patch_FontTextureCache();
+
+	if (DDrConfig_GetOptOfType("patches.getcmdline", C_BOOL)->value.intBoolVal)
+		DD_Patch_GetCmdLine();
+
+	if (DDrConfig_GetOptOfType("patches.hdscreens_lowres", C_BOOL)->value.intBoolVal)
+		DD_Patch_HDScreens_LowRes();
+
+	if (DDrConfig_GetOptOfType("patches.highres_console", C_BOOL)->value.intBoolVal)
+		DD_Patch_HighresConsole();
+	
+	if (DDrConfig_GetOptOfType("patches.kickguns", C_BOOL)->value.intBoolVal)
+		DD_Patch_KickGuns();
+	
+	//if (patch_killvtune)
+	//	DD_Patch_KillVTune();
+
+	if (DDrConfig_GetOptOfType("patches.largetextures", C_BOOL)->value.intBoolVal)
+		DD_Patch_LargeTextures();
+	
+	if (DDrConfig_GetOptOfType("patches.levelplugins", C_BOOL)->value.intBoolVal)
+		DD_Patch_LevelPlugins();
+
+	if (DDrConfig_GetOptOfType("patches.newweap", C_BOOL)->value.intBoolVal)
+		DD_Patch_NewWeap();
+
+	if (DDrConfig_GetOptOfType("patches.nomultibyte", C_BOOL)->value.intBoolVal)
+		DD_Patch_NoMultiByte();
+
+	if (DDrConfig_GetOptOfType("patches.optionsvisible", C_BOOL)->value.intBoolVal)
+		DD_Patch_OptionsVisible();
+
+	if (DDrConfig_GetOptOfType("patches.particledisablebit", C_BOOL)->value.intBoolVal)
+		DD_Patch_ParticleDisableBit();
+	
+	if (DDrConfig_GetOptOfType("patches.pathfinding", C_BOOL)->value.intBoolVal)
+		DD_Patch_PathFinding();
+
+	if (DDrConfig_GetOptOfType("patches.projaware", C_BOOL)->value.intBoolVal)
+		DD_Patch_ProjAware();
+
+	if (DDrConfig_GetOptOfType("patches.safeprintf", C_BOOL)->value.intBoolVal)
+		DD_Patch_SafePrintf();
+
+	if (DDrConfig_GetOptOfType("patches.showalllasersights", C_BOOL)->value.intBoolVal)
+		DD_Patch_ShowAllLasersights();
+
+	if (DDrConfig_GetOptOfType("patches.showtriggervolumes", C_BOOL)->value.intBoolVal)
+		DD_Patch_ShowTriggerVolumes();
+	
+	if (DDrConfig_GetOptOfType("patches.throwtest", C_BOOL)->value.intBoolVal)
+		DD_Patch_Throwtest();
+
+	if (DDrConfig_GetOptOfType("patches.usedaodangl", C_BOOL)->value.intBoolVal)
+		DD_Patch_UseDaodanGL();
+
+	if (DDrConfig_GetOptOfType("patches.usegettickcount", C_BOOL)->value.intBoolVal)
+		DD_Patch_UseGetTickCount();
+	
+	if (DDrConfig_GetOptOfType("patches.wpfadetime", C_BOOL)->value.intBoolVal)
+		DD_Patch_WpFadetime();
+
+
+	DD_Patch_DaodanInit();
+	
+	DD_Patch_GammaSlider();
+
+	DD_Patch_PrintWarning();
+
+	DD_Patch_ShowNames();
+
+	return true;
+}
+
Index: Daodan/src/Patches/Patches.h
===================================================================
--- Daodan/src/Patches/Patches.h	(revision 994)
+++ Daodan/src/Patches/Patches.h	(revision 994)
@@ -0,0 +1,8 @@
+#ifndef PATCHES_H
+#define PATCHES_H
+
+#include "../stdint.h"
+
+bool DD_Patch_Init();
+
+#endif
Index: Daodan/src/Patches/Utility.c
===================================================================
--- Daodan/src/Patches/Utility.c	(revision 994)
+++ Daodan/src/Patches/Utility.c	(revision 994)
@@ -0,0 +1,169 @@
+#include <windows.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#include "Utility.h"
+#include "../Oni/Oni.h"
+
+const double fps = 60.0;
+
+void __cdecl DDrStartupMessage(const char* fmt, ...)
+{
+
+	char* buffer;
+	va_list ap;
+	va_start(ap, fmt);
+
+	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;
+}
+
+int64_t ONICALL DDrMachineTime_Sixtieths()
+{
+	static uint32_t startticks = 0;
+	double ticks = 0;
+	
+	if (startticks)
+		ticks = GetTickCount() - startticks;
+	else
+		startticks = GetTickCount();
+	
+	return (int64_t)(ticks / 1000.0 * fps);
+}
+
+int64_t ONICALL DDrMachineTime_High()
+{
+//	LARGE_INTEGER PerfCount;
+//	
+//	if (!QueryPerformanceCounter(&PerfCount))
+//		PerfCount.QuadPart = GetTickCount();
+//	
+//	return PerfCount.QuadPart;
+	return GetTickCount();
+}
+
+double ONICALL DDrMachineTime_High_Frequency()
+{
+//	LARGE_INTEGER Frequency;
+//
+//	if (!QueryPerformanceFrequency(&Frequency))
+		return 1000.0;
+	
+//	return Frequency.QuadPart;
+}
+	
+void ONICALL DDrWeapon2Message(int* weapon, void* output_ptr) 
+{
+	char buffer[128] = {0};
+	char* weapon_string = (char*)(*(weapon + 1)+0x5C);
+	int16_t ammo = *(int16_t *)((int)weapon + 0x56);
+	int16_t maxammo = *(int16_t *)(*(weapon + 1)+0xC0);
+	float ratio = (float)ammo / (float)maxammo;
+	
+	char ammocolor;
+	if		(ratio >= .9)	ammocolor = 'g';
+	else if (ratio >= .5)	ammocolor = 'y';
+	else if (ratio >= .2)	ammocolor = 'o';
+	else					ammocolor = 'r';
+
+	DDrMake_Weapon_Message( weapon_string, buffer); //gets the name of the weapon and formats it...probably doesn't need to be in seperate func.
+	sprintf(SSrMessage_Find("autoprompt_weapon"), "%s |[%c.%i/%i]|", buffer, ammocolor, ammo, maxammo); //copies the new string to ONGS
+	ONiGameState_FindAutoPromptMessage("weapon", output_ptr);	//does what the code i replaced does. Basically tells the game to show the msg.
+}
+
+
+void ONICALL DDrMake_Weapon_Message(char* weapon_string, char* output_ptr) 
+{
+	char* weapon_msg = NULL;	//The normal "You have recieved X" message.
+	char weapon_name[64] = {'\0'};	//The stripped weapon name
+	//TODO, someday: dynamically detect different keybindings.
+	char default_msg[] = "Press [c.Q] to pick up weapon.";	//default return
+	
+	//Find the recieved message string
+	weapon_msg = SSrMessage_Find(weapon_string);
+	//this probably could be reorganized
+	if(weapon_msg) {	//SSrMsgblah returns NULL if it can't find the message key
+		memcpy(weapon_name, weapon_msg, (strstr(weapon_msg,"] ") - weapon_msg + 1)); //strips uneeded characters
+		sprintf(output_ptr, "Press [c.Q] to pick up %s", weapon_name);
+	}
+	else {
+		memcpy(output_ptr, default_msg, sizeof(default_msg));
+	}
+	
+}
+
+typedef struct
+{
+	uint16_t x;
+	uint16_t y;
+
+} IMtPoint2D;
+IMtPoint2D Point = {256, 250};
+extern void* TSrTest;
+extern void* TSrScores;
+unsigned int lastPasteTime;
+
+//TODO: Fix what happens when you hold down paste
+//Check if console is open
+void DDrPasteHack()
+{
+	COtTextArea* cons = *(COtTextArea**)0x00571B74;
+	char* clipboardText = 0;
+	if(ONgGameState->Input.Current.Actions1 & Action_Console && GetKeyState(0x56) & 0x80 && GetKeyState(VK_CONTROL) & 0x80 )
+	{
+		if(cons && cons->text_entries && cons->num_text_entries)
+		{
+			//why abs()? so we dont have to reset the timer after a level load.
+			if( abs(ONgGameState->GameTime - lastPasteTime) > 60) {
+				//DDrConsole_Print(cons->text_entries[0].text);
+				if(OpenClipboard(ONgPlatformData.Window))
+				{
+					unsigned short charsUsed = strlen(cons->text_entries[0].text);
+					//get rid of the v character
+					if(charsUsed) charsUsed--;
+					clipboardText = GetClipboardData(CF_TEXT);
+					if(clipboardText && strlen(clipboardText) + charsUsed < 502)
+					{
+						strcpy( cons->text_entries[0].text + charsUsed, clipboardText);
+						lastPasteTime = ONgGameState->GameTime;
+					}
+					CloseClipboard();
+				}
+
+			}
+			else
+			{
+				//need to hook whatever controls however often you can repeat characters...i guess.
+				//cons->text_entries[0].text[strlen(cons->text_entries[0].text) - 1] = 0;
+			}
+		}
+	}
+}
+
+void ONICALL DDrText_Hook()
+{
+
+	if(TSrTest)
+	{
+		TSrContext_DrawText(TSrTest, "FINALLY THIS BLOODY TEXT THING WORKS\n Gotta call it at the right point...", 128, 0, &Point);	
+
+	}
+
+
+	DDrPasteHack();
+	
+	COrConsole_StatusLine_Display();
+
+}
Index: Daodan/src/Patches/Utility.h
===================================================================
--- Daodan/src/Patches/Utility.h	(revision 994)
+++ Daodan/src/Patches/Utility.h	(revision 994)
@@ -0,0 +1,19 @@
+#ifndef UTILITY_H
+#define UTILITY_H
+
+#include "../Daodan.h"
+
+#define WHERESTR  "[%-22s:%4d ]: "
+#define WHEREARG  __FILE__, __LINE__
+#define DEBUGPRINT2(...)       DDrStartupMessage(__VA_ARGS__)
+#define STARTUPMESSAGE(_fmt, ...)  DEBUGPRINT2(WHERESTR _fmt, WHEREARG, __VA_ARGS__)
+
+
+void __cdecl DDrStartupMessage(const char* fmt, ...);
+int64_t ONICALL DDrMachineTime_High();
+double  ONICALL DDrMachineTime_High_Frequency();
+int64_t ONICALL DDrMachineTime_Sixtieths();
+void ONICALL DDrMake_Weapon_Message(char* weapon_string, char* output_ptr);
+void ONICALL DDrWeapon2Message(int* weapon, void* output_ptr);
+void ONICALL DDrText_Hook();
+#endif
Index: Daodan/src/Patches/Win32.c
===================================================================
--- Daodan/src/Patches/Win32.c	(revision 994)
+++ Daodan/src/Patches/Win32.c	(revision 994)
@@ -0,0 +1,183 @@
+#include <windows.h>
+
+#include "../Daodan.h"
+#include "../Daodan_Config.h"
+#include "Win32.h"
+
+#include "../Oni/Oni.h"
+
+
+// LIrPlatform_Terminate wrapper. Removes any cursor clipping we've done. Doing
+// this is required for Windows 98 :-D
+void ONICALL DD_LIrPlatform_Terminate(void)
+{
+	ClipCursor(NULL);
+	LIrPlatform_Terminate();
+}
+
+// LIrPlatform_Mode_Set wrapper. Clips cursor to window bounds to
+// prevent loosing focus (mostly on Linux).
+void ONICALL DD_LIrPlatform_Mode_Set(unsigned int active_mode)
+{
+	DDmAssert(ONgPlatformData.Window);
+
+	if (active_mode)
+	{
+		RECT rc;
+		POINT pt;
+
+		pt.x = 0;
+		pt.y = 0;
+
+		if (GetClientRect(ONgPlatformData.Window, &rc) &&
+			ClientToScreen(ONgPlatformData.Window, &pt))
+		{
+			rc.left   += pt.x;
+			rc.top    += pt.y;
+			rc.right  += pt.x;
+			rc.bottom += pt.y;
+
+			ClipCursor(&rc);
+		}
+	}
+	else
+	{
+		ClipCursor(NULL);
+	}
+
+	LIrPlatform_Mode_Set(active_mode);
+}
+
+BOOL WINAPI DD_GetCursorPos(LPPOINT lpPoint)
+{
+	DDmAssert(ONgPlatformData.Window);
+	
+	return GetCursorPos(lpPoint) && ScreenToClient(ONgPlatformData.Window, lpPoint);
+}
+
+BOOL WINAPI DD_SetCursorPos(int X, int Y)
+{
+	POINT pt;
+	pt.x = X;
+	pt.y = Y;
+	
+	DDmAssert(ONgPlatformData.Window);
+	
+	return ClientToScreen(ONgPlatformData.Window, &pt) && SetCursorPos(pt.x, pt.y);
+}
+
+static LRESULT CALLBACK DD_ONrPlatform_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+	switch (uMsg)
+	{
+		case WM_SYSCOMMAND:
+			if (wParam == SC_SCREENSAVE)
+			{
+				// Prevent screen saver from starting when Oni has focus.
+				return 0;
+			}
+			break;
+		
+		case WM_PAINT:
+		{
+			PAINTSTRUCT ps;
+			BeginPaint(hWnd, &ps);
+			// Oni does a useless PatBlt here.
+			EndPaint(hWnd, &ps);
+			return 0;
+		}
+		
+		case WM_CLOSE:
+			// There's no way to reliably terminate a modal dialog.
+			// The following condition is (almost) always true.
+			if (WMgActive)
+				exit(0);
+
+			ONgTerminateGame = UUcTrue;
+			return 0;
+			
+		case WM_SETCURSOR:
+			// If a mouse is inside our client area, we hide cursor (always),
+			// otherwise we ask DefWindowProc to set an appropriate arrow for us.
+			if (LOWORD(lParam) == HTCLIENT)
+			{
+				SetCursor(NULL);
+				return TRUE;
+			}
+			
+			break;
+	}
+	
+	return ONrPlatform_WindowProc(hWnd, uMsg, wParam, lParam);
+}
+
+
+UUtError ONICALL DD_ONrPlatform_Initialize(ONtPlatformData *PlatformData)
+{
+ 	WNDCLASSEX WndClass;
+ 	RECT Rect;
+ 	const int Width = 640, Height = 480;
+	DWORD window_style, window_style_ex;
+ 
+	PlatformData->Instance = ONgInstance;
+	PlatformData->Window   = NULL;
+	
+	if (FindWindow("ONI ", "ONI "))
+	{
+		AUrMessageBox(1, "Daodan: There is already an instance of the game running.");
+		exit(0);
+	}
+	
+	WndClass.cbSize        = sizeof(WndClass);
+	WndClass.style         = CS_VREDRAW | CS_HREDRAW | CS_OWNDC;
+	WndClass.cbClsExtra    = 0;
+	WndClass.cbWndExtra    = 0;
+	WndClass.hInstance     = PlatformData->Instance;
+	WndClass.hCursor       = NULL; // To debug: LoadCursor(NULL, IDC_ARROW);
+	WndClass.hIcon         = LoadIcon(ONgInstance, MAKEINTRESOURCE(103));
+	WndClass.hIconSm       = LoadIcon(ONgInstance, MAKEINTRESOURCE(103));
+	WndClass.hbrBackground = GetStockObject(BLACK_BRUSH);
+	WndClass.lpszMenuName = NULL;
+	WndClass.lpszMenuName  = NULL;
+ 	WndClass.lpszClassName = "ONI ";
+	WndClass.lpfnWndProc   = DD_ONrPlatform_WindowProc;
+ 
+ 	RegisterClassEx(&WndClass);
+ 	
+	if (M3gResolutionSwitch)
+	{
+		// Do not allow border and topmost flag for a fullscreen window.
+		window_style    = WS_POPUP;
+		window_style_ex = 0;
+	}
+	else
+	{
+		ConfigOption_t* co = DDrConfig_GetOptOfType("options.border", C_BOOL);
+		int opt_border = 0;
+		if (co && co->value.intBoolVal)
+			opt_border = 1;
+		co = DDrConfig_GetOptOfType("options.topmost", C_BOOL);
+		int opt_topmost = 0;
+		if (co && co->value.intBoolVal)
+			opt_topmost = 1;
+
+		window_style    = (opt_border) ? WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_DLGFRAME | WS_MINIMIZEBOX : WS_POPUP;
+		window_style_ex = (opt_topmost) ? WS_EX_TOPMOST : 0;
+	}
+	
+ 	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;
+	AdjustWindowRectEx(&Rect, window_style, FALSE, window_style_ex);
+	
+	PlatformData->Window = CreateWindowEx(window_style_ex, WndClass.lpszClassName, "ONI ", window_style,
+		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);
+ 
+	return UUcError_None;
+ }
+
Index: Daodan/src/Patches/Win32.h
===================================================================
--- Daodan/src/Patches/Win32.h	(revision 994)
+++ Daodan/src/Patches/Win32.h	(revision 994)
@@ -0,0 +1,13 @@
+#ifndef DD_WIN32_H
+#define DD_WIN32_H
+
+#include "../Daodan.h"
+#include "../Oni/Oni.h"
+
+UUtError ONICALL DD_ONrPlatform_Initialize(ONtPlatformData *PlatformData);
+BOOL WINAPI DD_GetCursorPos(LPPOINT lpPoint);
+BOOL WINAPI DD_SetCursorPos(int X, int Y);
+void ONICALL DD_LIrPlatform_Mode_Set(unsigned int active_mode);
+void ONICALL DD_LIrPlatform_Terminate(void);
+
+#endif
Index: Daodan/src/bink-proxy.c
===================================================================
--- Daodan/src/bink-proxy.c	(revision 993)
+++ Daodan/src/bink-proxy.c	(revision 994)
@@ -2,5 +2,5 @@
 
 #include <windows.h>
-#include "Daodan_Utility.h"
+#include "Patches/Utility.h"
 
 
Index: Daodan/src/makefile
===================================================================
--- Daodan/src/makefile	(revision 994)
+++ Daodan/src/makefile	(revision 994)
@@ -0,0 +1,58 @@
+# If SRC or TARGET is a folder it must end in a slash "/"
+SRC = 
+TARGET = ../build/
+SUBFOLDERS = Patches beaengine
+
+DEF = BEA_ENGINE_STATIC
+INCLUDEPATHS = .
+GCCFLAGS = -std=c99 -O0 -Wall -fomit-frame-pointer -fpack-struct -Wextra -Wno-pragmas -Wno-unused-variable $(addprefix -I,$(INCLUDEPATHS)) -Wno-unused-parameter $(addprefix -D,$(DEF))
+LINKFLAGS = -O0 -Wall -fomit-frame-pointer -fpack-struct -s -mdll
+LOCALE = LC_MESSAGES=C
+
+LIBDIRS = 
+LIBS = -lgdi32 -lwsock32
+OBJS = $(SRC)binkw32.def 
+OUT = $(TARGET)binkw32.dll
+
+FILES := _DLLInfo.rc $(foreach dir,. $(SUBFOLDERS),$(wildcard $(SRC)$(dir)/*.c))
+
+###################################################
+#                                                 #
+# Should not be required to change anything below #
+#                                                 #
+###################################################
+
+UNAME := $(shell uname -s)
+ifeq ("Linux","$(UNAME)")
+    GCC := i686-w64-mingw32-gcc
+    WINDRES := i686-w64-mingw32-windres
+else
+    GCC := gcc
+    WINDRES := windres
+endif
+
+DESTFOLDERS = $(addprefix $(TARGET),$(SUBFOLDERS))
+DEST = $(patsubst $(SRC)%.rc,$(TARGET)%.o,$(patsubst $(SRC)%.c,$(TARGET)%.o,$(FILES)))
+
+ALL: $(DESTFOLDERS) $(DEST) $(OBJS)
+	@echo "Linking"
+	$(LOCALE) $(GCC) $(LINKFLAGS) -o $(OUT) $(DEST) $(OBJS) $(LIBDIRS) $(LIBS)
+
+clean:
+	rm -f $(DEST)
+	rm -Rf $(DESTFOLDERS)
+	rm -f $(OUT)
+
+$(DESTFOLDERS):
+	mkdir -p $@
+
+$(TARGET)%.o: $(SRC)%.c
+	@echo "Compiling $<"
+	$(LOCALE) $(GCC) $(GCCFLAGS) -c -o $@ $<
+	@echo
+
+$(TARGET)%.o: $(SRC)%.rc
+	@echo "Assembling resource $<"
+	$(WINDRES) -i $< -o $@
+	@echo
+
