Sonic and Sega Retro Message Board: Basic Questions & Answers thread - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
  • 399 Pages +
  • ◄ First
  • 397
  • 398
  • 399
    Locked
    Locked Forum

Basic Questions & Answers thread NEWBIES: Start here!

#5971 User is offline Stax 

Posted 13 October 2017 - 06:02 PM

  • Posts: 16
  • Joined: 01-July 14
  • Gender:Male
  • Location:Coquitlam, BC
  • Project:Sonic Pocket Mania

View PostMainMemory, on 13 October 2017 - 02:23 PM, said:

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.


Oh both me and my friend didn't know about Paint Shop Pro 9 when we were trying to fix this.

#5972 User is offline Stax 

Posted 13 October 2017 - 08:34 PM

  • Posts: 16
  • Joined: 01-July 14
  • Gender:Male
  • Location:Coquitlam, BC
  • Project:Sonic Pocket Mania

View PostPokepunch, on 13 October 2017 - 11:49 AM, said:

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.


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:
Posted Image

Here is the GIMP 2 export:
Posted Image


As you can see, the image becomes very different when exported from GIMP 2. This is because the original image uses a <b>global color table</b> 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:
Posted Image


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.
Posted Image


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.:
Posted Image

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.
Posted Image


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.
Posted Image

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. <b>YOU CANNOT CHANGE THE COLOR PALETTE!</b> 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.
This post has been edited by Stax: 13 October 2017 - 10:24 PM

#5973 User is offline Overlord 

Posted 14 October 2017 - 03:37 PM

  • Substitute Meerkovo IT Chief
  • Posts: 16567
  • Joined: 12-January 03
  • Gender:Male
  • Location:Berkshire, England
  • Project:VGDB
  • Wiki edits:3,204
Quite an illuminating read, thank you.

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

#5974 User is offline TheInvisibleSun 

Posted 14 October 2017 - 11:56 PM

  • OVER THE TOP TECHNO-BLAST
  • Posts: 1336
  • Joined: 09-December 09
  • Gender:Male
  • Location:Buffalo, NY, USA
  • Project:Sonic 1 Color Contrast

View PostGreggSalt, on 06 October 2017 - 03:04 PM, said:

Wow, I'm asking a lot of questions, but how would one go about making a new spring variant?


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.

#5975 User is offline EnderWaffle 

Posted 10 November 2017 - 01:14 PM

  • p e r f e c t t e c h n o
  • Posts: 16
  • Joined: 13-August 15
  • Gender:Male
  • Location:The Middle of Nowhere, USA
  • Project:Sonic 1: Changed Edition
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.
This post has been edited by EnderWaffle: 10 November 2017 - 01:15 PM

  • 399 Pages +
  • ◄ First
  • 397
  • 398
  • 399
    Locked
    Locked Forum

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users

  1. Google