
有同事向我提出想了解「Street Fighter IV Volt」的製作方法;於是我嘗試解開內裡的圖檔,發現跟「THE KING OF FIGHTERS-i」一樣使用了很多 obm 格式的檔案。我不知道 obm 是不是某遊戲引擎的格式。我為「THE KING OF FIGHTERS-i」編寫了一個工具,能把 obm 轉換為 PNG 檔案,用在「Street Fighter IV Volt」一樣沒有問題,肯定了兩個遊戲的 obm 格式是一樣。
obm 還會分至少三個格式,以 2-3 Bytes 來分辨。其中一個格式在圖寬及圖闊數據後,是 512 Bytes 的色盤數據,往後的才是像素數據。以下是目前為止的代碼:
NSString *directory = [[NSBundle mainBundle] bundlePath];
NSArray *array = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:directory error:nil];
for (NSString *filename in array) {
NSString *fileExtension = [[filename pathExtension] lowercaseString];
if ([fileExtension isEqualToString:@"obm"] == NO) {continue;}
string = [directory stringByAppendingPathComponent:filename];
NSData *data = [NSData dataWithContentsOfFile:string];
unsigned char *dataBuffer = (unsigned char *)[data bytes];
unsigned short *headerInfo = (unsigned short *)(dataBuffer);
unsigned short *palette = (unsigned short *)(dataBuffer+8);
int width = headerInfo[2];
int height = headerInfo[3];
unsigned char *imageBuffer = (unsigned char *)malloc((width*height)<<2);
int imageType = headerInfo[1];
switch (imageType) {
case 0x0801:
case 0x0804: {
int sourceOffset = 8+512;
int targetOffset = 0;
for (int y=0; y<height; y++) {
for (int x=0; x<width; x++) {
unsigned char pixelByte = dataBuffer[sourceOffset];
unsigned short paletteValue = palette[pixelByte];
int alpha = (paletteValue&0x0001)<<7;
int blue = (paletteValue&0x003e)<<2;
int green = (paletteValue&0x07c0)>>3;
int red = (paletteValue&0xf800)>>8;
if (alpha != 0) {alpha = 255;}
// 0 = Blue
// 1 = Green
// 2 = Red
// 3 = Alpha
imageBuffer[targetOffset+0] = blue;
imageBuffer[targetOffset+1] = green;
imageBuffer[targetOffset+2] = red;
imageBuffer[targetOffset+3] = alpha;
targetOffset += 4;
sourceOffset++;
}
}
} break;
case 0x2001: {
memcpy(imageBuffer, palette, (width*height)<<2);
for (int i=0; i<(width*height)<<2; i+=4) {
unsigned char red = imageBuffer[i+0];
imageBuffer[i+0] = imageBuffer[i+2];
imageBuffer[i+2] = red;
}
} break;
}
image = [MainViewController raw2UIImage:imageBuffer width:width height:height];
[currentImageView setImage:image];
[currentImageView setFrame:CGRectMake(0, 0, width, height)];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
string = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png", filename]];
[UIImagePNGRepresentation(image) writeToFile:string atomically:YES];
}

6 則留言:
Can you extract the cut-scene images of the iPhone version of Double Dragon? I can't get them to show up in color.
I can extract most of images. What do you mean "cut-scene"?
You can refer to my new post (http://pacess.blogspot.com/2012/02/raw2uiimage-uiimage-raw2uiimageunsigned.html) for making a obm decoder.
Sorry. By "cut-scenes", I meant the obm files that are used for the story scenes in Double Dragon for the iPhone. Their file names all begin with the tag "avg" (i.e. avg_billy.obm, avg_marian.obm, avg_jimmy.obm, ect.)
http://dl.dropbox.com/u/26103827/DoubleDragonOBM.zip
Thanks!
我也對這個遊戲的obm格式做了一个分析,链接http://blog.sina.com.cn/s/blog_8a230ccd010118lw.html
只是“1009”這種格式的文件不知怎麼處理。
在KOF i 2012里是mstage開頭的。
我推測應該是和stage開頭的同名文件配套使用的。
每個像素用4bits來表示數據,可是這種格式沒有調色板。我實在想不出來改怎麼解開,又不太會用IDA來調試,所以想請教一下您。謝謝!
張貼留言