Previous 199869 Revisions Next

r21315 Friday 22nd February, 2013 at 14:38:01 UTC by David Haywood
further code reorg, this seems to upset some of the fb logging, find out why.
[src/mame/drivers]coolridr.c

trunk/src/mame/drivers/coolridr.c
r21314r21315
445445   DECLARE_WRITE32_MEMBER(sysh1_sound_dma_w);
446446   DECLARE_READ32_MEMBER(sysh1_ioga_r);
447447   DECLARE_WRITE32_MEMBER(sysh1_ioga_w);
448   DECLARE_WRITE32_MEMBER(sysh1_txt_blit_w);
448   DECLARE_WRITE32_MEMBER(sysh1_unk_blit_w);
449   DECLARE_WRITE32_MEMBER(sysh1_blit_mode_w);
450   DECLARE_WRITE32_MEMBER(sysh1_blit_data_w);
451   DECLARE_WRITE32_MEMBER(sysh1_fb_mode_w);
452   DECLARE_WRITE32_MEMBER(sysh1_fb_data_w);
453
449454   DECLARE_WRITE32_MEMBER(sysh1_pal_w);
450455   DECLARE_WRITE32_MEMBER(sysh1_dma_w);
451456   DECLARE_WRITE32_MEMBER(sysh1_char_w);
r21314r21315
467472   UINT32 screen_update_coolridr(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int which);
468473   UINT32 screen_update_coolridr1(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
469474   UINT32 screen_update_coolridr2(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
475   void blit_current_sprite(address_space &space);
470476   INTERRUPT_GEN_MEMBER(system_h1);
471477   TIMER_DEVICE_CALLBACK_MEMBER(system_h1_main);
472478   TIMER_DEVICE_CALLBACK_MEMBER(system_h1_sub);
r21314r21315
607613}
608614#endif
609615
616/* This is a RLE-based sprite blitter (US Patent #6,141,122), very unusual from Sega... */
617void coolridr_state::blit_current_sprite(address_space &space)
618{
619   const pen_t *clut = &machine().pens[0];
610620
621   // Serialized 32-bit words in order of appearance:
622   //  0: 00000000 - unknown, 0x00000000 or 0x00000001, 0 seems to be regular sprite, 1 seems to change meaning of below, possible clip area?
623   //  1: 00010000 - unknown, color mode? (7bpp select?) set on player bike object
624   //  1: 00000xxx - "Color Number" (all bits or just lower 16/8?)
625   //  2: 007f0000 - unknown, transpen? set to 0x7f whenever the 'color mode' bit in (1) is set, otherwise 0
626   //  2: 00000xxx - unknown, usually a copy of color number, leftover?
627   //  3: 001fffff - offset to compressed data? (it's 0 on text objects tho, but maybe the ascii tiles are a special decode to go with the indirect mode)
628   //  4: 07000000 - unknown (draw mode?)
629   //  4: 00010000 - unknown (set on a few object)
630   //  4: 00000100 - y-flip?
631   //  4: 00000001 - x-flip?
632   //  5: 00010000 - enable indirect text tile lookup
633   //  5: 00000001 - enable line-zoom(?) lookup (road)
634   //  6: vvvv---- - "Vertical Cell Count"
635   //  6: ----hhhh - "Horizontal Cell Count"
636   //  7: 00030003 - "Vertical|Horizontal Origin point"
637   //  8: 00ff00ff - "Vertical|Horizontal Zoom Ratios"
638   //  9: xxxx---- - "Display Vertical Position"
639   //  9: ----yyyy - "Display Horizontal Position"
640   // 10: 00000000 - unknown : always seems to be zero - NO, for some things (not text) it's also a reference to 3f40000 region like #11
641   // 11: ........ - indirect tile mode ram address (used for text)
611642
612/*
613         if(type == 4)
614643
644   // first parse the bits
615645
616*/
646   /************* m_spriteblit[0] *************/
617647
618/* This is a RLE-based sprite blitter (US Patent #6,141,122), very unusual from Sega... */
619WRITE32_MEMBER(coolridr_state::sysh1_txt_blit_w)
620{
621   COMBINE_DATA(&m_sysh1_txt_blit[offset]);
622   const pen_t *clut = &machine().pens[0];
648   // set to 0x00000001 on some objects during the 'film strip' part of attract, otherwise 0
649   // those objects don't seem visible anyway so might have some special meaning
650   // this is also set at times during the game
651   //
652   // the sprites with 1 set appear to have 0x00000000 in everything after the 4th write (blit4 and above)
653   // so likely have some other meaning and are NOT regular sprite data
654   UINT32 blit0 = m_spriteblit[0];
623655
624   switch(offset)
625   {
626      /*
627      This does the fb display/clear phases of blitter data processed in the previous frame.
628      And yes, game effectively runs at 30 Hz (because data processing happens on even frames, actual display transfer happens on odd frames).
629      screen 1
630      8c200000 06
631      00000001 07
632      0000017f 07 Y range (upper start, lower end)
633      000701f7 07 X range (upper start, lower end)
634      00000007 07 enable?
635      screen 2
636      8c800000 06
637      00000001 07
638      0000017f 07
639      020703f7 07
640      00000207 07 enable plus clear?
641      */
642      case 0x06:
643         m_blitterClearMode = m_sysh1_txt_blit[offset];
656   // abort early..
657   if (blit0!=0)
658      return;
644659
645         if(m_blitterClearMode != 0x8c200000 && m_blitterClearMode != 0x8c800000)
646            printf("Blitter Clear used with param %08x\n",m_blitterClearMode);
660   /************* m_spriteblit[1] *************/
661   
662   // 000u0ccc  - c = colour? u = 0/1
663   UINT32 blit1_unused = m_spriteblit[1] & 0xfffef800;
664   UINT32 b1mode = (m_spriteblit[1] & 0x00010000)>>16;
665   //UINT32 b1colorNumber = (m_spriteblit[1] & 0x000007ff);    // Probably more bits
647666
648         m_blitterClearCount = 0;
649         break;
667   if (blit1_unused!=0) printf("blit1 unknown bits set %08x\n", m_spriteblit[1]);
650668
651      case 0x07:
652         if(m_blitterClearCount == 0)
653         {
654            if(m_sysh1_txt_blit[offset] != 1)
655               printf("Blitter Clear Count == 0 used with param %08x\n",m_sysh1_txt_blit[offset]);
656         }
657         else if(m_blitterClearCount == 1)
658         {
659            if(m_sysh1_txt_blit[offset] != 0x17f)
660               printf("Blitter Clear Count == 1 used with param %08x\n",m_sysh1_txt_blit[offset]);
661         }
662         else if(m_blitterClearCount == 2)
663         {
664            if(m_sysh1_txt_blit[offset] != 0x000701f7 && m_sysh1_txt_blit[offset] != 0x020703f7)
665               printf("Blitter Clear Count == 2 used with param %08x\n",m_sysh1_txt_blit[offset]);
666         }
667         else if(m_blitterClearCount == 3)
668         {
669            if(m_sysh1_txt_blit[offset] != 0x00000007 && m_sysh1_txt_blit[offset] != 0x00000207)
670               printf("Blitter Clear Count == 3 used with param %08x\n",m_sysh1_txt_blit[offset]);
669   /************* m_spriteblit[3] *************/
670   
671   // seems to be more complex than just transparency
672   UINT32 blit2_unused = m_spriteblit[2]&0xff80f800;
673   UINT32 b2tpen = (m_spriteblit[2] & 0x007f0000)>>16;
674   //UINT32 b2colorNumber = (m_spriteblit[2] & 0x000007ff);
671675
672            {
673               const rectangle& visarea = machine().primary_screen->visible_area();
676   if (blit2_unused!=0) printf("blit1 unknown bits set %08x\n", m_spriteblit[2]);
677   if (b1mode)
678   {
679      if (b2tpen != 0x7f) printf("b1mode 1, b2tpen!=0x7f\n");
680   }
681   else
682   {
683      // 0x01/0x02 trips in rare cases (start of one of the attract levels) maybe this is some kind of alpha instead?
684      if ((b2tpen != 0x00) && (b2tpen != 0x01) && (b2tpen != 0x02)) printf("b1mode 0, b2tpen!=0x00,0x01 or 0x02 (is %02x)\n", b2tpen);
685   }
686    // 00??0uuu
687    // ?? seems to be 00 or 7f, set depending on b1mode
688    // uuu, at least 11 bits used, maybe 12 usually the same as blit1_unused? leftover?
674689
675               if(m_blitterClearMode == 0x8c200000)
676               {
677                  copybitmap(m_screen1_bitmap, m_temp_bitmap_sprites, 0, 0, 0, 0, visarea);
678                  m_temp_bitmap_sprites.fill(0, visarea);
679               }
690   /************* m_spriteblit[3] *************/
680691
681               if(m_blitterClearMode == 0x8c800000)
682               {
683                  copybitmap(m_screen2_bitmap, m_temp_bitmap_sprites2, 0, 0, 0, 0, visarea);
684                  m_temp_bitmap_sprites2.fill(0, visarea);
685               }
686            }
687         }
688         else
689         {
690            printf("Blitter Clear Count == %02x used with param %08x\n",m_blitterClearCount,m_sysh1_txt_blit[offset]);
691         }
692   UINT32 blit3_unused = m_spriteblit[3] & 0xffe00000;
693   UINT32 b3romoffset = (m_spriteblit[3] & 0x001fffff)*2;
694   // if this is an offset into the compressed m_spriteblit[3] then it's probably a word offset into each rom (each is 0x400000 bytes) with the m_spriteblit[3] from all 10 being used in parallel as per the notes from Charles
695   // this needs verifying as it could instead be an index into some other ram area already decompressed..
696   // 0000xxxx
697   //  to
698   // 001fxxxx
692699
700   if (blit3_unused) printf("unknown bits in blit word %d -  %08x\n", m_blitterSerialCount, blit3_unused);
701   
693702
694         m_blitterClearCount++;
695         break;
703   /************* m_spriteblit[4] *************/
696704
697      // The mode register
698      case 0x04:
699      {
700         m_blitterMode = (data & 0x00ff0000) >> 16;
705   UINT32 blit4_unused = m_spriteblit[4] & 0xf8fefefe;
706   //UINT32 blit4 = m_spriteblit[4] & 0x07000000;
707   UINT32 blit_flipx = m_spriteblit[4] & 0x00000001;
708   UINT32 blit_flipy = (m_spriteblit[4] & 0x00000100)>>8;
709   UINT32 blit_rotate = (m_spriteblit[4] & 0x00010000)>>16;
710   if (blit4_unused) printf("unknown bits in blit word %d -  %08x\n", m_blitterSerialCount, blit4_unused);
701711
702         if (m_blitterMode == 0xf4)
703         {
704            // Some sort of addressing state.
705            // In the case of text, simply writes 4 characters per 32-bit word.
706            // These values may be loaded into RAM somewhere as they are written.
707            // The number of characters is determined by the upper-most 8 bits.
708            m_textBytesToWrite = (data & 0xff000000) >> 24;
709            m_textOffset = (data & 0x0000ffff);
710            m_blitterSerialCount = 0;
712   // ---- -111 ---- ---r ---- ---y ---- ---x
713   // 1 = used bits? (unknown purpose.. might be object colour mode)
714   // x = x-flip
715   // y = y-flip
716   // r = unknown, not used much, occasional object - rotate
711717
712            // this is ONLY used when there is text on the screen
718   /************* m_spriteblit[5] *************/
713719
714            //printf("set mode %08x\n", data);
720   UINT32 blit5_unused = m_spriteblit[5]&0xfffefffe;
721   // this might enable the text indirection thing?
722   int indirect_tile_enable = (m_spriteblit[5] & 0x00010000)>>16;
723   int indirect_zoom_enable = (m_spriteblit[5] & 0x00000001);
715724
716725
717         }
718         else if (m_blitterMode == 0x30 || m_blitterMode == 0x40 || m_blitterMode == 0x50 || m_blitterMode == 0x60
719              || m_blitterMode == 0x90 || m_blitterMode == 0xa0 || m_blitterMode == 0xb0 || m_blitterMode == 0xc0)
720         {
721            // The blitter function(s).
722            // After this is set a fixed count of 11 32-bit words are sent to the data register.
723            // The lower word always seems to be 0x0001 and the upper byte always 0xac.
724            m_blitterSerialCount = 0;
726   if (blit5_unused) printf("unknown bits in blit word %d -  %08x\n", m_blitterSerialCount, blit5_unused);
727   // 00010000 (text)
728   // 00000001 (other)
725729
726            // form 0xacMM-xxx   ac = fixed value for this mode?  MM = modes above.  -xxx = some kind of offset? but it doesn't increment for each blit like the textOffset / paletteOffset stuff, investigate
727730
728         }
729         else if (m_blitterMode == 0x10)
730         {
731            // Could be a full clear of VRAM?
732            for(UINT32 vramAddr = 0x3f40000; vramAddr < 0x3f4ffff; vramAddr+=4)
733               space.write_dword(vramAddr, 0x00000000);
734731
735            m_blitterSerialCount = 0;
736         }
737         else if (m_blitterMode == 0xe0)
738         {
739            // uploads palettes...
740            // does NOT upload the palette for the WDUD screen when set to US mode this way..
741            m_blitterSerialCount = 0;
742            m_textOffset = (data & 0x0000ffff)>>2; // it's a byte offset
743732
744         //   printf("set e0 %08x\n", data);
733   /************* m_spriteblit[6] *************/
745734
746         }
747         else
748         {
749            printf("set unknown blit mode %02x\n", m_blitterMode);
750         }
751         break;
752      }
735   UINT16 vCellCount = (m_spriteblit[6] & 0xffff0000) >> 16;
736   UINT16 hCellCount = (m_spriteblit[6] & 0x0000ffff);
753737
754      // The data register
755      case 0x05:
756      {
757         if (m_blitterMode == 0xf4)
758         {
759            // Uploads a series of bytes that index into the encoded sprite table
760            const size_t memOffset = 0x03f40000 + m_textOffset + m_blitterSerialCount;
761            space.write_dword(memOffset, data);
762            m_blitterSerialCount += 0x04;
738   /************* m_spriteblit[7] *************/
763739
764            // DEBUG: Uncomment to see the ASCII strings as they are being blitted
765            //if (m_blitterSerialCount >= m_textBytesToWrite)
766            //{
767            //  for (int i = 0; i < m_textBytesToWrite+1; i++)
768            //      printf("%c", read_byte(0x03f40000 + m_textOffset + i));
769            //  printf("\n");
770            //}
771         }
772         else if (m_blitterMode == 0x30 || m_blitterMode == 0x40 || m_blitterMode == 0x50 || m_blitterMode == 0x60
773              || m_blitterMode == 0x90 || m_blitterMode == 0xa0 || m_blitterMode == 0xb0 || m_blitterMode == 0xc0)
774         {
775            // Serialized 32-bit words in order of appearance:
776            //  0: 00000000 - unknown, 0x00000000 or 0x00000001, 0 seems to be regular sprite, 1 seems to change meaning of below, possible clip area?
777            //  1: 00010000 - unknown, color mode? (7bpp select?) set on player bike object
778            //  1: 00000xxx - "Color Number" (all bits or just lower 16/8?)
779            //  2: 007f0000 - unknown, transpen? set to 0x7f whenever the 'color mode' bit in (1) is set, otherwise 0
780            //  2: 00000xxx - unknown, usually a copy of color number, leftover?
781            //  3: 001fffff - offset to compressed data? (it's 0 on text objects tho, but maybe the ascii tiles are a special decode to go with the indirect mode)
782            //  4: 07000000 - unknown (draw mode?)
783            //  4: 00010000 - unknown (set on a few object)
784            //  4: 00000100 - y-flip?
785            //  4: 00000001 - x-flip?
786            //  5: 00010000 - enable indirect text tile lookup
787            //  5: 00000001 - enable line-zoom(?) lookup (road)
788            //  6: vvvv---- - "Vertical Cell Count"
789            //  6: ----hhhh - "Horizontal Cell Count"
790            //  7: 00030003 - "Vertical|Horizontal Origin point"
791            //  8: 00ff00ff - "Vertical|Horizontal Zoom Ratios"
792            //  9: xxxx---- - "Display Vertical Position"
793            //  9: ----yyyy - "Display Horizontal Position"
794            // 10: 00000000 - unknown : always seems to be zero - NO, for some things (not text) it's also a reference to 3f40000 region like #11
795            // 11: ........ - complex - likely an address into bytes uploaded by mode 0xf4  (likely, it's only used when text is present otherwise it's always 0, some indirect tile mode I guess)
796            //                (See ifdef'ed out code below for a closer examination)
740   UINT16 vOrigin = (m_spriteblit[7] & 0xffff0000) >> 16;
741   UINT16 hOrigin = (m_spriteblit[7] & 0x0000ffff);
742   //printf("%04x %04x\n", vOrigin, hOrigin);
797743
798            // Serialized counts
799            if (m_blitterSerialCount < 12)
800            {
801               m_spriteblit[m_blitterSerialCount] = data;
802               m_blitterSerialCount++;
803            }
804            else
805            {
806               printf("more than 11 dwords (%d) in blit?\n", m_blitterSerialCount);
807            }
744   /************* m_spriteblit[8] *************/
808745
809            // use the 11th blit write also as the trigger
810            if (m_blitterSerialCount == 12)
811            {
812               // first parse the bits
746   UINT16 vZoom = (m_spriteblit[8] & 0xffff0000) >> 16;
747   UINT16 hZoom = (m_spriteblit[8] & 0x0000ffff);
813748
814               /************* m_spriteblit[0] *************/
749   /************* m_spriteblit[9] *************/
815750
816               // set to 0x00000001 on some objects during the 'film strip' part of attract, otherwise 0
817               // those objects don't seem visible anyway so might have some special meaning
818               // this is also set at times during the game
819               //
820               // the sprites with 1 set appear to have 0x00000000 in everything after the 4th write (blit4 and above)
821               // so likely have some other meaning and are NOT regular sprite data
822               UINT32 blit0 = m_spriteblit[0];
751   int vPosition = (m_spriteblit[9] & 0xffff0000) >> 16;
752   int hPosition = (m_spriteblit[9] & 0x0000ffff);
823753
824               // abort early..
825               if (blit0!=0)
826                  return;
754   if (hPosition & 0x8000) hPosition -= 0x10000;
755   if (vPosition & 0x8000) vPosition -= 0x10000;
827756
828               /************* m_spriteblit[1] *************/
829               
830               // 000u0ccc  - c = colour? u = 0/1
831               UINT32 blit1_unused = m_spriteblit[1] & 0xfffef800;
832               UINT32 b1mode = (m_spriteblit[1] & 0x00010000)>>16;
833               //UINT32 b1colorNumber = (m_spriteblit[1] & 0x000007ff);    // Probably more bits
757   /************* m_spriteblit[10] *************/
834758
835               if (blit1_unused!=0) printf("blit1 unknown bits set %08x\n", m_spriteblit[1]);
836         
837               /************* m_spriteblit[3] *************/
838               
839               // seems to be more complex than just transparency
840               UINT32 blit2_unused = m_spriteblit[2]&0xff80f800;
841               UINT32 b2tpen = (m_spriteblit[2] & 0x007f0000)>>16;
842               //UINT32 b2colorNumber = (m_spriteblit[2] & 0x000007ff);
759   // this is an address on some objects..
760   // to be specific, the center line of the road (actual road object? which currently gets shown as a single pixel column?)
761   // and the horizontal road used in the background of the title screen (which currently looks normal)
762   // I guess it's some kind of indirect way to do a line effect?
763   //UINT32 blit10 =  m_spriteblit[10];
843764
844               if (blit2_unused!=0) printf("blit1 unknown bits set %08x\n", m_spriteblit[2]);
845               if (b1mode)
846               {
847                  if (b2tpen != 0x7f) printf("b1mode 1, b2tpen!=0x7f\n");
848               }
849               else
850               {
851                  // 0x01/0x02 trips in rare cases (start of one of the attract levels) maybe this is some kind of alpha instead?
852                  if ((b2tpen != 0x00) && (b2tpen != 0x01) && (b2tpen != 0x02)) printf("b1mode 0, b2tpen!=0x00,0x01 or 0x02 (is %02x)\n", b2tpen);
853               }
854                // 00??0uuu
855                // ?? seems to be 00 or 7f, set depending on b1mode
856                // uuu, at least 11 bits used, maybe 12 usually the same as blit1_unused? leftover?
857         
858               /************* m_spriteblit[3] *************/
765   /************* m_spriteblit[11] *************/
766   
767   UINT32 textlookup =  m_spriteblit[11];
859768
860               UINT32 blit3_unused = m_spriteblit[3] & 0xffe00000;
861               UINT32 b3romoffset = (m_spriteblit[3] & 0x001fffff)*2;
862               // if this is an offset into the compressed m_spriteblit[3] then it's probably a word offset into each rom (each is 0x400000 bytes) with the m_spriteblit[3] from all 10 being used in parallel as per the notes from Charles
863               // this needs verifying as it could instead be an index into some other ram area already decompressed..
864               // 0000xxxx
865               //  to
866               // 001fxxxx
769   /* DRAW */
770   UINT16 used_hCellCount = hCellCount;
771   UINT16 used_vCellCount = vCellCount;
772   UINT16 used_flipx = blit_flipx;
773   UINT16 used_flipy = blit_flipy;
867774
868               if (blit3_unused) printf("unknown bits in blit word %d -  %08x\n", m_blitterSerialCount, blit3_unused);
869               
775   if (blit_rotate)
776   {
777      used_hCellCount = vCellCount;
778      used_vCellCount = hCellCount;
779      used_flipx = blit_flipy;
780      used_flipy = blit_flipx;
781      // do the zoom params rotate?
782   }
870783
871               /************* m_spriteblit[4] *************/
784   // SPRITES / BLITS
872785
873               UINT32 blit4_unused = m_spriteblit[4] & 0xf8fefefe;
874               //UINT32 blit4 = m_spriteblit[4] & 0x07000000;
875               UINT32 blit_flipx = m_spriteblit[4] & 0x00000001;
876               UINT32 blit_flipy = (m_spriteblit[4] & 0x00000100)>>8;
877               UINT32 blit_rotate = (m_spriteblit[4] & 0x00010000)>>16;
878               if (blit4_unused) printf("unknown bits in blit word %d -  %08x\n", m_blitterSerialCount, blit4_unused);
786   // for text objects this is an address containing the 8-bit tile numbers to use for ASCII text
787   // I guess the tiles are decoded by a DMA operation earlier, from the compressed ROM?
879788
880               // ---- -111 ---- ---r ---- ---y ---- ---x
881               // 1 = used bits? (unknown purpose.. might be object colour mode)
882               // x = x-flip
883               // y = y-flip
884               // r = unknown, not used much, occasional object - rotate
885           
886               /************* m_spriteblit[5] *************/
789   // we also use this to trigger the actual draw operation
887790
888               UINT32 blit5_unused = m_spriteblit[5]&0xfffefffe;
889               // this might enable the text indirection thing?
890               int indirect_tile_enable = (m_spriteblit[5] & 0x00010000)>>16;
891               int indirect_zoom_enable = (m_spriteblit[5] & 0x00000001);
791   if (indirect_zoom_enable)
792   {
793      // with this bit enabled blit10 is a look up to the zoom(?) value eg. 03f42600
794      //UINT32 temp = space.read_dword(blit10);
795      //PRINT_BLIT_STUFF
796      /* for the horizontal road during attract there are tables 0x480 bytes long (0x120 dwords) and the value passed points to the start of them */
797      /* cell sizes for those are are 0011 (v) 0007 (h) with zoom factors of 0020 (half v) 0040 (normal h) */
798      /* tables seem to be 2x 8-bit values, possibly zoom + linescroll, although ingame ones seem to be 2x16-bit (corrupt? more meaning) */
892799
800   }
893801
894               if (blit5_unused) printf("unknown bits in blit word %d -  %08x\n", m_blitterSerialCount, blit5_unused);
895               // 00010000 (text)
896               // 00000001 (other)
802   bitmap_rgb32* drawbitmap;
897803
804   // 0x30 - 0x60 are definitely the left screen, 0x90 - 0xc0 are definitely the right screen.. the modes seem priority related
805   if (m_blitterMode == 0x30 || m_blitterMode == 0x40 || m_blitterMode == 0x50 || m_blitterMode == 0x60)
806      drawbitmap = &m_temp_bitmap_sprites;
807   else // 0x90, 0xa0, 0xb0, 0xc0
808      drawbitmap = &m_temp_bitmap_sprites2;
898809
810   int sizex = used_hCellCount * 16 * hZoom;
811   int sizey = used_vCellCount * 16 * vZoom;
812   hPosition *= 0x40;
813   vPosition *= 0x40;
899814
815   switch (vOrigin & 3)
816   {
817   case 0:
818      // top
819      break;
820   case 1:
821      vPosition -= sizey / 2 ;
822      // middle?
823      break;
824   case 2:
825      vPosition -= sizey;
826      // bottom?
827      break;
828   case 3:
829      // invalid?
830      break;
831   }
900832
901               /************* m_spriteblit[6] *************/
833   switch (hOrigin & 3)
834   {
835   case 0:
836      // left
837      break;
838   case 1:
839      hPosition -= sizex / 2;
840      // middle?
841      break;
842   case 2:
843      hPosition -= sizex;
844      // right?
845      break;
846   case 3:
847      // invalid?
848      break;
849   }
902850
903               UINT16 vCellCount = (m_spriteblit[6] & 0xffff0000) >> 16;
904               UINT16 hCellCount = (m_spriteblit[6] & 0x0000ffff);
905         
906               /************* m_spriteblit[7] *************/
907     
908               UINT16 vOrigin = (m_spriteblit[7] & 0xffff0000) >> 16;
909               UINT16 hOrigin = (m_spriteblit[7] & 0x0000ffff);
910               //printf("%04x %04x\n", vOrigin, hOrigin);
911         
912               /************* m_spriteblit[8] *************/
851   UINT32 lastSpriteNumber = 0xffffffff;
852   // Splat some sprites
853   for (int v = 0; v < used_vCellCount; v++)
854   {
855      const int pixelOffsetY = ((vPosition) + (v* 16 * vZoom)) / 0x40;
913856
914               UINT16 vZoom = (m_spriteblit[8] & 0xffff0000) >> 16;
915               UINT16 hZoom = (m_spriteblit[8] & 0x0000ffff);
916         
917               /************* m_spriteblit[9] *************/
857      if (pixelOffsetY>383)
858      {
859         v = used_vCellCount;
860         continue;
861      }
918862
919               int vPosition = (m_spriteblit[9] & 0xffff0000) >> 16;
920               int hPosition = (m_spriteblit[9] & 0x0000ffff);
921863
922               if (hPosition & 0x8000) hPosition -= 0x10000;
923               if (vPosition & 0x8000) vPosition -= 0x10000;
924         
925               /************* m_spriteblit[10] *************/
864      for (int h = 0; h < used_hCellCount; h++)
865      {
866         const int pixelOffsetX = ((hPosition) + (h* 16 * hZoom)) / 0x40;
926867
927               // this is an address on some objects..
928               // to be specific, the center line of the road (actual road object? which currently gets shown as a single pixel column?)
929               // and the horizontal road used in the background of the title screen (which currently looks normal)
930               // I guess it's some kind of indirect way to do a line effect?
931               //UINT32 blit10 =  m_spriteblit[10];
868         if (pixelOffsetX>495)
869         {
870            h = used_hCellCount;
871            continue;
872         }
932873
933               /************* m_spriteblit[11] *************/
934               
935               UINT32 textlookup =  m_spriteblit[11];
874         int lookupnum;
936875
937               /* DRAW */
938               
939               if (blit0 & 1)
876         // with this bit enabled the tile numbers gets looked up using 'data' (which would be blit11) (eg 03f40000 for startup text)
877         // this allows text strings to be written as 8-bit ascii in one area (using command 0x10), and drawn using multi-width sprites
878         if (indirect_tile_enable)
879         {
880            lookupnum = space.read_byte(textlookup + h + (v*used_hCellCount));
881         }
882         else
883         {
884            if (!blit_rotate)
885            {
886               if (!used_flipy)
940887               {
941                  // NOT A SPRITE
888                  if (!used_flipx)
889                     lookupnum = h + (v*used_hCellCount);
890                  else
891                     lookupnum = (used_hCellCount-h-1) + (v*used_hCellCount);
892               }
893               else
894               {
895                  if (!used_flipx)
896                     lookupnum = h + ((used_vCellCount-v-1)*used_hCellCount);
897                  else
898                     lookupnum = (used_hCellCount-h-1) + ((used_vCellCount-v-1)*used_hCellCount);
942899
943                  // these are something else, not sprites?  It still writes 11 dwords I think they have a different meaning
944                  // it might be a clipping area set? looks potentially like co-ordinates at least
945                  //printf("non sprite: ");
946                  //PRINT_BLIT_STUFF
947900               }
901            }
902            else
903            {
904               if (!used_flipy)
905               {
906                  if (!used_flipx)
907                     lookupnum = v + (h*used_vCellCount);
908                  else
909                     lookupnum = (used_vCellCount-v-1) + (h*used_vCellCount);
910               }
948911               else
949912               {
950                  UINT16 used_hCellCount = hCellCount;
951                  UINT16 used_vCellCount = vCellCount;
952                  UINT16 used_flipx = blit_flipx;
953                  UINT16 used_flipy = blit_flipy;
913                  if (!used_flipx)
914                     lookupnum = v + ((used_hCellCount-h-1)*used_vCellCount);
915                  else
916                     lookupnum = (used_vCellCount-v-1) + ((used_hCellCount-h-1)*used_vCellCount);
954917
955                  if (blit_rotate)
956                  {
957                     used_hCellCount = vCellCount;
958                     used_vCellCount = hCellCount;
959                     used_flipx = blit_flipy;
960                     used_flipy = blit_flipx;
961                     // do the zoom params rotate?
962                  }
918               }
919            }
920         }
963921
964                  // SPRITES / BLITS
965922
966                  // for text objects this is an address containing the 8-bit tile numbers to use for ASCII text
967                  // I guess the tiles are decoded by a DMA operation earlier, from the compressed ROM?
923         // these should be 'cell numbers' (tile numbers) which look up RLE data?
924         UINT32 spriteNumber = (m_expanded_10bit_gfx[ (b3romoffset << 3) + (lookupnum<<1) +0 ] << 10) | (m_expanded_10bit_gfx[ (b3romoffset << 3) + (lookupnum<<1) + 1 ]);
925         UINT16 tempshape[16*16];
926         
927         // skip the decoding if it's the same tile as last time!
928         if (spriteNumber != lastSpriteNumber)
929         {
930            lastSpriteNumber = spriteNumber;
968931
969                  // we also use this to trigger the actual draw operation
932            int i = 1;// skip first 10 bits for now
933            int data_written = 0;
970934
971           
972                  //if (blit10!=0)
973                  if (indirect_zoom_enable)
974                  {
975                     // with this bit enabled blit10 is a look up to the zoom(?) value eg. 03f42600
976                     //UINT32 temp = space.read_dword(blit10);
977                     //PRINT_BLIT_STUFF
978                     /* for the horizontal road during attract there are tables 0x480 bytes long (0x120 dwords) and the value passed points to the start of them */
979                     /* cell sizes for those are are 0011 (v) 0007 (h) with zoom factors of 0020 (half v) 0040 (normal h) */
980                     /* tables seem to be 2x 8-bit values, possibly zoom + linescroll, although ingame ones seem to be 2x16-bit (corrupt? more meaning) */
935            while (data_written<256)
936            {
981937
982                  }
938               UINT16 compdata = m_expanded_10bit_gfx[ (b3romoffset << 3) + spriteNumber + i];
983939
984                  bitmap_rgb32* drawbitmap;
940               if (((compdata & 0x300) == 0x000) || ((compdata & 0x300) == 0x100))
941               {
942                  // mm ccrr rrr0
943                  int encodelength = (compdata & 0x03e)>>1;
944                  int rledata = (compdata & 0x3c0) >> 6;
985945
986                  // 0x30 - 0x60 are definitely the left screen, 0x90 - 0xc0 are definitely the right screen.. the modes seem priority related
987                  if (m_blitterMode == 0x30 || m_blitterMode == 0x40 || m_blitterMode == 0x50 || m_blitterMode == 0x60)
988                     drawbitmap = &m_temp_bitmap_sprites;
989                  else // 0x90, 0xa0, 0xb0, 0xc0
990                     drawbitmap = &m_temp_bitmap_sprites2;
946                  // guess, blank tiles have the following form
947                  // 00120 (00000024,0) | 010 03f
948                  if (compdata&1) encodelength = 255;
991949
992                  int sizex = used_hCellCount * 16 * hZoom;
993                  int sizey = used_vCellCount * 16 * vZoom;
994                  hPosition *= 0x40;
995                  vPosition *= 0x40;
996
997                  switch (vOrigin & 3)
950                  while (data_written<256 && encodelength >=0)
998951                  {
999                  case 0:
1000                     // top
1001                     break;
1002                  case 1:
1003                     vPosition -= sizey / 2 ;
1004                     // middle?
1005                     break;
1006                  case 2:
1007                     vPosition -= sizey;
1008                     // bottom?
1009                     break;
1010                  case 3:
1011                     // invalid?
1012                     break;
952                     tempshape[data_written] = rledata;
953                     encodelength--;
954                     data_written++;
1013955                  }
956               }
957               else if ((compdata & 0x300) == 0x200)
958               {
959                  // mm cccc ccrr
960                  int encodelength = (compdata & 0x003);
961                  int rledata = (compdata & 0x3fc) >> 6;
1014962
1015                  switch (hOrigin & 3)
963                  while (data_written<256 && encodelength >=0)
1016964                  {
1017                  case 0:
1018                     // left
1019                     break;
1020                  case 1:
1021                     hPosition -= sizex / 2;
1022                     // middle?
1023                     break;
1024                  case 2:
1025                     hPosition -= sizex;
1026                     // right?
1027                     break;
1028                  case 3:
1029                     // invalid?
1030                     break;
965                     tempshape[data_written] = rledata;
966                     encodelength--;
967                     data_written++;
1031968                  }
1032969
1033                  UINT32 lastSpriteNumber = 0xffffffff;
1034                  // Splat some sprites
1035                  for (int v = 0; v < used_vCellCount; v++)
1036                  {
1037                     const int pixelOffsetY = ((vPosition) + (v* 16 * vZoom)) / 0x40;
970               }
971               else
972               {
973                  // mm cccc cccc
974                  tempshape[data_written] = compdata&0xff;
975                  data_written++;
976               }
1038977
1039                     if (pixelOffsetY>383)
1040                     {
1041                        v = used_vCellCount;
1042                        continue;
1043                     }
978               i++;
979            }
980         }
1044981
1045982
1046                     for (int h = 0; h < used_hCellCount; h++)
1047                     {
1048                        const int pixelOffsetX = ((hPosition) + (h* 16 * hZoom)) / 0x40;
983         if (!hZoom || !vZoom)
984         {
985            m_blitterSerialCount++;
986            return;
987         }
1049988
1050                        if (pixelOffsetX>495)
1051                        {
1052                           h = used_hCellCount;
1053                           continue;
1054                        }
989         int blockwide = ((16*hZoom)/0x40);
990         int blockhigh = ((16*vZoom)/0x40);
1055991
1056                        int lookupnum;
1057992
1058                        // with this bit enabled the tile numbers gets looked up using 'data' (which would be blit11) (eg 03f40000 for startup text)
1059                        // this allows text strings to be written as 8-bit ascii in one area (using command 0x10), and drawn using multi-width sprites
1060                        if (indirect_tile_enable)
1061                        {
1062                           lookupnum = space.read_byte(textlookup + h + (v*used_hCellCount));
1063                        }
1064                        else
1065                        {
1066                           if (!blit_rotate)
1067                           {
1068                              if (!used_flipy)
1069                              {
1070                                 if (!used_flipx)
1071                                    lookupnum = h + (v*used_hCellCount);
1072                                 else
1073                                    lookupnum = (used_hCellCount-h-1) + (v*used_hCellCount);
1074                              }
1075                              else
1076                              {
1077                                 if (!used_flipx)
1078                                    lookupnum = h + ((used_vCellCount-v-1)*used_hCellCount);
1079                                 else
1080                                    lookupnum = (used_hCellCount-h-1) + ((used_vCellCount-v-1)*used_hCellCount);
1081993
1082                              }
1083                           }
1084                           else
1085                           {
1086                              if (!used_flipy)
1087                              {
1088                                 if (!used_flipx)
1089                                    lookupnum = v + (h*used_vCellCount);
1090                                 else
1091                                    lookupnum = (used_vCellCount-v-1) + (h*used_vCellCount);
1092                              }
1093                              else
1094                              {
1095                                 if (!used_flipx)
1096                                    lookupnum = v + ((used_hCellCount-h-1)*used_vCellCount);
1097                                 else
1098                                    lookupnum = (used_vCellCount-v-1) + ((used_hCellCount-h-1)*used_vCellCount);
994         UINT32 incx = 0x8000000 / hZoom;
995         UINT32 incy = 0x8000000 / vZoom;
1099996
1100                              }
1101                           }
1102                        }
997         // DEBUG: Draw 16x16 block
998         UINT32* line;
999         if (blit_rotate)
1000         {
1001            if (used_flipy)
1002            {
1003               for (int y = 0; y < 16; y++)
1004               {
1005                  const int drawy = pixelOffsetY+y;
1006                  if ((drawy>383) || (drawy<0)) continue;
1007                  line = &drawbitmap->pix32(drawy);
1008                  int realy = ((y*incy)>>21);
11031009
1010                  if (used_flipx)
1011                  {
1012                     for (int x = 0; x < 16; x++)
1013                     {
1014                        const int drawx = pixelOffsetX+x;
1015                        if ((drawx>=495 || drawx<0)) continue;
1016                        int realx = ((x*incx)>>21);
11041017
1105                        // these should be 'cell numbers' (tile numbers) which look up RLE data?
1106                        UINT32 spriteNumber = (m_expanded_10bit_gfx[ (b3romoffset << 3) + (lookupnum<<1) +0 ] << 10) | (m_expanded_10bit_gfx[ (b3romoffset << 3) + (lookupnum<<1) + 1 ]);
1107                        UINT16 tempshape[16*16];
1108                       
1109                        // skip the decoding if it's the same tile as last time!
1110                        if (spriteNumber != lastSpriteNumber)
1111                        {
1112                           lastSpriteNumber = spriteNumber;
1018                        UINT16 pix = tempshape[(15-realx)*16+(15-realy)];
1019                        if (pix )
1020                           if (line[drawx]==0) line[drawx] = clut[pix+0x4000];
1021                     }
1022                  }
1023                  else
1024                  {
1025                     for (int x = 0; x < 16; x++)
1026                     {
1027                        const int drawx = pixelOffsetX+x;
1028                        if ((drawx>=495 || drawx<0)) continue;
1029                        int realx = ((x*incx)>>21);
11131030
1114                           int i = 1;// skip first 10 bits for now
1115                           int data_written = 0;
1031                        UINT16 pix = tempshape[(15-realx)*16+realy];
1032                        if (pix )
1033                           if (line[drawx]==0) line[drawx] = clut[pix+0x4000];
1034                     }
1035                  }
1036               }
1037            }
1038            else
1039            {
1040               for (int y = 0; y < 16; y++)
1041               {
1042                  const int drawy = pixelOffsetY+y;
1043                  if ((drawy>383) || (drawy<0)) continue;
1044                  line = &drawbitmap->pix32(drawy);
1045                  int realy = ((y*incy)>>21);
11161046
1117                           while (data_written<256)
1118                           {
1047                  if (used_flipx)
1048                  {
1049                     for (int x = 0; x < 16; x++)
1050                     {
1051                        const int drawx = pixelOffsetX+x;
1052                        if ((drawx>=495 || drawx<0)) continue;
1053                        int realx = ((x*incx)>>21);
11191054
1120                              UINT16 compdata = m_expanded_10bit_gfx[ (b3romoffset << 3) + spriteNumber + i];
1055                        UINT16 pix = tempshape[realx*16+(15-realy)];
1056                        if (pix )
1057                           if (line[drawx]==0) line[drawx] = clut[pix+0x4000];
1058                     }
1059                  }
1060                  else
1061                  {
1062                     for (int x = 0; x < 16; x++)
1063                     {
1064                        const int drawx = pixelOffsetX+x;
1065                        if ((drawx>=495 || drawx<0)) continue;
1066                        int realx = ((x*incx)>>21);
11211067
1122                              if (((compdata & 0x300) == 0x000) || ((compdata & 0x300) == 0x100))
1123                              {
1124                                 // mm ccrr rrr0
1125                                 int encodelength = (compdata & 0x03e)>>1;
1126                                 int rledata = (compdata & 0x3c0) >> 6;
1068                        UINT16 pix = tempshape[realx*16+realy];
1069                        if (pix )
1070                           if (line[drawx]==0) line[drawx] = clut[pix+0x4000];
1071                     }
1072                  }
1073               }
1074            }                       
1075         }
1076         else // no rotate
1077         {
1078            if (used_flipy)
1079            {
1080               for (int y = 0; y < 16; y++)
1081               {
1082                  const int drawy = pixelOffsetY+y;
1083                  if ((drawy>383) || (drawy<0)) continue;
1084                  line = &drawbitmap->pix32(drawy);
1085                  int realy = ((y*incy)>>21);
11271086
1128                                 // guess, blank tiles have the following form
1129                                 // 00120 (00000024,0) | 010 03f
1130                                 if (compdata&1) encodelength = 255;
1087                  if (used_flipx)
1088                  {
1089                     for (int x = 0; x < 16; x++)
1090                     {
1091                        const int drawx = pixelOffsetX+x;
1092                        if ((drawx>=495 || drawx<0)) continue;
1093                        int realx = ((x*incx)>>21);
11311094
1132                                 while (data_written<256 && encodelength >=0)
1133                                 {
1134                                    tempshape[data_written] = rledata;
1135                                    encodelength--;
1136                                    data_written++;
1137                                 }
1138                              }
1139                              else if ((compdata & 0x300) == 0x200)
1140                              {
1141                                 // mm cccc ccrr
1142                                 int encodelength = (compdata & 0x003);
1143                                 int rledata = (compdata & 0x3fc) >> 6;
1095                        UINT16 pix = tempshape[(15-realy)*16+(15-realx)];
1096                        if (pix )
1097                           if (line[drawx]==0) line[drawx] = clut[pix+0x4000];
1098                     }
1099                  }
1100                  else
1101                  {
1102                     for (int x = 0; x < 16; x++)
1103                     {
1104                        const int drawx = pixelOffsetX+x;
1105                        if ((drawx>=495 || drawx<0)) continue;
1106                        int realx = ((x*incx)>>21);
1107                        UINT16 pix = tempshape[(15-realy)*16+realx];
1108                        if (pix )
1109                           if (line[drawx]==0) line[drawx] = clut[pix+0x4000];
1110                     }
1111                  }
1112               }
1113            }
1114            else // no rotate, no flipy
1115            {
1116               for (int y = 0; y < blockhigh; y++)
1117               {
1118                  const int drawy = pixelOffsetY+y;
1119                  if ((drawy>383) || (drawy<0)) continue;
1120                  line = &drawbitmap->pix32(drawy);
1121                  int realy = ((y*incy)>>21);
11441122
1145                                 while (data_written<256 && encodelength >=0)
1146                                 {
1147                                    tempshape[data_written] = rledata;
1148                                    encodelength--;
1149                                    data_written++;
1150                                 }
1123                  if (used_flipx)
1124                  {
1125                     for (int x = 0; x < blockwide; x++)
1126                     {
1127                        const int drawx = pixelOffsetX+x;
1128                        if ((drawx>=495 || drawx<0)) continue;
1129                        int realx = ((x*incx)>>21);
11511130
1152                              }
1153                              else
1154                              {
1155                                 // mm cccc cccc
1156                                 tempshape[data_written] = compdata&0xff;
1157                                 data_written++;
1158                              }
1131                        UINT16 pix = tempshape[realy*16+(15-realx)];
1132                        if (pix )
1133                           if (line[drawx]==0) line[drawx] = clut[pix+0x4000];
1134                     }
1135                  }
11591136
1160                              i++;
1161                           }
1162                        }
11631137
11641138
1165                        if (!hZoom || !vZoom)
1166                        {
1167                           m_blitterSerialCount++;
1168                           return;
1169                        }
1139                  else // no rotate, no flipy, no flipx
1140                  {
1141                     for (int x = 0; x < blockwide; x++)
1142                     {
1143                        const int drawx = pixelOffsetX+x;
1144                        if ((drawx>=495 || drawx<0)) continue;
1145                        int realx = ((x*incx)>>21);
11701146
1171                        int blockwide = ((16*hZoom)/0x40);
1172                        int blockhigh = ((16*vZoom)/0x40);
1173   
1147                        UINT16 pix = tempshape[realy*16+realx];
1148                        if (pix )
1149                           if (line[drawx]==0) line[drawx] = clut[pix+0x4000];
1150                     }
1151                  }
1152               }
1153            }
1154         }
1155      }
1156   }
1157}
11741158
1159WRITE32_MEMBER(coolridr_state::sysh1_blit_mode_w)
1160{
1161   m_blitterMode = (data & 0x00ff0000) >> 16;
11751162
1176                        UINT32 incx = 0x8000000 / hZoom;
1177                        UINT32 incy = 0x8000000 / vZoom;
1163   if (m_blitterMode == 0xf4)
1164   {
1165      // Some sort of addressing state.
1166      // In the case of text, simply writes 4 characters per 32-bit word.
1167      // These values may be loaded into RAM somewhere as they are written.
1168      // The number of characters is determined by the upper-most 8 bits.
1169      m_textBytesToWrite = (data & 0xff000000) >> 24;
1170      m_textOffset = (data & 0x0000ffff);
1171      m_blitterSerialCount = 0;
11781172
1179                        // DEBUG: Draw 16x16 block
1180                        UINT32* line;
1181                        if (blit_rotate)
1182                        {
1183                           if (used_flipy)
1184                           {
1185                              for (int y = 0; y < 16; y++)
1186                              {
1187                                 const int drawy = pixelOffsetY+y;
1188                                 if ((drawy>383) || (drawy<0)) continue;
1189                                 line = &drawbitmap->pix32(drawy);
1190                                 int realy = ((y*incy)>>21);
1173      // this is ONLY used when there is text on the screen
11911174
1192                                 if (used_flipx)
1193                                 {
1194                                    for (int x = 0; x < 16; x++)
1195                                    {
1196                                       const int drawx = pixelOffsetX+x;
1197                                       if ((drawx>=495 || drawx<0)) continue;
1198                                       int realx = ((x*incx)>>21);
1175      //printf("set mode %08x\n", data);
11991176
1200                                       UINT16 pix = tempshape[(15-realx)*16+(15-realy)];
1201                                       if (pix )
1202                                          if (line[drawx]==0) line[drawx] = clut[pix+0x4000];
1203                                    }
1204                                 }
1205                                 else
1206                                 {
1207                                    for (int x = 0; x < 16; x++)
1208                                    {
1209                                       const int drawx = pixelOffsetX+x;
1210                                       if ((drawx>=495 || drawx<0)) continue;
1211                                       int realx = ((x*incx)>>21);
12121177
1213                                       UINT16 pix = tempshape[(15-realx)*16+realy];
1214                                       if (pix )
1215                                          if (line[drawx]==0) line[drawx] = clut[pix+0x4000];
1216                                    }
1217                                 }
1218                              }
1219                           }
1220                           else
1221                           {
1222                              for (int y = 0; y < 16; y++)
1223                              {
1224                                 const int drawy = pixelOffsetY+y;
1225                                 if ((drawy>383) || (drawy<0)) continue;
1226                                 line = &drawbitmap->pix32(drawy);
1227                                 int realy = ((y*incy)>>21);
1178   }
1179   else if (m_blitterMode == 0x30 || m_blitterMode == 0x40 || m_blitterMode == 0x50 || m_blitterMode == 0x60
1180        || m_blitterMode == 0x90 || m_blitterMode == 0xa0 || m_blitterMode == 0xb0 || m_blitterMode == 0xc0)
1181   {
1182      // The blitter function(s).
1183      // After this is set a fixed count of 11 32-bit words are sent to the data register.
1184      // The lower word always seems to be 0x0001 and the upper byte always 0xac.
1185      m_blitterSerialCount = 0;
12281186
1229                                 if (used_flipx)
1230                                 {
1231                                    for (int x = 0; x < 16; x++)
1232                                    {
1233                                       const int drawx = pixelOffsetX+x;
1234                                       if ((drawx>=495 || drawx<0)) continue;
1235                                       int realx = ((x*incx)>>21);
1187      // form 0xacMM-xxx   ac = fixed value for this mode?  MM = modes above.  -xxx = some kind of offset? but it doesn't increment for each blit like the textOffset / paletteOffset stuff, investigate
12361188
1237                                       UINT16 pix = tempshape[realx*16+(15-realy)];
1238                                       if (pix )
1239                                          if (line[drawx]==0) line[drawx] = clut[pix+0x4000];
1240                                    }
1241                                 }
1242                                 else
1243                                 {
1244                                    for (int x = 0; x < 16; x++)
1245                                    {
1246                                       const int drawx = pixelOffsetX+x;
1247                                       if ((drawx>=495 || drawx<0)) continue;
1248                                       int realx = ((x*incx)>>21);
1189   }
1190   else if (m_blitterMode == 0x10)
1191   {
1192      // Could be a full clear of VRAM?
1193      for(UINT32 vramAddr = 0x3f40000; vramAddr < 0x3f4ffff; vramAddr+=4)
1194         space.write_dword(vramAddr, 0x00000000);
12491195
1250                                       UINT16 pix = tempshape[realx*16+realy];
1251                                       if (pix )
1252                                          if (line[drawx]==0) line[drawx] = clut[pix+0x4000];
1253                                    }
1254                                 }
1255                              }
1256                           }                       
1257                        }
1258                        else // no rotate
1259                        {
1260                           if (used_flipy)
1261                           {
1262                              for (int y = 0; y < 16; y++)
1263                              {
1264                                 const int drawy = pixelOffsetY+y;
1265                                 if ((drawy>383) || (drawy<0)) continue;
1266                                 line = &drawbitmap->pix32(drawy);
1267                                 int realy = ((y*incy)>>21);
1196      m_blitterSerialCount = 0;
1197   }
1198   else if (m_blitterMode == 0xe0)
1199   {
1200      // uploads palettes...
1201      // does NOT upload the palette for the WDUD screen when set to US mode this way..
1202      m_blitterSerialCount = 0;
1203      m_textOffset = (data & 0x0000ffff);
12681204
1269                                 if (used_flipx)
1270                                 {
1271                                    for (int x = 0; x < 16; x++)
1272                                    {
1273                                       const int drawx = pixelOffsetX+x;
1274                                       if ((drawx>=495 || drawx<0)) continue;
1275                                       int realx = ((x*incx)>>21);
1205   //   printf("set e0 %08x\n", data);
12761206
1277                                       UINT16 pix = tempshape[(15-realy)*16+(15-realx)];
1278                                       if (pix )
1279                                          if (line[drawx]==0) line[drawx] = clut[pix+0x4000];
1280                                    }
1281                                 }
1282                                 else
1283                                 {
1284                                    for (int x = 0; x < 16; x++)
1285                                    {
1286                                       const int drawx = pixelOffsetX+x;
1287                                       if ((drawx>=495 || drawx<0)) continue;
1288                                       int realx = ((x*incx)>>21);
1289                                       UINT16 pix = tempshape[(15-realy)*16+realx];
1290                                       if (pix )
1291                                          if (line[drawx]==0) line[drawx] = clut[pix+0x4000];
1292                                    }
1293                                 }
1294                              }
1295                           }
1296                           else // no rotate, no flipy
1297                           {
1298                              for (int y = 0; y < blockhigh; y++)
1299                              {
1300                                 const int drawy = pixelOffsetY+y;
1301                                 if ((drawy>383) || (drawy<0)) continue;
1302                                 line = &drawbitmap->pix32(drawy);
1303                                 int realy = ((y*incy)>>21);
1207   }
1208   else
1209   {
1210      printf("set unknown blit mode %02x\n", m_blitterMode);
1211   }
1212}
13041213
1305                                 if (used_flipx)
1306                                 {
1307                                    for (int x = 0; x < blockwide; x++)
1308                                    {
1309                                       const int drawx = pixelOffsetX+x;
1310                                       if ((drawx>=495 || drawx<0)) continue;
1311                                       int realx = ((x*incx)>>21);
1214WRITE32_MEMBER(coolridr_state::sysh1_blit_data_w)
1215{
1216   if (m_blitterMode == 0xf4)
1217   {
1218      // Uploads a series of bytes that index into the encoded sprite table
1219      const size_t memOffset = 0x03f40000 + m_textOffset + m_blitterSerialCount;
1220      space.write_dword(memOffset, data);
1221      m_blitterSerialCount += 0x04;
1222   }
1223   else if (m_blitterMode == 0x30 || m_blitterMode == 0x40 || m_blitterMode == 0x50 || m_blitterMode == 0x60
1224        || m_blitterMode == 0x90 || m_blitterMode == 0xa0 || m_blitterMode == 0xb0 || m_blitterMode == 0xc0)
1225   {
1226      // Serialized counts
1227      if (m_blitterSerialCount < 12)
1228      {
1229         m_spriteblit[m_blitterSerialCount] = data;
1230         m_blitterSerialCount++;
1231      }
1232      else
1233      {
1234         printf("more than 11 dwords (%d) in blit?\n", m_blitterSerialCount);
1235      }
13121236
1313                                       UINT16 pix = tempshape[realy*16+(15-realx)];
1314                                       if (pix )
1315                                          if (line[drawx]==0) line[drawx] = clut[pix+0x4000];
1316                                    }
1317                                 }
1237      // use the 11th blit write also as the trigger
1238      if (m_blitterSerialCount == 12)
1239      {
1240         blit_current_sprite(space);
1241      }
13181242
1243   }
1244   // ??
1245   else if (m_blitterMode == 0x10) // at startup
1246   {
1247      //printf("blit mode %02x %02x %08x\n", m_blitterMode, m_blitterSerialCount,  data);
1248      m_blitterSerialCount++;
1249   }
1250   else if (m_blitterMode == 0xe0) // when going into game (in units of 0x10 writes)
1251   {
1252      // it writes the palette for the bgs here, with fade effects?
1253      //  is this the only way for the tile colours to be actually used, or does this just go to memory somewhere too?
1254      //printf("blit mode %02x %02x %08x\n", m_blitterMode, m_blitterSerialCount,  data);
13191255
1256      // maybe should write to a different address, see dma hack in other code
1257      const size_t memOffset = 0x3c00000 + m_textOffset + m_blitterSerialCount;
1258      space.write_dword(memOffset, data);
1259      m_blitterSerialCount += 0x04;
13201260
1321                                 else // no rotate, no flipy, no flipx
1322                                 {
1323                                    for (int x = 0; x < blockwide; x++)
1324                                    {
1325                                       const int drawx = pixelOffsetX+x;
1326                                       if ((drawx>=495 || drawx<0)) continue;
1327                                       int realx = ((x*incx)>>21);
1261   }
1262   else
1263   {
1264      logerror("unk blit mode %02x\n", m_blitterMode);
1265   }
1266}
13281267
1329                                       UINT16 pix = tempshape[realy*16+realx];
1330                                       if (pix )
1331                                          if (line[drawx]==0) line[drawx] = clut[pix+0x4000];
1332                                    }
1333                                 }
1334                              }
1335                           }
1336                        }
1268WRITE32_MEMBER(coolridr_state::sysh1_fb_mode_w)
1269{
1270   /*
1271   This does the fb display/clear phases of blitter data processed in the previous frame.
1272   And yes, game effectively runs at 30 Hz (because data processing happens on even frames, actual display transfer happens on odd frames).
1273   screen 1
1274   8c200000 06
1275   00000001 07
1276   0000017f 07 Y range (upper start, lower end)
1277   000701f7 07 X range (upper start, lower end)
1278   00000007 07 enable?
1279   screen 2
1280   8c800000 06
1281   00000001 07
1282   0000017f 07
1283   020703f7 07
1284   00000207 07 enable plus clear?
1285   */
13371286
1287   COMBINE_DATA(&m_blitterClearMode);
13381288
1339                     }
1340                  }
1289/*
1290   if(m_blitterClearMode != 0x8c200000 && m_blitterClearMode != 0x8c800000)
1291      printf("Blitter Clear used with param %08x\n",m_blitterClearMode);
1292*/
13411293
1342                  //printf("\n");
1294   m_blitterClearCount = 0;
1295}
13431296
1344               }
1345            }
1297WRITE32_MEMBER(coolridr_state::sysh1_fb_data_w)
1298{
1299   if(m_blitterClearCount == 0)
1300   {
1301      if(data != 1)
1302         printf("Blitter Clear Count == 0 used with param %08x\n",data);
1303   }
1304   else if(m_blitterClearCount == 1)
1305   {
1306      if(data != 0x17f)
1307         printf("Blitter Clear Count == 1 used with param %08x\n",data);
1308   }
1309   else if(m_blitterClearCount == 2)
1310   {
1311      /*
1312      if(data != 0x000701f7 && m_sysh1_txt_blit[offset] != 0x020703f7)
1313         printf("Blitter Clear Count == 2 used with param %08x\n",data);
1314      */
1315   }
1316   else if(m_blitterClearCount == 3)
1317   {
1318      if(data != 0x00000007 && data != 0x00000207)
1319         printf("Blitter Clear Count == 3 used with param %08x\n",data);
13461320
1347         }
1348         // ??
1349         else if (m_blitterMode == 0x10) // at startup
1321      {
1322         const rectangle& visarea = machine().primary_screen->visible_area();
1323
1324         if(m_blitterClearMode == 0x8c200000)
13501325         {
1351            //printf("blit mode %02x %02x %08x\n", m_blitterMode, m_blitterSerialCount,  data);
1352            m_blitterSerialCount++;
1326            copybitmap(m_screen1_bitmap, m_temp_bitmap_sprites, 0, 0, 0, 0, visarea);
1327            m_temp_bitmap_sprites.fill(0, visarea);
13531328         }
1354         else if (m_blitterMode == 0xe0) // when going into game (in units of 0x10 writes)
1355         {
1356            // it writes the palette for the bgs here, with fade effects?
1357            //  is this the only way for the tile colours to be actually used, or does this just go to memory somewhere too?
1358            //printf("blit mode %02x %02x %08x\n", m_blitterMode, m_blitterSerialCount,  data);
13591329
1360            sysh1_pal_w(space,m_textOffset,data,0xffffffff);
1361            m_textOffset++;
1362
1363         }
1364         else
1330         if(m_blitterClearMode == 0x8c800000)
13651331         {
1366            logerror("unk blit mode %02x\n", m_blitterMode);
1332            copybitmap(m_screen2_bitmap, m_temp_bitmap_sprites2, 0, 0, 0, 0, visarea);
1333            m_temp_bitmap_sprites2.fill(0, visarea);
13671334         }
1368         break;
13691335      }
13701336   }
1337   else
1338   {
1339      printf("Blitter Clear Count == %02x used with param %08x\n",m_blitterClearCount,m_sysh1_txt_blit[offset]);
1340   }
1341
1342   m_blitterClearCount++;
13711343}
13721344
13731345
1346
1347WRITE32_MEMBER(coolridr_state::sysh1_unk_blit_w)
1348{
1349   COMBINE_DATA(&m_sysh1_txt_blit[offset]);
1350
1351   switch(offset)
1352   {     
1353      default:
1354      {
1355         printf("sysh1_unk_blit_w unhandled offset %04x %08x %08x\n", offset, data, mem_mask);
1356      }
1357
1358   }
1359}
1360
1361
13741362// NOTE, this gets called from the blitter code above AND the DMA code below.. addresses from each are probably wrong
13751363WRITE32_MEMBER(coolridr_state::sysh1_pal_w)
13761364{
r21314r21315
14751463{
14761464   COMBINE_DATA(&m_framebuffer_vram[offset]);
14771465
1466   // is this real, or just work ram for the actual blitter?
14781467   if(offset*4 == 0x000)
14791468   {
14801469      if((m_framebuffer_vram[offset] & 0xff00000) == 0xfe00000)
r21314r21315
15091498
15101499   AM_RANGE(0x03f00000, 0x03f0ffff) AM_RAM AM_SHARE("share3") /*Communication area RAM*/
15111500   AM_RANGE(0x03f40000, 0x03f4ffff) AM_RAM AM_SHARE("txt_vram")//text tilemap + "lineram"
1512   AM_RANGE(0x04000000, 0x0400003f) AM_RAM_WRITE(sysh1_txt_blit_w) AM_SHARE("sysh1_txt_blit")
1501   AM_RANGE(0x04000000, 0x0400000f) AM_RAM_WRITE(sysh1_unk_blit_w) AM_SHARE("sysh1_txt_blit")
1502   AM_RANGE(0x04000010, 0x04000013) AM_WRITE(sysh1_blit_mode_w)
1503   AM_RANGE(0x04000014, 0x04000017) AM_WRITE(sysh1_blit_data_w)
1504   AM_RANGE(0x04000018, 0x0400001b) AM_WRITE(sysh1_fb_mode_w)
1505   AM_RANGE(0x0400001c, 0x0400001f) AM_WRITE(sysh1_fb_data_w)
1506
1507
1508
1509   
1510   
1511   
15131512   AM_RANGE(0x06000000, 0x060fffff) AM_RAM AM_SHARE("sysh1_workrah")
15141513   AM_RANGE(0x20000000, 0x201fffff) AM_ROM AM_SHARE("share1")
15151514

Previous 199869 Revisions Next


© 1997-2024 The MAME Team