This is a translation of the second half of the Tsushin Tool manual Translation by Chris Covell (chris_covell@yahoo.ca) ####################### PAGE 28 ############################# 5. Program (BASIC) Function 5.1 Constants 1) Base 10 Constants: -32767 ~ 32767 [sic] 2) Base 16 Constants: $0000 ~ $FFFF 3) Text Constants: An apostrophe (') is used to quote or enclose a single character (no distinction between full width and half width.) This passes its ASCII Code to other functions. X='A' X is set to $41. PRINT 'A' A is displayed. 4) String Constants: A double-quotation mark (") is used to quote or enclose a string. It is used in the operand of a PRINT statement. 5.2 Variables Single letters from A-Z (26 capital letters only.) Variables are 2 bytes: -32768 ~ +32767. 5.3 Pointers 1) Byte-Length Pointers: An address prefixed by an asterisk (*) accesses the byte stored at that address. 2) Word-Length Pointers: An address prefixed by a period (.) accesses the word stored at that address. If PRINT takes a string pointer as its operand, it will start printing text from the pointer's referenced address until it reaches a terminator (0). This functions similarly to the usual BASIC's PEEK and POKE commands. With pointers, the user is able to access only the memory available to him. Memory used by the system is off-limits. The size of the pointer memory can be checked with the command PRINT FRE(1), whose maximum size is 2.5 KBytes. *$0000=15 The address offset $0000 is set to 15. *.0001=$FFFF [sic] The address offset $0001 is set to $FFFF. X=*$0000 Variable X is set to 15. X=.$0001 Variable X is set to $FFFF. ####################### PAGE 29 ############################# 5.4 Operations 1) (1) +,- Positive, Negative number (2) *,/ Multiply, Divide (3) +,- Add, Subtract (4) [sic] MOD [INT Divide missing?], Remainder 2) Comparisons (1) = Equal (2) < Less Than (3) > Greater Than (4) <=,=< Less or Equal (5) >=,=> Greater or Equal (6) <>,>< Not Equal 3) Logical Operations (1) AND Bitwise AND (2) OR Bitwise OR (3) XOR Bitwise Exclusive-OR 4) Shift Operations (1) << Left Shift (2) >> Right Shift ex. X<<3 X is shifted 3 bits to the left. Y>>6 Y is shifted 6 bits to the right. 5) Order of Operations 1. Sign 2. Multiply/Divide 3. Shift 4. Remainder 5. Addition/Subtraction 6. Comparisons 7. Logical Operations ####################### PAGE 30 ############################# 5.5 About BASIC Screenmodes (1) Colour Terminology To generate a dot on-screen, the PC-Engine needs 3 types of data: Palette, Colour Code, and Colour Data. 1) Palette: Each character on the PC-Engine (whether an 8x8-dot BG Character or a 16x16-dot Sprite Character) can use one of 16 (0-15) BG or Sprite Palettes, respectively. 2) Colour Code: A character's Font Data is stored in 4 planes. Each dot can thus be one of 16 colours (4 bits, 0-15) represented by a Colour Code. 3) Colour Data: Each Palette has 16 entries (0-15) for Colour Data. This data is how colour values for the Colour Codes are chosen. There are 512 possible values ($000-$1FF) for the data, of which $000 is black and $1FF white on-screen. For all Palettes, Colour Code 0 appears as Palette 0, Colour Code 0. In the BG Character & SPR Character Editors, only Palettes 0-7 of each of the BG and SPR Palettes can be edited. Palettes 8-15 are reserved for use by the Tsushin Tool programs. However, in Character Mode, the SPDSP, CHPAL, BGPAL, CELPAL commands can set the BG or SPR characters to any of the 16 BG/SPR Palettes. Here are the colour data of BG & SPR Palettes 8-15: [omitted from this translation] ####################### PAGE 31 ############################# (2) Screen Modes 1) Text Mode (Same as the screen mode during Communications.) Type 'CLS 0' to set this mode. Because Characters can't be set individually, this mode is fixed to Palette 0. When text is printed to the screen by BASIC's PRINT statement, only one plane (Plane 3 of 0-3) is used. When CLS 0 is executed, all dots' Colour Codes on the screen are cleared to 0. Text Colour Code is set to 8 (1000B). When the screen is scrolled or the cursor moved, only Plane 3 of the Font Data is altered. 2) Graphic Mode Type 'CLS 1' to set this mode. This mode is restricted to Palette 0, as above. When graphic commands (LINE, BOX...) are executed, all 4 graphic planes' data can be manipulated. 3) Character Mode Type 'CLS 2' to set this mode. This mode is only for use with graphic data created in the Graphic Editor. As VRAM is used by such character data, Text Mode-only and Graphic Mode-only commands (PRINT, LINE...) cannot be used. 4) Using Text & Graphics together: Graphics commands can be used freely in Text Mode, and vice-versa. However, when text and graphics overlap, their planes will also overlap, so be careful when scrolling text, etc. ####################### PAGE 32 ############################# 5.5 Direct Statements (1) RUN Starts execution of a BASIC Program. RUN [Line No.] If a Line Number is supplied, execution will begin from that line; otherwise, it begins from the first line of the program. (2) DELETE Deletes Program Lines. DELETE [First Line No.] [-] [Last Line No.] [First Line No.] deletes a single line. [First Line No.-] deletes that line and all lines after it. [-Last Line No.] deletes all lines up to and including the line. [First Line No.-Last Line No.] deletes all lines in that range. ex. DELETE 10 Line 10 is deleted. DELETE 10- Lines 10 and up are deleted. DELETE -10 Lines 10 and under deleted. DELETE 10-100 Lines 10 to 100 are deleted. (3) LIST Displays Program Lines. LIST [First Line No.] [-] [Last Line No.] [First Line No.] lists a single line. [First Line No.-] lists that line and all lines after it. [-Last Line No.] lists all lines up to and including the line. [First Line No.-Last Line No.] lists all lines in that range. ex. LIST The whole program is displayed. LIST 10 Line 10 is displayed. DELETE 10- Lines 10 and up are displayed. DELETE -10 Lines 10 and under displayed. DELETE 10-100 Lines 10 to 100 are displayed. (4) RENUM Renumbers Line Numbers RENUM [New Line No.], [Old Line No.], [Step] All lines starting from "Old Line No." will be renumbered to "New Line No." plus the Step value for each successive line. GOTO, GOSUB commands, etc, will also have their operands adjusted accordingly. If each operand is left out, the following are used as defaults: New Line No. 10 Old Line No. The lowest Line No. Step 10 (5) AUTO The BASIC interpreter automatically enters line numbers. AUTO [Line No.], [Step] The interpreter will insert line numbers anytime the RETURN Key is pressed, increasing the line number by the step value (default of 10) for each line. This will continue until the user presses CTRL-C (SELECT+II). In TEXT Mode, not only a line number but a ' (REM) will be added. ####################### PAGE 33 ############################# (6) EXIT Exits the BASIC Interpreter and returns to the Program Menu screen. (7) NEW Clears the current Program or Text File. (8) TEXT Enters TEXT File creation mode. The Program File is closed and a downloaded(?) Text File is opened for reading. In TEXT Mode, when the TYPE command is used, a file used for uploading is displayed on the screen. (??) [I don't understand how to create anything at all useful in TEXT Mode...] (9) BASIC Enters BASIC programming mode (from TEXT Mode.) (10) TYPE Displays Text Lines (in TEXT Mode only.) Commands are identical to LIST, but the output is formatted differently: LIST's Output TYPE's Output 10 A A A A A A 20 B B B B B B 30 C C C @ C C C D D D 40 D D D E E E 50 E E E ####################### PAGE 34 ############################# 5.6 General Statements (1) END Stops program execution. (2) FOR TO STEP Starts a FOR-NEXT loop. FOR Variable=Start Value TO End Value [STEP Step Value] The loop will start with the Variable at the specified Start Value, increasing the Variable by the Step amount until it reaches the End Value. A negative Step Value is also possible. ex. FOR X=1 TO 10 STEP 2:PRINT HEX$(X+40):NEXT:END (3) NEXT Ends a FOR-NEXT loop. NEXT [Variable, ..., Variable] If the Variable in the FOR...TO statement is within the limits imposed by the End Value, the loop will continue. If the Variable in the FOR...TO statement has exceeded the End Value, the loop will end. ex. FOR X=1 TO 10:PRINT HEX$(X+40):NEXT X:END (4) GOSUB Jumps from the current line to a specified Subroutine. GOSUB Line No. The Subroutine specified by GOSUB will be executed until it reaches a RETURN statement, where it will return to the point after the GOSUB statement. ex. 10 GOSUB 100 ............ 100 PRINT X; 110 RETURN (5) GOTO Jumps to a specified line. GOTO Line No. (6) IF THEN ELSE IF Condition THEN Statement/Line No. [ELSE Statement/Line No.] If the Condition is true then the Statement following it will be executed (alternately, execution will jump to the supplied Line Number.) If the Condition is false, then the Statement will not be executed, (and the statement supplied with ELSE will be executed if ELSE is present.) ex. IF X=0 THEN 30 ELSE 10 IF X=0 THEN PRINT "ok" ELSE PRINT "bad" ####################### PAGE 35 ############################# (7) RETURN Ends a Subroutine (see GOSUB). (8) REM Denotes a Comment Line. An apostrophe (') has the same function. (9) PUSH Pushes a Variable onto the System Stack. PUSH Variable[,Variable,...] ex. PUSH X:GOSUB 30:POP X PUSH X,Y,Z:GOSUB 100:POP Z,Y,X (10) POP Pops a Variable off the System Stack (see PUSH). (11) DATA Stores sets of numbers as Data Constants. Values are separated by a comma (,). DATA 10, 20, $FFFF (12) READ Values from a DATA statement are read and stored into a Variable. READ Variable [, Variable, ...] Reading begins from the DATA statement with the lowest Line Number. ex. READ X,Y:PRINT X;Y (13) RESTORE Specifies the point from where DATA READing begins. RESTORE [Line No.] If no Line Number is specified, reading begins from the DATA statement with the lowest Line Number. If a Line Number is specified, reading begins from the first DATA statement starting from that Line Number. ####################### PAGE 36 ############################# (14) CLS Clears the screen. CLS [N] N: Screen Mode 0: Text Screen Mode 1: Graphic Screen Mode 2: Character Screen Mode When N is not specified, CLS 0 is executed, and Palette 0's Colour Data is initialized. When CLS 2 is executed, the screen is filled with BG Character 0, Palette 0 data from the Graphic Editor. Also, BG Palettes 0-7 and SPR Palettes 0-7 are sent to the Colour Registers, while the following files created with the Graphic Editor are uploaded to VRAM. (In Character Mode, Character-only BASIC statements can also now be used.) BG Font Data CELL Data MAP Data SCREEN Data SPR Font Data ANIMATION Data (15) LOCATE The starting position of text printed by the PRINT statement can be set. LOCATE Column No., Line No. Column Nos. 0 - 39 Line Nos. 0 - 15 (16) PRINT Prints text to the screen. A semicolon (;) separates operands on the same line. PRINT Value [; Value; Value;...] Numerical Constants Variables Text Constants Pointers CHR$ (Value) The value's ASCII Code. The following codes have a certain effect: $05 Deletes all text from the cursor to the end of the line. $07 Deletes the letter under the cursor. $08 Deletes all text from the cursor to the beginning of the line. $0A Moves the cursor down 1 line. (??) $0B Moves the cursor to home position (0,0) on-screen. $0C Clears the screen and moves the cursor to home position (0,0) on-screen. $0D Moves the cursor to the beginning of that line. (??) $1A Deletes all text on-screen after the cursor's position. $1C Moves the character under the cursor to the right. (??) $1D Moves the character under the cursor to the left. (??) $1E Moves the line under the cursor upwards. (??) $1F Moves the line under the cursor downwards. (??) $7F Deletes the letter under the cursor. HEX$ (Value) The value is printed in Base 16. ####################### PAGE 37 ############################# ex. Result PRINT 30 30 X=20:PRINT X 20 *($0000)='A':*($0001)=0:PRINT *($0000) A PRINT 'A' A PRINT 'KAN' [Kanji character] KAN PRINT "KANJI" [2 Kanji characters] KANJI PRINT CHR$($41) A PRINT HEX$($32) 32 (17) PSET Draws a graphic point on the screen. PSET (X,Y) [,COLOR] X: Horizontal graphic position (0-239) Y: Vertical graphic position (0-203) COLOR: Colour Code (0-15). If omitted, the colour will be the Graphic Foreground Colour Code. (18) LINE Draws a graphic line on the screen. Values operate the same as PSET. LINE (X1,Y1)-(X2,Y2) [,COLOR] (19) BOX A rectangular graphic box is drawn on the screen. BOX (X1,Y1)-(X2,Y2) [,COLOR, FLAG] Values operate the same as PSET. If FLAG is 0, an unfilled box is drawn; if FLAG is any other number, a filled box is drawn. (20) COLOR COLOR [C1, C2, C3, C4] C1: ($000-$1FF) The Colour Data of Text Colour Code (Palette 0, Colour Code 8) can be changed. Default is $1FF (White). C2: ($000-$1FF) The Colour Data of Background Colour Code (Palette 0, Colour Code 0) can be changed. Default is $087 (Blue). C3: (0-15) The Graphic Foreground Colour Code is changed. This change is reflected the next time a graphic statement is executed. Default is 7. C4: (0-15) The Graphic Background Colour Code is changed. Default is 0. When CLS 1 is executed, the screen is filled with the colour specified by this code. When CLS 0 is executed, the screen is filled with Colour Code 0. This is the only difference between CLS 0 and CLS 1. If no operands are supplied, C1-C4 are reset to their defaults. ####################### PAGE 38 ############################# (21) PALETTE Sets the Colour Data of a specified Colour Code. PALETTE P1, C1 [, P2, C2...] P1: Colour Code (0-15) C1: Colour Data ($000-$1FF) If no operands are supplied, All colours in Palette 0 are reset to their defaults. (22) PAINT Fills an area with a colour until it reaches a specified boundary. PAINT (X,Y) [, C1, C2] X: Horizontal graphic position (0-239) Y: Vertical graphic position (0-203) C1: Fill Colour Code (0-15). If omitted, the colour will be the Graphic Foreground Colour Code. C2: Boundary Colour Code (0-15). If omitted, the colour will be the Graphic Foreground Colour Code. ex. CLS:CIRCLE (120,102),75,4:PAINT (120,102),2,4 (23) CIRCLE CIRCLE (X,Y),R [, C, F] X: Horizontal graphic position (0-239) Y: Vertical graphic position (0-203) R: Radius C: Colour Code (0-15). If omitted, the colour will be the Graphic Foreground Colour Code. F: Ratio. 100 is circular, less than 100 is wide, greater than 100 is tall. (24) VPUT Data is loaded to the selected VRAM Address. VPUT (VADR, DATA) VADR: VRAM Address DATA: Data (from a DATA statement (??)) to be transferred. (25) VTRANS Data is loaded from Main RAM to the selected VRAM Address. VTRANS (VADR, MADR, LEN) VADR: VRAM Address MADR: Memory Address of data to be transferred. LEN: Length in Words. (26) INPUT Numbers or strings are entered by the user. INPUT X (*X) If X is supplied, the Variable X is loaded with the input. If *X is supplied, it is loaded with a pointer to the input text string terminated by a 0. ex. 10 INPUT *X The program waits for input by the user. Here, the user types "30*2[RET]". 20 PRINT *X "30*2" is displayed on the screen. ####################### PAGE 39 ############################# (27) MINIT Initializes the audio channels (tracks) to play music data (MML Data) for use with the PLAY command. MINIT X X is the number of tracks to use (1-6). Default is 1. MINIT needs to be executed before the PLAY command, otherwise music tracks may only be played through a single channel. When MINIT is executed, space is allocated in SRAM for the music data. If there is not enough space in SRAM, an error will be displayed. (28) PLAY Sets up MML music data to be played. PLAY (X,) String (, String,...) X: Track Number (0-5). Valid numbers are determined by the number of tracks set up in MINIT. String: MML Data, separated by commas (,). Examples of valid data: 1. "ABC" 2. 'A' 3. Numerical Constant (or ASCII Code) X 65 $41 4. Pointer *X (29) MPLAY Starts playing the music data specified in PLAY. MPLAY ex. 10 MINIT 3 20 X=0:GOSUB 200 30 PLAY X,"CDEFGAB>C8CC8CEDCFEDG8" 80 MPLAY 90 X=INKEY(1) 100 END 200 PLAY X,"L2" 210 PLAY X,"O3V28" 220 RETURN (30) SOUND Plays a sound effect (valid numbers are 0-65.) SOUND X ####################### PAGE 40 ############################# 5.7 Character Screen Mode-only Statements The commands below are to be used after setting the mode with CLS 2. (1) BGDSP Displays SCREEN Data along with BG Font Data created in the Graphic Editor. BGDSP N N: Page Number (0-3) (2) MAPDSP Displays MAP Data along with CELL Data and BG Font Data created in the Graphic Editor. MAPDSP N, MODE N: Page Number (0-3) MODE: MAP Arrangement Mode: Mode 0: 0 1 Mode 1: 0 1 2 3 Mode 2: 0 2 3 1 2 3 (3) MAPHSCR Sets the Horizontal Scroll after MAPDSP is executed. MAPHSCR Scroll Val. (4) MAPVSCR Sets the Vertical Scroll after MAPDSP is executed. MAPVSCR Scroll Val. ####################### PAGE 41 ############################# (5) ANIMSET Displays the Animations created in the Sprite Pattern Editor. The User Specification Number is used in the statements ANIMMOVE, ANIMCLR, SPMOVE, SPCLR. ANIMSET (X,Y), N1, N2 [, N3, XW, YW, F] X: Horizontal Graphic Position (0-255) Y: Vertical Graphic Position (0-255) N1: User Specification Number (0-255) N2: Animation Data Number. This is the Pattern Editor Data created in the Graphic Editor. (0-) N3: Animation Loop Value. If 0, the animation will loop infinitely. If non-zero, when the animation finishes its specified number of loops, SPCLR will be executed automatically. XW: Horizontal Effective Size (Default is 16). SPTOUCH, SPMCHK use this value. YW: Vertical Effective Size (Default is 16). SPTOUCH, SPMCHK use this value. F: BG Priority Setting. (Default is 0). If 0, the Sprite has priority over the BG. If non-zero, the BG has priority over the Sprite. (6) SPDSP Displays a Sprite created in the SPR Character Editor. SPDSP (X,Y), N1, N2 [, C, CGX, CGY, XF, YF, XW, YW, SPBG] X: Horizontal Graphic Position (0-255) Y: Vertical Graphic Position (0-255) N1: User Specification Number (0-255) N2: Sprite Data Number (0-63) C: Palette (0-15). Default is 0. CGX: Horizontal Size. (Default is 0) 0: 16 pixels wide 1: 32 pixels wide * CGY: Vertical Size. (Default is 0) 0: 16 pixels high 1: 32 pixels high * 2: 64 pixels high * XF: Horizontal Flip. (Anything other than 0 activates Flip.) YF: Vertical Flip. (Anything other than 0 activates Flip.) XW: Horizontal Effective Size (Default is 16). SPTOUCH, SPMCHK use this value. YW: Vertical Effective Size (Default is 16). SPTOUCH, SPMCHK use this value. SPBG: BG Priority Setting. (Default is 0). If 0, the Sprite has priority over the BG. If non-zero, the BG has priority over the Sprite. * If CGX, CGY are non-zero, please be careful of the following: The Sprite Data Number can only be an even number. Also, Sprite Characters are arranged differently depending on the CGX, CGY values. See the following figures for clarification. ####################### PAGE 42 ############################# Fig. 1 00 0 1 2 3 4 5 6 7 08 8 9 A B C D E F 16 G H I J K L M N 24 O P Q R S T U V 32 W X Y Z Fig. 2 CGX=1 CGX=1 CGX=1 CGX=0 CGX=0 CGY=0 CGY=1 CGY=2 CGY=1 CGY=2 Screen 0 1 0 1 0 1 0 0 Display 8 9 8 9 8 8 G H G O P O (7) SPCLR Clears Sprites set with ANIMSET or SPDSP. SPCLR N1 N1: User Specification Number (0-255) (8) SPMOVE Changes the position of Sprites set with ANIMSET or SPDSP. SPMOVE (X,Y), N1 X: Horizontal Graphic Position (-32767~+32767) Y: Vertical Graphic Position (-32767~+32767) N1: User Specification Number (0-255) (9) CHLOC Sets the position in the Screen Character Map for writing to the BG. This is used before executing the BGPUT or CHPUT statements. CHLOC X,Y X: Horizontal Character Position (0-31) Y: Vertical Character Position (0-28) In Character Mode, each Character is an 8x8-dot area. When CLS 2 is executed, X and Y are reset to 0. ex. 10 CLS 2 20 CHLOC 3,4 30 CELPUT 'A':BGPUT 30 (10) BGPAL The Palette written along with the BGPUT command is chosen here. BGPAL P P: Palette Number (0-15, Default is 0) ####################### PAGE 43 ############################# (11) BGPUT A User-defined (BG) Character is written to the screen. BGPUT X0 [, X1, X2,...] Xn: User Character Number (0-255). Values are separated by a comma (,). (12) CHPAL The Palette written along with the CHPUT command is chosen here. CHPAL P (13) CHPUT A System Character is written to the screen. CHPUT X0 [, X1, X2,...] The System Characters are the following 8x8 Characters: 0 1 2 3 4 5 6 7 8 9 A B C D E F $00 O 1 2 3 4 5 6 7 8 9 " [in Japanese] $10 x / $20 ! " # $ % & ' ( ) * + , - . / $30 0 1 2 3 4 5 6 7 8 9 : ; < = > ? $40 @ A B C D E F G H I J K L M N O $50 P Q R S T U V W X Y Z [ \ ] ^ _ $60 \ a b c d e f g h i j k l m n o $70 p q r s t u v w x y z { } ~ $80 [Hiragana:] woa i u e o yayuyotu $90 A I U E O KaKiKuKeKoSaSiSuSeSo $A0 * . [ ] , . Woa i u e o yayuyotu [<-Katakana->] $B0 - A I U E O KaKiKuKeKoSaSiSuSeSo $C0 TaTiTuTeToNaNiNuNeNoHaHiFuHeHoMa $D0 MiMuMeMoYaYuYoRaRiRuReRoWaN " . $E0 TaTiTuTeToNaNiNuNeNoHaHiFuHeHoMa [<-Hiragana->] $F0 MiMuMeMoYaYuYoRaRiRuReRoWaN (14) MAPLOC Sets the position in the Screen CELL Map for writing by the MAPPUT command. MAPLOC X,Y,P X: Horizontal CELL Position (0-15) Y: Vertical CELL Position (0-15) P: Page Number (0-3) In the MAP Screen, a CELL is a 16x16-dot area. When CLS 2 is executed, X and Y are reset to 0. ####################### PAGE 44 ############################# ex. 10 CLS 2 20 MAPLOC 3,4 30 MAPPUT 20 (15) CELPAL The Palette written along with the CELPUT [sic - confused with MAPPUT?] command is chosen here. MAPDSP needs to be executed after this (???) in order for changes to be seen. CELPAL [CN, P, CN, P,...] CN: CELL Number P: Palette Number (0-15, Default is 0) If no parameters are supplied, all CELLs will have their Palettes re-initialized. (16) CELATR The CELL Attribute can be changed. MAPDSP needs to be executed after this (???) in order for changes to be seen. CELATR [CN, A, CN, A,...] CN: CELL Number A: Attribute Number (0-255, Default is 0) If no parameters are supplied, all CELLs will have their Attributes re-initialized. (17) MAPPUT The CELL Number can be changed. MAPDSP needs to be executed after this (???) in order for changes to be seen. MAPPUT [X0, X1, X2,...] Xn: The User CELL Number (0-255) Values are separated by a comma (,). If no parameters are supplied, all CELLs will have their Numbers re-initialized. ####################### PAGE 45 ############################# 5.8 Communications-only Statements (1) TEL Dials a phone number. TEL X, Phone Number X: Status (returned variable) 0 Failure 1 Connect ex. INPUT *S TEL X, *S (2) INCOME Receives a phone call. INCOME X X: Status (returned) 0 Failure 1 Connect (3) COMOUT Sends Data (1 Byte). COMOUT X X: Data to send. Bytes, Words, Strings are all accepted. (?) ex. COMOUT 'D' Byte Data COMOUT X Byte Data if X is $FF or less COMOUT "ABCD" String COMOUT *X String terminated with 0 (4) COMIN Receives Data (1 Byte). COMIN X X(LOW): Data (returned) X(HIGH):Status (returned) 0 Normal. Data Received in low byte. 1 Normal. No Data Received. $FF No Carrier. If No Carrier, the system will redial automatically. (?) (5) TELOFF Disconnects Communications. TELOFF ####################### PAGE 46 ############################# 5.9 Numerical Functions (1) CHR$ ( ) Converts to ASCII. Used with PRINT to display the ASCII text of a variable. CHR$ (X) ex. PRINT CHR$($41) A is printed. (2) HEX$ ( ) Converts to Base 16. Used with PRINT to display numbers in HEX. HEX$ (X) ex. PRINT HEX$(65) 41 is printed. (3) ABS ( ) Converts a number to its Absolute Value. ABS (X) ex. 10 X= -1 20 Y=ABS(X) 30 PRINT X;Y -1 1 is printed. (4) RND ( ) Generates a random number. RND (X) What is returned is a number between 0 and (X-1). (5) SGN ( ) Returns the sign of a number. SGN (X) What is returned: 0 if X is 0. 1 if X is positive. -1 if X is negative. (6) POINT ( ) Returns the Colour Code of a point on-screen. POINT (X,Y) X: Horizontal graphic position (0-239) Y: Vertical graphic position (0-203) What is returned: The Colour Code of the selected position. (7) VGET ( ) Returns the data at a selected VRAM Address. VGET (X) X: VRAM Address (0 - $7FFF) What is returned: The WORD at the selected address (because VRAM data is 16-bit.) (8) INKEY ( ) Inputs an ASCII Code from the user. INKEY (N) N: 0 Returns the code even if no buttons are pressed. Non-0 Waits for a button press and then returns the code. What is returned: Key Code ####################### PAGE 47 ############################# (9) PAD ( ) Inputs Joypad data. PAD (N) N: 0 Returns the code even if no buttons are pressed. 1 Waits for a button press and then returns the code. 2 Returns the realtime state of the PAD. What is returned: Bit 7 Left Bit 6 Down Bit 5 Right Bit 4 Up Bit 3 RUN Bit 2 SELECT Bit 1 II Bit 0 I If any bit is 1, the corresponding button on the PAD has been pressed. (10) FRE () Returns the number of free bytes in memory. As with HEX$ (), used only with a PRINT statement. PRINT FRE (X) X: 0 Free bytes in SRAM. 1 Free bytes in Main RAM's Pointer Area. (11) SPTOUCH () Detects collisions between Sprites/Animations. SPTOUCH (N) N: User Specification Number What is returned: 0 if no collisions. Otherwise, the User Number of the sprite with which the selected sprite has collided. The User Specification Number can even be set to 0 to make game programming more useful. If you set your game's character's User Number as 0, then when checking your character's own bullets colliding with enemies, collisions between your bullets and your character are registered as 0 -- no hits. (12) SPNCHK () Checks if a Sprite has been defined for the specified User Number. SPNCHK (N) N: User Specification Number What is returned: 0 if the sprite is not defined. 1 if the sprite has been defined. ####################### PAGE 48 ############################# (13) SPLCX () Returns the Sprite or Animation's horizontal position. SPLCX (N) N: User Specification Number What is returned: Horizontal Graphic Position (0-272) (14) SPLCY () Returns the Sprite or Animation's vertical position. SPLCY (N) N: User Specification Number What is returned: Vertical Graphic Position (0-256) (15) SPMCHK () Checks (and possibly changes) the CELL Attribute on the MAP where the specified sprite is located. SPMCHK (X,Y), N [, A] X: Horizontal Graphic Position (-32767~+32767) Y: Vertical Graphic Position (-32767~+32767) N: User Specification Number (0-255) A: Attribute (0-255, Default is $FF) What is returned: 0 If the MAP Attribute ANDed with the specified Attribute is 0, the specified Attribute is saved to the MAP Attribute. (??) 1 If the MAP Attribute ANDed with the specified Attribute is non-zero, the specified Attribute is not saved. (16) ATRGET () Reads the CELL Attribute on the MAP. ATRGET (X, Y, P) X: Horizontal Graphic Position (0-15) Y: Vertical Graphic Position (0-15) P: Page Number (0-3) What is returned: Attribute (0-255) ####################### PAGE 49 ############################# 5.10 Music Macro Language (MML) (1) Tempo The higher the parameter, the faster the tempo. Tn n: 0-6 (Default is 3) Tempo (in BPM?) 0 56 1 75 2 90 3 113 4 150 5 225 6 450 (2) Length Note (or Rest) data is assigned the specified length. Ln n: 1,2,4,8,16, or 32 (Default is 4) The higher the parameter, the shorter the note. (1=Full Note, 2=1/2 Note, 4=1/4 Note...) (3) Quantize A note is cut off early (specified by its parameter). Qn n: 0-8 (Default is 8) The parameter allows n/8 of the note to play before the note is cut off. (4) Volume Vn n: 0-31 (Default is 31) ####################### PAGE 50 ############################# (5) Octave Sets the note's octave. On n: 1-7 (Default is 4) (6) Octave Up Increases the note's current octave. > ex. C>C The second C ("do") note is one octave higher than the first note. (7) Octave Down Decreases the note's current octave. < ex. C