diff --git a/MarathonData.md b/MarathonData.md index 852aecb..0b04d82 100644 --- a/MarathonData.md +++ b/MarathonData.md @@ -391,10 +391,10 @@ main menu, and physics files. Here is a listing of all chunks used within them: | `ShPa` | Not analyzed (shapes) | | `MMLS` | Not analyzed (MML scripts) | | `LUAS` | Not analyzed (Lua scripts) | -| `FXpx` | Effect definitions | +| `FXpx` | Array of Effect Definition | | `MNpx` | Monster definitions | | `PRpx` | Player definitions | -| `PXpx` | Physics definitions | +| `PXpx` | Array of Physics Definition | | `WPpx` | Weapon definitions | | `PICT` | Picture Resource | | `clut` | Unused(?) | @@ -976,6 +976,21 @@ Physics Definition is 104 bytes. | `PlayerSplash` | `fixed` | `96` | | `HalfCamSep` | `fixed` | `100` | +### Effect Definition ### + +Effect Definition is 14 bytes. + +| Name | Type | Offset | +| ---- | ---- | ------ | +| `Collection` | `u16` | `0` | +| `Shape` | `u16` | `2` | +| `Pitch` | `fixed` | `4` | +| `Flags` | `u16` | `8` | +| `Delay` | `u16` | `10` | +| `DelaySound` | `u16` | `12` | + +- `Flags` is an Effect Definition Flags bit field. + ## Images ## ### Picture Resource ### @@ -1925,4 +1940,14 @@ most sensible for, for instance, lava which can be drained. If I could explain to you why there are this many flags, I gladly would, but this actually hurts my head. +### Effect Definition Flags ### + +| Name | Bit | +| ---- | --- | +| `EndOnLoop` | `0` | +| `EndOnXferLoop` | `1` | +| `SoundOnly` | `2` | +| `MakeTwinVisible` | `3` | +| `MediaEffect` | `4` | + diff --git a/src/main.rs b/src/main.rs index ebffeb3..0761722 100644 --- a/src/main.rs +++ b/src/main.rs @@ -64,6 +64,7 @@ fn dump_chunk(opt: &Options, cid: Ident, cnk: &[u8], eid: u16) -> ResultS<()> b"plat" => make_yaml(opt, &rd_array(cnk, map::read_plat)?)?, b"term" => make_yaml(opt, &rd_array(cnk, trm::read_term)?)?, b"PXpx" => make_yaml(opt, &rd_array(cnk, phy::read_pxpx)?)?, + b"FXpx" => make_yaml(opt, &rd_array(cnk, phy::read_fxpx)?)?, _ => (), } } diff --git a/src/marathon/phy.rs b/src/marathon/phy.rs index 2d4fd9f..cc23d70 100644 --- a/src/marathon/phy.rs +++ b/src/marathon/phy.rs @@ -1,4 +1,5 @@ -use crate::{durandal::{err::*, fixed::*}}; +use crate::{durandal::{bin::*, err::*, fixed::*}}; +use bitflags::bitflags; use serde::Serialize; pub fn read_pxpx(b: &[u8]) -> ResultS<(Physics, usize)> @@ -39,6 +40,23 @@ pub fn read_pxpx(b: &[u8]) -> ResultS<(Physics, usize)> vel_bkw, vel_fwd, vel_prp, vel_rec, vel_trm}, 104)) } +pub fn read_fxpx(b: &[u8]) -> ResultS<(Effect, usize)> +{ + read_data! { + 14, BE in b => + collection = u16[0]; + shape = u16[2]; + pitch = Fixed[4]; + flags = u16[8]; + delay = OptShort[10]; + delay_snd = OptShort[12]; + } + + let flags = ok!(EffectFlags::from_bits(flags), "bad EffectFlags")?; + + Ok((Effect{collection, shape, pitch, flags, delay, delay_snd}, 14)) +} + #[derive(Debug, Serialize)] pub struct Physics { @@ -70,4 +88,27 @@ pub struct Physics pub vel_trm: Fixed, } +#[derive(Debug, Serialize)] +pub struct Effect +{ + pub collection: u16, + pub shape: u16, + pub pitch: Fixed, + pub flags: EffectFlags, + pub delay: OptShort, + pub delay_snd: OptShort, +} + +bitflags! { + #[derive(Serialize)] + pub struct EffectFlags: u16 + { + const EndOnLoop = 1; + const EndOnXferLoop = 1 << 1; + const SoundOnly = 1 << 2; + const MakeTwinVisible = 1 << 3; + const MediaEffect = 1 << 4; + } +} + // EOF