trunk/src/mame/drivers/coolridr.c
| r21417 | r21418 | |
| 364 | 364 | #include "machine/nvram.h" |
| 365 | 365 | #include "rendlay.h" |
| 366 | 366 | |
| 367 | #define CLIPWIDTH (496-1) |
| 368 | #define CLIPHIGH (384-1) |
| 367 | 369 | |
| 368 | | |
| 369 | 370 | class coolridr_state : public driver_device |
| 370 | 371 | { |
| 371 | 372 | public: |
| r21417 | r21418 | |
| 529 | 530 | UINT32 coolridr_state::screen_update_coolridr(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int which) |
| 530 | 531 | { |
| 531 | 532 | /* planes seems to basically be at 0x8000 and 0x28000... */ |
| 533 | #if 1 |
| 532 | 534 | UINT32 base_offset; |
| 533 | 535 | int xsrc,ysrc,ydst,xdst; |
| 534 | 536 | int xisrc,yisrc; |
| r21417 | r21418 | |
| 595 | 597 | bitmap.pix32(ydst, xdst) = r<<16 | g<<8 | b; |
| 596 | 598 | } |
| 597 | 599 | } |
| 598 | | |
| 600 | #endif |
| 599 | 601 | if (which==0) |
| 600 | 602 | { |
| 601 | 603 | // will probably need a custom function |
| r21417 | r21418 | |
| 714 | 716 | if (!hZoomTable[realy]) \ |
| 715 | 717 | continue; \ |
| 716 | 718 | const int pixelOffsetX = ((hPositionTable[realy]) + (h* 16 * hZoomTable[realy])) / 0x40; \ |
| 719 | const int pixelOffsetnextX = ((hPositionTable[realy]) + ((h+1)* 16 * hZoomTable[realy])) / 0x40; \ |
| 717 | 720 | const int drawy = pixelOffsetY+y; \ |
| 718 | | if ((drawy>383) || (drawy<0)) continue; \ |
| 721 | if ((drawy>CLIPHIGH) || (drawy<0)) continue; \ |
| 719 | 722 | line = &drawbitmap->pix32(drawy); \ |
| 720 | 723 | 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; \ |
| 722 | 729 | UINT32 incx = 0x8000000 / hZoomTable[realy]; \ |
| 723 | 730 | for (int x = 0; x < blockwide; x++) \ |
| 724 | 731 | { \ |
| 725 | 732 | const int drawx = pixelOffsetX+x; \ |
| 726 | | if ((drawx>495 || drawx<0)) continue; \ |
| 733 | if ((drawx>CLIPWIDTH || drawx<0)) continue; \ |
| 727 | 734 | int realx = ((x*incx)>>21); \ |
| 728 | 735 | |
| 729 | 736 | #define YXLOOP_END \ |
| r21417 | r21418 | |
| 736 | 743 | { \ |
| 737 | 744 | int realy = ((y*incy)>>21); \ |
| 738 | 745 | const int drawy = pixelOffsetY+y; \ |
| 739 | | if ((drawy>383) || (drawy<0)) continue; \ |
| 746 | if ((drawy>CLIPHIGH) || (drawy<0)) continue; \ |
| 740 | 747 | line = &drawbitmap->pix32(drawy); \ |
| 741 | 748 | zline = &object->zbitmap->pix16(drawy); \ |
| 742 | 749 | for (int x = 0; x < blockwide; x++) \ |
| 743 | 750 | { \ |
| 744 | 751 | const int drawx = pixelOffsetX+x; \ |
| 745 | | if ((drawx>495 || drawx<0)) continue; \ |
| 752 | if ((drawx>CLIPWIDTH || drawx<0)) continue; \ |
| 746 | 753 | int realx = ((x*incx)>>21); \ |
| 747 | 754 | |
| 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); \ |
| 748 | 767 | |
| 768 | |
| 749 | 769 | #define YXLOOP_START_NO_ZOOM \ |
| 750 | 770 | for (int y = 0; y < 16; y++) \ |
| 751 | 771 | { \ |
| 752 | 772 | const int drawy = pixelOffsetY+y; \ |
| 753 | | if ((drawy>383) || (drawy<0)) continue; \ |
| 773 | if ((drawy>CLIPHIGH) || (drawy<0)) continue; \ |
| 754 | 774 | line = &drawbitmap->pix32(drawy); \ |
| 755 | 775 | zline = &object->zbitmap->pix16(drawy); \ |
| 756 | 776 | for (int x = 0; x < 16; x++) \ |
| 757 | 777 | { \ |
| 758 | 778 | const int drawx = pixelOffsetX+x; \ |
| 759 | | if ((drawx>495 || drawx<0)) continue; \ |
| 779 | if ((drawx>CLIPWIDTH || drawx<0)) continue; \ |
| 760 | 780 | |
| 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; \ |
| 761 | 791 | |
| 762 | 792 | |
| 763 | 793 | |
| 764 | | |
| 765 | 794 | /* the two tables that the patent claims are located at: |
| 766 | 795 | 0x1ec800 |
| 767 | 796 | 0x1f0000 |
| r21417 | r21418 | |
| 781 | 810 | int r,g,b; \ |
| 782 | 811 | r = pal5bit((pix >> 10) & 0x1f); \ |
| 783 | 812 | g = pal5bit((pix >> 5) & 0x1f); \ |
| 784 | | b = pal5bit((pix >> 0) & 0x1f); \ |
| 813 | b = pal5bit((pix >> 0) & 0x1f); \ |
| 785 | 814 | line[drawx] = r<<16 | g<<8 | b; \ |
| 786 | 815 | zline[drawx] = object->zpri; \ |
| 787 | 816 | } \ |
| r21417 | r21418 | |
| 913 | 942 | UINT16 vZoom = (object->spriteblit[8] & 0xffff0000) >> 16; |
| 914 | 943 | UINT16 hZoom = (object->spriteblit[8] & 0x0000ffff); |
| 915 | 944 | |
| 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 | |
| 916 | 961 | /************* object->spriteblit[9] *************/ |
| 917 | 962 | |
| 918 | 963 | int vPosition = (object->spriteblit[9] & 0xffff0000) >> 16; |
| r21417 | r21418 | |
| 991 | 1036 | |
| 992 | 1037 | |
| 993 | 1038 | const int pixelOffsetY = ((vPosition) + (v* 16 * vZoom)) / 0x40; |
| 1039 | const int pixelOffsetnextY = ((vPosition) + ((v+1)* 16 * vZoom)) / 0x40; |
| 994 | 1040 | |
| 995 | | if (pixelOffsetY>383) |
| 1041 | int blockhigh = pixelOffsetnextY - pixelOffsetY; |
| 1042 | |
| 1043 | if (pixelOffsetY+blockhigh<0) |
| 1044 | continue; |
| 1045 | |
| 1046 | |
| 1047 | |
| 1048 | if (pixelOffsetY>CLIPHIGH) |
| 996 | 1049 | { |
| 997 | 1050 | v = used_vCellCount; |
| 998 | 1051 | continue; |
| r21417 | r21418 | |
| 1079 | 1132 | if (!indirect_zoom_enable) |
| 1080 | 1133 | { |
| 1081 | 1134 | // int offs = ((hPosition) + (h* 16 * hZoom)) / 0x40; |
| 1082 | | // if (offs>495) continue; |
| 1135 | // if (offs>CLIPWIDTH) continue; |
| 1083 | 1136 | } |
| 1084 | 1137 | |
| 1085 | 1138 | UINT32 lastSpriteNumber = 0xffffffff; |
| r21417 | r21418 | |
| 1166 | 1219 | if (blankcount==0) |
| 1167 | 1220 | continue; |
| 1168 | 1221 | |
| 1169 | | if (!vZoom) |
| 1170 | | { |
| 1171 | | // abort, but make sure we clean up |
| 1172 | | goto end; |
| 1173 | | } |
| 1174 | 1222 | |
| 1175 | | int blockhigh = ((16*vZoom)/0x40); |
| 1176 | 1223 | |
| 1177 | 1224 | |
| 1178 | 1225 | |
| 1226 | |
| 1179 | 1227 | UINT32 incy = 0x8000000 / vZoom; |
| 1180 | 1228 | |
| 1181 | 1229 | // DEBUG: Draw 16x16 block |
| r21417 | r21418 | |
| 1212 | 1260 | { |
| 1213 | 1261 | const int pixelOffsetX = ((hPosition/0x40) + (h* 16)); |
| 1214 | 1262 | |
| 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) |
| 1216 | 1270 | { |
| 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 | } |
| 1221 | 1285 | } |
| 1222 | | else // no rotate |
| 1286 | else |
| 1223 | 1287 | { |
| 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 | } |
| 1228 | 1302 | } |
| 1229 | 1303 | } |
| 1230 | 1304 | else // zoomed |
| 1231 | 1305 | { |
| 1232 | 1306 | 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; |
| 1234 | 1310 | UINT32 incx = 0x8000000 / hZoom; |
| 1235 | 1311 | |
| 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) |
| 1237 | 1319 | { |
| 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 | } |
| 1242 | 1334 | } |
| 1243 | | else // no rotate |
| 1335 | else |
| 1244 | 1336 | { |
| 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 | } |
| 1249 | 1351 | } |
| 1250 | 1352 | } // end zoomed |
| 1251 | 1353 | } // end no indirect zoom |
| r21417 | r21418 | |
| 2597 | 2699 | MCFG_SCREEN_ADD("lscreen", RASTER) |
| 2598 | 2700 | MCFG_SCREEN_REFRESH_RATE(60) |
| 2599 | 2701 | MCFG_SCREEN_SIZE(640, 512) |
| 2600 | | MCFG_SCREEN_VISIBLE_AREA(0,495, 0, 383) |
| 2702 | MCFG_SCREEN_VISIBLE_AREA(0,CLIPWIDTH, 0, CLIPHIGH) |
| 2601 | 2703 | MCFG_SCREEN_UPDATE_DRIVER(coolridr_state, screen_update_coolridr1) |
| 2602 | 2704 | |
| 2603 | 2705 | MCFG_SCREEN_ADD("rscreen", RASTER) |
| 2604 | 2706 | MCFG_SCREEN_REFRESH_RATE(60) |
| 2605 | 2707 | MCFG_SCREEN_SIZE(640, 512) |
| 2606 | | MCFG_SCREEN_VISIBLE_AREA(0,495, 0, 383) |
| 2708 | MCFG_SCREEN_VISIBLE_AREA(0,CLIPWIDTH, 0, CLIPHIGH) |
| 2607 | 2709 | MCFG_SCREEN_UPDATE_DRIVER(coolridr_state, screen_update_coolridr2) |
| 2608 | 2710 | |
| 2609 | 2711 | MCFG_PALETTE_LENGTH(0x10000) |