Skip to content

Commit b69dfc5

Browse files
authored
Improve SOS, add help menu, and fix friendship (#70)
1 parent fadec10 commit b69dfc5

36 files changed

+483
-129
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ clean:
2121
make clean -C 3gx
2222
rm -rf out
2323

24+
format:
25+
cargo +nightly fmt --all --manifest-path reader_core/Cargo.toml
26+
2427
lint:
2528
cargo +nightly-2024-03-21 clippy --release -Z build-std=core,alloc --target armv6k-nintendo-3ds --manifest-path reader_core/Cargo.toml
2629

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ This information can be used to RNG shiny and high IV Pokemon, similar to lua sc
1616
- Start + Select: Pause game and enable manual frame advancing
1717
- Select: Advance one frame while paused
1818
- Start or A: Unpause game
19+
- SOS Menu Commands:
20+
- X + Right (D-Pad): Set SOS Caller slot to current Ally slot
21+
- X + Up/Down: Manually increment/decrement Caller slot
1922

2023
## Installing
2124

reader_core/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

reader_core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pokereader"
3-
version = "0.7.4"
3+
version = "0.8.0"
44
edition = "2021"
55

66
[dependencies]

reader_core/build.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ fn get_tree_state() -> &'static str {
88
.unwrap()
99
.stdout
1010
.is_empty();
11-
if is_clean {
12-
""
13-
} else {
14-
"dirty-"
15-
}
11+
if is_clean { "" } else { "dirty-" }
1612
}
1713

1814
fn get_hash() -> String {
@@ -30,9 +26,5 @@ fn get_hash() -> String {
3026
}
3127

3228
fn main() {
33-
println!(
34-
"cargo:rustc-env=GIT_HASH={}{}",
35-
get_tree_state(),
36-
get_hash()
37-
);
29+
println!("cargo:rustc-env=GIT_HASH={}{}", get_tree_state(), get_hash());
3830
}

reader_core/rustfmt.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
style_edition = "2024"
2+
max_width = 110

reader_core/src/crystal/draw.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::pnp::{self, Button};
77
const WHITE: u32 = 0xffffff;
88
const GREEN: u32 = 0x003c00;
99
const RED: u32 = 0x1f0000;
10+
pub const CRYSTAL_CYAN: u32 = 0x003c3c;
1011

1112
fn get_iv_color(iv: u8) -> u32 {
1213
match iv {
@@ -42,11 +43,7 @@ pub fn draw_rng(reader: &Gen2Reader) {
4243
pub fn draw_pkx(pkx: &Pk2) {
4344
pnp::println!("Species: {}", pkx.species);
4445
pnp::println!(color = get_shiny_color(pkx.shiny), "Shiny: {}", pkx.shiny);
45-
pnp::println!(
46-
"HPower: {} {}",
47-
pkx.hidden_power_type,
48-
pkx.hidden_power_base
49-
);
46+
pnp::println!("HPower: {} {}", pkx.hidden_power_type, pkx.hidden_power_base);
5047
pnp::println!(color = get_iv_color(pkx.hp), "HP DV: {}", pkx.hp);
5148
pnp::println!(color = get_iv_color(pkx.atk), "Atk DV: {}", pkx.atk);
5249
pnp::println!(color = get_iv_color(pkx.def), "Def DV: {}", pkx.def);

reader_core/src/crystal/frame.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ use super::{
66
use crate::{
77
pnp,
88
utils::{
9+
ShowView,
10+
help_menu::HelpMenu,
911
menu::{Menu, MenuOption, MenuOptionValue},
1012
sub_menu::SubMenu,
11-
ShowView,
1213
},
1314
};
1415
use once_cell::unsync::Lazy;
@@ -20,6 +21,7 @@ enum CrystalView {
2021
Party,
2122
Wild,
2223
NonCfw,
24+
HelpMenu,
2325
}
2426

2527
impl MenuOptionValue for CrystalView {
@@ -30,6 +32,7 @@ impl MenuOptionValue for CrystalView {
3032
Self::Party => "Party",
3133
Self::Wild => "Wild",
3234
Self::NonCfw => "Non-CFW",
35+
Self::HelpMenu => "Help",
3336
}
3437
}
3538
}
@@ -38,8 +41,9 @@ struct PersistedState {
3841
frame: usize,
3942
show_view: ShowView,
4043
view: CrystalView,
41-
main_menu: Menu<4, CrystalView>,
44+
main_menu: Menu<5, CrystalView>,
4245
party_menu: SubMenu<1, 6>,
46+
help_menu: HelpMenu,
4347
}
4448

4549
unsafe fn get_state() -> &'static mut PersistedState {
@@ -48,11 +52,13 @@ unsafe fn get_state() -> &'static mut PersistedState {
4852
show_view: ShowView::default(),
4953
view: CrystalView::MainMenu,
5054
party_menu: SubMenu::default(),
55+
help_menu: HelpMenu::default(),
5156
main_menu: Menu::new([
5257
MenuOption::new(CrystalView::Rng),
5358
MenuOption::new(CrystalView::Party),
5459
MenuOption::new(CrystalView::Wild),
5560
MenuOption::new(CrystalView::NonCfw),
61+
MenuOption::new(CrystalView::HelpMenu),
5662
]),
5763
});
5864
Lazy::force_mut(&mut STATE)
@@ -91,6 +97,7 @@ pub fn run_frame() {
9197
draw_pkx(&reader.party((slot - 1) as u8));
9298
}
9399
CrystalView::NonCfw => draw_non_cfw(&reader, state.frame),
100+
CrystalView::HelpMenu => state.help_menu.update_and_draw(is_locked),
94101
CrystalView::MainMenu => {
95102
state.main_menu.update_view();
96103
state.main_menu.draw();

reader_core/src/crystal/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ mod hook;
55
mod pk2;
66
mod reader;
77

8+
pub use draw::CRYSTAL_CYAN;
89
pub use frame::run_frame;
910
pub use hook::init_crystal;

reader_core/src/crystal/pk2.rs

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -253,15 +253,53 @@ const SPECIES_LOOKUP: [&str; 252] = [
253253
"Celebi",
254254
];
255255

256+
#[rustfmt::skip]
256257
const NATURE_LOOKUP: [&str; 25] = [
257-
"Hardy", "Lonely", "Brave", "Adamant", "Naughty", "Bold", "Docile", "Relaxed", "Impish", "Lax",
258-
"Timid", "Hasty", "Serious", "Jolly", "Naive", "Modest", "Mild", "Quiet", "Bashful", "Rash",
259-
"Calm", "Gentle", "Sassy", "Careful", "Quirky",
258+
"Hardy",
259+
"Lonely",
260+
"Brave",
261+
"Adamant",
262+
"Naughty",
263+
"Bold",
264+
"Docile",
265+
"Relaxed",
266+
"Impish",
267+
"Lax",
268+
"Timid",
269+
"Hasty",
270+
"Serious",
271+
"Jolly",
272+
"Naive",
273+
"Modest",
274+
"Mild",
275+
"Quiet",
276+
"Bashful",
277+
"Rash",
278+
"Calm",
279+
"Gentle",
280+
"Sassy",
281+
"Careful",
282+
"Quirky",
260283
];
261284

285+
#[rustfmt::skip]
262286
const HIDDEN_POWER_LOOKUP: [&str; 16] = [
263-
"Fighting", "Flying", "Poison", "Ground", "Rock", "Bug", "Ghost", "Steel", "Fire", "Water",
264-
"Grass", "Electric", "Psychic", "Ice", "Dragon", "Dark",
287+
"Fighting",
288+
"Flying",
289+
"Poison",
290+
"Ground",
291+
"Rock",
292+
"Bug",
293+
"Ghost",
294+
"Steel",
295+
"Fire",
296+
"Water",
297+
"Grass",
298+
"Electric",
299+
"Psychic",
300+
"Ice",
301+
"Dragon",
302+
"Dark",
265303
];
266304

267305
pub struct Pk2 {
@@ -299,9 +337,7 @@ impl Pk2 {
299337
Pk2 {
300338
spec_index,
301339
species: SPECIES_LOOKUP.get(spec_index as usize).unwrap_or(&"None"),
302-
nature: NATURE_LOOKUP
303-
.get(experience as usize % 25)
304-
.unwrap_or(&"Unknown"),
340+
nature: NATURE_LOOKUP.get(experience as usize % 25).unwrap_or(&"Unknown"),
305341
experience,
306342
atk,
307343
def,
@@ -313,12 +349,7 @@ impl Pk2 {
313349
.get(((atk & 3) << 2 | def & 3) as usize)
314350
.unwrap_or(&"Unknown"),
315351
hidden_power_base: 31
316-
+ (5 * ((atk >> 3) << 3
317-
| (def >> 3) << 2
318-
| (spe >> 3) << 1
319-
| (spc >> 3))
320-
+ (spc & 3))
321-
/ 2,
352+
+ (5 * ((atk >> 3) << 3 | (def >> 3) << 2 | (spe >> 3) << 1 | (spc >> 3)) + (spc & 3)) / 2,
322353
}
323354
}
324355
}

0 commit comments

Comments
 (0)