TVDOS App Package
TVDOS App Package brings the convenience of the self-packaged executable to TVDOS. Applications containing multiple resources, library dependencies, specific environment variables, etc. are compressed, self-contained, and upon execution, unpacked and presented to your application — all in a single .app file.
TVDOS App Package is built with following goals in mind:
- Smaller file size than “everything spilled out”
- All required libraries are self-contained
- Has its own bootloader so that minimal extra code is required on DOS-side
- Bootloader must be versatile enough that DOS code needs no change when more advanced features were added
How It Runs
TVDOS will recognise that the file is an App Package, by considering the .app extension and the file header. Once recognised, TVDOS will go through the following steps to present the packed app to the end user:
- Internally defines the path named
MOUNT(typically under$:\TMP\)
- An empty filesystem is then created and mounted to the
MOUNT
- Optional VDISK is unpacked to Program Memory and then mounted under the
MOUNT\
- Resources defined in RODATA are loaded into the Scratchpad Memory
- Pointers to the loaded resources are injected as an JavaScript Object
__RODATA, into the main executable code (format: __RODATA.mylabel = 123456)
- Injects patched
files.open()which redirects any file references that are defined in the VDISK to the mounted VDISK
- Main executable code (“bootloader” for the App Package) is copied as
MOUNT\run.com
MOUNT\run.comis then read and called
- If any exceptions were caught or quit successfully, undoes any patching, unmounts itself, then returns the Errorlevel of the app to TVDOS
TVDOS App Package Format
Structure
Overview
| Header Area |
| Section Table |
| VDISK |
| RODATA |
| TEXT |
Header Area
| Offset | Type | Description |
|---|---|---|
| 0 | \x7F A p P | Magic (App Package) |
| 4 | Uint8 | Endianness. 1 for Big |
| 5 | Uint8 | Version. Always 1 |
| 6 | Uint8 | Section Compression. 0—None, 1—Gzip |
| 7 | Uint8 | Number of Sections. Always greater than zero because of the ENDOFSECTION |
| 8 | Uint8 | Target OS. 1—TVDOS, 0—Unspecified |
| 9 | Byte[7] | Padding bytes |
Section Table
Repetition of:
| Section Name
(12 bytes, \x00 padded) | Offset
(Uint32; 4 bytes) |
Recognised section names:
- VDISK — Virtual Disk (TVDOS LFS format). Extra libraries must be contained here
- RODATA — Read-only Data. Typically graphical resources
- TEXT — The Bootloader (
run.com)
- APPINFO — Desktop Entry text that contains information about the App
- COPYING — Licence text
- ENDOFSECTION — Marker for the end of the penultimate section. The offset is identical to the size of the entire App Package if no extra bytes (aka footers) are followed
The Section Structure (not RODATA)
| Uncompressed Size
- (Uint48; 4 bytes) | Compressed Payload
+ (Uint32; 4 bytes) | Compressed Payload
(arbitrary size) |
RODATA Section Structure
Repetition of:
| Label Length
(1—255) | Label
(arbitrary size) | Compressed Size |