chore(*): cargo fmt
This commit is contained in:
parent
15d438f294
commit
94823a21e3
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
pub mod package;
|
pub mod package;
|
||||||
pub mod package_toc;
|
pub mod package_toc;
|
||||||
pub mod ps2_texture;
|
|
||||||
pub mod ps2_palette;
|
pub mod ps2_palette;
|
||||||
|
pub mod ps2_texture;
|
||||||
|
|
||||||
/// A trait validatable format objects should implement.
|
/// A trait validatable format objects should implement.
|
||||||
/// TODO: integrate this with some FourCC crate, or re-invent the wheel.
|
/// TODO: integrate this with some FourCC crate, or re-invent the wheel.
|
||||||
|
@ -32,6 +32,6 @@ pub fn make_c_string(bytes: &[u8]) -> Option<String> {
|
||||||
|
|
||||||
match std::str::from_utf8(bytes_without_null).ok() {
|
match std::str::from_utf8(bytes_without_null).ok() {
|
||||||
Some(string) => Some(String::from(string)),
|
Some(string) => Some(String::from(string)),
|
||||||
None => None
|
None => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//! Package file format structures
|
//! Package file format structures
|
||||||
|
|
||||||
use crate::lzss::header::LzssHeader;
|
|
||||||
use super::Validatable;
|
use super::Validatable;
|
||||||
|
use crate::lzss::header::LzssHeader;
|
||||||
|
|
||||||
/// "EOF" header. The QuickBMS script uses this to seek to the PGRP entry.
|
/// "EOF" header. The QuickBMS script uses this to seek to the PGRP entry.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
@ -13,7 +13,7 @@ pub struct PackageEofHeader {
|
||||||
pub stringtable_size: u32,
|
pub stringtable_size: u32,
|
||||||
|
|
||||||
/// Start offset of the [PackageGroup] in the package file.
|
/// Start offset of the [PackageGroup] in the package file.
|
||||||
pub header_start_offset: u32
|
pub header_start_offset: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A Package Group. I have no idea what this is yet
|
/// A Package Group. I have no idea what this is yet
|
||||||
|
@ -29,7 +29,7 @@ pub struct PackageGroup {
|
||||||
pub group_file_count: u32,
|
pub group_file_count: u32,
|
||||||
|
|
||||||
/// Padding. Set to a fill of 0xCD.
|
/// Padding. Set to a fill of 0xCD.
|
||||||
pub pad: u32
|
pub pad: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PackageGroup {
|
impl PackageGroup {
|
||||||
|
@ -87,10 +87,9 @@ pub struct PackageFileChunk {
|
||||||
pub file_uncompressed_size: u32,
|
pub file_uncompressed_size: u32,
|
||||||
|
|
||||||
/// LZSS header. Only used if the file chunk is compressed.
|
/// LZSS header. Only used if the file chunk is compressed.
|
||||||
pub lzss_header: LzssHeader
|
pub lzss_header: LzssHeader,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl PackageFileChunk {
|
impl PackageFileChunk {
|
||||||
/// 'PFIL'
|
/// 'PFIL'
|
||||||
pub const VALID_FOURCC: u32 = 0x4C494650;
|
pub const VALID_FOURCC: u32 = 0x4C494650;
|
||||||
|
|
|
@ -17,7 +17,7 @@ pub struct Ps2PaletteHeader {
|
||||||
pub data_start: u32,
|
pub data_start: u32,
|
||||||
pub header_size: u32,
|
pub header_size: u32,
|
||||||
|
|
||||||
pub pad: [u32; 6] // reserved for game code, like .ps2_texture?
|
pub pad: [u32; 6], // reserved for game code, like .ps2_texture?
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Ps2PaletteHeader {
|
impl Ps2PaletteHeader {
|
||||||
|
|
|
@ -65,9 +65,8 @@ impl Crc32Hash {
|
||||||
pub fn update_case_insensitive(&self, data: &[u8]) {
|
pub fn update_case_insensitive(&self, data: &[u8]) {
|
||||||
for b in data.iter() {
|
for b in data.iter() {
|
||||||
let old = self.state.take();
|
let old = self.state.take();
|
||||||
self.state.set(
|
self.state
|
||||||
CRC32_TABLE[((old ^ (*b & !0x20) as u32) & 0xff) as usize] ^ (old >> 8),
|
.set(CRC32_TABLE[((old ^ (*b & !0x20) as u32) & 0xff) as usize] ^ (old >> 8));
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use std::mem::size_of;
|
|
||||||
use crate::format::Validatable;
|
use crate::format::Validatable;
|
||||||
|
use std::mem::size_of;
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
|
|
|
@ -6,4 +6,3 @@
|
||||||
// - if we can't do that, investigate reimplementing compression based on `lzss` crate?
|
// - if we can't do that, investigate reimplementing compression based on `lzss` crate?
|
||||||
|
|
||||||
pub mod header;
|
pub mod header;
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{Seek, SeekFrom};
|
use std::io::{Seek, SeekFrom};
|
||||||
use std::path::{PathBuf};
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use crate::format::{
|
use crate::format::package_toc::*;
|
||||||
package_toc::*
|
|
||||||
};
|
|
||||||
|
|
||||||
use binext::BinaryRead;
|
use binext::BinaryRead;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
|
@ -27,7 +27,7 @@ impl Ps2Rgba {
|
||||||
r: ((value & 0x7C00) >> 7) as u8,
|
r: ((value & 0x7C00) >> 7) as u8,
|
||||||
g: ((value & 0x03E0) >> 2) as u8,
|
g: ((value & 0x03E0) >> 2) as u8,
|
||||||
b: ((value & 0x001F) << 3) as u8,
|
b: ((value & 0x001F) << 3) as u8,
|
||||||
a: 255
|
a: 255,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
//! This program should be run in the root directory
|
//! This program should be run in the root directory
|
||||||
//! of an extracted (from image) copy of the game.
|
//! of an extracted (from image) copy of the game.
|
||||||
|
|
||||||
use std::{fs, path::Path};
|
|
||||||
use jmmt::hash::filename::*;
|
use jmmt::hash::filename::*;
|
||||||
use jmmt::read::package_toc::{read_package_toc};
|
use jmmt::read::package_toc::read_package_toc;
|
||||||
|
use std::{fs, path::Path};
|
||||||
|
|
||||||
// TODO: A mode that will re-name everything back? This wouldn't be too hard to implement
|
// TODO: A mode that will re-name everything back? This wouldn't be too hard to implement
|
||||||
|
|
||||||
|
@ -21,14 +21,22 @@ fn main() {
|
||||||
match read_package_toc(Path::new(package_toc_filename.as_str()).to_path_buf()) {
|
match read_package_toc(Path::new(package_toc_filename.as_str()).to_path_buf()) {
|
||||||
Ok(toc) => {
|
Ok(toc) => {
|
||||||
for toc_entry in toc {
|
for toc_entry in toc {
|
||||||
let dat_src = format!("DATA/{}", dat_filename_from_hash(toc_entry.file_name_hash()));
|
let dat_src = format!(
|
||||||
|
"DATA/{}",
|
||||||
|
dat_filename_from_hash(toc_entry.file_name_hash())
|
||||||
|
);
|
||||||
let src_path = Path::new(dat_src.as_str());
|
let src_path = Path::new(dat_src.as_str());
|
||||||
let dat_clearname = format!("DATA/{}", toc_entry.file_name().expect("How did invalid ASCII get here?"));
|
let dat_clearname = format!(
|
||||||
|
"DATA/{}",
|
||||||
|
toc_entry
|
||||||
|
.file_name()
|
||||||
|
.expect("How did invalid ASCII get here?")
|
||||||
|
);
|
||||||
let dest_path = Path::new(dat_clearname.as_str());
|
let dest_path = Path::new(dat_clearname.as_str());
|
||||||
|
|
||||||
if src_path.exists() {
|
if src_path.exists() {
|
||||||
match fs::rename(src_path, dest_path) {
|
match fs::rename(src_path, dest_path) {
|
||||||
Ok(_) => {},
|
Ok(_) => {}
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
println!("Error renaming {}: {}", src_path.display(), error);
|
println!("Error renaming {}: {}", src_path.display(), error);
|
||||||
return ();
|
return ();
|
||||||
|
@ -38,8 +46,11 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
match fs::rename(Path::new(package_toc_filename.as_str()), Path::new("DATA/package.toc")) {
|
match fs::rename(
|
||||||
Ok(_) => {},
|
Path::new(package_toc_filename.as_str()),
|
||||||
|
Path::new("DATA/package.toc"),
|
||||||
|
) {
|
||||||
|
Ok(_) => {}
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
println!("Error renaming TOC file: {}", error);
|
println!("Error renaming TOC file: {}", error);
|
||||||
return ();
|
return ();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
|
|
||||||
use std::path::Path;
|
|
||||||
use jmmt::read::texture::Ps2TextureReader;
|
use jmmt::read::texture::Ps2TextureReader;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author, version, about, long_about = None)]
|
#[command(author, version, about, long_about = None)]
|
||||||
|
|
Loading…
Reference in New Issue