Previous 199869 Revisions Next

r21417 Sunday 24th February, 2013 at 04:29:37 UTC by David Haywood
code reorganization
[src/mame/drivers]coolridr.c

trunk/src/mame/drivers/coolridr.c
r21416r21417
650650   coolridr_state* state;
651651};
652652
653#define YLOOP_START \
653#define RLE_BLOCK(writeaddrxor) \
654   /* skip the decoding if it's the same tile as last time! */ \
655   if (spriteNumber != lastSpriteNumber) \
656   { \
657      lastSpriteNumber = spriteNumber; \
658       \
659      int i = 1;/* skip first 10 bits for now */ \
660      int data_written = 0; \
661 \
662      while (data_written<256) \
663      { \
664 \
665         const UINT16 compdata = expanded_10bit_gfx[ (b3romoffset) + spriteNumber + i]; \
666 \
667         if (((compdata & 0x300) == 0x000) || ((compdata & 0x300) == 0x100)) /* 3bpp */ \
668         { \
669            /* mm ccrr rrr0 */ \
670            int encodelength = (compdata & 0x03e)>>1; \
671            const UINT16 rledata =  rearranged_16bit_gfx[color_offs + ((compdata & 0x1c0) >> 6)]; \
672            /* guess, blank tiles have the following form */ \
673            /* 00120 (00000024,0) | 010 03f */ \
674            if (compdata&1) encodelength = 255; \
675 \
676            while (data_written<256 && encodelength >=0) \
677            { \
678               tempshape[data_written^writeaddrxor] = rledata; \
679               if (tempshape[data_written^writeaddrxor]==0x8000) blankcount--; \
680               encodelength--; \
681               data_written++; \
682            } \
683         } \
684         else if ((compdata & 0x300) == 0x200) /* 6bpp */ \
685         { \
686            /* mm cccc ccrr */ \
687            int encodelength = (compdata & 0x003);          \
688            const UINT16 rledata = rearranged_16bit_gfx[color_offs + ((compdata & 0x0fc) >> 2) + 8]; \
689            while (data_written<256 && encodelength >=0) \
690            { \
691               tempshape[data_written^writeaddrxor] = rledata; /* + 0x8 crt test, most of red, green, start of blue */ \
692               if (tempshape[data_written^writeaddrxor]==0x8000) blankcount--; \
693               encodelength--; \
694               data_written++; \
695            } \
696         } \
697         else /* 8bpp */ \
698         { \
699            /* mm cccc cccc */ \
700            tempshape[data_written^writeaddrxor] = rearranged_16bit_gfx[color_offs + (compdata & 0x0ff) + 0x48]; /* +0x48 crt test end of blue, start of white */ \
701            if (tempshape[data_written^writeaddrxor]==0x8000) blankcount--; \
702            data_written++; \
703         } \
704 \
705         i++; \
706      } \
707   } \
708
709
710#define YXLOOP_START \
654711   for (int y = 0; y < blockhigh; y++) \
655712   { \
656713      int realy = ((y*incy)>>21); \
r21416r21417
663720      zline = &object->zbitmap->pix16(drawy); \
664721      int blockwide = ((16*hZoomTable[realy])/0x40); \
665722      UINT32 incx = 0x8000000 / hZoomTable[realy]; \
723      for (int x = 0; x < blockwide; x++) \
724      { \
725         const int drawx = pixelOffsetX+x; \
726         if ((drawx>495 || drawx<0)) continue; \
727         int realx = ((x*incx)>>21); \
666728
729#define YXLOOP_END \
730      } \
731   } \
667732
668733
669#define YLOOP_START_NO_LINEZOOM \
734#define YXLOOP_START_NO_LINEZOOM \
670735   for (int y = 0; y < blockhigh; y++) \
671736   { \
672737      int realy = ((y*incy)>>21); \
r21416r21417
674739      if ((drawy>383) || (drawy<0)) continue; \
675740      line = &drawbitmap->pix32(drawy); \
676741      zline = &object->zbitmap->pix16(drawy); \
742      for (int x = 0; x < blockwide; x++) \
743      { \
744         const int drawx = pixelOffsetX+x; \
745         if ((drawx>495 || drawx<0)) continue; \
746         int realx = ((x*incx)>>21); \
677747
678748
679#define XLOOP_START \
680   for (int x = 0; x < blockwide; x++) \
749#define YXLOOP_START_NO_ZOOM \
750   for (int y = 0; y < 16; y++) \
681751   { \
682      const int drawx = pixelOffsetX+x; \
683      if ((drawx>495 || drawx<0)) continue; \
684      int realx = ((x*incx)>>21); \
752      const int drawy = pixelOffsetY+y; \
753      if ((drawy>383) || (drawy<0)) continue; \
754      line = &drawbitmap->pix32(drawy); \
755      zline = &object->zbitmap->pix16(drawy); \
756      for (int x = 0; x < 16; x++) \
757      { \
758         const int drawx = pixelOffsetX+x; \
759         if ((drawx>495 || drawx<0)) continue; \
685760
686761
762
763
764
687765/* the two tables that the patent claims are located at:
688766   0x1ec800
689767   0x1f0000
r21416r21417
921999      }
9221000
9231001      // I don't know, the Rainbow is a non-zoomed sprite and won't link unless you move one half
924      if (used_flipx)
925         hPositionx -= 1;
1002      //  (fixed in the hOrigin handling instead)
1003      //if (used_flipx)
1004      //   hPositionx -= 1;
9261005
9271006      UINT16 hZoomTable[16];
9281007      int hPositionTable[16];
r21416r21417
9581037               // middle?
9591038               break;
9601039            case 2:
961               hPositionTable[idx] -= sizex;
1040               hPositionTable[idx] -= sizex-1;
9621041               // right?
9631042               break;
9641043            case 3:
r21416r21417
9841063            // middle?
9851064            break;
9861065         case 2:
987            hPosition -= sizex;
1066            hPosition -= sizex-1;
9881067            // right?
9891068            break;
9901069         case 3:
r21416r21417
10591138         UINT16 tempshape[16*16];
10601139         
10611140         int color_offs = (0x7b20 + (b1colorNumber & 0x7ff))*0x40 * 5; /* yes, * 5 */
1062
1063         // skip the decoding if it's the same tile as last time!
1064         if (spriteNumber != lastSpriteNumber)
1141         UINT16 blankcount = 256;
1142         
1143         if (used_flipy)
10651144         {
1066            lastSpriteNumber = spriteNumber;
1067
1068            int i = 1;// skip first 10 bits for now
1069            int data_written = 0;
1070
1071            while (data_written<256)
1145            if (used_flipx)
10721146            {
1073
1074               UINT16 compdata = expanded_10bit_gfx[ (b3romoffset) + spriteNumber + i];
1075
1076               if (((compdata & 0x300) == 0x000) || ((compdata & 0x300) == 0x100)) // 3bpp
1077               {
1078                  // mm ccrr rrr0
1079                  int encodelength = (compdata & 0x03e)>>1;
1080                  int rledata = (compdata & 0x1c0) >> 6;
1081
1082                  // guess, blank tiles have the following form
1083                  // 00120 (00000024,0) | 010 03f
1084                  if (compdata&1) encodelength = 255;
1085
1086                  while (data_written<256 && encodelength >=0) // 6bpp
1087                  {
1088                     tempshape[data_written] = rearranged_16bit_gfx[color_offs + rledata];
1089                     encodelength--;
1090                     data_written++;
1091                  }
1092               }
1093               else if ((compdata & 0x300) == 0x200) // 8bpp
1094               {
1095                  // mm cccc ccrr
1096                  int encodelength = (compdata & 0x003);
1097                  int rledata = (compdata & 0x0fc) >> 2;
1098
1099                  while (data_written<256 && encodelength >=0)
1100                  {
1101                     tempshape[data_written] = rearranged_16bit_gfx[color_offs + rledata + 8]; // + 0x8 crt test, most of red, green, start of blue
1102                     encodelength--;
1103                     data_written++;
1104                  }
1105
1106               }
1107               else
1108               {
1109                  int rledata = (compdata & 0x0ff);
1110                  // mm cccc cccc
1111                  tempshape[data_written] = rearranged_16bit_gfx[color_offs + rledata + 0x48]; // +0x48 crt test end of blue, start of white
1112                  data_written++;
1113               }
1114
1115               i++;
1147               RLE_BLOCK(0xff)
11161148            }
1149            else
1150            {
1151               RLE_BLOCK(0xf0)
1152            }
11171153         }
1154         else
1155         {   if (used_flipx)
1156            {
1157               RLE_BLOCK(0x0f)
1158            }
1159            else
1160            {
1161               RLE_BLOCK(0x00)
1162            }
1163         }
11181164
11191165
1166         if (blankcount==0)
1167            continue;
1168
11201169         if (!vZoom)
11211170         {
11221171            // abort, but make sure we clean up
r21416r21417
11381187         {
11391188            if (blit_rotate)
11401189            {
1141               if (used_flipy)
1142               {
1143                  YLOOP_START
1144
1145                     if (used_flipx)
1146                     {
1147                        XLOOP_START
1148
1149                           UINT16 pix = tempshape[(15-realx)*16+(15-realy)];
1150                           DRAW_PIX
1151                        }
1152                     }
1153                     else
1154                     {
1155                        XLOOP_START
1156
1157                           UINT16 pix = tempshape[(15-realx)*16+realy];
1158                           DRAW_PIX
1159                        }
1160                     }
1161                  }
1162               }
1163               else
1164               {
1165                  YLOOP_START
1166
1167                     if (used_flipx)
1168                     {
1169                        XLOOP_START
1170
1171                           UINT16 pix = tempshape[realx*16+(15-realy)];
1172                           DRAW_PIX
1173                        }
1174                     }
1175                     else
1176                     {
1177                        XLOOP_START
1178
1179                           UINT16 pix = tempshape[realx*16+realy];
1180                           DRAW_PIX
1181                        }
1182                     }
1183                  }
1184               }
1190               YXLOOP_START
1191               UINT16 pix = tempshape[realx*16+realy];
1192               DRAW_PIX
1193               YXLOOP_END
11851194            }
11861195            else // no rotate
11871196            {
1188               if (used_flipy)
1189               {
1190                  YLOOP_START
1191
1192                     if (used_flipx)
1193                     {
1194                        XLOOP_START
1195
1196                           UINT16 pix = tempshape[(15-realy)*16+(15-realx)];
1197                           DRAW_PIX
1198                        }
1199                     }
1200                     else
1201                     {
1202                        XLOOP_START
1203                           UINT16 pix = tempshape[(15-realy)*16+realx];
1204                           DRAW_PIX
1205                        }
1206                     }
1207                  }
1208               }
1209               else // no rotate, no flipy
1210               {
1211                  YLOOP_START
1212
1213                     if (used_flipx)
1214                     {
1215                        XLOOP_START
1216
1217                           UINT16 pix = tempshape[realy*16+(15-realx)];
1218                           DRAW_PIX
1219                        }
1220                     }
1221                     else // no rotate, no flipy, no flipx
1222                     {
1223                        XLOOP_START
1224
1225                           UINT16 pix = tempshape[realy*16+realx];
1226                           DRAW_PIX
1227                        }
1228                     }
1229                  }
1230               }
1197               YXLOOP_START
1198               UINT16 pix = tempshape[realy*16+realx];
1199               DRAW_PIX
1200               YXLOOP_END
12311201            }
12321202         }
12331203         else  // no indirect zoom
r21416r21417
12371207               // abort, but make sure we clean up
12381208               goto end;
12391209            }
1240            const int pixelOffsetX = ((hPosition) + (h* 16 * hZoom)) / 0x40;
1241            int blockwide = ((16*hZoom)/0x40);
1242            UINT32 incx = 0x8000000 / hZoom;
12431210
1244            if (blit_rotate)
1211            if ((hZoom==0x40) && (vZoom==0x40)) // non-zoomed
12451212            {
1246               if (used_flipy)
1247               {
1248                  YLOOP_START_NO_LINEZOOM
1213               const int pixelOffsetX = ((hPosition/0x40) + (h* 16));
12491214
1250                     if (used_flipx)
1251                     {
1252                        XLOOP_START
1253
1254                           UINT16 pix = tempshape[(15-realx)*16+(15-realy)];
1255                           DRAW_PIX
1256                        }
1257                     }
1258                     else
1259                     {
1260                        XLOOP_START
1261
1262                           UINT16 pix = tempshape[(15-realx)*16+realy];
1263                           DRAW_PIX
1264                        }
1265                     }
1266                  }
1215               if (blit_rotate)
1216               {
1217                  YXLOOP_START_NO_ZOOM
1218                  UINT16 pix = tempshape[x*16+y];
1219                  DRAW_PIX
1220                  YXLOOP_END
12671221               }
1268               else
1222               else // no rotate
12691223               {
1270                  YLOOP_START_NO_LINEZOOM
1271
1272                     if (used_flipx)
1273                     {
1274                        XLOOP_START
1275
1276                           UINT16 pix = tempshape[realx*16+(15-realy)];
1277                           DRAW_PIX
1278                        }
1279                     }
1280                     else
1281                     {
1282                        XLOOP_START
1283
1284                           UINT16 pix = tempshape[realx*16+realy];
1285                           DRAW_PIX
1286                        }
1287                     }
1288                  }
1224                  YXLOOP_START_NO_ZOOM
1225                  UINT16 pix = tempshape[y*16+x];
1226                  DRAW_PIX
1227                  YXLOOP_END
12891228               }
12901229            }
1291            else // no rotate
1230            else // zoomed
12921231            {
1293               if (used_flipy)
1294               {
1295                  YLOOP_START_NO_LINEZOOM
1232               const int pixelOffsetX = ((hPosition) + (h* 16 * hZoom)) / 0x40;
1233               int blockwide = ((16*hZoom)/0x40);
1234               UINT32 incx = 0x8000000 / hZoom;
12961235
1297                     if (used_flipx)
1298                     {
1299                        XLOOP_START
1300
1301                           UINT16 pix = tempshape[(15-realy)*16+(15-realx)];
1302                           DRAW_PIX
1303                        }
1304                     }
1305                     else
1306                     {
1307                        XLOOP_START
1308                           UINT16 pix = tempshape[(15-realy)*16+realx];
1309                           DRAW_PIX
1310                        }
1311                     }
1312                  }
1236               if (blit_rotate)
1237               {
1238                  YXLOOP_START_NO_LINEZOOM
1239                  UINT16 pix = tempshape[realx*16+realy];
1240                  DRAW_PIX
1241                  YXLOOP_END
13131242               }
1314               else // no rotate, no flipy
1243               else // no rotate
13151244               {
1316                  YLOOP_START_NO_LINEZOOM
1317
1318                     if (used_flipx)
1319                     {
1320                        XLOOP_START
1321
1322                           UINT16 pix = tempshape[realy*16+(15-realx)];
1323                           DRAW_PIX
1324                        }
1325                     }
1326                     else // no rotate, no flipy, no flipx
1327                     {
1328                        XLOOP_START
1329
1330                           UINT16 pix = tempshape[realy*16+realx];
1331                           DRAW_PIX
1332                        }
1333                     }
1334                  }
1245                  YXLOOP_START_NO_LINEZOOM
1246                  UINT16 pix = tempshape[realy*16+realx];
1247                  DRAW_PIX
1248                  YXLOOP_END
13351249               }
1336            }
1250            } // end zoomed
13371251         } // end no indirect zoom
13381252      }
13391253   }

Previous 199869 Revisions Next


© 1997-2024 The MAME Team