PCem
changeset 152:f6069ee5e9d7
Fixed terminal count on auto-init DMA. Fixed sound on All New World of Lemmings when using GUS.
| author | TomW |
|---|---|
| date | Sun Aug 24 14:08:17 2014 +0100 |
| parents | 55564c65aa15 |
| children | ad7d877a3b53 |
| files | src/dma.c src/sound_gus.c |
| diffstat | 2 files changed, 16 insertions(+), 5 deletions(-) [+] |
line diff
1.1 --- a/src/dma.c Sat Aug 23 21:32:36 2014 +0100 1.2 +++ b/src/dma.c Sun Aug 24 14:08:17 2014 +0100 1.3 @@ -251,7 +251,8 @@ 1.4 int dma_channel_read(int channel) 1.5 { 1.6 uint16_t temp; 1.7 - 1.8 + int tc = 0; 1.9 + 1.10 if (dma.command & 0x04) 1.11 return DMA_NODATA; 1.12 1.13 @@ -272,6 +273,7 @@ 1.14 dma.cc[channel]--; 1.15 if (dma.cc[channel] < 0) 1.16 { 1.17 + tc = 1; 1.18 if (dma.mode[channel] & 0x10) /*Auto-init*/ 1.19 { 1.20 dma.cc[channel] = dma.cb[channel]; 1.21 @@ -282,7 +284,7 @@ 1.22 dma.stat |= (1 << channel); 1.23 } 1.24 1.25 - if (dma.m & (1 << channel)) 1.26 + if (tc) 1.27 return temp | DMA_OVER; 1.28 return temp; 1.29 } 1.30 @@ -302,6 +304,7 @@ 1.31 dma16.cc[channel]--; 1.32 if (dma16.cc[channel] < 0) 1.33 { 1.34 + tc = 1; 1.35 if (dma16.mode[channel] & 0x10) /*Auto-init*/ 1.36 { 1.37 dma16.cc[channel] = dma16.cb[channel]; 1.38 @@ -312,7 +315,7 @@ 1.39 dma16.stat |= (1 << channel); 1.40 } 1.41 1.42 - if (dma.m & (1 << channel)) 1.43 + if (tc) 1.44 return temp | DMA_OVER; 1.45 return temp; 1.46 }
2.1 --- a/src/sound_gus.c Sat Aug 23 21:32:36 2014 +0100 2.2 +++ b/src/sound_gus.c Sun Aug 24 14:08:17 2014 +0100 2.3 @@ -374,12 +374,17 @@ 2.4 c=0; 2.5 while (c<65536) 2.6 { 2.7 + int dma_result; 2.8 d = gus->ram[gus->dmaaddr]; 2.9 if (val & 0x80) d ^= 0x80; 2.10 - if (dma_channel_write(gus->dma, d) == DMA_NODATA) break; 2.11 + dma_result = dma_channel_write(gus->dma, d); 2.12 + if (dma_result == DMA_NODATA) 2.13 + break; 2.14 gus->dmaaddr++; 2.15 gus->dmaaddr&=0xFFFFF; 2.16 c++; 2.17 + if (dma_result & DMA_OVER) 2.18 + break; 2.19 } 2.20 // printf("GUS->MEM Transferred %i bytes\n",c); 2.21 gus->dmactrl=val&~0x40; 2.22 @@ -391,12 +396,15 @@ 2.23 while (c<65536) 2.24 { 2.25 d = dma_channel_read(gus->dma); 2.26 - if (d == DMA_NODATA) break; 2.27 + if (d == DMA_NODATA) 2.28 + break; 2.29 if (val&0x80) d^=0x80; 2.30 gus->ram[gus->dmaaddr]=d; 2.31 gus->dmaaddr++; 2.32 gus->dmaaddr&=0xFFFFF; 2.33 c++; 2.34 + if (d & DMA_OVER) 2.35 + break; 2.36 } 2.37 // printf("MEM->GUS Transferred %i bytes\n",c); 2.38 gus->dmactrl=val&~0x40;
