I added a master SPI interface to Lionsystem in order to communicate with a SD Card and use it as a storage device.
So signals CCS, MOSI, MISO, SCLK were added.
Also 4 interrupt operations were added to send/receive from SPI and initialize, read/write to SD Card
INT 4 A0=11 Initialize spi sd card communications
INT 4 A0=12 Spi send/receive byte in A1, mode in A2 1=CS LOW 3=CS HIGH, read byte in A0
INT 4 A0=13 Read n sector in buffer, n in A1
INT 4 A0=14 Write sector from buffer to block in A1
The routines support 65536 blocks of 512 bytes each for a total capacity of 32MB storage per SD Card
Added the following Functions to Tiny Basic
SDINIT Initialize sd card returns 256 on success
SREAD(n) Read nth block in buffer, returns 256 on success.
SWRITE(n) Write nth block from buffer
The buffer area is currently fixed at address 8706 with 514 size (512 + 2 bytes CRC)
Update 30/3/2017
Implemented a simple file system to store Tiny Basic programs.
First Block keeps a list of 51 clusters of 64 blocks each (32K).
Cluster 0 is reserved for auto boot.
Clusters 1-50 are used to store basic programs usinf the following commands:
save n saves program in memory to cluster n
load n loads the programm from cluster n to memory
first a successful sd card initialization using the function SDINIT is needed.