src/mess/drivers/act.c
| r6243 | r6244 | |
| 19 | 19 | #include "devices/flopdrv.h" |
| 20 | 20 | #include "cpu/z80/z80daisy.h" |
| 21 | 21 | #include "machine/z80ctc.h" |
| 22 | #include "machine/pit8253.h" |
| 23 | #include "machine/pic8259.h" |
| 22 | 24 | |
| 25 | #include "devices/flopdrv.h" |
| 26 | #include "formats/basicdsk.h" |
| 27 | |
| 23 | 28 | static UINT16 *act_vram,*act_scrollram,*act_ram; |
| 29 | static struct |
| 30 | { |
| 31 | UINT8 disp_en; //bit 3 |
| 32 | UINT8 gfx_mode; //bit 4 |
| 33 | UINT8 fdrv_num; //bit 6 |
| 34 | UINT8 p_input_dir; //bit 7 |
| 35 | }xi_sys_ctrl; |
| 24 | 36 | |
| 25 | 37 | static VIDEO_START( act_f1 ) |
| 26 | 38 | { |
| r6243 | r6244 | |
| 66 | 78 | { |
| 67 | 79 | int y,x,xi,yi; |
| 68 | 80 | |
| 69 | | for (y=0;y<25;y++) |
| 81 | if(xi_sys_ctrl.disp_en) |
| 82 | return 0; |
| 83 | |
| 84 | if(xi_sys_ctrl.gfx_mode) |
| 70 | 85 | { |
| 71 | | for (x=0;x<80;x++) |
| 86 | for (y=0;y<25;y++) |
| 72 | 87 | { |
| 73 | | int tile = act_vram[(x+y*80)] & 0x03ff; |
| 88 | for (x=0;x<80;x++) |
| 89 | { |
| 90 | int tile = act_vram[(x+y*80)] & 0x03ff; |
| 74 | 91 | |
| 75 | | //0x8000: reverse |
| 76 | | //0x4000: bright |
| 77 | | //0x2000: underline |
| 78 | | //0x1000: strikethrough |
| 92 | //0x8000: reverse |
| 93 | //0x4000: bright |
| 94 | //0x2000: underline |
| 95 | //0x1000: strikethrough |
| 79 | 96 | |
| 80 | | for(yi=0;yi<16;yi++) |
| 81 | | { |
| 82 | | for(xi=0;xi<10;xi++) |
| 97 | for(yi=0;yi<16;yi++) |
| 83 | 98 | { |
| 84 | | int color; |
| 99 | for(xi=0;xi<10;xi++) |
| 100 | { |
| 101 | int color; |
| 85 | 102 | |
| 86 | | color = (act_ram[(tile*16)+(yi)]>>(xi) & 1) ? 7 : 0; |
| 103 | color = (act_ram[(tile*16)+(yi)]>>(xi) & 1) ? 7 : 0; |
| 87 | 104 | |
| 88 | | //FIXME: X should actually be multiplied by 10. |
| 89 | | if((x*8+xi)<=video_screen_get_visible_area(screen)->max_x && ((y*16+yi))<video_screen_get_visible_area(screen)->max_y) |
| 90 | | *BITMAP_ADDR16(bitmap, y*16+yi, x*8+xi) = screen->machine->pens[color]; |
| 105 | //FIXME: X should actually be multiplied by 10. |
| 106 | if((x*8+xi)<=video_screen_get_visible_area(screen)->max_x && ((y*16+yi))<video_screen_get_visible_area(screen)->max_y) |
| 107 | *BITMAP_ADDR16(bitmap, y*16+yi, x*8+xi) = screen->machine->pens[color]; |
| 108 | } |
| 91 | 109 | } |
| 92 | 110 | } |
| 93 | 111 | } |
| 94 | 112 | } |
| 113 | else |
| 114 | { |
| 115 | //... |
| 116 | } |
| 117 | |
| 95 | 118 | return 0; |
| 96 | 119 | } |
| 97 | 120 | |
| r6243 | r6244 | |
| 113 | 136 | |
| 114 | 137 | static READ8_HANDLER( act_fdc_r ) |
| 115 | 138 | { |
| 116 | | // const device_config* dev = devtag_get_device(space->machine,"fdc"); |
| 139 | const device_config* dev = devtag_get_device(space->machine,"fdc"); |
| 117 | 140 | |
| 118 | 141 | // printf("%02x\n",offset); |
| 119 | 142 | |
| 143 | floppy_drive_set_motor_state(floppy_get_device(space->machine, xi_sys_ctrl.fdrv_num), 1); |
| 144 | floppy_drive_set_ready_state(floppy_get_device(space->machine, xi_sys_ctrl.fdrv_num), 1,0); |
| 145 | |
| 120 | 146 | switch(offset) |
| 121 | 147 | { |
| 122 | 148 | case 0: |
| 123 | | return mame_rand(space->machine); |
| 124 | | // return wd17xx_status_r(dev,offset); |
| 125 | | // case 1: |
| 126 | | // return wd17xx_track_r(dev,offset); |
| 127 | | // case 2: |
| 128 | | // return wd17xx_sector_r(dev,offset); |
| 129 | | // case 3: |
| 130 | | // return wd17xx_data_r(dev,offset); |
| 149 | return wd17xx_status_r(dev,offset); |
| 150 | case 1: |
| 151 | return wd17xx_track_r(dev,offset); |
| 152 | case 2: |
| 153 | return wd17xx_sector_r(dev,offset); |
| 154 | case 3: |
| 155 | return wd17xx_data_r(dev,offset); |
| 131 | 156 | default: |
| 132 | 157 | logerror("FDC: read from %04x\n",offset); |
| 133 | 158 | return 0xff; |
| r6243 | r6244 | |
| 138 | 163 | |
| 139 | 164 | static WRITE8_HANDLER( act_fdc_w ) |
| 140 | 165 | { |
| 141 | | // const device_config* dev = devtag_get_device(space->machine,"fdc"); |
| 166 | const device_config* dev = devtag_get_device(space->machine,"fdc"); |
| 142 | 167 | |
| 143 | 168 | // printf("%02x %02x\n",offset,data); |
| 144 | 169 | |
| 170 | floppy_drive_set_motor_state(floppy_get_device(space->machine, xi_sys_ctrl.fdrv_num), 1); |
| 171 | floppy_drive_set_ready_state(floppy_get_device(space->machine, xi_sys_ctrl.fdrv_num), 1,0); |
| 172 | |
| 145 | 173 | switch(offset) |
| 146 | 174 | { |
| 147 | | // case 0: |
| 148 | | // wd17xx_command_w(dev,offset,data); |
| 149 | | // break; |
| 150 | | // case 1: |
| 151 | | // wd17xx_track_w(dev,offset,data); |
| 152 | | // break; |
| 153 | | // case 2: |
| 154 | | // wd17xx_sector_w(dev,offset,data); |
| 155 | | // break; |
| 156 | | // case 3: |
| 157 | | // wd17xx_data_w(dev,offset,data); |
| 158 | | // break; |
| 175 | case 0: |
| 176 | wd17xx_command_w(dev,offset,data); |
| 177 | break; |
| 178 | case 1: |
| 179 | wd17xx_track_w(dev,offset,data); |
| 180 | break; |
| 181 | case 2: |
| 182 | wd17xx_sector_w(dev,offset,data); |
| 183 | break; |
| 184 | case 3: |
| 185 | wd17xx_data_w(dev,offset,data); |
| 186 | break; |
| 159 | 187 | default: |
| 160 | 188 | logerror("FDC: write to %04x = %02x\n",offset,data); |
| 161 | 189 | break; |
| r6243 | r6244 | |
| 208 | 236 | |
| 209 | 237 | static ADDRESS_MAP_START( act_xi_io , ADDRESS_SPACE_IO, 16) |
| 210 | 238 | ADDRESS_MAP_UNMAP_HIGH |
| 211 | | // AM_RANGE(0x0000, 0x0003) pic |
| 239 | AM_RANGE(0x0000, 0x0003) AM_DEVREADWRITE8("pic8259_master",pic8259_r, pic8259_w,0x00ff) |
| 212 | 240 | AM_RANGE(0x0040, 0x0047) AM_READWRITE8(act_fdc_r, act_fdc_w,0x00ff) |
| 213 | 241 | AM_RANGE(0x0048, 0x004f) AM_DEVREADWRITE8("ppi8255_0", ppi8255_r, ppi8255_w,0x00ff) |
| 214 | 242 | // AM_RANGE(0x0050, 0x0051) sound gen |
| 215 | | // AM_RANGE(0x0058, 0x005f) pit |
| 243 | AM_RANGE(0x0058, 0x005f) AM_DEVREADWRITE8("pit8253",pit8253_r,pit8253_w,0x00ff) |
| 216 | 244 | AM_RANGE(0x0060, 0x0067) AM_READWRITE8(act_sio_r,act_sio_w,0x00ff) |
| 217 | 245 | AM_RANGE(0x0068, 0x0069) AM_DEVWRITE8("crtc", mc6845_address_w,0x00ff) |
| 218 | | AM_RANGE(0x006a, 0x006b) AM_DEVWRITE8("crtc", mc6845_register_w,0x00ff) |
| 246 | AM_RANGE(0x006a, 0x006b) AM_DEVREADWRITE8("crtc", mc6845_register_r,mc6845_register_w,0x00ff) |
| 219 | 247 | // AM_RANGE(0x0070, 0x0073) 8089 |
| 220 | 248 | ADDRESS_MAP_END |
| 221 | 249 | |
| r6243 | r6244 | |
| 289 | 317 | NULL /* update address callback */ |
| 290 | 318 | }; |
| 291 | 319 | |
| 320 | static READ8_DEVICE_HANDLER( act_portb_r ) |
| 321 | { |
| 322 | return 0xff; |
| 323 | } |
| 324 | |
| 325 | /* |
| 326 | x--- ---- Parallel Input Direction |
| 327 | -x-- ---- FDC Drive select |
| 328 | ---x ---- Text/GFX Mode |
| 329 | ---- x--- Display Enable |
| 330 | ---- -x-- FDC Side load |
| 331 | ---- ---x CRTC reset |
| 332 | */ |
| 333 | static WRITE8_DEVICE_HANDLER( act_portb_w ) |
| 334 | { |
| 335 | const device_config* dev = devtag_get_device(device->machine,"fdc"); |
| 336 | |
| 337 | // printf("PPI Port B write %02x\n",data); |
| 338 | xi_sys_ctrl.disp_en = (data & 8)>>3; |
| 339 | xi_sys_ctrl.gfx_mode = (data & 0x10)>>4; |
| 340 | xi_sys_ctrl.p_input_dir = (data & 0x80)>>7; |
| 341 | xi_sys_ctrl.fdrv_num = (data & 0x40)>>6; |
| 342 | |
| 343 | wd17xx_set_drive(dev,xi_sys_ctrl.fdrv_num); |
| 344 | wd17xx_set_side(dev,(data & 0x04)>>2); |
| 345 | } |
| 346 | |
| 292 | 347 | static const ppi8255_interface ppi8255_intf = |
| 293 | 348 | { |
| 294 | | DEVCB_NULL, /* Port A read */ |
| 295 | | DEVCB_NULL, /* Port B read */ |
| 296 | | DEVCB_NULL, /* Port C read */ |
| 297 | | DEVCB_NULL, /* Port A write */ |
| 298 | | DEVCB_NULL, /* Port B write */ |
| 299 | | DEVCB_NULL /* Port C write */ |
| 349 | DEVCB_NULL, /* Port A read */ |
| 350 | DEVCB_HANDLER(act_portb_r), /* Port B read */ |
| 351 | DEVCB_NULL, /* Port C read */ |
| 352 | DEVCB_NULL, /* Port A write */ |
| 353 | DEVCB_HANDLER(act_portb_w), /* Port B write */ |
| 354 | DEVCB_NULL /* Port C write */ |
| 300 | 355 | }; |
| 301 | 356 | |
| 302 | 357 | static const gfx_layout charset_8x8 = |
| r6243 | r6244 | |
| 365 | 420 | // cpu_set_input_line_and_vector(device,0,HOLD_LINE,0x60); |
| 366 | 421 | } |
| 367 | 422 | |
| 423 | static PIC8259_SET_INT_LINE( pc98_master_set_int_line ) { |
| 424 | //printf("%02x\n",interrupt); |
| 425 | cputag_set_input_line(device->machine, "maincpu", 0, interrupt ? HOLD_LINE : CLEAR_LINE); |
| 426 | } |
| 427 | |
| 428 | |
| 429 | static const struct pic8259_interface pic8259_master_config = { |
| 430 | pc98_master_set_int_line |
| 431 | }; |
| 432 | |
| 433 | static PIT8253_OUTPUT_CHANGED( pc_timer0_w ) |
| 434 | { |
| 435 | pic8259_set_irq_line(devtag_get_device( device->machine, "pic8259_master" ), 0, state); |
| 436 | } |
| 437 | |
| 438 | static const struct pit8253_config pit8253_config = |
| 439 | { |
| 440 | { |
| 441 | { |
| 442 | 4670000, /* heartbeat IRQ */ |
| 443 | pc_timer0_w |
| 444 | }, { |
| 445 | 4670000, /* dram refresh */ |
| 446 | NULL |
| 447 | }, { |
| 448 | 4670000, /* pio port c pin 4, and speaker polling enough */ |
| 449 | NULL |
| 450 | } |
| 451 | } |
| 452 | }; |
| 453 | |
| 454 | static FLOPPY_OPTIONS_START( act ) |
| 455 | FLOPPY_OPTION( img2hd, "dsk", "2HD disk image", basicdsk_identify_default, basicdsk_construct_default, |
| 456 | HEADS([2]) |
| 457 | TRACKS([80]) |
| 458 | SECTORS([16]) |
| 459 | SECTOR_LENGTH([256]) |
| 460 | FIRST_SECTOR_ID([1])) |
| 461 | FLOPPY_OPTIONS_END |
| 462 | |
| 463 | static const floppy_config act_floppy_config = |
| 464 | { |
| 465 | DEVCB_NULL, |
| 466 | DEVCB_NULL, |
| 467 | DEVCB_NULL, |
| 468 | DEVCB_NULL, |
| 469 | DEVCB_NULL, |
| 470 | FLOPPY_DRIVE_DS_80, |
| 471 | FLOPPY_OPTIONS_NAME(act), |
| 472 | DO_NOT_KEEP_GEOMETRY |
| 473 | }; |
| 474 | |
| 368 | 475 | static MACHINE_DRIVER_START( act_f1 ) |
| 369 | 476 | /* basic machine hardware */ |
| 370 | 477 | MDRV_CPU_ADD("maincpu", I8086, 4670000) |
| r6243 | r6244 | |
| 420 | 527 | |
| 421 | 528 | MDRV_PPI8255_ADD("ppi8255_0", ppi8255_intf ) |
| 422 | 529 | MDRV_WD2793_ADD("fdc", act_wd2797_interface ) |
| 530 | MDRV_PIC8259_ADD( "pic8259_master", pic8259_master_config ) |
| 531 | MDRV_PIT8253_ADD( "pit8253", pit8253_config ) |
| 423 | 532 | |
| 424 | 533 | MDRV_GFXDECODE(act_xi) |
| 425 | 534 | |
| 426 | 535 | MDRV_VIDEO_START(act_xi) |
| 427 | 536 | MDRV_VIDEO_UPDATE(act_xi) |
| 537 | |
| 538 | MDRV_FLOPPY_2_DRIVES_ADD(act_floppy_config) |
| 428 | 539 | MACHINE_DRIVER_END |
| 429 | 540 | |
| 430 | 541 | /* ROM definition */ |