Previous 199869 Revisions Next

r21225 Wednesday 20th February, 2013 at 19:30:15 UTC by David Haywood
document 'blits' where the first sent parameter is '1' not '0' as non-sprites, probably clipping windows.
[src/mame/drivers]coolridr.c

trunk/src/mame/drivers/coolridr.c
r21224r21225
692692              || m_blitterMode == 0x90 || m_blitterMode == 0xa0 || m_blitterMode == 0xb0 || m_blitterMode == 0xc0)
693693         {
694694            // Serialized 32-bit words in order of appearance:
695            //  0: 00000000 - totally unknown : always seems to be zero
695            //  0: 00000000 - unknown, 0x00000000 or 0x00000001, 0 seems to be regular sprite, 1 seems to change meaning of below, possible clip area?
696696            //  1: xxxxxxxx - "Color Number" (all bits or just lower 16/8?)
697697            //  2: 00000000 - unknown : OT flag?  (transparency)
698698            //  3: 00000000 - unknown : RF flag?  (90 degree rotation)
r21224r21225
717717            {
718718               // set to 0x00000001 on some objects during the 'film strip' part of attract, otherwise 0
719719               // those objects don't seem visible anyway so might have some special meaning
720               // this is also set at times during the game
721               //
722               // the sprites with 1 set appear to have 0x00000000 in everything after the 4th write (m_blit4 and above)
723               // so likely have some other meaning and are NOT regular sprite data           
720724               m_blit0 = data;
725
726               
727
728
729
721730            //   if (data!=0) printf("blit %08x\n", data);
722731            }
723732            else if (m_blitterSerialCount == 1)
r21224r21225
807816            }
808817            else if (m_blitterSerialCount == 11)
809818            {
810               // for text objects this is an address containing the 8-bit tile numbers to use for ASCII text
811               // I guess the tiles are decoded by a DMA operation earlier, from the compressed ROM?
819               if (m_blit0 & 1)
820               {
821                  // NOT A SPRITE
812822
813               // we also use this to trigger the actual draw operation
823                  // these are something else, not sprites?  It still writes 11 dwords I think they have a different meaning
824                  // it might be a clipping area set? looks potentially like co-ordinates at least
825                  //printf("NON-SPRITE blit %08x %08x %08x %08x %08x(%08x) %08x %04x %04x %04x %04x %08x %08x %d %d\n", m_blit0, m_blit1, m_blit2, m_blit3, m_blit4_unused, m_blit4, m_blit5_unused, m_vCellCount, m_hCellCount, m_vZoom, m_hZoom, m_blit10, data, m_vPosition, m_hPosition);
814826
815               //printf("blit %08x\n", data);
827               }
828               else
829               {
830                  // SPRITES / BLITS
831
832                  // for text objects this is an address containing the 8-bit tile numbers to use for ASCII text
833                  // I guess the tiles are decoded by a DMA operation earlier, from the compressed ROM?
834
835                  // we also use this to trigger the actual draw operation
836
837                  //printf("blit %08x\n", data);
816838               
817               // debug, hide objects without m_blit10 set
818               //if (m_blit10==0) return;
819               //if (m_blit0==0) return;
839                  // debug, hide objects without m_blit10 set
840                  //if (m_blit10==0) return;
841                  //if (m_blit0==0) return;
820842
821               //if (m_blit10!=0)
822               if (m_indirect_zoom_enable)
823               {
824                  // with this bit enabled m_blit10 is a look up to the zoom(?) value eg. 03f42600
825                  //UINT32 temp = space.read_dword(m_blit10);
826                  //printf("road type blit %08x %08x %08x %08x %08x(%08x) %08x %04x %04x %04x %04x %08x %08x (TEMP %08x) %d %d\n", m_blit0, m_blit1, m_blit2, m_blit3, m_blit4_unused, m_blit4, m_blit5_unused, m_vCellCount, m_hCellCount, m_vZoom, m_hZoom, m_blit10, data, temp, m_vPosition, m_hPosition);
843                  //if (m_blit10!=0)
844                  if (m_indirect_zoom_enable)
845                  {
846                     // with this bit enabled m_blit10 is a look up to the zoom(?) value eg. 03f42600
847                     //UINT32 temp = space.read_dword(m_blit10);
848                     //printf("road type blit %08x %08x %08x %08x %08x(%08x) %08x %04x %04x %04x %04x %08x %08x (TEMP %08x) %d %d\n", m_blit0, m_blit1, m_blit2, m_blit3, m_blit4_unused, m_blit4, m_blit5_unused, m_vCellCount, m_hCellCount, m_vZoom, m_hZoom, m_blit10, data, temp, m_vPosition, m_hPosition);
827849               
828                  /* for the horizontal road during attract there are tables 0x480 bytes long (0x120 dwords) and the value passed points to the start of them */
829                  /* cell sizes for those are are 0011 (v) 0007 (h) with zoom factors of 0020 (half v) 0040 (normal h) */
830                  /* tables seem to be 2x 8-bit values, possibly zoom + linescroll, although ingame ones seem to be 2x16-bit (corrupt? more meaning) */
850                     /* for the horizontal road during attract there are tables 0x480 bytes long (0x120 dwords) and the value passed points to the start of them */
851                     /* cell sizes for those are are 0011 (v) 0007 (h) with zoom factors of 0020 (half v) 0040 (normal h) */
852                     /* tables seem to be 2x 8-bit values, possibly zoom + linescroll, although ingame ones seem to be 2x16-bit (corrupt? more meaning) */
831853
832               }
854                  }
833855
834856     
835               int random;
857                  int random;
836858               
837               random = 0;
859                  random = 0;
838860
839               // not used much..
840               if (m_blit4 &0x00010000)
841               {
842               //   printf("type blit %08x %08x %08x %08x %08x(%08x) %08x %04x %04x %04x %04x %08x %08x %d %d\n", m_blit0, m_blit1, m_blit2, m_blit3, m_blit4_unused, m_blit4, m_blit5_unused, m_vCellCount, m_hCellCount, m_vZoom, m_hZoom, m_blit10, data, m_vPosition, m_hPosition);
843                  m_colorNumber = machine().rand() | 0xff000000;
844                  random = 1;
845               }
846               else
847               {
848                 
849               }
850           
851               bitmap_rgb32* drawbitmap;
861                  // not used much..
862                  /*
863                  if (m_blit4 &0x00010000)
864                  {
865                     printf("type blit %08x %08x %08x %08x %08x(%08x) %08x %04x %04x %04x %04x %08x %08x %d %d\n", m_blit0, m_blit1, m_blit2, m_blit3, m_blit4_unused, m_blit4, m_blit5_unused, m_vCellCount, m_hCellCount, m_vZoom, m_hZoom, m_blit10, data, m_vPosition, m_hPosition);
866                     m_colorNumber = machine().rand() | 0xff000000;
867                     random = 1;
868                  }
869                  else
870                  {
871                     
872                  }
873                  */
852874
853               // 0x30 - 0x60 are definitely the left screen, 0x90 - 0xc0 are definitely the right screen.. the modes seem priority related
854               if (m_blitterMode == 0x30 || m_blitterMode == 0x40 || m_blitterMode == 0x50 || m_blitterMode == 0x60)
855                  drawbitmap = &m_temp_bitmap_sprites;
856               else // 0x90, 0xa0, 0xb0, 0xc0
857                  drawbitmap = &m_temp_bitmap_sprites2;
875                  bitmap_rgb32* drawbitmap;
858876
859               int sizex = m_hCellCount * 16 * m_hZoom;
860               int sizey = m_vCellCount * 16 * m_vZoom;
861               m_hPosition *= 0x40;
862               m_vPosition *= 0x40;
877                  // 0x30 - 0x60 are definitely the left screen, 0x90 - 0xc0 are definitely the right screen.. the modes seem priority related
878                  if (m_blitterMode == 0x30 || m_blitterMode == 0x40 || m_blitterMode == 0x50 || m_blitterMode == 0x60)
879                     drawbitmap = &m_temp_bitmap_sprites;
880                  else // 0x90, 0xa0, 0xb0, 0xc0
881                     drawbitmap = &m_temp_bitmap_sprites2;
863882
864               switch (m_vOrigin & 3)
865               {
866               case 0:
867                  // top
868                  break;
869               case 1:
870                  m_vPosition -= sizey / 2 ;
871                  // middle?
872                  break;
873               case 2:
874                  m_vPosition -= sizey;
875                  // bottom?
876                  break;
877               case 3:
878                  // invalid?
879                  break;
880               }
883                  int sizex = m_hCellCount * 16 * m_hZoom;
884                  int sizey = m_vCellCount * 16 * m_vZoom;
885                  m_hPosition *= 0x40;
886                  m_vPosition *= 0x40;
881887
882               switch (m_hOrigin & 3)
883               {
884               case 0:
885                  // left
886                  break;
887               case 1:
888                  m_hPosition -= sizex / 2;
889                  // middle?
890                  break;
891               case 2:
892                  m_hPosition -= sizex;
893                  // right?
894                  break;
895               case 3:
896                  // invalid?
897                  break;
898               }
888                  switch (m_vOrigin & 3)
889                  {
890                  case 0:
891                     // top
892                     break;
893                  case 1:
894                     m_vPosition -= sizey / 2 ;
895                     // middle?
896                     break;
897                  case 2:
898                     m_vPosition -= sizey;
899                     // bottom?
900                     break;
901                  case 3:
902                     // invalid?
903                     break;
904                  }
899905
900
901               // Splat some sprites
902               for (int h = 0; h < m_hCellCount; h++)
903               {
904                  for (int v = 0; v < m_vCellCount; v++)
906                  switch (m_hOrigin & 3)
905907                  {
906                     const int pixelOffsetX = ((m_hPosition) + (h* 16 * m_hZoom)) / 0x40;
907                     const int pixelOffsetY = ((m_vPosition) + (v* 16 * m_vZoom)) / 0x40;
908                  case 0:
909                     // left
910                     break;
911                  case 1:
912                     m_hPosition -= sizex / 2;
913                     // middle?
914                     break;
915                  case 2:
916                     m_hPosition -= sizex;
917                     // right?
918                     break;
919                  case 3:
920                     // invalid?
921                     break;
922                  }
908923
909                     // It's unknown if it's row-major or column-major
910                     // TODO: Study the CRT test and "Cool Riders" logo for clues.
911                     UINT8 spriteNumber = 0;
912924
913                     // with this bit enabled the tile numbers gets looked up using 'data' (which would be m_blit11) (eg 03f40000 for startup text)
914                     // this allows text strings to be written as 8-bit ascii in one area (using command 0x10), and drawn using multi-width sprites
915                     if (m_indirect_tile_enable)
925                  // Splat some sprites
926                  for (int h = 0; h < m_hCellCount; h++)
927                  {
928                     for (int v = 0; v < m_vCellCount; v++)
916929                     {
917                        const UINT32 memOffset = data;
918                        spriteNumber = space.read_byte(memOffset + h + (v*h));
930                        const int pixelOffsetX = ((m_hPosition) + (h* 16 * m_hZoom)) / 0x40;
931                        const int pixelOffsetY = ((m_vPosition) + (v* 16 * m_vZoom)) / 0x40;
919932
920                        // DEBUG: For demo purposes, skip &spaces and NULL characters
921                        if (spriteNumber == 0x20 || spriteNumber == 0x00)
922                           continue;
923#ifdef FAKE_ASCII_ROM
924                        drawgfx_opaque(*drawbitmap,drawbitmap->cliprect(), machine().gfx[3],spriteNumber,0,0,0,pixelOffsetX,pixelOffsetY);
925                        continue;
926#endif
927                     }
933                        // It's unknown if it's row-major or column-major
934                        // TODO: Study the CRT test and "Cool Riders" logo for clues.
935                        UINT8 spriteNumber = 0;
928936
937                        // with this bit enabled the tile numbers gets looked up using 'data' (which would be m_blit11) (eg 03f40000 for startup text)
938                        // this allows text strings to be written as 8-bit ascii in one area (using command 0x10), and drawn using multi-width sprites
939                        if (m_indirect_tile_enable)
940                        {
941                           const UINT32 memOffset = data;
942                           spriteNumber = space.read_byte(memOffset + h + (v*h));
929943
930                     int blockwide = ((16*m_hZoom)/0x40)-1;
931                     int blockhigh = ((16*m_vZoom)/0x40)-1;
932                     // hack
933                     if (blockwide<=0) blockwide = 1;
934                     if (blockhigh<=0) blockhigh = 1;
944                           // DEBUG: For demo purposes, skip &spaces and NULL characters
945                           if (spriteNumber == 0x20 || spriteNumber == 0x00)
946                              continue;
947   #ifdef FAKE_ASCII_ROM
948                           drawgfx_opaque(*drawbitmap,drawbitmap->cliprect(), machine().gfx[3],spriteNumber,0,0,0,pixelOffsetX,pixelOffsetY);
949                           continue;
950   #endif
951                        }
935952
936953
937                     UINT32 color = 0xffffffff;
938                     // HACKS to draw coloured blocks in easy to distinguish colours
939                     if (m_blitterMode == 0x30 || m_blitterMode == 0x90)
940                     {
941                        if (m_colorNumber == 0x5b)
942                           color = 0xffff0000;
943                        else if (m_colorNumber == 0x5d)
944                           color = 0xff00ff00;
945                        else if (m_colorNumber == 0x5e)
946                           color = 0xff0000ff;
947                        else
948                           color = 0xff00ffff;
949                     }
950                     else if (m_blitterMode == 0x40 || m_blitterMode == 0xa0)
951                     {
952                        color = 0xff000000 | (((m_colorNumber & 0xff) | 0x80)-0x40);
953                     }
954                     else if (m_blitterMode == 0x50 || m_blitterMode == 0xb0)
955                     {
956                        color = 0xff000000 | ((((m_colorNumber & 0xff) | 0x80)-0x40) << 8);
957                     }
958                     else if (m_blitterMode == 0x60 || m_blitterMode == 0xc0)
959                     {
960                        color = 0xff000000 | ((((m_colorNumber & 0xff) | 0x80)-0x40) << 16);
961                     }
962                     if (random == 1)
963                        color = m_colorNumber;
954                        int blockwide = ((16*m_hZoom)/0x40)-1;
955                        int blockhigh = ((16*m_vZoom)/0x40)-1;
956                        // hack
957                        if (blockwide<=0) blockwide = 1;
958                        if (blockhigh<=0) blockhigh = 1;
964959
965                     // DEBUG: Draw 16x16 block
966                     for (int y = 0; y < blockhigh; y++)
967                     {
968                        int drawy = pixelOffsetY+y;
969                        if ((drawy>383) || (drawy<0)) continue;
970960
971                        for (int x = 0; x < blockwide; x++)
961                        UINT32 color = 0xffffffff;
962                        // HACKS to draw coloured blocks in easy to distinguish colours
963                        if (m_blitterMode == 0x30 || m_blitterMode == 0x90)
972964                        {
973                           int drawx = pixelOffsetX+x;
974                           if ((drawx>=495 || drawx<0)) continue;
965                           if (m_colorNumber == 0x5b)
966                              color = 0xffff0000;
967                           else if (m_colorNumber == 0x5d)
968                              color = 0xff00ff00;
969                           else if (m_colorNumber == 0x5e)
970                              color = 0xff0000ff;
971                           else
972                              color = 0xff00ffff;
973                        }
974                        else if (m_blitterMode == 0x40 || m_blitterMode == 0xa0)
975                        {
976                           color = 0xff000000 | (((m_colorNumber & 0xff) | 0x80)-0x40);
977                        }
978                        else if (m_blitterMode == 0x50 || m_blitterMode == 0xb0)
979                        {
980                           color = 0xff000000 | ((((m_colorNumber & 0xff) | 0x80)-0x40) << 8);
981                        }
982                        else if (m_blitterMode == 0x60 || m_blitterMode == 0xc0)
983                        {
984                           color = 0xff000000 | ((((m_colorNumber & 0xff) | 0x80)-0x40) << 16);
985                        }
986                        if (random == 1)
987                           color = m_colorNumber;
975988
976                           if (drawbitmap->pix32(drawy,drawx)==0) drawbitmap->pix32(drawy, drawx) = color;
989                        // DEBUG: Draw 16x16 block
990                        for (int y = 0; y < blockhigh; y++)
991                        {
992                           int drawy = pixelOffsetY+y;
993                           if ((drawy>383) || (drawy<0)) continue;
994
995                           for (int x = 0; x < blockwide; x++)
996                           {
997                              int drawx = pixelOffsetX+x;
998                              if ((drawx>=495 || drawx<0)) continue;
999
1000                              if (drawbitmap->pix32(drawy,drawx)==0) drawbitmap->pix32(drawy, drawx) = color;
1001                           }
9771002                        }
9781003                     }
9791004                  }

Previous 199869 Revisions Next


© 1997-2024 The MAME Team