Previous 15994 Revisions Next

r823 Tuesday 14th August, 2007 at 10:45:32 UTC by Curt Coder
[ATARIST] Rewrote FDC emulation
[src/mess/drivers]atarist.c

src/mess/drivers/atarist.c
r822r823
1212#include "includes/serial.h"
1313#include "machine/6850acia.h"
1414#include "machine/68901mfp.h"
15#include "machine/rp5c15.h"
1516#include "machine/wd17xx.h"
16#include "machine/rp5c15.h"
1717#include "sound/ay8910.h"
1818
1919/*
2020
2121   TODO:
2222
23   - US keyboard layout
24   - add serial communications to HD63701 cpu core
25   - MFP interrupts
23   - proper UK TOS roms
24   - save state support
25   - serial communications for the HD63701 cpu
26   - US keyboard layout for the special keys
2627   - accurate screen timing
27   - fdc.dma_int ?
28   - save states
29   - memory shadow
30   - proper UK TOS roms
28   - memory shadow for boot memory check
3129
3230*/
3331
3432#define Y1      2457600.0
3533
36/* WD1772 FDC */
34/* Floppy Disk Controller */
3735
38static struct FDC
36#define ATARIST_FLOPPY_STATUS_FDC_DATA_REQUEST   0x04
37#define ATARIST_FLOPPY_STATUS_SECTOR_COUNT_ZERO   0x02
38#define ATARIST_FLOPPY_STATUS_DMA_ERROR         0x01
39
40#define ATARIST_FLOPPY_MODE_WRITE            0x0100
41#define ATARIST_FLOPPY_MODE_FDC_ACCESS         0x0080
42#define ATARIST_FLOPPY_MODE_DMA_DISABLE         0x0040
43#define ATARIST_FLOPPY_MODE_SECTOR_COUNT      0x0010
44#define ATARIST_FLOPPY_MODE_HDC               0x0008
45#define ATARIST_FLOPPY_MODE_ADDRESS_MASK      0x0006
46
47#define ATARIST_FLOPPY_BYTES_PER_SECTOR         512
48
49struct FDC
3950{
40   int dma_status;
41   int reg;
42   int dma_sector_count;
43   int dma_select;
44   int dma_direction;
45   UINT32 dma_base;
46   int dma_bytes;
47   int dma_int;
48   int active;
49   int interrupt;
51   UINT32 dmabase;
52   UINT16 status, mode;
53   UINT8 sectors;
54   int dmabytes;
55   int irq;
5056} fdc;
5157
52static void atarist_dma_transfer(void)
58static void atarist_fdc_dma_transfer(void)
5359{
54   UINT8 *RAM = memory_region(REGION_CPU1) + fdc.dma_base;
60   UINT8 *RAM = memory_region(REGION_CPU1) + fdc.dmabase;
5561
56   if (fdc.dma_direction)
62   if ((fdc.mode & ATARIST_FLOPPY_MODE_DMA_DISABLE) == 0)
5763   {
58      wd17xx_data_w(0, RAM[0]);
59   }
60   else
61   {
62      RAM[0] = wd17xx_data_r(0);
63   }
64      if (fdc.sectors > 0)
65      {
66         if (fdc.mode & ATARIST_FLOPPY_MODE_WRITE)
67         {
68            wd17xx_data_w(0, RAM[0]);
69         }
70         else
71         {
72            RAM[0] = wd17xx_data_r(0);
73         }
6474
65   fdc.dma_base++;
66   fdc.dma_bytes--;
75         fdc.dmabase++;
76         fdc.dmabytes--;
6777
68   if (fdc.dma_bytes == 0)
69   {
70      fdc.dma_int = ASSERT_LINE;
78         if (fdc.dmabytes == 0)
79         {
80            fdc.sectors--;
81
82            if (fdc.sectors == 0)
83            {
84               fdc.status &= ~ATARIST_FLOPPY_STATUS_SECTOR_COUNT_ZERO;
85            }
86            else
87            {
88               fdc.dmabytes = ATARIST_FLOPPY_BYTES_PER_SECTOR;
89            }
90         }
91      }
7192   }
72   else
73   {
74      fdc.dma_int = CLEAR_LINE;
75   }
7693}
7794
7895static void atarist_fdc_callback(wd17xx_state_t event, void *param)
r822r823
8097   switch (event)
8198   {
8299   case WD17XX_IRQ_CLR:
83      fdc.interrupt = CLEAR_LINE;
100      fdc.irq = CLEAR_LINE;
84101      break;
85   case WD17XX_DRQ_CLR:
86      break;
102
87103   case WD17XX_IRQ_SET:
88      fdc.interrupt = ASSERT_LINE;
104      fdc.irq = ASSERT_LINE;
89105      break;
106
90107   case WD17XX_DRQ_SET:
91      if (fdc.dma_select == 0)
92      {
93         atarist_dma_transfer();
94      }
108      fdc.status &= ~ATARIST_FLOPPY_STATUS_FDC_DATA_REQUEST;
109      atarist_fdc_dma_transfer();
95110      break;
111
112   case WD17XX_DRQ_CLR:
113      fdc.status |= ATARIST_FLOPPY_STATUS_FDC_DATA_REQUEST;
114      break;
96115   }
97116}
98117
99static READ16_HANDLER( atarist_fdc_r )
118static READ16_HANDLER( atarist_fdc_data_r )
100119{
101   switch (offset)
120   if (fdc.mode & ATARIST_FLOPPY_MODE_SECTOR_COUNT)
102121   {
103   case 0: // reserved
104   case 2: // reserved
105      break;
122      return fdc.sectors;
123   }
124   else
125   {
126      if (fdc.mode & ATARIST_FLOPPY_MODE_HDC)
127      {
128         // HDC not implemented
129         fdc.status &= ~ATARIST_FLOPPY_STATUS_DMA_ERROR;
106130
107   case 4: // data register
108      fdc.active = 0; //todo?
131         return 0;
132      }
133      else
134      {
135         return wd17xx_r((fdc.mode & ATARIST_FLOPPY_MODE_ADDRESS_MASK) >> 1);
136      }
137   }
138}
109139
110      switch (fdc.reg & 0x0f)
140static WRITE16_HANDLER( atarist_fdc_data_w )
141{
142   if (fdc.mode & ATARIST_FLOPPY_MODE_SECTOR_COUNT)
143   {
144      if (data == 0)
111145      {
112      // A0/A1 pins on wd179x controller
113      case 0:
114         fdc.dma_status = 1;
115         return wd17xx_status_r(0);
116      case 1:
117         fdc.dma_status = 1;
118         return wd17xx_track_r(0);
119      case 2:
120         fdc.dma_status = 1;
121         return wd17xx_sector_r(0);
122      case 3:
123         fdc.dma_status = 1;
124         return wd17xx_data_r(0);
146         fdc.status &= ~ATARIST_FLOPPY_STATUS_SECTOR_COUNT_ZERO;
147      }
148      else
149      {
150         fdc.status |= ATARIST_FLOPPY_STATUS_SECTOR_COUNT_ZERO;
151      }
125152
126      // HDC register select - Unimplemented
127      case 4:
128      case 5:
129      case 6:
130      case 7:
131         fdc.dma_status = 0; // Force DMA error on hard-disk accesses
132         break;
133
134      // DMA sector count register
135      default:
136         fdc.dma_status = 1;
137         return fdc.dma_sector_count;
153      fdc.sectors = data;
154   }
155   else
156   {
157      if (fdc.mode & ATARIST_FLOPPY_MODE_HDC)
158      {
159         // HDC not implemented
160         fdc.status &= ~ATARIST_FLOPPY_STATUS_DMA_ERROR;
138161      }
139      break;
162      else
163      {
164         wd17xx_w((fdc.mode & ATARIST_FLOPPY_MODE_ADDRESS_MASK) >> 1, data);
165      }
166   }
167}
140168
141   case 6: // Status register
142      return 0xfe | fdc.dma_status;
169static READ16_HANDLER( atarist_fdc_dma_status_r )
170{
171   return fdc.status;
172}
173
174static WRITE16_HANDLER( atarist_fdc_dma_mode_w )
175{
176   if ((data & ATARIST_FLOPPY_MODE_WRITE) != (fdc.mode & ATARIST_FLOPPY_MODE_WRITE))
177   {
178      fdc.status = 0;
143179   }
144180
145   return 0xff;
181   fdc.mode = data;
146182}
147183
148static WRITE16_HANDLER( atarist_fdc_w )
184static READ16_HANDLER( atarist_fdc_dma_base_r )
149185{
150186   switch (offset)
151187   {
152   case 0: // Unused
188   case 0:
189      return (fdc.dmabase >> 16) & 0xff;
190   case 1:
191      return (fdc.dmabase >> 8) & 0xff;
153192   case 2:
193      return fdc.dmabase & 0xff;
194   }
195
196   return 0;
197}
198
199static WRITE16_HANDLER( atarist_fdc_dma_base_w )
200{
201   switch (offset)
202   {
203   case 0:
204      fdc.dmabase = (fdc.dmabase & 0x00ffff) | ((data & 0xff) << 16);
205      fdc.dmabytes = ATARIST_FLOPPY_BYTES_PER_SECTOR;
154206      break;
155   case 4: // Data register
156      switch (fdc.reg & 0x0f)
157      {
158      // A0/A1 pins on wd179x controller
159      case 0:
160         wd17xx_command_w(0, data & 0xff);
161         break;
162      case 1:
163         wd17xx_track_w(0, data & 0xff);
164         break;
165      case 2:
166         wd17xx_sector_w(0, data & 0xff);
167         break;
168      case 3:
169         wd17xx_data_w(0, data & 0xff);
170         break;
171      // HDC register select - Unimplemented
172      case 4:
173      case 5:
174      case 6:
175      case 7:
176         break;
177      // DMA sector count register
178      default:
179         fdc.dma_sector_count = data & 0xff;
180         break;
181      }
207   case 1:
208      fdc.dmabase = (fdc.dmabase & 0xff00ff) | ((data & 0xff) << 8);
209      fdc.dmabytes = ATARIST_FLOPPY_BYTES_PER_SECTOR;
182210      break;
183   case 6: // Select/Status register
184      fdc.reg = (data >> 1) & 0x0f;
185      fdc.dma_select = data & 0x40;
186      fdc.dma_direction = data & 0x100;
211   case 2:
212      fdc.dmabase = (fdc.dmabase & 0xffff00) | (data & 0xff);
213      fdc.dmabytes = ATARIST_FLOPPY_BYTES_PER_SECTOR;
187214      break;
188   case 8:
189      fdc.dma_base = (fdc.dma_base & 0x00ffff) | ((data & 0xff) << 16);
190      fdc.dma_bytes = 512;
191      break;
192   case 10:
193      fdc.dma_base = (fdc.dma_base & 0xff00ff) | ((data & 0xff) << 8);
194      fdc.dma_bytes = 512;
195      break;
196   case 12:
197      fdc.dma_base = (fdc.dma_base & 0xffff00) | (data & 0xff);
198      fdc.dma_bytes = 512;
199      break;
200215   }
201216}
202217
r822r823
433448   AM_RANGE(0xff820a, 0xff820b) AM_READWRITE(atarist_shifter_sync_r, atarist_shifter_sync_w)
434449   AM_RANGE(0xff8240, 0xff825f) AM_READWRITE(atarist_shifter_palette_r, atarist_shifter_palette_w)
435450   AM_RANGE(0xff8260, 0xff8261) AM_READWRITE(atarist_shifter_mode_r, atarist_shifter_mode_w)
436   AM_RANGE(0xff8600, 0xff860f) AM_READWRITE(atarist_fdc_r, atarist_fdc_w)
451   AM_RANGE(0xff8604, 0xff8605) AM_READWRITE(atarist_fdc_data_r, atarist_fdc_data_w)
452   AM_RANGE(0xff8606, 0xff8607) AM_READWRITE(atarist_fdc_dma_status_r, atarist_fdc_dma_mode_w)
453   AM_RANGE(0xff8608, 0xff860d) AM_READWRITE(atarist_fdc_dma_base_r, atarist_fdc_dma_base_w)
437454   AM_RANGE(0xff8800, 0xff8801) AM_READWRITE(AY8910_read_port_0_msb_r, AY8910_control_port_0_msb_w)
438455   AM_RANGE(0xff8802, 0xff8803) AM_WRITE(AY8910_write_port_0_msb_w)
439456   AM_RANGE(0xfffa00, 0xfffa2f) AM_READWRITE(mfp68901_0_register16_r, mfp68901_0_register_lsb_w)
r822r823
455472   AM_RANGE(0xff820a, 0xff820b) AM_READWRITE(atarist_shifter_sync_r, atarist_shifter_sync_w)
456473   AM_RANGE(0xff8240, 0xff825f) AM_READWRITE(atarist_shifter_palette_r, atarist_shifter_palette_w)
457474   AM_RANGE(0xff8260, 0xff8261) AM_READWRITE(atarist_shifter_mode_r, atarist_shifter_mode_w)
458   AM_RANGE(0xff8600, 0xff860f) AM_READWRITE(atarist_fdc_r, atarist_fdc_w)
475   AM_RANGE(0xff8604, 0xff8605) AM_READWRITE(atarist_fdc_data_r, atarist_fdc_data_w)
476   AM_RANGE(0xff8606, 0xff8607) AM_READWRITE(atarist_fdc_dma_status_r, atarist_fdc_dma_mode_w)
477   AM_RANGE(0xff8608, 0xff860d) AM_READWRITE(atarist_fdc_dma_base_r, atarist_fdc_dma_base_w)
459478   AM_RANGE(0xff8800, 0xff8801) AM_READWRITE(AY8910_read_port_0_msb_r, AY8910_control_port_0_msb_w)
460479   AM_RANGE(0xff8802, 0xff8803) AM_WRITE(AY8910_write_port_0_msb_w)
461480//   AM_RANGE(0xff8a00, 0xff8a3f) AM_READWRITE(atarist_blitter_r, atarist_blitter_w)
r822r823
769788   }
770789
771790   data |= acia_int << 4;
772   data |= fdc.interrupt << 5;
791   data |= fdc.irq << 5;
773792   data |= readinputportbytag("config") & 0x80;
774793
775794   return data;
r822r823
848867   acia6850_config(1, &acia_midi_intf);
849868
850869   mfp68901_config(0, &mfp_intf);
870
871   memset(&fdc, 0, sizeof(fdc));
851872}
852873
853874static struct rp5c15_interface rtc_intf =
r822r823
11641185/*
11651186COMP( 1989, stacy,    atarist,  0,      stacy,    stacy,    0,     stacy,    "Atari", "STacy", GAME_NOT_WORKING )
11661187COMP( 1992, stbook,   atarist,  0,      stbook,   stbook,   0,     stbook,    "Atari", "ST Book", GAME_NOT_WORKING )
1167COMP( 1989, atariste, 0,      0,      atariste, atarist,  0,     atariste, "Atari", "STE", GAME_NOT_WORKING )
1168COMP( 1991, megaste,  atariste, 0,      megaste,  atarist,  0,     megaste,  "Atari", "Mega STE", GAME_NOT_WORKING )
1188COMP( 1989, atariste, 0,      0,      atariste, atariste, 0,     atariste, "Atari", "STE", GAME_NOT_WORKING )
1189COMP( 1991, megaste,  atariste, 0,      megaste,  atariste, 0,     megaste,  "Atari", "Mega STE", GAME_NOT_WORKING )
11691190COMP( 1990, tt030,    0,        0,      tt030,    tt030,    0,     tt030,    "Atari", "TT030", GAME_NOT_WORKING )
11701191COMP( 1992, falcon,   0,        0,      falcon,   falcon,   0,     falcon,    "Atari", "Falcon030", GAME_NOT_WORKING )
11711192*/

Previous 15994 Revisions Next


© 1998-2018 The MESS Team