src/mess/video/fmtowns.c
| r6727 | r6728 | |
| 612 | 612 | * +2: Y position (10-bit) |
| 613 | 613 | * +4: Sprite Attribute |
| 614 | 614 | * bit 15: enforce offsets (regs 2-5) |
| 615 | * bit 12,13: flip sprite |
| 615 | 616 | * bits 10-0: Sprite RAM offset containing sprite pattern |
| 616 | 617 | * TODO: other attributes (zoom?) |
| 617 | 618 | * +6: Sprite Colour |
| 618 | 619 | * bit 15: use colour data in located in sprite RAM offset in bits 11-0 (x32) |
| 619 | 620 | */ |
| 620 | | void render_sprite_4(bitmap_t* bitmap, UINT32 poffset, UINT32 coffset, UINT16 x, UINT16 y, const rectangle* rect) |
| 621 | void render_sprite_4(bitmap_t* bitmap, UINT32 poffset, UINT32 coffset, UINT16 x, UINT16 y, UINT16 xflip, UINT16 yflip, const rectangle* rect) |
| 621 | 622 | { |
| 622 | 623 | UINT16 xpos,ypos; |
| 623 | 624 | UINT16 col,pixel; |
| 624 | 625 | UINT32 voffset; |
| 626 | int xstart,xend,xdir,ystart,yend,ydir; |
| 625 | 627 | |
| 626 | | for(ypos=y;ypos<y+16;ypos++) |
| 628 | if(xflip) |
| 627 | 629 | { |
| 628 | | for(xpos=x;xpos<x+16;xpos+=2) |
| 630 | xstart = x+16; |
| 631 | xend = x; |
| 632 | xdir = -2; |
| 633 | } |
| 634 | else |
| 635 | { |
| 636 | xstart = x; |
| 637 | xend = x+16; |
| 638 | xdir = 2; |
| 639 | } |
| 640 | if(yflip) |
| 641 | { |
| 642 | ystart = y+16; |
| 643 | yend = y; |
| 644 | ydir = -1; |
| 645 | } |
| 646 | else |
| 647 | { |
| 648 | ystart = y; |
| 649 | yend = y+16; |
| 650 | ydir = 1; |
| 651 | } |
| 652 | |
| 653 | for(ypos=ystart;ypos!=yend;ypos+=ydir) |
| 654 | { |
| 655 | for(xpos=xstart;xpos!=xend;xpos+=xdir) |
| 629 | 656 | { |
| 630 | 657 | voffset = 0; |
| 631 | | pixel = towns_sprram[poffset] & 0x0f; |
| 658 | if(xflip) |
| 659 | pixel = (towns_sprram[poffset] & 0xf0) >> 4; |
| 660 | else |
| 661 | pixel = towns_sprram[poffset] & 0x0f; |
| 632 | 662 | col = towns_sprram[coffset+(pixel*2)] | (towns_sprram[coffset+(pixel*2)+1] << 8); |
| 633 | 663 | voffset += (towns_crtc_reg[24] * 4) * ypos; // scanline size in bytes * y pos |
| 634 | 664 | voffset += (xpos & 0x1ff) * 2; |
| r6727 | r6728 | |
| 639 | 669 | towns_gfxvram[voffset+1] = (col & 0xff00) >> 8; |
| 640 | 670 | towns_gfxvram[voffset] = col & 0x00ff; |
| 641 | 671 | } |
| 642 | | voffset+=2; |
| 643 | | pixel = (towns_sprram[poffset] & 0xf0) >> 4; |
| 672 | if(xflip) |
| 673 | { |
| 674 | voffset+=2; |
| 675 | pixel = (towns_sprram[poffset] & 0xf0) >> 4; |
| 676 | } |
| 677 | else |
| 678 | { |
| 679 | voffset-=2; |
| 680 | pixel = towns_sprram[poffset] & 0x0f; |
| 681 | } |
| 644 | 682 | col = towns_sprram[coffset+(pixel*2)] | (towns_sprram[coffset+(pixel*2)+1] << 8); |
| 645 | 683 | voffset &= 0x3ffff; |
| 646 | 684 | voffset += (towns_sprite_reg[6] & 0x10) ? 0x60000 : 0x40000; |
| r6727 | r6728 | |
| 654 | 692 | } |
| 655 | 693 | } |
| 656 | 694 | |
| 657 | | void render_sprite_16(bitmap_t* bitmap, UINT32 poffset, UINT16 x, UINT16 y, const rectangle* rect) |
| 695 | void render_sprite_16(bitmap_t* bitmap, UINT32 poffset, UINT16 x, UINT16 y, UINT16 xflip, UINT16 yflip, const rectangle* rect) |
| 658 | 696 | { |
| 659 | 697 | UINT16 xpos,ypos; |
| 660 | | UINT16 col;//,pixel; |
| 698 | UINT16 col; |
| 661 | 699 | UINT32 voffset; |
| 700 | int xstart,ystart,xend,yend,xdir,ydir; |
| 662 | 701 | |
| 663 | | for(ypos=y;ypos<y+16;ypos++) |
| 702 | if(xflip) |
| 664 | 703 | { |
| 665 | | for(xpos=x;xpos<x+16;xpos++) |
| 704 | xstart = x+16; |
| 705 | xend = x; |
| 706 | xdir = -1; |
| 707 | } |
| 708 | else |
| 709 | { |
| 710 | xstart = x; |
| 711 | xend = x+16; |
| 712 | xdir = 1; |
| 713 | } |
| 714 | if(yflip) |
| 715 | { |
| 716 | ystart = y+16; |
| 717 | yend = y; |
| 718 | ydir = -1; |
| 719 | } |
| 720 | else |
| 721 | { |
| 722 | ystart = y; |
| 723 | yend = y+16; |
| 724 | ydir = 1; |
| 725 | } |
| 726 | |
| 727 | for(ypos=ystart;ypos!=yend;ypos+=ydir) |
| 728 | { |
| 729 | for(xpos=xstart;xpos!=xend;xpos+=xdir) |
| 666 | 730 | { |
| 667 | 731 | voffset = (towns_sprite_reg[6] & 0x10) ? 0x60000 : 0x40000; |
| 668 | 732 | col = towns_sprram[poffset] | (towns_sprram[poffset+1] << 8); |
| r6727 | r6728 | |
| 717 | 781 | n,x,y,attr,colour,poffset,coffset); |
| 718 | 782 | #endif |
| 719 | 783 | if(!(colour & 0x2000)) |
| 720 | | render_sprite_4(bitmap,(poffset+pshift)&0x1ffff,coffset,x,y,rect); |
| 784 | render_sprite_4(bitmap,(poffset+pshift)&0x1ffff,coffset,x,y,attr&0x2000,attr&0x1000,rect); |
| 721 | 785 | } |
| 722 | 786 | else |
| 723 | 787 | { |
| r6727 | r6728 | |
| 727 | 791 | printf("Sprite16 #%i, X %i Y %i Attr %04x Col %04x Poff %05x Coff %05x\n", |
| 728 | 792 | n,x,y,attr,colour,poffset,coffset); |
| 729 | 793 | #endif |
| 730 | | render_sprite_16(bitmap,(poffset+pshift)&0x1ffff,x,y,rect); |
| 794 | render_sprite_16(bitmap,(poffset+pshift)&0x1ffff,x,y,attr&0x2000,attr&0x1000,rect); |
| 731 | 795 | } |
| 732 | 796 | } |
| 733 | 797 | } |