1.2 file instruction

About the file instruction
Attention
BASIC confuses the file and delete needless, please in the place where data is copied on the preservation data management screen etc. when the same two comment names or more exist in same RAM (same partition in case of FD). When the program ends, all files that have opened are annulled. It is necessary to close to write data that does FWRITE before the program is finished. When the error occurs, all files that have opened are annulled.

Device name
COM: Host computer(personal computer)
BRAM: Main body RAM
CRAM: Card ridge RAM
FD0: Floppy disk: Partition 1
FD1: Floppy disk: Partition 2
CD: Internal organs CD drive

File beautiful passage Gerets
The file name is divided into the base name "XXXXXXXX" and the extension "Y" in the form of "XXXXXXXX.Y". The extension "Y" shows the file type, and the following one is defined.

.The base name is [A~Z,0~9,_] by one character or more up to eight characters.
.When both base names and the extensions give the small letter, it is converted into the capital letter.
.Space cannot be contained in the base name.
.To separate the base name and the extension, the period is done ..doing...
.Space enters up to eight characters when the period is put or the base name doesn't come up to eight characters.
.It is not possible to put it excluding the extension specified behind the period though the file name can be ended at the period.
.When the extension is omitted by SAVE and LOAD, "B" is added for the blank.
.When the extension is omitted by GSAVE and GLOAD, "0" or "1" is added for the blank.
.Besides, the extension becomes "D".
Exceptionally, the extension is not displayed in FILES and FILES$ if it doesn't match it to the pattern though is permitted "*".
Attention
Actually, the comment on the backup data name is used as a file name.

File number
The file number starts from the difference from the partition number and 1 in the number in which the file is operated.
Attention
When writing such as LOAD and SAVE and the reading instructions are executed for the personal computer side when Sega Saturn has added, it is not likely to be able to read and write it well. In that case, please push [CTRL] + [P] key or the [F12] key or execute SCREEN 0.

Direct effective order indirect effect instruction of BLOAD
Function
The file is read to the content of the user's area secured by the CLEAR instruction.
Format
BLOAD"[<デバイス名>]<ファイル名>",<先頭ブロック>,<先頭オフセット>
Example
BLOAD FILENAME$, 0, 0
Parameter
<デバイス名>… Character string type. The character string that can be specified is limited thoroughly to the provided name.
<ファイル名>… Character string type. The character string that can be specified is limited to an effective character as a file name.
<先頭ブロック>… Fixed zero point type. The first block in the written user's area is specified.
<先頭オフセット>… Fixed zero point type. The offset from the first block in the written user's area is specified.
Operation is detailed.
<デバイス名>When is omitted, the device used at the end becomes an object. <ファイル名>When it drinks and Hiroga Haco is omitted, "D" is added. If characters other than "D" are specified when the extension is specified specifying it, it becomes Bad file name. The address in the written user's area is read from * <先頭ブロック>256+ about the user's area. <先頭オフセット><先頭ブロック>As for the numerical value for which can be specified, the fraction part is disregarded in the numerical value of 0 or more. <先頭オフセット>It drinks and the fraction part is disregarded in range and 0~ &H1FFFF.
Attention
File still open happens when BLOAD is done by the same file name as the file name that has already opened with the same device. When the user's area is exceeded and it reads, Not enough space is generated.

Direct effective order indirect effect instruction of BSAVE
Function
The content of the user's area secured by the CLEAR instruction is written file.
Format
BSAVE"[<デバイス名>]<ファイル名>",<先頭ブロック>,<先頭オフセット>,<終端ブロック>,<終端オフセット>
Example
BSAVE FILENAME$, 0, 0, 10, 10
Parameter
<デバイス名>… Character string type. The character string that can be specified is limited thoroughly to the provided name.
<ファイル名>… Character string type. The character string that can be specified is limited to an effective character as a file name.
<先頭ブロック>… Fixed zero point type. The first block in the written user's area is specified.
<先頭オフセット>… Fixed zero point type. The offset from the first block in the written user's area is specified.
<終端ブロック>… Fixed zero point type. The terminal block in the written user's area is specified.
<終端オフセット>… Fixed zero point type. The terminal offset of the written user's area is specified.
Operation is detailed.
<デバイス名>When is omitted, the device used at the end becomes an object. <ファイル名>When it drinks and Hiroga Haco is omitted, "D" is added. If characters other than "D" are specified when the extension is specified specifying it, it becomes Bad file name. As for the range in the written user's area, it is * <先頭ブロック>256+~*256 <先頭オフセット><終端ブロック>+. <終端オフセット><先頭ブロック>As for the numerical value for which can be specified, the fraction part is disregarded in the numerical value of 0 or more. <先頭オフセット>It drinks and the fraction part is disregarded in range and 0~ &H1FFFF.
Attention
File still open happens when BSAVE is done by the same file name as the file name that has already opened with the same device. Not enough space happens when the capacity of the object device is few or starts making 99 more files with the backup device.

Direct effective order indirect effect instruction of CLOSE
Function
End of file access
Format
CLOSE[[#]<ファイル番号>]
Example
CLOSE
CLOSE #1
Parameter
<ファイル番号>… Numerical value type of fixed zero point type. The range of an effective numerical value is a value of 1~2(All the decimal parts are rounded down).
Operation is detailed.
The file opened by the OPEN instruction is shut, and the access to the file is ended. After the data is written in the file, it ends when data remains in the file area when this instruction is executed. <ファイル番号>However, all files opened by the OPEN instruction become objects when omitted (When the backup data device closes, the file is written for the first time).

Direct effective order indirect effect instruction of FILES
Function
The file is retrieved, and the existing file name is displayed.
Format
FILES"[<デバイス名>],<検索ファイル名>]"[,P]
Example
FILES
FILES "COM:SAMPLE??"
FILES F$
Parameter
<デバイス名>… The character string that can be specified is limited thoroughly to the provided name.
<検索ファイル名>… Character string type. The character string that can be specified is limited to an effective character string ( <ワイルドカード>Contains it) as a file name.
P … Temporary stop specification.
Operation is detailed.
<デバイス名>Specify..device..specify..file..retrieve..match..file..information..screen..list..display. <検索ファイル名><デバイス名>The character kind and the number of characters that can be <検索ファイル名>used apply to the rule of the file name. The wild-card can be used for the file name. <>However, the device used immediately before becomes an object when omitted. <検索ファイル名>However, all files that exist in the device become objects when omitted. <ファイル拡張子>However, all file extensions become objects when omitted. It stops temporarily when the retrieved file name cannot be displayed on the screen and it enters the state of the input waiting when "P" is specified for the option. Continuation is displayed if there are some key input. The display changes line when neither the separator two characters nor file name ten characters + file names enter the line of the remainder. It is CD in the object of FILE: It is not <残りファイルブロック数> <総ファイルブロック数>displayed for the selection excluding or CD of the display of the capacity of the device (block = one file 64 bytes) in the last line on a page with Free size/file blocks.

Direct effective order indirect effect instruction of FORMAT
Function
<デバイス名>It drinks and the device is initialized.
Format
FORMAT "<デバイス名>"
Example
FORMAT "FD1:"
Parameter
<デバイス名>… Device name. Refer to above-mentioned "File instruction".
Operation is detailed.
<デバイス名>Only when it drinks and the device is not formatted, it deletes it (initialization). allThe device that can be formatted is BRAM: CRAM: FD0: It is only FD1. As for the floppy disk, it is formatted only in the selected partition.
Example
Partition number 1 of "FD1" … floppy disk of FORMAT is initialized. The Bad device name error occurs when the device name is illegal.
Attention
The Already formatted error occurs when already formatted.

Direct effective order indirect effect instruction of FREAD
Function
Data is read from the file area to the character variable.
Format
FREAD[#]<ファイル番号>,<文字変数>,<バイト数>
Example
FREAD #1, A$, 10
Parameter
<ファイル番号>… Numerical value type of fixed zero point. The range of an effective numerical value is a value of 1~2(All the decimal parts are rounded down).
<文字変数>… The name of the variable of the character string type is described. The name that can be specified applies to the the name of the variable putting rule.
<バイト数>… Numerical value type of fixed zero point. The range of an effective numerical value is a value of one or more (All the decimal parts are rounded down).
Operation is detailed.
The <文字変数>data of the amount is <バイト数>read from the file name opened by the OPEN instruction to the variable that specifies. It is necessary to open the file by the OPEN instruction by either without INPUT or specification. It is actually reading from the file area that <ファイル番号>corresponds to specification. The SEEK position moves only in the read number of characters when data is read. Please refer to the SEEK instruction for the SEEK position.
Attention
If it reads exceeding the size of the file, Access past EOF is generated.
Reference
SEEK

Direct effective order indirect effect instruction of FWRITE
Function
Data is written in the file area.
Format
FWRITE[#]<ファイル番号>,<データ>
Example
FWRITE #1, "ABC"
FWRITE 1, A$
Parameter
<ファイル番号>… Numerical value type of fixed zero point. The range of an effective numerical value is a value of 1~2(All the decimal parts are rounded down).
<データ>… Character string type
Operation is detailed.
<データ>Data that specifies is written in the file opened by the OPEN instruction. It is necessary to open the file by the OPEN instruction by either without OUTPUT, APPEND, and specification. It is necessary to close the file number for the object to finish writing. Actually, when it becomes writing in the file area that <ファイル番号>corresponds to specification, writing ends, and the CLOSE instruction is executed, it is written to the file. The SEEK position moves only in the number of characters written to write data. Please refer to the SEEK instruction when adhering to the SEEK position.
Reference
SEEK

Direct effective order indirect effect instruction of GLOAD
Function
<ファイル名>It drinks and Bittomappdata <論理BG>Yo expects it.
Format
GLOAD"[<デバイス名>]<ファイル名>"[,<論理BG>][,(<転送先X座標>,<転送先Y座標>)][,P]
Example
GLOAD "COM:TEST.1"
Parameter
<デバイス名>… Character string type. The character string that can be specified is limited thoroughly to the provided name.
<ファイル名>… Character string type. The character string that can be specified is limited to an effective character as a file name.
<論理BG>… Numerical value type of fixed zero point type. The range of an effective numerical value depends on the screen mode set by the SCREEN instruction.
<転送先X座標>,<転送先Y座標>… Coordinates of one point in a rectangular area (Correspond to the starting point of forwarding) at the forwarding destination are specified. Numerical value type of fixed zero point type.
The palette color data in the P…256 color bit map data is not read.
Operation is detailed.
Graphic data is <転送先X座標><転送先Y座標>read from the position of (,) to the bit map screen. Processing when graphic data exceeds the boundary of the bit map screen

GCOPY <文字列式> TO (coordinates specification at forwarding destination)
It is the same. <転送先X座標>,<転送先Y座標>When you omit

<転送先X座標>= 0
<転送先Y座標>= 0
It does and it is executed solving.

<デバイス名>However, the device used at the end becomes an object when omitted. <ファイル名>It is the following either of Hiroga Haco. drink
. 0 256 color bit map data
. 1 32768 color bit map data
When the extension is omitted, the extension corresponding to a present screen mode is automatically added. Illegal function call occurs when the bit map data cannot be treated in a present screen mode.
Illegal function call occurs when the relation of the condition written the screen mode is different when the extension is specified specifying it.
When "P" is specified for the option, the palette color data in 256 color bit map data is not read. This option is disregarded for 32768 color mode.
<論理BG>Data is read to the bit map screen specified that is omitted by the ACTIVE instruction at the end.
Because GLOAD uses the file buffer to read graphic data temporarily, it is necessary to secure independence a necessary size by the CLEAR instruction. The file buffer used temporarily uses the largest one in a buffer unused (It is not allocated by the OPEN instruction) during this instruction. The size of a necessary file buffer should be larger than the size of the read graphic data in GLOAD. For instance, after the following area is secured by the CLEAR instruction, it is necessary to read graphic data that GSAVE is done by the size of 320X 224 dot with GLOAD.

282 bit map data blocks or more of 256 colors(one block =256 bytes)
560 bit map data blocks or more of 32768 colors( " )

Example
SCREEN 1
CLEAR, 600
GLOAD "GDATA.0", 1
Bit map data format
The format is as follows. Basically, neither the character string nor the difference data size are limited to &HFFFF though it is the same form as the character string used by the GCOPY instruction. The position and SIZE from the head of data show the number of bytes in OFFSET.
256 color bit map data
Content of OFFSET SIZE
+0 Number (1~512) of dots of widths of two [ Width ] image data. The order of high-ranking byte and subordinate position byte
+2 Number (1~256) of dots of width of length of two [ Height ] image data. The order of high-ranking byte and subordinate position byte
+4 512 palette color data. It is 256 colors, and 512 bytes in the order of a high-ranking byte and the subordinate position byte.
+516 changeable dot data. [ Height ] byte of [ Width ]X necessity specified ahead

Element of &B000000000011111 red
Element of &B000001111100000 green
Element of &B111110000000000 blue

32768 color (RGB color) bit map data
Content of OFFSET SIZE
+0 Number (1~512) of dots of widths of two [ Width ] image data. The order of high-ranking byte and subordinate position byte
+2 Number (1~256) of dots of width of length of two [ Height ] image data. The order of high-ranking byte and subordinate position byte
+4 changeable dot data. [ Width ]X [ Height ] X 2 byte necessity specified ahead
It is expressed by RGB data of one dot =16 bits, and it arranges it to one dot in order of a high-ranking byte and the subordinate position byte.
The structure of RGB data is the same as the form treated by RGB function.
Element of &B000000000011111 red
Element of &B000001111100000 green
Element of &B111110000000000 blue
However, the display color most significant bit (bit 15) should be "1. "In a word, a black dot :.
RGB( 0, 0, 0 )+ &H8000 (= &H8000 )
It does and it specifies it solving. When the dot of the object is displayed as a transparent color, the entire RGB data is specified for 0. The displays of the value of data (&H0001~&H7FFF) other than Core are not guaranteed.
Reference
GSAVE, GCOPY, ACTIVE

Direct effective order indirect effect instruction of GSAVE
Function
<論理BG>It writes it to the file as ..drinking.. ..Bittomappdata.. ..drinking.. <ファイル名>data.
Format
GSAVE"[<デバイス名>]<ファイル名>"[,<論理BG>][,(<始点X座標>,<始点Y座標>)-(<終点X座標>,<終点Y座標>)]
Example
GSAVE "COM:PICT", 0
Parameter
<デバイス名>… Character string type. The character string that can be specified is limited thoroughly to the provided name.
<ファイル名>… Character string type. The character string that can be specified is limited to an effective character as a file name.
<論理BG>… Numerical value type of fixed zero point type. The range of an effective numerical value depends on the screen mode set by the SCREEN instruction.
<始点X座標>, <始点Y座標>, <終点X座標>, <終点Y座標>… Coordinates of two points that become corners in a rectangular area of forwarding are specified. Numerical value type of fixed zero point type.
Operation is detailed.
<始点X座標>,<始点Y座標>,<終点X座標>,<終点Y座標>When you omit
.<始点X座標>= 0
.<始点Y座標>= 0
.<終点X座標>= 319
.<終点Y座標>= 223
It does and it is executed solving. <デバイス名>However, the device used at the end becomes an object when omitted. <ファイル名>It is the following either of Hiroga Haco. drink
. 0 256 color bit map data
. 1 32768 color bit map data
When the extension is omitted, the extension corresponding to a present screen mode is automatically added. Illegal function call happens when the bit map data cannot be treated in a present screen mode. Illegal function call happens when the relation of the condition written the screen mode is different when the extension is specified specifying it.
<論理BG>The file of the bit map screen specified that is omitted by the ACTIVE instruction at the end is made. Because GSAVE uses the largest though graphic data is temporarily written a body use file buffer, it is necessary to secure a necessary size beforehand by the CLEAR instruction.
For instance, the <論理BG>data of 320X 224 dot of 0 is done with SCREEN-0 and as follows is done to writing.
600 blocks are secured for CLEAR and 600→ file buffer # 1.
GSAVE "TEMP", 0
The size of a necessary file buffer : with GSAVE.
.<幅>= <終点X座標>- <始点X座標>+ 1
.<高さ>= <終点Y座標>- <始点Y座標>+ 1
Then,
. 4+512+ (X) byte in case of 256 color bit map data <幅> <高さ>
. 4+ (X X 2) <幅> <高さ>byte in case of 32768 color bit map data
It is necessary. Please refer to GLOAD when adhering to the bit map data format. COM when the area where GSAVE is done is large: It takes 1~2 minutes or more for writing in the device.

Direct effective order indirect effect instruction of KILL
Function
The specified file is deleted.
Format
KILL[<デバイス名>]<ファイル名>
Example
KILL "BRAM:TEST.B"
KILL F$
Parameter
<デバイス名>… Character string type. The character string that can be specified is limited thoroughly to the provided name.
<ファイル名>… Character string type. The character string that can be specified is limited to an effective character as a file name.
Operation is detailed.
<デバイス名>The file <ファイル名>specified with device's for which is specified is deleted. <ファイル名>It peels off and it is necessary to specify a complete name including , extension. <デバイス名>The character kind and the number of characters that can be <ファイル名>used apply to the file name rule. <デバイス名>However, the device used immediately before becomes an object when omitted.
Attention
<ファイル名文字列>It drinks and it is necessary to specify Hiroga Haco specifying it. File not found is generated because the extension is treated as space when the extension is omitted.

Direct effective order indirect effect instruction of LOAD
Function
The program list is read.
Format
LOAD[<デバイス名>]<ファイル名>[,[{R|M}] …]
Example
LOAD "SAMPL2"
LOAD "BRAM:MAIN", R
LOAD F$, R
Parameter
<デバイス名>… Character string type. The character string that can be specified is limited thoroughly to the provided name.
<ファイル名>… Character string type. The character string that can be specified is limited to an effective character as a file name.
R|M … Execution or merging loading specification immediately.
Operation is detailed.
<デバイス名>The file <ファイル名>specified with device's for which is specified is read. <デバイス名>The character kind and the number of characters that can be <ファイル名>used apply to the file name rule.
<デバイス名>However, the device used immediately before becomes an object when omitted. Even when the extension is not given specifying it as for the extension, "B" is added.
It is distinguished whether it is an executable BASIC program by the file extension.
<デバイス名>However, FD0: FD1: BRAM: " <ファイル名>. D" can be given to the extension only for CRAM. This file should be a text form of BASIC (ASCII code). When the program is merged with the personal computer not especially connected (annexation) or the data made by the program such as the character editors is taken partially of the program of BASIC, this mechanism is friendship.
The device when the device is COM is CRAM: BRAM: FD0: When the condition that the file writes in the case of FD1 is ". D", M option can be put. This option annexes a new program to the program before it loads it. At this time, the same line as former line - number is deleted, and the program of the line that appears newly is added. The line that starts excluding the line - number is disregarded.
Please add CHR$(13) + CHR$(10) at the end of the written program when making it excluding SAVE ""A command of the text form program. (CHR$(13) is disregarded, and CHR$(10) is considered delimit of one line. )。
Supplementation
It is necessary to note it because the value of former program and the variable disappears though the LOAD instruction (indirect execution) can be described while programming it. However, the content of the sound source data etc. of the content of the user's area secured with CLEAR, the texture, the top, the polygon, and the attribute is maintained.
Attention
When writing such as LOAD and SAVE and the reading instructions are executed for the personal computer side when the load hangs to Sega Saturn, it is not likely to be able to read and write it well. In that case, please push [CTRL] + [P] key or the [F12] key or execute SCREEN 0.

Direct effective order indirect effect instruction of OPEN
Function
It is prepared for the file to read and write data.
Format
OPEN[<デバイス名>]<ファイル名>[FOR{INPUT|OUTPUT|APPEND}]AS[#]<ファイル番号>
Example
OPEN "SAMPL2.D" AS 1
OPEN "SAVE.D" FOR INPUT AS 1
OPEN FILENAME$ FOR APPEND AS FNUM
Parameter
<デバイス名>,<ファイル名>… Character string type
<ファイル番号>… Numerical value type of fixed zero point type. The range of an effective numerical value is a value of 1~2. (All the decimal parts are rounded down. )
Operation is detailed.
<デバイス名>File <ファイル番号>can be allocated .. <ファイル名>specification.. and the content be read and written. <デバイス名>However, the device used immediately before becomes an object when omitted. The following attributes are given by the key word specified since FOR.
.INPUT
The specified file only is for reading and opened. INPUT cannot be specified for the file that doesn't exist. Moreover, the extension is only a file of ". D" it is possible to read.
.OUTPUT
The specified file only is for a new writing and opened. The file is made at that time when OUTPUT is specified for the file that doesn't exist. The content of the file cannot be read when OUTPUT is done to an existing file, and the SEEK position becomes the first of the file.
.APPEND
The specified file only is for an additional writing and opened. APPEND cannot be specified for the file that doesn't exist. The SEEK position is moved to the end reading the content of the specified file to the file area.
When it is omitted since FOR, it is allocated in the file number as a file that can do reading and writing. The extension ". D" is added to the file made by the OPEN instruction.
Attention
The file is opened for writing that [FOR…] is omitted or reading. File already open happens when starting opening by the same file name as the file name that has already opened with the same device. Not enough space happens when 99 more files are made with the backup device.

Direct effective order indirect effect instruction of SAVE
Function
The program list is preserved.
Format
SAVE[<デバイス名>]<ファイル名>[,A]
Example
SAVE "SAMPLE"
SAVE "BRAM:MAIN"
SAVE F$
Parameter
<デバイス名>… Character string type. The character string that can be specified is limited thoroughly to the provided name.
<ファイル名>… Character string type. The character string that can be specified is limited to an effective character as a file name.
A … The program is written as data with the file of the text form that ". D" is put on the extension.
Operation is detailed.
<デバイス名>The program list is preserved in the device for which is specified by the file name that <ファイル名>specifies. <デバイス名>The character kind and the number of characters that can be <ファイル名>used apply to the file name rule.
<デバイス名>However, the device used immediately before becomes an object when omitted. ". B" of the file extension is automatically added to the file name of the preserved BASIC program. <デバイス名>However, FD0: FD1: BRAM: When "A" is put only for CRAM as an option, the program is written as data with the file of the text form that ". D" is put on the extension. This file can be read and written by the OPEN instruction.
Moreover, if the extension ". D" is specified by the LOAD instruction specifying it, it is possible to read as a program and to merge it (annexation).
Because SAVE" and A instruction use the file buffer to put the text file temporarily as well as the GSAVE instruction, it is necessary to secure independence a necessary size by the CLEAR instruction (In a word, a very large file cannot be written). The Out of memory error occurs when the size of BASIC text file that tries to be written is larger than that of the file buffer. As for the file buffer, the maximum unused (It is not open), buffer is temporarily used. After the buffer is used and this instruction is executed, it is liberated because SAVE" and A are concluded by this instruction and finish processing.
It is necessary that the buffer specify only the amount of the size of the data that will be written by the 2nd or the third parameter of the CLEAR instruction.
Reference
CLEAR

Direct effective order indirect effect instruction of SEEK
Function
The position where the file is read and written is specified.
Format
SEEK[#]<ファイル番号>,<位置>
Example
SEEK #1, 128
Parameter
<ファイル番号>… Numerical value type of fixed zero point type. The range of an effective numerical value is a value of 1~2(All the decimal parts are rounded down).
<位置>… Numerical value type in floating point. The range of the value is 0~2147483647 (&H7FFFFFFF). The fraction part is rounded down.
Operation is detailed.
The read and written position is specified for the file opened by the OPEN instruction. (OPEN FOR INPUT AS…) <ファイル名>occurs "Access past EOF" error if the position in which former size of the file is exceeded is specified when it begins to read a file and only it is for and it is opened. The content becomes irregular though the position in which the size of former file is exceeded can be specified by the SEEK instruction when opening to the file in a recordable mode.
If the <ファイル名> <ファイル名>file is opened by "OPEN AS" or "OPEN FOR OUTPUT AS", the size of the file becomes the largest size in which data is written regardless of the position of the SEEK instruction.
If the <ファイル名>file is opened by "OPEN FOR APPEND AS", the size of the file becomes the largest size in which data is written more than former size of the file though it is a position of the SEEK instruction. A present SEEK position can acquire the terminal position of the file in the LOF function in the LOC function.