trunk/src/emu/video/scn2674.c
| r249172 | r249173 | |
| 38 | 38 | save_item(NAME(m_linecounter)); |
| 39 | 39 | save_item(NAME(m_screen2_l)); |
| 40 | 40 | save_item(NAME(m_screen2_h)); |
| 41 | save_item(NAME(m_cursor_l)); |
| 42 | save_item(NAME(m_cursor_h)); |
| 41 | 43 | } |
| 42 | 44 | |
| 43 | 45 | void scn2674_device::device_reset() |
| r249172 | r249173 | |
| 94 | 96 | m_spl1= 0; |
| 95 | 97 | m_spl2= 0; |
| 96 | 98 | m_dbl1= 0; |
| 99 | m_buffer= 0; |
| 97 | 100 | m_linecounter= 0; |
| 98 | 101 | m_irq_state= 0; |
| 99 | 102 | m_IR_pointer = 0; |
| 100 | 103 | m_address = 0; |
| 104 | m_start1change = 0; |
| 101 | 105 | m_hpixels_per_column = m_text_hpixels_per_column; |
| 102 | 106 | } |
| 103 | 107 | |
| r249172 | r249173 | |
| 246 | 250 | break; |
| 247 | 251 | |
| 248 | 252 | } |
| 249 | | if(m_display_enabled) |
| 250 | | recompute_parameters(); |
| 253 | recompute_parameters(); |
| 251 | 254 | |
| 252 | 255 | m_IR_pointer++; |
| 253 | 256 | if (m_IR_pointer>14)m_IR_pointer=14; |
| r249172 | r249173 | |
| 291 | 294 | /* Disable GFX */ |
| 292 | 295 | LOG2674(("disable GFX %02x\n",data)); |
| 293 | 296 | m_gfx_enabled = 0; |
| 294 | | if(m_display_enabled) |
| 295 | | recompute_parameters(); |
| 297 | recompute_parameters(); |
| 296 | 298 | } |
| 297 | 299 | |
| 298 | 300 | if ((data&0xe3)==0x23) |
| r249172 | r249173 | |
| 300 | 302 | /* Enable GFX */ |
| 301 | 303 | LOG2674(("enable GFX %02x\n",data)); |
| 302 | 304 | m_gfx_enabled = 1; |
| 303 | | if(m_display_enabled) |
| 304 | | recompute_parameters(); |
| 305 | recompute_parameters(); |
| 305 | 306 | } |
| 306 | 307 | |
| 307 | 308 | if ((data&0xe9)==0x28) |
| r249172 | r249173 | |
| 410 | 411 | |
| 411 | 412 | /* Delayed Commands */ |
| 412 | 413 | /* These set 0x20 in status register when done */ |
| 413 | | |
| 414 | | if (data == 0xa4) |
| 414 | // These use the pointer address according to the datasheet but the pcx expects the screen start 2 address instead |
| 415 | switch(data) |
| 415 | 416 | { |
| 416 | | /* read at pointer address */ |
| 417 | | LOG2674(("DELAYED read at pointer address %02x\n",data)); |
| 418 | | } |
| 417 | case 0xa4: |
| 418 | /* read at pointer address */ |
| 419 | m_buffer = space().read_byte(m_screen2_l | (m_screen2_h << 8)); |
| 420 | LOG2674(("DELAYED read at pointer address %02x\n",data)); |
| 421 | break; |
| 419 | 422 | |
| 420 | | if (data == 0xa2) |
| 421 | | { |
| 422 | | /* write at pointer address */ |
| 423 | | LOG2674(("DELAYED write at pointer address %02x\n",data)); |
| 424 | | } |
| 423 | case 0xa2: |
| 424 | /* write at pointer address */ |
| 425 | space().write_byte(m_screen2_l | (m_screen2_h << 8), m_buffer); |
| 426 | LOG2674(("DELAYED write at pointer address %02x\n",data)); |
| 427 | break; |
| 425 | 428 | |
| 426 | | if (data == 0xa9) |
| 427 | | { |
| 428 | | /* increase cursor address */ |
| 429 | | LOG2674(("DELAYED increase cursor address %02x\n",data)); |
| 430 | | } |
| 429 | case 0xa9: |
| 430 | /* increment cursor address */ |
| 431 | if(!(++m_cursor_l)) |
| 432 | m_cursor_h++; |
| 433 | LOG2674(("DELAYED increase cursor address %02x\n",data)); |
| 434 | break; |
| 431 | 435 | |
| 432 | | if (data == 0xac) |
| 433 | | { |
| 434 | | /* read at cursor address */ |
| 435 | | LOG2674(("DELAYED read at cursor address %02x\n",data)); |
| 436 | | } |
| 436 | case 0xac: |
| 437 | /* read at cursor address */ |
| 438 | m_buffer = space().read_byte(m_cursor_l | (m_cursor_h << 8)); |
| 439 | LOG2674(("DELAYED read at cursor address %02x\n",data)); |
| 440 | break; |
| 437 | 441 | |
| 438 | | if (data == 0xaa) |
| 439 | | { |
| 440 | | /* write at cursor address */ |
| 441 | | LOG2674(("DELAYED write at cursor address %02x\n",data)); |
| 442 | | } |
| 442 | case 0xaa: |
| 443 | /* write at cursor address */ |
| 444 | space().write_byte(m_cursor_l | (m_cursor_h << 8), m_buffer); |
| 445 | LOG2674(("DELAYED write at cursor address %02x\n",data)); |
| 446 | break; |
| 443 | 447 | |
| 444 | | if (data == 0xad) |
| 445 | | { |
| 446 | | /* read at cursor address + increment */ |
| 447 | | LOG2674(("DELAYED read at cursor address+increment %02x\n",data)); |
| 448 | | } |
| 448 | case 0xad: |
| 449 | /* read at cursor address + increment */ |
| 450 | m_buffer = space().read_byte(m_cursor_l | (m_cursor_h << 8)); |
| 451 | if(!(++m_cursor_l)) |
| 452 | m_cursor_h++; |
| 453 | LOG2674(("DELAYED read at cursor address+increment %02x\n",data)); |
| 454 | break; |
| 449 | 455 | |
| 450 | | if (data == 0xab) |
| 451 | | { |
| 452 | | /* write at cursor address + increment */ |
| 453 | | LOG2674(("DELAYED write at cursor address+increment %02x\n",data)); |
| 454 | | } |
| 456 | case 0xab: |
| 457 | /* write at cursor address + increment */ |
| 458 | space().write_byte(m_cursor_l | (m_cursor_h << 8), m_buffer); |
| 459 | if(!(++m_cursor_l)) |
| 460 | m_cursor_h++; |
| 461 | LOG2674(("DELAYED write at cursor address+increment %02x\n",data)); |
| 462 | break; |
| 455 | 463 | |
| 456 | | if (data == 0xbb) |
| 457 | | { |
| 458 | | /* write from cursor address to pointer address */ |
| 459 | | LOG2674(("DELAYED write from cursor address to pointer address %02x\n",data)); |
| 460 | | } |
| 464 | case 0xbb: |
| 465 | /* write from cursor address to pointer address TODO: transfer only during blank*/ |
| 466 | for(i = m_cursor_l | (m_cursor_h << 8); i != (m_screen2_l | (m_screen2_h << 8)); i = ((i + 1) & 0xffff)) |
| 467 | space().write_byte(i, m_buffer); |
| 468 | space().write_byte(i, m_buffer); // get the last |
| 469 | m_cursor_l = m_screen2_l; |
| 470 | m_cursor_h = m_screen2_h; |
| 471 | LOG2674(("DELAYED write from cursor address to pointer address %02x\n",data)); |
| 472 | break; |
| 461 | 473 | |
| 462 | | if (data == 0xbd) |
| 463 | | { |
| 464 | | /* read from cursor address to pointer address */ |
| 465 | | LOG2674(("DELAYED read from cursor address to pointer address %02x\n",data)); |
| 474 | case 0xbd: |
| 475 | /* read from cursor address to pointer address */ |
| 476 | LOG2674(("DELAYED read from cursor address to pointer address %02x\n",data)); |
| 477 | break; |
| 466 | 478 | } |
| 467 | 479 | } |
| 468 | 480 | |
| r249172 | r249173 | |
| 540 | 552 | write_command(data); |
| 541 | 553 | break; |
| 542 | 554 | |
| 543 | | case 2: m_screen1_l = data; break; |
| 555 | case 2: |
| 556 | m_screen1_l = data; |
| 557 | if(!m_screen->vblank()) |
| 558 | m_start1change = (m_linecounter / m_IR0_scanline_per_char_row) + 1; |
| 559 | break; |
| 544 | 560 | case 3: |
| 545 | 561 | m_screen1_h = data; |
| 546 | 562 | m_dbl1=(data & 0xc0)>>6; |
| r249172 | r249173 | |
| 550 | 566 | m_screen1_h &= 0x3f; |
| 551 | 567 | LOG2674(("IR14 - Double 1 overridden %02x\n",m_IR14_double_1)); |
| 552 | 568 | } |
| 569 | if(!m_screen->vblank()) |
| 570 | m_start1change = (m_linecounter / m_IR0_scanline_per_char_row) + 1; |
| 553 | 571 | break; |
| 554 | 572 | |
| 555 | 573 | case 4: m_cursor_l = data; break; |
| r249172 | r249173 | |
| 572 | 590 | int max_visible_x = (m_IR5_character_per_row * m_hpixels_per_column) - 1; |
| 573 | 591 | int max_visible_y = (m_IR4_rows_per_screen * m_IR0_scanline_per_char_row) - 1; |
| 574 | 592 | |
| 593 | if(!horiz_pix_total || !vert_pix_total) |
| 594 | { |
| 595 | m_scanline_timer->adjust(attotime::never); |
| 596 | return; |
| 597 | } |
| 598 | |
| 575 | 599 | LOG2674(("width %u height %u max_x %u max_y %u refresh %f\n", horiz_pix_total, vert_pix_total, max_visible_x, max_visible_y, 1 / ATTOSECONDS_TO_DOUBLE(refresh))); |
| 576 | 600 | |
| 577 | 601 | rectangle visarea; |
| r249172 | r249173 | |
| 594 | 618 | m_display_enabled_scanline = 0; |
| 595 | 619 | m_display_enabled_field = 0; |
| 596 | 620 | } |
| 597 | | else if(!m_display_enabled) |
| 598 | | break; |
| 599 | 621 | else |
| 600 | 622 | m_linecounter++; |
| 601 | 623 | |
| 602 | | // should be triggered at the start of each ROW (line zero for that row) |
| 603 | 624 | if(m_linecounter >= m_screen->height()) |
| 604 | 625 | { |
| 605 | | m_status_register |= 0x08; |
| 606 | | if (m_irq_mask & 0x08) |
| 607 | | { |
| 608 | | LOG2674(("SCN2674 Line Zero\n")); |
| 609 | | m_irq_state = 1; |
| 610 | | m_irq_register |= 0x08; |
| 611 | | m_irq_cb(1); |
| 612 | | } |
| 613 | 626 | m_linecounter = 0; |
| 614 | 627 | m_address = (m_screen1_h << 8) | m_screen1_l; |
| 615 | 628 | } |
| r249172 | r249173 | |
| 629 | 642 | if(m_linecounter >= (m_IR4_rows_per_screen * m_IR0_scanline_per_char_row)) |
| 630 | 643 | break; |
| 631 | 644 | |
| 645 | int charrow = m_linecounter % m_IR0_scanline_per_char_row; |
| 646 | int tilerow = charrow; |
| 647 | |
| 648 | // should be triggered at the start of each ROW (line zero for that row) |
| 649 | if(!charrow) |
| 650 | { |
| 651 | m_status_register |= 0x08; |
| 652 | if (m_irq_mask & 0x08) |
| 653 | { |
| 654 | LOG2674(("SCN2674 Line Zero\n")); |
| 655 | m_irq_state = 1; |
| 656 | m_irq_register |= 0x08; |
| 657 | m_irq_cb(1); |
| 658 | } |
| 659 | } |
| 660 | |
| 632 | 661 | if((m_linecounter == (m_IR12_split_register_1 * m_IR0_scanline_per_char_row)) && m_linecounter) /* Split Screen 1 */ |
| 633 | 662 | { |
| 634 | 663 | m_status_register |= 0x04; |
| r249172 | r249173 | |
| 661 | 690 | dw = m_IR14_double_2; |
| 662 | 691 | } |
| 663 | 692 | |
| 664 | | int charrow = m_linecounter % m_IR0_scanline_per_char_row; |
| 665 | | int tilerow = charrow; |
| 693 | if(!m_display_enabled) |
| 694 | break; |
| 666 | 695 | |
| 667 | 696 | if(m_IR2_row_table) |
| 668 | 697 | { |
| r249172 | r249173 | |
| 684 | 713 | m_screen2_h = (addr >> 8) & 0x3f; |
| 685 | 714 | m_screen2_l = addr & 0xff; |
| 686 | 715 | } |
| 687 | | |
| 688 | 716 | } |
| 717 | else if(m_start1change && (m_start1change == (m_linecounter / m_IR0_scanline_per_char_row))) |
| 718 | { |
| 719 | m_address = (m_screen1_h << 8) | m_screen1_l; |
| 720 | m_start1change = 0; |
| 721 | } |
| 689 | 722 | |
| 690 | 723 | if(dw == 2) |
| 691 | 724 | tilerow >>= 1; |
trunk/src/mess/drivers/pcd.c
| r249172 | r249173 | |
| 17 | 17 | #include "machine/wd_fdc.h" |
| 18 | 18 | #include "machine/mc146818.h" |
| 19 | 19 | #include "machine/pcd_kbd.h" |
| 20 | | #include "machine/terminal.h" |
| 20 | #include "video/pcd.h" |
| 21 | 21 | #include "sound/speaker.h" |
| 22 | | #include "video/scn2674.h" |
| 23 | 22 | #include "formats/pc_dsk.h" |
| 24 | 23 | #include "bus/scsi/omti5100.h" |
| 25 | 24 | #include "bus/rs232/rs232.h" |
| r249172 | r249173 | |
| 39 | 38 | m_speaker(*this, "speaker"), |
| 40 | 39 | m_fdc(*this, "fdc"), |
| 41 | 40 | m_rtc(*this, "rtc"), |
| 42 | | m_crtc(*this, "crtc"), |
| 43 | | m_palette(*this, "palette"), |
| 44 | | m_gfxdecode(*this, "gfxdecode"), |
| 45 | 41 | m_scsi(*this, "scsi"), |
| 46 | 42 | m_scsi_data_out(*this, "scsi_data_out"), |
| 47 | 43 | m_scsi_data_in(*this, "scsi_data_in"), |
| 48 | | m_terminal(*this, "terminal"), |
| 49 | | m_ram(*this, "ram"), |
| 50 | | m_vram(*this, "vram"), |
| 51 | | m_charram(8*1024) |
| 44 | m_ram(*this, "ram") |
| 52 | 45 | { } |
| 53 | 46 | |
| 54 | 47 | DECLARE_READ8_MEMBER( irq_callback ); |
| r249172 | r249173 | |
| 63 | 56 | DECLARE_WRITE8_MEMBER( stat_w ); |
| 64 | 57 | DECLARE_READ8_MEMBER( led_r ); |
| 65 | 58 | DECLARE_WRITE8_MEMBER( led_w ); |
| 66 | | DECLARE_READ8_MEMBER( detect_r ); |
| 67 | | DECLARE_WRITE8_MEMBER( detect_w ); |
| 68 | 59 | DECLARE_READ16_MEMBER( dskctl_r ); |
| 69 | 60 | DECLARE_WRITE16_MEMBER( dskctl_w ); |
| 70 | | DECLARE_READ8_MEMBER( mcu_r ); |
| 71 | | DECLARE_WRITE8_MEMBER( mcu_w ); |
| 61 | |
| 72 | 62 | DECLARE_READ8_MEMBER( scsi_r ); |
| 73 | 63 | DECLARE_WRITE8_MEMBER( scsi_w ); |
| 74 | | DECLARE_WRITE8_MEMBER( vram_sw_w ); |
| 75 | | DECLARE_WRITE16_MEMBER( vram_w ); |
| 76 | 64 | DECLARE_READ16_MEMBER( mmu_r ); |
| 77 | 65 | DECLARE_WRITE16_MEMBER( mmu_w ); |
| 78 | 66 | DECLARE_READ16_MEMBER( mem_r ); |
| 79 | 67 | DECLARE_WRITE16_MEMBER( mem_w ); |
| 80 | | DECLARE_READ8_MEMBER( exp_r ); |
| 81 | | DECLARE_WRITE8_MEMBER( exp_w ); |
| 82 | | DECLARE_WRITE8_MEMBER( term_key_w ); |
| 83 | | SCN2674_DRAW_CHARACTER_MEMBER(display_pixels); |
| 68 | |
| 84 | 69 | DECLARE_FLOPPY_FORMATS( floppy_formats ); |
| 85 | 70 | DECLARE_WRITE_LINE_MEMBER(write_scsi_bsy); |
| 86 | 71 | DECLARE_WRITE_LINE_MEMBER(write_scsi_cd); |
| r249172 | r249173 | |
| 101 | 86 | required_device<speaker_sound_device> m_speaker; |
| 102 | 87 | required_device<wd2793_t> m_fdc; |
| 103 | 88 | required_device<mc146818_device> m_rtc; |
| 104 | | required_device<scn2674_device> m_crtc; |
| 105 | | required_device<palette_device> m_palette; |
| 106 | | required_device<gfxdecode_device> m_gfxdecode; |
| 107 | 89 | required_device<SCSI_PORT_DEVICE> m_scsi; |
| 108 | 90 | required_device<output_latch_device> m_scsi_data_out; |
| 109 | 91 | required_device<input_buffer_device> m_scsi_data_in; |
| 110 | | optional_device<generic_terminal_device> m_terminal; |
| 111 | 92 | required_device<ram_device> m_ram; |
| 112 | | required_shared_ptr<UINT16> m_vram; |
| 113 | | dynamic_buffer m_charram; |
| 114 | | UINT8 m_stat, m_led, m_vram_sw, m_term_key; |
| 93 | UINT8 m_stat, m_led; |
| 115 | 94 | int m_msg, m_bsy, m_io, m_cd, m_req, m_rst; |
| 116 | 95 | emu_timer *m_req_hack; |
| 117 | 96 | UINT16 m_dskctl; |
| r249172 | r249173 | |
| 128 | 107 | // MACHINE EMULATION |
| 129 | 108 | //************************************************************************** |
| 130 | 109 | |
| 131 | | static const gfx_layout pcd_charlayout = |
| 132 | | { |
| 133 | | 8, 14, /* 8 x 14 characters */ |
| 134 | | 512, /* 512 characters */ |
| 135 | | 1, /* 1 bits per pixel */ |
| 136 | | { 0 }, /* no bitplanes */ |
| 137 | | /* x offsets */ |
| 138 | | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 139 | | /* y offsets */ |
| 140 | | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8 }, |
| 141 | | 8*16 |
| 142 | | }; |
| 143 | | |
| 144 | 110 | void pcd_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 145 | 111 | { |
| 146 | 112 | // TODO: remove this hack |
| r249172 | r249173 | |
| 150 | 116 | |
| 151 | 117 | void pcd_state::machine_start() |
| 152 | 118 | { |
| 153 | | m_gfxdecode->set_gfx(0, global_alloc(gfx_element(machine().device<palette_device>("palette"), pcd_charlayout, &m_charram[0], 0, 1, 0))); |
| 154 | 119 | m_req_hack = timer_alloc(); |
| 155 | 120 | save_item(NAME(m_mmu.ctl)); |
| 156 | 121 | save_item(NAME(m_mmu.regs)); |
| r249172 | r249173 | |
| 161 | 126 | m_stat = 0; |
| 162 | 127 | m_led = 0; |
| 163 | 128 | m_dskctl = 0; |
| 164 | | m_vram_sw = 1; |
| 165 | 129 | m_rst = 0; |
| 166 | 130 | m_mmu.ctl = 0; |
| 167 | 131 | m_mmu.sc = false; |
| 168 | | m_mmu.type = ioport("mmu")->read(); |
| 169 | | m_term_key = 0; |
| 132 | if(ioport("mmu")) |
| 133 | m_mmu.type = ioport("mmu")->read(); |
| 134 | else |
| 135 | m_mmu.type = 0; |
| 170 | 136 | } |
| 171 | 137 | |
| 172 | 138 | READ8_MEMBER( pcd_state::irq_callback ) |
| r249172 | r249173 | |
| 185 | 151 | m_speaker->level_w(state); |
| 186 | 152 | } |
| 187 | 153 | |
| 188 | | WRITE16_MEMBER( pcd_state::vram_w ) |
| 189 | | { |
| 190 | | if(m_vram_sw) |
| 191 | | COMBINE_DATA(&m_vram[offset]); |
| 192 | | else if(mem_mask & 0xff) |
| 193 | | { |
| 194 | | m_charram[offset & 0x1fff] = data; |
| 195 | | m_gfxdecode->gfx(0)->mark_dirty(offset/16); |
| 196 | | } |
| 197 | | } |
| 198 | | |
| 199 | | WRITE8_MEMBER( pcd_state::vram_sw_w ) |
| 200 | | { |
| 201 | | m_vram_sw = data & 1; |
| 202 | | } |
| 203 | | |
| 204 | 154 | READ8_MEMBER( pcd_state::nmi_io_r ) |
| 205 | 155 | { |
| 206 | 156 | if(space.debugger_access()) |
| r249172 | r249173 | |
| 242 | 192 | m_stat &= ~data; |
| 243 | 193 | } |
| 244 | 194 | |
| 245 | | READ8_MEMBER( pcd_state::detect_r ) |
| 246 | | { |
| 247 | | return 0; |
| 248 | | } |
| 249 | | |
| 250 | | WRITE8_MEMBER( pcd_state::detect_w ) |
| 251 | | { |
| 252 | | } |
| 253 | | |
| 254 | | READ8_MEMBER( pcd_state::mcu_r ) |
| 255 | | { |
| 256 | | return 0x20; |
| 257 | | } |
| 258 | | |
| 259 | | WRITE8_MEMBER( pcd_state::mcu_w ) |
| 260 | | { |
| 261 | | } |
| 262 | | |
| 263 | 195 | READ16_MEMBER( pcd_state::dskctl_r ) |
| 264 | 196 | { |
| 265 | 197 | return m_dskctl; |
| r249172 | r249173 | |
| 337 | 269 | } |
| 338 | 270 | } |
| 339 | 271 | |
| 340 | | SCN2674_DRAW_CHARACTER_MEMBER(pcd_state::display_pixels) |
| 341 | | { |
| 342 | | if(lg) |
| 343 | | { |
| 344 | | UINT16 data = m_vram[address]; |
| 345 | | data = (data >> 8) | (data << 8); |
| 346 | | for(int i = 0; i < 16; i++) |
| 347 | | bitmap.pix32(y, x + i) = m_palette->pen((data & (1 << (15 - i))) ? 1 : 0); |
| 348 | | } |
| 349 | | else |
| 350 | | { |
| 351 | | UINT8 data = m_charram[(m_vram[address] & 0xff) * 16 + linecount]; |
| 352 | | if(cursor && blink) |
| 353 | | data = 0xff; |
| 354 | | for(int i = 0; i < 8; i++) |
| 355 | | bitmap.pix32(y, x + i) = m_palette->pen((data & (1 << (7 - i))) ? 1 : 0); |
| 356 | | } |
| 357 | | } |
| 358 | | |
| 359 | 272 | READ8_MEMBER(pcd_state::scsi_r) |
| 360 | 273 | { |
| 361 | 274 | UINT8 ret = 0; |
| r249172 | r249173 | |
| 495 | 408 | return ram[offset]; |
| 496 | 409 | } |
| 497 | 410 | |
| 498 | | // The PC-X treats the graphics board as a serial port. Maybe the 8031 (instead of 8047) can |
| 499 | | // write directly to the video ram and there's a char ROM instead of RAM? |
| 500 | | READ8_MEMBER(pcd_state::exp_r) |
| 501 | | { |
| 502 | | if(m_dskctl & 0x40) |
| 503 | | { |
| 504 | | if(!offset) |
| 505 | | { |
| 506 | | UINT8 data = m_term_key; |
| 507 | | m_term_key = 0; |
| 508 | | return data; |
| 509 | | } |
| 510 | | else |
| 511 | | { |
| 512 | | m_pic2->ir0_w(CLEAR_LINE); |
| 513 | | return (m_term_key ? 1 : 0); |
| 514 | | } |
| 515 | | } |
| 516 | | else if(offset & 1) |
| 517 | | return m_crtc->read(space, offset/2); |
| 518 | | return 0xff; |
| 519 | | } |
| 520 | | |
| 521 | | WRITE8_MEMBER(pcd_state::exp_w) |
| 522 | | { |
| 523 | | if(m_dskctl & 0x40) |
| 524 | | { |
| 525 | | if(!offset) |
| 526 | | { |
| 527 | | m_pic2->ir0_w(ASSERT_LINE); |
| 528 | | m_terminal->write(space, 0, data); |
| 529 | | } |
| 530 | | } |
| 531 | | else if(!(offset & 1)) |
| 532 | | return m_crtc->write(space, offset/2, data); |
| 533 | | } |
| 534 | | |
| 535 | | WRITE8_MEMBER(pcd_state::term_key_w) |
| 536 | | { |
| 537 | | m_pic2->ir0_w(ASSERT_LINE); |
| 538 | | m_term_key = data; |
| 539 | | } |
| 540 | | |
| 541 | 411 | //************************************************************************** |
| 542 | 412 | // ADDRESS MAPS |
| 543 | 413 | //************************************************************************** |
| 544 | 414 | |
| 545 | 415 | static ADDRESS_MAP_START( pcd_map, AS_PROGRAM, 16, pcd_state ) |
| 546 | 416 | AM_RANGE(0x00000, 0x7ffff) AM_READWRITE(mem_r, mem_w) |
| 547 | | AM_RANGE(0xf0000, 0xf7fff) AM_READONLY AM_WRITE(vram_w) AM_SHARE("vram") |
| 548 | 417 | AM_RANGE(0xfc000, 0xfffff) AM_ROM AM_REGION("bios", 0) |
| 549 | 418 | AM_RANGE(0x00000, 0xfffff) AM_READWRITE8(nmi_io_r, nmi_io_w, 0xffff) |
| 550 | 419 | ADDRESS_MAP_END |
| 551 | 420 | |
| 552 | 421 | static ADDRESS_MAP_START( pcd_io, AS_IO, 16, pcd_state ) |
| 553 | 422 | ADDRESS_MAP_UNMAP_HIGH |
| 554 | | AM_RANGE(0x8000, 0x8fff) AM_READWRITE(mmu_r, mmu_w) |
| 555 | 423 | AM_RANGE(0x0000, 0xefff) AM_READWRITE8(nmi_io_r, nmi_io_w, 0xffff) |
| 556 | 424 | AM_RANGE(0xf000, 0xf7ff) AM_RAM AM_SHARE("nvram") |
| 557 | 425 | AM_RANGE(0xf800, 0xf801) AM_DEVREADWRITE8("pic1", pic8259_device, read, write, 0xffff) |
| r249172 | r249173 | |
| 562 | 430 | AM_RANGE(0xf900, 0xf903) AM_DEVREADWRITE8("fdc", wd2793_t, read, write, 0xffff) |
| 563 | 431 | AM_RANGE(0xf904, 0xf905) AM_READWRITE(dskctl_r, dskctl_w) |
| 564 | 432 | AM_RANGE(0xf940, 0xf943) AM_READWRITE8(scsi_r, scsi_w, 0xffff) |
| 565 | | AM_RANGE(0xf980, 0xf98f) AM_DEVWRITE8("crtc", scn2674_device, write, 0x00ff) |
| 566 | | AM_RANGE(0xf980, 0xf98f) AM_DEVREAD8("crtc", scn2674_device, read, 0xff00) |
| 567 | | AM_RANGE(0xf9a0, 0xf9a1) AM_WRITE8(vram_sw_w, 0x00ff) |
| 568 | | AM_RANGE(0xf9b0, 0xf9b3) AM_READWRITE8(mcu_r, mcu_w, 0x00ff) // 8741 comms |
| 433 | AM_RANGE(0xf980, 0xf98f) AM_DEVICE("video", pcdx_video_device, map) |
| 569 | 434 | AM_RANGE(0xf9c0, 0xf9c3) AM_DEVREADWRITE8("usart1",mc2661_device,read,write,0xffff) // UARTs |
| 570 | 435 | AM_RANGE(0xf9d0, 0xf9d3) AM_DEVREADWRITE8("usart2",mc2661_device,read,write,0xffff) |
| 571 | 436 | AM_RANGE(0xf9e0, 0xf9e3) AM_DEVREADWRITE8("usart3",mc2661_device,read,write,0xffff) |
| 572 | 437 | // AM_RANGE(0xfa00, 0xfa7f) // pcs4-n (peripheral chip select) |
| 573 | | AM_RANGE(0xfb00, 0xfb01) AM_READWRITE8(detect_r, detect_w, 0xff00) // expansion card detection? |
| 574 | 438 | AM_RANGE(0xfb00, 0xffff) AM_READWRITE8(nmi_io_r, nmi_io_w, 0xffff) |
| 575 | 439 | ADDRESS_MAP_END |
| 576 | 440 | |
| 577 | 441 | static ADDRESS_MAP_START( pcx_io, AS_IO, 16, pcd_state ) |
| 578 | 442 | ADDRESS_MAP_UNMAP_HIGH |
| 579 | | AM_RANGE(0xf980, 0xf98f) AM_READWRITE8(exp_r, exp_w, 0xffff) |
| 443 | AM_RANGE(0x8000, 0x8fff) AM_READWRITE(mmu_r, mmu_w) |
| 444 | AM_RANGE(0xfb00, 0xfb01) AM_READWRITE8(nmi_io_r, nmi_io_w, 0xff00) |
| 580 | 445 | AM_IMPORT_FROM(pcd_io) |
| 581 | 446 | ADDRESS_MAP_END |
| 582 | 447 | |
| r249172 | r249173 | |
| 593 | 458 | FLOPPY_PC_FORMAT |
| 594 | 459 | FLOPPY_FORMATS_END |
| 595 | 460 | |
| 596 | | static INPUT_PORTS_START(pcd) |
| 461 | static INPUT_PORTS_START(pcx) |
| 597 | 462 | PORT_START("mmu") |
| 598 | 463 | PORT_CONFNAME(0x03, 0x00, "MMU Type") |
| 599 | 464 | PORT_CONFSETTING(0x00, "None") |
| r249172 | r249173 | |
| 608 | 473 | MCFG_80186_TMROUT1_HANDLER(WRITELINE(pcd_state, i186_timer1_w)) |
| 609 | 474 | MCFG_80186_IRQ_SLAVE_ACK(READ8(pcd_state, irq_callback)) |
| 610 | 475 | |
| 611 | | MCFG_CPU_ADD("graphics", I8741, XTAL_16MHz/2) |
| 612 | | MCFG_DEVICE_DISABLE() |
| 613 | | |
| 614 | 476 | MCFG_TIMER_DRIVER_ADD_PERIODIC("timer0_tick", pcd_state, timer0_tick, attotime::from_hz(XTAL_16MHz / 24)) // adjusted to pass post |
| 615 | 477 | |
| 616 | 478 | MCFG_PIC8259_ADD("pic1", DEVWRITELINE("maincpu", i80186_cpu_device, int0_w), VCC, NULL) |
| 617 | 479 | MCFG_PIC8259_ADD("pic2", DEVWRITELINE("maincpu", i80186_cpu_device, int1_w), VCC, NULL) |
| 618 | 480 | |
| 481 | MCFG_DEVICE_ADD("video", PCD_VIDEO, 0) |
| 482 | |
| 619 | 483 | MCFG_RAM_ADD(RAM_TAG) |
| 620 | 484 | MCFG_RAM_DEFAULT_SIZE("1M") |
| 621 | 485 | |
| r249172 | r249173 | |
| 656 | 520 | MCFG_SOUND_ADD("speaker", SPEAKER_SOUND, 0) |
| 657 | 521 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 658 | 522 | |
| 659 | | // video hardware |
| 660 | | MCFG_SCREEN_ADD("screen", RASTER) |
| 661 | | MCFG_SCREEN_SIZE(640, 350) |
| 662 | | MCFG_SCREEN_VISIBLE_AREA(0, 639, 0, 349) |
| 663 | | MCFG_SCREEN_REFRESH_RATE(50) |
| 664 | | MCFG_SCREEN_UPDATE_DEVICE("crtc", scn2674_device, screen_update) |
| 665 | | |
| 666 | | MCFG_GFXDECODE_ADD("gfxdecode", "palette", empty) |
| 667 | | MCFG_PALETTE_ADD_BLACK_AND_WHITE("palette") |
| 668 | | |
| 669 | | MCFG_SCN2674_VIDEO_ADD("crtc", 0, NULL); |
| 670 | | MCFG_SCN2674_TEXT_CHARACTER_WIDTH(8) |
| 671 | | MCFG_SCN2674_GFX_CHARACTER_WIDTH(16) |
| 672 | | MCFG_SCN2674_DRAW_CHARACTER_CALLBACK_OWNER(pcd_state, display_pixels) |
| 673 | | MCFG_VIDEO_SET_SCREEN("screen") |
| 674 | | |
| 675 | 523 | // rtc |
| 676 | 524 | MCFG_MC146818_ADD("rtc", XTAL_32_768kHz) |
| 677 | 525 | MCFG_MC146818_IRQ_HANDLER(DEVWRITELINE("pic1", pic8259_device, ir7_w)) |
| r249172 | r249173 | |
| 696 | 544 | MCFG_CPU_MODIFY("maincpu") |
| 697 | 545 | MCFG_CPU_IO_MAP(pcx_io) |
| 698 | 546 | |
| 699 | | // FIXME: temporary workaround |
| 700 | | MCFG_DEVICE_ADD("terminal", GENERIC_TERMINAL, 0) |
| 701 | | MCFG_GENERIC_TERMINAL_KEYBOARD_CB(WRITE8(pcd_state, term_key_w)) |
| 547 | MCFG_DEVICE_REPLACE("video", PCX_VIDEO, 0) |
| 548 | MCFG_PCX_VIDEO_TXD_HANDLER(DEVWRITELINE("keyboard", pcd_keyboard_device, t0_w)) |
| 702 | 549 | |
| 703 | | MCFG_DEVICE_REMOVE("graphics") |
| 550 | MCFG_DEVICE_MODIFY("keyboard") |
| 551 | MCFG_PCD_KEYBOARD_OUT_TX_HANDLER(DEVWRITELINE("video", pcx_video_device, rx_w)) |
| 552 | |
| 553 | MCFG_DEVICE_MODIFY("usart2") |
| 554 | MCFG_MC2661_TXD_HANDLER(NULL) |
| 704 | 555 | MACHINE_CONFIG_END |
| 705 | 556 | |
| 706 | 557 | //************************************************************************** |
| r249172 | r249173 | |
| 715 | 566 | ROM_SYSTEM_BIOS(1, "v3", "V3 GS4") // from mainboard SYBAC S26361-D359 V3 GS4 |
| 716 | 567 | ROMX_LOAD("361d0359.d42", 0x0001, 0x2000, CRC(5b4461e4) SHA1(db6756aeabb2e6d3921dc7571a5bed3497b964bf), ROM_SKIP(1) | ROM_BIOS(2)) |
| 717 | 568 | ROMX_LOAD("361d0359.d43", 0x0000, 0x2000, CRC(71c3189d) SHA1(e8dd6c632bfc833074d3a833ea7f59bb5460f313), ROM_SKIP(1) | ROM_BIOS(2)) |
| 718 | | |
| 719 | | // gfx card (scn2674 with 8741), to be moved |
| 720 | | ROM_REGION(0x400, "graphics", 0) |
| 721 | | ROM_LOAD("s36361-d321-v1.bin", 0x000, 0x400, CRC(69baeb2a) SHA1(98b9cd0f38c51b4988a3aed0efcf004bedd115ff)) |
| 722 | 569 | ROM_END |
| 723 | 570 | |
| 724 | 571 | ROM_START( pcx ) |
| r249172 | r249173 | |
| 735 | 582 | // GAME DRIVERS |
| 736 | 583 | //************************************************************************** |
| 737 | 584 | |
| 738 | | COMP( 1984, pcd, 0, 0, pcd, pcd, driver_device, 0, "Siemens", "PC-D", MACHINE_NOT_WORKING ) |
| 739 | | COMP( 1984, pcx, pcd, 0, pcx, pcd, driver_device, 0, "Siemens", "PC-X", MACHINE_NOT_WORKING ) |
| 585 | COMP( 1984, pcd, 0, 0, pcd, 0, driver_device, 0, "Siemens", "PC-D", MACHINE_NOT_WORKING ) |
| 586 | COMP( 1984, pcx, pcd, 0, pcx, pcx, driver_device, 0, "Siemens", "PC-X", MACHINE_NOT_WORKING ) |
trunk/src/mess/video/pcd.c
| r0 | r249173 | |
| 1 | // license:BSD-3-Clause |
| 2 | // copyright-holders:Carl |
| 3 | |
| 4 | #include "pcd.h" |
| 5 | #include "cpu/mcs51/mcs51.h" |
| 6 | #include "cpu/mcs48/mcs48.h" |
| 7 | |
| 8 | const device_type PCD_VIDEO = &device_creator<pcd_video_device>; |
| 9 | const device_type PCX_VIDEO = &device_creator<pcx_video_device>; |
| 10 | |
| 11 | pcdx_video_device::pcdx_video_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source) : |
| 12 | device_t(mconfig, type, name, tag, owner, clock, shortname, source), |
| 13 | m_maincpu(*this, ":maincpu"), |
| 14 | m_mcu(*this, "graphics"), |
| 15 | m_crtc(*this, "crtc"), |
| 16 | m_palette(*this, "palette"), |
| 17 | m_gfxdecode(*this, "gfxdecode") |
| 18 | { |
| 19 | } |
| 20 | |
| 21 | pcd_video_device::pcd_video_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 22 | pcdx_video_device(mconfig, PCD_VIDEO, "Siemens PC-D Video", tag, owner, clock, "pcd_video", __FILE__), |
| 23 | m_vram(32*1024), |
| 24 | m_charram(8*1024) |
| 25 | { |
| 26 | } |
| 27 | |
| 28 | pcx_video_device::pcx_video_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 29 | pcdx_video_device(mconfig, PCX_VIDEO, "Siemens PC-X Video", tag, owner, clock, "pcx_video", __FILE__), |
| 30 | device_serial_interface(mconfig, *this), |
| 31 | m_vram(4*1024), |
| 32 | m_charrom(*this, "char"), |
| 33 | m_pic2(*this, ":pic2"), |
| 34 | m_txd_handler(*this) |
| 35 | { |
| 36 | } |
| 37 | |
| 38 | ROM_START( pcd_video ) |
| 39 | ROM_REGION(0x400, "graphics", 0) |
| 40 | ROM_LOAD("s36361-d321-v1.bin", 0x000, 0x400, CRC(69baeb2a) SHA1(98b9cd0f38c51b4988a3aed0efcf004bedd115ff)) |
| 41 | ROM_END |
| 42 | |
| 43 | const rom_entry *pcd_video_device::device_rom_region() const |
| 44 | { |
| 45 | return ROM_NAME( pcd_video ); |
| 46 | } |
| 47 | |
| 48 | ROM_START( pcx_video ) |
| 49 | ROM_REGION(0x2000, "char", 0) |
| 50 | ROM_LOAD("d12-graka.bin", 0x0000, 0x2000, CRC(e4933c16) SHA1(932ae1f0cd2b029b7f5fc3d2d1679e70b25c0828)) |
| 51 | |
| 52 | ROM_REGION(0x6000, "graphics", 0) |
| 53 | ROM_LOAD("d40-graka.bin", 0x0000, 0x2000, CRC(dce48252) SHA1(0d9a575b2d001168a36864d7bd5db1c3aca5fb8d)) |
| 54 | ROM_LOAD("d39-graka.bin", 0x4000, 0x2000, CRC(02920e25) SHA1(145a6648d75c1dc4788f9bc7790281ef7e8f8426)) |
| 55 | ROM_END |
| 56 | |
| 57 | const rom_entry *pcx_video_device::device_rom_region() const |
| 58 | { |
| 59 | return ROM_NAME( pcx_video ); |
| 60 | } |
| 61 | |
| 62 | static const gfx_layout pcd_charlayout = |
| 63 | { |
| 64 | 8, 14, /* 8 x 14 characters */ |
| 65 | 512, /* 512 characters */ |
| 66 | 1, /* 1 bits per pixel */ |
| 67 | { 0 }, /* no bitplanes */ |
| 68 | /* x offsets */ |
| 69 | { 0, 1, 2, 3, 4, 5, 6, 7 }, |
| 70 | /* y offsets */ |
| 71 | { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8, 8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8 }, |
| 72 | 8*16 |
| 73 | }; |
| 74 | |
| 75 | static GFXDECODE_START( pcx ) |
| 76 | GFXDECODE_ENTRY( "char", 0x0000, pcd_charlayout, 0, 1 ) |
| 77 | GFXDECODE_END |
| 78 | |
| 79 | static MACHINE_CONFIG_FRAGMENT( pcd_video ) |
| 80 | MCFG_CPU_ADD("graphics", I8741, XTAL_16MHz/2) |
| 81 | MCFG_DEVICE_DISABLE() |
| 82 | |
| 83 | // video hardware |
| 84 | MCFG_SCREEN_ADD("screen", RASTER) |
| 85 | MCFG_SCREEN_SIZE(640, 350) |
| 86 | MCFG_SCREEN_VISIBLE_AREA(0, 639, 0, 349) |
| 87 | MCFG_SCREEN_REFRESH_RATE(50) |
| 88 | MCFG_SCREEN_UPDATE_DEVICE("crtc", scn2674_device, screen_update) |
| 89 | |
| 90 | MCFG_GFXDECODE_ADD("gfxdecode", "palette", empty) |
| 91 | MCFG_PALETTE_ADD_BLACK_AND_WHITE("palette") |
| 92 | |
| 93 | MCFG_SCN2674_VIDEO_ADD("crtc", 0, NULL); |
| 94 | MCFG_SCN2674_TEXT_CHARACTER_WIDTH(8) |
| 95 | MCFG_SCN2674_GFX_CHARACTER_WIDTH(16) |
| 96 | MCFG_SCN2674_DRAW_CHARACTER_CALLBACK_OWNER(pcd_video_device, display_pixels) |
| 97 | MCFG_VIDEO_SET_SCREEN("screen") |
| 98 | MACHINE_CONFIG_END |
| 99 | |
| 100 | machine_config_constructor pcd_video_device::device_mconfig_additions() const |
| 101 | { |
| 102 | return MACHINE_CONFIG_NAME( pcd_video ); |
| 103 | } |
| 104 | |
| 105 | static ADDRESS_MAP_START( pcx_vid_map, AS_PROGRAM, 8, pcx_video_device ) |
| 106 | AM_RANGE(0x0000, 0x5fff) AM_ROM AM_REGION("graphics", 0) |
| 107 | ADDRESS_MAP_END |
| 108 | |
| 109 | static ADDRESS_MAP_START( pcx_vid_io, AS_IO, 8, pcx_video_device ) |
| 110 | AM_RANGE(0x8000, 0x8007) AM_DEVREADWRITE("crtc", scn2674_device, read, write) |
| 111 | AM_RANGE(0x8008, 0x8008) AM_READ(unk_r) |
| 112 | AM_RANGE(0xa000, 0xa001) AM_READWRITE(vram_latch_r, vram_latch_w) |
| 113 | AM_RANGE(0xa002, 0xa003) AM_READWRITE(term_mcu_r, term_mcu_w) |
| 114 | AM_RANGE(0xc000, 0xc7ff) AM_RAM |
| 115 | ADDRESS_MAP_END |
| 116 | |
| 117 | static ADDRESS_MAP_START( pcx_vram, AS_0, 8, pcx_video_device ) |
| 118 | AM_RANGE(0x0000, 0x07ff) AM_READWRITE(vram_r, vram_w) |
| 119 | ADDRESS_MAP_END |
| 120 | |
| 121 | static MACHINE_CONFIG_FRAGMENT( pcx_video ) |
| 122 | MCFG_CPU_ADD("graphics", I8031, XTAL_24MHz/2) |
| 123 | MCFG_CPU_PROGRAM_MAP(pcx_vid_map) |
| 124 | MCFG_CPU_IO_MAP(pcx_vid_io) |
| 125 | |
| 126 | // video hardware |
| 127 | MCFG_SCREEN_ADD("screen", RASTER) |
| 128 | MCFG_SCREEN_SIZE(640, 350) |
| 129 | MCFG_SCREEN_VISIBLE_AREA(0, 639, 0, 349) |
| 130 | MCFG_SCREEN_REFRESH_RATE(50) |
| 131 | MCFG_SCREEN_UPDATE_DEVICE("crtc", scn2674_device, screen_update) |
| 132 | |
| 133 | MCFG_GFXDECODE_ADD("gfxdecode", "palette", pcx) |
| 134 | MCFG_PALETTE_ADD_BLACK_AND_WHITE("palette") |
| 135 | |
| 136 | MCFG_SCN2674_VIDEO_ADD("crtc", 0, INPUTLINE("graphics", MCS51_INT0_LINE)); |
| 137 | MCFG_SCN2674_TEXT_CHARACTER_WIDTH(8) |
| 138 | MCFG_SCN2674_GFX_CHARACTER_WIDTH(16) |
| 139 | MCFG_SCN2674_DRAW_CHARACTER_CALLBACK_OWNER(pcx_video_device, display_pixels) |
| 140 | MCFG_VIDEO_SET_SCREEN("screen") |
| 141 | MCFG_DEVICE_ADDRESS_MAP(AS_0, pcx_vram) |
| 142 | MACHINE_CONFIG_END |
| 143 | |
| 144 | machine_config_constructor pcx_video_device::device_mconfig_additions() const |
| 145 | { |
| 146 | return MACHINE_CONFIG_NAME( pcx_video ); |
| 147 | } |
| 148 | |
| 149 | SCN2674_DRAW_CHARACTER_MEMBER(pcd_video_device::display_pixels) |
| 150 | { |
| 151 | address <<= 1; |
| 152 | if(lg) |
| 153 | { |
| 154 | UINT16 data = m_vram[address + 1] | (m_vram[address] << 8); |
| 155 | for(int i = 0; i < 16; i++) |
| 156 | bitmap.pix32(y, x + i) = m_palette->pen((data & (1 << (15 - i))) ? 1 : 0); |
| 157 | } |
| 158 | else |
| 159 | { |
| 160 | UINT8 data; |
| 161 | data = m_charram[m_vram[address] * 16 + linecount]; |
| 162 | if(cursor && blink) |
| 163 | data = 0xff; |
| 164 | for(int i = 0; i < 8; i++) |
| 165 | bitmap.pix32(y, x + i) = m_palette->pen((data & (1 << (7 - i))) ? 1 : 0); |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | SCN2674_DRAW_CHARACTER_MEMBER(pcx_video_device::display_pixels) |
| 170 | { |
| 171 | UINT8 data; |
| 172 | address <<= 1; |
| 173 | data = m_charrom[m_vram[address] * 16 + linecount + (m_vram[address + 1] & 0x20 ? 4096 : 0)]; |
| 174 | if(cursor && blink) |
| 175 | data = 0xff; |
| 176 | for(int i = 0; i < 8; i++) |
| 177 | bitmap.pix32(y, x + i) = m_palette->pen((data & (1 << (7 - i))) ? 1 : 0); |
| 178 | } |
| 179 | |
| 180 | WRITE8_MEMBER(pcd_video_device::vram_w) |
| 181 | { |
| 182 | if(m_vram_sw) |
| 183 | m_vram[offset] = data; |
| 184 | else if(!(offset & 1)) |
| 185 | { |
| 186 | offset >>= 1; |
| 187 | m_charram[offset & 0x1fff] = data; |
| 188 | m_gfxdecode->gfx(0)->mark_dirty(offset/16); |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | READ8_MEMBER(pcd_video_device::vram_r) |
| 193 | { |
| 194 | return m_vram[offset]; |
| 195 | } |
| 196 | |
| 197 | WRITE8_MEMBER(pcd_video_device::vram_sw_w) |
| 198 | { |
| 199 | m_vram_sw = data & 1; |
| 200 | } |
| 201 | |
| 202 | |
| 203 | READ8_MEMBER(pcd_video_device::mcu_r) |
| 204 | { |
| 205 | return 0x20; |
| 206 | } |
| 207 | |
| 208 | WRITE8_MEMBER(pcd_video_device::mcu_w) |
| 209 | { |
| 210 | } |
| 211 | |
| 212 | READ8_MEMBER(pcx_video_device::term_r) |
| 213 | { |
| 214 | switch(offset) |
| 215 | { |
| 216 | case 0: |
| 217 | m_pic2->ir0_w(CLEAR_LINE); |
| 218 | m_term_stat &= ~2; |
| 219 | return m_term_key; |
| 220 | case 1: |
| 221 | m_pic2->ir0_w(CLEAR_LINE); |
| 222 | return m_term_stat >> 1; |
| 223 | } |
| 224 | return 0xff; |
| 225 | } |
| 226 | |
| 227 | WRITE8_MEMBER(pcx_video_device::term_w) |
| 228 | { |
| 229 | if(!offset) |
| 230 | { |
| 231 | m_mcu->set_input_line(MCS51_INT1_LINE, ASSERT_LINE); |
| 232 | m_term_char = data; |
| 233 | m_term_stat |= 4; |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | READ8_MEMBER(pcx_video_device::term_mcu_r) |
| 238 | { |
| 239 | switch(offset) |
| 240 | { |
| 241 | case 0: |
| 242 | m_mcu->set_input_line(MCS51_INT1_LINE, CLEAR_LINE); |
| 243 | m_pic2->ir0_w(ASSERT_LINE); |
| 244 | m_term_stat &= ~4; |
| 245 | return m_term_char; |
| 246 | case 1: |
| 247 | return m_term_stat; |
| 248 | } |
| 249 | return 0; |
| 250 | } |
| 251 | |
| 252 | WRITE8_MEMBER(pcx_video_device::term_mcu_w) |
| 253 | { |
| 254 | if(!offset) |
| 255 | { |
| 256 | m_term_key = data; |
| 257 | m_pic2->ir0_w(ASSERT_LINE); |
| 258 | m_term_stat |= 2; |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | WRITE8_MEMBER(pcx_video_device::vram_w) |
| 263 | { |
| 264 | offset <<= 1; |
| 265 | m_vram[offset] = m_vram_latch_w[0]; |
| 266 | m_vram[offset+1] = m_vram_latch_w[1]; |
| 267 | } |
| 268 | |
| 269 | READ8_MEMBER(pcx_video_device::vram_r) |
| 270 | { |
| 271 | offset <<= 1; |
| 272 | m_vram_latch_r[0] = m_vram[offset]; |
| 273 | m_vram_latch_r[1] = m_vram[offset+1]; |
| 274 | return m_vram[offset]; |
| 275 | } |
| 276 | |
| 277 | WRITE8_MEMBER(pcx_video_device::vram_latch_w) |
| 278 | { |
| 279 | m_vram_latch_w[offset] = data; |
| 280 | } |
| 281 | |
| 282 | READ8_MEMBER(pcx_video_device::vram_latch_r) |
| 283 | { |
| 284 | return m_vram_latch_r[offset]; |
| 285 | } |
| 286 | |
| 287 | READ8_MEMBER(pcdx_video_device::detect_r) |
| 288 | { |
| 289 | return 0; |
| 290 | } |
| 291 | |
| 292 | WRITE8_MEMBER(pcdx_video_device::detect_w) |
| 293 | { |
| 294 | } |
| 295 | |
| 296 | READ8_MEMBER(pcx_video_device::unk_r) |
| 297 | { |
| 298 | return 0x80; |
| 299 | } |
| 300 | |
| 301 | void pcd_video_device::device_start() |
| 302 | { |
| 303 | m_maincpu->space(AS_IO).install_write_handler(0xf9a0, 0xf9a1, 0, 0, write8_delegate(FUNC(pcd_video_device::vram_sw_w), this), 0x00ff); |
| 304 | m_maincpu->space(AS_IO).install_readwrite_handler(0xf9b0, 0xf9b3, 0, 0, read8_delegate(FUNC(pcd_video_device::mcu_r), this), write8_delegate(FUNC(pcd_video_device::mcu_w), this), 0x00ff); |
| 305 | m_maincpu->space(AS_IO).install_readwrite_handler(0xfb00, 0xfb01, 0, 0, read8_delegate(FUNC(pcdx_video_device::detect_r), this), write8_delegate(FUNC(pcdx_video_device::detect_w), this), 0xff00); |
| 306 | m_maincpu->space(AS_PROGRAM).install_readwrite_handler(0xf0000, 0xf7fff, 0, 0, read8_delegate(FUNC(pcd_video_device::vram_r), this), write8_delegate(FUNC(pcd_video_device::vram_w), this), 0xffff); |
| 307 | m_gfxdecode->set_gfx(0, global_alloc(gfx_element(machine().device<palette_device>("palette"), pcd_charlayout, &m_charram[0], 0, 1, 0))); |
| 308 | } |
| 309 | |
| 310 | void pcd_video_device::device_reset() |
| 311 | { |
| 312 | m_vram_sw = 1; |
| 313 | } |
| 314 | |
| 315 | |
| 316 | DEVICE_ADDRESS_MAP_START(map, 16, pcd_video_device) |
| 317 | AM_RANGE(0x0, 0xf) AM_DEVWRITE8("crtc", scn2674_device, write, 0x00ff) |
| 318 | AM_RANGE(0x0, 0xf) AM_DEVREAD8("crtc", scn2674_device, read, 0xff00) |
| 319 | ADDRESS_MAP_END |
| 320 | |
| 321 | void pcx_video_device::device_start() |
| 322 | { |
| 323 | mcs51_cpu_device *mcu = downcast<mcs51_cpu_device *>(m_mcu.target()); |
| 324 | m_maincpu->space(AS_IO).install_readwrite_handler(0xfb00, 0xfb01, 0, 0, read8_delegate(FUNC(pcdx_video_device::detect_r), this), write8_delegate(FUNC(pcdx_video_device::detect_w), this), 0x00ff); |
| 325 | m_txd_handler.resolve_safe(); |
| 326 | |
| 327 | // set serial callbacks |
| 328 | mcu->i8051_set_serial_tx_callback(WRITE8_DELEGATE(pcx_video_device, tx_callback)); |
| 329 | mcu->i8051_set_serial_rx_callback(READ8_DELEGATE(pcx_video_device, rx_callback)); |
| 330 | set_data_frame(1, 8, PARITY_NONE, STOP_BITS_1); |
| 331 | set_rate(600*2); // FIXME: fix the keyboard when the mc2661 baud rate calc is fixed |
| 332 | } |
| 333 | |
| 334 | void pcx_video_device::device_reset() |
| 335 | { |
| 336 | m_term_key = 0; |
| 337 | m_term_stat = 0; |
| 338 | transmit_register_reset(); |
| 339 | receive_register_reset(); |
| 340 | |
| 341 | m_txd_handler(1); |
| 342 | } |
| 343 | |
| 344 | DEVICE_ADDRESS_MAP_START(map, 16, pcx_video_device) |
| 345 | AM_RANGE(0x0, 0xf) AM_READWRITE8(term_r, term_w, 0xffff) |
| 346 | ADDRESS_MAP_END |
| 347 | |
| 348 | READ8_MEMBER(pcx_video_device::rx_callback) |
| 349 | { |
| 350 | return get_received_char(); |
| 351 | } |
| 352 | |
| 353 | WRITE8_MEMBER(pcx_video_device::tx_callback) |
| 354 | { |
| 355 | transmit_register_setup(data); |
| 356 | } |
| 357 | |
| 358 | void pcx_video_device::tra_callback() |
| 359 | { |
| 360 | m_txd_handler(transmit_register_get_data_bit()); |
| 361 | } |
| 362 | |
| 363 | void pcx_video_device::rcv_complete() |
| 364 | { |
| 365 | receive_register_extract(); |
| 366 | m_mcu->set_input_line(MCS51_RX_LINE, ASSERT_LINE); |
| 367 | m_mcu->set_input_line(MCS51_RX_LINE, CLEAR_LINE); |
| 368 | } |
| 369 | |
| 370 | void pcx_video_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 371 | { |
| 372 | device_serial_interface::device_timer(timer, id, param, ptr); |
| 373 | } |
trunk/src/mess/video/pcd.h
| r0 | r249173 | |
| 1 | // license:BSD-3-Clause |
| 2 | // copyright-holders:Carl |
| 3 | |
| 4 | #ifndef _PCD_H_ |
| 5 | #define _PCD_H_ |
| 6 | |
| 7 | #include "emu.h" |
| 8 | #include "machine/pic8259.h" |
| 9 | #include "video/scn2674.h" |
| 10 | |
| 11 | #define MCFG_PCX_VIDEO_TXD_HANDLER(_devcb) \ |
| 12 | devcb = &pcx_video_device::set_txd_handler(*device, DEVCB_##_devcb); |
| 13 | |
| 14 | class pcdx_video_device : public device_t |
| 15 | { |
| 16 | public: |
| 17 | pcdx_video_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, const char *shortname, const char *source); |
| 18 | |
| 19 | virtual DECLARE_ADDRESS_MAP(map, 16) = 0; |
| 20 | DECLARE_READ8_MEMBER(detect_r); |
| 21 | DECLARE_WRITE8_MEMBER(detect_w); |
| 22 | protected: |
| 23 | required_device<cpu_device> m_maincpu; |
| 24 | required_device<cpu_device> m_mcu; |
| 25 | required_device<scn2674_device> m_crtc; |
| 26 | required_device<palette_device> m_palette; |
| 27 | required_device<gfxdecode_device> m_gfxdecode; |
| 28 | }; |
| 29 | |
| 30 | class pcd_video_device : public pcdx_video_device |
| 31 | { |
| 32 | public: |
| 33 | pcd_video_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 34 | |
| 35 | DECLARE_ADDRESS_MAP(map, 16); |
| 36 | DECLARE_ADDRESS_MAP(vram_map, 8); |
| 37 | DECLARE_READ8_MEMBER(mcu_r); |
| 38 | DECLARE_WRITE8_MEMBER(mcu_w); |
| 39 | DECLARE_WRITE8_MEMBER(vram_sw_w); |
| 40 | DECLARE_READ8_MEMBER(vram_r); |
| 41 | DECLARE_WRITE8_MEMBER(vram_w); |
| 42 | |
| 43 | virtual const rom_entry *device_rom_region() const; |
| 44 | virtual machine_config_constructor device_mconfig_additions() const; |
| 45 | SCN2674_DRAW_CHARACTER_MEMBER(display_pixels); |
| 46 | protected: |
| 47 | void device_start(); |
| 48 | void device_reset(); |
| 49 | private: |
| 50 | dynamic_buffer m_vram; |
| 51 | dynamic_buffer m_charram; |
| 52 | UINT8 m_vram_sw; |
| 53 | }; |
| 54 | |
| 55 | class pcx_video_device : public pcdx_video_device, |
| 56 | public device_serial_interface |
| 57 | { |
| 58 | public: |
| 59 | pcx_video_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 60 | template<class _Object> static devcb_base &set_txd_handler(device_t &device, _Object object) { return downcast<pcx_video_device &>(device).m_txd_handler.set_callback(object); } |
| 61 | |
| 62 | DECLARE_ADDRESS_MAP(map, 16); |
| 63 | DECLARE_READ8_MEMBER(term_r); |
| 64 | DECLARE_WRITE8_MEMBER(term_w); |
| 65 | DECLARE_READ8_MEMBER(term_mcu_r); |
| 66 | DECLARE_WRITE8_MEMBER(term_mcu_w); |
| 67 | DECLARE_READ8_MEMBER(rx_callback); |
| 68 | DECLARE_WRITE8_MEMBER(tx_callback); |
| 69 | DECLARE_READ8_MEMBER(vram_r); |
| 70 | DECLARE_WRITE8_MEMBER(vram_w); |
| 71 | DECLARE_READ8_MEMBER(vram_latch_r); |
| 72 | DECLARE_WRITE8_MEMBER(vram_latch_w); |
| 73 | DECLARE_READ8_MEMBER(unk_r); |
| 74 | |
| 75 | virtual const rom_entry *device_rom_region() const; |
| 76 | virtual machine_config_constructor device_mconfig_additions() const; |
| 77 | SCN2674_DRAW_CHARACTER_MEMBER(display_pixels); |
| 78 | protected: |
| 79 | void device_start(); |
| 80 | void device_reset(); |
| 81 | void tra_callback(); |
| 82 | void rcv_complete(); |
| 83 | void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| 84 | private: |
| 85 | dynamic_buffer m_vram; |
| 86 | required_region_ptr<UINT8> m_charrom; |
| 87 | required_device<pic8259_device> m_pic2; |
| 88 | devcb_write_line m_txd_handler; |
| 89 | UINT8 m_term_key, m_term_char, m_term_stat, m_vram_latch_r[2], m_vram_latch_w[2]; |
| 90 | }; |
| 91 | |
| 92 | extern const device_type PCD_VIDEO; |
| 93 | extern const device_type PCX_VIDEO; |
| 94 | |
| 95 | #endif |