voicemaskdictionary.c 1.55 KB
/*---------------------------------------------------------------------
 	Copyright (C) 1998 Nintendo.
 	
 	File		voicemaskdictionary.c
 	Coded    by	Koji Mitsunari.	May 27, 1998.
 	Modified by     Koji Mitsunari.	Jun 22, 1998.
 	Comments	Voice Recognition System
   
 	$Id: voicemaskdictionary.c,v 1.1.1.1 2002/05/02 03:28:44 blythe Exp $
   ---------------------------------------------------------------------*/
/**************************************************************************
 *
 *  $Revision: 1.1.1.1 $
 *  $Date: 2002/05/02 03:28:44 $
 *  $Source: 
 *
 **************************************************************************/
#include "osint.h"
#include "controller.h"
#include "siint.h"

s32
osVoiceMaskDictionary(OSVoiceHandle *hd, u8 *pattern, int size) {
  s32	ret = 0 ;
  s32	i, j;
  u8	stat;
  u8	buf[20];		/*--- 20バイトライト用のバッファ ---*/

  if ((ret = __osVoiceGetStatus(hd->__mq, hd->__channel, &stat)) != 0 ) {
    return(ret);
  } else if (stat & VOICE_WRITE_READY) {
    return(CONT_ERR_VOICE_NO_RESPONSE);
  }
    
  if (size&1) {
    j = size +1;
  } else {
    j = size;
  }
    
  bzero(buf, 20);
    
  /*--- 辞書マスク用コマンドのセット ---*/
  buf[18-j] = 0x04;	/*--- マスクコマンド ---*/

  for(i = 0 ; i < j ; i+=2 ){
    buf[20+i-j] = pattern[i];
    buf[20+i-j+1] = pattern[i+1];
  }

  if (size&1) {
    buf[19] = 0;
  }

  ret = __osVoiceContWrite20(hd->__mq, hd->__channel, VOICE_RW_ADDR, buf);
  if (ret == 0 ) {
    ret = __osVoiceCheckResult(hd, &stat);
    if (ret & 0xff00) {
      ret = CONT_ERR_INVALID;
    }
  }

  return(ret);
}