Previous 199869 Revisions Next

r21403 Saturday 23rd February, 2013 at 17:07:29 UTC by Angelo Salese
Almost there
[src/mame/drivers]coolridr.c

trunk/src/mame/drivers/coolridr.c
r21402r21403
379379      m_subcpu(*this,"sub"),
380380      m_soundcpu(*this,"soundcpu"),
381381      //m_dmac(*this, "i8237"),
382      m_h1_charram(*this, "h1_charram"),
383382      m_framebuffer_vram(*this, "fb_vram"),
384383      m_txt_vram(*this, "txt_vram"),
385384      m_sysh1_txt_blit(*this, "sysh1_txt_blit"),
r21402r21403
406405   required_device<cpu_device> m_soundcpu;
407406   //required_device<am9517a_device> m_dmac;
408407
409   required_shared_ptr<UINT32> m_h1_charram;
410408   required_shared_ptr<UINT32> m_framebuffer_vram;
411409   required_shared_ptr<UINT32> m_txt_vram;
412410   required_shared_ptr<UINT32> m_sysh1_txt_blit;
r21402r21403
471469   void sysh1_dma_transfer( address_space &space, UINT16 dma_index );
472470
473471   UINT8 *m_h1_vram;
472   UINT8 *m_h1_pcg;
474473
475474};
476475
r21402r21403
500499   machine().primary_screen->register_screen_bitmap(m_screen2_bitmap);
501500
502501   m_h1_vram = auto_alloc_array_clear(machine(), UINT8, VRAM_SIZE);
502   m_h1_pcg = auto_alloc_array_clear(machine(), UINT8, VRAM_SIZE);
503503
504504   save_pointer(NAME(m_h1_vram), VRAM_SIZE);
505   save_pointer(NAME(m_h1_pcg), VRAM_SIZE);
505506}
506507
507508// might be a page 'map / base' setup somewhere, but it's just used for ingame backgrounds
r21402r21403
511512UINT32 coolridr_state::screen_update_coolridr(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int which)
512513{
513514   /* planes seems to basically be at 0x8000 and 0x28000... */
514   gfx_element *gfx = machine().gfx[0];
515515   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;
519519   int scrollx;
520520   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;
521529
522530   scrollx = (m_framebuffer_vram[(0x9bac+which*0x40)/4] >> 16) & 0x7ff;
523531   scrolly = m_framebuffer_vram[(0x9bac+which*0x40)/4] & 0x3ff;
r21402r21403
525533   base_offset = which * 0x20000;
526534   m_color = which * 2;
527535
528   for (y=0;y<64;y++)
536   for(ydst=cliprect.min_y;ydst<=cliprect.max_y;ydst++)
529537   {
530      for (x=0;x<128;x++)
538      for(xdst=cliprect.min_x;xdst<=cliprect.max_x;xdst++)
531539      {
532         int tile;
533         int res_x,res_y;
534540         UINT16 cur_tile;
541         UINT16 dot_data;
535542
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;
540550
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];
542552
543553         tile = cur_tile & 0x07ff;
544554         color = m_color + ((cur_tile & 0x0800) >> 11) * 4;
545555
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];
550562      }
551563   }
552564
r21402r21403
15141526
15151527void coolridr_state::sysh1_dma_transfer( address_space &space, UINT16 dma_index )
15161528{
1517   UINT32 src,dst,size;
1529   UINT32 src = 0,dst = 0,size = 0;
15181530   UINT8 end_dma_mark;
15191531   UINT8 cmd;
15201532   UINT8 is_dma;
r21402r21403
15501562            if(dst & 0xfff00000)
15511563               printf("unk values to %02x dst %08x\n",cmd,dst);
15521564            dst &= 0x000fffff;
1553            dst |= 0x05800000;
1554            size*=2;
1555            is_dma = 2;
1565            is_dma = 3;
15561566            //printf("%08x %08x %08x %02x\n",src,dst,size,cmd);
15571567            dma_index+=0xc;
15581568            break;
r21402r21403
16141624         src+=4;
16151625      }
16161626   }
1627   else if(is_dma == 3)
1628   {
1629      UINT16 read_src;
16171630
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
16181642   }while(!end_dma_mark );
16191643}
16201644
r21402r21403
16301654   }
16311655}
16321656
1633WRITE32_MEMBER(coolridr_state::sysh1_char_w)
1634{
1635   COMBINE_DATA(&m_h1_charram[offset]);
16361657
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
16491658static ADDRESS_MAP_START( system_h1_map, AS_PROGRAM, 32, coolridr_state )
16501659   AM_RANGE(0x00000000, 0x001fffff) AM_ROM AM_SHARE("share1") AM_WRITENOP
16511660   AM_RANGE(0x01000000, 0x01ffffff) AM_ROM AM_REGION("gfx_data",0x0000000)
r21402r21403
16611670   AM_RANGE(0x04000018, 0x0400001b) AM_WRITE(sysh1_fb_mode_w)
16621671   AM_RANGE(0x0400001c, 0x0400001f) AM_WRITE(sysh1_fb_data_w)
16631672
1664   AM_RANGE(0x05800000, 0x058fffff) AM_RAM_WRITE(sysh1_char_w) AM_SHARE("h1_charram") //TODO: fake region
1665
16661673   AM_RANGE(0x06000000, 0x060fffff) AM_RAM AM_SHARE("sysh1_workrah")
16671674   AM_RANGE(0x20000000, 0x201fffff) AM_ROM AM_SHARE("share1")
16681675

Previous 199869 Revisions Next


© 1997-2024 The MAME Team