TEXAS INSTRUMENTS Bringing Affordable Electronics To Your Fingertips Graphics Programming Language Prog ramme r"s Guide o ORIGINAL Issu e , MA Y 1979 .=l EV 1S;::" 1 JUNE 19 79 REVIS C:" J OeCZNl BE" 1979 Personal Computer Divis io n ) TEXAS INSTRUMENTS GRAPHICS PROGRAMMING LANGUAGE USER'S GUIDE @ TEXAS INSTRUMENTS INCORPORATED 1979 ALL RIGHTS RESERVED ) Personal Computer Division June 1. 1979 Revised December 3, 1979 ) , I TABLE OF CONTENTS GRAPHICS PROGRAMMING LANGUAGE PAGE Section 1.0 GRAPHICS PROGRAMMING LANGUAGE 1-1 1.1 Overview 1-1 1.2 GPL Instruction synopsis 1-2 1.3 GPL Timing 1-2 1.4 GPL Assembler 1-3 1.5 Software Monitor Reconfiguration 1-3 1.6 Foreign Language Screens 1- 4 1.7 Applicable Documents ' 1-4 Section 2.0 SUMMARY OF SYSTEM ORGANIZATION 2-1 2.1 VDP Organization 2-1 2.1.1 Patterns 2-1 Pattern Name Table 2-2 Pattern Generator Sets 2-2 Pattern Color Table 2-2 2.1.2 Sprites 2-3 Sprite Attribute Block (SAB) 2-3 Sprite Descriptor Block (SDB) 2- 6 Sprite velocity Block , ( SVB ) 2-7 2.1. 3 VDP Text Mode and Multicolor Mode 2-8 2.2 System Memory Organization 2-9 Section 3.0 GPL INSTRUCTIONS 3-1 3.1 Addressing Memory 3- 2 3.1.1 Immediate Field ( IMM ) 3-2 3.1. 2 Global Source (GS ) 3-4 3 . 1. 3 Global Destination (GO ) 3- 4 3.1. 4 Label 3-5 3.1. 5 Addressing Modes 3- 5 3.2 Format Types 3- 9 3.3 Running GPL Programs 3-12 3.3.1 The Status Block 3-17 Maxmem 3-17 Data Stack 3-17 Subroutine Stack 3-18 Keyboard 3-18 Key 3-18 Joystick Y 3-18 Joystick X 3-18 Random Number 3-18 Timer 3-18 Motion 3-19 VDP Status 3-19 Sta tus 3-19 Character Buffer 3-19 Y-Pointer 3-19 X-Pointer 3-19 3.4 The Status Byte 3-22 TABLE OF CONTENTS Page 2 Section 4.0 INSTRUCTI ON DESCRIPTIONS 4-1 4.1 Compare and Test Instructions 4-2 4.1.1 Text Logical High Bit 4-2 4.1. 2 Test Arithmetic Greater Than Bit 4-3 4.1. 3 Test Carry Bi t 4-4 4.1. 4 Test Overflow Bit 4- 5 4.1. 5 Compare Equal 4- 6 4.1. 6 Compare High 4-7 4.1. 7 Compare Logical High or Equal 4-8 4.1. 8 Compare Greater Than 4- 9 4.1. 9 Compare Greter Than or Equal 4-10 4.1.1 0 Compare Log ical 4-11 4.1.11 Compare Zero 4-12 4.2 program Control Instructi ons 4-13 4.2.1 Br anch on Se t 4-13 4.2.2 Branch on Reset 4 - 14 4.2.3 Branch 4-15 4.2.4 Case 4 -1 6 4.2.5 Call Subroutine 4-17 4.2. 6 Fetch 4-18 4.2.7 Return from Subroutine 4-19 4.2.8 Return from Subroutine (Sav e Condition) 4-20 4.3 Bit Manipulation Instructions 4- 21 4.3.1 Reset Bit 4-21 4.3.2 Se t Bi t 4-21 4.3.3 Test if Bit Reset 4-21 4.4 Arithmetic and Logical Instructi ons 4-22 4.4.1 Add 4-2 3 4•4•2 Subtract 4- 24 4 .4 .3 Multiply 4-25 4.4.4 Divide 4- 26 4.4.5 Increment by One 4- 27 4.4.6 Increment by Two 4- 28 4.4.7 Decrement by One 4-29 4.4.8 Decrement by Two 4- 30 4.4.9 Abosolute Value 4- 31 4.4.10 Negate 4- 32 4.4.11 I nve r t 4-3 3 4.4.12 Log ical AND 4-34 4.4.13 Log ical OR 4- 3 5 4.4.14 Exclusive OR 4- 36 4.4.15 Clear Loca t ion 4-37 4.4.16 Store 4- 38 4.4.17 Exchange 4- 39 4.4.18 Push Onto Data Stack 4- 40 4.4.19 pop Off of Data Stack 4-41 4.4.20 Block Move 4- 42 4.4.21 Shift Left Logical 4-43 4.4.22 Shift Right Arithmetic 4- 44 4.4.23 Shift Right Logical 4-45 4.4.24 Shift Right Circular 4-46 TABLE OF CONTENTS Page 3 4.5 Graphics and Miscellaneous Instructions 4-47 4.5.1 Col nc idence 4- 47 4.5.2 Load Backdrop Color 4- 48 4.5.3 Load Screen 4- 49 4.5.4 Formatted Block Move 4- 50 4.5.5 Generate Random Number 4-53 4.5.6 Scan Keyboard 4- 54 4. 5. 7 Execute Machine Language 4-55 4.5.8 Exit GPL 4-57 4.5.9 I/O Instruction 4- 58 4.5.10 BOME 4-59 Appendix A THE GPL ASSEMBLER A-1 Source Pile Format A-1 Assembler Directives A-2 DATA A-2 TITLE A-2 END A-2 EQU A-2 GROM A-3 ORG A-3 BASE A-3 PAGE A-4 LIST A-4 UNL A-4 LISTM A-4 UNLM A-4 GPL MACROS A-s $END A-s $SEND A-s $WBI LE A-s $REPEAT A-s $UNTIL A-s $FOR GO = GS TO GS BY GS A-s $FOR GO = GS DOWN TO GS BY GS A-6 $IF - GOTO A-6 $IF - THEN A-6 $ELSE A-6 $SELSE A-6 $CASE A-6 $GOTO A-7 $CALL A-7 COMPARISON A-7 Appendix B AUTOMATIC SPRITE MOTION B-1 Append ix C AUTO-SOUND INSTRUCTION C-l Table Forma t C-1 Sound Generator Chip (SGC) Control Summary C-3 Attenuation Control C-3 Frequency Control C-3 Noise Control C-4 TABLE OF CONTENTS Page 4 Appendix D HANDSET/KEYBOARD INTERFACE D-1 40-Key Keyboard D-1 Remo te Sa nd se ts D-1 Remote Keyboard D-2 Wired Handsets D-2 Appendix E COINCIDENCE DETECTION E-1 constructing Coincidence Tables for Mapping = 0 E-2 Higher Mapping Values E-4 Append ix F I / O INSTRUCTION F-1 Appendix G TEXT AND MULTI COLOR MODE G-1 Appendix 8 DEVICE I /O 8-1 Monitor Funct ions B-1 System Init ialization H-1 Power-Up Routines B-3 Ge nera l Subroutines Provided by the Mon i tor H- 5 Ex it H-4 8i t Reversal B- 5 writing I / O Routines H-6 Subroutine and nSR Calls B-6 Interrupt Routines B-7 Appendix I CASSETTE DSR 1-1 Definition 1-1 Mode of Operation 1-2 Implementati on 1-2 Peripheral Access Block (PAB ) Definiti on 1-2 I /O Opcodes 1- 7 Open 1- 8 Close 1- 8 Read 1- 8 We i te 1-9 Res tore / Re ''' i nd 1-9 Lo ad 1-9 Save 1-10 De Ie te 1-10 Scratch Record 1-10 Ve r i fy 1-10 Error Codes 1-11 Bad Device Name 1- 11 Illegal Operation 1- 11 Device Er ror 1- 11 Issuing t he Command to the Cassette DSR 1-11 Audio Gate 1-12 Motor Control 1-13 TABLE OF CONTENTS Page 5 ) Appendix J LIST OF INSTRDCTIONS J-1 Alphabetic J-1 Instruction Map J-4 Append!x K FLOATING POINT OPERATIONS K-1 CNS - Convert Number to String K-2 INT - Greatest Integer Function K-3 PWR - Involution Routine K-4 SQR - Square Root Rou t i'ne K-S EXP - Exponential Routine K-S LOG - Natural Logarithm Routine K-6 COS - Cosine Routine K-7 SIN - Sine Routine K-8 TAN - Tangent Routine K-8 ATN - Arctangent Routine K-9 CSN - Convert String to Number K-10 CFr - Convert Floating Point to Integer K-10 FADD - Floating Point Addition K-ll FSUB - Floating Point Subtraction K-ll FMUL - Floating Point Multiplicati o n K-12 FDIV - Floating Point Divide K-12 FCOMP - Floating Point Compare K-13 ) SADD - Value Stack Addition K-13 SSUB - Value Stack Subtraction K-14 SMUL - Value Stack Multiplication K-14 SDIV - Value Stack Division K-1S SCaMP - Value Stack Compare K-1S RADIX 100 - Internal Format K-16 Appendix L 9900 ASSEMBLY LANGUAGE L-1 Append ix M PROGRAMMER/ PLANNER STANDARDS M-l Purpose M-l Screen Processing and Function Key M-2 Usage Screen Formats M-8 Menus, Submenus M-8 Prompts M-9 Multi-Lingual Planning M-ll Glossary Alphabetical Index LIST OF FIGURES AND TABLES Figure/Table Oescr iption Page 2.1 Color Nybble Assignments 2-4 2.1. A Best Color Combinations 2-5 2.2 CPU RAM Memo ry Map 2-10,2-11 2.3 VDP RAM Memo ry Map 2-12 3.1 Syntax for GS, GD 3-7 3.2 Formats of Instructions 3-10,3-11 3.3 Default Character Set 3-13 3.4 VDP Registers 3 - 15 3.4.A Command Register Values 3-16 3.5 Status Block 3-21 4.5. 1 XML Table 4-5 6 A.1 Macr o Expansions A-8,A-9,A- 10 D.1 Console Keyboard D-4 D. 1.A Consol e Ke ybo ard Sex-Code Assignments D- S D.2 Handheld Unit Keyboard D-6 D.2.A Console Keybo ard Mapped as Two Sandheld Units D- 7 D.3 J oy stick Codes D-8 E. l Coincid ence Testing E- 6 E. 2 Coincidence Bi t Table E- 6 E .3 Manually Constructing a Bit Table E- 7 E. 4 Magnification Zero Table E-8 G. 1 Mu l tic olor Mode Scree n Format G-5 LIST OF FIGURES AND TABLES ) Page 2 B. l GROH Header B-2 B.2 Program Header B-2 1.1 PAB Layout 1-6 1.2 I / O Ope odes 1-7 J .2 Instruction Map J-4 M.l Function Key Swruna ry M-8 M.2 CPU-RAM CHart M-14 M. 3 Sprite Table M-1S M.4 Title M-16 M. S Screen Display M-17 1.0 GRAPHICS PROGRAMMING LANGUAGE The system software resident in the pr oduct consists o f a monitor and a GPL ( Graphics Programming Language ) processor. It is the function of the monitor to insure that every time the system is turned on, a new cartridge is inserted, or an existing prog ram terminates, that al l memory and periphera l devices are initialized. The GPL processor is an interpreter optimized to execute GPL programs directly out of GROM . The GPL processor software is coded in TMS 9900 assembly language. 1.1 OVERVIEW GPL is a pr ogramming language specially developed by Texas Instruments to provide the best possible tradeoff of c ode compac- tion, e xecu t ion speed, and ease of program development f or the target computer s ystem. The GPL instruction set facilitates development of programs which make use of the unique features of the system chip set. It is byte oriented , and instruct ion s typically have one or two operands. The addressing scheme is such that most instructions can access either standard microprocess or RAM, GROM, or the vide o scratchpad RAM address space eas i 1y. Mo st instructi o n operands can be either single or d o uble byte values. The addressing modes are : immediate, direct, indirect, indexed. indexed indirect ( with pre-indexing ) , and 't o p of stack'. Source operands and desti na tion addresses can be in the CPU, video RAM, or in GROM. Support for t\ol O stacks is available; a data stack and a subroutine ret ur n address stac k ( allowing arbitrary nest ing of subroutines ) . 1- 1 1.2 GPL INSTROCTION SYNOPSIS GPL has the following types of instructions: "DATA TRANSFER -single or double byte transfers: -block to block transfers -formatted block transfers "ARITHMETIC -add, subtract, multiply, divide, negate, absolute value "LOGICAL -and, or ,exclusive or, shifting "CONDITION TESTS -arithmetic and logical tests "BRANCHING -unconditional and conditional "BIT MANIPULATION -set, reset, and test "SUBROUTINING -call, return, parameter fetching 'STACK OPERATIONS -push and pop "MISCELLANEOUS -random number gener at ion, key- board scan, coincidence detection pattern movement, sound contr ol , TMS 9900 subroutine linking, I / O 1.3 GPL TIMING The GPL interpreter contains an interrupt driven serv ic e r outine which is tied to the video scan. Video symbols may be moved about the screen automatically; also sounds may be generated from a sequence table. These are of the ftset it and forget itft type of instruct ions which free up the control program to do concurrent decision and computational ope rations . The interrupt also controls a software real t ime clock. 1-2 Each system will have a clock byte reserved in the console ROM at location >OOOC to indicate the clock rate for that system. Peripherals may read this byte to adjust their timing interface to the CPU's clock combinations in different consoles. The high nybble contains the integer frequency in megahertz and the low nybble, the fractional frequency. 1.4 GPL ASSEMBLER The assembler for GPL (GPLASM) is written in a mixture of FORTRAN and assembly language and is currently available for installation on 990 / 10 DS minicomputers. The assembler provides standard features such as creation of a list file, cross reference tables, and error flagging. A set of macros is included to help structure GPL programs; these include statements such as: REPEAT ... UNTIL and IF •.. THEN ... ELSE. The output o f the assembler is a 990 object module. 1.5 SOFTWARE MONITOR RECONFIGURATION The monitor code is executed whenever a system restart is required. The system parameters and control values are initialized to default values. A default character set is loaded into the video pattern generator, making it immediately available to GPL programs. This pattern set consists of 64 ASCII characters, including the upper-case alphabet, digits, arithmetic symbols, and punctuation symbols. The monitor is also resp o nsible for determ i n in g t h e existing system configuration. The power-up mo nit o r must pol l 1-3 add-on I/O peripherals and the 'SOLID STATE SOFTWARE CARTRIDGE' to determine which program to execute. The Borne Computer system has been designed to be flexible and expandable. Each plug-in ROM or GROM may contain power-up procedures. These power-up procedures will all be executed allowing for expansion of the power-up routines. A power-up routine may also be replaced by another. 1.6 FOREIGN LANGUAGE SCREENS GPL code has been included in GROM 0 to allow a plug-in GROM. to "translate" the main screen, the menu screen, and the cassette DSR messages to alternate languages. The main screen and the menu screen are "translated" after the screen has been formatted in English but while the screen is turned off (only the ) backgound color is visible on the screen ) . At this time, the plug-in GROM is checked for a negative versi o n number ( byte 1 of the GROM ) . When a negative version number is encountered, a routine is called at >6010 for the main screen 006013 for the menu screen. These locations should contain unconditional branches to the routines in the plug-in GROM that will rewrite the screen in the desired language. These routines may use all of the usual CPU RAM locations (>0 through >6F ) and the full facilities of the Monitor and Interpreter. The routines should end with a RTN instruction . 1.7 APPLICABLE DOCUMENTS • System Monitor Specification 1-4 • TMS 9918 Video Display Processor Specification • TMS 9919 Sound Generation Controller • TMS 9900 Microprocessor Specification • File Management Specification • Borne Computer System Memory, CRU, and Interrupt Mapping Specification 1- 5 ) 2.0 SUMMARY OF SYSTEM ORGANIZATION The system , as supponed by the interpreter, consists ora 9900 mi croprocessor with the following peripheral devices tied to it *A Sound Generation Control ler Chip *A Video Display Processor C hip ·One or more GROM devices • At least one type of keypad entry device T he sound chip interface is discussed in Appendi x C. The GROM is described in System Memory Organization below. The following is a quick summary of the VDP organizati on. For J more detailed information on any orthe system hardware, refer to the appropriate document. 2. 1 VDP ORGANIZATION The VDP RAM contents determine what will appear on the screen. They contain several sub- blocks, each of wh ich is described below. The base address of each sub-block is detennined by the contents of the VDP control regi sters. Also shown are the most commonly used va lues for these registers. These val ues keep all the sub-bloc ks within the first 4K bytes of VOP RAM , and in sure that none of the sub-b locks overlap each other. 2. 1.l PATTERNS The active area of the screen is divided into a grid of 192 pixal s (vertica l) by 256 pixels (horizo ntal). These pixels are then clustered into J 2- 1 8 x 8 pixel groups called Patterns. Thus there are 24 x 32 pattern positions on the screen in the normal mode. There are three sub-blocks of VDP RAM associated with displaying patterns on the screen: • Pattern Name Table (76 8 bytes )- Each byte corresponds to a pattern position on the screen, and its value is the pattern number (0 thru 255 ) displayed at that location . • Pattern Generator Sets ( 8 * 256 = 2048 bytes)- Each block of 8 bytes in the Pattern Generator Set defines a pattern (8 x 8 pi xels); the first 8 bytes correspond to pattern number 0 (as called out in the Pattern Name Table ), t he last 8 to pattern number 255. No te that a pattern is not displayed on the screen until an entry i n the Pattern Name Table calls for it. Als o , a pattern can be disp l ayed in multiple p o sitions on the screen by setting several entr i es in the Pattern Name Table t o the same pattern number . • Pattern Color Table ( 32 bytes ) - Each byte o f the Color Table conta i ns in its left nybble a foreground color (l 's in the pattern ) and in its right nybble a background co lo r ( O's in the pattern ) . The first byte describes c olo rs f or pattern numbers 0 thru 7, the next for numbers 8 thru 15, etc. See Table 2.1 (p age 2-4 ) for color nybble assignments . Table 2.l.A ( page 2-5 ) contains s o me o f the ) best foreground / background combinations. 2-2 2.1.2. SPRITES Sprites are objects that exist essentially in planes in front of the pattern plane. These objects can be moved on a pixel-by-pixel basis, providing for excellent animation capabi- lity. Up to 32 Spr i tes may be on the screen at any time; however, no more than 4 on a given h o rizontal pixel line are allowed (subsequent sprites on that line will not be displayed ) . Three sub-blocks of VDP RAM define the Sprites: • Sprite Attribute Block (SAB) (4 • 32 = 128 bytes ) - Each 4-byte entry in this block describes the positi o n and color of each Spr i te: byte 1- y-position of Sprite (> FF is t op of screen, i.e., vertical position is 1 p ixel less than desired starting posi - tion of sprite); byte 2- x-position of Sprite (0 is left edge of screen); byte 3- pOinter to Sprite Descriptor Block en t ry; byte 4- ear ly clock and color nybble. The pOinters to Sprite Descriptor Block entries, .... hen the recormnended base addresses are chosen , range from >80 to >FF if no Sprite motion is used and from >80 t o >EF if Sprite motion is used (each pOinter points to a succeeding 8 - by:e :,!ock in the S?rite Desc:-i;t or 3! o c "<: . ;'ihen ~::e .:. si"i::.es ( 32-oyte ) are chosen, the pointer value must be an even multiple of 4 (i .e. >80, >84, >88 .. etc. ) and point to a 32-byte block in t he Sprite Descript or Bl o ck. 2- 3 TABLE 2.1 COLOR NYBBLE ASSIGNMENTS NYBBLE VALUE (» COLOR o Transparent 1 Black 2 Green 2 3 Green 1 4 Blue 2 5 Blue 1 6 Red 3 7 Cyan 8 Red 2 9 Red 1 A Yello ..... 2 B Yellow 1 C Green 3 D Magenta E Gray F White When there is more than one shade of the same color, the lo . . . est numbered color is the lightest and the highest numbered color is the darkest (e .g. ; Green 1 is the lightest, Green 2 is medium, and Green 3 is darkest. ) 2-4 TABLE2.1.A BEST COLOR COMBINATIONS BEST SECOND BEST Black on Medium Green Light Blue on Light Green Dark Green on Medium Green Black on Dark Blue Dark Blue on Light Green Black on Light Red Dark Green on Light Green , Dark Green on Light Red Black on Light Blue Black on Dark Yell ow Dark Blue on Light Blue Black on Light Green Black on Dark Red Black on Light Yellow Black on Cyan Light Blue on Gray Dark Blue on Cyan Light Green on White Dark Green on Cyan Light Blue on White Black on Medium Red Dark Red o n White Dark Red on Light Red Dark Green on White Magenta on Light Red Dark Green on Dark Yellow Dark Green on Light Yellow Dark Red on Light Yellow Medium Green on Light Yellow FOURTH BEST Black on Dark Green Black on Magenta Light Green on Bl ack Dark Blue on Magenta Light Bl~e on B~ack Black on Gray Dark Red on Black Dark Blue on Gray Cyan on Black Dark Red on Gray Light Red on Black Dark Green on Gray Medium Red on Light Green Medium Green on White Dark Red on Light Green Dark Blue on White Whi te on Light Blue Magenta on Light Yellow Cyan on White THIRD BEST Light Red on Wh ite Gray on Wh ite Dark Red on Medium Red Medium Red on Light Reden Medium Green on Dark Yellow Light Green on Light Yellow Dark Blue on Light Yellow Medium Red on Light Ye llow Medium Green on Gray Medium Red on Gray Mag en ta on Gray Slack on 'lih'::e . !e -::"u .::J ::ell .:n ;i1 _ :~ ~agen:a on ~ h :te White on Dark Red 2-5 The MSB of byte 4 is set if you want the sprite to come in or go off smoothly on the left side of the screen. I f this bit is not set, the sprite will come in or go off smoothly on the right side of the screen. The right nybble of this byte is the color nybble. A >00 in the first byte of a 4-byte block in the Sprite Attribute Block will tell the system to disregard all following , data in the Sprite Attribute Block. The >00 indicates t o the system that the preceding 4-byte block is the last sprite to be displayed on the screen . • Sprite Descriptor Block (SOB) (3 2*32 = 1024 bytes if no sprite motion is used; 32*28 = 896 bytes if sprite moti on is used since the Sprite Velocity Block begins at >780 ) . The SOB is similar to the Pattern Generator Set area, each block of 8 byt es describes an 8 x 8 pixeled Sprite; alternately, each block of 32 bytes may describe a 16 x 16 pixel Sprite ( .... hen the size bit is set to a 1 in the VDP Command Register 1). When the size bit is set and 4 characters (3 2 bytes ) are used t o make the sprite, the first 8 bytes are the upper left character, the next 8 bytes are the lower left character, the next 8 bytes are the upper right character and the last 8 bytes are the lower right character . For example, if the bytes in a 32-byte Sprite Descriptor Block area are numbered 0 through 2-6 31, this is how the characters would be displayed in a sprite: bytes 0-7 bytes 16-23 bytes 8-15 bytes 24-31 When the magnification bit in the VDP Command Register (1) is set, all sprites double their size, but keep the same pixel dimensions (8x8 or l6xl6 ) . Each pixel doubles its size. This expansion of size is to the right and down. Therefore, an unmagnified sprite on the screen will keep the same upper left c o rner position when the magnificat ion bit is set . • Sprite Velocity Block (SVB) ( 4*32 = 128 bytes ) -Each 4-byte entry in this block assigns motion to the corresponding 4-byte entry in the Sprite Attribute Block: byte 1 - y-velocity of Sprite ( positive number means down, negative number means up ) byte 2- x-velocity of Sprite f90si ~i v e numb~r means :~ght, nega:i~e number means left) 2-7 bytes 3 and 4- reserved for system use (must be initialized to zero ). A velocity can range from 0 to >7F in the positive direc- tion and from >FF to >80 in the negative direction. See Appendix B for more information on Automatic Sprite Motion. 2.1.3 VDP TEXT MODE AND MULTICOLOR MODE The VDP Text Mode and Multicolor Mode as described in the VDP Specification are supported to the extent described in Appendix G. The pr ogrammer may use Text, Multicolor and normal mode in the same program if he chooses. The programmer sh ould be aware, however, that a ne w mapping of VDP RAM into a screen image is created f o r each mode. ) ) 2-8 2.2 SYSTEM MEMORY ORGANIZATION There are three segments of memory associated with the basic system: • CPU RAM: 256 bytes of high speed Read/Write random access memory (Figure 2.2, page 2-10, 2-11). To access CPU RAM in Asssernbly Language, a bias of 8300 is added to the address. • VDP RAM: 4K, 8K or 16K of Read / Write random access memory (Figure 2.3, page 2-12); as discussed earlier, this memory is segmented into sUbbloc'ks whose data map into a screen image; whatever memory is left over is available for GPL programming use. • GROM: Increments of 6K bytes located at 8K-hyte boundar- ies; this is special, medium speed, ROM; it typically contains GPL programs and data. Certain areas of the t hr ee segments are dedicated for special use by the VDP hardware or the interpreter software. See Figure 2.2 (p age 2-10, 2-11 ) for CPU RAM segments dedicated t o the interpreter. See Figure 2.3 (p age 2-12 ) for VDP RAM dedicated fo r use by the VDP chip (no te the base addresses of the sub-bl o cks assume that the recommended values are loaded in the VDP Registers). Also shown in Figure 2.3 ( page 2-12) is a sub-b lock that is used by the Interpreter software for auto-motion of sprites. If auto-motion is not to be used in a GPL ?rogr~m. t hi s memory space is freed up for ot.he~ use. See A?pendi~ 3 for decails on Au:o-Sprice ~o~~on. GROMs have a format pr o toc ol which they must adhere to in order t o maintain system compatibility. See the System Monitor Specification for details. 2- 9 P'IQJRE 2.2 mrIMAL HEX 0 0 , 16 >10 32 >20 48 >30 64 >40 ---------- 80 >4A thru>6D will be >50 '" destroyed when using peripherals 96 >60 ---------- 112 >70 ) STA'lUS = 128 >80 Default s ubr. stack 144 >90 T 160 >AO FREE TCefault Data Stack 176 >50 192 >CO INTERRlJPl' ~PFa: 208 >00 224 >EO :40 > FO Rl3 address of Q04 wr i te address Rl4 Systen flags Sourd tiner in MSBy. Flags for 1'01. Interrupt flag. ard GRCM,IVDP select for sound are in LSBy. RlS address of VDP write address 2- 10 FIGURE 2.2 (Cont.) >CO: Rardon Seed >C2- C9: Re!rote hardset debource >CA: Console Keyboard debource >0::: Soure list pointer >CE: NLnber of sourrl bytes > DO: search p:>inters for > 02: GRCM arrl ReM searches > D4: One byte - stores last VDP (1 ) >06: Screen timeout counter > 08: Save return add r ess for scan routine > CA.: Save player rumber in scan routine Rl3 .. Rl5: Return linkage for interrup t s 2- 11 FIGURE 203 VDP !WI MEHlRY M1\P • DB:IMAL III!X 0 >000 256 >100 PA'I'I'mI NA'!E 512 >200 TABLE (768 byte) 768 >300 SPRITE ATffiI IIlI'E LIsr (128°bytes ) 896 >380 rnEE (96 bvtes ) ( PATl'EFN OJLCR (32 bytes) = 1024 >400 1280 >500 SPRITE DES:::lUProR 0 BLOCKS 1536 >600 (lK) 1792 >700 1920 >780 « SPRITE VELO:ITY 'Il\llLE 2048 > 800 (128 bytes) 2304 >900 2560 >AOO 2816 >BOO PATl'EFN 3072 > COO GENERA'I1:R 3328 >000 AREA 3584 >EOO (2K) :840 > <"00 4096 >1000 *AsSunE!S stardard values in VDP registers. 2-12 3.0 GPL INSTRUCTION S The Graphics Programming Language is similar t o an Assemb l y Language in many respects. Commands are followed by operands which specify addresses and immediate values. The completed program is run through an assembler which generates, for each instruction, the opcode followed by an encoding of the operands. Many instructions can operate on single or , double byte values. In the instruction descriptions of Section 4, this is indicated by a "D" prefix on the mnemonic; for example, the single-byte to single-byte "add" instruction is an ADD, .... hile the double-to-double-byte add is a DADO. The extent of graphics support is through the following: • Almost all instructions can mod i £y locat ions in VDP RAM easily; t his can cause a change in the screen image; • Locations in the Pattern Name Table can be addressed by specifying an X pointer and a Y pointer: • Special instructions allow the reading and writing of large blocks of VDP RAM quickly; • Automatic motion of Sprites can be initiated; after enabling auto- motion with a GPt instruction, motion of sprites is automatically controlled until stopped by another GPL command. GPL instructions fall into severa l classes: • Data Transfer • Arithmetic • :'og ic 3.:" • Condition Tests 3-1 • Bra.nching • Bit Manipulation • Subroutining • Stack Operations • Miscellaneous 3.1 ADDRESSING MEMORY The addressing modes of most instructions allow operands to reside ",nywhere in VDP RAM or CPU RAM. This is called "Global Addressing". Each address above CPU locati o n >7F requires two bytes to specify its address. The next section is a description of all GPL instructions. The mnemonics used f or specifying the operand t ypes required for a given instruction are always of the following types: ) GS (Global Source), GO ( Gl obal Destination ) , IMM (imm ed iate value ) , LABEL ( GPL label). These are each described more fully be lo w. • 3.1.1. IMM An immediate field can be a numeric c onst ant in decimal, hexadecimal or binary format. Depending upon the context, values can be si ngl e or double byte values. In DATA statements doub le-byte values must be preceded by a pound sign (I). The I sign is optional for do uble-byte values in branches, move statements , and double instructions. ) A symbol can be used in an IMM field if it is equated to an immediate value using the assembler EQU directive 3- 2 (commonly used locations in CPU RAM and VDP RAM are often assigned symbolic equates to improve program clarity ). If it is a label in the GPL program, it is a double-byte value unless used in a single byte operation. In th i s case the least significant byte Is used. To illustrate the possibilities: FIVE EQU 5 (now the s'ymbol FIVE can be used wherever IMM is called fori ) 51 •• decimal 51; >33 or 033 .• hexadecima133; &110011 . . binary 110011i 'LOOP .• (if LOOP is a label in the GPL program ) The ASCII equivalent of characters can also be used f or IMM fields. The character(s ) should be enclosed between c olons; e.g. :A: is equivalent to >41 :2A: is equivalent t o >3241 The FMT instruction, to be discusse d later, as well as the asse mble r directive DATA ( in Appendi x A) can use IMM fields of arbitrary length (e .g .• :ABCD1234:) . Instr- uctions that require double-byte IMM operands !legin with a "D" ( e.g . , DADD = Double Add ) as opposed to instruct- ions that do not ( e .g ., ADD = Add ) . The instructions D or DIV, DEC, and DECT require single-byte I~~ operands; wh ile DD or DDtV, DDEC, and DDEr.T ~equ ir e d oubl e-byte I~1 operands. 3- 3 • 3.1.2 GS (GLOBAL SOURCE) Unless otherwise specified for a given instruction, a Global Source operand can be an immediate value (i.e. anything that fulfills requirements for IMM), or an address with any combination of the following features in effect: 1 ) Select CPU RAM or VDP RAM , ( select ROM i n a MOVE statement only); 2) Select direct or indirect addressing; 3) Select indexing or not. There are two special mnemonics that can be used wherever GS is called for : pop and TOP. pop pops the top value off the data stack and uses this data as an operand. TOP uses the data pointed to by the data s tack pointer, but it does not actually p op the data off the stack. POP and TOP should not be used in double-byte instructions. An example of the use of POP and TOP is : ADD POP,TOP This instruction is equivalent to the sequence: ST *DATSTK,@TEMP DEC @DATSTK ADD @TEMP,*DATSTK The ne xt section discusses the Data Stack more fully . • 3 .1.3 GO ( GLOBAL DESTINATION ) Global Destination is exactly the same as G lo ba~ Source except that immediate values are not allowed. 3-4 • 3.1.4 LABEL A LABEL field refers to a symbol which has been used in front of a GPL instruction, or a symbol that has been equated ( using EQU ) to an IMM. A LABEL always generates a 2-byte immediate value (16 bits). LABEL fields are called for in Branch instructions and Subroutine call instructions., A long branch (B) instruction, a CALL subroutine instruction, and a GS or GD of ROM ('LABEL) in a MO VE statement may use labels contained anywhere in the program, but short branch instructions (SR , S5, or $IF-GOTO ) must use labels contained in the same 6K GROM segment as the instructi o n. A special LABEL, "$", is used to represent the current location; ( e.g. "B $" will cause the GPL program to loop forever ) • LABELs can have, in addition to the symb ol, an expression of the fo rm { symbol)+IMM or {symbol ) -IMM; f or example, BR tLAB1+3 or: BR LAB3-1 • 3.1.5 ADDRESSING MODES Table 3 .1 (page 3-7) shows the formats fo r the various mode combinations with an examp le . IMM specifies a numeric constant. If an " at sign" ( @) ?r~ce des ':i:1 !MM value , i: specifies the contents stored at iocation r>lM in CPU RAM. 3- 5 If a star (*) precedes an IMM value, it specifies indirect addressing through location IMM in CPU RAM. For example, A EQU >02 B EQU >04 ST >60, @A ST *A , , @B will take the data stored in CPU location >60 and store it in CPU location >04. A double byte value in CPU RAM can be used as an index to a specified location. For example, A EQO >02 B EQU >0 4 INDEX EQU >06 ) DST >OOOA, @INDEX ST @A(INDEX ) , @B will store the contents of CPU location > OC in CPU > 04. You would obtain the same results with: ST @A (>06) ,@B Notice that indexing takes the double-byte contents located at the CPO RAM address in parentheses and adds that parentheses and adds the double-byte value st ored in value to the CPU RAM address in front of the parentheses. You do not use the @ sign with the index variable. In the case of VDP RAM indexing, the inner parentheses contain t he index value . 3-6 Tl\BLE 3.1 SYNTAX FOR GS, GD .EXNo!PLE la te value for GS only JM! • indicates 2 bytes iII1nediate value t [Alll, 21 C P @ lIM!. Direc t to CPU RA'1 @IOC, @ 30 U • IM>!l Irrlirect to am thru cru RAM *LOC, • 31 @ IM>!l ( 11oM2 ) Direct indexed by and to CPU AAM, @LOCl (I0C2) R *IIMl(IMM2) In:Hrect in::3exed by, thru & to em RAM IOCl (I0C2) A CB, XPI', YPI' Direct to CRT RA'1 at >70, >7E, >7F XPr, CB, YPI' M respectively V AAM (UoMl ) Direct to VDP RAM AAM(LOCl) ,AAM ( 300) D AAM@IM>!l) Irrlirect to VR1>M thru cru RAM !WI(@IOCl) P AAM ( lloM3 (I1oM2 ) ) Di rec t 'iRIl'I indexed by CPU AAM AAM (LOCl (I0C2 ) ) !WI) @IIMl ( IM-!2 ) Indirect to \/RAM. thru & irrlexed by !WI ( @IOC (I0C2 II R CPU AAM , A DISPLAY (X=I/ofoI, Pattern name table * M y.JM! =(I1+1 ) Pattern generator L'« = 00 to FF Tl\BLE ( lMM) Pattern color table L'M = 00 to IF All di.rect SPRITE (IMM) FIGURE (IM1) StRITE attr ibute list IMM • 00 t o IF SPRITE descriptor block LMM = 00 to SF to Vl\aI I , VEL (IMM ) SF!UTE velocity table rn4 .., 00 to IF , I VDP(IMM) VDP register in VDP chip register \'DP(7) I IM1 = 00, to 07 ' GS in HJ\1E statement only I I GS in MJVE statenent only I G OCM(Ut13 ) Direct to ~ IRCM (tDATAl) R RCM (@IMM2) Irdirect to GRCM thru cru AAM !ReM(@IOCl) 0 ReM ( lloM3 (IW>12) ) DIrect to GIn! indexed by CPU FA'! ;RCM ( ,DATAl (LOCl ) ) M I, IM>!l - 1 byte CPU FA'! adress expardable to 6SK. 2 bytes accepted byut need to be one byte to address to CRJ R/l:1. !JoM2 1 byte cru RA'1 address. If 2 byte value is used, the f ir st byte is ignored. DM3 - 2 by t~5 "lRA'of or GRO·1 DDRESS. * - AsstJTIe5 re:cmneoced base address 3-7 El[PLl\NATI(NS FOR '!BE EXJloIIU:s @= (I0C2) 2 byte <''"tent at IOC2 In CIU IWI will be a:lded to = and then addressed to CIU IWI. *= (I0C2) 2LOCI.byteandcontent at IOC2 In CIU IWI will be a:lded to addressed thru that address In CIU IWI to CIU IWI. RAM (LOCl (LOC2» 2 byte content at LOC2 in CPO RAM will be added to 2 byte VDP RAM address LOCI and then _ressed to VDP IWI. RAM (@LOCI.(I0C2» 2 byte content at LOC2 in CPO RAM will be added to the content of c:ru- RAM at LCX:l and then addressed to CPO RAM to obtain 2 byte VDP RAM address. RCM (LOC1(LOC2» 2 byte content of LOC2 at CPO RAM will be added to 2 byte GRa-1 adjress LOCl then addressed to GROt. 3-8 3.2 FORMAT TYPES In the next section you will see that instructions get assembled into several different variations of formats. Each instruction has a "format type" number. Table 3.2 (page 3-9 ) shows all the possible formats, listed by format type. Also shown is the op-code range for each of the format types. The XiS in the formats represent bits that may be turned on or off according to the ope ode for the instruction. Each letter in the format other than X is described on page 3-10 along with the five forms of GS and GO. 3- 9 TABLE 3.2 FCRIAT THE FCRIAT OP OOOES bit f 7 6 5 4 3 210 1 1 IxlxlxlXIXISI!2 AX, BK, at GO ox ,EX I GS bit f 76543210 2 ax, lX bit f 76543210 3 OX,lX bit t 76543210 4 4X,5X,6X, n ) bit t 76543210 5 bit t I olololx lxlx lXlx 76543210 I ax,lX 6 bit t I 11010lxlx lx XID 76543210 GS I 8x,9X 7 QIQIQIOl1101010 08 FOlMAT OOOES bit t 76543210 8 F6 bit t 7 6 5 4 3 2 1 0 r I I I I I: O J 13 'V 1C '! 'N ::L :x Ll'NG1H GO GS 3-10 TABLE 3.2 (Coot. ) o • "10 = SINGLE BYTE OPrnATICN ~ = lXXJBLE Bl'TE OPERATI CN S = = GS I S lUI' IM-IIDIATE = GS IS If.i.lWlATE (1 OR 2 BYTES DEFENDING CN 0 ) 001RVCIN R' ¢O = GO is 1CM 1 = GO is not R01 V = =GO is rot a VDP register Q~ =GO is a VDP register C • is rot RA.." Q~ =GS is RA.." = GS • is rot 101 addressed by au ¢~ =GS is Ra.i irilexed or addressed by a var iable in em RJoM I =GS N = 0 = Number of bytes moved is rot .i.rmediate value 1 = Number o f bytes movoo is i.rmlediate va l ue GS, GO SAVES FOR-1S: I = 0 1 = ADDRESSING '!O FIRSI' 128 BYTES OF cru RA'I; II 1 0 V I ADDRESS V=l S = S VDP RAM; O~ RAM ADORESS (CCNT' D ) 1=1 SELEI:TS INDIREI:T; O=Drn= INDEX III 1 1 V I ADr:rus5 LIKE ABJ\IE, EXCEl':' AN INDEX V1illJE IS ADDED '!O '!HE = s (CCNT' O) AIJ[RE5SIN cru RA'I IV 10 VI 1111 LIKE II WI'lH AIJ[RE5S EXTENDED RANGE 0- 651< ADDRESS V II 11 VI lill LIKE ABJVE II I ADrnESS E:!TENDID ADIRESS AND INDEXED ADDRESS ! INDEX 3-11 3.3 RUNNING GPL PROGRAMS The system Monitor performs the startup of a GPL program. See the Monitor Speeification for details on power-up and restart sequences. It will suffice here to know the state of all RAM and Register locations upon beginning program execution. • A >60 is written to the VDP Command Register, which makes the Start bit a 1; this turns , the TV screen to the background color. • A default character set has been loaded into Pattern Generator Sets 4 thru 11, corresponding to ASCII symbols >20 thru >5F; see Table 3.3. The Pattern Color Table is initialized and all other locations are zero. • Several locations in the "Status Block" in the CPU RAM have been initialized to pre-defined values; these locations are explained in Appendix H under System Initialization. The programmer has the responsibility of initializing the values of the VDP Registers if default values are not to be used. The values in Table 3.4 are the default values. For a system without RAM expansion, these VOP block bases are suggested. 3-12 TABLE 3.3 DEFAULT CHARACTER SET PATTERN i >20 BLANK >30 0 >40 @ >50 P 1 A G " 2 B R i 3 C S >24 $ >34 4 > 44 D > 54 T % 5 E U & 6 F V 7 G W > 28 >38 8 >48 H > 58 X 9 I Y • J Z + K [ >2C >3C < >4C L >5C \ = M J > N ,\ I ? 0 3-13 VDP(l) is the command register. Bit 7 is set if there is a ) 16K chip in the system. This bit should always be reset by the programmer. The interpreter will set the bit if there is 16K. Bit 6 turns the screen on when set. Bit 5 is the interrupt enable bit. The Bit 4 tells the VDP to use text mode when it is set and Bit 3 tells the VDP multicolor mode when it is set. Bits 3 and 4 may not be set at the same time., Bits 1 and 0 tell the system double-size and magnified sprites, respectively, when set. Bit 2 must always be reset. The value in VDP(2) can range from 0 to 15. The Pattern Name Table will begin at location VDP ( 2) • 1024. The value in VDP(3) can range from a to>FF. The Pattern Color Table will begin at location VDP ( 3 ) * 64. The value in VDP (4) can range from a - 7. The Pattern Generator Table will begin at l ocat ion VDP(4 ) * >800. The value in VDP(S) can range from 0 - >7F. The Sprite Attribute List will begin at location VDP (S) * 128. The value in VDP(6 ) can range from 0 - 7. The Sprite Descriptor Block will begin at location (VDP (6) * >800) + >400. The value in VDP(7) contains the only way of giving foreground and background colors to Text mod e . The most significant nybble is the foreground color, and the least significant nybble is the background color and also the border color in any mode. The value of VDP ( l ) will probably be the reg i ster most often changed in a program. Taole 3.4.A ( page 3-15 ) lists s ome of the most common values used in this command register and what they represent. 3-14 TABLE 3.4 VDP RffiIsrrns 7 654 3 210 I 1 4K sr ~ TXT MOl lZE1 Ccmnand Reg. >60-sets VDP for 16K nm I bi ts turn on/off 4K memory, turns 4K or 16K, screen screen on,enables 1 on/off, interrupt VDP interrupt, I I I text mcde, M: mcde Sprite size & mag puts VDP in oorm- I al pattern mode with size 0, mag I I a spri tes i 2 !NT BASE Multiple of 256 a-puts Pattern to start mT at Name Table at o. I I PA'ITERNi i , I 3 CO[QR TABLE ' BASE Multiple of 64 to >OE-puts color to start col. table table at 380 4 PAT GENi Multiple of > 800 >l-puts pattern BASE ' to start pat. gen. genera tor area at>800 5 Multiple of 128 LIsr BASE >06-pu ts Spri te jL--'>--~--...,..-..,..-----l to start SAL, Attribute List at > 300 6 Multiple of >800 ,, SOB BASE , O-puts Sprite jL--':'--"--"-..:.L-'---...,.--l then add> 400 to Descriptor start SOB Blocks at> 400 I 7 TEXT CO[QR Bl\Q(J)R)p COUlRColors for text >F7-make text 1_-_"":'_- ' - - ' - - - - ' - - - 11 mode, backdrop c olor white, 1- , color backdrop cyan 3-15 TABLE 3.4.A COMMAND REGI STER VALUES VALUE MEANING >61 4K memory, screen on, interrupt on, single-sized, magnified sprites. >62 4K memory, screen on, interrupt on, double-sized ~magnified sprites >63 4K memory, screen on, interrupt on, double-sized magnified sprites. > 20 4K memory screen off (viewer sees a blank screen the color of the border) • >70 4K memory, screen on, interrupt on, text mode ( 40 x 24 character screen ) >68 4K memory, screen on, interrupt on, multicolor mode, single sized ~mag­ nified sprit es. >69 4K memory, screen on, interrupt on, multicolor mode, single-sized magni- fied sprites. >6A 4K memory , screen on, interrupt on, multicolor mode, do uble-s ized unmag- nified sprites. >6B 4K memory, screen on, interrupt on, multicolor mode , double-sized magni- fied sprites. 3-16 The actual mechanics of writing and running a GPL program are described in Appendix A. This describes the format of instructions that the GPL assembler will accept. The interpreter and the GPL program communicate with each other through a dedicated location in CPU RAM, called the Status Block. Table 3.5 (page 3-20) shows the fixed locat io ns of each Status Block variable. 3.3.1 THE STATUS BLOCK If any of the byte s in the Status Block are to be a ccessed from a GPL program, it is recommended that the symbols in Table 3.5 (page 3-20) be equated t o the proper values as shown at the beginning of the GPL pr ogram. The symbol can then be used as an instruction operand. The foll owing is a discussion of each of the Status Block by tes: • MAXMEM - Highest available VDP memory address. For a 4K system this would be >OFFF . • DATSTK- Stack pointer f o r data; initialized to >9F by the Monitor , the point er always points to the last value pushed on t he data stack. The data stack is a pre-incremented, byte-oriented stack, and grows to increasing values in CPU RAo'-1. If the use r ,. . ishes, he can change the ~ocation of the stack I';y doii'lg an ST in~o DA'~S':'K ( .:.g. ST >92,~DATS'!'K ) . PUSH and POP affect the pointer value , as we ll as the ope r and POP. 3-17 • SUBSTK- Stack pointer for subroutine return addresses: ) initialized to >7E by the Monitor, the pointer always points to the last address pushed onto the stack. Addresses are automatIcally pushed onto the stack by the CALL instruction, and popped off by the RTN and RTNC instructions . As ."ith DATSTK, the user can change the default address of the stack. The , user s hould be careful ."hen changing this stack pointer. SUBSTK should only be initialized ."ith e ven numbers if it is changed. The MOVE and SCAN instructi ons use one level of subroutine stack. • KEYBOARD, KEY ,JOYY ,JOYX- These locations are used for handset, joystick an d keyboard interfaces. KEYBRD is the keyboard number, KEY is the returned keycode, JOYY and JOYX ) are the returned joystiCk parameters. See the SCAN instruction description for more details. Also see Appendix D. These values are initialized to 0 by the Monit o r. • RANDOM- This location is loaded with a random number when the RAND instruction is executed. It is initialized to a random number generated by the Monito r. • TIMER- When the VDP Frame interrupt is enabled, this byte gets incremented by one every 1/60 second. By clearing it with a CLR and then using the loop ) LOOP CEQ (delay),@ TIMER BR LOOP 3-18 a fixed delay in the GPL program can be implemented. • MOTION- This location, when set to a non-zero value by the programmer, represents the number of Sprites that are i ncluded in auto-motion. F o r e x ample, if it contains a two, Sprites 0 and 1 will be put into auto-moti o n . See Appendix B for details on Sprite auto-motion. • VDPSTT- This location is a copy o f the VDP Status register. It is updated every frame interrupt ( when frame interrupts are disabled, VDPSTT is not updated ) . • STATUS- This byte automatically gets loaded with bits as a result of many instructions. It contains bits represent i ng equality, arithmetic greater than, logical greater than, carry and overflow . See Section 3.4 for details. • CB, YPT, XPT- The se bytes, in conjunction with one another, provide a method f or writing information out t o the VOP Pattern Name Table. When t h e CB location is used as a source operand in an instruction , it is first l oaded wi th the va lue of the Pattern Name Ta ble specified by XP7 and YFT. This ass umes that the Pattern Name Ta ble base address is 0 and the absolute VDP RAM ad dress is calculated by Th i s pr ovid es a conve n ient ~e~hod for read i ng informa ~ lon off o f ~ he screen . I! CB is ever f ound t o h av~ been modified by an instruction, the ne·... value of CB is 3-19 , written to the Pattern Name Table location specified by IPT and YPT. Some examples :" DST t0302,YPT ST CB,@TEMp· •• causes TEMP to get loaded with the byte from l ocation XPT=2,YPT=3; ST @CBRl, CB .. causes whatever , is in CHRl to be written to the screen at the location corresponding to the current values of XPT and YPT. Mu 1 tic 0 lor mode uses YPT and XPT to do mappi ng automatically in range YPT :!t 0 to 47, XPT = 0 to 63. CB, ) XPT, and YPT are predefined symbols and can be used with or without @ sign in front of them. 3- 20 TABLE 3.5 SfA'IUS BLOCl< REXXMMENOED AOORESS ill illITIALIZED '10 SYMB)L CRJRAM (» B\' M:NI-rrn MAXMEM 70, 71 MAXIMUM VDP MEMJRY A!XRESS DATSTI< 72 >9F SUIETK 73 >7E KEYBRD 74 0 = 75 0 JOYY 76 0 JOYX 77 0 AANDCM 78 0 TIMER 79 0 MJTICN 7A 0 VDPSM' 7B 0 srA'lUS 7C 0 CB 7D 0 YPI' 7E 0 XPI' 7F 0 3- 21 3.4 THE STATUS BYTE Two bytes in the STATUS BLOCK are used to indicate the VDP and program status. Five bits in the program status byte, called STATUS, indicate the result of operations. The format of the STATUS by te is: I B / GT / COND I CARRY / OVF / o / o / o I bit 7 6 5 4 3 2 1 o The COND bit is most important, si nc e the BR (Branch on Reset ) and as (Branch on Set ) instructions use this bit to decide whether to branch or not. Many operations affect all the bits, ) especially single and double operand arithmetic / logical instructions. Instructi ons have been provided which transfer one of the other bits into the COND bit; t hi s makes it easy to conditionally branch based on the results of an operation ( See instructions H, GT, CARRY, OVF) . Fo r example, to branch to the LABEL ftBR l ft if the CARRY bit or the OVF bit is set, the fo l lowing sequence can be used: CARRY BS ' BRl o r $IF .CARRY. GOTO BR l OVF BS 4BRl or $IF .OVF . GOTO BRl 3-22 In the instruction descriptions in the following section, the STATUS bits affected for each instruction are shown boxed in. Other STATUS bits are not affected at all. Note that s ome instructions like the branches always reset the COND bit. The format of the VDP status byte, called VDPSTT, is: bit The MSB is a frame interrupt bit. Bit 6 is the f ifth sprite bit and is set any time there are f ive sprites o n a line. Bit 5 is a sprite coinci den ce flag and is set any time th ere is spr i te coincidence. The last five bits are used for the num ber of the fifth sprite on a line . 3-23 4.0 INSTRUCTION DESCRIPTIONS The following pages are a description of each Graphics Language instruction. All instruction descriptions tell how the status byte is affected and give execution results. The symbol := represents "takes the value of.ft Parentheses mean ·contents of", e.g. ·Compare (A) to 48" means "Compare the ,contents of variable A to 48". ) 4-1 4.1 COMPARE AND TEST INSTRUCTIONS H 4.1.1 TEST LOGICAL HIGH BIT Syntax definition: H Examp le: LABl H TEST THE LOGICAL HIGH BIT Definition: Set/r eset condition bit to the logical high status bit value Status bits affected: I 8 I GT I cond I carry I OVF I Execution results: COND:= H Applicati on notes: Use the R instruction to detect whether the logical high status bit was set as a result of the previ ous instruction as a prelude to a condit ion a l branch ( BR or as) For example: 8 BS LAB l or $IF .8. GOTO LAB1 causes a Branch to LABEL "LABl" if t he logical high bit has been set. Op Code: >09 Forma t Type: 5 4-2 4.1.2 TEST ARITHMETIC GREATER THAN BIT GT Syntax definition: GT Example: LABl GT TEST THE ARITHMETIC GT BIT. Definition: Set/reset condition bit to the , arithmetic greater than status bit value. Status bits affected: I H I GT I cond I I carry I OVF/ Execution results: COND:= GT Application notes: Use the GT instruction to detect whether the Arithmetic greater than status bit was set as a result of the previous instruction as a prelude to a conditional branch (BR or BS ) Op Code: >OA Forma t type: 5 ) 4- 3 4.1 . 3 TEST CARRY BIT CA~RY Synt a x definition : CARRY Example: LABl CARRY TEST THE CARRY BI T Definition: Set / reset condition bit to the carry status bit value Status bits affected: I H I GT I c ond I carry I OVF I i Execution results : COND:= CARRY Application notes: Use the CARRY instruction to detect whether there was a carry out of the most significant bit of a byte or word as a result o f the p re- vious instructi o n as a prelude t o a c ondi- tional branch ( BR or BS ) Op Code: >OC Forma t type 05 4- 4 4.1.4 TEST OVERFLOW BIT OVF ) Syntax definition: OVF Example: LAB1 OVF TEST THE OVERFLOW BI T Definition: Set/reset condition bit to the overflow status bit value. Status bits affected: ( B ( GT ( cond I carry I OVF ( Execution results: CONO : = OVF Application no tes: Use the OVF instruction to detect whether an arithmetic overfloW' ( the result is to o ) large or too small to be correctly represented in two's complement representa- tion) has occurred as a pre l ude to a condi- tional branch ( BR or BS ) . Op Code: >00 Format type: 05 4- 5 4.1.5 COMPARE EQUAL CEQ OCEQ Syntax definition: CEQ GS,GD DCEQ GS,GD Example: LABl CEQ 48,@A COMPARE (A) TO 48 AND SET CONDITION BIT ON EQUAL OR LABl $IF @A .EQ. 48 THEN Definition: Compare the GO t o the GS and set the condition bit depending on the result. Status bits affected: I H I GT I cond / carry I OVF/ ? Executio n results: ( GO ) = ( GS ) CONDo = set, if true CONDo = reset, if fa lse Application No tes: Use the CEQ instruction to compare t he GD t o the GS and set the condition bit if they are equal. This is used as a pre l ude to a condi- tional branch ( BR or BS ) . The effect on the status bits is as if GS is subtracted fr om GO and the result compared t o zer o . Op Code: >04 Format type: 1 4-6 4.1.6 COMPARE LOGICAL BIGB CH DCH Syntax definition: CB GS,GD DCB GS,GO Example: LABl C8 @A,@B COMPARE (B) TO ( A ) or AND IF (B) IS LOGICALLY BIGBER THAN (A) SET THE CONDITION BIT LABl $IF @B .B. @A THEN Definition: Compare the GO t o the GS and set the condition bit if the GO is l ogi cally higher than the GS Status bits affected: I H I GT I cond 7 carry I OVF I I Execution results: COND:= (GO ) B (GS) Applicati on Notes: Use the CH instruction to do the comparison GD.B.GS and set the c ondition bit if the relation is true. Use as a prelude to a conditional branch (BR or BS ) . Op Code: >C4 Format t ype : 1 / 4-7 4.1.7 COMPARE LOGI CAL HIGH OR EQUAL CHE DCHE Syntax definition: CHE GS.GD DCBE GS,GO Example: LABl CHE 20.@VALUE COMPARE (VALUE ) TO 20 & SET CONDITION BIT IF or (VALUE) IS LOGICALLY HIGHER THAN OR EQUAL TO 20 SIF @VALUE .HE. 20 THEN Definition: Compare the GD to the GS and set the condition bit if the GO is logically higher than or e qual t o the GS Status bit affected: ( H ( GT / c ond I 7 carry I OVF ( Execution Result: COND :" (GD) HE (GS) Application Notes: Use the CHE instruction t o do the comparis on GO.HE . GS and set the c ondition bit if the relation is t rue. Use as a prelude to a conditional branch ( BR or as ) Op Code: >C8 Fo rmat type: 1 4-8 4 . 1. 8 COMPARE GREATER THAN CGT DCGT Syntax definition: CGT GS,GO DCGT GS,GD Example: LABEL CGT @A,NEW COMPARE NEW TO (A) AND SET CONDITION BIT IF NEW IS GREATER THAN (A) OR LABEL $IF @NEW . GT. @A THEN Definition: Compare the GD to the GS and set the condition bit if GO is greater than (arithmetically) the GS. Status bits affected: I H I GT I c ond , I carry I OVF I } ? Execution results: COND := (GO) GT ( GS ) Application Notes: Use the CGT instruction to do the c omparison GD.GT.GS and set the condition bit if the relation is true. Use as a prelude to a conditional branch ( BR or BS ) Op Code: > CC Forma t type: 1 4-9 4.1.9 COMPARE GREATER THAN OR EQUAL CGE DCGE Syntax definition: CGE GS,GD DCGE GS,GO Example: LABl CGE 82,@B COMPARE (B) TO 82 AND SET CONDITION BIT IF (B) IS or GREATER THAN OR EQUAL TO 82 LABl $IF @B .GE . 82 THEN Definition: Compare the GD to the GS and set the condition bit if GO is greater than or equal to the GS Status bits affected: I B / GT ( cond 7 carry / OVF / • Execution results: COND := (GO ) GE (GS) Application Notes: Use the CGE instruction to do the comparison GO GS and set the c onditi on bit if the relation is true as a prelude t o a conditi onal branch ( BR or as ) Op Code: >00 Format type: 1 4-10 4.1.10 COMPARE LOGICAL CLOG DCLOG Syntax definition: CLOG GS,GD DCLOG GS,GO Example: LABEL CLOG 86.@VALOE SET CONDITION IF RESULT OF 86.AND.(VALUE ) IS ZERO Definition: Perform the bit by bit logical AND operation between GS and GD and set the COND bit if the result is O. Status bits affected: I B I GT Z cond Z carry I OVF I ? Executi on Results: COND:= ( GS ) AND (GO ) = 0 Applicat ion Notes: Use the CLOG instruction t o set CONO if GO and GS have no lis in same positions. Use as a prelude to a conditional branch (BR or BS ) Op Code: > 08 Forma t type: 1 4-11 4.1.11 COMPARE ZERO ez Dez Syntax definition: CZ GO DCZ GO Example: LAB1 CZ @VALUE SET CONDITION BIT IF (VALUE)IS EQUAL TO ZERO Definition: Compare the GO to zero and set the condition bit accord in91y. Status bit affected: I H I GT I c o, nd / carry / OW / ? Execution Results: COND =: (GO ) = 0 Applicatio n No tes: Use the CZ ins t ruction t o d o t he c ompa ri s o n GO = 0 and set the c o ndit i o n bit i f t h e relation is true. Use as a prelude t o a conditi o nal branch CBR or BS ) Op Code: > 8E Forma t type: 6 4-12 4.2 PROGRAM CONTROL INSTRUCTIONS BS 4.2.1 BRANCH ON SET Syntax definition: BS LABEL Example: LABEL BS HERE BRANCH TO ADDRESS OF HERE IF CONDITION IS SET Definition: Branch to address of the LABEL operand if the COND bit is set. After branching the condition bit is rese t. Status bit affected: I R / GT / cond 7 carry / OVF / Execution results: IF (COND.EQ.set ) TIlEN (PC):' LABEL Application Notes: Use the as instruction to branch to another portion of the program depending on whether the condition bit is set . For example if the previous instruction was a SUB that re- sulted in a zero result; the instruction, BS ZERO program execution commencing at the instruction at label "ZERO". NOTE: The LABEL must reside in the same 6K GROM segment as the as instruction. Op Code: >60 :or:nat : '! ':!e: ~ 4-13 4.2.2 BRANCH ON RESET BR Syntax definition: BR LABEL Example: LABl BR HERE BRANCH TO ADDRESS "HERE" IF CONDITION IS RESET Definition: Branch to address of the label operand if the condition bit is reset. After execution the condition bit is reset. Status bits affected: , I carry I OVF I I H I GT I cond Execution results: IF ( COND.EO.O) THEN (PC):= LABEL Applicat ion notes: Use the BR instruc ticn to branch t o another portion of the program depending on whether the condition bit is reset. For example i f the previous instruction was an ADD t hat resulted in a non-zero result the instruct i on, BR NONZ would result in the program commencing at the instruction at "NONZ" in the program. NOTE: The LABEL must reside in the" same 6 K GROM segment as the BR instruction. Op Code: >40 Format type: 4 4-14 4.2.3 BRANCH B Syntax definition: B LABEL Example: LABl B HERE BRANCH TO ADDRESS OF HERE Definition: Branch absolutely to address of the label operand. This branch is unconditi o nai. The condition bit is reset after execution. Status bits affected: / H / GT / c o nd I carry / OVF / Execution results: ( PC): = LABEL Application Notes: Use t he B instruction to unconditionally ) transfer program control t o another por ti o n of t he pr ogram. If t he label HERE is at the address 08; the instruction, B HERE will replace the PC with the value OB. The condition bit will be reset. NOTE: The B instruction should be used to trans fer control between 6K GROM segmen ts . Op Code: >05 Format type: 3 ) 4-15 4.2.4 CASE CASE DCASE Syntax definition: CASE GO DCASE GD Example: LABl CASE @A GOTO NEXT INSTRUCTION FOR (A) EQUAL TO ZERO, TWO MORE IF (A) EQUAL TO ONE, ETC Definition: Add two times the value of the operand to the current GROM Program Counter. Resets condition bit in status. Status bits affected: I B I GT I cond 7 carry I OVF I Execution results: ( PC):= 2 * ( GD ) +PC Application Notes: The CASE instruction is typically followed by a series of BR statements. Since the condit ion bit resets after executing, the BR's are always taken. (Th e BR is used because it is a two- byte instruction while B is a 3-byte instruc- tion). An examp l e of use of the CASE statement is: CASE @NMBR BR LAB l BR LAB2 BR LAB3 If the byte at locat ion NMBR is a 0, branch t o LABl, if a I, branch to LAB2; if a 2, branch to LAB3. NOTE: All the labels have t o reside in t he same 6K GROM segment as the ( 0 ) CASE inst ru c- t ion . .:;:: : .;ce: > 3,; Format type: 6 4-16 4.2.5 CALL SUBROUTINE CALL Syntax definition: CALL LABEL Example: LAB1 CALL HERE CALL THE SUBROUTINE STARTING AT "mE ADDRESS OF THE LABEL HERE Definition: Replace the PC with the address of the LABEL. Place the old PC at the top of the call stack (pointer at CPU RAM >73). Reset condition bit. Status bits affected: I H I GT I cond I carry I OVF I I Execution results: (SBRSTK): -(SBRSTK)+2 ((SBRSTK )) : '(PC) (PC) : =LABEL Application Notes: Use the CALL instruetion to enter a subr outine . Op Code: > 06 Format type: 3 The following table may be used as a reference for determining when it is more economical t o use a subroutine: Instruction Set Length Mi nimum Number of Times Bytes Saved ( m) in bytes Instruction Set is Used n z Times Used 3 or less 4 6 n - 5 5 4 2n - 6 , - ;:1. - 7 3 4n -8 8+ 2 (m-3 )n - (m+1) 4- 17 4.2.6 FETCH FETCH Syntax: FETCH GO Examp l e: LAB1 FETCH @VAL1 FETCH 1ST PARAMETER Definition: Retrieves a byte of data pointed to by the return address on the subroutine stack and increments th is return address by 1. Status bits affected: / H / GT / cond / carry / OVF / Execution results: ( GD ) := (((SBRSTK))) ( (SBRSTK) ) : = ( (SBRSTK ) ) +1 Applications Note: Use the FETCH instruction to pass parameters in line t o a subroutine For example in this sequence, CALL SUB DATA 1,24 SUB FETCH @ARG1 FETCH @ARG2 The FETCH statement at SUB wi ll p lace a 1 in location ARG1 . The next instruction will place a 24 in location ARG2. Upon returning from the subroutine, execution commencences at instruction after the 24. The FETCH instruction uses t .... o bytes of the subroutine stack. The FETCH ins truct ion can only use CPU RAM as GO. Op Code: >88 Format type: 6 4-18 4.2.7 RETURN FROM SUBROUTINE RTN Syntax definition: RTN Example: LABl RTN RETURN WITH 0 TO CONDITION Definition: Replaces PC with the value at the top of the sub- routine stack (pointer at >73 in CPU RAM). Rese ts the condition bit. Status bits affected: I H / GT / cond I carry / OVF / Execution results: (PC) : = ((SBRSTK)) (SBRSTK):=(SBRSTK)-2 COND:=reset Applications Notes: RTN is used to return from a subroutine call ) when you don't care about saving the condition bit value. By changing the value of the top of the subroutine call stack (pOinted to by CPU RAM location >73 ) , the return address may be modified. Op Code: >00 Format type: 5 4-19 4.2.8 RETURN FROM SUBROUTINE (SAVE CONDITION ) RTNC Syntax definition: RTNC Example: LAB1 RTNC RETURN WITH NO EFFECT ON STATUS Definition: Replaces PC with the value at the top of the subroutine stack (pOinter at >73 in CPU RAM ) . Does not affect status. Status bits affected: I H / GT I cond I carry I OVF / Execution results: (PC):= ( {SBRSTK » (SBRSTK ) := (S BRSTK ) -2 Applications Notes: see RTN Op Code: > 01 Forma t type: 5 4-2 0 4.3 BIT MANIPULATION INSTRUCTIONS . Individual bits of memory may be set, reset, or tested using bit operations. The memory bits are numbered 76543210, with 0 being the least significant a nd 7 the most signif ican t bit. The immediate oper"a nd that specifies bit number is truncated to 3 bits . The status byte is modified by these insructions. These instructions are macro-instructions which the assembler converts into equi valent GPL instructions. 4.3.1 RB GD,IMM : . AND IMM1,GD Reset the bit in memory identified by the two operands. The COND bit is set if the resulting destination byte is zero and rese t otherwise. Note that an AND instruc ti on is generated by the assembler. 4 .3.2 SB GD,IMM := OR IMM1,GD Set the bit in memory identified by the two operands. The COND bit is always reset. This instructio n is assembled as an OR instruction. 4.3.3 TBR GD,IMM := CLOG IMM1,G D := SIF BIT ( IMM ) GO .EO. 0 THEN Test the bit in memory identified by the two operands and set the CONO bit if the tested bit is a zero. Otherwise reset the COND bit . This instruction is assemb l ed into a CLOG statement. 4- 21 4.4 ARITHMETIC & LOGICAL INSTRUCTIONS Arithmetic operations work on operands in two's complement form and affect the status byte. The result of an add, subtract, increment, or decrement instruction sets the COND bit if the result is zero, the H bit if logical high, the GT bit if arithmetic greater than, the OVF bit on overfl o w, and the CARRY bit if a carry occurs from the most significant digit. The divide instruction sets the OVF bit if the divisor is less than or equal to . the first byte of the dividend. The compare instructions compare the destination operand to the source operand. For example, a CGT instruction sets the COND bit if the destination is greater than the source . The address fields of these instructions contain one or two operands. In general the first is the source operand and the second the destination. For example, in an add operation the first operand is added t o the second and in a subtract oper ati on the first is subtracted from the second. 4-22 4.4.1 ADD ADD OR A DADD OR DA Syntax definition : ADD GS,GD DADO GS,GD Examp le: LABl ADD 48,@X(ONE) ADD 48 TO ( X) INDEXED BY (ONE) Definit ion : Replace GO with the sum of the GS and GO. Compare the result t o zero and set/ reset status bits to indicate this result Status bits affected: I H I GT I cond I carry I OVF I ' I I I i Execution resluts: ( GO ) := (GS ) + { GD ) Application notes: ADD is used to ad d Twos c omplemen t integer. For examp l e, if the address labeled TABLE contains >FE and the addre ss lab e led NO contains a >Ol ~ the instruction ADD @TABLE,@NO would result in NO containing a FF and TABLE remain ing unchanged. The logical high bit would be set and the o ther b its rese t. Op Cod e: >AO Format type: 1 4- 23 4.4.2 SUBTRACT SUB OR S DSUB OR DS Syntax definition: SUB GS,GD OSUB GS . GO Example: LABl SUB @A.@B SUBTRACT (A) FROM (B) Definition: Replace GO with the GO less the GS. Compare the result to zero and set/reset status bits to indicate this result. Status bits affected : / H / GT / cond / carry / OVF / • I I I I Execution results: (G O ) : . (GO) - (GS) Application notes: Use the SUB instruction to subtract signed integer values. For example, if the location NEW contains a value of 6F and memor y location OLD contains a value of - I i the instruction, SUB @O LD.@NE.W results in the contents of NEW changing t o >70. The logical high, greater than stat us bi ts set, the o thers reset. Op Code: >A4 Format type: 1 4- 24 4.4.3 MULTIPLY MUL OR M DMUL OR OM Syntax definition: MUL GS,GO DMUL GS,GD Example: LIIBI MUL > 4,@1I MULTI PLY >4 TIMES (11) Definition: Multiply the GO by the GS. In the single byte MUL, both operands are single byte values but the result is stored in a double byte l ocation at GO. The 8 most significant bits are stored in the GO. In the double byte DMUL, both operands are d ouble byte values and the result is a four byte value at GO. No status bits are affected. The multiply is an unsigned type. Status bits affected: I H / GT / c ond / carry / OVF / Executi on results: MUL: (GD,GD+l) := (GS ) * (GD ) DMUL ( GD,GD+l,GD+2,GD+3 ) := (GS, GS·l ) • (GD, GD+l ) Application no tes: In the single MUL the GS & GO are a-bit values. The result is a 16-bit value. In the double DMUL , the GS and GO are 16-bit values . The result is a 32-bit value. Fo r example, if location A contains a > F3 and locati on B contains a >82 , the instruction MUL @II,@B would result in location A being unchanged & location 8 containing >78 , and location ( 8+1) containing > 66. Status bits are unchanged. -:p C.::l ce: >Aa Forma t type: 1 ) 4- 25 4.4.4 DIVIDE DIV OR D DDIV OR DD Syntax definition: DIV GS,GO DDIV GS,GO Example: LABl DIV >08,@VALUE DIVIDE TWO BYTES STARTING AT VALUE BY >08 Definition: Replace the GO with the quotient and remainder of GO divided by GS. Compare the result to zero and set/ reset status bits to indicate the result. The divide is of the signed type. Status bits affected: ! H / GT ! cond / carry / OVF / Executi on results: OIV: ( GD ) := ( GD,GD+l )/( GS ) ,(GD+l ) := remainder, DDIV: (GD,GD+l ): = (GD,GD+l,GD+2,GD+3 )/( GS,GS+l ), ( GD+2,GD+3 ) := remainder. Application Note: If the DIV instruction is a sing l e byte instruction, the single byte GS is divided into the double byte GO and the quotient is put in the GO. If the DOlV instruction is used, the two byte GS is divided into t he f our byte GO and the quotient is put into the t·... o bytes at GO; the remainder is placed in two bytes at GD+2. Op Code: >AC Forma t type: 1 4- 26 4.4.5 INCREMENT BY ONE INC DINC Syntax definition: INC GD DINC GO Example: LABl INC @A INCREMENT (A) BY 1 Definiti o n: Replace the GO with the GO plus on e. The result is compared with zero and the status bits are set/r eset to indicate the result of this comparison. Status bits affected: ( 8 7 GT Z cond / carry , 7 OVF I Execu tion results: (GD): = {GO)+l Application notes: Use the INC instruction to count and index byte arrays, add a value of one to an addressable memory location, or set flags. For example, if COUNT contains a zero, the instructi on INC @COUNT places a >01 in COUNT and sets the logical high, and arithmetic greater than status bits, while the condition, carry and over flo·.... status bits are rese t. Op Code: >90 Format type: 6 4- 27 4.4.6 INCREMENT BY TWO INCT DINCT Syntax definition: INCT GO DINCT GO Example: LABl INCT @A INCREMENT (A) BY 2 Definition: Replace the GO with the GO plus two. The result is compared with zero and the status bits are set / reset to indicate the result of this comparison. Status bits affected: I B I GT I cond I carry , I OVF I Execut ion Results: ( GO ) := ( GD ) +2 Applicati on notes: Use the INCT instruction to count and index double byte arrays and add a value of two to an addressab l e memory location . For example, if TEMP contains the address >00 ( i.e. points to the first te mporary two byte locatio n in CPU RAMi the instruction, lNCT @TEMP places a 0002 in TEMP (so that it now points to the next tw o bytes of temp or ary byte CPU RA'1 ) . Op Code: >94 Fo rrna t ty pe : 6 4- 28 4.4.7 DECREMENT BY ONE DEC DDEC Syntax definition: DEC GO DDEC GD Example: LABI DEC @A DECR&~ENT (Al BY 1 Definition: Replace the GO with the GO minus one. The result is compared with zero & the status bits are set / reset to indicate the result of this comparison. Status bits affected: 1HZ GT I cond 7 carry I OVF / Execution results: (GO):= (GD)-l ) Application notes: Use the DEC instruction to subtract a value of one from any addressable operand. The DEC instruction is also useful in counting and indexing byte arrays . For example, if COUNT contains a value of 1, then DEC @COUNT results in a value of zero in location COUNT & sets the condition and carry status bits while resetting th~ logical high , arit hmetic greater than, and overflow status bits. Op Code: > 92 Forma t type: 6 4- 29 4.4.8 DECREMENT BY TWO DECT DDECT Syntax definition: DECT GO DDECT GD Example: LABl DECT @A DECREMENT (AI BY 2 Definition: Replace the GO with the GO minus two. The result is compared with zero and the status bits are set /reset to indicate the result of this comparison. Status bits affected: ( H ( GT ( cond 7 carry ( OVF ( Exe cution results: (GO): = (GD)-2 Application notes: The DECT instruction is useful in counting & indexing two byte arrays. Also, use the OECT instruction to subtract a value of two fr om any addressable operand. For example, if COLOR contains the value >OA the ins truct ion DECT @COLOR would result in the value >08 being st ored in COLOR Op Code: >96 Fo rmat type: 6 4- 30 4.4.9 ABSOLOTE VALOE ABS DABS Syntax definition: ABS GO Example: LAB1 ABS @DX(INDEX) ABSOLUTE VALUE OF (DX) INDEXED BY (INDEX) Definition: Replace the GO with the absolute value of the GO. Does not affect status bits. Status bits affected: ! GT ! B ! cond I carry! OVF I Execution results: (GO): = ABS (GO) Application notes: Use the ABS instruction to take the absolute value of an operand. For example if the location >76 ( joystick Y) contains -4 then ABS @ 76 will result in a +4 at >76. Op Code: >80 Format type: 6 4-31 4.4.10 NEGATE NEG DNEG Syntax definition: NEG GO ONEG GO Example: LABl ONEG @B NEGATE TWO BYTES AT B , Definition: Replace the GO with its t .... o's complement value. Does not affect status bits . Status bits affected: / H / GT / cond I carry / OVF / Execution results: (G O) := -(GO) Applications notes: Use the NEG instruction to make the contents of an addressable memory location its additive inverse. For example if TEMP contains the value of 1, the instruction, NEG @TEMP wo uld result in the value >FF being stored in TEMP. Op Code: >82 Format type: 6 4- 32 4.4.11 INVERT LW DINV Syntax definition: INV GO DINV GO Example: LABl INV @A INVERT (AI Definition! Replace the GD with its one 1 's complement va lue, Does not affect status bits. Status bits affected: / GT / B / cond / carry / OVF / Execution results: ( GD I :" LOGICAL INVERSION ( GO ) Applicat ion notes: Use the INV instruction t o complement an operand . For example if location COUNT contained a zero~ the instructi on INV @COUNT will result in a >FF being stored in COUNT. Op Code: >84 Forma t type : 6 ) 4-33 4.4 . 12 LOGICAL AND AND DA~D Syntax definition: AND GS , GO DAND GS,GD Example: LAB1 AND >FO,@Y SET 4 LSB OF (Y) TO ZERO Definiti on: Perform a bit-by-bit AND operation of the 8 (16) bits in GS with the GO and store the result in the GO. The result is compared to zero and the status bits are set/reset to indicate the result. Status bits affected: I HI I GT I cond I I carry , I OVF I Execution results: (GO) := (GS ) AND (GO) Application notes: Use the AND instruction to perform a logical AND operation between a GS and GO. The AND operation is useful in masking out bits before a comparison. If location X contains a >66 and location Y contains a >OF; the instruction AND @Y,@X would result in X containing a 06. The GT and B status bits will be set and all other status bits reset. Op Code: >BO Format type: 1 4-34 4.4.13 LOGICAL OR OR DOR Syntax definition: OR GS,GD DOR GS,GO Example: LABl DOR FFFE,@VALUE 'OR" THE DOUBLE BYTE IMMEDIATE VALUE FFFE WITH (VALUE) Definition: Replace the GO with the GO ORld with the GS . Compare the result to zero & set/r eset the status bits to indicate this result. Status Bits Affected: ( H 1 GT 1 cond 1 carry 1 OVF 1 i i ' I Execution results: (GD ) := (GS) OR (GD) Application notes: Use the OR instruction to perform a logical OR between the GS and GD. If location A contains >F6 and location B contains a >68 the instruction OR @A.@B would result in location B chang i ng to > FE. The logical high status bit will be set, the rest will be reset. Op Code: >B4 Format type: 1 4- 35 4.4.14 EXCLUSIVE OR XOR DXOR Syntax definition: XOR GS,GO OXOR GS,GO Example: LAB 1 lOR >F8,@A "EXCLUSIVE OR" > F8 WITH (A) A Defini ticn: Excl usively OR the GS and GO and replace the GO with the result. The result is compared to zero and the status bits are set/r eset to indicate the result. Status bits affected: I H 7 GT 7 cond 7 carry 7 OVF I Executi on results: ( GO) :- ( GS) XOR ( GD ) Application notes: The exclusive OR is accomplished by comparing the GO and GS on a bit-by-bit basis. If the bits are both 0 or both 1, the GO is reset; otherwise it is set. If location A contains >88 and location B contains >87, the instruc- tion XOR @A,@B would result in location B changing to >OF. The logical high and greater than status bits will be set, t he rest will be reset. To reverse bits in a byte, do an XOR with a number which has all bits set you want t o reverse. Op Cod e: >B8 4- 36 4.4.15 CLEAR LOCATION CLR DCLR Syntax definition: CLR GO DCLR GO Example: LABl CLR @A STORE ZERO IN (Aj Definition: Replace the GO with a zero. 1 Does not affect status bits. Status bits affected: ( H I GT I cond I carry I OVF I Execution results: (GD):= 0 Applications notes: Use the CLR instruction to replace any ) addressable memory location with a zero. Op Code: >66 Format type: 6 4-37 4.4.16 STORE ST DST Syntax definition: ST GS,GO CST GS,GO Example: LABl ST @X,@TEMP STORE CONTENTS OF LOCATION X IN LOCATION TEMP Definition: Replace the GO with the GS. Status bits are not affec ted. Status bits affected: I H I GT I cond I carry I OVF I Execution results: ( GO):= (GS) Application notes: Use the ST instruction to copy the contents of any addressable memory location or an immediate value into any addressa ble memory location. For example, if location X contains a>88; the instruction ST @X,@TEMP will result in both location X and TEMP con- taining a >88. Op Code: >BC Format type: 1 4- 38 4.4.17 EXCHANGE EX ) DEX Syntax definition: EX GD,GD OEX GO,GD Example: LAB1 EX @X,@Y EXCHANGE THE CONTENTS OF LOCATIONS X • Y. Definition: The contents of the first operand is ex changed with the contents of the second oper and . No sta tus bits a r e affected. Status bits affected: I H I GT I cond I carry I OVF I Execution results: (GO ) (EXCHANGE WITH ) (GO) J Applicati on notes: Use the EX instruction to exchange the co n tents of two locations in memory. For example if location >380 in VDP RAM contains a 03 and location >381 in VDP RAM contains a 05 the instruction; EX RAM(>380 ), RAM (>381) would result in location>380 in VDP RAM containing a 05 & location >381 in VDP RAM containing a >03; thus swapping the colors of pattern set to with pattern set ,1. Op Code: >CO Format type: 1 4- 39 4.4.18 PUSH ONTO DATA STACK PUSH Syntax definition: PUSH GD Example: LABl PUSH @NEWEST PUSH VALUE AT LOCATION NEWEST ONTO DATA STACK Definiti on: Increment the data stack pointer & push the one byte operand onto it. (Opposite of instruction POP). No status bits are affected. Status bits affected: I B I GT ( cond ( carry I OVF / Execut ion resu lts : ( DATSTK) ( DATSTK ) + 1 (( DATSTK)) := (GD) Applicat ion no tes: Use PUSH instruction t o add t o data stack. Opposite of POP. Op Code: >8C Format ty pe : 6 4- 40 4.4.19 pop OFP OP DATA STACK POP Syntax definition: pop GD Example: LABl pop @DAT pop top value off data stack and into location OAT Definition: Pop a byte off the data stack and load it into GO, then decrement the value of the data stack pointer Status bits affected: / H / GT / cond / carry / OVF I Execution results: (GD) := ((DATSTK)) (DATSTK ) (DATSTK ) - 1 Application notes: This is a macro instruction which the assembler accepts. The pop instruction is the opposite of the PUSH instruction. It assembles in to: ST *STATUS,GD The interpreter traps this out to pop a byte of data off the data stack and places it into the GO, then decrements the data stack pointer. 4-41 4.4.20 BLOCK MOVE MOVE Syntax definition: MOVE GS l FROM GS2 TO GO Example: MOVE 21 FROM ROM ( ,TABL) TO RAM (S OO ) Definition: Move the specified number of bytes from the source to the destination. Status bits affected: I B I GT ~ cond I carry I OVF I Ll (GO): = ( GS ) GO: =GOH GS2: =GS2+ 1 GS1: =GSl -1 $IF GSl .GT: 0 GOTO Ll, Ex ecut ion results: The requested number of by tes are transferred from the So urce to the destination. Applicat ion notes: The MOVE instruction is useful wherever a block of data must be mo v ed from one section of memory to an o ther. Note that the byte count is IMM or CPU and a double- byte value.The Source and Destinat io n operands can represent blocks in CPU RAM, VDP RAM, or ROM. In addit ion , the f ollo .... i ng mnemonics can be used: Destination o nly: VDP ( IMM ) . . block of VDP Registers Instead of using a LABEL f or GROM, an tMM field 0-48K, o r a GS poin ting into CPU RAM can be used ( e.g. ROM ( 22), ROM (@ CPULOC ) . Furthermore, an index can be used, as in the norma l addres sing mode (e .g . ROM ( tAB ( A » . The VDP registers cannot be used as Sou rce, since they a re write-only registers. The MOVE instruction uses tw o bytes of the sub- routine stack. Forma t t ype: 9 More examples: MOVE 7 FROM ROM ( 2000 ) TO VDP(l) .. loads up registers 1 th ru 7. MOVE @COUNT FROM @O to @100 .. copy a block from CPU to CPU 4- 42 4 . 4.21 SHIFT LEFT LOGICAL SLL DSLL Syntax Definition: SLL GD, GS DSLL GO, GS Example: LABl SLL @ VALUE,S SHIFT (VALUE ) LEFT LOGICAL 5 BITS Definition: Shift the (GD ) left for the (GS) number of bits. Pill in the vacated bits with logical zeros. Status is not affected. Status bits affected: I H I GT / cond / carry / OVF / Execution results: Shift the ( GO) left for the (GS) number of bits and fill in the vacated bit with zeros. Application notes: Use the shift left logical to shift t he GO. For example, i f VAL has >21 in it, the instructi o n SLL @VAL, 2 results in the contents of VAL bec omi ng >84. OSLL requires a 2-byte shift count. Op Code: >EO Format type : 1 4 -43 4.4.22 SHIFT RIGHT ARITHMETIC SRA DSRA syntax definition: SRA GO, GS DSRA GO, GS Example: LABl SRA @A,@B SHIFT (A) RIGHT ARITHMETIC BY THE NUMBER OF BITS SPECIFIED IN LOCATION B Definition: Shift the (GO) right for the (GS) number of bits. Fill in the vacated bits with the MSB of (G O) . Status is not affacted. Status bits affected: (H ( GT I cond I carry / OVP/ Execution results: See definition Application Notes; An examp le of an a rithmetic right shift is: if location contains a >86; the instruction SR @A,2 .... i ll resu lt in changing location A to be a El. DSRA requires a 2-byte shift count. Op Code: >DC Forma t type: 1 4- 44 4.4.23 SHIFT RIGHT LOGICAL SRL DSRL Syntax definition: SRL GO, GS DSRL GO, GS Example: LABl SRL @VALUE,7 SHIFT (VALUE ) RIGHT 7 BIT POSITIONS Definition : Shift the contents of the GD to the right for the ( GS ) number of bits while filling in the vacated bit positions with zeros. Status is not affected. Status bits affected: I H I GT I cond I carry I OVF I Execution results: See definition Applicati on notes: An example of a logical right shift is: If the double byte location A contains the value >FFEF, then the instruction, ) DSRL @A.3 changes the contents of location A to >lFFD. DSRL requires a 2-byte shift . count. Op Code: >E4 Forma t type: 1 4-45 4.4.24 SHIFT RIGHT CIRCULAR SRC DSRC Syntax definition: SRC GO, GS DSRC GO, GS Example: LABl SRC @A,@B SRIFT (A) RIGHT CIRCULAR BY THE NUMBER OF BITS SPECIFIED IN LOCATION B. Definition: Shift the (GD) to the right for number of bits specified in the GS while filling vacated bit positions with the bit shifted out (LSB). Status bits are not affected. Status bits affected: I H I GT I cond I carry I OVF / Execution results: See definition Application notes: An example of a =ight circular shift is, if locati o n VALUE contains a >A 5, the instruction SRC @VALUE, 1 will result in location VALUE containing a 02. OSRe requires a 2-byte s hift count Op Code : >E8 Format type: 1 4- 46 4.5 GRAPHICS AND MISCELLANEOUS INSTRUCTIONS COINC 4.5.1 COINCIDENCE Syntax definition: LAB 1 COINC GS, GO Example: COINC RAM (>300),RAM(>304) Definition: The Source operand must indicate a Y,X byte pair for object 1; likewise, the Destination operand indicates the Y,X byte pair for object 2: COINe sets the status equal bit if the objects are in coincidence: otherwise it resets the status equal bit. Status bits affected: H I GT I cond I carry I OVE I ) Execution results: COND = (obj ects in coincidence?) Application notes: See Append ix E f o r details on operation of the COINC INSTRUCTION . Op Code : >ED Format type: 1 4-47 4.5.2 LOAD BACKDROP COLOR BACK Syntax definition: BACK IMM Example: LABl BACK 3 LOAD BORDER WITH COLOR 3 Definition: Load the border area of the display with the immediate color specified. Does not affect status bits. Loads VDP register 7. Status bits affected: I H I GT I cond I carry I OVF I Execution results: (VDP reg.7 ) := IMM Application notes: Use the BACK instruction to change the VDP register 7 to change the bo rder c o lor of the display to the desired color. Op Code: >04 Format type: 2 4- 48 4.5.3 LOAD SCREEN ALL Syntax definition: ALL IMM Example: LABl ALL 0 LOAD EVERY BLOCK ON SCREEN WITH PATTERN ,0 (RESIDES AT>0800 ->0807 IN VDP RAM) Definition: Replace every byte in the pattern name table (768 bytes) with the immediate operand. No status bits are affected. Status bits affected: I B I GT I cond I carry I OVP I Execution results: ST IMM,RAM {O) HOVE 767 from RAM ( O) to RAM ( l ) Application notes: Use the ALL instruction to display a repetitive pattern on the entire screen. This can be used to clear the screen. Assuming >900 to >907 (Pattern number >20) contains OO's (which they will at power up fr om the ASCII default character set); the instruction ALL >20 will result in the the sceen getting filled up with ASCII blanks. No status bits a r e affected. Op Code: >07 Format type: 2 4-49 4.5.4 FORMATTED BLOCK MOVE FMT Syntax definition: FMT OPERANDl,OPERAND2.0PERAND3 • • .. Example: FMT BIAS=>20,4('O,2,4,6') Oefinition: Output immediate and variable data to the Pattern Name Table in a controlled, formatted fashion. Status bits affected: I H I GT I cond I carry I OVF / Execution results: The Pattern Name Table is modified; see below, Application notes: The operands of the FMT instruction are encoded by the assembler and placed inline after the FMT op code. The FMT processor in the interpreter is essentially a sub-interpreter in that its ftlanguage" is different from the rest of GPL. The FMT instruction places data into the VDP Pattern Name Table in such a way that the resulting screen image is formatted in the way the programmer desires. The locations XPT and YPT in the CPU RAM are used heavily by FMT to determine where to put the next bytes of data. These locations can be set within the FMT statement; they are updated by the FMT statement also. Some of the FMT capabilities are: • Place a sequence of immediate data across the screen from a defined starting pOint; • Place a sequence of immediate data down the screen from a defined starting point; • Repeat the same immediate data byte or sequence of bytes across or down the screen; • Nest the above features in order to put data up in a rectangular fashion; Each of the OPER&~D5 can be o f one of the : :1 2.2. 0 ..... : :19 : ':I: :na~3: I IMM., IMM, IMM, • •••• ' ( places the data across the screen from starting point specified by XPT,YPT ) ; 4- 50 • IMM, IMM, IMM, •••.• (places the data down the screen from .tarting point specified by IPT,YPT): M('@IMM') (repeats the data from location IMM in CPU RAM across the screen M times, where M is from 1 to 32, or left off for 1, uses the data stack); M'IMM' (repeats the same value across the screen M times; M is from 1 tq 32, or left off for 1); N"IMM" (repeats the same value down the screen N times; N is from 1 to 32); ':character string:' or ·:character string:" (outputs the ASCII equivalents of the character string to the Pattern Name Table; note also that this colon-delimited string can be used wherever IMM is called for in the above formats ) ; N (adds the value of N to YPT, N from 1 to 32 ) ; M (adds the value of M to XPT, M from 1 to 32 ), XPT=IMM (sets XPT to a specified value ); YPT-IMM ( sets YPT t o a specified value ); BIAS=GS (sets the BIAS to a specified value, see below ) ; Upon entering the FMT statement, the BIAS is O. Everyth ing that gets outp ut to the Pattern Name Table gets the value of BIAS added to it. Setting the BIAS to a non-zero value a llows using the same FM~ statement to output alternate character sets, the same character set of different colors, etc. Any sequence of operands to the FMT instructi on may be enclosed in parentheses, and a "loop" count constant used in front of it. The operands inside the ?a:ent~eses ~r~ the~ af!ecti~ely rapeat~d t~e ~u~be[ of times specified by the loop count. Examples of this will be seen below. Furthe rmo re, these loop structures may be nested inside one another. 4-51 If a horizontal boundary is reachec while outputting data to the VDP, 1PT is reset to 0 and YPT is incremented. Thus further data is then output starting at the beginning of the ne xt line. If the vertical boundary is reached, YFT is reset to 0 : 1PT is kept the same ( this means vertical wrap-around will be to the same column ) . Examples: FMT 3" :HELLO:" (Rep eats BELLO 3 times down the screen ) HOME , FMT 32' >EO I ,22 ( '>EO' ,30 < , '> EO' ) ,32, ' >EO I (Puts a border around the screen one character wide of character >EO) FMT BIAS= >AO,XPT=13,YPT=23,':TENNIS:' (Adds >AO to the hex value o f the ASCII characters and puts those characters on the screen ) PAOL I EOU > AS FMT XPT= lS ,YPT=l, 22 "PADL1 " ( Puts 22 of characer >AS d own the screen ) FMT BIAS=>20,2 ( ' @NUM' ) ( Adds >20 to the value stored in NUM and puts 2 of those characters on the screen. ) FMT 3(1" ,29<,3 (' :AAA:' » (Moves pointer one line d own, 29 spaces right, and puts 9 A's on the screen- - repeats this two more times ) FMT BI AS =RAM ( 0 ) ,1 , 2 ,3 , 4 , 5 ,6 ,7, 8, 9,0 {Adds the value at RAM ( O) t o eac h number and puts t ha t character acr oss the screen ) FMT " XPT=O,YPT=O," :MY:",1 ,2 < ,":ARM:",1 ,3<; ":THAT:", I" ,4<,":THROWS:" " (Start ing at the t op c orn e r, puts MY down the s c reen, moves down 1 line, right 2 spaces, puts ARM down screen ; moves down 1 line. right 3 spaces. ?U':3 :':-.:.;-:' .3 owr. ':. :1e 3C:-~~~, :na ves down o ne l i ne , r i ght 4 spaces . puts THROWS down the sc reen. ) Op Code >08 Format type: 7 4-52 4.5.5 GENERATE RANDOM NUMBER RAND Syntax definition: RAND IMM Example: LABEL RAND 25 GENERATE A RANDOM NUMBER FROM o TO 25 INCLUSIVE Definition: Generate a random number fr~m zero to the immediate operand and store this number in location >78 of CPU RAM. Does not affect status bits. If no immediate value is specified, the default is 255. Status bits affected: / B / GT / cond / carry / OVF / Execution results: (RAND) ;= Random number in (OrIMM ) Application notes: Use RAND to generate random numbers. For example, for RAND sprite motion the in- struction, RAND 3 would generate a random number between o and 3 inclusive. There is a useful way to generate the initial seed for the random number: LOOPl RAND SCAN BR LOOPl This method generates a "random" number of calls to RAND, depending on how long it takes for a key to be pressed. All subsequent calls to RAND will thus gene- rate unique random numbers every time the program is run. It is good to use this loop everywhere you do a scan if you need really random ~umce:s. Op Code: >02 Format type: 2 4-53 4.5.6 SCAN KEYBOARD SCAN Syntax definition: SCAN Example: LABl SCAN SCAN KEYBOARD Definition: Scans keyboard specified in >74 in CPU RAM. Returns the keycode in location >75, the Y-position of the joystick in location >76, and the X-position in location >77. The CONn bit is set if a key is found depressed; however, the keypad or keyboard is "debounced" in the sense that if the same key is found depressed as was depressed upon the previous call to SCAN (on the same keyboard ) , the proper keycode is returned, but the COND bit is reset. Status bits affected: ( H ( GT ( cond / carry I OVF / Execution results: >75 := KEY value > 76 : = JOYY > 77 : = JOYX COND := set if new key; reset if old key or no key Applications notes: See Appendix D for details on handsets and keyboards. Assembly Language: There is a keyboard scan subroutine that can be called while executing 9900 Assemb ly Language code. This subr outine is loc ated at location >OOOE in the console ROM. The key- board number ( CPU >74 ) sh ould be specified before calling the subr outine. A BL t o this subroutine will serve the same purp ose as a SCAN instruction in Graphics Language. Op Cod e: >03 Format type: 5 4- 54 4.5.7 EXECUTE MACBINE LANGUAGE XML Syntax definition: XML IMM Example: LABl XML > 05 Definition: Begin execution of 9900 machine language. Use the IMM field to tell where. Status bits affected: I BI GT I cond I carry I OVF / Execution results: Execute 9900 machine language directly. Application Notes: The immediate field of the XML instruction is split into a left nybble (table number) and a right nybble (index into table ) . There are 16 table addresses defined in the CPO address space. See Table 4 . 5.1 for a list of these hardcoded values ( note that they have been arranged so as to insure that at least one table exists in any conceivable plug-in fast ROM ) . The left nybble specifies wh ic h of the 16 tables to get the Branch address from. ) The right nybble is then used to determine which of the 16 addresses in the table to use. Each table can contain up to 16 2-byte entry-point addresses. Note that one can have less if one wishes. As an example of XML, XML >24 causes a branch to the address contained in the fifth entry of Table 2. Upon entry to a routine, the 9900 workspace pointer is set to >83EO and the 9900 ST is set to an unknown value. To return control t o the interpreter, make sure WP is still >83EO and execute a "B *Rl l ft. GPL execution will continue out of the GROM from which he XML was seen, at the address specified by the internal GROM address . To do a keyboard scan in 9900 Assembly Language, do a BL to a subroutine located at location >OOOE in con- sole ROM. Op Code : >OF Format type: 2 4- 55 TABLE 4.5.1 XML TABLE TABLE t roN:TION IIDDRESS ( » 0 FIDA= IOINT OCUTINES "FLTI'AB" 1 OB Forma t type: 5 4- 57 4.5.9 I /O INSTRUCTION liD Syntax definition: I/ O GS,IMM Example: I/O @BLOCK,2 Definition: This is an extended instruction in the sense that the action that occurs depends up o n the value of the IMM field. Specifically, this instruction does SOUND, eRU input and outp ut. Status b i ts affe cted: I H / GT / c ond / carry / OVF ( Execution result: See below. Applicat ion notes: See Appe ndix F f or currently supported uses f or the I / O inst ructi on. Op code: >F6 Forma t type: 8 4 - 58 4. 5 .10 BOME INSTROCTION HOME Syntax Definition: HOME Example: HOME Definition: SET XPT and YPT equal to zero Status bits affected: None Execution results: >7E (YPl'): • 0 >7F (XPl'): • 0 Application notes: The HOME instruction assembles the same as: DCLR YPl' ) ) 4- 59 APPENDIX A - THE GPL ASSEMBLER SOURCE FILE FORMAT GPL source instructions are entered as card images to the assembler in a free field format with the restrictions that LABEL fields must begin in column 1 and Operand list fields must begin before column 25. No imbedded blanks are permitted within an operand list. Blank lines in the source are ignored. The format of a typical instruction is: (LABEL) (INSTRUCTION MNEMONIC ) (OPERAND LIST) (COMMENT) The LABEL field is always optional. It consists of an alpha-numeric string of up to 6 characters the first of which must be non-numeric. Up to 1000 LABELs can be defined in anyone source file. Any label that is defined in a source file can be referred to in t he OPERAND LIST of any other instruction in that ) source file. Note that SYMBOLS ( as defined using the EQU directive ) are exactly like LABELs and their usage is the same . The INSTRUCTION MNEMONI C must be one of the valid mnemonics as described in Section 4 of this manual. The OPERAND LIST must be of the type required by that particular instruction. For instructions that all ow OPERAND LISTs of arbitrary length, this field may be conti~ued up to 16 lines by terminating an OPERAND with a semicolon instead of a comma ( the FMT is an example ) . The comment field must be separated from the OPERAND LIST by at least one space. A comment cann ot be placed on the same line with a SCase macro instruction. In addition, GPL instruction wnich have no oper a nd s ( e.g. CARRY, GT, g, OVF, SCAN , ) RTN, etc.) will only allow comments beyond column 25. A line of source code should not consist of only a label and a comment. A-l ASSEMBLER DIRECTIVES These directives have a format similar to GPL instructions; they can include LABEL fields as well as comment fields. DATA IMM,IMM,IMM, .•. The DATA instruction is used t o generate a sequence of bytes in the Graphics ROM. The address field , contains a list of immediate values or LABELS. In conjunction with the MOVE instruction, the DATA statement provides a way to load up a sequential block of CPU or VDP RAM. For example: MOVE 10 FROM ROM ( tLAB1 ) TO RAM (>300 ) where later on in the source: LAB1 DATA 0,1,2,3,4,5,6,7,8,9 TITLE XXXXXXXX The TITLE directive provides an 8 character string that is printed at the top of each page of listing and included in the object file. It generates no code and should be placed at the very beginning of the source file. ~D The END directive may be used to separate blocks of code. It also is required to terminate the source f il e. (S YMBOL ) EQU I~~ The EQU dir ective assigns t h e immediate field va:ue to the symbol that starts in column one. A symbol may be a one or tw o byte value. A-2 GROM IMM The GROM directive selects which GROM the assembled program is to be in. In the current definition of the system the operand must be less than eight and the maximum length of the program in a GRCM is 6R. The GROM directive sets the assembler location counter to the start of the selected ROM. Remember that if a program is longer than 6144 (>1800) bytes, it must be partitioned into segments. The only way to transfer control from one GROM to another is through the long Branch instruction. However, references can be made to LABELs and SYMBOLs in different GROMS. ORG IMM The ORG directive sets the assembler location counter to the displacement within the currently selected ROM specified by the operand. This is useful for generating data in a different section of the GROM than the program. IMM must be a value from o to >17FF. BASE IMM], IMM2, tMM3, IMM4, IMMs, IMM6, IM.M7 The BASE directive specifies the base addresses for the various sub-blocks in VDP RAM. The seven operands are the base addresses for the Pattern Name Table, Pattern Generator Area, the Pattern Color Table, Sprite Attribute List, Sprite Descriptor Blocks, Sprite Velocity Table, and Object code bias. The default values correspond to the standard configuration and are 0, >800, >380, >300, >400, >780 and O. It is necessary to use a BASE directive only if one wishes to use the special mnemonics in the MOVE instruction, and base addresses other than the defaults listed above are used. A-3 PAGE The PAGE directive causes the listing to continue on a new page. The PAGE statement is not printed. LIST The LIST directive restores printing of the source listing. This directive is required only when UNL ,directive is in effect, to cause the assembler to resume printing. The LIST statement is not printed. UNL The UNL directive inhibits printing of the source listing. The UNL statement is not printed. LISTM The LISTM d i rective rest o res pr i nting of multiple lines of Object code. Th i s d i rective is required only if a UNLM directi v e is in effect. This statement is not printed. UNLM The UNLM directive inhibits printing of multiple lines of object code. Th i s statement is not printed. A-4 GPL MACROS ) These macro instructions are designed to allow implementa- tion of control statements similar to those In high level langua- ges like PASCAL. Table A.I shows the GPL instructions which each macro expands to. The mnemonics for the statements are: Terminator for the $WHILE, SPOR, $IP, $ELSE, , and $SELSE state- ments. $SENO Same as end SEND. When use~ as a terminator for $WHILE and $FOR, it generates a BR instead of a B. $WBILE GO .R. GS Causes the following block to be executed as long as the comparison is true. A list of valid relations is given below. $REPEAT Causes the following block to be executed until t h e comparison in the terminating $UNTIL statement is true. The block is executed at least once. $UNTIL GO .R. GS Terminator for the $REPEAT statement. $FOR GO = GS TO GS BY GS Causes the following block to be executed as a loop. The loop is controlled by a counter specified by the first operand. ~he counter is initialized by the second operand and incremented by the optional fourth operand until it is greater than ( arithmetic compare) the third operand. The range of each GS op erand an d the GD operand is 0- >7F . If there is no fourth operand specified,a default value of 1 is used to increment the second operand. A-S $FOR GO. GS OOWNTO GS BY GS Same as previous statement except that the counter is decremented by the optional fourth operand until it is less than (arithmetic compare ) the third operand. $IF GO .R. GS GOTO LAB The branch is taken if the comparison is true and otherwise execution continues at the next line. N~ END statement is required with this form of SIF. LAB must be a label in the same GROM because the compare generates a BS or BR instruction. $IF GO .R. GS THEN The following block is executed if the comparis on is true. If false it is s k ipped. An END statement must terminate the block. If the "GOTO LAB" or "THEN" is omitted from a S IF statement, the statement is treated as a SIF-THEN. SELSE Terminates a block following an SIF statement. If the comparison was true causes a skip around the following block. If the comparison was false the block is executed. SSELSE Same as SELSE, except it generates a BR instead of a B. SeASE VAR OF LAB1, LAB2, ... Branches to the label in the list whose position corresponds to the value of the operand. ( If the value in VAl{ is 0, then the program branches to LAB1; if the value is 1, then the program branches to LAB2, etc. ) All label s in the list must be contai:1ed in the same GROM as the SeASE stacement. A-6 ~GOTO LAB Branches to the label. Label can be anywhere in the program since the SGOTO generates a long branch. $CALL LAB Calls the label as a subroutine. The c omparisons may take the following relati o ns: • R. • RE. •L• • GT • .GE . . LT. .LE • • DR. • ORE • • DL • • DGT • • DGE. .DLT. • OLE • • EO. • NE • .AND • . DEO. • DNE. .DAND • These rela ticns are used in the log ieal expressions. .B., .HE., .L., .DB., .DSE., and .Dt.. are LOGICAL comparisons . . GT., .GE., . LT., .LE., .DGT., .DGE., .OtT ., and .OLE. are ARITHMETIC comparisons. The relations .AND. or .DAND. generate a CLOG of ) the GS and GD. AdditionallY the relations .R., .GT. , .OVF., .CARRY. may be used without GS and GO arguments to test bits in the STATUS byte. The negating prefix .NOT. may be used before the relation or first argumen t t o reverse the sense of the test. Individual bits may be tested by using the prefix .BITn or .BIT {IMM ) before the first argument ~here n is a bit number from o to 7 or IMM is equated to a number from a to 7. Only the .EO. and .NE. relations may be used and the second argument must be a o or 1. ) A-7 Tl\BLE A.l MICR) EXPNlSICNS .B. B BR as BR BR .G!'. G!' BR as BR 8R .OVF. CNF 8R as BR BR .CARRY. CARRY BR as BR 8R TEST RELATION OF GO "10 GS : .m. em BR as BR BR .NE. em BS 8R BS BS .H. O! 8R BS 8R 8R .HE. CHE BR as 8R 8R • L. CHE as 8R IE IE .GT. CG'I' BR BS 8R 8R . GE. • LT. = = BR BS BS 8R BR IE BR as .IE. CG'I' IE 8R IE BS • AND. = TEST RELATIa/ OF GO "10 0 : BR BS 8R 8R .m. cz BR as BR BR .NE. CZ BS 8R as as All other relat ions of GD to 0 are tested as GO to GS, using Oas the GS. Following are several MACRO instructions with their grap hics language equivalents: 1. $REPEAT $UNTI L GO .lOI'. • H. GS CH GS,GD as (COde following SREPe-AT I 2. $REPEAT $UNTI L GD . HE. GS mE GS,GD 8R (COde following = T I 3. $REPEAT $UNTIL . 101'. GD .J>ND. GS = as GS,GD (COde fo 110.ing SREPC-AT I 4. SREPEAT $UNTI L •OW . OVF 8R (COde following $REFEAT I A-8 Page TWO Ml\CR) EXPl\NSICNS - 'l'1IBLE 1..1 5. ~IEGD .NE. GS em GS.GD as (axle following ~ ) ~ B swmIE 6. $WHUll .BITs GD . EO . 1 ~ = as B >20.GD (axle following ~ ) swmLE 7. $WHILE .CMRY. CJ\RRY BR (axle following ~ ) ~ B swmLE 8. $IF GO. .EO. GS '!HEN em GS.GD BR (axle following $ELSE ) $"ELSE B (Code following ~ ) ~ 9. $IP GO . lXiE. GS '!HEN = BR GS.GD (axle following ~ ) ~ 10. $IF GO .L. GS '!HEN OlE GS.GD as (axle following ~ ) ~ 11. $IF GO .1D1'. .l'ND. GS '!HEN ~ = as GS.GD (axle following ~ ) 12. $IF GO .GT. GS GOIO = 80 .GD (axle following ~ ) 15. $FOR GD = GSl TO GS2 BY GS3 ST GSl,GD B $ + 6 $FOR+6 ADD GS3. GO 5+6 = 3S GS2' GO (Cede fo 110w ing = ) B $FCR+6 ) A-9 PCJ3e 'Itlree M1Cro EXPANSICNS - Table A.l 16. $roR GO = 0 'II) GS ern GO B $+5 $FOH5 INC GO $+5 ror GS,GO BS (Cbde following $END ) $END B $FCR+5 17. $FOR GO = GS ocwmo 0 sr GS,GO B $+5 $FOR+6 D&: GO $+5 = BR GS,GO (OXle following $END) $END B $FCR+6 18. $CASE VAA OF IABl, tAB2 CASE VAA !R tABl BR tAB2 19. $GO'!I) rABEL B = 20. $CAlL tABEL CAll. LABEl. 11-10 APPENDIX B AUTOMATIC SPRITE MOTION Any number of Sprites from 1 to 32 can be set into motion I, in such a way that the direction and speeds of each Sprite are constant, and independent of each other. The MOTION byte in the STATUS BLOCK, which is normally 0, is set by the programmer to the number of Sprites he wants to be governed by auto-motion . If set to N, Sprite (0) thru Sprite , (N-l) in the Sprite Attribute List are set in motion . The Sprites are moved by updating the Y and X pixe l positi ons f or each one in the Sprite Attr ib ute List. A motion control block must be set up in VDP RAM prior to making t he MOTION "byte non-zer o. Th is control bl ock must begin at >78 0 in the VDP RAM. Four bytes are required for each Sprite to be controlled: byte 1: velocity in the vertical direction~ byte 2: velocity in the horizontal direction; bytes 3,4: reserved for system use. The velocity bytes are scaled in such a way that a value of 1 causes the Sprite to move in that direction once every 16 f rame refreshes (o r 16/60 second, ab out ~ second). A value of 16 in a velocity byte causes a movement of one pixel e ve r yo ne-sixtieth of a second, or 60 pps. A p ositive Y velocity causes do .... n .... ard motion, a positive X velocity causes horizontal motion to the right. As an example, if the first t .... o bytes a re 1 and 8, then every 16 frame refreshes the Sprite will move 1 pixel do .... n and 8 pixels to the right. The motion ·... il1 appear to be continuous . ) For a complete example of Sprite auto-motion, see sample program "SPRITES" on the following page. B-1 TI990 GL ASSEMBLER SPRITES 04/12/79 07 ' 55 :3 5 PAGE I TITLE SPR ITES • STATUS BLOCK LOCATION TELLING NUMBER OF MOVING SPRITE 007A 3 "PC EGU >7A 4 • COLOR NUMBER OF BLACK . .' 0001 5 BLACK EGU I 6 , 7 • MAIN PR OGRAM 8 **** •• ****.*.****** •• ***~**~.*******~.**.*********~*** •• 9 . -11-. TELLS BEGINNIt~G LOCA TION OF OBJECT CODE (>6000) 10 GROM 3 I I ORG 0 12 *** HEADER GLOCK 6000 AAOIOI 13 DATA ) AA, 1. 1 6003 000000 14 DATA 0.0.0 6006 6010 15 DATA #PROGI 6008 000000 16 DATA 0.0.0 600B 000000 17 DATA 0.0,0 600E 0000 18 DATA 0.0 6010 0000 19 PRoGI DATA 0.0 601~ bOIC 20 DATA _START 6014 075350 21 DATA 7. : SPRITES : 6017 524954 60lA 4553 22 ••• STORE NUMBE.R OF SPR I 1 ES IN 1'1PC bOIC BE7A20 23 ~, START ST 32, (!MPC "32 SPR iTE S I\LLDWED TO MOVE 24 .*"* LOAD COLOR TABLE THAT CONTAH~S THE SPACE 601F CEA384 25 ST >0 1. RAMD38-l ) . COLOR SPACE BLACK 6022 0 1 26 *** LOAD VDP RECI STER FOR DOUBLE-SIZED SPRITES 6023 390001 27 MOVE 1 FROM ROM(ijVDPREG) TO VDP(l) 6026 016045 29 *** ESTADLISH SPRilE fHTRIn UTE I3i....OC I-\, 6029 310 08 0 29 MOVE 128 FR O!'l Rm1300i 602C A30060 602F 46 30 .... ESTADLISH SPRITE OESCRIPTOR nLOC~ 6030 310080 31 MO VE 128 FROM ROMe«SHAPE ) TO RAM(~4QO ) 6033 A40Q61 6036 46 32 ·re ..... ESTAI3LISH SPPITE \' ELOCITY DLOCI-\, 6037 310080 33 MOVE 128 FROM ROM ! ijSMOTAU ) TO RA I1 (:-760) 603A A78060 603D C6 rlA~ E ALL PATTERN NAME TA~LE I3~AN~ 603E 0720 35 ALL ~ 20 6040 0401 36 GACK DLACK "'GORDER IS GLACV. 6042 05.!J042 37 13 $ 6045 62 38 VDFREG DATA )62 : -2 TI990 CL ASSEMDLER SPRITES 04/12179 07 : 55 : 35 PA GE 40 ** ••••• **** •••••••• *** ••• *** •••••••••••••• + • • **** ••••• +. .,. ~'. 41 4~ •••• * ••••••••••••••••••••••• SPRITE ATTRIDUTE LIST 1 N1TI ALI ZA TI ONS ** ••••••••••• * •• * •••••••••••• , 6046 000080 43 SAL/NT DATA >00.)00.)80,)2.)06.)08,)84.>3 6049 O;:t060B 604e 84 03 604E oe1088 44 DATA . >OC. > 10. >8 e . > 4 .'> 12 , ) 18 . >8e. ) 5 6051 041218 6054 g e0 5 6056 182080 45 DATA >18,)20.>80.)6.) IE .)28. ) 84 .)7 60 59 061E28 605e 8 407 605E 243088 46 DATA ) 24. ) 30, ) 88.)S. )2 A.)38.>SC.)9 6061 082A38 6064 8e09 6066 304080 47 DATA ) 3Q.)40. >80.>A, ) 36 .)4 8, ) 84. ) B 6069 OA3648 606e 840D b0 6E 3C5088 48 DATA ) 3C. ) 50. ) 88.)C.)42.)59. ) 8C, ) 0 60 71 OC4258 6074 8COD , 6076 4 86080 49 DATA > 48. )6Q.)SO ,) E. ) 4E. ) b8 ,) 84. ) F 6079 OE4 E68 607C 840F 607E 547088 50 DATA ) S4 . ) 7Q .)68 . ) 2. ) SA. ) 78.)8C. ) 3 6081 025A78 6084 8 C03 6086 608080 51 DATA ~ 60. ) 80. >e O. > 4 .)66, ) 88 .) 84. ) 5 6 089 046698 608 C 84 0 5 608E 6(9088 52 DATA ) 6C. ) 90. ) 88 .>6, ) 7 2 . >98, >8C .)7 6 0q l 067298 6094 Be07 60 q 6 78A0 8 0 53 DATA ) 78.)AQ. ) 80. ) 8 .)7 E. ) A8. ) B4.)9 6099 087EAB 60qC 84 0 9 609E 84n088 54 DATA ) S4. ) 00. >S8, ) A.)SA. ) 0 8. ~ OC .> O 60AI OAeA[3S 6 0 A4 8COD 60A6 90C08 0 55 DATA >90. >CO . >80 .) C. ) 96 .)C8 .)84. )D 601\9 OC96C8 60AC 8400 60AE 9CD0 88 56 OATA ~ 9C .> DO .)8 8. ) E. > A2. ~ D8. ) 8C. ) F 6081 OEA2D8 600 4 8eOF 6006 A8EGGO 57 DATA >AB. > EO.)80.)2 .)AE. ) E8 .)- 84. ) 4 60D9 02AEE8 60De 8404 60D E 34F088 58 DATA ) B4. >FO, >SS, ) 6 .> I3 A. ) FS , ) 8C .)8 boe 1 O':'CA F8 ~ OC ~ 3c':e 8- 3 TI990 OL ASSEMBLER SPRI TIcS U4/1211'1 t"AGt:. bO • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • ++ •• +.+ bl b;! • SPRITE NOTION TABLE ...................................................... ~ boeb 021000 b3 SMOTAS DATA 2.16. O. O. 2.14 . O. a boe9 COO20E boce 0000 bOCE o~ocoo b4 DATA 2. 12. O. 0. 2. 10. O. 0 6001 0OO20A b004 0000 bOOb 020800 b5 OATA 2,8.0.0,2.~ , O.O b009 000206 bODe 0000 bODE 020400 b6 DATA 2 . 4.0.0. 2 . 2. 0.0 bOEI 000202 60E4 0000 bOEb 040200 67 DATA 4.2.0.0. 6 .2.0.0 bOE9 000602 bOEC 0000 bOEE 080200 68 DATA 8.2.0,0.10.2.0.0 bOFI OOOA02 6 0F 4 0000 6 0 Fb oe0200 b9 D~TA 12.2.0,0.14.2 . 0.0 60F9 OOOEO~ 60FC 0000 60FE 100200 70 DATA 16.2.0 . 0 . 8 . 0.0.0 6101 000800 bl04 0000 610b 00F800 71 DATA 0. -8 . 0 ,0, -2 . -16.0 .0 bl09 OOF EF O blOC 0000 610E FEF200 72 DATA -2 ,- 14 , 0,0 . -2,-12 . 0 ,0 6111 OOFEF . 6114 0000 6116 FE F 6 00 73 DATA -2 . -1 0.0 . 0. -2 . - 8,0,0 6119 COFEFS 611 C 0000 bIlE FEFAOO 7' DATA -2 . -6 .0,0, -2 . -~ .0 , 0 6121 OOF EFC 6124 OC OO 6126 FEFEOO 75 DATA -2.-2 . 0.0.-4 . -2 , 0 ,0 6129 OOFeFE 612C 0000 612E F"'FE OQ 76 DATA -6.-2.0.0 . -8 . - 2.0, 0 6131 OOF8FE 6134 0000 6136 FoFEOO 77 DATA -1 0, -2 .0.0. - 12 . -2 , 0,0 bl39 aOF4FE 613C 0000 613E F2FE OO 78 DATA -14 , -2 , O. 0, - 16, .-2 , O. 0 6141 OOFCF;o 6~J...l oeoo 9-4 , TI990 QL ASSEMDLER , SPRITES 04/12179 07 : 55 : 35 PAQE 80 •••••••••••••••••••••••••••••••••••••••••••••••• ** •••••• , 81 • SPRITE DESCRIPTOR DLOCKS 82 • (SQUAR E. DIAMOND. CIRCLE. TRIANQLEI '- 83 •••••••••••••••••••••••••••••••••••••••••••••••••••••••• 6146 FFFFCO 84 SHAPE DATA >FF.)FF. >CO.) CO. )CO. >CO .)CO.>CO SQ' 6149 COCOCO 614C COCO 614E COCOCO 85 DATA ) CO.>CO. >CO.)CO.>CO.)CO.)FF .)FF 6151 COCOCO 6154 FFFF 6156 FFFF03 86 OATA >FF. :> FF .)03.>0 3 .)03,)03.>03.)03 6159 030303 615C 0303 615E 030303 87 DATA )03.:>03. >03.)03.)03. ) 03, ) FF .)F F 6161 030303 6164 FFFF 616 6 010306 88 DATA ) 01. >03. )06. >OC. > 18 . :> 30. > 60 . ) CO DIAl 6169 OC1830 616C 60CO 616E C06030 89 DATA )CO.)60.>30.:>18.)0(.)-06.)03.)01 6171 18"C06 6174 0301 61 76 80C 0 60 90 DATA ) 80.)CO. ) 60. > 30 .) 18 . ) OC. )0 6 ,)0 3 6179 30180C 617C 0603 617E OJ060C 91 DATA ) 03, )06, )oe.:: 18 . > 30, )60. >eo, > 80 6181 183060 6184 coeo 6186 071F3C 92 DATA ) 07,)lF. ) 3C. )70, ) 60, ) EO. )CQ,)CO CI \ 618 9 7060 EO 618C COCO 618E COCO EO 93 DATA ) CO, :>CO, :: EO, ::60, )70 .. > 3C, :>1 F . >0 7 6191 b0703C 6194 tF 07 6190 EOF83C 94 DATA > EO, ) FB. ) 3C , :: OE, ) 06, > 07, >0 3 , >0 3 6199 OE0607 619C 0303 619E 030307 95 DATA >03 . )03.>07,)06,)OE,)3C.)F8 ,> EO 611\ 1 060E3C 61A4 FeEO blAb 010103 96 DATA > 01. )01. > 03, > 03, :: 06, ;06 , )OC, > OC TRJA 61A9 030606 blAC OCOC 61AE 181830 97 DATA ) 18 ,> 18. ) 3 0,)30 , ) 6 0, :> 60, ) FF , ) FF 61Dl 306060 61134 FFFF 61 D6 808.JCO 98 DATA )80,) 80. ) CO. ) CO, ) 60. ) 60, ) 30 .) 30 6109 C06060 blBe 303 0 613E 18180C 99 DATA ) 18, > 18, )OC.~ OC, > 06 . )0 6. ) FF .) FF 61 C: .JCDt:06 61C4 FFF ?= 1 00 Et~D ERRORS= 0 LEN GTH= 454 <)0 IC6 ) " , 0- ' APPENDIX C AUTO-SOUND INSTRUCTION The sound instruction allows the programmer to control the S ound Generator Chip (SGC) in the system console by means of a pre-defined table in GROM, or VDP RAM. Sound output is controlled by the table and the VDP interrupt service routine. A control byte at the end of the table can tell the interpreter to end sound output, or can cause control , to loop back up in the table. Table Forma t The format of the table is the same regardless of where it resides. The table consists of a ser ie s of blocks, each of which contains a series of bytes which are directly output to the SGC. The exact format of each block is: (block size in bytes ) byte 1 to output t o SGC; byte 2 Interrupt count (unsigned) Since the VDP generates 60 int erru?ts per sec ond I the interrupt count is express ed in units of one-sixtieth of a second. When the I/O instruction is called, upon the nex t occurring VDP interru pt, the first block of bytes is output to the SGC chip. The interpreter then 'Naits for the requested nurn- ber of interrupts ( for example, if interrupt c oun ts are 1, every C-l interrupt causes the next block to be output). Remember that interpretation of GPL continues normally while the SGC control is enabled. The sound control can be terminated by using an interrupt count of 0 in the last block of the- table. Alternatively, a primitive looping control is provided by using a block whose first byte is 0, and the next 2 bytes indicate an address in the same memory space of the next sound block to use. If the first byte is hexadecimal FF, the next two bytes indicate an address in the other memory space. These allow switching sound lists from GROM to VDP or VDP to GROM. By making this the beginning of the entire table, the sound sequence can be made to repeat indefinitely. To initiate sound use the I /O instruction : ) I/O GS, 0 for list in GROM or I / O GS,l for list in VDP RAM, e.g. I /O @FAC, 1 The GS points to two-byte block in CPU RAM which contains the address of the sound list. GPL can also check for completion of an execut ing sound list by testing whether location > 83CE (>C E in GPL ) in CPU RAM is equal to a ( th i s byte is a down-counter and is a only after table-dri v en execution is c omplete. Add ition ally, the address of the sound block current ly executing is in CPU RAM loc ati o ns >83CC and >83CD. Execut ing a sound list ~h:le table-driven soune cont=ol :5 already in progress ( from a previous sound l i st ) causes the old C-2 sound control to be totally supplanted by the new sound instruction. Sound Generator CHIP (SGC) Control Summary The SGC has 3 tone (square vave) generators - 0, 1, and 2 - all of which can be working simultaneously or in any combination. The frequency (pitch ) and attenuation (volume) of each generator • can be independently controlled. In addition, there is a noise generator vhich can output white or periodic noise. Attenuation Control for generato rs 0,1,2 or 3) One byte must be transmitted to the SGC: + + + + + + + + + /1 / REGI /1 / A / REG# = register number (0 ,1,2,3 ) ; ~ • attenuation/ 2 (e.g. A=OOOO = 0 db • highest volume; A=lOOO = 16 db = medium volume; A·1111 • 30 db • off . examples: 1 10 1 0000: turn on gen . 12 t o highest volume; 1 11 1 1111: turn off noise generator (13). You should no t use all three tone generators at ma ximum volume at once. Frequency Control ( for generators 0,1,2 ) Two bytes must be transmitted to the SGC t o control the frequency of a given register. To c ompute the numbe r o f counts from t he frequency f, use: N • 111860 / f ; C-3 byte 1: by te 2: + + + + + + + + + + + + + + + + + + /1 /REGt / N (ls 4 bits) / / 0 0 I N (ms 6 bits )1 Note that N must be split up into its least significant 4 bits and most significant 6 bits (10 bits total) . The lowest frequency possible , is 110 Hz and the highest is 55,938 Hz. Noise Control One byte must be transmitted to the SGC: + + + + + + + + + /1 1 1 0 / 0 IT / S / T = 0 for white, 1 for periodic noise; S - Shift rate (0 , 1,2,3) =Erequency center of noise. s ~ 3 = frequency dependent on the frequency of tone generator 3. For more information on controlling the SGC, see the TMS9919 SGC Specification. Creates a Palling Sound (High to Low) SOUND EQU >00 DTEMPl EQU >02 TR EQU >79 MUSIC EQU >4.00 MOVE 8 FROM aOM ( ;DROP ) TO RAM ( MUSIC ) DST >0039, @DTEMPl >39 = Highest frequency played @DTEMPl = 2-byte temp area C-4 DST MUSIC,@SOUND (Music is a constant , of 400 could be anywhere in RAM BOl DST @DTEMP1, RAM(MUSIC+l) DSRC RAM(MUSIC+l),4 SRL RAM(MUSIC+l),4 OR &lOOOOOOO,RAM {MUSIC+l) I /O @SOUND ,l @SOUND • 2-byte , area for AODR CLR @TR @TR = Timing register ( >79) B02 cz @TR BS B02 DINC @DTEMPl DCGE >0200,@DTEMPl >0200 = Lowest frequency played BR BOl DST iENDROP, @SOUND *Turns s ound off I/ O @SOUND, ° B $ DROP DATA 3,>00, >00, >92.1 ENDROP DA~A 1, >9F, 0 A similar routine c ould be implemented to create a rising sound by storing a low frequency in DTEMPI to begin with, do a DDEC to DTEMP I and a compare l o w with a high frequency value. CREATES AN EXPLOSION SOUND CST ~EX PL, @SOUNO I/ O @SOUND,0 B $ C- 5 EXPL DATA 2 , >E4, >F2, 5 DATA 2, >1:4, >FO, 18 DATA 2 , >E4, >F 1, 16 DATA 2 , >E4, >F2, 14 DATA 2 , >£4, >F3, 12 DATA 2, >£4 I >F4, 10 DATA 2 , >ES I >F5, 9 DATA 2 , >£5, >F6, 8 DATA 2 , >E5, >F7, 7 DATA 2, >E5, >F8, 6 DATA 2, >£5, >F9, 5 DA TA 2 , >E6,>FA , 4 DATA 2 , >£6, >FB, 3 DATA 2, >E6, >FC, 2 ) DATA 2 , >£6, >FD, 1 DA TA 2, >E6, >FE, 1 , 1, >FF,O C- 6 APPENDIX 0 HANDSET/KEYBOARD INTERFACE As mentioned in section 4 of this manual, the SCAN instruction is used to poll the state of the handsets and keyboards on the system. The byte KEYBRD in the STATUS BLOCK is used by the SCAN instruction to determine which peripheral device to look at, as well as how to interpret the , results. Presently, the following peripherals are supported by the SCAN instruction: • 40-KEY KEYBOARD (KEYBRD • 0): When scanning this keyboard, only the bytes KEY, and the COND bit are affected. The layout of the keyboard and the codes returned by each key are shown in Figures 0.1 and D.l.A. If more than one key is depressed at a given time, only one key will be read . • REMOTE HANDSETS (K EYBRD = 0,1,2,3,4) See Figures 0.2, and D.2.A for keycodes assigned to the Remo te Handsets. Note that if KEYBRD ~ 0 , aandsets 1 and 2 are assumed to be adjacent to each other and thus simulate the 40-key keyboard. If KEYBRD = 1.2,3 or 4, the corresp ondin gly numbered handset is scanned; in addition, the joystick is scanned, and each of JOYY and JOYX wi l: get a value returned in them ranging from -7 to +7, depending upon the amount of deviat io n from the neutral position in t he Y a nd X axes res~ ectively. 0- 1 • REMOTE KEYBOARD (KEY BRO' 5) ) Remote handsets 3 and 4 can be mapped into a 40 key keyboard in the same manner as handsets 1 and 2 . • WIRED HANDSETS (KEYBRD = 1,2): See Table 0.3 for keycodes assigned to this type of handset . The joystick behaves similarly to the remote handsets except t h at the range of JOYY and JOYX is limited to values of -4,0, or +4. These values were chosen to make the remote and wired joysticks as compatible as possible . Note there is a pushbutton mounted on the joystick . This button is electrically and logically the same as the key corresp onding t o keycode >C. The console keyboard may be used to simulate tw o 20-key keypads for the wired handsets. ) Note that if t he joystick pushbutton is depressed, it will always be recognized, as it has t he highest priority. The depression of more than 2 keys causes undefined values to be returned. Since the GPL ·p rogram is not immediately alerted that the state of a handset has altered, it is necessary to regu larly scan the handsets, if input from them is desired. The CONn bit in the STATOS byte is set only the first time a given key is found depressed . If the same key is found depressed on successive scans, the successive calls t o SCAN reads the keycode properly, but resets the COND bit. Thus in applicati ons like t~e above, where we .",ish to recognize fresh keystrokes only, the following } code sequence can be used: 0-2 toOPl SCAN BR LOOPl The above code causes GPL to loop until a fresh keystroke is seen. In order to debounce the Fire button a routine must be implemented to make sure it has been lifted before it is detected as being down again. An example of this routine would be: SCANIT SCAN $IF @KEY .EO. @OLDKEY THEN B SCANIT $ELSE ST @KEY, @OLDKEY (operate on KEY ) $END B SCANIT D- 3 -O ---[JJ - '" . >- .... '" ) [] Ql -"" Q - U ~ W Q '" x -f5 ~ ':: I! :; N - -! M . I FIGURE 0.2 ) HANDHELD UNIT KEYBOARD ~- - [] ~ .,.~ "" ~ 0J- '" '" u 0 A ~ . ~ 4- '" '" '" - ~ A --- ~ ~ '" ~ '"A "" N '" ~ ~ '" ~ '" '" U a: 4- '~ ~ " - 0A -. - , ~ I I 1 _ 0 N I o - I <.:l~ , - 'I : - ';:: ~ I ~-;:- I I 1 W - ,, :"'1 - , \, I ,~- TABU! D.3 JOrSTICK CXDES • IIEl.AIlEI:IMAL I'OSITICN Y I'OSITICN ODE (1DU1INTAL ) (vmTICAL) 7 .' PUll Right _11.111 Right _1. . PUll Up Up 1 Near Right Near Up 0 Center Off , center Off >FP (-1) >FC* (-4) Near Left _lUll Left _1. . Near IloIm IloIm >P9 (-7) PUll Left PUll Down ) >F8 Illegal Illegal *These codes to be returned if joystick has only single bi t resolution in any direction. Example Pull Right and Med i UII Down 7. >FC l'}J' I I - - 7 - 4 -I 0 1 4 7 0-8 APPENDIX E COINCIDENCE DETECTION The VDP provides a bit in the VDP status register that is set whenever any Sprites are in coincidence with one another (in this instance, coincidence means that they overlap by at least one pixel of foreground ) . From GPL, this bit is most easily checked by the instruction: CLOG >20,@VSTAT The VDP status byte in CPU RAM is copied from the VOP Status register every frame interrupt; the third bit is the sprite coincidence bit. The COINe instruction in GPL allo .... s the user t o c h eck f or coincidence bet .... een any 2 objects. These may be 2 Spr it es, a Sprite and another obj ect, or any 2 generalize d objects . The strict def ini tion o f c oincidence can be dictated by a bit tab l e the user must provide in GROM; one might desire c oincidenc e to be true ~hen the objects just touch. or a on e dot overlap may be required. Or perha ps coincidence may be true only when object 1 overlaps object 2 exactly. Coincidence statements must be followed by a one-byte mapping value, p lus a 2-byte addr ess pointing to a table in GROM. Mapp ing = 0 g ives the hig hest resolut ion c o inc idence checking, but requires the largest table. Mapping = 1 yields a ta bl e of ~ the size; however, c oincidence err or s of + 2 pixe ls are possible. Mapping = 2 yields one -sixt eenth the table size but can have e:: o rs o f ~4 ? i~ els. Let an ~ object t yp e~ be a set of identical objects. Then 2 sprites which have identical dot patterns are actually of the E-l same object type. To detect coincidence between objects of 2 types (may be the same type) a unique table for this type combination is necessary. Coincidence screening is done on 2 levels. The first, range checking, involves looking at the distance between the objects as well as their individual dimensions (in pixels). If they are out of range, coincidence is terminated , by resetting the condition bit and terminating. If in range, a table lookup is used to determine coincidence. The delta-y and delta-x are found: using them as indices, a bit is read from the table. If it is a 1, coincidence is true, and the cond bit is set; otherwise coincidence is false. Remember that a unique table is required for each combination of object types; e.g. for 2 object types, say girls and boys, three tables are required for complete ) coincidence detec tion: - girls: girls - girls boys - boys : boys Coincidence must always be called with its arguments in the same order that the table was c onstructed for. CONSTRUCTING COINCIDENCE TABLES FOR MAPPING =0 Let Vl and 81 be the dimensions of object type 1 in pixels ( for irregular objects, these are the dimensi o ns o f the circumscribing rectangle ) . Likew i se, let V2 and H2 b e t he ) vertical and horizontal dimensions of object type 2. Let YI, Xl E-2 be the dot position of object type one, and Y2, 12 the same for object type 2 (the origin is at the t op left of the TV screen; object position is the position of the top left dot of the circumscribing rectangle ) . Then let OY be Yl - Y2, and ox be Xl - 12. Then DX, OY, VI' 81' V2 , 82' and the object shapes completely specify whether coincidence is true or not. See Figu re E.l , ( page E-6 ). Imagine object 2 fixed in one place on the screen, and Object 1 mobile. It is not hard to see that after object 1 is more than HI dots to the left of object 2, coincidence i s no longer possible . Similarly after it is more than H2 dots to the right of objec t I, co i ncidence i s not p o ss ibl e. Applying the same logic to the vertical axis, we arrive at the rules for the range c heck: -B1 ,LE. OX .LE. H2 - V1 .LE . OY .LE. V2 After finding DX an d DY to be within this range, the y are used to compute a uniq ue bit index int o the bit tabl e : INDEX = ( OX + B1 ) + ( OY + V1)"(B1 + B2 + 1 ) . The bi t tab l e is mo st eas ily visualized as seen in Figure E . 2 (page E-6 ) . This table is then encoded by bytes; start i ng at the t op left, working t o the r ight . then g o ing t o the second row and repeat ing. T h e easiest way t o manually construct a bit - ta bl e is t o draw object 2 on grap h paper , letting each s qua re r e present a p i xe l . T hen cut ou t obj ect 1 f ro m anothe: sheet. Starting ·... ith object 1 at the t op l eft c orn er of obj ect 2 ( c ir cumscr ibin g E-3 rectangles just touching), move it to the right, generating a 1 or a 0 each movement. An example is shown in Figure E.3 (page E-7). Then repeat the same with object 1 down by one dot. This technique is repeated through the row In which object 1 is just touching the bottom of object 2 . The table in GROM requires a 4 byte header. The exact struc ture is: (label) DATA (vertical size of table less 1 ) DATA (horiz. • • • • . ) DATA ( V1 ) DATA (Hl ) DATA (bi ts , grouped in 8'5) In the example from F igure E.3, we have ) EXAMP DATA 4 DATA 5 DATA 2 DATA 2 DATA >73 .>FF .>FF .>FF (2 scrap bits at end ) ; HIGHER MAPPING VALUES By specifying MAPPING values greater than 0, one can make the bit table more compact; however , accuracy of detection su ffe rs. I n the case of MAPPING ""1, instead of a one- to-one mapping of OX,OY pairs onto bits of the table, 4 combinations of OX,OY all map into one bit. Thus the bit table is smaller, but it is necessary t o lose detection resolution. E-4 To con~truct a tab le for MAPPING = " con~truct a magn1f1cat1on 0 table rir~t ( ~ee Figure £.4 (page E-8 ) j note that . the object~ are not ~hown 1n this example ). Then draw 2x2 boxe.s on the table, starting at the box corresp o nd in g to OX=O , ' , DY=O,'. A new table 1~ then constructed; each group of 4 pixels in a box are compacted down to one pixel (V , and H1 are half the1r actua l ~ize). Note that: -small 2x' boxes on the edges reduce a single bit; -the single bit should reflect the pred o minant value of the cluster; -in the cases of 2 one3 and 2 zer 03. the user has a choice, depending on if he wa nts coincidence to predominate . To make a table of MAPPING =2, do the same process, but make 4x 4 boxes on the 2 d im ensi onal table ( the f irst box is at OX ; 0,1,2,3, DY :: 0,1,2 ,3 ) · Now V 1 a nd H1 are one -f ou rt h their actual size. Note that res olution of coincidence suffers greatly because now we have 16 comb i nations of OX and or mapping into one bit. The concept of MAPPING lends itself well t o changing the magnificat ion s of sprites. If a MAPPING:: a table is designed for tw o mag 0 sprites, the same tabl e can be usee for checking coincidence when mag:: " by merely calling COINC with HAPPING:: 1. Remem ber though that coincidence resolution goes down. Note that .!..!!.1. object can be used in coincidence detection; all t~at. is :"'equi:-ed is t.:'lat a 'f , X by~e pair ex:'st.s i:1 ::.::"l~ iJ'J ? RAM for that obj ect. Not.e also th~t the object can ~e pure:y flctitious as far as the TV screen is concerned. E-5 OBJECT 2 .----, , , OBJECT 1 - ~--'----' FIGURE E.1 I ... _ _ ..J DY=-l DX=-2 V1= 3 H1= 4 V2= 3 H2= 2 ) •.... • '" .... ., . .:t-. . . . ~.... ~ . . . . .... c • •.... • ~rv ~rv -VI o 0 1 1 0 1 o 1 1 00 1 1 -V 1+1 1 1 1 1 1 0 o 0 000 1 1 -VI+Z 10 0 o0 1 o0 1 -I o 0 C a o0 1 +1 o 0 1 10 0 1 1 1 VZ-I o 1 1 Vz o 1 0 FI GURE E. 2 E- 6 ) GENERATED 0 1 1 1 0 I 1 ,.---+---, _ _ _)~ 1 GENERATED 1 1 1 1 1 2 2 GENERATED 1 1 1 1 1 > 2 GENERATED 1 1 1 1 2 GENERATED 1 1 1 1 1 1 DX · 2 - 10+1+2+3 1 , - 'J - l ) FI GURE E, 3 -1 1 1 1 1 1 1 a 1 1 1 1 1 1 . +1 1 1 1 1 1 1 . . . .1, .1, T,- 1 1 + 1 + 1 + E- 7 " ) -3 -2- 1 012345 -6 0 o 1 1 0 1 0 1 1 0 -5 0 1 1 11 0 11 1 o 0 11 -4 0 0 1 1 1 o 0 o 0 0 -3 1 o 1 1 1 1 0 1 1 I 1 0111 1 1 -2 1 1 1 1 1 o 1 1 1 1 1 1 101 1 -1 1 1 1 o 1 o 1 1 1 I 1 > 11111 1 o 0 1 0 o1 o1 1 1 1 1 0 111 1 1 1 o0 1 1 1 1 1 1 1 101 1 1 1 2 0 o0 o0 1 1 1 1 0 3 1 o1 1 1 1 1 1 0 1 FIGURE E. 4 TABLE : DATA4 ) DATA 5 DATA6 DATA3 DATA>7F, >BF, >EF, >BC ) E- 8 APPENDIX F I/O INSTRUCTION The I/O instruction is used to control a variety of input-output devices including cassettes, speech, sound, and CRU. The f ormat of the I /O instruction is: I /O GS. IMM where GS is the address of a list wh ose format depends on the value of IMM. IMM specifies the type of input-output. Currently supported values of IMM are: o ~ Sound in GROM 1 = Sound in VDP RAM 2 = eRU input 3 • CRU output 4 = Cassette write 5 = Cassette re ad 6 = Cassette verify The f ormat o f the list specified by GS for sound I /O instructions is g iven in Appendix C. The format of the lists for CRU output is the same . GS po i nts t o a 4 byte block in CPU RAM . The f ormat of the bloc k is: bytes 0 and 1 - eRU base addr ess . The in terp reter wi l l double this f or you since the 9901 ignores the least sign ifican t bit of the base :eg i ster . oyte 2 - The number o f bi:s t ~ i~ p u t ur output (1 -16 ) F-l byte 3 - A pointer to a one or two byte area ) in CPO RAM to write from or read to. If the number of bits to read or write is greater than 8 then this address must be even. The CRU data to be written should be right justified in the byte or word . The least significant bit will output to or input from the CRU address specified by the CRU base address. Subsequent bits will come from or go to sequentially higher CRU addresses. If the CRU input reads less than 8 bits, the unused bits in the byte are reset t o zero. If the CRU input reads less than 16 but more than 8 bits, the unused bits in the word will be reset t o zero. The three different cassette I / O instructions use the same ) list format. This list must be in CPU RAM. bytes 0, 1 - are the length of the data transfer (or the number of bytes t o verify). This lengt h is rounded up t o the nearest multiple of 64. by te s 2, 3 - are the source or destination address in VOP RAM or the addres s of the bytes to verify the tape. The read and write instructions physically perform I / O to the cassette. The verify instruction will read a tape and compare it, byte for byte, against what is in the specified VOP RAM area . It •... ill set the status in CPU RAM loc ati o n 7C if any differences are detected. F-2 The I/O instructions for cassette will not generally be used by the application programs. There is a cassette program written in GPL that should be used by the application programs. This program will uniformly request the user to perform certain manual operations necessary to the operation of the cassette. This cassette program is described in Appendix I . F- 3 APPENDIX G TEXT AND MULTI COLOR MODE When the '1'ext" lIode' bit -(bit '4) · In VDP register 11 . Is set, 40-character mode is selected. ' The screen is 40 :r: 24 Jcharacters with each character being 6 x , 8~ dots . The Pattern Name Table is now 960 bytes long and is In locations 0 .- ~_ 3BP -in VDP RAM. Each byte in the Pattern Name Table corresponds , to a pattern position on the screen (0 - 27, first row: 28 - 4F, second row; etc.). The pattern ' numbers "are still O. - 255;. corresponding to VOP 800 . .- ' FFF, but in text mode the last , 2 btts of each . byte in the patterns are ignored -, making the .6.. x 8 dot ~ patterns. The only means of changing the screen in text ~ode is to write the pattern numbers to the Pattern Name Table position. There is not a color table to use with text mode. The only way to give color t o the ) patterns is by loading VOP (7) with the foreground /background combination desired . When the MeMO bit (bit 3 ) in VDP register '1 is set, the multicolor mode is selected. Each 8 x 8 dot pattern on the screen is now divided into four quadrants (4 x 4 dots each ) . Each quadrant must be given a nybble assignment -in the pattern generator block before you can use multicolor mode correctly. The nybble s used in the pattern generator block are from RAM 800 th r u OFF. The ny bble ass ignments are made with a fo rrna t sta tement as follows: aOME FMT 4 ( , > 00 , >01, >02 ... >IF I ) , 4 ( , > 20, >21, >22 .. . > 3F' ) . 4 ( , >40, >41, >42 .• . > SF I ) , 4 ( , >60 , > 61, > 62 • . . > 7F I ) , 4 ( , >80, >81, >82 ... >9F' ) 4 ( ' >AO, >"1, >"2 ... >BF ' ) G-l This format statement puts 24 rows of 32 characters in the Pattern Name Table (VDP RAM >0 - >2FF), but it puts 48 rows of 64 blocks on the screen (each byte in the PNT corresponds to a 2 x 2 block of 4 x 4 dots on the screen) VDP RAM locations 0, >20, >40, and >60 all have the value 0, but RAM (0) uses the nybbles at >800 and >801, RAM (>20) uses the nybbles at >802 and 803, RAM (>40) uses the nybbles and >804 and >805, RAM (>60) uses the nybbles at >806 and >807. The value in each byte of the PNT is the number of the character in the Pattern Generator. Although each character in the Pattern Generator consists of 8 bytes, the system has a painter for each byte in the PNT which tells it which two bytes of that charater it uses to color the quadrants. The nybbles in these two bytes are used as follows: The fi r st byte'S MSN describes t h e upper left qu a drant's color T he first byte'S LSN describes the upper right quadrant's color The second byte's MSN describes the lower le ft quad- rant's color. The second byte's LSN describes the lower right quadrant's c olor. Figure G.l shows the ranges of XPT and YPT and t he VDP nybble assignments. As you can see fr o m th i s drawing there is a type of indexing of t he !Jytes in an 8 - byte pat.te:-:1 gene:-at o r block ~hich corresponds t o YPT. For example: G-2 Index into Pattern Generator YPl' Values ) o 0, 8, 16, 24, 32, 40 1 1, 9, 17, 25, 33, 41 2 2, 10, 18, 26, 34, 42 3 3, 11, 19, 27, 35, 43 4 4, 12, 20, 28, 36, 44 5 5, 13, 21 , 29, 37, 45 6 6, 14, 22, 30, 38, 46 7 7, 15, 23, 31, 39, 47 When XPT is even, then MSN of each byte is usedj and when XPT is odd, the LSN of each byte is used. After the screen has been initialized with the format statement as described above, bit 1 of CPU RAM location >FD must be set. Once this bit is set, you cannot use format statements ) to change the screen. All changes to the screen must be done by setting XPT and YPT to specific values and storing the color you wish for that block in the character buffer (CB = CPU RA,.\1. 70). For example, the instructions: ST 37,@XPT ST 13,@YPT ST 4,@CB would put a 4 x 4 dot block of color 'blue 2' at the specified place on the screen and also put a 4 in the right nybble o f VDP RAM ( >995 ). A st o re in CB does not affect the PNT si nce the values from the initial format statement are the only ones which allow MeMO to work correctly. G-3 The ALL inst ruction may be used in this mode to change the screen. For example: ALL >24 will look at VDP RAM (>920->927) and fill the screen with these colors in 2 x 8 blocks of 4 x 4 dots. It will also store >24 in VDP RAM (O -> 2FF). Since the ALL instruction changes the values in the PNT, before successful use of MeMO can be made, the programmer must reset bit I of CPU RAM location >FO and re-initialize the screen with the format statement above. ' Then set bit I at location > 'F'O ' and proceed as above with a store to CB of a color. G-4 , , ,, ,, ," , I I ! I I ! I I , ,: ,, , - -:- . I ,, , I I I I , , , , , I , I I " , , ' I I I , --'- I; , I , I I I I I I i :.- , ! ; , . ..!... , , I , I , i I I -, I I i , , I , I ' ,, -, , , ' , I I I , ' I , , : I j ; , , , ; , I , I ' , I :- _ ~ i w , I , I, I I " , Cl 'T , , '. o ~ , , ' I I '. i' ~ I I , , I ! , , I , I : I I I I .- - ----, , I , : I I I I _. , I , : , , , , , ' -, , _ _ .J "' ,, , , , .. J , f I ,, - -I I , ,' . .. , , - , " , I , , . , , , ,. >- =- . . . .i APPENDIX H DEVICE I/O Each GROM or ROM that contains programs that may be accessed by programs outside of that ROM or GROM need a header. There are 6 types of programs currently defined. They are power up, user application, device service, subroutine links, BASIC sub- program libraries, and interrupt service ,programs. Every type of program except user application programs, BASIC subprogram libraries, and interrupt service routines can be in either ROM or GROM. User application programs and BASIC subprogram libraries can only be in GROM. For every type of program in a GROM or ROM, t here is a chained list of program headers. The first program header of each type is pointed to by an entry in the GROM / ROM header. GROM/ ROM headers must be l ocated at the beginning of a GROM or ROM. Program headers can be located any .... here. Wi th i n a multi-GROM package the GROM headers and program headers may be i n the same or different GR0r>1s. Table H.l sho .... s a GROM / ROM header and Table B.2 shows a program header. MONITOR FUNCTIONS 1. SYSTEM INIT! ALI ZATION The monitor will start every application program with al l of RAM in a defined state. CPU RAM will be zer o ed except for >70 through >81. Location >70, >71 contains the highest address in VDP RAM. Location >72 will contain >9F and is the data stack pOint'!!'. Locat i on >73 ( t he su!n out in e s ta c :< ? oi:1 t ': r ) is initial i zed t o >72. Lo cat io n >74 i s :e: o . :,~e o tne: loca t ions ( >75 t o >81 ) have undefined value s . H-1 TABLE S.l GROM HEADER LOCATION SIZE CONTENTS xooo byte >AA valid identification XOOl byte version number X002 byte number of program X003 byte reserved X004 word(2 by tes ) address of first rpo .... er up routine header X006 .... ord address of first ~ser program header X008 word address of first nSR header XOOA word address of first stibr outi ne link header XOOC word address of first ~n terrupt link XOOE word address of first . BASIC subprogram libraries The address of any program types should "be 0 in the GROM / ROM header if there are no programs of that - type. The number of programs and verisan number are not curr~ently being used but should be used for future expansion. ) TABLE H.2 PROGRAM HEADER SIZE CONTENTS word pointer of next pro~ram headec "'of the same pr ogr am type (0 i f end of 11St ) word entry address of program byte number of characters in pr ogram name (N ) N. bytes ASCII character representation of pr ogram name B-2 YDP RAM will have the 6 X 8 character set loaded. Th e YDP regist ers will be set f or th e standar d locations (s ee Table 3.4, pag e 3 - 10. The screen will be blanked and the color table will conta i n all >17. All the rest of VDP RAM will be zeroes . 2 POWER-UP RO UTINES The monitor initializes the 5ystem by calli ng p ower - up r outines. The console power-up rout ine exe cutes f irst. This r ou tine puts up the in i t i a l screen and menu and calls the selected program. Next. the moni t or :searches peripheral ROM and GRaM headers for power - up routine addresses and executes them as it finds them . After each power - up routine is execut ed, a search is made for the next one. When there are no mor e power - up routines found. the selec ted program is started w ith t he system initialized as desc ribed in Section 1. Each ROM power-up can use RO - Rl0, but cannot use >55 and >6D l.n CPU RAM. R12 w ill be :set up with the proper CRU address to address the attached peripheral's eRU. The ROM power - u;> r outi ne should end with a B - Rl l to return to the system. GRaM power-up routines are ca~le d fr om CPL. They can be located 1n any sl ot of the library peripheral. They may not use subroutine links or call DSR 's. The return is ac co~plished by moving 2 bytes f ro m the data stack to the subroutine s:.ack, decrementing the data stack p oi nter by 2, and then doing a ret urn in :struct:'o n. ?o;.rer- u;l :'0'..: :'i:::es ca:l :.JSC: C?U ;1:A:~ > ... co >71 :'~r '.l:::ate':,?:, they need. The y may a l so use al l of VDP RAM, They must no:. H- 3 change the data or subroutine stack pointers upon return to the monitor. 3. GENERAL SUBROUTINES PROVIDED BY THE MONITOR The monitor provides a group of subroutines that are of general use in many applications. These include mathematical functions, character sets, certain sounds, and application exit. The mathematical functions are described ' in Appendix K. There are two routines to load VDP RAM with either a 6 x 8 or 5 x 6 character set. They are called by: CBRl EQU >16 CALL CHRl ( 6 x 8 char,acters ) CBR2 EQU >18 CALL CIlR2 (5 x 6 characters ) When they are called, CPU RAM location FA C should be pointing to the VDP RAM location of the first character ( space ) . There are two r outines that give positive and negative acknowle dge tones. These are used primarily for acknowledging good and invalid key pushes. The two routines are called by: TONl EQU >34 CALL TON 1 (positive acknowledge ) TON 2 EQU >36 CALL TON2 ( negative acknowledge ) EXIT - RETURN TO MONITOR An applicati on program may exit and return t o the monitor oy: EXIT H- 4 This instruction causes a software reset of the system. All power-up routines are executed and the initial screen displayed. This should not be confused with a hardware reset. BIT REVERSAL ROUTINE >3B Purpose: Provide a quick way to form mirror image bytes in VDP RAM Input: FAC address of data in VDP (C PU RAM location >4A) FAC+2 number of bytes to reverse Call: BITRVR EQU >3B CALL BITRVR Output: Every byte in VDP RAM fr om t he first address pointed t o by FAC to the byte pointed t o by the addre ss + numbers of bytes in FAC+2 is bit reversed. "!'his means bits 0 and 7 are exc h anged , bits I and 6 a r e exchanged, bits 2 and 5 are exchanged, a nd bits 3 and 4 are exchanged to give a mirror image of the by te. Excepti ons : None Side Effects: CPU RAM from >00 to >40 will be destroyed. H- 5 WRITING I/O ROUTINES ) 1. SUBROUTINE AND DSR CALLS Subroutines and DSR's may be called through the monitor. The monitor is passed the name of the routine in VDP RAM. The name location in VDP RA. ."" is pointed to by a 2-byte value in CPU RAM >56. The VCP locations contain a one-byte count of the number of characters in the name ,followed by the ASCII representation of the name ~ith a "." (period) and s o me more characters. This may be repeated any number of times. The routine name the monitor uses c on sists of the string up to the first peri od , if any. The routine itself is called by CALL LINK LINK EQU >10 DATA BYTE where byte is 8 for a DSR an d > A for a subroutine link. The ) , subroutine or DSR sh ould re turn by CALL RETN EQU > 12 If the routine is in ROM. Rl will c o nta in a version number starting with 1. Eve ry t ime a r o utine is f ound with the right name, RI is incremented. This enables a r ou t ine to determine its po sitio n re l a tive to oth e r routines of t he same name. If the versi o n number is wr ong , t he r ou tine should B *R II without changing any registers. If t he routine is execu ted , i t shou l d return by incrementing RII by 2, and branching indirect on RII. Reg i ste rs RO - RIO can be used, as well as CPU RAM locations 4A th:u GD. Rll has the r et'Jrn address fo~ ROM c ode and R1 2 '", i :: be pointing to the perip heral C~U space. ) H-6 For GROM programs, the subroutine or DSR may reside in another library peripheral slot. The subroutine or DSR calls may be nested. Each GROM subroutine or DSR call takes 4 bytes of subroutine stack. ROM subroutines and DSR ' s called through the monitor may not be nested. 2. INTERRUPT ROUTINES Interrupt routines may only be in peripheral ROM. Inter ru pt routines may not use R9 or the subroutine stack. R8 must be cleared before returning if the interrupt uses it. Every , interrupt that is not recognized as being a console interrupt causes the interpreter to execute every interrupt service routine that it can find in a peripheral ROM. These routines may use RI-R8 and RIO. Rll has the return address and Rl2 must be returned wit h t he same value . If the DSR enables the interrupt, it should wait for all processing to be complete before disabling the interrupt and returning to the a pplication program. Because o f the execution of an interrupt routine only as part of a DSR, the DSR and interrupt routine can split the allocation of CPU RAM from >4A to >6D. Interrupt routines that service interrupts in any other way may only use RI-RlO. All interrupt routines end by a RT instruction. 8-7 APPENDIX I CASSETTE DSR DEFINI nON A file con~lsts of a collection of data groupings called l ogical reco r ds . This division of the file into logical records does not necessarily correspond to the physical division of data 00 the medium (like a block on a d~sk ) . Thus I there are tw o types of records: • Logica l records - the data gr oupi ng of a file as seen by the BASIC interpreter or other application programs. • Physica l records - the buffers physically transferred between memory and medium. File I /O from a program 13 done on a logical record basis. The manipulation o f physical records 1s done by the DSR. ) All cassette files are sequential and allow variable length logical re co r ds. When a file is created, the 10g1ca1 record size must be specif ied . F or sequential files the specif icatio n is optional. If specified, the logical rec ord s i ze is used as an upper li mit f or any logical record s ize o f that file. The physi cal record size for any med iu m is specified w i t hin the DSR and is i mpl ementati on dependent. PATTERN NAME TABLE When t he cassette DSR is used, the PATTERN NAME TABLE !!l ust be located at address 0 1n VDP RAM. I- 1 MODE OF OPERATION A file is opened for a specific mode of operation, specified 1n the OPEN I /O call. The three modes of operat ion are: • INPUT - the contents of the file may be read, but they may not be altered. • OUTPUT - the file is being created . It ls contents may be written but not read. e APPEND - new data may be added at the end of the file, but the contents o f the file may not be read. This is the same on the cassette as output mode. Each DSR decides whe ther or not a specific mode f or an I/O operation can be acc epted by t he corresponding device . IMPLEMENTAT ION As ment ioned, the DSR ' s should present a uniform interface between the F ile Management System and the peripherals . This section will give implementation details on this interface. PERIPHERAL ACCESS BLOCK DEFINITION All DSR 's are accessed through a so called Peripheral Access Bloc k (PAB ) . The definition for t hese PA3's is the same for every peripheral. The only difference between peripherals is t hat some peripherals will not support every option provided for in the PAB. All PAS' 5 a=e ph:,sically loc~t.ed i:1 VDP RA:1. Tr.ey 3:-e created before the O?E':'1 call, anc are not to be releasee until the I /O has been closed for that device or file. 1-2 Figure I.1 (page 1-6) shows the layout of a PAS. The PAS has a variable length, depending upon the length of the file descriptor. The meaning of the bytes and bits wit hin the PAS is: BYTE BIT MEANING o I /O opcode - contains opcode for the current I/O-call. See Table , 1.2 for available opcodes. 1 Flagbyte / statu5 - all the information the system needs about file-type, mo de of operation, an d data-type, is stored in this byte. The mean- ing of the bits within this flagbyte is (bi t 7 is most significant bit, b it 0 is least 5i9ni- ficant bi t). ) o Filetype - indic ated file-type o = Sequential file 1 = Relative record file (Cassettes are always sequential. ) 1-2 Mod e of operation - indicates operation mode file has been opened for: 00 = UPDATE 01 = OUTPUT 10 = INPUT 11 = APPEND Cassette DSR do es not support updatp. or append . ) I- 3 BYTE BIT HEANING 3 Datatype - indicates type of data stored in the file. DISPLAY type data comprises standard ASCII data. INTERNAL type data is imple- mentation dependent . o = DISPLAY 1 = INTERNAL 4 Recordtype - indicates type of record used. o = Fixed length records 1 = variable length records 5-7 Errarcode - these three bits indicate, in com,bination with the I / O opcode, the error type that has occurred (0 = no err o r ) . 2-3 Data buffer address - address of the data buffer the data has to be .... ritten to or read fr o m. The buffer is al~ays in VDP RAM. 4 Logical record length - indicates the logica l record length for fixed length rec o rds, or the maximum length for a variable l ength rec o rd (see flagbyte ) . It is rounded up to the next highest multiple of 64. 5 Character count - number of characters t o be transferred in write mode, or the number of bytes actually read in read mo de. It is used by the cassette DS~ only f o r ::ead s and '..;r i tes. 1-4 BYTE BIT MEANING ) 6-7 For cassettes, the record number is used for the number of bytes to load or save. This number must be larger than the number of bytes o n the cassette record. This number is rounded up to the nearest multiple of 64 by the cassette DSR. 8 Screen offset - offset of the screen characters in respect to their normal ASCII value. This is used if your characters ace not at the default positions in VDP RAM. It enables the cassette DSR to use your character set for messages. The cassette DSR messages look best using the small character set. ) 9 Name length - length of the file descriptor following the PAB. 10+ File descriptor - devicename. The length of this descriptor is given in byte 9. There are two valid names for cassettes: CSI - cassette unit 1 CS2 - cassette unit 2 I 1-5 *----------------------------------------------------* 1 0 1 1 1 1 I / O OPCODE 1 FLAG / STATUS 1 1 1 1 1----------------------------------------------------! 1 2- 3 1 1 D A T A B U F FER ADD RES S 1 1------- ---- - ------------------- ------- ---- ----------1 4 1 5 1 LOG ICAL RECORD LENGTH CHARACTER COUNT 1----------------------------------------------------! 1 6-7 1 RECORD NUMBER 1 1----------------------------------------------------1 8 ! 9 SCREEN OFFSET NAME LENGTH !-- ------------------- --------------- --- -------------! 10 .. . FIGURE 1.1 PAB LAY OUT 1- 6 I/O OPCODES This section describes the valid opcodes that can be used in the PAS. These valid opcodes are shown in Table 1.2 (page 1-6 ) The following section will describe the general actions caused by an I /O-call with each of the I /O-opcodes . Each I/O-call returns any err or-codes in the FLAG/STATUS byte of the PAB. OPCODE MEANING 00 OPEN 01 CLOSE 02 READ 03 WRITE 04 RESTORE/ R~dIND (not supported ) 05 LOAD 06 SAVE 07 DELETE FILE - NO OPERATION FOR CASSETTE 08 SCRATCH RECORD - NO OPERATION FOR CASSETTE 09 END OF FILE TEST (not supported ) TABLE 1.2 I / O OPCODES ) 1-7 The OPEN operation should be performed before any data transfer operation. The file remains open until a CLOSE operation is performed. The mode of operation for which the file has to be OPENed should be indicated in the flag byte of the PAB. In case th is mode is OUTPUT, APPEND or INPUT, the record length (64) is returned in byte 4. An OPEN operation must be performed before any other operation except LOAD or SAVE. Consistent use of OPEN and CLOSE is recommended Eor all files and devices; howeve r, neither the OPEN nor the CLOSE operation is required for devices. Close The CLOSE operation informs t h e DSR that the current I/O sequence t o that DSR has been completed. After the CLOSE operation, the PAS i.s no longer needed, so it can be released. As long as no CLOSE operation is performed on a n actille PAS, this PAS has to be preserved. Read The READ operation reads a record from t he selected device and st ores the bytes in the spec ified buffer. The buffe~ address is specified in PAB entry 2 and 3, and the buffer size is specified in PAB entry 4. If the length of the input record exceeds ~;,e :,uffe: s i ze, t~e record is not ~e2d and 2:"1 e::!':l: :S returne': . I- B Wr i te The WRITE operation writes a record to the specified device from the buffer specified in the PAS. The number of bytes to be written is specified in byte 5 of the PAS . Restore/Rewind The RESTORE / REWIND oper ati on repositions the file read pointer to the beginning of the file. A RESTORE can only be used if the fi Ie is opened for INPUT mode . RESTORE itself does not perform any READ operati o n . Load The LOAD opera tion loads an entire program from an external device or file into program memory. All the control information for BASIC is contained in t he load file. Since all information is directly written to pr ogram memory without intermediate buffering, no buffer memory needs to be assigned. The LOAD ope rat ion is a stand alone operation , i.e., the LOAD operation can be use d without previous OPEN operation. For the LOAD operation, the PAS needs to contain the following information: Bytes 2 and 3 sho uld contain the start address of the prog ram me mo ry. Bytes 6 and 7 should c on ta i n the maximum number of bytes available for the ?~ogram. Aside from the I / O opcode and the file descriptor, no more ) information is required fo r the LOAD operation. 1-9 Save SAVE is the complementary operation for LOAD. Instead oE loading a program from a device or file, it writes a program from program memory to a device or file. Again, only a small part oE the PAB is used. Aside from the usual information ( I /O opcode and file descriptor ) , the PAB should contain the start address of the program to be SAVEd in bytes 2 and 3, and the number of bytes to be SAVEd in bytes 6 and 7. BASI C automatically saves all the control informati on necessary for reloading of the program, together with the program code. Delete The DELETE operation deletes the specified file fr om t he specified device . Th is operation also CLOSEs the I / O sequence. The DELETE operation can only be used in UPDATE, APPEND or OUTPUT mode. (No operation for cassette.) scratch Record The SCRATCH RECORD operation scratches the specif ied record from the specified (rel ative re co rd ) file. The record t o be scratched is specified in byte 6 and 7 o f the PAB. This operation wil l cause an error for sequential files and de vices . (No operation f o r cassette . ) VERIFY The VERIFY command all ows the record on tape to be c ompa red against what is in VDP RAM. It will return an error code if the 1-10 record is unreadable or if there is a difference between the tape's data and the VDP data. ERROR CODES The F ile Management System shall support the following error codes: 1. BAD DEVICE NAME the device indicated is not in the system. 2. ILLEGAL OPERATION either an invalid operation was specified, or a conflict with the OPEN mode has occurred. 3. DEVICE ERROR covers all hard device errors, such as parity and bad medium errors. ISSUING THE COMMAND TO THE CASSETTE DSR After the PAB is set up, the cassette DSR is called by putting the address of the name length ( byte 9 of the PAB ) in CPU RAM location >56 and then calling a subroutine at location >10 in GROM O. This is illustrated as follows for a save routine: DSR EQU >10 Address of sub routine NAMLEN EQU >56 Address of byte 9 of PAa ) 1-11 MOVE 13 FROM ROM(tPASCAS) TO R~~ ( 500) DST t >509, @NAMLEN Address of byte 9 of PAS in VDP CALL DSR DATA 8 *Tells subroutine this is a DSR PASCAS DATA >06 Ope ode for save DATA > 02 Sets output status f or save DATA 1>600 Address in VDP of data buffer DATA >40 Fixed record leng th size f or cassette DATA >00 Character count f o r cass e tte DATA t > 6FO Number of bytes to be read DATA >00 Bias f o r ASCII characters DATA >03 Len gth of name of device DATA :CS1: Name of dey ic e* * For cassettes t he name of the d ev i ce is predefined as CSl or CS2 and these a re the only names you a r e allowed to use. AUD IO GATE eRU bit 24 is t h e a udio gate bit wh ich allows data being read t o be heard. If t he bi t is set t o 1, t he data being read is heard, a nd if the bit is set to 0, t he data is not heard. Set ting this bi t t o a 0 or 1 is done wit h an I / O ins t ruction. :-!O':'OR CON':'ROL There are t·... o CRU bits ( 22 a nd 23 ) used t o control cassettes 1 and 2, re spectively. When t here is no Cassette I / O being done, 1-12 both motors remain on. When Cassette I/O is specified, the DSR will control the data being read. If there are two motor uni ts connected, the data will be read simultaneously, or you may have the option of reading data from one motor unit and playing the recorded voice from another motor unit through the TV speaker. ) 1- 13 srA'lUS ~IC OFCODE (» FOR-IAT AF1"EL"lfD INSTRUCl'Ioo =00 DIV }C 1 AIL DIVIDE 4.4.4 EX CO 1 NONE EXOIRlGE 4.4 . 17 EXEX: II 5 AIL !lI\S I C EXro1I'E EXIT OB 5 NONE EX IT PRCXiRJ>M 4.5.8 FmOl 88 6 N:NE FE:"rCH ERCM CAlL 4.2.6 EMT 08 7 EOIMAT &:REEN 4.5.4 GT OA 5 = GRFATER $TA'lUS TO = 4 .1.2 H 09 5 = BIG! srA'lUS TO = 4 .1.1 INC 90 6 AIL IOCREMENr !r{ CNE 4.4 . 5 INCT 94 6 ALL INCREMmT !r{ '!WO 4.4.6 I /O F6 8 N:NE SPECIAL I/O 4.5.9 INV 84 6 NONE INVERT (CNE'S CXMPLEMENT ) 4.4.11 M:lVE 20 9 N:NE M:lVE DATA 4.4.20 M A8 1 NONE MJLTIPLY 4.4.3 MJL A8 1 N:NE flJLTIPLY 4.4.3 NEt; 82 6 NONE NEXiATE ('!WO' S CCMPLEMrnT ) 4 . 4.1 0 CR 64 1 AIL r.a:;ICA!. OR 4.4.1 3 OVF 00 5 = o.JERFI.aoI STA'lUS TO = 4.1.4 PARSE DE 2 AIL !lI\SIC PARSE pugj 8C 6 NONE FUgj DATA STACl< 4.4.18 RAND 02 2 N:NE RANCCM NU1BER 4.5.5 RB BO 1 ALL RESE."rBIT 4.3 R'IN 00 5 = R!:JUm rnD!INE U\NGUta: 4.5.7 XOR B8 1 ALL LCX;ICAL EXCWSI \IE OR 4.4.14 The following instructions are used to access BASIC Language: EASIC COntinue PARSE B.aSIC Parse RINB &.SIC Return BASIC Execute J-3 PAIl! 2 INSTRUCTION MAP Leas t Si9n if icant Nybble U 1 2 ) 4 5 6 7 0 9 A 0 C D E f o "-;~ lln_~~J_~'A;'~1 5_r~AiL um1~~ C ALLI AI LI~-;-j II GT L.:0jCARRVI ovr IPARSE I XML I liNT EXEC, RTllU UNUSED - -- -- ---- -------.-.- - - -----------------------~ l I·IOVE ) ., ------------_._-----_._-- - - - - - - - --- -- ,,---- - - - - - q Z ,., .0 .0 UR 5 <. ~ c -----------. - - - - ---------------- - , m u 6 ~ .~ ~ OS m c 7 .~ ~ ~ ~ 0 U · ~u;-_: I~ ~,[G __ r -,N-V- -I- - CLR b TCll1 ICASE I IPUSII I CZ :;: 9 UNUSED UNUSED IN C DEC IN CT DECT - - -. I - A AOIl______ .____ • ________SUO __ _ _ _ __ 1 Mill , DIV - . - _. - 1- U Mil) OR XO R ST .- --- ------ ---- --- - ~ --. -- C (X CII I (lIE CGT 11 F --:~:-:~:-=:: :~--~~:--==~~-:-:~~~~=r-=-- C~: ---- ;~s~D101-~~~USE-D --U-t~,~,~;) - ~ _-_::~ -~~-_ __ .-_-_____.___UN-U=SE:~_- ~: - ~ II-/~I-~_~ _~~- . - -- -- - __ . __ _ APPENDIX K FLOATING POINT OPERATIONS There are several subroutines in the monitor which can be called from a GPL program. These subroutines are described in this appendix. It is important the progranuner realize that when one of these subroutines is called the contents of CPU RAM locations >4A through >6F may be used, a~d VDP RAM locations >3CO through >3DF will be used for rollout. The mathematical function subroutines provided in the monitor include convert number to string, greatest integer, invo- lution, square root, exponential, natural log, c osine, sine, tangent, and arctangent. The CPU RAM locations used by these routines are: FAC is CPU RAM >4A (8 bytes) ARG is CPU RAM >5C (8 by tes) STATUS is CPU RAH >7C SGN is CPU RAM >75 EXP is CPU Rk'l >76 IlSPTR is CPU RAM >6E ( 2 bytes ) FPERAD is CPU RAM >6C FLOATING POINT ERRORS When err o rs occur during the execution of floating point routines, they are indicated by a non-zero value being placed in CPU RAM location FAC+10 . If an error has occured, the user ?rog:a~ is t~e~ :esp onsi~~e ~~: clea:ing ~~~s ~=:c: ::~g location. K-l Error Codes: WRNOV >01 - warning, overflow DIVZER >01 - division by zero ERRSNN >02 - syntax error ERRIOV >03 - integer overflow on cohversion ERRSQR >04 - square root of negative number ERRNI P >05 - negative number to non-integral power ERRLOG >06 - log of negative number or zero TRIGER >07 - invalid argument in trig functi o n CNS - CONVERT NUMBER TO STRING Purpose: Convert a floating point number to an ASCII string. Input: FAC The f lo ating point value. ) FAC+ll If set to 0, the output string will be in BASIC format. If greater than 0, represents output in CALCULATOR mode. The contents are the effective calculator ... idth, exclusive of dec imal po i n t . The f ollo wing tw o cells are also required in CALCULATOR mode. FAC+ 12 If zero, express o verflow from calculator range by .. or - EE ... E. Underflow is ex?ressed as O. If positive, under- or o ver-:~o'''' f ::-cm calculator range is expresse d in ) E-format using the number of K-2 significant digits specified by this cell. FAC+l3 The number of digits t o fix to the right of the decimal pOint. A negative value disables the FIX mode. CNS EQU >14 CALL: CALL CNS Output: FAC The FAC contents will be modified due to rounding performed for display purposes. FAC+ll Points to the beginning of the result string. The string will be entirely contained within the floating point sc ratch area between FAC and FPERAD. FAC+l2 The length of the string, in bytes. Except ions: None INT - GREATEST INTEGER FUNCTION Purpose: compute the greatest integer contained in a floating point value. Input: FAC The fl o ating point va:ue. !NT EQU > 22 K-3 Call : CALL INT Output: FAC The greatest integer contained in the floating pOint value. For positive numbers the integer is the truncated value. For negative numbers the integer is the truncated value plus one. STATUS The status byte is set according to the contents of FAC after the operation. Exceptions: None PWR - INVOLUTION ROUTINE ) Purpose: Raise a number, B, to a specified power, E I npu t: FAC The exponent, E. STACK The base, B. PWR EQU >24 Call: CALL PWR Output: FAC The result, B**E. The result is c om- puted as EXP I E * LOG (ABS ( B »)) . If B is negative and :c: is an odd integer, the result is negated. K-4 STATUS The status byte is set according to the contents of FAC. Exceptions: Negative number to non-integer power. Zero raised to a negative power. Overflow if result greater than maximum value . K-4 Side Effects: SGN and EXP are destroyed. The prev ious FAC contents are destroyed and the contents of VSPTR are decremented by 8. SQR - SQUARE ROOT ROUTINE Purpose: compute the square r oo t of a number. Input: FAC The input value. SQR EQU >26 Call: CALL SQR Output: FAC T~e square r oot of the number. STAT~S Set accorc~n9 t o the contents of FAC. K-S Exceptions: If the input value is negative, the ERRSQR condition results. ) Side Effects: SGN and EXP are destroyed. The con- tents of VSPTR are unchanged. EXP - EXPONENTIAL ROUTINE Purpose: Compute the inverse natural logarithm. Input: FAC The input value. EXP EQtJ >28 K-S Call : CALL EXP ) Output: FAC The inverse natural logarithm. STATUS Set acco rd i ng to the con ten ts of FAC. Excepti ons: Overflow of the result causes the WRNOV condition. Side Effects: SGN and EXP are destr oyed . The contents of VSPTR are unchanged. LOG - NATURAL LOGARI~~ ROUT!NE Purpose: Compute t he natural log of a number. K-6 Input: FAC The input value. LOG EQU >2A Call: CALL LOG Output: FAC The natural log of the number. STATUS Set according to the contents of FAC. Exceptions: If the input value is zero or negative, the ERRLOG condition results . Side Effects: SGN and EXP are destroyed. The contents of VSPTR are unchanged. COS - COSINE ROUTINE Purpose: Compute the cosine of a number ( in radians ) . I npu t: FAC The input value. COS EQU >2C Call: CALL COS Output: FAC The cosine of the number. STATUS Set according to the contents of FAC E;{cept ions : :~o~e K-7 Side Effects: SGN and EXP are destroyed. The ) contents of VSPTR are unchanged. SIN - SINE ROUT IN E Pu r p ose: Compute the sine o f a n umber (i n radians ) Input: FAC The input value. SIN EQU >2E Call: CALL SIN Output: FAC The sine o f the number. STATUS Set acc o rding t o the contents of FAe. Excepti ons: None ) Side Effects: SGN and EXP are destroyed. The c ontents o f VSPTR are un cha nged. TAN - TANGENT ROUTINE Purpose: compute t h e ta ngen t of a numbe~ ( i n radians ) . I npu t: FAC The input va l ue. TAN EQU >30 Call: CALL TA.'1 Output: lAC The ta ng ent of the number (i n radians ) . STATUS Set according to the contents of FAC. ) K-8 Exceptions: If the input value causes an overflow the WRNOV condition results. Side Effects: SGN and EXP are destroyed. The contents of VSPTR are unchanged. ATN - ARCTANGENT ROUTINE Purpose: compute the arctangent ,of a number (in radians ) I npu t: FAC The input value. ATN EQU >32 Call: CALL ATN Output: FAC The arctangent o f the number. STATUS Set according t o the contents of FAC. Except ions: None Side Effec ts: SGN and EXP are destroyed. The contents of VSPTR are unc hanged . The floating point routines provided in ROM are convert string to number, convert floating t o integer, floating add, floating subtract, floating multiply, floating divide, f loating compare, stack add, stack subtract, stack mu ltipl.y, stack di'Jide, and st3ck com?a:e. All numbers a:e 8-bits. As a number is usee on the val~e stack, t;,~ stac :< poi:1te: is incremented by 8. All errors a:e returned in location FAC + 10. K-9 Only overflow errors are detected and the code is 1 f or a floating point overflow and 3 for integer overflow. CSN - CONVERT STRING TO NUMBER Purpose: Convert an ASCII string t o a floating pOint number. I npu t: FAC Address of the string. CSN EQU >10 Call: XML CSN (The instruction FLTPT will generate the same code as XML) Output: FAC Number returned here. All numbers are returned in internal format which is radix 100. CPU RAM space FAC thru FAC.9 should be reserved for the answer. Error code ( >01 - overflow ) CFI - CONVERT FLOATING POINT TO INTEGER Purpose: ~ rounded conversion of a floating point num ber to an intege r. I npu t: FAC Floating point numbe: CFI EQU >12 ) K-10 Call: IML CFI ( Output: PAC Integer value returned in first two by tes. FAC+10 Error code ( >03 - overflow) Excepti ons : Range of integer must be , -32,768 t o 32,767 FADD - FLOATING POINT ADDITION Purpose: Perform addition in ba se 100. Input: ARG Left-hand term FAC Right-hand te rm FADD EQU > 06 Call : XML FADD Output: FAC Result of addition problem. FAC +10 Error code ( >01 - overflow ) • FSUB - FLOATING POINT SUBTRACTION Purpose: Perf o rm subtracti o n in base 100. I npu t: ARG Left-hand term FAC Right-ha nd term FSU3 £QU >07 K- ll Call: XML FSUB Output: PAC Result of subtraction problem. FAC+IO Error code (>01 - overflow) FMUL - FLO~TING POINT MULTIPLICATION Purpose: Perform multiplication in base 100. Input: ARG Multiplicand F~C Multiplier FMUL EQU > 08 Call: XML FMUL ) Ou tpu t: PAC Result FAC+10 Err or code ( >01 - Overflow) FDIV - FLO~TING POINT DIVISION Pu rpose : Perform d ivision in base 100. I npu t: ARG Dividend FAe Divisor FDIV EQU >09 Call: XML FDIV Output: F~C Result F~C+10 Error code ( >01 - Overflow ) K-12 FCOMP - FLOATING POINT COMPARE Purpose: Compare two base 100 numbers. Input: ARG First argument to compare FAC Second argument to compare FCOMP EQU >OA Call: XML FCOMP Output: STATUS Bits set according to the c ompa re -- High bit is set if ARG is logically higher than FAC, greater than bit is set if ARG is arithmetica lly greater than FAC, condition bit is set if ARG and FAC a:e equal. SADD - VALUE STACK ADDITION Purpose: Perform base 100 addition of the top value on the value stack in VDP R~~ with another value . Input: ARG Top number on t he value stack (VDP RAM. address pointed to by V5PTR ) is left - hand term. FAC Right-hand term SADD EeU >08 Call : XML SADD R-13 Output: FAC Result ) FAC ·HO Error code ( >01 - Overflow ) SSUB - VALUE STACK SUBTRACTION Purpos e : Perform base 100 subtracti on of a number from the top of the value stack. Input: ARG TOP number on the value stack is left-hand term FAC Right-hand term SSUB EQU >OC Call : XML SSUB ) Ou tpu t: FAC Result FAC+10 Error code ( >01 - overflow ) SMUL - VALUE STACK MULTIPLICATION Purpose: Perf o rm base 100 multiplication of a number from the t op of the value stack with another number. Input: AHG TOP number on the value stack is multiplicand. FAC Multiplier S11uL ECU >OD ) Call : XML SMUL K-14 Output: FAC Result FAC+IO Error code ( >01 - Overflow ) SDIV - VALUE STACK DIVISION Purpose: Perform base 100 divis io n of a number from the top of the value stack by another number. Input: ARG Top number on the value stack-dividend FAC Divisor SDIV EQU >OE Call: XML SDIV Output: FAC Result FAC+ IO Error code { >01 - overflow} SCOMP - VALUE STACK COMP&qE Purpose: Compare the t op n umber on the value stack to anothe~ number I npu t: ARG TOP number on the value staCK - first argument FAC Second argume nt SCOMP EQU >OF Call : XML SCOMP Out?ut: Sl'.;TtiS ARG is c ompared to FAC and the ~!gh, greater t han, and condition bits are set accordingly. K-1S RADIX 100 The internal format for floating pOint numbers is Radix 100. Each number c onsists of 8 bytes - an exponent followed by a 7-digit Radix 10 0 mantissa. A single Radix 100 digit has a range in decimal value from a to 99. Thus, a 7-digit Radix 100 numbe r ~ill correspond to decimal precisi on of 13 to 14 digits. The exponents range i n value from -64 to +63, which corresponds t o a decimal range of 10-128 t o 10+ 126 . The result is an equivalent decimal range from -9.999999999999 X 10+ 1 27 throug h -1 . 000000000 0000 X 10 - 128 ; zero; and then +1.0000000000000 X 10-128 throug h +9.9999999999999 X 10+ 127 . The firs t byte of the eight byte number is the exponent , biased by >40. The remaining seven bytes contain the seven-digit mantissa, with the most significant digit first. The number is normali zed s o that the decimal point is immediatelY after the most significant Radix 100 digit. If the number is negative, the first two bytes are complemented. Examp les : 1) Decimal value = 12543 Floating point value = >42, >01, >19, >28, >00, >00, >00, >00 2) Decimal value = 0.5294 Floating point value = >3F, >34, >5E, >00, >00, >00, >00, >00 3) Decimal va lue = 23.75 Floating poin t value = > 40, >17 , >48, >00 , >00, >00, >00, >00 4) Decimal value = -2 3.75 Floating po in t value = >3 F, >E9, >~B, >00 , >00, >00, >00, >00 ) K-16 APPENDIX L 9900 ASSEMBLY LANGUAGE The VDP chip is accessed by writing to the appropriated memory mapped location (see Borne Computer system Memory, CRU, and Interrupt Mapping Specification ) . First, the VDP address pointer is loaded by writing out, sequentially, two by tes ( low byte first ) to the VDP address l o cation. (If the full operation is to be a WRITE data to VDP, then the 2 byte address must be ORe a with 4000 ). Because of timing considerations on the VDP, there should be a delay of at least 6 usee between a read or write ope rati on and loading the address pOinter (or between any two VDP operations ) . Data may then be moved from ( to ) the VDP r ead- { wr i te ) -data address which will contain the content of VDP memory pointed t o by the VDP address register. After each operation the VDP address pOinter aut o ~atically increments and points t o the next locati o n. Therefore, the address pointer d o es not have t o be reloaded t o move blocks of VDP memory. Rl = @MSB ( LSB) two byte VDP address R2 = @VDPWA I / O write address R3 = @VDPWD address to writ e data R4 = @VD PRD address t o read data ORI Rl .>400 0 wr i te option MOVB @R1LSB.*R2 MOVB Rl,*R2 SLA R8.6 delay :-IOVB *R4,@LO:: read ca ta ;<4 = .~\iDPR!) MOVB @LOC .*R3 write R3 = @VDP\;D L- l GROM is accessed by ~riting a two-byte address (high order byte first) to the appropriate memory-mapped GROM ~rite address location. Data may then be moved from (to) the GROM read (write) data address which will contain the contents of GROM memory pointed to by the GROM address location. After each operation, the GROM address p o inter automatically increments and points to the next location. Therefore, the address pointer does not have , to be reloaded to move blocks of GROM data. Rl = @MSB(@LSB) two-byte GROM address R2 = @GRMWA - GROM write address R3 = @grmwd - address t o write GROM data R4 = @GRMRD - address containing current GROM data MOVB Rl, *R2 MOVB @R1LSB, *R 2 ) SLA R8,16 delay MOVB *R4,R6 move data from GROM address to R6 MOVB R6, *R3 move data f rom R6 to GROM address To create sound in an Assembly Language progra m, you create a sound list exactly as you .... ould in Graphics La nguage. The address of this sound list should be stored in locaion >83CC which is CPU RAt'!. locati o n >CC. If this ad dress is in VDP RAM, the low order o f R1 4 sh ould be a 1; if t he address is in GRCM , the low order bit should be a O. Location >83CE (CPU RAM >CE - number of sound bytes ) should contain a 1. To a llow for interrupt detection, you should do tw o LIMI instructions about every 400 i~structions . R14LB EQU > 83FD ONE BYTE >01 L-2 SOUND DATA >700 ·Sound list in VDP RAM MOV @SOUND,@>83CC MOVB @ONE,@>83CE SOCB @ONE,@R14LB (400 - 500 Instructions ) LIMI 2 Sees interrupts greater or equal to 2 LIMI 0 No interrupts except reset or load L- 3 APPENDIX M PROG RAMMER/PLAN~ER STANDARDS 1.0 PURPOSE The purp ose of this notebook is two fold. First, it is designed to set f o rth the conventions to be applied across all Home Computer software in orde r to minimize custome r confusion. Our softw are should be viewed as being of the utmost quality, and one way t o accomplish this is t o make the interface between the customer and the Home Compu- ter as much the same as is p ossible, regardless of which package he is using. Secondly, it is designed to help re- duce our development cycle time. One way t o accomplish this is through the use of common subroutines and functions These can be coded and checked out only once . This guide is meant to be an evolutionary document, therefore , your inputs are requested and updates made to it from time t o time. ) ) M-l 2.0 SCREEN PROCESSING AND FUNCTION KEY USAGE The Primary interface between our s o ftware and the customer is through the mo nitor. This occurs with four basic types of screens: o MASTER MENU - tells user basic package options and requires one user response. o SUBMENU - used when a gi ven option in turn has several suboptions, requires one user response. o PROMPTS - used to get necessary data from t he user to process currently selec ted o p- tions, may be one or more screens, o DISPLAYS - provides user with result of selected option. The interface between these screens can lead to a very large c on f usion factor if not handled properly. 2.1 MASTER MEN U Example format would be: INVES T~EN T ANALYSI S I I I l. STOCKS 2. BLACK-SCHOLES OPTIONS PRICING 3 . OPTION WRITING 4. OPTION SPREADS s. BONDS 6. BASIC FINANCIAL TOOLS I, , YOUR CHOICE? ,I - I The usee ·.... ould !:'lake !'lis se::"~c:i o n ':> y \;. eying i :"l a :"-6 anc press ing wT;:?; a!i.] O;:.1er :,es~ on se ·",ou 1. d ca",Se a n e ( =0 : tone. :-\-2 2.2 SUBMENU If option "l't .... as selected in 2.1, the follo . . . ing submenu would appear: STOOlS 1. STOCK PERFORMANCE 2 . THEORETHICAL STOCK PRI CE USING REQUIRED RETURN 3. EXPECTED RETURN WITH THE CURRENT STOOl PRICE YOUR CHOICE? _I The users now have 2 possible paths to ta ke. The normal path is to select a 1 - 3 on the keyboard ( any other entry produces an error t one) . The second path is to re- ) turn to the menu that got them here ( in th is case the Master Menu). The SH IF T-Z or BACK key should be used to accomplish t his . The SHIFT-W or BEGIN key CQuid als o be useci . 2.3 PROMPTS For example, if "1" is selected in 2.2, the following prompt screen might appear: STOCK PERFORM~~CE IN C014E TAX BRACKET ( % J? CAPITAL GAINS TAX RATE (%)? I TO'!'AL DIVIDEND PER IODS? I !)IVID E: 1i) P£R.! ODS ?::~ YEA..q? ) M-3 The cursor is located at the first pr ompt. Here t he user has 3 options: 1. He can key in the requested value, press ENTEF and move to the next prompt . 2. If a "NULL" response is acceptable and the us er wishes not to enter a value, he can simply press ENTER and move to the next prompt. 3. The user can decide that "STOCK PERFORMACE" wa s not really what he wanted t o do. He can press the SHIFT-Z key and return t o the menu that g ot him here ( in this case t h e "STOCK" submenu ). The last pr ompt on the screen is a special case . Here again, the user keys in the reque s ted value an d presses ENTER. At this p o int, rather than automatic al ly going to the next logical pr o cess, the following should appear at t he bottom of the screen: SCREEN IS COMPLETE PRESS PROC 'D, REDO, ERASE Whe r e: PROC 'D means that the us er is read y f or t he prog~am to accept t he data just g iven it an d it s hould procee d to the next logi ca l function - i.e., pr ocess data, a sk for more pr ompts , etc. REDO means that the user wants t o change s ome of the da ta just input so t he p rogram s ho u ld i n effect move the cursor b a ck t o the first entr y ( still sho~ing or re-d i splaying t he user's las t responses ) and let the user mov e thr o ugh the p rom pt s vi a the ENTER key chang ing the ones he wa nts t o. ERASE means t hat the use r doesn't want the pr ogram to use any data just given it - i.e., abort. I n t hi s case, the pr ogram sh ould era se t he screen and start it over, thus wiping out the use r 's last respon ses. The user can also press BACK (S HIFT- Z) - it has the same c onota tion a s ERASE, in t ha t a ll data input on current scre en is los t, but it t akes t he us e r back t o the menu that lead him to this prompt screen . There are se veral special cases that aris~ ~~ ?rocess:r.~ ~ sc:~=no f ?r~m?ts : REQUIRED A:.JD O~ I ONAL PROHP1'S: Whe re at a ll po ss ible , a ll required p rom?ts ( pr ompts that must be ans .... ered t o solve the p roblem), should come M-4 first and be grouped together. While the user is in the required prompt area, the only valid function keys are: ENTER - to get to the next prompt ERASE - erase screen and start it over REDO - change a previously entered value on current screen BACK - takes user back t o the last menu screen BEGIN - ta kes user back to the Master Me nu QUIT - takes user back to the color bar screen When the user has completed all required prompts and is in the optional prompt area, the above keys a re valid with the addition of: PROC'O - takes user immediately t o the screen complete line. REDO CYCLE: If the user has c om pleted all required prompts and then presses REDO, he is reviewing previ ously entered data on the current screen. Once he has made corrections, he can press PROC'D which will automatically take him to t he "SCREEN IS COf.IPLETE" line . This allows him to bypass entries that require no changes rather than having to press ENTER to get to t he bottom o f the screen. ) Wom t o say the same thing in a f orei gn language t ~an in Eng lis h . We nee d to keep t h is:' n mine, because we ''' ou le also like f or t he prom?t and answer t o still fit on one li ne after it is conver~ed to an other lar.guage, M- IO If we will leave a blank line f ollowing each prompt, then the answer can be mov ed to that line, if required, when we translate. For example in U.S. we might say: ) IS THIS CORRECT (YIN)? and when translate d t o French they might say: EST-CE CORRECT (OUI = llNON = 2 ) ? The YES /NO pr ompt is a special type. In the U.S. the term (YIN) is acceptable, but as illustrated above " yes " in a foreign language does not start with a "Y" . Since we do not know what languages we will be t ranslating to, we will use "1" for YES and "2" for NO in the f oreign language . Theref ore, all of our packages should accept a "Y" or "1" f or YES and a "N" or "2" for NO. Another type of prompt we need t o pay special attenti on t o is the "DATE" pr om pt. Every o n e, except the U.S., thinks of cates in DAY / MONTH/ YEAR format. Fo r ease of processing, all packages should process dates only in one format---MONTH / DAY / YEAR. Therefore, each package must check a language flag (se e MULTI-:"INGUAL PLANNING ) to determine t he format and if non-U.S. t h en it must reverse t he order when accepting or displaying dates . ) The format for the date prompt will depend upon the age of the expected user , but if at all possible shou!.d be as foll o ws: TODAY'S DATE? I I People in the u .s. wil l automatically input M!1/ DD/ YY and else .... here, they .... i ll inpu t DD/MM / YY. We can determine order by kno .... ing if the package is u.s. o r not. If t he planne:: feels that the date need s to be mo:e explicit, then the f ollowing format should be used: TODAY'S DATE : MONTH? DAY? YEAH.? Note that the prefix "19" is be i ng dropped f rom the year. With the underscore it is obvious t h at t he last t .... o digits are all that is requir~c, pl u s it 9!Ve us 2 extra charac~e:s on ~~e !~~~. In packages that require data logic ( difference bet .... een two dates, etc.) the second f or mat should be used. This is especially true if a package like this is t o be marketed in the U.K . or Canada .... ith no changes fr om the M-ll U.S. version. In this case, we need it absolutely clear that the date order is MM/DD/YY, as .... e have no way of telling whether the package is being run in the u.s. or U.K. 4.0 MULTI-LINGUAL PLANNING In designing packages that will be translated from U.S. to a foreign language there are several items that must be taken into consideration. Some of these have already been discussed under PROMPT FORMATS (3.2.) The f ollowing items are also required to make the conve:sion as easy and inexpensive as possible: 1. All text must be located in one GROM. If this is not possible, then a concerted effort should be made to reduce the amount of text so it will fit. Only after all possibilities have been explored, should .... e go to 2 GROMS for text. 2. If the package uses the cassette DSR, then in the text GROM we must leave 400 bytes of free space to alIa .... for the inclusion of an override DSR . This is the only way the DSR text can be translated from u.s. to a foreign language. 3. We must also leave 150 bytes of free space t o allow for t h e inclusion of an ov erride p o werup program so that the in t roduc t o r y ( col or bar ) screen can be trans l ated. 4. Most foreign languages take mo re root:! than U.S . As a rule of t humb . ' -@VI" --- 9E DE ]f 5f ® - ----- " )f XPT Of _ J FIGURE M.3 SPRITE TABLE VOP REG 11 I - TE: YF'T XF'T CHAR CD L. VElD· Y X SPRITE : YF'T XPT CHAR. CO L. VElD· Y X CITY CITY >7 C11 ,0 >300 >lQ4 > 7811 >764 '6 >340 17 >l44 >7 C4 Z > 308 >788 18 >348 >7 Ca l >30C >78 C ,9 > 34C >7 CC I 4 > 31 0 >790 ZO > 350 > 700 5 > 314 >794 Z, >lS4 >704 6 >3 18 >798 22 >JSa > 70 8 7 >l ' C >79C ZJ >lSC >7OC 8 >l20 >7AQ Z4 >l60 > 7E O 9 > 324 >7 44 Z5 >l64 I >7E4 '0 >l 28 I >7A8 Z6 >l68 I > 7E3 >lZC I >7AC 27 >l6C I >7EC " >3JO > 780 28 > 370 > 7FO ,. '2 I 'l l >lJ4 1>784 Z9 >374 >7F 4 I > 338 I > 788 lO > 378 >7F B '5 >33C I I > 7BC I l' >17C I > 7FC CHAR·I RAM I DAT,.\ CHAR RAM I OA7A CHAR. I RAM I DATA CHAR. RAM I O~TA . >8' :0 I >.l00 I >"18 >.lCO > BO >5,0 t >C3 ! > 640 I >648 I ==,408 I ><1 9 >.l C8 > B' >58 8 > C9 >'2 I >"0 >"IA >' 00 >82 > 590 >CA >650 I >8l >"8 >9 B >'08 > B3 > 538 >CB I >m I >84 >'20 I >9C >' EO >,4 >oAO I >CC I > 660 I >85 >'28 >'30 >4 E! I >SS I >;AB I >CO I > 668 I >86 I >430 >9E I >' FO I >8S >;ao I > CE 1>070 I >8 7 I >438 >'3 F >' F8 > B7 >;88 I >CF I >678 I >BB I >440 >A O >~oo > B8 >5CO I > 00 1 >63 0 I >89 I >448 I > A' >008 >a9 >oC8 I >0' I > 638 I > 8A >450 I >A2 >5 10 >aA >000 I >02 I >690 I >8S >4S' I >A3 1>518 > BB I >;08 I >03 1 >631 I >8 C >4S0 I > A4 >520 > BC I >;EO I >04 I >6AO I >.0 >'SB I > A5 >528 I >,0 ! >; E3 I >05 I >5A8 I >8E I >47 0 I > AS nJO I >9E I >5FO I >06 I >6ao : >8F I >478 I > A7 > 538 I > BF I >0,9 I >07 I >o 5S I I >90 I >480 I > A8 I >o4ll I > CO I >600 I >08 I > 6;:0 ! >~ l >.!S8 • >.9 I > 5.l8 I > C~ , >?ua >as , >'; C3 >:2 i .>olg a I > .l.':' ! >::\1 ·• >C:! :::-610 I j > G..l. . >; ;:JO , >93 I >498 I > A8 > 558 I . >C3 I >618 I >OB : >5u s ; "4 I >lAO I > .1.C I >560 >C' >020 I >OC I >5E o ! >95 i >4A8 I > AO I >568 I >Cs 1>628 I >00 I >i E. I >96 I >4ao I > AE > =70 •I > CS I > 6~O I >OE I >; ;:0 I :>9; I >l88 I >AF >575 I >C7 1>038 I >oF I>m I :1-15 I' I lJllii t 'I TITLE __ ....... -, - - - -, - , -.-- - - SE TO SE I I SET 2 SET 3 SET --4 SET 5_. ____6 0-- ..SE-_.-. "SET T 7 - -- ..SET 8 .. ._----- -.-_._ SET 9 SET 10 . . , ---_._ flAM ~ 8UO [III.{I II : IIAM .· 11 ~o 1:1)11111 : 11l\M > 8DO Clllon : nI\M > 8CO COlOIl : COLOII : IlI\M > !JOO Clilon , RAM > 980 COlon, nAM > !J40 -- -nAM> - --- 9CO COlon, .. - , --nAM>AOO ... _..... --_ COlon , _.. nAM >A40 . _ -- COlon , - - nAM ..- - >--- COlon , AIO _ ,·no - - - -- -. -- - . -- . - - - - > U8 > 10 >18 5" > 10 I > 18 0 >1 0 8 -- _. '"18 @ >4 0 II >..48.. P ~ nl , - - - .. >50 .. ;.. II!I > 11 >19 > /1 I > 19 I >1 1 9 '"19 A >41 . I__ . > 49 0 >1 1 .:- 0 ] .:- 111\ > 11 ;..11\ .. > 12 • >21\ 1 >11 , >lA B - - >41 - J -- •. . - - - >'1 A -- .- -- . n . '" 51 -- > 0) : > un > 11 > 111 • > 1) I > 10 ) .. >ll , - '"10 C , >41 - - K - >4 n s - > 5) > 1JlI ::> ut: > 14 >I~ S :;..24 , >2r. 4 > )4 < >lC II >44 l > 4C T > 5" > U~ > nll > 11 > 111 . " >/1 - > 211 \ >35 • . - :» 1) E -- >45 M -- ... >'10 U -- - - .. --- :..55 > llIi .. III :.. 111 ,- III :.. Hi > 11 :..H - • , >2li > 2E r. >31; > -- - .. >JE F .. >46 N .. - , :> 56 -- -.- '"4E V - .... - > 11 > 11 / '" 11 1 '" )1 1 '")' G >41 0 > 41 W ;.. 51 !;I I I I S EII ~ SF. T 1J SE r 14 SET I!. SEl 16 SET 17 SET 18 SET 19 SET - SET - - - _-0. _ . . . -- - " - - 20 .. - 21 - - 11M.. ,·1\1:0 IIAM ..... 11 10 11Mb 1140 flAM :-. 1100 nAM > 111:0 nAM ;...[00 RAM :;>o C4 0 nAM '" C~O 1:11 1 1111 : r.n l HIl 1:111011 : r.UlIlIl : I: OI.UI1 : - . - - ~ >C80 .."AM--- - - nAM >UOO - - -- -_. . :> U40 RAM ~(fllln : Clilon , COlon , COlon : COlon , - ... - , - .. . ,. - - .. ..-. .COlon , x .~ l~ I V I :..- 5" ::;.. !.o!J , IA ·IiU ;.. Ii I ;. fi1 :... till > fi!.J ;.. Ijl\ :> III ;.. II > 11 :.. /11 > )g > UU > 81 - - - >08 - >89 - --- -- > gn >91 - - .. ;;.. !l8 >99 I. -- >..An >A I - I- f-- >.0 >AU - - - _.. ;.. 11\ > 81 > BA . .. - >92 _ , .. . _..> OA > Al - -- - . >AA -- !.oil .... Ii ·' :.. IiII > 7l ::.. IU > 81 ,I 1 ' f, -. Ii·' ;.. (j r: ~H > 1C: :>o U~ '" 8U >8(; -- - -- >!IJ . - - - -- - -- - > go - .. >Il -l -- -- - >AO - ... - -- > !1<1 ~ , . >IIC - - - - --- > 9C .. >M -- - .... to II _ li~1 :.. lill > f!.! ;.. 11) ;.. n ~ 1 >811 ::.. 9!i . > 911 >AI >i\n , I I:~~I - , - - - - :> fili ::.. lil :.. /ti ;... 7F ;. Hli >8£ >96 > !Jl >M > A( -- 1--. '.-.- tof_ ... Ii I --- - .. - - -. ;:> jjl - -- , /I -- .. n- - -- " . ~..... ' > 8( > g, > !J r -- > AI >., Sf I V Sll 1 , I !I t "1 111 SF r 2~i SE T ~ Ii ~l r "2 7 SEl 21l :in 29 SET ... - 30 SET 31 III\M "·lIlIn IlI\M .. I 11:0 IIIIM ;. I UU II /1M :.. Lo1U IIAM :,.. (011 flAM :,.. HU I1AM :> ruu IlAM > r40 "AM ;:.. ruo RAM > feD --- -- - ....-- .. --- 1;1111111 : CIIIIIII : t:flllIll: till 1111 : CUllin : efll nn : I:OlllO , -- _.. 1: 01.111" Cll llln , CliLO n , -- ·1111 · ' IUI ... r:u > rH ... IJIJ :-118 > EtI > [8 > (0 > r8 .. _.. I __ f: I - , - - - ..... 111 ;.. /I!I ... f.!J .. III :... II!I >U > E9 > FI >(g - -- - .... 11 / . • 1\ /\ .... 1:1 ;:.. 1: 1\ > 11 1 >11/\ > (] > fA :.o Ff\. > f1 .... /11 .. liII :... 1:] :. f: II ;.. 11 ] > 1111 >0 > EO > Fl >f ll -- - -- .... 11 ., >u., -- - --- -- - ·-IIt: > 1:4 ;. 1:1: >i ll: > [4 >EC > fo1 >re - .. . - - - .-. ;.. II !. .... 1111 ," 1: !J ..... 1:11 > lIfl ;:.{ III > E!J > £11 > F5 > FO -, - . --- - - ... . ."" lit· .... [Ii .... 1:1: :> 111; ;.111' > EE > r6 . , . "' '. " . . ... > E6 _ r oo - ' . r:r - - - - -, -- - - - -" ri GIi RE M.S ~ TEXAS,!,~_~!.':,~.M EN TS _ _ _ _ _~_ __,H::Oc::M_:E::C_::: O-M-P- UT-E- R-.. G-R-O-'.-,.·-D-EV -E- cO - P_M_E_NT PROJECT: F- ' E ! I I I I I I I I I IT I I I I. I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I I i I I I I I I I I ,I I I I I I I I I I I I I I I I I I I I I I i I I I I I I I I I I I I I ,I I I I i I I . I I I I I I I I I I I I I I ,I I I I I I I , I I I I i I I I , I I I I I I I I 1 I I I I I I I I I I I 1 I I I I I I I I I I I, I, I I I ! I I I , I I I I I I 1 , I I I I I I I , I I I I I, i I I I I I I I I I I I I, I I I I I I I I I I I i I I I I I I I , I I I i I I I I I I I I I I I I I I I I I i I ! I I I I I I I I I I I I I I I I I I I ! I 1 I I I I I I ,, I I I I I i I , I I I I I I , I i ,I I I , I I I I I I I I I, I I I I I ,I I , I, ! I, ,, I I i I I I I I I I • I I I ,I I I, ! I, I ! b n ! I I , I I 1 I I I I I I I . II I I I . , . I I I E:. --=: 1 I i ! i i , I I I I I , I , ~ I ; I I I I I I I . i I , , . I I I I , , , I I , I I I ! , , ! Ii , I : , I !i I , I I .; , I I I I I I I , I, , I I I I I I I , I I I , I ; I I I I! I I I I iii I I I \ ~ I I , i I! I I i , I , . I I . I I I I I I . , I I V1C EC iCQ ?Y ).t.:OI Oi TCNES · ALPHA BETICAL INDEX Page Addressing Hodes Direc t 3-5 , 3-7 Imm ed ia te 3-2, 3-7 Inde xed 3- 5, 3-7 Indexed Indirect 3-7 Indire ct 3 - 5, 3- 7 Top of Stack 3- 4 ASCII Character Sets 3- 1 3 , H-3, H- 4 Bit Reversa l H- 5 Casse tte DSR I - I CPU RAM 2- 9, 2 - 10 2 - 11 Destination Address 1- 1 I 3- 4 Floating Point Subroutines K- I ATN K- 9 CFI K- IO CNS K- 2 COS K-7 CSN K- I 0 EXP K- 6 FA DD K- , 1 FCOMP K- 13 FDIV K- 12 FMUL K - 12 FSUB K- 11 INT K- 3 LOG K -6 PWR K-4 SADD K - 13 SCO:1P K - 15 SD!V !{ - , 5 .:: : :; ... . ,, - ':: '.("'- SQR K- 5 SSUB K- 14 TAN K-8 ALPH ABETICAL INDEX Page 2 Funct ion Keys M-2. M- 8 GPL As sembler GPL Directive s A-2 BASE A-3 DATA A- 2 EN D A-2 EQU A-2 GROM A-3 LIST A-4 LISTM A-4 ORG A- 3 PAGE A- 4 TITLE A- 2 UNL A- 4 UNLM A- 4 GPL Instructions 4- 1 . J- 1 I J- 4 A 4 - 23 ) ABS 4- 31 ADD 4 -2 3 ALL 4 - 49 AND 4- 3 4 B 4-15 BACK 4- 48 BR 4 - 111 I A- 8 BS 11 - 13 , A- 8 CALL 4 - 17 CARRY 4- 4 . A-8 CASE 4 - 16 CEQ 4 - 6, A- 8 CGE 4 - 10, A- 8 CGT 4- 9. A- 8 CH 4 - 7, ..! - 5, A- 8 CLOG 4 - 11 , A- 8 CLR 4 _ 37 COING 4 - 47 , E- 1 ALPHABETICAL INDEX page 3 GPL Instructi ons (Cont.) o 4- 26 DA 4-23 DABS 4-31 DADO 4-23 DAND 4-34 DCASE 4-16 DCEQ 4- 6 DCGE 4-1 0 DCGT 4-9 DCH 4-7 DCHE 4-8 DC LOG 4-11 DCLR 4-37 DCZ 4-12 DD 4- 26 DDEC 4 -29 DDECT 4- 30 DDIV 4-26 DEC 4- 29 DECT 4- 30 DEX 4- 39 DINC 4-27 DINCT 4- 28 DINV 4- 33 DIV 4- 26 OM 4-25 DMUL 4-25 D~EG 4-32 DOR 4-35 DS 4-24 DSLL 4-43 DSRA 4-44 DSRC 4-46 DSRL 4- 4 5 DST 4-38 DSUB 4- 24 DXOR 4- 36 EX 4- 39 EXIT 4-57, 8-4 FETCH 4-18 FMT 4- 50 GT 4-3, A- 3 ..: -2, A-8 HOME 4- 59 I/ O 4- 58, F-l ALPHABETICAL INDEX Page 4 GPL Instructi ons (Can t. ) INC 4-27 INCT 4-28 INV 4-33 M 4-25 MOVE 4-42 MUL 4-25 NEG 4- 32 OR 4-35 OVF 4- 5, A-8 PCP 4-41 PUSH 4-4 0 RAND 4-53 RB 4-21 RTN 4-19 RTNC 4- 20 S 4-2 4 SB 4- 21 SCAN 4- 54 SLL 4-43 SRA 4- 44 l SRC 4-46 SRL 4-45 ST 4- 38 SUB 4-24 TBR 4-2 1 XML 4- 55, H-3, K-l, L-1 XOR 4- 36 GPL Macro Instr uct io ns SCALL A-7 SCASE A-6 SELSE A- 6 SEND A- 5 SFOR - TO A- 5 SFOR - DO~-J;J70 A-6 SGOTO A-7 SIF - GOTO A-6 SIF - THEN A-6 . --. -- .:0 ':':'_':':' :~'. - .; S.SZ:-;i) A-3 $UNTI L A- 5 SWHgE A-5 ALPHABETICAL IN DEX Page 5 Page GPL Timing 1-2 Hand se ts J oystick Codes 0-8 Remote 0 -1 , 0- 6, 0-7 Wired 0-2 Ins truction Formats 3-9, 3-10 3-11 Keyb oards 40-Key 0-1, 0-4, 0-5 Remote 0-2 Label 3-5 Moni t or 1-3, H-4 Multic olor Hade 2- 6, G- ~ Patt ern Col or Table 2-2, 2-3 , 2-4 Patter n Generator Sets Mult ieolar Mode G-2 Normal Mode 2- 2 Text Mode G-1 Patte rn Na~e Tab l e Mult ieolor Mode G-2 Nor ma l Mod e 2-2, 3-1 Tex tHod e G- 1 Patte rns ( Characters ) 2 - 1. Peripheral Access Blo ck ( PAS ) 1-2 :!- : . Radix 1 00 Numbers K-16 ALP HABETIC AL INDEX Pag e 6 Referen ce Documents 1- 4 Sample Pr ogr-am B-2 Sound C- l , H- 5 Source Operand 1 -1 , 3- 3 Sprites 2- 3 Sprite Attribute Block (SAB) 2-3 Sprite Descriptor Block (SOB) 2- 6 Sprit e Velocity Block (SVB) 2 - 7. 3- 1 , B-1 Block 3 - 17 I 3 - 21 , H- l ... ation ) H- 1 , H- 2, H-3. H- 5 a t ion 2- 1 2 - 8, G- 1 2- 1, 2 - 9, 2 - 12 Control Registers 3 - 14 , 3 - 15 , 3 - 16 , H- 3 USER'S RESPONSE SHEET Graphics Programming Language User's Guide December 3, 1979 User I S Name, _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 'l'e lephone, _ _ _ __ _ COMPANY __________________________________ Date,______________ Please li st any discrepan cy found in ' this manual by page , paragraph, figure, or table number in the f o llowi ng space. If there are any o ther suggesti o ns that you 1M ish to make, feel free to include them. Thank you. LOCATION IN MAN UAL COMMENT/SUGG EST ION