OSDN Git Service

[DOC] For release 2017-01-24.
[csp-qt/common_source_project-fm7.git] / source / src / vm / scsi_cdrom.h
1 /*
2         Skelton for retropc emulator
3
4         Author : Takeda.Toshiya
5         Date   : 2016.03.06-
6
7         [ SCSI CD-ROM drive ]
8 */
9
10 #ifndef _SCSI_CDROM_H_
11 #define _SCSI_CDROM_H_
12
13 #include "scsi_dev.h"
14
15 #define SIG_SCSI_CDROM_PLAYING  0
16 #define SIG_SCSI_CDROM_SAMPLE_L 1
17 #define SIG_SCSI_CDROM_SAMPLE_R 2
18
19 class FILEIO;
20
21 class SCSI_CDROM : public SCSI_DEV
22 {
23 private:
24         outputs_t outputs_done;
25         
26         FILEIO* fio_img;
27         struct {
28                 uint32_t index0, index1, pregap;
29                 bool is_audio;
30         } toc_table[1024];
31         int track_num;
32         
33         uint32_t cdda_start_frame, cdda_end_frame, cdda_playing_frame;
34         uint8_t cdda_status;
35         bool cdda_repeat, cdda_interrupt;
36         uint8_t cdda_buffer[2352 * 75];
37         int cdda_buffer_ptr;
38         int cdda_sample_l, cdda_sample_r;
39         int event_cdda, mix_loop_num;
40         
41         void set_cdda_status(uint8_t status);
42         int get_track(uint32_t lba);
43         double get_seek_time(uint32_t lba);
44         
45         int volume_m;
46         int volume_l, volume_r;
47         
48 public:
49         SCSI_CDROM(VM* parent_vm, EMU* parent_emu) : SCSI_DEV(parent_vm, parent_emu) 
50         {
51                 initialize_output_signals(&outputs_done);
52                 
53                 volume_m = 1024;
54                 volume_l = volume_r = 1024;
55                 
56                 my_sprintf_s(vendor_id, 9, "NECITSU");
57                 my_sprintf_s(product_id, 17, "SCSI-CDROM");
58                 device_type = 0x05; // CD-ROM drive
59                 is_removable = true;
60                 physical_block_size = 2352;
61                 logical_block_size = 2048;
62 //              seek_time = 400000; // 400msec (temporary)
63                 seek_time = 10.0;
64                 bytes_per_sec = 2048 * 75; // speed x1
65                 set_device_name(_T("SCSI CDROM"));
66         }
67         ~SCSI_CDROM() {}
68         
69         // common functions
70         void initialize();
71         void release();
72         void reset();
73         uint32_t read_signal(int id);
74         void event_callback(int event_id, int err);
75         void mix(int32_t* buffer, int cnt);
76         void set_volume(int ch, int decibel_l, int decibel_r);
77         void save_state(FILEIO* state_fio);
78         bool load_state(FILEIO* state_fio);
79         
80         // virtual scsi functions
81         void reset_device();
82         bool is_device_ready();
83         int get_command_length(int value);
84         void start_command();
85         void read_buffer(int length);
86         
87         // unique functions
88         void set_context_done(DEVICE* device, int id, uint32_t mask)
89         {
90                 register_output_signal(&outputs_done, device, id, mask);
91         }
92         void open_disc(const _TCHAR* file_path);
93         void close_disc();
94         bool is_disc_inserted();
95         void set_volume(int volume);
96 };
97
98 #endif
99