src/emu/video/pc_vga.c
| r14383 | r14384 | |
| 44 | 44 | |
| 45 | 45 | #include "emu.h" |
| 46 | 46 | #include "pc_vga.h" |
| 47 | #include "debugger.h" |
| 47 | 48 | |
| 48 | 49 | /*************************************************************************** |
| 49 | 50 | |
| r14383 | r14384 | |
| 102 | 103 | /**/ UINT8 cursor_scan_start; |
| 103 | 104 | /**/ UINT8 cursor_skew; |
| 104 | 105 | /**/ UINT8 cursor_scan_end; |
| 105 | | /**/ UINT16 start_addr; |
| 106 | UINT32 start_addr; |
| 106 | 107 | /**/ UINT8 protect_enable; |
| 107 | 108 | /**/ UINT8 bandwidth; |
| 108 | 109 | /**/ UINT8 offset; |
| r14383 | r14384 | |
| 172 | 173 | UINT8 id; |
| 173 | 174 | }svga; |
| 174 | 175 | |
| 176 | static struct |
| 177 | { |
| 178 | UINT8 memory_config; |
| 179 | UINT8 ext_misc_ctrl_2; |
| 180 | UINT8 crt_reg_lock; |
| 181 | UINT8 reg_lock1; |
| 182 | }s3; |
| 183 | |
| 175 | 184 | #define REG(x) vga.crtc.data[x] |
| 176 | 185 | |
| 177 | 186 | #define CRTC_CHAR_HEIGHT ((REG(9)&0x1f)+1) |
| r14383 | r14384 | |
| 505 | 514 | int height = vga.crtc.maximum_scan_line * (vga.crtc.scan_doubling + 1); |
| 506 | 515 | int yi; |
| 507 | 516 | int xi; |
| 517 | UINT8 start_shift; |
| 508 | 518 | |
| 509 | 519 | /* line compare is screen sensitive */ |
| 510 | 520 | mask_comp = 0x3ff; |
| 521 | curr_addr = 0; |
| 511 | 522 | |
| 512 | | curr_addr = 0; |
| 513 | | for (addr = VGA_START_ADDRESS, line=0; line<LINES; line+=height, addr+=VGA_LINE_LENGTH, curr_addr+=VGA_LINE_LENGTH) |
| 523 | start_shift = (!(vga.sequencer.data[4] & 0x08)) ? 2 : 0; |
| 524 | |
| 514 | 525 | { |
| 515 | | for(yi = 0;yi < height; yi++) |
| 526 | for (addr = VGA_START_ADDRESS << start_shift, line=0; line<LINES; line+=height, addr+=VGA_LINE_LENGTH, curr_addr+=VGA_LINE_LENGTH) |
| 516 | 527 | { |
| 517 | | if((line + yi) < (vga.crtc.line_compare & mask_comp)) |
| 518 | | curr_addr = addr; |
| 519 | | if((line + yi) == (vga.crtc.line_compare & mask_comp)) |
| 520 | | curr_addr = 0; |
| 521 | | bitmapline = &bitmap.pix32(line + yi); |
| 522 | | addr %= vga.svga_intf.vram_size; |
| 523 | | for (pos=curr_addr, c=0, column=0; column<VGA_COLUMNS; column++, c+=8, pos+=0x8) |
| 528 | for(yi = 0;yi < height; yi++) |
| 524 | 529 | { |
| 525 | | if(pos + 0x08 > 0x100000) |
| 526 | | return; |
| 530 | if((line + yi) < (vga.crtc.line_compare & mask_comp)) |
| 531 | curr_addr = addr; |
| 532 | if((line + yi) == (vga.crtc.line_compare & mask_comp)) |
| 533 | curr_addr = 0; |
| 534 | bitmapline = &bitmap.pix32(line + yi); |
| 535 | addr %= vga.svga_intf.vram_size; |
| 536 | for (pos=curr_addr, c=0, column=0; column<VGA_COLUMNS; column++, c+=8, pos+=0x8) |
| 537 | { |
| 538 | if(pos + 0x08 > 0x100000) |
| 539 | return; |
| 527 | 540 | |
| 528 | | for(xi=0;xi<8;xi++) |
| 529 | | { |
| 530 | | if(!machine.primary_screen->visible_area().contains(c+xi, line + yi)) |
| 531 | | continue; |
| 532 | | bitmapline[c+xi] = machine.pens[vga.memory[(pos+(xi))]]; |
| 541 | for(xi=0;xi<8;xi++) |
| 542 | { |
| 543 | if(!machine.primary_screen->visible_area().contains(c+xi, line + yi)) |
| 544 | continue; |
| 545 | bitmapline[c+xi] = machine.pens[vga.memory[(pos+(xi))]]; |
| 546 | } |
| 533 | 547 | } |
| 534 | 548 | } |
| 535 | 549 | } |
| r14383 | r14384 | |
| 2025 | 2039 | } |
| 2026 | 2040 | } |
| 2027 | 2041 | |
| 2042 | static UINT8 s3_crtc_reg_read(running_machine &machine, UINT8 index) |
| 2043 | { |
| 2044 | UINT8 res; |
| 2028 | 2045 | |
| 2046 | res = 0; |
| 2047 | if(index <= 0x18) |
| 2048 | res = vga.crtc.data[index]; |
| 2049 | else |
| 2050 | { |
| 2051 | switch(index) |
| 2052 | { |
| 2053 | case 0x30: // CR30 Chip ID/REV register |
| 2054 | res = 0xc0; // TODO: hardcoded to Vision 86c864 |
| 2055 | break; |
| 2056 | case 0x31: |
| 2057 | res = s3.memory_config; |
| 2058 | break; |
| 2059 | case 0x35: |
| 2060 | res = s3.crt_reg_lock; |
| 2061 | break; |
| 2062 | case 0x38: |
| 2063 | res = s3.reg_lock1; |
| 2064 | break; |
| 2065 | case 0x42: // CR42 Mode Control |
| 2066 | res = 0x0d; // hardcode to non-interlace |
| 2067 | break; |
| 2068 | case 0x67: |
| 2069 | res = s3.ext_misc_ctrl_2; |
| 2070 | break; |
| 2071 | case 0x6a: |
| 2072 | res = svga.bank_r & 0x7f; |
| 2073 | break; |
| 2074 | default: |
| 2075 | res = vga.crtc.data[index]; |
| 2076 | //debugger_break(machine); |
| 2077 | //printf("%02x\n",index); |
| 2078 | break; |
| 2079 | } |
| 2080 | } |
| 2081 | |
| 2082 | return res; |
| 2083 | } |
| 2084 | |
| 2085 | static void s3_define_video_mode(void) |
| 2086 | { |
| 2087 | if((s3.ext_misc_ctrl_2) >> 4) |
| 2088 | { |
| 2089 | fatalerror("TODO: s3 video mode not implemented %02x",((s3.ext_misc_ctrl_2) >> 4)); |
| 2090 | } |
| 2091 | else |
| 2092 | { |
| 2093 | svga.rgb8_en = (s3.memory_config & 8) >> 3; |
| 2094 | } |
| 2095 | } |
| 2096 | |
| 2097 | static void s3_crtc_reg_write(running_machine &machine, UINT8 index, UINT8 data) |
| 2098 | { |
| 2099 | if(index <= 0x18) |
| 2100 | crtc_reg_write(machine,index,data); |
| 2101 | else |
| 2102 | { |
| 2103 | switch(index) |
| 2104 | { |
| 2105 | case 0x31: // CR31 Memory Configuration Register |
| 2106 | s3.memory_config = data; |
| 2107 | vga.crtc.start_addr &= ~0x30000; |
| 2108 | vga.crtc.start_addr |= ((data & 0x30) << 12); |
| 2109 | //popmessage("%02x",data); |
| 2110 | s3_define_video_mode(); |
| 2111 | break; |
| 2112 | case 0x35: |
| 2113 | if((s3.reg_lock1 & 0xc) != 8 || ((s3.reg_lock1 & 0xc0) == 0)) // lock register |
| 2114 | return; |
| 2115 | s3.crt_reg_lock = data; |
| 2116 | svga.bank_w = data & 0xf; |
| 2117 | svga.bank_r = svga.bank_w; |
| 2118 | break; |
| 2119 | case 0x38: |
| 2120 | s3.reg_lock1 = data; |
| 2121 | break; |
| 2122 | case 0x51: |
| 2123 | vga.crtc.start_addr &= ~0xc0000; |
| 2124 | vga.crtc.start_addr |= ((data & 0x3) << 18); |
| 2125 | break; |
| 2126 | case 0x67: |
| 2127 | s3.ext_misc_ctrl_2 = data; |
| 2128 | s3_define_video_mode(); |
| 2129 | //printf("%02x X\n",data); |
| 2130 | //debugger_break(machine); |
| 2131 | break; |
| 2132 | case 0x6a: |
| 2133 | svga.bank_w = data & 0xf; |
| 2134 | svga.bank_r = svga.bank_w; |
| 2135 | if(data & 0x60) |
| 2136 | fatalerror("TODO: s3 bank selects above 1M"); |
| 2137 | break; |
| 2138 | default: |
| 2139 | //printf("%02x %02x\n",index,data); |
| 2140 | break; |
| 2141 | } |
| 2142 | } |
| 2143 | } |
| 2144 | |
| 2029 | 2145 | READ8_HANDLER(s3_port_03d0_r) |
| 2030 | 2146 | { |
| 2031 | 2147 | UINT8 res = 0xff; |
| r14383 | r14384 | |
| 2034 | 2150 | { |
| 2035 | 2151 | switch(offset) |
| 2036 | 2152 | { |
| 2153 | case 5: |
| 2154 | res = s3_crtc_reg_read(space->machine(),vga.crtc.index); |
| 2155 | break; |
| 2037 | 2156 | default: |
| 2038 | 2157 | res = vga_port_03d0_r(space,offset); |
| 2039 | 2158 | break; |
| r14383 | r14384 | |
| 2049 | 2168 | { |
| 2050 | 2169 | switch(offset) |
| 2051 | 2170 | { |
| 2171 | case 5: |
| 2172 | vga.crtc.data[vga.crtc.index] = data; |
| 2173 | s3_crtc_reg_write(space->machine(),vga.crtc.index,data); |
| 2174 | break; |
| 2052 | 2175 | default: |
| 2053 | 2176 | vga_port_03d0_w(space,offset,data); |
| 2054 | 2177 | break; |
| r14383 | r14384 | |
| 2056 | 2179 | } |
| 2057 | 2180 | } |
| 2058 | 2181 | |
| 2182 | /* accelerated ports, TBD ... */ |
| 2183 | READ8_HANDLER(s3_port_9ae8_r) |
| 2184 | { |
| 2185 | return 0; |
| 2186 | } |
| 2187 | |
| 2188 | WRITE8_HANDLER(s3_port_9ae8_w) |
| 2189 | { |
| 2190 | // ... |
| 2191 | } |
| 2192 | |
| 2059 | 2193 | READ8_HANDLER( s3_mem_r ) |
| 2060 | 2194 | { |
| 2195 | if (svga.rgb8_en) |
| 2196 | { |
| 2197 | int data; |
| 2198 | if(offset & 0x10000) |
| 2199 | return 0; |
| 2200 | data = 0; |
| 2201 | if(vga.sequencer.data[4] & 0x8) |
| 2202 | data = vga.memory[offset + (svga.bank_r*0x10000)]; |
| 2203 | else |
| 2204 | { |
| 2205 | int i; |
| 2206 | |
| 2207 | for(i=0;i<4;i++) |
| 2208 | { |
| 2209 | if(vga.sequencer.map_mask & 1 << i) |
| 2210 | data |= vga.memory[offset*4+i+(svga.bank_r*0x10000)]; |
| 2211 | } |
| 2212 | } |
| 2213 | return data; |
| 2214 | } |
| 2061 | 2215 | return vga_mem_r(space,offset); |
| 2062 | 2216 | } |
| 2063 | 2217 | |
| 2064 | 2218 | WRITE8_HANDLER( s3_mem_w ) |
| 2065 | 2219 | { |
| 2220 | if (svga.rgb8_en) |
| 2221 | { |
| 2222 | //printf("%08x %02x (%02x %02x) %02X\n",offset,data,vga.sequencer.map_mask,svga.bank_w,(vga.sequencer.data[4] & 0x08)); |
| 2223 | if(offset & 0x10000) |
| 2224 | return; |
| 2225 | if(vga.sequencer.data[4] & 0x8) |
| 2226 | vga.memory[offset + (svga.bank_w*0x10000)] = data; |
| 2227 | else |
| 2228 | { |
| 2229 | int i; |
| 2230 | for(i=0;i<4;i++) |
| 2231 | { |
| 2232 | if(vga.sequencer.map_mask & 1 << i) |
| 2233 | vga.memory[offset*4+i+(svga.bank_w*0x10000)] = data; |
| 2234 | } |
| 2235 | } |
| 2236 | return; |
| 2237 | } |
| 2238 | |
| 2066 | 2239 | vga_mem_w(space,offset,data); |
| 2067 | 2240 | } |
| 2068 | | |
src/mess/video/isa_svga_s3.c
| r14383 | r14384 | |
| 75 | 75 | |
| 76 | 76 | m_isa->install_rom(this, 0xc0000, 0xc7fff, 0, 0, "svga", "s3_764"); |
| 77 | 77 | |
| 78 | | m_isa->install_device(0x3b0, 0x3bf, 0, 0, FUNC(vga_port_03b0_r), FUNC(vga_port_03b0_w)); |
| 79 | | m_isa->install_device(0x3c0, 0x3cf, 0, 0, FUNC(s3_port_03c0_r), FUNC(s3_port_03c0_w)); |
| 80 | | m_isa->install_device(0x3d0, 0x3df, 0, 0, FUNC(s3_port_03d0_r), FUNC(s3_port_03d0_w)); |
| 78 | m_isa->install_device(0x03b0, 0x03bf, 0, 0, FUNC(vga_port_03b0_r), FUNC(vga_port_03b0_w)); |
| 79 | m_isa->install_device(0x03c0, 0x03cf, 0, 0, FUNC(s3_port_03c0_r), FUNC(s3_port_03c0_w)); |
| 80 | m_isa->install_device(0x03d0, 0x03df, 0, 0, FUNC(s3_port_03d0_r), FUNC(s3_port_03d0_w)); |
| 81 | m_isa->install_device(0x9ae8, 0x9aeb, 0, 0, FUNC(s3_port_9ae8_r), FUNC(s3_port_9ae8_w)); |
| 81 | 82 | |
| 82 | 83 | m_isa->install_memory(0xa0000, 0xbffff, 0, 0, FUNC(s3_mem_r), FUNC(s3_mem_w)); |
| 83 | 84 | } |