#Rayearth BIN Files

94 messages ยท Page 1 of 1 (latest)

undone totem
#

So, I'm trying to get information from the Rayearth game for Sega Saturn, but everything is locked behind .bin files. The headers seem to be made of garbage, and nothing I have has been able to even take a look into them.

I've attached one that should just be images.

surreal sphinx
#

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

undone totem
surreal sphinx
#

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)

undone totem
surreal sphinx
#

Looks more promising, although the format is quite distinct from the first one

#

Hmm, not finding much unfortunately.

undone totem
#

I just pulled off the disc what seemed likely to have images in it.

surreal sphinx
#

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

undone totem
#

Awesome; thanks!

edgy cobalt
#

Found an easy algorithm as it were for at least the charface.bin file

undone totem
#

Oh awesome.

#

I'm trying to load it in TiledGGD (PE) now, but I'm not seeing what you guys are getting.

surreal sphinx
#

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

undone totem
#

Okay, cool. ๐Ÿ˜ฎ

#

How do I scroll down to see more of the image?

surreal sphinx
#

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

edgy cobalt
edgy cobalt
#

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

edgy cobalt
# surreal sphinx But it seems predictable enough that coding something for it shouldn't be hard

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

edgy cobalt
#

๐Ÿค”

edgy cobalt
#

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

edgy cobalt
#

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

edgy cobalt
#

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

edgy cobalt
#

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

edgy cobalt
undone totem
#

Hey, um. I appreciate you going this far, but this is something I wanna rip myself.

edgy cobalt
#

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

undone totem
#

That's okay; I'm used to that.

#

//STARES AT BLEACH GAMES

edgy cobalt
undone totem
#

I do not, but if you have a tutorial on hand, I can follow that.

edgy cobalt
#

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

undone totem
#

...okay, this may be a little much for me lol

edgy cobalt
#

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

undone totem
#

Oh no wories, I have Eset. It's much better at picking up actual problem files.

edgy cobalt
#

One sec and I'll get one built ๐Ÿ‘

#

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

undone totem
#

Worked beautifully.

edgy cobalt
#

Excellent ๐Ÿ˜„

undone totem
#

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.

edgy cobalt
#

Yeah, the offsets will be different, I hardcoded them for this one

undone totem
#

Gotcha.

edgy cobalt
#

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.

undone totem
#

Okay, I sort of understand what you're saying.

surreal sphinx
#

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

undone totem
#

Let me look.

edgy cobalt
# surreal sphinx I've started working on a program that can do it a bit more automatically (at le...

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

edgy cobalt
undone totem
edgy cobalt
#

Narp, seems to be some sort of text data

undone totem
#

I got nothing then.

edgy cobalt
#

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

undone totem
edgy cobalt
#

Interestingly that one starts with some magic bytes 0x48 49 4B 30 (HIK0) which is missing from the other one

surreal sphinx
surreal sphinx
#

(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)

edgy cobalt
#

Been trying Avalonia again lately, that's not bad but assume the exe will be vastly larger due to all the dependencies

surreal sphinx
#

Yeah Avalonia is what I used for this

#

Might switch to WPF in the next iteration just to keep the size down

undone totem
#

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.

surreal sphinx
#

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

undone totem
#

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.

surreal sphinx
#

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