ff3:ff3us:tutorial:compressed

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
ff3:ff3us:tutorial:compressed [2017/09/14 00:54]
madsiur [Editing the Graphic]
ff3:ff3us:tutorial:compressed [2019/02/12 12:03] (current)
Line 1: Line 1:
 ===== Compressed Graphics Tutorial ===== ===== Compressed Graphics Tutorial =====
  
-In this tutorial, we will edit a compressed graphic with the help of four utilities. We will first decompress from the ROM the graphic, modify its palette in the ROM, edit the graphic and finally compress the new graphic in the ROM.+In this tutorial, we will edit a compressed graphic with the help of four utilities. We will first decompress the graphic from the ROM, modify its palette in the ROM, edit the graphic and finally compress the new graphic back to the ROM. 
 + 
 +----
  
 ==== The Tools ==== ==== The Tools ====
  
-The first utility you will need is {{ff3:ff3us:util:gfx:psv.7z|Peer Sprite Viewer}} (PSV). This utility can compress and decompress data from the FF3us and Chrono Trigger ROMSecondly you will need YY-CHR. There is a {{ff3:ff3us:util:gfx:yychr_net.zip|.NET version}} and a {{ff3:ff3us:util:gfx:yy-chr20120407_en.zip|C++ version}}. I personally go with the C++ one; it is older, but it has more features that have not yet been ported to the .NET version. The image shown here is from the C++ version. The other utility required is {{ff3:ff3us:util:gfx:snspal03.zip|SNESpal}}, which can modify color palettes in the ROM.+The first utility you will need is {{ff3:ff3us:util:gfx:psv.7z|Peer Sprite Viewer}} (PSV). This utility can compress and decompress data from the ROMs for FF3us and Chrono Trigger. Second, you will need [[rh:utilities:yychr|YY-CHR]]. There is a .NET and C++ versions. I personally go with the C++ one; it is older, but it has more features that have not yet been ported to the .NET version. The image shown here is from the C++ version. The other utility required is {{ff3:ff3us:util:gfx:snspal03.zip|SNESpal}}, which can modify color palettes in the ROM
 + 
 +Finally, you will need an all purpose image editor. My favorite editor for many things is Gimp.  It is great for icon making, spriting, and other graphic editing. Visit [[https://www.gimp.org/|gimp.org]] for the latest version.
  
-Finally you will need an all purpose image editor. My favorite one is Gimp for many things, including icon making, spriting and other graphics editing. Visit [[https://www.gimp.org/|gimp.org]] for the latest version.+----
  
 ==== Decompressing the Graphic ==== ==== Decompressing the Graphic ====
  
-The first thing to do is to locate what you need to decompress. We have a [[ff3:ff3us:doc:asm:other:compression|Compressed Data List]] which include graphics. Alternatively, you can look at the [[ff3:ff3us:doc:asm:rom_map|ROM Map]] but theoretically everything should be in the Compressed Data List. We will take for this tutorial the battle shield used in shield blocks by party members. It is part of a bigger //graphic sheet//, meaning you cannot just decompress / compress the shield alone. Modifying the shield will have an impact on the size and arrangement of the data once re-compressed. +The first thing to do is to locate what you need to decompress. We have a [[ff3:ff3us:doc:asm:other:compression|Compressed Data List]] which includes graphics. Alternatively, you can look at the [[ff3:ff3us:doc:asm:rom_map|ROM Map]]but everything should theoretically be in the Compressed Data List.  In this tutorial, we will edit the battle shield used by party members when they block with their shields. It is part of a larger //graphic sheet//, meaning you cannot just decompress / compress the shield alone. Modifying the shield will have an impact on the size and arrangement of the data once re-compressed. 
  
-The battle graphics we are looking for are at $D2E000 (unheadered ROM). This is $12E000 in absolute addressing. If you open a hex editor and go at this address, you'll see the following:+The battle graphics we are looking for are at $D2E000 (unheadered ROM). This is $12E000 when using absolute addressing. If you open a hex editor and go to this address, you'll see the following:
  
 {{ff3:ff3us:tutorial:compressed:hex-1.png?nolink}} {{ff3:ff3us:tutorial:compressed:hex-1.png?nolink}}
  
-The first two bytes are always an inverted word of the compressed data size. This mean our graphics are $0B44 bytes in size (including the first two bytes), meaning they are from $D2E000 to $D2EB43. The wiki list the graphic ending at $D2EBFF, which is not totally false since $D2EB44-$D2EBFF is unused space. However, while the starting offset will always likely be good, I suggest you check the data size to decompress the exact amount of data.+The first two bytes are always an inverted word representing the compressed data size. This means that our graphics are $0B44 bytes in size (including the first two bytes themselves), so the graphics are stored between $D2E000 and $D2EB43. The wiki lists the graphic as ending at $D2EBFF, which is not totally false since $D2EB44-$D2EBFF is unused space. While the starting offset is very likely to be correct, I suggest that you check the data size to ensure that you only decompress the data that makes up the graphic.
  
 Open your ROM in Peer Sprite Viewer (PSV). You'll see the main interface: Open your ROM in Peer Sprite Viewer (PSV). You'll see the main interface:
Line 24: Line 28:
 {{ff3:ff3us:tutorial:compressed:psv1.png?nolink}} {{ff3:ff3us:tutorial:compressed:psv1.png?nolink}}
  
-**Start** is your starting offset, **End** is your ending offset, **Width** and **Height** are the wanted dimensions of your decompressed graphic, **BitPlane** is the type of graphic once decompressed and **Decomp** is the compression type. I have always kept the **BitPlanes** value as //4 (16 colors)// for FF3us and obviously **Decomp** value should be set as //Final Fantasy VI//. This {{ff3:ff3us:tutorial:compressed:psv2-b.png?linkonly|screenshot}} show the correct values to enter for our example. Now click **Copy to Buffer**.+**Start** is your starting offset, and **End** is your ending offset, **Width** and **Height** are the desired dimensions of your decompressed graphic, **BitPlanes** specifies the type of graphic after decompression, and **Decomp** is the compression type. I have always kept the **BitPlanes** value as //4 (16 colors)// for FF3usand obviously **Decomp** should be set to //Final Fantasy VI//. This {{ff3:ff3us:tutorial:compressed:psv2-b.png?linkonly|screenshot}} shows the correct values to enter for our example. Now click **Copy to Buffer**.
  
-You should see the graphics in another window. Note that you can modify the sheet size and re-click on **Copy to Buffer** to get the right sizeHere are the same graphicsfirst screenshot is default 256x256 and second one is 128x128. This does not change much, only it will be easier to edit if you got the correct size.\\+After clicking, you should see the graphics in another window.  If the sheet size is incorrect, you can adjust it by changing the **Width**/**Height** fields and clicking on **Copy to Buffer** again. You may have to try several times to find the correct dimensions The following two images show the same graphics.  The first screenshot is 256x256 (the default value), and the second one is 128x128. The only difference is that it will be easier to edit if you find the correct size.\\
  
 {{ff3:ff3us:tutorial:compressed:psv4.png?nolink}} {{ff3:ff3us:tutorial:compressed:psv4-b.png?nolink}}\\ {{ff3:ff3us:tutorial:compressed:psv4.png?nolink}} {{ff3:ff3us:tutorial:compressed:psv4-b.png?nolink}}\\
  
-The next step is saving this graphic into a file. Click **Compress** and you will see this window:+The next step is saving this graphic to a file. Click **Compress**and you will see this window:
  
 {{ff3:ff3us:tutorial:compressed:psv5.png?nolink}}\\ {{ff3:ff3us:tutorial:compressed:psv5.png?nolink}}\\
  
-Enter the same starting offset ($12E000) and click **...** to enter a filename with the extension of your choice (a lot of people use .bin to hint at a binary file). Finally click **Decompress**, as shown {{ff3:ff3us:tutorial:compressed:psv7.png?linkonly|here}}. Your GFX is now saved in a file we will next edit with YY-CHR.+Enter the same starting offset ($12E000) and click **...** to enter a filename with the extension of your choice (a lot of people use .bin to hint at a binary file). Finallyclick **Decompress**, as shown {{ff3:ff3us:tutorial:compressed:psv7.png?linkonly|here}}. Your GFX is now saved in a file that we will edit with [[rh:utilities:yychr|YY-CHR]]. 
 + 
 +----
  
 ==== Finding and Editing the Palette ==== ==== Finding and Editing the Palette ====
  
-Now we need to use **YY-CHR**. If you want the compressed files and correct savestate to load the palette, you can download them {{ff3:ff3us:tutorial:compressed:shield.zip|here}}. When you lad the decompressed GFX, it should look like {{ff3:ff3us:tutorial:compressed:yy1.png?linkonly|this}}. No need to worry here, we will load the palette from a ZSNES savestate which was taken when the shield was on screen. Do //Palette -> Load Emulator state file// and select your savestate. Click **Pal** at the bottom right window and try each palette until you get the correct one. It should now look like this:+Now we need to use [[rh:utilities:yychr|YY-CHR]]. If you want the compressed files and savestate that will allow you to load the palette correctly, you can download them {{ff3:ff3us:tutorial:compressed:shield.zip|here}}. When you load the decompressed GFX, it should look like {{ff3:ff3us:tutorial:compressed:yy1.png?linkonly|this}}. No need to worry about the incorrect palette; we will load it from a ZSNES savestate that was taken when the shield was on screen. Select //Palette -> Load Emulator state file// and choose your savestate. Click **Pal** at the bottom right window and try each palette until you get the correct one. It should now look like this:
  
 {{ff3:ff3us:tutorial:compressed:yy2.png?nolink}} {{ff3:ff3us:tutorial:compressed:yy2.png?nolink}}
  
-When you right click on a palette color you will see its RGB value as shown {{ff3:ff3us:tutorial:compressed:yy3.png?linkonly|here}}. In this example, color BB RGB values are D0,C8,68 which is in hexadecimal notation. You'll need to convert the hex values into decimal (0-255) to find the palete with SNESpal. When entering the values in SNESpal, make sure you check the autoconvert checkbox. The example in the next picture is no with the last color of the palette. There is no real trick to find the color except looking at the search results and finding the few colors that are in same order as in YY-CHR. Try searching with "rareor uncommon colors and do not search for black or white as it will give tons of results.+When you right click on a palette coloryou will see its RGB value as shown {{ff3:ff3us:tutorial:compressed:yy3.png?linkonly|here}}. In this example, the RGB values of color BB are D0,C8, and 68which are in hexadecimal notation. You'll need to convert the hex values into decimal (0-255) to find the pallete with SNESpal. When entering the values in SNESpal, make sure you check the autoconvert checkbox. The example in the next picture highlights the colors that correspond with colors BA-BF in the previous picture. There is no real trick to find the color except looking at the search results and finding few colors that are in same order as in [[rh:utilities:yychr|YY-CHR]]. Try searching for rare or uncommon colors in SNESpal, and do not search for black or white as it will give tons of results.
  
 {{ff3:ff3us:tutorial:compressed:snespal1.png?nolink}} {{ff3:ff3us:tutorial:compressed:snespal1.png?nolink}}
  
-You can right away edit your new palettes. It can be unclear how many exclusive colors your GFX has but try reusing the available white and black on the palette and only edit what seems to be exclusive. You minimize this way the potential conflicts. Gimp Colormap for indexed images is useful to get the right RGB values to edit in SNESpal, however you need to do an hexadecimal to 1-31 scale conversion by dividing by 8.+Right away, you can edit your palette to something new.  It can be unclear how many exclusive colors your GFX has (some colors might be shared with other GFX), but try reusing the white and black that is already available in the paletteand only edit what seems to be exclusive.  In this way, you'll minimize potential conflicts.  For indexed images, Gimp Colormap is useful to get the right RGB values to edit in SNESpal, but you need to divide by 8 to do hexadecimal to 1-31 scale conversion.
  
 {{ff3:ff3us:tutorial:compressed:gimp1.png?nolink}}\\ {{ff3:ff3us:tutorial:compressed:gimp1.png?nolink}}\\
 {{ff3:ff3us:tutorial:compressed:gimp2.png?nolink}} {{ff3:ff3us:tutorial:compressed:gimp2.png?nolink}}
 +
 +----
 +
 ==== Editing the Graphic ==== ==== Editing the Graphic ====
  
-This is the fun part! (to me..)+This is the fun part! (to me...)
  
-First you can edit your YY-CHR palette to what was in Gimp and SNESpal, as shown {{ff3:ff3us:tutorial:compressed:yy4.png?linkonly|here}}. Next just edit the GFX and the finalk result should look like this:+First you can edit your [[rh:utilities:yychr|YY-CHR]] palette to the palette you made in Gimp and SNESpal, as shown {{ff3:ff3us:tutorial:compressed:yy4.png?linkonly|here}}. Nextjust edit the GFXand the final result should look like this:
  
 {{ff3:ff3us:tutorial:compressed:yy5.png?nolink}} {{ff3:ff3us:tutorial:compressed:yy5.png?nolink}}
 +
 +----
  
 ==== Recompressing the Graphic ==== ==== Recompressing the Graphic ====
 +
 +You can now reload your ROM in PSV by entering the same info as if you were decompressing. In this case, you should enter $D2EBFF as the ending offset to have some extra room if your GFX happens to take more space (I have not validated if this really has an impact or not).  Once again, click **Compress** and enter your starting offset in the compression window. Finally, click **Recompress** and save your ROM.
 +
 +{{ff3:ff3us:tutorial:compressed:psv7.png?nolink}} 
 +
 +The result in-game should be this one:
 +
 +{{ff3:ff3us:tutorial:compressed:teaser.png?nolink}}
 +
 +----
  
 ==== Conclusion ====  ==== Conclusion ==== 
 +
 +I hope I made this tutorial clear enough to give you a good indication of how to proceed with editing compressed graphics. If you ever get a compression error due to lack of space, there is no simple trick; you must either relocate the GFX (which requires code modifications) or make your graphic take less space once compressed. If you want more info on the compression algorithm, it is available in the FF6LE source code or in this [[http://www.romhacking.net/utilities/1176/|pearl script]].
 +
 +A while back, I also covered the same example in a video tutorial in pretty much in the same way. It is a good complement to this written tutorial.
 +
 +{{youtube>WhQXW21shd4}}
  • ff3/ff3us/tutorial/compressed.1505350473.txt.gz
  • Last modified: 5 years ago
  • (external edit)