Skip to content

Commit 941793c

Browse files
committed
Add TRV to gen 6 and 7
1 parent a19eeeb commit 941793c

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

reader_core/src/gen6/draw.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub fn draw_rng(reader: &Gen6Reader, rng: &Gen6Rng) {
4848
draw_tinymt(reader, rng);
4949
pnp::println!("");
5050
pnp::println!("Save var: {:08X}", reader.seed_save_variable());
51-
pnp::println!("TSV: {}", reader.tsv());
51+
pnp::println!("TSV: {}, TRV: {:X}", reader.tsv(), reader.trv());
5252
}
5353

5454
pub fn draw_daycare(daycare: &Daycare) {

reader_core/src/gen6/reader.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ impl Gen6Reader {
126126
(self.tid() ^ self.sid()) >> 4
127127
}
128128

129+
pub fn trv(&self) -> u16 {
130+
(self.tid() ^ self.sid()) & 0xf
131+
}
132+
129133
pub fn daycare1(&self) -> Daycare {
130134
Daycare {
131135
egg_seed: [

reader_core/src/gen7/draw.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ pub fn draw_rng(reader: &Gen7Reader, rng: &RngWrapper<Sfmt>) {
1515
pnp::println!("State[0]: {:08X}", (sfmt_state >> 32) as u32);
1616
pnp::println!("Advances: {}", rng.advances());
1717
pnp::println!("");
18-
pnp::println!("Gen7TID: {}", reader.tid());
19-
pnp::println!("TSV: {}", reader.tsv());
18+
pnp::println!("Gen7TID: {}", reader.g7tid());
19+
pnp::println!("TSV: {}, TRV: {:X}", reader.tsv(), reader.trv());
2020
pnp::println!("");
2121
pnp::println!("NPC count: {}", reader.npc_count());
2222
}

reader_core/src/gen7/reader.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,26 @@ impl Gen7Reader {
8989
}
9090
}
9191

92-
pub fn tid(&self) -> u32 {
92+
pub fn g7tid(&self) -> u32 {
9393
let sidtid = pnp::read::<u32>(self.addrs.id);
9494

9595
sidtid % 1000000
9696
}
9797

98+
fn tid(&self) -> u16 {
99+
pnp::read::<u16>(self.addrs.id)
100+
}
101+
102+
fn sid(&self) -> u16 {
103+
pnp::read::<u16>(self.addrs.id + 2)
104+
}
105+
98106
pub fn tsv(&self) -> u16 {
99-
let tid = pnp::read::<u16>(self.addrs.id);
100-
let sid = pnp::read::<u16>(self.addrs.id + 2);
107+
(self.tid() ^ self.sid()) >> 4
108+
}
101109

102-
(tid ^ sid) >> 4
110+
pub fn trv(&self) -> u16 {
111+
(self.tid() ^ self.sid()) & 0xf
103112
}
104113

105114
pub fn init_seed(&self) -> u32 {

0 commit comments

Comments
 (0)