Previous 15994 Revisions Next

r9348 Sunday 10th October, 2010 at 01:35:54 UTC by Barry Rodewald
[FMTOWNS] Made a start on implementing SCSI support. Not working yet, as DMA is not hooked up, and scsibus lacks support for the ATN line.
[src/mess/drivers]fmtowns.c
[src/mess/includes]fmtowns.h
[src/mess/video]fmtowns.c

src/mess/video/fmtowns.c
r9347r9348
499499   {
500500      case 0x02:  // 0x5ca - VSync clear?
501501         pic8259_ir3_w(dev, 0);
502         logerror("PIC: IRQ11 (VSync) set low\n");
502         if(IRQ_LOG) logerror("PIC: IRQ11 (VSync) set low\n");
503503         //towns_vblank_flag = 0;
504504         break;
505505   }
r9347r9348
18031803   towns_state* state = machine->driver_data<towns_state>();
18041804   running_device* dev = (running_device*)ptr;
18051805   pic8259_ir3_w(dev, 0);  // IRQ11 = VSync
1806   logerror("PIC: IRQ11 (VSync) set low\n");
1806   if(IRQ_LOG) logerror("PIC: IRQ11 (VSync) set low\n");
18071807   state->video.towns_vblank_flag = 0;
18081808}
18091809
r9347r9348
18121812   towns_state* state = device->machine->driver_data<towns_state>();
18131813   running_device* dev = state->pic_slave;
18141814   pic8259_ir3_w(dev, 1);  // IRQ11 = VSync
1815   logerror("PIC: IRQ11 (VSync) set high\n");
1815   if(IRQ_LOG) logerror("PIC: IRQ11 (VSync) set high\n");
18161816   state->video.towns_vblank_flag = 1;
18171817   timer_set(device->machine,device->machine->primary_screen->time_until_vblank_end(),(void*)dev,0,towns_vblank_end);
18181818   if(state->video.towns_tvram_enable)
src/mess/includes/fmtowns.h
r9347r9348
33
44#include "emu.h"
55
6#define IRQ_LOG 0  // set to 1 to log IRQ line activity
7
68READ8_HANDLER( towns_gfx_high_r );
79WRITE8_HANDLER( towns_gfx_high_w );
810READ8_HANDLER( towns_gfx_r );
r9347r9348
120122   UINT8 towns_mouse_y;
121123   UINT8 towns_volume[8];  // volume ports
122124   UINT8 towns_volume_select;
125   UINT8 towns_scsi_control;
126   UINT8 towns_scsi_status;
123127   struct towns_cdrom_controller towns_cd;
124128   struct towns_video_controller video;
125129   required_shared_ptr<UINT8>   m_nvram;
r9347r9348
135139   running_device* messram;
136140   running_device* cdrom;
137141   running_device* cdda;
138
142   running_device* scsibus;
143   running_device* hd0;
144   running_device* hd1;
145   running_device* hd2;
146   running_device* hd3;
147   running_device* hd4;
139148};
140149
141150void towns_update_video_banks(address_space*);
src/mess/drivers/fmtowns.c
r9347r9348
126126#include "devices/messram.h"
127127#include "includes/fmtowns.h"
128128#include "machine/nvram.h"
129#include "devices/harddriv.h"
130#include "machine/scsi.h"
131#include "machine/scsibus.h"
129132
130133// CD controller IRQ types
131134#define TOWNS_CD_IRQ_MPU 1
r9347r9348
362365   if(tstate->towns_fdc_irq6mask == 0)
363366      state = 0;
364367   pic8259_ir6_w(device, state);  // IRQ6 = FDC
365   logerror("PIC: IRQ6 (FDC) set to %i\n",state);
368   if(IRQ_LOG) logerror("PIC: IRQ6 (FDC) set to %i\n",state);
366369}
367370
368371static WRITE_LINE_DEVICE_HANDLER( towns_mb8877a_drq_w )
r9347r9348
533536   if(state->towns_kb_irq1_enable)
534537   {
535538      pic8259_ir1_w(dev, 1);
536      logerror("PIC: IRQ1 (keyboard) set high\n");
539      if(IRQ_LOG) logerror("PIC: IRQ1 (keyboard) set high\n");
537540   }
538541   logerror("KB: sending scancode 0x%02x\n",scancode);
539542}
r9347r9348
576579         ret = state->towns_kb_output;
577580         //logerror("KB: read keyboard output port, returning %02x\n",ret);
578581         pic8259_ir1_w(state->pic_master, 0);
579         logerror("PIC: IRQ1 (keyboard) set low\n");
582         if(IRQ_LOG) logerror("PIC: IRQ1 (keyboard) set low\n");
580583         if(state->towns_kb_extend != 0xff)
581584         {
582585            towns_kb_sendcode(space->machine,state->towns_kb_extend,2);
r9347r9348
721724         state->towns_pcm_channel_flag = 0;
722725         state->towns_pcm_irq_flag = 0;
723726         pic8259_ir5_w(state->pic_slave, 0);
724         logerror("PIC: IRQ13 (PCM) set low\n");
727         if(IRQ_LOG) logerror("PIC: IRQ13 (PCM) set low\n");
725728         break;
726729//      default:
727730         //logerror("FM: unimplemented port 0x%04x read\n",offset + 0x4e8);
r9347r9348
11391142               {
11401143                  tstate->towns_cd.status |= 0x80;
11411144                  pic8259_ir1_w(tstate->pic_slave, 1);
1142                  logerror("PIC: IRQ9 (CD-ROM) set high\n");
1145                  if(IRQ_LOG) logerror("PIC: IRQ9 (CD-ROM) set high\n");
11431146               }
11441147            }
11451148            else
r9347r9348
11491152         {
11501153            tstate->towns_cd.status &= ~0x80;
11511154            pic8259_ir1_w(tstate->pic_slave, 0);
1152            logerror("PIC: IRQ9 (CD-ROM) set low\n");
1155            if(IRQ_LOG) logerror("PIC: IRQ9 (CD-ROM) set low\n");
11531156         }
11541157         break;
11551158      case TOWNS_CD_IRQ_DMA:
r9347r9348
11611164               {
11621165                  tstate->towns_cd.status |= 0x40;
11631166                  pic8259_ir1_w(tstate->pic_slave, 1);
1164                  logerror("PIC: IRQ9 (CD-ROM DMA) set high\n");
1167                  if(IRQ_LOG) logerror("PIC: IRQ9 (CD-ROM DMA) set high\n");
11651168               }
11661169            }
11671170            else
r9347r9348
11711174         {
11721175            tstate->towns_cd.status &= ~0x40;
11731176            pic8259_ir1_w(tstate->pic_slave, 0);
1174            logerror("PIC: IRQ9 (CD-ROM DMA) set low\n");
1177            if(IRQ_LOG) logerror("PIC: IRQ9 (CD-ROM DMA) set low\n");
11751178         }
11761179         break;
11771180   }
r9347r9348
17601763}
17611764
17621765// SCSI controller - I/O ports 0xc30 and 0xc32
1766// info from Toshiya Takeda's e-FMR50 source (the Towns uses the same controller?)
1767// 0xc30 = Data register
1768// 0xc32 = Status register (read)
1769//         bit 7 = REQ
1770//         bit 6 = IO
1771//         bit 5 = MSG
1772//         bit 4 = CD
1773//         bit 3 = BUSY
1774//         bit 1 = INT
1775//         bit 0 = PERR
1776// 0xc32 = Control register (write)
1777//         bit 7 = WEN
1778//         bit 6 = IMSK
1779//         bit 4 = ATN
1780//         bit 2 = SEL
1781//         bit 1 = DMAE
1782//         bit 0 = RST
17631783static READ8_HANDLER(towns_scsi_r)
17641784{
1765   logerror("scsi_r (offset %i) read\n",offset);
1766   if(offset == 2)
1767      return 0x08;
1785   towns_state* state = space->machine->driver_data<towns_state>();
1786   UINT8 ret = 0x00;
1787//   logerror("scsi_r (offset %i) read\n",offset);
1788   switch(offset)
1789   {
1790   case 0x00:
1791      return scsi_data_r(state->scsibus);
1792   case 0x02:
1793      ret |= (get_scsi_line(state->scsibus,SCSI_LINE_REQ)) ? 0x00 : 0x80;
1794      ret |= (get_scsi_line(state->scsibus,SCSI_LINE_IO)) ? 0x00 : 0x40;
1795      ret |= (get_scsi_line(state->scsibus,SCSI_LINE_MSG)) ? 0x00 : 0x20;
1796      ret |= (get_scsi_line(state->scsibus,SCSI_LINE_CD)) ? 0x00 : 0x10;
1797      ret |= (get_scsi_line(state->scsibus,SCSI_LINE_BSY)) ? 0x00 : 0x08;
1798      return ret;
1799   }
17681800   return 0x00;
17691801}
17701802
1803static WRITE8_HANDLER(towns_scsi_w)
1804{
1805   towns_state* state = space->machine->driver_data<towns_state>();
1806   switch(offset)
1807   {
1808   case 0x00:
1809      scsi_data_w(state->scsibus,data);
1810      set_scsi_line(state->scsibus,SCSI_LINE_ACK,0);
1811      logerror("SCSI data write %02x\n",data);
1812      break;
1813   case 0x02:
1814      set_scsi_line(state->scsibus,SCSI_LINE_SEL,data & 0x04);
1815      if(data & 0x01)
1816      {
1817         set_scsi_line(state->scsibus,SCSI_LINE_RESET,data & 0x01);
1818      }
1819      logerror("SCSI control write %02x\n",data);
1820      break;
1821   }
1822}
1823
1824void towns_scsi_linechange(running_device *device, UINT8 line, UINT8 state)
1825{
1826   towns_state* tstate = device->machine->driver_data<towns_state>();
1827
1828   if(state == 0)
1829   {
1830      switch(line)
1831      {
1832      case SCSI_LINE_REQ:
1833         break;
1834      case SCSI_LINE_IO:
1835         break;
1836      case SCSI_LINE_MSG:
1837         break;
1838      case SCSI_LINE_CD:
1839         break;
1840      case SCSI_LINE_BSY:
1841         break;
1842      }
1843   }
1844   else
1845   {
1846      switch(line)
1847      {
1848      case SCSI_LINE_REQ:
1849         set_scsi_line(tstate->scsibus,SCSI_LINE_ACK,1);
1850         break;
1851      case SCSI_LINE_IO:
1852         break;
1853      case SCSI_LINE_MSG:
1854         break;
1855      case SCSI_LINE_CD:
1856         break;
1857      case SCSI_LINE_BSY:
1858         break;
1859      }
1860   }
1861
1862}
1863
17711864// Volume ports - I/O ports 0x4e0-0x4e3
1772// 0x4e3 = channel select
1773//         (4 and 5 = CD-DA left and right channels)
1774//         (6 = MIC?)
1775// 0x4e2 = volume level
1865// 0x4e0 = input volume level
1866// 0x4e1 = input channel select
1867//         4 = Line in, left channel
1868//         5 = Line in, right channel
1869// 0x4e2 = output volume level
1870// 0x4e3 = output channel select
1871//         2 = MIC
1872//         3 = MODEM
1873//         4 = CD-DA left channel
1874//         5 = CD-DA right channel
17761875static READ8_HANDLER(towns_volume_r)
17771876{
17781877   towns_state* state = space->machine->driver_data<towns_state>();
r9347r9348
18431942   {
18441943      state->towns_fm_irq_flag = 1;
18451944      pic8259_ir5_w(pic, 1);
1846      logerror("PIC: IRQ13 (FM) set high\n");
1945      if(IRQ_LOG) logerror("PIC: IRQ13 (FM) set high\n");
18471946   }
18481947   else
18491948   {
18501949      state->towns_fm_irq_flag = 0;
18511950      pic8259_ir5_w(pic, 0);
1852      logerror("PIC: IRQ13 (FM) set low\n");
1951      if(IRQ_LOG) logerror("PIC: IRQ13 (FM) set low\n");
18531952   }
18541953}
18551954
r9347r9348
18641963      state->towns_pcm_irq_flag = 1;
18651964      state->towns_pcm_channel_flag |= (1 << channel);
18661965      pic8259_ir5_w(pic, 1);
1867      logerror("PIC: IRQ13 (PCM) set high (channel %i)\n",channel);
1966      if(IRQ_LOG) logerror("PIC: IRQ13 (PCM) set high (channel %i)\n",channel);
18681967   }
18691968}
18701969
r9347r9348
18821981   if(tstate->towns_timer_mask & 0x01)
18831982   {
18841983      pic8259_ir0_w(dev, state);
1885      logerror("PIC: IRQ0 (PIT Timer) set to %i\n",state);
1984      if(IRQ_LOG) logerror("PIC: IRQ0 (PIT Timer) set to %i\n",state);
18861985   }
18871986}
18881987
r9347r9348
19892088  // Keyboard (8042 MCU)
19902089  AM_RANGE(0x0600,0x0607) AM_READWRITE8(towns_keyboard_r, towns_keyboard_w,0x00ff00ff)
19912090  // SCSI controller
1992  AM_RANGE(0x0c30,0x0c33) AM_READ8(towns_scsi_r,0xffffffff)
2091  AM_RANGE(0x0c30,0x0c33) AM_READWRITE8(towns_scsi_r,towns_scsi_w,0xffffffff)
19932092  // CMOS
19942093  AM_RANGE(0x3000,0x3fff) AM_READWRITE8(towns_cmos8_r, towns_cmos8_w,0x00ff00ff)
19952094  // Something (MS-DOS wants this 0x41ff to be 1)
r9347r9348
22322331   state->towns_cd.read_timer = timer_alloc(machine,towns_cdrom_read_byte,(void*)machine->device("dma_1"));
22332332
22342333   cpu_set_irq_callback(machine->device("maincpu"), towns_irq_callback);
2334   init_scsibus(machine->device("scsibus"));
22352335}
22362336
22372337static DRIVER_INIT( marty )
r9347r9348
22542354   state->messram = machine->device("messram");
22552355   state->cdrom = machine->device("cdrom");
22562356   state->cdda = machine->device("cdda");
2357   state->scsibus = machine->device("scsibus");
2358   state->hd0 = machine->device("harddisk0");
2359   state->hd1 = machine->device("harddisk1");
2360   state->hd2 = machine->device("harddisk2");
2361   state->hd3 = machine->device("harddisk3");
2362   state->hd4 = machine->device("harddisk4");
22572363   state->ftimer = 0x00;
22582364   state->nmi_mask = 0x00;
22592365   state->compat_mode = 0x00;
r9347r9348
23522458   towns_pcm_irq
23532459};
23542460
2461static const SCSIConfigTable towns_scsi_device_table =
2462{
2463   5,                                      /* 5 SCSI devices */
2464   {
2465      { SCSI_ID_0, "harddisk0", SCSI_DEVICE_HARDDISK },
2466      { SCSI_ID_1, "harddisk1", SCSI_DEVICE_HARDDISK },
2467      { SCSI_ID_2, "harddisk2", SCSI_DEVICE_HARDDISK },
2468      { SCSI_ID_3, "harddisk3", SCSI_DEVICE_HARDDISK },
2469      { SCSI_ID_4, "harddisk4", SCSI_DEVICE_HARDDISK },
2470   }
2471};
2472
2473static const SCSIBus_interface towns_scsi_config =
2474{
2475    &towns_scsi_device_table,
2476    &towns_scsi_linechange
2477};
2478
23552479static const gfx_layout fnt_chars_16x16 =
23562480{
23572481   16,16,
r9347r9348
24212545
24222546   MDRV_CDROM_ADD("cdrom")
24232547
2548   MDRV_HARDDISK_ADD("harddisk0")
2549   MDRV_HARDDISK_ADD("harddisk1")
2550   MDRV_HARDDISK_ADD("harddisk2")
2551   MDRV_HARDDISK_ADD("harddisk3")
2552   MDRV_HARDDISK_ADD("harddisk4")
2553   MDRV_SCSIBUS_ADD("scsibus",towns_scsi_config)
2554
24242555   MDRV_UPD71071_ADD("dma_1",towns_dma_config)
24252556   MDRV_UPD71071_ADD("dma_2",towns_dma_config)
24262557

Previous 15994 Revisions Next


© 1998-2018 The MESS Team