Question: LoadSD at nextlib.bas / NextBuilder v5

This is where most of us started. Classic Spectrum basic.

Moderator: Programming Moderators

Post Reply
Posts: 179
Joined: Thu Jun 01, 2017 11:13 am

Question: LoadSD at nextlib.bas / NextBuilder v5

Post by PiyoTaro » Sun May 19, 2019 9:12 am

NextBuilder v5
Questions about the "nextlib.bas" library.
Please answer my specific questions, as there is no such thing as a list of library functions.

I want to create a program that reads a part of a large file in the SD card.
The function "LoadSD (filename, address, size, offset)" is used in "LoadFromSD.BAS" of the "NextBuilder v5" sample.

I am trying to create a program that refers to files in 1 cluster 256 bytes.
As I do not know about the memory map, I will assume that there is a buffer of 256 bytes from address $E000 for the time being, and I think it will be the following description.
"LoadSD (" filename ", $E000, 256, offset)"

Can this function read beyond the end of the file?
And is there a function to know "size of file"?

User avatar
Posts: 70
Joined: Mon May 29, 2017 6:55 pm

Re: Question: LoadSD at nextlib.bas / NextBuilder v5

Post by emook » Mon May 20, 2019 7:19 pm


Yes you can put LoadSD in a loop and incrementally increase the offset to read 256 bytes from anywhere in the file.

LoadBMP uses this method of loading 16kb chunks into ram, eg :

Code: Select all

LoadSD(fname, $c000, $4000, pos) 

; do something with the data @ $c000

Loop until pos = 49152

It doesn't yet return the file size, if I add it that will change the way LoadSD would be called. There's also mcleod_ideafix's excellent esxdos examples that are located in the ZXBC\examples\esxdos folder. Its a bit larger but offers more information and control.
ZXorDIE NextBuild ZXBD Snapshot uploader ZXBasic Online Database

Post Reply