Page 1 of 1

How to read a file from disc, just one byte at a time

Posted: Sat Nov 02, 2013 3:40 pm
by pser1
Hello,
I am trying to read not text files from disk with the commands FLREAD and FREAD but these always truncate the reading when bytes like $0D or $00 ar reached, or commas found.
So, I was thinking that maybe I could read just one byte at a time, like we can do in PC languages (C, C++, Java ...), but haven't found a way to do it.
Has anybody had and solved this kind of problem?
I wouldn't mind to use assembler language, but hate to look for the entry in the directory track and then search for each used sector to load them in a user buffer, that hopefully could be read byte by byte.
Thanks in advance!
best regards
have a nice week-end
Pere

Re: How to read a file from disc, just one byte at a time

Posted: Sun Nov 03, 2013 9:06 am
by snarkhunter
Hello,

The standard Dragon ROM does have some routines to read single bytes or bits from tape. There is some sample code about achieving this in section 8.4.4 of 'Inside The Dragon'.

So I'd say it's likely there are similar features in DragonDOS. Unfortunately, not having any disassembled DragonDOS currently available, it is pretty difficult for me to confirm this. But Ii do believe someone else here will be able to do so.

Kind regards,
Lionel

Re: How to read a file from disc, just one byte at a time

Posted: Sun Nov 03, 2013 10:17 am
by robcfg
I think that the smallest thing you can read from disc is a 256-byte sector into two 128-byte strings.

Once you have read the sector, you can take your bytes one by one from the strings.

Re: How to read a file from disc, just one byte at a time

Posted: Sun Nov 03, 2013 11:41 am
by rolfmichelsen
From BASIC the smallest unit you can read is a sector into two 128 byte strings, as robcfg points out. The trick is to figure out which sector to read.

If you are willing to use machine code, there is a ROM routine to read raw data from a file. See the READ routine located at [$C014] documented in DragonDos; A Programmer's Guide. The booklet is available from the archive.

-- Rolf

Re: How to read a file from disc, just one byte at a time

Posted: Mon Nov 04, 2013 4:39 pm
by prime
rolfmichelsen wrote:From BASIC the smallest unit you can read is a sector into two 128 byte strings, as robcfg points out. The trick is to figure out which sector to read.

If you are willing to use machine code, there is a ROM routine to read raw data from a file. See the READ routine located at [$C014] documented in DragonDos; A Programmer's Guide. The booklet is available from the archive.

-- Rolf
And please if you are going to call it do so by calling the indirect this means it should work with other versions of DOS.

e.g. JSR [$C014]

Cheers.

Phill.