Previous 199869 Revisions Next

r21356 Saturday 23rd February, 2013 at 02:35:57 UTC by Angelo Salese
Rewritten Tilemap DMA from scratch, and fixed data fetching while at it. Now the game properly clears palette when entering into test mode
[src/mame/drivers]coolridr.c

trunk/src/mame/drivers/coolridr.c
r21355r21356
402402   // store the blit params here
403403   UINT32 m_spriteblit[12];
404404
405   
406405
407406
408407
r21355r21356
410409
411410
412411
413   
414412
413
414
415415   required_device<cpu_device> m_maincpu;
416416   required_device<cpu_device> m_subcpu;
417417   required_device<cpu_device> m_soundcpu;
r21355r21356
757757      // abort early
758758      return;
759759   }
760   
761760
762761
763762
763
764764   /************* m_spriteblit[1] *************/
765   
765
766766   // 000u0ccc  - c = colour? u = 0/1
767767   UINT32 blit1_unused = m_spriteblit[1] & 0xfffef800;
768768   UINT32 b1mode = (m_spriteblit[1] & 0x00010000)>>16;
r21355r21356
771771   if (blit1_unused!=0) printf("blit1 unknown bits set %08x\n", m_spriteblit[1]);
772772
773773   /************* m_spriteblit[3] *************/
774   
774
775775   // seems to be more complex than just transparency
776776   UINT32 blit2_unused = m_spriteblit[2]&0xff80f800;
777777   UINT32 b2tpen = (m_spriteblit[2] & 0x007f0000)>>16;
r21355r21356
798798
799799
800800   if (blit3_unused) printf("unknown bits in blit word %d -  %08x\n", 3, blit3_unused);
801   
802801
802
803803   /************* m_spriteblit[4] *************/
804804
805805   UINT32 blit4_unused = m_spriteblit[4] & 0xf8fefefe;
r21355r21356
864864   UINT32 blit10 =  m_spriteblit[10];
865865
866866   /************* m_spriteblit[11] *************/
867   
867
868868   UINT32 textlookup =  m_spriteblit[11];
869869
870870   /* DRAW */
r21355r21356
891891
892892
893893
894   
895894
896895
896
897897   bitmap_rgb32* drawbitmap;
898898
899899   /* test code, not right 0x30 is always text, 0x40 hud, 0x50 99% of game objects and 0x60 some background objects, but it doesn't seem directly priority related*/
r21355r21356
905905      drawbitmap = &m_temp_bitmap_sprites2[(m_blitterMode-0x90)>>4];
906906   */
907907
908   
908
909909   if (m_blitterMode == 0x30 || m_blitterMode == 0x40 || m_blitterMode == 0x50 || m_blitterMode == 0x60)
910910      drawbitmap = &m_temp_bitmap_sprites[0];
911911   else // 0x90, 0xa0, 0xb0, 0xc0
912912      drawbitmap = &m_temp_bitmap_sprites2[0];
913   
914913
914
915915   int sizey = used_vCellCount * 16 * vZoom;
916916
917917   vPosition *= 0x40;
r21355r21356
961961            UINT32 dword = space.read_dword(blit10);
962962
963963            hZoomTable[idx] = hZoom + (dword>>16); // add original value?
964           
964
965965            // bit 0x8000 does get set too, but only on some lines, might have another meaning?
966966            int linescroll = dword&0x7fff;
967967            if (linescroll & 0x4000) linescroll -= 0x8000;
r21355r21356
979979
980980         // DON'T use the table hZoom in this calc? (road..)
981981         int sizex = used_hCellCount * 16 * hZoom;
982           
982
983983         hPositionTable[idx] *= 0x40;
984984
985985         switch (hOrigin & 3)
r21355r21356
10591059         // these should be 'cell numbers' (tile numbers) which look up RLE data?
10601060         UINT32 spriteNumber = (m_expanded_10bit_gfx[ (b3romoffset) + (lookupnum<<1) +0 ] << 10) | (m_expanded_10bit_gfx[ (b3romoffset) + (lookupnum<<1) + 1 ]);
10611061         UINT16 tempshape[16*16];
1062         
1062
10631063         // skip the decoding if it's the same tile as last time!
10641064         if (spriteNumber != lastSpriteNumber)
10651065         {
r21355r21356
11321132         UINT32* line;
11331133
11341134
1135   
11361135
1136
11371137         if (blit_rotate)
11381138         {
11391139            if (used_flipy)
r21355r21356
11801180                     }
11811181                  }
11821182               }
1183            }                       
1183            }
11841184         }
11851185         else // no rotate
11861186         {
r21355r21356
14501450   COMBINE_DATA(&m_sysh1_txt_blit[offset]);
14511451
14521452   switch(offset)
1453   {     
1453   {
14541454      default:
14551455      {
14561456         printf("sysh1_unk_blit_w unhandled offset %04x %08x %08x\n", offset, data, mem_mask);
r21355r21356
14711471
14721472         //printf("sysh1_unk_blit_w unhandled offset %04x %08x %08x\n", offset, data, mem_mask);
14731473
1474     
1474
14751475      }
14761476      break;
14771477
r21355r21356
14951495   palette_set_color_rgb(machine(),offset*2,pal5bit(r),pal5bit(g),pal5bit(b));
14961496}
14971497
1498
1499/* FIXME: this seems to do a hell lot of stuff, it's not ST-V SCU but still somewhat complex :/ */
15001498void coolridr_state::sysh1_dma_transfer( address_space &space, UINT16 dma_index )
15011499{
1502   UINT32 src,dst,size,type,s_i;
1500   UINT32 src,dst,size;
15031501   UINT8 end_dma_mark;
1502   UINT8 cmd;
1503   UINT8 is_dma;
15041504
15051505   end_dma_mark = 0;
15061506
15071507   do{
1508      src = (m_framebuffer_vram[(0+dma_index)/4] & 0x0fffffff);
1509      dst = (m_framebuffer_vram[(4+dma_index)/4]);
1510      size = m_framebuffer_vram[(8+dma_index)/4];
1511      type = (m_framebuffer_vram[(0+dma_index)/4] & 0xf0000000) >> 28;
1508      cmd = (m_framebuffer_vram[(0+dma_index)/4] & 0xfc000000) >> 24;
15121509
1510      is_dma = 0;
15131511
1514
1515      switch (type)
1512      switch(cmd)
15161513      {
1517         case 0x0:
1518            end_dma_mark = 1; //end of DMA list
1514         case 0x00: /* end of list marker */
1515            //printf("end of list reached\n");
1516            end_dma_mark = 1;
15191517            break;
1520
1521         default:
1522            // on startup
1523            //unhandled dma type 01 03e09b80
1524            //unhandled dma type 02 03e0dc00
1525            //unhandled dma type 02 07e0ee00
1526
1527            printf("unhandled dma type %02x %08x\n", type, src);
1528            dma_index+=4;
1529            break;
1530
1531         case 0x3:
1532            //type 3 sets a DMA state->m_param, type 4 sets some kind of table? Skip it for now
1533            /* per screen - on transitions */
1534            if (src & 0x04000000)
1535            {
1536               //printf("screen 2 unhandled dma type %02x %08x\n", type, src& ~0x04000000);
1537            }
1538            else
1539            {
1540               //printf("screen 1 unhandled dma type %02x %08x\n", type, src& ~0x04000000);
1541            }
1542           
1543            dma_index+=4;
1544            break;
1545
1546         case 0x4:
1547            /* per screen - on transitions */
1548            /* some kind of brightness effect for the sprites? */
1549
1550            if (src & 0x04000000)
1551            {
1552               // screen 2...
1553               //printf("screen 2 unhandled dma type %02x %08x\n", type, src& ~0x04000000);
1554            }
1555            else
1556            {
1557               // screen 1
1558               //printf("screen 1 unhandled dma type %02x %08x\n", type, src& ~0x04000000);
1559            }
1560
1561            //type 3 sets a DMA state->m_param, type 4 sets some kind of table? Skip it for now
1562            dma_index+=4;
1563            break;
1564
1565         case 0xc:
1566            dst &= 0xfffff;
1567
1568            dst |= 0x3000000; //to videoram, FIXME: unknown offset
1518         case 0xc0: /* to internal buffer VRAM */
1519            src = (m_framebuffer_vram[(0+dma_index)/4] & 0x03ffffff);
1520            dst = (m_framebuffer_vram[(4+dma_index)/4]);
1521            size = m_framebuffer_vram[(8+dma_index)/4];
1522            if(dst & 0xfff00000)
1523               printf("unk values to %02x dst %08x\n",cmd,dst);
1524            dst &= 0x000fffff;
1525            dst |= 0x03000000;
15691526            size*=2;
1570
1571            for(s_i=0;s_i<size;s_i+=4)
1572            {
1573               space.write_dword(dst,space.read_dword(src));
1574               dst+=4;
1575               src+=4;
1576            }
1527            is_dma = 1;
1528            //printf("%08x %08x %08x %02x\n",src,dst,size,cmd);
15771529            dma_index+=0xc;
15781530            break;
15791531
1580         case 0xd:
1581            dst &= 0xfffff;
1582
1583            dst |= 0x3d00000; //to charram, FIXME: unknown offset
1532         case 0xd0: /* to internal buffer PCG */
1533            src = (m_framebuffer_vram[(0+dma_index)/4] & 0x03ffffff);
1534            dst = (m_framebuffer_vram[(4+dma_index)/4]);
1535            size = m_framebuffer_vram[(8+dma_index)/4];
1536            if(dst & 0xfff00000)
1537               printf("unk values to %02x dst %08x\n",cmd,dst);
1538            dst &= 0x000fffff;
1539            dst |= 0x05800000;
15841540            size*=2;
1585
1586            for(s_i=0;s_i<size;s_i+=4)
1587            {
1588               space.write_dword(dst,space.read_dword(src));
1589               dst+=4;
1590               src+=4;
1591            }
1541            is_dma = 1;
1542            //printf("%08x %08x %08x %02x\n",src,dst,size,cmd);
15921543            dma_index+=0xc;
15931544            break;
15941545
1595         case 0xe:
1596            dst &= 0xfffff;
1597
1598            dst |= 0x3c00000; //to paletteram FIXME: unknown offset
1599            //size/=2;
1600
1601            // this is used when transfering palettes written by the blitter? maybe?
1602            //  it might be a better indication of where blitter command 0xe0 should REALLY write data (at 0x3e00000)...
1603            if((src & 0xff00000) == 0x3e00000)
1604            {
1605               src &= 0xfffff;
1606               src |= 0x3c00000;
1607            }
1608
1609            for(s_i=0;s_i<size;s_i+=4)
1610            {
1611               space.write_dword(dst,space.read_dword(src));
1612               dst+=4;
1613               src+=4;
1614            }
1546         case 0xe0: /* to palette RAM */
1547            src = (m_framebuffer_vram[(0+dma_index)/4] & 0x03ffffff);
1548            dst = (m_framebuffer_vram[(4+dma_index)/4]);
1549            size = m_framebuffer_vram[(8+dma_index)/4];
1550            /*
1551            special: copy palette RAM to palette RAM (otherwise attract mode tries to read from tile data)
1552            */
1553            if((src & 0x03f00000) == 0x03e00000)
1554               src &= ~0x00200000;
1555            if(dst & 0xfff00000)
1556               printf("unk values to %02x dst %08x\n",cmd,dst);
1557            dst &= 0x000fffff;
1558            dst |= 0x03c00000;
1559            is_dma = 1;
1560            //printf("%08x %08x %08x %02x\n",src,dst,size,cmd);
16151561            dma_index+=0xc;
16161562            break;
1563
1564         case 0x04: /* init - value 0x040c80d2 (unknown purpose, slave mode?) */
1565         case 0x10: /* sets up look-up for tilemap video registers */
1566         case 0x20: /* unknown table */
1567         case 0x24: /* unknown table */
1568         case 0x30: /* screen 1 - 0x80 at boot, then 0x808080  */
1569         case 0x34: /* screen 2 / */
1570         case 0x40: /* screen 1 - almost certainly RGB brightness (at least bits 4 - 0) */
1571         case 0x44: /* screen 2 / */
1572         case 0x50: /* screen 1 - unknown */
1573         case 0x54: /* screen 2 / */
1574            //printf("%02x %08x\n",cmd,m_framebuffer_vram[(0+dma_index)/4]);
1575            dma_index+=4;
1576            break;
1577         default:
1578            printf("%02x %08x\n",cmd,m_framebuffer_vram[(0+dma_index)/4]);
1579            dma_index+=4;
1580            break;
16171581      }
16181582
1583   if(is_dma)
1584   {
1585      for(int i=0;i<size;i+=4)
1586      {
1587         space.write_dword(dst,space.read_dword(src));
1588         dst+=4;
1589         src+=4;
1590      }
1591   }
16191592
1620
1621
16221593   }while(!end_dma_mark );
16231594}
16241595
r21355r21356
16261597{
16271598   COMBINE_DATA(&m_framebuffer_vram[offset]);
16281599
1629   // is this real, or just work ram for the actual blitter?
16301600   if(offset*4 == 0x000)
16311601   {
1632      if((m_framebuffer_vram[offset] & 0xff00000) == 0xfe00000)
1602      /* enable */
1603      if((m_framebuffer_vram[offset] & 0xff000000) == 0x0f000000)
16331604         sysh1_dma_transfer(space, m_framebuffer_vram[offset] & 0xffff);
16341605   }
16351606}
r21355r21356
16541625   AM_RANGE(0x00000000, 0x001fffff) AM_ROM AM_SHARE("share1") AM_WRITENOP
16551626   AM_RANGE(0x01000000, 0x01ffffff) AM_ROM AM_REGION("gfx_data",0x0000000)
16561627
1657   AM_RANGE(0x03000000, 0x030fffff) AM_RAM AM_SHARE("h1_vram")//bg vram
1658   AM_RANGE(0x03c00000, 0x03c0ffff) AM_RAM_WRITE(sysh1_pal_w) AM_SHARE("paletteram") // palettes get written here, but the actual used ones seem to get sent via blitter??
1659   AM_RANGE(0x03d00000, 0x03dfffff) AM_RAM_WRITE(sysh1_char_w) AM_SHARE("h1_charram") //FIXME: half size
1660   AM_RANGE(0x03e00000, 0x03efffff) AM_RAM_WRITE(sysh1_dma_w) AM_SHARE("fb_vram") //FIXME: not all of it
1628   AM_RANGE(0x03000000, 0x030fffff) AM_RAM AM_SHARE("h1_vram")//bg vram TODO: fake region
1629   AM_RANGE(0x03c00000, 0x03c0ffff) AM_RAM_WRITE(sysh1_pal_w) AM_SHARE("paletteram")
1630   AM_RANGE(0x03e00000, 0x03efffff) AM_RAM_WRITE(sysh1_dma_w) AM_SHARE("fb_vram")
16611631
16621632   AM_RANGE(0x03f00000, 0x03f0ffff) AM_RAM AM_SHARE("share3") /*Communication area RAM*/
16631633   AM_RANGE(0x03f40000, 0x03f4ffff) AM_RAM AM_SHARE("txt_vram")//text tilemap + "lineram"
r21355r21356
16671637   AM_RANGE(0x04000018, 0x0400001b) AM_WRITE(sysh1_fb_mode_w)
16681638   AM_RANGE(0x0400001c, 0x0400001f) AM_WRITE(sysh1_fb_data_w)
16691639
1640   AM_RANGE(0x05800000, 0x058fffff) AM_RAM_WRITE(sysh1_char_w) AM_SHARE("h1_charram") //TODO: fake region
16701641
1671
1672   
1673   
1674   
16751642   AM_RANGE(0x06000000, 0x060fffff) AM_RAM AM_SHARE("sysh1_workrah")
16761643   AM_RANGE(0x20000000, 0x201fffff) AM_ROM AM_SHARE("share1")
16771644
16781645   AM_RANGE(0x60000000, 0x600003ff) AM_WRITENOP
16791646ADDRESS_MAP_END
16801647
1648
16811649READ16_MEMBER( coolridr_state::h1_soundram_r)
16821650{
16831651   return m_soundram[offset];
r21355r21356
24102378   MCFG_SCREEN_ADD("lscreen", RASTER)
24112379   MCFG_SCREEN_REFRESH_RATE(60)
24122380   MCFG_SCREEN_SIZE(640, 512)
2413   MCFG_SCREEN_VISIBLE_AREA(0,495, 0, 383)
2381   MCFG_SCREEN_VISIBLE_AREA(0,495, 0, 383)
24142382   MCFG_SCREEN_UPDATE_DRIVER(coolridr_state, screen_update_coolridr1)
24152383
24162384   MCFG_SCREEN_ADD("rscreen", RASTER)
r21355r21356
25162484   // with the non-recompiler pc returns +2
25172485   if(pc == 0x06002cbc || pc == 0x06002d44)
25182486      return 0;
2519   
2487
25202488   return m_sysh1_workram_h[0xd8894/4];
25212489}
25222490

Previous 199869 Revisions Next


© 1997-2024 The MAME Team