Previous 199869 Revisions Next

r21410 Saturday 23rd February, 2013 at 21:20:16 UTC by David Haywood
just part of a failed zbuffer experiment, will test a few other things later, this was nice in theory but isn't right.
[src/mame/drivers]coolridr.c

trunk/src/mame/drivers/coolridr.c
r21409r21410
395395   UINT16 m_textBytesToWrite;
396396   INT16  m_blitterSerialCount;
397397   UINT8  m_blitterMode;
398   UINT8  m_blittype;
398399   UINT16 m_blitterAddr;
399400   UINT16 m_textOffset;
400401   UINT32 m_blitterClearMode;
r21409r21410
417418   required_shared_ptr<UINT16> m_soundram2;
418419   bitmap_rgb32 m_temp_bitmap_sprites[4];
419420   bitmap_rgb32 m_temp_bitmap_sprites2[4];
421   bitmap_ind16 m_zbuffer_bitmap;
422   bitmap_ind16 m_zbuffer_bitmap2;
423
420424   bitmap_rgb32 m_screen1_bitmap;
421425   bitmap_rgb32 m_screen2_bitmap;
422426   int m_color;
r21409r21410
492496{
493497   machine().primary_screen->register_screen_bitmap(m_temp_bitmap_sprites[0]);
494498   machine().primary_screen->register_screen_bitmap(m_temp_bitmap_sprites2[0]);
499   machine().primary_screen->register_screen_bitmap(m_zbuffer_bitmap);
500   machine().primary_screen->register_screen_bitmap(m_zbuffer_bitmap2);
495501
502
503   
504
496505   // testing, not right
497506   machine().primary_screen->register_screen_bitmap(m_temp_bitmap_sprites[1]);
498507   machine().primary_screen->register_screen_bitmap(m_temp_bitmap_sprites2[1]);
r21409r21410
631640   UINT32* indirect_zoom;
632641   UINT32 spriteblit[12];
633642   bitmap_rgb32* drawbitmap;
643   bitmap_ind16* zbitmap;
644   UINT16 zpri;
645   UINT8 blittype;
634646   coolridr_state* state;
635647};
636648
r21409r21410
644656      const int drawy = pixelOffsetY+y; \
645657      if ((drawy>383) || (drawy<0)) continue; \
646658      line = &drawbitmap->pix32(drawy); \
659      zline = &object->zbitmap->pix16(drawy); \
647660      int blockwide = ((16*hZoomTable[realy])/0x40); \
648661      UINT32 incx = 0x8000000 / hZoomTable[realy]; \
649662
663
664
665#define YLOOP_START_NO_LINEZOOM \
666   for (int y = 0; y < blockhigh; y++) \
667   { \
668      int realy = ((y*incy)>>21); \
669      const int drawy = pixelOffsetY+y; \
670      if ((drawy>383) || (drawy<0)) continue; \
671      line = &drawbitmap->pix32(drawy); \
672      zline = &object->zbitmap->pix16(drawy); \
673
674
650675#define XLOOP_START \
651676   for (int x = 0; x < blockwide; x++) \
652677   { \
653678      const int drawx = pixelOffsetX+x; \
654      if ((drawx>=495 || drawx<0)) continue; \
679      if ((drawx>495 || drawx<0)) continue; \
655680      int realx = ((x*incx)>>21); \
656681
657682
r21409r21410
663688of each rom ... ROM 1 + 2 gives the full palette data for each pixel, in even/odd order.
664689TODO: fix anything that isn't text.
665690*/
691
692// because of our copy bitmap any black pens get removed.. obviously this is wrong
693
666694#define DRAW_PIX \
667   if (pix) \
695   if (pix&0x7fff) \
668696   { \
697      if (object->blittype==0) \
669698      { \
670         if (!line[drawx]) \
699         if (object->zpri < zline[drawx]) \
671700         { \
672            int r,g,b; \
673            r = pal5bit((pix >> 10) & 0x1f); \
674            g = pal5bit((pix >> 5) & 0x1f); \
675            b = pal5bit((pix >> 0) & 0x1f); \
676            line[drawx] = r<<16 | g<<8 | b; \
701            { \
702               int r,g,b; \
703               r = pal5bit((pix >> 10) & 0x1f); \
704               g = pal5bit((pix >> 5) & 0x1f); \
705               b = pal5bit((pix >> 0) & 0x1f); \
706               line[drawx] = r<<16 | g<<8 | b; \
707               zline[drawx] = object->zpri; \
708            } \
677709         } \
678710      } \
711      else if (object->blittype==1) \
712      { \
713         if (object->zpri < zline[drawx]) \
714         { \
715            { \
716               int r,g,b; \
717               r = pal5bit((pix >> 10) & 0x1f); \
718               g = pal5bit((pix >> 5) & 0x1f); \
719               b = pal5bit((pix >> 0) & 0x1f); \
720               line[drawx] = r<<16 | g<<8 | b; \
721               zline[drawx] = object->zpri; \
722            } \
723         } \
724      } \
725      if (object->blittype==2) \
726      { \
727         if (object->zpri < zline[drawx]) \
728         { \
729            { \
730               int r,g,b; \
731               r = pal5bit((pix >> 10) & 0x1f); \
732               g = pal5bit((pix >> 5) & 0x1f); \
733               b = pal5bit((pix >> 0) & 0x1f); \
734               line[drawx] = r<<16 | g<<8 | b; \
735               zline[drawx] = object->zpri; \
736            } \
737         } \
738      } \
739      if (object->blittype==3) \
740      { \
741         if (object->zpri < zline[drawx]) \
742         { \
743            { \
744               int r,g,b; \
745               r = pal5bit((pix >> 10) & 0x1f); \
746               g = pal5bit((pix >> 5) & 0x1f); \
747               b = pal5bit((pix >> 0) & 0x1f); \
748               line[drawx] = r<<16 | g<<8 | b; \
749               zline[drawx] = object->zpri; \
750            } \
751         } \
752      } \
679753   } \
680754
681755
r21409r21410
797871   /************* object->spriteblit[9] *************/
798872
799873   int vPosition = (object->spriteblit[9] & 0xffff0000) >> 16;
800   int hPosition = (object->spriteblit[9] & 0x0000ffff);
874   int hPositionx = (object->spriteblit[9] & 0x0000ffff);
801875
802   if (hPosition & 0x8000) hPosition -= 0x10000;
876   if (hPositionx & 0x8000) hPositionx -= 0x10000;
803877   if (vPosition & 0x8000) vPosition -= 0x10000;
804878
805879   /************* object->spriteblit[10] *************/
r21409r21410
882956
883957      UINT16 hZoomTable[16];
884958      int hPositionTable[16];
959      int hPosition = 0;
885960
886
887      for (int idx=0;idx<16;idx++)
961      if (indirect_zoom_enable)
888962      {
889
890         if (indirect_zoom_enable)
963         for (int idx=0;idx<16;idx++)
891964         {
892965            UINT32 dword = object->indirect_zoom[blit10];
893966
r21409r21410
897970            int linescroll = dword&0x7fff;
898971            if (linescroll & 0x4000) linescroll -= 0x8000;
899972
900            hPositionTable[idx] = linescroll + hPosition;
973            hPositionTable[idx] = linescroll + hPositionx;
901974            blit10++;
902975
976            // DON'T use the table hZoom in this calc? (road..)
977            int sizex = used_hCellCount * 16 * hZoom;
903978
979            hPositionTable[idx] *= 0x40;
980
981            switch (hOrigin & 3)
982            {
983            case 0:
984               // left
985               break;
986            case 1:
987               hPositionTable[idx] -= sizex / 2;
988               // middle?
989               break;
990            case 2:
991               hPositionTable[idx] -= sizex;
992               // right?
993               break;
994            case 3:
995               // invalid?
996               break;
997            }
904998         }
905         else
906         {
907            hZoomTable[idx] = hZoom;
908            hPositionTable[idx] = hPosition;
909         }
999      }
1000      else
1001      {
9101002
911         // DON'T use the table hZoom in this calc? (road..)
9121003         int sizex = used_hCellCount * 16 * hZoom;
9131004
914         hPositionTable[idx] *= 0x40;
1005         hPosition = hPositionx * 0x40;
9151006
9161007         switch (hOrigin & 3)
9171008         {
r21409r21410
9191010            // left
9201011            break;
9211012         case 1:
922            hPositionTable[idx] -= sizex / 2;
1013            hPosition -= sizex / 2;
9231014            // middle?
9241015            break;
9251016         case 2:
926            hPositionTable[idx] -= sizex;
1017            hPosition -= sizex;
9271018            // right?
9281019            break;
9291020         case 3:
9301021            // invalid?
9311022            break;
9321023         }
933
9341024      }
9351025
9361026
1027
9371028      for (int h = 0; h < used_hCellCount; h++)
9381029      {
939         
1030         if (!indirect_zoom_enable)
1031         {
1032         //   int offs = ((hPosition) + (h* 16 * hZoom)) / 0x40;
1033         //   if (offs>495) continue;
1034         }
9401035
941
9421036         UINT32 lastSpriteNumber = 0xffffffff;
9431037
9441038         int lookupnum;
r21409r21410
10671161
10681162         // DEBUG: Draw 16x16 block
10691163         UINT32* line;
1164         UINT16* zline;
10701165
10711166
1072
1073         if (blit_rotate)
1167         if (indirect_zoom_enable)
10741168         {
1075            if (used_flipy)
1169            if (blit_rotate)
10761170            {
1077               YLOOP_START
1171               if (used_flipy)
1172               {
1173                  YLOOP_START
10781174
1079                  if (used_flipx)
1080                  {
1081                     XLOOP_START
1175                     if (used_flipx)
1176                     {
1177                        XLOOP_START
10821178
1083                        UINT16 pix = tempshape[(15-realx)*16+(15-realy)];
1084                        DRAW_PIX
1179                           UINT16 pix = tempshape[(15-realx)*16+(15-realy)];
1180                           DRAW_PIX
1181                        }
10851182                     }
1183                     else
1184                     {
1185                        XLOOP_START
1186
1187                           UINT16 pix = tempshape[(15-realx)*16+realy];
1188                           DRAW_PIX
1189                        }
1190                     }
10861191                  }
1087                  else
1088                  {
1089                     XLOOP_START
1192               }
1193               else
1194               {
1195                  YLOOP_START
10901196
1091                        UINT16 pix = tempshape[(15-realx)*16+realy];
1092                        DRAW_PIX
1197                     if (used_flipx)
1198                     {
1199                        XLOOP_START
1200
1201                           UINT16 pix = tempshape[realx*16+(15-realy)];
1202                           DRAW_PIX
1203                        }
10931204                     }
1205                     else
1206                     {
1207                        XLOOP_START
1208
1209                           UINT16 pix = tempshape[realx*16+realy];
1210                           DRAW_PIX
1211                        }
1212                     }
10941213                  }
10951214               }
10961215            }
1097            else
1216            else // no rotate
10981217            {
1099               YLOOP_START
1218               if (used_flipy)
1219               {
1220                  YLOOP_START
11001221
1222                     if (used_flipx)
1223                     {
1224                        XLOOP_START
11011225
1102                  if (used_flipx)
1103                  {
1104                     XLOOP_START
1105
1106                        UINT16 pix = tempshape[realx*16+(15-realy)];
1107                        DRAW_PIX
1226                           UINT16 pix = tempshape[(15-realy)*16+(15-realx)];
1227                           DRAW_PIX
1228                        }
11081229                     }
1230                     else
1231                     {
1232                        XLOOP_START
1233                           UINT16 pix = tempshape[(15-realy)*16+realx];
1234                           DRAW_PIX
1235                        }
1236                     }
11091237                  }
1110                  else
1111                  {
1112                     XLOOP_START
1238               }
1239               else // no rotate, no flipy
1240               {
1241                  YLOOP_START
11131242
1114                        UINT16 pix = tempshape[realx*16+realy];
1115                        DRAW_PIX
1243                     if (used_flipx)
1244                     {
1245                        XLOOP_START
1246
1247                           UINT16 pix = tempshape[realy*16+(15-realx)];
1248                           DRAW_PIX
1249                        }
11161250                     }
1251                     else // no rotate, no flipy, no flipx
1252                     {
1253                        XLOOP_START
1254
1255                           UINT16 pix = tempshape[realy*16+realx];
1256                           DRAW_PIX
1257                        }
1258                     }
11171259                  }
11181260               }
11191261            }
11201262         }
1121         else // no rotate
1263         else // no indirect zoom
11221264         {
1123            if (used_flipy)
1265            if (!hZoom)
11241266            {
1125               YLOOP_START
1267               // abort, but make sure we clean up
1268               goto end;
1269            }
1270            const int pixelOffsetX = ((hPosition) + (h* 16 * hZoom)) / 0x40;
1271            int blockwide = ((16*hZoom)/0x40);
1272            UINT32 incx = 0x8000000 / hZoom;
11261273
1127                  if (used_flipx)
1128                  {
1129                     XLOOP_START
1274            if (blit_rotate)
1275            {
1276               if (used_flipy)
1277               {
1278                  YLOOP_START_NO_LINEZOOM
11301279
1131                        UINT16 pix = tempshape[(15-realy)*16+(15-realx)];
1132                        DRAW_PIX
1280                     if (used_flipx)
1281                     {
1282                        XLOOP_START
1283
1284                           UINT16 pix = tempshape[(15-realx)*16+(15-realy)];
1285                           DRAW_PIX
1286                        }
11331287                     }
1288                     else
1289                     {
1290                        XLOOP_START
1291
1292                           UINT16 pix = tempshape[(15-realx)*16+realy];
1293                           DRAW_PIX
1294                        }
1295                     }
11341296                  }
1135                  else
1136                  {
1137                     XLOOP_START
1138                        UINT16 pix = tempshape[(15-realy)*16+realx];
1139                        DRAW_PIX
1297               }
1298               else
1299               {
1300                  YLOOP_START_NO_LINEZOOM
1301
1302                     if (used_flipx)
1303                     {
1304                        XLOOP_START
1305
1306                           UINT16 pix = tempshape[realx*16+(15-realy)];
1307                           DRAW_PIX
1308                        }
11401309                     }
1310                     else
1311                     {
1312                        XLOOP_START
1313
1314                           UINT16 pix = tempshape[realx*16+realy];
1315                           DRAW_PIX
1316                        }
1317                     }
11411318                  }
11421319               }
11431320            }
1144            else // no rotate, no flipy
1321            else // no rotate
11451322            {
1146               YLOOP_START
1323               if (used_flipy)
1324               {
1325                  YLOOP_START_NO_LINEZOOM
11471326
1327                     if (used_flipx)
1328                     {
1329                        XLOOP_START
11481330
1149                  if (used_flipx)
1150                  {
1151                     XLOOP_START
1152
1153                        UINT16 pix = tempshape[realy*16+(15-realx)];
1154                        DRAW_PIX
1331                           UINT16 pix = tempshape[(15-realy)*16+(15-realx)];
1332                           DRAW_PIX
1333                        }
11551334                     }
1335                     else
1336                     {
1337                        XLOOP_START
1338                           UINT16 pix = tempshape[(15-realy)*16+realx];
1339                           DRAW_PIX
1340                        }
1341                     }
11561342                  }
1157                  else // no rotate, no flipy, no flipx
1158                  {
1159                     XLOOP_START
1343               }
1344               else // no rotate, no flipy
1345               {
1346                  YLOOP_START_NO_LINEZOOM
11601347
1161                        UINT16 pix = tempshape[realy*16+realx];
1162                        DRAW_PIX
1348                     if (used_flipx)
1349                     {
1350                        XLOOP_START
1351
1352                           UINT16 pix = tempshape[realy*16+(15-realx)];
1353                           DRAW_PIX
1354                        }
11631355                     }
1356                     else // no rotate, no flipy, no flipx
1357                     {
1358                        XLOOP_START
1359
1360                           UINT16 pix = tempshape[realy*16+realx];
1361                           DRAW_PIX
1362                        }
1363                     }
11641364                  }
11651365               }
11661366            }
1167         }
1367         } // end no indirect zoom
11681368      }
11691369   }
1370   
11701371
11711372
11721373   end:
r21409r21410
13331534   {
13341535      testobject->indirect_zoom = NULL;
13351536   }     
1537
1538   testobject->zpri = m_blitterAddr;
1539   testobject->blittype = m_blittype;
1540
13361541   osd_work_queue *queue;
13371542   // which queue, which bitmap
13381543   if (m_blitterMode == 0x30 || m_blitterMode == 0x40 || m_blitterMode == 0x50 || m_blitterMode == 0x60)
13391544   {
13401545      testobject->drawbitmap = &m_temp_bitmap_sprites[0];
1546      testobject->zbitmap = &m_zbuffer_bitmap;
13411547      queue = m_work_queue[0];
13421548   }
13431549   else // 0x90, 0xa0, 0xb0, 0xc0
13441550   {
13451551      testobject->drawbitmap = &m_temp_bitmap_sprites2[0];
1552      testobject->zbitmap = &m_zbuffer_bitmap2;
13461553      queue = m_work_queue[1];
13471554   }
13481555
r21409r21410
13781585      // The lower word always seems to be 0x0001 and the upper byte always 0xac.
13791586      m_blitterSerialCount = 0;
13801587
1588      if (m_blitterMode>=0x80)
1589         m_blittype = m_blitterMode - 0x90;
1590      else
1591         m_blittype = m_blitterMode - 0x30;
1592
1593      m_blittype>>=4;
1594
1595
13811596      m_blitterAddr = data & 0x00000fff;
13821597
13831598      // maybe it's actually treated like RAM, and blittermode determines the nature of the write (forward inc, backward inc, no inc etc.)
r21409r21410
14481663      // use the 11th blit write also as the trigger
14491664      if (m_blitterSerialCount == 12)
14501665      {
1451         blit_current_sprite(space);
1666         //if (m_blittype==2)
1667            blit_current_sprite(space);
14521668      }
14531669
14541670   }
r21409r21410
15401756            osd_work_queue_wait(m_work_queue[0], osd_ticks_per_second() * 100);
15411757            copybitmap(m_screen1_bitmap, m_temp_bitmap_sprites[i], 0, 0, 0, 0, visarea);
15421758            m_temp_bitmap_sprites[i].fill(0, visarea);
1759            m_zbuffer_bitmap.fill(0xffff, visarea);
15431760         }
15441761
15451762         if(m_blitterClearMode == 0x8c800000)
r21409r21410
15471764            osd_work_queue_wait(m_work_queue[1], osd_ticks_per_second() * 100);
15481765            copybitmap(m_screen2_bitmap, m_temp_bitmap_sprites2[i], 0, 0, 0, 0, visarea);
15491766            m_temp_bitmap_sprites2[i].fill(0, visarea);
1767            m_zbuffer_bitmap2.fill(0xffff, visarea);
15501768         }
15511769
15521770         //printf("frame\n");

Previous 199869 Revisions Next


© 1997-2024 The MAME Team