gemot encubed  

Go Back   gemot encubed > Gemot > Technical Issues

Technical Issues For bug reports, problem solving, and help running Japanese software.

Reply
 
Thread Tools Display Modes
  #1  
Old 2007-09-11, 01:42
Chu Chu is offline
Member
 
Join Date: Sep 2007
Posts: 13
Default Ripping data from .afs format

There's a game I'm trying to extract data from (audio, CGs, script, the works) but they're all packed in .afs, which I don't know anything about. I tried AFS extract but all of the CGs are in .cel format, so I can't view them. Is there a better program, or a way to convert the images to a viewable format?
Reply With Quote
  #2  
Old 2007-09-11, 01:56
Asceai's Avatar
Asceai Asceai is offline
Posts way too much
 
Join Date: Mar 2007
Posts: 1,413
Default

I've never even heard of that one before. Throw a .cel or two this way. (and a PNG of the image as a screenshot, if you can guess which one it is from the scripts you extracted or something)
Reply With Quote
  #3  
Old 2007-09-11, 02:01
Chu Chu is offline
Member
 
Join Date: Sep 2007
Posts: 13
Default

I have absolutely no clue which images are which ^^; So there's some guess work involved.

http://www.u-chan.org/spare/C11B2M2.cel
Reply With Quote
  #4  
Old 2007-09-11, 20:38
Minagi's Avatar
Minagi Minagi is offline
Regular
 
Join Date: Jun 2007
Posts: 85
Default

I think that might be an animation file and not CG. What other files are in the game?

Quick look at it and it's:

Header (0xf0 bytes, don't care enough to figure out what everything means)
I'm going to guess 0xC is the amount of files in the cel file, but I can't tell from just one file.


IMAG block, 32 bytes:
IMAG 4 byte
End of LZ file 4(maybe 8?) bytes
(24 bytes I don't feel like figuring out)

LZSS File:
LZ 2 bytes
Uncompressed file size 4(6?) bytes
Size of file without header 2(4?) bytes
LZSS data

Something like that.

Last edited by Minagi; 2007-09-11 at 20:50.
Reply With Quote
  #5  
Old 2007-09-11, 22:43
zalas zalas is offline
 
 
Join Date: Feb 2004
Location: fushigi misuterii
Posts: 1,831
Send a message via ICQ to zalas
Default

Upon quick glance, I think that DWORD after the chunk name doesn't necessarily mean the end of the LZ chunk. I think it's a generic chunk length thing, and it points to the next chunk in the list of chunks. Why they chose to do it that way instead of length beats me. Maybe they intended to load the entire thing into memory...

As for the first header, it has 0100 0300 0200 0800. Not sure about the 0100, but the 0300, 0200 and 0800 probably refer to the number of ENTR, ANIM and IMAG chunks, respectively. The DWORD at offset 0x10 looks like the size of the file and the DWORD following might be the size of the file after decompression of all the chunks? It could also be a CRC32, but who knows...

EDIT: It's probably more likely the CRC32, since the files don't really expand to something that large. I find it funny how the LZ chunks are stored in bigendian format while the rest of the file is in little endian.
__________________
~Yoda is waiting in the air~ | HAVEN

Last edited by zalas; 2007-09-11 at 22:46.
Reply With Quote
  #6  
Old 2007-09-12, 04:04
Asceai's Avatar
Asceai Asceai is offline
Posts way too much
 
Join Date: Mar 2007
Posts: 1,413
Default

Post more files. As a general rule, full-screen CG is often ~1mb or so, depending on the resolution. These .CEL files seem to be tiny on-screen animations, like what haruoto and ef use.
Reply With Quote
  #7  
Old 2007-09-12, 10:46
Chu Chu is offline
Member
 
Join Date: Sep 2007
Posts: 13
Default

It looks like it packed animations and CGs all in the same .afs, so I just picked out the largest one and uploaded it.

http://www.u-chan.org/spare/EV083_1.cel (assuming this one is an event CG)
http://www.u-chan.org/spare/BG002_1.cel (assuming this one is a background CG)
Reply With Quote
  #8  
Old 2007-09-12, 11:23
Minagi's Avatar
Minagi Minagi is offline
Regular
 
Join Date: Jun 2007
Posts: 85
Default

It looks like this now:

IMAG block
IMAG 4 bytes
Start of next chunk/end of current chunk (it's still there even with 1 file) 4 bytes
Null 4 bytes
Height 2 bytes
Width 2 bytes
? 12 bytes
Size of file 4 bytes

(When LZ is present)
LZ header
LZ 2 bytes
4 bytes big endian decompressed file size (probably wouldn't have noticed it was in big endian so thanks zalas :3)
4 bytes big endian compressed file size
LZ Data (Maybe it's not standard? It looks messed up after decompression)

Messing around with the uncompressed file in InfranView, I was able to come up with this from BG002_1.cel with the settings 640x480 32 BPP BGR Interleaved:


From EV083_1.cel (doesn't use an LZ file, it's a straight up raw image). Same settings as BG002_1.cel except it's 640x960:

Last edited by Minagi; 2007-09-12 at 11:33.
Reply With Quote
  #9  
Old 2007-09-12, 12:50
Chu Chu is offline
Member
 
Join Date: Sep 2007
Posts: 13
Default

How exactly did you get them like that? I downloaded the program but I just get errors when I try to open them.

Er. Also, is there possibly an easier way to do that? ^^;; because I have like...six hundred of these buggers.

Last edited by Chu; 2007-09-12 at 12:54.
Reply With Quote
  #10  
Old 2007-09-12, 14:33
Minagi's Avatar
Minagi Minagi is offline
Regular
 
Join Date: Jun 2007
Posts: 85
Default

Try this: http://www.sendspace.com/file/ci8513

It'll extract both LZ and raw files from .cel files.

Code:
Usage: cel.exe [flag] (files)

flags:
x - extract
d - decompress (only works on LZ files)
You can use a wildcard to open the files, so cel.exe x *.cel and then cel.exe d *.lz would work best for processing a lot of files. A small note though, things that use the LZ compression might come out a little funny. I used the standard LZ code (besides a small part I added in to skip the header) but I think they might've changed things up in their compression.

What game is this for anyway?

Last edited by Minagi; 2007-09-12 at 14:52.
Reply With Quote
  #11  
Old 2007-09-12, 15:35
Chu Chu is offline
Member
 
Join Date: Sep 2007
Posts: 13
Default

I'm not exactly sure how to use this program... When I give it a cel, it says 'could not open'.

The game is Akai Ito. Technically the event CGs have already been ripped, I'm mostly trying to get at the character images.

Last edited by Chu; 2007-09-12 at 15:42.
Reply With Quote
  #12  
Old 2007-09-12, 16:38
zalas zalas is offline
 
 
Join Date: Feb 2004
Location: fushigi misuterii
Posts: 1,831
Send a message via ICQ to zalas
Default

Hahah, amusingly enough the first time I saw AFS was in Akai Ito. Still haven't fully figured out how to re-encrypt the data files so that the trial version would run the full version files. If that were finished, then an Akai Ito translation that would run on PC wouldn't be out of the question <_<;

I guess if I have time I could dig around the PC executable to find the LZ decompression code. Though, I really should get more work done on my image code for Python so that I can write plugins for various game formats in it and have it be able to export/import TIFF files or something -_-;
__________________
~Yoda is waiting in the air~ | HAVEN

Last edited by zalas; 2007-09-12 at 16:40.
Reply With Quote
  #13  
Old 2007-09-12, 17:07
Chu Chu is offline
Member
 
Join Date: Sep 2007
Posts: 13
Default

Quote:
Originally Posted by zalas View Post
Hahah, amusingly enough the first time I saw AFS was in Akai Ito. Still haven't fully figured out how to re-encrypt the data files so that the trial version would run the full version files. If that were finished, then an Akai Ito translation that would run on PC wouldn't be out of the question <_<;
Ahaha, that was *exactly* what I was going to try and do! Since someone is already translating it (and finished two character routes) I thought that if I could figure out how to run it on the PC I could edit the script.
Reply With Quote
  #14  
Old 2007-09-12, 18:47
Minagi's Avatar
Minagi Minagi is offline
Regular
 
Join Date: Jun 2007
Posts: 85
Default

Quote:
Originally Posted by Chu View Post
I'm not exactly sure how to use this program... When I give it a cel, it says 'could not open'.

The game is Akai Ito. Technically the event CGs have already been ripped, I'm mostly trying to get at the character images.
Throw the exe in the same folder as the .cel files. That's how I always ran it.
Reply With Quote
  #15  
Old 2007-09-12, 19:12
zalas zalas is offline
 
 
Join Date: Feb 2004
Location: fushigi misuterii
Posts: 1,831
Send a message via ICQ to zalas
Default


for the first image in C11B2M2.

That image is an index-color image. The first four bytes are 00 01 00 00. The next 1024 bytes are BGRA tuples, each 1 byte each, for the palette entries. The rest is the image data, 1 byte per pixel. The image I posted does not have the color-palette on and is just using a default grayscale mapping.



BGRA ordering

Basically the LZ algorithm is as follows, as far as I know:

[L][Z][decompressed size:DWORD(BE)][compressed size:DWORD(BE)]

The LZSS implementation uses a 0x400(1024) byte window, with the starting offset at 0x3EE into the window (where the first lookback data will be written).

Flag bytes are used to denote lookback(bit=0) or verbatim(bit=1). Bits are read from LSB in the flag byte.

For verbatim, one byte is copied and placed into window

For lookback, two bytes are read. Let's say the two bytes are byte0 and byte1. The start of the read-back from the window is at offset ((byte1&0xf0) << 4) | byte0. The length of the read-back is (byte1 & 0xf)+3.

Hope this helps.

EDIT: So what's this about a translation already done for 2 routes? The ROFS CVM format is kind of annoying for Akaiito in particular because it uses a scrambled form. roxfan figured out the descrambling needed, but I still don't know exactly what fields correspond to what in the CVM and have been too busy to sit down and figure it out. Akaiito's code is massively painful to go through, since it uses lots of optimizations -_-;
__________________
~Yoda is waiting in the air~ | HAVEN

Last edited by zalas; 2007-09-12 at 19:48. Reason: color order fixed
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
AFS format (DC/PS2 stuff) Minagi Technical Issues 3 2014-03-24 19:19
Ripping Audio from CD Inexperienced Gaijin Technical Issues 0 2011-12-30 15:55
VN soundtrack ripping Unregistered Technical Issues 1 2010-06-18 02:32
Ripping Game Data AireTamStorm Technical Issues 4 2008-08-07 12:21
Ripping Clannad's music from the DVD? K Technical Issues 5 2004-08-07 08:26


All times are GMT -8. The time now is 22:14.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2023, vBulletin Solutions, Inc.