Skip to content

Instantly share code, notes, and snippets.

@simondotm
Last active March 24, 2018 14:31
Show Gist options
  • Save simondotm/edf518a3f1fb174c0af84b61dc32f05d to your computer and use it in GitHub Desktop.
Save simondotm/edf518a3f1fb174c0af84b61dc32f05d to your computer and use it in GitHub Desktop.
Format ideas for a BBC Micro PAK file

BBC Pak file

Objective is to create a simple toolchain that can compile a bunch of code or data assets into a single file.

Advantages

  • compression
  • load time
  • more than 31 files per disk, and no need to load bloaty 512 byte disk catalogs
  • can control disk layout order for optimum seeks
  • toolchain can take a pak-config file as input, and output a TOC file. This can be directly INCBIN'd in the runtime code.

Notes

  • No need for executable addresses - geared for data/overlays only
  • No need for 32-bit load addresses - not for tube compatible systems
  • 31 files in DFS requires a 512 byte catalog
  • Support 64Kb PAK file maximum size means sector offsets can be 1 byte rather than 2, but will require support for multiple PAK files to be mounted
  • Add option to flag a pak'd file as pucrunch compressed? (for auto unpack)

Format

  • 8 bytes - Filename
  • 2 bytes - File Load address
  • 2 bytes - File length in bytes (top byte is length in sectors minus 1)
  • 2 bytes - File offset into PAK file in sectors (will be 2 bytes if PAK files larger than 64Kb are supported)

Total 14 bytes per file = 31 files = 434 bytes

Runtime functions

pakfile_mount() - will need to use FS to find the file initially and determine it's sector offset on the disk at runtime pakfile_load() - load a subfile from within the pak file to load address

Workflow

  1. Build/assemble/compress all the "assets" (code and/or data)
  2. compile the assets into pak form
  3. runtime mounts the pakfile
  4. route all loading through pakfile system (yet to be written)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment