Can just ONE byte be read from disk?

Hardware Hacking, Programming and Game Solutions/Cheats
Post Reply
pser1
Posts: 1202
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Can just ONE byte be read from disk?

Post by pser1 » Fri Jan 11, 2019 12:55 pm

Hello,
I was trying to read the contents of a binary file but as there could be any value ($00 - $ff) reading variables / strings seems to fail ...
Does anybody know of a trick to emulate the C getc function?
Thanks in advance
pere

Pd The file is big enough to make it difficult to load it into memory and then access the desired bytes ...

User avatar
robcfg
Posts: 1221
Joined: Sat Apr 04, 2009 10:16 pm
Location: Stockholm, Sweden

Re: Can just ONE byte be read from disk?

Post by robcfg » Fri Jan 11, 2019 3:48 pm

I think the smallest size you can read from disk is a sector, or 256 bytes.

You can emulate getc’s behaviour by allocating a buffer, reading a sector there and triggering a new read from disk when reading the last byte from the buffer.

pser1
Posts: 1202
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: Can just ONE byte be read from disk?

Post by pser1 » Fri Jan 11, 2019 4:25 pm

robcfg wrote:I think the smallest size you can read from disk is a sector, or 256 bytes.
You can emulate getc’s behaviour by allocating a buffer, reading a sector there and triggering a new read from disk when reading the last byte from the buffer.
Right, but this implies you know what sector you need to read first!
Of course this info exists in the directory entry for that file, but it is not very user friendly becuase the file can be partitioned in
various chunks so you have to keep track of the way it is distributed in the disk. Not an easy task indeed
thanks a lot
pere

pser1
Posts: 1202
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: Can just ONE byte be read from disk?

Post by pser1 » Fri Jan 11, 2019 7:13 pm

Hi Roberto Carlos,
it seems that I am able to 'open' the file and make it read sectors from assembler.
It creates a FIB with a buffer area (256) so I could be taking bytes from there one by one
and I must be controlling the end of the buffer in order to ask for next sector.
This last part is not yet implemented, but it seems doable.
Thanks a lot
pere

pser1
Posts: 1202
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: Can just ONE byte be read from disk?

Post by pser1 » Fri Jan 11, 2019 10:03 pm

Hi Roberto Carlos,
it seems it was easier than I had thought!
Right now I have a ml program that reads the long file (screen definitions from an AGD program) and shows the data
one row at a time on the text screen.
Need to verify that the whole screen is shown alright (number of rows) and then the more interesting part will be
drawing a graphic screen using the file that contains the blocks, loading it into RAM (it is short, aprox 1520 bytes)
Once done, maybe we could 'edit' a block at a time and see the effect immediately!
will keep in contact
cheers
pere

bluearcus
Posts: 44
Joined: Wed Sep 07, 2016 4:45 pm

Re: Can just ONE byte be read from disk?

Post by bluearcus » Mon Feb 11, 2019 2:19 pm

Have a look at the DOS command. I think this does a two byte read, to check for the presence of the boot track signature. So a one byte read, or any other number should be possible, assuming you only want to start at the beginning of the sector.

I don't think the disk controller is able to allow presentation of the data from an arbitrary point in the sector though.

pser1
Posts: 1202
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: Can just ONE byte be read from disk?

Post by pser1 » Mon Feb 11, 2019 5:37 pm

Hello,
I forgot to say that everything went alright and so I have made a graphics editor that allows the users
to modify the elements of any AGD game, I mean blocks/tiles, sprites, obects and fonts.
In fact this 'new' part is going to be added to the GitHub as part of the production toolchain we are using
to convert the SNA/AGD games for the 6809 (CoCo and Dragon)
regards
pere

Post Reply