Skip to content

Commit

Permalink
Reorganize how pickup names are stored again
Browse files Browse the repository at this point in the history
  • Loading branch information
aprilwade committed Jul 16, 2017
1 parent b7aeced commit 521db3c
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 94 deletions.
6 changes: 3 additions & 3 deletions src/bin/randomprime_patcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ fn skip_hudmemos_strg_id(pickup_meta_idx: usize) -> u32

fn add_skip_hudmemos_strgs(pickup_resources: &mut HashMap<(u32, FourCC), structs::Resource>)
{
for (pickup_meta_idx, pt) in PICKUP_TYPES.iter().enumerate() {
for (pickup_meta_idx, pt) in pickup_meta::pickup_meta_table().iter().enumerate() {
let id = skip_hudmemos_strg_id(pickup_meta_idx);
let res = pickup_meta::build_resource(
id,
Expand Down Expand Up @@ -248,7 +248,7 @@ fn build_artifact_temple_totem_scan_strings<R>(pickup_layout: &[u8], rng: &mut R
// XXX It would be nice if we didn't have to use Vec here and could allocated on the stack
// instead, but there doesn't seem to be a way to do it that isn't extremely painful or
// relies on unsafe code.
let specific_room_templates: &mut [(u32, Vec<&str>)] = &mut [
let mut specific_room_templates = [
// Artifact Temple
(0x2398E906, vec!["{pickup} awaits those who truly seek it.\0"]),
];
Expand Down Expand Up @@ -286,7 +286,7 @@ fn build_artifact_temple_totem_scan_strings<R>(pickup_layout: &[u8], rng: &mut R
.find(|row| row.0 == room_id)
.and_then(|row| row.1.pop())
.unwrap_or_else(|| generic_templates_iter.next().unwrap());
let pickup_name = PICKUP_TYPES[*pickup_meta_idx as usize].name;
let pickup_name = pickup_meta::pickup_meta_table()[*pickup_meta_idx as usize].name;
scan_text[artifact_id] = template.replace("{room}", name).replace("{pickup}", pickup_name);
}

Expand Down
55 changes: 54 additions & 1 deletion src/bin/resource_tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,59 @@ impl ResourceKey
}


pub struct PickupType
{
pub name: &'static str,
pub first_loc: usize,
}
// A map from pickup type -> pickup name and location
// Note, the ordering matters here
const PICKUP_TYPES: &'static [PickupType] = &[
PickupType { name: "Missile", first_loc: 1 },
PickupType { name: "Energy Tank", first_loc: 9, },

PickupType { name: "Thermal Visor", first_loc: 50, },
PickupType { name: "X-Ray Visor", first_loc: 71, },

PickupType { name: "Varia Suit", first_loc: 20, },
PickupType { name: "Gravity Suit", first_loc: 54, },
PickupType { name: "Phazon Suit", first_loc: 83, },

PickupType { name: "Morph Ball", first_loc: 5, },
PickupType { name: "Boost Ball", first_loc: 43, },
PickupType { name: "Spider Ball", first_loc: 44, },

PickupType { name: "Morph Ball Bomb", first_loc: 28, },
PickupType { name: "Power Bomb Expansion", first_loc: 12, },
PickupType { name: "Power Bomb", first_loc: 85, },

PickupType { name: "Charge Beam", first_loc: 23, },
PickupType { name: "Space Jump Boots", first_loc: 59, },
PickupType { name: "Grapple Beam", first_loc: 75, },

PickupType { name: "Super Missile", first_loc: 47, },
PickupType { name: "Wavebuster", first_loc: 13, },
PickupType { name: "Ice Spreader", first_loc: 96, },
PickupType { name: "Flamethrower", first_loc: 76, },

PickupType { name: "Wave Beam", first_loc: 41, },
PickupType { name: "Ice Beam", first_loc: 34, },
PickupType { name: "Plasma Beam", first_loc: 99, },

PickupType { name: "Artifact of Lifegiver", first_loc: 14, },
PickupType { name: "Artifact of Wild", first_loc: 21, },
PickupType { name: "Artifact of World", first_loc: 33, },
PickupType { name: "Artifact of Sun", first_loc: 37, },
PickupType { name: "Artifact of Elder", first_loc: 49, },
PickupType { name: "Artifact of Spirit", first_loc: 56, },
PickupType { name: "Artifact of Truth", first_loc: 63, },
PickupType { name: "Artifact of Chozo", first_loc: 72, },
PickupType { name: "Artifact of Warrior", first_loc: 77, },
PickupType { name: "Artifact of Newborn", first_loc: 89, },
PickupType { name: "Artifact of Nature", first_loc: 91, },
PickupType { name: "Artifact of Strength", first_loc: 95, },
];

static CUT_SCENE_PICKUPS: &'static [(u32, u32)] = &[
(0x3C785450, 589860), // Morph Ball
(0x0D72F1F7, 1377077), // Wavebuster
Expand Down Expand Up @@ -836,8 +889,8 @@ fn main()
for i in 0..pickup_table.len() {
let ref pickup_data = pickup_table[&i];
let pickup_bytes = &pickup_data.bytes;
println!(" // {}", pickup_data.name);
println!(" PickupMetaRaw {{");
println!(" name: {:?},", pickup_data.name);
println!(" pickup: &[");
for y in 0..((pickup_bytes.len() + BYTES_PER_LINE - 1) / BYTES_PER_LINE) {
let len = ::std::cmp::min(BYTES_PER_LINE, pickup_bytes.len() - y * BYTES_PER_LINE);
Expand Down
53 changes: 0 additions & 53 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,56 +103,3 @@ pub mod asset_ids {
ARTIFACT_TEMPLE_MREA = 0x2398E906,
}
}

pub struct PickupType
{
pub name: &'static str,
pub first_loc: usize,
}
// A map from pickup type -> pickup name and location
// Note, the ordering matters here
pub const PICKUP_TYPES: &'static [PickupType] = &[
PickupType { name: "Missile", first_loc: 1 },
PickupType { name: "Energy Tank", first_loc: 9, },

PickupType { name: "Thermal Visor", first_loc: 50, },
PickupType { name: "X-Ray Visor", first_loc: 71, },

PickupType { name: "Varia Suit", first_loc: 20, },
PickupType { name: "Gravity Suit", first_loc: 54, },
PickupType { name: "Phazon Suit", first_loc: 83, },

PickupType { name: "Morph Ball", first_loc: 5, },
PickupType { name: "Boost Ball", first_loc: 43, },
PickupType { name: "Spider Ball", first_loc: 44, },

PickupType { name: "Morph Ball Bomb", first_loc: 28, },
PickupType { name: "Power Bomb Expansion", first_loc: 12, },
PickupType { name: "Power Bomb", first_loc: 85, },

PickupType { name: "Charge Beam", first_loc: 23, },
PickupType { name: "Space Jump Boots", first_loc: 59, },
PickupType { name: "Grapple Beam", first_loc: 75, },

PickupType { name: "Super Missile", first_loc: 47, },
PickupType { name: "Wavebuster", first_loc: 13, },
PickupType { name: "Ice Spreader", first_loc: 96, },
PickupType { name: "Flamethrower", first_loc: 76, },

PickupType { name: "Wave Beam", first_loc: 41, },
PickupType { name: "Ice Beam", first_loc: 34, },
PickupType { name: "Plasma Beam", first_loc: 99, },

PickupType { name: "Artifact of Lifegiver", first_loc: 14, },
PickupType { name: "Artifact of Wild", first_loc: 21, },
PickupType { name: "Artifact of World", first_loc: 33, },
PickupType { name: "Artifact of Sun", first_loc: 37, },
PickupType { name: "Artifact of Elder", first_loc: 49, },
PickupType { name: "Artifact of Spirit", first_loc: 56, },
PickupType { name: "Artifact of Truth", first_loc: 63, },
PickupType { name: "Artifact of Chozo", first_loc: 72, },
PickupType { name: "Artifact of Warrior", first_loc: 77, },
PickupType { name: "Artifact of Newborn", first_loc: 89, },
PickupType { name: "Artifact of Nature", first_loc: 91, },
PickupType { name: "Artifact of Strength", first_loc: 95, },
];
3 changes: 3 additions & 0 deletions src/pickup_meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use asset_ids;

pub struct PickupMeta
{
pub name: &'static str,
pub pickup: Pickup<'static>,
pub deps: &'static [(u32, FourCC)],
pub hudmemo_strg: u32,
Expand All @@ -29,6 +30,7 @@ pub fn setup_pickup_meta_table()
let vec = PICKUP_RAW_META.iter()
.map(|meta| {
PickupMeta {
name: meta.name,
pickup: Reader::new(meta.pickup).read(()),
deps: leak_vec(meta.deps.iter().map(|&(fid, ref b)| (fid, b.into())).collect()),
hudmemo_strg: meta.hudmemo_strg,
Expand Down Expand Up @@ -129,6 +131,7 @@ pub fn extra_assets<'a>() -> Vec<Resource<'a>>

struct PickupMetaRaw
{
name: &'static str,
pickup: &'static [u8],
deps: &'static [(u32, [u8; 4])],
hudmemo_strg: u32,
Expand Down
Loading

0 comments on commit 521db3c

Please sign in to comment.