mirror of
https://github.com/libAthena/athena.git
synced 2025-12-09 21:47:52 +00:00
* Fixed compression code, old code was unreliable and failed at random
(don't use zlib's compress function) * More refactory work, ready for merge
This commit is contained in:
@@ -20,6 +20,9 @@
|
||||
|
||||
#include "Types.hpp"
|
||||
|
||||
namespace zelda
|
||||
{
|
||||
|
||||
enum BowType : char
|
||||
{
|
||||
BowNone,
|
||||
@@ -105,5 +108,6 @@ enum ALTTPTagAlong
|
||||
AfterBoss
|
||||
};
|
||||
|
||||
} // zelda
|
||||
#endif // __DOXYGEN_IGNORE__
|
||||
#endif // __ALTTP_ENUMS_HPP__
|
||||
|
||||
@@ -24,9 +24,9 @@
|
||||
namespace zelda
|
||||
{
|
||||
class ALTTPFile;
|
||||
|
||||
namespace io
|
||||
{
|
||||
|
||||
/*! \class ALTTPFileReader
|
||||
* \brief A Link to the Past save data reader class
|
||||
*
|
||||
@@ -34,10 +34,10 @@ namespace io
|
||||
* all work is done using a memory buffer, and not read directly from the disk.
|
||||
* \sa BinaryReader
|
||||
*/
|
||||
|
||||
class ALTTPFileReader : public io::BinaryReader
|
||||
class ALTTPFileReader : protected BinaryReader
|
||||
{
|
||||
BINARYREADER_BASE
|
||||
|
||||
public:
|
||||
/*! \brief This constructor takes an existing buffer to read from.
|
||||
*
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace io
|
||||
* all work is done using a memory buffer, and not written directly to the disk.
|
||||
* \sa BinaryReader
|
||||
*/
|
||||
class ALTTPFileWriter : public io::BinaryWriter
|
||||
class ALTTPFileWriter : protected BinaryWriter
|
||||
{
|
||||
BINARYWRITER_BASE
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace zelda
|
||||
{
|
||||
namespace io
|
||||
{
|
||||
|
||||
/*! \class BinaryReader
|
||||
* \brief A Stream class for reading binary data
|
||||
*
|
||||
@@ -177,4 +178,5 @@ protected:
|
||||
private: \
|
||||
typedef zelda::io::BinaryReader base;
|
||||
#endif // BINARYREADER_BASE
|
||||
|
||||
#endif // __BINARYREADER_HPP__
|
||||
|
||||
@@ -138,6 +138,13 @@ public:
|
||||
* \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);
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace io
|
||||
namespace Compression
|
||||
{
|
||||
Int32 decompressZlib(Uint8* src, Uint32 srcLen, Uint8* dst, Uint32 dstLen);
|
||||
void compressZlib(const Uint8* src, Uint32 srcLen, Uint8* dst, Uint32* dstLen);
|
||||
Int32 compressZlib(const Uint8* src, Uint32 srcLen, Uint8* dst, Uint32 dstLen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace io
|
||||
* all work is done using a memory buffer, and not read directly from the disk.
|
||||
* \sa BinaryReader
|
||||
*/
|
||||
class MCFileReader : public io::BinaryReader
|
||||
class MCFileReader : protected BinaryReader
|
||||
{
|
||||
BINARYREADER_BASE
|
||||
public:
|
||||
|
||||
@@ -24,6 +24,9 @@ namespace zelda
|
||||
|
||||
class MCFile;
|
||||
|
||||
namespace io
|
||||
{
|
||||
|
||||
/*! \class MCFileWriter
|
||||
* \brief The Minish Cap Save save data writer class
|
||||
*
|
||||
@@ -31,7 +34,7 @@ class MCFile;
|
||||
* all work is done using a memory buffer, and not written directly from the disk.
|
||||
* \sa BinaryWriter
|
||||
*/
|
||||
class MCFileWriter : public io::BinaryWriter
|
||||
class MCFileWriter : protected BinaryWriter
|
||||
{
|
||||
BINARYWRITER_BASE
|
||||
public:
|
||||
@@ -64,6 +67,7 @@ private:
|
||||
void unscramble();
|
||||
};
|
||||
|
||||
} // io
|
||||
} // zelda
|
||||
|
||||
#endif // __MCFILEWRITER_HPP__
|
||||
|
||||
@@ -80,16 +80,16 @@ public:
|
||||
* \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
|
||||
*/
|
||||
* \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
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
|
||||
#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
|
||||
@@ -27,6 +30,8 @@ enum Endian
|
||||
LittleEndian, //!< Specifies that the Stream is Little Endian (LSB)
|
||||
BigEndian //!< Specifies that the Stream is Big Endian (MSB)
|
||||
};
|
||||
} // zelda
|
||||
#endif
|
||||
|
||||
// 8 bits integer types
|
||||
#if UCHAR_MAX == 0xFF
|
||||
|
||||
@@ -12,12 +12,13 @@
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with libZelda. 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 "Types.hpp"
|
||||
#include "utility.hpp"
|
||||
#include "BinaryReader.hpp"
|
||||
|
||||
namespace zelda
|
||||
{
|
||||
@@ -36,7 +37,7 @@ namespace io
|
||||
* all work is done using a memory buffer, and not read directly from the disk.
|
||||
* \sa BinaryReader
|
||||
*/
|
||||
class WiiSaveReader : public io::BinaryReader
|
||||
class WiiSaveReader : protected BinaryReader
|
||||
{
|
||||
BINARYREADER_BASE
|
||||
public:
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
namespace zelda
|
||||
{
|
||||
|
||||
class WiiSave;
|
||||
class WiiBanner;
|
||||
class WiiFile;
|
||||
@@ -38,7 +37,7 @@ namespace io
|
||||
* all work is done using a memory buffer, and not written directly to the disk.
|
||||
* \sa BinaryReader
|
||||
*/
|
||||
class WiiSaveWriter : public io::BinaryWriter
|
||||
class WiiSaveWriter : protected BinaryWriter
|
||||
{
|
||||
BINARYWRITER_BASE
|
||||
public:
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#ifndef ZQUEST_HPP
|
||||
#define ZQUEST_HPP
|
||||
|
||||
#include <Types.hpp>
|
||||
#include "Types.hpp"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -25,65 +25,70 @@ namespace zelda
|
||||
/*!
|
||||
* \brief The ZQuest class
|
||||
*/
|
||||
class ZQuest
|
||||
class ZQuestFile
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
* \brief Major
|
||||
* \brief The current major version of the ZQuest format
|
||||
*/
|
||||
static const Uint32 Major;
|
||||
/*!
|
||||
* \brief Minor
|
||||
* \brief The current minor version of the ZQuest format
|
||||
*/
|
||||
static const Uint32 Minor;
|
||||
/*!
|
||||
* \brief Revision
|
||||
* \brief The current revision of the ZQuest format
|
||||
*/
|
||||
static const Uint32 Revision;
|
||||
/*!
|
||||
* \brief Build
|
||||
* \brief The current build of the ZQuest format
|
||||
*/
|
||||
static const Uint32 Build;
|
||||
/*!
|
||||
* \brief Version
|
||||
* \brief The current version of the ZQuest format
|
||||
*/
|
||||
static const Uint32 Version;
|
||||
|
||||
/*!
|
||||
* \brief Magic
|
||||
* \brief The magic number used to identify the file e.g. "ZQS1"
|
||||
*/
|
||||
static const Uint32 Magic;
|
||||
|
||||
/*!
|
||||
* \brief The Game enum
|
||||
* \enum Game
|
||||
* \brief The list of games currently supported by ZQuest
|
||||
*/
|
||||
enum Game
|
||||
{
|
||||
NoGame,
|
||||
LegendofZelda,
|
||||
AdventureOfLink,
|
||||
ALinkToThePast,
|
||||
LinksAwakening,
|
||||
OcarinaOfTime,
|
||||
OcarinaOfTime3D,
|
||||
MajorasMask,
|
||||
OracleOfSeasons,
|
||||
OracleOfAges,
|
||||
FourSwords,
|
||||
WindWaker,
|
||||
FourSwordsAdventures,
|
||||
MinishCap,
|
||||
TwilightPrincess,
|
||||
PhantomHourglass,
|
||||
SpiritTracks,
|
||||
SkywardSword,
|
||||
ALinkBetweenWorlds // Not released
|
||||
NoGame, //!< None or Unsupported
|
||||
LoZ, //!< Legend of Zelda
|
||||
AoL, //!< Adventure of Link
|
||||
ALttP, //!< A Link to the Past
|
||||
LA, //!< Links Awakening
|
||||
OoT, //!< Ocarin of Time
|
||||
OoT3D, //!< Ocarina of Time 3D
|
||||
MM, //!< Majora's Mask
|
||||
OoS, //!< Oracle of Season
|
||||
OoA, //!< Oracle of Ages
|
||||
FS, //!< Four Swords
|
||||
WW, //!< Wind Waker
|
||||
FSA, //!< Four Swords Adventures
|
||||
MC, //!< Minish Cap
|
||||
TP, //!< Twilight Princess
|
||||
PH, //!< Phantom Hourglass
|
||||
ST, //!< Spirit Tracks
|
||||
SS, //!< Skyward Sword
|
||||
ALBW, //!< A Link Between Worlds
|
||||
// Add more games here
|
||||
|
||||
// This must always be last
|
||||
GameCount //!< Total number of supported games
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief ZQuest
|
||||
*/
|
||||
ZQuest();
|
||||
ZQuestFile();
|
||||
|
||||
/*!
|
||||
* \brief ZQuest
|
||||
@@ -92,8 +97,8 @@ public:
|
||||
* \param data
|
||||
* \param length
|
||||
*/
|
||||
ZQuest(Game game, Endian endian, Uint8* data, Uint32 length);
|
||||
~ZQuest();
|
||||
ZQuestFile(Game game, Endian endian, Uint8* data, Uint32 length);
|
||||
~ZQuestFile();
|
||||
|
||||
/*!
|
||||
* \brief setGame
|
||||
@@ -121,9 +126,10 @@ public:
|
||||
|
||||
/*!
|
||||
* \brief setData
|
||||
* \param data
|
||||
* \param data The data to assign
|
||||
* \param length The length of the data
|
||||
*/
|
||||
void setData(Uint8* data);
|
||||
void setData(Uint8* data, Uint32 length);
|
||||
|
||||
/*!
|
||||
* \brief data
|
||||
@@ -131,12 +137,6 @@ public:
|
||||
*/
|
||||
Uint8* data() const;
|
||||
|
||||
/*!
|
||||
* \brief setLength
|
||||
* \param length
|
||||
*/
|
||||
void setLength(Uint32 length);
|
||||
|
||||
/*!
|
||||
* \brief length
|
||||
* \return
|
||||
@@ -20,16 +20,18 @@
|
||||
|
||||
namespace zelda
|
||||
{
|
||||
class ZQuest;
|
||||
class ZQuestFile;
|
||||
|
||||
namespace io
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief The ZQuestFileReader class
|
||||
*/
|
||||
class ZQuestFileReader : public io::BinaryReader
|
||||
class ZQuestFileReader : protected BinaryReader
|
||||
{
|
||||
BINARYREADER_BASE
|
||||
|
||||
public:
|
||||
/*!
|
||||
* \brief ZQuestFileReader
|
||||
@@ -48,7 +50,7 @@ public:
|
||||
* \brief read
|
||||
* \return
|
||||
*/
|
||||
ZQuest* read();
|
||||
ZQuestFile* read();
|
||||
};
|
||||
|
||||
} // io
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
namespace zelda
|
||||
{
|
||||
class ZQuest;
|
||||
class ZQuestFile;
|
||||
|
||||
namespace io
|
||||
{
|
||||
@@ -28,7 +28,7 @@ namespace io
|
||||
/*!
|
||||
* \brief The ZQuestFileWriter class
|
||||
*/
|
||||
class ZQuestFileWriter : public io::BinaryWriter
|
||||
class ZQuestFileWriter : protected BinaryWriter
|
||||
{
|
||||
BINARYWRITER_BASE
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
* \param quest
|
||||
* \param compress
|
||||
*/
|
||||
void write(ZQuest* quest, bool compress = true);
|
||||
void write(ZQuestFile* quest, bool compress = true);
|
||||
};
|
||||
|
||||
} // io
|
||||
|
||||
@@ -88,7 +88,7 @@ extern "C"
|
||||
* Typedefs:
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
typedef struct auth_md5Ctx_
|
||||
{
|
||||
unsigned int len;
|
||||
unsigned int ABCD[4];
|
||||
|
||||
@@ -19,13 +19,19 @@
|
||||
#include <string>
|
||||
#include "Types.hpp"
|
||||
|
||||
bool isEmpty(Int8*, size_t);
|
||||
namespace zelda
|
||||
{
|
||||
namespace utility
|
||||
{
|
||||
|
||||
unsigned short swapU16(unsigned short val );
|
||||
short swap16 (short val );
|
||||
unsigned int swapU32(unsigned int val);
|
||||
int swap32 (int val );
|
||||
long long swap64 (long long val);
|
||||
bool isEmpty(Int8*, Uint32);
|
||||
|
||||
Uint16 swapU16(Uint16 val );
|
||||
Int16 swap16 (Int16 val );
|
||||
Uint32 swapU32(Uint32 val);
|
||||
Int32 swap32 (Int32 val );
|
||||
Uint64 swapU64(Uint64 val);
|
||||
Int64 swap64 (Int64 val);
|
||||
|
||||
float swapFloat(float val);
|
||||
double swapDouble(double val);
|
||||
@@ -36,4 +42,8 @@ void fillRandom(Uint8 * rndArea, Uint8 count);
|
||||
|
||||
void yaz0Decode(Uint8* src, Uint8* dst, Uint32 uncompressedSize);
|
||||
|
||||
|
||||
} // utility
|
||||
} // zelda
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user