Skip to content

Support for ETT (.ttp) file format #19

@premultiply

Description

@premultiply

Maybe you are interested in adding support for the FAB ETT file format.
This is the format description:

	When teletext pages are stored in FAB ETT file format the files are stored with extension .TTP and contain following data:

	Byte 0:				Number of used rows (1 to 49)

	Byte 1..42:	Row 0
		Byte 1:			SO (0Eh)
		Byte 2:			80h
		Byte 3...32:	Page name + odd parity (first 30 bytes, rest starts at position 2060)
		Byte 33..35:	80h
		Byte 36:		Left Margin (0 to 38) + odd parity
		Byte 37:		Right Margin (1 to 39) + odd parity
		Byte 38:		Top Margin (1 to 22) + odd parity
		Byte 39:		Bottom Margin (2 to 23) + odd parity

		Byte 40:		Time for display (3 to 60), bit with value 64 should be set to disable numbering of subpages (FAB System only)+ odd parity

		Byte 41:
			bit 0 (1) 	= C7, header suppress
			bit 1 (2)	= C4, erase page
			bit 2 (4)	= C9, interrupted sequence
			bit 3 (8)	= C10, inhibit display
			bit 4 (16)	= C5, newsflash
			bit 5 (32)	= C6, subtitle
			bit 6 (64)	= set to 0
			bit 7 (128)	= odd parity

		Byte 42:		Character Set + odd parity	(0=GB, 4=D, 2=S, 6=I, 1=F, 5=E, 3=CS)

	Byte 43..2059:		Data rows (as specified in byte 0 minus 1), each consisting of block of 42 bytes:
		Byte 0:			SO (0Eh)
		Byte 1:			Packet (Row) number + odd parity
		Byte 2..41:		Contents of data line

	Byte 2060..2069:	Page name + odd parity (last 10 bytes)

	Remarks:
	1. Data lines should be stored in the following order: X/27 (0 or 1 packets),  X/26 (0 to 15 packets),  X/1..X/23 (only lines which contain characters other than 20h), X/24 (0 or 1 packet), X/25 (0 or 1 packet)
	2. Data in data lines should be encoded according to teletext specification. For lines X/1 to X/23 use odd parity characters.
	3. Unused space at the end of file can be filled up with character 20h.

Each page file has a size of 2070 bytes. I can provide some sample files.

Here is some sample PHP code to read a ETT file:

	public function loadETT($filename) {
		if (filesize($filename) == 2070) {
			$fh = fopen($filename, 'rb');

			//fseek($fh, 0);
			//print "Number of used content rows: ".ord(fread($fh, 1))."\r\n";

			fseek($fh, 3);
			$this->PageContent[0] = $this->ParityStrip(fread($fh, 30));

			fseek($fh, 40);
			$this->Duration = ord(fread($fh, 1)) & 0x7f;

			fseek($fh, 41);
			$flags = ord(fread($fh, 1));
			$this->FlagInhibitHeader  = $this->TestBit($flags, 0);
			$this->FlagErasePage      = $this->TestBit($flags, 1);
			$this->FlagOutOfSequence  = $this->TestBit($flags, 2);
			$this->FlagInhibitDisplay = $this->TestBit($flags, 3);
			$this->FlagNewsflash      = $this->TestBit($flags, 4);
			$this->FlagSubtitle       = $this->TestBit($flags, 5);

			fseek($fh, 42);
			$this->CharacterSet = ord(fread($fh, 1)) & 0x7f;

			for ($i = 0; $i < 48; $i++) {
				fseek($fh, ($i) * 42 + 44);
				$rownum = ord(fread($fh, 1)) & 0x7f;

				fseek($fh, ($i) * 42 + 45);
				$rowdata = fread($fh, TTX_LINELENGTH);
				if ($rownum < 26) {
					$this->PageContent[$rownum] = $this->ParityStrip($rowdata);
					if ($rownum == 24) $this->extractX24($this->PageContent[$rownum], $this->char_replacement_map[$i]);
				}
				else {
					$this->PageExtension[$rownum][] = $rowdata;
					switch ($rownum) {
						case 26:
							$this->decodeX26($rowdata);
							break;
						case 27:
							$this->decodeX27($rowdata);
							break;
					}
				}
			}

			fseek($fh, 2060);
			$this->PageContent[0] .= $this->ParityStrip(fread($fh, 10));

			fclose($fh);
		}
	}

Page number and Subpage number have to be parsed from the filename (like 100_00.ttp) or may be written to Row 0 as text like "100.00 Some Page Title here". Most systems parse it from the filename.

There is also a variant of this file format to support multiple subpages in one file but I did not have a look at it and do not have a format description yet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions