don't click here

Sonic Metatiles

Discussion in 'Engineering & Reverse Engineering' started by Mercury, Nov 29, 2010.

Thread Status:
Not open for further replies.
  1. Techokami

    Techokami

    For use only on NTSC Genesis systems Researcher
    1,373
    81
    28
    HoleNet!
    Sonic Worlds Next
    What language is your exporting tool written in? I can help you with calculating the palette data to be more accurate.
     
  2. Endri

    Endri

    Officer I don't have my drivers license with me. C Tech Member
    Techokami's assistancy could be handy. He's really good with metatile ripping.
     
  3. Tribeam

    Tribeam

    I code Lua and Lua accessories Member
    80
    0
    6
    4 days ago I was assigned "build an application of your choice on the stuff you've learned so far" as homework for school, and I finished my project today, (do by Tuesday)

    So I was trying to think of something to make, but nothing came to mind, and I was searching through the forums like I usually do, and seen this thread and it clicked, "I'll use these tiles for a level viewer".

    And so I did that.


    This probably has absolutely no use to anyone but I figured I'd share my app with the Sonic community.

    With out further ado...

    The Sonic Level Viewer:
    (hope the image isn't too big, I have a really high resolution)
    [​IMG]

    This doesn't read through ROM files, the layouts were dumped into bin files and are loaded from hard drive, then it loads the Metatiles created by Mercury.

    Everything you need is in the zip(so you don't need anything)
    Download

    Enjoy.

    EDIT: I forgot to mention that it requires .net 2.0.

    EDIT2: oh and the code is a mess, and the way I rendered it is shitty and probably lags for some people.
     
  4. Mercury

    Mercury

    His Name Is Sonic Tech Member
    1,740
    21
    18
    Location Location
    AeStHete
    Embarrassingly, Game Maker.

    Basically it exports 32bit BMPs, and this is the GM default so I can't do anything about it. I then convert each file using ImageMagick to a PNG.

    It's pathetic really. However, if I knew the format of the right type of PNG I could write the files binarily and skip all the rigmarole. I'm not sure there's any other way to be absolutely certain each tile has the correct palette in the Mega Drive order even if all those colours aren't present in the tile.
     
  5. nineko

    nineko

    I am the Holy Cat Tech Member
    6,309
    486
    63
    italy
    If you have to write an image file in the good old binary way I don't recommend you to do so with a PNG file, because the format is a bitch (it's compressed and filled of checksums everywhere). I'd rather write a PCX file, which is billions of times easier. The palettes would be correct and sorted, though you won't be able to add transparency. Not a big deal, you can batch convert the files from 8-bit PCX to 8-bit PNG (making sure to use a converter that preserves palette indexes) and then massively add the "tRNS" chunk to the PNG, since it will always be the same for all the files as the transparent palette indexes are always the same (0, 16, 32, 48 iirc). Brutally adding a chunk to a PNG doesn't affect the checksums so you can totally do it. I'm up to help if you want.
     
  6. Techokami

    Techokami

    For use only on NTSC Genesis systems Researcher
    1,373
    81
    28
    HoleNet!
    Sonic Worlds Next
    Oh. I've been using PHP, because the GD libraries are actually quite handy, and work with paletted APNG images.
    I should really update my tool to spit out priority-based images as well. But I should also figure out why the hell I can't get 16x16 tiles to properly transform with Sonic 1... mind helping me out with that? The wiki is useless in that regard. (transform in this case means the flip X/Y bits)

    In the meantime, here's some code for calculating a Genesis palette entry. It's in PHP, but I'm sure that you can port it to GML:
    Code (Text):
    1. $color = getByte($source);
    2. $color2 = getByte($source);
    3. // Genesis pallete entries are words - 0B GR
    4. $red = 17 * ($color2 % 16);
    5. $green = 17 * floor($color2 / 16);
    6. $blue = 17 * ($color % 16);
     
  7. nineko

    nineko

    I am the Holy Cat Tech Member
    6,309
    486
    63
    italy
    Yes, that's correct according to what we know.
     
  8. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,742
    338
    63
    SonLVL
    Actually, IIRC GerbilSoft later told me that the answer in that thread is not the correct one.
     
  9. nineko

    nineko

    I am the Holy Cat Tech Member
    6,309
    486
    63
    italy
    You mean this?
     
  10. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,742
    338
    63
    SonLVL
    He told me on IRC I think, but yeah.
     
  11. ValleyBell

    ValleyBell

    Tech Member
    246
    25
    28
    researching PC-98/X68000 sound drivers
    You're right, Sonic 1 (and Sonic CD) uses different flags than the other Sonic games. (I remember that it took me a while to figure them out.)
    Sonic 1 uses bit 4 (0x10) for vertical flipping and bit 3 (0x08) for horizontal flipping.
     
  12. Techokami

    Techokami

    For use only on NTSC Genesis systems Researcher
    1,373
    81
    28
    HoleNet!
    Sonic Worlds Next
    So I tried updating my Sonic 2/3K tool to export metatiles with priority, like Mercury is doing. The Wikis say the 8x8 tile data is PCCY XAAA AAAA AAAA, with P being the priority bit... so if I do a test to see if $tile & 0x8000, that should tell me if a tile has priority or not! Let's give it a spin and see what...
    [​IMG]
    [​IMG] Well that ain't right.
     
  13. Mercury

    Mercury

    His Name Is Sonic Tech Member
    1,740
    21
    18
    Location Location
    AeStHete
    I looked up the PCX format and it does look simple. Tell you what, I'll try to rewrite the programme to export PCXs, and if I can get that working okay, I'll take you up on your offer for help with the PNG step.

    I've been using the colour values that Gens does.

    In the end, it might be best if I make a utility for ripping the tiles, as opposed to uploading zips, so that users can choose the colour formula, image format, etc.

    Techokami, your scripts are all PHP. I'm not too "with it" when it comes to PHP - the code itself makes sense, but I thought it was a web thing. Is there a simple way to execute PHP locally, like a command line programme?
     
  14. Andlabs

    Andlabs

    「いっきまーす」 Wiki Sysop
    2,175
    1
    0
    Writing my own MD/Genesis sound driver :D
    Again, if you want I already have a lot of the code written in C++ for Chaotix. All that would really be needed would be to change the addresses and data loading, use the proper decompression formats, and then write a new for loop to write out the images, converting the palettes in the process (IF Qt allows that, which is why I've delayed — haven't checked).
     
  15. Mercury

    Mercury

    His Name Is Sonic Tech Member
    1,740
    21
    18
    Location Location
    AeStHete
    Well, sure. It also can't hurt because I haven't found a lot of Chaotix info yet.
     
  16. Yes, PCX is really simple, but I don't see a reason to deal with compression at all (even if it's the simple RLE implementation used by the PCX format - unless you actually want PCX to be the final delivery format) when you could just export uncompressed BMPs. Since all the images for a given game have the same dimensions, you could even save "template images" from MS Paint (one that's 128x128 and another that's 256x256) and copy their headers directly, so that during export you just have to worry about writing the palettes and the image itself, one pixel at a time without having to bother compressing anything. These BMPs should compress well when archived, or you could convert them to PNG later. The only weird thing about BMP is that they are stored from the bottom up, so the first row in the file is the last row of the image.
     
  17. Techokami

    Techokami

    For use only on NTSC Genesis systems Researcher
    1,373
    81
    28
    HoleNet!
    Sonic Worlds Next
    Well one, yes there is a command line version of PHP you can install. But I don't use it, I run my scripts in the browser via my own webserver running on my computer.
    And two, there's a fair amount of binary file functions, as well as a powerful image library called GD. While GD was made to have dynamically generated images for websites, or to watermark a photo that gets uploaded, or to generate thumbnails from a large image, it can also be used to, well, rip graphics from games! :)

    Okay. Will it change anything?
    [​IMG]
    [​IMG][​IMG] Sonic 1 hates me.
     
  18. Andlabs

    Andlabs

    「いっきまーす」 Wiki Sysop
    2,175
    1
    0
    Writing my own MD/Genesis sound driver :D
    Doesn't the image prove otherwise then?
     
  19. Techokami

    Techokami

    For use only on NTSC Genesis systems Researcher
    1,373
    81
    28
    HoleNet!
    Sonic Worlds Next
    That was the output from my upgraded script on a Sonic 1 savestate of Green Hill Zone, after getting help from both ValleyBell and Mercury. The shuttle loop isn't supposed to look like that, you know.
     
  20. Andlabs

    Andlabs

    「いっきまーす」 Wiki Sysop
    2,175
    1
    0
    Writing my own MD/Genesis sound driver :D
Thread Status:
Not open for further replies.