Skip to content

Commit

Permalink
Merge branch 'main' into cutscene-skip-crash
Browse files Browse the repository at this point in the history
  • Loading branch information
toasterparty authored May 22, 2024
2 parents aa0846a + bbf56c3 commit 1468c4d
Show file tree
Hide file tree
Showing 14 changed files with 204 additions and 143 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

20 changes: 14 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ dol_linker = { path = "dol_linker" }
dol_symbol_table = { path = "generated/dol_symbol_table" }
json_data = { path = "generated/json_data" }
json_strip = { path = "generated/json_strip" }
libsquish_wrapper = { path = "libsquish_wrapper" }
ppcasm = { path = "ppcasm" }
reader_writer.workspace = true
rel_files = { path = "generated/rel_files" }
resource_info_table.workspace = true
structs = { path = "structs" }
texpresso = "2.0.1"

[profile.release]
lto = "thin"
Expand All @@ -51,7 +51,6 @@ members = [
"generated/dol_symbol_table/dol_symbol_table_macro",
"generated/json_data",
"generated/json_strip",
"libsquish_wrapper",
"ppcasm",
"ppcasm/ppcasm_macro",
"reader_writer",
Expand Down
8 changes: 0 additions & 8 deletions libsquish_wrapper/Cargo.toml

This file was deleted.

17 changes: 0 additions & 17 deletions libsquish_wrapper/build.rs

This file was deleted.

1 change: 0 additions & 1 deletion libsquish_wrapper/libSquish
Submodule libSquish deleted from fd5e6f
32 changes: 0 additions & 32 deletions libsquish_wrapper/src/lib.rs

This file was deleted.

26 changes: 0 additions & 26 deletions libsquish_wrapper/src/wrapper.cpp

This file was deleted.

1 change: 1 addition & 0 deletions ppcasm/ppcasm_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ decl_instrs! {
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) | (?.);
nop => (32;0x60000000);
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);
slwi, (r:a), (r:s), (i:n) => (6;21) | s | a | (5;{#n}) | (5;0) |(5;{31 - #n}) | (1;0);
Expand Down
14 changes: 11 additions & 3 deletions schema/randomprime.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,17 @@
"default": false
},
"staggeredSuitDamage": {
"description": "Damage reduction depends on how many suits you have, not which.",
"type": "boolean",
"default": false
"description": "Configure how suit damage reduction is calculated.\n- `Default` or `false`: Based on strongest suit.\n- `Progressive` or `true`: Based on number of suits.\n- `Additive`: Individual suits provide added damage reduction.\nNOTE: boolean values are deprecated.",
"type": [
"string",
"boolean"
],
"enum": [
"Default",
"Progressive",
"Additive"
],
"default": "Default"
},
"heatDamagePerSec": {
"description": "Configure how much damage per second you take in heated rooms when you don't have the proper protection.",
Expand Down
11 changes: 3 additions & 8 deletions src/bin/txtr_converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use image::{
codecs::png::{PngDecoder, PngEncoder},
ColorType, ImageDecoder,
};
use libsquish_wrapper::{compress_dxt1gcn_block, decompress_dxt1gcn_block};
use randomprime::txtr_conversions::{compress_dxt1gcn_block, decompress_dxt1gcn_block};
use reader_writer::{Readable, Reader, Writable};
use structs::{Txtr, TxtrFormat, TxtrPaletteFormat};

Expand Down Expand Up @@ -445,13 +445,8 @@ impl TxtrFormatExt for TxtrFormat {
}
TxtrFormat::Rgba8 => pixels.copy_from_slice(block),
TxtrFormat::Cmpr => {
let mut decoded_dxt1_block = [[0u8; 4]; 16];
for i in 0..4 {
decompress_dxt1gcn_block(
&mut decoded_dxt1_block,
block[i * 8..(i + 1) * 8].try_into().unwrap(),
);

let decoded_dxt1_block = decompress_dxt1gcn_block(&block[i * 8..(i + 1) * 8]);
let outer_x = i % 2 * 4;
let outer_y = i / 2 * 4;
for (k, decoded_pixel) in decoded_dxt1_block.iter().enumerate() {
Expand Down Expand Up @@ -542,7 +537,7 @@ impl TxtrFormatExt for TxtrFormat {
sub_block_pixel[..].copy_from_slice(&pixels[start..start + 4]);
}

compress_dxt1gcn_block(&sub_block_pixels, sub_block.try_into().unwrap());
compress_dxt1gcn_block(sub_block_pixels, sub_block);
}
}
}
Expand Down
75 changes: 70 additions & 5 deletions src/patch_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ use clap::{crate_version, App, Arg};
use json_data::*;
use json_strip::strip_jsonc_comments;
use reader_writer::{FourCC, Reader};
use serde::{Deserialize, Serialize};
use serde::{
de::{Error, Visitor},
Deserialize, Deserializer, Serialize,
};
use structs::{res_id, MapaObjectVisibilityMode, ResId};

use crate::{
Expand Down Expand Up @@ -1111,6 +1114,66 @@ pub enum DifficultyBehavior {
HardOnly,
}

#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize)]
pub enum SuitDamageReduction {
#[default]
Default,
Progressive,
Additive,
}

impl<'de> Deserialize<'de> for SuitDamageReduction {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct SuitDamageReductionVisitor;

impl<'de> Visitor<'de> for SuitDamageReductionVisitor {
type Value = SuitDamageReduction;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(
formatter,
r#""Default", "Progressive", "Additive", true, or false"#
)
}

fn visit_bool<E>(self, v: bool) -> Result<Self::Value, E>
where
E: Error,
{
if v {
Ok(SuitDamageReduction::Progressive)
} else {
Ok(SuitDamageReduction::Default)
}
}

fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where
E: Error,
{
match v {
"Default" => Ok(SuitDamageReduction::Default),
"Progressive" => Ok(SuitDamageReduction::Progressive),
"Additive" => Ok(SuitDamageReduction::Additive),
variant => Err(E::unknown_variant(
variant,
&["Default", "Progressive", "Additive"],
)),
}
}
}

deserializer.deserialize_enum(
"SuitDamageReduction",
&["Default", "Progressive", "Additive"],
SuitDamageReductionVisitor,
)
}
}

impl fmt::Display for Version {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match self {
Expand Down Expand Up @@ -1190,7 +1253,7 @@ pub struct PatchConfig {
pub poison_damage_per_sec: f32,
pub phazon_damage_per_sec: f32,
pub phazon_damage_modifier: PhazonDamageModifier,
pub staggered_suit_damage: bool,
pub staggered_suit_damage: SuitDamageReduction,
pub item_max_capacity: HashMap<PickupType, u32>,
pub map_default_state: MapaObjectVisibilityMode,
pub auto_enabled_elevators: bool,
Expand Down Expand Up @@ -1283,7 +1346,7 @@ struct GameConfig {
shuffle_pickup_pos_all_rooms: Option<bool>,
remove_vanilla_blast_shields: Option<bool>,
nonvaria_heat_damage: Option<bool>,
staggered_suit_damage: Option<bool>,
staggered_suit_damage: Option<SuitDamageReduction>,
heat_damage_per_sec: Option<f32>,
poison_damage_per_sec: Option<f32>,
phazon_damage_per_sec: Option<f32>,
Expand Down Expand Up @@ -1577,11 +1640,13 @@ impl PatchConfig {
"quickpatch" => patch_config.preferences.quickpatch,
"quiet" => patch_config.preferences.quiet,
"nonvaria heat damage" => patch_config.game_config.nonvaria_heat_damage,
"staggered suit damage" => patch_config.game_config.staggered_suit_damage,
"auto enabled elevators" => patch_config.game_config.auto_enabled_elevators,
"spring ball" => patch_config.game_config.spring_ball,
"warp to start" => patch_config.game_config.warp_to_start,
);
if matches.is_present("staggered suit damage") {
patch_config.game_config.staggered_suit_damage = Some(SuitDamageReduction::Default);
}

// string
if let Some(input_iso_path) = matches.value_of("input iso path") {
Expand Down Expand Up @@ -2362,7 +2427,7 @@ impl PatchConfigPrivate {
.remove_vanilla_blast_shields
.unwrap_or(false),
nonvaria_heat_damage: self.game_config.nonvaria_heat_damage.unwrap_or(false),
staggered_suit_damage: self.game_config.staggered_suit_damage.unwrap_or(false),
staggered_suit_damage: self.game_config.staggered_suit_damage.unwrap_or_default(),
heat_damage_per_sec: self.game_config.heat_damage_per_sec.unwrap_or(10.0),
poison_damage_per_sec: self.game_config.poison_damage_per_sec.unwrap_or(0.11),
phazon_damage_per_sec: self.game_config.phazon_damage_per_sec.unwrap_or(0.964),
Expand Down
Loading

0 comments on commit 1468c4d

Please sign in to comment.