Previous 199869 Revisions Next

r21419 Sunday 24th February, 2013 at 14:43:33 UTC by Angelo Salese
Tilemap rewrite once again, re-instated drawgfx, fixed second screen
[src/mame/drivers]coolridr.c

trunk/src/mame/drivers/coolridr.c
r21418r21419
424424
425425   bitmap_rgb32 m_screen1_bitmap;
426426   bitmap_rgb32 m_screen2_bitmap;
427   int m_color;
428   UINT8 m_vblank;
429427   int m_scsp_last_line;
430428   UINT8 an_mux_data;
431429   UINT8 sound_data, sound_fifo_full;
r21418r21419
477475   void sysh1_dma_transfer( address_space &space, UINT16 dma_index );
478476
479477   UINT16 *m_h1_vram;
480   UINT16 *m_h1_pcg;
478   UINT8 *m_h1_pcg;
481479   UINT16 *m_h1_pal;
480   void flush_pal_data( UINT16 offset );
481   int m_gfx_index;
482   int m_color_bank;
482483
483484   osd_work_queue *    m_work_queue[2]; // work queue, one per screen
484485   static void *draw_tile_row_threaded(void *param, int threadid);
r21418r21419
493494
494495#define VRAM_SIZE 0x100000
495496
497static const gfx_layout h1_tile_layout =
498{
499   16,16,
500   0x800,
501   8,
502   { 0, 1, 2, 3, 4, 5, 6, 7 },
503   { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120 },
504   { 0*128, 1*128, 2*128, 3*128, 4*128, 5*128, 6*128, 7*128, 8*128, 9*128, 10*128, 11*128, 12*128, 13*128, 14*128, 15*128 },
505   16*128
506};
507
508
496509void coolridr_state::video_start()
497510{
511   /* find first empty slot to decode gfx */
512   for (m_gfx_index = 0; m_gfx_index < MAX_GFX_ELEMENTS; m_gfx_index++)
513      if (machine().gfx[m_gfx_index] == 0)
514         break;
515
498516   machine().primary_screen->register_screen_bitmap(m_temp_bitmap_sprites[0]);
499517   machine().primary_screen->register_screen_bitmap(m_temp_bitmap_sprites2[0]);
500518   machine().primary_screen->register_screen_bitmap(m_zbuffer_bitmap);
501519   machine().primary_screen->register_screen_bitmap(m_zbuffer_bitmap2);
502520
503521
504   
505522
523
506524   // testing, not right
507525   machine().primary_screen->register_screen_bitmap(m_temp_bitmap_sprites[1]);
508526   machine().primary_screen->register_screen_bitmap(m_temp_bitmap_sprites2[1]);
r21418r21419
514532   machine().primary_screen->register_screen_bitmap(m_screen1_bitmap);
515533   machine().primary_screen->register_screen_bitmap(m_screen2_bitmap);
516534
517   m_h1_vram = auto_alloc_array_clear(machine(), UINT16, VRAM_SIZE);
518   m_h1_pcg = auto_alloc_array_clear(machine(), UINT16, VRAM_SIZE);
519   m_h1_pal = auto_alloc_array_clear(machine(), UINT16, VRAM_SIZE);
520
521   save_pointer(NAME(m_h1_vram), VRAM_SIZE);
522   save_pointer(NAME(m_h1_pcg), VRAM_SIZE);
523   save_pointer(NAME(m_h1_pal), VRAM_SIZE);
535   machine().gfx[m_gfx_index] = auto_alloc(machine(), gfx_element(machine(), h1_tile_layout, m_h1_pcg, 8, 0));
524536}
525537
526538// might be a page 'map / base' setup somewhere, but it's just used for ingame backgrounds
r21418r21419
532544   /* planes seems to basically be at 0x8000 and 0x28000... */
533545#if 1
534546   UINT32 base_offset;
535   int xsrc,ysrc,ydst,xdst;
536   int xisrc,yisrc;
537547   int tile,color;
538548   int scrollx;
539549   int scrolly;
540   #define xsize_mask 2048-1
541   #define ysize_mask 1024-1
542   #define xsize 128
543   #define xi_size 16
544   #define yi_size 16
545   #define xi_mask xi_size-1
546   #define yi_mask yi_size-1
547   UINT32 src_offs,pcg_offs;
550   gfx_element *gfx = machine().gfx[m_gfx_index];
548551
549552   scrollx = (m_framebuffer_vram[(0x9bac+which*0x40)/4] >> 16) & 0x7ff;
550553   scrolly = m_framebuffer_vram[(0x9bac+which*0x40)/4] & 0x3ff;
551554
552   base_offset = which * 0x20000;
553   m_color = which * 2;
555   base_offset = (which * 0x20000)/2;
556   m_color_bank = which * 2;
554557
555   // drawgfx was a lot faster, and I think can handle what we need, even if there
556   // are RGB effects I think it will be cheaper to manipulate the palette...
557   for(ydst=cliprect.min_y;ydst<=cliprect.max_y;ydst++)
558   {
559      for(xdst=cliprect.min_x;xdst<=cliprect.max_x;xdst++)
560      {
561         UINT16 cur_tile;
562         UINT16 dot_data,pal_data;
563         int r,g,b;
558    for (int y=0;y<64;y++)
559    {
560      for (int x=0;x<128;x++)
561       {
562          int res_x,res_y;
564563
565         /* base tile scrolling */
566         xsrc = ((xdst + scrollx) & (xsize_mask)) >> 4;
567         ysrc = ((ydst + scrolly) & (ysize_mask)) >> 4;
568         /* apply fractional scrolling */
569         xisrc = (xdst + scrollx) & (xi_mask);
570         yisrc = (ydst + scrolly) & (yi_mask);
571         /* do the tile offset calc */
572         src_offs = (xsrc + (ysrc*xsize));
573         src_offs += base_offset;
564         res_x = (x*16)-scrollx;
565          res_y = (y*16)-scrolly;
574566
575         /* fetch tilemap data */
576         cur_tile = m_h1_vram[src_offs];
567         tile = (m_h1_vram[x+y*128+base_offset] & 0x0fff);
568         color = m_color_bank + ((tile & 0x800) >> 11) * 4;
577569
578         /* split proper tile reading and apply color too */
579         tile = cur_tile & 0x07ff;
580         color = m_color + ((cur_tile & 0x0800) >> 11) * 4;
581
582         /* we have a tile number, fetch the PCG RAM */
583         pcg_offs = (xisrc+yisrc*xi_size)+tile*xi_size*yi_size;
584         /* the dot offset calculation */
585         dot_data = m_h1_pcg[pcg_offs/2];
586         dot_data>>= ((pcg_offs & 1) ^ 1) * 8;
587         dot_data&= 0xff;
588         dot_data+= color<<8;
589
590         /* finally, take the palette data (TODO: apply RGB control) */
591         pal_data = m_h1_pal[dot_data];
592         r = pal5bit((pal_data >> 10) & 0x1f);
593         g = pal5bit((pal_data >> 5) & 0x1f);
594         b = pal5bit((pal_data >> 0) & 0x1f);
595
596         /* put on the screen */
597         bitmap.pix32(ydst, xdst) = r<<16 | g<<8 | b;
570         drawgfx_opaque(bitmap,cliprect,gfx,tile & 0x7ff,color,0,0,res_x,res_y);
571         drawgfx_opaque(bitmap,cliprect,gfx,tile & 0x7ff,color,0,0,res_x+2048,res_y);
572         drawgfx_opaque(bitmap,cliprect,gfx,tile & 0x7ff,color,0,0,res_x,res_y+1024);
573         drawgfx_opaque(bitmap,cliprect,gfx,tile & 0x7ff,color,0,0,res_x+2048,res_y+1024);
598574      }
599575   }
576
600577#endif
601578   if (which==0)
602579   {
r21418r21419
626603
627604
628605
629/* According to Guru, this is actually the same I/O chip of Sega Model 2 HW */
630#if 0
631READ32_MEMBER(coolridr_state::sysh1_ioga_r)
632{
633   //return machine().rand();//h1_ioga[offset];
634   return h1_ioga[offset];
635}
636606
637WRITE32_MEMBER(coolridr_state::sysh1_ioga_w)
638{
639   COMBINE_DATA(&h1_ioga[offset]);
640}
641#endif
642
643607struct cool_render_object
644608{
645609   UINT8* indirect_tiles;
r21418r21419
836800{
837801   cool_render_object *object = reinterpret_cast<cool_render_object *>(param);
838802   bitmap_rgb32* drawbitmap = object->drawbitmap;
839   
803
840804   UINT16* rearranged_16bit_gfx = object->state->m_rearranged_16bit_gfx;
841805   UINT16* expanded_10bit_gfx = object->state->m_expanded_10bit_gfx;
842   
843806
844807
808
845809   /************* object->spriteblit[1] *************/
846810
847811   // 000u0ccc  - c = colour? u = 0/1
r21418r21419
862826   {
863827   //   b1colorNumber = space.machine().rand()&0xfff;
864828   }
865     
866829
830
867831//   if(b1colorNumber > 0x60 || b2colorNumber)
868832//      printf("%08x %08x\n",b1colorNumber,b2colorNumber);
869833
r21418r21419
895859   UINT32 blit4_unused = object->spriteblit[4] & 0xf8fefefe;
896860   //UINT32 blit4 = (object->spriteblit[4] & 0x07000000)>>24;
897861   //object->zpri = 7-blit4;
898   
862
899863   UINT32 blit_flipx = object->spriteblit[4] & 0x00000001;
900864   UINT32 blit_flipy = (object->spriteblit[4] & 0x00000100)>>8;
901865   UINT32 blit_rotate = (object->spriteblit[4] & 0x00010000)>>16;
r21418r21419
11891153         // these should be 'cell numbers' (tile numbers) which look up RLE data?
11901154         UINT32 spriteNumber = (expanded_10bit_gfx[ (b3romoffset) + (lookupnum<<1) +0 ] << 10) | (expanded_10bit_gfx[ (b3romoffset) + (lookupnum<<1) + 1 ]);
11911155         UINT16 tempshape[16*16];
1192         
1156
11931157         int color_offs = (0x7b20 + (b1colorNumber & 0x7ff))*0x40 * 5; /* yes, * 5 */
11941158         UINT16 blankcount = 256;
1195         
1159
11961160         if (used_flipy)
11971161         {
11981162            if (used_flipx)
r21418r21419
13531317         } // end no indirect zoom
13541318      }
13551319   }
1356   
13571320
13581321
1322
13591323   end:
13601324
13611325   if (object->indirect_tiles)
r21418r21419
14821446   testobject->state = this;
14831447
14841448   for (int i=0;i<12;i++)
1485      testobject->spriteblit[i] = m_spriteblit[i];   
1449      testobject->spriteblit[i] = m_spriteblit[i];
14861450
14871451   // cache some values that are looked up from RAM to be safe.. alternatively we could stall the rendering if they get written to, but they're a direct memory pointer..
14881452   int test_indirect_tile_enable = (m_spriteblit[5] & 0x00010000)>>16;
r21418r21419
15071471   int test_indirect_zoom_enable = (m_spriteblit[5] & 0x00000001);
15081472   if (test_indirect_zoom_enable)
15091473   {
1510      UINT32 test_blit10 =  m_spriteblit[10];   
1474      UINT32 test_blit10 =  m_spriteblit[10];
15111475      UINT16 test_vCellCount = (m_spriteblit[6] & 0x03ff0000) >> 16;
15121476      int bytes = test_vCellCount * 4 * 16;
15131477      testobject->indirect_zoom = (UINT32*)malloc(bytes);
r21418r21419
15191483   else
15201484   {
15211485      testobject->indirect_zoom = NULL;
1522   }     
1486   }
15231487
15241488   testobject->zpri = m_blitterAddr | m_blittype<<12;
15251489   testobject->blittype = m_blittype;
r21418r21419
18191783}
18201784
18211785
1786void coolridr_state::flush_pal_data( UINT16 offset )
1787{
1788   int r,g,b;
1789   r = ((m_h1_pal[offset] & 0x7c00) >> 10);
1790   g = ((m_h1_pal[offset] & 0x03e0) >> 5);
1791   b = ((m_h1_pal[offset] & 0x001f) >> 0);
1792   palette_set_color_rgb(machine(),offset,pal5bit(r),pal5bit(g),pal5bit(b));
1793}
18221794
1823
18241795void coolridr_state::sysh1_dma_transfer( address_space &space, UINT16 dma_index )
18251796{
18261797   UINT32 src = 0,dst = 0,size = 0;
18271798   UINT8 end_dma_mark;
18281799   UINT8 cmd;
1829   UINT8 is_dma;
1830   UINT16 *dst_ptr;
18311800
18321801   end_dma_mark = 0;
18331802
18341803   do{
18351804      cmd = (m_framebuffer_vram[(0+dma_index)/4] & 0xfc000000) >> 24;
18361805
1837      is_dma = 0;
18381806
18391807      switch(cmd)
18401808      {
r21418r21419
18461814            src = (m_framebuffer_vram[(0+dma_index)/4] & 0x03ffffff);
18471815            dst = (m_framebuffer_vram[(4+dma_index)/4]);
18481816            size = m_framebuffer_vram[(8+dma_index)/4];
1849            if(dst & 0xfff00000)
1817            if(dst & 0xfff00001)
18501818               printf("unk values to %02x dst %08x\n",cmd,dst);
1851            dst_ptr = m_h1_vram;
18521819            dst &= 0x000ffffe;
18531820            dst >>= 1;
1854            is_dma = 1;
1821
1822            for(int i=0;i<size;i+=2)
1823            {
1824               m_h1_vram[dst] = space.read_word(src);
1825               dst++;
1826               src+=2;
1827            }
1828
18551829            dma_index+=0xc;
18561830            break;
18571831
r21418r21419
18611835            size = m_framebuffer_vram[(8+dma_index)/4];
18621836            if(dst & 0xfff00000)
18631837               printf("unk values to %02x dst %08x\n",cmd,dst);
1864            dst_ptr = m_h1_pcg;
1865            dst &= 0x000ffffe;
1866            dst >>= 1;
1867            is_dma = 1;
1838            dst &= 0x000fffff;
1839
1840            /* TODO: might as well improve the dirty handling */
1841            for(int i=0;i<size;i++)
1842            {
1843               m_h1_pcg[dst] = space.read_byte(src);
1844               machine().gfx[m_gfx_index]->mark_dirty(dst/256);
1845               dst++;
1846               src++;
1847            }
1848
18681849            dma_index+=0xc;
18691850            break;
18701851
r21418r21419
18731854            dst = (m_framebuffer_vram[(4+dma_index)/4]);
18741855            size = m_framebuffer_vram[(8+dma_index)/4];
18751856            /* Note: there are also some reads at 0x3e00000. This tells us that the DMA thing actually mirrors at 0x3c00000 too. */
1876            if(dst & 0xfff00000)
1857            if(dst & 0xfff00001)
18771858               printf("unk values to %02x dst %08x\n",cmd,dst);
1878            dst_ptr = m_h1_pal;
18791859            dst &= 0x000ffffe;
18801860            dst >>= 1;
1881            is_dma = 1;
1861
1862            for(int i=0;i<size;i+=2)
1863            {
1864               m_h1_pal[dst] = space.read_word(src);
1865               flush_pal_data(dst);
1866               dst++;
1867               src+=2;
1868            }
1869
18821870            dma_index+=0xc;
18831871            break;
18841872
r21418r21419
19011889            break;
19021890      }
19031891
1904   if(is_dma)
1905   {
1906      for(int i=0;i<size;i+=2)
1907      {
1908         dst_ptr[dst] = space.read_word(src);
1909         dst++;
1910         src+=2;
1911      }
1912   }
1913
19141892   }while(!end_dma_mark );
19151893}
19161894
r21418r21419
21232101
21242102
21252103
2126static const gfx_layout tiles16x16_layout =
2127{
2128   16,16,
2129   RGN_FRAC(1,1),
2130   8,
2131   { 0, 1, 2, 3, 4, 5, 6, 7 },
2132   { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120 },
2133   { 0*128, 1*128, 2*128, 3*128, 4*128, 5*128, 6*128, 7*128, 8*128, 9*128, 10*128, 11*128, 12*128, 13*128, 14*128, 15*128 },
2134   16*128
2135};
21362104
21372105
21382106static GFXDECODE_START( coolridr )
2139   GFXDECODE_ENTRY( "ram_gfx", 0, tiles16x16_layout, 0, 0x100 )
2107//   GFXDECODE_ENTRY( NULL, 0, tiles16x16_layout, 0, 0x100 )
21402108GFXDECODE_END
21412109
21422110static INPUT_PORTS_START( coolridr )
r21418r21419
26022570      }
26032571   }
26042572
2573   m_h1_vram = auto_alloc_array_clear(machine(), UINT16, VRAM_SIZE);
2574   m_h1_pcg = auto_alloc_array_clear(machine(), UINT8, VRAM_SIZE);
2575   m_h1_pal = auto_alloc_array_clear(machine(), UINT16, VRAM_SIZE);
2576
2577   save_pointer(NAME(m_h1_vram), VRAM_SIZE);
2578   save_pointer(NAME(m_h1_pcg), VRAM_SIZE);
2579   save_pointer(NAME(m_h1_pal), VRAM_SIZE);
26052580}
26062581
26072582void coolridr_state::machine_reset()
r21418r21419
27412716   ROM_LOAD32_WORD_SWAP( "mp17656.17", 0x0c00002, 0x0200000, CRC(945c89e3) SHA1(8776d74f73898d948aae3c446d7c710ad0407603) )
27422717   ROM_LOAD32_WORD_SWAP( "mp17657.18", 0x0c00000, 0x0200000, CRC(74676b1f) SHA1(b4a9003a052bde93bebfa4bef9e8dff65003c3b2) )
27432718
2744   ROM_REGION32_BE( 0x100000, "ram_gfx", ROMREGION_ERASE00 ) /* SH2 code */
2745
27462719   ROM_REGION( 0x100000, "soundcpu", ROMREGION_ERASE00 )   /* 68000 */
27472720
27482721   ROM_REGION( 0x100000, "sub", 0 ) /* SH1 */

Previous 199869 Revisions Next


© 1997-2024 The MAME Team