voicestartreaddata.c 1.1 KB
/*---------------------------------------------------------------------
 	Copyright (C) 1997, Nintendo.
 	
 	File		voicestartreaddata.c
 	Coded    by	Koji Mitsunari.	Oct  8, 1997.
 	Modified by	Koji Mitsunari.	Jul  3, 1998.
 	Comments	Voice Recognition System
   
 	$Id: voicestartreaddata.c,v 1.1.1.1 2002/05/02 03:28:44 blythe Exp $
   ---------------------------------------------------------------------*/
#include "osint.h"
#include "controller.h"
#include "siint.h"

s32
osVoiceStartReadData(OSVoiceHandle *hd) {
  s32		ret;
  u8		stat;
  u8		temp[4];

  if( (ret = __osVoiceGetStatus(hd->__mq, hd->__channel, &stat)) != 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] = 0x05000000; /* Read command */
  ret = __osVoiceContWrite4(hd->__mq, hd->__channel, VOICE_RW_ADDR, temp);
  if (ret == 0 ) {
    ret = __osVoiceCheckResult(hd, &stat);
    if (ret & 0xff00) {
      ret = CONT_ERR_INVALID;
    } else {
      hd->__mode = 1;
    }
  }
  return(ret);
}