Index: /Daodan/makefile
===================================================================
--- /Daodan/makefile	(revision 982)
+++ /Daodan/makefile	(revision 983)
@@ -1,7 +1,9 @@
-FOLDERS = patches flatline
-FILES = Daodan.c Daodan_BSL.c Daodan_Character.c Daodan_Cheater.c Daodan_Config.c Daodan_Console.c Daodan_GL.c Daodan_Patch.c Daodan_Persistence.c Daodan_Utility.c Daodan_Win32.c Inifile_Reader.c _DLLInfo.rc patches/Patches.c flatline/Flatline.c flatline/Flatline_BSL.c flatline/Flatline_Client.c flatline/Flatline_Hooks.c flatline/Flatline_Net.c flatline/Flatline_Packet.c flatline/Flatline_PacketReader.c flatline/Flatline_PacketBuilder.c flatline/Flatline_Server.c flatline/Flatline_Win32.c flatline/Mariusnet.c flatline/Flatline_Events.c
+SRC = src
+TARGET = build
+SUBFOLDERS = patches flatline beaengine
 
-DEF = 
-GCCFLAGS = -std=c99 -O0 -Wall -fomit-frame-pointer -fpack-struct -Wextra -Wno-unused-variable -Wno-unused-parameter $(addprefix -D,$(DEF))
+DEF = BEA_ENGINE_STATIC
+INCLUDEPATHS = .
+GCCFLAGS = -std=c99 -O0 -Wall -fomit-frame-pointer -fpack-struct -Wextra -Wno-pragmas -Wno-unused-variable $(addprefix -I$(SRC)/,$(INCLUDEPATHS)) -Wno-unused-parameter $(addprefix -D,$(DEF))
 LINKFLAGS = -O0 -Wall -fomit-frame-pointer -fpack-struct -s -mdll
 LOCALE = LC_MESSAGES=C
@@ -9,7 +11,8 @@
 #LIBS = -lwinmm -lopengl32
 LIBS = -lgdi32 -lwsock32
-OBJS = src/binkw32.def 
-OUT = build/binkw32.dll
+OBJS = $(SRC)/binkw32.def 
+OUT = $(TARGET)/binkw32.dll
 
+FILES := src/_DLLInfo.rc $(foreach dir,. $(SUBFOLDERS),$(wildcard $(SRC)/$(dir)/*.c))
 
 ###################################################
@@ -28,7 +31,6 @@
 endif
 
-DESTFOLDERS = $(addprefix build/,$(FOLDERS))
-SRC = $(addprefix src/,$(FILES))
-DEST = $(patsubst src/%.rc,build/%.o,$(patsubst src/%.c,build/%.o,$(SRC)))
+DESTFOLDERS = $(addprefix $(TARGET)/,$(SUBFOLDERS))
+DEST = $(patsubst $(SRC)/%.rc,$(TARGET)/%.o,$(patsubst $(SRC)/%.c,$(TARGET)/%.o,$(FILES)))
 
 ALL: $(DESTFOLDERS) $(DEST) $(OBJS)
@@ -37,17 +39,17 @@
 
 clean:
-	rm $(DEST)
-	rm -R $(DESTFOLDERS)
-	rm $(OUT)
+	rm -f $(DEST)
+	rm -Rf $(DESTFOLDERS)
+	rm -f $(OUT)
 
 $(DESTFOLDERS):
 	mkdir -p $@
 
-build/%.o: src/%.c
+$(TARGET)/%.o: $(SRC)/%.c
 	@echo "Compiling $<"
 	$(LOCALE) $(GCC) $(GCCFLAGS) -c -o $@ $<
 	@echo
 
-build/%.o: src/%.rc
+$(TARGET)/%.o: $(SRC)/%.rc
 	@echo "Assembling resource $<"
 	$(WINDRES) -i $< -o $@
Index: /Daodan/src/Daodan.c
===================================================================
--- /Daodan/src/Daodan.c	(revision 982)
+++ /Daodan/src/Daodan.c	(revision 983)
@@ -21,5 +21,4 @@
 HMODULE DDrONiModule;
 
-
 void __cdecl DDrMain(int argc, char* argv[])
 {
@@ -37,6 +36,5 @@
 
 	DD_Patch_Init();
-	
-	
+
 	ONiMain(argc, argv);
 }
Index: /Daodan/src/Daodan_Config.c
===================================================================
--- /Daodan/src/Daodan_Config.c	(revision 982)
+++ /Daodan/src/Daodan_Config.c	(revision 983)
@@ -27,4 +27,5 @@
 bool patch_getcmdline = true;
 bool patch_hdscreens_lowres = true;
+bool patch_highres_console = true;
 bool patch_kickguns = false;
 bool patch_killvtune = true;
@@ -134,4 +135,6 @@
 			else if (!_stricmp(name, "hdscreens_lowres"))
 				patch_hdscreens_lowres = !_stricmp(inifile_cleanstr(value), "true");
+			else if (!_stricmp(name, "highres_console"))
+				patch_highres_console = !_stricmp(inifile_cleanstr(value), "true");
 			else if (!_stricmp(name, "kickguns"))
 				patch_kickguns = !_stricmp(inifile_cleanstr(value), "true");
Index: /Daodan/src/Daodan_Config.h
===================================================================
--- /Daodan/src/Daodan_Config.h	(revision 982)
+++ /Daodan/src/Daodan_Config.h	(revision 983)
@@ -22,4 +22,5 @@
 extern bool patch_getcmdline;
 extern bool patch_hdscreens_lowres;
+extern bool patch_highres_console;
 extern bool patch_kickguns;
 extern bool patch_killvtune;
Index: /Daodan/src/Daodan_Patch.c
===================================================================
--- /Daodan/src/Daodan_Patch.c	(revision 982)
+++ /Daodan/src/Daodan_Patch.c	(revision 983)
@@ -1,3 +1,6 @@
 #include "Daodan_Patch.h"
+#include "Daodan_Utility.h"
+#include <beaengine/BeaEngine.h>
+
 #include <windows.h>
 #include <stdlib.h>
@@ -36,4 +39,182 @@
 }
 
+void* DDrPatch_MakeDetour(void* from, void* to)
+{
+	int len = 0;
+/*
+    DISASM MyDisasm;
+    int i = 0;
+    DDrStartupMessage("");
+    DDrStartupMessage("");
+
+    memset (&MyDisasm, 0, sizeof(DISASM));
+    MyDisasm.EIP = (UIntPtr) from;
+    i = 0;
+    DDrStartupMessage("Orig before @ 0x%06x", from);
+    while (i<10){
+        len = Disasm(&MyDisasm);
+        if (len != UNKNOWN_OPCODE) {
+			DDrStartupMessage("%s, Opcode: 0x%x, len: %d, branch: %d, to: 0x%06x", MyDisasm.CompleteInstr, MyDisasm.Instruction.Opcode, len, MyDisasm.Instruction.BranchType, MyDisasm.Instruction.AddrValue);
+			DDrStartupMessage("    Cat: 0x%04x, prefix count: %d", MyDisasm.Instruction.Category & 0xffff, MyDisasm.Prefix.Number );
+            MyDisasm.EIP += (UIntPtr)len;
+            i++;
+        }
+    };
+    DDrStartupMessage("");
+*/
+
+	DISASM disasm;
+	memset(&disasm, 0, sizeof(DISASM));
+	disasm.EIP = (UIntPtr) from;
+
+	char* trampoline = malloc(40);
+	DDrPatch_NOOP(trampoline, 40);
+	int pos = 0;
+	int branches = 0;
+
+	while (((void*)disasm.EIP - from) < 5) {
+		len = Disasm(&disasm);
+		if (len != UNKNOWN_OPCODE) {
+			if ((disasm.Instruction.Category & 0xffff) == CONTROL_TRANSFER) {
+				if (disasm.Prefix.Number > 0) {
+						DDrStartupMessage("Daodan: Detour: Branch in trampoline area from address 0x%08x with prefixes", from);
+						return (void*)-1;
+				}
+				branches++;
+				int target = disasm.Instruction.AddrValue;
+				bool targetInTrampoline = ((void*)disasm.Instruction.AddrValue - from) < 5;
+				switch (disasm.Instruction.BranchType) {
+					case JmpType:
+					case CallType:
+						if (targetInTrampoline) {
+							int offset = disasm.Instruction.AddrValue - disasm.EIP;
+							if (disasm.Instruction.BranchType == JmpType)
+								DDrPatch_MakeJump(&trampoline[pos], &trampoline[pos]+offset);
+							else
+								DDrPatch_MakeCall(&trampoline[pos], &trampoline[pos]+offset);
+						} else {
+							if (disasm.Instruction.BranchType == JmpType)
+								DDrPatch_MakeJump(&trampoline[pos], (void*)target);
+							else
+								DDrPatch_MakeCall(&trampoline[pos], (void*)target);
+						}
+						pos += 5;
+						break;
+					case RetType:
+					case JECXZ:
+						memcpy(&trampoline[pos], (void*)disasm.EIP, len);
+						pos += len;
+						break;
+					// Opcode +1
+					case JO:
+					case JC:
+					case JE:
+					case JNA:
+					case JS:
+					case JP:
+					case JL:
+					case JNG:
+						if (targetInTrampoline) {
+							memcpy(&trampoline[pos], (void*)disasm.EIP, len);
+							pos += len;
+						} else {
+							trampoline[pos++] = disasm.Instruction.Opcode + 1;
+							trampoline[pos++] = 5;
+							DDrPatch_MakeJump(&trampoline[pos], (void*)target);
+							pos += 5;
+						}
+						break;
+					// Opcode -1
+					case JNO:
+					case JNC:
+					case JNE:
+					case JA:
+					case JNS:
+					case JNP:
+					case JNL:
+					case JG:
+						if (targetInTrampoline) {
+							memcpy(&trampoline[pos], (void*)disasm.EIP, len);
+							pos += len;
+						} else {
+							trampoline[pos++] = disasm.Instruction.Opcode - 1;
+							trampoline[pos++] = 5;
+							DDrPatch_MakeJump(&trampoline[pos], (void*)target);
+							pos += 5;
+						}
+						break;
+					default:
+						DDrStartupMessage("Daodan: Detour: Unknown branch in trampoline area from address 0x%08x", from);
+						return (void*)-1;
+				}
+			} else {
+				memcpy(&trampoline[pos], (void*)disasm.EIP, len);
+				pos += len;
+			}
+			disasm.EIP += (UIntPtr)len;
+		}
+		else {
+			DDrStartupMessage("Daodan: Detour: Unknown opcode in trampoline area from address 0x%08x", from);
+			return (void*)-1;
+		}
+	}
+
+	if (branches > 1) {
+		DDrStartupMessage("Daodan: Detour: Too many branches in trampoline'd code from address 0x%08x: %d", from, branches);
+		return (void*)-1;
+	}
+
+
+	DDrPatch_MakeJump(&trampoline[pos], (void*)disasm.EIP);
+	DDrPatch_NOOP(from, (void*)disasm.EIP - from);
+	DDrPatch_MakeJump(from, to);
+/*
+    memset (&MyDisasm, 0, sizeof(DISASM));
+    MyDisasm.EIP = (UIntPtr) trampoline;
+    i = 0;
+    DDrStartupMessage("Trampoline @ 0x%06x", trampoline);
+    while (i<10){
+        len = Disasm(&MyDisasm);
+        if (len != UNKNOWN_OPCODE) {
+            DDrStartupMessage(MyDisasm.CompleteInstr);
+            MyDisasm.EIP += (UIntPtr)len;
+            i++;
+        }
+    };
+    DDrStartupMessage("");
+     
+    memset (&MyDisasm, 0, sizeof(DISASM));
+    MyDisasm.EIP = disasm.EIP;
+    i = 0;
+    DDrStartupMessage("Orig after @ 0x%06x", disasm.EIP);
+    while (i<7){
+        len = Disasm(&MyDisasm);
+        if (len != UNKNOWN_OPCODE) {
+            DDrStartupMessage(MyDisasm.CompleteInstr);
+            MyDisasm.EIP += (UIntPtr)len;
+            i++;
+        }
+    };
+    DDrStartupMessage("");
+
+    memset (&MyDisasm, 0, sizeof(DISASM));
+    MyDisasm.EIP = (UIntPtr) from;
+    i = 0;
+    DDrStartupMessage("Orig start after @ 0x%06x", from);
+    while (i<3){
+        len = Disasm(&MyDisasm);
+        if (len != UNKNOWN_OPCODE) {
+            DDrStartupMessage(MyDisasm.CompleteInstr);
+            MyDisasm.EIP += (UIntPtr)len;
+            i++;
+        }
+    };
+    DDrStartupMessage("");
+    DDrStartupMessage("");
+    DDrStartupMessage("");
+     */
+	return trampoline;
+}
+
 bool DDrPatch_String(char* dest, const unsigned char* string, int length)
 {
Index: /Daodan/src/Daodan_Patch.h
===================================================================
--- /Daodan/src/Daodan_Patch.h	(revision 982)
+++ /Daodan/src/Daodan_Patch.h	(revision 983)
@@ -10,4 +10,5 @@
 bool DDrPatch_MakeJump(void* from, void* to);
 bool DDrPatch_MakeCall(void* from, void* to);
+void* DDrPatch_MakeDetour(void* from, void* to);
 bool DDrPatch_String(char* dest, const unsigned char* string, int length);
 bool DDrPatch_Byte(char* dest, unsigned char value);
Index: /Daodan/src/Oni.h
===================================================================
--- /Daodan/src/Oni.h	(revision 982)
+++ /Daodan/src/Oni.h	(revision 983)
@@ -16,4 +16,10 @@
 } ONtPlatformData;
 
+typedef struct {
+	int16_t left;
+	int16_t top;
+	int16_t right;
+	int16_t bottom;
+} UUtRect;
 
 void ONICALL TMrInstance_GetDataPtr_List( 
Index: /Daodan/src/Oni_Symbols.h
===================================================================
--- /Daodan/src/Oni_Symbols.h	(revision 982)
+++ /Daodan/src/Oni_Symbols.h	(revision 983)
@@ -23,4 +23,8 @@
 #define COgConsoleLines		(*((uint32_t*)0x005cb468))
 
+// Command line instance
+#define COgCommandLine		(*((void**)0x00571b74))
+
+
 // Default console text color
 #define COgDefaultTextShade	(*((uint32_t*)0x00533f70))
@@ -156,4 +160,5 @@
 // Print message to console
 DefFunc(void, COrTextArea_Print, ONICALL, (uint32_t area, uint32_t priority, uint32_t textshade, uint32_t textshadowshade, const char* text, uint32_t unk_alwaws_0, uint32_t fadetime), 0x00431340);
+DefFunc(int16_t, COrTextArea_Resize, ONICALL, (void* inTextArea, UUtRect* inBounds, int16_t inNumTextEntries), 0x00431460);
 
 // Original cheat function
@@ -195,6 +200,6 @@
 DefFunc(int16_t, TSrContext_DrawText, ONICALL, (uint32_t TSrContext, char* Text, char alpha, uint32_t usuallyzero, void* pRect), 0x0042DF00);
 DefFunc(int16_t, TSrContext_New, ONICALL, (void* FontInstance, int size, int hthsik1,int hthsik2,int hthsik3, void* TSrContext), 0x0042EA30);
-
-DefFunc(int16_t, TSrContext_SetShade, ONICALL, (void *ioTextContext, uint32_t inShade), 0x0042EE50);
+DefFunc(int16_t, TSrContext_SetFontSize, ONICALL, (void* ioTextContext, uint16_t inSize), 0x0042ED50);
+DefFunc(int16_t, TSrContext_SetShade, ONICALL, (void* ioTextContext, uint32_t inShade), 0x0042EE50);
 
 DefFunc(uint16_t, TRrAnimation_GetDuration, ONICALL, (void* Animation), 0x00428740);
Index: /Daodan/src/_Version.h
===================================================================
--- /Daodan/src/_Version.h	(revision 982)
+++ /Daodan/src/_Version.h	(revision 983)
@@ -6,5 +6,5 @@
 
 #define DAODAN_VERSION_MAJOR 3
-#define DAODAN_VERSION_MINOR 5
+#define DAODAN_VERSION_MINOR 6
 #define DAODAN_VERSION_STRING STRINGIZE(DAODAN_VERSION_MAJOR) "." STRINGIZE(DAODAN_VERSION_MINOR)
 
Index: /Daodan/src/patches/Patches.c
===================================================================
--- /Daodan/src/patches/Patches.c	(revision 982)
+++ /Daodan/src/patches/Patches.c	(revision 983)
@@ -90,7 +90,6 @@
 //this was broken 
 FILE** _UUgError_WarningFile = (FILE**)0x005711B4;
-FILE *__fastcall DDrPrintWarning(int filename, int linenumber, unsigned __int16 errornum, int message)
-{
-
+FILE* ONICALL DDrPrintWarning(int filename, int linenumber, unsigned __int16 errornum, int message)
+{
 	FILE *v4; // eax@1
 	FILE *result; // eax@4
@@ -121,4 +120,11 @@
 }
 
+_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 -= 5;
+	}
+	return Oni_COrTextArea_Resize(inTextArea, inBounds, inNumTextEntries);
+}
 
 int DD_Patch_DebugNameTextureInit(short width, short height, int type, int allocated, int flags, char* name, void** output)
@@ -320,4 +326,8 @@
 }
 
+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.
@@ -594,4 +604,7 @@
 	if (patch_hdscreens_lowres)
 		DD_Patch_HDScreens_LowRes();
+
+	if (patch_highres_console)
+		DD_Patch_HighresConsole();
 	
 	if (patch_kickguns)
