Skip to content

Latest commit

 

History

History
311 lines (246 loc) · 11.7 KB

File metadata and controls

311 lines (246 loc) · 11.7 KB

TX File Format

The TX format has the following layout:

<optional_version_line>
<size_line>
<empty_line>
<glyph_block>
<empty_line>
<fg_color_block>
<empty_line>
<bg_color_block>
<empty_line>
<material_block>

Version Line

<optional_version_line> := ["VER " <major> "." <minor>]

Version line is optional when loading; absence means VER 1.0.

Current saver always writes VER <major>.<minor>.

Here are the characteristics of each version:

  • VER 1.0: Original format, ASCII glyphs, original 16-color encoding with additional transparency modes and default mode.
  • VER 2.0: 8-bit color support.
  • VER 2.1: - material sentinel support (- represents raw_mat_none decoded into mat_none, typically for AdHoc textels in TextUR).
  • VER 3.0: Bracketed Glyph serialization with preferred Unicode + fallback.

Size Line

<size_line> := <num_rows> <num_cols>

For example:

3 11

Where each block has <num_rows> non-empty lines. Each block row encodes exactly <num_cols> cells, but cell width in characters may vary for newer formats.

Glyph Block

Glyph block depends on version:

  • ver <= 2.1: one legacy ASCII glyph per cell.
  • ver >= 3.0: glyphs serialized with Glyph::str(false), e.g. [A], [2588,#], [] etc.

FG and BG Color Blocks

The color encodings are done in different categories:

4-bit Colors + Extra Color Modes

The extra color modes are:

Encoding Color Notes
T Color16::Transparent2 = -3 Transparency mode 2
t Color16::Transparent = -2 Transparency mode 1
* Color16::Default = -1 Default color

The 4-bit colors are:

Encoding Color
0 Color16::Black = 0
1 Color16::DarkRed = 1
2 Color16::DarkGreen = 2
3 Color16::DarkYellow = 3
4 Color16::DarkBlue = 4
5 Color16::DarkMagenta = 5
6 Color16::DarkCyan = 6
7 Color16::LightGray = 7
8 Color16::DarkGray = 8
9 Color16::Red = 9
A Color16::Green = 10
B Color16::Yellow = 11
C Color16::Blue = 12
D Color16::Magenta = 13
E Color16::Cyan = 14
F Color16::White = 15

These colors are supported by all TX versions.

8-bit Color Extensions

These colors are only supported by version 2.0 and later of the TX format.

The extended modes are as follows:

RGB6

This is the ANSI RGB cube that is 6x6x6 colors, i.e. 6 Reds, 6 Greens and 6 Blues.

They are encoded like this: "["<r><g><b>"]", so [123] means Red = 1, Green = 2, Blue = 3.

<r>, <g> and <b> are in the range [0, 5].

Gray24

This is a gray scale gradient from the ANSI standard that goes from almost black to almost white.

They are encoded like this: "{"<gray_hex>"}", so {0} is the darkest Gray24 entry and {17} is the brightest Gray24 entry.

<gray_hex> is encoded in hex format and in the range [0, 23] (dec) or more accurately [0, 17] (hex).

Hexadecimal letters generated by TextureFile::save() / TextureFileTx::save() will be in uppercase, but loading by TextureFile::load() / TextureFileTx::load() accept both lowercase and uppercase hexadecimal letters.

Material Block

Materials are encoded according to the following pattern:

  • - : For t8::texture::raw_mat_none, which decodes to public t8::texture::mat_none.
  • 0 -> 9 : For values in the range [0, 9] (dec).
  • A -> Z : For values in the range [10, 35] (dec).
  • a -> z : For values in the range [36, 61] (dec).
  • .0 -> .9 : For values in the range [62, 71] (dec).
  • .A -> .Z : For values in the range [72, 97] (dec).
  • .a -> .z : For values in the range [98, 123] (dec).
  • ,0 -> ,9 : For values in the range [124, 133] (dec).
  • ,A -> ,Z : For values in the range [134, 159] (dec).
  • ,a -> ,z : For values in the range [160, 185] (dec).
  • :0 -> :9 : For values in the range [186, 195] (dec).
  • :A -> :Z : For values in the range [196, 221] (dec).
  • :a -> :z : For values in the range [222, 247] (dec).
  • ;0 -> ;6 : For values in the range [248, 254] (dec).

The saver never emits ;7, because that would decode to raw value 255, i.e. t8::texture::raw_mat_none.

Examples

Termin8or/Examples/background.tx:

20 40

                                        
                                        
                                        
                                        
                                        
                                        
                                        
                                        
                                        
:::::::                                 
~~~.~=.::%%                             
ou.~~~~~,.~%%%%                         
898o.~~~+~~~~o8%%%                      
9883o..,~~~~ooO9Wm**                    
8i8o.~~.~~~"%oOoO%8w**                  
86o>+~~~~~%OooOOoww~<)oo                
8Oo+~+~~<%%OOo~~mm~~~/o\o               
3~~oo~~%%M%68OooO~mm~|(9\o              
3S0~o~~p%MM%99oOOo8ooo\6)o              
8%~o~~%WW%SSooOOOoooo~~~~~i             

****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
22AAAAA*********************************
EEE2EC2AAE7*****************************
C62EEEEEE2E66EF*************************
2C2C2EEE6EEEEC2EEE**********************
C22AC22EEEEECC4C2AEC********************
2A2C2EE2EEEC6C4C462EC4******************
22C66EEEEE64CC44CEEE633C****************
24C6E6EE66644CEEAAEEE3B3C***************
AEECCEE6626224CC4EAAE3BB3C**************
A66ECEE46226CCC44C2CCC3B3C**************
26ECEE622666CC44CCCEEEEEA24*************

TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
7FFF762TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
66676E72CCCTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
627666667762CCCTTTTTTTTTTTTTTTTTTTTTTTTT
AAA67666766666A2CCTTTTTTTTTTTTTTTTTTTTTT
AAA26777666666AAAE66TTTTTTTTTTTTTTTTTTTT
A2A67667666EE6A6AEAE66TTTTTTTTTTTTTTTTTT
AC67766666EA66AA6EE674C6TTTTTTTTTTTTTTTT
AA6767667EEAA666EE6664C46TTTTTTTTTTTTTTT
2666666EEAECAA66A6EE64CC46TTTTTTTTTTTTTT
2C466662EAAEAA6AA6A6664C46TTTTTTTTTTTTTT
AE6666EAAECC66AAA66666622A2TTTTTTTTTTTTT

0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
1111111000000000000000000000000000000000
1111111111100000000000000000000000000000
1111111111111110000000000000000000000000
1111111111111111110000000000000000000000
1111111111111111111100000000000000000000
1111111111111111111111000000000000000000
1111111111111111111111110000000000000000
1111111111111111111111111000000000000000
1111111111111111111111111100000000000000
1111111111111111111111111100000000000000
1111111111111111111111111110000000000000

Termin8or/Examples/background.tx:

VER 2
20 40

Tt*                                     
0123456789ABCDEF                        
------------------------------------    
------------------------------------    
------------------------------------    
------------------------------------    
------------------------------------                                        
------------------------------------    
                                        
                                        
                                        
                                        
                                        
                                        
                                        
                                        
                                        
                                        
                                        
                                        

****************************************
FFFFFFFFFFFFFFFF************************
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************
****************************************

Tt*TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
0123456789ABCDEFTTTTTTTTTTTTTTTTTTTTTTTT
[000][001][002][003][004][005][010][011][012][013][014][015][020][021][022][023][024][025][030][031][032][033][034][035][040][041][042][043][044][045][050][051][052][053][054][055]TTTT
[100][101][102][103][104][105][110][111][112][113][114][115][120][121][122][123][124][125][130][131][132][133][134][135][140][141][142][143][144][145][150][151][152][153][154][155]TTTT
[200][201][202][203][204][205][210][211][212][213][214][215][220][221][222][223][224][225][230][231][232][233][234][235][240][241][242][243][244][245][250][251][252][253][254][255]TTTT
[300][301][302][303][304][305][310][311][312][313][314][315][320][321][322][323][324][325][330][331][332][333][334][335][340][341][342][343][344][345][350][351][352][353][354][355]TTTT
[400][401][402][403][404][405][410][411][412][413][414][415][420][421][422][423][424][425][430][431][432][433][434][435][440][441][442][443][444][445][450][451][452][453][454][455]TTTT
[500][501][502][503][504][505][510][511][512][513][514][515][520][521][522][523][524][525][530][531][532][533][534][535][540][541][542][543][544][545][550][551][552][553][554][555]TTTT
{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{A}{B}{C}{D}{E}{F}{10}{11}{12}{13}{14}{15}{16}{17}TTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT

0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000
0000000000000000000000000000000000000000