trunk/src/mame/drivers/coolridr.c
| r21416 | r21417 | |
| 650 | 650 | coolridr_state* state; |
| 651 | 651 | }; |
| 652 | 652 | |
| 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 \ |
| 654 | 711 | for (int y = 0; y < blockhigh; y++) \ |
| 655 | 712 | { \ |
| 656 | 713 | int realy = ((y*incy)>>21); \ |
| r21416 | r21417 | |
| 663 | 720 | zline = &object->zbitmap->pix16(drawy); \ |
| 664 | 721 | int blockwide = ((16*hZoomTable[realy])/0x40); \ |
| 665 | 722 | 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); \ |
| 666 | 728 | |
| 729 | #define YXLOOP_END \ |
| 730 | } \ |
| 731 | } \ |
| 667 | 732 | |
| 668 | 733 | |
| 669 | | #define YLOOP_START_NO_LINEZOOM \ |
| 734 | #define YXLOOP_START_NO_LINEZOOM \ |
| 670 | 735 | for (int y = 0; y < blockhigh; y++) \ |
| 671 | 736 | { \ |
| 672 | 737 | int realy = ((y*incy)>>21); \ |
| r21416 | r21417 | |
| 674 | 739 | if ((drawy>383) || (drawy<0)) continue; \ |
| 675 | 740 | line = &drawbitmap->pix32(drawy); \ |
| 676 | 741 | 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); \ |
| 677 | 747 | |
| 678 | 748 | |
| 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++) \ |
| 681 | 751 | { \ |
| 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; \ |
| 685 | 760 | |
| 686 | 761 | |
| 762 | |
| 763 | |
| 764 | |
| 687 | 765 | /* the two tables that the patent claims are located at: |
| 688 | 766 | 0x1ec800 |
| 689 | 767 | 0x1f0000 |
| r21416 | r21417 | |
| 921 | 999 | } |
| 922 | 1000 | |
| 923 | 1001 | // 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; |
| 926 | 1005 | |
| 927 | 1006 | UINT16 hZoomTable[16]; |
| 928 | 1007 | int hPositionTable[16]; |
| r21416 | r21417 | |
| 958 | 1037 | // middle? |
| 959 | 1038 | break; |
| 960 | 1039 | case 2: |
| 961 | | hPositionTable[idx] -= sizex; |
| 1040 | hPositionTable[idx] -= sizex-1; |
| 962 | 1041 | // right? |
| 963 | 1042 | break; |
| 964 | 1043 | case 3: |
| r21416 | r21417 | |
| 984 | 1063 | // middle? |
| 985 | 1064 | break; |
| 986 | 1065 | case 2: |
| 987 | | hPosition -= sizex; |
| 1066 | hPosition -= sizex-1; |
| 988 | 1067 | // right? |
| 989 | 1068 | break; |
| 990 | 1069 | case 3: |
| r21416 | r21417 | |
| 1059 | 1138 | UINT16 tempshape[16*16]; |
| 1060 | 1139 | |
| 1061 | 1140 | 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) |
| 1065 | 1144 | { |
| 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) |
| 1072 | 1146 | { |
| 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) |
| 1116 | 1148 | } |
| 1149 | else |
| 1150 | { |
| 1151 | RLE_BLOCK(0xf0) |
| 1152 | } |
| 1117 | 1153 | } |
| 1154 | else |
| 1155 | { if (used_flipx) |
| 1156 | { |
| 1157 | RLE_BLOCK(0x0f) |
| 1158 | } |
| 1159 | else |
| 1160 | { |
| 1161 | RLE_BLOCK(0x00) |
| 1162 | } |
| 1163 | } |
| 1118 | 1164 | |
| 1119 | 1165 | |
| 1166 | if (blankcount==0) |
| 1167 | continue; |
| 1168 | |
| 1120 | 1169 | if (!vZoom) |
| 1121 | 1170 | { |
| 1122 | 1171 | // abort, but make sure we clean up |
| r21416 | r21417 | |
| 1138 | 1187 | { |
| 1139 | 1188 | if (blit_rotate) |
| 1140 | 1189 | { |
| 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 |
| 1185 | 1194 | } |
| 1186 | 1195 | else // no rotate |
| 1187 | 1196 | { |
| 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 |
| 1231 | 1201 | } |
| 1232 | 1202 | } |
| 1233 | 1203 | else // no indirect zoom |
| r21416 | r21417 | |
| 1237 | 1207 | // abort, but make sure we clean up |
| 1238 | 1208 | goto end; |
| 1239 | 1209 | } |
| 1240 | | const int pixelOffsetX = ((hPosition) + (h* 16 * hZoom)) / 0x40; |
| 1241 | | int blockwide = ((16*hZoom)/0x40); |
| 1242 | | UINT32 incx = 0x8000000 / hZoom; |
| 1243 | 1210 | |
| 1244 | | if (blit_rotate) |
| 1211 | if ((hZoom==0x40) && (vZoom==0x40)) // non-zoomed |
| 1245 | 1212 | { |
| 1246 | | if (used_flipy) |
| 1247 | | { |
| 1248 | | YLOOP_START_NO_LINEZOOM |
| 1213 | const int pixelOffsetX = ((hPosition/0x40) + (h* 16)); |
| 1249 | 1214 | |
| 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 |
| 1267 | 1221 | } |
| 1268 | | else |
| 1222 | else // no rotate |
| 1269 | 1223 | { |
| 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 |
| 1289 | 1228 | } |
| 1290 | 1229 | } |
| 1291 | | else // no rotate |
| 1230 | else // zoomed |
| 1292 | 1231 | { |
| 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; |
| 1296 | 1235 | |
| 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 |
| 1313 | 1242 | } |
| 1314 | | else // no rotate, no flipy |
| 1243 | else // no rotate |
| 1315 | 1244 | { |
| 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 |
| 1335 | 1249 | } |
| 1336 | | } |
| 1250 | } // end zoomed |
| 1337 | 1251 | } // end no indirect zoom |
| 1338 | 1252 | } |
| 1339 | 1253 | } |