Compare commits

...

3 Commits

Author SHA1 Message Date
an 2fd48d53a2 code cleanup 2019-02-16 12:07:28 -05:00
an 5dddf61119 add new documentation 2019-02-16 12:06:53 -05:00
an 04f6ad0bdb make dump_chunk better 2019-02-14 00:52:07 -05:00
6 changed files with 904 additions and 652 deletions

File diff suppressed because it is too large Load Diff

View File

@ -28,7 +28,7 @@ pub fn crc32(b: &[u8], s: u32) -> u32
#[test]
fn crc32_lorem_ipsum()
{
assert_eq!(crc32(b"Lorem ipsum dolor sit amet", !0), 0x5F29D461);
assert_eq!(crc32(b"Lorem ipsum dolor sit amet", !0), 0x5F29_D461);
}
// EOF

View File

@ -33,48 +33,24 @@ fn dump_chunk(opt: &Options, cid: Ident, cnk: &[u8], eid: u16) -> ResultS<()>
return Ok(());
}
match &cid {
b"PICT" => {
if opt.wad_chunks.contains(&cid) {
if opt.wad_chunks.contains(&cid) {
match &cid {
b"PICT" => {
let im = pict::load_pict(cnk)?;
make_tga(&format!("{}/pict_{}.tga", opt.out_dir, eid), &im)?;
}
b"Minf" => make_yaml(&map::Minf::chunk(cnk)?)?,
b"EPNT" => make_yaml(&map::Endpoint::chunk(cnk)?)?,
b"PNTS" => make_yaml(&map::Point::chunk(cnk)?)?,
b"LINS" => make_yaml(&map::Line::chunk(cnk)?)?,
b"SIDS" => make_yaml(&map::Side::chunk(cnk)?)?,
b"term" => make_yaml(&term::Terminal::chunk(cnk)?)?,
_ => (),
}
b"Minf" => {
if opt.wad_chunks.contains(&cid) {
make_yaml(&map::Minf::chunk(cnk)?)?;
}
}
b"EPNT" => {
if opt.wad_chunks.contains(&cid) {
make_yaml(&map::Endpoint::chunk(cnk)?)?;
}
}
b"PNTS" => {
if opt.wad_chunks.contains(&cid) {
make_yaml(&map::Point::chunk(cnk)?)?;
}
}
b"LINS" => {
if opt.wad_chunks.contains(&cid) {
make_yaml(&map::Line::chunk(cnk)?)?;
}
}
b"SIDS" => {
if opt.wad_chunks.contains(&cid) {
make_yaml(&map::Side::chunk(cnk)?)?;
}
}
b"term" => {
if opt.wad_chunks.contains(&cid) {
make_yaml(&term::Terminal::chunk(cnk)?)?;
}
}
&cid => {
if opt.wad_unknown {
make_chunk(opt, cid, cnk, eid)?;
}
}
}
if opt.wad_unknown {
make_chunk(opt, cid, cnk, eid)?;
}
Ok(())

View File

@ -295,7 +295,7 @@ pub fn get_clut(b: &[u8]) -> ResultS<(Vec<Color8>, usize)>
for i in 0..num {
// with device mapping, we ignore the index entirely
let n = if !dev {c_byte(b, p + 1)? as usize} else {i};
let n = if !dev {c_u16b(b, p)? as usize} else {i};
let r = c_byte(b, p + 2)?;
let g = c_byte(b, p + 4)?;
let b = c_byte(b, p + 6)?;

View File

@ -384,7 +384,7 @@ pub struct Collection
pub type CollectionDef = (Option<Collection>, Option<Collection>);
bitflags! {
pub struct BmpFlags: u16
struct BmpFlags: u16
{
const ColumnMajor = 0x80_00;
const Transparent = 0x40_00;

View File

@ -1,9 +1,11 @@
use crate::durandal::{bin::*, chunk::*, err::*, text::*};
use bitflags::bitflags;
use serde::Serialize;
use std::fmt;
fn read_group(b: &[u8], text: &[u8]) -> ResultS<Group>
{
let flags = c_u16b(b, 0)?;
let ttype = c_u16b(b, 2)?;
let pdata = c_i16b(b, 4)?;
let start = c_u16b(b, 6)? as usize;
@ -11,9 +13,10 @@ fn read_group(b: &[u8], text: &[u8]) -> ResultS<Group>
let lines = c_u16b(b, 10)?;
let text = c_data(text, start..start + size)?;
let text = mac_roman_conv(text);
let flags = ok!(GroupFlags::from_bits(flags), "bad GroupFlags")?;
let ttype = GroupType::from_repr(ttype)?;
Ok(Group{ttype, pdata, lines, text})
Ok(Group{flags, ttype, pdata, lines, text})
}
fn read_face(b: &[u8]) -> ResultS<Face>
@ -98,12 +101,22 @@ pub struct Face
#[derive(Serialize)]
pub struct Group
{
flags: GroupFlags,
ttype: GroupType,
pdata: i16,
lines: u16,
text: String,
}
bitflags! {
#[derive(Serialize)]
pub struct GroupFlags: u16
{
const DrawOnRight = 0x00_01;
const DrawCenter = 0x00_02;
}
}
c_enum! {
#[derive(Debug, Serialize)]
pub enum GroupType: u16