src/mess/drivers/x1.c
| r5503 | r5504 | |
| 117 | 117 | #include "machine/8255ppi.h" |
| 118 | 118 | #include "sound/ay8910.h" |
| 119 | 119 | #include "video/mc6845.h" |
| 120 | #include "machine/wd17xx.h" |
| 121 | #include "devices/basicdsk.h" |
| 120 | 122 | |
| 123 | static UINT8 hres_320,io_switch; |
| 124 | static UINT8 *bitmapa_ram,*bitmapb_ram; |
| 121 | 125 | |
| 122 | 126 | static VIDEO_START( x1 ) |
| 123 | 127 | { |
| r5503 | r5504 | |
| 125 | 129 | |
| 126 | 130 | static VIDEO_UPDATE( x1 ) |
| 127 | 131 | { |
| 128 | | int y,x; |
| 132 | int y,x,w; |
| 129 | 133 | |
| 134 | w = (hres_320 & 0x40) ? 1 : 2; |
| 135 | |
| 130 | 136 | for (y=0;y<25;y++) |
| 131 | 137 | { |
| 132 | | for (x=0;x<40;x++) |
| 138 | for (x=0;x<40*w;x++) |
| 133 | 139 | { |
| 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; |
| 137 | 143 | |
| 138 | 144 | drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[width],tile,color,0,0,(x/(width+1))*8*(width+1),y*8); |
| 139 | 145 | } |
| r5503 | r5504 | |
| 223 | 229 | ROM[0x10000+offset] = data; |
| 224 | 230 | } |
| 225 | 231 | |
| 232 | /* |
| 233 | FDC is a MB8877A, wd17XX compatible |
| 234 | */ |
| 226 | 235 | |
| 236 | //static UINT8 fdc_irq_flag; |
| 237 | //static UINT8 fdc_drq_flag; |
| 238 | //static UINT8 fdc_side; |
| 239 | //static UINT8 fdc_drive; |
| 240 | |
| 241 | static 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 | |
| 262 | static 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 | |
| 288 | static 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 | |
| 323 | static const wd17xx_interface x1_mb8877a_interface = |
| 324 | { |
| 325 | x1_fdc_irq, |
| 326 | NULL |
| 327 | }; |
| 328 | |
| 227 | 329 | static ADDRESS_MAP_START( x1_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| 228 | 330 | ADDRESS_MAP_UNMAP_HIGH |
| 229 | 331 | AM_RANGE(0x0000, 0x7fff) AM_ROMBANK(1) AM_WRITE(rom_data_w) |
| r5503 | r5504 | |
| 237 | 339 | AM_RANGE(0x0e00, 0x0e02) AM_WRITE(x1_rom_w) |
| 238 | 340 | AM_RANGE(0x0e03, 0x0e03) AM_READ(x1_rom_r) |
| 239 | 341 | // 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 |
| 241 | 343 | // AM_RANGE(0x1000, 0x12ff) AM_RAM //paletteram |
| 242 | 344 | // AM_RANGE(0x1300, 0x13ff) AM_WRITENOP //ply port, mirrored |
| 243 | 345 | // AM_RANGE(0x1400, 0x17ff) AM_RAM //pcg? |
| r5503 | r5504 | |
| 256 | 358 | // AM_RANGE(0x1fd0, 0x1fdf) AM_RAM //scrn? |
| 257 | 359 | AM_RANGE(0x2000, 0x2fff) AM_RAM AM_BASE(&colorram)//txt mode RAM |
| 258 | 360 | 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 |
| 260 | 363 | ADDRESS_MAP_END |
| 261 | 364 | |
| 262 | 365 | static const gfx_layout x1_chars_8x8 = |
| r5503 | r5504 | |
| 318 | 421 | palette_set_color_rgb(machine, 0x200+i, pal1bit(i >> 2), pal1bit(i >> 1), pal1bit(i >> 0)); |
| 319 | 422 | } |
| 320 | 423 | |
| 321 | | static UINT8 hres_320,io_switch; |
| 322 | | |
| 323 | 424 | static READ8_DEVICE_HANDLER( x1_porta_r ) |
| 324 | 425 | { |
| 325 | 426 | //printf("PPI Port A read\n"); |
| r5503 | r5504 | |
| 488 | 589 | MDRV_VIDEO_START(x1) |
| 489 | 590 | MDRV_VIDEO_UPDATE(x1) |
| 490 | 591 | |
| 592 | MDRV_MB8877_ADD("fdc",x1_mb8877a_interface) |
| 593 | |
| 491 | 594 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 492 | 595 | |
| 493 | 596 | MDRV_SOUND_ADD("ay", AY8910, XTAL_4MHz/8) //unknown clock / divider |
| r5503 | r5504 | |
| 495 | 598 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 496 | 599 | MACHINE_DRIVER_END |
| 497 | 600 | |
| 601 | static 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 | |
| 620 | static 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 | |
| 498 | 637 | static SYSTEM_CONFIG_START(x1) |
| 638 | CONFIG_DEVICE(x1_floppy_getinfo) |
| 499 | 639 | SYSTEM_CONFIG_END |
| 500 | 640 | |
| 501 | 641 | /* ROM definition */ |