src/emu/machine/z80dma.c
| r5833 | r5834 | |
| 83 | 83 | #define PORTB_IS_SOURCE(_c) (!PORTA_IS_SOURCE(_c)) |
| 84 | 84 | #define TRANSFER_MODE(_c) (WR0(_c) & 0x03) |
| 85 | 85 | |
| 86 | #define MATCH_F_SET(_c) (_c->status &= ~0x10) |
| 87 | #define MATCH_F_CLEAR(_c) (_c->status |= 0x10) |
| 88 | #define EOB_F_SET(_c) (_c->status &= ~0x20) |
| 89 | #define EOB_F_CLEAR(_c) (_c->status |= 0x20) |
| 90 | |
| 86 | 91 | #define TM_TRANSFER (0x01) |
| 87 | 92 | #define TM_SEARCH (0x02) |
| 88 | 93 | #define TM_SEARCH_TRANSFER (0x03) |
| r5833 | r5834 | |
| 138 | 143 | mode = TRANSFER_MODE(cntx); |
| 139 | 144 | switch(mode) { |
| 140 | 145 | case TM_TRANSFER: |
| 146 | case TM_SEARCH: |
| 141 | 147 | if (PORTA_IS_SOURCE(cntx)) |
| 142 | 148 | { |
| 143 | 149 | if (PORTA_MEMORY(cntx)) |
| r5833 | r5834 | |
| 157 | 163 | cntx->addressB += PORTB_FIXED(cntx) ? 0 : PORTB_INC(cntx) ? PORTB_STEP(cntx) : -PORTB_STEP(cntx); |
| 158 | 164 | } |
| 159 | 165 | break; |
| 160 | | case TM_SEARCH: |
| 161 | | fatalerror("z80dma_do_operation: unhandled search mode!\n"); |
| 162 | | break; |
| 163 | 166 | case TM_SEARCH_TRANSFER: |
| 164 | 167 | fatalerror("z80dma_do_operation: unhandled search & transfer mode !\n"); |
| 165 | 168 | break; |
| r5833 | r5834 | |
| 205 | 208 | break; |
| 206 | 209 | |
| 207 | 210 | case TM_SEARCH: |
| 208 | | fatalerror("z80dma_do_operation: unhandled search mode!\n"); |
| 211 | { |
| 212 | UINT8 load_byte,match_byte; |
| 213 | load_byte = cntx->latch | MASK_BYTE(cntx); |
| 214 | match_byte = MATCH_BYTE(cntx) | MASK_BYTE(cntx); |
| 215 | //LOG(("%02x %02x\n",load_byte,match_byte)); |
| 216 | if(load_byte == match_byte) |
| 217 | MATCH_F_SET(cntx); |
| 218 | |
| 219 | cntx->count--; |
| 220 | done = (cntx->count == 0xFFFF); //correct? |
| 221 | } |
| 209 | 222 | break; |
| 210 | 223 | |
| 211 | 224 | case TM_SEARCH_TRANSFER: |
| r5833 | r5834 | |
| 338 | 351 | else if ((data & 0x83) == 0x80) // WR3 |
| 339 | 352 | { |
| 340 | 353 | WR3(cntx) = data; |
| 354 | if (data & 0x08) |
| 341 | 355 | cntx->regs_follow[cntx->num_follow++] = GET_REGNUM(cntx, MASK_BYTE(cntx)); |
| 342 | 356 | if (data & 0x10) |
| 343 | 357 | cntx->regs_follow[cntx->num_follow++] = GET_REGNUM(cntx, MATCH_BYTE(cntx)); |
| r5833 | r5834 | |
| 398 | 412 | cntx->addressA = PORTA_ADDRESS(cntx); |
| 399 | 413 | cntx->addressB = PORTB_ADDRESS(cntx); |
| 400 | 414 | cntx->count = BLOCKLEN(cntx); |
| 401 | | cntx->status &= ~0x30; |
| 415 | cntx->status |= 0x30; |
| 402 | 416 | LOG(("Load A: %x B: %x N: %x\n", cntx->addressA, cntx->addressB, cntx->count)); |
| 403 | 417 | break; |
| 404 | 418 | case 0x83: /* Disable dma */ |
| r5833 | r5834 | |
| 420 | 434 | cntx->count = 0; |
| 421 | 435 | cntx->dma_enabled = 1; |
| 422 | 436 | //"match not found" & "end of block" status flags zeroed here |
| 423 | | cntx->status &= ~0x30; |
| 437 | cntx->status |= 0x30; |
| 424 | 438 | break; |
| 425 | 439 | case 0xc7: /* Reset Port A Timing */ |
| 426 | 440 | LOG(("Reset Port A Timing\n")); |
| r5833 | r5834 | |
| 444 | 458 | cntx->irq_en = 0; |
| 445 | 459 | break; |
| 446 | 460 | case 0x8B: /* Reinitialize status byte */ |
| 447 | | /* FIXME: docs says these two is 1, but behaviour makes me think it's a 0, investigate */ |
| 448 | 461 | LOG(("Reinitialize status byte\n")); |
| 449 | | cntx->status &= ~0x30; |
| 462 | cntx->status |= 0x30; |
| 450 | 463 | break; |
| 451 | 464 | case 0xFB: |
| 452 | 465 | LOG(("Z80DMA undocumented command triggered 0x%02X!\n",data)); |