-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
98b417e
commit 51c542d
Showing
19 changed files
with
766 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
|
||
#include "pk9.h" | ||
#include "rng_tracker.h" | ||
|
||
#ifdef __cplusplus | ||
#include <memory> | ||
|
||
namespace csight::arceus { | ||
extern "C" { | ||
#endif | ||
|
||
pk9_t *arceus_read_party_pokemon(u8 index); | ||
pk9_t *arceus_read_wild_pokemon(); | ||
xoroshiro_tracker_t *arceus_get_main_rng_tracker(); | ||
|
||
#ifdef __cplusplus | ||
} | ||
|
||
std::shared_ptr<Pk9> read_party_pokemon(u8 index) { return std::make_shared<Pk9>(arceus_read_party_pokemon(index)); } | ||
|
||
std::shared_ptr<Pk9> read_wild_pokemon() { return std::make_shared<Pk9>(arceus_read_wild_pokemon()); } | ||
|
||
std::shared_ptr<RngTracker> get_main_rng_tracker() { | ||
return std::make_shared<RngTracker>((void *)arceus_get_main_rng_tracker(), RngType::Xoroshiro); | ||
} | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
#pragma once | ||
|
||
#include "pkx.h" | ||
#include <switch.h> | ||
|
||
#ifdef __cplusplus | ||
|
||
#include <array> | ||
#include <optional> | ||
#include <string> | ||
|
||
namespace csight { | ||
extern "C" { | ||
#endif | ||
|
||
typedef struct pk9 pk9_t; | ||
|
||
void free_pk9(pk9_t *ptr); | ||
|
||
u32 pk9_encryption_constant(pk9_t *ptr); | ||
void pk9_species_string(pk9_t *ptr, char *out, size_t out_size); | ||
u16 pk9_tid(pk9_t *ptr); | ||
u16 pk9_sid(pk9_t *ptr); | ||
void pk9_ability_string(pk9_t *ptr, char *out, size_t out_size); | ||
u8 pk9_ability_number(pk9_t *ptr); | ||
u32 pk9_pid(pk9_t *ptr); | ||
void pk9_nature_string(pk9_t *ptr, char *out, size_t out_size); | ||
void pk9_minted_nature_string(pk9_t *ptr, char *out, size_t out_size); | ||
u8 pk9_gender(pk9_t *ptr); | ||
Stats pk9_evs(pk9_t *ptr); | ||
Stats pk9_ivs(pk9_t *ptr); | ||
void pk9_move1_string(pk9_t *ptr, char *out, size_t out_size); | ||
void pk9_move2_string(pk9_t *ptr, char *out, size_t out_size); | ||
void pk9_move3_string(pk9_t *ptr, char *out, size_t out_size); | ||
void pk9_move4_string(pk9_t *ptr, char *out, size_t out_size); | ||
u8 pk9_language(pk9_t *ptr); | ||
u8 pk9_current_friendship(pk9_t *ptr); | ||
bool pk9_is_shiny(pk9_t *ptr); | ||
bool pk9_is_egg(pk9_t *ptr); | ||
bool find_pk9_raid_seed(u64 *out, pk9_t *ptr); | ||
|
||
#ifdef __cplusplus | ||
} | ||
|
||
class Pk9 : public Pkx { | ||
public: | ||
static const size_t StoredSize = 328; | ||
|
||
Pk9(pk9_t *pk9) : m_pk9(pk9) { } | ||
~Pk9() { free_pk9(m_pk9); } | ||
|
||
u32 EncryptionConstant() { return pk9_encryption_constant(m_pk9); } | ||
|
||
std::string SpeciesString() { | ||
char text[13]; | ||
pk9_species_string(m_pk9, text, 13); | ||
return std::string(text); | ||
} | ||
|
||
u16 Tid() { return pk9_tid(m_pk9); } | ||
|
||
u16 Sid() { return pk9_sid(m_pk9); } | ||
|
||
std::string AbilityString() { | ||
char text[17]; | ||
pk9_ability_string(m_pk9, text, 17); | ||
return std::string(text); | ||
} | ||
|
||
u8 AbilityNumber() { return pk9_ability_number(m_pk9); } | ||
|
||
u32 Pid() { return pk9_pid(m_pk9); } | ||
|
||
std::string NatureString() { | ||
char text[8]; | ||
pk9_nature_string(m_pk9, text, 8); | ||
return std::string(text); | ||
} | ||
|
||
std::string MintedNatureString() { | ||
char text[8]; | ||
pk9_minted_nature_string(m_pk9, text, 8); | ||
return std::string(text); | ||
} | ||
|
||
u8 Gender() { return pk9_gender(m_pk9); } | ||
|
||
Stats Evs() { return pk9_evs(m_pk9); } | ||
|
||
Stats Ivs() { return pk9_ivs(m_pk9); } | ||
|
||
std::string Move1String() { | ||
char text[28]; | ||
pk9_move1_string(m_pk9, text, 28); | ||
return std::string(text); | ||
} | ||
|
||
std::string Move2String() { | ||
char text[28]; | ||
pk9_move2_string(m_pk9, text, 28); | ||
return std::string(text); | ||
} | ||
|
||
std::string Move3String() { | ||
char text[28]; | ||
pk9_move3_string(m_pk9, text, 28); | ||
return std::string(text); | ||
} | ||
|
||
std::string Move4String() { | ||
char text[28]; | ||
pk9_move4_string(m_pk9, text, 28); | ||
return std::string(text); | ||
} | ||
|
||
u8 CurrentFriendship() { return pk9_current_friendship(m_pk9); } | ||
|
||
u8 Language() { return pk9_language(m_pk9); } | ||
|
||
bool IsShiny() { return pk9_is_shiny(m_pk9); } | ||
|
||
bool IsEgg() { return pk9_is_egg(m_pk9); } | ||
|
||
std::optional<u64> FindRaidSeed() { return std::nullopt; } | ||
|
||
private: | ||
pk9_t *m_pk9; | ||
}; | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
#include <switch.h> | ||
#include <vector> | ||
|
||
#ifdef __cplusplus | ||
|
||
namespace csight::arceus { | ||
extern "C" { | ||
#endif | ||
typedef struct arceus_spawn arceus_spawn_t; | ||
|
||
u64 spawn_get_hash(arceus_spawn_t *ptr); | ||
u64 spawn_get_seed(arceus_spawn_t *ptr); | ||
bool spawn_get_is_active(arceus_spawn_t *ptr); | ||
arceus_spawn_t *free_spawn(arceus_spawn_t *ptr); | ||
arceus_spawn_t *arceus_read_spawn(size_t index); | ||
arceus_spawn_t *arceus_read_next_active_spawn(size_t start_index, size_t *found_index); | ||
size_t arceus_read_active_spawn_count(); | ||
size_t arceus_read_spawn_count(); | ||
|
||
#ifdef __cplusplus | ||
} | ||
|
||
class Spawn { | ||
public: | ||
static const size_t Size = 0x18; | ||
|
||
Spawn(size_t index, bool find_next_active = false) { | ||
if (find_next_active) { | ||
m_spawn = arceus_read_next_active_spawn(index, &m_index); | ||
} else { | ||
m_spawn = arceus_read_spawn(index); | ||
m_index = index; | ||
} | ||
} | ||
~Spawn() { free_spawn(m_spawn); } | ||
|
||
size_t Index() { return m_index; } | ||
|
||
u64 Hash() { return spawn_get_hash(m_spawn); } | ||
|
||
u64 Seed() { return spawn_get_seed(m_spawn); } | ||
|
||
bool IsActive() { return spawn_get_is_active(m_spawn); } | ||
|
||
private: | ||
arceus_spawn_t *m_spawn; | ||
size_t m_index; | ||
}; | ||
|
||
// TODO: clean. This was super dirty and quick | ||
std::vector<std::shared_ptr<Spawn>> readActiveSpawns(size_t start_index, size_t end_index) { | ||
std::vector<std::shared_ptr<Spawn>> result; | ||
|
||
for (size_t next_index = start_index; next_index < end_index;) { | ||
auto spawn = std::make_shared<Spawn>(next_index, true); | ||
|
||
if (!spawn->IsActive()) { | ||
break; | ||
} | ||
|
||
next_index = spawn->Index() + 1; | ||
result.push_back(spawn); | ||
} | ||
|
||
return result; | ||
} | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
mod read; | ||
pub use read::*; | ||
|
||
mod offsets; | ||
pub mod rng; | ||
|
||
mod spawn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use num_enum::IntoPrimitive; | ||
|
||
#[derive(Clone, Copy, Debug, PartialEq, IntoPrimitive)] | ||
#[repr(u64)] | ||
pub enum Offset { | ||
PlayerSingleton = 0x4268000, | ||
BattleSingleton = 0x4267f00, | ||
SpawnSingleton = 0x4267ee0, | ||
} |
Oops, something went wrong.