trunk/src/emu/bus/isa/trident.c
| r32202 | r32203 | |
| 14 | 14 | |
| 15 | 15 | #define CRTC_PORT_ADDR ((vga.miscellaneous_output&1)?0x3d0:0x3b0) |
| 16 | 16 | |
| 17 | #define READPIXEL8(x,y) (vga.memory[(y*offset() + x) % vga.svga_intf.vram_size]) |
| 18 | #define WRITEPIXEL8(x,y,c) if(x<tri.accel_dest_y_clip && y<tri.accel_dest_y_clip) \ |
| 19 | (vga.memory[(y*offset() + x) % vga.svga_intf.vram_size] = c) |
| 20 | |
| 21 | #define LOG (1) |
| 22 | |
| 17 | 23 | trident_vga_device::trident_vga_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 18 | 24 | : svga_device(mconfig, TRIDENT_VGA, "Trident TGUI9680", tag, owner, clock, "trident_vga", __FILE__) |
| 19 | 25 | { |
| r32202 | r32203 | |
| 41 | 47 | save_pointer(vga.crtc.data,"CRTC Registers",0x100); |
| 42 | 48 | save_pointer(vga.sequencer.data,"Sequencer Registers",0x100); |
| 43 | 49 | save_pointer(vga.attribute.data,"Attribute Registers", 0x15); |
| 50 | save_pointer(tri.accel_pattern,"Pattern Data", 0x80); |
| 44 | 51 | |
| 45 | 52 | m_vblank_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(vga_device::vblank_timer_cb),this)); |
| 46 | 53 | vga.svga_intf.seq_regcount = 0x0f; |
| r32202 | r32203 | |
| 164 | 171 | break; |
| 165 | 172 | } |
| 166 | 173 | } |
| 167 | | logerror("Trident SR%02X: read %02x\n",index,res); |
| 174 | if(LOG) logerror("Trident SR%02X: read %02x\n",index,res); |
| 168 | 175 | return res; |
| 169 | 176 | } |
| 170 | 177 | |
| r32202 | r32203 | |
| 178 | 185 | } |
| 179 | 186 | else |
| 180 | 187 | { |
| 181 | | logerror("Trident SR%02X: %s mode write %02x\n",index,tri.new_mode ? "new" : "old",data); |
| 188 | if(LOG) logerror("Trident SR%02X: %s mode write %02x\n",index,tri.new_mode ? "new" : "old",data); |
| 182 | 189 | switch(index) |
| 183 | 190 | { |
| 184 | 191 | case 0x0b: |
| r32202 | r32203 | |
| 265 | 272 | break; |
| 266 | 273 | } |
| 267 | 274 | } |
| 268 | | logerror("Trident CR%02X: read %02x\n",index,res); |
| 275 | if(LOG) logerror("Trident CR%02X: read %02x\n",index,res); |
| 269 | 276 | return res; |
| 270 | 277 | } |
| 271 | 278 | void trident_vga_device::trident_crtc_reg_write(UINT8 index, UINT8 data) |
| r32202 | r32203 | |
| 277 | 284 | } |
| 278 | 285 | else |
| 279 | 286 | { |
| 280 | | logerror("Trident CR%02X: write %02x\n",index,data); |
| 287 | if(LOG) logerror("Trident CR%02X: write %02x\n",index,data); |
| 281 | 288 | switch(index) |
| 282 | 289 | { |
| 283 | 290 | case 0x1e: // Module Testing Register |
| r32202 | r32203 | |
| 345 | 352 | break; |
| 346 | 353 | } |
| 347 | 354 | } |
| 348 | | logerror("Trident GC%02X: read %02x\n",index,res); |
| 355 | if(LOG) logerror("Trident GC%02X: read %02x\n",index,res); |
| 349 | 356 | return res; |
| 350 | 357 | } |
| 351 | 358 | |
| r32202 | r32203 | |
| 355 | 362 | gc_reg_write(index,data); |
| 356 | 363 | else |
| 357 | 364 | { |
| 358 | | logerror("Trident GC%02X: write %02x\n",index,data); |
| 365 | if(LOG) logerror("Trident GC%02X: write %02x\n",index,data); |
| 359 | 366 | switch(index) |
| 360 | 367 | { |
| 361 | 368 | case 0x0e: // New Source Address Register (bit 1 is inverted here, also) |
| r32202 | r32203 | |
| 524 | 531 | { |
| 525 | 532 | case 2: |
| 526 | 533 | res = port_03c0_r(space,5,mem_mask); |
| 527 | | logerror("Trident: 83c6 read %02x\n",res); |
| 534 | if(LOG) logerror("Trident: 83c6 read %02x\n",res); |
| 528 | 535 | break; |
| 529 | 536 | case 4: |
| 530 | 537 | res = vga.sequencer.index; |
| 531 | | logerror("Trident: 83c8 seq read %02x\n",res); |
| 538 | if(LOG) logerror("Trident: 83c8 seq read %02x\n",res); |
| 532 | 539 | break; |
| 533 | 540 | } |
| 534 | 541 | return res; |
| r32202 | r32203 | |
| 539 | 546 | switch(offset) |
| 540 | 547 | { |
| 541 | 548 | case 2: |
| 542 | | logerror("Trident: 83c6 seq write %02x\n",data); |
| 549 | if(LOG) logerror("Trident: 83c6 seq write %02x\n",data); |
| 543 | 550 | port_03c0_w(space,5,data,mem_mask); |
| 544 | 551 | break; |
| 545 | 552 | case 4: |
| 546 | | logerror("Trident: 83c8 seq index write %02x\n",data); |
| 553 | if(LOG) logerror("Trident: 83c8 seq index write %02x\n",data); |
| 547 | 554 | vga.sequencer.index = data; |
| 548 | 555 | break; |
| 549 | 556 | } |
| r32202 | r32203 | |
| 696 | 703 | { |
| 697 | 704 | case 0x02: // Operation Mode |
| 698 | 705 | tri.accel_opermode = (tri.accel_opermode & 0xff00) | data; |
| 699 | | logerror("Trident: Operation Mode set to %04x\n",tri.accel_opermode); |
| 706 | if(LOG) logerror("Trident: Operation Mode set to %04x\n",tri.accel_opermode); |
| 700 | 707 | break; |
| 701 | 708 | case 0x03: |
| 702 | 709 | tri.accel_opermode = (tri.accel_opermode & 0x00ff) | (data << 8); |
| 703 | | logerror("Trident: Operation Mode set to %04x\n",tri.accel_opermode); |
| 710 | if(LOG) logerror("Trident: Operation Mode set to %04x\n",tri.accel_opermode); |
| 704 | 711 | break; |
| 705 | 712 | case 0x04: // Command register |
| 706 | 713 | tri.accel_command = data; |
| 707 | | switch(data) |
| 708 | | { |
| 709 | | case 0x00: |
| 710 | | logerror("Trident: Command: NOP\n"); |
| 711 | | break; |
| 712 | | case 0x01: |
| 713 | | logerror("Trident: Command: BitBLT ROP3\n"); |
| 714 | | break; |
| 715 | | case 0x02: |
| 716 | | logerror("Trident: Command: BitBLT ROP4\n"); |
| 717 | | break; |
| 718 | | case 0x03: |
| 719 | | logerror("Trident: Command: Scanline\n"); |
| 720 | | break; |
| 721 | | case 0x04: |
| 722 | | logerror("Trident: Command: Bresenham Line\n"); |
| 723 | | break; |
| 724 | | case 0x05: |
| 725 | | logerror("Trident: Command: Short Vector\n"); |
| 726 | | break; |
| 727 | | case 0x06: |
| 728 | | logerror("Trident: Command: Fast Line\n"); |
| 729 | | break; |
| 730 | | case 0x07: |
| 731 | | logerror("Trident: Command: Trapezoid Fill\n"); |
| 732 | | break; |
| 733 | | case 0x08: |
| 734 | | logerror("Trident: Command: Ellipse\n"); |
| 735 | | break; |
| 736 | | case 0x09: |
| 737 | | logerror("Trident: Command: Ellipse Fill\n"); |
| 738 | | break; |
| 739 | | default: |
| 740 | | logerror("Trident: Unknown acceleration command %02x\n",data); |
| 741 | | } |
| 714 | accel_command(); |
| 742 | 715 | break; |
| 743 | 716 | case 0x07: // Foreground Mix? |
| 744 | 717 | tri.accel_fmix = data; |
| 745 | | logerror("Trident: FMIX set to %02x\n",data); |
| 718 | if(LOG) logerror("Trident: FMIX set to %02x\n",data); |
| 746 | 719 | break; |
| 747 | 720 | case 0x08: // Draw flags |
| 748 | 721 | tri.accel_drawflags = (tri.accel_drawflags & 0xffffff00) | data; |
| 749 | | logerror("Trident: Draw flags set to %08x\n",tri.accel_drawflags); |
| 722 | if(LOG) logerror("Trident: Draw flags set to %08x\n",tri.accel_drawflags); |
| 750 | 723 | break; |
| 751 | 724 | case 0x09: |
| 752 | 725 | tri.accel_drawflags = (tri.accel_drawflags & 0xffff00ff) | (data << 8); |
| 753 | | logerror("Trident: Draw flags set to %08x\n",tri.accel_drawflags); |
| 726 | if(LOG) logerror("Trident: Draw flags set to %08x\n",tri.accel_drawflags); |
| 754 | 727 | break; |
| 755 | 728 | case 0x0a: |
| 756 | 729 | tri.accel_drawflags = (tri.accel_drawflags & 0xff00ffff) | (data << 16); |
| 757 | | logerror("Trident: Draw flags set to %08x\n",tri.accel_drawflags); |
| 730 | if(LOG) logerror("Trident: Draw flags set to %08x\n",tri.accel_drawflags); |
| 758 | 731 | break; |
| 759 | 732 | case 0x0b: |
| 760 | 733 | tri.accel_drawflags = (tri.accel_drawflags & 0x00ffffff) | (data << 24); |
| 761 | | logerror("Trident: Draw flags set to %08x\n",tri.accel_drawflags); |
| 734 | if(LOG) logerror("Trident: Draw flags set to %08x\n",tri.accel_drawflags); |
| 762 | 735 | break; |
| 763 | 736 | case 0x0c: // Foreground Colour |
| 764 | 737 | tri.accel_fgcolour = (tri.accel_fgcolour & 0xffffff00) | data; |
| 765 | | logerror("Trident: Foreground Colour set to %08x\n",tri.accel_fgcolour); |
| 738 | if(LOG) logerror("Trident: Foreground Colour set to %08x\n",tri.accel_fgcolour); |
| 766 | 739 | break; |
| 767 | 740 | case 0x0d: |
| 768 | 741 | tri.accel_fgcolour = (tri.accel_fgcolour & 0xffff00ff) | (data << 8); |
| 769 | | logerror("Trident: Foreground Colour set to %08x\n",tri.accel_fgcolour); |
| 742 | if(LOG) logerror("Trident: Foreground Colour set to %08x\n",tri.accel_fgcolour); |
| 770 | 743 | break; |
| 771 | 744 | case 0x0e: |
| 772 | 745 | tri.accel_fgcolour = (tri.accel_fgcolour & 0xff00ffff) | (data << 16); |
| 773 | | logerror("Trident: Foreground Colour set to %08x\n",tri.accel_fgcolour); |
| 746 | if(LOG) logerror("Trident: Foreground Colour set to %08x\n",tri.accel_fgcolour); |
| 774 | 747 | break; |
| 775 | 748 | case 0x0f: |
| 776 | 749 | tri.accel_fgcolour = (tri.accel_fgcolour & 0x00ffffff) | (data << 24); |
| 777 | | logerror("Trident: Foreground Colour set to %08x\n",tri.accel_fgcolour); |
| 750 | if(LOG) logerror("Trident: Foreground Colour set to %08x\n",tri.accel_fgcolour); |
| 778 | 751 | break; |
| 779 | 752 | case 0x10: // Background Colour |
| 780 | 753 | tri.accel_bgcolour = (tri.accel_bgcolour & 0xffffff00) | data; |
| 781 | | logerror("Trident: Background Colour set to %08x\n",tri.accel_bgcolour); |
| 754 | if(LOG) logerror("Trident: Background Colour set to %08x\n",tri.accel_bgcolour); |
| 782 | 755 | break; |
| 783 | 756 | case 0x11: |
| 784 | 757 | tri.accel_bgcolour = (tri.accel_bgcolour & 0xffff00ff) | (data << 8); |
| 785 | | logerror("Trident: Background Colour set to %08x\n",tri.accel_bgcolour); |
| 758 | if(LOG) logerror("Trident: Background Colour set to %08x\n",tri.accel_bgcolour); |
| 786 | 759 | break; |
| 787 | 760 | case 0x12: |
| 788 | 761 | tri.accel_bgcolour = (tri.accel_bgcolour & 0xff00ffff) | (data << 16); |
| 789 | | logerror("Trident: Background Colour set to %08x\n",tri.accel_bgcolour); |
| 762 | if(LOG) logerror("Trident: Background Colour set to %08x\n",tri.accel_bgcolour); |
| 790 | 763 | break; |
| 791 | 764 | case 0x13: |
| 792 | 765 | tri.accel_bgcolour = (tri.accel_bgcolour & 0x00ffffff) | (data << 24); |
| 793 | | logerror("Trident: Background Colour set to %08x\n",tri.accel_bgcolour); |
| 766 | if(LOG) logerror("Trident: Background Colour set to %08x\n",tri.accel_bgcolour); |
| 794 | 767 | break; |
| 795 | 768 | case 0x14: // Pattern Location |
| 796 | 769 | tri.accel_pattern_loc = (tri.accel_pattern_loc & 0xff00) | data; |
| 797 | | logerror("Trident: Pattern Location set to %04x\n",tri.accel_pattern_loc); |
| 770 | if(LOG) logerror("Trident: Pattern Location set to %04x\n",tri.accel_pattern_loc); |
| 771 | debugger_break(machine()); |
| 798 | 772 | break; |
| 799 | 773 | case 0x15: |
| 800 | 774 | tri.accel_pattern_loc = (tri.accel_pattern_loc & 0x00ff) | (data << 8); |
| 801 | | logerror("Trident: Pattern Location set to %04x\n",tri.accel_pattern_loc); |
| 775 | if(LOG) logerror("Trident: Pattern Location set to %04x\n",tri.accel_pattern_loc); |
| 776 | debugger_break(machine()); |
| 802 | 777 | break; |
| 803 | 778 | case 0x18: // Destination X |
| 804 | 779 | tri.accel_dest_x = (tri.accel_dest_x & 0xff00) | data; |
| 805 | | logerror("Trident: Destination X set to %04x\n",tri.accel_dest_x); |
| 780 | if(LOG) logerror("Trident: Destination X set to %04x\n",tri.accel_dest_x); |
| 806 | 781 | break; |
| 807 | 782 | case 0x19: |
| 808 | 783 | tri.accel_dest_x = (tri.accel_dest_x & 0x00ff) | (data << 8); |
| 809 | | logerror("Trident: Destination X set to %04x\n",tri.accel_dest_x); |
| 784 | if(LOG) logerror("Trident: Destination X set to %04x\n",tri.accel_dest_x); |
| 810 | 785 | break; |
| 811 | 786 | case 0x1a: // Destination Y |
| 812 | 787 | tri.accel_dest_y = (tri.accel_dest_y & 0xff00) | data; |
| 813 | | logerror("Trident: Destination Y set to %04x\n",tri.accel_dest_y); |
| 788 | if(LOG) logerror("Trident: Destination Y set to %04x\n",tri.accel_dest_y); |
| 814 | 789 | break; |
| 815 | 790 | case 0x1b: |
| 816 | 791 | tri.accel_dest_y = (tri.accel_dest_y & 0x00ff) | (data << 8); |
| 817 | | logerror("Trident: Destination Y set to %04x\n",tri.accel_dest_y); |
| 792 | if(LOG) logerror("Trident: Destination Y set to %04x\n",tri.accel_dest_y); |
| 818 | 793 | break; |
| 819 | 794 | case 0x1c: // Source X |
| 820 | 795 | tri.accel_source_x = (tri.accel_source_x & 0xff00) | data; |
| 821 | | logerror("Trident: Source X set to %04x\n",tri.accel_source_x); |
| 796 | if(LOG) logerror("Trident: Source X set to %04x\n",tri.accel_source_x); |
| 822 | 797 | break; |
| 823 | 798 | case 0x1d: |
| 824 | 799 | tri.accel_source_x = (tri.accel_source_x & 0x00ff) | (data << 8); |
| 825 | | logerror("Trident: Source X set to %04x\n",tri.accel_source_x); |
| 800 | if(LOG) logerror("Trident: Source X set to %04x\n",tri.accel_source_x); |
| 826 | 801 | break; |
| 827 | 802 | case 0x1e: // Source Y |
| 828 | 803 | tri.accel_source_y = (tri.accel_source_y & 0xff00) | data; |
| 829 | | logerror("Trident: Source Y set to %04x\n",tri.accel_source_y); |
| 804 | if(LOG) logerror("Trident: Source Y set to %04x\n",tri.accel_source_y); |
| 830 | 805 | break; |
| 831 | 806 | case 0x1f: |
| 832 | 807 | tri.accel_source_y = (tri.accel_source_y & 0x00ff) | (data << 8); |
| 833 | | logerror("Trident: Source Y set to %04x\n",tri.accel_source_y); |
| 808 | if(LOG) logerror("Trident: Source Y set to %04x\n",tri.accel_source_y); |
| 834 | 809 | break; |
| 835 | 810 | case 0x20: // Dimension(?) X |
| 836 | 811 | tri.accel_dim_x = (tri.accel_dim_x & 0xff00) | data; |
| 837 | | logerror("Trident: Dimension X set to %04x\n",tri.accel_dim_x); |
| 812 | if(LOG) logerror("Trident: Dimension X set to %04x\n",tri.accel_dim_x); |
| 838 | 813 | break; |
| 839 | 814 | case 0x21: |
| 840 | 815 | tri.accel_dim_x = (tri.accel_dim_x & 0x00ff) | (data << 8); |
| 841 | | logerror("Trident: Dimension X set to %04x\n",tri.accel_dim_x); |
| 816 | if(LOG) logerror("Trident: Dimension X set to %04x\n",tri.accel_dim_x); |
| 842 | 817 | break; |
| 843 | 818 | case 0x22: // Dimension(?) Y |
| 844 | 819 | tri.accel_dim_y = (tri.accel_dim_y & 0xff00) | data; |
| 845 | | logerror("Trident: Dimension y set to %04x\n",tri.accel_dim_y); |
| 820 | if(LOG) logerror("Trident: Dimension y set to %04x\n",tri.accel_dim_y); |
| 846 | 821 | break; |
| 847 | 822 | case 0x23: |
| 848 | 823 | tri.accel_dim_y = (tri.accel_dim_y & 0x00ff) | (data << 8); |
| 849 | | logerror("Trident: Dimension y set to %04x\n",tri.accel_dim_y); |
| 824 | if(LOG) logerror("Trident: Dimension y set to %04x\n",tri.accel_dim_y); |
| 850 | 825 | break; |
| 851 | 826 | case 0x24: // Style |
| 852 | 827 | tri.accel_style = (tri.accel_style & 0xffffff00) | data; |
| 853 | | logerror("Trident: Style set to %08x\n",tri.accel_style); |
| 828 | if(LOG) logerror("Trident: Style set to %08x\n",tri.accel_style); |
| 854 | 829 | break; |
| 855 | 830 | case 0x25: |
| 856 | 831 | tri.accel_style = (tri.accel_style & 0xffff00ff) | (data << 8); |
| 857 | | logerror("Trident: Style set to %08x\n",tri.accel_style); |
| 832 | if(LOG) logerror("Trident: Style set to %08x\n",tri.accel_style); |
| 858 | 833 | break; |
| 859 | 834 | case 0x26: |
| 860 | 835 | tri.accel_style = (tri.accel_style & 0xff00ffff) | (data << 16); |
| 861 | | logerror("Trident: Style set to %08x\n",tri.accel_style); |
| 836 | if(LOG) logerror("Trident: Style set to %08x\n",tri.accel_style); |
| 862 | 837 | break; |
| 863 | 838 | case 0x27: |
| 864 | 839 | tri.accel_style = (tri.accel_style & 0x00ffffff) | (data << 24); |
| 865 | | logerror("Trident: Style set to %08x\n",tri.accel_style); |
| 840 | if(LOG) logerror("Trident: Style set to %08x\n",tri.accel_style); |
| 866 | 841 | break; |
| 867 | 842 | case 0x28: // Source Clip X |
| 868 | 843 | tri.accel_source_x_clip = (tri.accel_source_x_clip & 0xff00) | data; |
| 869 | | logerror("Trident: Source X Clip set to %04x\n",tri.accel_source_x_clip); |
| 844 | if(LOG) logerror("Trident: Source X Clip set to %04x\n",tri.accel_source_x_clip); |
| 870 | 845 | break; |
| 871 | 846 | case 0x29: |
| 872 | 847 | tri.accel_source_x_clip = (tri.accel_source_x_clip & 0x00ff) | (data << 8); |
| 873 | | logerror("Trident: Source X Clip set to %04x\n",tri.accel_source_x_clip); |
| 848 | if(LOG) logerror("Trident: Source X Clip set to %04x\n",tri.accel_source_x_clip); |
| 874 | 849 | break; |
| 875 | 850 | case 0x2a: // Source Clip Y |
| 876 | 851 | tri.accel_source_y_clip = (tri.accel_source_y_clip & 0xff00) | data; |
| 877 | | logerror("Trident: Source Y Clip set to %04x\n",tri.accel_source_y_clip); |
| 852 | if(LOG) logerror("Trident: Source Y Clip set to %04x\n",tri.accel_source_y_clip); |
| 878 | 853 | break; |
| 879 | 854 | case 0x2b: |
| 880 | 855 | tri.accel_source_y_clip = (tri.accel_source_y_clip & 0x00ff) | (data << 8); |
| 881 | | logerror("Trident: Source Y Clip set to %04x\n",tri.accel_source_y_clip); |
| 856 | if(LOG) logerror("Trident: Source Y Clip set to %04x\n",tri.accel_source_y_clip); |
| 882 | 857 | break; |
| 883 | 858 | case 0x2c: // Destination Clip X |
| 884 | 859 | tri.accel_dest_x_clip = (tri.accel_dest_x_clip & 0xff00) | data; |
| 885 | | logerror("Trident: Destination X Clip set to %04x\n",tri.accel_dest_x_clip); |
| 860 | if(LOG) logerror("Trident: Destination X Clip set to %04x\n",tri.accel_dest_x_clip); |
| 886 | 861 | break; |
| 887 | 862 | case 0x2d: |
| 888 | 863 | tri.accel_dest_x_clip = (tri.accel_dest_x_clip & 0x00ff) | (data << 8); |
| 889 | | logerror("Trident: Destination X Clip set to %04x\n",tri.accel_dest_x_clip); |
| 864 | if(LOG) logerror("Trident: Destination X Clip set to %04x\n",tri.accel_dest_x_clip); |
| 890 | 865 | break; |
| 891 | 866 | case 0x2e: // Destination Clip Y |
| 892 | 867 | tri.accel_dest_y_clip = (tri.accel_dest_y_clip & 0xff00) | data; |
| 893 | | logerror("Trident: Destination Y Clip set to %04x\n",tri.accel_dest_y_clip); |
| 868 | if(LOG) logerror("Trident: Destination Y Clip set to %04x\n",tri.accel_dest_y_clip); |
| 894 | 869 | break; |
| 895 | 870 | case 0x2f: |
| 896 | 871 | tri.accel_dest_y_clip = (tri.accel_dest_y_clip & 0x00ff) | (data << 8); |
| 897 | | logerror("Trident: Destination Y Clip set to %04x\n",tri.accel_dest_y_clip); |
| 872 | if(LOG) logerror("Trident: Destination Y Clip set to %04x\n",tri.accel_dest_y_clip); |
| 898 | 873 | break; |
| 899 | 874 | case 0x48: // CKEY (Chromakey?) |
| 900 | 875 | tri.accel_ckey = (tri.accel_ckey & 0xffffff00) | data; |
| 901 | | logerror("Trident: CKey set to %08x\n",tri.accel_ckey); |
| 876 | if(LOG) logerror("Trident: CKey set to %08x\n",tri.accel_ckey); |
| 902 | 877 | break; |
| 903 | 878 | case 0x49: |
| 904 | 879 | tri.accel_ckey = (tri.accel_ckey & 0xffff00ff) | (data << 8); |
| 905 | | logerror("Trident: CKey set to %08x\n",tri.accel_ckey); |
| 880 | if(LOG) logerror("Trident: CKey set to %08x\n",tri.accel_ckey); |
| 906 | 881 | break; |
| 907 | 882 | case 0x4a: |
| 908 | 883 | tri.accel_ckey = (tri.accel_ckey & 0xff00ffff) | (data << 16); |
| 909 | | logerror("Trident: CKey set to %08x\n",tri.accel_ckey); |
| 884 | if(LOG) logerror("Trident: CKey set to %08x\n",tri.accel_ckey); |
| 910 | 885 | break; |
| 911 | 886 | case 0x4b: |
| 912 | 887 | tri.accel_ckey = (tri.accel_ckey & 0x00ffffff) | (data << 24); |
| 913 | | logerror("Trident: CKey set to %08x\n",tri.accel_ckey); |
| 888 | if(LOG) logerror("Trident: CKey set to %08x\n",tri.accel_ckey); |
| 914 | 889 | break; |
| 915 | 890 | case 0x58: // Foreground Pattern Colour |
| 916 | 891 | tri.accel_fg_pattern_colour = (tri.accel_fg_pattern_colour & 0xffffff00) | data; |
| 917 | | logerror("Trident: FG Pattern Colour set to %08x\n",tri.accel_fg_pattern_colour); |
| 892 | if(LOG) logerror("Trident: FG Pattern Colour set to %08x\n",tri.accel_fg_pattern_colour); |
| 918 | 893 | break; |
| 919 | 894 | case 0x59: |
| 920 | 895 | tri.accel_fg_pattern_colour = (tri.accel_fg_pattern_colour & 0xffff00ff) | (data << 8); |
| 921 | | logerror("Trident: FG Pattern Colour set to %08x\n",tri.accel_fg_pattern_colour); |
| 896 | if(LOG) logerror("Trident: FG Pattern Colour set to %08x\n",tri.accel_fg_pattern_colour); |
| 922 | 897 | break; |
| 923 | 898 | case 0x5a: |
| 924 | 899 | tri.accel_fg_pattern_colour = (tri.accel_fg_pattern_colour & 0xff00ffff) | (data << 16); |
| 925 | | logerror("Trident: FG Pattern Colour set to %08x\n",tri.accel_fg_pattern_colour); |
| 900 | if(LOG) logerror("Trident: FG Pattern Colour set to %08x\n",tri.accel_fg_pattern_colour); |
| 926 | 901 | break; |
| 927 | 902 | case 0x5b: |
| 928 | 903 | tri.accel_fg_pattern_colour = (tri.accel_fg_pattern_colour & 0x00ffffff) | (data << 24); |
| 929 | | logerror("Trident: FG Pattern Colour set to %08x\n",tri.accel_fg_pattern_colour); |
| 904 | if(LOG) logerror("Trident: FG Pattern Colour set to %08x\n",tri.accel_fg_pattern_colour); |
| 930 | 905 | break; |
| 931 | 906 | case 0x5c: // Background Pattern Colour |
| 932 | 907 | tri.accel_bg_pattern_colour = (tri.accel_bg_pattern_colour & 0xffffff00) | data; |
| 933 | | logerror("Trident: BG Pattern Colour set to %08x\n",tri.accel_bg_pattern_colour); |
| 908 | if(LOG) logerror("Trident: BG Pattern Colour set to %08x\n",tri.accel_bg_pattern_colour); |
| 934 | 909 | break; |
| 935 | 910 | case 0x5d: |
| 936 | 911 | tri.accel_bg_pattern_colour = (tri.accel_bg_pattern_colour & 0xffff00ff) | (data << 8); |
| 937 | | logerror("Trident: BG Pattern Colour set to %08x\n",tri.accel_bg_pattern_colour); |
| 912 | if(LOG) logerror("Trident: BG Pattern Colour set to %08x\n",tri.accel_bg_pattern_colour); |
| 938 | 913 | break; |
| 939 | 914 | case 0x5e: |
| 940 | 915 | tri.accel_bg_pattern_colour = (tri.accel_bg_pattern_colour & 0xff00ffff) | (data << 16); |
| 941 | | logerror("Trident: BG Pattern Colour set to %08x\n",tri.accel_bg_pattern_colour); |
| 916 | if(LOG) logerror("Trident: BG Pattern Colour set to %08x\n",tri.accel_bg_pattern_colour); |
| 942 | 917 | break; |
| 943 | 918 | case 0x5f: |
| 944 | 919 | tri.accel_bg_pattern_colour = (tri.accel_bg_pattern_colour & 0x00ffffff) | (data << 24); |
| 945 | | logerror("Trident: BG Pattern Colour set to %08x\n",tri.accel_bg_pattern_colour); |
| 920 | if(LOG) logerror("Trident: BG Pattern Colour set to %08x\n",tri.accel_bg_pattern_colour); |
| 946 | 921 | break; |
| 947 | 922 | default: |
| 948 | | logerror("Trident: unimplemented acceleration register offset %02x write %02x\n",offset,data); |
| 923 | if(LOG) logerror("Trident: unimplemented acceleration register offset %02x write %02x\n",offset,data); |
| 949 | 924 | } |
| 950 | 925 | } |
| 926 | |
| 927 | void trident_vga_device::accel_command() |
| 928 | { |
| 929 | switch(tri.accel_command) |
| 930 | { |
| 931 | case 0x00: |
| 932 | if(LOG) logerror("Trident: Command: NOP\n"); |
| 933 | break; |
| 934 | case 0x01: |
| 935 | if(LOG) logerror("Trident: Command: BitBLT ROP3 (Source %i,%i Dest %i,%i Size %i,%i)\n",tri.accel_source_x,tri.accel_source_y,tri.accel_dest_x,tri.accel_dest_y,tri.accel_dim_x,tri.accel_dim_y); |
| 936 | logerror("BitBLT: Drawflags = %08x\n",tri.accel_drawflags); |
| 937 | accel_bitblt(); |
| 938 | break; |
| 939 | case 0x02: |
| 940 | if(LOG) logerror("Trident: Command: BitBLT ROP4\n"); |
| 941 | break; |
| 942 | case 0x03: |
| 943 | if(LOG) logerror("Trident: Command: Scanline\n"); |
| 944 | break; |
| 945 | case 0x04: |
| 946 | if(LOG) logerror("Trident: Command: Bresenham Line (Source %i,%i Dest %i,%i Size %i,%i)\n",tri.accel_source_x,tri.accel_source_y,tri.accel_dest_x,tri.accel_dest_y,tri.accel_dim_x,tri.accel_dim_y); |
| 947 | accel_line(); |
| 948 | break; |
| 949 | case 0x05: |
| 950 | if(LOG) logerror("Trident: Command: Short Vector\n"); |
| 951 | break; |
| 952 | case 0x06: |
| 953 | if(LOG) logerror("Trident: Command: Fast Line\n"); |
| 954 | break; |
| 955 | case 0x07: |
| 956 | if(LOG) logerror("Trident: Command: Trapezoid Fill\n"); |
| 957 | break; |
| 958 | case 0x08: |
| 959 | if(LOG) logerror("Trident: Command: Ellipse\n"); |
| 960 | break; |
| 961 | case 0x09: |
| 962 | if(LOG) logerror("Trident: Command: Ellipse Fill\n"); |
| 963 | break; |
| 964 | default: |
| 965 | logerror("Trident: Unknown acceleration command %02x\n",tri.accel_command); |
| 966 | } |
| 967 | } |
| 968 | |
| 969 | void trident_vga_device::accel_bitblt() |
| 970 | { |
| 971 | int x,y; |
| 972 | int sx,sy; |
| 973 | int xdir,ydir; |
| 974 | int xstart,xend,ystart,yend; |
| 975 | |
| 976 | if(tri.accel_drawflags & 0x0200) |
| 977 | { |
| 978 | xdir = -1; |
| 979 | xstart = tri.accel_dest_x; |
| 980 | xend = tri.accel_dest_x-tri.accel_dim_x-1; |
| 981 | } |
| 982 | else |
| 983 | { |
| 984 | xdir = 1; |
| 985 | xstart = tri.accel_dest_x; |
| 986 | xend = tri.accel_dest_x+tri.accel_dim_x+1; |
| 987 | } |
| 988 | if(tri.accel_drawflags & 0x0100) |
| 989 | { |
| 990 | ydir = -1; |
| 991 | ystart = tri.accel_dest_y; |
| 992 | yend = tri.accel_dest_y-tri.accel_dim_y-1; |
| 993 | } |
| 994 | else |
| 995 | { |
| 996 | ydir = 1; |
| 997 | ystart = tri.accel_dest_y; |
| 998 | yend = tri.accel_dest_y+tri.accel_dim_y+1; |
| 999 | } |
| 1000 | sy = tri.accel_source_y; |
| 1001 | |
| 1002 | // printf("BitBLT: flags=%08x source %i, %i dest %i, %i size %i, %i dir %i,%i\n", |
| 1003 | // tri.accel_drawflags,tri.accel_source_x,tri.accel_source_y,tri.accel_dest_x,tri.accel_dest_y, |
| 1004 | // tri.accel_dim_x,tri.accel_dim_y,xdir,ydir); |
| 1005 | for(y=ystart;y!=yend;y+=ydir,sy+=ydir) |
| 1006 | { |
| 1007 | sx = tri.accel_source_x; |
| 1008 | for(x=xstart;x!=xend;x+=xdir,sx+=xdir) |
| 1009 | { |
| 1010 | if(tri.accel_drawflags & 0x4000) // Solid fill |
| 1011 | { |
| 1012 | WRITEPIXEL8(x,y,tri.accel_fgcolour); |
| 1013 | } |
| 1014 | else |
| 1015 | { |
| 1016 | WRITEPIXEL8(x,y,READPIXEL8(sx,sy)); |
| 1017 | } |
| 1018 | } |
| 1019 | } |
| 1020 | } |
| 1021 | |
| 1022 | void trident_vga_device::accel_line() |
| 1023 | { |
| 1024 | UINT8 col = tri.accel_fgcolour & 0xff; |
| 1025 | // TGUI_SRC_XY(dmin-dmaj,dmin); |
| 1026 | // TGUI_DEST_XY(x,y); |
| 1027 | // TGUI_DIM_XY(dmin+e,len); |
| 1028 | INT16 dx = abs(tri.accel_source_x); |
| 1029 | INT16 dy = abs(tri.accel_source_y); |
| 1030 | INT16 err = tri.accel_dim_x - tri.accel_source_y; |
| 1031 | int sx = (tri.accel_drawflags & 0x0200) ? -1 : 1; |
| 1032 | int sy = (tri.accel_drawflags & 0x0100) ? -1 : 1; |
| 1033 | int count = 0; |
| 1034 | INT16 temp; |
| 1035 | |
| 1036 | // if(LOG_8514) logerror("8514/A: Command (%04x) - Line (Bresenham) - %i,%i Axial %i, Diagonal %i, Error %i, Major Axis %i, Minor Axis %i\n",ibm8514.current_cmd, |
| 1037 | // ibm8514.curr_x,ibm8514.curr_y,ibm8514.line_axial_step,ibm8514.line_diagonal_step,ibm8514.line_errorterm,ibm8514.rect_width,ibm8514.rect_height); |
| 1038 | |
| 1039 | if(tri.accel_drawflags & 0x400) |
| 1040 | { |
| 1041 | temp = dx; dx = dy; dy = temp; |
| 1042 | } |
| 1043 | for(;;) |
| 1044 | { |
| 1045 | WRITEPIXEL8(tri.accel_dest_x,tri.accel_dest_y,col); |
| 1046 | if (count > tri.accel_dim_y) break; |
| 1047 | count++; |
| 1048 | if((err*2) > -dy) |
| 1049 | { |
| 1050 | err -= dy; |
| 1051 | tri.accel_dest_x += sx; |
| 1052 | } |
| 1053 | if((err*2) < dx) |
| 1054 | { |
| 1055 | err += dx; |
| 1056 | tri.accel_dest_y += sy; |
| 1057 | } |
| 1058 | } |
| 1059 | } |