src/mess/drivers/fmtowns.c
| r6427 | r6428 | |
| 164 | 164 | static UINT16 towns_crtc_reg[32]; |
| 165 | 165 | static UINT8 towns_tvram_enable; |
| 166 | 166 | |
| 167 | struct 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 | |
| 167 | 176 | static void towns_update_video_banks(const address_space* space); |
| 168 | 177 | static PIC8259_SET_INT_LINE( towns_pic_irq ); |
| 169 | 178 | |
| r6427 | r6428 | |
| 1122 | 1131 | |
| 1123 | 1132 | /* |
| 1124 | 1133 | * 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 | * |
| 1126 | 1168 | */ |
| 1169 | static 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 | |
| 1127 | 1182 | static READ8_HANDLER(towns_cdrom_r) |
| 1128 | 1183 | { |
| 1184 | logerror("CD: read port %02x\n",offset*2); |
| 1129 | 1185 | switch(offset) |
| 1130 | 1186 | { |
| 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++]; |
| 1133 | 1196 | default: |
| 1134 | | logerror("CD: read port %02x\n",offset*2); |
| 1135 | 1197 | return 0x00; |
| 1136 | 1198 | } |
| 1137 | 1199 | } |
| 1138 | 1200 | |
| 1139 | 1201 | static WRITE8_HANDLER(towns_cdrom_w) |
| 1140 | 1202 | { |
| 1203 | int x; |
| 1141 | 1204 | switch(offset) |
| 1142 | 1205 | { |
| 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; |
| 1143 | 1224 | default: |
| 1144 | | logerror("CD: read port %02x\n",offset*2); |
| 1225 | logerror("CD: write port %02x\n",offset*2); |
| 1145 | 1226 | } |
| 1146 | 1227 | } |
| 1147 | 1228 | |
| r6427 | r6428 | |
| 1643 | 1724 | towns_vram_wplane = 0x00; |
| 1644 | 1725 | towns_kb_status = 0x18; |
| 1645 | 1726 | towns_kb_irq1_enable = 0; |
| 1727 | towns_cd.status = 0x01; // CDROM controller ready |
| 1646 | 1728 | timer_adjust_periodic(towns_rtc_timer,attotime_zero,0,ATTOTIME_IN_HZ(1)); |
| 1647 | 1729 | timer_adjust_periodic(towns_kb_timer,attotime_zero,0,ATTOTIME_IN_MSEC(10)); |
| 1648 | 1730 | } |