src/mess/video/fmtowns.c
| r7602 | r7603 | |
| 125 | 125 | extern UINT32 towns_mainmem_enable; |
| 126 | 126 | extern UINT32 towns_ankcg_enable; |
| 127 | 127 | |
| 128 | | static UINT32 pshift; // for debugging |
| 128 | //static UINT32 pshift; // for debugging |
| 129 | 129 | |
| 130 | 130 | void towns_crtc_refresh_mode(running_machine* machine) |
| 131 | 131 | { |
| r7602 | r7603 | |
| 682 | 682 | */ |
| 683 | 683 | void render_sprite_4(UINT32 poffset, UINT32 coffset, UINT16 x, UINT16 y, UINT16 xflip, UINT16 yflip, const rectangle* rect) |
| 684 | 684 | { |
| 685 | | INT16 xpos,ypos; |
| 685 | UINT16 xpos,ypos; |
| 686 | 686 | UINT16 col,pixel; |
| 687 | 687 | UINT32 voffset; |
| 688 | | int xstart,xend,xdir,ystart,yend,ydir; |
| 688 | UINT16 xstart,xend,ystart,yend; |
| 689 | int xdir,ydir; |
| 690 | int width = (towns_crtc_reg[12] - towns_crtc_reg[11]) / (((towns_crtc_reg[27] & 0x0f00) >> 8)+1); |
| 691 | int height = (towns_crtc_reg[16] - towns_crtc_reg[15]) / (((towns_crtc_reg[27] & 0xf000) >> 12)+1); |
| 689 | 692 | |
| 690 | 693 | if(xflip) |
| 691 | 694 | { |
| r7602 | r7603 | |
| 711 | 714 | yend = y+16; |
| 712 | 715 | ydir = 1; |
| 713 | 716 | } |
| 717 | xstart &= 0x1ff; |
| 718 | xend &= 0x1ff; |
| 719 | ystart &= 0x1ff; |
| 720 | yend &= 0x1ff; |
| 721 | poffset &= 0x1ffff; |
| 714 | 722 | |
| 715 | | for(ypos=ystart;ypos!=yend;ypos+=ydir) |
| 723 | for(ypos=ystart;ypos!=yend;ypos+=ydir,ypos&=0x1ff) |
| 716 | 724 | { |
| 717 | | for(xpos=xstart;xpos!=xend;xpos+=xdir) |
| 725 | for(xpos=xstart;xpos!=xend;xpos+=xdir,xpos&=0x1ff) |
| 718 | 726 | { |
| 719 | 727 | voffset = 0; |
| 720 | 728 | pixel = (towns_txtvram[poffset] & 0xf0) >> 4; |
| r7602 | r7603 | |
| 723 | 731 | voffset += (xpos & 0x1ff) * 2; |
| 724 | 732 | voffset &= 0x3ffff; |
| 725 | 733 | voffset += (towns_sprite_reg[6] & 0x10) ? 0x60000 : 0x40000; |
| 726 | | if(xpos <= rect->max_x && ypos <= rect->max_y && pixel != 0) |
| 734 | if(xpos < width && ypos < height && pixel != 0) |
| 727 | 735 | { |
| 728 | 736 | towns_gfxvram[voffset+1] = (col & 0xff00) >> 8; |
| 729 | 737 | towns_gfxvram[voffset] = col & 0x00ff; |
| r7602 | r7603 | |
| 736 | 744 | col = towns_txtvram[coffset+(pixel*2)] | (towns_txtvram[coffset+(pixel*2)+1] << 8); |
| 737 | 745 | voffset &= 0x3ffff; |
| 738 | 746 | voffset += (towns_sprite_reg[6] & 0x10) ? 0x60000 : 0x40000; |
| 739 | | if(xpos <= rect->max_x && ypos <= rect->max_y && pixel != 0) |
| 747 | if(xpos < width && ypos < height && pixel != 0) |
| 740 | 748 | { |
| 741 | 749 | towns_gfxvram[voffset+1] = (col & 0xff00) >> 8; |
| 742 | 750 | towns_gfxvram[voffset] = col & 0x00ff; |
| 743 | 751 | } |
| 744 | 752 | poffset++; |
| 753 | poffset &= 0x1ffff; |
| 745 | 754 | } |
| 746 | 755 | } |
| 747 | 756 | } |
| 748 | 757 | |
| 749 | 758 | void render_sprite_16(UINT32 poffset, UINT16 x, UINT16 y, UINT16 xflip, UINT16 yflip, const rectangle* rect) |
| 750 | 759 | { |
| 751 | | INT16 xpos,ypos; |
| 760 | UINT16 xpos,ypos; |
| 752 | 761 | UINT16 col; |
| 753 | 762 | UINT32 voffset; |
| 754 | | int xstart,ystart,xend,yend,xdir,ydir; |
| 763 | UINT16 xstart,ystart,xend,yend; |
| 764 | int xdir,ydir; |
| 765 | int width = (towns_crtc_reg[12] - towns_crtc_reg[11]) / (((towns_crtc_reg[27] & 0x0f00) >> 8)+1); |
| 766 | int height = (towns_crtc_reg[16] - towns_crtc_reg[15]) / (((towns_crtc_reg[27] & 0xf000) >> 12)+1); |
| 755 | 767 | |
| 756 | 768 | if(xflip) |
| 757 | 769 | { |
| r7602 | r7603 | |
| 777 | 789 | yend = y+16; |
| 778 | 790 | ydir = 1; |
| 779 | 791 | } |
| 792 | xstart &= 0x1ff; |
| 793 | xend &= 0x1ff; |
| 794 | ystart &= 0x1ff; |
| 795 | yend &= 0x1ff; |
| 796 | poffset &= 0x1ffff; |
| 780 | 797 | |
| 781 | | for(ypos=ystart;ypos!=yend;ypos+=ydir) |
| 798 | for(ypos=ystart;ypos!=yend;ypos+=ydir,ypos&=0x1ff) |
| 782 | 799 | { |
| 783 | | for(xpos=xstart;xpos!=xend;xpos+=xdir) |
| 800 | for(xpos=xstart;xpos!=xend;xpos+=xdir,xpos&=0x1ff) |
| 784 | 801 | { |
| 785 | 802 | voffset = (towns_sprite_reg[6] & 0x10) ? 0x60000 : 0x40000; |
| 786 | 803 | col = towns_txtvram[poffset] | (towns_txtvram[poffset+1] << 8); |
| 787 | 804 | voffset += (towns_crtc_reg[24] * 4) * ypos; // scanline size in bytes * y pos |
| 788 | 805 | voffset += (xpos & 0x1ff) * 2; |
| 789 | 806 | voffset &= 0x7ffff; |
| 790 | | if(xpos <= rect->max_x && ypos <= rect->max_y && col < 0x8000) |
| 807 | if(xpos < width && ypos < height && col < 0x8000) |
| 791 | 808 | { |
| 792 | 809 | towns_gfxvram[voffset+1] = (col & 0xff00) >> 8; |
| 793 | 810 | towns_gfxvram[voffset] = col & 0x00ff; |
| 794 | 811 | } |
| 795 | 812 | poffset+=2; |
| 813 | poffset &= 0x1ffff; |
| 796 | 814 | } |
| 797 | 815 | } |
| 798 | 816 | } |
| r7602 | r7603 | |
| 831 | 849 | poffset = (attr & 0x3ff) << 7; |
| 832 | 850 | coffset = (colour & 0xfff) << 5; |
| 833 | 851 | #ifdef SPR_DEBUG |
| 834 | | printf("Sprite4 #%i, X %i Y %i Attr %04x Col %04x Poff %05x Coff %05x\n", |
| 852 | printf("Sprite4 #%i, X %i Y %i Attr %04x Col %04x Poff %08x Coff %08x\n", |
| 835 | 853 | n,x,y,attr,colour,poffset,coffset); |
| 836 | 854 | #endif |
| 837 | 855 | if(!(colour & 0x2000)) |
| 838 | | render_sprite_4((poffset+pshift)&0x1ffff,coffset,x,y,attr&0x2000,attr&0x1000,rect); |
| 856 | render_sprite_4((poffset)&0x1ffff,coffset,x,y,attr&0x2000,attr&0x1000,rect); |
| 839 | 857 | } |
| 840 | 858 | else |
| 841 | 859 | { |
| 842 | 860 | poffset = (attr & 0x3ff) << 7; |
| 843 | 861 | coffset = (colour & 0xfff) << 5; |
| 844 | 862 | #ifdef SPR_DEBUG |
| 845 | | printf("Sprite16 #%i, X %i Y %i Attr %04x Col %04x Poff %05x Coff %05x\n", |
| 863 | printf("Sprite16 #%i, X %i Y %i Attr %04x Col %04x Poff %08x Coff %08x\n", |
| 846 | 864 | n,x,y,attr,colour,poffset,coffset); |
| 847 | 865 | #endif |
| 848 | | render_sprite_16((poffset+pshift)&0x1ffff,x,y,attr&0x2000,attr&0x1000,rect); |
| 866 | if(!(colour & 0x2000)) |
| 867 | render_sprite_16((poffset)&0x1ffff,x,y,attr&0x2000,attr&0x1000,rect); |
| 849 | 868 | } |
| 850 | 869 | } |
| 851 | 870 | } |
| r7602 | r7603 | |
| 1340 | 1359 | towns_crtc_draw_layer(screen->machine,bitmap,&towns_crtc_layerscr[1],1); |
| 1341 | 1360 | } |
| 1342 | 1361 | |
| 1343 | | #ifdef SPR_DEBUG |
| 1362 | /*#ifdef SPR_DEBUG |
| 1344 | 1363 | if(input_code_pressed(screen->machine,KEYCODE_O)) |
| 1345 | 1364 | pshift+=0x80; |
| 1346 | 1365 | if(input_code_pressed(screen->machine,KEYCODE_I)) |
| 1347 | 1366 | pshift-=0x80; |
| 1348 | 1367 | popmessage("Pixel shift = %08x",pshift); |
| 1349 | | #endif |
| 1368 | #endif*/ |
| 1350 | 1369 | |
| 1351 | 1370 | #ifdef CRTC_REG_DISP |
| 1352 | 1371 | popmessage("CRTC: %i %i %i %i %i %i %i %i %i\n%i %i %i %i | %i %i %i %i\n%i %i %i %i | %i %i %i %i\nZOOM: %04x\nVideo: %02x %02x\nText=%i Spr=%02x", |