trunk/src/emu/bus/isa/trident.c
| r32123 | r32124 | |
| 8 | 8 | |
| 9 | 9 | #include "emu.h" |
| 10 | 10 | #include "trident.h" |
| 11 | #include "debugger.h" |
| 11 | 12 | |
| 12 | 13 | const device_type TRIDENT_VGA = &device_creator<trident_vga_device>; |
| 13 | 14 | |
| r32123 | r32124 | |
| 20 | 21 | |
| 21 | 22 | void trident_vga_device::device_start() |
| 22 | 23 | { |
| 23 | | svga_device::device_start(); |
| 24 | memset(&vga, 0, sizeof(vga)); |
| 25 | memset(&svga, 0, sizeof(svga)); |
| 26 | |
| 27 | int i; |
| 28 | for (i = 0; i < 0x100; i++) |
| 29 | m_palette->set_pen_color(i, 0, 0, 0); |
| 30 | |
| 31 | // Avoid an infinite loop when displaying. 0 is not possible anyway. |
| 32 | vga.crtc.maximum_scan_line = 1; |
| 33 | |
| 34 | |
| 35 | // copy over interfaces |
| 36 | vga.read_dipswitch = read8_delegate(); //read_dipswitch; |
| 37 | vga.svga_intf.vram_size = 0x200000; |
| 38 | |
| 39 | vga.memory.resize_and_clear(vga.svga_intf.vram_size); |
| 40 | save_item(NAME(vga.memory)); |
| 41 | save_pointer(vga.crtc.data,"CRTC Registers",0x100); |
| 42 | save_pointer(vga.sequencer.data,"Sequencer Registers",0x100); |
| 43 | save_pointer(vga.attribute.data,"Attribute Registers", 0x15); |
| 44 | |
| 45 | m_vblank_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(vga_device::vblank_timer_cb),this)); |
| 24 | 46 | vga.svga_intf.seq_regcount = 0x0f; |
| 25 | 47 | vga.svga_intf.crtc_regcount = 0x50; |
| 26 | 48 | memset(&tri, 0, sizeof(tri)); |
| r32123 | r32124 | |
| 30 | 52 | { |
| 31 | 53 | svga_device::device_reset(); |
| 32 | 54 | svga.id = 0xd3; // identifies at TGUI9660XGi |
| 33 | | tri.revision = 0x01; // revision identifies as TGUI9680 |
| 55 | tri.revision = 0x05; // revision identifies as TGUI9680 |
| 34 | 56 | tri.new_mode = false; // start up in old mode |
| 35 | 57 | tri.dac_active = false; |
| 58 | tri.linear_active = false; |
| 59 | tri.mmio_active = false; |
| 36 | 60 | } |
| 37 | 61 | |
| 38 | 62 | UINT16 trident_vga_device::offset() |
| r32123 | r32124 | |
| 111 | 135 | case 0x0b: |
| 112 | 136 | res = svga.id; |
| 113 | 137 | tri.new_mode = true; |
| 138 | //debugger_break(machine()); |
| 114 | 139 | break; |
| 115 | 140 | case 0x0c: // Power Up Mode register 1 |
| 116 | 141 | res = tri.sr0c & 0xef; |
| r32123 | r32124 | |
| 134 | 159 | break; |
| 135 | 160 | } |
| 136 | 161 | } |
| 137 | | |
| 162 | logerror("Trident SR%02X: read %02x\n",index,res); |
| 138 | 163 | return res; |
| 139 | 164 | } |
| 140 | 165 | |
| r32123 | r32124 | |
| 176 | 201 | if(tri.new_mode) |
| 177 | 202 | { |
| 178 | 203 | tri.sr0e_new = data ^ 0x02; |
| 179 | | svga.bank_w = (data & 0x0f) ^ 0x02; // bit 1 is inverted, used for card detection, it is not XORed on reading |
| 204 | svga.bank_w = (data & 0x1f) ^ 0x02; // bit 1 is inverted, used for card detection, it is not XORed on reading |
| 180 | 205 | if(!(tri.gc0f & 0x01)) |
| 181 | | svga.bank_r = (data & 0x0f) ^ 0x02; |
| 206 | svga.bank_r = (data & 0x1f) ^ 0x02; |
| 182 | 207 | // TODO: handle planar modes, where bits 0 and 2 only are used |
| 183 | 208 | } |
| 184 | 209 | else |
| 185 | 210 | { |
| 186 | 211 | tri.sr0e_old = data; |
| 187 | | svga.bank_w = data & 0x06; |
| 212 | svga.bank_w = data & 0x0e; |
| 188 | 213 | if(!(tri.gc0f & 0x01)) |
| 189 | | svga.bank_r = data & 0x06; |
| 214 | svga.bank_r = data & 0x0e; |
| 190 | 215 | } |
| 191 | 216 | break; |
| 192 | 217 | case 0x0f: // Power Up Mode 2 |
| r32123 | r32124 | |
| 206 | 231 | { |
| 207 | 232 | switch(index) |
| 208 | 233 | { |
| 234 | case 0x1e: |
| 235 | res = tri.cr1e; |
| 236 | break; |
| 209 | 237 | case 0x1f: |
| 210 | 238 | res = tri.cr1f; |
| 211 | 239 | break; |
| 240 | case 0x21: |
| 241 | res = tri.cr21; |
| 242 | break; |
| 243 | case 0x27: |
| 244 | res = (vga.crtc.start_addr & 0x60000) >> 17; |
| 245 | break; |
| 246 | case 0x29: |
| 247 | res = tri.cr29; |
| 248 | break; |
| 212 | 249 | case 0x38: |
| 213 | 250 | res = tri.pixel_depth; |
| 214 | 251 | break; |
| 252 | case 0x39: |
| 253 | res = tri.cr39; |
| 254 | break; |
| 255 | case 0x50: |
| 256 | res = tri.cr50; |
| 257 | break; |
| 215 | 258 | default: |
| 216 | 259 | res = vga.crtc.data[index]; |
| 217 | 260 | break; |
| 218 | 261 | } |
| 219 | 262 | } |
| 263 | logerror("Trident CR%02X: read %02x\n",index,res); |
| 220 | 264 | return res; |
| 221 | 265 | } |
| 222 | 266 | void trident_vga_device::trident_crtc_reg_write(UINT8 index, UINT8 data) |
| r32123 | r32124 | |
| 231 | 275 | logerror("Trident CR%02X: write %02x\n",index,data); |
| 232 | 276 | switch(index) |
| 233 | 277 | { |
| 278 | case 0x1e: // Module Testing Register |
| 279 | tri.cr1e = data; |
| 280 | vga.crtc.start_addr = (vga.crtc.start_addr & 0xfffeffff) | ((data & 0x20)<<11); |
| 281 | break; |
| 234 | 282 | case 0x1f: |
| 235 | 283 | tri.cr1f = data; // "Software Programming Register" written to by software (BIOS?) |
| 236 | 284 | break; |
| 285 | case 0x21: // Linear aperture |
| 286 | tri.cr21 = data; |
| 287 | tri.linear_address = ((data & 0xc0)<<18) | ((data & 0x0f)<<20); |
| 288 | tri.linear_active = data & 0x20; |
| 289 | if(tri.linear_active) |
| 290 | popmessage("Trident: Linear Aperture active - %08x, %s",tri.linear_address,(tri.cr21 & 0x10) ? "2MB" : "1MB" ); |
| 291 | break; |
| 292 | case 0x27: |
| 293 | vga.crtc.start_addr = (vga.crtc.start_addr & 0xfff9ffff) | ((data & 0x03)<<17); |
| 294 | break; |
| 295 | case 0x29: |
| 296 | tri.cr29 = data; |
| 297 | vga.crtc.offset = (vga.crtc.offset & 0xfeff) | ((data & 0x10)<<4); |
| 298 | break; |
| 237 | 299 | case 0x38: |
| 238 | 300 | tri.pixel_depth = data; |
| 239 | 301 | trident_define_video_mode(); |
| 240 | 302 | break; |
| 303 | case 0x39: |
| 304 | tri.cr39 = data; |
| 305 | tri.mmio_active = data & 0x01; |
| 306 | if(tri.mmio_active) |
| 307 | popmessage("Trident: MMIO activated"); |
| 308 | break; |
| 309 | case 0x50: |
| 310 | tri.cr50 = data; |
| 311 | break; |
| 241 | 312 | default: |
| 242 | | logerror("Trident: 3D4 index %02x write %02x\n",index,data); |
| 313 | //logerror("Trident: 3D4 index %02x write %02x\n",index,data); |
| 243 | 314 | break; |
| 244 | 315 | } |
| 245 | 316 | } |
| r32123 | r32124 | |
| 261 | 332 | case 0x0f: |
| 262 | 333 | res = tri.gc0f; |
| 263 | 334 | break; |
| 335 | case 0x2f: |
| 336 | res = tri.gc2f; |
| 337 | break; |
| 264 | 338 | default: |
| 265 | 339 | res = 0xff; |
| 266 | 340 | break; |
| 267 | 341 | } |
| 268 | 342 | } |
| 343 | logerror("Trident GC%02X: read %02x\n",index,res); |
| 269 | 344 | return res; |
| 270 | 345 | } |
| 271 | 346 | |
| r32123 | r32124 | |
| 289 | 364 | case 0x0f: |
| 290 | 365 | tri.gc0f = data; |
| 291 | 366 | break; |
| 367 | case 0x2f: // XFree86 refers to this register as "MiscIntContReg", setting bit 2, but gives no indication as to what it does |
| 368 | tri.gc2f = data; |
| 369 | break; |
| 292 | 370 | default: |
| 293 | | logerror("Trident: Unimplemented GC register %02x write %02x\n",index,data); |
| 371 | //logerror("Trident: Unimplemented GC register %02x write %02x\n",index,data); |
| 294 | 372 | break; |
| 295 | 373 | } |
| 296 | 374 | } |
| r32123 | r32124 | |
| 434 | 512 | } |
| 435 | 513 | } |
| 436 | 514 | |
| 515 | READ8_MEMBER(trident_vga_device::port_83c6_r) |
| 516 | { |
| 517 | UINT8 res = 0xff; |
| 518 | switch(offset) |
| 519 | { |
| 520 | case 2: |
| 521 | res = port_03c0_r(space,5,mem_mask); |
| 522 | logerror("Trident: 83c6 read %02x\n",res); |
| 523 | break; |
| 524 | case 4: |
| 525 | res = vga.sequencer.index; |
| 526 | logerror("Trident: 83c8 seq read %02x\n",res); |
| 527 | break; |
| 528 | } |
| 529 | return res; |
| 530 | } |
| 531 | |
| 532 | WRITE8_MEMBER(trident_vga_device::port_83c6_w) |
| 533 | { |
| 534 | switch(offset) |
| 535 | { |
| 536 | case 2: |
| 537 | logerror("Trident: 83c6 seq write %02x\n",data); |
| 538 | port_03c0_w(space,5,data,mem_mask); |
| 539 | break; |
| 540 | case 4: |
| 541 | logerror("Trident: 83c8 seq index write %02x\n",data); |
| 542 | vga.sequencer.index = data; |
| 543 | break; |
| 544 | } |
| 545 | } |
| 546 | |
| 437 | 547 | READ8_MEMBER(trident_vga_device::mem_r ) |
| 438 | 548 | { |
| 439 | 549 | if (svga.rgb8_en || svga.rgb15_en || svga.rgb16_en || svga.rgb32_en) |
trunk/src/emu/bus/isa/svga_trident.c
| r32123 | r32124 | |
| 81 | 81 | m_isa->install_device(0x3b0, 0x3bf, 0, 0, read8_delegate(FUNC(trident_vga_device::port_03b0_r),m_vga), write8_delegate(FUNC(trident_vga_device::port_03b0_w),m_vga)); |
| 82 | 82 | m_isa->install_device(0x3c0, 0x3cf, 0, 0, read8_delegate(FUNC(trident_vga_device::port_03c0_r),m_vga), write8_delegate(FUNC(trident_vga_device::port_03c0_w),m_vga)); |
| 83 | 83 | m_isa->install_device(0x3d0, 0x3df, 0, 0, read8_delegate(FUNC(trident_vga_device::port_03d0_r),m_vga), write8_delegate(FUNC(trident_vga_device::port_03d0_w),m_vga)); |
| 84 | m_isa->install_device(0x83c4, 0x83cb, 0, 0, read8_delegate(FUNC(trident_vga_device::port_83c6_r),m_vga), write8_delegate(FUNC(trident_vga_device::port_83c6_w),m_vga)); |
| 84 | 85 | |
| 85 | 86 | m_isa->install_memory(0xa0000, 0xbffff, 0, 0, read8_delegate(FUNC(trident_vga_device::mem_r),m_vga), write8_delegate(FUNC(trident_vga_device::mem_w),m_vga)); |
| 86 | 87 | } |