Updating to reflect the latest work
[zilutils.git] / zilasm / header.h
1 /*
2  * header.h -- part of ZilUtils/ZilAsm
3  *
4  * Copyright (C) 2016, 2019 Jason Self <j@jxself.org>
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Affero General Public License as
8  * published by the Free Software Foundation, either version 3 of the
9  * License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Affero General Public License for more details.
15  *
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>
18  *
19  * SPDX-License-Identifier: AGPL-3.0-or-later
20  */
21
22 #ifndef ZILASM_HEADER
23 #define ZILASM_HEADER 1
24 extern "C"
25 {
26 #include "zmem.h"
27 }
28 typedef unsigned long Byte_address;
29 typedef unsigned long Word_address;
30 typedef unsigned long Packed_address;
31 typedef unsigned long Offset8;
32 typedef unsigned short Word;
33 typedef unsigned char Byte;
34 typedef int Bool;
35
36 //typedef struct {
37 //      unsigned version;  // 1..6
38 //      // [$01] V1..V3: Flags1
39 //      Bool  statusline_type;      // bit1: 0=score/turns, 1=hh:mm
40 //      Bool  split_two_discs;      // bit2
41 //      Bool  statusline_notavail;  // bit4
42 //      Bool  screensplit_avail;    // bit5
43 //      Bool  varpitchfont_default; // bit6
44 //      // [$01] V4: Flags1
45 //      Bool  colors_avail;         // v5: bit0
46 //      Bool  pics_avail;           // v6: bit1
47 //      Bool  bold_avail;           // v4: bit2
48 //      Bool  italic_avail;         // v4: bit3
49 //      Bool  fixedspace_avail;     // v4: bit4
50 //      Bool  sound_avail;          // v6: bit5
51 //      Bool  timedkeyb_avail;      // v4: bit7
52 //      // Addresses
53 //      Byte_address   highmem_base;  // [$04]
54 //      Byte_address   start_pc;      //  [$06], v1
55 //      Packed_address start_routine; //  [$06], v6
56 //      Byte_address   dictionary;    // [$08]
57 //      Byte_address   objects;       // [$0A]
58 //      Byte_address   globals;       // [$0C]
59 //      Byte_address   static_base;   // [$0E]
60 //      // [$10] Flags2
61 //      Bool  transcript_on;        // v1: bit0
62 //      Bool  print_fixedfont;      // v3: bit1
63 //      Bool  request_redraw;       // v6: bit2
64 //      Bool  want_pics;            // v5: bit3
65 //      Bool  want_undo;            // v5: bit4
66 //      Bool  want_mouse;           // v5: bit5
67 //      Bool  want_colors;          // v5: bit6
68 //      Bool  want_sound;           // v5: bit7
69 //      Bool  want_menus;           // v5: bit8
70 //      //
71 //      Byte_address  abbrevs;        // [$18], v2
72 //      Word  file_length;            // [$1A], v3
73 //      Word  checksum;               // [$1C], v3
74 //      Byte  interpreter_number;     // [$1E], v4
75 //      Byte  interpreter_version;    // [$1F], v4
76 //      // Screen
77 //      Byte  screen_lines;           // [$20], v4 ($FF = infinite)
78 //      Byte  screen_chars;           // [$21], v4
79 //      Word  screen_width;           // [$22], v5
80 //      Word  screen_height;          // [$24], v5
81 //      Byte  font_width;             // [$26], v5/v6
82 //      Byte  font_height;            // [$27], v5/v6
83 //      // Tables
84 //      Offset8  routines;            // [$28], v6
85 //      Offset8  strings;             // [$2A], v6
86 //      Byte     backcolor;           // [$2C], v5
87 //      Byte     forecolor;           // [$2D], v5
88 //      Byte_address  term_chartable; // [$2E], v5
89 //      Word     width3;              // [$30], v6
90 //      Word     revnumber;           // [$32], v1
91 //      Byte_address  alphabet;       // [$34], v5
92 //      Byte_address  header_ext;     // [$36], v5
93 //} Program_header_struct;
94
95
96 enum MODE_FLAGS
97 {
98   COLOR_AVAILABLE = 0,
99   DISPLAY_AVAILABLE = 1,
100   BOLD_AVAILABLE = 2,
101   ITALIC_AVAILABLE = 4,
102   MONOSPACE_AVAILABLE = 8
103 };
104
105 typedef struct
106 {
107   Byte version;                 // 1..6
108   Byte mode;
109   Word release;
110   Word resident_size;           // also it's a start of "high" memory region
111   Word startPC;
112   Word dictionaryTableOffset;
113   Word objectsTableOffset;
114   Word globalsTableOffset;
115   Word dynamic_size;            // also it's a start of "static" memory region
116   Word flags;
117   unsigned char serial[6];
118   Word h_abbreviations;
119   Word h_file_size;
120   Word checkSum;
121   unsigned char interpreterNumber;
122   unsigned char interpreterVersion;
123   unsigned char H_SCREEN_ROWS;
124   unsigned char H_SCREEN_COLS;
125   Word H_SCREEN_WIDTH;
126   Word H_SCREEN_HEIGHT;
127   unsigned char H_FONT_HEIGHT;  /* this is the font width in V5 */
128   unsigned char H_FONT_WIDTH;   /* this is the font height in V5 */
129   Word H_FUNCTIONS_OFFSET;
130   Word H_STRINGS_OFFSET;
131   unsigned char H_DEFAULT_BACKGROUND;
132   unsigned char H_DEFAULT_FOREGROUND;
133   Word H_TERMINATING_KEYS;
134   Word H_LINE_WIDTH;
135   unsigned char H_STANDARD_HIGH;
136   unsigned char H_STANDARD_LOW;
137   Word H_ALPHABET;
138   Word H_EXTENSION_TABLE;
139   char USER_NAME[8];
140 } Program_header_struct;
141
142
143 extern Program_header_struct Program_header;
144
145 void program_header_reset (unsigned zversion);
146 ZMemblock *program_header_build (void);
147
148 typedef struct
149 {
150   Byte numberOfSelfinseringCharacters;
151   Byte *pSymbols;
152   Byte numberOfBytesInEachEntry;
153
154 } Program_dictionary_struct;
155
156
157
158 void outputToFile (Program_header_struct * h, FILE * file);
159
160 void relase_parser ();
161 #endif /* ifndef ZILASM_HEADER */