Previous 15994 Revisions Next

r6471 Friday 27th November, 2009 at 01:05:40 UTC by Barry Rodewald
[FMTOWNS] Cleaned up CD controller interrupts a bit.
[src/mess/drivers]fmtowns.c

src/mess/drivers/fmtowns.c
r6470r6471
122122#include "machine/upd71071.h"
123123#include "devices/messram.h"
124124
125// CD controller IRQ types
126#define TOWNS_CD_IRQ_MPU 1
127#define TOWNS_CD_IRQ_DMA 2
128
125129static UINT8 ftimer;
126130static UINT8 nmi_mask;
127131static UINT8 compat_mode;
r6470r6471
12011205 *    bit 4 - DMA transfer mode
12021206 *
12031207 */
1208static void towns_cdrom_set_irq(running_machine* machine,int line,int state)
1209{
1210   switch(line)
1211   {
1212      case TOWNS_CD_IRQ_MPU:
1213         if(state != 0)
1214         {
1215            if(towns_cd.command & 0x40)
1216            {
1217               towns_cd.status |= 0x80;
1218               if(towns_cd.mpu_irq_enable)
1219                  pic8259_set_irq_line(devtag_get_device(machine,"pic8259_slave"),1,1);                 
1220            }
1221         }
1222         else
1223         {
1224            towns_cd.status &= ~0x80;
1225            pic8259_set_irq_line(devtag_get_device(machine,"pic8259_slave"),1,0);
1226         }
1227         break;
1228      case TOWNS_CD_IRQ_DMA:
1229         if(state != 0)
1230         {
1231            if(towns_cd.command & 0x40)
1232            {
1233               towns_cd.status |= 0x40;
1234               if(towns_cd.dma_irq_enable)
1235                  pic8259_set_irq_line(devtag_get_device(machine,"pic8259_slave"),1,1);                 
1236            }
1237         }
1238         else
1239         {
1240            towns_cd.status &= ~0x40;
1241            pic8259_set_irq_line(devtag_get_device(machine,"pic8259_slave"),1,0);
1242         }
1243         break;
1244   }
1245}
1246
12041247static TIMER_CALLBACK( towns_cdrom_read_byte )
12051248{
12061249   const device_config* device = ptr;
r6470r6471
12391282            towns_cd.cmd_status[1] = 0x00;
12401283            towns_cd.cmd_status[2] = 0x00;
12411284            towns_cd.cmd_status[3] = 0x00;
1242            if(towns_cd.dma_irq_enable != 0)
1243            {
1244               towns_cd.status |= 0x40;  // IRQ from end of DMA
1245               pic8259_set_irq_line(devtag_get_device(device->machine,"pic8259_slave"),1,0);
1246            }
1285            towns_cdrom_set_irq(device->machine,TOWNS_CD_IRQ_DMA,1);
12471286            towns_cd.status |= 0x01;  // ready
12481287         }
12491288         else
r6470r6471
12551294            towns_cd.cmd_status[1] = 0x00;
12561295            towns_cd.cmd_status[2] = 0x00;
12571296            towns_cd.cmd_status[3] = 0x00;
1258            if(towns_cd.dma_irq_enable != 0)
1259            {
1260               towns_cd.status |= 0x40;  // IRQ from end of DMA
1261               pic8259_set_irq_line(devtag_get_device(device->machine,"pic8259_slave"),1,0);
1262            }
1297            towns_cdrom_set_irq(device->machine,TOWNS_CD_IRQ_DMA,1);
12631298            cdrom_read_data(mess_cd_get_cdrom_file(devtag_get_device(device->machine,"cdrom")),++towns_cd.lba_current,towns_cd.buffer,CD_TRACK_MODE1);
12641299            timer_adjust_oneshot(towns_cd.read_timer,ATTOTIME_IN_HZ(300000),1);
12651300            towns_cd.buffer_ptr = -1;
r6470r6471
12941329      towns_cd.cmd_status[1] = 0x00;
12951330      towns_cd.cmd_status[2] = 0x00;
12961331      towns_cd.cmd_status[3] = 0x00;
1297      if(towns_cd.mpu_irq_enable != 0)
1298      {
1299         towns_cd.status |= 0x80;  // IRQ from MPU
1300         pic8259_set_irq_line(devtag_get_device(device->machine,"pic8259_slave"),1,1);
1301      }
1332      towns_cdrom_set_irq(device->machine,TOWNS_CD_IRQ_MPU,1);
13021333   }
13031334   else
13041335   {
r6470r6471
13131344      towns_cd.cmd_status[1] = 0x00;
13141345      towns_cd.cmd_status[2] = 0x00;
13151346      towns_cd.cmd_status[3] = 0x00;
1316      if(towns_cd.mpu_irq_enable != 0)
1317      {
1318         towns_cd.status |= 0x80;  // IRQ from MPU
1319         pic8259_set_irq_line(devtag_get_device(device->machine,"pic8259_slave"),1,1);
1320      }
1347      towns_cdrom_set_irq(device->machine,TOWNS_CD_IRQ_MPU,1);
13211348   }
13221349   
13231350   // start read timer - assume single-speed currently
r6470r6471
13401367         towns_cd.cmd_status[1] = 0x00;
13411368         towns_cd.cmd_status[2] = 0x00;
13421369         towns_cd.cmd_status[3] = 0x00;
1370         towns_cdrom_set_irq(device->machine,TOWNS_CD_IRQ_MPU,1);
13431371      }
13441372   }
13451373   else
r6470r6471
13561384               towns_cd.cmd_status[1] = 0x00;
13571385               towns_cd.cmd_status[2] = 0x00;
13581386               towns_cd.cmd_status[3] = 0x00;
1359               if(towns_cd.command & 0x40)
1360                  towns_cd.status |= 0x80;  // IRQ from MPU
1387               towns_cdrom_set_irq(device->machine,TOWNS_CD_IRQ_MPU,1);
13611388            }
13621389            logerror("CD: Command 0x00: SEEK\n");
13631390            break;
r6470r6471
13741401               towns_cd.cmd_status[1] = 0x00;
13751402               towns_cd.cmd_status[2] = 0x00;
13761403               towns_cd.cmd_status[3] = 0x00;
1377               if(towns_cd.command & 0x40)
1378                  towns_cd.status |= 0x80;  // IRQ from MPU
1404               towns_cdrom_set_irq(device->machine,TOWNS_CD_IRQ_MPU,1);
13791405            break;
13801406         case 0x80:  // set state
13811407            if(towns_cd.command & 0x20)
r6470r6471
13871413               towns_cd.cmd_status[1] = 0x00;
13881414               towns_cd.cmd_status[2] = 0x00;
13891415               towns_cd.cmd_status[3] = 0x00;
1390               if(towns_cd.command & 0x40)
1391                  towns_cd.status |= 0x80;  // IRQ from MPU
1416               towns_cdrom_set_irq(device->machine,TOWNS_CD_IRQ_MPU,1);
13921417            }
13931418            logerror("CD: Command 0x80: set state\n");
13941419            break;
r6470r6471
14021427               towns_cd.cmd_status[1] = 0x00;
14031428               towns_cd.cmd_status[2] = 0x00;
14041429               towns_cd.cmd_status[3] = 0x00;
1405               if(towns_cd.command & 0x40)
1406                  towns_cd.status |= 0x80;  // IRQ from MPU
1430               towns_cdrom_set_irq(device->machine,TOWNS_CD_IRQ_MPU,1);
14071431            }
14081432            logerror("CD: Command 0x81: set state (CDDASET)\n");
14091433            break;
r6470r6471
14151439            towns_cd.cmd_status[1] = 0x00;
14161440            towns_cd.cmd_status[2] = 0x00;
14171441            towns_cd.cmd_status[3] = 0x00;
1442            towns_cdrom_set_irq(device->machine,TOWNS_CD_IRQ_MPU,1);
14181443            logerror("CD: Unknown or unimplemented command %02x\n",towns_cd.command);
14191444      }
14201445   }
r6470r6471
15521577   {
15531578      case 0x00: // status
15541579         if(data & 0x80)
1555            towns_cd.status &= ~0x80;
1580            towns_cdrom_set_irq(space->machine,TOWNS_CD_IRQ_MPU,0);
15561581         if(data & 0x40)
1557            towns_cd.status &= ~0x40;
1582            towns_cdrom_set_irq(space->machine,TOWNS_CD_IRQ_DMA,0);
15581583         if(data & 0x04)
15591584            logerror("CD: sub MPU reset\n");
15601585         towns_cd.mpu_irq_enable = data & 0x02;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team