2 * $Id: gdrom.h,v 1.2 2006-04-30 01:51:08 nkeynes Exp $
4 * This file defines the structures and functions used by the GD-Rom
5 * disc driver. (ie, the modules that supply a CD image to be used by the
8 * Copyright (c) 2005 Nathan Keynes.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
22 #define dream_gdrom_H 1
28 uint32_t first, last, leadout;
31 #define GDROM_PREGAP 150 /* Sectors */
33 extern uint32_t gdrom_sector_size[];
34 #define GDROM_SECTOR_SIZE(x) gdrom_sector_size[x]
44 /* The disc register indicates the current contents of the drive. When open
47 #define IDE_DISC_AUDIO 0x00
48 #define IDE_DISC_NONE 0x06
49 #define IDE_DISC_CDROM 0x20
50 #define IDE_DISC_GDROM 0x80
51 #define IDE_DISC_READY 0x01 /* ored with above */
52 #define IDE_DISC_IDLE 0x02 /* ie spun-down */
55 gdrom_track_mode_t mode;
56 int session; /* session # containing this track */
57 uint32_t lba; /* start sector address */
58 uint32_t sector_size; /* For convenience, determined by mode */
59 uint32_t sector_count;
60 uint32_t offset; /* File offset of start of track - image files only */
64 typedef struct gdrom_disc {
67 struct gdrom_track track[99];
68 gchar mcn[14]; /* Media catalogue number */
69 const gchar *filename; /* Image filename */
70 FILE *file; /* Stream, for image files */
71 uint32_t (*read_sectors)( struct gdrom_disc *disc,
72 uint32_t lba, uint32_t sector_count,
74 void (*close)( struct gdrom_disc *disc );
78 * Construct a new image file using the default methods.
80 gdrom_disc_t gdrom_image_new( FILE *file );
85 gdrom_disc_t gdrom_image_open( const gchar *filename );
86 gdrom_disc_t nrg_image_open( const gchar *filename );
89 * Retrieve the disc table of contents, and write it into the buffer in the
90 * format expected by the DC.
91 * @return TRUE on success, FALSE on failure (eg no disc mounted)
93 gboolean gdrom_get_toc( char *buf );
96 * Shortcut to open and mount an image file
98 gdrom_disc_t gdrom_mount_image( const gchar *filename );
100 void gdrom_mount_disc( gdrom_disc_t disc );
102 void gdrom_unmount_disc( void );
104 gboolean gdrom_is_mounted( void );
106 uint32_t gdrom_read_sectors( uint32_t sector, uint32_t sector_count,
.