Previous 15994 Revisions Next

r5718 Sunday 13th September, 2009 at 22:43:33 UTC by R. Belmont
[DREAMCAST] Initial support for controllers and GD-ROM drive. Discs do
not boot yet.
[src/mame/machine]dc.c
[src/mess/drivers]dc.c
[src/mess/machine]dc.c* gdrom.c* gdrom.h*

src/mame/machine/dc.c
r5717r5718
147147UINT32 dc_coin_counts[2];
148148static UINT32 maple_regs[0x100/4];
149149static UINT32 dc_rtcregister[4];
150static UINT32 g1bus_regs[0x100/4];
150UINT32 g1bus_regs[0x100/4];
151151static UINT32 g2bus_regs[0x100/4];
152152UINT8 maple0x86data1[0x80];
153153static UINT8 maple0x86data2[0x400];
src/mess/machine/gdrom.c
r0r5718
1/***************************************************************************
2
3 gdrom.c - Implementation of the Sega GD-ROM device
4
5***************************************************************************/
6
7#include "machine/scsidev.h"
8#include "cdrom.h"
9#include "sound/cdda.h"
10#include "state.h"
11#ifdef MESS
12#include "devices/chd_cd.h"
13#endif
14#include "gdrom.h"
15
16typedef struct
17{
18   UINT32 lba;
19   UINT32 blocks;
20   UINT32 last_lba;
21   UINT32 bytes_per_sector;
22   UINT32 num_subblocks;
23   UINT32 cur_subblock;
24   UINT32 play_err_flag;
25   UINT32 read_type;   // for command 0x30 only
26   UINT32 data_select;   // for command 0x30 only
27    cdrom_file *cdrom;
28} SCSIGd;
29
30static UINT8 GDROM_Cmd11_Reply[32] =
31{
32   0x00, 0x00, 0x00, 0x00, 0x00, 0xB4, 0x19, 0x00, 0x00, 0x08, 0x53, 0x45, 0x20, 0x20, 0x20, 0x20,
33   0x20, 0x20, 0x52, 0x65, 0x76, 0x20, 0x36, 0x2E, 0x34, 0x32, 0x39, 0x39, 0x30, 0x33, 0x31, 0x36
34};
35
36static void phys_frame_to_msf(int phys_frame, int *m, int *s, int *f)
37{
38   *m = phys_frame / (60*75);
39   phys_frame -= (*m * 60 * 75);
40   *s = phys_frame / 75;
41   *f = phys_frame % 75;
42}
43
44
45// scsicd_exec_command
46//
47// Execute a SCSI command.
48
49static int scsicd_exec_command( SCSIInstance *scsiInstance, UINT8 *statusCode )
50{
51   UINT8 *command;
52   int commandLength;
53   SCSIGd *our_this = (SCSIGd *)SCSIThis( &SCSIClassGDROM, scsiInstance );
54
55   cdrom_file *cdrom = our_this->cdrom;
56   const device_config *cdda;
57   int trk;
58
59   SCSIGetCommand( scsiInstance, &command, &commandLength );
60
61   switch ( command[0] )
62   {
63     
64
65      case 0x03: // REQUEST SENSE
66         SCSISetPhase( scsiInstance, SCSI_PHASE_DATAIN );
67         return SCSILengthFromUINT8( &command[ 4 ] );
68
69      case 0x11: // REQ_MODE
70         SCSISetPhase( scsiInstance, SCSI_PHASE_DATAIN );
71         printf("REQ_MODE %02x %02x %02x %02x %02x %02x\n",
72            command[0], command[1],
73            command[2], command[3],
74            command[4], command[5]);
75//         if (SCSILengthFromUINT8( &command[ 4 ] ) < 32) return -1;
76         return 32; //SCSILengthFromUINT8( &command[ 4 ] );
77
78      case 0x12: // INQUIRY
79         logerror("GDROM: REQUEST SENSE\n");
80         SCSISetPhase( scsiInstance, SCSI_PHASE_DATAIN );
81         return SCSILengthFromUINT8( &command[ 4 ] );
82
83      case 0x15: // MODE SELECT(6)
84         logerror("GDROM: MODE SELECT(6) length %x control %x\n", command[4], command[5]);
85         SCSISetPhase( scsiInstance, SCSI_PHASE_DATAOUT );
86         return SCSILengthFromUINT8( &command[ 4 ] );
87
88      case 0x1a: // MODE SENSE(6)
89         SCSISetPhase( scsiInstance, SCSI_PHASE_DATAIN );
90         return SCSILengthFromUINT8( &command[ 4 ] );
91
92      case 0x1b: // START STOP UNIT
93         cdda = cdda_from_cdrom(scsiInstance->machine, cdrom);
94         if (cdda != NULL)
95         {
96            cdda_stop_audio(cdda);
97         }
98         SCSISetPhase( scsiInstance, SCSI_PHASE_STATUS );
99         return 0;
100
101      case 0x1e: // PREVENT ALLOW MEDIUM REMOVAL
102         SCSISetPhase( scsiInstance, SCSI_PHASE_STATUS );
103         return 0;
104
105      case 0x25: // READ CAPACITY
106         SCSISetPhase( scsiInstance, SCSI_PHASE_DATAIN );
107         return 8;
108
109      case 0x28: // READ(10)
110
111         our_this->lba = command[2]<<24 | command[3]<<16 | command[4]<<8 | command[5];
112         our_this->blocks = SCSILengthFromUINT16( &command[7] );
113
114         logerror("GDROM: READ(10) at LBA %x for %d blocks (%d bytes)\n", our_this->lba, our_this->blocks, our_this->blocks * our_this->bytes_per_sector);
115
116         if (our_this->num_subblocks > 1)
117         {
118            our_this->cur_subblock = our_this->lba % our_this->num_subblocks;
119            our_this->lba /= our_this->num_subblocks;
120         }
121         else
122         {
123            our_this->cur_subblock = 0;
124         }
125
126         cdda = cdda_from_cdrom(scsiInstance->machine, cdrom);
127         if (cdda != NULL)
128         {
129            cdda_stop_audio(cdda);
130         }
131
132         SCSISetPhase( scsiInstance, SCSI_PHASE_DATAIN );
133         return our_this->blocks * our_this->bytes_per_sector;
134
135      case 0x30: // CD_READ
136         if (command[1] & 1)
137         {
138            fatalerror("GDROM: MSF mode used for CD_READ, unsupported\n");
139            return 0;
140         }
141         else
142         {
143            our_this->lba = (command[2]<<16 | command[3]<<8 | command[4]) - 150;
144            our_this->blocks = command[8]<<16 | command[9]<<8 | command[10];
145
146            our_this->read_type = (command[1] >> 1) & 7;
147            our_this->data_select = (command[1]>>4) & 0xf;
148
149            if (our_this->read_type != 2)   // mode 1
150            {
151               fatalerror("GDROM: Unhandled read_type %d\n", our_this->read_type);
152            }
153
154            if (our_this->data_select != 2)   // just sector data
155            {
156               fatalerror("GDROM: Unhandled data_select %d\n", our_this->data_select);
157            }
158
159            printf("GDROM: CD_READ at LBA %x for %d blocks (%d bytes, read type %d, data select %d)\n", our_this->lba, our_this->blocks, our_this->blocks * our_this->bytes_per_sector, our_this->read_type, our_this->data_select);
160
161            if (our_this->num_subblocks > 1)
162            {
163               our_this->cur_subblock = our_this->lba % our_this->num_subblocks;
164               our_this->lba /= our_this->num_subblocks;
165            }
166            else
167            {
168               our_this->cur_subblock = 0;
169            }
170
171            cdda = cdda_from_cdrom(scsiInstance->machine, cdrom);
172            if (cdda != NULL)
173            {
174               cdda_stop_audio(cdda);
175            }
176
177            SCSISetPhase( scsiInstance, SCSI_PHASE_DATAIN );
178            return our_this->blocks * our_this->bytes_per_sector;
179         }
180
181      case 0x42: // READ SUB-CHANNEL
182//                      logerror("GDROM: READ SUB-CHANNEL type %d\n", command[3]);
183         SCSISetPhase( scsiInstance, SCSI_PHASE_DATAIN );
184         return SCSILengthFromUINT16( &command[ 7 ] );
185
186      case 0x43: // READ TOC
187      {
188         int start_trk = command[6];
189         int end_trk = cdrom_get_last_track(cdrom);
190         int length;
191         int allocation_length = SCSILengthFromUINT16( &command[ 7 ] );
192
193         if( start_trk == 0 )
194         {
195            start_trk = 1;
196         }
197         if( start_trk == 0xaa )
198         {
199            end_trk = start_trk;
200         }
201
202         length = 4 + ( 8 * ( ( end_trk - start_trk ) + 1 ) );
203         if( length > allocation_length )
204         {
205            length = allocation_length;
206         }
207         else if( length < 4 )
208         {
209            length = 4;
210         }
211
212         cdda = cdda_from_cdrom(scsiInstance->machine, cdrom);
213         if (cdda != NULL)
214         {
215            cdda_stop_audio(cdda);
216         }
217
218         SCSISetPhase( scsiInstance, SCSI_PHASE_DATAIN );
219         return length;
220      }
221      case 0x45: // PLAY AUDIO(10)
222         our_this->lba = command[2]<<24 | command[3]<<16 | command[4]<<8 | command[5];
223         our_this->blocks = SCSILengthFromUINT16( &command[7] );
224
225         // special cases: lba of 0 means MSF of 00:02:00
226         if (our_this->lba == 0)
227         {
228            our_this->lba = 150;
229         }
230         else if (our_this->lba == 0xffffffff)
231         {
232            logerror("GDROM: play audio from current not implemented!\n");
233         }
234
235         logerror("GDROM: PLAY AUDIO(10) at LBA %x for %x blocks\n", our_this->lba, our_this->blocks);
236
237         trk = cdrom_get_track(cdrom, our_this->lba);
238
239         if (cdrom_get_track_type(cdrom, trk) == CD_TRACK_AUDIO)
240         {
241            our_this->play_err_flag = 0;
242            cdda = cdda_from_cdrom(scsiInstance->machine, cdrom);
243            if (cdda != NULL)
244               cdda_start_audio(cdda, our_this->lba, our_this->blocks);
245         }
246         else
247         {
248            logerror("GDROM: track is NOT audio!\n");
249            our_this->play_err_flag = 1;
250         }
251
252         SCSISetPhase( scsiInstance, SCSI_PHASE_STATUS );
253         return 0;
254
255      case 0x48: // PLAY AUDIO TRACK/INDEX
256         // be careful: tracks here are zero-based, but the SCSI command
257         // uses the real CD track number which is 1-based!
258         our_this->lba = cdrom_get_track_start(cdrom, command[4]-1);
259         our_this->blocks = cdrom_get_track_start(cdrom, command[7]-1) - our_this->lba;
260         if (command[4] > command[7])
261         {
262            our_this->blocks = 0;
263         }
264
265         if (command[4] == command[7])
266         {
267            our_this->blocks = cdrom_get_track_start(cdrom, command[4]) - our_this->lba;
268         }
269
270         if (our_this->blocks && cdrom)
271         {
272            cdda = cdda_from_cdrom(scsiInstance->machine, cdrom);
273            if (cdda != NULL)
274               cdda_start_audio(cdda, our_this->lba, our_this->blocks);
275         }
276
277         logerror("GDROM: PLAY AUDIO T/I: strk %d idx %d etrk %d idx %d frames %d\n", command[4], command[5], command[7], command[8], our_this->blocks);
278         SCSISetPhase( scsiInstance, SCSI_PHASE_STATUS );
279         return 0;
280
281      case 0x4b: // PAUSE/RESUME
282         if (cdrom)
283         {
284            cdda = cdda_from_cdrom(scsiInstance->machine, cdrom);
285            if (cdda != NULL)
286               cdda_pause_audio(cdda, (command[8] & 0x01) ^ 0x01);
287         }
288
289         logerror("GDROM: PAUSE/RESUME: %s\n", command[8]&1 ? "RESUME" : "PAUSE");
290         SCSISetPhase( scsiInstance, SCSI_PHASE_STATUS );
291         return 0;
292
293      case 0x55: // MODE SELECT(10)
294         logerror("GDROM: MODE SELECT length %x control %x\n", command[7]<<8 | command[8], command[1]);
295         SCSISetPhase( scsiInstance, SCSI_PHASE_DATAOUT );
296         return SCSILengthFromUINT16( &command[ 7 ] );
297
298      case 0x5a: // MODE SENSE(10)
299         SCSISetPhase( scsiInstance, SCSI_PHASE_DATAIN );
300         return SCSILengthFromUINT16( &command[ 7 ] );
301
302      case 0xa5: // PLAY AUDIO(12)
303         our_this->lba = command[2]<<24 | command[3]<<16 | command[4]<<8 | command[5];
304         our_this->blocks = command[6]<<24 | command[7]<<16 | command[8]<<8 | command[9];
305
306         // special cases: lba of 0 means MSF of 00:02:00
307         if (our_this->lba == 0)
308         {
309            our_this->lba = 150;
310         }
311         else if (our_this->lba == 0xffffffff)
312         {
313            logerror("GDROM: play audio from current not implemented!\n");
314         }
315
316         logerror("GDROM: PLAY AUDIO(12) at LBA %x for %x blocks\n", our_this->lba, our_this->blocks);
317
318         trk = cdrom_get_track(cdrom, our_this->lba);
319
320         if (cdrom_get_track_type(cdrom, trk) == CD_TRACK_AUDIO)
321         {
322            our_this->play_err_flag = 0;
323            cdda = cdda_from_cdrom(scsiInstance->machine, cdrom);
324            if (cdda != NULL)
325               cdda_start_audio(cdda, our_this->lba, our_this->blocks);
326         }
327         else
328         {
329            logerror("GDROM: track is NOT audio!\n");
330            our_this->play_err_flag = 1;
331         }
332         SCSISetPhase( scsiInstance, SCSI_PHASE_STATUS );
333         return 0;
334
335      case 0xa8: // READ(12)
336         our_this->lba = command[2]<<24 | command[3]<<16 | command[4]<<8 | command[5];
337         our_this->blocks = command[7]<<16 | command[8]<<8 | command[9];
338
339         logerror("GDROM: READ(12) at LBA %x for %x blocks (%x bytes)\n", our_this->lba, our_this->blocks, our_this->blocks * our_this->bytes_per_sector);
340
341         if (our_this->num_subblocks > 1)
342         {
343            our_this->cur_subblock = our_this->lba % our_this->num_subblocks;
344            our_this->lba /= our_this->num_subblocks;
345         }
346         else
347         {
348            our_this->cur_subblock = 0;
349         }
350
351         cdda = cdda_from_cdrom(scsiInstance->machine, cdrom);
352         if (cdda != NULL)
353         {
354            cdda_stop_audio(cdda);
355         }
356
357         SCSISetPhase( scsiInstance, SCSI_PHASE_DATAIN );
358         return our_this->blocks * our_this->bytes_per_sector;
359
360      case 0xbb: // SET CD SPEED
361         logerror("GDROM: SET CD SPEED to %d kbytes/sec.\n", command[2]<<8 | command[3]);
362         SCSISetPhase( scsiInstance, SCSI_PHASE_STATUS );
363         return 0;
364
365      default:
366         return SCSIBase( &SCSIClassGDROM, SCSIOP_EXEC_COMMAND, scsiInstance, 0, NULL );
367   }
368}
369
370// scsicd_read_data
371//
372// Read data from the device resulting from the execution of a command
373
374static void scsicd_read_data( SCSIInstance *scsiInstance, UINT8 *data, int dataLength )
375{
376   UINT8 *command;
377   int commandLength;
378   SCSIGd *our_this = (SCSIGd *)SCSIThis( &SCSIClassGDROM, scsiInstance );
379
380   int i;
381   UINT32 last_phys_frame;
382   cdrom_file *cdrom = our_this->cdrom;
383   UINT32 temp;
384   UINT8 tmp_buffer[2048];
385   const device_config *cdda;
386
387   SCSIGetCommand( scsiInstance, &command, &commandLength );
388
389   switch ( command[0] )
390   {
391      case 0x03: // REQUEST SENSE
392         logerror("GDROM: Reading REQUEST SENSE data\n");
393
394         memset( data, 0, dataLength );
395
396         data[0] = 0x71;   // deferred error
397
398         cdda = cdda_from_cdrom(scsiInstance->machine, cdrom);
399         if (cdda != NULL && cdda_audio_active(cdda))
400         {
401            data[12] = 0x00;
402            data[13] = 0x11;   // AUDIO PLAY OPERATION IN PROGRESS
403         }
404         else if (our_this->play_err_flag)
405         {
406            our_this->play_err_flag = 0;
407            data[12] = 0x64;   // ILLEGAL MODE FOR THIS TRACK
408            data[13] = 0x00;
409         }
410         // (else 00/00 means no error to report)
411         break;
412
413      case 0x11: // REQ_MODE
414         printf("REQ_MODE: dataLength %d\n", dataLength);
415         memcpy(data, &GDROM_Cmd11_Reply[0], (dataLength >= 32) ? 32 : dataLength);
416         break;
417
418      case 0x12: // INQUIRY
419         memset( data, 0, dataLength );
420         data[0] = 0x05; // device is present, device is CD/DVD (MMC-3)
421         data[1] = 0x80; // media is removable
422         data[2] = 0x05; // device complies with SPC-3 standard
423         data[3] = 0x02; // response data format = SPC-3 standard
424         // some Konami games freak out if this isn't "Sony", so we'll lie
425         // this is the actual drive on my Nagano '98 board
426         strcpy((char *)&data[8], "Sony");
427         strcpy((char *)&data[16], "CDU-76S");
428         strcpy((char *)&data[32], "1.0");
429         break;
430
431      case 0x25: // READ CAPACITY
432         logerror("GDROM: READ CAPACITY\n");
433
434         temp = cdrom_get_track_start(cdrom, 0xaa);
435         temp--;   // return the last used block on the disc
436
437         data[0] = (temp>>24) & 0xff;
438         data[1] = (temp>>16) & 0xff;
439         data[2] = (temp>>8) & 0xff;
440         data[3] = (temp & 0xff);
441         data[4] = 0;
442         data[5] = 0;
443         data[6] = (our_this->bytes_per_sector>>8)&0xff;
444         data[7] = (our_this->bytes_per_sector & 0xff);
445         break;
446
447      case 0x28: // READ(10)
448      case 0xa8: // READ(12)
449         logerror("GDROM: read %x dataLength, \n", dataLength);
450         if ((our_this->cdrom) && (our_this->blocks))
451         {
452            while (dataLength > 0)
453            {
454               if (!cdrom_read_data(our_this->cdrom, our_this->lba, tmp_buffer, CD_TRACK_MODE1))
455               {
456                  logerror("GDROM: CD read error!\n");
457               }
458
459               logerror("True LBA: %d, buffer half: %d\n", our_this->lba, our_this->cur_subblock * our_this->bytes_per_sector);
460
461               memcpy(data, &tmp_buffer[our_this->cur_subblock * our_this->bytes_per_sector], our_this->bytes_per_sector);
462
463               our_this->cur_subblock++;
464               if (our_this->cur_subblock >= our_this->num_subblocks)
465               {
466                  our_this->cur_subblock = 0;
467
468                  our_this->lba++;
469                  our_this->blocks--;
470               }
471
472               our_this->last_lba = our_this->lba;
473               dataLength -= our_this->bytes_per_sector;
474               data += our_this->bytes_per_sector;
475            }
476         }
477         break;
478
479      case 0x30: // CD_READ
480         logerror("GDROM: read %x dataLength, \n", dataLength);
481         if ((our_this->cdrom) && (our_this->blocks))
482         {
483            while (dataLength > 0)
484            {
485               if (!cdrom_read_data(our_this->cdrom, our_this->lba, tmp_buffer, CD_TRACK_MODE1))
486               {
487                  logerror("GDROM: CD read error!\n");
488               }
489
490               logerror("True LBA: %d, buffer half: %d\n", our_this->lba, our_this->cur_subblock * our_this->bytes_per_sector);
491
492               memcpy(data, &tmp_buffer[our_this->cur_subblock * our_this->bytes_per_sector], our_this->bytes_per_sector);
493
494               our_this->cur_subblock++;
495               if (our_this->cur_subblock >= our_this->num_subblocks)
496               {
497                  our_this->cur_subblock = 0;
498
499                  our_this->lba++;
500                  our_this->blocks--;
501               }
502
503               our_this->last_lba = our_this->lba;
504               dataLength -= our_this->bytes_per_sector;
505               data += our_this->bytes_per_sector;
506            }
507         }
508
509      case 0x42: // READ SUB-CHANNEL
510         switch (command[3])
511         {
512            case 1:   // return current position
513            {
514               int audio_active;
515               int msf;
516
517               if (!cdrom)
518               {
519                  return;
520               }
521
522               logerror("GDROM: READ SUB-CHANNEL Time = %x, SUBQ = %x\n", command[1], command[2]);
523
524               msf = command[1] & 0x2;
525
526               cdda = cdda_from_cdrom(scsiInstance->machine, cdrom);
527               audio_active = cdda != NULL && cdda_audio_active(cdda);
528               if (audio_active)
529               {
530                  if (cdda_audio_paused(cdda))
531                  {
532                     data[1] = 0x12;      // audio is paused
533                  }
534                  else
535                  {
536                     data[1] = 0x11;      // audio in progress
537                  }
538               }
539               else
540               {
541                  if (cdda != NULL && cdda_audio_ended(cdda))
542                  {
543                     data[1] = 0x13;   // ended successfully
544                  }
545                  else
546                  {
547//                          data[1] = 0x14;    // stopped due to error
548                     data[1] = 0x15;   // No current audio status to return
549                  }
550               }
551
552               // if audio is playing, get the latest LBA from the CDROM layer
553               if (audio_active)
554               {
555                  our_this->last_lba = cdda_get_audio_lba(cdda);
556               }
557               else
558               {
559                  our_this->last_lba = 0;
560               }
561
562               data[2] = 0;
563               data[3] = 12;      // data length
564               data[4] = 0x01;   // sub-channel format code
565               data[5] = 0x10 | (audio_active ? 0 : 4);
566               data[6] = cdrom_get_track(cdrom, our_this->last_lba) + 1;   // track
567               data[7] = 0;   // index
568
569               last_phys_frame = our_this->last_lba;
570
571               if (msf)
572               {
573                  int m,s,f;
574                  phys_frame_to_msf(last_phys_frame, &m, &s, &f);
575                  data[8] = 0;
576                  data[9] = m;
577                  data[10] = s;
578                  data[11] = f;
579               }
580               else
581               {
582                  data[8] = last_phys_frame>>24;
583                  data[9] = (last_phys_frame>>16)&0xff;
584                  data[10] = (last_phys_frame>>8)&0xff;
585                  data[11] = last_phys_frame&0xff;
586               }
587
588               last_phys_frame -= cdrom_get_track_start(cdrom, data[6] - 1);
589
590               if (msf)
591               {
592                  int m,s,f;
593                  phys_frame_to_msf(last_phys_frame, &m, &s, &f);
594                  data[12] = 0;
595                  data[13] = m;
596                  data[14] = s;
597                  data[15] = f;
598               }
599               else
600               {
601                  data[12] = last_phys_frame>>24;
602                  data[13] = (last_phys_frame>>16)&0xff;
603                  data[14] = (last_phys_frame>>8)&0xff;
604                  data[15] = last_phys_frame&0xff;
605               }
606               break;
607            }
608            default:
609               logerror("GDROM: Unknown subchannel type %d requested\n", command[3]);
610         }
611         break;
612
613      case 0x43: // READ TOC
614         /*
615                Track numbers are problematic here: 0 = lead-in, 0xaa = lead-out.
616                That makes sense in terms of how real-world CDs are referred to, but
617                our internal routines for tracks use "0" as track 1.  That probably
618                should be fixed...
619            */
620         logerror("GDROM: READ TOC, format = %d time=%d\n", command[2]&0xf,(command[1]>>1)&1);
621         switch (command[2] & 0x0f)
622         {
623            case 0:      // normal
624               {
625                  int start_trk;
626                  int end_trk;
627                  int len;
628                  int in_len;
629                  int dptr;
630                  UINT32 tstart;
631
632                  start_trk = command[6];
633                  if( start_trk == 0 )
634                  {
635                     start_trk = 1;
636                  }
637
638                  end_trk = cdrom_get_last_track(cdrom);
639                  len = (end_trk * 8) + 2;
640
641                  // the returned TOC DATA LENGTH must be the full amount,
642                  // regardless of how much we're able to pass back due to in_len
643                  dptr = 0;
644                  data[dptr++] = (len>>8) & 0xff;
645                  data[dptr++] = (len & 0xff);
646                  data[dptr++] = 1;
647                  data[dptr++] = end_trk;
648
649                  if( start_trk == 0xaa )
650                  {
651                     end_trk = 0xaa;
652                  }
653
654                  in_len = command[7]<<8 | command[8];
655
656                  for (i = start_trk; i <= end_trk; i++)
657                  {
658                     int cdrom_track = i;
659                     if( cdrom_track != 0xaa )
660                     {
661                        cdrom_track--;
662                     }
663
664                     if( dptr >= in_len )
665                     {
666                        break;
667                     }
668
669                     data[dptr++] = 0;
670                     data[dptr++] = cdrom_get_adr_control(cdrom, cdrom_track);
671                     data[dptr++] = i;
672                     data[dptr++] = 0;
673
674                     tstart = cdrom_get_track_start(cdrom, cdrom_track);
675                     if ((command[1]&2)>>1)
676                        tstart = lba_to_msf(tstart);
677                     data[dptr++] = (tstart>>24) & 0xff;
678                     data[dptr++] = (tstart>>16) & 0xff;
679                     data[dptr++] = (tstart>>8) & 0xff;
680                     data[dptr++] = (tstart & 0xff);
681                  }
682               }
683               break;
684            default:
685               logerror("GDROM: Unhandled READ TOC format %d\n", command[2]&0xf);
686               break;
687         }
688         break;
689
690      case 0x1a: // MODE SENSE(6)
691      case 0x5a: // MODE SENSE(10)
692         logerror("GDROM: MODE SENSE page code = %x, PC = %x\n", command[2] & 0x3f, (command[2]&0xc0)>>6);
693
694         switch (command[2] & 0x3f)
695         {
696            case 0xe:   // CD Audio control page
697               data[0] = 0x8e;   // page E, parameter is savable
698               data[1] = 0x0e;   // page length
699               data[2] = 0x04;   // IMMED = 1, SOTC = 0
700               data[3] = data[4] = data[5] = data[6] = data[7] = 0; // reserved
701
702               // connect each audio channel to 1 output port
703               data[8] = 1;
704               data[10] = 2;
705               data[12] = 4;
706               data[14] = 8;
707
708               // indicate max volume
709               data[9] = data[11] = data[13] = data[15] = 0xff;
710               break;
711
712            default:
713               logerror("GDROM: MODE SENSE unknown page %x\n", command[2] & 0x3f);
714               break;
715         }
716         break;
717
718      default:
719         SCSIBase( &SCSIClassGDROM, SCSIOP_READ_DATA, scsiInstance, dataLength, data );
720         break;
721   }
722}
723
724// scsicd_write_data
725//
726// Write data to the CD-ROM device as part of the execution of a command
727
728static void scsicd_write_data( SCSIInstance *scsiInstance, UINT8 *data, int dataLength )
729{
730   UINT8 *command;
731   int commandLength;
732   SCSIGd *our_this = (SCSIGd *)SCSIThis( &SCSIClassGDROM, scsiInstance );
733   SCSIGetCommand( scsiInstance, &command, &commandLength );
734
735   switch (command[ 0 ])
736   {
737      case 0x15: // MODE SELECT(6)
738      case 0x55: // MODE SELECT(10)
739         logerror("GDROM: MODE SELECT page %x\n", data[0] & 0x3f);
740
741         switch (data[0] & 0x3f)
742         {
743            case 0x0:   // vendor-specific
744               // check for SGI extension to force 512-byte blocks
745               if ((data[3] == 8) && (data[10] == 2))
746               {
747                  logerror("GDROM: Experimental SGI 512-byte block extension enabled\n");
748
749                  our_this->bytes_per_sector = 512;
750                  our_this->num_subblocks = 4;
751               }
752               else
753               {
754                  logerror("GDROM: Unknown vendor-specific page!\n");
755               }
756               break;
757
758            case 0xe:   // audio page
759               logerror("Ch 0 route: %x vol: %x\n", data[8], data[9]);
760               logerror("Ch 1 route: %x vol: %x\n", data[10], data[11]);
761               logerror("Ch 2 route: %x vol: %x\n", data[12], data[13]);
762               logerror("Ch 3 route: %x vol: %x\n", data[14], data[15]);
763               break;
764         }
765         break;
766
767      default:
768         SCSIBase( &SCSIClassGDROM, SCSIOP_WRITE_DATA, scsiInstance, dataLength, data );
769         break;
770   }
771}
772
773static void scsicd_alloc_instance( SCSIInstance *scsiInstance, const char *diskregion )
774{
775   running_machine *machine = scsiInstance->machine;
776   SCSIGd *our_this = (SCSIGd *)SCSIThis( &SCSIClassGDROM, scsiInstance );
777
778   our_this->lba = 0;
779   our_this->blocks = 0;
780   our_this->last_lba = 0;
781   our_this->bytes_per_sector = 2048;
782   our_this->num_subblocks = 1;
783   our_this->cur_subblock = 0;
784   our_this->play_err_flag = 0;
785
786   state_save_register_item( machine, "scsicd", diskregion, 0, our_this->lba );
787   state_save_register_item( machine, "scsicd", diskregion, 0, our_this->blocks );
788   state_save_register_item( machine, "scsicd", diskregion, 0, our_this->last_lba );
789   state_save_register_item( machine, "scsicd", diskregion, 0, our_this->bytes_per_sector );
790   state_save_register_item( machine, "scsicd", diskregion, 0, our_this->num_subblocks );
791   state_save_register_item( machine, "scsicd", diskregion, 0, our_this->cur_subblock );
792   state_save_register_item( machine, "scsicd", diskregion, 0, our_this->play_err_flag );
793
794#ifdef MESS
795   /* TODO: get rid of this ifdef MESS section */
796   our_this->cdrom = mess_cd_get_cdrom_file( devtag_get_device( machine, diskregion ) );
797#else
798   our_this->cdrom = cdrom_open(get_disk_handle( diskregion ));
799
800   if (!our_this->cdrom)
801   {
802      logerror("GDROM: no CD found!\n");
803   }
804#endif
805}
806
807static void scsicd_delete_instance( SCSIInstance *scsiInstance )
808{
809#ifndef MESS
810   SCSIGd *our_this = (SCSIGd *)SCSIThis( &SCSIClassGDROM, scsiInstance );
811   if( our_this->cdrom )
812   {
813      cdrom_close( our_this->cdrom );
814   }
815#endif
816}
817
818static void scsicd_get_device( SCSIInstance *scsiInstance, cdrom_file **cdrom )
819{
820   SCSIGd *our_this = (SCSIGd *)SCSIThis( &SCSIClassGDROM, scsiInstance );
821   *cdrom = our_this->cdrom;
822}
823
824static void scsicd_set_device( SCSIInstance *scsiInstance, cdrom_file *cdrom )
825{
826   SCSIGd *our_this = (SCSIGd *)SCSIThis( &SCSIClassGDROM, scsiInstance );
827   our_this->cdrom = cdrom;
828}
829
830static int scsigd_dispatch(int operation, void *file, INT64 intparm, void *ptrparm)
831{
832   SCSIAllocInstanceParams *params;
833
834   switch (operation)
835   {
836      case SCSIOP_EXEC_COMMAND:
837         return scsicd_exec_command( (SCSIInstance *)file, (UINT8 *)ptrparm );
838
839      case SCSIOP_READ_DATA:
840         scsicd_read_data( (SCSIInstance *)file, (UINT8 *)ptrparm, intparm );
841         return 0;
842
843      case SCSIOP_WRITE_DATA:
844         scsicd_write_data( (SCSIInstance *)file, (UINT8 *)ptrparm, intparm );
845         return 0;
846
847      case SCSIOP_ALLOC_INSTANCE:
848         params = (SCSIAllocInstanceParams *)ptrparm;
849         SCSIBase( &SCSIClassGDROM, operation, (SCSIInstance *)file, intparm, (UINT8 *)ptrparm );
850         scsicd_alloc_instance( params->instance, params->diskregion );
851         return 0;
852
853      case SCSIOP_DELETE_INSTANCE:
854         scsicd_delete_instance( (SCSIInstance *)file );
855         break;
856
857      case SCSIOP_GET_DEVICE:
858         scsicd_get_device( (SCSIInstance *)file, (cdrom_file **)ptrparm );
859         return 0;
860
861      case SCSIOP_SET_DEVICE:
862         scsicd_set_device( (SCSIInstance *)file, (cdrom_file *)ptrparm );
863         return 0;
864   }
865
866   return SCSIBase( &SCSIClassGDROM, operation, (SCSIInstance *)file, intparm, (UINT8 *)ptrparm );
867}
868
869const SCSIClass SCSIClassGDROM =
870{
871   &SCSIClassDevice,
872   scsigd_dispatch,
873   sizeof( SCSIGd )
874};
src/mess/machine/gdrom.h
r0r5718
1/***************************************************************************
2
3 gdrom.h
4
5***************************************************************************/
6
7#ifndef _GDROM_H_
8#define _GDROM_H_
9
10#include "machine/scsi.h"
11
12// Sega GD-ROM handler
13extern const SCSIClass SCSIClassGDROM;
14#define SCSI_DEVICE_GDROM &SCSIClassGDROM
15
16#endif
17
src/mess/machine/dc.c
r0r5718
1/*
2
3    dc.c - Sega Dreamcast hardware
4
5    MESS (DC home console) hardware overrides (GD-ROM drive etc)
6
7    c230048 - 5 is written, want 6
8    c0d9d9e - where bad happens, from routine @ c0da260
9
10    c0d9d8e - R0 on return is the value to put in
11
12    cfffee0 - stack location when bad happens
13   
14*/
15
16#include "driver.h"
17#include "cdrom.h"
18#include "debugger.h"
19#include "dc.h"
20#include "cpu/sh4/sh4.h"
21#include "sound/aica.h"
22#include "naomi.h"
23#include "machine/gdrom.h"
24#include "devices/chd_cd.h"
25             
26#define ATAPI_CYCLES_PER_SECTOR (5000)   // TBD for Dreamcast
27
28#define ATAPI_STAT_BSY      0x80
29#define ATAPI_STAT_DRDY    0x40
30#define ATAPI_STAT_DMARDDF 0x20
31#define ATAPI_STAT_SERVDSC 0x10
32#define ATAPI_STAT_DRQ     0x08
33#define ATAPI_STAT_CORR    0x04
34#define ATAPI_STAT_CHECK   0x01
35
36#define ATAPI_INTREASON_COMMAND 0x01
37#define ATAPI_INTREASON_IO      0x02
38#define ATAPI_INTREASON_RELEASE 0x04
39
40#define ATAPI_REG_DATA      0
41#define ATAPI_REG_FEATURES   1
42#define ATAPI_REG_INTREASON   2
43#define ATAPI_REG_SAMTAG   3
44#define ATAPI_REG_COUNTLOW   4
45#define ATAPI_REG_COUNTHIGH   5
46#define ATAPI_REG_DRIVESEL   6
47#define ATAPI_REG_CMDSTATUS   7
48#define ATAPI_REG_ERROR      16   // read-only ERROR (write is FEATURES)
49
50#define ATAPI_REG_MAX 24
51
52#define ATAPI_XFER_PIO      0x00
53#define ATAPI_XFER_PIO_FLOW   0x08
54#define ATAPI_XFER_MULTI_DMA   0x20
55#define ATAPI_XFER_ULTRA_DMA   0x40
56
57#define ATAPI_DATA_SIZE ( 64 * 1024 )
58
59static UINT8 *atapi_regs;
60static emu_timer *atapi_timer;
61static SCSIInstance *gdrom_device;
62static UINT8 *atapi_data;
63static int atapi_data_ptr, atapi_data_len, atapi_xferlen, atapi_xferbase, atapi_cdata_wait, atapi_xfermod;
64static UINT32 gdrom_alt_status;
65static UINT8 xfer_mode = ATAPI_XFER_PIO;
66
67#define MAX_TRANSFER_SIZE ( 63488 )
68
69extern UINT32 dc_sysctrl_regs[0x200/4];
70
71extern UINT32 g1bus_regs[0x100/4];
72
73static void gdrom_raise_irq(running_machine *machine)
74{
75   dc_sysctrl_regs[SB_ISTEXT] |= IST_EXT_GDROM;
76   dc_update_interrupt_status(machine);
77}
78
79static TIMER_CALLBACK( atapi_xfer_end )
80{
81   UINT8 sector_buffer[ 4096 ];
82
83   timer_adjust_oneshot(atapi_timer, attotime_never, 0);
84
85   printf("atapi_xfer_end atapi_xferlen = %d, atapi_xfermod=%d\n", atapi_xfermod, atapi_xferlen );
86
87   mame_printf_debug("ATAPI: xfer_end.  xferlen = %d, atapi_xfermod = %d\n", atapi_xferlen, atapi_xfermod);
88
89   while (atapi_xferlen > 0 )
90   {
91      struct sh4_ddt_dma ddtdata;
92
93      // get a sector from the SCSI device
94      SCSIReadData( gdrom_device, sector_buffer, 2048 );
95
96      atapi_xferlen -= 2048;
97
98      // perform the DMA
99      ddtdata.destination = atapi_xferbase;    // destination address
100      ddtdata.length = 2048/4;
101      ddtdata.size = 4;
102      ddtdata.buffer = sector_buffer;     
103      ddtdata.direction=1;   // 0 source to buffer, 1 buffer to destination
104      ddtdata.channel= -1;   // not used
105      ddtdata.mode= -1;      // copy from/to buffer
106      printf("ATAPI: DMA one sector to %x, %x remaining\n", atapi_xferbase, atapi_xferlen);
107      sh4_dma_ddt(cputag_get_cpu(machine, "maincpu"), &ddtdata);
108
109      atapi_xferbase += 2048;
110   }
111
112   if (atapi_xfermod > MAX_TRANSFER_SIZE)
113   {
114      atapi_xferlen = MAX_TRANSFER_SIZE;
115      atapi_xfermod = atapi_xfermod - MAX_TRANSFER_SIZE;
116   }
117   else
118   {
119      atapi_xferlen = atapi_xfermod;
120      atapi_xfermod = 0;
121   }
122
123   if (atapi_xferlen > 0)
124   {
125      printf("ATAPI: starting next piece of multi-part transfer\n");
126      atapi_regs[ATAPI_REG_COUNTLOW] = atapi_xferlen & 0xff;
127      atapi_regs[ATAPI_REG_COUNTHIGH] = (atapi_xferlen>>8)&0xff;
128
129      timer_adjust_oneshot(atapi_timer, cputag_clocks_to_attotime(machine, "maincpu", (ATAPI_CYCLES_PER_SECTOR * (atapi_xferlen/2048))), 0);
130   }
131   else
132   {
133      printf("ATAPI: Transfer completed, dropping DRQ\n");
134      atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRDY;
135      gdrom_alt_status = ATAPI_STAT_DRDY;
136      atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO | ATAPI_INTREASON_COMMAND;
137
138      g1bus_regs[SB_GDST]=0;
139      dc_sysctrl_regs[SB_ISTNRM] |= IST_DMA_GDROM;
140      dc_update_interrupt_status(machine);
141   }
142
143   gdrom_raise_irq(machine);
144
145   printf( "atapi_xfer_end: %d %d\n", atapi_xferlen, atapi_xfermod );
146}
147
148static READ32_HANDLER( atapi_r )
149{
150   running_machine *machine = space->machine;
151   int reg, data;
152
153   if (mem_mask == 0x0000ffff)   // word-wide command read
154   {
155//      mame_printf_debug("ATAPI: packet read = %04x\n", atapi_data[atapi_data_ptr]);
156
157      // assert IRQ and drop DRQ
158      if (atapi_data_ptr == 0 && atapi_data_len == 0)
159      {
160         // get the data from the device
161         if( atapi_xferlen > 0 )
162         {
163            SCSIReadData( gdrom_device, atapi_data, atapi_xferlen );
164            atapi_data_len = atapi_xferlen;
165         }
166
167         if (atapi_xfermod > MAX_TRANSFER_SIZE)
168         {
169            atapi_xferlen = MAX_TRANSFER_SIZE;
170            atapi_xfermod = atapi_xfermod - MAX_TRANSFER_SIZE;
171         }
172         else
173         {
174            atapi_xferlen = atapi_xfermod;
175            atapi_xfermod = 0;
176         }
177
178//         printf( "atapi_r: atapi_xferlen=%d\n", atapi_xferlen );
179         if( atapi_xferlen != 0 )
180         {
181            atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRQ | ATAPI_STAT_SERVDSC;
182            gdrom_alt_status = ATAPI_STAT_DRQ | ATAPI_STAT_SERVDSC;
183            atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO;
184         }
185         else
186         {
187            //mame_printf_debug("ATAPI: dropping DRQ\n");
188            atapi_regs[ATAPI_REG_CMDSTATUS] = 0;
189            gdrom_alt_status = 0;
190            atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO;
191         }
192
193         atapi_regs[ATAPI_REG_COUNTLOW] = atapi_xferlen & 0xff;
194         atapi_regs[ATAPI_REG_COUNTHIGH] = (atapi_xferlen>>8)&0xff;
195
196         gdrom_raise_irq(machine);
197      }
198
199      if( atapi_data_ptr < atapi_data_len )
200      {
201         data = atapi_data[atapi_data_ptr++];
202         data |= ( atapi_data[atapi_data_ptr++] << 8 );
203         if( atapi_data_ptr >= atapi_data_len )
204         {
205//              printf( "atapi_r: read all bytes\n" );
206            atapi_data_ptr = 0;
207            atapi_data_len = 0;
208
209            if( atapi_xferlen == 0 )
210            {
211               atapi_regs[ATAPI_REG_CMDSTATUS] = 0;
212               gdrom_alt_status = 0;
213               atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO;
214               gdrom_raise_irq(machine);
215            }
216         }
217      }
218      else
219      {
220         data = 0;
221      }
222   }
223   else
224   {
225      reg = offset;
226
227      // get read-only side of read-only/write-only registers from elsewhere
228      if (reg == ATAPI_REG_FEATURES)
229      {
230         reg = ATAPI_REG_ERROR;
231      }
232      data = atapi_regs[reg];
233
234      #if 0
235      switch( reg )
236      {
237      case ATAPI_REG_DATA:
238         printf( "atapi_r: data=%02x\n", data );
239         break;
240      case ATAPI_REG_ERROR:
241         printf( "atapi_r: error=%02x\n", data );
242         break;
243      case ATAPI_REG_INTREASON:
244         printf( "atapi_r: intreason=%02x\n", data );
245         break;
246      case ATAPI_REG_SAMTAG:
247         printf( "atapi_r: samtag=%02x\n", data );
248         break;
249      case ATAPI_REG_COUNTLOW:
250         printf( "atapi_r: countlow=%02x\n", data );
251         break;
252      case ATAPI_REG_COUNTHIGH:
253         printf( "atapi_r: counthigh=%02x\n", data );
254         break;
255      case ATAPI_REG_DRIVESEL:
256         printf( "atapi_r: drivesel=%02x\n", data );
257         break;
258      case ATAPI_REG_CMDSTATUS:
259         printf( "atapi_r: cmdstatus=%02x\n", data );
260         break;
261      }
262      #endif
263
264      mame_printf_debug("ATAPI: read reg %d = %x (PC=%x)\n", reg, data, cpu_get_pc(space->cpu));
265   }
266
267//   printf( "atapi_r( %08x, %08x ) %08x\n", offset, mem_mask, data );
268   return data;
269}
270
271static WRITE32_HANDLER( atapi_w )
272{
273   running_machine *machine = space->machine;
274   int reg;
275
276//   printf( "atapi_w( %08x, %08x, %08x )\n", offset, mem_mask, data );
277
278   if (mem_mask == 0x0000ffff)   // word-wide command write
279   {
280//      printf("atapi_w: data=%04x\n", data );
281
282//      printf("ATAPI: packet write %04x\n", data);
283      atapi_data[atapi_data_ptr++] = data & 0xff;
284      atapi_data[atapi_data_ptr++] = data >> 8;
285
286      if (atapi_cdata_wait)
287      {
288//                printf("ATAPI: waiting, ptr %d wait %d\n", atapi_data_ptr, atapi_cdata_wait);
289         if (atapi_data_ptr == atapi_cdata_wait)
290         {
291            // send it to the device
292            SCSIWriteData( gdrom_device, atapi_data, atapi_cdata_wait );
293
294            // assert IRQ
295            gdrom_raise_irq(machine);
296
297            // not sure here, but clear DRQ at least?
298            atapi_regs[ATAPI_REG_CMDSTATUS] = 0;
299         }
300      }
301
302      else if ( atapi_data_ptr == 12 )
303      {
304         int phase;
305
306//         printf("atapi_w: command %02x\n", atapi_data[0]&0xff );
307
308         // reset data pointer for reading SCSI results
309         atapi_data_ptr = 0;
310         atapi_data_len = 0;
311
312         // send it to the SCSI device
313         SCSISetCommand( gdrom_device, atapi_data, 12 );
314         SCSIExecCommand( gdrom_device, &atapi_xferlen );
315         SCSIGetPhase( gdrom_device, &phase );
316
317         if (atapi_xferlen != -1)
318         {
319            printf("ATAPI: SCSI command %02x returned %d bytes from the device\n", atapi_data[0]&0xff, atapi_xferlen);
320
321            // store the returned command length in the ATAPI regs, splitting into
322            // multiple transfers if necessary
323            atapi_xfermod = 0;
324            if (atapi_xferlen > MAX_TRANSFER_SIZE)
325            {
326               atapi_xfermod = atapi_xferlen - MAX_TRANSFER_SIZE;
327               atapi_xferlen = MAX_TRANSFER_SIZE;
328            }
329
330            atapi_regs[ATAPI_REG_COUNTLOW] = atapi_xferlen & 0xff;
331            atapi_regs[ATAPI_REG_COUNTHIGH] = (atapi_xferlen>>8)&0xff;
332
333            gdrom_alt_status = 0;   // (I guess?)
334
335            if (atapi_xferlen == 0)
336            {
337               // if no data to return, set the registers properly
338               atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRDY;
339               atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO|ATAPI_INTREASON_COMMAND;
340            }
341            else
342            {
343               // indicate data ready: set DRQ and DMA ready, and IO in INTREASON
344               if (atapi_regs[ATAPI_REG_FEATURES] & 0x01)   // DMA feature
345               {
346                  atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_BSY | ATAPI_STAT_DRDY | ATAPI_STAT_SERVDSC;
347               }
348               else
349               {
350                  atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRQ | ATAPI_STAT_SERVDSC | ATAPI_STAT_DRQ;
351               }
352               atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO;
353            }
354
355            switch( phase )
356            {
357            case SCSI_PHASE_DATAOUT:
358               atapi_cdata_wait = atapi_xferlen;
359               break;
360            }
361
362            // perform special ATAPI processing of certain commands
363            switch (atapi_data[0]&0xff)
364            {
365               case 0x00: // BUS RESET / TEST UNIT READY
366               case 0xbb: // SET CDROM SPEED
367                  atapi_regs[ATAPI_REG_CMDSTATUS] = 0;
368                  break;
369
370               case 0x45: // PLAY
371                  atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_BSY;
372                  timer_adjust_oneshot( atapi_timer, cpu_clocks_to_attotime( space->cpu, ATAPI_CYCLES_PER_SECTOR ), 0 );
373                  break;
374            }
375
376            // assert IRQ
377            gdrom_raise_irq(machine);
378         }
379         else
380         {
381                       printf("ATAPI: SCSI device returned error!\n");
382
383            atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRQ | ATAPI_STAT_CHECK;
384            atapi_regs[ATAPI_REG_ERROR] = 0x50;   // sense key = ILLEGAL REQUEST
385            atapi_regs[ATAPI_REG_COUNTLOW] = 0;
386            atapi_regs[ATAPI_REG_COUNTHIGH] = 0;
387         }
388      }
389   }
390   else
391   {
392      reg = offset;
393#if 0
394      switch( reg )
395      {
396      case ATAPI_REG_DATA:
397         printf( "atapi_w: data=%02x\n", data );
398               break;
399            case ATAPI_REG_FEATURES:
400         printf( "atapi_w: features=%02x\n", data );
401               break;
402            case ATAPI_REG_INTREASON:
403         printf( "atapi_w: intreason=%02x\n", data );
404               break;
405            case ATAPI_REG_SAMTAG:
406         printf( "atapi_w: samtag=%02x\n", data );
407               break;
408            case ATAPI_REG_COUNTLOW:
409         printf( "atapi_w: countlow=%02x\n", data );
410               break;
411            case ATAPI_REG_COUNTHIGH:
412         printf( "atapi_w: counthigh=%02x\n", data );
413               break;
414            case ATAPI_REG_DRIVESEL:
415         printf( "atapi_w: drivesel=%02x\n", data );
416               break;
417            case ATAPI_REG_CMDSTATUS:
418         printf( "atapi_w: cmdstatus=%02x\n", data );
419         break;
420      }
421#endif
422      atapi_regs[reg] = data;
423//      mame_printf_debug("ATAPI: reg %d = %x (offset %x mask %x PC=%x)\n", reg, data, offset, mem_mask, cpu_get_pc(space->cpu));
424
425      if (reg == ATAPI_REG_CMDSTATUS)
426      {
427         printf("ATAPI command %x issued! (PC=%x)\n", data, cpu_get_pc(space->cpu));
428
429         switch (data)
430         {
431            case 0xa0:   // PACKET
432                atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRQ;
433               gdrom_alt_status = ATAPI_STAT_DRQ;
434               atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_COMMAND;
435
436               atapi_data_ptr = 0;
437               atapi_data_len = 0;
438
439               /* we have no data */
440               atapi_xferlen = 0;
441               atapi_xfermod = 0;
442
443               atapi_cdata_wait = 0;
444               break;
445
446            case 0xa1:   // IDENTIFY PACKET DEVICE
447                atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_DRQ;
448               gdrom_alt_status = ATAPI_STAT_DRQ;
449
450               atapi_data_ptr = 0;
451               atapi_data_len = 512;
452
453               /* we have no data */
454               atapi_xferlen = 0;
455               atapi_xfermod = 0;
456
457               memset( atapi_data, 0, atapi_data_len );
458
459               atapi_data[ 0 ^ 1 ] = 0x86;   // ATAPI device, cmd set 6 compliant, DRQ within 3 ms of PACKET command
460               atapi_data[ 1 ^ 1 ] = 0x00;
461
462               memset( &atapi_data[ 46 ], ' ', 8 );
463               atapi_data[ 46 ^ 1 ] = 'S';
464               atapi_data[ 47 ^ 1 ] = 'E';
465
466               memset( &atapi_data[ 54 ], ' ', 40 );
467               atapi_data[ 54 ^ 1 ] = 'C';
468               atapi_data[ 55 ^ 1 ] = 'D';
469               atapi_data[ 56 ^ 1 ] = '-';
470               atapi_data[ 57 ^ 1 ] = 'R';
471               atapi_data[ 58 ^ 1 ] = 'O';
472               atapi_data[ 59 ^ 1 ] = 'M';
473               atapi_data[ 60 ^ 1 ] = ' ';
474               atapi_data[ 61 ^ 1 ] = 'D';
475               atapi_data[ 62 ^ 1 ] = 'R';
476               atapi_data[ 63 ^ 1 ] = 'I';
477               atapi_data[ 64 ^ 1 ] = 'V';
478               atapi_data[ 65 ^ 1 ] = 'E';
479               atapi_data[ 66 ^ 1 ] = ' ';
480               atapi_data[ 67 ^ 1 ] = ' ';
481               atapi_data[ 68 ^ 1 ] = ' ';
482               atapi_data[ 69 ^ 1 ] = ' ';
483               atapi_data[ 70 ^ 1 ] = '6';
484               atapi_data[ 71 ^ 1 ] = '.';
485               atapi_data[ 72 ^ 1 ] = '4';
486               atapi_data[ 73 ^ 1 ] = '2';
487
488               atapi_data[ 98 ^ 1 ] = 0x04; // IORDY may be disabled
489               atapi_data[ 99 ^ 1 ] = 0x00;
490
491               atapi_regs[ATAPI_REG_COUNTLOW] = 0;
492               atapi_regs[ATAPI_REG_COUNTHIGH] = 2;
493
494               gdrom_raise_irq(space->machine);
495               break;
496
497            case 0xef:   // SET FEATURES
498               // set xfer mode?
499               if (atapi_regs[ATAPI_REG_FEATURES] == 0x03)
500               {
501                  printf("Set transfer mode to %x\n", atapi_regs[ATAPI_REG_COUNTLOW] & 0xf8);
502                  xfer_mode = atapi_regs[ATAPI_REG_COUNTLOW] & 0xf8;
503               }
504               else
505               {
506                  printf("ATAPI: Unknown set features %x\n", atapi_regs[ATAPI_REG_FEATURES]);
507               }
508
509                atapi_regs[ATAPI_REG_CMDSTATUS] = 0;
510               gdrom_alt_status = 0;   // is this correct?
511
512               atapi_data_ptr = 0;
513               atapi_data_len = 0;
514
515               gdrom_raise_irq(space->machine);
516               break;
517
518            default:
519               mame_printf_debug("ATAPI: Unknown IDE command %x\n", data);
520               break;
521         }
522      }
523    }
524}
525
526void dreamcast_atapi_exit(running_machine* machine)
527{
528   if (gdrom_device != NULL)
529   {
530      SCSIDeleteInstance( gdrom_device );
531   }
532}
533
534void dreamcast_atapi_init(running_machine *machine)
535{
536   atapi_regs = auto_alloc_array(machine, UINT8,  ATAPI_REG_MAX );
537   memset(atapi_regs, 0, sizeof(atapi_regs));
538
539   atapi_regs[ATAPI_REG_CMDSTATUS] = 0;
540   atapi_regs[ATAPI_REG_ERROR] = 1;
541   atapi_regs[ATAPI_REG_COUNTLOW] = 0x14;
542   atapi_regs[ATAPI_REG_COUNTHIGH] = 0xeb;
543
544   atapi_data_ptr = 0;
545   atapi_data_len = 0;
546   atapi_cdata_wait = 0;
547
548   atapi_timer = timer_alloc(machine,  atapi_xfer_end , NULL);
549   timer_adjust_oneshot(atapi_timer, attotime_never, 0);
550
551   gdrom_device = NULL;
552
553   add_exit_callback(machine, dreamcast_atapi_exit);
554
555   atapi_data = auto_alloc_array(machine, UINT8,  ATAPI_DATA_SIZE );
556
557   state_save_register_global_pointer(machine,  atapi_regs, ATAPI_REG_MAX );
558   state_save_register_global_pointer(machine,  atapi_data, ATAPI_DATA_SIZE / 2 );
559   state_save_register_global(machine,  atapi_data_ptr );
560   state_save_register_global(machine,  atapi_data_len );
561   state_save_register_global(machine,  atapi_xferlen );
562   state_save_register_global(machine,  atapi_xferbase );
563   state_save_register_global(machine,  atapi_cdata_wait );
564   state_save_register_global(machine,  atapi_xfermod );
565}
566
567void dreamcast_atapi_reset(running_machine *machine)
568{
569   atapi_regs[ATAPI_REG_CMDSTATUS] = 0;
570   atapi_regs[ATAPI_REG_ERROR] = 1;
571   atapi_regs[ATAPI_REG_COUNTLOW] = 0x14;
572   atapi_regs[ATAPI_REG_COUNTHIGH] = 0xeb;
573
574   atapi_data_ptr = 0;
575   atapi_data_len = 0;
576   atapi_cdata_wait = 0;
577
578   atapi_xferlen = 0;
579   atapi_xfermod = 0;
580
581   if ( mess_cd_get_cdrom_file(devtag_get_device( machine, "cdrom" )) != NULL )
582   {
583      SCSIAllocInstance( machine, &SCSIClassGDROM, &gdrom_device, "cdrom" );
584   }
585   else
586   {
587      gdrom_device = NULL;
588   }
589}
590
591/*
592
593 GDROM regsters:
594
595 5f7018: alternate status/device control
596 5f7080: data
597 5f7084: error/features
598 5f7088: interrupt reason/sector count
599 5f708c: sector number
600 5f7090: byte control low
601 5f7094: byte control high
602 5f7098: drive select
603 5f709c: status/command
604
605c002910 - ATAPI packet writes
606c002796 - aux status read after that
607c000776 - DMA triggered to c008000
608
609*/
610
611READ64_HANDLER( dc_mess_gdrom_r )
612{
613   UINT32 off;
614
615   if ((int)~mem_mask & 1)
616   {
617      off=(offset << 1) | 1;
618   }
619   else
620   {
621      off=offset << 1;
622   }
623
624//   printf("gdrom_r: @ %x (off %x), mask %llx (PC %x)\n", offset, off, mem_mask, cpu_get_pc(space->cpu));
625
626   if (offset == 3)
627   {
628      return gdrom_alt_status;
629   }
630   else if (off >= 0x20)
631   {
632      return atapi_r(space, off-0x20, 0xff);
633   }
634
635   return 0;
636}
637
638WRITE64_HANDLER( dc_mess_gdrom_w )
639{
640   UINT32 dat,off;
641
642   if ((int)~mem_mask & 1)
643   {
644      dat=(UINT32)(data >> 32);
645      off=(offset << 1) | 1;
646   }
647   else
648   {
649      dat=(UINT32)data;
650      off=offset << 1;
651   }
652
653//   printf("GDROM: [%08x=%x]write %llx to %x, mask %llx (PC %x)\n", 0x5f7000+off*4, dat, data, offset, mem_mask, cpu_get_pc(space->cpu));
654
655   if (off >= 0x20)
656   {
657      atapi_w(space, off-0x20, dat, (UINT32)mem_mask);
658   }
659}
660
661// register decode helpers
662
663// this accepts only 32-bit accesses
664INLINE int decode_reg32_64(running_machine *machine, UINT32 offset, UINT64 mem_mask, UINT64 *shift)
665{
666   int reg = offset * 2;
667
668   *shift = 0;
669
670   // non 32-bit accesses have not yet been seen here, we need to know when they are
671   if ((mem_mask != U64(0xffffffff00000000)) && (mem_mask != U64(0x00000000ffffffff)))
672   {
673      mame_printf_verbose("%s:Wrong mask!\n", cpuexec_describe_context(machine));
674//      debugger_break(machine);
675   }
676
677   if (mem_mask == U64(0xffffffff00000000))
678   {
679      reg++;
680      *shift = 32;
681    }
682
683   return reg;
684}
685
686READ64_HANDLER( dc_mess_g1_ctrl_r )
687{
688   int reg;
689   UINT64 shift;
690
691   reg = decode_reg32_64(space->machine, offset, mem_mask, &shift);
692   mame_printf_verbose("G1CTRL:  Unmapped read %08x\n", 0x5f7400+reg*4);
693   return (UINT64)g1bus_regs[reg] << shift;
694}
695
696WRITE64_HANDLER( dc_mess_g1_ctrl_w )
697{
698   int reg;
699   UINT64 shift;
700   UINT32 old,dat;
701
702   reg = decode_reg32_64(space->machine, offset, mem_mask, &shift);
703   dat = (UINT32)(data >> shift);
704   old = g1bus_regs[reg];
705
706   g1bus_regs[reg] = dat; // 5f7400+reg*4=dat
707   mame_printf_verbose("G1CTRL: [%08x=%x] write %llx to %x, mask %llx\n", 0x5f7400+reg*4, dat, data, offset, mem_mask);
708   switch (reg)
709   {
710   case SB_GDST:
711      if (dat & 1 && g1bus_regs[SB_GDEN] == 1) // 0 -> 1
712      {
713         if (g1bus_regs[SB_GDDIR] == 0)
714         {
715            printf("G1CTRL: unsupported transfer\n");
716            return;
717         }
718
719         atapi_xferbase = g1bus_regs[SB_GDSTAR];
720         timer_adjust_oneshot(atapi_timer, cputag_clocks_to_attotime(space->machine, "maincpu", (ATAPI_CYCLES_PER_SECTOR * (atapi_xferlen/2048))), 0);
721      }
722      break;
723   }
724}
725
src/mess/drivers/dc.c
r5717r5718
11/*
22
3    dc.c - Sega Dreamcast skeleton driver
3    dc.c - Sega Dreamcast driver
44    by R. Belmont
55
66    SH-4 @ 200 MHz
r5717r5718
2525#include "cpu/arm7/arm7core.h"
2626#include "sound/aica.h"
2727#include "dc.h"
28#include "devices/chd_cd.h"
2829
2930#define CPU_CLOCK (200000000)
3031
32// things from mess/machine/dc.c
33void dreamcast_atapi_init(running_machine *machine);
34void dreamcast_atapi_exit(running_machine *machine);
35void dreamcast_atapi_reset(running_machine *machine);
36extern READ64_HANDLER( dc_mess_gdrom_r );
37extern WRITE64_HANDLER( dc_mess_gdrom_w );
38extern READ64_HANDLER( dc_mess_g1_ctrl_r );
39extern WRITE64_HANDLER( dc_mess_g1_ctrl_w );
40
3141static UINT32 *dc_sound_ram;
42static UINT64 *dc_ram;
3243
3344int jvsboard_type;
3445
46static DRIVER_INIT(dc)
47{
48   dreamcast_atapi_init(machine);
49}
50
3551static UINT64 PDTRA, PCTRA;
3652static READ64_HANDLER( dc_pdtra_r )
3753{
r5717r5718
108124   AM_RANGE(0x00200000, 0x0021ffff) AM_ROM AM_REGION("maincpu", 0x200000)   // flash
109125   AM_RANGE(0x005f6800, 0x005f69ff) AM_READWRITE( dc_sysctrl_r, dc_sysctrl_w )
110126   AM_RANGE(0x005f6c00, 0x005f6cff) AM_READWRITE( dc_maple_r, dc_maple_w )
111   AM_RANGE(0x005f7000, 0x005f70ff) AM_READWRITE( dc_gdrom_r, dc_gdrom_w )
112   AM_RANGE(0x005f7400, 0x005f74ff) AM_READWRITE( dc_g1_ctrl_r, dc_g1_ctrl_w )
127   AM_RANGE(0x005f7000, 0x005f70ff) AM_READWRITE( dc_mess_gdrom_r, dc_mess_gdrom_w )
128   AM_RANGE(0x005f7400, 0x005f74ff) AM_READWRITE( dc_mess_g1_ctrl_r, dc_mess_g1_ctrl_w )
113129   AM_RANGE(0x005f7800, 0x005f78ff) AM_READWRITE( dc_g2_ctrl_r, dc_g2_ctrl_w )
114130   AM_RANGE(0x005f7c00, 0x005f7cff) AM_READWRITE( pvr_ctrl_r, pvr_ctrl_w )
115131   AM_RANGE(0x005f8000, 0x005f9fff) AM_READWRITE( pvr_ta_r, pvr_ta_w )
r5717r5718
123139   AM_RANGE(0x05000000, 0x05ffffff) AM_RAM AM_BASE( &dc_framebuffer_ram ) // apparently this actually accesses the same memory as the 64-bit texture memory access, but in a different format, keep it apart for now
124140
125141   /* Area 3 */
126   AM_RANGE(0x0c000000, 0x0cffffff) AM_RAM AM_SHARE(4)
142   AM_RANGE(0x0c000000, 0x0cffffff) AM_RAM AM_SHARE(4) AM_BASE(&dc_ram)
127143   AM_RANGE(0x0d000000, 0x0dffffff) AM_RAM AM_SHARE(4)// extra ram on Naomi (mirror on DC)
128144   AM_RANGE(0x0e000000, 0x0effffff) AM_RAM AM_SHARE(4)// mirror
129145   AM_RANGE(0x0f000000, 0x0fffffff) AM_RAM AM_SHARE(4)// mirror
r5717r5718
137153   AM_RANGE(0x12800000, 0x12ffffff) AM_WRITE( ta_fifo_yuv_w )
138154   AM_RANGE(0x13000000, 0x137fffff) AM_WRITE( ta_texture_directpath1_w ) AM_MIRROR(0x00800000) // access to texture / fraembfufer memory (either 32-bit or 64-bit area depending on SB_LMMODE1 register - cannot be written directly, only through dma / store queue
139155
156   AM_RANGE(0x8c000000, 0x8cffffff) AM_RAM AM_SHARE(4)   // another RAM mirror
157
140158   AM_RANGE(0xa0000000, 0xa01fffff) AM_ROM AM_REGION("maincpu", 0)
141159ADDRESS_MAP_END
142160
r5717r5718
154172   const device_config *aica = devtag_get_device(machine, "aica");
155173   MACHINE_RESET_CALL(dc);
156174   aica_set_ram_base(aica, dc_sound_ram, 2*1024*1024);
175   dreamcast_atapi_reset(machine);
157176}
158177
159178static void aica_irq(const device_config *device, int irq)
r5717r5718
206225   MDRV_SOUND_CONFIG(dc_aica_interface)
207226   MDRV_SOUND_ROUTE(0, "lspeaker", 2.0)
208227   MDRV_SOUND_ROUTE(0, "rspeaker", 2.0)
228
229   MDRV_CDROM_ADD( "cdrom" )
209230MACHINE_DRIVER_END
210231
211232ROM_START(dc)
r5717r5718
237258SYSTEM_CONFIG_END
238259
239260static INPUT_PORTS_START( dc )
240   PORT_START("IN0")
241   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("Service")
242   PORT_SERVICE_NO_TOGGLE( 0x01, IP_ACTIVE_LOW )
243   PORT_START("IN1")
244   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_START1 )
245   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY
246   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY
247   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY
248   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY
249   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 )
250   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 )
251   PORT_START("IN2")
252   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON6 )
253   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON5 )
254   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON4 )
255   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON3 )
256   PORT_START("IN3")
257   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_START2 )
258   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
259   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
260   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
261   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
262   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2)
263   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(2)
264   PORT_START("IN4")
265   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_PLAYER(2)
266   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_PLAYER(2)
267   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_PLAYER(2)
268   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_PLAYER(2)
261   PORT_START("P1L")
262   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
263   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
264   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
265   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
266   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
267   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
268   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
269   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
270   PORT_START("P1H")
271   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN1 )
272   PORT_SERVICE_NO_TOGGLE( 0x40, IP_ACTIVE_LOW )
273   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE1 )
274   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
275   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
276   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(1)
277   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_PLAYER(1)
278   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_PLAYER(1)
279
280   PORT_START("P2L")
281   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
282   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
283   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
284   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
285   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START2 )
286   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
287   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
288   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
289   PORT_START("P2H")
290   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 )
291   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
292   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE2 )
293   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
294   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
295   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(2)
296   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_PLAYER(2)
297   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_PLAYER(2)
298
299   PORT_START("P3L")
300   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(3)
301   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(3)
302   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(3)
303   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(3)
304   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START3 )
305   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(3)
306   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(3)
307   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(3)
308   PORT_START("P3H")
309   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN3 )
310   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
311   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE3 )
312   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
313   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
314   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(3)
315   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_PLAYER(3)
316   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_PLAYER(3)
317
318   PORT_START("P4L")
319   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(4)
320   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(4)
321   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(4)
322   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(4)
323   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START4 )
324   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(4)
325   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(4)
326   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(4)
327   PORT_START("P4H")
328   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN4 )
329   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
330   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE4 )
331   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
332   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
333   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(4)
334   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_PLAYER(4)
335   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_PLAYER(4)
336
269337   PORT_START("MAMEDEBUG") \
270338   PORT_DIPNAME( 0x01, 0x00, "Bilinear Filtering" )
271339   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
r5717r5718
274342
275343
276344/*    YEAR  NAME    PARENT  COMPAT  MACHINE INPUT   INIT    CONFIG  COMPANY FULLNAME */
277CONS( 1999, dc,      dcjp,   0,   dc,   dc,   0,   dc,    "Sega", "Dreamcast (US NTSC)", GAME_NOT_WORKING )
278CONS( 1998, dcjp,   0,   0,   dc,   dc,   0,   dc,    "Sega", "Dreamcast (Japan NTSC)", GAME_NOT_WORKING )
279CONS( 1999, dceu,   dcjp,   0,   dc,   dc,   0,   dc,    "Sega", "Dreamcast (European PAL)", GAME_NOT_WORKING )
280CONS( 1998, dcdev,   dcjp,   0,   dc,   dc,   0,   dc,    "Sega", "HKT-0120 Sega Dreamcast Development Box", GAME_NOT_WORKING )
345CONS( 1999, dc,      dcjp,   0,   dc,   dc,   dc,   dc,    "Sega", "Dreamcast (US NTSC)", GAME_NOT_WORKING )
346CONS( 1998, dcjp,   0,   0,   dc,   dc,   dc,   dc,    "Sega", "Dreamcast (Japan NTSC)", GAME_NOT_WORKING )
347CONS( 1999, dceu,   dcjp,   0,   dc,   dc,   dc,   dc,    "Sega", "Dreamcast (European PAL)", GAME_NOT_WORKING )
348CONS( 1998, dcdev,   dcjp,   0,   dc,   dc,   dc,   dc,    "Sega", "HKT-0120 Sega Dreamcast Development Box", GAME_NOT_WORKING )
281349

Previous 15994 Revisions Next


© 1998-2018 The MESS Team