xoreos  0.0.5
ndsrom.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos 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
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef AURORA_NDSROM_H
26 #define AURORA_NDSROM_H
27 
28 #include <vector>
29 
30 #include "src/common/types.h"
31 #include "src/common/scopedptr.h"
32 #include "src/common/ustring.h"
33 
34 #include "src/aurora/types.h"
35 #include "src/aurora/archive.h"
36 
37 namespace Common {
38  class UString;
39  class SeekableReadStream;
40 }
41 
42 namespace Aurora {
43 
45 class NDSFile : public Archive {
46 public:
48  NDSFile(const Common::UString &fileName);
51  ~NDSFile();
52 
54  bool hasResource(Common::UString name) const;
55 
57  const ResourceList &getResources() const;
58 
60  uint32 getResourceSize(uint32 index) const;
61 
63  Common::SeekableReadStream *getResource(uint32 index, bool tryNoCopy = false) const;
64 
66  const Common::UString &getTitle() const;
68  const Common::UString &getCode() const;
70  const Common::UString &getMaker() const;
71 
73  static bool isNDS(Common::SeekableReadStream &stream,
74  Common::UString &title, Common::UString &code, Common::UString &maker);
75 
76 private:
78  struct IResource {
81  };
82 
83  typedef std::vector<IResource> IResourceList;
84 
86 
90 
93 
96 
98  void readNames(Common::SeekableReadStream &nds, uint32 offset, uint32 length);
99  void readFAT(Common::SeekableReadStream &nds, uint32 offset);
100 
101  const IResource &getIResource(uint32 index) const;
102 };
103 
104 } // End of namespace Aurora
105 
106 #endif // AURORA_NDSROM_H
const Common::UString & getTitle() const
Return the game title string stored in the NDS header.
Definition: ndsrom.cpp:110
Definition: 2dafile.h:39
Common::UString _title
Definition: ndsrom.h:87
A class holding an UTF-8 string.
Definition: ustring.h:48
ResourceList _resources
External list of resource names and types.
Definition: ndsrom.h:92
const Common::UString & getMaker() const
Return the maker code string stored in the NDS header.
Definition: ndsrom.cpp:118
Handling various archive files.
bool hasResource(Common::UString name) const
Does the Nintendo DS ROM contain a certain resource?
Definition: ndsrom.cpp:141
A simple scoped smart pointer template.
void readFAT(Common::SeekableReadStream &nds, uint32 offset)
Definition: ndsrom.cpp:100
Internal resource information.
Definition: ndsrom.h:78
std::list< Resource > ResourceList
Definition: archive.h:57
Common::UString _code
Definition: ndsrom.h:88
uint32 offset
The offset of the resource within the NDS.
Definition: ndsrom.h:79
Low-level type definitions to handle fixed width types portably.
const Common::UString & getCode() const
Return the game code string stored in the NDS header.
Definition: ndsrom.cpp:114
Common::SeekableReadStream * getResource(uint32 index, bool tryNoCopy=false) const
Return a stream of the resource&#39;s contents.
Definition: ndsrom.cpp:166
Unicode string handling.
void readNames(Common::SeekableReadStream &nds, uint32 offset, uint32 length)
Definition: ndsrom.cpp:79
Basic type definitions to handle files used in BioWare&#39;s Aurora engine.
IResourceList _iResources
Internal list of resource offsets and sizes.
Definition: ndsrom.h:95
Common::ScopedPtr< Common::SeekableReadStream > _nds
Definition: ndsrom.h:85
uint32_t uint32
Definition: types.h:204
std::vector< IResource > IResourceList
Definition: ndsrom.h:83
NDSFile(const Common::UString &fileName)
Over this file in the filesystem and read a NDS file out of it.
Definition: ndsrom.cpp:41
const IResource & getIResource(uint32 index) const
Definition: ndsrom.cpp:155
static bool isNDS(Common::SeekableReadStream &stream, Common::UString &title, Common::UString &code, Common::UString &maker)
Check if a stream is a valid Nintendo DS ROM and read its title, code and maker strings.
Definition: ndsrom.cpp:122
A class encapsulating Nintendo DS ROM access.
Definition: ndsrom.h:45
An abstract file archive.
Definition: archive.h:45
const ResourceList & getResources() const
Return the list of resources.
Definition: ndsrom.cpp:151
Common::UString _maker
Definition: ndsrom.h:89
uint32 getResourceSize(uint32 index) const
Return the size of a resource.
Definition: ndsrom.cpp:162
Interface for a seekable & readable data stream.
Definition: readstream.h:265
uint32 size
The resource&#39;s size.
Definition: ndsrom.h:80
void load(Common::SeekableReadStream &nds)
Definition: ndsrom.cpp:56