2019-04-11 21:04:39 -07:00
|
|
|
//! Shapes file frame type.
|
|
|
|
|
2019-06-13 18:09:07 -07:00
|
|
|
use crate::{err::*, fixed::*};
|
2019-04-11 21:04:39 -07:00
|
|
|
|
|
|
|
/// Reads a `Frame`.
|
|
|
|
pub fn read(b: &[u8]) -> ResultS<Frame>
|
|
|
|
{
|
2019-07-05 20:21:11 -07:00
|
|
|
read_data! {
|
|
|
|
endian: BIG, buf: b, size: 36, start: 0, data {
|
|
|
|
let flags = u16[0] flag FrameFlags;
|
|
|
|
let min_lt = Fixed[2];
|
|
|
|
let bmp_ind = u16[6] usize;
|
|
|
|
let wrl_l = Unit[16];
|
|
|
|
let wrl_r = Unit[18];
|
|
|
|
let wrl_t = Unit[20];
|
|
|
|
let wrl_b = Unit[22];
|
|
|
|
let wrl_x = Unit[24];
|
|
|
|
let wrl_y = Unit[26];
|
|
|
|
}
|
|
|
|
}
|
2019-04-11 21:04:39 -07:00
|
|
|
|
2019-07-05 20:21:11 -07:00
|
|
|
Ok(Frame{flags, min_lt, bmp_ind, wrl_l, wrl_r, wrl_t, wrl_b, wrl_x, wrl_y})
|
2019-04-11 21:04:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/// A frame, also known as a low level shape.
|
|
|
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
2019-07-04 14:43:29 -07:00
|
|
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
2019-06-25 03:52:21 -07:00
|
|
|
pub struct Frame {
|
2019-07-05 20:21:11 -07:00
|
|
|
/// The flags for this frame.
|
|
|
|
pub flags: FrameFlags,
|
2019-04-11 21:04:39 -07:00
|
|
|
|
2019-07-05 20:21:11 -07:00
|
|
|
/// The minimum light level for this frame.
|
|
|
|
pub min_lt: Fixed,
|
2019-04-11 21:04:39 -07:00
|
|
|
|
2019-07-05 20:21:11 -07:00
|
|
|
/// The index of the bitmap this frame uses.
|
|
|
|
pub bmp_ind: usize,
|
2019-04-11 21:04:39 -07:00
|
|
|
|
2019-07-05 20:21:11 -07:00
|
|
|
/// The left translation for this frame.
|
|
|
|
pub wrl_l: Unit,
|
2019-04-11 21:04:39 -07:00
|
|
|
|
2019-07-05 20:21:11 -07:00
|
|
|
/// The right translation for this frame.
|
|
|
|
pub wrl_r: Unit,
|
2019-04-11 21:04:39 -07:00
|
|
|
|
2019-07-05 20:21:11 -07:00
|
|
|
/// The top translation for this frame.
|
|
|
|
pub wrl_t: Unit,
|
2019-04-11 21:04:39 -07:00
|
|
|
|
2019-07-05 20:21:11 -07:00
|
|
|
/// The bottom translation for this frame.
|
|
|
|
pub wrl_b: Unit,
|
2019-04-11 21:04:39 -07:00
|
|
|
|
2019-07-05 20:21:11 -07:00
|
|
|
/// The X translation for this frame.
|
|
|
|
pub wrl_x: Unit,
|
2019-04-11 21:04:39 -07:00
|
|
|
|
2019-07-05 20:21:11 -07:00
|
|
|
/// The Y translation for this frame.
|
|
|
|
pub wrl_y: Unit,
|
2019-04-11 21:04:39 -07:00
|
|
|
}
|
|
|
|
|
2019-07-02 21:34:14 -07:00
|
|
|
c_bitfield! {
|
2019-07-05 20:21:11 -07:00
|
|
|
/// Flags for `Frame`.
|
|
|
|
#[cfg_attr(feature = "serde_obj", derive(serde::Serialize))]
|
|
|
|
pub struct FrameFlags: u16 {
|
|
|
|
/// The player's torso will obscure the player's legs.
|
|
|
|
OBSCURE = 13,
|
|
|
|
/// The bitmap will be flipped on the vertical axis.
|
|
|
|
FLIP_Y = 14,
|
|
|
|
/// The bitmap will be flipped on the horizontal axis.
|
|
|
|
FLIP_X = 15,
|
|
|
|
}
|
2019-04-11 21:04:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// EOF
|