1 /*
2  *  Open Fodder
3  *  ---------------
4  *
5  *  Copyright (C) 2008-2018 Open Fodder
6  *
7  *  This program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 3 of the License, or
10  *  (at your option) any later version.
11  *
12  *  This program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License along
18  *  with this program; if not, write to the Free Software Foundation, Inc.,
19  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  */
22 
23 #include "stdafx.hpp"
24 
25 std::shared_ptr<cResources> g_Resource;
26 std::shared_ptr<cWindow>    g_Window;
27 std::shared_ptr<cFodder>    g_Fodder;
28 std::shared_ptr<cDebugger>  g_Debugger;
29 std::shared_ptr<cResourceMan> g_ResourceMan;
30 std::shared_ptr<cScriptingEngine> g_ScriptingEngine;
31 
32 const char gPathSeperator = '/';
33 
main(int argc,char * argv[])34 int main(int argc, char *argv[]) {
35 	auto result = start(argc, argv);
36 	if (result == -1) {
37 		std::cout << "Press enter to continue\n";
38 		std::cin.get();
39 	}
40 
41 	return result;
42 }
43 
44 /**
45  *
46  * @param pBuffer
47  * @param pSize Number of words
48  */
tool_EndianSwap(uint8 * pBuffer,size_t pSize)49 void tool_EndianSwap(uint8 *pBuffer, size_t pSize) {
50 	uint8 *pDest = pBuffer;
51 
52 	pSize /= 2;
53 
54 	while (pSize--) {
55 		uint8 al = *pBuffer++;
56 		uint8 ah = *pBuffer++;
57 
58 		*pDest++ = ah;
59 		*pDest++ = al;
60 	}
61 }
62 
tool_StripLeadingZero(const std::string & pValue)63 std::string tool_StripLeadingZero(const std::string& pValue) {
64 	std::string Final = pValue;
65 
66 	while (*Final.begin() == 0x30 && Final.length() > 1) {
67 
68 		Final.erase(Final.begin());
69 	}
70 
71 	return Final;
72 }
73 
tool_DecimalToBinaryCodedDecimal(uint16 pDecimal)74 uint16 tool_DecimalToBinaryCodedDecimal(uint16 pDecimal) {
75 
76 	return ((pDecimal / 10) << 4) + (pDecimal % 10);
77 }
78