src/mame/drivers/megadriv.c
| r9383 | r9384 | |
| 4664 | 4664 | |
| 4665 | 4665 | // non-tilemap functions to get a pixel from a 'tilemap' based on the above, but looking up each pixel, as to avoid the heavy cache bitmap |
| 4666 | 4666 | |
| 4667 | | INLINE UINT8 get_stampmap_16x16_1x1_tile_info_pixel(running_machine* machine, UINT16 xpos, UINT16 ypos) |
| 4667 | INLINE UINT8 get_stampmap_16x16_1x1_tile_info_pixel(running_machine* machine, int xpos, int ypos) |
| 4668 | 4668 | { |
| 4669 | 4669 | const int tilesize = 4; // 0xf pixels |
| 4670 | 4670 | const int tilemapsize = 0x0f; |
| 4671 | 4671 | |
| 4672 | 4672 | int wraparound = segacd_stampsize&1; |
| 4673 | | wraparound = 1; |
| 4674 | 4673 | |
| 4675 | 4674 | int xtile = xpos / (1<<tilesize); |
| 4676 | 4675 | int ytile = ypos / (1<<tilesize); |
| r9383 | r9384 | |
| 4701 | 4700 | return srcdata[((ypos&((1<<tilesize)-1))*(1<<tilesize))+(xpos&((1<<tilesize)-1))]; |
| 4702 | 4701 | } |
| 4703 | 4702 | |
| 4704 | | INLINE UINT8 get_stampmap_32x32_1x1_tile_info_pixel(running_machine* machine, UINT16 xpos, UINT16 ypos) |
| 4703 | INLINE UINT8 get_stampmap_32x32_1x1_tile_info_pixel(running_machine* machine, int xpos, int ypos) |
| 4705 | 4704 | { |
| 4706 | 4705 | const int tilesize = 5; // 0x1f pixels |
| 4707 | 4706 | const int tilemapsize = 0x07; |
| 4708 | 4707 | |
| 4709 | 4708 | int wraparound = segacd_stampsize&1; |
| 4710 | | wraparound = 1; |
| 4711 | 4709 | |
| 4712 | 4710 | int xtile = xpos / (1<<tilesize); |
| 4713 | 4711 | int ytile = ypos / (1<<tilesize); |
| r9383 | r9384 | |
| 4738 | 4736 | return srcdata[((ypos&((1<<tilesize)-1))*(1<<tilesize))+(xpos&((1<<tilesize)-1))]; |
| 4739 | 4737 | } |
| 4740 | 4738 | |
| 4741 | | INLINE UINT8 get_stampmap_16x16_16x16_tile_info_pixel(running_machine* machine, UINT16 xpos, UINT16 ypos) |
| 4739 | INLINE UINT8 get_stampmap_16x16_16x16_tile_info_pixel(running_machine* machine, int xpos, int ypos) |
| 4742 | 4740 | { |
| 4743 | 4741 | const int tilesize = 4; // 0xf pixels |
| 4744 | 4742 | const int tilemapsize = 0xff; |
| 4745 | 4743 | |
| 4746 | 4744 | int wraparound = segacd_stampsize&1; |
| 4747 | | wraparound = 1; |
| 4748 | 4745 | |
| 4749 | 4746 | int xtile = xpos / (1<<tilesize); |
| 4750 | 4747 | int ytile = ypos / (1<<tilesize); |
| r9383 | r9384 | |
| 4775 | 4772 | return srcdata[((ypos&((1<<tilesize)-1))*(1<<tilesize))+(xpos&((1<<tilesize)-1))]; |
| 4776 | 4773 | } |
| 4777 | 4774 | |
| 4778 | | INLINE UINT8 get_stampmap_32x32_16x16_tile_info_pixel(running_machine* machine, UINT16 xpos, UINT16 ypos) |
| 4775 | INLINE UINT8 get_stampmap_32x32_16x16_tile_info_pixel(running_machine* machine, int xpos, int ypos) |
| 4779 | 4776 | { |
| 4780 | 4777 | const int tilesize = 5; // 0x1f pixels |
| 4781 | 4778 | const int tilemapsize = 0x7f; |
| 4782 | 4779 | |
| 4783 | 4780 | int wraparound = segacd_stampsize&1; |
| 4784 | | wraparound = 1; |
| 4785 | 4781 | |
| 4786 | 4782 | int xtile = xpos / (1<<tilesize); |
| 4787 | 4783 | int ytile = ypos / (1<<tilesize); |
| r9383 | r9384 | |
| 5290 | 5286 | // the lower 3 bits of segacd_imagebuffer_hdot_size are set |
| 5291 | 5287 | |
| 5292 | 5288 | // this really needs to be doing it's own lookups rather than depending on the inefficient MAME cache.. |
| 5293 | | INLINE UINT8 read_pixel_from_stampmap( running_machine* machine, bitmap_t* srcbitmap, UINT16 x, UINT16 y) |
| 5289 | INLINE UINT8 read_pixel_from_stampmap( running_machine* machine, bitmap_t* srcbitmap, int x, int y) |
| 5294 | 5290 | { |
| 5295 | 5291 | /* |
| 5296 | 5292 | if (!srcbitmap) |
| r9383 | r9384 | |
| 5388 | 5384 | { |
| 5389 | 5385 | int base = (data & 0xfffe) * 4; |
| 5390 | 5386 | |
| 5391 | | logerror("actual base = %06x\n", base + 0x80000); |
| 5387 | //printf("actual base = %06x\n", base + 0x80000); |
| 5392 | 5388 | |
| 5393 | 5389 | // nasty nasty nasty |
| 5394 | 5390 | //segacd_mark_stampmaps_dirty(); |
| r9383 | r9384 | |
| 5406 | 5402 | for (line=0;line<segacd_imagebuffer_vdot_size;line++) |
| 5407 | 5403 | { |
| 5408 | 5404 | int currbase = base + line * 0x8; |
| 5409 | | UINT16 param1,param2,param3,param4; |
| 5410 | 5405 | |
| 5411 | | param1 = segacd_dataram[(currbase+0x0)>>1]; |
| 5412 | | param2 = segacd_dataram[(currbase+0x2)>>1]; |
| 5413 | | param3 = segacd_dataram[(currbase+0x4)>>1]; |
| 5414 | | param4 = segacd_dataram[(currbase+0x6)>>1]; |
| 5406 | // are the 256x256 tile modes using the same sign bits? |
| 5407 | INT16 tilemapxoffs,tilemapyoffs; |
| 5408 | INT16 deltax,deltay; |
| 5409 | |
| 5410 | tilemapxoffs = segacd_dataram[(currbase+0x0)>>1]; |
| 5411 | tilemapyoffs = segacd_dataram[(currbase+0x2)>>1]; |
| 5412 | deltax = segacd_dataram[(currbase+0x4)>>1]; // x-zoom |
| 5413 | deltay = segacd_dataram[(currbase+0x6)>>1]; // rotation |
| 5415 | 5414 | |
| 5415 | //printf("%06x: %04x (%d) %04x (%d) %04x %04x\n", currbase, tilemapxoffs, tilemapxoffs>>3, tilemapyoffs, tilemapyoffs>>3, deltax, deltay); |
| 5416 | 5416 | |
| 5417 | | //printf("%06x: %04x (%d) %04x (%d) %04x %04x\n", currbase, param1, param1>>3, param2, param2>>3, param3, param4); |
| 5418 | | |
| 5419 | | int xbase = param1 << 8; |
| 5420 | | int ybase = param2 << 8; |
| 5417 | int xbase = tilemapxoffs * 256; |
| 5418 | int ybase = tilemapyoffs * 256; |
| 5421 | 5419 | int count; |
| 5422 | 5420 | |
| 5423 | 5421 | for (count=0;count<(segacd_imagebuffer_hdot_size>>3);count++) |
| r9383 | r9384 | |
| 5428 | 5426 | { |
| 5429 | 5427 | pixblock |= read_pixel_from_stampmap(space->machine, srcbitmap, xbase>>(3+8), ybase>>(3+8)) << (i); |
| 5430 | 5428 | |
| 5431 | | if (param3&0x8000) |
| 5432 | | xbase -= param3&0x7fff; |
| 5433 | | else |
| 5434 | | xbase += param3&0x7fff; |
| 5435 | | |
| 5436 | | if (param4&0x8000) |
| 5437 | | ybase -= param4&0x7fff; |
| 5438 | | else |
| 5439 | | ybase += param4&0x7fff; |
| 5440 | 5429 | |
| 5430 | xbase += deltax; |
| 5431 | ybase += deltay; |
| 5432 | |
| 5441 | 5433 | |
| 5442 | 5434 | } |
| 5443 | 5435 | |