Previous 15994 Revisions Next

r6732 Thursday 24th December, 2009 at 11:17:39 UTC by Miodrag Milanović
- Amiga floppy disk controller moved to MAME device
[src/mess]mess.mak
[src/mess/drivers]ami1200.c amiga.c
[src/mess/formats]ami_dsk.c ami_dsk.h
[src/mess/machine]amigafdc.c amigafdc.h

src/mess/machine/amigafdc.c
r6731r6732
1313
1414#include "driver.h"
1515#include "includes/amiga.h"
16#include "devices/flopdrv.h"
17#include "formats/ami_dsk.h"
1618#include "amigafdc.h"
1719#include "machine/6526cia.h"
1820
r6731r6732
3032#define NUM_DRIVES 2
3133
3234/* required prototype */
33static void setup_fdc_buffer( int drive );
35static void setup_fdc_buffer( const device_config *device,int drive );
3436
37/***************************************************************************
38    TYPE DEFINITIONS
39***************************************************************************/
3540typedef struct {
3641   int motor_on;
3742   int side;
r6731r6732
5560   offs_t ptr;
5661} fdc_def;
5762
58static fdc_def fdc_status[NUM_DRIVES];
59/* signals */
60static int fdc_sel = 0x0f;
61static int fdc_dir = 0;
62static int fdc_side = 1;
63static int fdc_step = 1;
64static int fdc_rdy = 0;
63typedef struct _amiga_fdc_t amiga_fdc_t;
64struct _amiga_fdc_t
65{
66   fdc_def fdc_status[NUM_DRIVES];
67   
68   /* signals */
69   int fdc_sel;
70   int fdc_dir;
71   int fdc_side;
72   int fdc_step;
73   int fdc_rdy;
74};
6575
76/*****************************************************************************
77    INLINE FUNCTIONS
78*****************************************************************************/
79INLINE amiga_fdc_t *get_safe_token(const device_config *device)
80{
81   assert(device != NULL);
82   assert(device->token != NULL);
83
84   return (amiga_fdc_t *)device->token;
85}
86
6687static TIMER_CALLBACK(fdc_rev_proc);
6788static TIMER_CALLBACK(fdc_dma_proc);
6889static TIMER_CALLBACK(fdc_sync_proc);
90static void check_extended_image( const device_config *device, int id );
6991
92static void amiga_load_proc(const device_config *image)
93{
94   amiga_fdc_t *fdc = get_safe_token(image->owner);
95   int id = floppy_get_drive(image);
96   fdc->fdc_status[id].disk_changed = DISK_DETECT_DELAY;
97   fdc->fdc_status[id].f = image;
98   fdc->fdc_status[id].cached = -1;
99   fdc->fdc_status[id].motor_on = 0;
100   fdc->fdc_status[id].rev_timer_started = 0;
101   timer_reset( fdc->fdc_status[id].rev_timer, attotime_never );
102   timer_reset( fdc->fdc_status[id].sync_timer, attotime_never );
103   timer_reset( fdc->fdc_status[id].dma_timer, attotime_never );
104   fdc->fdc_rdy = 0;
105
106   check_extended_image( image->owner, id );
107}
108
109static void amiga_unload_proc(const device_config *image)
110{
111   amiga_fdc_t *fdc = get_safe_token(image->owner);
112   int id = floppy_get_drive(image);
113   fdc->fdc_status[id].disk_changed = DISK_DETECT_DELAY;
114   fdc->fdc_status[id].f = NULL;
115   fdc->fdc_status[id].cached = -1;
116   fdc->fdc_status[id].motor_on = 0;
117   fdc->fdc_status[id].rev_timer_started = 0;
118   timer_reset( fdc->fdc_status[id].rev_timer, attotime_never );
119   timer_reset( fdc->fdc_status[id].sync_timer, attotime_never );
120   timer_reset( fdc->fdc_status[id].dma_timer, attotime_never );
121   fdc->fdc_rdy = 0;
122}
123
124/*-------------------------------------------------
125    DEVICE_START(amiga_fdc)
126-------------------------------------------------*/
127const device_config *amiga_floppy_get_device_child(const device_config *device,int drive)
128{
129   switch(drive) {
130      case 0 : return device_find_child_by_tag(device,FLOPPY_0);
131      case 1 : return device_find_child_by_tag(device,FLOPPY_1);
132   }
133   return NULL;
134}
135
70136static DEVICE_START(amiga_fdc)
71137{
72   int id = image_index_in_device(device);
73   fdc_status[id].motor_on = 0;
74   fdc_status[id].side = 0;
75   fdc_status[id].dir = 0;
76   fdc_status[id].wprot = 1;
77   fdc_status[id].cyl = 0;
78   fdc_status[id].rev_timer = timer_alloc(device->machine, fdc_rev_proc, NULL);
79   fdc_status[id].dma_timer = timer_alloc(device->machine, fdc_dma_proc, NULL);
80   fdc_status[id].sync_timer = timer_alloc(device->machine, fdc_sync_proc, NULL);
81   fdc_status[id].rev_timer_started = 0;
82   fdc_status[id].cached = -1;
83   fdc_status[id].pos = 0;
84   fdc_status[id].len = 0;
85   fdc_status[id].ptr = 0;
86   fdc_status[id].f = NULL;
87   fdc_status[id].is_ext_image = 0;
88   fdc_status[id].tracklen = MAX_TRACK_BYTES;
89   fdc_status[id].disk_changed = DISK_DETECT_DELAY;
138   amiga_fdc_t *fdc = get_safe_token(device);
139   int id;
140   for(id=0;id<2;id++)
141   {
142      fdc->fdc_status[id].rev_timer = timer_alloc(device->machine, fdc_rev_proc, (void*)device);
143      fdc->fdc_status[id].dma_timer = timer_alloc(device->machine, fdc_dma_proc, (void*)device);
144      fdc->fdc_status[id].sync_timer = timer_alloc(device->machine, fdc_sync_proc, (void*)device);     
145      floppy_install_load_proc(amiga_floppy_get_device_child(device, id), amiga_load_proc);
146      floppy_install_unload_proc(amiga_floppy_get_device_child(device, id), amiga_unload_proc);
147      fdc->fdc_status[id].motor_on = 0;
148      fdc->fdc_status[id].side = 0;
149      fdc->fdc_status[id].dir = 0;
150      fdc->fdc_status[id].wprot = 1;
151      fdc->fdc_status[id].cyl = 0;
152      fdc->fdc_status[id].rev_timer_started = 0;
153      fdc->fdc_status[id].cached = -1;
154      fdc->fdc_status[id].pos = 0;
155      fdc->fdc_status[id].len = 0;
156      fdc->fdc_status[id].ptr = 0;
157      fdc->fdc_status[id].f = NULL;
158      fdc->fdc_status[id].is_ext_image = 0;
159      fdc->fdc_status[id].tracklen = MAX_TRACK_BYTES;
160      fdc->fdc_status[id].disk_changed = DISK_DETECT_DELAY;
161      timer_reset( fdc->fdc_status[id].rev_timer, attotime_never );
162      timer_reset( fdc->fdc_status[id].sync_timer, attotime_never );
163      timer_reset( fdc->fdc_status[id].dma_timer, attotime_never );
164      memset( fdc->fdc_status[id].mfm, 0xaa, MAX_MFM_TRACK_LEN );
165   }
166   fdc->fdc_sel = 0x0f;
167   fdc->fdc_dir = 0;
168   fdc->fdc_side = 1;
169   fdc->fdc_step = 1;
170   fdc->fdc_rdy = 0;
171   
172}
90173
91   memset( fdc_status[id].mfm, 0xaa, MAX_MFM_TRACK_LEN );
92174
93   fdc_sel = 0x0f;
94   fdc_dir = 0;
95   fdc_side = 1;
96   fdc_step = 1;
97   fdc_rdy = 0;
175/*-------------------------------------------------
176    DEVICE_RESET(amiga_fdc)
177-------------------------------------------------*/
178
179static DEVICE_RESET(amiga_fdc)
180{   
98181}
99182
100static void check_extended_image( int id )
183static void check_extended_image( const device_config *device, int id )
101184{
102185   UINT8   header[8], data[4];
186   amiga_fdc_t *fdc = get_safe_token(device);
187   
188   fdc->fdc_status[id].is_ext_image = 0;
103189
104   fdc_status[id].is_ext_image = 0;
105
106   if ( image_fseek( fdc_status[id].f, 0, SEEK_SET ) )
190   if ( image_fseek( fdc->fdc_status[id].f, 0, SEEK_SET ) )
107191   {
108192      logerror("FDC: image_fseek failed!\n" );
109193      return;
110194   }
111195
112   image_fread( fdc_status[id].f, &header, sizeof( header ) );
196   image_fread( fdc->fdc_status[id].f, &header, sizeof( header ) );
113197
114198   if ( memcmp( header, "UAE--ADF", sizeof( header ) ) == 0 )
115199   {
r6731r6732
117201
118202      for( i = 0; i < MAX_TRACKS; i++ )
119203      {
120         image_fread( fdc_status[id].f, &data, sizeof( data ) );
204         image_fread( fdc->fdc_status[id].f, &data, sizeof( data ) );
121205
122206         /* data[0,1] = SYNC - data[2,3] = LEN */
123207
124         fdc_status[id].extinfo[i] = data[0];
125         fdc_status[id].extinfo[i] <<= 8;
126         fdc_status[id].extinfo[i] |= data[1];
127         fdc_status[id].extinfo[i] <<= 8;
128         fdc_status[id].extinfo[i] |= data[2];
129         fdc_status[id].extinfo[i] <<= 8;
130         fdc_status[id].extinfo[i] |= data[3];
208         fdc->fdc_status[id].extinfo[i] = data[0];
209         fdc->fdc_status[id].extinfo[i] <<= 8;
210         fdc->fdc_status[id].extinfo[i] |= data[1];
211         fdc->fdc_status[id].extinfo[i] <<= 8;
212         fdc->fdc_status[id].extinfo[i] |= data[2];
213         fdc->fdc_status[id].extinfo[i] <<= 8;
214         fdc->fdc_status[id].extinfo[i] |= data[3];
131215
132216         if ( i == 0 )
133            fdc_status[id].extoffs[i] = sizeof( header ) + ( MAX_TRACKS * sizeof( data ) );
217            fdc->fdc_status[id].extoffs[i] = sizeof( header ) + ( MAX_TRACKS * sizeof( data ) );
134218         else
135            fdc_status[id].extoffs[i] = fdc_status[id].extoffs[i-1] + ( fdc_status[id].extinfo[i-1] & 0xffff );
219            fdc->fdc_status[id].extoffs[i] = fdc->fdc_status[id].extoffs[i-1] + ( fdc->fdc_status[id].extinfo[i-1] & 0xffff );
136220      }
137221
138      fdc_status[id].is_ext_image = 1;
222      fdc->fdc_status[id].is_ext_image = 1;
139223   }
140224}
141225
142static DEVICE_IMAGE_LOAD(amiga_fdc)
226static int fdc_get_curpos( const device_config *device, int drive )
143227{
144   int id = image_index_in_device(image);
145
146   fdc_status[id].disk_changed = DISK_DETECT_DELAY;
147   fdc_status[id].f = image;
148   fdc_status[id].cached = -1;
149   fdc_status[id].motor_on = 0;
150   fdc_status[id].rev_timer_started = 0;
151   timer_reset( fdc_status[id].rev_timer, attotime_never );
152   timer_reset( fdc_status[id].sync_timer, attotime_never );
153   timer_reset( fdc_status[id].dma_timer, attotime_never );
154   fdc_rdy = 0;
155
156   check_extended_image( id );
157
158   return INIT_PASS;
159}
160
161static DEVICE_IMAGE_UNLOAD(amiga_fdc)
162{
163   int id = image_index_in_device(image);
164
165   fdc_status[id].disk_changed = DISK_DETECT_DELAY;
166   fdc_status[id].f = NULL;
167   fdc_status[id].cached = -1;
168   fdc_status[id].motor_on = 0;
169   fdc_status[id].rev_timer_started = 0;
170   timer_reset( fdc_status[id].rev_timer, attotime_never );
171   timer_reset( fdc_status[id].sync_timer, attotime_never );
172   timer_reset( fdc_status[id].dma_timer, attotime_never );
173   fdc_rdy = 0;
174}
175
176static int fdc_get_curpos( int drive )
177{
178228   double elapsed;
179229   int speed;
180230   int   bytes;
181231   int pos;
232   amiga_fdc_t *fdc = get_safe_token(device);
182233
183   if ( fdc_status[drive].rev_timer_started == 0 ) {
234   if ( fdc->fdc_status[drive].rev_timer_started == 0 ) {
184235      logerror("Rev timer not started on drive %d, cant get position!\n", drive );
185236      return 0;
186237   }
187238
188   elapsed = attotime_to_double(timer_timeelapsed( fdc_status[drive].rev_timer ));
239   elapsed = attotime_to_double(timer_timeelapsed( fdc->fdc_status[drive].rev_timer ));
189240   speed = ( CUSTOM_REG(REG_ADKCON) & 0x100 ) ? 2 : 4;
190241
191242   bytes = elapsed / attotime_to_double( ATTOTIME_IN_USEC( speed * 8 ) );
192   pos = bytes % ( fdc_status[drive].tracklen );
243   pos = bytes % ( fdc->fdc_status[drive].tracklen );
193244
194245   return pos;
195246}
196247
197UINT16 amiga_fdc_get_byte( void ) {
248UINT16 amiga_fdc_get_byte (const device_config *device)
249{
198250   int pos;
199251   int i, drive = -1;
200252   UINT16 ret;
253   amiga_fdc_t *fdc = get_safe_token(device);
201254
202255   ret = ( ( CUSTOM_REG(REG_DSKLEN) >> 1 ) & 0x4000 ) & ( ( CUSTOM_REG(REG_DMACON) << 10 ) & 0x4000 );
203256   ret |= ( CUSTOM_REG(REG_DSKLEN) >> 1 ) & 0x2000;
204257
205258   for ( i = 0; i < NUM_DRIVES; i++ ) {
206      if ( !( fdc_sel & ( 1 << i ) ) )
259      if ( !( fdc->fdc_sel & ( 1 << i ) ) )
207260         drive = i;
208261   }
209262
210263   if ( drive == -1 )
211264      return ret;
212265
213   if ( fdc_status[drive].disk_changed )
266   if ( fdc->fdc_status[drive].disk_changed )
214267      return ret;
215268
216   setup_fdc_buffer( drive );
269   setup_fdc_buffer( device,drive );
217270
218   pos = fdc_get_curpos( drive );
271   pos = fdc_get_curpos( device, drive );
219272
220   if ( fdc_status[drive].mfm[pos] == ( CUSTOM_REG(REG_DSRSYNC) >> 8 ) &&
221       fdc_status[drive].mfm[pos+1] == ( CUSTOM_REG(REG_DSRSYNC) & 0xff ) )
273   if ( fdc->fdc_status[drive].mfm[pos] == ( CUSTOM_REG(REG_DSRSYNC) >> 8 ) &&
274       fdc->fdc_status[drive].mfm[pos+1] == ( CUSTOM_REG(REG_DSRSYNC) & 0xff ) )
222275         ret |= 0x1000;
223276
224   if ( pos != fdc_status[drive].pos ) {
277   if ( pos != fdc->fdc_status[drive].pos ) {
225278      ret |= 0x8000;
226      fdc_status[drive].pos = pos;
279      fdc->fdc_status[drive].pos = pos;
227280   }
228281
229   ret |= fdc_status[drive].mfm[pos];
282   ret |= fdc->fdc_status[drive].mfm[pos];
230283
231284   return ret;
232285}
r6731r6732
238291   int            cur_pos;
239292   int            sector;
240293   int            time;
294   amiga_fdc_t *fdc = get_safe_token(ptr);
241295
242296   /* if floppy got ejected, stop */
243   if ( fdc_status[drive].disk_changed )
297   if ( fdc->fdc_status[drive].disk_changed )
244298      goto bail;
245299
246   if ( fdc_status[drive].motor_on == 0 )
300   if ( fdc->fdc_status[drive].motor_on == 0 )
247301      goto bail;
248302
249   cur_pos = fdc_get_curpos( drive );
303   cur_pos = fdc_get_curpos( ptr, drive );
250304
251305   if ( cur_pos <= ( GAP_TRACK_BYTES + 6 ) )
252306   {
r6731r6732
257311      sector = ( cur_pos - ( GAP_TRACK_BYTES + 6 ) ) / ONE_SECTOR_BYTES;
258312   }
259313
260   setup_fdc_buffer( drive );
314   setup_fdc_buffer( ptr, drive );
261315
262316   if ( cur_pos < 2 )
263317      cur_pos = 2;
264318
265   if ( fdc_status[drive].mfm[cur_pos-2] == ( ( sync >> 8 ) & 0xff ) &&
266       fdc_status[drive].mfm[cur_pos-1] == ( sync & 0xff ) )
319   if ( fdc->fdc_status[drive].mfm[cur_pos-2] == ( ( sync >> 8 ) & 0xff ) &&
320       fdc->fdc_status[drive].mfm[cur_pos-1] == ( sync & 0xff ) )
267321   {
268322      const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
269323
r6731r6732
276330      time = ONE_SECTOR_BYTES;
277331      time *= ( CUSTOM_REG(REG_ADKCON) & 0x0100 ) ? 2 : 4;
278332      time *= 8;
279      timer_adjust_oneshot(fdc_status[drive].sync_timer, ATTOTIME_IN_USEC( time ), drive);
333      timer_adjust_oneshot(fdc->fdc_status[drive].sync_timer, ATTOTIME_IN_USEC( time ), drive);
280334      return;
281335   }
282336
283337bail:
284   timer_reset( fdc_status[drive].sync_timer, attotime_never );
338   timer_reset( fdc->fdc_status[drive].sync_timer, attotime_never );
285339}
286340
287341static TIMER_CALLBACK(fdc_dma_proc)
288342{
289343   int drive = param;
344   amiga_fdc_t *fdc = get_safe_token(ptr);
345   
290346   /* if DMA got disabled by the time we got here, stop operations */
291347   if ( ( CUSTOM_REG(REG_DSKLEN) & 0x8000 ) == 0 )
292348      goto bail;
r6731r6732
295351      goto bail;
296352
297353   /* if floppy got ejected, also stop */
298   if ( fdc_status[drive].disk_changed )
354   if ( fdc->fdc_status[drive].disk_changed )
299355      goto bail;
300356
301   if ( fdc_status[drive].motor_on == 0 )
357   if ( fdc->fdc_status[drive].motor_on == 0 )
302358      goto bail;
303359
304   setup_fdc_buffer( drive );
360   setup_fdc_buffer( ptr, drive );
305361
306362   if ( CUSTOM_REG(REG_DSKLEN) & 0x4000 ) /* disk write case, unsupported yet */
307363   {
308      if ( fdc_status[drive].len > 0 )
364      if ( fdc->fdc_status[drive].len > 0 )
309365      {
310366         const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
311367
r6731r6732
316372   }
317373   else
318374   {
319      offs_t offset = fdc_status[drive].ptr;
320      int cur_pos = fdc_status[drive].pos;
321      int len = fdc_status[drive].len;
375      offs_t offset = fdc->fdc_status[drive].ptr;
376      int cur_pos = fdc->fdc_status[drive].pos;
377      int len = fdc->fdc_status[drive].len;
322378
323379      if ( len > MAX_WORDS_PER_DMA_CYCLE ) len = MAX_WORDS_PER_DMA_CYCLE;
324380
325      fdc_status[drive].len -= len;
381      fdc->fdc_status[drive].len -= len;
326382
327383      while ( len-- )
328384      {
329         int dat = ( fdc_status[drive].mfm[cur_pos++] ) << 8;
385         int dat = ( fdc->fdc_status[drive].mfm[cur_pos++] ) << 8;
330386
331         cur_pos %= ( fdc_status[drive].tracklen );
387         cur_pos %= ( fdc->fdc_status[drive].tracklen );
332388
333         dat |= fdc_status[drive].mfm[cur_pos++];
389         dat |= fdc->fdc_status[drive].mfm[cur_pos++];
334390
335         cur_pos %= ( fdc_status[drive].tracklen );
391         cur_pos %= ( fdc->fdc_status[drive].tracklen );
336392
337393         amiga_chip_ram_w(offset, dat);
338394
339395         offset += 2;
340396      }
341397
342      fdc_status[drive].ptr = offset;
343      fdc_status[drive].pos = cur_pos;
398      fdc->fdc_status[drive].ptr = offset;
399      fdc->fdc_status[drive].pos = cur_pos;
344400
345      if ( fdc_status[drive].len <= 0 )
401      if ( fdc->fdc_status[drive].len <= 0 )
346402      {
347403         const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
348404
r6731r6732
351407      else
352408      {
353409         int time;
354         double   len_words = fdc_status[drive].len;
410         double   len_words = fdc->fdc_status[drive].len;
355411         if ( len_words > MAX_WORDS_PER_DMA_CYCLE ) len_words = MAX_WORDS_PER_DMA_CYCLE;
356412
357413         time = len_words * 2;
358414         time *= ( CUSTOM_REG(REG_ADKCON) & 0x0100 ) ? 2 : 4;
359415         time *= 8;
360         timer_adjust_oneshot(fdc_status[drive].dma_timer, ATTOTIME_IN_USEC( time ), drive);
416         timer_adjust_oneshot(fdc->fdc_status[drive].dma_timer, ATTOTIME_IN_USEC( time ), drive);
361417         return;
362418      }
363419   }
364420
365421bail:
366   timer_reset( fdc_status[drive].dma_timer, attotime_never );
422   timer_reset( fdc->fdc_status[drive].dma_timer, attotime_never );
367423}
368424
369void amiga_fdc_setup_dma( running_machine *machine ) {
425void amiga_fdc_setup_dma( const device_config *device ) {
370426   int i, cur_pos, drive = -1, len_words = 0;
371427   int time = 0;
428   amiga_fdc_t *fdc = get_safe_token(device);
372429
373430   for ( i = 0; i < NUM_DRIVES; i++ ) {
374      if ( !( fdc_sel & ( 1 << i ) ) )
431      if ( !( fdc->fdc_sel & ( 1 << i ) ) )
375432         drive = i;
376433   }
377434
378435   if ( drive == -1 ) {
379      const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
436      const address_space *space = cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
380437
381438      logerror("Disk DMA started with no drive selected!\n" );
382439      amiga_custom_w(space, REG_INTREQ, 0x8000 | INTENA_DSKBLK, 0xffff);
r6731r6732
389446   if ( ( CUSTOM_REG(REG_DMACON) & 0x0210 ) == 0 )
390447      goto bail;
391448
392   if ( fdc_status[drive].disk_changed )
449   if ( fdc->fdc_status[drive].disk_changed )
393450      goto bail;
394451
395   setup_fdc_buffer( drive );
452   setup_fdc_buffer( device,drive );
396453
397   fdc_status[drive].len = CUSTOM_REG(REG_DSKLEN) & 0x3fff;
398   fdc_status[drive].ptr = CUSTOM_REG_LONG(REG_DSKPTH);
399   fdc_status[drive].pos = cur_pos = fdc_get_curpos( drive );
454   fdc->fdc_status[drive].len = CUSTOM_REG(REG_DSKLEN) & 0x3fff;
455   fdc->fdc_status[drive].ptr = CUSTOM_REG_LONG(REG_DSKPTH);
456   fdc->fdc_status[drive].pos = cur_pos = fdc_get_curpos( device, drive );
400457
401458   /* we'll do a set amount at a time */
402   len_words = fdc_status[drive].len;
459   len_words = fdc->fdc_status[drive].len;
403460   if ( len_words > MAX_WORDS_PER_DMA_CYCLE ) len_words = MAX_WORDS_PER_DMA_CYCLE;
404461
405462   if ( CUSTOM_REG(REG_ADKCON) & 0x0400 ) { /* Wait for sync */
r6731r6732
409466
410467      i = cur_pos;
411468      do {
412         if ( fdc_status[drive].mfm[i] == ( CUSTOM_REG(REG_DSRSYNC) >> 8 ) &&
413             fdc_status[drive].mfm[i+1] == ( CUSTOM_REG(REG_DSRSYNC) & 0xff ) )
469         if ( fdc->fdc_status[drive].mfm[i] == ( CUSTOM_REG(REG_DSRSYNC) >> 8 ) &&
470             fdc->fdc_status[drive].mfm[i+1] == ( CUSTOM_REG(REG_DSRSYNC) & 0xff ) )
414471                break;
415472
416473         i++;
417         i %= ( fdc_status[drive].tracklen );
474         i %= ( fdc->fdc_status[drive].tracklen );
418475         time++;
419476      } while( i != cur_pos );
420477
r6731r6732
422479         logerror("SYNC not found on track!\n" );
423480         return;
424481      } else {
425         fdc_status[drive].pos = i + 2;
482         fdc->fdc_status[drive].pos = i + 2;
426483         time += 2;
427484      }
428485   }
r6731r6732
430487   time += len_words * 2;
431488   time *= ( CUSTOM_REG(REG_ADKCON) & 0x0100 ) ? 2 : 4;
432489   time *= 8;
433   timer_adjust_oneshot(fdc_status[drive].dma_timer, ATTOTIME_IN_USEC( time ), drive);
490   timer_adjust_oneshot(fdc->fdc_status[drive].dma_timer, ATTOTIME_IN_USEC( time ), drive);
434491
435492   return;
436493
437494bail:
438   timer_reset( fdc_status[drive].dma_timer, attotime_never );
495   timer_reset( fdc->fdc_status[drive].dma_timer, attotime_never );
439496}
440497
441static void setup_fdc_buffer( int drive )
498static void setup_fdc_buffer( const device_config *device,int drive )
442499{
443500   int      sector, offset, len;
444501   UINT8   temp_cyl[512*11];
445
502   amiga_fdc_t *fdc = get_safe_token(device);
503   
446504   /* no disk in drive */
447   if ( fdc_status[drive].f == NULL ) {
448      memset( &fdc_status[drive].mfm[0], 0xaa, 32 );
449      fdc_status[drive].disk_changed = DISK_DETECT_DELAY;
505   if ( fdc->fdc_status[drive].f == NULL ) {
506      memset( &fdc->fdc_status[drive].mfm[0], 0xaa, 32 );
507      fdc->fdc_status[drive].disk_changed = DISK_DETECT_DELAY;
450508      return;
451509   }
452510
453511   len = 512*11;
454512
455   offset = ( fdc_status[drive].cyl << 1 ) | fdc_side;
513   offset = ( fdc->fdc_status[drive].cyl << 1 ) | fdc->fdc_side;
456514
457   if ( fdc_status[drive].cached == offset )
515   if ( fdc->fdc_status[drive].cached == offset )
458516      return;
459517
460518#if 0
461   popmessage("T:%d S:%d", fdc_status[drive].cyl, fdc_side );
519   popmessage("T:%d S:%d", fdc->fdc_status[drive].cyl, fdc_side );
462520#endif
463521
464   if ( fdc_status[drive].is_ext_image )
522   if ( fdc->fdc_status[drive].is_ext_image )
465523   {
466      len = fdc_status[drive].extinfo[offset] & 0xffff;
524      len = fdc->fdc_status[drive].extinfo[offset] & 0xffff;
467525
468526      if ( len > ( MAX_MFM_TRACK_LEN - 2 ) )
469527         len = MAX_MFM_TRACK_LEN - 2;
470528
471      if ( image_fseek( fdc_status[drive].f, fdc_status[drive].extoffs[offset], SEEK_SET ) )
529      if ( image_fseek( fdc->fdc_status[drive].f, fdc->fdc_status[drive].extoffs[offset], SEEK_SET ) )
472530      {
473531         logerror("FDC: image_fseek failed!\n" );
474         fdc_status[drive].f = NULL;
475         fdc_status[drive].disk_changed = DISK_DETECT_DELAY;
532         fdc->fdc_status[drive].f = NULL;
533         fdc->fdc_status[drive].disk_changed = DISK_DETECT_DELAY;
476534         return;
477535      }
478536
479537      /* if SYNC is 0000, then its a regular amiga dos track image */
480      if ( ( fdc_status[drive].extinfo[offset] >> 16 ) == 0x0000 )
538      if ( ( fdc->fdc_status[drive].extinfo[offset] >> 16 ) == 0x0000 )
481539      {
482         image_fread( fdc_status[drive].f, temp_cyl, len );
540         image_fread( fdc->fdc_status[drive].f, temp_cyl, len );
483541         /* fall through to regular load */
484542      }
485543      else /* otherwise, it's a raw track */
486544      {
487         fdc_status[drive].mfm[0] = ( fdc_status[drive].extinfo[offset] >> 24 ) & 0xff;
488         fdc_status[drive].mfm[1] = ( fdc_status[drive].extinfo[offset] >> 16 ) & 0xff;
489         image_fread( fdc_status[drive].f, &fdc_status[drive].mfm[2], len );
490         fdc_status[drive].tracklen = len + 2;
491         fdc_status[drive].cached = offset;
545         fdc->fdc_status[drive].mfm[0] = ( fdc->fdc_status[drive].extinfo[offset] >> 24 ) & 0xff;
546         fdc->fdc_status[drive].mfm[1] = ( fdc->fdc_status[drive].extinfo[offset] >> 16 ) & 0xff;
547         image_fread( fdc->fdc_status[drive].f, &fdc->fdc_status[drive].mfm[2], len );
548         fdc->fdc_status[drive].tracklen = len + 2;
549         fdc->fdc_status[drive].cached = offset;
492550         return;
493551      }
494552   }
495553   else
496554   {
497      if ( image_fseek( fdc_status[drive].f, offset * len, SEEK_SET ) )
555      if ( image_fseek( fdc->fdc_status[drive].f, offset * len, SEEK_SET ) )
498556      {
499557         logerror("FDC: image_fseek failed!\n" );
500         fdc_status[drive].f = NULL;
501         fdc_status[drive].disk_changed = DISK_DETECT_DELAY;
558         fdc->fdc_status[drive].f = NULL;
559         fdc->fdc_status[drive].disk_changed = DISK_DETECT_DELAY;
502560         return;
503561      }
504562
505      image_fread( fdc_status[drive].f, temp_cyl, len );
563      image_fread( fdc->fdc_status[drive].f, temp_cyl, len );
506564   }
507565
508   fdc_status[drive].tracklen = MAX_TRACK_BYTES;
509   memset( &fdc_status[drive].mfm[0], 0xaa, GAP_TRACK_BYTES );
566   fdc->fdc_status[drive].tracklen = MAX_TRACK_BYTES;
567   memset( &fdc->fdc_status[drive].mfm[0], 0xaa, GAP_TRACK_BYTES );
510568
511569   for ( sector = 0; sector < 11; sector++ ) {
512570      int x;
513       UINT8 *dest = ( &fdc_status[drive].mfm[(ONE_SECTOR_BYTES*sector)+GAP_TRACK_BYTES] );
571       UINT8 *dest = ( &fdc->fdc_status[drive].mfm[(ONE_SECTOR_BYTES*sector)+GAP_TRACK_BYTES] );
514572       UINT8 *src = &temp_cyl[sector*512];
515573      UINT32 tmp;
516574      UINT32 even, odd;
r6731r6732
595653      *(dest + 63) = (UINT8) (even & 0xff);
596654   }
597655
598   fdc_status[drive].cached = offset;
656   fdc->fdc_status[drive].cached = offset;
599657}
600658
601659static TIMER_CALLBACK(fdc_rev_proc)
r6731r6732
603661   int drive = param;
604662   int time;
605663   const device_config *cia;
664   amiga_fdc_t *fdc = get_safe_token(ptr);
606665
607666   /* Issue a index pulse when a disk revolution completes */
608667   cia = devtag_get_device(machine, "cia_1");
609668   cia_issue_index(cia);
610669
611   timer_adjust_oneshot(fdc_status[drive].rev_timer, ATTOTIME_IN_MSEC( ONE_REV_TIME ), drive);
612   fdc_status[drive].rev_timer_started = 1;
670   timer_adjust_oneshot(fdc->fdc_status[drive].rev_timer, ATTOTIME_IN_MSEC( ONE_REV_TIME ), drive);
671   fdc->fdc_status[drive].rev_timer_started = 1;
613672
614   if ( fdc_status[drive].is_ext_image == 0 )
673   if ( fdc->fdc_status[drive].is_ext_image == 0 )
615674   {
616675      /* also start the sync timer */
617676      time = GAP_TRACK_BYTES + 6;
618677      time *= ( CUSTOM_REG(REG_ADKCON) & 0x0100 ) ? 2 : 4;
619678      time *= 8;
620      timer_adjust_oneshot(fdc_status[drive].sync_timer, ATTOTIME_IN_USEC( time ), drive);
679      timer_adjust_oneshot(fdc->fdc_status[drive].sync_timer, ATTOTIME_IN_USEC( time ), drive);
621680   }
622681}
623682
624static void start_rev_timer( int drive ) {
683static void start_rev_timer( const device_config *device,int drive ) {
625684//  double time;
626
627   if ( fdc_status[drive].rev_timer_started ) {
685   amiga_fdc_t *fdc = get_safe_token(device);
686   
687   if ( fdc->fdc_status[drive].rev_timer_started ) {
628688      logerror("Revolution timer started twice?!\n" );
629689      return;
630690   }
631691
632   timer_adjust_oneshot(fdc_status[drive].rev_timer, ATTOTIME_IN_MSEC( ONE_REV_TIME ), drive);
633   fdc_status[drive].rev_timer_started = 1;
692   timer_adjust_oneshot(fdc->fdc_status[drive].rev_timer, ATTOTIME_IN_MSEC( ONE_REV_TIME ), drive);
693   fdc->fdc_status[drive].rev_timer_started = 1;
634694}
635695
636static void stop_rev_timer( int drive ) {
637   if ( fdc_status[drive].rev_timer_started == 0 ) {
696static void stop_rev_timer( const device_config *device,int drive ) {
697   amiga_fdc_t *fdc = get_safe_token(device);
698   
699   if ( fdc->fdc_status[drive].rev_timer_started == 0 ) {
638700      logerror("Revolution timer never started?!\n" );
639701      return;
640702   }
641703
642   timer_reset( fdc_status[drive].rev_timer, attotime_never );
643   fdc_status[drive].rev_timer_started = 0;
644   timer_reset( fdc_status[drive].dma_timer, attotime_never );
645   timer_reset( fdc_status[drive].sync_timer, attotime_never );
704   timer_reset( fdc->fdc_status[drive].rev_timer, attotime_never );
705   fdc->fdc_status[drive].rev_timer_started = 0;
706   timer_reset( fdc->fdc_status[drive].dma_timer, attotime_never );
707   timer_reset( fdc->fdc_status[drive].sync_timer, attotime_never );
646708}
647709
648static void fdc_setup_leds(running_machine *machine, int drive ) {
710static void fdc_setup_leds(const device_config *device, int drive ) {
649711
650712   char portname[12];
713   amiga_fdc_t *fdc = get_safe_token(device);
651714   sprintf(portname, "drive_%d_led", drive);
652   output_set_value(portname, fdc_status[drive].motor_on == 0 ? 0 : 1);
715   output_set_value(portname, fdc->fdc_status[drive].motor_on == 0 ? 0 : 1);
653716
654717   if ( drive == 0 )
655      set_led_status(machine, 1, fdc_status[drive].motor_on ); /* update internal drive led */
718      set_led_status(device->machine, 1, fdc->fdc_status[drive].motor_on ); /* update internal drive led */
656719
657720   if ( drive == 1 )
658      set_led_status(machine, 2, fdc_status[drive].motor_on ); /* update external drive led */
721      set_led_status(device->machine, 2, fdc->fdc_status[drive].motor_on ); /* update external drive led */
659722}
660723
661static void fdc_stepdrive( int drive ) {
662   if ( fdc_dir ) {
663      if ( fdc_status[drive].cyl )
664         fdc_status[drive].cyl--;
724static void fdc_stepdrive( const device_config *device,int drive ) {
725   amiga_fdc_t *fdc = get_safe_token(device);
726   
727   if ( fdc->fdc_dir ) {
728      if ( fdc->fdc_status[drive].cyl )
729         fdc->fdc_status[drive].cyl--;
665730   } else {
666      if ( fdc_status[drive].cyl < 79 )
667         fdc_status[drive].cyl++;
731      if ( fdc->fdc_status[drive].cyl < 79 )
732         fdc->fdc_status[drive].cyl++;
668733   }
669734
670735   /* Update disk detection if applicable */
671   if ( fdc_status[drive].f != NULL )
736   if ( fdc->fdc_status[drive].f != NULL )
672737   {
673      if ( fdc_status[drive].disk_changed > 0 )
674         fdc_status[drive].disk_changed--;
738      if ( fdc->fdc_status[drive].disk_changed > 0 )
739         fdc->fdc_status[drive].disk_changed--;
675740   }
676741}
677742
678static void fdc_motor( int drive, int off ) {
743static void fdc_motor( const device_config *device,int drive, int off ) {
744   amiga_fdc_t *fdc = get_safe_token(device);
679745   int on = !off;
680746
681   if ( ( fdc_status[drive].motor_on == 0 ) && on ) {
682      fdc_status[drive].pos = 0;
747   if ( ( fdc->fdc_status[drive].motor_on == 0 ) && on ) {
748      fdc->fdc_status[drive].pos = 0;
683749
684      start_rev_timer( drive );
750      start_rev_timer( device,drive );
685751
686752   } else {
687      if ( fdc_status[drive].motor_on && off )
688         stop_rev_timer( drive );
753      if ( fdc->fdc_status[drive].motor_on && off )
754         stop_rev_timer(device, drive );
689755   }
690756
691   fdc_status[drive].motor_on = on;
757   fdc->fdc_status[drive].motor_on = on;
692758}
693759
694760WRITE8_DEVICE_HANDLER( amiga_fdc_control_w )
r6731r6732
696762   int step_pulse;
697763   int drive;
698764
699   if ( fdc_sel != ( ( data >> 3 ) & 15 ) )
700      fdc_rdy = 0;
765   amiga_fdc_t *fdc = get_safe_token(device);
766   
767   if ( fdc->fdc_sel != ( ( data >> 3 ) & 15 ) )
768      fdc->fdc_rdy = 0;
701769
702   fdc_sel = ( data >> 3 ) & 15;
703    fdc_side = 1 - ( ( data >> 2 ) & 1 );
704   fdc_dir = ( data >> 1 ) & 1;
770   fdc->fdc_sel = ( data >> 3 ) & 15;
771    fdc->fdc_side = 1 - ( ( data >> 2 ) & 1 );
772   fdc->fdc_dir = ( data >> 1 ) & 1;
705773
706774   step_pulse = data & 1;
707775
708    if ( fdc_step != step_pulse ) {
709      fdc_step = step_pulse;
776    if ( fdc->fdc_step != step_pulse ) {
777      fdc->fdc_step = step_pulse;
710778
711       if ( fdc_step == 0 ) {
779       if ( fdc->fdc_step == 0 ) {
712780          for ( drive = 0; drive < NUM_DRIVES; drive++ ) {
713            if ( !( fdc_sel & ( 1 << drive ) ) )
714                fdc_stepdrive( drive );
781            if ( !( fdc->fdc_sel & ( 1 << drive ) ) )
782                fdc_stepdrive( device, drive );
715783         }
716784      }
717785   }
718786
719787   for ( drive = 0; drive < NUM_DRIVES; drive++ ) {
720      if ( !( fdc_sel & ( 1 << drive ) ) ) {
721         fdc_motor( drive, ( data >> 7 ) & 1 );
722         fdc_setup_leds( device->machine,drive );
788      if ( !( fdc->fdc_sel & ( 1 << drive ) ) ) {
789         fdc_motor( device, drive, ( data >> 7 ) & 1 );
790         fdc_setup_leds( device,drive );
723791      }
724792    }
725793}
726794
727int amiga_fdc_status_r( void ) {
795UINT8  amiga_fdc_status_r (const device_config *device)
796{
728797   int drive = -1, ret = 0x3c;
729
798   amiga_fdc_t *fdc = get_safe_token(device);
730799   for ( drive = 0; drive < NUM_DRIVES; drive++ ) {
731      if ( !( fdc_sel & ( 1 << drive ) ) ) {
800      if ( !( fdc->fdc_sel & ( 1 << drive ) ) ) {
732801
733         if ( fdc_status[drive].motor_on ) {
734            if ( fdc_rdy ) ret &= ~0x20;
735            fdc_rdy = 1;
802         if ( fdc->fdc_status[drive].motor_on ) {
803            if ( fdc->fdc_rdy ) ret &= ~0x20;
804            fdc->fdc_rdy = 1;
736805         } else {
737806            /* return drive id */
738807            ret &= ~0x20;
739808         }
740809
741         if ( fdc_status[drive].cyl == 0 )
810         if ( fdc->fdc_status[drive].cyl == 0 )
742811            ret &= ~0x10;
743812
744         if ( fdc_status[drive].wprot )
813         if ( fdc->fdc_status[drive].wprot )
745814            ret &= ~0x08;
746815
747         if ( fdc_status[drive].disk_changed )
816         if ( fdc->fdc_status[drive].disk_changed )
748817            ret &= ~0x04;
749818
750819         return ret;
r6731r6732
754823   return ret;
755824}
756825
826static const floppy_config amiga_floppy_config =
827{
828   DEVCB_NULL,
829   DEVCB_NULL,
830   DEVCB_NULL,
831   DEVCB_NULL,
832   DEVCB_NULL,
833   FLOPPY_DRIVE_DS_80,
834   FLOPPY_OPTIONS_NAME(amiga_only),
835   DO_NOT_KEEP_GEOMETRY
836};
757837
838static MACHINE_DRIVER_START( amiga_fdc )
839   MDRV_FLOPPY_2_DRIVES_ADD(amiga_floppy_config)
840MACHINE_DRIVER_END
758841
759void amiga_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
842
843DEVICE_GET_INFO( amiga_fdc )
760844{
761   switch(state)
845   switch (state)
762846   {
763847      /* --- the following bits of info are returned as 64-bit signed integers --- */
764      case MESS_DEVINFO_INT_TYPE:               info->i = IO_FLOPPY; break;
765      case MESS_DEVINFO_INT_COUNT:               info->i = NUM_DRIVES; break;
766      case MESS_DEVINFO_INT_READABLE:            info->i = 1; break;
767      case MESS_DEVINFO_INT_WRITEABLE:            info->i = 0; break;
768      case MESS_DEVINFO_INT_CREATABLE:            info->i = 0; break;
848      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                                    break;
849      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(amiga_fdc_t);                        break;
850      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;                     break;
769851
852      /* --- the following bits of info are returned as pointers --- */
853      case DEVINFO_PTR_MACHINE_CONFIG:            info->machine_config = MACHINE_DRIVER_NAME(amiga_fdc);      break;
854
770855      /* --- the following bits of info are returned as pointers to data or functions --- */
771      case MESS_DEVINFO_PTR_START:               info->start = DEVICE_START_NAME(amiga_fdc); break;
772      case MESS_DEVINFO_PTR_LOAD:               info->load = DEVICE_IMAGE_LOAD_NAME(amiga_fdc); break;
773      case MESS_DEVINFO_PTR_UNLOAD:            info->unload = DEVICE_IMAGE_UNLOAD_NAME(amiga_fdc); break;
856      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(amiga_fdc);               break;
857      case DEVINFO_FCT_STOP:                     /* Nothing */                                    break;
858      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(amiga_fdc);               break;
774859
775860      /* --- the following bits of info are returned as NULL-terminated strings --- */
776      case MESS_DEVINFO_STR_FILE_EXTENSIONS:      strcpy(info->s = device_temp_str(), "adf"); break;
861      case DEVINFO_STR_NAME:                     strcpy(info->s, "Amiga FDC");                        break;
862      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Amiga FDC");                        break;
863      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                              break;
864      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                           break;
865      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");             break;
777866   }
778867}
868
src/mess/machine/amigafdc.h
r6731r6732
22#define AMIGAFDC_H
33
44WRITE8_DEVICE_HANDLER( amiga_fdc_control_w );
5int amiga_fdc_status_r( void );
6unsigned short amiga_fdc_get_byte( void );
7void amiga_fdc_setup_dma( running_machine *machine );
5UINT8  amiga_fdc_status_r (const device_config *device);
6UINT16 amiga_fdc_get_byte (const device_config *device);
7void amiga_fdc_setup_dma( const device_config *device );
88
9void amiga_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info);
9/***************************************************************************
10    MACROS
11***************************************************************************/
1012
13#define AMIGA_FDC      DEVICE_GET_INFO_NAME(amiga_fdc)
14
15#define MDRV_AMIGA_FDC_ADD(_tag)   \
16   MDRV_DEVICE_ADD((_tag),  AMIGA_FDC, 0)
17
18
19/***************************************************************************
20    FUNCTION PROTOTYPES
21***************************************************************************/
22
23DEVICE_GET_INFO(amiga_fdc);
24
1125#endif /* AMIGAFDC_H */
src/mess/formats/ami_dsk.c
r6731r6732
9393      SECTORS([11]/22)
9494   )
9595FLOPPY_OPTIONS_END
96
97FLOPPY_OPTIONS_START( amiga_only )
98   FLOPPY_OPTION(
99      ami_dsk,
100      "adf",
101      "Amiga floppy disk image",
102      amiga_dsk_identify,
103      amiga_dsk_construct,
104      HEADS([2])
105      TRACKS([80])
106      SECTORS([11]/22)
107   )
108      { NULL }
109};
src/mess/formats/ami_dsk.h
r6731r6732
1212#include "formats/flopimg.h"
1313
1414FLOPPY_OPTIONS_EXTERN(amiga);
15FLOPPY_OPTIONS_EXTERN(amiga_only);
1516
1617#endif /*AMI_DSK_H_*/
src/mess/mess.mak
r6731r6732
399399   $(MESS_DEVICES)/cassette.o   \
400400   $(MESS_DEVICES)/chd_cd.o   \
401401   $(MESS_FORMATS)/imd_dsk.o   \
402   $(MESS_FORMATS)/ami_dsk.o   \
402403   $(MESS_FORMATS)/td0_dsk.o   \
403404   $(MESS_FORMATS)/cqm_dsk.o   \
404405   $(MESS_FORMATS)/dsk_dsk.o   \
src/mess/drivers/amiga.c
r6731r6732
315315   0,                                       /* tod_clock */
316316   {
317317      { DEVCB_DEVICE_HANDLER("centronics", amiga_cia_1_porta_r), DEVCB_NULL },   /* port A */
318      { DEVCB_NULL, DEVCB_HANDLER(amiga_fdc_control_w) }               /* port B */
318      { DEVCB_NULL, DEVCB_DEVICE_HANDLER("fdc", amiga_fdc_control_w) }               /* port B */
319319   }
320320};
321321
r6731r6732
402402   /* cia */
403403   MDRV_CIA8520_ADD("cia_0", AMIGA_68000_NTSC_CLOCK / 10, cia_0_ntsc_intf)
404404   MDRV_CIA8520_ADD("cia_1", AMIGA_68000_NTSC_CLOCK, cia_1_intf)
405   
406   MDRV_AMIGA_FDC_ADD("fdc")
405407MACHINE_DRIVER_END
406408
407409static MACHINE_DRIVER_START( a1000n )
r6731r6732
487489static READ8_DEVICE_HANDLER( amiga_cia_0_portA_r )
488490{
489491   UINT8 ret = input_port_read(device->machine, "CIA0PORTA") & 0xc0;   /* Gameport 1 and 0 buttons */
490   ret |= amiga_fdc_status_r();
492   ret |= amiga_fdc_status_r(devtag_get_device(device->machine, "fdc"));
491493   return ret;
492494}
493495
r6731r6732
556558
557559static UINT16 amiga_read_dskbytr(running_machine *machine)
558560{
559   return amiga_fdc_get_byte();
561   return amiga_fdc_get_byte(devtag_get_device(machine, "fdc"));
560562}
561563
562564static void amiga_write_dsklen(running_machine *machine, UINT16 data)
563565{
564566   if ( data & 0x8000 ) {
565567      if ( CUSTOM_REG(REG_DSKLEN) & 0x8000 )
566         amiga_fdc_setup_dma(machine);
568         amiga_fdc_setup_dma(devtag_get_device(machine, "fdc"));
567569   }
568570}
569571
r6731r6732
729731   ROM_LOAD("252608-01.u62", 0x000, 0x1000, NO_DUMP)
730732ROM_END
731733
732
733734/***************************************************************************
734    SYSTEM CONFIG
735***************************************************************************/
736
737static SYSTEM_CONFIG_START( amiga )
738   CONFIG_DEVICE(amiga_floppy_getinfo)
739SYSTEM_CONFIG_END
740
741
742/***************************************************************************
743735    GAME DRIVERS
744736***************************************************************************/
745737
746738/*    YEAR  NAME    PARENT  COMPAT  MACHINE INPUT   INIT    CONFIG  COMPANY                             FULLNAME                 FLAGS */
747COMP( 1985, a1000n, 0,      0,      a1000n, amiga,  amiga,  amiga,  "Commodore Business Machines Co.",  "Amiga 1000 (NTSC)",     GAME_IMPERFECT_GRAPHICS )
748COMP( 1985, a1000p, a1000n, 0,      a1000p, amiga,  amiga,  amiga,  "Commodore Business Machines Co.",  "Amiga 1000 (PAL)",      GAME_IMPERFECT_GRAPHICS )
749COMP( 1987, a500n,  0,      0,      a500n,  amiga,  amiga,  amiga,  "Commodore Business Machines Co.",  "Amiga 500 (NTSC, OCS)", GAME_IMPERFECT_GRAPHICS )
750COMP( 1987, a500p,  a500n,  0,      a500p,  amiga,  amiga,  amiga,  "Commodore Business Machines Co.",  "Amiga 500 (PAL, OCS)",  GAME_IMPERFECT_GRAPHICS )
739COMP( 1985, a1000n, 0,      0,      a1000n, amiga,  amiga,  0,     "Commodore Business Machines Co.",  "Amiga 1000 (NTSC)",     GAME_IMPERFECT_GRAPHICS )
740COMP( 1985, a1000p, a1000n, 0,      a1000p, amiga,  amiga,  0,     "Commodore Business Machines Co.",  "Amiga 1000 (PAL)",      GAME_IMPERFECT_GRAPHICS )
741COMP( 1987, a500n,  0,      0,      a500n,  amiga,  amiga,  0,     "Commodore Business Machines Co.",  "Amiga 500 (NTSC, OCS)", GAME_IMPERFECT_GRAPHICS )
742COMP( 1987, a500p,  a500n,  0,      a500p,  amiga,  amiga,  0,     "Commodore Business Machines Co.",  "Amiga 500 (PAL, OCS)",  GAME_IMPERFECT_GRAPHICS )
751743COMP( 1991, cdtv,   0,      0,      cdtv,   cdtv,   cdtv,   0,      "Commodore Business Machines Co.",  "CDTV (NTSC)",           GAME_IMPERFECT_GRAPHICS )
src/mess/drivers/ami1200.c
r6731r6732
380380static READ8_DEVICE_HANDLER( a1200_cia_0_portA_r )
381381{
382382   UINT8 ret = input_port_read(device->machine, "CIA0PORTA") & 0xc0;   /* Gameport 1 and 0 buttons */
383   ret |= amiga_fdc_status_r();
383   ret |= amiga_fdc_status_r(devtag_get_device(device->machine, "fdc"));
384384   return ret;
385385}
386386
r6731r6732
414414   0,                                       /* tod_clock */
415415   {
416416      { DEVCB_NULL, DEVCB_NULL },                           /* port A */
417      { DEVCB_NULL, DEVCB_HANDLER(amiga_fdc_control_w) }         /* port B */
417      { DEVCB_NULL, DEVCB_DEVICE_HANDLER("fdc", amiga_fdc_control_w) }         /* port B */
418418   }
419419};
420420
r6731r6732
462462   /* cia */
463463   MDRV_CIA8520_ADD("cia_0", AMIGA_68EC020_NTSC_CLOCK / 10, a1200_cia_0_intf)
464464   MDRV_CIA8520_ADD("cia_1", AMIGA_68EC020_NTSC_CLOCK / 10, a1200_cia_1_intf)
465   
466   MDRV_AMIGA_FDC_ADD("fdc")
465467MACHINE_DRIVER_END
466468
467469static MACHINE_DRIVER_START( a1200p )
r6731r6732
555557
556558static UINT16 a1200_read_dskbytr(running_machine *machine)
557559{
558   return amiga_fdc_get_byte();
560   return amiga_fdc_get_byte(devtag_get_device(machine, "fdc"));
559561}
560562
561563static void a1200_write_dsklen(running_machine *machine, UINT16 data)
r6731r6732
563565   if ( data & 0x8000 )
564566   {
565567      if ( CUSTOM_REG(REG_DSKLEN) & 0x8000 )
566         amiga_fdc_setup_dma(machine);
568         amiga_fdc_setup_dma(devtag_get_device(machine, "fdc"));
567569   }
568570}
569571
r6731r6732
620622   amiga_akiko_init(machine);
621623}
622624
623/***************************************************************************
624  System config
625***************************************************************************/
626
627static SYSTEM_CONFIG_START(a1200)
628   CONFIG_DEVICE(amiga_floppy_getinfo)
629SYSTEM_CONFIG_END
630
631
632625/***************************************************************************************************/
633626
634627/*    YEAR  NAME     PARENT   COMPAT  MACHINE INPUT   INIT    CONFIG  COMPANY       FULLNAME */
635COMP( 1992, a1200n,  0,       0,      a1200n, a1200,  a1200,  a1200,  "Commodore",  "Amiga 1200 (NTSC)" , GAME_NOT_WORKING )
636COMP( 1992, a1200p,  a1200n,  0,      a1200p, a1200,  a1200,  a1200,  "Commodore",  "Amiga 1200 (PAL)" , GAME_NOT_WORKING )
637CONS( 1993, cd32,    0,       0,      cd32,   cd32,   cd32,   0,      "Commodore",  "Amiga CD32 (NTSC)" , GAME_NOT_WORKING )
628COMP( 1992, a1200n,  0,       0,      a1200n, a1200,  a1200,  0,     "Commodore",  "Amiga 1200 (NTSC)" , GAME_NOT_WORKING )
629COMP( 1992, a1200p,  a1200n,  0,      a1200p, a1200,  a1200,  0,     "Commodore",  "Amiga 1200 (PAL)" , GAME_NOT_WORKING )
630CONS( 1993, cd32,    0,       0,      cd32,   cd32,   cd32,   0,    "Commodore",  "Amiga CD32 (NTSC)" , GAME_NOT_WORKING )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team