What follows is a detailed breakdown of how the set of valid tokens in Hugo is encoded and read within compiled code.
Tokens simply marked TOKEN are coded just as the byte value of the token in question; no other formatting or necessary token/value is required to follow. These are typically used for delimitation, signaling the end of a structure or structure component, etc.
STATEMENTS are those tokens that are read by the engine as some sort of operation — typically, these are “start of line” tokens, with some exceptions.
VALUES return an integer value to the engine within the context of an expression. See [sec_15-2], which describes all the valid types of values.
INTERNAL tokens never appear in source code. These are added by the compiler for use by the engine.
A “code block” is any executable statement or statements followed by a terminating $0D (}
).
Constructions may include expressions or values; the difference between the two is that values are expected to be discrete data types.
Note also that GetVal()
in heexpr.c allows a solvable expression bracketed by $01 ((
) and $02 ()
) to be treated as a discrete value.
Source references point to places in the Hugo C source code that may help to clarify how a particular construction is coded/interpreted.
While not specifically mentioned, the compiling of many tokens is localized in CodeLine()
in hccode.c, and the execution of many simple statements is localized in RunRoutine()
in herun.c.
The reading of values from data types or expressions begins with GetValue()
in heexpr.c, with the basic identification of values in GetVal()
.
01 |
|
TOKEN |
||||
02 |
|
TOKEN |
||||
03 |
|
TOKEN |
||||
04 |
|
reserved (not coded) |
||||
05 |
|
TOKEN |
||||
06 |
|
TOKEN |
||||
07 |
|
TOKEN |
||||
08 |
|
TOKEN |
||||
09 |
|
TOKEN |
||||
0A |
|
TOKEN |
||||
0B |
|
TOKEN |
||||
0C |
|
TOKEN |
||||
0D |
|
TOKEN (Signifies the end of a code block) |
||||
0E |
|
TOKEN |
||||
0F |
|
TOKEN |
||||
10 |
|
TOKEN |
||||
11 |
|
TOKEN |
||||
12 |
|
TOKEN |
||||
13 |
|
TOKEN |
||||
14 |
|
TOKEN |
||||
15 |
|
TOKEN |
||||
16 |
|
TOKEN |
||||
17 |
|
TOKEN |
||||
18 |
STATEMENT 18 <skip distance> <expression> 4C <conditional block> <next statement> |
|||||
As in: |
if <expression> {...} Where the two bytes of
|
|||||
Source: |
|
|||||
19 |
|
TOKEN |
||||
1A |
|
STATEMENT 1A <skip distance> <conditional block> <next statement> |
||||
As in: |
else {...} Where |
|||||
Source: |
|
|||||
1B |
|
STATEMENT 1B <skip distance> <expression> 4C <conditional block> <next statement> |
||||
As in: |
elseif <expression> {...} |
|||||
Source: |
|
|||||
1C |
|
STATEMENT :<starting point> 1C <skip distance> <expression> 4C <conditional block> 25 <starting point> <next statement> |
||||
As in: |
while <expression> {...} As long as
|
|||||
Source: |
|
|||||
1D |
|
STATEMENT 1D <skip distance> :<starting point> <block> 1C <two bytes> <expression> 4C <next statement> |
||||
As in: |
do {...} while <expression> If, after |
|||||
Source: |
|
|||||
1E |
|
STATEMENT 1E When encountered by the engine, resets the conditional-statement evaluator, i.e., so that the next |
||||
Source: |
|
|||||
1F |
STATEMENT Treated identically by the engine to In other words, what the compiler does is take: select <expression> case <test1> <first conditional block> case <test2> <second conditional block> ... case else <default conditional block> and restructure it into: 1F <skip distance> <expression> 05 <test1> 4C <first conditional block> 1F <skip distance> <expression> 05 <test2> 4C <second conditional block> 1A <skip distance> <default conditional block> Note that $1A is the |
|||||
Source: |
|
|||||
20 |
|
STATEMENT <assignment> :<starting point> 20 <skip distance> <expression> 4C <conditional block> <modifying expression> 25 <starting point> <next statement> |
||||
As in: |
for (<assign>; <expr>; <modifying>) {...} The |
|||||
Source: |
|
|||||
21 |
|
STATEMENT 21 <expression> 4C |
||||
As in: |
return <expression> Where 21 4C |
|||||
22 |
|
STATEMENT 22 |
||||
23 |
|
TOKEN |
||||
24 |
|
TOKEN |
||||
25 |
|
STATEMENT 25 <address> |
||||
As in: |
jump <label> Where |
|||||
26 |
|
|||||
27 |
|
TOKEN |
||||
As in: |
|
|||||
28 |
|
TOKEN |
||||
29 |
|
VALUE 29 Hard-coded Boolean constant meaning 1. |
||||
2A |
|
VALUE 2A Hard-coded Boolean constant meaning 0. |
||||
2B |
|
reserved (not coded) |
||||
2C |
|
STATEMENT 2C <n> <dict_1> <dict_2>...<dict_n> Occurs in the grammar table and explicitly denotes the beginning of a new verb, where the single byte |
||||
2D |
|
STATEMENT 2D <n> <dict_1> <dict_2>...<dict_n> Coded and handled identically to |
||||
2E |
|
GRAMMAR TOKEN |
||||
2F |
|
GRAMMAR TOKEN |
||||
30 |
|
GRAMMAR TOKEN |
||||
31 |
|
PRINT TOKEN Signals a |
||||
32 |
|
GRAMMAR TOKEN |
||||
33 |
|
STATEMENT 33 <print data> 4C 33 <print data> 0B <print data> ... 4C Where
Multiple |
||||
Source: |
|
|||||
34 |
|
GRAMMAR TOKEN or PRINT TOKEN In a In a grammar line, represents any integer number. |
||||
35 |
|
PRINT TOKEN Signals that the following dictionary entry should have its first letter capitalized. |
||||
36 |
|
|||||
As in: |
text to n Where |
|||||
37 |
|
STATEMENT (Not implemented.) |
||||
38 |
|
STATEMENT 38 <value> 4C 38 <value> 19 <value> 4C 38 <value> 19 <value> 19 <value> 4C |
||||
As in: |
color foreground color foreground, background color foreground, background, inputcolor Where |
|||||
39 |
|
|||||
As in: |
remove <object> |
|||||
Source: |
|
|||||
3A |
|
|||||
As in: |
move <object1> to <object2> |
|||||
Source: |
|
|||||
3B |
|
TOKEN Followed by a value, as in: 3B <value> Typically found in ...3B <value> 4C |
||||
3C |
|
VALUE 3C 01 <expression> 02 |
||||
As in: |
parent(...) Returns the parent object of the object resulting from
|
|||||
3D |
|
VALUE 3D 01 <expression> 02 |
||||
As in: |
sibling(...) Returns the sibling of the object resulting from |
|||||
3E |
|
VALUE 3E 01 <expression> 02 |
||||
As in: |
child(...) Returns the child object of the object resulting from |
|||||
3F |
|
VALUE 3F 01 <expression> 02 |
||||
As in: |
youngest(...) Returns the youngest (most recently added) child object of the object resulting from |
|||||
40 |
|
VALUE 40 01 <expression> 02 |
||||
As in: |
eldest(...) Interpreted identically to |
|||||
41 |
|
VALUE 41 01 <expression> 02 |
||||
As in: |
younger(...) Interpreted identically to |
|||||
42 |
|
VALUE 42 01 <expression> 02 |
||||
As in: |
elder(...) Returns the object number of the object more recently added to the parent of the object resulting from |
|||||
43 |
|
INTERNAL VALUE 43 <property> Where |
||||
44 |
|
INTERNAL VALUE 44 <attribute> Where |
||||
45 |
|
INTERNAL VALUE 45 <variable> Where |
||||
46 |
|
INTERNAL VALUE 46 <dictionary entry> Where |
||||
47 |
|
INTERNAL STATEMENT 47 <text address> Where |
||||
48 |
|
INTERNAL STATEMENT or VALUE 48 <routine address> Where |
||||
49 |
|
INTERNAL DATA Is followed by data that is helpful to the engine at runtime — not visible in, for example, the debugger’s code window. E.g., local variable name: 49 45 <byte> <data> Where |
||||
4A |
|
INTERNAL VALUE 4A <object number> Where |
||||
4B |
|
INTERNAL VALUE 4B <number> Where |
||||
4C |
|
INTERNAL TOKEN End-of-line marker. |
||||
4D |
|
|||||
As in: |
||||||
Source: |
|
|||||
4E |
|
GRAMMAR TOKEN |
||||
4F |
|
GRAMMAR TOKEN |
||||
50 |
|
STATEMENT window n 50 <value> 4C window left, top, right, bottom 50 <v1> 19 <v2> 19 <v3> 19 <v4> 4C window 50 4C window 0 50 4B 00 00 4C Where
|
||||
Source: |
|
|||||
51 |
|
VALUE 51 01 <expression> 02 |
||||
As in: |
random(...) Returns a random value between 1 and |
|||||
52 |
|
VALUE 52 0E <expression> 0F |
||||
As in: |
As in: word[...] Returns the dictionary address of |
|||||
53 |
|
STATEMENT 53 <value> 4C 53 <value> 19 <value> 4C |
||||
As in: |
locate x locate x, y Where |
|||||
54 |
|
TOKEN Read-only engine variable representing the engine parser’s internal |
||||
Source: |
|
|||||
55 |
|
VALUE 55 01 <expression> 02 |
||||
As in: |
children(...) Returns the number of children owned by the object resulting from |
|||||
56 |
|
TOKEN |
||||
As in: |
for <object> in <parent> or if <object> [not] in <parent> |
|||||
57 |
|
STATEMENT 57 Waits for a keypress.
Stores the resulting key value in |
||||
58 |
|
STATEMENT 58 Runs all events in scope. |
||||
59 |
|
VALUE
|
||||
5A |
|
|||||
As in: |
call <routine address> Where |
|||||
5B |
|
PRINT TOKEN 5B <n> <char1> <char2> <char3> ... <charn> Valid only in a |
||||
Source: |
|
|||||
5C |
|
VALUE |
||||
As in: |
x = save Calls the engine’s save-game procedure (which includes filename input); returns a true value on success, or false on failure. |
|||||
Source: |
|
|||||
5D |
|
VALUE |
||||
As in: |
x = restore Calls the engine’s restore-game procedure (which includes filename input); returns a true value on success, or false on failure. |
|||||
Source: |
|
|||||
5E |
|
STATEMENT 5E Terminates program execution and exits the engine. |
||||
5F |
|
STATEMENT 5F Prompts for user input, storing the resulting word(s) in the |
||||
Source: |
|
|||||
60 |
|
PRINT TOKEN Read-only engine variable representing the compiler-determined serial number. |
||||
Source: |
|
|||||
61 |
|
STATEMENT 61 Clears the currently defined text window. |
||||
62 |
|
VALUE As in: x = scripton Calls the engine’s begin-scripting procedure (which includes filename input); returns a true value on success, or false on failure. |
||||
Source: |
|
|||||
63 |
|
VALUE |
||||
As in: |
x = scriptoff Calls the engine’s end-scripting procedure; returns a true value on success, or false on failure. |
|||||
Source: |
|
|||||
64 |
|
VALUE |
||||
As in: |
x = restart Attempts to reload the dynamic game data and restart the game loop; returns a true value on success or false on failure. |
|||||
65 |
|
PRINT TOKEN Signals that the following value should be printed as a hexadecimal number, not as the corresponding dictionary entry. |
||||
66 |
|
GRAMMAR TOKEN
|
||||
67 |
|
GRAMMAR TOKEN
|
||||
68 |
|
VALUE 68 01 <expr1> 19 <expr2> 19 <expr3> 02 |
||||
As in: |
x = string(a, "apple", 8) Calls the engine string-writing function to write the dictionary entry |
|||||
Source: |
|
|||||
69 |
|
VALUE 69 <value> Forces |
||||
Source: |
|
|||||
6A |
|
STATEMENT 6A <value1> 19 <value2> 19 ... 4C |
||||
As in: |
printchar 'A', 'B',... Outputs a single ASCII character value at the current screen position. Multiple values are separated by $19; the sequence is terminated by $4C. |
|||||
6B |
|
VALUE |
||||
As in: |
x = undo Attempts to restore all data changes made since the last typed input; returns a true value on success or false on failure. |
|||||
Source: |
|
|||||
6C |
|
VALUE 6C 01 <expr1> 19 <expr2> 02 |
||||
As in: |
x = dict(<array>, <len>) Calls the engine dictionary-writing function to write the given string into the dictionary, to a maximum of |
|||||
Source: |
|
|||||
6D |
|
VALUE |
||||
As in: |
x = recordon Calls the engine’s begin-command-recording procedure (which includes filename input); returns a true value on success, or false on failure. |
|||||
Source: |
|
|||||
6E |
|
VALUE |
||||
As in: |
x = recordoff Calls the engine’s end-command-recording procedure; returns a true value on success, or false on failure. |
|||||
Source: |
|
|||||
6F |
|
|||||
As in: |
writefile <file> {...} Opens the file named by the dictionary entry |
|||||
Source: |
|
|||||
70 |
|
|||||
As in: |
readfile <file> {...} Opens the file named by the dictionary entry |
|||||
71 |
|
|||||
72 |
|
VALUE |
||||
As in: |
x = readval Valid only in a |
|||||
73 |
|
VALUE |
||||
As in: |
x = playback Calls the engines command-playback procedure (including filename input) and attempts to begin command playback from the requested file.
If found, player input in |
|||||
74 |
|
STATEMENT Treated identically to $38: |
||||
75 |
|
STATEMENT 75 <value1> 19 <value2> 4C 75 <value1> 4C Attempts to load and display a JPEG-format picture either as resource |
||||
76 |
|
INTERNAL DATA |
||||
77 |
|
STATEMENT 77 [79] <value1> 19 <value2> [19 <value3>] 4C 77 <value1> 4C Attempts to load and play a WAV-format sample as resource |
||||
78 |
|
STATEMENT 78 [79] <value1> 19 <value2> [19 <value3>] 4C 78 <value1> 4C Attempts to load and play a music resource[11] as resource
11. Version 2.5 supports MOD, S3M, and XM-format music modules. Version 3.0 and later additionally support MIDI and MP3 files.
|
||||
79 |
|
TOKEN Used by |