1 /*  Copyright 2014-2016 James Laird-Wah
2     Copyright 2004-2006, 2013 Theo Berkau
3 
4     This file is part of Yabause.
5 
6     Yabause is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10 
11     Yabause is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15 
16     You should have received a copy of the GNU General Public License
17     along with Yabause; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
19 */
20 
21 #ifndef CD_DRIVE_H
22 #define CD_DRIVE_H
23 
24 #include "core.h"
25 #include "cdbase.h"
26 
27 struct CdState
28 {
29    u8 current_operation;//0
30    u8 q_subcode;//1
31    u8 track_number;//2
32    u8 index_field;//3
33    u8 minutes;//4
34    u8 seconds;//5
35    u8 frame;//6
36    //7 zero
37    u8 absolute_minutes;//8
38    u8 absolute_seconds;//9
39    u8 absolute_frame;//10
40    //11 parity
41    //12 zero
42 };
43 
44 struct CdDriveContext
45 {
46    s32 cycles_remainder;
47 
48    int num_execs;
49    int output_enabled;
50    int bit_counter;
51    int byte_counter;
52 
53    struct CdState state;
54    u8 state_data[13];
55    u8 received_data[13];
56    int received_data_counter;
57    u8 post_seek_state;
58 
59    CDInterfaceToc10 toc[103*3], tracks[100];
60    int toc_entry;
61    int num_toc_entries, num_tracks;
62 
63    u32 disc_fad;
64    u32 target_fad;
65 
66    int seek_time;
67    int speed;
68 };
69 
70 extern struct CdDriveContext cdd_cxt;
71 
72 
73 void cd_drive_exec(struct CdDriveContext * drive, s32 cycles);
74 u8 cd_drive_get_serial_bit();
75 void cd_drive_set_serial_bit(u8 bit);
76 void cd_drive_start_transfer();
77 void cdd_reset();
78 #endif
79