]> Shamusworld >> Repos - virtualjaguar/blob - src/cdrom.cpp
Initial revision
[virtualjaguar] / src / cdrom.cpp
1 #include "include/cdrom.h"
2
3 //#define CDROM_LOG
4
5 static uint8  cdrom_ram[0x100];
6 static uint16  cdrom_cmd=0;
7
8 //////////////////////////////////////////////////////////////////////////////
9 //
10 //////////////////////////////////////////////////////////////////////////////
11 //
12 //
13 //
14 //
15 //
16 //
17 //////////////////////////////////////////////////////////////////////////////
18 void cdrom_init(void)
19 {
20 }
21 //////////////////////////////////////////////////////////////////////////////
22 //
23 //////////////////////////////////////////////////////////////////////////////
24 //
25 //
26 //
27 //
28 //
29 //
30 //////////////////////////////////////////////////////////////////////////////
31 void cdrom_reset(void)
32 {
33         memset(cdrom_ram,0x00,0x100);
34         cdrom_cmd=0;
35
36 }
37 //////////////////////////////////////////////////////////////////////////////
38 //
39 //////////////////////////////////////////////////////////////////////////////
40 //
41 //
42 //
43 //
44 //
45 //
46 //////////////////////////////////////////////////////////////////////////////
47 void cdrom_done(void)
48 {
49 }
50 //////////////////////////////////////////////////////////////////////////////
51 //
52 //////////////////////////////////////////////////////////////////////////////
53 //
54 //
55 //
56 //
57 //
58 //
59 //////////////////////////////////////////////////////////////////////////////
60 void cdrom_byte_write(uint32 offset, uint8 data)
61 {
62         offset&=0xff;
63         cdrom_ram[offset]=data;
64
65 #ifdef CDROM_LOG
66         fprintf(log_get(),"cdrom: writing byte 0x%.2x at 0x%.8x\n",data,offset);
67 #endif
68 }
69 //////////////////////////////////////////////////////////////////////////////
70 //
71 //////////////////////////////////////////////////////////////////////////////
72 //
73 //
74 //
75 //
76 //
77 //
78 //////////////////////////////////////////////////////////////////////////////
79 void cdrom_word_write(uint32 offset, uint16 data)
80 {
81         offset&=0xff;
82         cdrom_ram[offset+0]=(data>>8)&0xff;
83         cdrom_ram[offset+1]=data&0xff;
84                 
85         // command register
86 /*
87         if (offset==0x0A)
88         {
89                 cdrom_cmd=data;
90                 if ((data&0xff00)==0x1500)
91                 {
92                         fprintf(log_get(),"cdrom: setting mode 0x%.2x\n",data&0xff);
93                         return;
94                 }
95                 if (data==0x7001)
96                 {
97                         uint32 offset=cdrom_ram[0x00];
98                         offset<<=8;
99                         offset|=cdrom_ram[0x01];
100                         offset<<=8;
101                         offset|=cdrom_ram[0x02];
102                         offset<<=8;
103                         offset|=cdrom_ram[0x03];
104
105                         uint32 size=cdrom_ram[0x04];
106                         offset<<=8;
107                         offset|=cdrom_ram[0x05];
108                         
109                         fprintf(log_get(),"cdrom: READ(0x%.8x, 0x%.4x) [68k pc=0x%.8x]\n",offset,size,s68000readPC());
110                         return;
111                 }
112                 else
113                         fprintf(log_get(),"cdrom: unknown command 0x%.4x\n",data);
114         }
115 */
116 #ifdef CDROM_LOG
117         fprintf(log_get(),"cdrom: writing word 0x%.4x at 0x%.8x\n",data,offset);
118 #endif
119 }
120 //////////////////////////////////////////////////////////////////////////////
121 //
122 //////////////////////////////////////////////////////////////////////////////
123 //
124 //
125 //
126 //
127 //
128 //
129 //////////////////////////////////////////////////////////////////////////////
130 uint8 cdrom_byte_read(uint32 offset)
131 {
132         offset&=0xff;
133 #ifdef CDROM_LOG
134         fprintf(log_get(),"cdrom: reading byte from 0x%.8x\n",offset);
135 #endif
136         return(cdrom_ram[offset]);
137 }
138 //////////////////////////////////////////////////////////////////////////////
139 //
140 //////////////////////////////////////////////////////////////////////////////
141 //
142 //
143 //
144 //
145 //
146 //
147 //////////////////////////////////////////////////////////////////////////////
148 uint16 cdrom_word_read(uint32 offset)
149 {
150         offset&=0xff;
151
152         uint16 data=0x0000;
153         
154         if (offset==0x00) 
155                 data=0x0000;
156         else
157         if (offset==0x02) 
158                 data=0x2000;
159         else
160         if (offset==0x0a) 
161         {
162                 if (cdrom_cmd==0x7001)
163                         data=cdrom_cmd;
164                 else
165                         data=0x0400;
166         }
167         else
168         {
169                 data=cdrom_ram[offset+0];
170                 data<<=8;
171                 data|=cdrom_ram[offset+1];
172         }
173 #ifdef CDROM_LOG
174         fprintf(log_get(),"cdrom: reading word 0x%.4x from 0x%.8x [68k pc=0x%.8x]\n",data,offset,s68000readPC());
175 #endif
176         return(data);
177 }