ervin@pinbot.enet.dec.com (Joseph James Ervin) (05/16/91)
The following is an excerpt from the MPE User's guide, describing how to download and use the MPE demo application. ********************************* 4.1 Application Overview This demo application is a simple demonstration of how MPE can be used to do graphical animation of several objects on the screen at once. This also provides a good visual demonstration of the CPU loading effects described in earlier sections. Basically, the application consists of a fire button and four "bullets". This application uses the [+] button as the fire button. When the user starts the application, the screen blanks and waits for the user to press the fire button. For each press of the [+] button, the application will fire a bullet. The bullets start at the upper left of the screen and move down the screen, row by row, until they reach the bottom of the screen. When any bullet reaches the lower right of the screen, the application stops. When the user has fired all four bullets, the fire button is disabled for the remainder of the application. The [.] key quits the application. Refer to the following section for how to download and run the application. 4.2 Downloading And Running The Application Included in this distribution is the uuencoded binary file. This binary file is a directory containing the machine language code which makes up the MPE application, and a short RPL program which runs it. The user should uudecode this file and then download the resulting binary file in the usual manner to the HP48SX (make sure to set the HP48SX kermit to binary mode. The RPL program, "DEMO", in the new directory serves only to clear the display and set the display to PICT memory before running the machine language application ("XXX"). You should _not_ run the "XXX" program directly, since if PICT memory has been purged (by doing a PICT PURGE), then the application may corrupt memory. Once started by pressing the button labeled "DEMO", the machine language program can be aborted at any time by pressing the [.] button. 4.3 Process Descriptions The following sections describe each of the seven processes which make up the application. Note that processes #1 and #2 are not integral to the application and could be omitted. 4.3.1 Process #1 This is the process which is auto-executed by MPE at startup. In terms of the application, the only thing that this process does is to start up the keyboard scanner process (#7). Another function that this process performs, in conjunction with process #2 is to do a register context integrity test periodically while the application is running. This was written mainly for debugging MPE, but may be useful to the programmer in general, so I have left it in. It runs once per second, so it does not add significant overhead to the application. 4.3.2 Process #2 This process does nothing except clear all the processor registers. The purpose of this process is to work with process #1 to implement a register context integrity test. 4.3.3 Processes #3, #4, And #5. These processes are grouped together here because they share the same process definition. This process definition shows a good example of how to share code between two or more processes. The code for this process definition makes use of the IF_PROC/ENDIF_PROC macros to do conditional execution of certain sections of code based on the current context ID. For example, the three bullets owned by processes #3, #4, and #5 all move at different speeds on the screen. This was done here to visually show the independence of the bullet processes running in the system. The process definition uses the IF_PROC/ENDIF_PROC macros to schedule the correct process at the correct interval, thus determining the speed of each bullet. One thing to note is that this process definition does not attempt to control the speed of a bullet with great accuracy. In other words, as the four bullets are fired and the CPU becomes more heavily loaded, the speed of the bullets corresponding to processes #3, #4, and #5 will slow down slightly. This is due to process latency in the scheduler. Process #6 shows a similar bullet process, but one which keeps track of absolute time and maintains an accurate velocity on the screen, independent of CPU loading. 4.3.4 Process #6 This process definition is very similar to that which defines processes #3, #4,and #5. The main difference is that process #6 keeps track of absolute time, making sure that its bullet moves at exactly the velocity indicated in the process definition. In this way, even though the bullet for this process does not start until the CPU is already very busy with the other three bullets, it will maintain its velocity at the expense of the other three bullets. The effects of the use of absolute time in this process, versus relative time in the other three bullet processes, can be seen in two ways. The first way is that after firing the four bullets, it should be discernible that the fourth bullet (process #6) moves slightly faster than the second one (process #4). By examining the definitions of these processes, one quickly sees that processes #4 and #6 have the same rescheduling interval. The difference in speed is therefore attributable to the time that process #4 loses while sitting in the RUN_LIST waiting to be run by the scheduler. Since process #6 keeps track of absolute time internal to itself, this queuing time is accurately recovered each time the process is invoked. The second way that the use of absolute time in process #6 can be seen is by pressing and briefly holding the [ON] key. Pressing this key temporarily halts execution of the calculator, causing all processes to pause. When the key is released, however, the bullet of process #6 will quickly "zip" ahead to catch up to where it should be. A similar effect can also be seen by pressing and holding some other key (besides [ON]). Since the keyboard controller causes lots of interrupts in when this is done, it has the effect of heavily loading the CPU. What can be seen on the display is that while the user holds down a key and thereby loads the CPU, the three bullets which do not use absolute timing slow down noticably, while the bullet for process #6 maintains its correct average velocity. The manner in which process #6 "catches up" to where it should be can be seen in the bullet's jumpiness. 4.3.5 Process #7 This process comprises the keyboard scanner. This process simply checks the keybuffer for the [+] key, and if it finds it then the next bullet process is scheduled for execution. If the [.] key is pressed, this process will cause the application to exit and continue with the RPL thread. This process runs approximately 8 times per second. ******************************************************************************* Here's the uuencoded demo application. ****************************CUT HERE*****************************************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