The CONTEXT mechanism
or how to avoid use of QUERY

Sorry, this document is yet to be written!

The way A-code is currently implemented, has one substantial disadvantage. The two input directives (INPUT and QUERY) expect execution to proceed from the the point where they have been called, which is fine if the game executable takes care of its own main loop. However, in the single turn (CGI) and library modes, this is not the case. Input is obtained by other controlling software (e.g. by a PHP script, in the single turn mode) and there is no mechanism to return the game to the point at which an input directive is used. The problem is aggravated by the fact that it may make perfect sense to have multiple calls for input in a single pass through the main loop (e.g. get general command, if this command is SAVE without a name to save the game under, get the name; if there is already such a saved game, query whether it should be overwritten).

In Platt's original A-code implementation as a virtual machine this would not have been a problem. One simply saved the state of the VM before returning control to the external software. Once the game code is re-invoked and supplied with the next command, the VM state is restored and executaion proceeds as normal. Things are noweher near as simple when a game is simply an executable (or a library) built from C sources.

There are possible solutions, of course. If the game is split into two processes (one in charge of player communication and the other running the game's world),

The CONTEXT meschanism was my solution to this problem when implementing the original CGI-based implementation of Adv770 to be used by game's beta-testers. The idea is a simple one

Back to the A-code page

To the Mipmip home page
Feel free to leave a comment!
Mike Arnautov (20 February 2019)