MagiCard Monitor Subroutines
In this section, we describe a number of useful subroutines that are part of the MagiCard Monitor program. These subroutines are contained in read-only memory so it is impossible for them to be overwritten by a programming error. The following information is provided for each subroutine:
1. Subroutine Name—A four letter name for the subroutine. The name is given for convenience only and has no meaning to the monitor program.
2. Subroutine Address—The four-hex-digit absolute address of the subroutine.
3. Subroutine Description—A short description of what the subroutine doe3.
Subroutine Calling Procedure—What input arguments the subroutine has and where they are to be placed before calling the subroutine.
5. Subroutine Outputs—What output arguments are produced by the subroutine and where they are to be found.
6. Subroutine Side Effects—What memory locations and registers (other than those registers and memory locations that are used for the output parameters) are modified by calling the subroutine.
7. Example—An example of how the subroutine can be used.
7.1 Refresh TV Display and Read Keyboard Controllers
Name: DSPL Address: FA6F
Description: Thi? subroutine make3 a display on the TV screen (for one
"frame" lasting one-3ixtieth of a second) and determines if any of the keys on the keyboard controllers were pushed during that time. Any program that is using DSPL to display information on the TV screen must call DSPL at least once each sixtieth of a second to maintain a steady picture. A significant amount of the allowed time between calls to DSPL is taken up by the subroutine itself before it returns. This leaves enough time for the user program to execute about 550 (decimal) average length instructions between calls.
For display purposes, the TV screen is divided into a set of equal-sized rectangular regions called "picture elements" or "pixels". There are forty-two rows of pixels containing forty pixels each. Each pixel can be individually turned "on" (i.e. be seen as a small colored rectangle on the TV screen) or turned "off" (i.e. be seen as a small black rectangle on the TV screen). Furthermore, each pixel has associated with it a unique memory bit (called the "pixel-bit"). When the DSPL subroutine is called, it uses this pixel-bit to control whether or not the pixel will be displayed as "on" or "off". If the pixel-bit is set to one, the corresponding pixel will be "on". If the pixel-bit is set to zero, the corresponding pixel will be "off".
The pixel-bits are stored in memory locations F000 through F0D1. Because of the complicated way the Atari Video Computer System makes a TV display (see Section 6.3), the pixel-bits are stored in memory in a funny way. The subroutine CALP (see Section 7.3) can be used to find the location of the pixel-bit for any desired pixel.
The subroutine is called via the instruction "JSR [A] FA6F". DSPL has no input parameters but it doe3 depend on proper initialization of the Video Computer System Display Generator. This initialization is made by the MagiCard Monitor program whenever a reset is made (e.g. when the system is powered up or when a BRK instruction is executed). Only the colors of the display are likely to be usefully changed in a U3er program. The background color 13 set by storing a value Into location 09« The pixel'3 color is 3et by storing a value into location 08. More details about color control can be found in Section 6.3 in which the Display Generator Is discussed.
location 82: indicates if a new key wa3 pressed on the left keyboard controller. If the contents of this location are negative, no new key has been pressed. If the contents are positive, it Is the value of the key that wa3 pressed (Pressing the "•" key returns a value of OA, and pressing the T key returns a value of OB). If a key is pressed and held down, it will only be reported on the first call to DSPL unless It i3 released and pressed again, location 83: indicates if a new key wa3 pressed on the right keyboard controller, location 8A: indicates if a key is currently being pressed on the left keyboard controller. The contents of this location are set in the same way a3 location 82 except that if a key Is pressed and held down it will be reported on each call to DSPL until it has been released (unlike location 8? where it would be reported only once), location 8B: Indicates if a key is currently being pressed on the right keyboard controller.
The accumulator, X index register, V index register and condition codes are all altered.
DSPL U3e3 the timer function of the 653? RIOT device (see Section 6.1.3). The timer can be read by a user program; however, IT It is altered between calls to DSPL, TV synchronization will he lost.
DSPL uses the "A" I/O port function of the 6532 RIOT device. The I/O port can be used by a user program, but DSPL will modify it each time It Is called.
If the "Game Reset" switch on the Video Computer System console Is depressed when DSPL Is called, a DRK Instruction will be executed forcing a reset of the MagiCard Monitor (see Section 7.15.1). This is a useful way to terminate the execution of a program that calls DSPL. The I-flag In the processor 3tatus register can be 3et to prevent the reset from occurring.
7.2 Store to Program Memory
Name: STPM Address: FFF7
Description: Store the contents of the accumulator into a memory location In program memory (i.e. between address F000 and F3FF). The address at which the accumulator is to be stored Is the sura of a specified sixteen-bit absolute address (called the "base address") and the contents of the Y index register (called the "address offset"). Warning: The sum of the V regis tor and the low order 8 Hits of the base addrpss shouId not Calling Procedure: " exceed FF.
1. Place the least significant byte of the base âôïïrêsâ into memory location 8C.
2. Add four to the most significant byte of the ba3e address and place the result into memory location 8D (i.e., if the base address Is FOOO, zero should be placed Into location 8C and, F'J should be placed into location 8D).
3. Place the value of the address offset into the Y index register.
Place the value to be stored into the accumulator. 5. Execute the instruction "JSR (A) FFF7".
Side Effects: None
Example: The following program fragment stores a one into memory location F106:
LDA [I] 00 clear the accumulator
STA [Z] 8C clear location 8C
STA [ZÎ 80 put value F5 into location 8D
Was this article helpful?