diff --git a/.travis.yml b/.travis.yml
index 6ad8a79..d46ae3a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,10 +1,17 @@
-install:
- - sudo apt-get update
- - sudo apt-get install qt4-qmake
+compiler:
+ - gcc-4.8
+
+before_install:
+ - sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa
+ - sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
+ - sudo apt-get update -qq
+ - sudo apt-get install -qq g++-4.8
+ - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8
+ - sudo update-alternatives --config gcc
script:
- - qmake libzelda.pro
- - make
+ - qmake Athena.pro
+ - make
notifications:
- irc: "irc.wiiking.com#wiiking2"
+ irc: "irc.wiiking2.com#wiiking2"
diff --git a/Athena.pri b/Athena.pri
new file mode 100644
index 0000000..9b606a7
--- /dev/null
+++ b/Athena.pri
@@ -0,0 +1,108 @@
+INCLUDEPATH += $$PWD/include
+
+unix:LIBS += -lz
+win32:LIBS += -lzlib
+QMAKE_CXXFLAGS += -std=c++11
+CONFIG -= qt
+
+SOURCES += \
+ $$PWD/src/Athena/Utility.cpp \
+ $$PWD/src/Athena/FileReader.cpp \
+ $$PWD/src/Athena/FileWriter.cpp \
+ $$PWD/src/Athena/BinaryReader.cpp \
+ $$PWD/src/Athena/BinaryWriter.cpp \
+ $$PWD/src/Athena/Global.cpp \
+ $$PWD/src/Athena/ALTTPFile.cpp \
+ $$PWD/src/Athena/ALTTPFileReader.cpp \
+ $$PWD/Athena/ALTTPFileWriter.cpp \
+ $$PWD/Athena/ALTTPQuest.cpp \
+ $$PWD/Athena/Checksums.cpp \
+ $$PWD/Athena/Compression.cpp \
+ $$PWD/Athena/MCFile.cpp \
+ $$PWD/Athena/MCFileReader.cpp \
+ $$PWD/Athena/MCFileWriter.cpp \
+ $$PWD/Athena/SkywardSwordFile.cpp \
+ $$PWD/Athena/SkywardSwordFileReader.cpp \
+ $$PWD/Athena/SkywardSwordFileWriter.cpp \
+ $$PWD/Athena/SkywardSwordQuest.cpp \
+ $$PWD/Athena/Sprite.cpp \
+ $$PWD/Athena/SpriteFile.cpp \
+ $$PWD/Athena/SpriteFileReader.cpp \
+ $$PWD/Athena/SpriteFileWriter.cpp \
+ $$PWD/Athena/SpriteFrame.cpp \
+ $$PWD/Athena/SpritePart.cpp \
+ $$PWD/Athena/WiiBanner.cpp \
+ $$PWD/Athena/WiiFile.cpp \
+ $$PWD/Athena/WiiImage.cpp \
+ $$PWD/Athena/WiiSave.cpp \
+ $$PWD/Athena/WiiSaveReader.cpp \
+ $$PWD/Athena/WiiSaveWriter.cpp \
+ $$PWD/Athena/ZQuestFile.cpp \
+ $$PWD/Athena/ZQuestFileReader.cpp \
+ $$PWD/Athena/ZQuestFileWriter.cpp \
+ $$PWD/bn.cpp \
+ $$PWD/ec.cpp \
+ $$PWD/md5.cpp \
+ $$PWD/sha1.cpp \
+ $$PWD/aes.c \
+ $$PWD/lzo.c
+
+HEADERS += \
+ $$PWD/Athena/Stream.hpp \
+ $$PWD/Athena/Types.hpp \
+ $$PWD/Athena/Utility.hpp \
+ $$PWD/Athena/Global.hpp \
+ $$PWD/Athena/Exception.hpp \
+ $$PWD/Athena/FileNotFoundException.hpp \
+ $$PWD/Athena/IOException.hpp \
+ $$PWD/Athena/InvalidDataException.hpp \
+ $$PWD/Athena/InvalidOperationException.hpp \
+ $$PWD/Athena/FileReader.hpp \
+ $$PWD/Athena/FileWriter.hpp \
+ $$PWD/utf8.h \
+ $$PWD/utf8/checked.h \
+ $$PWD/utf8/core.h \
+ $$PWD/utf8/unchecked.h \
+ $$PWD/Athena/BinaryReader.hpp \
+ $$PWD/Athena/BinaryWriter.hpp \
+ $$PWD/Athena/NotImplementedException.hpp \
+ $$PWD/aes.h \
+ $$PWD/bn.h \
+ $$PWD/ec.h \
+ $$PWD/lzo.h \
+ $$PWD/md5.h \
+ $$PWD/sha1.h \
+ $$PWD/Athena/ALTTPEnums.hpp \
+ $$PWD/Athena/ALTTPFile.hpp \
+ $$PWD/Athena/ALTTPFileReader.hpp \
+ $$PWD/Athena/ALTTPFileWriter.hpp \
+ $$PWD/Athena/ALTTPQuest.hpp \
+ $$PWD/Athena/ALTTPStructs.hpp \
+ $$PWD/Athena/Checksums.hpp \
+ $$PWD/Athena/Compression.hpp \
+ $$PWD/Athena/MCFile.hpp \
+ $$PWD/Athena/MCFileReader.hpp \
+ $$PWD/Athena/MCFileWriter.hpp \
+ $$PWD/Athena/SkywardSwordFile.hpp \
+ $$PWD/Athena/SkywardSwordFileReader.hpp \
+ $$PWD/Athena/SkywardSwordFileWriter.hpp \
+ $$PWD/Athena/SkywardSwordQuest.hpp \
+ $$PWD/Athena/Sprite.hpp \
+ $$PWD/Athena/SpriteFile.hpp \
+ $$PWD/Athena/SpriteFileReader.hpp \
+ $$PWD/Athena/SpriteFileWriter.hpp \
+ $$PWD/Athena/SpriteFrame.hpp \
+ $$PWD/Athena/SpritePart.hpp \
+ $$PWD/Athena/WiiBanner.hpp \
+ $$PWD/Athena/WiiFile.hpp \
+ $$PWD/Athena/WiiImage.hpp \
+ $$PWD/Athena/WiiSave.hpp \
+ $$PWD/Athena/WiiSaveReader.hpp \
+ $$PWD/Athena/WiiSaveWriter.hpp \
+ $$PWD/Athena/ZQuestFile.hpp \
+ $$PWD/Athena/ZQuestFileReader.hpp \
+ $$PWD/Athena/ZQuestFileWriter.hpp
+
+OTHER_FILES += \
+ .travis.yml
+
diff --git a/Athena.pro b/Athena.pro
new file mode 100644
index 0000000..0491fe9
--- /dev/null
+++ b/Athena.pro
@@ -0,0 +1,137 @@
+CONFIG += staticlib
+TEMPLATE= lib
+DESTDIR = ./lib
+
+# Uncomment this if you wish to use Qt with libAthena
+#DEFINES += ATHENA_USE_QT
+
+contains(DEFINES, ATHENA_USE_QT){
+ QT += core
+}
+
+CONFIG(debug, debug|release){
+ DEFINES += DEBUG
+ TARGET=Athena-d
+ # We don't want the objects,
+ # in the project directory, so tell qmake
+ # where to put them
+ OBJECTS_DIR = obj/debug
+}
+
+CONFIG(release, release|debug){
+ DEFINES -= DEBUG
+ TARGET=Athena
+ # We don't want the objects,
+ # in the project directory, so tell qmake
+ # where to put them
+ OBJECTS_DIR = obj/release
+}
+
+QMAKE_CXXFLAGS += -std=c++11
+INCLUDEPATH += include
+CONFIG -= qt
+
+
+SOURCES += \
+ src/Athena/Utility.cpp \
+ src/Athena/FileReader.cpp \
+ src/Athena/FileWriter.cpp \
+ src/Athena/BinaryReader.cpp \
+ src/Athena/BinaryWriter.cpp \
+ src/Athena/Global.cpp \
+ src/Athena/ALTTPFile.cpp \
+ src/Athena/ALTTPFileReader.cpp \
+ src/Athena/ALTTPFileWriter.cpp \
+ src/Athena/ALTTPQuest.cpp \
+ src/Athena/Checksums.cpp \
+ src/Athena/Compression.cpp \
+ src/Athena/MCFile.cpp \
+ src/Athena/MCFileReader.cpp \
+ src/Athena/MCFileWriter.cpp \
+ src/Athena/SkywardSwordFile.cpp \
+ src/Athena/SkywardSwordFileReader.cpp \
+ src/Athena/SkywardSwordFileWriter.cpp \
+ src/Athena/SkywardSwordQuest.cpp \
+ src/Athena/Sprite.cpp \
+ src/Athena/SpriteFile.cpp \
+ src/Athena/SpriteFileReader.cpp \
+ src/Athena/SpriteFileWriter.cpp \
+ src/Athena/SpriteFrame.cpp \
+ src/Athena/SpritePart.cpp \
+ src/Athena/WiiBanner.cpp \
+ src/Athena/WiiFile.cpp \
+ src/Athena/WiiImage.cpp \
+ src/Athena/WiiSave.cpp \
+ src/Athena/WiiSaveReader.cpp \
+ src/Athena/WiiSaveWriter.cpp \
+ src/Athena/ZQuestFile.cpp \
+ src/Athena/ZQuestFileReader.cpp \
+ src/Athena/ZQuestFileWriter.cpp \
+ src/bn.cpp \
+ src/ec.cpp \
+ src/md5.cpp \
+ src/sha1.cpp \
+ src/aes.c \
+ src/lzo.c
+
+INCLUDEPATH += \
+ include
+
+HEADERS += \
+ include/Athena/Stream.hpp \
+ include/Athena/Types.hpp \
+ include/Athena/Utility.hpp \
+ include/Athena/Global.hpp \
+ include/Athena/Exception.hpp \
+ include/Athena/FileNotFoundException.hpp \
+ include/Athena/IOException.hpp \
+ include/Athena/InvalidDataException.hpp \
+ include/Athena/InvalidOperationException.hpp \
+ include/Athena/FileReader.hpp \
+ include/Athena/FileWriter.hpp \
+ include/utf8.h \
+ include/utf8/checked.h \
+ include/utf8/core.h \
+ include/utf8/unchecked.h \
+ include/Athena/BinaryReader.hpp \
+ include/Athena/BinaryWriter.hpp \
+ include/Athena/NotImplementedException.hpp \
+ include/aes.h \
+ include/bn.h \
+ include/ec.h \
+ include/lzo.h \
+ include/md5.h \
+ include/sha1.h \
+ include/Athena/ALTTPEnums.hpp \
+ include/Athena/ALTTPFile.hpp \
+ include/Athena/ALTTPFileReader.hpp \
+ include/Athena/ALTTPFileWriter.hpp \
+ include/Athena/ALTTPQuest.hpp \
+ include/Athena/ALTTPStructs.hpp \
+ include/Athena/Checksums.hpp \
+ include/Athena/Compression.hpp \
+ include/Athena/MCFile.hpp \
+ include/Athena/MCFileReader.hpp \
+ include/Athena/MCFileWriter.hpp \
+ include/Athena/SkywardSwordFile.hpp \
+ include/Athena/SkywardSwordFileReader.hpp \
+ include/Athena/SkywardSwordFileWriter.hpp \
+ include/Athena/SkywardSwordQuest.hpp \
+ include/Athena/Sprite.hpp \
+ include/Athena/SpriteFile.hpp \
+ include/Athena/SpriteFileReader.hpp \
+ include/Athena/SpriteFileWriter.hpp \
+ include/Athena/SpriteFrame.hpp \
+ include/Athena/SpritePart.hpp \
+ include/Athena/WiiBanner.hpp \
+ include/Athena/WiiFile.hpp \
+ include/Athena/WiiImage.hpp \
+ include/Athena/WiiSave.hpp \
+ include/Athena/WiiSaveReader.hpp \
+ include/Athena/WiiSaveWriter.hpp \
+ include/Athena/ZQuestFile.hpp \
+ include/Athena/ZQuestFileReader.hpp \
+ include/Athena/ZQuestFileWriter.hpp
+
+OTHER_FILES += \
+ .travis.yml
diff --git a/README.md b/README.md
deleted file mode 100644
index 1fafc95..0000000
--- a/README.md
+++ /dev/null
@@ -1,5 +0,0 @@
-libZelda provides several basic classes that can be used to read from
-and write to files, and memory, classes such as Stream, BinaryReader,
-BinaryWriter, and the currently work in progress TextStream.
-
-[![Build Status](https://travis-ci.org/Antidote/libzelda.png?branch=master)](https://travis-ci.org/Antidote/libzelda)
diff --git a/include/ALTTPEnums.hpp b/include/Athena/ALTTPEnums.hpp
similarity index 99%
rename from include/ALTTPEnums.hpp
rename to include/Athena/ALTTPEnums.hpp
index 8b2344e..c5f557c 100644
--- a/include/ALTTPEnums.hpp
+++ b/include/Athena/ALTTPEnums.hpp
@@ -20,7 +20,7 @@
#include "Types.hpp"
-namespace zelda
+namespace Athena
{
enum BowType : char
diff --git a/include/Athena/ALTTPEnums.hpp.autosave b/include/Athena/ALTTPEnums.hpp.autosave
new file mode 100644
index 0000000..9bdb74b
--- /dev/null
+++ b/include/Athena/ALTTPEnums.hpp.autosave
@@ -0,0 +1,113 @@
+// This file is part of libAthena.
+//
+// libAthena is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libAthena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libAthena. If not, see
+
+#ifndef __ALTTP_ENUMS_HPP__
+#define __ALTTP_ENUMS_HPP__
+
+#ifndef __DOXYGEN_IGNORE__
+
+#include "Types.hpp"
+
+namespace Athena
+{
+
+enum BowType : char
+{
+ BowNone,
+ BowArrows,
+ BowSilverArrows
+};
+
+enum BoomerangType : char
+{
+ BoomerangNone,
+ BoomerangBlue,
+ BoomerangRed
+};
+
+enum MagicType : char
+{
+ MagicNone,
+ MagicMushroom,
+ MagicPowder
+};
+
+enum ArmorType : char
+{
+ GreenJerkin,
+ BlueMail,
+ RedMail
+};
+
+enum BottleType : char
+{
+ BottleNone,
+ BottleMushroom, // No Use
+ BottleEmpty,
+ BottleRedPotion,
+ BottleBluePotion,
+ BottleFairy,
+ BottleBee,
+ BottleGoodBee
+};
+
+
+enum ALTTPStartLocation
+{
+ LinksHouse = 0x00,
+ Sanctuary = 0x01,
+ Any = 0x05
+};
+
+enum ALTTPProgressIndicator
+{
+ LinkInBed,
+ InCastleWithSword,
+ CompletedFirstDungeon,
+ BeatenAghanim
+};
+
+enum ALTTPMapIcon
+{
+ Nothing = 0x00, //?
+ CrossInKakariko = 0x01, //?
+ CrossAtFirstDungeon = 0x02, //
+ Pendant = 0x03,
+ MasterSword = 0x04,
+ AganhimCastle = 0x05,
+ Crystal1 = 0x06,
+ AllCrystals = 0x07,
+ AganhimGanonTower = 0x08
+};
+
+enum ALTTPTagAlong
+{
+ Noone,
+ Zelda,
+ Unknown1,
+ Oldman,
+ ZeldaMessage,
+ Blind,
+ DwarfFrog,
+ DwarfLW,
+ Kiki,
+ Unknown2,
+ TheifsChest,
+ AfterBoss
+};
+
+} // zelda
+#endif // __DOXYGEN_IGNORE__
+#endif // __ALTTP_ENUMS_HPP__
diff --git a/include/ALTTPFile.hpp b/include/Athena/ALTTPFile.hpp
similarity index 94%
rename from include/ALTTPFile.hpp
rename to include/Athena/ALTTPFile.hpp
index f2ec7fa..8c88bf5 100644
--- a/include/ALTTPFile.hpp
+++ b/include/Athena/ALTTPFile.hpp
@@ -16,10 +16,10 @@
#ifndef __ALTTP_FILE_HPP__
#define __ALTTP_FILE_HPP__
-#include
+#include "Athena/Types.hpp"
#include
-namespace zelda
+namespace Athena
{
class ALTTPQuest;
diff --git a/include/Athena/ALTTPFile.hpp.autosave b/include/Athena/ALTTPFile.hpp.autosave
new file mode 100644
index 0000000..d952ff6
--- /dev/null
+++ b/include/Athena/ALTTPFile.hpp.autosave
@@ -0,0 +1,91 @@
+// This file is part of libAthena.
+//
+// libAthena is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libAthena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libAthena. If not, see
+
+#ifndef __ALTTP_FILE_HPP__
+#define __ALTTP_FILE_HPP__
+
+#include "Athena/Types.hpp"
+#include
+
+namespace Athena
+{
+
+class ALTTPQuest;
+
+/*! \class ALTTPFile
+ * \brief A Link to the Past data container class class
+ *
+ * Contains all relevant data for an A Link to the Past
+ * SRM file.
+ */
+class ALTTPFile
+{
+public:
+ /*! \brief Quest Iterator
+ *
+ * An Iterator typedef for iterating through the Quest lists
+ */
+ typedef std::vector::iterator QuestIter;
+
+ /*! \brief Default constructor
+ *
+ *
+ */
+ ALTTPFile();
+
+ /*! \brief Constructor
+ *
+ * \param questList The primary quest list
+ * \param backupList The backup quest list
+ */
+ ALTTPFile(std::vector questList, std::vector backupList);
+
+
+ /*! \brief Sets a quest at the given index
+ *
+ * \param id Index to the given quest
+ * \param val The new quest to assign to the given index
+ * \throw InvalidOperationException on index out of range
+ */
+ void setQuest(Uint32 id, ALTTPQuest* val);
+ /*! \brief Returns the primary quest list
+ *
+ * \return The primary quest list
+ */
+ std::vector questList() const;
+
+ /*! \brief Returns a quest at the given index
+ *
+ * Returns a quest at the given index
+ *
+ * \return ALTTPQuest*
+ * \throw InvalidOperationException on index out of range
+ */
+ ALTTPQuest* quest(Uint32 id) const;
+
+ /*! \brief Returns the number of primary quests
+ *
+ * \return The number of quests
+ */
+ Uint32 questCount() const;
+
+private:
+
+ std::vector m_quests;
+ std::vector m_backup;
+};
+
+} // zelda
+#endif // __ALTTP_FILE_HPP__
diff --git a/include/ALTTPFileReader.hpp b/include/Athena/ALTTPFileReader.hpp
similarity index 95%
rename from include/ALTTPFileReader.hpp
rename to include/Athena/ALTTPFileReader.hpp
index d5d4774..b105d49 100644
--- a/include/ALTTPFileReader.hpp
+++ b/include/Athena/ALTTPFileReader.hpp
@@ -21,7 +21,7 @@
#include "BinaryReader.hpp"
#include "ALTTPQuest.hpp"
-namespace zelda
+namespace Athena
{
class ALTTPFile;
diff --git a/include/Athena/ALTTPFileReader.hpp.autosave b/include/Athena/ALTTPFileReader.hpp.autosave
new file mode 100644
index 0000000..0d4b406
--- /dev/null
+++ b/include/Athena/ALTTPFileReader.hpp.autosave
@@ -0,0 +1,68 @@
+// This file is part of libAthena.
+//
+// libAthena is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libAthena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libAthena. If not, see
+
+#ifndef __ALTTP_FILE_READER_HPP__
+#define __ALTTP_FILE_READER_HPP__
+
+#include
+#include "Types.hpp"
+#include "BinaryReader.hpp"
+#include "ALTTPQuest.hpp"
+
+namespace Athena
+{
+class ALTTPFile;
+
+namespace io
+{
+/*! \class ALTTPFileReader
+ * \brief A Link to the Past save data reader class
+ *
+ * A Class for reading binary data from an ALTTP Save File,
+ * all work is done using a memory buffer, and not read directly from the disk.
+ * \sa BinaryReader
+ */
+class ALTTPFileReader : protected BinaryReader
+{
+ BINARYREADER_BASE
+
+public:
+ /*! \brief This constructor takes an existing buffer to read from.
+ *
+ * \param data The existing buffer
+ * \param length The length of the existing buffer
+ */
+ ALTTPFileReader(Uint8*, Uint64);
+
+ /*! \brief This constructor creates an instance from a file on disk.
+ *
+ * \param filename The file to create the stream from
+ */
+ ALTTPFileReader(const std::string&);
+
+ /*! \brief Reads the SRAM data from the buffer
+ *
+ * \return ALTTPFile* SRAM data
+ */
+ ALTTPFile* readFile();
+private:
+ ALTTPRoomFlags* readRoomFlags();
+ ALTTPOverworldEvent* readOverworldEvent();
+ ALTTPDungeonItemFlags readDungeonFlags();
+};
+
+} // io
+} // zelda
+#endif // __ALTTP_FILE_READER_HPP__
diff --git a/include/ALTTPFileWriter.hpp b/include/Athena/ALTTPFileWriter.hpp
similarity index 92%
rename from include/ALTTPFileWriter.hpp
rename to include/Athena/ALTTPFileWriter.hpp
index 825e95e..8a60b94 100644
--- a/include/ALTTPFileWriter.hpp
+++ b/include/Athena/ALTTPFileWriter.hpp
@@ -17,11 +17,10 @@
#define __ALTTP_FILE_WRITER_HPP__
#include
-#include
-#include
-#include "ALTTPQuest.hpp"
+#include "Athena/BinaryWriter.hpp"
+#include "Athena/ALTTPQuest.hpp"
-namespace zelda
+namespace Athena
{
class ALTTPFile;
diff --git a/include/Athena/ALTTPFileWriter.hpp.autosave b/include/Athena/ALTTPFileWriter.hpp.autosave
new file mode 100644
index 0000000..bf35f22
--- /dev/null
+++ b/include/Athena/ALTTPFileWriter.hpp.autosave
@@ -0,0 +1,70 @@
+// This file is part of libAthena.
+//
+// libAthena is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libAthena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libAthena. If not, see
+
+#ifndef __ALTTP_FILE_WRITER_HPP__
+#define __ALTTP_FILE_WRITER_HPP__
+
+#include
+#include "Athena/BinaryWriter.hpp"
+#include "Athena/ALTTPQuest.hpp"
+
+namespace Athena
+{
+class ALTTPFile;
+
+namespace io
+{
+/*! \class ALTTPFileWriter
+ * \brief A Link to the Past save data writer class
+ *
+ * A Class for writing binary data to an ALTTP Save File,
+ * all work is done using a memory buffer, and not written directly to the disk.
+ * \sa BinaryReader
+ */
+class ALTTPFileWriter : protected BinaryWriter
+{
+ BINARYWRITER_BASE
+
+public:
+ /*! \brief This constructor takes an existing buffer to write to.
+ *
+ * \param data The existing buffer
+ * \param length The length of the existing buffer
+ */
+ ALTTPFileWriter(Uint8*, Uint64);
+
+ /*! \brief This constructor creates an instance from a file on disk.
+ *
+ * \param filename The file to create the stream from
+ */
+ ALTTPFileWriter(const std::string&);
+
+ /*! \brief Writes the given SRAM data to a file on disk
+ *
+ * \param file SRAM data to right
+ */
+ void writeFile(ALTTPFile* file);
+
+private:
+ void writeRoomFlags(ALTTPRoomFlags*);
+ void writeOverworldEvent(ALTTPOverworldEvent*);
+ void writeDungeonItems(ALTTPDungeonItemFlags);
+ Uint16 calculateChecksum(Uint32 game);
+};
+
+} // io
+} // zelda
+
+#endif // __ALTTP_FILE_WRITER_HPP__
diff --git a/include/ALTTPQuest.hpp b/include/Athena/ALTTPQuest.hpp
similarity index 95%
rename from include/ALTTPQuest.hpp
rename to include/Athena/ALTTPQuest.hpp
index 31cf51b..d8e27d1 100644
--- a/include/ALTTPQuest.hpp
+++ b/include/Athena/ALTTPQuest.hpp
@@ -22,7 +22,7 @@
#include "ALTTPStructs.hpp"
#include "ALTTPEnums.hpp"
-namespace zelda
+namespace Athena
{
/*! \class ALTTPQuest
diff --git a/include/Athena/ALTTPQuest.hpp.autosave b/include/Athena/ALTTPQuest.hpp.autosave
new file mode 100644
index 0000000..bc91729
--- /dev/null
+++ b/include/Athena/ALTTPQuest.hpp.autosave
@@ -0,0 +1,685 @@
+// This file is part of libAthena.
+//
+// libAthena is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libAthena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libAthena. If not, see
+#ifndef __ALTTP_QUEST_HPP__
+#define __ALTTP_QUEST_HPP__
+
+#include "Types.hpp"
+#include
+#include
+#include "ALTTPStructs.hpp"
+#include "ALTTPEnums.hpp"
+
+namespace Athena
+{
+
+/*! \class ALTTPQuest
+ * \brief A Link to the Past Quest container class
+ *
+ * Contains all relevant data for an A Link to the Past
+ * Quest entry.
+ */
+class ALTTPQuest
+{
+public:
+ /*!
+ * \brief ALTTPQuest
+ */
+ ALTTPQuest();
+ ~ALTTPQuest();
+
+ /*!
+ * \brief setRoomFlags
+ * \param flags
+ */
+ void setRoomFlags(std::vector flags);
+
+ /*!
+ * \brief setRoomFlags
+ * \param rf
+ * \param id
+ */
+ void setRoomFlags(ALTTPRoomFlags* rf, Uint32 id);
+
+ /*!
+ * \brief roomFlags
+ * \return
+ */
+ std::vector roomFlags();
+
+ /*!
+ * \brief roomFlags
+ * \param id
+ * \return
+ */
+ ALTTPRoomFlags* roomFlags(Uint32 id);
+
+ /*!
+ * \brief setOverworldEvents
+ * \param events
+ */
+ void setOverworldEvents(std::vector events);
+
+ /*!
+ * \brief setOverworldEvents
+ * \param ow
+ * \param id
+ */
+ void setOverworldEvents(ALTTPOverworldEvent* ow, Uint32 id);
+
+ /*!
+ * \brief overworldEvents
+ * \return
+ */
+ std::vector overworldEvents() const;
+
+ /*!
+ * \brief overworldEvent
+ * \param id
+ * \return
+ */
+ ALTTPOverworldEvent* overworldEvent(Uint32 id) const;
+
+ /*!
+ * \brief setInventory
+ * \param inv
+ */
+ void setInventory(ALTTPInventory* inv);
+
+ /*!
+ * \brief inventory
+ * \return
+ */
+ ALTTPInventory* inventory() const;
+
+ /*!
+ * \brief setRupeeMax
+ * \param val
+ */
+ void setRupeeMax(Uint16 val);
+
+ /*!
+ * \brief rupeeMax
+ * \return
+ */
+ Uint16 rupeeMax() const;
+
+ /*!
+ * \brief setRupeeCurrent
+ * \param val
+ */
+ void setRupeeCurrent(Uint16 val);
+
+ /*!
+ * \brief rupeeCurrent
+ * \return
+ */
+ Uint16 rupeeCurrent() const;
+
+ /*!
+ * \brief setCompasses
+ * \param flags
+ */
+ void setCompasses(ALTTPDungeonItemFlags flags);
+
+ /*!
+ * \brief compasses
+ * \return
+ */
+ ALTTPDungeonItemFlags compasses() const;
+
+ /*!
+ * \brief setBigKeys
+ * \param flags
+ */
+ void setBigKeys(ALTTPDungeonItemFlags flags);
+
+ /*!
+ * \brief bigKeys
+ * \return
+ */
+ ALTTPDungeonItemFlags bigKeys() const;
+
+ /*!
+ * \brief setDungeonMaps
+ * \param flags
+ */
+ void setDungeonMaps(ALTTPDungeonItemFlags flags);
+
+ /*!
+ * \brief dungeonMaps
+ * \return
+ */
+ ALTTPDungeonItemFlags dungeonMaps() const;
+
+ /*!
+ * \brief setWishingPond
+ * \param val
+ */
+ void setWishingPond(Uint16 val);
+
+ /*!
+ * \brief wishingPond
+ * \return
+ */
+ Uint16 wishingPond() const;
+
+ /*!
+ * \brief setHealthMax
+ * \param val
+ */
+ void setHealthMax(Uint8 val);
+
+ /*!
+ * \brief healthMax
+ * \return
+ */
+ Uint8 healthMax() const;
+
+ /*!
+ * \brief setHealth
+ * \param val
+ */
+ void setHealth(Uint8 val);
+
+ /*!
+ * \brief health
+ * \return
+ */
+ Uint8 health() const;
+
+ /*!
+ * \brief setMagicPower
+ * \param val
+ */
+ void setMagicPower(Uint8 val);
+
+ /*!
+ * \brief magicPower
+ * \return
+ */
+ Uint8 magicPower() const;
+
+ /*!
+ * \brief setKeys
+ * \param val
+ */
+ void setKeys(Uint8 val);
+
+ /*!
+ * \brief keys
+ * \return
+ */
+ Uint8 keys() const;
+
+ /*!
+ * \brief setBombUpgrades
+ * \param val
+ */
+ void setBombUpgrades(Uint8 val);
+
+ /*!
+ * \brief bombUpgrades
+ * \return
+ */
+ Uint8 bombUpgrades() const;
+
+ /*!
+ * \brief setArrowUpgrades
+ * \param val
+ */
+ void setArrowUpgrades(Uint8 val);
+
+ /*!
+ * \brief arrowUpgrades
+ * \return
+ */
+ Uint8 arrowUpgrades() const;
+
+ /*!
+ * \brief setHealthFiller
+ * \param val
+ */
+ void setHealthFiller(Uint8 val);
+
+ /*!
+ * \brief healthFiller
+ * \return
+ */
+ Uint8 healthFiller() const;
+
+ /*!
+ * \brief setMagicFiller
+ * \param val
+ */
+ void setMagicFiller(Uint8 val);
+
+ /*!
+ * \brief magicFiller
+ * \return
+ */
+ Uint8 magicFiller() const;
+
+ /*!
+ * \brief setPendants
+ * \param val
+ */
+ void setPendants(ALTTPPendants val);
+
+ /*!
+ * \brief pendants
+ * \return
+ */
+ ALTTPPendants pendants() const;
+
+ /*!
+ * \brief setBombFiller
+ * \param val
+ */
+ void setBombFiller(Uint8 val);
+
+ /*!
+ * \brief bombFiller
+ * \return
+ */
+ Uint8 bombFiller() const;
+
+ /*!
+ * \brief setArrowFiller
+ * \param val
+ */
+ void setArrowFiller(Uint8 val);
+
+ /*!
+ * \brief arrowFiller
+ * \return
+ */
+ Uint8 arrowFiller() const;
+
+ /*!
+ * \brief setArrows
+ * \param val
+ */
+ void setArrows(Uint8 val);
+
+ /*!
+ * \brief arrows
+ * \return
+ */
+ Uint8 arrows() const;
+
+ /*!
+ * \brief setAbilityFlags
+ * \param val
+ */
+ void setAbilityFlags(ALTTPAbilities val);
+
+ /*!
+ * \brief abilityFlags
+ * \return
+ */
+ ALTTPAbilities abilityFlags() const;
+
+ /*!
+ * \brief setCrystals
+ * \param val
+ */
+ void setCrystals(ALTTPCrystals val);\
+
+ /*!
+ * \brief crystals
+ * \return
+ */
+ ALTTPCrystals crystals() const;
+
+ /*!
+ * \brief setMagicUsage
+ * \param val
+ */
+ void setMagicUsage(ALTTPMagicUsage val);
+
+ /*!
+ * \brief magicUsage
+ * \return
+ */
+ ALTTPMagicUsage magicUsage() const;
+
+ /*!
+ * \brief setDungeonKeys
+ * \param val
+ */
+ void setDungeonKeys(std::vector val);
+
+ /*!
+ * \brief setDungeonKeys
+ * \param id
+ * \param val
+ */
+ void setDungeonKeys(Uint32 id, Uint8 val);
+
+ /*!
+ * \brief dungeonKeys
+ * \param id
+ * \return
+ */
+ Uint8 dungeonKeys(Uint32 id) const;
+
+ /*!
+ * \brief dungeonCount
+ * \return
+ */
+ Uint32 dungeonCount() const;
+
+ /*!
+ * \brief setProgressIndicator
+ * \param val
+ */
+ void setProgressIndicator(ALTTPProgressIndicator val);
+
+ /*!
+ * \brief progressIndicator
+ * \return
+ */
+ ALTTPProgressIndicator progressIndicator() const;
+
+ /*!
+ * \brief setProgressFlags1
+ * \param val
+ */
+ void setProgressFlags1(ALTTPProgressFlags1 val);
+
+ /*!
+ * \brief progressFlags1
+ * \return
+ */
+ ALTTPProgressFlags1 progressFlags1() const;
+
+ /*!
+ * \brief setMapIcon
+ * \param val
+ */
+ void setMapIcon(ALTTPMapIcon val);
+
+ /*!
+ * \brief mapIcon
+ * \return
+ */
+ ALTTPMapIcon mapIcon() const;
+
+ /*!
+ * \brief setStartLocation
+ * \param val
+ */
+ void setStartLocation(ALTTPStartLocation val);
+
+ /*!
+ * \brief startLocation
+ * \return
+ */
+ ALTTPStartLocation startLocation() const;
+
+ /*!
+ * \brief setProgressFlags2
+ * \param val
+ */
+ void setProgressFlags2(ALTTPProgressFlags2 val);
+
+ /*!
+ * \brief progressFlags2
+ * \return
+ */
+ ALTTPProgressFlags2 progressFlags2() const;
+
+ /*!
+ * \brief setLightDarkWorldIndicator
+ * \param val
+ */
+ void setLightDarkWorldIndicator(ALTTPLightDarkWorldIndicator val);
+
+ /*!
+ * \brief lightDarkWorldIndicator
+ * \return
+ */
+ ALTTPLightDarkWorldIndicator lightDarkWorldIndicator() const;
+
+ /*!
+ * \brief setTagAlong
+ * \param val
+ */
+ void setTagAlong(ALTTPTagAlong val);
+
+ /*!
+ * \brief tagAlong
+ * \return
+ */
+ ALTTPTagAlong tagAlong() const;
+
+ /*!
+ * \brief setOldManFlags
+ * \param flags
+ */
+ void setOldManFlags(std::vector flags);
+
+ /*!
+ * \brief setOldManFlag
+ * \param id
+ * \param val
+ */
+ void setOldManFlag(Uint32 id, Uint8 val);
+
+ /*!
+ * \brief oldManFlag
+ * \param id
+ * \return
+ */
+ Uint8 oldManFlag(Uint32 id);
+
+ /*!
+ * \brief oldManFlagCount
+ * \return
+ */
+ Uint32 oldManFlagCount() const;
+
+ /*!
+ * \brief setBombFlag
+ * \param flag
+ */
+ void setBombFlag(Uint8 flag);
+
+ /*!
+ * \brief bombFlag
+ * \return
+ */
+ Uint8 bombFlag() const;
+
+ /*!
+ * \brief setUnknown1
+ * \param flags
+ */
+ void setUnknown1(std::vector flags);
+
+ /*!
+ * \brief setUnknown1
+ * \param id
+ * \param val
+ */
+ void setUnknown1(Uint32 id, Uint8 val);
+
+ /*!
+ * \brief unknown1
+ * \param id
+ * \return
+ */
+ Uint8 unknown1(Uint32 id);
+
+ /*!
+ * \brief unknown1Count
+ * \return
+ */
+ Uint32 unknown1Count() const;
+
+ /*!
+ * \brief setPlayerName
+ * \param playerName
+ */
+ void setPlayerName(std::vector playerName);
+ /*!
+ * \brief setPlayerName
+ * \param playerName
+ */
+ void setPlayerName(const std::string& playerName);
+ /*!
+ * \brief playerName
+ * \return
+ */
+ std::vector playerName() const;
+ /*!
+ * \brief playerNameToString
+ * \return
+ */
+ std::string playerNameToString() const;
+
+ /*!
+ * \brief setValid
+ * \param val
+ */
+ void setValid(bool val);
+
+ /*!
+ * \brief valid
+ * \return
+ */
+ bool valid();
+
+ /*!
+ * \brief setDungeonDeathTotals
+ * \param val
+ */
+ void setDungeonDeathTotals(std::vector val);
+
+ /*!
+ * \brief setDungeonDeathTotal
+ * \param id
+ * \param val
+ */
+ void setDungeonDeathTotal(Uint32 id, Uint16 val);
+
+ /*!
+ * \brief dungeonDeathTotal
+ * \param id
+ * \return
+ */
+ Uint16 dungeonDeathTotal(Uint32 id) const;
+
+ /*!
+ * \brief dungeonDeathTotalCount
+ * \return
+ */
+ Uint16 dungeonDeathTotalCount() const;
+
+ /*!
+ * \brief setUnknown2
+ * \param val
+ */
+ void setUnknown2(Uint16 val);
+
+ /*!
+ * \brief unknown2
+ * \return
+ */
+ Uint16 unknown2() const;
+
+ /*!
+ * \brief setDeathSaveCount
+ * \param val
+ */
+ void setDeathSaveCount(Uint16 val);
+
+ /*!
+ * \brief deathSaveCount
+ * \return
+ */
+ Uint16 deathSaveCount() const;
+
+ /*!
+ * \brief setPostGameDeathCounter
+ * \param val
+ */
+ void setPostGameDeathCounter(Int16 val);
+
+ /*!
+ * \brief postGameDeathCounter
+ * \return
+ */
+ Int16 postGameDeathCounter() const;
+
+ /*!
+ * \brief setChecksum
+ * \param checksum
+ */
+ void setChecksum(Uint16 checksum);
+
+ /*!
+ * \brief checksum
+ * \return
+ */
+ Uint16 checksum() const;
+private:
+ std::vector m_roomFlags;
+ std::vector m_overworldEvents;
+ ALTTPInventory* m_inventory;
+ Uint16 m_rupeeMax;
+ Uint16 m_rupeeCurrent;
+ ALTTPDungeonItemFlags m_compasses;
+ ALTTPDungeonItemFlags m_bigKeys;
+ ALTTPDungeonItemFlags m_dungeonMaps;
+ Uint16 m_wishingPond;
+ Uint8 m_healthMax;
+ Uint8 m_health;
+ Uint8 m_magicPower;
+ Uint8 m_keys;
+ Uint8 m_bombUpgrades;
+ Uint8 m_arrowUpgrades;
+ Uint8 m_heartFiller;
+ Uint8 m_magicFiller;
+ ALTTPPendants m_pendants;
+ Uint8 m_bombFiller;
+ Uint8 m_arrowFiller;
+ Uint8 m_arrows;
+ ALTTPAbilities m_abilityFlags;
+ ALTTPCrystals m_crystals;
+ ALTTPMagicUsage m_magicUsage;
+ std::vector m_dungeonKeys;
+ ALTTPProgressIndicator m_progressIndicator;
+ ALTTPProgressFlags1 m_progressFlags1;
+ ALTTPMapIcon m_mapIcon;
+ ALTTPStartLocation m_startLocation;
+ ALTTPProgressFlags2 m_progressFlags2;
+ ALTTPLightDarkWorldIndicator m_lightDarkWorldIndicator;
+ ALTTPTagAlong m_tagAlong;
+ std::vector m_oldManFlags;
+ Uint8 m_bombFlag;
+ std::vector m_unknown1;
+ std::vector m_playerName;
+ Uint16 m_valid;
+ std::vector m_dungeonDeathTotals;
+ Uint16 m_unknown2;
+ Uint16 m_deathSaveCount;
+ Int16 m_postGameDeathCounter;
+ Uint16 m_checksum;
+};
+
+} // zelda
+
+#endif // __ALTTP_QUEST_HPP__
diff --git a/include/ALTTPStructs.hpp b/include/Athena/ALTTPStructs.hpp
similarity index 94%
rename from include/ALTTPStructs.hpp
rename to include/Athena/ALTTPStructs.hpp
index f201ff7..1123fc7 100644
--- a/include/ALTTPStructs.hpp
+++ b/include/Athena/ALTTPStructs.hpp
@@ -21,7 +21,7 @@
#include
#include "Types.hpp"
-namespace zelda
+namespace Athena
{
struct ALTTPRoomFlags
diff --git a/include/Athena/ALTTPStructs.hpp.autosave b/include/Athena/ALTTPStructs.hpp.autosave
new file mode 100644
index 0000000..bc41d62
--- /dev/null
+++ b/include/Athena/ALTTPStructs.hpp.autosave
@@ -0,0 +1,203 @@
+// This file is part of libAthena.
+//
+// libAthena is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libAthena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libAthena. If not, see
+
+#ifndef __ALTTP_STRUCTS_HPP__
+#define __ALTTP_STRUCTS_HPP__
+
+#ifndef __DOXYGEN_IGNORE__
+
+#include
+#include "Types.hpp"
+
+namespace Athena
+{
+
+struct ALTTPRoomFlags
+{
+ bool Chest1:1;
+ bool Chest2:1;
+ bool Chest3:1;
+ bool Chest4:1;
+ bool Quadrant1:1;
+ bool Quadrant2:1;
+ bool Quadrant3:1;
+ bool Quadrant4:1;
+ bool Door1:1;
+ bool Door2:1;
+ bool Door3:1;
+ bool Door4:1;
+ bool BossBattleWon:1;
+ bool Key:1;
+ bool KeyOrChest:1;
+ bool ChestOrTile:1;
+};
+
+struct ALTTPOverworldEvent
+{
+ bool Unused1:1;
+ bool HeartPiece:1;
+ bool Overlay:1;
+ bool Unused2:1;
+ bool Unused3:1;
+ bool Unused4:1;
+ bool Set:1;
+ bool Unused5:1;
+};
+
+struct ALTTPInventory
+{
+ char Bow;
+ char Boomerang;
+ bool Hookshot;
+ char Bombs; // Bomb count
+ char Magic;
+ bool FireRod;
+ bool IceRod;
+ bool Bombos;
+ bool Ether;
+ bool Quake;
+ bool Torch;
+ bool Hammer;
+ char Flute;
+ bool BugNet;
+ bool Book;
+ bool Bottles;
+ bool Somaria;
+ bool Byrna;
+ bool MagicCape;
+ char MagicMirror;
+ char Gloves;
+ char Boots;
+ bool Flippers;
+ bool MoonPearl;
+ char Unused; //?
+ char Sword;
+ char Shield;
+ char Armor;
+ char BottleTypes[4];
+};
+
+/*! \struct ALTTPLightDarkWorldIndicator
+ */
+struct ALTTPLightDarkWorldIndicator
+{
+ bool Unused1:1;
+ bool Unused2:1;
+ bool Unused3:1;
+ bool Unused4:1;
+ bool Unused5:1;
+ bool Unused6:1;
+ bool IsDarkWorld:1;
+ bool Unused7:1;
+};
+
+
+struct ALTTPDungeonItemFlags
+{
+ bool Unused1:1;
+ bool Unused2:1;
+ bool GanonsTower:1;
+ bool TurtleRock:1;
+ bool GargoylesDomain:1;
+ bool TowerOfHera:1;
+ bool IcePalace:1;
+ bool SkullWoods:1;
+ bool MiseryMire:1;
+ bool DarkPalace:1;
+ bool SwampPalace:1;
+ bool HyruleCastle2:1; // Doesn't exists in orignal game
+ bool DesertPalace:1;
+ bool EasternPalace:1;
+ bool HyruleCastle:1; // Doesn't exist in original game
+ bool SewerPassage:1; // Doesn't exist in original game
+};
+
+struct ALTTPPendants
+{
+ bool Courage:1;
+ bool Wisdom:1;
+ bool Power:1;
+ bool Unused1:1;
+ bool Unused2:1;
+ bool Unused3:1;
+ bool Unused4:1;
+ bool Unused5:1;
+};
+
+struct ALTTPAbilities
+{
+ char Nothing:1; //?
+ char Swim:1;
+ char Dash:1;
+ char Pull:1;
+ char Unknown1:1; //---
+ char Talk:1;
+ char Read:1;
+ char Unknown2:1; //---
+};
+
+struct ALTTPCrystals
+{
+ bool MiseryMire:1;
+ bool DarkPalace:1;
+ bool IcePalace:1;
+ bool TurtleRock:1;
+ bool SwampPalace:1;
+ bool GargoyleDomain:1;
+ bool SkullWoods:1;
+};
+
+struct ALTTPMagicUsage
+{
+ bool Normal:1;
+ bool Half:1;
+ bool Quarter:1;
+ bool Unused1:1;
+ bool Unused2:1;
+ bool Unused3:1;
+ bool Unused4:1;
+ bool Unused5:1;
+};
+
+
+struct ALTTPProgressFlags1
+{
+ bool UncleSecretPassage:1;
+ bool DyingPriest:1; //?
+ bool ZeldaSanctuary:1; //?
+ bool Unused1:1;
+ bool UncleLeftHouse:1;
+ bool BookOfMudora:1;//? Math says it's a guess need to investigate
+ bool DwarfPartner:1; //?
+ bool Unused2:1;
+};
+
+
+struct ALTTPProgressFlags2
+{
+ bool BottleFromBum:1;
+ bool BottleFromSalesMen:1;
+ bool Unused1:1; //?
+ bool FluteBoy:1;
+ bool ThiefsChest:1;
+ bool SavedSmithPartner:1;
+ bool Unused2:1; //?
+ bool SmithsHaveSword:1;
+};
+
+}
+
+#endif // __DOXYGEN_IGNORE__
+#endif // __ALTTP_STRUCTS_HPP__
diff --git a/include/BinaryReader.hpp b/include/Athena/BinaryReader.hpp
similarity index 56%
rename from include/BinaryReader.hpp
rename to include/Athena/BinaryReader.hpp
index a549359..8edbeaa 100644
--- a/include/BinaryReader.hpp
+++ b/include/Athena/BinaryReader.hpp
@@ -20,11 +20,10 @@
#include
#include
-namespace zelda
+namespace Athena
{
namespace io
{
-
/*! \class BinaryReader
* \brief A Stream class for reading binary data
*
@@ -42,16 +41,91 @@ public:
* \param length The length of the existing buffer
*/
BinaryReader(const Uint8* data, Uint64 length);
- /*! \brief This constructor takes an existing Stream to read from.
- *
- * \param stream The stream to read data from
- */
- BinaryReader(const Stream& stream);
+
/*! \brief This constructor creates an instance from a file on disk.
*
* \param filename The file to create the stream from
*/
- BinaryReader(const std::string& filename);
+ BinaryReader(const std::string& filename, std::function progressFun = nullptr);
+
+ ~BinaryReader();
+
+ /*! \brief Sets the Endianss of the stream
+ *
+ * \param endian The Endianess to set \sa Endian
+ */
+ void setEndian(Endian endian);
+
+ /*! \brief Returns the current Endianness of the stream
+ *
+ * \return Endian The current Stream Endianess
+ */
+ Endian endian() const;
+
+ /*! \brief Returns whether the stream is BigEndian
+ *
+ * \return bool True for BigEndian; False for LittleEndian
+ */
+ bool isBigEndian() const;
+
+ /*! \brief Returns whether the stream is LittleEndian
+ *
+ * \return bool True for LittleEndian; False for BigEndian
+ */
+ bool isLittleEndian()const;
+
+ /*! \brief Retuns whether or not the Stream is open.
+ *
+ * \return True if open; False otherwise.
+ */
+ bool isOpen() const;
+
+ /*! \brief Sets the buffers position relative to the specified position.
+ * It seeks relative to the current position by default.
+ * \param position where in the buffer to seek
+ * \param origin The Origin to seek \sa SeekOrigin
+ */
+ void seek(Int64 pos, SeekOrigin origin = SeekOrigin::Current);
+
+
+ /*! \brief Returns whether or not the stream is at the end.
+ *
+ * \return bool True if at end; False otherwise.
+ */
+ bool atEnd() const;
+
+ /*! \brief Returns the current position in the stream.
+ *
+ * \return Int64 The current position in the stream.
+ */
+ Uint64 position() const;
+
+ /*! \brief Returns whether or not the stream is at the end.
+ *
+ * \return bool True if at end; False otherwise.
+ */
+ Uint64 length() const;
+
+ /*! \brief Sets the buffer to the given one, deleting the current one.
+ * BEWARE: As this deletes the current buffer it WILL cause a loss of data
+ * if that was not the intent.
+ * Once you pass the data to setData DO NOT delete the buffer
+ * as Stream now owns the address, this is done to keep memory usage down.
+ * \param data The new buffer.
+ * \param length The length of the new buffer.
+ * \throw IOException
+ */
+ void setData(const Uint8* data, Uint64 length);
+
+
+ /*! \brief Returns a copy of the current buffer.
+ * Changes to the copy do not affect the buffer so it's perfectly safe to
+ * directly edit the buffer and use setData to set the new information.
+ * However once you pass the data to setData DO NOT delete the buffer
+ * as Stream now owns the address, this is done to keep memory usage down.
+ * \return Uint8* The copy of the buffer.
+ */
+ Uint8* data() const;
/*! \brief Sets the target file
*
@@ -65,10 +139,40 @@ public:
*/
std::string filepath() const;
+ /*!
+ * \brief Seeks to the specified bit within the current byte
+ * \param bit Bit to seek to, range is 0 - 7
+ */
+ void seekBit(int bit);
+
+ /*! \brief Reads a bit at the current position and advances the current position
+ *
+ * \return bool The value at the current position
+ */
bool readBit();
+
+ /*! \brief Reads a byte at the current position and advances the current position
+ *
+ * \return Int8 The value at the current position
+ */
Int8 readByte();
+
+ /*! \brief Reads a byte at the current position and advances the current position
+ *
+ * \return Uint8 The value at the current position
+ */
Uint8 readUByte();
+
+ /*! \brief Reads a byte at the current position and advances the current position.
+ *
+ * \return Uint8* The buffer at the current position from the given length.
+ */
Int8* readBytes(Int64 length);
+
+ /*! \brief Reads a byte at the current position and advances the current position.
+ *
+ * \return Int8* The buffer at the current position from the given length.
+ */
Uint8* readUBytes(Int64 length);
/*! \brief Reads a Int16 and swaps to proper endianness depending on platform
@@ -79,7 +183,7 @@ public:
* \return Int16 The value at the current address
* \throw IOException when address is out of range
*/
- Int16 readInt16();
+ Int16 readInt16();
/*! \brief Reads a Uint16 and swaps to proper endianness depending on platform
* and Stream settings, and advances the current position
@@ -89,7 +193,7 @@ public:
* \return Uint16 The value at the current address
* \throw IOException when address is out of range
*/
- Uint16 readUInt16();
+ Uint16 readUint16();
/*! \brief Reads a Int32 and swaps to proper endianness depending on platform
* and Stream settings, and advances the current position
@@ -99,7 +203,7 @@ public:
* \return Int32 The value at the current address
* \throw IOException when address is out of range
*/
- Int32 readInt32();
+ Int32 readInt32();
/*! \brief Reads a Uint32 and swaps to proper endianness depending on platform
* and Stream settings, and advances the current position
@@ -109,7 +213,7 @@ public:
* \return Uint32 The value at the current address
* \throw IOException when address is out of range
*/
- Uint32 readUInt32();
+ Uint32 readUint32();
/*! \brief Reads a Int64 and swaps to proper endianness depending on platform
* and Stream settings, and advances the current position
@@ -119,7 +223,7 @@ public:
* \return Int64 The value at the current address
* \throw IOException when address is out of range
*/
- Int64 readInt64();
+ Int64 readInt64();
/*! \brief Reads a Uint64 and swaps to proper endianness depending on platform
* and Stream settings, and advances the current position
@@ -129,7 +233,7 @@ public:
* \return Uint64 The value at the current address
* \throw IOException when address is out of range
*/
- Uint64 readUInt64();
+ Uint64 readUint64();
/*! \brief Reads a float and swaps to proper endianness depending on platform
* and Stream settings, and advances the current position
@@ -139,7 +243,7 @@ public:
* \return float The value at the current address
* \throw IOException when address is out of range
*/
- float readFloat();
+ float readFloat();
/*! \brief Reads a double and swaps to proper endianness depending on platform
* and Stream settings, and advances the current position
@@ -149,13 +253,15 @@ public:
* \return double The value at the current address
* \throw IOException when address is out of range
*/
- double readDouble();
+ double readDouble();
+
/*! \brief Reads a bool and advances the current position
*
* \return bool The value at the current address
* \throw IOException when address is out of range
*/
- bool readBool();
+ bool readBool();
+
/*! \brief Reads a Unicode string and advances the position in the file
*
* \return std::string The value at the current address
@@ -173,33 +279,22 @@ public:
void setProgressCallback(std::function cb);
protected:
void loadData();
- /*! \brief Overload of isOpenForWriting in Stream
- *
- * \return false
- */
- bool isOpenForWriting();
- /*! \brief Overload of writeByte in Stream
- *
- * \throw IOException
- */
- void writeByte(Int8 byte);
- /*! \brief Overload of writeBytes in Stream
- *
- * \throw IOException
- */
- void writeBytes(Int8*, Int64);
+ Uint8* m_data;
+ Uint64 m_length;
std::string m_filepath; //!< Path to the target file
- Uint32 m_currentLength;
- FILE* m_file;
+ Uint64 m_position;
+ Uint64 m_bitPosition;
+ Endian m_endian;
std::function m_progressCallback;
};
-}
-}
+
+} // io
+} // Athena
#ifndef BINARYREADER_BASE
#define BINARYREADER_BASE \
private: \
- typedef zelda::io::BinaryReader base;
+ typedef Athena::io::BinaryReader base;
#endif // BINARYREADER_BASE
diff --git a/include/Athena/BinaryReader.hpp.autosave b/include/Athena/BinaryReader.hpp.autosave
new file mode 100644
index 0000000..b47b540
--- /dev/null
+++ b/include/Athena/BinaryReader.hpp.autosave
@@ -0,0 +1,301 @@
+// This file is part of libAthena.
+//
+// libAthena is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libAthena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libAthena. If not, see
+
+#ifndef __BINARYREADER_HPP__
+#define __BINARYREADER_HPP__
+
+#include "Stream.hpp"
+#include
+#include
+
+namespace Athena
+{
+namespace io
+{
+/*! \class BinaryReader
+ * \brief A Stream class for reading binary data
+ *
+ * A Class for reading binary data from a file or memory stream,
+ * all work is done using a memory buffer, and not read directly from the disk
+ * this allows for fast, flexible code as well as the ability to quickly modify data
+ * \sa Stream
+ */
+class BinaryReader : public Stream
+{
+public:
+ /*! \brief This constructor takes an existing buffer to read from.
+ *
+ * \param data The existing buffer
+ * \param length The length of the existing buffer
+ */
+ BinaryReader(const Uint8* data, Uint64 length);
+
+ /*! \brief This constructor creates an instance from a file on disk.
+ *
+ * \param filename The file to create the stream from
+ */
+ BinaryReader(const std::string& filename, std::function progressFun = nullptr);
+
+ ~BinaryReader();
+
+ /*! \brief Sets the Endianss of the stream
+ *
+ * \param endian The Endianess to set \sa Endian
+ */
+ void setEndian(Endian endian);
+
+ /*! \brief Returns the current Endianness of the stream
+ *
+ * \return Endian The current Stream Endianess
+ */
+ Endian endian() const;
+
+ /*! \brief Returns whether the stream is BigEndian
+ *
+ * \return bool True for BigEndian; False for LittleEndian
+ */
+ bool isBigEndian() const;
+
+ /*! \brief Returns whether the stream is LittleEndian
+ *
+ * \return bool True for LittleEndian; False for BigEndian
+ */
+ bool isLittleEndian()const;
+
+ /*! \brief Retuns whether or not the Stream is open.
+ *
+ * \return True if open; False otherwise.
+ */
+ bool isOpen() const;
+
+ /*! \brief Sets the buffers position relative to the specified position.
+ * It seeks relative to the current position by default.
+ * \param position where in the buffer to seek
+ * \param origin The Origin to seek \sa SeekOrigin
+ */
+ void seek(Int64 pos, SeekOrigin origin = SeekOrigin::Current);
+
+
+ /*! \brief Returns whether or not the stream is at the end.
+ *
+ * \return bool True if at end; False otherwise.
+ */
+ bool atEnd() const;
+
+ /*! \brief Returns the current position in the stream.
+ *
+ * \return Int64 The current position in the stream.
+ */
+ Uint64 position() const;
+
+ /*! \brief Returns whether or not the stream is at the end.
+ *
+ * \return bool True if at end; False otherwise.
+ */
+ Uint64 length() const;
+
+ /*! \brief Sets the buffer to the given one, deleting the current one.
+ * BEWARE: As this deletes the current buffer it WILL cause a loss of data
+ * if that was not the intent.
+ * Once you pass the data to setData DO NOT delete the buffer
+ * as Stream now owns the address, this is done to keep memory usage down.
+ * \param data The new buffer.
+ * \param length The length of the new buffer.
+ * \throw IOException
+ */
+ void setData(const Uint8* data, Uint64 length);
+
+
+ /*! \brief Returns a copy of the current buffer.
+ * Changes to the copy do not affect the buffer so it's perfectly safe to
+ * directly edit the buffer and use setData to set the new information.
+ * However once you pass the data to setData DO NOT delete the buffer
+ * as Stream now owns the address, this is done to keep memory usage down.
+ * \return Uint8* The copy of the buffer.
+ */
+ Uint8* data() const;
+
+ /*! \brief Sets the target file
+ *
+ * \sa Endian
+ * \param filepath The path to write to.
+ */
+ void setFilepath(const std::string& filepath);
+
+ /*! \brief Returns the target file
+ *
+ */
+ std::string filepath() const;
+
+ /*!
+ * \brief Seeks to the specified bit within the current byte
+ * \param bit Bit to seek to, range is 0 - 7
+ */
+ void seekBit(int bit);
+
+ /*! \brief Reads a bit at the current position and advances the current position
+ *
+ * \return bool The value at the current position
+ */
+ bool readBit();
+
+ /*! \brief Reads a byte at the current position and advances the current position
+ *
+ * \return Int8 The value at the current position
+ */
+ Int8 readByte();
+
+ /*! \brief Reads a byte at the current position and advances the current position
+ *
+ * \return Uint8 The value at the current position
+ */
+ Uint8 readUByte();
+
+ /*! \brief Reads a byte at the current position and advances the current position.
+ *
+ * \return Uint8* The buffer at the current position from the given length.
+ */
+ Int8* readBytes(Int64 length);
+
+ /*! \brief Reads a byte at the current position and advances the current position.
+ *
+ * \return Int8* The buffer at the current position from the given length.
+ */
+ Uint8* readUBytes(Int64 length);
+
+ /*! \brief Reads a Int16 and swaps to proper endianness depending on platform
+ * and Stream settings, and advances the current position
+ *
+ * \sa Endian
+ *
+ * \return Int16 The value at the current address
+ * \throw IOException when address is out of range
+ */
+ Int16 readInt16();
+
+ /*! \brief Reads a Uint16 and swaps to proper endianness depending on platform
+ * and Stream settings, and advances the current position
+ *
+ * \sa Endian
+ *
+ * \return Uint16 The value at the current address
+ * \throw IOException when address is out of range
+ */
+ Uint16 readUint16();
+
+ /*! \brief Reads a Int32 and swaps to proper endianness depending on platform
+ * and Stream settings, and advances the current position
+ *
+ * \sa Endian
+ *
+ * \return Int32 The value at the current address
+ * \throw IOException when address is out of range
+ */
+ Int32 readInt32();
+
+ /*! \brief Reads a Uint32 and swaps to proper endianness depending on platform
+ * and Stream settings, and advances the current position
+ *
+ * \sa Endian
+ *
+ * \return Uint32 The value at the current address
+ * \throw IOException when address is out of range
+ */
+ Uint32 readUint32();
+
+ /*! \brief Reads a Int64 and swaps to proper endianness depending on platform
+ * and Stream settings, and advances the current position
+ *
+ * \sa Endian
+ *
+ * \return Int64 The value at the current address
+ * \throw IOException when address is out of range
+ */
+ Int64 readInt64();
+
+ /*! \brief Reads a Uint64 and swaps to proper endianness depending on platform
+ * and Stream settings, and advances the current position
+ *
+ * \sa Endian
+ *
+ * \return Uint64 The value at the current address
+ * \throw IOException when address is out of range
+ */
+ Uint64 readUint64();
+
+ /*! \brief Reads a float and swaps to proper endianness depending on platform
+ * and Stream settings, and advances the current position
+ *
+ * \sa Endian
+ *
+ * \return float The value at the current address
+ * \throw IOException when address is out of range
+ */
+ float readFloat();
+
+ /*! \brief Reads a double and swaps to proper endianness depending on platform
+ * and Stream settings, and advances the current position
+ *
+ * \sa Endian
+ *
+ * \return double The value at the current address
+ * \throw IOException when address is out of range
+ */
+ double readDouble();
+
+ /*! \brief Reads a bool and advances the current position
+ *
+ * \return bool The value at the current address
+ * \throw IOException when address is out of range
+ */
+ bool readBool();
+
+ /*! \brief Reads a Unicode string and advances the position in the file
+ *
+ * \return std::string The value at the current address
+ * \throw IOException when address is out of range
+ */
+ std::string readUnicode();
+
+ /*! \brief Reads a string and advances the position in the file
+ *
+ * \return std::string The value at the current address
+ * \throw IOException when address is out of range
+ */
+ std::string readString();
+
+ void setProgressCallback(std::function cb);
+protected:
+ void loadData();
+ Uint8* m_data;
+ Uint64 m_length;
+ std::string m_filepath; //!< Path to the target file
+ Uint64 m_position;
+ Uint64 m_bitPosition;
+ Endian m_endian;
+ std::function m_progressCallback;
+};
+
+} // io
+} // Athena
+
+#ifndef BINARYREADER_BASE
+#define BINARYREADER_BASE \
+private: \
+ typedef Athena::io::BinaryReader base;
+
+#endif // BINARYREADER_BASE
+
+#endif // __BINARYREADER_HPP__
diff --git a/include/Athena/BinaryWriter.hpp b/include/Athena/BinaryWriter.hpp
new file mode 100644
index 0000000..8f52e18
--- /dev/null
+++ b/include/Athena/BinaryWriter.hpp
@@ -0,0 +1,296 @@
+// This file is part of libAthena.
+//
+// libAthena is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libAthena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libAthena. If not, see
+
+#ifndef __BINARYWRITER_HPP__
+#define __BINARYWRITER_HPP__
+
+#include "Stream.hpp"
+#include
+#include
+
+namespace Athena
+{
+namespace io
+{
+
+/*! \class BinaryWriter
+ * \brief A Stream class for writing binary data
+ *
+ * A Class for writing binary data to a file or memory stream,
+ * all work is done using a memory buffer, and not written directly to the disk
+ * this allows for fast, flexible code as well as the ability to quickly modify data
+ * \sa Stream
+ */
+class BinaryWriter : public Stream
+{
+public:
+ /*! \brief This constructor takes an existing buffer to write to.
+ *
+ * \param data The existing buffer
+ * \param length The length of the existing buffer
+ */
+ BinaryWriter(Uint8* data, Uint64 length);
+
+ /*! \brief This constructor creates an instance from a file on disk.
+ *
+ * \param filename The file to create the stream from
+ */
+ BinaryWriter(const std::string& filename, std::function progressFun = nullptr);
+
+ ~BinaryWriter();
+
+ /*! \brief Sets the Endianss of the stream
+ *
+ * \param endian The Endianess to set \sa Endian
+ */
+ void setEndian(Endian endian);
+
+ /*! \brief Returns the current Endianness of the stream
+ *
+ * \return Endian The current Stream Endianess
+ */
+ Endian endian() const;
+
+ /*! \brief Returns whether the stream is BigEndian
+ *
+ * \return bool True for BigEndian; False for LittleEndian
+ */
+ bool isBigEndian() const;
+
+ /*! \brief Returns whether the stream is LittleEndian
+ *
+ * \return bool True for LittleEndian; False for BigEndian
+ */
+ bool isLittleEndian()const;
+
+ /*! \brief Retuns whether or not the Stream is open.
+ *
+ * \return True if open; False otherwise.
+ */
+ bool isOpen() const;
+
+ /*! \brief Sets the buffers position relative to the specified position.
+ * It seeks relative to the current position by default.
+ * \param position where in the buffer to seek
+ * \param origin The Origin to seek \sa SeekOrigin
+ */
+ void seek(Int64 pos, SeekOrigin origin = SeekOrigin::Current);
+
+
+ /*! \brief Returns whether or not the stream is at the end.
+ *
+ * \return bool True if at end; False otherwise.
+ */
+ bool atEnd() const;
+
+
+ /*! \brief Returns the current position in the stream.
+ *
+ * \return Int64 The current position in the stream.
+ */
+ Uint64 position() const;
+
+ /*! \brief Returns whether or not the stream is at the end.
+ *
+ * \return bool True if at end; False otherwise.
+ */
+ Uint64 length() const;
+
+ /*! \brief Sets the buffer to the given one, deleting the current one.
+ * BEWARE: As this deletes the current buffer it WILL cause a loss of data
+ * if that was not the intent.
+ * Once you pass the data to setData DO NOT delete the buffer
+ * as Stream now owns the address, this is done to keep memory usage down.
+ * \param data The new buffer.
+ * \param length The length of the new buffer.
+ * \throw IOException
+ */
+ void setData(const Uint8* data, Uint64 length);
+
+
+ /*! \brief Returns a copy of the current buffer.
+ * Changes to the copy do not affect the buffer so it's perfectly safe to
+ * directly edit the buffer and use setData to set the new information.
+ * However once you pass the data to setData DO NOT delete the buffer
+ * as Stream now owns the address, this is done to keep memory usage down.
+ * \return Uint8* The copy of the buffer.
+ */
+ Uint8* data() const;
+
+ /*! \brief Sets the target file
+ *
+ * \param filepath The path to write to.
+ */
+ void setFilepath(const std::string& filepath);
+
+ /*! \brief
+ * Returns the target file
+ */
+ std::string filepath() const;
+
+ /*! \brief Saves the file to the specified file.
+ *
+ * \param filename If not empty, the filename to save to
+ */
+ void save(const std::string& filename="");
+
+ /*!
+ * \brief Seeks to the specified bit within the current byte
+ * \param bit Bit to seek to, range is 0 - 7
+ */
+ void seekBit(int bit);
+
+ /*! \brief Writes a bit at the current position and advances the position by one bit.
+ * \param val the value to write
+ * \throw IOException
+ */
+ void writeBit(bool val);
+
+ /*! \brief Writes a byte at the current position and advances the position by one byte.
+ * \param byte The value to write
+ */
+ void writeUByte(Uint8 val);
+
+ /*! \brief Writes a byte at the current position and advances the position by one byte.
+ * \param byte The value to write
+ * \throw IOException
+ */
+ void writeByte(Int8 val);
+
+ /*! \brief Writes the given buffer with the specified length, buffers can be bigger than the length
+ * however it's undefined behavior to try and write a buffer which is smaller than the given length.
+ *
+ * \param data The buffer to write
+ * \param length The amount to write
+ */
+ void writeUBytes(Uint8* data, Uint64 len);
+
+ /*! \brief Writes the given buffer with the specified length, buffers can be bigger than the length
+ * however it's undefined behavior to try and write a buffer which is smaller than the given length.
+ *
+ * \param data The buffer to write
+ * \param length The amount to write
+ */
+ void writeBytes(Int8* data, Uint64 len);
+
+ /*! \brief Writes an Int16 to the buffer and advances the buffer.
+ * It also swaps the bytes depending on the platform and Stream settings.
+ *
+ * \sa Endian
+ * \param val The value to write to the buffer
+ */
+ void writeInt16(Int16 val);
+
+ /*! \brief Writes an Uint16 to the buffer and advances the buffer.
+ * It also swaps the bytes depending on the platform and Stream settings
+ *
+ * \sa Endian
+ * \param val The value to write to the buffer
+ */
+ void writeUint16(Uint16);
+
+ /*! \brief Writes an Int32 to the buffer and advances the buffer.
+ * It also swaps the bytes depending on the platform and Stream settings.
+ *
+ * \sa Endian
+ * \param val The value to write to the buffer
+ */
+ void writeInt32(Int32);
+
+ /*! \brief Writes an Uint32 to the buffer and advances the buffer.
+ * It also swaps the bytes depending on the platform and Stream settings.
+ *
+ * \sa Endian
+ * \param val The value to write to the buffer
+ */
+ void writeUint32(Uint32);
+
+ /*! \brief Writes an Int64 to the buffer and advances the buffer.
+ * It also swaps the bytes depending on the platform and Stream settings.
+ *
+ * \sa Endian
+ * \param val The value to write to the buffer
+ */
+ void writeInt64(Int64);
+
+ /*! \brief Writes an Uint64 to the buffer and advances the buffer.
+ * It also swaps the bytes depending on the platform and Stream settings.
+ *
+ * \sa Endian
+ * \param val The value to write to the buffer
+ */
+ void writeUint64(Uint64);
+
+ /*! \brief Writes an float to the buffer and advances the buffer.
+ * It also swaps the bytes depending on the platform and Stream settings.
+ *
+ * \sa Endian
+ * \param val The value to write to the buffer
+ */
+ void writeFloat(float);
+
+ /*! \brief Writes an double to the buffer and advances the buffer.
+ * It also swaps the bytes depending on the platform and Stream settings.
+ *
+ * \sa Endian
+ * \param val The value to write to the buffer
+ */
+ void writeDouble(double);
+
+ /*! \brief Writes an bool to the buffer and advances the buffer.
+ * It also swaps the bytes depending on the platform and Stream settings.
+ *
+ * \sa Endian
+ * \param val The value to write to the buffer
+ */
+ void writeBool(bool);
+
+ /*! \brief Writes an unicode string to the buffer and advances the buffer.
+ * It also swaps the bytes depending on the platform and Stream settings.
+ *
+ * \sa Endian
+ * \param str The string to write to the buffer
+ */
+ void writeUnicode(const std::string& str);
+
+ /*! \brief Writes an string to the buffer and advances the buffer.
+ *
+ * \sa Endian
+ * \param str The string to write to the buffer
+ */
+ void writeString(const std::string& str);
+
+ void setProgressCallback(std::function cb);
+protected:
+ void loadData();
+ Uint8* m_data;
+ Uint64 m_length;
+ std::string m_filepath; //!< Path to the target file
+ Uint64 m_position;
+ Uint64 m_bitPosition;
+ Endian m_endian;
+ std::function m_progressCallback;
+private:
+ void resize(Uint64 newSize);
+};
+}
+}
+
+#ifndef BINARYWRITER_BASE
+#define BINARYWRITER_BASE \
+ private: \
+ typedef Athena::io::BinaryWriter base;
+#endif // BINARYWRITER_BASE
+#endif // __BINARY_WRITER_HPP__
diff --git a/include/Athena/Checksums.hpp b/include/Athena/Checksums.hpp
new file mode 100644
index 0000000..9d8ecb3
--- /dev/null
+++ b/include/Athena/Checksums.hpp
@@ -0,0 +1,30 @@
+// This file is part of libAthena.
+//
+// libAthena is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libAthena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libAthena. If not, see
+
+#ifndef CHECKSUMS_HPP
+#define CHECKSUMS_HPP
+
+#include "Athena/Global.hpp"
+
+namespace Athena
+{
+namespace Checksums
+{
+Uint32 crc32(const Uint8* data, Uint64 length, Uint32 seed = 0xFFFFFFFF);
+Uint16 crc16CCITT(const Uint8* data, Uint64 length, Uint16 seed = 0xFFFF, Uint16 final = 0);
+Uint16 crc16(const Uint8* data, Uint64 length);
+}
+}
+#endif // CHECKSUMS_HPP
diff --git a/include/Compression.hpp b/include/Athena/Compression.hpp
similarity index 78%
rename from include/Compression.hpp
rename to include/Athena/Compression.hpp
index 3e35d3f..0aeca4b 100644
--- a/include/Compression.hpp
+++ b/include/Athena/Compression.hpp
@@ -1,24 +1,24 @@
-// This file is part of libZelda.
+// This file is part of libAthena.
//
-// libZelda is free software: you can redistribute it and/or modify
+// libAthena is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// libZelda is distributed in the hope that it will be useful,
+// libAthena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with libZelda. If not, see
+// along with libAthena. If not, see
#ifndef COMPRESSION_HPP
#define COMPRESSION_HPP
-#include
+#include "Athena/Global.hpp"
-namespace zelda
+namespace Athena
{
namespace io
{
diff --git a/include/Exception.hpp b/include/Athena/Exception.hpp
similarity index 58%
rename from include/Exception.hpp
rename to include/Athena/Exception.hpp
index cea139e..0c8cd84 100644
--- a/include/Exception.hpp
+++ b/include/Athena/Exception.hpp
@@ -1,17 +1,17 @@
-// This file is part of libZelda.
+// This file is part of libAthena.
//
-// libZelda is free software: you can redistribute it and/or modify
+// libAthena is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// libZelda is distributed in the hope that it will be useful,
+// libAthena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with libZelda. If not, see
+// along with libAthena. If not, see
#ifndef __EXCEPTION_HPP__
#define __EXCEPTION_HPP__
@@ -22,11 +22,10 @@
#define __STR(x) __STRX(x)
#define __LINE_STRING__ __STR(__LINE__)
-namespace zelda
+namespace Athena
{
namespace error
{
-
/*! \class Exception
* \brief The baseclass for all Exceptions.
*
@@ -39,8 +38,11 @@ public:
/*! \brief The constructor for an Exception
* \param message The error message to throw
*/
- inline Exception(const std::string& message) :
- m_message(message)
+ inline Exception(const std::string& message, const std::string& file, const std::string& function, const int line) :
+ m_message(message),
+ m_file(file),
+ m_function(function),
+ m_line(line)
{
}
@@ -51,16 +53,30 @@ public:
{
return m_message;
}
+
+ inline std::string file() const
+ {
+ return m_file;
+ }
+
+ inline std::string function() const
+ {
+ return m_function;
+ }
+
+ inline int line() const
+ {
+ return m_line;
+ }
protected:
std::string m_message; //!< The error message string
+ std::string m_file;
+ std::string m_function;
+ int m_line;
};
-
} // error
-} // zelda
+} // Athena
#define THROW_EXCEPTION(msg) \
- do \
- { \
- throw zelda::error::Exception(__LINE_STRING__ " " __FILE__ " " msg); \
- } while(0)
+ do { throw Athena::error::Exception("Exception: " msg, __FILE__, __PRETTY_FUNCTION__, __LINE__); } while(0)
#endif
diff --git a/include/FileNotFoundException.hpp b/include/Athena/FileNotFoundException.hpp
similarity index 66%
rename from include/FileNotFoundException.hpp
rename to include/Athena/FileNotFoundException.hpp
index d25c2f0..6fd931f 100644
--- a/include/FileNotFoundException.hpp
+++ b/include/Athena/FileNotFoundException.hpp
@@ -1,28 +1,27 @@
-// This file is part of libZelda.
+// This file is part of libAthena.
//
-// libZelda is free software: you can redistribute it and/or modify
+// libAthena is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// libZelda is distributed in the hope that it will be useful,
+// libAthena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with libZelda. If not, see
+// along with libAthena. If not, see
#ifndef __FILENOTFOUNDEXCEPTION_HPP__
#define __FILENOTFOUNDEXCEPTION_HPP__
#include "Exception.hpp"
-namespace zelda
+namespace Athena
{
namespace error
{
-
/*! \class FileNotFoundException
* \brief An excpeption thrown when a file could not be found at the given path.
*
@@ -37,8 +36,8 @@ public:
/*! \brief The constructor for an FileNotFoundException
* \param filename The path of the offending file.
*/
- inline FileNotFoundException(const std::string& filename) :
- Exception("Couldn't find \"" + filename + "\", please check that it exists."),
+ inline FileNotFoundException(const std::string& filename, const std::string& file, const std::string& function, const int line) :
+ Exception(std::string("FileNotFoundException: Could not find file \"") + filename + std::string("\", please check that it exists."), file, function, line),
m_filename(filename)
{}
@@ -49,14 +48,10 @@ public:
private:
std::string m_filename;
};
-
} // error
-} // zelda
+} // Athena
-#define THROW_FILENOTFOUND_EXCEPTION(msg) \
- do \
- { \
- throw zelda::error::FileNotFoundException(__LINE_STRING__ " " __FILE__ " " msg); \
- } while(0)
+#define THROW_FILE_NOT_FOUND_EXCEPTION(msg) \
+ do { throw Athena::error::FileNotFoundException(msg, __FILE__, __PRETTY_FUNCTION__, __LINE__); } while(0)
#endif
diff --git a/include/Athena/FileReader.hpp b/include/Athena/FileReader.hpp
new file mode 100644
index 0000000..ba1765c
--- /dev/null
+++ b/include/Athena/FileReader.hpp
@@ -0,0 +1,76 @@
+// This file is part of libAthena.
+//
+// libAthena is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libAthena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libAthena. If not, see
+
+#ifndef FILESTREAM_HPP
+#define FILESTREAM_HPP
+
+#include "Stream.hpp"
+#include
+#include
+
+namespace Athena
+{
+namespace io
+{
+class FileReader : public Stream
+{
+public:
+ FileReader(const std::string& filename);
+ ~FileReader();
+ std::string filename() const;
+
+ void setEndian(Endian endian);
+ Endian endian() const;
+ bool isBigEndian() const;
+ bool isLittleEndian() const;
+ void open();
+ void close();
+ bool isOpen() const;
+ bool save();
+ void seek(Int64 pos, SeekOrigin origin = SeekOrigin::Current);
+ bool atEnd() const;
+ Uint64 position() const;
+ Uint64 length() const;
+
+
+ void seekBit(int);
+ bool readBit();
+ Uint8 readUByte();
+ Int8 readByte();
+ Uint8* readUBytes(Uint64 len);
+ Int8* readBytes(Uint64 len);
+ Uint16 readUint16();
+ Int16 readInt16();
+ Uint32 readUint32();
+ Int32 readInt32();
+ Uint64 readUint64();
+ Int64 readInt64();
+ double readDouble();
+ float readFloat();
+ bool readBool();
+ std::string readString();
+ std::string readUnicode();
+private:
+ std::string m_filename;
+ FILE* m_fileHandle;
+ Endian m_endian;
+ Uint8 m_currentByte;
+ Uint8 m_bitShift;
+ bool m_bitValid;
+};
+} // io
+} // Athena
+
+#endif // FILESTREAM_HPP
diff --git a/include/Athena/FileWriter.hpp b/include/Athena/FileWriter.hpp
new file mode 100644
index 0000000..ed8a05b
--- /dev/null
+++ b/include/Athena/FileWriter.hpp
@@ -0,0 +1,72 @@
+// This file is part of libAthena.
+//
+// libAthena is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libAthena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libAthena. If not, see
+
+#ifndef FILEWRITER_HPP
+#define FILEWRITER_HPP
+
+#include "Athena/Stream.hpp"
+
+namespace Athena
+{
+namespace io
+{
+class FileWriter : public Stream
+{
+public:
+ FileWriter(const std::string& filename);
+ ~FileWriter();
+
+ void setEndian(Endian endian);
+ Endian endian() const;
+ bool isBigEndian() const;
+ bool isLittleEndian() const;
+ void open();
+ void close();
+ bool isOpen() const;
+ bool save();
+ void seek(Int64 pos, SeekOrigin origin = SeekOrigin::Current);
+ bool atEnd() const;
+ Uint64 position() const;
+ Uint64 length() const;
+
+ void writeBit (bool val);
+ void seekBit (int bit);
+ void writeUByte (Uint8 val);
+ void writeByte (Int8 val);
+ void writeUBytes(Uint8* data, Uint64 len);
+ void writeBytes (Int8* data, Uint64 len);
+ void writeUint16(Uint16 val);
+ void writeInt16 (Int16 val);
+ void writeUint32(Uint32 val);
+ void writeInt32 (Int32 val);
+ void writeUint64(Uint64 val);
+ void writeInt64 (Int64 val);
+ void writeDouble(double val);
+ void writeFloat (float val);
+ void writeBool (bool val);
+ void writeString(const std::string& val);
+ void writeUnicode(const std::string& str);
+private:
+ std::string m_filename;
+ FILE* m_fileHandle;
+ Endian m_endian;
+ Uint8 m_currentByte;
+ Uint8 m_bytePosition;
+ Uint8 m_bitShift;
+ bool m_bitValid;
+};
+}
+} // Athena
+#endif // FILEWRITER_HPP
diff --git a/include/Athena/Global.hpp b/include/Athena/Global.hpp
new file mode 100644
index 0000000..a2e05dc
--- /dev/null
+++ b/include/Athena/Global.hpp
@@ -0,0 +1,81 @@
+// This file is part of libAthena.
+//
+// libAthena is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libAthena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libAthena. If not, see
+
+#ifndef GLOBAL_HPP
+#define GLOBAL_HPP
+
+#include "Athena/Types.hpp"
+#include "Athena/Utility.hpp"
+#include
+
+#ifndef aDebug
+#define aDebug() \
+ std::cout << __FILE__ << "(" << __LINE__ << ") " << __PRETTY_FUNCTION__ << ": "
+#endif
+#ifndef aError
+#define aError() \
+ std::cerr << __FILE__ << "(" << __LINE__ << ") " << __PRETTY_FUNCTION__ << ": "
+#endif
+
+#ifndef BLOCKSZ
+#define BLOCKSZ 512
+#endif
+
+namespace Athena
+{
+enum class SeekOrigin
+{
+ Begin,
+ Current,
+ End
+};
+
+enum class Endian
+{
+ LittleEndian,
+ BigEndian
+};
+
+namespace Sakura
+{
+
+template
+class Vector2D
+{
+public:
+ T x;
+ T y;
+
+ Vector2D()
+ : x(0),
+ y(0)
+ {
+ }
+
+ Vector2D(T x, T y)
+ : x(x),
+ y(y)
+ {
+ }
+};
+
+typedef Vector2D Vector2Di;
+typedef Vector2D Vector2Df;
+} // Sakura
+} // Athena
+
+std::ostream& operator<<(std::ostream& os, const Athena::SeekOrigin& origin);
+std::ostream& operator<<(std::ostream& os, const Athena::Endian& endian);
+#endif // GLOBAL_HPP
diff --git a/include/IOException.hpp b/include/Athena/IOException.hpp
similarity index 68%
rename from include/IOException.hpp
rename to include/Athena/IOException.hpp
index a6a5f2c..25c6d35 100644
--- a/include/IOException.hpp
+++ b/include/Athena/IOException.hpp
@@ -1,17 +1,17 @@
-// This file is part of libZelda.
+// This file is part of libAthena.
//
-// libZelda is free software: you can redistribute it and/or modify
+// libAthena is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// libZelda is distributed in the hope that it will be useful,
+// libAthena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with libZelda. If not, see
+// along with libAthena. If not, see
#ifndef __IOEXCEPTION_HPP__
#define __IOEXCEPTION_HPP__
@@ -19,11 +19,10 @@
#include "Exception.hpp"
-namespace zelda
+namespace Athena
{
namespace error
{
-
/*! \class IOException
* \brief An excpeption thrown on inappropriate IO calls.
*
@@ -40,18 +39,15 @@ public:
/*! \brief The constructor for an IOException
* \param message The error message to throw
*/
- inline IOException(const std::string& message) :
- Exception(message)
+ inline IOException(const std::string& message, const std::string& file, const std::string& function, const int line) :
+ Exception(message, file, function, line)
{}
};
} // error
-} // zelda
+} // Athena
#define THROW_IO_EXCEPTION(msg) \
- do \
- { \
- throw zelda::error::IOException(__LINE_STRING__ " " __FILE__ " " msg); \
- } while(0)
+ do { throw Athena::error::IOException("IOException: " msg, __FILE__, __PRETTY_FUNCTION__, __LINE__); } while(0)
#endif
diff --git a/include/Athena/InvalidDataException.hpp b/include/Athena/InvalidDataException.hpp
new file mode 100644
index 0000000..2b6727d
--- /dev/null
+++ b/include/Athena/InvalidDataException.hpp
@@ -0,0 +1,49 @@
+// This file is part of libAthena.
+//
+// libAthena is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libAthena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libAthena. If not, see
+
+#ifndef INVALIDDATAEXCEPTION_HPP
+#define INVALIDDATAEXCEPTION_HPP
+
+#include "Exception.hpp"
+#include
+
+namespace Athena
+{
+namespace error
+{
+/*! \class InvalidDataException
+ * \brief An exception thrown on Invalid Data calls.
+ *
+ * This should only be thrown when the library tries to
+ * e.g pass a NULL pointer to a function which requires a valid pointer.
+ *
+ * It is NOT appropriate to use throw new so avoid doing so,
+ * keeping things on the stack as much as possible is very important for speed.
+ */
+class InvalidDataException : public Exception
+{
+public:
+ inline InvalidDataException(const std::string& error, const std::string& file, const std::string& function, const int line)
+ : Exception(error, file, function, line)
+ {
+ }
+};
+} // error
+} // Athena
+
+#define THROW_INVALID_DATA_EXCEPTION(msg) \
+ do { throw Athena::error::InvalidDataException("InvalidDataException: " msg, __FILE__, __PRETTY_FUNCTION__, __LINE__); } while(0)
+
+#endif // INVALIDDATAEXCEPTION_HPP
diff --git a/include/InvalidOperationException.hpp b/include/Athena/InvalidOperationException.hpp
similarity index 65%
rename from include/InvalidOperationException.hpp
rename to include/Athena/InvalidOperationException.hpp
index 9e37d8b..c705c9a 100644
--- a/include/InvalidOperationException.hpp
+++ b/include/Athena/InvalidOperationException.hpp
@@ -1,17 +1,17 @@
-// This file is part of libZelda.
+// This file is part of libAthena.
//
-// libZelda is free software: you can redistribute it and/or modify
+// libAthena is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// libZelda is distributed in the hope that it will be useful,
+// libAthena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with libZelda. If not, see
+// along with libAthena. If not, see
#ifndef __INVALID_OPERATION_EXCEPTION_HPP__
#define __INVALID_OPERATION_EXCEPTION_HPP__
@@ -19,11 +19,10 @@
#include
#include "Exception.hpp"
-namespace zelda
+namespace Athena
{
namespace error
{
-
/*! \class InvalidOperationException
* \brief An excpeption thrown on Invalid Operations calls.
*
@@ -39,19 +38,15 @@ public:
/*! \brief The constructor for an InvalidOperationException
* \param error The error message to throw
*/
- inline InvalidOperationException(const std::string& error)
- : Exception(error)
+ inline InvalidOperationException(const std::string& message, const std::string& file, const std::string& function, const int line) :
+ Exception(message, file, function, line)
{
}
};
-
} // error
-} // zelda
+} // Athena
-#define THROW_INVALIDOPERATION_EXCEPTION(msg) \
- do \
- { \
- throw zelda::error::InvalidOperationException(__LINE_STRING__ " " __FILE__ " " msg); \
- } while(0)
+#define THROW_INVALID_OPERATION_EXCEPTION(msg) \
+ do { throw Athena::error::InvalidOperationException("InvalidOperationException: " msg, __FILE__, __PRETTY_FUNCTION__, __LINE__); } while(0)
#endif // __INVALID_OPERATION_EXCEPTION_HPP__
diff --git a/include/MCFile.hpp b/include/Athena/MCFile.hpp
similarity index 73%
rename from include/MCFile.hpp
rename to include/Athena/MCFile.hpp
index ce32684..bdab882 100644
--- a/include/MCFile.hpp
+++ b/include/Athena/MCFile.hpp
@@ -1,22 +1,22 @@
-// This file is part of libZelda.
+// This file is part of libAthena.
//
-// libZelda is free software: you can redistribute it and/or modify
+// libAthena is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// libZelda is distributed in the hope that it will be useful,
+// libAthena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with libZelda. If not, see
+// along with libAthena. If not, see
#ifndef __MCFILE_HPP__
#define __MCFILE_HPP__
-namespace zelda
+namespace Athena
{
/*! \class MCFile
diff --git a/include/MCFileReader.hpp b/include/Athena/MCFileReader.hpp
similarity index 84%
rename from include/MCFileReader.hpp
rename to include/Athena/MCFileReader.hpp
index 84fdab4..02b86b7 100644
--- a/include/MCFileReader.hpp
+++ b/include/Athena/MCFileReader.hpp
@@ -1,25 +1,24 @@
-// This file is part of libZelda.
+// This file is part of libAthena.
//
-// libZelda is free software: you can redistribute it and/or modify
+// libAthena is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// libZelda is distributed in the hope that it will be useful,
+// libAthena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with libZelda. If not, see
+// along with libAthena. If not, see
#ifndef __MCFILEREADER_HPP__
#define __MCFILEREADER_HPP__
-#include "Types.hpp"
#include "BinaryReader.hpp"
-namespace zelda
+namespace Athena
{
class MCFile;
diff --git a/include/MCFileWriter.hpp b/include/Athena/MCFileWriter.hpp
similarity index 87%
rename from include/MCFileWriter.hpp
rename to include/Athena/MCFileWriter.hpp
index 4750072..f5f5f68 100644
--- a/include/MCFileWriter.hpp
+++ b/include/Athena/MCFileWriter.hpp
@@ -1,17 +1,17 @@
-// This file is part of libZelda.
+// This file is part of libAthena.
//
-// libZelda is free software: you can redistribute it and/or modify
+// libAthena is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// libZelda is distributed in the hope that it will be useful,
+// libAthena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with libZelda. If not, see
+// along with libAthena. If not, see
#ifndef __MCFILEWRITER_HPP__
#define __MCFILEWRITER_HPP__
@@ -19,7 +19,7 @@
#include "Types.hpp"
#include "BinaryWriter.hpp"
-namespace zelda
+namespace Athena
{
class MCFile;
diff --git a/include/Athena/NotImplementedException.hpp b/include/Athena/NotImplementedException.hpp
new file mode 100644
index 0000000..371a48e
--- /dev/null
+++ b/include/Athena/NotImplementedException.hpp
@@ -0,0 +1,38 @@
+// This file is part of libAthena.
+//
+// libAthena is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libAthena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libAthena. If not, see
+
+#ifndef NOTIMPLEMENTEDEXCEPTION_HPP
+#define NOTIMPLEMENTEDEXCEPTION_HPP
+
+#include "Athena/Exception.hpp"
+
+namespace Athena
+{
+namespace error
+{
+class NotImplementedException : public Exception
+{
+public:
+ NotImplementedException(const std::string& message, const std::string& file, const std::string& function, const int line) :
+ Exception(message, file, function, line)
+ {}
+};
+} // error
+} // Athena
+
+#define THROW_NOT_IMPLEMENTED_EXCEPTION() \
+ do { throw Athena::error::NotImplementedException("NotImplementedException", __FILE__, __PRETTY_FUNCTION__, __LINE__); } while(0)
+
+#endif // NOTIMPLEMENTEDEXCEPTION_HPP
diff --git a/include/Athena/SkywardSwordFile.hpp b/include/Athena/SkywardSwordFile.hpp
new file mode 100644
index 0000000..c1b420c
--- /dev/null
+++ b/include/Athena/SkywardSwordFile.hpp
@@ -0,0 +1,63 @@
+// This file is part of libAthena.
+//
+// libAthena is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libAthena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libAthena. If not, see
+
+#ifndef __SSFILE_HPP__
+#define __SSFILE_HPP__
+
+#include "Athena/Global.hpp"
+
+// standard lib
+#include
+
+namespace Athena
+{
+class SkywardSwordQuest;
+
+enum class Region
+{
+ NTSC,
+ NTSCJ,
+ PAL
+};
+
+class SkywardSwordFile
+{
+public:
+ enum MagicNumbers
+ {
+ USMagic = 0x534F5545,
+ JAMagic = 0x534F554A,
+ EUMagic = 0x534F5550
+ };
+
+ SkywardSwordFile();
+ SkywardSwordFile(std::vector quests);
+ ~SkywardSwordFile();
+
+ void addQuest(SkywardSwordQuest* q);
+ SkywardSwordQuest* quest(Uint32 id);
+ std::vector questList() const;
+
+ void setRegion(Region region);
+ Region region() const;
+private:
+ Region m_region;
+ // A vector is a bit overkill
+ std::vector m_quests;
+ Uint32 m_numQuests;
+};
+
+}
+#endif // __SSFILE_HPP__
diff --git a/include/Athena/SkywardSwordFileReader.hpp b/include/Athena/SkywardSwordFileReader.hpp
new file mode 100644
index 0000000..643d873
--- /dev/null
+++ b/include/Athena/SkywardSwordFileReader.hpp
@@ -0,0 +1,39 @@
+// This file is part of libAthena.
+//
+// libAthena is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libAthena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libAthena. If not, see
+
+#ifndef __SSFILEREADER_HPP__
+#define __SSFILEREADER_HPP__
+
+#include "BinaryReader.hpp"
+
+namespace Athena
+{
+class SkywardSwordFile;
+namespace io
+{
+class SkywardSwordFileReader : public BinaryReader
+{
+ BINARYREADER_BASE
+public:
+
+ SkywardSwordFileReader(Uint8* data, Uint64 length);
+ SkywardSwordFileReader(const std::string& filename);
+
+ SkywardSwordFile* read();
+};
+} // io
+} // zelda
+
+#endif // __SSFILEREADER_HPP__
diff --git a/include/Athena/SkywardSwordFileWriter.hpp b/include/Athena/SkywardSwordFileWriter.hpp
new file mode 100644
index 0000000..6ec6d22
--- /dev/null
+++ b/include/Athena/SkywardSwordFileWriter.hpp
@@ -0,0 +1,40 @@
+// This file is part of libAthena.
+//
+// libAthena is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libAthena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libAthena. If not, see
+
+#ifndef __SSFILEWRITER_HPP__
+#define __SSFILEWRITER_HPP__
+
+#include "BinaryWriter.hpp"
+
+namespace Athena
+{
+class SkywardSwordFile;
+
+namespace io
+{
+
+class SkywardSwordFileWriter : public BinaryWriter
+{
+ // Why does this fuck up my formatting in Qt Creator?
+ BINARYWRITER_BASE
+public:
+ SkywardSwordFileWriter(Uint8* data, Uint64 len);
+ SkywardSwordFileWriter(const std::string& filename);
+
+ void write(SkywardSwordFile* file);
+};
+}
+}
+#endif // __SSFILEWRITER_HPP__
diff --git a/include/Athena/SkywardSwordQuest.hpp b/include/Athena/SkywardSwordQuest.hpp
new file mode 100644
index 0000000..3e07175
--- /dev/null
+++ b/include/Athena/SkywardSwordQuest.hpp
@@ -0,0 +1,44 @@
+// This file is part of libAthena.
+//
+// libAthena is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libAthena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libAthena. If not, see
+
+#ifndef SKYWARDSWORDQUEST_HPP
+#define SKYWARDSWORDQUEST_HPP
+
+#include "Athena/Global.hpp"
+#include "ZQuestFile.hpp"
+
+namespace Athena
+{
+
+// TODO: Handle game specific data
+class SkywardSwordQuest : public ZQuestFile
+{
+public:
+ SkywardSwordQuest(Uint8* data, Uint32 len);
+
+ // TODO: Is len really needed?
+ void setSkipData(const Uint8* data, Uint32 len = 0x24);
+ Uint8* skipData() const;
+
+ Uint32 skipLength() const;
+
+private:
+ Uint8* m_skipData;
+ Uint32 m_skipLength;
+};
+
+
+} // zelda
+#endif // SSQUEST_HPP
diff --git a/include/Sprite.hpp b/include/Athena/Sprite.hpp
similarity index 81%
rename from include/Sprite.hpp
rename to include/Athena/Sprite.hpp
index d6756f0..1992a66 100644
--- a/include/Sprite.hpp
+++ b/include/Athena/Sprite.hpp
@@ -1,3 +1,18 @@
+// This file is part of libAthena.
+//
+// libAthena is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libAthena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libAthena. If not, see
+
#ifndef SSPRITE_HPP
#define SSPRITE_HPP
@@ -10,9 +25,9 @@
#include
#include
#endif
-#include
+#include "Athena/Global.hpp"
-namespace zelda
+namespace Athena
{
namespace Sakura
{
diff --git a/include/SpriteFile.hpp b/include/Athena/SpriteFile.hpp
similarity index 85%
rename from include/SpriteFile.hpp
rename to include/Athena/SpriteFile.hpp
index 60f0755..8ed39ea 100644
--- a/include/SpriteFile.hpp
+++ b/include/Athena/SpriteFile.hpp
@@ -1,4 +1,19 @@
-#ifndef SSPRITEFILE_HPP
+// This file is part of libAthena.
+//
+// libAthena is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libAthena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libAthena. If not, see
+
+#ifndef SSPRITEFILE_HPP
#define SSPRITEFILE_HPP
#ifndef LIBZELDA_USE_QT
@@ -13,9 +28,9 @@
#endif
#include
-#include
+#include "Athena/Global.hpp"
-namespace zelda
+namespace Athena
{
namespace Sakura
{
diff --git a/include/Athena/SpriteFileReader.hpp b/include/Athena/SpriteFileReader.hpp
new file mode 100644
index 0000000..937245e
--- /dev/null
+++ b/include/Athena/SpriteFileReader.hpp
@@ -0,0 +1,44 @@
+// This file is part of libAthena.
+//
+// libAthena is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libAthena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libAthena. If not, see
+
+#ifndef SSPRITEFILEREADER_HPP
+#define SSPRITEFILEREADER_HPP
+
+#include "Athena/BinaryReader.hpp"
+
+namespace Athena
+{
+namespace Sakura
+{
+class SpriteFile;
+} // Sakura
+
+namespace io
+{
+
+class SpriteFileReader : public BinaryReader
+{
+ BINARYREADER_BASE;
+public:
+ SpriteFileReader(Uint8* data, Uint64 length);
+ SpriteFileReader(const std::string& filepath);
+
+ Sakura::SpriteFile* readFile();
+};
+} // io
+} // zelda
+
+
+#endif // SSPRITEFILEREADER_HPP
diff --git a/include/Athena/SpriteFileWriter.hpp b/include/Athena/SpriteFileWriter.hpp
new file mode 100644
index 0000000..3aaa594
--- /dev/null
+++ b/include/Athena/SpriteFileWriter.hpp
@@ -0,0 +1,44 @@
+// This file is part of libAthena.
+//
+// libAthena is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libAthena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libAthena. If not, see
+
+#ifndef SSPRITEFILEWRITER_HPP
+#define SSPRITEFILEWRITER_HPP
+
+#include "Athena/BinaryWriter.hpp"
+
+namespace Athena
+{
+namespace Sakura
+{
+class SpriteFile;
+} // Sakura
+
+namespace io
+{
+
+class SpriteFileWriter : public BinaryWriter
+{
+ BINARYWRITER_BASE;
+public:
+ SpriteFileWriter(Uint8* data, Uint64 length);
+
+ SpriteFileWriter(const std::string& filepath);
+
+ void writeFile(Sakura::SpriteFile* file);
+};
+
+} // io
+} // zelda
+#endif // SSPRITEFILEWRITER_HPP
diff --git a/include/SpriteFrame.hpp b/include/Athena/SpriteFrame.hpp
similarity index 65%
rename from include/SpriteFrame.hpp
rename to include/Athena/SpriteFrame.hpp
index dd33564..752a7bb 100644
--- a/include/SpriteFrame.hpp
+++ b/include/Athena/SpriteFrame.hpp
@@ -1,8 +1,23 @@
+// This file is part of libAthena.
+//
+// libAthena is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libAthena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libAthena. If not, see
+
#ifndef SSPRITEFRAME_HPP
#define SSPRITEFRAME_HPP
-#include
+#include "Athena/Global.hpp"
#ifndef LIBZELDA_USE_QT
#include
@@ -11,7 +26,7 @@
#include
#endif
-namespace zelda
+namespace Athena
{
namespace Sakura
{
diff --git a/include/SpritePart.hpp b/include/Athena/SpritePart.hpp
similarity index 84%
rename from include/SpritePart.hpp
rename to include/Athena/SpritePart.hpp
index a0f467a..11630d9 100644
--- a/include/SpritePart.hpp
+++ b/include/Athena/SpritePart.hpp
@@ -1,7 +1,22 @@
+// This file is part of libAthena.
+//
+// libAthena is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libAthena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libAthena. If not, see
+
#ifndef SSPRITEPART_HPP
#define SSPRITEPART_HPP
-#include
+#include "Athena/Global.hpp"
#ifndef LIBZELDA_USE_QT
# include
#else
@@ -12,9 +27,8 @@
#endif
#include
-#include
-namespace zelda
+namespace Athena
{
namespace Sakura
{
diff --git a/include/Athena/Stream.hpp b/include/Athena/Stream.hpp
new file mode 100644
index 0000000..bcbadd9
--- /dev/null
+++ b/include/Athena/Stream.hpp
@@ -0,0 +1,79 @@
+// This file is part of libAthena.
+//
+// libAthena is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// libAthena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with libAthena. If not, see
+
+#ifndef STREAM_HPP
+#define STREAM_HPP
+
+#include "Global.hpp"
+#include "Athena/NotImplementedException.hpp"
+
+namespace Athena
+{
+
+std::ostream& operator<<(std::ostream& os, Endian& endian);
+
+class Stream
+{
+public:
+
+
+ virtual void setEndian(Endian) = 0;
+ virtual Endian endian() const= 0;
+ virtual bool isBigEndian() const= 0;
+ virtual bool isLittleEndian()const= 0;
+ virtual bool isOpen() const= 0;
+ virtual void seek(Int64, SeekOrigin)=0;
+ virtual bool atEnd() const= 0;
+ virtual Uint64 position() const= 0;
+ virtual Uint64 length() const= 0;
+protected:
+ virtual void seekBit (int){THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ // Reading
+ virtual bool readBit() {THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual Uint8 readUByte() {THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual Int8 readByte() {THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual Uint8* readUBytes(Uint64){THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual Int8* readBytes(Uint64) {THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual Uint16 readUint16() {THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual Int16 readInt16() {THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual Uint32 readUint32() {THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual Int32 readInt32() {THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual Uint64 readUint64() {THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual Int64 readInt64() {THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual double readDouble() {THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual float readFloat() {THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual bool readBool() {THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual std::string readUnicode(){THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual std::string readString() {THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ // Writing
+ virtual void writeBit (bool){THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual void writeUByte (Uint8){THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual void writeByte (Int8){THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual void writeUBytes(Uint8*, Uint64){THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual void writeBytes (Int8*, Uint64){THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual void writeUint16(Uint16){THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual void writeInt16 (Int16){THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual void writeUint32(Uint32){THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual void writeInt32 (Int32){THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual void writeUint64(Uint64){THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual void writeInt64 (Int64){THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual void writeDouble(double){THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual void writeFloat (float){THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual void writeBool (bool){THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual void writeString(const std::string&){THROW_NOT_IMPLEMENTED_EXCEPTION();}
+ virtual void writeUnicode(const std::string&){THROW_NOT_IMPLEMENTED_EXCEPTION();}
+};
+}
+#endif // STREAM_HPP
diff --git a/include/Types.hpp b/include/Athena/Types.hpp
similarity index 64%
rename from include/Types.hpp
rename to include/Athena/Types.hpp
index 88d69b9..4630242 100644
--- a/include/Types.hpp
+++ b/include/Athena/Types.hpp
@@ -1,72 +1,22 @@
-// This file is part of libZelda.
+// This file is part of libAthena.
//
-// libZelda is free software: you can redistribute it and/or modify
+// libAthena is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// libZelda is distributed in the hope that it will be useful,
+// libAthena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with libZelda. If not, see
-#ifndef __TYPES_HPP__
-#define __TYPES_HPP__
+// along with libAthena. If not, see
+#ifndef TYPES_HPP
+#define TYPES_HPP
#include
-#ifdef __cplusplus
-namespace zelda
-{
-/*! \enum Endian
- * \brief Allows the user to specify the Endianness of data.
- * The proper actions are automatically taken depending on platform and
- * buffer settings
- */
-enum Endian
-{
- LittleEndian, //!< Specifies that the Stream is Little Endian (LSB)
- BigEndian //!< Specifies that the Stream is Big Endian (MSB)
-};
-
-enum Region
-{
- NTSCURegion,
- NTSCJRegion,
- PALRegion
-};
-
-namespace Sakura
-{
-
-template
-class Vector2D
-{
-public:
- T x;
- T y;
-
- Vector2D()
- : x(0),
- y(0)
- {
- }
-
- Vector2D(T x, T y)
- : x(x),
- y(y)
- {
- }
-};
-
-typedef Vector2D Vector2Di;
-typedef Vector2D Vector2Df;
-} // Sakura
-} // zelda
-#endif
-
// 8 bits integer types
#if UCHAR_MAX == 0xFF
typedef signed char Int8;
@@ -127,4 +77,4 @@ typedef unsigned long long Uint64;
#define DEPRECATED(func) func
#endif
-#endif
+#endif // TYPES_HPP
diff --git a/include/utility.hpp b/include/Athena/Utility.hpp
similarity index 78%
rename from include/utility.hpp
rename to include/Athena/Utility.hpp
index c9b8696..fb25fa3 100644
--- a/include/utility.hpp
+++ b/include/Athena/Utility.hpp
@@ -1,17 +1,18 @@
-// This file is part of libZelda.
+// This file is part of libAthena.
//
-// libZelda is free software: you can redistribute it and/or modify
+// libAthena is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// libZelda is distributed in the hope that it will be useful,
+// libAthena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with libZelda. If not, see
+// along with libAthena. If not, see
+
#ifndef __UTILITY_H__
#define __UTILITY_H__
@@ -20,11 +21,10 @@
#include
#include "Types.hpp"
-namespace zelda
+namespace Athena
{
namespace utility
{
-
bool isEmpty(Int8*, Uint32);
Uint16 swapU16(Uint16 val );
@@ -45,12 +45,12 @@ std::vector split(const std::string &s, char delim);
std::string join(const std::vector& elems, const std::string& delims);
void tolower(std::string& str);
void toupper(std::string& str);
-std::string sprintf(const char* fmt, ...);
+std::string stdsprintf(const char* fmt, ...);
bool parseBool(const std::string& boolean, bool* valid = NULL);
int countChar(const std::string& str, const char chr, int* lastOccur = NULL);
+Uint64 fileSize(FILE* f);
} // utility
-} // zelda
-
+} // Athena
#endif
diff --git a/include/WiiBanner.hpp b/include/Athena/WiiBanner.hpp
similarity index 88%
rename from include/WiiBanner.hpp
rename to include/Athena/WiiBanner.hpp
index 6a5bc55..f1c83df 100644
--- a/include/WiiBanner.hpp
+++ b/include/Athena/WiiBanner.hpp
@@ -1,26 +1,27 @@
-// This file is part of libZelda.
+// This file is part of libAthena.
//
-// libZelda is free software: you can redistribute it and/or modify
+// libAthena is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// libZelda is distributed in the hope that it will be useful,
+// libAthena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with libZelda. If not, see
+// along with libAthena. If not, see
+
#ifndef WIIBANNER_H
#define WIIBANNER_H
#include
#include
-#include
+#include "Athena/Global.hpp"
-namespace zelda
+namespace Athena
{
class WiiImage;
/*! \class WiiBanner
diff --git a/include/WiiFile.hpp b/include/Athena/WiiFile.hpp
similarity index 79%
rename from include/WiiFile.hpp
rename to include/Athena/WiiFile.hpp
index 927c07b..a3af946 100644
--- a/include/WiiFile.hpp
+++ b/include/Athena/WiiFile.hpp
@@ -1,27 +1,32 @@
-// This file is part of libZelda.
+// This file is part of libAthena.
//
-// libZelda is free software: you can redistribute it and/or modify
+// libAthena is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
-// libZelda is distributed in the hope that it will be useful,
+// libAthena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
-// along with libZelda. If not, see
+// along with libAthena. If not, see
+
#ifndef WIIFILE_H
#define WIIFILE_H
#include
#include