trunk/src/emu/video/pc_vga.c
r17520 | r17521 | |
204 | 204 | UINT8 reg_lock2; |
205 | 205 | UINT8 enable_8514; |
206 | 206 | UINT16 current_cmd; |
207 | | UINT16 dest_x; |
208 | | UINT16 dest_y; |
209 | | UINT16 curr_x; |
210 | | UINT16 curr_y; |
| 207 | INT16 dest_x; |
| 208 | INT16 dest_y; |
| 209 | INT16 curr_x; |
| 210 | INT16 curr_y; |
211 | 211 | UINT16 line_axial_step; |
212 | 212 | UINT16 line_diagonal_step; |
213 | 213 | UINT16 rect_width; |
r17520 | r17521 | |
215 | 215 | UINT32 fgcolour; |
216 | 216 | UINT32 bgcolour; |
217 | 217 | UINT32 pixel_xfer; |
218 | | UINT16 wait_rect_x; |
219 | | UINT16 wait_rect_y; |
| 218 | INT16 wait_rect_x; |
| 219 | INT16 wait_rect_y; |
220 | 220 | UINT8 bus_size; |
221 | 221 | UINT8 multifunc_sel; |
222 | 222 | bool gpbusy; |
r17520 | r17521 | |
2851 | 2851 | switch(data & 0xe000) |
2852 | 2852 | { |
2853 | 2853 | case 0x0000: // NOP (for "Short Stroke Vectors") |
| 2854 | s3.state = S3_IDLE; |
2854 | 2855 | s3.gpbusy = false; |
2855 | 2856 | logerror("S3: Command (%04x) - NOP\n",s3.current_cmd); |
2856 | 2857 | break; |
2857 | 2858 | case 0x2000: // Line |
| 2859 | s3.state = S3_IDLE; |
2858 | 2860 | s3.gpbusy = false; |
2859 | 2861 | logerror("S3: Command (%04x) - Line\n",s3.current_cmd); |
2860 | 2862 | break; |
r17520 | r17521 | |
2866 | 2868 | s3.wait_rect_x = s3.curr_x; |
2867 | 2869 | s3.wait_rect_y = s3.curr_y; |
2868 | 2870 | s3.bus_size = (data & 0x0600) >> 9; |
| 2871 | logerror("S3: Command (%04x) - Rectangle Fill (WAIT) %i,%i Width: %i Height: %i Colour: %08x\n",s3.current_cmd,s3.curr_x, |
| 2872 | s3.curr_y,s3.rect_width,s3.rect_height,s3.fgcolour); |
2869 | 2873 | break; |
2870 | 2874 | } |
2871 | 2875 | offset = VGA_START_ADDRESS; |
2872 | 2876 | offset += (VGA_LINE_LENGTH * s3.curr_y); |
2873 | 2877 | offset += s3.curr_x; |
2874 | | dir_x = 2; |
| 2878 | if(data & 0x0020) |
| 2879 | dir_x = 2; |
| 2880 | else |
| 2881 | dir_x -= 2; |
2875 | 2882 | for(y=0;y<=s3.rect_height;y++) |
2876 | 2883 | { |
2877 | 2884 | for(x=0;x<=s3.rect_width;x+=dir_x) |
r17520 | r17521 | |
2879 | 2886 | vga.memory[(offset+x) % vga.svga_intf.vram_size] = s3.fgcolour & 0x000000ff; |
2880 | 2887 | vga.memory[(offset+x+1) % vga.svga_intf.vram_size] = (s3.fgcolour & 0x0000ff00) >> 8; |
2881 | 2888 | } |
2882 | | offset += VGA_LINE_LENGTH; |
| 2889 | if(data & 0x0080) |
| 2890 | offset += VGA_LINE_LENGTH; |
| 2891 | else |
| 2892 | offset -= VGA_LINE_LENGTH; |
2883 | 2893 | } |
| 2894 | s3.state = S3_IDLE; |
2884 | 2895 | s3.gpbusy = false; |
2885 | 2896 | logerror("S3: Command (%04x) - Rectangle Fill %i,%i Width: %i Height: %i Colour: %08x\n",s3.current_cmd,s3.curr_x, |
2886 | 2897 | s3.curr_y,s3.rect_width,s3.rect_height,s3.fgcolour); |
r17520 | r17521 | |
2891 | 2902 | offset += s3.dest_x; |
2892 | 2903 | src = VGA_START_ADDRESS; |
2893 | 2904 | src += (VGA_LINE_LENGTH * s3.curr_y); |
2894 | | src += s3.curr_x; |
| 2905 | if(s3.curr_x & 0x0800) |
| 2906 | src -= s3.curr_x & 0x7ff; |
| 2907 | else |
| 2908 | src += s3.curr_x; |
2895 | 2909 | buffer = (UINT8*)malloc((s3.rect_height+1)*(s3.rect_width+1)); |
2896 | 2910 | count = 0; |
2897 | 2911 | // copy to temporary buffer |
r17520 | r17521 | |
2926 | 2940 | offset -= VGA_LINE_LENGTH; |
2927 | 2941 | } |
2928 | 2942 | free(buffer); |
| 2943 | s3.state = S3_IDLE; |
2929 | 2944 | s3.gpbusy = false; |
2930 | 2945 | logerror("S3: Command (%04x) - BitBLT from %i,%i to %i,%i Width: %i Height: %i\n",s3.current_cmd, |
2931 | 2946 | s3.curr_x,s3.curr_y,s3.dest_x,s3.dest_y,s3.rect_width,s3.rect_height); |
2932 | 2947 | break; |
2933 | 2948 | case 0xe000: // Pattern Fill |
| 2949 | s3.state = S3_IDLE; |
2934 | 2950 | s3.gpbusy = false; |
2935 | 2951 | logerror("S3: Command (%04x) - Pattern Fill\n",s3.current_cmd); |
2936 | 2952 | break; |
2937 | 2953 | default: |
| 2954 | s3.state = S3_IDLE; |
2938 | 2955 | s3.gpbusy = false; |
2939 | 2956 | logerror("S3: Unknown command: %04x\n",data); |
2940 | 2957 | } |
r17520 | r17521 | |
2963 | 2980 | WRITE16_HANDLER( s3_8ae8_w ) |
2964 | 2981 | { |
2965 | 2982 | s3.line_axial_step = data & 0x3fff; |
2966 | | s3.dest_y = data & 0x0fff; |
| 2983 | s3.dest_y = data; |
2967 | 2984 | logerror("S3: Line Axial Step / Destination Y write %04x\n",data); |
2968 | 2985 | } |
2969 | 2986 | |
r17520 | r17521 | |
2988 | 3005 | WRITE16_HANDLER( s3_8ee8_w ) |
2989 | 3006 | { |
2990 | 3007 | s3.line_diagonal_step = data & 0x3fff; |
2991 | | s3.dest_x = data & 0x0fff; |
| 3008 | s3.dest_x = data; |
2992 | 3009 | logerror("S3: Line Diagonal Step / Destination X write %04x\n",data); |
2993 | 3010 | } |
2994 | 3011 | |
r17520 | r17521 | |
3019 | 3036 | |
3020 | 3037 | WRITE16_HANDLER(s3_currentx_w) |
3021 | 3038 | { |
3022 | | s3.curr_x = data & 0x0fff; |
3023 | | logerror("S3: Current X set to %04x\n",data); |
| 3039 | s3.curr_x = data; |
| 3040 | logerror("S3: Current X set to %04x (%i)\n",data,s3.curr_x); |
3024 | 3041 | } |
3025 | 3042 | |
3026 | 3043 | READ16_HANDLER(s3_currenty_r) |
r17520 | r17521 | |
3030 | 3047 | |
3031 | 3048 | WRITE16_HANDLER(s3_currenty_w) |
3032 | 3049 | { |
3033 | | s3.curr_y = data & 0x0fff; |
3034 | | logerror("S3: Current Y set to %04x\n",data); |
| 3050 | s3.curr_y = data; |
| 3051 | logerror("S3: Current Y set to %04x (%i)\n",data,s3.curr_y); |
3035 | 3052 | } |
3036 | 3053 | |
3037 | 3054 | READ16_HANDLER(s3_fgcolour_r) |
r17520 | r17521 | |
3104 | 3121 | case 0xf000: |
3105 | 3122 | s3.multifunc_sel = data & 0x000f; |
3106 | 3123 | default: |
3107 | | logerror("S3: Unimplemented multifunction register %i write\n",data >> 12); |
| 3124 | logerror("S3: Unimplemented multifunction register %i write %03x\n",data >> 12,data & 0x0fff); |
3108 | 3125 | } |
3109 | 3126 | } |
3110 | 3127 | |
r17520 | r17521 | |
3140 | 3157 | off += s3.wait_rect_x; |
3141 | 3158 | for(x=0;x<data_size;x++) |
3142 | 3159 | { |
3143 | | if(s3.current_cmd & 0x1000) |
| 3160 | if(s3.wait_rect_x >= 0 || s3.wait_rect_y >= 0) |
3144 | 3161 | { |
3145 | | xfer = ((s3.pixel_xfer & 0x000000ff) << 8) | ((s3.pixel_xfer & 0x0000ff00) >> 8) |
3146 | | | ((s3.pixel_xfer & 0x00ff0000) << 8) | ((s3.pixel_xfer & 0xff000000) >> 8); |
| 3162 | if(s3.current_cmd & 0x1000) |
| 3163 | { |
| 3164 | xfer = ((s3.pixel_xfer & 0x000000ff) << 8) | ((s3.pixel_xfer & 0x0000ff00) >> 8) |
| 3165 | | ((s3.pixel_xfer & 0x00ff0000) << 8) | ((s3.pixel_xfer & 0xff000000) >> 8); |
| 3166 | } |
| 3167 | else |
| 3168 | xfer = s3.pixel_xfer; |
| 3169 | if((xfer & ((1<<(data_size-1))>>x)) != 0) |
| 3170 | vga.memory[off] = s3.fgcolour & 0x00ff; |
3147 | 3171 | } |
3148 | | else |
3149 | | xfer = s3.pixel_xfer; |
3150 | | if((xfer & ((1<<(data_size-1))>>x)) != 0) |
3151 | | vga.memory[off] = s3.fgcolour & 0x00ff; |
3152 | 3172 | off++; |
3153 | 3173 | s3.wait_rect_x++; |
3154 | 3174 | if(s3.wait_rect_x > s3.curr_x + s3.rect_width) |