Previous 199869 Revisions Next

r21418 Sunday 24th February, 2013 at 12:43:37 UTC by David Haywood
improve zoom handling
[src/mame/drivers]coolridr.c

trunk/src/mame/drivers/coolridr.c
r21417r21418
364364#include "machine/nvram.h"
365365#include "rendlay.h"
366366
367#define CLIPWIDTH (496-1)
368#define CLIPHIGH (384-1)
367369
368
369370class coolridr_state : public driver_device
370371{
371372public:
r21417r21418
529530UINT32 coolridr_state::screen_update_coolridr(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int which)
530531{
531532   /* planes seems to basically be at 0x8000 and 0x28000... */
533#if 1
532534   UINT32 base_offset;
533535   int xsrc,ysrc,ydst,xdst;
534536   int xisrc,yisrc;
r21417r21418
595597         bitmap.pix32(ydst, xdst) = r<<16 | g<<8 | b;
596598      }
597599   }
598
600#endif
599601   if (which==0)
600602   {
601603      // will probably need a custom function
r21417r21418
714716      if (!hZoomTable[realy]) \
715717         continue;    \
716718      const int pixelOffsetX = ((hPositionTable[realy]) + (h* 16 * hZoomTable[realy])) / 0x40; \
719      const int pixelOffsetnextX = ((hPositionTable[realy]) + ((h+1)* 16 * hZoomTable[realy])) / 0x40; \
717720      const int drawy = pixelOffsetY+y; \
718      if ((drawy>383) || (drawy<0)) continue; \
721      if ((drawy>CLIPHIGH) || (drawy<0)) continue; \
719722      line = &drawbitmap->pix32(drawy); \
720723      zline = &object->zbitmap->pix16(drawy); \
721      int blockwide = ((16*hZoomTable[realy])/0x40); \
724      int blockwide = pixelOffsetnextX-pixelOffsetX; \
725      if (pixelOffsetX+blockwide <0) \
726         continue; \
727      if (pixelOffsetX>CLIPWIDTH) \
728         continue; \
722729      UINT32 incx = 0x8000000 / hZoomTable[realy]; \
723730      for (int x = 0; x < blockwide; x++) \
724731      { \
725732         const int drawx = pixelOffsetX+x; \
726         if ((drawx>495 || drawx<0)) continue; \
733         if ((drawx>CLIPWIDTH || drawx<0)) continue; \
727734         int realx = ((x*incx)>>21); \
728735
729736#define YXLOOP_END \
r21417r21418
736743   { \
737744      int realy = ((y*incy)>>21); \
738745      const int drawy = pixelOffsetY+y; \
739      if ((drawy>383) || (drawy<0)) continue; \
746      if ((drawy>CLIPHIGH) || (drawy<0)) continue; \
740747      line = &drawbitmap->pix32(drawy); \
741748      zline = &object->zbitmap->pix16(drawy); \
742749      for (int x = 0; x < blockwide; x++) \
743750      { \
744751         const int drawx = pixelOffsetX+x; \
745         if ((drawx>495 || drawx<0)) continue; \
752         if ((drawx>CLIPWIDTH || drawx<0)) continue; \
746753         int realx = ((x*incx)>>21); \
747754
755#define YXLOOP_START_NO_LINEZOOM_NO_XCLIP \
756   for (int y = 0; y < blockhigh; y++) \
757   { \
758      int realy = ((y*incy)>>21); \
759      const int drawy = pixelOffsetY+y; \
760      if ((drawy>CLIPHIGH) || (drawy<0)) continue; \
761      line = &drawbitmap->pix32(drawy); \
762      zline = &object->zbitmap->pix16(drawy); \
763      for (int x = 0; x < blockwide; x++) \
764      { \
765         const int drawx = pixelOffsetX+x; \
766         int realx = ((x*incx)>>21); \
748767
768
749769#define YXLOOP_START_NO_ZOOM \
750770   for (int y = 0; y < 16; y++) \
751771   { \
752772      const int drawy = pixelOffsetY+y; \
753      if ((drawy>383) || (drawy<0)) continue; \
773      if ((drawy>CLIPHIGH) || (drawy<0)) continue; \
754774      line = &drawbitmap->pix32(drawy); \
755775      zline = &object->zbitmap->pix16(drawy); \
756776      for (int x = 0; x < 16; x++) \
757777      { \
758778         const int drawx = pixelOffsetX+x; \
759         if ((drawx>495 || drawx<0)) continue; \
779         if ((drawx>CLIPWIDTH || drawx<0)) continue; \
760780
781#define YXLOOP_START_NO_ZOOM_NO_XCLIP \
782   for (int y = 0; y < 16; y++) \
783   { \
784      const int drawy = pixelOffsetY+y; \
785      if ((drawy>CLIPHIGH) || (drawy<0)) continue; \
786      line = &drawbitmap->pix32(drawy); \
787      zline = &object->zbitmap->pix16(drawy); \
788      for (int x = 0; x < 16; x++) \
789      { \
790         const int drawx = pixelOffsetX+x; \
761791
762792
763793
764
765794/* the two tables that the patent claims are located at:
766795   0x1ec800
767796   0x1f0000
r21417r21418
781810            int r,g,b; \
782811            r = pal5bit((pix >> 10) & 0x1f); \
783812            g = pal5bit((pix >> 5) & 0x1f); \
784            b = pal5bit((pix >> 0) & 0x1f); \
813            b = pal5bit((pix >> 0) & 0x1f); \
785814            line[drawx] = r<<16 | g<<8 | b; \
786815            zline[drawx] = object->zpri; \
787816         } \
r21417r21418
913942   UINT16 vZoom = (object->spriteblit[8] & 0xffff0000) >> 16;
914943   UINT16 hZoom = (object->spriteblit[8] & 0x0000ffff);
915944
945   // if we have no vertical zoom value there's no point in going any further
946   // because there are no known vertical indirect modes
947   if (!vZoom)
948   {
949      // abort, but make sure we clean up
950      if (object->indirect_tiles)
951         free(object->indirect_tiles);
952
953      if (object->indirect_zoom)
954         free(object->indirect_zoom);
955
956      free (object);
957
958      return NULL;
959   }
960
916961   /************* object->spriteblit[9] *************/
917962
918963   int vPosition = (object->spriteblit[9] & 0xffff0000) >> 16;
r21417r21418
9911036
9921037
9931038      const int pixelOffsetY = ((vPosition) + (v* 16 * vZoom)) / 0x40;
1039      const int pixelOffsetnextY = ((vPosition) + ((v+1)* 16 * vZoom)) / 0x40;
9941040
995      if (pixelOffsetY>383)
1041      int blockhigh = pixelOffsetnextY - pixelOffsetY;
1042
1043      if (pixelOffsetY+blockhigh<0)
1044         continue;
1045
1046
1047
1048      if (pixelOffsetY>CLIPHIGH)
9961049      {
9971050         v = used_vCellCount;
9981051         continue;
r21417r21418
10791132         if (!indirect_zoom_enable)
10801133         {
10811134         //   int offs = ((hPosition) + (h* 16 * hZoom)) / 0x40;
1082         //   if (offs>495) continue;
1135         //   if (offs>CLIPWIDTH) continue;
10831136         }
10841137
10851138         UINT32 lastSpriteNumber = 0xffffffff;
r21417r21418
11661219         if (blankcount==0)
11671220            continue;
11681221
1169         if (!vZoom)
1170         {
1171            // abort, but make sure we clean up
1172            goto end;
1173         }
11741222
1175         int blockhigh = ((16*vZoom)/0x40);
11761223
11771224
11781225
1226
11791227         UINT32 incy = 0x8000000 / vZoom;
11801228
11811229         // DEBUG: Draw 16x16 block
r21417r21418
12121260            {
12131261               const int pixelOffsetX = ((hPosition/0x40) + (h* 16));
12141262
1215               if (blit_rotate)
1263               if (pixelOffsetX+16 < 0)
1264                  continue;
1265
1266               if (pixelOffsetX>CLIPWIDTH)
1267                  continue;
1268
1269               if (pixelOffsetX>=0 && pixelOffsetX+16<CLIPWIDTH)
12161270               {
1217                  YXLOOP_START_NO_ZOOM
1218                  UINT16 pix = tempshape[x*16+y];
1219                  DRAW_PIX
1220                  YXLOOP_END
1271                  if (blit_rotate)
1272                  {
1273                     YXLOOP_START_NO_ZOOM_NO_XCLIP
1274                     UINT16 pix = tempshape[x*16+y];
1275                     DRAW_PIX
1276                     YXLOOP_END
1277                  }
1278                  else // no rotate
1279                  {
1280                     YXLOOP_START_NO_ZOOM_NO_XCLIP
1281                     UINT16 pix = tempshape[y*16+x];
1282                     DRAW_PIX
1283                     YXLOOP_END
1284                  }
12211285               }
1222               else // no rotate
1286               else
12231287               {
1224                  YXLOOP_START_NO_ZOOM
1225                  UINT16 pix = tempshape[y*16+x];
1226                  DRAW_PIX
1227                  YXLOOP_END
1288                  if (blit_rotate)
1289                  {
1290                     YXLOOP_START_NO_ZOOM
1291                     UINT16 pix = tempshape[x*16+y];
1292                     DRAW_PIX
1293                     YXLOOP_END
1294                  }
1295                  else // no rotate
1296                  {
1297                     YXLOOP_START_NO_ZOOM
1298                     UINT16 pix = tempshape[y*16+x];
1299                     DRAW_PIX
1300                     YXLOOP_END
1301                  }
12281302               }
12291303            }
12301304            else // zoomed
12311305            {
12321306               const int pixelOffsetX = ((hPosition) + (h* 16 * hZoom)) / 0x40;
1233               int blockwide = ((16*hZoom)/0x40);
1307               const int pixelOffsetnextX = ((hPosition) + ((h+1)* 16 * hZoom)) / 0x40;
1308
1309               int blockwide = pixelOffsetnextX-pixelOffsetX;
12341310               UINT32 incx = 0x8000000 / hZoom;
12351311
1236               if (blit_rotate)
1312               if (pixelOffsetX+blockwide < 0)
1313                  continue;
1314
1315               if (pixelOffsetX>CLIPWIDTH)
1316                  continue;
1317
1318               if (pixelOffsetX>=0 && pixelOffsetX+blockwide<CLIPWIDTH)
12371319               {
1238                  YXLOOP_START_NO_LINEZOOM
1239                  UINT16 pix = tempshape[realx*16+realy];
1240                  DRAW_PIX
1241                  YXLOOP_END
1320                  if (blit_rotate)
1321                  {
1322                     YXLOOP_START_NO_LINEZOOM_NO_XCLIP
1323                     UINT16 pix = tempshape[realx*16+realy];
1324                     DRAW_PIX
1325                     YXLOOP_END
1326                  }
1327                  else // no rotate
1328                  {
1329                     YXLOOP_START_NO_LINEZOOM_NO_XCLIP
1330                     UINT16 pix = tempshape[realy*16+realx];
1331                     DRAW_PIX
1332                     YXLOOP_END
1333                  }
12421334               }
1243               else // no rotate
1335               else
12441336               {
1245                  YXLOOP_START_NO_LINEZOOM
1246                  UINT16 pix = tempshape[realy*16+realx];
1247                  DRAW_PIX
1248                  YXLOOP_END
1337                  if (blit_rotate)
1338                  {
1339                     YXLOOP_START_NO_LINEZOOM
1340                     UINT16 pix = tempshape[realx*16+realy];
1341                     DRAW_PIX
1342                     YXLOOP_END
1343                  }
1344                  else // no rotate
1345                  {
1346                     YXLOOP_START_NO_LINEZOOM
1347                     UINT16 pix = tempshape[realy*16+realx];
1348                     DRAW_PIX
1349                     YXLOOP_END
1350                  }
12491351               }
12501352            } // end zoomed
12511353         } // end no indirect zoom
r21417r21418
25972699   MCFG_SCREEN_ADD("lscreen", RASTER)
25982700   MCFG_SCREEN_REFRESH_RATE(60)
25992701   MCFG_SCREEN_SIZE(640, 512)
2600   MCFG_SCREEN_VISIBLE_AREA(0,495, 0, 383)
2702   MCFG_SCREEN_VISIBLE_AREA(0,CLIPWIDTH, 0, CLIPHIGH)
26012703   MCFG_SCREEN_UPDATE_DRIVER(coolridr_state, screen_update_coolridr1)
26022704
26032705   MCFG_SCREEN_ADD("rscreen", RASTER)
26042706   MCFG_SCREEN_REFRESH_RATE(60)
26052707   MCFG_SCREEN_SIZE(640, 512)
2606   MCFG_SCREEN_VISIBLE_AREA(0,495, 0, 383)
2708   MCFG_SCREEN_VISIBLE_AREA(0,CLIPWIDTH, 0, CLIPHIGH)
26072709   MCFG_SCREEN_UPDATE_DRIVER(coolridr_state, screen_update_coolridr2)
26082710
26092711   MCFG_PALETTE_LENGTH(0x10000)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team