Previous 15994 Revisions Next

r5834 Monday 21st September, 2009 at 17:06:26 UTC by Angelo Salese
[z80dma]: added preliminary search mode support and fixed a bug with WR3 mask byte writes
[src/emu/machine]z80dma.c

src/emu/machine/z80dma.c
r5833r5834
8383#define PORTB_IS_SOURCE(_c)   (!PORTA_IS_SOURCE(_c))
8484#define TRANSFER_MODE(_c)   (WR0(_c) & 0x03)
8585
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
8691#define TM_TRANSFER      (0x01)
8792#define TM_SEARCH      (0x02)
8893#define TM_SEARCH_TRANSFER   (0x03)
r5833r5834
138143   mode = TRANSFER_MODE(cntx);
139144   switch(mode) {
140145      case TM_TRANSFER:
146      case TM_SEARCH:
141147         if (PORTA_IS_SOURCE(cntx))
142148         {
143149            if (PORTA_MEMORY(cntx))
r5833r5834
157163            cntx->addressB += PORTB_FIXED(cntx) ? 0 : PORTB_INC(cntx) ? PORTB_STEP(cntx) : -PORTB_STEP(cntx);
158164         }
159165         break;
160      case TM_SEARCH:
161         fatalerror("z80dma_do_operation: unhandled search mode!\n");
162         break;
163166      case TM_SEARCH_TRANSFER:
164167         fatalerror("z80dma_do_operation: unhandled search & transfer mode !\n");
165168         break;
r5833r5834
205208         break;
206209
207210      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         }
209222         break;
210223
211224      case TM_SEARCH_TRANSFER:
r5833r5834
338351      else if ((data & 0x83) == 0x80) // WR3
339352      {
340353         WR3(cntx) = data;
354         if (data & 0x08)
341355            cntx->regs_follow[cntx->num_follow++] = GET_REGNUM(cntx, MASK_BYTE(cntx));
342356         if (data & 0x10)
343357            cntx->regs_follow[cntx->num_follow++] = GET_REGNUM(cntx, MATCH_BYTE(cntx));
r5833r5834
398412               cntx->addressA = PORTA_ADDRESS(cntx);
399413               cntx->addressB = PORTB_ADDRESS(cntx);
400414               cntx->count = BLOCKLEN(cntx);
401               cntx->status &= ~0x30;
415               cntx->status |= 0x30;
402416               LOG(("Load A: %x B: %x N: %x\n", cntx->addressA, cntx->addressB, cntx->count));
403417               break;
404418            case 0x83:   /* Disable dma */
r5833r5834
420434               cntx->count = 0;
421435               cntx->dma_enabled = 1;
422436               //"match not found" & "end of block" status flags zeroed here
423               cntx->status &= ~0x30;
437               cntx->status |= 0x30;
424438               break;
425439            case 0xc7:   /* Reset Port A Timing */
426440               LOG(("Reset Port A Timing\n"));
r5833r5834
444458               cntx->irq_en = 0;
445459               break;
446460            case 0x8B:   /* Reinitialize status byte */
447               /* FIXME: docs says these two is 1, but behaviour makes me think it's a 0, investigate */
448461               LOG(("Reinitialize status byte\n"));
449               cntx->status &= ~0x30;
462               cntx->status |= 0x30;
450463               break;
451464            case 0xFB:
452465               LOG(("Z80DMA undocumented command triggered 0x%02X!\n",data));

Previous 15994 Revisions Next


© 1998-2018 The MESS Team