Previous 15994 Revisions Next

r9380 Thursday 14th October, 2010 at 10:43:02 UTC by Angelo Salese
[Mega CD]: Done some work to allow Sega CD logo animations [David Haywood]
[src/mame/drivers]megadriv.c

src/mame/drivers/megadriv.c
r9379r9380
26812681
26822682         current_fifo_read_pos++;
26832683
2684      //  printf("reading FIFO!\n");
2684      //   printf("reading FIFO!\n");
26852685
26862686         if (current_fifo_readblock == fifo_block_a && !fifo_block_a_full)
26872687            printf("Fifo block a isn't filled!\n");
r9379r9380
27412741         dreq_src_addr[offset&1] = ((offset&1) == 0) ? (data & 0xff) : (data & 0xfffe);
27422742
27432743         //if((dreq_src_addr[0]<<16)|dreq_src_addr[1])
2744         //  printf("DREQ set SRC = %08x\n",(dreq_src_addr[0]<<16)|dreq_src_addr[1]);
2744         //   printf("DREQ set SRC = %08x\n",(dreq_src_addr[0]<<16)|dreq_src_addr[1]);
27452745
27462746         break;
27472747
r9379r9380
27562756         dreq_dst_addr[offset&1] = ((offset&1) == 0) ? (data & 0xff) : (data & 0xffff);
27572757
27582758         //if((dreq_dst_addr[0]<<16)|dreq_dst_addr[1])
2759         //  printf("DREQ set DST = %08x\n",(dreq_dst_addr[0]<<16)|dreq_dst_addr[1]);
2759         //   printf("DREQ set DST = %08x\n",(dreq_dst_addr[0]<<16)|dreq_dst_addr[1]);
27602760
27612761         break;
27622762
r9379r9380
27692769
27702770         dreq_size = data & 0xfffc;
27712771
2772         //  if(dreq_size)
2773         //      printf("DREQ set SIZE = %04x\n",dreq_size);
2772         //   if(dreq_size)
2773         //      printf("DREQ set SIZE = %04x\n",dreq_size);
27742774
27752775         break;
27762776
r9379r9380
32083208
32093209
32103210
3211//  printf("_32x_68k_a15180_r (a15180) %04x\n",mem_mask);
3211//   printf("_32x_68k_a15180_r (a15180) %04x\n",mem_mask);
32123212
32133213   // read needs authorization too I think, undefined behavior otherwise
32143214   switch (offset)
r9379r9380
33823382
33833383      case 0x0a/2:
33843384         // bit 0 is the framebuffer select, change is delayed until vblank;
3385      //  _32x_a1518a_reg = (_32x_a1518a_reg & 0xfffe);
3385      //   _32x_a1518a_reg = (_32x_a1518a_reg & 0xfffe);
33863386         if (ACCESSING_BITS_0_7)
33873387         {
33883388            _32x_fb_swap = data & 1;
r9379r9380
38613861static UINT16 segacd_imagebuffer_start_address;
38623862static UINT16 segacd_imagebuffer_offset;
38633863static tilemap_t    *segacd_stampmap[4];
3864static void segacd_mark_stampmaps_dirty(void);
3864//static void segacd_mark_stampmaps_dirty(void);
38653865
38663866
38673867static WRITE16_HANDLER( scd_a12000_halt_reset_w )
r9379r9380
39793979static READ16_HANDLER( segacd_sub_memory_mode_r )
39803980{
39813981   return (segacd_ram_writeprotect_bits << 8) |
3982       /*(segacd_4meg_prgbank << 6) | */
3982        /*(segacd_4meg_prgbank << 6) | */
39833983         (segacd_memory_priority_mode << 3) |
39843984         (segacd_ram_mode << 2) |
39853985         ((segacd_maincpu_has_ram_access^1) << 1) |
r9379r9380
43094309
43104310static READ16_HANDLER( scd_hint_vector_r )
43114311{
4312//  printf("read HINT offset %d\n", offset);
4312//   printf("read HINT offset %d\n", offset);
43134313
43144314   switch (offset&1)
43154315   {
r9379r9380
43394339{
43404340   // todo irqmask
43414341
4342   printf("segacd_gfx_conversion_timer_callback\n");
4342   //printf("segacd_gfx_conversion_timer_callback\n");
43434343
43444344   if (segacd_irq_mask & 0x02)
43454345      cputag_set_input_line(machine, "segacd_68k", 1, HOLD_LINE);
r9379r9380
43604360/*
43614361static const gfx_layout sega_8x8_layout =
43624362{
4363    8,8,
4364    SEGACD_NUM_TILES16,
4365    4,
4366    { 0,1,2,3 },
4367    { 8,12,0,4,24,28,16,20 },
4368    { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
4369    8*32
4363   8,8,
4364   SEGACD_NUM_TILES16,
4365   4,
4366   { 0,1,2,3 },
4367   { 8,12,0,4,24,28,16,20 },
4368   { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
4369   8*32
43704370};
43714371*/
43724372
r9379r9380
43774377#define _16x16_SEQUENCE_1_FLIP  { 512+20,512+16,512+28,512+24,512+4,512+0, 512+12,512+8, 20,16,28,24,4,0,12,8 },
43784378
43794379#define _16x16_SEQUENCE_2  { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32, 8*32, 9*32,10*32,11*32,12*32,13*32,14*32,15*32 },
4380#define _16x16_SEQUENCE_2_FLIP  { 16*32, 14*32, 13*32, 12*32, 11*32, 10*32, 9*32, 8*32, 7*32, 6*32, 5*32, 4*32, 3*32, 2*32, 1*32, 0*32 },
4380#define _16x16_SEQUENCE_2_FLIP  { 15*32, 14*32, 13*32, 12*32, 11*32, 10*32, 9*32, 8*32, 7*32, 6*32, 5*32, 4*32, 3*32, 2*32, 1*32, 0*32 },
43814381
43824382
43834383#define _16x16_START \
r9379r9380
44214421
44224422#define _32x32_SEQUENCE_2 \
44234423      { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32, \
4424       8*32, 9*32, 10*32, 11*32, 12*32, 13*32, 14*32, 15*32, \
4425    16*32,17*32,18*32,19*32,20*32,21*32,22*32,23*32, \
4424        8*32, 9*32, 10*32, 11*32, 12*32, 13*32, 14*32, 15*32, \
4425     16*32,17*32,18*32,19*32,20*32,21*32,22*32,23*32, \
44264426    24*32,25*32, 26*32, 27*32, 28*32, 29*32, 30*32, 31*32}, \
44274427
44284428#define _32x32_SEQUENCE_2_FLIP \
r9379r9380
45524552   gfx_element_mark_dirty(machine->gfx[15],(offset*2)/(SEGACD_BYTES_PER_TILE32));
45534553}
45544554
4555
45554556// mame specific.. map registers to which tilemap cache we use
45564557static int segacd_get_active_stampmap_tilemap(void)
45574558{
45584559   return (segacd_stampsize & 0x6)>>1;
45594560}
45604561
4562#if 0
45614563static void segacd_mark_stampmaps_dirty(void)
45624564{
45634565   tilemap_mark_all_tiles_dirty(segacd_stampmap[segacd_get_active_stampmap_tilemap()]);
r9379r9380
45674569   //tilemap_mark_all_tiles_dirty(segacd_stampmap[2]);
45684570   //tilemap_mark_all_tiles_dirty(segacd_stampmap[3]);
45694571}
4572#endif
45704573
4571static TILE_GET_INFO( get_stampmap_16x16_1x1_tile_info )
4574void SCD_GET_TILE_INFO_16x16_1x1( int& tile_region, int& tileno, int tile_index )
45724575{
4573   int tile_region = 0; // 16x16 tiles
4576   tile_region = 0; // 16x16 tiles
45744577   int tile_base = (segacd_stampmap_base_address & 0xff80) * 4;
45754578
45764579   int tiledat = segacd_dataram[((tile_base>>1)+tile_index) & 0x1ffff];
4577   int tileno = tiledat & 0x07ff;
4580   tileno = tiledat & 0x07ff;
45784581   int xflip =  tiledat & 0x8000;
45794582   int roll  =  (tiledat & 0x6000)>>13;
45804583
45814584   if (xflip) tile_region += 4;
45824585   tile_region+=roll;
4583
4584   SET_TILE_INFO(tile_region, tileno, 0, 0);
45854586}
45864587
4587static TILE_GET_INFO( get_stampmap_16x16_16x16_tile_info )
4588void SCD_GET_TILE_INFO_32x32_1x1( int& tile_region, int& tileno, int tile_index )
45884589{
4589   int tile_region = 0; // 16x16 tiles
4590   int tile_base = (0x8000) * 4; // fixed address in this mode
4590   tile_region = 8; // 32x32 tiles
4591   int tile_base = (segacd_stampmap_base_address & 0xffe0) * 4;
45914592
45924593   int tiledat = segacd_dataram[((tile_base>>1)+tile_index) & 0x1ffff];
4593   int tileno = tiledat & 0x07ff;
4594   tileno = (tiledat & 0x07fc)>>2;
45944595   int xflip =  tiledat & 0x8000;
45954596   int roll  =  (tiledat & 0x6000)>>13;
45964597
45974598   if (xflip) tile_region += 4;
45984599   tile_region+=roll;
4599
4600   SET_TILE_INFO(tile_region, tileno, 0, 0);
46014600}
46024601
4603static TILE_GET_INFO( get_stampmap_32x32_1x1_tile_info )
4602
4603void SCD_GET_TILE_INFO_16x16_16x16( int& tile_region, int& tileno, int tile_index )
46044604{
4605   int tile_region = 8; // 32x32 tiles
4606   int tile_base = (segacd_stampmap_base_address & 0xffe0) * 4;
4605   tile_region = 0; // 16x16 tiles
4606   int tile_base = (0x8000) * 4; // fixed address in this mode
46074607
46084608   int tiledat = segacd_dataram[((tile_base>>1)+tile_index) & 0x1ffff];
4609   int tileno = (tiledat & 0x07fc)>>2;
4609   tileno = tiledat & 0x07ff;
46104610   int xflip =  tiledat & 0x8000;
46114611   int roll  =  (tiledat & 0x6000)>>13;
46124612
46134613   if (xflip) tile_region += 4;
46144614   tile_region+=roll;
4615
4616   SET_TILE_INFO(tile_region, tileno, 0, 0);
46174615}
46184616
4619static TILE_GET_INFO( get_stampmap_32x32_16x16_tile_info )
4617
4618void SCD_GET_TILE_INFO_32x32_16x16( int& tile_region, int& tileno, int tile_index )
46204619{
4621   int tile_region = 8; // 32x32 tiles
4620   tile_region = 8; // 32x32 tiles
46224621   int tile_base = (segacd_stampmap_base_address & 0xe000) * 4;
46234622
46244623   int tiledat = segacd_dataram[((tile_base>>1)+tile_index) & 0x1ffff];
4625   int tileno = (tiledat & 0x07fc)>>2;
4624   tileno = (tiledat & 0x07fc)>>2;
46264625   int xflip =  tiledat & 0x8000;
46274626   int roll  =  (tiledat & 0x6000)>>13;
46284627
46294628   if (xflip) tile_region += 4;
46304629   tile_region+=roll;
4630}
46314631
4632/* Tilemap callbacks (we don't actually use the tilemaps due to the excessive overhead */
4633
4634
4635
4636static TILE_GET_INFO( get_stampmap_16x16_1x1_tile_info )
4637{
4638   int tile_region, tileno;
4639   SCD_GET_TILE_INFO_16x16_1x1(tile_region,tileno,(int)tile_index);
46324640   SET_TILE_INFO(tile_region, tileno, 0, 0);
46334641}
46344642
4643static TILE_GET_INFO( get_stampmap_32x32_1x1_tile_info )
4644{
4645   int tile_region, tileno;
4646   SCD_GET_TILE_INFO_32x32_1x1(tile_region,tileno,(int)tile_index);
4647   SET_TILE_INFO(tile_region, tileno, 0, 0);
4648}
46354649
46364650
4651static TILE_GET_INFO( get_stampmap_16x16_16x16_tile_info )
4652{
4653   int tile_region, tileno;
4654   SCD_GET_TILE_INFO_16x16_16x16(tile_region,tileno,(int)tile_index);
4655   SET_TILE_INFO(tile_region, tileno, 0, 0);
4656}
4657
4658static TILE_GET_INFO( get_stampmap_32x32_16x16_tile_info )
4659{
4660   int tile_region, tileno;
4661   SCD_GET_TILE_INFO_32x32_16x16(tile_region,tileno,(int)tile_index);
4662   SET_TILE_INFO(tile_region, tileno, 0, 0);
4663}
4664
4665// non-tilemap functions to get a pixel from a 'tilemap' based on the above, but looking up each pixel, as to avoid the heavy cache bitmap
4666
4667INLINE UINT8 get_stampmap_16x16_1x1_tile_info_pixel(running_machine* machine, UINT16 xpos, UINT16 ypos)
4668{
4669   const int tilesize = 4; // 0xf pixels
4670   const int tilemapsize = 0x0f;
4671   
4672   int wraparound = segacd_stampsize&1;
4673   wraparound = 1;
4674   
4675   int xtile = xpos / (1<<tilesize);
4676   int ytile = ypos / (1<<tilesize);
4677
4678   if (wraparound)
4679   {
4680      // wrap...
4681      xtile &= tilemapsize;
4682      ytile &= tilemapsize;
4683   }
4684   else
4685   {
4686      if (xtile>tilemapsize) return 0;
4687      if (xtile<0) return 0;
4688     
4689      if (ytile>tilemapsize) return 0;
4690      if (ytile<0) return 0;
4691   }
4692
4693   int tile_index = (ytile * (tilemapsize+1)) + xtile;
4694
4695   int tile_region, tileno;
4696   SCD_GET_TILE_INFO_16x16_1x1(tile_region,tileno,(int)tile_index);
4697
4698   const gfx_element *gfx = machine->gfx[tile_region];
4699   tileno %= gfx->total_elements;
4700   const UINT8* srcdata = gfx_element_get_data(gfx, tileno);
4701   return srcdata[((ypos&((1<<tilesize)-1))*(1<<tilesize))+(xpos&((1<<tilesize)-1))];
4702}
4703
4704INLINE UINT8 get_stampmap_32x32_1x1_tile_info_pixel(running_machine* machine, UINT16 xpos, UINT16 ypos)
4705{
4706   const int tilesize = 5; // 0x1f pixels
4707   const int tilemapsize = 0x07;
4708   
4709   int wraparound = segacd_stampsize&1;
4710   wraparound = 1;
4711   
4712   int xtile = xpos / (1<<tilesize);
4713   int ytile = ypos / (1<<tilesize);
4714
4715   if (wraparound)
4716   {
4717      // wrap...
4718      xtile &= tilemapsize;
4719      ytile &= tilemapsize;
4720   }
4721   else
4722   {
4723      if (xtile>tilemapsize) return 0;
4724      if (xtile<0) return 0;
4725     
4726      if (ytile>tilemapsize) return 0;
4727      if (ytile<0) return 0;
4728   }
4729   
4730   int tile_index = (ytile * (tilemapsize+1)) + xtile;
4731   
4732   int tile_region, tileno;
4733   SCD_GET_TILE_INFO_32x32_1x1(tile_region,tileno,(int)tile_index);
4734
4735   const gfx_element *gfx = machine->gfx[tile_region];
4736   tileno %= gfx->total_elements;
4737   const UINT8* srcdata = gfx_element_get_data(gfx, tileno);
4738   return srcdata[((ypos&((1<<tilesize)-1))*(1<<tilesize))+(xpos&((1<<tilesize)-1))];
4739}
4740
4741INLINE UINT8 get_stampmap_16x16_16x16_tile_info_pixel(running_machine* machine, UINT16 xpos, UINT16 ypos)
4742{
4743   const int tilesize = 4; // 0xf pixels
4744   const int tilemapsize = 0xff;
4745   
4746   int wraparound = segacd_stampsize&1;
4747   wraparound = 1;
4748   
4749   int xtile = xpos / (1<<tilesize);
4750   int ytile = ypos / (1<<tilesize);
4751
4752   if (wraparound)
4753   {
4754      // wrap...
4755      xtile &= tilemapsize;
4756      ytile &= tilemapsize;
4757   }
4758   else
4759   {
4760      if (xtile>tilemapsize) return 0;
4761      if (xtile<0) return 0;
4762     
4763      if (ytile>tilemapsize) return 0;
4764      if (ytile<0) return 0;
4765   }
4766
4767   int tile_index = (ytile * (tilemapsize+1)) + xtile;
4768
4769   int tile_region, tileno;
4770   SCD_GET_TILE_INFO_16x16_16x16(tile_region,tileno,(int)tile_index);
4771
4772   const gfx_element *gfx = machine->gfx[tile_region];
4773   tileno %= gfx->total_elements;
4774   const UINT8* srcdata = gfx_element_get_data(gfx, tileno);
4775   return srcdata[((ypos&((1<<tilesize)-1))*(1<<tilesize))+(xpos&((1<<tilesize)-1))];
4776}
4777
4778INLINE UINT8 get_stampmap_32x32_16x16_tile_info_pixel(running_machine* machine, UINT16 xpos, UINT16 ypos)
4779{
4780   const int tilesize = 5; // 0x1f pixels
4781   const int tilemapsize = 0x7f;
4782   
4783   int wraparound = segacd_stampsize&1;
4784   wraparound = 1;
4785   
4786   int xtile = xpos / (1<<tilesize);
4787   int ytile = ypos / (1<<tilesize);
4788
4789   if (wraparound)
4790   {
4791      // wrap...
4792      xtile &= tilemapsize;
4793      ytile &= tilemapsize;
4794   }
4795   else
4796   {
4797      if (xtile>tilemapsize) return 0;
4798      if (xtile<0) return 0;
4799     
4800      if (ytile>tilemapsize) return 0;
4801      if (ytile<0) return 0;
4802   }
4803   
4804   int tile_index = (ytile * (tilemapsize+1)) + xtile;
4805   
4806   int tile_region, tileno;
4807   SCD_GET_TILE_INFO_32x32_16x16(tile_region,tileno,(int)tile_index);
4808
4809   const gfx_element *gfx = machine->gfx[tile_region];
4810   tileno %= gfx->total_elements;
4811   const UINT8* srcdata = gfx_element_get_data(gfx, tileno);
4812   return srcdata[((ypos&((1<<tilesize)-1))*(1<<tilesize))+(xpos&((1<<tilesize)-1))];
4813}
4814
4815
4816
4817
46374818/* main CPU map set up in INIT */
46384819void segacd_init_main_cpu( running_machine* machine )
46394820{
r9379r9380
46934874
46944875   /* as a temporary measure we use the MAME tilemaps, this is hideously inefficient as we have to mark the active one as
46954876       dirty before each operation due to the RAM based tiles.  For the larger tilemaps this means we have to re-render a 4096x4096
4696       bitmap to the tilemap cache on each blit operation just to copy the few needed tiles out of it, needless to say, this is SLOW.
4697       Eventually the tilemaps will be replaced with a get_pixel function which will perform all the needed lookups on a per-pixel
4698       basis instead of re-rendering the whole thing */
4877      bitmap to the tilemap cache on each blit operation just to copy the few needed tiles out of it, needless to say, this is SLOW.
4878      Eventually the tilemaps will be replaced with a get_pixel function which will perform all the needed lookups on a per-pixel
4879      basis instead of re-rendering the whole thing */
46994880   segacd_stampmap[0] = tilemap_create(machine, get_stampmap_16x16_1x1_tile_info, tilemap_scan_rows, 16, 16, 16, 16);
47004881   segacd_stampmap[1] = tilemap_create(machine, get_stampmap_32x32_1x1_tile_info, tilemap_scan_rows, 32, 32, 8, 8);
47014882   segacd_stampmap[2] = tilemap_create(machine, get_stampmap_16x16_16x16_tile_info, tilemap_scan_rows, 16, 16, 256, 256); // 128kb!
r9379r9380
49635144   // ...
49645145
49655146   /*segacd_cdd.status = 0;
4966    segacd_cdd.minute = 0;
4967    segacd_cdd.seconds = 0;
4968    segacd_cdd.frame = 0;
4969    segacd_cdd.ext = 0;*/
5147   segacd_cdd.minute = 0;
5148   segacd_cdd.seconds = 0;
5149   segacd_cdd.frame = 0;
5150   segacd_cdd.ext = 0;*/
49705151
49715152   cdd_hock_irq(machine,1);
49725153}
r9379r9380
51045285   }
51055286}
51065287
5288// these functions won't cope if
5289//
5290// the lower 3 bits of segacd_imagebuffer_hdot_size are set
5291
5292// this really needs to be doing it's own lookups rather than depending on the inefficient MAME cache..
5293INLINE UINT8 read_pixel_from_stampmap( running_machine* machine, bitmap_t* srcbitmap, UINT16 x, UINT16 y)
5294{
5295/*
5296   if (!srcbitmap)
5297   {
5298      return mame_rand(machine);
5299   }
5300
5301   if (x >= srcbitmap->width) return 0;
5302   if (y >= srcbitmap->height) return 0;
5303   
5304   UINT16* cacheptr = BITMAP_ADDR16( srcbitmap, y, x);
5305
5306   return cacheptr[0] & 0xf;
5307*/
5308
5309   switch (segacd_get_active_stampmap_tilemap()&3)
5310   {
5311      case 0x00: return get_stampmap_16x16_1x1_tile_info_pixel( machine, x, y );
5312      case 0x01: return get_stampmap_32x32_1x1_tile_info_pixel( machine, x, y );
5313      case 0x02: return get_stampmap_16x16_16x16_tile_info_pixel( machine, x, y );
5314      case 0x03: return get_stampmap_32x32_16x16_tile_info_pixel( machine, x, y );
5315   }
5316   
5317   return 0;
5318}
5319
5320INLINE void write_pixel_to_imagebuffer( running_machine* machine, UINT32 pix, int line, int xpos )
5321{
5322
5323   UINT32 bufferstart = (segacd_imagebuffer_start_address&0xfff8)*2;
5324   UINT32 bufferend = bufferstart + (((segacd_imagebuffer_vcell_size+1) * (segacd_imagebuffer_hdot_size>>3)*0x20)/2);
5325   UINT32 offset;
5326
5327   offset = bufferstart+(((segacd_imagebuffer_vcell_size+1)*0x10)*xpos);
5328   
5329   // lines of each output cell
5330   offset+= (line*2);
5331         
5332   while (offset>=bufferend)
5333      offset-= bufferend;
5334   
5335   
5336   switch (segacd_memory_priority_mode)
5337   {
5338      case 0x00: // normal write, just write the data
5339         segacd_dataram[offset] = pix >> 16;
5340         segacd_dataram[offset+1] = pix & 0xffff;
5341         break;
5342         
5343      case 0x01: // underwrite, only write if the existing data is 0
5344         if ((segacd_dataram[offset]&0xf000) == 0x0000) segacd_dataram[offset] |= (pix>>16)&0xf000;
5345         if ((segacd_dataram[offset]&0x0f00) == 0x0000) segacd_dataram[offset] |= (pix>>16)&0x0f00;
5346         if ((segacd_dataram[offset]&0x00f0) == 0x0000) segacd_dataram[offset] |= (pix>>16)&0x00f0;
5347         if ((segacd_dataram[offset]&0x000f) == 0x0000) segacd_dataram[offset] |= (pix>>16)&0x000f;
5348         if ((segacd_dataram[offset+1]&0xf000) == 0x0000) segacd_dataram[offset+1] |= (pix)&0xf000;
5349         if ((segacd_dataram[offset+1]&0x0f00) == 0x0000) segacd_dataram[offset+1] |= (pix)&0x0f00;
5350         if ((segacd_dataram[offset+1]&0x00f0) == 0x0000) segacd_dataram[offset+1] |= (pix)&0x00f0;
5351         if ((segacd_dataram[offset+1]&0x000f) == 0x0000) segacd_dataram[offset+1] |= (pix)&0x000f;
5352         break;
5353         
5354      case 0x02: // overwrite, only write non-zero data
5355         if ((pix>>16)&0xf000) segacd_dataram[offset] = (segacd_dataram[offset] & 0x0fff) | ((pix>>16)&0xf000);
5356         if ((pix>>16)&0x0f00) segacd_dataram[offset] = (segacd_dataram[offset] & 0xf0ff) | ((pix>>16)&0x0f00);
5357         if ((pix>>16)&0x00f0) segacd_dataram[offset] = (segacd_dataram[offset] & 0xff0f) | ((pix>>16)&0x00f0);
5358         if ((pix>>16)&0x000f) segacd_dataram[offset] = (segacd_dataram[offset] & 0xfff0) | ((pix>>16)&0x000f);
5359         if ((pix)&0xf000) segacd_dataram[offset+1] = (segacd_dataram[offset+1] & 0x0fff) | ((pix)&0xf000);
5360         if ((pix)&0x0f00) segacd_dataram[offset+1] = (segacd_dataram[offset+1] & 0xf0ff) | ((pix)&0x0f00);
5361         if ((pix)&0x00f0) segacd_dataram[offset+1] = (segacd_dataram[offset+1] & 0xff0f) | ((pix)&0x00f0);
5362         if ((pix)&0x000f) segacd_dataram[offset+1] = (segacd_dataram[offset+1] & 0xfff0) | ((pix)&0x000f);
5363         break;
5364         
5365      default:
5366      case 0x03: // invalid?
5367         segacd_dataram[offset] = mame_rand(machine);
5368         segacd_dataram[offset+1] = mame_rand(machine);
5369         break;
5370   
5371   }
5372   
5373   segacd_mark_tiles_dirty(machine, offset);
5374   segacd_mark_tiles_dirty(machine, offset+1);
5375
5376}
5377
51075378// this triggers the conversion operation, which will cause an IRQ1 when finished
51085379WRITE16_HANDLER( segacd_trace_vector_base_address_w )
51095380{
r9379r9380
51125383      printf("ILLEGAL: segacd_trace_vector_base_address_w %04x %04x in mode 1!\n",data,mem_mask);
51135384   }
51145385
5115   logerror("segacd_trace_vector_base_address_w %04x %04x\n",data,mem_mask);
5386   //printf("segacd_trace_vector_base_address_w %04x %04x\n",data,mem_mask);
51165387
51175388   {
51185389      int base = (data & 0xfffe) * 4;
r9379r9380
51205391      logerror("actual base = %06x\n", base + 0x80000);
51215392
51225393      // nasty nasty nasty
5123      segacd_mark_stampmaps_dirty();
5394      //segacd_mark_stampmaps_dirty();
51245395
51255396      segacd_conversion_active = 1;
51265397
r9379r9380
51285399      timer_adjust_oneshot(segacd_gfx_conversion_timer, ATTOTIME_IN_HZ(1000), 0);
51295400
51305401
5131      int i;
5402      int line;
5403      //bitmap_t *srcbitmap = tilemap_get_pixmap(segacd_stampmap[segacd_get_active_stampmap_tilemap()]);
5404      bitmap_t *srcbitmap = 0;
51325405
5133      for (i=0;i<segacd_imagebuffer_vdot_size;i++)
5406      for (line=0;line<segacd_imagebuffer_vdot_size;line++)
51345407      {
5135         int currbase = base + i * 0x8;
5136         UINT16 param1 = segacd_dataram[(currbase+0x0)>>1];
5137         UINT16 param2 = segacd_dataram[(currbase+0x2)>>1];
5138         UINT16 param3 = segacd_dataram[(currbase+0x4)>>1];
5139         UINT16 param4 = segacd_dataram[(currbase+0x6)>>1];
5408         int currbase = base + line * 0x8;
5409         UINT16 param1,param2,param3,param4;
5410         
5411         param1 = segacd_dataram[(currbase+0x0)>>1];
5412         param2 = segacd_dataram[(currbase+0x2)>>1];
5413         param3 = segacd_dataram[(currbase+0x4)>>1];
5414         param4 = segacd_dataram[(currbase+0x6)>>1];
51405415
51415416
5142         logerror("%06x:  %04x %04x %04x %04x\n", currbase, param1, param2, param3, param4);
5417         //printf("%06x:  %04x (%d) %04x (%d) %04x %04x\n", currbase, param1, param1>>3, param2, param2>>3, param3, param4);
51435418
5144      }
5145
5146      {
5147         // not real code.. yet
5148         // should copy part of the stamp into the imagebuffer area using the rotation / zooming parameters given
5149         // (while we're using the MAME tilemaps that means, part of the tilemap cache into the ram buffer for the image)
5150
5151         bitmap_t *srcbitmap = tilemap_get_pixmap(segacd_stampmap[segacd_get_active_stampmap_tilemap()]);
5152         UINT16* x;
5153         x = BITMAP_ADDR16(srcbitmap,10,10);
5154         UINT16 datax;
5155         datax = x[0];
5156
5157         // I don't quite understand what happens if the lower bits of hdotsize are set.. do we end up rounding up?
5158         // this 'buffersize' clearly fills the frame for the SegaCD logo screen at least
5159         int buffersize = ((segacd_imagebuffer_vcell_size+1) * (segacd_imagebuffer_hdot_size>>3)*0x20)/2;  // 0x20 = 8x8x4 tile, /2 due to word offset
5160         //buffersize -= 8;
5161
5162         for (int i=0;i< buffersize ;i++)
5419         int xbase = param1 << 8;
5420         int ybase = param2 << 8;
5421         int count;
5422                 
5423         for (count=0;count<(segacd_imagebuffer_hdot_size>>3);count++)
51635424         {
5164            int offsetx = ((segacd_imagebuffer_start_address&0xfff8)*2)+i;
5425            int i;
5426            UINT32 pixblock = 0x00000000;
5427            for (i=7*4;i>=0;i-=4)
5428            {   
5429               pixblock |= read_pixel_from_stampmap(space->machine, srcbitmap, xbase>>(3+8), ybase>>(3+8)) << (i);
5430               
5431               if (param3&0x8000)
5432                  xbase -= param3&0x7fff;
5433               else
5434                  xbase += param3&0x7fff;
5435                 
5436               if (param4&0x8000)
5437                  ybase -= param4&0x7fff;
5438               else
5439                  ybase += param4&0x7fff;
5440               
51655441
5166            //printf("data write %08x\n", offsetx*2);
5167
5168
5169            segacd_dataram[offsetx]=mame_rand(space->machine);
5170
5171            segacd_mark_tiles_dirty(space->machine, offsetx);
5442            }
5443           
5444           
5445           
5446           
5447            write_pixel_to_imagebuffer(space->machine, pixblock, line, count);
51725448         }
51735449
5174
51755450      }
5176
51775451   }
51785452
51795453}
r9379r9380
51865460
51875461WRITE16_HANDLER( segacd_imagebuffer_vdot_size_w )
51885462{
5189   printf("segacd_imagebuffer_vdot_size_w %04x %04x\n",data,mem_mask);
5463   //printf("segacd_imagebuffer_vdot_size_w %04x %04x\n",data,mem_mask);
51905464   COMBINE_DATA(&segacd_imagebuffer_vdot_size);
51915465}
51925466
r9379r9380
52175491{
52185492   COMBINE_DATA(&segacd_imagebuffer_start_address);
52195493
5220   int base = (segacd_imagebuffer_start_address & 0xfffe) * 4;
5221
5222   printf("segacd_imagebuffer_start_address_w %04x %04x (actual base = %06x)\n", data, segacd_imagebuffer_start_address, base);
5494   //int base = (segacd_imagebuffer_start_address & 0xfffe) * 4;
5495   //printf("segacd_imagebuffer_start_address_w %04x %04x (actual base = %06x)\n", data, segacd_imagebuffer_start_address, base);
52235496}
52245497
52255498static READ16_HANDLER( segacd_imagebuffer_offset_r )
r9379r9380
52705543
52715544   AM_RANGE(0xff8004 ,0xff8005) AM_READWRITE(segacd_cdc_mode_address_r, segacd_cdc_mode_address_w)
52725545   AM_RANGE(0xff8006 ,0xff8007) AM_READWRITE(segacd_cdc_data_r, segacd_cdc_data_w)
5273//  AM_RANGE(0xff8008, 0xff8009) // CDC Host Data
5274//  AM_RANGE(0xff800a, 0xff800b) // CDC DMA Address
5275//  AM_RANGE(0xff800c, 0xff800d) // Stopwatch timer
5546//   AM_RANGE(0xff8008, 0xff8009) // CDC Host Data
5547//   AM_RANGE(0xff800a, 0xff800b) // CDC DMA Address
5548//   AM_RANGE(0xff800c, 0xff800d) // Stopwatch timer
52765549   AM_RANGE(0xff800e ,0xff800f) AM_READWRITE(segacd_comms_flags_r, segacd_comms_flags_subcpu_w)
52775550   AM_RANGE(0xff8010 ,0xff801f) AM_READWRITE(segacd_comms_sub_part1_r, segacd_comms_sub_part1_w)
52785551   AM_RANGE(0xff8020 ,0xff802f) AM_READWRITE(segacd_comms_sub_part2_r, segacd_comms_sub_part2_w)
5279//  AM_RANGE(0xff8030, 0xff8031) // Timer W/INT3
5552//   AM_RANGE(0xff8030, 0xff8031) // Timer W/INT3
52805553   AM_RANGE(0xff8032, 0xff8033) AM_READWRITE(segacd_irq_mask_r,segacd_irq_mask_w)
52815554   AM_RANGE(0xff8034, 0xff8035) AM_NOP // CD Fader
52825555   AM_RANGE(0xff8036, 0xff8037) AM_READWRITE(segacd_cdd_ctrl_r,segacd_cdd_ctrl_w)
52835556   AM_RANGE(0xff8038, 0xff8041) AM_READ8(segacd_cdd_rx_r,0xffff)
52845557   AM_RANGE(0xff8042, 0xff804b) AM_WRITE8(segacd_cdd_tx_w,0xffff)
5285//  AM_RANGE(0xff804c, 0xff804d) // Font Color
5286//  AM_RANGE(0xff804e, 0xff804f) // Font bit
5287//  AM_RANGE(0xff8050, 0xff8057) // Font data (read only)
5558//   AM_RANGE(0xff804c, 0xff804d) // Font Color
5559//   AM_RANGE(0xff804e, 0xff804f) // Font bit
5560//   AM_RANGE(0xff8050, 0xff8057) // Font data (read only)
52885561   AM_RANGE(0xff8058, 0xff8059) AM_READWRITE(segacd_stampsize_r, segacd_stampsize_w) // Stamp size
52895562   AM_RANGE(0xff805a, 0xff805b) AM_READWRITE(segacd_stampmap_base_address_r, segacd_stampmap_base_address_w) // Stamp map base address
52905563   AM_RANGE(0xff805c, 0xff805d) AM_READWRITE(segacd_imagebuffer_vcell_size_r, segacd_imagebuffer_vcell_size_w)// Image buffer V cell size
r9379r9380
52935566   AM_RANGE(0xff8062, 0xff8063) AM_READWRITE(segacd_imagebuffer_hdot_size_r, segacd_imagebuffer_hdot_size_w) // Image buffer H dot size
52945567   AM_RANGE(0xff8064, 0xff8065) AM_READWRITE(segacd_imagebuffer_vdot_size_r, segacd_imagebuffer_vdot_size_w ) // Image buffer V dot size
52955568   AM_RANGE(0xff8066, 0xff8067) AM_WRITE(segacd_trace_vector_base_address_w)// Trace vector base address
5296//  AM_RANGE(0xff8068, 0xff8069) // Subcode address
5569//   AM_RANGE(0xff8068, 0xff8069) // Subcode address
52975570
5298//  AM_RANGE(0xff8100, 0xff817f) // Subcode buffer area
5299//  AM_RANGE(0xff8180, 0xff81ff) // mirror of subcode buffer area
5571//   AM_RANGE(0xff8100, 0xff817f) // Subcode buffer area
5572//   AM_RANGE(0xff8180, 0xff81ff) // mirror of subcode buffer area
53005573
53015574ADDRESS_MAP_END
53025575

Previous 15994 Revisions Next


© 1998-2018 The MESS Team