summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/src/log.h4
-rw-r--r--src/common/src/log_manager.cpp4
-rw-r--r--src/core/core.vcxproj2
-rw-r--r--src/core/core.vcxproj.filters2
-rw-r--r--src/core/src/loader.cpp123
-rw-r--r--src/core/src/loader.h76
6 files changed, 207 insertions, 4 deletions
diff --git a/src/common/src/log.h b/src/common/src/log.h
index c2549affb..fb39720a3 100644
--- a/src/common/src/log.h
+++ b/src/common/src/log.h
@@ -47,8 +47,8 @@ enum LOG_TYPE {
47 STREAMINGINTERFACE, 47 STREAMINGINTERFACE,
48 VIDEO, 48 VIDEO,
49 VIDEOINTERFACE, 49 VIDEOINTERFACE,
50 WII_IOB, 50 LOADER,
51 WII_IPC, 51 FILESYS,
52 WII_IPC_DVD, 52 WII_IPC_DVD,
53 WII_IPC_ES, 53 WII_IPC_ES,
54 WII_IPC_FILEIO, 54 WII_IPC_FILEIO,
diff --git a/src/common/src/log_manager.cpp b/src/common/src/log_manager.cpp
index e202d01d3..16dae6521 100644
--- a/src/common/src/log_manager.cpp
+++ b/src/common/src/log_manager.cpp
@@ -60,8 +60,8 @@ LogManager::LogManager()
60 m_Log[LogTypes::CONSOLE] = new LogContainer("CONSOLE", "Dolphin Console"); 60 m_Log[LogTypes::CONSOLE] = new LogContainer("CONSOLE", "Dolphin Console");
61 m_Log[LogTypes::OSREPORT] = new LogContainer("OSREPORT", "OSReport"); 61 m_Log[LogTypes::OSREPORT] = new LogContainer("OSREPORT", "OSReport");
62 m_Log[LogTypes::WIIMOTE] = new LogContainer("Wiimote", "Wiimote"); 62 m_Log[LogTypes::WIIMOTE] = new LogContainer("Wiimote", "Wiimote");
63 m_Log[LogTypes::WII_IOB] = new LogContainer("WII_IOB", "WII IO Bridge"); 63 m_Log[LogTypes::LOADER] = new LogContainer("Loader", "Loader");
64 m_Log[LogTypes::WII_IPC] = new LogContainer("WII_IPC", "WII IPC"); 64 m_Log[LogTypes::FILESYS] = new LogContainer("FileSys", "File System");
65 m_Log[LogTypes::WII_IPC_HID] = new LogContainer("WII_IPC_HID", "WII IPC HID"); 65 m_Log[LogTypes::WII_IPC_HID] = new LogContainer("WII_IPC_HID", "WII IPC HID");
66 m_Log[LogTypes::WII_IPC_HLE] = new LogContainer("WII_IPC_HLE", "WII IPC HLE"); 66 m_Log[LogTypes::WII_IPC_HLE] = new LogContainer("WII_IPC_HLE", "WII IPC HLE");
67 m_Log[LogTypes::WII_IPC_DVD] = new LogContainer("WII_IPC_DVD", "WII IPC DVD"); 67 m_Log[LogTypes::WII_IPC_DVD] = new LogContainer("WII_IPC_DVD", "WII IPC DVD");
diff --git a/src/core/core.vcxproj b/src/core/core.vcxproj
index 081f4a489..11e31c8f5 100644
--- a/src/core/core.vcxproj
+++ b/src/core/core.vcxproj
@@ -137,6 +137,7 @@
137 <ClCompile Include="src\arm\arminit.cpp" /> 137 <ClCompile Include="src\arm\arminit.cpp" />
138 <ClCompile Include="src\arm\disassembler\arm_disasm.cpp" /> 138 <ClCompile Include="src\arm\disassembler\arm_disasm.cpp" />
139 <ClCompile Include="src\core.cpp" /> 139 <ClCompile Include="src\core.cpp" />
140 <ClCompile Include="src\loader.cpp" />
140 <ClCompile Include="src\mem_map.cpp" /> 141 <ClCompile Include="src\mem_map.cpp" />
141 <ClCompile Include="src\mem_map_funcs.cpp" /> 142 <ClCompile Include="src\mem_map_funcs.cpp" />
142 </ItemGroup> 143 </ItemGroup>
@@ -155,6 +156,7 @@
155 <ClInclude Include="src\arm\mmu\wb.h" /> 156 <ClInclude Include="src\arm\mmu\wb.h" />
156 <ClInclude Include="src\arm\skyeye_defs.h" /> 157 <ClInclude Include="src\arm\skyeye_defs.h" />
157 <ClInclude Include="src\core.h" /> 158 <ClInclude Include="src\core.h" />
159 <ClInclude Include="src\loader.h" />
158 <ClInclude Include="src\mem_map.h" /> 160 <ClInclude Include="src\mem_map.h" />
159 </ItemGroup> 161 </ItemGroup>
160 <ItemGroup> 162 <ItemGroup>
diff --git a/src/core/core.vcxproj.filters b/src/core/core.vcxproj.filters
index cf374ee88..51aa17d76 100644
--- a/src/core/core.vcxproj.filters
+++ b/src/core/core.vcxproj.filters
@@ -13,6 +13,7 @@
13 <Filter>arm</Filter> 13 <Filter>arm</Filter>
14 </ClCompile> 14 </ClCompile>
15 <ClCompile Include="src\mem_map_funcs.cpp" /> 15 <ClCompile Include="src\mem_map_funcs.cpp" />
16 <ClCompile Include="src\loader.cpp" />
16 </ItemGroup> 17 </ItemGroup>
17 <ItemGroup> 18 <ItemGroup>
18 <Filter Include="arm"> 19 <Filter Include="arm">
@@ -67,6 +68,7 @@
67 <ClInclude Include="src\arm\mmu\wb.h"> 68 <ClInclude Include="src\arm\mmu\wb.h">
68 <Filter>arm\mmu</Filter> 69 <Filter>arm\mmu</Filter>
69 </ClInclude> 70 </ClInclude>
71 <ClInclude Include="src\loader.h" />
70 </ItemGroup> 72 </ItemGroup>
71 <ItemGroup> 73 <ItemGroup>
72 <None Include="CMakeLists.txt" /> 74 <None Include="CMakeLists.txt" />
diff --git a/src/core/src/loader.cpp b/src/core/src/loader.cpp
new file mode 100644
index 000000000..44cb92a29
--- /dev/null
+++ b/src/core/src/loader.cpp
@@ -0,0 +1,123 @@
1/**
2 * Copyright (C) 2013 Citrus Emulator
3 *
4 * @file loader.cpp
5 * @author ShizZy <shizzy247@gmail.com>
6 * @date 2013-09-18
7 * @brief Loads bootable binaries into the emu
8 *
9 * @section LICENSE
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details at
19 * http://www.gnu.org/copyleft/gpl.html
20 *
21 * Official project repository can be found at:
22 * http://code.google.com/p/gekko-gc-emu/
23 */
24
25#include "file_util.h"
26#include "loader.h"
27
28////////////////////////////////////////////////////////////////////////////////////////////////////
29
30bool _Load_BIN(std::string &filename) {
31 File::IOFile f(filename, "rb");
32 if (f.IsOpen()) {
33 // TODO(ShizZy): read here to memory....
34 }
35 return true;
36}
37
38namespace Loader {
39
40/**
41 * Identifies the type of a bootable file
42 * @param filename String filename of bootable file
43 * @todo (ShizZy) this function sucks... make it actually check file contents etc.
44 * @return FileType of file
45 */
46FileType IdentifyFile(std::string &filename) {
47 if (filename.size() == 0) {
48 ERROR_LOG(LOADER, "invalid filename %s", filename.c_str());
49 return FILETYPE_ERROR;
50 }
51 std::string extension = filename.size() >= 5 ? filename.substr(filename.size() - 4) : "";
52
53 if (File::IsDirectory(filename)) {
54 return FILETYPE_NORMAL_DIRECTORY;
55 } else if (!strcasecmp(extension.c_str(),".bin")) {
56 return FILETYPE_3DS_BIN;
57 } else if (!strcasecmp(extension.c_str(),".zip")) {
58 return FILETYPE_ARCHIVE_ZIP;
59 } else if (!strcasecmp(extension.c_str(),".rar")) {
60 return FILETYPE_ARCHIVE_RAR;
61 } else if (!strcasecmp(extension.c_str(),".r00")) {
62 return FILETYPE_ARCHIVE_RAR;
63 } else if (!strcasecmp(extension.c_str(),".r01")) {
64 return FILETYPE_ARCHIVE_RAR;
65 }
66 return FILETYPE_UNKNOWN;
67}
68
69/**
70 * Identifies and loads a bootable file
71 * @param filename String filename of bootable file
72 * @param error_string Point to string to put error message if an error has occurred
73 * @return True on success, otherwise false
74 */
75bool LoadFile(std::string &filename, std::string *error_string) {
76 INFO_LOG(LOADER,"Identifying file...");
77 // Note that this can modify filename!
78 switch (IdentifyFile(filename)) {
79
80 case FILETYPE_3DS_BIN:
81 {
82 INFO_LOG(LOADER,"File is a BIN !");
83 return _Load_BIN(filename);
84 }
85
86 case FILETYPE_ERROR:
87 ERROR_LOG(LOADER, "Could not read file");
88 *error_string = "Error reading file";
89 break;
90
91 case FILETYPE_ARCHIVE_RAR:
92#ifdef WIN32
93 *error_string = "RAR file detected (Require WINRAR)";
94#else
95 *error_string = "RAR file detected (Require UnRAR)";
96#endif
97 break;
98
99 case FILETYPE_ARCHIVE_ZIP:
100#ifdef WIN32
101 *error_string = "ZIP file detected (Require WINRAR)";
102#else
103 *error_string = "ZIP file detected (Require UnRAR)";
104#endif
105 break;
106
107 case FILETYPE_NORMAL_DIRECTORY:
108 ERROR_LOG(LOADER, "Just a directory.");
109 *error_string = "Just a directory.";
110 break;
111
112 case FILETYPE_UNKNOWN_BIN:
113 case FILETYPE_UNKNOWN_ELF:
114 case FILETYPE_UNKNOWN:
115 default:
116 ERROR_LOG(LOADER, "Failed to identify file");
117 *error_string = "Failed to identify file";
118 break;
119 }
120 return false;
121}
122
123} // namespace \ No newline at end of file
diff --git a/src/core/src/loader.h b/src/core/src/loader.h
new file mode 100644
index 000000000..4a0b3cf67
--- /dev/null
+++ b/src/core/src/loader.h
@@ -0,0 +1,76 @@
1/**
2 * Copyright (C) 2013 Citrus Emulator
3 *
4 * @file loader.h
5 * @author ShizZy <shizzy247@gmail.com>
6 * @date 2013-09-18
7 * @brief Loads bootable binaries into the emu
8 *
9 * @section LICENSE
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details at
19 * http://www.gnu.org/copyleft/gpl.html
20 *
21 * Official project repository can be found at:
22 * http://code.google.com/p/gekko-gc-emu/
23 */
24
25#ifndef CORE_LOADER_H_
26#define CORE_LOADER_H_
27
28#include "common.h"
29
30////////////////////////////////////////////////////////////////////////////////////////////////////
31
32namespace Loader {
33
34enum FileType {
35 FILETYPE_ERROR,
36
37 FILETYPE_3DS_CCI,
38 FILETYPE_3DS_CIA,
39 FILETYPE_3DS_CXI,
40
41 FILETYPE_3DS_BIN,
42 FILETYPE_3DS_ELF,
43
44 FILETYPE_CTR_DISC_DIRECTORY,
45
46 FILETYPE_UNKNOWN_BIN,
47 FILETYPE_UNKNOWN_ELF,
48
49 FILETYPE_ARCHIVE_RAR,
50 FILETYPE_ARCHIVE_ZIP,
51
52 FILETYPE_NORMAL_DIRECTORY,
53
54 FILETYPE_UNKNOWN
55};
56
57////////////////////////////////////////////////////////////////////////////////////////////////////
58
59/**
60 * Identifies the type of a bootable file
61 * @param filename String filename of bootable file
62 * @return FileType of file
63 */
64FileType IdentifyFile(std::string &filename);
65
66/**
67 * Identifies and loads a bootable file
68 * @param filename String filename of bootable file
69 * @param error_string Point to string to put error message if an error has occurred
70 * @return True on success, otherwise false
71 */
72bool LoadFile(std::string &filename, std::string *error_string);
73
74} // namespace
75
76#endif // CORE_LOADER_H_ \ No newline at end of file