Previous 15994 Revisions Next

r5504 Wednesday 26th August, 2009 at 23:41:23 UTC by Angelo Salese
[X1]: Added basic floppy support, now games executes their code properly and some of them displays some bare minimum gfxs
[src/mess/drivers]x1.c

src/mess/drivers/x1.c
r5503r5504
117117#include "machine/8255ppi.h"
118118#include "sound/ay8910.h"
119119#include "video/mc6845.h"
120#include "machine/wd17xx.h"
121#include "devices/basicdsk.h"
120122
123static UINT8 hres_320,io_switch;
124static UINT8 *bitmapa_ram,*bitmapb_ram;
121125
122126static VIDEO_START( x1 )
123127{
r5503r5504
125129
126130static VIDEO_UPDATE( x1 )
127131{
128   int y,x;
132   int y,x,w;
129133
134   w = (hres_320 & 0x40) ? 1 : 2;
135
130136   for (y=0;y<25;y++)
131137   {
132      for (x=0;x<40;x++)
138      for (x=0;x<40*w;x++)
133139      {
134         int tile = videoram[x+(y*40)];
135         int color = colorram[x+(y*40)] & 0x3f;
136         int width = (colorram[x+(y*40)] & 0x80)>>7;
140         int tile = videoram[x+(y*40*w)];
141         int color = colorram[x+(y*40*w)] & 0x3f;
142         int width = (colorram[x+(y*40*w)] & 0x80)>>7;
137143
138144         drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[width],tile,color,0,0,(x/(width+1))*8*(width+1),y*8);
139145      }
r5503r5504
223229   ROM[0x10000+offset] = data;
224230}
225231
232/*
233FDC is a MB8877A, wd17XX compatible
234*/
226235
236//static UINT8 fdc_irq_flag;
237//static UINT8 fdc_drq_flag;
238//static UINT8 fdc_side;
239//static UINT8 fdc_drive;
240
241static WD17XX_CALLBACK( x1_fdc_irq )
242{
243   #if 0
244   switch(state)
245   {
246      case WD17XX_IRQ_CLR:
247         fdc_irq_flag = 0;
248         break;
249      case WD17XX_IRQ_SET:
250         fdc_irq_flag = 1;
251         break;
252      case WD17XX_DRQ_CLR:
253         fdc_drq_flag = 0;
254         break;
255      case WD17XX_DRQ_SET:
256         fdc_drq_flag = 1;
257         break;
258   }
259   #endif
260}
261
262static READ8_HANDLER( x1_fdc_r )
263{
264   const device_config* dev = devtag_get_device(space->machine,"fdc");
265   //UINT8 ret = 0;
266
267   switch(offset+0xff8)
268   {
269      case 0x0ff8:
270         return wd17xx_status_r(dev,offset);
271      case 0x0ff9:
272         return wd17xx_track_r(dev,offset);
273      case 0x0ffa:
274         return wd17xx_sector_r(dev,offset);
275      case 0x0ffb:
276         return wd17xx_data_r(dev,offset);
277      case 0x0ffc:
278      case 0x0ffd:
279      case 0x0ffe:
280      case 0x0fff:
281         logerror("FDC: read from %04x\n",offset+0xff8);
282         return 0xff;
283   }
284
285   return 0x00;
286}
287
288static WRITE8_HANDLER( x1_fdc_w )
289{
290   const device_config* dev = devtag_get_device(space->machine,"fdc");
291
292   switch(offset+0xff8)
293   {
294      case 0x0ff8:
295         wd17xx_command_w(dev,offset,data);
296         break;
297      case 0x0ff9:
298         wd17xx_track_w(dev,offset,data);
299         break;
300      case 0x0ffa:
301         wd17xx_sector_w(dev,offset,data);
302         break;
303      case 0x0ffb:
304         wd17xx_data_w(dev,offset,data);
305         break;
306      case 0x0ffc:
307         /* data & 3 = disk drive, TODO */
308         if(data & 3)
309            fatalerror("FDC: Using more than 1 floppy disk drive!");
310         wd17xx_set_drive(dev,0);
311         floppy_drive_set_motor_state(image_from_devtype_and_index(space->machine, IO_FLOPPY, 0), data & 0x80);
312         floppy_drive_set_ready_state(image_from_devtype_and_index(space->machine, IO_FLOPPY, 0), data & 0x80,0);
313         wd17xx_set_side(dev,(data & 0x10)>>4);
314         break;
315      case 0x0ffd:
316      case 0x0ffe:
317      case 0x0fff:
318         logerror("FDC: write to %04x = %02x\n",offset+0xff8,data);
319         break;
320   }
321}
322
323static const wd17xx_interface x1_mb8877a_interface =
324{
325   x1_fdc_irq,
326   NULL
327};
328
227329static ADDRESS_MAP_START( x1_mem, ADDRESS_SPACE_PROGRAM, 8 )
228330   ADDRESS_MAP_UNMAP_HIGH
229331   AM_RANGE(0x0000, 0x7fff) AM_ROMBANK(1) AM_WRITE(rom_data_w)
r5503r5504
237339   AM_RANGE(0x0e00, 0x0e02) AM_WRITE(x1_rom_w)
238340   AM_RANGE(0x0e03, 0x0e03) AM_READ(x1_rom_r)
239341//   AM_RANGE(0x0e80, 0x0e82) AM_WRITENOP //kanji registers?
240//   AM_RANGE(0x0ff8, 0x0fff) AM_WRITENOP //fdc registers
342   AM_RANGE(0x0ff8, 0x0fff) AM_READWRITE(x1_fdc_r,x1_fdc_w) //fdc registers
241343//   AM_RANGE(0x1000, 0x12ff) AM_RAM //paletteram
242344//   AM_RANGE(0x1300, 0x13ff) AM_WRITENOP //ply port, mirrored
243345//   AM_RANGE(0x1400, 0x17ff) AM_RAM //pcg?
r5503r5504
256358//   AM_RANGE(0x1fd0, 0x1fdf) AM_RAM //scrn?
257359   AM_RANGE(0x2000, 0x2fff) AM_RAM AM_BASE(&colorram)//txt mode RAM
258360   AM_RANGE(0x3000, 0x3fff) AM_RAM AM_BASE(&videoram)//txt mode RAM
259   AM_RANGE(0x4000, 0x5fff) AM_RAM //gfx mode RAM
361   AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE(&bitmapa_ram)//gfx mode bank 1 RAM
362   AM_RANGE(0x6000, 0x7fff) AM_RAM AM_BASE(&bitmapb_ram)//gfx mode bank 2 RAM
260363ADDRESS_MAP_END
261364
262365static const gfx_layout x1_chars_8x8 =
r5503r5504
318421      palette_set_color_rgb(machine, 0x200+i, pal1bit(i >> 2), pal1bit(i >> 1), pal1bit(i >> 0));
319422}
320423
321static UINT8 hres_320,io_switch;
322
323424static READ8_DEVICE_HANDLER( x1_porta_r )
324425{
325426   //printf("PPI Port A read\n");
r5503r5504
488589   MDRV_VIDEO_START(x1)
489590   MDRV_VIDEO_UPDATE(x1)
490591
592   MDRV_MB8877_ADD("fdc",x1_mb8877a_interface)
593
491594   MDRV_SPEAKER_STANDARD_MONO("mono")
492595
493596   MDRV_SOUND_ADD("ay", AY8910, XTAL_4MHz/8) //unknown clock / divider
r5503r5504
495598   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
496599MACHINE_DRIVER_END
497600
601static DEVICE_IMAGE_LOAD( x1_floppy )
602{
603   if (image_has_been_created(image))
604      return INIT_FAIL;
605
606   if (image_length(image) == 80*1*16*256) // 320K
607   {
608      if (DEVICE_IMAGE_LOAD_NAME(basicdsk_floppy)(image) == INIT_PASS)
609      {
610         /* image, tracks, sides, sectors per track, sector length, first sector id, offset of track 0, track skipping */
611         basicdsk_set_geometry(image, 40, 2, 16, 256, 1, 0, FALSE);
612
613         return INIT_PASS;
614      }
615   }
616
617   return INIT_FAIL;
618}
619
620static void x1_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info)
621{
622   switch(state)
623   {
624      /* --- the following bits of info are returned as 64-bit signed integers --- */
625      case MESS_DEVINFO_INT_COUNT:               info->i = 1; break;
626
627      /* --- the following bits of info are returned as pointers to data or functions --- */
628      case MESS_DEVINFO_PTR_LOAD:                  info->load = DEVICE_IMAGE_LOAD_NAME(x1_floppy); break;
629
630      /* --- the following bits of info are returned as NULL-terminated strings --- */
631      case MESS_DEVINFO_STR_FILE_EXTENSIONS:         strcpy(info->s = device_temp_str(), "2d"); break;
632
633      default:                              legacybasicdsk_device_getinfo(devclass, state, info); break;
634   }
635}
636
498637static SYSTEM_CONFIG_START(x1)
638   CONFIG_DEVICE(x1_floppy_getinfo)
499639SYSTEM_CONFIG_END
500640
501641/* ROM definition */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team