Previous 15994 Revisions Next

r10807 Monday 14th March, 2011 at 14:24:00 UTC by Angelo Salese
[MEGACD]: Improve graphic scale/rotate conversion handling - improves batmanre, advbat, f1btl, bcracers + others, improved sub-cpu until timings in timegal, anettfut etc. are worked out [David Haywood]
[src/mame/machine]megadriv.c

src/mame/machine/megadriv.c
r10806r10807
39433943#define RAM_MODE_2MEG (0)
39443944#define RAM_MODE_1MEG (2)
39453945
3946
3947
3948INLINE void write_pixel(running_machine* machine, UINT8 pix, int pixeloffset )
3949{
3950
3951   int shift = 12-(4*(pixeloffset&0x3));
3952   UINT16 datamask = (0x000f) << shift;
3953
3954   int offset = pixeloffset>>3;
3955   if (pixeloffset&4) offset++;
3956
3957   offset &=0x1ffff;
3958
3959   switch (segacd_memory_priority_mode)
3960   {
3961      case 0x00: // normal write, just write the data
3962         segacd_dataram[offset] = segacd_dataram[offset] &~ datamask;
3963         segacd_dataram[offset] |= pix << shift;
3964         break;
3965
3966      case 0x01: // underwrite, only write if the existing data is 0
3967         if ((segacd_dataram[offset]&datamask) == 0x0000)
3968         {
3969            segacd_dataram[offset] = segacd_dataram[offset] &~ datamask;
3970            segacd_dataram[offset] |= pix << shift;
3971         }
3972         break;
3973     
3974      case 0x02: // overwrite, only write non-zero data
3975         if (pix)
3976         {
3977            segacd_dataram[offset] = segacd_dataram[offset] &~ datamask;
3978            segacd_dataram[offset] |= pix << shift;
3979         }
3980         break;
3981
3982      default:
3983      case 0x03:
3984         pix = machine->rand() & 0x000f;
3985         segacd_dataram[offset] = segacd_dataram[offset] &~ datamask;
3986         segacd_dataram[offset] |= pix << shift;
3987         break;
3988
3989   }
3990}
3991
39463992// 1meg / 2meg swap is interleaved swap, not half/half of the ram?
39473993// Wily Beamish and Citizen X appear to rely on this
39483994// however, it breaks the megacdj bios (megacd2j still works!)
r10806r10807
39594005   return segacd_dataram[offset];
39604006}
39614007
3962void segacd_1meg_mode_word_write(int offset, UINT16 data, UINT16 mem_mask, int use_pm)
4008
4009void segacd_1meg_mode_word_write(running_machine* machine, int offset, UINT16 data, UINT16 mem_mask, int use_pm)
39634010{
39644011   offset *= 2;
39654012
r10806r10807
46004647
46014648                  if (!(scd_rammode & 1))
46024649                  {
4603                     segacd_1meg_mode_word_write((dstoffset+0x20000)/2, data, 0xffff, 0);
4650                     segacd_1meg_mode_word_write(space->machine,(dstoffset+0x20000)/2, data, 0xffff, 0);
46044651                  }
46054652                  else
46064653                  {
4607                     segacd_1meg_mode_word_write((dstoffset+0x00000)/2, data, 0xffff, 0);
4654                     segacd_1meg_mode_word_write(space->machine,(dstoffset+0x00000)/2, data, 0xffff, 0);
46084655                  }
46094656               }
46104657
r10806r10807
48554902//static void segacd_mark_stampmaps_dirty(void);
48564903
48574904
4905
48584906static WRITE16_HANDLER( scd_a12000_halt_reset_w )
48594907{
48604908   space->machine->scheduler().synchronize();
r10806r10807
48654913   {
48664914      // reset line
48674915      if (a12000_halt_reset_reg&0x0001)
4916      {
48684917         cputag_set_input_line(space->machine, "segacd_68k", INPUT_LINE_RESET, CLEAR_LINE);
4918         printf("clear reset slave\n");
4919      }
48694920      else
4921      {
48704922         cputag_set_input_line(space->machine, "segacd_68k", INPUT_LINE_RESET, ASSERT_LINE);
4923         printf("assert reset slave\n");
4924      }
48714925
48724926      // request BUS
48734927      if (a12000_halt_reset_reg&0x0002)
4928      {
48744929         cputag_set_input_line(space->machine, "segacd_68k", INPUT_LINE_HALT, ASSERT_LINE);
4930         printf("halt slave\n");
4931      }
48754932      else
4933      {
48764934         cputag_set_input_line(space->machine, "segacd_68k", INPUT_LINE_HALT, CLEAR_LINE);
4935         printf("resume slave\n");
4936      }
48774937   }
48784938
48794939   if (ACCESSING_BITS_8_15)
r10806r10807
48864946
48874947      if (a12000_halt_reset_reg&0x8000)
48884948      {
4889         printf("a12000_halt_reset_reg & 0x8000 set\n"); // irq2 mask?
4949         //printf("a12000_halt_reset_reg & 0x8000 set\n"); // irq2 mask?
48904950      }
48914951
48924952
r10806r10807
53475407         // ret bit set by sub cpu determines which half of WorkRAM we have access to?
53485408         if (scd_rammode&1)
53495409         {
5350            segacd_1meg_mode_word_write(offset+0x20000/2, data, mem_mask, 0);
5410            segacd_1meg_mode_word_write(space->machine, offset+0x20000/2, data, mem_mask, 0);
53515411         }
53525412         else
53535413         {
5354            segacd_1meg_mode_word_write(offset+0x00000/2, data, mem_mask, 0);
5414            segacd_1meg_mode_word_write(space->machine, offset+0x00000/2, data, mem_mask, 0);
53555415         }
53565416      }
53575417      else
r10806r10807
60306090   stopwatch_timer = machine->device<timer_device>("sw_timer");
60316091
60326092   scd_dma_timer->adjust(attotime::zero);
6093
6094
6095   // HACK!!!! timegal, anettfut, roadaven end up with the SubCPU waiting in a loop for *something*
6096   // overclocking the CPU, even at the point where the game is hung, allows them to continue and boot
6097   // I'm not sure what the source of this timing problem is, it's not using IRQ3 or StopWatch at the
6098   // time.  Changing the CDHock timer to 50hz from 75hz also stops the hang, but then the video is
6099   // too slow and has bad sound.  -- Investigate!
6100   
6101   _segacd_68k_cpu->set_clock_scale(1.5000f);
6102
60336103}
60346104
60356105
r10806r10807
61546224
61556225      if (scd_rammode&1)
61566226      {
6157         segacd_1meg_mode_word_write(offset/2+0x00000/2, data , mem_mask, 1);
6227         segacd_1meg_mode_word_write(space->machine, offset/2+0x00000/2, data , mem_mask, 1);
61586228      }
61596229      else
61606230      {
6161         segacd_1meg_mode_word_write(offset/2+0x20000/2, data, mem_mask, 1);
6231         segacd_1meg_mode_word_write(space->machine, offset/2+0x20000/2, data, mem_mask, 1);
61626232      }
61636233
61646234   //   printf("Unspported: segacd_sub_dataram_part1_w in mode 1 (Word RAM Expander - 1 Byte Per Pixel) %04x\n", data);
r10806r10807
62026272      // ret bit set by sub cpu determines which half of WorkRAM we have access to?
62036273      if (scd_rammode&1)
62046274      {
6205         segacd_1meg_mode_word_write(offset+0x00000/2, data, mem_mask, 0);
6275         segacd_1meg_mode_word_write(space->machine,offset+0x00000/2, data, mem_mask, 0);
62066276      }
62076277      else
62086278      {
6209         segacd_1meg_mode_word_write(offset+0x20000/2, data, mem_mask, 0);
6279         segacd_1meg_mode_word_write(space->machine,offset+0x20000/2, data, mem_mask, 0);
62106280      }
62116281
62126282   }
r10806r10807
63606430   return 0;
63616431}
63626432
6363INLINE void write_pixel_to_imagebuffer( running_machine* machine, UINT32 pix, int line, int xpos )
6364{
63656433
6366   UINT32 bufferstart = (segacd_imagebuffer_start_address&0xfff8)*2;
6367   UINT32 bufferend = bufferstart + (((segacd_imagebuffer_vcell_size+1) * (segacd_imagebuffer_hdot_size>>3)*0x20)/2);
6368   UINT32 offset;
63696434
6370   offset = bufferstart+(((segacd_imagebuffer_vcell_size+1)*0x10)*xpos);
63716435
6372   // lines of each output cell
6373   offset+= (line*2);
63746436
6375   while (offset>=bufferend)
6376      offset-= bufferend;
6377
6378
6379   switch (segacd_memory_priority_mode)
6380   {
6381      case 0x00: // normal write, just write the data
6382         segacd_dataram[offset] = pix >> 16;
6383         segacd_dataram[offset+1] = pix & 0xffff;
6384         break;
6385
6386      case 0x01: // underwrite, only write if the existing data is 0
6387         if ((segacd_dataram[offset]&0xf000) == 0x0000) segacd_dataram[offset] |= (pix>>16)&0xf000;
6388         if ((segacd_dataram[offset]&0x0f00) == 0x0000) segacd_dataram[offset] |= (pix>>16)&0x0f00;
6389         if ((segacd_dataram[offset]&0x00f0) == 0x0000) segacd_dataram[offset] |= (pix>>16)&0x00f0;
6390         if ((segacd_dataram[offset]&0x000f) == 0x0000) segacd_dataram[offset] |= (pix>>16)&0x000f;
6391         if ((segacd_dataram[offset+1]&0xf000) == 0x0000) segacd_dataram[offset+1] |= (pix)&0xf000;
6392         if ((segacd_dataram[offset+1]&0x0f00) == 0x0000) segacd_dataram[offset+1] |= (pix)&0x0f00;
6393         if ((segacd_dataram[offset+1]&0x00f0) == 0x0000) segacd_dataram[offset+1] |= (pix)&0x00f0;
6394         if ((segacd_dataram[offset+1]&0x000f) == 0x0000) segacd_dataram[offset+1] |= (pix)&0x000f;
6395         break;
6396
6397      case 0x02: // overwrite, only write non-zero data
6398         if ((pix>>16)&0xf000) segacd_dataram[offset] = (segacd_dataram[offset] & 0x0fff) | ((pix>>16)&0xf000);
6399         if ((pix>>16)&0x0f00) segacd_dataram[offset] = (segacd_dataram[offset] & 0xf0ff) | ((pix>>16)&0x0f00);
6400         if ((pix>>16)&0x00f0) segacd_dataram[offset] = (segacd_dataram[offset] & 0xff0f) | ((pix>>16)&0x00f0);
6401         if ((pix>>16)&0x000f) segacd_dataram[offset] = (segacd_dataram[offset] & 0xfff0) | ((pix>>16)&0x000f);
6402         if ((pix)&0xf000) segacd_dataram[offset+1] = (segacd_dataram[offset+1] & 0x0fff) | ((pix)&0xf000);
6403         if ((pix)&0x0f00) segacd_dataram[offset+1] = (segacd_dataram[offset+1] & 0xf0ff) | ((pix)&0x0f00);
6404         if ((pix)&0x00f0) segacd_dataram[offset+1] = (segacd_dataram[offset+1] & 0xff0f) | ((pix)&0x00f0);
6405         if ((pix)&0x000f) segacd_dataram[offset+1] = (segacd_dataram[offset+1] & 0xfff0) | ((pix)&0x000f);
6406         break;
6407
6408      default:
6409      case 0x03: // invalid?
6410         segacd_dataram[offset] = machine->rand();
6411         segacd_dataram[offset+1] = machine->rand();
6412         break;
6413
6414   }
6415
6416   segacd_mark_tiles_dirty(machine, offset);
6417   segacd_mark_tiles_dirty(machine, offset+1);
6418
6419}
6420
64216437// this triggers the conversion operation, which will cause an IRQ1 when finished
64226438WRITE16_HANDLER( segacd_trace_vector_base_address_w )
64236439{
r10806r10807
64466462      int line;
64476463      //bitmap_t *srcbitmap = tilemap_get_pixmap(segacd_stampmap[segacd_get_active_stampmap_tilemap()]);
64486464      bitmap_t *srcbitmap = 0;
6465      UINT32 bufferstart = ((segacd_imagebuffer_start_address&0xfff8)*2)<<3;
64496466
64506467      for (line=0;line<segacd_imagebuffer_vdot_size;line++)
64516468      {
r10806r10807
64666483         int ybase = tilemapyoffs * 256;
64676484         int count;
64686485
6469         for (count=0;count<(segacd_imagebuffer_hdot_size>>3);count++)
6486         for (count=0;count<(segacd_imagebuffer_hdot_size);count++)
64706487         {
6471            int i;
6472            UINT32 pixblock = 0x00000000;
6473            for (i=7*4;i>=0;i-=4)
6474            {
6475               pixblock |= read_pixel_from_stampmap(space->machine, srcbitmap, xbase>>(3+8), ybase>>(3+8)) << (i);
6488            //int i;
6489            UINT8 pix = 0x0;
64766490
6491            pix = read_pixel_from_stampmap(space->machine, srcbitmap, xbase>>(3+8), ybase>>(3+8));
64776492
6478               xbase += deltax;
6479               ybase += deltay;
6493            xbase += deltax;
6494            ybase += deltay;
64806495
6481               // clamp to 24-bits, seems to be required for all the intro effects to work
6482               xbase &= 0xffffff;
6483               ybase &= 0xffffff;
6496            // clamp to 24-bits, seems to be required for all the intro effects to work
6497            xbase &= 0xffffff;
6498            ybase &= 0xffffff;
64846499
6500            int countx = count + (segacd_imagebuffer_offset&0x7);
64856501
6486            }
6502            UINT32 offset;
64876503
6504            offset = bufferstart+((((segacd_imagebuffer_vcell_size+1)*0x10)*(countx>>3))<<3);
64886505
6506            offset+= ((line*2)<<3);
6507            offset+=(segacd_imagebuffer_offset&0x38)<<1;
64896508
6509            offset+=countx & 0x7;
64906510
6491            write_pixel_to_imagebuffer(space->machine, pixblock, line, count);
6511            write_pixel( space->machine, pix, offset );
6512
6513            segacd_mark_tiles_dirty(space->machine, (offset>>3));
6514            segacd_mark_tiles_dirty(space->machine, (offset>>3)+1);
6515
64926516         }
64936517
64946518      }
r10806r10807
66516675   else
66526676      cdfader_vol = (cdfader_vol / 1024.0) * 100.0;
66536677
6654   printf("%f\n",cdfader_vol);
6678   //printf("%f\n",cdfader_vol);
66556679
66566680   cdda_set_volume(space->machine->device("cdda"), cdfader_vol);
66576681}
r10806r10807
92719295   if (genesis_other_hacks)
92729296   {
92739297   //  set_refresh_rate(megadriv_framerate);
9274      machine->device("maincpu")->set_clock_scale(0.9950f); /* Fatal Rewind is very fussy... */
9275   //  machine->device("maincpu")->set_clock_scale(0.3800f); /* Fatal Rewind is very fussy... */
9298   //   machine->device("maincpu")->set_clock_scale(0.9950f); /* Fatal Rewind is very fussy... (and doesn't work now anyway, so don't bother with this) */
92769299
92779300      memset(megadrive_ram,0x00,0x10000);
92789301   }

Previous 15994 Revisions Next


© 1998-2018 The MESS Team