[XP/VX] PROJECT OPTIMIZATION (7/15/2011 UPDATE)

Make your games smaller by ExHydra

  • Update History
  • < Version 1.6 | 07/14/11 > Added Blizzard's Resource Tester project under Stowaway Files (thanks GameGuysProjects)
  • < Version 1.5 | 07/13/11 > Added Zeriab's Remove Comments project under Scripts.(RXDATA/RVDATA) Comment Removal.
  • < Version 1.4 | 07/12/11 > Added JPEG & PNG Stripper under PNG/JPEG Optimization.
  • < Version 1.3 | 07/12/11 > Added the Compact RVData script under .RVData Compression.
  • < Version 1.2 | 07/08/11 > Added a tutorial on looping.
  • < Version 1.1 | 07/08/11 > Added Yeyinde's RM Data Checker under Stowaway Files (thanks cozziekuns)
  • < Version 1.0 | 07/08/11 > Initial Release





  • Easy
  • \ Graphics
  • < PNG/JPEG Optimization (XP/VX) >
    One of the easiest and quickest ways to shrink your project size is to use a PNG/JPEG optimizer on all of your graphics. While saving roughly 20 kb off of a single file may not seem very impressive, if your project has a large amount of graphics, then these small bits begin to add up quickly.

    For example, I recently optimized a project for a friend which had about 1,500 PNG files. The original size for the entire graphics folder was 84,085,192 bytes (84 mb). The size of the folder after I ran a quick PNG optimization was 57,719,751 bytes (57 mb). That's a difference of 26 megabytes simply by removing excess information that's not being used by the game and then re-compressing the file. No extra scripts or advanced computer knowledge required.

    There are a plethora of options available for PNG/JPEG optimization, but I personally prefer the following programs :


  • PSYDK.ORG PNG Optimizer
    This program features an easy to use interface which you can quickly drag and drop your files into. Very simple to use. By default, the program makes backups for each file that it optimizes, so remember to either disable this feature through the options menu or move the backups after optimization is complete. No installation required; free to use.


  • OptiPNG Advanced PNG Optimizer
    Unless you're like me and find glee in squeezing every last useless kilobyte out of PNG files, use the PSYDK PNG Optimizer instead. This is a command line PNG optimizer which has advanced options not normally needed, but can occasionally eek out several more kilobytes of unneeded data from the image file. No installation required; free to use.


  • JPEG & PNG Stripper
    Unlike the other two options above, this program removes useless metadata from JPEG files as well. If you are using JPEG files, I highly suggest running them through this optimizer to clear up the most amount of space possible. The program has an easy to use interface which you can quickly drag and drop your files into. Very simple to use. Please note that some anti-virus software may mark this program as malware, but it is not. No installation required; free to use.






  • < Thumbnail Cache Files (XP/VX) >
    Occasionally I see these database files just hanging around in one or more of the graphics directories, taking up space that they shouldn't be. Thumbs.DB is often the biggest offender. This file is generated automatically by Windows when browsing a folder with image files while the 'thumbnails' view is enabled. Always check to see if you have any such files before you export the release of your game, as I have seen them bloat as high as 5 mb.


  • < Stowaway Files (XP/VX) >
    Quickly run through your current graphic and audio files. Open them up, visually inspect or listen to them. Are you using all of them in your project? I've found myself guilty of allowing stowaway files into my project. That is, images that are not being used in the game and are most likely left overs from a quick graphic test or an older backup version of something that is being used in the game. These normally don't eat up very much space, but in larger games allowing these moochers to tag along can inflate the size of your project by several megabytes.

    If you're unsure if you're still using a certain graphic or music file within your game, move the file out of your project folder and use the following program or script to see if any errors crop up :


  • Yeyinde's RM Data Checker (XP/VX)


  • Blizzard's Resource Tester (XP)


  • Jet's Integrity Checker (VX)







  • Intermediate
  • \ Audio
  • < General >
  • Suggested Software Tools

  • Audacity Sound Editor
    Using Audacity is not required, although all of the steps for this tutorial will be done using that program.



  • Optional Software Tools

  • fre:ac Audio Encoder/Converter


  • MP3Gain MP3 Audio Normalizer
    Occasionally I will come across MP3s that are just outright loud or strangely quiet. I use this utility to bring their default volume up or down to a more acceptable level. This can be done within Audacity as well.







  • < Looping (VX) >
    Although the Graphics directory is often the biggest offender of project size bloat, the Audio directory can often rival or in many cases surpass its graphical neighbor.

    One way to help reduce the bulk of your Audio directory is to find a section within the music files to lock into an endless and flawless loop. However, the process to obtain such a loop can be difficult, depending on the song that you are wanting to create a loop with. If you are new to audio editing, you may wish to hone your skills first on a basic 8-bit song before moving on to more difficult targets. For this example, I will be using Two Things from the Yoko Kanno album 23 Ji no Ongaku which is a somewhat easy target for looping.

    Ok, so I've found the song that I want to use. Two Things adds the right feel to the city map that I'm creating, but there's a problem. This wonderful three minute song is nearly 8 megabytes in size due to the fact that it was encoded at 320 kbps in MP3 format. At the moment, that file alone is double the amount of my entire Graphics directory, which is really not a ratio that I enjoy seeing. I really need to find a loop that maintains the feeling the song offers while significantly lowering its size.


  • DISCLAIMER ( The following techniques have been self-taught, so I do not know the proper audio and/or music terminology to use. Those who are knowledgeable in those areas may frown upon my shenanigans. )


  • Step (1A)
    First, I'll open up Audacity and use the File > Open menu option to load Two Things. You can also simply drag and drop your sound files into the program. I now have a rather intimidating looking, almost cactus-like sound file staring me down.



    If you are new to audio editing, you might be asking yourself : "How do I find a loop among a solid block of that?"
    The answer is that it's easy with practice and some patience. Personally, I listen to and/or watch the audio read out to find the loops within a song. Depending on the type of music, it may take me a short time or it might take me a very long time. As far as I know, there is no automatic and free way to identify a loop within an audio file.


  • Step (1B)
    After listening to the song several times, I have identified that there is a possibility of a loop starting at the ten second marker and ending near the 1:25 minute marker. It is at around those two points that the song sounds the most similar. To test out my hunch, I will click on the Selection tool from the upper left-hand corner of the Tools toolbar.



    Then I will roughly select the area where I think the song will loop by clicking and dragging my cursor along the audio data from the start point to the end point that I want.




  • Step (2)
    Now I'll hold down the Shift key and click on the Play button. This will tell Audacity to continuously loop my selection, so I can hear if my hunch was correct.



    It turns out that I was really quite close to making a loop! However, try as I might to correct my selection by hovering the Selection tool at the edges of my current selection -- turning its graphic from a cross-hair into a pointing finger -- then clicking and dragging the start and end points, I cannot locate the coveted flawless loop. The best I can do from my current vantage point is create a near-perfect loop that causes the song to stutter and/or issue a barely audible pop or scratch just briefly.

    Is this the end of the line for my attempt? Not at all, it's just the beginning. This is where a little bit of audio editing experience comes in handy.


  • Step (3)
    What I will now need to do is use the Zoom tool which is located on the lower left-hand corner of the Tools toolbar. This will allow me to zoom in and get a closer look at the audio data of the song, which will hopefully allow me to create a perfect loop.




    With the Zoom tool, I'll click and drag my cursor along the audio data to specify the area near the beginning of my first selection to zoom in on first (zoom area specified between the two vertical dashed lines on the screen shot).



    Now I have a much better vantage point to work from! I can see the peaks and valleys much easier from here.



    While I'm zoomed in, I'll switch back to the Selection tool from the zoom tool and grab the edges of my selection, making small changes and then playing my altered loop using Shift and the Play button. Once I have one side where I want it, I'll use the scroll bar on the bottom of the screen to move to the other end while zoomed in. At that point, I'll continue to make minor changes of the selected area and listen to the newly changed selection. This is the part that takes quite a bit of patience and can be quite frustrating to find the right point to start and end your loop.


  • Step (4)
    After fiddling with my selection, I'm finally rewarded with a perfect loop! Now, I need to copy down the Selection Start (the far left on the screen shot) and Selection Length (the middle of the screen shot) information from the Selection toolbar. With this information, I can add the LOOPSTART and LOOPLENGTH metadata tags to an OGG file and have a flawless loop play within RPG Maker VX.



    After I have written or typed out the loop selection information, I'll use the selection tool to drag the left side of the selection to the beginning of the file. The first ten seconds or so will now serve as my lead-in, which will be played once before the loop takes over.

    Since I now have my loop start and end point, I no longer have any use for the remainder of the song. Therefore, with my new selection set in, I will go to the Edit menu and select the Trim option. This will clear any part of the audio data that is outside of the selection I have made.

    With that now done, I can now proceed to exporting the song as an OGG file by going to the File menu and selecting the Export option. I'll want to choose Ogg Vorbis Files from the Save As Type drop-down box.



    Also, I'll click on the Options button shown in the above screen shot and select a quality of '2'. I have found that for most music, this setting compresses the best while leaving decent audio quality. To be honest, the only person that really notices the quality drop will be you, unless the selected compression really degrades the clarity of the audio. In which case, you can merely re-encode the audio at a higher quality setting.



    After I press 'Ok' on the 'Export File' window, an 'Edit Metadata' window will then query me for any other data that I want to put into the file. This is where I want to use the Selection Start and Selection Length information. I'll double-click on the blank box underneath of 'Comment' and add 'LOOPSTART'. After that, I'll double-click on the blank field beside it and enter the start of my loop, which is '431418'.

    Next, I'll click the 'Add' button to provide myself with another field where I'll follow a similar method as above for inputting 'LOOPLENGTH'.



    After I'm finished, I'll merely hit the 'Ok' button on the window and Audacity will begin encoding the OGG file with the short lead-in and loop. Now a music file that was once nearly 8 megabytes is now around 1 megabyte and loops nicely!


  • Step (5A)
    If you want to hear the finished product, right-click download the OGG file and place it into either the BGM or BGS Audio sub-folder and play it within a project. You should hear the short lead-in once before the audio file will continuously loop with the selection I have given it.


  • Step (5B)
    Dance.




  • < File Compression (XP/VX) >
    ( To Do )


  • < Time Compression (XP/VX) >
    ( To Do )








  • Extreme
  • NOTE : There is no real need to use the following suggestions unless you find enjoyment in the challenge of scraping every possible kilobyte from your project.


  • \ { Base Directory }
  • < Executable Packing (XP/VX) >
    Although this is wandering into the realm of silliness, you can also shave around 30 kb from the Game.EXE file by using an executable packer. There are many options available for such compressors, although I would suggest using the following program :


  • UPX (Ultimate Packer for eXecutables)
    This is the portable GUI version of the popular UPX program. Quick, reliable and fairly easy to use. No installation required; free to use. Using the following options should allow for optimal compression while not interfering with the normal operation of the executable :



    After packing the executable, remember to run and play through your game to check for any incompatibilities that might arise, although there really should not be any. If everything is running fine, delete the backup file Game.EX~. If the game crashes or displays problems after compression, delete the packed executable and rename the backup file to take its place.





  • \ Data
  • < .RVDATA Compression (VX) >
    I've currently completed a script to allow for compressing .RVDATA within the Data directory, as its total size can often roam higher than 4 mb in large projects. Current test runs have dropped the size from roughly 5 mb to 500-ish kb (200 maps, full compliment of items, armors, weapons and animations). No third party DLLs or EXEs required.


  • Compact RVData (VX)





  • < Scripts.(RXDATA/RVDATA) Comment Removal (XP/VX) >
    Although the Scripts.(rxdata/rvdata) file cannot be compressed by the Compact RVData script above, it can still be optimized by removing commented lines and carriage returns. Zeriab has created a project for doing just that and I believe that it does its job well. For example, I have taken a heavily commented Scripts.rvdata which was 270 kb and come away with a 170 kb file after.

    It should be noted that removing the comments and carriage returns will make reading the code very difficult and should only be done when you are ready to release your game. You should also make a copy of your original Scripts.(rxdata/rvdata) and over-write the optimized version after having finalized your compressed distribution file.

    NOTE : There are no guarantees by the author of this project that scripts will be in complete working order after the comments and carriage returns are removed. Please test your game thoroughly before releasing the finished product.


  • Zeriab's Remove Comments (XP/VX)
    To use, place your Scripts.(rxdata/rvdata) file in the Input folder and run Game.exe. This project will require the RPG Maker XP RTP if you do not already have it installed.






  • Posts

    Pages: 1
    Gibmaker
    I hate RPG Maker because of what it has done to me
    9274
    THIS IS A GOOD IDEA.
    Thanks for all the links to the tools and everything!
    Sailerius
    did someone say angels
    3214
    Very useful! Would you mind sharing the process you're using to build the RVData Compactor so that an XP version could be made?
    Everything in the Extreme level is a losing battle against time. You can download a program that compresses the executable but the difference is absolutely trivial. Instead of saving 30KB in five minutes you could spend that five minutes on more testing or checking every corner of a map or fighting a boss with a different party than usual and you'll get far more out of that five minutes testing the game than a whole 30KB could save, never mind the difference after compression and if it'll set of the heuristics of AVs. bSNES had that issues a few years ago but to be fair I'm not sure if that is an issue nowadays. Compressing and uncompressing the game data on the fly with GZIP is a redundant step because every game is already compressed in a zip/rar/7zip/ect. . All that does is create overhead at runtime, another point of failure, and waste time compressing the information again. There are platforms where data size is an issue, the PC is not one of them where saving 50KB of compressing the executable and rezipping compressed data will make any negligible difference.

    The rest is a much better use of time. I personally use PNGOut with irfanview for batch converting images to small 8-bit PNGs (24-bit PNGs that don't have to be are another waste of space but determining if an image is better suited for 8 or 24 bit could be another time waster). Adding loop data for music is a great use of time. Looped music flows much better than the regular joe and saves an appreciable amount of size that doesn't compress well. It can be annoying as hell though trying to get it to loop on the right sample without sounding off and that only RM can play the loop correctly slows everything down when you need to wait three minutes just to hear the loop and you aren't sure if you noticed a loop artifact or if it was just your imagination. Hell I probably spent 15 minutes listening to one track trying to tell if I was hearing a loop artifact or not until I called it the day and accepted it.
    (this is where I write how I also did a pseudo-double blind test to make sure the quality of the new file compared to the old one was acceptable but I just had a paragraph above this one about wasting time
    )
    Can I recommend a script for XP?
    http://forum.chaos-project.com/index.php/topic,113.0.html

    Its a resource tester created by Blizzard. It literally checks everything. Graphics, Audio, events, maps, database files. Makes and log and tells you what is and isn't being used. Its a great tool!
    Hello, I'm the author of this article. I had given Nessiah permission to redistribute the original article, which is updated semi-frequently when people suggest new things or when I come across new methods.

    @Sailerius : I'm simply using the internal GZip functions that comes with the version of Ruby that RPG Maker uses. Nothing super fancy, in fact the code could use some work, but for now it seems to do its job just fine.

    @GreatRedSpirit : I should probably change the 'Extreme' section name to 'Zealot'. Personally, I am a data zealot. I grew up when two gigabyte hard drives were considered massive and I spent quite a bit of time packing utilities onto a 1.44 megabyte boot disk. So for me, it's fun to take on the challenge of shrinking the size of projects down as small as they can go. However, it really isn't the thing that most people should try, which is why I stuck it under the 'Extreme' category.

    @GameGuysProjects : Sure, I'll add that script to the original document. Thanks for the suggestion!
    I think this is one of the best tutorials here on RMN... o_o
    Simply amazing, thanks for this, Archeia! :3
    Pages: 1