Question about LBA value computing in CLoneCD CCD file.

Discussion in 'CloneCD' started by DocMX7, Jul 19, 2019.

  1. DocMX7

    DocMX7 Member

    Hi,

    Those days, I try to code a little thing to parse a .CCD file.
    I am sure that people here are very comfortable with some definitions
    I am about to tell : it is only to clarify the subject of my question.

    I start from the fact that time in CCD file is indicated by 3 fields :

    - Minute
    - Second
    - Frame

    These time information is present twice on a section called "Entry".

    An example below :

    [Entry 8]
    Session=1
    Point=0xc1
    ADR=0x05
    Control=0x00
    TrackNo=0
    AMin=4
    ASec=152
    AFrame=96
    ALBA=29346

    Zero=0
    PMin=0
    PSec=0
    PFrame=0
    PLBA=-150


    AMin, ASec, AFrame to indicate Absolute time (I think).
    PMin, PSec, PFrame to indicate Point time (I think).

    In a theoretical point of view, there are means to translate a time to an address.
    The address is called LBA (Logical Block Address) and there are ALBA to indicate Absolute address and PLBA to indicate Point address.

    As I want is to deal with the less fields and datas in my code, I take only Minute, Second, Frame values
    and later use means to compute address value.

    I know two means to compute it :

    - a translation table between LBA and MSF found in a file called "SCSI-3 – Multimedia Commands" from "American National Standards Institute" page 115.

    - a formula from ECMA-394 Chapter 13: Attachment 11 :
    LBN = (((MIN*60)+SEC)*75+FRAMES)-150

    But quickly I face very confusing LBA values that do not match any known means result.

    Let's concentrate about Absolute time and Absolute address.

    I have selected three (from many) examples where I could not understand
    how CloneCd figure it out.

    Problem 1

    [Entry 8]
    Session=1
    Point=0xc1
    ADR=0x05
    Control=0x00
    TrackNo=0
    AMin=4
    ASec=152
    AFrame=96
    ALBA=29346

    Zero=0
    PMin=0
    PSec=0
    PFrame=0
    PLBA=-150


    AMin=4
    ASec=152
    AFrame=96
    ALBA=29346

    Using LBA to MSF transaltion table :
    29346<=> 60:00:48
    Using ECMA formula :
    (((4 * 60) + 152) * 75 + 96) - 150 = 29346

    Problem 2

    [Entry 10]
    Session=2
    Point=0xb0
    ADR=0x05
    Control=0x04
    TrackNo=0
    AMin=255
    ASec=255
    AFrame=255
    ALBA=716730

    Zero=1
    PMin=79
    PSec=59
    PFrame=73
    PLBA=359848


    AMin=255
    ASec=255
    AFrame=255
    ALBA=716730

    Using LBA to MSF transaltion table :
    impossible because 255 is out of range
    Using ECMA formula :
    (((255 * 60) + 255) * 75 + 255) - 150 = 1166730

    Problem 3

    [Entry 5]
    Session=1
    Point=0xc0
    ADR=0x05
    Control=0x04
    TrackNo=0
    AMin=160
    ASec=0
    AFrame=48
    ALBA=269898

    Zero=0
    PMin=97
    PSec=26
    PFrame=66
    PLBA=-11634


    AMin=160
    ASec=0
    AFrame=48
    ALBA=269898

    Using LBA to MSF transaltion table :
    269898 <=> 60:00:48
    Using ECMA formula :
    (((160 * 60) + 0) * 75 + 48) - 150 = 719898

    How CloneCd compute ALBA in those case (PLBA should have same issue) ?

    Thanks in advance for any help.
     
  2. James

    James Redfox Development Team Staff Member

    I think the Min/Sec/Fra fields are taken 1:1 from the TOC of the source disc. I don't think they are used by CloneCD, except when writing a raw copy to create a TOC most similar to the source. (It may be a copy protection?)
    E.g.
    AMin=255
    ASec=255
    AFrame=255

    are 0xFF, 0xFF, 0xFF in hex and have some special meaning....? (which I forgot).

    I believe the lba values are not calculated from the min/sec/fra values, but the drive is asked with a different command.
     
  3. DocMX7

    DocMX7 Member

    Thanks for your answer.

    Did you have an idea about the command used to ask the drive LBA ?
    It should be a standard command and standard command are documented on MMC.
    It will help me figuring out algorithm used in LBA computation.

    Regards.
     
  4. James

    James Redfox Development Team Staff Member

    I would guess READ TOC/PMA/ATIP is the only possible command (op code 0x43)

    EDIT: I don't think it uses read track information (op code 0x52).
     
  5. DocMX7

    DocMX7 Member

    Thanks, I'm going to dig in that direction !