Previous 15994 Revisions Next

r6428 Friday 20th November, 2009 at 01:58:34 UTC by Barry Rodewald
[FMTOWNS] Implemented basic CDROM controller command handling. Basically this will tell the system that no CDROM in inserted, speeding up the boot process, and allowing MS-DOS CD-ROM drivers and MSCDEX to load without problems.
[src/mess/drivers]fmtowns.c

src/mess/drivers/fmtowns.c
r6427r6428
164164static UINT16 towns_crtc_reg[32];
165165static UINT8 towns_tvram_enable;
166166
167struct towns_cdrom_controller
168{
169   UINT8 command;
170   UINT8 status;
171   UINT8 cmd_status[4];
172   UINT8 cmd_status_ptr;
173   UINT8 parameter[8];
174} towns_cd;
175
167176static void towns_update_video_banks(const address_space* space);
168177static PIC8259_SET_INT_LINE( towns_pic_irq );
169178
r6427r6428
11221131
11231132/*
11241133 *  I/O ports 0x4c0-0x4cf
1125 *  CD-ROM driver (SCSI?)
1134 *  CD-ROM driver (custom?)
1135 *
1136 *  0x4c0 - Status port (R/W)
1137 *    bit 7 - IRQ from sub MPU (reset when read)
1138 *    bit 6 - IRQ from DMA end (reset when read)
1139 *    bit 5 - Software transfer
1140 *    bit 4 - DMA transfer
1141 *    bit 1 - status read request
1142 *    bit 0 - ready
1143 *
1144 *  0x4c2 - Command port (R/W)
1145 *    On read, returns status byte (4 in total?)
1146 *    On write, performs specified command:
1147 *      bit 7 - command type
1148 *      bit 6 - IRQ
1149 *      bit 5 - status
1150 *      bits 4-0 - command
1151 *        Type=1:
1152 *          0 = set state
1153 *          1 = set state (CDDASET)
1154 *        Type=0:
1155 *          0 = Seek
1156 *          2 = Read (MODE1)
1157 *          5 = TOC Read
1158 *
1159 *  0x4c4 - Parameter port (R/W)
1160 *    Inserts a byte into an array of 8 bytes used for command parameters
1161 *    Writing to this port puts the byte at the front of the array, and
1162 *    pushes the other parameters back.  Parameters are in BCD?
1163 *
1164 *  0x4c6 (W/O)
1165 *    bit 3 - software transfer mode
1166 *    bit 4 - DMA transfer mode
1167 *
11261168 */
1169static void towns_cdrom_execute_command(void)
1170{
1171   // For now, we'll return status codes that hopefully tell the system
1172   // that there is no CD-ROM in the drive.
1173   
1174   towns_cd.status |= 0x02;  // status read request
1175   towns_cd.cmd_status_ptr = 0;
1176   towns_cd.cmd_status[0] = 0x10;
1177   towns_cd.cmd_status[1] = 0x00;
1178   towns_cd.cmd_status[2] = 0x00;
1179   towns_cd.cmd_status[3] = 0x00;
1180}
1181
11271182static READ8_HANDLER(towns_cdrom_r)
11281183{
1184   logerror("CD: read port %02x\n",offset*2);
11291185   switch(offset)
11301186   {
1131      case 0x00:
1132         return 0x01;
1187      case 0x00:  // status
1188         return towns_cd.status;
1189      case 0x01:  // command status
1190         if(towns_cd.cmd_status_ptr > 3)
1191         {
1192            towns_cd.cmd_status_ptr = 0;
1193            towns_cd.status &= ~0x02;
1194         }
1195         return towns_cd.cmd_status[towns_cd.cmd_status_ptr++];
11331196      default:
1134         logerror("CD: read port %02x\n",offset*2);
11351197         return 0x00;
11361198   }
11371199}
11381200
11391201static WRITE8_HANDLER(towns_cdrom_w)
11401202{
1203   int x;
11411204   switch(offset)
11421205   {
1206      case 0x00: // status
1207         logerror("CD: status write %02x\n",data);
1208         break;
1209      case 0x01: // command
1210         towns_cd.command = data;
1211         towns_cdrom_execute_command();
1212         logerror("CD: command %02x sent\n",data);
1213         logerror("CD: parameters: %02x %02x %02x %02x %02x %02x %02x %02x\n",
1214            towns_cd.parameter[0],towns_cd.parameter[1],towns_cd.parameter[2],
1215            towns_cd.parameter[3],towns_cd.parameter[4],towns_cd.parameter[5],
1216            towns_cd.parameter[6],towns_cd.parameter[7]);
1217         break;
1218      case 0x02: // parameter
1219         for(x=0;x<7;x++)
1220            towns_cd.parameter[x+1] = towns_cd.parameter[x];
1221         towns_cd.parameter[0] = data;
1222         logerror("CD: parameter %02x added\n",data);
1223         break;
11431224      default:
1144         logerror("CD: read port %02x\n",offset*2);
1225         logerror("CD: write port %02x\n",offset*2);
11451226   }
11461227}
11471228
r6427r6428
16431724   towns_vram_wplane = 0x00;
16441725   towns_kb_status = 0x18;
16451726   towns_kb_irq1_enable = 0;
1727   towns_cd.status = 0x01;  // CDROM controller ready
16461728   timer_adjust_periodic(towns_rtc_timer,attotime_zero,0,ATTOTIME_IN_HZ(1));
16471729   timer_adjust_periodic(towns_kb_timer,attotime_zero,0,ATTOTIME_IN_MSEC(10));
16481730}

Previous 15994 Revisions Next


© 1998-2018 The MESS Team