A-code library mode interface
Normally, A-code games drive their own main loop, but various app frameworks insist on taking this functionality over. To cater for implementations based on such frameworks, A-code kernel has a library mode. When compiled in this mode, instead of having main(), it has a function called advturn(), which takes as its sole character string argument a a request (e.g. a player's command), and returns as its value a pointer to the game's response.
char *advturn(char *command)
At present, there is on important restriction on A-code games to be built using the library mode: they cannot use the QUERY directive. Reasons for this restriction , as well as a workaround, can be found in a separate document describing the A-code CONTEXT mechanism.
The advturn function takes a character string as its single argument and returns a pointer to a character string. This pointer is maintained by the kernel and should not be manipulated by the calling code.
Once the game is running, the argument string contains a game command obtained from the player and the returned pointer points to the game's response to that command. However, there are also other special values that the argument string can have:
Except for the above special cases, the argument string is interpreted as the player's next command to be processed by the game. The output string contains the full game's response, prefixed with a single character indicating the type of the response:
The simple libtest.c wrapper program supplied with the A-code kernel sources provides an example of using the library mode.