add NOTE loader

png-branch
an 2019-03-01 06:22:27 -05:00
parent 144a4ae24a
commit 49253773a6
12 changed files with 115 additions and 120 deletions

View File

@ -378,7 +378,7 @@ Map tags:
| `SIDS` | Array of Side | | `SIDS` | Array of Side |
| `POLY` | Array of Polygon | | `POLY` | Array of Polygon |
| `LITE` | Array of Light | | `LITE` | Array of Light |
| `NOTE` | Not analyzed (annotations) | | `NOTE` | Array of Annotation |
| `OBJS` | Array of Object | | `OBJS` | Array of Object |
| `påth` | Not analyzed (guardpaths) (å is $8C) | | `påth` | Not analyzed (guardpaths) (å is $8C) |
| `plac` | Array of Object Frequency | | `plac` | Array of Object Frequency |
@ -782,6 +782,20 @@ Light is 100 bytes.
- `ActivPri`, `ActivSec` and `ActivMid` are Light Function structures. - `ActivPri`, `ActivSec` and `ActivMid` are Light Function structures.
- `InactPri`, `InactSec` and `InactMid` are Light Function structures. - `InactPri`, `InactSec` and `InactMid` are Light Function structures.
### Map Annotation ###
Map Annotation is 72 bytes.
| Name | Type | Offset |
| ---- | ---- | ------ |
| `Type` | `u16` | `0` |
| `Location` | `struct` | `2` |
| `Polygon` | `u16` | `6` |
| `Text` | `u8[64]` | `8` |
- `Type` is an index into the annotation type definition, but there's only one,
so this will always be `0` anyway.
### Object ### ### Object ###
Object is 16 bytes. Object is 16 bytes.

View File

@ -1,7 +1,6 @@
//! Binary data conversion utilities. //! Binary data conversion utilities.
use crate::durandal::err::*; use crate::durandal::err::*;
use serde::Serialize;
use std::{fmt, num::NonZeroU16}; use std::{fmt, num::NonZeroU16};
#[doc(hidden)] #[doc(hidden)]
@ -267,7 +266,7 @@ impl fmt::Debug for OptU16
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result
{ {
match self.get() { match self.get() {
None => write!(f, "None"), None => write!(f, "None"),
Some(n) => write!(f, "Some({})", n), Some(n) => write!(f, "Some({})", n),
} }
} }
@ -278,7 +277,7 @@ pub type Ident = [u8; 4];
/// An object identified by a `u16` which may be `u16::max_value()` to /// An object identified by a `u16` which may be `u16::max_value()` to
/// represent a nulled value. /// represent a nulled value.
#[derive(Serialize)] #[derive(serde::Serialize, serde::Deserialize)]
pub struct OptU16(Option<NonZeroU16>); pub struct OptU16(Option<NonZeroU16>);
// EOF // EOF

View File

@ -1,6 +1,5 @@
//! Fixed point numbers. //! Fixed point numbers.
use serde::Serialize;
use std::{fmt::{self, Write}, use std::{fmt::{self, Write},
ops}; ops};
@ -10,7 +9,7 @@ macro_rules! define_fixed_type {
struct $Type:ident ($IT:ident) : $UT:ident, $LT:ident, $FracBits:expr; struct $Type:ident ($IT:ident) : $UT:ident, $LT:ident, $FracBits:expr;
) => { ) => {
$(#[$outer])* $(#[$outer])*
#[derive(Clone, PartialEq, Serialize)] #[derive(Clone, PartialEq, serde::Serialize)]
pub struct $Type($IT); pub struct $Type($IT);
impl $Type impl $Type

View File

@ -1,7 +1,6 @@
//! Image and color representations. //! Image and color representations.
use crate::durandal::err::*; use crate::durandal::err::*;
use serde::Serialize;
use std::io; use std::io;
/// Creates a RGB8 color from a R5G5B5 format color. /// Creates a RGB8 color from a R5G5B5 format color.
@ -187,15 +186,15 @@ impl Color for Color8
} }
/// An RGB16 color. /// An RGB16 color.
#[derive(Clone, Debug, PartialEq, Serialize)] #[derive(Clone, Debug, PartialEq, serde::Serialize)]
pub struct Color16(u16, u16, u16); pub struct Color16(u16, u16, u16);
/// An RGB8 color. /// An RGB8 color.
#[derive(Clone, Debug, PartialEq, Serialize)] #[derive(Clone, Debug, PartialEq, serde::Serialize)]
pub struct Color8(u8, u8, u8); pub struct Color8(u8, u8, u8);
/// An RGB16 image. /// An RGB16 image.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct Image16 pub struct Image16
{ {
w: usize, w: usize,
@ -204,7 +203,7 @@ pub struct Image16
} }
/// An RGB8 image. /// An RGB8 image.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct Image8 pub struct Image8
{ {
w: usize, w: usize,

View File

@ -1,7 +1,6 @@
use maraiah::{durandal::{err::*, file::*, image::*, sound::*, text::*}, use maraiah::{durandal::{err::*, file::*, image::*, sound::*},
marathon::{machdr, shp, snd, wad}}; marathon::{machdr, shp, snd, wad}};
use std::{fs, use std::{fs, io};
io::{self, Write}};
fn make_tga(_opt: &Options, fname: &str, im: &impl Image) -> ResultS<()> fn make_tga(_opt: &Options, fname: &str, im: &impl Image) -> ResultS<()>
{ {
@ -9,13 +8,6 @@ fn make_tga(_opt: &Options, fname: &str, im: &impl Image) -> ResultS<()>
write_tga(&mut out, im) write_tga(&mut out, im)
} }
fn make_data(_opt: &Options, fname: &str, data: &[u8]) -> ResultS<()>
{
let mut out = io::BufWriter::new(fs::File::create(fname)?);
out.write_all(data)?;
Ok(())
}
fn make_yaml<T>(opt: &Options, data: &T) -> ResultS<()> fn make_yaml<T>(opt: &Options, data: &T) -> ResultS<()>
where T: serde::Serialize + std::fmt::Debug where T: serde::Serialize + std::fmt::Debug
{ {
@ -34,29 +26,6 @@ fn make_wav(fname: &str, snd: &impl Sound) -> ResultS<()>
write_wav(&mut out, snd) write_wav(&mut out, snd)
} }
fn dump_chunk(opt: &Options, cnk: &wad::Chunk, eid: u16) -> ResultS<()>
{
if opt.wad_wrt_all {
match cnk {
wad::Chunk::Pict(im) => {
let fname = format!("{}/pict_{}.tga", opt.out_dir, eid);
make_tga(opt, &fname, im)?;
}
wad::Chunk::Data{iden, data} => {
if opt.wad_unknown {
let iden = mac_roman_conv(iden);
let fname = format!("{}/{:04}{}.bin", opt.out_dir, eid, iden);
make_data(opt, &fname, data)?;
}
make_yaml(opt, cnk)?;
}
_ => make_yaml(opt, cnk)?,
}
}
Ok(())
}
fn process_wad(opt: &Options, b: &[u8]) -> ResultS<()> fn process_wad(opt: &Options, b: &[u8]) -> ResultS<()>
{ {
let wad = wad::read_wad(b)?; let wad = wad::read_wad(b)?;
@ -65,10 +34,8 @@ fn process_wad(opt: &Options, b: &[u8]) -> ResultS<()>
make_yaml(opt, &wad.head)?; make_yaml(opt, &wad.head)?;
} }
for (eid, ent) in wad.entries { if opt.wad_wrt_all {
for cnk in ent.chunks { make_yaml(opt, &wad.entries)?;
dump_chunk(opt, &cnk, eid)?;
}
} }
Ok(()) Ok(())

View File

@ -3,7 +3,6 @@
use crate::{durandal::{bin::*, err::*, fixed::*, text::mac_roman_conv}, use crate::{durandal::{bin::*, err::*, fixed::*, text::mac_roman_conv},
marathon::xfer::TransferMode}; marathon::xfer::TransferMode};
use bitflags::bitflags; use bitflags::bitflags;
use serde::Serialize;
/// Reads a `Minf` chunk. /// Reads a `Minf` chunk.
pub fn read_minf(b: &[u8]) -> ResultS<Minf> pub fn read_minf(b: &[u8]) -> ResultS<Minf>
@ -311,8 +310,21 @@ pub fn read_plat(b: &[u8]) -> ResultS<(Platform, usize)>
Ok((Platform{ptype, speed, delay, hei_min, hei_max, flags, index, tag}, 32)) Ok((Platform{ptype, speed, delay, hei_min, hei_max, flags, index, tag}, 32))
} }
/// Reads a `NOTE` chunk.
pub fn read_note(b: &[u8]) -> ResultS<(Note, usize)>
{
read_data! {
72, BE in b =>
pos = read_point[2..6];
poly = u16[6];
text = mac_roman_conv[8..72] nt;
}
Ok((Note{pos, poly, text}, 72))
}
/// A point in world-space. /// A point in world-space.
#[derive(Clone, PartialEq, Serialize)] #[derive(Clone, PartialEq, serde::Serialize)]
pub struct Point pub struct Point
{ {
pub x: Unit, pub x: Unit,
@ -320,7 +332,7 @@ pub struct Point
} }
/// A line segment. /// A line segment.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct Line pub struct Line
{ {
pub flags: LineFlags, pub flags: LineFlags,
@ -333,7 +345,7 @@ pub struct Line
} }
/// The texture of a side segment. /// The texture of a side segment.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct SideTex pub struct SideTex
{ {
pub offs: Point, pub offs: Point,
@ -341,7 +353,7 @@ pub struct SideTex
} }
/// One side of a line segment. /// One side of a line segment.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct Side pub struct Side
{ {
pub stype: SideType, pub stype: SideType,
@ -358,7 +370,7 @@ pub struct Side
} }
/// A polygon segment. /// A polygon segment.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct Polygon pub struct Polygon
{ {
pub ptype: PolyType, pub ptype: PolyType,
@ -381,7 +393,7 @@ pub struct Polygon
} }
/// A light function. /// A light function.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct LightFunc pub struct LightFunc
{ {
pub ftype: LightFuncType, pub ftype: LightFuncType,
@ -392,7 +404,7 @@ pub struct LightFunc
} }
/// A dynamic polygon light. /// A dynamic polygon light.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct Light pub struct Light
{ {
pub ltype: LightType, pub ltype: LightType,
@ -408,7 +420,7 @@ pub struct Light
} }
/// An object in the world. /// An object in the world.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct Object pub struct Object
{ {
pub group: u16, pub group: u16,
@ -423,7 +435,7 @@ pub struct Object
} }
/// The difficulty definition for various object types. /// The difficulty definition for various object types.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct ObjectFreq pub struct ObjectFreq
{ {
pub rnd_loc: bool, pub rnd_loc: bool,
@ -435,7 +447,7 @@ pub struct ObjectFreq
} }
/// An ambient sound definition. /// An ambient sound definition.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct SoundAmbi pub struct SoundAmbi
{ {
pub index: u16, pub index: u16,
@ -443,7 +455,7 @@ pub struct SoundAmbi
} }
/// A randomly played sound definition. /// A randomly played sound definition.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct SoundRand pub struct SoundRand
{ {
pub no_dir: bool, pub no_dir: bool,
@ -459,7 +471,7 @@ pub struct SoundRand
} }
/// A media, as in a part of a polygon which goes up the middle of the wall. /// A media, as in a part of a polygon which goes up the middle of the wall.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct Media pub struct Media
{ {
pub mtype: MediaType, pub mtype: MediaType,
@ -477,7 +489,7 @@ pub struct Media
} }
/// Extra information for polygons with platforms. /// Extra information for polygons with platforms.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct Platform pub struct Platform
{ {
pub ptype: u16, pub ptype: u16,
@ -490,8 +502,17 @@ pub struct Platform
pub tag: u16, pub tag: u16,
} }
/// Overhead map annotations.
#[derive(Debug, serde::Serialize)]
pub struct Note
{
pub pos: Point,
pub poly: u16,
pub text: String,
}
/// Static map information. /// Static map information.
#[derive(Debug, PartialEq, Serialize)] #[derive(Debug, PartialEq, serde::Serialize)]
pub struct Minf pub struct Minf
{ {
pub env_code: u16, pub env_code: u16,
@ -505,7 +526,7 @@ pub struct Minf
bitflags! { bitflags! {
/// Flags for `Line`. /// Flags for `Line`.
#[derive(Serialize)] #[derive(serde::Serialize)]
pub struct LineFlags: u16 pub struct LineFlags: u16
{ {
const TransSide = 1 << 9; const TransSide = 1 << 9;
@ -519,7 +540,7 @@ bitflags! {
bitflags! { bitflags! {
/// Flags for `Side`. /// Flags for `Side`.
#[derive(Serialize)] #[derive(serde::Serialize)]
pub struct SideFlags: u16 pub struct SideFlags: u16
{ {
const Status = 1; const Status = 1;
@ -535,7 +556,7 @@ bitflags! {
bitflags! { bitflags! {
/// Static environment flags. /// Static environment flags.
#[derive(Serialize)] #[derive(serde::Serialize)]
pub struct EnvFlags: u16 pub struct EnvFlags: u16
{ {
const Vacuum = 1; const Vacuum = 1;
@ -556,7 +577,7 @@ bitflags! {
bitflags! { bitflags! {
/// Static entry point flags. /// Static entry point flags.
#[derive(Serialize)] #[derive(serde::Serialize)]
pub struct EntFlags: u32 pub struct EntFlags: u32
{ {
const Solo = 1; const Solo = 1;
@ -572,7 +593,7 @@ bitflags! {
bitflags! { bitflags! {
/// Static mission flags. /// Static mission flags.
#[derive(Serialize)] #[derive(serde::Serialize)]
pub struct MsnFlags: u16 pub struct MsnFlags: u16
{ {
const Extermination = 1; const Extermination = 1;
@ -585,7 +606,7 @@ bitflags! {
bitflags! { bitflags! {
/// Flags for `Polygon`. /// Flags for `Polygon`.
#[derive(Serialize)] #[derive(serde::Serialize)]
pub struct PolyFlags: u16 pub struct PolyFlags: u16
{ {
const Detached = 1 << 14; const Detached = 1 << 14;
@ -594,7 +615,7 @@ bitflags! {
bitflags! { bitflags! {
/// Flags for `Light`. /// Flags for `Light`.
#[derive(Serialize)] #[derive(serde::Serialize)]
pub struct LightFlags: u16 pub struct LightFlags: u16
{ {
const InitActive = 1; const InitActive = 1;
@ -605,7 +626,7 @@ bitflags! {
bitflags! { bitflags! {
/// Flags for `Object`. /// Flags for `Object`.
#[derive(Serialize)] #[derive(serde::Serialize)]
pub struct ObjectFlags: u16 pub struct ObjectFlags: u16
{ {
const Invisible = 1; const Invisible = 1;
@ -619,7 +640,7 @@ bitflags! {
bitflags! { bitflags! {
/// Flags for `Platform`. /// Flags for `Platform`.
#[derive(Serialize)] #[derive(serde::Serialize)]
pub struct PlatformFlags: u32 pub struct PlatformFlags: u32
{ {
const InitActive = 1; const InitActive = 1;
@ -654,7 +675,7 @@ bitflags! {
c_enum! { c_enum! {
/// The texture type of a `Side`. /// The texture type of a `Side`.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub enum SideType: u16 pub enum SideType: u16
{ {
0 => Full, 0 => Full,
@ -667,7 +688,7 @@ c_enum! {
c_enum! { c_enum! {
/// The action type of a `Polygon`. /// The action type of a `Polygon`.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub enum PolyType: u16 pub enum PolyType: u16
{ {
0 => Normal, 0 => Normal,
@ -694,7 +715,7 @@ c_enum! {
c_enum! { c_enum! {
/// The type of function for a `LightFunc`. /// The type of function for a `LightFunc`.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub enum LightFuncType: u16 pub enum LightFuncType: u16
{ {
0 => Constant, 0 => Constant,
@ -706,7 +727,7 @@ c_enum! {
c_enum! { c_enum! {
/// The type of a `Light`. /// The type of a `Light`.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub enum LightType: u16 pub enum LightType: u16
{ {
0 => Normal, 0 => Normal,
@ -717,7 +738,7 @@ c_enum! {
c_enum! { c_enum! {
/// The liquid type of a `Media`. /// The liquid type of a `Media`.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub enum MediaType: u16 pub enum MediaType: u16
{ {
0 => Water, 0 => Water,

View File

@ -2,7 +2,6 @@
use crate::{durandal::{bin::*, err::*, fixed::*}}; use crate::{durandal::{bin::*, err::*, fixed::*}};
use bitflags::bitflags; use bitflags::bitflags;
use serde::Serialize;
/// Reads a `PXpx` chunk. /// Reads a `PXpx` chunk.
pub fn read_pxpx(b: &[u8]) -> ResultS<(Physics, usize)> pub fn read_pxpx(b: &[u8]) -> ResultS<(Physics, usize)>
@ -284,7 +283,7 @@ fn read_attack(b: &[u8]) -> ResultS<Attack>
} }
/// Static physics information. /// Static physics information.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct Physics pub struct Physics
{ {
pub acc_ang: Fixed, pub acc_ang: Fixed,
@ -316,7 +315,7 @@ pub struct Physics
} }
/// An effect definition. /// An effect definition.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct Effect pub struct Effect
{ {
pub collection: u16, pub collection: u16,
@ -328,7 +327,7 @@ pub struct Effect
} }
/// A weapon definition. /// A weapon definition.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct Weapon pub struct Weapon
{ {
pub amp_bob: Fixed, pub amp_bob: Fixed,
@ -359,7 +358,7 @@ pub struct Weapon
} }
/// The definition of one of two triggers for a weapon. /// The definition of one of two triggers for a weapon.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct Trigger pub struct Trigger
{ {
pub burst: u16, pub burst: u16,
@ -383,7 +382,7 @@ pub struct Trigger
} }
/// A projectile definition. /// A projectile definition.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct Projectile pub struct Projectile
{ {
pub collection: OptU16, pub collection: OptU16,
@ -406,7 +405,7 @@ pub struct Projectile
} }
/// A monster definition. /// A monster definition.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct Monster pub struct Monster
{ {
pub collection: u16, pub collection: u16,
@ -463,7 +462,7 @@ pub struct Monster
} }
/// A damage definition. /// A damage definition.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct Damage pub struct Damage
{ {
pub dtype: DamageType, pub dtype: DamageType,
@ -474,7 +473,7 @@ pub struct Damage
} }
/// The definition of a monster's attack. /// The definition of a monster's attack.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct Attack pub struct Attack
{ {
pub ptype: OptU16, pub ptype: OptU16,
@ -489,7 +488,7 @@ pub struct Attack
bitflags! { bitflags! {
/// Flags for an effect. /// Flags for an effect.
#[derive(Serialize)] #[derive(serde::Serialize)]
pub struct EffectFlags: u16 pub struct EffectFlags: u16
{ {
const EndOnLoop = 1; const EndOnLoop = 1;
@ -502,7 +501,7 @@ bitflags! {
bitflags! { bitflags! {
/// Flags for a weapon. /// Flags for a weapon.
#[derive(Serialize)] #[derive(serde::Serialize)]
pub struct WeaponFlags: u16 pub struct WeaponFlags: u16
{ {
const Automatic = 1; const Automatic = 1;
@ -521,7 +520,7 @@ bitflags! {
bitflags! { bitflags! {
/// Flags for a projectile. /// Flags for a projectile.
#[derive(Serialize)] #[derive(serde::Serialize)]
pub struct ProjectileFlags: u32 pub struct ProjectileFlags: u32
{ {
const Guided = 1; const Guided = 1;
@ -550,7 +549,7 @@ bitflags! {
bitflags! { bitflags! {
/// Flags for a monster. /// Flags for a monster.
#[derive(Serialize)] #[derive(serde::Serialize)]
pub struct MonsterFlags: u32 pub struct MonsterFlags: u32
{ {
const IgnoreLOS = 1; const IgnoreLOS = 1;
@ -586,7 +585,7 @@ bitflags! {
bitflags! { bitflags! {
/// The composite type of a monster. /// The composite type of a monster.
#[derive(Serialize)] #[derive(serde::Serialize)]
pub struct MonsterClass: u32 pub struct MonsterClass: u32
{ {
const Player = 1; const Player = 1;
@ -610,7 +609,7 @@ bitflags! {
bitflags! { bitflags! {
/// The composite type of damage taken by something. /// The composite type of damage taken by something.
#[derive(Serialize)] #[derive(serde::Serialize)]
pub struct DamageTypeFlags: u32 pub struct DamageTypeFlags: u32
{ {
const Explosion = 1; const Explosion = 1;
@ -642,7 +641,7 @@ bitflags! {
c_enum! { c_enum! {
/// A bullet shell casing emitted by a weapon. /// A bullet shell casing emitted by a weapon.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub enum CasingType: u16 pub enum CasingType: u16
{ {
0 => Rifle, 0 => Rifle,
@ -656,7 +655,7 @@ c_enum! {
c_enum! { c_enum! {
/// The type of functionality a weapon provides. /// The type of functionality a weapon provides.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub enum WeaponType: u16 pub enum WeaponType: u16
{ {
0 => Melee, 0 => Melee,
@ -669,7 +668,7 @@ c_enum! {
c_enum! { c_enum! {
/// A named type of damage taken by something. /// A named type of damage taken by something.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub enum DamageType: u16 pub enum DamageType: u16
{ {
0 => Explosion, 0 => Explosion,

View File

@ -3,7 +3,6 @@
use crate::{durandal::{bin::*, err::*, fixed::*, image::*, text::*}, use crate::{durandal::{bin::*, err::*, fixed::*, image::*, text::*},
marathon::xfer::TransferMode}; marathon::xfer::TransferMode};
use bitflags::bitflags; use bitflags::bitflags;
use serde::Serialize;
/// Reads a color from a color table into `clut`. /// Reads a color from a color table into `clut`.
fn read_color(b: &[u8], clut: &mut [ColorShp]) -> ResultS<()> fn read_color(b: &[u8], clut: &mut [ColorShp]) -> ResultS<()>
@ -312,7 +311,7 @@ impl Color for ColorShp
} }
/// A color in an `ImageShp`'s color table. /// A color in an `ImageShp`'s color table.
#[derive(Clone, Debug, Serialize)] #[derive(Clone, Debug, serde::Serialize)]
pub enum ColorShp pub enum ColorShp
{ {
Translucent, Translucent,
@ -345,7 +344,7 @@ pub struct ImageShp<'a, 'b>
} }
/// A frame, also known as a low level shape. /// A frame, also known as a low level shape.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct Frame pub struct Frame
{ {
flags: FrameFlags, flags: FrameFlags,
@ -360,7 +359,7 @@ pub struct Frame
} }
/// A sequence, also known as a high level shape. /// A sequence, also known as a high level shape.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct Sequence pub struct Sequence
{ {
name: String, name: String,
@ -400,7 +399,7 @@ bitflags! {
bitflags! { bitflags! {
/// Flags for `Frame`. /// Flags for `Frame`.
#[derive(Serialize)] #[derive(serde::Serialize)]
pub struct FrameFlags: u16 pub struct FrameFlags: u16
{ {
const Obscure = 1 << 13; const Obscure = 1 << 13;
@ -411,7 +410,7 @@ bitflags! {
c_enum! { c_enum! {
/// The type of a collection. /// The type of a collection.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub enum CollectionType: u16 pub enum CollectionType: u16
{ {
0 => Unused, 0 => Unused,
@ -424,7 +423,7 @@ c_enum! {
c_enum! { c_enum! {
/// The type of or number of views for a sequence. /// The type of or number of views for a sequence.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub enum ViewType: u16 pub enum ViewType: u16
{ {
1 => Anim, 1 => Anim,

View File

@ -2,7 +2,6 @@
use crate::durandal::{bin::*, err::*, fixed::*, sound::*}; use crate::durandal::{bin::*, err::*, fixed::*, sound::*};
use bitflags::bitflags; use bitflags::bitflags;
use serde::Serialize;
use std::collections::BTreeMap; use std::collections::BTreeMap;
/// Reads a sound. /// Reads a sound.
@ -125,7 +124,7 @@ pub fn read_sounds(b: &[u8]) -> ResultS<Vec<SoundTable>>
} }
/// The header of a sound definition. /// The header of a sound definition.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct SoundHead pub struct SoundHead
{ {
pub volume: Volume, pub volume: Volume,
@ -147,7 +146,7 @@ pub type SoundTable = BTreeMap<u16, SoundDef>;
bitflags! { bitflags! {
/// Flags for `SoundHead`. /// Flags for `SoundHead`.
#[derive(Serialize)] #[derive(serde::Serialize)]
pub struct SoundFlags: u16 pub struct SoundFlags: u16
{ {
const NoRestart = 1; const NoRestart = 1;
@ -162,7 +161,7 @@ bitflags! {
c_enum! { c_enum! {
/// The type of volume this sound has. /// The type of volume this sound has.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub enum Volume: u16 pub enum Volume: u16
{ {
0 => Quiet, 0 => Quiet,

View File

@ -2,7 +2,6 @@
use crate::durandal::{err::*, text::*}; use crate::durandal::{err::*, text::*};
use bitflags::bitflags; use bitflags::bitflags;
use serde::Serialize;
use std::fmt; use std::fmt;
/// Reads a `Group`. /// Reads a `Group`.
@ -82,7 +81,7 @@ pub fn read_term(b: &[u8]) -> ResultS<(Terminal, usize)>
} }
/// A terminal definition, with collections of groups and faces. /// A terminal definition, with collections of groups and faces.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct Terminal pub struct Terminal
{ {
lines: u16, lines: u16,
@ -91,7 +90,7 @@ pub struct Terminal
} }
/// A text face. /// A text face.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct Face pub struct Face
{ {
start: usize, start: usize,
@ -100,7 +99,7 @@ pub struct Face
} }
/// A terminal command grouping. /// A terminal command grouping.
#[derive(Serialize)] #[derive(serde::Serialize)]
pub struct Group pub struct Group
{ {
flags: GroupFlags, flags: GroupFlags,
@ -112,7 +111,7 @@ pub struct Group
bitflags! { bitflags! {
/// Flags for `Group`. /// Flags for `Group`.
#[derive(Serialize)] #[derive(serde::Serialize)]
pub struct GroupFlags: u16 pub struct GroupFlags: u16
{ {
const DrawOnRight = 1; const DrawOnRight = 1;
@ -122,7 +121,7 @@ bitflags! {
c_enum! { c_enum! {
/// The command of a `Group`. /// The command of a `Group`.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub enum GroupType: u16 pub enum GroupType: u16
{ {
0 => Logon, 0 => Logon,

View File

@ -2,7 +2,6 @@
use crate::durandal::{bin::*, err::*, image, text::mac_roman_conv}; use crate::durandal::{bin::*, err::*, image, text::mac_roman_conv};
use crate::marathon::{map, phy, pict, trm}; use crate::marathon::{map, phy, pict, trm};
use serde::Serialize;
use std::collections::BTreeMap; use std::collections::BTreeMap;
/// Reads all chunks in an entry. /// Reads all chunks in an entry.
@ -37,6 +36,7 @@ pub fn read_chunks(b: &[u8], siz_cnk: usize) -> ResultS<Vec<Chunk>>
b"bonk" => Chunk::Bonk(rd_array(data, map::read_bonk)?), b"bonk" => Chunk::Bonk(rd_array(data, map::read_bonk)?),
b"medi" => Chunk::Medi(rd_array(data, map::read_medi)?), b"medi" => Chunk::Medi(rd_array(data, map::read_medi)?),
b"plat" => Chunk::Plat(rd_array(data, map::read_plat)?), b"plat" => Chunk::Plat(rd_array(data, map::read_plat)?),
b"NOTE" => Chunk::Note(rd_array(data, map::read_note)?),
b"term" => Chunk::Term(rd_array(data, trm::read_term)?), b"term" => Chunk::Term(rd_array(data, trm::read_term)?),
b"FXpx" => Chunk::Fxpx(rd_array(data, phy::read_fxpx)?), b"FXpx" => Chunk::Fxpx(rd_array(data, phy::read_fxpx)?),
b"MNpx" => Chunk::Mnpx(rd_array(data, phy::read_mnpx)?), b"MNpx" => Chunk::Mnpx(rd_array(data, phy::read_mnpx)?),
@ -129,7 +129,7 @@ pub fn read_wad(b: &[u8]) -> ResultS<Wad>
} }
/// Any kind of chunk in an `Entry`. /// Any kind of chunk in an `Entry`.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub enum Chunk pub enum Chunk
{ {
Pict(image::Image8), Pict(image::Image8),
@ -145,6 +145,7 @@ pub enum Chunk
Bonk(Vec<map::SoundRand>), Bonk(Vec<map::SoundRand>),
Medi(Vec<map::Media>), Medi(Vec<map::Media>),
Plat(Vec<map::Platform>), Plat(Vec<map::Platform>),
Note(Vec<map::Note>),
Term(Vec<trm::Terminal>), Term(Vec<trm::Terminal>),
Fxpx(Vec<phy::Effect>), Fxpx(Vec<phy::Effect>),
Mnpx(Vec<phy::Monster>), Mnpx(Vec<phy::Monster>),
@ -155,7 +156,7 @@ pub enum Chunk
} }
/// An entry containing chunks and application-specific data. /// An entry containing chunks and application-specific data.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct Entry pub struct Entry
{ {
pub chunks: Vec<Chunk>, pub chunks: Vec<Chunk>,
@ -163,7 +164,7 @@ pub struct Entry
} }
/// The header of a `Wad`. /// The header of a `Wad`.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct WadHeader pub struct WadHeader
{ {
pub ver_wad: Ver, pub ver_wad: Ver,
@ -173,7 +174,7 @@ pub struct WadHeader
} }
/// A Map file containing entries. /// A Map file containing entries.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub struct Wad pub struct Wad
{ {
pub head: WadHeader, pub head: WadHeader,
@ -182,7 +183,7 @@ pub struct Wad
c_enum! { c_enum! {
/// The version of a `Wad`. /// The version of a `Wad`.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub enum Ver: u16 pub enum Ver: u16
{ {
0 => Base, 0 => Base,

View File

@ -1,11 +1,10 @@
//! Transfer Mode type. //! Transfer Mode type.
use crate::durandal::err::*; use crate::durandal::err::*;
use serde::Serialize;
c_enum! { c_enum! {
/// A rendering style for many things. /// A rendering style for many things.
#[derive(Debug, Serialize)] #[derive(Debug, serde::Serialize)]
pub enum TransferMode: u16 pub enum TransferMode: u16
{ {
0 => Normal, 0 => Normal,