Spy Programs

A G Walduck
In an attempt to 'look inside' the machine as AMPLE was playing music (to see if I could spot interesting things like sound event queues and to try to make some sense of them) I wrote two short programs to give me a dynamic memory display of areas within the machine.
Most other methods are unsuitable for use with AMPLE: Exmon is another language ROM, and only one language can be active at a time; Disc Doctor's MZAP almost completely takes over the machine; ADT's MEX command hangs the machine if executed from AMPLE.
I wished to obtain a fairly large 'window' into the machine, refreshed as rapidly as possible, that could co-exist with a busy AMPLE environment, could be easily instructed to view different areas, and could be turned on or off at will. Above all the keyboard control of AMPLE still had to be maintained.
The program is a small (less than one page) machine code program (AMPLE was far too slow!) which is completely illegally written, writing directly to the screen (apologies to Shadow RAM users, but even the OS routines are too slow), grabbing Econet zero-page workspace (&90-&9F) for its use, and residing in either page &900 or &A00 (which probably clashes with the Staff editor buffer usage of this area). It is a real quick-and-dirty program - but if anyone cares to improve on it, so much the better.
It exists as a background process, driven by the vertical sync event. Consequently the display can be animated by *FX14,4 (turn vertical sync event on), or frozen by *FX13,4 (turn vertical sync event off). Since text windows are not used, if the screen scrolls the display gets a little fragmented, but to no harm, and a quick 7 MODE puts everything to rights again.
The program suite exists in two versions, a 'normal' one which displays in the lower half of the screen (more suitable for coexisting with Menus and Editors), and a 'Hi' version which uses the upper half of the screen, and which is more suitable for use with the Mixing Desk. This version has to write a little more to the screen (i.e. spaces) for the output to be presentable, so is potentially a little more demanding of the processor, which can occasionally get a little stretched at busy times in the music processing; under these circumstances the music will temporarily slow or get out of step.
Each version consists of two programs:
a) U.MonS (or U.HiMonS) - a BASIC source program to assemble the code, and to save the machine code image. It also gives a test environment in BASIC, and starts with a display of the active area of the BASIC stack (for a bit of movement!). The machine code images produced are called Mon (or HiMon) and must be loaded at &900.
b) U.Spy (or U.HiSpy) - an EXEC file to load the machine code, set up function keys to 'move around' in memory, write the vector contents, and turn on the display (this time of the AMPLE stack). A couple of new AMPLE words are defined ('set' and 'show') to help in its use. These will be lost if a new program is loaded (unless SPY is EXECed again), but the equivalent commands can still be typed by hand.

Interesting areas in AMPLE memory

&160 show

The AMPLE stack. Unusual in that it runs from &17F down, and AMPLE error messages reside at &180 up (c.f. the typical BASIC/OS stack which runs from &1FF down, with error messages at &100 up.

&1D38 show (&2138 show, for the Music 4000)

Use HiSpy and the Mixing Desk to view this area within the M.M5 module work area, and one can readily see the correspondence between sounds on voices shown on the mixing desk and changes in this area. If the music is very busy, remember that the Mixing Desk screen refresh is a very low priority task in AMPLE so it may well lag noticeably behind the Spy screen, which has a higher priority than many of the AMPLE processes.

&1913/4 show

This is in the M.INT area and is incremented each 1/100th of a second during the running of an AMPLE music piece. Possibly the master timebase for the system.
I would be most interested if anyone finds any more attributable actions in the welter of changing data that this program reveals.

Related files on this disc:
U.MonS - BASIC program to produce 'Mon' machine code
U.HiMonS - BASIC program to produce 'HiMon' machine code
U.Spy - EXEC file to enable use of Mon code within the AMPLE environment
U.HiSpy - EXEC file to enable use of HiMon code within the AMPLE environment

Published in AMPLINEX 006, July 1988