DSKI$()
This page was last modified 20:49, 13 January 2022 by NYYRIKKI. Based on work by Mars2000you and Gdx and others.

Contents

Effect

Reads a sector (512 bytes) of the disk inserted in the specified drive and loads the data to a temporary buffer pointed by addresses &HF351 and &HF352.

The function itself always returns an empty string as maximum string space (255 bytes) is too small to store the sector.

Initially, only integer (16 bit) sector numbers are accepted. However, version 3 of Disk BASIC, provided by the Nextor operating system version 2.0 and higher, accepts 32 bit sector numbers when used in MSX-DOS 2 mode, therefore allowing access to any drive sector, not only the first 65536 sectors of mass storage devices.

Syntax

DSKI$(<DriveNumber>,<SectorNumber>)

Parameters

<DriveNumber> is a value between 0 and 8, according the following table:

Number Drive
0 Default drive
1 Drive A
2 Drive B
3 Drive C
4 Drive D
5 Drive E
6 Drive F
7 Drive G
8 Drive H


<SectorNumber> can vary between 0 and a maximum that depends from the used drive to format the disk. The highest possible maximum on MSX for floppy disks is 719 for single sided disks and 1439 for double sided disks. Initially, it can only be integer numbers.

If you use the Nextor OS in MSX-DOS 2 mode:

  • You can reach any sector of mass storage devices: in order to access sectors with numbers over 32767, the sector number must be specified as a single or double precision constant, expression or variable. If a single precision value is specified and the number is so big that one or more of the least significant digits of the number is lost due to truncation, you will get an "Overflow" error. In such cases or to access arbitrary sector numbers in your BASIC code, using double precision variables will provide a safe solution.
  • Note that an "Overflow" error will be thrown too if the sector number specified does not fit in 32 bits, that is, if it is greater than 4294967295.
  • In order to maintain compatibility with the MSX-DOS equivalent command, negative sector numbers are accepted (to which 65536 is added to get the real sector number) but only if the sector number can be evaluated as an integer (16 bit) expression.

Examples

10 X$ = DSKI$(0,0)
20 AD = PEEK(&HF351)+PEEK(&HF352)*256
30 FOR I=0 TO 511:PRINT PEEK(AD+I);:NEXT

Only if you use Nextor in MSX-DOS 2 mode:

10 DEFDBL S
20 S=12345678
30 PRINT S 
40 PRINT DSKI$(0, S)
10 DEFINT S
20 S=-1
30 PRINT DSKI$(0, S)
10 ' Boot sector info (By: NYYRIKKI)
20 MAXFILES=2:OPEN"NUL"AS1:FIELD1,3ASJP$,8ASN$,2ASBS$,1ASSC$,2ASRS$,1ASFS$,2ASRD$,2ASTS$,1ASMD$,2ASSF$,2ASST$,2ASDS$:CLOSE
30 M=VARPTR(JP$):POKE&HF351,PEEK(M+1):POKE&HF352,PEEK(M+2)
40 CLS:PRINT"Disk information"+DSKI$(0,0)
50 PRINT"----------------"
60 PRINT"Media descriptor:"," ";HEX$(ASC(MD$))
70 PRINT"OEM name:",," ";N$
80 PRINT"Heads:",,CVI(DS$)
90 PRINT"Sectors / Track:",CVI(ST$)
100 PRINT"Bytes/Sector:",,CVI(BS$)
110 PRINT"Sectors/Cluster:",ASC(SC$)
120 PRINT"Reserved Sectors:",CVI(RS$)
130 PRINT"Total Sectors:",CVI(TS$)
140 PRINT"Number of FATs:",ASC(FS$)
150 PRINT"Sectors / FAT:",CVI(SF$)
160 PRINT"Root dir entries:",CVI(RD$)

Related to

DSKO$

Compatibility

Disk BASIC 1.0 or higher / both modes of Nextor OS but 32 bit sector numbers and 16 bit negative sector numbers only accepted in MSX-DOS 2 mode