Skip to content

Commit 99b0b37

Browse files
committed
fix bip tiling
1 parent 53cdfbe commit 99b0b37

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,19 @@ This is an attempt to collect code to decode all file formats in the Infinity se
88
Kidfile is a library that can be used by other projects to handle supported files easily.
99
Kidfile Explorer is an application that can navigate, preview and convert those files in batch.
1010

11-
Currently supports all images from Never7 on PS2 and most images from 12Riven on PC. Lots of other formats used in the other games and releases are missing, but it's not hard to add support for each.
11+
Currently supports images in most of the PS2 games and their late PSP and PC ports.
1212

13-
- Archive formats:
14-
- AFS
15-
- LNK
16-
- Concatenated files aligned to 2KiB
17-
- Compression formats:
18-
- LZSS/BIP
19-
- CPS (PS2)
2013
- Image formats:
2114
- OGDT
2215
- TIM2
23-
- KLZ
16+
- BIP (all)
17+
- GIM (PSP)
18+
- KLZ (PC)
2419
- common formats (PNG, BMP, etc)
20+
- Archive formats:
21+
- AFS
22+
- LNK (partial)
23+
- Concatenated OGDT/TIM2 images
24+
- Compression formats:
25+
- LZSS
26+
- CPS (PS2)

kidfile/src/data_formats/cps.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ pub const ENTRY_CPS: Decoder<Box<[u8]>> = Decoder {
1111

1212
fn decode(data: &mut FileData) -> Result<Box<[u8]>, String> {
1313
let expected_size = data.get_u32_at_be(0).unwrap() as usize >> 8;
14-
println!("cps expecting size {expected_size}, file size is {}", data.len());
1514

1615
let buf = &data.read()[3..];
1716
let mut in_cursor = 0;

kidfile/src/image_formats/bip.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub const ENTRY_BIP: Decoder<Image> = Decoder {
3636
let palette = &bytes[palette_section..];
3737
//let tile_pixel_data = pixel_section; // + bytes.read_u16(index_section + 2)? as usize * 1024;
3838
let frame = cur_frame.get_or_insert_with(|| Frame::empty(og_full_width, og_full_height, PixelFormat::RgbaClut8));
39-
// this part is SUPER quirky. the source image is split into 30x30 blocks, but the last 2 rows and columns are
39+
// this part is SUPER quirky. the source image is split into 30x30 blocks, but the first and last rows and columns are
4040
// repeated so the blocks grow to 32x32. however, the blocks aren't stored sequentially, but rather as an image
4141
// with its width forced to 512. if the real width is 512, it can be directly read as an image but the
4242
// repeated pixels in the blocks will be visible. if it's not 512 the rows of blocks wrap and that breaks.
@@ -50,12 +50,8 @@ pub const ENTRY_BIP: Decoder<Image> = Decoder {
5050
if src_block_start + 30 >= bytes.len() {
5151
break;
5252
}
53-
let row = Frame::from_rgba_clut8(30, 1, palette, &bytes[src_block_start..]);
54-
if false {
55-
frame.paste(dst_block_x_idx * 30 + dst_block_y_idx * tile_x_blocks * 30, dst_y - dst_y_start + tile_idx as u32 * 30, &row); // TODO: revert
56-
} else {
57-
frame.paste(tile_x + dst_block_x_idx * 30, dst_y, &row);
58-
}
53+
let row = Frame::from_rgba_clut8(30, 1, palette, &bytes[src_block_start + 1..]);
54+
frame.paste(tile_x + dst_block_x_idx * 30, dst_y, &row);
5955
src_block_start += 512;
6056
}
6157
src_block_x_idx += 1;

0 commit comments

Comments
 (0)