aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/fparkan-fx/src/lib.rs16
-rw-r--r--crates/fparkan-render/src/water.rs29
2 files changed, 45 insertions, 0 deletions
diff --git a/crates/fparkan-fx/src/lib.rs b/crates/fparkan-fx/src/lib.rs
index af7408a..8a567de 100644
--- a/crates/fparkan-fx/src/lib.rs
+++ b/crates/fparkan-fx/src/lib.rs
@@ -67,6 +67,12 @@ pub struct FxHeader {
pub scale: [f32; 3],
}
+/// Effect.dll RVA 0x5C60 reads an owner/provider for modes 4 through 17, including mode 14.
+#[must_use]
+pub const fn fx_time_mode_requires_owner_state(mode: u32) -> bool {
+ matches!(mode, 4..=17)
+}
+
/// FX opcode.
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub enum FxOpcode {
@@ -624,6 +630,16 @@ mod tests {
use std::path::{Path, PathBuf};
#[test]
+ fn phase_sources_distinguish_elapsed_damage_and_progress_modes() {
+ for mode in [0, 1, 2, 3, 18, u32::MAX] {
+ assert!(!fx_time_mode_requires_owner_state(mode));
+ }
+ for mode in [4, 5, 9, 13, 14, 15, 16, 17] {
+ assert!(fx_time_mode_requires_owner_state(mode));
+ }
+ }
+
+ #[test]
fn decodes_synthetic_opcodes_and_refs() {
let mut bytes = header(2);
bytes.extend_from_slice(&command_with_ref_at(
diff --git a/crates/fparkan-render/src/water.rs b/crates/fparkan-render/src/water.rs
index 4f161cc..58a2817 100644
--- a/crates/fparkan-render/src/water.rs
+++ b/crates/fparkan-render/src/water.rs
@@ -7,6 +7,17 @@ pub const EMBM_BUMP_TILE: f32 = 100.0;
/// Native diagonal bump matrix, without luminance modulation.
pub const EMBM_COEFFICIENTS: [f32; 2] = [0.01, 0.01];
+/// Square reflection size chosen by Terrain.dll RVA 0x27FC7 from renderer dimensions.
+#[must_use]
+pub fn legacy_embm_reflection_size(extent: [u32; 2]) -> u32 {
+ let limit = extent[0].min(extent[1]).min(1024);
+ let mut side = 2;
+ while side * 2 <= limit {
+ side *= 2;
+ }
+ side
+}
+
/// Generates the signed bytes written by Terrain.dll RVA 0x2BF50 with CW 0x007F.
#[must_use]
pub fn legacy_embm_bump_map() -> Vec<[i8; 2]> {
@@ -117,6 +128,24 @@ mod tests {
use super::*;
#[test]
+ fn reflection_size_matches_native_renderer_dimension_vectors() {
+ for (extent, expected) in [
+ ([1280, 1024], 1024),
+ ([1280, 720], 512),
+ ([800, 600], 512),
+ ([640, 480], 256),
+ ([1920, 1080], 1024),
+ ([2048, 2048], 1024),
+ ([4, 7], 4),
+ ([3, 300], 2),
+ ([1, 1], 2),
+ ([700, 700], 512),
+ ] {
+ assert_eq!(legacy_embm_reflection_size(extent), expected, "{extent:?}");
+ }
+ }
+
+ #[test]
fn shifted_camera_maps_native_water_corners_and_retains_perspective_depth() {
let projection = crate::LegacyD3d7Projection {
viewport: [0, 0, 1280, 1024],