SmileBASIC

Instruction List

This is a simple reference listing BASIC instructions only.

PDF File

InstructionList.pdf

Instructions available only in DIRECT mode

Instructions that can be used only if DIRECT mode has been turned on by pressing the DIRECT button
These instructions cannot be included in programs in EDIT mode.

CLEARInitializes the BASIC internal memory
DIRECT mode only
FormatCLEAR
ExamplesCLEAR
NEWErases programs
DIRECT mode only
FormatNEW [Program SLOT]
ArgumentsProgram SLOT 0-3: Erases the specified SLOT only
If unspecified, all SLOTs are erased
ExamplesNEW
NEW 3
LISTSwitches to EDIT mode and starts editing
- DIRECT mode only
- Using LIST with no argument is equal to pressing the EDIT button
FormatLIST [ Line number/ERR ]
ArgumentsLine number- If unspecified, the displayed list will start with the default line
- A program SLOT can be specified, e.g., by entering 2:120
ERRSpecifies the line where the last error occurred
ExamplesLIST ERR
LIST 1:
RUNProgram execution
DIRECT mode only
FormatRUN [Program SLOT]
ArgumentsProgram SLOTSpecified program SLOT to be executed (0 to 3. If omitted, 0)
ExamplesRUN
RUN 1
CONTResumes a suspended program
- DIRECT mode only
- Execution is resumed from the location it was suspended at using the START button, the STOP instruction, or due to an error
- If the program has been stopped and then edited, it cannot be resumed
- If the program was suspended while waiting for user input, it cannot be resumed
- The program may not be able to be resumed depending on the type of error that occurred
FormatCONT
ExamplesCONT
PROJECT (1)Switches the default project
DIRECT mode only
FormatPROJECT "Project name"
ArgumentsProject nameName string of project to change
- New projects can be created from the TOP MENU
- Project name "" specifies the default project
SupplementThree conditions for the current project1) Current project at start-up time (specified using Change Active Project option under the Manage Projects/Files menu)
2) Current project at non-execution time (set with the PROJECT instruction)
3) Current project at execution time (set during execution, e.g., of EXEC)

When the current project is set for 1) - 3), the respective subordinate project settings will also be updated accordingly.
For example, if the current project is changed through the Change Active Project setting, the project at non-execution time and the project at execution time will also be changed.
Furthermore, when execution is started (by using RUN, executing a tool, or executing a program from the file viewer), the current project at non-execution time will be set as the initial value of the current project at execution time.
ExamplesPROJECT ""
PROJECT (2)Obtains the default project
Can be also used from within programs
FormatPROJECT OUT PJ$
ArgumentsNone
Return ValuesPJ$Current project name
ExamplesPROJECT OUT PJ$
BACKTRACEDisplays the history of previous callers
- DIRECT mode only
- When execution has been stopped, for example with the STOP instruction, the caller history up to the point just before it was stopped will be displayed
- A list of slot numbers and line numbers will be displayed
FormatBACKTRACE
ExamplesBACKTRACE

Basic instructions (variables and arrays)

Instructions for handling definitions of variables or arrays, array operations, etc.

=Assigns a value or expression to a variable
- A simplified notation of the LET instruction used in conventional BASIC
- In this software, the LET instruction itself is omitted; only '=' should be used for assignment
Format=
ExamplesA=10
A$="HELLO"
DIM (1)Declares arrays to use
- In this product, arrays must always be declared
- The subscript should begin with 0
- The number of elements must be enclosed in []. () is not allowed
- Either DIM or VAR can be used
FormatDIM Array variable name[ Number of elements ] ,…
ArgumentsArray variable name[ Number of elements ]- Alphanumeric characters and underscores (_) are allowed
- Leading numerals are not allowed
- String variables are also allowed for the array variable
Number of elements- Specify the number of array elements to provide, enclosed in []
- Up to four dimensions can be specified, with commas (,) to separate them
ExamplesDIM ATR[4]
DIM DX[5], DY[5], DZ[5]
DIM POS[10,5]
DIM (2)Declares variables to use
- When OPTION STRICT is specified, each variable that will be used must be declared
- Usage where DIM is used for variable definition
FormatDIM Variable name ,…
ArgumentsVariable name- Alphanumeric characters and underscores (_) are allowed
- Leading numerals are not allowed
- String variables can also be declared
ExamplesDIM A, ATRB, B$
VAR (1)Declares variables to use
When OPTION STRICT is specified, each variable that will be used must be declared
FormatVAR Variable name ,…
ArgumentsVariable name- Alphanumeric characters and underscores (_) are allowed
- Leading numerals are not allowed
- String variables can also be declared
ExamplesVAR A, ATRB, B$
VAR (2)Declares arrays to use
- In this product, arrays must always be declared
- The subscript should begin with 0
- The number of elements must be enclosed in []. () is not allowed
- Either DIM or VAR can be used
FormatVAR Array variable name[ Number of elements ] ,…
ArgumentsArray variable name[ Number of elements ]- Alphanumeric characters and underscores (_) are allowed
- Leading numerals are not allowed
- String variables are also allowed for the array variable
Number of elements- Specify the number of array elements to provide, enclosed in []
- Up to four dimensions can be specified, with commas (,) to separate them
ExamplesVAR ATR[4]
VAR DX[5], DY[5], DZ[5]
VAR POS[10, 5]
SWAPSwaps the values of two variables
Replacing a character string with a numerical value, or vice versa, is not allowed
FormatSWAP Variable 1, Variable 2
ArgumentsVariable 1Variable to be replaced
Variable 2Variable to be replaced with
ExamplesSWAP A,B
INCIncrements the value of a variable by +1
If the Expression argument is specified, the value of the expression will be added
FormatINC Variable [, Expression ]
ArgumentsVariableName of variable to increment value of
ExpressionValue to add (If omitted, 1)
ExamplesINC X
INC X,3
DECDecrements the value of a variable by -1
If the Expression argument is specified, the value of the expression will be subtracted
FormatDEC Variable [, Expression ]
ArgumentsVariableName of variable to decrement value of
ExpressionValue to subtract (If omitted, 1)
ExamplesDEC X
DEC X,3
COPY (1)Copies one array to another array
- For one-dimensional arrays only, if the number of elements in the copy destination is insufficient, the required element(s) will be added automatically
- Both the copy source and destination ignore dimensions
FormatCOPY Copy destination array [,Copy destination offset],Copy source array [[,Copy source offset] , Number of copy elements]
ArgumentsCopy destination arrayCopy destination array (to be overwritten with the content of the copy source array)
Copy destination offsetFirst element to be overwritten (If this is omitted, overwriting will start with the beginning of the copy destination)
Copy source arrayCopy source array
Copy source offsetFirst element to be overwritten (If this is omitted, copying will start with the beginning of the copy source)
Number of copy elementsNumber of elements to be overwritten (If this is omitted, up to the end of the copy source will be copied)
ExamplesDIM SRC[10],DST[10]
COPY DST,SRC
COPY (2)Reads a DATA sequence into an array
- The data elements enumerated in the DATA instruction will be read into the array
- For one-dimensional arrays only, if the number of elements in the copy destination is insufficient, the required element(s) will be added automatically
FormatCOPY Copy destination array [,Copy destination offset], "@Label string" [,Number of copy data items]
ArgumentsCopy destination arrayCopy destination array (to be overwritten with the content of the DATA sequence)
Copy destination offsetFirst element to be overwritten (If this is omitted, overwriting will start with the beginning of the array)
"@Label string"Specify the @Label name string set to the DATA instruction to be read
Number of copy data items- Number of data items to be read (If this is omitted, data items will be read according to the number of elements in the copy destination array)
- If the number of data items is smaller than the number of arrays in the copy destination, an error will occur.
ExamplesDIM DST[5]
COPY DST,"@SRC"
@SRC
DATA 5,1,1,2,4
SORTSorts arrays in ascending order
FormatSORT [Start position, Number of elements,] Array 1 [,Array 2 ,…]
ArgumentsStart positionPosition in Array 1 (0-) from which to start sorting
Number of elementsNumber of elements in Array 1 (1-) to sort
Array 1Array with numerical values to sort
Array 2- Array to sort according to the result of sorting of Array 1
- Array 1 to Array 8 can be enumerated
ExamplesDIM WORK[10]
SORT 0, 10, WORK
RSORTSorts arrays in descending order
FormatRSORT [Start position, Number of elements,] Array 1 [,Array 2 ,…]
ArgumentsStart positionPosition in Array 1 (0-) from which to start sorting
Number of elementsNumber of elements in Array 1 (1-) to sort
Array 1Array with numerical values to sort
Array 2- Array to sort according to the result of sorting of Array 1
- Array 1 to Array 8 can be enumerated
ExamplesDIM WORK[10]
RSORT 0, 10, WORK
PUSHAdds an element to the end of an array (The number of elements will increase by 1)
FormatPUSH Array, Expression
ArgumentsArrayArray to which the element will be added
ExpressionValue of the element to add
ExamplesDIM WORK[10]
PUSH WORK, 123
POPRemoves an element from the end of an array (The number of elements will decrease by 1)
FormatVariable=POP( Array )
ArgumentsArrayArray from which the element will be removed
Return ValuesValue of the element that was removed
ExamplesDIM WORK[10]
PUSH WORK, 123
A=POP(WORK)
UNSHIFTAdds an element to the start of an array (The number of elements will increase by 1)
FormatUNSHIFT Array, Expression
ArgumentsArrayArray to which the element will be added
ExpressionValue of the element to add
ExamplesDIM WORK[10]
UNSHIFT WORK, 123
SHIFTRemoves an element from the start of an array (The number of elements will decrease by 1)
FormatVariable=SHIFT( Array )
ArgumentsArrayArray from which the element will be removed
ExamplesDIM WORK[10]
UNSHIFT WORK, 123
A=SHIFT(WORK)
FILLSets all the elements in an array to the specified value
- Partial changes can also be made by specifying an offset and number of elements
- You can specify any type of array, including integer, real number, or string
FormatFILL Array, Value [,Offset [,Number of elements]]
ArgumentsArrayThe array that you want to overwrite with a value
ValueThe desired number or string
OffsetThe position to begin writing the value from
Number of elementsThe number of elements to write the value into
ExamplesDIM WORK[10]
FILL WORK,0

Basic instructions (control and branching)

Control instructions for comparison, branching, repeats, etc.

@Name to indicate a program or data position
- It is not possible to specify the line number directly with GOTO or other instructions
- Branch destinations and data positions must be all specified using labels
Format@Label name
Arguments@Label nameAlphanumerical or underscore (_) characters, prefixed with @
Examples@MAINLOOP
GOTO (1)Forces branching
FormatGOTO @Label
Arguments@Label- Jump target @Label name
- Label string, which is the Label name enclosed in "" (String variables are also allowed)
- A program SLOT can be specified in the following format: "1:@Label name"
- The target SLOT should be enabled beforehand with the USE instruction
ExamplesGOTO @MAIN
JP$="@MAIN":GOTO JP$
GOSUB (1)Calls a sub-routine
FormatGOSUB @Label
Arguments@Label- @Label name of the sub-routine to call
- Label string, which is the Label name enclosed in "" (String variables are also allowed)
- A program SLOT can be specified in the following format: "1:@Label name"
- The target SLOT should be enabled beforehand with the USE instruction
ExamplesGOSUB @SUB
RETURN (1)Returns from a sub-routine to the caller
FormatRETURN
ExamplesRETURN
RETURN (2)Returns a value from a sub-routine while returning to the caller
Used to return values in a DEF instruction defined as function type
FormatRETURN
ExamplesDEF CALC(A,B)
 RETURN A*B
END
PRINT CALC(2,3)
OUTInstruction used when multiple outputs are required
- Used to declare a DEF instruction that returns multiple values
- Also used in built-in instructions that return multiple values
FormatOUT
ExamplesDEF SUB A OUT D,M
 D=A DIV 10
 M=A MOD 10
END
SUB 34 OUT DV,ML
PRINT DV,ML
ON (1)Branches to a label line according to the control variable value
- The branch number begins with 0, unlike in conventional BASIC
FormatON Control variable GOTO @Label 0, @Label 1…
Arguments@Label 0Jump target to use when the control variable is 0
@Label 1Jump target to use when the control variable is 1
  :
- Prepare the necessary number of branch destinations
- Label strings cannot be used in the ON to GOTO labels
ExamplesON IDX GOTO @JMP_A,@JMP_B
PRINT "OVER":END
@JMP_A
PRINT "IDX=0":END
@JMP_B
PRINT "IDX=1":END
GOTO (2)Branches to a label line according to the control variable value
- The branch number begins with 0, unlike in conventional BASIC
FormatON Control variable GOTO @Label 0, @Label 1…
Arguments@Label 0Jump target to use when the control variable is 0
@Label 1Jump target to use when the control variable is 1
  :
- Prepare the necessary number of branch destinations
- Label strings cannot be used in the ON to GOTO labels
ExamplesON IDX GOTO @JMP_A,@JMP_B
PRINT "OVER":END
@JMP_A
PRINT "IDX=0":END
@JMP_B
PRINT "IDX=1":END
ON (2)Calls a sub-routine according to a control variable value
- The branch number begins with 0, unlike in conventional BASIC
FormatON Control variable GOSUB @Label 0, @Label 1…
Arguments@Label 0Sub-routine when the control variable is 0
@Label 1Sub-routine when the control variable is 1
  :
- Prepare the necessary number of branch destinations
- Label strings cannot be used in the ON to GOSUB labels
ExamplesON IDX GOSUB @SUB_A,@SUB_B
PRINT "EXIT":END
@SUB_A
PRINT "IDX=0":RETURN
@SUB_B
PRINT "IDX=1":RETURN
GOSUB (2)Calls a sub-routine according to the control variable value
- The branch number begins with 0, unlike in conventional BASIC
FormatON Control variable GOSUB @Label 0, @Label 1…
Arguments@Label 0Sub-routine when the control variable is 0
@Label 1Sub-routine when the control variable is 1
  :
- Prepare the necessary number of branch destinations
- Label strings cannot be used in the ON to GOSUB labels
ExamplesON IDX GOSUB @SUB_A,@SUB_B
PRINT "EXIT":END
@SUB_A
PRINT "IDX=0":RETURN
@SUB_B
PRINT "IDX=1":RETURN
IF (1)Executes Process 1 if the condition is satisfied, or Process 2 if the condition is not satisfied
- GOTO can be omitted immediately after THEN or ELSE
- ENDIF should be used when the process spans multiple lines
FormatIF Conditional expression THEN Process to execute when the condition is satisfied [ELSE Process to execute when the condition is not satisfied] [ENDIF]
Conditional Expressions Comparison Operators == Equal to
!= Not equal to
> Greater than
< Smaller than
>= Equal to or greater than
<= Equal to or smaller than
Logical Operators (for comparing multiple conditions) (Condition 1 AND Condition 2) Both of the conditions should be satisfied
(Condition 1 && Condition 2) Both of the conditions should be satisfied
(Condition 1 OR Condition 2) Either one of the conditions should be satisfied
(Condition 1 || Condition 2) Either one of the conditions should be satisfied
* The key for the "||" characters is located to the upper left of the "?" key on the keyboard.
ExamplesIF A==1 THEN PRINT "OK"
IF A>1 THEN @JMP1 ELSE PRINT DATE$
IF A==1 THEN
 PRINT "Congratulations":BEEP 72
ELSE
 PRINT "Bad luck"
ENDIF
@JMP1
END
THENControl destination if the IF condition is satisfied
See Comment for IF for details regarding conditional evaluation
FormatIF Conditional expression THEN Process to execute when the condition is satisfied [ELSE Process to execute when the condition is not satisfied] [ENDIF]
ExamplesIF A==1 THEN PRINT "OK"
IF A<1 THEN @JMP1 'GOTO omitted
IF A==1 THEN
 PRINT "Congratulations":BEEP 72
ELSE
 PRINT "Bad luck"
ENDIF
@JMP1
END
ELSEControl destination if the IF condition is not satisfied
See Comment for IF for details regarding conditional evaluation
FormatIF Conditional expression THEN Process to execute when the condition is satisfied ELSE Process to execute when the condition is not satisfied [ENDIF]
ExamplesIF A==1 THEN PRINT "OK"
IF A<1 THEN @JMP1 ELSE PRINT DATE$
IF A==1 THEN
 PRINT "Congratulations":BEEP 72
ELSE
 PRINT "Bad luck"
ENDIF
@JMP1
END
ELSEIFAdditional conditional evaluation if the IF condition is not satisfied
- Used to evaluate another condition if the IF condition is not satisfied
- See Comment for IF for details regarding conditional evaluation
FormatIF Conditional expression THEN Process to execute when the condition is satisfied ELSEIF Conditional expression THEN Process to execute when the condition is satisfied ENDIF
ExamplesIF A==1 THEN
 PRINT "Congratulations":BEEP 0
ELSEIF A==2 THEN
 PRINT "Bad luck"
ELSE IF A==3 THEN
 PRINT "So-so"
ENDIF '--- Required when using ELSE IF
ENDIF
ENDIFEnds if processing spans multiple lines after control switching with IF
See Comment for IF for details regarding conditional evaluation
FormatIF Conditional expression THEN Process to execute when the condition is satisfied ELSE Process to execute when the condition is not satisfied [ENDIF]
ExamplesIF A==0 THEN
 PRINT "A=0"
ENDIF
IF (2)Branches to @Label if the condition is satisfied
See Comment for IF for details regarding conditional evaluation
FormatIF Conditional expression GOTO @Label [ELSE Process to execute when the condition is not satisfied]
Notes when using a string for the label- Label strings can also be used for the label
- Label strings are not allowed if GOTO immediately after ELSE is omitted
× IF A==0 GOTO "@LABEL1" ELSE "@LABEL2"
○ IF A==0 GOTO "@LABEL1" ELSE @LABEL2
○ IF A==0 GOTO "@LABEL1" ELSE GOTO "@LABEL2"
ExamplesIF A==1 GOTO @MAIN
IF X>0 GOTO @JMP1 ELSE PRINT A$
IF Y==5 GOTO @JMP1 ELSE @JMP2
@JMP1
PRINT "@JMP1"
@JMP2
PRINT "@JMP2"
END
GOTO (3)Branches to @Label if the condition is satisfied
- See Comment for IF for details regarding conditional evaluation
FormatIF Conditional expression GOTO @Label [ELSE Process to execute when the condition is not satisfied]
Notes when using a string for the label- Label strings can also be used for the label
- Label strings are not allowed if GOTO immediately after ELSE is omitted
× IF A==0 GOTO "@LABEL1" ELSE "@LABEL2"
○ IF A==0 GOTO "@LABEL1" ELSE @LABEL2
○ IF A==0 GOTO "@LABEL1" ELSE GOTO "@LABEL2"
ExamplesIF A==1 GOTO @MAIN
IF X>0 GOTO @JMP1 ELSE PRINT A$
IF Y==5 GOTO @JMP1 ELSE @JMP2
@JMP1
PRINT "@JMP1"
@JMP2
PRINT "@JMP2"
END
FORRepeats the process for the specified number of times
- The NEXT instruction should be placed at the end of the process
- If the condition is not satisfied, the process may not be executed at all
FormatFOR Loop variable=Initial value TO End value [STEP Increment]
ArgumentsLoop variableVariable for loop count (On each iteration of the loop, the increment is added to the count)
Initial valueValue or expression for the loop variable at the start of the loop
TO End valueValue or expression for the loop variable at the end of the loop
STEP Increment- Increment added to the loop variable at the end of the loop (If omitted, 1)
- If the increment is specified as a fractional value, the intended loop count may not be achieved due to operational errors.
ExamplesFOR I=0 TO 9 STEP 2
 PRINT I;",";
NEXT
TOSpecifies the loop count end value
- See Comment for the FOR instruction for details regarding FOR to NEXT
FormatTO End value
ExamplesFOR I=0 TO 9 STEP 2
 PRINT I;",";
NEXT
STEPSpecifies the increment value for a FOR loop count
- See Comment for the FOR instruction for details regarding FOR to NEXT
FormatSTEP Increment
ExamplesFOR I=0 TO 9 STEP 2
 PRINT I;",";
NEXT
NEXTInstruction that indicates the end of a FOR loop
- See Comment for the FOR instruction for details regarding FOR to NEXT
- Using NEXT with IF in a FOR loop is not recommended
- Use CONTINUE to exit the loop before the end
FormatNEXT [ Control variable ]
ArgumentsControl variable- Even if a control variable is specified, it will be ignored and the instruction will work in the same way as NEXT on its own
- Specifications such as NEXT J,I are not allowed
ExamplesFOR I=0 TO 9 STEP 2
 PRINT I;",";
NEXT
WHILERepeats the process up to WEND while the condition is satisfied
- Exits the loop if the condition is not satisfied or when the BREAK instruction is executed
FormatWHILE Conditional expression
Conditional ExpressionsThe same conditional expressions as in IF statements can be specified
Comparison Operators== Equal to
!= Not equal to
> Greater than
< Smaller than
>= Equal to or greater than
<= Equal to or smaller than
Logical operators (for comparison with multiple conditions)(Condition 1 AND Condition 2) Both of the two conditions must be satisfied
(Condition 1 && Condition 2) Both of the two conditions must be satisfied
(Condition 1 OR Condition 2) Either of the two conditions must be satisfied
(Condition 1 || Condition 2) Either of the two conditions must be satisfied
* The key "||" can be found to the upper left of ? on your keyboard.
ExamplesA=0:B=4
WHILE A<B
 A=A+1
WEND
WENDInstruction that indicates the end of a WHILE loop
FormatWEND
ExamplesA=0:B=4
WHILE A<B
 A=A+1
WEND
REPEATInstruction for starting a REPEAT loop
- The UNTIL instruction and a conditional expression should be placed at the end of the loop
- Unlike the WHILE instruction, this executes the process before determining the condition
- Exits the loop when the condition is satisfied or when the BREAK instruction is executed
FormatREPEAT
ExamplesA=0:B=4
REPEAT
 A=A+1
UNTIL A>B
UNTILRepeats the process from REPEAT until the conditional expression is satisfied
- The REPEAT instruction should be placed at the beginning of the loop
- Unlike the WHILE instruction, this executes the process before determining the condition
- Exits the loop if the condition is satisfied or when the BREAK instruction is executed
FormatUNTIL conditional expression
Conditional ExpressionsThe same conditional expressions as in IF statements can be specified
Comparison Operators== Equal to
!= Not equal to
> Greater than
< Smaller than
>= Equal to or greater than
<= Equal to or smaller than
Logical operators (for comparison with multiple conditions)(Condition 1 AND Condition 2) Both of the two conditions must be satisfied
(Condition 1 && Condition 2) Both of the two conditions must be satisfied
(Condition 1 OR Condition 2) Either of the two conditions must be satisfied
(Condition 1 || Condition 2) Either of the two conditions must be satisfied
* The key for "||" can be found on the upper left of ? on your keyboard.
ExamplesA=0:B=4
REPEAT
 A=A+1
UNTIL A<B
CONTINUEForces a loop to proceed
- Used in FOR ... NEXT, WHILE ... WEND, REPEAT ... UNTIL
FormatCONTINUE
ExamplesFOR I=0 TO 9
 IF I==1 THEN CONTINUE
 IF I==7 THEN BREAK
 PRINT I;",";
NEXT
BREAKForces a loop to end
- Used in FOR ... NEXT, WHILE ... WEND, REPEAT ... UNTIL
FormatBREAK
ExamplesFOR I=0 TO 9
 IF I==1 THEN CONTINUE
 IF I==7 THEN BREAK
 PRINT I;",";
NEXT
END (1)Exits the program
FormatEND
ExamplesEND
END (2)Exits a DEF definition for a user function or user instruction.
FormatEND
ExamplesDEF FUNC
 PRINT "FUNC"
END
STOPSuspends a running program
- The program SLOT:line number of the suspended program will be displayed
- The program can be resumed with the CONT instruction (However, resuming is not available in certain situations)
FormatSTOP
ExamplesSTOP

Basic instructions (advanced control)

Instructions for user-defined functions, control of add-ons, etc.

DEF (1)About DEF user-defined instructions
1) USER (No arguments; no return values)
2) A=USER(X) (With argument; single return value)
3) USER(X) OUT A,B (With argument; multiple return values)

Using DEF allows you to define unique instructions as shown above
DEFCommon Supplement for DEF- The definition range should be from DEF to END
- Variables and labels defined in the DEF to END range are handled as local
- GOTO outside the DEF to END range is impossible
- GOSUB or ON GOSUB in the DEF to END range cannot be used
They can be used if a SLOT is specified, as in GOSUB "0:@SUB"
- They can be used from a different SLOT by adding the COMMON instruction
Specifications for DEF arguments- For arguments received with DEF, types will not be checked strictly
- Variable names to be received can be specified as necessary by separating them with commas (,)
- For string variables, it is also possible to attach $ to the end of a variable name
Specifications for DEF return values- For DEF return values, types will not be checked strictly
- The type will be determined according to the value written at the beginning of the output variables
- When an integer is assigned to a numerical variable, it is handled as integer type
- To handle a value as real type, it should be written as in A=100.0
- If the type of a return value from DEF is different from the type expected by the recipient, an error will occur
DEF (2)Defines a user instruction with no return values and no arguments
FormatDEF definition name
ArgumentsNone
Return ValuesNone
Examples'--- Text display
DEF FUNC
PRINT "SAMPLE"
END
'--- Call
FUNC
DEF (3)Defines a user function with a single return value
FormatDEF Function name([Argument [,Argument…])
ArgumentsSpecify variable names as necessary if there is an argument or arguments to be passed to the function
Return ValuesValue to return as a result should be specified after the RETURN instruction
* Notation such as RETURN ANS
Examples'---Addition
DEF ADD(X,Y)
RETURN X+Y
END
'--- Factorial calculation using recursion
DEF FACTORIAL(N)
IF N==1 THEN RETURN N
RETURN N*FACTORIAL(N-1)
END
'--- Character string inversion
DEF REVERSE$(T$)
VAR A$="" 'Local character string
VAR L=LEN(T$) 'Local
WHILE L>0
 A$=A$+MID$(T$,L-1,1)
 DEC L
WEND
RETURN A$
END
'--- Call
PRINT ADD(10,5)
PRINT FACTORIAL(4)
PRINT REVERSE$("BASIC")
DEF (4)Defines a user instruction with multiple return values
FormatDEF Instruction name [Argument [,Argument…]] [OUT V1 [,V2…]]
Arguments Specify variable names as necessary if there is an argument or arguments to be passed to the function
Return ValuesVariable names to be returned as a result should be specified as necessary after OUT
Examples'--- Addition and multiplication
DEF CALCPM A,B OUT OP,OM
OP=A+B
OM=A*B
END
'--- Call
CALCPM 5,10 OUT P,M
PRINT P,M
COMMON1) COMMON DEF USER
2) COMMON DEF USER(X)
3) COMMON DEF USER(X) OUT A,B

COMMON can be used when a unique instruction is used from a different SLOT
USE is required if a program is used between different SLOTs
ExamplesCOMMON DEF FOO(X, Y, Z)
CALL (1)Calls the user-defined instruction with the specified name
FormatCALL "Instruction name" [,Argument…] [OUT Variable 1 [,Variable 2…]]
ArgumentsInstruction name- User-defined instruction name string to call
- Being a string, it should either be enclosed in "" or specified using a string variable.
Arguments-Any arguments required for the specified instruction
Return ValuesVariable names to return as a result should be specified as necessary after OUT
ExamplesCALL "USERCD",X,Y OUT A,B
'
DEF USERCD X,Y OUT A,B
A=X+Y:B=X*Y
END
CALL (2)Calls the user-defined function with the specified name
FormatVariable=CALL("Function name" [,Argument…])
ArgumentsFunction name- User-defined function name string to call
- Being a string, it should either be enclosed in "" or specified using a string variable.
ArgumentsAny arguments required for the specified function should be enumerated
ExamplesA=CALL("USERFC",X,Y)
'
DEF USERFC(X,Y)
RETURN X*Y
END
CALL (3)Calls a sprite callback
Processes which have been specified for each sprite using SPFUNC are called together
FormatCALL SPRITE
ExamplesCALL SPRITE
CALL (4)Calls a BG callback
Processes which have been specified for each sprite using SPFUNC are called together
FormatCALL BG
ExamplesCALL BG
XONDeclares the use of a special feature
- These features are not available unless their use is declared beforehand
- When XON EXPAD is successful, RESULT will be returned as TRUE.
- If the system is already in the XON state, this command will not display a dialog
FormatXON Name of feature to use
ArgumentsName of feature to useMOTION: Motion sensor, gyro sensor
EXPAD: Circle Pad Pro
MIC: Microphone
ExamplesXON MOTION
XOFFStops using a special feature declared with XON
FormatXOFF Name of the feature to stop
ArgumentsName of feature to stopMOTION: Motion sensor, gyro sensor
EXPAD: Circle Pad Pro
MIC: Microphone
ExamplesXOFF MOTION

Basic instructions (data operations and others)

Instructions for reading data, vertical synchronization, comments, etc.

READReads the information enumerated with the DATA instruction into the variables
Information should be read in the same type as that enumerated with the DATA instruction
FormatREAD Acquisition variable 1 [, Acquisition variable 2…]
ArgumentsAcquisition variables- Variables to store read information (Multiple variables can be specified)
- DATA in and after the line specified with the RESTORE instruction will be acquired
- If RESTORE is omitted, acquisition will begin with the first occurrence of DATA
ExamplesREAD X,Y,Z,G$
DATA 200,120,0,"JAN"
DATA 210,120,0,"FEB"
DATADefines data to read with READ
- Numerical values and character strings can be mixed
- Expressions containing only numerical constants are handled as constants, and so can be written in DATA statements
- Constants starting with # are also allowed
- Expressions where &&, ||, variables, and functions are mixed are not allowed
- Character string expressions are not allowed
FormatDATA Data [, Data…]
Notation of Data- List numerical values and character strings, separating each one with ','
- Character strings must be enclosed in double quotations ("") ("" cannot be omitted)
ExamplesREAD X,Y,Z,ST$ 'Comments can be written
DATA 123,345,56,"SAMPLE"
RESTORESpecifies the first DATA to read with the READ instruction
FormatRESTORE @Label
Arguments@Label- @Label name given to the beginning of the DATA instruction to be read
- A string variable to which a @Label name is assigned can also be specified
- It is also possible to reference a label from a different SLOT by using the format RESTORE "1:@Label name"
- The target SLOT should be enabled beforehand with USE, e.g., USE 1
ExamplesRESTORE @DATATOP
@DATATOP
DATA 123,345,56,"SAMPLE"
OPTIONSets the operating mode of the program
FormatOPTION Feature name
ArgumentsFeature nameSTRICT: Variable declaration is required (A reference without declaration will give an error)
DEFINT: Causes the default variable type to be Integer
ExamplesOPTION STRICT
WAITStops the program until the specified number of vertically synchronized frames has been reached
FormatWAIT [Number of frames]
ArgumentsNumber of framesSpecify the number of frames to wait, starting from the present point (0: Ignore; if omitted, 1 is assumed)
ExamplesWAIT 60
VSYNCStops the program until the specified number of vertically synchronized frames has been reached
Unlike WAIT, the VSYNC count starts from the last VSYNC
FormatVSYNC [Number of frames]
ArgumentsNumber of framesSpecify the number of frames to wait, starting from the last VSYNC (0: Ignore; if omitted, 1 is assumed)
ExamplesVSYNC 1
'Symbols for writing comments
- Comments do not affect program execution
Format' [String]
Examples' ---MAIN ROUTINE---
REMInstructions for writing comments
- Comments do not affect program execution
FormatREM [Character string]
ExamplesREM ---MAIN ROUTINE---
KEYAssigns an arbitrary character string to a function key
FormatKEY Number,"Character string"
ArgumentsNumberNumber of the function key (1-5)
Character string- Character string to assign
- If the whole string cannot be displayed, '…' will be displayed at the end
ExamplesKEY 1,"CLS"+CHR$(13)
TMREADConverts a time string to numerical values
FormatTMREAD ["Time string"] OUT H,M,S
ArgumentsTime stringTime string in "HH:MM:SS" format (if omitted, the current time)
Return ValuesVariables to store numerical valuesH: Variable to receive the hours (0-23)
M: Variable to receive the minutes
S: Variable to receive the seconds
ExamplesTMREAD "12:59:31" OUT H,M,S
DTREADConverts a date string to numerical values
FormatDTREAD ["Date string"] OUT Y,M,D [,W]
ArgumentsDate stringDate string in "YYYY/MM/DD" format (if omitted, the current date and time)
Return ValuesVariables to store numerical valuesY: Variable to receive the year
M: Variable to receive the month
D: Variable to receive the day
W: Variable to receive the day of the week (numerical value: 0 for Sunday)
ExamplesDTREAD "2014/10/12" OUT Y,M,D
CHKLABELChecks if there is a label that can be referenced with the specified string
FormatVariable = CHKLABEL("@Label string"[,Flag])
Arguments@Label string- It is also possible to check a different SLOT by using CHKLABEL "1:@Label name"
- The target SLOT should be enabled beforehand with USE, e.g., USE 1
Flag0= Searches only within DEF (if omitted, 0)
1= If not found within DEF, searches for global labels
Return ValuesFALSE= Does not exist, TRUE= Exists
ExamplesA=CHKLABEL("@MAIN")
CHKCALLChecks if there is an instruction or function that can be referenced with the specified string
FormatVariable = CHKCALL("Character string")
ArgumentsCharacter stringCharacter string of the instruction or function to check
Return ValuesFALSE= Does not exist, TRUE= Exists
ExamplesA=CHKCALL("KEYCHECK")
CHKVARChecks if there is a variable that can be referenced with the specified string
FormatVariable = CHKVAR("Character string")
ArgumentsCharacter stringCharacter string of the variable to check
Return ValuesFALSE= Does not exist, TRUE= Exists
ExamplesA=CHKVAR("COUNTX")
DIALOG (1)Displays a dialog and waits for a button to be pressed
- The result is returned with the system variable RESULT
- RESULT: 1 (Confirmed), -1 (Canceled), 0 (Time out)
FormatDIALOG "Text string"
ArgumentsText stringCharacter string to display in the dialog
Supplement (common for DIALOG instructions)- Dialog are always displayed on the Touch Screen
- The total length of the text string and caption string should be 256 characters or less
- If CHR$(10) or CHR$(13) is included in the text string, a line break will occur at that point
- If a negative value is set for the Timeout period, texts are handled in frame units
ExamplesDIALOG "Good morning!"
DIALOG (2)Displays a dialog and waits for a button to be pressed
FormatDIALOG "Text string",[Selection type],["Caption string"],[Timeout period]
ArgumentsText stringCharacter string to display in the dialog
Selection type0: OK (default)
5: Next
Caption stringCharacter string to display in the caption field at the top of the dialog
Timeout periodNumber of seconds to wait before closing the dialog automatically (If omitted, 0: Not closed)
Supplement (common for DIALOG instructions)- Dialog are always displayed on the Touch Screen
- The total length of the text string and caption string should be 256 characters or less
- If CHR$(10) or CHR$(13) is included in the text string, a line break will occur at that point
- If a negative value is set for the Timeout period, texts are handled in frame units
ExamplesDIALOG "Let's get started",5,"Scenario",-120
DIALOG (3)Displays a dialog and waits for the specified button to be pressed
FormatVariable = DIALOG("Text string",[Selection type],["Caption string"],[Timeout period])
ArgumentsText stringCharacter string to display in the dialog
Selection type0: OK (default)
1: No/Yes
2: Back/Next
3: Cancel/Confirm
4: Cancel/Execute
5: Next
Caption stringCharacter string to display in the caption field at the top of the dialog
Timeout periodNumber of seconds to wait before closing the dialog automatically (If omitted, 0: Not closed)
Return Values-1: Negation (Left button)
0: Timeout
1: Affirmation (Right button)
* These values will also remain in the system variable RESULT.
Supplement (common for DIALOG instructions)- Dialog are always displayed on the Touch Screen
- The total length of the text string and caption string should be 256 characters or less
- If CHR$(10) or CHR$(13) is included in the text string, a line break will occur at that point
- If a negative value is set for the Timeout period, texts are handled in frame units
ExamplesR=DIALOG("Would you like to try again?" ,1,"かくにん",0)
DIALOG (4)Displays a dialog and waits for the Touch Screen or a hardware button to be pressed
FormatVariable = DIALOG("Text string",Button type,["Caption string"],[Timeout period])
ArgumentsText stringCharacter string to display in the dialog
Button type|b00| ABXY buttons (1)
|b01| +Control Pad (2)
|b02| L,R buttons (4)
|b03| Touch Screen (8)

- Specify a value for which the logical OR is calculated with the above bit value and the sign is reversed
- ZL and ZR buttons cannot be detected
- -1 causes only ABXY to be specified
- For example, to detect ABXY and +Control Pad, -3 should be specified
Caption stringCharacter string to display in the caption field at the top of the dialog
Timeout periodNumber of seconds to wait before closing the dialog automatically (if omitted, 0: Not closed)
Return Values128: A button pressed
129: B button pressed
130: X button pressed
131: Y button pressed
132: +Control Pad up pressed
133: +Control Pad down pressed
134: +Control Pad left pressed
135: +Control Pad right pressed
136: L button pressed
137: R button pressed
140: Touch Screen pressed
ExamplesR=DIALOG("ABXYLR/+Control Pad/Touch",-15,"Special",0)
DIALOG (5)Displays a dialog used only for inputting file names
FormatString=DIALOG( "Initial string", "Caption string" [,Maximum characters])
ArgumentsInitial stringString that is initially input
Caption stringString to be displayed in the caption field
Maximum charactersUp to 14 characters
Return ValuesThe obtained character string will be returned
* If RESULT=-1, Canceled (the character string is invalid)
Supplement (common for DIALOG instructions) - Dialog are always displayed on the Touch Screen
- The total length of the text string and caption string should be 256 characters or less
- If CHR$(10) or CHR$(13) is included in the text string, a line break will occur at that point
- If a negative value is set for the Timeout period, texts are handled in frame units
ExamplesT$=DIALOG( "NEWNAME0","SAVE", 14 )
DIALOG (6)Displaying special characters in DIALOG
To use special character and symbols, pass the character code in the UTF-16 format to CHR$
* For details on the UTF-16 format, please refer to a technical book or similar resource.
Supplement (common for DIALOG instructions) - Dialog are always displayed on the Touch Screen
- The total length of the text string and caption string should be 256 characters or less
- If CHR$(10) or CHR$(13) is included in the text string, a line break will occur at that point
- If a negative value is set for the Timeout period, texts are handled in frame units
Examples to display Japanese Kanji characters' もういちど?
T$="もう"+CHR$(&H4E00)+CHR$(&H5EA6)+"?"
' かくにん
C$=CHR$(&H78BA)+CHR$(&H8A8D)
R=DIALOG(T$,1,C$,0)

Console input/output

Instructions related to display of characters, input of strings on the screen, etc.

CLSClears the console screen (the screen specified with the DISPLAY instruction)
FormatCLS
ExamplesDISPLAY 0
CLS
COLORSpecifies the display colors for the console screen
Constants for text colors are available (#TBLACK to #TWHITE)
FormatCOLOR Drawing color [,Background color]
ArgumentsDrawing color0: Transparent color
1: Black, #TBLACK
2: Dark red, #TMAROON
3: Red, #TRED
4: Dark green, #TGREEN
5: Green, #TLIME
6: Dark yellow, #TOLIVE
7: Yellow, #TYELLOW
8: Dark blue, #TNAVY
9: Blue, #TBLUE
10: Dark magenta, #TPURPLE
11: Magenta, #TMAGENTA
12: Dark cyan, #TTEAL
13: Cyan, #TCYAN
14: Gray, #TGRAY
15: White, #TWHITE
Background color- Background color number for each character (0-15: See the drawing colors)
- If only the background color needs to be changed, the drawing color can be omitted
ExamplesCOLOR 7,4
COLOR #TWHITE
COLOR ,0
LOCATESpecifies the character display location on the console screen
FormatLOCATE [X-coordinate],[Y-coordinate] [,Z-coordinate]
ArgumentsX-,Y-coordinates- Coordinates of each character (X:0-49,Y:0-29)
- If the X- and Y-coordinates are omitted, the previous coordinates for each will be kept
Z-coordinate- Coordinate in the depth direction (Rear:1024<Screen surface:0<Front:-256)
- If omitted, the previous Z-coordinate will be kept
ExamplesLOCATE 20,15
LOCATE 0,0,-200
PRINTDisplays characters on the console screen
- Omitting expressions causes only a line break to occur
- ? can be used instead of PRINT
FormatPRINT [Expression [; or, Expression…]]
ArgumentsExpression- Variables, string variables, numerical values, or character strings to display
- Formulas are also allowed, including the four arithmetic operations, and functional calculations (The calculation results will be displayed)
; (semicolon)Without beginning a new line after the previous display item, displays the next display item without any space
, (comma)- Without beginning a new line after the previous display item, places a set interval before the next display item
- The display location is determined according to a system variable (the TABSTEP unit)
ExamplesPRINT "RESULT(X,Y)=";DX*4+1,DY+1
ATTRSets the rotation/inversion attributes of the characters to display on the console screen
Constants for text attributes are available (#TROT0-270, #TREVH,V)
FormatATTR Display attribute
ArgumentsDisplay attribute|b00| ↑Rotation by 90 degrees (specified by using two bits: b00 and b01)
|b01| ↓#TROT0, #TROT90, #TROT180, #TROT270
|b02| Horizontal inversion (0=OFF, 1=ON), #TREVH
|b03| Vertical inversion (0=OFF, 1=ON), #TREVV
ExamplesATTR 3:PRINT "ABC"
SCROLLAdjusts the display location of the whole console screen
- Can give the impression of a moving view point (characters will move in the opposite direction)
- Characters pushed out of the screen will disappear
FormatSCROLL Number of characters X, Number of characters Y
ArgumentsNumber of characters XAmount of horizontal view point movement (Negative values indicate leftward movement, positive values rightward movement)
Number of characters YAmount of vertical view point movement (Negative values indicate upward movement, positive values downward movement)
ExamplesSCROLL 5,7
CHKCHRChecks the character code of a character on the console screen
FormatVariable = CHKCHR( X-coordinate,Y-coordinate )
ArgumentsX-,Y-coordinatesCoordinates in character units (X:0-49,Y:0-29)
Return ValuesUTF-16 character code
ExamplesCODE=CHKCHR(0,0)
INPUTInputs numerical values or character strings from the keyboard
- Waits for input until the ENTER key is input
- If the number of input items is insufficient, "?Redo from start" will be displayed for re-input
FormatINPUT ["Guiding text string";] Variable[,Variable 2…]
ArgumentsGuiding text string- Guidance message for input (Optional)
- If , (comma) is used instead of ; after the guiding text string, a ? mark will not be displayed
- Only when ; is used, a string variable can be used for the guiding text string
Variables- Variables to receive the input (numerical values or string variables)
- When specifying multiple variables, they should be delimited with commas (,)
ExamplesINPUT "Your name and age";NM$,AG
LINPUTGets a character string input from the keyboard
- Also accepts "," and other characters that the INPUT instruction does not allow
- Waits for input until the ENTER key is input
FormatLINPUT ["Guiding text string";] String variable
ArgumentsGuiding text stringGuidance message for input (Optional)
String variableString variable to receive a single line input
ExamplesLINPUT "ADDRESS:";ADR$
INKEY$Gets a character input from the keyboard (without waiting for input)
FormatString variable=INKEY$()
ArgumentsNone
Return Values- A character (UTF-16) from the keyboard
- If there is no input, "" will be returned
ExamplesC$=INKEY$()
FONTDEF (1)Defines a font for the specified character code
FormatFONTDEF Character code, "Font definition string"
ArgumentsCharacter codeCharacter code (UTF-16) for which to define a font
Font definition string- One pixel corresponds to a 16-bit color code in the RGBA=5551 format
- 5 bits for each RGB color (0-31) + alpha channel 1 bit (0: Transparent, 1: Opaque)
- A color element should be handled as a 4-digit hexadecimal string
- Example) White: FFFF, Black: 0001, Red: F801
- As one character occupies 8x8=64 pixels, its font definition string should consist of a total of 256 characters
See AlsoFont images can be manipulated with GCOPY, GSAVE, or GLOAD page number -1
ExamplesF$="FFFF":Z$="0000"
D$=F$*7+Z$
D$=D$+F$*2+Z$*3+F$*2+Z$
D$=D$+F$+Z$+F$*3+Z$+F$+Z$
D$=D$+F$+Z$*5+F$+Z$
D$=D$+F$+Z$+F$*3+Z$+F$+Z$
D$=D$+F$+Z$+F$*3+Z$+F$+Z$
D$=D$+F$*7+Z$
D$=D$+Z$*8
FONTDEF ASC("A"),D$
FONTDEF (2)Defines a font for the specified character code
FormatFONTDEF Character code, Numerical value array
ArgumentsCharacter codeCharacter code (UTF-16) for which to define a font
Font definition array- A numerical value array with an element for each pixel should be prepared (8x8 pixels for one character = 64 elements)
- One pixel corresponds to a 16-bit color code in the RGBA=5551 format
- 5 bits for each RGB color (0-31) + alpha channel 1 bit (0: Transparent, 1: Opaque)
- Example) White: &HFFFF, Black: &H0001, Red: &HF801
See AlsoFont images can be manipulated with GCOPY, GSAVE, or GLOAD page number -1
ExamplesDIM F%[64]
DATA "11111110"
DATA "11000110"
DATA "10111010"
DATA "10000010"
DATA "10111010"
DATA "10111010"
DATA "11111110"
DATA "00000000"
TOP=ASC("A"):CNT=1
FOR I=0 TO CNT-1
 FOR D=0 TO 7
  READ F$
  FOR B=0 TO 7
   C=0:IF MID$(F$,B,1)=="1" THEN C=&HFFFF
   F%[D*8+B]=C
  NEXT
 NEXT
 FONTDEF TOP+I,F%
NEXT
FONTDEF (3)Resets the font definition to its initial state
FormatFONTDEF
ExamplesFONTDEF
WIDTHChanges the console character sizes
- Only enlarges the characters, does not display a smooth zoomed-in view
- This is an auxiliary function for people who have trouble viewing small characters
FormatWIDTH Font size
ArgumentsFont size 8: 8x8 pixels (Standard)
16: 16x16 pixels (Twice as large as the normal horizontal and vertical display)
ExamplesWIDTH 16
A=WIDTH()

Various kinds of input

Instructions for retrieving information from buttons, sticks, touch sensors, and microphones

BUTTONGets the status of hardware buttons
Constants for buttons are available for return values
FormatVariable=BUTTON( [Feature ID [,Terminal ID]] )
ArgumentsFeature ID0: Held down
1: Moment pressed (with the repeat feature enabled)
2: Moment pressed (with the repeat feature disabled)
3: Moment released
Terminal ID (0-3)This should be specified to get information from another terminal via wireless communication
Return Values|b00| +Control Pad up (1), #UP
|b01| +Control Pad down (2), #DOWN
|b02| +Control Pad left (4), #LEFT
|b03| +Control Pad right (8), #RIGHT
|b04| A button (16), #A
|b05| B button (32), #B
|b06| X button (64), #X
|b07| Y button (128), #Y
|b08| L button (256), #L
|b09| R button (512), #R
|b10| Not used
|b11| ZR button (2048), #ZL
|b12| ZL button (4096), #ZR

- The buttons correspond to b0-b12 (If a button is pressed, its corresponding bit = 1)
- Contents in () next to button names are decimal numerals
- ZR and ZL buttons are available only when Circle Pad Pro is used
ExamplesB=BUTTON()
B=BUTTON( 0,3 )
BREPEATSets the key repeat feature
- Omitting Start time and Interval will turn off repeat
- Management numbers differ from the bit values that correspond to each button in BUTTON
- ZR and ZL buttons are available only when Circle Pad Pro is used
FormatBREPEAT Button ID, Start time, Interval
ArgumentsButton ID0: +Control Pad up ID
1: +Control Pad down ID
2: +Control Pad left ID
3: +Control Pad right ID
4: A button ID
5: B button ID
6: X button ID
7: Y button ID
8: L button ID
9: R button ID
10: Not used
11: ZR button ID
12: ZL button ID
Start timeTime from when a key is pressed first to when repeat begins (in units of 1/60th of a second)
IntervalRepeat interval after repeat begins (in units of 1/60th of a second, 0 = Repeat OFF)
ExamplesBREPEAT 0,15,4
STICKGets information on the Circle Pad
FormatSTICK [Terminal ID] OUT X,Y
ArgumentsTerminal ID (0-3)This should be specified when information is obtained from another terminal via wireless communication
Return ValuesX,Y- Variables to receive Circle Pad input magnitude ( X:±1.0, Y:±1.0 )
- Actual return values will be around ±0.86
- For Y values, ↑ corresponds to positive and ↓ to negative
ExamplesSTICK OUT X,Y
STICK 3 OUT X,Y
STICKEXGets information on the Circle Pad Pro stick
Circle Pad Pro should be enabled beforehand with XON EXPAD
FormatSTICKEX [Terminal ID] OUT X,Y
ArgumentsTerminal ID (0-3)This should be specified when information from another terminal is to be obtained via wireless communication
Return ValuesX,Y Variables to receive Circle Pad Pro input magnitude ( X:±1.0, Y:±1.0 )
ExamplesXON EXPAD
STICKEX OUT X,Y
ACCELGets information on acceleration
- The motion sensor should be enabled beforehand with XON MOTION
- Note that this instruction will continue to detect 1G acceleration in the gravity direction
- This is useful when operation is performed while tilting
FormatACCEL OUT X,Y,Z
ArgumentsNone
Return ValuesX,Y,ZVariables to receive acceleration (Unit: G)
ExamplesXON MOTION
ACCEL OUT X,Y,Z
GYROVGets information on the angular velocity of the gyro sensor
Motion sensor(s) should be enabled beforehand with XON MOTION
FormatGYROV OUT P,R,Y
ArgumentsNone
Return ValuesPVariable to receive Pitch (angular velocity of the X-coordinate) (Unit: radians/second)
R Variable to receive Roll (angular velocity of the Y-coordinate) (Unit: radians/second)
YVariable to receive Yaw (angular velocity of the Z-coordinate) (Unit: radians/second)
ExamplesXON MOTION
GYROV OUT P,R,Y
GYROAGets information on the angle of the gyro sensor
Motion sensor(s) should be enabled beforehand with XON MOTION
FormatGYROA OUT P,R,Y
ArgumentsNone
Return ValuesPVariable to receive Pitch (angle of the X-coordinate) (Unit: radian)
R Variable to receive Roll (angle of the Y-coordinate) (Unit: radian)
YVariable to receive Yaw (angle of the Z-coordinate) (Unit: radian)
ExamplesXON MOTION
GYROA OUT P,R,Y
GYROSYNCUpdates gyro information
- Error accumulation may occur if gyro information is repeatedly retrieved
- This instruction should be called to reset information appropriately
- However, calling this instruction at an interval of 1 frame or less is prohibited
FormatGYROSYNC
ExamplesGYROSYNC
TOUCHGets touch information
The 5 pixels around the edge of the screen cannot be read
FormatTOUCH [Terminal ID] OUT STTM,TX,TY
ArgumentsTerminal ID (0-3)This should be specified when information from another terminal is to be obtained via wireless communication
Return ValuesSTTMVariable to receive the time when the screen is touched (0 = No touch)
TX,TY- Variables to receive the touch coordinates (TX: 5-314, TY: 5-234)
- Note that returned values are not in the same range as the size of the Touch Screen
ExamplesTOUCH OUT TM,TX,TY
MICSTARTStarts sampling from the microphone
- The microphone should be enabled beforehand with XON MIC
- Recorded into memory used for sampling in the system
FormatMICSTART Sampling rate, Number of bits, Number of seconds
ArgumentsSampling rate0: 8180Hz
1: 10910Hz
2: 16360Hz
3: 32730Hz
Number of bits0: 8 bits
1: 16 bits
Number of seconds0: Loop mode
1-: Number of seconds for sampling
- 8180Hz: Up to 32 sec for 8 bits, 16 sec for 16 bits
- 10910Hz: Up to 24 sec for 8 bits, 12 sec for 16 bits
- 16360Hz: Up to 16 sec for 8 bits, 8 sec for 16 bits
- 32730Hz: Up to 8 sec for 8 bits, 4 sec for 16 bits
- In loop mode, data will be overwritten from the beginning once the maximum number of seconds has been reached
ExamplesXON MIC
MICSTART 0,1,10
MICSTOPStops sampling from the microphone
FormatMICSTOP
ExamplesMICSTOP
MICDATAGets data from the microphone
This returns sampling data from the specified position
FormatVariable=MICDATA( Acquisition position )
ArgumentsAcquisition position- 0- (The range is determined according to the number of bits and the maximum number of seconds)
- In loop mode, the range will not be checked
Return ValuesWaveform data- For 8 bits, return values are 128-basis
- For 16 bits, return values are 32768-basis
ExamplesD=MICDATA(100)
MICSAVECopies data from the internal sampling memory to an array
FormatMICSAVE [[Acquisition position,] Number of samples to get,] Array name
ArgumentsAcquisition positionPosition to start capturing from (0-)
Number of samples- Number of samples to capture (If omitted, the whole sampling buffer)
- Any value greater than the product of the sampling rate and the number of seconds specified with MICSTART will give an error
Array name- Array to store the captured sampling data
- For one-dimensional arrays, if the number of samples exceeds the number of elements, the array will be extended automatically
ExamplesMICSTART 0,0,1 'rate:8180 bit:8 length:1sec
DIM WAVE%[8180] 'MICSIZE
MICSAVE 0,8180,WAVE%

Files

Instructions for retrieving file lists, reading from/writing to files, etc.

FILES (1)Displays a file list on the console
FormatFILES ["File type"]
ArgumentsFile typeTo display only a certain type of file, specify the following:
"TXT:" Texts and programs
"DAT:" Binary data (including graphics)
"//" Project list
"PROJECT/" Project name should be specified
ExamplesFILES
FILES (2)Gets a file list and stores it in an array
FormatFILES ["File type",] String array
ArgumentsFile typeTo display only a certain type of file, specify the following:
"TXT:" Texts and programs
"DAT:" Binary data (including graphics)
"//" Project list
"PROJECT/" Project name should be specified
String arrayString array to store the listed file names
- For one-dimensional arrays, the array will be automatically extended according to the number of files obtained
ExamplesDIM NAMETBL$[100]
FILES NAMETBL$
LOAD (1)Loads a file
- A confirmation dialog will be displayed
- It is impossible to load a program into the same program SLOT as a running program
FormatLOAD "[Resource name:]File name"[,Dialog display flag]
ArgumentsResource name:If omitted: Current program SLOT
PRG0-PRG3: Program SLOT (PRG = PRG0)
GRP0-GRP5: Graphic page
GRPF: Font image page
File nameName of file to load
Dialog display flagFALSE = Suppresses confirmation dialog
ExamplesLOAD "PROGNAME"
LOAD "GRP0:GRPDATA"
LOAD (2)Loads a text file into a string variable
FormatLOAD "TXT:File name"[,Dialog display flag] OUT TX$
ArgumentsFile nameName of text file to load (prefixed with "TXT:")
Dialog display flagFALSE = Suppresses confirmation dialog
Return ValuesTX$String variable to store the loaded text file
ExamplesLOAD "TXT:MEMOFILE" OUT TX$
LOAD (3)Loads a text file into a string variable
FormatString variable = LOAD("TXT:File name" [,Dialog display flag])
ArgumentsFile nameName of text file to load (prefixed with "TXT:")
String variableString variable to store the loaded text file
Dialog display flagFALSE = Suppresses confirmation dialog
ExamplesTX$=LOAD("TXT:MEMOFILE")
LOAD (4)Loads a binary file into a numerical value array
FormatLOAD "DAT:File name", Numerical value array[,Dialog display flag]
ArgumentsFile nameName of binary file to load (prefixed with "DAT:")
Numerical value arrayNumerical value variable to store the loaded binary file
Dialog display flagFALSE = Suppresses confirmation dialog
ExamplesDIM MARRAY[100]
LOAD "DAT:MDATA", MARRAY
SAVE (1)Saves a file
- When run, a confirmation dialog will be displayed
- The confirmation dialog for SAVE cannot be hidden
FormatSAVE "[Resource name:]File name"
ArgumentsResource name:If omitted: Current program SLOT
PRG0-PRG3: Program SLOT (PRG = PRG0)
GRP0-GRP5: Graphic page
GRPF: Font image page
File nameName to save the file under
ExamplesSAVE "PRG0:TEST"
SAVE (2)Saves a string variable to a text file
FormatSAVE "TXT:File name", String variable
ArgumentsFile nameName to save the file under (prefixed with "TXT:")
String variableString variable containing the text data to be saved (UTF-8)
ExamplesSAVE "TXT:MEMOFILE",TX$
SAVE (3)Saves a numerical value array to a binary file
FormatSAVE "DAT:File name", Numerical value array
ArgumentsFile nameName to save the file under (prefixed with "DAT:")
Numerical value arrayNumerical value array containing the data to be saved
ExamplesSAVE "DAT:TEST",MARRAY
RENAMEChanges a file name
When run, a confirmation dialog will be displayed
FormatRENAME "[File type:]File name", "[File type:]New name"
ArgumentsFile type: "TXT:" Texts and programs (optional)
"DAT:" Binary data (including graphics)
File nameName of file to change name of
New nameNew file name
ExamplesRENAME "SAMPLE","NEWNAME"
DELETEDeletes a file
When run, a confirmation dialog will be displayed
FormatDELETE "[File type:]File name"
ArgumentsFile type:"TXT:" Texts and programs (optional)
"DAT:" Binary data (including graphics)
ExamplesDELETE "SAMPLE"
EXEC (1)Loads and executes a program
- It is impossible to return from a program started with EXEC to the previous program
- It is possible to return by using END in a program started with EXEC in another SLOT
- This cannot be used to run a program in DIRECT mode
FormatEXEC "[Resource name:]File name"
ArgumentsResource name: PRG0-PRG3: Program SLOT into which to load the program
File nameFile name of the program to load
ExamplesEXEC "SAMPLE"
EXEC "PRG0:SBGED"
EXEC (2)Executes a program in a different SLOT
- It is impossible to return from a program executed with EXEC to the previous program
- It is possible to return by using END in a program started with EXEC in another SLOT
- This cannot be used to run a program in DIRECT mode
FormatEXEC Program SLOT
ArgumentsProgram SLOT0-3: SLOT number of the program to execute
ExamplesEXEC 2
USEMakes a program in the specified program SLOT executable
FormatUSE Program SLOT
ArgumentsProgram SLOT0-3: Program SLOT
ExamplesUSE 2
CHKFILEChecks if the specified file exists
FormatVariable = CHKFILE("[File type:]File name")
ArgumentsFile type"TXT:" Texts and programs
"DAT:" Binary data (including graphics)
File nameName of the file to check
Return ValuesTRUE= Exists, FALSE= Does not exist
ExamplesA=CHKFILE("SBATTACK")

Wireless communication

Instructions related to wireless communication sessions, which allow up to four systems to be connected
* In order to connect, each system must have SmileBASIC installed.

MPSTARTStarts a wireless communication session
- Connection to a session is allowed when MPSTART identifiers are equal
- The RESULT system variable should be used to get information on whether or not a session has successfully been established
- Communication will be terminated if the system goes into sleep mode
FormatMPSTART Maximum number of connected users, "Communication identifier string"
ArgumentsMaximum number of connected users2-4: Number of concurrent connected users
Communication identifier stringAny character string for authentication
ExamplesMPSTART 4,"ANYSTR"
MPENDEnds a wireless communication session
- All participants close the session synchronously
- A wait dialog will be displayed
FormatMPEND
ExamplesMPEND
MPSENDSends data to all participants in a wireless communication session
- Delivery of sent data is guaranteed, but with a delay
- A large number of MPSEND calls in a short period will result in an error
  * Communication buffer overflow
- Communication will be terminated if the system goes into sleep mode
FormatMPSEND "Character string to send"
ArgumentsCharacter string to sendCharacter string of up to 256 bytes
ExamplesMPSEND "HELLO!"
MPRECVReceives data from MPSEND
- If there is no data to receive, the sender ID will contain the value -1
- Communication will be terminated if the system goes into sleep mode
FormatMPRECV OUT SID,RCV$
ArgumentsSID0-3: Connection destination number from which the string will be sent
RCV$String variable to store the received data
ExamplesMPRECV OUT SID,RCV$
PRINT SID;":";RCV$
MPSTATGets the connection status of a specified terminal in a wireless communication session
Communication will be terminated if the system goes into sleep mode
FormatVariable = MPSTAT( [Terminal ID] )
ArgumentsTerminal ID0-3: ID of another terminal in the wireless communication session (If omitted, the whole session will be assumed)
Return Values0: Not connected, 1: Connected
ExamplesRET=MPSTAT( 2 )
MPNAME$Gets the terminal name of a specified terminal in a wireless communication session
Communication will be terminated if the system goes into sleep mode
FormatString variable = MPNAME$( Terminal ID )
ArgumentsTerminal ID0-3: ID of another terminal in the wireless communication session
Return ValuesTerminal name string
ExamplesNAME$=MPNAME$( 3 )
MPGETGets user-defined data from a specified terminal in a wireless communication session
Communication will be terminated if the system goes into sleep mode
FormatVariable=MPGET( Terminal ID, Internal management number )
ArgumentsTerminal ID0-3: ID of another terminal in the wireless communication session
Internal management number0-8: Management number of the target data
Return ValuesNumerical value (integer) of the specified data
ExamplesRET=MPGET( 0, 5 )
MPSETWrites to user-defined data in a wireless communication session
Communication will be terminated if the system goes into sleep mode
FormatMPSET Internal management number, Numerical value
ArgumentsInternal management number0-8: Management number of the target data/td>
Numerical valueNumerical value to register (Only an integer value is allowed)
ExamplesMPSET 5,123

Screen control

Instructions related to screen display modes, etc.

XSCREENSets a screen mode
- Screen modes 2 and 3 can also be used in DIRECT mode, but the Touch Screen will be switched to a keyboard after execution is started
- 3D specification can be disabled in the Parental Control settings
FormatXSCREEN Screen mode [,Number of sprite assignments ,Number of BG assignments]
ArgumentsScreen mode0: Upper screen-3D, Touch Screen-Not used (Default)
1: Upper screen-2D, Touch Screen-Not used
2: Upper screen-3D, Touch Screen-Used (Keyboard displayed during INPUT)
3: Upper screen-2D, Touch Screen-Used (Keyboard displayed during INPUT)
4: Upper and Touch screens combined (Upper screen 2D; INPUT and DIRECT mode not allowed)
Number of sprite assignments- Number of sprites to assign to the upper screen: 0-512
- Touch Screen: 512 - number of SPs on the upper screen
Number of BG allocations - Number of BG layers to assign to the upper screen: 0-4
- Touch Screen: 4 - number of BG layers on the upper screen
ExamplesXSCREEN 2,128,4
DISPLAY (1)Selects the screen to manipulate (Upper or Touch)
- DISPLAY 1 can be specified when XSCREEN 2 or 3 is used
-This command cannot be directly executed in DIRECT mode.
FormatDISPLAY Screen ID
ArgumentsScreen ID0: Upper screen, 1: Touch Screen
ExamplesDISPLAY 0
DISPLAY (2)Gets the Screen ID that is currently being used
- DISPLAY 1 can be specified when XSCREEN 2 or 3 is used
- This command cannot be directly executed in DIRECT mode.
FormatVariable=DISPLAY()
Return ValuesScreen ID (0: Upper screen, 1: Touch Screen)
ExamplesA=DISPLAY()
VISIBLESwitches screen display elements ON/OFF
FormatVISIBLE Console,Graphic,BG,sprite
ArgumentsConsole0: Hide (#OFF), 1: Display (#ON)
Graphic0: Hide (#OFF), 1: Display (#ON)
BG0: Hide (#OFF), 1: Display (#ON)
sprite0: Hide (#OFF), 1: Display (#ON)
ExamplesVISIBLE 1,1,1,1
BACKCOLOR (1)Specifies a background color
FormatBACKCOLOR Background color code
ArgumentsBackground color code- Usually specified with the RGB function, e.g., BACKCOLOR RGB(64,128,128)
- To specify a numerical value directly, a color code consisting of an 8-bit value for each RGB element should be specified
ExamplesBACKCOLOR RGB(64,128,128)
BACKCOLOR (2)Specifies the current background color
FormatVariable=BACKCOLOR()
Return ValuesColor code of the background color currently set
ExamplesC=BACKCOLOR()
ACLSResets the draw settings to their settings when BASIC was started
- The same operations as those shown after END in the Examples should be executed
- Sound settings such as BGM will not be affected
FormatACLS
ExamplesACLS
END
'---
XSCREEN 0
LOAD "GRP4:SYS/DEFSP.GRP"
LOAD "GRP5:SYS/DEFBG.GRP"
FONTDEF
SPDEF
DISPLAY 1
WIDTH 8
BACKCOLOR 0
FADE 0
COLOR 15,0:LOCATE 0,0,0:ATTR 0:CLS
GPAGE 1,1:SPPAGE 4:BGPAGE 5
VISIBLE 1,1,1,1
DISPLAY 0
BACKCOLOR 0
FADE 0
WIDTH 8
COLOR 15,0:LOCATE 0,0,0:ATTR 0:CLS
FOR I=0 TO 3:GPAGE I,I:GCLS 0:NEXT
GPAGE 0,0:GPRIO 1024
SPPAGE 4:SPCLR
BGPAGE 5:BGCLR
VISIBLE 1,1,1,1
FADE (1)Sets the color for the screen fader
- The fader is always displayed in the front
- The entire screen is filled with the fading color (taking the transparent color into consideration)
FormatFADE Fading color [,Fading time]
ArgumentsFading colorThe color to fill the screen (specifying RGB(0,0,0,0) disables the fader)
Fading timeThe screen color changes from the current fading color to the specified fading color over a specified time period, which can be specified in units of 1/60th of a second.
ExamplesFADE RGB(32,64,64,64),60
FADE (2)Gets the current screen fader color
FormatValue=FADE()
Return ValuesColor code consisting of an 8-bit value for each ARGB element
ExamplesC=FADE()
FADECHKGets the state of the fading animation
FormatVariable=FADECHK()
Return ValuesTRUE= Animation in progress, FALSE= Animation suspended
ExamplesR=FADECHK()

Graphics

Functions for drawing figures including lines and circles in pixel units

GPAGE (1)Specifies a page for graphic display and a page for manipulation
FormatGPAGE Display page, Manipulation page
ArgumentsDisplay page0-5: GRP0-GRP5
Manipulation page0-5: GRP0-GRP5
* By default, GRP4 contains sprites and GRP5 contains BG images.
ExamplesGPAGE 0,0
GPAGE (2)Gets information on the graphic page currently set
FormatGPAGE OUT VP,WP
ArgumentsNone
Return ValuesVPPage number for display (0-5)
WPPage number for manipulation (0-5)
ExamplesGPAGE OUT WP,GP
GCOLOR (1)Specifies the graphic draw color
FormatGCOLOR Color code
ArgumentsColor code- Usually specified with the RGB function, e.g., GCOLOR RGB(64,255,48)
- To specify a numerical value directly, a color code consisting of an 8-bit value for each ARGB element should be specified
- An 8-bit value for A (255: Opaque, Otherwise: Transparent) + one for each RGB element (0-255)
ExamplesGCOLOR RGB(255,0,0)
GCOLOR (2)Specifies the graphic draw color
FormatGCOLOR OUT C32
ArgumentsNone
Return ValuesC32Color code consisting of an 8-bit value for each ARGB element
ExamplesGCOLOR OUT C32
RGBGets a color code based on 8-bit RGB values
- Black RGB(0,0,0)
- White RGB(255,255,255)
- Light gray RGB(224,224,224)
- Gray RGB(128,128,128)
- Dark gray RGB(64,64,64)
- Red RGB(255,0,0)
- Pink RGB(255,96,208)
- Purple RGB(160,32,255)
- Light blue RGB(80,208,255)
- Blue RGB(0,32,255)
- Yellow green RGB(96,255,128)
- Green RGB(0,192,0)
- Yellow RGB(255,224,32)
- Orange RGB(255,160,16)
- Brown RGB(160,128,96)
- Pale pink RGB(255,208,160)
FormatVariable = RGB( [Transparency,] Red,Green,Blue )
ArgumentsTransparency- Transparency information (255: Opaque, Otherwise: Transparent)
- A transparency level in the range 0-255 can be specified for SPCOLOR
Red, Green, BlueEach color has an 8-bit color tone value (each 0-255)
Return ValuesVariable=Color code (An 8-bit value for each ARGB element) * See GCOLOR
ExamplesGPSET 0,0, RGB(255,255,0) 'YELLOW
RGBREADGets each RGB element from a color code
FormatRGBREAD Color code OUT [A,] R,G,B
ArgumentsColor codeColor code consisting of an 8-bit value for each ARGB element * See GCOLOR
Return ValuesAVariable to receive transparency information (Opaque: 255 - 0: Transparent)
R,G,BVariables to receive 8-bit color information (each 0-255)
ExamplesRGBREAD C OUT R,G,B
GCLIPSpecifies a clipping area on the graphic screen
- When the range is omitted in display mode, the whole screen will be clipped
- When the range is omitted in write mode, the whole graphic page is assumed
FormatGCLIP Clip mode [,Start point X,Start point Y,End point X, End point Y]
ArgumentsClip mode0: Clipping for display, 1: Clipping for writing
Start point X,YStart point coordinates for the clipping area
End point X,YEnd point coordinates for the clipping area
ExamplesGCLIP 0,100,100,200,200
GPRIOChanges the display order of the graphic screen
If 3D mode is used, the whole graphic screen will be affected
FormatGPRIO Z-coordinate
ArgumentsZ-coordinateCoordinate in the depth direction (Rear:1024 < Screen surface:0 < Front:-256)
ExamplesGPRIO -100
GCLSClears the graphic screen
- Instruction to fill the whole screen with black
- It is also possible to specify a color code with which to fill the screen
FormatGCLS [ Color code ]
ArgumentsColor codeColor code consisting of an 8-bit value for each ARGB element * See GCOLOR
ExamplesGCLS RGB(32,32,32)
GSPOITGets a color from the specified coordinates on the graphic screen
The return value may not be the same as the value specified at the time of drawing because it has passed through the internal color representation
FormatVariable = GSPOIT( X-coordinate,Y-coordinate )
ArgumentsX-,Y-coordinatesCoordinates of which to get the color (X: 0-399, Y: 0-239)
Return ValuesColor code consisting of an 8-bit value for each ARGB element * See GCOLOR
ExamplesC=GSPOIT(100,100)
GPSETPuts a pixel on the graphic screen
FormatGPSET X-coordinate,Y-coordinate [,Color code ]
ArgumentsX-,Y-coordinatesCoordinates to place the pixel at
Color codeColor code consisting of an 8-bit value for each ARGB element * See GCOLOR
ExamplesGPSET 100,50
GLINEDraws a straight line on the graphic screen
FormatGLINE Start point X,Start point Y, End point X,End point Y [,Color code ]
ArgumentsStart point X,YStart point coordinates (X: 0-399, Y: 0-239)
End point X,YEnd point coordinates (X: 0-399, Y: 0-239)
Color codeColor code consisting of an 8-bit value for each ARGB element * See GCOLOR
ExamplesGLINE 0,0,399,239,RGB(0,255,255)
GCIRCLE (1)Draws a circle on the graphic screen
FormatGCIRCLE Center point X,Center point Y, Radius [,Color code ]
ArgumentsCenter point X,YCenter point coordinates (X: 0-399, Y: 0-239)
RadiusRadius of the circle (in pixels) 1-
Color codeColor code consisting of an 8-bit value for each ARGB element * See GCOLOR
ExamplesGCIRCLE 200,120,30
GCIRCLE (2)Draws an arc on the graphic screen
FormatGCIRCLE Center point X, Center point Y, Radius, Start angle, End angle [ Flag [ Color code ]]
ArgumentsCenter point X,YCenter point coordinates (X: 0-399, Y: 0-239)
RadiusRadius of the circle (in pixels) 1-
Start angle, End angleAngle of the arc 0-360
FlagDrawing method (0=Arc, 1=Sector)
Color codeColor code consisting of an 8-bit value for each ARGB element * See GCOLOR
ExamplesGCIRCLE 200,120,30, 0,45, 1
GBOXDraws a quadrangle on the graphic screen
FormatGBOX Start point X,Start point Y, End point X,End point Y [,Color code]
ArgumentsStart point X,YStart point coordinates (X: 0-399, Y: 0-239)
End point X,YEnd point coordinates (X: 0-399, Y: 0-239)
Color codeColor code consisting of an 8-bit value for each ARGB element * See GCOLOR
ExamplesGBOX 0,0,399,239
GFILLDraws a quadrangle on the graphic screen and fills it with a color
FormatGFILL Start point X,Start point Y, End point X,End point Y [,Color code]
ArgumentsStart point X,YStart point coordinates (X: 0-399, Y: 0-239)
End point X,YEnd point coordinates (X: 0-399, Y: 0-239)
Color codeColor code consisting of an 8-bit value for each ARGB element * See GCOLOR
ExamplesGFILL 0,0,399,239
GPAINTFills the graphic screen with color
If the border color is omitted, the color range at the start point coordinates will be used
FormatGPAINT Start point X, Start point Y [ ,Fill Color [, Border color ] ]
ArgumentsStart point X,YCoordinates to start filling from (X: 0-399, Y: 0-239)
Fill colorColor code consisting of an 8-bit value for each ARGB element * See GCOLOR
Border colorShould be specified in the same way as Fill color
ExamplesGPAINT 200,120,RGB(255,0,0),RGB(0,0,0)
GCOPYCopies an image from another graphic page
FormatGCOPY [Transfer source page,] Start point X,Start point Y, End point X,End point Y, Transfer destination X,Transfer destination Y, Copy mode
ArgumentsTransfer source page0-5 (GRP0-GRP5), -1 (GRPF) If omitted: Current drawing page
Start point X,Y End point X,YStart and end point coordinates of the copy source range (X: 0-399, Y: 0-239)
Transfer destination X,YStart point coordinates of the copy destination range (X: 0-399, Y: 0-239)
Copy modeTRUE = Copies the transparent color, FALSE = Does not copy the transparent color
ExamplesGCOPY 0, 0,0,100,100, 200,100 ,1
GSAVECopies an image (whole screen) to an array
FormatGSAVE [Transfer source page,] [X,Y,Width,Height,] Transfer destination array, Color conversion flag
ArgumentsTransfer source page0-5 (GRP0-GRP5), -1(GRPF) If omitted: Current drawing page
X,Y,Width,HeightStart point X-coordinate, start point Y-coordinate, and width/height (in pixels) of the copy source range
If omitted: Current drawing area
Transfer destination arrayArray variable to store the image
* If the number of elements in the array is insufficient, the required element(s) will be added automatically, provided that the array is one-dimensional.
Color conversion flag0: Performs color conversion (Converts to 32-bit logical colors)
1: Leaves the physical codes as they are (16-bit)
ExamplesDIM WORK[0]
GSAVE 0,0,0,512,512,WORK,1
GLOAD (1)Copies image data from an array to the graphic screen
FormatGLOAD [X,Y,Width,Height,] Image array,Color conversion flag,Copy mode
ArgumentsX,Y,Width,HeightStart point X-coordinate, start point Y-coordinate, and width/height (in pixels) of the copy destination range
Image arrayNumerical value array containing image data stored with GSAVE
Color conversion flag0: Performs color conversion (Converts to 32-bit logical colors)
1: Leaves the physical codes as they are (16-bit)
Copy modeTRUE = Copies the transparent color, FALSE = Does not copy the transparent color
ExamplesGLOAD 0,0,512,512, WORK, 1, 0
GLOAD (2)Copies image data from an array to the graphic screen
Colors will be handled as index colors from palettes
FormatGLOAD [X,Y,Width,Height,] Image array,Palette array,Copy mode
ArgumentsX,Y,Width,HeightStart point X-coordinate, start point Y-coordinate, and width/height (in pixels) of the copy destination range
Image arrayNumerical value array containing image data stored with GSAVE
Palette arrayNumerical value array containing palette data
Copy modeTRUE = Copies the transparent color, FALSE = Does not copy the transparent color
ExamplesGLOAD 0,0,512,512, WORK, PALETTE, 0
GTRIDraws a triangle on the graphic screen and fills it with a color
FormatGTRI X1,Y1, X2,Y2, X3,Y3 [,Color code]
ArgumentsX1,Y1Vertex 1(X: 0-399, Y: 0-239)
X2,Y2Vertex 2 (X: 0-399, Y: 0-239)
X3,Y3Vertex 3 (X: 0-399, Y: 0-239)
Color codeColor code consisting of an 8-bit value for each ARGB element * See GCOLOR
ExamplesGTRI 200,10,300,200,100,200
GPUTCHR (1)Draws a character string on the graphic screen
FormatGPUTCHR X,Y, "String" [,Scale X,Scale Y][,Color code]
ArgumentsX,YDisplay position (X: 0-399, Y: 0-239)
"String"String to display
Scale X,YDisplay magnification (No scaling=1.0)
Color codeColor code consisting of an 8-bit value for each ARGB element * See GCOLOR
ExamplesGPUTCHR 10,10,"あいう"
GPUTCHR (2)Draws a character on the graphic screen
FormatGPUTCHR X,Y, Character code [,Scale X,Scale Y][,Color code]
ArgumentsX,YDisplay position (X: 0-399, Y: 0-239)
Character codeCharacter code to display
Scale X,YDisplay magnification (No scaling=1.0)
Color codeColor code consisting of an 8-bit value for each ARGB element * See GCOLOR
ExamplesGPUTCHR 10,10,ASC("A")

Sprites

Functions related to display of images made up of rectangles that can be moved freely

SPPAGE (1)Sets a graphic page to assign to sprites
FormatSPPAGE Graphic page
ArgumentsGraphic page0-5 (GRP0-GRP5) By default, the page for sprites is 4 (GRP4)
ExamplesSPPAGE 4
SPPAGE (2)Gets the graphic page that has been assigned to sprites
FormatVariable=SPPAGE()
Return ValuesGraphic page number (0-5)
ExamplesP=SPPAGE()
SPCLIPSpecifies a clipping area in the sprite
- If the range is omitted, the whole screen will be assumed
FormatSPCLIP [Start point X,Start point Y,End point X, End point Y]
ArgumentsStart point X,YStart point coordinates for the clipping area (X: 0-399, Y: 0-239)
End point X,YEnd point coordinates for the clipping area (X: 0-399, Y: 0-239)
ExamplesSPCLIP 100,100,200,200
SPDEF (1)Resets the sprite character definition template to its initial state
FormatSPDEF
ArgumentsNone
Common Supplement for SPDEF- The sprite definition template is a common component for both the upper screen and the Touch Screen
- This is provided in order to simplify SPSET definition
ExamplesSPDEF
SPDEF (2)Creates a template for sprite character definition
FormatSPDEF Definition number, U,V [,W,H [,Origin X,Origin Y]] [,Attribute]
ArgumentsDefinition numberDefinition number of the template: 0-4095
U,VCoordinates of the original image to define (U: 0-511, V: 0-511)
W,HSize of the original image to define If omitted: 16,16
* U+W and/or V+H values greater than 512 will give an error.
Origin X,YReference point for the coordinates of the sprite If omitted: 0,0
Attribute|b00| Display (0=OFF, 1=ON) #SPSHOW
|b01| ↑Rotation by 90 degrees (Specified with two bits: b01 and b02)
|b02| ↓#SPROT0, #SPROT90, #SPROT0180, #SPROT270
|b03| Horizontal inversion (0=OFF, 1=ON), #SPREVH
|b04| Vertical inversion (0=OFF, 1=ON), #SPREVV
|b05| Additive synthesis (0=OFF, 1=ON), #SPADD

If omitted, 0x01 (Only display is set to ON)
ExamplesSPDEF 0,192,352,32,32,16,16,1
SPDEF (3)Creates templates for sprite character definition collectively from an array
FormatSPDEF Numerical value array
ArgumentsNumerical value arrayNumerical value array containing sprite template data
- One sprite template consists of the following 7 elements: U,V,W,H,Origin X,Origin Y,Attribute
- The number of elements must be a multiple of 7
- A specific number of sprite templates (the number of elements divided by 7) will be defined in order, starting with 0
ExamplesSPDEF SRCDATA
SPDEF (4)Creates templates for sprite character definition collectively from a DATA sequence
FormatSPDEF "@Label string"
Arguments@Label stringLabel of the DATA instruction that enumerates the sprite template data
- The @Label name should be enclosed in "" or specified with a string variable
- The first data should be the number of sprites to define, followed by enumeration of the data for each sprite (7 data elements per sprite)
- One sprite template consists of the following 7 elements: U,V,W,H,Origin X,Origin Y,Attribute
ExamplesSPDEF "@SRCDATA"
SPDEF (5)Gets information on a sprite character definition template
FormatSPDEF Definition number OUT U,V [,W,H [,HX,HY]] [,A]
ArgumentsDefinition numberDefinition number of the template: 0-4095
Return ValuesU,VVariables to receive the image coordinates
W,HVariable to receive the image size
HX,HYVariable to receive the reference point for the sprite coordinates
AVariable to receive the attribute
ExamplesSPDEF 2 OUT U,V,ATR
SPDEF (6)Copies a template for sprite character definition
- Unnecessary elements can be omitted (Separating commas (',') are required)
- Arguments are used to adjust the copied template
FormatSPDEF Definition number,Source definition number,[U],[V],[W],[H],[Origin X],[Origin Y],[Attribute]
ArgumentsDefinition numberDefinition number of the template: 0-4095
Source definition numberDefinition number of the copy source: 0-4095
U,VCoordinates of the original image to define (U: 0-511, V: 0-511)
W,HSize of the original image to define If omitted: 16,16
* U+W and/or V+H values greater than 512 will give an error.
Origin X,YReference point for the coordinates of the sprite If omitted: 0,0
Attribute|b00| Display (0=OFF, 1=ON) #SPSHOW
|b01| ↑Rotation by 90 degrees (Specified with two bits: b01 and b02)
|b02| ↓#SPROT0, #SPROT90, #SPROT0180, #SPROT270
|b03| Horizontal inversion (0=OFF, 1=ON), #SPREVH
|b04| Vertical inversion (0=OFF, 1=ON), #SPREVV
|b05| Additive synthesis (0=OFF, 1=ON), #SPADD

If omitted, 0x01 (Only display is set to ON)
ExamplesSPDEF 0,255,192,352,32,32,16,16,1
SPDEF 1,255,,,32,32,,,
SPSET (1)Creates a sprite (using a definition template)
- SPSET makes a sprite available for use
- Executing SPSET will initialize rotation and all other information
- All values of SPVAR will be 0
- When any SPHIT instruction for collision detection is to be used, SPCOL should be called after SPSET
FormatSPSET Management number,Definition number
ArgumentsManagement numberNumber of the sprite to create: 0-511
Definition numberDefinition number of the template defined with SPDEF: 0-4095
ExamplesSPSET 1,500
SPSET (2)Creates a sprite (using image and other information specified directly)
Can be used to set a sprite separately without using the values from SPDEF
- SPSET makes a sprite available for use
- Executing SPSET will initialize rotation and all other information
- All values of SPVAR will be 0
- When any SPHIT instruction for collision detection is to be used, SPCOL should be called after SPSET
FormatSPSET Management number ,U,V [,W,H] ,Attribute
ArgumentsManagement numberNumber of the sprite to create: 0-511
U,VCoordinates of the original image to define (U: 0-511, V: 0-511)
W,HSize of the original image to define (If omitted: 16,16)
* U+W and/or V+H values greater than 512 will give an error.
Attribute|b00| Display (0=OFF, 1=ON) #SPSHOW
|b01| ↑Rotation by 90 degrees (Specified with two bits: b01 and b02)
|b02| ↓#SPROT0, #SPROT90, #SPROT0180, #SPROT270
|b03| Horizontal inversion (0=OFF, 1=ON), #SPREVH
|b04| Vertical inversion (0=OFF, 1=ON), #SPREVV
|b05| Additive synthesis (0=OFF, 1=ON), #SPADD

If omitted, 0x01 (Only display is set to ON)
ExamplesSPSET 54,0,0,32,32,1
SPSET (3)Finds an available sprite number and creates a sprite (using a definition template)
Finds an available sprite number from the whole range
- SPSET makes a sprite available for use
- Executing SPSET will initialize rotation and all other information
- All values of SPVAR will be 0
- When any SPHIT instruction for collision detection is to be used, SPCOL should be called after SPSET
FormatSPSET Definition number OUT IX
ArgumentsDefinition numberDefinition number of the template defined with SPDEF: 0-4095
Return ValuesIXVariable to receive the generated number: 0-511 (-1 = No available number)
ExamplesSPSET 500 OUT IX
SPSET (4)Finds an available sprite number and creates a sprite (using image and other information specified directly)
Finds an available sprite number from the whole range
- SPSET makes a sprite available for use
- Executing SPSET will initialize rotation and all other information
- All values of SPVAR will be 0
- When any SPHIT instruction for collision detection is to be used, SPCOL should be called after SPSET
FormatSPSET U,V,W,H,Attribute OUT IX
ArgumentsU,VCoordinates of the original image to define (U: 0-511, V: 0-511)
W,HSize of the original image to define (If omitted: 16,16)
* U+W and/or V+H values greater than 512 will give an error.
Attribute|b00| Display (0=OFF, 1=ON) #SPSHOW
|b01| ↑Rotation by 90 degrees (Specified with two bits: b01 and b02)
|b02| ↓#SPROT0, #SPROT90, #SPROT0180, #SPROT270
|b03| Horizontal inversion (0=OFF, 1=ON), #SPREVH
|b04| Vertical inversion (0=OFF, 1=ON), #SPREVV
|b05| Additive synthesis (0=OFF, 1=ON), #SPADD
Return ValuesIX Variable to receive the generated number: 0-511 (-1 = No available number)
ExamplesSPSET 0,0,32,32,1 OUT IX
SPSET (5)Finds an available sprite number in a certain range and creates a sprite (using a definition template)
Finds an available number in the specified range
- SPSET makes a sprite available for use
- Executing SPSET will initialize rotation and all other information
- All values of SPVAR will be 0
- When any SPHIT instruction for collision detection is to be used, SPCOL should be called after SPSET
FormatSPSET Upper limit,Lower limit, Definition number OUT IX
ArgumentsUpper limit, Lower limitRange in which to find an available number (0-511)
Definition numberDefinition number of the template defined with SPDEF: 0-4095
Return ValuesIXVariable to receive the generated number: 0-511 (-1 = No available number)
ExamplesSPSET 100,120, 500 OUT IX
SPSET (6)Finds an available sprite number in a certain range and creates a sprite (using image and other information specified directly)
Finds an available number in the specified range
- SPSET makes a sprite available for use
- Executing SPSET will initialize rotation and all other information
- All values of SPVAR will be 0
- When any SPHIT instruction for collision detection is to be used, SPCOL should be called after SPSET
FormatSPSET Upper limit,Lower limit, U,V,W,H,Attribute OUT IX
ArgumentsUpper limit,Lower limitRange in which to find an available number (0-511)
U,VCoordinates of the original image to define (U: 0-511, V: 0-511)
W,HSize of the original image to define (If omitted: 16,16)
* U+W and/or V+H values greater than 512 will give an error.
Attribute|b00| Display (0=OFF, 1=ON) #SPSHOW
|b01| ↑Rotation by 90 degrees (Specified with two bits: b01 and b02)
|b02| ↓#SPROT0, #SPROT90, #SPROT0180, #SPROT270
|b03| Horizontal inversion (0=OFF, 1=ON), #SPREVH
|b04| Vertical inversion (0=OFF, 1=ON), #SPREVV
|b05| Additive synthesis (0=OFF, 1=ON), #SPADD

If omitted, 0x01 (Only display is set to ON)
Return ValuesIX Variable to receive the generated number: 0-511 (-1 = No available number)
ExamplesSPSET 100,120, 0,0,32,32,1 OUT IX
SPCLRStops using the specified sprite and releases the memory
If memory is not released after use with sprites, there will be no available memory for SPSET
FormatSPCLR Management number
ArgumentsManagement numberManagement number of the sprite to stop using: 0-511
ExamplesSPCLR 56
SPSHOWStarts displaying a sprite
If used before SPSET, an error will occur
FormatSPSHOW Management number
ArgumentsManagement numberManagement number of the sprite to display: 0-511
ExamplesSPSHOW 43
SPHIDEHides a sprite
- This only hides the sprite; it continues to exist
- If used before SPSET, an error will occur
FormatSPHIDE Management number
ArgumentsManagement numberManagement number of the sprite to hide: 0-511
ExamplesSPHIDE 43
SPHOME (1)Specifies the reference point (home position) for the coordinates of a sprite
- Position reference point for the SPOFS instruction
- Center point for rotation and scaling
- Center coordinates for collision detection
- If used before SPSET, an error will occur
FormatSPHOME Management number,Position X,Position Y
ArgumentsManagement numberManagement number of the sprite for which to set the reference point: 0-511
Position X,YRelative coordinates with the top left corner of the sprite as the origin (0,0)
ExamplesSPHOME 34,16,16
SPHOME (2)Gets the reference point (home position) for the coordinates of a sprite
If used before SPSET, an error will occur
FormatSPHOME Management number OUT HX,HY
ArgumentsManagement numberManagement number of the sprite: 0-511
Return ValuesHX,HYVariable to receive the coordinates of the reference point
ExamplesSPHOME 10 OUT HX,HY
SPOFS (1)Changes (moves) the coordinates of a sprite
If used before SPSET, an error will occur
FormatSPOFS Management number, X, Y [,Z]
ArgumentsManagement numberManagement number of the target sprite: 0-511
X,YScreen coordinates where the sprite will be displayed
ZCoordinate in the depth direction (Rear:1024 < Screen surface:0 < Front:-256)
ExamplesSPOFS 23,50,80
SPOFS 23,,,1000
SPOFS 23,150,180,0
SPOFS (2)Gets the coordinates of a sprite
If used before SPSET, an error will occur
FormatSPOFS Management number OUT X,Y[,Z]
ArgumentsManagement numberManagement number of the target sprite: 0-511
Return ValuesX,YVariable to receive the coordinates
Z Variable to receive the depth information
ExamplesSPOFS 12 OUT X,Y,Z
SPROT (1)Specifies the rotation angle of a sprite
If used before SPSET, an error will occur
FormatSPROT Management number,Angle
ArgumentsManagement numberManagement number of the target sprite: 0-511
Angle Rotation angle: 0-360 (clockwise)
ExamplesSPROT 23,45
SPROT (2)Gets the rotation angle of a sprite
If used before SPSET, an error will occur
FormatSPROT Management number OUT DR
ArgumentsManagement numberManagement number of the target sprite: 0-511
Return ValuesDRVariable to receive the angle
ExamplesSPROT 23 OUT DR
SPROT (3)Gets the rotation angle of a sprite (Function type)
If used before SPSET, an error will occur
FormatVariable=SPROT(Management number)
ArgumentsManagement numberManagement number of the target sprite: 0-511
Return ValuesCurrent angle (0-360)
ExamplesA=SPROT(23)
SPSCALE (1)Changes the scale (display magnification) of a sprite
- For collision detection that takes scale into account, SPCOL should first be executed
If used before SPSET, an error will occur
FormatSPSCALE Management number, Magnification X, Magnification Y
ArgumentsManagement numberManagement number of the target sprite: 0-511
Magnification X,Y0.5 (50%) - 1.0 (100%) - 2.0 (200%) -
ExamplesSPSCALE 56, 0.75, 0.75
SPSCALE (2)Gets the display magnification of a sprite
If used before SPSET, an error will occur
FormatSPSCALE Management number OUT SX,SY
ArgumentsManagement numberManagement number of the target sprite: 0-511
Return ValuesSX,SYVariable to receive the magnification
ExamplesSPSCALE 45 OUT SX,SY
SPCOLOR (1)Sets the display color of a sprite
If used before SPSET, an error will occur
FormatSPCOLOR Management number, Color code
ArgumentsManagement numberManagement number of the target sprite: 0-511
Color code 32-bit color code in the ARGB=8888 format
- The lower the value of A, the higher the transparency level
- The actual display color will be the color code multiplied by the original pixel color
ExamplesSPCOLOR 1,RGB(16, 255,0,0) 'A=16,R=255,G=0,B=0
SPCOLOR (2)Gets the display color of a sprite
If used before SPSET, an error will occur
FormatSPCOLOR Management number OUT C32
ArgumentsManagement numberManagement number of the target sprite: 0-511
Return ValuesC32Variable that returns the current color code (32-bit ARGB)
ExamplesSPCOLOR 1 OUT C
SPCHR (1)Changes the character definition of a sprite (using the specified template)
If used before SPSET, an error will occur
FormatSPCHR Management number, Definition number
ArgumentsManagement numberManagement number of the sprite to change the definition of: 0-511
Definition numberDefinition number of the template registered using the SPDEF instruction: 0-4095
ExamplesSPCHR 0,500
SPCHR (2)Changes the character definition of a sprite (using a definition specified directly)
- Arguments other than the management number can be omitted
- If used before SPSET, an error will occur
FormatSPCHR Management number,[U],[V],[W],[H],[Attribute]
ArgumentsManagement numberManagement number of the target sprite: 0-511
U,VCoordinates of the original image to define (U: 0-511, V: 0-511)
W,H Size of the original image to define (If omitted: 16,16)
* U+W and/or V+H values bigger than 512 will give an error
Attribute|b00| Display (0=OFF, 1=ON) #SPSHOW
|b01| ↑Rotation by 90 degrees (Specified with two bits: b01 and b02)
|b02| ↓#SPROT0, #SPROT90, #SPROT0180, #SPROT270
|b03| Horizontal inversion (0=OFF, 1=ON), #SPREVH
|b04| Vertical inversion (0=OFF, 1=ON), #SPREVV
|b05| Additive synthesis (0=OFF, 1=ON), #SPADD

If omitted, 0x01 (Only display is set to ON)
ExamplesSPCHR 5,64,64,16,16,1
SPCHR 6,,,32,32,1 'UV skip
SPCHR (3)Gets information on the character definition of a sprite
If used before SPSET, an error will occur
FormatSPCHR Management number OUT U,V [,W,H [,A] ]
ArgumentsManagement numberManagement number of the target sprite: 0-511
Return ValuesU,VVariables to store the coordinates of the original image
W,HVariables to store the size of the original image
AVariables to store the attribute
ExamplesSPCHR 5 OUT U,V,W,H,ATR
SPCHR (4)Gets the character definition number of a sprite
If used before SPSET, an error will occur
FormatSPCHR Management number OUT DEFNO
ArgumentsManagement numberManagement number of the target sprite: 0-511
Return ValuesDEFNO Variable to receive the definition number
ExamplesSPCHR 5 OUT DEFNO
SPLINKLinks one sprite to another sprite
- Only the coordinates will be linked (The rotation angle and magnification information will not)
- Only a sprite with a lower management number can be specified as the link destination (parent)
- The display coordinates of the child will be determined in relation to the parent
- In this coordinate system, the top left corner of the screen will not be the origin
- There are no restrictions on link hierarchies
- If used before SPSET, an error will occur
FormatSPLINK Management number, Link destination management number
ArgumentsManagement numberManagement number of the link source (child) sprite: 0-511
Link destination management numberManagement number of the link destination (parent) sprite: 0-511
* Management numbers that are not lower than that of the link source will give errors.
ExamplesSPLINK 15,4
SPUNLINKUnlinks a sprite
If used before SPSET, an error will occur
FormatSPUNLINK Management number
ArgumentsManagement numberManagement number of the sprite to unlink: 0-511
ExamplesSPUNLINK 15
SPANIM (1)Displays animation with a sprite (using animation data specified with an array)
If used before SPSET, an error will occur
- Animation waits for a specified time, according to the value input
- Animation starts from the frame following SPANIM execution
- Up to 32 pieces of data will be accepted for each target element
- If a negative value is specified for time, linear interpolation from the previous value will occur
FormatSPANIM Management number,"Animation target",Data array [,Loop]
ArgumentsManagement numberManagement number of the sprite for which to set the animation: 0-511
Animation targetNumerical value or character string to control the elements that should change
- 0 or "XY": XY-coordinates
- 1 or "Z": Z-coordinates
- 2 or "UV": UV-coordinates (Coordinates of the definition source image)
- 3 or "I": Definition number
- 4 or "R": Rotation angle
- 5 or "S": Magnification XY
- 6 or "C": Display color
- 7 or "V": Variable (Value of sprite internal variable 7)
- Adding 8 to the target numerical value will cause the value to be treated as being relative to the run time
- Suffixing the character string with "+" will also cause the value to be treated as being relative to the run time
Data array One-dimensional numerical value array storing the animation data
Loop Loop count: (1-) The value 0 specifies an endless loop
Data ArraysAnimation data should be provided in a numerical value array in the following order (Up to 32 pieces of data):
Time 1, Item 1,[Item2,] Time 2,Item 1,[Item 2,]…
ExamplesDIM PANIM[ 6 ]
PANIM[0] = -60 'frame(-60=smooth)
PANIM[1] = 200 'offset X,Y
PANIM[2] = 100
PANIM[3] = -30 'frame
PANIM[4] = 50 'offset
PANIM[5] = 20
SPSET 0,0
SPANIM 0,"XY",PANIM
SPANIM (2)Displays animation with a sprite (using animation data specified with the DATA instruction)
If used before SPSET, an error will occur
- Animation waits for a specified time, according to the value input
- Animation starts from the frame following SPANIM execution
- Up to 32 pieces of data will be accepted for each target element
- If a negative value is specified for time, linear interpolation from the previous value will occur
FormatSPANIM Management number,"Animation target","@Label string" [,Loop]
ArgumentsManagement numberManagement number of the sprite for which to set the animation: 0-511
Animation targetNumerical value or character string to control the elements that should change
- 0 or "XY": XY-coordinates
- 1 or "Z": Z-coordinates
- 2 or "UV": UV-coordinates (Coordinates of the definition source image)
- 3 or "I": Definition number
- 4 or "R": Rotation angle
- 5 or "S": Magnification XY
- 6 or "C": Display color
- 7 or "V": Variable (Value of sprite internal variable 7)
- Adding 8 to the target numerical value will cause the value to be treated as being relative to the run time
- Suffixing the character string with "+" will also cause the value to be treated as being relative to the run time
@Label string - First label of the DATA instruction storing the animation data
- This should be specified as a character string by enclosing the @Label name in "" (or as a string variable)
LoopLoop count: (1-) The value 0 specifies an endless loop
DataAnimation data should be provided in the DATA instruction in the following order:
DATA Number of key frames (maximum: 32)
DATA Time 1,Item 1[,Item 2]
DATA Time 2,Item 1[,Item 2]
  :
Examples@MOVDATA
DATA 2 'counter
DATA -60,200,100 'frame,offset
DATA -30,50,20 'frame,offset
SPSET 0,0
SPANIM 0,"XY","@MOVDATA"
SPANIM (3)Displays animation with a sprite (using animation data specified directly as arguments)
If used before SPSET, an error will occur
- Animation waits for a specified time, according to the value input
- Animation starts from the frame following SPANIM execution
- Up to 32 pieces of data will be accepted for each target element
- If a negative value is specified for time, linear interpolation from the previous value will occur
FormatSPANIM Management number,"Animation target",Time 1,Item 1[,Item 2] [,Time 2,Item 1[,Item 2]]… [,Loop]
ArgumentsManagement numberManagement number of the sprite for which to set the animation: 0-511
Animation targetNumerical value or character string to control the elements that should change
- 0 or "XY": XY-coordinates
- 1 or "Z": Z-coordinates
- 2 or "UV": UV-coordinates (Coordinates of the definition source image)
- 3 or "I": Definition number
- 4 or "R": Rotation angle
- 5 or "S": Magnification XY
- 6 or "C": Display color
- 7 or "V": Variable (Value of sprite internal variable 7)
- Adding 8 to the target numerical value will cause the value to be treated as being relative to the run time
- Suffixing the character string with "+" will also cause the value to be treated as being relative to the run time
Time,Item - Animation data itself (As many Time/Item sets as needed should be listed. Maximum: 32)
LoopLoop count: (1-) The value 0 specifies an endless loop
ExamplesSPSET 0,0
SPANIM 0,"XY", -60,200,100, -30,50,20
SPSTOPStops animation of a sprite
If used before SPSET, an error will occur
FormatSPSTOP [Management number]
ArgumentsManagement numberManagement number of the target sprite: 0-511
* If the management number is omitted, animation of all sprites will be stopped.
ExamplesSPSTOP
SPSTARTStarts animation of a sprite
(If used before SPSET, an error will occur)
FormatSPSTART [Management number]
ArgumentsManagement numberManagement number of the target sprite: 0-511
* If the management number is omitted, animation of all sprites will be started.
ExamplesSPSTART
SPCHKGets the animation status of a sprite
If used before SPSET, an error will occur
FormatVariable=SPCHK( Management number )
ArgumentsManagement numberManagement number of the target sprite: 0-511
Return Values|b00| XY-coordinates (1), #CHKXY
|b01| Z-coordinates (2), #CHKZ
|b02| UV-coordinates (4), #CHKUV
|b03| Definition number (8), #CHKI
|b04| Rotation (16), #CHKR
|b05| Magnification XY (32), #CHKS
|b06| Display color (64), #CHKC
|b07| Variable (128), #CHKV

For each bit, a target is assigned (If 0 is assigned for all bits, animation is being stopped)
ExamplesST=SPCHK(5)
'|b00|#CHKXY
'|b01|#CHKZ
'|b02|#CHKUV
'|b03|#CHKI
'|b04|#CHKR
'|b05|#CHKS
'|b06|#CHKC
'|b07|#CHKV
SPVAR (1)Writes to a sprite internal variable
- Sprite internal variables (Each sprite has eight variables that the user can use)
- Can also be used before SPSET (When SPSET is executed, all eight variables will be 0)
FormatSPVAR Management number,Internal variable number,Numerical data
ArgumentsManagement numberManagement number of the target sprite: 0-511
Internal variable numberNumber of the internal variable: 0-7
Numerical value Numerical value to register with the internal variable (0-
ExamplesSPVAR 0,7,1
SPVAR (2)Reads a sprite internal variable (Function type)
- Sprite internal variables (Each sprite has eight variables that the user can use)
- Can also be used before SPSET (When SPSET is executed, all eight variables will be 0)
FormatVariable=SPVAR( Management number,Internal variable number )
ArgumentsManagement numberManagement number of the target sprite: 0-511
Internal variable numberNumber of the internal variable: 0-7
Return ValuesValue written with SPVAR
ExamplesV=SPVAR(54,0)
SPVAR (3)Reads a sprite internal variable
- Sprite internal variables (Each sprite has eight variables that the user can use)
- Can also be used before SPSET (When SPSET is executed, all eight variables will be 0)
FormatSPVAR Management number,Internal variable number OUT V
ArgumentsManagement numberManagement number of the target sprite: 0-511
Internal variable numberNumber of the internal variable: 0-7
Return ValuesV Numerical value variable that returns the value of the internal variable
ExamplesSPVAR 54,0 OUT V
SPCOL (1)Sets sprite collision detection information
- Must be called before any SPHIT instruction is used
- SPCOLVEC should also be called
- If used before SPSET, an error will occur
FormatSPCOL Management number [,Scale adjustment]
ArgumentsManagement numberManagement number of the target sprite: 0-511
Scale adjustmentFALSE = Ignores this specification (If omitted = FALSE)
TRUE = Synchronizes the detection area with SPSCALE
* This specification will be effective for SPSCALE instructions set after the SPCOL instruction.
ExamplesSPCOL 3,TRUE
SPCOL (2)Sets sprite collision detection information (including mask specification)
- Must be called before any SPHIT instruction is used
- SPCOLVEC should also be called
- If used before SPSET, an error will occur
FormatSPCOL Management number,[Scale adjustment],Mask
ArgumentsManagement numberManagement number of the target sprite: 0-511
Scale adjustmentFALSE = Ignores this specification (If omitted = FALSE)
TRUE = Synchronizes the detection area with SPSCALE
* This specification will be effective for SPSCALE instructions set after the SPCOL instruction.
Mask 0 - &HFFFFFFFF (32 bits)
* For collision detection, the AND of the bits is determined,
  and if it is 0, it is regarded as no collision (If omitted, &HFFFFFFFF).
ExamplesSPCOL 3,TRUE,31
SPCOL 3,,31
SPCOL (3)Sets sprite collision detection information (including range specification)
- Must be called before any SPHIT instruction is used
- SPCOLVEC should also be called
- If used before SPSET, an error will occur
FormatSPCOL Management number,Start point X,Start point Y,Width,Height,[Scale adjustment],Mask
ArgumentsManagement numberManagement number of the target sprite: 0-511
Start point X,Y- Start point coordinates of the detection area: X,Y (-32768 to 32767)
- Relative coordinates with SPHOME as the origin (0,0)
Width,Height   Width and height of the detection area: W,H (0-65535)
Scale adjustmentFALSE = Ignores this specification (If omitted = FALSE)
TRUE = Synchronizes the detection area with SPSCALE
* This specification will be effective for SPSCALE instructions set after the SPCOL instruction.
Mask0 - &HFFFFFFFF (32 bits)
* For collision detection, the AND of the bits is determined,
  and if it is 0, it is regarded as no collision (If omitted, &HFFFFFFFF).
ExamplesSPCOL 3,0,0,32,32,TRUE,255
SPCOL 3,0,0,32,32,,255
SPCOL (4)Gets sprite collision detection information (scale adjustment and mask)
If used before SPSET, an error will occur
FormatSPCOL Management number OUT Scale adjustment [,Mask]
ArgumentsManagement numberManagement number of the target sprite: 0-511
Return ValuesScale adjustmentVariable to receive the scale value
Mask Variable to receive the mask value
ExamplesSPCOL 3 OUT SC,MSK
SPCOL (5)Gets sprite collision detection information (range)
If used before SPSET, an error will occur
FormatSPCOL Management number OUT Start point X,Start point Y,Width,Height
ArgumentsManagement numberManagement number of the target sprite: 0-511
Return ValuesStart point X,YVariables to receive the start point coordinates of the detection area
Width,Height Variables to receive the width and height of the detection area
ExamplesSPCOL 3 OUT X,Y,W,H
SPCOL (6)Gets sprite collision detection information (range and scale adjustment)
If used before SPSET, an error will occur
FormatSPCOL Management number OUT Start point X,Start point Y,Width,Height,Scale adjustment
ArgumentsManagement numberManagement number of the target sprite: 0-511
Return ValuesStart point X,YVariables to receive the start point coordinates of the detection area
Width,HeightVariables to receive the width and height of the detection area
Scale adjustmentVariable to receive the scale value
ExamplesSPCOL 3 OUT X,Y,W,H,SC
SPCOL (7)Gets sprite collision detection information (all information)
If used before SPSET, an error will occur
FormatSPCOL Management number OUT Start point X,Start point Y,Width,Height,Scale adjustment,Mask
ArgumentsManagement numberManagement number of the target sprite: 0-511
Return ValuesStart point X,Y Variables to receive the start point coordinates of the detection area
Width,Height Variables to receive the width and height of the detection area
Scale adjustment Variable to receive the scale value
Mask Variable to receive the mask value
ExamplesSPCOL 3 OUT X,Y,W,H,SC,MSK
SPCOLVECSets a movement speed for sprite collision detection
- It is recommended to also call this instruction when setting SPCOL
- If used before SPSET, an error will occur
FormatSPCOLVEC Management number [,Movement amount X,Movement amount Y]
ArgumentsManagement numberManagement number of the target sprite: 0-511
Movement amount X,Movement amount Y- If omitted, the amount will be automatically calculated as follows:
- When linear interpolation of "XY" in SPANIM is being performed: Movement distance from the previous frame
- Otherwise: 0,0
ExamplesSPCOLVEC 93
SPHITSP (1)Detects sprite collision
- SPCOL and SPCOLVEC should be called beforehand
- If used before SPSET, an error will occur
FormatVariable = SPHITSP( Management number [,First ID,Last ID] )
ArgumentsManagement numberManagement number of the sprite to detect collision with: 0-511
First ID,Last IDRange of sprites to detect (0-511)
Return ValuesManagement number of the colliding sprite (When no collision, -1)
ExamplesH=SPHITSP(0)
SPHITSP (2)Detects sprite collision: collision between the specified sprites
- SPCOL and SPCOLVEC should be called beforehand
- If used before SPSET, an error will occur
FormatVariable = SPHITSP( Management number ,Opponent management number )
ArgumentsManagement numberManagement number of the sprite to detect collision with: 0-511
Opponent management numberManagement number of the opponent sprite: 0-511
Return ValuesFALSE = No collision, TRUE = Collision
ExamplesH=SPHITSP( 0,34 )
SPHITRC (1)Detects collision between a moving quadrangle and any sprite
- SPCOL and SPCOLVEC should be called beforehand
- If used before SPSET, an error will occur
FormatSPHITRC( Start point X,Start point Y,Width,Height[,[Mask],Movement amount X,Movement amount Y] )
ArgumentsStart point X,YTop left coordinates of the quadrangle to detect collision with
Width,HeightWidth and height of the quadrangle to detect collision with
Mask 0 - &HFFFFFFFF (32 bits)
* For collision detection, the AND of the bits is determined,
  and if it is 0, it is regarded as no collision (If omitted, &HFFFFFFFF).
Movement amount X,YMovement amount of the quadrangle to detect collision with
Return ValuesManagement number of the colliding sprite (When no collision, -1)
ExamplesH=SPHITRC( 0,0,16,16 )
SPHITRC (2)Detects collision between the specified sprite and a quadrangle
- SPCOL and SPCOLVEC should be called beforehand
- If used before SPSET, an error will occur
FormatSPHITRC( Management number,Start point X,Start point Y,Width,Height[,[Mask],Movement amount X,Movement amount Y] )
ArgumentsManagement numberManagement number of the collision opponent sprite: 0-511
Start point X,YTop left coordinates of the quadrangle to detect collision with
Width,Height Width and height of the quadrangle to detect collision with
Mask0 - &HFFFFFFFF (32 bits)
* For collision detection, the AND of the bits is determined,
  and if it is 0, it is regarded as no collision (If omitted, &HFFFFFFFF).
Movement amount X,YMovement amount of the quadrangle to detect collision with
Return ValuesFALSE = No collision, TRUE = Collision
ExamplesH=SPHITRC( 1,0,0,16,16 )
SPHITRC (3)Detects collision between the specified range of sprites and a quadrangle
- SPCOL and SPCOLVEC should be called beforehand
- If used before SPSET, an error will occur
FormatSPHITRC( First ID,Last ID, Start point x,Start point y,Width,Height[,[Mask],Movement amount X, Movement amount Y] )
ArgumentsFirst ID,Last IDRange of sprites to detect (0-511)
Start point X,YTop left coordinates of the quadrangle to detect collision with
Width,HeightWidth and height of the quadrangle to detect collision with
Mask0 - &HFFFFFFFF (32 bits)
* For collision detection, the AND of the bits is determined,
  and if it is 0, it is regarded as no collision (If omitted, &HFFFFFFFF).
Movement amount X,YMovement amount of the quadrangle to detect collision with
Return ValuesManagement number of the colliding sprite (When no collision, -1)
ExamplesH=SPHITRC( 0,0,16,16 )
SPHITINFO (1)Gets information on collision detection results (Time of collision)
If used before SPSET, an error will occur
FormatSPHITINFO OUT TM
ArgumentsNone
Return ValuesTM - Variable that returns time of collision: real-type number from 0 to 1
- Position at collision detection + speed x collision time = collision X-Y coordinates
ExamplesSPHITINFO OUT TM
SPHITINFO (2)Gets information on collision detection results (Time of collision and coordinates)
If used before SPSET, an error will occur
FormatSPHITINFO OUT TM,X1,Y1,X2,Y2
ArgumentsNone
Return ValuesTM- Variable that returns time of collision: real-type number from 0 to 1
- Position at collision detection + speed x collision time = collision X-Y coordinates
X1,Y1 Variable that returns the X-Y coordinates of object 1 at the time of collision
X2,Y2 Variable that returns the X-Y coordinates of object 2 at the time of collision
ExamplesSPHITINFO OUT TM,X1,Y1,X2,Y2
SPHITINFO (3)Gets information on collision detection results (Time of collision, coordinates and speed)
If used before SPSET, an error will occur
FormatSPHITINFO OUT TM,X1,Y1,VX1,VY1,X2,Y2,VX2,VY2
ArgumentsNone
Return ValuesTime of collision- Variable that returns time of collision: real-type number from 0 to 1
- Position at collision detection + speed x collision time = collision X-Y coordinates
X1,Y1 Variable that returns the X-Y coordinates of object 1 at the time of collision
VX1,VY1Variable that returns the speed of object 1 at the time of collision
X2,Y2Variable that returns the X-Y coordinates of object 2 at the time of collision
VX2,VY2Variable that returns the speed of object 2 at the time of collision
ExamplesSPHITINFO OUT TM,X1,Y1,VX1,VY1,X2,Y2,VX2,VY2
SPFUNCAssigns a process to a sprite
- An instruction for advanced users that is used when callback processing is required
- All sprite processes are executed with CALL sprite
- Instead of @Label, a user process defined using DEF can also be specified
- At the processing target, the management number can be obtained using the CALLIDX system variable
- If used before SPSET, an error will occur
FormatSPFUNC Management number, @Label
ArgumentsManagement numberManagement number of the target sprite: 0-511
@LabelLabel of the processing target (or a user-defined process) to be called
ExamplesSPFUNC 0,@PROG
SPUSEDChecks if the specified sprite is in use
FormatVariable=SPUSED(Management number)
ArgumentsManagement numberManagement number of the target sprite: 0-511
Return ValuesTRUE = In use, FALSE = Available
ExamplesS=SPUSED(4)

BG

Functions for displaying tiled 16x16-pixel rectangular images

BGPAGE (1)Sets a graphic page to assign to BG
FormatBGPAGE Graphic page
ArgumentsGraphic page0-5 (GRP0-GRP5) By default, the graphic page for BG is 5 (GRP5)
ExamplesBGPAGE 5
BGPAGE (2)Gets the graphic page that has been assigned to BG
FormatVariable=BGPAGE()
Return ValuesGraphic page number (0-5)
ExamplesP=BGPAGE()
BGSCREENSets the BG screen size per layer
FormatBGSCREEN Layer,Width,Height
ArgumentsLayerTarget layer number: 0-3
Width,Height- Width and height in character units (Width x Height should be equal to or less than 16383)
- Initial state: 25 x 15 (Right size to fill the upper screen with BG)
ExamplesBGSCREEN 0,128,127
BGCLRClears the BG screen
FormatBGCLR [Layer]
ArgumentsLayerTarget layer number: 0-3 (If omitted, all layers)
ExamplesBGCLR
BGSHOWShows the BG screen
FormatBGSHOW Layer
ArgumentsLayerTarget layer number: 0-3
ExamplesBGSHOW 0
BGHIDEHides the BG screen
FormatBGHIDE Layer
ArgumentsLayerTarget layer number: 0-3
ExamplesBGHIDE 0
BGCLIPSpecifies the display area of the BG screen
FormatBGCLIP Layer [,Starting point X,Starting point Y,End point X,End point Y]
ArgumentsLayerTarget layer number: 0-3
Start point X,YStart point coordinates (in pixels) of the display area
End point X,Y- End point coordinates (in pixels) of the display area
- If the start and end points are omitted, the whole layer will be the display area
ExamplesBGCLIP 0,20,20,379,219
BGHOME (1)Sets the display origin of a layer
- Origin for rotation and scaling of the BG screen
FormatBGHOME Layer,Position X,Position Y
ArgumentsLayer  Target layer number: 0-3
Position X,YOrigin coordinates in pixel units
ExamplesBGHOME 0,200,120
BGHOME (2)Gets the display origin of a layer
FormatBGHOME Layer OUT HX,HY
ArgumentsLayerTarget origin number: 0-3
Return ValuesHX,HYVariables to receive the coordinates of the reference point
ExamplesBGHOME 0 OUT HX,HY
BGOFS (1)Changes the display offset of the BG screen
FormatBGOFS Layer,X,Y,[Z]
ArgumentsLayerTarget layer number: 0-3
X,YDisplay offset coordinates in pixels
ZCoordinate in the depth direction (Rear:1024 < Screen surface:0 < Front:-256)
ExamplesBGOFS 0,-100,-100
BGOFS (2)Gets BG coordinates
FormatBGOFS Layer OUT X,Y[,Z]
ArgumentsLayerTarget layer number: 0-3
Return ValuesX,YVariables to receive the coordinates
ZVariable to receive the depth information
ExamplesBGOFS 0 OUT X,Y,Z
BGROT (1)Rotates the BG screen
FormatBGROT Layer,Angle
ArgumentsLayerTarget layer number: 0-3
AngleRotation angle (clockwise): 0-360
ExamplesBGROT 0,180
BGROT (2)Gets rotation information from the BG screen
FormatBGROT Layer OUT R
ArgumentsLayerTarget layer number: 0-3
Return ValuesAngleR: 0-360
ExamplesBGROT 0 OUT R
BGSCALE (1)Scales the BG screen
- When scaled down, BGs exceeding 3600 in total will not be displayed
- If this display limit is exceeded, the BG screen will be distorted
FormatBGSCALE Layer,Enlargement scale X,Enlargement scale Y
ArgumentsLayerTarget layer number: 0-3
Enlargement scale X,Y0.5 (50%) - 1.0 (100%) - 2.0(200%) -
ExamplesBGSCALE 0,1.5,2.0
BGSCALE (2)Gets scale-up/down information from the BG screen
FormatBGSCALE Layer OUT SX,SY
ArgumentsLayerTarget layer number: 0-3
Return ValuesSX,SY0.5 (50%) - 1.0 (100%) - 2.0(200%) -
ExamplesBGSCALE 0 OUT SX,SY
BGPUTPlaces a BG character on the BG screen
No image will be displayed for character number 0
FormatBGPUT Layer,X,Y,Screen data
ArgumentsLayerTarget layer number: 0-3
X,YCoordinates to place the character at (0 - the value specified with BGSCREEN minus 1)
Screen Data|b00| ↑
|   | Character number (0-4095, repeated at the cycle of 1024)
|b11| ↓
|b12| ↑Rotation by 90 degrees (Specified with two bits: b12 and b13)
|b13| ↓[ 00 = 0 degrees, 01 = 90 degrees, 10 = 180 degrees, 11 = 270 degrees ]
|b14| Horizontal inversion (0=OFF, 1=ON)
|b15| Vertical inversion (0=OFF, 1=ON)

- 16-bit numerical value that specifies the character number and the rotation information
- A 4-digit hexadecimal string can also be specified ("0000"-"FFFF")
ExamplesBGPUT 0,0,0,5
BGPUT 0,20,15,"80FF"
BGFILLFills the BG screen with a BG character
FormatBGFILL Layer,Start point X,Start point Y,End point X,End point Y,Screen data
ArgumentsLayerTarget layer number: 0-3
Start point X,YStart point coordinates (Each coordinate: 0 - the value specified with the BGSCREEN instruction minus 1)
End point X,YEnd point coordinates (Each coordinate: 0 - the value specified with the BGSCREEN instruction minus 1)
Screen Data|b00| ↑
|  | Character number (0-4095, repeated at the cycle of 1024)
|b11| ↓
|b12| ↑Rotation by 90 degrees (Specified with two bits: b12 and b13)
|b13| ↓[ 00 = 0 degrees, 01 = 90 degrees, 10 = 180 degrees, 11 = 270 degrees ]
|b14| Horizontal inversion (0=OFF, 1=ON)
|b15| Vertical inversion (0=OFF, 1=ON)

- 16-bit numerical value that specifies the character number and the rotation information
- A 4-digit hexadecimal string can also be specified ("0000"-"FFFF")
ExamplesBGFILL 0,0,0,19,15,1024
BGFILL 0,5,5,10,10,"C040"
BGGETGets information on a BG character on the BG screen
FormatVariable=BGGET( Layer, X, Y [,Coordinate system flag] )
ArgumentsLayerTarget layer number: 0-3
X,YCoordinates to get the BG character from (Coordinate values differ depending on the coordinate system flag described below)
Coordinate system flag (If omitted, 0)0: Treats X-, Y-coordinates as the BG screen coordinates (in character units)
1: Treats X-, Y-coordinates as the screen coordinates (in pixel units)
Return Values|b00| ↑
|  | Character number (0-4095, repeated at cycles of 1024)
|b11| ↓
|b12| ↑Rotation by 90 degrees (Specified with two bits: b12 and b13)
|b13| ↓#BGROT0, #BGROT90, #BGROT0180, #BGROT270
|b14| Horizontal inversion (0=OFF, 1=ON), #BGREVH
|b15| Vertical inversion (0=OFF, 1=ON), #BGREVV

Screen data
ExamplesC=BGGET(0,12,14)
BGANIM (1)Displays animation with BG (using animation data specified with an array)
- Animation waits for a specified time, according to the value input
- Animation starts from the frame following BGANIM
- Up to 32 pieces of data will be accepted for each target element
- If a negative value is specified for time, linear interpolation from the previous value will occur
FormatBGANIM Layer,"Animation target",Data array [,Loop]
ArgumentsLayerNumber of the layer for which to set the animation: 0-3
Animation targetNumerical value or character string to control the elements that should change
- 0 or "XY": XY-coordinates
- 1 or "Z": Z-coordinates
- 4 or "R": Rotation angle
- 5 or "S": Magnification XY
- 6 or "C": Display color
- 7 or "V": Variable (Value of BG internal variable 7)
- Adding 8 to the target numerical value will cause the value to be treated as being relative to the run time
- Suffixing the character string with "+" will also cause the value to be treated as being relative to the run time
Data arrayOne-dimensional numerical value array storing the animation data
LoopLoop count: (1-) The value 0 specifies an endless loop
Data Arrays Animation data should be provided in a numerical value array in the following order (Up to 32 pieces of data):
Time 1, Item 1,[Item2,] Time 2,Item 1,[Item 2,]…
ExamplesDIM PANIM[ 6 ]
PANIM[0] = -60 'frame(-60=smooth)
PANIM[1] = 200 'offset X,Y
PANIM[2] = 100
PANIM[3] = -30 'frame
PANIM[4] = 50 'offset
PANIM[5] = 20
BGANIM 0,"XY",PANIM
BGANIM (2)Displays animation using the BG (Specifying animation data with the DATA instruction)
- Animation waits for a specified time, according to the value input
- Animation starts from the frame following BGANIM
- Up to 32 pieces of data will be accepted for each target element
- If a negative value is specified for time, linear interpolation from the previous value will occur
FormatBGANIM Layer,"Animation target","@Label string" [,Loop]
ArgumentsLayerNumber of the layer for which to set the animation: 0-3
Animation targetNumerical value or character string to control the elements that should change
- 0 or "XY": XY-coordinates
- 1 or "Z": Z-coordinate
- 4 or "R": Rotation angle
- 5 or "S": Magnification XY
- 6 or "C": Display color
- 7 or "V": Variable (Value of BG internal variable 7)
- Adding 8 to the target numerical value will cause the value to be treated as being relative to the run time
- Suffixing the character string with "+" will also cause the value to be treated as being relative to the run time
@Label string- First label of the DATA instruction storing the animation data
- This should be specified as a character string by enclosing the @Label name in " (or as a string variable)
LoopLoop count: (1-) The value 0 specifies an endless loop
Data Animation data should be provided in the DATA instruction in the following order:
DATA Number of key frames (maximum: 32)
DATA Time 1,Item 1[,Item 2]
DATA Time 2,Item 1[,Item 2]
  :
Examples@MOVDATA
DATA 2 'counter
DATA -60,200,100 'frame,offset
DATA -30,50,20 'frame,offset
BGANIM 0,"XY","@MOVDATA"
BGANIM (3)Displays animation using the BG (Specifying animation data with arguments directly)
- Animation waits for a specified time, according to the value input
- Animation starts from the frame following BGANIM
- Up to 32 pieces of data will be accepted for each target element
- If a negative value is specified for time, linear interpolation from the previous value will occur
FormatBGANIM Layer,"Animation target",Time 1,Item 1[,Item 2] [,Time 2,Item 1[,Item 2]]… [,Loop]
ArgumentsLayerNumber of the layer for which to set the animation: 0-3
Animation targetNumerical value or character string to control the elements that should change
- 0 or "XY": XY-coordinates
- 1 or "Z": Z-coordinate
- 4 or "R": Rotation angle
- 5 or "S": Magnification XY
- 6 or "C": Display color
- 7 or "V": Variable (Value of BG internal variable 7)
- Adding 8 to the target numerical value will cause the value to be treated as relative to the run time
- Suffixing the character string with "+" will also cause the value to be treated as relative to the run time/td>
Time, Item- Animation data itself (Up to 32 necessary data items can be listed)
LoopLoop count: (1-) The value 0 specifies an endless loop
ExamplesBGANIM 0,"XY", -60,200,100, -30,50,20
BGSTOPStops BG animation
FormatBGSTOP [Layer]
ArgumentsLayerTarget layer number: 0-3
* If the layer is omitted, animation of all layers will be stopped.
ExamplesBGSTOP
BGSTARTStarts BG animation
FormatBGSTART [Layer]
ArgumentsLayerTarget layer number: 0-3
* If the layer is omitted, animation of all layers will be started.
ExamplesBGSTART
BGCHKGets BG animation status
FormatVariable=BGCHK( Layer )
ArgumentsLayerNumber of the layer to check: 0-3
Return Values|b00| XY-coordinates (1), #CHKXY
|b01| Z-coordinate (2), #CHKZ
|b02|
|b03|
|b04| Rotation (16), #CHKR
|b05| Magnification XY (32), #CHKS
|b06| Display color (64), #CHKC
|b07| Variable (128), #CHKV

A target is assigned for each bit (If 0 is assigned for all bits, animation is being stopped)
ExamplesST=BGCHK(0)
'|b00|#CHKXY
'|b01|#CHKZ
'|b04|#CHKR
'|b05|#CHKS
'|b06|#CHKC
'|b07|#CHKV
BGVAR (1)Writes to a BG internal variable
User variables; there are eight variables for each BG layer
FormatBGVAR Layer,Internal variable number,Numerical value
ArgumentsLayerTarget layer number: 0-3
Internal variable numberNumber of the internal variable: 0-7
Numerical valueNumerical value to register with the internal variable
ExamplesBGVAR 0,7,1
BGVAR (2)Reads a BG internal variable (function type)
User variables; there are eight variables for each BG layer
FormatVariable=BGVAR( Layer number,Internal variable number )
ArgumentsLayerTarget layer number: 0-3
Internal variable numberNumber of the internal variable: 0-7
Return ValuesValue written with BGVAR
ExamplesV=BGVAR(0,5)
BGVAR (3)Reads a BG internal variable
- User variables; there are eight variables for each BG layer
FormatBGVAR Layer,Internal variable number OUT V
ArgumentsLayerTarget layer number: 0-3
Internal variable numberNumber of the internal variable: 0-7
Return ValuesVNumerical value variable that returns the value of the internal variable
ExamplesBGVAR 0,5 OUT V
BGCOPYCopies from the BG screen in character units
FormatBGCOPY Layer,Start point X,Start point Y, End point X,End point Y, Transfer destination X,Transfer destination Y
ArgumentsLayerTarget layer number: 0-3
Start point X,Y End point X,YStart and End point coordinates of the copy source (0 - the value specified with BGSCREEN minus 1)
Transfer destination X,YStart point coordinates of the copy destination (0 - the value specified with BGSCREEN minus 1)
ExamplesBGCOPY 2,0,0,32,32,0,0
BGLOADCopies BG data from an array to the BG screen
FormatBGLOAD Layer, [Start point X,Start point Y,Width,Height,] Numerical value array
ArgumentsLayerLayer number of the copy destination range: 0-3
Start point X,Start point YStart point coordinates (character coordinates) of the copy destination range
Width, Height- Width and height (in character units) of the copy destination range
- If the range specification is omitted, the whole BG screen will be the display area.
Numerical value arrayNumerical value array containing the BG data stored with BGSAVE
ExamplesBGLOAD 0, 0,0,30,10, BGARRAY
BGSAVECopies the contents of the BG screen to a numerical value array
FormatBGSAVE Layer, [Start point X,Start point Y,Width,Height,] Numerical value array
ArgumentsLayerLayer number of the copy source: 0-3
Start point X,Start point YStart point coordinates (character coordinates) of the copy source range
Width, Height- Width and height (in character units) of the copy source range
- If the range specification is omitted, the whole BG screen will be the display area
Numerical value array- Numerical value array to which to copy the data
- For one-dimensional arrays only, if the array is insufficient, the required element(s) will be added automatically
ExamplesDIM BGARRAY[30*10]
BGSAVE 0, 0,0,30,10, BGARRAY
BGCOORDConverts display coordinates to BG screen coordinates, or vice versa
FormatBGCOORD Layer,Source X-coordinate,Source Y-coordinate[,Mode]OUT DX,DY
ArgumentsLayerLayer number: 0-3
Source X-, Y-coordinatesCoordinates to convert (BG character coordinates or display coordinates)
ModeConversion mode: 0-2
0: Converts BG screen coordinates to display coordinates
1: Converts display coordinates to BG screen coordinates (in character units)
2: Converts display coordinates to BG screen coordinates (in pixel units)
DX,DYVariable to store the converted coordinates (BG character coordinates or display coordinates)
ExamplesBGCOORD 0,BGX,BGY,0 OUT DX,DY
BGCOLOR (1)Sets the BG display color
FormatBGCOLOR Layer, Color code
ArgumentsManagement numberLayer number: 0-3
Color code- 32-bit color code in the ARGB=8888 format
- The RGB function is useful for this specification: RGB( R,G,B )
- Unlike with sprites, the alpha value is not valid (Semitransparent representation is not allowed)
- The actual display color will be the color code multiplied by the original pixel color.
ExamplesBGCOLOR 1,RGB(255,0,0) 'R=255,G=0,B=0
BGCOLOR (2)Gets the BG display color
FormatBGCOLOR Layer OUT C32
ArgumentsLayerLayer number: 0-3
Return ValuesC32Variable that returns the current color code (32-bit ARGB)
ExamplesBGCOLOR 1 OUT C
BGFUNCAssigns a callback process to a BG layer
- An instruction for advanced users that is used when callback processing is required
- All BG layer processes are executed with CALL BG
- Instead of @Label, a user process defined using DEF can also be specified
- At the processing target, a management number can be obtained using a CALLIDX system variable
FormatBGFUNC Layer, @Label
ArgumentsLayerLayer number: 0-3
@LabelThe label of the process target (or a user-defined process)
ExamplesBGFUNC 0,@LAYERSUB0

Sound

Functions for playing back music and sound effects, setting effectors, and generating synthesized voice

BEEPGenerates a simple alarm sound or sound effect
FormatBEEP [Sound effect number][,Frequency][,Volume][,Pan pot]
ArgumentsSound effect number- Type of sound to generate: Preset sound 0-133
- A list of preset sounds can be viewed by pressing the SMILE button
Frequency- Frequency value to change to: -32768 to 32767 (One halftone per 100)
Volume- Volume level for playback: 0-127
Pan pot- Stereo pan pot specification: 0 (Left) - 64 (Center) - 127 (Right)
ExamplesBEEP 20
BGMCHKChecks music playback status
FormatVariable=BGMCHK( [Track number] )
ArgumentsTrack numberTrack number: 0-7 (If omitted, 0)
Return ValuesFALSE = Stopped, TRUE = Playing
ExamplesRET=BGMCHK(0)
BGMCLEARClears a user-defined piece of music
FormatBGMCLEAR [User-defined tune number]
ArgumentsUser-defined tune numberTune number: 128-255 (If omitted, all defined tunes will be cleared)
ExamplesBGMCLEAR
BGMPLAY (1)Plays music (Plays back registered BGM)
- Up to 8 tunes can be played simultaneously (The total maximum number of sounds that can be generated simultaneously is 16)
- See the second page for information on how to play music using MML
FormatBGMPLAY [Track number,] Tune number [,Volume]
ArgumentsTrack numberTrack number to play back: 0-7 (If omitted, number 0)
Tune number- Preset tune: 0-42
- User-defined tune: 128-255
- A list of preset sounds can be viewed by pressing the SMILE button.
VolumeVolume level for playback: 0-127
ExamplesBGMPLAY 0
BGMPLAY (2)Plays music (Plays back the input MML data)
- MML playback is performed in track 0
- The MML tune will overwrite user-defined tune number 255
- Executing immediately after BGMPLAY will cause a delay of approx. 2 frames
FormatBGMPLAY "MML string"
ArgumentsMML string- Pressing the Help button for "MML" will display descriptions of MML commands
- You can register a character string to play by listing the following symbols:

:0 - :15  Channel specification
T1 - T512 Tempo specification
CDEFGAB   Scale (C# is a halftone higher; C- is a halftone lower)
N0 - N127 Key value specification (O4C=60)
1 - 192   Individual tone length specification (C1 = Whole note, C4. = Dotted quarter note)
L1 - L192 Default tone length (. should be used for dotted notes)
R Rest
O0 - O8   Octave number specification
< >     One octave up or down
V0 - V127 Volume level value specification
( )     Volume up or down
@0 - @255 Tone change (0 - 127: Equivalent to GM, 224-: User-defined waveform)
P0 - P127 Pan pot (Left: P0-63 Center: P64 Right: P65-127)
[      Repeat start
]      Number of times Repeat end (If the number of times is omitted, the loop will be endless)
&      Connects the preceding/succeeding notes
_      Portamento
ExamplesBGMPLAY "T120O4L4CC8D8EE8F8GA8G8E2"
BGMSETPredefines a user-defined piece of music
Executing immediately after BGMPLAY will cause a delay of approx. 2 frames
FormatBGMSET User-defined tune number,"MML string"
ArgumentsUser-defined tune numberUser-defined tune number: 128-255
MML string Pressing the Help button for "MML" will display the description of MML commands
ExamplesBGMSET 128,"CDEFG"
BGMSETDPredefines a user-defined tune
- The DATA instruction should be used for internal registration of MML ( DATA "CDEFGAB" )
- The end of DATA is determined according to the numerical value ( DATA 0 )
- Internally, this is handled in the same way as RESTORE
- RESTORE must be used to READ the data after BGMSETD
- Executing immediately after BGMPLAY will cause a delay of approx. 2 frames
FormatBGMSETD User-defined tune number,"@Label string"
ArgumentsUser-defined tune numberUser-defined tune number: 128-255
@Label string- A label string where an MML string has been registered with DATA
- Should be specified by enclosing the string in " or by assigning it to a string variable
- Pressing the Help button for "MML" will display the description of MML commands
ExamplesBGMSETD 128,"@MMLTOP"
BGMVAR (1)Writes to an MML internal variable
FormatBGMVAR Track number, Variable number, Value
ArgumentsTrack numberTarget MML track number: 0-7
Variable numberInternal variable to which to write a value: 0-7 ($0-$7 in MML)
Value Value to write to the variable
ExamplesBGMVAR 0,5,10
BGMVAR (2)Reads an MML internal variable
FormatVariable=BGMVAR(Track number, Variable number )
ArgumentsTrack numberTarget MML track number: 0-7
Variable numberInternal variable from which to read the value: 0-7 ($0-$7 in MML)
Return ValuesContent of the specified variable during playback (When the music is stopped, -1)
ExamplesMC=BGMVAR(0,5)
BGMSTOP (1)Stops playing music
FormatBGMSTOP [Track number [,Fading time]]
ArgumentsTrack numberTarget track number: 0-7 (If omitted, all tracks will be stopped)
Fading timeSeconds (Decimal fractions are allowed; 0 = Stop immediately; if omitted, handled as 0)
ExamplesBGMSTOP
BGMSTOP (2)Stops playing music
- Forces ongoing sounds such as release sounds to stop
- Executing this will cause user-defined BGM 255 to be overwritten
FormatBGMSTOP -1
Arguments-1: Value for forcibly stopping sound
ExamplesBGMSTOP -1
BGMVOLSets the volume for the specified track
FormatBGMVOL [Track number,] Volume
ArgumentsTrack numberTarget track number: 0-7 (If omitted, 0)
VolumeVolume level to set: 0-127
ExamplesBGMVOL 0,64
WAVSETDefines the sound of an MML user-defined musical instrument
FormatWAVSET Definition number,A,D,S,R,"Waveform string" [,Reference pitch]
ArgumentsDefinition number- User-defined musical instrument number: 224-255
- This number is specified with the MML @ command.
A,D,S,REnvelope definition parameters
A: Attack (0-127)
D: Decay (0-127)
S: Sustain (0-127)
R: Release (0-127)
Waveform string- Hexadecimal string
- Two characters represent one sample value (8 bits)
- &H00 - &H80 (128) - &HFF (255)
- 16, 32, 64, 128, 256, or 512 samples can be specified
- The number of characters should be twice the number of samples
Reference pitchIf omitted, 69 (O4A)
ExamplesW$="7F7F7F7FFFFFFFFF7F7F7F7FFFFFFFFF"*4
WAVSET 224,3,10,30,5,W$,69
WAVSETADefines the sound of an MML user-defined musical instrument from an array
- Used for sound definition from an array obtained with MICSAVE
- 8180Hz sampling rate, 8 bits fixed
FormatWAVSETA Definition number,A,D,S,R,Numerical value array [,Reference pitch][,Start subscript][,End subscript]
ArgumentsDefinition number- User-defined musical instrument number: 224-255
- This number is specified with the MML @ command
A,D,S,REnvelope definition parameters
A: Attack (0-127)
D: Decay (0-127)
S: Sustain (0-127)
R: Release (0-127)
Numerical value arrayArray obtained with the MICSAVE instruction (Up to 16384 samples)
Reference pitchIf omitted, 69 (O4A)
Start subscriptSubscript of the element in the numerical value array at which to start reading (If omitted, 0)
End subscriptSubscript of the element in the numerical value array at which to stop reading (If omitted, the last element)
ExamplesWAVSETA 224,0,95,100,20,SMPDATA
EFCOFFTurns off the effector setting
FormatEFCOFF
ExamplesEFCOFF
EFCONTurns on the effector setting
The effect type should be selected with the EFCSET instruction
FormatEFCON
ExamplesEFCON
EFCSET (1)Selects a music effect type
FormatEFCSET Type number
ArgumentsType number0: No effect (Same as EFCOFF)
1: Reverb (Bathroom)
2: Reverb (Cave)
3: Reverb (Space)
ExamplesEFCSET 2
EFCSET (2)Sets effect parameters (For advanced users)
FormatEFCSET Initial reflection time,Reverberation sound delay time,Reverberation sound decay time,Reverberation sound filter coefficient 1,Reverberation sound filter coefficient 2,Initial reflection sound gain,Reverberation sound gain
ArgumentsInitial reflection time0-2000 (msec)
Reverberation sound delay time0-2000 (msec)
Reverberation sound decay time1-10000 (msec)
Reverberation sound filter coefficient 10.0-1.0
Reverberation sound filter coefficient 20.0-1.0
Initial reflection sound gain0.0-1.0
Reverberation sound gain0.0-1.0
ExamplesEFCSET 997,113,1265,0.1,0,0.2,0.1
EFCWETSets the respective effect amounts for BEEP, BGM, and TALK
FormatEFCWET BEEP effect value, BGM effect value, TALK effect value
ArgumentsBEEP effect valueEffect amount for BEEP (0-127)
BGM effect valueEffect amount for BGM (0-127)
TALK effect value- Effect setting for TALK (Less than 64: OFF; 64 or greater: ON)
- For TALK, the only available setting is ON/OFF; the amount does not change
ExamplesEFCWET 0,100,64
TALKGenerates synthesized speech
Alphanumeric symbols are read out character-by-character
FormatTALK "Voice string"
ArgumentsVoice stringSynthesized speech string (Characters will be read out directly)
Special commandsA special command enclosed with <> is available for use in strings
<S Speed>: Speech speed (Speed: 0-65536, default: 32768)
<P Pitch>: Tone pitch (Pitch: 0-65536, default: 32768)
ExamplesTALK "ABCDE<P50000><S20000>FGHIJKLM"
TALKCHKChecks the status of speech synthesis
FormatVariable=TALKCHK()
Return ValuesFALSE = Stopped, TRUE = Playing
ExamplesRET=TALKCHK()
TALKSTOPStops the synthesized speech currently playing
FormatTALKSTOP
ExamplesTALKSTOP

Mathematics

Instructions for mathematical operations including trigonometric functions and logarithms

FLOORGets the integer part (by rounding down to the whole number)
- The largest integer that is not greater than the specified value will be obtained
- FLOOR(12.5) will be 12, while FLOOR(-12.5) will be -13
FormatVariable = FLOOR( Numerical value )
ArgumentsNumerical valueSource numerical value
Return ValuesInteger value after rounding down
See Also ROUND: Round-off, CEIL: Round-up
ExamplesA=FLOOR(12.345)
ROUNDGets the integer part (by rounding off to the nearest whole number)
FormatVariable = ROUND( Numerical value )
ArgumentsNumerical valueSource numerical value
Return ValuesInteger value after rounding off
See Also FLOOR: Round-down, CEIL: Round-up
ExamplesA=ROUND(12.345)
CEILGets the integer part (by rounding up to the whole number)
- The smallest integer that is not less than the specified value will be obtained
- CEIL(12.5) will be 13, while CEIL(-12.5) will be -12
FormatVariable = CEIL( Numerical value )
ArgumentsNumerical valueSource numerical value
Return ValuesInteger value after rounding up
See Also ROUND: Round-off, FLOOR: Round-down
ExamplesA=CEIL(12.345)
ABSGets the absolute value
FormatVariable = ABS( Numerical value )
ArgumentsNumerical valueNumerical value for which to get the absolute value
Return ValuesAbsolute value
ExamplesA=ABS(-12.345)
SGNGets the sign
FormatVariable = SGN( Numerical value )
ArgumentsNumerical valueNumerical value for which to get the sign
Return Values0 or ±1
ExamplesA=SGN(12.345)
MIN (1)Gets the smallest value in the specified numerical value array
FormatVariable = MIN( Numerical value array )
ArgumentsNumerical value arrayName of a numerical value array storing multiple numerical values
Return ValuesSmallest number in the passed arguments
ExamplesDIM TMP[2]
TMP[0]=50:TMP[1]=3
A=MIN(TMP)
MIN (2)Gets the smallest value from the specified multiple numerical values
FormatVariable = MIN( Numerical value [,Numerical value…] )
ArgumentsNumerical values enumerated directly  Enumerate multiple numerical values separated by commas
Return Values  Smallest number in the passed arguments
ExamplesA=MIN(1,2,3,4)
MAX (1)Gets the largest value in the specified numerical value array
FormatVariable = MAX( Numerical value array )
ArgumentsNumerical value arrayName of a numerical value array storing multiple numerical values
Return ValuesLargest number in the passed arguments
ExamplesDIM TMP[2]
TMP[0]=50:TMP[1]=3
A=MAX(TMP)
MAX (2)Gets the largest value from the specified multiple numerical values
FormatVariable = MAX( Numerical value [,Numerical value…] )
ArgumentsNumerical values enumerated directlyEnumerate multiple numerical values separated by commas
Return ValuesLargest number in the passed arguments
ExamplesA=MAX(1,2,3,4)
RNDGets an integer random number (0 - the maximum value minus 1)
FormatVariable = RND( [ Seed ID, ] Maximum value )
ArgumentsSeed IDRandom number series: 0-7
Maximum valueUpper limit of the random number to be obtained
Return ValuesInteger random number in the range 0 - the maximum value minus 1
ExamplesA=RND(100)
RNDFGets a real-type random number (a real-type random number greater than 0 and less than 1.0)
FormatVariable = RNDF( [ Seed ID ] )
ArgumentsSeed IDRandom number series: 0-7
Return ValuesReal-type random number greater than 0 and less than 1
ExamplesA=RNDF()
RANDOMIZEInitializes a random number series
FormatRANDOMIZE Seed ID [, Seed value ]
ArgumentsSeed IDRandom number series type: 0-7
Seed valueIf 0 or omitted, initialization will be performed using available entropy information
ExamplesRANDOMIZE 0
SQRFinds the positive square root
FormatVariable = SQR( Numerical value )
ArgumentsNumerical valueNumerical value for which to find the square root
Return ValuesPositive square root found
ExamplesA=SQR(4)
EXPExponentiates e (natural logarithm base)
FormatVariable = EXP( [ Numerical value ] )
ArgumentsNumerical valueExponent (* If omitted, e will be returned.)
Return ValuesExponentiation result
ExamplesA=EXP(2)
LOGFinds the logarithm
FormatVariable = LOG( Numerical value [,Base ] )
ArgumentsNumerical valueAntilogarithm
BaseBase (* If omitted, the natural logarithm will be found.)
Return ValuesResult found
ExamplesA=LOG(2,2)
POWExponentiates a value
FormatVariable = POW( Numerical value, Multiplier )
ArgumentsNumerical valueNumerical value to exponentiate
MultiplierExponentiation multiplier
Return ValuesExponentiation result
ExamplesA=POW(1,4)
PIGets the circumference ratio
FormatVariable = PI()
Return ValuesCircumference ratio value (3.14159265)
ExamplesA=PI()
RADFinds the radian value from a degree value
FormatVariable = RAD( Numerical value )
ArgumentsNumerical valueDegrees: 0-360
Return ValuesRadian value found from the degree value
ExamplesR=RAD(45)
DEGFinds the degree value from a radian value
FormatVariable = DEG( Numerical value )
ArgumentsNumerical valueRadian value
Return ValuesDegree value found from the radian value
ExamplesA=DEG(0.5*PI())
SINReturns the sine value
FormatVariable = SIN( Angle )
ArgumentsAngleRadian
Return ValuesValue found
ExamplesA=SIN( RAD(45) )
COSReturns the cosine value
FormatVariable = COS( Angle )
ArgumentsAngleRadian
Return ValuesValue found
ExamplesA=COS( RAD(45) )
TANReturns the tangent value
FormatVariable = TAN( Angle )
ArgumentsAngleRadian
Return ValuesValue found
ExamplesA=TAN( RAD(45) )
ASINReturns the arc sine value
FormatVariable = ASIN( Numerical value )
ArgumentsNumerical value-1.0 to 1.0
Return ValuesArc sine (radian) value found
ExamplesA=ASIN(0)
ACOSReturns the arc cosine value
FormatVariable = ACOS( Numerical value )
ArgumentsNumerical value-1.0 to 1.0
Return ValuesArc cosine (radian) value found
ExamplesA=ACOS(1)
ATAN (1)Returns the arc tangent value (from numerical values)
FormatVariable = ATAN( Numerical value )
ArgumentsNumerical valueNumerical value from which to find the angle
Return ValuesArc tangent (radian) value found
ExamplesA=ATAN(1)
ATAN (2)Returns the arc tangent value (from XY-coordinates)
FormatVariable = ATAN( Y-coordinate,X-coordinate )
ArgumentsY-,X-coordinates- X-,Y-coordinates from the origin
- The Y-coordinate should be input first
Return ValuesArc tangent (radian) value found
ExamplesA=ATAN(1,1)
SINHReturns the hyperbolic sine value
FormatVariable = SINH( Numerical value )
ArgumentsNumerical valueReal-type number for which to find the hyperbolic sine
Return ValuesHyperbolic sine value found
ExamplesA=SINH(1)
COSHReturns the hyperbolic cosine value
FormatVariable = COSH( Numerical value )
ArgumentsNumerical valueReal-type number for which to find the hyperbolic cosine
Return ValuesHyperbolic cosine value found
ExamplesA=COSH(1)
TANHReturns the hyperbolic tangent value
FormatVariable = TANH( Numerical value )
ArgumentsNumerical valueReal-type number for which to find the hyperbolic tangent
Return ValuesHyperbolic tangent value found
ExamplesA=TANH(0.5)
CLASSIFYDetermines whether a given number is an ordinary numerical value, infinity, or not-a-number (NaN)
FormatVariable = CLASSIFY( Numerical value )
ArgumentsNumerical valueReal number to check
Return Values0 = Ordinary numerical value, 1 = Infinity, 2 = NaN
ExamplesA=CLASSIFY(0.5)

Operations on strings

Instructions for specifying display formats for strings, extracting strings, etc.

ASCGets a character code for the specified character (or string variable)
FormatVariable = ASC( "Character" )
ArgumentsCharacterCharacter string (or string variable) storing the character to check
Return ValuesCharacter code (UTF-16) for the specified character
ExamplesA=ASC("A")
CHR$Returns the character for the specified character code
FormatString variable = CHR$( Character code )
ArgumentsCharacter codeNumber (UTF-16) that corresponds to a character
Return ValuesCharacter that corresponds to the character code
ExamplesS$=CHR$(65)
VALGets a numerical value from a character string
FormatVariable = VAL( "Character string" )
ArgumentsCharacter stringA character string representing a number (e.g., "123"), or a string variable
Return ValuesNumerical value interpreted from the character string
ExamplesA=VAL("123")
STR$Gets a character string from a numerical value
FormatString variable = STR$( Numerical value [,Number of digits] )
ArgumentsNumerical valueNumerical value to convert to a character string
Number of digits- Should be specified when right-justification with a certain number of digits is desired
- When the number of digits in the numerical value is greater than the specified number of digits, the specification will be ignored
Return ValuesCharacter string generated from the numerical value (123 → "123")
ExamplesS$=STR$( 123 )
HEX$Gets a hexadecimal string from a numerical value
FormatString variable = HEX$( Numerical value [,Number of digits] )
ArgumentsNumerical valueNumerical value from which to get a hexadecimal string (The fractional part should be truncated)
Number of digits- Number of digits in the hexadecimal string to output
- If specified, the string will be padded with leading zeros before being returned
Return ValuesHexadecimal string generated from the numerical value (255 → "FF")
ExamplesS$=HEX$(65535,4)
FORMAT$Stringizes values by using display formats to shape them
FormatVariable$ = FORMAT$( "Format string", Value ,… )
ArgumentsFormat string (Multiple formats can be enumerated)%S: Outputs the content of the string variable
%D: Outputs integers in decimal
%X: Outputs integers in hexadecimal
%F: Outputs real numbers
Supplemental specifications for format stringsThe following supplemental specifications can be used after % to shape output
- Specification of the number of digits: A value indicating the number of digits should be specified (%8D, %4X)
- Specification of the number of fractional digits: Should be specified as (number of digits in the integer part).(number of digits in the fractional part) (%8.2F)
- Space-padding: A space character and the number of digits should be specified (% 4D → 0)
- Zero-padding: 0 and the number of digits should be specified (%08D → 00000000)
- Left alignment: A "-" sign and the number of digits should be specified (%-8D)
- Displaying the + sign: A "+" sign and the number of digits should be specified (%+8D)
Value- Source value to shape
- An adequate number of values corresponding to the elements specified in the formats should be enumerated, separated by commas (,)
Return ValuesCharacter string generated
ExamplesS$=FORMAT$("%06D",A)
LENGets the number of characters in a character string/Gets the number of elements in an array
Format>Variable = LEN( "Character string" or Array variable )
ArgumentsFor a character stringCharacter string, or the name of the string variable, in which to check the number of characters
For an array variableName of the array variable in which to check the number of elements
Return Values- For a character string: Number of characters (All characters will be counted as one character)
- For an array variable: Number of elements
ExamplesA=LEN("ABC123")
MID$Extracts a character string with the specified number of characters from the specified position in the specified character string
FormatString variable = MID$( "Character string", Start position, Number of characters )
ArgumentsCharacter stringSource character string
Start positionPosition (in character units) from which to start extracting a character string
Number of charactersNumber of characters to extract
Return ValuesCharacter string extracted
ExamplesS$=MID$("ABC",0,2)
LEFT$Extracts a character string with the specified number of characters from the left end of the specified character string
FormatString variable = LEFT$( "Character string", Number of characters )
ArgumentsCharacter stringSource character string
Number of charactersNumber of characters to extract
Return ValuesCharacter string extracted
ExamplesS$=LEFT$("ABC",2)
RIGHT$Extracts a character string with the specified number of characters from the right end of the specified character string
FormatVariable$ = RIGHT$( "Character string", Number of characters )
ArgumentsCharacter stringSource character string
Number of charactersNumber of characters to extract
Return ValuesCharacter string extracted
ExamplesS$=RIGHT$("ABC",2)
INSTRSearches for the target character string in another character string
FormatVariable = INSTR( [Start position,] "Character string to search in", "Character string to search" )
ArgumentsStart position- Position (in character units, larger than or equal to 0) in the source character string from which to start searching
- If omitted, the search will be started from the beginning of the source string
Character string to search inSource character string
Character string to search forCharacter string to search for in the source character string
Return Values- If the search string is found: Position in the source string (in character units)
- Otherwise: -1
ExamplesA=INSTR( 0, "ABC","B" )
SUBST$Substitutes one character string with another string
FormatString variable = SUBST$( "Character string", Start position, [Number of characters,] "Substitute string" )
ArgumentsCharacter stringSource character string
Start positionPosition in the source character string from which to start substitution (0 - Number of characters minus 1)
Number of characters- Number of characters to substitute with another string
- If omitted, all characters after the substitution start position will be replaced with the substitute string
Substitute stringThe specified number of characters from the start position will be substituted with this string
Return ValuesCharacter string after the substitution
ExamplesA$=SUBST$( "ABC",0,2,"XY" )

Source code manipulation

Functions for writing program strings into specified SLOTs

PRGEDITSpecifies the program SLOT to manipulate, and the current line
FormatPRGEDIT Program SLOT [,Line number]
ArgumentsProgram SLOT- Program SLOT to manipulate: 0-3
- Specifying the SLOT currently running will give an error
Line number- Line to manipulate (Current line)
- If this is omitted, the first line will be the current line
- If -1 is specified for the line number, the current line will be the last line
ExamplesPRGEDIT 0
PRGGET$Gets the current single line as a character string
FormatString variable=PRGGET$()
Return Values Source character string of the current line (or an empty string if there is no applicable line)
ExamplesA$=PRGGET$()
PRGSETSubstitutes the contents of the current line with the specified string
If PRGGET$ has returned an empty string, a line will be added
FormatPRGSET "Character string"
ArgumentsCharacter stringCharacter string to substitute the current line with
ExamplesPRGSET "'Comment"
PRGINSInserts a line in the current line
For a character string including the line feed code CHR$(10), multiple lines will be inserted
FormatPRGINS "Character string" [,Flag]
ArgumentsCharacter stringSource character string to insert
Flag1 = Inserts a line after the current line
0 = Inserts a line before the current line (If omitted = 0, before the current line)
ExamplesPRGINS "PRINT "+CHR$(34)+"HELLO"+CHR$(34)
PRGDELDeletes the current line
FormatPRGDEL [Number of lines to delete]
ArgumentsNumber of lines to delete- Number of lines to delete (If omitted, one line will be deleted)
- If a negative value is specified, all lines will be deleted
ExamplesPRGDEL
PRGSIZEGets the number of lines in the source code
FormatVariable=PRGSIZE( [Program SLOT [,Type of value to get]] )
ArgumentsProgram SLOTProgram SLOT from which to get the number of lines: 0-3
Type of value to get0 = Number of lines, 1 = number of characters, 2 = number of free characters (Default: 0)
Return ValuesType-appropriate value
ExamplesA=PRGSIZE(0)
PRGNAME$Program file name
File that has been handled with the LOAD/SAVE instruction
FormatString variable=PRGNAME$([Program SLOT])
ArgumentsProgram SLOTProgram SLOT from which to get the file name: 0-3
Return Values- Program file name
- When a program is running, the SLOT in which it is running
- When no program is running, the "SLOT of the last program run"
- The "SLOT of the last program run" is usually SLOT 0
- If a running program has been suspended with the STOP instruction or the START button, or if an error has occurred, the SLOT at that time will be the “SLOT of the last program run” and will remain so until the next RUN
ExamplesPRINT PRGNAME$(0)

Bit Operations

Instructions for performing a bit operation to numerical values

MODGets the remainder of Numerical value 1 divided by Numerical value 2
FormatVariable=Numerical value 1 MOD Numerical value 2
ArgumentsNumerical value 1Number (or expression) to divide
Numerical value 2Number (or expression) to divide by (Dividing by zero gives an error)
ExamplesA=200 MOD 5
DIVGets the integer value of Numerical value 1 divided by Numerical value 2
FormatVariable=Numerical value 1 DIV Numerical value 2
ArgumentsNumerical value 1Number (or expression) to divide
Numerical value 2Number (or expression) to divide by (Dividing by zero gives an error)
ExamplesA=200 DIV 5
ANDLogical AND of Numerical value 1 and Numerical value 2 (Multiplication of bits)
FormatVariable=Numerical value 1 AND Numerical value 2
ArgumentsNumerical value 1Bit string 1
Numerical value 2Bit string 2
ExamplesA=200 AND &HE7
ORLogical OR of Numerical value 1 and Numerical value 2 (Addition of bits)
FormatVariable=Numerical value 1 OR Numerical value 2
ArgumentsNumerical value 1Bit string 1
Numerical value 2Bit string 2
ExamplesA=128 OR &HA3
XORExclusive OR of Numerical value 1 and Numerical value 2 (If the values are the same, 0; if not, inversion)
FormatVariable=Numerical value 1 XOR Numerical value 2
ArgumentsNumerical value 1Bit string 1
Numerical value 2Bit string 2
ExamplesA=100 XOR &H4C
<<Shifts a numerical value to the left by the specified number of bits
FormatVariable=Numerical value << Number of times
ArgumentsNumerical valueBit string 1
Number of timesNumber of bit shifts
ExamplesA=100 << 2
>>Shifts a numerical value to the right by the specified number of bits
FormatVariable=Numerical value >> Number of times
ArgumentsNumerical valueBit string 1
Number of timesNumber of bit shifts
ExamplesA=100 >> 2

MML

Commands for MML (Music Macro Language)

MML (1)Commands for controlling whole tunes
Channel specification:0 - :15 (A colon [:] followed by a channel number should be specified)
Tempo specificationT1 - T512
Examples'--- Chord of Do Mi Sol with tempo 120
BGMPLAY "T120:0CCC:1EEE:2GGG"
MML (2)Commands and notations for controlling tone length
Specification of default tone lengthL1 - L192 These specifications will change the subsequent default tone length
Individual tone length specification◆To play a tone with a length other than the default tone length, change the tone length by inputting the length specification after the pitch symbol
e.g., Specify the length of Do directly
C1 (Whole note of Do)
C2 (Half note of Do)
C4 (Quarter note of Do)
C8 (Eighth note of Do)
C16 (Sixteenth note of Do)
C32 (Thirty-second note of Do)
C1. - C32. (Dotted note representations of Do)
* Triplets should be specified as C12C12C12, C24C24C24, etc.
Playing technique& Connects the preceding/succeeding notes ()
_ Portamento ()
Note duration ratio (gate) settingQ0 - Q8 Smaller numbers give a greater impression of breaks between successive tones
MML (3)Commands for controlling (tone) pitch.
Scale specificationC (Do)
D (Re)
E (Mi)
F (Fa)
G (Sol)
A (La)
B (Ti)
Halftone higherC# D# E# F# G# A# B#
Halftone lowerC- D- E- F- G- A- B-
Rest◆R * Can be used in the same way as scales.
e.g., R4 (Quarter-note rest)
Octave specificationO0 - O8 Octave number specification
One octave up<
One octave down>
Inversion of octave specification! * Specifying this causes the <> symbols to be handled in reverse.
Key value specification◆N0 - N127 * O4C=60; one increment/decrement per halftone.
Examples'--- Do Do Re Mi Fa Sol Sol La Ti Ti Ti Ti
BGMPLAY "CCDEFGGABBBB"
MML (4)Commands for controlling sound volume and localization
Volume specification◆V0 - V127 Volume level value specification
One volume level up(
One volume level down)
Pan pot◆P0 - P127 Determines the position between the speakers from which the sound is heard (localization)
Left: P0 - P63 Center: P64 Right: P65 - P127
Envelope setting@E + A,D,S,R values Sets the change in volume from sound generation to attenuation
A (Attack time): 0-127
D (Decay time): 0-127
S (Sustain level): 0-127
R (Release time): 0-127 * The smaller each time value, the slower it is.
e.g., @E127,100,30,100
Envelope resetting@ER Releases the envelope
MML (5)Commands for controlling tone changes
Instrument sound changes@0 - @127 Equivalent to GM (Can be checked using the SMILETOOL)
@128 Standard drum set
@129 Electric drum set
@144 - @150 PSG sound sources
@151 Noise sound source
@224 - @255 User-defined waveforms (Those registered with WAVSET)
@256 - Sound effects provided for BEEP
@128 drum set (@129)B1 Acoustic Bass Drum 2 (909BD)
C2 Acoustic Bass Drum 1 (808BDTom)
C2# Side Stick(808RimShot)
D2 Acoustic Snare (808SD)
D2# Hand Clap
E2 Electric Snare (909SD)
F2 Low Floor Tom (808TomLF)
F2# Closed Hi-hat(808CHH)
G2 High Floor Tom (808TomF)
G2# Pedal Hi-hat(808CHH)
A2 Low Tom (808TomL)
A2# Open Hi-hat(808OHH)
B2 Low-Mid Tom (808TomLM)
C3 High Mid Tom (808TomHM)
C3# Crash Cymbal 1(808Cymbal)
D3 High Tom (808TomH)
D3# Ride Cymbal 1
E3 Chinese Cymbal
F3 Ride Bell
F3# Tambourine
G3 Splash Cymbal
G3# Cowbell(808Cowbell)
A3 Crash Cymbal 2
A3# Vibra-slap
B3 Ride Cymbal 2
C4 High Bongo
C4# Low Bongo
D4 Mute Hi Conga (808CongaMute)
D4# Open Hi Conga(808CongaHi)
E4 Low Conga (808CongaLo)
F4 High Timbale
F4# Low Timbale
G4 High Agogo
G4# Low Agogo
A4 Cabasa
A4# Maracas(808Maracas)
B4 Short Whistle
C5 Long Whistle
C5# Short Guiro
D5 Long Guiro
D5# Claves(808Claves)
E5 Hi Wood Block
F5 Low Wood Block
F5# Mute Cuica
G5 Open Cuica
G5# Mute Triangle
A5 Open Triangle
MML (6)Special effect commands used to give a subtle fluctuation to sounds and volume
* @MA, @MP, and @ML cannot be used at the same time.
Start modulation@MON
Stop modulation@MOF
Detuning (fine frequency adjustment) setting◆@D-128 to @D127 (-128 is a tone lower; +127 is a tone higher)
Tremolo setting@MA + Depth, Range, Speed, Delay values (0-127 for each)
e.g., @MA64,1,16,32
Vibrato setting@MP + Depth, Range, Speed, Delay values (0-127 for each)
e.g., @MP64,1,16,32
Auto pan pot setting@ML + Depth, Range, Speed, Delay values (0-127 for each)
e.g., @ML100,1,8,0
MML (7)Special music playback commands.
Repeat start[
Repeat end]Number of times * If the number of times is omitted, the loop will be endless.◆
e.g., Complicated repeat to play CCC CCC DEF CCC CCC DEF
BGMPLAY "[[CCC]2DEF]2"
MML internal variable specification$0 - $7 MML internal variables
* In commands marked with ◆, these variables can be specified in place of numerical values.
e.g., $0=64 V$0 instead of V64
Value assignment to MML internal variables$0=value - $7=value Assign values (0-255) to the variables
* Variables being played back can be assigned a value or referenced with the BGMVAR instruction.
Macro definition{Label name=MML}
Can be used to reuse a melody or phrase repeatedly
- Channel specification within the defined MML is not allowed
- For label names, up to eight alphanumerical characters can be used
- Reusing a label name for another definition is not allowed
Macro use{Label name} MML corresponding to the defined label will be expanded
Examples'--- Play a rhythm using a macro
BGMPLAY "T240@128O2{PT0=CDEDCDE<G}[{PT0}]4"

Error Table

System Variable for Error Handling If an error has occurred, the relevant information is stored in the system variable.
ERRNUM (Error number)
ERRLINE (Number of the line where the error occurred)
Common Errors 3: Syntax error (syntax does not follow the grammar rules)
4: Illegal function call (the number of arguments specified in an instruction or function is wrong)
5: Stack overflow (an overflow has occurred in the stack)
6: Stack underflow (an underflow has occurred in the stack)
7: Divide by zero (division by zero was attempted)
8: Type mismatch (an inconsistent variable type is specified)
9: Overflow (the calculation result exceeded the allowed range)
10: Out of range (a value outside the allowed range was specified)
11: Out of memory (sufficient memory area is not available)
12: Out of code memory (sufficient code memory area is not available)
13: Out of DATA (DATA that can be READ is insufficient)
14: Undefined label (the specified label could not be found)
15: Undefined variable (the specified variable could not be found)
16: Undefined function (the specified instruction/function could not be found)
17: Duplicate label (the same label has been defined twice)
18: Duplicate variable (the same variable has been defined twice)
19: Duplicate function (the same instruction/function has been defined twice)
20: FOR without NEXT (a FOR has no NEXT)
21: NEXT without FOR (a NEXT has no FOR)
22: REPEAT without UNTIL (a REPEAT has no UNTIL)
23: UNTIL without REPEAT (an UNTIL has no REPEAT)
24: WHILE without WEND (a WHILE has no WEND)
25: WEND without WHILE (a WEND has no WHILE)
26: THEN without ENDIF (a THEN has no ENDIF)
27: ELSE without ENDIF (an ELSE has no ENDIF)
28: ENDIF without IF (an ENDIF has no IF)
29: DEF without END (a DEF has no END)
30: RETURN without GOSUB (a RETURN has no GOSUB)
31: Subscript out of range (array subscripts are not within the allowed range)
32: Nested DEF (a DEF has been defined within another DEF)
33: Can't continue (the program cannot resume with CONT)
34: Illegal symbol string (a label string has been incorrectly described)
35: Illegal file format (the file is in a format that SmileBASIC cannot support)
36: Mic is not available (a microphone instruction was used without using XON MIC)
37: Motion sensor is not available (a motion instruction was used without using XON MOTION)
38: Use PRGEDIT before any PRG function (one of the PRG instructions was used without using PRGEDIT)
39: Animation is too long (animation definition is too long)
40: Illegal animation data (animation data is incorrect)
41: String too long (string is too long)
42: Communication buffer overflow (an overflow has occurred in the buffer for sending MPSEND)
43: Can't use from DIRECT mode (an instruction that does not work in DIRECT mode was used)
44: Can't use in program (an instruction that cannot be used in a program was used)
45: Can't use in tool program (an instruction that cannot be used from a tool program was used)
46: Load failed (failed to read the file)
47: Illegal MML (the MML [Music Macro Language] is incorrect)

System Variable

What is a System Variable? System variables are variables reserved in the system managed by SmileBASIC.
* Although they are primarily read-only, it is possible to populate values in some (they are writable).
Examples CSRX 'Cursor position X
CSRY 'Cursor position Y
CSRZ 'Cursor position Z (depth)
FREEMEM 'Amount of free user memory available (in KB)
VERSION 'System version (&HXXYYZZZZ)
TABSTEP 'TAB movement amount (writable)
SYSBEEP 'System sound effects (writable, TRUE=allowed)
ERRNUM 'Error number
ERRLINE 'Line where an error occurred
ERRPRG 'Program SLOT where an error occurred
PRGSLOT 'Current program SLOT for the PRG instruction
RESULT 'Dialog result (TRUE/FALSE/-1=Suspended)
MAINCNT 'Number of frames since SmileBASIC was launched
MICPOS 'Current sampling location
MICSIZE 'Number of samples in the sampling buffer
MPCOUNT 'Number of participants in a session
MPHOST 'Host ID
MPLOCAL 'User ID
TRUE 'Always 1
FALSE 'Always 0
TIME$ 'Time string (HH:MM:SS)
DATE$ 'Date string (YYYY/MM/DD)
HARDWARE 'Hardware information (1=new3DS)
CALLIDX 'Number called by SPFUNC and BGFUNC

Constants

# - 32-bit numerical value definitions prepared in the system
- Used instead of a numerical value in order to specify a color or handle a button
- e.g., IF BUTTON() AND (#A OR #B) THEN
Examples '--- Generic
#ON    '1
#OFF   '0
#YES   '1
#NO    '0
#TRUE  '1
#FALSE '0
'--- RGB
#AQUA    '&HFF00F8F8
#BLACK   '&HFF000000
#BLUE    '&HFF0000FF
#CYAN    '&HFF0000F8
#FUCHSIA '&HFFF800F8
#GRAY    '&HFF808080
#GREEN   '&HFF008000
#LIME    '&HFF00F800
#MAGENTA '&HFFF800F8
#MAROON  '&HFF800000
#NAVY    '&HFF000080
#OLIVE   '&HFF808000
#PURPLE  '&HFF800080
#RED     '&HFFF80000
#SILVER  '&HFFC0C0C0
#TEAL    '&HFF008080
#WHITE   '&HFFF8F8F8
#YELLOW  '&HFFF8F800
'--- TEXTCOLOR
#TBLACK   '1
#TMAROON  '2
#TRED     '3
#TGREEN   '4
#TLIME    '5
#TOLIVE   '6
#TYELLOW  '7
#TNAVY    '8
#TBLUE    '9
#TPURPLE  '10
#TMAGENTA '11
#TTEAL    '12
#TCYAN    '13
#TGRAY    '14
#TWHITE   '15
'--- BUTTON
#UP    '&H0001
#DOWN  '&H0002
#LEFT  '&H0004
#RIGHT '&H0008
#A     '&H0010
#B     '&H0020
#X     '&H0040
#Y     '&H0080
#L     '&H0100
#R     '&H0200
#ZL    '&H0800
#ZR    '&H1000
'--- ATTR
#TROT0   '&H00
#TROT90  '&H01
#TROT180 '&H02
#TROT270 '&H03
#TREVH   '&H04
#TREVV   '&H08
'---SPSET/SPCHR ATTR
#SPSHOW   '&H01, Display
#SPROT0   '&H00, Rotate by 0 degree
#SPROT90  '&H02, Rotate by 90 degrees
#SPROT180 '&H04, Rotate by 180 degrees
#SPROT270 '&H06, Rotate by 270 degrees
#SPREVH   '&H08, Right/left
#SPREVV   '&H10, Up/down
#SPADD    '&H20, Additive synthesis
'--- BG ATTRE
#BGROT0   '&H0000
#BGROT90  '&H0800
#BGROT180 '&H1000
#BGROT270 '&H2000
#BGREVH   '&H4000
#BGREVV   '&H8000
'--- SPCHK/BGCHK
#CHKXY '&H01
#CHKZ  '&H02
#CHKUV '&H04
#CHKI  '&H08
#CHKR  '&H10
#CHKS  '&H20
#CHKC  '&H40
#CHKV  '&H80