Previous 199869 Revisions Next

r21401 Saturday 23rd February, 2013 at 16:33:14 UTC by Angelo Salese
Part one of tilemap rewrite
[src/mame/drivers]coolridr.c

trunk/src/mame/drivers/coolridr.c
r21400r21401
379379      m_subcpu(*this,"sub"),
380380      m_soundcpu(*this,"soundcpu"),
381381      //m_dmac(*this, "i8237"),
382      m_h1_vram(*this, "h1_vram"),
383382      m_h1_charram(*this, "h1_charram"),
384383      m_framebuffer_vram(*this, "fb_vram"),
385384      m_txt_vram(*this, "txt_vram"),
r21400r21401
402401   // store the blit params here
403402   UINT32 m_spriteblit[12];
404403
405
406
407
408
409
410
411
412
413
414
415404   required_device<cpu_device> m_maincpu;
416405   required_device<cpu_device> m_subcpu;
417406   required_device<cpu_device> m_soundcpu;
418407   //required_device<am9517a_device> m_dmac;
419408
420   required_shared_ptr<UINT32> m_h1_vram;
421409   required_shared_ptr<UINT32> m_h1_charram;
422410   required_shared_ptr<UINT32> m_framebuffer_vram;
423411   required_shared_ptr<UINT32> m_txt_vram;
r21400r21401
447435   DECLARE_WRITE32_MEMBER(sysh1_sound_dma_w);
448436   DECLARE_READ32_MEMBER(sysh1_ioga_r);
449437   DECLARE_WRITE32_MEMBER(sysh1_ioga_w);
438   DECLARE_READ32_MEMBER(sysh1_unk_blit_r);
450439   DECLARE_WRITE32_MEMBER(sysh1_unk_blit_w);
451440   DECLARE_WRITE32_MEMBER(sysh1_blit_mode_w);
452441   DECLARE_WRITE32_MEMBER(sysh1_blit_data_w);
r21400r21401
481470
482471   void sysh1_dma_transfer( address_space &space, UINT16 dma_index );
483472
473   UINT8 *m_h1_vram;
474
484475};
485476
486477#define PRINT_BLIT_STUFF \
487478   printf("type blit %08x %08x(%d, %03x) %08x(%02x, %03x) %08x(%06x) %08x(%08x, %d, %d, %d) %08x(%d,%d) %04x %04x %04x %04x %08x %08x %d %d\n", blit0, blit1_unused,b1mode,b1colorNumber, blit2_unused,b2tpen,b2colorNumber, blit3_unused,b3romoffset, blit4_unused, blit4, blit_flipy,blit_rotate, blit_flipx, blit5_unused, indirect_tile_enable, indirect_zoom_enable, vCellCount, hCellCount, vZoom, hZoom, blit10, textlookup, vPosition, hPosition); \
488479
489480
481
490482/* video */
491483
484#define VRAM_SIZE 0x100000
485
492486void coolridr_state::video_start()
493487{
494488   machine().primary_screen->register_screen_bitmap(m_temp_bitmap_sprites[0]);
r21400r21401
504498
505499   machine().primary_screen->register_screen_bitmap(m_screen1_bitmap);
506500   machine().primary_screen->register_screen_bitmap(m_screen2_bitmap);
501
502   m_h1_vram = auto_alloc_array_clear(machine(), UINT8, VRAM_SIZE);
503
504   save_pointer(NAME(m_h1_vram), VRAM_SIZE);
507505}
508506
509507// might be a page 'map / base' setup somewhere, but it's just used for ingame backgrounds
r21400r21401
520518   int scrollx;
521519   int scrolly;
522520
523   count = 0/4;
521   count = 0;
524522   m_color = 0;
525523
526524   if (which==1)
527525   {
528      count += 0x20000/4;
526      count += 0x20000;
529527//      color += 0x5e;
530528      m_color = 2;
531529   }
r21400r21401
541539   /* TODO: optimize! */
542540   for (y=0;y<64;y++)
543541   {
544      for (x=0;x<128;x+=2)
542      for (x=0;x<128;x++)
545543      {
546544         int tile;
547545         int res_x,res_y;
546         UINT16 cur_ptr;
548547
549         res_x = ((x+0)*16)-scrollx;
548         res_x = (x*16)-scrollx;
550549         res_y = (y*16)-scrolly;
551550
552         tile = (m_h1_vram[count] & 0x0fff0000) >> 16;
553         color = m_color + ((tile & 0x800) >> 11) * 4;
551         cur_ptr = (m_h1_vram[count]<<8)|m_h1_vram[count+1];
554552
555         drawgfx_opaque(bitmap,cliprect,gfx,tile & 0x7ff,color,0,0,res_x,res_y);
556         drawgfx_opaque(bitmap,cliprect,gfx,tile & 0x7ff,color,0,0,res_x+2048,res_y);
557         drawgfx_opaque(bitmap,cliprect,gfx,tile & 0x7ff,color,0,0,res_x,res_y+1024);
558         drawgfx_opaque(bitmap,cliprect,gfx,tile & 0x7ff,color,0,0,res_x+2048,res_y+1024);
553         tile = cur_ptr & 0x07ff;
554         color = m_color + ((cur_ptr & 0x0800) >> 11) * 4;
559555
560         res_x = ((x+1)*16)-scrollx;
561         res_y = (y*16)-scrolly;
556         drawgfx_opaque(bitmap,cliprect,gfx,tile,color,0,0,res_x,res_y);
557         drawgfx_opaque(bitmap,cliprect,gfx,tile,color,0,0,res_x+2048,res_y);
558         drawgfx_opaque(bitmap,cliprect,gfx,tile,color,0,0,res_x,res_y+1024);
559         drawgfx_opaque(bitmap,cliprect,gfx,tile,color,0,0,res_x+2048,res_y+1024);
562560
563         tile = (m_h1_vram[count] & 0x00000fff) >> 0;
564         color = m_color + ((tile & 0x800) >> 11) * 4;
565
566         drawgfx_opaque(bitmap,cliprect,gfx,tile & 0x7ff,color,0,0,res_x,res_y);
567         drawgfx_opaque(bitmap,cliprect,gfx,tile & 0x7ff,color,0,0,res_x+2048,res_y);
568         drawgfx_opaque(bitmap,cliprect,gfx,tile & 0x7ff,color,0,0,res_x,res_y+1024);
569         drawgfx_opaque(bitmap,cliprect,gfx,tile & 0x7ff,color,0,0,res_x+2048,res_y+1024);
570
571
572         count++;
561         count+=2;
573562      }
574563   }
575564
r21400r21401
14771466   m_blitterClearCount++;
14781467}
14791468
1469READ32_MEMBER(coolridr_state::sysh1_unk_blit_r)
1470{
1471//   if(offset == 0x0c/4) reads
14801472
1473   return m_sysh1_txt_blit[offset];
1474}
14811475
1476
14821477WRITE32_MEMBER(coolridr_state::sysh1_unk_blit_w)
14831478{
14841479   COMBINE_DATA(&m_sysh1_txt_blit[offset]);
r21400r21401
15011496      case 0x02:
15021497      {
15031498
1504         // writes 3d0dxxxx / 3d0exxxx before a level start.. tilemaps transfer?
1499         // writes 3d0dxxxx / 3d0exxxx before a level start.. offset for a transfer read at 0x400000c, stored in work RAM H
15051500
15061501         //printf("sysh1_unk_blit_w unhandled offset %04x %08x %08x\n", offset, data, mem_mask);
15071502
r21400r21401
15561551            if(dst & 0xfff00000)
15571552               printf("unk values to %02x dst %08x\n",cmd,dst);
15581553            dst &= 0x000fffff;
1559            dst |= 0x03000000;
1560            size*=2;
15611554            is_dma = 1;
1562            //printf("%08x %08x %08x %02x\n",src,dst,size,cmd);
15631555            dma_index+=0xc;
15641556            break;
15651557
r21400r21401
15721564            dst &= 0x000fffff;
15731565            dst |= 0x05800000;
15741566            size*=2;
1575            is_dma = 1;
1567            is_dma = 2;
15761568            //printf("%08x %08x %08x %02x\n",src,dst,size,cmd);
15771569            dma_index+=0xc;
15781570            break;
r21400r21401
15861578               printf("unk values to %02x dst %08x\n",cmd,dst);
15871579            dst &= 0x000fffff;
15881580            dst |= 0x03800000;
1589            is_dma = 1;
1581            is_dma = 2;
15901582            //printf("%08x %08x %08x %02x\n",src,dst,size,cmd);
15911583            dma_index+=0xc;
15921584            break;
r21400r21401
16101602            break;
16111603      }
16121604
1613   if(is_dma)
1605   /* TODO: clean-up at a later stage (once that I properly rewrite everything) */
1606   if(is_dma == 1)
16141607   {
1608      UINT16 read_src;
1609
1610      for(int i=0;i<size;i+=2)
1611      {
1612         read_src = space.read_word(src);
1613
1614         m_h1_vram[dst] = read_src >> 8;
1615         m_h1_vram[dst+1] = read_src & 0xff;
1616         dst+=2;
1617         src+=2;
1618      }
1619   }
1620   else if(is_dma == 2)
1621   {
16151622      for(int i=0;i<size;i+=4)
16161623      {
16171624         space.write_dword(dst,space.read_dword(src));
r21400r21401
16551662   AM_RANGE(0x00000000, 0x001fffff) AM_ROM AM_SHARE("share1") AM_WRITENOP
16561663   AM_RANGE(0x01000000, 0x01ffffff) AM_ROM AM_REGION("gfx_data",0x0000000)
16571664
1658   AM_RANGE(0x03000000, 0x030fffff) AM_RAM AM_SHARE("h1_vram")//bg vram TODO: fake region
16591665   AM_RANGE(0x03800000, 0x0380ffff) AM_RAM_WRITE(sysh1_pal_w) AM_SHARE("paletteram")
16601666   AM_RANGE(0x03c00000, 0x03c1ffff) AM_MIRROR(0x00200000) AM_RAM_WRITE(sysh1_dma_w) AM_SHARE("fb_vram") /* mostly mapped at 0x03e00000 */
16611667
16621668   AM_RANGE(0x03f00000, 0x03f0ffff) AM_RAM AM_SHARE("share3") /*Communication area RAM*/
16631669   AM_RANGE(0x03f40000, 0x03f4ffff) AM_RAM AM_SHARE("txt_vram")//text tilemap + "lineram"
1664   AM_RANGE(0x04000000, 0x0400000f) AM_RAM_WRITE(sysh1_unk_blit_w) AM_SHARE("sysh1_txt_blit")
1670   AM_RANGE(0x04000000, 0x0400000f) AM_READWRITE(sysh1_unk_blit_r,sysh1_unk_blit_w) AM_SHARE("sysh1_txt_blit")
16651671   AM_RANGE(0x04000010, 0x04000013) AM_WRITE(sysh1_blit_mode_w)
16661672   AM_RANGE(0x04000014, 0x04000017) AM_WRITE(sysh1_blit_data_w)
16671673   AM_RANGE(0x04000018, 0x0400001b) AM_WRITE(sysh1_fb_mode_w)
r21400r21401
22802286
22812287void coolridr_state::machine_start()
22822288{
2283//  machine().device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
2284//   m_soundcpu->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE);
2285
2286//   memcpy(memregion("soundcpu")->base(), memregion("maincpu")->base()+0x100000, 0x80000);
2287//   m_soundcpu->reset();
22882289   m_compressedgfx = memregion( "compressedgfx" )->base();
22892290   size_t  size    = memregion( "compressedgfx" )->bytes();
22902291
r21400r21401
25522553   sh2drc_set_options(machine().device("sub"), SH2DRC_FASTEST_OPTIONS);
25532554}
25542555
2555GAME( 1995, coolridr,    0, coolridr,    coolridr, coolridr_state,    coolridr, ROT0,  "Sega", "Cool Riders",GAME_NOT_WORKING|GAME_NO_SOUND ) // region is set in test mode, this set is for Japan, USA and Export (all regions)
2556GAME( 1995, coolridr,    0, coolridr,    coolridr, coolridr_state,    coolridr, ROT0,  "Sega", "Cool Riders",GAME_NOT_WORKING|GAME_IMPERFECT_SOUND|GAME_IMPERFECT_GRAPHICS ) // region is set in test mode, this set is for Japan, USA and Export (all regions)
25562557

Previous 199869 Revisions Next


© 1997-2024 The MAME Team