Skip to content

Commit

Permalink
Custom item support
Browse files Browse the repository at this point in the history
Required mains supported for Missiles/PB
Unlimited Missiles/PBs are supported now
Spring Ball has its own item now
  • Loading branch information
UltiNaruto committed Aug 30, 2024
1 parent 0881b63 commit 57419f8
Show file tree
Hide file tree
Showing 10 changed files with 650 additions and 286 deletions.
6 changes: 6 additions & 0 deletions ppcasm/ppcasm_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ decl_instrs! {
addc[o][.], (r:d), (r:a), (r:b) => (6;31) | d | a | b | (?o) | (9;10) | (?.);
addi, (r:d), (r:a), (i:imm) => (6;14) | d | a | (16;imm);
addic[.], (r:d), (r:a), (i:imm) => (5;6) | (?.) | d | a | (16;imm);
and[.], (r:d), (r:a), (r:b) => (6;31) | d | a | b | (10;28) | (?.);
andi, (r:d), (r:a), (i:imm) => (6;28) | d | a | (16;imm);
andis, (r:d), (r:a), (i:imm) => (6;29) | d | a | (16;imm);
b[l][a], (l:li) => (6;18) | (24;li) | (?a) | (?l);
Expand Down Expand Up @@ -409,11 +410,16 @@ decl_instrs! {
mr, (r:a), (r:s) => (6;31) | s | a | s | (10;444) | (1;0);
mtlr, (r:d) => (6;31) | d | (10;0x100) | (10;467) | (1;0);
mullw[o][.],(r:d), (r:a), (r:b) => (6;31) | d | a | b | (?o) | (9;235) | (?.);
neg, (r:d), (r:a) => (6;31) | d | a | (16;208);
nop => (32;0x60000000);
nor[.], (r:d), (r:a), (r:b) => (6;31) | d | a | b | (10;124) | (?.);
not, (r:a), (r:s) => (6;31) | s | a | s | (10;124) | (1;0);
or[.], (r:d), (r:a), (r:b) => (6;31) | d | a | b | (10;444) | (?.);
ori, (r:d), (r:a), (i:imm) => (6;24) | d | a | (16;imm);
oris, (r:d), (r:a), (i:imm) => (6;25) | d | a | (16;imm);
slw[.], (r:d), (r:a), (r:b) => (6;31) | d | a | b | (10;24) | (?.);
slwi, (r:a), (r:s), (i:n) => (6;21) | s | a | (5;{#n}) | (5;0) |(5;{31 - #n}) | (1;0);
srw[.], (r:d), (r:a), (r:b) => (6;31) | d | a | b | (10;536) | (?.);
srwi, (r:a), (r:s), (i:n) => (6;21) | s | a | (5;{32 - #n}) | (5;n) |(5;31) | (1;0);
rlwimi[.], (r:a), (r:s), (i:sh), (i:mb), (i:me) =>
(6;20) | s | a | (5;sh) | (5;mb) |(5;me) | (?.);
Expand Down
229 changes: 131 additions & 98 deletions schema/randomprime.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,22 @@
"type": "string"
},
"springBall": {
"description": "Restores the Spring Ball feature from Metroid Prime Trilogy. Use C-Stick Up while being morphed to use Spring Ball. NOTE: You need Morph Ball Bombs to use Spring Ball just like in Metroid Prime Trilogy.",
"description": "[Deprecated] Restores the Spring Ball feature from Metroid Prime Trilogy. Use C-Stick Up while being morphed to use Spring Ball. NOTE: You need Morph Ball Bombs to use Spring Ball just like in Metroid Prime Trilogy.",
"type": "boolean",
"default": false
"default": false,
"deprecated": true
},
"springBallItem": {
"description": "Spring Ball will require this item to be obtained before being able to use it.",
"$ref": "#/$defs/pickupType",
"not": {
"enum": [
"Nothing",
"Floaty Jump",
"Ice Trap"
]
},
"default": "Spring Ball"
},
"warpToStart": {
"description": "Refusing to save at any Save Station while holding L + R will warp you to the starting location (by default, Samus' Ship in Tallon Overworld: Landing Site)",
Expand Down Expand Up @@ -470,9 +483,10 @@
"default": false
},
"enableIceTraps": {
"description": "Set to true if Ice Traps items are used in this layout.",
"description": "[Deprecated] Does not do anything anymore",
"type": "boolean",
"default": false
"default": false,
"deprecated": true
},
"missileStationPbRefill": {
"description": "If enabled, Missile Stations also refill Power Bomb ammunition.",
Expand Down Expand Up @@ -2492,6 +2506,12 @@
"type": "boolean",
"default": false
},
"powerSuit": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295,
"default": 0
},
"variaSuit": {
"type": "boolean",
"default": false
Expand Down Expand Up @@ -2535,6 +2555,32 @@
"flamethrower": {
"type": "boolean",
"default": false
},
"unknownItem1": {
"type": "integer",
"minimum": 0,
"maximum": 4294967295,
"default": 0
},
"unlimitedMissiles": {
"type": "boolean",
"default": false
},
"unlimitedPowerBombs": {
"type": "boolean",
"default": false
},
"missileLauncher": {
"type": "boolean",
"default": true
},
"powerBombLauncher": {
"type": "boolean",
"default": true
},
"springBall": {
"type": "boolean",
"default": false
}
},
"required": [
Expand All @@ -2552,6 +2598,7 @@
"bombs",
"spiderBall",
"boostBall",
"powerSuit",
"variaSuit",
"gravitySuit",
"phazonSuit",
Expand All @@ -2562,7 +2609,13 @@
"superMissile",
"wavebuster",
"iceSpreader",
"flamethrower"
"flamethrower",
"unknownItem1",
"unlimitedMissiles",
"unlimitedPowerBombs",
"missileLauncher",
"powerBombLauncher",
"springBall"
],
"default": {
"combatVisor": true,
Expand All @@ -2579,6 +2632,7 @@
"bombs": false,
"spiderBall": false,
"boostBall": false,
"powerSuit": 0,
"variaSuit": false,
"gravitySuit": false,
"phazonSuit": false,
Expand All @@ -2589,7 +2643,13 @@
"superMissile": false,
"wavebuster": false,
"iceSpreader": false,
"flamethrower": false
"flamethrower": false,
"unknownItem1": 0,
"unlimitedMissiles": false,
"unlimitedPowerBombs": false,
"missileLauncher": true,
"powerBombLauncher": true,
"springBall": false
},
"additionalProperties": false
},
Expand Down Expand Up @@ -2693,53 +2753,7 @@
},
"type": {
"description": "Defines what is acquired when the pickup is obtained.",
"type": "string",
"enum": [
"Power Beam",
"Ice Beam",
"Wave Beam",
"Plasma Beam",
"Missile",
"Scan Visor",
"Morph Ball Bomb",
"Power Bomb",
"Flamethrower",
"Thermal Visor",
"Charge Beam",
"Super Missile",
"Grapple Beam",
"X-Ray Visor",
"Ice Spreader",
"Space Jump Boots",
"Morph Ball",
"Combat Visor",
"Boost Ball",
"Spider Ball",
"Power Suit",
"Gravity Suit",
"Varia Suit",
"Phazon Suit",
"Energy Tank",
"Unknown Item 1",
"Health Refill",
"Unknown Item 2",
"Wavebuster",
"Artifact of Truth",
"Artifact of Strength",
"Artifact of Elder",
"Artifact of Wild",
"Artifact of Lifegiver",
"Artifact of Warrior",
"Artifact of Chozo",
"Artifact of Nature",
"Artifact of Sun",
"Artifact of World",
"Artifact of Spirit",
"Artifact of Newborn",
"Nothing",
"Floaty Jump",
"Ice Trap"
],
"$ref": "#/$defs/pickupType",
"default": "Nothing"
},
"scanText": {
Expand Down Expand Up @@ -3918,51 +3932,16 @@
"default": 0
},
"itemId": {
"type": "string",
"enum": [
"PowerBeam",
"IceBeam",
"WaveBeam",
"PlasmaBeam",
"Missile",
"ScanVisor",
"MorphBallBomb",
"PowerBomb",
"Flamethrower",
"ThermalVisor",
"ChargeBeam",
"SuperMissile",
"GrappleBeam",
"XRayVisor",
"IceSpreader",
"SpaceJumpBoots",
"MorphBall",
"CombatVisor",
"BoostBall",
"SpiderBall",
"PowerSuit",
"GravitySuit",
"VariaSuit",
"PhazonSuit",
"EnergyTank",
"UnknownItem1",
"HealthRefill",
"UnknownItem2",
"Wavebuster",
"ArtifactOfTruth",
"ArtifactOfStrength",
"ArtifactOfElder",
"ArtifactOfWild",
"ArtifactOfLifegiver",
"ArtifactOfWarrior",
"ArtifactOfChozo",
"ArtifactOfNature",
"ArtifactOfSun",
"ArtifactOfWorld",
"ArtifactOfSpirit",
"ArtifactOfNewborn"
],
"default": "PowerBeam"
"description": "Any custom items will be stored in UnknownItem2",
"$ref": "#/$defs/pickupType",
"not": {
"enum": [
"Nothing",
"Floaty Jump",
"Ice Trap"
]
},
"default": "Power Beam"
},
"active": {
"type": "boolean",
Expand Down Expand Up @@ -5820,6 +5799,60 @@
"Disabled",
"Enemy"
]
},
"pickupType": {
"type": "string",
"enum": [
"Power Beam",
"Ice Beam",
"Wave Beam",
"Plasma Beam",
"Missile",
"Scan Visor",
"Morph Ball Bomb",
"Power Bomb",
"Flamethrower",
"Thermal Visor",
"Charge Beam",
"Super Missile",
"Grapple Beam",
"X-Ray Visor",
"Ice Spreader",
"Space Jump Boots",
"Morph Ball",
"Combat Visor",
"Boost Ball",
"Spider Ball",
"Power Suit",
"Gravity Suit",
"Varia Suit",
"Phazon Suit",
"Energy Tank",
"Unknown Item 1",
"Health Refill",
"Unknown Item 2",
"Wavebuster",
"Artifact of Truth",
"Artifact of Strength",
"Artifact of Elder",
"Artifact of Wild",
"Artifact of Lifegiver",
"Artifact of Warrior",
"Artifact of Chozo",
"Artifact of Nature",
"Artifact of Sun",
"Artifact of World",
"Artifact of Spirit",
"Artifact of Newborn",
"Unlimited Missiles",
"Unlimited Power Bombs",
"Missile Launcher",
"Main Power Bomb",
"Spring Ball",
"Nothing",
"Floaty Jump",
"Ice Trap"
]
}
}
}
8 changes: 4 additions & 4 deletions src/add_modify_obj_patches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,9 @@ pub fn patch_add_spawn_point(
varia_suit: 0,
phazon_suit: 0,
energy_tanks: 0,
unknown0: 0,
unknown_item_1: 0,
health_refill: 0,
unknown1: 0,
unknown_item_2: 0,
wavebuster: 0,
default_spawn: config.default_spawn.unwrap_or(false) as u8,
active: config.active.unwrap_or(true) as u8,
Expand Down Expand Up @@ -630,7 +630,7 @@ pub fn patch_add_special_fn(
unknown3: config.unknown4.unwrap_or_default(),
layer_change_room_id: config.layer_change_room_id.unwrap_or(0xFFFFFFFF),
layer_change_layer_id: config.layer_change_layer_id.unwrap_or(0xFFFFFFFF),
item_id: config.item_id.unwrap_or(PickupType::PowerBeam) as u32,
item_id: PickupType::from_str(config.item_id.unwrap_or("Power Beam")) as u32,

Check failure on line 633 in src/add_modify_obj_patches.rs

View workflow job for this annotation

GitHub Actions / Linux

mismatched types

Check failure on line 633 in src/add_modify_obj_patches.rs

View workflow job for this annotation

GitHub Actions / Linux

mismatched types

Check failure on line 633 in src/add_modify_obj_patches.rs

View workflow job for this annotation

GitHub Actions / macOS

mismatched types

Check failure on line 633 in src/add_modify_obj_patches.rs

View workflow job for this annotation

GitHub Actions / macOS

mismatched types

Check failure on line 633 in src/add_modify_obj_patches.rs

View workflow job for this annotation

GitHub Actions / Windows

mismatched types

Check failure on line 633 in src/add_modify_obj_patches.rs

View workflow job for this annotation

GitHub Actions / Windows

mismatched types
unknown4: config.active.unwrap_or(true) as u8, // active
unknown5: config.unknown6.unwrap_or_default(),
unknown6: config.spinner1.unwrap_or(0xFFFFFFFF),
Expand Down Expand Up @@ -668,7 +668,7 @@ pub fn patch_add_special_fn(
property_data.layer_change_layer_id = layer_change_layer_id
}
if let Some(item_id) = config.item_id {
property_data.item_id = item_id as u32
property_data.item_id = PickupType::from_str(item_id) as u32

Check failure on line 671 in src/add_modify_obj_patches.rs

View workflow job for this annotation

GitHub Actions / Linux

mismatched types

Check failure on line 671 in src/add_modify_obj_patches.rs

View workflow job for this annotation

GitHub Actions / macOS

mismatched types

Check failure on line 671 in src/add_modify_obj_patches.rs

View workflow job for this annotation

GitHub Actions / Windows

mismatched types
}
if let Some(active) = config.active {
property_data.unknown4 = active as u8
Expand Down
18 changes: 8 additions & 10 deletions src/custom_assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1367,16 +1367,14 @@ pub fn collect_game_resources<'r>(
];
looking_for.extend(custom_scan_point_deps);

if config.enable_ice_traps {
let player_freeze_deps: Vec<(u32, FourCC)> = vec![
resource_info!("breakFreezeVisor.PART").into(),
resource_info!("Frost1TXTR.TXTR").into(),
resource_info!("75DAC95C.PART").into(),
resource_info!("zorch1_snow3.TXTR").into(),
resource_info!("C28C7348.PART").into(),
];
looking_for.extend(player_freeze_deps);
}
let player_freeze_deps: Vec<(u32, FourCC)> = vec![
resource_info!("breakFreezeVisor.PART").into(),
resource_info!("Frost1TXTR.TXTR").into(),
resource_info!("75DAC95C.PART").into(),
resource_info!("zorch1_snow3.TXTR").into(),
resource_info!("C28C7348.PART").into(),
];
looking_for.extend(player_freeze_deps);

// Dependencies read from paks and custom assets will go here //
let mut found = HashMap::with_capacity(looking_for.len());
Expand Down
Loading

0 comments on commit 57419f8

Please sign in to comment.