trunk/src/emu/video/upd7220.c
| r242318 | r242319 | |
| 148 | 148 | |
| 149 | 149 | |
| 150 | 150 | // default address map |
| 151 | | static ADDRESS_MAP_START( upd7220_vram, AS_0, 8, upd7220_device ) |
| 151 | static ADDRESS_MAP_START( upd7220_vram, AS_0, 16, upd7220_device ) |
| 152 | 152 | AM_RANGE(0x00000, 0x3ffff) AM_RAM |
| 153 | 153 | ADDRESS_MAP_END |
| 154 | 154 | |
| r242318 | r242319 | |
| 206 | 206 | space().write_byte(address, data); |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | inline UINT16 upd7220_device::readword(offs_t address) |
| 210 | { |
| 211 | return space().read_word(address); |
| 212 | } |
| 213 | |
| 214 | |
| 215 | inline void upd7220_device::writeword(offs_t address, UINT16 data) |
| 216 | { |
| 217 | space().write_word(address, data); |
| 218 | } |
| 219 | |
| 209 | 220 | //------------------------------------------------- |
| 210 | 221 | // fifo_clear - |
| 211 | 222 | //------------------------------------------------- |
| r242318 | r242319 | |
| 495 | 506 | |
| 496 | 507 | result = 0; |
| 497 | 508 | |
| 498 | | if(((m_mode & UPD7220_MODE_DISPLAY_MASK) == UPD7220_MODE_DISPLAY_GRAPHICS) || m_figs.m_gd) |
| 499 | | result = BITSWAP8(m_pr[1],0,1,2,3,4,5,6,7) | (BITSWAP8(m_pr[2],0,1,2,3,4,5,6,7) << 8); |
| 500 | | else |
| 501 | | result = m_pr[1] | (m_pr[2] << 8); |
| 509 | result = m_pr[1] | (m_pr[2] << 8); |
| 502 | 510 | |
| 503 | 511 | switch(type) |
| 504 | 512 | { |
| r242318 | r242319 | |
| 526 | 534 | switch(mod & 3) |
| 527 | 535 | { |
| 528 | 536 | case 0x00: //replace |
| 529 | | if(type == 0 || type == 2) |
| 537 | if(type == 0) |
| 538 | writeword(m_ead*2+0, result); |
| 539 | if(type == 2) |
| 530 | 540 | writebyte(m_ead*2+0, result & 0xff); |
| 531 | | if(type == 0 || type == 3) |
| 541 | if(type == 3) |
| 532 | 542 | writebyte(m_ead*2+1, result >> 8); |
| 533 | 543 | break; |
| 534 | 544 | case 0x01: //complement |
| 535 | | if(type == 0 || type == 2) |
| 545 | if(type == 0) |
| 546 | writeword(m_ead*2+0, readword(m_ead*2+0) ^ result); |
| 547 | if(type == 2) |
| 536 | 548 | writebyte(m_ead*2+0, readbyte(m_ead*2+0) ^ (result & 0xff)); |
| 537 | | if(type == 0 || type == 3) |
| 549 | if(type == 3) |
| 538 | 550 | writebyte(m_ead*2+1, readbyte(m_ead*2+1) ^ (result >> 8)); |
| 539 | 551 | break; |
| 540 | 552 | case 0x02: //reset to zero |
| 541 | | if(type == 0 || type == 2) |
| 553 | if(type == 0) |
| 554 | writeword(m_ead*2+0, readword(m_ead*2+0) & ~result); |
| 555 | if(type == 2) |
| 542 | 556 | writebyte(m_ead*2+0, readbyte(m_ead*2+0) & ~(result & 0xff)); |
| 543 | | if(type == 0 || type == 3) |
| 557 | if(type == 3) |
| 544 | 558 | writebyte(m_ead*2+1, readbyte(m_ead*2+1) & ~(result >> 8)); |
| 545 | 559 | break; |
| 546 | 560 | case 0x03: //set to one |
| 547 | | if(type == 0 || type == 2) |
| 561 | if(type == 0) |
| 562 | writeword(m_ead*2+0, readword(m_ead*2+0) | result); |
| 563 | if(type == 2) |
| 548 | 564 | writebyte(m_ead*2+0, readbyte(m_ead*2+0) | (result & 0xff)); |
| 549 | | if(type == 0 || type == 3) |
| 565 | if(type == 3) |
| 550 | 566 | writebyte(m_ead*2+1, readbyte(m_ead*2+1) | (result >> 8)); |
| 551 | 567 | break; |
| 552 | 568 | } |
| r242318 | r242319 | |
| 631 | 647 | m_disp(0), |
| 632 | 648 | m_gchr(0), |
| 633 | 649 | m_bitmap_mod(0), |
| 634 | | m_space_config("videoram", ENDIANNESS_LITTLE, 8, 18, 0, NULL, *ADDRESS_MAP_NAME(upd7220_vram)) |
| 650 | m_space_config("videoram", ENDIANNESS_LITTLE, 16, 18, 0, NULL, *ADDRESS_MAP_NAME(upd7220_vram)) |
| 635 | 651 | { |
| 636 | 652 | for (int i = 0; i < 16; i++) |
| 637 | 653 | { |
| r242318 | r242319 | |
| 773 | 789 | void upd7220_device::draw_pixel(int x, int y, int xi, UINT16 tile_data) |
| 774 | 790 | { |
| 775 | 791 | UINT32 addr = ((y * (m_pitch << (m_figs.m_gd ? 0 : 1))) + (x >> 3)) & 0x3ffff; |
| 776 | | UINT8 data = readbyte(addr); |
| 777 | | UINT8 new_pixel = (xi & 8 ? tile_data >> 8 : tile_data & 0xff) & (0x80 >> (xi & 7)); |
| 778 | | new_pixel = new_pixel ? (0xff & (0x80 >> (x & 7))) : 0; |
| 792 | UINT16 data = readword(addr); |
| 793 | UINT16 new_pixel = (tile_data & (1 << (xi & 0xf))) ? (1 << (x & 0xf)) : 0; |
| 779 | 794 | |
| 780 | 795 | switch(m_bitmap_mod) |
| 781 | 796 | { |
| 782 | 797 | case 0: //replace |
| 783 | | writebyte(addr, (data & ~(0x80 >> (x & 7))) | new_pixel); |
| 798 | writeword(addr, (data & ~(1 << (x & 0xf))) | new_pixel); |
| 784 | 799 | break; |
| 785 | 800 | case 1: //complement |
| 786 | | writebyte(addr, data ^ new_pixel); |
| 801 | writeword(addr, data ^ new_pixel); |
| 787 | 802 | break; |
| 788 | 803 | case 2: //reset |
| 789 | | writebyte(addr, data & ~new_pixel); |
| 804 | writeword(addr, data & ~new_pixel); |
| 790 | 805 | break; |
| 791 | 806 | case 3: //set |
| 792 | | writebyte(addr, data | new_pixel); |
| 807 | writeword(addr, data | new_pixel); |
| 793 | 808 | break; |
| 794 | 809 | } |
| 795 | 810 | } |
| r242318 | r242319 | |
| 986 | 1001 | |
| 987 | 1002 | for(int pi = 0; pi < psize; pi++) |
| 988 | 1003 | { |
| 989 | | tile_data = BITSWAP8(m_ra[((psize-1-pi) & 7) | 8],0,1,2,3,4,5,6,7); |
| 990 | | tile_data = (tile_data << 8) | (tile_data & 0xff); |
| 1004 | tile_data = (m_ra[((psize-1-pi) & 7) | 8] << 8) | m_ra[((psize-1-pi) & 7) | 8]; |
| 991 | 1005 | for(int pz = 0; pz <= m_gchr; pz++) |
| 992 | 1006 | { |
| 993 | 1007 | for(int ii = 0, curpixel = 0; ii < isize; ii++) |
| r242318 | r242319 | |
| 1572 | 1586 | |
| 1573 | 1587 | for (sx = 0; sx < pitch; sx++) |
| 1574 | 1588 | { |
| 1575 | | if((sx << 3) < m_aw * 16 && y < al) |
| 1576 | | m_display_cb(bitmap, y, sx << 3, addr); |
| 1589 | if((sx << 4) < m_aw * 16 && y < al) |
| 1590 | m_display_cb(bitmap, y, sx << 4, addr); |
| 1577 | 1591 | |
| 1578 | | addr+= wd + 1; |
| 1592 | addr+= (wd + 1) * 2; |
| 1579 | 1593 | } |
| 1580 | 1594 | } |
| 1581 | 1595 | |
trunk/src/mess/drivers/pc9801.c
| r242318 | r242319 | |
| 484 | 484 | optional_device<input_buffer_device> m_sasi_data_in; |
| 485 | 485 | optional_device<input_buffer_device> m_sasi_ctrl_in; |
| 486 | 486 | optional_device<ata_interface_device> m_ide; |
| 487 | | required_shared_ptr<UINT8> m_video_ram_1; |
| 488 | | required_shared_ptr<UINT8> m_video_ram_2; |
| 489 | | optional_shared_ptr<UINT8> m_ext_gvram; |
| 487 | required_shared_ptr<UINT16> m_video_ram_1; |
| 488 | required_shared_ptr<UINT16> m_video_ram_2; |
| 489 | optional_shared_ptr<UINT16> m_ext_gvram; |
| 490 | 490 | required_device<beep_device> m_beeper; |
| 491 | 491 | optional_device<ram_device> m_ram; |
| 492 | 492 | required_device<gfxdecode_device> m_gfxdecode; |
| r242318 | r242319 | |
| 508 | 508 | UINT8 m_txt_scroll_reg[8]; |
| 509 | 509 | UINT8 m_pal_clut[4]; |
| 510 | 510 | |
| 511 | | UINT8 *m_tvram; |
| 511 | UINT16 *m_tvram; |
| 512 | 512 | |
| 513 | 513 | UINT16 m_font_addr; |
| 514 | 514 | UINT8 m_font_line; |
| r242318 | r242319 | |
| 542 | 542 | UINT8 tile[4], tile_index; |
| 543 | 543 | }m_grcg; |
| 544 | 544 | |
| 545 | struct { |
| 546 | UINT16 regs[8]; |
| 547 | UINT16 pat[4]; |
| 548 | UINT16 src[4]; |
| 549 | INT16 count; |
| 550 | UINT16 leftover[4]; |
| 551 | bool first; |
| 552 | } m_egc; |
| 553 | |
| 545 | 554 | /* PC9821 specific */ |
| 546 | 555 | UINT8 m_sdip[24], m_sdip_bank; |
| 547 | 556 | UINT8 m_pc9821_window_bank; |
| r242318 | r242319 | |
| 557 | 566 | DECLARE_WRITE8_MEMBER(txt_scrl_w); |
| 558 | 567 | DECLARE_READ8_MEMBER(grcg_r); |
| 559 | 568 | DECLARE_WRITE8_MEMBER(grcg_w); |
| 569 | DECLARE_WRITE16_MEMBER(egc_w); |
| 560 | 570 | DECLARE_READ8_MEMBER(pc9801_a0_r); |
| 561 | 571 | DECLARE_WRITE8_MEMBER(pc9801_a0_w); |
| 562 | 572 | DECLARE_READ8_MEMBER(pc9801_fdc_2hd_r); |
| 563 | 573 | DECLARE_WRITE8_MEMBER(pc9801_fdc_2hd_w); |
| 564 | 574 | DECLARE_READ8_MEMBER(pc9801_fdc_2dd_r); |
| 565 | 575 | DECLARE_WRITE8_MEMBER(pc9801_fdc_2dd_w); |
| 566 | | DECLARE_READ8_MEMBER(tvram_r); |
| 567 | | DECLARE_WRITE8_MEMBER(tvram_w); |
| 576 | DECLARE_READ16_MEMBER(tvram_r); |
| 577 | DECLARE_WRITE16_MEMBER(tvram_w); |
| 568 | 578 | DECLARE_READ8_MEMBER(gvram_r); |
| 569 | 579 | DECLARE_WRITE8_MEMBER(gvram_w); |
| 570 | 580 | DECLARE_WRITE8_MEMBER(pc9801rs_mouse_freq_w); |
| 571 | 581 | DECLARE_CUSTOM_INPUT_MEMBER(system_type_r); |
| 572 | | DECLARE_READ8_MEMBER(grcg_gvram_r); |
| 573 | | DECLARE_WRITE8_MEMBER(grcg_gvram_w); |
| 574 | | DECLARE_READ8_MEMBER(grcg_gvram0_r); |
| 575 | | DECLARE_WRITE8_MEMBER(grcg_gvram0_w); |
| 576 | | DECLARE_READ8_MEMBER(upd7220_grcg_r); |
| 577 | | DECLARE_WRITE8_MEMBER(upd7220_grcg_w); |
| 582 | DECLARE_READ16_MEMBER(grcg_gvram_r); |
| 583 | DECLARE_WRITE16_MEMBER(grcg_gvram_w); |
| 584 | DECLARE_READ16_MEMBER(grcg_gvram0_r); |
| 585 | DECLARE_WRITE16_MEMBER(grcg_gvram0_w); |
| 586 | DECLARE_READ16_MEMBER(upd7220_grcg_r); |
| 587 | DECLARE_WRITE16_MEMBER(upd7220_grcg_w); |
| 588 | void egc_blit_w(UINT32 offset, UINT16 data, UINT16 mem_mask); |
| 589 | UINT16 egc_blit_r(UINT32 offset, UINT16 mem_mask); |
| 590 | inline UINT16 egc_do_partial_op(int plane, UINT16 src, UINT16 pat, UINT16 dst); |
| 578 | 591 | UINT32 pc9801_286_a20(bool state); |
| 579 | 592 | |
| 580 | 593 | DECLARE_READ8_MEMBER(ide_hack_r); |
| r242318 | r242319 | |
| 717 | 730 | |
| 718 | 731 | void pc9801_state::video_start() |
| 719 | 732 | { |
| 720 | | m_tvram = auto_alloc_array(machine(), UINT8, 0x4000); |
| 733 | m_tvram = auto_alloc_array(machine(), UINT16, 0x2000); |
| 721 | 734 | |
| 722 | 735 | // find memory regions |
| 723 | 736 | m_char_rom = memregion("chargen")->base(); |
| r242318 | r242319 | |
| 753 | 766 | |
| 754 | 767 | if(m_ex_video_ff[ANALOG_256_MODE]) |
| 755 | 768 | { |
| 756 | | for(xi=0;xi<8;xi++) |
| 769 | for(xi=0;xi<16;xi++) |
| 757 | 770 | { |
| 758 | 771 | res_x = x + xi; |
| 759 | 772 | res_y = y; |
| r242318 | r242319 | |
| 761 | 774 | if(!m_screen->visible_area().contains(res_x, res_y*2+0)) |
| 762 | 775 | return; |
| 763 | 776 | |
| 764 | | pen = m_ext_gvram[(address*8+xi)+(m_vram_disp*0x40000)]; |
| 777 | pen = m_ext_gvram[((address*16+xi)+(m_vram_disp*0x40000)) >> 1]; |
| 765 | 778 | |
| 766 | 779 | bitmap.pix32(res_y*2+0, res_x) = palette[pen + 0x20]; |
| 767 | 780 | if(m_screen->visible_area().contains(res_x, res_y*2+1)) |
| r242318 | r242319 | |
| 770 | 783 | } |
| 771 | 784 | else |
| 772 | 785 | { |
| 773 | | for(xi=0;xi<8;xi++) |
| 786 | for(xi=0;xi<16;xi++) |
| 774 | 787 | { |
| 775 | 788 | res_x = x + xi; |
| 776 | 789 | res_y = y; |
| 777 | 790 | |
| 778 | | pen = ((m_video_ram_2[(address & 0x7fff) + (0x08000) + (m_vram_disp*0x20000)] >> (7-xi)) & 1) ? 1 : 0; |
| 779 | | pen|= ((m_video_ram_2[(address & 0x7fff) + (0x10000) + (m_vram_disp*0x20000)] >> (7-xi)) & 1) ? 2 : 0; |
| 780 | | pen|= ((m_video_ram_2[(address & 0x7fff) + (0x18000) + (m_vram_disp*0x20000)] >> (7-xi)) & 1) ? 4 : 0; |
| 791 | pen = ((m_video_ram_2[((address & 0x7fff) + (0x08000) + (m_vram_disp*0x20000)) >> 1] >> xi) & 1) ? 1 : 0; |
| 792 | pen|= ((m_video_ram_2[((address & 0x7fff) + (0x10000) + (m_vram_disp*0x20000)) >> 1] >> xi) & 1) ? 2 : 0; |
| 793 | pen|= ((m_video_ram_2[((address & 0x7fff) + (0x18000) + (m_vram_disp*0x20000)) >> 1] >> xi) & 1) ? 4 : 0; |
| 781 | 794 | if(m_ex_video_ff[ANALOG_16_MODE]) |
| 782 | | pen|= ((m_video_ram_2[(address & 0x7fff) + (0) + (m_vram_disp*0x20000)] >> (7-xi)) & 1) ? 8 : 0; |
| 795 | pen|= ((m_video_ram_2[((address & 0x7fff) + (0) + (m_vram_disp*0x20000)) >> 1] >> xi) & 1) ? 8 : 0; |
| 783 | 796 | |
| 784 | 797 | if(interlace_on) |
| 785 | 798 | { |
| r242318 | r242319 | |
| 829 | 842 | kanji_sel = 0; |
| 830 | 843 | kanji_lr = 0; |
| 831 | 844 | |
| 832 | | tile = m_video_ram_1[(tile_addr*2) & 0x1fff] & 0xff; |
| 833 | | knj_tile = m_video_ram_1[(tile_addr*2+1) & 0x1fff] & 0xff; |
| 845 | tile = m_video_ram_1[tile_addr & 0xfff] & 0xff; |
| 846 | knj_tile = m_video_ram_1[tile_addr & 0xfff] >> 8; |
| 834 | 847 | if(knj_tile) |
| 835 | 848 | { |
| 836 | 849 | /* Note: bit 7 doesn't really count, if a kanji is enabled then the successive tile is always the second part of it. |
| r242318 | r242319 | |
| 851 | 864 | else |
| 852 | 865 | x_step = 1; |
| 853 | 866 | |
| 854 | | attr = (m_video_ram_1[(tile_addr*2 & 0x1fff) | 0x2000] & 0xff); |
| 867 | attr = (m_video_ram_1[(tile_addr & 0xfff) | 0x1000] & 0xff); |
| 855 | 868 | |
| 856 | 869 | secret = (attr & 1) ^ 1; |
| 857 | 870 | blink = attr & 2; |
| r242318 | r242319 | |
| 1282 | 1295 | |
| 1283 | 1296 | |
| 1284 | 1297 | /* TODO: banking? */ |
| 1285 | | READ8_MEMBER(pc9801_state::tvram_r) |
| 1298 | READ16_MEMBER(pc9801_state::tvram_r) |
| 1286 | 1299 | { |
| 1287 | | UINT8 res; |
| 1300 | UINT16 res; |
| 1288 | 1301 | |
| 1289 | | if((offset & 0x2000) && offset & 1) |
| 1290 | | return 0xff; |
| 1302 | if((offset & 0x1000) && (mem_mask == 0xff00)) |
| 1303 | return 0xffff; |
| 1291 | 1304 | |
| 1292 | 1305 | res = m_tvram[offset]; |
| 1293 | 1306 | |
| 1294 | 1307 | return res; |
| 1295 | 1308 | } |
| 1296 | 1309 | |
| 1297 | | WRITE8_MEMBER(pc9801_state::tvram_w) |
| 1310 | WRITE16_MEMBER(pc9801_state::tvram_w) |
| 1298 | 1311 | { |
| 1299 | | if(offset < (0x3fe2) || m_video_ff[MEMSW_REG]) |
| 1300 | | m_tvram[offset] = data; |
| 1312 | if(offset < (0x3fe2>>1) || m_video_ff[MEMSW_REG]) |
| 1313 | COMBINE_DATA(&m_tvram[offset]); |
| 1301 | 1314 | |
| 1302 | | m_video_ram_1[offset] = data; //TODO: check me |
| 1315 | COMBINE_DATA(&m_video_ram_1[offset]); //TODO: check me |
| 1303 | 1316 | } |
| 1304 | 1317 | |
| 1305 | 1318 | /* +0x8000 is trusted (bank 0 is actually used by 16 colors mode) */ |
| 1306 | 1319 | READ8_MEMBER(pc9801_state::gvram_r) |
| 1307 | 1320 | { |
| 1308 | | return m_video_ram_2[offset+0x08000+m_vram_bank*0x20000]; |
| 1321 | return BITSWAP8(m_video_ram_2[(offset>>1)+0x04000+m_vram_bank*0x10000] >> ((offset & 1) << 3),0,1,2,3,4,5,6,7); |
| 1309 | 1322 | } |
| 1310 | 1323 | |
| 1311 | 1324 | WRITE8_MEMBER(pc9801_state::gvram_w) |
| 1312 | 1325 | { |
| 1313 | | m_video_ram_2[offset+0x08000+m_vram_bank*0x20000] = data; |
| 1326 | UINT16 ram = m_video_ram_2[(offset>>1)+0x04000+m_vram_bank*0x10000]; |
| 1327 | int mask = (offset & 1) << 3; |
| 1328 | data = BITSWAP8(data,0,1,2,3,4,5,6,7); |
| 1329 | m_video_ram_2[(offset>>1)+0x04000+m_vram_bank*0x10000] = (ram & (0xff00 >> mask)) | (data << mask); |
| 1314 | 1330 | } |
| 1315 | 1331 | |
| 1316 | | READ8_MEMBER(pc9801_state::upd7220_grcg_r) |
| 1332 | inline UINT16 pc9801_state::egc_do_partial_op(int plane, UINT16 src, UINT16 pat, UINT16 dst) |
| 1317 | 1333 | { |
| 1318 | | UINT8 res = 0; |
| 1334 | UINT16 out = 0; |
| 1335 | int src_off, dst_off; |
| 1336 | UINT16 src_tmp = src; |
| 1319 | 1337 | |
| 1320 | | if(!(m_grcg.mode & 0x80)) |
| 1338 | if(m_egc.regs[6] & 0x1000) |
| 1339 | { |
| 1340 | src_off = 16 - (m_egc.regs[6] & 0xf); |
| 1341 | dst_off = 16 - ((m_egc.regs[6] >> 4) & 0xf); |
| 1342 | } |
| 1343 | else |
| 1344 | { |
| 1345 | src_off = m_egc.regs[6] & 0xf; |
| 1346 | dst_off = (m_egc.regs[6] >> 4) & 0xf; |
| 1347 | } |
| 1348 | |
| 1349 | if(src_off < dst_off) |
| 1350 | { |
| 1351 | src = src_tmp << (dst_off - src_off); |
| 1352 | src |= m_egc.leftover[plane]; |
| 1353 | m_egc.leftover[plane] = src_tmp >> (16 - (dst_off - src_off)); |
| 1354 | } |
| 1355 | else |
| 1356 | { |
| 1357 | src = src_tmp >> (src_off - dst_off); |
| 1358 | src |= m_egc.leftover[plane] >> dst_off; |
| 1359 | m_egc.leftover[plane] = src_tmp << (16 - (src_off - dst_off)); |
| 1360 | } |
| 1361 | |
| 1362 | for(int i = 7; i >= 0; i--) |
| 1363 | { |
| 1364 | if(BIT(m_egc.regs[2], i)) |
| 1365 | out |= src & pat & dst; |
| 1366 | pat = ~pat; |
| 1367 | dst = (!(i & 1)) ? ~dst : dst; |
| 1368 | src = (i == 4) ? ~src : src; |
| 1369 | } |
| 1370 | return out; |
| 1371 | } |
| 1372 | |
| 1373 | void pc9801_state::egc_blit_w(UINT32 offset, UINT16 data, UINT16 mem_mask) |
| 1374 | { |
| 1375 | UINT16 mask = m_egc.regs[4] & mem_mask, out = 0; |
| 1376 | bool dir = !(m_egc.regs[6] & 0x1000); |
| 1377 | int dst_off = (m_egc.regs[6] >> 4) & 0xf; |
| 1378 | offset &= 0x3fff; |
| 1379 | |
| 1380 | // mask off the bits past the end of the blit |
| 1381 | if(m_egc.count < 16) |
| 1382 | mask &= dir ? ((1 << (m_egc.count + 1)) - 1) : ~((1 << (15 - m_egc.count)) - 1); |
| 1383 | |
| 1384 | // mask off the bits before the start |
| 1385 | if(m_egc.first) |
| 1386 | { |
| 1387 | m_egc.leftover[0] = m_egc.leftover[1] = m_egc.leftover[2] = m_egc.leftover[3] = 0; |
| 1388 | mask &= dir ? ~((1 << (15 - dst_off)) - 1) : ((1 << (dst_off + 1)) - 1); |
| 1389 | } |
| 1390 | |
| 1391 | for(int i = 0; i < 4; i++) |
| 1392 | { |
| 1393 | if(!BIT(m_egc.regs[0], i)) |
| 1394 | { |
| 1395 | UINT16 src = m_egc.src[i] & mem_mask, pat = m_egc.pat[i]; |
| 1396 | if(BIT(m_egc.regs[2], 10)) |
| 1397 | src = data; |
| 1398 | |
| 1399 | if((m_egc.regs[2] & 0x300) == 0x200) |
| 1400 | pat = m_video_ram_2[offset + (((i + 1) & 3) * 0x4000)]; |
| 1401 | |
| 1402 | switch((m_egc.regs[2] >> 11) & 3) |
| 1403 | { |
| 1404 | case 0: |
| 1405 | out = data; |
| 1406 | break; |
| 1407 | case 1: |
| 1408 | if(mem_mask == 0x00ff) |
| 1409 | src = src | src << 8; |
| 1410 | else if(mem_mask == 0xff00) |
| 1411 | src = src | src >> 8; |
| 1412 | |
| 1413 | out = egc_do_partial_op(i, src, pat, m_video_ram_2[offset + (((i + 1) & 3) * 0x4000)]); |
| 1414 | break; |
| 1415 | case 2: |
| 1416 | out = pat; |
| 1417 | break; |
| 1418 | case 3: |
| 1419 | logerror("Invalid EGC blit operation\n"); |
| 1420 | return; |
| 1421 | } |
| 1422 | |
| 1423 | m_video_ram_2[offset + (((i + 1) & 3) * 0x4000)] &= ~mask; |
| 1424 | m_video_ram_2[offset + (((i + 1) & 3) * 0x4000)] |= out & mask; |
| 1425 | } |
| 1426 | } |
| 1427 | if(mem_mask != 0xffff) |
| 1428 | { |
| 1429 | dst_off &= 7; |
| 1430 | if(m_egc.first) |
| 1431 | m_egc.count -= dir ? 7 - dst_off : dst_off; |
| 1432 | else |
| 1433 | m_egc.count -= 8; |
| 1434 | } |
| 1435 | else |
| 1436 | { |
| 1437 | if(m_egc.first) |
| 1438 | m_egc.count -= dir ? 15 - dst_off : dst_off; |
| 1439 | else |
| 1440 | m_egc.count -= 16; |
| 1441 | } |
| 1442 | |
| 1443 | m_egc.first = false; |
| 1444 | |
| 1445 | if(m_egc.count <= 0) |
| 1446 | { |
| 1447 | m_egc.first = true; |
| 1448 | m_egc.count = (m_egc.regs[7] & 0xfff) + 1; |
| 1449 | } |
| 1450 | } |
| 1451 | |
| 1452 | UINT16 pc9801_state::egc_blit_r(UINT32 offset, UINT16 mem_mask) |
| 1453 | { |
| 1454 | UINT16 plane_off = offset & 0x3fff; |
| 1455 | if((m_egc.regs[2] & 0x300) == 0x100) |
| 1456 | { |
| 1457 | m_egc.pat[0] = m_video_ram_2[plane_off + 0x4000]; |
| 1458 | m_egc.pat[1] = m_video_ram_2[plane_off + (0x4000 * 2)]; |
| 1459 | m_egc.pat[2] = m_video_ram_2[plane_off + (0x4000 * 3)]; |
| 1460 | m_egc.pat[3] = m_video_ram_2[plane_off]; |
| 1461 | } |
| 1462 | if(!BIT(m_egc.regs[2], 10)) |
| 1463 | { |
| 1464 | m_egc.src[0] = m_video_ram_2[plane_off + 0x4000]; |
| 1465 | m_egc.src[1] = m_video_ram_2[plane_off + (0x4000 * 2)]; |
| 1466 | m_egc.src[2] = m_video_ram_2[plane_off + (0x4000 * 3)]; |
| 1467 | m_egc.src[3] = m_video_ram_2[plane_off]; |
| 1468 | } |
| 1469 | if(BIT(m_egc.regs[2], 13)) |
| 1470 | return m_video_ram_2[offset]; |
| 1471 | else |
| 1472 | return m_video_ram_2[plane_off + (((m_egc.regs[1] >> 8) + 1) & 3) * 0x4000]; |
| 1473 | } |
| 1474 | |
| 1475 | READ16_MEMBER(pc9801_state::upd7220_grcg_r) |
| 1476 | { |
| 1477 | UINT16 res = 0; |
| 1478 | |
| 1479 | if(!(m_grcg.mode & 0x80) || space.debugger_access()) |
| 1321 | 1480 | res = m_video_ram_2[offset]; |
| 1481 | else if(m_ex_video_ff[2]) |
| 1482 | res = egc_blit_r(offset, mem_mask); |
| 1322 | 1483 | else if(!(m_grcg.mode & 0x40)) |
| 1323 | 1484 | { |
| 1324 | 1485 | int i; |
| 1325 | 1486 | |
| 1326 | | offset &= ~(3 << 15); |
| 1487 | offset &= 0x3fff; |
| 1327 | 1488 | res = 0; |
| 1328 | 1489 | for(i=0;i<4;i++) |
| 1329 | 1490 | { |
| 1330 | 1491 | if((m_grcg.mode & (1 << i)) == 0) |
| 1331 | | res |= m_video_ram_2[offset | (((i + 1) & 3) * 0x8000)] ^ m_grcg.tile[i]; |
| 1492 | { |
| 1493 | res |= m_video_ram_2[offset | (((i + 1) & 3) * 0x4000)] ^ (m_grcg.tile[i] | m_grcg.tile[i] << 8); |
| 1494 | } |
| 1332 | 1495 | } |
| 1333 | 1496 | |
| 1334 | | res ^= 0xff; |
| 1497 | res ^= 0xffff; |
| 1335 | 1498 | } |
| 1336 | 1499 | |
| 1337 | 1500 | return res; |
| 1338 | 1501 | } |
| 1339 | 1502 | |
| 1340 | | WRITE8_MEMBER(pc9801_state::upd7220_grcg_w) |
| 1503 | WRITE16_MEMBER(pc9801_state::upd7220_grcg_w) |
| 1341 | 1504 | { |
| 1342 | | if((m_grcg.mode & 0x80) == 0) |
| 1343 | | m_video_ram_2[offset] = data; |
| 1505 | if(!(m_grcg.mode & 0x80)) |
| 1506 | COMBINE_DATA(&m_video_ram_2[offset]); |
| 1507 | else if(m_ex_video_ff[2]) |
| 1508 | egc_blit_w(offset, data, mem_mask); |
| 1344 | 1509 | else |
| 1345 | 1510 | { |
| 1346 | 1511 | int i; |
| 1347 | | offset &= ~(3 << 15); |
| 1512 | UINT8 *vram = (UINT8 *)m_video_ram_2.target(); |
| 1513 | offset = (offset << 1) & 0x7fff; |
| 1348 | 1514 | |
| 1349 | 1515 | if(m_grcg.mode & 0x40) // RMW |
| 1350 | 1516 | { |
| r242318 | r242319 | |
| 1352 | 1518 | { |
| 1353 | 1519 | if((m_grcg.mode & (1 << i)) == 0) |
| 1354 | 1520 | { |
| 1355 | | m_video_ram_2[offset | (((i + 1) & 3) * 0x8000)] &= ~data; |
| 1356 | | m_video_ram_2[offset | (((i + 1) & 3) * 0x8000)] |= m_grcg.tile[i] & data; |
| 1521 | if(mem_mask & 0xff) |
| 1522 | { |
| 1523 | vram[offset | (((i + 1) & 3) * 0x8000)] &= ~data; |
| 1524 | vram[offset | (((i + 1) & 3) * 0x8000)] |= m_grcg.tile[i] & data; |
| 1525 | } |
| 1526 | if(mem_mask & 0xff00) |
| 1527 | { |
| 1528 | vram[offset | (((i + 1) & 3) * 0x8000) | 1] &= ~(data >> 8); |
| 1529 | vram[offset | (((i + 1) & 3) * 0x8000) | 1] |= m_grcg.tile[i] & (data >> 8); |
| 1530 | } |
| 1357 | 1531 | } |
| 1358 | 1532 | } |
| 1359 | 1533 | } |
| r242318 | r242319 | |
| 1363 | 1537 | { |
| 1364 | 1538 | if((m_grcg.mode & (1 << i)) == 0) |
| 1365 | 1539 | { |
| 1366 | | m_video_ram_2[offset | (((i + 1) & 3) * 0x8000)] = m_grcg.tile[i]; |
| 1540 | if(mem_mask & 0xff) |
| 1541 | vram[offset | (((i + 1) & 3) * 0x8000)] = m_grcg.tile[i]; |
| 1542 | if(mem_mask & 0xff00) |
| 1543 | vram[offset | (((i + 1) & 3) * 0x8000) | 1] = m_grcg.tile[i]; |
| 1367 | 1544 | } |
| 1368 | 1545 | } |
| 1369 | 1546 | } |
| r242318 | r242319 | |
| 1494 | 1671 | |
| 1495 | 1672 | static ADDRESS_MAP_START( pc9801_map, AS_PROGRAM, 16, pc9801_state ) |
| 1496 | 1673 | AM_RANGE(0x00000, 0x9ffff) AM_RAM //work RAM |
| 1497 | | AM_RANGE(0xa0000, 0xa3fff) AM_READWRITE8(tvram_r,tvram_w,0xffff) //TVRAM |
| 1674 | AM_RANGE(0xa0000, 0xa3fff) AM_READWRITE(tvram_r,tvram_w) //TVRAM |
| 1498 | 1675 | AM_RANGE(0xa8000, 0xbffff) AM_READWRITE8(gvram_r,gvram_w,0xffff) //bitmap VRAM |
| 1499 | 1676 | AM_RANGE(0xcc000, 0xcdfff) AM_ROM AM_REGION("sound_bios",0) //sound BIOS |
| 1500 | 1677 | AM_RANGE(0xd6000, 0xd6fff) AM_ROM AM_REGION("fdc_bios_2dd",0) //floppy BIOS 2dd |
| r242318 | r242319 | |
| 1677 | 1854 | txt_scrl_w(space,offset,data); |
| 1678 | 1855 | } |
| 1679 | 1856 | |
| 1857 | WRITE16_MEMBER(pc9801_state::egc_w) |
| 1858 | { |
| 1859 | if(!m_ex_video_ff[2]) |
| 1860 | return; |
| 1861 | |
| 1862 | COMBINE_DATA(&m_egc.regs[offset]); |
| 1863 | switch(offset) |
| 1864 | { |
| 1865 | case 1: |
| 1866 | case 3: |
| 1867 | case 5: |
| 1868 | { |
| 1869 | UINT8 color = 0; |
| 1870 | switch((m_egc.regs[1] >> 13) & 3) |
| 1871 | { |
| 1872 | case 1: |
| 1873 | //back color |
| 1874 | color = m_egc.regs[5]; |
| 1875 | break; |
| 1876 | case 2: |
| 1877 | //fore color |
| 1878 | color = m_egc.regs[3]; |
| 1879 | break; |
| 1880 | default: |
| 1881 | return; |
| 1882 | } |
| 1883 | m_egc.pat[0] = (color & 1) ? 0xffff : 0; |
| 1884 | m_egc.pat[1] = (color & 2) ? 0xffff : 0; |
| 1885 | m_egc.pat[2] = (color & 4) ? 0xffff : 0; |
| 1886 | m_egc.pat[3] = (color & 8) ? 0xffff : 0; |
| 1887 | break; |
| 1888 | } |
| 1889 | case 6: |
| 1890 | case 7: |
| 1891 | m_egc.count = (m_egc.regs[7] & 0xfff) + 1; |
| 1892 | m_egc.first = true; |
| 1893 | break; |
| 1894 | } |
| 1895 | } |
| 1896 | |
| 1680 | 1897 | READ8_MEMBER(pc9801_state::pc9810rs_fdc_ctrl_r) |
| 1681 | 1898 | { |
| 1682 | 1899 | return (m_fdc_ctrl & 3) | 0xf0 | 8 | 4; |
| r242318 | r242319 | |
| 1888 | 2105 | ((offset >= 4) ? m_pic2 : m_pic1)->write(space, offset & 3, data); |
| 1889 | 2106 | } |
| 1890 | 2107 | |
| 1891 | | READ8_MEMBER(pc9801_state::grcg_gvram_r) |
| 2108 | READ16_MEMBER(pc9801_state::grcg_gvram_r) |
| 1892 | 2109 | { |
| 1893 | | return upd7220_grcg_r(space, (offset + 0x8000) | (m_vram_bank << 17), mem_mask); |
| 2110 | UINT16 ret = upd7220_grcg_r(space, (offset + 0x4000) | (m_vram_bank << 16), mem_mask); |
| 2111 | return BITSWAP16(ret,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7); |
| 1894 | 2112 | } |
| 1895 | 2113 | |
| 1896 | | WRITE8_MEMBER(pc9801_state::grcg_gvram_w) |
| 2114 | WRITE16_MEMBER(pc9801_state::grcg_gvram_w) |
| 1897 | 2115 | { |
| 1898 | | upd7220_grcg_w(space, (offset + 0x8000) | (m_vram_bank << 17), data, mem_mask); |
| 2116 | data = BITSWAP16(data,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7); |
| 2117 | upd7220_grcg_w(space, (offset + 0x4000) | (m_vram_bank << 16), data, mem_mask); |
| 1899 | 2118 | } |
| 1900 | 2119 | |
| 1901 | | READ8_MEMBER(pc9801_state::grcg_gvram0_r) |
| 2120 | READ16_MEMBER(pc9801_state::grcg_gvram0_r) |
| 1902 | 2121 | { |
| 1903 | | return upd7220_grcg_r(space, offset | (m_vram_bank << 17), mem_mask); |
| 2122 | UINT16 ret = upd7220_grcg_r(space, offset | (m_vram_bank << 16), mem_mask); |
| 2123 | return BITSWAP16(ret,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7); |
| 1904 | 2124 | } |
| 1905 | 2125 | |
| 1906 | | WRITE8_MEMBER(pc9801_state::grcg_gvram0_w) |
| 2126 | WRITE16_MEMBER(pc9801_state::grcg_gvram0_w) |
| 1907 | 2127 | { |
| 1908 | | upd7220_grcg_w(space, offset | (m_vram_bank << 17), data, mem_mask); |
| 2128 | data = BITSWAP16(data,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7); |
| 2129 | upd7220_grcg_w(space, offset | (m_vram_bank << 16), data, mem_mask); |
| 1909 | 2130 | } |
| 1910 | 2131 | |
| 1911 | 2132 | static ADDRESS_MAP_START( pc9801ux_map, AS_PROGRAM, 16, pc9801_state ) |
| 1912 | 2133 | AM_RANGE(0x000000, 0x09ffff) AM_RAMBANK("wram") |
| 1913 | | AM_RANGE(0x0a0000, 0x0a3fff) AM_READWRITE8(tvram_r, tvram_w, 0xffff) |
| 2134 | AM_RANGE(0x0a0000, 0x0a3fff) AM_READWRITE(tvram_r, tvram_w) |
| 1914 | 2135 | AM_RANGE(0x0a4000, 0x0a4fff) AM_READWRITE8(pc9801rs_knjram_r, pc9801rs_knjram_w, 0xffff) |
| 1915 | | AM_RANGE(0x0a8000, 0x0bffff) AM_READWRITE8(grcg_gvram_r, grcg_gvram_w, 0xffff) |
| 1916 | | AM_RANGE(0x0e0000, 0x0e7fff) AM_READWRITE8(grcg_gvram0_r,grcg_gvram0_w, 0xffff) |
| 2136 | AM_RANGE(0x0a8000, 0x0bffff) AM_READWRITE(grcg_gvram_r, grcg_gvram_w) |
| 2137 | AM_RANGE(0x0e0000, 0x0e7fff) AM_READWRITE(grcg_gvram0_r,grcg_gvram0_w) |
| 1917 | 2138 | AM_RANGE(0x0e0000, 0x0fffff) AM_READ8(pc9801rs_ipl_r, 0xffff) |
| 1918 | 2139 | ADDRESS_MAP_END |
| 1919 | 2140 | |
| r242318 | r242319 | |
| 1930 | 2151 | AM_RANGE(0x00f0, 0x00ff) AM_READWRITE8(a20_ctrl_r, a20_ctrl_w, 0x00ff) |
| 1931 | 2152 | AM_RANGE(0x0438, 0x043b) AM_READWRITE8(pc9801rs_access_ctrl_r,pc9801rs_access_ctrl_w,0xffff) |
| 1932 | 2153 | AM_RANGE(0x043c, 0x043f) AM_WRITE8(pc9801rs_bank_w, 0xffff) //ROM/RAM bank |
| 2154 | AM_RANGE(0x04a0, 0x04af) AM_WRITE(egc_w) |
| 1933 | 2155 | AM_RANGE(0x3fd8, 0x3fdf) AM_DEVREADWRITE8("pit8253", pit8253_device, read, write, 0xff00) |
| 1934 | 2156 | // AM_RANGE(0xa460, 0xa463) AM_READWRITE8(pc9801_ext_opna_r, pc9801_ext_opna_w, 0xffff) |
| 1935 | 2157 | AM_IMPORT_FROM(pc9801_io) |
| r242318 | r242319 | |
| 2138 | 2360 | static ADDRESS_MAP_START( pc9821_map, AS_PROGRAM, 32, pc9801_state ) |
| 2139 | 2361 | AM_RANGE(0x00000000, 0x0009ffff) AM_RAMBANK("wram") |
| 2140 | 2362 | //AM_RANGE(0x00080000, 0x0009ffff) AM_READWRITE8(winram_r, winram_w, 0xffffffff) |
| 2141 | | AM_RANGE(0x000a0000, 0x000a3fff) AM_READWRITE8(tvram_r, tvram_w, 0xffffffff) |
| 2363 | AM_RANGE(0x000a0000, 0x000a3fff) AM_READWRITE16(tvram_r, tvram_w, 0xffffffff) |
| 2142 | 2364 | AM_RANGE(0x000a4000, 0x000a4fff) AM_READWRITE8(pc9801rs_knjram_r, pc9801rs_knjram_w, 0xffffffff) |
| 2143 | | AM_RANGE(0x000a8000, 0x000bffff) AM_READWRITE8(grcg_gvram_r, grcg_gvram_w, 0xffffffff) |
| 2365 | AM_RANGE(0x000a8000, 0x000bffff) AM_READWRITE16(grcg_gvram_r, grcg_gvram_w, 0xffffffff) |
| 2144 | 2366 | AM_RANGE(0x000cc000, 0x000cdfff) AM_ROM AM_REGION("sound_bios",0) //sound BIOS |
| 2145 | 2367 | AM_RANGE(0x000d8000, 0x000d9fff) AM_ROM AM_REGION("ide",0) |
| 2146 | 2368 | AM_RANGE(0x000da000, 0x000dbfff) AM_RAM // ide ram |
| 2147 | | AM_RANGE(0x000e0000, 0x000e7fff) AM_READWRITE8(grcg_gvram0_r,grcg_gvram0_w, 0xffffffff) |
| 2369 | AM_RANGE(0x000e0000, 0x000e7fff) AM_READWRITE16(grcg_gvram0_r,grcg_gvram0_w, 0xffffffff) |
| 2148 | 2370 | AM_RANGE(0x000e0000, 0x000fffff) AM_READ8(pc9801rs_ipl_r, 0xffffffff) |
| 2149 | 2371 | AM_RANGE(0x00f00000, 0x00f9ffff) AM_RAM AM_SHARE("ext_gvram") |
| 2150 | 2372 | AM_RANGE(0xffee0000, 0xffefffff) AM_READ8(pc9801rs_ipl_r, 0xffffffff) |
| r242318 | r242319 | |
| 2232 | 2454 | // AM_RANGE(0xfcd0, 0xfcd3) MIDI port, option F / <undefined> |
| 2233 | 2455 | ADDRESS_MAP_END |
| 2234 | 2456 | |
| 2235 | | static ADDRESS_MAP_START( upd7220_1_map, AS_0, 8, pc9801_state ) |
| 2457 | static ADDRESS_MAP_START( upd7220_1_map, AS_0, 16, pc9801_state ) |
| 2236 | 2458 | AM_RANGE(0x00000, 0x3ffff) AM_RAM AM_SHARE("video_ram_1") |
| 2237 | 2459 | ADDRESS_MAP_END |
| 2238 | 2460 | |
| 2239 | | static ADDRESS_MAP_START( upd7220_2_map, AS_0, 8, pc9801_state ) |
| 2461 | static ADDRESS_MAP_START( upd7220_2_map, AS_0, 16, pc9801_state ) |
| 2240 | 2462 | AM_RANGE(0x00000, 0x3ffff) AM_RAM AM_SHARE("video_ram_2") |
| 2241 | 2463 | ADDRESS_MAP_END |
| 2242 | 2464 | |
| 2243 | | static ADDRESS_MAP_START( upd7220_grcg_2_map, AS_0, 8, pc9801_state ) |
| 2465 | static ADDRESS_MAP_START( upd7220_grcg_2_map, AS_0, 16, pc9801_state ) |
| 2244 | 2466 | AM_RANGE(0x00000, 0x3ffff) AM_READWRITE(upd7220_grcg_r, upd7220_grcg_w) AM_SHARE("video_ram_2") |
| 2245 | 2467 | ADDRESS_MAP_END |
| 2246 | 2468 | |
| r242318 | r242319 | |
| 2784 | 3006 | |
| 2785 | 3007 | MACHINE_RESET_MEMBER(pc9801_state,pc9801_common) |
| 2786 | 3008 | { |
| 2787 | | memset(m_tvram, 0, sizeof(UINT8) * 0x4000); |
| 3009 | memset(m_tvram, 0, sizeof(UINT16) * 0x2000); |
| 2788 | 3010 | /* this looks like to be some kind of backup ram, system will boot with green colors otherwise */ |
| 2789 | 3011 | { |
| 2790 | 3012 | int i; |
| r242318 | r242319 | |
| 2795 | 3017 | }; |
| 2796 | 3018 | |
| 2797 | 3019 | for(i=0;i<0x10;i++) |
| 2798 | | m_tvram[(0x3fe0)+i*2] = default_memsw_data[i]; |
| 3020 | m_tvram[(0x3fe0>>1)+i] = default_memsw_data[i]; |
| 2799 | 3021 | } |
| 2800 | 3022 | |
| 2801 | 3023 | m_beeper->set_frequency(2400); |
| r242318 | r242319 | |
| 2805 | 3027 | m_mouse.control = 0xff; |
| 2806 | 3028 | m_mouse.freq_reg = 0; |
| 2807 | 3029 | m_mouse.freq_index = 0; |
| 3030 | memset(&m_egc, 0, sizeof(m_egc)); |
| 2808 | 3031 | } |
| 2809 | 3032 | |
| 2810 | 3033 | MACHINE_RESET_MEMBER(pc9801_state,pc9801f) |
| r242318 | r242319 | |
| 3161 | 3384 | ROM_IGNORE( 0x2000 ) \ |
| 3162 | 3385 | ROM_IGNORE( 0x2000 ) \ |
| 3163 | 3386 | ROM_IGNORE( 0x2000 ) \ |
| 3164 | | ROM_FILL( 0x0000, 0x2000, 0xcb ) |
| 3387 | // ROM_FILL( 0x0000, 0x2000, 0xcb ) |
| 3165 | 3388 | |
| 3166 | 3389 | // all of these are half size :/ |
| 3167 | 3390 | #define LOAD_KANJI_ROMS \ |