@glk opcode documentation

Hello all!

I’ve been going round in circles trying to find documentation on @glk and its associated opcodes.

I’ve been looking through infglk.h and wanted to understand what arguments could be passed. For example:

[ glk_fileref_create_by_name _vararg_count ret;
  ! glk_fileref_create_by_name(uint, string, uint) => fileref
  @glk 97 _vararg_count ret;
  return ret;

Where is opcode, I’m assuming hex but that could be decimal not clear, 97 documented? How do I find out what arguments it takes and what its return values are?

Thank you!

You can find the numbers and what they all mean in the GLK specification.

Although note that when used in the Inform source they’re specified in decimal, not hex (but they’re in hex in that spec, so you’ll still have to translate.)

Ah ha! But they’re not listed by their opcode, as far as I can see, but by their “friendly name” as defined in infglk.h.

Is there some online list that maps the opcode value (hex or others) to the correct function in the GLK specification?

That’s just decimal 97. The @glk opcode will call the dispatch layer, which handles marshalling the call to the Glk library. The Glk side of all this is documented in section 12 of the Glk specification (“The Dispatch Layer”). There is a table of these ‘selector’ values in section 12.1.6 (“Table of Selectors”), which includes the entry

0x0061: glk_fileref_create_by_name
1 Like

Excellent answer, thank you!