trunk/src/emu/video/pc_vga.c
r17495 | r17496 | |
191 | 191 | S3_IDLE = 0, |
192 | 192 | S3_DRAWING_RECT, |
193 | 193 | S3_DRAWING_LINE, |
194 | | S3_DRAWING_BITBLT |
| 194 | S3_DRAWING_BITBLT, |
| 195 | S3_DRAWING_PATTERN |
195 | 196 | }; |
196 | 197 | |
197 | 198 | static struct |
r17495 | r17496 | |
2841 | 2842 | { |
2842 | 2843 | if(s3.enable_8514 != 0) |
2843 | 2844 | { |
2844 | | int x,y; |
| 2845 | int x,y,count; |
2845 | 2846 | int dir_x; |
2846 | | UINT32 offset; |
| 2847 | UINT32 offset,src; |
| 2848 | UINT8* buffer; // for bitblt operations |
| 2849 | |
2847 | 2850 | s3.current_cmd = data; |
2848 | 2851 | switch(data & 0xe000) |
2849 | 2852 | { |
r17495 | r17496 | |
2873 | 2876 | { |
2874 | 2877 | for(x=0;x<=s3.rect_width;x+=dir_x) |
2875 | 2878 | { |
2876 | | vga.memory[(offset+x) % vga.svga_intf.vram_size] = s3.fgcolour & 0x000000ff; // TODO: handle 16-bit or 32-bit transfers |
| 2879 | vga.memory[(offset+x) % vga.svga_intf.vram_size] = s3.fgcolour & 0x000000ff; |
2877 | 2880 | vga.memory[(offset+x+1) % vga.svga_intf.vram_size] = (s3.fgcolour & 0x0000ff00) >> 8; |
2878 | 2881 | } |
2879 | 2882 | offset += VGA_LINE_LENGTH; |
2880 | 2883 | } |
2881 | | logerror("S3: Command (%04x) - Rectangle Fill %i,%i Width: %i Height: %i Colour: %08x\n",s3.current_cmd,s3.curr_x,s3.curr_y,s3.rect_width,s3.rect_height,s3.fgcolour); |
| 2884 | s3.gpbusy = false; |
| 2885 | logerror("S3: Command (%04x) - Rectangle Fill %i,%i Width: %i Height: %i Colour: %08x\n",s3.current_cmd,s3.curr_x, |
| 2886 | s3.curr_y,s3.rect_width,s3.rect_height,s3.fgcolour); |
2882 | 2887 | break; |
2883 | 2888 | case 0xc000: // BitBLT |
| 2889 | offset = VGA_START_ADDRESS; |
| 2890 | offset += (VGA_LINE_LENGTH * s3.dest_y); |
| 2891 | offset += s3.dest_x; |
| 2892 | src = VGA_START_ADDRESS; |
| 2893 | src += (VGA_LINE_LENGTH * s3.curr_y); |
| 2894 | src += s3.curr_x; |
| 2895 | buffer = (UINT8*)malloc((s3.rect_height+1)*(s3.rect_width+1)); |
| 2896 | count = 0; |
| 2897 | // copy to temporary buffer |
| 2898 | for(y=0;y<=s3.rect_height;y++) |
| 2899 | { |
| 2900 | for(x=0;x<=s3.rect_width;x++) |
| 2901 | { |
| 2902 | if(data & 0x0020) |
| 2903 | buffer[count++] = vga.memory[(src+x) % vga.svga_intf.vram_size]; |
| 2904 | else |
| 2905 | buffer[count++] = vga.memory[(src-x) % vga.svga_intf.vram_size]; |
| 2906 | } |
| 2907 | if(data & 0x0080) |
| 2908 | src += VGA_LINE_LENGTH; |
| 2909 | else |
| 2910 | src -= VGA_LINE_LENGTH; |
| 2911 | } |
| 2912 | // write from buffer to screen |
| 2913 | count = 0; |
| 2914 | for(y=0;y<=s3.rect_height;y++) |
| 2915 | { |
| 2916 | for(x=0;x<=s3.rect_width;x++) |
| 2917 | { |
| 2918 | if(data & 0x0020) |
| 2919 | vga.memory[(offset+x) % vga.svga_intf.vram_size] = buffer[count++]; |
| 2920 | else |
| 2921 | vga.memory[(offset-x) % vga.svga_intf.vram_size] = buffer[count++]; |
| 2922 | } |
| 2923 | if(data & 0x0080) |
| 2924 | offset += VGA_LINE_LENGTH; |
| 2925 | else |
| 2926 | offset -= VGA_LINE_LENGTH; |
| 2927 | } |
| 2928 | free(buffer); |
2884 | 2929 | s3.gpbusy = false; |
2885 | | logerror("S3: Command (%04x) - BitBLT\n",s3.current_cmd); |
| 2930 | logerror("S3: Command (%04x) - BitBLT from %i,%i to %i,%i Width: %i Height: %i\n",s3.current_cmd, |
| 2931 | s3.curr_x,s3.curr_y,s3.dest_x,s3.dest_y,s3.rect_width,s3.rect_height); |
2886 | 2932 | break; |
2887 | 2933 | case 0xe000: // Pattern Fill |
2888 | 2934 | s3.gpbusy = false; |
r17495 | r17496 | |
2974 | 3020 | WRITE16_HANDLER(s3_currentx_w) |
2975 | 3021 | { |
2976 | 3022 | s3.curr_x = data & 0x0fff; |
| 3023 | logerror("S3: Current X set to %04x\n",data); |
2977 | 3024 | } |
2978 | 3025 | |
2979 | 3026 | READ16_HANDLER(s3_currenty_r) |
r17495 | r17496 | |
2984 | 3031 | WRITE16_HANDLER(s3_currenty_w) |
2985 | 3032 | { |
2986 | 3033 | s3.curr_y = data & 0x0fff; |
| 3034 | logerror("S3: Current Y set to %04x\n",data); |
2987 | 3035 | } |
2988 | 3036 | |
2989 | 3037 | READ16_HANDLER(s3_fgcolour_r) |