1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378
|
# Yet another Random Datafile format: only lines with '>' in the
# 0th column are considered data, the rest is comments.
# Probabially wants to be conf/ed sometime in the future.
# UPDATE: Really, REALLY needs to be conf/ed, or something.
# Column 1: hex opcode
# Column 2: assembler opcode nmonic
# Column 3: assembler output format
# Column 4: assembler comment output format
# Column 5: script function output format
# Column 6: number of data bytes
# Column 7: data types of bytes
# Column 8: number of elements it pops from the stack
# Column 9: number of elements it pushes to the stack
# Column 10: the 'call effect' true false (1/0) if this is a 'call type' opcode
# Column 11: Flags. Each 0/1 reperesents a false/true condition for each of the
# flags listed below:
# Flag 1: Return flag. If true, it signifises that the function this
# opcode is found in, returns a variable on the stack.
# Flag 2: Paren output flag. If true, we output a pair of parenthesis
# around the usecode script output.
# The following flags are specific only to the usecode script output.
# Flag 3: Increment indent. If true, output the opcode, then increment
# the indent level by 1.
# Flag 4: Decrement indent. If true, decrement the indent level by 1,
# then output the opcode.
# Flag 5: Temporarly increment indent. If true, increment the indent
# level by 1, output the opcode, then decrement the indent level
# by 1.
# Flag 6: Temporarly decrement indent. If trye, decrement the indent
# level by 1, output the opcode, then increment the indent level
# by 1.
# DataType Notes:
# long == 4 bytes
# flag == extoffset == dataoffset == varoffset == offset == short == 2 bytes
# byte == 1 byte
# offset is calculated from the relative offset it
# A "false" value is defined as integer 0, a null string, or an empty array.
# (stateing obvious) Logically a "true" value would be the opposite of this.
# "Truth value"s pushed on the stack are integer 1 for true, and integer 0
# for false.
# REMEMBER: All arrays are indexed with as 1 based rather then 0 based.
# Notes on number of bytes poped/pushed:
# All numbers are the number of bytes poped/pushed from the stack, with the
# exception of 0xFF, which currently means the number of bytes in the first
# opcode parameter (see opcode 0x07). and 0xFE means the second parameter.
# Logic: parameter referenced is abs(0x100 - value)
# NOTE: Description of function appears below the relevant function.
> 0x00 NULL "null" "" "null()" 0 {} 0 0 0 000000
> 0x01 NULL "null" "" "null()" 0 {} 0 0 0 000000
> 0x02 NEXT "next\t[%1], [%2], [%3], [%4], %5" "\t\t\t;" "for (var%3 in var%4 with var%1 to var%2 atend label%f*_%5)" 10 {short,short,short,varoffset,offset} 0 0 0 000000
TODO: To be done...
* {varoffset} is the array to loop over.
* {short}(1st) is used to store the "counter".
* {short}(2nd) is used to store the "max" value. Which is the number of elements
stored in {varoffset} or 1 if it's a string or integer.
* {offset} is the relative offset to jump to after the loop is completed.
> 0x03 NULL "null" "" "null()" 0 {} 0 0 0 000000
> 0x04 ASK "ask\t%1" "" "UcAsk" 2 {offset} 0 0 0 000000
Display the Avatar's conversation options and ask for the user's input.
It jumps to {offset} if there is no conversation answers available.
> 0x05 JNE "jne\t%1" "" "if(!%p1) goto label%f*_%1" 2 {offset} 1 0 0 000000
Pops a value from the stack, tests if it's false, if it's false jumps to
the relative {offset}.
> 0x06 JMP "jmp\t%1" "" "goto label%f*_%1" 2 {offset} 0 0 0 000000
Jumps to the relative {offset} provided.
> 0x07 CMPS "cmps\t%1H, %2" "\t\t;" "cmps(%p,)" 4 {short,offset} 0xFF 0 0 000000
Pop {short} number of values from the stack, compare each one to the
last response from the user, and jumps to the {offset} if it's not found,
else continue as normal.
NOTE: only do this comparing if we haven't found a correct answer on
any of the previous CMPSs since the last ASK.
> 0x08 NULL "null" "" "null()" 0 {} 0 0 0 000000
> 0x09 ADD "add" "" "%p2 + %p1" 0 {} 2 1 0 010000
Adds %p1 to %p2.
> 0x0A SUB "sub" "" "%p2 - %p1" 0 {} 2 1 0 010000
Subtracts %p1 from %p2.
> 0x0B DIV "div" "" "%p2 / %p1" 0 {} 2 1 0 010000
Divides %p2 by %p1.
> 0x0C MUL "mul" "" "%p2 * %p1" 0 {} 2 1 0 010000
Multiplies %p1 by %p2.
> 0x0D MOD "mod" "" "%p2 %% %p1" 0 {} 2 1 0 010000
Mods %p2 by %p1.
> 0x0E AND "and" "" "%p2 && %p1" 0 {} 2 1 0 010000
Pops two elements from the stack, converts them to true/false, logically
"and"s the values, and pushes the resulting truth value back on the stack
as a 1/0(true/false).
> 0x0F OR "or" "" "%p2 || %p1" 0 {} 2 1 0 010000
The "logical or" counterpart the the "logical and" (opcode 0x0E). Refer to
that opcode for more information.
> 0x10 NOT "not" "" "!%p1" 0 {} 1 1 0 010000
Pops one element from the stack converts it to a truth value, logically "not"s
it, and then pushes the resulting truth value on the stack.
> 0x11 NULL "null" "" "null()" 0 {} 0 0 0 000000
> 0x12 POP "pop\t[%1]" "\t\t\t;" "var%1 = %p1" 2 {varoffset} 1 0 0 000000
Pops one element from the stack and assigns it to the local varitable pointed
to by {varoffset}.
MENTAL NOTE: assert(varoffset>=0 && varoffset<num_local_variables);
> 0x13 PUSHT "push\ttrue" "" "true" 0 {} 0 1 0 000000
Pushes true onto the stack.
> 0x14 PUSHF "push\tfalse" "" "false" 0 {} 0 1 0 000000
Pushes false onto the stack.
> 0x15 NULL "null" "" "null()" 0 {} 0 0 0 000000
> 0x16 CMPGT "cmpgt" "" "%p2 > %p1" 0 {} 2 1 0 010000
Tests if %p2 is greater then %p1.
> 0x17 CMPLT "cmplt" "" "%p2 < %p1" 0 {} 2 1 0 010000
Tests if %p2 is less then %p1.
> 0x18 CMPGE "cmpge" "" "%p2 >= %p1" 0 {} 2 1 0 010000
Tests if %p2 is greater then or equal to %p1.
> 0x19 CMPLE "cmple" "" "%p2 <= %p1" 0 {} 2 1 0 010000
Tests if %p2 is less then or equal to %p1.
> 0x1A CMPNE "cmpne" "" "%p2 != %p1" 0 {} 2 1 0 010000
Tests if %p2 is not equal to %p1.
> 0x1B NULL "null" "" "null()" 0 {} 0 0 0 000000
> 0x1C ADDSI "addsi\t%1H" "\t\t\t; %tc1" "UcMessage(\"%t1\")" 2 {dataoffset} 0 0 0 000000
Appends a string from the data segment {dataoffset} to the string register.
> 0x1D PUSHS "pushs\t%1H" "\t\t\t; %tc1" "\"%t1\"" 2 {dataoffset} 0 1 0 000000
Pushes the string at {dataoffset} onto the stack.
> 0x1E ARRC "arrc\t%1H" "\t\t\t;" "[%p,]" 2 {short} 0xFF 1 0 000000
Pops {short} number of elements from the stack, and creates an array of
them, first off the stack is the first appended to the end of the array
(ie. the elements were appended originally to the stack in the order 3, 2,
1 would create an array of the form {1, 2, 3}). The created array is then
appended to the stack.
> 0x1F PUSHI "pushi\t%1H" "\t\t\t; %d1" "0x%1" 2 {short} 0 1 0 000000
Pushes the element {short} to the stack as a signed 16bit integer.
> 0x20 NULL "null" "" "null()" 0 {} 0 0 0 000000
> 0x21 PUSH "push\t[%1]" "\t\t\t;" "var%1" 2 {varoffset} 0 1 0 000000
Pushes the variable stored at {varoffset} onto the stack.
> 0x22 CMPEQ "cmpeq" "" "%p2 == %p1" 0 {} 2 1 0 010000
Tests if %p2 is equal to %p1.
> 0x23 NULL "null" "" "null()" 0 {} 0 0 0 000000
> 0x24 CALL "call\textern:[%1]" "\t\t;" "%f1(%p,)" 2 {extoffset} 0 0 1 000000
References the "external usecode function table" (Exult code calls this
"externals"), with the {extoffset} value passed in the opcode call
(eg: external_table[extoffset]), then "calls" that function to continue
execution.
> 0x25 RET "ret" "" "return" 0 {} 0 0 0 000000
Returns to the "caller" function, after showing any text remaining in the
string buffer (Exult: say_string() buffer). Does not return any elements
on the stack (ie: returns "void").
> 0x26 AIDX "aid\t[%1]" "\t\t\t;" "var%1[%p1]" 2 {varoffset} 1 1 0 000000
Pops one (pop v1) element off the stack (the array index), and uses it as an
index of the local variable {varoffset}. (varoffset[v1]) The element obtained
is then pushed onto the stack.
TODO: NOTE: This opcode has been changed... need to redocument.
> 0x27 NULL "null" "" "null()" 0 {} 0 0 0 000000
> 0x28 NULL "null" "" "null()" 0 {} 0 0 0 000000
> 0x29 NULL "null" "" "null()" 0 {} 0 0 0 000000
> 0x2A NULL "null" "" "null()" 0 {} 0 0 0 000000
> 0x2B NULL "null" "" "null()" 0 {} 0 0 0 000000
> 0x2C EXIT2 "exit2" "" "exit2()" 0 {} 0 0 0 000000
Yet Another Return. Exult implements this identically to the RET opcode (0x25).
> 0x2D SETR "setr" "" "rr = %p1" 0 {} 1 0 0 000000
Pops the top most element off the stack and stores it in the return register.
> 0x2E ENUM "enum" "" "enum()" 0 {} 0 0 0 000000
Part one of the two opcode for...each opcode loop. Details under opcode 0x02.
> 0x2F ADDSV "addsv\t[%1]" "\t\t\t;" "UcMessage(var%1)" 2 {varoffset} 0 0 0 000000
Appends the local variable pointed to by {varoffset} onto the end of the
string register.
> 0x30 IN "in" "\t\t\t\t;" "in(%p2, %p1)" 0 {} 2 1 0 000000
Tests if a value is in an array. Pops two elements from the stack (pop v1,
then pop v2) test if any of the elements inside the array v1 are equal to
the element v2 (v2 cannot be an array), and pushes the resulting truth value
on the stack.
> 0x31 SMTH "smth\t%1 %2" "\t\t\t;" "smth()" 4 {short,offset} 0 0 0 000000
Does something related to conversations. Only occurs (2x) in the usecode
function handling the 'audition' in Britain. Current implementation
produces same result as original, although we're unsure of the exact
function of this opcode.
(Doesn't push or pop anything)
> 0x32 RTS "rts" "" "return rr" 0 {} 0 0 0 100000
(ucdump calls this "retr") Same as RET except pushes the return register
onto the stack before returning.
EXULT NOTE: unlike ret, it doesn't show any remaining text in the string
buffer. Bug?
> 0x33 SAY "say" "" "UcSay" 0 {} 0 0 0 000000
Displays the string register to the screen (as appropriate talk, sign, scroll,
book, whatever). Has the side effect of clearing the string register.
> 0x34 NULL "null" "" "null()" 0 {} 0 0 0 000000
> 0x35 NULL "null" "" "null()" 0 {} 0 0 0 000000
> 0x36 NULL "null" "" "null()" 0 {} 0 0 0 000000
> 0x37 NULL "null" "" "null()" 0 {} 0 0 0 000000
> 0x38 CALLIS "callis\t%i1@%b2" "\t\t; %1" "UI_%i1(%p,)" 3 {short,byte} 0xFE 1 0 000000
Calls the intrinsic {short} with {byte} number of parameters popped from the
stack passed to it. Eg: if you were calling intrinsic 23 (short) with 3 (byte)
parameters, and the stack looked like this: {4, 3, 2, 1} (4 was the first
element pushed upon the stack), the intrinsic function call in a c-like form
would look like: intrinsic23( 1, 2, 3);
The intrinsic called will return a value on the stack.
The intrinsic called also has the same "event" flag as the caller function.
> 0x39 CALLI "calli\t%i1@%b2" "\t\t; %1, %d2" "UI_%i1(%p,)" 3 {short,byte} 0xFE 0 0 000000
Same as opcode CALLIS (0x38), except no return value.
> 0x3A NULL "null" "" "null()" 0 {} 0 0 0 000000
> 0x3B NULL "null" "" "null()" 0 {} 0 0 0 000000
> 0x3C NULL "null" "" "null()" 0 {} 0 0 0 000000
> 0x3D NULL "null" "" "null()" 0 {} 0 0 0 000000
> 0x3E PUSHITM "push\titemref" "\t\t\t;" "item" 0 {} 0 1 0 000000
(ucdump & exult call this "push itemref") Pushes the identifier of the item
(for which the usecode event handler is called) onto the stack.
> 0x3F ABRT "abrt" "" "abrt()" 0 {} 0 0 0 000000
(ucdump calles this "exit") (exult says this is "really like a throw") Shows
any text in the string register, and exits the function immediatly.
ABRT also exits all calling functions, effectively stopping the usecode interpreter.
> 0x40 END_CONV "end_conv" "" "end_conv()" 0 {} 0 0 0 000000
Always seems to be called right before a "goodbye", so guessing
it means 'end conversation'.
> 0x41 NULL "null" "" "null()" 0 {} 0 0 0 000000
> 0x42 PUSHF "pushf\tflag:[%1]" "\t\t\t;" "gflags[%1]" 2 {flag} 0 1 0 000000
TODO: document
> 0x43 POPF "popf\tflag:[%1]" "\t\t;" "gflags[%1] = %p1" 2 {flag} 1 0 0 000000
TODO: document
> 0x44 PUSHB "pushb\t%b1H" "\t\t\t; %d1" "0x%b1" 1 {byte} 0 1 0 000000
(ucdump calls this "pushbi")
TODO: document
> 0x45 NULL "null" "" "null()" 0 {} 0 0 0 000000
> 0x46 APUT "aput\t[%1]" "\t\t\t;" "var%1[%p1] = %p2" 2 {varoffset} 2 0 0 000000
TODO: document
> 0x47 CALLE "calle\t%1H" "\t\t\t;" "calle()" 2 {short} 0 0 0 000000
# TODO: Needs more documenting, need to find the pop/push numbers.
{short} == usecode function number to call
TODO: document
> 0x48 PUSHEID "push\teventid" "" "event" 0 {} 0 1 0 000000
(ucdump & exult calles this "push eventid")
TODO: document
> 0x49 NULL "null" "" "null()" 0 {} 0 0 0 000000
> 0x4a ARRA "arra" "\t\t\t\t;" "%p2 & %p1" 0 {} 2 1 0 010000
Appends second param. to the list in first param.
> 0x4b POPEID "pop\teventid" "" "event = %p1" 0 {} 1 0 0 000000
# TODO: Needs more documenting
(ucdump & exult calls this "pop eventid")
TODO: document
# Debug opcodes -- currently only found in the .es version of SI
> 0x4c DBGLINE "dbgline %1" "" "// Line: %1" 2 {short} 0 0 0 000000
> 0x4d DBGFUNC "dbgfunc %1 %2 " "; %t1" "// Function: %t1 %2" 4 {short,dataoffset} 0 0 0 000000
# Fake opcodes for use with optimsations in ucxt
> 0x101 LABEL "(invalid)" "" "label%f*_%1" 2 {offset} 1 0 0 000001
|