# Preparing an Optimized CD-ROM Image

Preparing an optimized CD-ROM image starts with creating a basic image, described in Preparing Simple cdrom.image Files. The following sections discuss the additional steps needed to produce an optimized image, which include:

- Creating the Base Image for Information Collection
- Preparing the Debugger for Information Collection
- Running Your Title to Collect Access Information
- Running the Layout Tool to Create an Optimized Image

## Creating the Base Image for Information Collection

The base image for information collection is identical to the simple image discussed above with the exception of the label field, which should be set to remote. To create the base image, follow these steps:

1. Edit the cdrom.tcl file using the settings in Preparing Simple cdrom.image Files, but use remote instead of cdrom for the label.
2. Run the layout tool again, as described in Creating the Simple Image.

## Preparing the Debugger for Information Collection

The optimizing layout tool requires information about when and how often the different files your title consists of are accessed when someone uses the title.

To set up the Debugger to collect file access information, follow these steps:

1. Put the Debugger Preferences file into the trash.

2. Launch the 3DO Debugger.

3. When prompted for a script to execute, click Cancel.

4. From the Edit menu, choose Preferences and do the following:

   - Make sure that RAM is set to Standard
   - Check the Set Initial Breakpoints
   - Check Set CD Emulation
   - Uncheck Auto-Launch Script
   - Uncheck Serial Port Enable

5. Make sure that there is no CD-ROM disc in the 3DO Station drive and that there is only one cdrom.image file on your Macintosh.

6. From the File menu, choose Directories and then choose Setup, and set your current data directory to the location of the cdrom.image file.

7. With the Debugger running, choose Launch from the Target menu and then select the boot script.

   Since you have turned on Set Initial Breakpoints, the application should stop at the first instruction.

8. From the File menu, choose Start CD Access Log and save the CD_Access.Log file into your /cdrommaster/_version_ folder, where _version_ is the most recent version of the operating system.

9. From the Execution menu, choose Go to run the boot script.

   The file system mounts the cdrom.image file under the name /remote. You are informed that because this file system was mounted, the Macintosh remote folder is not mounted. All of the system folios are launched from the cdrom.image file. The shell automatically starts up your LaunchMe application.

## Running Your Title to Collect Access Information

You are now set up for collecting the file access information required by the optimized layout tool. This section steps through running your title from the CD-ROM image file to collect the information.

Note: The person collecting file access information should be thoroughly familiar with the title.

With the 3DO Debugger running, follow these steps:

1. From the File menu, choose Special Mode.

   This puts the Debugger into special mode to make CD-ROM emulation as fast as possible.

2. With all settings for the Debugger in place, go through your title as follows:

   - Go through the title's startup sequence.

   - At each major user-interaction point, for example, each time a menu lets the user select a game level, pause for a second or so before making a selection.

   - Enter each major branch of the title only once if possible, so that file access information for that branch can be recorded.

   - The goal is to "exercise" the set of files used by each level, so that the optimizer can observe which files are used together.

3. After "touching" each level or branch in the title, press the Stop button on the control pad to exit the program.

4. Click the Macintosh mouse to terminate Debugger special mode.

5. From the File menu, select Stop CD Access Log.

6. Quit the Debugger.

## Running the Layout Tool to Create an Optimized Image

To create an optimized CD-ROM image file, you have to make the CD access log available to the cdrom.tcl script file that you run to create a CD-ROM image.

This section shows how to set up all required files and how to run the layout tool again to create the optimized image.

### Editing the cdrom.tcl File for the Optimized Image

To edit the cdrom.tcl file for the optimized image, use the settings in the table below, which differ from the settings for the nonoptimized image you used earlier:

    Table 1:  Variable settings for optimized image creation.
    --------------------------------------------------------
    Variable  |Setting
    --------------------------------------------------------
    label     |cd-rom (the default). Make sure the label is
              |NOT set to remote at this stage or you won't
              |be able to debug the optimized image.
    --------------------------------------------------------
    megabytes |Number of megabytes of CD-ROM space your
              |software will occupy. Larger is better; the
              |more storage space you allocate (in excess of
              |the amount actually needed for one copy of
              |each file), the more room the optimizer and
              |Catapult have to make multiple avatars of
              |your title's files, and the more effective
              |the optimization and clustering will be.
    --------------------------------------------------------
    catapultme|Set catapultmegabytes to the number of
    gabytes   |megabytes of CD-ROM space that you wish to
              |make available for the Catapult file. If your
              |application already uses most of the space on
              |the CD-ROM, you can make this a fairly small
              |number (Catapult files as small as 4 or 5 MB
              |can make a big difference in startup speed).
              |If your application has lots of room to
              |spare, request a larger Catapult file (20 to
              |30 MB or more).
              |
              |Since the actual benefit of Catapult varies
              |greatly depending  on the title, consider
              |making several images, one of them with
              |catapultmegabytes commented out.
    --------------------------------------------------------

If you used Catapult, you can exclude certain files or entire directories, from being included in the Catapult file (see Catapult). This can make sense for Cinepak or other full-motion-video files: they take up a lot of space in the Catapult file and usually don't benefit much from being catapulted. To do this, include a statement using one of the following formats in your cdrom.tcl file:

``

    excludecatapult "foo/bar/baz.cinepak"
    excludecatapult "foo/bar/"

The `excludecatapult` command accepts a single parameter, the Portfolio pathname to a file or directory. In either case, the path is relative to the root directory of the file system being created. The first format identifies a specific file which is to be excluded from the Catapult file. The second format (with a trailing "/") identifies a directory, and specifies that all files found in that directory are to be excluded from the Catapult file.

### Dealing with Large Files

If you have a large Cinepak file, or any other large file which is "streamed" into memory at high speed, you should do one of two things:

- Either exclude the file from the Catapult file using the `excludecatapult` command
- or make sure that the entire file is included in the Catapult file.

You need to make sure you don't have half of a file in the Catapult file and half of it excluded. This can occur if during your test-and-exercise run you play halfway through the file and then use the control pad to skip the rest of the introductory sequence. In this case, there may be an extra seek when the catapulted CD-ROM image accesses the file. It reads the first portion of the data from the Catapult file, but is forced to find an avatar of the file itself to get the remainder.

### Starting the Image Creation Process

After you've run the title with CD Access Log on, you should find a filemap.out file and a CD_Access.log file in the /cdrommaster/_version folder.

1. Rename the filemap.out file to filemap.in.

2. Make sure the CD_Access.log file resides in the /cdrommaster/_version folder.

3. Delete (or rename and move) the old copy of the cdrom.image file in the /cdrommaster/_version folder.

4. Run the layout tool program again, using the newly edited script. The CD.Access.log and filemap.in files are automatically used as input.

   The tool goes through several stages of file access analysis: clustering, file organization, cluster placement, and avatar assignment. It then writes a new cdrom.image file, which is optimized for the access performed while testing the first cdrom.image file.