10/22/2010

Optimizing your Homebrew Release

Hey there Space Cats!

It's time for my most important guide yet, how to optimize your homebrew resulting in a perfect release, just like the Deprogrammer would make it.

NOTE: This guide is geared towards Windows. It most likely works for other OS as well, though.

First, let's make clear WHY you want to optimize your release:
You see, Dreamcast discs spin at a constant speed, ~12x on the outer part of the disc to be exact. Thus we can say it takes more space in the inside of the disc than on the outside. This is probably best explained with a diagram, behold, my MS Paint powerz:



YES, let's assume that the red and the green part cover the same area. In order to read the same amount of data, the laser has to move way less if the data is in the green area! This results in faster loading times and less noise coming from the laser. So, using common sense, you want to put data that's used often, like the main binary or streamed data on the outside, but more on that later.

In case you're thinking: "Pah!! I bet this only saves a splitsecond or two!!", think again: Some games' difference has been reported to be 10 seconds. So quit jabbin' and start reading the rest of this guide.

Like every new padawan, you'll need some tools, so get this pack. It includes everything you need for making an optimized release, from the IP.BIN to a dummy file creator. Just give it a download instead of googling for 4 hours. And while you're still downloading, let's start:

Most homebrew developers use programs like BootDreams to make their games selfbootable. The skilled ones even include a dummy file (usually called 000DUMMY.DAT, 000.000  or 0.0)  Do you wanna know why they always start with 0? Because those programs use alphabetical file order.


Alphabetical file order?

Yes, it really is that horrible. So guess where it puts your precious 1ST_READ.BIN: Right after your dummy file, in the center of the disc. For those of you unaware of the effects, since this file is accessed pretty much ALWAYS, it increases your loading times by far. The programs also use audio/data layout, which is sooooo 2007, so this guide explains how to make a data/data image as well, also increasing loading times.

The pack should be done downloading for now, so let's get to the good stuff. It is advised that you make a folder C:\selfboot and extract the content of the archive there.
Next, put your game data (scrambled binary, just the way you'd hand your data to a program) in the folder named "data".

Now, this is where we make a split: Releases with CDDA cannot be made using data/data layout and will be dealt with later.

Dummying for Games without CDDA


Now, in order to calculate a dummy file, you can either use my other tutorial, or use the easier approach which is explained here:
Start by putting a 1MB dummy file in the folder named "dummy". You do this by using DummyFileGen.exe in the "others" folder. You can name your file whatever you want, it won't be visible in your file system later on, unless someone uses Isobuster or another advanced program.
Next you need to use a command line tool named mkisofs. For those of you unfamiliar with the command line, it's situated in the Program files subfolder accessories, right next to M$ Paint. To get to the folder with command line use

chdir C:\selfboot

Now that you're in the right folder, you can use mkisofs.exe in this way:

mkisofs -V NAME_OF_YOUR_DUMMY_SESSION -l -o dummy.iso dummy

This will create dummy.iso. Make sure NOT to close the command line yet, we need a number:



11402 sectors is the space between the two sessions, NEVER FORGET TO ADD THEM!

Now we can conclude that the second session starts at 536+11402 -->  11938

Here's what we need it for, if you use the same way to make an iso for the second session, (e.g: your data), you'll burn a coaster. Here, we also include the rockridge (-R) and Joliet (-J) filesystems. They're not necessary, but BootDreams uses them, so I've included them as well. You need to include the parameter -C in this way:

mkisofs -C 0,SECOND_SESSION_START -V GAME_TITLE_HERE -R -J -l -o data.iso data

so for our value 11938 it would be:

mkisofs -C 0,11938 -V TITLE -R -J -l -o data.iso data

and it would look like this:





































456 MB, not quite what a CD-R can handle (701MB). After subtracting the 1MB our dummy file had before, we have 701 - 455 = 246MB, the size of the Dummy file we'd need! See, it's that easy to calculate a good dummy file! After replacing the old dummy file with the new one, just do everything like you did before, making the dummy.iso, calculating the second session start, etc...

In the end it should say ca.359200 extents written <701 Mb>
Some CDs have errors when you use all 360000 sectors, so always leave at least 500 sectors unused!!
Note: This is not your final data.iso, there's more steps that need to be done which will be explained after the CDDA tutorial. Feel free to delete the data.iso you now have.

Dummying Games with CDDA

When using CDDA, you always have a fixed second session start, because only the CDDA is in the first session. First, you have to burn the CDDA using a program called CDRECORD. Getting CDRECORD to run is a bitch, since you have to install an ASPI layer and other funky stuff. From my own experience, the easiest way to get a good ASPI layer going is installing a program called CDRWin: The trial version can be found here. After installing, it sets up ASPI all on its own, so there's no need to worry about anything. Haha, this is probably the hardest part of this whole tutorial.

To test if everything worked, run this command line in the selfboot folder:

cdrecord -scanbus

It'll search for CD-Recorders and stuff, everything that's connected to a scsi-bus. Search for the CD-Recorder you wanna use for burning and note the three numbers in front of it:

My three numbers are 1,0,0


These three numbers will be referred to as a,b,c now.

If you get errors, your ASPI is screwed. Good luck with fixing it, there's nothing more annoying. -_-

However, if everything works fine, use this command line to burn your CDDA:

cdrecord -dev=a,b,c -multi -pad -audio track01.wav track02.wav track03.wav ... trackXY.wav -speed=x

After it's done burning, you need to find out the second session start again, this time you use cdrecord in this way:

cdrecord -dev=a,b,c -msinfo

It will output two numbers: 0 and the second session start.

You should be able to figure out the rest from now on, but let's go it through again:

First you use mkisofs on your data folder WITHOUT a dummy file:

mkisofs -C 0,SECOND_SESSION_START -V GAME_TITLE_HERE -R -J -l -o data.iso data

Yes, now you calculate  your dummy file using 701MB minus the value mkisofs outputs. The only difference is that you have to put the Dummy file in your data folder this time. In case you want to be professional, you can name the Dummy file 0.0 and use one of DarkFalz' tools, the DummyHider.exe. How to use it is explained in a later step though, for now all you have to do is name your file 0.0, 'kay?

And there you go, a shiny new dummy file, state-of-the-art. Congrats, now you've mastered kindergarden, let's move on to elementary school:

FILE ORDER

This section is dedicated to DarkFalz, grandmaster of the sorttxt project.

This is the alpha and the omega. A bad file order can break a game, a good fileorder can make a game. Including file order is actually pretty simple, just add a new parameter to mkisofs:

-sort sorttxt.txt

Your sorttxt has to look like this:

data/0.0 30000
data/file3 29000
data/file2 28000
data/file1 27000
data/1ST_READ.BIN 26000

The higher the number, the farther on the inside of the disc the file is situated.

What do you say? "But Captain, I have 154453 files and can't manually write the down like that!!"

Well, do you still have the data.iso? You can extract the Alphabetical file order from there, that way you only have to change the values and don't have to jot everything down. You're gonna need isofix.exe (included) and Isobuster (Download here).

First, use isofix with this command line:

isofix data.iso SECOND_SESSION_START

for example

isofix data.iso 45000

This will create a fixed.iso you can open in Isobuster:
Now, select this:

Right-click on the iso name. Just in case you wondered.


This will create a Filelist.txt. Use TuxTheWise's listorganizer.exe (in the others folder) to output output.txt. This is not correct yet, you still need to make some changes, so open output.txt in a text editor. Use the "replace" function and replace every " <:\" with "data/" and every "\" with "/". Take care that you type " >:\" instead of  ">:\", if you don't replace the space before the >, it's Game Over for you!

Now, about how you should order the files:

This is the step no program in the world can do for you, and honestly, it differs from game to game. Here are some rules of the thumb you should think about:

-The main binary should ALWAYS be the farthest file away from the center,
-Videos and music always go to the center of the disc, you just have to watch out that they stream fast enough.
-Wallpapers and bonus stuff go to the center, naturally.
-The more often a file is accessed the farther to the outside the file goes.

Your best bet is to experiment around a bit and see what happens if you change the file order. As long as you stick to the basic rules above, your loading speed should improve.

Give your sorttxt a simple name, like for example list.txt.

Now, once you're done with file ordering it's time for

THE GRAND FINAL!

Now, use mkisofs for the final time:

mkisofs -C 0,SECOND_SESSION_START -V TITLE -R -J -sort list.txt -l -o data.iso data

This will create your data.iso. Check for a final time, did you dummy it right? Any errors? If you want to make your 0.0 invisible, now is the time to use DarkFalz' DummyHider.exe from the others folder.
Once that's done and over with, it's time for the IPINS step, which uses (you guessed it) ipins.exe
Just type ipins.exe in your command line.

Your Bootsector is "IP.BIN"
Your iso is "data.iso"

This is it. Your data.iso is done. All that's left is for you to burn. When burning, it is best advised to use CD-RWs first and test it on an emulator before wasting a CD-R. Unless you're the CD-R king, if that's the case, wear yourself out.

If you have a dummy.iso, you still have to burn it. Use cdrecord like this:

cdrecord -dev=a,b,c -multi -xa1 dummy.iso -speed=x

In case you have a game with CDDA, you should have burned it already, so all that's left is the final step...

Burning your data:

cdrecord -dev=a,b,c -xa1 data.iso -speed=x

Congrats, you made it. Wait for the burning to finish and test it afterwards. If it doesn't work, make sure you have followed every step very carefully! And if you still can't figure it out, send me a message and I'll try to help you.

Good luck!!

P.S.: I'll add an appendix as time permits where I'll explain such cool things as IPBIN4WIN and the super special Fastload file order. So stay tuned!

Credits

DarkFalz, TuxTheWise and Echelon for their tools
Jörg Schilling for cdrecord
Nikko Cheng for the Dummy File Generator

Keine Kommentare:

Kommentar veröffentlichen