Jump to content

Hacking NEC PC Games/Understanding Game Disks

From Wikibooks, open books for an open world

Structure of a Game Disk

[edit | edit source]

The structure of a disk (called it's "geometry") is determined when it formatted. Disk geometry elements include sides, tracks, and sectors.

  • sectors (also called "cylinders") are the lowest level of disk organization. The bytes within a disk are evenly divided into sectors, each with their own number. Sector sizes matter because a given file must consist of at least one sector, thus for each file on the disk needs its own sector and takes up at least that many bytes. Common sector sizes for game disks include 128, 256, and 512 bytes. (128 bytes is the absolute minimum the hardware will permit).
  • tracks (also called "heads") are groupings of sectors. There are usually 18 sectors per track, of which there may be anywhere from 40 to 320 tracks depending on the size of the sectors and the disk.
  • sides are the highest level of disk organization, and simply refer to the top and bottom sides of the disk, either of which may contain tracks and sectors. If a disk has two sides, half the tracks will on top and the other half on the bottom.

Layout of a Game Disk

[edit | edit source]

Master Boot Sector

[edit | edit source]

If the disk is a system disk, it will begin with a master boot sector (MBR) containing an interrupt service table, the location of the root directory (expressed as a sector ordinal), and a pointer to the start of the operating system (also as a sector ordinal). The master boot sector may actually contain more than one sector, but there will never been sectors (or files) in between parts of the MBR.

File Attribution Table

[edit | edit source]

If files on the disk have parts that are non-contiguous, or there is the potential for this, a file attribution table (FAT) may exist after the MBR (if there is one). These are generally similar to those created by MS-DOS for floppies. If the disk has a FAT but is not a system disk, the FAT will be the first thing on the disk. The FAT is an accounting of the positions of files on disk (in terms of sector) and the specific sectors they inhabit.

The root directory is the top of the files hierarchy and all other files are contained either within it or in sub-directories inside of it. If the disk is not a system disk and has no FAT, the root will be the first thing on the disk. The root directory consists of a list of all files within it, their positions either in the FAT (if it exists) or directly on the disk (in terms of sector and possibly track and head), and their respective lengths (in terms of absolute size, and sectors inhabited).

Sub-directories and files

[edit | edit source]
  • Files are the most basic unit of data the operating system can retrieve. Files consist of sectors, the organization of which may be described in a FAT.
  • Sub-directories are named collections of files. Nominally containers of files, they are in fact files in their own right, and are present in the FAT if there is one. Their structure is identical to that of the root directory.

File Attribution Table Copy

[edit | edit source]

If a FAT exists it may have a backup copy, usually halfway through the disk but sometimes immediately after the original.