filename | src/gdrom/gdrom.h |
changeset | 168:203a72138e16 |
prev | 152:d42a4c5cc709 |
next | 237:6f1a429c9d12 |
author | nkeynes |
date | Mon Jun 26 10:30:42 2006 +0000 (17 years ago) |
permissions | -rw-r--r-- |
last change | Implement multi-format CD image support Fix CDI support up to (more or less) work |
view | annotate | diff | log | raw |
1 /**
2 * $Id: gdrom.h,v 1.7 2006-06-26 10:30:42 nkeynes Exp $
3 *
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
6 * system).
7 *
8 * Copyright (c) 2005 Nathan Keynes.
9 *
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.
14 *
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.
19 */
21 #ifndef dream_gdrom_H
22 #define dream_gdrom_H 1
24 #include "dream.h"
26 typedef uint16_t gdrom_error_t;
28 struct gdrom_toc {
29 uint32_t track[99];
30 uint32_t first, last, leadout;
31 };
33 #define GDROM_PREGAP 150 /* Sectors */
35 extern uint32_t gdrom_sector_size[];
36 #define GDROM_SECTOR_SIZE(x) gdrom_sector_size[x]
37 typedef enum {
38 GDROM_MODE1,
39 GDROM_MODE2,
40 GDROM_MODE2_XA1,
41 GDROM_MODE2_XA2,
42 GDROM_CDDA,
43 GDROM_GD,
44 GDROM_RAW
45 } gdrom_track_mode_t;
47 /* The disc register indicates the current contents of the drive. When open
48 * contains 0x06.
49 */
50 #define IDE_DISC_AUDIO 0x00
51 #define IDE_DISC_NONE 0x06
52 #define IDE_DISC_CDROM 0x20
53 #define IDE_DISC_GDROM 0x80
54 #define IDE_DISC_READY 0x01 /* ored with above */
55 #define IDE_DISC_IDLE 0x02 /* ie spun-down */
57 #define TRACK_PRE_EMPHASIS 0x10
58 #define TRACK_COPY_PERMITTED 0x20
59 #define TRACK_DATA 0x40
60 #define TRACK_FOUR_CHANNEL 0x80
62 struct gdrom_track {
63 gdrom_track_mode_t mode;
64 uint8_t flags; /* Track flags */
65 int session; /* session # containing this track */
66 uint32_t lba; /* start sector address */
67 uint32_t sector_size; /* For convenience, determined by mode */
68 uint32_t sector_count;
69 uint32_t offset; /* File offset of start of track - image files only */
70 };
73 typedef struct gdrom_disc {
74 int disc_type;
75 int track_count;
76 struct gdrom_track track[99];
77 gchar mcn[14]; /* Media catalogue number */
78 const gchar *filename; /* Image filename */
79 FILE *file; /* Stream, for image files */
80 gdrom_error_t (*read_sectors)( struct gdrom_disc *disc,
81 uint32_t lba, uint32_t sector_count,
82 int mode, char *buf, uint32_t *length );
83 void (*close)( struct gdrom_disc *disc );
84 } *gdrom_disc_t;
86 /**
87 *
88 */
89 typedef struct gdrom_image_class {
90 const gchar *name;
91 const gchar *extension;
92 gboolean (*is_valid_file)(FILE *f);
93 gdrom_disc_t (*open_image_file)(const gchar *filename, FILE *f);
94 } *gdrom_image_class_t;
96 extern struct gdrom_image_class nrg_image_class;
97 extern struct gdrom_image_class cdi_image_class;
99 /**
100 * Construct a new image file using the default methods.
101 */
102 gdrom_disc_t gdrom_image_new( FILE *file );
104 /**
105 * Open an image file
106 */
107 gdrom_disc_t gdrom_image_open( const gchar *filename );
109 /**
110 * Retrieve the disc table of contents, and write it into the buffer in the
111 * format expected by the DC.
112 * @return 0 on success, error code on failure (eg no disc mounted)
113 */
114 gdrom_error_t gdrom_get_toc( char *buf );
116 /**
117 * Retrieve the short (6-byte) session info, and write it into the buffer.
118 * @return 0 on success, error code on failure.
119 */
120 gdrom_error_t gdrom_get_info( char *buf, int session );
122 /**
123 * Shortcut to open and mount an image file
124 */
125 gdrom_disc_t gdrom_mount_image( const gchar *filename );
127 void gdrom_mount_disc( gdrom_disc_t disc );
129 void gdrom_unmount_disc( void );
131 gboolean gdrom_is_mounted( void );
133 uint32_t gdrom_read_sectors( uint32_t sector, uint32_t sector_count,
134 int mode, char *buf, uint32_t *length );
136 #endif
.