clean up code
parent
57eee06ba1
commit
fab076be5b
|
@ -374,7 +374,7 @@ main menu, and physics files. Here is a listing of all chunks used within them:
|
|||
| `LITE` | Array of Lights |
|
||||
| `NOTE` | Not analyzed (annotations) |
|
||||
| `OBJS` | Array of Objects |
|
||||
| `påth` | No test data (å is $8C) (guardpaths) |
|
||||
| `påth` | Not analyzed (å is $8C) (guardpaths) |
|
||||
| `Minf` | Static Map Info |
|
||||
| `plac` | Not analyzed (item placement) |
|
||||
| `door` | No test data (extra door data) |
|
||||
|
@ -382,7 +382,7 @@ main menu, and physics files. Here is a listing of all chunks used within them:
|
|||
| `EPNT` | Array of Endpoints |
|
||||
| `medi` | Not analyzed (media) |
|
||||
| `ambi` | Not analyzed (ambient sounds) |
|
||||
| `bonk` | No test data (random sounds) |
|
||||
| `bonk` | Not analyzed (random sounds) |
|
||||
| `term` | Array of Terminals |
|
||||
| `iidx` | Not analyzed (map indices) |
|
||||
| `ShPa` | Not analyzed (shapes) |
|
||||
|
|
20
src/main.rs
20
src/main.rs
|
@ -69,15 +69,29 @@ fn process_wad(b: &[u8]) -> ResultS<()>
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn dump_bitmaps(c: &shp::Collection, i: usize) -> ResultS<()>
|
||||
{
|
||||
for (j, bmp) in c.bmps.iter().enumerate() {
|
||||
for (k, tab) in c.tabs.iter().enumerate() {
|
||||
let fname = format!("out/shape{}_{}_{}.tga", i, j, k);
|
||||
let out = fs::File::create(&fname)?;
|
||||
let mut out = io::BufWriter::new(out);
|
||||
write_tga(&mut out, &shp::ImageShp::new(bmp, &tab))?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn process_shp(b: &[u8]) -> ResultS<()>
|
||||
{
|
||||
for (i, cl) in shp::testfn_replaceme(b)?.iter().enumerate() {
|
||||
for (i, cl) in shp::read_shapes(b)?.iter().enumerate() {
|
||||
if let Some(cl) = &cl.0 {
|
||||
shp::testfn_dump_bitmaps(cl, i)?;
|
||||
dump_bitmaps(cl, i)?;
|
||||
eprintln!("<{} lo> {:#?}\n{:#?}", i, cl.frms, cl.seqs);
|
||||
}
|
||||
if let Some(cl) = &cl.1 {
|
||||
shp::testfn_dump_bitmaps(cl, i + 100)?;
|
||||
dump_bitmaps(cl, i + 100)?;
|
||||
eprintln!("<{} hi> {:#?}\n{:#?}", i, cl.frms, cl.seqs);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -206,23 +206,7 @@ fn collection(b: &[u8]) -> ResultS<Collection>
|
|||
Ok(Collection{ctyp: cl_type, tabs, bmps, frms, seqs})
|
||||
}
|
||||
|
||||
pub fn testfn_dump_bitmaps(c: &Collection, i: usize) -> ResultS<()>
|
||||
{
|
||||
use std::{fs, io};
|
||||
|
||||
for (j, bmp) in c.bmps.iter().enumerate() {
|
||||
for (k, tab) in c.tabs.iter().enumerate() {
|
||||
let fname = format!("out/shape{}_{}_{}.tga", i, j, k);
|
||||
let out = fs::File::create(&fname)?;
|
||||
let mut out = io::BufWriter::new(out);
|
||||
write_tga(&mut out, &ImageShp{bmp, clut: &tab})?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn testfn_replaceme(b: &[u8]) -> ResultS<Vec<CollectionDef>>
|
||||
pub fn read_shapes(b: &[u8]) -> ResultS<Vec<CollectionDef>>
|
||||
{
|
||||
let mut cl = Vec::with_capacity(32);
|
||||
let mut p = 0;
|
||||
|
@ -261,6 +245,14 @@ impl Bitmap
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b> ImageShp<'a, 'b>
|
||||
{
|
||||
pub fn new(bmp: &'a Bitmap, clut: &'b [ColorShp]) -> Self
|
||||
{
|
||||
Self{bmp, clut}
|
||||
}
|
||||
}
|
||||
|
||||
impl Image for ImageShp<'_, '_>
|
||||
{
|
||||
type Output = ColorShp;
|
||||
|
|
Loading…
Reference in New Issue