Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added patches/ips/resource_collection_hudcap.ips
Binary file not shown.
88 changes: 88 additions & 0 deletions patches/src/resource_collection_hudcap.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
!bank_84_free_space_start = $84F4A0
!bank_84_free_space_end = $84F4FF

org $84896C
jsr add_max_energy_capped

org $84898A
jsr add_max_reserve_capped

org $8489AD
jsr add_max_missile_capped

org $8489B7
jsr add_current_missile_capped

org $8489D6
jsr add_max_super_capped

org $8489E0
jsr add_current_super_capped

org $8489FF
jsr add_max_powerbomb_capped

org $848A09
jsr add_current_powerbomb_capped

org !bank_84_free_space_start

add_max_energy_capped:
adc $0000,Y
cmp #$05D8 ;1499 energy

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be 0x5DB

bcc +
lda #$05D8
+
rts

add_max_reserve_capped:
adc $0000,Y
cmp #$0190
bcc +
lda #$0190
+
rts

add_max_missile_capped:
adc $0000,Y
cmp #$03E7 ;999 missiles
bcc +
lda #$03E7
+
rts

add_max_super_capped:
add_max_powerbomb_capped:
adc $0000,Y
cmp #$0063 ;99 supers/powerbombs
bcc +
lda #$0063
+
rts

add_current_missile_capped:
adc $0000,Y
cmp $09C8
bcc +
lda $09C8
+
rts

add_current_super_capped:
adc $0000,Y
cmp $09CC
bcc +
lda $09CC
+
rts

add_current_powerbomb_capped:
adc $0000,Y
cmp $09D0
bcc +
lda $09D0
+
rts

print pc
assert pc() <= !bank_84_free_space_end
35 changes: 21 additions & 14 deletions rust/maprando-logic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,38 +54,45 @@ impl GlobalState {
match item {
Item::Missile => {
self.inventory.collectible_missile_packs += 1;
let new_max_missiles = (ammo_collect_fraction
* self.inventory.collectible_missile_packs as f32)
.round() as Capacity
* (missile_size as Capacity);
let new_max_missiles = std::cmp::min(
999,
(ammo_collect_fraction * self.inventory.collectible_missile_packs as f32)
.round() as Capacity
* (missile_size as Capacity),
);
self.inventory.max_missiles = new_max_missiles;
}
Item::Super => {
self.inventory.collectible_super_packs += 1;
let new_max_supers = (ammo_collect_fraction
* self.inventory.collectible_super_packs as f32)
.round() as Capacity
* (super_size as Capacity);
let new_max_supers = std::cmp::min(
99,
(ammo_collect_fraction * self.inventory.collectible_super_packs as f32).round()
as Capacity
* (super_size as Capacity),
);
self.inventory.max_supers = new_max_supers;
}
Item::PowerBomb => {
self.inventory.collectible_power_bomb_packs += 1;
let new_max_power_bombs = (ammo_collect_fraction
* self.inventory.collectible_power_bomb_packs as f32)
.round() as Capacity
* (powerbomb_size as Capacity);
let new_max_power_bombs = std::cmp::min(
99,
(ammo_collect_fraction * self.inventory.collectible_power_bomb_packs as f32)
.round() as Capacity
* (powerbomb_size as Capacity),
);
self.inventory.max_power_bombs = new_max_power_bombs;
}
Item::ETank => {
self.inventory.max_energy += 100;
self.inventory.max_energy = std::cmp::min(1499, self.inventory.max_energy + 100);
if !tech[game_data.manage_reserves_tech_idx] {
self.inventory.max_reserves =
Capacity::min(self.inventory.max_reserves, self.inventory.max_energy);
}
}
Item::ReserveTank => {
self.inventory.collectible_reserve_tanks += 1;
self.inventory.max_reserves = self.inventory.collectible_reserve_tanks * 100;
self.inventory.max_reserves =
std::cmp::min(400, self.inventory.collectible_reserve_tanks * 100);
if !tech[game_data.manage_reserves_tech_idx] {
self.inventory.max_reserves =
Capacity::min(self.inventory.max_reserves, self.inventory.max_energy);
Expand Down
18 changes: 18 additions & 0 deletions rust/maprando/src/patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ impl Patcher<'_> {
"fix_horiz_doors", // this too?
"fix_dust_torizo",
"fix_choot",
"resource_collection_hudcap",
];

patches.push("new_game");
Expand Down Expand Up @@ -2304,6 +2305,23 @@ impl Patcher<'_> {
* (self.settings.item_progression_settings.powerbomb_size as isize);
}
}

if starting_energy > 1499 {
starting_energy = 1499
}
if starting_reserves > 400 {
starting_reserves = 400
}
if starting_missiles > 999 {
starting_missiles = 999
}
if starting_supers > 99 {
starting_supers = 99
}
if starting_powerbombs > 99 {
starting_powerbombs = 99
}

let beam_equipped_mask = if beam_mask & 0x000C == 0x000C {
// Don't equip Spazer if Plasma equipped
beam_mask & !0x0004
Expand Down
40 changes: 0 additions & 40 deletions rust/maprando/src/randomize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3640,26 +3640,6 @@ pub fn get_starting_items(settings: &RandomizerSettings) -> Vec<ItemCount> {
if x.item == Item::WallJump && settings.other_settings.wall_jump == WallJump::Vanilla {
continue;
}
// Enforce HUD-based limits for starting ammo
// TODO: eliminate this in favor of an in-game patch to cap ammo capacity to HUD limits.
match x.item {
Item::Missile => {
while x.count * settings.item_progression_settings.missile_size as usize > 999 {
x.count -= 1;
}
}
Item::Super => {
while x.count * settings.item_progression_settings.super_size as usize > 99 {
x.count -= 1;
}
}
Item::PowerBomb => {
while x.count * settings.item_progression_settings.powerbomb_size as usize > 99 {
x.count -= 1;
}
}
_ => {}
}
// Depending on if Split Speed Booster is enabled, do not place inapplicable booster items.
match (x.item, settings.other_settings.speed_booster) {
(Item::BlueBooster | Item::SparkBooster, SpeedBooster::Vanilla) => continue,
Expand Down Expand Up @@ -3745,26 +3725,6 @@ impl<'r> Randomizer<'r> {
}
}

// Enforce HUD-based total resource limits (999 missile, 99 super, 99 PB)
while initial_items_remaining[Item::Missile as usize]
* settings.item_progression_settings.missile_size as usize
> 999
{
initial_items_remaining[Item::Missile as usize] -= 1;
}
while initial_items_remaining[Item::Super as usize]
* settings.item_progression_settings.super_size as usize
> 99
{
initial_items_remaining[Item::Super as usize] -= 1;
}
while initial_items_remaining[Item::PowerBomb as usize]
* settings.item_progression_settings.powerbomb_size as usize
> 99
{
initial_items_remaining[Item::PowerBomb as usize] -= 1;
}

let target_initial_items = initial_items_remaining.clone();
let ammo_shortage_weight: Vec<(Item, f32)> = vec![
(Item::Missile, 0.12),
Expand Down
Loading