Search
lxdream.org :: lxdream/src/gdrom/gdrom.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/gdrom/gdrom.h
changeset 1296:30ecee61f811
prev1109:700c5ab26a63
author nkeynes
date Sat Jan 26 14:00:48 2013 +1000 (9 years ago)
permissions -rw-r--r--
last change Change glib includes to #include <glib.h> rather than the individual
headers, as recent glib versions are breaking on this
file annotate diff log raw
nkeynes@125
     1
/**
nkeynes@561
     2
 * $Id$
nkeynes@125
     3
 *
nkeynes@678
     4
 * This file defines the public structures and functions exported by the 
nkeynes@678
     5
 * GD-Rom subsystem
nkeynes@125
     6
 *
nkeynes@125
     7
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@125
     8
 *
nkeynes@125
     9
 * This program is free software; you can redistribute it and/or modify
nkeynes@125
    10
 * it under the terms of the GNU General Public License as published by
nkeynes@125
    11
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@125
    12
 * (at your option) any later version.
nkeynes@125
    13
 *
nkeynes@125
    14
 * This program is distributed in the hope that it will be useful,
nkeynes@125
    15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@125
    16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@125
    17
 * GNU General Public License for more details.
nkeynes@125
    18
 */
nkeynes@125
    19
nkeynes@678
    20
#ifndef lxdream_gdrom_H
nkeynes@678
    21
#define lxdream_gdrom_H 1
nkeynes@125
    22
nkeynes@678
    23
#include "lxdream.h"
nkeynes@678
    24
#include "hook.h"
nkeynes@1097
    25
#include "drivers/cdrom/defs.h"
nkeynes@1296
    26
#include <glib.h>
nkeynes@342
    27
nkeynes@736
    28
#ifdef __cplusplus
nkeynes@736
    29
extern "C" {
nkeynes@736
    30
#endif
nkeynes@736
    31
nkeynes@1101
    32
struct gdrom_toc {
nkeynes@1101
    33
    uint32_t track[99];
nkeynes@1101
    34
    uint32_t first, last, leadout;
nkeynes@1101
    35
};
nkeynes@1101
    36
nkeynes@1023
    37
#define GDROM_TOC_SIZE (102*4) /* Size of GDROM TOC structure */
nkeynes@1023
    38
#define GDROM_SESSION_INFO_SIZE 6 /* Size of GDROM session info structure */
nkeynes@1023
    39
#define GDROM_SHORT_STATUS_SIZE 14 /* Size of GDROM short status structure */
nkeynes@1023
    40
nkeynes@1097
    41
typedef gboolean (*gdrom_disc_change_hook_t)( cdrom_disc_t new_disc, const gchar *new_disc_name, void *user_data );
nkeynes@720
    42
DECLARE_HOOK(gdrom_disc_change_hook, gdrom_disc_change_hook_t);
nkeynes@138
    43
nkeynes@720
    44
typedef gboolean (*gdrom_drive_list_change_hook_t)( GList *drive_list, void *user_data );
nkeynes@720
    45
DECLARE_HOOK(gdrom_drive_list_change_hook, gdrom_drive_list_change_hook_t);
nkeynes@125
    46
nkeynes@138
    47
/**
nkeynes@138
    48
 * Open an image file
nkeynes@138
    49
 */
nkeynes@1097
    50
cdrom_disc_t gdrom_image_open( const gchar *filename );
nkeynes@245
    51
nkeynes@138
    52
/**
nkeynes@138
    53
 * Shortcut to open and mount an image file
nkeynes@433
    54
 * @return true on success
nkeynes@138
    55
 */
nkeynes@1109
    56
gboolean gdrom_mount_image( const gchar *filename, ERROR *err );
nkeynes@138
    57
nkeynes@1097
    58
void gdrom_mount_disc( cdrom_disc_t disc );
nkeynes@138
    59
nkeynes@138
    60
void gdrom_unmount_disc( void );
nkeynes@138
    61
nkeynes@138
    62
gboolean gdrom_is_mounted( void );
nkeynes@138
    63
nkeynes@1097
    64
cdrom_disc_t gdrom_get_current_disc();
nkeynes@464
    65
nkeynes@678
    66
const gchar *gdrom_get_current_disc_name();
nkeynes@678
    67
nkeynes@837
    68
const gchar *gdrom_get_current_disc_title();
nkeynes@837
    69
nkeynes@1023
    70
/**
nkeynes@1097
    71
 * Find the track which should be checked for the
nkeynes@1097
    72
 * dreamcast bootstrap - this is the first data track on the last
nkeynes@1097
    73
 * session (where there are at least 2 sessions). If a boot track
nkeynes@1097
    74
 * cannot be found, returns NULL.
nkeynes@1023
    75
 */
nkeynes@1097
    76
cdrom_track_t gdrom_disc_get_boot_track( cdrom_disc_t disc );
nkeynes@1023
    77
nkeynes@1023
    78
/** 
nkeynes@1023
    79
 * Check if the disc contains valid media.
nkeynes@1097
    80
 * @return CDROM_ERROR_OK if disc is present, otherwise CDROM_ERROR_NODISC
nkeynes@1023
    81
 */
nkeynes@1097
    82
cdrom_error_t gdrom_check_media( );
nkeynes@678
    83
nkeynes@613
    84
/**
nkeynes@678
    85
 * Retrieve the disc table of contents, and write it into the buffer in the 
nkeynes@678
    86
 * format expected by the DC.
nkeynes@1023
    87
 * @param buf Buffer to receive the TOC data, which must be at least
nkeynes@1023
    88
 * GDROM_TOC_SIZE bytes long.
nkeynes@1023
    89
 * @return 0 on success, error code on failure (eg no disc)
nkeynes@613
    90
 */
nkeynes@1097
    91
cdrom_error_t gdrom_read_toc( unsigned char *buf );
nkeynes@678
    92
nkeynes@678
    93
/**
nkeynes@678
    94
 * Retrieve the short (6-byte) session info, and write it into the buffer.
nkeynes@1023
    95
 * @param session The session to read (numbered from 1), or 0 
nkeynes@1023
    96
 * @param buf Buffer to receive the session data, which must be at least
nkeynes@1023
    97
 * GDROM_SESSION_INFO_SIZE bytes long.
nkeynes@678
    98
 * @return 0 on success, error code on failure.
nkeynes@678
    99
 */
nkeynes@1097
   100
cdrom_error_t gdrom_read_session( int session, unsigned char *buf );
nkeynes@1023
   101
nkeynes@1023
   102
/**
nkeynes@1023
   103
 * Generate the position data as returned from a STATUS(1) packet. 
nkeynes@1023
   104
 * @param disc The disc to read
nkeynes@1023
   105
 * @param lba The current head position
nkeynes@1023
   106
 * @param buf The buffer to receive the position data, which must be at least
nkeynes@1023
   107
 * GDROM_SHORT_STATUS_SIZE bytes long.
nkeynes@1023
   108
 * @return 0 on success, error code on failure.
nkeynes@1023
   109
 */
nkeynes@1097
   110
cdrom_error_t gdrom_read_short_status( uint32_t lba, unsigned char *buf );
nkeynes@1097
   111
nkeynes@1097
   112
/**
nkeynes@1097
   113
 * Read sectors from the current disc.
nkeynes@1097
   114
 * @param lba Address of first sector to read
nkeynes@1097
   115
 * @param count Number of sectors to read
nkeynes@1097
   116
 * @param read_mode GDROM format read-mode
nkeynes@1097
   117
 * @param buf Buffer to receive read sectors
nkeynes@1097
   118
 * @param length If not null, will be written with the number of bytes read.
nkeynes@1097
   119
 * @return 0 on success, otherwise error code.
nkeynes@1097
   120
 */
nkeynes@1097
   121
cdrom_error_t gdrom_read_cd( cdrom_lba_t lba, cdrom_count_t count,
nkeynes@1097
   122
                             unsigned read_mode, unsigned char *buf, size_t *length );
nkeynes@1097
   123
nkeynes@1097
   124
cdrom_error_t gdrom_play_audio( cdrom_lba_t lba, cdrom_count_t count );
nkeynes@1023
   125
nkeynes@1023
   126
/**
nkeynes@1023
   127
 * Return the 1-byte status code for the disc (combination of IDE_DISC_* flags)
nkeynes@1023
   128
 */
nkeynes@1097
   129
int gdrom_get_drive_status( );
nkeynes@678
   130
nkeynes@709
   131
/**
nkeynes@1097
   132
 * Run GDROM time slice (if any)
nkeynes@709
   133
 */
nkeynes@1097
   134
void gdrom_run_slice( uint32_t nanosecs );
nkeynes@709
   135
nkeynes@736
   136
#ifdef __cplusplus
nkeynes@736
   137
}
nkeynes@125
   138
#endif
nkeynes@736
   139
nkeynes@736
   140
#endif /* !lxdream_gdrom_H */
.