trunk/src/mame/drivers/coolridr.c
| r21402 | r21403 | |
| 379 | 379 | m_subcpu(*this,"sub"), |
| 380 | 380 | m_soundcpu(*this,"soundcpu"), |
| 381 | 381 | //m_dmac(*this, "i8237"), |
| 382 | | m_h1_charram(*this, "h1_charram"), |
| 383 | 382 | m_framebuffer_vram(*this, "fb_vram"), |
| 384 | 383 | m_txt_vram(*this, "txt_vram"), |
| 385 | 384 | m_sysh1_txt_blit(*this, "sysh1_txt_blit"), |
| r21402 | r21403 | |
| 406 | 405 | required_device<cpu_device> m_soundcpu; |
| 407 | 406 | //required_device<am9517a_device> m_dmac; |
| 408 | 407 | |
| 409 | | required_shared_ptr<UINT32> m_h1_charram; |
| 410 | 408 | required_shared_ptr<UINT32> m_framebuffer_vram; |
| 411 | 409 | required_shared_ptr<UINT32> m_txt_vram; |
| 412 | 410 | required_shared_ptr<UINT32> m_sysh1_txt_blit; |
| r21402 | r21403 | |
| 471 | 469 | void sysh1_dma_transfer( address_space &space, UINT16 dma_index ); |
| 472 | 470 | |
| 473 | 471 | UINT8 *m_h1_vram; |
| 472 | UINT8 *m_h1_pcg; |
| 474 | 473 | |
| 475 | 474 | }; |
| 476 | 475 | |
| r21402 | r21403 | |
| 500 | 499 | machine().primary_screen->register_screen_bitmap(m_screen2_bitmap); |
| 501 | 500 | |
| 502 | 501 | m_h1_vram = auto_alloc_array_clear(machine(), UINT8, VRAM_SIZE); |
| 502 | m_h1_pcg = auto_alloc_array_clear(machine(), UINT8, VRAM_SIZE); |
| 503 | 503 | |
| 504 | 504 | save_pointer(NAME(m_h1_vram), VRAM_SIZE); |
| 505 | save_pointer(NAME(m_h1_pcg), VRAM_SIZE); |
| 505 | 506 | } |
| 506 | 507 | |
| 507 | 508 | // might be a page 'map / base' setup somewhere, but it's just used for ingame backgrounds |
| r21402 | r21403 | |
| 511 | 512 | UINT32 coolridr_state::screen_update_coolridr(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int which) |
| 512 | 513 | { |
| 513 | 514 | /* planes seems to basically be at 0x8000 and 0x28000... */ |
| 514 | | gfx_element *gfx = machine().gfx[0]; |
| 515 | 515 | UINT32 base_offset; |
| 516 | | UINT32 tile_offset; |
| 517 | | int y,x; |
| 518 | | int color; |
| 516 | int xsrc,ysrc,ydst,xdst; |
| 517 | int xisrc,yisrc; |
| 518 | int tile,color; |
| 519 | 519 | int scrollx; |
| 520 | 520 | int scrolly; |
| 521 | #define xsize_mask 2048-1 |
| 522 | #define ysize_mask 1024-1 |
| 523 | #define xsize 128 |
| 524 | #define xi_size 16 |
| 525 | #define yi_size 16 |
| 526 | #define xi_mask xi_size-1 |
| 527 | #define yi_mask yi_size-1 |
| 528 | UINT32 src_offs,pcg_offs; |
| 521 | 529 | |
| 522 | 530 | scrollx = (m_framebuffer_vram[(0x9bac+which*0x40)/4] >> 16) & 0x7ff; |
| 523 | 531 | scrolly = m_framebuffer_vram[(0x9bac+which*0x40)/4] & 0x3ff; |
| r21402 | r21403 | |
| 525 | 533 | base_offset = which * 0x20000; |
| 526 | 534 | m_color = which * 2; |
| 527 | 535 | |
| 528 | | for (y=0;y<64;y++) |
| 536 | for(ydst=cliprect.min_y;ydst<=cliprect.max_y;ydst++) |
| 529 | 537 | { |
| 530 | | for (x=0;x<128;x++) |
| 538 | for(xdst=cliprect.min_x;xdst<=cliprect.max_x;xdst++) |
| 531 | 539 | { |
| 532 | | int tile; |
| 533 | | int res_x,res_y; |
| 534 | 540 | UINT16 cur_tile; |
| 541 | UINT16 dot_data; |
| 535 | 542 | |
| 536 | | res_x = (x*16)-scrollx; |
| 537 | | res_y = (y*16)-scrolly; |
| 538 | | tile_offset = (x+y*128)*2; |
| 539 | | tile_offset+= base_offset; |
| 543 | xsrc = ((xdst + scrollx) >> 4) & (xsize_mask); |
| 544 | ysrc = ((ydst + scrolly) >> 4) & (ysize_mask); |
| 545 | xisrc = (xdst + scrollx) & (xi_mask); |
| 546 | yisrc = (ydst + scrolly) & (yi_mask); |
| 547 | src_offs = (xsrc + (ysrc*xsize)); |
| 548 | src_offs *= 2; |
| 549 | src_offs += base_offset; |
| 540 | 550 | |
| 541 | | cur_tile = (m_h1_vram[tile_offset]<<8)|m_h1_vram[tile_offset+1]; |
| 551 | cur_tile = (m_h1_vram[src_offs]<<8)|m_h1_vram[src_offs+1]; |
| 542 | 552 | |
| 543 | 553 | tile = cur_tile & 0x07ff; |
| 544 | 554 | color = m_color + ((cur_tile & 0x0800) >> 11) * 4; |
| 545 | 555 | |
| 546 | | drawgfx_opaque(bitmap,cliprect,gfx,tile,color,0,0,res_x,res_y); |
| 547 | | drawgfx_opaque(bitmap,cliprect,gfx,tile,color,0,0,res_x+2048,res_y); |
| 548 | | drawgfx_opaque(bitmap,cliprect,gfx,tile,color,0,0,res_x,res_y+1024); |
| 549 | | drawgfx_opaque(bitmap,cliprect,gfx,tile,color,0,0,res_x+2048,res_y+1024); |
| 556 | /* we have a tile number, fetch into the PCG RAM */ |
| 557 | pcg_offs = (xisrc+yisrc*xi_size)+tile*xi_size*yi_size; |
| 558 | dot_data = m_h1_pcg[pcg_offs] & 0xff; |
| 559 | dot_data+= color<<8; |
| 560 | |
| 561 | bitmap.pix32(ydst, xdst) = machine().pens[dot_data]; |
| 550 | 562 | } |
| 551 | 563 | } |
| 552 | 564 | |
| r21402 | r21403 | |
| 1514 | 1526 | |
| 1515 | 1527 | void coolridr_state::sysh1_dma_transfer( address_space &space, UINT16 dma_index ) |
| 1516 | 1528 | { |
| 1517 | | UINT32 src,dst,size; |
| 1529 | UINT32 src = 0,dst = 0,size = 0; |
| 1518 | 1530 | UINT8 end_dma_mark; |
| 1519 | 1531 | UINT8 cmd; |
| 1520 | 1532 | UINT8 is_dma; |
| r21402 | r21403 | |
| 1550 | 1562 | if(dst & 0xfff00000) |
| 1551 | 1563 | printf("unk values to %02x dst %08x\n",cmd,dst); |
| 1552 | 1564 | dst &= 0x000fffff; |
| 1553 | | dst |= 0x05800000; |
| 1554 | | size*=2; |
| 1555 | | is_dma = 2; |
| 1565 | is_dma = 3; |
| 1556 | 1566 | //printf("%08x %08x %08x %02x\n",src,dst,size,cmd); |
| 1557 | 1567 | dma_index+=0xc; |
| 1558 | 1568 | break; |
| r21402 | r21403 | |
| 1614 | 1624 | src+=4; |
| 1615 | 1625 | } |
| 1616 | 1626 | } |
| 1627 | else if(is_dma == 3) |
| 1628 | { |
| 1629 | UINT16 read_src; |
| 1617 | 1630 | |
| 1631 | for(int i=0;i<size;i+=2) |
| 1632 | { |
| 1633 | read_src = space.read_word(src); |
| 1634 | |
| 1635 | m_h1_pcg[dst] = read_src >> 8; |
| 1636 | m_h1_pcg[dst+1] = read_src & 0xff; |
| 1637 | dst+=2; |
| 1638 | src+=2; |
| 1639 | } |
| 1640 | } |
| 1641 | |
| 1618 | 1642 | }while(!end_dma_mark ); |
| 1619 | 1643 | } |
| 1620 | 1644 | |
| r21402 | r21403 | |
| 1630 | 1654 | } |
| 1631 | 1655 | } |
| 1632 | 1656 | |
| 1633 | | WRITE32_MEMBER(coolridr_state::sysh1_char_w) |
| 1634 | | { |
| 1635 | | COMBINE_DATA(&m_h1_charram[offset]); |
| 1636 | 1657 | |
| 1637 | | { |
| 1638 | | UINT8 *gfx = memregion("ram_gfx")->base(); |
| 1639 | | |
| 1640 | | gfx[offset*4+0] = (m_h1_charram[offset] & 0xff000000) >> 24; |
| 1641 | | gfx[offset*4+1] = (m_h1_charram[offset] & 0x00ff0000) >> 16; |
| 1642 | | gfx[offset*4+2] = (m_h1_charram[offset] & 0x0000ff00) >> 8; |
| 1643 | | gfx[offset*4+3] = (m_h1_charram[offset] & 0x000000ff) >> 0; |
| 1644 | | |
| 1645 | | machine().gfx[0]->mark_dirty(offset/64); //*4/256 |
| 1646 | | } |
| 1647 | | } |
| 1648 | | |
| 1649 | 1658 | static ADDRESS_MAP_START( system_h1_map, AS_PROGRAM, 32, coolridr_state ) |
| 1650 | 1659 | AM_RANGE(0x00000000, 0x001fffff) AM_ROM AM_SHARE("share1") AM_WRITENOP |
| 1651 | 1660 | AM_RANGE(0x01000000, 0x01ffffff) AM_ROM AM_REGION("gfx_data",0x0000000) |
| r21402 | r21403 | |
| 1661 | 1670 | AM_RANGE(0x04000018, 0x0400001b) AM_WRITE(sysh1_fb_mode_w) |
| 1662 | 1671 | AM_RANGE(0x0400001c, 0x0400001f) AM_WRITE(sysh1_fb_data_w) |
| 1663 | 1672 | |
| 1664 | | AM_RANGE(0x05800000, 0x058fffff) AM_RAM_WRITE(sysh1_char_w) AM_SHARE("h1_charram") //TODO: fake region |
| 1665 | | |
| 1666 | 1673 | AM_RANGE(0x06000000, 0x060fffff) AM_RAM AM_SHARE("sysh1_workrah") |
| 1667 | 1674 | AM_RANGE(0x20000000, 0x201fffff) AM_ROM AM_SHARE("share1") |
| 1668 | 1675 | |