#Rayearth BIN Files
94 messages ยท Page 1 of 1 (latest)
Just by skimming it looks like multiple instances of probably indexed images
Took a quick look in TiledGGD and found this
It seems like there's some misc data at the front (probably something that points to each image), and then all the images back to back with 256 16-bit colours as a palette, followed by the pixel data
If you send me another file that should contain images I can maybe take a closer look later this week and whip up something that can extract them automatically
This might also have images.
Nah, it just has text. You'll probably want files that are at least 50kb, especially now that we know the format it'd be tough to fit images into anything less (the above images are about 27kb each)
How about this one?
Looks more promising, although the format is quite distinct from the first one
Hmm, not finding much unfortunately.
Oh yup that one works
So I'll take a closer look and try figure out the rest of the header when I have time this week
Awesome; thanks!
Oh awesome.
I'm trying to load it in TiledGGD (PE) now, but I'm not seeing what you guys are getting.
You'll want to set Image > Format to 8 Bit per pixel
Press the right arrow key until the panel size has a width of 168
Press the down arrow key a couple of times just to see more
Press the End key until the palette offset is 0x50
Press/hold the Page Down key until the image offset is 0x250
That will display the first image perfectly, the rest of them have different palette and image offsets
But it seems predictable enough that coding something for it shouldn't be hard
TiledGGD is dumb and the way to do it is to change how much Page Down shifts the offset by
Go to Image > Skip Size and pick 1 Tile Row
Then you can scroll down by holding down Page Down
And Page Up to scroll up
I would love to make an easier to use version of TiledGGD someday but I don't know if it'll ever make it high enough on my priority list
I've got a tool I made for the CD-i but it only works with specific palette formats and image formats at the moment, no tiling either, it can view these images okay because they're what I'd call Clut images on the cd-i, but not the palettes atm because cd-i used rgb24, this is some of the "sprites" in the players.bin but obviously the colours and sprite separation are knackered lol
Palette is hiding well but if I use my default palette I get that for one of the "sprite" images seems to be 16x24 px
This is what I used for charface
var imageFile = @"C:\Dev\Projects\Gaming\VGR\CHARFACE.BIN";
var outputFolder = @"C:\Dev\Projects\Gaming\VGR\charface";
Directory.CreateDirectory(outputFolder);
var offsetList = new List<int>();
var offsetData = File.ReadAllBytes(imageFile).Take(0x40).ToArray();
for (int i = 0; i < offsetData.Length; i += 4)
{
var offset = BitConverter.ToInt32(offsetData.Skip(i).Take(4).Reverse().ToArray(), 0);
offsetList.Add(offset);
}
foreach (var offset in offsetList)
{
var data = File.ReadAllBytes(imageFile).Skip(offset).Take(0x6b10).ToArray();
var paletteData = data.Skip(0x10).Take(0x210).ToArray();
var imageData = data.Skip(0x210).ToArray();
var palette2 = ConvertRGB15BytesToRGB(paletteData);
var image = GenerateClutImage(palette2, imageData, 168, 160);
image.Save(Path.Combine(outputFolder, $"{offset:X4}_2.png"), ImageFormat.Png);
}
static List<Color> ConvertRGB15BytesToRGB(byte[] bytes)
{
List<Color> colors = new List<Color>();
for (int i = 0; i < bytes.Length - 1; i += 2)
{
ushort color = BitConverter.ToUInt16(bytes.Skip(i).Take(2).Reverse().ToArray(), 0);
byte red = (byte)((color >> 10) & 0x1F);
byte green = (byte)((color >> 5) & 0x1F);
byte blue = (byte)(color & 0x1F);
red = (byte)((red << 3) | (red >> 2));
green = (byte)((green << 3) | (green >> 2));
blue = (byte)((blue << 3) | (blue >> 2));
Color rgbColor = Color.FromArgb(blue, green, red);
colors.Add(rgbColor);
}
return colors;
}```
The GenerateClutImage method just treats each byte/pixel of imageData as the index into the palette and constructs the image to the right dimensions
Oh wow, the top of the head/hair seems to be a separate sprite lol
What I've managed to get so far, the structure and offsets are a little awkward to get my head around as far as automating it all but I'm sure there's a sensible way to do it, I just focused on one of the "chunks" in the larger player file
There's some "tiles" which seem to be corrupt data, not sure if it's down to the extraction, or just how the files were originally, but some of the offsets point to "chunks" that aren't big enough to populate an image
Fixed the transparency issues from the last ones, had to manually combine the top of the head and body for the gifs, wondering if there's something in the header data that says whether an image should be combined with another somehow
Okay, so each image block seems to have an 8 byte header, first 4 bytes so far have been either 0x00000032 or 0x00000034, 32 seems to mean use the first palette, 34 use the second palette. Next 2 bytes are the image width / 2, then the next two bytes are the image height
Looks like the spell fx or attack fx use that second palette
Scaled so it's easier to see
Hey, um. I appreciate you going this far, but this is something I wanna rip myself.
Yeah, I can provide the code, was just showing the progress ๐
Probably going to need some manual assembly, once they've all been spat out, can't really see a foolproof way to assemble them in code
Do you know how to build a dotnet console app?
https://gist.github.com/ogarvey/2f9a826cee8baa1868880934db928909
That's the code to extract everything from player.bin, hopefully correctly...
I do not, but if you have a tutorial on hand, I can follow that.
dotnet sdk download: https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/sdk-8.0.401-windows-x64-installer
vscode download: https://code.visualstudio.com/Download
console app tut: https://www.youtube.com/watch?v=0NdStXm_B5c
Basically, just do what he does, but replace everything in the program.cs file with the code from my gist above
And you'll also need to add the following lines to the .csproj file: xml <ItemGroup> <PackageReference Include="System.Drawing.Common" Version="8.0.0" /> </ItemGroup> just before the closing </Project> tag
And if you're struggling at any point, feel free to ping me
...okay, this may be a little much for me lol
Lmao, I could build an exe that you can just drop the file onto but the last time I did that it set someones AV off and last thing I want is for people to think I'm trying to hack them
Oh no wories, I have Eset. It's much better at picking up actual problem files.
One sec and I'll get one built ๐
Fingers crossed that works okay lol
Just drop the player.bin file on the exe and it'll create some folders with the output in the same place as the .bin file
Worked beautifully.
Excellent ๐
Hm, looks like it doesn't work with any of the other player.bin files. That's okay, though; this gives me something to start with.
Yeah, the offsets will be different, I hardcoded them for this one
Gotcha.
If you can figure out how to build and run the code yourself, you should be able to change the offsets to the correct ones by examining the files in a hex editor if you use the one you sent and the code as a reference ๐
The file you sent has 3 "chunks", if you skip the first 4 bytes, then the offsets to the chunks are 0xC, 0x21f40, and 0x473a0, adding 4 to those values gives the offsets to the start of the chunks.
Each "chunk" starts with 32 bytes of header info which I ignore, then a massive list of offsets, pointing to some data I've no idea the purpose of also ignored lol, followed by 2 or 3 palettes depending how many it needs I guess, then more offsets to the individual sprites and then the actual sprite data.
Okay, I sort of understand what you're saying.
I've started working on a program that can do it a bit more automatically (at least the files like CHARFACE.BIN and KEIKOKU0.BIN), unfortunately it's a busy weekend and time is getting away from me so I haven't made it very far yet.
That being said, I have looked at the files some more and it's annoying because they don't have any kind of magic identifiers; you're just expected to know what kind of files they are and how to process them.
Are you able to find a file called something along the lines of "index"? There might be a file that says how each other file should be read
I think there is a pattern in the player.bin files as well that should enable automating that, but my brain was melting so it was easier to pick the offsets manually with there only being the three chunks, didn't realise there were more files or I'd have tried to automate it a bit more. Still like to know what the other offsets and data are preceding the image data, I was wondering if that was some sort of instruction on how to combine the sprites or something
This is the only other one I could think of it being in then.
I got nothing then.
Have you got an example of one of the other player files, might make it easier to determine a pattern in conjunction with the one I already looked at
Interestingly that one starts with some magic bytes 0x48 49 4B 30 (HIK0) which is missing from the other one
It looks like it could be animation instructions, although that's just a guess at this point
@undone totem https://drive.google.com/file/d/1NEWokp2cyVCAutZBP6OhW-BVB3qeM3B_/view?usp=drive_link
I made a small program for this. Currently it only supports the first kind of format (like CHARFACE.BIN and INITIAL.BIN). I'll try find the time to add support for the PLAYER.BIN format, as well as files that only have a single image (such as KEIKOKU0.BIN).
(I also need to make it smaller; I'm using a different UI framework than normal but it seems to end up making an unnecessarily huge binary)
Winforms ftw lmao
Been trying Avalonia again lately, that's not bad but assume the exe will be vastly larger due to all the dependencies
Yeah Avalonia is what I used for this
Might switch to WPF in the next iteration just to keep the size down
Sorry, I didn't ignore this, I promise. Thanks for this, Puggsoy. I'm going to try it with a few other bins and see what happens.
No worries! I need to find the time to have it support other types but between work and other stuff I haven't gotten to it yet
Just wanted to show that I haven't forgotten about this. I've started working on putting the sprite files together. So far, so good.
Ah yup, sorry I haven't been able to work on this. Been super busy and that isn't looking to die down anytime soon