mirror of https://github.com/libAthena/athena.git
* Major rewrite
This commit is contained in:
parent
1a389de296
commit
ec4167abca
19
.travis.yml
19
.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"
|
||||
|
|
|
@ -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
|
||||
|
|
@ -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
|
|
@ -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)
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#include "Types.hpp"
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
|
||||
enum BowType : char
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#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__
|
|
@ -16,10 +16,10 @@
|
|||
#ifndef __ALTTP_FILE_HPP__
|
||||
#define __ALTTP_FILE_HPP__
|
||||
|
||||
#include <Types.hpp>
|
||||
#include "Athena/Types.hpp"
|
||||
#include <vector>
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
|
||||
class ALTTPQuest;
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef __ALTTP_FILE_HPP__
|
||||
#define __ALTTP_FILE_HPP__
|
||||
|
||||
#include "Athena/Types.hpp"
|
||||
#include <vector>
|
||||
|
||||
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<ALTTPQuest*>::iterator QuestIter;
|
||||
|
||||
/*! \brief Default constructor
|
||||
*
|
||||
*
|
||||
*/
|
||||
ALTTPFile();
|
||||
|
||||
/*! \brief Constructor
|
||||
*
|
||||
* \param questList The primary quest list
|
||||
* \param backupList The backup quest list
|
||||
*/
|
||||
ALTTPFile(std::vector<ALTTPQuest*> questList, std::vector<ALTTPQuest*> 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<ALTTPQuest*> 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<ALTTPQuest*> m_quests;
|
||||
std::vector<ALTTPQuest*> m_backup;
|
||||
};
|
||||
|
||||
} // zelda
|
||||
#endif // __ALTTP_FILE_HPP__
|
|
@ -21,7 +21,7 @@
|
|||
#include "BinaryReader.hpp"
|
||||
#include "ALTTPQuest.hpp"
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
class ALTTPFile;
|
||||
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef __ALTTP_FILE_READER_HPP__
|
||||
#define __ALTTP_FILE_READER_HPP__
|
||||
|
||||
#include <string>
|
||||
#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__
|
|
@ -17,11 +17,10 @@
|
|||
#define __ALTTP_FILE_WRITER_HPP__
|
||||
|
||||
#include <string>
|
||||
#include <Types.hpp>
|
||||
#include <BinaryWriter.hpp>
|
||||
#include "ALTTPQuest.hpp"
|
||||
#include "Athena/BinaryWriter.hpp"
|
||||
#include "Athena/ALTTPQuest.hpp"
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
class ALTTPFile;
|
||||
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef __ALTTP_FILE_WRITER_HPP__
|
||||
#define __ALTTP_FILE_WRITER_HPP__
|
||||
|
||||
#include <string>
|
||||
#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__
|
|
@ -22,7 +22,7 @@
|
|||
#include "ALTTPStructs.hpp"
|
||||
#include "ALTTPEnums.hpp"
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
|
||||
/*! \class ALTTPQuest
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
#ifndef __ALTTP_QUEST_HPP__
|
||||
#define __ALTTP_QUEST_HPP__
|
||||
|
||||
#include "Types.hpp"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#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<ALTTPRoomFlags*> flags);
|
||||
|
||||
/*!
|
||||
* \brief setRoomFlags
|
||||
* \param rf
|
||||
* \param id
|
||||
*/
|
||||
void setRoomFlags(ALTTPRoomFlags* rf, Uint32 id);
|
||||
|
||||
/*!
|
||||
* \brief roomFlags
|
||||
* \return
|
||||
*/
|
||||
std::vector<ALTTPRoomFlags*> roomFlags();
|
||||
|
||||
/*!
|
||||
* \brief roomFlags
|
||||
* \param id
|
||||
* \return
|
||||
*/
|
||||
ALTTPRoomFlags* roomFlags(Uint32 id);
|
||||
|
||||
/*!
|
||||
* \brief setOverworldEvents
|
||||
* \param events
|
||||
*/
|
||||
void setOverworldEvents(std::vector<ALTTPOverworldEvent*> events);
|
||||
|
||||
/*!
|
||||
* \brief setOverworldEvents
|
||||
* \param ow
|
||||
* \param id
|
||||
*/
|
||||
void setOverworldEvents(ALTTPOverworldEvent* ow, Uint32 id);
|
||||
|
||||
/*!
|
||||
* \brief overworldEvents
|
||||
* \return
|
||||
*/
|
||||
std::vector<ALTTPOverworldEvent*> 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<Uint8> 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<Uint8> 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<Uint8> 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<Uint16> playerName);
|
||||
/*!
|
||||
* \brief setPlayerName
|
||||
* \param playerName
|
||||
*/
|
||||
void setPlayerName(const std::string& playerName);
|
||||
/*!
|
||||
* \brief playerName
|
||||
* \return
|
||||
*/
|
||||
std::vector<Uint16> 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<Uint16> 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<ALTTPRoomFlags*> m_roomFlags;
|
||||
std::vector<ALTTPOverworldEvent*> 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<Uint8> 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<Uint8> m_oldManFlags;
|
||||
Uint8 m_bombFlag;
|
||||
std::vector<Uint8> m_unknown1;
|
||||
std::vector<Uint16> m_playerName;
|
||||
Uint16 m_valid;
|
||||
std::vector<Uint16> m_dungeonDeathTotals;
|
||||
Uint16 m_unknown2;
|
||||
Uint16 m_deathSaveCount;
|
||||
Int16 m_postGameDeathCounter;
|
||||
Uint16 m_checksum;
|
||||
};
|
||||
|
||||
} // zelda
|
||||
|
||||
#endif // __ALTTP_QUEST_HPP__
|
|
@ -21,7 +21,7 @@
|
|||
#include <string>
|
||||
#include "Types.hpp"
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
|
||||
struct ALTTPRoomFlags
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef __ALTTP_STRUCTS_HPP__
|
||||
#define __ALTTP_STRUCTS_HPP__
|
||||
|
||||
#ifndef __DOXYGEN_IGNORE__
|
||||
|
||||
#include <string>
|
||||
#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__
|
|
@ -20,11 +20,10 @@
|
|||
#include <string>
|
||||
#include <functional>
|
||||
|
||||
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<void(int)> 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.<br />
|
||||
* 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.<br />
|
||||
* <b>BEWARE:</b> As this deletes the current buffer it WILL cause a loss of data
|
||||
* if that was not the intent.<br />
|
||||
* Once you pass the data to setData <b>DO NOT</b> 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.<br />
|
||||
* 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.<br />
|
||||
* However once you pass the data to setData <b>DO NOT</b> 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<void(int)> 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<void(int)> m_progressCallback;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
} // io
|
||||
} // Athena
|
||||
|
||||
#ifndef BINARYREADER_BASE
|
||||
#define BINARYREADER_BASE \
|
||||
private: \
|
||||
typedef zelda::io::BinaryReader base;
|
||||
typedef Athena::io::BinaryReader base;
|
||||
|
||||
#endif // BINARYREADER_BASE
|
||||
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef __BINARYREADER_HPP__
|
||||
#define __BINARYREADER_HPP__
|
||||
|
||||
#include "Stream.hpp"
|
||||
#include <string>
|
||||
#include <functional>
|
||||
|
||||
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<void(int)> 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.<br />
|
||||
* 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.<br />
|
||||
* <b>BEWARE:</b> As this deletes the current buffer it WILL cause a loss of data
|
||||
* if that was not the intent.<br />
|
||||
* Once you pass the data to setData <b>DO NOT</b> 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.<br />
|
||||
* 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.<br />
|
||||
* However once you pass the data to setData <b>DO NOT</b> 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<void(int)> 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<void(int)> m_progressCallback;
|
||||
};
|
||||
|
||||
} // io
|
||||
} // Athena
|
||||
|
||||
#ifndef BINARYREADER_BASE
|
||||
#define BINARYREADER_BASE \
|
||||
private: \
|
||||
typedef Athena::io::BinaryReader base;
|
||||
|
||||
#endif // BINARYREADER_BASE
|
||||
|
||||
#endif // __BINARYREADER_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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef __BINARYWRITER_HPP__
|
||||
#define __BINARYWRITER_HPP__
|
||||
|
||||
#include "Stream.hpp"
|
||||
#include <string>
|
||||
#include <functional>
|
||||
|
||||
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<void(int)> 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.<br />
|
||||
* 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.<br />
|
||||
* <b>BEWARE:</b> As this deletes the current buffer it WILL cause a loss of data
|
||||
* if that was not the intent.<br />
|
||||
* Once you pass the data to setData <b>DO NOT</b> 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.<br />
|
||||
* 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.<br />
|
||||
* However once you pass the data to setData <b>DO NOT</b> 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<void(int)> 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<void(int)> 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__
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#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
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef COMPRESSION_HPP
|
||||
#define COMPRESSION_HPP
|
||||
|
||||
#include <Types.hpp>
|
||||
#include "Athena/Global.hpp"
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
namespace io
|
||||
{
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#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
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#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
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef FILESTREAM_HPP
|
||||
#define FILESTREAM_HPP
|
||||
|
||||
#include "Stream.hpp"
|
||||
#include <string>
|
||||
#include <cstdio>
|
||||
|
||||
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
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#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
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef GLOBAL_HPP
|
||||
#define GLOBAL_HPP
|
||||
|
||||
#include "Athena/Types.hpp"
|
||||
#include "Athena/Utility.hpp"
|
||||
#include <iostream>
|
||||
|
||||
#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 <typename T>
|
||||
class Vector2D
|
||||
{
|
||||
public:
|
||||
T x;
|
||||
T y;
|
||||
|
||||
Vector2D()
|
||||
: x(0),
|
||||
y(0)
|
||||
{
|
||||
}
|
||||
|
||||
Vector2D(T x, T y)
|
||||
: x(x),
|
||||
y(y)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
typedef Vector2D<int> Vector2Di;
|
||||
typedef Vector2D<float> 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
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#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
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef INVALIDDATAEXCEPTION_HPP
|
||||
#define INVALIDDATAEXCEPTION_HPP
|
||||
|
||||
#include "Exception.hpp"
|
||||
#include <sstream>
|
||||
|
||||
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.
|
||||
* <br />
|
||||
* It is <b>NOT</b> appropriate to use <b>throw new</b> 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
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef __INVALID_OPERATION_EXCEPTION_HPP__
|
||||
#define __INVALID_OPERATION_EXCEPTION_HPP__
|
||||
|
@ -19,11 +19,10 @@
|
|||
#include <string>
|
||||
#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__
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef __MCFILE_HPP__
|
||||
#define __MCFILE_HPP__
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
|
||||
/*! \class MCFile
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef __MCFILEREADER_HPP__
|
||||
#define __MCFILEREADER_HPP__
|
||||
|
||||
#include "Types.hpp"
|
||||
#include "BinaryReader.hpp"
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
|
||||
class MCFile;
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef __MCFILEWRITER_HPP__
|
||||
#define __MCFILEWRITER_HPP__
|
||||
|
@ -19,7 +19,7 @@
|
|||
#include "Types.hpp"
|
||||
#include "BinaryWriter.hpp"
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
|
||||
class MCFile;
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#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
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef __SSFILE_HPP__
|
||||
#define __SSFILE_HPP__
|
||||
|
||||
#include "Athena/Global.hpp"
|
||||
|
||||
// standard lib
|
||||
#include <vector>
|
||||
|
||||
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<SkywardSwordQuest*> quests);
|
||||
~SkywardSwordFile();
|
||||
|
||||
void addQuest(SkywardSwordQuest* q);
|
||||
SkywardSwordQuest* quest(Uint32 id);
|
||||
std::vector<SkywardSwordQuest*> questList() const;
|
||||
|
||||
void setRegion(Region region);
|
||||
Region region() const;
|
||||
private:
|
||||
Region m_region;
|
||||
// A vector is a bit overkill
|
||||
std::vector<SkywardSwordQuest*> m_quests;
|
||||
Uint32 m_numQuests;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // __SSFILE_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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#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__
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#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__
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#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
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef SSPRITE_HPP
|
||||
#define SSPRITE_HPP
|
||||
|
||||
|
@ -10,9 +25,9 @@
|
|||
#include <QString>
|
||||
#include <QList>
|
||||
#endif
|
||||
#include <Types.hpp>
|
||||
#include "Athena/Global.hpp"
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
namespace Sakura
|
||||
{
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef SSPRITEFILE_HPP
|
||||
#define SSPRITEFILE_HPP
|
||||
|
||||
#ifndef LIBZELDA_USE_QT
|
||||
|
@ -13,9 +28,9 @@
|
|||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <Types.hpp>
|
||||
#include "Athena/Global.hpp"
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
namespace Sakura
|
||||
{
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#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
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#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
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef SSPRITEFRAME_HPP
|
||||
#define SSPRITEFRAME_HPP
|
||||
|
||||
|
||||
#include <Types.hpp>
|
||||
#include "Athena/Global.hpp"
|
||||
|
||||
#ifndef LIBZELDA_USE_QT
|
||||
#include <vector>
|
||||
|
@ -11,7 +26,7 @@
|
|||
#include <QList>
|
||||
#endif
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
namespace Sakura
|
||||
{
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef SSPRITEPART_HPP
|
||||
#define SSPRITEPART_HPP
|
||||
|
||||
#include <Types.hpp>
|
||||
#include "Athena/Global.hpp"
|
||||
#ifndef LIBZELDA_USE_QT
|
||||
# include <vector>
|
||||
#else
|
||||
|
@ -12,9 +27,8 @@
|
|||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <Types.hpp>
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
namespace Sakura
|
||||
{
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#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
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
#ifndef __TYPES_HPP__
|
||||
#define __TYPES_HPP__
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef TYPES_HPP
|
||||
#define TYPES_HPP
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace zelda
|
||||
{
|
||||
/*! \enum Endian
|
||||
* \brief Allows the user to specify the Endianness of data.<br />
|
||||
* 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 <typename T>
|
||||
class Vector2D
|
||||
{
|
||||
public:
|
||||
T x;
|
||||
T y;
|
||||
|
||||
Vector2D()
|
||||
: x(0),
|
||||
y(0)
|
||||
{
|
||||
}
|
||||
|
||||
Vector2D(T x, T y)
|
||||
: x(x),
|
||||
y(y)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
typedef Vector2D<int> Vector2Di;
|
||||
typedef Vector2D<float> 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
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
|
||||
#ifndef __UTILITY_H__
|
||||
#define __UTILITY_H__
|
||||
|
@ -20,11 +21,10 @@
|
|||
#include <vector>
|
||||
#include "Types.hpp"
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
namespace utility
|
||||
{
|
||||
|
||||
bool isEmpty(Int8*, Uint32);
|
||||
|
||||
Uint16 swapU16(Uint16 val );
|
||||
|
@ -45,12 +45,12 @@ std::vector<std::string> split(const std::string &s, char delim);
|
|||
std::string join(const std::vector<std::string>& 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
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef WIIBANNER_H
|
||||
#define WIIBANNER_H
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <Types.hpp>
|
||||
#include "Athena/Global.hpp"
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
class WiiImage;
|
||||
/*! \class WiiBanner
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef WIIFILE_H
|
||||
#define WIIFILE_H
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <Types.hpp>
|
||||
#include "Athena/Global.hpp"
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
|
||||
const Uint8 SD_KEY [16] = {0xab, 0x01, 0xb9, 0xd8, 0xe1, 0x62, 0x2b, 0x08, 0xaf, 0xba, 0xd8, 0x4d, 0xbf, 0xc2, 0xa5, 0x5d};
|
||||
const Uint8 SD_IV [16] = {0x21, 0x67, 0x12, 0xe6, 0xaa, 0x1f, 0x68, 0x9f, 0x95, 0xc5, 0xa2, 0x23, 0x24, 0xdc, 0x6a, 0x98};
|
||||
const Uint8 MD5_BLANKER[16] = {0x0e, 0x65, 0x37, 0x81, 0x99, 0xbe, 0x45, 0x17, 0xab, 0x06, 0xec, 0x22, 0x45, 0x1a, 0x57, 0x93};
|
||||
|
||||
/*! \class WiiFile
|
||||
* \brief Wii file container class
|
||||
*
|
|
@ -1,23 +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 <http://www.gnu.org/licenses/>
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef __WIIIMAGE_HPP__
|
||||
#define __WIIIMAGE_HPP__
|
||||
|
||||
#include "Types.hpp"
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
|
||||
/*!
|
|
@ -1,25 +1,26 @@
|
|||
// 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 <http://www.gnu.org/licenses/>
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef __WII__SAVE_HPP__
|
||||
#define __WII__SAVE_HPP__
|
||||
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
#include <Types.hpp>
|
||||
#include "Athena/Global.hpp"
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
|
||||
class WiiFile;
|
|
@ -1,26 +1,25 @@
|
|||
// 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 <http://www.gnu.org/licenses/>
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef __WII_SAVE_READER_HPP__
|
||||
#define __WII_SAVE_READER_HPP__
|
||||
|
||||
#include "Types.hpp"
|
||||
#include "utility.hpp"
|
||||
#include "BinaryReader.hpp"
|
||||
#include "Athena/Global.hpp"
|
||||
#include "Athena/BinaryReader.hpp"
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
class WiiSave;
|
||||
class WiiBanner;
|
|
@ -1,26 +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 <http://www.gnu.org/licenses/>
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef __WII_SAVE_WRITER_HPP__
|
||||
#define __WII_SAVE_WRITER_HPP__
|
||||
|
||||
#include "Types.hpp"
|
||||
#include "utility.hpp"
|
||||
#include "BinaryWriter.hpp"
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
class WiiSave;
|
||||
class WiiBanner;
|
|
@ -1,29 +1,29 @@
|
|||
// 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 <http://www.gnu.org/licenses/>
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef ZQUEST_HPP
|
||||
#define ZQUEST_HPP
|
||||
|
||||
#include "Types.hpp"
|
||||
#include "Athena/Global.hpp"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#define ZQUEST_VERSION_CHECK(major, minor, revision) \
|
||||
(major | (minor << 8) | (revision << 16))
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
/*!
|
||||
* \brief ZQuestFile is an export format for save data.
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef __ZQUESTFILEREADER_HPP__
|
||||
#define __ZQUESTFILEREADER_HPP__
|
||||
|
||||
#include "BinaryReader.hpp"
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
class ZQuestFile;
|
||||
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef __ZQUESTFILEWRITER_HPP__
|
||||
#define __ZQUESTFILEWRITER_HPP__
|
||||
|
||||
#include <BinaryWriter.hpp>
|
||||
#include "Athena/BinaryWriter.hpp"
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
class ZQuestFile;
|
||||
|
|
@ -1,176 +0,0 @@
|
|||
// This file is part of libZelda.
|
||||
//
|
||||
// libZelda 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,
|
||||
// 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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef __BINARYWRITER_HPP__
|
||||
#define __BINARYWRITER_HPP__
|
||||
|
||||
#include "Stream.hpp"
|
||||
#include <string>
|
||||
|
||||
namespace zelda
|
||||
{
|
||||
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(const Uint8* data, Uint64 length);
|
||||
|
||||
/*! \brief This constructor takes an existing Stream to write to.
|
||||
*
|
||||
* \param stream The stream to write data to
|
||||
*/
|
||||
BinaryWriter(const Stream& stream);
|
||||
|
||||
/*! \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);
|
||||
|
||||
/*! \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 Saves the file to the specified file.
|
||||
*
|
||||
* \param filename If not empty, the filename to save to
|
||||
*/
|
||||
void save(const std::string& filename="");
|
||||
|
||||
/*! \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);
|
||||
|
||||
protected:
|
||||
Int8 readByte();
|
||||
Int8* readBytes(Int64);
|
||||
bool isOpenForReading(); //!< Overridden from \sa Stream
|
||||
std::string m_filepath; //!< Path to the target file
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef BINARYWRITER_BASE
|
||||
#define BINARYWRITER_BASE \
|
||||
private: \
|
||||
typedef zelda::io::BinaryWriter base;
|
||||
#endif // BINARYWRITER_BASE
|
||||
#endif // __BINARY_WRITER_HPP__
|
|
@ -1,15 +0,0 @@
|
|||
#ifndef CHECKSUMS_HPP
|
||||
#define CHECKSUMS_HPP
|
||||
|
||||
#include <Types.hpp>
|
||||
|
||||
namespace zelda
|
||||
{
|
||||
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
|
|
@ -1,37 +0,0 @@
|
|||
#ifndef INVALIDDATAEXCEPTION_HPP
|
||||
#define INVALIDDATAEXCEPTION_HPP
|
||||
|
||||
#include "Exception.hpp"
|
||||
#include <sstream>
|
||||
|
||||
namespace zelda
|
||||
{
|
||||
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.
|
||||
* <br />
|
||||
* It is <b>NOT</b> appropriate to use <b>throw new</b> 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)
|
||||
: Exception(error)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#define THROW_INVALID_DATA(msg) \
|
||||
do \
|
||||
{ \
|
||||
throw zelda::error::InvalidDataException(__LINE_STRING__ " " __FILE__ " " msg); \
|
||||
} while(0)
|
||||
#endif // INVALIDDATAEXCEPTION_HPP
|
|
@ -1,85 +0,0 @@
|
|||
// This file is part of libZelda.
|
||||
//
|
||||
// libZelda 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,
|
||||
// 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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#ifndef __MAINPAGE_HPP__
|
||||
#define __MAINPAGE_HPP__
|
||||
|
||||
/*! \mainpage libZelda
|
||||
* \section intro_sec Introduction to libZelda
|
||||
* libZelda is an IO Library which is designed to be powerful, simple,
|
||||
* and infinitely extensible. <br />
|
||||
* <br />
|
||||
* 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 TextStream.
|
||||
* \section example_sec BinaryWriter example
|
||||
* \code
|
||||
* #include "BinaryWriter.hpp"
|
||||
* #include "FileNotFoundException.hpp"
|
||||
* #include "Exception.hpp"
|
||||
* int main()
|
||||
* {
|
||||
* try
|
||||
* {
|
||||
* BinaryWriter writer("test.bin");
|
||||
* writer.writeByte('t');
|
||||
* writer.writeInt32(123454321);
|
||||
* writer.save();
|
||||
* }
|
||||
* catch (FileNotFoundException e)
|
||||
* {
|
||||
* std::cout << e.message() << std::endl;
|
||||
* }
|
||||
* catch (Exception e)
|
||||
* {
|
||||
* std::cout << e.message() << std::endl;
|
||||
* }
|
||||
* catch(...)
|
||||
* {
|
||||
* }
|
||||
* return 0;
|
||||
* }
|
||||
* \endcode
|
||||
* \section example_sec BinaryReader example
|
||||
* \code
|
||||
* #include "BinaryReader.hpp"
|
||||
* #include "FileNotFoundException.hpp"
|
||||
* #include "Exception.hpp"
|
||||
* int main()
|
||||
* {
|
||||
* try
|
||||
* {
|
||||
* BinaryReader writer("test.bin");
|
||||
* std::cout << reader.readByte() << std::endl;
|
||||
* std::cout << reader.readInt32() << std::endl;
|
||||
* }
|
||||
* catch (FileNotFoundException e)
|
||||
* {
|
||||
* std::cout << e.message() << std::endl;
|
||||
* }
|
||||
* catch (Exception e)
|
||||
* {
|
||||
* std::cout << e.message() << std::endl;
|
||||
* }
|
||||
* catch(...)
|
||||
* {
|
||||
* }
|
||||
* return 0;
|
||||
* }
|
||||
* \endcode
|
||||
* \section Credits
|
||||
* Chibi Zelda: <a href="http://animewaterfall.deviantart.com/art/Chibi-Zelda-331611090">AnimeWaterFall</a> on Deviantart
|
||||
*/
|
||||
#endif // __MAINPAGE_HPP__
|
|
@ -1,41 +0,0 @@
|
|||
#ifndef __SSFILE_HPP__
|
||||
#define __SSFILE_HPP__
|
||||
|
||||
#include "Types.hpp"
|
||||
|
||||
// standard lib
|
||||
#include <vector>
|
||||
|
||||
namespace zelda
|
||||
{
|
||||
class SkywardSwordQuest;
|
||||
|
||||
class SkywardSwordFile
|
||||
{
|
||||
public:
|
||||
enum MagicNumbers
|
||||
{
|
||||
USMagic = 0x534F5545,
|
||||
JAMagic = 0x534F554A,
|
||||
EUMagic = 0x534F5550
|
||||
};
|
||||
|
||||
SkywardSwordFile();
|
||||
SkywardSwordFile(std::vector<SkywardSwordQuest*> quests);
|
||||
~SkywardSwordFile();
|
||||
|
||||
void addQuest(SkywardSwordQuest* q);
|
||||
SkywardSwordQuest* quest(Uint32 id);
|
||||
std::vector<SkywardSwordQuest*> questList() const;
|
||||
|
||||
void setRegion(Region region);
|
||||
Region region() const;
|
||||
private:
|
||||
Region m_region;
|
||||
// A vector is a bit overkill
|
||||
std::vector<SkywardSwordQuest*> m_quests;
|
||||
Uint32 m_numQuests;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // __SSFILE_HPP__
|
|
@ -1,24 +0,0 @@
|
|||
#ifndef __SSFILEREADER_HPP__
|
||||
#define __SSFILEREADER_HPP__
|
||||
|
||||
#include "BinaryReader.hpp"
|
||||
|
||||
namespace zelda
|
||||
{
|
||||
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__
|
|
@ -1,25 +0,0 @@
|
|||
#ifndef __SSFILEWRITER_HPP__
|
||||
#define __SSFILEWRITER_HPP__
|
||||
|
||||
#include "BinaryWriter.hpp"
|
||||
|
||||
namespace zelda
|
||||
{
|
||||
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__
|
|
@ -1,28 +0,0 @@
|
|||
#ifndef SKYWARDSWORDQUEST_HPP
|
||||
#define SKYWARDSWORDQUEST_HPP
|
||||
|
||||
#include "ZQuestFile.hpp"
|
||||
|
||||
namespace zelda
|
||||
{
|
||||
|
||||
// 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
|
|
@ -1,29 +0,0 @@
|
|||
#ifndef SSPRITEFILEREADER_HPP
|
||||
#define SSPRITEFILEREADER_HPP
|
||||
|
||||
#include <BinaryReader.hpp>
|
||||
|
||||
namespace zelda
|
||||
{
|
||||
namespace Sakura
|
||||
{
|
||||
class SpriteFile;
|
||||
} // Sakura
|
||||
|
||||
namespace io
|
||||
{
|
||||
|
||||
class SpriteFileReader : public zelda::io::BinaryReader
|
||||
{
|
||||
BINARYREADER_BASE;
|
||||
public:
|
||||
SpriteFileReader(Uint8* data, Uint64 length);
|
||||
SpriteFileReader(const std::string& filepath);
|
||||
|
||||
Sakura::SpriteFile* readFile();
|
||||
};
|
||||
} // io
|
||||
} // zelda
|
||||
|
||||
|
||||
#endif // SSPRITEFILEREADER_HPP
|
|
@ -1,29 +0,0 @@
|
|||
#ifndef SSPRITEFILEWRITER_HPP
|
||||
#define SSPRITEFILEWRITER_HPP
|
||||
|
||||
#include <BinaryWriter.hpp>
|
||||
|
||||
namespace zelda
|
||||
{
|
||||
namespace Sakura
|
||||
{
|
||||
class SpriteFile;
|
||||
} // Sakura
|
||||
|
||||
namespace io
|
||||
{
|
||||
|
||||
class SpriteFileWriter : public zelda::io::BinaryWriter
|
||||
{
|
||||
BINARYWRITER_BASE;
|
||||
public:
|
||||
SpriteFileWriter(Uint8* data, Uint64 length);
|
||||
|
||||
SpriteFileWriter(const std::string& filepath);
|
||||
|
||||
void writeFile(Sakura::SpriteFile* file);
|
||||
};
|
||||
|
||||
} // io
|
||||
} // zelda
|
||||
#endif // SSPRITEFILEWRITER_HPP
|
|
@ -1,261 +0,0 @@
|
|||
// This file is part of libZelda.
|
||||
//
|
||||
// libZelda 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,
|
||||
// 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 <http://www.gnu.org/licenses/>
|
||||
#ifndef __STREAM_HPP__
|
||||
#define __STREAM_HPP__
|
||||
|
||||
#include "Types.hpp"
|
||||
|
||||
namespace zelda
|
||||
{
|
||||
namespace io
|
||||
{
|
||||
|
||||
/*! \class Stream
|
||||
* \brief Stream is the main class all streams inherit from
|
||||
*
|
||||
* The Stream class contains the memory buffer, buffer size, and current position.<br />
|
||||
* It provides basic functionality such as reading or writing bits and bytes
|
||||
* The user has the ability to specify the Endianness of the Stream as well
|
||||
* And all inheriting classes are required to take that into account to be accepted
|
||||
* as a valid stream. <br />
|
||||
* <br />
|
||||
* Stream can also be used by itself though it's not advised as it's not feature filled.<br />
|
||||
* It's highly suggested to use of the more advanced Streams such as BinaryReader.
|
||||
*/
|
||||
class Stream
|
||||
{
|
||||
public:
|
||||
//! \brief Default buffer block size.
|
||||
static const Uint32 BLOCKSZ;
|
||||
|
||||
/*! \enum SeekOrigin
|
||||
* \brief Specifies how to seek in a stream.
|
||||
*/
|
||||
enum SeekOrigin
|
||||
{
|
||||
Beginning = 0, //!< Tells the Stream to seek from the Beginning of the buffer.
|
||||
Current, //!< Tells the Stream to seek from the Current position of the buffer.
|
||||
End //!< Tells the Stream to seek from the End of the buffer.
|
||||
};
|
||||
|
||||
/*! \brief The default constructor
|
||||
*/
|
||||
Stream();
|
||||
/*! \brief This constructor takes an existing buffer to read from.
|
||||
*
|
||||
* \param bytes The existing buffer
|
||||
* \param length The length of the existing buffer
|
||||
*/
|
||||
Stream(const Uint8* bytes, Uint64 length);
|
||||
/*! \brief This constructor creates a buffer from the given length.
|
||||
*
|
||||
* \param length The length of the existing buffer
|
||||
*/
|
||||
Stream(Int64 length);
|
||||
/*! \brief This constructor takes an existing Stream to read from.
|
||||
*
|
||||
* \param stream The stream to read data from
|
||||
*/
|
||||
Stream(Stream* stream);
|
||||
|
||||
/*! \brief The destructor cleans up memory and sets everything back
|
||||
* to the default settings.
|
||||
*/
|
||||
virtual ~Stream();
|
||||
|
||||
/*! \brief Writes a bit at the current position and advances the position by one bit.
|
||||
* \param val the value to write
|
||||
* \throw IOException
|
||||
*/
|
||||
virtual 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
|
||||
* \throw IOException
|
||||
*/
|
||||
virtual void writeUByte(Uint8 byte);
|
||||
/*! \brief Writes a byte at the current position and advances the position by one byte.
|
||||
* \param byte The value to write
|
||||
* \throw IOException
|
||||
*/
|
||||
virtual void writeByte(Int8 byte);
|
||||
|
||||
/*! \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
|
||||
* \throw IOException
|
||||
*/
|
||||
virtual void writeUBytes(Uint8* data, Int64 length);
|
||||
|
||||
/*! \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
|
||||
* \throw IOException
|
||||
*/
|
||||
virtual void writeBytes(Int8* data, Int64 length);
|
||||
|
||||
/*! \brief Reads a bit at the current position and advances the current position
|
||||
*
|
||||
* \return bool The value at the current position
|
||||
* \throw IOException
|
||||
*/
|
||||
virtual bool readBit();
|
||||
/*! \brief Reads a byte at the current position and advances the current position
|
||||
*
|
||||
* \return Int8 The value at the current position
|
||||
* \throw IOException
|
||||
*/
|
||||
virtual Int8 readByte();
|
||||
|
||||
/*! \brief Reads a byte at the current position and advances the current position
|
||||
*
|
||||
* \return Uint8 The value at the current position
|
||||
* \throw IOException
|
||||
*/
|
||||
virtual 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.
|
||||
* \throw IOException
|
||||
*/
|
||||
virtual Uint8* readUBytes(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.
|
||||
* \throw IOException
|
||||
*/
|
||||
virtual Int8* readBytes(Int64 length);
|
||||
|
||||
/*! \brief Sets the buffers position relative to the specified position.<br />
|
||||
* 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
|
||||
* \throw IOException
|
||||
*/
|
||||
void seek(Int64 position, SeekOrigin origin = Current);
|
||||
|
||||
/*! \brief Resizes the buffer to the given length.<br />
|
||||
* The new size must be greater than the current length to avoid loss of data.
|
||||
* \param newSize The amount to resize by.
|
||||
* \throw IOException
|
||||
*/
|
||||
void resize(Uint64 newSize);
|
||||
|
||||
/*! \brief Sets the buffer to the given one, deleting the current one.<br />
|
||||
* <b>BEWARE:</b> As this deletes the current buffer it WILL cause a loss of data
|
||||
* if that was not the intent.<br />
|
||||
* Once you pass the data to setData <b>DO NOT</b> 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.<br />
|
||||
* 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.<br />
|
||||
* However once you pass the data to setData <b>DO NOT</b> 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 Returns the length of the Stream.
|
||||
*
|
||||
* \return Int64 The length of the stream.
|
||||
*/
|
||||
Int64 length() const;
|
||||
|
||||
/*! \brief Returns the current position in the stream.
|
||||
*
|
||||
* \return Int64 The current position in the stream.
|
||||
*/
|
||||
Int64 position() const;
|
||||
|
||||
/*! \brief Returns whether or not the stream is at the end.
|
||||
*
|
||||
* \return bool True if at end; False otherwise.
|
||||
*/
|
||||
bool atEnd() const;
|
||||
|
||||
/*! \brief Sets whether the Stream resizes when the at the end of the buffer.
|
||||
*
|
||||
* \param val True for resizing; False for no resizing.
|
||||
*/
|
||||
void setAutoResizing(bool val);
|
||||
|
||||
/*! \brief Retuns whether or not the Stream currenty autoresizes.
|
||||
*
|
||||
* \return True for resizing; False otherwise.
|
||||
*/
|
||||
bool autoResizing() const;
|
||||
|
||||
|
||||
/*! \brief Retuns whether or not the Stream is open for reading.
|
||||
*
|
||||
* \return True if open for reading; False otherwise.
|
||||
*/
|
||||
virtual bool isOpenForReading() const;
|
||||
|
||||
/*! \brief Retuns whether or not the Stream is open for writing
|
||||
*
|
||||
* \return True if open for writing; False otherwise.
|
||||
*/
|
||||
virtual bool isOpenForWriting() const;
|
||||
|
||||
/*! \brief Sets the Endianss of the stream
|
||||
*
|
||||
* \param endian The Endianess to set \sa Endian
|
||||
*/
|
||||
void setEndianess(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;
|
||||
|
||||
protected:
|
||||
Uint32 m_bitPosition; //!< The current position in the current byte
|
||||
Uint64 m_position; //!< The current position in the Stream
|
||||
Uint64 m_length; //!< The length of the Stream
|
||||
Endian m_endian; //!< The Endianess of the Stream
|
||||
Uint8* m_data; //!< The Stream buffer
|
||||
bool m_autoResize; //!< Whether the stream is autoresizing
|
||||
};
|
||||
} // io
|
||||
} // zelda
|
||||
#endif // __STREAM_HPP__
|
|
@ -1,170 +0,0 @@
|
|||
// This file is part of libZelda.
|
||||
//
|
||||
// libZelda 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,
|
||||
// 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 <http://www.gnu.org/licenses/>
|
||||
#ifndef __TEXTSTREAM_HPP__
|
||||
#define __TEXTSTREAM_HPP__
|
||||
|
||||
#include "Stream.hpp"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace zelda
|
||||
{
|
||||
namespace io
|
||||
{
|
||||
// TODO (Phil#1#): Need to actually use AccessMode
|
||||
/*! \class TextStream
|
||||
* \brief A Class for reading or writing Text data.
|
||||
*
|
||||
* TextStream is a class for reading/writing TextData.<br />
|
||||
* It is currently incomplete, but usable, so use with caution.<br/>
|
||||
* Since it's incomplete it may not behave exactly as expected.
|
||||
*/
|
||||
class TextStream : public Stream
|
||||
{
|
||||
public:
|
||||
/*! \enum TextMode
|
||||
* \brief Specifies how the file is opened.
|
||||
*/
|
||||
enum TextMode
|
||||
{
|
||||
Open = 0x01, //!< The file is opened if it exists.
|
||||
Create = 0x02, //!< Create the file if it does not exist.
|
||||
OpenOrCreate = Open|Create, //!< If the file does not exist when opening the file it is created
|
||||
Truncate = 0x04, //!< All the data currently that is in the file is erased.
|
||||
Append = 0x08 //!< After opening the file the current line is set to the end of the buffer
|
||||
};
|
||||
|
||||
/*! \enum AccessMode
|
||||
* \brief Specifies how the Stream can be interacted with.
|
||||
*/
|
||||
enum AccessMode
|
||||
{
|
||||
ReadOnly, //!< The Stream can only be read from.
|
||||
WriteOnly,//!< The Stream can only be written to.
|
||||
ReadWrite //!< The Stream can be read from or written to.
|
||||
};
|
||||
|
||||
TextStream();
|
||||
/*! \brief This constructor opens the file and loads all the lines. */
|
||||
TextStream(const std::string& filename, Uint32 fileMode = Open, AccessMode accessMode = ReadWrite);
|
||||
|
||||
/*! \brief Creates a new buffer and saves all lines to the specified file.
|
||||
* \param filename The file, including path to save to.
|
||||
*/
|
||||
void save(const std::string& filename = "");
|
||||
|
||||
/*! \brief Reads the line at the current address.
|
||||
*
|
||||
* \return std::string The line read.
|
||||
*/
|
||||
std::string readLine();
|
||||
|
||||
/*! \brief Writes a line to the buffer
|
||||
*
|
||||
* \param str The string to write.
|
||||
*/
|
||||
void writeLine(const std::string& str);
|
||||
|
||||
/*! \brief Reads a given amount of lines relative to the current address
|
||||
*
|
||||
* \param numLines The amount of lines to read.
|
||||
* \return std::vector<std::string> The lines read.
|
||||
*/
|
||||
std::vector<std::string> readLines(Uint32 numLines);
|
||||
|
||||
/*! \brief Reads a given list of lines relative to the current address
|
||||
*
|
||||
* \param lines The lines to write.
|
||||
*/
|
||||
void writeLines(std::vector<std::string> lines);
|
||||
|
||||
/*! \brief Reads all the lines in the current buffer.
|
||||
*
|
||||
* \return The lines read.
|
||||
*/
|
||||
std::vector<std::string> readAllLines();
|
||||
|
||||
/*! \brief Reads a line at the given address.
|
||||
*
|
||||
* \param line The line to read.
|
||||
* \return std::string The lines read.
|
||||
*/
|
||||
std::string readLineAt(Uint32 line);
|
||||
|
||||
/*! \brief Writes a line at the given address.
|
||||
*
|
||||
* \param line The address to write to.
|
||||
* \param str The string to write.
|
||||
*/
|
||||
void writeLineAt(Uint32 line, const std::string& str);
|
||||
|
||||
/*! \brief Sets the current line in the Stream.
|
||||
*
|
||||
* \param line The line to seek to.
|
||||
*/
|
||||
void setCurrentLine(Uint32 line);
|
||||
|
||||
/*! \brief Returns the current line in the stream.
|
||||
*
|
||||
* \return Uint32 The current line in the stream.
|
||||
*/
|
||||
Uint32 currentLine() const;
|
||||
|
||||
/*! \brief Sets the AccessMode of the Stream.
|
||||
*
|
||||
* \param mode The mode to set.
|
||||
*/
|
||||
void setAccessMode(AccessMode mode);
|
||||
|
||||
/*! \brief Returns the AccessMode of the Stream.
|
||||
*
|
||||
* \return AccessModeThe mode to set.
|
||||
*/
|
||||
AccessMode accessMode() const;
|
||||
|
||||
/*! \brief Sets the Textmode of the Stream.
|
||||
*
|
||||
* \param mode The mode to set.
|
||||
*/
|
||||
void setTextMode(TextMode mode);
|
||||
|
||||
/*! \brief Returns the TextMode of the Stream.
|
||||
*
|
||||
* \return TextMode The mode to set.
|
||||
*/
|
||||
Uint32 textMode() const;
|
||||
|
||||
|
||||
/*! \brief Empties the stream.
|
||||
*
|
||||
*/
|
||||
void truncate();
|
||||
|
||||
bool isOpenForReading() const;
|
||||
bool isOpenForWriting() const;
|
||||
private:
|
||||
void loadLines();
|
||||
std::string m_filename;
|
||||
Uint32 m_textmode;
|
||||
AccessMode m_accessmode;
|
||||
|
||||
std::vector<std::string> m_lines;
|
||||
Uint32 m_currentLine;
|
||||
Uint32 m_startLength;
|
||||
};
|
||||
} // io
|
||||
} // zelda
|
||||
#endif
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef __AES_H_
|
||||
#define __AES_H_
|
||||
|
||||
#include <Types.hpp>
|
||||
#include "Athena/Types.hpp"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
|
||||
#ifndef __DOXYGEN_IGNORE__
|
||||
|
||||
#include <Types.hpp>
|
||||
|
||||
#include "Athena/Types.hpp"
|
||||
int bn_compare(Uint8 *a, Uint8 *b, Uint32 n);
|
||||
void bn_sub_modulus(Uint8 *a, Uint8 *N, Uint32 n);
|
||||
void bn_add(Uint8 *d, Uint8 *a, Uint8 *b, Uint8 *N, Uint32 n);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#ifndef EC_H
|
||||
#define EC_H
|
||||
#include <Types.hpp>
|
||||
#include "Athena/Types.hpp"
|
||||
|
||||
bool check_ec ( Uint8 *ng, Uint8 *ap, Uint8 *sig, Uint8 *sig_hash );
|
||||
void make_ec_cert ( Uint8 *cert, Uint8 *sig, char *signer, char *name, Uint8 *priv, Uint32 key_id );
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef _LZO_H
|
||||
#define LZO_H
|
||||
|
||||
#include "Types.hpp"
|
||||
#include "Athena/Types.hpp"
|
||||
|
||||
#define LZO_INPUT_DEPLETED 1
|
||||
#define LZO_OUTPUT_FULL 2
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef _SHA1_H_
|
||||
#define _SHA1_H_
|
||||
|
||||
#include <Types.hpp>
|
||||
#include "Athena/Types.hpp"
|
||||
|
||||
#ifndef __DOXYGEN_IGNORE__
|
||||
#ifdef __cplusplus
|
||||
|
|
158
libzelda.cbp
158
libzelda.cbp
|
@ -1,158 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="libzelda" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Debug Win32">
|
||||
<Option platforms="Windows;" />
|
||||
<Option output="lib/Win32/zelda-d" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="" />
|
||||
<Option object_output="obj/Debug/" />
|
||||
<Option type="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Compiler>
|
||||
<Add option="-g" />
|
||||
</Compiler>
|
||||
</Target>
|
||||
<Target title="Release Win32">
|
||||
<Option output="lib/Win32/zelda" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="" />
|
||||
<Option object_output="obj/Release/" />
|
||||
<Option type="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Compiler>
|
||||
<Add option="-O2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Debug Wii">
|
||||
<Option output="lib/Wii/zelda-d" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="" />
|
||||
<Option type="2" />
|
||||
<Option compiler="devkitppc_wii" />
|
||||
<Option createDefFile="1" />
|
||||
</Target>
|
||||
<Target title="Release Wii">
|
||||
<Option output="lib/Wii/zelda" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="" />
|
||||
<Option type="2" />
|
||||
<Option compiler="devkitppc_wii" />
|
||||
<Option createDefFile="1" />
|
||||
</Target>
|
||||
<Target title="Debug Linux">
|
||||
<Option platforms="Unix;" />
|
||||
<Option output="lib/Linux/zelda-d" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="" />
|
||||
<Option type="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
</Target>
|
||||
<Target title="Release Linux">
|
||||
<Option platforms="Unix;" />
|
||||
<Option output="lib/Linux/zelda" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="" />
|
||||
<Option type="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-std=c++11" />
|
||||
<Add option="-Wall" />
|
||||
<Add directory="include" />
|
||||
</Compiler>
|
||||
<Unit filename="include/ALTTPEnums.hpp" />
|
||||
<Unit filename="include/ALTTPFile.hpp" />
|
||||
<Unit filename="include/ALTTPFileReader.hpp" />
|
||||
<Unit filename="include/ALTTPFileWriter.hpp" />
|
||||
<Unit filename="include/ALTTPQuest.hpp" />
|
||||
<Unit filename="include/ALTTPStructs.hpp" />
|
||||
<Unit filename="include/BinaryReader.hpp" />
|
||||
<Unit filename="include/BinaryWriter.hpp" />
|
||||
<Unit filename="include/Checksums.hpp" />
|
||||
<Unit filename="include/Compression.hpp" />
|
||||
<Unit filename="include/Exception.hpp" />
|
||||
<Unit filename="include/FileNotFoundException.hpp" />
|
||||
<Unit filename="include/IOException.hpp" />
|
||||
<Unit filename="include/InvalidOperationException.hpp" />
|
||||
<Unit filename="include/MCFile.hpp" />
|
||||
<Unit filename="include/MCFileReader.hpp" />
|
||||
<Unit filename="include/MCFileWriter.hpp" />
|
||||
<Unit filename="include/Mainpage.hpp" />
|
||||
<Unit filename="include/SSFile.hpp" />
|
||||
<Unit filename="include/SSFileReader.hpp" />
|
||||
<Unit filename="include/SSFileWriter.hpp" />
|
||||
<Unit filename="include/SSQuest.hpp" />
|
||||
<Unit filename="include/Stream.hpp" />
|
||||
<Unit filename="include/TextStream.hpp" />
|
||||
<Unit filename="include/Types.hpp" />
|
||||
<Unit filename="include/WiiBanner.hpp" />
|
||||
<Unit filename="include/WiiFile.hpp" />
|
||||
<Unit filename="include/WiiImage.hpp" />
|
||||
<Unit filename="include/WiiSave.hpp" />
|
||||
<Unit filename="include/WiiSaveReader.hpp" />
|
||||
<Unit filename="include/WiiSaveWriter.hpp" />
|
||||
<Unit filename="include/ZQuestFile.hpp" />
|
||||
<Unit filename="include/ZQuestFileReader.hpp" />
|
||||
<Unit filename="include/ZQuestFileWriter.hpp" />
|
||||
<Unit filename="include/aes.h" />
|
||||
<Unit filename="include/bn.h" />
|
||||
<Unit filename="include/ec.h" />
|
||||
<Unit filename="include/md5.h" />
|
||||
<Unit filename="include/sha1.h" />
|
||||
<Unit filename="include/utf8.h" />
|
||||
<Unit filename="include/utf8/checked.h" />
|
||||
<Unit filename="include/utf8/core.h" />
|
||||
<Unit filename="include/utf8/unchecked.h" />
|
||||
<Unit filename="include/utility.hpp" />
|
||||
<Unit filename="src/ALTTPFile.cpp" />
|
||||
<Unit filename="src/ALTTPFileReader.cpp" />
|
||||
<Unit filename="src/ALTTPFileWriter.cpp" />
|
||||
<Unit filename="src/ALTTPQuest.cpp" />
|
||||
<Unit filename="src/BinaryReader.cpp" />
|
||||
<Unit filename="src/BinaryWriter.cpp" />
|
||||
<Unit filename="src/Checksums.cpp" />
|
||||
<Unit filename="src/Compression.cpp" />
|
||||
<Unit filename="src/MCFile.cpp" />
|
||||
<Unit filename="src/MCFileReader.cpp" />
|
||||
<Unit filename="src/MCFileWriter.cpp" />
|
||||
<Unit filename="src/SSFile.cpp" />
|
||||
<Unit filename="src/SSFileReader.cpp" />
|
||||
<Unit filename="src/SSFileWriter.cpp" />
|
||||
<Unit filename="src/SSQuest.cpp" />
|
||||
<Unit filename="src/Stream.cpp" />
|
||||
<Unit filename="src/TextStream.cpp" />
|
||||
<Unit filename="src/WiiBanner.cpp" />
|
||||
<Unit filename="src/WiiFile.cpp" />
|
||||
<Unit filename="src/WiiImage.cpp" />
|
||||
<Unit filename="src/WiiSave.cpp" />
|
||||
<Unit filename="src/WiiSaveReader.cpp" />
|
||||
<Unit filename="src/WiiSaveWriter.cpp" />
|
||||
<Unit filename="src/ZQuestFile.cpp" />
|
||||
<Unit filename="src/ZQuestFileReader.cpp" />
|
||||
<Unit filename="src/ZQuestFileWriter.cpp" />
|
||||
<Unit filename="src/aes.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/bn.cpp" />
|
||||
<Unit filename="src/ec.cpp" />
|
||||
<Unit filename="src/md5.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/sha1.cpp" />
|
||||
<Unit filename="src/utility.cpp" />
|
||||
<Extensions>
|
||||
<code_completion />
|
||||
<envvars />
|
||||
<debugger />
|
||||
<lib_finder disable_auto="1" />
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
1869
libzelda.conf
1869
libzelda.conf
File diff suppressed because it is too large
Load Diff
|
@ -1,14 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_layout_file>
|
||||
<ActiveTarget name="Release Linux" />
|
||||
<File name="include/BinaryReader.hpp" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="0" topLine="115" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="include/BinaryWriter.hpp" open="1" top="1" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="4709" topLine="96" />
|
||||
</Cursor>
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
BIN
libzelda.png
BIN
libzelda.png
Binary file not shown.
Before Width: | Height: | Size: 30 KiB |
100
libzelda.pri
100
libzelda.pri
|
@ -1,100 +0,0 @@
|
|||
INCLUDEPATH += $$PWD/include
|
||||
|
||||
QMAKE_CXXFLAGS = -std=c++0x
|
||||
|
||||
unix:LIBS += -lz
|
||||
win32:LIBS += -lzlib
|
||||
HEADERS += \
|
||||
$$PWD/include/utility.hpp \
|
||||
$$PWD/include/utf8.h \
|
||||
$$PWD/include/utf8/unchecked.h \
|
||||
$$PWD/include/utf8/core.h \
|
||||
$$PWD/include/utf8/checked.h \
|
||||
$$PWD/include/Types.hpp \
|
||||
$$PWD/include/TextStream.hpp \
|
||||
$$PWD/include/Stream.hpp \
|
||||
$$PWD/include/Mainpage.hpp \
|
||||
$$PWD/include/InvalidOperationException.hpp \
|
||||
$$PWD/include/IOException.hpp \
|
||||
$$PWD/include/FileNotFoundException.hpp \
|
||||
$$PWD/include/Exception.hpp \
|
||||
$$PWD/include/BinaryWriter.hpp \
|
||||
$$PWD/include/BinaryReader.hpp \
|
||||
$$PWD/include/WiiBanner.hpp \
|
||||
$$PWD/include/WiiFile.hpp \
|
||||
$$PWD/include/WiiSave.hpp \
|
||||
$$PWD/include/WiiSaveReader.hpp \
|
||||
$$PWD/include/WiiSaveWriter.hpp \
|
||||
$$PWD/include/aes.h \
|
||||
$$PWD/include/bn.h \
|
||||
$$PWD/include/ec.h \
|
||||
$$PWD/include/md5.h \
|
||||
$$PWD/include/sha1.h \
|
||||
$$PWD/include/ALTTPStructs.hpp \
|
||||
$$PWD/include/ALTTPQuest.hpp \
|
||||
$$PWD/include/ALTTPFileWriter.hpp \
|
||||
$$PWD/include/ALTTPFileReader.hpp \
|
||||
$$PWD/include/ALTTPFile.hpp \
|
||||
$$PWD/include/ALTTPEnums.hpp \
|
||||
$$PWD/include/MCFileReader.hpp \
|
||||
$$PWD/include/MCFile.hpp \
|
||||
$$PWD/include/MCFileWriter.hpp \
|
||||
$$PWD/include/ZQuestFileWriter.hpp \
|
||||
$$PWD/include/ZQuestFileReader.hpp \
|
||||
$$PWD/include/Compression.hpp \
|
||||
$$PWD/include/lzo.h \
|
||||
$$PWD/include/WiiImage.hpp \
|
||||
$$PWD/include/ZQuestFile.hpp \
|
||||
$$PWD/include/Checksums.hpp \
|
||||
$$PWD/include/SkywardSwordFile.hpp \
|
||||
$$PWD/include/SkywardSwordFileReader.hpp \
|
||||
$$PWD/include/SkywardSwordFileWriter.hpp \
|
||||
$$PWD/include/SkywardSwordQuest.hpp \
|
||||
$$PWD/include/Sprite.hpp \
|
||||
$$PWD/include/SpriteFile.hpp \
|
||||
$$PWD/include/SpriteFileReader.hpp \
|
||||
$$PWD/include/SpriteFileWriter.hpp \
|
||||
$$PWD/include/SpriteFrame.hpp \
|
||||
$$PWD/include/SpritePart.hpp \
|
||||
$$PWD/include/InvalidDataException.hpp
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/src/utility.cpp \
|
||||
$$PWD/src/TextStream.cpp \
|
||||
$$PWD/src/Stream.cpp \
|
||||
$$PWD/src/BinaryWriter.cpp \
|
||||
$$PWD/src/BinaryReader.cpp \
|
||||
$$PWD/src/WiiBanner.cpp \
|
||||
$$PWD/src/WiiFile.cpp \
|
||||
$$PWD/src/WiiSave.cpp \
|
||||
$$PWD/src/WiiSaveReader.cpp \
|
||||
$$PWD/src/WiiSaveWriter.cpp \
|
||||
$$PWD/src/aes.c \
|
||||
$$PWD/src/bn.cpp \
|
||||
$$PWD/src/ec.cpp \
|
||||
$$PWD/src/md5.cpp \
|
||||
$$PWD/src/sha1.cpp \
|
||||
$$PWD/src/ALTTPQuest.cpp \
|
||||
$$PWD/src/ALTTPFileWriter.cpp \
|
||||
$$PWD/src/ALTTPFileReader.cpp \
|
||||
$$PWD/src/ALTTPFile.cpp \
|
||||
$$PWD/src/MCFileReader.cpp \
|
||||
$$PWD/src/MCFile.cpp \
|
||||
$$PWD/src/MCFileWriter.cpp \
|
||||
$$PWD/src/ZQuestFileWriter.cpp \
|
||||
$$PWD/src/ZQuestFileReader.cpp \
|
||||
$$PWD/src/Compression.cpp \
|
||||
$$PWD/src/lzo.c \
|
||||
$$PWD/src/WiiImage.cpp \
|
||||
$$PWD/src/ZQuestFile.cpp \
|
||||
$$PWD/src/Checksums.cpp \
|
||||
$$PWD/src/SkywardSwordFile.cpp \
|
||||
$$PWD/src/SkywardSwordFileReader.cpp \
|
||||
$$PWD/src/SkywardSwordFileWriter.cpp \
|
||||
$$PWD/src/SkywardSwordQuest.cpp \
|
||||
$$PWD/src/Sprite.cpp \
|
||||
$$PWD/src/SpriteFile.cpp \
|
||||
$$PWD/src/SpriteFileReader.cpp \
|
||||
$$PWD/src/SpriteFileWriter.cpp \
|
||||
$$PWD/src/SpriteFrame.cpp \
|
||||
$$PWD/src/SpritePart.cpp
|
125
libzelda.pro
125
libzelda.pro
|
@ -1,125 +0,0 @@
|
|||
CONFIG += staticlib
|
||||
TEMPLATE= lib
|
||||
DESTDIR = ./lib
|
||||
|
||||
# Uncomment this if you wish to use Qt with libZelda
|
||||
#DEFINES += LIBZELDA_USE_QT
|
||||
|
||||
contains(DEFINES, LIBZELDA_USE_QT){
|
||||
QT += core
|
||||
}
|
||||
|
||||
CONFIG(debug, debug|release){
|
||||
DEFINES += DEBUG
|
||||
TARGET=zelda-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=zelda
|
||||
# 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++0x
|
||||
INCLUDEPATH += include
|
||||
|
||||
HEADERS += \
|
||||
include/utility.hpp \
|
||||
include/utf8.h \
|
||||
include/utf8/unchecked.h \
|
||||
include/utf8/core.h \
|
||||
include/utf8/checked.h \
|
||||
include/Types.hpp \
|
||||
include/TextStream.hpp \
|
||||
include/Stream.hpp \
|
||||
include/Mainpage.hpp \
|
||||
include/InvalidOperationException.hpp \
|
||||
include/IOException.hpp \
|
||||
include/FileNotFoundException.hpp \
|
||||
include/Exception.hpp \
|
||||
include/BinaryWriter.hpp \
|
||||
include/BinaryReader.hpp \
|
||||
include/WiiBanner.hpp \
|
||||
include/WiiFile.hpp \
|
||||
include/WiiSave.hpp \
|
||||
include/WiiSaveReader.hpp \
|
||||
include/WiiSaveWriter.hpp \
|
||||
include/aes.h \
|
||||
include/bn.h \
|
||||
include/ec.h \
|
||||
include/md5.h \
|
||||
include/sha1.h \
|
||||
include/ALTTPStructs.hpp \
|
||||
include/ALTTPQuest.hpp \
|
||||
include/ALTTPFileWriter.hpp \
|
||||
include/ALTTPFileReader.hpp \
|
||||
include/ALTTPFile.hpp \
|
||||
include/ALTTPEnums.hpp \
|
||||
include/MCFileReader.hpp \
|
||||
include/MCFile.hpp \
|
||||
include/MCFileWriter.hpp \
|
||||
include/ZQuestFileWriter.hpp \
|
||||
include/ZQuestFileReader.hpp \
|
||||
include/Compression.hpp \
|
||||
include/lzo.h \
|
||||
include/WiiImage.hpp \
|
||||
include/ZQuestFile.hpp \
|
||||
include/Checksums.hpp \
|
||||
include/SkywardSwordFile.hpp \
|
||||
include/SkywardSwordFileReader.hpp \
|
||||
include/SkywardSwordFileWriter.hpp \
|
||||
include/SkywardSwordQuest.hpp \
|
||||
include/Sprite.hpp \
|
||||
include/SpriteFile.hpp \
|
||||
include/SpriteFileReader.hpp \
|
||||
include/SpriteFileWriter.hpp \
|
||||
include/SpriteFrame.hpp \
|
||||
include/SpritePart.hpp
|
||||
|
||||
SOURCES += \
|
||||
src/utility.cpp \
|
||||
src/TextStream.cpp \
|
||||
src/Stream.cpp \
|
||||
src/BinaryWriter.cpp \
|
||||
src/BinaryReader.cpp \
|
||||
src/WiiBanner.cpp \
|
||||
src/WiiFile.cpp \
|
||||
src/WiiSave.cpp \
|
||||
src/WiiSaveReader.cpp \
|
||||
src/WiiSaveWriter.cpp \
|
||||
src/aes.c \
|
||||
src/bn.cpp \
|
||||
src/ec.cpp \
|
||||
src/md5.cpp \
|
||||
src/sha1.cpp \
|
||||
src/ALTTPQuest.cpp \
|
||||
src/ALTTPFileWriter.cpp \
|
||||
src/ALTTPFileReader.cpp \
|
||||
src/ALTTPFile.cpp \
|
||||
src/MCFileReader.cpp \
|
||||
src/MCFile.cpp \
|
||||
src/MCFileWriter.cpp \
|
||||
src/ZQuestFileWriter.cpp \
|
||||
src/ZQuestFileReader.cpp \
|
||||
src/Compression.cpp \
|
||||
src/lzo.c \
|
||||
src/WiiImage.cpp \
|
||||
src/ZQuestFile.cpp \
|
||||
src/Checksums.cpp \
|
||||
src/SkywardSwordFile.cpp \
|
||||
src/SkywardSwordFileReader.cpp \
|
||||
src/SkywardSwordFileWriter.cpp \
|
||||
src/SkywardSwordQuest.cpp \
|
||||
src/Sprite.cpp \
|
||||
src/SpriteFile.cpp \
|
||||
src/SpriteFileReader.cpp \
|
||||
src/SpriteFileWriter.cpp \
|
||||
src/SpriteFrame.cpp \
|
||||
src/SpritePart.cpp
|
222
libzelda.vcproj
222
libzelda.vcproj
|
@ -1,222 +0,0 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="libzelda"
|
||||
ProjectGUID="{3E0B05A1-DE7E-4EAE-86DF-2FB507E7F1AD}"
|
||||
RootNamespace="libzelda"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="include"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="lib\Win32\zelda-d.lib"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
AdditionalIncludeDirectories="include"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
OutputFile="lib\Win32\zelda.lib"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\BinaryReader.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\BinaryWriter.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\FileStream.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\Stream.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\utility.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\utility.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\include\BinaryReader.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\BinaryWriter.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Exception.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\FileNotFoundException.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\FileStream.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\IOException.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Stream.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\Types.hpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
147
libzelda_wii.cbp
147
libzelda_wii.cbp
|
@ -1,147 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="libzelda_wii" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
<Target title="Debug">
|
||||
<Option output="lib/zeldad" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="" />
|
||||
<Option object_output="obj/Debug/" />
|
||||
<Option type="2" />
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Compiler>
|
||||
<Add option="-g" />
|
||||
</Compiler>
|
||||
</Target>
|
||||
<Target title="Release">
|
||||
<Option output="lib/libzelda" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/Release/" />
|
||||
<Option type="1" />
|
||||
<Option compiler="gcc" />
|
||||
<Compiler>
|
||||
<Add option="-O2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
</Linker>
|
||||
</Target>
|
||||
<Target title="Debug Wii">
|
||||
<Option output="lib/zeldawiid" prefix_auto="1" extension_auto="1" />
|
||||
<Option working_dir="" />
|
||||
<Option object_output="obj/Debug/" />
|
||||
<Option type="2" />
|
||||
<Option compiler="wii_compiler" />
|
||||
<Option createDefFile="1" />
|
||||
<Compiler>
|
||||
<Add option="-g" />
|
||||
</Compiler>
|
||||
</Target>
|
||||
<Target title="Release Wii">
|
||||
<Option output="lib/libzeldawii" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/Release/" />
|
||||
<Option type="1" />
|
||||
<Option compiler="wii_compiler" />
|
||||
<Compiler>
|
||||
<Add option="-O2" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
</Linker>
|
||||
</Target>
|
||||
</Build>
|
||||
<Compiler>
|
||||
<Add option="-std=c++0x" />
|
||||
<Add option="-Wall" />
|
||||
<Add directory="include" />
|
||||
</Compiler>
|
||||
<Unit filename="include/ALTTPEnums.hpp" />
|
||||
<Unit filename="include/ALTTPFile.hpp" />
|
||||
<Unit filename="include/ALTTPFileReader.hpp" />
|
||||
<Unit filename="include/ALTTPFileWriter.hpp" />
|
||||
<Unit filename="include/ALTTPQuest.hpp" />
|
||||
<Unit filename="include/ALTTPStructs.hpp" />
|
||||
<Unit filename="include/BinaryReader.hpp" />
|
||||
<Unit filename="include/BinaryWriter.hpp" />
|
||||
<Unit filename="include/Compression.hpp" />
|
||||
<Unit filename="include/Exception.hpp" />
|
||||
<Unit filename="include/FileNotFoundException.hpp" />
|
||||
<Unit filename="include/IOException.hpp" />
|
||||
<Unit filename="include/InvalidOperationException.hpp" />
|
||||
<Unit filename="include/MCFile.hpp" />
|
||||
<Unit filename="include/MCFileReader.hpp" />
|
||||
<Unit filename="include/MCFileWriter.hpp" />
|
||||
<Unit filename="include/Mainpage.hpp" />
|
||||
<Unit filename="include/SSFile.hpp" />
|
||||
<Unit filename="include/SSFileReader.hpp" />
|
||||
<Unit filename="include/SSFileWriter.hpp" />
|
||||
<Unit filename="include/SSQuest.hpp" />
|
||||
<Unit filename="include/Stream.hpp" />
|
||||
<Unit filename="include/TextStream.hpp" />
|
||||
<Unit filename="include/Types.hpp" />
|
||||
<Unit filename="include/WiiBanner.hpp" />
|
||||
<Unit filename="include/WiiFile.hpp" />
|
||||
<Unit filename="include/WiiImage.hpp" />
|
||||
<Unit filename="include/WiiSave.hpp" />
|
||||
<Unit filename="include/WiiSaveReader.hpp" />
|
||||
<Unit filename="include/WiiSaveWriter.hpp" />
|
||||
<Unit filename="include/ZQuestFile.hpp" />
|
||||
<Unit filename="include/ZQuestFileReader.hpp" />
|
||||
<Unit filename="include/ZQuestFileWriter.hpp" />
|
||||
<Unit filename="include/aes.h" />
|
||||
<Unit filename="include/bn.h" />
|
||||
<Unit filename="include/ec.h" />
|
||||
<Unit filename="include/md5.h" />
|
||||
<Unit filename="include/sha1.h" />
|
||||
<Unit filename="include/utf8.h" />
|
||||
<Unit filename="include/utf8/checked.h" />
|
||||
<Unit filename="include/utf8/core.h" />
|
||||
<Unit filename="include/utf8/unchecked.h" />
|
||||
<Unit filename="include/utility.hpp" />
|
||||
<Unit filename="src/ALTTPFile.cpp" />
|
||||
<Unit filename="src/ALTTPFileReader.cpp" />
|
||||
<Unit filename="src/ALTTPFileWriter.cpp" />
|
||||
<Unit filename="src/ALTTPQuest.cpp" />
|
||||
<Unit filename="src/BinaryReader.cpp" />
|
||||
<Unit filename="src/BinaryWriter.cpp" />
|
||||
<Unit filename="src/Checksums.cpp" />
|
||||
<Unit filename="src/Compression.cpp" />
|
||||
<Unit filename="src/MCFile.cpp" />
|
||||
<Unit filename="src/MCFileReader.cpp" />
|
||||
<Unit filename="src/MCFileWriter.cpp" />
|
||||
<Unit filename="src/SSFile.cpp" />
|
||||
<Unit filename="src/SSFileReader.cpp" />
|
||||
<Unit filename="src/SSFileWriter.cpp" />
|
||||
<Unit filename="src/SSQuest.cpp" />
|
||||
<Unit filename="src/Stream.cpp" />
|
||||
<Unit filename="src/TextStream.cpp" />
|
||||
<Unit filename="src/WiiBanner.cpp" />
|
||||
<Unit filename="src/WiiFile.cpp" />
|
||||
<Unit filename="src/WiiImage.cpp" />
|
||||
<Unit filename="src/WiiSave.cpp" />
|
||||
<Unit filename="src/WiiSaveReader.cpp" />
|
||||
<Unit filename="src/WiiSaveWriter.cpp" />
|
||||
<Unit filename="src/ZQuestFile.cpp" />
|
||||
<Unit filename="src/ZQuestFileReader.cpp" />
|
||||
<Unit filename="src/ZQuestFileWriter.cpp" />
|
||||
<Unit filename="src/aes.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/bn.cpp" />
|
||||
<Unit filename="src/ec.cpp" />
|
||||
<Unit filename="src/md5.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/sha1.cpp" />
|
||||
<Unit filename="src/utility.cpp" />
|
||||
<Extensions>
|
||||
<envvars />
|
||||
<code_completion />
|
||||
<lib_finder disable_auto="1" />
|
||||
<debugger />
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
674
license.txt
674
license.txt
|
@ -1,674 +0,0 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program 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.
|
||||
|
||||
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#include "ALTTPFile.hpp"
|
||||
#include "ALTTPQuest.hpp"
|
||||
#include "Athena/ALTTPFile.hpp"
|
||||
#include "Athena/ALTTPQuest.hpp"
|
||||
|
||||
#include "InvalidOperationException.hpp"
|
||||
#include "Athena/InvalidOperationException.hpp"
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
ALTTPFile::ALTTPFile()
|
||||
{}
|
||||
|
@ -32,7 +32,7 @@ ALTTPFile::ALTTPFile(std::vector<ALTTPQuest*> quests, std::vector<ALTTPQuest*> b
|
|||
void ALTTPFile::setQuest(Uint32 id, ALTTPQuest* val)
|
||||
{
|
||||
if (id > m_quests.size())
|
||||
throw error::InvalidOperationException("ALTTPFile::setQuest -> index out of range");
|
||||
THROW_INVALID_OPERATION_EXCEPTION("index out of range");
|
||||
|
||||
m_quests[id] = val;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ std::vector<ALTTPQuest*> ALTTPFile::questList() const
|
|||
ALTTPQuest* ALTTPFile::quest(Uint32 id) const
|
||||
{
|
||||
if (id > m_quests.size())
|
||||
throw error::InvalidOperationException("ALTTPFile::setQuest -> index out of range");
|
||||
THROW_INVALID_OPERATION_EXCEPTION("index out of range");
|
||||
|
||||
return m_quests[id];
|
||||
}
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#include "ALTTPFileReader.hpp"
|
||||
#include "ALTTPFile.hpp"
|
||||
#include "ALTTPQuest.hpp"
|
||||
#include "Athena/ALTTPFileReader.hpp"
|
||||
#include "Athena/ALTTPFile.hpp"
|
||||
#include "Athena/ALTTPQuest.hpp"
|
||||
#include <iostream>
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
namespace io
|
||||
{
|
||||
|
@ -64,12 +64,12 @@ ALTTPFile* ALTTPFileReader::readFile()
|
|||
quest->setOverworldEvents(owEvents);
|
||||
|
||||
quest->setInventory((ALTTPInventory*)base::readBytes(sizeof(ALTTPInventory)));
|
||||
quest->setRupeeMax(base::readUInt16());
|
||||
quest->setRupeeCurrent(base::readUInt16());
|
||||
quest->setRupeeMax(base::readUint16());
|
||||
quest->setRupeeCurrent(base::readUint16());
|
||||
quest->setCompasses(readDungeonFlags());
|
||||
quest->setBigKeys(readDungeonFlags());
|
||||
quest->setDungeonMaps(readDungeonFlags());
|
||||
quest->setWishingPond(base::readUInt16());
|
||||
quest->setWishingPond(base::readUint16());
|
||||
quest->setHealthMax(base::readByte());
|
||||
quest->setHealth(base::readByte());
|
||||
quest->setMagicPower(base::readByte());
|
||||
|
@ -142,26 +142,26 @@ ALTTPFile* ALTTPFileReader::readFile()
|
|||
j = 6;
|
||||
while((j--) > 0)
|
||||
{
|
||||
playerName.push_back(base::readUInt16());
|
||||
playerName.push_back(base::readUint16());
|
||||
}
|
||||
|
||||
quest->setPlayerName(playerName);
|
||||
quest->setValid((base::readUInt16() == 0x55AA));
|
||||
quest->setValid((base::readUint16() == 0x55AA));
|
||||
|
||||
j = 0x0D;
|
||||
while((j--) > 0)
|
||||
{
|
||||
dungeonDeaths.push_back(base::readUInt16());
|
||||
dungeonDeaths.push_back(base::readUint16());
|
||||
}
|
||||
quest->setDungeonDeathTotals(dungeonDeaths);
|
||||
|
||||
quest->setUnknown2(base::readUInt16());
|
||||
quest->setDeathSaveCount(base::readUInt16());
|
||||
quest->setUnknown2(base::readUint16());
|
||||
quest->setDeathSaveCount(base::readUint16());
|
||||
quest->setPostGameDeathCounter(base::readInt16());
|
||||
|
||||
base::seek(0xF7);
|
||||
|
||||
quest->setChecksum(base::readUInt16());
|
||||
quest->setChecksum(base::readUint16());
|
||||
|
||||
if (i < 3)
|
||||
quests.push_back(quest);
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#include "ALTTPFileWriter.hpp"
|
||||
#include "ALTTPFile.hpp"
|
||||
#include "ALTTPQuest.hpp"
|
||||
#include "Athena/ALTTPFileWriter.hpp"
|
||||
#include "Athena/ALTTPFile.hpp"
|
||||
#include "Athena/ALTTPQuest.hpp"
|
||||
#include <iostream>
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
|
||||
namespace io
|
||||
|
@ -55,12 +55,12 @@ void ALTTPFileWriter::writeFile(ALTTPFile* file)
|
|||
}
|
||||
|
||||
base::writeBytes((Int8*)quest->inventory(), sizeof(ALTTPInventory));
|
||||
base::writeUInt16(quest->rupeeMax());
|
||||
base::writeUInt16(quest->rupeeCurrent());
|
||||
base::writeUint16(quest->rupeeMax());
|
||||
base::writeUint16(quest->rupeeCurrent());
|
||||
writeDungeonItems(quest->compasses());
|
||||
writeDungeonItems(quest->bigKeys());
|
||||
writeDungeonItems(quest->dungeonMaps());
|
||||
base::writeUInt16(quest->wishingPond());
|
||||
base::writeUint16(quest->wishingPond());
|
||||
base::writeByte(quest->healthMax());
|
||||
base::writeByte(quest->health());
|
||||
base::writeByte(quest->magicPower());
|
||||
|
@ -116,20 +116,20 @@ void ALTTPFileWriter::writeFile(ALTTPFile* file)
|
|||
base::writeByte(quest->unknown1(j));
|
||||
|
||||
for (int j = 0; j < 6; j++)
|
||||
base::writeUInt16(quest->playerName()[j]);
|
||||
base::writeUint16(quest->playerName()[j]);
|
||||
|
||||
base::writeUInt16((quest->valid() == true ? 0x55AA : 0));
|
||||
base::writeUint16((quest->valid() == true ? 0x55AA : 0));
|
||||
|
||||
for (int j = 0; j < 0x0D; j++)
|
||||
base::writeUInt16(quest->dungeonDeathTotal(j));
|
||||
base::writeUint16(quest->dungeonDeathTotal(j));
|
||||
|
||||
|
||||
base::writeUInt16(quest->unknown2());
|
||||
base::writeUInt16(quest->deathSaveCount());
|
||||
base::writeUInt16(quest->postGameDeathCounter());
|
||||
base::writeUint16(quest->unknown2());
|
||||
base::writeUint16(quest->deathSaveCount());
|
||||
base::writeUint16(quest->postGameDeathCounter());
|
||||
|
||||
base::seek(0xF7);
|
||||
base::writeUInt16(calculateChecksum(i));
|
||||
base::writeUint16(calculateChecksum(i));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +1,23 @@
|
|||
// 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 <http://www.gnu.org/licenses/>
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#include "ALTTPQuest.hpp"
|
||||
#include "InvalidOperationException.hpp"
|
||||
#include "Athena/ALTTPQuest.hpp"
|
||||
#include "Athena/InvalidOperationException.hpp"
|
||||
#include <iostream>
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
|
||||
ALTTPQuest::ALTTPQuest()
|
||||
|
@ -71,7 +71,7 @@ std::vector<ALTTPOverworldEvent*> ALTTPQuest::overworldEvents() const
|
|||
ALTTPOverworldEvent* ALTTPQuest::overworldEvent(Uint32 id) const
|
||||
{
|
||||
if (id > m_overworldEvents.size() - 1)
|
||||
throw error::InvalidOperationException("ALTTPQuest::overworldEvents -> index out of range");
|
||||
THROW_INVALID_OPERATION_EXCEPTION("index out of range");
|
||||
return m_overworldEvents[id];
|
||||
}
|
||||
|
||||
|
@ -301,7 +301,7 @@ void ALTTPQuest::setDungeonKeys(std::vector<Uint8> val)
|
|||
void ALTTPQuest::setDungeonKeys(Uint32 id, Uint8 val)
|
||||
{
|
||||
if (id > m_dungeonKeys.size() - 1)
|
||||
throw error::InvalidOperationException("ALTTPQuest::setDungeonKeys -> index out of range");
|
||||
THROW_INVALID_OPERATION_EXCEPTION("index out of range");
|
||||
|
||||
m_dungeonKeys[id] = val;
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ void ALTTPQuest::setDungeonKeys(Uint32 id, Uint8 val)
|
|||
Uint8 ALTTPQuest::dungeonKeys(Uint32 id) const
|
||||
{
|
||||
if (id > m_dungeonKeys.size() - 1)
|
||||
throw error::InvalidOperationException("ALTTPQuest::dungeonKeys -> index out of range");
|
||||
THROW_INVALID_OPERATION_EXCEPTION("index out of range");
|
||||
|
||||
return m_dungeonKeys[id];
|
||||
}
|
||||
|
@ -398,7 +398,7 @@ void ALTTPQuest::setOldManFlags(std::vector<Uint8> flags)
|
|||
void ALTTPQuest::setOldManFlag(Uint32 id, Uint8 val)
|
||||
{
|
||||
if (id > m_oldManFlags.size() - 1)
|
||||
throw error::InvalidOperationException("ALTTPQuest::setOldManFlag -> index out of range");
|
||||
THROW_INVALID_OPERATION_EXCEPTION("index out of range");
|
||||
|
||||
m_oldManFlags[id] = val;
|
||||
}
|
||||
|
@ -406,7 +406,7 @@ void ALTTPQuest::setOldManFlag(Uint32 id, Uint8 val)
|
|||
Uint8 ALTTPQuest::oldManFlag(Uint32 id)
|
||||
{
|
||||
if (id > m_oldManFlags.size() - 1)
|
||||
throw error::InvalidOperationException("ALTTPQuest::oldManFlag -> index out of range");
|
||||
THROW_INVALID_OPERATION_EXCEPTION("index out of range");
|
||||
|
||||
return m_oldManFlags[id];
|
||||
}
|
||||
|
@ -434,7 +434,7 @@ void ALTTPQuest::setUnknown1(std::vector<Uint8> flags)
|
|||
void ALTTPQuest::setUnknown1(Uint32 id, Uint8 val)
|
||||
{
|
||||
if (id > m_unknown1.size())
|
||||
throw error::InvalidOperationException("ALTTPQuest::setUnknown1) -> index out of range");
|
||||
THROW_INVALID_OPERATION_EXCEPTION("index out of range");
|
||||
|
||||
m_unknown1[id] = val;
|
||||
}
|
||||
|
@ -442,7 +442,7 @@ void ALTTPQuest::setUnknown1(Uint32 id, Uint8 val)
|
|||
Uint8 ALTTPQuest::unknown1(Uint32 id)
|
||||
{
|
||||
if (id > m_unknown1.size())
|
||||
throw error::InvalidOperationException("ALTTPQuest::unknown1 -> index out of range");
|
||||
THROW_INVALID_OPERATION_EXCEPTION("index out of range");
|
||||
|
||||
return m_unknown1[id];
|
||||
}
|
||||
|
@ -460,7 +460,7 @@ void ALTTPQuest::setPlayerName(std::vector<Uint16> playerName)
|
|||
void ALTTPQuest::setPlayerName(const std::string& playerName)
|
||||
{
|
||||
if (playerName == std::string() || playerName.size() > 6)
|
||||
throw error::InvalidOperationException("ALTTPQuest::setPlayerName -> playerName invalid");
|
||||
THROW_INVALID_OPERATION_EXCEPTION("index out of range");
|
||||
|
||||
m_playerName.clear();
|
||||
|
||||
|
@ -623,7 +623,7 @@ void ALTTPQuest::setDungeonDeathTotals(std::vector<Uint16> val)
|
|||
void ALTTPQuest::setDungeonDeathTotal(Uint32 id, Uint16 val)
|
||||
{
|
||||
if (id > m_dungeonDeathTotals.size())
|
||||
throw error::InvalidOperationException("ALTTPQuest::setDungeonDeathTotal -> index out of range");
|
||||
THROW_INVALID_OPERATION_EXCEPTION("index out of range");
|
||||
|
||||
m_dungeonDeathTotals[id] = val;
|
||||
}
|
||||
|
@ -631,7 +631,7 @@ void ALTTPQuest::setDungeonDeathTotal(Uint32 id, Uint16 val)
|
|||
Uint16 ALTTPQuest::dungeonDeathTotal(Uint32 id) const
|
||||
{
|
||||
if (id > m_dungeonDeathTotals.size())
|
||||
throw error::InvalidOperationException("ALTTPQuest::setDungeonDeathTotal -> index out of range");
|
||||
THROW_INVALID_OPERATION_EXCEPTION("index out of range");
|
||||
|
||||
return m_dungeonDeathTotals[id];
|
||||
}
|
|
@ -0,0 +1,506 @@
|
|||
// 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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#include "Athena/BinaryReader.hpp"
|
||||
#include "Athena/IOException.hpp"
|
||||
#include "Athena/FileNotFoundException.hpp"
|
||||
#include "Athena/InvalidDataException.hpp"
|
||||
#include "Athena/InvalidOperationException.hpp"
|
||||
#include "utf8.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
|
||||
#ifdef HW_RVL
|
||||
#include <malloc.h>
|
||||
#endif // HW_RVL
|
||||
|
||||
namespace Athena
|
||||
{
|
||||
namespace io
|
||||
{
|
||||
BinaryReader::BinaryReader(const Uint8* data, Uint64 length)
|
||||
: m_length(length),
|
||||
m_position(0),
|
||||
m_bitPosition(0),
|
||||
m_endian(Endian::LittleEndian),
|
||||
m_progressCallback(nullptr)
|
||||
{
|
||||
if (!data)
|
||||
THROW_INVALID_DATA_EXCEPTION("data cannot be NULL");
|
||||
if (length == 0)
|
||||
THROW_INVALID_OPERATION_EXCEPTION("length cannot be 0");
|
||||
|
||||
m_data = new Uint8[m_length];
|
||||
memcpy(m_data, data, m_length);
|
||||
}
|
||||
|
||||
BinaryReader::BinaryReader(const std::string& filename, std::function<void(int)> progFun)
|
||||
: m_data(NULL),
|
||||
m_length(0),
|
||||
m_filepath(filename),
|
||||
m_position(0),
|
||||
m_bitPosition(0),
|
||||
m_endian(Endian::LittleEndian),
|
||||
m_progressCallback(progFun)
|
||||
{
|
||||
loadData();
|
||||
}
|
||||
|
||||
BinaryReader::~BinaryReader()
|
||||
{
|
||||
delete[] m_data;
|
||||
m_data = NULL;
|
||||
}
|
||||
|
||||
void BinaryReader::setEndian(Endian endian)
|
||||
{
|
||||
m_endian = endian;
|
||||
}
|
||||
|
||||
Endian BinaryReader::endian() const
|
||||
{
|
||||
return m_endian;
|
||||
}
|
||||
|
||||
bool BinaryReader::isBigEndian() const
|
||||
{
|
||||
return (m_endian == Endian::BigEndian);
|
||||
}
|
||||
|
||||
bool BinaryReader::isLittleEndian() const
|
||||
{
|
||||
return (m_endian == Endian::LittleEndian);
|
||||
}
|
||||
|
||||
bool BinaryReader::isOpen() const
|
||||
{
|
||||
return m_data != nullptr;
|
||||
}
|
||||
|
||||
void BinaryReader::seek(Int64 position, SeekOrigin origin)
|
||||
{
|
||||
switch (origin)
|
||||
{
|
||||
case SeekOrigin::Begin:
|
||||
if ((position < 0 || (Int64)position > (Int64)m_length))
|
||||
THROW_IO_EXCEPTION("Position outside stream bounds");
|
||||
m_position = position;
|
||||
break;
|
||||
case SeekOrigin::Current:
|
||||
if ((((Int64)m_position + position) < 0 || (m_position + position) > m_length))
|
||||
THROW_IO_EXCEPTION("Position outside stream bounds");
|
||||
m_position += position;
|
||||
break;
|
||||
case SeekOrigin::End:
|
||||
if ((((Int64)m_length - position < 0) || (m_length - position) > m_length))
|
||||
THROW_IO_EXCEPTION("Position outside stream bounds");
|
||||
m_position = m_length - position;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool BinaryReader::atEnd() const
|
||||
{
|
||||
return m_position >= m_length;
|
||||
}
|
||||
|
||||
Uint64 BinaryReader::position() const
|
||||
{
|
||||
return m_position;
|
||||
}
|
||||
|
||||
Uint64 BinaryReader::length() const
|
||||
{
|
||||
return m_length;
|
||||
}
|
||||
|
||||
void BinaryReader::setData(const Uint8* data, Uint64 length)
|
||||
{
|
||||
if (m_data)
|
||||
#ifdef HW_RVL
|
||||
free(m_data);
|
||||
#else
|
||||
delete[] m_data;
|
||||
#endif
|
||||
|
||||
m_data = (Uint8*)data;
|
||||
m_length = length;
|
||||
m_position = 0;
|
||||
m_bitPosition = 0;
|
||||
}
|
||||
|
||||
Uint8* BinaryReader::data() const
|
||||
{
|
||||
Uint8* ret = new Uint8[m_length];
|
||||
memset(ret, 0, m_length);
|
||||
memcpy(ret, m_data, m_length);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void BinaryReader::seekBit(int bit)
|
||||
{
|
||||
if (!m_data)
|
||||
loadData();
|
||||
|
||||
if (bit < 0 || bit > 7)
|
||||
THROW_INVALID_OPERATION_EXCEPTION("bit out of range");
|
||||
|
||||
m_bitPosition = bit;
|
||||
}
|
||||
|
||||
bool BinaryReader::readBit()
|
||||
{
|
||||
if (!m_data)
|
||||
loadData();
|
||||
if (m_position > m_length)
|
||||
THROW_IO_EXCEPTION("Position outside stream bounds");
|
||||
|
||||
bool ret = (*(Uint8*)(m_data + m_position) & (1 << m_bitPosition));
|
||||
|
||||
m_bitPosition++;
|
||||
if (m_bitPosition > 7)
|
||||
{
|
||||
m_bitPosition = 0;
|
||||
m_position += sizeof(Uint8);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Int8 BinaryReader::readByte()
|
||||
{
|
||||
if (!m_data)
|
||||
loadData();
|
||||
|
||||
if (m_bitPosition > 0)
|
||||
{
|
||||
m_bitPosition = 0;
|
||||
m_position += sizeof(Uint8);
|
||||
}
|
||||
if (m_position + 1 > m_length)
|
||||
THROW_IO_EXCEPTION("Stream::readByte -> Position passed stream bounds");
|
||||
|
||||
return *(Int8*)(m_data + m_position++);
|
||||
}
|
||||
|
||||
Uint8 BinaryReader::readUByte()
|
||||
{
|
||||
if (!m_data)
|
||||
loadData();
|
||||
|
||||
if (!m_data)
|
||||
loadData();
|
||||
|
||||
if (m_bitPosition > 0)
|
||||
{
|
||||
m_bitPosition = 0;
|
||||
m_position += sizeof(Uint8);
|
||||
}
|
||||
if (m_position + 1 > m_length)
|
||||
THROW_IO_EXCEPTION("Position passed stream bounds");
|
||||
|
||||
return *(Uint8*)(m_data + m_position++);
|
||||
}
|
||||
|
||||
Int8* BinaryReader::readBytes(Int64 length)
|
||||
{
|
||||
return (Int8*)readUBytes(length);
|
||||
}
|
||||
|
||||
Uint8* BinaryReader::readUBytes(Int64 length)
|
||||
{
|
||||
if (!m_data)
|
||||
loadData();
|
||||
|
||||
if (m_bitPosition > 0)
|
||||
{
|
||||
m_bitPosition = 0;
|
||||
m_position += sizeof(Uint8);
|
||||
}
|
||||
|
||||
if (m_position + length > m_length)
|
||||
THROW_IO_EXCEPTION("Position passed stream bounds");
|
||||
|
||||
Uint8* ret;
|
||||
#ifdef HW_RVL
|
||||
ret = (Uint8*)memalign(32, length);
|
||||
#else
|
||||
ret = new Uint8[length];
|
||||
#endif
|
||||
|
||||
memcpy(ret, (const Uint8*)(m_data + m_position), length);
|
||||
m_position += length;
|
||||
return ret;
|
||||
}
|
||||
|
||||
Int16 BinaryReader::readInt16()
|
||||
{
|
||||
if (!m_data)
|
||||
loadData();
|
||||
|
||||
if (m_bitPosition > 0)
|
||||
{
|
||||
m_bitPosition = 0;
|
||||
m_position += sizeof(Uint8);
|
||||
}
|
||||
|
||||
if (m_position + sizeof(Int16) > m_length)
|
||||
THROW_IO_EXCEPTION("Position outside stream bounds");
|
||||
Int16 ret = *(Int16*)(m_data + m_position);
|
||||
m_position += sizeof(Int16);
|
||||
|
||||
if ((!utility::isSystemBigEndian() && isBigEndian()) || (utility::isSystemBigEndian() && isLittleEndian()))
|
||||
ret = utility::swap16(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Uint16 BinaryReader::readUint16()
|
||||
{
|
||||
return readInt16();
|
||||
}
|
||||
|
||||
Int32 BinaryReader::readInt32()
|
||||
{
|
||||
if (!m_data)
|
||||
loadData();
|
||||
|
||||
if (m_bitPosition > 0)
|
||||
{
|
||||
m_bitPosition = 0;
|
||||
m_position += sizeof(Uint8);
|
||||
}
|
||||
|
||||
if (m_position + sizeof(Int32) > m_length)
|
||||
THROW_IO_EXCEPTION("Position outside stream bounds");
|
||||
Int32 ret = *(Int32*)(m_data + m_position);
|
||||
m_position += 4;
|
||||
|
||||
if ((!utility::isSystemBigEndian() && isBigEndian()) || (utility::isSystemBigEndian() && isLittleEndian()))
|
||||
ret = utility::swap32(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Uint32 BinaryReader::readUint32()
|
||||
{
|
||||
if (!m_data)
|
||||
loadData();
|
||||
|
||||
if (m_bitPosition > 0)
|
||||
{
|
||||
m_bitPosition = 0;
|
||||
m_position += sizeof(Uint8);
|
||||
}
|
||||
if (m_position + sizeof(Uint32) > m_length)
|
||||
THROW_IO_EXCEPTION("Position outside stream bounds");
|
||||
|
||||
Uint32 ret = *(Uint32*)(m_data + m_position);
|
||||
m_position += 4;
|
||||
|
||||
if ((!utility::isSystemBigEndian() && isBigEndian()) || (utility::isSystemBigEndian() && isLittleEndian()))
|
||||
ret = utility::swapU32(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Int64 BinaryReader::readInt64()
|
||||
{
|
||||
if (!m_data)
|
||||
loadData();
|
||||
|
||||
if (m_bitPosition > 0)
|
||||
{
|
||||
m_bitPosition = 0;
|
||||
m_position += sizeof(Uint8);
|
||||
}
|
||||
if (m_position + sizeof(Int64) > m_length)
|
||||
THROW_IO_EXCEPTION("Position outside stream bounds");
|
||||
|
||||
Int64 ret = *(Int64*)(m_data + m_position);
|
||||
m_position += 8;
|
||||
|
||||
if ((!utility::isSystemBigEndian() && isBigEndian()) || (utility::isSystemBigEndian() && isLittleEndian()))
|
||||
ret = utility::swap64(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Uint64 BinaryReader::readUint64()
|
||||
{
|
||||
if (!m_data)
|
||||
loadData();
|
||||
|
||||
if (m_bitPosition > 0)
|
||||
{
|
||||
m_bitPosition = 0;
|
||||
m_position += sizeof(Uint8);
|
||||
}
|
||||
if (m_position + sizeof(Uint64) > m_length)
|
||||
THROW_IO_EXCEPTION("Position outside stream bounds");
|
||||
Uint64 ret = *(Uint64*)(m_data + m_position);
|
||||
m_position += 8;
|
||||
|
||||
if ((!utility::isSystemBigEndian() && isBigEndian()) || (utility::isSystemBigEndian() && isLittleEndian()))
|
||||
ret = utility::swapU64(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
float BinaryReader::readFloat()
|
||||
{
|
||||
if (!m_data)
|
||||
loadData();
|
||||
|
||||
if (m_bitPosition > 0)
|
||||
{
|
||||
m_bitPosition = 0;
|
||||
m_position += sizeof(Uint8);
|
||||
}
|
||||
if (m_position + sizeof(float) > m_length)
|
||||
THROW_IO_EXCEPTION("Position outside stream bounds");
|
||||
|
||||
float ret = *(float*)(m_data + m_position);
|
||||
m_position += 4;
|
||||
|
||||
if ((!utility::isSystemBigEndian() && isBigEndian()) || (utility::isSystemBigEndian() && isLittleEndian()))
|
||||
ret = utility::swapFloat(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
double BinaryReader::readDouble()
|
||||
{
|
||||
if (!m_data)
|
||||
loadData();
|
||||
|
||||
if (m_bitPosition > 0)
|
||||
{
|
||||
m_bitPosition = 0;
|
||||
m_position += sizeof(Uint8);
|
||||
}
|
||||
if (m_position + sizeof(double) > m_length)
|
||||
THROW_IO_EXCEPTION("Position outside stream bounds");
|
||||
|
||||
double ret = *(double*)(m_data + m_position);
|
||||
m_position += 8;
|
||||
|
||||
if ((!utility::isSystemBigEndian() && isBigEndian()) || (utility::isSystemBigEndian() && isLittleEndian()))
|
||||
ret = utility::swapDouble(ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool BinaryReader::readBool()
|
||||
{
|
||||
if (!m_data)
|
||||
loadData();
|
||||
|
||||
if (m_bitPosition > 0)
|
||||
{
|
||||
m_bitPosition = 0;
|
||||
m_position += sizeof(Uint8);
|
||||
}
|
||||
if (m_position + sizeof(bool) > m_length)
|
||||
THROW_IO_EXCEPTION("Position outside stream bounds");
|
||||
|
||||
bool ret = *(bool*)(m_data + m_position);
|
||||
m_position += 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string BinaryReader::readUnicode()
|
||||
{
|
||||
if (!m_data)
|
||||
loadData();
|
||||
std::string ret;
|
||||
std::vector<short> tmp;
|
||||
Uint16 chr = readUint16();
|
||||
for(;;)
|
||||
{
|
||||
if (!chr)
|
||||
break;
|
||||
tmp.push_back(chr);
|
||||
chr = readUint16();
|
||||
}
|
||||
|
||||
utf8::utf16to8(tmp.begin(), tmp.end(), back_inserter(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string BinaryReader::readString()
|
||||
{
|
||||
std::string ret = "";
|
||||
Uint8 chr = readByte();
|
||||
|
||||
while (chr != 0)
|
||||
{
|
||||
ret += chr;
|
||||
chr = readByte();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void BinaryReader::setProgressCallback(std::function<void (int)> cb)
|
||||
{
|
||||
m_progressCallback = cb;
|
||||
}
|
||||
|
||||
void BinaryReader::loadData()
|
||||
{
|
||||
FILE* in;
|
||||
Uint32 length;
|
||||
in = fopen(m_filepath.c_str(), "rb");
|
||||
|
||||
if (!in)
|
||||
THROW_FILE_NOT_FOUND_EXCEPTION(m_filepath);
|
||||
|
||||
fseek(in, 0, SEEK_END);
|
||||
length = ftell(in);
|
||||
fseek(in, 0, SEEK_SET);
|
||||
#ifdef HW_RVL
|
||||
m_data = (Uint8*)memalign(32, length);
|
||||
#else
|
||||
m_data = new Uint8[length];
|
||||
#endif
|
||||
|
||||
Uint32 done = 0;
|
||||
Uint32 blocksize = BLOCKSZ;
|
||||
do
|
||||
{
|
||||
if (blocksize > length - done)
|
||||
blocksize = length - done;
|
||||
|
||||
Int32 ret = fread(m_data + done, 1, blocksize, in);
|
||||
|
||||
if (ret < 0)
|
||||
THROW_IO_EXCEPTION("Error reading data from disk");
|
||||
else if (ret == 0)
|
||||
break;
|
||||
|
||||
done += ret;
|
||||
|
||||
if (m_progressCallback)
|
||||
m_progressCallback((int)((float)(done* 100.f)/length));
|
||||
|
||||
} while (done < length);
|
||||
|
||||
fclose(in);
|
||||
m_length = length;
|
||||
m_position = 0;
|
||||
m_bitPosition = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,505 @@
|
|||
// 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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#include "Athena/BinaryWriter.hpp"
|
||||
#include "Athena/IOException.hpp"
|
||||
#include "Athena/InvalidOperationException.hpp"
|
||||
#include "Athena/InvalidDataException.hpp"
|
||||
#include "Athena/FileNotFoundException.hpp"
|
||||
#include "utf8.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
#ifdef HW_RVL
|
||||
#include <malloc.h>
|
||||
#endif // HW_RVL
|
||||
|
||||
namespace Athena
|
||||
{
|
||||
namespace io
|
||||
{
|
||||
|
||||
BinaryWriter::BinaryWriter(Uint8* data, Uint64 length)
|
||||
: m_data((Uint8*)data),
|
||||
m_length(length),
|
||||
m_position(0),
|
||||
m_bitPosition(0),
|
||||
m_endian(Endian::LittleEndian),
|
||||
m_progressCallback(nullptr)
|
||||
{}
|
||||
|
||||
BinaryWriter::BinaryWriter(const std::string& filename, std::function<void(int)> progressFun)
|
||||
: m_length(0),
|
||||
m_filepath(filename),
|
||||
m_position(0),
|
||||
m_bitPosition(0),
|
||||
m_endian(Endian::LittleEndian),
|
||||
m_progressCallback(progressFun)
|
||||
{
|
||||
m_length = 0x10;
|
||||
m_bitPosition = 0;
|
||||
m_position = 0;
|
||||
#ifdef HW_RVL
|
||||
m_data = (Uint8*)memalign(32, m_length);
|
||||
#else
|
||||
m_data = new Uint8[m_length];
|
||||
#endif
|
||||
|
||||
if (!m_data)
|
||||
THROW_IO_EXCEPTION("Could not allocate memory!");
|
||||
|
||||
memset(m_data, 0, m_length);
|
||||
}
|
||||
|
||||
BinaryWriter::~BinaryWriter()
|
||||
{
|
||||
if (isOpen())
|
||||
save();
|
||||
delete[] m_data;
|
||||
m_data = nullptr;
|
||||
}
|
||||
|
||||
void BinaryWriter::setEndian(Endian endian)
|
||||
{
|
||||
m_endian = endian;
|
||||
}
|
||||
|
||||
Endian BinaryWriter::endian() const
|
||||
{
|
||||
return m_endian;
|
||||
}
|
||||
|
||||
bool BinaryWriter::isBigEndian() const
|
||||
{
|
||||
return (m_endian == Endian::BigEndian);
|
||||
}
|
||||
|
||||
bool BinaryWriter::isLittleEndian() const
|
||||
{
|
||||
return (m_endian == Endian::LittleEndian);
|
||||
}
|
||||
|
||||
bool BinaryWriter::isOpen() const
|
||||
{
|
||||
return m_data != nullptr;
|
||||
}
|
||||
|
||||
void BinaryWriter::seek(Int64 position, SeekOrigin origin)
|
||||
{
|
||||
switch (origin)
|
||||
{
|
||||
case SeekOrigin::Begin:
|
||||
if (position < 0)
|
||||
THROW_IO_EXCEPTION("Position outside stream bounds");
|
||||
|
||||
if ((Uint64)position > m_length)
|
||||
resize(position);
|
||||
m_position = position;
|
||||
break;
|
||||
case SeekOrigin::Current:
|
||||
if ((((Int64)m_position + position) < 0))
|
||||
THROW_IO_EXCEPTION("Position outside stream bounds");
|
||||
|
||||
if (m_position + position > m_length)
|
||||
resize(m_position + position);
|
||||
|
||||
m_position += position;
|
||||
break;
|
||||
case SeekOrigin::End:
|
||||
if (((Int64)m_length - position) < 0)
|
||||
THROW_IO_EXCEPTION("Position outside stream bounds");
|
||||
|
||||
if ((Uint64)position > m_length)
|
||||
resize(position);
|
||||
m_position = m_length - position;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool BinaryWriter::atEnd() const
|
||||
{
|
||||
return m_position >= m_length;
|
||||
}
|
||||
|
||||
Uint64 BinaryWriter::position() const
|
||||
{
|
||||
return m_position;
|
||||
}
|
||||
|
||||
Uint64 BinaryWriter::length() const
|
||||
{
|
||||
return m_length;
|
||||
}
|
||||
|
||||
void BinaryWriter::setFilepath(const std::string& filepath)
|
||||
{
|
||||
m_filepath = filepath;
|
||||
}
|
||||
|
||||
std::string BinaryWriter::filepath() const
|
||||
{
|
||||
return m_filepath;
|
||||
}
|
||||
|
||||
void BinaryWriter::setData(const Uint8* data, Uint64 length)
|
||||
{
|
||||
if (m_data)
|
||||
#ifdef HW_RVL
|
||||
free(m_data);
|
||||
#else
|
||||
delete[] m_data;
|
||||
#endif
|
||||
|
||||
m_data = (Uint8*)data;
|
||||
m_length = length;
|
||||
m_position = 0;
|
||||
m_bitPosition = 0;
|
||||
}
|
||||
|
||||
Uint8* BinaryWriter::data() const
|
||||
{
|
||||
Uint8* ret = new Uint8[m_length];
|
||||
memset(ret, 0, m_length);
|
||||
memcpy(ret, m_data, m_length);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void BinaryWriter::save(const std::string& filename)
|
||||
{
|
||||
if (filename.empty() && m_filepath.empty())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("No file specified, cannot save.");
|
||||
|
||||
if (!filename.empty())
|
||||
m_filepath = filename;
|
||||
|
||||
FILE* out = fopen(m_filepath.c_str(), "wb");
|
||||
if (!out)
|
||||
THROW_FILE_NOT_FOUND_EXCEPTION(m_filepath);
|
||||
|
||||
Uint32 done = 0;
|
||||
Uint32 blocksize = BLOCKSZ;
|
||||
do
|
||||
{
|
||||
if (blocksize > m_length - done)
|
||||
blocksize = m_length - done;
|
||||
|
||||
Int32 ret = fwrite(m_data + done, 1, blocksize, out);
|
||||
|
||||
if (ret < 0)
|
||||
THROW_IO_EXCEPTION("Error writing data to disk");
|
||||
else if (ret == 0)
|
||||
break;
|
||||
|
||||
done += blocksize;
|
||||
}while (done < m_length);
|
||||
|
||||
fclose(out);
|
||||
}
|
||||
|
||||
void BinaryWriter::seekBit(int bit)
|
||||
{
|
||||
if (bit < 0 || bit > 7)
|
||||
THROW_INVALID_OPERATION_EXCEPTION("bit out of range");
|
||||
|
||||
m_bitPosition = bit;
|
||||
}
|
||||
|
||||
void BinaryWriter::writeBit(bool val)
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for writing");
|
||||
|
||||
if (m_position + sizeof(Uint8) > m_length)
|
||||
resize(m_position + sizeof(Uint8));
|
||||
|
||||
if (val)
|
||||
*(Uint8*)(m_data + m_position) |= (1 << m_bitPosition);
|
||||
else
|
||||
*(Uint8*)(m_data + m_position) &= ~(1 << m_bitPosition);
|
||||
m_bitPosition++;
|
||||
if (m_bitPosition > 7)
|
||||
{
|
||||
m_bitPosition = 0;
|
||||
m_position += sizeof(Uint8);
|
||||
}
|
||||
}
|
||||
|
||||
void BinaryWriter::writeUByte(Uint8 val)
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for writing");
|
||||
|
||||
if (m_bitPosition > 0)
|
||||
{
|
||||
m_bitPosition = 0;
|
||||
m_position += sizeof(Uint8);
|
||||
}
|
||||
if (m_position + 1 > m_length)
|
||||
resize(m_position + 1);
|
||||
|
||||
*(Uint8*)(m_data + m_position) = val;
|
||||
|
||||
m_position++;
|
||||
}
|
||||
|
||||
void BinaryWriter::writeByte(Int8 val)
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for writing");
|
||||
|
||||
writeUByte(val);
|
||||
}
|
||||
|
||||
void BinaryWriter::writeUBytes(Uint8* data, Uint64 length)
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for writing");
|
||||
|
||||
if (m_bitPosition > 0)
|
||||
{
|
||||
m_bitPosition = 0;
|
||||
m_position += sizeof(Uint8);
|
||||
}
|
||||
|
||||
if (!data)
|
||||
THROW_INVALID_DATA_EXCEPTION("data cannnot be NULL");
|
||||
if (m_position + length > m_length)
|
||||
resize(m_position + length);
|
||||
|
||||
memcpy((Int8*)(m_data + m_position), data, length);
|
||||
|
||||
m_position += length;
|
||||
}
|
||||
|
||||
void BinaryWriter::writeBytes(Int8* data, Uint64 length)
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for writing");
|
||||
|
||||
writeUBytes((Uint8*)data, length);
|
||||
}
|
||||
|
||||
void BinaryWriter::writeInt16(Int16 val)
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for writing");
|
||||
|
||||
if (m_bitPosition > 0)
|
||||
{
|
||||
m_bitPosition = 0;
|
||||
m_position += sizeof(Uint8);
|
||||
}
|
||||
|
||||
if (m_position + sizeof(Int16) > m_length)
|
||||
resize(m_position + sizeof(Int16));
|
||||
|
||||
if ((!utility::isSystemBigEndian() && isBigEndian()) || (utility::isSystemBigEndian() && isLittleEndian()))
|
||||
val = utility::swap16(val);
|
||||
|
||||
*(Int16*)(m_data + m_position) = val;
|
||||
m_position += sizeof(Int16);
|
||||
}
|
||||
|
||||
void BinaryWriter::writeUint16(Uint16 val)
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for writing");
|
||||
|
||||
writeInt16(val);
|
||||
}
|
||||
|
||||
void BinaryWriter::writeInt32(Int32 val)
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for writing");
|
||||
|
||||
if (m_bitPosition > 0)
|
||||
{
|
||||
m_bitPosition = 0;
|
||||
m_position += sizeof(Uint8);
|
||||
}
|
||||
|
||||
if (m_position + sizeof(Int32) > m_length)
|
||||
resize(m_position + sizeof(Int32));
|
||||
|
||||
if ((!utility::isSystemBigEndian() && isBigEndian()) || (utility::isSystemBigEndian() && isLittleEndian()))
|
||||
val = utility::swap32(val);
|
||||
|
||||
*(Int32*)(m_data + m_position) = val;
|
||||
m_position += sizeof(Int32);
|
||||
}
|
||||
|
||||
void BinaryWriter::writeUint32(Uint32 val)
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for writing");
|
||||
|
||||
writeInt32(val);
|
||||
}
|
||||
|
||||
void BinaryWriter::writeInt64(Int64 val)
|
||||
{
|
||||
if (m_bitPosition > 0)
|
||||
{
|
||||
m_bitPosition = 0;
|
||||
m_position += sizeof(Uint8);
|
||||
}
|
||||
|
||||
if (m_position + sizeof(Int64) > m_length)
|
||||
resize(m_position + sizeof(Int64));
|
||||
|
||||
|
||||
if ((!utility::isSystemBigEndian() && isBigEndian()) || (utility::isSystemBigEndian() && isLittleEndian()))
|
||||
val = utility::swap64(val);
|
||||
|
||||
*(Int64*)(m_data + m_position) = val;
|
||||
m_position += sizeof(Int64);
|
||||
}
|
||||
|
||||
void BinaryWriter::writeUint64(Uint64 val)
|
||||
{
|
||||
if (m_bitPosition > 0)
|
||||
{
|
||||
m_bitPosition = 0;
|
||||
m_position += sizeof(Uint8);
|
||||
}
|
||||
|
||||
if (m_position + sizeof(Uint64) > m_length)
|
||||
resize(m_position + sizeof(Uint64));
|
||||
|
||||
if ((!utility::isSystemBigEndian() && isBigEndian()) || (utility::isSystemBigEndian() && isLittleEndian()))
|
||||
val = utility::swapU64(val);
|
||||
|
||||
*(Uint64*)(m_data + m_position) = val;
|
||||
m_position += sizeof(Uint64);
|
||||
}
|
||||
|
||||
void BinaryWriter::writeFloat(float val)
|
||||
{
|
||||
if (m_bitPosition > 0)
|
||||
{
|
||||
m_bitPosition = 0;
|
||||
m_position += sizeof(Uint8);
|
||||
}
|
||||
|
||||
if (m_position + sizeof(float) > m_length)
|
||||
resize(m_position + sizeof(float));
|
||||
|
||||
if ((!utility::isSystemBigEndian() && isBigEndian()) || (utility::isSystemBigEndian() && isLittleEndian()))
|
||||
val = utility::swapFloat(val);
|
||||
|
||||
*(float*)(m_data + m_position) = val;
|
||||
m_position += sizeof(float);
|
||||
}
|
||||
|
||||
void BinaryWriter::writeDouble(double val)
|
||||
{
|
||||
if (m_bitPosition > 0)
|
||||
{
|
||||
m_bitPosition = 0;
|
||||
m_position += sizeof(Uint8);
|
||||
}
|
||||
|
||||
if (m_position + sizeof(double) > m_length)
|
||||
resize(m_position + sizeof(double));
|
||||
|
||||
if ((!utility::isSystemBigEndian() && isBigEndian()) || (utility::isSystemBigEndian() && isLittleEndian()))
|
||||
val = utility::swapDouble(val);
|
||||
|
||||
*(double*)(m_data + m_position)= val;
|
||||
m_position += sizeof(double);
|
||||
}
|
||||
|
||||
void BinaryWriter::writeBool(bool val)
|
||||
{
|
||||
if (m_bitPosition > 0)
|
||||
{
|
||||
m_bitPosition = 0;
|
||||
m_position += sizeof(Uint8);
|
||||
}
|
||||
|
||||
if (m_position + sizeof(bool) > m_length)
|
||||
resize(m_position + sizeof(bool));
|
||||
|
||||
*(bool*)(m_data + m_position) = val;
|
||||
m_position += sizeof(bool);
|
||||
}
|
||||
|
||||
void BinaryWriter::writeUnicode(const std::string& str)
|
||||
{
|
||||
std::string tmpStr = "\xEF\xBB\xBF" + str;
|
||||
|
||||
std::vector<short> tmp;
|
||||
|
||||
utf8::utf8to16(tmpStr.begin(), tmpStr.end(), back_inserter(tmp));
|
||||
|
||||
for (Uint16 chr : tmp)
|
||||
{
|
||||
if (chr != 0xFEFF)
|
||||
writeInt16(chr);
|
||||
}
|
||||
writeInt16(0);
|
||||
}
|
||||
|
||||
void BinaryWriter::writeString(const std::string& str)
|
||||
{
|
||||
for (Uint8 c : str)
|
||||
{
|
||||
writeUByte(c);
|
||||
if (c == '\0')
|
||||
break;
|
||||
}
|
||||
writeUByte(0);
|
||||
}
|
||||
|
||||
void BinaryWriter::setProgressCallback(std::function<void (int)> cb)
|
||||
{
|
||||
m_progressCallback = cb;
|
||||
}
|
||||
|
||||
void BinaryWriter::resize(Uint64 newSize)
|
||||
{
|
||||
if (newSize < m_length)
|
||||
THROW_INVALID_OPERATION_EXCEPTION("Stream::resize() -> New size cannot be less to the old size.");
|
||||
|
||||
// Allocate and copy new buffer
|
||||
#ifdef HW_RVL
|
||||
Uint8* newArray = (Uint8*)memalign(32, newSize);
|
||||
#else
|
||||
Uint8* newArray = new Uint8[newSize];
|
||||
#endif
|
||||
|
||||
memset(newArray, 0, newSize);
|
||||
|
||||
memcpy(newArray, m_data, m_length);
|
||||
|
||||
// Delete the old one
|
||||
#ifdef HW_RVL
|
||||
free(m_data);
|
||||
#else
|
||||
delete[] m_data;
|
||||
#endif
|
||||
|
||||
// Swap the pointer and size out for the new ones.
|
||||
m_data = newArray;
|
||||
m_length = newSize;
|
||||
}
|
||||
|
||||
} // io
|
||||
} // Athena
|
|
@ -1,9 +1,24 @@
|
|||
#include "Checksums.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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#include "Athena/Checksums.hpp"
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
namespace Checksums
|
||||
{
|
|
@ -13,13 +13,13 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with libZelda. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#include "Compression.hpp"
|
||||
#include "Exception.hpp"
|
||||
#include "Athena/Compression.hpp"
|
||||
#include "Athena/Exception.hpp"
|
||||
#include "lzo.h"
|
||||
#include <iostream>
|
||||
#include <zlib.h>
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
namespace io
|
||||
{
|
|
@ -0,0 +1,333 @@
|
|||
// 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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#include "Athena/FileReader.hpp"
|
||||
#include "Athena/FileNotFoundException.hpp"
|
||||
#include "Athena/InvalidDataException.hpp"
|
||||
#include "Athena/InvalidOperationException.hpp"
|
||||
#include "Athena/IOException.hpp"
|
||||
#include "utf8.h"
|
||||
|
||||
namespace Athena
|
||||
{
|
||||
namespace io
|
||||
{
|
||||
FileReader::FileReader(const std::string& filename)
|
||||
: m_filename(filename),
|
||||
m_fileHandle(NULL),
|
||||
m_endian(Endian::LittleEndian),
|
||||
m_bitValid(false)
|
||||
{
|
||||
open();
|
||||
}
|
||||
|
||||
FileReader::~FileReader()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
std::string FileReader::filename() const
|
||||
{
|
||||
return m_filename;
|
||||
}
|
||||
|
||||
void FileReader::setEndian(Endian endian)
|
||||
{
|
||||
m_endian = endian;
|
||||
}
|
||||
|
||||
Endian FileReader::endian() const
|
||||
{
|
||||
return m_endian;
|
||||
}
|
||||
|
||||
bool FileReader::isBigEndian() const
|
||||
{
|
||||
return (m_endian == Endian::BigEndian);
|
||||
}
|
||||
|
||||
bool FileReader::isLittleEndian() const
|
||||
{
|
||||
return (m_endian == Endian::LittleEndian);
|
||||
}
|
||||
|
||||
void FileReader::open()
|
||||
{
|
||||
m_fileHandle = fopen(m_filename.c_str(), "rb");
|
||||
if (!m_fileHandle)
|
||||
THROW_FILE_NOT_FOUND_EXCEPTION(m_filename);
|
||||
|
||||
// ensure we're at the beginning of the file
|
||||
rewind(m_fileHandle);
|
||||
}
|
||||
|
||||
void FileReader::close()
|
||||
{
|
||||
if (!m_fileHandle)
|
||||
THROW_INVALID_OPERATION_EXCEPTION("Cannot close an unopened stream");
|
||||
|
||||
fclose(m_fileHandle);
|
||||
m_fileHandle = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
bool FileReader::isOpen() const
|
||||
{
|
||||
return m_fileHandle != NULL;
|
||||
}
|
||||
|
||||
void FileReader::seek(Int64 pos, SeekOrigin origin)
|
||||
{
|
||||
if (fseeko64(m_fileHandle, pos, (int)origin) != 0)
|
||||
THROW_INVALID_OPERATION_EXCEPTION("Unable to seek in file");
|
||||
}
|
||||
|
||||
bool FileReader::atEnd() const
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open");
|
||||
|
||||
return feof(m_fileHandle) != 0;
|
||||
}
|
||||
|
||||
Uint64 FileReader::position() const
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open");
|
||||
|
||||
return ftello64(m_fileHandle);
|
||||
}
|
||||
|
||||
Uint64 FileReader::length() const
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open");
|
||||
|
||||
return utility::fileSize(m_fileHandle);
|
||||
}
|
||||
|
||||
void FileReader::seekBit(int bit)
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open");
|
||||
|
||||
if (bit < 0 || bit > 7)
|
||||
THROW_INVALID_OPERATION_EXCEPTION("bit out of range");
|
||||
|
||||
m_bitShift = bit;
|
||||
}
|
||||
|
||||
bool FileReader::readBit()
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File is not open for reading");
|
||||
|
||||
if (!m_bitValid)
|
||||
{
|
||||
int size = fread(&m_currentByte, 1, 1, m_fileHandle);
|
||||
if (size != sizeof(Uint8))
|
||||
THROW_IO_EXCEPTION("Error reading from file.");
|
||||
|
||||
m_bitShift = 0;
|
||||
m_bitValid = true;
|
||||
}
|
||||
|
||||
Uint8 flag = (1 << m_bitShift);
|
||||
m_bitShift++;
|
||||
if (m_bitShift > 7)
|
||||
m_bitValid = false;
|
||||
|
||||
return ((m_currentByte & flag) == flag);
|
||||
}
|
||||
|
||||
Uint8 FileReader::readUByte()
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for reading");
|
||||
|
||||
m_bitValid = false;
|
||||
Uint8 val = 0;
|
||||
fread(&val, 1, 1, m_fileHandle);
|
||||
return val;
|
||||
}
|
||||
|
||||
Int8 FileReader::readByte()
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for reading");
|
||||
return (Int8)readUByte();
|
||||
}
|
||||
|
||||
Uint8* FileReader::readUBytes(Uint64 len)
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for reading");
|
||||
m_bitValid = false;
|
||||
Uint8* val = new Uint8[len];
|
||||
fread(val, 1, len, m_fileHandle);
|
||||
return val;
|
||||
}
|
||||
|
||||
Int8* FileReader::readBytes(Uint64 len)
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for reading");
|
||||
return (Int8*)readUBytes(len);
|
||||
}
|
||||
|
||||
Uint16 FileReader::readUint16()
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for reading");
|
||||
|
||||
m_bitValid = false;
|
||||
Uint16 val;
|
||||
fread(&val, 1, sizeof(Uint16), m_fileHandle);
|
||||
|
||||
if ((utility::isSystemBigEndian() && !isBigEndian()) || (!utility::isSystemBigEndian() && isBigEndian()))
|
||||
utility::swapU16(val);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
Int16 FileReader::readInt16()
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for reading");
|
||||
|
||||
return (Int16)readUint16();
|
||||
}
|
||||
|
||||
Uint32 FileReader::readUint32()
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for reading");
|
||||
|
||||
m_bitValid = false;
|
||||
Uint32 val;
|
||||
fread(&val, 1, sizeof(Uint32), m_fileHandle);
|
||||
|
||||
if ((utility::isSystemBigEndian() && !isBigEndian()) || (!utility::isSystemBigEndian() && isBigEndian()))
|
||||
utility::swapU64(val);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
Int32 FileReader::readInt32()
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for reading");
|
||||
|
||||
return (Int32)readUint32();
|
||||
}
|
||||
|
||||
Uint64 FileReader::readUint64()
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for reading");
|
||||
|
||||
m_bitValid = false;
|
||||
Uint64 val;
|
||||
fread(&val, 1, sizeof(Uint64), m_fileHandle);
|
||||
|
||||
if ((utility::isSystemBigEndian() && !isBigEndian()) || (!utility::isSystemBigEndian() && isBigEndian()))
|
||||
utility::swapU64(val);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
Int64 FileReader::readInt64()
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for reading");
|
||||
|
||||
return (Int64)readUint64();
|
||||
}
|
||||
|
||||
double FileReader::readDouble()
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for reading");
|
||||
|
||||
m_bitValid = false;
|
||||
double val;
|
||||
fread(&val, 1, sizeof(double), m_fileHandle);
|
||||
|
||||
if ((utility::isSystemBigEndian() && !isBigEndian()) || (!utility::isSystemBigEndian() && isBigEndian()))
|
||||
utility::swapDouble(val);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
float FileReader::readFloat()
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for reading");
|
||||
|
||||
m_bitValid = false;
|
||||
float val;
|
||||
fread(&val, 1, sizeof(float), m_fileHandle);
|
||||
|
||||
if ((utility::isSystemBigEndian() && !isBigEndian()) || (!utility::isSystemBigEndian() && isBigEndian()))
|
||||
utility::swapFloat(val);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
bool FileReader::readBool()
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for reading");
|
||||
|
||||
return (readByte() != 0);
|
||||
}
|
||||
|
||||
std::string FileReader::readString()
|
||||
{
|
||||
std::string ret = "";
|
||||
Uint8 chr = readByte();
|
||||
|
||||
while (chr != 0)
|
||||
{
|
||||
ret += chr;
|
||||
chr = readByte();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string FileReader::readUnicode()
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for reading");
|
||||
|
||||
std::string ret;
|
||||
std::vector<short> tmp;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
short chr = readUint16();
|
||||
if (chr)
|
||||
tmp.push_back(chr);
|
||||
else
|
||||
break;
|
||||
};
|
||||
|
||||
utf8::utf16to8(tmp.begin(), tmp.end(), back_inserter(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // io
|
||||
} // Athena
|
|
@ -0,0 +1,298 @@
|
|||
// 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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#include "Athena/FileWriter.hpp"
|
||||
#include "Athena/FileNotFoundException.hpp"
|
||||
#include "Athena/InvalidDataException.hpp"
|
||||
#include "Athena/InvalidOperationException.hpp"
|
||||
#include "Athena/IOException.hpp"
|
||||
#include "utf8.h"
|
||||
|
||||
namespace Athena
|
||||
{
|
||||
namespace io
|
||||
{
|
||||
FileWriter::FileWriter(const std::string& filename)
|
||||
: m_filename(filename),
|
||||
m_fileHandle(NULL),
|
||||
m_endian(Endian::LittleEndian),
|
||||
m_bytePosition(0),
|
||||
m_bitShift(0),
|
||||
m_bitValid(false)
|
||||
{
|
||||
open();
|
||||
}
|
||||
|
||||
FileWriter::~FileWriter()
|
||||
{
|
||||
if (isOpen())
|
||||
close();
|
||||
}
|
||||
|
||||
void FileWriter::setEndian(Endian endian)
|
||||
{
|
||||
m_endian = endian;
|
||||
}
|
||||
|
||||
Endian FileWriter::endian() const
|
||||
{
|
||||
return m_endian;
|
||||
}
|
||||
|
||||
bool FileWriter::isBigEndian() const
|
||||
{
|
||||
return (m_endian == Endian::BigEndian);
|
||||
}
|
||||
|
||||
bool FileWriter::isLittleEndian() const
|
||||
{
|
||||
return (m_endian == Endian::LittleEndian);
|
||||
}
|
||||
|
||||
void FileWriter::open()
|
||||
{
|
||||
m_fileHandle = fopen(m_filename.c_str(), "w+b");
|
||||
if (!m_fileHandle)
|
||||
THROW_FILE_NOT_FOUND_EXCEPTION(m_filename);
|
||||
|
||||
// ensure we're at the beginning of the file
|
||||
rewind(m_fileHandle);
|
||||
}
|
||||
|
||||
void FileWriter::close()
|
||||
{
|
||||
if (!m_fileHandle)
|
||||
THROW_INVALID_OPERATION_EXCEPTION("Cannot close an unopened stream");
|
||||
|
||||
fclose(m_fileHandle);
|
||||
m_fileHandle = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
bool FileWriter::isOpen() const
|
||||
{
|
||||
return m_fileHandle != NULL;
|
||||
}
|
||||
|
||||
void FileWriter::seek(Int64 pos, SeekOrigin origin)
|
||||
{
|
||||
if (fseeko64(m_fileHandle, pos, (int)origin) != 0)
|
||||
THROW_IO_EXCEPTION("Unable to seek in file");
|
||||
}
|
||||
|
||||
bool FileWriter::atEnd() const
|
||||
{
|
||||
return feof(m_fileHandle) != 0;
|
||||
}
|
||||
|
||||
Uint64 FileWriter::position() const
|
||||
{
|
||||
return ftello64(m_fileHandle);
|
||||
}
|
||||
|
||||
Uint64 FileWriter::length() const
|
||||
{
|
||||
return utility::fileSize(m_fileHandle);
|
||||
}
|
||||
|
||||
void FileWriter::writeBit(bool val)
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for writing");
|
||||
|
||||
if (!m_bitValid)
|
||||
{
|
||||
m_bitValid = true;
|
||||
m_bitShift = 0;
|
||||
m_bytePosition = ftello64(m_fileHandle);
|
||||
}
|
||||
|
||||
|
||||
if (val)
|
||||
m_currentByte |= (1 << m_bitShift++);
|
||||
else
|
||||
m_currentByte &= ~(1 << m_bitShift++);
|
||||
|
||||
if (m_bitShift > 7)
|
||||
m_bitValid = false;
|
||||
|
||||
fseeko64(m_fileHandle, m_bytePosition, (int)SeekOrigin::Begin);
|
||||
if (fwrite(&m_currentByte, 1, 1, m_fileHandle) != sizeof(Int8))
|
||||
THROW_IO_EXCEPTION("Unable to data to file");
|
||||
}
|
||||
|
||||
void FileWriter::seekBit(int bit)
|
||||
{
|
||||
if (bit < 0 || bit > 7)
|
||||
THROW_INVALID_OPERATION_EXCEPTION("bit must be >= 0 and <= 7");
|
||||
m_bitShift = bit;
|
||||
m_bitValid = true;
|
||||
}
|
||||
|
||||
void FileWriter::writeUByte(Uint8 val)
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for writing");
|
||||
|
||||
m_bitValid = false;
|
||||
|
||||
if (fwrite(&val, 1, sizeof(Uint8), m_fileHandle) != sizeof(Uint8))
|
||||
THROW_IO_EXCEPTION("Unable to write to stream");
|
||||
}
|
||||
|
||||
void FileWriter::writeByte(Int8 val)
|
||||
{
|
||||
writeUByte(val);
|
||||
}
|
||||
|
||||
void FileWriter::writeUBytes(Uint8* data, Uint64 len)
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for writing");
|
||||
|
||||
m_bitValid = false;
|
||||
|
||||
if (fwrite(data, 1, len, m_fileHandle) != len)
|
||||
THROW_IO_EXCEPTION("Unable to write to stream");
|
||||
}
|
||||
|
||||
void FileWriter::writeBytes(Int8* data, Uint64 len)
|
||||
{
|
||||
writeUBytes((Uint8*)data, len);
|
||||
}
|
||||
|
||||
void FileWriter::writeUint16(Uint16 val)
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for writing");
|
||||
|
||||
m_bitValid = false;
|
||||
|
||||
if ((utility::isSystemBigEndian() && !isBigEndian()) || (!utility::isSystemBigEndian() && isBigEndian()))
|
||||
utility::swapU16(val);
|
||||
|
||||
if (fwrite(&val, 1, sizeof(Uint16), m_fileHandle) != sizeof(Uint16))
|
||||
THROW_IO_EXCEPTION("Unable to write to stream");
|
||||
}
|
||||
|
||||
void FileWriter::writeInt16(Int16 val)
|
||||
{
|
||||
writeUint16(val);
|
||||
}
|
||||
|
||||
void FileWriter::writeUint32(Uint32 val)
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for writing");
|
||||
|
||||
m_bitValid = false;
|
||||
|
||||
if ((utility::isSystemBigEndian() && !isBigEndian()) || (!utility::isSystemBigEndian() && isBigEndian()))
|
||||
utility::swapU32(val);
|
||||
|
||||
if (fwrite(&val, 1, sizeof(Uint32), m_fileHandle) != sizeof(Uint32))
|
||||
THROW_IO_EXCEPTION("Unable to write to stream");
|
||||
}
|
||||
|
||||
void FileWriter::writeInt32(Int32 val)
|
||||
{
|
||||
writeUint32(val);
|
||||
}
|
||||
|
||||
void FileWriter::writeUint64(Uint64 val)
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for writing");
|
||||
|
||||
m_bitValid = false;
|
||||
|
||||
if ((utility::isSystemBigEndian() && !isBigEndian()) || (!utility::isSystemBigEndian() && isBigEndian()))
|
||||
utility::swapU32(val);
|
||||
|
||||
if (fwrite(&val, 1, sizeof(Uint64), m_fileHandle) != sizeof(Uint64))
|
||||
THROW_IO_EXCEPTION("Unable to write to stream");
|
||||
}
|
||||
|
||||
void FileWriter::writeInt64(Int64 val)
|
||||
{
|
||||
writeUint64(val);
|
||||
}
|
||||
|
||||
void FileWriter::writeDouble(double val)
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for writing");
|
||||
|
||||
m_bitValid = false;
|
||||
|
||||
if ((utility::isSystemBigEndian() && !isBigEndian()) || (!utility::isSystemBigEndian() && isBigEndian()))
|
||||
utility::swapDouble(val);
|
||||
|
||||
if (fwrite(&val, 1, sizeof(double), m_fileHandle) != sizeof(double))
|
||||
THROW_IO_EXCEPTION("Unable to write to stream");
|
||||
}
|
||||
|
||||
void FileWriter::writeFloat(float val)
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for writing");
|
||||
|
||||
m_bitValid = false;
|
||||
|
||||
if ((utility::isSystemBigEndian() && !isBigEndian()) || (!utility::isSystemBigEndian() && isBigEndian()))
|
||||
utility::swapFloat(val);
|
||||
|
||||
if (fwrite(&val, 1, sizeof(float), m_fileHandle) != sizeof(float))
|
||||
THROW_IO_EXCEPTION("Unable to write to stream");
|
||||
}
|
||||
|
||||
void FileWriter::writeBool(bool val)
|
||||
{
|
||||
writeByte(val);
|
||||
}
|
||||
|
||||
void FileWriter::writeString(const std::string& val)
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for writing");
|
||||
|
||||
m_bitValid = false;
|
||||
|
||||
char term = '\0';
|
||||
if (fwrite(val.c_str(), 1, val.length(), m_fileHandle) != val.length())
|
||||
THROW_IO_EXCEPTION("Unable to write to stream");
|
||||
if (fwrite(&term, 1, 1, m_fileHandle) != 1)
|
||||
THROW_IO_EXCEPTION("Unable to write to stream");
|
||||
}
|
||||
|
||||
void FileWriter::writeUnicode(const std::string& str)
|
||||
{
|
||||
if (!isOpen())
|
||||
THROW_INVALID_OPERATION_EXCEPTION("File not open for writing");
|
||||
|
||||
std::string tmpStr = "\xEF\xBB\xBF" + str;
|
||||
|
||||
std::vector<short> tmp;
|
||||
|
||||
utf8::utf8to16(tmpStr.begin(), tmpStr.end(), back_inserter(tmp));
|
||||
|
||||
for (Uint16 chr : tmp)
|
||||
{
|
||||
if (chr != 0xFEFF)
|
||||
writeInt16(chr);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // Athena
|
|
@ -0,0 +1,48 @@
|
|||
// 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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#include "Athena/Global.hpp"
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const Athena::SeekOrigin& origin)
|
||||
{
|
||||
switch(origin)
|
||||
{
|
||||
case Athena::SeekOrigin::Begin:
|
||||
os << "Begin";
|
||||
break;
|
||||
case Athena::SeekOrigin::Current:
|
||||
os << "Current";
|
||||
break;
|
||||
case Athena::SeekOrigin::End:
|
||||
os << "End";
|
||||
break;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const Athena::Endian& endian)
|
||||
{
|
||||
switch(endian)
|
||||
{
|
||||
case Athena::Endian::LittleEndian:
|
||||
os << "LittleEndian";
|
||||
break;
|
||||
case Athena::Endian::BigEndian:
|
||||
os << "BigEndian";
|
||||
break;
|
||||
}
|
||||
return os;
|
||||
}
|
|
@ -1,21 +1,21 @@
|
|||
// 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 <http://www.gnu.org/licenses/>
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#include "MCFile.hpp"
|
||||
#include "Athena/MCFile.hpp"
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
|
||||
MCFile::MCFile()
|
|
@ -1,21 +1,21 @@
|
|||
// 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 <http://www.gnu.org/licenses/>
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#include "MCFileReader.hpp"
|
||||
#include "Athena/MCFileReader.hpp"
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
|
||||
namespace io
|
|
@ -1,21 +1,21 @@
|
|||
// 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 <http://www.gnu.org/licenses/>
|
||||
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
||||
|
||||
#include "MCFileWriter.hpp"
|
||||
#include "Athena/MCFileWriter.hpp"
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
namespace io
|
||||
{
|
|
@ -0,0 +1,71 @@
|
|||
// 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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#include "Athena/SkywardSwordFile.hpp"
|
||||
#include "Athena/SkywardSwordQuest.hpp"
|
||||
#include "Athena/InvalidOperationException.hpp"
|
||||
|
||||
namespace Athena
|
||||
{
|
||||
|
||||
SkywardSwordFile::SkywardSwordFile()
|
||||
: m_numQuests(0)
|
||||
{
|
||||
}
|
||||
|
||||
SkywardSwordFile::SkywardSwordFile(std::vector<SkywardSwordQuest*> quests)
|
||||
: m_numQuests(0)
|
||||
{
|
||||
m_quests = quests;
|
||||
}
|
||||
|
||||
SkywardSwordFile::~SkywardSwordFile()
|
||||
{
|
||||
}
|
||||
|
||||
void SkywardSwordFile::addQuest(Athena::SkywardSwordQuest *q)
|
||||
{
|
||||
// Do not allow more than 3 quests
|
||||
if (m_quests.size() >= 3)
|
||||
return;
|
||||
|
||||
m_quests.push_back(q);
|
||||
}
|
||||
|
||||
SkywardSwordQuest *SkywardSwordFile::quest(Uint32 id)
|
||||
{
|
||||
if (id > m_quests.size() - 1)
|
||||
THROW_INVALID_OPERATION_EXCEPTION("index out of range");
|
||||
|
||||
return m_quests[id];
|
||||
}
|
||||
|
||||
std::vector<SkywardSwordQuest*> SkywardSwordFile::questList() const
|
||||
{
|
||||
return m_quests;
|
||||
}
|
||||
|
||||
void SkywardSwordFile::setRegion(Region region)
|
||||
{
|
||||
m_region = region;
|
||||
}
|
||||
|
||||
Region SkywardSwordFile::region() const
|
||||
{
|
||||
return m_region;
|
||||
}
|
||||
|
||||
|
||||
} // zelda
|
|
@ -0,0 +1,84 @@
|
|||
// 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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#include "Athena/SkywardSwordFileReader.hpp"
|
||||
#include "Athena/SkywardSwordFile.hpp"
|
||||
#include "Athena/SkywardSwordQuest.hpp"
|
||||
#include "Athena/InvalidOperationException.hpp"
|
||||
#include "Athena/InvalidDataException.hpp"
|
||||
#include <iostream>
|
||||
|
||||
namespace Athena
|
||||
{
|
||||
namespace io
|
||||
{
|
||||
|
||||
SkywardSwordFileReader::SkywardSwordFileReader(Uint8* data, Uint64 length)
|
||||
: base(data, length)
|
||||
{
|
||||
base::setEndian(Endian::BigEndian);
|
||||
}
|
||||
|
||||
SkywardSwordFileReader::SkywardSwordFileReader(const std::string& filename)
|
||||
: base(filename)
|
||||
{
|
||||
base::setEndian(Endian::BigEndian);
|
||||
}
|
||||
|
||||
SkywardSwordFile* SkywardSwordFileReader::read()
|
||||
{
|
||||
SkywardSwordFile* file = NULL;
|
||||
try
|
||||
{
|
||||
if (base::length() != 0xFBE0)
|
||||
THROW_INVALID_DATA_EXCEPTION("File not the expected size of 0xFBE0");
|
||||
|
||||
Uint32 magic = base::readUint32();
|
||||
|
||||
if (magic != SkywardSwordFile::USMagic && magic != SkywardSwordFile::JAMagic && magic != SkywardSwordFile::EUMagic)
|
||||
THROW_INVALID_DATA_EXCEPTION("Not a valid Skyward Sword save file");
|
||||
|
||||
base::seek(0x01C, SeekOrigin::Begin);
|
||||
Uint32 headerSize = base::readUint32(); // Seems to be (headerSize - 1)
|
||||
|
||||
if (headerSize != 0x1D)
|
||||
THROW_INVALID_DATA_EXCEPTION("Invalid header size, Corrupted data?");
|
||||
|
||||
// Time to read in each slot
|
||||
file = new SkywardSwordFile;
|
||||
file->setRegion((magic == SkywardSwordFile::USMagic ? Region::NTSC: (magic == SkywardSwordFile::JAMagic ? Region::NTSCJ: Region::PAL)));
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
SkywardSwordQuest* q = new SkywardSwordQuest((Uint8*)base::readBytes(0x53C0), 0x53C0);
|
||||
Uint64 pos = base::position();
|
||||
// seek to the skip data for this particular quest
|
||||
base::seek(0xFB60 + (i * 0x24), SeekOrigin::Begin);
|
||||
q->setSkipData(base::readUBytes(0x24));
|
||||
base::seek(pos, SeekOrigin::Begin);
|
||||
file->addQuest(q);
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
delete file;
|
||||
file = NULL;
|
||||
throw;
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
} // io
|
||||
} // zelda
|
|
@ -0,0 +1,75 @@
|
|||
// 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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#include "Athena/SkywardSwordFileWriter.hpp"
|
||||
#include "Athena/SkywardSwordFile.hpp"
|
||||
#include "Athena/SkywardSwordQuest.hpp"
|
||||
#include "Athena/InvalidOperationException.hpp"
|
||||
#include "Athena/InvalidDataException.hpp"
|
||||
|
||||
namespace Athena
|
||||
{
|
||||
namespace io
|
||||
{
|
||||
|
||||
SkywardSwordFileWriter::SkywardSwordFileWriter(Uint8 *data, Uint64 len)
|
||||
: base(data, len)
|
||||
{
|
||||
base::setEndian(Endian::BigEndian);
|
||||
}
|
||||
|
||||
SkywardSwordFileWriter::SkywardSwordFileWriter(const std::string &filename)
|
||||
: base(filename)
|
||||
{
|
||||
base::setEndian(Endian::BigEndian);
|
||||
}
|
||||
|
||||
void SkywardSwordFileWriter::write(SkywardSwordFile *file)
|
||||
{
|
||||
if (!file)
|
||||
THROW_INVALID_OPERATION_EXCEPTION("file cannot be NULL");
|
||||
|
||||
Uint32 magic = (file->region() == Region::NTSC ? SkywardSwordFile::USMagic :
|
||||
(file->region() == Region::NTSCJ ? SkywardSwordFile::JAMagic : SkywardSwordFile::EUMagic));
|
||||
|
||||
base::writeUint32(magic);
|
||||
base::seek(0x1C, SeekOrigin::Begin);
|
||||
base::writeUint32(0x1D);
|
||||
|
||||
std::vector<SkywardSwordQuest*> quests = file->questList();
|
||||
int i = 0;
|
||||
for (SkywardSwordQuest* q : quests)
|
||||
{
|
||||
if (q->length() != 0x53C0)
|
||||
THROW_INVALID_DATA_EXCEPTION("q->data() not 0x53C0 bytes in length");
|
||||
if (q->skipLength() != 0x24)
|
||||
THROW_INVALID_DATA_EXCEPTION("q->skipData() not 0x24 bytes in length");
|
||||
// Write the save data
|
||||
base::writeUBytes(q->data(), q->length());
|
||||
Uint64 pos = base::position();
|
||||
// Write the slots skip data
|
||||
base::seek(0xFB60 + (i * 0x24), SeekOrigin::Begin);
|
||||
base::writeUBytes(q->skipData(), q->skipLength());
|
||||
base::seek(pos, SeekOrigin::Begin);
|
||||
i++;
|
||||
}
|
||||
|
||||
// write those padding bytes
|
||||
base::seek(0xFBE0, SeekOrigin::Begin);
|
||||
save();
|
||||
}
|
||||
|
||||
} // io
|
||||
} // zelda
|
|
@ -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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#include "Athena/SkywardSwordQuest.hpp"
|
||||
|
||||
namespace Athena
|
||||
{
|
||||
SkywardSwordQuest::SkywardSwordQuest(Uint8 *data, Uint32 len)
|
||||
: ZQuestFile(ZQuestFile::SS, Endian::BigEndian, data, len),
|
||||
m_skipData(nullptr),
|
||||
m_skipLength(0)
|
||||
{
|
||||
}
|
||||
|
||||
void SkywardSwordQuest::setSkipData(const Uint8 *data, Uint32 len)
|
||||
{
|
||||
if (m_skipData)
|
||||
{
|
||||
delete[] m_skipData;
|
||||
m_skipData = nullptr;
|
||||
}
|
||||
|
||||
m_skipData = (Uint8*)data;
|
||||
m_skipLength = len;
|
||||
}
|
||||
|
||||
Uint8 *SkywardSwordQuest::skipData() const
|
||||
{
|
||||
return m_skipData;
|
||||
}
|
||||
|
||||
Uint32 SkywardSwordQuest::skipLength() const
|
||||
{
|
||||
return m_skipLength;
|
||||
}
|
||||
|
||||
} // zelda
|
|
@ -1,13 +1,28 @@
|
|||
#include "Sprite.hpp"
|
||||
#include "SpriteFrame.hpp"
|
||||
#include "SpriteFile.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 <http://www.gnu.org/licenses/>
|
||||
|
||||
#include "Athena/Sprite.hpp"
|
||||
#include "Athena/SpriteFrame.hpp"
|
||||
#include "Athena/SpriteFile.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef LIBZELDA_USE_QT
|
||||
#include <QVector>
|
||||
#endif
|
||||
|
||||
namespace zelda
|
||||
namespace Athena
|
||||
{
|
||||
namespace Sakura
|
||||
{
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue