Detecting optical media type

Programming, for all ages and all languages.
Post Reply
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Detecting optical media type

Post by AndrewAPrice »

I'm curious as to how optical drives detect the type of media inserted. e.g. if I inserted a blank unformatted disc, how does my drive know if it's a 650MB cd, 700MB cd, single layer DVD+R , single layer DVD-R, etc? Is there some unwritable part of the disc where this information is stored?

I'm guessing the physical medium if different, but could I write to the disk somehow and have my drive believe a DVD+R disc is really a DVD-R disc? (although it would cause the disc to be unreadable)

The last question is how do games detect if the original disc is inserted? I always assumed games accessed the disc as a stream of bytes and that is all that is available to them. If so, how would something like DPM work?
My OS is Perception.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: Detecting optical media type

Post by Brynet-Inc »

For CD's, ATIP.

Not sure about other types of optical media, but I assume it's a similar concept.. ;)

Additional Linkage:
http://www.cdr-forum.de/download/cdr.pdf

EDIT: According to the cdrecord(1) man page from the cdrtools project: "DVD media does not have ATIP information but there is equivalent prerecorded information that is read out and printed."

So it prints out both ATIP and.. the unnamed DVD counterpart. ;)
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Detecting optical media type

Post by Troy Martin »

On the question of determining if the original disc has been inserted for a game, I'm going to take Age of Empires II as an example. The game's .exe (EMPIRES2.EXE) is a stub to check to see if there is a CD in the drive with the file EMPIRES2.ICD (or something like that) on it. If it is, the copy of EMPIRES2.ICD on the hard drive is ran as an executable, running the game.

Not sure about new games though, but I assume it's much more complex (I can't just go and rename a few files to play SimCity 4 without a CD :P).
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Re: Detecting optical media type

Post by bewing »

The tracks on optical discs are not multiples of 512bytes (or 2K or whatever nice power of 2 you want to contemplate).
The extra bytes on each track are called "subcodes". They can be accessed by special ATAPI read commands. A typical burning program has a default algorithm for calculating and burning the subcodes, and the burner hardware itself may also enforce the default algorithm.

Games use non-standard subcodes. They use the special read commands to make sure that the subcodes on the disk are "valid". So, to copy a game disk, you need a cloning program that reads and writes the non-standard subcodes, and you need a burner that does not try to "fix" your subcodes into the standard, generic subcode format.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: Detecting optical media type

Post by AJ »

Hi,

There are lots of different pieces of software out there to provide copy protection. Have a look here for a start. I have had issues with some copy protection in the past - not being able to play the game. I think this was with the Safedisc-protected Dungeon Keeper 2.

Cheers,
Adam
Post Reply