Basic Questions & Answers thread

Discussion in 'Engineering & Reverse Engineering' started by Tweaker, May 29, 2008.

  1. Kapacitado

    Kapacitado

    Member
    1
    0
    0
    Hi guys! I'm new here.
    I'm working on a Sonic Mania mod that changes Sonic's sprites with the ones from Sonic 3&K. Thing is, I'm struggling so hard with palettes. Whenever I try to use custom colors in both the GameConfig.bin and the .gif itself, this is what happens:

    [​IMG]

    This is my GameConfig.bin palette

    [​IMG]

    And this is my Sonic1.gif palette
    [​IMG]

    I absolutely have no idea what am I doing wrong here, so any help would be much appreciated
     
  2. GreggSalt

    GreggSalt

    Member
    19
    0
    1
    Wow, I'm asking a lot of questions, but how would one go about making a new spring variant?
     
  3. Clownacy

    Clownacy

    Tech Member
    834
    69
    28
    You'll have to disassemble it. Like I said, I'm not even sure if the driver and its SFX are compressed or not, so you might not be able to copy/paste in the first place.
     
  4. BlackHole

    BlackHole

    You're going to need MORE than help. Member
    3,842
    177
    43
    England
    Sprites for Cybernetic Outbreak
    Has anyone managed to rip the complete planet from Sonic Unleashed's opening menu yet? I still can't seem to find it, despite seeing entire levels pulled from the game. If so, could I please receive a link to it? Thank you kindly.
     
  5. Stax

    Stax

    Member
    16
    0
    0
    Coquitlam, BC
    Sonic Pocket Mania
    [​IMG]

    Hey guys so if you guys remember I had an issue with the DD Wrecker mini-boss when I tried to mod it for Sonic Mania, where it's appearance glitches up, well thanks to a good friend of mine he figured out how to fix the issue with the boss!

    So how did he do it? Well it's a bit complicated and I can't take any credit for fixing this issue, that honor goes to yoshimo/yoshiweegee you can go check him out if you want.

    Well first off we had to figure out what was causing the issue in the first place, the only .gif file that had this kind of issue so far was this one specifically I believe it had something to do with the transition of the sprite to orange which was coded. But after a couple of tests later we figured out that the issue was that when I exported the .gif with GIMP 2.0 it changed the size of the color palette, as a result nothing would appear when the mini-boss fight would occur. When using Paint.Net it showed something but well... I'll let you see for yourself.

    [​IMG]

    What he did was pretty complicated which involved the use of HxD (A hex editor but any should work fine), he managed to fix it. And he made a program which will automatically correct the color palette of the .gif if you changed it. Now I have no idea how a hex editor works so if you have any questions regarding this you can go contact him through various means, which will be included below.

    Simply drag the .gif file onto the .exe file and it should correct it. Just slap it into your game and check if it works, if not contact yoshimo for some support if needed.

    Yoshimo:
    Discord: yoshimo#6922
    Youtube: youtube.com/user/yoshiweegee (if you search for either yoshimo or yoshiweegee you might not be able to find him)

    Thanks for reading and also thanks to those who also tried to help out with this issue!

    DDWreckerFixer.exe https://www.dropbox.com/s/te9h26lagpyfaut/DDWreckerFixer.exe?dl=0
     
  6. Fred

    Fred

    Taking a break Oldbie
    1,563
    114
    43
    Portugal
    Sonic 3 Unlocked
    "I have no idea what this executable does, but I'm going to post it online and tell people to download it!"
     
  7. Stax

    Stax

    Member
    16
    0
    0
    Coquitlam, BC
    Sonic Pocket Mania
    I guess I could've worded that better ha ha.
    Well what I meant is that I didn't know what process my friend did to fix the .gif file I know that he used HxD(a hex editor), but I didn't know what he did to the .gif to fix it. Then he created a program through C++ which is the program I linked. What it does is that you drag the .gif to the .exe file, and then the executable basically does what my friend did which was correcting the color pallete so that it actually works once you edit it in a program such as GIMP or any other kind. I have tested it and it does work from my expierance, the sprite sheet uses colours from the original sprite sheet, so I don't know what will happen if use colours that were not on the original sprite sheet, I'm assuming nothing bad but I can test it out when I return home.
     
  8. Pokepunch

    Pokepunch

    Member
    82
    0
    6
    UK
    A Sonic 2 Hack
    I think it would help if you got your friend to actually tell us the process this program does in detail. As it stands you haven't actually told us how it works, just that it fixes an issue. It "fixes" the GIF, but we kinda need to know how it fixes it.
     
  9. Stax

    Stax

    Member
    16
    0
    0
    Coquitlam, BC
    Sonic Pocket Mania
    The program takes the gif you put into it, and changes that gifs color pallete into the color pallete of the original DDWRECKER.GIF file.
     
  10. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,543
    142
    43
    SonLVL
    Couldn't you just use an image editor that maintains the image's original palette? I know Paint Shop Pro 9 does, though I've never tried editing Sonic Mania with it.
     
  11. Stax

    Stax

    Member
    16
    0
    0
    Coquitlam, BC
    Sonic Pocket Mania
    Oh both me and my friend didn't know about Paint Shop Pro 9 when we were trying to fix this.
     
  12. Stax

    Stax

    Member
    16
    0
    0
    Coquitlam, BC
    Sonic Pocket Mania
    The first response was from my point of view. The following is from my friend who created the program.

    Alright, boys, I'm gonna teach you some GIF format!

    First, let's see the difference between the original GIF from Sonic Mania and the same GIF imported into GIMP 2 and then exported.

    Here is the original GIF:
    [​IMG]

    Here is the GIMP 2 export:
    [​IMG]


    As you can see, the image becomes very different when exported from GIMP 2. This is because the original image uses a global color table with 256 colors, but GIMP 2 realizes it can fit the number of colors into a lower power of 2, 32. It does this to reduce the image's size in memory.

    We can see this in the bytes at offset 0x0A. Bits 2-0 determine the size of the global color table <i>in colors</i> by the following formula:
    [​IMG]


    You're probably hella confused by the symbolism here, so let me show how it works for these two images.

    Firstly, the byte at offset 0xA is located here, where the sum of the offset for the rows and columns is equal to 0xA.
    [​IMG]


    We then want bits 2-0, so we need to translate the value, 0xF7, to binary.

    0xF7 = 0b11110111


    Bits are ordered highest first, so we start counting from the left, at 0.

    1 1 1 1 0 1 1 1
    7 6 5 4 3 2 1 0


    So bits 2-0 gives us 0b111, which is 7. The formula produces our result.:
    [​IMG]

    This is for the original GIF. The GIMP 2 export has 0x84 as byte 0xA, which is 0b10000100. Bits 2-0 are 0b100, which is 4. Again, the size of the color table is acquired with the formula.
    [​IMG]


    With some math, we can determine the byte where the global color table ends. Each color is three bytes big, so for the original GIF, since 256 = 0x100, 0x100 * 0x3 = 0x300. The global color table starts at byte 0xD, so the global color table ends at 0xD + 0x300 = 0x30D.
    [​IMG]

    Meanwhile, for the GIMP export, 32 = 0x20, so 0x20 * 0x3 = 0x60, and 0xD + 0x60 = 0x6D. That's a very different end for the global color tables, and it this confuses Sonic Mania. I'm honestly suprised that it doesn't crash!


    This is where my program attempts to fix the export so that Sonic Mania can properly recognize it. It is a simple task of changing bits 2-0 of byte 0xA to 0b111 and filling the space between the original end of the color table and 0x30D with a lot of 0s. It does not change the global color table; it increases its size.


    Speaking of the changing the global color table, for unanimated GIFs, the global color table is the what we call the color palette. YOU CANNOT CHANGE THE COLOR PALETTE! Sonic Mania assigns the color palette itself, ignoring the global color table entirely. Increasing the size of the global color table only accomplishes the task of pushing the image data to the correct offset.

    This means that if you do change the color palette, the color for a given index will become the color in the index of the original GIF's color palette. I suspect that this is to accomplish the red-orange coloring during the boss fight by directly modifying the color palette.

    This is also why the color palette's colors cannot be rearranged, which is what Paint.Net does, which is why the image is the same but with the colors assigned to the wrong places.

    As much as I would love to fix this in my program, this is easier said than done. The GIF format uses LZW compression on the image data, so I would have learn how to decompress the image data in order to modify the color index of each pixel, and since there are ways to export the image with the correct color palette, I am not interested in bothering with this.
     
  13. Overlord

    Overlord

    Now playable in Smash Bros Ultimate Moderator
    18,305
    404
    63
    Berkshire, England
    Learning Cymraeg
    Quite an illuminating read, thank you.

    + - If you're using formatting tags, you want to use BBCode, not HTML. [], not <> !  
     
  14. TheInvisibleSun

    TheInvisibleSun

    OVER THE TOP TECHNO-BLAST Member
    If you look into and learn what the existing object does, you should be able to duplicate it, and make a new object or subtype with whatever parameters you like.
     
  15. EnderWaffle

    EnderWaffle

    Ghostly Friend Member
    So I currently can't work on my hack at the moment because my computer stopped working for some odd reason, but I'm still trying to think of ideas. :argh:

    Does anyone know how to shift the pitch of the songs in Sonic 3? I wanted to use Azure Lake in my hack and have it sound like the version from Sonic Pocket Adventure, but could only find a video showing how to change tempo.
     
  16. Aiko

    Aiko

    Member
    1
    0
    0
    Canada
    I'm pretty new here and I was surfing around the forums to try and find where I should post questions and I found myself here to ask about my SA2 ModLoader. I play SA2 on Steam and I downloaded SA2 ModLoader for it as soon as I got it. Everything was working perfectly but one day about a week ago, it kept crashing on the Omochao tip screen. I asked the Steam community about it and one guy told me to verify the game's integrity. So I did. And then my save file got deleted. Which isn't that big of a deal. But it kept crashing. So I rage quit for a couple of days but found myself coming back to it. I tried to run the game again with mods, but, it just crashed again. So then I clicked 'uninstall loader' and my game ran fine. It didn't crash. I'm hoping that someone can help me figure out how to fix this and get my mods back. I don't know if it has anything to do with it, but, I also have Fushion's Chao Editor installed. Maybe it conflicts with the files. I don't know. I'm not very good with coding or anything of the sorts.
     
  17. Blue Spikeball

    Blue Spikeball

    Member
    1,106
    287
    63
    Question. What program(s) should I use to edit the sprites and art in .bin format in the S&K Disassembler files?
     
  18. EnderWaffle

    EnderWaffle

    Ghostly Friend Member
    What compression type is it? If it has no compression on it (usually in an "artunc" folder), or if it uses Nemesis or Kosinski compression (usually in "artnem" or "artkos" folders respectively), then SonMapEd should be the right one to use. IIRC there might be other compression types, but I'm not sure if SonMapEd supports them or not.

    EDIT: Just realised that those folder names might only be for S1 and S2, nor S3K. But SonMapEd should still work, just as long as you make sure to set the Format to Sonic 3 in Settings -> Format -> Sonic 3. Also, here's a link to the SonMapEd info page.
     
  19. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,543
    142
    43
    SonLVL
    I'd recommend Flex 2. It is worth noting that Sonic's sprites in particular are difficult to edit for two reasons: first, his mapping and DPLC lists are sort of merged with Super Sonic's, so you have to disentangle them before you can edit anything, and secondly, he has two sets of art, so you have to switch between the two depending on which sprite you're editing.
     
  20. Blue Spikeball

    Blue Spikeball

    Member
    1,106
    287
    63
    Thanks for the suggestions guys, these programs seem to be what I needed. I have some questions about them, though.

    I don't suppose you can export a spritesheet as a bmp with SonMapEd?

    Also, can you edit the sprites directly? Because exporting them as bitmaps and editing like that them doesn't seem to be a very reliable method. I tried exporting them as bmp and reimporting them back, but the program gets the colors mixed up on the reimporting, even if I didn't edit the bitmap...
    If not, how should I go about editing the sprites?

    Does Flex 2 support importing data from .bin files? Because the "Import Over Sprite" and "Import Spritesheet" options seem to be for image formats only.