TVDOS App Package
TVDOS App Package brings the convenience of the self-packaged executable to the 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 ENDSECTION |
| 8 | Uint8 | Target OS. 1—TVDOS, 0—Unspecified |
| 9 | Byte[7] | Padding bytes |
Section Table
Repetition of:
| Section Name
+ (10 bytes, \x00 padded) | Offset
+ (Uint48; 6 bytes) |
Recognised section names:
- VDISK — Virtual Disk. 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
- ENDSECTION — 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; 6 bytes) | Compressed Payload
+ (arbitrary size) |
RODATA Section Structure
Repetition of:
| Label Length
+ (1—255) | Label
+ (arbitrary size) | Compressed Size
+ (Uint48; 6 bytes) | Uncompressed Size
+ (Uint48; 6 bytes) | Payload
+ (arbitrary size) |
- Compressed Size is equal to the size of the Payload block
ApP Devkit
The ApP Devkit allows the programmers to test their to-be-packaged apps before the actual packaging. All the required files are placed into a directory, and the Package Simulator will run the contents in the directory as if they were packed into the App Package.
Package Simulator Components
apprun.js
apprun is an executable provided by the Simulator that simulates the runtime for the App Package.
Synopsis: apprun dir\to\app\files
rodata.json
rodata.json simulates the RODATA map of the App Package, and is required to actually create the App Package. The map contains the simple list of paths to the assets. The load order is the same as the order in the text file.
This file must reside in the root directory of your app.
Example:
{
+ "splash": "A:\myapp\assets\splash.ipf",
+ "icons": "A:\myapp\assets\icons.bin",
+ "frame": "A:\myapp\assets\guiframe.bin",
+ "jingle": "A:\myapp\assets\jingle.mp2"
+}The key of the JSON object will be the label for finding the pointer to the loaded assets. In this example, the pointer where guiframe.bin is stored is found on __RODATA.frame in your app’s code.
run.com
run.com is an entry point and the bootloader for your app.
This file must reside in the root directory of your app.
+