First commit

This commit is contained in:
Elouan Appéré 2015-08-30 22:09:23 +02:00
parent cdbc39c8dd
commit c586def095
163 changed files with 28854 additions and 0 deletions

23
CMakeLists.txt Normal file
View File

@ -0,0 +1,23 @@
cmake_minimum_required(VERSION 2.8.12)
project(PkmGCTools)
set(CMAKE_INSTALL_PREFIX installdir)
option(BUILD_PKMGCSAVEEDITOR ON)
add_subdirectory(LibPkmGC)
add_definitions(${LIBPKMGC_DEFINITIONS})
message("BUILD_PKMGCSAVEEDITOR:\t${BUILD_PKMGCSAVEEDITOR}")
if(BUILD_PKMGCSAVEEDITOR)
add_subdirectory(PkmGCSaveEditor)
install(FILES ${LIBPKMGC_RUNTIME} DESTINATION Debug/bin CONFIGURATIONS Debug)
install(FILES ${LIBPKMGC_RUNTIME} DESTINATION Release/bin CONFIGURATIONS Release RelWithDebInfo MinSizeRel)
install(FILES ${QT5_RUNTIME_DEBUG} DESTINATION Debug/bin CONFIGURATIONS Debug)
install(FILES ${QT5_RUNTIME_RELEASE} DESTINATION Release/bin CONFIGURATIONS Release RelWithDebInfo MinSizeRel)
install(FILES ${QT5_TRANSLATION_QM} DESTINATION Debug/bin/languages CONFIGURATIONS Debug)
install(FILES ${QT5_TRANSLATION_QM} DESTINATION Release/bin/languages CONFIGURATIONS Release RelWithDebInfo MinSizeRel)
endif()

41
LibPkmGC/CMakeLists.txt Normal file
View File

@ -0,0 +1,41 @@
cmake_minimum_required(VERSION 2.8.12)
project(LibPkmGC)
include(FindBoost)
find_package(Boost 1.55.0 REQUIRED)
file(GLOB_RECURSE source_files ${PROJECT_SOURCE_DIR}/src/*)
file(GLOB_RECURSE header_files ${PROJECT_SOURCE_DIR}/include/*)
set(all_files ${source_files} ${header_files})
set(LIBPKMGC_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/include
${Boost_INCLUDE_DIRS}
CACHE INTERNAL "${PROJECT_NAME}: Include Directories" FORCE)
include_directories(${LIBPKMGC_INCLUDE_DIRS})
option(LIBPKMGC_DYN_LIB ON)
message("LIBPKMGC_DYN_LIB:\t${LIBPKMGC_DYN_LIB}")
add_definitions(-DLIBPKMGC_SOURCE)
unset(LIBPKMGC_RUNTIME CACHE)
unset(LIBPKMGC_DEFINITONS CACHE)
if(LIBPKMGC_DYN_LIB)
set(LIBPKMGC_DEFINITIONS -DLIBPKMGC_DYN_LIB CACHE INTERNAL "LibPkmGC's definitions" FORCE)
add_definitions(-DLIBPKMGC_DYN_LIB)
add_library(LibPkmGC SHARED ${all_files})
set(LIBPKMGC_RUNTIME $<TARGET_FILE:LibPkmGC> CACHE INTERNAL "Runtime dependencies for projects linking against this library" FORCE)
install(FILES $<TARGET_FILE:LibPkmGC> $<TARGET_LINKER_FILE:LibPkmGC> DESTINATION Release/lib/shared CONFIGURATIONS Release RelWithDebInfo MinSizeRel)
install(FILES $<TARGET_FILE:LibPkmGC> $<TARGET_LINKER_FILE:LibPkmGC> DESTINATION Debug/lib/shared CONFIGURATIONS Debug)
else()
set(LIBPKMGC_DEFINITIONS -DLIBPKMGC_STATIC_LIB CACHE INTERNAL "LibPkmGC's definitions" FORCE)
add_definitions(-DLIBPKMGC_STATIC_LIB)
add_library(LibPkmGC STATIC ${all_files})
install(FILES $<TARGET_FILE:LibPkmGC> DESTINATION Release/lib/static CONFIGURATIONS Release RelWithDebInfo MinSizeRel)
install(FILES $<TARGET_FILE:LibPkmGC> DESTINATION Debug/lib/static CONFIGURATIONS Debug)
endif()
set_target_properties(LibPkmGC PROPERTIES PREFIX "" IMPORT_PREFIX "")

View File

@ -0,0 +1,66 @@
#ifndef _LIBPKMGC_BASE_DATASTRUCT_H
#define _LIBPKMGC_BASE_DATASTRUCT_H
#include <LibPkmGC/Core/Detail/StructMacros.h>
#define LIBPKMGC_STRUCT_DECRYPTED 1
#define LIBPKMGC_FWD_DECL_GC_CLS(cls) namespace Colosseum { class cls; } namespace XD { class cls; }
namespace LibPkmGC {
namespace Base {
class LIBPKMGC_DECL DataStruct {
public:
u8* data;
//u32 statusFlags;
DataStruct(void);
DataStruct(size_t inSize, const u8* inData = NULL, bool fixed = true);
virtual void save(void) = 0;
virtual void reload(const u8* inData = NULL, u32 flags = 0);
DataStruct(const DataStruct& other);
virtual DataStruct* clone(void) const = 0;
virtual DataStruct* create(void) const = 0;
void swap(DataStruct& other);
DataStruct& operator=(DataStruct const& other);
virtual ~DataStruct(void);
bool sizeIsFixed(void) const;
const size_t fixedSize; // = 0 if not fixed
size_t getSize(void) const;
protected:
size_t size;
void initWithEmptyData(u32 flags = 0);
void copyData(const u8* data = NULL);
virtual void load(u32 flags = 0);
virtual void loadData(u32 flags = 0);
virtual void loadFields(void) = 0;
virtual void deleteFields(void) = 0; // delete dynamically allocated fields
};
class LIBPKMGC_DECL UnimplementedStruct : public DataStruct {
public:
UnimplementedStruct(void) : DataStruct() { }
UnimplementedStruct(size_t inSize, const u8* inData = NULL) : DataStruct(inSize, inData) { if (inData == NULL) initWithEmptyData(); }
UnimplementedStruct* clone(void) const { return new UnimplementedStruct(*this); }
UnimplementedStruct* create(void) const { return new UnimplementedStruct; }
void save(void) {}
private:
void loadFields(void) {}
void deleteFields(void) {}
};
}
}
#endif

View File

@ -0,0 +1,111 @@
#ifndef _LIBPKMGC_BASE_POKEMON_H
#define _LIBPKMGC_BASE_POKEMON_H
#include <LibPkmGC/Core/PokemonInfo.h>
#include <LibPkmGC/Core/ItemInfo.h>
#include <LibPkmGC/Base/DataStruct.h>
#include <LibPkmGC/Base/PokemonString.h>
namespace LibPkmGC {
LIBPKMGC_FWD_DECL_GC_CLS(Pokemon)
namespace Base {
class LIBPKMGC_DECL Pokemon : public DataStruct {
public:
Pokemon(size_t inSize, const u8* inData = NULL);
virtual ~Pokemon(void);
virtual void swap(Pokemon& other);
virtual Pokemon& operator=(Pokemon const& other);
virtual Pokemon* clone(void) const = 0;
virtual Pokemon* create(void) const = 0;
static u16 calculateStat(size_t statIndex, PokemonSpeciesIndex species, PokemonNatureIndex natureIndex, u8 level, u8 IV, u8 EV);
static void calculateStats(PokemonSpeciesIndex species, PokemonNatureIndex natureIndex, u8 level, const u8 IVs[6], const u8 EVs[6], u16 outStats[6]);
static u8 calculateLevelFromExp(PokemonSpeciesIndex species, u32 experience);
static u32 calculateExpFromLevel(PokemonSpeciesIndex species, u8 level);
void calculateStats(u16 outStats[6]) const;
u8 calculateLevelFromExp(void) const;
u32 calculateExpFromLevel(u8 lvl) const;
void updateStats(void);
void updateLevelFromExp(void);
void updateExpFromLevel(u8 lvl);
static bool isShiny(u32 PID, u16 TID, u16 SID);
static PokemonNatureIndex getNature(u32 PID);
static Gender getGender(PokemonSpeciesIndex species, u32 PID);
static PokemonSpeciesIndex getWurmpleEvolution(u32 PID);
static char getUnownForm(u32 PID);
bool isShiny(void) const;
PokemonNatureIndex getNature(void) const;
Gender getGender(void) const;
PokemonSpeciesIndex getWurmpleEvolution(void) const;
char getUnownForm(void) const;
bool isSpecialAbilityDefined(void) const;
virtual PokemonAbilityIndex getAbility(void) const = 0;
virtual bool isEmptyOrInvalid(void) const;
PokemonSpeciesIndex species; //u16
ItemIndex heldItem;
u8 happiness;
u8 locationCaught; // u16 on Colo/XD
ItemIndex ballCaughtWith;
u8 levelMet;
Gender OTGender;
PokemonString* OTName;
PokemonString* name;
u8 contestLuster;
u8 pkrsStatus;
PokemonMarkings markings;
u32 experience;
u16 SID;
u16 TID;
u32 PID;
// u8 encounterType;
VersionInfo version;
bool specialRibbons[12]; //special ribbons #7 only exists in XD/Col
//u32 statusFlags;
PokemonMove moves[4];
u8 EVs[6];
u8 IVs[6];
u8 contestStats[5];
ContestAchievementLevel contestAchievements[5];
bool usesPartyData; // we will avoid using ptrs here
struct PokemonComputedPartyData {
u16 currentHP;
u8 level;
PokemonStatus status;
u16 stats[6];
};
PokemonComputedPartyData partyData;
void resetPartyData(void);
protected:
Pokemon(Pokemon const& other);
virtual void deleteFields(void);
};
}
}
#endif

View File

@ -0,0 +1,36 @@
#ifndef _LIBPKMGC_BASE_POKEMON_BOX_H
#define _LIBPKMGC_BASE_POKEMON_BOX_H
#include <LibPkmGC/Base/Pokemon.h>
namespace LibPkmGC {
LIBPKMGC_FWD_DECL_GC_CLS(PokemonBox)
namespace Base {
class LIBPKMGC_DECL PokemonBox : public Base::DataStruct {
public:
PokemonBox(size_t inSize, const u8* inData = NULL);
virtual ~PokemonBox(void);
virtual PokemonBox* clone(void) const = 0;
virtual PokemonBox* create(void) const = 0;
virtual void deleteFields(void);
void swap(PokemonBox & other);
PokemonBox& operator=(PokemonBox const& other);
PokemonString *name;
Pokemon* pkm[30];
protected:
PokemonBox(PokemonBox const& other);
};
}
}
#endif

View File

@ -0,0 +1,45 @@
#ifndef _LIBPKMGC_BASE_POKEMONSTRING_H
#define _LIBPKMGC_BASE_POKEMONSTRING_H
#include <LibPkmGC/Core/IntegerTypes.h>
#include <algorithm>
namespace LibPkmGC {
namespace Base {
// Commands (scroll, color etc...) are NOT supported
class LIBPKMGC_DECL PokemonString {
public:
PokemonString(void);
virtual ~PokemonString(void);
virtual PokemonString& operator=(PokemonString const& other);
virtual PokemonString* clone(void) const = 0;
virtual PokemonString* create(void) const = 0;
virtual void fromUTF8(const char* str = NULL) = 0;
virtual const char* toUTF8(void) const = 0;
virtual size_t size(void) const = 0; // number of characters, not counting NULL
operator const char*(void) const;
virtual void load(u8* data, size_t nb) = 0; // nb: number of characters, not counting NULL
virtual void save(u8* data, size_t nb) const = 0;
protected:
PokemonString(PokemonString const& other);
mutable bool hasChanged;
mutable char* _str;
mutable size_t strSz, strCapacity;
void resizeStr(void) const;
};
}
}
#endif

View File

@ -0,0 +1,32 @@
#ifndef _LIBPKMGC_COLOSSEUM_BAG_DATA_H
#define _LIBPKMGC_COLOSSEUM_BAG_DATA_H
#include <LibPkmGC/GC/Common/BagData.h>
namespace LibPkmGC {
namespace Colosseum {
class LIBPKMGC_DECL BagData :
public GC::BagData
{
public:
static const size_t size = 0x300;
BagData(void);
BagData(BagData const& other);
BagData(const u8* inData);
~BagData();
void swap(BagData& other);
BagData* clone(void) const;
BagData* create(void) const;
private:
BagData(XD::BagData const&);
};
}
}
#endif

View File

@ -0,0 +1,41 @@
#ifndef _LIBPKMGC_COLOSSEUM_BATTLE_MODE_DATA_H
#define _LIBPKMGC_COLOSSEUM_BATTLE_MODE_DATA_H
#include <LibPkmGC/GC/Common/BattleModeData.h>
#include <LibPkmGC/Colosseum/Common/GroupBattleRule.h>
namespace LibPkmGC {
namespace Colosseum {
/*
??
0xc16c: Colosseum::GroupBattleRules rules[26]
??
*/
class LIBPKMGC_DECL BattleModeData :
public GC::BattleModeData
{
public:
static const size_t size = 0xcc2c;
BattleModeData(void);
BattleModeData(BattleModeData const& other);
BattleModeData(const u8* inData);
~BattleModeData();
BattleModeData* clone(void) const;
BattleModeData* create(void) const;
void save(void);
protected:
void loadFields(void);
private:
BattleModeData(XD::BattleModeData const& other);
};
}
}
#endif

View File

@ -0,0 +1,31 @@
#ifndef _LIBPKMGC_COLOSSEUM_DAYCARE_DATA_H
#define _LIBPKMGC_COLOSSEUM_DAYCARE_DATA_H
#include <LibPkmGC/GC/Common/DaycareData.h>
#include <LibPkmGC/Colosseum/Common/Pokemon.h>
namespace LibPkmGC {
namespace Colosseum {
class LIBPKMGC_DECL DaycareData :
public GC::DaycareData
{
public:
static const size_t size = 0x140;
DaycareData(void);
DaycareData(const u8* inData);
DaycareData(DaycareData const& other);
~DaycareData(void);
DaycareData* clone(void) const;
DaycareData* create(void) const;
DaycareData(XD::DaycareData const& other);
private:
void loadFields(void);
};
}
}
#endif

View File

@ -0,0 +1,10 @@
#pragma once
#include <LibPkmGC/Colosseum/Common/PlayerData.h>
#include <LibPkmGC/Colosseum/Common/PCData.h>
#include <LibPkmGC/Colosseum/Common/PlayerData.h>
#include <LibPkmGC/Colosseum/Common/MailboxData.h>
#include <LibPkmGC/Colosseum/Common/DaycareData.h>
#include <LibPkmGC/Colosseum/Common/StrategyMemoData.h>
#include <LibPkmGC/Colosseum/Common/BattleModeData.h>

View File

@ -0,0 +1,36 @@
#ifndef _LIBPKMGC_COLOSSEUM_GROUP_BATTLE_RULE_H
#define _LIBPKMGC_COLOSSEUM_GROUP_BATTLE_RULE_H
#include <LibPkmGC/GC/Common/GroupBattleRule.h>
namespace LibPkmGC {
namespace Colosseum {
class LIBPKMGC_DECL GroupBattleRule :
public GC::GroupBattleRule
{
public:
static const size_t size = 0x54;
GroupBattleRule(const u8* inData);
GroupBattleRule(GroupBattleRule const& other);
GroupBattleRule(void);
~GroupBattleRule();
// void swap(GroupBattleRule& other);
GroupBattleRule* clone(void) const;
GroupBattleRule* create(void) const;
void save(void);
protected:
void loadFields(void);
private:
GroupBattleRule(XD::GroupBattleRule const& other);
};
}
}
#endif

View File

@ -0,0 +1,42 @@
#ifndef _LIBPKMGC_COLOSSEUM_MAILBOX_DATA
#define _LIBPKMGC_COLOSSEUM_MAILBOX_DATA
#include <LibPkmGC/GC/Common/MailboxData.h>
namespace LibPkmGC {
namespace Colosseum {
/*
0x00: u16 mails[32] = mailID or 255 if empty; 0x1f: invisible mail
0x400: u16 nbMails
0x402: u8 ?
0x442: u8 ?
*/
class LIBPKMGC_DECL MailboxData :
public GC::MailboxData
{
public:
static const size_t size = 0x448;
MailboxData(void);
MailboxData(MailboxData const& other);
MailboxData(const u8* inData);
~MailboxData(void);
MailboxData* clone(void) const;
MailboxData* create(void) const;
void save(void);
protected:
void loadFields(void);
private:
MailboxData(XD::MailboxData const&);
};
}
}
#endif

View File

@ -0,0 +1,38 @@
#ifndef _LIBPKMGC_COLOSSEUM_PC_DATA_H
#define _LIBPKMGC_COLOSSEUM_PC_DATA_H
#include <LibPkmGC/GC/Common/PCData.h>
#include <LibPkmGC/Colosseum/Common/PokemonBox.h>
namespace LibPkmGC {
namespace Colosseum {
/*
0x00: PokemonBox boxes[8]
0x6dec -- end(0x7198): items[235]
*/
class LIBPKMGC_DECL PCData :
public GC::PCData
{
public:
static const size_t size = 0x7198;
PCData(void);
PCData(PCData const& other);
PCData(const u8* inData);
~PCData(void);
PCData* clone(void) const;
PCData* create(void) const;
void save(void);
protected:
void loadFields(void);
private:
PCData(XD::PCData const&);
};
}
}
#endif

View File

@ -0,0 +1,49 @@
#ifndef _LIBPKMGC_COLOSSEUM_PLAYER_DATA_H
#define _LIBPKMGC_COLOSSEUM_PLAYER_DATA_H
#include <LibPkmGC/GC/Common/PlayerData.h>
#include <LibPkmGC/Colosseum/Common/Pokemon.h>
#include <LibPkmGC/Colosseum/Common/BagData.h>
namespace LibPkmGC {
namespace Colosseum {
/*
0x00 -- 0x2b: trainer name (10+1 chars) + copy
0x2c: u16 SID
0x2e: u16 TID
0x30: Pokémon Party (6*0xc4)
0x780: bag
0xa80: u8 trainerGender
0xa84: u32 money
0xa88: u32 pkCoupons + copy
*/
class LIBPKMGC_DECL PlayerData :
public GC::PlayerData
{
public:
static const size_t size = 0xb18;
PlayerData(void);
PlayerData(PlayerData const& other);
PlayerData(const u8* inData);
~PlayerData(void);
PlayerData* clone(void) const;
PlayerData* create(void) const;
void save(void);
protected:
void loadFields(void);
private:
PlayerData(XD::PlayerData const& other);
};
}
}
#endif

View File

@ -0,0 +1,92 @@
#ifndef _LIBPKMGC_COLO_POKEMON_H
#define _LIBPKMGC_COLO_POKEMON_H
#include <LibPkmGC/GC/Common/Pokemon.h>
namespace LibPkmGC {
namespace Colosseum {
/*
pkm
0x00: u16 index
0x02 : u16 ? ? ? ? (0 on shadow pkm)
0x04 : u32 PID
0x08 : VersionInfo version(4 bytes)
0x0c : u16 locationCaught
0x0e : u8 levelMet
0x0f : u8 ballCaughtWith
0x10 : u8 OTGender
0x11 -- 0x13 : ? ? ? ? ?
0x14 : u16 SID
0x16 : u16 TID
0x18 : OT Name(10 + 1 chars, limited to 8 in game)
0x2e : Pkm Name(10 + 1, or 5 in game for jap.versions)
0x44 : Pkm name backup
0x5a -- 0x5b : u16 = field 0x02 backup
0x5c : u32 experience
0x60 : u8 currentLevel
0x61 -- 0x64 : ? ?
0x65 : u16 status (u8 on XD)
0x65 -- 0x67 : ? ?
0x68 : u32 ? ?
0x6c--0x78 ? ?
0x78 : moves info
0x88 : u16 itemHeld
0x8a : u16 currentHP
0x8c : u16 stats[6]
0x98 : u16 EVs[6]
0xa4 : u16 IVs[6]
0xb0 : u16 happinness
0xb2 : u8 contestsStats[5]
0xb7 : u8 contestsRibbons[5]
0xbc : u8 contestLuster
0xbd : u8 specialRibbons[12]
0xc9 : u8 unused ?
0xca : u8 pkrsStatus
0xcb : u8 ?
0xcc : u8 abilityUsed
0xcd : u16 ? ?
0xcf : u8 marks
// shadow pkm data ?
0xd0--0xd7 : ? ?
0xd8 : u16 shadowPkmID
0xda--0xdb : padding ?
0xdc : s32 purificationCounter
0xe0 : u32 expStored
0xe4 : u16 ? ?
0xe6 : u16 ? ?
0xfb : u8 encounterType
0xfc--0x138 : ? ? ? ? ? ? ? ? ? ?
*/
class LIBPKMGC_DECL Pokemon : public GC::Pokemon {
public:
static const size_t size = 0x138;
Pokemon(void);
Pokemon(const u8* inData);
Pokemon(Pokemon const& other);
~Pokemon(void);
Pokemon* clone(void) const;
Pokemon* create(void) const;
void save(void);
void swap(Pokemon& other);
Pokemon& operator=(Pokemon const& other);
bool hasSpecialAbility(void) const;
void setSpecialAbilityStatus(bool status);
bool specialAbilityStatus;
Pokemon(XD::Pokemon const& other);
Pokemon& operator=(GC::Pokemon const& other);
void swap(GC::Pokemon & other);
protected:
void loadFields(void);
};
}
}
#endif

View File

@ -0,0 +1,34 @@
#ifndef _LIBPKMGC_COLOSSEUM_POKEMON_BOX_H
#define _LIBPKMGC_COLOSSEUM_POKEMON_BOX_H
#include <LibPkmGC/GC/Common/PokemonBox.h>
#include <LibPkmGC/Colosseum/Common/Pokemon.h>
namespace LibPkmGC {
namespace Colosseum {
class LIBPKMGC_DECL PokemonBox :
public GC::PokemonBox
{
public:
static const size_t size = 0x24a4;
PokemonBox(void);
PokemonBox(PokemonBox const& other);
PokemonBox(const u8* inData);
~PokemonBox(void);
PokemonBox* clone(void) const;
PokemonBox* create(void) const;
void save(void);
PokemonBox(XD::PokemonBox const& other);
protected:
void loadFields(void);
};
}
}
#endif

View File

@ -0,0 +1,35 @@
#ifndef _LIBPKMGC_COLOSSEUM_STRATEGY_MEMO_DATA_H
#define _LIBPKMGC_COLOSSEUM_STRATEGY_MEMO_DATA_H
#include <LibPkmGC/GC/Common/StrategyMemoData.h>
#include <LibPkmGC/Colosseum/Common/StrategyMemoEntry.h>
namespace LibPkmGC {
namespace Colosseum {
class LIBPKMGC_DECL StrategyMemoData :
public GC::StrategyMemoData
{
public:
static const size_t size = 0x1774;
~StrategyMemoData(void);
bool isXD(void) const;
StrategyMemoData(void);
StrategyMemoData(const u8* inData);
StrategyMemoData(StrategyMemoData const& other);
StrategyMemoData* clone(void) const;
StrategyMemoData* create(void) const;
void save(void);
StrategyMemoData(XD::StrategyMemoData const& other);
protected:
void loadFields(void);
};
}
}
#endif

View File

@ -0,0 +1,30 @@
#ifndef _LIBPKMGC_COLOSSEUM_STRATEGY_MEMO_ENTRY_H
#define _LIBPKMGC_COLOSSEUM_STRATEGY_MEMO_ENTRY_H
#include <LibPkmGC/GC/Common/StrategyMemoEntry.h>
namespace LibPkmGC {
namespace Colosseum {
class LIBPKMGC_DECL StrategyMemoEntry :
public GC::StrategyMemoEntry
{
public:
static const size_t size = 12;
~StrategyMemoEntry(void);
StrategyMemoEntry(void);
StrategyMemoEntry(const u8* inData);
bool isXD(void) const;
StrategyMemoEntry* clone(void) const;
StrategyMemoEntry* create(void) const;
bool isInfoPartial(void) const;
void setInfoCompleteness(bool partial);
};
}
}
#endif

View File

@ -0,0 +1,38 @@
#ifndef _LIBPKMGC_COLOSSEUM_SAVE_EDITING_SAVE_H
#define _LIBPKMGC_COLOSSEUM_SAVE_EDITING_SAVE_H
#include <LibPkmGC/GC/SaveEditing/Save.h>
#include <LibPkmGC/Colosseum/SaveEditing/SaveSlot.h>
namespace LibPkmGC {
namespace Colosseum {
namespace SaveEditing {
class LIBPKMGC_DECL Save :
public GC::SaveEditing::Save
{
public:
static const size_t size = 0x60000;
Save(void);
Save(Save const& other);
Save(const u8* inData, bool hasGCIData_ = false, bool isDecrypted = false);
//~Save(void);
Save* clone(void) const;
Save* create(void) const;
void save(void);
protected:
void loadFields(void);
private:
Save(XD::SaveEditing::Save const&);
};
}
}
}
#endif

View File

@ -0,0 +1,81 @@
#ifndef _LIBPKMGC_COLOSSEUM_SAVE_EDITING_SAVE_SLOT_H
#define _LIBPKMGC_COLOSSEUM_SAVE_EDITING_SAVE_SLOT_H
#include <LibPkmGC/GC/SaveEditing/SaveSlot.h>
#include <LibPkmGC/Colosseum/Common/Everything.h>
namespace LibPkmGC {
namespace Colosseum {
namespace SaveEditing {
/*
size = 0x1e000
0x00: u32 magic
0x04: u32 saveCount
** Metadata / game config
0x08: VersionInfo version
0x0c: u32 headerChecksum
0x10: u64/u32[2] memcardUID : memcard[0:8] xor memcard[8:16] xor memcard[16:24] iirc
0x18: **ENCRYPTED DATA**
0x18: u32 storyModeSaveCount // saveCount minus the number of times the rules were saved
0x20: u32 = 0
0x31: u8 noRumble
0x32: u16 titleScreenLanguage;
0x78: **END OF METADATA
0x78: substructures. In Pokémon Colosseum, they are strictly contiguous with no trash bytes in between.
(end)-60: **END OF ENCRYPTED DATA**
(end)-60: u8 checksum[20]; // sha1 digest
(end)-40: u8 randomBytes[40];
*/
class LIBPKMGC_DECL SaveSlot :
public GC::SaveEditing::SaveSlot
{
public:
static const size_t size = 0x1e000;
SaveSlot(void);
SaveSlot(const SaveSlot& other);
SaveSlot(const u8* inData, bool isDecrypted = false);
~SaveSlot(void);
SaveSlot* clone(void) const;
SaveSlot* create(void) const;
void swap(SaveSlot& other);
SaveSlot& operator=(SaveSlot const& other);
void save(void);
bool checkChecksum(bool fix = false);
bool checkHeaderChecksum(bool fix = false);
std::pair<bool, bool> checkBothChecksums(bool fixGlobalChecksum = false, bool fixHeaderChecksum = false);
bool isCorrupt(void);
void saveEncrypted(u8* outBuf);
s32 storyModeSaveCount;
u8 checksum[20]; // digest
protected:
void loadData(u32 flags = 0);
void deleteFields(void);
void loadFields(void);
private:
void _deleteFields_extension(void);
SaveSlot(XD::SaveEditing::SaveSlot const&);
};
}
}
}
#endif

View File

@ -0,0 +1,24 @@
#ifndef _LIBPKMGC_CONFIG_H
#define _LIBPKMGC_CONFIG_H
// _LICENSE_
#include <boost/config/warning_disable.hpp>
#include <boost/config.hpp>
#include <boost/predef.h>
#define LIBPKMGC_VERSION 1000000
#define LIBPKMGC_VERSION_MAJOR ((LIBPKMGC_VERSION / 1000000) % 1000)
#define LIBPKMGC_VERSION_MINOR ((LIBPKMGC_VERSION / 1000) % 1000)
#define LIBPKMGC_VERSION_BUILD (LIBPKMGC_VERSION % 1000)
#if defined(LIBPKMGC_DYN_LIB) && !defined(LIBPKMGC_STATIC_LIB)
# ifdef LIBPKMGC_SOURCE
# define LIBPKMGC_DECL BOOST_SYMBOL_EXPORT
# else
# define LIBPKMGC_DECL BOOST_SYMBOL_IMPORT
# endif
#else
# define LIBPKMGC_DECL
#endif
#endif

View File

@ -0,0 +1,16 @@
#ifndef _LIBPKMGC_CRYPTO_H
#define _LIBPKMGC_CRYPTO_H
#include <LibPkmGC/Core/IntegerTypes.h>
#include <string>
namespace LibPkmGC {
namespace Crypto {
LIBPKMGC_DECL void sha1(const u8* start, const u8* end, u8 digest[20]);
LIBPKMGC_DECL std::string sha1(const u8* data, const u8* end);
}
}
#endif

View File

@ -0,0 +1,28 @@
#ifndef _LIBPKMGC_ABILITY_NAMES_H
#define _LIBPKMGC_ABILITY_NAMES_H
#include <LibPkmGC/Core/Config.h>
namespace LibPkmGC {
namespace Localization {
namespace Detail {
namespace Abilities {
#define NB_NAMES 78
extern const char LIBPKMGC_DECL *englishNames[NB_NAMES];
extern const char LIBPKMGC_DECL *frenchNames[NB_NAMES];
extern const char LIBPKMGC_DECL *germanNames[NB_NAMES];
extern const char LIBPKMGC_DECL *italianNames[NB_NAMES];
extern const char LIBPKMGC_DECL *spanishNames[NB_NAMES];
extern const char LIBPKMGC_DECL *japaneseNames[NB_NAMES];
extern const char **names[7];
#undef NB_NAMES
}
}
}
}
#endif

View File

@ -0,0 +1,120 @@
template<typename I, typename E, typename OutputIteratorType>
void fromEnumInteger(OutputIteratorType const& _dest, E const& _integer, size_t _integerSize = sizeof(I)){
return fromInteger<I,OutputIteratorType>(_dest, (I) _integer, _integerSize);
}
template<typename I, typename E, typename IteratorType>
E toEnumInteger(IteratorType const& _bufferIterator, size_t _integerSize = sizeof(I)){
return (E) toInteger<I,IteratorType>(_bufferIterator, _integerSize);
}
template<typename I, typename OutputIteratorType>
void fromBoolInteger(OutputIteratorType const& _dest, bool _integer, size_t _integerSize = sizeof(I)){
return fromInteger<I,OutputIteratorType>(_dest, (I) (_integer) ? 1 : 0, _integerSize);
}
template<typename I, typename IteratorType>
bool toBoolInteger(IteratorType const& _bufferIterator, size_t _integerSize = sizeof(I)){
return toInteger<I,IteratorType>(_bufferIterator, _integerSize) != 0;
}
template<typename IteratorType, typename OutputIteratorType>
void fromArrayOfIntegers(OutputIteratorType const& _dest, IteratorType const& _integers,
IteratorType const& _integersEnd,
size_t _integerSize = sizeof(typename std::iterator_traits<IteratorType>::value_type)){
typedef typename std::iterator_traits<IteratorType>::value_type I;
size_t _count = std::distance(_integers, _integersEnd);
IteratorType it(_integers);
OutputIteratorType dst(_dest);
for(size_t i = 0; i < _count; i++){
fromInteger<I,OutputIteratorType>(dst, *it, _integerSize);
++it;
std::advance(dst, _integerSize);
}
}
template<typename I, typename IteratorType, typename OutputIteratorType>
void fromArrayOfEnumIntegers(OutputIteratorType const& _dest, IteratorType const& _integers,
IteratorType const& _integersEnd,
size_t _integerSize = sizeof(I)){
typedef typename std::iterator_traits<IteratorType>::value_type E;
size_t _count = std::distance(_integers, _integersEnd);
IteratorType it(_integers);
OutputIteratorType dst(_dest);
for(size_t i = 0; i < _count; i++){
fromEnumInteger<I,E,OutputIteratorType>(dst, *it, _integerSize);
++it;
std::advance(dst, _integerSize);
}
}
template<typename I, typename IteratorType, typename OutputIteratorType>
void fromArrayOfBoolIntegers(OutputIteratorType const& _dest, IteratorType const& _integers,
IteratorType const& _integersEnd,
size_t _integerSize = sizeof(I)){
size_t _count = std::distance(_integers, _integersEnd);
IteratorType it(_integers);
OutputIteratorType dst(_dest);
for(size_t i = 0; i < _count; i++){
fromBoolInteger<I,OutputIteratorType>(dst, *it, _integerSize);
++it;
std::advance(dst, _integerSize);
}
}
template<typename IteratorType, typename OutputIteratorType>
void toArrayOfIntegers(OutputIteratorType const& _dest, IteratorType const& _bufferIterator,
IteratorType const& _bufferIteratorEnd,
size_t _integerSize = sizeof(typename std::iterator_traits<OutputIteratorType>::value_type)){
// size_t _count = std::distance(_bufferIterator, bufferIteratorEnd);
typedef typename std::iterator_traits<OutputIteratorType>::value_type I;
IteratorType it2(_bufferIterator);
OutputIteratorType dst(_dest);
for(; it2 != _bufferIteratorEnd; std::advance(it2, _integerSize)){
*dst = toInteger<I, IteratorType>(it2, _integerSize);
++dst;
}
}
template<typename I, typename IteratorType, typename OutputIteratorType>
void toArrayOfEnumIntegers(OutputIteratorType const& _dest, IteratorType const& _bufferIterator,
IteratorType const& _bufferIteratorEnd,
size_t _integerSize = sizeof(I)){
// size_t _count = std::distance(_bufferIterator, bufferIteratorEnd);
typedef typename std::iterator_traits<OutputIteratorType>::value_type E;
IteratorType it2(_bufferIterator);
OutputIteratorType dst(_dest);
for(; it2 != _bufferIteratorEnd; std::advance(it2, _integerSize)){
*dst = toEnumInteger<I, E, IteratorType>(it2, _integerSize);
++dst;
}
}
template<typename I, typename IteratorType, typename OutputIteratorType>
void toArrayOfBoolIntegers(OutputIteratorType const& _dest, IteratorType const& _bufferIterator,
IteratorType const& _bufferIteratorEnd,
size_t _integerSize = sizeof(I)){
// size_t _count = std::distance(_bufferIterator, bufferIteratorEnd);
IteratorType it2(_bufferIterator);
OutputIteratorType dst(_dest);
for(; it2 != _bufferIteratorEnd; std::advance(it2, _integerSize)){
*dst = toBoolInteger<I, IteratorType>(it2, _integerSize);
++dst;
}
}

View File

@ -0,0 +1,63 @@
#ifndef _LIBPKMGC_ITEM_NAMES_H
#define _LIBPKMGC_ITEM_NAMES_H
#include <LibPkmGC/Core/Config.h>
namespace LibPkmGC {
namespace Localization {
namespace Detail {
namespace GivableItems {
#define NB_NAMES 245
extern const char LIBPKMGC_DECL *englishNames[NB_NAMES];
extern const char LIBPKMGC_DECL *frenchNames[NB_NAMES];
extern const char LIBPKMGC_DECL *germanNames[NB_NAMES];
extern const char LIBPKMGC_DECL *italianNames[NB_NAMES];
extern const char LIBPKMGC_DECL *spanishNames[NB_NAMES];
extern const char LIBPKMGC_DECL *japaneseNames[NB_NAMES];
extern const char **names[7];
#undef NB_NAMES
}
namespace ColosseumExclusiveItems { // Some items are common to Col. and XD
#define NB_NAMES 48
extern const char LIBPKMGC_DECL *englishNames[NB_NAMES];
extern const char LIBPKMGC_DECL *frenchNames[NB_NAMES];
extern const char LIBPKMGC_DECL *germanNames[NB_NAMES];
extern const char LIBPKMGC_DECL *italianNames[NB_NAMES];
extern const char LIBPKMGC_DECL *spanishNames[NB_NAMES];
extern const char LIBPKMGC_DECL *japaneseNames[NB_NAMES];
extern const char **names[7];
#undef NB_NAMES
}
namespace XDExclusiveItems {
extern const size_t namesByIndex[94];
// BEWARE, these ones are not in the correct order
#define NB_NAMES 91
extern const char LIBPKMGC_DECL *englishNames[NB_NAMES];
extern const char LIBPKMGC_DECL *frenchNames[NB_NAMES];
extern const char LIBPKMGC_DECL *germanNames[NB_NAMES];
extern const char LIBPKMGC_DECL *italianNames[NB_NAMES];
extern const char LIBPKMGC_DECL *spanishNames[NB_NAMES];
extern const char LIBPKMGC_DECL *japaneseNames[NB_NAMES];
extern const char **names[7];
#undef NB_NAMES
}
}
}
}
#endif

View File

@ -0,0 +1,28 @@
#ifndef _LIBPKMGC_MOVE_NAMES_H
#define _LIBPKMGC_MOVE_NAMES_H
#include <LibPkmGC/Core/Config.h>
namespace LibPkmGC {
namespace Localization {
namespace Detail {
namespace Moves {
#define NB_NAMES 355
extern const char LIBPKMGC_DECL *englishNames[NB_NAMES];
extern const char LIBPKMGC_DECL *frenchNames[NB_NAMES];
extern const char LIBPKMGC_DECL *germanNames[NB_NAMES];
extern const char LIBPKMGC_DECL *italianNames[NB_NAMES];
extern const char LIBPKMGC_DECL *spanishNames[NB_NAMES];
extern const char LIBPKMGC_DECL *japaneseNames[NB_NAMES];
extern const char **names[7];
#undef NB_NAMES
}
}
}
}
#endif

View File

@ -0,0 +1,183 @@
#include <LibPkmGC/Core/Detail/NatureNames.h>
namespace LibPkmGC {
namespace Localization {
namespace Detail {
namespace Natures {
const char **names[7] = { NULL, japaneseNames, englishNames, germanNames, frenchNames, italianNames, spanishNames };
const char* englishNames[25] = {
"HARDY",
"LONELY",
"BRAVE",
"ADAMANT",
"NAUGHTY",
"BOLD",
"DOCILE",
"RELAXED",
"IMPISH",
"LAX",
"TIMID",
"HASTY",
"SERIOUS",
"JOLLY",
"NAIVE",
"MODEST",
"MILD",
"QUIET",
"BASHFUL",
"RASH",
"CALM",
"GENTLE",
"SASSY",
"CAREFUL",
"QUIRKY"
};
const char* frenchNames[25] = {
"HARDI",
"SOLO",
"BRAVE",
"RIGIDE",
"MAUVAIS",
"ASSURE",
"DOCILE",
"RELAX",
"MALIN",
"LACHE",
"TIMIDE",
"PRESSE",
"SERIEUX",
"JOVIAL",
"NAIF",
"MODESTE",
"DOUX",
"DISCRET",
"PUDIQUE",
"FOUFOU",
"CALME",
"GENTIL",
"MALPOLI",
"PRUDENT",
"BIZARRE",
};
const char* germanNames[25] = {
"ROBUST",
"SOLO",
"MUTIG",
"HART",
"FRECH",
"K\xC3\x9CHN",
"SANFT",
"LOCKER",
"PFIFFIG",
"LASCH",
"SCHEU",
"HASTIG",
"ERNST",
"FROH",
"NAIV",
"M\xC3\x84SSIG",
"MILD",
"RUHIG",
"ZAGHAFT",
"HITZIG",
"STILL",
"ZART",
"FORSCH",
"SACHT",
"KAUZIG",
};
const char* italianNames[25] = {
"ARDITA",
"SCHIVA",
"AUDACE",
"DECISA",
"BIRBONA",
"SICURA",
"DOCILE",
"PLACIDA",
"SCALTRA",
"FIACCA",
"TIMIDA",
"LESTA",
"SERIA",
"ALLEGRA",
"INGENUA",
"MODESTA",
"MITE",
"QUIETA",
"RITROSA",
"ARDENTE",
"CALMA",
"GENTILE",
"VIVACE",
"CAUTA",
"FURBA",
};
const char* spanishNames[25] = {
"FUERTE",
"HURA\xC3\x91""A",
"AUDAZ",
"FIRME",
"P\xC3\x8D""CARA",
"OSADA",
"D\xC3\x93""CIL",
"PL\xC3\x81""CIDA",
"AGITADA",
"FLOJA",
"MIEDOSA",
"ACTIVA",
"SERIA",
"ALEGRE",
"INGENUA",
"MODESTA",
"AFABLE",
"MANSA",
"T\xC3\x8DMIDA",
"ALOCADA",
"SERENA",
"AMABLE",
"GROSERA",
"CAUTA",
"RARA",
};
const char* japaneseNames[25] = {
"\xe3\x81\x8c\xe3\x82\x93\xe3\x81\xb0\xe3\x82\x8a\xe3\x82\x84",
"\xe3\x81\x95\xe3\x81\xbf\xe3\x81\x97\xe3\x81\x8c\xe3\x82\x8a",
"\xe3\x82\x86\xe3\x81\x86\xe3\x81\x8b\xe3\x82\x93",
"\xe3\x81\x84\xe3\x81\x98\xe3\x81\xa3\xe3\x81\xb1\xe3\x82\x8a",
"\xe3\x82\x84\xe3\x82\x93\xe3\x81\xa1\xe3\x82\x83",
"\xe3\x81\x9a\xe3\x81\xb6\xe3\x81\xa8\xe3\x81\x84",
"\xe3\x81\x99\xe3\x81\xaa\xe3\x81\x8a",
"\xe3\x81\xae\xe3\x82\x93\xe3\x81\x8d",
"\xe3\x82\x8f\xe3\x82\x93\xe3\x81\xb1\xe3\x81\x8f",
"\xe3\x81\xae\xe3\x81\x86\xe3\x81\xa6\xe3\x82\x93\xe3\x81\x8d",
"\xe3\x81\x8a\xe3\x81\x8f\xe3\x81\xb3\xe3\x82\x87\xe3\x81\x86",
"\xe3\x81\x9b\xe3\x81\xa3\xe3\x81\x8b\xe3\x81\xa1",
"\xe3\x81\xbe\xe3\x81\x98\xe3\x82\x81",
"\xe3\x82\x88\xe3\x81\x86\xe3\x81\x8d",
"\xe3\x82\x80\xe3\x81\x98\xe3\x82\x83\xe3\x81\x8d",
"\xe3\x81\xb2\xe3\x81\x8b\xe3\x81\x88\xe3\x82\x81",
"\xe3\x81\x8a\xe3\x81\xa3\xe3\x81\xa8\xe3\x82\x8a",
"\xe3\x82\x8c\xe3\x81\x84\xe3\x81\x9b\xe3\x81\x84",
"\xe3\x81\xa6\xe3\x82\x8c\xe3\x82\x84",
"\xe3\x81\x86\xe3\x81\xa3\xe3\x81\x8b\xe3\x82\x8a\xe3\x82\x84",
"\xe3\x81\x8a\xe3\x81\xa0\xe3\x82\x84\xe3\x81\x8b",
"\xe3\x81\x8a\xe3\x81\xa8\xe3\x81\xaa\xe3\x81\x97\xe3\x81\x84",
"\xe3\x81\xaa\xe3\x81\xbe\xe3\x81\x84\xe3\x81\x8d",
"\xe3\x81\x97\xe3\x82\x93\xe3\x81\xa1\xe3\x82\x87\xe3\x81\x86",
"\xe3\x81\x8d\xe3\x81\xbe\xe3\x81\x90\xe3\x82\x8c",
};
}
}
}
}

View File

@ -0,0 +1,28 @@
#ifndef _LIBPKMGC_NATURE_NAMES_H
#define _LIBPKMGC_NATURE_NAMES_H
#include <LibPkmGC/Core/Config.h>
namespace LibPkmGC {
namespace Localization {
namespace Detail {
namespace Natures {
#define NB_NAMES 25
extern const char LIBPKMGC_DECL *englishNames[NB_NAMES];
extern const char LIBPKMGC_DECL *frenchNames[NB_NAMES];
extern const char LIBPKMGC_DECL *germanNames[NB_NAMES];
extern const char LIBPKMGC_DECL *italianNames[NB_NAMES];
extern const char LIBPKMGC_DECL *spanishNames[NB_NAMES];
extern const char LIBPKMGC_DECL *japaneseNames[NB_NAMES];
extern const char **names[7];
#undef NB_NAMES
}
}
}
}
#endif

View File

@ -0,0 +1,29 @@
#ifndef _LIBPKMGC_SPECIES_NAMES_H
#define _LIBPKMGC_SPECIES_NAMES_H
#include <LibPkmGC/Core/Config.h>
namespace LibPkmGC {
namespace Localization {
namespace Detail {
namespace Species {
#define NB_NAMES 388
extern const char LIBPKMGC_DECL *englishNames[NB_NAMES];
extern const char LIBPKMGC_DECL *frenchNames[NB_NAMES];
extern const char LIBPKMGC_DECL *germanNames[NB_NAMES];
extern const char LIBPKMGC_DECL *italianNames[NB_NAMES]; // english names
extern const char LIBPKMGC_DECL *spanishNames[NB_NAMES]; // english names
extern const char LIBPKMGC_DECL *japaneseNames[NB_NAMES];
extern const char **names[7];
#undef NB_NAMES
}
}
}
}
#endif

View File

@ -0,0 +1,147 @@
#ifndef _LIBPKMGC_STRUCT_MACROS_H
#define _LIBPKMGC_STRUCT_MACROS_H
#include <LibPkmGC/Core/IntegerManip.h>
#include <boost/core/enable_if.hpp>
#ifdef LIBPKMGC_SOURCE
# define LIBPKMGC_DEFINE_IMPL_HELPER_MACROS
#endif
#ifdef LIBPKMGC_DEFINE_IMPL_HELPER_MACROS
#ifndef BUFFER_NAME
#define BUFFER_NAME data
#endif
#ifndef TARGET_ENDIANNESS
#define TARGET_ENDINANNESS BE
#endif
#define SM_H_TMP_NS_EVAL() TARGET_ENDINANNESS
#define SM_H_TMP_NS() LibPkmGC::IntegerManip::SM_H_TMP_NS_EVAL()
#define LD_FIELD(type,fld,off) fld = SM_H_TMP_NS()::toInteger<type, u8*>(BUFFER_NAME+off)
#define LD_FIELD_E(type,fld,off,etype) fld = SM_H_TMP_NS()::toEnumInteger<type, etype, u8*>(BUFFER_NAME+off)
#define LD_FIELD_B(type,fld,off) fld = SM_H_TMP_NS()::toBoolInteger<type,u8*>(BUFFER_NAME+off)
#define LD_ARRAY(type,ar,sz,off) SM_H_TMP_NS()::toArrayOfIntegers<u8*,type*>(ar, BUFFER_NAME+off, BUFFER_NAME+off+(sizeof(type)*sz))
#define LD_ARRAY_E(type,ar,sz,off,etype) SM_H_TMP_NS()::toArrayOfEnumIntegers<type,u8*,etype*>(ar, BUFFER_NAME+off, BUFFER_NAME+off+(sizeof(type)*sz))
#define LD_ARRAY_B(type,ar,sz,off) SM_H_TMP_NS()::toArrayOfBoolIntegers<type,u8*,bool*>(ar, BUFFER_NAME+off, BUFFER_NAME+off+(sizeof(type)*sz))
#define SV_FIELD(type,fld,off) SM_H_TMP_NS()::fromInteger<type, u8*>(BUFFER_NAME+off, fld)
#define SV_FIELD_E(type,fld,off,etype) SM_H_TMP_NS()::fromEnumInteger<type, etype, u8*>(BUFFER_NAME+off, fld)
#define SV_FIELD_B(type,fld,off) SM_H_TMP_NS()::fromBoolInteger<type,u8*>(BUFFER_NAME+off, fld)
#define SV_ARRAY(type,ar,sz,off) SM_H_TMP_NS()::fromArrayOfIntegers<type*, u8*>(BUFFER_NAME+off, ar, ar+sz)
#define SV_ARRAY_E(type,ar,sz,off,etype) SM_H_TMP_NS()::fromArrayOfEnumIntegers<type,etype*, u8*>(BUFFER_NAME+off, ar, ar+sz)
#define SV_ARRAY_B(type,ar,sz,off) SM_H_TMP_NS()::toArrayOfBoolIntegers<type, bool*, u8*>(BUFFER_NAME+off, ar, ar+sz)
#define LD_SUBSTRUCTURE(type, fld, off) fld = new type(data + off)
#define LD_SUBSTRUCTURE_ARRAY(type, ar, sz, off) for(size_t i__ = 0; i__ < sz; ++i__) LD_SUBSTRUCTURE(type, ar[i__], off+type::size*i__);
#define LD_SUBSTRUCTURE_ARRAY2(type, ar, sz, off) for(size_t i__ = 0; i__ < sz; ++i__) LD_SUBSTRUCTURE(type, ar[i__], off+ar[i__]->getSize()*i__);
#define SV_SUBSTRUCTURE(type, fld, off) fld->save(); std::copy(fld->data, fld->data + type::size, data + off);
#define SV_SUBSTRUCTURE2(type, fld, off) fld->save(); std::copy(fld->data, fld->data + fld->getSize(), data + off);
#define SV_SUBSTRUCTURE_ARRAY(type, ar, sz, off) for(size_t i__ = 0; i__ < sz; ++i__) { SV_SUBSTRUCTURE(type, ar[i__], off+type::size*i__); }
//#define SV_SUBSTRUCTURE_ARRAY2(type, ar, sz, off) for(size_t i__ = 0; i__ < sz; ++i__) { SV_SUBSTRUCTURE2(type, ar[i__], off+ar[i__]->getSize()*i__); }
#define CP(fld) this->fld = other.fld
#define CP_ARRAY(fld, sz) std::copy(other.fld, other.fld+sz, fld)
#define SW(fld) std::swap(this->fld, other.fld)
#define SW_ARRAY(fld, sz) for(size_t i__0123 = 0; i__0123 < sz; ++i__0123) SW(fld[i__0123]);
#define ASSIGN_CP(fld) *(this->fld) = *(other.fld)
#define ASSIGN_ARRAY_CP(fld, sz) for(size_t i__1234 = 0; i__1234 < sz; ++i__1234) ASSIGN_CP(fld[i__1234]);
#define CL(fld) this->fld = other.fld->clone();
#define CL_ARRAY(fld, sz) for(size_t i__1234 = 0; i__1234 < sz; ++i__1234) CL(fld[i__1234]);
#define LIBPKMGC_GEN_CONVERTER_CTOR2(cls, flgs) \
Colosseum::cls::cls(XD::cls const& other) : GC::cls(Colosseum::cls::size){\
initWithEmptyData(flgs);\
GC::cls::operator=(other);\
}\
XD::cls::cls(Colosseum::cls const& other) : GC::cls(XD::cls::size){\
initWithEmptyData(flgs);\
GC::cls::operator=(other);\
}
#define LIBPKMGC_GEN_CONVERTER_CTOR(cls) LIBPKMGC_GEN_CONVERTER_CTOR2(cls, 0)
#define LIBPKMGC_GEN_UNIMPLEMENTED_CONVERTER_CTOR(cls)\
Colosseum::cls::cls(XD::cls const& other) : GC::cls(Colosseum::cls::size, 0){}\
XD::cls::cls(Colosseum::cls const& other) : GC::cls(XD::cls::size, 0){}
#define LIBPKMGC_GEN_UNIMPLEMENTED_SAVE_EDITING_CONVERTER_CTOR(cls)\
Colosseum::SaveEditing::cls::cls(XD::SaveEditing::cls const& other) : GC::SaveEditing::cls(Colosseum::SaveEditing::cls::size, 0){}\
XD::SaveEditing::cls::cls(Colosseum::SaveEditing::cls const& other) : GC::SaveEditing::cls(XD::SaveEditing::cls::size, 0){}
#define LIBPKMGC_GC_GEN_XD_VTF2(cls, flgs) \
cls& cls::operator=(GC::cls const& other){\
if(LIBPKMGC_IS_XD(cls,&other)) return (cls&) operator=((cls const&)other);\
else { deleteFields(); initWithEmptyData(flgs); return (cls&) GC::cls::operator=(other); }\
}\
void cls::swap(GC::cls & other){\
if(LIBPKMGC_IS_XD(cls,&other)) swap((cls&)other);\
else {cls obj((Colosseum::cls&)other); swap(obj); other.swap(obj);}\
}
#define LIBPKMGC_GC_GEN_COL_VTF2(cls, flgs) \
cls& cls::operator=(GC::cls const& other){\
if(LIBPKMGC_IS_COLOSSEUM(cls,&other)) return operator=((cls const&)other);\
else { deleteFields(); initWithEmptyData(flgs); return (cls&) GC::cls::operator=(other); }\
}\
void cls::swap(GC::cls & other){\
if(LIBPKMGC_IS_COLOSSEUM(cls,&other)) swap((cls&)other);\
else {cls obj((XD::cls&)other); swap(obj); other.swap(obj);}\
}
#define LIBPKMGC_GC_GEN_XD_VTF(cls) LIBPKMGC_GC_GEN_XD_VTF2(cls,0)
#define LIBPKMGC_GC_GEN_COL_VTF(cls) LIBPKMGC_GC_GEN_COL_VTF2(cls, 0)
#endif
#ifndef BOOST_NO_SFINAE
namespace {
#define CREATE_MEMBER_DETECTOR(X) \
template<typename T> class Detect_##X { \
struct Fallback { int X; }; \
struct Derived : T, Fallback { }; \
\
template<typename U, U> struct Check; \
\
typedef char ArrayOfOne[1]; \
typedef char ArrayOfTwo[2]; \
\
template<typename U> static ArrayOfOne & func(Check<int Fallback::*, &U::X> *); \
template<typename U> static ArrayOfTwo & func(...); \
public: \
typedef Detect_##X type; \
static const bool value = sizeof(func<Derived>(0)) == 2; \
};
CREATE_MEMBER_DETECTOR(isXD)
#undef CREATE_MEMBER_DETECTOR
}
namespace LibPkmGC {
namespace Detail {
template<typename T> bool test_isXD_or_true(T* obj, typename boost::disable_if<Detect_isXD<T> >::type* dummy = NULL) { return true; }
template<typename T> bool test_isXD_or_true(T* obj, typename boost::enable_if<Detect_isXD<T> >::type* dummy = NULL) {
return obj->isXD();
}
}
}
#define LIBPKMGC_IS_XD(cls, obj) ((obj)->fixedSize == LibPkmGC::XD::cls::size && LibPkmGC::Detail::test_isXD_or_true(obj))
#define LIBPKMGC_IS_COLOSSEUM(cls, obj) ((obj)->fixedSize == LibPkmGC::Colosseum::cls::size && LibPkmGC::Detail::test_isXD_or_true(obj))
#endif
#endif

View File

@ -0,0 +1,107 @@
#ifndef _LIBPKMGC_INTEGER_MANIP_H
#define _LIBPKMGC_INTEGER_MANIP_H
#include <LibPkmGC/Core/IntegerTypes.h>
#include <algorithm>
#include <iterator>
#include <stdexcept>
namespace LibPkmGC {
namespace IntegerManip {
namespace LE {
template<typename I, typename OutputIteratorType>
void fromInteger(OutputIteratorType const& _dest, I const& _integer, size_t _integerSize = sizeof(I)) {
OutputIteratorType dst(_dest);
for (size_t i = 0; i < _integerSize; i++) {
*dst = (_integer >> (8 * i)) & 0xff;
++dst;
}
}
template<typename I, typename IteratorType>
I toInteger(IteratorType const& _bufferIterator, size_t _integerSize = sizeof(I)) {
I ret = I(0);
size_t shift = 0;
IteratorType it(_bufferIterator);
for (; shift <= 8 * _integerSize - 8; ++it) {
ret |= (I(*it) << shift);
shift += 8;
}
return ret;
}
#include <LibPkmGC/Core/Detail/IntegerManipCode.h>
}
namespace BE {
template<typename I, typename OutputIteratorType>
void fromInteger(OutputIteratorType const& _dest, I const& _integer, size_t _integerSize = sizeof(I)) {
OutputIteratorType dst(_dest);
std::advance(dst, _integerSize - 1);
size_t shift = 0;
for (; shift < 8 * _integerSize; shift += 8) {
*dst = (_integer >> shift) & 0xff;
if ((shift + 8) < (8 * _integerSize)) --dst;
}
}
template<typename I, typename IteratorType>
I toInteger(IteratorType const& _bufferIterator, size_t _integerSize = sizeof(I)) {
I ret = I(0);
IteratorType it(_bufferIterator);
size_t shift = 8 * _integerSize - 8;
for (;; ++it) {
ret |= (I(*it) << shift);
if (shift == 0) break;
else shift -= 8;
}
return ret;
}
#include <LibPkmGC/Core/Detail/IntegerManipCode.h>
}
template<typename I>
I rotateLeft(I _value, size_t _rotate, size_t _integerSize = sizeof(I)) {
_rotate %= 8 * _integerSize;
//e.g n [rotate left/right] 33 is equal to n [rotate left/right] 1 if n is a 8/16/32-bit integer
return ((_value << _rotate) | (_value >> (8 * _integerSize - _rotate)));
}
template<typename I>
I rotateRight(I _value, size_t _rotate, size_t _integerSize = sizeof(I)) {
_rotate %= 8 * _integerSize;
return ((_value >> _rotate) | (_value << (8 * _integerSize - _rotate)));
}
template<typename I>
I extractBits(I const& _integer, size_t _endBit, size_t _beginBit, size_t _integerSize = sizeof(I)) {
if ((_endBit >= _integerSize * 8) || (_beginBit >= _integerSize * 8))
throw std::out_of_range("The values of _beginBit and/or _endBit you specified are too high (more than _integerSize * 8 - 1) !");
if (_endBit < _beginBit)
throw std::invalid_argument("_beginBit cannot be greater than _endBit !");
return (_integer >> _beginBit) & ((1 << (_endBit - _beginBit + 1)) - 1);
}
}
}
#endif

View File

@ -0,0 +1,26 @@
#ifndef _LIBPKMGC_INTEGER_TYPES_H
#define _LIBPKMGC_INTEGER_TYPES_H
#include <LibPkmGC/Core/Config.h>
#include <boost/cstdint.hpp>
namespace LibPkmGC {
#ifndef BOOST_NO_INT64_T
typedef boost::uint64_t u64;
typedef boost::int64_t s64;
#else
# define LIBPKM_NO_INT64_T
#endif
typedef boost::uint32_t u32;
typedef boost::uint16_t u16;
typedef boost::uint8_t u8;
typedef boost::int32_t s32;
typedef boost::int16_t s16;
typedef boost::int8_t s8;
}
#endif

View File

@ -0,0 +1,441 @@
#ifndef _LIBPKMGC_ITEM_INFO_H
#define _LIBPKMGC_ITEM_INFO_H
#include <LibPkmGC/Core/IntegerTypes.h>
namespace LibPkmGC {
enum ItemIndex {
NoItem = 0x0000,
MasterBall = 0x0001,
UltraBall = 0x0002,
GreatBall = 0x0003,
PokeBall = 0x0004,
SafariBall = 0x0005,
NetBall = 0x0006,
DiveBall = 0x0007,
NestBall = 0x0008,
RepeatBall = 0x0009,
TimerBall = 0x000A,
LuxuryBall = 0x000B,
PremierBall = 0x000C,
Potion = 0x000D,
Antidote = 0x000E,
BurnHeal = 0x000F,
IceHeal = 0x0010,
Awakening = 0x0011,
ParlyzHeal = 0x0012,
FullRestore = 0x0013,
MaxPotion = 0x0014,
HyperPotion = 0x0015,
SuperPotion = 0x0016,
FullHeal = 0x0017,
Revive = 0x0018,
MaxRevive = 0x0019,
FreshWater = 0x001A,
SodaPop = 0x001B,
Lemonade = 0x001C,
MoomooMilk = 0x001D,
EnergyPowder = 0x001E,
EnergyRoot = 0x001F,
HealPowder = 0x0020,
RevivalHerb = 0x0021,
Ether = 0x0022,
MaxEther = 0x0023,
Elixir = 0x0024,
MaxElixir = 0x0025,
LavaCookie = 0x0026,
BlueFlute = 0x0027,
YellowFlute = 0x0028,
RedFlute = 0x0029,
BlackFlute = 0x002A,
WhiteFlute = 0x002B,
BerryJuice = 0x002C,
SacredAsh = 0x002D,
ShoalSalt = 0x002E,
ShoalShell = 0x002F,
RedShard = 0x0030,
BlueShard = 0x0031,
YellowShard = 0x0032,
GreenShard = 0x0033,
HPUp = 0x003F,
Protein = 0x0040,
Iron = 0x0041,
Carbos = 0x0042,
Calcium = 0x0043,
RareCandy = 0x0044,
PPUp = 0x0045,
Zinc = 0x0046,
PPMax = 0x0047,
GuardSpec = 0x0049,
DireHit = 0x004A,
XAttack = 0x004B,
XDefend = 0x004C,
XSpeed = 0x004D,
XAccuracy = 0x004E,
XSpecial = 0x004F,
Pokedoll = 0x0050,
FluffyTail = 0x0051,
SuperRepel = 0x0053,
MaxRepel = 0x0054,
EscapeRope = 0x0055,
Repel = 0x0056,
SunStone = 0x005D,
MoonStone = 0x005E,
FireStone = 0x005F,
ThunderStone = 0x0060,
WaterStone = 0x0061,
LeafStone = 0x0062,
TinyMushroom = 0x0067,
BigMushroom = 0x0068,
Pearl = 0x006A,
BigPearl = 0x006B,
Stardust = 0x006C,
StarPiece = 0x006D,
Nugget = 0x006E,
HeartScale = 0x006F,
OrangeMail = 0x0079,
HarborMail = 0x007A,
GlitterMail = 0x007B,
MechMail = 0x007C,
WoodMail = 0x007D,
WaveMail = 0x007E,
BeadMail = 0x007F,
ShadowMail = 0x0080,
TropicMail = 0x0081,
DreamMail = 0x0082,
FabMail = 0x0083,
RetroMail = 0x0084,
CheriBerry = 0x0085,
ChestoBerry = 0x0086,
PechaBerry = 0x0087,
RawstBerry = 0x0088,
AspearBerry = 0x0089,
LeppaBerry = 0x008A,
OranBerry = 0x008B,
PersimBerry = 0x008C,
LumBerry = 0x008D,
SitrusBerry = 0x008E,
FigyBerry = 0x008F,
WikiBerry = 0x0090,
MagoBerry = 0x0091,
AguavBerry = 0x0092,
IapapaBerry = 0x0093,
RazzBerry = 0x0094,
BlukBerry = 0x0095,
NanabBerry = 0x0096,
WepearBerry = 0x0097,
PinapBerry = 0x0098,
PomegBerry = 0x0099,
KelpsyBerry = 0x009A,
QualotBerry = 0x009B,
HondewBerry = 0x009C,
GrepaBerry = 0x009D,
TamatoBerry = 0x009E,
CornnBerry = 0x009F,
MagostBerry = 0x00A0,
RabutaBerry = 0x00A1,
NomelBerry = 0x00A2,
SpelonBerry = 0x00A3,
PamtreBerry = 0x00A4,
WatmelBerry = 0x00A5,
DurinBerry = 0x00A6,
BelueBerry = 0x00A7,
LiechiBerry = 0x00A8,
GanlonBerry = 0x00A9,
SalacBerry = 0x00AA,
PetayaBerry = 0x00AB,
ApicotBerry = 0x00AC,
LansatBerry = 0x00AD,
StarfBerry = 0x00AE,
EnigmaBerry = 0x00AF,
BrightPowder = 0x00B3,
WhiteHerb = 0x00B4,
MachoBrace = 0x00B5,
ExpShare = 0x00B6,
QuickClaw = 0x00B7,
SootheBell = 0x00B8,
MentalHerb = 0x00B9,
ChoiceBand = 0x00BA,
KingsRock = 0x00BB,
SilverPowder = 0x00BC,
AmuletCoin = 0x00BD,
CleanseTag = 0x00BE,
SoulDew = 0x00BF,
DeepSeaTooth = 0x00C0,
DeepSeaScale = 0x00C1,
SmokeBall = 0x00C2,
Everstone = 0x00C3,
FocusBand = 0x00C4,
LuckyEgg = 0x00C5,
ScopeLens = 0x00C6,
MetalCoat = 0x00C7,
Leftovers = 0x00C8,
DragonScale = 0x00C9,
LightBall = 0x00CA,
SoftSand = 0x00CB,
HardStone = 0x00CC,
MiracleSeed = 0x00CD,
BlackGlasses = 0x00CE,
BlackBelt = 0x00CF,
Magnet = 0x00D0,
MysticWater = 0x00D1,
SharpBeak = 0x00D2,
PoisonBarb = 0x00D3,
NeverMeltIce = 0x00D4,
SpellTag = 0x00D5,
TwistedSpoon = 0x00D6,
Charcoal = 0x00D7,
DragonFang = 0x00D8,
SilkScarf = 0x00D9,
UpGrade = 0x00DA,
ShellBell = 0x00DB,
SeaIncense = 0x00DC,
LaxIncense = 0x00DD,
LuckyPunch = 0x00DE,
MetalPowder = 0x00DF,
ThickClub = 0x00E0,
Stick = 0x00E1,
RedScarf = 0x00FE,
BlueScarf = 0x00FF,
PinkScarf = 0x0100,
GreenScarf = 0x0101,
YellowScarf = 0x0102,
TM01 = 0x0121,
TM02 = 0x0122,
TM03 = 0x0123,
TM04 = 0x0124,
TM05 = 0x0125,
TM06 = 0x0126,
TM07 = 0x0127,
TM08 = 0x0128,
TM09 = 0x0129,
TM10 = 0x012A,
TM11 = 0x012B,
TM12 = 0x012C,
TM13 = 0x012D,
TM14 = 0x012E,
TM15 = 0x012F,
TM16 = 0x0130,
TM17 = 0x0131,
TM18 = 0x0132,
TM19 = 0x0133,
TM20 = 0x0134,
TM21 = 0x0135,
TM22 = 0x0136,
TM23 = 0x0137,
TM24 = 0x0138,
TM25 = 0x0139,
TM26 = 0x013A,
TM27 = 0x013B,
TM28 = 0x013C,
TM29 = 0x013D,
TM30 = 0x013E,
TM31 = 0x013F,
TM32 = 0x0140,
TM33 = 0x0141,
TM34 = 0x0142,
TM35 = 0x0143,
TM36 = 0x0144,
TM37 = 0x0145,
TM38 = 0x0146,
TM39 = 0x0147,
TM40 = 0x0148,
TM41 = 0x0149,
TM42 = 0x014A,
TM43 = 0x014B,
TM44 = 0x014C,
TM45 = 0x014D,
TM46 = 0x014E,
TM47 = 0x014F,
TM48 = 0x0150,
TM49 = 0x0151,
TM50 = 0x0152,
/* Colosseum-only items (mostly key items) */
JailKey = 0x01F4,
ElevatorKey = 0x01F5, // common to colo and XD
SmallTablet = 0x01F6,
FDisk = 0x01F7,
RDisk = 0x01F8,
LDisk = 0x01F9,
DDisk = 0x01FA,
UDisk = 0x01FB,
SubwayKey = 0x01FC,
MaingateKey = 0x01FD,
CardKey = 0x01FE,
DownStKey = 0x01FF,
DNASample = 0x0200,
DNASample1 = 0x0201,
DNASample2 = 0x0202,
DNASample3 = 0x0203,
DNASample4 = 0x0204,
DNASample5 = 0x0205,
DNASample6 = 0x0206,
DNASample7 = 0x0207,
DNASample8 = 0x0208,
DNASample9 = 0x0209,
DNASample10 = 0x020A,
DNASample11 = 0x020B,
DNASample12 = 0x020C,
DNASample13 = 0x020D,
DNASample14 = 0x020E,
DNASample15 = 0x020F,
DNASample16 = 0x0210,
DNASample17 = 0x0211,
DataROM_C = 0x0212,
SteelTeeth = 0x0213,
Gear = 0x0214,
RedIDBadge = 0x0215,
GrnIDBadge = 0x0216,
BluIDBadge = 0x0217,
YlwIDBadge = 0x0218,
TimeFlute = 0x0219,
EinFileS = 0x021A,
EinFileH = 0x021B,
EinFileC = 0x021C,
EinFileP = 0x021D,
CologneCase_C = 0x021E,
JoyScent_C = 0x021F,
ExciteScent_C = 0x0220,
VividScent_C = 0x0221,
PowerupPart = 0x0222,
EinFileF = 0x0223,
/* XD-only items. On the debugger, they will probably be hidden by the Colosseum-only items */
SafeKey = 0x01F4,
BonslyCard = 0x01F6,
MachinePart = 0x01F7,
GonzapsKey = 0x01F8,
DataROM_XD = 0x01F9,
IDCard = 0x01FA,
MusicDisc = 0x01FB,
SystemLever = 0x01FC,
MayorsNote = 0x01FD,
MirorRadar = 0x01FE,
PokeSnack = 0x01FF,
CologneCase_XD = 0x200,
JoyScent_XD = 0x0201,
ExciteScent_XD = 0x0202,
VividScent_XD = 0x0203,
SunShard = 0x0204,
MoonShard = 0x0205,
BonslyPhoto = 0x0206,
CryAnalyzer = 0x0207,
KraneMemo1 = 0x020B,
KraneMemo2 = 0x020C,
KraneMemo3 = 0x020D,
KraneMemo4 = 0x020E,
KraneMemo5 = 0x020F,
VoiceCase1 = 0x0210,
VoiceCase2 = 0x0211,
VoiceCase3 = 0x0212,
VoiceCase4 = 0x0213,
VoiceCase5 = 0x0214,
DiscCase = 0x0215,
BattleCD01 = 0x0216,
BattleCD02 = 0x0217,
BattleCD03 = 0x0218,
BattleCD04 = 0x0219,
BattleCD05 = 0x021A,
BattleCD06 = 0x021B,
BattleCD07 = 0x021C,
BattleCD08 = 0x021D,
BattleCD09 = 0x021E,
BattleCD10 = 0x021F,
BattleCD11 = 0x0220,
BattleCD12 = 0x0221,
BattleCD13 = 0x0222,
BattleCD14 = 0x0223,
BattleCD15 = 0x0224,
BattleCD16 = 0x0225,
BattleCD17 = 0x0226,
BattleCD18 = 0x0227,
BattleCD19 = 0x0228,
BattleCD20 = 0x0229,
BattleCD21 = 0x022A,
BattleCD22 = 0x022B,
BattleCD23 = 0x022C,
BattleCD24 = 0x022D,
BattleCD25 = 0x022E,
BattleCD26 = 0x022F,
BattleCD27 = 0x0230,
BattleCD28 = 0x0231,
BattleCD29 = 0x0232,
BattleCD30 = 0x0233,
BattleCD31 = 0x0234,
BattleCD32 = 0x0235,
BattleCD33 = 0x0236,
BattleCD34 = 0x0237,
BattleCD35 = 0x0238,
BattleCD36 = 0x0239,
BattleCD37 = 0x023A,
BattleCD38 = 0x023B,
BattleCD39 = 0x023C,
BattleCD40 = 0x023D,
BattleCD41 = 0x023E,
BattleCD42 = 0x023F,
BattleCD43 = 0x0240,
BattleCD44 = 0x0241,
BattleCD45 = 0x0242,
BattleCD46 = 0x0243,
BattleCD47 = 0x0244,
BattleCD48 = 0x0245,
BattleCD49 = 0x0246,
BattleCD50 = 0x0247,
BattleCD51 = 0x0248,
BattleCD52 = 0x0249,
BattleCD53 = 0x024A,
BattleCD54 = 0x024B,
BattleCD55 = 0x024C,
BattleCD56 = 0x024D,
BattleCD57 = 0x024E,
BattleCD58 = 0x024F,
BattleCD59 = 0x0250,
BattleCD60 = 0x0251,
};
struct LIBPKMGC_DECL Item {
ItemIndex index;
u16 quantity;
void load(u8* data);
void save(u8* data);
};
enum ItemCategoryIndex {
NoItemCategory = 0,
PokeballsCategory = 1,
RegularItemsCategory = 2,
BerriesCategory = 3,
TMsCategory = 4,
KeyItemsCategory = 5,
ColognesCategory = 6,
BattleCDsCategory = 7
};
LIBPKMGC_DECL ItemCategoryIndex getItemCategory(ItemIndex index, bool isXD = false);
}
#endif

View File

@ -0,0 +1,34 @@
#ifndef _LIBPKMGC_LOCALIZATION_H
#define _LIBPKMGC_LOCALIZATION_H
#include <LibPkmGC/Core/PokemonInfo.h>
#include <LibPkmGC/Core/ItemInfo.h>
#include <LibPkmGC/Core/Detail/SpeciesNames.h>
#include <LibPkmGC/Core/Detail/NatureNames.h>
#include <LibPkmGC/Core/Detail/MoveNames.h>
#include <LibPkmGC/Core/Detail/AbilityNames.h>
#include <LibPkmGC/Core/Detail/ItemNames.h>
namespace LibPkmGC {
namespace Localization {
LIBPKMGC_DECL size_t itemIndexToNameIndex(ItemIndex index, bool isXD = false);
LIBPKMGC_DECL ItemIndex nameIndexToItemIndex(size_t index, bool isXD = false);
LIBPKMGC_DECL size_t pkmSpeciesIndexToNameIndex(PokemonSpeciesIndex index);
LIBPKMGC_DECL PokemonSpeciesIndex nameIndexToPkmSpeciesIndex(size_t index);
LIBPKMGC_DECL const char* getPokemonSpeciesName(LanguageIndex language, PokemonSpeciesIndex index);
LIBPKMGC_DECL const char* getPokemonSpeciesNameByPkdxIndex(LanguageIndex language, u16 pkdexIndex);
LIBPKMGC_DECL const char* getPokemonNatureName(LanguageIndex language, PokemonNatureIndex index);
LIBPKMGC_DECL const char* getPokemonMoveName(LanguageIndex language, PokemonMoveIndex index);
LIBPKMGC_DECL const char* getPokemonAbilityName(LanguageIndex language, PokemonAbilityIndex index);
LIBPKMGC_DECL const char* getItemName(LanguageIndex language, ItemIndex index, bool isXD = false);
}
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,47 @@
#ifndef _LIBPKMGC_GC_BAG_DATA_H
#define _LIBPKMGC_GC_BAG_DATA_H
#include <LibPkmGC/Core/ItemInfo.h>
#include <LibPkmGC/Base/DataStruct.h>
namespace LibPkmGC {
LIBPKMGC_FWD_DECL_GC_CLS(BagData)
namespace GC {
class LIBPKMGC_DECL BagData :
public Base::DataStruct
{
public:
BagData(size_t inSize, size_t nb_regular_items, const u8* inData = NULL);
virtual ~BagData();
virtual BagData* clone(void) const = 0;
virtual BagData* create(void) const = 0;
void swap(BagData& other);
BagData& operator=(BagData const& other);
virtual void save(void);
const size_t nbRegularItems;
Item* regularItems;
Item keyItems[43];
Item pokeballs[16];
Item TMs[64];
Item berries[46];
Item colognes[3];
protected:
BagData(BagData const& other);
virtual void deleteFields(void);
virtual void loadFields(void);
};
}
}
#endif

View File

@ -0,0 +1,38 @@
#ifndef _LIBPKMGC_GC_BATTLE_MODE_DATA_H
#define _LIBPKMGC_GC_BATTLE_MODE_DATA_H
#include <LibPkmGC/GC/Common/GroupBattleRule.h>
namespace LibPkmGC {
LIBPKMGC_FWD_DECL_GC_CLS(BattleModeData)
namespace GC {
class LIBPKMGC_DECL BattleModeData :
public Base::DataStruct
{
public:
BattleModeData(size_t inSize, const u8* inData = NULL);
virtual ~BattleModeData();
virtual BattleModeData* clone(void) const = 0;
virtual BattleModeData* create(void) const = 0;
void swap(BattleModeData& other);
BattleModeData& operator=(BattleModeData const& other);
GroupBattleRule* rules[6];
protected:
BattleModeData(BattleModeData const& other);
virtual void deleteFields(void);
};
}
}
#endif

View File

@ -0,0 +1,58 @@
#ifndef _LIBPKMGC_GC_DAYCARE_DATA_H
#define _LIBPKMGC_GC_DAYCARE_DATA_H
#include <LibPkmGC/GC/Common/Pokemon.h>
namespace LibPkmGC {
enum DaycareStatus {
NotVisited = -1, NoPkmDeposited = 0, PkmDeposited = 1
};
LIBPKMGC_FWD_DECL_GC_CLS(DaycareData)
namespace GC {
/*
For both Colosseum and XD:
0x00: s8 daycareStatus (0: no pkm, >1: pkm in daycare, <0: first visit (XD only)
0x01: u8 initialPkmLevel;
0x02: padding/trash data
0x04: u32 initialPurificationCounter
0x08--end: stored pkm
*/
// Cost of daycare : 100*(1 + (currentLevel - initialLevel) + 1 + int((purifCtr - initialPurifCtr)/100))
// or 100*(1 + currentLevel - initialLvl) if (purifCtr - initialPurifCtr) < 100. 0 if status != PkmDeposited
class LIBPKMGC_DECL DaycareData :
public Base::DataStruct
{
public:
DaycareData(size_t inSize, const u8* inData = NULL);
virtual ~DaycareData(void);
virtual DaycareData* clone(void) const = 0;
virtual DaycareData* create(void) const = 0;
virtual void swap(DaycareData& other);
virtual DaycareData& operator=(DaycareData const& other);
virtual void save(void);
DaycareStatus status;
u8 initialPkmLevel;
u32 initialPkmPurifCounter;
Pokemon* pkm;
protected:
DaycareData(DaycareData const& other);
virtual void deleteFields(void);
virtual void loadFields(void);
};
}
}
#endif

View File

@ -0,0 +1,9 @@
#pragma once
#include <LibPkmGC/GC/Common/PlayerData.h>
#include <LibPkmGC/GC/Common/PCData.h>
#include <LibPkmGC/GC/Common/PlayerData.h>
#include <LibPkmGC/GC/Common/MailboxData.h>
#include <LibPkmGC/GC/Common/DaycareData.h>
#include <LibPkmGC/GC/Common/StrategyMemoData.h>
#include <LibPkmGC/GC/Common/BattleModeData.h>

View File

@ -0,0 +1,52 @@
#ifndef _LIBPKMGC_GC_GROUP_BATTLE_RULE_H
#define _LIBPKMGC_GC_GROUP_BATTLE_RULE_H
#include <LibPkmGC/Base/DataStruct.h>
namespace LibPkmGC {
enum ItemRestrictionLevel {
AllItemsAllowed = 0,
NoItemAllowed = 1,
SomeItemsAllowed = 2
};
LIBPKMGC_FWD_DECL_GC_CLS(GroupBattleRule)
namespace GC {
class LIBPKMGC_DECL GroupBattleRule :
public Base::DataStruct
{
public:
GroupBattleRule(size_t inSize, size_t nb_banned_items, const u8* inData = NULL);
virtual ~GroupBattleRule(void);
GroupBattleRule& operator=(GroupBattleRule const& other);
virtual GroupBattleRule* clone(void) const = 0;
virtual GroupBattleRule* create(void) const = 0;
void swap(GroupBattleRule& other);
virtual void save(void);
u16 minLevel, maxLevel;
u16 maxLevelSum;
ItemRestrictionLevel itemRestrictions;
bool noSpeciesClause, noItemClause, noSleepClause, noFreezeClause;
bool noSkillSwap, explosionClause, noRequiemClause, allowFixedDmgAbilities;
s16 maxBattleDuration, orderTimeout; // resp. in min., sec. if negative, it's the opposite of the suggested value
const size_t nbBannableItems;
bool* bannedItems; // 60 or 62
protected:
GroupBattleRule(GroupBattleRule const& other);
virtual void deleteFields(void);
virtual void loadFields(void);
};
}
}
#endif

View File

@ -0,0 +1,44 @@
#ifndef _LIBPKMGC_GC_MAILBOX_DATA
#define _LIBPKMGC_GC_MAILBOX_DATA
#include <LibPkmGC/Base/DataStruct.h>
#define LIBPKMGC_MAILBOX_EMPTY_MAIL 255
namespace LibPkmGC {
LIBPKMGC_FWD_DECL_GC_CLS(MailboxData)
namespace GC {
class LIBPKMGC_DECL MailboxData :
public Base::DataStruct
{
public:
MailboxData(size_t inSize, u16 max_nb_mails, const u8* inData = NULL);
virtual ~MailboxData();
void swap(MailboxData& other);
MailboxData& operator=(MailboxData const& other);
virtual MailboxData* clone(void) const = 0;
virtual MailboxData* create(void) const = 0;
bool isMailEmpty(size_t i);
u16 nbMails;
u16* mails;
const u16 maxNbMails;
protected:
MailboxData(MailboxData const& other);
virtual void deleteFields(void);
};
}
}
#endif

View File

@ -0,0 +1,40 @@
#ifndef _LIBPKMGC_GC_PC_DATA_H
#define _LIBPKMGC_GC_PC_DATA_H
#include <LibPkmGC/GC/Common/PokemonBox.h>
namespace LibPkmGC {
LIBPKMGC_FWD_DECL_GC_CLS(PCData)
namespace GC {
class LIBPKMGC_DECL PCData :
public Base::DataStruct
{
public:
PCData(size_t inSize, size_t nb_boxes, const u8* inData = NULL);
virtual ~PCData(void);
virtual PCData* clone(void) const = 0;
virtual PCData* create(void) const = 0;
void swap(PCData& other);
PCData& operator=(PCData const& other);
PokemonBox** boxes;
const size_t nbBoxes;
Item items[235];
protected:
PCData(PCData const& other);
virtual void deleteFields(void);
};
}
}
#endif

View File

@ -0,0 +1,52 @@
#ifndef _LIBPKMGC_GC_PLAYER_DATA_H
#define _LIBPKMGC_GC_PLAYER_DATA_H
#include <LibPkmGC/GC/Common/Pokemon.h>
#include <LibPkmGC/GC/Common/BagData.h>
namespace LibPkmGC {
LIBPKMGC_FWD_DECL_GC_CLS(PlayerData)
namespace GC {
class LIBPKMGC_DECL PlayerData :
public Base::DataStruct
{
public:
PlayerData(size_t inSize, const u8* inData = NULL);
PlayerData& operator=(PlayerData const& other);
virtual PlayerData* clone(void) const = 0;
virtual PlayerData* create(void) const = 0;
virtual ~PlayerData(void);
void swap(PlayerData& other);
void swapPokemon(size_t n, size_t m);
virtual void save(void);
PokemonString* trainerName;
u16 SID, TID;
Pokemon* party[6];
BagData* bag;
Gender trainerGender;
u32 money;
u32 pkCoupons;
protected:
PlayerData(PlayerData const& other);
virtual void deleteFields(void);
virtual void loadFields(void);
};
}
}
#endif

View File

@ -0,0 +1,32 @@
#ifndef _LIBPKMGC_GC_POKEMON_H
#define _LIBPKMGC_GC_POKEMON_H
#include <LibPkmGC/Base/Pokemon.h>
#include <LibPkmGC/GC/Common/PokemonString.h>
namespace LibPkmGC {
namespace GC {
class LIBPKMGC_DECL Pokemon :
public Base::Pokemon {
public:
Pokemon(size_t inSize, const u8* inData = NULL);
virtual ~Pokemon(void);
virtual Pokemon* clone(void) const = 0;
virtual Pokemon* create(void) const = 0;
virtual void swap(Pokemon& other);
virtual Pokemon& operator=(Pokemon const& other);
virtual bool hasSpecialAbility(void) const = 0;
virtual void setSpecialAbilityStatus(bool status) = 0;
virtual PokemonAbilityIndex getAbility(void) const;
u16 shadowPkmID;
virtual void swap(Base::Pokemon& other);
virtual Pokemon& operator=(Base::Pokemon const& other);
protected:
Pokemon(Pokemon const& other);
};
}
}
#endif

View File

@ -0,0 +1,34 @@
#ifndef _LIBPKMGC_GC_POKEMON_BOX_H
#define _LIBPKMGC_GC_POKEMON_BOX_H
#include <LibPkmGC/Base/PokemonBox.h>
#include <LibPkmGC/GC/Common/Pokemon.h>
namespace LibPkmGC {
namespace GC {
/*
0x00: PokemonString name (2*(8+1) bytes)
0x12: u16 ??
0x14 -- end: Pokemon pkm[30]
*/
class LIBPKMGC_DECL PokemonBox : public Base::PokemonBox {
public:
PokemonBox(size_t inSize, const u8* inData = NULL);
virtual ~PokemonBox(void);
virtual PokemonBox* clone(void) const = 0;
virtual PokemonBox* create(void) const = 0;
virtual void save(void);
protected:
PokemonBox(PokemonBox const& other);
virtual void loadFields(void);
};
}
}
#endif

View File

@ -0,0 +1,40 @@
#ifndef _LIBPKMGC_GC_POKEMON_STRING_H
#define _LIBPKMGC_GC_POKEMON_STRING_H
#include <LibPkmGC/Base/PokemonString.h>
namespace LibPkmGC {
namespace GC {
class LIBPKMGC_DECL PokemonString : public Base::PokemonString {
public:
PokemonString(const char* str = NULL);
PokemonString(u8* data, size_t nb);
PokemonString(PokemonString const& other);
~PokemonString(void);
PokemonString* clone(void) const;
PokemonString* create(void) const;
PokemonString& operator=(PokemonString const& other);
PokemonString& operator=(Base::PokemonString const& other);
void fromUTF8(const char* str = NULL);
const char* toUTF8(void) const;
size_t size(void) const;
void load(u8* data, size_t nb);
void save(u8* data, size_t nb) const;
private:
u8* _data;
size_t dataSz;
size_t dataCapacity;
void resizeData(void);
};
}
}
#endif

View File

@ -0,0 +1,59 @@
#ifndef _LIBPKMGC_GC_STRATEGY_MEMO_DATA_H
#define _LIBPKMGC_GC_STRATEGY_MEMO_DATA_H
#include <LibPkmGC/GC/Common/StrategyMemoEntry.h>
#include <LibPkmGC/GC/Common/Pokemon.h>
namespace LibPkmGC {
LIBPKMGC_FWD_DECL_GC_CLS(StrategyMemoData)
namespace GC {
/*
For both XD and Colosseum:
0x00: u32 nbEntries, max. 500
0x04: StrategyMemoEntry entries[500];
*/
class LIBPKMGC_DECL StrategyMemoData :
public Base::DataStruct
{
public:
StrategyMemoData(size_t inSize, const u8* inData = NULL);
virtual bool isXD(void) const = 0;
virtual ~StrategyMemoData(void);
virtual StrategyMemoData* clone(void) const = 0;
virtual StrategyMemoData* create(void) const = 0;
void swap(StrategyMemoData& other);
StrategyMemoData& operator=(StrategyMemoData const& other);
virtual void save(void);
virtual bool registerSpecies(PokemonSpeciesIndex index, u32 PID, u16 SID = 0, u16 TID = 0);
virtual bool registerSpecies(Pokemon* pkm);
void deleteEntry(size_t index);
size_t recount(void) const;
void sortedBySpeciesIndex(StrategyMemoEntry* dst[0x19b]); // only entries containing a valid Gen III species index are sorted
virtual void fixInvalidEntries(void);
u16 nbEntries;
StrategyMemoEntry* entries[500];
protected:
StrategyMemoData(StrategyMemoData const& other);
virtual void deleteFields(void);
virtual void loadFields(void);
};
}
}
#endif

View File

@ -0,0 +1,55 @@
#ifndef _LIBPKMGC_GC_STRATEGY_MEMO_ENTRY_H
#define _LIBPKMGC_GC_STRATEGY_MEMO_ENTRY_H
#include <LibPkmGC/Base/DataStruct.h>
#include <LibPkmGC/Core/PokemonInfo.h>
namespace LibPkmGC {
LIBPKMGC_FWD_DECL_GC_CLS(StrategyMemoEntry)
namespace GC {
/*
For both Colosseum and XD:
0x00: u16 pokemonIndex | flag (Colosseum: 0 : pokémon fully registered; 0x8000 : registered as seen; XD : 0x8000 if registered)
0x04: u16 firstSID
0x06: u16 firstTID
0x08: u32 firstPID
*/
class LIBPKMGC_DECL StrategyMemoEntry :
public Base::DataStruct
{
public:
StrategyMemoEntry(const u8* inData = NULL);
virtual ~StrategyMemoEntry(void);
virtual bool isXD(void) const = 0;
virtual void save(void);
virtual StrategyMemoEntry* clone(void) const = 0;
virtual StrategyMemoEntry* create(void) const = 0;
void swap(StrategyMemoEntry& other);
bool isEmpty(void) const;
virtual bool isInfoPartial(void) const = 0;
virtual void setInfoCompleteness(bool partial) = 0;
//PokemonSpeciesStatus status; // discarded in Pokémon XD, where full information is automatically obtained
u16 flags;
PokemonSpeciesIndex species;
u16 firstSID, firstTID;
u32 firstPID;
protected:
virtual void deleteFields(void);
virtual void loadFields(void);
};
}
}
#endif

View File

@ -0,0 +1,60 @@
#ifndef _LIBPKMGC_GC_SAVE_EDITING_SAVE_H
#define _LIBPKMGC_GC_SAVE_EDITING_SAVE_H
#include <LibPkmGC/GC/SaveEditing/SaveSlot.h>
namespace LibPkmGC {
namespace XD { namespace SaveEditing { class Save; } }
namespace Colosseum { namespace SaveEditing { class Save; } }
namespace GC {
namespace SaveEditing {
/*
For both Colosseum and XD:
0x0000 -- 0x6000: banner data
0x6000 -- end: SaveSlot saveSlots[3 (Colo.) or 2 (XD)]
*/
class LIBPKMGC_DECL Save :
public Base::DataStruct
{
public:
Save(size_t inSize, size_t nb_slots, const u8* inData = NULL, bool hasGCIData_ = false);
virtual Save* clone(void) const = 0;
virtual Save* create(void) const = 0;
void swap(Save& other);
Save& operator=(Save const& other);
virtual ~Save(void);
virtual void reload(const u8* inData = NULL, u32 flags = 0);
void saveEncrypted(u8* outBuf, bool exportGCIData = true);
SaveSlot* getMostRecentSlot(size_t index = 0) const;
SaveSlot* getMostRecentValidSlot(size_t index = 0, size_t *outIndex = NULL);
SaveSlot** saveSlots;
const size_t nbSlots;
bool hasGCIData;
u8 GCIData[0x40];
protected:
Save(Save const& other);
bool _is_decrypted;
virtual void loadData(u32 flags = 0);
virtual void deleteFields(void);
};
}
}
}
#endif

View File

@ -0,0 +1,78 @@
#ifndef _LIBPKMGC_GC_SAVE_EDITING_SAVE_SLOT_H
#define _LIBPKMGC_GC_SAVE_EDITING_SAVE_SLOT_H
#include <LibPkmGC/GC/Common/Everything.h>
#include <utility>
namespace LibPkmGC {
enum SaveMagic {
ColosseumMagic = 0x01010000,
XDMagic = 0x01010100
};
namespace XD { namespace SaveEditing { class SaveSlot; } }
namespace Colosseum { namespace SaveEditing { class SaveSlot; } }
namespace GC {
namespace SaveEditing {
class LIBPKMGC_DECL SaveSlot : public Base::DataStruct
{
public:
SaveSlot(size_t inSize, size_t nb_random_bytes, const u8* inData = NULL);
SaveSlot(const SaveSlot& other);
virtual ~SaveSlot(void);
void swap(SaveSlot& other);
SaveSlot& operator=(SaveSlot const& other);
virtual SaveSlot* clone(void) const = 0;
virtual SaveSlot* create(void) const = 0;
virtual void reload(const u8* inData = NULL, u32 flags = 0);
virtual bool checkChecksum(bool fix = false) = 0;
virtual bool checkHeaderChecksum(bool fix = false) = 0;
virtual std::pair<bool, bool> checkBothChecksums(bool fixGlobalChecksum = false, bool fixHeaderChecksum = false) = 0;
virtual bool isCorrupt(void) = 0;
virtual void saveEncrypted(u8* outBuf) = 0;
SaveMagic magic; // 0x00 -- 0x04 (0x03 actually)
s32 headerChecksum; // definition and location vary across Colosseum and XD
s32 saveCount;//, totalSaveCount;
/* A bit inconsistent across versions */
u32 memcardUID[2]; // u64. memcard[0:8] xor memcard[8:16] xor memcard[16:24] iirc
VersionInfo version;
LanguageIndex titleScreenLanguage;
bool noRumble;
const size_t nbRandomBytes;
u8* randomBytes;
PlayerData* player;
PCData* PC;
MailboxData* mailbox;
DaycareData* daycare;
StrategyMemoData* strategyMemo;
BattleModeData* battleMode;
protected:
virtual void deleteFields(void);
};
}
}
}
#endif

View File

@ -0,0 +1,37 @@
#ifndef _LIBPKMGC_XD_BAG_DATA_H
#define _LIBPKMGC_XD_BAG_DATA_H
#include <LibPkmGC/GC/Common/BagData.h>
namespace LibPkmGC {
namespace XD {
class LIBPKMGC_DECL BagData :
public GC::BagData
{
public:
static const size_t size = 0x418;
BagData(void);
BagData(const u8* inData);
BagData(BagData const& other);
~BagData();
void swap(BagData& other);
BagData* clone(void) const;
BagData* create(void) const;
void save(void);
Item battleCDs[60];
protected:
void loadFields(void);
private:
BagData(Colosseum::BagData const&);
};
}
}
#endif

View File

@ -0,0 +1,43 @@
#ifndef _LIBPKMGC_XD_BATTLE_MODE_DATA_H
#define _LIBPKMGC_XD_BATTLE_MODE_DATA_H
#include <LibPkmGC/GC/Common/BattleModeData.h>
#include <LibPkmGC/XD/Common/GroupBattleRule.h>
namespace LibPkmGC {
namespace XD {
/*
0x00: XDBattleRule rules[6]
0x360: u8 groupBattleModeUsed
0x361--0x363: unused/trash data
*/
class LIBPKMGC_DECL BattleModeData :
public GC::BattleModeData
{
public:
static const size_t size = 0x364;
BattleModeData(void);
BattleModeData(BattleModeData const&);
BattleModeData(const u8* inData);
~BattleModeData();
void swap(BattleModeData& other);
BattleModeData* clone(void) const;
BattleModeData* create(void) const;
void save(void);
bool battleModeUsed;
private:
void loadFields(void);
BattleModeData(Colosseum::BattleModeData const& other);
};
}
}
#endif

View File

@ -0,0 +1,31 @@
#ifndef _LIBPKMGC_XD_DAYCARE_DATA_H
#define _LIBPKMGC_XD_DAYCARE_DATA_H
#include <LibPkmGC/GC/Common/DaycareData.h>
#include <LibPkmGC/XD/Common/Pokemon.h>
namespace LibPkmGC {
namespace XD {
class LIBPKMGC_DECL DaycareData :
public GC::DaycareData
{
public:
static const size_t size = 0xcc;
DaycareData(void);
DaycareData(DaycareData const& other);
DaycareData(const u8* inData);
~DaycareData(void);
DaycareData* clone(void) const;
DaycareData* create(void) const;
DaycareData(Colosseum::DaycareData const& other);
private:
void loadFields(void);
};
}
}
#endif

View File

@ -0,0 +1,11 @@
#pragma once
#include <LibPkmGC/XD/Common/PlayerData.h>
#include <LibPkmGC/XD/Common/PCData.h>
#include <LibPkmGC/XD/Common/PlayerData.h>
#include <LibPkmGC/XD/Common/MailboxData.h>
#include <LibPkmGC/XD/Common/DaycareData.h>
#include <LibPkmGC/XD/Common/StrategyMemoData.h>
#include <LibPkmGC/XD/Common/BattleModeData.h>
#include <LibPkmGC/XD/Common/PurifierData.h>

View File

@ -0,0 +1,46 @@
#ifndef _LIBPKMGC_XD_GROUP_BATTLE_RULE_H
#define _LIBPKMGC_XD_GROUP_BATTLE_RULE_H
#include <LibPkmGC/GC/Common/GroupBattleRule.h>
#include <LibPkmGC/GC/Common/PokemonString.h>
namespace LibPkmGC {
namespace XD {
class LIBPKMGC_DECL GroupBattleRule :
public GC::GroupBattleRule
{
public:
static const size_t size = 0x90;
GroupBattleRule(const u8* inData);
GroupBattleRule(void);
GroupBattleRule(GroupBattleRule const& other);
~GroupBattleRule();
void swap(GroupBattleRule& other);
GroupBattleRule* clone(void) const;
GroupBattleRule* create(void) const;
void save(void);
bool revealDeoxysForm;
GC::PokemonString* customName; // 25 + 1
u16 nbPkm;
bool isBattleOpen; // unresticted number of Pkm., max. 6.
protected:
void loadFields(void);
void deleteFields(void);
private:
GroupBattleRule(Colosseum::GroupBattleRule const& other);
};
}
}
#endif

View File

@ -0,0 +1,39 @@
#ifndef _LIBPKMGC_XD_MAILBOX_DATA
#define _LIBPKMGC_XD_MAILBOX_DATA
#include <LibPkmGC/GC/Common/MailboxData.h>
namespace LibPkmGC {
namespace XD {
/*
0x00: u16 nbMails
0x02: u16 mails[32] = mailID or 255 if empty
0x42 -- end (0x49): unused (?)
*/
class LIBPKMGC_DECL MailboxData :
public GC::MailboxData
{
public:
static const size_t size = 0x4a;
MailboxData(void);
MailboxData(MailboxData const& other);
MailboxData(const u8* inData);
~MailboxData(void);
MailboxData* clone(void) const;
MailboxData* create(void) const;
void save(void);
protected:
void loadFields(void);
private:
MailboxData(Colosseum::MailboxData const&);
};
}
}
#endif

View File

@ -0,0 +1,39 @@
#ifndef _LIBPKMGC_XD_PC_DATA_H
#define _LIBPKMGC_XD_PC_DATA_H
#include <LibPkmGC/GC/Common/PCData.h>
#include <LibPkmGC/XD/Common/PokemonBox.h>
namespace LibPkmGC {
namespace XD {
/*
0x00: PokemonBox boxes[8]
0xb860: items[235]
0xbc0c -- end(0xbc50): unknown/unused ?
*/
class LIBPKMGC_DECL PCData :
public GC::PCData
{
public:
static const size_t size = 0xbc50;
PCData(void);
PCData(PCData const& other);
PCData(const u8* inData);
~PCData(void);
PCData* clone(void) const;
PCData* create(void) const;
void save(void);
protected:
void loadFields(void);
private:
PCData(Colosseum::PCData const&);
};
}
}
#endif

View File

@ -0,0 +1,49 @@
#ifndef _LIBPKMGC_XD_PLAYER_DATA_H
#define _LIBPKMGC_XD_PLAYER_DATA_H
#include <LibPkmGC/GC/Common/PlayerData.h>
#include <LibPkmGC/XD/Common/Pokemon.h>
#include <LibPkmGC/XD/Common/BagData.h>
namespace LibPkmGC {
namespace XD {
/*
0x00 -- 0x2b: trainer name (10+1 wide characters) + copy
0x2c: u16 SID
0x2e: u16 TID
0x30: Pokémon Party (6*0xc4)
0x4c8: bag
0x8e0: u8 trainerGender
0x8e4: u32 money
0x8e8: u32 pkCoupons + copy
*/
class LIBPKMGC_DECL PlayerData :
public GC::PlayerData
{
public:
static const size_t size = 0x978;
PlayerData(void);
PlayerData(PlayerData const& other);
PlayerData(const u8* inData);
~PlayerData(void);
PlayerData* clone(void) const;
PlayerData* create(void) const;
//void swap(PlayerData& other);
void save(void);
protected:
void loadFields(void);
private:
PlayerData(Colosseum::PlayerData const&);
};
}
}
#endif

View File

@ -0,0 +1,93 @@
#ifndef _LIBPKMGC_XD_POKEMON_H
#define _LIBPKMGC_XD_POKEMON_H
#include <LibPkmGC/GC/Common/Pokemon.h>
namespace LibPkmGC {
namespace XD {
/*
0x00: u16 species
0x02: u16 itemHeld
0x04: u16 currentHP
0x06: u16 happiness
0x08: u16 locationCaught
// 0x09 -- 0xd :: ??
0x0e: u8 levelMet
0x0f: u8 ballCaughtWith
0x10: u8 OTGender (00 male 01 female 02 genderless=none)
0x11: u8 currentLevel
0x12: u8 Contest Luster
0x13: u8 pkrsStatus
0x14: u8 marks (bitfield)
0x15: 0xff ?
0x16: u16 status (3 psn, 4 psn (toxic ?), 5 par, 6 brn, 7 frzn, 8 slp)
0x17: ?
0x18 -- 0x1b : ? (0x50)
0x1d: u8 pkmFlags
bit 7: egg flag
bit 6: special (second) ability flag. Pokémon XD's catchable Pkms have a 50% chance to have their special ability
bit 5: invalidity flag. MUST **NOT** BE SET for the Pokémon to be considered as valid ("not empty")
bit 4: "not traded" flag ??
bit 2: "caught" flag ??
0x1e 0x1f : ??
0x20: u32 experience
0x24: u16 SID
0x26: u16 TID
0x28: u32 PID
0x2c -- 0x32 : ?? (0 on shadow pkm)
0x33: u8 encounterType
0x34 -- 0x37 : Version info (actual region, original region, original language)
0x38: GC::PokemonString OTName (10+1 chars = 22 bytes)
0x4e: GC::PokemonString name (10+1 chars)
0x64: pkm name backup
0x7a -- 0x7b: ??
0x7c: u16 specialRibbons
0x7e -- 0x7f: ??
0x80: moves[4]{u16 moveID, u8 basePP (?), u8 nbPPUps}
0x90: u16 stats[6]
0x9c: u16 EVs[6]
0xa8: u8 IVs[6]
0xae: u8 contestStats[6] (0 to 255)
0xb3: u8 contestAchievements[5]
0xb7: unused
0xb8 : u16 ??
0xba: shadow pkm id
0xbc -- 0xbf : ??? ????
0xc0 -- 0xc1 : unused ?
0xc2: party identify (lead = 00, 01 otherwise)
*/
class LIBPKMGC_DECL Pokemon : public GC::Pokemon {
public:
static const size_t size = 0xc4;
Pokemon(void);
Pokemon(const u8* inData);
Pokemon(Pokemon const& other);
~Pokemon(void);
Pokemon* clone(void) const;
Pokemon* create(void) const;
void save(void);
void swap(Pokemon& other);
Pokemon& operator=(Pokemon const& other);
bool hasSpecialAbility(void) const;
void setSpecialAbilityStatus(bool status);
u8 pkmFlags;
bool isEmptyOrInvalid(void) const;
Pokemon(Colosseum::Pokemon const& other);
Pokemon& operator=(GC::Pokemon const& other);
void swap(GC::Pokemon & other);
private:
void loadFields(void);
};
}
}
#endif

View File

@ -0,0 +1,33 @@
#ifndef _LIBPKMGC_XD_POKEMON_BOX_H
#define _LIBPKMGC_XD_POKEMON_BOX_H
#include <LibPkmGC/GC/Common/PokemonBox.h>
#include <LibPkmGC/XD/Common/Pokemon.h>
namespace LibPkmGC {
namespace XD {
class LIBPKMGC_DECL PokemonBox :
public GC::PokemonBox
{
public:
static const size_t size = 0x170c;
PokemonBox(void);
PokemonBox(PokemonBox const& other);
PokemonBox(const u8* inData);
~PokemonBox(void);
PokemonBox* clone(void) const;
PokemonBox* create(void) const;
void save(void);
PokemonBox(Colosseum::PokemonBox const& other);
protected:
void loadFields(void);
};
}
}
#endif

View File

@ -0,0 +1,47 @@
#ifndef _LIBPKMGC_XD_PURIFICATION_CHAMBER_H
#define _LIBPKMGC_XD_PURIFICATION_CHAMBER_H
#include <LibPkmGC/XD/Common/Pokemon.h>
namespace LibPkmGC {
namespace XD {
/*
0x00: XDPokemon normalPkm[4]
0x310: XDPokemon shadowPkm
0x3d4: u8 ??
0x3d5 -- end: padding/trash bytes
*/
class LIBPKMGC_DECL PurificationChamber :
public Base::DataStruct
{
public:
static const size_t size = 0x3d8;
PurificationChamber(void);
PurificationChamber(const u8* inData);
~PurificationChamber(void);
PurificationChamber(PurificationChamber const& other);
PurificationChamber& operator=(PurificationChamber const& other);
void swap(PurificationChamber& other);
PurificationChamber* clone(void) const;
PurificationChamber* create(void) const;
void save(void);
Pokemon* normalPkm[4];
Pokemon* shadowPkm;
private:
void deleteFields(void);
void loadFields(void);
};
}
}
#endif

View File

@ -0,0 +1,43 @@
#ifndef _LIBPKMGC_PURIFIER_DATA_H
#define _LIBPKMGC_PURIFIER_DATA_H
#include <LibPkmGC/XD/Common/PurificationChamber.h>
namespace LibPkmGC {
namespace XD {
/*
0x00--end(0x2298): PurificationChamber chambers[9]
*/
class LIBPKMGC_DECL PurifierData :
public Base::DataStruct
{
public:
static const size_t size = 0x2298;
PurifierData(void);
PurifierData(const u8* inData);
~PurifierData(void);
PurifierData(PurifierData const& other);
PurifierData& operator=(PurifierData const& other);
void swap(PurifierData& other);
PurifierData* clone(void) const;
PurifierData* create(void) const;
void save(void);
PurificationChamber* chambers[9];
private:
void deleteFields(void);
void loadFields(void);
};
}
}
#endif

View File

@ -0,0 +1,37 @@
#ifndef _LIBPKMGC_XD_STRATEGY_MEMO_DATA_H
#define _LIBPKMGC_XD_STRATEGY_MEMO_DATA_H
#include <LibPkmGC/GC/Common/StrategyMemoData.h>
#include <LibPkmGC/XD/Common/StrategyMemoEntry.h>
namespace LibPkmGC {
namespace XD {
class LIBPKMGC_DECL StrategyMemoData :
public GC::StrategyMemoData
{
public:
static const size_t size = 0x1774;
~StrategyMemoData(void);
bool isXD(void) const;
StrategyMemoData(void);
StrategyMemoData(const u8* inData);
StrategyMemoData(StrategyMemoData const& other);
StrategyMemoData* clone(void) const;
StrategyMemoData* create(void) const;
void save(void);
StrategyMemoData(Colosseum::StrategyMemoData const& other);
protected:
void loadFields(void);
};
}
}
#endif

View File

@ -0,0 +1,30 @@
#ifndef _LIBPKMGC_XD_STRATEGY_MEMO_ENTRY_H
#define _LIBPKMGC_XD_STRATEGY_MEMO_ENTRY_H
#include <LibPkmGC/GC/Common/StrategyMemoEntry.h>
namespace LibPkmGC {
namespace XD {
class LIBPKMGC_DECL StrategyMemoEntry :
public GC::StrategyMemoEntry
{
public:
static const size_t size = 12;
~StrategyMemoEntry(void);
StrategyMemoEntry(void);
StrategyMemoEntry(const u8* inData);
bool isXD(void) const;
StrategyMemoEntry* clone(void) const;
StrategyMemoEntry* create(void) const;
bool isInfoPartial(void) const;
void setInfoCompleteness(bool partial);
};
}
}
#endif

View File

@ -0,0 +1,39 @@
#ifndef _LIBPKMGC_XD_SAVE_EDITING_SAVE_H
#define _LIBPKMGC_XD_SAVE_EDITING_SAVE_H
#include <LibPkmGC/GC/SaveEditing/Save.h>
#include <LibPkmGC/XD/SaveEditing/SaveSlot.h>
namespace LibPkmGC {
namespace XD {
namespace SaveEditing {
class LIBPKMGC_DECL Save :
public GC::SaveEditing::Save
{
public:
static const size_t size = 0x56000;
Save(void);
Save(Save const& other);
Save(const u8* inData, bool hasGCIData_ = false, bool isDecrypted = false);
//~Save(void);
Save* clone(void) const;
Save* create(void) const;
void save(void);
void saveUnshuffled(void);
protected:
void loadFields(void);
private:
Save(Colosseum::SaveEditing::Save const&);
};
}
}
}
#endif

View File

@ -0,0 +1,109 @@
#ifndef _LIBPKMGC_XD_SAVE_EDITING_SAVE_SLOT_H
#define _LIBPKMGC_XD_SAVE_EDITING_SAVE_SLOT_H
#include <LibPkmGC/GC/SaveEditing/SaveSlot.h>
#include <LibPkmGC/XD/Common/Everything.h>
namespace LibPkmGC {
namespace XD {
namespace SaveEditing {
/*
0x00: u32 magic
0x04: s32 saveCount
0x08: u16 encryptionKeys[4] (random generated)
0x10: **ENCRYPTED DATA**
0x10: u32 checksum[4] (stored in a particular way, see below)
0x20: u16 substructureSizes[16]
0x40: u32 substructureOffsets[16] (stored in a particular way, see below)
0x80: u16 substructure8SubsubstructureSizes[5] (??)
0xa8: substructures
(end)-40: **END OF ENCRYPTED DATA**
(end)-40: u8 randomBytes[40];
*/
/*
Substructures, in order :
- [0] metadata/game config, size=0x88 (for compat. w/ colosseum it is directly handled within GC::SaveSlot)
- [1] party & player data
- [2] PC Storage
- [3] Mailbox
- [4] Daycare
- [5] Strategy memo
- [6] Battle mode
- [7] Shadow Pokémon data (in Colosseum, this is apparently a PID list; the full shadow data SEEMS to be included in the Pokémon's data)
- ?
- ?
- map data / script state
- Purifier
*/
/*
Metadata substructure (off 0 (total 0xa8)) :
0x00: VersionInfo version (game, region, language)
0x04--0x07: u32 ?
0x08: u64 memcardUID (see GCSaveSlot.h)
0x29: u8 noRumble
0x2a: u16 titleScreenLanguage
0x38: s32 headerChecksum
*/
class LIBPKMGC_DECL SaveSlot :
public GC::SaveEditing::SaveSlot
{
public:
static const size_t size = 0x28000;
SaveSlot(void);
SaveSlot(const u8* inData, bool isDecrypted = false);
SaveSlot(SaveSlot const& other);
~SaveSlot(void);
SaveSlot* clone(void) const;
SaveSlot* create(void) const;
void swap(SaveSlot& other);
SaveSlot& operator=(SaveSlot const& other);
void save(void);
bool checkChecksum(bool fix = false);
bool checkHeaderChecksum(bool fix = false);
std::pair<bool, bool> checkBothChecksums(bool fixGlobalChecksum = false, bool fixHeaderChecksum = false);
bool isCorrupt(void);
void reorderSubstructures(void);
void saveUnshuffled(void);
void saveEncrypted(u8* outBuf);
PurifierData* purifier;
u32 checksum[4];
u16 encryptionKeys[4];
u32 substructureSizes[16]; // there are actually 12 substructures
u32 substructureOffsets[16]; // there are actually 12 substructures
protected:
void loadData(u32 flags = 0);
void deleteFields(void);
void loadFields(void);
private:
Base::UnimplementedStruct* unhandledSubstructures[16]; // by definition don't pay attention to that
void _deleteFields_extension(void);
bool _other_corruption_flags;
SaveSlot(Colosseum::SaveEditing::SaveSlot const&);
};
}
}
}
#endif

View File

@ -0,0 +1,80 @@
#include <LibPkmGC/Base/DataStruct.h>
namespace LibPkmGC {
namespace Base {
//size_t allocatedBytesInUsage = 0;
DataStruct::DataStruct(void) : data(NULL), size(0), fixedSize(0) {}
void DataStruct::copyData(const u8* inData) {
if (inData == NULL) {
data = NULL;
return;
}
delete[] data;
data = new u8[size];
std::copy(inData, inData + size, data);
}
void DataStruct::loadData(u32 flags) {};
void DataStruct::load(u32 flags) {
loadData(flags);
loadFields();
}
DataStruct::DataStruct(size_t inSize, const u8* inData, bool fixed) : size(inSize), data(NULL), fixedSize((fixed) ? inSize : 0) {
// allocatedBytesInUsage += inSize;
copyData(inData);
}
DataStruct::~DataStruct(void) {
// allocatedBytesInUsage -= size;
delete[] data;
}
bool DataStruct::sizeIsFixed(void) const{
return fixedSize != 0;
}
void DataStruct::reload(const u8* inData, u32 flags) {
deleteFields();
if (inData != NULL) std::copy(inData, inData + size, data);
load(flags);
}
DataStruct::DataStruct(DataStruct const& other) : size(other.size), fixedSize(other.fixedSize) {
data = new u8[size];
std::copy(other.data, other.data + size, data);
}
void DataStruct::swap(DataStruct& other) {
if ((!sizeIsFixed() || (sizeIsFixed() && (size == other.size))) && (this != &other))
SW(data);
}
DataStruct& DataStruct::operator=(const DataStruct& other) {
if (this != &other) {
if (sizeIsFixed()) {
if (size == other.size) CP_ARRAY(data, size);
else std::fill(data, data + size, 0);
}
else {
CP(size);
delete[] data;
data = new u8[size];
std::copy(other.data, other.data + size, data);
}
}
return *this;
}
void DataStruct::initWithEmptyData(u32 flags) {
if (data != NULL) delete[] data;
data = new u8[size];
std::fill(data, data + size, 0);
loadFields();
}
size_t DataStruct::getSize(void) const { return size; }
}
}

View File

@ -0,0 +1,220 @@
#include <LibPkmGC/Base/Pokemon.h>
namespace LibPkmGC {
namespace Base {
u16 Pokemon::calculateStat(size_t statIndex, PokemonSpeciesIndex species, PokemonNatureIndex natureIndex, u8 level, u8 IV, u8 EV){
static const u16 n[3] = { 110, 100, 90 };
if ((statIndex == 0) && (species == Shedinja)) return 1;
if (statIndex >= 6) return 0;
size_t i = statIndex;
u16 outStat;
outStat = IV + (2 * getSpeciesData(species).baseStats[i]) + EV / 4;
// We're applying bonuses now
if(i == 0) return ((outStat + 100) * level / 100) + 10; // HP
else return (outStat * level / 100 + 5) * n[(size_t)getNatureStatAffinity(natureIndex, i) ] / 100;
}
void Pokemon::calculateStats(PokemonSpeciesIndex species, PokemonNatureIndex natureIndex, u8 level, const u8 IVs[6], const u8 EVs[6], u16 outStats[6]) {
for (size_t i = 0; i < 6; ++i)
outStats[i] = calculateStat(i, species, natureIndex, level, IVs[i], EVs[i]);
}
u8 Pokemon::calculateLevelFromExp(PokemonSpeciesIndex species, u32 experience) {
const u32* expTable = getSpeciesExpTable(species);
if (experience >= expTable[100]) return 100;
u8 i = 0;
while (i < 100 && experience >= expTable[++i]);
return i-1;
}
u32 Pokemon::calculateExpFromLevel(PokemonSpeciesIndex species, u8 level) {
const u32* expTable = getSpeciesExpTable(species);
if (level >= 100) return expTable[100];
return expTable[level];
}
Pokemon::Pokemon(size_t inSize, const u8* inData) : DataStruct(inSize, inData) {
}
Pokemon::~Pokemon(void) {
}
u8 Pokemon::calculateLevelFromExp(void) const {
return calculateLevelFromExp(species, experience);
}
void Pokemon::updateLevelFromExp(void) { partyData.level = calculateLevelFromExp(); }
u32 Pokemon::calculateExpFromLevel(u8 lvl) const {
return calculateExpFromLevel(species, lvl);
}
void Pokemon::updateExpFromLevel(u8 lvl) { experience = calculateExpFromLevel(lvl); }
void Pokemon::calculateStats(u16 outStats[6]) const {
calculateStats(species, (PokemonNatureIndex)(PID % 25), calculateLevelFromExp(), IVs, EVs, outStats);
}
void Pokemon::updateStats(void) { calculateStats(partyData.stats); }
bool Pokemon::isShiny(u32 PID, u16 TID, u16 SID) {
return ((PID >> 16) ^ (PID & 0xffff) ^ SID ^ TID) < 8;
}
PokemonNatureIndex Pokemon::getNature(u32 PID) {
return (PokemonNatureIndex)(PID % 25);
}
Gender Pokemon::getGender(PokemonSpeciesIndex species, u32 PID) {
PokemonSpeciesGenderRatio r = getSpeciesData(species).genderRatio;
if (r == GenderlessOnly) return Genderless;
else if (r == MaleOnly) return Male;
else if (r == FemaleOnly) return Female;
else
return ((PID & 0xff) >= (u32)r) ? Male : Female;
}
PokemonSpeciesIndex Pokemon::getWurmpleEvolution(u32 PID) {
return (((PID & 0xffff) % 10) < 5) ? Silcoon : Cascoon;
}
char Pokemon::getUnownForm(u32 PID) {
char tbl[] = "ABCDEFGHIKLMNOPQRSTUVWXYZ?!";
u32 n = (((PID >> 24) & 3) << 6) | (((PID >> 16) & 3) << 4) | (((PID >> 8) & 3) << 2) | (PID & 3);
return tbl[n % 28];
}
bool Pokemon::isShiny(void) const {
return isShiny(PID, TID, SID);
}
PokemonNatureIndex Pokemon::getNature(void) const {
return getNature(PID);
}
Gender Pokemon::getGender(void) const {
return getGender(species, PID);
}
PokemonSpeciesIndex Pokemon::getWurmpleEvolution(void) const {
return getWurmpleEvolution(PID);
}
char Pokemon::getUnownForm(void) const {
return getUnownForm(PID);
}
void Pokemon::resetPartyData(void) {
updateStats();
updateLevelFromExp();
partyData.status = NoStatus;
partyData.currentHP = partyData.stats[0];
}
Pokemon::Pokemon(Pokemon const & other) : Base::DataStruct(other.fixedSize, NULL, true){
data = new u8[other.fixedSize];
Pokemon::operator=(other);
}
void Pokemon::deleteFields(void){
}
/*
void Pokemon::calculateSpindaSpotsPosition(std::pair<u8,u8>[4]) const{
u32 PID_2 = PID;
}*/
bool Pokemon::isEmptyOrInvalid(void) const {
return (species > 0x19e) || (species == 0) || !getSpeciesData(species).isValid || version.isIncomplete();
}
bool Pokemon::isSpecialAbilityDefined(void) const{
return (getSpeciesData(species).possibleAbilities[1] != NoAbility);
}
void Pokemon::swap(Pokemon& other) {
DataStruct::swap(other);
SW(species);
SW(heldItem);
SW(happiness);
SW(locationCaught);
SW(ballCaughtWith);
SW(levelMet);
SW(OTGender);
SW(OTName);
SW(name);
SW(contestLuster);
SW(pkrsStatus);
SW(markings);
SW(experience);
SW(SID);
SW(TID);
SW(PID);
// SW(encounterType);
SW(version);
SW(usesPartyData);
SW(partyData);
SW_ARRAY(specialRibbons, 12)
SW_ARRAY(moves, 4);
SW_ARRAY(EVs, 6);
SW_ARRAY(IVs, 6);
SW_ARRAY(contestStats, 5);
SW_ARRAY(contestAchievements, 5);
}
Pokemon & Pokemon::operator=(Pokemon const & other){
if (this != &other) {
Base::DataStruct::operator=(other);
CP(species);
CP(heldItem);
CP(happiness);
CP(locationCaught);
CP(ballCaughtWith);
CP(levelMet);
CP(OTGender);
CL(OTName)
CL(name);
CP(contestLuster);
CP(pkrsStatus);
CP(markings);
CP(experience);
CP(SID);
CP(TID);
CP(PID);
// CP(encounterType);
CP(version);
CP_ARRAY(specialRibbons, 12);
CP(usesPartyData);
CP(partyData);
CP_ARRAY(moves, 4);
CP_ARRAY(EVs, 6);
CP_ARRAY(IVs, 6);
CP_ARRAY(contestStats, 5);
CP_ARRAY(contestAchievements, 5);
}
return *this;
}
}
}

View File

@ -0,0 +1,41 @@
#include <LibPkmGC/Base/PokemonBox.h>
namespace LibPkmGC {
namespace Base {
PokemonBox::PokemonBox(size_t inSize, const u8* inData) : DataStruct(inSize, inData) {
}
void PokemonBox::deleteFields(void) {
for (size_t i = 0; i < 30; ++i)
delete pkm[i];
}
PokemonBox::PokemonBox(PokemonBox const& other) : DataStruct(other) {
CL(name);
CL_ARRAY(pkm, 30);
}
PokemonBox::~PokemonBox(void) {
PokemonBox::deleteFields();
}
void PokemonBox::swap(PokemonBox& other) {
DataStruct::swap(other);
SW(name);
for (size_t i = 0; i < 30; ++i) pkm[i]->swap(*other.pkm[i]);
}
PokemonBox& PokemonBox::operator=(PokemonBox const& other) {
DataStruct::operator=(other);
if (this != &other) {
PokemonBox::deleteFields();
for (size_t i = 0; i < 30; ++i) *pkm[i] = *(other.pkm[i]);
CL(name);
}
return *this;
}
}
}

View File

@ -0,0 +1,44 @@
#include <LibPkmGC/Base/PokemonString.h>
namespace LibPkmGC {
namespace Base {
PokemonString::PokemonString(void) : hasChanged(true), _str(NULL), strSz(0), strCapacity(0) {
}
PokemonString::~PokemonString(void) {
}
PokemonString & PokemonString::operator=(PokemonString const & other) {
if (this != &other) {
hasChanged = other.hasChanged;
strSz = other.strSz;
resizeStr();
std::copy(other._str, other._str + strSz, _str);
}
return *this;
}
PokemonString::operator const char*(void) const {
return toUTF8();
}
PokemonString::PokemonString(PokemonString const & other) : hasChanged(other.hasChanged), strSz(other.strSz), strCapacity(0), _str(NULL) {
resizeStr();
std::copy(other._str, other._str + strSz, _str);
}
void PokemonString::resizeStr(void) const {
if (strCapacity < strSz) {
strCapacity = strSz;
delete[] _str;
_str = new char[strSz];
}
}
}
}

View File

@ -0,0 +1,28 @@
#include <LibPkmGC/Colosseum/Common/BagData.h>
namespace LibPkmGC {
namespace Colosseum {
BagData::BagData(void) : GC::BagData(0x300, 20) {
initWithEmptyData();
}
BagData::BagData(const u8* inData) : GC::BagData(0x300, 20, inData) {
load();
}
BagData::BagData(BagData const& other) : GC::BagData(other){}
BagData::~BagData(){
}
BagData* BagData::clone(void) const {
return new BagData(*this);
}
BagData* BagData::create(void) const {
return new BagData;
}
}
}

View File

@ -0,0 +1,42 @@
#include <LibPkmGC/Colosseum/Common/BattleModeData.h>
namespace LibPkmGC {
namespace Colosseum {
BattleModeData::BattleModeData(void) : GC::BattleModeData(0xcc2c) {
initWithEmptyData();
}
BattleModeData::BattleModeData(const u8* inData) : GC::BattleModeData(0xcc2c, inData) {
load();
}
BattleModeData::BattleModeData(BattleModeData const& other) : GC::BattleModeData(other) {}
BattleModeData::~BattleModeData()
{
}
BattleModeData* BattleModeData::clone(void) const
{
return new BattleModeData(*this);
}
BattleModeData* BattleModeData::create(void) const
{
return new BattleModeData;
}
void BattleModeData::loadFields(void) {
LD_SUBSTRUCTURE_ARRAY(GroupBattleRule, rules, 6, 0xc16c);
//LD_FIELD_B(u8, groupBattleModeUsed, 0x360);
}
void BattleModeData::save(void) {
SV_SUBSTRUCTURE_ARRAY(GroupBattleRule, rules, 6, 0xc16c);
//SV_FIELD_B(u8, groupBattleModeUsed, 0x360);
}
}
}

View File

@ -0,0 +1,34 @@
#include <LibPkmGC/Colosseum/Common/DaycareData.h>
namespace LibPkmGC {
namespace Colosseum {
DaycareData::DaycareData(void) : GC::DaycareData(0x140) {
initWithEmptyData();
}
DaycareData::DaycareData(const u8* inData) : GC::DaycareData(0x140, inData) {
load();
}
DaycareData::DaycareData(DaycareData const& other) : GC::DaycareData(other) {}
DaycareData::~DaycareData(void) {
}
void DaycareData::loadFields(void) {
GC::DaycareData::loadFields();
status = (status == NotVisited) ? NoPkmDeposited : status;
pkm = new Pokemon(data + 8);
}
DaycareData* DaycareData::clone(void) const {
return new DaycareData(*this);
}
DaycareData* DaycareData::create(void) const {
return new DaycareData;
}
}
}

View File

@ -0,0 +1,40 @@
#include <LibPkmGC/Colosseum/Common/GroupBattleRule.h>
namespace LibPkmGC {
namespace Colosseum {
GroupBattleRule::GroupBattleRule(const u8* inData) : GC::GroupBattleRule(0x54, 60, inData) {
load();
}
GroupBattleRule::GroupBattleRule(void) : GC::GroupBattleRule(0x54, 60) {
initWithEmptyData();
}
GroupBattleRule::GroupBattleRule(GroupBattleRule const& other) : GC::GroupBattleRule(other) {}
GroupBattleRule::~GroupBattleRule()
{
}
GroupBattleRule* GroupBattleRule::clone(void) const {
return new GroupBattleRule(*this);
}
GroupBattleRule* GroupBattleRule::create(void) const {
return new GroupBattleRule;
}
void GroupBattleRule::loadFields(void) {
GC::GroupBattleRule::loadFields();
LD_ARRAY_B(u8, bannedItems, 60, 24);
}
void GroupBattleRule::save(void) {
GC::GroupBattleRule::save();
SV_ARRAY_B(u8, bannedItems, 60, 24);
}
}
}

View File

@ -0,0 +1,40 @@
#include <LibPkmGC/Colosseum/Common/MailboxData.h>
namespace LibPkmGC {
namespace Colosseum {
MailboxData::MailboxData(void) : GC::MailboxData(0x448, 512) {
initWithEmptyData();
}
MailboxData::MailboxData(const u8* inData) : GC::MailboxData(0x448, 512, inData) {
load();
}
MailboxData::MailboxData(MailboxData const& other) : GC::MailboxData(other) {}
MailboxData::~MailboxData() {
}
MailboxData* MailboxData::clone(void) const {
return new MailboxData(*this);
}
MailboxData* MailboxData::create(void) const {
return new MailboxData;
}
void MailboxData::loadFields(void) {
mails = new u16[512];
LD_ARRAY(u16, mails, 512, 0);
LD_FIELD(u16, nbMails, 0x400);
}
void MailboxData::save(void) {
SV_ARRAY(u16, mails, 512, 0);
SV_FIELD(u16, nbMails, 0x400);
}
}
}

View File

@ -0,0 +1,44 @@
#include <LibPkmGC/Colosseum/Common/PCData.h>
namespace LibPkmGC {
namespace Colosseum {
PCData::PCData(void) : GC::PCData(0x7198, 3) {
initWithEmptyData();
}
PCData::PCData(const u8* inData) : GC::PCData(0x7198, 3, inData) {
load();
}
PCData::PCData(PCData const& other) : GC::PCData(other) {}
PCData::~PCData(void) {
}
PCData* PCData::clone(void) const {
return new PCData(*this);
}
PCData* PCData::create(void) const {
return new PCData;
}
void PCData::loadFields(void) {
boxes = new GC::PokemonBox*[nbBoxes];
LD_SUBSTRUCTURE_ARRAY(PokemonBox, boxes, 3, 0);
for (size_t i = 0; i < 235; ++i)
items[i].load(data + 0x6dec + 4*i);
}
void PCData::save(void) {
SV_SUBSTRUCTURE_ARRAY(PokemonBox, boxes, 3, 0);
for (size_t i = 0; i < 235; ++i)
items[i].save(data + 0x6dec + 4*i);
}
}
}

View File

@ -0,0 +1,53 @@
#include <LibPkmGC/Colosseum/Common/PlayerData.h>
namespace LibPkmGC {
namespace Colosseum {
PlayerData::PlayerData(void) : GC::PlayerData(0xb18) {
initWithEmptyData();
}
PlayerData::PlayerData(const u8* inData) : GC::PlayerData(0xb18, inData) {
load();
}
PlayerData::PlayerData(PlayerData const& other) : GC::PlayerData(other) {}
PlayerData::~PlayerData(void){
}
PlayerData* PlayerData::clone(void) const {
return new PlayerData(*this);
}
PlayerData* PlayerData::create(void) const {
return new PlayerData;
}
void PlayerData::loadFields(void) {
GC::PlayerData::loadFields();
LD_FIELD_E(u8, trainerGender, 0xa80, Gender);
if (trainerGender > Female) trainerGender = Male;
LD_FIELD(u32, money, 0xa84);
LD_FIELD(u32, pkCoupons, 0xa88);
LD_SUBSTRUCTURE_ARRAY(Pokemon, party, 6, 0x30);
LD_SUBSTRUCTURE(BagData, bag, 0x780);
}
void PlayerData::save(void) {
GC::PlayerData::save();
if (trainerGender > Female) trainerGender = Male;
SV_FIELD_E(u8, trainerGender, 0xa80, Gender);
SV_FIELD(u32, money, 0xa84);
SV_FIELD(u32, pkCoupons, 0xa88);
SV_FIELD(u32, pkCoupons, 0xa8c);
SV_SUBSTRUCTURE_ARRAY(Pokemon, party, 6, 0x30);
SV_SUBSTRUCTURE(BagData, bag, 0x780);
}
}
}

View File

@ -0,0 +1,152 @@
#include <LibPkmGC/Colosseum/Common/Pokemon.h>
namespace LibPkmGC {
namespace Colosseum {
Pokemon::Pokemon(const u8* inData) : GC::Pokemon(0x138, inData) {
load();
}
Pokemon::Pokemon(void) : GC::Pokemon(0x138) { initWithEmptyData(); }
Pokemon::~Pokemon(void) {
}
Pokemon::Pokemon(Pokemon const& other) : GC::Pokemon(other), specialAbilityStatus(other.specialAbilityStatus){}
Pokemon* Pokemon::clone(void) const { return new Pokemon(*this); }
Pokemon* Pokemon::create(void) const { return new Pokemon; }
void Pokemon::swap(Pokemon& other) {
GC::Pokemon::swap(other);
SW(specialAbilityStatus);
}
void Pokemon::loadFields(void) {
u8 marksTmp = 0;
LD_FIELD_E(u16, species, 0x00, PokemonSpeciesIndex);
LD_FIELD(u32, PID, 0x04);
version.load(data + 0x08);
u16 locationCaught_tmp;
LD_FIELD(u16, locationCaught_tmp, 0x0c);
locationCaught = (u8)((locationCaught_tmp > 255) ? 255 : locationCaught_tmp);
LD_FIELD(u8, levelMet, 0x0e);
LD_FIELD_E(u8, ballCaughtWith, 0x0f, ItemIndex);
LD_FIELD_E(u8, OTGender, 0x10, Gender);
LD_FIELD(u16, SID, 0x14);
LD_FIELD(u16, TID, 0x16);
OTName = new GC::PokemonString(data + 0x18, 10);
name = new GC::PokemonString(data + 0x2e, 10);
LD_FIELD(u32, experience, 0x5c);
LD_FIELD(u8, partyData.level, 0x60);
if (partyData.level > 100) partyData.level = 100;
LD_FIELD_E(u16, partyData.status, 0x65, PokemonStatus);
partyData.status = (partyData.status != NoStatus && partyData.status < Poisoned && partyData.status > Asleep) ? NoStatus : partyData.status;
LD_FIELD_E(u16, heldItem, 0x88, ItemIndex);
LD_FIELD(u16, partyData.currentHP, 0x8a);
LD_ARRAY(u16, partyData.stats, 6, 0x8c);
u16 EVs_tmp[6]; // EVs are internally stored as u16
LD_ARRAY(u16, EVs_tmp, 6, 0x98);
for (size_t i = 0; i < 6; ++i) EVs[i] = (u8)((EVs_tmp[i] > 255) ? 255 : EVs_tmp[i]);
LD_ARRAY(u8, IVs, 6, 0xa4);
for (size_t i = 0; i < 6; ++i) IVs[i] = (IVs[i] > 31) ? 31 : IVs[i];
u16 happiness_tmp;
LD_FIELD(u16, happiness_tmp, 0xb0);
happiness = (happiness_tmp > 255) ? 255 : happiness_tmp;
LD_ARRAY(u8, contestStats, 5, 0xb2);
LD_ARRAY_E(u8, contestAchievements, 5, 0xb7, ContestAchievementLevel);
LD_FIELD(u8, contestLuster, 0xbc);
LD_ARRAY_B(u8, specialRibbons, 12, 0xbd);
LD_FIELD(u8, pkrsStatus, 0xca);
LD_FIELD_B(u8, specialAbilityStatus, 0xcc);
LD_FIELD(u8, marksTmp, 0xcf);
LD_FIELD(u16, shadowPkmID, 0xd8);
markings.load(marksTmp);
for (size_t i = 0; i < 4; ++i)
moves[i].load(data + 0x78 + 4 * i);
}
void Pokemon::save(void) {
SV_FIELD_E(u16, species, 0x00, PokemonSpeciesIndex);
SV_FIELD(u32, PID, 0x04);
version.save(data + 0x08);
SV_FIELD(u16, (u16) locationCaught, 0x0c);
SV_FIELD(u8, levelMet, 0x0e);
SV_FIELD_E(u8, ballCaughtWith, 0x0f, ItemIndex);
SV_FIELD_E(u8, OTGender, 0x10, Gender);
SV_FIELD(u16, SID, 0x14);
SV_FIELD(u16, TID, 0x16);
OTName->save(data + 0x18, 10);
name->save(data + 0x2e, 10);
name->save(data + 0x44, 10);
SV_FIELD(u32, experience, 0x5c);
if (partyData.level > 100) partyData.level = 100;
SV_FIELD(u8, partyData.level, 0x60);
partyData.status = (partyData.status != NoStatus && partyData.status < Poisoned && partyData.status > Asleep) ? NoStatus : partyData.status;
SV_FIELD_E(u16, partyData.status, 0x65, PokemonStatus);
SV_FIELD_E(u16, heldItem, 0x88, ItemIndex);
SV_FIELD(u16, partyData.currentHP, 0x8a);
SV_ARRAY(u16, partyData.stats, 6, 0x8c);
u16 EVs_tmp[6]; for (size_t i = 0; i < 6; ++i) EVs_tmp[i] = (u16)EVs[i];
SV_ARRAY(u16, EVs_tmp, 6, 0x98);
for (size_t i = 0; i < 6; ++i) IVs[i] = (IVs[i] > 31) ? 31 : IVs[i];
SV_ARRAY(u8, IVs, 6, 0xa4);
SV_FIELD(u16, (u16)happiness, 0xb0);
SV_ARRAY(u8, contestStats, 5, 0xb2);
SV_ARRAY_E(u8, contestAchievements, 5, 0xb7, ContestAchievementLevel);
SV_FIELD(u8, contestLuster, 0xbc);
SV_ARRAY_B(u8, specialRibbons, 12, 0xbd);
SV_FIELD(u8, pkrsStatus, 0xca);
SV_FIELD_B(u8, specialAbilityStatus, 0xcc);
SV_FIELD(u8, markings.save(), 0xcf);
SV_FIELD(u16, shadowPkmID, 0xd8);
for (size_t i = 0; i < 4; ++i)
moves[i].save(data + 0x78 + 4 * i);
}
Pokemon& Pokemon::operator=(Pokemon const& other) {
if (this != &other) {
GC::Pokemon::operator=(other);
CP(specialAbilityStatus);
}
return *this;
}
LIBPKMGC_GC_GEN_COL_VTF(Pokemon)
bool Pokemon::hasSpecialAbility(void) const {
return isSpecialAbilityDefined() && specialAbilityStatus;
}
void Pokemon::setSpecialAbilityStatus(bool status) {
specialAbilityStatus = isSpecialAbilityDefined() && status;
}
}
}

View File

@ -0,0 +1,43 @@
#include <LibPkmGC/Colosseum/Common/PokemonBox.h>
namespace LibPkmGC {
namespace Colosseum {
PokemonBox::PokemonBox(void) : GC::PokemonBox(0x24a4) {
initWithEmptyData();
}
PokemonBox::PokemonBox(const u8* inData) : GC::PokemonBox(0x24a4, inData) {
load();
}
PokemonBox::PokemonBox(PokemonBox const& other) : GC::PokemonBox(other) {}
PokemonBox::~PokemonBox(void)
{
}
PokemonBox* PokemonBox::clone(void) const {
return new PokemonBox(*this);
}
PokemonBox* PokemonBox::create(void) const {
return new PokemonBox;
}
void PokemonBox::loadFields(void) {
GC::PokemonBox::loadFields();
LD_SUBSTRUCTURE_ARRAY(Pokemon, pkm, 30, 0x14);
}
void PokemonBox::save(void) {
GC::PokemonBox::save();
SV_SUBSTRUCTURE_ARRAY(Pokemon, pkm, 30, 0x14);
}
}
}

View File

@ -0,0 +1,46 @@
#include <LibPkmGC/Colosseum/Common/StrategyMemoData.h>
namespace LibPkmGC {
namespace Colosseum {
StrategyMemoData::StrategyMemoData(void) : GC::StrategyMemoData(0x1774) {
initWithEmptyData();
}
StrategyMemoData::StrategyMemoData(const u8* inData) : GC::StrategyMemoData(0x1774, inData) {
load();
}
StrategyMemoData::StrategyMemoData(StrategyMemoData const& other) : GC::StrategyMemoData(other) {}
bool StrategyMemoData::isXD(void) const {
return false;
}
StrategyMemoData* StrategyMemoData::clone(void) const
{
return new StrategyMemoData(*this);
}
StrategyMemoData* StrategyMemoData::create(void) const
{
return new StrategyMemoData;
}
void StrategyMemoData::loadFields(void) {
GC::StrategyMemoData::loadFields();
LD_SUBSTRUCTURE_ARRAY(StrategyMemoEntry, entries, 500, 4);
}
void StrategyMemoData::save(void) {
GC::StrategyMemoData::save();
SV_SUBSTRUCTURE_ARRAY(StrategyMemoEntry, entries, 500, 4);
}
StrategyMemoData::~StrategyMemoData(void)
{
}
}
}

View File

@ -0,0 +1,39 @@
#include <LibPkmGC/Colosseum/Common/StrategyMemoEntry.h>
namespace LibPkmGC {
namespace Colosseum {
StrategyMemoEntry::~StrategyMemoEntry(void) {
}
StrategyMemoEntry::StrategyMemoEntry(void) : GC::StrategyMemoEntry() {
initWithEmptyData();
}
StrategyMemoEntry::StrategyMemoEntry(const u8* inData) : GC::StrategyMemoEntry(inData) {
load();
}
bool StrategyMemoEntry::isXD(void) const {
return false;
}
StrategyMemoEntry* StrategyMemoEntry::clone(void) const {
return new StrategyMemoEntry(*this);
}
StrategyMemoEntry* StrategyMemoEntry::create(void) const {
return new StrategyMemoEntry;
}
bool StrategyMemoEntry::isInfoPartial(void) const {
return (flags == 2);
}
void StrategyMemoEntry::setInfoCompleteness(bool partial) {
flags = (partial) ? 2 : 0;
}
}
}

View File

@ -0,0 +1,50 @@
#include <LibPkmGC/Colosseum/SaveEditing/Save.h>
namespace LibPkmGC {
namespace Colosseum {
namespace SaveEditing {
Save::Save(void) : GC::SaveEditing::Save(0x60000, 3) {
initWithEmptyData();
}
Save::Save(const u8* inData, bool hasGCIData_, bool isDecrypted) : GC::SaveEditing::Save(0x60000, 3, inData, hasGCIData_) {
load((isDecrypted) ? 1 : 0);
}
Save::Save(Save const& other) : GC::SaveEditing::Save(other) {}
Save* Save::clone(void) const {
return new Save(*this);
}
Save* Save::create(void) const {
return new Save;
}
/*
0x0000 -- 0x6000: save file title + icon (ignored here)
0x6000: SaveSlot saveSlots[3]
*/
void Save::loadFields(void) {
// deleteFields();
saveSlots = new GC::SaveEditing::SaveSlot*[3];
u8* start = data + 0x6000;
/*delete saveSlots[0];
delete saveSlots[1];*/
saveSlots[0] = new SaveSlot(start, _is_decrypted);
saveSlots[1] = new SaveSlot(start + 0x1e000, _is_decrypted);
saveSlots[2] = new SaveSlot(start + 0x1e000*2, _is_decrypted);
}
void Save::save(void) {
SV_SUBSTRUCTURE_ARRAY(SaveSlot, saveSlots, 3, 0x6000);
}
}
}
}

View File

@ -0,0 +1,280 @@
#include <LibPkmGC/Colosseum/SaveEditing/SaveSlot.h>
#include <LibPkmGC/Core/Crypto.h>
namespace LibPkmGC {
namespace Colosseum {
namespace SaveEditing {
inline void decrypt_in_place_impl(u8* data, u8 digest[20]) {
u8 key[20];
std::copy(digest, digest + 20, key);
u32 K[5], D[5];
std::copy(key, key + 20, (u8*)K); // these copy calls will be optimized by the compiler
for (size_t i = 0; i < 5; ++i) // unrolling the loops manually has no influence over the performance
K[i] = ~K[i]; // 'NOT' the 20 digest bytes
std::copy((u8*)K, (u8*)(K + 5), key);
for (size_t i = 0x18; i < 0x1dfd8; i += 20) {
Crypto::sha1(data + i, data + i + 20, key); // hash the 20 bytes of encrypted data -- there are the next key
std::copy(data + i, data + i + 20, (u8*)D);
for (size_t j = 0; j < 5; ++j)
D[j] ^= K[j]; // 'XOR' the data with the current digest
std::copy((u8*)D, (u8*)(D + 5), data + i);
std::copy(key, key + 20, (u8*)K);
}
}
inline void encrypt_impl(u8* data, u8* outData, u8 digest[20]) {
u8 key[20];
std::copy(digest, digest + 20, key);
u32 K[5], D[5], OD[5];
std::copy(key, key + 20, (u8*)K); // these copy calls will be optimized by the compiler
for (size_t i = 0; i < 5; ++i) // unrolling the loops manually has no influence over the performance
K[i] = ~K[i]; // 'NOT' the 20 digest bytes
std::copy((u8*)K, (u8*)(K + 5), key);
for (size_t i = 0x18; i < 0x1dfd8; i += 20) {
std::copy(data + i, data + i + 20, (u8*)D);
for (size_t j = 0; j < 5; ++j)
OD[j] = D[j] ^ K[j]; // 'XOR' the data with the current digest
std::copy((u8*)OD, (u8*)(OD + 5), outData + i);
Crypto::sha1(outData + i, outData + i + 20, key);
std::copy(key, key + 20, (u8*)K);
}
}
SaveSlot::SaveSlot(void) : GC::SaveEditing::SaveSlot(0x1e000, 20) {
initWithEmptyData(1);
}
SaveSlot::SaveSlot(const u8* inData, bool isDecrypted) : GC::SaveEditing::SaveSlot(0x1e000, 20, inData) {
u32 flags = (isDecrypted) ? 1 : 0;
load(flags);
}
SaveSlot::SaveSlot(SaveSlot const& other) : GC::SaveEditing::SaveSlot(other), storyModeSaveCount(other.storyModeSaveCount) {
CP_ARRAY(checksum, 20);
}
void SaveSlot::deleteFields(void) {
GC::SaveEditing::SaveSlot::deleteFields();
_deleteFields_extension();
}
SaveSlot::~SaveSlot(void) {
_deleteFields_extension();
}
SaveSlot* SaveSlot::clone(void) const {
return new SaveSlot(*this);
}
SaveSlot* SaveSlot::create(void) const {
return new SaveSlot;
}
void SaveSlot::swap(SaveSlot& other) {
GC::SaveEditing::SaveSlot::swap(other);
SW(storyModeSaveCount);
SW_ARRAY(checksum, 20);
}
bool SaveSlot::checkChecksum(bool fix){
u8 newDigest[20];
std::fill(data + 12, data + 16, 0); // headerChecksum field
Crypto::sha1(data, data + 0x1dfd8, newDigest);
SV_FIELD(s32, headerChecksum, 12);
bool ret = std::equal(checksum, checksum + 20, newDigest);
if (!ret && fix) std::copy(newDigest, newDigest + 20, checksum);
return ret;
}
bool SaveSlot::checkHeaderChecksum(bool fix){
using namespace IntegerManip::BE;
u8 newDigest[20]; // when computing the header's checksum, words @0x18 @0x1c are already encrypted
std::fill(data + 12, data + 16, 0); // headerChecksum field
Crypto::sha1(data, data + 0x1dfd8, newDigest);
u32 D[2], H[2];
u8 tmpBuf[8];
std::copy(newDigest, newDigest + 8, (u8*)H);
std::copy(data + 0x18, data + 0x20, (u8*)D);
D[0] ^= ~H[0];
D[1] ^= ~H[1];
std::copy((u8*)D, (u8*)(D + 2), tmpBuf);
s32 newHC = 0;
for (size_t i = 0; i < 0x18; i += 4)
newHC -= (s32) toInteger<u32, u8*>(data + i);
newHC -= (s32)toInteger<u32,u8*>(tmpBuf);
newHC -= (s32)toInteger<u32, u8*>(tmpBuf + 4);
SV_FIELD(s32, headerChecksum, 12);
bool ret = (newHC == headerChecksum);
if (!ret && fix) headerChecksum = newHC;
return ret;
}
std::pair<bool, bool> SaveSlot::checkBothChecksums(bool fixGlobalChecksum, bool fixHeaderChecksum) {
if (!fixGlobalChecksum || !fixHeaderChecksum) return std::pair<bool, bool>(checkChecksum(fixGlobalChecksum), checkHeaderChecksum(fixHeaderChecksum));
else {
using namespace IntegerManip::BE;
u8 newDigest[20]; // when computing the header's checksum, words @0x18 @0x1c are already encrypted
std::fill(data + 12, data + 16, 0); // headerChecksum field
Crypto::sha1(data, data + 0x1dfd8, newDigest);
bool ret1 = std::equal(checksum, checksum + 20, newDigest);
if (!ret1) std::copy(newDigest, newDigest + 20, checksum);
u32 D[2], H[2];
u8 tmpBuf[8];
std::copy(newDigest, newDigest + 8, (u8*)H);
std::copy(data + 0x18, data + 0x20, (u8*)D);
D[0] ^= ~H[0];
D[1] ^= ~H[1];
std::copy((u8*)D, (u8*)(D + 2), tmpBuf);
s32 newHC = 0;
for (size_t i = 0; i < 0x18; i += 4)
newHC -= (s32)toInteger<u32, u8*>(data + i);
newHC -= (s32)toInteger<u32, u8*>(tmpBuf);
newHC -= (s32)toInteger<u32, u8*>(tmpBuf + 4);
SV_FIELD(s32, headerChecksum, 12);
bool ret2 = (newHC == headerChecksum);
headerChecksum = newHC;
return std::pair<bool, bool>(ret1, ret2);
}
}
bool SaveSlot::isCorrupt(void) {
if ((static_cast<u32>(magic) & 0xffff0000) != (u32)ColosseumMagic) return true;
std::pair<bool, bool> chk = checkBothChecksums();
return !chk.first || !chk.second;
}
void SaveSlot::loadData(u32 flags) {
bool decrypted = (flags & 1) == 1;
std::copy(data + 0x1dfec, data + 0x1e000, checksum);
if (!decrypted) decrypt_in_place_impl(data, checksum);
}
void SaveSlot::loadFields(void) {
randomBytes = new u8[20];
LD_FIELD_E(u32, magic, 0, SaveMagic);
LD_FIELD(s32, saveCount, 4);
version.load(data + 8);
LD_FIELD(u32, headerChecksum, 12);
LD_ARRAY(u32, memcardUID, 2, 16);
LD_FIELD(u32, storyModeSaveCount, 24);
LD_FIELD_B(u8, noRumble, 0x31);
LD_FIELD_E(u16, titleScreenLanguage, 0x32, LanguageIndex);
size_t offset = 0x70 + 8;
#define LD_IMPLEMENTED_SUBSTRUCTURE(type, field) LD_SUBSTRUCTURE(type, field, offset); offset += type::size;
LD_IMPLEMENTED_SUBSTRUCTURE(PlayerData, player);
LD_IMPLEMENTED_SUBSTRUCTURE(PCData, PC);
LD_IMPLEMENTED_SUBSTRUCTURE(MailboxData, mailbox);
LD_IMPLEMENTED_SUBSTRUCTURE(DaycareData, daycare);
LD_IMPLEMENTED_SUBSTRUCTURE(StrategyMemoData, strategyMemo);
offset += 0x523c;
LD_IMPLEMENTED_SUBSTRUCTURE(BattleModeData, battleMode);
// unknown substructures following
std::copy(data + 0x1dfd8, data + 0x1dfec, randomBytes);
}
void SaveSlot::save(void) {
magic = ColosseumMagic;
SV_FIELD_E(u32, ColosseumMagic, 0, SaveMagic);
SV_FIELD(u32, saveCount, 4);
//deleteFields();
version.save(data + 8);
SV_ARRAY(u32, memcardUID, 2, 16);
SV_FIELD(s32, storyModeSaveCount, 24);
SV_FIELD_B(u8, noRumble, 0x31);
SV_FIELD_E(u16, titleScreenLanguage, 0x32, LanguageIndex);
size_t offset = 0x70 + 8;
#define SV_IMPLEMENTED_SUBSTRUCTURE(type, field) SV_SUBSTRUCTURE(type, field, offset); offset += type::size;
SV_IMPLEMENTED_SUBSTRUCTURE(PlayerData, player);
SV_IMPLEMENTED_SUBSTRUCTURE(PCData, PC);
SV_IMPLEMENTED_SUBSTRUCTURE(MailboxData, mailbox);
SV_IMPLEMENTED_SUBSTRUCTURE(DaycareData, daycare);
SV_IMPLEMENTED_SUBSTRUCTURE(StrategyMemoData, strategyMemo);
offset += 0x523c;
SV_IMPLEMENTED_SUBSTRUCTURE(BattleModeData, battleMode);
// unknown substructures following
checkBothChecksums(true, true); // update checksums
SV_FIELD(u32, headerChecksum, 12);
std::copy(randomBytes, randomBytes + 20, data + 0x1dfd8);
std::copy(checksum, checksum + 20, data + 0x1dfec);
}
void SaveSlot::saveEncrypted(u8* outBuf) {
save();
std::copy(data, data + 0x18, outBuf);
std::copy(data + 0x1dfd8, data + 0x1e000, outBuf + 0x1dfd8);
encrypt_impl(data, outBuf, checksum);
}
void SaveSlot::_deleteFields_extension(void) {
}
}
}
}

View File

@ -0,0 +1,301 @@
#include <LibPkmGC/Core/Crypto.h>
#include <cstring>
using namespace LibPkmGC;
#define os_memcpy memcpy
#define os_memset memset
// MODIFIED :
/* ===== start - public domain SHA1 implementation ===== */
/*
SHA-1 in C
By Steve Reid <sreid@sea-to-sky.net>
100% Public Domain
-----------------
Modified 7/98
By James H. Brown <jbrown@burgoyne.com>
Still 100% Public Domain
Corrected a problem which generated improper hash values on 16 bit machines
Routine SHA1Update changed from
void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int
len)
to
void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned
long len)
The 'len' parameter was declared an int which works fine on 32 bit machines.
However, on 16 bit machines an int is too small for the shifts being done
against
it. This caused the hash function to generate incorrect values if len was
greater than 8191 (8K - 1) due to the 'len << 3' on line 3 of SHA1Update().
Since the file IO in main() reads 16K at a time, any file 8K or larger would
be guaranteed to generate the wrong hash (e.g. Test Vector #3, a million
"a"s).
I also changed the declaration of variables i & j in SHA1Update to
unsigned long from unsigned int for the same reason.
These changes should make no difference to any 32 bit implementations since
an
int and a long are the same size in those environments.
--
I also corrected a few compiler warnings generated by Borland C.
1. Added #include <process.h> for exit() prototype
2. Removed unused variable 'j' in SHA1Final
3. Changed exit(0) to return(0) at end of main.
ALL changes I made can be located by searching for comments containing 'JHB'
-----------------
Modified 8/98
By Steve Reid <sreid@sea-to-sky.net>
Still 100% public domain
1- Removed #include <process.h> and used return() instead of exit()
2- Fixed overwriting of finalcount in SHA1Final() (discovered by Chris Hall)
3- Changed email address from steve@edmweb.com to sreid@sea-to-sky.net
-----------------
Modified 4/01
By Saul Kravitz <Saul.Kravitz@celera.com>
Still 100% PD
Modified to run on Compaq Alpha hardware.
-----------------
Modified 4/01
By Jouni Malinen <j@w1.fi>
Minor changes to match the coding style used in Dynamics.
Modified September 24, 2004
By Jouni Malinen <j@w1.fi>
Fixed alignment issue in SHA1Transform when SHA1HANDSOFF is defined.
*/
/*
Test Vectors (from FIPS PUB 180-1)
"abc"
A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
A million repetitions of "a"
34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
*/
struct SHA1_CTX {
u32 state[5];
u32 count[2];
u8 buffer[64];
};
#define SHA1HANDSOFF
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
/* blk0() and blk() perform the initial expand. */
/* I got the idea of expanding during the round function from SSLeay */
#if BOOST_ENDIAN_BIG_BYTE == BOOST_VERSION_NUMBER_NOT_AVAILABLE
#define blk0(i) (l[i] = (rol(l[i], 24) & 0xFF00FF00) | \
(rol(l[i], 8) & 0x00FF00FF))
#else
#define blk0(i) l[i]
#endif
#define blk(i) (l[i & 15] = rol(l[(i + 13) & 15] ^ \
l[(i + 8) & 15] ^ l[(i + 2) & 15] ^ l[i & 15], 1))
/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
#define R0(v,w,x,y,z,i) \
z += ((w & (x ^ y)) ^ y) + blk0(i) + 0x5A827999 + rol(v, 5); \
w = rol(w, 30);
#define R1(v,w,x,y,z,i) \
z += ((w & (x ^ y)) ^ y) + blk(i) + 0x5A827999 + rol(v, 5); \
w = rol(w, 30);
#define R2(v,w,x,y,z,i) \
z += (w ^ x ^ y) + blk(i) + 0x6ED9EBA1 + rol(v, 5); w = rol(w, 30);
#define R3(v,w,x,y,z,i) \
z += (((w | x) & y) | (w & x)) + blk(i) + 0x8F1BBCDC + rol(v, 5); \
w = rol(w, 30);
#define R4(v,w,x,y,z,i) \
z += (w ^ x ^ y) + blk(i) + 0xCA62C1D6 + rol(v, 5); \
w=rol(w, 30);
#ifdef VERBOSE /* SAK */
void SHAPrintContext(SHA1_CTX *context, char *msg)
{
printf("%s (%d,%d) %x %x %x %x %x\n",
msg,
context->count[0], context->count[1],
context->state[0],
context->state[1],
context->state[2],
context->state[3],
context->state[4]);
}
#endif
/* Hash a single 512-bit block. This is the core of the algorithm. */
inline void SHA1Transform(u32 state[5], const u8 buffer[64])
{
u32 a, b, c, d, e;
u32 l[16];
#ifdef SHA1HANDSOFF
os_memcpy((u8*)l, buffer, 64);
#else
//
#endif
/* Copy context->state[] to working vars */
a = state[0];
b = state[1];
c = state[2];
d = state[3];
e = state[4];
/* 4 rounds of 20 operations each. Loop unrolled. */
R0(a, b, c, d, e, 0); R0(e, a, b, c, d, 1); R0(d, e, a, b, c, 2); R0(c, d, e, a, b, 3);
R0(b, c, d, e, a, 4); R0(a, b, c, d, e, 5); R0(e, a, b, c, d, 6); R0(d, e, a, b, c, 7);
R0(c, d, e, a, b, 8); R0(b, c, d, e, a, 9); R0(a, b, c, d, e, 10); R0(e, a, b, c, d, 11);
R0(d, e, a, b, c, 12); R0(c, d, e, a, b, 13); R0(b, c, d, e, a, 14); R0(a, b, c, d, e, 15);
R1(e, a, b, c, d, 16); R1(d, e, a, b, c, 17); R1(c, d, e, a, b, 18); R1(b, c, d, e, a, 19);
R2(a, b, c, d, e, 20); R2(e, a, b, c, d, 21); R2(d, e, a, b, c, 22); R2(c, d, e, a, b, 23);
R2(b, c, d, e, a, 24); R2(a, b, c, d, e, 25); R2(e, a, b, c, d, 26); R2(d, e, a, b, c, 27);
R2(c, d, e, a, b, 28); R2(b, c, d, e, a, 29); R2(a, b, c, d, e, 30); R2(e, a, b, c, d, 31);
R2(d, e, a, b, c, 32); R2(c, d, e, a, b, 33); R2(b, c, d, e, a, 34); R2(a, b, c, d, e, 35);
R2(e, a, b, c, d, 36); R2(d, e, a, b, c, 37); R2(c, d, e, a, b, 38); R2(b, c, d, e, a, 39);
R3(a, b, c, d, e, 40); R3(e, a, b, c, d, 41); R3(d, e, a, b, c, 42); R3(c, d, e, a, b, 43);
R3(b, c, d, e, a, 44); R3(a, b, c, d, e, 45); R3(e, a, b, c, d, 46); R3(d, e, a, b, c, 47);
R3(c, d, e, a, b, 48); R3(b, c, d, e, a, 49); R3(a, b, c, d, e, 50); R3(e, a, b, c, d, 51);
R3(d, e, a, b, c, 52); R3(c, d, e, a, b, 53); R3(b, c, d, e, a, 54); R3(a, b, c, d, e, 55);
R3(e, a, b, c, d, 56); R3(d, e, a, b, c, 57); R3(c, d, e, a, b, 58); R3(b, c, d, e, a, 59);
R4(a, b, c, d, e, 60); R4(e, a, b, c, d, 61); R4(d, e, a, b, c, 62); R4(c, d, e, a, b, 63);
R4(b, c, d, e, a, 64); R4(a, b, c, d, e, 65); R4(e, a, b, c, d, 66); R4(d, e, a, b, c, 67);
R4(c, d, e, a, b, 68); R4(b, c, d, e, a, 69); R4(a, b, c, d, e, 70); R4(e, a, b, c, d, 71);
R4(d, e, a, b, c, 72); R4(c, d, e, a, b, 73); R4(b, c, d, e, a, 74); R4(a, b, c, d, e, 75);
R4(e, a, b, c, d, 76); R4(d, e, a, b, c, 77); R4(c, d, e, a, b, 78); R4(b, c, d, e, a, 79);
/* Add the working vars back into context.state[] */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
state[4] += e;
/* Wipe variables */
//a = b = c = d = e = 0;
#ifdef SHA1HANDSOFF
//os_memset(block, 0, 64);
#endif
}
/* SHA1Init - Initialize new context */
inline void SHA1Init(SHA1_CTX* context)
{
/* SHA1 initialization constants */
context->state[0] = 0x67452301;
context->state[1] = 0xEFCDAB89;
context->state[2] = 0x98BADCFE;
context->state[3] = 0x10325476;
context->state[4] = 0xC3D2E1F0;
context->count[0] = context->count[1] = 0;
}
/* Run your data through this. */
inline void SHA1Update(SHA1_CTX* context, const u8 *_data, u32 len)
{
u32 i, j;
const u8 *data = _data;
#ifdef VERBOSE
SHAPrintContext(context, "before");
#endif
j = (context->count[0] >> 3) & 63;
if ((context->count[0] += len << 3) < (len << 3))
context->count[1]++;
context->count[1] += (len >> 29);
if ((j + len) > 63) {
os_memcpy(&context->buffer[j], data, (i = 64 - j));
SHA1Transform(context->state, context->buffer);
for (; i + 63 < len; i += 64) {
SHA1Transform(context->state, &data[i]);
}
j = 0;
}
else i = 0;
os_memcpy(&context->buffer[j], &data[i], len - i);
#ifdef VERBOSE
SHAPrintContext(context, "after ");
#endif
}
/* Add padding and return the message digest. */
inline void SHA1Final(u8 digest[20], SHA1_CTX* context)
{
u32 i;
u8 finalcount[8];
for (i = 0; i < 8; i++) {
finalcount[i] = (u8)
((context->count[(i >= 4 ? 0 : 1)] >>
((3 - (i & 3)) * 8)) & 255); /* Endian independent */
}
SHA1Update(context, (u8 *) "\200", 1);
while ((context->count[0] & 504) != 448) {
SHA1Update(context, (u8 *) "\0", 1);
}
SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform()
*/
for (i = 0; i < 20; i++) {
digest[i] = (u8)
((context->state[i >> 2] >> ((3 - (i & 3)) * 8)) &
255);
}
/* Wipe variables */
/*
i = 0;
os_memset(context->buffer, 0, 64);
os_memset(context->state, 0, 20);
os_memset(context->count, 0, 8);
os_memset(finalcount, 0, 8);
*/
}
/* ===== end - public domain SHA1 implementation ===== */
static const char* nibbles = "0123456789abcdef";
namespace LibPkmGC {
namespace Crypto {
void sha1(const u8* start, const u8* end, u8 digest[20]) {
SHA1_CTX ctx;
SHA1Init(&ctx);
SHA1Update(&ctx, start, (size_t)(end-start));
SHA1Final(digest, &ctx);
}
std::string sha1(const u8* start, const u8* end) {
u8 digest[20];
sha1(start, end, digest);
std::string ret;
ret.resize(40);
for (size_t i = 0; i < 20; ++i) {
ret[39 - 2 * i] = nibbles[digest[19 - i] & 0x0f];
ret[39 - 2 * i - 1] = nibbles[(digest[19 - i] >> 4) & 0x0f];
}
return ret;
}
}
}

View File

@ -0,0 +1,502 @@
#include <LibPkmGC/Core/Detail/AbilityNames.h>
namespace LibPkmGC {
namespace Localization {
namespace Detail {
namespace Abilities {
const char **names[7] = { NULL, japaneseNames, englishNames, germanNames, frenchNames, italianNames, spanishNames };
const char *englishNames[78] = {
"(None)",
"STENCH",
"DRIZZLE",
"SPEED BOOST",
"BATTLE ARMOR",
"STURDY",
"DAMP",
"LIMBER",
"SAND VEIL",
"STATIC",
"VOLT ABSORB",
"WATER ABSORB",
"OBLIVIOUS",
"CLOUD NINE",
"COMPOUNDEYES",
"INSOMNIA",
"COLOR CHANGE",
"IMMUNITY",
"FLASH FIRE",
"SHIELD DUST",
"OWN TEMPO",
"SUCTION CUPS",
"INTIMIDATE",
"SHADOW TAG",
"ROUGH SKIN",
"WONDER GUARD",
"LEVITATE",
"EFFECT SPORE",
"SYNCHRONIZE",
"CLEAR BODY",
"NATURAL CURE",
"LIGHTNINGROD",
"SERENE GRACE",
"SWIFT SWIM",
"CHLOROPHYLL",
"ILLUMINATE",
"TRACE",
"HUGE POWER",
"POISON POINT",
"INNER FOCUS",
"MAGMA ARMOR",
"WATER VEIL",
"MAGNET PULL",
"SOUNDPROOF",
"RAIN DISH",
"SAND STREAM",
"PRESSURE",
"THICK FAT",
"EARLY BIRD",
"FLAME BODY",
"RUN AWAY",
"KEEN EYE",
"HYPER CUTTER",
"PICKUP",
"TRUANT",
"HUSTLE",
"CUTE CHARM",
"PLUS",
"MINUS",
"FORECAST",
"STICKY HOLD",
"SHED SKIN",
"GUTS",
"MARVEL SCALE",
"LIQUID OOZE",
"OVERGROW",
"BLAZE",
"TORRENT",
"SWARM",
"ROCK HEAD",
"DROUGHT",
"ARENA TRAP",
"VITAL SPIRIT",
"WHITE SMOKE",
"PURE POWER",
"SHELL ARMOR",
"CACOPHONY",
"AIR LOCK"
};
const char *frenchNames[78] = {
"(Rien)",
"PUANTEUR",
"CRACHIN",
"TURBO",
"ARMURBASTON",
"FERMETE",
"MOITEUR",
"ECHAUFFEMENT",
"VOILE SABLE",
"STATIK",
"ABSORB VOLT",
"ABSORB EAU",
"BENET",
"CIEL GRIS",
"OEIL COMPOSE",
"INSOMNIA",
"DEGUISEMENT",
"VACCIN",
"TORCHE",
"ECRAN POUDRE",
"TEMPO PERSO",
"VENTOUSE",
"INTIMIDATION",
"MARQUE OMBRE",
"PEAU DURE",
"GARDE MYSTIK",
"LEVITATION",
"POSE SPORE",
"SYNCHRO",
"CORPS SAIN",
"MEDIC NATURE",
"PARATONNERRE",
"SERENITE",
"GLISSADE",
"CHLOROPHYLE",
"LUMIATIRANCE",
"CALQUE",
"COLOFORCE",
"POINT POISON",
"ATTENTION",
"ARMUMAGMA",
"IGNIFU-VOILE",
"MAGNEPIEGE",
"ANTI-BRUIT",
"CUVETTE",
"SABLE VOLANT",
"PRESSION",
"ISOGRAISSE",
"MATINAL",
"CORPS ARDENT",
"FUITE",
"REGARD VIF",
"HYPER CUTTER",
"RAMASSAGE",
"ABSENTEISME",
"AGITATION",
"JOLI SOURIRE",
"PLUS",
"MINUS",
"METEO",
"GLUE",
"MUE",
"CRAN",
"ECAILLE SPE.",
"SUINTEMENT",
"ENGRAIS",
"BRASIER",
"TORRENT",
"ESSAIM",
"TETE DE ROC",
"SECHERESSE",
"PIEGE",
"ESPRIT VITAL",
"ECRAN FUMEE",
"FORCE PURE",
"COQUE ARMURE",
"CACOPHONIE",
"AIR LOCK",
};
const char *germanNames[78] = {
"(Nichts)",
"DUFTNOTE",
"NIESEL",
"TEMPOSCHUB",
"KAMPFPANZER",
"ROBUSTHEIT",
"FEUCHTIGKEIT",
"FLEXIBILIT\xC3\x84T",
"SANDSCHLEIER",
"STATIK",
"VOLTABSORBER",
"H2O-ABSORBER",
"D\xC3\x96SIGKEIT",
"WOLKE SIEBEN",
"FACETTENAUGE",
"INSOMNIA",
"FARBWECHSEL",
"IMMUNIT\xC3\x84T",
"FEUERF\xC3\x84NGER",
"PUDERABWEHR",
"TEMPOMACHER",
"SAUGNAPF",
"BEDROHER",
"WEGSPERRE",
"RAUHAUT",
"WUNDERWACHE",
"SCHWEBE",
"SPORENWIRT",
"SYNCHRO",
"NEUTRALTORSO",
"INNERE KRAFT",
"BLITZF\xC3\x84NGER",
"EDELMUT",
"WASSERTEMPO",
"CHLOROPHYLL",
"ERLEUCHTUNG",
"F\xC3\x84HRTE",
"KRAFTKOLOSS",
"GIFTDORN",
"KONZENTRATOR",
"MAGMAPANZER",
"AQUAH\xC3\x9CLLE",
"MAGNETFALLE",
"L\xC3\x84RMSCHUTZ",
"REGENGENUSS",
"SANDSTURM",
"ERZWINGER",
"SPECKSCHICHT",
"FR\xC3\x9CHWECKER",
"FLAMMK\xC3\x96RPER",
"ANGSTHASE",
"ADLERAUGE",
"SCHERENMACHT",
"MITNAHME",
"SCHNARCHNASE",
"\xC3\x9C""BEREIFER",
"CHARMEBOLZEN",
"PLUS",
"MINUS",
"PROGNOSE",
"WERTEHALTER",
"EXPIDERMIS",
"ADRENALIN",
"NOTSCHUTZ",
"KLOAKENSOSSE",
"NOTD\xC3\x9CNGER",
"GROSSBRAND",
"STURZBACH",
"HEXAPLAGA",
"STEINHAUPT",
"D\xC3\x9CRRE",
"AUSWEGSLOS",
"MUNTERKEIT",
"PULVERRAUCH",
"MENTALKRAFT",
"PANZERHAUT",
"KAKOPHONY",
"KLIMASCHUTZ",
};
const char *italianNames[78] = {
"(Nessuno)",
"TANFO",
"PIOVISCHIO",
"ACCELERATORE",
"LOTTASCUDO",
"VIGORE",
"UMIDIT\xC3\x80",
"SCIOLTEZZA",
"SABBIAVELO",
"STATICO",
"ASSORBIVOLT",
"ASSORBACQUA",
"INDIFFERENZA",
"ANTIMETEO",
"INSETTOCCHI",
"INSONNIA",
"CAMBIACOLORE",
"IMMUNIT\xC3\x80",
"FUOCARDORE",
"POLVOSCUDO",
"MENTE LOCALE",
"VENTOSE",
"PREPOTENZA",
"PEDINOMBRA",
"CARTAVETRO",
"MAGIDIFESA",
"LEVITAZIONE",
"SPARGISPORA",
"SINCRONISMO",
"CORPOCHIARO",
"ALTERNACURA",
"PARAFULMINE",
"LEGGIADRO",
"NUOTOVELOX",
"CLOROFILLA",
"RISPLENDI",
"TRACCIA",
"MACROFORZA",
"VELENOPUNTO",
"FUOCODENTRO",
"MAGMASCUDO",
"IDROVELO",
"MAGNETISMO",
"ANTISUONO",
"COPRIPIOGGIA",
"SABBIAFIUME",
"PRESSIONE",
"GRASSOSPESSO",
"SVEGLIALAMPO",
"CORPODIFUOCO",
"FUGAFACILE",
"SGUARDOFERMO",
"IPERTAGLIO",
"RACCOLTA",
"PIGRONE",
"TUTTAFRETTA",
"INCANTEVOLE",
"PI\xC3\x99",
"MENO",
"PREVISIONI",
"ANTIFURTO",
"MUTA",
"DENTISTRETTI",
"PELLEDURA",
"MELMA",
"ERBAIUTO",
"AIUTOFUOCO",
"ACQUAIUTO",
"AIUTINSETTO",
"TESTADURA",
"SICCIT\xC3\x80",
"TRAPPOARENA",
"SPIRITOVIVO",
"FUMOCHIARO",
"FORZAPURA",
"GUSCIOSCUDO",
"CACOFONIA",
"RIPARO",
};
const char *spanishNames[78] = {
"(Ninguno)",
"HEDOR",
"LLOVIZNA",
"IMPULSO",
"ARMAD. BAT.",
"ROBUSTEZ",
"HUMEDAD",
"FLEXIBILIDAD",
"VELO ARENA",
"ELEC. EST\xC3\x81T.",
"ABSOR. ELEC.",
"ABSOR. AGUA",
"DESPISTE",
"ACLIMATACI\xC3\x93N",
"OJOCOMPUESTO",
"INSOMNIO",
"CAMBIO COLOR",
"INMUNIDAD",
"ABSOR. FUEGO",
"POLVO ESCUDO",
"RITMO PROPIO",
"VENTOSAS",
"INTIMIDACI\xC3\x93N",
"SOMBRATRAMPA",
"PIEL TOSCA",
"SUPERGUARDA",
"LEVITACI\xC3\x93N",
"EFEC. ESPORA",
"SINCRON\xC3\x8D""A",
"CUERPO PURO",
"CURA NATURAL",
"PARARRAYOS",
"DICHA",
"NADO R\xC3\x81PIDO",
"CLOROFILA",
"ILUMINACI\xC3\x93N",
"RASTRO",
"POTENCIA",
"PUNTO T\xC3\x93XICO",
"FOCO INTERNO",
"ESCUDO MAGMA",
"VELO AGUA",
"IM\xC3\x81N",
"INSONORIZAR",
"CURA LLUVIA",
"CHORRO ARENA",
"PRESI\xC3\x93N",
"SEBO",
"MADRUGAR",
"CUERPO LLAMA",
"FUGA",
"VISTA LINCE",
"CORTE FUERTE",
"RECOGIDA",
"AUSENTE",
"ENTUSIASMO",
"GRAN ENCANTO",
"M\xC3\x81S",
"MENOS",
"PREDICCI\xC3\x93N",
"VISCOSIDAD",
"MUDAR",
"AGALLAS",
"ESCAMA ESP.",
"LODO L\xC3\x8DQUIDO",
"ESPESURA",
"MAR LLAMAS",
"TORRENTE",
"ENJAMBRE",
"CABEZA ROCA",
"SEQU\xC3\x8D""A",
"TRAMPA ARENA",
"ESP\xC3\x8DR. VITAL",
"HUMO BLANCO",
"ENERG\xC3\x8D""A PURA",
"CAPARAZ\xC3\x93N",
"CACOFON\xC3\x8D""A",
"BUCLE AIRE"
};
const char *japaneseNames[78] = {
"(\xe4\xbd\x95\xe3\x82\x82)",
"\xe3\x81\x82\xe3\x81\x8f\xe3\x81\x97\xe3\x82\x85\xe3\x81\x86",
"\xe3\x81\x82\xe3\x82\x81\xe3\x81\xb5\xe3\x82\x89\xe3\x81\x97",
"\xe3\x81\x8b\xe3\x81\x9d\xe3\x81\x8f",
"\xe3\x82\xab\xe3\x83\x96\xe3\x83\x88\xe3\x82\xa2\xe3\x83\xbc\xe3\x83\x9e\xe3\x83\xbc",
"\xe3\x81\x8c\xe3\x82\x93\xe3\x81\x98\xe3\x82\x87\xe3\x81\x86",
"\xe3\x81\x97\xe3\x82\x81\xe3\x82\x8a\xe3\x81\x91",
"\xe3\x81\x98\xe3\x82\x85\xe3\x81\x86\xe3\x81\xaa\xe3\x82\x93",
"\xe3\x81\x99\xe3\x81\xaa\xe3\x81\x8c\xe3\x81\x8f\xe3\x82\x8c",
"\xe3\x81\x9b\xe3\x81\x84\xe3\x81\xa7\xe3\x82\x93\xe3\x81\x8d",
"\xe3\x81\xa1\xe3\x81\x8f\xe3\x81\xa7\xe3\x82\x93",
"\xe3\x81\xa1\xe3\x82\x87\xe3\x81\x99\xe3\x81\x84",
"\xe3\x81\xa9\xe3\x82\x93\xe3\x81\x8b\xe3\x82\x93",
"\xe3\x83\x8e\xe3\x83\xbc\xe3\x81\xa6\xe3\x82\x93\xe3\x81\x8d",
"\xe3\x81\xb5\xe3\x81\x8f\xe3\x81\x8c\xe3\x82\x93",
"\xe3\x81\xb5\xe3\x81\xbf\xe3\x82\x93",
"\xe3\x81\xb8\xe3\x82\x93\xe3\x81\x97\xe3\x82\x87\xe3\x81\x8f",
"\xe3\x82\x81\xe3\x82\x93\xe3\x81\x88\xe3\x81\x8d",
"\xe3\x82\x82\xe3\x82\x89\xe3\x81\x84\xe3\x81\xb3",
"\xe3\x82\x8a\xe3\x82\x93\xe3\x81\xb7\xe3\x82\x93",
"\xe3\x83\x9e\xe3\x82\xa4\xe3\x83\x9a\xe3\x83\xbc\xe3\x82\xb9",
"\xe3\x81\x8d\xe3\x82\x85\xe3\x81\x86\xe3\x81\xb0\xe3\x82\x93",
"\xe3\x81\x84\xe3\x81\x8b\xe3\x81\x8f",
"\xe3\x81\x8b\xe3\x81\x92\xe3\x81\xb5\xe3\x81\xbf",
"\xe3\x81\x95\xe3\x82\x81\xe3\x81\xaf\xe3\x81\xa0",
"\xe3\x81\xb5\xe3\x81\x97\xe3\x81\x8e\xe3\x81\xaa\xe3\x81\xbe\xe3\x82\x82\xe3\x82\x8a",
"\xe3\x81\xb5\xe3\x82\x86\xe3\x81\x86",
"\xe3\x81\xbb\xe3\x81\x86\xe3\x81\x97",
"\xe3\x82\xb7\xe3\x83\xb3\xe3\x82\xaf\xe3\x83\xad",
"\xe3\x82\xaf\xe3\x83\xaa\xe3\x82\xa2\xe3\x83\x9c\xe3\x83\x87\xe3\x82\xa3",
"\xe3\x81\x97\xe3\x81\x9c\xe3\x82\x93\xe3\x81\x8b\xe3\x81\x84\xe3\x81\xb5\xe3\x81\x8f",
"\xe3\x81\xb2\xe3\x82\x89\xe3\x81\x84\xe3\x81\x97\xe3\x82\x93",
"\xe3\x81\xa6\xe3\x82\x93\xe3\x81\xae\xe3\x82\x81\xe3\x81\x90\xe3\x81\xbf",
"\xe3\x81\x99\xe3\x81\x84\xe3\x81\x99\xe3\x81\x84",
"\xe3\x82\x88\xe3\x81\x86\xe3\x82\x8a\xe3\x82\x87\xe3\x81\x8f\xe3\x81\x9d",
"\xe3\x81\xaf\xe3\x81\xa3\xe3\x81\x93\xe3\x81\x86",
"\xe3\x83\x88\xe3\x83\xac\xe3\x83\xbc\xe3\x82\xb9",
"\xe3\x81\xa1\xe3\x81\x8b\xe3\x82\x89\xe3\x82\x82\xe3\x81\xa1",
"\xe3\x81\xa9\xe3\x81\x8f\xe3\x81\xae\xe3\x83\x88\xe3\x82\xb2",
"\xe3\x81\x9b\xe3\x81\x84\xe3\x81\x97\xe3\x82\x93\xe3\x82\x8a\xe3\x82\x87\xe3\x81\x8f",
"\xe3\x83\x9e\xe3\x82\xb0\xe3\x83\x9e\xe3\x81\xae\xe3\x82\x88\xe3\x82\x8d\xe3\x81\x84",
"\xe3\x81\xbf\xe3\x81\x9a\xe3\x81\xae\xe3\x83\x99\xe3\x83\xbc\xe3\x83\xab",
"\xe3\x81\x98\xe3\x82\x8a\xe3\x82\x87\xe3\x81\x8f",
"\xe3\x81\xbc\xe3\x81\x86\xe3\x81\x8a\xe3\x82\x93",
"\xe3\x81\x82\xe3\x82\x81\xe3\x81\x86\xe3\x81\x91\xe3\x81\x96\xe3\x82\x89",
"\xe3\x81\x99\xe3\x81\xaa\xe3\x81\x8a\xe3\x81\x93\xe3\x81\x97",
"\xe3\x83\x97\xe3\x83\xac\xe3\x83\x83\xe3\x82\xb7\xe3\x83\xa3\xe3\x83\xbc",
"\xe3\x81\x82\xe3\x81\xa4\xe3\x81\x84\xe3\x81\x97\xe3\x81\xbc\xe3\x81\x86",
"\xe3\x81\xaf\xe3\x82\x84\xe3\x81\x8a\xe3\x81\x8d",
"\xe3\x81\xbb\xe3\x81\xae\xe3\x81\x8a\xe3\x81\xae\xe3\x81\x8b\xe3\x82\x89\xe3\x81\xa0",
"\xe3\x81\xab\xe3\x81\x92\xe3\x81\x82\xe3\x81\x97",
"\xe3\x81\x99\xe3\x82\x8b\xe3\x81\xa9\xe3\x81\x84\xe3\x82\x81",
"\xe3\x81\x8b\xe3\x81\x84\xe3\x82\x8a\xe3\x81\x8d\xe3\x83\x90\xe3\x82\xb5\xe3\x83\x9f",
"\xe3\x82\x82\xe3\x81\xae\xe3\x81\xb2\xe3\x82\x8d\xe3\x81\x84",
"\xe3\x81\xaa\xe3\x81\xbe\xe3\x81\x91",
"\xe3\x81\xaf\xe3\x82\x8a\xe3\x81\x8d\xe3\x82\x8a",
"\xe3\x83\xa1\xe3\x83\xad\xe3\x83\xa1\xe3\x83\xad\xe3\x83\x9c\xe3\x83\x87\xe3\x82\xa3",
"\xe3\x83\x97\xe3\x83\xa9\xe3\x82\xb9",
"\xe3\x83\x9e\xe3\x82\xa4\xe3\x83\x8a\xe3\x82\xb9",
"\xe3\x81\xa6\xe3\x82\x93\xe3\x81\x8d\xe3\x82\x84",
"\xe3\x81\xad\xe3\x82\x93\xe3\x81\xa1\xe3\x82\x83\xe3\x81\x8f",
"\xe3\x81\xa0\xe3\x81\xa3\xe3\x81\xb4",
"\xe3\x81\x93\xe3\x82\x93\xe3\x81\x98\xe3\x82\x87\xe3\x81\x86",
"\xe3\x81\xb5\xe3\x81\x97\xe3\x81\x8e\xe3\x81\xaa\xe3\x82\xa6\xe3\x83\xad\xe3\x82\xb3",
"\xe3\x83\x98\xe3\x83\x89\xe3\x83\xad\xe3\x81\x88\xe3\x81\x8d",
"\xe3\x81\x97\xe3\x82\x93\xe3\x82\x8a\xe3\x82\x87\xe3\x81\x8f",
"\xe3\x82\x82\xe3\x81\x86\xe3\x81\x8b",
"\xe3\x81\x92\xe3\x81\x8d\xe3\x82\x8a\xe3\x82\x85\xe3\x81\x86",
"\xe3\x82\x80\xe3\x81\x97\xe3\x81\xae\xe3\x81\x97\xe3\x82\x89\xe3\x81\x9b",
"\xe3\x81\x84\xe3\x81\x97\xe3\x81\x82\xe3\x81\x9f\xe3\x81\xbe",
"\xe3\x81\xb2\xe3\x81\xa7\xe3\x82\x8a",
"\xe3\x81\x82\xe3\x82\x8a\xe3\x81\x98\xe3\x81\x94\xe3\x81\x8f",
"\xe3\x82\x84\xe3\x82\x8b\xe3\x81\x8d",
"\xe3\x81\x97\xe3\x82\x8d\xe3\x81\x84\xe3\x81\x91\xe3\x82\x80\xe3\x82\x8a",
"\xe3\x83\xa8\xe3\x82\xac\xe3\x83\x91\xe3\x83\xaf\xe3\x83\xbc",
"\xe3\x82\xb7\xe3\x82\xa7\xe3\x83\xab\xe3\x82\xa2\xe3\x83\xbc\xe3\x83\x9e\xe3\x83\xbc",
"\xe3\x81\x9d\xe3\x81\x86\xe3\x81\x8a\xe3\x82\x93",
"\xe3\x82\xa8\xe3\x82\xa2\xe3\x83\xad\xe3\x83\x83\xe3\x82\xaf"
};
}
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,46 @@
#include <LibPkmGC/Core/ItemInfo.h>
#include <LibPkmGC/Core/Detail/StructMacros.h>
namespace LibPkmGC {
void Item::load(u8 * data) {
LD_FIELD_E(u16, index, 0, ItemIndex);
LD_FIELD(u16, quantity, 2);
}
void Item::save(u8 * data) {
SV_FIELD_E(u16, index, 0, ItemIndex);
SV_FIELD(u16, quantity, 2);
}
ItemCategoryIndex getItemCategory(ItemIndex index, bool isXD) {
u16 i = (u16)index;
if ((index >= MasterBall) && (index <= PremierBall)) return PokeballsCategory;
if ((index >= Potion) && (index <= GreenShard)) return RegularItemsCategory;
if ((index >= HPUp) && (index <= Repel) && (i != 0x48) && (i != 0x52)) return RegularItemsCategory;
if ((index >= SunStone) && (index <= LeafStone)) return RegularItemsCategory;
if ((index >= TinyMushroom) && (index <= HeartScale) && (i != 0x69)) return RegularItemsCategory;
if ((index >= OrangeMail) && (index <= RetroMail)) return RegularItemsCategory;
if ((index >= CheriBerry) && (index <= EnigmaBerry)) return BerriesCategory;
if ((index >= BrightPowder) && (index <= Stick)) return RegularItemsCategory;
if ((index >= RedScarf) && (index <= YellowScarf)) return RegularItemsCategory;
if ((index >= TM01) && (index <= TM50)) return TMsCategory;
if (isXD) {
if ((index >= SafeKey) && (index <= MirorRadar)) return KeyItemsCategory;
if (index == PokeSnack) return RegularItemsCategory;
if (index == CologneCase_XD) return KeyItemsCategory;
if ((index >= JoyScent_XD) && (index <= VividScent_XD)) return ColognesCategory;
if ((index >= SunShard) && (index <= CryAnalyzer)) return KeyItemsCategory;
if ((index >= KraneMemo1) && (index <= DiscCase)) return KeyItemsCategory;
if ((index >= BattleCD01) && (index <= BattleCD60)) return BattleCDsCategory;
}
else {
if ((index >= JailKey) && (index <= YlwIDBadge)) return KeyItemsCategory;
if (index == TimeFlute) return RegularItemsCategory;
if ((index >= JoyScent_C) && (index <= VividScent_C)) return ColognesCategory;
if ((index == PowerupPart) || (index == EinFileF)) return KeyItemsCategory;
}
return NoItemCategory;
}
}

View File

@ -0,0 +1,533 @@
#include <LibPkmGC/Core/Localization.h>
//^([0-9a-f]*)\t(.*){{null}}
//(.*)(\\n|\\0)
namespace LibPkmGC {
namespace Localization {
size_t itemIndexToNameIndex(ItemIndex index, bool isXD) {
size_t i = (size_t)index;
if ((index >= NoItem) && (index <= GreenShard)) return i;
i -= 11;
if ((index >= HPUp) && (index <= PPMax)) return i;
--i;
if ((index >= GuardSpec) && (index <= FluffyTail)) return i;
--i;
if ((index >= SuperRepel) && (index <= Repel)) return i;
i -= 6;
if ((index >= SunStone) && (index <= LeafStone)) return i;
i -= 4;
if ((index == TinyMushroom) || (index == BigMushroom)) return i;
--i;
if ((index >= Pearl) && (index <= HeartScale)) return i;
i -= 9;
if ((index >= OrangeMail) && (index <= EnigmaBerry)) return i;
i -= 3;
if ((index >= BrightPowder) && (index <= Stick)) return i;
i -= 28;
if ((index >= RedScarf) && (index <= YellowScarf)) return i;
i -= 30;
if ((index >= TM01) && (index <= TM50)) return i;
i -= 161;
if (isXD) {
if (index < SafeKey || index > BattleCD60) return 0;
return i;
}
else{
if (index < SafeKey || index > EinFileF) return 0;
return i;
}
return 0;
}
ItemIndex nameIndexToItemIndex(size_t index, bool isXD) {
static const ItemIndex commonItems[] = {
NoItem,
MasterBall,
UltraBall,
GreatBall,
PokeBall,
SafariBall,
NetBall,
DiveBall,
NestBall,
RepeatBall,
TimerBall,
LuxuryBall,
PremierBall,
Potion,
Antidote,
BurnHeal,
IceHeal,
Awakening,
ParlyzHeal,
FullRestore,
MaxPotion,
HyperPotion,
SuperPotion,
FullHeal,
Revive,
MaxRevive,
FreshWater,
SodaPop,
Lemonade,
MoomooMilk,
EnergyPowder,
EnergyRoot,
HealPowder,
RevivalHerb,
Ether,
MaxEther,
Elixir,
MaxElixir,
LavaCookie,
BlueFlute,
YellowFlute,
RedFlute,
BlackFlute,
WhiteFlute,
BerryJuice,
SacredAsh,
ShoalSalt,
ShoalShell,
RedShard,
BlueShard,
YellowShard,
GreenShard,
HPUp,
Protein,
Iron,
Carbos,
Calcium,
RareCandy,
PPUp,
Zinc,
PPMax,
GuardSpec,
DireHit,
XAttack,
XDefend,
XSpeed,
XAccuracy,
XSpecial,
Pokedoll,
FluffyTail,
SuperRepel,
MaxRepel,
EscapeRope,
Repel,
SunStone,
MoonStone,
FireStone,
ThunderStone,
WaterStone,
LeafStone,
TinyMushroom,
BigMushroom,
Pearl,
BigPearl,
Stardust,
StarPiece,
Nugget,
HeartScale,
OrangeMail,
HarborMail,
GlitterMail,
MechMail,
WoodMail,
WaveMail,
BeadMail,
ShadowMail,
TropicMail,
DreamMail,
FabMail,
RetroMail,
CheriBerry,
ChestoBerry,
PechaBerry,
RawstBerry,
AspearBerry,
LeppaBerry,
OranBerry,
PersimBerry,
LumBerry,
SitrusBerry,
FigyBerry,
WikiBerry,
MagoBerry,
AguavBerry,
IapapaBerry,
RazzBerry,
BlukBerry,
NanabBerry,
WepearBerry,
PinapBerry,
PomegBerry,
KelpsyBerry,
QualotBerry,
HondewBerry,
GrepaBerry,
TamatoBerry,
CornnBerry,
MagostBerry,
RabutaBerry,
NomelBerry,
SpelonBerry,
PamtreBerry,
WatmelBerry,
DurinBerry,
BelueBerry,
LiechiBerry,
GanlonBerry,
SalacBerry,
PetayaBerry,
ApicotBerry,
LansatBerry,
StarfBerry,
EnigmaBerry,
BrightPowder,
WhiteHerb,
MachoBrace,
ExpShare,
QuickClaw,
SootheBell,
MentalHerb,
ChoiceBand,
KingsRock,
SilverPowder,
AmuletCoin,
CleanseTag,
SoulDew,
DeepSeaTooth,
DeepSeaScale,
SmokeBall,
Everstone,
FocusBand,
LuckyEgg,
ScopeLens,
MetalCoat,
Leftovers,
DragonScale,
LightBall,
SoftSand,
HardStone,
MiracleSeed,
BlackGlasses,
BlackBelt,
Magnet,
MysticWater,
SharpBeak,
PoisonBarb,
NeverMeltIce,
SpellTag,
TwistedSpoon,
Charcoal,
DragonFang,
SilkScarf,
UpGrade,
ShellBell,
SeaIncense,
LaxIncense,
LuckyPunch,
MetalPowder,
ThickClub,
Stick,
RedScarf,
BlueScarf,
PinkScarf,
GreenScarf,
YellowScarf,
TM01,
TM02,
TM03,
TM04,
TM05,
TM06,
TM07,
TM08,
TM09,
TM10,
TM11,
TM12,
TM13,
TM14,
TM15,
TM16,
TM17,
TM18,
TM19,
TM20,
TM21,
TM22,
TM23,
TM24,
TM25,
TM26,
TM27,
TM28,
TM29,
TM30,
TM31,
TM32,
TM33,
TM34,
TM35,
TM36,
TM37,
TM38,
TM39,
TM40,
TM41,
TM42,
TM43,
TM44,
TM45,
TM46,
TM47,
TM48,
TM49,
TM50
};
static const ItemIndex colosseumItems[] = {
JailKey,
ElevatorKey,
SmallTablet,
FDisk,
RDisk,
LDisk,
DDisk,
UDisk,
SubwayKey,
MaingateKey,
CardKey,
DownStKey,
DNASample,
DNASample1,
DNASample2,
DNASample3,
DNASample4,
DNASample5,
DNASample6,
DNASample7,
DNASample8,
DNASample9,
DNASample10,
DNASample11,
DNASample12,
DNASample13,
DNASample14,
DNASample15,
DNASample16,
DNASample17,
DataROM_C,
SteelTeeth,
Gear,
RedIDBadge,
GrnIDBadge,
BluIDBadge,
YlwIDBadge,
TimeFlute,
EinFileS,
EinFileH,
EinFileC,
EinFileP,
CologneCase_C,
JoyScent_C,
ExciteScent_C,
VividScent_C,
PowerupPart,
EinFileF,
};
static const ItemIndex XDItems[] = {
SafeKey,
ElevatorKey,
BonslyCard,
MachinePart,
GonzapsKey,
DataROM_XD,
IDCard,
MusicDisc,
SystemLever,
MayorsNote,
MirorRadar,
PokeSnack,
CologneCase_XD,
JoyScent_XD,
ExciteScent_XD,
VividScent_XD,
SunShard,
MoonShard,
BonslyPhoto,
CryAnalyzer,
KraneMemo1,
KraneMemo2,
KraneMemo3,
KraneMemo4,
KraneMemo5,
VoiceCase1,
VoiceCase2,
VoiceCase3,
VoiceCase4,
VoiceCase5,
DiscCase,
BattleCD01,
BattleCD02,
BattleCD03,
BattleCD04,
BattleCD05,
BattleCD06,
BattleCD07,
BattleCD08,
BattleCD09,
BattleCD10,
BattleCD11,
BattleCD12,
BattleCD13,
BattleCD14,
BattleCD15,
BattleCD16,
BattleCD17,
BattleCD18,
BattleCD19,
BattleCD20,
BattleCD21,
BattleCD22,
BattleCD23,
BattleCD24,
BattleCD25,
BattleCD26,
BattleCD27,
BattleCD28,
BattleCD29,
BattleCD30,
BattleCD31,
BattleCD32,
BattleCD33,
BattleCD34,
BattleCD35,
BattleCD36,
BattleCD37,
BattleCD38,
BattleCD39,
BattleCD40,
BattleCD41,
BattleCD42,
BattleCD43,
BattleCD44,
BattleCD45,
BattleCD46,
BattleCD47,
BattleCD48,
BattleCD49,
BattleCD50,
BattleCD51,
BattleCD52,
BattleCD53,
BattleCD54,
BattleCD55,
BattleCD56,
BattleCD57,
BattleCD58,
BattleCD59,
BattleCD60,
};
if (index < 245) return commonItems[index];
index -= 245;
if (isXD) {
if (index < 91) return XDItems[index];
}
else {
if (index < 48) return colosseumItems[index];
}
return NoItem;
}
size_t pkmSpeciesIndexToNameIndex(PokemonSpeciesIndex index) {
if (index == Bonsly) return 387;
return (size_t) getPokedexIndexOf(index);
}
PokemonSpeciesIndex nameIndexToPkmSpeciesIndex(size_t index) {
if (index == 387) return Bonsly;
return getSpeciesIndexOf((u16)index);
}
#define LIBPKMGC_CHECK_LANG_INDEX(lang) lang = ((lang == NoLanguage) || (lang > Spanish)) ? English : lang;
#define LIBPKMGC_GET_LOCALIZED_NAME_LIST(lang) const char **lst = (names[(size_t)lang] == NULL) ? names[2] : names[(size_t)lang];
#define LIBPKMGC_GET_LOCALIZED_NAME(lang, id, maxval) LIBPKMGC_CHECK_LANG_INDEX(lang); LIBPKMGC_GET_LOCALIZED_NAME_LIST(lang);\
return (id > maxval) ? lst[0] : lst[(size_t)id];
const char* getPokemonSpeciesName(LanguageIndex language, PokemonSpeciesIndex index) {
using namespace Detail::Species;
size_t id = pkmSpeciesIndexToNameIndex(index);
LIBPKMGC_GET_LOCALIZED_NAME(language, id, 387);
}
const char* getPokemonSpeciesNameByPkdxIndex(LanguageIndex language, u16 pkdexIndex) {
using namespace Detail::Species;
size_t id = (pkdexIndex == 438) ? 387 : pkdexIndex;
LIBPKMGC_GET_LOCALIZED_NAME(language, id, 387);
}
const char* getPokemonNatureName(LanguageIndex language, PokemonNatureIndex index) {
using namespace Detail::Natures;
LIBPKMGC_GET_LOCALIZED_NAME(language, index, Quirky);
}
const char* getPokemonMoveName(LanguageIndex language, PokemonMoveIndex index) {
using namespace Detail::Moves;
LIBPKMGC_GET_LOCALIZED_NAME(language, index, PsychoBoost);
}
const char* getPokemonAbilityName(LanguageIndex language, PokemonAbilityIndex index) {
using namespace Detail::Abilities;
LIBPKMGC_GET_LOCALIZED_NAME(language, index, AirLock);
}
const char* getItemName(LanguageIndex language, ItemIndex index, bool isXD) {
LIBPKMGC_CHECK_LANG_INDEX(language);
size_t id = itemIndexToNameIndex(index, isXD);
if (id < 245) {
using namespace Detail::GivableItems;
LIBPKMGC_GET_LOCALIZED_NAME_LIST(language);
return lst[id];
}
if (isXD) {
using namespace Detail::XDExclusiveItems;
LIBPKMGC_GET_LOCALIZED_NAME_LIST(language);
return lst[namesByIndex[id - 245]];
}
else {
using namespace Detail::ColosseumExclusiveItems;
LIBPKMGC_GET_LOCALIZED_NAME_LIST(language);
return lst[id - 245];
}
return 0;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,81 @@
#include <LibPkmGC/GC/Common/BagData.h>
namespace LibPkmGC {
namespace GC {
BagData::BagData(size_t inSize, size_t nb_regular_items, const u8* inData) : Base::DataStruct(inSize, inData), nbRegularItems(nb_regular_items){
}
void BagData::deleteFields(void) {
delete[] regularItems;
}
BagData::~BagData() {
BagData::deleteFields();
}
void BagData::swap(BagData& other) {
if (nbRegularItems != other.nbRegularItems) throw(std::invalid_argument("this->nbRegularItems != other.nbRegularItems"));
Base::DataStruct::swap(other);
SW(regularItems);
SW_ARRAY(keyItems, 43);
SW_ARRAY(TMs, 64);
SW_ARRAY(berries, 46);
SW_ARRAY(colognes, 3);
}
BagData::BagData(BagData const & other) : Base::DataStruct(other), nbRegularItems(other.nbRegularItems) {
regularItems = new Item[nbRegularItems];
CP_ARRAY(regularItems, nbRegularItems);
CP_ARRAY(keyItems, 43);
CP_ARRAY(TMs, 64);
CP_ARRAY(berries, 46);
CP_ARRAY(colognes, 3);
}
BagData& BagData::operator=(BagData const & other) {
Base::DataStruct::operator=(other);
if (nbRegularItems != other.nbRegularItems) throw(std::invalid_argument("this->nbRegularItems != other.nbRegularItems"));
if (this != &other) {
BagData::deleteFields();
regularItems = new Item[nbRegularItems];
CP_ARRAY(regularItems, nbRegularItems);
CP_ARRAY(keyItems, 43);
CP_ARRAY(TMs, 64);
CP_ARRAY(berries, 46);
CP_ARRAY(colognes, 3);
}
return *this;
}
void BagData::loadFields(void) {
size_t offset = 0;
regularItems = new Item[nbRegularItems];
#define LD_ITEMS(field, nb) for (size_t i = 0; i < nb; ++i)\
field[i].load(data + offset + 4*i);\
offset += 4 * nb;
LD_ITEMS(regularItems, nbRegularItems);
LD_ITEMS(keyItems, 43);
LD_ITEMS(pokeballs, 16);
LD_ITEMS(TMs, 64);
LD_ITEMS(berries, 46);
LD_ITEMS(colognes, 3);
}
void BagData::save(void) {
size_t offset = 0;
#define SV_ITEMS(field, nb) for (size_t i = 0; i < nb; ++i)\
field[i].save(data + offset + 4*i);\
offset += 4 * nb;
SV_ITEMS(regularItems, nbRegularItems);
SV_ITEMS(keyItems, 43);
SV_ITEMS(pokeballs, 16);
SV_ITEMS(TMs, 64);
SV_ITEMS(berries, 46);
SV_ITEMS(colognes, 3);
}
}
}

View File

@ -0,0 +1,35 @@
#include <LibPkmGC/GC/Common/BattleModeData.h>
namespace LibPkmGC {
namespace GC {
BattleModeData::BattleModeData(size_t inSize, const u8* inData) : Base::DataStruct(inSize, inData) {
}
void BattleModeData::deleteFields(void) {
for (size_t i = 0; i < 6; ++i) delete rules[i];
}
BattleModeData::~BattleModeData() {
BattleModeData::deleteFields();
}
void BattleModeData::swap(BattleModeData& other) {
Base::DataStruct::swap(other);
for (size_t i = 0; i < 6; ++i) other.rules[i]->swap(*rules[i]);
}
BattleModeData::BattleModeData(BattleModeData const& other) : Base::DataStruct(other){
CL_ARRAY(rules, 6);
}
BattleModeData & BattleModeData::operator=(BattleModeData const& other) {
Base::DataStruct::operator=(other);
if (this != &other) {
CL_ARRAY(rules, 6);
}
return *this;
}
}
}

View File

@ -0,0 +1,57 @@
#include <LibPkmGC/GC/Common/DaycareData.h>
namespace LibPkmGC {
namespace GC {
DaycareData::DaycareData(size_t inSize, const u8* inData) : Base::DataStruct(inSize, inData) {
}
void DaycareData::deleteFields(void) {
delete pkm;
}
DaycareData::~DaycareData(void) {
DaycareData::deleteFields();
}
DaycareData::DaycareData(DaycareData const& other) : Base::DataStruct(other),
status(other.status), initialPkmLevel(other.initialPkmLevel), initialPkmPurifCounter(other.initialPkmPurifCounter) {
pkm = other.pkm->clone();
}
void DaycareData::swap(DaycareData& other) {
Base::DataStruct::swap(other);
SW(status);
SW(initialPkmLevel);
SW(initialPkmPurifCounter);
pkm->swap(*other.pkm);
}
DaycareData& DaycareData::operator=(DaycareData const& other) {
Base::DataStruct::operator=(other);
if (this != &other) {
CP(status);
CP(initialPkmLevel);
CP(initialPkmPurifCounter);
*pkm = *other.pkm;
}
return *this;
}
void DaycareData::loadFields(void) {
LD_FIELD_E(s8, status, 0, DaycareStatus);
status = ((status < NotVisited) || (status > PkmDeposited)) ? NoPkmDeposited : status;
LD_FIELD(u8, initialPkmLevel, 1);
LD_FIELD(u32, initialPkmPurifCounter, 4);
}
void DaycareData::save(void) {
SV_FIELD_E(s8, status, 0, DaycareStatus);
SV_FIELD(u8, initialPkmLevel, 1);
SV_FIELD(u32, initialPkmPurifCounter, 4);
SV_SUBSTRUCTURE2(Pokemon, pkm, 8);
}
}
}

View File

@ -0,0 +1,101 @@
#include <LibPkmGC/GC/Common/GroupBattleRule.h>
namespace LibPkmGC {
namespace GC {
GroupBattleRule::GroupBattleRule(size_t inSize, size_t nb_bannable_items, const u8* inData) : Base::DataStruct(inSize, inData), nbBannableItems(nb_bannable_items) {
}
GroupBattleRule::GroupBattleRule(GroupBattleRule const& other) : Base::DataStruct(other), nbBannableItems(other.nbBannableItems) {
*this = other;
}
void GroupBattleRule::deleteFields(void) {
delete bannedItems;
}
GroupBattleRule::~GroupBattleRule(void) {
delete bannedItems;
}
void GroupBattleRule::swap(GroupBattleRule & other) {
if (nbBannableItems != other.nbBannableItems) throw std::invalid_argument("this->nbBannableItems != other.nbBannableItems");
Base::DataStruct::swap(other);
SW(minLevel);
SW(maxLevel);
SW(maxLevelSum);
SW(itemRestrictions);
SW(noSpeciesClause);
SW(noItemClause);
SW(noSleepClause);
SW(noFreezeClause);
SW(noSkillSwap);
SW(explosionClause);
SW(noRequiemClause);
SW(allowFixedDmgAbilities);
SW(maxBattleDuration);
SW(orderTimeout);
SW_ARRAY(bannedItems, nbBannableItems);
}
GroupBattleRule& GroupBattleRule::operator=(GroupBattleRule const& other) {
if (nbBannableItems != other.nbBannableItems) throw std::invalid_argument("this->nbBannableItems != other.nbBannableItems");
if (this != &other) {
Base::DataStruct::operator=(other);
CP(minLevel);
CP(maxLevel);
CP(maxLevelSum);
CP(itemRestrictions);
CP(noSpeciesClause);
CP(noItemClause);
CP(noSleepClause);
CP(noFreezeClause);
CP(noSkillSwap);
CP(explosionClause);
CP(noRequiemClause);
CP(allowFixedDmgAbilities);
CP(maxBattleDuration);
CP(orderTimeout);
CP_ARRAY(bannedItems, nbBannableItems);
}
return *this;
}
void GroupBattleRule::loadFields(void) {
bannedItems = new bool[nbBannableItems];
LD_FIELD(u16, minLevel, 0);
LD_FIELD(u16, maxLevel, 2);
LD_FIELD(u16, maxLevelSum, 4);
LD_FIELD_E(u32, itemRestrictions, 8, ItemRestrictionLevel);
LD_FIELD_B(u8, noSpeciesClause, 12);
LD_FIELD_B(u8, noItemClause, 13);
LD_FIELD_B(u8, noSleepClause, 14);
LD_FIELD_B(u8, noFreezeClause, 15);
LD_FIELD_B(u8, noSkillSwap, 16);
LD_FIELD_B(u8, explosionClause, 17);
LD_FIELD_B(u8, noRequiemClause, 18);
LD_FIELD_B(u8, allowFixedDmgAbilities, 19);
LD_FIELD(s16, maxBattleDuration, 20);
LD_FIELD(s16, orderTimeout, 22);
}
void GroupBattleRule::save(void) {
SV_FIELD(u16, minLevel, 0);
SV_FIELD(u16, maxLevel, 2);
SV_FIELD(u16, maxLevelSum, 4);
SV_FIELD_E(u32, itemRestrictions, 8, ItemRestrictionLevel);
SV_FIELD_B(u8, noSpeciesClause, 12);
SV_FIELD_B(u8, noItemClause, 13);
SV_FIELD_B(u8, noSleepClause, 14);
SV_FIELD_B(u8, noFreezeClause, 15);
SV_FIELD_B(u8, noSkillSwap, 16);
SV_FIELD_B(u8, explosionClause, 17);
SV_FIELD_B(u8, noRequiemClause, 18);
SV_FIELD_B(u8, allowFixedDmgAbilities, 19);
SV_FIELD(s16, maxBattleDuration, 20);
SV_FIELD(s16, orderTimeout, 22);
}
}
}

View File

@ -0,0 +1,47 @@
#include <LibPkmGC/GC/Common/MailboxData.h>
namespace LibPkmGC {
namespace GC {
MailboxData::MailboxData(size_t inSize, u16 max_nb_mails, const u8* inData) : Base::DataStruct(inSize, inData), maxNbMails(max_nb_mails) {
}
void MailboxData::deleteFields(void) {
delete[] mails;
}
MailboxData::~MailboxData() {
MailboxData::deleteFields();
}
void MailboxData::swap(MailboxData & other) {
if (maxNbMails != other.maxNbMails) throw std::invalid_argument("maxNbMails != other.maxNbMails");
Base::DataStruct::swap(other);
SW(nbMails);
SW(mails);
}
MailboxData::MailboxData(MailboxData const & other) : Base::DataStruct(other), nbMails(other.nbMails), maxNbMails(other.maxNbMails) {
mails = new u16[nbMails];
CP_ARRAY(mails, nbMails);
}
MailboxData & MailboxData::operator=(MailboxData const & other) {
if (maxNbMails != other.maxNbMails) throw std::invalid_argument("maxNbMails != other.maxNbMails");
Base::DataStruct::operator=(other);
if (this != &other) {
MailboxData::deleteFields();
CP(nbMails);
mails = new u16[nbMails];
CP_ARRAY(mails, nbMails);
}
return *this;
}
bool MailboxData::isMailEmpty(size_t i) {
return mails[i] == LIBPKMGC_MAILBOX_EMPTY_MAIL;
}
}
}

View File

@ -0,0 +1,48 @@
#include <LibPkmGC/GC/Common/PCData.h>
namespace LibPkmGC {
namespace GC {
PCData::PCData(size_t inSize, size_t nb_boxes, const u8* inData) : Base::DataStruct(inSize, inData), nbBoxes(nb_boxes) {
}
void PCData::deleteFields(void) {
for (size_t i = 0; i < nbBoxes; ++i)
delete boxes[i];
delete[] boxes;
}
PCData::~PCData(void) {
PCData::deleteFields();
}
PCData::PCData(PCData const& other) : Base::DataStruct(other), nbBoxes(other.nbBoxes) {
boxes = new PokemonBox*[nbBoxes];
CL_ARRAY(boxes, nbBoxes);
CP_ARRAY(items, 235);
}
void PCData::swap(PCData& other) {
if (nbBoxes != other.nbBoxes) throw std::invalid_argument("this->nbBoxes != other.nbBoxes");
Base::DataStruct::swap(other);
SW(boxes);
SW_ARRAY(items, 235);
}
PCData& PCData::operator=(PCData const& other) {
if (nbBoxes != other.nbBoxes) throw std::invalid_argument("this->nbBoxes != other.nbBoxes");
Base::DataStruct::operator=(other);
if (this != &other) {
PCData::deleteFields();
boxes = new PokemonBox*[nbBoxes];
CL_ARRAY(boxes, nbBoxes);
CP_ARRAY(items, 235);
}
return *this;
}
}
}

View File

@ -0,0 +1,69 @@
#include <LibPkmGC/GC/Common/PlayerData.h>
namespace LibPkmGC {
namespace GC {
PlayerData::PlayerData(size_t inSize, const u8* inData) : Base::DataStruct(inSize, inData) {
}
void PlayerData::deleteFields(void) {
for (size_t i = 0; i < 6; ++i) delete party[i];
delete bag;
delete trainerName;
}
PlayerData::~PlayerData(void) {
PlayerData::deleteFields();
}
PlayerData::PlayerData(PlayerData const& other) : Base::DataStruct(other), SID(other.SID), TID(other.TID), money(other.money), pkCoupons(other.pkCoupons),
trainerGender(other.trainerGender){
CL(trainerName);
CL_ARRAY(party, 6);
CL(bag);
}
PlayerData& PlayerData::operator=(PlayerData const& other) {
if (size != other.size) throw std::invalid_argument("Cannot assign because *this and other are of different types");
Base::DataStruct::operator=(other);
if (this != &other) {
PlayerData::deleteFields();
CP(SID); CP(TID); CP(money); CP(pkCoupons);
CL(trainerName);
CL_ARRAY(party, 6);
CL(bag);
CP(trainerGender);
}
return *this;
}
void PlayerData::swap(PlayerData& other) {
if (size != other.size) throw std::invalid_argument("Cannot assign because *this and other are of different types");
Base::DataStruct::swap(other);
SW(SID); SW(TID); SW(money); SW(pkCoupons);
CL(trainerName);
SW_ARRAY(party, 6);
SW(bag);
SW(trainerGender);
}
void PlayerData::loadFields(void) {
trainerName = new PokemonString(data, 10);
LD_FIELD(u16, SID, 0x2c);
LD_FIELD(u16, TID, 0x2e);
}
void PlayerData::save(void) {
trainerName->save(data, 10);
SV_FIELD(u16, SID, 0x2c);
SV_FIELD(u16, TID, 0x2e);
}
void PlayerData::swapPokemon(size_t n, size_t m) {
if ((n > 6) || (m > 6)) return;
std::swap(party[n], party[m]);
}
}
}

View File

@ -0,0 +1,41 @@
#include <LibPkmGC/GC/Common/Pokemon.h>
namespace LibPkmGC {
namespace GC {
Pokemon::Pokemon(size_t inSize, const u8* inData) : Base::Pokemon(inSize, inData) {
usesPartyData = true;
}
Pokemon::~Pokemon(void)
{
}
Pokemon::Pokemon(Pokemon const& other) : Base::Pokemon(other), shadowPkmID(other.shadowPkmID) {}
void Pokemon::swap(Pokemon& other) { Base::Pokemon::swap(other); SW(shadowPkmID); }
PokemonAbilityIndex Pokemon::getAbility(void) const {
const PokemonSpeciesData dt = getSpeciesData(species);
return (hasSpecialAbility()) ? dt.possibleAbilities[1] : dt.possibleAbilities[0];
}
Pokemon& Pokemon::operator=(Pokemon const& other) {
if (this != &other) {
Base::Pokemon::operator=(other);
CP(shadowPkmID);
}
return *this;
}
void Pokemon::swap(Base::Pokemon & other) {
return swap((Pokemon&)other);
}
Pokemon& Pokemon::operator=(Base::Pokemon const& other) {
return operator=((Pokemon const&)other);
}
}
}

View File

@ -0,0 +1,24 @@
#include <LibPkmGC/GC/Common/PokemonBox.h>
namespace LibPkmGC {
namespace GC {
PokemonBox::PokemonBox(size_t inSize, const u8* inData) : Base::PokemonBox(inSize, inData){
};
PokemonBox::~PokemonBox(void) {
}
PokemonBox::PokemonBox(PokemonBox const& other) : Base::PokemonBox(other) {
}
void PokemonBox::loadFields(void) {
name = new PokemonString(data, 8);
}
void PokemonBox::save(void) {
name->save(data, 8);
}
}
}

Some files were not shown because too many files have changed in this diff Show More