News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_roudoudou

AMSDOS header complete description

Started by roudoudou, 08:45, 13 December 17

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

roudoudou

Hi, i'm looking for a detailed description of AMSDOS header


I found this one but it seems to be very incomplete! A file with this kind of header does not load without loading adress!


When i look on a DSK generated with an emulator, i see the filename again with the extension replaced by #24,#24,#24 (wtf???)


Anyone know how to do this? Demoniak?  :P





        /***  cpcwiki                   
        Byte 00: User number
        Byte 01 to 08: filename
        Byte 09 bis 11: Extension
        Byte 18: type-byte
        Byte 21 and 22: loading address
        Byte 24 and 25: file length
        Byte 26 and 27: execution address for machine code programs
        Byte 64 and 65: (file length)
        Byte 67 and 68: checksum for byte 00 to byte 66
        To calculate the checksum, just add byte 00 to byte 66 to each other.
        */



In fact the cpcwiki page indicated -> This is only a summary. All details are in Firmware Guide chapter 9, page 4.

[/color]But the firmware guide has no chapter :-\
My pronouns are RASM and ACE

Docent

#1
Quote from: roudoudou on 08:45, 13 December 17
Hi, i'm looking for a detailed description of AMSDOS header


I found this one but it seems to be very incomplete! A file with this kind of header does not load without loading adress!


When i look on a DSK generated with an emulator, i see the filename again with the extension replaced by #24,#24,#24 (wtf???)


Anyone know how to do this? Demoniak?  :P





        /***  cpcwiki                   
        Byte 00: User number
        Byte 01 to 08: filename
        Byte 09 bis 11: Extension
        Byte 18: type-byte
        Byte 21 and 22: loading address
        Byte 24 and 25: file length
        Byte 26 and 27: execution address for machine code programs
        Byte 64 and 65: (file length)
        Byte 67 and 68: checksum for byte 00 to byte 66
        To calculate the checksum, just add byte 00 to byte 66 to each other.
        */



In fact the cpcwiki page indicated -> This is only a summary. All details are in Firmware Guide chapter 9, page 4.

[/color]But the firmware guide has no chapter :-\

Make sure that the length of the file is stored in bytes 64,65,66 as 24bit value and then calc the checksum
Check out soft158A - DDI firmware - chapter 3.3 for details.


demoniak

Here is the structure used in ManageDsk :

typedef struct
    {
    BYTE    UserNumber;             // User
    BYTE    FileName[ 15 ];         // Nom + extension
    BYTE    BlockNum;               // Numéro du premier bloc (disquette)
    BYTE    LastBlock;              // Numéro du dernier bloc (disquette)
    BYTE    FileType;               // Type de fichier
    USHORT  Length;                 // Longueur
    USHORT  Adress;                 // Adresse
    BYTE    FirstBlock;             // Premier bloc de fichier (disquette)
    USHORT  LogicalLength;          // Longueur logique
    USHORT  EntryAdress;            // Point d'entrée
    BYTE    Unused[ 0x24 ];
    USHORT  RealLength;             // Longueur réelle
    BYTE    BigLength;              // Longueur réelle (3 octets)
    USHORT  CheckSum;               // CheckSum Amsdos
    BYTE    Unused2[ 0x3B ];
    } StAmsdos;

roudoudou


OK, found the bug, was computing checksum with signed values, now all is correct  :laugh:

The curious thing is that AMSDOS do not verify checksum when loading to an adress, only when loading without parameter for destination adress  :o


Demoniak, when i create an empty DSK with managedsk and put a screen (done with convimgcpc) I do not see the informations firstblock, lastblock, it may be tape specific!

Another curious thing with ManageDSK. If there is a digit in the name, it's stored #10 + digit instead of ASCII char (#30+digit) but it works!





My pronouns are RASM and ACE

GUNHED

Quote from: roudoudou on 08:45, 13 December 17
Hi, i'm looking for a detailed description of AMSDOS header

That's what I know:
http://futureos.cpc-live.com/files/FutureOS%20Handbook.docx

Go to page 38, it describes the Amsdos header :-)
http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

arnoldemu

Use soft 968 section 9 and section 8 together (and 15)

I will also point you at my work in progress for section 15 (see the amsdos versions of cas in char etc for more information). I am continuing to typeset this document - I need to correct all the headings and adjust some spacing to match the original document:

http://www.cpctech.org.uk/s968se15.pdf

My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

roudoudou

thank you all


i updated a little the cpcwiki page about amsdos header
My pronouns are RASM and ACE

ikonsgr

I just discover something strange about header information.
I have most of amstrad games in "real" file form (e.g. unpacked from the dsk image containers, and have the real files in folders), and noticed something that i can't quite understand. In thoery, total length of a file would be 128(length of header)+data length, right?
Well,i noticed that almost all files, have a real length, bigger than this! For instance,a BAS file where header bytes 24+25 ,declare 81 bytes of data length (so it should have  128+81=209 bytes of total length), is actually 384 byte! And this goes for almost any file i looked at (only a couple of files had real length=128+data length).
So, am i missing something here? Is there any extra bytes that are added to the "128+data length" size?
And if i want to read all data from a file correctly, what should i do? Start from byte 128, up to the data length given by header bytes 24+25, or up to the end of file?

GUNHED

This is because files get saved as a multiple of 128 bytes. One block of 128 bytes is also called a record, and this record number is used in directory entries.

http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

ikonsgr

#9

I also thought so, but many files where many times bigger than a round up to 128.I make a bit more investigation and discover that in practice,everything above 128+data length size is ignored. I use cpcdiskxp to create an empty dsk image and then tried to add the BAS file i told you about, which size appeared to be 384byte in windows. And guess what, cpcdiskxp appear it in his directory window as 209bytes! That is 128+data length from 24+25header bytes, ignoring the rest! Same goes with 4-5 different files i test, binary or basic. Ofcourse the "cutted" files was working just fine! I also tried to extract files from dsk images i already have, and they appear with correct size in windows folder.
As all the files i tried where from an old version of cpc loader from 2010,i guess maybe something went wrong with the extraction...  ::)   
I tried to download the newer cpcgamescd from cpcwiki mirror page but it says that file is damaged...  :(

GUNHED

Sorry, you really should work on real hardware, lot's of PC tools to work with DSKs have bugs.
The record number is written at byte 15 of any directory entry (additional bytes if file has more than 128 records of 128 bytes).

http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

ikonsgr

It must be some bug in the batch "dsk to files" extraction procedure of the cpcload. But since i can determine the size of data from header bytes 24+25, i really don't care about this! ;-)

Powered by SMFPacks Menu Editor Mod