News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
A

Large file access

Started by Arnaud, 20:52, 04 June 15

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Arnaud

Hello,
i'm trying to code with SDCC an adventure game like Zombi or Hurlements.
I'm currently working on the loading of the graphics, and i want to load from the disc the room at each move.

Thus i'm looking for a way to handle all graphics in only one file (too large to fit in memory), and i haven't found how access only to a part of the file.

I was thinking about using CASE_IN_CHAR, but i can't directly seek to the data and i must read all the previous bytes.

Any ideas ?  :D
Thanks for reading

TFM

You could use directly 512 Byte sectors of the floppy disc. What you need it read-sector and write-sector. Dunno if SDCC provides them, but you can easily use the RSX of the DOS for that.
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

arnoldemu

Quote from: TFM on 06:55, 05 June 15
You could use directly 512 Byte sectors of the floppy disc. What you need it read-sector and write-sector. Dunno if SDCC provides them, but you can easily use the RSX of the DOS for that.
No library for sdcc exists to read and write sectors using DOS but it could be made.


Prodatron

Quote from: Arnaud on 20:52, 04 June 15
Thus i'm looking for a way to handle all graphics in only one file (too large to fit in memory), and i haven't found how access only to a part of the file.

I was thinking about using CASE_IN_CHAR

Unfortunately AMSDOS doesnt provide random file access. The IN CHAR methode would be the only way to handle it without hacks, but this is terrible slow and therefore useless. If you want to stay Amsdos conform you have to put the data in different files. Using direct sector read would mean that you have to analyse the directorie entries directly as well.

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

Arnaud

#4
Well, the easiest solution is to create one file for one or two rooms, it's not great but i'll work.

Thanks.

Executioner

I think you can actually do CAS_IN_DIRECT with a smaller size to skip multiple bytes at a time, would be a lot quicker than CAS_IN_DIRECT. I'm not exactly sure how, it's been a long time since I did it, I think you may need to modify the file header in the AMSDOS data area while reading chunks.

Prodatron

Quote from: Executioner on 01:05, 02 July 15
I think you can actually do CAS_IN_DIRECT with a smaller size to skip multiple bytes at a time, would be a lot quicker than CAS_IN_DIRECT. I'm not exactly sure how, it's been a long time since I did it, I think you may need to modify the file header in the AMSDOS data area while reading chunks.
For Digitracker I used the IN/OUT_CHAR function to read/write "ASCII" files in a fast way. The trick was to read/write the bytes to/from the 2KB input/output buffer directly, updating the pointers and therefore using IN/OUT_CHAR only once every 2048 bytes. But it wasn't possible to really skip a part of a file, only to read it in different chunks.

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

Arnaud

Thanks for your suggestions, i'll try it.

Prodatron

If you are interested, I can dig out the code. It should be still somewhere.

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

Arnaud

#9
Of course i am interested  :D

Prodatron

Attached is the source code. Didn't have time yet to test it again, but you will get the idea.

There is an issue with accessing the Asmdos system variables directly at fixed addresses (#A79D etc.). This is probably a problem when additional ROMs have been installed.
I should put it into the CPC Wiki, then this can be fixed later.

GRAPHICAL Z80 MULTITASKING OPERATING SYSTEM

Arnaud

Thanks i'll try it.

m_dr_m

Quote from: Prodatron on 14:28, 11 July 15This is probably a problem when additional ROMs have been installed.

For you visitor from the future: I have floating-amsdos-compatible routines, battle tested in Orgams.
Can share if there is any interest.

Powered by SMFPacks Menu Editor Mod