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

Looking for a Dragon or CoCo game not already in the archive - Then request it here and hopefully it will either be uploaded to the archive or another member can upload it to this forum.
Post Reply
pser1
Posts: 1668
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

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

Post 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
User avatar
snarkhunter
Posts: 241
Joined: Fri Apr 03, 2009 7:16 pm
Location: France

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

Post 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
User avatar
robcfg
Posts: 1531
Joined: Sat Apr 04, 2009 10:16 pm
Location: Stockholm, Sweden
Contact:

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

Post 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.
User avatar
rolfmichelsen
Posts: 299
Joined: Wed Apr 08, 2009 8:43 pm
Location: Oslo, Norway
Contact:

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

Post 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
prime
Posts: 267
Joined: Fri Apr 10, 2009 1:40 am

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

Post 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.
Post Reply