Platform ZX Basic Driver
The library "zxbasdrv" (ZX BASIC driver) provides simple file access facilities (fopen, fread, etc) for the ZX Spectrum, by including a piece of ZX BASIC code within the compiled program binary. This ZX BASIC code is written to talk to a particular type of disk expansion hardware on behalf of the compiled code. "zxbasdrv" also forms a simple hardware abstraction layer for other purposes such as hardcopy printing to paper.
There are samples for a few different disk expansion systems in the z88dk/support/zx/zxbasdrv directory. If a hardware interface doesn't support streams, then only the block LOAD and SAVE functions need to be implemented.
The machine code part of the library extracts a drive path from the file names, so you can specify them with an MS-DOS like syntax.
Valid examples for file names are:
"a:filename" (drive #1)
"H:filename" .. i.e. 8th microdrive
"filename" (the file will be searched in drive #1)
"2:filename" ..numbers are allowed, too !
"P::" Printer device on stream #3
The 'appmake' tool has been extended to permit to pick a BASIC program from a TAP file and merge it with the loader. Such feature makes easier the linkage of a driver at compile time, like in the following example:
zcc +zxansi -lzxbasdrv -create-app -zorg=27000 -Cz--merge -Czc:\if1.tap program.c
You may notice that the 'zxbasdrv' library has been specified and that the '--merge' option is used to pass the appropriate BASIC portion to 'appmake'.
Description of the BASIC program line numbers corresponding to the various driver functions
(just after the LOAD CODE command) set d=
s$ = Name/Description
s=stream number (4-15); the ASM part detects the existence of the channel and handles a "file not found" condition if it is missing
f=mode flag (0=read, 256=write, etc..)
d=drive number (it is extracted from the file name, see above)
n$=file name
s=stream number
a=address or 0 if unspecified
l=length or 0 if unspecified
d=drive number
n$=file name
a=address
l=length
d=drive number
n$=file name
Optionally you can handle a "file name" to redirect the printer output. This entry works as a sort of "OPEN" command, but the stream number must be forced to #3.
Here the drivers should normally just close the stream #3.
Do hardcopy (or dump screen to file, or whatever you prefer)
d=drive number
n$=file name
d=drive number
n$=old file name
o$=new file name
- Overview
- Platform List
- Unsupported Platforms
- i8080/5 Support
- Homebrew hardware quickstart
- Retargetting
- Building the libraries
- Clang support
- Pragmas
- Adding to Classic
- Introduction
- Library Configuration
- CRT
- Header Files
- Assembly Language
- Library in Depth
- Embedded Platform
- Adding to NewLib
- Benchmarks
- Datatypes
- Debugging
- Decompression
- More than 64k
- Deficiencies
- Compiling Larger Applications
- Importing routines written in 8080 assembly mnemonics
- Using CP/M libraries in REL format with z88dk
- Writing optimal code
- Speeding up Compilation
- CMake usage