src/mess/drivers/supracan.c
| r6959 | r6960 | |
| 309 | 309 | |
| 310 | 310 | typedef struct |
| 311 | 311 | { |
| 312 | | UINT32 source; |
| 313 | | UINT32 dest; |
| 314 | | UINT16 count; |
| 315 | | UINT16 control; |
| 312 | UINT32 source[2]; |
| 313 | UINT32 dest[2]; |
| 314 | UINT16 count[2]; |
| 315 | UINT16 control[2]; |
| 316 | 316 | } _acan_dma_regs_t; |
| 317 | 317 | |
| 318 | | static _acan_dma_regs_t acan_dma_regs; |
| 319 | | |
| 320 | 318 | typedef struct |
| 321 | 319 | { |
| 322 | 320 | UINT32 src; |
| r6959 | r6960 | |
| 325 | 323 | UINT16 control; |
| 326 | 324 | } _acan_sprdma_regs_t; |
| 327 | 325 | |
| 326 | static _acan_dma_regs_t acan_dma_regs; |
| 328 | 327 | static _acan_sprdma_regs_t acan_sprdma_regs; |
| 329 | 328 | |
| 330 | 329 | |
| 331 | 330 | static WRITE16_HANDLER( supracan_dma_w ) |
| 332 | 331 | { |
| 333 | 332 | int i; |
| 333 | int ch; |
| 334 | 334 | |
| 335 | ch = (offset < 0x10/2) ? 0 : 1; |
| 336 | |
| 335 | 337 | switch(offset) |
| 336 | 338 | { |
| 337 | 339 | case 0x00/2: // Source address MSW |
| 338 | | acan_dma_regs.source &= 0x0000ffff; |
| 339 | | acan_dma_regs.source |= data << 16; |
| 340 | case 0x10/2: |
| 341 | acan_dma_regs.source[ch] &= 0x0000ffff; |
| 342 | acan_dma_regs.source[ch] |= data << 16; |
| 340 | 343 | break; |
| 341 | 344 | case 0x02/2: // Source address LSW |
| 342 | | acan_dma_regs.source &= 0xffff0000; |
| 343 | | acan_dma_regs.source |= data; |
| 345 | case 0x12/2: |
| 346 | acan_dma_regs.source[ch] &= 0xffff0000; |
| 347 | acan_dma_regs.source[ch] |= data; |
| 344 | 348 | break; |
| 345 | 349 | case 0x04/2: // Destination address MSW |
| 346 | | acan_dma_regs.dest &= 0x0000ffff; |
| 347 | | acan_dma_regs.dest |= data << 16; |
| 350 | case 0x14/2: |
| 351 | acan_dma_regs.dest[ch] &= 0x0000ffff; |
| 352 | acan_dma_regs.dest[ch] |= data << 16; |
| 348 | 353 | break; |
| 349 | 354 | case 0x06/2: // Destination address LSW |
| 350 | | acan_dma_regs.dest &= 0xffff0000; |
| 351 | | acan_dma_regs.dest |= data; |
| 355 | case 0x16/2: |
| 356 | acan_dma_regs.dest[ch] &= 0xffff0000; |
| 357 | acan_dma_regs.dest[ch] |= data; |
| 352 | 358 | break; |
| 353 | 359 | case 0x08/2: // Byte count |
| 354 | | acan_dma_regs.count = data; |
| 360 | case 0x18/2: |
| 361 | acan_dma_regs.count[ch] = data; |
| 355 | 362 | break; |
| 356 | 363 | case 0x0a/2: // Control |
| 364 | case 0x1a/2: |
| 357 | 365 | //if(acan_dma_regs.dest != 0xf00200) |
| 358 | | printf("%08x %08x %02x %04x\n",acan_dma_regs.source,acan_dma_regs.dest,acan_dma_regs.count + 1,data); |
| 366 | printf("%08x %08x %02x %04x\n",acan_dma_regs.source[ch],acan_dma_regs.dest[ch],acan_dma_regs.count[ch] + 1,data); |
| 359 | 367 | if(data & 0x8800) |
| 360 | 368 | { |
| 361 | 369 | //if(data != 0x9800 && data != 0x8800) |
| r6959 | r6960 | |
| 364 | 372 | //} |
| 365 | 373 | // if(data & 0x2000) |
| 366 | 374 | // acan_dma_regs.source-=2; |
| 367 | | verboselog(space->machine, 0, "supracan_dma_w: Kicking off a DMA from %08x to %08x, %d bytes (%04x)\n", acan_dma_regs.source, acan_dma_regs.dest, acan_dma_regs.count + 1, data); |
| 368 | | for(i = 0; i <= acan_dma_regs.count; i++) |
| 375 | verboselog(space->machine, 0, "supracan_dma_w: Kicking off a DMA from %08x to %08x, %d bytes (%04x)\n", acan_dma_regs.source[ch], acan_dma_regs.dest[ch], acan_dma_regs.count[ch] + 1, data); |
| 376 | for(i = 0; i <= acan_dma_regs.count[ch]; i++) |
| 369 | 377 | { |
| 370 | 378 | if(data & 0x1000) |
| 371 | 379 | { |
| 372 | | memory_write_word(space, acan_dma_regs.dest, memory_read_word(space, acan_dma_regs.source)); |
| 373 | | acan_dma_regs.dest+=2; |
| 374 | | acan_dma_regs.source+=2; |
| 380 | memory_write_word(space, acan_dma_regs.dest[ch], memory_read_word(space, acan_dma_regs.source[ch])); |
| 381 | acan_dma_regs.dest[ch]+=2; |
| 382 | acan_dma_regs.source[ch]+=2; |
| 375 | 383 | } |
| 376 | 384 | else |
| 377 | 385 | { |
| 378 | | memory_write_byte(space, acan_dma_regs.dest, memory_read_byte(space, acan_dma_regs.source)); |
| 379 | | acan_dma_regs.dest++; |
| 380 | | acan_dma_regs.source++; |
| 386 | memory_write_byte(space, acan_dma_regs.dest[ch], memory_read_byte(space, acan_dma_regs.source[ch])); |
| 387 | acan_dma_regs.dest[ch]++; |
| 388 | acan_dma_regs.source[ch]++; |
| 381 | 389 | } |
| 382 | 390 | } |
| 383 | 391 | } |
| 384 | 392 | else |
| 385 | 393 | { |
| 386 | | verboselog(space->machine, 0, "supracan_dma_w: Unknown DMA kickoff value of %04x (other regs %08x, %08x, %d)\n", data, acan_dma_regs.source, acan_dma_regs.dest, acan_dma_regs.count + 1); |
| 387 | | fatalerror("supracan_dma_w: Unknown DMA kickoff value of %04x (other regs %08x, %08x, %d)",data, acan_dma_regs.source, acan_dma_regs.dest, acan_dma_regs.count + 1); |
| 394 | verboselog(space->machine, 0, "supracan_dma_w: Unknown DMA kickoff value of %04x (other regs %08x, %08x, %d)\n", data, acan_dma_regs.source[ch], acan_dma_regs.dest[ch], acan_dma_regs.count[ch] + 1); |
| 395 | fatalerror("supracan_dma_w: Unknown DMA kickoff value of %04x (other regs %08x, %08x, %d)",data, acan_dma_regs.source[ch], acan_dma_regs.dest[ch], acan_dma_regs.count[ch] + 1); |
| 388 | 396 | } |
| 389 | 397 | break; |
| 390 | 398 | } |
| r6959 | r6960 | |
| 400 | 408 | AM_RANGE( 0xe80300, 0xe80301 ) AM_READ( supracan_unk1_r ) |
| 401 | 409 | AM_RANGE( 0xe81000, 0xe8ffff ) AM_RAM_WRITE( supracan_soundram_w ) AM_BASE( &supracan_soundram_16 ) |
| 402 | 410 | AM_RANGE( 0xe90000, 0xe9001f ) AM_WRITE( supracan_sound_w ) |
| 403 | | AM_RANGE( 0xe90020, 0xe9002b ) AM_WRITE( supracan_dma_w ) |
| 404 | | // AM_RANGE( 0xe90030, 0xe9003b ) AM_WRITE( supracan_dma_w ) //FIXME: scatter gather list? |
| 411 | AM_RANGE( 0xe90020, 0xe9003f ) AM_WRITE( supracan_dma_w ) |
| 405 | 412 | AM_RANGE( 0xf00000, 0xf001ff ) AM_READWRITE( supracan_video_r, supracan_video_w ) |
| 406 | 413 | AM_RANGE( 0xf00200, 0xf003ff ) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) |
| 407 | 414 | AM_RANGE( 0xf40000, 0xf5ffff ) AM_RAM_WRITE(supracan_char_w) AM_BASE(&supracan_vram) /* Unknown, some data gets copied here during boot */ |