| version 1.1.1.1, 2003/10/16 17:58:07 | version 1.6, 2005/02/07 14:46:12 | 
| Line 10  static const UINT adpcmdeltatable[8] = { | Line 10  static const UINT adpcmdeltatable[8] = { | 
 | 228,    228,    228,    228,    308,    408,    512,    612}; | 228,    228,    228,    228,    308,    408,    512,    612}; | 
 |  |  | 
 |  |  | 
| BYTE SOUNDCALL adpcm_readsample(ADPCM ad) { | REG8 SOUNDCALL adpcm_readsample(ADPCM ad) { | 
 |  |  | 
 | UINT32  pos; | UINT32  pos; | 
| BYTE    data; | REG8    data; | 
| BYTE    ret; | REG8    ret; | 
 |  |  | 
 | if ((ad->reg.ctrl1 & 0x60) == 0x20) { | if ((ad->reg.ctrl1 & 0x60) == 0x20) { | 
 | pos = ad->pos & 0x1fffff; | pos = ad->pos & 0x1fffff; | 
| Line 23  BYTE SOUNDCALL adpcm_readsample(ADPCM ad | Line 23  BYTE SOUNDCALL adpcm_readsample(ADPCM ad | 
 | pos += 8; | pos += 8; | 
 | } | } | 
 | else { | else { | 
| const BYTE *ptr; | const UINT8 *ptr; | 
| BYTE bit; | REG8 bit; | 
 | UINT tmp; | UINT tmp; | 
 | ptr = ad->buf + ((pos >> 3) & 0x7fff); | ptr = ad->buf + ((pos >> 3) & 0x7fff); | 
 | bit = 1 << (pos & 7); | bit = 1 << (pos & 7); | 
| Line 36  BYTE SOUNDCALL adpcm_readsample(ADPCM ad | Line 36  BYTE SOUNDCALL adpcm_readsample(ADPCM ad | 
 | tmp += (ptr[0x28000] & bit) << 5; | tmp += (ptr[0x28000] & bit) << 5; | 
 | tmp += (ptr[0x30000] & bit) << 6; | tmp += (ptr[0x30000] & bit) << 6; | 
 | tmp += (ptr[0x38000] & bit) << 7; | tmp += (ptr[0x38000] & bit) << 7; | 
| data = (BYTE)(tmp >> (pos & 7)); | data = (REG8)(tmp >> (pos & 7)); | 
 | pos++; | pos++; | 
 | } | } | 
 | if (pos != ad->stop) { | if (pos != ad->stop) { | 
| Line 58  BYTE SOUNDCALL adpcm_readsample(ADPCM ad | Line 58  BYTE SOUNDCALL adpcm_readsample(ADPCM ad | 
 | return(ret); | return(ret); | 
 | } | } | 
 |  |  | 
| void SOUNDCALL adpcm_datawrite(ADPCM ad, BYTE data) { | void SOUNDCALL adpcm_datawrite(ADPCM ad, REG8 data) { | 
 |  |  | 
 | UINT32  pos; | UINT32  pos; | 
 |  |  | 
| Line 68  void SOUNDCALL adpcm_datawrite(ADPCM ad, | Line 68  void SOUNDCALL adpcm_datawrite(ADPCM ad, | 
 | pos += 8; | pos += 8; | 
 | } | } | 
 | else { | else { | 
| BYTE *ptr; | UINT8 *ptr; | 
| BYTE bit; | UINT8 bit; | 
| BYTE mask; | UINT8 mask; | 
 | ptr = ad->buf + ((pos >> 3) & 0x7fff); | ptr = ad->buf + ((pos >> 3) & 0x7fff); | 
 | bit = 1 << (pos & 7); | bit = 1 << (pos & 7); | 
 | mask = ~bit; | mask = ~bit; | 
| Line 98  void SOUNDCALL adpcm_datawrite(ADPCM ad, | Line 98  void SOUNDCALL adpcm_datawrite(ADPCM ad, | 
 | if (data & 0x20) { | if (data & 0x20) { | 
 | ptr[0x28000] |= bit; | ptr[0x28000] |= bit; | 
 | } | } | 
| ptr[0x300000] &= mask; | ptr[0x30000] &= mask; | 
 | if (data & 0x40) { | if (data & 0x40) { | 
 | ptr[0x30000] |= bit; | ptr[0x30000] |= bit; | 
 | } | } | 
| Line 108  void SOUNDCALL adpcm_datawrite(ADPCM ad, | Line 108  void SOUNDCALL adpcm_datawrite(ADPCM ad, | 
 | } | } | 
 | pos++; | pos++; | 
 | } | } | 
| if (pos != ad->stop) { | if (pos == ad->stop) { | 
 | pos &= 0x1fffff; | pos &= 0x1fffff; | 
 | ad->status |= 4; | ad->status |= 4; | 
 | } | } | 
| Line 129  static void SOUNDCALL getadpcmdata(ADPCM | Line 129  static void SOUNDCALL getadpcmdata(ADPCM | 
 | pos = ad->pos; | pos = ad->pos; | 
 | if (!(ad->reg.ctrl2 & 2)) { | if (!(ad->reg.ctrl2 & 2)) { | 
 | data = ad->buf[(pos >> 3) & 0x3ffff]; | data = ad->buf[(pos >> 3) & 0x3ffff]; | 
 | pos += ADPCM_NBR + 4; |  | 
 | if (!(pos & ADPCM_NBR)) { | if (!(pos & ADPCM_NBR)) { | 
 | data >>= 4; | data >>= 4; | 
 | } | } | 
 |  | pos += ADPCM_NBR + 4; | 
 | } | } | 
 | else { | else { | 
| const BYTE *ptr; | const UINT8 *ptr; | 
| BYTE bit; | REG8 bit; | 
 | UINT tmp; | UINT tmp; | 
 | ptr = ad->buf + ((pos >> 3) & 0x7fff); | ptr = ad->buf + ((pos >> 3) & 0x7fff); | 
 | bit = 1 << (pos & 7); | bit = 1 << (pos & 7); | 
| Line 160  static void SOUNDCALL getadpcmdata(ADPCM | Line 160  static void SOUNDCALL getadpcmdata(ADPCM | 
 | dir = data & 8; | dir = data & 8; | 
 | data &= 7; | data &= 7; | 
 | dlt = adpcmdeltatable[data] * ad->delta; | dlt = adpcmdeltatable[data] * ad->delta; | 
 | dlt -= 12; |  | 
 | dlt >>= 8; | dlt >>= 8; | 
| if (dlt < 126) { | if (dlt < 127) { | 
| dlt = 126; | dlt = 127; | 
 | } | } | 
 | else if (dlt > 24000) { | else if (dlt > 24000) { | 
 | dlt = 24000; | dlt = 24000; | 
| Line 191  static void SOUNDCALL getadpcmdata(ADPCM | Line 190  static void SOUNDCALL getadpcmdata(ADPCM | 
 | if (ad->reg.ctrl1 & 0x10) { | if (ad->reg.ctrl1 & 0x10) { | 
 | pos = ad->start; | pos = ad->start; | 
 | ad->samp = 0; | ad->samp = 0; | 
| ad->delta = 128; | ad->delta = 127; | 
 | } | } | 
 | else { | else { | 
 | pos &= 0x1fffff; | pos &= 0x1fffff; |