voicestopreaddata.c 1.38 KB
/*---------------------------------------------------------------------
 	Copyright (C) 1997,1998 Nintendo.
 	
 	File		voicestopreaddata.c
 	Coded    by	Koji Mitsunari.	Oct  8, 1997.
 	Modified by	Koji Mitsunari.	Jun 11, 1999.
 	Comments	Voice Recognition Board
   
 	$Id: voicestopreaddata.c,v 1.2 2003/03/25 20:42:04 blythe Exp $
   ---------------------------------------------------------------------*/
#include "osint.h"
#include "controller.h"
#include "siint.h"

s32
osVoiceStopReadData(OSVoiceHandle *hd) {
#ifdef BBPLAYER
    return CONT_ERR_DEVICE;
#else
  s32		ret, i;
  u8		stat;
  u8		temp[4];

  ret = __osVoiceGetStatus(hd->__mq, hd->__channel, &stat);
  if( ret != 0 ) {
    return(ret);
  } else if (stat & VOICE_WRITE_READY) {
    return(CONT_ERR_VOICE_NO_RESPONSE);
  }

  if (hd->__mode == 0) {	/* ưƤʤ */
    return(CONT_ERR_INVALID);
  }

  ((u32 *)temp)[0] = 0x00000700;
  ret = __osVoiceContWrite4(hd->__mq, hd->__channel, VOICE_RW_ADDR, temp);
  if (ret == 0 ) {
    i = 0;
    do {
      ret = __osVoiceCheckResult(hd, &stat);
      if (ret & 0xff00) {
	if (((ret & 7) == 0 ) || ((ret & 7) == 7 )) {
	  ret = 0;
	  hd->__mode = 0;
	} else {
	  ret = CONT_ERR_INVALID;
	}
      } else {
	hd->__mode = 0;
      }
      i ++;
    } while ( (ret == CONT_ERR_VOICE_NO_RESPONSE) && (i < 20));
  }
  if ( i >= 20 ) {
    ret == CONT_ERR_VOICE_NO_RESPONSE;
  }

  return(ret);
#endif
}