Add new test code
parent
445eb15729
commit
55195368e2
72
src/main.rs
72
src/main.rs
|
@ -1,47 +1,51 @@
|
||||||
extern crate memmap;
|
extern crate memmap;
|
||||||
|
extern crate generic_array;
|
||||||
|
|
||||||
pub mod durandal;
|
pub mod durandal;
|
||||||
pub mod marathon;
|
pub mod marathon;
|
||||||
|
|
||||||
use std::{io, fs};
|
use std::{io, fs, env};
|
||||||
|
use std::io::Write;
|
||||||
|
|
||||||
use memmap::Mmap;
|
use memmap::Mmap;
|
||||||
|
|
||||||
|
use marathon::wad;
|
||||||
|
use durandal::pict::load_pict;
|
||||||
|
|
||||||
fn main() -> io::Result<()>
|
fn main() -> io::Result<()>
|
||||||
{
|
{
|
||||||
let fp = fs::File::open("data/Rubicon Map.sceA")?;
|
let arg = env::args().nth(1).expect("need at least 1 argument");
|
||||||
let mm = unsafe{Mmap::map(&fp)?};
|
let fp = fs::File::open(arg)?;
|
||||||
println!("{:?}", marathon::wad::Wad::new(&mm));
|
let mm = unsafe{Mmap::map(&fp)?};
|
||||||
|
let wad = wad::Wad::new(&mm);
|
||||||
|
|
||||||
|
println!("{:?}", wad);
|
||||||
|
|
||||||
|
for (id, ent) in wad.ent
|
||||||
|
{
|
||||||
|
if let Some(c) = ent.map.get(b"PICT")
|
||||||
|
{
|
||||||
|
let im = load_pict(c);
|
||||||
|
match im {
|
||||||
|
Ok(im) => {
|
||||||
|
let out = fs::File::create(format!("out_{}.ppm", id))?;
|
||||||
|
let mut out = io::BufWriter::new(out);
|
||||||
|
println!("entry {} has PICT {}x{}", id, im.w(), im.h());
|
||||||
|
write!(&mut out, "P3\n{} {}\n255\n", im.w(), im.h())?;
|
||||||
|
for y in 0..im.h() {
|
||||||
|
for x in 0..im.w()
|
||||||
|
{
|
||||||
|
let cr = &im[(x, y)];
|
||||||
|
write!(&mut out, "{} {} {} ", cr.r, cr.g, cr.b)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(e) => println!("entry {} has PICT (invalid: {:?})", id, e),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
extern crate gtk;
|
|
||||||
use gtk::prelude::*;
|
|
||||||
use gtk::{Button, Window, WindowType};
|
|
||||||
|
|
||||||
fn main()
|
|
||||||
{
|
|
||||||
if gtk::init().is_err() {
|
|
||||||
println!("failed to initialize GTK");
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
let win = Window::new(WindowType::Toplevel);
|
|
||||||
win.set_title("GTK test");
|
|
||||||
win.set_default_size(350, 70);
|
|
||||||
let btn = Button::new_with_label("butts");
|
|
||||||
win.add(&btn);
|
|
||||||
win.show_all();
|
|
||||||
|
|
||||||
win.connect_delete_event(|_, _| {
|
|
||||||
gtk::main_quit();
|
|
||||||
Inhibit(false)
|
|
||||||
});
|
|
||||||
|
|
||||||
btn.connect_clicked(|_| {println!("clicc");});
|
|
||||||
|
|
||||||
gtk::main();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
|
Loading…
Reference in New Issue