CN1272800A - 交互式玩具 - Google Patents

交互式玩具 Download PDF

Info

Publication number
CN1272800A
CN1272800A CN99800961.XA CN99800961A CN1272800A CN 1272800 A CN1272800 A CN 1272800A CN 99800961 A CN99800961 A CN 99800961A CN 1272800 A CN1272800 A CN 1272800A
Authority
CN
China
Prior art keywords
user
student
equipment
toy
content
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN99800961.XA
Other languages
English (en)
Inventor
奥兹·加拜
雅各布·加拜
尼姆罗德·桑德勒曼
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Creator Ltd
Original Assignee
Creator Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Priority claimed from US09/081,255 external-priority patent/US6160986A/en
Application filed by Creator Ltd filed Critical Creator Ltd
Publication of CN1272800A publication Critical patent/CN1272800A/zh
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G09EDUCATION; CRYPTOGRAPHY; DISPLAY; ADVERTISING; SEALS
    • G09BEDUCATIONAL OR DEMONSTRATION APPLIANCES; APPLIANCES FOR TEACHING, OR COMMUNICATING WITH, THE BLIND, DEAF OR MUTE; MODELS; PLANETARIA; GLOBES; MAPS; DIAGRAMS
    • G09B5/00Electrically-operated educational appliances
    • G09B5/06Electrically-operated educational appliances with both visual and audible presentation of the material to be studied
    • G09B5/065Combinations of audio and video presentations, e.g. videotapes, videodiscs, television systems
    • GPHYSICS
    • G09EDUCATION; CRYPTOGRAPHY; DISPLAY; ADVERTISING; SEALS
    • G09BEDUCATIONAL OR DEMONSTRATION APPLIANCES; APPLIANCES FOR TEACHING, OR COMMUNICATING WITH, THE BLIND, DEAF OR MUTE; MODELS; PLANETARIA; GLOBES; MAPS; DIAGRAMS
    • G09B5/00Electrically-operated educational appliances
    • G09B5/04Electrically-operated educational appliances with audible presentation of the material to be studied
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63HTOYS, e.g. TOPS, DOLLS, HOOPS OR BUILDING BLOCKS
    • A63H13/00Toy figures with self-moving parts, with or without movement of the toy as a whole
    • A63H13/005Toy figures with self-moving parts, with or without movement of the toy as a whole with self-moving head or facial features
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63HTOYS, e.g. TOPS, DOLLS, HOOPS OR BUILDING BLOCKS
    • A63H2200/00Computerized interactive toys, e.g. dolls
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63HTOYS, e.g. TOPS, DOLLS, HOOPS OR BUILDING BLOCKS
    • A63H3/00Dolls
    • A63H3/28Arrangements of sound-producing means in dolls; Means in dolls for producing sounds
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63HTOYS, e.g. TOPS, DOLLS, HOOPS OR BUILDING BLOCKS
    • A63H3/00Dolls
    • A63H3/36Details; Accessories
    • A63H3/38Dolls' eyes
    • A63H3/40Dolls' eyes movable

Abstract

一种交互式玩具设备,包括:具有有趣的物理外观(17、18、19、20)的玩具(10),安装在玩具(10)上的扬声器(58),用户输入接收器(28),存贮有关至少一个用户的信息的用户信息存贮单元(74),响应通过用户输入接收器(28)接收的当前用户输入以及存贮在存贮单元(74)中的信息以便通过该扬声器向该用户提供音频内容的内容控制器(82)。

Description

交互式玩具
发明领域
本发明总地涉及计算机系统和方法,且更具体地涉及交互式构造的开发,讲授这样的开发的技术和言语交互式玩具。
发明背景
在现有技术中已知有各种言语交互式玩具。总地说来,这些玩具可被划分成两类,计算机游戏和独立玩具。这些独立玩具典型地在内部装有电子电路,通常提供相对低水平的语音识别和非常有限的词汇,经常导致在玩耍期间儿童产生厌烦和进行破坏。
计算机游戏可得到基本的计算能力的受益且因此可提供高水平的语音识别且使用户满意。它们的特征在于非言语方面是虚假的且因此缺乏与孩子门结合的能力。
以下的专利相信代表了言语交互式玩具的技术状况:
授予郝格鲁(Haugerud)的美国专利No.4,712,184描述了一种计算机控制的教育玩具,其结构可起到教导用户关于计算机的术语和编程及机器人技术的作用。郝格鲁说明了通过有线连接的计算机玩具控制,典型地,其中的计算机用户需编写一个简单的程序来控制机器人的运动。
授予罗斯(Rose)的美国专利No.4,840,602描述了一种会响应于外部信号而说话的玩偶,其中该玩偶有一个以数字数据形式存储在一个存储器中的词汇库,当该存储器被访问时将会使玩偶内的一 个语音合成器模仿说话。
授予兰格(Lang)的美国专利No.5,021,878描述了一种可实时控制的动画角色系统。
授予兰格的美国专利No.5,142,803描述了一种可实时控制的动画角色系统。
授予阿达伐(Aldava)等人的美国专利No.5,191,615描述了一种互联声动娱乐系统,其中向电视屏幕外面的一些会动和会听的玩具和其他可动装置提供与一个电视节目相同步的声音和控制数据,使之根据电视节目的进程与节目观看者互相作用。
授予库利埃(Collier)的美国专利No.5,195,920描述了一种无线电控制的玩具车辆,它能产生逼真的声响效果。与一个远地计算机相通信可使得操作人能修改和增添新的声响效果。
授予希卡瓦(Hikawa)的美国专利No.5,270,480描述了一种能响应于一个MIDI(乐器数字界面)信号而动作的玩具,其中一个玩着乐器的玩具会表演模拟的乐器弹奏动作。
授予兰格的美国专利No.5,289,273描述了一种用来遥控一个动画角色的系统。该系统利用无线电信号把声频、视频和其他控制信号传送给动画角色,实时地使之说话、聆听、观看和运动。
美国专利No.5,388,493描述了一种手风琴师用的容纳一个垂直双键盘MIDI无线控制器的系统。该系统既可按普通MIDI电缆连接使用,也可被无线MIDI发送系统使用。
授予诺依希尔(Neuhierl)的德国专利DE3009-040描述了一种用来增添从遥控器向受控模型车辆发送声音的能力的装置。其中的声音由话筒或磁带录音机产生,并通过无线电通信发送给受控模型车辆。模型车辆上装备了一个能把接收到的声频信号放出来的扬声 器。
本说明书中所有提到和引用的出版物的公开内容均在此引用作为参考。
发明的技术方案
本发明目的在于提供克服上述现有技术缺陷的言语交互式玩具及其方法。
根据本发明的一优选实施例提供了一交互式玩具设备,包括具有有趣的物理外观的一玩具;安装在该玩具上的一扬声器;一用户输入接收器;存储有关至少一用户的信息的一用户信息存储单元;和一内容控制器,其响应于经该用户输入接收器接收的当前用户输入和该存储单元中存储的信息进行工作,经该扬声器提供音频内容给该用户。
再根据本发明的一优选实施例,该用户输入接收器包括一音频接收器。
再根据本发明的一优选实施例,该当前用户输入包括经该音频接收器接收的一言语输入。
再根据本发明的一优选实施例,该用户输入接收器包括一触觉输入接收器。
再根据本发明的一优选实施例,该存储单元存储有关至少一用户的个人信息且该内容控制器进行工作以使该音频内容人性化。
再根据本发明的一优选实施例,该存储单元存储有关至少一用户与该交互式玩具设备的交互的信息且该内容控制器进行工作以根据存储的有关该至少一用户与该交互式玩具设备的过去的交互的信息来控制该音频内容。
再根据本发明的一优选实施例,该存储单元还存储有关至少一用户与该交互式玩具设备的交互的信息且该内容控制器还进行工作以根据有关该至少一用户与该交互式玩具设备的过去的交互的信息来控制该音频内容。
再根据本发明的一优选实施例,该存储单元还存储由一用户经该用户输入接收器言语地输入的信息。
而且,再根据本发明的一优选实施例,该存储单元还存储由一用户经该用户输入接收器言语地输入的信息。
而且,再根据本发明的一优选实施例,该存储单元还存储由一用户经该用户输入接收器言语地输入的信息。
再根据本发明的一优选实施例,该交互式玩具设备还包括一内容存储单元,存储经该扬声器待被播送给一用户的至少一内容标题的的音频内容,该至少一内容标题是交互式的且包含交互分支。
而且,再根据本发明的一优选实施例,该至少一内容标题包括存储对应的多个内容标题部分的多个音频文件,该多个内容标题部分包括至少两个可替换的内容标题部分;和响应于一任意的一用户输入、一环境条件、一过去的交互、有关一用户的个人信息、一远程计算机、和一与时间有关的条件在这些可替换的用户部分之间的一文本定义分支。
而且,再根据本发明的一优选实施例,该交互式玩具设备还包括一内容存储单元,存储经该扬声器待被播送给一用户的至少一内容标题的的音频内容,该至少一内容标题是交互式的且包含交互分支。
而且,再根据本发明的一优选实施例,该至少一内容标题包括多个内容元素的并行部分,该多个内容元素的并行部分包括至少两 个可替换的部分;和在这些可替换的部分之间的以一人性化方式的一文本定义分支。
再根据本发明的一优选实施例,该用户信息存储单元被至少部分地定位在该玩具中。
而且,再根据本发明的一优选实施例,该用户信息存储单元被至少部分地定位在该玩具外。
而且,再根据本发明的一优选实施例,该内容存储单元被至少部分地定位在该玩具中。
而且,再根据本发明的一优选实施例,该内容存储单元被至少部分地定位在该玩具外。
再根据本发明的一优选实施例,该用户输入接收器包括安装在该玩具上的一麦克风,和接收自该麦克风输入的一语句的一语音识别单元。
再根据本发明的一优选实施例,该用户信息存储单元进行工作以存储有关各可用一唯一码识别的多个用户的个人信息且该内容控制器进行工作以提醒任意用户提供该用户码。
而且,再根据本发明的一优选实施例,该用户信息存储单元进行工作以存储有关一用户的合作行为的信息。
再根据本发明的一优选实施例,提供具有改变脸部表情的玩具设备,该玩具包括多特征化的脸部设备,该多特征化的脸部设备包括多个可多位置的脸部特征;和一脸部表情控制单元,其进行工作以至少生成代表至少两个对应的脸部表情的多个脸部特征的位置的三种组合。
而且,再根据本发明的一优选实施例,该脸部表情控制单元进行工作以使这些特征以不同的速率在多个位置之间变动,从而生成 不同情绪的错觉。
而且,再根据本发明的一优选实施例,该玩具设备还包括一扬声器装置、存储一音频声明的一音频存储器、和进行工作以通过该扬声器装置控制该音频声明的输出的一音频输出单元,且该脸部表情控制单元进行工作以与该声明的输出同步地生成多个位置的组合。
再根据本发明的一优选实施例,还提供有用于播放一交互式言语游戏的玩具设备,包括一玩具;安装在该玩具上的一扬声器装置;安装在该玩具上的一麦克风;接收自该麦克风输入的一语句的一语音识别单元;和一音频存储单元,用于存储通过该扬声器装置待被播放的多个言语游戏段和在这些言语游戏段之间的一文本存储定义交互分支。
再根据本发明的一优选实施例,这些言语游戏段包括提醒一用户生成对该言语游戏的一说出的输入的至少一段。
再根据本发明的一优选实施例,该至少一段包括两或更多的言语串和一对该用户的提醒以再现这些言语串之一。
再根据本发明的一优选实施例,该至少一段包括一谜。
再根据本发明的一优选实施例,这些言语串中的至少一个具有教育内容。
再根据本发明的一优选实施例,这些言语串中的至少一个包括有关在该游戏中的该用户的行为的性质对用户的一个反馈。
再根据本发明的一优选实施例,该交互式玩具设备还包括与该玩具一起装配的包括多个可多位置的脸部特征的多特征化脸部设备;和一脸部表情控制单元,其进行工作以至少生成代表至少两个对应的脸部表情的多个脸部特征的位置的三种组合。
而且,再根据本发明的一优选实施例,该脸部表情控制单元进行工作以使这些特征以不同的速率在多个位置之间变动,从而生成不同情绪的错觉。
而且,再根据本发明的一优选实施例,该交互式玩具设备还包括存储一音频声明的一音频存储器;和进行工作以通过该扬声器装置控制该音频声明的输出的一音频输出单元,且该脸部表情控制单元进行工作以与该声明的输出同步地生成多个位置的组合。
再根据本发明的一优选实施例,该交互式玩具设备还包括安装在该玩具上的一麦克风;接收自该麦克风输入的一语句的一语音识别单元;和一音频存储单元,用于存储通过该扬声器装置待被播放的一言语游戏的多个言语游戏段和在这些言语游戏段之间的一文本存储定义交互分支。
再根据本发明的一优选实施例,这些言语游戏段包括提醒一用户生成对该言语游戏的一说出的输入的至少一段。
再根据本发明的一优选实施例,该至少一段包括两或更多的言语串和一对该用户的提醒以再现这些言语串之一。
再根据本发明的一优选实施例,该至少一段包括一谜。
再根据本发明的一优选实施例,这些言语串中的至少一个具有教育内容。
再根据本发明的一优选实施例,还包括安装在该玩具上的一麦克风;接收自该麦克风输入的一语句的一语音识别单元;和一音频存储单元,用于存储通过该扬声器装置待被播放的一言语游戏的多个言语游戏段和在这些言语游戏段之间的一文本存储定义交互分支。
再根据本发明的一优选实施例,这些言语游戏段包括提醒一用 户生成对该言语游戏的一说出的输入的至少一段。
再根据本发明的一优选实施例,该至少一段包括两或更多的言语串和一对该用户的提醒以再现这些言语串之一。另外或可替换地,该至少一段包括一谜。
再根据本发明的一优选实施例,这些言语串中的至少一个具有教育内容。
再根据本发明的一优选实施例,这些言语串中的至少一个包括有关在该游戏中的该用户的行为的性质对用户的一个反馈。
根据本发明的一优选实施例,还提供有一种玩具交互的方法,包括提供具有有趣的物理外观的一玩具;提供安装在该玩具上的一扬声器;提供一用户输入接收器;将有关至少一用户的信息存储进一用户信息存储单元;并经一响应于经该用户输入接收器接收的当前用户输入和该存储单元中存储的信息进行工作的内容控制器,,经该扬声器提供音频内容给该用户。
再根据本发明的一优选实施例,该存储步骤包括存储有关至少一用户的个人信息并经该内容控制器使该音频内容人性化。
再根据本发明的一优选实施例,该存储步骤包括存储有关至少一用户与该交互式玩具设备的交互的信息且根据存储的有关该至少一用户与该交互式玩具设备的过去的交互的信息经该内容控制器来控制该音频内容。
再根据本发明的一优选实施例,该方法还包括在一内容存储单元中存储经该扬声器待被播送给一用户的至少一内容标题的的音频内容,该至少一内容标题是交互式的且包含交互分支。
再根据本发明的一优选实施例,该方法还包括存储有关各可用一唯一码识别的多个用户的个人信息且经该内容控制器提醒任意用 户提供该用户码。
而且,再根据本发明的一优选实施例,该方法还包括存储有关一用户的合作行为的信息。
再根据本发明的一优选实施例,该方法还包括提供多特征化的脸部设备,该多特征化的脸部设备包括多个可多位置的脸部特征;并至少生成代表至少两个对应的脸部表情的多个脸部特征的位置的三种组合。
而且,再根据本发明的一优选实施例,该方法还包括使这些特征以不同的速率在多个位置之间变动,从而生成不同情绪的错觉。
而且,再根据本发明的一优选实施例,该方法还包括存储一音频声明,并通过该扬声器提供该音频声明,且与该声明的输出同步地生成多个脸部位置的组合。
根据本发明的一优选实施例,还提供有一种用于使用交互式对象,将编程教授给学生,例如学校的孩子们的系统,该系统包括一计算机化的学生界面,允许一学生通过定义该交互式对象的特性赋与该交互式对象以生命,该计算机化学生界面进行工作以响应于学生输入至少部分地定义该交互式对象与人之间的交互;和一计算机化教师界面,允许一教师在定义该交互式对象的特性中监视学生的进度。
再根据本发明的一优选实施例,该计算机化教师界面允许该教师配置该计算机化学生界面。
根据本发明的一优选实施例,还提供有一种用于将交互式对象的设计和编程教授给学生的教授系统,该系统包括包括一计算机化的学生界面,允许一学生通过定义该交互式对象的特性赋与该交互式对象以生命,该计算机化学生界面进行工作以响应于学生输入至 少部分地定义该交互式对象与人之间的交互;和一计算机化教师界面,允许一教师配置该计算机化学生界面。
根据本发明的一优选实施例,还提供有一种用于开发情绪上有知觉的计算机化的创造物的计算机系统,包括一计算机化的用户界面,允许一用户通过定义一情绪上有知觉的计算机化的创造物与自然人之间的交互来开发该情绪上有知觉的计算机化的创造物,该交互至少包括该情绪上有知觉的计算机化的创造物对从该自然人提供的一刺激所导出的,指示自然人情绪的至少一参数的至少一响应;和一创造物控制单元,其进行工作以根据由该用户定义的这些特性和交互来控制该情绪上有知觉的创造物。
再根据本发明的一优选实施例,该指示自然人情绪的参数包括除其语言内容之外的自然人语句的特性。
根据本发明的一优选实施例,还提供有一种用于开发情绪上有知觉的计算机化的创造物的方法,该方法包括定义该情绪上有知觉的计算机化的创造物与自然人之间的交互,该交互至少包括该情绪上有知觉的计算机化的创造物对从该自然人提供的一刺激所导出的,指示自然人情绪的至少一参数的至少一响应;和根据由该用户定义的这些特性和交互来控制该情绪上有知觉的创造物。
根据本发明的一优选实施例,还提供有一种用于将编程教授给学生的方法,该方法包括提供一基于计算机化的虚拟编程的学生界面,允许学生执行虚拟编程;并提供一计算机化的教师界面,允许教师配置该计算机化的学生界面。
还提供有一种情绪上有知觉的计算机化的创造物,包括多个交互模式,用于实现对应的多个与自然人的交互,该多个交互至少包括对指示自然人情绪的至少一自然人情绪参数的一响应;和一情绪 感知单元,用于从由该自然人提供的一刺激导出至少一自然人情绪参数,并将该参数提供给多个交互模式中的至少一个;和任选地,一真实的或虚拟的,例如在屏幕上的,的物体,用于在多个交互模式中的至少一个中进行参与。
附图的简要说明
本发明将从以下参照附图的详细描述中被予理解且显见。
图1A是形成根据本发明的一优选实施例构成并工作的一交互式玩具系统的至少一部分的一玩具的简化视图;
图1B使图1的玩具的后视图;
图2使图1A和1B的玩具的部分切开视图;
图3是图1A和1B及2的玩具的元件的简化分解视图;
图4A、4B、4C、4D和4E是指示脸部表情变化的图1A-3的玩具的视图;
图5是本发明的一优选实施例的交互式玩具设备的简化方框图;
图6是形成图5的设备的部分的一基台的功能方框图;
图7是形成图5的设备的部分的一玩具中安装的一电路的功能方框图;
图8A-8G结合在一起组成图5的基础通信单元62的概略性视图:
图8H-8N结合在一起组成根据一替换实施例的图5的基础通信单元62的概略性视图;
图9A-9G结合在一起组成图5的玩具控制装置24的概略性视图;
图9H-9M结合在一起组成根据一替换实施例的图5的玩具控 制装置24的概略性视图;
图10-15结合在一起组成图1-9G的交互式玩具系统的一优选的操作方法的简化流程图;
图16A和16B结合在一起形成由图10的“播放”字模块执行的一文本的打开动作的一种可能实施方案的简化的工作流程图;
图17A-17E结合在一起形成由图10的“播放”字模块执行的一故事文本的一种可能实施方案的简化的工作流程图;
图18A-18G结合在一起形成由图10的“播放”字模块执行的一游戏文本的一种可能实施方案的简化的工作流程图;
图19A-19C结合在一起形成由图10的“播放”字模块执行的一歌曲文本的一种可能实施方案的简化的工作流程图;
图20A-20C结合在一起形成由图10的“播放”字模块执行的图17A-17E的“Bunny Short”故事文本的一种可能实施方案的简化的工作流程图;
图21A-21F结合在一起形成由图10的“播放”字模块执行的图17A-17E的“兔子长片”故事文本的一种可能实施方案的简化的工作流程图;
图22是在图17D、18C、19B和19C中所涉及的“主题部份”的简化的工作流程图;
图23A是根据本发明的一优选实施例的一真实玩具活创造物的开发和操作的视图;
图23B是根据本发明的一优选实施例的一虚拟活创造物的开发和操作的视图;
图23C是对图23A-23B的系统进行变化的一系统的简化的半插图半方框图的视图,其中设置一远程内容服务器,其对在将生命 赋与一计算机化的活创造物中有用的数据、程序、声音、文件和其他内容提供服务;
图24A是一学生编程一计算机化的活创造物的视图;
图24B是人与一计算机化的活创造物至少进行言语交互的视图,其中该交互如上所述参照图24A地由学生进行编程;
图24C是装备有摄像机和例如液晶显示器(LCD)的视频显示器中的一构件的一创造物的视图;
图25是一系统管理员的优选功能性的简化的软件设计视图;
图26是例如图23A-23C的系统的一用于教授交互式计算机化的构造的开发的系统中的教师工作站312的优选功能性的简化的软件视图;
图27是例如图23A-23C的系统的一用于教授交互式计算机化的构造的开发的系统中的学生工作站10的优选功能性的简化的软件视图;
图28-31是作为用于可视编程块840840的一人界面的部分的屏幕显示的例子;
图32是包括一投射的状态机器图的例子的图示的屏幕显示;
图33是使学生建立一环境的屏幕显示,其中一先前生成的模块可被测试;
图34-37是图23A、23B或23C中任一的教师工作站312给出的屏幕显示的例子;
图38是学生典型地使用图23A、23B或23C中任一的学生工作站的过程的简化的流程图;
图39是通过在该学生工作站310中的插入目录中的选择事件(Event)所生成的一屏幕显示的例子;
图40是通过在该学生工作站310中的插入目录中的选择功能(Function)所生成的一屏幕显示的例子;
图41是在执行图38的步骤910和920的过程中由学生执行的处理的简化的流程图;
图42是一情绪交互作用流程设计过程的简化的流程图;
图43-102是根据本发明的一优选实施例构成并工作的一计算机化的编程教授系统的优选实施例的视图;
图103是一情绪分析数据库的表格图;
图104是一情绪分析状态图;
图105是典型的功能呼叫和回呼通知视图;
图106是适用于一媒体BIOS模块的典型的输入数据处理视图;
图107是适用于一UCP实现模块的典型的输入数据处理视图;
图108是适用于用户应用和一API模块的典型的数据处理视图;
图109是一典型的UCP实现模块和媒体BIOS输出数据处理视图;
图110是用于可以协议实现模块和媒体BIOS模块的输出数据处理视图;
图111是典型的图形构成的视图;及
图112-115是典型的安装—检验(分别为BT1/4,2/4,3/4和4/4)视图。
这里附有以下的附录,其目的在于理解和评定所示出及所描述的本发明的一优选实施例:
附录A是本发明的交互式玩具系统的一优选的软件实现的计算机目录;
附录B是用于图8A-8G的设备的一优选的部分目录;及
附录C是用于图9A-9G的设备的一优选的部分目录。
优选方案的详细描述
现在参照图1A。图1A是一个简化的玩具图,一般情况下,本发明将一个玩具标记为10。玩具10至少为所建造的交互玩具系统的一个组成部分,其操作符合本发明所优选的一个具体实现。尽管玩具10能够以多种物理配置加以实现,并仍可保持此处所描述的交互玩具系统的各种功能,但为了便于说明,图1A中仅显示了一个典型的玩具10,这一玩具10具有一个奇特的物理外观,并包括一个拥有一系列附件(例如胳膊14、腿16、眼睑17、眼睛18、鼻子19以及嘴20)的身体部分12。胳膊14和腿16可能是被动的″附件″,即可将它们配置为不可移动的,但眼睑17、眼睛18和嘴20可以是″活跃的″附件,即可将它们配置为可移动的。以下将参照图3~4E对此进行较为详细的描述。
图1B是图1中所示玩具的一个背视图,而且还把玩具10典型地显示为一个具有有孔区22的玩具,在孔区22的后面可安装一个扬声器,以下将对此更详细地加以描述。
图2是图1A和1B所示玩具的局部剖面图,显示了玩具控制设备24(通常安置在身体部分12中)和一系列用户输入接收器(例如那些位于胳膊14和腿16中用以接收触觉用户输入的开关26)以及一个用于接收音频用户输入的麦克风28。应明白允许把此处所描述的各种用户输入接收器定位在玩具10中的任何地方,例如鼻子19之后,只要它们能够根据要求由触觉和音频用户输入(例如话音输入)加以访问即可。
应明白,令大量人们所知的传感器和输入设备(例如加速度测量器、方向传感器、接近传感器、温度传感器、视频输入设备等)中的 任何一种(尽管并没有特别示出)都可并入玩具10,用以接收输入或其它刺激,从而并入此处所描述的针对本发明的交互式玩具系统的交互环境中。
现在,请再次参照图3。图3是图1A、1B以及2中所示玩具10的各部件的简化分解图。图1所示身体部分12的面部部分30在图3中与鼻子19和嘴20一起加以显示,并拥有2个孔32,用以容纳眼睑17和眼睛18。面部部分典型地位于保护盖34的顶部,保护盖34安装在保护盒36上。眼睑17、眼睛18以及嘴20,每一个都典型地与运动部件38相配合,运动部件38向每一附件提供了一个动作。运动部件38典型地由一个齿轮盘40所驱动,而该盘由一个齿轮传动轴42和电机44加以控制。通过一个相应的运动部件38,电路24实现了一个具体附件所希望的一个运动,即取决于齿轮传动装置平台40相对于当前转动方向的所希望的转动方向控制电机44和齿轮传动轴42,以定向和移动齿轮传动装置平台40,齿轮盘40的方向是由光定位设备46所决定的。更可取的做法是,令齿轮传动装置平台40有选择地与运动部件38中一个单一的运动部件在某一时刻协作,而该选择时刻依赖于齿轮传动装置平台40的具体转动方向。另外还提供了一个针对音频输出的扬声器。能量典型地由电源48(通常为一个DC电源)加以提供。
图4A、4B、4C、4D以及4E是对图1A~3所示玩具10的面部表情变化的图示说明。图4A显示的是按箭头50所指示的方向加以转动的眼睛18。图4B显示的是按箭头52所指示的方向加以转动的眼睛18。图4C显示的是已呈半闭状态的眼睑17,而图4D显示的是全闭状态的眼睑17。图4E显示的是按箭头54和箭头56所指示方向加以移动的嘴唇20。应明白,嘴20既可移动一片嘴唇也可移动两 片嘴唇。
现在请参照图5。图5是按照本发明的一个优选的具体方案所构造并可在这一方案中加以运作的交互式玩具设备的一个简化的结构图。这一方案典型地提供了一台计算机60,例如一台基于Intel公司PENTIUM微处理器的个人计算机,通过RS-232串行通信端口与一个基础通信单元62(典型地为一个基于无线电的单元)进行通信。通过并行端口、声卡的MIDI和音频端口、USB端口或任何为人们所熟悉的通信端口,可实现计算机60和基础单元62之间的通信。单元62典型地由电力供给装置64提供能量,这一电力供给装置可由一个AC电源供电。更好的方案是,令单元62包括一个天线66,用于与玩具10(图2)的玩具控制设备24进行通信,相类似,玩具控制设备24也应装备天线68。玩具控制设备24典型地控制电机44(图3)、开关26(图2)、一或多个用于检测玩具10的动作的运动传感器70、麦克风28(图2)、扬声器58(图3)。部件24、44、26、28、58以及70中的任何一个,均可由电源48(图3)提供能量。
计算机60典型地提供了用户信息存储机制,例如,在一个硬磁盘上或在任何一个为人们所熟悉的、更为理想的非易失性存储媒体上,用以存储与用户相关的信息,例如用户的个人信息,这些信息包括用户名、一个唯一的用户代码(本发明将其称为″秘密名″,秘密名可能是用户的一个虚构名或其它奇异的名,典型地由用户预定义或选择)以及用户的年龄等。
计算机60还可做为本发明所称的″内容控制器″。作为内容控制器,计算机60可识别与玩具10交互的用户、对通过玩具10(例如通过扬声器58)的控制内容的选择与输出,以下将会更详细地加以描述。内容控制器可利用与用户相关的信息,人性化那些提交给用户的 音频内容,例如通过使用用户的秘密名来称呼用户,或以一种适合于用户性别的方式与用户交谈。计算机60还典型地可为存储内容标题提供内容存储,每一个内容标题包括一个或多个内容元素,用于响应通过以上描述的玩具10的用户输入接收器所接收到的用户输入、环境输入、或随机的输入。例如,一个内容标题可以是一个笑话、一个谜语或一个交互故事。一个交互故事可以包括许多内容元素,例如音频元素,通常情况下安排在一个用于顺序输出的脚本中。交交互故事典型地被划分为多个内容元素序列部分,而且把多个部分并行加以安排,以代表故事中每一点的可选的交互分支。内容控制器可根据玩具10的当前用户输入、先前的分支选择、或其它用户信息(例如过去的交互、用户的偏好、性别、环境或瞬时状态等)选择一个分支。
计算机60可通过各种人们所熟悉的装置(例如通过与BBS或与Internet固定或拨号的连接)与一或多台其它的计算机(例如一台远程计算机)进行通信。计算机60可实时地或通过一个后台或批处理过程,从远程服务器上下载各种类型的内容信息,例如全新的内容标题、现存标题的附加部分或内容元素(例如脚本和话音文件)、一般化的信息(例如天气预报信息和广告以及教育材料)。从一台远程计算机那里所下载的信息,先前可能曾经针对某一特定用户进行过定制化处理,例如根据年龄、用户的地址、购买习惯、受教育水平以及现存的用户信誉所进行的定制化处理。
内容控制器也可记录和存储从某一用户那里接收来的用户信息,用户信息是通过用户输入接收器(例如话音的或其它音频用户输入)加以接收的。计算机60包括语音识别能力,这一能力典型地通过硬件与/或软件,例如″Automatic Speech Recognition SoftwareDevelopmemtKit(自动语音识别软件开发工具)3.0版″,(可从 Lernout&Hauspie话音产品、Sint-Krispisnstraat7、8900Leper以及Belgium),加以实现。语音识别可为内容控制器加以使用,用于分析来自用户的话音输入,以确定用户的选择,例如在与某一交互故事的连接中,以选择该故事的一个分支。内容控制器还可把语音识别能力用于对用户的识别,即由用户讲出秘密名或代码,并由麦克风28加以接收,从而实现对用户的识别。
内容控制器还可提供对面部表情的控制。通过使面容的各部分以不同的速率在不同位置之间振动,面部机制(图5)可以提供复杂的和动态的面部表情。更理想的方案是,令面容的每一个部分至少拥有两个假设的位置。通常情况下,两个或更多的面容部分可在同一时刻以不同的速率,移向不同位置,以便提供一系列面部表情的组合,从而可产生各种不同的感情。更可取的是,内容控制器可控制面部特征的组合,与用户的交互或内容的输出同步发生,以提供一个自然的伴随表情,例如嘴唇的同步和眼睛的自然转动。
更理想的方案是,内容控制器可记录那些与提供给用户的内容相关的信息以及与每一用户同玩具10之间的交互相关的信息,例如给每一用户所讲的具体的笑话和为每一用户所唱的具体的歌曲、用户对提示(例如问题或谜语或交互故事以及其它用户输入)的响应与选择。内容控制器可把与每一用户过去交互相关的信息,用于相继内容的选择和输出,另外还可适当地控制玩具10(例如当与一个先前并没有同当前用户玩过游戏的用户玩游戏),或影响交互的复杂度。
最好能够把计算机60安置在玩具10内或物理地与玩具10组装在一起,以致于计算机60能够直接与玩具控制设备24进行通信,而不必通过基础单元62和天线66及68,例如通过有线装置或光无线通信方法。另外,也可把计算机60电子地与玩具控制设备24集成在 一起。
图6是图5所示的基础通信单元62的一个功能结构图。单元62典型地包括一个微控制器单元72,这一微控制器单元拥有一个内存74,单元72可通过一个适配器76与图5所示的计算机60进行通信,并典型地通过一个RS-232端口或如以上所述的其它形式与计算机60相连(参见图5)。单元72通过发送接收机78和天线66与玩具10(图2)的玩具控制设备24进行通信。发送接收机78通常为一无线电发送接收机。
图7是图5所示的玩具控制设备24的一个功能结构图。设备24典型地包括一个微控制器单元82,它可通过一个发送接收机84(典型地为一无线电发送接收机)和天线68与图5所示的基础单元72进行通信。能量是由一个电力供给装置86加以提供的,电力供给装置86由电源48(图5)提供电能。更可取的做法是,让单元82控制与/或接收来自玩具接口模块88的输入,而玩具接口模块88将控制与/或接收来自如以上所描述的扬声器、麦克风、传感器、以及电机的输入。发送接收机84可以附加地或交替地与接口模块88进行通信,以实现麦克风输入和扬声器输出的直接通信。
现在参照图8A~8G。图8A~8G共同构成图5所示基础通信单元62的一个示意图。附录B是图8A~8G所示装置的一张优选零件的列表。
图8H~8N共同构成图5所示的基础通信单元62的另一可选方案的示意图。
现在参照图9A~9G。它们共同构成图5所示玩具控制设备24的一个示意图。附录C是图9A~9G所示装置的一个优选零件的列表。
图9H~9M共同构造图5所示玩具控制设备24的另一可选方案 的示意图。
现在参照图10~15。它们共同构成图1~9G所示交互玩具系统的一个优选的操作方法的简化流程图。应明白,图10~15所示的方法可部分地由计算机硬件和部分地由软件或全部由定制化的硬件加以实现。可取的做法是,令图10~15所示的方法作为由计算机60(图5)所执行的软件指令加以实现。应明白,图10~15所示的方法以及以下所描述的其它方法,不必以一种特定的顺序加以执行。事实上,出于实现上的原因,这些方法的某一具体实现很可能会按不同于另一个特定实现的顺序加以实现。
图10描述了主要的软件模块以及相应的高层部件。操作典型地开始于:接通可与基础单元62进行通信的通信端口,并通过基础单元62初始化计算机60与玩具控制设备24之间的通信。主模块还初始化一个语音识别引擎,并显示(典型地通过计算机60的显示器)用于以选择各种子模块的程序的主菜单。主模块典型地包括下列子模块:
1)″关于你的信息″是一个子模块,它可使用户根据用户的偏好配置该系统,即用户可通过装入相应的参数,例如用户的真实姓名、秘密名、出生日期、头发与眼睛的颜色、性别、以及通常睡觉与起床的时间等,对系统加以配置。
2)″跟着唱″是另一个子模块,它提供了具体的内容,例如允许用户跟着一起唱的歌曲。
3)″如何玩玩具″是一个教学子模块,它可教用户如何使用这一系统以及如何玩玩具10。
4)″玩玩具″是一个子模块,它可把交互内容提供给玩具10,并指导玩具10与用户进行交互。
5)″检查玩具″是一个子模块,它可帮助用户解决与该系统的操作 相关的技术问题,例如当玩具的电池能量偏低和无法向基站提供足够的电力时应怎么办,以及
6)″退出″是一个子模块,它能够使用户停止交互玩具系统软件的操作,并将其从计算机内存中加以清除。
图11更详细地说明了图10所示″接通通信″步骤的一个优选的实现。典型的操作开始于:对典型的系统参数(例如设置对各存储单元的文件系统的存取)的初始化。接下来的操作,将是加载显示元素、接通数据库、初始化玩具和通信驱动程序、初始化语音识别软件引擎,并为各种并行操作的活动创建独立的线程以便一个用户在与玩具交互的同时,另一个用户也可以把计算机屏幕和键盘用于其它应用,例如文字处理。
图12更详细地显示了图10所示″关于你的信息″子模块的一个优选的实现。典型的操作开始于当用户在计算机屏幕的主菜单上选择了″关于你的信息″选项时。然后提示用户,请用户表明他是一个现存的用户还是一个新的用户。接下来,由用户提供用户标识,并继续进入一个注册步骤。图12中所示的部分或全部操作可根据玩具的话音指示加以执行。
图13更详细地显示了图12所示注册阶段的一个优选的实现。典型的操作开始于:加载一个注册数据库、选择一个秘密名,然后选择和修改显示在计算机屏幕上的参数。当选择退出选项时,用户返回到图10所描绘的主菜单。
图14更详细地显示了图10所示″跟着唱″子模块的一个优选的实现。典型的操作开始于:在计算机的屏幕上显示一部电影,并同时使(在基础单元的通信范畴内)所有玩具10通过它们的扬声器提供音频内容,例如电影的插曲。用户可以(例如通过键盘键入)选择前进 到下一首歌曲或退出这一模块,并返回到主模块。
图15显示了图10所示的″如何玩玩具″和″玩玩具″子模块的一个优选的实现。典型的操作开始于:对所希望的脚本的初始化(以下将对此更详细地加以描述)、最小化计算机屏幕上的状态窗口、关闭线程、并返回到主菜单。计算机继续操作负责玩具运行的线程,并继续并行地在计算机屏幕上显示通信媒体的状态和脚本。
现在请参照图16A和16B,它们共同构成由图10所示″Play--玩玩具″子模块所执行的一个脚本的打开动作的一种可能的实现,简化的操作流程图。与下列的动作识别符和动作相结合,可更好地理解图16A和16B的实现。
打开
音频     文本
Op002     请捏我有脚。
Op015m     ″嗨!早安!哇!多好的早晨呀!我是一个可以讲故事的人!请问,何为你的秘密名?
Op020m     ″嗨!午安!哇!多好的下午呀!我是一个可以讲故事的人!请问,何为你的秘密名?
Op025m     ″嗨!晚安!哇!多好的夜晚呀!我是一个可以讲故事的人!请问,何为你的秘密名?
op036m     好,从现在起,我将叫你彩虹。嗨!彩虹,今天的天气多么好啊!好,彩虹,你是老板,你来选择我们应该做的事。请说:故事、游戏或、唱歌。
op040m     艾丝,你直接来自外层空间!好,艾丝,你是老板,你来选择我们应该做的事。请说:故事、游戏或唱歌。
Op045m     彩虹,今天的天气多么好啊!好,彩虹,你是老板,你来选择我们应该做的事。请说:故事、游戏或唱歌。
Op050m     泡泡糖,好好地消磨一下时光!好,泡泡糖,你是老板,你来选择我们应该做的事。请说:STORY(故事)、游戏或唱歌
op060     不要害羞,只要你做出决定,我们就开始玩,请你大声喊:STORY(故事)、游戏或唱歌。
播放上表中标识为Op002的话音文件,图16A和16B所示方法的典型操作将开始进行。这可典型地通过指示玩具开始接受一个特定时间长度的话音文件得以实现。接下来,从计算机的存储单元中读出这一话音文件,并通过无线电基站与玩具控制设备进行通信。玩具控制设备把所接收的无线电输入与玩具的扬声器连接起来,无线电输入将通过玩具的扬声器加以输出。话音文件op002请求用户按压位于玩具鼻子或脚上的微开关。
如果用户按下微开关,则脚本程序将会继续播放话音文件op015m、op020m或op025m,每一个文件都按照当前日期时间欢迎用户,然后请求用户说出他或她的秘密名,以向系统标识他或她自己。接下来,脚本程序用三秒钟的时间记录用户的话音响应。记录工作是由计算机来完成的,即计算机将向玩具发送一条命令,命令玩具把玩具的麦克风与玩具无线电发射机连接在一起,并用三秒钟的时间发射所接收的音频输入。无线电通信由无线电基站加以接收,传送给计算机,并作为一个文件存储在计算机的存储单元中。接下来应用软件根据所记录的文件执行语音识别。然后把语音识别过程的结果返回给脚本程序。脚本程序根据用户的响应,继续播放一条对应于所标识秘密名的人性化的欢迎消息,或播放另一条有关识别工作未能成功进 行的消息。这一欢迎消息还请求用户在多个选项(例如一个故事、一个游戏或一首歌曲)之间加以选择。用户的选择是通过记录用户的话音响应和执行语音识别加以接收的。图17A~17E、18A~18G以及19A~19C分别更详细地描述了一个故事、一个游戏和一首歌曲的简化的优选的实现。
图17A~17E共同构成了图10所示″Play--玩玩具″子模块所执行的一个故事脚本的一个可能的实现的一个简化的操作流程图。与下列的动作识别符和动作联系在一起,将可更好地理解图17A~17E的实现:
故事菜单
音频     文本
stm105     ″嘿艾丝,看起来你象我一样喜欢故事,我知道一个非常有意思的关于三只特别好奇的小免子的故事。
stm110     ″嘿彩虹,看起来你象我一样喜欢故事,我知道一个非常有意思的关于三只特别好奇的小免子的故事。
Stm115     ″嘿泡泡糖,看起来你象我一样喜欢故事,我知道一个非常有意思的关于三只特别好奇的小免子的故事。
stm125m     听故事,多好的主意啊!我喜欢听故事,让我们一起讲一个吧,就让我们从″金发小姑娘和三只狗熊″的故事开始吧。
stm130m     从前,有一个小姑娘,她在森林中迷路了。又饿又累,忽然她看到了一个舒适的小屋。门是敞开的,因此她径直地走了进去。
stm135m     在厨房的桌子上,摆放着三个碗粥。她走到一个碗边,喝了一勺粥。
Stm140m   呀!你告诉我,那粥怎样?太热,太凉还是凉热正好?如果希望接着讲,请说:太热、太凉或凉热正好。
stm150m   (粥从嘴里喷出的声音)太热!这是狗熊爸爸的那碗粥,这粥太热。
Stm155   (粥从嘴里喷出的声音)太凉!这是狗熊妈妈的那碗粥,这粥太凉。
stm160   咕噜咕噜地喝起来。凉热正好!这是狗熊宝宝的那碗粥,这粥凉热正好!金发小姑娘把粥全喝光了!
stm170   通过给你讲故事来消磨我的时间吧!你还想再听另一个故事吗?请说:是或否。
stm180   如果你还想再听另一个故事,就说是。如果你想做别的事情,就说否。
stm195   我打算给你讲一个关于三只特别好奇的小免子的故事。
stm205m   嗯,啊!小免子们好象有点儿麻烦!现在你想接着听小免子的故事吗?请说:是或否。
stm206m   记住小免子的故事了吗?小免子们正在吃美味的东西,这时它们听到有人走过来,你想知道下面发生了什么事情吗?请说:是或否。
stm215m   如果你想听接着听小免子的故事,请说:是。如果你想做其它的事情请说:否。
stm225   不?--好,讲到这里已经足够了。记住只要你想玩“有趣的小兔子小册子”,你随时可以玩。让我们看一下,现在你想干些?
stm230   现在你想玩游戏还是想听歌曲?请说:游戏或唱歌。
stm245     现在,让我们玩游戏还是唱歌,由你来决定。请决定--游戏或唱歌。
图18A~18G共同构成了由图10所示″Play--玩玩具″子模块所执行的一个游戏脚本的可能的实现的一个简化的操作流程图。与下列动作标识符及动作相结合,将会对图18A~18G所示的实现有更好的理解:
游戏菜单
音频     文本
gm805     嘿艾丝,原来你又想玩游戏了。太棒了!让我们再来玩Jumble Story(混乱故事:一种把故事段落打乱,然后由用户按正确顺序重新排列的游戏)。
gm810     嘿彩虹,原来你又想玩游戏了。太棒了!让我们再来玩混乱故事。
Gm815     嘿泡泡糖,原来你又想玩游戏了。太棒了!让我们再来玩混乱故事。
Gm820m     玩游戏!多好的主意!我喜欢玩游戏,特别是那些根据故事编写的游戏。
Gm840     这一游戏叫做混乱故事。故事的段落顺序全部打乱了,将需要你来帮助我整理这一故事。
GM845m     当你捏我的鼻子、我的手或我的脚时,可听我讲一些句子。然后再按正确的顺序捏,以致于所讲的故事将合乎情理。
gm847m     好,请捏我的鼻子。
gm855m     (打喷嚏声)哦,对不起。(呼呼地吸气)现在好了,你可以捏我的鼻子了。
Gm860     一个女人来到门前,并说她是一位公主。
gm865m     ″好一现在捏我的脚。″
gm875     ″不要担心,我不会踢你,请捏我的脚″。
Gm890     不久以后,他们结婚了,此后他们一直生活得非常幸福。
gm895     请再捏一次我的手。
gm905     ″如果要捏,应友善地轻轻捏一下。″
Gm910     从前,一位王子正寻求一位公主,想和她结婚。
gm915     ″现在一定要记住每要听一句话时你应捏什么地方。然后按正确的顺序捏我的手、我的脚或我鼻子,就能得到正确的故事。″
gm921     一个女人来到门前,并说她是一个公主。
gm922     不久以后,他们结婚了,此后他们一直生活得非常幸福。
gm923     从前,一位王子正寻求一位公主,想和她结婚。
gm924     如果你想玩JumbleStory,请按正确的顺序捏我的鼻子、捏我的手和捏我的脚。
Gm925     正确的顺序是手、鼻子、然后是脚,试着做一遍。
gm926m     ″这是你做的!真不错!你是多好的一个JumbleStory的玩家呀!″
gm930m     ″这就是整个故事的来龙去脉!现在它不再是一个段落顺序混乱的故事!事实上,它是″豌豆公主″的故事。如果你想听,我可以从头到尾给你讲一遍这个故事。你应该说:是或否。″
gm932     ″你玩JumbleStory玩得很好!现在你想玩一个不同的游戏吗?请说:是或否。″
gm933     我们可以再下一次玩这个游戏。现在你想玩一个不同的游戏吗?请说:是或否。
gm940     ″好,现在有足够多的游戏加以选择。  因此有更多的事情可以做。我们应该讲故事还是应该唱歌?请说:是或否。″
gm945     你告诉我想干什么!好,请说:是或否。
gm965m     这是我的另一个最喜欢的游戏。它叫做猜迷游戏。
gm970     好,现在让我们开始吧。现在我的脑子里正在想某种粘的东西。猜一猜它是棒糖还是花生酱?请说:棒糖或花生酱。
gm972     猜一猜我脑子里正在想的是哪一种粘的东西,是棒糖还是花生酱?
gm975     猜对了!我脑子里想的正是棒糖。它是粘的,而且还有一根棒。
Gm980     猜对了!我脑子里想的正是花生酱。它很粘,以致于粘你的上牙堂。
gm984     太棒了,让我们再猜另一个谜语吧。兔子或狗熊谁跳得更高?请说:兔子或狗熊。
gm982     让我们想一想。谁跳得更高--兔子还是狗熊。
gm985m     免子,猜对了。如果这只小免子不是一个玩具,它会兴高采烈地跳起来(一连串的嘣嘣声)。
Gm990     我希望看到一只狗熊跳起来,但我不希望它砸在我的身
上。
gm1005     这是玩游戏的非常好的方式,让我们再尝试玩一些不同的东西吧,讲个故事或唱个歌怎么样?你告诉我:故事或唱歌。
gm997     选择我们将要做的事,请说:故事或唱歌。
图19A~19C共同构成由图10所示″PLAY--玩玩具″子模块所执行的一个歌曲脚本的可能的实现的一个简化的操作流程图。如果与下列的动作标识符和动作相结合,可对图19A~19C的实现更好地加以理解:
唱歌菜单
音频     文本
Sng305     ″有兴致唱一支歌,是来自外层空间的艾丝吗?好极了!让我们再唱一遍那支喝粥的歌吧,快点,随我一起唱。″
Sng310     ″有兴致唱一支歌,彩虹今天的天气不错吧?好极了!让我们再唱一遍那支喝粥的歌吧,快点,随我一起唱。″
Sng315     ″有兴致唱一支歌,泡泡糖,好好地消磨一下时光?好极了!让我们再唱一遍那支喝粥的歌吧,快点,随我一起唱。″
Sng320     唱歌,唱歌,我们有兴致唱歌。
Sng=prog     短片″碗豆粥″
Sng370     ″你希望我接着把这支歌唱完吗?请说:是或否。″
Sng390     那首歌使我想起金发小姑娘的故事,你想起来了吗?金发小姑娘喜欢让她所要喝的粥不凉也不热!
Sng395     ″我刚刚想起另一支好歌,我们可以听另一支歌、玩游戏或讲故事。只要说:故事、游戏或唱歌。″
Sng410+     好,现在让我们唱另一支好歌。请听…[唱短片—HEAD ANDSNG_HANDSHOULDERS]。
sng415     多好听的歌呀!这是多么好的练歌的方法呀!现在你想玩游戏还是想听故事?请说:游戏或故事。
sng425     我有兴致玩一个好游戏或听一个好故事。我们做什么,由你来决定。请告诉我:游戏还是故事。
图20A~20C共同构成图17A~17E所示″兔子短片″故事脚本的一个可能的实现的一个简化的操作流程图,并由图10所示的″玩玩具″子模块加以执行。与下列的动作标识符和动作相结合,可对图20A~20C的实现更好地加以理解:
兔子短片
音频     文本
Rb3005m     音乐
Rb005m     (叹息声)当饥饿的女人向她的碗橱里张望时,说了一声″天哪!″。(打开碗橱的吱吱声)。碗橱几乎是空的,除了一罐…,什么也没有剩下。你来决定罐子里有什么?蜂蜜、花生酱或果汁软糖?
rb015     你来决定罐里有什么?请说:蜂蜜、花生酱或果汁软糖。
rb026     有蜂蜜。
rb0301     蜂蜜!!甜美、可口、粘稠的蜂蜜,是蜜蜂酿造的,狗熊特别喜欢。
rb0302     花生酱!!特别甜、特别粘的花生酱,粘你的上牙堂。
rb0303     果汁软糖。甜腻腻的、白色的、从里到外都特别粘的果汁软糖,与花生酱一起吃十分可口!
rb3050m     她爬上碗橱伸手够放在那里的一个罐子。(女人伸手够东西的声音),但她不小心,没能牢牢抓住罐子…罐子摔到地上,摔得粉碎(玻璃落地和打碎的声音)。
rb3055     粘稠的蜂蜜开始在地板上流淌。
rb3060     粘稠的花生酱开始在地板上流淌。
rb3065     粘稠的果汁软糖开始在地板上流淌。
rb090m     ″现在我必须把撒落的东西打扫干净,以免地板变得越来越脏。嗳,我的拖布哪儿去了?″[开门和关门的声音]。咳,对了!我把拖布借给了邻居YoursIsMine(你的就是我的)先生了,他借东西从来不还。
rb3075     她穿上她那邋塌的破鞋,冲出房门。这时一个长着毛茸茸的小脑袋,一对儿长长的尖耳朵、一个粉红色的鼻子以及一个象棉团儿一样翘起的尾巴的家伙出现在窗台上(唧唧声和动作声)。
rb110     你认为它是什么?一只大象?一只老鼠?或一只小免子?请你告诉我:长颈鹿、大象或小免子。
rb120     不对...大象长有长长的鼻子,不是长长的耳朵。
rb125     不对...长颈鹿长有长长的脖子,不是长长的耳朵。
Rb130     是一只小免子!是你所见到过的最讨人喜爱的小免子!这只小免子的名字叫BunnyOne。(嗅东西的声音)这里肯定有特别好吃的东西。
rb195     此时,小免子们变得兴奋起来,它们开始上窜下跳,就象BunnyOne开始做得那样。
rb200     地跳。我每说一次″嘣″,你就再跳一次。当你想停止时,就捏我的手。你能象小免子一样地跳吗?当我说″嘣″时,你就象小免子一样
3-bongs
rb220m     当BunnyOne嘣嘣地跳开时,另一只小免子一BuunyTwo跑过来。BuunyTwo比BunnyOne更加好奇,立即趴在窗台上偷看。″嘿,BunnyOne,″BuunyTwo喊。
rb230     让我们进去,把它吃光。″嗨,我不知道这是不是一个好主意...″BunnyOne说。″我们可能会遇到麻烦″
231m     音乐
Rb235     BunnyOne说完那些话不久,第三对儿长耳朵也从窗台上向屋子里偷看。你猜它是谁?
Rb245     你猜对了!你是怎么知道的!这太有意思了,我们一起来讲这个故事吧!
rb3155     它的名字BuunyThree!
rb3160     Buunythree看了看BunnyOne和BuunyTwo,猛地跳到蜂蜜中间,并开始舔吃起来。
rb3165     BuunyThree看了看BunnyOne和BuunyTwo,猛地跳到花生酱中间,并开始舔食起来。
rb3170     Buunythree看了看BunnyOne和BuunyTwo,猛地跳到果汁软糖中间,并开始舔食起来。
rb3175     BunnyOne和BuunyTwo看了看正在舔食美食的BunnyThree,也跳了过去。
rb2751     然而,正当三只小免子在一点儿一点儿地舔食蜂蜜时,它们听到了脚步声。
rb2752     然而,正当三只小免子在一点儿一点儿地舔食花生酱时,它们听到了脚步声。
rb2753     然而,正当三只小免予在一点儿一点儿地舔食果汁软糖时,它们听到了脚步声。
rb280m     音乐
图21A~21F共同构成图17A~17E所示″BunnyLong″故事脚本的一种可能的实现的一个简化的操作流程图,它由图10所示的″Play--玩玩具″子模块加以执行。对照下列的动作标识符和动作列表,可以更好地对图21A~21F所示的实现加以理解:
兔子长命
音频     文本
rb280m     (紧张的音乐声)。
rb285     ″嘿!小免子们--让我们走吧,″BunnyOne悄声地说。它是我们所知道的这些小免子中最好奇的一个″好,我们离开这里,″BuunyTwo和Buunythree回答。但当这些小兔子试图离开时,它们大吃一惊,原来它们被粘住了。
rb2901     粘在了蜂蜜浆中。
rb2902     粘在了花生酱团儿中。
rb2903     粘在了一层甜腻腻、粘乎乎的果汁软糖浆中。
Rb295     ″我们该怎么办?″BuunyTwo问。
rb2961     (旁白)泡泡糖,不要担心,这三只小免子总是能够从险境中逃脱的。
rb2962     (旁白)艾丝,不要担心,这三只小免子总是能够从险境中逃脱的。
rb2963     (旁白)彩虹,不要担心,这三只小免子总是能够从险境中逃脱的。
rb297m
rb300     门打开了,HungryMan走了进来,他遇到了从YoursIsMines家中取回拖布的HungerWoman。
rb3051     ″看来你是想告诉我,我们的全部午餐就是面包和蜂蜜。″
rb3052     ″看来你是想告诉我,我们的全部午餐就是面包和花生酱。″
rb3053     ″看来你是想告诉我,我们的全部午餐就是面包和果汁软糖。″
Rb315     当他走进房门并看到三只小免子粘在地板上时,他说:″对于一只免子来说难道那还不够吗?″
rb316m
Rb320     ″宝贝儿,我知道你总是愚弄我,但当我饿了的时候,你从来也不会愚弄我,免子是我最喜欢的晚餐。″
Rb330     ″嘿,让我们走吧,″BunnyOne悄声说。″对,我们必须马上离开这里,″BuunyTwo和BuunyThree回答。但当这些小兔子试图离开时,它们发现它们脚被牢牢地粘住了。
Rb335     HungerWoman走了进来,在看到小免子之前,她没有意识到HungryMan正在说些什么。她说:″(咯咯笑声)--是的,亲爱的。我就是在开玩笑。美味儿的免子将成为你的晚餐,为什么不呢?你来抓免子,我去找木头点火。″
rb345     ″不必抓它们,″HungryMan说。″那些小免子真不错,它们被粘住了...动不了。我到花园去刨点马玲薯。到火烧旺时,我将回来帮助你把免子放到锅里。说完他匆忙走出去了。″
rb346m     (脚步声逐渐消失,关门的声音)。
Rb350m     ″我们现在该怎么办?″BuunyThree问--它已不再那么勇敢。″让我们跳出去,″BunnyOne说。于是它们试图跳起(失真的嘣声),再试着跳起(嘣),但它们纹丝儿未动。
Rb355m     HungerWoman和HungryMan拿着点火用的木头走了进来,他们正在快活地吹着口哨,因为他们觉得他们很快将会吃上一顿丰盛的美餐。他们开始点火,向锅里活添水,火烧得越来越旺,他们口哨也吹得越来越响(背景音乐为口哨音)。这时,小免子们却一个个木呆呆地站立在那里。
Rb360     你能站得象雕像那么稳吗?如果你想试着当一座雕像,那么你将会象小免子们一样。捏我的手,然后静静地站着。当你已完全成为一座雕像时,请再捏我的手。
rb370     ″好,那么现在你已是一座雕像了,我将等你,直至你捏我的手。″
rb375     ″在你扮演雕像之前,请捏我的手。″
rb382     要成为一座雕像需要很长的时间。
rb385     ″再添点儿木头,把火烧得再旺些,然后我们就可以做饭了,″HungerWoman对她的丈夫说。他们俩都出去了,准备寻找更多的木头。
rb386     (声音效果)
Rb390     ″你听到了没有?″BuunyTwo愤怒地悄声说。″我们该怎么办,怎么办呢?″″让我们试着再跳一次,″BunnyOne说。
Rb395m     彩虹,你知道,你可以帮助它们。当你听到[嘣]的一声时,尽可能地往高处跳。
Rb400m     艾丝,你知道,你可以帮助它们。当你听到[嘣]的一声时,尽可能地往高处跳。
Rb405m     泡泡糖,你知道,你可以帮助它们。当你听到[嘣]的一声时,尽可能地往高处跳。
Rb410m     [嘣]的一声,小免子们使劲儿地跳了一下。[嘣],它们又跳了一次,[嘣],它们又跳了一次。
rb4151m     再跳一次[嘣],它们摆脱了蜂蜜浆。
rb4152m     再跳一次[嘣],它们摆脱了花生酱团。
rb4153m     再跳一次[嘣],它们摆脱了果汁软糖浆。
rb4201     你知道这是为什么吗?因为火烧得越来越旺,蜂蜜就变得越稀,最后稀得足可使小免子们拔出它们的脚。
rb2402     你知道这是为什么吗?因为火烧得越来越旺,花生酱就变得越稀,最后稀得足可使小免子们拔出它们的脚。
rb4203     你知道这是为什么吗?因为火烧得越来越旺,果汁软糖就变得越稀,最后稀得足可使小免子们拔出它们的脚。
Rb425m     又一跳了次[嘣]的一声,它们跳上了窗台,然后跑出花园,并仓皇奔逃走。
rb426m     (音乐)
rb435m     就在这时,HungryMan和HungryWoman带着木头和马玲薯走进房间,而且嘴里哼着他们最喜欢的歌曲(背景音乐PeasPorri dgeHot--热豌豆粥)。
Rb440     他们走进来,恰好看到他们眼看到嘴的免子晚餐跳走了,并跑进了花园。
rb445     它们一边跳,一边高兴地唱歌(背景音乐为
HoneyontheTable--桌上的蜂蜜)
图22是图17D、18C、19B以及19C所涉及的″ThemeSection--主题部分″的一个简化的操作流程图。主题部分向用户提供了对整个应用的一个总的介绍和一个教学部分。
附录A是以上所述交互式玩具系统的一个优选的软件实施例计算机列表。本发明的交互式玩具系统软部件的一个优选的实现方法描述如下:
1)提供一台可运行WINDOWS95操作系统的计算机;
2)附录A中如下标记的源代码:
*Installation Source Code(安装源代码)
*Application Source Code(应用源代码)
*针对语音识别的ActiveX源代码
*CREAPI.DLL
*CRPRO.DLL
*BASEIO.DLL
*Toy Configuration Source Code(玩具配置源代码)
编译成可在步骤1)中所提供的计算机上执行的相应的可执行文件;
3)安装针对WINDOWS95的″Automatic Speech RecognitionSoftware DevelopmemtKit(自动语音识别软件开发工具)3.0版″,来自Lernout&Hauspie话音产品、Sint-Krispisnstraat7、8900 Leper、Belgium。
4)把附录A中以如下标记的源代码:
*BaseStation Source Code(基站源代码)
*ToyControl Device Source Code(玩具控制设备源代码)
编译成相应的可执行的文件,并分别安装进图5所示的基础通信单元62和图5所示的玩具控制设备24中。
5)运行对应于Installation Source Code(安装源代码)的可执行文件。
6)运行对应于Toy Configuration Source Code(玩具配置源代码)的可执行文件。
7)运行对应于Application Source Code(应用源代码)的可执行文件。
应明白,这里所展示和所描述的交互式玩具系统的操作,不仅考虑到普通日期的情况,而且也将考虑到诸如节假日以及孩子的生日等日历信息,例如玩具可以在孩子的生日输出特殊的消息,或可在夜晚生成一个″疲劳的″面部表情。
较理想的做法是,至少这里所展示和所描述的玩具装置的某些处理功能可由一台通用的或家庭计算机(例如一台PC)加以提供,并使这一计算机能够以任何合适的方式与玩具装置进行通信,典型地为无线通信,例如无线电通信。更可取的方案是,一旦玩具得以建立,包含玩具处理功能的PC程序运行在后台方式中,允许其它用户,例如成人在孩子们玩玩具的同时,把家庭计算机用于他们自己的其它应用。
与本发明共有未决的PCT申请--PCT/IL96/00157、共有未决的以色列的专利申请--121574以及共有未决的以色列的专利应用--121642,描述了一些在生成计算机化的玩具过程中使用的技术与装置,本发明把它们所公布的技术与装置并入此处,以作参考。
在本专利文档的公布中,有一个其所包含的内容必须得到知识产权保护的部分。若本专利文档或专利公布中的某一技术或装置出现 在美国专利和商标局的专利文件或记录中,则知识产权的拥有者不反对按本专利文档或专利公布对这一技术或装置进行精确的复制,除此之外,知识产权的拥有者保留所有技术或装置的知识产权。
在本发明的说明书和权力要求书中,术语″计算机化的创造物″或″计算机化的活的创造物″用于表示那些可由计算机控制的创造物,它们既可以是存在于计算机屏幕上的虚拟的创造物,也可以是具有实际、有形身驱的物理的玩具创造物。一个创造物既可以是创造物,也可以是人,甚至可以是其它形式的物体。
″把生命赋予″一个创造物,指的是把类生命的行为赋予创造物,典型地通过定义自然人与该创造物至少一个交互加以实现。从创造物的角度来看,更理想的做法是,这一交互包括由那些由自然人所表露的情感的觉察。
一个″自然人″指的是一个由上帝所创造的人,且在传统世界的感觉上是活的,而不是针对虚拟人、玩具人以及玩具娃娃等。
现在参照图23A~23B,它们共同说明了符合本发明的一个优选实施例的一个计算机化的活的创造物的开发与操作。图23A显示了一个物理的创造物,而图23B显示了一个虚拟的创造物。
如图23A和23B所示,它们提供了一个用于教授交互计算机化结构开发的教学设施,典型地包括一系列学生工作站310和一台教师工作站312,它们通过一条总线314与一台教学设施服务器316互连。教学设施服务器316可向教师工作站312和学生工作站310提交适当的内容。更可取做法是,提供一台创造物生命服务器318(这里也称作″创造物支持服务器″或″创造物生命支持服务器″)。如以下所描述的,这一服务器为一个创造物324提供了由学生编程的类生命的功能。也可把服务器316和318合并为一台单一的服务器。作为进一 步的选择,可提供多台创造物支持服务器318,每一台支持一个或多个计算机化的活的创造物。还有一种选择(未在图中加以显示)是,提供一台单一的中央计算机,学生和教师工作站可由那些通过中央计算机加以支持的终端组成。
如图23A所示,理想的方案是,把创造物生命支持服务器318与一个计算机无线电接口320相藕合,而这一接口最好与一个在计算机化的活的创造物324中的一个相应的控制器322进行无线通信,由此对计算机化的活的创造物324的动作与响应加以控制和存储,以及最好把其内部化的经验加以保存与分析。
由创造物生命服务器318所提供的计算机化的活的创造物324具有一系列不同的拟人的感觉,例如听觉、视觉、触觉、温感、位置感和最好这些感觉的合成以及可由学生编程的感觉,例如触摸的感觉,这些感觉可通过适当的与计算机化的活的创造物相关连的音频、视频、接触、温度以及位置传感器来提供这些感觉。另外,按照本发明的一个优选的实施例,计算机化的活的创造物324被赋予一系列拟人的表达方式,例如言语、动作、面部表情以及各种表达方式的组合形式,例如高兴、生气、悲伤以及惊讶等。这些表达结构可通过利用适当的机械和电子机械驱动器而得以实现,并可通过创造物生命服务器318根据学生的程序得以生成。
现在参照图23B。可以看出,一个虚拟的计算机化的活的创造物可以在计算机338的显示器336上得以创建,计算机338可直接或通过网络(例如Internet)与总线314相连。更可取的做法是,为虚拟的计算机化的活的创造物334赋予一系列不同的拟人感觉,例如听觉、视觉、触觉、温感、位置感,最好还赋予这些感觉的合成,例如触摸感。建议的做法是,通过把麦克风340、照相机342、触摸垫或其它 触摸输入设备344与计算机338相关联,来提供这些感觉。
更理想的是,还可把一个扬声器346与计算机338关联在一起。服务器348典型地既可执行图23A所示的教学设施服务器316的功能,也可执行图23A所示的创造物生命服务器318的功能。
另外,根据本发明所优选的实施例,需赋予虚拟的计算机化的活的创造物334一系列拟人的表达方式,例如言语、动作、面部表情以及各种表达方式的组合形式,例如高兴、生气、悲伤以及惊讶等。它们是由适当的传统计算机技术加以实现的。
本发明一个较好的特性是,在计算机化的活的创造物以及在与其交互的人这两个方面,都能通过适当的编程,基于以上所提到的拟人的感觉和表达方式,为计算机化的活的创造物提供与人的交互能力。更可取的是,能够令这些交互包括上述感觉的组合及表达方式的组合。
图23C是图23A~23B所示系统的一个衍生系统的半图示、半结构化的简化图。该系统提供了一台远程内容服务器340,提供把生命赋予创造物324所用的数据、程序、话音文件以及其它内容。
图24A是学生利用其中一台仿真显示器对该创造物进行编程的图形表示,编程是通过该学生与该学生的工作站310交互作用来实施的。这种交互可以是语言的或可以通过其它合适的输入设备如键盘或鼠标来完成。
在说话以及“停止”之前的命令“播放记录”意思是该学生工作站应在“播放记录”之后记录由该学生发出的说话内容,直到“停止”但不包括“停止”,并把说话内容存储在一个语音文件中,同时该创造物的生命服务器318应指导该创造物324发出存储在该语音文件中的说话内容。
“If-then-endif”,“语音识别”“语音类型”“and”以及“or”都是控制字或命令或编程指令,如图31所示。
图24B是人与计算机化创造物的语言交流的图形表示,其中该交流是学生按照上面描述的参照图24A进行编程的结果。
图24C是配备有内置的视频照像机342和视频显示器582如液晶显示器(LCD)的创造物324的图形表示,该视频照像机为该创造物提供了视觉输入并且通过该创造物或无线通信到计算机。该显示器可以使该计算机为用户提供更为详细的信息。在图中,该显示用于提供更细致、更灵活的表情如眼睛、眉毛。彩色显示器可以使计算机调整眼睛的颜色以适应用户或其它主题。
本发明的一个特定的特征是提供有教育工具来培训工程师或编程者来生成交流指示。一个教师可以为全班的学生确定一个整体项目,如对一个警察的行为进行编程。他可以定义一些可以分成特定事件的总的条件,而每一个事件可以分给一个学生用于编程一个交互的套件。
例如,警察的行为可以分成如下模块:与受害人的亲属进行交流,与同事、老板进行交流,与要进行犯罪控诉的控诉方进行交流,与嫌疑人、同伙及目击者进行交流。根据所涉及的犯罪是谋杀、暴力中的非谋杀、恶意犯罪、侵犯财产犯罪等,每一个交流以可以分成子模块,而每一个模块或子模块可以分给不同的孩子。
类似,一个项目又可以包括对学生的行为的编程。换句话说,该情绪化理解性的创造物是学生,该项目可分成例如如下的模块:面向教师的行为、面向模块的行为以及面向其他孩子的行为。面向其他孩子的行为又可以分成如下的子模块,如秘密俱乐部的成立、一起学习、闲谈、请求帮助等。
为编程一个特定的子模块,一般要求学生至少执行下列子模块中的一些:
a.选择触发进入他的子模块的初始事件。听到单词“俱乐部”可触发进入“成立秘密俱乐部”子模块,这些初始事件可以形成该模块的状态机的一部份或者可以优先地被连带的学生或教师合成一个主程序,该主程序可以根据各种事件的发生调用各种模块。
b.列出与该对话相对应的主题以便维持在该学生与靠近该学生的某人之间。例如,为成立一个俱乐部,该俱乐部一般需要一个名称、会员清单、密码、标志、规则等。
c.确定这些主题之间的关系。例如,一旦建立了会员清单,该密码需要被传送到会员清单上的所有会员。
d.在该学生与该某人之间提供一个分支对话框,设计成该学生的每一个意见均会引起该某人一个响应,该响应可以很容易地被加以分类。例如,该学生可能希望只问有限选择的问题而不是自由回答的问题。例如,如果学生问“该标志的颜色应是什么颜色,白色、黑色或红色?”,那么系统只需要识别三个单词中的一个。
e.确定如何检测情感及决定在学生-该人的关系中不同情感的角色。例如,结合该某人,如果该学生正在定义该成员清单,该学生可能就会注意到该某人正在变得感情丰富,该学生可因此选择建议终止该成员清单或表现得感情专注。可选地或附加地,对于该某人三个或四个不同的感情状态,该学生的每一个意见可以有稍许不同的文本。
其它项目包括对教师、父母、宠物、销售商、名人等的行为的编程,应明白,项目的范围是无限制的。
应明白,对一个情绪上有知觉的生命的编程的复杂性会预料到 产生娱乐条件,由此该情绪上有知觉的生命会以一种有缺陷的方式运行。于是,通过使学生错误与一个诙谐的结果联系起来而缓解伴随该学生错误或学生失败条件的压力,希望增强学习条件。对一个情绪上有知觉的生命的编程的困难并不是实施这里所显示及描述的系统的困难,因为系统的目标是教育性和正确性,而情绪上有知觉的生命的完整功能只是一个艺术品,而不是该系统和目标。
而且,虽然对一个情绪上有知觉的生命的编程是非常困难的,甚至过份单纯化的感情敏感性(当由一台机器规划好时)对于人与该机器的交互产生很大的影响。因此,感情理解力的编程,即使在初级水平上,都是一个有所回报的活动,因而能激发学生通过实践增强其编程的能力。
图25是一个系统管理器的优选功能的简化软件图,最好其中的一个教师工作站312作为一个系统管理器工作站使用。
图26是系统中教师工作站312的优选功能简化软件图,该功能用于指导开发交互式计算机化指示,如图23A-23C中系统。
学生管理功能(图25中的单元715)典型地包括常规功能,如学生注册、学生特征的统计分析、学生报告的生成等。
集成化(单元740)可以通过多组学生或该教师来执行,该教师工作站为该教师提供一个定义各模块被组合的顺序的集成方案。
运行管理功能(单元750)用于管理多个生命服务器318。例如,一个教师在其布置阶段15上可能具有由3个创造物生命服务器控制的创造物和由300个学生开发的30个项目,并且每一个包括几个项目模块,其中的某些项目模块是可选的。运行管理功能使教师能够确定:在某一确定的天和时间,利用一特定的项目,一特定子集的创造物将被一特定的创造物生命服务器所控制。如果该项目包括了 可选模块,教师可以定义使用其中的哪些。
图27是系统中学生工作站310的优选功能简化软件图,该功能用于指导开发交互式计算机化指示,如图23A-23C中系统。图27中的分析和设计方块815典型地包括字处理功能、画流程图功能和允许学生归档他对该项目模块的分析的数据库规划设计功能。
图27中的视觉编程方块840优先运行以使得学生能定义和参数化软件对象以及使这些对象与其他对象相联系。
软件对象包括:
子模块;诸如时间事件、口语事件、数据库事件、传感器事件以及上述事件的组合的事件;诸如动作功能、讲话(回放)功能等的功能;针对状态机的状态;以及并行运行的任务。
例如,视觉编程的典型会话包括如下步骤:
a.学生选择“视图”,然后是“状态机”,以便观察当前定义他所在班级所分配的项目中的模块的状态机。作为响应,系统向学生显示当前的状态机。
b.学生选择“插入”,然后是“状态”,由此加入一个新的状态到该状态机。
c.学生选择“插入”和“连接”,以便将新的状态连接到状态机中的已有的状态。
d.学生为所选择的连接定义一个事件和功能,该功能可以从功能选项下列出的已有功能中选取,也可以利用程序块选项及第三代编程语言如Basic或者通过打开该功能内的一个状态机来生成。
选择可以通过合适的接口机制来实施,如工具框的图标的下拉或从一个菜单条进行选择以及随后从与菜单条项相关的菜单中选择。
视觉编程单元840一般允许学生选择多个“视图”中之一,而每一个这样的“视图”都包括一个由该学生如此编程的此模块的不同的说明。该视图例如可包括:
a.在赋给该学生的模块内的子模块;
b.在该模块内的事件列表。事件典型地包括:时间事件,传感器事件,语言事件,数据库事件(如数据库内的一个特定的计数器达到零)以及上述事件的组合。一个事件可以从scratch中产生、修改或与一个源状态和目标状态之间的已有连接相关联;
c.表明该模块内状态及其间的连接的状态机;
d.任务列表,其中每一个任务包括一序列功能和/或模块,并且在任务之间定义了一个关联以便允许不同的任务可并行地执行;
e.在该模块内的功能列表,功能典型地包括语言功能,如谈话、语音识别和记录,致动器功能,如电机功能和点火功能,数据库功能,如对存储在该数据库中数据进行的计算。
一个功能可以从scratch中产生、修改或与一个源状态和目标状态之间的已有连接相关联。
在每一个视窗内,该学生可以修改或增加在该视窗内所表现的模块的各个方面。例如,为修改与该状态机内的个别连接相关联的一个事件,该学生一般可以访问该事件列表并修改该事件的定义,或者,学生或可以访问该状态机并选择一个不同的事件以与该个别连接相关联。
图28-31是屏幕显示的例子,是针对视觉编程单元840的一个人机接口的部份。如图28中菜单条所示,学生最好可以选择执行下列活动之一:
常规文件操作,常规编揖操作、视图操作、插入操作、仿真操 作以及常规的窗口及帮助操作。
利用该视图菜单,也如图28中所示,该学生可以选择观察他所开发的该模块的各种表示,例如项目图示、模块图表以及任务列表等。
在图28中,该学生可以选择在该视图菜单内的连接。作为响应,一般在屏幕在显示该学生,以及在其模块内的已有状态机连接的列表。该学生也可以选择一个或另一个连接。如所示,该学生已选择了连接t6,作为响应,学生可以看到连接t6的参数据的屏幕显示,包括连接源和目标状态,与该连接相关的事件和功能。
一般地,每个功能是一个或多个原始功能如“播放”“记录”“设置表达式”的组合。
图29说明在响应学生从该视图菜单选择状态而产生的一个模块的状态机视图。如所示,在状态表中显示了互连,其中该创造物从一个状态移动到另一个状态,其中从一个状态移动到另一个状态是根据在状态之间出现的事件的发生而有条件的,并伴随有在状态间出现的功能的发生。
例如,在状态2与状态6间的转移与事件7和功能7相关联。这意味着:当该创造物处于状态2时,如果它检测到事件7,它就执行功能7并移到状态7。
例如,事件7可以是该自然人兴奋,这是一个复杂的事件,是几个原始事件如高声、高调、在语句末的音调的增加以及由语音识别单元检测到的“兴奋”等的组合。功能7例如可以是下列消息的发送:“你今天看起来非常地高兴,对吗?”。
状态6例如可以是一个对情感诊断状态确认的等待,其中该创造物等待该自然人确认或拒绝该创造物对该自然人正处于“高兴” 的理解。
状态2例如可以是情感改变状态,其中已经检测到情感的改变,但新的情感还没有被特征化。
“U”表示从一个状态到另一个状态的无条件改变。
在图30中该学生正通过插入一个新的功能来修改该模块,该功能试图与该状态机内的状态-状态的连接相关联,正在显示该学生正在插入的功能是“记录2秒”。
应明白,在观察选项(图28)下的功能选项可被用来定义作为一序列已有功能的功能。
图32的屏幕显示包括一个项目的状态机观察的说明示例。如所示,在状态间的每一个连接的特征在于一个事件和一个功能。事件的发生导致功能的执行以及进程从当前状态流到下一个状态。例如当系统处于状态1时发生事件E1,那么系统执行F1并进到状态6。
在图32中,状态由椭圆、事件由菱形、功能由矩形表示。为了对一个连接插入一个事件和一个功能,学生可以从图32的显示选择所期望的连接,然后在视觉编程的主菜单条中选择插入,然后依次选择功能和事件。
图33的屏幕显示使学生能创建一个能测试先前生成的模块的环境。为此,学生一般要按如下去做:
a.学生生成激励该模块的软件仿真(开始设置);
b.学生生成处理到该模块的输入和来自该模块的输出的的仿真环境。也就是,在步骤b生成的仿真环境仿真性地提供到该模块的输入以及,按照该模块的仿真性输出接收和动作,使该环境又作用回到该模块。
c.学生定义一个监视该模块的性能的设置。一般地,学生定义某 个被检测到的事件将被显示到屏幕上以及某个被检测到的事件被记录到一个日志文件。
d.学生执行仿真,同时监视该屏幕;以及
e.学生观察该日志文件的内容。
图34-37是说明由图23A、23B或23C的教师工作站312提供的屏幕显示的例子。
特别是,图34是在图26的学生管理单元715内生成的屏幕显示的例子。如所示,该屏幕显示使教师能进入和修改学生标识的细节以及观察赋与每个学生的项目和模块,尤其是项目和模块的状态。该模块也可以允许教师给学生分配一个标记。可选地,分配标记也可以是执行监视的一部份(单元760)。
学生对项目与模块的分配一般地在项目模块分配单元730内来执行,如下面参照图35所描述的。
图35是在图26的项目模块分配单元730内生成的屏幕显示的例子。如所示,教师一般从一个项目菜单中选择一个项目,该项目菜单一般地显示每一个项目的属性如难度级别、模块数量等。在图13中,教师选择了“警察”项目。如所示,在该项目内有几个模块。
教师也可以选择一个班以执行该项目。在图35中,教师选择了3A并且作为响应,屏幕向教师显示班3A中学生清单。
该屏幕还向教师显示在该“警察”项目中模块清单,然后,通过单击在学生菜单中的所选学生,教师分配一个或多个学生给每一个模块。
图36是在图26的集成监视单元740内生成的屏幕显示的一个例子。如所示,教师一般确定模块被集成以形成该完整项目的至少一个序列。一般地,系统画出彼此要集成的模块间的连接的图形表 示,而每一个这样的连接被标记以一个日期和一个状态指示(集成/非集成)。
图37是在图26的分配运行单元755内生成的屏幕显示的一个例子。该分配运行单元在所生成的创造物是一个自然创造物而不是一个虚拟创造物时显得特别重要。如果是这种情况,则该自然创造物是一个可被多个学生共享的稀有资源。如所示,该教师典型地从一个可用的自然创造物池中选择一个自然创造物,如红警察,当工作在该警察项目上时,在教师定义的时间内,所选的自然创造物执行由该教师的学生所定义的功能。如果两个不同的模块被分配到同一时间和同一创造物,亦即,如果指示红色警察运行在“犯罪关系”模块和“嫌疑”模块,那么该教师定义一个优先权系统以便这种跨越最小化。
图38是该过程的简化流程图示,借助于此,学生典型地使用图23的学生工作站310。
在执行图38的步骤910和920过程中由该学生执行的过程的流程图说明将参照图41进行说明。
如所示,一开始,教师或项目策划者定义状态,即表情范畴(高兴、悲伤、愤怒)。
一个学生按照从人那里记录/接收的语言输入的内容和/或特征,在运行中定义每一个表情范畴。该学生将到分区表情的事件定义进范畴。语言输入的特征包括:语音幅度,语音音调、说话频率以及用词质量。
学生显性地定义一个问号确认各种表情范畴。学生定义每一个问号为一个状态、每一个问号为一个功能以及每一个问号的结果为一个事件。
学生和/或教师根据人的表情的范畴确定与人交流的修改。
图39是通过在学生工作站10内的插入菜单中选择事件所产生的屏幕显示一个例子。如所示,被选择的事件包括关闭各种开关,尤其是,该事件包括关闭在该创造物的右手侧的开关或关闭在该创造物的右足侧的开关。
图39是通过在学生工作站10内的插入菜单中选择功能所产生的屏幕显示一个例子。如所示,被选择的功能包括一个眼睛移动,尤其是,该功能包括移动该眼球到左侧。
本发明的较佳实施例及其相关技术将参照附图42-68加以说明。
LOLA应用的一个优化结构在图42-68图表中加以描述。
LOLA系统是一个由几个主进程构成的分布式应用。地址和数据的空间界限分离开可驻留在一个计算机或该网络内的不同计算机上的这些进程。这些进程使用标准的中间件(MW)如CORBA/DCOM/RMI以便彼此进行透明地通信。
这些主进程包括:
任务分配器:
这些部件运行在与活(living)对象进行通信的每一个无线电基站,在这些部件内的主要子部件在图42-68中加以描述。
代理对象:
责任:系统中每一个活对象都有一个表示它的相应对象。对一个活对象所做的所有操作都在其代理对象上首次激发,并且由活对象生成的所有事件都在其代理对象内首次接收。而且,该代理对象负责存储和跟踪每个活对象的状态。该代理对象是一个远程对象以便允许进程间通信。
代理所使用的服务(协作):
*代理正使用所提供的Java Bean以便激发操作和接收来自活对象的事件;
*安全管理器以便检验一个请求的操作是否是合法的;
*日志和事件服务以便记录消息和生成事件;
提供给其它部件的服务:
*由该分配器产生的任务与该代理们进行本地交互;
*IDE可以与代理交互以便允许远程调试或执行;
*管理控制台可以与该代理远程交互以便激发诊断与监视操作;
分配器引擎:
责任:从任务管理器获取用于执行的已注册的任务,并以独立的线程执行每一个任务。该任务运行在灰箱(sandbox)内以便加强安全策略。
由该分配器使用的服务:
*任务管理器以便接收所注册的任务;
*所产生的任务使用代理对象以便激发对活对象的操作;
*定时器,以便接收时间事件;
*日志和事件服务,以便记录消息和产生事件;
提供给其它组件的服务:
*IDE可以与该分配器交互以便协作远程调试或执行;
*管理控制台可以与该分配器远程交互以便激发诊断与监视操作;
定时器:
责任:为注册的听众产生时间事件。
由该定时器使用的服务:
*该定时器并不使用由LOLA系统提供的任何服务,它只使用OS 服务。
提供给其它组件的服务:
*该分配器在该定时器中注册以便接收时间事件。
LOLA服务器:
该组件向系统中所有的其它组件提供所需要的服务,在此组件中的主子组件在图42-68中加以描述。
日志服务器:
责任:该日志服务器负责记录系统中其它组件的日志消息,并按照几个标准检索这些消息。日志消息跟事件不一样,它只是日志,即,它仅记录信息,而不是期望会根据此日志消息触发某些动作。
由该日志服务器使用的服务:
*永久存储服务,以便将日志永久保存。
提供给其它组件的服务:
*该分配器和该代理记录在任务执行期间的某些任务;
*管理控制台和学生IDE,以便跟踪某些特定任务的执行;
*教师管理控制台,以便接收关于任务执行的统计。
监视引擎:
责任:监视器引擎负责接收来自系统中其它部件的事件,并且根据事件-条件-动作逻揖而动作。该监视器引擎在系统范围的基础上提供这种逻揖,即便是该部件可以另外地驻留在每个无线电基站以便允许事件的本地处理。
由监视器引擎使用的服务:
*永久存储服务,以便永久地保存策略和所接收的事件。
提供给其它部件的服务:
*在任务执行期间或当测试系统的安全性时分配器和代理产生事 件。
*管理控制台,以便接收事件并相应地进行动作。
安全管理器:
责任:该安全管理器将系统中的所有的用户、组及角色保存在一个库中,并且根据它们来决定谁有权做何种事。
由该安全服务器所使用的服务:
*永久存储服务,以便永久地保存用户、组和角色。
提供给其它部件的服务:
*代理,以便确认在其上所触发远程操作。
*任务管理器,以便确认允许特定的任务注册。
任务管理器:
责任:该任务管理器把系统中所有的任务保存在一个库中,并据其向无线电基站提供所应执行的任务。
由该任务管理器使用的服务:
*永久存储服务,以便永久保存这些任务。
*安全管理器,以便确认任务注册。
提供给其它部件的服务:
*无线电基站,以便接收所注册的任务。
管理控制台:
该部件是管理员的控制台,监视和控制系统的动作以及配置系统等,而且,该控制台可以使教师查询系统以便制作一些任务,如评估学生工作,或分配给学生执行某些特定任务的许可。
在该部件中的主要子部件示于图42-68中,在图中也示出了这些部件的在线观察。
责任:该控制台用于联机监视和控制该系统,观察诸如在每个 无线电基站上运行的任务之类的东西,以及每个活对象的状态和情况。触发例如改变一个特定的活创造物的信道的操作的能力,以及观察系统中产生的所有事件的能力。
由联机观察所使用的服务典型地包括:
*代理对象,以便触发其上的操作及从中接收事件;
*分配器,以便以一种在线方式监视和控制任务的执行;
*监视器引擎,以便在系统范围基础上接收事件。
提供给其它部件的服务:
*在线观察仅是一个GUI客户。
在图中示出了配置视图。
责任:在其运行时用于配置系统的控制台,如定义用户、组及角色的配置由控制台进行。
由该配置视图所使用的服务:
*安全服务器,以便授权经触发的操作。
提供给其它部件的服务:
*配置视图仅是一个GUI客户。
脱机观察:
责任:不在系统正常运行期间(如升级、填加活对象等)对系统进行配置。
由该配置视图使用的服务
提供给其它部件的服务:
该配置视图仅是一个GUI客户。
教师控制台
责任:该控制台由教师使用以便评估学生的工作。教师被提供有如学生工作的普及和关于任务执行的其它统计的信息。而且,教 师可以观察由学生所写的所有任务的资源。
由该配置视图所使用的服务:
*任务管理器,以便观察其学生任务的资源;
*日志服务器,以便获取关于任务执行的统计信息。
提供给其它部件的服务:
*脱机观察仅是一个GUI客户。
集成开发环境(IDE)
该部件运行在每个学生编程工作站上,其结构支持下列三种可能性:
*位于学生家中的独一无二的PC机,不连接到互连网。
*位于学生家中的PC机,其通过互连网连接到LOLA系统。一个防火墙位于学生家中的PC机与LOLA系统之间。
*位于企业内部互连网上的PC机,其通过标准的中间设备连接到其它LOLA部件。
IDE核心:
责任:由学生所使用的集成开发环境用于编写由任务分配器执行的任务。
由IDE核心所使用的服务:
*IDE核心在注册被用于执行之前利用活对象仿真器来测试任务。
IDE核心利用代理对象以便执行在真实活对象上的任务。该特征仅当此IDE核心可与该代理对象通过该中间设备通信之前使用,也就是,仅当PC机位于同一企业内部网上、或如果防火墙不限制中间设备口的数据包时远离家、以及可用的带宽允许时使用。
提供给其它部件的服务:
*IDE核心仅是一个服务客户。
代理仿真器:
责任:仿真该活对象的代理以便允许本地调试和任务的执行。
由该配置视图所使用的服务
*
提供给其它部件的服务:
*IDE核心将仿真器用于本地任务的执行及调试.
任务登记:
责任:基于浏览器的部件为学生提供增加或删除用于在基于无线电的PC机上执行任务的能力.
由该配置视图使用的服务
*任务注册服务器
提供给其它部件的服务:
*开发
该部件负责开发系统中所有的其它部件,尤其负责开发所有的代理对象及其相应的仿真器,并在必要时建立时这些对象。建立这些对象是有选择的,关于此事基本上有三个可选项:
所有对象都是同一类型,即,所有的对象都有同一个接口,而不管它们所代表的活对象。专用于一个特定的活对象的操作通过一个公共接口如“send-cmd”执行。这种方式的优点在于系统的开发、维护及配置都简单。其缺点是:对于用户来说一个没什么意义的命令集,更重要的是,只有当在活对象上执行任务时才能检测到不正确的命令的使用,而不是在仿真器上或编译时才检测到。
*在API级上所有对象都是同一类型,但每个对象都知道其自身的类型。在系统中所有的类型都驻留在一个库中。这样,从开发 和维护观点看,这种方式又不简单,命令集的API仍无意义,但当任务在仿真器执行时能检测到错误。
*不同的对象有不同的API来访问它们。这样系统的开发与维护就更不简单了,因为码是根据活对象的类型产生和建立的,而不是只被保存在一个库中,或根本不保存。但是该命令集对它的用户来说却有意义,而且,只要任务一被编译就能检测到错误。如此一来该方式就是较佳的途径。但是实施该方式却需要更多的开发努力,如此一来仅能以次级迭代来实施。
任务和安全管理器数据模型
图42-68包括描述任务和安全管理器数据模型的流程图.
*用户:
*名称.
*密码:使用一种函数加密.
*组:用户所属的一个或多个组.
*组:
*名称.
*用户:属于该组的零或多个用户.
*角色:与该组相关的零个或多个角色.
*角色:
*名称.
*许可:根据下列条件:
*活对象类型.
*活对象.
*计算机.
*定时器:类似UNIX crontab的能力.
*任务:
*名称.
*位置.
*用户:编写此任务的一个或多个用户.
*执行时间:何处及何时该任务将执行,必须匹配与该用户的组相关的角色。
*活对象:
*名称
*类型
*主人
*任务:操作此活对象的一个或多个任务.
*活对象类型:
*名称.
部件描述
安全管理器
此安全管理器为其它部件输出两个主服务器。
部件:
*配置授权:负责建立用户、组、角色库,它所输出操作是远程操作,当管理员决定更新学生、组及角色的定义时就触发这些操作。该管理员使这些变化通过其基于GUI的控制台,该控制台利用上述的操作起到一个客户作用。
*配置授权:利用库中的数据,检查是否一个特定的操作是合法的。
这种服务的客户是:
*任务管理器-无论何时当学生注册一个任务时,它就请求确认。
*代理对象-无论何时当学生触发一个操作时,它就请求确认。
任务管理器
该任务管理器将系统中所有任务保存在一个库中,并据此向相应的无线电基站提供它们应该执行的任务。
图42-68图示说明该情节,其中一个学生注册一个要执行的任务。她首先输入其用户及密码,然后安全管理器验证该学生。如果是许可的,则该学生获得所有允许的操作清单,即,获得具有下列操作的清单:
*增加任务
*删除任务
*更新任务
*列出所有已注册的任务
假定该学生决定注册一个任务用于执行,因此她选择“增加任务”操作。该任务管理器接收任务内容及任务信息,并且查询安全管理器该学生是否被允许注册一个具有特定任务信息的任务。如果是,任务管理器就注册该任务,然后通知该学生注册成功结束。
任务规划器:
任务规划器负责规划所有已注册的任务,无论何时当一个任务的执行时间到达时,规划器就通知分配器应该下载该任务并产生(spawn)它。
当规划器起动时,它重复通过所有的已注册任务的列表,并针对每一个SchedInfo对象建立一个包含本任务应起动和停止的下次时间的简单对象。
该任务规划器根据所有已注册任务的执行时间保存它们的索引表,然后,无论何时任务的执行时间来到时,它在定时器中注册以 接收事件。在接收到该事件后,它就通知相应的分配器应下载并执行该任务。
任务分配器:
无论何时,当任务的起动时间来到时,任务分配器从该规划器获得一个已注册的任务,然后以独立的线程执行该任务。每个任务运行在灰箱内以便强化安全策略。下列状态图描述了该任务分配器。
在图42-68中的一个图描述了系统中该任务分配器、任务规划器及其它组件中的数据流。任务规划器可从定时器中接收时间事件以及来自任务管理器中的taskListChange事件。该时间事件在任务的起动执行时间到达时产生。该事件触发了任务从规划器到分配器的下载和产生(spawn)。TaskListChange事件实际上改变了规划任务的清单,由此改变了定时器中的注册。
管理控制台可以手动地浏览和改变正在执行的任务。
下面描述关于首选的LOLA系统的总体考虑。
LOLA(活对象实验室)是一个计算机班级,可使学生建立和体验称为活对象的自然人物(figure)的生动化。该生动化为活对象提供了以人声、似人和智能方式与人交互的能力。
活对象实验室教给学生分析、设计和将“自然智能(NI)”编程进自然对象-活对象形象。由学生开发的NI随着时间增加和积累活对象与学生交互的能力。活对象形象分布到操场,并用作为对所有孩子们的娱乐和教育目的。
自然智能
自然智能是计算机化对象提供“类似人的行为”的能力,人尤其是年轻人非常能接受一直在变化的环境,这种技巧允许在与人的交互中有更大的自由。
基于计算机的系统具有严格的交互协议,只要交流者(用户或另一个计算机化的机器)严格地遵循协议的规则,一个计算机化的机器的行为是高度可预测的并且非常精确。与该协议的偏离将导致交互的立即中止。
计算机编程和基于计算机的机器被用于“解决问题”,当达到一个识别得很好的目标时该程序结束(暂停、或等待一个新的输入或事件),人的交互被定向于建立一个逐渐增加的共享理解。即使当最后的交互目标是解决一个问题时,每一步交互的“连续目标”是搜集和增加相应的信息至知识的集中池,这可在最后的目标到达之前来进行。在很多环境下,在交互开始之前是不知道最后的目标的,仅作为交互的结果而在以后标识出。
将自然智能装进机器使得该机器可执行下列循环:
1、标识一种环境;
2、对人作出应答;
3、传送描述对该环境的累积或附加理解的信息;
4、标识什么信息正在丢失;
5、建议附加信息;
6、请求附加信息;
7、接收人的响应并分析它。
LOLA的目标
LOLA的首次实施是针对教育目的的高校,这些是该项目的高级目标:
*教授学生分析、设计以及将“自然智能(NI)”编程进自然对象。
*友好并容易地使用该系统,来吸引学生学习高技术课程。
*支持教师进行任务分配和评分。
*作为基于内容的对象,取悦并提供信息给学生及教职员工。
服务和他们使用情形的分析
系统中的主要参与者是学生、教师、管理员和用户。该文档声明了系统的参与者的重要的使用情形,该使用情形被参与者以及服务编组:学生、教师、管理员和用户。一个人可以作为一个或多个参与者而存在,尤其是,每个学生、教师和管理员同时又是用户,有可能同一个人可能既是教师又是管理员。
系统中的主要部件是:
*编程基站:每个基站包含IDE(集成开发环境),提供将NI编程进活对象的能力。在学生家中的计算机在安装了生成器IDE后也可以是这样的一种编程基站。
*无线电基站:每个基站与一个或多个活对象(通过RF通信)进行通信,并发送这些对象命令。
*LOLA服务器:主管LOLA系统中服务器(如任务服务器、安全服务器)的基站。
*教师和管理员控制台:在实验室中的基站,由教师和管理员分别使用。
*活对象:活对象是配备有控制装置的玩具。该控制装置包括微控制器、无线电发送接收器和I/O口,I/O口连接到同样包含在该活对象内的外设,如扬声器、麦克风、传感器、致动器、电机、灯、视频照相机等。这些外设可使该活对象能以人的方式与人打交道,外设由该微控制器操作运行,该控制器通过内置的发射接收器从基于无线电的PC实时地接收程序指令。
随后介绍提供用于建立内部数据库的数据的另外两个次级参与 者。提供用于建立内部数据库的数据的信息服务器支持来自学生任务的查询,一个内容提供商提供将被保存在内容服务器中的内容,这些内容将被规划成按所要求的执行。
我们描述服务以及相关使用情形的分析。
学生服务
提供给学生(组建该活对象的行为的人)的主要服务在附图中加以说明。
名称
生成器IDE安装
参与者
如果安装在家里的PC机上则是学生,如果是安装在学校的PC上则是管理员。教师也可以将IDE安装在家中的PC上以便浏览其学生的任务。
目标
生成器IDE要被正确地安装。
前后的影响
1)可能先前已有安装,这时将对已有的安装进行升级。
2)安装保护型安装
3)学生一般使用Windows95/98,但也可能使用其它的环境如Macintosh、windows3.1/DOS、UNIX或NC(这时的安装将发生在服务器上)。
触发器
参与者从CD或一个下载文件起动安装。
总结
这种使用情形采用了第一个或稍后的生成器IDE安装:
1)要求参与者提供几个配置参数。
2)参与者进到生成器IDE的正常使用。
先决条件
参与者下载该文件包或有一个CD。
后条件
生成器IDE已安装。
相关使用情形
应该随后立即生成或更新家中PC上的活对象,在用户方便时推迟到以后进行。
名称
增加家中活对象类型
参与者
学生
如果教师在家中的PC上已安装了IDE,则教师也可能是这种情形的参与者。
在此,管理员不是参与者:管理员有单独的使用情形-处理活对象的更新。
目标
对于生成器IDE来说,系统中所有的活对象的类型都是已知的,以便为每种活对象类型支持一个仿真器。
前后的影响
1)信息源一般是安装在学校的LOLA系统,更新过程将是基于浏览器并通过因特网来完成,一个防火墙设置在家中的学生浏览器和LOLA系统之间。
2)在学校,学生可以把所需要的数据放置在一张软盘上,然 后将其安装在家中的PC上。
触发器
可以是下列触发器之一:
1)生成器IDE刚刚被安装。
2)新型活对象已被连接到系统。
总结
生成或更新对于安装在学生的家中的IDE是已知的活对象类型。
先决条件
生成器IDE被安装。
后条件
1)在生成器IDE中的仿真器匹配可用的活对象的类型。
2)学生可以着手建立一个决策树。相关使用情形
1)生成器IDE安装
2)LOLA安装
名称
建立一个决策树
参与者
学生
目标
建立一个准备复杂化的任务。前后的影响
1)不需要编程知识
2)容易使用且友好的GUI
3)可再次应用以前任务中所做的决策树或子树。
4)可使用内建的决策树或子树。
5)学生想使用对其正在使用的玩具来说是高级的命令。触发器
1)教师给学生分配作业。
2)学生在实验室的上课期间或通过自由选择建立决策树。
总结
该使用情形捕获这样一种情况:学生建立一个决策树以便将NT编程进一个活对象
1)学生起动生成器IDE;
2)学生建立一个决策树;
先决条件
1)准备复杂化的任务。
相关的使用情形
1)生成器IDE安装:是所要求的;
2)在家中的PC上生成或更新活对象类型:是所要求的。
名称
建立一个高度定制的决策树。
参与者
学生
目标
建立一个准备复杂化的任务。
前后的影响
1)要求基本的编程技巧;
2)易于使用编程语言和库;
3)再次应用在先前任务中所做的决策树或子树;
4)使用内建决策树或子树;
5)学生想使用对其正在使用的玩具来说是高级的命令。
触发器
1)教师给学生分配作业。
2)学生在实验室的上课期间或通过自由选择建立决策树。
总结
该使用情形捕获这样一种情况:学生建立一个决策树以便将NT编程进一个活对象
1)学生起动生成器IDE;
2)学生建立一个决策树;
先决条件
1)生成器IDE安装在学生桌面上;
2)仿真器仿真存在于学校内的活对象。
后条件
1)准备复杂化的任务。
相关使用情形
1)生成器IDE安装:是所要求的;
2)在家中的PC上生成或更新活对象类型:是所要求的。
名称
编译一个任务
参与者
学生
目标
产生一个准备在活对象上执行的任务,并根据由该学生建立的决策树而动作。
前后的影响
1)学生不必对该决策树的内部实现熟悉;
2)如果该学生只建立了一个决策树,而没有增加学生定义的宏/码,则希望该复杂化过程能通过大多数情况。
3)通过观察决策树应能显示复杂化的错误/警告。只有在学生增加宏的情况下,这些行也被显示。
4)友好、易于使用。
触发器
1)学生已建了一个决策树。
总结
该使用情形捕获这样一种情况:学生建立了一个决策树并想编译它。
1)学生起动生成器IDE:
2)学生建立了一个决策树;
3)学生编译该任务。
先决条件
1)学生已建了一个决策树。
后条件
1)如果复杂化通过-一个任务准备执行。
相关的使用情形
1)建立一个高度定制化的决策树或建立一个决策树是所要求的。
名称
执行一个任务
参与者
学生
目标
学生PC上本地执行一个任务以便检查它,该对象与一个驻留在学生PC机上的活对象仿真器进行交互,或者如果可能的话,与一个连接到学生PC或网络中其它PC上的自然对象进行交互。
前后的影响
1)活对象仿真器应精确地仿真一个自然对象的行为,尤其是,它应当指出当此任务单独地在一个活对象上执行时可能发生的所有任务;
2)作为一个生成器IDE的集成部件看待;
3)友好、易于使用;
4)安全:在学生试图执行连接到一个远程PC的活对象上的任务时检验该学生的许可权利。
触发器
1)学生建立和编译一个任务并希望执行它。
总结
该使用情形捕获这样一种情况:学生建立了一个决策树并想立即运行它,一般地以便检查该任务。
1)学生起动生成器IDE;
2)学生建立一个决策树;
3)学生编译该任务;
4)学生执行该任务。
先决条件
1)一个任务准备在一个活对象上执行。
相关使用情形
1)建立一个高度定制化决策树或建立一个决策树或编译一个任务是所要求的。
名称
调试一个任务
参与者
学生
目标
在学生PC上本地调试一个任务,该任务与驻留在学生PC上的活对象仿真器进行交互,或者可能的话,与一个连接到该学生PC或网络中其它计算机上的自然对象进行交互。
前后的影响
1)活对象仿真器应精确地仿真一个自然对象的行为,尤其是,当此任务与该活对象单独地执行时它应能指出发生的所有错误;
2)作为生成器IDE的集成部件看待;
3)友好且易于使用;
4)如果学生在一个连接到如远程PC的活对象上执行该任务则进行安全检查。
5)学生可以按步骤地跟踪任务的执行,并可以图形方式观察决策树中哪一个点正在被执行。
6)学生可以进入代码行调试,以增加决策树;
7)一般的调试能力如步入、步出、进到光标处、设置断点、继续、观察设置点等。
触发器
学生建立并编译一个任务,并希望调试它。
总结
该使用情形捕获这样一种情况:学生建立了一个决策树并想调试它。
1)学生起动生成器IDE;
2)学生建立一个决策树;
3)学生编译该任务;
4)学生调试该任务。
先决条件
1)学生建立了一个决策树。
后条件
1)一个任务准备好在一活对象上执行。
相关使用情形
1)学生建立了一个高度定制化的决策树或建立了一个决策树并编译该任务是所要求的。
名称
任务注册
参与者
学生
目标
该任务被正确地安装,并当规划时运行。
前后的影响
1)通过因特网或企业内部网的基于浏览器的注册;
2)安全、保密;
3)防火墙驻留在基于网站的客户和该服务器之间。
触发器
学生起动注册过程,一般地是在她已建立、执行和调试一个任务之后。
总结
该使用情形可以保证学生注册了一个用于执行的任务。
1)请求学生的用户名和口令;
2)请求学生发送任务文件;
3)学生可以浏览所有他已注册的任务,并执行其它的操作如删除先前注册的任务。
先决条件
学生已建立、执行和调试了她的任务。
后条件
任务被注册成按规划的执行。
相关使用情形
1)调试或执行一个任务。
名称
浏览任务的执行日志
参与者
主要参与者是学生,教师和管理员也可以是这种情形下的参与者,一般是帮助解决问题的。
目标
浏览已执行的任务的日志,一般是为了诊断问题。
前后的影响
1)学生可以从连接到该企业网的每个PC上浏览该日志;
2)通过因特网的基于浏览器的日志浏览,其中,防火墙驻留 在家中PC和LOLA系统之间是较好的特点;
3)学生可以根据几种条件浏览日志。
触发器
1)学生的任务已执行,学生想浏览该执行的日志。
总结
这种使用情形捕获了这样一种情形:学生已建立了一个决策树,并将其登记用于执行,并想浏览该执行的日志。
1)学生起动生成器IDE;
2)学生建立一个决策树;
3)学生调试该任务;
4)学生注册该任务;
5)学生浏览该执行的日志。
先决条件
1)学生已注册了一个任务,且该任务已被执行。
后条件
1)学生理解她的任务是如何被执行的。
相关使用情形
1)注册任务是所要求的。
教师服务
教师负责任务分配、检查及评估的各个方面。
名称
浏览学生任务
参与者
教师
目标 浏览学生的任务以及对其任务进行评估或帮助解决问题。前后的影响1)安全、策略-只有教师可以浏览学生的任务;2)教师可浏览每一个注册的任务;3)教师使用生成器IDE作为任务浏览器;4)根据配置,教师可以或不可以改变学生的任务。触发器教师想评估她的学生的任务或帮助她们解决问题。总结1)教师起动生成器IDE;2)教师登录进入任务管理器;3)教师从该服务器装载一个任务到她的IDE。先决条件1)生成器IDE安装在该教师的桌面上。后条件1)学生任务出现在教师的控制台上。相关使用情形生成器IDE的安装是所要求的所执行任务统计的使用情形也可用作为一个措施以评估学生。名称所执行任务的统计参与者教师目标教师浏览关于学生任务的统计,以便评估他们的工作。
前后的影响
1)安全、保密-只有教师可以浏览学生的任务;
2)教师可以浏览有关其学生的每一个任务的统计。
触发器
1)教师想评估她的学生的工作。
总结
1)教师登录进入统计服务器;
2)教师从该服务器查询数据,并浏览该数据。
先决条件
学生任务已在系统中执行。
后条件
教师有更多的措施来评估其学生。
相关使用情形
浏览学生任务的使用情形也可以作为评估学生任务的措施。
管理员服务
管理员负责系统的安装、开发、维护、诊断、监视及控制。
名称
安装
参与者
管理员
目标
该LOLA系统将被正确地安装。
前后的影响
1)应用组件应该以这样一种方式开发:不会产生瓶颈,系统将以有效的方式运行;
2)安装过程可以从中央位置来完成;
3)先前可能已有安装,在这各情况下,安装将是更新先前的版本;
4)类似安装的安装保护;
5)系统应被调整成支持十个活对象和成百个学生。
触发器
管理员从CD或一个下载的文件上起动安装过程。
总结
这种使用情形捕获了系统的第一和稍后的安装:
1)询问管理员几个配置参数;
2)管理员进而更新活对象的使用情形。
先决条件
管理员下载文件包或有一个CD。
后条件
设置用于定义活对象类型的所有东西。
相关使用情形
1)更新活对象类型立即随后进行,也可以延迟到用户方便的稍后时间。
名称
增加活对象类型
参与者
管理员
目标
系统中所有活对象的类型和对象对于该系统来说都是已知的,并据其来开发相应的应用组件。
前后的影响
1)从一个中央位置来进行;
2)活对象和对象类型在其生命周期内可以从系统中增加或删除,而不只是在安装后。
3)尤其是,驻留在学生家中的PC上的IDE内的仿真器应被更新。
触发器
1)LOLA系统已经被安装了;
2)活对象的新类型已被连接到该系统。
总结
根据可用的活对象来配置系统。
先决条件
系统的安装
后条件
在系统中所有活对象的类型是已知的。
相关的使用情形
1)安装
2)触发在家中PC上生成或更新活对象类型的使用情形。
名称
学生、组和角色定义
参与者
管理员
目标
学生可登录进该系统,并根据他们的权力许可执行某些动作。
前后的影响
1)灵活性-学生可以属于一个或多个组,并且每一个组可以有一个或多个角色,同一角色可被分配到几个组;
2)该过程可以在安装或活对象的配置后进行,以及在无论何时新的学生、组或角色应当被增加或删除的有规律的基础上;
3)用户的定义独立于系统用户。
触发器
教师请求管理员打开到他的学生的帐户,以便他们开始应用该系统。
总结
该使用情形捕获这样一种情景:一个班的教师希望她的学生被授权使用该系统。
1)管理员定义角色:每个角色定义包括角色名称和角色的所有者被赋与的许可权,许可权可根据下列条件来授予:
*活对象类型;
*活对象;
*次数:类似UNIX crontab的能力;
2)管理员定义组:每组的定义包括组名、与该组相关的零个或多个角色;
3)管理员定义用户:每个用户定义包括用户名、密码(用一种函数加密)以及零或多个与该组相关的角色。
先决条件
1)安装;
2)更新活对象类型。
后条件
学生可以根据他们的许可权登录进该系统。
相关使用情形
1)安装和更新活对象类型是所要求的。
名称
诊断、监视和控制系统。
参与者
管理员
目标
该参与者能诊断、监视和控制系统。
前后的影响
1)在可能时能检测到潜在的问题;
2)通过诊断工具分离该问题;
3)通过正确的措施解决该问题;
4)自动进行全面检查;
5)允许管理员定义针对某些事件的自动动作,例如,根据所接收到的特定的时间事件改变此RF信道;
6)管理员可以触发对活对象的操作,并以一种联机的方式从该处接收事件;
7)管理员可以浏览系统中的所有事件;
8)基于浏览器的管理控制台;
9)安全;
10)与企业管理控制台(如果有的话)集成。
触发器
在有规律的基础上,或在学生或教师提出问题后,对系统的管理。
总结
1)管理中起动基于浏览器的管理站;
2)管理员诊断、监视和控制系统。
先决条件
1)系统已被安装。
后条件
系统运行正常。
相关使用情形
1)安装;
2)浏览和改变任务的规划时间。
名称
浏览和改变任务的规划时间。
参与者
管理员
目标
从一个中央位置或通过对整个系统的观察控制任务的执行时间。
前后的影响
1)从任务规划中滋生的潜在问题应当在可能时事先检测到;
2)管理员应能看到系统中所有任务的规划时间;
3)管理员应能改变任务的规划时间或能规划用于执行的未规划任务;
4)安全性。
触发器
1)学生刚刚注册了用于执行的任务,管理员希望验证学生们恰当地规划了他们的任务。注意:学生仅能根据他们的许可权力注 册任务。但是他们仍可能不恰当地注册了任务-如-如果两个或多个在同一活对象上注册了任务,且次数重迭,那么这些任务将作用在同一传感器上;
2)学生们已经注册了任务,但没有声明规划时间,一般地,因为管理员想避免冲突而自己声明它,这样,管理员声明了所有任务的规划时间;
3)任务已经从一个因特网上的内容提供商服务器处下载,管理员想规划这些任务用于执行。
总结
1)管理员起动基于浏览器的管理站;
2)管理员浏览系统中的所有任务和它们的规划时间(如果已规划的话);
3)管理员改变任务的规划时间或规划用于执行的新的任务。
先决条件
1)系统已安装;
2)任务已注册在系统中或被下载进系统。
后条件
任务被规划成按所要求的执行。
相关使用情形
1)安装;
2)诊断、监视和控制系统。
用户服务
该用户可以是操场内与该活对象进行交互的任何人,尤其是,可以是一个学生、教师、管理员或一个都不是。
名称
与活对象进行交互
参与者
用户
目标
交互的目的可以娱乐、教育、任务检测(学生或教师)、系统检测(管理员)。
前后的影响
1)友好地交互;
2)活对象按照所注册的任务而运行规划这些用于执行的任务的规划器。
3)用户看见操场内的活对象并决定与之交互。
总结
该使用情形捕获这样一种情形:一个用户与一个活对象进行交互,用户通过语音(听或与之交谈)、观察其反应或触发其传感器而与该活对象交互。
先决条件
一个或多个任务与该活对象一起执行。
后条件
一个或下列中的两个:
1)娱乐该用户,更多地是教育;
2)利用一个自然对象(学生或教师)检查该任务;
3)已检查了活对象的功能性(管理员);
相关使用情形
1)执行一个任务;
2)调试一个任务;
3)任务注册。
内容提供商服务
与该系统交互的外部服务器,以便将数据推进(push)LOLA数据库,或根据来自一个LOLA客户的要求提供这样的数据。
名称
建立内容数据库
参与者
内容提供商
目标
拖出(pull)或提供将在活对象上运行的任务(内容)。
前后的影响
1)支持为LOIS系统所开发的能力;
2)内容可以在有规律的基础上自动地被推进,或根据请求被拖出来;
3)由该内容提供商所写的任务以与学生所写的任务相似的方式被规划执行;
触发器
取决于下列配置:
1)一般地,管理员将配置推进客户以便在特定的时间间隔上运行更新,因此触发器是推进客户触发器;
2)管理员可以手动初始化一个下载。
总结
该使用情形捕获这样一种情景:学校的管理员想要规划由内容服务商提供的要执行的任务,并在有规律的基础上更新这些任务,这些任务是以一种与学生所写的任务相似的方式进行规划执行。
所有的使用情形支持动作,如注册、付帐,内容提供商被认为是LOLA系统的一部份。
先决条件
1)已安装了LOLA系统;
2)安装和注册使用LOIS系统的情形。
后条件
1)准备用于执行的新任务驻留在任务数据库中。
相关使用情形
1)安装
信息服务器服务
外部服务器与该系统交互以便将数据推进LOLA数据库,或者根据LOLA客户的请求提供这样的数据。
名称
提供信息以建立支持学生任务查询的数据库。
参与者
信息服务器
目标
推进或提供用于学生数据库查询的数据。
前后的影响
1)使用标准工具或协议以建立这样的数据库;
2)数据可以在有规律的基础上自动推进,或有请求时被拖出来。
触发器
取决于下列配置:
1)一般地,管理员将配置该推进客户以便在特定的间隔上运 行更新,因此触发器是推进客户规划器;
2)管理员可以手动地初始化一个下载。
总结
该使用情形捕获这样一种情景:学校的管理员想建立一个学生可查询的内部数据库,而不是在网页上搜索想要的数据。
先决条件
已安装了LOLA系统。
后条件
1)数据库被更新。
相关使用情形
1)安装
图42是一种情感相互作用流程图设计过程的简化流程图说明。
图43-102说明根据本发明一个优选实施例构筑和工作的一种计算机化编程教学系统的一些优选实施例。
现在详细说明图69-102。
图69是该系统网络的一般逻辑全貌图,其中,各个服务器(例如数据库服务器316和创造物控制服务器318)位于中央,而学生编程工作站310、教师站312、管理员站1200和无线电基地站320则聚集在各服务器的周围。
图70是对创造物322的控制的一般逻辑全貌图,其中,无线电基地站(它向各种创造物提供控制)位于中央,而学生编程工作站310、教师站312、管理员站1200、和无线电基地站320则聚集在各服务器的周围。
图71是管理员站的主菜单,其中包括4个主要的子菜单:关于系统操作的“实时信息”1250,用于寻找硬件和软件的问题的“诊 断”1260、软件和硬件的“配置和记录”1270,以及用来调度和管理由学生提出并由系统执行的各种任务(项目、程序)的“任务”1200。
图72说明在家里建立和测试一个任务(项目、程序)的一些基本步骤。首先,学生建立任务(步骤1290),然后编译源码(步骤1300),然后利用仿真器执行任务(步骤1310),如果任务未能按其设计要求执行,则学生将利用仿真器为程序找错,找出问题,进行改正,然后重新测试任务(步骤1320)。如果任务能按设计要求执行,则学生将记录该任务(步骤1330),准备对一个物理创造物执行。
图73说明学生在家里和学校里建立,测试和记录一项任务的处理过程。该过程以家里的学生开始,与图62类似,不过这里学生将把任务转移到学校,并在学校里继续同样的过程。
图74是说明一个非常简单的“决策树”(也称为“状态引擎”)的流程图,该流程图教导创造物进入“聆听横式”于是记录用户发出的语声并利用语言识别引擎处理这个记录。聆听模式一直持续到识别出词语“清醒”,点明任务是唱出一首歌曲。当完成歌曲之后,处理过程将重复进行。
图75是说明仿真引擎主要功能的方框图。仿真引擎使学生能在不存在物理创造物的情况下测试所建立程序(任务)对物理创造物的有效性。仿真引擎利用一些标准计算机周边设备来提供物理创造物的所有物理功能:例如用计算机话筒模拟创造物的聆听功能1450,用计算机扬声器模拟创造物的说话功能1460,用在计算机屏幕上显示创造物的动作来模拟创造物的运动1470,用计算机键盘和鼠标来模拟创造物的传感器1480,以及用计算机显示器和周设摄像机来模拟安装在创造物中的视频显示器和摄像机。
图76是说明对一个项目(任务)的记录和执行的处理的流程图。在步骤1500中,学生或教师把任务记录在数据库服务器(LOLA服务器)316中,供以后借助于一个特定创造物控制服务器318和一个特定创造物324来执行,在步骤1510中,根据在记录步骤1500中所规定的日期、时间或其他条件,LOLA服务器316把任务传送给相应的创造物控制服务器318执行。创造物控制服务器通过利用无线电基地站320把命令发送给相应的创造物324来发出程序和执行程序。
图77是教师们能得到的一些主要服务的方框图。教师可以访问IDE的唯一扩展形式(步骤1600),以选择和检查每个学生的每项任务(步骤1610)。教师能够浏览学生的任务(1620),观看关于任务的执行的统计情况(1630),例如绝对性能统计(1640)和相对性能统计(1650),以及给学生打分(1660)。
图78是活对象实验室(LOLA)系统拓扑结构的方框图,其中包括以下一些主要子系统:
LOLA服务器,其中含有一个或几个服务器,例如数据库服务器和创造物控制服务器,管理员站1710;教师站1720;学生编程站1740和无线电基地站1750。除了无线电基地站之外,所有主要子系统都由网络手段互联,其中网络手段例如有超文本传送协议(HTTP)或中间件(MW),其中的中间件可以是任何适当的接口软件。典型地,除了无线电基地站之外,所有子系统都通过一个例如以太网(Ethernet)这样的局域网(LAN)互联,而无线电基地站则由万能串行总线(Universal Serial Bus,USB)连接。
图79是活对象实验室(LOLA)系统的一个方框图,其中示出了该系统所提供的一些主要(逻辑)服务:数据库引擎1760管理对数 据库1765的所有访问。登录服务器1770登录在系统中运行的所有创造物和任务的执行情况和性能的细节。监视器引擎1775实时地向用户提供在监视时间上系统所执行的任务的性能的信息。安全管理器1780监督所有访问该系统的用户,并根据管理员预定的条件确认只有被授权的用户才可以访问数据库的某些特定部分。任务管理器1785根据被授权用户所提出的规定来监督系统中所有任务的操作,典型地,这些服务由一些独立的软件子系统提供,这些子系统通过HTTP和MW等普通通信手段相互连接。
图80是系统管理员利用系统管理员站1200可得到的一个些主要服务的方框图。典型地,这些服务包括:
在线控制台1800,用于当系统工作正常时对所有可得到的服务的控制。
脱机控制台1810,用于当系统因进行重大安装和维修而关闭时对所有可得到的服务的控制。
配置控制台1820,它使系统管理员能装设硬件周边设备,建立网络配置等等。
调度控制台1830,它使系统管理员能设置新的创造物或改变已有创造物的配置。
图81是创造物控制服务器软件的主要模块的方框图,其中的创造物控制服务器可以是一个独立的服务器,也可以是例如总LOLA服务器这样的另一个服务器的一部分。创造物控制服务器由许多代理对象1840组成,每个代理对象负责一个特定的创造物和一个计划器任务,该计划器任务负责各种代理对象的操作的协调和时序。
图82是学生利用编程站可得到的一些主要服务的方框图。这些服务以一些通过例如HTTP和MW等接口互相连接的模块来实现。三 种主要的模块/服务器是:交互作用开发环境(IDE)1860,它使学生能进行对指定给他(她)的作业(任务)的编程;仿真器1870,它使学生能利用在计算机屏幕上模拟的虚拟创造物来测试所建立的程序;以及任务记录器1880,它使学生能把所建立的程序记录下来,供物理创造物执行。
图83是教师利用教师站能得到的一些主要服务的方框图,除了另外有一个教师控制台使教师能给学生指定任务(作业)并监视他们的完成情况和打分等等之外,这些服务及其模块式结构与编程站的是相同的。
图84至93一起构成了对LOLA的一个演示性示范项目的总体说明。
图84是一个示范性LOLA的方框图,其中含有两个班级,每个班级有5个编程站、1个教师站、一个直接连接在网络上的无线电基地站和一个创造物。此外,在两个班级之外,还有一个LOLA服务器、一个管理员站和一个也是直接连接在网络上的无线电基地站,该基地站控制着4个创造物。
图85是说明安装该示范性实验室的方法和功能的方框图,它在管理员级别上和两个班中使用。
图86和87说明该示范性系统的软件和硬件的结构。
图88至90是说明激励该示范性项目的演示程序的步骤的流程图。
图91说明该示范性系统的一些主要应用模块。
图92和93说明为使该LOLA系统工作所需采取的步骤。
图92列出为激励示范性演示软件所必需安装的一些软件模块。
图93列出为了在能执行图88和89所示的活动之前必需进行的 配置活动。
只要所有步骤都能完全地执行,它们的执行次序并不重要。
图94至105说明交互作用式开发环境(IDE)的结构和特性。
图94示出IDE屏幕的典型结构。该屏幕的典型组成是:如所有Windows(视窗)应用所共有的一个顶部菜单条2000和一个底部状态条2005;例如2010和2020等工具条,它们可设置在屏幕上任何处,图中示出的是在靠近顶部菜单条处。工具条2010中含有编程人可得到的各种软件工具的图标,例如编辑、编评、仿真等的图标。编程工具条2020中含有编程人可以列入软件程序中的各种目标的图标,例如状态、事件、功能等的图标。可以从工具条中拉出一个目标放入编程窗2030,以与该窗内的其他目标连接。当选出一个目标时,在目标检验窗2040中将显示出该特定目标的性质,编程人可以修改这些性质的值,以生成所需的程序行为。当选择了“仿真”时,将在仿真窗2050中显示出被编程创造物的模拟像。当指令该创造物收集输入数据(语音或触觉传感器)时,将跳出一个菜单2060,于是编程人可以通过该跳出式菜单中作出适当的选择来与创造物相互作用。消息窗2070在编程过程中将向编程人提供提示,在仿真过程中将向编程人提供程序执行的跟踪数据。
图95示出编程人可得到的一些主要功能(文件、编辑、观看等)和一些子功能,主要功能显示在IDE屏幕的顶部菜单条2000中,子功能是在选择了一个主要功能后在一个下拉式窗口中示出的。
图96A和96B示出用户可以目标工具条2010和编程工具条2020中得到的一些主要目标和编程工具。
图97更详细地说明了目标检验窗2040。
图98说明各种情况下在消息窗2070中向编程人显示的一些主 要消息组。这些消息组是:编程句法错误,编译错误,例如编译,找错等各种功能的进程说明消息,系统在找错时提供的测试登录消息。
图99是仿真处理和模块结构的方框图。当“仿真”被激活时,IDE模块2200将执行被测试的程序,只是把创造物能执行的指令发送给了虚拟创造物命令接口2210。接口2210识别创造物类型,并且被仿真的相应创造物功能将选择和操作相应的功能2220,功能2220在计算机显示屏上执行虚拟创造物的相应动作2230。
图100说明底部状态条2005的结构。
图101A至101D更详细地说明当选择了一个目标组时各种目标组的目标工具条2020的内容和结构。图101A是图96A中2100的详细情况,图101B是图96A中2110的详细情况,图101C是图96A中2120的详细情况,图101D是图96A中2130的详细情况。
情感分析
概念性说明
活对象实验室LOLA的目的是教导学生把人类行为灌注到计算机化的机器中去的技术。人类的一个主要特性是能感知情感。也就是说,能识别另一个人的情感状态和状态改变并作出相应的反应。向人类教导情感感知是十分困难的,而要把情感感知植入到机器中去则更要困难得多,然而,当机器具有即使是简单的情感感知时,也会对人机交互作用有巨大的作用。因此对情感感知的编程是重要的。
情感分析的主要目的是给主要应用以能适应与机器交流的人的情感状态的能力。情感分析是一种背景处理。情感分析评估与活对象交流的人的情感状态。这个评估是与其他处理并行地连续进行的。 按照应用系统的复杂程度和编程的难易程度,该处理可以作为一个被主处理调用的子程序或作为一项背景任务来执行。主要模块(或处理)的对象是应用的主要目的(例如扮演教师、保护人、响导、玩件等角色)。情感分析与主要任务通信,接收必要的输入,并向主要应用提供一系列应对与之交流的人作出的适当反应。
情感分析大部分是语言上的。情感分析处理将分析由主要应用所记录的语言输入内容。根据分析结果,情感分析将向主要应用提供适当的数据。由情感分析处理向主要处理提供的数据可以从相互作用人的可看到的情感状态或情感状态改变一直到准备让主要处理放送的详细语句。向情感分析提供的输入和是否遵从情感分析的输出,其最终决策在于主要(应用)处理。
情感分析基本上是一个程序,它可以用与编制主要应用相同的现成编程工具来编程。情感分析程序可以看作是一个实现成状态引擎的算法,该引擎中的事件是从与使用人的交流中接收到(记录下)的语言输入的语音分析和语义分析以及所积累的数据的结合。
情感分析处理的设计涉及到几个阶段,例如:
确定情感的种类范围,例如三种情感:悲伤、快乐和愤怒;
确定准确在从与使用人的交流中接收到(记录下)的语言输入中探测出的情感的语音和语义表示,例如,语声幅度(轻声或高声)、语音的音调、语速、收录质量(语言识别质量)、和特定语词(如“悲伤”、“快乐”、“愤怒”)。当然,上述某一特征的变化可能会比该特征本身更重要,例如,提高声音可能比连续的高声传递更多的情感信息;
确定明确地询问交流人的情感的方法,例如直接提出“你悲伤吗?”这样的问题;
根据所探测到的交流人的情感状态,确定对应用的相互作用所进行的修改。应该首先确定修改的目的,然后再确定方法。其中,修改目的的例子有:表达同情,提供情感支持和鼓励等,以及影响(改变)情感种类;方法的例子有:采取适当的语言输出幅度(响度)、调门、和速度,准备要选择和放送的同一语言内容的几种版本,表达同情、感兴趣、支持等的约定/标准短语;
确定应用处理与情感分析处理之间通信方法(协议)。
给学生的编程项目打分
通常,教师根据一个检查清单来评估考虑和打分。对于从精确的科学直到人类学等所有的命题考试都是这样来评估和打分的。对于编程(从分析、设计、到实施)的评估来说也是这样做的。检查清单评估可以自动进行,也即由计算机进行。由于对考卷的计算机评估的机制是很普通的,并且对所有命题考试都是一样的,所以这已不属于本文的范畴。
编出的程序还应该能正确地运行,也就是说应能符合规定要求不出错(不失败)地靠其自身运行。显然,计算机能够跟踪被运行程序的性能,根据规定分析其性能,和报告结果。
自动(或计算机)评估通过一个监视程序来实行,该监视程序能记录被监视程序的性能,分析记录,和报告结果。为了实现监视,在被监视程序中需设置一些检查点,并且监视程序应同时记录通过每个这种检查点的情况和相应的参数值。
LOLA的约定监视将提供对每个状态的入口和出口(从而提供对每个状态改变/连接的入口和出口)。监视程序应报告对每个学生的每个程序模块的监视结果。可以根据以下一些标准来打分:
已进入的(从而已测试过的)的状态和状态连接的百分比;
已退出的(从而表明已成功运行的)状态和状态连接的百分比;
内部性能的平衡情况,它是两个数的比值,第一个数对最少访问(最多访问)的实体(状态、连接)的进口(出口)数,第二个数是模块(每个模块和各个模块)内的平均入口(出口)数。更精确地说,平衡情况是清单中各入口(出口)和各最多访问实体与平均值之间的差值的平方和的平方根;
总体性能平衡情况,它是模块中的进口(出口)数与项目的平均数的比值。
图103是说明情感分析数据库的一个表格。
图104是一个情感分析状态图。
情感分析设备能探测到用户情感状态的变化。情感状态的变化与用户语言特征的变化有关,这些特征例如有响度、速度、音调(以下是隐含特征的例子)以及用户所使用的特定词条和对创造物所提出的直接约定问题的回答(以上是显特征的例子)。每个这种特征事件都有一个权重,当发生某一事件时将在相应的表格单元中增大权重。仅当超过某一阈值时创造物才会对探测到的状态变化作出响应(提供同情,提出一个约定的问题等)。
图105-110说明Uniport(单端口)的一个优选实施例,其中包括了一个软件体系的总貌。图105示出一些典型的功能调用和返回说明。图106示出适用于媒体BIOS模块的典型输入数据处理。图107示出适用于UCP实现模块的典型输入数据处理。图108示出适用于用户应用和API模块的典型输出数据处理,图109示出一个典型的UCP实现模块和媒体BIOS输出数据处理。图110示出协议实现模块和媒体BIOS模块的输出数据处理,在图110中,MAX-OB代表 输出缓存器中各单元的最大值。
下面是一些典型输出功能的说明:
crsrAddWords
这个功能用来从语言识别引擎向活动正文添加词条。
crWaitForEvent
这个功能用来等待来自UNIT的事件。
bioTransferReset
这个功能用来复原Media(媒体)BIOS模块中的输入或/和输出队列(见图5,2)。
关于3.2协议实现模块的输出功能的说明。
proSystemOpen
这个功能用来打开系统。
proSystemeLose
这个功能用来关闭系统。
proSendMessage
这个功能用来发送控制消息。
proSendBuffer
这个功能用来发送缓存。
proTransferReset
这个功能用来复原Media BIOS模块中的输入或/和输出队列。
关于3.2API模块输出功能的说明。
crBaseDetect
这个功能用来探测BASE(基地)(确定装置的识别符ID)。
crSystemOpen
这个功能用来打开系统。 crSystem Close这个功能用来关闭系统。crSetNotification这个功能用来设置用户应用中的回呼说明机制。crSendBuffer这个功能用来发送缓存。crSendMessage这个功能用来发关消息。crUnitTalk这个功能用来放送声音文件。crGetBaseVersion这个功能用来从BASE获得版本号。crsrGetWords这个功能用来从语言识别引擎的有效正文获得所有词语。crsrCreateContext这个功能用来在语言识别引擎中生成新的正文。crsr Delete Context这个功能用来在语言识别引擎中删除正文。crsrSelect Context这个功能用来从语言识别引擎选择正文。crsrRemoveWords这个功能用来从语言识别引擎的有效正文去除词语。关于3.1Media(媒体)BIOS模块输出功能的说明bioMediaConnect这个功能用来连接到通信媒体上。
bioMediaDisconnect
这个功能用来断开与通信媒体的连接。
bioAddOutBuffer
这个功能用来把输出缓存添加到输出队列上(见图5)。
图111-115一起构成了玩具配置的流程图。图111说明典型的人物(figure)配置。图112-115说明典型的安装-检验(分别为BT的四之一、四之二、四之三、四之四)。
为了产生一个屏幕接口,可以记录下述用作屏幕文本的带声voice-over内容:
屏幕0010-0012
进入前言:
早上:嗨,早上好!
下午:嗨,不错吧,下午好!
晚上:嗨,晚—安!
屏幕0040:关于你(ABOUT YOU)
叩击这里以给出或改变用户信息。
屏幕0050:热叩击!(HOT CLIP!)
叩击这里可看到说故事人跳舞和唱歌。
屏幕0600:如何玩(HOW T0 PLAY)
叩击这里可听到教你如何玩。
屏幕0070:起动游戏(PLAY)
叩击这里可以开始游戏。
屏幕0080:**新:检查(**NEW:CHECK-UP)
叩击这里可以检查系统。
屏幕0090:退出(EXIT)
叩击这里可以关闭说故事人程序。
屏幕0041
双击用户名或键入新用户的姓名。如果是键入新的姓名,则键入完后按“ENTER”键。
屏幕0042
请键入新用户的姓名。键入完后按下ENTER键。
屏幕0043
当我们一起玩时,我将用一个秘密名字来叫你。现在请双击你想要的秘密名字。
当他们没有选择秘密名字时
我必须首先知道你的秘密名字。现在赶快选择一个秘密名字。
关于你(ABOUT YOU)
叩击这里以告诉我有关你的一切。
填写个人数据的说明
1、叩击位于某一项处的光标。
2、将呈现一个菜单。作出你的选择。
3、逐项地重复上述过程。
4、完成后叩击主菜单(MAIN MENU)钮。
在“关于你”(ABOUT YOU)/“秘密名字”(AECRET NAME)/“爱好”(FAVORITES)屏幕顶部的关于输入数据的一般邀请
请告诉我关于你的一切。我很乐意了解你。
爱好(FAVORITES)
叩击这里来选择你爱好的事物。
·你喜爱什么颜色?黄?红?蓝?选一个。
·你喜爱什么食品?比萨饼?通心粉和奶酪?炸薯条?选一个。
·你喜爱什么活动?玩骗人相信?画画?玩计算机游戏?选一个。
你喜爱什么动物?猫、狗、马?选一个。
光标图(GRAPHIC OF CURSOR)叩击这里以返回“说故事人”的主菜单。
应该看到,如果需要,本发明的软件部分可以用ROM(只读存储器)的形式的实现。一般,如果愿意,软件部分可以用普通技术以硬件的形式实现。
应该看到,附录中所说明的具体实施例只是为了提供本发明的一个极详细的公开内容,而不是为了限制本发明。
应该看到,为了清楚而在各个分开的实施例的说明文中说明的本发明的各种特征也可以结合在一个实施例中给出。反之,为了简短而在一个实施例的说明文中说明的本发明的各种特征也可以完全分开地说明或组合成任何适当的子组合来说明。 附录A 应用源代码
===============================

  Copyrignt (c) 1995-1998 Creator Ltd. All Rights Reserved
================================
Description :This is the Main unit.
unit Main;
interface
uses
  Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs,
  StdCtrls,Toy,PDBEngine,XMIDILib_TLB,OleCtrls,NEWSRLib_TLB
  ,ExtCtrls,MPlayer,ComCtrls,jpeg,Menus;
type
  TTalkThread=class(TThread)

  private

    ToyNumber:Integer;

    TalkFile :string;

    Motion   :Integer;

  protected

    constructor create(ToyNumberl:Integer;TalkFilel:string;
Motionl:Integer);

    procedure Execute;override;

  end;
  TMainForm=class(TForm)

  Buttonl:TButton;

  SRl:TSR;

  XMidil:TXMidi;

  MainMenul:TMainMenu;

  testl:TMenuItem;

  spacel:TMenuItem;

  Panell:TPanel;

  MediaPlayerl:TMediaPlayer;

  Timerl:TTimer;

  procedure FormCreate(Sender:TObject);

  procedure FormClose(Sender:Tobject;var Action:TCloseAction);

  procedure spacelClick(Sender:TObject);

  procedure TimerlTimer(Sender:TObject);
  private

  (Private declarations)
				
				<dp n="d105"/>
     TalkingInThread:TTalkThread;

   public

     ( Public declarations )

       CurrentPath     :string;

       CreatorPath     :string;

       DatabasePath    :string;

       GraphicsPath    :string;

       AudioPath       :string;

       UsagePath       :string;

       AboutYouPath    :string;

       Toy             :TToy;

       ToyMachine      :string;

       PDBEngine       :TPDBEngine;

       ThreadInProgress :Boolean;

       ToyNameIsStoryTeller :string;

       ToyNameIsBear        :string;

       procedure ApplicationInitialization;

       procedure GotoMainMenu;

       procedure GotoCreator;

       function BackGroundTalking(TalkFile:string;Motion:string)
:Integer;

       function GetCurrentPath(CurrentExeName:string):string;

       function TalkInBackGround(ToyNumber:Integer;TalkFile:string;

                                 Motion:string):Integer;
   end;
var
  MainForm:TMainForm;
implementation
uses Menu,Status,creator;
(SR *.DFM)
procedure TMainForm.FormCreate(Sender:TObject);
begin
//   screen.cursor:=crDefault;
   ToyNameIsStoryTeller:= ′StoryTeller′;
   ToyNameIsBear       := ′TeddyBear′;
				
				<dp n="d106"/>
  Screen.Cursors[5]:=LoadCursor(HInstance,′PestoHand.Cur′);

  Screen.Cursors[6]:=LoadCursor(HInstance,′PestoMenu.Cur′);

  cursor:=5;

  ApplicationInitialization;

  Cursor:=crNone;

  Timerl.Interval:=1000;

  Timerl.Enabled :=True;

  if(Toy.ToyNumber>0)and(Toy.ToyNumber<32)then ToyMachine:=
 ToyNameIsBear

     else ToyMachine:=ToyNameIsStoryTeller;
 end;
 procedure TMainForm.ApplicationInitialization;
 begin
 // Fill Pathes

     CurrentPath:=GetCurrenfPath(Application.ExeName);

     CreatorPath:=
 Copy(CurrentPath,1,Length(CurrentPath)-Length(′Executables\′));

     //CreatorPath     :=Copy(Application.ExeName,1,

                           //Length(Application.ExeName)-27);

     DatabasePath     :=CreatorPath+ ′PESTO\DATABASE\′;

     GraphicsPath     :=CreatorPath+ ′PESTO\GRAPHICS\′;

     AudioPath        :=CreatorPath+ ′PESTO\AUDIO\′;

     UsagePath        :=CreatorPath+ ′PESTO\USAGE\′;

     PDBEngine   :=TPDBEngine.create(self);

     PDBEngine.DataBasePath   :=DatabasePath;

     PDBEngine.LoadRegistration;

     PDBEngine.SetChildNumber(1);

     PDBEngine.LoadConfiguration;

     Toy :=TToy.Create(self);

     Toy.ToyNumber:=PDBEngine.ToyNumber;

     Toy.TurnOn;

     Application.Icon.LoadFromFile(GraphicsPath+′PestoIcon.ico′);

     AboutYouPath     :=AudioPath+′AboutYou\′;
end;
function TMainForm.GetCurrentPath(CurrentExeName:string):string;
var
   i:integer;
begin
   i:=Length(CurrentExeName);
   While i>0 do
   begin
				
				<dp n="d107"/>
          if Copy(CurrentExeName,i,l)= ′\′then i:=0

          else

            begin

              i:=i-1;

              CurrentExeName:=Copy(CurrentExeName,l,i);

           end;

   end;

   Result :=CurrentExeName;
end;
procedure TMainForm. GotoMainMenu;
begin

        if Time<StrToTime(′12:00:00′) then

           BackGroundTalking(AboutYouPath + ′vo001.wav′,′S′)

       else

       if Time>StrToTime(′16:00:00′)then

          BackGroundTalking(AboutYouPath + ′vo003.wav′,′5′)

       else

          BackGroundTalking(AboutYouPath + ′vo002.wav′,′S′);

   Spacel.Enabled:=False;

   Hide;

   Timerl.Enabled:=False;

   MenuForm.Show;
end;
procedure TMainForm.FormClose(Sender:TObject;var Action:TCloseAction);
begin
   if ThreadInProgress then Exit;
   Toy.TurnOff;
   Toy.Free;
   PDBEngine.Free;
end;
procedure TMainForm.spacelClick(Sender:TObject);
begin
//space
   GotoCreator;
end;
procedure TMainForm.GotoCreator;
begin
				
				<dp n="d108"/>
    Spacel.Enabled:=False;

    Hide;

    CreatotForm.Show;

    CreatorForm.PlayMovie;

    Timerl.Enabled:=False;
 end;
function TMainForm.BackGroundTalking(TalkFile:string;Motion:string)
:Integer;
var

  Threadl:TTalkThread;
begin

   ThreadInProgress:=True;

   Threadl:=TTalkThread.create(Toy.ToyNumber,TalkFile,0);

    Result:=0;
end;
function TMainForm.TalkInBackGround(ToyNumber:Integer;TalkFile:string;

                                    Motion:string):Integer;
var
   Threadl:TTalkThread;
begin
   ThreadInProgress:=True;
   Threadl:=TTalkThread.create(ToyNumber,TalkFile,0);
   Result:=0;
end;
constructor TTalkThread.create(ToyNumber1:Integer;TalkFile1:string ;
Motionl:Integer);
begin
   inherited create(False);
   ToyNumber:=ToyNumber1;
   TalkFile :=TalkFile1;
   Motion   :=Motionl;
   FreeOnTerminate :=True;
end;
procedure TTalkThread.Execute;
begin

                               //85 =55H BroadCast

  if(MainForm.ToyMachine =′StoryTeller′)and(ToyNumber<>85)then

             MainForm.XMidil.ToyTalk2(ToyNumber,TalkFile,0,0,Motion,0);

  if(MainForm.ToyMachine= ′TeddyBear′)or(ToyNumber=85)        then
				
				<dp n="d109"/>
             MainForm.XMidil.NewToyTalk(ToyNumber,TalkFile,0,9,0);

    Terminate;

    MainForm.ThreadInProgress:=False;

  Exit;
end;
procedure TMainForm.TimerlTimer(Sender:TObject);
begin
   //GotoCreator;
   GotoMainMenu;
end;
end.
				
				<dp n="d110"/>
================================

  Copyright (c) 1995-1998 Creator Ltd. All Rights Reserved
================================
Description:This is the Checkup unit.
unit CheckUp;
interrface
uses
  Windows.Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs,
  ExtCtrls.Jpeg.ComCtrls;
type
  TCheckUpForm=class(TForm)
   Imagel:TImage;
   ExitImage:TImage;
   CarAnimate:TAnimate;
   ClownAnimate:TAnimate;
   DuckAnimate:TAnimate:
   DuckWalkAnimate:TAnimate;
   LightOrganAnimate:TAnimate;
   LogoMoveAnimate:TAnimate;
   MicrophoneAnimate:TAnimate;
   MotionLetersAnimate:TAnimate;
   SensorAnimate:TAnimate;
   SpeakerAnimate:TAnimate;
   Image2:TImage:
   procedure ExitImageClick(Sender:TObject);
   procedure FormCreate(Sender:TObject);
   procedure Image2Click(Sender:TObject);
 private
   {Private declarations}
 pubiic
   {Pubiic declarations}
  procedure ActivateTheAnimation(value:boolean);
 end;
var
				
				<dp n="d111"/>
 CheckUpForm:TCheckUpForm:
implementation
uses Menu.Main:
{SR*.DFM}
procedure TCheckUpForm.ExitImageClick(Sender:TObject);
begin
//
 Hide:
 Activate TheAnimation(False);
 MenuForm.Show;
end;                                            
procedure TCbeckUpForm.FormCreate(Sender:TObject);
begin
//
 with CarAnimate do
 begin
   FileName:=MainForm GraphicsPath+ ′Car.avi′;
   Left :=260;
   Top  :=441;
   Width :=80;
   Height:=60:
 end;
 with ClownAnimate do
 begin
   FileName :=MainForm GraphicsPath + ′Clownavi′;
   Left :=652;
   Top  :=393;
   Width :=32;
   Height :=40;
 end;
 with DuckAnimate do
 begin
				
				<dp n="d112"/>
  FileName :=MainForm.GraphicsPath+ ′Duckavi′:
  Left :=613;
  Top  :=114;
  Width :=48;
  Height :=50;
end;
with DuckWalkAnimate do
begin
  FileName:=MainForm.GraphicsPath+ ′DuckWalk.avi′;
  Left:=599;
  Top :=216;
  Width :=128;
  Height :=115;
end;
with LightOrganAnimate do
begin
  FileName :=MainForm.GraphicsPath+LightOrgan.avi′;
  Left:=455;
  Top:=440;
  Width :=48;

    Height :=70;
  end;
  with LogoMoveAnimate do
  begin

    FileName := MainForm.GraphicsPath + ′LogoMove.avi ′;

    Left    :=336;

    Top     :=19;

    Width  :=112;

    Height :=45;
  end;
  with MicrophoneAnimate do
  begin

    FileName :=MainForm.GraphicsPath + ′HubWave.avi′;

    Left    :=95;

    Top     :=365;

    Width   :=80;
				
				<dp n="d113"/>
       Height :=40;

   end;

    with MotionLetersAnimate do

    begin

       FileName :=MainForm.GraphicsPath + ′MotionLeters.avi′;

       Left     :=468;

       Top      :=172;

       Width    :=144;

       Height   :=45;

    end;

    with SensorAnimate do

    begin

       FileName :=MainForm.GraphicsPath + ′Sensor.avi′;

       Left     :=341;

       Top      :=227;

       Width    := 96;

       Height   :=60;

  end;

   with SpeakerAnimate do

   begin

     FileName :=MainForm. GraphicsPath + ′Speaker.avi′;

     Left    :=57;

     Top     :=169;

     Width   :=96;

     Height  :=80;

  end;
end;
procedure TCheckUpForm. ActivateTheAnimation(value:boolean);
begin
//

     try

        CarAnimate.Active             :=Value;

     except

     end;

     try

        ClownAnimate.Active           :=Value;

     except
				
				<dp n="d114"/>
    end;

    try

           DuckAnimate.Active           :Value;

    except

    end;

    try

           DuckWalkAnimate.Active       :=Value;

    except

    end;

    try

           LightOrganAnimate.Active     :=Value;

    except

    end;

    try

           LogoMoveAnimate.Active      :=Value;

    except

    end;

    try

           MicrophoneAnimate.Active     :=Value;

    except

    end;

    try

           MotionLetersAnimate.Active   :=Value;

    except

    end;

    try

           SensorAnimate.Active         :=Value;

    except

    end;

    try

           SpeakerAnimate.Active        :=Value;

    except

    end;
end;
				
				<dp n="d115"/>
procedure TCheckUpForm.Image2Click(Sender:TObject);
begin
//
//  MainForm.Toy.TurnOff;
  sleep(5000);
  ActivateTheAnimation(False);
  close;
  MainForm. close;
  WinExec(PChar(MainForm.CurrentPath+ ′PESTOInstallation′),sw_show);
  Application.Terminate;
end;
end.
				
				<dp n="d116"/>
================================

  Copyright (c) 1995-1998 Creator Ltd. All Rights Reserved
================================
Description:This is the Creator unit.
unit creator;
interface
uses
  Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs,
  Menus,ExtCtrls,MPlayer;
type
  TCreatorForm=class(TForm)

  MainMenul:TMainMenu;

  testl:TMenuItem;

  spacel:TMenuItem;

  MediaPlayerl:TMediaPlayer;

  Panell:TPanel;

  Timerl:TTimer;

  Escapel:TMenuItem;

  procedure spacelClick(Sender:TObject);

  procedure TimerlTimer(Sender:TObject);

  procedure FormCreate(Sender:TObject);

  procedure EscapelClick(Sender:TObject);

  procedure FormClose(Sender:TOdject;var Action:TCloseAction);
  private

  (Private declarations)
  public

  (Public declarations)

  StartPlay:Integer;

  procedure PlayMovie;

  procedure GoToPestoSong;
  end;
var

  CreatorForm:TCteatorForm;
implementation
uses PestoSong,Main,Menu;
				
				<dp n="d117"/>
(SR *.DFM)
procedure TCreatorForm.spacelClick(Sender:TObject);
begin
//space
   GoToPestoSong;
end;
procedure TCreatorForm.GoToPestoSong;
begin
//
   Spacel.Enabled:=False;
   MediaPlayerl.stop;
   MediaPlayerl.Close;
   hide;
   PestoSongForm.Show;
   PestoSongForm.PlayMovie;
   Timerl.Enabled:=False;
end;
procedure TCreatorForm.PlayMovie;
begin
//
  try

  Timerl.Enabled:=True;

  MediaPlayerl.Play;
  except
 end;
end;
procedure TCreatorForm.TimerlTimer(Sender:TObject);
begin
//
   StartPlay:=StartPlay+1;
   if StartPlay=1 then exit;
   GoToPestoSong;
end;
procedure TCreatorForm.FormCreate(Sender:TObject);
begin
//
   Timerl.Enabled:=False;
				
				<dp n="d118"/>
   Panell.Cursor:=crNone;

   Timerl.Interval:=17000;

   StartPlay:=0;

   Cursor:=crNone;

   MediaPlayerl.FileName:=MainForm.GraphicsPath+ ′Open0.avi′;
end;
procedure TCreatorForm.EscapelClick(Sender:TObject);
begin
//  Exit

  try

    MediaPlayerl.stop;

  except

  end;

  try

    MediaPlayerl.Close;

  except

  end;

  Hide;

  MenuForm.Show;
end;
procedure TCreatorForm.FormClose(Sender:TObject;
  var Action:TCloseAction);
begin
//  Exit

  try

    MediaPlayerl.stop;

  except

  end;

  try

    MediaPlayerl.Close;

  except

  end;
end;
end.
				
				<dp n="d119"/>
================================

  Copyrignt (c) 1995-1998 Creator Ltd. All Rights Reserved
================================
Description:This is the Menu unit.
unit Menu;
interface
uses
  Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs,
  StdCtrls,Buttons,ExtCtrls,ComCtrls,Intto,jpeg,Toy,Menus;
type
  TMenuForm=class(TForm)

  MenuImage:TImage;

  SetupImage:TImage;

  AnimationImage:TImage;

  IntroImage:TImage;

  PlayImage:TImage;

  ExitImage:TImage;

  TVAnimate:TAnimate;

  PickUserImage:TImage;

  OKButtonImage:TImage;

  UserNameEdit:TEdit;

  SetUpOrgImage:TImage;

  CheckImage:TImage;

  PickUserTitleLabel:TLabel;

  PickUserLabel1:TLabel;

  PickUserLabel2:TLabel;

  ImageFrame1:TImage;

  ImageFrame2:TImage;

  ImageFrame3:TImage;

  ImageFrame4:TImage;

  ImageFrame5:TImage;

  ImageErame6:TImage;

  UserNameLabel1:TLabel;

  UserNameLabel2:TLabel;

  UserNameLabel3:TLabel;

  UserNameLabel4:TLabel;

  UserNameLabel5:TLabel;

  UserNameLabel6:TLabel;
				
				<dp n="d120"/>
UserNameLabel7:TLabel;
UserNameLabel8:TLabel;
MainMenul:TMalnMenu;
testll:TMenuItem;
Enterl:TMenuItem;
Escapel:TMenuItem;
ToyImage:TImage;
ToyAnimate:TAnimate;
procedure FormCreate(Sender:TObject);
procedure UserName1ButtonClick(Sender:TObject);
procedure UserName2ButtonClick(Sender:TObject);
procedure UserName3ButtonClick(Sender:TObject);
procedure UserName4ButtonClick(Sender:TObject);
procedure UserName5ButtonClick(Sender:TObject);
procedure UserName6ButtonClick(Sender:TObject);
procedure UserName7ButtonClick(Sender:TObject);
procedure UserName8ButtonClick(Sender:TObject);
procedure UserName1ButtonMouseMove(Sender:TObject;Shift:TShiftState;
  X,Y:Integer);
procedure UserName2ButtonMouseMove (Sender:TObject;Shift:TShiftState;
  X,Y:Integer);
procedure UserName3ButtonMouseMove (Sender:TObject;Shift:TShiftState;
  X,Y:Integer);
procedure UserName4ButtonMouseMove (Sender:TObject;Shift:TShiftState;
  X,Y:Integer);
procedure UserNameSButtonMouseMove (Sender:TObject;Shift:TShiftState;
  X,Y:Integer);
procedure UserName6ButtonMouseMove (Sender:TObject;Shift:TShiftState;
  X,Y:Integer);
procedure UserName7ButtonMouseMove (Sender:TObject;Shift:TShiftState;
  X,Y:Integer);
procedure UserName8ButtonMouseMove (Sender:TObject;Shift:TShiftState;
  X,Y:Integer);
procedure OKButtonImageClick(Sender:TObject);
procedure ImageFrame1MouseMove(Sender:TObject;Shift:TShiftState;X,
  Y:Integer);
procedure ImageFrame2MouseMove(Sender:TObject;Shift:TShiftState;X,
  Y:Integer);
procedure ImageFrame3MouseMove(Sender:TObject;Shift:TShiftState;X,
  Y:Integer);
procedure ImageFrame4MouseMove(Sender:TObject;Shift:TShiftState;X,
  Y:Integer);
procedure ImageFrame5MouseMove(Sender:TObject;Shift:TShiftState;X,
				
				<dp n="d121"/>
    Y:Integer);

  procedure ImageFrame6MouseMove(Sender:TObject;Shift:TShiftState;X,

    Y:Integer);

  procedure ImageFrame1Click(Sender:TObject);

  procedure ImageFrame2Click(Sender:TObject);

  procedure ImageFrame3Click(Sender:TObject);

  procedure ImageFrame4Click(Sender:TObject);

  procedure ImageFrame5Click(Sender:TObject);

  procedure ImageFrame6Click(Sender:TObject);

  procedure MenuImageMouseMove(Sender:TObject;Shift:TShiftstate;X,

    Y:Integer);

  procedure EnterlClick(Sender:TObject);

  procedure EscapelClick(Sender:TObject);

  procedure FormClose(Sender:TObject;var Action:TCloseAction);
 private
   (Private declarations)

  procedure ResetCurrentButton;

  procedure UserNameDefaultColor;

  procedure ClearUserName;

  procedure AssignCursorsInImages;

  procedure ShowRegistration(Value:string);
 public

  (Public declarations)

  Threadl         :TIntro;

  CurrentButton   :String;
  end;
var
  MenuForm:TMenuForm;
const
  crPESTOHandCursor=100;
  crPESTOMenuCursor=101;
implementation
uses Main,Status,Registration,ToySimulation,MotionSimulation,CheckUp,
  PestoSong,SingAlong,creator;
(SR *.DEM)
procedure TMenuForm.ResetCurrentButton;
begin
				
				<dp n="d122"/>
       if CurrentButton = ′SetUp′      then SetupImage.Visible      :=
False;

       if CurrentButton = ′Animation′  then AnimationImage.Visible :=
False;

       if CurrentButton = ′Intro′      then IntroImage.Visible      :=
False;

       if CurrentButton = ′Play′       then PlayImage.Visible    :=
False;

       if CurrentButton = ′Check′      then CheckImage.Visible   :=
False;

       if CurrentButton = ′Exit′       then ExitImage.Visible    :=
False;
end;
procedure TMenuForm.FormCreate(Sender:TObject);
begin

  Screen.Cursors[crPESTOHandCursor]:=

               LoadCursor(HInstance,′PESTOHAND.CUR′);

  Screen.Cursors[crPESTOMenuCursor]:=

               LoadCursor(HInstance,′PESTOMENU.CUR′);

  TVAnimate. FileName:=MainForm. GraphicsPath+′Noise.AVI′;

  TVAnimate.Active:=True;

  MainForm. Hide;

  Threadl:=nil;

  SetupImage.Visible       :=True;

  SetUpOrgImage.Visible    :=False;

  AnimationImage.Visible   :=False;

  IntroImage.Visible       :=False;

  PlayImage. Visible       :=False;

  CheckImage.Visible       :=False;

  ExitImage. Visible       :=False;

  SetupImage.cursor        :=crPESTOMenuCursor;

  SetUpOrgImage.cursor     :=crPESTOMenuCursor;

  AnimationImage.cursor    :=crPESTOMenuCursor;

  IntroImage.cursor        :=crPESTOMenuCursor;

  PlayImage.cursor         :=crPESTOMenuCursor;

  CheckImage.cursor        :=crPESTOMenuCursor;

  ExitImage.cursor         :=crPESTOMenuCursor;

  ImageFrame1.cursor       :=crPESTOHandCursor;
				
				<dp n="d123"/>
     ImageFrame2.cursor      :=crPESTOHandCursor;

     ImageFrame3.cursor      :=crPESTOHandCursor;

     ImageFrame4.cursor      :=crPESTOHandCursor;

     ImageFrame5.cursor      :=crPESTOHandCursor;

     ImageFrame6.cursor      :=crPESTOHandCursor;

     OKButtonImage.Cursor    :=crPESTOHandCursor;

      CurrentButton := ′SetUp′;
// Unvisible Registration

      PickUserImage.Visible:=False;

      // Reg 1

       PickUserTitleLabel.Visible:=False;

       UserNameLabel1.Visible:=False;

       UserNameLabel2.Visible:=False;

       UserNameLabel3.Visible:=False;

       UserNameLabel4.Visible:=False;

       UserNameLabel5.Visible:=False;

       UserNameLabel6.Visible:=False;

       UserNameLabel7.Visible:=False;

       UserNameLabel8.Visible:=False;

       // Reg 2

       PickUserLabel1.Visible:=False;

       PickUserLabel2.Visible:=False;

       UserNameEdit.Visible  :=False;

       OKButtonImage.Visible :=False;

       //

       Cursor:=crPESTOMenuCursor;

       //AssignCursorsInImages;

       UserNameLabel1.Caption := ′NEW USER′;

       With ToyAnimate do

       begin

           FileName :=MainFom.GraphicsPath+′Eye.AVI′;

           Active :=True;

           Left    :=376;

           Top     :=252;

           Width   :=80;

           Height  :=40;

        end;

        With ToyImage do

        begin

              Left  :=265;
				
				<dp n="d124"/>
             Top    :=177;

             Width  :=309;

             Height :=368;

         end;
end;
procedure TMenuForm.UserName1ButtonClick(Sender:TObject);
begin
  //

        if MainForm.ThreadInProgress then exit;

        PickUserTitleLabel.Visible :=False;

        UserNameLabel1.Visible :=False;

        UserNameLabel2.Visible :=False;

        UserNameLabel3.Visible :=False;

        UserNameLabel4.Visible :=False;

        UserNameLabel5.Visible :=False;

        UserNameLabel6.Visible :=False;

        UserNameLabel7.Visible :=False;

        UserNameLabel8.Visible :=False;

        UserNameEdit.Text       :=′’′;

        PickUserLabel1.Visible  :=True;

        PickUserLabel2.Visible  :=True;

        UserNameEdit.Visible    :=True;

        OKButtonImage.Visible  :=True;

        UserNameEdit.SetFocus;

        MainForm.PDBEngine.InsertNewChild;

        MainForm.BackGroundTalking(MainForm.AboutYouPath+ ′vo0042.wav′,′S′);
end;
procedure TMenuForm. UserName2ButtonClick(Sender:TObject);
begin
 //
   if MainForm.ThreadInProgress then exit;
   MainForm.PDBEngine.SetChildNumber(1);
   ShowRegistration(UserNameLabel2.Caption);
end;
procedure TMenuForm.UserName3ButtonClick(Sender:TObject);
begin
//
   if MainFoLm.ThreadInProgress then exit;
   MainFom.PDBEngine.SetChildNumber(2);
				
				<dp n="d125"/>
  ShowRegistration(UserNameLaoel3.laptlon;
 end;
procedure TMenuForm.UserName4ButtonClick(Sender:TObject);
begin
 //

  if MainForm.ThreadInProgress then exit;

  MainForm.PDBEngine.SetChildNumber(3);

  ShowRegistration(UserNameLabel4.Caption);
end;
procedure TMenuForm.UserName5ButtonClick(Sender:TObject);
begin
//

  if MainForm.ThreadInProgress then exit;

  MainForm.PDBEngine.SetChildNumber(4);

  ShowRegistration(UserNameLabel5.Caption);
end;
procedure TMenuForm.UserName6ButtonClick(Sender:TObject);
begin
//
   if MainForm.ThreadInProgress then exit;
   MainForm.PDBEngine.SetChildNumber(5);
   ShowRegistration(UserNameLabel6.Caption);
end;
proceure TMenuForm.UserName7ButtonClick(Sender:TObject);
begin
//
   if MainForm.ThreadInProgress then exit;
   MainForm.PDBEngine.SetChildNumber(6);
   ShowRegistration(UserNameLabel7.Caption);
end;
procedure TMenuForm.UserName8ButtonClick(Sender:TObject);
begin
//
   if MainForm.ThreadInProgress then exit;
   MainForm.PDBEngine.SetChildNumber(7);
   ShowRegistration(UserNameLabel8.Caption);
end;
				
				<dp n="d126"/>
procedure TMenuForm.UserName1ButtonMouseMove(Sender:TObject;
   Shift:TShiftState;X,Y:Integer);
begin
 //

  if UserNameLabel1.Font.Color<>clGreen then

     begin

        UserNameDefaultColor;

        UserNameLabel1.Font.Color:=clGreen;

     end;
end;
procedure TMenuForm.UserNameDefaultColor;
var

  UserColor:TColor;
begin
//

  UserColor:=clRed;

  UserNameLabel1.Font.Color:=UserColor;

  UserNameLabel2.Font.Color:=UserColor;

  UserNameLabel3.Font.Color:=UserColor;

  UserNameLabel4.Font.Color:=Usercolor;

  UserNameLabel5.Fonc.Color:=UserColor;

  UserNameLabel6.Font.Color:=Usercolor;

  UserNameLabel7.Font.Color:=UserColor;

  UserNameLabel8.Font.Color:=UserColor;
end;
procedure TMenuForm.UserName2ButtonMouseMove(Sender:TObject;
  Shift:TShiftState;X,Y:Integer);
begin
//
   if UserNameLabel2.Font.Color<>clGreen then

    begin

        UserNameDefaultColor;

        UserNameLabel2.Font.Color:=clGreen;

      end;
end;
procedure TMenuForm.UserName3ButtonMouseMove(Sender:TObject;
   Shift:TShiftState;X,Y:Integer);
begin
				
				<dp n="d127"/>
//
   if UserNameLabel3.Font.Color<>clGreen then

    begin

      UserNameDefaultColor;

      UserNameLabel3.Font.Color:=clGreen;

    end;
end;
procedure TMenuForm.UserName4ButtonMouseMove(Sender:TObject;
  Shift:TShiftState;X,Y:Integer);
begin
//

   if UserNameLabel4.Font.Color<>clGreen then

      begin

         UserNameDefaultColor;

         UserNameLabel4.Font.Color:=clGreen;

      end;
end;
procedure TMenuForm.UserName5ButtonMouseMove(Sender:TObject;
  Shift:TShiftState;X,Y:Integer);
begin
//

   if UserNameLabel5.Font.Color<>clGreen then

      begin

         UserNameDefaultColor;

         UserNameLabel5.Font.Color:=clGreen;

      end;
end;
procedure TMenuForm.UserName6ButtonMouseMove(Sender:TObject;
  Shift:TShiftState;X,Y:Integer);
begin
//

  if UserNameLabel6.Font.Color<>clGreen then

     begin

        UserNameDefaultColor;

        UserNameLabel6.Font.Color:=clGreen;

      end;
end;
procedure TMenuForm.UserName7ButtonMouseMove(Sender:TObject;
  Shift:TShiftState;X,Y:Integer);
				
				<dp n="d128"/>
begin
//

  if UserNameLabel7.Font.Color<>clGreen then

     begin

        UserNameDefaultColor;

        UserNameLabel7.Fonr.Color:=clGreen;

      end;
end;
procedure TMenuForm.UserName8ButtonMouseMove(Sender:TObject;
  Shift:TShiftState;X,Y:Integer);
begin
//

   if UserNameLabel8.Font.Color<>clGreen then

    begin

        UserNameDefaultColor;

        UserNameLabel8.Font.Color:=clGreen;

      end;
end;
procedure TMenuForm.ClearUserName;
begin
//

      PickUserImage.Visible :=False;

      UserNameLabel1.Visible:=False;

      UserNameLabel2.Visible:=False;

      UserNameLabel3.Visible:=False;

      UserNameLabel4.Visible:=False;

      UserNameLabel5.Visible:=False;

      UserNameLabel6.Visible:=False;

      UserNameLabel7.Visible:=False;

      UserNameLabel8.Visible:=False;

      UserNameEdit.Visible  :=False;

      OKButtonImage.Visible :=False;
end;
procedure TMenuForm. OKButtonImageClick(Sender:TObject);
begin
//
   if MainForm.ThreadInProgress then exit;
   if Length(Trim(UserNameEdit.Text))>0 then
				
				<dp n="d129"/>
   begin

     with  MainForm.PDBEngine do

     begin

        SecretName           :=″;

        ChildSex             :=″;

        BirthDay             :=″;

        ChildEyeColor        :=″;

        ChildHairColor       :=″;

        BedTimeHour          :=″;

        FavoriteColor        :=″;

        FavoriteFood         :=″;

        FavoriteActivity     :=″;

        FavoriteAnimal       :=″;

      end;

    ShowRegistration(TrimLeft(UserNameEdit.Text));

    end;
end;
procedure TMenuForm. AssignCursorsInImages;
begin
//

   PickUserImage.Cursor   :=crPESTOHandCursor;

   UserNameLabel1.Cursor  :=crPESTOHandCursor;

   UserNameLabel2.Cursor  :=crPESTOHandCursor;

   UserNameLabel3.Cursor  :=crPESTOHandCursor;

   UserNameLabel4.Cursor  :=crPESTOHandCursor;

   UserNameLabel5.Cursor  :=crPESTOHandCursor;

   UserNameLabel6.Cursor  :=crPESTOHandCursor;

   UserNameLabel7.Cursor  :=crPESTOHandCursor;

   UserNameLabel8.Cursor  :=crPESTOHandCursor;

   UserNameEdit.Cursor    :=crPESTOHandCursor;

   OKButtonImage.Cursor   :=crPESTOHandCursor;
end;
procedure TMenuForm.ImageFrame1MouseMove(Sender:TObject;
  Shift:TShiftState;X,Y:Integer);
begin

        if CurrentButton<>′SetUp′then

          begin

            ResetCurrentButton;

            SetupImage. Visible    :=True;

            CurrentButton          :=′SetUp′;
				
				<dp n="d130"/>
          end;
end;
procedure TMenuForm.ImeFrame2MouseMove(Sender:TObject;
  Shift:TShiftState;X,Y:Integer);
begin

        if CurrentButton<>′Animation′then

          begin

            ResetCurrentButton;

            AnimationImage.Visible:=True;

            CurrentButton         :=′Animation′;

         end;
end;
procedure TMenuForm.ImageFrame3MouseMove(Sender:TObject;
  Shift:TShiftState;X,Y:Integer);
begin

       if CurrentButton<>′Intro′then

         begin

           ResetCurrentButton;

           IntroImage.Visible      :=True;

           CurrentButton           :=′Intro′;

        end;
end;
procedure TMenuForm.ImageFrame4MouseMove(Sender:TObject;
  Shift:TShiftState;X,Y:Integer);
begin

       if CurrentButton<>′Play′then

         begin

           ResetCurrentButton;

           PlayImage.Visible   :=True;

           CurrentButton       :=′Play′;

         end;
end;
procedure TMenuForm.ImageFrame5MouseMove(Sender:TObject;
  Shift:TShiftState;X,Y:Integer);
begin

        if CurrentButton<>′Check′then

          begin

            ResetCurrentButton;

            CheckImage.Visible    :=True;
				
				<dp n="d131"/>
             CurrentButton         :=′Check′;

          end;
end;
procedure TMenuForm.ImageFrame6MouseMove(Sender:TObject;
   Shift:TShiftState;X,Y:Integer);
begin

        if Current8utton<>′Exit′then

          begin

            ResetCurrentButton;

            ExitImage.Visible      := True;

            CurrentButton          :=′Exit′;

          end;
end;
procedure TMenuForm.ImageFrame1Click(Sender:TObject);
begin

      if MainForm.ThreadInProgress then exit;

   // Load From DataBase

      MainForm.PDBEngine.SetChildNumber(1);

      UserNameLabel2.Caption:=MainForm.PDBEngine.ChildName;

      MainForm.PDBEngine.SetChildNumber(2);

      UserNameLabel3.Caption:=MainForm,PDBEngine.ChildName;

      MainForm.PDBEngine.SetChildNumber(3);

      UserNameLabel4,Caption:=MainForm.PDBEngine.ChildName;

      MainForm.PDBEngine,SetChildNumber(4);

      UserNameLabel5.Caption:=MainForm,PDBEngine.ChildName;

      MainForm,PDBEngine.SetChildNumber(5);

      UserNameLabel6.Caption:=MainForm.PDBEngine.ChildName;

      MainForm.PDBEngine.SetChillier(6);

      UserNameLabel7.Caption:=MainForm.PDBEngine.ChildName;

      MainForm.PDBEngine.SetchildNumer(7);

      UserNameLabel8.Caption:=MainForm.PDBEngine.ChildName;

   // Registration

      SetupImage.Visible        :=False;

      SetupOrgImage.Visible     :=True;

      PickUserTitleLabel.Visible:=True;

      PickUserImage.Visible    :=True;

      UserNameLabel1.Visible:=True;

      UserNameLabel2.Visible:=True;

      UserNameLabel3.Visible:=True;

      UserNameLatel4.Visible:=True;

      UserNameLatel5.Visible:=True;
				
				<dp n="d132"/>
      UserNameLabel6.Visible:=True;

      UserNameLabel7.Visible:=True;

      UserNameLabel8.Visible:=True;

  if  UserNameLabel2.Caption =″then     UserNameLabel2.Visible := False;

  if  UserNameLabel3.Caption =″then     UserNameLabel3.Visible := False;

  if  UserNameLabel4.Caption =″then     UserNameLabel4.Visible := False;

  if  UserNameLabel5.Caption =″then     UserNameLabel5.Visible := False;

  if  UserNameLabel6.Caption =″then     UserNameLabel6.Visible := False;

  if  UserNameLabel7.Caption =″then     UserNameLabel7.Visible := False;

  if  UserNameLabel8.Caption =″then     UserNameLabel8.Visible := False;

          ImageFrame1.Enabled       :=False;

          ImageFrame2.Enabled       :=False;

          ImageFrame3.Enabled       :=False;

          ImageFrame4.Enabled       :=False;

          ImageFrame5.Enabled       :=False;

          ImageFrame6.Enabled       :=False;
   //Toy To TV

          ToyAnimate.Visible:=FaLse;

          ToyImage.Visible  :=False;

          with TVAnimate do

          begin

            Active   :=False;

            FileName :=MainForm.GraphicsPath+′TV.AVT′;

            Active   :=True;

            Left     :=627;

            Top      :=308;

            Width    :=101;

            height   :=104;

          end;
  //

  MainForm.BackGroundTalking(MainForm.AboutYouPath+ ′vo0041.wav′,′S′);
end;
procedure TMenuForm.ImageFrame2Click(Sender:TObject);
begin
// Sing Along
{Hide;
   CreatorForm. Show;
   CreatorFom.PlayMovie;}
   SingAlongForm. PlaySongs;
   {with SingALongForm do
				
				<dp n="d133"/>
    begin

        Spacel.Enabled:=True;

        PlaySongs;

        Show;

    end;}
 end;
 procedure TMenuForm.ImageFrame3Click(Sender:TObject);
 begin

  // Execute INTRO

     MainForm.Hide;

     Hide;

     StatusForm.Caption:=′Storyteller How-to-Play Status′;

     StatusForm.Show;

     if MainForm.PDBEngine.ToyNumber<0 then

     begin

        SimulationForm.Show;

        MotionSimulationForm.Show;

     end;

     Threadl:=TIntro.Create(′Intro′);
end;
procedure TMenuForm.ImageFrame4Click(Sender:TObject);
begin
   // Execute PLAY

    MainForm.Hide;

    Hide;

    StatusForm.Caption:=′Storyteller Play Status′;

    StatusForm.Show;

    if MainForm.PDBEngine.ToyNumber<0 then

    begin

       SimulationForm.Show;

       MotionSimulationForm.Show;

    end;

    Threadl:=TIntro.Create(′Play′);
end;
procedure TMenuForm.ImageFrameSClick(Sender:TObject);
begin
//
  Hide;
  CheckUpForm.ActivateTheAnimation(True);
  CheckUpForm.Show;
				
				<dp n="d134"/>
 end;
procedure TMenuForm.ImageFrame6Click(Sender:TObjecct);
begin
// Exit
   Close;
   MainForm. Close;
end;
procedure TMenuForm.MenuImageMouseMove(Sender:TObject;Shift:TShiftState;
  X,Y:Integer);
begin
  CurrentButton:=″;
  SetupImage.Visible     :=False;
  AnimationImage.Visible :=False;
  IntroImage.Visible     :=False;
  PlayImage.Visible      :=False;
  CheckImage.Visible     :=False;
  ExitImage.Visible      :=False;
end;
procedure TMenuForm.ShowRegistration(Value:string);
begin
  with RegistrationForm do
  begin

  CurrentItem       :=″;

  SecretName        :=″;

  Gender            :=″;

  DateOfBirth       :=″;

  EyeColor          :=″;

  HairColor         :=″;

  BedTimeHour       :=″;

  FavoriteColor     :=″;

  FavoriteFood      :=″;

  FavoriteActivity  :=″;

  FavoriteAnimal    :=″;

  BoyImage.Visible                  :=False;

  BoyHairYellowImage.Visible        :=False;

  BoyHairBlackImage.Visible         :=False;

  BoyHairOrangeImage.Visible        :=False;

  BoyHairBrownImage.Visible         :=False;

  BoyEyeBlueImage.Visible           :=False;
				
				<dp n="d135"/>
  BoyEyeGreenImage.Visible              :=False;

  BoyEyeBrownImage.Visible              :=False;

  BoyEyeBlackImage.Visible              :=False;

  BoyShirtYellowImage.Visible           :=False;

  BoyShirtBlueImage.Visible             :=False;

  BoyShirtRedImage.Visible              :=False;

  GirlImage.Visible                     :=False;

  GirlHairYellowImage.Visible           :=False;

  GirlHairBrownImage.Visible            :=False;

  GirlHairOrangeImage.Visible           :=False;

  GirlHairBlackImage.Visible            :=False;

  GirlEyeBlueImae.Visible               :=False;

  GirlEyeGreenImage.Visible             :=False;

  GirlEyeBrownImage.Visible             :=False;

  GirlEyeBlackImage.Visible             :=False;

  GirlShirtYellowImage.Visible          :=False;

  GirlShirtBlueImage.Visible            :=False;

  GirlShirtRedImage.Visible             :=False;

  FavoritePanel.Visible                 :=False;

  BirthDayPanel.Visible                 :=False;

  BedTimeHourPanel.Visible              :=False;
end;

   RegistrationForm.UserNameLabel.Caption:=Value;

   MainForm.PDBEngine.ChildName:=Value;

   MainForm.PDBEngine.UpDateCurrentChild;

   RegistrationForm.LoadFromDataBase;
//
with RegistrationForm do
begin
  if SecretName=″then

   begin

     AboutYouLabel.Visible                :=False;

     AboutSexLabel.Visible                :=False;

     AboutAgeLabel.Visible                :=False;

     AboutEyeLabel.Visibie                :=False;

     AboutHairLabel.Visible               :=False;

     AboutBedTimeLabel.Visible            :=False;

     FavoritesLabel.Visible               :=False;

     FavoritesColorLabel.Visible          :=False;

     FavoritesFoodLabel.Visible           :=False;

     FavoritesActivityLabel.Visible       :=False;
				
				<dp n="d136"/>
       FavorltesAnimalLabel.Visble        :=False;

    end
   else

   begin

      AboutYouLabel.Visible                 :=True;

      AboutSexLabel.Visible                 := True;

      AboutAgeLabel.Visible                 := True;

      AboutEyeLabel.Visible                 := True;

      AboutHairLabel.Visible                := True;

      AboutBedTimeLabel.Visible             := True;

      FavoritesLabel.Visible                := True;

      FavoritesColorLabel.Visible           := True;

      FavoritesFoodLabel.Visible            := True;

      FavoritesActivityLabel.Visible        := True;

      FavoritesAnimalLabel.Visible          := True;

      DrawBoyOrGirl;

    end;
   end;
 //
 MainForm.PDBEngine.SetCurrentToFirst;
//

    MainForm.Hide;

    Hide;

    RegistrationForm.Show;

    RegistrationForm.ShowVTfSelected;
   MainForm.BackGroundTalking(MainForm.AboutYouPath+′vo0047.wav′,′S′);
end;
procedure TMenuForm.EnterlClick(Sender:TObject);
begin
// Enter=OK
   if OKButtonImage.Visible then OKButtonImageClick(nil);
end;
procedure TMenuForm.EscapelClick(Sender:TObject);
begin
//Exit
  Close;
  MainForm.Close;
end;
procedure TMenuForm.FormClose(Sender:TObject;var Action:TCloseAction);
				
				<dp n="d137"/>
begin

  TVAnimate.Active:=False;
end;
end.
				
				<dp n="d138"/>
================================

  Copyright (c) 1995-1998 Creator Ltd. All Rights Reserved
================================
Description:This is the PanelControls unit.
unit PanelControls;
interface
uses

  Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs,

  Buttons,ExtCtrls;
type

  TPanelControlForm=class(TForm)

    Panell:TPanel;

    PauseButton:TSpeedButton;

    StartButton:TSpeedButton;

    StopButton:TSpeedButton;

    procedure StopButtonClick(Sender:TObject);

    procedure StartButtonClick(Sender:TObject);

    procedute PauseButtonClick(Sender:TObject);

    procedure FormCreate(Sender:TObject);

    procedure FormHide(Sender:TObject);
   private

     (Private declarations)
   public

     (Public declarations)

     Status:string;
   end;
var
   PanelControlForm:TPanelControlForm;
implmeentation
{SR *.DFM}
procedure TPanelControlForm.StopButtonClick(Sender:TObject);
begin
   Status:=′STOP′;
end;
				
				<dp n="d139"/>
procedure TPanelControlForm.StartButtonClick(Sender:TObject);
begin
   Status:=′START′;
end;
procedure TPanelControlForm.PauseButtonClick(Sender:TObject);
begin
   Status:=′PAUSE′;
end;
procedure TPanelControlForm. FormCreate(Sender:TObject);
begin
   Status:=″;
end;
procedure TPanelControlForm.FormHide(Sender:TObject);
begin
   Status:=″;
end;
end.
				
				<dp n="d140"/>
================================

  Copyright (c) 1995-1998 Creator Ltd. All Rights Reserved
================================
Description:This is the PDBEngine unit.
unit PDBEngine;
  // Pseudo DataBase Engine
interface
uses
  Classes,Windows,SysUtils;
type
   TPDBEngine=class(TComponent)
   private
// Registration

  FChildName            :string;

  FChildSex             :string;

  FChiidEyeColor        :string;

  FChildHairColor       :string;

  FBedTimeHour          :string;

  FBirthDay             :string;

  FSecretName           :string;

  FFavoriteColor        :string;

  FFavoriteFood         :string;

  FFavoriteActivity     :string;

  FFavoriteAnimal       :string;

  FChildNumber          :Integer;

  FVisitSongMenu        :Integer;

  FVisitGameMenu        :Integer;

  FVisitStoryMenu       :Integer;
  FVisitBunnyShort      :Integer;

  FVisitBunnyLong       :Integer;

  FVisitPrincess        :Integer;

  FBunnyFavoriteFood    :string;
// Configuration

  FToyNumber     :Integer;

  FDataBasePath  :string;
// Multi Toys

  FMultiToy1          :Integer;

  FMultiToy2          :Integer;

  FMultiToy3          :Integer;
				
				<dp n="d141"/>
     FMultiToy4            :Integer;

     FMultiToy5            :Integer;

     FMultiToy6            :Integer;

     FMultiToy7            :Integer;

     FMultiToy8            :Integer;

protected
// Data[ChildNumber,FieldNumber]

  Data  :Array[1..10,1..40]of string; // change const;Example:
Data[i,j] :=′test′;

    procedure ClearDataArray;
   public

    procedure LoadRegistration;

    procedure SaveRegistration;

    procedure InsertNewChild;// Become First in the List (Array)

    procedure UpDateCurrentChild;

    procedure SetChillier(Value:Integer);

    procedure LoadConfiguration;

    procedure SaveConfiguration;

    procedure SetCurrentToFirst;

    procedure LoadMultiToys;

    procedure SaveMultiToys;
   published
// Registration

  property ChildName      :string    read FChildName         write  FChildName;

  property ChildSex       :string    read FChildSex          write  FChildSex;

  property ChildEyeColor  :string    read FChildEyeColor     write
FChildEyeColor;

  property ChildHairColor :string    read FChildHaircolor    write
FChildHairColor;

  property BedTimeHour    :string    read FBedTimeHour       write
FBedTimeHour;

  property BirthDay       :string    read FBirthDay          write  FBirthDay;

  property SecretName     :string    read FSecretName         write
FSecretName;

  property FavoriteColor  :string    read FFavoriteColor     write
FFavoriteColor;

  property FavoriteFood   :string    read FFavoriteFood      write
FFavoriteFood;

  property FavoriteActivity :string  read FFavoriteActivity  write
FFavoriteActivity;

  property FavoriteAnimal  :string   read FFavoriteAnimal    write
FFavoriteAnimal;
				
				<dp n="d142"/>
  property ChildNumber     :Integer read FChildNumber     write
SetChildNumber;

  property VisitSongMenu   :Integer read FVisitSongMenu   write
FVisitSongMenu;

  property VisitGameMenu   :Integer read FVisitGameMenu   write
FVisitGameMenu;

  property VisitStoryMenu  :Integer read FVisitStoryMenu  write
FVisitStoryMenu;

  property VisitBunnyShort :Integer read FVisitBunnyShort write
FVisitBunnyShort;

  property VisitBunnyLong  :Integer read FVisitBunnyLong  write
FVisitBunnyLong;

  property VisitPrincess   :Integer read FVisitPrincess  write
FVisitPrincess;

  property BunnyFavoriteFood :string read FBunnyFavoriteFood  write
FByFavoriteFood;
// Configuration

  property ToyNumber      :Integer read FToyNumber write FToyNumber;

  property DataBasePath   :string  read FDataBasePath write
FDataBasePath;
// Multi Toys

  property MultiToy1   : Integer read FMultiToy1  write FMultiToy1;

  property MultiToy2   : Integer read FMultiToy2  write FMultiToy2;

  property MultiToy3   : Integer read FMultiToy3  write FMultiToy3;

  property MultiToy4   : Integer read FMultiToy4  write FMultiToy4;

  property MultiToy5   : Integer read FMultiToy5  write FMultiToy5;

  property MultiToy6   : Integer read FMultiToy6  write FMultiToy6;

  property MultiToy7   : Integer read FMultiToy7  write FMultiToy7;

  property MultiToy8   : Integer read FMultiToy8  write FMultiToy8;
  end;
const

  HowManyChildren=7;

  ChildProperties=40;//change alse Array
implementation
procedure TPDBEngine.LoadRegistration;
var

  F:TextFile;

  i,j:integer;
begin
   ClearDataArrav;
				
				<dp n="d143"/>
  try

     AssignFile(F,DatabasePath+′Registration.CRE′);

     Reset (F);

     i:=1;

     while not EOF(F) do

       begin

          for j:=1 to ChildProperties do Readln(F,Data{i,j});

          i:=i+1;

       end;

    CloseFile(F);
   except

    SaveRegistration;

  end;

   ChildNumber:=1;
end;
procedure TPDBEngine.SaveRegistration;
var

  F:TextFile;

  i,j :Integer;
begin
   AssignFile(F,DatabasePath+ ′Registration.CRE ′);
   Rewrite (F);
   for i:=1 to HowManyChildren do

   begin

       for j:=1 to ChildProperties do Writeln(F,Data{i,j});

     end;
   CloseFile(F);
end;
// All The Data Shift 1 step:Nine Become Ten,Eiht Become Nine....
//                            First Become Second.
// The New Data will be in the First Record.
procedure TPDBEngine.InsertNewChild;
var
   index :integer;
   i     :integer;
   j     :integer;
begin
 for i:=(HowManyChildren-1)downto 1 do
   begin

   for j:=1 to ChildProperties do

  begin
				
				<dp n="d144"/>
           Data{i+l,j}:=Data{i,j};

        end;

   end;
//     index:=ChildNumber;

     ChildNumber=1;

     UpDateCurrentChild;
//     Chillier:=index;
end;
procedure TPDBEngine.UpDateCurrentChild;
begin
   Data[ChildNumber,1]      :=ChildName;
   Data[ChildNumber,2]      :=Childsex;
   Data[ChildNumber,3]      :=ChildEyecolor;
   Data[ChildNumber,4]      :=ChildHairColor;
   Data[ChildNumber,5]      :=BedTimeHour;
   Data[ChildNumber,6]      :=BirthDay;
   Dara[ChildNumber,7]      :=SecretName;
   Data[ChildNumber,8]      :=FavoriteColor;
   Data[ChildNumber,9]      :=FavoriteFood     ;
   Data[Childnmber,10]      :=FavoriteActivity;
   Data[ChildNumber,11]     :=FavoriteAnimal;
   Data[ChildNumber,12]     :=IntToStr(VisitSongMenu);
   Data[ChildNumber,13]     :=IntToStr(VisitStoryMenu);
   Data[ChildNumber,14]     :=IntToStr(VisitBunnyShort);
   Data[ChildNumber,15]     :=IntToStr(VisitBunnyLong);
   Data[ChildNumber,16]     :=IntToStr(VisitGameMenu);
   Data[ChildNumber,17]     :=IntToStr(VisitPrincess);
   Data[ChildNumber,18]     :=BunnyFavoriteFood;
   SaveRegistration;
end;
procedure TPDBEngine.SetchildNumber(Value:Integer);
begin

   if(Value>0)and(Value<HowManyChildren+1)then FchildNvmber:=Value

      else FChildNumber:=1;

    ChildName          :=Data[childNumber,1];

    ChildSex           :=Data[ChildNumber,2];

    ChildEyeColor      :=Data[ChildNumber,3];

    ChildHairColor     :=Data[ChildNumber,4];

    BedTimeHour        :=Data[ChildNumber,5];

    BirthDay           :=Data[ChildNumber,6];

    SecretName         :=Data[ChildNumber,7];
				
				<dp n="d145"/>
     FavoriteColor       :=Data[ChildNumber,8];

     FavoriteFood        :=Data[ChildNumber,9];

     FavoriteActivity    :=Data[ChildNumber,10];

     FavoriteAnimal      :=Data[ChildNumber,11];

     VisitSongMenu       :=StrToIntDef(Data[ChildNumber,12],0);

     VisitStoryMenu      :=StrToIntDef(Data[ChildNumber,13],0);

     VisitBunnyShort     :=StrToIntDef(Data[ChildNumber,14],0);

     VisitBunnyLong      :=StrToIntDef(Data[ChildNumber,15],0);

     VisitGameMenu       :=StrToIntDef(Data[ChildNumber,16],0);

     VisitPrincess       :=StrToIntDef(Data[ChildNumber,17],0);

     BunnyFavoriteFood   :=Data[ChildNumber,18];
end;
procedure TPDBEngine.ClearDataArray;
var
  i:integer;
  j:integer;
begin

  for i:= 1 to HowManyChildren do

    begin

      for j:=1 to ChildProperties do

       begin

         Data[i,j]:=′′;

       end;

     end;
end;
procedure TPDBEngine.LoadConfiguration;
var
  F:TextFile;
begin
   FToyNumber:=0;
   try

   AssignFile(F,DatabasePath+′Configuration.CRE′);

   Reset(F);

   Readln(F,FToyNumber);

   CloseFile(F);
   except

   SaveConfiguration;
   end;
end;
procedure TPDBEngine.SaveConfiguration;
				
				<dp n="d146"/>
var
   F:TextFile;
begin
   AssignFile(F,DatabasePath+′Configuration. CRE′);
   Rewrite(F);

     Writeln(F,FToyNumber);
   CloseFile(F);
end;
procedure TPDBEngine.SetCurrentToFirst;
var
  i    :integer;
  Temp :string;
begin
//

  While ChildNumber>1 do

  begin

    for i:=1 to ChildProperties do

      begin

        Temp                     :=Data[Chillier,i];

        Data[ChildNumber,i]     :=Data[ChildNumber-1,i];

        Data[ChildNumber-1,i]   := Temp;

      end;

    Chillier:=ChildNumber-1;

  end;
end;
procedure TPDBEgine.LoadMultiToys;
var
  F:TextFile;
begin
  EToyNumber:=0;
  try
   AssignFile(F,DatabasePath+′MultiToys.CRE′);
   Reset (F);
   Readln(F,FMultiToy1);
   Readln(F,FMultiToy2);
   Readln(F,FMultiToy3);
   Readln(F,FMultiToy4);
   Readln(F,FMultiToy5);
   Readln(F,FMultiToy6);
   Readln(F,FMultiToy7);
   Readln(F,FMultiToy8);
				
				<dp n="d147"/>
  CloseFile(F);
  except

  SaveConfiguration;

  end;
end;
procedure TPDBEngine.SaveMultiToys;
var
   F:TextFile;
begin
   AssignFile(F,DatabasePath+′MultiToys.CRE′);
   Rewrite(F);
   Writeln(F,FMultiToy1);
   Writeln(F,FMultiToy2);
   Writeln(F,FMultiToy3);
   Writeln(F,FMultiToy4);
   Writeln(F,FMultiToy5);
   Writeln(F,FMultiToy6);
   Writeln(F,FMultiToy7);
   Writeln(F,FMultiToy8 ) ;
   CloseFile(F);
end;
end.
				
				<dp n="d148"/>
================================

  Copyright (c) 1995-1998 Creator Ltd.All Rights Reserved
================================
Description;This is the PestoSong unit.
unit PestoSong;
interfaoe
uses
  Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs,
  Menus,ExtCtrls,MPlayer;
type
  TPestoSongForm=class(TForm)

  MainMenul:TMainMenu;

  testl:TMenuItem;

  spacel:TMenuItem;

  MediaPlayerl:TMediaPlayer;

  Panell:TPanel;

  Timerl:TTimer;

  Escapel:TMenuItem;

  procedure spacelClick(Sender:TObject);

  procedure FormCreate(Sender:TObject);

  procedure TimerlTimer(Sender:TObject);

  procedure EscapelClick(Sender:TObject);

  procedure FormClose(Sender:TObject;var Action:TCloseAction);
  private

  (Private declarations)
  public

  (Public declarations)

  FirstTimePlay:Boolean;

  Section      :Integer;

  procedure PlayMovie;

  procedure GoToMenu;

  procedure playSection(value:Integer);

  procedure ToyTalk(NumbersOfToy:string;Wave:string;motion:string);
  end;
var

  PestoSongForm:TPestoSongForm;
				
				<dp n="d149"/>
  implementation
  uses Main Menu;
  (SR*.DFM)
 procedure TPestoSongForm.spacelClick(Sender:TObject);
 begin
 //space

   if MainForm.ThreadInProgress=True then exit;
   GoToMenu;
 end;
 procedure TPestoSongForm. GoToMenu;
 begin

   Timerl.Enabled  :=False;

   Spacel.Enabled  :=False;

   MediaPlayerl.Stop;

   MediaPlayerl.Close;

   hide;

   MenuForm.Show;
end;
procedure TPestoSongForm.PlayMovie;
begin

      MediaPlayerl.Play;

      ToyTalk(′All′,′StoryTeller.wav′,′S′);
end;
procedure TPestoSongForm.PlaySection(Value:Integer);
begin

     MediaPlayerl.close;

     case Value of

     1:begin

          MediaPlayerl.FileName :=MainForm.GraphicsPath+ ′Logo.avi′;

          ToyTalk(′one′,′Logo.wav′,′S′);

       end;

     2:begin

          MediaPlayerl.FileName :=MainForm.GraphicsPath + ′Alonel.mov′;

          ToyTalk(′One′,′Alonel.wav′,′S′);

       end;
				
				<dp n="d150"/>
  3:begin

       MediaPlayerl.FileName:=MainForm.GraphicsPath+ ′Alone2.mov′;

       ToyTalk(′One′,′Alone2.wav′,′S′);

     end;

   4:begin

        MediaPlayerl.FileName:=MainForm.GraphicsPath+ ′Alone3.mov′;

        ToyTalk(′One′,′Alone3.wav′,′S′);

      end;

   5: begin

         MediaPlayerl. FileName:=MainForm.GraphicsPath + ′All.mov′;

         ToyTalk( ′All′,′All.wav′,′S′);

       end;

     end;

     MediaPlayerl.open;

     MediaPlayerl.Play;
end;
procedure TPestoSongForm. FormCreate(Sender:TObject);
begin

   Panell.Cursor:=crNone;

   Timerl.Enabled:=False;

   Timerl.Interval:=60000;

   Cursor:=crNone;

   MediaPlayerl.FileMame:=MainForm.GraphicsPath+ ′StoryTeller.avi′;

   MediaPlayerl.open;

   FirstTimePlay:=True;
end;
procedure TPestoSongForm.TimerlTimer(Sender:TObject);
begin
//
   GoToMenu;
end;
procedure TPestoSongForm.EscapelClick(Sender:TObject);
begin
// Exit
   if MainForm.ThreadInProgress=True then exit;
   MediaPlayerl.stop;
				
				<dp n="d151"/>
    MediaPlayerl.Close;

    Hide;

    MenuForm.Show;
end;
procedure TPestoSongForm.ToyTalk(NumbersOfToy:string ;Wave:string
;motion:string);
var
   ToyNo:Integer;
begin
   if NumbersOfToy=′All′then ToyNo:=85//55H

    else ToyNo:=MainForm.Toy.ToyNumber;

  MainForm.TalkInBackGround(ToyNo,MainForm. AudioPath +Wave,′′);
end;
procedure TPestoSongForm.FormClose(Sender:TObject;
  var Action:TCloseAction);
begin
 try
   MediaPlayerl.stop;
 except
 end;
 try
   MediaPlayerl.Close;
 except
 end;
end;
end.
				
				<dp n="d152"/>
================================

  Copyrignt (c) 1995-1998 Creator Ltd.All Rights Reserved
================================
Description;This is the Registration unit.
unit Registration;
interface
uses
   Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs,
   ExtCtrls,jpeg,StdCtrls,Buttons,Spin,Grids,Calendar,ComCtrls,Menus;
type
   TRegistrationForm=class(TForm)

   RegistrationImage:TImage;

   RegistrationBackImage:TImage;

   UserNameLabel:TLabel;

   BoyImage:TImage;

   BoyHairYellowImage:TImage;

   BoyHairBlackImage:TImage;

   BoyHairOrangeImage:TImage;

   BoyHairBrownImage:TImage;

   BoyEyeBlueImage:TImage;

   BoyEyeGreenImage:TImage;

   BoyEyeBrownImage:TImage;

   BoyEyeBlackImage:TImage;

   BoyShirtYellowImage:TImage;

   BoyShirtBlueImage:TImage;

   BoyShirtRedImage:TImage;

   GirlImage:TImage;

   GirlHairYellowImage:TImage;

   GirlHairBrownImage:TImage;

   GirlHairOrangeImage:TImage;

   GirlHairBlackImage:TImage;

   GirlEyeBlueImage:TImage;

   GirlEyeGreenImage:TImage;

   GirlEyeBrownImage:TImage;

   GirlEyeBlackImage:TImage;

   GirlShirtYellowImage:TImage;

   GirlShirtBlueImage:TImage;

   GirlShirtRedImage:TImage;
				
				<dp n="d153"/>
AboutYouLabel:TLabel;
AboutSexLabel:TLabel;
AboutAgeLabel:TLabel;
AboutEyeLabel:TLabel;
AboutHairLabel:TLabel;
AboutBedTimeLabel:TLabel;
FavoritesLabel:TLabel;
FavoritesColorLabel:TLabel;
FavoritesFoodLabel:TLabel;
FavoritesActivityLabel:TLabel;
FavoritesAnimalLabel:TLabel;
FavoritePanel:TPanel;
PanelImage:TImage;
PanelLabel1:TLabel;
PanelLabel2:TLabel;
PanelLabel3:TLabel;
PanelLabel4:TLabel;
SecretNameLabel:TLabel;
GoOutArrowImage:TImage;
BirthDayPanel:TPanel;
BirthDayImage:TImage;
Calendarl:TCalendar;
SpinEditl:TSpinEdit;
ComboBoxl:TComboBox;
BedTimeHourPanel:TPanel;
BedTimeHourImage:TImage;
ComboBox2:TComboBox;
BearEyesAnimate:TAnimate;
SteemAnimate:TAnimate;
WheelsAnimate:TAnimate;
BirthDayOKImage:TImage;
BedTimeHourOKImage:TImage;
VGenderImage:TImage;
VBirthdayImage:TImage;
VEyeColorImage:TImage;
VHairColorImage:TImage;
VBedTimeHourImage:TImage;
VFavoriteColorImage:TImage;
VFavoriteFoodImage:TImage;
VFavoriteActivityImage:TImage;
VFavoriteAnimalImage:TImage;
MainMenul:TMainMenu;
testl:TMenuItem;
				
				<dp n="d154"/>
Escapel:TMenuItem;
BallJumpAnimate:TAnimate;
procedure FormCreate(Sender:TObject);
procedure RegietrationBackImageClick(Sender:TObject);
procedure AboutSexLabelClick(Sender:TObject);
procedure AboutAgeLabelClick(Sender:TObject);
procedure AboutEyeLabelClick(Sender:TObject);
procedure AboutHairLabelClick(Sender:TObject);
procedure AboutBedTimeLabelClick(Sender:TObject);
procedure PanelLabel1Click(Sender:TObject);
procedure PanelLabel2Click(Sender:TObject);
procedure PanelLabel3Click(Sender:TObject);
procedure PanelLabel4Click(Sender:TObject);
procedure FavoritesColorLabelClick(Sender:TObject);
procedure FavoritesFoodLabelClick(Sender:TObject);
procedure FayoritesActivityLabelClick(Sender:TObject);
procedure FavoritesAnimalLabelClick(Sender:TObject);
procedure AboutSexLabelMouseMove(Sender:TObject;shift:TShiftState;
  X,Y:Integer);
procedure AboutAgeLabelMouseMove(Sender:TObject;Shift:TShiftState;
  X,Y:Integer);
procedure AboutEyeLabelMouseMove(Sender:TObject;Shift:TShiftState;
  X,Y:Integer);
procedure AboutHairLabelMouseMove(Sender:TObject;Shift:TShiftState;
  X,Y:Integer);
procedure AboutBedTimeLabelMouseMove(Sender:TObject;
  Shift:TShiftState;X,Y:Integer);
procedure PanelLabel1MouseMove(Sender:TObject;Shift:TShiftState;X,
  Y:Integer);
procedure PanelLabel2MouseMove(Sender:TObject;Shift:TShiftState;X,
  Y:Integer);
procedure PanelLabel3MouseMove(Sender:TObject;Shift:TShiftState;X,
  Y:Integer);
procedure PanelLabel4MouseMove(Sender:TObject;Shift:TShiftState;X,
  Y:Integer);
procedure FavoritesColorLabelMouseMove(Sender:TObject;
  Shift:TShiftState;X,Y:Integer);
procedure FavoritesFoodLabelMouseMove(Sender:TObject;
  Shift:TShiftState;X,Y:Inreger);
procedure FavoritesActivityLabelMouseMove(Sender:TObject;
  Shift:TShiftState;X,Y:Integer);
procedure FavoritesAnimalLabelMouseMove(Sender:TObject;
  Shift:TShiftState;X,Y:Integer); 
procedure RegiscrationImageMouseMove(Sender:TObjecc;
Shift:TShiftState;X,Y:Integer);
Drocedure SecretNameLabelMouseMove(Sender:TObject;Shift:TShiftState,
X,Y:Integer);
procedure RegistrationBackImageMouseMove(Sender:TObject;
Shift:TShiftState;X,Y:Integer);
procedure GoOutArrowImageclick(Sender:TObject);
procedure ComboBoxlchange(Sender:TObject);
procedure SpinEditlchange(Sender:TObject);
procedure Calendarlchange(Sender:TObject);
procedure BirthDaFImageClick(Sender:TObject);
procedure RegistrationImageclick(Sender:TObject);
procedure BedTimeHourImageclick(Sender:TObject);
procedure ComboBox2Change(Sender:TObject);
procedure BirthDayOKImageClick(Sender:TObject),
procedure BedTimeHourOKImageclick(Sender:TObject);
procedure EscapelClick(Sender:TObject);private
(Private declarations)public
(Public declarations)
CurrentItem       :  string,
ChildName         :  string;
SecretName        :  string;
Gender            :  string;
DateofBirth       :  string;
EyeCoIor          :  string;
HairColor         :  string;
BedTimeHour       :  string,
FavoriteColOr     :  string;
FavoriteFood      :  string;
FavoriteActivity  :  string;
FavoriteAnimal    :  string;
procedure  InitialReg;
procedure DrawBoyorGirl;
procedure AssignCurrentItem(Value:string);
procedure GoBackToMenu;
proccdure ChoosePanelLabel (Value:Integer);
procedure SaveToDataBase;
procedure LoadFromDataBase;
Procedure BackgroungSpeaking (Value:string);
procedure ShowVTfSelected;
end;
var

  RegistrationForm:TRegistrationForm;
implementation
uses Main,Menu;
(SR *.DFM)
procedure TRegistrationForm. FormCreate(Sender:TObject);
begin
   //Maximize
   WindowState:=wsMaximized;
   RegistrationBackImage.Cursor:=crDefault;
   InitialReg;
end;
procedure TRegistrationForm.RegistrationBackImageClick(Sender:TObject);
begin
//
   if MainForm.ThreadInFrogress then exit;
   GoBackToMenu;
end;
procedure TregistrationForm.GoBackToMenu;
begin
   with MenuForm do
   begin

    PickUserImage.Visible:=alse;

    // Reg 1

    PickUserTitleLabel.Visible := False;

    UserNameLabel1.Visible :=False;

    UserNameLabel2.Visible :=False;

    UserNameLabel3.Visible :=False;

    UserNameLabel4.Visible :=False;

    UserNameLabel5.Visible :=False;

    UserNameLabel6.Visible :=False;

    UserNameLabel7.Visible :=False;

    UserNameLabel8.Visible :=False;

    // Reg 2

    PickUserLabel1.Visible :=False;
				
				<dp n="d157"/>
  UserNameEdit.Visible     :=False;

  OKButtonImage.Visible    :=False;

  SetUpOrgImage.Visible    :=False;

  SetupImage.Visible       :=True;

  ImageFrame1.Enabled      :=True;

  ImageFrame2.Enabled      :=True;

  ImageFrame3.Enabled      :=True;

  ImageFrame4.Enabled      :=True;

  ImageFrame5.Enabled      :=True;

  ImageFrame6.Enabled      :=True;
//Toy To TV

     ToyAnimate.Visible  :=True;

     ToyImage.Visible    :=True;

     with TVAnimate do

     begin

       Active    :=False;

       FileName  :=MainFom.GraphicsPath+′noise.AVI′;

       Active    :=True;

       Left      :=629;

       Top       :=318;

       Width     :=112;

       height    :=88;

     end;
   //

  end;
   SaveToDataBase;
   Close;
   MenuForm.Show;
end;
procedure TRegistrationForm. InitialReg;
begin

  RegistrationImage.Visible             :=True;

  RegistrationBackImage.Visible         :=True;

  UserNameLabel.Visible                 :=True;

  BoyImage.Visible                      :=False;

  BoyHairYellowImage.Visible            :=False;

  BoyHairBlackImage.Visible             :=False;

  BoyHairOrangeImage.Visible            :=False;

  BoyHairBrownImage.Visible             :=False;
				
				<dp n="d158"/>
BoyEyeBlueImage.Visible           :=Falsc;
BoyEyeGreenImage.Visible          :=False;
BoyEyeBrownImage.Visible          :=False;
BoyEyeBlackImage.Visible          :=False;
BoyShirtYellowImage.Visible       :=False;
BoyShirtBlueImage.Visible         :=False;
BoyShirtRedImage.Visible          :=False;
GirlImage.Visible                 :=False;
GirlHairYellowImage.Visible       :=False;
GirlHairBrownImage.Visible        :=False;
GirlHairOrangeImage.Visible       :=False;
GirlHairBlackImage.Visible        :=False;
GirlEyeBlueImage.Visible          :=False;
GirlEyeGreenImage.Visible         :=False;
GirlEyeBrownImage.Visible         :=False;
GirlEyeBlackImage.Visible         :=False;
GirlShirtYellowImage.Visible      :=False;
GirlShirtBlueImage.Visible        :=False;
GirlShirtRedImage.Visible         :=False;
AboutYouLabel.Visible             :=False;
AboutSexLabel.Visible             :=False;
AboutAgeLabel.Visible             :=False;
AboutEyeLabel.Visible             :=False;
AboutHairLabel.Visible            :=False;
AboutBedTimeLabel.Visible         :=False;
FavoritesLabel.Visible            :=False
FavoritesColorLabel.Visible       :=False;
FavoritesFoodLabel.Visible        :=False;
FavoritesActivityLabel.Visible    :=False;
FavoritesAnimalLabel.Visible      :=False;
FavoritePanel.Visible             :=False;
//RegistrationImage.Cursor        :=6;
AboutSexLabel.Cursor              :=5;
AboutAgeLabel.Cursor              :=5;
AboutEyeLabel.Cursor              :=5;
AboutHairLabel.Cursor             :=5;
AboutBedTimeLabel.Cursor          :=5;
FavoritesColorLabel.Cursor        :=5;
FavoritesFoodLabel.Cursor         :=5;
				
				<dp n="d159"/>
  EavorltesActlvltyLaDel.Cursot     := 5;

  FavoritesAnimalLabel.Cursor       := 5;

  PanelImage.Cursor                 := 5;

  PanelLabel1.Cursor                := 5;

  PanelLabel2.Cursor                := 5;

  PanelLabel3.Cursor                := 5;

  PanelLabel4.Cursor                := 5;

  SecretNameLabel.Cursor            := 5;

  RegistrationBackImage.Cursor      := 5;

  GoOutArrowImage.Cursor            := 5;

  BedTimeHourOKImage.Cursor         := 5;

  BirthDayOKImage.Cursor            := 5;

  CurrentItem           :=″;

  SecretName            :=″;

  Gender                :=″;

  DateOfBirth           :=″;

  EyeColor              :=″;

  HairColor             :=″;

  BedTimeHour           :=″;

  FavoriteColor         :=″;

  FavoriteFood          :=″;

  FavoriteActivity      :=″;

  FavoriteAnimal        :=″;
ComboBox1.Items.Add(′January′);
ComboBox1.Items.Add(′February′);
ComboBox1.Items.Add(′March′);
ComboBox1.Items.Add(′April′);
ComboBox1.Items.Add(′May′);
ComboBox1.Items.Add(′June′);
ComboBox1.Items.Add(′July′);
ComboBox1.Items.Add(′August′);
ComboBox1.Items.Add(′September′);
ComboBox1.Items.Add(′October′);
ComboBox1.Items.Add(′November′);
ComboBox1.Items.Add(′December′);
SpinEditl.Value:=1995;
ComboBox2.Items.Add(′6:00   PM′);
ComboBox2.Items.Add(′6:30   PM′);
ComboBox2.Items.Add(′7:00   PM′);
ComboBox2.Items.Add(′7:30   PM′);
				
				<dp n="d160"/>
  ComboBox2.Items.Add(′9:00   PM′);

  ComboBox2.Items.Add(′9:30   PM′);

  ComboBox2.Items.Add(′9:00   PM′);

  ComboBox2.Items.Add(′9:30   PM′);

  ComboBox2.Items.Add(′10:00  PM′);

  ComboBox2.Items.Add(′10:30  PM′);

  with BedTimeHourPanel do

    begin

       Left   :=135;

       Top    :=335;

       Width  :=157;

       Height :=78;
   with BirthDayPanel do

  begin

     Left   :=134;

     Top    :=239;

     Width  :=278;

     Height :=201;

   end;

   end;

   BearEyesAnimate.FileName:=MainForm.GraphicsPath+ ′BearEye.avi′;

   SteemAnimate.FileName:= MainForm.GraphicsPath+ ′Steem.avi′;

   WheelsAnimate.FileName:= MainForm.GraphicsPath+ ′Wheels.avi′;

   BallJumpAnimate.FileName:= MainForm.GraphicsPath+ ′BallJump.avi′;

   BearEyesAnimate.Active: = True;

   SteePte.Active:=True;

   WheelsAnimate.Active:=True;

   BallJumpAnimate.Active:=True;
end;
procedure TRegistrationForm.AboutSexLabelClick(Sender:TObject);
begin
//

   if MainForm.ThreadInProgress then exit;

   if Gender=′Boy′     then ChoosePanelLabel(1);

   if Gender=′Girl′    then ChoosePanelLabel(2);

   PanelLabel1.caption := ′Boy′;

   PanelLabel2.caption := ′Girl′;

  with FavoritePanel do
				
				<dp n="d161"/>
  begin

    Left   :=134;

    Top    :=204;

    Width  :=225;

    Height :=65;

  end;

  FavoritePanel.Visible     :* True;

  BedTimeHourPanel.Visible  :=False;

  BirthDayPanel.Visible     :=False;

  CurrentItem:=′Gender′;

  SteemAnimate.Visible:=True;

  MainForm.BackGroundTalking(MainForm.AboutYouPath+′ay62.wav′,′S′);
 end;
procedure TRegistrationForm.AboutAgeLabelClick(Sender:TObject);
var

  Temp:string;
begin

  if MainForm.ThreadInProgress then exit;

  Temp:=DateOfBirth;

  if Length(DateOfBirth)=10 then

  begin

    Calendarl.Year   :=StrToInt(copy(Temp,7,4));

    Calendarl.Day    :=StrToInt(copy(Temp,4,2));

    Calendarl.Month  :=StrToInt(copy(Temp,1,2));

  end;

    SpinEditl.Value      :=Calendarl.Year;

    ComboBox1.ItemIndex :=Calendarl.Month-l;

    BirthDayPanel.Visible     := True;

    Favoritepanel.Visible     := False;

    BedTimeHourPanel.Visible  := False;

    SteemAnimate.Visible := False;

    MainForm.BackGroundTalking(MainForm.AboutYouPath+′ay63.wav′,′S′);
end;
procedure TRegistrationForm.AboutEyeLabelClick(Sender:TObject);
begin
//

  if MainForm.ThreadInProgress then exit;

  if EyeColor=′Blue′   then ChoosePanelLabel(1);

  if EyeColor=′Green′  then ChoosePanelLabel(2);

  if EyeColor=′Brown′  then ChoosePanelLabel(3);

  if EyeColor=′Black′  then ChoosePanelLabel(4);
				
				<dp n="d162"/>
   PanelLabel1.caption :=′Blue′;

   PanelLabel2.caption :=′Green′;

   PanelLabel3.caption :=′Brown′;

   PanelLabel4.caption :=′Black′;

   with FavoritePanel do

   begin

      Left    :=134;

      Top     :=269;

      Width   :=225;

      Height  :=145;

   end;

   FavoritePanel.Visible     :=True;

   BedTimeHourPanel.Visible  :=False;

   BirthDayPanel.Visible     :=False;

   CurrentItem :=′EyeColor′;

   SteemAnimate.Visible:=False;

   MainForm.BackGroundTalking(MainForm.AboutYouPath+′ay66.wav′,′S′);
end;
procedure TRegistrationForm.AboutHairLabelClick(Sender:TObject);
begin
//

   if MainForm.ThreadInProgress then exit;

   if HairColor=′Blond′   then ChoosePanelLabel(1);

   if HairColor=′Brown′   then ChoosePanelLabel(2);

   if HairColor=′Red′     then ChoosePanelLabel(3);

   if HairColor=′Black′   then ChoosePanelLabel(4);

   PanelLabel1.caption:=′Blond′;

   PanelLabel2.caption:=′Brown′;

   PanelLabel3.caption:=′Red′;

   PanelLabel4.caption:=′Black′;

   with FavoritePanel do

   begin

      Left    :=134;

      Top     :=302;

      Width   :=225;

      Height  :=145;

  end;

  FavoritePanel.Visible     :=True;

  BedTimeHourPanel.Visible  :=False;

  BirthDayPanel.Visible     :=False;
				
				<dp n="d163"/>
    CurrentItem :=′HalrColor;

     SteemAnimate.Visible:=False;

    MainForm.BackGroundTalking(MainForm. AboutYouPath +′ay67.wav′,′S′);
 end;
procedure TRegistrationForm. AboutBedTimeLabelClick(Sender:TObject);
begin
   if MainForm.ThreadInProgress then exit;
   ComboBox2.ItemIndex :=ComboBox2.Items.IndexOf(BedTimeHour);
   BedTimeHourPanel.Visible :=True;
   FavoritePanel.Visible    :=False;
   BirthDayPanel.Visible    :=False;
   SteemAnimate.Visible:=False;
   MainForm. BackGroundTalking(MainForm. AboutYouPath +′ay68.wav′,′S′);
end;
procedure TRegistrationForm.PanelLabellClick(Sender: TObject);
begin

    if MainForm. ThreadInProgress then exit;

    FavoritePanel.Visible:=False;

    AssignCurrentItem (PanelLabell. Caption);

    DrawBoyOrGirl;

    CurrentItem:=′′;
end;
procedure TRegistrationForm. PanelLabel2Click(Sender:TObject);
begin

    if MainForm. ThreadInProgtess then exit;

    FavoritePanel.Visible:=False;

    AssignCurrentItem (PanelLabel2.Caption);

    DrawBoyOrGirl;

    CurrentItem:=′′;
end;
procedure TRegistrationForm. PanelLabel3Click(Sender:TObject);
begin

    if MainForm. ThreadInProgress then exit;

    FavoritePanel.Visible:=False;

    AssignCurrentItem(PanelLabel3.Caption);

    DrawBoyOrGirl;

    CurrentItem:=′′;
end;
				
				<dp n="d164"/>
 procedure TRegistrationForm.PanelLabel4Click(Sender:TObject);
 begin

    if MainForm. ThreadInProgress then exit;

    FavoritePanel.Visible:=False;

    AssignCurrentItem (PanelLabel4.Caption);

    DrawBoyOrGirl;

    CurrentItem:=′′;
 end;
 procedure TRegistrationForm.FavoritesColorLabelClick(Sender:TObject);
begin
 //

  if MainForm. ThreadInProgress then exit;

  if FavoriteColor=′Yellow′then ChoosePanelLabel(1);

  if FavoriteColor=′Blue′  then ChoosePanelLabel(2);

  if FavoriteColor=′Red′   then ChoosePanelLabel(3);

  PanelLabel1.caption:=′Yellow′;

  PanelLabel2.caption:=′Blue′;

  PanelLabel3.caption:=′Red′;

  with FavoritePanel do

  begin

     Left    :=415;

     Top     :=204;

     Width   :=225;

     Height  :=115;

   end;

   FavoritePanel.Visible     :=True;

   BedTimeHourpanel.Visible  :=False;

   BirthDayPanel.Visible     :=False;

   CurrentItem:= ′FavoriteColor′;

   SteemAnimate.Visible :=True;

   MainForm.BackGroundTalking(MainForm. AboutYouPath +′fa71.wav′,′S′);
end;
procedure TRegistrationForm.FavoritesFoodLabelClick(Sender:TObject);
begin
//
   if MainForm. ThreadInProgress then exit;
   if FavoriteFood= ′Pizza′then ChoosePanelLabel(1);
   if FavoriteFood= ′French Fries′then ChoosePanelLabel(2);
   if FavoriteFood= ′Macaroni And Cheese′then ChoosePanelLabel(3);
				
				<dp n="d165"/>
    PanelLaDel1.caption := ′French Fries′;

    PanelLabel2.caption := ′French Fries′;

    PanelLabel3.caption := ′Macaroni And Cheese′;

    with FavoritePanel do

    begin

       Left    :=415;

       Top     :=236;

       Width   :=225;

       Height  :=115;

    end;

    FavoritePanel.Visible     :=True;

    BedTimeHourPanel.Visible  :=False;

   BirthDayPanel.Visible      :=False;

   CurrentItem := ′FavoriteFood′;

   SteemAnimate.Visible :=True;

   MainForm.BackGroundTalking(MainForm. AboutYouPath +′fa72.wav′,′S′);
end;
procedure TRegistrationForm.FavoritesActivityLabelClick(Sender:TObject);
begin
//
   if MainForm.ThreadInProgress then exit;
   if FavoriteActivity=′Drawing′then ChoosePanelLabel(1);
   if FavoriteActivity=′Playing Computer Games′then ChoosePanelLabel(2);
   if FavoriteActivity=′Pretending′then ChoosePanelLabel(3);
   PanelLabel1.caption:=′Drawing′;
   PanelLabel2.caption:=′Playing Computer Games′;
   PanelLabel3.caption:=′Pretending′;
   with FavoritePanel do
   begin

    Left    :=415;

    Top     :=271;

    Width   :=225;

    Height  :=115;

   end;

   FavoritePanel.Visible     :=True;

   BedTimeHourPanel.Visible  :=False;

   BirthDayPanel.Visible     :=False;

   CurrentItem:= ′FavoriteActivity′;

   SteemAnimate.Visible:=True;

   MainForm.BackGroundTalking(MainForm. AboutYouPath +′fa73.wav′,′S′);
end;
				
				<dp n="d166"/>
procedure TRegistrationForm.FavoritesAnimalLabelClick(Sender:TObject);
begin
//
   if MainForm.ThreadInProgress then exit;
   if FavoriteAnimal=′Horse′then ChoosePanelLabel(1);
   if FavoriteAnimal=′Dog′  then ChoosePanelLabel(2);
   if FavoriteAnimal=′Cat′  then ChoosePanelLabel(3);
   PanelLabel1.caption:=′Horse′;
   PanelLabel2.caption:=′Dog′;
   PanelLabel3.caption:=′Cat′;
   with FavoritePanel do
   begin

   Left    :=415;

   Top     :=304;

   Width   :=225;

   Height  :=115;
   end;
   FavoritePanel.Visible      :=True;
   BedTimeHourPanel.Visible   :=False;
   BirthDayPanel.Visible      :=False;
   CurrentItem:=′FavoriteAnimal′;
   SteemAnimate.Visible:=True;
   MainForm.BackGroundTalking(MainForm.AboutYouPath +′fa74.wav′,′S′);
end;
procedure TRegistrationForm.ChoosePanelLabel(Value:Integer);
begin
   if Value=1 then PanelLabel1.Font.Color:=clFuchsia;
   if Value=2 then PanelLabel2.Font.Color:=clFuchsia;
   if Value=3 then PanelLabel3.Font.Color:=clFuchsia;
   if Value=4 then PanelLabel4.Font.Color:=clFuchsia;
end;
procedure TRegistrationForm.AboutSexLabelMouseMove(Sender:TObject;
  Shift:TShiftState;X,Y:Integer);
begin
  AboutSexLabel.Font.Color:=clTeal;
end;
procedure TRegistrationForm. AboutAgeLabelMouseMove(Sender:TObject;
  Shift:TShiftState;X,Y:Integer);
begin
end;procedura TRegistrationEorm.AboutEyeLabelMouseMove(Sender:TObject;Shift:TShiftState;X,Y:Integer);beginAboutEyeLabel.Color :=clTeal;end;procedure TRegistrationForm.AboutHairLabelMouseMove(Sender:TObject;Shift:TShiftState;X,Y:Integer);beginAboutHairLabel.Font.Color :=clTeal;end;procedure TRegistrationForm.AboutBedTimeLabelMouseMove(Sender:TObject;Shift;TShiftState;X,Y:Integer);begin
AboutBedTimeLabel.Font.Color :=clTeal;end;procedure TRegistrationForm.PanelLabel1MouseMove(Sender:TObject;Shift:TShiftState;X,Y:Integer);begin
PanelLabel1.Font.Color :=clRed;
PanelLabel2.Font.Color :=clTeal;
PanelLabel3.Font.Color :=clTeal;
PanelLabel4.Font.Color :=clTeal;end;procedure TRegistrationForm.PanelLabel2MouseMove(Sender:TObject;Shift:TShiftState;X,Y:Integer);begin
PanelLabel1.Font.Color :=clTeal;
PanelLabel2.Font.Color :=clRed;
PanelLabel3.Font.Color :=clTeal;
PanelLabel4.Font.Color :=clTeal;end;procedure TRegistrarionForm.PanelLabel3MouseMove(Sender:TObject;Shift:TShiftState;X,Y:Integer);begin
PanelLabel1.Font.Color :=clTeal;
   PanelLabel2.Font.Color :=clTeal;

     PanelLabel3.Font.Color :=clRed;

     PanelLabel4.Font.Color :=clTeal;
end;
procedure TRegistrationForm. PanelLabel4MouseMove(Sender:TObject;

  Shift:TShiftState;X,Y:Integer);
begin

  PanelLabel1.Font.Color:=clTeal;

  PanelLabel2.Font.Color:=clTeal;

  PanelLabel3.Font.Color:=clTeal;

  PanelLabel4.Font.Color:=clRed;
end;
procedure TRegistrationForm.FavoritesColorLabelMouseMove(Sender:TObject;
   Shift:TShiftState;X,Y:Integer);
begin
   FavoritesColorLabel.Font.Color:=clTeal;
end;
procedure TRegistrationForm.FavoritesFoodLabelMouseMove(Sender:TObject;
   Shift:TShiftState;X,Y:Integer);
begin

  FavoritesFoodLabel.Font.Color:=clTeal;
end;
procedure TRegistrationForm.FavoritesActivityLabelMouseMove(
  Sender:TObject;Shift:TShiftState;X,Y:Integer);
begin
   FavoritesActivityLabel.Font.Color:=clTeal;
end;
procedure TRegistrationForm.FavoritesAnimalLabelMouseMove(Sender:TObject;
  Shift:TShiftState;X,Y:Integer);
begin
   FavoritesAnimalLabel.Font.Color:=clTeal;
end;
procedure TRegistrationForm.SecretNameLabelClick(Sender:TObject);
begin
//

  if MainForm.ThreadInProgress then exit;

  if SecretName=′Bubble Gum′then ChoosePanelLabel(1);
				
				<dp n="d169"/>
  if SecretName=′RainBow′then ChoosePanelLabel(2);

  PanelLabel1.caption :=′Bubble Gum′;

  PanelLabel2.caption :=′RainBow′;

  with FavoritePanel do

  begin

     Left    :=292;

     Top     :=186;

     Width   :=225;

     Height  :=85;

   end;

   FavoritePanel.Visible     :=True;

   BedTimeHourPanel.Visible  :=False;

   BirthDayPanel.Visible     :=False;

   CurrentItem :=′SecretName′;

   SteemAnimate.Visible:=True;

   MainForm.BackGroundTalking(MainForm.AboutYouPath +′fa75.wav′,′S′);
end;
procedure TRegistrationFom.RegistrationImageMouseMove(Sender:TObject;
   Shift:TShiftState;X,Y:Integer);
begin
//

  AboutSexLabel.Font.Color            :=clBlue;

  AboutAgeLabel.Font.Color            :=clBlue;

  AboutEyeLabel.Font.Color            :=clBlue;

  AboutHairLabel.Font.Color           :=clBlue;

  AboutBedTimeLabel.Font.Color        :=clBlue;

  FavoritesColorLabel.Font.Color      :=clBlue;

  FavoritesFoodLabel.Font.Color       :=clBlue;

  FavoritesActivityLabel.Font.Color   :=clBlue;

  FavoritesAnimalLabel.Font.Color     :=clBlue;

  PanelLabel1.Font.Color              :=clTeal;

  PanelLabel2.Font.Color              :=clTeal;

  PanelLabel3.Font.Color              :=clTeal;

  PanelLabel4.Font.Color              :=clTeal;

  SecretNameLabel.Font.Color          :=clGray;

  if CurrentItem=′′then FavoritePanel.Visible:=False;

  GoOutArrowImage.Visible:=False;
end;
				
				<dp n="d170"/>
 procedure TRegistrationForm.SecretNameLabelMouseMove(Sender:TObject;
   Shift:TShiftState;X,Y:Integer);
 begin
 //

   SecretNameLabel.Font.Color          :=clFuchsia;
  end;
  procedure TRegistrationForm.DrawBoyOrGirl;
 var
   dx:integer;
   dy:integer;
begin
//
   BoyHairYellowImage.Visible            :=False;
   BoyHairBlackImage.Visible             :=False;
   BoyHairOrangeImage.Visible            :=False;
   BoyHairBrownImage.Visible             :=False;
   BoyEyeBlueImage.Visible               :=False;
   BoyEyeGreenImage.Visible              :=False;
   BoyEyeBrownImage.Visible              :=False;
   BoyEyeBlackImage.Visible              :=False;
   BoyShirtYellowImage.Visible           :=False;
   BoyShirtBlueInage.Visible             :=False;
   BoyShirtRedImage.Visible              :=False;
   GirlHairYellowImage.Visible           :=False;
   GirlHairBrownImage.Visible            :=False;
   GirlHairOrangeImage.Visible           :=False;
   GirlHairBlackImage.Visible            :=False;
   GirlEyeBlueImage.Visible              :=False;
   GirlEyeGreenImage.Visible             :=False;
   GirlEyeBrownImage.Visible             :=False;
   GirlEyeBlackImage.Visible             :=False;
   GirlShirtYellowImage.Visible          :=False;
   GirlShirtBlueImage.Visible            :=False;
   GirlShirtRedImage.Visible             :=False;
//
 dx:=32;
				
				<dp n="d171"/>
   dy:=30;
if Gender=′Boy′then
   begin

  GirlImage.Visible                     :=False;

   with BoyImage do

   begin

     Left     :=272+dx;

     Top      :=208+dy;

     Width    :=201;

     Height   :=337;

     Visible  :=True;

   end;

   if HairColor= ′Blond′then

   with BoyHairYellowImage do

   begin

     Left    :=309+dx;

     Top     :=208+dy;

     Width   :=109;

     Height  :=98;

     Visible :=True;

    end;

    if HairColor= ′Brown′then

    with BoyHairBrownImage do

    begin

      Left     :=312+dx;

      Top      :=208+dy;

      Width    :=105;

      Height   :=97;

      Visible  :=True;

    end;

    if HairColor= ′Red′then

    with BoyHairOrangeImage do

    begin

       Left     :=312+dx;

       Top      :=208+dy;

       Width    :=105;

       Height   :=97;

       Visible  :=True;

      end;
				
				<dp n="d172"/>
if HairColor=′Black′then
with BoyHairBlackImage do
begin

   Left     :=311+dx;

   Top      :=208+dy;

   Width    :=113;

   Height   :=105;

   Visible  :=True;
end;
if EyeColor=′Blue′then
with BoyEyeBlueImage do
begin
   Left     :=352+dx;
   Top      :=267+dy;
   Width    :=46;
   Height   :=25;
   Visible  :=True;
end;
if EyeColor=′Green′then
with BoyEyeGreenImage do
begin
   Left     :=356+dx;
   Top      :=268+dy;
   Width    :=49;
   Height   :=25;
   Visible  :=True;
end;
if EyeColor=′Brown′then
with BoyEyeBrownImage do
begin
   Left     :=352+dx;
   Top      :=267+dy;
   Width    :=49;
   Height   :=25;
   Visible  :=True;
 end;
 if EyeColor=′Black′then
 with BoyEyeBlackImage do
				
				<dp n="d173"/>
  begin

     Left     :=352+dx;

     Top      :=265+dy;

     Width    :=49;

     Height   :=24;

     Visible  :=True;

   end;

   if FavoriteColor=′Yellow′then

   with BoyShirtYellowImage do

   begin

      Left      :=288+dx;
      Top       :=320+dy;

      Width     :=185;

      Height    :=193;

      Visible   :=True;

   end;

   if FavoriteColor=′Blue′then

   with BoyShirtBlueImage do

   begin

      Left     :=285+dx;

      Top      :=319+dy;

      Width    :=156;

      Height   :=192;

      Visible  :=True;

    end;

    if FavoriteColor=′Red′then

    with BoyShirtRedImage do

    begin

       Left     :=285+dx;

       Top      :=312+dy;

       Width    :=161;

       Height   :=185;

     Visible  :=True;

     end;

    end;
//
if Gender=′Girl′ then
   begin

  BoyImage.Visible                    :=False;
				
				<dp n="d174"/>
with GirlImage do
begin
   Left     :=274+dx;
   Top      :=197+dy;
   Width    :=177;
   Height   :=305;
   Visible  :=True;
end;
if HairColor=′Blond′then
with GirlHairYellowImage do
begin
   Left     :=281+dx;
   Top      :=197+dy;
   Width    :=139;
   Height   :=121;
   Visible  :=True;
end;
if HairColor=′Brown′then
with GirlHairBrownImage do
begin
   Left     :=277+dx;
   Top      :=197+dy;
   Width    :=143;
   Height   :=129;
   Visible  :=True;
end;
if HairColor=′Red′then
with GirlHairOrangeImage do
begin
   Left     :=279+dx;
   Top      :=197+dy;
   Width    :=142;
   Height   :=129;
   Visible  :=True;
 end;
 if HairColor= ′Black′then
 with GirlHairBlackImage do
 begin
				
				<dp n="d175"/>
   Left     :=280+dx;

   Top      :=197+dy;

   Width    :=139;

   Height   :=129;

   Visible  :=True;
end;
if EyeColor=′Blue′then
with GirlEyeBlueImage do
begin

  Left     :=360+dx;

  Top      :=266+dy;

  Width    :=49;

  Height   :=33;

  Visible  :=True;
end;
if EyeColor=′Green′then
with GirlEyeGreenImage do
begin

  Left     :=363+dx;

  Top      :=266+dy;

  Width    :=49;

  Height   :=25;

  Visible  :=True;
end;
if EyeColor=′Brown′then
with GirlEyeBrownImage do
begin
   Left      :=363+dx;
   Top       :=266+dy;
   Width     :=49;
   Height    :=25;
   Visible   :=True;
 end;
 if EyeColor=′Black′then
 with GirlEyeBlackImage do
 begin

  Left     :=359+dx;

  Top      :=266+dy;

  Width    :=49;
				
				<dp n="d176"/>
            Height  :=25;

            Visible :=True;

       end;

       if FavoriteColor=′Yellow′then

       with GirlShirtYellowImage do

       begin

          Left     :=305+dx;

          Top      :=303+dy;

          Width    :=144;

          Height   :=209;

          Visible  :=True;

       end;

       if FavoriteColor=′Blue′then

       with GirlShirtBlueImage do

       begin

          Left     :=302+dx;

          Top      :=312+dy;

          Width    :=147;

          Height   :=193;

          Visible  :=True;

       end;

      if FavoriteColor=′Red′then

      with GirlShirtRedImage do

      begin

         Left     :=305+dx;

         Top      :=315+dy;

         Width    :=143;

         Height   :=201;

         Visible  :=True;

       end;

    end;
end;
procedure TRegistrationForm.AssignCurrentItem(Value:string);
begin
   if CurrentItem=′SecretName′           then

    begin

       SecretName:=Value;

       AboutYouLabel.Visible              :=True;
				
				<dp n="d177"/>
  AboutSexLabel.Visible                   :=True;

  AboutAgeLabel.Visible                   :=True;

  AboutEyeLabel.Visible                   :=True;

  AboutHairLabel.Visible                  :=True;

  AboutBedTimeLabei.Visible               :=True;

  FavoritesLabel.Visible                  :=True;

  FavoritesColorLabel.Visible             :=True;

  FavoritesFoodLabel.Visible              :=True;

  FavoritesActivityLabel.Visible          :=True;

  FavoritesAnimalLabel.Visible            :=True;
  end;
if(CurrentItem=′Gender′)and(Gender<>Value)then
   begin

  DateOfBirth        :=′′;

  EyeColor           :=′′;

  HairColor          :=′′;

  BedTimeHour        :=′′;

  FavoriteColor      :=′′;

  FavoriteFood       :=′′;

  FavoriteActivity   :=′′;

  FavoriteAnimal     :=′′;

  Gender  :=Value;
   end;

  if CurrentItem=′DateOfBirth′         then DateOfBirth        :=Value;

  if CurrentItem=′EyeColor′            then EyeColor           :=Value;

  if CurrentItem=′HairColor′           then HairColor          :=Value;

  if CurrentItem=′BedTimeHour′         then BedTimeHour        :=Value;

  if CurrentItam=′FavoriteColor′       then FavoriteColor      :=Value;

  if CurrentItem=′FavoriteFood′        then FavoriteFood       :=Value;

  if CurrentItem=′FavoriteActivity′    then FavoriteActivity   :=Value;

  if CurrentItem=′FavoriteAnimal′      then FavoriteAnimal     :=Value;
   //

  BackgroungSpeaking(Value);

  SteemAnimate.Visible:=True;

  ShowVIfSelected;

  //
end;
procedure TRegistrationForm.BackgroungSpeaking(Value:string);
var
  TalkString:string;
begin
				
				<dp n="d178"/>
  TalkString:= ′′;
  if CurrentItem=′SecretName′then

   begin

     if Value=′Bubble Gum′then    TalkString:=′fa75a′;

     if Value=′RainBow′   then    TalkString:=′fa75b′;

   end;
  if CurrehtItem=′Gender′   then

   begin

      if Value=′Boy′      then     TalkString:=′ay64′;

      if Value=′Girl′     then     TalkString:=′ay65′;

   end;
  if CurrentItem=′EyeColor′ then

   begin

      if Value=′Blue′     then    TalkString:=′ay66a′;

      if Value=′Green′    then    TalkString:=′ay66b′;

      if Value=′Brown′    then    TalkString:=′ay66c′;

      if Value=′Black′    then    TalkString:=′ay66d′;

    end;
if CurrentItem=′HairColor′  then
   begin

    if Value=′Blond′      then    TalkString:=′ay68a′;

    if Value=′Brown′      then    TalkString:=′ay68b′;

    if Value=′Red′        then    TalkString:=′ay68c′;

    if Value=′Black′      then    TalkString:=′ay68d′;

  end;
if CurrentItem=′FavoriteColor′        then
   begin

    if Value=′Yellow′ then    TalkString:=′fa71a′;

    if Value=′Blue′   then    TalkString:=′fa71b′;

    if Value=′Red′    then    TalkString:=′fa71c′;

   end;
if CurrentItem=′FavoriteFood′         then
   begin

     if Value=′Pizza′                  then     TalkString:=′fa72a′;

     if Value=′French Fries′           then     TalkString:=′fa72b′;

     if Value=′Macaroni And Cheese′    then     TalkString:=′fa72c′;

   end;
				
				<dp n="d179"/>
   if CurrentItem=′FavoriteActivity′then

      begin

         if Value=′Drawing′                  then     TalkString:=′fa73a′;

         if Value=′Playing Computer Games′   then     TalkString:=′fa73b′;

         if Value=′Play Make Believe′        then     TalkString:=′fa73c′;

       end;

   if CurrentItem=′FavoriteAnimal′           then

      begin

         if Value=′Horse′  then    TalkString:=′fa74a′;

         if Value=′Dog′    then    TalkString:=′fa74b′;

         if Value=′Cat′    then    TalkString:=′fa74c′;

       end;

  if TalkString<>′′then MainForm.BackGroundTalking(MainForm.AboutYouPath

                           +TalkString+′.wav′,′S′);
end;
procedure TRegistrationForm.RegistrationBackImageMouseMove(Sender:TObject;
  Shift:TShiftState;X,Y:Integer);
begin
//
  GoOutArrowImage.Visible:=True;
end;
procedure TRegistrationForm.GoOutArrowImageCiick(Sender:TObject);
begin
  if MainForm.ThreadInProgress then exit;

    GoBackToMenu;
end;
procedure TRegistrationForm.LoadFromDataBase;
begin

  ChildName          :=MainForm.PDBEngine.ChildName;

  SecretName         :=MainForm.PDBEngine.SecretName;

  Gender             :=MainForm.PDBEngine.Childsex;

  DateOfBirth        :=MainForm.PDBEngine.BirthDay;

  EyeColor           :=MainForm.PDBFngine.ChildEyeColor;

  HairColor          :=MainForm.PDBEngine.ChildHairColor;

  BedTimeHour        :=MainForm.PDBEngine.BedTimeHour;

  FavoriteColor      :=MainForm.PDBEngine.FavoriteColor;

  FavoriteFood       :=MainForm.PDBEngine.FavoriteFood;
				
				<dp n="d180"/>
       Favorite Activity   := MainForm.PDBEngine.Favorite Activity;

       FavoriteAnimal      := MainForm.PDBEngine.FavoriteAnimal;
 end;
 procedure TRegistrationForm.SaveToDataBase;
 begin

     MainForm.PDBEngine.ChildName             :=ChildName;

     MainForm.PDBEngine.SecretName            :=SecretName;

     MainForm.PDBEngine.ChildSex              :=Gender;

     MainForm.PDBEngine.BirthDay              :=DateOfBirth;

     MainForm.PDBEngine.ChildEyeColor         :=EyeColor;

     MainForm.PDBEngine.ChildHairColor        :=HairColor;

     MainForm.PDBEngine.BedTimaHour           :=BedTimeHour;

     MainForm.PDBEngine.FavoriteColor         :=FavoriteColor;

     MainForm.PDBEngine.FavoriteFood          :=FavoriteFood;

     MainForm.PDBEngine.FavoriteActivity      :=FavoriteActivity;

     MainForm.PDBEngine.FavoriteAnimal        :=FavoriteAnimal;

     MainForm.PDBEngine.UpDateCurrentChild;
 end;
procedure TRegistrationForm.ComboBox1Change(Sender:TObject);
begin

    Calendarl.Month:=ComboBox1.ItemIndex+1;
end;
Procedure TRegistrationForm.SpinEditlChange(Sender:TObject);
begin

    Calendarl.Year:=SpinEditl.Value;
end;
procedure TRegistrationForm.CalendarlChange(Sender:TObject);
var

  space1:string;

  space2:string;
begin

    if Calendarl.Month<10 then space1 := ′0′else space1 := ′′;

    if Calendarl.Day<10 then space2 := ′0′  else space2 := ′′;

    DateOfBirth :=spacel+IntToStr(Calendarl. Month)+′/′+space2+

                    IntToStr(calendarl. Day)+′/′+IntToStr(Calendarl.Year);
end;
procedure TRegistrationForm. BirthDayImageClick(Sender:TObject);
begin
				
				<dp n="d181"/>
    if MainForm.ThreadInProgress then exit;

    BirthDayPanel.Visible := False;

    ShowVTfSelected;
end;
procedure TRegistrationForm.RegistrationImageClick(Sender:TObject);
begin

   if MainForm. ThreadInProgress then exit;

   BirthDayPanel.Visible    :=False;

   FavoritePanel.Visible    :=False;

   BedTimeHourPanel.Visible :=False;

   SteemAnimate.Visible := True;

   ShowVTfSelected;
end;
procedure TRegistrationForm.BedTimeHourImageClick(Sender:TObject);
begin
   if MainForm.ThreadInProgress then exit;
   BedTimeHourPanel.Visible :=False;
   ShowVIfSelected;
end;
procedure TRegistrationForm.ComboBox2Change(Sender:TObject);
begin

   BedTimeHour :=ComboBox2.Text;
end;
procedure TRegistrationForm.BirthDayOKImageClick(Sender:TObject);
begin
//

   if MainForm.ThreadInProgress then exit;

   BirthDayPanel.Visible:=False;

   ShowVIfseletted;
end;
procedure TRegistrationForm.BedTimeHourOKImageClick(Sender:TObject);
begin
//
   if MainForm.ThreadInProgress then exit;
   BedTimeHourPanel.Visible:=False;
   ShowVIfSelected;
end;
				
				<dp n="d182"/>
 procedure TRegistrationForm.ShowVIfSelected;
 begin

     if Gender         = ′′then VGenderImage.visible            :=False 
 else VGenderImage.visible             :=True;

     if DateOfBirth    = ′′then VBirthdayImage.visible          :=False
 else VBirthdayImage.visible           :=True;

     if EyeColor       = ′′then VEyeColorImage.visible          :=False
 else VEyeColorImage.visible           :=True;

     if HairColor      = ′′then VHairColorImage.visible         :=False
 else VHairColorImage.visible           :=True;

    if BedTimeHour     = ′′then VBedTimeHourImage.visible       := False
 else VBedTimeHourImage.visible         :=True;

    if FavoriteColor   = ′′then VFavoritecolorImage.visible     := False
 else VFavoriteColorImage.visible       :=True;

    if FavoriteFood    = ′′then VFavoriteFoodImage.visible      := False
 else VFavoriteFoodImage.visible        :=True;

    if FavoriteActivity= ′′then VFavoriteActivityImage.visible  := False
 else VFavoriteActivityImage.visible    :=True;

    if FavoriteAnimal  = ′′then VFavoriteAnimalImage.visible    :=False
 else VFavoriteAnimalImage.visible      :=True;
end;
procedure TRegistrationForm.EscapelClick(Sender:TObject);
begin
//

  GoBackToMenu;
end;
end.
				
				<dp n="d183"/>
================================

  Copyright (c) 1995-199g Creator Ltd. All Rights Reserved
================================
Description:This is the SingAlong unit.
unit SingAlong;
interface
uses
  Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs,
  ExtCtrls,Menus;
type
  TSingAlongForm=class(TForm)

  Imagel:TImage;

  StoryTellerImage:TImage;

  PeasImage:TImage;

  HeadImage:TImage;

  MainMenul:TMainMenu;

  testl:TMenuItem;

  spacel:TMuItem;

  Timerl:TTimer;

  procedure spacelClick(Sender:TObject);

  procedure TimerlTimet(Sender:TObject) ;

  procedure FormCreate(Sender:TObject);
  private

  (Private declaretions)
  public

  (Public declaretions)

  Song:Integer;

  procedure PlaySongs;

  end;
var

  SingAlongForm:TSingAlongForm;
implementation
uses Menu,Main,creator,PestoSong;
(SR *.DEM)
				
				<dp n="d184"/>
procedure TSingAlongForm.spacelClick(Sender:TObject);
begin
// stop playing and go back to menu

    Timerl.Enabled :=False;

    Spacel.Enabled :=False;

    Hide;

    MenuForm.Show;
end;
procedure TSingAlongForm.TimerlTimer(Sender:TObject);
begin

    Timerl. Enabled:=False;

       Hide;

       CreatorForm.Show;

       CreatorForm.PlayMovie;
end;
procedure TSingAlongForm.FormCreate(Sender:TObject);
begin
   Timerl.Enabled:=False;
   with StoryTellerImage do
   begin

    Left    :=125;

    Top     :=80;

    Width   :=453;

    Height  :=453;

  end;

  with PeasImage do

  begin

     Left    :=176;

     Top     :=176;

     Width   :=186;

     Height  :=236;
   end;
   with HeadImage do
   begin

     Left    :=152;

     Top     :=129;

     Width   :=258;

     Height  :=346;
   end;
   StoryTellerImage.Visible:=True;
				
				<dp n="d185"/>
  PeasImage.Visible        := False;

  HeadImage.Visible        := False;
end;
procedure TSingAlongForm.PlaySongs;
begin                // 85=Broadcast

  with PestoSongForm do

  begin

    Spacel.Enabled:=True;

    Timerl.Enabled:=True;

    MediaPlayerl.Open;

  end;

  with CreatorForm do

  begin

    Spacel.Enabled:=True;

    Timerl.Enabled:=True;

    MediaPlayerl.Open;

  end;
   Timerl.Interval:=3000;
   Timerl. Enabled:=True;
   Song:=1;
   StoryTellerImage.Visible :=True;
   PeasImage.VisibIe        :=False;
   HeadImage.Visible        :=False;
   //MainForm. TalkInBackGround(85,MainForm. AudioPath+
′StoryTeller.wav′,′′);
end;
end.
				
				<dp n="d186"/>
================================

  Copyright (c) 1995-1998 Creator Ltd. All Rights Reserved
================================
Description:This is the Status unit.
unit Status;
interface
uses
   Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs,
   ComCtrls,Buttons,StdCtrls,jpeg,Gauges,ExtCtrls,Menus;
type
   TStatusForm=class(TForm)

     StatusImage:TImage;

     GotoMenuImage:TImage;

     MinimizeImage:TImage;

     StatusGauge:TGauge;

     Labell:TLabel;

     MainMenul:TMainMenu;

     testl:TMenuItem;

     Escapel:TMenuItem;

     StatusAnimate:TAnimate;

     SpeechLabel:TLabel;

     StandByLabel:TLabel;

     TalkErrorLabel:TLabel;

     procedure FormClose(Sender:TObject;var Action:TCloseAction);

     procedure SpeedButtonlClick(Sender:TObject);

     procedure FormCreate(Sender:TObject);

     procedure SpeedButton2Click(Sender:TObject);

     procedure GotoMenuImgeClick(Sender:TObject);

     procedure MinimizeImageClick(Sender:TObject);

     procedure EscapelClick(Sender:TObject);

     procedure FormShow(Sender:TObject);

     procedure FormHide(Sender:TObject);
   private

     (Private declarations)
  public

     (Public declarations)
  end;
				
				<dp n="d187"/>
var

  StatusForm:TStatusForm;
implementation
uses Menu,Main,ToySimulation,MotionSimulation,PanelControls;
(SR *.DFM)
procedure TStatusForm.FormClose(Sender:TObject;var Action:TCloseAction);
begin

  StatusAnimate.Active  :=False;

  MenuForm.Show;

  if MenuForm.Threadl<>nil then

    begin

      MenuForm.Threadl.Terminate;

   end;
end;
procedure TStatusForm.SpeedButtonlClick(Sender:TObject);
begin

      SimulationForm.Close;

      MotionSimulationForm.Close;

  close;

  MenuForm.Show;
end;
procedure TStatusForm.FormCreate(Sender:TObject);
begin

        //Icon.LoadFromFile(MainForm.GraphicsPath+′PestoIcon.ico′);

     StatusAnimate.FileName :=MainForm.GraphicsPath+′top.AVT′;

     StatusAnimate.Active   :=True;

     GotoMenuImage.Cursor := 5;

     MinimizeImage.Cursor := 5;
end;
procedure TStatusForm.SpeedButton2Click(Sender:TObject);
begin
   Application.Minimize;
end;
procedure TStatusForm.GotoMenuImageClick(Sender:TObject);
begin
				
				<dp n="d188"/>
    SimulationForm.Close;

    MotionSimulationForm.Close;

    close;
    MenuForm.Show;
end;
procedure TStatusForm.MinimizeImageClick(Sender:TObject);
begin

  Application.Minimize;
end;
procedure TStatusForm.EscapelClick(Sender:TObject);
begin

  SimulationForm.Close;

  MotionSimulationForm.Close;

  close;

  MenuForm.Show;
end;
procedure TStatusForm.FormShow(Sender:TObject);
begin
  PanelControlForm.Show;
end;
procedure TStatusForm.FormHide(Sender:TObject);
begin
  PanelControlForm.Hide;
end;
end.
				
				<dp n="d189"/>
================================

  Copyright (c) 1995-1998 Creator Ltd. All Rights Reserved
================================
Description:This is the Toy unit.
unit Toy;
(This Unit contained several methods,converting from
 Dll/Ocx to Simple methods)
interface
uses
   Windows,Messages,SysUtils,Classes,Graphics,Controls,

  Forms,Dialogs;
type
   TToy=class(TComponent)
   private

   (Private declarations)

   FToyNumber:Integer;
   public

   (Public declarations)

    function Talk(TalkFiles:string;Motion:string):Integer;

    function TalkAndListen(TalkFiles:string;TalkMotion:string;

                    ListenTime:Real;ListenMotion:string):Integer;

    function Wait  (ListenTime:Real;Motion:string):Integer;

    function Listen(Map:string;DelayTime:Real;

                          device:String;Motion:string):
Integer;

    function TurnOn                 :Boolean;

    function TurnOff                :Boolean;

    function CheckToySystem         :Integer;

    function ListenConv(ListenMotion:string):Integer;

    function TalkConv(ListenMotion :string):Integer;

    function RecordWave (WaveFile:string;DelayTime:Real;

                         Motion:String):Integer;

    function ListenActive (Map:string;DelayTime:Real;

                     device:String;Motion:string):Integer;

    function TalkAll (TalkFiles:string;Motion:string):Integer;

    function ToyTalkIn  (ToyNumberValue:Integer;TalkFiles:string;
				
				<dp n="d190"/>
                          LTime:Integer;Motion:string):Integer;

     function ToyListenIn(DTime:Integer;Motion:string):Integer;

  published

     property ToyNumber:integer read FToyNumber write FToyNumber;

  end;
  const

    SBDevice=0;

    AllToys=85;
  implementation
   uses

   Main,ToySimulation,MotionSimulation,status;
  //**************************************************************************
  //Examples:Talk(′a.wav+b.wav+c.wav′,′Motor and Listen∷1.5);
  //                                                  Listen Time=1.5sec
  //sensors:1-Nose 2-Hand 3-Foot;0-none
  function TToy.Talk(TalkFiles:string;Motion:string):Integer;
  var

  LTime         :integer;

  SensorFlag    :Boolean;

  SensorNumber  :Integer;

  i             :Integer;
  begin

  LTime:=12000;

  StatusForm.TalkErrorLabel.Visible:=False;

   if ToyNumber<0 then

  begin

  simulationForm.ToyTalk(TalkFiles,Motion,0(LTime));//fix

  While(SimulationForm.ToyTalkStatus=True)or

              (SimulationForm.ToyListenStatus=True)do

              sleep(500);

  //Sleep(1000);//Limitation of the Equipment    //fix

  Result:=SimulationForm.KeyPress;

  end
//===============================

  else

  begin//ToyNumber>0

  Result:=ToyTalkIn(ToyNumber,TalkFiles,LTime,Motion);

  if Result<0 then

  begin

    sleep(250);
				
				<dp n="d191"/>
      Result:=ToyTalkIn(ToyNumber,TalkFiles,LTime,Motion);

     end;

    if Result < 0 then

     begin

       StatusForm. TalkErrorLabel.Visible:= True;

       sleep(1000);

       Result :=ToyTalkIn(ToyNumber,TalkFiles,LTime,Motion);

     end;

     if Result < 0 then

     begin

       sleep(1000);

       Result := ToyTalkIn(ToyNumber,TalkFiles,LTime,Motion);

     end;

     if Result=-2 then

     begin

       sleep(20000);

       Result :=ToyTalkIn(ToyNumber,TalkFiles,LTime,Motion);

     end;
     if Result= -2 then

     begin

      sleep(20000);

      Result:=ToyTalkIn(ToyNumber,TalkFiles,LTime,Motion);

     end;

  end;
end;
//*****************************************************************
function TToy. TalkAll(TalkFiles:string;Motion:string):Integer;
var
  LTime          : integer;
  SensorFlag     : Boolean;
  SensorNumber   : Integer;
  i              : Integer;
begin
  LTime:=50;
   if ToyNumber < 0 then
   begin

    SimulationForm.ToyTalk(TalkFiles,Motion,LTime);
				
				<dp n="d192"/>
        While   (SimulationForm.ToyTalkStatus=True)or

                         (SimulationForm. ToyListenStatus=True)do

                          sleep(500);

        Sleep(1000);//Limitation of the Equipment

        Result:=SimulationForm.KeyPress;

    end
//=========================================

    else

      begin // ToyNumber >0

          Result:=ToyTalkIn(AllToys,TalkFiles,LTime,Motion);

          if Result < 0 then

          Result:=ToyTalkIn(AllToys,TalkFiles,LTime,Motion);

       end;
end;
//**********************************************************************************
function  TToy.Wait    (ListenTime :Real;Motion:string):Integer;
var
  LTime:integer;
begin
//=========================================
   LTime := Trunc(1000*ListenTime);
   SimulationForm.ToyListen(LTime,Motion);
   While(SimulationForm.ToyTalkStatus=True)or

                (SimulationForm.ToyListenStatus =True)do

                 sleep(200);
   Sleep(1000);//Limitation of the Equipment
   Result:=SimulationForm.KeyPress;
//=========================================
   {
   Result:=
MainForm.XMidil.ToyListen2(ToyNumber,Trunc(LTime*10),ListenConv(Motion));
   Result:=MainForm.SR1.WaitForEvent(″,Trunc(LTime*10),2);//Sensors
   }
//=========================================
end;
//**********************************************************************************
//sensors:1-Nose 2-Hand 3-Foot;0-none
function TToy.Listen(Map    :stringDelayTime:Real;

                   device :String;Motion:string):Integer;
var
   DTime:Integer;
				
				<dp n="d193"/>
  Flags:Integer;

  SRisOn:Boolean;
 begin

  sleep(100);

  DTime:=Trunc(DelayTime*10);

  Flags:=0;

  if Pos(′SR′,Device)       > 0 then

    begin

       Flags :=Flags+1;

       SRisOn:=True;

     end

     else SRisOn:=False;

  if Pos(′Sensor′,Device) > 0 then Flags :=Flags+2;

  StatusForm.SpeechLabel.Visible:=True;

  Result:=MainForm.srl.WaitForEvent(Map,DTime,Flags);

  StatusForm.SpeechLabel.Visible:=False;

  if (Result > 0)and(MainForm.srl.GetPhraseConfLevel(1) < 5000)and

     (SRisOn=True)then Result:=0;
end;
//**********************************************************************************
//sensors:1-Nose 2-Hand 3-Foot;0-none
function TToy.ListenActive(Map:string;DelayTime:Real;

                    device:String;Motion:string):Integer;
var
   DTime :Integer;
   Flags :Integer;
   SRisOn :Boolean;
begin
   Result :=1;
   DTime :=Trunc(DelayTime*10);
   if ToyNumber > -1 then
     begin

     Result :=ToyListenIn(DTime,Motion);

     if Result <> 1 then

       Result :=ToyListenIn(DTime,Motion);

     if Result <> 1 then

       begin

         Result :=ToyListenIn(DTime,Motion);

       end;

     end

     else

      Result :=1;
  Flags  :=0;
				
				<dp n="d194"/>
    if Pos(′SR′,Device)       > 0 then

     begin

       Flags   :=Flags+1;

       SRisOn  :=True;

    end

    else SRisOn :=False;

  if Pos(′Sensor′,Device|  > 0 then  Flags:= Flags+2;

  sleep(100);

  if Result=1 then

     begin

       StatusForm.SpeechLabel.Visible :=True;

       Result:=MainForm.srl.WaitForEvent(Map,DTime,Flags);

       StatusForm.SpeechLabel.Visible:=False;

       if (Result > 0) and (MainForm.srl.GetPhraseConfLevel(1) < 5000)and

          (SRisOn = True) then Result := 0;

    end

    else if Result = -2 then Result := -9999;
end;
//**********************************************************************************
function TToy.TalkAndListen (TalkFiles :string;TalkMotion :string;

                   ListenTime :Real;ListenMotion :string) :Integer;
var
  Flags : Integer;
  LTime : Integer;
begin
  Flags := 0;
  Ltime := 0;
  {
   SimulationForm.ToyTalk(TalkFiles,Motion,LTime);
   While   (SimulationForm. ToyTalkStatus = True) or

                   (SimulationForm.ToyListenStatus = True) do

                    sleep(500);
   Sleep(1000);//Limitation of the Equipment
   Result := SimulationForm.KeyPress;
   }
//=========================================
   //Result :=MainForm.XMidil.ToyTalk2(ToyNumber,TalkFiles,

           //SBDevice,0,0,0);
//=========================================
				
				<dp n="d195"/>
 end;
 //**********************************************************************************
 function TToy.TurnOn                     :Boolean;
 var

  ResultSR     : Integer;

  ResultXMidi  : Integer;
 begin

   // open SR

  {with MainForm do

  begin

    SR1.DataBase    := ′ASR1500 - Telephone′;

    SR1.User        := ′Creator′;

    SR1.Context     := ′Demo′;

    SR1.OpenAttr    := 0;

    ResultSR        := SR1.Init;

   end;}

  ResultSR := MainForm. SR1.Init;
  //open  MIDI
  ResultXMidi := MainForm.XMidil.StartHUB;
  if (MainForm. ToyMachine = MainForm. ToyNameIsBear) then
MainForm.XMidil.SetMotor(ToyNumber,0,1,200);

    Result := (ResultSR = 0) AND (ResultXMidi = 0);
end;
function TToy.TurnOff                      :Boolean;
var
   ResultSR     : Integer;
   ResultXMidi  : Integer;
begin

  //close SR &amp; MIDI

  ResultSR     := MainForm.SR1.Close;

  ResultXMidi := MainForm.XMidil.StopHUB;

  Result :=(ResultSR = 0) AND (ResultXMidi = 0);
end;
//  0=OK , -1=LowBattery, -2=No Communication
//  -3=LowBattery &amp; No Communication
function TToy.CheckToySystem               :Integer;
begin
   Result:= 0;
end;
				
				<dp n="d196"/>
function TToy.ListenConv(ListenMotion:string):Integer;
begin
   Result:=0;
   if ListenMotion= ′W′ then Result :=0;
   if  ListenMotion= ′X′ then Result :=1;
   if  ListenMotion= ′Y′ then Result :=2;
   if  ListenMotion= ′Z′ then Result :=3;
end;
function TToy.TalkConv(ListenMotion:string):Integer;
begin
   Result:=0;
   if  ListenMotion= ′S′ then Result :=0;
   if  ListenMotion= ′EC′then Result:=1;
   if  ListenMotion= ′E′ then Result:=2;
   if  ListenMotion= ′EL′then Result:=3;
   if  ListenMotion= ′S#′then Result:=4;
   if  ListenMotion= ′X′ then Result:=5;
   if  ListenMotion= ′X′ then Result:=6;
   if  ListenMotion= ′X′ then Result:=7;
   if  ListenMotion= ′X′ then Result:=8;
   if  ListenMotion= ′X′ then Result:=9;
   if  ListenMotion= ′X′ then Result:=10;
   if  ListenMotion= ′X′ then Result:=11;
   if  ListenMotion= ′X′ then Result:=12;
   if  ListenMotion= ′X′ then Result:=13;
   if  ListenMotion= ′X′ then Result:=14;
   if  ListenMotion= ′X′ then Result:=15;
   if  ListenMotion= ′X′ then Result:=16;
   if  ListenMotion= ′X′ then Result:=17;
   if  ListenMotion= ′X′ then Result:=18;
   if  ListenMotion= ′X′ then Result:=19;
   if  ListenMotion= ′X′ then Result:=20;
   if  ListenMotion= ′X′ then Result:=21;
   if  ListenMotion= ′X′ then Result:=22;
   if  ListenMotion= ′X′ then Result:=23;
   if  ListenMotion= ′x′ then Result:=24;
   if  ListenMotion= ′X′ then Result:=25;
   if  ListenMotion= ′X′ then Result:=26;
   if  ListenMotion= ′X′ then Result:=27;
   if  ListenMotion= ′X′ then Result:=28;
   if  ListenMotion= ′X′ then Result:=29;
				
				<dp n="d197"/>
  if  ListenMotion= ′X′ then Result:=30;
 end;
 function TToy.RecordWave(WaveFile:string;DelayTime:Real;

                       Motion:String):Integer;
 var

  DTime:Integer;
 begin

   Wait(DelayTime,Motion);

   DTime:=Trunc(DelayTime*10);

   Result :=MainForm.XMidil.ToyRecord(WaveFile,DTime);
 end;
 function TToy.ToyTalkIn   (ToyNumberValue:Integer;TalkFiles:string;

                          LTime:Integer;Motion :string):Integer;
 begin

  sleep(100);

  if(MainForm.ToyMachine=′StoryTeller′) and (ToyNumber <> 85) then

              Result:=MainForm.XMidil.ToyTalk2(ToyNumber,TalkFiles,

                        SBDevice,LTime,TalkConv(Motion),0);

  if (MainForm.ToyMachine= ′TeddyBear′) or (ToyNumber=85)    then

             Result:=MainForm.XMidil.NewToyTalk(ToyNumber,TalkFiles,

                        SBDevice,9,LTime);
end;
function TToy.ToyListenIn(DTime:Integer;Motion:string):Integer;
begin
   sleep(100);
   if MainForm. ToyMachine= ′StoryTeller′then

    Result:=
MainForm.XMidil.ToyListen2(ToyNumber,DTime,ListenConv(Motion));
   if MainForm.ToyMachine= ′TeddyBear′    then

     Result:=MainForm.XMidil.ToyListenTime(ToyNumber,DTime);
end;
end.
				
				<dp n="d198"/>
========================================= 

     Copyright (c) 1995-1998 Creator Ltd.All  Rights Reserved
=========================================
Description:This is the Intro unit.
unit Intro;
interface
uses
  Status,Main,Toy,PanelControls,Windows,
  Messages,SysUtils,Classes,Graphics,Controls,Forms,
Dialogs,Registration;
type
  TIntro=class(TThread)
  private

  {Private declarations}

   GameStatus                  : string;

   ChildName                   : string;

   SecretName                  : string;

   DateOfBirth                 : string;

   EyeColor                    : string;

   HairColor                   : string;

   BedTimeHour                 : string;

   FavoriteColor               : string;

   FavoriteFood                : string;

   FavoriteActivity            : string;

   FavoriteAnimal              : string;

   ChildSex                    : string;

   IntroNextSection            : Integer;

  PlayNextSection             : Integer;

   PrincessNextSection         : Integer;

   TheStoryMenuNextSection     : Integer;

   RunStoryMenuNextSection     : Integer;

   BedTimeRitualNextSection    : Integer;

   GrouchyNextSection          : Integer;

   BunnyNextSection            : Integer;

   PresentationNextSection     : Integer;

   VisitSongMenu               : Integer;

   VisitGameMenu               : Integer;

   VisitStoryMenu              : Integer;
				
				<dp n="d199"/>
   VisitBunnyShort             : Integer;

   VisitBunnyLong              : Integer;

   VisitPrincess               : Integer;

   BunnyFavoriteFood           : string;
   protected

   procedure Execute;override;

   procedure LoadDataFromDatabsse;

   procedure SaveDataFromDatabase;

   procedure UpdateIntroBar;

   procedure UpdatePlayBar;

   procedure UpdatePrincessBar;

   procedure UpdateTheStoryMenuBar;

   procedure UpdateRunStoryMenuBar;

   procedure UpdateBedTimeRitualBar;

   procedure UpdateGrouchyBar;

   procedure UpdateBunnyBar;

   procedure UpdatePresentationBar;

   procedure ApplicationMinimize;

   procedure ClearStatusControl;
   public

   constructor Create (Status:string);
   end;
//sensors:1-Nose 2-Hand 3-Foot
constt
   NoseSensor=2;
   HandSensor=1;
   FootSensor=3;
implementation
{Important:Methods and properties of objects in VCL can only be used in a
 method called using Synchronize,for example,

    Synchronize(UpdateCaption);
   and UpdateCaption could look like,

   procedure TIntro.UpdateCaption;

   begin

     Forml.Caption:= ′UPdated in a thread′;

   end; }
				
				<dp n="d200"/>
 {TIntro}
 constructor TIntro.Create (Status:string);
 begin
   inherited Create(False);
   FreeOnTerminate:=True;
   GameStatus:=Status;
 end;
 procedure TIntro.LoadDataFromDatabase;
 begin

   // Get Current Data From database

   ChildName           :=Trim(MainForm.PDBEngine.ChildName);

   SecretName          :=Trim(MainForm.PDBEngine.SecretName);

   ChildSex            :=Trim(MainForm.PDBEngine.ChildSex);

   DateOfBirth         :=Trim(MainForm.PDBEngine.BirthDay);

   EyeColor            :=Trim(MainForm.PDBEngine.ChildEyeColor);

   HairColor           :=Trim(MainForm.PDBEngine.ChildHairColor);

   BedTimeHour         :=Trim(MainForm.PDBEngine.BedTimeHour);

   FavoriteColor       :=Trim(MainForm.PDBEngine.FavoriteColor);

   FavoriteFood        :=Trim(MainForm.PDBEngine.FavoriteFood);

   FavoriteActivity    :=Trim(MainForm.PDBEngine.FavoriteActivity);

   FavoriteAnimal      :=Trim(MainForm.PDBEngine.FavoriteAnimal);

   VisitSongMenu       :=MainForm.PDBEngine.VisitSongMenu;

   VisitGameMenu       :=MainForm.PDBEngine.VisitGameMenu;

   VisitStoryMenu      :=MainForm.PDBEngine. VisitStoryNenu;

   VisitBunnyShort     :=MainForm.PDBEngine.VisitBunnyShort;

   VisitBunnyLong      :=MainForm.PDBEngine.VisitBunnyLong;

   VisitPrincess       :=MainForm.PDBEngine.VisitPrincess;

   BunnyFavoriteFood   :=MainForm.PDBEngine.BunnyFavoriteFood;
end;
procedure TIntro.SaveDataFromDatabase;
begin

   // Save Current Data To database

   MainForm.PDBEngine.VisitSongMenu    :=VisitSongMenu;

   MainForm.PDBEngine.VisitGameMenu    :=VisitGameMenu;

   MainForm.PDBEngine.VisitStoryMenu   :=VisitStoryMenu;

   MainForm.PDBEngine.VisitBunnyShort  :=VisitBunnyShort;

   MainForm.PDBEngine.VisitBunnyLong   :=VisitBunnyLong;

   MainForm.PDBEngine.VisitPrincess    :=VisitPrincess;

   MainForm.PDBEngine.BunnyFavoriteFood:=BunnyFavoriteFood;
end;
				
				<dp n="d201"/>
procedure TIntro.Execute;
var
  ParamTalk             : Integer;
  ParanmListen          : Integer;
  Toy                   : TToy;
  LastPresentation      : Integer;
  Path                  : string;
  IntroPath             : string;
  BedTimePath           : string;
  BunnyPath             : string;
  GrouchyPath           : string;
  PeasPath              : string;
  PlayPath              : string;
  RunStoryPath          : string;
  SillyPath             : string;
  SongMenuPath          : string;
  SongsPath             : string;
  StoryMenuPath         : string;
  PresentationPath      : string;
  GamePrincessStatus    : string;
  WaveSection           : string;
  Sensor1               : Integer;
  Sensor2               : Integer;
  Sensor3               : Integer;
  GetSensor             : Integer;
  LoopCount             : Integer;
  DTime                 : Integer;
  BeginningPlay         : Boolean;
begin
  { Place thread code here }
  Toy              :=MainForm.Toy;
  Path             :=MainForm.AudioPath;
  IntroPath        :=Path+′Intro\′;
  BedTimePath      :=Path+′BedTime\′;
  BunnyPath        :=Path+′Bunny\′;
  GrouchyPath      :=Path+′Grouchy\′;
  PeasPath         :=Path+′Peas\′;
  PlayPath         :=Path+′Play\′;
  RunStoryPath     :=Path+′RunStory\′;
  SillyPath        :=Path+′Silly\′;
  SongMenuPath     :=Path+′SongMenu\′;
  SongsPath        :=Path+′Songs\′;
  StoryMenuPath    :=Path+′StoryMenu\′;
				
				<dp n="d202"/>
  PresentationPath           :=Path+′Presentation\′;

  LastPresentation           :=0;

  ParamTalk                  :=0;

  LoopCount                  :=0;

  Sensor1                    :=0;

  Sensor2                    :=0;

  Sensor3                    :=0;

  DTime                      :=5;

 BeginningPlay              :=True;

  Synchronize(LoadDataFromDatabase);

  if GameStatus= ′Intro′ then //===== How To Play ========

     begin

       IntroNextSection           :=-1; // UnPerform Intro Script

       PlayNextSection            :=-1; // UnPerform Play Script

       PrincessNextSection        :=-1; // UnPerform Princess Script

       TheStoryMenuNextSection    :=-1; // UnPerform TheStoryMenu Script

       RunStoryMenuNextSection    :=-1; // UnPerform RunStoryMenu Script

       BedTimeRitualNextSection   :=-1; // UnPerform BedTimeRitual Script

       GrouchyNextSection         :=-1; // UnPerform Grouchy Script

       BunnyNextSection           :=-1; // UnPerfom Bunny Script

       PresentationNextSection    :=-1; // UnPerfom Presentation Demo Ver
1.0

    end
   else

    begin                //===== Play =================

      IntroNextSection           :=-1; // UnPerform Intro Script

      PlayNextSection            :=-1; // UnPerform Play Script

      PrincessNextSection        :=-1; // UnPerform Princess Script

      TheStoryMenuNextSection    :=-1; // UnPerform TheStoryMenu Script

      RunStoryMenuNextSection    :=-1; // UnPerform RunStoryMenu Script

      BedTimeRitualNextSection   :=-1; // UnPerform BedTimeRitual Script

      GrouchyNextSection         :=-1; // UnPerform Grouchy Script

      BunnyNextSection           :=-1; // UnPerform Bunny Script

      PresentationNextSection    :=1;  // Perform Presentation Demo Ver 1.0

   end;
 StatusForm. StatusGauge.Progress :=0;
 while not Terminated do
   begin
// Checking

  (if StatusForm.WindowState =wsMinimized then
				
				<dp n="d203"/>
        begin

          //Synchronize(ApplicationMinimize);

         end;   }
// ==========  Presentation ============
// ---------------- write here all sessions-------------------
// ==============================

    case PresentationNextSection of

      1 : begin

             PresentationNextSection :=5;

           end;

       5 : begin

                                                            
              ParamTalk :=Toy.Talk(PresentationPath+′op002.wav′,′S′);

              Synchronize(UpdatePresentationBar);

              PresentationNextSection :=6;

           end;

       6 :begin

             ParamListen :=Toy.ListenActive(″,180,′Sensor′,′W′);

             if (ParamListen=FootSensor) or (ParamListen=NoseSensor) then
PresentationNextSection:=10

            else  PresentationNextSection :=5;

         //PresentationNextSection :=10;//??Delete this line

       end;
   10 : begin

         BeginningPlay :=False;

         if Time< StrToTime(′12:00:00′) then        PresentationNextSection
:=15

         else if Time> StrToTime(′16:00:00′) then PresentationNextSection
:=25

         else                                         PresentationNextSection
:=20;

       end;

   15:begin

         ParamTalk :=Toy.Talk(PresentationPath+′op015m.wav′,′S′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=35;

      end;
				
				<dp n="d204"/>
 20 :begin

      ParamTalk :=Toy.Talk(PresentationPath+′op020m.wav′,′S′);

      Synchronize(UpdatePresentationBar);

      PresentationNextSection :=35;

    end;
 25 :begin
      ParamTalk :=Toy.Talk(PresentationPath+′op025m.wav′,′S′);

      Synchronize(UpdatePresentationBar);

      PresentationNextSection :=35;

   end;
 35 :begin

      Secret Name:= ′Rainbow′;

      ParamListen:=Toy.Listen(′rainbow/2,bubble gum/3′,

                                    7,′SR′,′W′);

      case ParamListen of

        2: begin

              PresentationNextSection :=45;

              SecretName := ′Rainbow′;

            end;

        3: begin

              PresentationNextSection :=50;

              SecretName := ′BubbleGum′;

           end;

        else PresentationNextSection :=36;

      end;

      Synchronize(UpdatePresentationBar);

   end;
36 :begin

     ParamTalk :=Toy.Talk(PresentationPath+′op036m.wav′,′S#′);

     Synchronize(UpdatePresentationBar);

     PresentationNextSection :=55;

   end;
45 :begin

     ParamTalk :=Toy.Talk(PresentationPath+′op045m.wav′,′S#′);

     Synchronize(UpdatePresentationBar);

     PresentationNextSection :=55;

   end;
				
				<dp n="d205"/>
  50 :begin

         ParamTalk :=Toy.Talk(PresentationPath+′op050m.wav′,′S#′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=55;

      end;

  55 :begin

         ParamListen :=Toy.Listen(′story/1,game/2,song/3′,

                                           7,′SR′,′W′);

         case ParamListen of

           1: PresentationNextSection :=100; //story menu

           2: PresentationNextSection :=800; //game menu

           3: PresentationNextSection :=300; //song menu

           else PresentationNextSection :=60;

         end;

         Synchronize(UpdatePresentationBar);

       end;

  60 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′op060.wav′,′S#′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=65;

        end;

   65 :begin

          ParamListen :=Toy.Listen(′story/1,game/2,song/3′

                                           7,′SR′,′W′);

          case ParamListen of

            1: PresentationNextSection := 100; //story menu

            2: PresentationNextSection := 800; //game menu

            3: PresentationNextSection := 300; //song menu

            else PresentationNextSection := 100;

          end;

          Synchronize(UpdatePresentationBar);

       end;
//story menu
   100 :begin

         if  VisitStoryMenu =0 then PresentationNextSection :=125

           else

              begin

                  PresentationNextSection :=235;

                  if VisitBunnyShort =0 then
				
				<dp n="d206"/>
                   begin
                     PresentationNextSection :=105;

                     if SecretName = ′BubbleGum′ then
PresentationNextSection := 115;

                     if SecretName = ′Rainbow′   then
PresentationNextSection := 110;

                   end;

                     if (VisitBunnyLong =0) and (VisitBunnyShort <> 0)
then PresentationNextSection :=206;

                     if (VisitBunnyShort <> 0) and (VisitBunnyLong  <> 0)
then PresentationNextSection := 235;

               end;

         VisitStoryMenu :=VisitStoryMenu  +1;

       end;
   110 :begin

         ParamTalk :=Toy.Talk(PresentationPath+′stm110.wav′,′S′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=200;

       end; 
   115 :begin

         ParamTalk :=Toy.Talk(PresentationPath+′stm115.wav′,′S′);

         Synchronize(UpdetePresentationBar);

         PresentationNextSection :=200;

      end;
  125 :begin

        ParamTalk :=Toy.Talk(PresentationPath+′stm125m. wav′,′S′);

        Synchronize(UpdatePresentationBar);

        PresentationNextSection := 130;

      end;
  130 :begin

        ParamTalk := Toy.Talk(PresentationPath+′stm130m.wav′,′S′);

        Synchronize(UpdatePresentationBar);

        PresentationNextSection := 135;

      end;
  135 :begin

        ParamTalk :=Toy.Talk(PresentationPath+′stm135m.wav′,′S′);

        Synchronize(UpdatePresentationBar);

        PresentationNextSection :=140:
				
				<dp n="d207"/>
     end;
 140 :begin

       ParamTalk :=Toy.Talk(PresentationPath+′stm140m.wav′,′S#′);

       Synchronize(UpdatePresentationBar);

       PresentationNextSection :=145;

     end;
 145 :begin

       ParamListen   :=Toy.Listen (′too hot/1,too cold/2,just right/3′,

                                          DTime,′SR′,′W′);

       case ParamListen of

         1: PresentationNextSection := 150;

         2: PresentationNextSection := 155;

         3: PresentationNextSection := 160;

         else PresentationNextSection := 165;

       end;

       Synchronize(UpdatePresentationBar);

     end;
 150 :begin

       ParamTalk :=Toy.Talk(PresentationPath+′stm50.wav′,′S′);

       Synchronize(UpdatePresentationBar);

      PresentationNextSection :=170;

     end;
 155 :begin

       ParamTalk :=Toy.Talk(PresentationPath+′stm155.wav′,′S′);

       Synchronize(UpdatePresentationBar);

       PresentationNextSection :=170;

     end;
 160 :begin

       ParamTalk :=Toy.Talk(PresentationPath+′stm160.wav′,′S′);

       Synchronize(UpdatePresentationBar);

       PresentationNextSection :=170;

     end;
 165 :begin

       ParamTalk :=Toy.Talk(PresentationPath+′stm165.wav′,′S′);

       Synchronize(UpdatePresentationBar);

       PresentationNextSection :=170;

     end;
				
				<dp n="d208"/>
  170 :begin

        ParamTalk :=Toy.Talk(PresentationPath+′stm170.wav′,′S#′);

       Synchronize(UpdatePresentationBar);

        PresentationNextSection :=175;

      end;
  175 :begin

        ParamListen     :=Toy. Listen (′yes/1,no/2′,DTime,′SR′,′W′);

        case ParamListen of

          1: PresentationNextSecticn :=195;

          2: PresentationNextSection :=225;

          else PresentationNextSection :=180;

        end;

        Synchronize(UpdatePresentationBar);

      end;
  180 :begin

        PeramTalk :=Toy.Talk(PresentationPath+′stm80.wav′,′S′);

        Synchronize(UpdatePresentationBar);

        PresentationNextSection :=185;

      end;
  185 :begin

        PeraamListen    :=Toy.Listen(′yes/1,no/2′,DTime,′SR′,′W′);

        case ParamListen of

          1: PresentationNextSection :=195;

          2: PresentationNextSection :=230;

          else PresentationNextSection :=230;

        end;

        Synchronize(UpdatePresentationBar);

      end;
  195 :begin

        ParamTalk :=Toy.Talk(PresentationPath+′stm195.wav′,′S′);

        Synchronize(UpdatePresentationBar);

        PresentationNextSection := 200;

      end;
  200 :begin

        ParamTalk :=Toy.Talk(PresentationPath+′stm00.wav′,′S′);

        Synchronize(UpdatePresentationBar);

        PresentationNextSection :=3000;//bunny short
				
				<dp n="d209"/>
      end;
  205 :begin

        ParamTalk :=Toy.Talk(PresentationPath+′stm205m.wav′, ′S′);

        Synchronize(UpdatePresentationBar);

        PresentationNextSection :=210;

      end;
  206 :begin

        ParamTalk := Toy.Talk(PresentationPath+′stm206m.wav′,′S#′);

        Synchronize(UpdatePresentationBar);

        PresentationNextSection :=210;

      end;
  210 :begin

        ParamListen    :=Toy.Listen (′yes/1,no/2′,DTime,′SR′,′W′);

        case ParamListen of

          1: PresentationNextSection :=2000;//bunny long

          2: PresentationNextSection :=225;

          else PresentationNextSection :=215;

        end;

        Synchronize(UpdatePresentationBar);

      end;
  215 :begin

        ParamTalk := Toy. Talk(PresentationPath+′stm215m.wav′,′S#′);

        Synchronize(UpdatePresentationBar);

        PresentationNextSection := 220;

      end;
  220 :begin

        ParamListen   :=Toy.Listen (′yes/1,no/2′,DTime,′SR′,′W′);

        case ParamListen of

          1: PresentationNextSection :=2000; //bunny long

          2: PresentationNextSection :=225;

          else PresentationNextSection :=225;

        end;

        Synchronize(UpdatePresentationBar);

      end;
  225 :begin

        ParamTalk :=Toy.Talk(PresentationPath+′stm225.wav′,′S′);

        Synchronize(UpdatePresentationBar);
				
				<dp n="d210"/>
         PresentationNextSection :=230;

       end;
   230 :begin

         ParamTalk :=Toy.Talk(PresentationPath+′stm230n.wav′,′S#′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=240;

       end;
   240 :begin

         ParamListen    :=Toy.Listen
(′game/1,song/2,storyteller/3′,DTime,′SR′,′W′);

         case ParamListen of

           1: PresentationNextSection :=800;//game menu

           2: PresentationNextSection :=300; //song menu

           3: PresentationNextSection :=5000; //theme song

           else PresentationNextSection :=245;

         end;

         Synchronize(UpdatePresentationBar);

       end;
   245 :begin

         ParamTalk :=Toy.Talk(PresentationPath+′stm245n.wav′,′S#′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=250;

       end;
   250 :begin

         ParamListen    :=Toy.Listen
 (′game/1,song/2,storyteller/3′,DTime,′SR′,′W′);

         case ParamListen of

           1: PresentationNextSection :=800; //game menu

           2: PresentationNextSection :=300; //song menu

           3: PresentationNextSection :=5000;//theme song

           else PresentationNextSection := 800;

         end;

        Synchronize(UpdatePresentationBar);

       end;
// song menu
   300 :begin

         Synchronize(UpdatePresentationBar);

         if VisitSongMenu =0 then PresentationNextSection :=320

            else
				
				<dp n="d211"/>
               begin

                 PresentationNextSection := 305;

                 if SecretName = ′BubbleGum′ then PresentationNextSection
:= 315;

                 if SecretName = ′Rainbow′   then PresentationNextSection
:= 310;

               end;

          VisitSongMenu :=VisitSongMenu +1:

        end;

  310 :begin

         ParamTalk := Toy. Talk(PresentationPath+′sng310.wav′,′S′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection := 330;

       end;
   315 :begin

         ParamTalk := Toy. Talk(PresentationPath+′sng315.wav′,′S′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=330;

      end;
  320 :begin

        ParamTalk := Toy.Talk(PresentationPath+′sng320.wav′,′S′);

        Synchronize(UpdatePresentationBar);

        PresentationNextSection :=330;

      end;
  330 :begin

        ParamTalk :=Toy.Talk(PresentationPath+′sng_prog.wav′,′S′);

        Synchronize(UpdatePresentationBar);

        PresentationNextSection :=370;

      end;
  370 :begin

        ParamTalk :=Toy.Talk(PresentationPath+′sng370.wav′,′S#′);

        Synchronize(UpdatePresentationBar);

        PresentationNextSection := 375;

      end;
  375 :begin

        ParamListen    :=Toy. Listen (′yes/1,no/2′,DTime,′SR′,′W′);

        case ParamListen  of
				
				<dp n="d212"/>
           1: PresentationNextSection :=380;

           2: PresentationNextSection :=395;

           else PresentationNextSection :=395;

         end;

         Synchronize(UpdatePresentationBar);

       end;
   380 :begin

         ParamTalk := Toy. Talk(PresentationPath+′sng380m.wav′,′S′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection := 390;

      end;
 
  390 :begin

        ParamTalk :=Toy.Talk(PresentationPath+′sng390.wav′,′S′);

        Synchronize(UpdatePresentationBar);

        PresentationNextSection :=395;

      end;
  395 :begin

        ParamTalk :=Toy.Talk(PresentationPath+′sng395.wav′,′S#′);

        Synchronize(UpdatePresentationBar);

        PresentationNextSection := 400;

      end;
  400 :begin

         ParamListen    :=Toy.Listen
(′game/1,story/2,song/3′,DTime,′SR′,′W′);

         case ParamListen of

           1: PresentationNextSection := 800; //game menu

           2: PresentationNextSection :=100; //story menu

           3: PresentationNextSection :=410;

           else PresentationNextSection :=410;

         end;

         Synchronize(UpdatePresentationBar);

       end;
   410 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′sng410m.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=415;

        end;
				
				<dp n="d213"/>
   415 :begin

         ParamTalk :=Toy.Talk(PresentationPath+′sng415n.wav′,′S#′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=420;

       end;
   420 :begin

         ParamListen    :=Toy.Listen
 (′game/1,story/2,storyteller/3′,DTime,′SR′,′W′);

         case ParamListen of

           1: PresentationNextSection :=800; //game menu

           2: PresentationNextSection :=100; //story menu

           3: PresentationNextSection :=5000; //theme song

           else PresentationNextSection :=425;

         end;

         Synchronize(UpdatePresentationBar);

       end;
   425 :begin

         ParamTalk := Toy.Talk(PresentationPath+′sng425n.wav′,′S#′);

         Synhronize (UpdatePresentationBar);

         PresentationNextSection :=430;

       end;
   430 :begin

        ParamListen   :=Toy.Listen
(′game/1,story/2,storyteller/3′,DTime,′SR′,′W′);

        case ParamListen of

          1: PresentationNextSection :=800; //game menu

          2: PresentationNextSection :=100; //story menu

          3: PresentationNextSection :=5000;//thee song

          else PresentationNextSection :=800;

        end;

        Synchronize(UpdatePresentationBar);

     end;
//StandBy
   699 :begin

         ParamListen   :=Toy.ListenActive (′continue/1,youre
on/2,theme/3′,12,′SR′,′W′);

         case ParamListen of

           1: PresentationNextSection :=LastPresentation;

           2: PresentationNextSection :=10;

           3: PresentationNextSection :=700;
				
				<dp n="d214"/>
           else PresentationNextSection :=699;

         end;

         Synchronize(UpdatePresentationBar);

       end;
   700 :begin  //Speech before theme song

         ParamTalk :=Toy.Talk(PresentationPath+′sb700.wav′,′S′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=5000;

       end;
// WakeUp
   750 :begin

         ParamTalk :=Toy.Talk(PresentationPath+′op005.wav′,′S#′);

         if ParamTalk =-2 then

         begin

           PresentationNextSection :=750;

           sleep(200);

         end

           else

           PresentationNextSection :=760;

        Synchronize(UpdatePresentationBar);

      end;
  760 :begin

        ParamListen    :=Toy. ListenActive (′yes/1,no/2′,12,′SR′,′W′);

        case ParamListen of

          1: PresentationNextSection :=LastPresentation;

          2: PresentationNextSection :=10;

          else PresentationNextSection :=LastPresentation;

        end;

        Synchronize(UpdatePresentationBar);

      end;
//Geme Menu
  800 :begin

        if VisitGameMenu=0 then PresentationNextSection :=820

           else

             begin

                PresentationNextSection :=805;

                if SecretName= ′BubbleGum′ then PresentationNextSection
:= 815;

                if SecretName= ′Rainbow′   then PresentationNextSection
:= 810;
				
				<dp n="d215"/>
           end;

       VisitGameMenu :=VisitGameMenu +1;

    end;
810 :begin

      ParamTalk :=Toy.Talk(PresentationPath+′gm810.wav′,′S′);

      Synchronize(UpdatePresentationBar);

      PresentationNextSection := 841;

    end;
815 :begin

      ParamTalk := Toy.Talk(PresentationPath+′gm815.wav′,′S′);

      Synchronize(UpdatePresentationBar);

      PresentationNextSection := 841;

    end;
820 :begin

      ParamTalk :=Toy.Talk(PresentationPath+′gm820m. wav′,′S′);

      Synchronize(UpdatePresentationBar);

     PresentationNextSection :=967;

   end;
840 :begin

      ParamTalk :=Toy.Talk(PresentationPath+′gm840.wav′,′S′);

      Synchronize(UpdatePresentationBar);

      PresentationNextSection :=841;

    end;
841 :begin

      ParamTalk :=Toy.Talk(PresentationPath+′gm841.wav′,′S′);

      Synchronize(UpdatePresentationBar);

      PresentationNextSection :=845;

    end;
845 :begin

      ParamTalk :=Toy.Talk(PresentationPath+′gm845.wav′,′S′);

      Synchronize(UpdatePresentationBar);

      PresentationNextSection :=919;

    end;
847 :begin

      ParamTalk :=Toy.Talk(PresentationPath+′gm847m.wav′,′S′);
				
				<dp n="d216"/>
       Synchronize(UpdatePresentationBar);

       PresentationNextSection :=850;

       LoopCount :=0;

     end;
 850 :begin

       //sensors :1-Nose 2-Hand 3-Foot ;0-none

       ParamListen :=Toy.Listen (″,DTime,′Sensor′,′W′);//nose

       if ParamListen=NoseSensor then PresentationNextSection :=860

          else PresentationNextSection :=855;

       Synchronize(UpdatePresentationBar);

       LoopCount :=LoopCount +1;

       if (LoopCount =3) and (PresentationNextSection =855) then

           PresentationNextSection :=860;

     end;
 855 :begin

       ParamTalk :=Toy.Talk(PresentationPath+′gm855m.wav′,′S′);

       Synchronize(UpdatePresentationBer);

       PresentationNextSection :=850;

     end;
 860 :begin

       ParamTalk :=Toy.Talk(PresentationPath+′gm860.wav′,′S′);

       Synchronize(UpdatePresentationBar);

       PresentationNextSection :=865;

     end;
 865 :begin

       ParamTalk := Toy. Talk(PresentationPath+′qm865m.wav′,′S′);

       Synchronize(UpdatePresentationBar);

       PresentationNextSection :=870;

       LoopCount :=0;

     end;
 870 :begin

       //sensors :1-Nose 2-Hand 3-Foot ; 0-none

       ParamListen := Toy.Listeh (′′,DTime,′Sensor′,′W′);//foot

       if ParamListen =FootSensor then PresentationNextSection :=890

          else PresentationNextSection :=875;

       Synchronize(UpdatePresentationBar);

       LoopCount :=LoopCount +1;

       if (LoopCount =3) and (PresentationNextSection =875) then
				
				<dp n="d217"/>
             PresentationNextSection := 890;

     end;
 875 :begin

       ParamTalk :=Toy.Talk(PresentationPath+′gm875m.wav′,′S′);

       Synchronize(UpdatePresentationBar);

       PresentationNextSection :=870;

     end;
 890 :begin

       ParamTalk :=Toy.Talk(PresentationPath+′gm890.wav′,′S′);

       Synchronize(UpdatePresentationBar);

       PresentationNextSection :=895;

     end;
 895 :begin

       ParamTalk :=Toy.Talk(PresentationPath+′gm895.wav′,′S′);

       Synchronize(UpdatePresentationBar);

       PresentationNextSection :=900;

       LoopCount :=0;

     end;
 900 :begin

       //sensors :1-Nose 2-Hand 3-Foot ;0-none

       ParamListen :=Toy.Listen (″,DTime,′Sensor′,′W′);//hand

      if ParamListen=HandSensor then PresentationNextSection :=910

          else PresentationNextSection :=905;

       Synchronize(UpdatePresentationBar);

       LoopCount :=LoopCount +1;

       if (LoopCount =3) and (PresentationNextSection =905) then

           PresentationNextSection :=910;

     end;
 905 :begin

       ParamTalk :=Toy.Talk(PresentationPath+′gm905m.wav′,′S′);

       Synchronize(UpdatePresentationBar);

       PresentationNextSection := 900;

     end;
 910 :begin

       ParamTalk :=Toy.Talk(PresentationPath+′gm910.wav′,′S′);

       Synchronize(UpdatePresentationBar);

       PresentationNextSection :=915;
				
				<dp n="d218"/>
       end;
   915 :begin

         ParamTalk :=Toy.Talk(PresentationPath+′gm915.wav′,′S′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=920;

         Sensor1:=0;

         Sensor2  :=0;

         Sensor3  :=0;

         LoopCount :=0;

       end;
   919 :begin

         PresentationNextSection :=920;

         Sensor1 :=0;

         Sensor2 :=0;

         Sensor3  :=0;

         LoopCount :=0;

       end;
   920 :begin

         //sensors :1-Nose 2-Hand 3-Foot ;0-none

         LoopCount :=LoopCount+1;

         if (Sensor1 =HandSensor) and (Sensor2 =NoseSensor) and (Sensor3
=FootSensor)  then

              PresentationNextSection :=926 //success

          else

              begin

                PresentationNextSection :=920; //looping

                if LoopCount > 5 then // pressing not right

                   begin

                      PresentationNextSection :=924; //timeout

                      if (Sensor1 > 0) or (Sensor2 >0) or (Sensor3 >0)
then

                          PresentationNextSection :=925;//press not right

                   end

                else

                   begin

                     GetSensor    :=Toy.Listen (″,DTime,′Sensor′,′W′);

                     if GetSensor > 0 then

                       begin

                          if GetSensor =NoseSensor then
PresentationNextSection :=921; //nose
				
				<dp n="d219"/>
                          if GetSensor=HandSensor then
PresentationNextSection :=923; //hand

                          if GetSensor=FootSensor then
PresentationNextSection :=922;//foot

                          Sensor1 :=Sensor2;

                          Sensor2 :=Sensor3;

                          Sensor3 :=GetSensor;

                       end;

                      if  (Sensor1=0) and (Sensor2=0) and (Sensor3=0)
//timeout

                          and (LoopCount=3) then
PresentationNextSection :=925;

                  end;

              end;

         end;

   921 :begin

           ParamTalk :=Toy.Talk(PresentationPath+′gm921.wav′,′S′);

           Synchronize(UpdatePresentationBar);

           PresentationNextSection :=920;

         end;

   922 :begin

           ParamTalk :=Toy.Talk(PresentationPath+′gm922.wav′,′S′);

           Synchronize(UpdatePresentationBar);

           PresentationNextSection :=920;

         end;

   923 :begin

           ParamTalk :=Toy.Talk(PresentationPath+′gm923.wav′,′S′);

           Synchronize(UpdatePresentationBar);

           PresentationNextSection :=920;

         end;

   925 :begin

           ParamTalk :=Toy.Talk(PresentationPath+′gm925.wav′,′S′);

          Synchronize(UpdatePresentationBar);

            PresentationNextSection :=927;

              end;

   926 :begin

           ParamTalk :=Toy.Talk(PresentationPath+′gm926m.wav′,′S′);

           Synchronize(UpdacePresentationBar);
				
				<dp n="d220"/>
          PresentationNextSection :=1006;

       end;
   927 :begin

         //sensors :1-Nose 2-Hand 3-Foot ;0-none

         PresentationNextSection :=928;

         Sensor1 :=Toy.Listen (″,7,′Sensor′,′W′);

         if Sensor1=HandSensor then
Toy.Talk(PresentationPath+′gm910.wav′,′S′);

         if Sensor1=NoseSensor then
Toy.Talk(PresentationPath+′gm860.wav′,′S′);

         if Sensor1=FootSensor then
Toy.Talk(PresentationPath+′gm890.wav′,′S′);

         Sensor2 :=Toy.Listen (″,7,′Sensor′,′W′);

         if Sensor2=HandSensor then
Toy.Talk(PresentationPath+′gm910.wav′,′S′);

         if Sensor2=NoseSensor then
Toy.Talk(PresentationPath+′gm860.wav′,′S′);

         if Sensor2=FootSensor then
Toy.Talk(PresentationPath+′gm890.wav′,′S′);

         Sensor3  :=Toy.Listen (″,7,′Sensor′,′W′);

         if Sensor3=HandSensor then
Toy.Talk(PresentationPath+′gm910.wav′,′S′);

         if Sensor3=NoseSensor then
Toy.Talk(PresentationPath+′gm860.wav′,′S′);

        if Sensor3=FootSensor then
Toy.Talk(PresentationPath+′gm890.wav′,′S′);

         if (Sensor1=HandSensor) and (Sensor2=NoseSensor) and (Sensor3
= FootSensor)

             then PresentationNextSection :=926

             else PresentationNextSection :=928;

        end;

  928 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′gm928.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=1005;

        end;

  932 :begin

         ParamTalk :=Toy.Talk(PresentationPath+′gm932.wav′,′S#′);

          Synchronize(UpdatePresentationBar);
				
				<dp n="d221"/>
          PresentationNextSection :=936;

        end;

  933 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′gm933n.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=1006;

        end;

  936 :begin

          ParamListen   :=Toy.Listen(′yes/1,no/2′,DTime,′SR′,′W′);

          case ParamListen of

            1: PresentationNextSection :=840;

            2: PresentationNextSection :=940;

            else PresentationNextSection :=940;

          end;

          Synchronize(UpdatePresentationBar);

        end; 

  940 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′gm940n.wav′,′S#′);

         Synchronize(UPdatePresentationBar);

          PresentationNextSection :=941;

          LoopCount :=0;

        end;

  941 :begin

          ParamListen    :=Toy.Listen
(′story/1,song/2,storyteller/3′,DTime,′SR′,′W′);

          case ParamListen of

            1: PresentationNextSection :=100;//story menu

            2: PresentationNextSection :=300;//song menu

            3: PresentationNextSection :=300;//theme song

            else PresentationNextSection :=945;

          end;

          Synchronize(UpdatePresentationBar);

          LoopCount :=LoopCount+1;

          if (LoopCount=3) and (PresentationNextSection=945) then

              PresentationNextSection :=100;

        end;

  945 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′gm940n.wav′,′S#′);
				
				<dp n="d222"/>
          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=941;

        end;

  965 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′gm965m.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=970;

        end;

  967 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′gm967.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=970;

        end;

 970 :begin
          ParamTalk :=Toy.Talk(PresentationPath+′gm970.wav′,′S#′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=971;

          LoopCount :=0;

        end;

  971 :begin

          ParamListen    :=Toy.Listen (′lollipop/1,peanut
butter/2′,7,′SR′,′W′);

          case ParamListen of

            1: PresentationNextSection :=975;

            2: PresentationNextSection :=980;

            else PresentationNextSection :=972;

          end;

          LoopCount :=LoopCount +1;

          if (LoopCount=3) and (PresentationNextSection=972) then

              PresentationNextSection :=984;

          Synchronize(UpdatePresentationBar);

        end;

  972 :begin

         ParamTalk :=Toy.Talk(PresentationPath+′gm972.wav′,′S#′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=971;

        end;
				
				<dp n="d223"/>
  975 :begin

        ParamTalk :=Toy.Talk(PresentationPath+′gm975.wav′,′S′);

        Synchronize(UpdatePresentationBar);

        PresentationNextSection :=984;

      end;
  980 :begin

        ParamTalk :=Toy.Talk(PresentationPath+′gm980.wav′,′S′);

        Synchronize(UpdatePresentationBar);

        PresentationNextSection :=984;

      end;
  984 :begin

        ParamTalk :=Toy.Talk(PresentationPath+′gm984.wav′,′S′);

        Synchronize(UpdatePresentationBar);

        PresentationNextSection :=983;

        LoopCount :=0;

      end;
  983 :begin

        ParamListen   :=Toy.Listen (′rabbit/1,bear/2′,DTime,′SR′,′W′);

        case ParamListen of

          1: PresentationNextSection :=985;

          2: PresentationNextSection :=990;

          else PresentationNextSection :=982;

        end;

        LoopCount :=LoopCount +1;

        if (LoopCount=3) and (PresentationNextSection=982) then

           PresentationNextSection := 005;

        Synchronize(UpdatePresentationBar);

      end;
  982 :begin

        ParamTalk :=Toy.Talk(PresentationPath+′gm982.wav′,′S#′);

        Synchronize(UpdatePresentationBar);

        PresentationNextSection :=983;

      end;
  985 :begin

        ParamTalk :=Toy.Talk(PresentationPath+′gm985m.wav′,′S′);

        Synchronize(UpdatePresentationBar);

        PresentationNextSection :=932;

      end;
				
				<dp n="d224"/>
   990 :begin

         ParamTalk :=Toy.Talk(PresentationPath+′gm990.wav′,′S′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=932;

         if  MainForm. ToyMachine = ′TeddyBear′ then
PresentationNextSection :=1005;

       end;
  1005 :begin

        ParamTalk :=Toy.Talk(PresentationPath+′gm1005.wav′,′S′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=1006;

       end;
  1006 :begin

         ParamTalk :=Toy.Talk(PresentationPath+′gm1006.wav′,′S#′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=998;

         LoopCount :=0;

       end;
   998 :begin

         ParamListen   :=Toy.Listen
(′story/1,song/2,storyteller/3′,DTime,′SR′,′W′);

         case ParamListen of

           1: PresentationNextSection :=100;//story menu

           2: PresentationNextSection :=300;//song menu

           3: PresentationNextSection :=5000;//theme song

           else PresentationNextSection :=997;

         end;

         LoopCount :=LoopCount+1;

         if (LoopCount=3) and (PresentationNextSection=997) then

            PresentationNextSection :=100;

         Synchronize(UpdatePresentationBar);

       end;
   997 :begin

         ParamTalk :=Toy.Talk(PresentationPath+′gm997.wav′,′S#′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=998;

       end:
				
				<dp n="d225"/>
  //  Bunny  Long     =============================
  2000 :begin

         Synchronize(UpdatePresentationBar);

         VisitBunnyLong :=VisitBunnyLong + 1;

         PresentationNextSection :=2280;

       end;
  2280 :begin

         ParamTalk :=Toy.Talk(PresentationPath+′rb280m.wav′,′E′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=2285;

       end;
  2285 :begin

         ParamTalk :=Toy.Talk(PresentationPath+′rb286.wav′,′S′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=2286;

       end;
  2286 :begin

         ParamTalk :=Toy. Talk(PresentationPath+′rb287.wav′,′S′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=2290;

       end;
  2290 :begin

         WaveSection :=′rb2901′;

         if BunnyFavoriteFood = ′Honey′         then WaveSection :=′rb2901′;

         if BunnyFavoriteFood = ′Peanut′        then WaveSection :=′rb2902′;

         if BunnyFavoriteFood = ′Marshmallow′   then WaveSection :=′rb2903′;

         ParamTalk :=Toy.Talk(PresentationPath+WaveSection+′.wav′,′S′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=2295;

       end;
  2295 :begin

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=2296;

       end;
  2296 :begin

         WaveSection  :=′rb2961′;

         if SecretName= ′BubbleGum′then WaveSection  :=′rb2961N′;
				
				<dp n="d226"/>
          if SecretName =′Ace′       then WaveSection :=′rb2962N′;

          if SecretName =′RainBow′   then WaveSection :=′rb2963N′;

          ParamTalk := Toy. Talk(PresentationPath+WaveSection+′,wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=2300;

        end;
   2297 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb297m.wav′,′E′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=2300;

        end;
   2300 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb300.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=2305;

        end;
   2305 :begin

          WaveSection :=′rb3051′;

          if BunnyFavoriteFood = ′Honey′         then WaveSection :=′rb3051′;

          if BunnyFavoriteFood = ′Peanut′        then WaveSection :=′rb3052′;

          if BunnyFavoriteFood = ′Marshmallow′   then WaveSection :=′rb3053′;

          ParamTalk :=Toy.Talk(PresentationPath+WaveSection+′.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=2315;

        end;
   2315 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb315.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=2320;

        end;
  2316 :begin

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=2320;

       end;
  2320 :begin

         ParamTalk :=Toy.Talk(PresentationPath+′rb320.wav′,′S′);

         Synchronize(UpdatePresentationBar);
				
				<dp n="d227"/>
          PresentationNextSection :=2330;

        end;
   2330 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb330.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=2335;

        end;
   2335 :begin

                                                                                                                 

           ParamTalk :=Toy.Talk(PresentationPath+′rb336.wav′,′S′);

           Synchronize(UpdatePresentationBar);

           PresentationNextSection :=2336;

        end;
   2336 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb337.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=2344;

        end;
   2344 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb343.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=2345;

        end;
   2345 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb344.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=2346;

        end;
   2346 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb346m.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=2350;

        end;
   2350 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb351.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection := 351;
				
				<dp n="d228"/>
        end;
   2351 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb352.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=2355;

        end;
   2355 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb356.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=2356;

        end;
   2356 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb357.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=2360;

        end;
   2360 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb360.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=2365;

        end;
   2365 :begin

          //sensors :  1-Nose 2-Hand 3-Foot ;0-none

          ParamListen :=Toy.Listen (″,DTime,′Sensor′, ′W′);

          case ParamListen of

          NoseSensor:   PresentationNextSection :=2375;

          HandSensor:   PresentationNextSection :=2370;

          FootSensor:   PresentationNextSection :=2375;

          else

               PresentationNextSection :=2385;

          end;

          Synchronize(UpdatePresentationBar);

        end;
   2370 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb370.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection  :=2380;
				
				<dp n="d229"/>
        end;
   2375 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb375.wav′, ′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=2365;

        end;
   2380 :begin

          //sensors :1-Nose 2-Hand 3-Foot ;0-none

          ParamListen :=Toy.Listen (″,DTime,′Sensor′,′W′);

          case ParamListen of

          NoseSensor:   PresentationNextSection :=2385;

          HandSensor:   PresentationNextSection :=2382;

          FootSensor:   PresentationNextSection :=2385;

          else

              PresentationNextSection :=2385;

          end;

          Synchronize(UpdatePresentationBar);

        end;
   2382 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb382.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=2385;

        end;
   2385 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb385.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=2386;

        end;
   2386 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb386.wav′,′E′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=2390;

        end;
   2390 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb390.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=2395;
				
				<dp n="d230"/>
        end;
   2395 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb395m.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=2410;

        end;
   2400 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb400m.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=2410;

        end;
   2405 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb405m. wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=2410;

        end;
   2410 :begin

          ParamTalk :=Toy. Talk(PresentationPath+′rb410m. wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection := 2415;

        end;
   2415 :begin

          WaveSection  :=′rb4151m′;

          if BunnyFavoriteFood = ′Honey′         then WaveSection
:=′rb4151m′;

          if BunnyFavoriteFood = ′Peanut′        then WaveSection
:=′rb4152m′;

          if BunnyFavoriteFood = ′Marshmallow′   then WaveSection
:=′rb4153m′;

          ParamTalk :=Toy.Talk(PresentationPath+WaveSection+′.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=2420;

        end;
   2420 :begin

          WaveSection  :=′rb4201′;

          if BunnyFavoriteFood = ′Honey′         then WaveSection :=′rb4201′;

          if BunnyFavoriteFood = ′Peanut′        then WaveSection :=′rb4202′;
				
				<dp n="d231"/>
        if BunnyFavoriteFood = ′Marshmallow′then WaveSection :=′rb4203′;

         ParamTalk :=Toy.Talk(PresentationPath+WaveSection+′.wav′,′S′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=2425;

       end;
  2425 :begin

         ParamTalk :=Toy.Talk(PresentationPath+′rb425m.wav′,′S′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=2426;

       end;
  2426 :begin

         ParamTalk :=Toy.Talk(PresentationPath+′rb426m.wav′,′EL′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=2435;

       end;
  2435 :begin

         ParamTalk :=Toy.Talk(PresentationPath+′rb435m.wav′,′S′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=2440;

       end;
  2440 :begin

         ParamTalk :=Toy.Talk(PresentationPath+′rb440.wav′,′S′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=2445;

       end;
  2445 :begin

         ParamTalk :=Toy.Talk(PresentationPath+′rb445m.wav′,′S′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=245;

       end;
// End of Bunny Long ==============================
// Bunny Short   ===============================
  3000 :begin

         Synchronize(UpdatePresentationBar);

         VisitBunnyShort :=VisitBunnyShort+1;

         PresentationNextSection :=3005;

       end;

                                                                 
				
				<dp n="d232"/>
  3005 :begin

           ParamTalk :=Toy.Talk(PresentationPath+′rb3005m.wav′,′E′);

           Synchronize(UpdatePresentationBar);

           PresentationNextSection :=3010;

         end;

  3010 :begin

           ParamTalk :=Toy. Talk(PresentationPath+′rb005m.wav′,′S′);

           Synchronize(UpdatePresentationBar);

           PresentationNextSection :=3015;

         end;

  3015 :begin

           ParamListen    :=Toy.Listen(′honey/1,peanut butter/2,marshmallow
fluff/3′,7,′SR′,′W′);

           case ParamListen of

             1: PresentationNextSection :=3035;

             2: PresentationNextSection :=3040;

             3: PresentationNextSection :=3045;

             else PresentationNextSection :=3020;

           end;

           Synchronize(UpdatePresentationBar);

         end;

  3020 :begin

           ParamTalk :=Toy.Talk(PresentationPath+′rb015.wav′,′S#′);

           Synchronize(UpdatePresentationBar);

           PresentationNextSection :=3025;

         end;

  3025 :begin

           ParanmListen    :=Toy.Listen (′honey/1,peanut butter/2,marshmallow
fluff/3′,DTime,′SR′,′W′);

           case ParamListen of

             1: PresentationNextSection :=3035;

             2: PresentationNextSection :=3040;

             3: PresentationNextSection :=3045;

             else PresentationNextSection :=3030;

           end;

           Synchronize(UpdatePresentationBar);

        end;
				
				<dp n="d233"/>
  3030 :begin

           BunnyFavoriteFood := ′Honey′;

           ParamTalk :=Toy.Talk(PresentationPath+′rb026.wav′,′S′);

           Synchronize(UpdatePresentationBar);

           PresentationNextSection :=3035;

         end;

  3035 :begin

           BunnyFavoriteFood := ′Honey′;

           ParamTalk := Toy. Talk(PresentationPath+′rb0301.wav′,′S′);

           Synchronize(UpdatePresentationBar);

           PresentationNextSection := 3050;

         end;

  3040 :begin

           BunnyFavoriteFood :=  ′Peanut′;

           ParamTalk :=Toy.Talk(PresentationPath+′rb0302.wav′,′S′);

           Synchronize(UpdatePresentationBar);

           PresentationNextSection :=3050;

         end;

  3045 :begin

           BunnyFavoriteFood := ′Marshmallow′;

           ParamTalk :=Toy.Talk(PresentationPath+′rb0303.wav′,′S′);

           Synchronize(UpdatePresentationBar);

           PresentationNextSection :=3050;

         end;

  3050 :begin

           ParamTalk :=Toy.Talk(PresentationPath+′rb3050m.wav′,′S′);

           PresentationNextSection :=3055;

           if BunnyFavoriteFood = ′Honey′       then PresentationNextSection
:=3055;

           if BunnyFavoriteFood = ′Peanut′      then PresentationNextSection
:=3060;

           if BunnyFavoriteFood = ′Marshmallow′ then PresentationNextSection
:=3065;

           Synchronize(UpdatePresentationBar);

         end;

  3055 :begin

           ParamTalk :=Toy.Talk(PresentationPath+′rb3055.wav′,′S′);

           Synchronize(UpdatePresentationBar);
				
				<dp n="d234"/>
          PresentationNextSection :=3075;

        end;
   3060 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb3060.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=3075;

        end;
   3065 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb3065.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=3075;

        end;
   3075 :begin

          ParamTalk := Toy.Talk(PresentationPath+′rb3075n.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=3080;

        end;
   3080 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb110.wav′,′S#′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=3085;

        end;
   3085 :begin

          ParamListen    :=Toy.Listen
(′giraffe/1,elephant/2,bunny/3′,7,′SR′,′W′);

          case ParamListen of

            1:  PresentationNextSection :=3095;

            2:  PresentationNextSection :=3090;

            3:  PresentationNextSection :=3100;

            else PresentationNextSection :=3100;

          end;

          Synchronize(UpdatePresentationBar);

        end;
   3090 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb120.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=3125;
				
				<dp n="d235"/>
     end;
3095 :begin

       ParamTalk :=Toy.Talk(PresentationPath+′rb125.wav′,′S′);

       Synchronize(UpdatePresentationBar);

       PresentationNextSection :=3125;

     end;
3100 :begin

       ParamTalk :=Toy.Talk(PresentationPath+′rb130.wav′,′S′);

       Synchronize(UpdatePresentationBar);

       PresentationNextSection :=3125;

     end;
3125 :begin

       ParamTalk :=Toy.Talk(PresentationPath+′rb220n.wav′,′S′);

       Synchronize(UpdatePresentationBar);

       PresentationNextSection :=3135;

     end;
3135 :begin

       ParamTalk :=Toy.Talk(PresentationPath+′rb231m. wav′,′EL′);

       Synchronize(UpdatePresentationBar);

       PresentationNextSection :=3140;

     end;
3140 :begin

       ParamTalk :=Toy.Talk(PresentationPath+′rb235n.wav′,′S#′);

       Synchronize(UpdatePresentationBar);

       PresentationNextSection :=3145;

     end;
3145 :begin

       ParamListen    :=Toy.Listen (′bunnythree/1′,DTime,′SR′,′W′);

       case ParamListen of

         1: PresentationNextSection :=3150;

         else PresentationNextSection :=3155;

       end;

       Synchronize(UpdatePresentationBar);

     end;
3150 :begin

       ParamTalk :=Toy.Talk(PresentationPath+′rb245.wav′,′S′);
				
				<dp n="d236"/>
            PresentationNextSection :=3160;

            if BunnyFavoriteFood = ′Honey′         then PresentationNextSection
  := 3160;

            if BunnyFavoriteFood = ′Peanut′        then PresentationNextSeotion
  := 3165;

            if BunnyFavoriteFood = ′Marshmallow′   then PresentationNextSection
  := 3170;

            Synchronize(UpdatePresentationBar);

          end;

   3155 :begin

            ParamTalk :=Toy.Talk(PresentationPath+′rb3155.wav′,′S′);

            PresentationNextSection := 3160;

            if BunnyFavoriteFood = ′Honey′       then PresentationNextSection
 := 3160;

            if BunnyFavoriteFood = ′Peanut′      then PresentationNextSection
 := 3165;

            if BunnyFavoriteFood = ′Marshmallow′ then PresentationNextSection
:= 3170;

            Synchronize(UpdatePresentationBar);

          end;

   3160 :begin

            ParamTalk :=Toy.Talk(PresentationPath+′rb3160.wav′,′S′);

            Synchronize(UpdatePresentationBar);

            PresentationNextSection :=3180;

          end;

   3165 :begin

            ParamTalk :=Toy.Talk(PresentationPath+′rb3165.wav′,′S′);

            Synchronize(UpdatePresentationBar);

            PresentationNextSection :=3185;

          end;

   3170 :begin

            ParamTalk :=Toy.Talk(PresentationPath+′rb3170.wav′,′S′);

            Synchronize(UpdatePresentationBar);

            PresentationNextSection :=3190;

          end;

   3180 :begin

            ParamTalk :=Toy.Talk(PresentationPath+′rb2751.wav′,′S′);

            Synchronize(UpdatePresentationBar);
				
				<dp n="d237"/>
          PresentationNextSection := 3195;

        end;
   3185 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb2752.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=3195;

        end;
   3190 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb2753.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=3195;

        end;
   3195 :begin

          ParamTalk :=Toy.Talk(PresentationPath+′rb280m.wav′,′E′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=205;

        end;
// End of Bunny Short =============================
// Princess and The Pea    =============== ===========      
   4000 :begin

          VisitPrincess :=Visitprincess+1;

          PresentationNextSection  :=-1;

          PrincessNextSection      :=1;

        end;
   4010 :begin

          PresentationNextSection :=699;    //go back from princess

        end;
// End of Princess and The Pea  ========================
// Theme Song   ================================
   5000 :begin

          PresentationNextSection :=5010;

        end;
   5010 :begin

          ParamTalk :=Toy.TalkAll(Path+′StoryTeller.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=5020;
				
				<dp n="d238"/>
           end;

  5020 :begin

           //ParamTalk :=Toy.Talk(Path+′Alonel.wav′,′S′);

           Synchronize(UpdatePresentationBar);

           PresentationNextSection :=5030;

         end;

  5030 :begin

           //ParamTalk :=Toy.TalkAll(Path+′All.wav′,′S′);

           Synchronize(UpdatePresentationBar);

           PresentationNextSection :=5040;

        end;
   5040 :begin

                                                    

          //ParamTalk :=Toy.Talk(Path+′Alone2.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=5050;

        end;
   5050 :begin

          //ParamTalk :=Toy.TalkAll(Path+′All.wav′,′S′);

          Synchronize(UpdatePresentationBar);

          PresentationNextSection :=5060;

        end;
  5060 :begin

         //ParamTalk := Toy. Talk(Path+′Alone3.wav′,′S′);

         Synchronize(UpdatePresentationBar);

         PresentationNextSection :=45;

         if SecretName = ′BubbleGum′  then PresentationNextSection :=50;

         if SecretName = ′Ace′        then PresentationNextSection :=40;

         if SecretName = ′Rainbow′    then PresentationNextSection :=45;

      end;
// End of Theme Song =============== =============
//PAUSE
10000 :begin

        PresentationNextSection :=10000;

        sleep(200);

      end;
 end://End of Presentation
				
				<dp n="d239"/>
  if (PresentationNextSection <> 699) and (PresentationNextSection <>
10000)

     and (PresentationNextSection <> 760) and (PresentationNextSection <>
750)then

     LastPresentation :=PresentationNextSection;
{*
//========  I  N  T  R  O   ====================
//------------write here all sessions---------------------------------------
//=====================================

  case IntroNextSection of

   1 :begin

         //Toy. Wait(12,′W′);

         {sleep(300);

          ParamTalk    :=Toy.Talk  (IntroPath+′in001.wav′,′E′);

          ParamListen :=Toy.Listen (′yes/1,no,2′,1.5,′SR and Sensor′);

          StatusForm.StatusGauge. Progress :=IntroNextSection/4.5;  }

          IntroNextSection := 5;

        end;

    2 :begin

          {ParamTalk    :=Toy.Talk    (IntroPath+′in01a.wav′,′E′);

          Synchronize(UpdateIntroBar);

          IntroNextSection :=3;}

        end;

    3 :begin

          {ParamTalk    :=Toy.Talk    (IntroPath+′in01b.wav′,′EL′);

          Synchronize(UpdateIntroBar);

          IntroNextSection :=5;}

        end;

    4 :begin

          {sleep(300);

          Synchronize(UpdateIntroBar);

          IntroNextSection :=5;}

        end;

    5 :begin

          ParamTalk    :=Toy.Talk    (IntroPath+′in01.wav′,′S′);

          Synchronize(UpdateIntroBar);

          IntroNextSection :=10;
				
				<dp n="d240"/>
     end;
 6 :begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection :=7;}

   end;
 7 :begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection :=8;}

   end;
 8 :begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection :=9;}

   end;
 9 :begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection :=10;}

   end;
10:begin

    ParamTalk    :=Toy.Talk    (IntroPath+′in02m.wav′,′SP1′);

    Synchronize(UpdateIntroBar);

    IntroNextSection :=21;

    if SecretName = ′Bubble gum′  then IntroNextSection :=21;

    if SecretName = ′Ace′         then IntroNextSection :=22;

    if SecretName = ′Rainbow′     then IntroNextSection :=23;

  end;
11:begin

    {sleep(300);

    Synchronize(UpdateIntroBar);

    IntroNextSection :=12;}

  end;
12:begin

    {sleep(300);
				
				<dp n="d241"/>
     Synchronize(UpdateIntroBar);

     IntroNextSection := 13;}

   end;
 13:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 14;}

   end;
 14:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 15;}

   end;
 15:begin

     {ParamTalk    :=Toy.Talk    (IntroPath+′in02b.wav′,′S′);

     Synchronize(UpdateIntroBar) ;

     IntroNextSection := 16;}

   end;
 16:begin

     {ParamTalk    :=Toy.Talk    (IntroPath+′in02c.wav′,′E′);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 20;}

   end;
 17:begin

     {ParamTalk    :=Toy.Talk    (IntroPath+′in02c.wav′,′E′);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 18;}

   end;
 18:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection :=19;}

   end;
19:begin

    {sleep(300);

    Synchronize(UpdateIntroBar);
				
				<dp n="d242"/>
     IntroNextSection := 20;)

   end;
 20:begin

     {ParamTalk    :=Toy.Talk    (IntroPath+′in02.wav′,′S′);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 21;

     if SecretName = ′Bubble gum′   then IntroNextSection := 21;

     if SecretName = ′Ace′          then IntroNextSection := 22;

     if SecretName = ′Rainbow′      then IntroNextSection := 23;}

   end;
 21:begin

     ParamTalk    := Toy. Talk    ( IntroPath+ ′in03 . way′, ′ S ′ );

     Synchronize(UpdateIntroBar);

     IntroNextSection := 30;

   end;
 22:begin

     ParamTalk    :=Toy.Talk     (IntroPath+′in03a.wav′,′S′);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 30;

   end;
 23:begin

     ParamTalk    :=Toy.Talk    (IntroPath+′in03b.wav′,′S′);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 30;

   end;
 24:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 25;}

   end;
 25:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 26;}

   end;
 26:begin
				
				<dp n="d243"/>
     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 27;}

   end;
 27:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 28;}

   end;
 28:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 29;}

   end;
 29:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 30;}

   end;
 30:begin

     ParamTalk    :=Toy.Talk    (IntroPath+′in04.wav′,′S′);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 35;

   end;
 31:begin

     {ParamTalk    :=Toy.Talk   (IntroPath+′in04a.wav′,′EL′);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 35;}

   end;
 32:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 33;}

   end;

 33:begin

     {sleep(300);
				
				<dp n="d244"/>
     Synchronize(UpdateIntroBar);

     IntroNextSection := 34;}

   end;
 34:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 35;}

   end;
 35:begin

     ParamTalk    :=Toy.Talk    (IntroPath+′in05m.wav′,′SP2′);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 45;

   end;
 36:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 37;}

   end;
 37:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 38;}

   end;
 38:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 39;}

   end;
 39:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 40;}

   end;
 40:begin

     {ParamTalk    := Toy.Talk    (IntroPath+′in05.wav′,′S′);

     Synchronize(UpdateIntroBar);
				
				<dp n="d245"/>
     IntroNextSection := 45;}

   end;
 41:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 42;}

   end;
 42:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 43;}

   end;
 43:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 44;}

   end;
 44:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 45;}

   end;
 45:begin

     ParamTalk    :=Toy.Talk    (IntroPath+′in06.wav′,′S′);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 50;

   end;
 46:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 47;}

     end;
 47:begin

       {sleep(300);

       Synchronize(UpdateIntroBar);

       IntroNextSection := 48;}
				
				<dp n="d246"/>
   end;
 48:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 49;}

   end;
 49:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 50;}

   end;
 50:begin

     ParamTalk    :=Toy.Talk    (IntroPath+′in07.wav′,′S′);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 55;

   end;
 51:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 52;}

   end;
 52:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 53;}

   end;
 53:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 54;}

   end;
 54:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection  := 55;}

   end;
				
				<dp n="d247"/>
 55:begin

     ParamListen :=Toy.Wait(12,′W′);

     if ParamListen = 1 then  IntroNextSection := 60

     else  IntroNextSection := 65;

     Synchronize(UpdateIntroBar);

   end;
 56:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 57;}

   end;
 57:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 58;}

   end;
 58:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 59;}

   end;
 59:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 60;}

   end;
 60:begin

     ParamTalk    :=Toy.Talk    (IntroPath+′in09.wav′,′S′);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 67;

   end;
 61:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 62;}

   end;
				
				<dp n="d248"/>
 62:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 63;}

   end;
 63:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 64;}

   end;
 64:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 65;}

     end;
 65:begin

     ParamTalk    :=Toy.Talk    (IntroPath+′in10.wav′,′S′);

     if ParamTalk = 1 then IntroNextSection := 60

        else  IntroNextSection := 66;

     Synchronize(UpdateIntroBar);

   end;
 66:begin

     ParamListen :=Toy.Wait(12,′W′);

     if ParamListen = 1 then IntroNextSection := 60

        else IntroNextSection := 67;

     Synchronize(UpdateIntroBar);

   end;
 67:begin

      ParamTalk    :=Toy.Talk    (IntroPath+′******.wav′,′S′);

      Synchronize(UpdateIntroBar);

      IntroNextSection := 70;

    end;
 68:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 69;}
				
				<dp n="d249"/>
     end;
 69:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 70;}

   end;
 70:begin

     ParamTalk    :=Toy.Talk    (IntroPath+′in10b.wav′,′S′);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 71;

     if SecretName = ′Bubble gum′then IntroNextSection := 71;

     if SecretName = ′Ace′       then IntroNextSection := 72;

     if SecretName = ′Rainbow′   then IntroNextSection := 73;

   end;
 71:begin

     ParamTalk    :=Toy.Talk    (IntroPath+′in11.wav′,′S′);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 80;

   end;
 72:begin

     ParamTalk    :=Toy.Talk    (IntroPath+′in11a.wav′,′S′);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 80;

   end;
 73:begin

     ParamTalk    :=Toy.Talk    (IntroPath+′in11b.wav′,′S′);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 80;

   end;
 74:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 75;}

   end;
 75:begin

     {sleep(300);
				
				<dp n="d250"/>
     Synchronize(UpdateIntroBar);

     IntroNextSection  := 76;}

   end;
 76:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 77;}

   end;
 77:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 78;}

   end;
 78:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 79;}

   end;
 79:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 80;}

   end;
 80:begin

     ParamTalk    :=Toy.Talk    (IntroPath+′in11m.wav′,′S′);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 85;

   end;
 81:begin

     {ParamTalk    :=Toy.Talk   (IntroPath+′in12.wav′,′S′);

     Synchronize(UpdateIntroBar);

     IntroNextSection := 85;}

   end;
 82:begin

     {sleep(300);

     Synchronize(UpdateIntroBar);
				
				<dp n="d251"/>
    IntroNextSection := 83;}

  end;
83:begin
    {sleep(300);

    Synchronize(UpdateIntroBar);

    IntroNextSection := 84;}

  end;
84:begin

    {sleep(300);

    Synchronize(UpdateIntroBar);

    IntroNextSection := 85;}

  end;
85:begin

    ParamTalk    :=Toy.Talk    (IntroPath+′in12.wav′,′EL′

    Synchronize(UpdateIntroBar);

    IntroNextSection := 86;

  end;
86:begin

    ParamTalk    :=Toy.Talk    (IntroPath+′in12b.wav′,′S′);

    Synchronize(UpdateIntroBar);

    IntroNextSection := 90;

  end;
87:begin

    {sleep(300);

    Synchronize(UpdateIntroBar);

    IntroNextSection := 88;}

  end;
88:begin

    {sleep(300);
    Synchronize(UpdateIntroBar);

    IntroNextSection := 89;}

  end;
89:begin

    {sleep(300);

    Synchronize(UpdateIntroBar);

    IntroNextSection := 90;}
				
				<dp n="d252"/>
       end;

   90:begin

         ParamTalk    :=Toy.Talk    (IntroPath+′in13.wav′,′S′);

         Synchronize(UpdateIntroBar);

         IntroNextSection := 95;

       end;

   95:begin

         ParamTalk    :=Toy.Talk    (IntroPath+′in13a.wav′,′S′);
//randomize WAVE

         Synchronize(UpdateIntroBar);

         IntroNextSection := 100;

       end;

  100:begin

         ParamTalk    :=Toy.Talk    (IntroPath+′in14.wav′,′S′);

         Synchronize(UpdateIntroBar);

         IntroNextSection := 110;

       end;

  110:begin

         ParamListen :=Toy.Wait(12,′W′);

         if ParamListen = 3 then IntroNextSection := 120

            else IntroNextSection := 115;

         Synchronize(UpdateIntroBar);

       end;

  115:begin

         ParamTalk    :=Toy.Talk   (IntroPath+′in14a.wav′,′S′);

         if ParamTalk = 3 then IntroNextSection := 120

            else IntroNextSection := 116;

         Synchronize(UpdateIntroBar);

       end;

  116:begin

         ParamListen :=Toy.Wait(12,′W′);

         if ParamListen = 3 then  IntroNextSection := 120

            else   IntroNextSection := 145;

         Synchronize(UpdateIntroBar);

       end;

  120:begin
				
				<dp n="d253"/>
           ParamTalk    :=Toy.Talk    (IntroPath+′in13a.wav′,′S′);//randomize
WAVE

           Synchronize(UpdateIntroBar);

           IntroNextSection := 145;

         end;

    145:begin

           ParamTalk    :=Toy.Talk    (IntroPath+′in1S.wav′,′S′);

           Synchronize(UpdateIntroBar);

           IntroNextSection := 155;

         end;

                                                        

    155:begin

           ParamTalk    :=Toy.Talk    (IntroPath+′in16.wav′,′S′);

           Synchronize(UpdateIntroBar);

           IntroNextSection := 160;

           if SecretName = ′Bubble gum′   then IntroNextSection := 160;

           if SecretName = ′Ace′          then IntroNextSection := 161;

          if SecretName = ′Rainbow′      then IntroNextSection := 162;

         end;

    160:begin

           ParamTalk    :=Toy.Talk    (IntroPath+′in17.wav′,′S′);

           Synchronize(UpdateIntroBar);

           IntroNextSection := 164;

         end;

    161:begin

           ParamTalk    :=Toy.Talk    (IntroPath+′in17a.wav′,′S′);

           Synchronize(UpdateIntroBar);

           IntroNextSection := 164;

         end;

    162:begin

           ParamTalk    :=Toy.Talk    (IntroPath+′in17b.wav′,′S′);

           Synchronize(UpdateIntroBar);

           IntroNextSection := 164;

         end;

    164:begin

           ParamTalk    :=Toy.Talk    (IntroPath+′in18.wav′,′S′);

           Synchronize(UpdateIntroBar);

           IntroNextSection := 165;
				
				<dp n="d254"/>
         end;

    165:begin

           ParamTalk    :=Toy.Talk    (IntroPath+′SPin165.wav′,′SP3′);

           Synchronize(UpdateIntroBar);

           IntroNextSection := 175;

         end;

    166:begin

           {ParamTalk    :=Toy.Talk    (IntroPath+′in20.wav′,′S′);

           Synchronize(UpdateIntroBar);

           IntroNextSection := 167;}
         end;

    167:begin

           {ParamTalk    :=Toy.Talk    (IntroPath+′inbeep.wav′,′EL′);

           Synchronize(UpdateIntroBar);

           IntroNextSection := 168;}

         end;

    168:begin

           {ParamTalk    :=Toy.Talk    (IntroPath+′in19.wav′,′S′);

           Synchronize(UpdateIntroBar);

           IntroNextSection := 169;}

         end;

    169:begin

           {ParamTalk    :=Toy.Talk    (IntroPath+′inblerp.wav′,′EC′);

           Synchronize(UpdateIntroBar);

           IntroNextSection := 170;}
         end;

    170:begin

           {ParamTalk    :=Toy.Talk    (IntroPath+′in21.wav +
′+IntroPath+′in22.wav′,′S′);

           Synchronize(UpdatefntroBar);

           IntroNextSection := 171;}

         end;

    171:begin

           {ParamTalk    :=Toy.Talk    (IntroPath+′inboop.wav′,′E′);

           Synchronize(UpdateIntroBar);

           IntroNextSection := 172;  }
				
				<dp n="d255"/>
        end;

   172:begin

          {ParamTalk    :=Toy.Talk    (IntroPath+′in26.wav′,′S′);

          Synchronize(UpdateIntroBar);

          IntroNextSection := 175;}

        end;

   173:begin

          {ParamTalk    :=Toy.Talk    (IntroPath+′in23.wav′,′S′);

          Synchronize(UpdateIntroBar);

          IntroNextSection := 175;}

        end;

   175:begin

          ParamListen :=Toy.Wait(12,′W′);

          if ParamListen = 1 then  IntroNextSection := 180

             else  IntroNextSection := 185;

          Synchronize(UpdateIntroBar);

        end;

   180:begin

          ParamTalk    :=Toy.Talk    (IntroPath+′in24.wav′,′S′);

          Synchronize(UpdateIntroBar);

          IntroNextSection := 195;

        end;

   181:begin

          {ParamTalk    :=Toy.Talk   (IntroPath+′inbeep.wav′,′EL′);//*****
check???

          if ParamTalk = 2 then IntroNextSection := 185

             else  IntroNextSection := 182;

          Synchronize(UpdateIntroBar);}

        end;

   182:begin

          {ParamTalk    :=Toy.Talk    (IntroPath+′in25b.wav′,′S′);//*****
check???

          if ParamTalk = 2 then IntroNextSection := 185

             else  IntroNextSection := 184;

          Synchronize(UpdateIntroBar);}

        end;
				
				<dp n="d256"/>
  184:begin

       {ParamListen :=Toy.Listen (″,10,′Sensor′);

       if ParamListen = 2 then  IntroNextSection := 185

          else  IntroNextSection := 190;

       Synchronize(UpdateIntroBar);}

     end;
  185:begin

       ParamTalk    :=Toy.Talk    (IntroPath+′SPin185.wav′,′SP4′);

       if ParamTalk = 1 then IntroNextSection := 180

          else  IntroNextSection := 190;

       Synchronize(UpdateIntroBar);

     end;
  186:begin

       {ParamTalk    :=Toy.Talk    (IntroPath+′inboop.wav′,′E′);

       if ParamTalk = 1 then IntroNextSection := 180

          else  IntroNextSection := 187;

        Synchronize(UpdateIntroBar);  }

      end;
   187:begin

       {ParamTalk    :=Toy.Talk    (IntroPath+′in29b.wav′,′S′);

       if ParamTalk = 1 then IntroNextSection := 180

          else  IntroNextSection := 190;

       Synchronize(UpdateIntroBar); }

     end;
  190:begin

       ParamListen :=Toy.Wait(12,′W′);

       if ParamListen = 1 then   IntroNextSection  := 180

          else  IntroNextSection := 195;

       Synchronize(UpdateIntroBar);

     end;
  195:begin

       ParamTalk    :=Toy.Talk    (IntroPath+′SPin195.wav′,′SP5′);

       Synchronize(UpdateIntroBar);

       IntroNextSection := 197;

     end;
  196:begin

      {ParamTalk    :=Toy.Talk    (IntroPath+′in23.wav′,′S′);
				
				<dp n="d257"/>
        Synchronize(UpdateIntroBar);

        IntroNextSection := 197;}

      end;
   197:begin

        ParamListen :=Toy.Wait(12,′W′);

        if ParamListen = 2 then  IntroNextSection := 200
           else   IntroNextSection  := 205;

        Synchronize(UpdateIntroBar);

      end;
   200:begin

        ParamTalk    :=Toy.Talk    (IntroPath+′in33.wav′,′S′);

        Synchronize(UpdateIntroBar);

        IntroNextSection := 215;

      end;
   205:begin

        ParamTalk    :=Toy.Talk    (IntroPath+′SPin205.wav′,′SP6′);

        if ParamTalk = 2 then IntroNextSection := 200

           else  IntroNextSection := 210;

        Synchronize(UpdateIntroBar);
      end;
   206:begin

        {ParamTalk    :=To.Talk    (IntroPath+′inbeep.wav′,′S′);

        if ParamTalk = 2 then IntroNextSection := 200

           else  IntroNextSection := 207;

        Synchronize(UpdateIntroBar);}

      end;
   207:begin

        {ParamTalk    :=Toy.Talk    (IntroPath+′in34b.wav′,′S′);

        if ParamTalk = 2 then IntroNextSection := 200

           else  IntroNextSection := 210;

        Synchronize(UpdateIntroBar);}

      end;
   210:begin

        ParamListen :=Toy.Wait(12,′W′);

        if ParamListen = 2 then  IntroNextSection := 200

           else  IntroNextSection := 215;

        Synchronize(UpdateIntroBar);
				
				<dp n="d258"/>
     end;
  215:begin

       ParamTalk    :=Toy.Talk    (IntroPath+′SPin215.wav′,′SP7′);

       Synchronize(UpdateIntroBar);

       IntroNextSection := 217;

     end;
  216:begin

       {ParamTalk    :=Toy.Talk   (IntroPath+′in30.wav′,′S′);

       Synchronize(UpdateIntroBar);

       IntroNextSection := 217;}

     end;
  217:begin

       ParamListen :=Toy.Wait(12,′W′);

       if ParamListen = 3 then  IntroNextSection := 220

          else  IntroNextSection := 221;

       Synchronize(UpdateIntroBar);

     end;
  220:begin

       ParamTalk    :=Toy.Talk   (IntroPath+′in36.wav′,′S′);

       Synchronize(UpdateIntroBar);

       IntroNextSection := 230;

     end;
 221:begin

       ParamTalk    :=Toy.Talk    (IntroPath+′SPin221.wav′,′SP8′);

       if ParamTalk = 3 then  IntroNextSection := 220

          else  IntroNextSection := 224;

       Synchronize(UpdateIntroBar);

     end;
  222:begin

       {ParamTalk    :=Toy.Talk    (IntroPath+′inblerp.wav′,′EC′);

       Synchronize(UpdateIntroBar);

       IntroNextSection := 90;}

     end;
  223:begin

       {ParamTalk    :=Toy.Talk    (IntroPath+′in37b.wav′,′S′);

       Synchronize(UpdateIntroBar);
				
				<dp n="d259"/>
        IntroNextSection := 190;}

      end;
   224:begin

        ParamTalk    :=Toy.Wait(12,′W′);

        if ParamTalk = 3 then  IntroNextSection := 220

           else  IntroNextSection := 230;

        Synchronize(UpdateIntroBar);

      end;
   230:begin

        ParamTalk    :=Toy.Talk    (IntroPath+′in38.wav′,′S′);

        Synchronize(UpdateIntroBar);

        IntroNextSection :=235;

      end;
   235:begin

        ParamTalk    :=Toy.Talk    (IntroPath+′SPin235.wav′,′SP9′);

        if ParamTalk = 1 then  IntroNextSection := 250

           else  IntroNextSection := 241;

        Synchronize(UpdateIntroBar);

      end;
   241:begin

        ParamTalk    :=Toy.Talk    (IntroPath+′in40a.wav′,′S′);

        Synchronize(UpdateIntroBar);

        IntroNextSection := 242;

      end;
   242:begin

        ParamTalk    :=Toy.Talk    (IntroPath+′SPin242.wav′,′SP10′);

        Synchronize(UpdateIntroBar);

        IntroNextSection := 248;

      end;
   243:begin

        {ParamTalk    :=Toy.Talk    (IntroPath+′in12b.wav′,′S′);

        Synchronize(UpdateIntroBar);

        IntroNextSection := 90;}

      end;
   244:begin

       {ParamTalk    :=Toy.Talk    (IntroPath+′in12b.wav′,′S′);
				
				<dp n="d260"/>
       Synchronize(UpdateIntroBar);

       IntroNextSection := 90;  }

     end;
  245:begin

       (ParamTalk    :=Toy.Talk    (IntroPath+′in12b.wav′,′S′);

       Synchronize(UpdateIntroBar);

       IntroNextSection :=90;}

     end;
  246:begin

       {ParamTalk    :=Toy.Talk    (IntroPath+′in12b.wav′,′S′);

       Synchronize(UpdateIntroBar);

       IntroNextSection := 90;}

     end;
  247:begin

       {ParamTalk    :=Toy.Talk    (IntroPath+′in24.wav′,′S′);

       Synchronize(UpdateIntroBar);

       IntroNextSection := 190;}

     end;
  248:begin

       ParamTalk    :=Toy.Talk    (IntroPath+′SPin235.wav′,′SP9′);

       if ParamTalk = 1 then   IntroNextSection := 250



          else  IntroNextSection := 270;

       Synchronize(UpdateIntroBar);

     end;
  250:begin

       ParamTalk    :=Toy.Talk    (IntroPath+′in39.wav′,′S′);

       Synchronize(UpdateIntroBar);

       IntroNextSection := 265;

     end;
  265:begin

       ParamTalk    :=Toy.Talk    (IntroPath+′in41.wav′,′S′);

       Synchronize(UpdateIntroBar);

       IntroNextSection := 270;

     end;
  270:begin

       ParamTalk    :=Toy.Talk    (IntroPath+′in41m.wav′,′EL′);
				
				<dp n="d261"/>
           Synchronize(UpdateIntroBar);

           IntroNextSection := 275;

         end;

    275:begin

           ParamTalk    :=Toy.Talk    (IntroPath+′in44.wav′,′S′);

           Synchronize(UpdateIntroBar);

           IntroNextSection := 295;

         end;

    276:begin

           {ParamTalk    :=Toy.Talk   (IntroPath+′in44c.wav′,′E′);

           Synchronize(UpdateIntroBar);

           IntroNextSection := 277;}

         end;

    277:begin

           {ParamTalk    :=Toy.Talk   (IntroPath+′in44b.wav′,′S′);

           Synchronize(UpdateIntroBar);

           IntroNextSection := 285;}

         end;

    285:begin

           {ParamTalk    :=Toy.Talk    (″,′EC′); // sleep(1000)  wait 1 sec
???

           Synchronize(UpdateIntroBar);

           IntroNextSection := 300;}

         end;

    290:begin

           {ParamTalk    :=Toy.Talk    (IntroPath+′in12b.wav′,′S′);
//??????

           Synchronize(UpdateIntroBar);

           IntroNextSection := 90;}

         end;

    295:begin

           ParamTalk    :=Toy.Talk    (IntroPath+′in49.wav′,′S′);

           Synchronize(UpdateIntroBar);

           IntroNextSection := 300;

         end;

    300:begin
				
				<dp n="d262"/>
        ParamTalk    :=Toy.Talk    (IntroPath+′in50.wav′,′S′);

        Synchronize(UpdateIntroBar);

        IntroNextSection := 305;

      end;
   305:begin

        ParamListen    :=Toy.Listen    (′too hot/7′,12,′SR′,′W′);

        if ParamListen = 7 then IntroNextSection := 315

           else IntroNextSection := 310;

        Synchronize(UpdateIntroBar);

      end;
   310:begin

        ParamTalk      :=Toy.Talk    (IntroPath+′in52.wav′,′S′);

        Synchronize(UpdateIntroBar);

        IntroNextSection :=311;

      end;
   311:begin

        ParamListen    :=Toy.Listen    (′too hot/7′,12,′SR′,′W′);

        if ParamListen = 7 then IntroNextSection := 315

           else IntroNextSection := 320;

        Synchronize(UpdateIntroBar);

      end;
   315:begin

        ParamTalk    :=Toy.Talk    (IntroPath+′in52m.wav′,′EL′);

        Synchronize(UpdateIntroBar);

        IntroNextSection := 316;

      end;
   316:begin

        ParamTalk    :=Toy.Talk    (IntroPath+′in51.wav′,′S′);

        Synchronize(UpdateIntroBar);

        IntroNextSection := 320;

      end;
   320:begin

        ParamTalk    :=Toy.Talk    (IntroPath+′in53.wav′,′S′);

        Synchronize(UpdateIntroBar);

        IntroNextSection := 325;

      end;
				
				<dp n="d263"/>
  325:begin

        ParamListen  :=Toy.Listen    (′too cold/7′,12,′SR′,′W′);

        if ParamListen = 7 then IntroNextSection := 335

           else IntroNextSection := 331;

        Synchronize(UpdateIntroBar);

      end;
   330:begin

        ParamTalk    :=Toy.Talk    (IntroPath+′in55.wav′,′S′);

        Synchronize(UpdateIntroBar);

        IntroNextSection := 331;

      end;
  331: begin

        ParamListen  :=Toy.Listen    (′too cold/7′,12,′SR′,′W′);

        if ParamListen = 7 then IntroNextSection := 335

           else IntroNextSection := 340;

        Synchronize(UpdateIntroBar);

      end;
   335:begin

        ParamTalk    :=Toy.Talk     (IntroPath+′in55m.wav′,′E′);

        Synchronize(UpdateIntroBar ;

        IntroNextSection := 336;

      end;
   336:begin

        ParamTalk    :=Toy.Talk    (IntroPath+′in54.wav′,′S′);

        Synchronize(UpdateIntroBar);

        IntroNextSection := 340;

      end;
   340:begin

        ParamTalk    :=Toy.Talk    (IntroPath+′in56.wav′,′S′);

        Synchronize(UpdateIntroBar);

        IntroNextSection := 345; 

      end;
   345:begin

        ParamListen  :=Toy.Listen    (′just right/7′,12,′SR′,′W′);

        if ParamListen = 7 then IntroNextSection := 355

        else IntroNextSection := 350;

        Synchronize(UpdateIntroBar);
				
				<dp n="d264"/>
        end;
   350:begin

        ParamTalk    :=Toy.Talk    (IntroPath+′in58.wav′,′S′);

        Synchronize(UpdateIntroBar);

        IntroNextSection := 351;

      end;
   351:begin

        ParamListen  :=Toy.Listen    (′just right/7′,12,′SR′,′W′);

        if ParamListen = 7 then IntroNextSection := 355

           else IntroNextSection := 360;

        Synchronize(UpdateIntroBar);

      end;
   355:begin

        ParamTalk    :=Toy.Talk    (IntroPath+′in58m.wav′,′EL′);

        Synchronize(UpdateIntroBar);

        IntroNextSection := 356;

      end;
   356:begin

        ParamTalk    :=Toy.Talk    (IntroPath+′in57.wav′,′S′);

        Synchronize(UpdateIntroBar);

        IntroNextSection := 360;

      end;
   360:begin

        ParamTalk    :=Toy.Talk    (IntroPath+′in59.wav′,′S′);

        Synchronize(UpdateIntroBar);

        IntroNextSection := 365;

      end;
  365:begin

        ParamListen  :=Toy.Listen    (′bears/7′,12,′SR′,′W′);

        if ParamListen = 7 then IntroNextSection := 370

           else IntroNextSection := 371;

        Synchronize(UpdateIntroBar);

      end;
  370:begin

        ParamTalk    :=Toy.Talk    (IntroPath+′in60.wav′, ′S′);

        Synchronize(UpdateIntroBar);
				
				<dp n="d265"/>
       IntroNextSection := 375;

     end;
  371:begin

       ParamTalk    :=Toy.Talk    (IntroPath+′in60a.wav′,′S′);

       Synchronize(UpdateIntroBar);

       IntroNextSection := 375;

     end;
  375:begin

       ParamTalk    :=Toy.Talk    (IntroPath+′in61m.wav′,′SP11′);

       Synchronize(UpdateIntroBar);

       IntroNextSection := 385;

     end;
  380:begin

       {ParamTalk   :=Toy.Talk    (IntroPath+′in61.wav′,′S′);

       Synchronize(UpdateIntroBar);

       IntroNextSection := 385;}

     end;
  385:begin

       ParamListen  :=Toy.Listen (′too hot/1,too cold/2,just right/3′,

                                        12,′SR′,′W′);

       case ParamListen of

         1: IntroNextSection := 390;

         2: IntroNextSection := 400;

         3: IntroNextSection := 405;

         else IntroNextSection := 410;

       end;

       Synchronize(UpdateIntroBar);

     end;
  390:begin

       ParamTalk    :=Toy.Talk    (IntroPath+′in62.wav′,′S′);

       Synchronize(UpdateIntroBar);

       IntroNextSection := 415;

     end;
  400:begin

       ParamTalk    :=Toy.Talk    (IntroPath+′in63.wav′,′S′);

       Synchronize(UpdateIntroBar);

       IntroNextSection := 415;
				
				<dp n="d266"/>
       end;
   405: begin

         ParamTalk    :=Toy.Talk    (IntroPath+′in64.wav′,′S′);

         Synchronize(UpdateIntroBar);

         IntroNextSection := 415;

       end;

  410:begin
         ParamTalk    :=Toy.Talk (IntroPath+′in62.wav +
′+IntroPath+′in63.wav + ′

                          +IntroPath+′in64.wav + ′,′S′);

         Synchronize(UpdateIntroBar);

         IntroNextSection := 411;

       end;

  411:begin

         ParamTalk    :=Toy.Talk    (IntroPath+′in67m.wav′,′S′);

         Synchronize(UpdateIntroBar);

         IntroNextSection := 415;

       end;

  415:begin

         ParamTalk    :=Toy.Talk    (IntroPath+′in68.wav′,′S′);

         Synchronize(UpdateIntroBar);

         IntroNextSection := 416;

       end;

  416:begin

         ParamListen :=Toy.Wait(12,′W′);

         if ParamListen = 3 then  IntroNextSection := 419

            else   IntroNextSection := 417;

         Synchronize(UpdateIntroBar);

       end;

  417:begin

         ParamTalk   :=Toy.Talk    (IntroPath+′in68a.wav′,′S′);

         if ParamTalk = 3 then  IntroNextSection := 419

            else  IntroNextSection := 418;

         Synchronize(UpdateIntroBar);

       end;

  418:begin
				
				<dp n="d267"/>
          ParamListen :=Toy.Wait(12,′W′);

          if ParamListen = 3 then IntroNextSection := 419

             else  IntroNextSection := 420;

          Synchronize(UpdateIntroBar);

        end;

   419:begin

          ParamTalk    :=Toy.Talk    (IntroPath+′in???.wav′,′S′);

          Synchronize(UpdateIntroBar);

          IntroNextSection := 420;

        end;

   420:begin

          ParamTalk    :=Toy.Talk    (IntroPath+′in68m. wav′,′E′);

          Synchronize(UpdateIntroBar);
          IntroNextSection := 425;

        end;

   425:begin

          ParamTalk    :=Toy.Talk    (IntroPath+′in69.wav′,′S′);

          Synchronize(UpdateIntroBar);

          IntroNextSection := 430;
        end;

   430:begin

          if  (Time < StrToTime(′20:00:00′)) and (Time >
StrToTime(′5:00:00′))

              then IntroNextSection := 435

          else IntroNextSection := 440;

          Synchronize(UpdateIntroBar);

        end;

   435:begin

          ParamTalk    :=Toy.Talk    (IntroPath+′in70.wav′,′S′);

          Synchronize(UpdateIntroBar);

          IntroNextSection := 436;

        end;

   436:begin

          ParamTalk    :=Toy.Talk    (IntroPath+′in70m.wav′,′S′);

          Synchronize(UpdateIntroBar);

          IntroNextSection := -1; //Goto Story  : AnyTime Story

          PlayNextSection   := 1;
				
				<dp n="d268"/>
        end;

   440:begin

          ParamTalk    :=Toy.Talk    (IntroPath+′in71.wav′,′S′);

          Synchronize(UpdateIntroBar);

          IntroNextSection := 441;

        end;

   441:begin

          ParamTalk    :=Toy.Talk    (IntroPath+′in71m.wav′,′S′);

          Synchronize(UpdateIntroBar);

          IntroNextSection := -1;

          PlayNextSection  := -1; //Goto Menu : Bed Time Story

        end;

     end;
//-----------end of Intro sesions-----------------------------------
// =========  P  L  A  Y   ================
//--------------- write here all Play sessions----------------------
//=================================

   case PlayNextSection of

   1 :begin

         {sleep(300);

         ParamTalk   :=Toy.Talk  (PlayPath+′in001.wav′,′E′);

         ParamListen :=Toy.Listen (′yes/1,no,2′,1.5,′SR and Sensor′);

         PlayNextSection := 2;

       end;

   2 :begin

         ParamTalk   :=Toy.Talk   (PlayPath+′in01a.wav′,′E′);

         Synchronize(UpdatePlayBar);

         PlayNextSection := 3;

       end;

   3 :begin

         ParamTalk   :=Toy.Talk    (PlayPath+′in01b.wav′,′EL′);

         Synchronize(UpdatePlayBar);

         PlayNextSection := 5;

       end;
				
				<dp n="d269"/>
   4 :begin

         {sleep(300);

         PlayNextSection := 5;}

       end;

   5 :begin

         ParamTalk    :=Toy.Talk    (PlayPath+′in01.wav′,′S′);

         Synchronize(UpdatePlayBar);

         PlayNextSection := -1;

       end;
   {else

       begin

         Terminate;

         bit;

       end; }

   end;
//-----------------end of Play sesions-----------------------
*}
// ======  The Princess and the Pe ==========
//--------------write here all  sessions---------------------
// =============================

  case PrincessNextSection of

   1 :begin

         GamePrincessStatus := ′Princess′;// Default is "Princess"

         PrincessNextSection := 5;

       end;

   5 :begin

         ParamTalk    := Toy.Talk    (PeasPath+′pp005.wav′,′S′);

         Synchronize(UpdatePrincessBar);

         PrincessNextSection := 10;

       end;

   10 :begin

          ParamListen    :=Toy.Listen(′boy/1,girl/2′,DTime,′SR′,′W′);

          case ParamListen of
				
				<dp n="d270"/>
         1 : PrincessNextSection    := 30;

         2 : PrincessNextSection    := 35;

         else  PrincessNextSection := 15;

       end;

       Synchronize(UpdatePrincessBar);

     end;
  15 :begin

       ParamTalk   :=Toy.Talk    (PeasPath+′pp020.wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 20;

     end;
  20 :begin

       ParamListen   :=Toy.Listen(′boy/1,girl/2′,DTime,′SR′,′W′);

       case ParamListen of

         1 : PrincessNextSection    := 30;

         2 : PrincessNextSection    := 35;

         else  PrincessNextSection   := 25;

       end;

       Synchronize(UpdatePrincessBar);

     end;
   25:begin

       ParamTalk   :=Toy.Talk    (PeasPath+′pp025.wav′,′S′);

       Synchronize (UpdatePrincessBar);

       PrincessNextSection := 40;

     end;
   30:begin

       GamePrincessStatus := ′Prince′;// Story is for a "Prince"

       ParamTalk   :=Toy.Talk    (PeasPath+′pp030.wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 31;

     end;
   31:begin

       ParamTalk   :=Toy.Talk    (PeasPath+′pp031.wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 37;

     end;
				
				<dp n="d271"/>
    35 :begin

           ParamTalk    :=Toy.Talk    (PeasPath+′pp035.wav′,′S′);

           Synchronize(UpdatePrincessBar);

           PrincessNextSection := 36;

         end;

    36 :begin

           ParamTalk    :=Toy.Talk    (PeasPath+′pp036.wav′,′S′);

           Synchronize(UpdatePrincessBar);

            PrincessNextSection := 37;

         end;

    37 :begin

           if GamePrincessStatus = ′Prince′ then PrincessNextSection := 40

              else PrincessNextSection := 100;

           Synchronize(UpdatePrincessBar);

         end;

    40 :begin

           ParamTalk   :=Toy.Talk    (PeasPath+′pp040m. wav′,′S′);

           Synchronize(UpdatePrincessBar);

           PrincessNextSection := 45;

         end;

    45 :begin

           ParamTalk    :=Toy.Talk    (PeasPath+′pp045.wav′,′S′);

           PrincessNextSection   := 50;

           if FavoriteColor = ′Red′     then PrincessNextSection    := 50;

           if FavoriteColor = ′Blue′    then PrincessNextSection    := 55;

           if FavoriteColor = ′Yellow′  then PrincessNextSection    := 60;

           Synchronize(UpdatePrincessBar);

         end;

    50 :begin

            ParamTalk    :=Toy.Talk    (PeasPath+′pp050.wav′,′S′);

            PrincessNextSection    := 65;

            if FavoriteFood = ′Pizza′     then PrincessNextSection   := 65;

            if FavoriteFood = ′FrenchFries′    then PrincessNextSection    :=
70;

            if FavoriteFood = ′MacaroniAndCheese′ then PrincessNextSection
:=75;
				
				<dp n="d272"/>
          Synchronize(UpdatePrincessBar);

          end;

   55 :begin

          ParamTalk    :=Toy.Talk    (PeasPath+′pp055.wav′,′S′);

          PrincessNextSection    := 65;

          if FavoriteFood = ′Pizza′     then PrincessNextSection    := 65;

          if FavoriteFood = ′FrenchFries′    then PrincessNextSection    :=
 70;

          if FavoriteFood = ′MacaroniAndCheese′ then PrincessNextSection
:=75;

          Synchronize (UpdatePrincessBar);

        end;

   60 :begin

          ParamTalk    :=Toy.Talk    (PeasPath+′pp060.wav′,′S′);

          PrincessNextSection   := 65;

          if FavoriteFood = ′Pizza′     then PrincessNextSection   := 65;

          if FavoriteFood = ′FrenchFries′    then PrincessNextSection    :=
70;

          if FavotiteFood = ′MacaroniAndCheese′ then PrincessNextSection
:=75;

          Synchronize(UpdatePrincessBar);

        end;

   65 :begin

          ParamTalk   :=Toy.Talk    (PeasPath+′pp065.wav′,′S′);

          PrincessNextSection    := 80;

          if FavoriteActivity = ′Drawing′     then PrincessNextSection   :=
80;

        if FavoriteActivity = ′PlayingComputerGames′ then
PrincessNextSection := 85;

          if FavoriteActivity = ′MakeBelieve′ then PrincessNextSection    :=
90;

          Synchronize(UpdatePrincessBar);

        end;

   70 :begin

          ParamTalk    :=Toy.Talk    (PeasPath+′pp070.wav′,′S′);

          PrincessNextSection    := 80;

          if FavoriteActivity = ′Drawing′     then PrincessNextSection    :=
80;
				
				<dp n="d273"/>
         if FavoriteActivity = ′PlayingComputerGames′ then
PrincessNextSection := 85;

         if FavoriteActivity = ′MakeBelieve′ then PrincessNextSection    :=
90;

         Synchronize(UpdatePrincessBar);

       end;

  75 :begin

         ParamTalk    :=Toy.Talk    (PeasPath+′pp075.wav′,′S′);

         PrincessNextSection    := 80;

         if FavoriteActivity = ′Drawing′     then PrincessNextSection    :=
80;

         if FavoriteActivity = ′PlayingComputerGames′ then
PrincessNextSection := 85;

         if FavoriteActivity = ′MakeBelieve′ then PrincessNextSection   :=
90;

         Synchronize(UpdatePrincessBar);

       end;

  80 :begin

         ParamTalk    :=Toy.Talk    (PeasPath+′pp080.wav′,′S′);

         Synchronize(UpdatePrincessBar);

         PrincessNextSection := 95;

       end;

  85 :begin

         ParamTalk    :=Toy.Talk    (PeasPath+′pp085.wav′,′S′);

         Synchronize(UpdatePrincessBar);

         PrincessNextSection := 95;

       end;

  90 :begin

         ParamTalk    :=Toy.Talk    (PeasPath+′pp090.wav′,′S′);

         Synchronize(UpdatePrincessBar);

         PrincessNextSection := 95;

       end;

  95 :begin

         ParamTalk    :=Toy.Talk    (PeasPath+′pp095.wav′,′S′);

         Synchronize(UpdatePrincessBar);

         PrincessNextSection := 165;

       end;
				
				<dp n="d274"/>
  100 :begin

          ParamTalk    :=Toy.Talk    (PeasPath+′pp100.wav′,′S′);

          Synchrcnize(UpdatePrincessBar);

          PrincessNextSection := 105;

        end;

  105 :begin

          ParamTalk    :=Toy.Talk    (PeasPath+′pp105.wav′,′S′);

          Synchronize(UpdatePrincessBar);

          PrincessNextSection := 110;

        end;

  110 :begin

          ParamTalk    :=Toy.Talk    (PeasPath+′pp110.wav′,′S′);

          PrincessNextSection    := 115;

          if FavoriteColor = ′Red′     then PrincessNextSection    := 115;

          if FavoriteColor = ′Blue′    then PrincessNextSection    := 120;

          if FavoriteColor = ′Yellow′  then PrincessNextSection    := 125;

          Synchronize(UpdatePrincessBar);

        end;

  115 :begin

          ParamTalk    :=Toy.Talk    (PeasPath+′pp115.wav′,′S′);

          PrincessNextSection    := 130;

          if FavoriteFood = ′Pizza′     then PrincessNextSection    := 130;

          if FavoriteFood = ′FrenchFries′    then PrincessNextSection    :=
135;

          if FavoriteFood = ′MacaroniAndCheese′ then PrincessNextSection
:=140;

          Synchronize(UpdatePrincessBar);

        end;

  120 :begin

          ParamTalk    :=Toy.Talk    (PeasPath+′pp120.wav′,′S′);

          PrincessNextSection    := 130;

          if FavoriteFood = ′Pizza′     then PrincessNextSection    := 130;

          if FavoriteFood = ′FrenchFries′    then PrincessNextSection    :=
135;

          if FavoriteFood = ′MacaroniAndCheese′ then PrincessNextSection
:=140;
				
				<dp n="d275"/>
          Synchronize(UpdatePrincessBar);

        end;

  125 :begin

          ParamTalk    :=Toy.Talk    (PeasPath+′pp125.wav′,′S′);

          PrincessNextSection    := 130;

          if FavoriteFood = ′Pizza′     then PrincessNextSection   := 130;

          if FavoriteFood = ′FrenchFries′    then PrincessNextSection    :=
 135;

          if FavoriteFood = ′MacaroniAndCheese′ then PrincessNextSection
 :=140;

          Synchronize(UpdatePrincessBar);

        end;

  130 :begin

          ParamTalk    :=Toy.Talk    (PeasPath+′pp130.wav′,′S′);

          PrincessNextSection    := 145;

          if FavoriteActivity = ′Drawing′     then PrincessNextSection   :=
145;

          if FavoriteActivity = ′PlayingComputerGames′ then
PrincessNextSection := 150;

          if FavoriteActivity = ′MakeBelieve′ then PrincessNextSection   :=
155;

          Synchronize(UpdatePrincessBar);

        end;

  135 :begin

          ParamTalk    :=Toy.Talk    (PeasPath+′pp135.wav′,′S′);

          PrincessNextSection    := 145;

          if FavoriteActivity = ′Drawing′     then PrincessNextSection   :=
145;

          if FavoriteActivity = ′PlayingComputerGames′ then
PrincessNextSection := 150;

          if FavoriteActivity = ′MakeBelieve′ then PrincessNextSection    :=
155;

          Synchronize(UpdatePrincessBar);

        end;

  140 :begin

          ParamTalk    :=Toy.Talk    (PeasPath+′pp140.wav′,′S′);

          PrincessNextSection    := 145;
				
				<dp n="d276"/>
         if FavoriteActivity = ′Drawing′     then PrincessNextSection    :=
145;

         if FavoriteActivity = ′PlayingComputerGames′then
PrincessNextSection := 150;

         if FavoriteActivity = ′MakeBelieve′ then PrincessNextSection    :=
155;

         Synchronize(UpdatePrincessBar);

       end;
   145 :begin

         ParamTalk    :=Toy.Talk    (PeasPath+′pp145.wav′,′S′);

         Synchronize(UpdatePrincessBar);

         PrincessMextSection := 160;

       end;
   150 :begin

         ParamTalk    :=Toy.Talk    (PeasPath+′pp150.wav′,′S′);

         Synchronize(UpdatePrincessBar);

         PrincessNextSection := 160;

       end;
   155 :begin

         ParamTalk    :=Toy.Talk    (PeasPath+′pp155.wav′,′S′);

         Synchronize(UpdatePrincessBar);

         PrincessNextSection := 160;

       end;
   160 :begin

         ParamTalk    :=Toy.Talk    (PeasPath+′pp160.wav′,′S′);

         Synchronize(UpdatePrincessBar);

         PrincessNextSection := 170;

       end;
   165 :begin

         ParamTalk    :=Toy.Talk    (PeasPath+′pp165.wav′,′S′);

         Synchronize(UpdatePrincessBar);

         PrincessNextSection := 171;

       end;
  170 :begin

        ParamTalk    :=Toy.Talk    (PeasPath+′pp170.wav′,′S′);

        Synchronize(UpdatePrinceasBar);
				
				<dp n="d277"/>
         PrincessNextSection := 172;

       end;
   172 :begin

         ParamTalk    :=Toy.Talk    (PeasPath+′pp172m.wav′,′S′);

         Synchronize(UpdatePrincessBar);

         PrincessNextSection := 175;

       end;
   175 :begin

         ParamTalk    :=Toy.Talk    (PeasPath+′pp175.wav′,′S′);

         Synchronize(UpdatePrincessBar);

         PrincessNextSection := 180;

       end;
   180 :begin

         ParamTalk    :=Toy.Talk    (PeasPath+′pp180.wav′,′S′);

         Synchronize(UpdatePrincessBar);

         PrincessNextSection := 181;

       end;
   181 :begin

         ParamTalk    :=Toy.Talk    (PeasPath+′pp181m.wav′,′EL′);

         Synchronize(UpdatePrincessBar);

         PrincessNextSection := 185;

       end;
   185 :begin

         ParamTalk    :=Toy.Talk    (PeasPath+′pp185.wav′,′S′);

         Synchronize(UpdatePrincessBar);

         PrincessNextSection := 190;

       end;
   190 :begin

         ParamTalk    :=Toy.Talk    (PeasPath+′pp190.wav′,′S′);

         Synchronize(UpdatePrincessBar);

         PrincessNextSection := 195;

       end;
   195 :begin

         ParamListen    :=Toy.Listen (′yes/1,no/2′,DTime,′SR′,′W′);
				
				<dp n="d278"/>
       case ParamListen of

         1: IntroNextSection := 245;

         2: IntroNextSection := 215;

         else IntroNextSection := 200;

       end;

       Synchronize(UpdateIntroBar);

     end;
200 :begin

      ParamTalk    :=Toy.Talk    (PeasPath+′pp200.wav′,′S′);

      Synchronize(UpdatePrincessBar);

      PrincessNextSection := 205;

    end;
205 :begin

      ParamListen    :=Toy.Listen (′yes/1,no/2′,DTime,′SR′,′W′);

      case ParamListen of

        1: IntroNextSection := 245;

        2: IntroNextSection := 215;

        else IntroNextSection := 210;

      end;

      Synchronize(UpdateIntroBar);

    end;
210 :begin

      ParamTalk    :=Toy.Talk    (PeasPath+′pp210.wav′,′S′);

      Synchronize(UpdatePrincessBar);

      PrincessNextSection := 245;

    end;
215 :begin

      ParamTalk    :=Toy.Talk    (PeasPath+′pp215.wav′,′S′);

      Synchronize(UpdatePrincessBar);

      PrincessNextSection := 220;

    end;
220 :begin

      ParamTalk    :=Toy.Talk    (PeasPath+′pp220m.wav′,′S′);

      if GamePrincessStatus = ′Prince′ then PrincessNextSection := 226

         else PrincessNextSection := 225;

      Synchronize(UpdatePrincessBar);

    end;
				
				<dp n="d279"/>
  225 :begin

        ParamTalk    :=Toy.Talk    (PeasPath+′pp225.wav′,′S′);// change

        Synchronize(UpdatePrincessBar);

        PrincessNextSection := 230;

      end;
  226 :begin

        ParamTalk    :=Toy.Talk    (PeasPath+′pp226.wav′,′S′); //change

        Synchronize(UpdatePrincessBar);

        PrincessNextSection := 235;

      end;
  230 :begin

        ParamTalk    :=Toy.Talk    (PeasPath+′pp230.wav′,′S′);

        Synchronize(UpdatePrincessBar);

        PrincessNextSection := 240;

      end;
  235 :begin

        ParamTalk    :=Toy.Talk    (PeasPath+′pp235.wav′,′S′);

        Synchronize(UpdatePrincessBar);

        PrincessNextSection := 240;

      end;
  240 :begin

        ParamTalk    :=Toy.Talk    (PeasPath+′pp240.wav′,′S′);

        if GamePrincessStatus = ′Prince′ then PrincessNextSection := 255

           else PrincessNextSection := 250;

        Synchronize(UpdatePrincessBar);

      end;
  245 :begin

        ParamTalk    :=Toy.Talk    (PeasPath+′pp245.wav′,′S′);

        if GamePrincessStatus = ′Prince′  then PrincessNextSection := 255

           else PrincessNextSection := 250;

        Synchronize(UpdatePrincessBar);

      end;
  249 :begin

        ParamTalk    :=Toy.Talk    (PeasPath+′pp249m.wav′,′S′);

        PrincessNextSection := 249;
				
				<dp n="d280"/>
       Synchronize(UpdatePrincessBar);

     end;
 250 :begin

       ParamTalk    :=Toy.Talk   (PeasPath+′pp250.wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 260;

     end;
 255 :begin

       ParamTalk    :=Toy.Talk   (PeasPath+′pp255.wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 265;

     end;
 260 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp260.wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 270;

     end;
 265 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp265.wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 270;

     end;
 270 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp270.wav′,′S′); //change

       if GamePrincessStatus = ′Prince′ then PrincessNextSection := 280

          else PrincessNextSection := 275;

       Synchronize(UpdatePrincessBar);

     end;
 275 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp275.wav′,′S′); //change

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 285;

     end;
 280 :begin
				
				<dp n="d281"/>
          ParamTalk    :=Toy.Talk    (PeasPath+′pp280.wav′,′S′);

          Synchronice(UpdatePrincessBar);

          PrincessNextSection := 290;

        end;

  285 :begin

          ParamTalk    := Toy. Talk    (PeasPath+′pp285.wav′,′S′);

          Synchronize(UpdatePrincessBar);

          PrincessNextSection := 295;

        end;

   290 :begin

          ParamTalk    :=Toy.Talk    (PeasPath+′pp290.wav′,′S′);

          Synchronize(UpdatePrincessBar);

          PrincessNextSection := 295;

        end;

  295 :begin

          ParamListen    :=Toy.Listen (′yes/1,no/2′,DTime,′SR′,′W′);

          case ParamListen of

            1:begin

                 if GamePrincessStatus = ′Prince′ then PrincessNextSection
:= 320

                 else PrincessNextSection := 315;

                end;

            2:  IntroNextSection := 345;

            else IntroNextSection := 300;

          end;

          Synchronize(UpdateIntroBar);

        end;

  300 :begin

          ParamTalk    :=Toy.Talk    (PeasPath+′pp300.wav′,′S′);

          Synchronize(UpdatePrincessBar);

          PrincessNextSection := 305;

        end;

  305 :begin

          ParamListen    :=Toy.Listen (′yes/1,no/2′,DTime,′SR′,′W′);

          case ParamListen of

            1:  begin
				
				<dp n="d282"/>
                      if GamePrincessStatus = ′Prince′  then PrincessNextSection
 := 320

                     else PrincessNextSection := 315;

                    end;

               2: IntroNextSection := 345;

               else IntroNextSection := 310;

             end;

             Synchronize(UpdateIntroBar);

           end;

     310 :begin

             ParamTalk    :=Toy.Talk    (PeasPath+′pp310.wav′,′S′);

             Synchronize(UpdatePrincessBar);

             PrincessNextSection := 345;

           end;

    315 :begin

            ParamTalk    :=Toy.Talk    (PeasPath+′pp315.wav′,′S′);

            Synchronize(UpdatePrincessBar);

            PrincessNextSection := 325;

          end;

    320 :begin

            ParamTalk    :=Toy.Talk    (PeasPath+′pp320.wav′,′S′);

            Synchronize(UpdatePrincessBar);

            PrincessNextSection := 326;

          end;

    325 :begin

            ParamListen    :=Toy.Listen
(′queen/1,king/2,prince/3′,DTime,′SR′,′W′);

                case ParamListen of

              1: IntroNextSection := 445;

              2: IntroNextSection := 450;

              3: IntroNextSection := 465;

              else IntroNextSection := 450;

            end;

            Synchronize(UpdateIntroBar);

          end;

    326 :begin
				
				<dp n="d283"/>
               ParamListen    :=Toy.Listen
  (′queen/1,king/2,princess/3′,DTime,′SR′,′W′);

           case ParamListen of

             1: IntroNextSection := 440;

             2: IntroNextSection := 450;

             3: IntroNextSection := 460;

             else IntroNextSection := 450;

           end;

           Synchronize(UpdateIntroBar);

         end;

   330 :begin

           ParamTalk    :=Toy.Talk    (PeasPath+′pp330.wav′, ′S′);

           Synchronize(UpdatePrincessBar);

           PrincessNextSection := 335;

         end;

   331 :begin

           ParamTalk    :=Toy.Talk   (PeasPath+′pp330.wav′,′S′);

           Synchronize(UpdatePrincessBar);

           PrincessNextSection := 336;

         end;

   335 :begin

           ParamListen    :=Toy.Listen
(′queen/1,king/2,prince/3′,DTime,′SR′,′W′);

             case ParamListen of

             1: IntroNextSection := 445;

             2: IntroNextSection := 450;

             3: IntroNextSection := 465;

             else IntroNextSection := 340;

           end;

           Synchronize(UpdateIntroBar);

         end;

   336 :begin

           ParamListen    :=Toy.Listen
(′queen/1,king/2,princess/3′,DTime,′SR′,′W′);

           case ParamListen of

             1: IntroNextSection := 440;

             2: IntroNextSection := 450;

             3: IntroNextSection := 460;
				
				<dp n="d284"/>
          else IntroNextSection := 340;

        end;

        Synchronize(UpdateIntroBar);

      end;
  340 :begin

        ParamTalk    :=Toy.Talk    (PeasPath+′pp340.wav′,′S′);

        Synchronize(UpdatePrincessBar);

        PrincessNextSection := 450;

      end;
  345 :begin

        ParamTalk    :=Toy.Talk    (PeasPath+′pp345.wav′,′S′);

        if GamePrincessStatus = ′Prince′ then PrincessNextSection := 350

        else PrincessNextSection := 400;

        Synchronize(UpdatePrincessBar);

      end;
  350 :begin

        ParamTalk    :=Toy.Talk    (PeasPath+′pp350.wav′,′S′);

        Synchronize(UpdatePrincessBar);

        PrincessNextSection := 405;

      end;
  400 :begin

        ParamTalk    :=Toy.Talk    (PeasPath+′pp400.wav′,′S′);

        Synchronize(UpdatePrincessBar);

        PrincessNextSection := 405;

      end;
  405 :begin

        ParamTalk    :=Toy.Talk    (PeasPath+′pp405.wav′,′S′);

        if GamePrincessStatus = ′Prince′ then PrincessNextSection := 410

        else PrincessNextSection := 420;

        Synchronize(UpdatePrincessBar);

      end;
  410 :begin

        ParamTalk    :=Toy.Talk    (PeasPath+′pp410.wav′,′S′);

        Synchronize(UpdatePrincessBar);

        PrincessNextSection := 430;

      end:
				
				<dp n="d285"/>
 420 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp420.wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 430;

     end;
 425 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp425.wav′,′S′);

       if GamePrincessStatus = ′Prince′  then PrincessNextSection := 430

       else PrincessNextSection := 435;

       Synchronize(UpdatePrincessBar);

     end;
 430 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp430.wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 470;

     end;
 435 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp435.wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 470;

     end;
 440 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp440.wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 470;

     end;
 445 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp445.wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 470;

     end;
 450 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp450.wav′,′S′);

       Synchronize(UpdatePrincessBar);
				
				<dp n="d286"/>
        PrincessNextSection := 470;

     end;
 460 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp460.wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 470;

     end;
 465 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp465.wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 470;

     end;
 469 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp436m.wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 470;

     end;
 470 :begin

       ParamTalk    :=Toy.Talk   (PeasPath+′pp470.wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 472;

     end;
 472 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp472.wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 475;

     end;
 475 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp475.wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 480;

     end;
 480 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp480.wav′,′S′);

       Synchronize(UpdatePrincessBar);
				
				<dp n="d287"/>
       PrincessNextSection := 485;

     end;
 485 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp485.wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 490;
     end;
 490 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp490m.wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 495;

     end;
 495 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp495.wav′,′S′);

       if GamePrincessStatus = ′Prince′ then PrincessNextSection := 505

       else PrincessNextSection := 500;

       Synchronize(UpdatePrincessBar);

     end;
 500 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp500.wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 510;

     end;
 505 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp505.wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 510;

     end;
 510 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp510m. wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 515;

     end;
 515 :begin
				
				<dp n="d288"/>
        ParamTalk    :=Toy.Talk    (PeasPath+′pp515.wav′,′S′);

        if GamePrincessStatus = ′Prince′ then PrincessNextSection := 516

        else PrincessNextSection := 517;

        Synchronize(UpdatePrincessBar);

      end;
  516 :begin

        ParamTalk    :=Toy.Talk    (PeasPath+′pp516m.wav′,′EC′);

        Synchronize(UpdatePrincessBar);

        PrincessNextSection := 520;

      end;
  517 :begin

        ParamTalk    :=Toy.Talk    (PeasPath+′pp517m.wav′,′EC′);

        Synchronize(UpdatePrincessBar);

        PrincessNextSection := 520;

      end;
  518 :begin

        ParamTalk    :=Toy.Talk    (PeasPath+′pp521m.wav′,′EL′);

        Synchronize(UpdatePrincessBar);

        PrincessNextSection := 520;

      end;
  520 :begin

        ParamTalk    :=Toy.Talk    (PeasPath+′pp520.wav′,′S′);

        Synchronize(UpdatePrincessBar);

        PrincessNextSection := 525;

      end;
  525 :begin

        ParamTalk    :=Toy.Talk    (PeasPath+′pp525.wav′,′S′);    //change

        if GamePrincessStatus = ′Prince′ then PrincessNextSection := 535

        else PrincessNextSection := 530;

        Synchronize(UpdatePrincessBar);

      end;
  530 :begin

        ParamTalk    :=Toy.Talk    (PeasPath+′pp530.wav′,′S′);

        Synchronize(UpdatePrincessBar);

        PrincessNextSection := 540;

      end;
				
				<dp n="d289"/>
   535 :begin

         ParamTalk    :=Toy.Talk    (PeasPath+′pp535.wav′,′S′);

         Synchronize(UpdatePrincessBar);

         PrincessNextSection := 545;

       end;
   540 :begin

         ParamTalk    :=Toy.Talk    (PeasPath+′pp540.wav′,′S′);

         Synchronize(UpdatePrincessBar);

         PrincessNextSection :=550;

       end;
   545 :begin

         ParamTalk    :=Toy.Talk    (PeasPath+′pp545.wav′,′S′);

         Synchronize(UpdatePrincessBar);

         PrincessNextSection := 550;

       end;
   550 :begin

         ParamTalk    :=Toy.Talk    (PeasPath+′pp550.wav′,′S′);

         PrincessNextSection   := 555;

         if FavoriteColor = ′Red′     then PrincessNextSection    := 555;

         if FavoriteColor = ′Blue′    then PrincessNextSection    := 565;

         if FavoriteColor = ′Yellow′  then PrincessNextSection    := 560;

         Synchronize(UpdatePrincessBar);

       end;
   555 :begin

         ParamTalk   :=Toy.Talk    (PeasPath+′pp555.wav′,′S′);

         PrincessNextSection   := 575;

         if FavoriteFood = ′Pizza′     then PrincessNextSection   := 575;

         if FavoriteFood = ′FrenchFries′   then PrincessNextSection    :=
580;

         if FavoriteFood = ′MacaroniAndCheese′  then PrincessNextSection
:= 585;

         Synchronize(UpdatePrincessBar);

       end;
   560 :begin

         ParamTalk    :=Toy.Talk    (PeasPath+′pp560.wav′,′S′);

         PrincessNextSection    := 575;
				
				<dp n="d290"/>
           if FavoriteFood = ′Pizza′     then PrincessNextSection    := 575;

           if FavoriteFood = ′FrenchFries′    then PrincessNextSection    :=
580;

           if FavoriteFood = ′MacaroniAndCheese′ then PrincessNextSection
:= 585;

           Synchronize(UpdatePrincessBar);

         end;

   565 :begin

           ParamTalk    :=Toy.Talk    (PeasPath+′pp565.wav′,′S′);

           PrincessNextSection   := 575;

           if FavoriteFood = ′Pizza′     then PrincessNextSection    := 575;

           if FavoriteFood = ′FrenchFries′    then PrincessNextSection   :=
580;

           if FavoriteFood = ′MacaroniAndCheese′ then PrincessNextSection
:= 585;

           Synchronize(UpdatePrincessBar);

         end;

    575:begin

           ParamTalk    :=Toy.Talk    (PeasPath+′pp575.wav′,′S′);

           PrincessNextSection   := 595;

           if FavoriteAnimal = ′Horse′   then PrincessNextSection    := 595;

           if FavoriteAnimal = ′Dog′     then PrincessNextSection    := 600;

           if FavoriteAnimal = ′Cat′     then PrincessNextSection   := 605;

           Synchronize(UpdatePrincessBar);

         end;

   580 :begin

           ParamTalk    :=Toy.Talk    (PeasPath+′pp580.wav′,′S′);

           PrincessNextSection   := 595;

           if FavoriteAnimal = ′Horse′   then PrincessNextSection    := 595;

           if FavoriteAnimal = ′Dog′     then PrincessNextSection    := 600;

           if FavoriteAnimal = ′Cat′     then PrincessNextSection    := 605;

           Synchronize(UPdatePrincessBar);

         end;

   585 :begin

           ParamTalk    :=Toy.Talk    (PeasPath+′pp585.wav′,′S′);

           PrincessNextSection    := 595;

           if FavoriteAnimal = ′Horse′   then PrincessNextSection    := 595;

           if FavoriteAnimal = ′Dog′     then PrincessNextSection    := 600;
				
				<dp n="d291"/>
         if FavoriteAnimal = ′Cat′     then PrincessNextSection   := 605;

         Synchronize(UpdatePrincessBar);

       end;
   595 :begin

         ParamTalk    :=Toy.Talk    (PeasPath+′pp595.wav′,′S′);

         PrincessNextSection    := 610;

         if FavoriteActivity = ′Draw′   then PrincessNextSection    := 610;

         if FavoriteActivity = ′PlayComputerGame′ then PrincessNextSection
 :=615;

         if FavoriteActivity = ′MakeBelieve′    then PrincessNextSection
 :=620;

         Synchronize(UpdatePrincessBar);

       end;
   600 :begin

         ParamTalk    :=Toy.Talk    (PeasPath+′pp600.wav′,′S′);

         PrincessNextSection    := 610;

         if FavoriteActivity = ′Draw′   then PrincessNextSection   := 610;

         if FavoriteActivity = ′PlayComputerGame′ then PrincessNextSection
:= 615;

        if FavoriteActivity = ′MakeBelieve′    then PrincessNextSection
:= 620;

         Synchronize(UpdatePrincessBar);

       end;
   605 :begin

         ParamTalk    :=Toy.Talk    (PeasPath+′pp605.wav′,′S′);

         PrincessNextSection   := 610;

         if FavoriteActivity = ′Draw′   then PrincessNextSection    := 610;

         if FavoriteActivity = ′PlayComputerGame′ then PrincessNextSection
:=615;

         if FavoriteActivity = ′MakeBelieve′    then PrincessNextSection
:=620;

         Synchronize(UpdatePrincessBar);

       end;
   610 :begin

         ParamTalk    :=Toy.Talk    (PeasPath+′pp610.wav′,′S′);

         Synchronize(UpdatePrincessBar);

         PrincessNextSection := 630;
				
				<dp n="d292"/>
     end;
 615 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp615.wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 630;

     end;
 620 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp620.wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 630;

     end;
 630 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp630m. wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := 635;

     end;
 635 :begin

       ParamTalk    :=Toy.Talk    (PeasPath+′pp635.wav′,′S′);

       Synchronize(UpdatePrincessBar);

       PrincessNextSection := -1;

       PresentationNextSection := 4010;

       if (ChildSex = ′Girl′) and (Time > StrToTime(′19:00:00′))  then

         begin

           PrincessNextSection := 640;

           PresentationNextSection := -1;

        end;

       if (ChildSex = ′Boy′) and (Time> StrToTime(′19:00:00′)) then

         begin

           PrincessNextSection := 645;

           PresentationNextSection := -1;

         end;

    end;
640 :begin

      ParamTalk    :=Toy.Talk    (PeasPath+′pp640.wav′,′S′);

      Synchronize(UpdatePrincessBar);

      PrincessNextSection := 650;

    end;
				
				<dp n="d293"/>
  645 :begin

          ParamTalk    :=Toy.Talk    (PeasPath+′pp640.wav′,′S′);

          Synchronize(UpdatePrincessBar);

          PrincessNextSection := 650;

        end;

  650 :begin

          ParamTalk    :=Toy.Talk    (PeasPath+′pp650m.wav′,′S′);

          Synchronize(UpdatePrincessBar);

          PrincessNextSection := -1;

          PresentationNextSection := 4010;

        end;

   {else

        begin

          Terminate;

          Exit;

        end;   }

    end;
//-------end of "The Princess and the Pea" sesions--------
{*
// =========The Story Menu  ============
//------------------  write here all  sessions---------------
// =============================

     case TheStoryMenuNextSection of

       1 :begin

             {sleep(300);

             ParamTalk  :=Toy.Talk    (StoryMenuPath+′in001.wav′,′E′);

             Paramisten :=Toy.Listen  (′yes/1,no,2′,1.5,′SR and Sensor′);  }

             TheStoryMenuNextSection := 5;

          end;

       5:begin

            ParamTalk   :=Toy.Talk    (StoryMenuPath+′pp005.wav′,′S′);

            Synchronize(UpdateTheStoryMenuBar);

            TheStoryMenuNextSection := 10;

          end;
				
				<dp n="d294"/>
 10 :begin

      ParamTalk    :=Toy.Talk   (StoryMenuPath+′pp005.wav′,′S′);

      Synchronize(UpdateTheStoryMenuBar);

      TheStoryMenuNextSection := 5;

    end;
 15 :begin

      ParamTalk    :=Toy.Talk    (StoryMenuPath+′pp005.wav′,′S′);

      Synchronize(UpdateTheStoryMenuBar);

      TheStoryMenuNextSection := -1;

    end;
 20 :begin

      ParamTalk    :=Toy.Talk    (StoryMenuPath+′pp005.wav′,′S′);

      Synchronize(UpdateTheStoryMenuBar);

      TheStoryMenuNextSection := 10;

    end;
 25 :begin

      ParamTalk    :=Toy.Talk    (StoryMenuPath+′pp005.wav′,′S′);

      Synchronize(UpdateTheStoryMenuBar);

      TheStoryMenuNextSection := 10;

    end;
 30 :begin

      ParamTalk    :=Toy.Talk    (StoryMenuPath+′pp005.wav′,′S′);

      Synchronize(UpdateTheStoryMenuBar);

      TheStoryMenuNextSection := 5;

    end;
 31 :begin

      ParamTalk    :=Toy.Talk    (StoryMenuPath+′pp005.wav′,′S′);

      Synchronize(UpdateTheStoryMenuBar);

      TheStoryMenuNextSection := -1;

    end;
 35 :begin

      ParamTalk    :=Toy.Talk    (StoryMenuPath+′pp005.wav′,′S′);

      Synchronize(UpdateTheStoryMenuBar);

      TheStoryMenuNextSection := 10;
				
				<dp n="d295"/>
    end;
 36 :begin

      ParamTalk    :=Toy.Talk    (StoryMenuPath+′pp005.wav′,′S′);

      Synchronize(UpdateTheStoryMenuBar);

      TheStoryMenuNextSection := 10;

    end;
 37 :begin

      ParamTalk    :=Toy.Talk    (StoryMenuPath+′pp005.wav′,′S′);

      Synchronize(UpdateTheStoryMenuBar);

      TheStoryMenuNextSection := 5;

    end;
 40 :begin

      ParamTalk    :=Toy.Talk    (StoryMenuPath+′pp005.wav′,′S′);

      Synchronize(UpdateTheStoryMenuBar);

      TheStoryMenuNextSection := -1;

    end;
 45 :begin

      ParamTalk    :=Toy.Talk    (StoryMenuPath+′pp005.wav′,′S′);

      Synchronize(UpdateTheStoryMenuBar);

      TheStoryMenuNextSection := 10;

    end;
 50 :begin

      ParamTalk    :=Toy.Talk    (StoryMenuPath+′pp005.wav′, ′S′);

      Synchronize(UpdateTheStoryMenuBar);

      TheStoryMenuNextSection := 10;

    end;
 55 :begin

      ParamTalk    :=Toy.Talk    (StoryMenuPath+′pp005.wav′,′S′);

      Synchronize(UpdateTheStoryMenuBar);

      TheStoryMenuNextSection := 5;

    end;
 60 :begin

      ParamTalk   :=Toy.Talk    (StoryMenuPath+′pp005.wav′,′S′);

      Synchronize(UpdateTheStoryMenuBar);
				
				<dp n="d296"/>
      TheStoryMenuNextSection ;= -1;

    end;
 65 :begin

      ParamTalk    :=Toy.Talk    (StoryMenuPath+′pp005.wav′,′S′);

      Synchronize(UpdateTheStoryMenuBar);

      TheStoryNenuNextSection := 10;

    end;
 70 :begin

      ParamTalk    :=Toy.Talk    (StoryMenuPath+′pp005.wav′,′S′);

      Synchronize(UpdateTheStoryMenuBar);

      TheStoryMenuNextSection := 10;

    end;
 75 :begin

      ParamTalk    :=Toy.Talk   (StoryMenuPath+′pp005.wav′,′S′);

      Synchronize(UpdateTheStoryMenuBar);

      TheStoryMenuNextSection := 5;

    end;
 80 :begin

      ParamTalk    :=Toy.Talk    (StoryMenuPath+′pp005.wav′,′S′);

      Synchronize(UpdateTheStoryMenuBar);

      TheStoryMenuNextSection := -1;

    end;
 85 :begin

      ParamTalk    :=Toy.Talk    (StoryMenuPath+′pp005.wav′,′S′);

      Synchronize(UpdateTheStoryMenuBar);

      TheStoryMenuNextSection := 10;

    end;
 90 :begin

      ParamTalk    := Toy. Talk    (StoryMenuPath+′pp005.wav′,′S′);

      Synchronize(UpdateTheStoryMenur);

      TheStoryMenuNextSection := 10;

    end;
 95 :begin

      ParamTalk    :=Toy.Talk   (StoryMenuPath+′pp005.wav′,′S′);

      Synchronize(UpdateTheStoryMenuBar);

                  370
				
				<dp n="d297"/>
        TheStoryMenuNextSection := 5;

      end;
  100 :begin

        ParamTalk    :=Toy.Talk    (StoryMenuPath+′pp005.wav′,′S′);

        Synchronize(UpdateTheStoryMenuBar);

        TheStoryMenuNextSection := -1;

      end;
  105 :begin

        ParamTalk    :=Toy.Talk    (StoryMenuPath+′pp005.wav′,′S′);

        Synchronize(UpdateTheStoryMenuBar);

        TheStoryMenuNextSection := 10;

      end;
  110 :begin

        ParamTalk    :=Toy.Talk    (StoryMenuPath+′pp005.wav′,′S′);

        Synchronize(UpdateTheStoryMenuBar);

        TheStoryMenuNextSection := 10;

      end;
  115 :begin

        ParamTalk    :=Toy.Talk    (StoryMenuPath+′pp005.wav′,′S′);

        Synchronize(UpdateTheStoryMenuBar);

        TheStoryMenuNextSection := 5;

      end;
  120 :begin

        ParamTalk    :=Toy.Talk    (StoryMenuPath+′pp005.wav′,′S′);

        Synchronize(UpdateTheStoryMenuBar);

        TheStoryMenuNextSection := -1;

      end;
  125 :begin

        ParamTalk    :=Toy.Talk    (StoryMenuPath+′pp005.wav′,′S′);

        Synchronize(UpdateTheStoryMenuBar);

        TheStoryMenuNextSection := 10;

      end;

  end;
//-------------------end of "The Story Menu" sesions-------------
				
				<dp n="d298"/>
//========== Run -  Story Menu   ==================
//------------------write here all sessions------------------------------------
/ / ======================================

   case RunStoryMenuNextSection of

    1 :begin

          {sleep(300);

          ParamTalk    :=Toy.Talk    (RunStoryPath+′in001.wav′,′E′);

          ParamListen  :=Toy.Listen (′yes/1,no,2′,1.5,′SR and Sensor′); }

          RunStoryMenuNextSection := 5;

        end;

    5 :begin

          ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

          Synchronize(UpdateRunStoruyMenuBar);

          RunStoryMenuNextSection := 10;

        end;

   10 :begin

          ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

          Synchronize (UpdateRunStoryMenuBar);

          RunStoryMenuNextSection := 5;

        end;

   15 :begin

          ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

          Synchronize(UpdateRunStoryMenuBar);

          RunStoryMenuNextSection := -1;

        end;

   20 :begin

          ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

          Synchronize(UpdateRunStoryMenuBar);

          RunStoryMenuNextSection := 10;

        end;

   25 :begin

          ParamTalk    :=Toy.Talk    (RunStoryPath+′pp00S.wav′,′S′);

          Synchronize(UpdateRunStoryMenuBar);

          RunStoryMenuNextSection := 10;

        end;
				
				<dp n="d299"/>
  30 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

       Synchronize(UpdateRunStoryMenuBar);

       RunStoryMenuNextSection := 5;

     end;
  31 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

       Synchronize(UpdateRunStoryMenuBar);

       RunStoryMenuNextSection := -1;

     end;
  35 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

       Synchronize(UpdateRunStoryMenuBar);

       RunStoryMenuNextSection := 10;

     end;
  36 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

       Synchronize(UpdateRunStoryMenuBar);

       RunStoryMenuNextSection := 10;

     end;
  37 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

       Synchronize(UpdateRunStoryMenuBar);

       RunStoryMenuNextSection := 5;

     end;
  40 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

       Synchronize(UpdateRunStoryMenuBar);

       RunStoryMenuNextSection := -1;

     end;
  45 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

       Synchronize(UpdateRunStoryMenuBar);

       RunStoryMenuNextSection := 10;
				
				<dp n="d300"/>
    end;
 50 :begin

      ParamTalk    :=Toy.Talk    (RunStoryPath+′PP115.wav′,′S′);

      Synchronize(UpdateRunStoryMenuBar);

      RunStoryMenuNextSection := 10;

    end;
 55 :begin

      ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

      Synchronize(UpdateRunStoryMenuBar);

      RunStoryMenuNextSection := 5;

    end;
 60 :begin

      ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

      Synchronize(UpdateRunStoryMenuBar);

      RunStoryMenuNextSection := -1;

    end;
 65 :begin

      ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

      Synchronize(UpdateRunStoryMenuBar);

      RunStoryMenuNextSection := 10;

    end;
 70 :begin

      ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

      Synchronize(UpdateRunStoryMenuBar);

      RunStoryMenuNextSection := 10;

    end;
 75 :begin

      ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

      Synchronize(UpdateRunStoryMenuBar);

      RunStoryMenuNextSection := 5;

    end;
 80 :begin

      ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

      Synchronize(UpdateRunStoryMenuBar);
				
				<dp n="d301"/>
       RunStoryMenuNextSection := -1;

     end;
  85 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

       Synchronize(UpdateRunStoryMenuBar);

       RunStoryMenuNextSection := 10;

     end;
  90 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

       Synchronize(UpdateRunStoryMenuBar);

       RunStoryMenuNextSection := 10;

     end;
  95 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′, ′S′);

       Synchronize(UpdateRunStoryMenuBar);

       RunStoryMenuNextSection := 5;

     end;
 100 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

       Synchronize(UpdateRunStoryMenuBar);

       RunStoryMenuNextSection := -1;

     end;
 105 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

       Synchronize(UpdateRunStoryMenuBar);

       RunStoryMenuNextSection := 10;

     end;
 110 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

       Synchronize(UpdateRunStoryMenuBar);

       RunStoryMenuNextSection := 10;

     end;
 115 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

       Synchronize(UpdateRunStoryMenuBar);
				
				<dp n="d302"/>
       RunStoryMenuNextSection := 5;

     end;
 120 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

       Synchronize(UpdateRunStoryM=nuBar);

       RunStoryMenuNextSection := -1;

     end;
 121 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

       Synchronize(UpdateRunStoryMenuBar);

       RunStoryMenuNextSection := 10;

     end;
 122 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

       Synchronize(UpdateRunStoryMenuBar);

       RunStoryMenuNextSection := 10;

     end;
 123 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

       Synchronize(UpdateRunStoryMenuBar);

       RunStoryMenuNextSection := 10;

     end;
 130 :begin

       ParamTalk    :=Toy.Talk   (RunStoryPath+′pp005.wav′,′S′);

       Synchronize(UpdateRunStoryMenuBar);

       RunStoryMenuNextSection := -1;

     end;
 135 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

       Synchronize(UpdateRunStoryMenuBar);

       RunStoryMenuNextSection := 10;

     end;
 140 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

       Synchronize(UpdateRunStoryMenuBar);
				
				<dp n="d303"/>
       RunStoryMenuNextSection := 10;

     end;
 145 :begin

       ParamTalk    :=Toy.Talk   (RunStoryPath+′pp005.wav′,′S′);

       Synchronize(UpdateRunStoryMenuBar);

       RunStoryMenuNextSection := 5;

     end;
 150 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

       Synchronize(UpdateRunStoryMenuBar);

       RunStoryMenuNextSection := -1;

     end;
 155 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

       Synchronize(UpdateRunStoryMenuBar);

       RunStoryMenuNextSection := 10;

     end;
 160 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

       Synchronize(UpdateRunStoryMenuBar);

       RunStoryMenuNextSection := 10;

     end;
 165 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp00S.wav′,′S′);

       Synchronize(UpdateRunStoryMenuBar);

       RunStoryMenuNextSection := 10;

     end;
 170 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

       Synchronize(UpdateRunStoryMenuBar);

       RunStoryMenuNextSection := 5;

     end;
 175 :begin

       ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);
				
				<dp n="d304"/>
         Synchronize(UpdateRunStoryMenuBar);

         RunStoryMenuNextSection := -1;

       end;
   180 :begin

         ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

         Synchronize(UpdateRunStoryMenuBar);

         RunStoryMenuNextSection := 10;

       end;
   185 :begin

         ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

         Synchronize(UpdateRunStoryMenuBar);

         RunStoryMenuNextSection := 10;

       end;
   190 :begin

         ParamTalk    :=Toy.Talk    (RunStoryPath+′pp005.wav′,′S′);

         Synchronize(UpdateRunStoryMenuBar);

         RunStoryMenuNextSection := 10;

       end;
   end;
//----------------end of "Run-Story Menu" sesions------------
//= ======Bunny ====================
//-------------write here all  sessions------------------------
//===============================

  case BunnyNextSection of

   1 :begin

         {sleep(300);

         ParamTalk    :=Toy.Talk    (BunnyPath+′in001.wav′,′E′);

         ParamListen  :=Toy.Listen (′yes/1,no,2′,1.5,′SR and Sensor′); }

         BunnyNextSection := 5;

       end;

   5 :begin

         ParamTalk    :=Toy.Talk    (BunnyPath+′rb005.wav′,′S′);

         Synchronize(UpdateBunnyBar);

         BunnyNextSection := 10;

       end;
				
				<dp n="d305"/>
  10 :begin

       ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

       Synchronize(UpdateBunnyBar);

       BunnyNextSection := 5;

     end;
  15 :begin

       ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

       Synchronize(UpdateBunnyBar);

       BunnyNextSection := -1;

     end;
  25 :begin

       ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

       Synchronize(UpdateBunnyBar);

       BunnyNextSection := 10;

     end;
  26 :begin

       ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

       Synchronize(UpdateBunnyBar);

       BunnyNextSection := 10;

     end;
 301 :begin

       ParamTalk    :=Toy. Talk   (BunnyPath+′pp005.wav′,′S′);

       Synchronize(UpdateBunnyBar);

       BunnyNextSection := 5;

     end;
 302 :begin

       ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

       Synchronize(UpdateBunnyBar);

       BunnyNextSection := -1;

     end;
 303 :begin

       ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

       Synchronize(UpdateBunnyBar);

       BunnyNextSection := 10;

     end;
				
				<dp n="d306"/>
  40 :begin

         ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

         Synchronize(UpdateBunnyBar);

         BunnyNextSection := -1;

       end;

  45 :begin

         ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

         Synchronize(UpdateBunnyBar);

         BunnyNextSection := 10;

       end;

  50 :begin

         ParamTalk    :=Toy.Talk   (BunnyPath+′pp005.wav′,′S′);

         Synchronize(UpdateBunnyBar);

         BunnyNextSection := 10;

       end;

  55 :begin

         ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′); //choose
in 551-553

         Synchronize(UpdateBunnyBar);

         BunnyNextSection := 5;

       end;

  60 :begin

         ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

         Synchronize(UpdateBunnyBar);

         BunnyNextSection := -1;

       end;

  65 :begin

         ParamTalk    :=Toy.Talk   (BunnyPath+′pp005.wav′,′S′);

         Synchronize(UpdateBunnyBar);

         BunnyNextSection := 10;

       end;

  70 :begin

         ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

         Synchronize(UpdateBunnyBar);

         BunnyNextSection := 10;

       end;
				
				<dp n="d307"/>
   75 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp00S.wav′,′S′);//choose in
 751-753

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 5;

        end;

   80 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := -1;

        end;

   85 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);//choose in
851-853

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 10;

        end;
   90 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 10;

        end;

  100 :begin

          ParamTalk    :=Toy.Talk   (BunnyPath+′pp005.wav′,′S′);//choose in
1001-1003

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := -1;

        end;

  105 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 10;

        end;
				
				<dp n="d308"/>
  110 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 10;

        end;

  115 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 5;

        end;

  120 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := -1;

        end;

  125 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 10;

        end;

  130 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 10;

        end;

  135 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);//choose in
1351-1353

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 5;

        end;

  150 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);
				
				<dp n="d309"/>
          BunnyNextSection  := 10;

        end;

  155 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 5;

        end;

  160 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := -1;

        end;

  165 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 10;

        end;

  166 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 10;

        end;

  171 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 5;

        end;

  180 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′); //choose
in 1802-18010

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 10;

        end;

  185 :begin
				
				<dp n="d310"/>
           ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′

           Synchronize(UpdateBunnyBar);

           BunnyNextSection := 10;

         end;

   190 :begin

           ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′); //choose
  in 1901-1903

           Synchronize(UpdateBunnyBar);

           BunnyNextSection := 5;

         end;

   195 :begin

           ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

           Synchronize(UpdateBunnyBar);

           BunnyNextSection := -1;

         end;

   200 :begin

           ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

           Synchronize(UpdateBunnyBar);

           BunnyNextSection := 10;

         end;

   205 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

           Synchronize(UpdateBunnyBar);

           BunnyNextSection := 10;

         end;

   220 :begin

           ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

           Synchronize(UpdateBunnyBar);

           BunnyNextSection := 10;

         end;

   225 :begin

           ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);//choose in
2251-2253

           Synchronize(UpdateBunnyBar);

           BunnyNextSection := 10;

         end;
				
				<dp n="d311"/>
  230 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := -1;

        end;

  235 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 10;

        end;

  240 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 10;

        end;

  245 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 5;

        end;

  250 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := -1;

        end;

  255 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);//choose in
2551-25510

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 10;

        end;

  260 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 10;

        end;
				
				<dp n="d312"/>
  265 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);//choose in
 2651-2653

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 5;

        end;

  270 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := -1;

        end;

  275 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);//choose in
 2751-2753

          Synchronize(UpdateBunnyBar);
          BunnyNextSection := 10;

        end;

  280 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 10;

        end;

  285 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 5;

        end;

  290 :begin

          ParamTalk    :=Toy.Talk   (BunnyPath+′pp005.wav′,′S′);//choose in
2901-2903

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := -1;

        end;
  295 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);
				
				<dp n="d313"/>
         Synchronize(UpdateBunnyBar);

         BunnyNextSection := 10;

         end;
   296 :begin

         ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);//choose in
2961-2963

         Synchronize(UpdateBunnyBar);

         BunnyNextSection := 10;

       end;
   300 :begin

         ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

         Synchronize(UpdateBunnyBar);

         BunnyNextSection := 10;

       end;
   305 :begin

         ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);//choose in
3051-3053

         Synchronize(UpdateBunnyBar);

         BunnyNextSection := 5;

        end;
   315 :begin

         ParamTalk    :=Toy.Talk   (BunnyPath+′pp005.wav′,′S′);

         Synchronize(UpdateBunnyBar);

         BunnyNextSection := 10;

       end;
   320 :begin

         ParamTalk    :=Toy.Talk   (BunnyPath+′pp005.wav′,′S′);

         Synchronize(UpdateBunnyBar);

         BunnyNextSection := 10;

       end;
   330 :begin

         ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

         Synchronize(UpdateBunnyBar);

         BunnyNextSection := 10;

       end;
				
				<dp n="d314"/>
  335 :begin

        ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

        Synchronize(UpdateBunnyBar);

        BunnyNextSection := 5;

      end;
  345 :begin

        ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

        Synchronize(UpdateBunnyBar);

        BunnyNextSection := 10;

      end;
  350 :begin

        ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

        Synchronize(UpdateBunnyBar);

        BunnyNextSection := 5;

      end;
  355 :begin

        ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

        Synchronize(UpdateBunnyBar);

        BunnyNextSection := 5;

      end;
  360 :begin

        ParamTalk    :=Toy.Talk   (BunnyPath+′pp005.wav′,′S′);

        Synchronize(UpdateBunnyBar);

        BunnyNextSection := 5;

      end;
  365 :begin

        ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

        Synchronize(UpdateBunnyBar);

        BunnyNextSection := 5;

      end;
  370 :begin

        ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

        Synchronize(UpdateBunnyBar);

        BunnyNextSection := 5;

      end;
				
				<dp n="d315"/>
  375 :begin

        ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′  ′S′);

        Synchronize(UpdateBunnyBar);

        BunnyNextSection := 5;

      end;
  380 :begin

        ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′  ′S′);

        Synchronize(UpdateBunnyBar);

        BunnyNextSection := 5;

      end;
  382 :begin

        ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′  ′S′);

       Synchronize(UpdateBunnyBar);

        BunnyNextSection := 5;

      end;
  385 :begin

        ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′  ′S′);

        Synchronize(UpdateBunnyBar);

       BunnyNextSection := 5;

      end;
  390 :begin

        ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′  ′S′);

        Synchronize(UpdateBunnyBar);

        BunnyNextSection := 5;

      end;
  395 :begin
        ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

        Synchronize(UpdateBunnyBar);

        BunnyNextSection := 5;

      end;
  400 :begin

        ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′  ′S′);

        Synchronize(UpdateBunnyBar);

        BunnyNextSection := -1;

      end;
  405 :begin
				
				<dp n="d316"/>
          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 10;

        end;

  410 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 10;
        end;

  415 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′); //choose
in 4151-4153

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 10;

        end;

  420 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′); //choose
in 4201-4203

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 10;

        end;

  425 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 5;

        end;

  435 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 10;

        end;

  440 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 10;

        end;
				
				<dp n="d317"/>
  445 :begin

          ParamTalk    :=Toy.Talk    (BunnyPath+′pp005.wav′,′S′);

          Synchronize(UpdateBunnyBar);

          BunnyNextSection := 5;

        end;

    {else

        begin

           Terminate;

          Exit;

        end;   }

    end;
//----------------end of "Bunny" sesions -----------------
//======== Grouchy=================
//--------------write here all sessions---------------------
//=============================

  case GrouchyNextSection of

   1 :begin

         {sleep(300);

         ParamTalk    :=Toy.Talk    (GrouchyPath+′in001.wav′,′E′);

         ParamTisten  :=Toy.Listen (′yes/1, no,2′,1.5,′SR and Sensor′); }

         GrouchyNextSection := 5;

       end;

   5 :begin

         ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

         Synchronize(UpdateGrouchyBar);

         GrouchyNextSection := 10;

       end;

  10 :begin

         ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

         Synchronize(UpdateGrouchyBar);

         GrouchyNextSection := 5;

       end;

  15 :begin
				
				<dp n="d318"/>
       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := -1;

     end;
  20 :begin

       ParamTalk    :=Toy.Talk     (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := 10;

     end;
  25 :begin

       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := 10;

     end;
  30 :begin

       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := 5;

     end;
  31 :begin

       ParamTalk    :=Toy.Talk     (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := -1;

     end;
  35 :begin

       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := 10;

     end;
  36 :begin

       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := 10;

     end;
  37 :begin
				
				<dp n="d319"/>
      ParamTalk     :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

      Synchronize(UpdateGrouchyBar);

      GrouchyNextSection := 5;

    end;
 40 :begin

      ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

      Synchronize(UpdateGrouchyBar);

      GrouchyNextSection := -1;

    end;
 45 :begin

      ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

      Synchronize(UpdateGrouchyBar);

      GrouchyNextSection := 10;

    end;
 50 :begin

      ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

      Synchronize(UpdateGrouchyBar);

      GrouchyNextSection := 10;

    end;
 55 :begin

      ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

      Synchronize(UpdateGrouchyBar);

      GrouchyNextSection := 5;

    end;
 60 :begin

      ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

      Synchronize(UpdateGrouchyBar);

      GrouchyNextSection := -1;

    end;
 65 :begin

      ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

      Synchronize(UpdateGrouchyBar);

      GrouchyNextSection := 10;

    end;
				
				<dp n="d320"/>
  70 :begin

       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := 10;

     end;
  75 :begin

       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := 5;

     end;
  80 :begin

       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := -1;

     end;
  85 :begin

       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := 10;

     end;
  90 :begin

       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := 10;

     end;
  95 :begin

       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);
       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := 5;

     end;
 100 :begin

       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := -1;

     end;
				
				<dp n="d321"/>
  105 :begin

        ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

        Synchronize(UpdateGrouchyBar);

        GrouchyNextSection := 10;

      end;
  110 :begin

        ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

        Synchronize(UpdateGrouchyBar);

        GrouchyNextSection := 10;

      end;
  115 :begin

        ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

        Synchronize(UpdateGrouchyBar);

        GrouchyNextSection := 5;

      end;
  120 :begin

        ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

        Synchronize(UpdateGrouchyBar);

        GrouchyNextSection := -1;

      end; 
  125 :begin

        ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

        Synchronize(UpdateGrouchyBar);

        GrouchyNextSection := 10;

      end;
  130 :begin

        ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

        Synchronize(UpdateGrouchyBar);

        GrouchyNextSection := 10;

      end;
  135 :begin

        ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

        Synchronize(UpdateGrouchyBar);

        GrouchyNextSection := 5;

      end;
				
				<dp n="d322"/>
  140 :begin

        ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

        Synchronize(UpdateGrouchyBar);

        GrouchyNextSection := -1;

      end;
  145 :begin

        ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

        Synchronize(UpdateGrouchyBar);

        GrouchyNextSection := 10;

      end; 
  150 :begin

        ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

        Synchronize(UpdateGrouchyBar);

        GrouchyNextSection := 10;

      end;
  155 :begin

        ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

        Synchronize(UpdateGrouchyBar);

        GrouchyNextSection := 5;

      end;
  160 :begin

        ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

        Synchronize(UpdateGrouchyBar);

        GrouchyNextSection := -1;

      end;
  165 :begin

        ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

        Synchronize(UpdateGrouchyBar);

        GrouchyNextSection := 10;

      end;
  170 :begin

        ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

        Synchronize(UpdateGrouchyBar);

        GrouchyNextSection := 10;

      end;
				
				<dp n="d323"/>
  171 :begin

        ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

        Synchronize(UpdateGrouchyBar);

        GrouchyNextSection := 5;

      end;
  175 :begin

        ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

        Synchronize(UpdateGrouchyBar);

        GrouchyNextSection := -1;

      end;
  180 :begin

        ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

        Synchronize(UpdateGrouchyBar);

        GrouchyNextSection := 10;

      end;
  185 :begin

        ParamTalk    :=Toy.Talk   (GrouchyPath+′pp005.wav′,′S′);

        Synchronize(UpdateGrouchyBar);

        GrouchyNextSection := 10;

      end;
  190 :begin

        ParamTalk    :=Toy.Talk   (GrouchyPath+′pp005.wav′,′S′);

        Synchronize(UpdateGrouchyBar);

        GrcuchyNextSection := 5;

      end;
  195 :begin

        ParamTalk    :=Toy.Talk   (GrouchyPath+′pp005.wav′,′S′);

        Synchronize(UpdateGrouchyBar);

        GrouchyNextSection := -1;

      end;
  200 :begin

        ParamTalk   :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

        Synchronize(UpdateGrouchyBar);

        GrouchyNextSection := 10;

      end;
				
				<dp n="d324"/>
 205 :begin

       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := 10;

     end;
 210 :begin

       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := 5;

     end;
 215 :begin

       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := -1;

     end;
 220 :begin

       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := 10;

     end;
 225 :begin

       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := 10;

     end;
 226 :begin

       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := 5;

     end;
 230 :begin

                                                            

       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := -1;

     end;
				
				<dp n="d325"/>
 235 :begin

       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := 10;

     end;
 240 :begin

       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := 10;

     end;
 245 :begin

       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′  ;

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := 5;

     end;
 250 :begin

       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);
       GrouchyNextSection := -1;

     end;
 255 :begin

       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := 10;

     end;
 260 :begin

       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := 10;

     end;
 265 :begin

       ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

       Synchronize(UpdateGrouchyBar);

       GrouchyNextSection := 5;

     end;
				
				<dp n="d326"/>
   270 :begin

         ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

         Synchronize(UpdateGrouchyBar);

         GrouchyNextSection := -1;

       end;
   275 :begin

         ParamTalk    :=Toy.Talk    (GrouchyPath+′pp005.wav′,′S′);

         Synchronize(UpdateGrouchyBar);

         GrouchyNextSection := 10;

       end;

   {else

       begin

          Terminate;

          Exit;

        end;   }

    end;
//------------end of "Grouchy" sesions--------------------
//====== BedTimeRitual  ===============
//----------write here all  sessions------------------------
// ============================

   case BedTimeRitualNextSection of

    1 :begin

          {sleep(300);

          ParamTalk   :=Toy.Talk    (BedTimePath+′in001.wav′,′E′);

          ParamListen   :=Toy.Listen  (′yes/1,no,2′,1.5,′SR and Sensor′);  }

          BedTimeRitualNextSection := 5;

        end;

    5 :begin

          ParamTalk   :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

          Synchronize(UpdateBedTimeRitualBar);

          BedTimeRitualNextSection := 10;

        end;

   10 :begin

          ParamTalk   :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

          Synchronize(UpdateBedTimeRitualBar);
				
				<dp n="d327"/>
      BedTimeRitualNextSection := 5;

    end;
 15 :begin

      ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

      Synchronize(UpdateBedTimeRitualBar);

      BedTimeRitualNextSection := -1;

    end;
 20 :begin

      ParamTalk   :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

      Synchronize(UpdateBedTimeRitualBar);

      BedTimeRitualNextSection := 10;

    end;
 25 :begin

      ParamTalk    :=Toy.Talk   (BedTimePath+′pp005.wav′,′S′);

      Synchronize(UpdateBedTimeRitualBar);

      BedTimeRitualNextSection := 10;

    end;
 30 :begin

      ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

      Synchronize(UpdateBedTimeRitualBar);

      BedTimeRitualNextSection := 5;

    end;
 31 :begin

      ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

      Synchronize(UpdateBedTimeRitualBar);

      BedTimeRitualNextSection := -1;

    end;
 35 :begin

      ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

      Synchronize(UpdateBedTimeRitualBar);

      BedTimeRitualNextSection := 10;

    end;
 36 :begin

      ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);
				
				<dp n="d328"/>
      Synchronize(UpdateBedTimeRitualBar);

      BedTimeRitualNextSection := 10;

    end;
 37 :begin

      ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

      Synchronize(UpdateBedTimeRitualBar);

      BedTimeRitualNextSection := 5;

    end;
 40 :begin

      ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

      Synchronize(UpdateBedTimeRitualBar);

      BedTimeRitualNextSection := -1;

    end;
 45 :begin

      ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

      Synchronize(UpdateBedTimeRitualBar);

      BedTimeRitualNextSection := 10;

    end;
 50 :begin

      ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

      Synchronize(UpdateBedTimeRitualBar);

      BedTimeRitualNextSection := 10;

    end;
 55 :begin

      ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

      Synchronize(UpdateBedTimeRitualBar);

      BedTimeRitualNextSection := 5;

    end;
 60 :begin

      ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

      Synchronize(UpdateBedTimeRitualBar);

      BedTimeRitualNextSection := -1;

    end;
 65 :begin
				
				<dp n="d329"/>
      ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

      Synchronize(UpdateBedTimeRitualBar);

      BedTimeRitualNextSection := 10;

    end;
 70 :begin

      ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

      Synchronize(UpdateBedTimeRitualBar);

      BedTimeRitualNextSection := 10;

    end;
 75 :begin

      ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

      Synchronize(UpdateBedTimeRitualBar);

      BedTimeRitualNextSection := 5;

    end;
 80 :begin

      ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

      Synchronize(UpdateBedTimeRitualBar);

      BedTimeRitualNextSection := -1;

    end;
 85 :begin

      ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

      Synchronize(UpdateBedTimeRitualBar);

      BedTimeRitualNextSection := 10;

    end;
 90 :begin

      ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

      Synchronize(UpdateBedTimeRitualBar);

      BedTimeRitualNextSection := 10;

    end;
 95 :begin

      ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

      Synchronize(UpdateBedTimeRitualBar);

      BedTimeRitualNextSection := 5;

    end;
				
				<dp n="d330"/>
 100 :begin

       ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

       Synchronize(UpdateBedTimeRitualBar);

       BedTimeRitualNextSection := -1;

     end;
 105 :begin

       ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

       Synchronize(UpdateBedTimeRitualBar);

       BedTimeRitualNextSection := 10;

     end;
 110 :begin

       ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

       Synchronize(UpdateBedTimeRitualBar);

       BedTimeRitualNextSection := 10;

     end;
 115 :begin

       ParamTalk    :=Toy.Talk   (BedTimePath+′pp005.wav′,′S′);

       Synchronize(UpdateBedTimeRitualBar);

       BedTimeRitualNextSection := 5;

     end;
 120 :begin

       ParamTalk    :=Toy. Talk   (BedTimePath+′pp005.wav′,′S′);

       Synchronize(UpdateBedTimeRitualBar);

       BedTimeRitualNextSection := -1;

     end;
 125 :begin

       ParamTalk    := Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

       Synchronize(UpdateBedTimeRitualBar);

       BedTimeRitualNextSection := 10;

     end;
 130 :begin

       ParamTalk    := Toy. Talk    (BedTimePath+′pp005.wav′,′S′);

       Synchronize(UpdateBedTimeRitualBar);

       BedTimeRitualNextSection := 10;

     end;
				
				<dp n="d331"/>
  135 :begin

        ParamTalk    :=Toy.Talk   (BedTimePath+′pp005.wav′,′S′);

        Synchronize(UpdateBedTimeRitualBar);

        BedTimeRitualNextSection := 5;

      end;
  140 :begin

        ParamTalk    :=Toy.Talk   (BedTimePath+′pp005.wav′,′S′);

        Synchronize (UpdateBedTimeRitualBar);

        BedTimeRitualNextSection := -1;

      end;
  145 :begin

        ParamTalk    :=Toy.Talk   (BedTimePath+′pp005.wav′,′S′);

        Synchronize(UpdateBedTimeRitualBar);

        BedTimeRitualNextSection := 10;

      end;
  150 :begin

        ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

        Synchronize(UpdateBedTimeRitualBar);

        B edTimeRitualNextSection := 10;

      end;
  155 :begin

        ParamTalk    :=Toy.Talk  (BedTimePath+′pp005.wav′,′S′);

        Synchronize(UpdateBedTimeRitualBar);

        BedTimeRitualNextSection := 5;

       end;
  160 :begin

        ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

        Synchronize(UpdateBedTimeRitualBar);

        BedTimeRitualNextSection := -1;

      end;
  165 :begin

        ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

        Synchronize(UpdateBedTimeRitualBar);

        BedTimeRitualNextSection := 10;

      end;
				
				<dp n="d332"/>
  170 :begin

       ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

        Synchronize(UpdateBedTimeRitualBar);

        BedTimeRitualNextSection := 10;

      end;
  171 :begin

        ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

        Synchronize(UpdateBedTimeRitualBar);

        BedTimeRitualNextSection := 5;

      end;
  175 :begin

        ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

        Synchronize(UpdateBedTimeritualBar);

        BedTimeRitualNextSection := -1;

      end;
  180 :begin

        ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

        Synchronize(UpdateBedTimeRitualBar);

        BedTimeRitualNextSection := 10;

      end;
 185 :begin

       ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

       Synchronize(UpdateBedTimeRitualBar);

       BedTimeRitualNextSection := 10;

     end;
 190 :begin

       ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

       Synchronize(UpdateBedTimeRitualBar);

       BedTimeRitualNextSection := 5;

     end;
 195 :begin

       ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

       Synchronize(UpdateBedTimeRitualBar);

       BedTimeRitualNextSection := -1;

     end;
				
				<dp n="d333"/>
 200 :begin

       ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

       Synchronize(UpdateBedTimeRitualBar);

       BedTimeRitualNextSection := 10;

     end;
 205 :begin

       ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

       Synchronize(UpdateBedTimeRitualBar);
       BedTimeRitualNextSection := 10;

     end;
 210 :begin

       ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

       Synchronize(UpdateBedTimeRitualBar);

       BedTimeRitualNextSection := 5;

     end;
 215 :begin

       ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

       Synchronize(UpdateBedTimeRitualBar);

       BedTimeRitualNextSection := -1;

     end;
 220 :begin

       ParamTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

       Synchronize(UpdateBedTimeRitualBar);

       BedTimeRitualNextSection := 10;

     end;
 225 :begin

       ParamTalk    := Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

       Synchronize(UpdateBedTimeRitualBar);

       BedTimeRitualNextSection := 10;

     end;
 226 :begin

       PeramTalk    :=Toy.Talk    (BedTimePath+′pp005.wav′,′S′);

       Synchronize(UpdateBedTimeRitualBar);

       BedTimeRitualNextSection := 5;

     end;
				
				<dp n="d334"/>
  230 :begin

        ParamTalk  :=Toy.Talk   (BedTimePath+′pp005.wav′,′S′);

        Synchronize(UpdateBedTimeRitualBar);

        BedTimeRitualNextSection := -1;

      end;
  235 :begin

        ParamTalk    :=Toy.Talk  (BedTimePath+′pp005.wav′,′S′);

        Synchronize(UpdateBedTimeRitualBar);

        BedTimeRitualNextSection := 10;

      end;
  240 :begin

        ParamTalk    :=Toy.Talk  (BedTimePath+′pp005.wav′,′S′);

        Synchronize(UpdateBedTimeRitualBar);

        BedTimeRitualNextSection := 10;

      end;
  245 :begin

        ParamTalk   :=Toy.Talk  (BedTimePath+′pp005.wav′,′S′);

        Synchronize(UpdateBedTimeRitualBar);

        BedTimeRitualNextSection := 5;

      end;
  250 :begin

        ParamTalk    :=Toy.Talk  (BedTimePath+′pp005.wav′,′S′);

        Synchronize(UpdateBedTimeRitualBar);

        BedTimeRitualNextSection := -1;

      end;
  255 :begin

        ParamTalk    :=Toy.Talk  (BedTimePath+′pp005.wav′,′S′);

        Synchronize(UpdateBedTimeRitualBar);

        BedTimeRitualNextSection := 10;

      end;
  260 :begin

        ParamTalk   :=Toy.Talk  (BedTimePath+′pp005.wav′,′S′);

        Synchronize(UpdateBedTimeRitualBar);

        BedTimeRitualNextSection := 10;

      end;
				
				<dp n="d335"/>
   265 :begin

         ParamTalk    :=Toy.Talk   (BedTimePath+′pp005.wav′,′S′);

         Synchronize(UpdateBedTimeRitualBar);

         BedTimeRitualNextSection := 5;

       end;
   270 :begin

         ParamTalk    := Toy.Talk  (BedTimePath+′pp005.wav′,′S′);

         Synchronize(UpdateBedTimeRitualBar);

         BedTimeRitualNextSection := -1;

       end;
   275 :begin

         ParamTalk    :=Toy.Talk   (BedTimePath+′pp005.wav′,′S′);

         Synchronize(UpdateBedTimeRitualBar);

         BedTimeRitualNextSection := 10;

       end;

   {else

       begin

         Terminate;

         Exit;

       end;  }

   end;
//--------------end of "BedTimeRitual" sesions--------------

   if (IntroNextSection             = -1) and

      (PlayNextSection              = -1) and

      (PrincessNextSection          = -1) and

      (TheStoryMenuNextSection      = -1) and

      (RunStoryMenuNextSection      = -1) and

      (BedTimeRitualNextSection     = -1) and

      (GrouchyNextSection           = -1) and

      (BunnyNextSection             = -1)      then Terminate;

    *}

      if ((ParamTalk = -2) or (ParamListen = -9999)) and
(PresentationNextSection <> 750) then

       begin

          PrincessNextSection := -1;

          PresentationNextSection := 750;
				
				<dp n="d336"/>
           ParamTalk  := 0;

           ParamListen := 0;

           if LastPresentation < 1 then LastPresentation := 699;

           Synchronize(UpdatePresentationBar);

        end;

        if PanelControlForm.Status = ′STOP′ then

           begin

             PresentationNextSection := 6;

             Synchronize(ClearStatusControl);

           end;

        if PanelControlForm.Status= ′START′then

           begin

             PresentationNextSection := 10;

             Synchronize(ClearStatusControl);

             VisitSongMenu            := 0;

             VisitGameMenu            := 0;

             VisitStoryMenu           := 0;

             VisitBunnyShort          := 0;

             VisitBunnyLong           := 0;

             VisitPrincess            := 0;

             BunnyFavoriteFood        := ″;

           end;

        if PanelControlForm.Status = ′PAUSE′ then

           begin

             if PresentationNextSection = 10000 then

                PresentationNextSection := LastPresentation

             else

               begin

                 LastPresentation := PresentationNextSection;

                 PresentationNextSection := 10000;

               end;

             Synchronize(ClearStatusControl);

             Synchronize(UpdatePresentationBar);

           end;

   end;// End of Terminate

   Terminate;

   Exit;
end;
				
				<dp n="d337"/>
procedure TIntro.UpdateIntroBar;
begin
// Intro have 450 sections
   StatusForm.StatusGauge.Progress := Trunc(IntroNextSection/4.5);
   StatusForm.Labell.Caption := IntToStr(IntroNextSection);
end;
procedure TIntro.UpdatePlayBar;
begin
// Play have 450 sections
   StatusForm.StatusGauge.Progress :=Trunc(PlayNextSection/4.5);
   StatusForm.Labell.Caption := IntToStr(PlayNextSection);
end;
procedure TIntro.UpdatePrincessBar;
begin
// Princess have 450 sections
   StatusForm.StatusGauge.Progress := Trunc(PrincessNextSection/4.5);
   StatusForm.Labell.Caption := IntToStr(PrincessNextSection);
end;
procedure TIntro.UpdateTheStoryMenuBar;
begin
// The Story Menu have 450 sections
   StatusForm.StatusGauge.Progress := Trunc(TheStoryMenuNextSection/4.5);
   StatusForm.Labell.Caption := IntToStr(TheStoryMenuNextSection);
end;
procedure TIntro.UpdateRunStoryMenuBar;
begin
// Run Story Menu have 450 sections
   StatusForm.StatusGauge.Progress := Trunc(RunStoryMenuNextSection/4.5);
   StatusForm.Labell.Caption := IntToStr(RunStoryMenuNextSection);
end;
procedure TIntro.UpdateBedTimeRitualBar;
begin
// Bed Time Ritual have 450 sections
   StatusForm.StatusGauge.Progress := Trunc(BedTimeRitualNextSection/4.5);
   StatusForm.Labell.Caption := IntToStr(BedTimeRitualNextSection);
end;
				
				<dp n="d338"/>
 procedure TIntro.UpdateGrouchyBar;
 begin
 // Grouchy have 450 sections

  StatusForm.StatusGauge.Progress := Trunc(GrouchyNextSection/4.5);

  StatusForm.Label1.Caption := IntToStr(GrouchyNextSection);
 end;
 procedure TIntro.UpdateBunnyBar;
 begin
 // Bunny have 450 sections

  StatusForm.StatusGauge.Progress := Trunc(BunnyNextSection/4.5);

  StatusForm.Labell.Caption := IntToStr(BunnyNextSection);
 end;
 procedure TIntro.UpdatePresentationBar;
 begin
 // Presentation have 5000 sections

  StatusForm.StatusGauge.Progress := Trunc(PresentationNextSection/50);

  StatusForm.Labell.Caption := IntToStr(PresentationNextSection);

  StatusForm.StandByLabel.Visible := False;

  if PresentationNextSection = 699 then

  begin

    StatusForm.StandByLabel.visible := True;

    StatusForm.StandByLabel.Caption := ′STANDBY MODE′;

  end;

  if PresentationNextSection = 750 then

  begin

    StatusForm.StandByLabel.Visible := Tte;

    StatusForm.StandByLabel.Caption := ′SLEEP MODE′;

  end;

  if PresentationNextSection = 10000 then

  begin

    StatusForm.StandByLabel.Visible := True;

    StatusForm.StandByLabel.Caption := ′PAUSE′;

  end;
end;
procedure TIntro. ClearStatusControl;
				
				<dp n="d339"/>
begin

  PanelControlForm.Status := ″;
end;
procedure TIntro.ApplicationMinimize;
begin

   StatusForm.Hide;

   StatusForm.WindowState :=wsNormal;

   StatusForm.Show;

   Application.Minimize;
end;
end.
基站源代码 基站源代码的系列单端口微片  ;14.04.98 18:00 MH_RF.asm UART,14.7456 MHZ,FIFO 8 KB M.Kholod.;MH:1.CTP1&org 04 2. VER,CMH:3. Del CMH.asm,4. Copy MH->\CMH,;6. Ren MH->CMH,7. B CTP1 & org4: MH->CMH,8. CTP4:";CEIBO_config;06.04:1. Memory Distribution (PAC||PEDELEHIE);06.04:2. In "NHfifo8K.asm" BF=42,BYTE=43(before 40,41);;COMH/COHM PC-HUB: FF 05 (Type=81  Leng=01 Data=47) KS=C9 (=81+01+47); RF TX/RX:55*5 Bar=32 (Type=D1 Leng=02 Data=2C A1) KS=A0 (=D1+02+2C+A1)
      LIST       p=16c73a
     __config    B′00000000110010′      ; for CEIBO=Y6PAT6 3TY CTPOKY !;                  |||||||          Select XT Oscil=01=04 MHZ; ====         |||||++------>  Select HS Oscil=10=10,20 MHZ;|14.7 MHZ|=′10′||||+-------->  WDT Disabled; ====         |||+--------->  Power-up Timer Enabled;                  |++---------->  Code protection off;yel  red          +------------>  Brown-out Reset Disabled;RX   TX      0;x x x x x x x x  ==========14.7 MHZ <==> 0.2712673611 U;   2 3       7    |  * * * ?   3 ? |      Tcomm=1cycl=0.27 U;  x x x x x x x   ==========;; Baud Rate=115200, 8-bit 1-StopBit, No Parity  RAO; A/D Works 8KHz, 8 bit;        PIC16C73A;
Figure A9980096103531
;                 x01 RESET        (    )    RB7      28x B7 =>COMP_EN;AUD_IN  A/D  => A0 x02 RA0/AN0    \_/     RB6      27x B6 => RF_EN;TX+B2_IN     <= A1 x03 RA1/AN1            RB5      26x B5;TX_DATA      <= A2 x04 RA2/AN2            RB4      25x B4 <=>FIFO;VREF         => A3 x05 RA3/AN3/REF        RB3      24x B3;CD_N     __  => A4 x06 RA4/TOCKI          RB2      23x B2;         OE  <= A5 x07 RA5/AN4/SS         RB1      22x B1 => CLK;Ground       =>    x08 VSS                RB0/INT  21x B0 => DATA;OSCi 14MHZ   =>    x09 OSC1/CLKIN         VDD      20x    <=;OSCo     __  <=    x10 OSC2/CLKOUT        VSS      19x    <=;         WE  <= C0 x11 RC0/T1OSO/T1CKI  RC7/RX/DT  18x C7 <=BASE_RX;BASE_CTS     => C1 x12 RC1/T1OSI/CCP2   RC6/TX/CK  17x C6 =>BASE_TX;         PWM <= C2 x13 RC2/CCP1         RC5/SDO    16x C5 =>G (CLK);BASE_RTS     <= C3 x14 RC3/SCK/SCL    RC4/SDI/SDA  15x C4 <=RX_DATA
                ----------------------------------------- ;PC_   0   1    2    3    4    5    6    7   PC_;STRB  /   |    |    |    |    |    |    \   ACK        PC CONNECTOR;  1   2   3    4    5    6    7    8    9   10;  x   x   x    x    x    x    x    x    x    x    x    x   x   x;;                                              ^COMM,PWM       ^---------;  -------            ------       ----------  |------------>|  |        |;  |     |    COMM   |     |-Data-->|       | |              |  |        |;  |  PC |  ------> | PIC |-Clock->|     RF|-+<----------- +--|  RF    |;  -------   UART    |     |--EN--->|       |  A/D,STATUS      |        |; |        |<----   |HUB  |RC2=PWM |  PLL  |  ACK,SENSOR      |    PIC |; |Com-port| ACK     |     |------->|(Comp- |                   |    TOY |; |        | STATUS  |     |<-------| ander)|                   |        |; -----------SENSOR--------- RA0=A/D-------                      ---------;;      ==============================;MFPW: |  |__PWM|     |     |     |     |     | COMM |  HEAD | |;       |  |  7  |  6  |  5  |  4  |  3  |  2  |  1   |   0   | |;      ==============================;             |                                   |       |;PWM=0->Not Read/  1->Read                     |   0-Wait COh;                                                 |   1-Yes HEADO(CO);                                                 |   and Leng=CNT;1->Yes  Head,Wait and Read Command from PC---+;;      ==============================; MFAD:| |__AD |     |     |     | APK   |  ACN  | ALH | ATP |  |;       | |  7  |  6  |  5  |  4  |  3    |   2   |  1  |  0  |  |;      ==============================;            |                       |        |      |     |;_AD=0->A/D   Not   Started        |        |      |  =1->HEADO=FF;                                    |        |      |    Wait Type;1->Yes  LSB=LCL -> Yes ACN ------+        |      |;                                             |      +-=1->Yes Type;ALH=1   ->  Yes  MSB Leng = ACNH ---------+;#INCLUDE "microch.asm"#DEFINE HUB             ;  For HUB.         HUB=BASE/TOY=HAND  Select ;******  Constants  ******;---------------------------------------------M_VER      EQU      45   ;  8 = Year (98),   3 = Month (March).  {HO POKA:  M D/2}MSYNC      EQU      05        ; Head1 =05h:   Sync PC <--> HUB  =  FF 05 . . .SYNCO1B    EQU      B′01010101′       ; Sync  Frequence  RFSYNC5L     EQU      05                  ; 5 Bytes  in   Sync   RFSYNC5R     EQU      05                  ; 5 Bytes  SYNC  Compare in RXBARKERB    EQU      B′00110010′BARK_TO    EQU      (SYNC5L+5)*8       ; Max  Bits  beefore  BARKER; 4 MHZ,F[USER]=8KHZ, Presc=1:4000/(4*8)-1=124   !!! TOY: 4  MHZ  RF!; 14.7456MHZ,  F[USER]=8.014KHZ,  Presc=4(T2CON,0=1):14745/(4*8*4)-1=114RF_PR2              EQU   d′114′  ; and  Presc.=4=T2CON,0:=1 RF !!!;                                                                  ------PWM |;if F[osc]=14745.6 KHZ,Presc=1, PR2=(14745.6/4*56))-1 = 64.8 = 65 |;F[user]=F[osc]/((PR2+1)*4*Presc)=14745 / (66*4) = 55.854(54)   KHZ   |;PR2=(F[osc]/(4*F[user]*Presc))-1 = (14,745/(4*56*1))-1 = 65          |PWM_PR2        EQU   d′65′ ;!!!PR2>CCPR1L,CCP1CON=8 Bit  !!  11.1|OVERSAMPLING   EQU   7    ;(BO CK. PA3 PEREKRYTIE) 17.9U*7 = 125.3U     |;F[pwm]=7*8KHZ=56 KHZ -> F[user]=56 KHZ -> 17.86U=.01786 MS  ->   |;if F[osc]=10.2 MHZ,Presc=1,PR2=(10,200/4*40*1))-1 = 62.8 = 63    |;F[user]=F[osc]/((PR2+1)*4*Presc) = 10 200 /(63*4) = 40.5 KHZ         |;if F[osc]=4 MHZ,Presc=1,  PR2 = (4,000 / 4*40*1))-1=24            |;if F[osc]=10 MHZ,Presc=1, PR2 = (10,000/4*40*1))-1= 61.5=62      |;F[user] = F[osc]/((PR2+1)*4*Presc) = 10 000 /(63*4)=39.68 KHZ        |;if F[osc] = 20 MHZ,Presc = 1,PR2=(20,000/4*40*1))-1=124           |;F[user] = F[osc]/((PR2+1)*4*Presc) = 20 000/(125*4) = 40.00 KHZ      |;                                                      --------PWM       |RTS_TRIS           EQU      TRISCRTS_PORT           EQU      PORTCRTS_BIT            EQU      3       ;   RC3CTS_TRIS           EQU      TRISCCTS_PORT           EQU      PORTCCTS_BIT            EQU      1       ;CTS=RC1=1=> PC Not Ready to Read  CLK_PORT               EQU         PORTBCLK_TRIS               EQU         TRISBCLK                    EQU         1                      ;RB1DATA_PORT              EQU         PORTBDATA_TRIS              EQU         TRISBDATABIT                EQU         0                      ;RB0RX_DATA_P              EQU         PORTCRX_DATA_T              EQU         TRISCRX_DATA                EQU         4                      ;RC4TX_DATA_P              EQU         PORTATX_DATA_T              EQU         TRISATX_DATA                EQU         2                      ;RA2ENMC_PORT              EQU         PORTBENMC_TRIS              EQU         TRISBENMC                   EQU         7                      ;RB7ENPF_PORT              EQU         PORTBENRF_TRIS              EQU         TRISBENRF                   EQU         6                       ;RB6;-------------------------------------------------------------;******  Variables  ******;-------------------------------------------------------------W_TMP         EQU      20             ;Temp Storage for W          [ 20 ]STATUS_TMP    EQU      21             ;for STATUS                  [ 21 ]FSR_TMP       EQU      22             ;for FSR                     [ 22 ];  PCLATH_TMP EQU      23            ; for PCLATH                 [ 23 ]MF      EQU   24       ; Curent Process,   STATE (COCTORHIE)PWMS    EQU   7        ;1:PC -UART->MBYTE-FIFO->Sample PWM / 0:COMHCOPW    EQU   6        ;1:Source State=PWM,aval(ODHAKO)FF 05 ...?!!COHM    EQU   4        ;1:HUB(HBYTE) ->PC:ACK or STATUSCOHMRF  EQU   3        ;1:TOY-HUB->PC: ACK or SENSOR(STATUS)from TOYADSM    EQU   2        ;1:A/D Sable -FIFO->HBYTE -UART->PCRFTX    EQU   0 ;1:  RF TX /0: RF RX if COPW=COHM=COHMRF=0:Not PWM&COHMFRF     EQU   25       ;RF Flags:  !! To Begin RF:  FRF(,_BUSY)  := 00(0)  !_BUSY   EQU   7        ;1:RF Busy:Process RF TXIRX in Interrupt _ERR    EQU   6         ; 1:KS Error(RX)_CUR    EQU   4    ;  1: Yes Barker,RX|TX Wait|Send Cur.Data Bits|Bytes_NLEN   EQU   3    ;  1: Yes Length,RX|TX:Wait|Send Curr.Data Bit|Byte_TYPR   EQU   2         ; 1: Yes Type,RX:Wait Length_BAR    EQU   1    ;  1: Yes SYNC,RX|TX:Wait Barker|Send SYNC and Barker_NIB    EQU   0         ; 1:Low Nibble is Received_MFH    EQU   26        ; HUB Flags_CMB    EQU   7         ; 1:Yes MBYTE from PC.HADO EGO O6PA6OTAT6 & :=0
                    ; 0:HADO Read Byte:PC -> MBYTE & _CMB:=0_PWM    EQU   6         ; 1:HADO FIFO -BUF R-> W(Sample)& _PWM:=0
                    ; 0:Wait untill in Interrupt 8 KHZ _PWM :=1_DAT    EQU   5         ; 1:Yes min (>1K Bytes) in FIFO
                    ; 0:FIFO still empty (<1K) -> Not Sing_AD     EQU   4         ; 1:HADO A/D Sample -BUF_W-> FIFO  & _AD :=0
                    ; 0:Wait untill in Interrupt 8 KHZ  _AD :=1_PLA    EQU   3         ; 1:Fluent end (PLABH 3ABEPWEHIE DO IC4EP Buff)}
      ;  0:Immedinate (HEMEDLEHHOE)  End PWM or A/D,and => BUF_SETTSTAD   EQU   2         ; 1:TEST HUB -> PC:00,01,..FE,FE(#FF),00,..TSTPW   EQU   1         ; 1:TEST PC -> HUB:00,01,..FE,FE(#FF),00,..TSMPL   EQU   0         ; 1:Samle renewing {O6HOBILOC6}FCOMH   EQU  28         ; Flags for COMHFCOHM   EQU  29         ; Flags for COHM_COM    EQU   7         ; 1:Read COMH or Send COHM (TEK Bytes COMM)_LEN    EQU   6         ; 1:Read (PC->HUB) or Send (HUB->PC) Length COMM_TYP    EQU   5         ; 1:-"- Type:p.6=1=TOY/0=HUB;p.5=1=Yes ACK/0=No_SYN    EQU   4         ; 1:Read (PC->HUB) or Send (HUB->PC) Head1=05h_MES    EQU   1         ; 1:Yes Special HUB Message (8E):Error or Information_2L3    EQU   0         ;1: Length COMH=1,3,..odd (HE4ETH)  / 0: =0,2,..evenMBYTE   EQU             2A      ;Byte from PC -> HUBHBYTE   EQU             2B      ;Byte from HUB to PC;BMH for COMH (PC->HUB):2E(MTYPE) 2F(MHCNT) 30-40(BMH_DATA)+(SCOMH) 2C-40SCOMH      EQU      2C  ;KS COMH=Type+Length (=n)+BMHD0+..+BMHDn-1ACOMH    EQU  2D ;Address Current Byte Buff BMH(COMH)(PC->HUB): 30h-3FhMTYPE     EQU 2E  ;Type COMH  PC -> HUBMHCNT     EQU 2F  ; Counter COMH PC -> HUB = Length COMM <=16=10hACOMH0    EQU 30  ; Address COMH PC->HUB (Leng <=10h),COMHO=INSTR!PLLADR    EQU  ACOMH0       ;Address PLL Reg.     [30]PLLDATH   EQU  ACOMH0+1     ;Data(MSB)            [31] PLLDATL EQU  ACOMH0+2 ;Data  (LSB)      [32]...[3F]  [40];42 BF:FW=1, FR=0; 0 -> BUF empty (FR=0) or full (FR=1) ;43 BYTE;44-45 BCM              46-47 BARH,BARL       48-49  BAWH,BAWL;BHM for COHM (HUB->PC):4E(MTYPE)4F(HLENG) 50-60(BHM_DATA)+(SCOHM) 4C-60SCOHM     EQU     4B ; KS COHM  HUB -> PCACOHM  EQU   4C ;Address  Current Byte Buff BHM(COHM)(HUB->PC):50h-5FhHM_CNT    EQU  4D ;Counter  COHM HUB -> PCHTYPE     EQU  4E ;Type COHM  HUB -> PCHLENG     EQU  4F ;Length COHM  HUB->PCACOHM0    EQU  50 ;Addr COHM HUB->PC, COHM0=Instr.Sens.or ACK !!!PSHADR    EQU   ACOHM0          ;Address PLL Shadow Reg.  [50]PSHDATH   EQU   ACOHM0+1        ;Data (MSB)               [51]PSHDATL   EQU   ACOHM0+2        ;Data (LSB)               [52]..[5F] [60];                                                          ------PWM|PWM_Cntr         EQU     61 ;PWM Pulse Counter for Oversampling [60]|Sample           EQU     62 ;Current Sample                     [61]|Sample_TMP       EQU     63 ;Current Sample TmP                 [62]|;                                                          ------PWM|MM11PW        EQU    64MM12AD        EQU    65MM            EQU    66MM1           EQU    67M_CNT         EQU    68PLLBYTE   EQU        6A              ;=> s/r PLLOutPLLCOUNT  EQU        6B              ;Counter s/r PLLOutPLL_LENG  EQU        6C ; p000 1111,p=1=Mc/ p=0=Sharp;1111=Leng (1-8)PLLSCNT   EQU        6D              ; Counter s/r PLLSetupMSTATUS      EQU     70    ;EC:cccc eeee=Exit Code=HUB StatusMCODE        EQU     71    ;EC:cccc eeee=Exit Code=HUB Status;cccc =7|6|5|4=where to {KYDA},eeee=Error Code;0h=0 x x x=>Cycle: MCOMH->MCOHM->MPWMS->MADSM->MCOMH...;8h=1 0 x x=>MLOOP00 = BUF_SET -> MCOMH->...(Start PWA or A/D);Ch=1 1 0 x=>M_START=Break HUB;Eh=1 1 1 0=>START=Reset HUB;Fh=1 1 1 1=>Error or Message => FCOMH:=0;MSTATUS:=Status=MCODE;;              if COPW=1,Restore Sourse PWM Mode;; eeee=0h=OK.     1h=Stop D/A, but Not PWM.2h=Not UART. ;             3h=UART busy  4h=CTS=1=> PC Not Ready to Read.;             5h=Head1 # 05.                            7h = KS Error.;             8h=Yes FFh.     9h=Stop PWM,then=> ACK:HM90PWMF.;                                               Dh=Error:  FIFO empty.;             Eh = Error Test PC->HUB          Fh=Head0 # FF.;  MFIFO8K  ->  Variable EQU >=40h !!!!RF_BYTE  EQU  74 ;(If Error RX->FRF,_ERR:=1 & RF_BYTE:=Error Code)RF_CNT   EQU  75     ;Counter Bits to TXRFMCNT   EQU  76     ;Counter Byt es to TXRF_FSR   EQU  77     ;Address BUFF to RX/TXTX_CNT   EQU  78  ;CNT 1/2Bytes Message to TX=2*(Leng+3(TYP,LEN,KS))RX_CNT   EQU  79  ;CNT Bytes Message TOY-HUB->PC:=Leng+3(TYP,LEN,KS)SRF_KS   EQU  7A     ;KS  RF RXM8CNT    EQU  7C     ;125.32552088U, M8CNT=0 -> Yes 1 KHZ = 1002.6MSTMR_125U EQU  7D     ;125 U=17.90364584U*7=125.32552088UTMR_32MS EQU  7E     ;32 MS=125.32552088U*256=32083.333345 MSTMR_8SEC EQU  7F     ;8 SEC=32.08333MS*256=8.2133333364 SEC;       BANK 1 !!!!!    BANK 1    !!!;BMT for PC -UART-HUB-RF-> TOY:A1(TXTYPE) A2 (TXLENG) A3-B3 (BMT_DATA+KS)TXTYPE  EQU  OA1  ;Type TX Instr. PC ->TOY          [A1]TXLENG  EQU  OA2  ;Counter (Length)                  [A2]BMTO     EQU  OA3  ;BMT(Instr.PC-> TOY)+KS          [A3]-[B3]SHARPSH   EQU        OB4           ;!!BANK 1 ! [B4]-[BD]SHARP_RX16  EQU     SHARPSH+0      ; 0000 0HL(D16) MSB        [B4]SHARP_RX08  EQU     SHARPSH+1      ; (D15) ..(D8)             [B5]SHARP_RX00  EQU     SHARPSH+2      ; (D7)..(D0)    LSB        [B6]SHARP_TX16  EQU     SHARPSH+3      ; 0000 0LH(D16) MSB        [B7]SHARP_TX08  EQU     SHARPSH+4      ; (D15)..(D8)              [B8]SHARP_TX00  EQU     SHARPSH+5      ; (D7)..(D0)    LSB        [B9]SHAPR_REF8  EQU     SHARPSH+6      ; 00HH (D11)(D10)(D9)(D8), D11 = MSBSHARP_REF0  EQU     SHARPSH+7      ; (D7)..(D0)    LSB        [BB] SHARP_OPT8  EQU    SHARPSH+8      ; 00LL (D11) (D10) (D9)(D8), D11 = MSBSHARP_OPT0  EQU    SHARPSH+9      ; (D7)..(D0)   LSB           [BD];BTM for TOY -RF-HUB-UART-> PC:BE(RXTYPE) BF(RXLENG) C0-D0(BTM_DATA+KS)RXTYPE  EQU  0BE  ; Type  RX  ACK or Sensor                  [BE]RXLENG  EQU  0BF  ; Counter (Length)                         [BF]BTM0    EQU  0C0  ; BTM (Instr.Sensor or ACK) + KS:       [C0]-[D0]PLLSHAD   EQU     0D0              ;!!BANK 1 ! [D0]PLLSH1H   EQU     PLLSHAD+2        ;(+2*1)     [D2]PLLSH1L   EQU     PLLSHAD+3        ;(+2*1+1)   [D3]PLLSH2H   EQU     PLLSHAD+4        ;(+2*2)PLLSH2L   EQU     PLLSHAD+5        ;(+2*2+1)PLLSH3H   EQU     PLLSHAD+6        ;(+2*3)PLLSH3L   EQU     PLLSHAD+7        ;(+2*3+1)PLLSH4H   EQU     PLLSHAD+8
 ;00000000 ;ALC-Enable, Limiter-Enable, Clk-Disable
 ; | ||\/+-----> Volume Control (MSB)
 ; | || \-------> Clk Out Select
 ; | |+---------> 1 - Clk Disable
 ; | +----------> 1 - Limiter Disable
 ; +------------> 1 - ALC DisablePLLSH4L            EQU     PLLSHAD+9
 ;00000000;Mode-Activ,Tx-UnMuted,Rx-Muted,SP-On
 ;\ /||||+----> 1 - Speaker Mute
 ; | |||+-----> 1 - Rx Mute
 ; | ||+------> 1 - Tx Mute
 ; | |+-------> Rx Mode          \ 00 - Active
 ; | +--------> StendBy Mode     / 11 - Inactive
 ; +----------> Volume Control   (bit2 - LSB)PLLSH5H          EQU     PLLSHAD+0APLLSHSL          EQU     PLLSHAD+0BPLLSH6H          EQU     PLLSHAD+0C
 ;00000000
 ;     \_/
 ;      +-------> Voltage Reference AdjustPLLSH6L          EQU     PLLSHAD+0D
 ;00000000
 ;||\___/
 ;||   +-------> Filter Clock Counter
 ;|+-----------> 1 - Tx Scrambler Bypass
 ;+------------> 1 - Rx Scrambler BypassPLLSH7H         EQU     PLLSHAD+0E      ; (+2*7)     [DE]PLLSH7L         EQU     PLLSHAD+0F      ; (+2*7+1)  [DF];  MM1  ->  Addr: E0h - EFh, MM  ->  Addr:   F0h -FFh#IFDEF  HUB     ; HUB = BASE:RY3GH045 (Baseset);***Default SHARP Settings for HUB!!!(For TOY Contrary RX<-->TX);fRX = 70504 * 0.0125 + 21.7 = 903.000 MHZ nRX = 70504 = 011368hSHARP_RX16DF    EQU     05 ; 0   0   0   0   0   H   L  D16 (101)SHARP_RX08DF    EQU     13 ; D15 D14 D13 D12  D11 D10 D9 D8SHARP_RX00DF    EQU     68 ; D7  D6  D5  D4  D3  D2  D1 D0;fTX = 74160 * 0.0125 = 927.000 MHZ  nTX = 74160 = 0121B0hSHARP_TX16DF    EQU     03 ; 0   0   0   0   0   L   H  D16 (011)SHARP_TX08DF    EQU     21 ; D15 D14 D13 D12 D11 D10 D9 D8SHARP_TX00DF    EQU     0B0 ;D7  D6  D5  D4  D3  D2  D1 D0;Reference = 3400 = 0D48hSHARP_REF8DF    EQU     3D ; 0  0  H  H  D11 D10 D9 D8 B′0011′  DhSHARP_REF0DF    EQU     48 ; D7 D6 D5 D4  D3  D2  D1 D0;Seting Options for Normal Operating Mode=B′0000 1010 0000 0000′SHARP_OPT8DF    EQU     0A      ; 0  0  L  L   D11 D10 D9 D8SHARP_OPT0DF    EQU     00      ; D7 D6 D5 D4  D3  D2  D1 D0#ELSE          ; TOY = HAND:RY3GH045(Handset); Default SHARP Settings for TOY.(For HUB Contrary,but Formula the same!);fRX = 72424 * 0.0125 + 21.7 = 927.000 MHZ  nRX=72424=011AE8hSHARP_RX16DF    EQU     05 ; 0   0   0   0   0   H   L  D16 (101)SHARP RX08DF    EQU     1A ; D15 D14 D13 D12  D11 D10 D9 D8SHARP_RX00DF    EQU     0E8 ;D7  D6  D5  D4   D3  D2  D1 D0;fTX = 72240 * 0.0125 = 903.000 MHZ   nTX = 72240 = 011A30hSHARP TX16DF    EQU     03 ; 0   0   0   0   0   L   H  D16 (011)SHARP_TX08DF    EQU     1A ; D15 D14 D13 D12 D11 D10 D9 D8SHARP_TX00DF    EQU     30 ; D7  D6  D5  D4  D3  D2  D1 D0;Reference = 3400 = 0D48hSHARP_REF8DF    EQU     3D ; 0  0  H  H  D11 D10 D9 D8 B′0011′DhSHARP_REF0DF    EQU     48 ; D7 D6 D5 D4 D3  D2  D1 D0;Seting Options for Normal Operating Mode=B′0000 1010 0000 0000′SHARP_OPT8DF    EQU     0A ; 0  0  L  L  D11 D10 D9 D8 SHARP OPT0DF    EQU    00  ; D7 D6 D5 D4 D3 D2 D1 D0#ENDIF                     ;  [A2]-[AB];****** Default PLL Settings (description see upword)PLLDR1H         EQU         00PLLDR1L         EQU    00PLLDR2H         EQU    00PLLDR2L         EQU    00PLLDR3H         EQU    00PLLDR3L         EQU    00PLLDR4H         EQU    18PLLDR4L         EQU    0C3PLLDR5H         EQU    3DPLLDR5L         EQU    0E0PLLDR6H         EQU    00PLLDR6L         EQU    0DFPLLDR7H         EQU    00PLLDR7L         EQU    00;=========================
   org      0000h
   goto     START;09.04.98 18:00 MH_RF.asm  UART,14.7456 MHZ, FIFO 8 KB  M.Kholod
   org      0004h
   GOTO     INT HANDLERR;---------------------------------------------------;******  ROM Constants  ******;---------------------------------------------------PLLSetDF:
   clrf     PCLATH        ;Should be in page 0
   ADDWF PCL,F
   NOP
   NOP
   RETLW    PLLDR1H
   RETLW    PLLDR1L
    RETLW       PLLDR2H
    RETLW       PLLDR2L
    RETLW       PLLDR3H
    RETLW       PLLDR3L
    RETLW       PLLDR4H
    RETLW       PLLDR4L
    RETLW       PLLDR5H
    RETLW       PLLDR5L
    RETLW       PLLDR6H
    RETLW       PLLDR6L
    RETLW       PLLDR7H
    RETLW       PLLDR7LEncodeTable:                          ; RF Message Encoding Table
    clrf        PCLATH             ; Should be in page 0
    addwf       PCL,F
    retlw       B′01001010′      ; 0h
    retlw       B′01010010′      ; 1h
    retlw       B′01011010′      ; 2h
    retlw       B′01101010′      ; 3h
    retlw       B′01001100′      ; 4h
    retlw       B′01010100′      ; 5h
    retlw       B′01100100′      ; 6h
    retlw       B′01101100′      ; 7h
    retlw       B′10010010′      ; 8h
    retlw       B′10011010′      ; 9h
    retlw       B′10101010′      ; Ah
    retlw       B′10110010′      ; Bh
    retlw       B′10010100′      ; Ch
    retlw       B′10100100′      ; Dh
    retlw       B′10101100′      ; Eh
    retlw       B′10110100′      ; Fh;-----------------------------------------------------DecodeTable:       ; RF Message Decoding Table
    clrf        PCLATH             ; Should be in page 0
    addwf       PCL,F             ; Input:Corrected to:
    retlw       B′00001000′      ; 00000      00100
    retlw       B′00001100′      ; 00001      00101
    retlw       B′00001001′      ; 00010      00110
    retlw       B′00001110′      ; 00011      01011
    retlw       B′00001000′      ; 00100
    retlw       B′00001100′      ; 00101
    retlw       B′00001001′      ; 00110
     retlw   B′00001001′      ; 00111      00110
     retlw   B′00001101′      ; 01000      01010
     retlw   B′00001101′      ; 01001
     retlw   B′00001010′      ; 01010
     retlw   B′00001110′      ; 01011
     retlw   B′00001011′      ; 01100
     retlw   B′00001111′      ; 01101
     retlw   B′00001011′      ; 01110      01100
     retlw   B′00001111′      ; 01111      01101
     retlw   B′00000000′      ; 10000      10010
     retlw   B′00000100′      ; 10001      10011
     retlw   B′00000000′      ; 10010
     retlw   B′00000100′      ; 10011
     retlw   B′00000001′      ; 10100
     retlw   B′00000101′      ; 10101
     retlw   B′00000010        ; 10110
     retlw   B′00000010        ; 10111      10110
     retlw   B′00000110        ; 11000      11001
     retlw   B′00000110        ; 11001
     retlw   B′00000011        ; 11010
     retlw   B′00000111        ; 11011
     retlw   B′00000001        ; 11100      10100
     retlw   B′00000110′      ; 11101      11001
     retlw   B′00000011′      ; 11110      11010
     retlw   B′00000111′      ; 11111      11011;==============================
  #INCLUDE "MHfifo8K.asm"                     ;FIFO BUF;==============================;    SHARPSET  -  Set  SHARP  Registers  to default;------------------------------------------------------------SHARPSET:
     BSF     FCOMH,_2L3         ; =1 -> For 19 Bit:Length = 3
     MOVLW   SHARP_RX16DF
     MOVWF   PLLADR
     MOVLW   SHARP_RX08DF
     MOVWF   PLLDATH
     MOVLW   SHARP_RX00DF
     MOVWF   PLLDATL
     CALL    SHARP_W
     MOVLW   SHARP_TX16DF
     MOVWF   PLLADR
     MOVLW    SHARP_TX08DF
     MOVWF    PLLDATH
     MOVLW    SHARP TX00DF
     MOVWF    PLLDATL
     CALL     SHARP W
     BCF      FCOMH,_2L3       ; =0 -> For 14 Bit: Length = 2
     MOVLW    SHARP_REF8DF
     MOVWF    PLLADR
     MOVLW    SHARP_REF0DF
     MOVWF    PLLDATH
     CALL     SHARP_W
     MOVLW    SHARP_OPT8DF
     MOVWF    PLLADR
     MOVLW    SHARP_OPT0DF
     MOVWF    PLLDATH
     CALL     SHARP_W
     RETURN;--------------------------------------------------; PLLSetup  -  Set Compander Registers to default;--------------------------------------------------PLLSetup:
     CLRF     PLLADR
     MOVLW    7
     MOVWF    PLLSCNTPLLSetL:
     INCF     PLLADR,F         ;  (PLLADR)  := Addr=i (i=1,2,..,7)
     BCF      STATUS,_C        ;  C:=0
     RLF      PLLADR, W        ;  *2
     CALL     PLLSetDF          ;  (W):= PLLDRiH,i=1,...,7
     MOVWF    PLLDATH
     BCF      STATUS ,_C       ;  C: =0
     RLF      PLLADR, W        ;  *2
     ADDLW    1
     CALL     PLLSetDF          ;  (W)  := PLLDRiL
     MOVWF    PLLDATL
    CALL     PLL_W            ; Write (output) to PLL
    DECFSZ   PLLSCNT,F
    GOTO     PLLSetL
    RETURN;-------------------------------------------------; PLLLiSTenOpen  =>  Set:Tx-Mute;Rx-on; Spk-on; (listen open   => bits:   1       0        0 );; PLLListenClose =>  Set:Tx-on;Rx-Mute;Spk-Mute;  (listen close => bits:   0       1        1 );-------------------------------------------------PLLLsitenOpen
    MOVLW     04
    MOVWF     PLLADR
    MOVLW     PLlH4L
    MOVWF     FSR              ; in BANK 1,indirect
    MOVF      INDF,W
    ANDLW     0F8      ;clear last 3 bits: Tx,Rx, Spk
    IORLW     04       ;4=100=> Tx-Mute;Rx-on; Spk-on
    GOTO      PLllistenPLLListenClose
    MOVLW     04
    MOVWF     PLLADR
    MOVLW     PLLSH4L
    MOVWF     FSR              ;in BANK 1, indirect
    MOVF      INDF,W
    ANDLW     0F8      ;clear last 3 bits:Tx,Rx,Spk
    IORLW     03       ;3=011 => Tx-on;Rx-Mute;Spk-MutePLLListen                  ; Common:
    MOVWF     PLLDATL
    MOVLW     PLLSH4H
    MOVWF     FSR               ; in BANK 1,indirect
    MOVF      INDF,W
    MOVWF     PLLDATH
    CALL    PLL_W
    RETURN;------------------------------------------------------;           PLL_W - write (output) to PLL (Compander);(PLLADR)=(ACOMH0)= Reg.Number(1..7);(PLLDATH,PLLDATL)=MSB,LSB=(ACOMH0+1,ACOMH0+2);-------------------------------------------------------PLL_W:
   BSF      ENMC_PORT,ENMC    ;EN:=1
   BSF      PLL_LENG,7    ; p=1->Leng = 8 Bits:All Byte
   MOVF     PLLADR,W
   MOVWF    FSR            ;Addr = N. Reg.: 1..7
   CALL     PLLOut         ;Out Addr.???If (W)=0 or(W)>7??!!
   BCF      STATUS,_C     ;C:=0
   RLF      FSR,W         ;*2
   ADDLW    PLLSHAD
   MOVWF    FSR            ;Address PLLSHiH
   BCF      ENMC_PORT,ENMC        ;EN:= 0
   MOVF     PLLDATH,W     ; PLLDATH
   MOVWF    INDF           ; Save PLLDATH to Shadow (indirect)
   CALL     PLLOut         ; Output MSB-Byte to PLL
   MOVF     PLLDATL,W     ; PLLDATL
   INCF     FSR,F         ; Address PLLSHiL
   MOVWF    INDF           ; Save PLLDATL to Shadow (indirect)
   CALL     PLLOut         ; output  LSB-Byte  to  PLL
   BSF      ENMC_PORT,ENMC           ;EN:=1
   NOP              ; US
   NOP              ; US
   NOP              ; US
   BCF    ENMC_PORT,ENMC     ;EN:= 0
   RETURN;--------------------------------------------------: SHARP W  - Write (Output) to PLL SHARP:(PLLADR, ;     PLLDATH,PLLDATL) = (ACOMH0,ACOMH0+1,ACOMH0+2);FCOMH,_2L3=0 (Leng=2) -> For 14bit / =1 -> For 19 bit;0 0 [0] MSB = a,b,D16 (or D11)..D2,D1,D0 = LSB;        ab:  10=RX,01=TX,11=Reference,00=Options;---------------------------------------------------------SHARP_W:
    MOVLW    08
    MOVMF    PLL_LENG            ; 8 Bits:LSB = D0 D1..D7
    SKIP_IF_SET   FCOMH,_2L3
    GOTO     SHARPW14            ; 0 -> Leng = 2 ->For 14 bit; 1 -> Leng = 3 -> For 19 bit:
    MOVLW    SHARP_RX00          ; For 19 bit
    SKIP_IF_SET PLLADR, 2         ;     2            2
    ADDLW    03                  ; 0000 001x = 0000 0LHx  ->  SHARP_TX00
    MOVWF    FSR
    MOVF     PLLDATL,W          ; PLLDATL = ACOMH0+2 = D7 - D0  for 19 bit
    GOTO     SHARPW2SHARPW14:                           ; 0 -> Leng = 2 -> For 14 bit
    MOVLW    SHARP_REF0          ; For 14 bit
    SKIP_IF_SET PLLADR, 5       ;   5           5
    ADDLW    02                  ; 0000 xxxx = 00LL xxxx  ->  SHARP_OPT0
    MOVWF    FSR
    MOVF     PLLDATH,W          ; PLLDATH = ACOMH0+1 = D7 - D0 for 14 bitSHARPW2:
    MOVWF   INDF                 ; Save SHARP LSB-AYTE to Shadow (indirect)
    CALL    PLLOut               ; Output LSB-Byte to SHARP: D0 D1..D7
    DECF    FSR,F
    MOVLW   06                   ; 6 Bits:D8 D9 D10 D11 b a -MSB
    SKIP_IF_SET  FCOMH,_2L3
    GOTO    SHARPW4              ; 0 -> Leng = 2 -> For 14 bit; Leng = 3 -> For 19 bit
    MOVF    PLLDATH, W          ; PLLDATH = ACOMH0+1 = D15 - D8 for 19 bit
    MOVWF   INDF                 ; Save SHARP middle-BYTE to Shadow (indir.)
    CALL    PLLOut               ; Out middle-Byte to SHARP:D8 D9..D15
    DECF    FSR,F
    MOVLW   03                   ; 3 Bits:D16 b a - MSB SHARPW4:
   MOVWF    PLL_LENG
   MOVF     PLLADR, W
   MOVWF    INDF               ; Save SHARP MSB-BYTE to Shadow (indirect)
   CALL     PLLOut             ; Out MSB-Byte to SHARP:..D16(D11) b a
   BSF      ENRF_PORT,ENRF          ; EN :=1
   NOP              ; US
   NOP              ; US
   NOP              ; US
   NOP              ; > 1.0 U 5*Tcomm=5cycl =1.35 U
   BCF      ENRF_PORT,ENRF          ; EN :=0
   RETURN;------------------------------------------------------------;PLLOut - Out PLL_LENG (8..)Bits (W) to PLL (Compander);         PLL_LENG=p000 1111,1111=Leng (1,2,..,8),;         p=1=Mc=MSB--LSB / p = 0 = SHARP = LSB - MSB;------------------------------------------------------------PLLOut:
   MOVWF    PLLBYTE
   MOVLW    08
   SKIP_IF_SET PLL_LENG,7
   MOVF     PLL_LENG,W             ; p=0 -> SHARP -> W := Leng <= 8
   MOVWF    PLLCOUNTPLLOutL                                 ; loop
   SKIP_IF_NOT PLL_LENG,7          ; 2 cycl
   GOTO    PLLOutMc; p = 0 -> SHARP -> LSB -- MSB
   MOVLW   0FC            ;-4      ; 1 cyclPLLOutSH:
   ADDLW   01                       ; 1 cycl
   SKIP_IF_Z                        ; 5 = 3+2
   GOTO    PLLOutSH                 ; 6 = 3*2
   RRF     PLLBYTE,F   ;C := LSB; 1 cycl
   GOTO    PLLOutSHARP              ; 2 cycl
                     ;tCKR = Rate of CLK = 18 + 3 (cycles) > 5 UPLLOutMc:
   RLF     PLLBYTE, F   ;C := MSBPLLOutSHARP:
    SKIP_IF_NC
    GOTO    PLLOut1           ; C = 1
    BCF     DATA_PORT,DATABIT      ; DATA = C = 0
    GOTO    PLLOutCPLLOut1:
    BSF     DATA_PORT,DATABIT      ; DATA = C = 1PLLOutC:
    NOP                      ; >0.1U  Tcomm = 1cycl = 0.27 U
    BSF     CLK_PORT,CLK           ; CLK := 1
    NOP             ; US
    NOP             ; US
    NOP             ; US
    NOP                      ; > 1.0 U  5*Tcomm= 5cycl = 1.35 U
    BCF     CLX_PORT,CLK            ; CLK := 0     RB1
    NOP             ; US;     >= 5 U ???????? !!!!!!!!!!! ; US
    NOP             ; US
    DECFSZ  PLLCOUNT,F
    GOTO    PLLOutL                   ; loop
    RETURN;-----------------------------------------------------------------; PLL_R - Read Bytes (MSB, LSB) from  Shadow Memory  to;     (PSHDATH,PSHdaTL) =MSB,LSB= (ACOHM0+1, ACOHM0+2);     (PSHADR)=(ACOHM0) :=(PLLADR)=(ACOMH0) = N.Reg.;-----------------------------------------------------------------PLL_R:
    MOVF    PLLADR, W
    MOVWF   PSHADR
    MOVWF   FSR                   ; address
    BCF     STATUS,_C            ; C :=0
    RLF     FSR,W                ; *2
    ADDLW   PLLSHAD
    MOVWF   FSR                   ; address PLLSHiH
    MOVF    INDF,W               ; Restore (MSB) from Shadow (indirect)
    MOVWF   PSHDATH               ; to PSHDATH
    INCF    FSR,F                ; address PLLSHiL
    MOVF     INDF, W            ; Restore (LSB)  from Shadow (indirect)
    MOVWF   PSHDATL          ; to PSHDATL
    RETURN;----------------------------------------------------------------------------; SHARP_R - Read Bytes (3 - for 19 bit or 2 - for 14 bit)  from Shadow;      Memory to (PSHADR,PSHDATH, PSHDATL) = (ACOHM0,ACOHM0+1,ACOHM0+2);      (PLADR) = xxxx xxcd:00=RX,01=TX,10=Reference,11=ptions;----------------------------------------------------------------------------SHARP_R:
    SKIP_IF_NOT PLLADR,1      ; c = ?
    GOTO    SHARPR14           ; 1x -> for 14 bit:REFerence or OPTions; 0x -> for 19 bit (3 Bytes):   RX  or TX
    MOVLW   SHARP_RX16         ; 00  ->  RX
    SKIP_IF_NOT   PLLADR, 0   ;  d = ?
    MOVLW   SHARP_TX16         ; 01  ->  TX
    MOVWF   FSR
    MOVLW   03
    GOTO    SHARPR2SHARPR14:                         ; 1x  -> Leng = 2 (For 14 bit)
    MOVLW   SHARP_REF8         ; 10  -> OPTions
    SKIP_IF_NOT PLADR, 0      ;  d = ?
    MOVLW   SHARP_OPT8         ; 11 -> REFerence
    MOVWF   FSR
    MOVLW   02SHARPR2:
    MOVWF   HLENG
    MOVF    INDF,W            ; Restore (MSB) from Shadow (indirect)
    MOVWF   PSHADR
    INCF    FSR,F
    MOVF    INDF,W
    MOVWF   PSHDATH
    INCF    FSR,F
    MOF     INDF,W
    MOVWF   PSHDATL
    RETURN;---------------------------------------------------------;MZP/MZP0 - Move (W)/00 to Addr=(FSR) Length=(M_CNT) MZP0:
     CLRWMZP:
     MOVWF    INDF
     INCF     FSR, F
     DECFSZ   M_CNT, F
     GOTO     MZP
     RETURN;=================================;  ****** Start of Program ******;----------------------------------------------------START:;    RAM20-RAM7F, RAMA0-RAMFF  := 00h
     CLRF     FSR
     BSF      FSR,5           ;FSR := 20hMZP00_L:
     SKIP_IF_NOT  FSR,7
     BSF      FSR, 5          ; FSR=80h -> FSR := A0h
     CLRF     INDF
     INCFSZ   FSR,F
     GOTO     MZP00_L; PowerOn Settings;Initialize A/D
  SELECT_BANK_1               ;!!Bank 1 !!!
     movlw    0x05
     movwf    ADCON1          ;Select RA0,RA1- Analog Input,vref=RA3SELECT BANK 0                  ;!! Bank 0 !!!
     movlw    B ′10000001 ′
     movwf    ADCON0          ;Select Fosc/32,Channel0-RA0,A/D-On
Initialize USART
  SELECT_BANK 1               ; !! Bank 1 !!!
    movlw   0x01              ;Set Baud Rate for 115.200KHZ =
    movwf   SPBRG             ;=14745.6KHZ / (64*(SPBRG+1))
    bcf     TXSTA,_SYNC      ;Set Asynchronoys Mode
    bcf     TXSTA,_BRGH      ;Set Low Speed Baud RateSELECT_BANK_0                   ; !! Bank 0 !!!
    bsf     RCSTA,_CREN      ; Enable RX
    bsf     RCSTA,_SPEN      ; Enable Serial Port
  SELECT_BANK_1            ;!!Bank 1 !!!
    bsf     TXSTA, _TXEN
   ;bcf     TRISC, _TX;Set RF frequency 8.014KHZ and Presc. = 4 = T2CON, 0:=1 RF!!!
 SELECT_BANK_1             ;!!Bank 1 !!!
  movlw    RF_PR2  ;(RF)  ;14745.6/(4*8kHz) - 1 = 115.2-1 = 114;Set PWM frequency 8*7=56KHZ ;Set Timer2 for 8 kHz frequency;US(PWM) movlw     PWM_PR2        ;14745.6/(4*8kHz*7) - 1 = 64.8 = 65
    movwf   PR2            ; !! Bank 1  !!!SELECT_BANK_0               ; !! Bank 0  !!!
    movlw   01     ; (RF) ; Set Prescaler (Postscaler=1) to 4:1 = 4;US(PWM) movlw   00                ; Set Prescaler & Postacaler to 1
    movwf   T2CON
    movlw   OVERSAMPLING
    movwf   PWM_Cntr       ; Setup PWM Pulse Counter
 clrf  Sample              ; Setup Sample Index; Set PWM Duty Cycle
   CLRF    CCPR1L; Enable Timer2 Interrupt
   BCF     PIR1,_MR2IF    ;Clear Int Flag
 SELECT_BANK_1             ; !! Bank1 !!!
   bsf      PIE1,_TMR2IE  ; Enable TMR2=PR2 Int
   bsf      INTCON,_PEIE  ; Enable Peripheral Int
   bsf      INTCON,_GIE    ; Global Int Enable; Set CTS, RX_DATA to input and PWM Pin,TX DATA to Output !!Bank 1 !!
   BSF      CTS_TRIS,CTS_BIT         ; =1  ->  CTS = RC1 to Input
   BSF      RX_DATA_P, RX_DATA       ; =1  ->  RC4 to Input
   BCF      TRISC, 2                 ; =0  ->  PWM = RC2 to Output
   BCF      TX_DATA_P,TX_DATA        ; =0  ->  RA2 to Output;CCP1CON,3    = 1 -> PWM-Mode:CCP1CON<3:0> = 11xx / = 0 -> Not PWM;ADCON0,_ADON = 1 -> Yes A/D = A/D On,    = 0 -> Not A/D;======================================SELECT_BANK_0                     ;  !!Bank 0 !!!
   CALL     PLLSetup            ; Set Compander Registers to default
   NOP                ; US
   CALL     SHARPSET            ; Set SHARP  Registers to default
   MOVLW    81                  ; RESET_ACK
   GOTO     M_START2 M_START:                              ;<=== Break HUBSELECT_BANK_0                         ;!! Bank 0 !!!
   MOVLW    82M_START2:
   MOVWF    HTYPE                  ; ACK RESET(81) or BRE AK(82)
   CLRF     HLENG
   CLRF     MF                     ; 0 -> wait COMH PC -> HUB
   BSF      MF, COHM              ; Yes CORM:HUB -> PC:
   BCF      CCP1CON,3             ; Disable PWM
   BCF      ADCON0,_ADON          ; Disable A/D,Switch Off
   CLRF     MFH
   CLRF     FCOMH
   CLRF     FCOHM
   CLRF     MCODE
   CLRF     MSTATUSMLOOP00:                              ; Start PWM or A/D -> BUF_SET
   CLRF     FRF                    ; RF all over again
   CALL     BUFF_SET               ; Reset FIFO (RTS_BIT:=0 - Rec. from PC)
   NOP                             ;US; Enable Timer2                       ; !! Bank 0 !!!
   BSF      T2CON,_TMR2ON         ; Enable Timer2MLOOP:
   SKIP_IF_SET RCSTA,_OERR        ; Overrun Error Bit
   GOTO     MLCOMH                 ; 0 -> Not Error UART;Error USART:Overrun Error Bit = 1  (RCSTA=18h = 92h)
   BCF      RCSTA,_CREN     ; Receive Enable Bit := 0 -> Enable Change
   BCF      RCSTA,_OERR     ; Overrun Error Bit := 0 -> No Error
   BSF      RCSTA,_CREN     ; Restore Bit := 1MLCOMH:
   SKIP_IF_NOT MF,PWMS
   GOTO     MLPWMS           ; 1 -> PWM Mode
   NOP              ; US
   CALL     MCOMH            ; 0 -> COMM:PC -> HUB
   MOVWF    MCODE
   SKIP_IF_SET MCODE,7
   GOTO    MLCOHM            ;0Xh => Cycle:MCOMH->MCOHM->RF->
   SKIP_IF_SET MCODE,6
     GOTO    MLOOP00             ; 8Xh => Start PWM (A/D) and Stop A/D (PWM)
     SKIP_IF_SET  MCODE,5
     GOTO    M_START             ; CXh => Break HUB
     SKIP_IF_SET  MCODE,4
     GOTO    START               ; EXh => Reset HUB
     CLRF    FCOMH               ; FXh:Error COMM:FCOMH :=00h
     MOVF    MCODE,W
     MOVWF   MSTATUS
     SKIP_IF_NOT  MF,COPW
     BSF     MF,PWMS            ; FXh & COPW=1:Restore PWM Mode:PWMS:=1
     GCTO    MLCOHM              ; Cycle:MCOMH->MCOHM->RF->MLPWMS:
     NOP            ;US
     CALL    MPWMS
     NOP            ;US
     MOVWF   MCODE
     GOTO    MLCOHM              ; Cycle:MPWMS->MCOHM->...MLCOHM:
     SKIP_IF_SET  MF,COHM
     GOTO    MLCOHMRF            ; COHM = 0 -> Test COHMRF
     NOP           ;US
     CALL    MCOHM
     NOP           ;US
     MOVWF   MCODE
     GOTO    MLOOP               ; Cycle:MCOHM->MCOMHMLCOHMRF:
     SKIP_IF_SET  MF,COHMRF
     GOTO    MLADSM              ; COHMRF = 0 -> Not COHM,Test A/D
     NOP             ; US
     CALL    MCOHM               ; For COHMRF
     NOP             ; US
     MOVWF   MCODE
     GOTO    MLOOP              ; Cycle:MCOHM->MCOMHMLADSM:
     SKIP_IF_SET  MF,ADSM
     GOTO    ML_RF              ; Cycle:MCOMH->(MADSM)->RF->...
     NOP            ; US
     CALL    MADSM
     NOP               ;US
     MOVWF   MCODEML_RF:                             ; Cycle:MCOMH-> (MADSM) ->RF->...
     SKIP_IF_NOT MF,COPW
     GOTO    MLOOP               ; COPW=1: Yes PWM(Not yet[od lo] End PWM)
     SKIP_IF_NOT FRF,_BUSY
     GOTO    MLOOP               ; =1 -> RF- Busy
     SKIP_IF_NOT MF, COHM       ;                                {HE HADO ??}
     GOTO    MLOOP               ; Yes COHM:Not RF??TX/RX ?? {HE HADO ?}
     SKIP IF NOT  MF,COHMRF
     GOTO    MLOOP               ; CORMRF=1 -> Yes COHM: Not RF ??TX/RX ??
     SKIP_IF SET MF,RFTX
     GOTO    MLRFRX              ; RX:PWMS=COPW=RFTX=COHM=0: RF RX Message;TX:PWMS=COPW=0,RFTX=1:Transmit = Send Message
     NOP               ;US
     CALL    MRFTX        ; Prepare RF TX,Start TX,Transmit in Inter.
     NOP               ;US
     MOVWF   MCODE
     GOTO    MLOOP          ; Cycle:MCOMH-> (MADSM)->RF->MCOMH...MLRFRX:
     NOP               ;US
     CALL    MRFRX          ; RX:PWMS=COPW=RFTX=COHM=0:RF RX Message
     NOP               ;US
     MOOF    MCODE
     GOTO    MLOOP          ; Cycle:MCOMH-> (MADSM)->RF->MCOMH...MRS:                 ; RFTX=1:Transmit = Send Message -> Prepare RF TX
     CLRF    M8CNT
     INCF    M8CNT,F
     CLRF    FRF
     MOVLW   SYNC5L    ; Prepare Send SYNC:5 * 8 bit (01010101) to TX
     MOVWF   RFMCNT         ;5*SYNC Bytes
     MOVLW   SYNC01B
     MOVWF   RF_BYTE        ;SYNC Byte:01010101
     MOVLW       08
     MOVWF       RF CNT              ; 8 Bits
     MOVLW       TXTYPE
     MOVWF       RF FSR              ; Addr BUF TX = A1h
     BSF         FRF,_BUSY          ; Ready to RF TX
     RETLW       0 0MRFRX:                                  ; RFTX=0: Receive RF All Message
     NOP             ;US
     CLRF        M8CNT
     INCF        M8CNT,F
     CLRF        FRF
     MOVLW       RXTYPE
     MOVWF       FSR            ;Addr BUF RX = C0h(BE,BF,C0,..,CF)
     CLRF        M_CNT
     BSF         M_CNT,3       ;:= 8
     CALL        MZP0    ; MZP/MZP0 - Move (W)/00 to Addr=(FSR) Leng=(M_CNT)
     NOP                 ; US
     CLRF        RF CNT
     BSF         FRF,_BUSY     ;RFB0 - RFB7,RF_CNT,..ready to RF RX
     RETLW       00MCOMH:                       ; PC -UART R-> HUB(MBYTE)
     SKIP_IF_NOT MFH,_CMB
     GOTO        MCMH     ; 1: Yes Byte, -> Processing (HADO EGO O6PA6OTAT6}MCMHR:                       ; _CMB = 0: Read Byte from UART (PC -> HUB)
     SKIP_IF_SET PIR1,_RCIF
     RETLW       02              ; RCIF = 0 -> Not UART Byte from PC;US         CALL  IMPULS                ;TEST IMPULS |_|-        BPEMEHHO;  Yes  UART   Byte  from   PC  to   HUB    ( -> W )
     MOVF     RCREG,W
     MOVWF    MBYTEMCMH:                  ; Processing (O6PA6OTKA) MBYTE from PC
     BCF      MFH,CMB               ; CMB = 0: Byte olredy Processing
     MOVF     MBYTE,W
     SKIP_IF_NOT      FCOMH,_COM
     GOTO     MCMHCOM
     SKIP_IF_NOT      FCOMH,_LEN
     GOTO     MCMHLEN
     SKIP_IF_NOT      FCOMH,_TYP
     GOTO     MCMHTYP
     SKIP_IF_NOT      FCOMH,_SYN
     GOTO     MCMHSYN
     BSF      FCOMH,_SYN
     SKIP_IF_WNEQUL  OFF         ; 0-Byte = HEDAD0 = FFh ?
     RETLW    00                 ; Yes -> MCOMH->MCOHM->MPWMS-> .  .  .
     RETLW    OFF                ; Error(Head 0 # FFh) -> Clean FCOMHMCMHSYN:                   ; Sync-Byte = 05
     BSF      FCOMH, _TYP
   SKIP_IF_WNEQUL MSYNC
     RETLW    00    ; = 05h ->MCOMH->MCOHM->MPWMS->MADSM->MCOMH..
     RETLW    0F5             ;Error(Head 1 # 05h) -> Clean FCOMHMCMHYP:                ; Type:p.6=1=TOY / 0=HUB;p.5=1=Yes ACK / 0=No
     BSF      FCOMH,_LEN
     MOVWF    MTYPE
     MOVWF    SCOMH
     RETLW    00              ; MCOMH->MCOHM->MPWMS->MADSM->MCOMH..MCMHLEN:
     BSF      FCOMH, _COM
     ADDWF    SCOMH,F        ; KS
     MOVWF    MHCNT
     MOVLW    ACOMH0
   SKIP IF SET   MTYPE,6
     GOTO     MCMHLEN2        ; =0:PC -> HUB:COMH; =1: PC -HUB-RF_TX-> TOY: COM RF TX
  SKIP_IF_NOT  MF,RFTX
    CLRF    FRF              ; 1:RF TX -> Stop TX
     BCF      MF,RFIX          ; always to RF RX
     MOVLW    RXTYPE
     MOVWF    FSR
     MOVF     MTYPE,W
     MOVWF    INDF
     INCF     FSR,F
     MOVF     MHCNT,W
     MOVWF    INDF
     ADDWF    MHCNT,W            ; (W) := 2*(MHCNT)
     ADDLW    06                  ; 2*3 (TYPE+LENG+KS)   ->
     MOVWF    TX_CNT              ; For RF TX:(TX_CNT) := 2*(Length+3)
     MOVLW    BMT0MCMHLEN2:
     MOVWF    ACOMH               ; = ACOMH0(BMH0) or BMT0(BUFF RF TX)
     BCF      FCOMH,_2L3         ; Length = 0, 2...even (4ETH)
     SKIP_IF_NOT   MHCNT,0
     BSF      FCOMH,_2L3         ; =1 -> Length = 1, 3,  .  .  . odd {HE4ETH}
     INCF     MHCNT,F            ;CNT := Leng COMM + 1(KS)
     RETLW    00                  ;MCOMH->MCOHM->MPWMS->MADSM->MCOMH...MCMHCOM:
     MOVF     ACOMH,W
     INCF     ACOMH,F
     MOVWF    FSR
     MOVF     MBYTE,W
     MOVWF    INDF
     ADDWF    SCOMH,F            ; KS
     DECFSZ   MHCNT,F
     RETLW    00       ;Current {TEK} Byte COMH:->MCOMH->(MADSM)->MCOMH;End COMM: (W) = KSR,    SCOMH = KS + KSR ( = 2*KS ?  )
     ADDWF    INDF,W             ;(W) := KSR + KSR
  SKIP_IF_WEQU SCMH
     RETLW    0F7                 ; 2*KSR # KS+KSR -> KS # KSR -> Error; KS=KSR -> OK:Prepare to RF TX -> TOY and to Read COMM again {CHOBA}
    CLRF      FCOMH               ; Prepare to Read COMM again {CHOBA}
    SKIP_IF_NOT  MF,COPW
    BSF       MF,PWMS            ; COPW=1: PWM Not end => Continue PWM
     SKIP_IF_SET     MTYPE,6
     GOTO      MCOMHAN            ; 0: PC-> HUB:COMH-> Analiz MTYPE,COMH
     BSF       MF,RFTX           ; 1: PC -HUB-RF TX-> TOY:RF TX
     RETLW     00                 ;  ->MRFTX- >MCOHM-> (MADSM) ->MCOMHMCOMHAN:         ; COMH end:ANALIZ MTYPE&COMH and PROCESSING{O6PA6OTKA} COMH
     SKIP_IF_NEQUL MTYPE,00
     GOTO      MH00PWM            ; PC -> FIFO (1K) and Enable  PWM !!!
     SKIP_IF_NEQUL MTYPE,01
     GOTO      MH01PLP   ; Fluent End PWM {PLABH 3ABEPWEHIE DO IC4EP BUF}
     SKIP_IF_NEQUL MTYPE,02
     GOTO      MH02ATD            ; Enable A/D:HUB -> PC
     SKIP_IF_NEQUL MTYPE,11          ;USx2  { BPEMEHHO }
     GOTO      MH11TSTPW          ; PC -> HUB (PWM):00 01..FE FE(#FF)00
     SKIP_IF_NEQUL MTYPE,12         ;USx2{ BPEMEHHO }
     GOTO      MH12TSTAD          ; HUB -> PC (A/D):00 01..FE FE(#FF)00
     SKIP_IF_NEQUL MTYPE,20
     GOTO      MH20VER            ; HUB Get Version
     SKIP_IF_NEQUL MTYPE,21
     RETLW     0E0                ; HUB Reset => START
     SKIP_IF_NEQUL MTYPE,22
     RETLW     0C0                ; HUB Break:Stop PWM and A/D => M_START
     SKIP_IF_NEQUL MTYPE,23
     GOTO      MH23WMC            ; Write to PLL(Compander Motorola)
     SKIP_IF_NEQUL MTYPE,24
     GOTO      MH24RMC            ; Read from Shadow Memory (Comp. Motorola)
     SKIP_IF_NEQUL MTYPE,25
     GOTO      MH25WSH            ; Write to SHARP
     SKIP_IF_NEQUL MTYPE,26
    GOTO    MH26RSH           ; Read from Shadow Memory SHARP
    SKIP_IF_NEQUL MTYPE,2E
    GOTO    MH2EMES           ; HUB Get StatusMH00PWM:            ; PC -> FIFO ((3APOLHEHIE FIFO HA)1K) and Enable PWM
    BCF     ADCON0, __ADON   ; A/D  Off
    BCF     MF,ADSM          ; Disable A/D
    BSF     MF,COPW
    BSF     MF,PWMS
    RETLW   80                ;=> MLOOP00 -> BUF SET ->MPWMS->MCOMH..MHO1PLP:                ; Fluent End PWM {PLABH 3ABEPWEHIE DO IC4EP Buff}}
    SKIP_IF_SET MF,COPW
    RETLW   01                ; COPW=0 = Not Source PWM:Ignore C0MM
    BSF     MFH, PLA         ; PWM - Not Finish.MF,PWMS:=1 already !!
    RETLW   00                ; MCOMH->MPWMS->MCOHM-> (MADSM) ->MPWMS .MH02ATD:                 ; Enable A/D: HUB -> PC (and Disable PWM)
    BCF     MF,PWMS
    BCF     MF,COPW
    BSF     ADCON0,_ADON      A/D Switch On
    BSF     MF,ADSM
    RETLW   80     ;=> MLOOP00->BUF SET->MCOMH->MCOHM|MADSM->MCOMH..MH11TSTPW:      ; TEST: PC -> HUB (PWM):00 01..FE FE(#FF)00 01..
    CLRF    MM
    CLRF    MM1
    CLRF    MM11PW
    BSF     MFH,TSTPW
    BSF     MF,COPW
    BSF     MF,PWMS
    RETLW   00                ; MCOMH->MCOHM->MPWMS-> (MADSM) ->MPWMSMH12TSTAD:      ; TEST:  HUB -> PC (A/D):00 01..FE FE(#FF)00 01..
    CLRF    MM12AD
    BSF     MFH,TSTAD
    BSF     ADCON0,ADON    ;A/D Switch On
    BSF       MF,ADSM
    RETLW     00                   ; MCOMH->MCOHM|MADSM->MCOMH..MH20VER:                              ; HUB Get Version
    MOVLW     80
    MOVWF     HTYPE
    MOVLW     01
    MOVWF     HLENG
    MOVLW     M_VER
    MOVWF     ACOHM0               ;83:8= Year (98), 3= Month (March)
    BSF       MF,COHM
    BCF       FCOHM,_MES          ;Not Message
    RETLW     00                    ;MCOMH->mCOHM->MCOMH...MH23WMC:         ; Write to PLL(Compander Motorola).Addr,MSB-Byte,LSB
    CALL      PLL_W
    MOVLW     83
    GOTO      MH24RMC2MH24RMC:         ;Read from Shadow Memory (Compander Motorola)
    MOVLW     84MH24RMC2:
    MOVWF     HTYPE
    MOVLW     03
    MOVWF      HLENG
    CALL      PLL_R ;(ACOHM0) := (ACMH0),Restore MLB,LSB
    BSF       MF,COHM
    BCF       FCOHM,_MES    ;Not Message
    RETLW     00             ;MCOMH->MCOHM->MCOMH...MH25WSH:         ;Write to SHARP
    CALL      SHARP_W
    MOVLW     85
    MHTO      MH26RSH2MH26RSH:         ;Read from  Shadow Merry SHARP
    MOVLW     86MH26RSH2:
    MOVWF     HTYPE
     CALL    SHARP_R
     BSF     MF,COHM
     BCF     FCOHM,_MES        ; Not Message
     RETLW   00                 ; MCOMH->MCOHM->MCOMH ...MH2EMES:                           ; HUB Get Status
     BSF     MF, COHM
     BSF     FCOHM,_MES        ; Message Status
     RETLW   00                 ; MCOMH->MCOHM->MCOMH...MCOHM:                      ;  HUB(HBYTE) -UART W-> PC
     SKIP_IF_NOT CTS_TRIS,CTS_BIT        ; CTS = RC1
     RETLW   04                 ; CTS=1 => PC Not Ready to Read;    Check USART Busy
   SELECT_BANK_1                ; !! Bank 1  !!!
     SKIP_IF_NOT TXSTA,_TRMT
     GOTO    MCHM               ; =1 it is possible Send HUB -> PC
SELECT_BANK_0                   ;  !! Bank 0 !!! Not Delete !!!
     RETLW   03                 ; USART busy: MCOHM->MCOMH(MPWMS)...MCHM:                    ; Ptepare (PODGOTOBKA) HBYTE to Send HUB -> PCSELECT_BANK_0                     ; !! Bank 0 !!!Mot Delete !!!
    SKIP_IF_NOT  FCOHM,_COM
    GOTO    MCHMCOM
    SKIP_IF_NOT  FCOHM,_TYP
    GOTO    MCHMTYP
    SKIP_IF_NOT  FCOHM, _SYN
    GOTO    MCHMSYN
    BSF     FCOHM, _SYN
    MOVLW   OFF                 ;0-Byte Packet = HEAD0 = FFh
    GOTO    MCOHMSENDMCHMSYN:               ; Sync-Byte = 05
    BSF     FCOHM, _TYP
    MOVLW   MSYNC
    GOTO    MCOHMSEND MCHMTYP:
    BSF     FCOHM,_LEN
    SKIP_IF_SET FCOHM, _MES
    GOTC    MCHMYP2           ;  MES = 0 => Not Special HUB Message;Yes  Special HUB Message  (Error  or  Information):
    BCF     FCOHM, _MES
    MOVLW   8E
    MOVWF   HTYPE
    MOVLW   04
    MOVWF   HLENG
    MOVLW   M_VER
    MOVWF   ACOHM0            ; 83:8= Year (98),3 = Month (March)
    MOVF    MSTATUS, W
    MOVWF   ACOHM0+1          ; see STATUS, MCODE = HUB Status
    MOVF    BCM,W
    MOVWF   ACOHM0+2
    MOVF    BCM+1,W
    MOVWF   ACOHM0+3          ; BCM= (BCM=BCH, BCM+1=BCL) - free spaceMCHNTYP2:
    BSF     FCOHM, _COM
    CRLF    SCOHM
    MOW     HLENG,W          ; W := Length COHM (SENSOR or ACK) to PC
    ADDLW   03
    MOVWF    HM_CNT            ; CNT = n+3 = Length+3 (Type, Length,KS)
    MOVLW   HTYPE
    SKIP_IF_NOT MF,COHM
    GOTO     MCHM2             ; COHM=1: Yes COHM,Not COHMRF !
    BCF      MF,COHMRF        ; COHM = 0  ->  Not COHM, Yes COHMRF
    BSF      MF, COHM         ; Chang: COHMRF <--> COHM
    MOVF     RX_CNT,W         ; W := Length COiF (SENSOR or ACK)
    MOVWF    HM_CNT            ; CNT = n+3 = Length+3(Type,Length,KS)
    MOVLW    RXTYPEMCHM2:
    MOVWF    ACOHMMCHMCOM:
    DECFSZ   HM_CNT,F
    GOTO     MCHMCOM2 ; END COHM: SENSOR (ACK) already Sent to PC: Send KS,COHM:=0,FCOHM:=0
    BCF       MF, COHM
    CLRF      FCOHM
    MOVF      SCOHM, W
    MOVWF     TXREG             ; Send KS to  PC,and then
    RETLW     00                ; MCOHM->MCOMH..MCHMCOW2:                          ; Send Current (TEK) Byte COHM to PC
    MOVF     ACOHM,W
    INCF     ACOHM,F
    MOVWF    FSR
    MOVF     INDF,W
    ADDWF    SCOHM,F           ; KS;(HE HADO?)      GOTO      MCOHMSEND
    NOPMCOHMSEND:                         ;  Send Byte to USART
    MOVWF     TXREG
    RETLW     00                ;  MCOHM->MCOMH...
                                ;                       /MPWMS:          ;PC -UART-> MBYTE -FIFO-> Sample PWM====-
    SKI_IF_SET MFH,_PWM        ;                       \
    GOTO   MPWM     ; _PWM = 0 => Sample od lo Sing, in Int(8KHZ) :=1
    SKIP_IF_SET MFH,_DAT       ;             {BCE EWE PO4TI}
    GOTO     MPWM               ; DAT = 0 -> FIFO still almost empty < 1K; Prepare  Next  Sample to Play
    CLRW
    CALL     BUF_R
  SKIP_IF_C
    GOTO     MPWSAMPL           ; C = 0  -> FIFO Not empty  -> OK
    SKIP_IF_SET  MFH,PLA
    GOTO     MPWM               ; FIFO empty & Not PLA end; C=1 & PLA=1:  FIFO empty & PLA end: Stop PWM, COHM(ACK) to PC and Wait COMM
    BCF      MFH, PLA
    BCF      MFH,_DAT          ; FIFO empty -> especially{TEM 6OLEE} < 1K
   BCF  CCP1CON,3           ; 0 -> Not PWM;Set RF frequency 8.014KHZ and Presc. = 4 = T2CON,0:=1 RF !!!
 SELECT_BANK 1               ;   !!  Bank 1   !!!
   movlw  RF PR      ;(RF)  ;  14745.6/(4*8kHz)  - 1 = 115.2-1 = 114
   movwf  PR2                ;   !!  Bank 1 !!!
 SELECT_BANK_0               ;   !!  Bank 0 !!!
   BSF    T2CON,0   ;(RF)  ;   Set Prescaler (Postscaler=1) to 4:1 = 4
   BCF    MF,PWMS
   BCF    MF,COPW
   BSF    MF,COHM
   CLRF   HLENG
   MOVLW  90                 ;  Status: Finish PWM(COHM:HM0PWMF)
   MOVWF   HTYPE
   RETLW  09                 ;  Stop PWM and => COHM => HM90PWMFMPWSAMPL:                ; C=0  ->  FIFO Not empty  -> OK
   MOVWF   Sample            ; Set next PWM Sample
   BCF     MFH,_PWM         ; __PWM := 0  -> Prepare:Not Read
   BSF     MFH,TSMPL        ; 1: Sample renewed {O6HOBILOC6}
   SKIP_IF_NOT  MM1,3
   GOTO    MPWM
   RLF     MM1,W
   ANDLW   OE
   ADDLW   OF0
   MOVWF   FSR
   MOVF    Sample,W
   MOVWF   INDF
   INCF    MM1,F
   INCF    FSR,F
   DECF    BARL,W
   MOVWF   INDFMPWM:           ;Read Packet Data: PC -UART->HUB ->FIFO8K
   SKIP_IF_SET   PIR1,_RCIF
   RETLW   02               ; RCIF = 0 -> Not UART Byte from  PC;US      CALL    IMPULS           ;TEST IMPULS |_|-          BPEMEHHO; Yes  UART Byte from PC to HUB          ( -> W )
    MOVF    RCREG,W
    MOVWF   MBYTE
    SKIP_IF_WEQUL OFF
    GOTO    MPWM2               ; MBYTE # FFh  ->  Not COMM(Audio PWM)
    BSF     MF, COPW     ;US?; MBYTE = FFh -> bat Source State =PWM ->
    BCF     MF, PWMS           ; -> may be {HABEPHO} yes COMH -> End PWM
    BSF     MFH,_MB            ; and may be  Start COMM:Head0 = FFh
    RETLW   08                  ; Yes FFh: MPWMS->COHM->(MADSM)->MCOMH..MPWM2:                             ; Audio,PWM   (No COMM)
    MOVF    MBYTE,W
    CALL    BUF_W
    NOP                         ; US
    SKIP_IF_NOT MM,3
    GOTO    MPWM TST
    RLF     MM,W
    ANDLW   OE
    ADDLW   OE0
    MOVWF   FSR
    MOVF    MBYTE,W
    MOVWF   INDF
    INCF    MM, F
    INCF    FSR, F
    DECF    BAWL,W
    MOVWF   INDFMPWM_TST:
  SKIP_IF_NOT  MFH,_DAT
    RETLW   00      ; 1: Yes Data-min in FIFO for PWM-Out: BCM < 1C00;Start and Beginning Read Data from PC (HUB)  to FIFO until BCM >= 1C00h
  SKIP IFM_LELM BCM,1C,00    ; Skip if (BCM,BCM+1) < 1C00h = 7168
   RETLW    00                ; MCOMH->MCOHM->MPWMS->MADSM->MCOHM...
   BSF      MFH,_DAT   ;BCM < 1C00 -> Yes 400h Byt es in FIFO (>1000);Enable PWM;Set PWM frequency 8*7=56KHZ  ;Set Timer2 for 8 kHz frequency
 SELECT_BANK_1              ; !!  Bank 1  !!!
   movlw    PWM_PR2         ; 14745.6/(4*8kHz*7) - 1 = 64.8 = 65
   movwf    PR2             ; !! Bank 1  !!!SELECT_BANK_0                ; !! Bank 0  !!!
   BCF     T2CON, 0          ; Set Prescaler & Postscaler to 1
   movlw   OVERSAMPLING
   movwf   PWM_Cntr           ; Setup PWM Pulse Counter
   MOVLW   OF                 ; PWM - Mode:CCP1CON<3:0> =11xx
   MOVWF   CCP1CON
   RETLW   00                 ; MPWMS->MCOHM-> (MADSM)->MCOMH...MADSM:         ;   -=A/D -FIFO->HBYTE -UART-> PC
   SKIP_IF_SET MFH,_AD
   GOTO    MAD                ; A/D Not Started;US      SKIP_IF_SET ADCON0,_ADON;US      GOTO    MAD               ; ADCON0,ADON = 0  -> Not A/D;US;ADCONO,_ADON = 1  ->  Yes A/D = A/D On
     SKIP_IF_NOT ADCONO, _GO
   GOTO    MAD             ;_GO = 1  -> A/D Busy;_GO = 0 ->  A/D Complete:Read A/D Reset and  Store to FIFO
   MOVF    ADRES,W        ; ADRES = 1EH = A/D Result Register
 SKIP_IF_SET   MFH, TSTAD
   GOTO    MADSM2          ; 0 = No Test A/D:00 01..FE FE..;Test HUB -> PC A/D: 00 01.. FE FE(#FF)00 ..
   MOVF    MM12AD,W
   INCF    MM12AD,FMADSM2:
   CALL    BUF_W
   BCF     MFH,_AD        ; Set A/D Not Started FlagMAD:                   ; Send Samples from FIFO to USART -> PC
   SKIP_IF_NOT CTS_TRIS,CTS_BIT         ;CTS = RC1
   RETLW    04              ; CTS=1 => PC Not Ready to Read;  Check USART Busy
 SELECT_BANK_1              ;  !!  Bank 1  !!!
   SKIP_IF_NOT TXSTA,_TRMT
   GOTO   MAD2              ; =1 it is possible Send  HUB -> PCSELECT BANK 0                  ;   ! !  Bank 0  !!! Not Delete !!!
    RETLW   03                 ;  USART busy:MADSM->MCOMH->MPWMS...MAD2:SELECT_BANK_0                    ; !! Bank 0  !!! Not Delete !!!
    CALL    BUF_R
  SKIP_IF_NC
    RETLW   OD                 ; C = 1  ->  BUF empty  -> Cycle
    MOVWF   HBYTE
  SKIP_IF_WNEQUL OFF
     DECF    HBYTE,F          ; (HBYTE) = FFh -> Change:FFh -> FEh
     MOVF    HBYTE,W
     MOVWF   TXREG             ; HBYTE -UART-> PC;US        CALL    IMPULS             ; TEST IMPULS    |_|-
     RETLW   00                ; MADSM->MCOMH-> (MPWMS) ->;{ {TEST   TMPULS        UM                      ; BPEMEHHOIMPULS:                   ; TEST IMPULS  |_|-            BPEMEHHO
     BTFSC   PORTA, 2          ; Test IMPULS Pin -> XOR:  0 <=> 1BPEMEHHO
     GOTO    IMPULS 1           ; BPEMEHHO
     BSF     PORTA,2           ;  0->1 ; BPEMEHHO
     GOTO    IMPULSEND                    ; BPEMEHHOIMPULS1:                                     ; BPEMEHHO
     BCF     PORTA, 2          ;  1->0 ; BPEMEHHOIMPULSEND:                                   ; BPEMEHHO
     RETURN                               ; BPEMEHHO; TEST   IMPULS }      ;UM                      ; BPEMEHHO   UM)};-------------------------------------------------------; ****** Interrupt Handler ******    BANK 0  !!!;-------------------------------------------------------INT_HANDLERR:
      INT_STORE;         MOVF     PCLATH,W;         MOVWF    PCLATH_TMP       ;Store PCLATH to PCLATH_TMP in Bank0;         CLRF     PCLATH           ; Page Zero,regardless of current page
;  =>     BANK 0      !!!!!!
    SKIP_IF_SET PIR1,_TM R2IF       ; if TMR2 Interrupt ?
    GOTO    IRET                     ; _TMR2IF = 0 -> No TMR2; TMR2IF = 1  ->  Yes  TMR 2  Interrupt    !!  Bank 0   !!!;   Process Timer2 Int  ->     Test  and Set  PWMTMR2_INT:
    BCF     PIR1,_TMR2IF      ; Clear Int Flag
    SKIP_IF_NOT T2CON, 0      ; !!if 1 -> Presc = 4 -> Not 56KHZ
    GOTO    TMR2_8KHZ          ; 1 -> RF (Not PWM)   ->  8KHZ (Not 56KHZ)
    DECFSZ  PWM_Cntr, F
    GOTO    IRET               ; PWM_Cntr # 0
    movlw   OVERSAMPLING       ; =7  ->  8KHZ * 7 = 56 KHZ
    movwf   PWM_Cntr           ; Reset PWM Pulse CounterTMR2_8KHZ:
    INCFSZ  TMR_125U,F        ; 125 U = 17.90364S84U * 7 = 125.32552088U
    GOTO    TMR_TTME           ; Time= (TMR_125U) * 125.32S5U
    INCFSZ  TMR_32MS,F        ; 32 MS = 125.32552088U*256 = 32.083333345MS
    GOTO    TMR_TIME           ; Time = (TMR_3MS) * 32.08333 MS
    INCF    TMR_8SEC,F        ; 8 SEC = 32.08333MS * 256 = 8.213333336 SECTMR_TIME:                         ; Time = (TMR_8SEC) * 8.213333336 SEC
    NOP
    BSF     ADCON0,_GO        ; Start A/D
    BSF     MFH,AD            ; Set A/D Started Flag
    BSF     MFH,_PWM          ; _PWM := 1  ->  Read next Sample
    SKIP_IF_SET MF,COPW       ; and PWMS ????
    GOTO    RF BEG             ; 0 -> Not PWM Mode -> Block TX or RX;  Set New Duty Cycle             PWM Sample  8 bit: SAMPle<7:0>;                 CCPR1L<7:0>          CCP1CON<5:4>;             |0|0| | | | | | |            | | |;                  \         /              | |;                   Sampe<7:2>        Sample<1:0>;
     SWAPF  Sample,W
     ANDLW  30                      ; W<5:4> := Sample<1:0>
  BCF     CCP1CON,4
  BCF     CCP1CON,5        ; CCP1CON<5:4> := 0 0
  IORWF   CCP1CON,F        ; CCP1CON<5: 4> := Sample<1:0>
  RRF     Sample,W
  MOVWF   Sample_TMP
  RRF     Sample_TMP,W     ; W<5:0> := Sample<7:2>
  ANDLW   3F
  MOVWF   CCPR1L            ; CCPR1L  := 0 0 Sample<7:2>;------PWM Sample End------RF_BEG:                        ; Begin  Block  RF TX or RF RX
  SKIP_IF_SET   FRF,_BUSY
    GOTO    RF_END          ; BUSY=0:Wait Start RF RX/TX
    DECFSZ  M8CNT,F
    GOTO    RF_8KHZ         ; #0:Not 1 KHZ (1 KHZ = 1 MS = 8 * 125U);M8CNT = 00: Yes 1KHZ = 1002.6MS: TX |  RX  Barker or Curr. Data | RX SYNC
    BSF     M8CNT,3        ; M8CNT := 08h
  SKIP_IF_NOT   MF,RFTX
    GOTO    RF_TX           ; 1:TX & 1KHZ (& COPW=PWMS=0)  =>  TX
  SKIP_IF_NOT   FRF,_CUR
    GOTO    RX_CUR          ; 1:Wait Current Data-Bit
  SKIP_IF_NOT   FRF,_BAR
    GOTO    RX_BAR          ; 1: Wait Barker-BitRF_8KHZ:
  SKIP_IF_NOT   FRF,_BAR   ; If _BAR = 1: SYNC Full =>
    GOTO    RF_END          ; Wait 1 KHZ only for Barker or Data;Current Sinc-Bit = SYNCij
    MOVF    M8CNT,W
    SUBLW   BTM0+8          ; 8->BTM0, 7->BTM1,..,1->BTM7
    MOVWF   FSR
    BSF     STATUS,_C
  SKIP_IF_SET RX_DATA_P, RX_DATA               ; RC4
    BCF     STATUS,_C
    RLF     INDF,F         ; Shift bit to Correlator ; Compare Correlator
   SKIP_IF_EQUL   INDF,-SYNC01B       ; RF Bits Inverse. Skip if ==
     GOTO     RXNO                     ; Not Sync-Byte
     INCF     RF_CNT,F
     GOTO     RF_ENDRXNO:                                 ; Not Sync-Byte
     MOVLW    SYNC5R
     SUBWF    RF_CNT,W            ; (W):=(RF_CNT)-5
     BTFSC    STATUS, _C
     GOTO     RXOK                 ; C=1:(RF_CNT)>=5
     CLRF     RF_CNT               ; (RF_CNT) < 5 -> Start SYNC again
     GOTO     RF_ENDRXOK:
     BCF      STATUS, _C
     RRF      RF_CNT,W            ; W =RF_CNT/2
     SUBLW    07                   ; W =8-RF_CNT/2-1 = 7-RF_CNT/2
     MOVWF    M8CNT;Yes SYNC.Detected.Lock CLK
     BS F     FRF, _BAR
     MOVLW    GARK_TO              ;Max Bits beefore BARKER
     MOVWF    RF_CNT               ;Used Like Timeout Counter
     CLRF     RF_BYTE              ;Used Like BARKER Detector Buffer
     GOTO     RF_ENDRX_BAR:                               ;Wait Barker
     BSF      STATUS, _C
   SKIP_IF_SET    RX_DATA_P,RX_DATA               ;RC4
     BCF      STATUS, _C
     RLF      RF_BYTE,F           ; C=x xxxx xxxX, X:= Next Bit,MSB First
   SKIP IF NEQUL      RF_BYTE,-BARKERB      ; Skip if Not Barker
     GOTO     RX_BAR_OK            ;  Yes Barker,Detectes Barker OK
     DECFSZ   RF_CNT,F            ;  Not Barker -> Check TimeOut
     GOTO     RF_END
     CLRF     FRF                  ; TimeOut Reset,Not BAR: Start SYNC again
     BSF      FRF,ERR             ; ERR Barker: FRF,_ERR:=1 (FRF,_BUSY:=0)
    MOVLW   81
    MOVWF   RF_BYTE             ; 81=Error Code = Barker Error
    GOTO    RX_ERRRX_BAR_OK:                         ; Barker OK, Prepare to RX Current Bytes
    BSF     FRF, _CUR
    MOVLW   BTMO                ; Buff COHM = Buff RF RX
    MOVWF   RF_FSR
    BCF     FRF,_NIB
    GOTO    RF_CUR_END          ; Prepare: RF_BYTE :=FCh for Curr.BytesRX_CUR:                ; 1:Wait(Processing(O6PA6OTKA)) Current Data-Bit
    BCF     STATUS,__C       ; Bits Inverse!!! I Must: BSF STATUS,_C
  SKIP_IF_SET   RX_DATA_P,RX_DATA                ; RC4
    BSF     STATUS,_C        ; Bits Inverse!!! I Must:BCF STAtuS,_C
    RLF     RF_BYTE,F        ; C=1 1..100x..xX,X:= Next Bit, MSB First
  SKIP_IF_NC
    GOTO    RF_D              ; C=1 1..100x..xx;   C=0  0xxx xxxx=7 Bit Received,   Store Nibble
    MOVF     RF_FSR,W
    MOVWF    FSR              ;Indirect Address: BUFi.
    RRF      RF_BYTE,W       ;Cut off Bit 0, (W) :=00xx xxxx
    ANDLW    1F               ;Cut off Bit 6, (W) :=000x xxxx
    CALL     DecodeTable      ;(W) :=Decode(W)=0000 NNNN, NNNN=Nibble
    NOP               ; US    (for CEIBO:OTLADKA)
    SKIP IF NOT FRE,_NIB
    GOTO     RX_CUR_L         ; 1 -> Low Nibble RX
    MOVWF    INDF             ; 0: Hi Nibble Receive to RF BUF:
    SWAPF    INDF,F
    BSF      FRF,_NIB        ; Next Low Nibble
    GOTO     RF_CUR_END       ; Prepare: RF_BYTE :=FChRX_CUR_L:                   ; Low Nibble RX
    IORWF    INDF,W          ; (W)=All Byte
    MOVWF    INDF
    INCF     RF_FSR, F       ; To next Byte BUF RF
    BCF      FRF,_NIB        ; Next Hi Nibble
    SKIP_IF_NOT  FRF, _NLEN
    GOTO     RX_CUR_B         ;1:Not Length-Byte, Current Byte
    SKIP_IF_NOT FRF,_TYPR
    GOTO     RX_CUR_LENG       ; 1: Not Type-Byte,to Length-Byte
    BSF      FRF,_TYPR        ; Receiv Type-Byte,next Length-Byte
    MOVWF    SRF_KS            ; KS
    GOTO     RF_CUR_END        ; Prepare:RF_BYTE :=FChRX_CUR_LENG:
    BSF      FRF,_NLEN        ; Receiv Length-Byte,next Current Byte
    MOVWF    RX_CNT            ; For COHMRF
    ADDWF    SRF_KS, F        ; KS
    ADDLW    01                ; +1(Byte with KS)
    MOVWF    RF_CNT
    GOTO     RF_CUR_END        ; Prepare: RF_BYTE :=FChRX_CUR_B:
    DECFSZ   RF_CNT, F
    GOTO     RF_CUR_KS         ; Current Byte Received: KS+=Cur.Byte; RF  Receive Finish: Compare KS
    CLRF     FRF               ; FRF,_BUSY :=0. KS OK:FRF,_ERR=0
    MOVWF    RF_BYTE           ; RF_BYTE :=RX KS
   SKIP_IF_WEQU  SRF_KS        ; Skip if (W)=KS
    GOTO     RX_ERR; RF RX Successful Complete(Finish) OK! -> to PC: TOY -RF-HUB-UART-> PC
    BSF      MF,COHMRF
    GOTO      RF_ENDRX_ERR:
    BSF       FRF,_ERR           ;  ERR: FRF,_ERR :=1
    GOTO      RF_ENDRF_CUR_KS:                           ; Current Byte Received
    ADDWF     SRF_KS,F           ; KS+=Cur.ByteRF_CUR_END:                          ; Prepare:RF_BYTE :=FCh
    MOVLW     OFC
    MOVWF     RF_BYTE
    GOTO      RF_END
;---------------------------------------------;---------RF Data Transmitting;RF_TX:
       RLF     RF_BYTE,F                 ; Send Next Bit to RF,MSB First
       SKIP_IF_C
       GOTO    RFTXO
       BSF     TX_DAT_P,TX_DATA                 ;RA2=1
       GOTO    TX_DECRFTXO:
       BCF     TX_DATA_P,TX_DATA                ;RA2=0TX_DEC:                                       ; Decrement Bit Counter
       DECFSZ  RF_CNT,F
       GOTO    RF_END
       BSF     RF_CNT,3         ;RF_CNT :=8 Bits
       RLF     RF_BYTE,F        ; RF_BYTE :=SYNC-Byte again:01010101
       SKIP_IF_NOT  FRF,_CUR
       GOTO    MTX_CUR         ; 1:Yes BARker,Transmits Current half-Bytes
       DECFSZ  RFMCNT,F         ; 5 * 8bits SYNC
       GOTO     RF_END;End Sync,Transmits Barker-Byte:00110010 (Send BARKER),;but before Prepare Transmits Current half-Bytes: (0-15 Bytes)
       BCF      FRF,_NIB         ; 0 -> Hi-Nibble to TX / 1 -> Low Nibble
       BSF      FRF,_CUR         ; Yes BARker, Transmits Current half-Bytes
       MOVLW    BARKERB
       MOVWF    RF_BYTE           ; RF TX Byte:Barker = 00110010MTX_CUR:                   ;  Transmits  Current  half-Bytes,Send Message
       MOVF     RF_FSR, W
       MOVWF    FSR               ; Indirect Address: BUFi
       SKIP_IF_SET  FRF,_NIB
       GOTO     MTX_CUR_H         ; 0 -> Hi Nibble to TX
       MOVF     INDF,W           ; Low Nibble to TX, W := (BUFi) = Byte<7:0>
       INCF     RF_FSR,F         ; To next Byte BUF RF
       BCF      FRF,_NIB         ; Next Hi Nibble
       GOTO     MTX_CUR_L         ; Low Nibble Ready to Encoding and RX TX MTX_CUR_H:
     SWAPF    INDF,W             ;W:= Byte<3:0>Byte<7:4> => Hi Nibble
     BSF      FRF,_NIB           ; :=1 = Next Low NibbleMTX CUR L:
     ANDLW    OFh
     CALL     EncodeTable      ; W = Encode(W) = <7:1> 0
     NOP             ; US
     MOVWF    RF_BYTE
     DECF     RF_CNT,F        ; RF_CNT := 7 Bits (=8-1)
     DECFSZ   TX_CNT, F       ; Counter Bytes Message to TX
     GOTO     RF_END           ; TX_CNTO=2* (Length+3(TYPE,LENG,KS) ); RF TX Finished,  Message Fully Transmits !!!
     CLRF     FRF               ; FRF,_BUSY :=0
     BCF      MF, RFTX         ; RF Transmit  Finish  ->  RF RX
     GOTO     RF_ENDRF_END:                            ; End  Block  RF TX  or  RF RX
  SKIP_IF_SET   MFH,TSTPW
     GOTO     IRET              ; 0=No Test PWM: 00 01..FE FE..;Test PC -> HUB PWM:00 01..FE FE(#FF) 00..
 SKIP_IF_EQUL  MM11PW, OFF     ; Skip if MM11PW # FFh
   GOTO    TST_NOFF             ; W # FFh
   MOVLW   OFE                   ;=FFh  ->   W:=FEh
   GOTO    TST_FETST_NOFF:
   MOVF    MM1PW, WTST_FE:
 SKIP_IF_SET    MFH,TSMPL
   GOTO     IRET               ; 0: Sample Not changed
   BCF      MFH,TSMPL         ; 1: Sample renewed   (O6HOBILOC6)  (:=0)
   INCF     MM11PW, F
 SKIP_IF_WNEQU   Sample         ; Skip if (W) # Sample
   GOTO     IRET               ; W = Sample  ->  OK
   NOP                   ;US  ; MM11PW # Sample  ->  Test Error
   DECF     MM11PW, F         ; Restore MM11PW;U      CALL     IMPULS
         MOVLW   OEE
         MOVWF   MSTATUS
      SKIP_IF_NLEL  TMR_32MS,20
         GOTO     IRET              ; Time < 32MS * 32 = 1.024 Sec
         BSF      FCOHM,_MES       ; Message Error
         BSF      MF,COHMIRET:;          MOVF      PCLATH_TMP, W;          MOVWF     PCLATH            ; Restore PCLATH
       INT_RESTORE
        END ;  04.02.98  19:00  Microch.asm  PIC16C7x  Michael Kholodet;  01.04.98  14:00  1.Comment:19h => 99h;--------------------------------------------;--------------------------------------------INDF     EQU      00       ; &80h   ; Indirect Access RegisterTMRO     EQU      01       ; Timer0 Register.See Also OPTIONR Bits;FO=Fosc/4/Presc/(256-TMRO) = Fosc/4/[ 2^(OPTION<2:0>+1)  ]/(256-TMR0);TMR0=256-Fosc/4/[2^(OPTION<2:0>+1)]/FOOPTIONR      EQU      01   ; 81h   Options Register_RBPU       EQU  7       ;1-PORTB pull-up are disabled_INTEDG     EQU  6       ;1-Int on Rising Edge of RBO/INT pin_TOSC       EQU  5       ;TMRO Clock Source 1-External(RA4) 0-Internal_TOSE       EQU  4       ;External Edge_PSA        EQU  3       ;Prescaller Assigment 1-WDT 0-Timer0
          ; 2       ;Prescaller Value
          ; 1       ;   TMRO Presc = 2^Value+1    1:2,  1:4  1:256
          ; 0       ;   WDT Presc  = 2^Value      1:1,  1:2,  ... 1:128PCL      EQU     02       ;&82h   ; Program CounterSTATUS   EQU     03       ;&83h   ; Status Register_IRP    EQU   7       ;Reg. Bank Bit for Indirect Addr. 0=00-0FF, 1=100-1FF_RP1    EQU   6       ;Reg. Bank Bit Select for Direct Addr._RP0    EQU   5       ;00=00-7F,01=80-0FF_Z      EQU   2       ;Zero Flag_C      EQU   0       ;Carry FlagFSR      EQU      04       ;&84h ;Indirect Addressing Registers;  I/O  Ports   RegistersPORTA   EQU       05TRISA   EQU       05       ;  85hPORTB   EQU       06TRISB   EQU       06       ;  86hPORTC   EQU       07TRISC   EQU       07       ;  87h_RX    EQU  7        ; USART RX Pin       RC7_TX    EQU  6        ; USART TX Pin       RC6PCLATH  EQU       0A       ; &8Ah;    Interrupt RegistersINTCON    EQU     0B       ;&8B     ;Interrupts Config. Register _GIE     EQU  7       ; Global Int Enable Bit_PEIE    EQU  6       ; Peripheral Int Enable Bit_T0IE    EQU  5       ; Timer0 Int Enable Bit_T0IF    EQU  2       ; Timer0 Int FlagPIR1     EQU       0C          ; Interrupts Status Flags Register_ADIF    EQU  6       ; A/D Int Flag_RCIF    EQU  5       ; USART Receive Int Flag_TXIF    EQU  4       ; USART Transmit Int Flag_SSPIF   EQU  3       ; SSP Int Flag_CCP1IF  EQU  2       ; TMR1 Capture Int Flag_TMR2IF  EQU  1       ; TMR2=PR2 Int Flag_TMR1IF  EQU  0       ; TMR1 Overflow Int FlagPIE1     EQU       0C     ;  8Ch  ; Peripheral Ints Control Register_ADIE    EQU  6       ; A/D Converter Int Enable Bit_RCIE    EQU  5       ; USART Receive Int Enable Bit_TXIE    EQU  4       ; USART Transmit IntEnable Bit_SSPIE   EQU  3       ; SSP Int Enable Bit_CCP1IE  EQU  2       ; CCP1 Int Enable Bit_TMR2IE  EQU  1       ; TMR2=PR Int Enable Bit_TMR1IE  EQU  0       ; TMR1 overflow Int Enable BitTMR1L    EQU  0E   ; Holding R for the Least Signif.Byte of TMR1 RegTMR1H    EQU  0F   ; Hold. Reg for the Most Significant Byte of 16-b TMR1T1CON   EQU      10       ; Timerl Control Register;   Bit    5-4    Prescale:11-1:8,10-1:4,01-1:2, 00-1:1_TMR1ON  EQU  0      ;1=> Enables / 0 => Stops TIMER1T2CON    EQU      12   ; Timer 2 Control Register;     Bit    6-3  Postscale: 0000-1,0001-2, ...1111-16_TMR2ON  EQU  2     ; 1=> Timer2 On;   Bit   1-0   Prescaler: 00-1,01-4,1x-16PR2  EQU  12   ;   92h  Timer 2 Period Reg: PR2=(Fosc/[4*Fuser*Presc])-1;   SSP Module RegistersSSPBUF    EQU      13       ; SSP Buffer RegisterSSPCON    EQU      14       ; Sync Serial Port Control Register_WCCOL   EQU  7         ; Write Collision Bit (0-No Collision)_SSPOV   EQU  6         ; Receive owerflow Indicator  (0-No owerflow)_SSPEN   EQU  5         ; SSP Enable Bit _CKP    EQU  4        ; Clock Polarity Bit
                  ; Bits 3-0 Mode SelectSSPSTAT   EQU   14   ; 94h  ; SSP Status Register_BF      EQU   0   ; Buffer Full Status Bit;    Capture/Compare/PWM Module  1CCPR1L      EQU  15       ; Capture/Compare/PWM Register 1 LSBCCPR1H      EQU  16       ; Capture/Compare/PWM Register 1 MSBCCP1CON     EQU  17       ; Capture/Compare/PWM Control Register 1_CCP1M0  EQU  0    ; Bit 3-0:0100=Falling / 0101 =Rising;    USART Module RegistersRCSTA       EQU  18       ; Receive Status & Control Register_SPEN     EQU  7    ; Serial Port Enable Bit_RX9      EQU  6_SREN     EQU  5_CREN     EQU  4    ; Receive Enable Bit_FERR     EQU  2    ; Framing Error Bit_OERR     EQU  1    ; Overrun Error Bit_RX9D     EQU  0TXSTA      EQU  18   ; 89h  ; Transmit Status & Control Register_CSRC     EQU  7    ; Clock Source Select_TX9      EQU  6    ; 9-Bit Transmit Enable Bit_TXEN     EQU  5    ; Transmit Enable Bit_SYNC     EQU  4    ; Mode Select Bit 1-Synchronous,0-Asychronous_BRGH     EQU  2    ; Hi Baud Selectt 1-Hi,0-Low_TRMT     EQU  1    ; Transmit Status 1-Empty, 0-Full_TX9D     EQU  0    ; 9th bit of DataTXREG     EQU  19   ; Tranceive RegisterSPBRG     EQU  19   ; 99h ;Baud Rate Register Baud=Fosc/[64(SPBRG+1)]RCREG     EQU  1A   ; Receive Register;   Capture/Compare/PWM Module  2CCPR2L    EQU  1B   ; Capture/Compare/PWM Register 1 LSBCCPR2H    EQU  1C   ; Capture/Compare/PWM Register 1 MSBCCP2CON   EQU  1D   ; Capture/Compare/PWM Control Register 2;   A/D  Convertor  Module  RegistersADRES       EQU  1E       ; A/D Convertion ResultADCON0      EQU  1F       ; A/D Port Config. Register_ADCS1      EQU  7    ; A/D Clock Select Bits_ADCS0      EQU  6    ; 00-Fosc/2 01-Fosc/8 10-Fosc/32 11-Frc
                  ;  Bits  5-3 -Channel Select 0-7 _GO      EQU  2    ;A/D Conversion Status/Start Bit_ADON    EQU  0    ;A/D Converter Module On/OffADCON1   EQU  1F    ; 9Fh  ; A/D Port Channels Select Bits;----------------------------------------------------;  *******  MACRO  *******;----------------------------------------------------SELECT_BANK_0    MACRO
    bcf    STATUS,_RP0    ;0 bank 0
    ENDMSELECT_BANK_1     MACRO
    bsf    STATUL_RP0    ;  1 bank 1
    ENDMSKIP_IF_Z         MACRO
    btfss  STATUS,_Z    ;  Skip if ZERO:Z=1
    ENDMSKIP_IF_NZ        MACRO
    btfsc  STATUS,_Z    ;  Skip if Not ZERO:Z=0
    ENDMSKIP_IF_C         MACRO
    btfss  STATUS,_C    ;  Skip if C=1
    ENDMSKIP_IF_NC        MACRO
    btfsc  STATUS,_C    ;  Skip if C=0
    ENDMSKIP_IF_SET       MACRO Reg,Bit
    btfss  Reg,Bit      ;  Skip if Bit=1
    ENDMSKIP_IF_NOT       MACRO Reg,Bit
    btfsc  Reg,Bit      ;  Skip if Bit=0
    ENDMSKIP_IF_NLESS     MACRO X,Y ;  Skip if  X>=Y
    movf   Y,W
    subwf  X,W          ;W=X-Y /*if was barrow Carry=0*/
    btfss  STATUS,_C    ;Skip if  X>= Y (C=1)
    ENDMSKIP_IF_LESS      MACRO X,Y ;Skip if  X<Y
    movf    Y,W                ;W=Y
    subwf   X,W                ;W=X-Y/*if was barrow Carry=0*/
    btfsc   STATUS,_C         ;Skip if X<Y      (C=0)
    ENDMSKIP_IF_EQUL       MACRO X,L       ;Skip if (X)=(L)
    MOVF    X,W
    XORLW   L
    SKIP_IF_Z                   ;Skip if (X)=(L)
    ENDMSKIP_IF_NEQUL      MACRO X,L       ;Skip if (X) # (L)
    MOVF    X,W
    XORLW   L
    SKIP_IF_NZ                  ;Skip if (X) # (L)
    ENDMSKIP_IF_WEQUL      MACRO L          ;Skip if (W)=(L)
    XORLW   L
    SKIP_IF_Z                   ;Skip if (W)=(L)
    ENDMSKIP_IF_WNEQUL     MACRO L          ;Skip if (W) # (L)
    XORLW   L
    SKIP_IF_NZ                  ;Skip if (W) # (L)
    ENDMSKIP_IF_WEQU       MACRO X          ;Skip if (W)=(X)
    XORWF   X,W
    SKIP_IF_Z                   ;Skip if (W)=(X)
    ENDMSKIP_IF_WNEQU      MACRO X          ;Skip if (W) # (X)
    XORWF   X,W
    SKIP_IF_NZ                  ;Skip if (W) # (X)
    ENDMSKIP_IF_LEL        MACRO X,L       ;Skip if  X<L
    MOVLW   L                   ;W=L
    SUBWF   X,W                ;W=X-L/*if was barrow Carry=0*/
    btfsc   STATUS,_C         ;Skip if X<L      (C=0)
    ENDM SKIP_IF_NLEL        MACRO X,L     ;Skip if X>=L
    MOVLW   L                  ;W=L
    SUBWF   X,W               ;W=X-L/*if was barrow Carrv=0*/
    btfss   STATUS,_C        ;Skip if X>=L      (C=1)
    ENDMSKIP_IFM_LELM       MACRO X,L,M  ;Skip if (X,X+1)<L,M
    MOVLW   L
    SUBWF   X,W               ;W:=(X)-L
    SKIP_IF_C
    GOTO    S+7                ;C=0->(X)<L->Skip
    SKIP_IF_Z                  ;C=1->(X)>=L
    GOTO    S+4                ;Not Zero->(X)>L->Not Skip
    MOVLW   M                  ;(X)=L->check(X+1),M
    SUBWF   X+1,W             ;W=(X+1)-M
    SKIP_IF_NC                 ;Skip if(X,X+1)<L,M
    ENDMSKIP_IFM_NLELM      MACRO X,L,M  ;Skip if(X,X+1)>=L,M
    MOVLW   L
    SUBWF   X,W               ;W:=(X)-L
    SKIP_IF_C
    GOTO    S+6                ;C=0->(X)<L->Not Skip
    SKIP_IF_Z                  ;C=1->(X)>=L
    GOTO    S+5                ;Not Zero->(X)>L->Skip
    MOVLW   M                  ;(X)=L->check(X+1),M
    SUBWF   X+1,W             ;W=(X+1)-M
    SKIP_IF_C                  ;Skip if(X,X+1)>=L,M
    ENDMSKIP_IFM_LESS       MACRO X,Y     ;Skip if(X,X+1)<(Y,Y+1)
    movf    Y,W
    subwf   X,W               ;W:=(X)-(Y)
    SKIP_IF_C
    GOTO    S+7                ;C=0->(X)<(Y)->Skip
    SKIP_IF_Z                  ;C=1->(X)>=(Y)
    GOTO    S+4                ;Not Zero->(X)>(Y)->Not Skip
    movf    Y+1,W             ;(X)=(Y)->check(X+1),(Y+1)
    subwf   X+1,W             ;W=(X+1)-(Y+1)
    SKIP_IF_NC                 ;Skip if(X,X+1)<(Y,Y+1)
    ENDMSKIP_IFM_NLESS      MACRO X,Y     ;Skip if(X,X+1)>=(Y,Y+1)
    movf    Y,W
    subwf   X,W                 ;W:=(X)-(Y)
    SKIP_IF_C
    GOTO    S+6                  ;C=0->(X)<(Y)->Not Skip
    SKIP_IF_Z                    ;C=1->(X)>=(Y)
    GOTO    S+5                  ;Not Zero->(X)>(Y)->Skip
    movf    Y+1,W               ;(X)=(Y)->check(X+1),(Y+1)
    subwf   X+1,W               ;W=(X+1)-(Y+1)
    SKIP_IF_C                    ;Skip if(X,X+1)>=(Y,Y+1)
    ENDMSKIP_IFM_Z      MACRO  X             ;Skip if(X)=(X+1)=00h
    MOVF    X,F
    SKIP_IF_Z
    GOTO    S+3                  ;(X) # 00h
    MOVF    X+1,F               ;(X)=00h
    SKIP_IF_Z                    ;Skip if(X)=(X+1)=00h
    ENDMSKIP_IFM_NZ     MACRO  X             ;Skip if(X) # 00h .or.(X+1) # 00h
    MOVF    X,F
    SKIP_IF_Z
    GOTO    S+4                  ;(X) # 00h=>Skip
    MOVF    X+1,F               ;(X)=00h
    SKIP_IF_Z                    ;Skip if(X) # 00h.or.(X+1) # 00h
    ENDMINCM            MACRO  X             ;X=(XH,XL):=X++(+=1)
    INCFSZ  X+1,F
    GOTO    S+2
    INCF    X,F                 ;X=(XH,XL):=X++(+=1)
    ENDMDECM            MACRO  X             ;X=(XH,XL):=X--(-=1)
    MOVF    X+1,F
    SKIP_IF_NZ
    DECF    X,F                 ;(XL)=(X+1)=0->(XH)--(-=1)
    DECF    X+1,F
    ENDMINT_STORE          MACRO
    movwf   W_TMP                ;Store W to W_TMP in bank one or zero
    swapf   STATUS,W            ;Store swapped STATUS to W
    CLRF    STATUS               ;0 bank 0
    movwf   STATUS_TMP         ;Store swapped STATUS to STATUS_TMP inBank0
    MOVF    FSR,W
    MOVWF   FSR_TMP            ;Store FSR to FSR_TMP
    ENDMINT_RESTORE          MACRO
    SELECT_BANK_0              ;0 bank 0
    MOVF    FSR_TMP,W
    MOVWF   FSR                ;Restore FSR
    swapf   STATUS_TMP,W      ;Load W with Stored STATUS
    movwf   STATUS             ;Restore STATUS and Bank
    swapf   W_TMP,1           ;Swap W_TMP
    swapf   W_TMP,W           ;Swap W_TMP to W
    RETFIE
    ENDM ;06.04.98 19:30  MHfifo8K.asm FIFO 8 KB Michael Knolodenko,Creator;06.4;2.BF=42,BYTE=43(before 40,41);16.3:1.Only  GG=RC5.Not Gl(RC4) Not G2;;19.2:1.Change:G1:=RC4(NotA2=TEST),(CTS:=RC1 in MH.asm);12.2:1.Delete NOP-s in ″B_IN″,″B_OUT″;--------------------------------------------------;****** Constants ******;--------------------------------------------------BC_rest EQU     10       ;=16BCH_max EQU     20       ;8K->20,SET BCM0:BCM:=8192=2000hB0x1F   EQU     1F       ;8K->1F;--------------------------------------------------;***** Variables ******;--------------------------------------------------BF     EQU     42        ;Flags:FW   EQU   1             ;0->BUF ampty(FR=0)or full(FR=1)FR   EQU   0BYTE   EQU     BF+1      ;->s/r BUF_R, BUF_W,B_IN_OUTBCM    EQU     BF+2      ;BCM+1 EQU BF+5.Counter->s/r BUF_R,BUF_W;BCM+1   EQU     BF+3;    BCM+BAW-BAR=2000h or 0000hBARH    EQU  BF+4        ;Address for read->s/r BUF_R,BUF_WBARL    EQU  BF+5BAWH    EQU  BF+6        ;Address for write->s/r BUF_R,BUF_WBAWL    EQU  BF+7BPORT   EQU  PORTBBTRIS   EQU  TRISBBGGPORT EQU  PORTCBGGTRIS EQU  TRISCB GG    EQU  5           ;GG=BGGPORT,B_GG=PORTC,5      RC5 BWEPORT EQU     PORTCBWETRIS EQU     TRISC   ;_B_WE    EQU     0       ;WE=BWEPORT,B_WE=PORTC,0          RC0BOEPORT EQU     PORTABOETRIS EQU     TRISA   ;_B_OE    EQU     5       ;OE=BOEPORT,B_OE=PORTA,5          RA5;---------------------------------------------------------;Macro:B_IN-input Byte from FIFO 8K->to BYTE.;         (FIFO address<12:0>=BARH<4:0> & BARL<7:0>);---------------------------------------------------------B_IN             MACRO
     BCF     BGGPORT,B_GG     ;GG:=0
     MOVF    BARL,W
     MOVWF   BPORT             ;Address<7:0>=B_ADL<7:0>
     BSF     BGGPORT,B_GG     ;GG:=1     RC5 _|--
     MOVF    BARH, W
     MOVWF   BPORT             ;Address<12:8>=B_AdH<4:0>
     BCF     BGGPORT,B_GG     ;GG:=0     RC4 --|_
     MOVLW   0FF
   SELECT_SANK_1
     MOVWF   BTRIS             ;FF->input data BYTE in PORTB
   SELECT_BANK_0               ;_     OE,WE
     BCF     BOEPORT,B_OE     ;OE:=0   01-read(input)    RA5
     MOVF    BPORT,W
     BSF     BOEPORT,B_OE     ;OE:=1   11-No w/r         RA5
     MOVWF   BYTE              ;read(input)in BYTE
   SELECT_BANK_1
     CLRF    BTRIS             ;00->output data BYTE in PORTB
   SELECT_BANK_0
     ENDM;---------------------------------------------------------;Macro:B_OUT-output Byte to FIFO 8K<-from BYTE.;         (FIFO address<12:0>=BAWH<4:0> & BAWL<7:0>);---------------------------------------------------------B_OUT            MACRO
    BCF      BGGPORT,B_GG      ;GG:=0
    MOVF     BAWL,W
    MOVWF    BPORT             ;Address<7:0>=B_ADL<7:0>
    BSF      BGGPORT,B_GG     ;GG:=1     RC5_|--
    MOVF     BAWH,W
    MOVWF    BPORT             ;Address<12:9>=B_ADH<4:0>
    BCF      BGGPORT,B_GG     ;GG:=0      RC5 --|_
    MOVF     BYTE,W           ;          _  _
    MOVWF    BPORT             ;_        OE,WE
    BCF      BWEPORT,B_WE     ;WE:=0    1  0-write(output)    RC0
    BSF      BWEPORT,B_WE     ;WE:=1    1  1-No w/r           RC0
     EMDM;----------------------------------------------------;*****       BUF_SET-setup BUF-FIFO             *****BUF_SET
    SELECT_BANK_1;      MOVLW    05    ;Pin RA0,RA1-Analog,RA2-D,RA3-Vref;      MOVLW    07             ;Pin RA0-RA7=D;      MOVWF    ADCON1
   NOP;         _  _;   Set  OE,WE,GG->Out;        1   1   0
   BCF    BOETRIS,B_OE  ;A.5=p07    RA5
   BCF    BWETRIS,B_WE  ;A.4=p06    RC0
   BCF    BGGTRIS,B_GG  ;C.5=p16    RC5
   NOP
   SELECT_BANK_0
   BSF    BOEPORT,B_OE  ;/OE:=1    RA5
   BSF    BWEPORT,B_WE  ;/WE:=1    RC0
   BCF    BGGPORT,B_GG  ;GG:=0     RC5
   NOP
   CLRF   BCM+1          ;BCL=:00h
   MOVLW  BCH_max
   MOVWF  BCM       ;BCM:=2000h=long BUF; (BAR)=(BAW):=0000
      CLRF     BARH
      CLRF     BARL
      CLRF    BAWH
      CLRF    BAWL
      CLRF    BF
      CLRF    BPORT
      SELECT_BANK_1
      NOP
      CLRF    BTRIS              ;output addr7-0;Prepare RTS Pin for Output
      SELECT_BANK_0
      NOP
      BCF     RTS_PORT,RTS_BIT  ;RC3=RTS:=0 to Recive from PC!!!
      SELECT_BANK_1
      NOP
      bcf     RTS_TRIS,RTS_BIT  ;RC3->Output
      SELECT_BANK_0
      NOP
      RETURN;;--------------------------------------------------;*****   BUF_W-write BYTE from W in BUFfer;*****   BUF_R-read BYTE in W from BUFfer;exit:C=0-OK,C=1-not w/r(BUF ampty or full);    BAW=(BAWH,BAWL)-address for write;    BAR=(BARH,BARL)-address for read;;    BCM=(BCM=BCH,BCM+1=BCL)-buffer counter;    (W)=(BYTE)for save byte source;    BF-buffers flags;      BF,1=FW,BF,0=FR;;    BCM(hex)   BCM    BF,W R;;       0       _0_  <=0 1-BUFfer  full;       1     |   1  | <=1 1-no write;       2     |   2  |;          .  .   .   .  .;       10h   |_16_| <=1 1-no write;       11h   | 16+1 | <=1 0-write and read;       12h   |  18  | ;    13h       |  19  |   <=1 0-write and read;    14h       |  20  |;           .  .   .   .  .;           .  .   .   .  .;    1FFE      | 8190 |;    1FFF      | 8191 |   <=1 0-write and read;    2000h     | 8192 |   <=0 0-BUFfer empty;              ********;;--------------------------------------------------;   BUF_R-read BYTE in W from BUFfer;exit:C=0-OK,C=1-not read(BUF empty);--------------------------------------------------BUf_R   MOVWF   BYTE              ;save(W)
    BTFSC   BF,FW
    GOTO    B_R               ;li;0i=>BUF empty or full
    BTFSS   BF,FR
    GOTO    BRWE              ;00=>BUF empty;01=>BUF full->read,and then BF,W R=BF<1:0>:=11
    BSF     BF,FW;read byte from BUFferB_R:
    B_IN
    INCFSZ   BARL,F
    GOTO     B_R2;FF+1=>+100
    INCF     BARH,W
    ANDLW    B0x1F            ;long BUF=8192=>0-1FFF
    MOVWF    BARHB_R2:
    INCM     BCM              ;BCM counter+=1
    MOVE     BCM,W
    SKIP_IF_NZ
    GOTO     B_R0             ;BCH=0->BCM<256
  SUBLW   BCH_max          ;BCH=20h?
  SKIP_IF_Z
  GOTO    BRW_OK           ;BCH # 20h;BCH=20h->BCM=2000h->BUF empty->;->BF,W R:=00(before:10)
  BCF     BF,FWB_R0:                ;BCM<256
  MOVF    BCM+1,W
  SKIP_IF_WNEQUL    BC_rest+1       ;Skip if BCM # 16+1
  GOTO    B_R17                     ;BCM=17
  SKIP_IF_WEQUL     BC_rest+20      ;Skip if BCM=16+32=48
  GOTO    BRW_OK                    ;BCM<48;BCM=48:1.Enable FILLING BUF!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  bcf     RTS_PORT,RTS_BIT         ;RC3:=0->Enable
  GOTO    BRW_OKB_R17 BCF     BF,FR                    ;BCM=16+1->BF,W R:=10(before:11)
  GOTO    BRW_OK;;---------------------------------------------------; ****  BUF_W-write BYTE from W in BUFfer;exit:C=0-OK,C=1-not write(BUF full);---------------------------------------------------BUF_W MOVWF   BYTE                      ;save(W)=byte source
  BTFSC   BF,FW
  GOTO    B_W                       ;1i;0i=>BUF empty or full
  BTFSC   BF,FR
  GOTO    BRWE                      ;01=>BUF full;00=>BUF empty->write,and then BF,W R:=10
  BSF     BF,FW;write BYTE in BUFferB_W
  B_OUT
   INCFSZ   BAWL,F
   GOTO     B_W2;FF+1=>+100
   INCF     BAWH,W
   ANDLW    B0x1F             ;long BUF=8192=>0-1FFF
   MOVWF    BAWHB_W2:                          ;(((=>BRW_OK??NO)))
   DECM     BCM                ;BCM counter-=1
   SKIP_IFM_Z    BCM           ;Skip if BCM=00 00
   GOTO    B_W4                ;BCM>0;BCM=0->BUF full->BF,W R:=01(before:11)
   BCF     BF,FW
   GOTO    BRW_OKB_W4:
   MOVF    BCM,F
   SKIP_IF_Z
   GOTO    BRW_OK;BCH=0->BCM<256
   MOVF    BCM+1,W
   SUBLW   BC_rest
   SKIP_IF_Z
   GOTO    BRW_OK;BCM=16->BF,W R:=11(before:10)
   BSF     BF,FR;  1. STOP   FILING  BUF!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
   bsf     RTS_PORT,RTS_BIT   ;RC3BRW_OK BCF     STATUS,_C
   GOTO    BRW_ENDBRWE   BSF     STATUS,_C         ;C:=1 Not r/wBRW_END
  MOVF     BYTE,W
  RETURN 玩具控制装置源代码 系列单端口摩托罗拉玩具控制装置源代码 ***************************************************************************************************FILE:cru.asm DATE:25/07/97*Sinclude″motorola.h″;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Story Teller Demo.;Januar 1988;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;***************************************************************************************************BEEP_PIN_PORT             EQU    PORTABEEP_PIN_DDR             EQU      DDRABEEP_PIN_BIT             EQU      0TX_DATA_PORT             EQU      PORTDTX_DATA_DDR              EQU      DDRDTX_DATA_BIT              EQU      5MUTE_PORT                EQU      PORTAMUTE_DDR                 EQU      DDRAMUTE_BIT                 EQU      1MOTOR_1_PORT             EQU      PORTBMOTOR_1_DDR              EQU      DDRBMOTOR_1_BIT              EQU      5LED_PORT                 EQU      PORTBLED_DDR                  EQU      DDRBLED_BIT                  EQU      6MOTOR_2_PORT             EQU      PORTBMOTOR_2_DDR              EQU      DDRBMOTOR_2_BIT              EQU      7RF_EN_PORT               EQU      PORTARF_EN_DDR                EQU      DDRARF_EN_BIT                EQU      3SENSE_3_PORT             EQU      PORTASENSE_3_DDR              EQU      DDRASENSE_3_BIT              EQU      5SENSE_2_PORT             EQU      PORTASENSE_2_DDR              EQU      DDRA SENSE_2_BIT                 EQU       6SENSE_1_PORT                EQU       PORTASENSE_1_DDR                 EQU       DDRASENSE_1_BIT                 EQU       7CLK_PORT                    EQU       PORTCCLK_DDR                     EQU       DDRCCLK_BIT                     EQU       0POWER_LOCK_PORT             EQU       PORTA   ;″1″=ONPOWER_LOCK_DDR              EQU       DDRAPOWER_LOCK_BIT              EQU       2TX_B2_PORT                  EQU       PORTATX_B2_DDR                   EQU       DDRATX_B2_BIT                   EQU       4LOW_BATT_PORT               EQU       PORTC   ;ANAILOG INPUT-AN3LOW_BATT_DDR                EQU       DDRCLOW_BATT_BIT                EQU       4CAR_DETECT_PORT             EQU       PORTCCAR_DETECT_DDR              EQU       DDRCCAR_DETECT_BIT              EQU       3LDT_PORT                    EQU       PORTCLDT_DDR                     EQU       DDRCLDT_BIT                     EQU       5RSSI PORT                   EQT       PORTC   ;ANALOG INPUT-AN0RSSI_DDR                    EQU       DDRCRSSI_BIT                    EQU       6********************************************************************RX_DATA_PORT                EQU       PORTD   ;PORTDRX_DATA_DDR                 EQU       DDRD    ;DDRDRX_DATA_BIT                 EQU       7DATA_PORT                   EQU       PORTCDATA_DDR                    EQU       DDRCDATA_BIT                    EQU       1       ;SAME PIN AS TXRX_PLL_DATA *********************************************************************;COPREGISTERSCOP_BIT                  EQU     S1D       ;COP BITCOP_REGISTER             EQU     S1FF0     ;COP REGISTERIRQ_OPT_REG              EQU     S1FDFIRQ_OPT_VAL              EQU     S00       ;EDGE TRIGGERED INTERRUPT;;*******************************************************************;TIMERCONSTANTS & REGISTERS;;WITH CRYSTAL OF 4MHZ,THE TIMER INCREMENTS EVERY 2US.TCR_REG                  EQU     S12       ;TIMER CONTROL REGOLVL_BIT                 EQU     S00       ;OUTPUT LEVEL BIT POSITION IN TCR.IEDG_BIT                 EQU     S01       ;1=POSITIVE EDGE TRIGGERS INPUTCAPTUREICIE_BIT                 EQU     S07       ;1=INPUT CAPTURE IRQ ENABLE(TCAP/PD7)TOIE_BIT                 EQU     S05       ;1=TIMER OVERFLOW IRQ ENABLEOCIE_BIT                 EQU     S06       ;1=OUTPUT COMPARE IRQ ENABLE(TCMP)TSR_REG                  EQU     S13       ;TIMER STATUS REGISTERICRE_REG                 EQU     S14       ;INPUT CAPTURE REG HIGHICRL_REG                 EQU     S15       ;INPUT CAPTURE REG LOWTIMER_HIGH               EQU     S18       ;TIMER HIGH REGISTERTIMER_LOW                EQU     S19OCR_HIGH                 EQU     S16       ;OUTPUT COMPARE REGISTER NSBIN MEMORYOCR_LOW                  EQU     S17;***************************************************************************************************************************************** STARTOF RAM********************************************************************ORG    S80WAIT_REG1       RMB     1        ;RESERVE 1 BYTE FOR WAIT REGISTERWAIT_REG2       RMB     1 REG1             RMB    1REG2             RMB    1REG3             RMB    1REG4             RMB    1TXRX_BYTE        RMB    1TXRX_TRAN_BUFF   RMB    5       ;TRANSMIT BUFFERTXRX_REC_BUFF    RMB    5       ;RECEIVE BUFFER;DECLARE_FLAGSFLAGS_BYTE       RMB    1OK_FLAG          EQU    0REC_BIT          EQU    1MIDI_OK_FLAG     EQU    2       ;USED IN MIDI PROCSYNC_DET_FLAG    EQU    3IF_FLAG          EQU    4FIND_SYNC_FLAG   EQU    5FIND_BIT_FLAG    EQU    6CAPTURE_FLAG     EQU    7FLAGS1_BYTE      RMB    1MIC_OPEN_FLAG         EQU    3       ;Microphone was open by ListenStartBIT_DTCTED_FLAG       EQU    4BIT_DETECTED_BIT      EQU    5BIT_DET_FAIL_FL       EQU    6REC_HEADER_FLAG       EQU    7BYTE_DTCTED_FLAG      EQU    7       ;SAME AS HEADER FLAGSYNC_COUNTER     RMB     1TIMER_MSB_BYTE   RMB     1TIMER_LSB_BYTE   RMB     1TIMER_DIFF_MSB   RMB     1TIMER_DIFF_LSB   RMB     1kbd_counter_msb  rmb     1kbd_counter_lsb  rmb     1kbd_counter_11   equ     !01kbd_counter_12   equ     !100;One time counterspwm_reg1          rmb    1pwm_reg2          rmb    1pwm_reg1          rmb    1 ;Zero Time Counterspwm_reg1_z       rmb      1pwm_reg2_z       rmb      1pwm_reg1_z       rmb      1;One/Zero Time Duration in 100 msone_time1        rmb      1one_time2        rmb      1zero_time1       rmb      1zero time2       rmb      1;Motors/LED Enable Flags Registerml_enable        rmb      1;******XOL*******Tmp1    db     0Tmp2    db     0Tmp3    db     0header bit cntr db 0;Time WordCounterCounter_Low     db 0Counter_Hi      db 0;****** Compander’s PLL Write Only Data Shadow MemoryPllShadow:Pll1Hi  db      0Pll1Lo  db      0Pll2Hi  db      0Pll2Lo  db      0Pll3Hi  db      0Pll3Lo  db      0Pll4Hi  db      %00011000;(18h)ALC-Enable,Limiter-Enable,Clk-Disable
            ;| ||\/+----->Volume Control(MSB)
            ;| || \------->Clk Out Select
            ;| |+-------->1-Clk Disable
            ;| +--------->1-Limiter Disable
            ;+----------->1-ALC DisablePll4Lo  db      %00000000;(00h)Mode-Activ,Tx-UnMuted,Rx-Muted,SP-On
            ;\ /||||+----->1-Speaker Mute
            ;| |||+------>1-Rx Mute
            ;| ||+------->1-Tx Mute
            ;| |+--------> Rx Mode  \ 00-Active
            ;|+--------->StendBy Mode  / 11-Inactive
            ;+---------->Volume Control(bit2-LSB) Pll5Hi  db        0Pll5Lo  db        0Pll6Hi  db        %00000000
              ;\_/
              ;   +------>Voltage Reference AdjustPll6Lo  db        %11000000
              ;||\__/
              ;||   +-------> Filter Clock Counter
              ;|+----------->1-Tx Scrambler Bypass
              ;+------------>1-Rx Scrambler BypassPll7Hi  db        0Pll7Lo  db        0;****** Default PLL Settings (description see upword)REG1HI            EQU      00hREG1LO            EQU      00hREG2HI            EQU      00hREG2LO            EQU      00hREG3HI            EQU      00hREG3LO            EQU      00hREG4HI            EQU      08hREG4LO            EQU      0A7hREG5HI            EQU      3EhREG5LO            EQU      0C0hREG6HI            EQU      00hREG6LO            EQU      0CAhREG7HI            EQU      00hREG7LO            EQU      00h***********************************************************;COSTANTS:MIDI_START_BYTE       EQU       S90UNIT_CODE_NUMBER      EQU       S21;UNIT_CODE_NUMBER     EQU      S22 ;UNIT_CODE_NUMBER      EQU      S23;UNIT_CCDE_NUMBER      EQU      S24    ;Book;UNIT_CODE_NUMBER      EQU      S25    ;Frog;UNIT_CODE_NUMBER      EQU      S26;UNIT_CODE_NUMBER      EQU      S27BASE_CODE_NUMBER        EQU      S98BROADCAST               EQU      S055h*******************************************************************;unitcommand declarations:unit_OLDtalk_cmd        equ      S10unit_talk_cmd           equ      S80unit_mic_t_cmd          equ      S90unit_mic_st_cmd         equ      S21unit_mic_stop_c         equ      S22unit_general_cmd        equ      S70unit_status_cmd         equ      S80unit_reset_cmd          equ      S0a0unit_turn_off_c         equ      S0a3unit_turn_on_cmd        equ      S0a5;****** XOLunit_compand_cmd        equ      S60set_script              equ      S30;******END XOL;****** ToyTalk FlagsLISTEN_AFTER     equ    S08hMOTOR1_ENABLE    equ    S01hM1_ENABLE_BIT    equ    S00hMOTOR2_ENABLE    equ    S02hM2_ENABLE_BIT    equ    S01hLED_ENABLE       equ    S04hLED_ENABLE_BIT   equ    S02h**********************************************************************STARTOF PROGRAM**********************************************************************sss
             ORG      S100START_OP:       ;;;INIT INTERRUPT TYPE:
             RSP                       ;RESET STACK POINTER
             LDA      #IRQ_OPT_VAL
             STA      IRQ_OPT_REG
             sei                       ;DISABLE IRQ;
             jsr      shutt_on         ;supply voltage to the rest of theboard
             JSR      TXRX_INIT_PINS   ;INIT TO ′0′
             JSR      TXRX_SET_FREQ
             JSR      SPKR_INIT;XOL Delay
             lda      #70
             jsr      wait_acc_ms;END XOL
             lda      #unit_reset_cmd
             ldx      #1
             sta      txrx_rec_buff,x
             ;jsr    send_ack
             ;Reset Delay
             JSR      BEEP_INIT
             JSR      BEEP_1
             lda      #!60
             jsr      wait_acm_100ms             ;delay 6sec
             JSR      BEEP_INIT
             JSR      BEEP_1
             jsr      send_ackMAIN:
             JSR      TIMER_INIT ;and enable irq from the receiver
             lda      #kbd_counter_11
             sta      kbd_counter_msb
             clr      kbd_counter_lsb ;XOL Primaty Setup For Compander′s PLL
             ;****** Enable SIOP in Master Mode
             lda      #50h
             sta      SCR
             jsr      SetupPllPort
             jsr      ReqSetup           ;Write Defaults to Regs & Shadow
             lda      #070h              ; Delay
             jsr      wait_acc_ms
             ;Stop Script
             lda      #0FFh
             jsr      SendM;END XOL
             CLI                         ;ENABLE ALL IRQS
             NOPMAIN_LOOP:
             nopMAIN_1:
             BRCLR    SYNC_DET_FLAG,FLAGS_BYTE,MAIN_2
             jsr      wait_rf_mssg_2;get the rf message
             brclr    sync_det_flag,flags_byte,main_1_1;msg fail?
             BCLR     SYNC_DET,FLAGS_BYTE
             SEI                           ;DISABLE ALL IRQS
             jsr      decode_cmdmain_1_1:
             JSR      TIMER_INIT;and enable irq from the receiver
             CLI                           ;ENABLE ALL IRQSMAIN_2:
             dec      kbd_counter_lsb
             bne      main_3
             dec      kbd_counter_msb
             bne      main_3
             lda      #kbd_counter_11
             sta      kbd_counter_msb
             SEI                           ;DISABLE ALL IRQS
             jsr      scan_sensor
             CLI                           ;ENABLE ALL IRQSmain_3:
             ;Check End of Listen Time
             brclr     MIC_OPEN_FLAG,FLAGS1_BYTE,MAIN_LOOP;Mic Closed
             brset     TOIE,TCR,MAIN_LOOP                   ;Timer StillWork
            ;Close Microphone
             jsr    ListenClose      ;Set Tx-On,Rx-Mute,Spk-Mute
             ;Stop Script
             lda    #0FFh
             jsr    SendM
             BRA    MAIN_LOOP;*******************************************************************scan_sensor:
             jsr    get_sensor
             cmp    #S0ff
             beq    scan_sensor_exit
             lda    #unit_status_cmd
             lda    #1
             sta    txrx_rec_buff,x
             jsr    send_ack
             lda    #kbd_counter_12;longer time for next scan time.
             sta    kbd_counter_msb
             ;Stop Current Script
             ;lda  #0FFh
             ;jsr  SendMscan_sensor_exit:
             rts;*******************************************************************GET_SENSOR:;check if a sensor is pressed and if so,return a value in the ACC;if no sensor,then the ACC=FF
             clra
             brset  SENSE_1_bit,SENSE_1_port,get_sensor_1
             lda    #!03
             bra    get_sensor_exitget_sensor_1:
             brset   SENSE_2_bit,SENSE_2_port,get_sensor_2
             lda     #!01
             bra     get_sensor_exitget_sensor_2:
             brset   SENSE_3_bit,SENSE_3_port,get_sensor_3
             lda     #!02
             bra     get_sensor_exitget_sensor_3:
             lda     #S0ff get_sensor_exit:
             rts**********************************************************************SEND_ACK:;send an ack to the base unit of a command that was just received.;format:<base#><unit#><command_byte><sensor status><0>
             ;Check Broadcast. if yes-no ACK
             lda      txrx_rec_buff
             cmp      #BROADCAST
             beq      send_ack_exit
             clrx;                                                ;place the base id number
             lda      #base_code_number
             sta      txrx_tran_buff,x
             incx                           ;x=1
                                            ;place the unit#
             lda      #unit_code_number
             sta      txrx_tran_buff,x;                                              ;place the command
             lda      txrx_rec_buff,x
             incx                           ;x=2
             sta      txrx_tran_buff,x
             incx                           ;x=3
                                            ;place the sensors status
             jsr      get_sensor
             sta      txrx_tran_buff,x
             incx;                                               ;place 0
             lda      #S00
             sta      txrx_tran_buff,x
             jsr      tx_rf_stringsend_ack_exit:
             rts;***************************************************************SEND_ACK_COMPAND: ;send an ack to the base unit of a compander command.;format:<base#><unit#><command_byte><compander_MSB><compander_LSB>
            clrx;                                                  ;place the base id number
            lda      #base_code_number
            sta      txrx_tran_buff, x
            incx                                ;x=1;                                                  ;place the unit#
            lda      #unit_code_number
            sta      txrx_tran_buff,x;                                                  ;place the command
            lda      txrx_rec_buff,x
            incx                                ;x=2
            sta      txrx_tran_buff,x
            and      #07h
            deca
            asla                                ;Calculate MSB Index in Shadow
            tax                                 ;X-index of MSB
            lda      PllShadow,X
            sta      txrx_tran_buff+3           ;Load MSB
            incx;
            lda      PllShadow,X
            sta      txrx_tran_buff+4           ;Load LSB
            jsr      tx_rf_string
            rts;****************************************************************;*****************************************************************;start Unitcommands;**************************************************************;*******************************************************************decode_cmd:;decode unit commands.
             bclr    ICIE_BIT,TCR_REG          ;INPUT CAPTURE IRQ DISABLED
             SEI                                ;DISABLE ALL IRQS
             ldx     #S00
             lda     txrx_rec_buff,x           ;unit number
             cmp     #unit_code_number
             beq      do_decode_cmd
             cmp      #BROADCAST           ;check broadcast
             bne      decode_cmd_exitdo_decode_cmd
             incx                          ;command byte
             lda      txrx_rec_buff,x
             and      #0F0h
             cmp      #unit_OLDtalk_cmd
             bne      decode_cmd_111
             jsr      unit_OLDtalk
             lda      txrx_rec_buff+1      ;restore A
             bra      decode_cmd_exitdecode_cmd_111:
             lda      txrx_rec_buff+1      ;restore A
             and      #0F0h
             cmp      #unit_talk_cmd
             bne      decode_cmd_1
             jsr      unit_talk
             lda      txrx_rec_buff+1      ;restore A
             bra      decode_cmd_exitdecode_cmd_1:
             lda      txrx_rec_buff+1      ;restore A
             cmp      #unit_mic_c_cmd
             bne      decode_cmd_2
             jsr      unit_mic_c_time
             bra      decode_cmd_exitdecode_cmd_2:
             cmp      #unit_mic_st_cmd
             bne      decode_cmd_3
             jsr      unit_mic_start
             bra      decode_cmd_exitdecode_cmd_3:
             cmp      #unit_mic_stop_c
             bne      decode_cmd_4
             jsr      unit_mic_stop
             bra      decode_cmd_exitdecode_cmd_4:
             cmp      #unit_reset_cmd
             bne      decode_cmd_5
             jsr       unit_reset
             bra      decode_cmd_exit decode_cmd_5:
             cmp      #unit_turn_off_c
             bne      decode_cmd_6
             jsr      unit_turn_off
             bra      decode_cmd_exitdecode_cmd_6:
             cmp      #unit_general_cmd
             bne      decode_cmd_7
             jsr      unit_general
             bra      decode_cmd_exit;****** XOLdecode_cmd_7:
             and      #0F0h                 ;select Hi nibble
             cmp      #unit_compand_cmd
             bne      decode_cmd_8
             jsr      compander_cmd
             lda      txrx_rec_buff+1       ;restore A
             bra      decode_cmd_exit;****** END XOLdecode_cmd_8:
             lda      txrx_rec_buff+1       ;restore A
             cmp      #set_script
             bne      decode_cmd_9
             jsr      set_script_cmd
             bra      decode_cmd_exitdecode_cmd_9:
             nopdecode_cmd_exit:
             CLI                            ;ENABLE ALL IRQS
             bset     ICIE_BIT,TCR_REG     ;INPUT CAPTURE IRQ ENABED;               jsr      led_off
             rts;*************************************************************unit_talk:;NewToyTalk2;command syntax:<unit id#><unit_talk_cmd><talk_time><listen_time><script>;<script>:TTTTTT LL;             |    +-----Listen Script 2 bit;             +--------Talk Script;
           jsr     send_ack                 ;ack ok
            ;Send Scrlpt Command
            lda     txrx_rec_buff+4   ;load script Byte
            lsra
            lsra    ;Talk Script-00TTTTTT
            jsr    SendM
            ;Open Talk Channel
            jsr     TalkOpen        ;Set Compander:Rx-On Spk-On
            lda     #!50
            jsr     wait_acc_ms           ;delay before unmute spk
            jsr     spkr_muce_off
            lda     txrx_rec_buff+2 ;load TalkTime
            sta     reg1            ;reg1=TalkTime
            beq     unit_talk_exunit_talk_1:   ;Talk Delay
            lda     #0FFh
            jsr     wait_acc_ms
            dec     reg1
            bne     unit_talk_1unit_talk_ex:
            ;Close Talk Channel
            jsr     TalkClose    ;Set Compander:Rx-Mute Spk-Mute
            jsr     spkr_mute
            ;Stop Script
            lda      #0FFh
            jsr      SendM
            ;Listen After
            jmp      do_listen_after;*****************************************************************;*******************************************************************unit_OLDtalk:;talk for time;command syntax:<unit id#><unit_talk_cmd><time_mab><time_lsb><listen>;talk for time_msb*time_lsb*100ms;unit_talk_cmd=0001 X X X X;                    | | | |-----------Motor 0 Enable;                    | | |-------------Motor 1 Enable;                    | |---------------Led Enable;                    |-----------------Listen After Talk
            jsr      send_ack             ;ack ok
            ;****** XOL
            jsr      TalkOpen       ;Set Compander:Rx-On Spk-On
             ;jsr    MUX_RX_TO_SP
             ;Send Script 0
             clra
             jsr      SendM
             lda      #!150
             jsr      wait_acc_ms           ;delay before unmute spk
             jsr      spkr_mute_off
             ldx      #!2
             lda      txrx_rec_buff,x      ;time_msb
             sta      reg1unit_OLDtalk_1:
             ldx      #!3
             lda      txrx_rec_buff,x      ;time_lsb
             jsr      wait_acc_100ms
             lda      reg1
             beq      unit_OLDtalk_exit
             dec      reg1
             bne      unit_OLDtalk_1unit_OLDtalk_exit:
             ;****** XOL
             jsr      TalkClose    ;Set Compander:Rx-Mute Spk-Mute
             jsr      spkr_mute
             ;Stop Script
             lda     #0FFh
             jsr     SendMunit_OLDtalk_ex2:
             rts;**************************************************************unit_mic_time:;ToyListenTime2;command syntax:<unit id#><toy_listen_time_cmd><XX><listen_time><script>;<script>:xxxxxx LL
                +-----Listen Script 2 bit
             jsr     send_ack               ;ack okdo_listen_after:
             ; check if Listen
             lda     txrx_rec_buff+3
             beq     listen_time_ex
             ;Send  Script Command
             lda     txrx_rec_buff+4  ;load script Byte
             and     #03h
             ora     #40h
                     ;Listen Script 010000LL
             jsr     SendM
             ;Open Listen Channel
             jsr     ListenOpen       ;Set Tx-Mute,Rx-On,Spk-On
             ;Set Alarm timer
             ;Timer Tick=131.072 ms
             bclr    TOIE,TCR
             clra
             sta     Counter_Hi
             lda     txrx_rec_buff+3
             sta      Counter_Low
             ;****** XOL
             jsr      ListenOpen      ;Set Tx-Mute,Rx-On,Spk-On
             ;Enable All Ints to receive commands
             cli        ;Wait Asinchroniosly for Counter Stoplisten_time_ex:
             rts;****************************************************************set_script_cmd:
             jsr      send_ack           ;ack ok.AND MUX txrx TO MCU
             ;store duty cycle times
             lda      txrx_rec_buff+2
             jsr      SendM
             rts;****************************************************************;****************************************************************unit_mic_start:;listen & transmit the microphone.
             jsr     send_ack                  ;ack ok. AND MUX txrx TO MCU
             bclr    TOIE,TCR
             lda     #0FFh
             sta     Counter_Low
             clr     Counter_Hi
             jsr     ListenOpen    ;Set Tx-Mute, Rx-On,Spk-On
             ;Enable All Ints to receive commands
                       cli
                                  rts;********************************************************************unit_mic_stop:;stop listenning for the microphone.
             jsr      ListenClose     ;Set Compander:Tx-Mute
             jsr      send_ack                 ;ack ok
             rts;*******************************************************************unit_reset:;reset the unit.
             jmp      start_op;********************************************************************unit_turn_off:;shutt off the power to the circuit. enter power save mode.
             jsr      send_ack      ;ack ok
             jsr      shutt_off     ;all pins=0 & inputs & turn offvoltage;               stop                   ;stop osc. irq or reset>exit toRESET.unit_turn_off_1:
             jmp      unit_turn_off_1;********************************************************************unit_general:;a general command. each unit can have a different data fields & action tothat;command.
             jsr      send_ack          ;ack ok
             ldx      #!2
             lda      txrx_rec_buff,x  ;motor direction
             cmp      #!1
             bne      unit_general_1
             ;jsr    motor_left
             bra      unit_general_exunit_general_1:
             cmp      #!2
             bne      unit_general_ex
             ;jsr    motor_rightunit_general_ex:
             rts ;****************************************************************;****************************************************************;start of RF proc;****************************************************************;****************************************************************;oz;------------------------------------------------------------------------_;                             rf general proc;------------------------------------------------------------------------_;****************************************************************;****************************************************************;TXRX_TEST:;                CLRX;TXRX_TEST_L:;                LDA    MIDI_TEST_STR,X;                STA    TXRX_TRAN_BUFF,X;                INCX;                CPX    #5;                BNE    TXRX_TEST_L;                JSR    TX_RF_STRING;;                RTS;****************************************************************test_compare:;compare the received 4 bytes to the test bytes in rom.
              clrxtest_compare_1:
              lda    midi_test_str,x
              cmp    txrx_rec_buff,x
              bne    test_comp_exit
              incx
              cpx    #5
              bne    test_compare_1
              LDA    #50
              JSR    BEEP_2;                jsr    blink_led2test_comp_exit:
              rts;****************************************************************TXRX_INIT_PINS:)
            BCLR     CLK_BIT,CLK_PORT
            BSET     CLK_BIT,CLK_DDR;OUTPUT
            BCLR     DATA_BIT,DATA_PORT
            BSET     DATA_BIT,DATA_DDR
            BCLR     RF_EN_BIT,RF_EN_PORT
            BSET     RF_EN_BIT,RF_EN_DDR
            BSET     TX_B2_BIT,TX_B2_PORT;TX BUFFER AMP CONTROL INPUT.ACTIVE LOW
            BSET     TX_B2_BIT,TX_B2_DDR
            BSET     TX_B2_BIT,TX_B2_PORT;TX VCO CONTROL INPUT. ACTIVELOW.
            BSET     TX_B2_BIT,TX_B2_DDR
            BCLR     TX_DATA_BIT,TX_DATA_PORT;DATA PIN=0
            BSET     TX_DATA_BIT,TX_DATA_DDR       ;OUT
            BCLR     LDT_BIT,LDT_DDR       ;Set LDT pin to Input
            RTS;*******************************************************************TRANSMITTER_ON:
            BCLR     TX_B2_BIT,TX_B2_PORT
            RTS;*******************************************************************TRANSMITTER_OFF:
            BSET     TX_B2_BIT,TX_B2_PORT
            RTS;*******************************************************************TXRX_SET_FREQ:;INIT THE TRANCEIVER FOR A TX & RX FREQUENCY.;oz
            LDA      #!100
            JSR      WAIT_ACC_MS
              ;;;Frx=926.9875 N=75895
            LDA      #S05
            STA      REG1
            LDA      #S28
            STA      REG2
            LDA      #S77
            STA      REG3
            JSR      TXRX_PRG_19_BITS
               ;;;Ftx=902.9875 N=72239
            LDA      #S03
            STA      REG1
            LDA      #S1A
            STA      REG2
            LDA      #S2F
            STA      REG3
            JSR      TXRX_PRG_19_BITS
            LDA      #S3D
            STA      REG1
            LDA      #S48
            STA      REG2
            LDA      #S00
            STA      REG3
            JSR      TXRX_PRG_14_BITS
            LDA      #S0A;0A
            STA      REG1
            LDA      #S00
            STA      REG2
            LDA      #S00
            STA      REG3
            JSR      TXRX_PRG_14_BITS
            RTS;********************************************************************TXRX_PRG_19_BITS:;PROGRAM THE PLL WITH 19 BITS;BITS ARE STORED IN REG1,REG2,REG3;REG1=3 MSB BITS;REG2=8 MIDDLE BITS;REG3=8 LSB BITS
            BCLR     CLK_BIT,CLK_PORT
            BCLR     DATA_BIT,DATA_PORT
            BCLR     RF_EN_BIT,RF_EN_PORT
            LDX      #8
            LDA      REG3;GET 8 LSB BITS
            JSR      TXRX PLL PRG
            LDX      #8
            LDA      REG2;GET 8
            JSR      TXRX_PLL_PRG
            LDX      #3
            LDA      REG1;GET 3 MSB BITS
            JSR      TXRX_PLL_PRG
            BSET     RF_EN_BIT,RF_EN_PORT;STROBE PULSE
            NOP
            NOP
            NOP
            NOP
            NOP
            NOP
            BCLR     RF_EN_BIT,RF_EN_PORT
            BCLR     CLK_BIT,CLK_PORT
            BCLR     DATA_BIT,DATA_PORT
            RTS;****************************************************************TXRX_PRG_14_BITS:;PROGRAM THE PLL WITH 14 BITS;BITS ARE STORED IN REG1,REG2,REG3;REG1=6 MSB BITS;REG2=8 LSB BITS;REG3=NC
            BCLR     CLK_BIT,CLK_PORT
            BCLR     DATA_BIT,DATA_PORT
            BCLR     RF_EN_BIT,RF_EN_PORT
            LDX      #8
            LDA      REG2;GET 8 LSB BITS
            JSR      TXRX_PLL_PRG
            LDX      #6
            LDA      REG1;GET 6 MSB BITS
            JSR      TXRX_PLL_PRG
            BSET     RF_EN_BIT,RF_EN_PORT
            NOP
            NOP
            NOP
            NOP
            NOP
            NOP
            BCLR     RF_EN_BIT,RF_EN_PORT
            BCLR     CLK_BIT,CLK_PORT
            BCLR     DATA_BIT,DATA_PORT
            RTS;****************************************************************TXRX_PLL_PRG:;PROGRAM THE PLL WITH THE BYTE STORED IN ACC AND WITH THE NUMBER;OF BITS STORED IN WAIT_REG1
            LSRA
            BCC      TXRX_PLL_PRG_1
            BSET     DATA_BIT,DATA_PORT
            BRA      TXRX_PLL_PRG_2TXRX_PLL_PRG_1:
            BCLR     DATA_BIT,DATA_PORTTXRX_PLL_PRG_2:
            NOP
            NOP
            NOP
            BSET     CLK_BIT,CLK_PORT
            NOP
            NOP
            NOP
            NOP
            BCLR     CLK_BIT,CLK_PORT
            DECK
            BNE      TXRX_PLL_PRG
            NOP
            NOP
            BCLR     DATA_BIT,DATA_PORT
            NOP
            NOP
            RTS;****************************************************************TIMER_INIT:;INIT THE INPUT CAPTURE
            ;BCLR   IEDG_BIT,TCR_REG       ;NEGATIVE EDGE
            BSET     IEDG_BIT,TCR_REG      ;Positive edge EDGE
            ;BCLR   TOIE_BIT,TCR_REG          ;TIMER  OVERFLOW   IRQDISABLED
            BCLR     OCIE_BIT,TCR_REG          ;OUTPUT COMPARE IRQ DISABLE
            BSET     ICIE_BIT,TCR_REG          ;INPUT CAPTURE IRQ ENABLED
            BCLR     SYNC_DET_FLAG,FLAGS_BYTE  ;WILL BE SET WHEN SYNCDETECTED
            CLR      SYNC_COUNTER
            BSET     FIND_SYNC_FTAG,FLAGS_BYTE ;FIND SYNC MODE
            BCLR     FIND_BIT_FLAG,FLAGS_BYTE  ;NOT IN FIND RF BIT MODE
            LDA      TSR_REG                 ;AND CLR THE ICF IRQ BIT
            LDA      ICRL_REG;              BCLR     TEST_PIN1_BIT,TEST_PIN1_PORT ;′1′=OFF;              BSET     TEST_PIN1_BIT,TEST_PIN1_DDR;OUTPUT;              BCLR     TEST_PIN2_BIT,TEST_PIN2_PORT;′1′=OFF;              BSET     TEST_PIN2_BIT,TEST_PIN2_DDR;OUTPUT;              CLI                               ;ENABLE ALL IRQS
            RTS;*******************************************************************WAIT_NO_CARR:;WAIT TILL NO CARRIER,THEN OK_FLAG=1;USES ACC
            BSET     OK_FLAG,FLAGS_BYTE
            BRSET    CAR_DETECT_BIT,CAR_DETECT_PORT,W_NO_CARR_EX
            LDA      #!100  ;100MSW_NO_CARR_LOOP:
            JSR      WAIT_1MS
            BRSET    CAR_DETECT_BIT,CAR_DETECT_PORT,W_NO_CARR_EX
            DECA
            BNE      W_NO_CARR_LOOP
            BCLR     OK_FLAG,FLAGS_BYTEW_NO_CARR_EX:
            RTS;*******************************************************************WAIT_TO_CARR:;WAIT TILL CARRIER,THEN OK_FLAG=1;USES ACC,X
            BSET     OK_FLAG,FLAGS_BYTE
            BRCLR    CAR_DETECT_BIT,CAR_DETECT_PORT,W_TO_CARR_EX
            LDA      #!200  ;204.8 MS
            LDX      #!0     ;256 * 8=2048 CYC=1.024ms W_TO_CARR_LOOP:
              BRCLR    CAR_DETECT_BIT,CAR_DETECT_PORT,W_TO_CARR_EX;5 CYC
              DECX                                             ;3 CYC
              BNE      W_TO_CARR_LOOP                       ;3 CYC
              DECA
              BNE      W_TO_CARR_LOOP
              BCLR     OK_FLAG,FLAGS_BYTEW_TO_CARR_EX:
              RTS;*******************************************************************;                         rf receiver proc;*******************************************************************WAIT_RF_mssg:;if the RF message was received fine then the SYNC_DET_FLAG=″1″;time out after aprx 600ms
              JSR      TIMER_INIT
              LDX      #!200
              LDA      #!255;256*11us=2.8MSWAIT_RF_MSSG_1:
              BRSET    SYNC_DET_FLAG,FLAGS_BYTE,WAIT_RF_MSSG_2;5CYC
              DECA                                               ;3 CYC
              BNE      WAIT_RF_MSSG_1                            ;3 CYC
              DECX
              BNE      WAIT_RF_MSSG_1                            ;3 CYC
              BRA      W_RF_MSSG_FAIL;                bra      wait_rf_mssg_1MAIT_RF_MSSG_2:
              JSR      REC_HEADER
              BRSET    REC_HEADER_FLAG,FLAGS1_BYTE,WAIT_RF_MSSG_3
              BRA      W_RF_MSSG_FAILWAIT_RF_MSSG_3:
              JSR      DETECT_STR
              BRCLR    BYTE_DTCTED_FLAG,FLAGS1_BYTE,W_RF_MSSG_FAIL
              NOP;                jsr      test_comoare;BLINK LED IF OK
              BRA      W_RF_MSSG_EXITW_RF_MSSG_FAIL:
              BCLR     SYNC_DET_FLAG,FLAGS_BYTE W_RF_MSSG_EXIT:
            RTS;****************************************************************REC_HEADER:;after detecting the sync,need to wait for 1 byte of header.;first wait for the first bit:
            BSET     FIND_BIT_FLAG,FLAGS_BYTE;THE TIMER WILL DETECT BITS
            CLR      TXRX_BYTE
            clr      header_bit_cntr
            LDX      #!10  ;10*5.3ms=53ms to search
            LDA      #!255 ;5.3ms
            STA      REG2REC_HEADER_L:
            BRSET    BIT_DTCTED_FLAG,FLAGS1_BYTE,REC_HEADER_BIT;5CYC
            BRSET    BIT_DET_FAIL_FAIL_FL,FLAGS1_BYTE,REC_HEADER_BAD
            BRSET    CAR_DETECT_BIT,CAR_DETECT_PORT,REC_HEADER_FAIL;NOCARRIER
            DEC      REG2;3CYC
            BNE      REC_HEADER_L;3CYC
            DECX
            BNE      REC_HEADER_L;;5+5+5+3+3=21
            BRA      REC_HEADER_FAILREC_HEADER_BAD:;failed so clr the txrx_byte
            CLR      TXRX_BYTE
            clr      header_bit_cntr
            BCLR     BIT_DTCTED_FLAG,FLAGS1_BYTE
            BCLR     BIT_DET_FAIL_FL,FLAGS1_BYTE
            BRA      REC_HEADER_LREC_HEADER_BIT:;bit detected ok,so rotate the txrx_byte until detects the header byte.
            BCLR     BIT_DTCTED_FLAG,FLAGS1_BYTE
            BCLR     BIT_DET_FAIL_FL,FLAGS1_BYTE
            BRSET    BIT_DETECTED_BIT,FLAGS1_BYTE,REC_HEADER_BIT1
            CLC
            BRA      REC_HEADER_BIT2REC_HEADER_BIT1:
            SECREC_HEADER_BIT2:
            ROL      TXRX_BYTE
            inc      header_bit_cntr
            lda      header_bit_cntr
            cmp      #08h          ;if number of received bits<8
            bcs      REC_HEADER_L  ;don′t check ToyNumber-get next bit
            ;Check And Close Microphone
            brclr    MIC_OPEN_FLAG,FLAGS1_BYTE,mic_closed
            jsr      ListenClosemic_closed:
            LDA      TXRX_BYTE
            CMP      #UNIT_CODE_NOMBER
            beq      ok_Continue
            cmp      #BROADCAST       ;Check Broadcast
            BNE      REC_HEADER_Lok_Continue:
            sta      TXRX_REC_BUFF    ; Store Received Byte
            BSET     REC_HEADER_FLAG,FLAGS1_BYTE
            BRA      REC_HEADER_EXITREC_HEADER_FAIL:
            BCLR     REC_HEADER_FLAG,FLAGS1_BYTEREC_HEADER_EXIT:
            NOP
            RTS;****************************************************************DETECT_STR:;detect 4 more bytes after the header.
            ;BCLR   IEDG_BIT,TCR_REG ;NEGATIVE EDGE
            BSET     IEDG_BIT,TCR_REG ;NEGATIVE EDGE
            CLRX
            ;LDA    #UNIT_CODE_NUMBER
            ;STA    TXRX_REC_BUFF,X
            INCXDETECT_STR_L:
            JSR      DETECT_BYTE
            BRCLR    BYTE_DTCTED_FLAG,FLAGS1_BYTE,DETECT_STR_FAIL
            LDA      TXRX_BYTE
            STA      TXRX_REC_BUFF,X
            ;BCLR   IEDG_BIT,TCR_REG ;NEGATIVE EDGE. prepare for nextbyte
            BSET     IEDG_BIT,TCR_REG ;NEGATIVE EDGE
            INCX
            CPX      #!5
            BNE      DETECT_STR_L
            BRA      DETECT_STR_EXITDETECT_STR_FAIL:
            NOPDETECT_STR_EXIT:
            BCLR     FIND_BIT_FLAG,FLAGS_BYTE ;THE TIMER WILL STOP DETECTBITS
            RTS;****************************************************************DETECT_BYTE:;detect 8 bits from the receiver.;save result in TXRX_BYTE
            BCLR     BYTE_DECTED_FLAG,FLAGS1_BYTE
            CLR      TXRX_BYTE
            LDA      #!8
            STA      RFG3             ;COUNTER
            LDA      #!5   ;4*5.3ms=21ms to search
            STA      REG1
            LDA      #!255 ;5.3ms
            STA      REG2DETECT_BYTE_L:
            BRSET    BIT_DTCTED_FLAG,FLAGS1_BYTE,DETECT_BYTE_BIT ;SCYC
            BRSET    BIT_DET_FAIL_FL,FLAGS1_BYTE,DETECT_BYTE_BF
            BRSET    CAR_DETECT_BIT,CAR_DETECT_PORT,DETECT_BYTE_FAIL ;NOCARRIER
            DEC       REG2;3CYC
            BNE       DETECT_BYTE_L;3CYC
            DEC       REG1
            BNE       DETECT_BYTE_L;5+5+5+3+3=21
             BRA      DETECT_BYTE_FAILDETECT_BYTE_BIT:;bit detected ok,so rotate the txrx_byte until detects 8 bits.
             BCLR     BIT_DTCTED_FLAG,FLAGS1_BYTE
             BCLR     BIT_DET_FAIL_FL,FLAGS1_BYTE
             BRSET    BIT_DETECTED_BIT,FLAGS1_BYTE,DETECT_BYTE_BIT1
             CLC
             BRA      DETECT_BYTE_BIT2DETECT_BYTE_BF:;the first time to check a byte we get fail (because of the space betweenone;byte to the other.so if the fail appears at bit #0 we continue to check.
             BCLR     BIT_DET_FAIL_FL,FLAGS1_BYTE ;INIT
             LDA      REG3
             CMP      #!8
             BEQ      DRYECT_BYTE_L
             BRA      DETECT_BYTE_FAIL ;NOT THE FIRST BIT SO FAILDETECT_BYTE_BIT1:
             SECDETECT_BYTE_BIT2:
             ROL      TXRX_BYTE
             DEC      REG3
             BNE      DETECT_BYTE_L
             BSET     BYTE_DTCTED_FLAG,FLAGS1_BYTE
             BRA      DETECT_BYTE_EXITDETECT_BYTE_FAIL:
             NOPDETECT_BYTE_EXIT:
             RTS;********************************************************************TIMER_SYNC:
             ;Check Int Source
             brclr    TOF,TSR,Capture_Int
             ;Clear  TOF
             lda      TRL
             ;Decrement Word Counter
             lda      Counter_Low
             sub      #01h
             sta      Counter_Low
             bcc      Check_Zero     ;if(!Carry) goto Check_Zero
             dec      Counter_Hi     ;else dec Counter_HiCheck_Zero:     ;Check if WordCounter==0
            ora      Counter_Hi      ;Counter_LolCount.
            bne      TOI_Exit        ;not Zero
            ;Zero in Counter. Disable next Overilow Int
            bclr    TOIE,TCRTOI_Exit:      rtiCapture_Int:;JUMP TO THIS ROUTINE WHEN DETECTS HIGH TO LOW IN INPUT CAPTURE PIN (PD7#25);each timer tick is 2us(4mhz crystal)and the counter counts up(0-ffff).
            BSET     CAPTURE_FLAG,FLAGS_BYTE       ;SET CAPTURE FLAG;NEED TO CLR THE ICF FLAG BY READING THE TSR REG AND ICRL REG.;              BCLR     TEST_PIN2_BIT,TEST_PIN2_PORT;              BCLR     TEST_PIN1_BIT,TEST_PIN1_PORT
            LDA      TSR_REG
            LDA      ICRL_REG      ;INPUT CAPTURE REG LOW.
            BRSET    CAR_DETECT_BIT,CAR_DETECT_PORT,TIMER_SYNC_FLIL ;NOCMRRIER
            CLC
            SBC      TIMER_LSB_BYTE ;LAST RESULT OF INPUT CAPTURE
            STA      TIMER_DIFF_LSB ;DIFFERENT VALUE
            LDA      ICRH_REG       ;INPUT CAP HIGH
            SBC      TIMER_MSB_BYTE
            STA      TIMER_DIFF_MSB;                                       ;NOW SAVE CAURRENT CAPTURE VALUE
            LDA      ICRH_REG
            STA      TIMER_MSB_BYTE
            LDA      ICRL_REG
            STA      TIMER_LSB_BYTE
            BRSET    FIND_BIT_FLAG,FLAGS_BYTE,TIMER_SYNC_BIT
            BRCLR    FIND_SYNC_FLAG,FLAGS_BYTE,TIMER_SYNC_EXIT
            JSR      CHECK_TIME       ;CHECK IF 400<t<600 us
            BRCLR    IF_FLAG,FLAGS_BYTE,TIMER_SYNC_FAIL
            INC      SYNC_COUNTER
            LDA      SYNC_COUNTER
            CMP      #!10
            BNE      TIMER_SYNC_EXIT  ;BCS
            BSET     SYNC_DET_FLAG,FLAGS_BYTE
            BSET     FIND_SYNC_FLAG,FLAGS_BYTE
            CLR      SYNC_COUNTER
            BRA      TIMER_SYNC_EXITTIMER_SYNC_BIT:
            JSR      BIT_TIMER
            BRA      TIMER_SYNC_EXITTIMER_SYNC_FAIL:
            CLR      SYNC_COUNTER
            CLR      SYNC_DET_FLAG
            NOPTIMER_SYNC_EXIT:
            NOP
            RTI;*******************************************************************BIT_TIMER:;EACH RF BIT IS WITHIN THE TIME OF 750us;″1″=700us CYCLE;″0″=1200US CYCLE
            BCLR     BIT_DTCTED_FLAG,FLAGS1_BYTE  ;init
            BCLR     BIT_DET_FAIL_FL,FLAGS1_BYTE  ;init
            BCLR     BIT_DETECTED_BIT,FLAGS1_BYTE ;status of the detectedbit;CACULATE THE BIT WHEN THE RX WAS IN ″0″ OR IN ″1″;SAVE RESULT IN TIMER_ZERO_H,TIMER_ZERO_L OR IN TIMER_ONE_H,TIMER_ONE_L;IF   200us<ZEROTIME<250us AND;;                                       ;the detected period is CYCLE;                                                 ;--------------------------
            JSR      IF_ZERO_TIME
            BRCLR    IF_FLAG,FLAGS_BYTE,BIT_TIMER_1
            BSET     BIT_DTCTED_FLAG,FLAGS1_BYTE   ;init
            BCLR     BIT_DETECTED_BIT,FLAGS1_BYTE  ;status of the detectedbit
            BRA      BIT_TIMER_EXITBIT_TIMER_1:
            JSR      IF_ONE_TIME
            BRCLR    IF_FLAG,FLAGS_BYTE,BIT_TIMER_FAIL
            BSET     BIT_DTCTED_FLAG,FLAGS1_BYTE   ;init
            BSET     BIT_DETECTED_BIT,FLAGS1_BYTE ;status of the detectedbit
            BRA      BIT_TIMER_EXITBIT_TIMER_FAIL:
            BSET     BIT_DET_FAIL_FL,FLAGS1_BYTE  ;initBIT_TIMER_EXIT:
            RTS;*******************************************************************CHECK_TIME:;we will check 600us(275=113h)(THE ACTUAL TIME IS 525US/2=106H);and 400us(200=0c8h)
            BSET    IF_FLAG,FLAGS_BYTE
            LDA     TIMER_DIFF_MSB
            CMP     #S02                     ;=2
            BCC     CHECK_TIME_FAIL  ;BIGGER/EQUL 02xxH
            CME     #S01                     ;=1
            BNE     CHECK_TIME_A
            LDA     TIMER_DIFF_LSB           ;MSB=1,SO CHECK ALSO LSB
            CMP     #S20 ;14
            BCC     CHECK_TIME_FAIL
            BRA     CHECK_IME_EXIT                         ;OKCHECK_TIME_A:                                   ;=0
            LDA     TIMER_DIFF_LSB  ;MSB=0 SO CHECK LSB.
            CMP     #S0E0 ;C8
            BCS     CHECK_TIME_FAIL
            BRA     CHECK_TIME_EXITCHECK_TIME_FAIL:
            BCLR    IF_FLAG,FLAGS_BYTECHECK_TIME_EXIT:
            RTS;*******************************************************************IF_ONE_TIME:;each timer tick is 2us(4mhz crystal);the″1″cycle is 700us and the″0″cycle is 1200us;700/2=350=15e(we will check 600/2=300=12c and 800/2=400=190);1200/2=600=258h(we will check 1100/2=550=226 and 1300/2=650=28a)
            BSET     IF_FLAG,FLAGS_BYTE
            LDA      TIMER_DIFF_MSB
            CMP       #S01                      ;=1
            BNE       IF_ONE_TIME_FAIL
            LDA       TIMER_DIFF_LSB            ;MSB=1,  SO CHECK ALSO LSB
            CMP       #S2C
            BCS       IF_ONE_TIME_FAIL
            CMP       #S9F
            BCC       IF_ONE_TIME_FAIL;              bset      TEST_PIN2_BIT,TEST_PIN2_PORT
            BRA       IF_ONE_TIME_EXIT          ;OKIF_ONE_TIME_FAIL:
            BCLR      IF_FLAG,FLAGS_BYTEIF_ONE_TIME_EXIT:
            RTS;*******************************************************************IF_ZERO_TIME:;each timer tick is 2us (4mhz crystal);the″1″cycle is 700us and the″0″cycle is 1200us;700/2=350=15e(we will check 600/2=300=12c and 800/2=400=190);1200/2=600=258h(we will check 1100/2=550=226 and 1300/2=650=28a)
            BSET      IF_FLAG,FLAGS_BYTE
            LDA       TIMER_DIFF_MSB
            CMP       #S02                      ;=1
            BNE       ZERO_TIME_FAIL
            LDA       TIMER_DIFF_LSB            ;MSB=1,SO CHECK ALSO LSB
            CMP       #S26
            BCS       ZERO_TIME_FAIL
            CMP       #S9A
            BCC       ZERO_TIME_FAIL;              bset      TEST_PIN1_BIT,TEST_PIN1_PORT
            BRA       ZERO_TIME_EXIT            ;OKZERO_TIME_FAIL:
            BCLR      IF_FLAG,FLAGS_BYTEZERO_TIME_EXIT:
            RTS;*******************************************************************;*******************************************************************;-------------------------------------------------------------------;                        rf tx proc;----------------------------------------------------------;*********************************************************** TX_RF_STRING:;TRANSMIT A STRING OF 5 BYTES-TXRX_TRAN_BUFF;THE STRING IS STORED IN TXRX_TRAN_BUFF;USES ACC,X;              SEI                         ;DISABLE IRQ
            bclr      ICIE_BIT,TCR_REG         ;INPUT CAPTURE IRQ DISABLED
            BCLR      TX_DATA_BIT,TX_DATA_PORT ;DATA PIN=0
            ;JSR     MUX_TXRX_TO_MCU
            JSR       TRANSMITTER_ON
            jsr       CompanderOff     ;Set Compander to not Active mode
            ; Wait For PLL Lock Positive Level of LDTWait_LDT:      brclr     LDT_BIT,LDT_PORT,Wait_LDT
            LDA       #!120
            JSR       WAIT_ACC_MS
            JSR       TX_RF_SYNC
            LDX       #0TX_RF_STR_LOOP:
            LDA       TXRX_TRAN_BUFF,X
            JSR       TX_RF_BYTE
            INCX
            CPX       #!5
            BNE       TX_RF_STR_LOOP
                                        ;TX LOW TO COMPLETE LAST BIT
                                        ;---------------------------
            BCLR      TX_DATA_BIT,TX_DATA_PORT ;DATA PIN=0
            JSR       WAIT_100US
            JSR       WAIT_100US
            JSR       WAIT_100US
            BSET      TX_DATA_BIT,TX_DATA_PORT ;DATA PIN=1
            LDA       #5
            JSR       WAIT_ACC_MS
            JSR       TRANSMITTER_OFF
            jsr       CompanderOn      ;Set Colander to Active Mode;TX_RF_STRIN_EXIT:;              CLI                            ;enable ALL IRQS
            bset      ICIE_BIT,TCR_REG    ;INPUT CAPTURE IRQ ENABLED
            RTS;*******************************************************************TX_RF_BYTE:;TRANSMIT 1 BYTE. MSB FIRST;″1″=CYCLE OF 700US  ,″0″=CYCLE OF 1200US(SYNC=CYCLE OF 500US);send msb first.;SAVE THIS BYTE IN ACC BEFORE EXECUTING THIS ROUTINE.;USES ACC,REG1
            STX      REG1
            LDX      #08TX_RF_BYTE_L:
            LSLA
            BCC      TX_RF_BYTE_1
                                      ;TX″1″
                                      ;------
            BCLR     TX_DATA_BIT,TX_DATA_PORT;DATA PIN=0
            JSR      WAIT_100US
            JSR      WAIT_100US
            JSR      WAIT_100US
            BSET     TX_DATA_BIT,TX_DATA_PORT  ;DATA PIN=1
            JSR      WAIT_100US
            JSR      WAIT_100US
            JSR      WAIT_100US
            JSR      WAIT_100US
            BRA      TX_RF_BYTE_2TX_RF_BYTE_1:
                                      ;TX″0″
                                      ;------
            BCLR     TX_DATA_BIT,TX_DATA_PORT  ;DATA PIN=1
            JSR      WAIT_500US
            JSR      WAIT_100US
            BSET     TX_DATA_BIT,TX_DATA_ORT   ;DATA PIN=0
            JSR      WAIT_500US
            JSR      WAIT_100USTX_RF_BYTE_2:
            DECX
            BNE       TX_RF_BYTE_L
            LDX       REG1
            RTS;*******************************************************************TX_RF_SYNC:;TRANSMIT 30 CYCLES OF 500US AS SYNC;
            LDA       #!30TX_RF_SYNC_L:
            BCLR      TX_DATA_BIT,TX_DATA_PORT ;DATA PIN=1
            JSR       WAIT_100US
            JSR       WAIT_100US
            JSR       WAIT_100US
            BSET      TX_DATA_BIT,TX_DATA_PORT ;DATA PIN=1
            JSR       WAIT_100US
            JSR       WAIT_100US
            DECA
            BNE       TX_RF_SYNC_L
            RTS;*******************************************************************;*******************************************************************;              end of rf proc;*******************************************************************;*******************************************************************;****************************************************************************************************************************************BEEP_1:
            LDA       #!100BEEP_2:
            JSR       SPKR_MUTE_OFF
            ;JSR     MUX_MCU_TO_SPBEEP_1_L:
            BCLR      BEEP_PIN_BIT,BEEP_PIN_PORT
            JSR       WAIT_1MS
            BSET      BEEP_PIN_BIT,BEEP_PIN_PORT
            JSR       WAIT_1MS
            DECA
            BNE      BEEP_1_L
            JSR      SPKR_MUTE
            RTS*********************************************************************BEEP_INIT:
            BCLR     BEEP_PIN_BIT,BEEP_PIN_PORT
            BSET     BEEP_PIN_BIT,BEEP_PIN_DDR  ;OUTPUT
            RTS*********************************************************************OUTPUT_INIT:;disable the output driver.
            BCLR     MOTOR_1_BIT,MOTOR_1_PORT
            BCLR     MOTOR_1_BIT,MOTOR_1_DDR
            RTS*********************************************************************SHUTT_ON:      ;;set the shutt_off pin to″1″to allow power to the rest of the circuit.
            BSET     POWER_LOCK_BIT,POWER_LOCK_PORT
            BSET     POWER_LOCK_BIT,POWER_LOCK1_DDR ;OUTPUT
            RTS*********************************************************************SHUTT_OFF:     ;;set the shutt_off pin to″0″to shutt off power to the rest of the circuit.;the MCU will continue to receive power and should go to power save mode;utill receive an IRQ or RESET.
            lda      #0
            sta      porta
            sta      portb
            sta      portc
            sta      portd
            sta      ddra
            sta      ddrb
            sta      ddrc
            sta      ddrd
            Bclr     POWER_LOCK_BIT,POWER_LOCK_PORT
            BSET     POWER_LOCK_BIT,POWER_LOCK_DDR ;OUTPUT
            RTS********************************************************************;MATRIX_INIT:;there are 5 i/o pins that allow the MCU to detect the status of;2X3 sensor matrix. 2 of those i/o pins are used as outputs ;and 3 as inputs.the MCU will sacn those pins to detect which of those;sensors is in the″0″status.;place the 2 line ports in″0″;              BCLR     MATRIX_LINE_1_BIT,MATRIX_LINE_1_PORT;              BSET     MATRIX_LINE_1_BIT,MATRIX_LINE_1_DDR;              BCLR     MATRIX_LINE_2_BIT,MATRIX_LINE_2_PORT;              BSET     MATRIX_LINE_2_BIT,MATRIX_LINE_2_DDR;              RTS*********************************************************************;MUX_INIT:;set the i/o pin to OUTPUT. also set the MUX to;MCU to SPEEKER;MIC to TRANSMITTER;MIC to A/D;              BSET     MUX_CNT_BIT,MUX_CNT_PORT;              BSET     MUX_CNT_BIT,MUX_CNT_DDR;              RTS*********************************************************************SPKR_INIT:
            BSET     MUTE_BIT,MUTE_DDR       ;OUTPUT
            BSET     MUTE_BIT,MUTE_PORT      ;AND MUTE THEE SPK
            RTS**********************************************************************SPKR_MUTE:
            BSET     MUTE_BIT,MUTE_PORT
            RTS*********************************************************************SPKR_MUTE_OFF:
            BCLR     MUTE_BIT,MUTE_PORT
            RTS*********************************************************************;MUX_MCU_TO_SP:;allow the MCU to beep the speeker. the other position of the mux;will connect the RF receiver to the speaker.;              sei;              BSET     MUX_CNT_BIT,MUX_CNT_PORT;              RTS************************************************************;MUX_RX_TO_SP: ;connect the RF receiver to the speaker.;              BCLR     MUX_CNT_BIT,MUX_CNT_PORT;              RTS*********************************************************************;MUX__TXRX_TO_MCU:;connect the MCU to the transmitter to allow the unit to send control;messages.;              BCLR     MUX_CNT_BIT,MUX CNT_PORT;              RTS*********************************************************************;MUX_TXRX_TO_MIC:;connect the microphone to the transmitter.;              BSET     MUX_CNT_BIT,MUX_CNT_PORT;              bset mux_cnt_bit,mux_cnt_port;;              nop;              RTS*******************************************************************************************************************************************               RF PROC************************************************************************************************************************************************************************************************************************************************************************************WAIT_100US:    ;;WAIT 100 US INCLUDING THE JSR COMMAND;IF OSC=4MHZ THEN 1US=2CYC;NEED TO WAIT 200 CYC
                                     ;JSR=5 CYC
            STA      WAIT_REG1       ;2 CYC
            LDA      #!30           ;2 CYC>30*6=180 CYCWAIT_100US_L:  DECA                     ;3 CYC } 3 US=6 CYC
            BNE      WAIT_100US_L    ;3 CYC }
            CLRA                     ;3 CYC
            NOP                      ;2 CYC
            LDA      WAIT_REG1       ;2 CYC
            RTS                      ;6 CYC;                                       ;--------------------;                                       ;5+2+2+180+3+2+2+6=200 CYCWAIT_500US:
            JSR      WAIT_100US
            JSR      WAIT_100US
            JSR      WAIT_100US
            JSR      WAIT_100US
            JSR      WAIT_100US
            RTS*********************************************************************WAIT_1MS:      ;;WAIT 1 MSEC(2000 CYC)WITH THE JSR
                                     ;JSR=5 CYC
            STA      WAIT_REG1       ;2 CYC
            LDA      #!248          ;2 CYC>248*8=1984 CYCWAIT_1MS_L:    DECA                     ;3 CYC } 8 CYC
            NOP                      ;2 CYC }
            BNE      WAIT_1MS_L      ;3 CYC }
            NOP                      ;2 CYC
            LDA      WAIT_REG1       ;2 CYC
            RTS                      ;6 CYC;                                       ;--------------------;                                       ;5+2+1984+2+2+6=2001 CYC*********************************************************************WAIT_ACC_MS:   ;;WAIT ACC X 1MS;CLEARS THE ACC VALUE WHEN EXIT
            JSR      WAIT_1MS
            DECA
            BNE      WAIT_ACC_MS
            RTS*********************************************************************WAIT_ACC_100MS:   ;;WAIT ACC X 100MS;CLEARS THE ACC VALUE WHEN EXIT
            STA      WAIT_REG2
            LDA      WAIT_REG2
            BEQ      W_ACC_100MS_EXITWAIT_ACC_100MS_S:
            LDA      #!100WAIT_ACC_100MS_L:
            JSR      WAIT_1MS
            DECA
            BNE      WAIT_ACC_100MS_L
            BRSET    CAR_DETECT_BIT,CAR_DETECT_PORT,w_acc_100ma_exit ;NOCARRIER
            DEC      WAIT_REG2
            BNE      WAIT_ACC_100MS_SW_ACC_100MS_EXIT:
            RTS*********************************************************************WAIT_acm_100ms:   ;;WAIT ACC X 100MS;CLEARS THE ACC VALUE WHEN EXIT
            STA      WAIT_REG2
            LDA      WAIT_REG2
            BEQ      W_acm_100ms_EXITWAIT_acm_100ms_S:
            LDA      #!100WAIT_acm_100ms_L:
            JSR      WAIT_1MS
            DECA
            BNE      WAIT_acm_100mc_L
            ;jsr    change_io2          ;change i/o#2 from 0>1 1>0
            DEC      WAIT_REG2
            BNE      WAIT_acm_100ms_SW_acm_100ms_EXIT:
            RTS;XOL;------------------------------------------------------------------- ;******        PLL Proqraming Library ******;---------------------------------------------------------Sinclude ″plllib.asm″;---------------------------------------------------------;******* Default PLL Settings in ROMDEF_SET:
            db       REG1HI
            db       REG1LO
            db       REG2HI
            db       REG2LO
            db       REG3HI
            db       REG3LO
            db       REG4HI
            db       REG4LO
            db       REG5HI
            db       REG5LO
            db       REG6HI
            db       REG6LO
            db       REG7HI
            db       REG7LO;---------------------------------------------------------;Proc RegSetup:Set Compander registers to default;Input:No;Output:No;Spoild Regs:A,X,Tmp1,Tmp2;---------------------------------------------------------RegSetup:
            clrxSetupLoop:
            ;Out Address
            txa
            lsra
            inca
            jsr      OutPLLAddr
            ;Out Data
            stx      Tmp2           ;Store X
            lda      DEF_SET,X     ;Load Hi Default Value to A
            ldx      DEF_SET+1,X   ;Load Lo Default Value to X
            jsr      OutPLLData     ;Out Data
            ;Store to Shadow
            ldx      Tmp2           ;Restore X
            lda      DEF_SET,X
           sta      PllShadow,X      ;Store Hi byte
           lda      DEF_SET+1,X
           sta      PllShadow+1,X    ;Store Lo byte
           incx
           incx
           cmpx     #0E
           bne      SetupLoop
           rts;------------------------------------------------------------;Proc CompanderOff:Set Compander to Inactive Mode;Input:No;Output:No;Spoild Regs:A,X,Tmp1;------------------------------------------------------------CompanderOff:
           lda      #04               ;Data to Register 4
           jsr      OutPLLAddr
           lda      Pll4Lo
           ora      #%00011000       ;Set Inactiv Mode
           sta      Pll4Lo
           tax                        ;Low Byte to X
           lda      Pll4Hi            ;Hi Byte to X
           jsr      OutPLLData        ;Out Data
           rts;------------------------------------------------------------;Proc CompanderOn:Set Compander to Active Mode;Input:No;Output:No;Spoild Regs:A,X,Tmp1;------------------------------------------------------------CompanderOn:
           lda      #04               ;Data to Register 4
           jsr      OutPLLAddr
           lda      Pll4Lo
           and      #%11100111       ;Set Activ Mode
           sta      Pll4Lo
           tax                        ;Low Byte to X
           lda      Pll4Hi            ;Hi Byte to X
           jsr      OutPLLData        ;Out Data
           rts ;---------------------------------------------------------;Proc TalkOpen:Set Rx-On,Spk-On;Input:No;Output:No;Spoild Regs:A,X,Tmp1;---------------------------------------------------------TalkOpen:
             lda      #04h
             jsr      OutPLLAddr
             lda      Pll4Lo
             and      #%11111100       ;Set Rx-On Spk-On
             sta      Pll4Lo
             tax                        ;Load Lo to X
             lda      Pll4Hi            ;Load Hi to A
             jsr      OutPLLData
             rts;---------------------------------------------------------;Proc TalkClose:Set Rx-Mute,Spk-Mute;Input:No;Output:No;Spoild Regs:A,X,Tmp1;---------------------------------------------------------TalkClose:
            lda       #04h
            jsr       OutPLLAddr
            lda       Pll4Lo
            ora       #%00000011       ;Set Rx-Mute Spk-Mute
            sta       Pll4Lo
            tax                         ;Load Lo to X
            lda      Pll4Hi             ;Load Hi to A
            jsr      OutPLLData
            rts;---------------------------------------------------------;Proc ListenOpen:Set Tx-On;Input:No;Output:No;Spoild Regs:A,X,Tmp1;---------------------------------------------------------ListenOpen:
            lda       #04h
            jsr       OutPLLAddr
            lda       Pll4Lo
           and      #%11111011       ;Set Tx-On
           sta      Pll4Lo
           tax                        ;Load Lo to X
           lda      Pll4Hi            ;Load Hi to A
           jsr      OutPLLData
           JSR      TRANSMITTER_ON
           bset     TOIE,TCR         ;Enable TimerCounter
           bset     MIC_OPEN_FLAG,FLAGS1_BYTE
           rts;---------------------------------------------------------;Proc ListenClose:Set Tx-Mute;Input:No;Output:No;Spoild Regs:A,X,Tmp1;---------------------------------------------------------ListenClose:
           lda      #04h
           jsr      OutPLLAddr
           lda      Pll4Lo
           ora      #%00000100       ;Set Tx-Mute
           sta      Pll4Lo
           tax                        ;Load Lo to X
           lda      Pll4Hi            ;Load Hi to A
           jsr      OutPLLData
           JSR      TRANSMITTER_OFF
           bclr     TOIE,TCR         ;Enable TimerCounter
           bclr     MIC_OPEN_FLAG,FLAGS1_BYTE
           rts;---------------------------------------------------------;Proc compander_cmd:Read/Write to Compander Data Register; Command=0101 r/w addr;               |   +-----------3 bit address;               +---------------0-read 1-write;Input:No;Output:No;Spoild Regs:A,X,Tmp1,Tmp2;---------------------------------------------------------compander_cmd:
           lda      txrx_rec_buff+1           ;A=command
            bit      #08h                  ;Check Bit r/w
            bne      write_compand
            ;Read and Send
            jsr      SEND_ACK_COMPAND
            bra      compand_exitwrite_compand:
            jsr      send_ack
            lda      txrx_rec_buff+1       ;A=command
            and      #07h                  ;Select Addres from Command
            sta      Tmp2                  ;Tmp-Register Adddress
            jsr      OutPLLAddr
            ;Store new Data To Shadow Memory
            lda      Tmp2
            deca
            asla
            tax                            ;X-Index of hadow MSB
            lda      txrx_rec_buff+2       ;Load MSB to A from command
            sta      PllShadow,x          ;Store Hi Byte to shadow
            lda      txrx_rec_buff+3       ;Load LSB to A from command
            incx
            sta      PllShadow,x          ;Store Lo Byte to shadow
            ;Out Data
            tax                            ;X=LSB
            lda      txrx_rec_buff+2       ;A=MSB
            jsr      OutPLLData            ;Out Data
            lda      #70h
            jsr      wait_acc_mscompand_exit:
            rts;---------------------------------------------------------;Proc SendM:Send byte teought SPI to Moution Module;Input:A-Byte to Send;Output:No;Spoild Regs:A;---------------------------------------------------------SendM:
            sta      Tmp3
            lda      #66h
            sta      SDR      ;Send SYNC
    ;Wait:xmit DoneWaitSIOP1:
    brclr    SPIF,SSR,WaitSIOP1
    lda      SDR      ;Clear SPIF
    lda      Tmp3
    sta      SDR      ;Send Data
    ;Wait xmit DoneWaitSIOP2:
    brclr    SPLF,SSR,WaitSIOP2
    lda      SDR      ;Clear SPIF
    rts********************************************************************* INTERRUPT VECTORS********************************************************************VECRESET:       ;;THIS IS THE POWER ON RESET ROUTINE;;DISABLE ALL INTERRUPTS:;                SEI;
             JMP      START_OP;*************************************IRQ_PROC:         ;;executed after an irq\signal.;;jump here 16cyc after the event(high to low).;the mcu also saves ccr,acc,x,pch,pcl registers.
             RTI*************************************VECSWI:         ;;THIS IS THE SWI SOFTWARE INTERRUPT ROUTINE
             RTI*************************************VECSPI:         ;;THIS IS THE PERIPHEAL INTERRUPT ROUTINE
             RTI************************************* VECSCI:         ;;THIS IS THE SERIAL INTERRUPT ROUTINE
             RTI;********************************************************************;ROM VARRIABLES:MIDI_TEST_STR    DB       S12,S34,S56,S78,S9A;PR_END:         NOP********************************************************************* MASK OPTION REGISTER********************************************************************
             ;ORG     S0900   ;705P9 CHIP
             ;db      00
             ORG       S1F00   ;705P6 CHIP
             DB        00      ;irq=negative edge,no wdg,siop msb first*********************************************************************START OF VECTOR EPROM********************************************************************
              ORG      S1FF8INT_VCTR:        ;
              FDB      TIMER_SYNC
              FDB      IRQ_PROC         ;IRQ\CAUSE THE MIDI PROCESS.
              FDB      VECSWI
              FDB      START_OP
              END CREAPI.DLL 系列单端口PC软件API模块
creapi.dll //creapi.c#define_CREAPI_DLL_#include ″windows.h″#include ″asrapi.h″#include ″asr1500.h″#include ″ttssdk32.h″#include ″..\crpro\crpro.h″#include ″creapi.h″#include ″mmio.h″#include ″notifvproc.h″#include ″mess.h″#include ″intdefs.h″#include ″sr.h″#include ″tts.h″#include ″uniprt.h″#include ″resource.h″#include ″queue.h″#define SR MESSAGE STRING       ″0555F940-BD0D-11d1-B001-00C0F01D50B7″void Initialize();void Uninitialize();void CALLBACK CrApiReadNotifyProc(PNOTIFY_PARAMS pNotifyParams);void CALLBACK CrApiWriteNotifyProc(PNOTIFY_PARAMS pNotifyParams);HINSTANCE hInstance=NULL;HANDLE hWaitMessageEvent;BYTE WaitAckBuffer[MAX_MESSAGE_SIZE];CREAPI NOTIFY PROC UserReadNotifyProc=NULL;CREAPI NOTIFY PROC UserWriteNotifyProc=NULL;DWORD UserData;HQUEUE hReadNotifyQueue=NULL;HQUEUE hWriteNotifyQueue=NULL;HANDLE hReadNotifyThread;HANDLE hWriteNotifyThread;extern UINT srMessage;
//=================================
LPSTR lpszCurrText;
DWORD dwUnitTalkFlags;
HWNDLE hUnitTalkThread;
HANDLE hAsync;
HANDLE hUnitTalkDone;
DWORD dwQueueSize;
HANDLE hUnitTalkBreak;
HANDLE hQueueNotFull;
HANDLE hUnitTalkBreakDone;
extern HTTSINSTANCE hTTSInst;
//=====================================
HANDLE hRecordFile=INVALID_HANDLE_VALUE;
DWORO dwUnitRecordFlags;
HANDLE hUnitRecordThread;
BOOL bUnitRecord=FALSE;
HANDLE hRecordAsync;
DWORD dwTime;
HANDLE hUnitRecordBreak;
//================================
BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID
lpvReserved){

      switch(fdwReason){

      case_DLL_PROCESS_ATTACH:

              if(hInstante!=NULL)

                       return FALSE;

               hInstance=hinstDLL;

               Initialize( );

               break;

        case DLL_PROCESS_DETACH:

                Uninitialize( );

                break;

        }

        return TRUE;
//=================================
DWORD WINAPI ReadNotifyThread(PVOID param){

      PCRAPI_NOTIFY_PARAMS pNotifyParams;

      for(;;){

                QueueWaitWhileEmpty(hReadNotifyQueue,INFINITE);
pNotifyParams=(PCRAPI_NOTIFY_PARAMS)QueuePop(hReadNotifyQueue);
				
				<dp n="d456"/>
              switch(pNotifyParams->dwNotifyType){

              case CRPRO_READ_BUFFER_READY:

                      pNotifyParams->dwNotifyType=CRAPI_BUFFER_RECEIVED;

                      break;

              case CRPRO_CNTR_RECEIVED:

                      pNotifyParams->dwNotifyTpe=CRAPI_MESSAGE_RECEIVED;

                      break;

              }

              UserReadNotifyProc(pNotifyParams,UserData);

              GlobalFree(pNotifyParams->pBuffer);

              GlobalFree(pNotifyParams);

      }

      return 0;
 }
//=================================
DWORD WINAPI WriteNotifyThread(PVOID Param){
      PCRAPI_NOTIFY_PARAMS pNotifyParams;

      for(;;) {

                QueueWaitWhileEmpty(hWriteNotifyQueue,INFINITE);
pNotifyParams=(PCRAPI_NOTIFY_PARAMS)QueuePop(hWriteNotifyQueue);

               switch(pNotifyParams->dwNotifyTpe){

               case CRPRO_WRITE_BUFFER_BREAK:

                       pNotifyParams->dwNotifyTpe=CRAPI_BREAK;

                       break;

               case CRPRO_WRITE_BUFFER_DONE:

                       pNotifyParams->dwNotifyType=CRAPI_BUFFER_SENT;

                       break;

               }

               UserWriteNotifyProc(pNotifyParams,UserData);

               GlobalFree(pNotifyParams);

         }

         return 0;
}
//=================================
CREAPI STATUS crSystemOpen(DWORD dwDeviceID,CREAPI_NOTIFY_PROC
ReadNotifyProc,CREAPI_NOTIFY_PROC WriteNotifyProc,DWORD dwUserData){

         DWORD status;

         DWORD dwDhreadID;
				
				<dp n="d457"/>
      status=proSystemOpen(dwDeviceID,CrApiReadNotifyProc,
CrApiWriteNotifyProc);

      if(status!=STATUS_OK)

              return status;

      status=ttsOpen();

      if(status!=STATUS_OK)(

              proSystemClose();

              return status;

      }

      if(!srOpen()){

              proSystemClose();

              ttsClose();

              return CREAPI_STATUS_ERR_SROPEN;

      }

      if(ReadNotifyProc!=NULL){

              hReadNotifyQueue=QueueCreate();

              hReadNotifyThread=CreateThread(NULL,0,ReadNotifyThread,0,
0, &amp;dwThreadID);

              UserReadNotifyProc=ReadNotifyProc;

      }

      if(WriteNotifyProc!=NULL){

              hWriteNotifyQueue=QueueCreate();

              hWriteNotifyThread=CreateThread(NULL,0,WriteNotifyThread,
0,0,&amp;dwThreadID);

              UserWriteNotifyProc=WriteNotifyProc;

      }

      UserData=dwUserData;

      return STATUS_OK;
//=================================
CREAPI_STATUS crSystemClose(){

      DWORD status;

      status=proSystemClose();
				
				<dp n="d458"/>
         srClose();

         ttsClose();

         if(UsecReadNotifyProc!=NULL){

                 while(QueueWaitWhileEmpty(hReadNotifyQueue,
0)==WAIT_OBJECT_0);

                 QueueDestroy(hReadNotifyQueue);

                 TerminateThread(hReadNotifyThread,0);

                 WaitForSingleObject(hReadNotifyThread,INFINITE);

                 CloseHandle(hReadNotifyThread);

                 UserReadNotifyProc=NULL;

         }

         if(UserWriteNotifyProc!=NULL){

                 while(QueueWaitWhileEmpty(hWriteNotifyQueue,
0)==WAIT_OBJECT_0);

                 QueueDestroy(hWriteNotifyQueue);

                 TerminateThread(hWriteNotifyThread,0);

                 WaitForSingleObject(hWriteNotifyThread,INFINITE);

                 CloseHandle(hWriteNotifyThread);

                 UserWriteNotifyProc=NULL;

         }

         return status;
}
//=================================
void TestAckProc(PNOTIFY_PARAMS pNotifyParams){

         if(WaitForSingleObject(hWaitMessageEvent,0)==WAIT_TIMEOUT){

                 PBYTE pBuffer=(PBYTE)pNotifyParams->pBuffer;

                 if(WaitAckBuffer[0]==pBuffer[0]){

                         mamcpy(WaitAckBuffer,pBuffer,
pNotifyParams->dwBufferLength);

                         SetEvent(hWaitMessageEvent);

                 }

      }
}
//=================================
				
				<dp n="d459"/>
CREAPI_STATUS crSendBuffer(PVOID pBuffer,DWORD dwBufferSize,DWORD
dwUserData)(

      return proSendBuffer(pBuffer,dwBufferSize,dwUserData,0);
}
//=================================
CREAPI STATUS crSendMessage(PVOID pMessage,BYTE byMessageType,BYTE
byMessageSize,PVOID pAck,BYTE bypAckSize){

     if(byMessageType&amp;ACK_EXPECTED_MASK){

             CRPRO_STATUS status;

             DWORD time_out=BASE_ACK_TIME_OUT;
             time_out+=byMessageType &amp; SRC_DEST_MASK?UNIT_ACK_TIMEOUT:0;

             WaitAckBuffer[0]=byMessageType;

             WaitAckBuffer[0]&amp;=~((BYTE)ACK_EXPECTED_MASK);

             WaitAckBuffer[0]|=DIRECTION_MASK;

             ResetEvent(hWaitMessageEvent);

             status=proSendMessage(pMessage,byMessageSize,
byMessageType);

             if(status!=STATUS_OK){

                     SetEvent(hWaitMessageEvent);

                     return status;

             }

             if(WaitForSingleObject(hWaitMessageEvent,
time_out)==WAIT_TIMEOUT){

                     SetEvent(hWaitMessageEvent);

                     return CREAPI_STATUS_ERR_TIMEOUT;

             }

             if(pAck!=NULL)

                     memcpy(pAck,WaitAckBuffer,min(bypAckSize,
WaitAckBuffer[1]+2));

             return  STATUS_OK;

   }  else    

             return proSendMessage(pMessage,byMessageSize,byMessageType);
}
//==================================
CREAPI_STATUS crBaseDetect(PBASE_DETECT pBaseDetect){
				
				<dp n="d460"/>
          CRPRO_STATUS status;

          DWORD i;

           BYTE Ack[MAX_MESSAGE_SIZE];

           for(i=0;i<MAX_DEVICE_ID;i++)(

                     status=proSystemOpen(i,CrApiReadNotifyProc,NULL);

                     if(status==STATUS_OK) {
 
                             if(crSendMessage(NULL,CMD_BASE_GET_VERSION,0,Ack,
sizeof(Ack))==STATUS_OK){

                                     proSystemClose();

                                    pBaseDetect->dwDeviceID=i;
pBaseDetect->version.byMajorVerNum=Ack[2]>>4;
pBaseDetect->version.byMinorVerNum=Ack[2] &amp; 0x0F;

                                    return STATUS_OK;

                           }

                           proSystemClose();

                   }

           }

           return CREAPI_STATUS_ERR_BASENOTFOUND;
}
//==================================
void Initialize(){

           hWaitMessageEvent=CreateEvent(NULL,TRUE,TRUE,NULL);

           hUnitTalkDone=CreateEvent(NULL,TRUE,TRUE,NULL);

           hUnitTalkBreak=CreateEvent(NULL,TRUE,FALSE,NULL);

           hQueueNotFull=CreateEvent(NULL,TRUE,TRUE,NULL);

           hUnitTalkBreakDone=CreateEvent(NULL,TRUE,TRUE,NULL);

           hUnitRecordBreak=CreateEvent(NULL,TRUE,TRUE,NULL);

           srMessage=RegisterWindowMessage(SR_MESSAGE_STRING);
}
//==================================
void Uninitialize(){

          CloseHandle(hUnitTalkDone);

          CloseHandle(hWaitMessageEvent);

          CloseHandle(hQueueNotFull);

          CloseHandle(hUnitTalkBreak);

          CloseHandle(hUnitTalkBreakDone);
				
				<dp n="d461"/>
           CloseHandle(hUnitRecordBreak);

  }

  //==================================

  CREAPI_STATUS crReset(DWORD dwFlags){

          DWORD status;

          status=proTransferReset(dwFlags);

          if(UserReadNotifyProc)

                  while(QueueWaitWhileEmpty(hReadNotifyQueue,

  0)==WAIT OBJECT 0);

          if(UserWriteNotifyProc)

                  while(QueueWaitWhileEmpty(hWriteNotifyQueue,

  0)==WAIT OBJECT 0);

          return status;

  }

  //==================================

  CREAPI_STATUS crGetBaseVersion(PVERSION base_version){

          DWORD status;

          BYTE Ack(MAX MESSAGE_SIZE);

          status=crSendMessage(NULL,CMD_BASE_GET_VERSION,0,Ack,

  sizeof(Ack));

          if(status==STATUS_OK){

                  base_version->byMajorVerNum=Ack[2]>>4;

                  base_version->byMinorVerNum=Ack[2]&amp;0x0F;

          }

          return status;

  }

  //==================================

  void UnitTalkBufferDone(PNOTIFY_PARAMS pNotifyParams){

          GlobalFree(pNotifyParams->pBuffer);

          if(pNotifyParams->dwUserData==1)

                  SetEvent(hUnitTalkDone);

          else{

                 dwQueueSize--;

                 if(dwQueueSize<UNIT_TALK_QUEUE_SIZE)

                         SetEvent(hQueueNotFull);

          }

  }
				
				<dp n="d462"/>
//============================
DWORD WINAPI UnitTalkThread(PVOID Param){

      DWORD ret_value=STATUS_OK;

      PVOID pBuffer;

      PVOID pFinishMarker;

      DWORD wait_result;

      HANDLE hWaitEvents[2];

      DWORD PCMDataSize,must_be_read,was_read;

      int done_status;

      DWORD gen_size,task no;

      BOOL bTTSFirstBuffer;

      hWaitEvents[0]=hUnitTalkBreak;

      hWaitEvents[1]=hQueueNotFull;

      pFinishMarker=GlobalAlloc(GPTR,1);

      *((PBYTE)(pFinishMarker))=0x80;

      dwQueueSize=0;

      ResetEvent(hUnitTalkDone);

      SetEvent(hQueueNotFull);

      if(dwUnitTalkFlags==UNITTALK_SRC_PCMFILE)

               PCMDataSize=PCMGetDataSize();

      else

               bTTSFirstBuffer=TRUE;

      for(;;){

               wait_result=WaitForMultipleObjects (2,hWaitEvents,FAISE,
INFINITE);

               if(wait_result==WAIT_OBJECT_0){

                       proSendBuffer(pFinishMarker,1,1,
UNIT_TALK_BUFFER);

                       SetEvent(hUnitTalkBreakDone);

                       break;

               }

               pBuffer=GlobalAlloc(GPTR,UNIT_TALK_BUFFER_SIZE);

               if(pBuffer==NULL){

                       ret_value=CREAPI_STATUS_ERR_MALLOC;
				
				<dp n="d463"/>
                     ProSendBuffer(pFinishMarker,1,1,
UNIT_TALK_BUFFER);

                     break;

              }

              if(dwUnitTalkFlags==UNITTALK_SRC_PCMFILE)(

                     must_be_read=min(PCMDataSize,
UNIT_TALK_BUFFER_SIZE);

                     if(!PCMReadFile(pBuffer,must_be_read,&amp; was_read)){

                             GlobalFree(pBuffer);

                             ret_value=CREAPI_STATUS_ERR_PCMREAD;

                             proSendBuffer(pFinishMarker,1,1,
UNIT_TALK_BUFFER);

                             break;

                     }

                     proSendBuffer(pBuffer,was_read,0,
UNIT_TAKK_BUFFER);

                     PCMDataSize-=was_read;

                     dwQueueSize++;

                     if(dwQueueSize>=DNIT_TALK_QUEUE_SIZE)

                             ResetEvent(hQueueNotFull);

                     if(PCMataSize==0){                         //
Normal Done

                             ret_value=STATUS_OK;

                             proSendBuffer(pFinishMarker,1,1,
UNIT_TALK_BUFFER);

                             break;

                     }else if(dwUnitTalkFlags==UNITTALK_SRC_TTS){

                             if(bTTSFirstBuffer)(

                                      done_status=TtsGenPcmBuf(hTTSInst,
lpszCurrText,strlen(lpszCurrText),
                                             M_OUT_BLINEAR,M_ANSI_TEXT,
UNIT_TALK_BUFFER_SIZE,pBuffer,&amp; gen_size,&amp; task_no);
				
				<dp n="d464"/>
                              bTTSFirstBuffer=FALSE;

                       }else

                              done_status=TtsGenNextPcmBuf(hTTSInst,
UNIT_TALK_BUFFER_SIZE,pBuffer,

                              M_OUT_BLINEAR,&amp; gen_size,&amp; task_no);

                       if(done_status==M_PCMGENDONE ||
done_status==E_NOINPUTTEXT){

                              GlobalFree(pBuffer);            // Normal
Done

                              ret_value=STATUS_OK;

                              proSendBuffer(pFinishMarker,1,1,
UNIT_TALK_BUFFER);

                              break; 

                       }

                       dwQueueSize++;

                       if(dwQueueSize>=UNIT_TALK_QUEUE_SIZE)

                              ResetEvent(hQueueNotFull);

                       proSendBuffer(pBuffer,gen_size,0,
UNIT_TALK_BUFFER);

              }

       }

       if(dwUnitTalkFlags==UNITTALK_SRC_PCMFILE)

              PCMCloseFile();

       else if(dwUnitTalkFlags==UNITTALK_SRC_TTS){

              TtsStopSpeech(hTTSInst,0);

              GlobalFree(lpszCurrText);

       }

       WaitForSingleObject(hUnitTalkDone,INFINITE);

       if(hAsync!=NULL){

              SetEvent(hAsync);

              CloseHandle(hUnitTalkThread);

              hUnitTalkThread=NULL;

       }
return ret_value;
}
				
				<dp n="d465"/>
//======================================
CREAPI_STATUS crUnitTalk(WORD wUnitNumber,DWORD dwFlags,LPCTSTR pszSource,
HANDLE hOpAsync){

      DWORD dwThreadID;

      DWORD status;

      if(hUnitTalkThread!=NULL &amp;&amp; pszSource==NULL){

              ResetEvent(hUnitTalkBreakDone);

              SetEvent(hUnitTalkBreak);

              WaitForSingleObject(hUnitTalkBreakDone,INFINITE);

              proTransferReset(BASEIO_WRITE_QUEUE);

              WaitForSingleObject(hUnitTalkThread,INFINITE);

              CloseHandle(hUnitTalkThread);

              hUnitTalkThread=NULL;

              return STATUS_OK;

  }

  if(dwFlags>0 &amp;&amp; dwFlags<=UNITTALK_SRC_MAX_VALUE)

          dwUnitTalkFlags=dwFlags;

  else

          return CREAPI_STATUS_ERR_FLAG_NOTSUPP;

  if(dwFlags==UNITTALK_SRC_PCMFILE){

          if(!PCMInitFile(pszSource))

                   return CREAPI_STATUS_ERR_PCMINIT;

  }else if(dwFlags==UNITTALK_SRC_TTS){

          lpszCurrText=(LPSTR)GlobalAlloc(GPTR,strlen(pszSource)+1);

          if(!lpszCurrText)

                   return CREAPI_STATUS_ERR_MALLOC;

          strcpy(lpszCurrText,pszSource);

  }

  status=crSendMessage(NULL,CMD_BASE_START_DA,0,NULL,0);

  if(status!=STATUS_OK){

          if(dwFlags==UNITTALK_SRC_PCMFILE)

                  PCMCloseFile();

          else if(dwFlags==UNITTALK_SRC_TTS)

          GlobalFree(lpszCurrText);

          return status;

  }
				
				<dp n="d466"/>
       hAsync=hOpAsync;

       ResetEvent(hUnitTalkBreak);
       if(hOpAsync!=NULL)

               ResetEvent(hOpAsync);

       hUnitTalkThread=CreateThread(NULL,0,UnitTalkThread,hOpAsync,0,
&amp; dwThreadID);

       if(hAsync==NLLL){

               WaitForSingleObject(hUnitTalkThread,INFINITE);

               CloseHandle(hUnitTalkThread);

               hUnitTalkThread=NULL;

       }

       return STATUS_OK;
}
//=================================
void UnitRecordBufferReady(PNOTIFY_PARAMS pNotifyParams){

       DWORD written;

       WriteFile(hRecordFile,pNotifyParams->pBuffer,
pNotifyParams->dwBufferLength,&amp; written,NULL);
}
//=================================
DWORD WINAPI UnitRecordThread(PVOID param){

        DWORD wait_result;

        DWORD data_size;

        DWORD written;

        bUnitRecord=TRUE;

        crSendMessage(NULL,CMD_BASE_START_AD,0,NULL,0);

        wait_result=WaitForSingleObject(hUnitRecordBreak,dwTime);

        crSendMessage(NULL,CMD_BASE_BREAK,0,NULL,0);

        crReset(BASEIO_READ_QUEUE);

        bUnitRecord=FALSE;

        if(dwUnitRecordFlags==UNITRECORD_DEST_PCMFILE){

                data_size=SetFilePointer(hRecordFile,0,NULL,
FILE_CURRENT)-WAVE_HEADER_LENGTH;
				
				<dp n="d467"/>
             SetFilePointer(hRecordFile,WAVE_DATA_LEN_POS,NULL,
FILE_BEGIN);

             WriteFile(hRecordFile,&amp; data_size,sizeof(data_size),
&amp; written,NULL);

       }

       CloseHandle(hRecordFile);

       hRecordFile=INVALID_HANDLE_VALUE;

       if(hRecordAsync!=NULL){

               SetEvent(hRecordAsync);

               CloseHandle(hUnitRecordThread);

       }

       return 0;
}
//=================================
CREAPI_STATUS crUnitRecord(WORD wUnitNumber,DWORD dwTime_ms,DWORD dwFlags,
LPCTSTR lpszDest,HANDLE hOpAsync){

      HRSRC hResInfo;

      HGLOBAL hResGlobal;

      DWORD written;

      DWORD dwThreadID;

      if(dwFlags>0 &amp;&amp; dwFlags<=UNITRECORD_MAX_VALUE)

              dwUnitRecordFlags=dwFlags;

      else

              return CREAPI_STATUS_ERR_FLAG_NOTSUPP;

      if(hRecordFile!=INVALID_HANDLE_VALUE &amp;&amp; lpszDest==NULL){

              SetEvent(hUnitRecordBreak);

              WaitForSingleObject(hUnitRecordThread,INFINITE);

              return STATUS_OK;

      }

      hRecordFile=CreateFile(lpszDest,GENERIC_WRITE,0,NULL,
CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);

      if(hRecordFile==INVALID_HANDLE_VALUE)

               return CREAPI_STATUS_ERR_FILE_CREATE;

      if(dwFlags==UNITRECORD_DEST_PCMFILE){
				
				<dp n="d468"/>
               hResInfo=FindResource(hInstance,″IDR_8BIT8KHZ_HEADER″,
″WAVEHFADER″);

               hResGlobal=LoadResource(hInstance,hResInfo);

               WriteFile(hRecordFile,hResGlobal,WAVE_HEADER_LENGTH,
&amp; written,NULL);

               if(written!=WAVE_HEADER_LENGTH){

                       CloseHandle(hRecotdFile);

                       hRecordFile=INVALID_HANDLE_VALUE;

                       return CREAPI_STATUS_ERR_FILE_WRITE;

               }

      }

      hRecordAsync=hOpAsync;

      dwTime=dwTime_ms;

      ResetEvent(hUnitRecordBreak);

      if(hOpAsync!=NULL)

               ResetEvent(hOpAsync);

      hUnitRecordThread=CreateThread(NULL,0,UnitRecordThread,hOpAsync,
0,&amp; dwThreadID);

      if(hOpAsync==NULL){

               WaitForSingleObject(hUnitRecordThread,INFINITE);

               CloseHandle(hUnitRecordThread);

      }

      return STATUS_OK;
}
//=================================
				
				<dp n="d469"/>
#ifndef_INTDEFS_H_
#define_INTDEFS_H_
#define CRAPI_INTERNAL_USE                       2
#define EVENT_SENSOR                             1
#define EVENT_SR                                 2
#de fine WE_SR_RESULT                            1
#define WE_SENSOR_RESULT                         2
#define STRING_MAX_LENGTH                        80
#define MAX_MESSAGE_SIZE                         255
typedef struct__SR_BUFFER{
      pvoID pBuffer;
      DWORD dwBufferSize;
} SR_BUFFER,*PSR_BUFFER;
#define CMD WAITFOREVENT                         1
#define CMD_UNITRECORD                           2
#define WAVE_HEADER_LENGTH                       44
#define WAVE_DATA_LEN_POS                        40
#define MAX_DEVICE_ID                            10
#define UNIT_TALK_BUFFER_SIZE                    2048
#define UNIT_TALK_QUEU11E_SIZE                   10
#define UNIT_TALK_BUFFER                         0x00000100
#endif//_INTDEFS_H_
				
				<dp n="d470"/>
#include<windows.h>
#include<mmsystem.h>
#include″mmio.h″
DWORD pcm_data_size;
HMMIO hmmio;
BOOL PCMInitFile(LPCTSTR pszFileName){

      MMCKINFO mmckinfoParent;

      MMCKINFO mmckinfoSubchunk;

      DWORD dwFmtSize;

      HGLOBAL hFormat;

      WAVEFORMATEX  *pFormat;

      hmmio=mmioOpen((LPSTR)pszFileName,NULL,MMIO_READ|MMIO_ALLOCBUF);

      if(!hmmio)

               return FALSE;

      mmckinfoParent.fccType=mmioFOURCC(′W′,′A′,′V′,′E′);

      if(mmioDescend(hmmio,&amp; mmckinfoParent,NULL,MMIO_FINDRIFF)){

               mmioClose(hmmio,0);

               return FALSE;

      }

      mmckinfoSubchunk.ckid=mmioFOURCC(′f′,′m′,′t′,′′);

      if(mmioDescend(hmmio,&amp; mmckinfoSubchunk,&amp; mmckinfoParent,
MMIO_FINDCHUNK)){

               mmioClose(hmmio,0);

               return FALSE;

      }

      dwFmtSize=mmckinfoSubchunk.cksize;

      hFormat=GlobalAlloc(LMEM_MOVEABLE,LOWORD(dwFmtSize));

      if(!hFormat){

               mmioClose(hmmio,0);

               return FALSE;

      }

      pFormat=(WAVEFORMATEX*)GlobalLock(hFormat);

      if(!pFormat){

               GlobalFree(hFormat);

               mmioClose(hmmio,0);

               return FALSE;

      }

      if(mmioRead(hmmio,(HPSTR)pFormat,dwFmtSize)!=(LONG)dwFmtSize){

               GlobalUnlock(hFormat);
				
				<dp n="d471"/>
               GlobalFree(hFormat);

               mmioClose(hmmio,0);

               return FALSE;

      if(pFormat->wFormatTag!=WAVE_FORMAT_PCM){

               GlobalUnlock(hFormat);

               GlobalFree(hFormat);

               mmioClose(hmmio,0);

               return FALSE;

      }

      GlobalUnlock(hFormat);

      GlobalFree(hFormat};

      mmioAscend(hmmio,&amp; mmckinfoSubchunk,0);

      mmckinfoSubchunk.ckid=mmioFOURCC(′d′,′a′,′t′,′a′);

      if(mmioDescend(hmmio,&amp; mmckinfoSubchunk,&amp; mmckinfoParent,
MMIO_FINDCHUNK)){

               mmioClose(hmmio,0);

               return FALSE;

      }

      pcm_data_size=mmckinfoSubchunk.cksize;

      if(pcm_data_size==0L){

                mmioClose(hmmio,0);

                return FALSE;

      }

      return TRUE;
}
BOOL PCMReadFile(PVOID pBuffer,DWORD bytes_to_read,PDWORD was_read){

      LONG actually_read;

      actually_read=mmioRead(hmmio,pBuffer,bytes_to_read);

      if(actually_read==-1}

               return FALSE;

      *was_read=actually_read;
DWORD PCMGetDataSize(){

      return pcm_data_size;
}
				
				<dp n="d472"/>
BOOL PCMCloseFile(){

      mmioClose(hmmio,0);

      return TRUE;
}
				
				<dp n="d473"/>
#include″asrapi.h″
#include″asr1500.h″
#include″notifyproc.h″
#include″..\crpro\crpro.h″
#include″creapi.h″
#include″mess.h″
#include″intdefs.h″
#include″uniprt.h″
#include″queue.h″
extern cREAPI_NOTIFY_PROC UserReadNotifyProc;
extern CREAPI_NOTIFY_PROC UserWriteNotifyProc;
void TestAckProc(PNOTIFY_PARAMS pNotifyParams);
extern HQUEUE hReadNotifyQueue;
extern HQUEUE hWriteNotifyQueue;
void DoReadNotify(PNOTIFY_PARAMS pNotifyParams);
void DoWriteNotify(PNOTIFY_PARAMS pNotifyParams);
void UnitTalkBufferDone(PNOTIFY_PARAMS pNotifyParams);
extern BOOL bUnitRecord;
void UnitRecordBufferReady(PNOTIFY_PARAMS pNotifyParams);
extern BOOL bWaitForEvent;
void WaitForEventBufferReady(PNOTIFY_PARAMS pNotifyParams);
extern HANDLE hEventEvent;
//=======================================================
void CALLBACK CrApiReadNotifyProc(PNOTIFY_PARAMS pNotifyParams){

      BOOL CallUserCallback=TRUE;

      switch(pNotifyParams->dwNotifyType){

      case CRPRO_CNTR_RECEIVED:

              TestAckProc(pNotifyParams);

              break;

      case CRPRO_READ_BUFFER_READY:

              if(bUnitRecord){

                      UnitRecordBufferReady(pNotifyParams);

                      CallUserCallback=FALSE;

              }
				
				<dp n="d474"/>
               if(WaitForSingleObject(hEventEvent,0)==WAIT_TIMEOUT){

                      WaitForEventBufferReady(pNotifyParams);

                      CallUserCallback=FALSE;

               }

               break;

       }

       if(UserReadNotifyProc!=NULL &amp;&amp; CallUserCallback)

               DoReadNotify(pNotifyParams);
}
//================================================================
void CALLBACK CrApiWriteNotifyProc(PNOTIFY_PARAMS pNotifyParams){

       if(pNotifyParams->dwFlags==UNIT_TALK_BUFFER){

               UnitTalkBufferDone(pNotifyParams);

               return;

       }

       switch(pNotifyParams->dwNotifyType){

       case CRPRO_WRITE_BUFFER_DONE:

               break;

       case CRPRO_WRITE_BUFFER_BREAK:

               break;

       }

       if(UserWriteNotifyProc!=NULL)

       DoWriteNotify(pNotifyParams);
}
//===================================
void DoReadNotify(PNOTIFY_PARAMS pNotifyParams){

       PNOTIF_PARAMS pPushParams;

       pPushParams=(PNOTIFY_PARAMS)GlobalAlloc(GPTR,
sizeof(NOTIFY_PARAMS));

       memcpy(pPushParams,pNotifyParams,sizeof(NOTIFY PARAMS));

       pPushParams->pBuffer=GlobalAlloc(GPTR,
pNotifyParams->dwBufferLength);

       memcpy(pPushParams->pBuffer,pNotifyParams->pBuffer,
pNotifyParams->dwBufferLength);

       QueuePush(hReadNotifyQueue,pPushParams);
}
				
				<dp n="d475"/>
//===============================================================
void DoWriteNotify(PNOTIFY_PARAMS pNotifyParams){

      PNOTIFY_PARAMS pPushParams;

      pPushParams=(PNOTIFY_PARAMS)GlobalAlloc(GPTR,
sizeof(NOTIFY_PARAMS));

      memcpy(pPushParams,pNotifyParams,sizeof(NOTIFY_PARAMS));

      QueuePush(hWriteNotifyQueue,pPushParams);
}
//===================================
				
				<dp n="d476"/>
#ifndef_NOTIFYPROC_H_
#define_NOTIFYPROC_H_
#include<windows.h>
#include<mmsysytem.h>
typedef struct_LOCAL_NOTIFY_PMRAMS{

      BOOL last_buffer;

      HANDLE hAsyncEvent;

      HANDLE hSyncEvent;

      HANDLE hThread;

      PBOOL pbUnitTalkProcess;
}LOCAL_NOTIFY_PARAMS,*PLOCAL_NOTIFY PARAMS;
void SetWaitMessage(PVOID pWaitMessage,BYTE byWaitMessageSize,BYTE
byWaitMessageType);
#endif//NOTIFYPROC_H_
				
				<dp n="d477"/>
#define_CREAPI_DLL_
#include <windows.h>
#include <mmsystem.h>
#include "resource.h"
#include "asrapi.h"
#include "asrLS00.h"
#include "strsupp.h"
#include "creapi.h"
#include "mess.h"
#include "intdefs.h"
#include "uniprt.h"
#include "sr.h"
#include "..\crpro\crpro.h"
#define CTX_CLOSE
#define CTX_WRITE_MODE  2
#define CTX_READ_MODK   3
extern HINSTARCE hInstance;
HDB hDb;
HASR hAsr;
HCTX hCtx;
WORD wCtxMode=CTX_CLOSE;
char actire_context[80];
DWORD userThrmadID;
HANDLE hWEThread;
DWORD dwWZResult;
WORD ConfLevelFilter=0;
NOTIFY_RESULT_SIMPLE* las=_sr_resul=NULL;
DWORD CALLBACK No=ifyProc(HNOTIFY hNo=ify, NOTIFY_TYPE No=ifyTy~e, HASR
hAsr, DWORD UserData);
void CALLBACK ErrorProc(HASR hAsr, WORD BlockID, ASRERROR ErrorID);
void CALLBACK stateChangeProc(HASR hAmr, ASRSTATE AsrState, ASRMODE
AsrModeJ;
DWORD SetActiveConteXt(char' con=ext, WORD mode);
				
				<dp n="d478"/>
CREAPI STATUS crsrSelectContext(LPSTR context);
DWORD SRThreadID;
HANDLE hSRThread;
HANDLE hEventEvent;
UINT srMessage;
BOOL srOpen(){

      ASRERROR status;

      char database[80];

      if(!LoadString(hInstance,IDS DATABASE,database,sizeof(database)))

               return FALSE;

      hDb=asrDbOpen(database);

      if(hDb<ASRERR_MAXERR)

               return FALSE;

      hAsr=asrRecOpenEx(hDb,″Win32″,NULL,ErrorProc,StateChangeProc,
NotifyProc,0);

      if(hAsr<ASRERR_MAXERR){

               asrDbClose(hDb);

               return FALSE;

      }

      status=asrRecSetMode(hAsr,ASRMODE CONTINUOUS);

      if(status!=ASRERR OK){

               asrRecClose(hAsr);

               asrDbClose(hDb);

               return FALSE;

      }
				
				<dp n="d479"/>
      hEventEvent=CreateEvent(NULL,TRUE,TRUE,NULL);

      return TRUE;
}
//==================================
DWORD srStart(){

      DWORD status;

      WAVEFORMAT wf=(WAVE_FORMAT_PCM,1,8000,8000,1);

      if(wCtxMode==CTX_CLOSE)

              return CREAPI_STATUS_ERR_CNTX_INACTIVE;

      status=asrRecAcqOpen(hAsr,&amp; wf);

      if(status!=ASRERR_OK)

              return status+SR_MIN_ERR_VALUE;

      status=asrRecStart(hAsr,NULL,NULL);

      if(status!=ASRERR_OK){

              asrRecAcqClose(hAsr);

              return status+SR_MIN_ERR_VALUE;

      }

      return STATUS_OK;
//==================================
DWORD srStop(){

      DWORD status;

      status=asrRecBreak(hAsr);

      if(status!=ASRERR_OK)

              return status+SR_MIN_ERR_VALUE;

      status=asrRecAcqClose(hAsr);

      if(status!=ASRERR_OK)

              return status+SR_MIN_ERR_VALUE;
      return STATUS_OK;
}
//==================================
BOOL srClose(){

      SetActiveContext(active_context,CTX_CLOSE);

      asrRecClose(hAsr);

      asrDbClose(hDb);
				
				<dp n="d480"/>
      if(last_sr_result)

              GlobalFree(last_sr_result;

      CloseHandle(hEventEvent);

      return TRUE;
//==================================
CREAPI_STATUS crSrCreateContext(LPSTR context){

      ASRERROR asr_status;

      char user[80];
      char syntax[80];

      char language[80];

      char upper_context[80];

      if(*context==0)

              return CREAPI_STATUS_ERR_CONTEXTNAME;

      if(!LoadString(hInstance,IDS_USER,user,sizeof(user)))

              return CREAPI_STATUS_ERR_LOADSTRING;

      if(!LoadString(hInstance,IDS_LANGUAGE,language,sizeof(language)))

              return CREAPI_STATUS_ERR_LOADSTRING;

      if(!LoadString(hInstance,IDS_SYNTAX,syntax,sizeof(syntax)))

              return CREAPI_STATUS_ERR_LOADSTRING;

      strcpy(upper_context,context);

      str_to_upper(upper_context);

      asr_status=asrCtxCreate(hDb,user,language,syntax,upper_context);

      return asr_status==ASRERR_OK?STATUS_OK:asr_status+SR_MIN_ERR_VALUE;
//==================================
CREAPI_STATUS crSrDeleteContext(LPSTR context){
      ASRERROR asr_status;

      char user[80];

      char upper_context[80];

      strcpy(upper_context,context);

      str_to_upper(upper_context);

      if(!LoadString(hInstance,IDS_USER,user,sizeof(user)))

               return CREAPI_STATUS_ERR_LOADSTRING;

				
				<dp n="d481"/>
      asr_status=asrCtxDelete(hDb,user,upper_context);

      return asr_status==ASRERR_OK?STATUS_OK:asr_status+SR_MIN_ERR_VALUE;
//===================================
CREAPI_STATUS crSrGetContexts(LPSTR buffer,PDWORD dwBufferSize

      ASERROR asr_status;

      DWORD dwSize;

      DWORD i;

      char user[80];

      if(!LoadString(hInstance,ID1S_USER,user,sizeof(user)))

               return CREAPI_STATUS_ERR_LOADSTRING;

      asr_status=asrUsrGetInfo(hDb,user,ASRUSRINFO_CONTEXTS,NULL,
&amp; dwSize);

      if(asr_status!=ASRERR_OK)

               return asr_status+SR_MIN_ERR__VALUE;

      if(buffer==UNLL){

               *dwBufferSize=dwSize;

               return STATUS_OK;

      if(*dwBufferSize<dwSize)

               return CREAPI STATUS_ERR_BUFFER_TOO_SMALL;

      asr_status=asrUsrGetInfo(hDb,user,ASRUSRINFO_CONTEXTS,buffer,
dwBufferSize);

      if(asr_status!=ASRERR_OK)

               return asr_status+SR_MIN_ERR_VALUE;

      for(i=0;i<dwSize-1;i++){

               if(buffer[i]==0){

                       if(buffer[i+1]==0)

                                break;

                       buffer[i]=′,′;

               }

      }

      return STATUS OK;
//===================================
DWORD SetActiveContext(char* context,WORD mode){

      DWORD status=STATUS_OK;
				
				<dp n="d482"/>
       char user[80];

       if(strcmp(context,active_context)!=0||mode!=wCtxMode)(

              if(wCtxMode!=CTX_CLOSE){

                      if(wCtxMode==CTX_READ_MODE){

                              status=asrRecCtxActivateEx(hAsr,
(ASRACTIVATE*)NULL,0,(HLIB)NULL);

                              if(status!=ASRERR_OK)

                                      return status+SR_MIN_ERR_VALUE;

                      }

                      status=asrCtxClose(hCtx,TRUE);

                      if(status!=ASRERR_OK)

                              return status+SR_MIN_ERR_VaLUE;

              }

              if(mode!=CTX_CLOSE){

                      if(!LoadString(hInstance,IDS_USER,user,
sizeof(user)))

                              return CREAPI_STATUS_ERR_LOADSTRING;

                      if(mode==CTX_READ_MODE)

                              hCtx=asrCtxOpen(hDb,user,context,
ASRCTXATTRIB_READ);

                      else

                              hCtx=asrCtxOpen(hDb,user,context,
ASRCTXATTRIB_WRITE);

                      if(hCtx>ASRERR_MAXERR){

                      if(mode==CTX_READ_MODE){

                              ASRACTIVATE AsrActivate;

                              AsrActivate.hCtx=hCtx;

                              *AsrActivate.szSymbol=′\0′;

                              status=asrRecCtxActivateEx(hAsr,
&amp; AsrActivate,1,(HLIB)NUL);

                              if(status!=ASRERR_OK){

                                      asrCtxClose(hCtx,FALSE);

                                      return
status+SR_MIN_ERR_VALUE;

                              }

                     }

                     strcpy(active_context,context);

                     wCtxMode=mode;

               }

         }

  }

  return status ;
}
				
				<dp n="d483"/>
//=====================================================
CREAPI_STATUS crSrSelectContext(LPSTR context){

      char user[80];

      DWORD dwSize;

      char* pBuffer;

      char* pUpperContext;

      DWORD status;

      if(context==NULL)

              return SetActiveContext(active_context,CTX_CLOSE);

      if(!LoadString(hInstance,IDS_USER,user,sizeof(user)))

              return CREAPI_STATUS_ERR_LOADSTRING;

      status=asrUsrGetInfo(hDb,user,ASRUSRINFO_CONTEXTS,NULL,&amp; dwSize);

      if(status!=ASRERR_OK)

              return status+SR_MIN_ERR_VALUE;

      pBuffer=(char*)GlobalAlloc(GPTR,dwSize);

      if(!pBuffer)

              return CREAPI_STATUS_ERR_MALLOC;

      status=asrUsrGetInfo(hDb,user,ASRUSRINFO_CONTEXTS,pBuffer,
&amp; dwSize);

      if(status!=ASRERR_OK){

              GlobalFree(pBuffer);

              return status+SR_MIN_ERR_VALUE;

      }

      pUpperContext=GlobalAlloc(GPTR,strlen(context)+1);

      if(!pUpperContext){

              GlobalFree(pBuffer);

              return CREAPI_STATUS_ERR_MALLOC;

      }

      strcpy(pUpperContext,context);

      str_to_upper(pUpperContext);

      if(!szszz(pUpperContext,pBuffer)){
               GlobalFree(pBuffer);

               GlobalFree(pUpperContext);

               return CREAPI_STATUS_ERR_CNTX_NOT_FOUND;

      }

      GlobalFree(pBuffer);

      status=SetActiveContext(pUpperContext,CTX_READ_MODE);
				
				<dp n="d484"/>
              Global Free (pUoperContext);

              return status;
//===================================
CREAPI_STATUS crSrGetWords(LPSTR buffer,PDWORD pdwBufferSize){

      ASRERROR status;

      DWORD dwSize,i;

      if(wCtxMode==CTX_CLOSE)

              return CREAPI_STATUS_ERR_CNTX_INACTIVE;

      status=asrCtxGetWords(hCtx,ASRCTXGETWORDS_ALLWORDS,″Word″,NULL,
&amp; dwSize);

      if(status!=ASRERR_OK)

              return status+SR_MIN_ERR_VALUE;

      if(buffer=NULL){

              *pdwBufferSize=dwSize;

              return STArS_OK;

      }

      if(*pdwBufferSize<dwSize)

              reeturn CREAPI_STATUS_ERR_BUFFER_TOO_SMALL;

      status=asrCtxGetWords(hCtx,ASRCTXGETWORDS_ALLWORDS,″Word″,buffer,
&amp; dwSize);

      if(status!=ASRERR_OK)

              return status+SR_MIN_ERR_VALUE;

      for(i=0;i<dwSize-1;i++){

              if(buffer[i]==0){

                     if(buffer[i+1]==0)

                             break;

                     buffer[i]=′,′;

              }

              return STATUS_OK;
//====================================
CREAPI_STATUS crSrAddWords(LPSTR list_of_words){
				
				<dp n="d485"/>
       char seps[]=″,\n″;

       char* token;

       char* pSource;

       char* pWord;

       char* pWordsInDB;

       ASRERROR status;

       DWORD dwSize;

       if(wCtxMode==CTX_CLOSE)

               return CREAPI_STATUS_ERR_CNTX_INACTIVE;

       status=asrCtxGetWords(hCtx,ASRCTXGETWORDS_ALLWORDS,″Word″,NULL,
&amp; dwSize);

       if(status!=ASRERR_OK)

               return status+SR_MIN_ERR_VALUE;

       pWordsInDB=GlobalAlloc(GPTR,dwSize);

       if(!pWordsInDB)

               return CREAPI_STATUS_ERR_MALLOC;

       status=asrCtxGetWords(hCtx,ASRCTXGETWORDS_ALLWORDS,″Word″,
pWordsInDB, &amp; dwSize);

       if(status!=ASRERR_OK){

               GlobalFree(pWordsInDB);

               return status+SR_MIN_ERR_VALUE;

       }

       pSource=GlobalAlloc(GPTR,strlen(list_of_words)+1);

       if(!pSource){

               GlobalFree(pWordsInDB);

               return CREAPI_STATUS_ERR_MALLOC;

       }

       strcpy(pSource,list_of_words);

       token=strtok(pSource,seps);

       while(token!=NULL){

               pWord=GlobalAlloc(GPTR,strlen(token)+1);

               if(!pWord){

                        GlobalFree(pSource);

                        GlobalFree(pWordsInDB);

                        return CREAPI_STATUS_ERR_MALLOC;

               }
               strcpy(pWord,token);

               pWord=str_alltrim(pWord);

               str_to_upper(pWord);

               if{!szszz(pWord,pWordsInDB)){
				
				<dp n="d486"/>
                    status=SetActiveContext(active_context,
CTX_WRITE_MODE);

                    if(status!=STATUS_OK){

                            GlobalFree(pWord);

                            GlobalFree(pSource);

                            GlobalFree(pWordsInDB);

                            SetActiveContext(active_context,
CTX_READ_MODE);

                            return status;

                    }

                    status=asrCtxAddWord(hCtx,(HDICT)NULL,″Word″,
pWord);

                    if(status!=ASRERR_OK){

                            GlobalFree(pWord);

                            GlobalFree(pSource);

                            GlobalFree(pWordsInDB);

                            SetActiveContext(active_context,
CTX_READ_MODE);

                            return status+SR_MIN_ERR_VALUE;

                    }

             }

             GlobalFree(pWord);

             token=strtok(NULL,seps);

      }

      GlobalFree(pSource);

      GlobalFree(pWordsInDB);

      status=SetActiveContext(active_context,CTX_READ_MODE);

      return status;
}
//=======================================
CREAPI_STATUS crSrRemoveWords(LPSTR list_of_words){

      char seps[]=″,\n″;

      char* token;

      char* pSource;

      char* pWord;

      char*pWordsInDB;

      ASRERROR status;

      DWORD dwSize;

      status=asrCtxGetWords(hCtx,ASRCTXGETWORDS_ALLWORDS,″Word″,NULL,
&amp; dwSize);
				
				<dp n="d487"/>
      if(status!=ASRERR_OK)

               return status+SR_MIN_ERR_VALUE;
      pWordsInDB=GlobalAlloc(GPTR,dwSize);

      if(!pWordsInDB)

               return CREAPI_STATUS_ERR_MALLOC;

      status=asrCtxGetWords(hCtx,ASRCTXGETWORDS_ALLWORDS,″Word″,
pWordsInDB,&amp; dwSize);

      if(status!=ASRERR_OK){

               GlobalFree(pWordsInDB);

               return status+SR_MIN_ERR_VALUE;

      }

      pSource=GlobalAlloc(GPTR,strlen(list_of_words)+1);

      if(!pSource){

               GlobalFree(pWordsInDB);

               return CREAPI_STATUS_ERR_MALLOC;

      }

      strcpy(pSource,list_of_words);

      token=strtok(pSource,seps);
      while(token!=NULL){

               pWord=GlobalAlloc(GPTR,strlen(token)+1);

               if(!pWord){

                        GlobalFree(pSource);

                        GlobalFree(pWordsInDB);

                        return CREAPI_STATUS_ERR_MALLOC;

               }

               strcpy(pWord,token);

               pWord=str_alltrim(pWord);

               str_to_upper(pWord);

               if(szszz(pWord,pWordsInDB)){

                        status=SetActiveContext(active_context,
CTX_WRITE_MODE);

                        if(status!=STATUS_OK){

                                GlobalFree(pWord);

                                GlobalFree(pSource);

                                GlobalFree(pWordsInDB);

                                SetActiveContext(active_context,
CTX_READ_MODE);

                                return status;

                        }

                        status=asrCtxDeleteWord(hCtx,″Word″,pWord);

                        if(status!=ASRERR_OK){

                                GlobalFree(pWord);
				
				<dp n="d488"/>
                           GlobalFree(pSource);

                           GlobalFree(pWordsInDB);

                           SetActiveContext(active_context,
CTX_READ_MODE);

                           return status+SR_NIN_ERR_VALUE;

                    }

             }

             GlobalFree(pWord);

             token=strtok(NULL,seps);

             GlobalFree(pSource);

             GlobalFree(pWordsInDB);

             status=SetActiveContext(active_context,CTX_READ_MODE);
             return statrs;
//====================================
DWORD CALLBACK NotifyProc(HNOTIFY hNotify,NOTIFY_TYPE NotifyType,HASR
hAsr,DWORD UserData)(

      ASRERROR err;

      NOTIFY_RESULT_N nN;

      NOTIFY_FORMAT_SIMPLE nFormat;

      DWORD size=sizeof(NOTIFY_RESULT_N);

      switch(NotifyType.wNotifyType){

      case NOTIFY_TYPE_RESULT:
              asrNotifyQuery(hNotify,NRESULT_N,NULL,0,&amp; nN,&amp; size);

              nFormat. wN=0;

              nFormat.wActions=FORMAT_SIMPLE_ALL;
              nFormat.bNoReject=FALSE;

              err=asrNotifyQuery(hNotify,

                                                 NRESULT_SIMPLE,

                                                 &amp; nFormat,
sizeof(NOTIFY_FORMAT_SIMPLE),

                                                 NULL,

                                                 &amp; size);

              if(last_sr_result)

                      GlobalFree(last_sr_result);

                      last_sr_result=(NOTIFY_RESULT_SIMPLE*)GlobalAlloc(GPTR,
size);
				
				<dp n="d489"/>
                if(!last_sr_result)(

                         asrNotifyRelease(hNotify);

                         return ASRERR_OK;
                }        
                err=asrNotifyQuery(hNotify,

                                                       NRESULT_SIMPLE,

                                                       &amp;nFormat,
sizeof(NOTIFY_FORMAT_SIMPLE),

                                                       Last_sr_result,

                                                       &amp;size);

               if(Last_sr_result->wConfidence>=ConfLevelFilter)(
                       dwWEResult=WE_SR_RESULT;

                       SetEvent(hEventEvent);

               }

       }

       asrNotifyRelease(hNotify);

       return ASRERR_OK;
}
//=================================
void CALLBACK ErrorProc(HASR hAsr, WORD BlockID, ASRERROR ErrorID)(
)
//=================================
void CALLBACK StateChangeProc(HASR hAsr, ASRSTATE AsrState, ASRMODE
AsrMode}{
}
//=================================
CREAPI_STATUS crSrGetResult(LPSTR pBuffer, PDWORD pdwBufferSize)(

        if(last_sr_result==NULL)

                return CREAPI_STATUS_ERR_RESULT_NOT_EXIST;

        if(pBuffer==NULL){

                *pdwBufferSize-strlen(last_sr_result->szResult)+l;

              return STATUS_OK;

      }

      if((*pdwBufferSize)<(strlen(last_sr_result->szResult)+l))

              return CREAPI_STATUS_ERR_BUFFER_TOO_SMAlL;
				
				<dp n="d490"/>
      strcpy(pBuffer,last_sr_result->szResult);

      return STATUS_OK;
}
//=================================
CREAPI_STATUS crSrGetConfLevel(PWORD pwConfLevel){

      if(last_sr_result==NULL)

              return CREAPI_STATUS_ERR_RESULT_NOT_EXIST;

      *pwConfLevel=last_sr_result->wConfidence;
//======================================
CROPI_STATUS crSrSetConfLevelFilter(WORD wConfLevelFilter){

      ConfLevelFilter=wConfLevelFilter;

      return STATUS_OK;
}
//======================================
CREAPI_STATUS crSrGetParam(WORD wParamType,PWORD pwValue){

      ASRERROR status;

      DWORD dwSize;

      dwSize=sizeof(WORD);

      status=asrRecGetParam(hAsr,wParamType,pwValue,&amp; dwSize);

      if(status!=ASRERR_OK)

               return status+SR_MIN_ERR_VALUE;

      return STATUS_OK;
}
//======================================
CREAPI_STATUS crSrSetParam(WORD wParamType,WORD wNewValue){

      ASRERROR status;

      DWORD dwSize;

      dwSize=sizeof(WORD);

      status=asrRecSetParam(hAsr,wParamType,&amp; wNewValue,dwSize);

      if(status!=ASRERR_OK)

              return status+SR_MIN_ERR_VALUE;

      return STATUS_OK;
}
				
				<dp n="d491"/>
//========================================================
void WaitForEventBufferReady(PNOTIFY_PARAMS pNotifyParams){

      ASRERROR status;

      status=asrRecAcqWaveBuffer(hAsr,pNotifyParams->pBuffer,
pNotifyParams->dwBufferLength);

      if(status!=0)

              MessageBox(0,″asrRecAcqWaveBuffer″,″Error″,MB_OK);
//========================================================
DWORD WINAPI WEThread(PVOID param){

      UINT time_to_wait=(UINT)param;

      DWORD ret_value;

      if(WaitForSingleObject(hEventEvent,time_to_wait)==WAIT_TIMEOUT)

              ret_value=WE_TIMEOUT;

      else

              ret_value=dwWEResult;

      PlstThreadMessage(userThreadID,srMessage,ret_value,0);

      return 0;
//========================================================       
CREAPI_STATUS crWaitForEvent(WORD wUnitNumber,LPSTR pszWordMap,

              DWORD_dwFlags,DWORD time_ms,PWORD pwResult){

      char* pMap;

      ASRERROR status;

      char* pWordsInDB;

      DWORD dwSize;

      char seps[]=″,\n″;

      char* token;

      char* pszWord;

      char* pActiveWordsBuffer;

      char* curr_actbuf_ptr;

      char* p;

      char* pszRetVal;

      DWORD dwWaitRetValue;

      DWORD crapi_status;

      MSG Msg;

      DWORD dwThreadID;

      if(wctxMode==CTX_CLOSE)
				
				<dp n="d492"/>
                return CREAPI_STATUS_ERR_CNTX_INACTIVE;

       dwWEResult=0;

       status=asrCtxGetWords(hCtx,ASRCTXGETWORDS_ALLWORDS,″Word″,NULL,
&amp; dwSize);

       if(status!=ASRERR_OK)

                return status+SR_MIN_ERR_VALUE;

       pWordsInDB=malloc(dwSize);

       if(!pWordsInDB)

                return CREAPI_STATUS_ERR_MALLOC;

       status=asrCtxGetWords(hCtx,ASRCTXGETWORDS_ALLWORDS,″Word″,
pWordsInDB,&amp; dwSize);

       if(status!=ASRERR_OK){

                free(pWordsInDB);

                return status+SR_MIN_ERR_VALUE;

       }

       pMap=GlobalAlloc(GPTR,strlen(pszWordMap)+l);

       if(!pMap){

                free(pWordsInDB);

                return CREAPI_STATUS_ERR_MALLOC;

       }

       strcpy(pMap,pszWordMap);

       pActiveWordsBuffer=malloc(strlen(pMap)+1);

       if(!pActiveWordsBuffer){

                GlobalFree(pMap);

                free(pWordsInDB);

                return CREAPI_STATUS_ERR_MALLOC;

       }

       curr_actbuf_ptr=pActiveWordsBuffer;

       token=strtok(pMap,seps);

       while(token!=NULL)(

                 pszWord=GlobalAlloc(GPTR,strlen(token)+1);

                 if(!pszWord){

                          free(pActiveWordsBuffer);

                          GlobalFree(pMap);

                          free(pWordsInDB);

                          return CREAPI_STATUS_ERR_MALLOC;

                 }

				
				<dp n="d493"/>
                strcpy(pszWord,token);

                pszWord=str_alltrim(pszWord);

                str_to_upper(pszWord);

                p=strchr(pszWord,′/′);

                if(!p){

                        free(pActiveWordsBuffer);

                        GlobalFree(pszWord);

                        GlobalFree(pMap);

                        free(pWordsInDB);

                        return CREAFI_STATUS_ERR_MAP_FORMAT;

                }

                *p=0;

                pszWord=str_alltrim(pszWord);

                if(szszz(pszWord,pWordsInDB)){

                        strcpy(curr_actbuf_ptr,pszWord);

                        curr_actbuf_ptr+=(strlen(pszWordl+1);

                } else {

                        free(pActiveWordsBuffer);

                        GlobalFree(pszWord);

                        GlobalFree(pMap);

                        free(pWordsInDB);

                        return CREAPI_STATUS_ERR_WORDNOTEXIST;

                }

                GlobalFree(pszWord);

                token=strtok(NULL,seps);

        }

        *curr_actbuf_ptr=′\0′;

        status=asrRecSetActiveWords(hAsr,hCtx,ASRREC_DISACTIVATION,
″Word″,pWordsInDB);

        if(status!=ASRERR_OK){

                free(pActiveWordsBuffer);

                GlobalFree(pMap);

                free(pWordsInDB);

                return status+SR_MIN_ERR_VALUE;

        free(pWordsInDB);

        status=asrRecSerActiveWords(hAsr,hCtx,ASRREC_ABSOLUTEACTIVATION,
″Word″,pActiveWordsBuffer);
				
				<dp n="d494"/>
       if(status!=ASRERR_OK;{

               free(pActiveWordsBuffer);

               GlobalFree(pMap);

               free(pWordsInDB);

               return status+SR_MIN_ERR_VALUE;

       }

       free(pActiveWordsBuffer);

       crapi_status=crSendMessage(NULL,CMD_BASE_START_AD,0,NULL,0);

       if(crapi_status!=STATUS_OK){

               GlobalFree(pMap);

               return crapi_status;

       }

       userThreadID=GetCurrentThreadId();

       ResetEvent(hEventEvent);

       status=srStart();

       if(status!=ASRERR_OK){

               GlobalFree(pMap);

               return status;

       }

       hWEThread=CreateThread(NULL,0,WEThread,(PVOID)time_ms,0,
&amp; dwThreadID);

       if(hWEThread==NULL){

               GlobalFree(pMap);

               return CREAPI_STATUS_ERR_MALLOC;

       }

       while(TRUE){

               GetMessage(&amp; Msg,NULL,0,0);

               if(Msg.message==srMessage){

                       break;

               }

               else{

                       TranslateMessage(&amp;Msg);

                       DispatchMessage(&amp;Msg);

               }

       }
				
				<dp n="d495"/>
SetEvent(hEventEvent);
status=srStop();
if(status!=ASRERR_OK){

      GlobalFree(pMap);

      return status;
}
WaitForSingleObject(hWEThread,INFINITE);
dwWaitRetValue=Msg.wParam;
CloseHandle(hWEThread);
if(dwWaitRetValue==WE_TIMEOUT){

      GlobalFree(pMap);

      *pwResult=WE_TIMEOUT;

      return STATUS_OK;
}
strcpy(pMap,pszWordMap);
token=strtok(pMap,seps);
while(token!=NULL){

      pszWord=GlobalAlloc(GPTR,strlen(token)+1);

      if(!pszWord){

               GlobalFree(pMap);

               return CREAPI_STATUS_ERR_MALLOC;

      }

      strcpy(pszWord,token);

      pszWord=str_alltrim(pszWord);

      str_to_upper(pszWord);

      p=strchr(pszWord,′/′);

      *p=0;

      pszRetVal=p+1;

      pszWord=str_alltrim(pszWord);

      if(strcmp(last_sr_result->szResult,pszWord)==0){

              pszRetVal=str_alltrim(pszRetVal);

              *pwResult=atoi(pszRetVal);

              GlobalFree(pMap);

              GlobalFree(pszWord);

              return STATUS_OK;

      }

      GlobalFree(pszWord);

      token=strtok(NULL,seps);
}
				
				<dp n="d496"/>
      *pwResult=WE_NOTFOUND;

      GlobalFree(pMap);

      return STATUS_OK;
}
//==================================
				
				<dp n="d497"/>
#include <string.h>
#include <stdlib.h>
#include ″strsupp.h″
char* szszz(char* pSz,char* pSzz){

      while(*pSzz){

               if(strcmp(pSz,pSzz)==0)

                       return pSzz;

               pSzz+=(strlen(pSzz)+l);

      }

      return NULL;
void str_to_upper(char* str){

      while(*str){

              *str=toupper(*str);

              str++;

      }
char* str_alltrim(char* str){

      char* new_start_pos=str;

      char* reverse_ptr;

      while(*new_start_pos==′′||*new_start_pos==′\t′)

              new_start_pos++;

      reverse_ptr=str+strlen(str)-1;

      while(*reverse_ptr==′′||*reverse_ptr==′\t′)

              reverse_ptr--;

      *(reverse_ptr+1)=′\0′;

      strcpy(str,new_start_pos);

      return str;
}
				
				<dp n="d498"/>
#define_CREAPI_DLL_
#include <indows.h>
#include <mmsvstem.h>
#include ″ttssdk32.h″
#include ″resource.h″
#include ″creapi.h″
#include ″uniprt.h″
#include ″tts.h″
extern HINSTANCE hInstance;
HTTSINSTANCE hTTSInst;
TTSSYSTEMINFO TTSSystemInfo;
DWORD ttsOpen(){

      int status,i,nEngineID;

      char language(80];

      status=TtsInitialize(&amp; hTTSInst,NULL,&amp; TTSSystemInfo);

      if(status!=R_SUCCESSFUL)

              return status+TTS_MIN_ERR_VALUE;

      if(!LoadString(hInstance,IDS_TTS_LANGUAGE,language,
sizeof(language)))

              return GetLastError();

      for(i=0;i<TTSSystemInfo.nMaxEngines;i++){

              if(strcmp(language,TTSSystemInfo.mTtsEg[i].szLanguage)==0){

                      nEngineID=TTSSystemInfo.mTtsEg[i].nEngineId;

                      break;

              }

      }

      status=TtsSelectEngine(hTTSInst,nEngineID,TRUE);

      if(status!=R_SUCCESSFUL){

              status=TtsUninitialize(hTTSInst);

              return status+TTS_MIN_ERR_VALUE;

      }

      status=TtsSetFreq(hTTSInst,M_FREQ_8KHZ);

      if(status!=R_SUCCESSFUL){

      status=TtsUninitialize(hTTSInst);

              return status+TTS_MIN_ERR_VALUE;

      }

      return STATUS_OK;
}
				
				<dp n="d499"/>
DWORD ttsClose(){

      int status;
      status=TtsUninitialize(hTTSInst);

      if(status!=R_SUCCESSFUL)

              return status+TTS_MIN_ERR_VALUE;
}
CREAPI_STATUS crTsGetSpeechMode(PTTS_SPEECH_MODE pSpeechMode)

      int status;

      status=TtsGetSpeechMode(hTTSInst,

              &amp;pSpeechMode->Volume,

              &amp;pSpeechMode->Speaker,

              &amp;pSpeechMode->SpeechRate,

              &amp;pSpeechMode->Pitch,

              &amp;pSpeechMode->PauseDur,

              &amp;pSpeechMode->ReadMode);

      if(status!=R_SUCCESSFUL)

              return status+TTS_MIN_ERR_VALUE;

      return STATUS_OK;
}
CREAPI_STATUS crTsSetSpeechMode(PTTS_SPEECH_MODE pSpeechMode){

      int status;

      status=TtsSetSpeechMode(hTTSInst,FALSE,

              pSpeechMode->Volume,

              pSpeechMode->Speaker,

              pSpeechMode->SpeechRate,

              pSpeechMode->Pitch,

              pSpeechMode->PauseDur,

              pSpeechMode->ReadMode);

      if(status!=R_SUCCESSFUL)

              return status+TTS_MIN_ERR_VALUE;

      return STATUS_OK;
}
#ifndef_MESS_H_#define_MESS_H_#define SRC_DEST_TCU                        1#define SRC_DEST_BASE                       0#define ACK_EXPECTED_MASK                   0x20#define SRC_DEST_MASK                       0x40#define DIRECTION_MASK                      0x80#define CMD_BASE_RESET                      0x21#define CMD_BASE_START_DA                   0x00#define CMD_BASE_START_AD                   0x02#define CMD_BASE_STOP_DA                    0x01#define CMD_BASE_GET_VERSION       0x20#define CMD_BASE_BREAK                      0x22#define ACK_BASE_BREAK                      0x82#define ACK_BASE_FINISHED_DA       0x90#define ACK_BASE_GET_VERSION       0x80#define ACK_BASE_RESET                      0x81#define BASE_ACK_TIME_OUT          1000#define UNIT_ACK_TIMEOUT           1000#define MAX_MESSAGE_SIZE           255#endif//_MESS_H_ #ifndef_MMIO_H_#define_MMIO_H_BOOL PCMInitFile(LPCTSTR PszFileName);BOOL PCMReadFile(PVOID pBuffer,DWORD bytes_to_read,PDWORD was_read);DWORD PCMGetDataSize();BOOL PCMCloseFile();#endif #ifndef_SR_H_#define_SR_H_BOOL srOpen();BOOL srClose();#endif//_SR_H_ #ifndef_STRSUPP_H_#defin__STRSUPP_H_char* szszz(char* pSz,char* pSzz);void str_to_upper(char* str);char* str_alltrim(char* str);#endif//_STRSUPP_H_ #ifndef_TTS_H_#define_TTS_H_DWORD ttsOpen();DWORD ttsClose();#endif//_TTS_H_ #define BAsEIO_READ_QUEUE#define BASEIO_WRITE_QUEUE#define STATUS_OK                               0#define BASEIO_ERR_COM_READ                     1#define BASEIO_ERR_MEM_ALLOC                    2#define BASEIO_ERR_COM_WRITE                    3#define BASEIO_ERR_BREAK                        4#define BASEIO_ERR_MEDIA_CONNECT                5#define BASEIO_ERR_MEDIA_SETUP                  6#define BASEIO_ERR_ALREADY_CONNECTED            7#define BASEIO_ERR_NOT_CONNECTED                8#define BASEIO_ERR_RESET_NOT_COMPLETE           9#define CRPRO_ERR_MALLOC                        101#define CRPRO_CONTROL_TOO_LONG                  102#define CREAPI_STATUS_ERR_WRONGSTATE            201#define CREAPI_STATUS_ERR_PCMINIT               202#define CREAPI_STATUS_ERR_MALLOC                203#define CREAPI_STATUS_ERR_PCMREAD               204#define CREAPI_STATUS_ERR_BASENOTFOUN           205#define CREAPI_STATUS_ERR_TIMEOUT               206#define CREAPI_STATUS_ERR_SROPEN                207#define CREAPI_STATUS_ERR_SRINTERNAL            208#define CREAPI_STATUS_ERR_BUFFERTOOSMALL        209#define CREAPI _STATUS_ERR_WORDNOTEXIST         210#define CREAPI_STATUS_ERR_CNTXNOTACTIVE         211#define CREAPI_STATUS_ERR_LOADSTRING            212#define CREAPI_STATUS_ERR_BUFFER_TOO_SMALL      212#define CREAPI_STATUS_ERR_CNTX_NOT_FOUND        213#define CREAPI_STATUS_ERR_CNTX_INACTIVE         214#define CREAPI_STATUS_ERR_MAP_FORMAT            215#define CREAPI_STATUS_ERR_SYS_ERROR             216#define CREAPI_STATUS_ERR_RESULT_NOT_EXIST      217#define CREAPI_STATUS_ERR_FLAG_NOTSUPP          218#define CREAPI_STATUS_ERR_FILE_CREATE           219#define CREAPI_STATUS_ERR_FILE_WRITE            220#define CREAPI_STATUS_ERR_CONTEXTNAME           221#define SR_MIN_ERR_VALUE                        300#define TTS_MIN_ERR_VALUE                       400 CRPRO.DLL 系列单端口PC软件协议实现模块Crpro.dll
//crpro.c
#define_CRPRO_DLL
#include ″crpro.h″
#include ″..\baseio\baseio.h″
#include ″..\capi\uniprt.h″
#define ID_BYTE                               0x05
#define MAX_MESSAGE_SIZE                      255
#define CRPRO_INTERNAL_USE                    1
BYTE MARKER()=(0xFF,ID_BYTE);
BYTE ControlBuffer[MAX_MESSAGE_SIZE+2];
DWORD BytesInControlBuffer=0;
DWORD MarkerWasRead=0;
DWORD dwReadUserData=0;
BYTE CountCheckSumm(PBYTE pBuffer,DWORD dwBufferSize);
void PrepareBuffer(PVOID pBuffer,DWORD dwBufferSize);
void ProcessInputBuffer(PBUFFER_HEADER pBufferHeader);
PVOID ControlSequenceSearch(PBYTE pBuffer,DWORD dwBufferSize);
void CALLBACK ReadNotifyCallback(DWORD dwNotifType,PBUFFER_HEADER
pBufferHeader);
void CALLBACK WriteNotifyCallback(DWORD dwNotifType,PBUFFER_HEADER
pBufferHeader);
NOTIFY_PROC UserReadCallback;
NOTIFY_PROC UserWriteCallback;
//=============================================
CRPRO_STATUS proTransferReset(DWORD dwFlags){

    return bioTransferReset(dwFlags);
}
//=============================================
CRPRO_STATUS proSendMessage(PVOID pMessage,BYTE byMessageSize,BYTE
byMessageType){

    PCONTROL_HEADER pControlHeader;
				
				<dp n="d509"/>
    DWORD actual_size;

    BYTE check_summ;

    DWORD status;

    if(byMessageSize>MAX_MESSAGE_SIZE)

           return CRPRO_ERR_CONTROL_TOO_LONG;

    actual_size=sizeof(CONTROL_HEADER)+byMessageSize;

    pControlHeader=(PCONTROL_HEADER)GlobalAlloc(GPTR,actual_size);

    if(!pControlHeader)

           return CRPRO_ERR_MALLOC;

    memcpy(pControlHeader->Marker,MARKER,MARKER_SIZE);

    pControlHeader->MessageType=byMessageType;

    pControlHeader->MessageSize=byMessageSize;

    memcpy(&amp;(pControlHeader->MessageFirstByte),pMessage,byMessageSize);

    check_summ=CountCheckSumm(&amp;(pControlHeader->MessageType),
actual_size-MARKER_SIZE-1);

    *(((PBYTE)(pControlHeader))+actual_size-1)=check_summ;

    status=bioAddOutBuffer(pControlHeader,actual_size,0,
CRPRO_INTERNAL_USE);

    if(status!=STATUS_OK)

          GlobalFree(pControlHeader);

    return status;
}
//======================================
CRPRO_STATUS proSendBuffer(PVOID pBuffer,DWORD dwBufferSize,DWORD
dwUserData,DWORD dwFlags){

    PrepareBBuffer(pBuffer,dwBufferSize);   //0xFF->0xFE

    dwFlags&amp;=-CRPRO_INTERNAL_USE;

    return bioAddOutBuffer(pBuffer,dwBufferSize,dwUserData,dwFlags);
}
//======================================
CRPRO_STATUS proSystemOpen(UINT DeviceID,NOTIFY_PROC ReadCallback,
NOTIFY_PROC WriteCallback){

    UserReadCallback=ReadCallback;

    UserWriteCallback=WriteCallback;

    return bioMediaConnect(DeviceID,ReadNotifyCallback,
WriteNotifcallback);
				
				<dp n="d510"/>
//=======================================
CRPRO_STATUS proSystemClose(){

    return bioMediaDisconnect();
//=======================================
void CALLBACK ReadNotifyCallback(DWORD dwNotifType,PBUFFER_HEADER
pBufferHeader){

    switch(dwNotifType){

    case BASEIO_READ_BUFFER_READY:

          ProcessInputBuffer(pBufferHeader);

          return;

    case BASEIO_ASYNC_ERROR:

          break;

    }
//=======================================
void CALLBACK WriteNotifyCallback(DWORD dwNotifType,PBUffer_HEADER
pBufferHeader){

    NOTIFY_PARAMS notify_params;

    if(UserWriteCallback!=NULL){

          switch(dwNotifType){

          case BASEIO_WRITE_BUFFER_DONE:

                notify_params.pBuffer=(PBYTE)pBufferHeader->pBuffer;

                notify_params.dwBufferLength=pBufferHeader->dwBufferSize;

                if(pBufferHeader->dwFlags &amp; CRPRO_INTERNAL_USE){

                      (PBYTE)notify_params.pBuffer+=2;

                      notify_params.dwBufferLength-=3;

                }

                notify_params.dwUserData=pBufferHeader->dwUser;

                notify_params.dwFlags=pBufferHeader->dwFlags;

                if(pBufferHeader->dwFlags &amp; CRPRO_INTERNAL_USE)

                      notify_params.dwNotifyType=CRPRO_WRITE_MESSAGE_DONE;

                else

                      notify_params.dwNotifyType=CRPRO_WRITE_BUFFER_DONE;

                break;
				
				<dp n="d511"/>
          case BASEIO_WRITE_BREAK:

                notify_params.pBuffer=(PBYTE)pBufferHeader->pBuffer;

                notify_params.dwBufferLength=pBufferHeader->dwBufferSize;

                if(pBufferHeader->dwFlags &amp; CRPRO_INTERNAL_USE){

                      (PBYTE)notify_params.pBuffer+=2;

                      notify_params.dwBufferLength-=3;

                }

                notify_params.dwUserData=pBufferHeader->dwUser;

                notify_params.dwFlags=pBufferHeader->dwFlags;

                if(pBufferHeader->dwFlags &amp; CRPRO_INTERNAL_USE)

    notify_params.dwNotifyType=CRPRO_WRITE_MESSAGE_BREAK;

                else

                      notify_params.dwNotifyType=CRPRO_WRITE_BUFFER_BREAK;

                break;

          case BASEIO_ASYNC_ERROR:

                notify_params.pBuffer=pBufferHeader->pBuffer;

                notify_params.dwBufferLength=pBufferHeader->dwBufferSize;

                notify_params.dwUserData=pBufferHeader->dwUser;

                notify_params.dwFlags=pBufferHeader->dwFlags;

                notify_params.dwNotifyType=CRPRO_ASYNC_ERROR;

                break;

           }

           UserWriteCallback(&amp;notify_params);

           if(pBufferHeader->dwFlags &amp; CRPRO_INTERNAL_USE)(

                GlobalFree(pBufferHeader->pBuffer);

                return;

           }

     }
}
//=====================================
void PrepareBuffer(PVOID pBuffer,DWORD dwBufferSize){

     DWORD size_to_search=dwBufferSize;

     PBYTE pBuffer_to_search=(PBYTE)pBuffer;

     PBYTE ptr;

     while((ptr=memchr(pBuffer_to_search,0xFF,size_to_search))){

           *ptr=0xFE;

           size_to_search-=(ptr-pBuffer_to_search+1);

           pBuffer_to_saarch=ptr+1;

     }
}
				
				<dp n="d512"/>
//============================================
void ProcessInputBuffer(PBUFFER_HEADER pBufferHeader)-(

    NOTIFY_PARAMS notify_params;

    PBYTE pBuffer=pBufferHeader->pBuffer;

    DWORD dwBufferSize=pBufferHeader->dwBufferSize;

    DWORD min_buff_length;

    PBYTE pControlSequence;

    while(dwBufferSize>0){

          if(MarkerWasRead>0){

                if(MarkerWasRead!=MARKER_SIZE){

                      min_buff_length=min(dwBufferSize,
MARKER_SIZE-MarkerWasRead);

                      if(memcmp(pBuffer,MARKER+MarkerWasRead,
min_buff_length)==0){

                            MarkerWasRead+min_buff_length;

                            pBuffer+=min_buff_length;

                            dwBufferSize-=min_buff_length;

                      }else

                            MarkerWasRead=0;

                  }

                  if(MarkerWasRead==MARKER_SIZE){

                        if(BytesInControlBuffer<2){

                              min_buff_length=min(dwBufferSize,
2-BytesInControlBuffer);

                              memcpy(ControlBuffer+BytesInControlBuffer,
pBuffer,min_buff_length);

                              pBuffer+min_buff_length;

                              dwBufferSize-=min_buff_length;

                              BytesInControlBuffer+=min_buff_length;

                        }

                        if(BytesInControlBuffer>1){

                              min_buff_length=min((BYTE)dwBufferSize,
ControlBuffer[1]+1);

                              memcpy(ControlBuffer+BytesInControlBuffer,
pBuffer,min_buff_length);

                              pBuffer+=min_buff_length;

                              dwBufferSize-=min_buff_length;

                              BytesInControlBuffer+=min_buff_length;

                      }

               }

        }
				
				<dp n="d513"/>
    if(BytesInConcrolBuffer>1 &amp;&amp; ControlBuffer[1]==ByceslnControlBuffer-3f&amp;&amp;U
serReadCallback!=NULL){

                  BYTE check_sum;

                  check_sum=CountCheckSumm(ControlBuffer,
BytesrnControlBuffer-1);

                  if(check_sum==ControlBuffer[BytesInControlBuffer-1]){

                        notify_params.pBuffer=ControlBuffer;

                        notify_params.dwBufferLength=BytesInControlBuffer-1;

                        notify_params.dwUserData=dwReadUserData;

                        notify_params.dwNotifyTye=CRPRO_CNTR_RECEIVED;

                        notify_params.dwFlags=pBufferHeader->dwFlags;

                        UserReadCallback(&amp;notify_params);

                  }

                  MarkerWasRead=0;

                  BytesInControlBuffer=0;

            }

            if(dwBufferSize>0){

                  if(UserReadCallback!=NULL){

                        pControlSequence=ControlSequenceSearch(pBuffer,
dwBufferSize);

                        notify_params.pBuffer=pBuffer;

                        if(pControlSequence==NULL){

                              if(pBuffer[dwBufferSize-1]==MARKER[0]){

                                    dwBufferSize--;

                                    MarkerWasRead=1;

                              }

                              notify_params.dwBufferLength=dwBufferSize;

                         }else(

       notify_params.dwBufferLength=pControlSequence-pBuffer;

                              MarkerWasRead=MARKER_SIZE;

                              dwBufferSize-=MARKER_SIZE;

                              pBuffer+=MARKER_SIZE;

                        }

                        if(notify_params.dwBufferLength>0){

                              notify_params.dwUserData=dwReadUserData;

      notify_params.dwNotifyType=CRPRO_READ_BUFFER_READY;

                              notify_params.dwFlags=pBufferHeader->dwFlags;

                              UserReadCallback(&amp;notify_params);

                              pBuffer+=notify_params.dwBufferLength;

                              dwBufferSize-=notify_params.dwBufferLength;
				
				<dp n="d514"/>
           }

    }
}
//=================================
PVOID ControlSequenceSearch(PBYTE pBuffer,DWORD dwBufferSize){

    DWORD size_to_search=dwBufferSize;

    PBYTE pBuffer_to_search=(PBYTE)pBuffer;

    PBYTE ptr;

    PBYTE pLastByte=pBuffer+dwBufferSize-1;

    while((ptr=memchr(pBuffer_to_search,MARKER[0],size_to_search))){

          if(ptr!=pLastByte&amp;&amp;ptr[1]==ID_BYTE){

                return ptr;

          }

          size_to_search-=(ptr-pBuffer_to_search+1);

          pBuffer_to_search=ptr+1;

    }

    return NULL;
//=================================
BYTE CountCheckSumm(PBYTE pBuffer,DWORD dwBufferSize){

    BYTE check_summ=0;

    unsigned int i;

    for(i=0;i<dwBufferSize;i++)

           check_summ+=pBuffer[i];

    return check_summ;
}
//=================================
CRPRO_STATUS proSetReadUserData(DWORD dwUserData){

    dwReadUserData=dwUserData;

    return STATUS_OK;
}
//=================================
				
				<dp n="d515"/>
#ifndef_CRPRO_H_
#define_CRPRO_H_
#ifdef_cplusplus
extern ″C″(
#endif //_cplusplus
#include<windows.h>
#ifdef_CRPRO_DLL_
#define CRPRO_STATUS    _decispec(dllexport)DWORD
#else
#define CRPRO_STATUS    DWORD
#endif
#define CRPRO_WRITE_BUFFER_DONE            1
#define CRPRO_READ_BUFFER_READY            2
#define CRPRO_CNTR_RECEIVED                3
#define CRPRO_WRITE_BUFFER_BREAK           4
#define CRPRO_ASYNC_ERROR                  5
#define CRPRO_WRITE_MESSAGE_DONE           6
#define CRPRO_WRITE_MESSAGE_BREAK          7
#define MARKER_SIZE
#pragma pack(1)
typedef struct_CONTROL_HEADER{

    BYTE Marker[MARKER_SIZE];

    BYTE MessageType;

    BYTE MessageSize;

    BYTE MessageFirstByte;
}  CONTROL_HEADER,*PCONTROL_HEADER;
typedef struct_NOTIFY_PARAMS(

    DWORD dwNotifyType;

    PVOID pBuffer;

    DWORD dwBufferLength;

    DWORD dwUserData;

    DWORD dwFlags;

    DWORD dwStatus;
} NOTIFY_PARAMS,*PNOTIFY_PARAMS;
typedef void(CALLBACK *NOTIFY_PROC)(PNOTIFY_PARAMS pNotifyParams);
				
				<dp n="d516"/>
CRPRO_STATUS proSystemOpen(UINT DeviceID,NOTIFY_PROC ReadCallback,
NOTIFY_PROC WriteCallback);
CRPRO_STATUS proSystemClose();
CRPRO_STATUS proSendMessage(PVOID pMessage,BYTE byMessageSize,BYTE
byMessageType);
CRPRO_STATUS proSendBuffer(PVOID pBuffer,DWORD dwBufferSize,DWORD
dwUserData,DWORD dwFlags);
CRPRO_STATUS proTransferReset(DWORD dwFlags);
CRPRO_STATUS proSetReadUserData(DWORD dwUserData);
#ifdef_cplusplus
}
#endif //_cplusplus
#endif //_CRPRO_H_
BASEIO.DLL
PC软件媒体输入输出模块
baseio.dll
//baseic.c
#define_BASEIO_DLL
#include <windows.h>
#include <stdio.h>
#include ″queue.h″
#include ″baseio.h″
#include ″..\capi\uniprt.h″
#define CHECK_TIME_SLEEP                              15
#define READ_BUFFER_SIZE                              1024
#define DRIVER_READ_BUFFER_SIZE                       16384
#define DRIVER_WRITE_BUFFER_SIZE                      16384
BOOL CommSettingsInit(HANDLE hCom);
BASEIO_CALLBACK UserReadCallback;
BASEIO_CALLBACK UserWriteCallback;
HQUEUE hWriteQueue;
HANDLE hWriteThread;
HANDLE hReadThread;
HANDLE hCom=INVALID_HANDLE_VALUE;
//=================================
DWORD WINAPI ReadThread(PVOID param){

    PBUFFER_HEADER pHeader;

    COMSTAT comstat;

    DWORD nb,was_read,dwError,mask;

    for(;;){

            ClearCommError(hCom,&amp; dwError,&amp; comstat);

            while(comstat.cbInQue==0){

                  WaitCommEvent(hCom,&amp; mask,NULL);

                  ClearCommError(hCom,&amp; dwError,&amp; comstat);

            }

            nb=comstat.cbInQue;

            Sleep(CHECK_TIME_SLEEP);

            ClearCommError(hCom,&amp; dwError,&amp; comstat);

            if(nb==comstat.cbInQue||comstat.cbInQue>=READ_BUFFER_SIZE){

                   pHeader=(PBUFFER_HEADER)GlobalAlloc(GPTR,
sizeof(BUFFER_HEADER));
				
				<dp n="d520"/>
                pHeader->pBuffer=(PVOID)GlobalAlloc(GPTR,
comstat.cbInQue);

                ReadFile(hCom,pHeader->pBuffer,comstat.cbInQue,
&amp;was_read,NULL);

                pHeader->dwBufferSize=comstat.cbInQue;

                UserReadCallback(BASEIO_READ_BUFFER_READY,pHeader);

                GlobalFree(pHeader->pBuffer);

                GlobalFree(pHeader);

         }

   }

   return 0;
}
//======================================
DWORD WINAPI WriteThread(PVOID param){

    PBUFFER_HEADER pHeader;

    DWORD written;

    DWORD dwNotifyType;

    for(;;){

            QueueWaitWhileEmpty(hWriteQueue,INFINITE);

            pHeader=(PBUFFER_HEADER)QueuePop(hWriteQueue);

            if(pHeader->dwBufferSize!=0){

                  GetOverlappedResult(hCom,&amp; pHeader->overlapped,&amp; written,
TRUE);

                  dwNotifyType=(written==0?
BASEIO_WRITE_BREAK:BASEIO_WRITE_BUFFER_DONE);

            } else

                  dwNotifyType=BASEIO_WRITE_BUFFER_DONE;

            UserWriteCallback(dwNotifyType,pHeader);

            CloseHandle(pHeader->overlapped.hEvent);

            GlobalFree(pHeader);

      }

      return 0;
//======================================
BAIO_STATUS bioMediaConnect(DWORD dwDeviceID,NASEIO_CALLBACK ReadCallback,
BASEIO_CALLBACK WriteCallback){

    DWORD dwThreadID;

    char szPort[16];
				
				<dp n="d521"/>
    sprintf(szPort,″%sid″,″COM″,dwDeviceID);

    hCom=CreateFile(szPort,GENERIC_READ|GENERIC_WRITE,0,NULL,
OPEN_EXISTING,FILE_ATTREBUTE_NORMAL(FILE_FLAG_OVERLAPPED,NULL);

    if(hCom==INVALID_HANDLE_VALUE)

          return BASEIO_ERR_MEDIA_CONNECT;

    UserReadCallback=ReadCallback;

    UserWriteCallback=WriteCallback;

    if(!CommSettingsInit(hCom)){

          CloseHandle(hCom);

          hCom=INVALID_HANDLE_VALUE;

          return BASEIO_ERR_MEDIA_SETUP;

    }

    hWriteQueue=QueueCreate();

    hReadThread=CreateThread(NULL,0,ReadThread,0,0,&amp; dwThreadID);

    SetThreadPriority(hReadThread,THREAD_PRIORITY_HIGHEST);

    hWriteThread=CreateThread(NULL,0,WriteThread,0,0,&amp; dwThreadID);

    SetThreadPriority(hWriteThread,THREAD_PRIORITY_HIGHEST);

    return STATUS_OK;
}
//======================================
BASIO_STATUS bioMediaDisconnect(){

    if(hCom=INVALID_HANDLE_VALUE)

          return BASEIO_ERR_NOT_CONNECTED;

    bioTransferReset(BASEIO_READ_QUEUE|BASEIO_WRITE_QUERE);

    TerminateThread(hReadThread,0);

    CloseHandle(hReadThread);

    TerminateThread(hWriteThread,0);

    CloseHandle(hWriteThread);

    QueueDestroy(hWriteQueue);

    CloseHandle(hCom);
				
				<dp n="d522"/>
           hCom = INVALID_HANDLE_VALUE;

           return STATUS OK;
}
//======================================
BASIO_STATUS bioAddOutBuffer(PVOID pBuffer,DWORD dwBufferSize,DWORD
dwUser,DWORD dwFlags){

    PBUFFER_HEADER pHeader;

    DWORD written;

    if(hCom==INVALID_HANDLE_VALUE)

          return BASEIO_ERR_NOT_CONNECTED;

    pHeader=(PBUFFER_HEADER)GlobalAlloc(GPTR,sizeof(BUFFER_HEADER));

    pHeader->pBuffer=puffer;

    pHeader->dwUser=dwUser;

    pHeader->dwBufferSize=dwBufferSize;

    pHeader->dwFlags=dwFlags;

    if(dwBufferSize!=0){

          pHeader->overlapped.hEvent=CreateEvent(NULL,FALSE,FALSE,
NULL);

          WriteFile(hCom,pHeader->pBuffer,pHeader->dwBufferSize,
&amp;written,&amp; pHeader->overlapped);

    }

    QueuePush(hWriteQueue,pHeader);

    return STATUS_OK;
//======================================
BASIO_STATUS bioTransferReset(DWORD dwFlags){

    DWORD num_elem;

    if(hCom=INVAIID_HANDLE_VALUE)

          return BASEIO_ERR_NOT_CONNECTED;

    if(dwFlags &amp; BASEIO_WRITE_QUEUE){

          num_elem=hWriteQueue->size;
				
				<dp n="d523"/>
          PurgeComm(hCom,PURGE_TXABORT);

          while (QueueWaitWhileEmpty(hWriteQueue,0)==WAIT_OBJECT_0);

          PurgeComm(hCom,PURGE_TXCLEAR);

    }

    if(dwFlags &amp; BASEIO_READ_QUEUE)

          PurgeComm(hCom,PURGE_RXABORT|PURGE_RXCLEAR);

    return STATUS_OK;
}
//======================================
BOOL CommSettingsInit(HANDLE hCom){

    DCB dcb;

    dcb.DCBlength=sizeof(DCB);

    GetCommState(hCom,&amp; dcb;

    dcb.BaudRate=CBR_115200;

    dcb.fBinary=TRUE;

    dcb.fParity=TRUE;

    dcb.fOutxCtsFlow=TRUE;

    dcb.fOutxDsrFlow=FALSE;

    dcb.fDtrControl=DTR_CONTROL_DISABLE;

    dcb.fDsrSensitivity=FALSE;

    dcb.fOutX=FALSE;

    dcb.fInX=FALSE;

    dcb.fNull=FALSE;

    dcb.fRtsControl=RTS_CONTROL_HANDSHAKE;

    dcb.ByteSize=8;

    dcb.Parity=NOPARITY;

    dcb.StopBits=ONESTOPBIT;

    dcb.XonChar=0;

    dcb.XoffChar=0;

    dcb.XonLim=0;

    dcb.XoffLim=0;

      dcb.EvtChar=0;

      if(!SetCommState(hCom,&amp; dcb))

             return FALSE;

      SetCommMask(hCom,EV_RXCHAR);
				
				<dp n="d524"/>
    PurqeComm(hCom,pURGE_TXABORT|PURGE_RXABORT|PURGE_TXCLEAR|
PURGE_RXCLEAR);

    if(!SetupComm(hCom,DRIVER_READ_BUFFER_SIZE,
DRIVER_WRITE_BUFFER_SIZE))

          return FALSE;

    return TRUE;
}
//======================================
				
				<dp n="d525"/>
//Queue.c
#include ″queue.h″
//Queue implementation
//======================================
HQUEUE QueueCreate(){

    HQUEUE hQueue;

    hQueue=(HQUEUE)GlobalAlloc(GPTR,sizeof(QUEUE));

    if(hQueue==NULL)

          return NULL;

    hQueue->size=0;

    hQueue->first=NULL;

    hQueue->hNotEmpty=CreateEvent(NULL,TRUE,FALSE,NULL);

    InitializeCriticalSection(&amp;hQueue->crit_section);

    return hQueue;
}
//======================================
BOOL QueuePush(HQUEUE hQueue,PVOID data){

    PQUEUE_NODE pNew_node;

    EnterCriticalSection(&amp;hQueue->crit_section);

    pNew_node=(PQUEUE_NODE)GlobalAlloc(GPTR,sizeof(QUEUE_NODE));

    if(pNew_node==NULL)

          return FALSE;

    pNew_node->data=data;

    pNew_node->next=NULL;

    if(hQueue->first==NULL)

          hQueue->first=pNew_node;

    else

          hQueue->last->next=pNew_node;

    hqueue->last=pNew_node;

    hQueue->size++;

    SetEvent(hQueue->hNotEmpty);

    LeaveCriticalSection(&amp; hQueue->crit_section);
				
				<dp n="d526"/>
    return TRUE;
}
//======================================
PVOID QueuePop(HQUEUE hQueue){

    PQUEUE_NODE next;

    PVOID data;

    if(hQueue->first==NULL)

          return NULL;

    EnterCriticalSection(&amp;hQueue->crit_section);

    data=hQueue->first->data;

    next=hQueue->first->next;

    GlobalFree(hQueue->first);

    hQueue->first=next;

    hQueue->size--;

    if(hQueue->size==0)

          ResetEvent(hQueue->hNotEmpty);

    LeaveCriticalSection(&amp; hQueue->crit_section);

    return data;
//======================================
void QueueReset(HQUEUE hQueue){

    while(WaitForSingleObject(hQueue->hNotEmpty,0)=WAIT_OBJECT_0)

          QueuePop(hQueue);
}
//======================================
void QueueDestroy(HQUEUE hQueue){

    QueueReset(hQueue);

    CloseHandle(hQueue->hNotEmpty);
    DeleteCriticalSection(&amp;hQueue->crit_section);

    GlobalFree(hQueue);
}
//======================================
DWORD QueueWaitWhileEmpty(HQUEUE hQueue,DWORD time_ms){
				
				<dp n="d527"/>
     return WaitForSingleObject(hQueue->hNotEmpty,time_ms);
}
//======================================
#ifndef_BASEIO_H_#define_BASEIO_H_#ifdef_cplusplusextern ″C″{#endif#define BASEIO_WRITE_BUFFER_DONE      1#define BASEIO_READ_BUFFER_READY      2#define BASEIO_WRITE_BREAK            3#define BASEIO_ASYNC_ERROR            4#ifdef_BASEIO_DLL#define BASIO_STATUS   _declspec(dllexport) DWORD#else#define BASIO_STATUS   _declspec(dllimport)DWORD#endiftypedef struct _BUFFER_HEADER(
  OVERLAPPED overlapped;
  PVID pBuffer;
  DWORD dwBufferSize;
  DWORD dwUser;
  DWORD dwFlags;
  BYTE  bySystem[3];} BUFFER_HEADER,*PBUFFER_HEADER;typedef void(CALLBACK *BASEIO_CALLBACK)(DWORD dwNotifType,PBUFFER_HEADERpBufferHeader);BASIO_STATUS bioMediaConnect(DWORD dwDeviceID,BASEIO_CALLBACK ReadCallback,BAEIO_CALLBACK WriteCallback);BASIO_STATUS bioMediaDisconnect();BASIO_STATUS bioAddOutBuffer(PVOID pBuffer,DWORD dwBufferSize,DWORDdwUser,DWORD dwFlags);BASIO STATUS bioTransferReset(DWORD dwFlags);#ifdef_cplusplus#endif#endif      //  _CRPKTDRV_H_ #ifndef_QUEUE_H_#define_QUEUE_H_#include<windows.h>typedef struct QUEUE_NODE_TAG{
  PVOID data;
  struct QUEUE_NODE_TAG* next;}QUEUE_NODE,*PQUEUE_NODE;tyPedef struct QUEUE_TAG{
  HANDLE hNotEmpty;
  DWORD size;
  PQUEUE_NODE first;
  PQUEUE_NODE last;
  CRITICAL_SECYION crit_section;}QUEUE,*QPUEUE;typedef PQUEUE HQUEUE;EQUEUE QueueCreate();BOOL QueuePush(HQUEUE hQueue,PVOID data);PVOID QueuePop(HQUEUE hQueue);void QueueReset(HQUEUE hQueue);void QueueDestroy(HQUEUE hQueue);DWORD QueueWaitWhileEmpty(HQUEUE hQueue,DWORD time_ms);#endif//_QUEUE_H_ 用于语音识别的有效源代码 // AcqPropPage.cpp:implementation file//#include ″stdafx.h″#include ″NewSR.h″#include ″AcqPropPage.h″#include ″SRCtl.h″#include <mmsystem.h>#ifdef_DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[]=_FILE_;#endif#define WORK_MODE 0#define INIT_MODE 1////////////////////////////////////////////////////////////////////////////// CAcqPropPage dialogIMPLEMENT_DYNCREATE(CAcqPropPage,COlePropertyPage)///////////////////////////////////////////////////////////////////////////////Message mapBEGIN_MESSAGE_MAP(CAcqPropPage,COlePropertyPage)
  //({AFX_MSG_MAP(CAcqPropPage)
  ON_BN_CLICKED(IDC_WAVEFORMAT,OnWaveformat)
  ON_BN_CLICKED(IDC_DEVICEID,OnDeviceid)
  ON_CBN_SELCHANGE(IDC_WAVELIST,OnSelchangeWavelist)
  ON_BN_CLICKED(IDC_REALTIME,OnRealtime)
  ON_BN_CLICKED(IDC_NONREALTIME,OnNonrealtime)
  //}}AFX_MSG_MAPEND_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// Initialite class factory and guid
//(D446B881-7537-11D0-A6CE-0040332D01CS)
IMPLEMENT_OLECREATE_EX(CAcqPropPage,″NewSR.CAcqPropPage″,

    0xd446b881,0x7537,0xl1d0,0xa6,0xce,0x0,0x40,0x33,0x2d,0x1,
0xc5)
////////////////////////////////////////////////////////////////////////////
/
//CAcqPropPage::CAcqPropPageFactory::UpdateRegistry-
//Adds or removes system registry entries for CAcqPropPage
BOOL CAcqPropPage::CAcqPropPageFactory::UpdateRegistry(BOOL bRegister)
{

    //TODO: Define string resource for page type;replace ′0′below with
ID.

   if(bRegister)

        return AfxOleRegisterPropertyPageClass(AfxGetInstanceHsndle(),

              m_clsid,IDS_SR_PPG);

   else

        return AfxOleUnregisterClass(m_clsid,NULL);
////////////////////////////////////////////////////////////////////////////
/
//CAcqPropPage::CAcqPropPsge-Constructor
//TODO:Define string resource for page caption;replace′0′below with ID.
CAcqPropage::CAcqPropPage():

    COlePropertyPage(IDD,IDS_ACQ)
{

    //{{AFX_DATA_INIT(CAcqPropPage)

    //}}AFX_DATA_INIT

    CurrWaveFormat=NULL;
}
CAcqPropPage::-CAcqPropPage(){

    if(!CurrWaveFormat)

           free(CurrWaveFormat);
}
				
				<dp n="d533"/>
////////////////////////////////////////////////////////////////////////
/
//CAcqPropPage::DoDataExchange-Moves data between page and properties
void CAcqPropPage::DoDataExchange(CDataExchange* pDX)
{

    //NOTE:ClassWizard will add DDP,DDX,and DDV calls here

    //DO NOT EDIT what you see in these blocks of generated code!
    //{{AFX_DATA_MAP(CAcqPropPage)

    DDX_Control(pDX,IDC_DESCRIPTION,m_EditDescription);
    DDP_CBIndex(pDX,IDC_WAVELIST,m_WaveIndex,″XWaveIndex″);

    DDX_CBIndex(pDX,IDC_WAVELIST,m_WaveIndex);

    DDP_Text(pDX,IDC_ACQ,m_DataBase,″DataBase″);

    DDP_CBIndex(pDX,IDC_ACQ,m_XSRTransfer,″XSRTransfer″);

    DDP_CBIndex(pDX,IDC_WAVEFORMAT,m_XAcqMode,″XAcqMode″);

    DDP_CBIndex(pDX,IDC_DEVICEID,m_XAcqMode,″XAcqMode″);

    DDP_CBIndex(pDX,IDC_REALTIME,m_XAcqMode,″XAcqMode″);

    DDP_CBIndex(pDX,IDC_NONREALTIME,m_XAcqMode,″XAcqMode″);

    DDX_Control(pDX,IDC_WAVELIST,m_WaveList);

    DDX_Control(pDX,IDC_WAVEFORMAT,m_WaveFormat);

    DDX_Control(pDX,IDC_REALTIME,m_RealTime);

    //}}AFX_DATA_MAP

    DDP_PostProcessing(pDX);
////////////////////////////////////////////////////////////////////////////
/
// CAcqPropPage message handlers
BOOL CAcqPropPage::OnInitDialog()
{

    PVOID wf;

    DWORD size;

    COlePropertyPage::OnInitDialog();

    CButton* CurrButton;

    HDB hDb;

    LPSTR Buffer;
				
				<dp n="d534"/>
HCURSOR SaveCursor;
SaveCursor=SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));
COlePropertyPage::OnInitDialog();
asrDbList(NULL,&amp; size);
Buffer=(LPSTR)malloc(size);
asrDbList(Buffer,&amp; size);
hDb=asrDbOpen(Buffer);
if(Buffer)

    free(Buffer);
asrDbGetInfo(hDb,ASRDBINFO_NBRWAVEFORMATS,NULL,&amp;size);
wf=(DWORD*)malloc(size);
asrDbGetInfo(hDb,ASRDBINFO_NBRWAVEFORMATS,wf,&amp; size);
nFormats=*((LPDWORD)wf);
free(wf);
asrDbGetInfo(hDb,ASRDBINFO_WAVEFORMATS,NULL,&amp; size);
CurrWaveFormat=(PWAVEFORMAT)malloc(size);
asrDbGetInfo(hDb,ASRDBINF0_WAVEFORMATS,CurrWaveFormat,&amp; size);
switch(m_XAcqMode){
case DISP_DEVICEID:

   CurrButton=(CButton*)GetDlgItem(IDC_DEVICEID);

   CurrButton->SetCheck(1);

   CurrButton=(CButton*)GetDlgItem(IDC_NONREALTIME);

   m_RealTime.SetCheck(1);

   FillID(INIT_MODE);

   break;
case DISP_REALTIME:

   CurrButton=(CButton*)GetDlgItem(IDC_WAVEFORMAT);

   CurrButton->SetCheck(1);

   CurrButton=(CButton*)GetDlgItem(IDC_REALTIME);

   CurrButton->SetCheck(1);

   FillWF(INIT_MODE);

   break;
case DISP_NONREALTIME:

   CurrButton=(CButton*)GetDlgItem(IDC_WAVEFORMAT);

   CurrButton->SetCheck(1);

   CurrButton=(CButton*)GetDlgItem(IDC_NONREALTIME);

   CurrButton->SetCheck(1);

   FillWF(INIT_MODE);

   break;
case DISP_WAVEFORMAT:

   MessageBox(″Not implemented″);
}
				
				<dp n="d535"/>
    if(hDb>ASRERR_MAXERR)

          asrDbClose(hDb);

    SetCursor(SaveCursor);

    return FALSE;
}
void CAcqPropPage::CheckAcqGroup(BOOL Enable=TRUE)
{

    CStatic* m_Static;

    CButton* m_Button;

    m_Button=(CButton*)GetDlgItem(IDC_NONREALTIME);

    m_Static=(CStatic*)GetDlgItem(IDC_ACQ);

    m_RealTime.EnableWindow(Enable);

    m_Static->EnableWindow(Enable);

    m_Button->EnableWindow(Enable);
void CAcqPropPage::FillDescription(FillType ftype,WORD wWhat)
{

    WAVEINCAPS wavecaps;

    CString m_Description;

    if(ftype==FILL_BYDEVICEID){

          waveInGetDevCaps(wWhat,&amp; wavecaps,sizeof(wavecaps));

          m_Description. Format(″Manufacturer identifier:%d\r\n\
Product identifier:%d\r\nProduct name:%s\r\n%s\r\nFormats that are
supported:″,

          wavecaps.wMid,wavecaps.wPid,wavecaps.szPname,

          wavecaps.wChannels==1?″Mono″:″Stereo″);

          if(wavecaps.dwFormats &amp; WAVE_FORMAT_1M08)

                m_Description+=″\r\n11.025kHz,mono,8-bit″;
          if(wavecaps.dwFormats&amp;WAVE_FORMAT_1M16)

                m_Description+=″\r\n11.025kHz,mono,16-bit″;

          if(wavecaps.dwFormats&amp;WAVE_FORMAT_1S08)

                m_0escription+=″\r\n11.025kHz,stereo,8-bit″;

          if(wavecaps.dwFormats&amp;WAVE_FORMAT_1S16)

                m_Description+=″\r\n11.025kHz,stereo,16-bit″;

          if(wavecaps.dwFormats &amp; WAVE_FORMAT_2M08)

                m_Description+=″\r\n22.05kHz,mono,8-bit″;

          if(wavecaps.dwFormats &amp; WAVE_FORMAT_2M16)

                m_Description+=″\r\n22.05kHz,mono,16-bit″;

          if(wavecaps.dwFormats&amp;WAVE_FORMAT_2S08)

                m_Description+=″\r\n22.05kHz,stereo,8-bit″;
				
				<dp n="d536"/>
          if(wavecaps.dwFormats &amp; WAVE_FORMAT_2S16)

                m_Description+=″\r\n22.05kHz,stereo,16-bit″;

          if(wavecaps.dwFormats &amp; WAVE_FORMAT_4M08)

                m_Description+=″\r\n44.1kHz,mono,8-bit″;

          if(wavecaps.dwFormats &amp; WAVE_FORMAT_4M16)

                m_Description+=″\r\n44.1kHz,mono,16-bit″;

          if(wavecaps.dwFormats &amp; WAVE_FORMAT_4S08)

                m _Description+=″\r\n44.1kHz,stereo,8-bit″;

          if(wavecaps.dwFormats &amp; WAVE_FORMAT_4S16)

                m_DescriPtion+=″\r\n44.1kHz,stereo,16-bit″;

          m_EditDescription. SetWindowText(m_Description);

     }

     else

          m_Description.Format″Format type %d\nNumber of channels
%d\r\n\
Sample rate %d\r\nData transfer rate %d\r\nBlock alignment %d″,

          CurrWaveFormat[wWhat].wFormatTag,

          CurrWaveFormat[wWhat].nChannels,

          CurrWaveFormat[wWhat].nSamplesPerSec,

          CurrWaveFormat[wWhat].nAvgBytesPerSec,

          CurrWaveFormat[wWhat].nBlockAlign);

          m_EditDescription.SetWindowText(m_Description);

    }
}
void CAcqPropPage::OnSelchangeWavelist()
{

    FillDescription(M_WaveFormat.GetCheck()?FILL_BYNBRWAVEFORMAT:FILL_BYDE
VICEID,m_WaveList. GetCurSel());
}
void CAcqPropPage::OnRealtime()
{

    SaveAcqMode();
}
void CAcqPropPage::OnNonrealtime()
{

    SaveAcqMode();
}
void CAcqPropPage::OnDeviceid()
				
				<dp n="d537"/>
    SaveAcqMode();

    FillID(WORK_MODE);
void CAcqPropPage::OnWaveformat()
{

    SaveAcqMode();

    FillWF(WORK_MODE);
}
void CAcqPropPage::SaveAcqMode()
{

    CButton* CurrentButton;

    CurrentButton=(CButton*)GetDlgItem(IDC_DEVICEID);

    if(CurrentButton->GetCheck()){

          m_XAcqMode=DISP_DEVICEID;
          return;

    }

   if(m_RealTime.GetCheck()){

          m_XAcqMode=DISP_REALTIME;

          return;

    }

    m_XAcqMode=DISP_NONREALTIME;
void CAcqPropPage::FillWF(int mode){

    CString tmp;

    CheckAcqGroup(TRUE);

    m_WaveList.ResetContent();

    for(DWORD i=0;i<nFormats;i++){

          tmp.Format(″%s%d″,″Wave format #″,i);

          m_WaveList.InsertString(-1,tmp);

    }

    if(mode==WORK_MODE)

          m_WaveList.SetCurSel(0);

    else

          m_WaveList.SetCurSel(m_WaveIndex);

    FillDescription(FILL_BYNBRWAVEFORMAT,m_WaveList.GetCurSel());
}
void CAcqPropPage::FillID(int mode){
				
				<dp n="d538"/>
UINT NumDevs;
CString InsertString;
CheckAcqGroup(FALSE);
NumDevs=waveInGetNumDevs();
m_WaveList.ResetContent();
for(UINT i=0;i<NumDevs;i++){

        InsertString.Format(″%s %d″,″Device ID:″,i);

        m_WaveList.InsertString(-1,InsertString);
}
if(mode==WORK_MODE)

        m_WaveList.SetCurSel(0);
else

        m_WaveList.SetCurSel(m_WaveIndex);
FillDescription(FILL_BYDEVICEID,m_WaveList.GetCurSel());
}
				
				<dp n="d539"/>
//NewSR.cpp:Implementation of CNewSRApp and DLL registration.
#include ″stdafx.h″
#include ″NewSR.h″
#ifdef_DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[]=_FILE_;
#endif
CNewSRApp NEAR theApp;
const GUID CDECL BASED_CODE_tlid=

          {0x528c0220,0x72ec,0x11d0,(0xa6,0xce,0,0x40,0x33,0x2d,
0x1,0xc5)};
const WORD_wVerMajor=1;
const WORD_wVerMinor=0;
////////////////////////////////////////////////////////////////////////////
// CNewSRApp::InitInstance-DLL initialization
BOOL CNewSRApp::InitInstance()
{

    BOOL bInit=COleControlModule::InitInstance();

    if(bInit)
    {

              SRIcon=LoadIcon(IDI_SRICON);

    }

    return bInit;
}
////////////////////////////////////////////////////////////////////////////
// CNewSRApp::ExitInstance-DLL termination
int CNewSRApp::ExitInstance()
{

     // TODO:Add your own module termination code here.
				
				<dp n="d540"/>
    return COleControiModule::ExitInstance();
////////////////////////////////////////////////////////////////////////////
/
//DllRegisterServer-Adds entries to the system registry
STDAPI DllRegisterServer(void)
{

    AFX_MANAGE_STATE(_afxModuleAddrThis);

    if(!AfxOleRegisterTypeLib(AfxGetInstanceHandle(),_tlid))

          return ResultFromScode(SELFREG_E_TYPELIB);

    if(!COleObjectFactoryEx::UpdateRegistryAll(TRUE))

          return ResultFromScode(SELFREG_E_CLASS);

    return NOERROR;
}
////////////////////////////////////////////////////////////////////////////
/
//DllUnregisterServer-Removes entries from the system registry
STDAPI DllUnregisterServer(void)
{

    AFX_MANAGE_STATE(_afxModuleAddrThis);

    if(!AfxOleUnregisterTvpeLib(_tlid))

          return ResultFromScode(SELFREG_E_TYPELIB);

    if(!COleObjectFactoryEx::UpdateRegistryAll(FALSE))

          return ResultFromScode(SELFREG_E_CLASS);

    return NOERROR;
}
				
				<dp n="d541"/>
;NewSR.def:Declares the module parameters.
LIBRARY    ″NEWSR.OCX″
EXPORTS

    DllCanUnloadNow      @1 PRIVATE

    DllGetClassObject    @2 PRIVATE

    DllRegisterServer    @3 PRIVATE

    DllUnregisterServer  @4 PRIVATE
				
				<dp n="d542"/>
//NewSR.odl:tvpe library source for OLE Control project.
//This file will be processed by the Make Type Library(mktyplib)tool to
//produce the type library(NewSR.tlb)that will become a resource in
//NewSR.ocx.
#include <olectl.h>
[uuid(528C0220-72EC-11D0-A6CE-0040332D01C5),version(1.0),
helpstring(″NewSR OLE Control module″),control]
library NEWSRLib
{

    importlib(STDOLE_TLB);

    importlib(STDTYPE_TLB);

    //Primary dispatch interface for CSRCtrl

    [uuid(528C0221-72EC-11D0-A6CE-0040332D01CS),

     helpstring(″Dispatch interface for SR Control″),hidden]

    dispinterface_DSR

    {

         properties:

               //NOTE-ClassWizard will maintain property information
here.

               //Use extreme caution when editing this section.

               //{{AFX_ODL_PROP(CSRCtrl)

               [id(l)] BSTR DataBase;

               [id(2)] BSTR User;

               [id(3)] BSTR Context;

               [id(4)] short Mode;

               [id(5)] short OpenAttr;

               [id(8)] boolean SaveCtx;

               //}}AFX_ODL_PROP

         methods:

               //NOTE-ClassWizard will maintain method information
here.

               //   Use extreme caution when editing this section.

               //{{AFX_ODL_METHOD(CSRCtrl)

               [id(10)] void ShowProperties();

               [id(11)] long RecAcqWaveBuffer(BSTR lpBuffer,long
dwLength);

               [id(12)]long RecGetState();
				
				<dp n="d543"/>
                 [id(13)) BSTR GetWords(short Type,BSTR Class);

                 [id(14)] long ActivateWords(short Type,BSTR Class,BSTR
Words);

                 [id(15)] BSTR GetActiveWords();

                 [id(16)] long Init();

                 [id(17)] long Start();

                 [id(18)] long Stop();

                 [id(19)] long Close();

                 [id(20)] long GetParam(long ParamType);

                 [id(21)] long SetParam(long ParamType,long NewValue);

                 [id(22)] long AddUserWord(BSTR Class,BSTR Word);

                 [id(23)] long CtxActivate(boolean Activate);

                 [id(24)] long DictClose(boolean SaveChanges);

                 [id(25)] long DictCopy(BSTR Language,BSTR DictSrc,BSTR
DictDest);

                 [id(26)] long DictCreate(BSTR Language,BSTR Dictionary);

                 [id(27)] long DictDelete(BSTR Language,BSTR Dictionsry);

                 [id(28)] long DictDeleteException(BSTR Word);

                 [id(29)] VARIANT DictGetInfo(short Type);

                 [id(30)] BSTR DictGetTranscription(BSTR Word);

                 [id(31)] long DictOpen(BSTR Language,BSTR Dictionary,
short Attrib);

                 [id(32)] long DictRename(BSTR Language,BSTR DictSrc,BSTR
DictDest);

                 [id(33)] long DbClose();

                 [id(34)] long DbCreate(BSTR DbName,BSTR Path);

                 [id(35)] long DbDelete(BSTR DbName);

                 [id(36)) long DbFxport(short Type,BSTR LangOrUser,BSTR
Name,BSTR Path);

                 [id(37)] VARIANT DbGetCaps(BSTR Environment,long Type);

                 [id(38)] VARIANT DbGetInfo(short Type);

                 [id(39)] long DbGetParamInfo();

                 [id(40)] long DbInstall(BSTR SetupFile,long hWnd);

                 [id(41)] BSTR DbList();

                 [id(42)] long DbOpen(BSTR DbName);

                 [id(43)] long DbUnInstall(short Type,BSTR ObjectName);

                 [id(44)] long RecAcqClose();

                 [id(45)] short RecAcqGetSignalLevel();

                 [id(46)] long RecAcqOpenEx(short WaveFormIndex,short
Type);

                 [id(47)) long RecBreak();

                 [id(48)] long RecClose();

                 [id(49)] long RecSetMode(short NewMode);
				
				<dp n="d544"/>
                [id(50)] long UsrCopy(BSTR UserSrc,BSTR UserDest);

                [id(51)] long UsrEnable(BSTR UserName,BSTR Language,
short Type);

                [id(52)] long UsrCreate(BSTR UserName);

                [id(53)] long UsrDelete(BSTR UserName);

                [id(54)] VARIANT UsrGetInfo(BSTR UserName,short Type);

                [id(55)] long UsrIndependent(BSTR UserName,BSTR
Language);

                [id(56)] long UsrRegister(BSTR User,short Type,BSTR
Name);

                [id(57)] long UsrRename(BSTR OldName,BSTR NewName);

                [id(S8)] long UsrUnregister(BSTR User,short Type,BSTR
Name);

                [id(59)] long CtxClose(boolean Save);

                [id(60)] long CtxCopy(BSTR SrcUser,BSTR SrcContext,BSTR
DestUser,BSTR DestContext);

                [id(61)] long CtxCreate(BSTR User,BSTR Language,BSTR
Syntax,BSTR Context);

                [id(62)] long CtxDelete(BSTR User,BSTR Context);

                [id(63)] long CtxDeleteWord(BSTR Class,BSTR Word);

                [id(64)] long CtxExport(BSTR User,BSTR Format,BSTR
Context);

                [id(65)] long CtxOpen(BSTR User,BSTR Context,short
Attrrib);

                [id(66)] long CtxRename(BSTR User,BSTR OldCtx,BSTR
NewCtx);

                [id(67)] long WaitForEvent(BSTR Map,short time_100ms,
long dwFlags);

                [id(68)] short GetNbrPhrases();

                [id(69)] BSTR GetPhrase(short PhraseNbr);

                [id(70)] short GetPhraseConfLevel(short PhraseNbr);

                //}}AFX_ODL_METHOD

                [id(DISPID_ABOUTBOX)] void AboutBox();

   };

   //  Event dispatch intefface for CSRCtrl

   [uuid(528C0222-72EC-11D0-A6CE-0040332D01C5),

    helpstring(″Event interface for SR Control″)]

   dispinterface_DSREvents

   {

        properties:
				
				<dp n="d545"/>
                  //Event interface has no properties

           methods:

                  //NOTE-ClassWizard will maintain event information
here.

                  //Use excreme oaution when editing this section.

                  //{{AFX_ODL_EVENT(CSRCtrl)

                  [id(1)]void Result(BSTR BestUtterance,short
BestConfidence,short nbrUtterances);
                  [id(2)] void RecError(long id,BSTR ErrorString);

                  [id(3)] void ChangeState(short NewState);

                  //}}AFX_ODL_EVENT
    };

    //Class information for CSRCtrl

    [uuid(528C0223-72EC-11D0-A6CE-0040332D01C5),

     helpstring(″Speech recognition OLE Control″),control]

    coclass SR

    {

          [default]dispinterface_DSR;

          [default,source].dispinterface_DSREvents;

    };

    //{{AFX_APPEND_ODL)}
};
				
				<dp n="d546"/>
//Microsoft Developer Studio generated resource script.
//
#include ″resource.h″
#define APSTUDIO_READONLY_SYMBOLS
///////////////////////////////////////////////////////////////////////////
/
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include ″afxres.h″
////////////////////////////////////////////////////////////////////////////
/
#undef APSTUDIC_READONLY_SYMBOLS
////////////////////////////////////////////////////////////////////////////
/
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL)||defined(AFX_TARG__ENU)
#ifdef_WIN32
LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif//_WIN32
#ifdef APSTUDIO_INVOKED
///////////////////////////////////////////////////////////////////////////
/
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN

  ″resource.h\0″
END
2 TEXTINCLUDE DISCARDABLE
BEGIN

  ″#include″″afxres.h″″\r\n″

  ″\0″
END
				
				<dp n="d547"/>
3 TEXTINCLUDE DISCARDABLE
BEGIN

  ″1 TYPELIB″″NewSR.tlb″″\r\n″

  ″\0″
END
#endif  // APSTUDIO_INVOKED
#ifndef_MAC
////////////////////////////////////////////////////////////////////////////
/
//
// Version
//
VS_VERSION_INFO VERSIONINFO
 FILEVERSION 1,0,0,1
 PRODUCTVERSION 1,0,0,1
 FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x4L
 FILETYPE 0x2L
 FILESUBTYPE 0x0L
BEGIN

  BLOCK″StringFileInfo″

  BEGIN

      BLOCK″040904B0″

      BEGIN

          VALUE″CompanyName″,″\0″

          VALUE″FileDescription″,″NewSR OLE Control Module\0″

          VALUE″FileVersion″,″1,0,0,1\0″

          VALUE″InternalName″,″NEWSR\0″

          VALUE″LegalCopyright″,″Copyright  1997\0″

          VALUE″LegalTrademarks″,″\0″

          VALUE″OriginalFilename″,″NEWSR.OCX\0″

          VALUE″ProductName″,″NewSR OLE Control Module\0″
				
				<dp n="d548"/>
          VALUE″ProductVersion″,″1,0,0,1\0″

      END

  END

  BLOCK″VarFileInfo″

  BEGIN

      VALUE″Translation″,0x409,1200

  FND
END
#endif    // !_MAC
////////////////////////////////////////////////////////////////////////////
/
//
//Icon
//
//Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ABOUTDLL            ICON    DISCARDABLE   ″SpRec.ico″
IDI_SRICON              ICON    DISCARDABLE   ″iconl.ico″
////////////////////////////////////////////////////////////////////////////
/
//
//Bitmap
//
IDB_SR                  BITMAP  DISCARDABLE   ″SpRecCtl.bmp″
////////////////////////////////////////////////////////////////////////////
/
//
//Dialog
//
IDD_ABOUTBOX_SR_DIALOG DISCARDABLE 34,22,260,55
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION ″About SpRec Control″
FONT 8, ″MS Sans Serif″
BEGIN

  ICON              IDI_ABOUTDLL,IDC_STATIC,10,10,18,20
				
				<dp n="d549"/>
     LTEXT             ″Speech Recognition OLE Control, Version
1.0″,IDC_STATIC,

                       40,10,170,8

    LTEXT              ″Copyright  1997,Creator,
Israel″,IDC_STATIC,40,25,170,

                       8

    DEFPUSHBUTTON ″OK″,IDOK,221,7,32,14,WS_GROUP
END
IDD_PARAMINFO DIALOG DISCARDABLE 0,0,250,110
STYLE WS_CHILD
FONT 8,″MS Sans Serif″
BEGIN

    LISTBOX          IDC_LIST1,13,8,120,63,LBS_NOINTEGRALHEIGHT | WS_VSCROLL

                     WS_TABSTOP

    LTEXT            ″″IDC_DESCRIPTION,12,96,237,10

    LTEXT            ″″IDC_MIN,15,73,20,8

    LTEXT            ″″IDC_MAX,101,73,19,8

    LTEXT            ″″IDC_CURRENT,79,73,20,8
    CONTROL          ″″Sliderl″,IDC_SLIDER1,″msctls_trackbar32″,TBS_BOTH

                     TBS_NOTICKS | WS_TABSTOP,12,83,102,9

    PUSHBUTTON       ″″,IDC_DEFAULTVALUE,115,82,21,13

    LTEXT            ″Current value″,IDC_TRANSFER,37,73,39,8
END
IDD_PROPPAGE_SR DIALOG DISCARDABLE 0,0,250,110
STYLE WS_CHILD
FONT 8,″MS Sans Serif″
BEGIN

    COMBOBOX         IDC_DATABASE,7,18,77,85,CBS_DROPDOWNLIST | WS_VSCROLL |

                     WS_TABSTOP

    LTEXT            ″Data base″,IDC_TRANSFER2,26,7,35,9

    COMBOBOX         IDC_USER,86,18,77,85,CBS_DROPDOWNLIST | WS_VSCROLL |

                     WS_TABSTOP

    LTEXT            ″User″,IDC_TRANSFER2,113,7,18,9

    COMBOBOX         IDC_CONTEXT,165,18,77,85,CBS_DROPDOWNLIST | WS_VSCROLL |

                     WS_TABSTOP

    LTEXT            ″Context″,IDC_TRANSFER2,188,7,25,9

    COMBOBOX         IDC_MODES,7,48,80,85,CBS_DROPDOWNLIST | WS_VSCROLL |

                     WS_TABSTOP

    LTEXT            ″Recognition open mode″,IDC_TRANSFER2,7,36,78,9
				
				<dp n="d550"/>
    COMBOBOX         IDC_ATTRIB,89,48,74,85,CBS_DROPDOWNLIST | WS_VSCROLL |

                     WS_TABSTOP

    LTEXT            ″Context access attribute″,IDC_TRANSFER2,89,36, 82,9
END
IDD_ACQPROPPAGE DIALOG DISCARDABLE 0,0,250,110
STYLE WS_CHILD
FONT 8,″MS Sans Serif″
BEGIN

    GROUPBOX         ″Acquisition channel open mode″,IDC_WAVEDEV,7,7,124,96

    CONTROL          ″WAVE format″,IDC_WAVEFORMAT,″Button″,BS_AUTORADIOBUTTON

                     WS_GROUP,12,17,51,11

    CONTROL          ″Device ID″,IDC_DEVICEID,″Button″,BS_AUTORADIOBUTTON,68,

                     17,41,11

    COMBOBOX         IDC_WAVELIST,11,30,117,73,CBS_DROPDOWNLIST | WS_VSCROLL

                     WS_GROUP

    GROUPBOX         ″Type of acquisition″,IDC_ACQ,133,7,110,22,WS_DISABLED

    CONTROL          ″Real time″,IDC_REALTIME,″Button″,BS_AUTORADIOBUTTON |

                     WS_DISABLED | WS_GROUP,136,17,40,11

  CONTROL          ″Not real time″,IDC_NONREALTIME,″Button″,

                   BS_AUTORADIOBUTTON | WS_DISABLED,191,17,48,11

  EDITTEXT         IDC_DESCRIPTION,11,47,117,53,ES_MULTILINE |

                  ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY |

                   WS_VSCROLL
END
////////////////////////////////////////////////////////////////////////////
/
//
// DESIGNINFO
//
#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO DISCARDABLE
BEGIN

  IDD_ABOUTBOX_SR,DIALOG

  BEGIN

      LEFTMARGIN,7

      RIGHTMARGIN,253

      TOPMARGIN,7
				
				<dp n="d551"/>
      BOTTOMMARGIN,48

  END

  IDD_PARAMINFO,DIALOG

  BEGIN

      RIGHTMARGIN,249

      TOPMARGIN,1

      BOTTOMMARGIN,108

  END

  IDD_PROPPAGE_SR,DIALOG

  BEGIN

      LEFTMARGIN,7

      RIGHTMARGIN,243

      TOPMARGIN,7

      BOTTOMMARGIN,103

  END

  IDD_ACQPROPPAGE,DIALOG

  BEGIN

      LEFTMARGIN,7

      RIGHTMARGIN,243

      TOPMARGIN,7

      BOTTOMMARGIN,103

  END
END
#endif    // APSTUDIO_INVOKED
////////////////////////////////////////////////////////////////////////////
/
//
// String Table
//
STRINGTABLE DISCARDABLE
BEGIN

  IDS_SR                ″SR Control″

  IDS_SR_PPG            ″SR Property Page″
END
STRINGTABLE DISCARDABLE
BEGIN
				
				<dp n="d552"/>
  IDS_SR_PPG_CAPTION       ″General″

  IDS_PARAM_CAPTION        ″Parameters″

  IDS_ACQ                  ″Acquisition channel″
END
#endif     // English (U.S.)  resources
////////////////////////////////////////////////////////////////////////////
/
#ifndef APSTUDIO_INVOKED
////////////////////////////////////////////////////////////////////////////
/
//
// Generated from the TEXTINCLUDE 3 resource.
//
1 TYPELIB ″NewSR.tlb″
////////////////////////////////////////////////////////////////////////////
/
#endif     // not APSTUDIO_INVOKED
				
				<dp n="d553"/>
// PrmPrpPg.cpp :impiementation file
//
#include ″stdafx.h″
#include ″NewSR.h″
#include ″PrmPrpPg.h″
#include ″SRCtl.h″
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[]=_FILE_;
#endif
////////////////////////////////////////////////////////////////////////////
/
// CPrmPrpPg dialog
IMPLEMET_DYNCREATE(CPrmPrpPg,COlePropertyPage)
////////////////////////////////////////////////////////////////////////////
/
// Message map
BEGIN_MESSAGE_MAP(CPrmPrpPg,COlePropertyPage)

    //{{AFX_MSG_MAP(CPrmPrpPg)

    ON_LBN_SELCHANGE(IDC_LIST1,OnSelchangeListl)

    ON_WM_HSCROLL()

    ON_BN_CLICKED(IDC_DEFAULTVALUE,OnDefaultvalue)

    //}}AFX_MSG_MAP
END_MESSAGE_MAP()
////////////////////////////////////////////////////////////////////////////
/
// Initialize class factory and guid
// (528C0229-72EC-11D0-A6CE-0040332D01C5)
IMPLEMENT_OLECREATE_EX(CPrmPrpPg,″NewSR.CPrmPrpPg″,

    0x528c0229,0x72ec,0x11d0,0xa6,0xce,0x0,0x40,0x33,0x2d,0x1,
0xc5)
				
				<dp n="d554"/>
////////////////////////////////////////////////////////////////////////////
/
// CPrmPrpPg::CPrmPrpPgFactory::UpdateRegistry-
// Adds or removes system registry entries for CPrmPrpPg
BOOL CPrmPrpPg::CPrmPrpPgFactory::UpdateRegistry(BOOL bRegister)
{

    // TODO:Define string resource for page type;replace′0′below with
ID.

   if(bRegister)

         return AfxOleRegisterPropertyPageClass(AfxGetInstanceHandle(),

               m_clsid,IDS_SR_PPG);

   else

         return AfxOleUnregisterClass(m_clsid,NULL);
////////////////////////////////////////////////////////////////////////////
/
// CPrmPrpPg::CPrmPrpPg-Constructor
// TOPO:Define string resource for page caption;replace′0′below with ID.
CPrmPrpPg::CPrmPrpPg():

     COlePropertyPage(IDD,IDS_PARAM_CAPTION)
{

     //{{AFX_DATA_INIT(CPrmPrpPg)

     //)}AFX_DATA_INIT

     ParamInfc=NULL;
}
CPrmPrpPg::-CPrmPrpPg(){

     if(ParamInfo)

           free(ParamIfo);
}
////////////////////////////////////////////////////////////////////////////
/
// CPrmPrpPg::DoDataExchange-Moves data between page and properties
				
				<dp n="d555"/>
void CPrmPrpPg::DoDataExchange(CDataExchange* pDX)
{

    // NOTE:ClassWizard will add DDP,DDX,and DDV calls here

    //    DO NOT EDIT what you see in these blocks of generated code !

    //[{AFX_DATA_MAP(CPrmPrpPg)

    DDX_Control(pDX,IDC_DEFAULTVALUE,m_SetDef);

    DDX_Control(pDX,IDC_SLIDER1,m_Slider);

    DDX_Control(pDX,IDC_CURRENT,m_CurrentValue);

    DDX_Control(pDX,IDC_MIN,m_Min);

    DDX_Control(pDX,IDC_MAX,m_Max);

    DDX_Control(pDX,IDC_DESCRIPTION,m_Description);

    DDX_Control(pDX,IDC_LIST1,m_Params);

    DDP_CBIndex(pDX,IDC_TRANSFER,m_Control,″Control″);

    //}}AFX_DATA_MAP

    DDP_PostProcessing(pDX);
BOOL CPrmPrpPg::OnInitDialog()
{

    DWORD size;

    LPSTR Buffer;

    HCURSOR SaveCursor;

    SaveCursor=SetCursor(AfxGet-App()->LoadStandardCursor(IDC_WAIT));

    COlePropertyPage::OnInitDialog();

    HDB hDb;

    HASR hAsr;
    asrDbList(NULL,&amp; size);

    Buffer=(LPSTR)malloc(size);

    asrDbList(Buffer,&amp; size);

    hDb=asrDbOpen(Buffer);

    if(Buffer)

           free(Buffer);

    hAsr=asrRecOpen(hDb,″Win32″,NULL,NULL,NULL);
    ASRERROR err=asrRecGetParamInfo(hAsr,NULL,&amp; size);

    ParamInfo=(PPARAMINFOLIST)malloc(size);

    err=asrRecGetParamInfo(hAsr,ParamInfo,&amp; size);

    for(int i=0;i<ParamInfo->nbrOfParams;i++){

          m_Params.InsertString(-1,(ParamInfo->info)[i].szName);

    }

    m_Params.SetCurSel(0);

    OnSelchangeListl();

    if(hAsr>ASRERR_MAXERR)
				
				<dp n="d556"/>
            asrRecClose(hAsr);

    if(hDb>ASRERR_MAXERR)

          asrDbClose(hDb);

    SetCursor(SaveCursor);

    return FALSE;
}
void CPrmPrpPg::OnSelchangeListl()
{

    char buffer[50];

    CSRCtrl* Control=(CSRCtrl*)m_Control;

    DWORD value,size=sizeof(DWORD);

    m_Description.SetWindowText((ParamInfo->info)[m_Params.GetCurSel()].sz
Description);

    sprintf(buffer,″%d″,
(ParamInfo->info)[m_Params.GetCurSel()].Range.Default);

    m_SetDef.SetWindowText(buffer);

    sprintf(buffer,″%d″,
(ParamInfo->info)[m_Params.GetCurSel()].Range.Maximum);

    m_Max.SetWindowText(buffer);

    sprintf(buffer,″%d″,
(ParamInfo->info)[m_Params.GetCurSel()].Range.Minimum);

    m_Min.SetWindowText(buffer);

    value=Control->PersistProp->Parameters[m_Params.GetCurSel)];

    sprintf(buffer,″%d″,value);

    m_CurrentValue.SetWindowText(buffer);

    M_Slider.SetRangeMin((ParamInfo->info)[m_Params.GetCurSel)].Range.Min
imum);

    m_Slider.SetRangeMax((ParamInfo->info)[m_Params.GetCurSel)].Range.Max
imum);

    m_Slider.SetPos(value);

    m_Slider.SetTicFreq(1);

    m_Slider.SetPageSize(1);
}
void CPrmPrpPg::OnHScroll(UINT nSBCode,UINT nPos,CScrollBar* pScrollBar)
{

    CSRCtrl* Control=(CSRCtrl*)m_Control;

    DWORD_size=sizeof(DWORD);

    char buffer[10];

    DWORD nAsrPos;

    Control->SetModifiedFlag();

  nAsrPos=Control->PersistProp->Parameters[m_Params.GetCurSel()];
				
				<dp n="d557"/>
    switch(nSBCode){

    case SB_PAGELEFT:

          nPos=nAsrPos;

          nPos-=m_Slider.GetPageSize();

          break;

    case SB_PAGERIGHT:

          nPos=nAsrPos;

          nPos+=m_Slider.GetPageSize();

          break;

    case SB_THUMBTRACK:

          break;

    default:

          return;

    }

    Control->PersistProp->Parameters[m_Params.GetCurSel()]=nPos;

    sprintf(buffer,″%d″,nPos);

    m_CurrentValue.SetWindowText(buffer);

    COlePropertyPage::OnHScroll(nSBCode,nPos,pScrollBar);
void CPrmPrpPg::OnDefaultvalue()
{

    CSRCtrl* Control=(CSRCtrl*)m_Control;

    char buffer[10];

    Control->SetModifiedFlag();

    sprintf(buffer,″%d″,
(ParamInfo->info)[m_Params.GetCurSel()].Range.Default);

    m_CurrentValue.SetWindowText(buffer);

    m_Slider.SetPos((ParamInfo->info)[m_Params.GetCurSel()].Range.Default)
;

    Control->PersistProp->Parameters[m_Params.GetCurSel()]=m_Slider.GetPos
();
}
				
				<dp n="d558"/>
#include ″stdafx.h″
#include ″NewSR.h″
#include ″SRCtl.h″
#include ″SRPpg.h″
#include ″PrmPrpPg.h″
#include ″AcqPropPage.h″
#include ″asrapi.h″
#include ″asr1000.h″
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[]=_FILE_;
#endif
IMPLEMENT_DYNCREATE(CSRCtrl,COleControl)
////////////////////////////////////////////////////////////////////////////
/
// Message map
BEGIN_MESSAGE_MAP(CSRCtrl,COleControl)

      //{{AFX_MSG_MAP(CSRCtrl)

      ON_WM_CREATE()

      ON_MESSAGE(ASRM_CONFIRM,OnConfirm)

      ON_MESSAGE(ASRM_ERROR,OnError)

      ON_MESSAGE(ASRM_GAINREQUEST,OnGainRequest)

      ON_MESSAGE(ASRM_PROGRESS,OnProgress)

      ON_MESSAGE(ASRM_PROMPT,OnPrompt)

      ON_MESSAGE(ASRM_STATE,OnState)

      ON_MESSAGE(ASRM_TRAINEND,OnTrained)

      ON_MESSAGE(ASRM_UPDATE,OnUpdate)

      ON_MESSAGE(ASRM_NOTIFY,OnSRNotify)

      //}}AFX_MSG_MAP

      ON_OLEVERB(AFX_IDS_VERB_PROPERTIES,OnProperties)
END_MESSAGE_MAP()
////////////////////////////////////////////////////////////////////////////
/
// Dispatch map
				
				<dp n="d559"/>
BEGIN_DISPATCH_MAP(CSRCtrl,COleControl)

      //{{AFX_DISPATCHH_MAP(CSRCtrl)

      DISP_PROPERTY_NOTIFY(CSRCtrl,″DataBase″,m_DataBase,
OnDataBaseChanged,VT_BSTR)

      DISP_PROPERTY_NOTIFY(CSRCtrl,″User″,m_User,OnUserChanged,
VT_BSTR)

      DISP_PROPERTY_NOTIFY(CSRCtrl,″Context″,m_Context,
OnContextChanged,VT_BSTR)

      DISP_PROPERTY_NOTIFY(CSRCtrl,″Mode″,m_Mode,OnModeChanged,VT_I2)

      DISP_PROPERTY_NOTIFY(CSRCtrl,″OpenAttr″,m_OpenAttr,
OnOpenAttrChanged,VT_I2)

      DISP_PROPERTY_NOTIFY(CSRCtrl,″XAcqMode″,m_XAcqMode,
OnXAcqModeChanged,VT_I4)

      DISP_PROPERTY_NOTIFY(CSRCtrl,″XWaveIndex″,m_XWaveIndex,
OnXWaveIndexChanged,VT_I4)

      DISP_PROPERTY_NOTIFY(CSRCtrl,″SaveCtx″,m_SaveCtx,
OnSaveCtxChanged,VT_BOOL)

      DISP_PROPERTY_NOTIFY(CSRCtrl,″Control″,m_control,
OnControlChanged,VT_I4)

      DISP_FUNCTION(CSRCtrl,″ShowProperties″,ShowProperties,VT_EMPTY,
VTS_NONE)

      DISP_FUNCTION(CSRCtrl,″RecAcqWaveBuffer″,RecAcqWaveBuffer,VT_I4,
VTS_BSTR VTS_I4)

      DISP_FUNCTION(CSRCtrl,″RecGetState″,RecGetState,VT_I4,VTS_NONE)

      DISP_FUNCTION(CSRCtrl,″GetWords″,GetWords,VT_BSTR,VTS_I2
VTS_BSTR)

      DISP_FUNCTION(CSRCtrl,″ActivateWords″,ActivateWords,VT_I4,VTS_I2
VTS_BSTR VTS_BSTR)

      DISP_FUNCTION(CSRCtrl,″GetActiveWords″,GetActiveWords,VT_BSTR,
VTS_NONE)

      DISP_FUNCTION(CSRCtrl,″Init″,Init,VT_I4,VTS_NONE)

      DISP_FUNCTION(CSRCtrl,″Start″,Start,VT_I4,VTS_NONE)

      DISP_FUNCTION(CSRCtrl,″Stop″,Stop,VT_I4,VTS_NONE)

      DISP_FUNCTION(CSRCtrl,″Close″,Close,VT_I4,VTS_NONE)

      DISP_FUNCTION(CSRCtrl,″GetParam″,GetParam,VT_I4,VTS_I4)

      DISP_FUNCTION(CSRCtrl,″SetParam″,SetParam,VT_I4,VTS_I4 VTS_I4)

      DISP_FUNCTION(CSRCtrl,″AddUserWord″,AddUserWord,VT_I4,VTS_BSTR
VTS_BSTR)

      DISP_FUNCTION(CSRCtrl,″CtxActivate″,CtxActivate,VT_I4,VTS_BOOL)

      DISP_FUNCTION(CSRCtrl,″DictClose″,DictClose,VT_I4,VTS_BOOL)

      DISP_FUNCTION(CSRCtrl,″DictCopy″,DictCopy,VT_I4,VTS_BSTR
VTS_BSTR VTS_BSTR)
				
				<dp n="d560"/>
      DISP_FUNCTION(CSRCtrl,″DictCreate″,DictCreate,VT_I4,VTS_BSTR
VTS_BSTR)

      DISP_FUNCTION(CSRCtrl,″DictDelete″,DictDelete,VT_I4,VTS_BSTR
VTS_BSTR)

      DISP_FUNCTION(CSRCtrl,″DictDeleteException″,DictDeleteException,
VT_I4,VTS_BSTR)

      DISP_FUNCTION(CSRCtrl,″DictGetInfo″,DictGetInfo,VT_VARIANT,
VTS_I2)

      DISP_FUNCTION(CSRCtrl,″DictGetTranscription″,DictGetTranscription,
VT_BSTR,VTS_BSTR)

      DISP_FUNCTION(CSRCtrl,″DictOpen″,DictOpen,VT_I4,VTS_BSTR
VTS_BSTR VTS_I2)

      DISP_FUNCTION(CSRCtrl,″DictRename″,DictRename,VT_I4,VTS_BSTR
VTS_BSTR VTS_BSTR)

      DISP_FUNCTION(CSRCtrl,″DbClose″,DbClose,VT_I4,VTS_NONE)

      DISP_FUNCTION(CSRCtrl,″DbCreate″,DbCreate,VT_I4,VTS_BSTR
VTS_BSTR)

      DISP_FUNCTION(CSRCtrl,″DbDelete″,DbDelete,VT_I4,VTS_BSTR)

      DISP_FUNCTION(CSRCtrl,″DbExport″,DbExport,VT_I4,VTS_I2 VTS_BSTR
VTS_BSTR VTS_BSTR)

      DISP_FUNCTION(CSRCtrl,″DbGetCaps″,DbGetCaps,VT_VARIANT,VTS_BSTR
VTS_I4)

      DISP_FUNCTION(CSRCtrl,″DbGetInfo″,DbGetInfo,VT_VARIANT,VTS_I2)

      DISP_FUNCTION(CSRCtrl,″DbGetParamInfo″,DbGetParamInfo,VT_I4,
VTS_NONE)

      DISP_FUNCTION(CSRCtrl,″DbInstall″,DbInstall,VT_I4,VTS_BSTR
VTS_I4)

      DISP_FUNCTION(CSRCtrl,″DbList″,DbList,VT_BSTR,VTS_NONE)

      DISP_FUNCTION(CSRCtrl,″DbOpen″,DbOpen,VT_I4,VTS_BSTR)

      DISP_FUNCTION(CSRCtrl,″DbUnInstall″,DbUnInstall,VT_I4,VTS_I2
VTS_BSTR)

      DISP_FUNCTION(CSRCtrl,″RecAcqClose″,RecAcqClose,VT_I4,VTS_NONE)

      DISP_FUNCTION(CSRCtrl,″RecAcqGetSignalLevel″,RecAcqGetSignalLevel,
VT_I2,VTS_NONE)

      DISP_FUNCTION(CSRCtrl,″RecAcqOpenEx″,RecAcqOpenEx,VT_I4,VTS_I2
VTS_I2)

      DISP_FUNCTION(CSRCtrl,″RecBreak″,RecBreak,VT_I4,VTS_NONE)

      DISP_FUNCTION(CSRCtrl,″RecClose″,RecClose,VT_I4,VTS_NONE)

      DISP_FUNCTION(CSRCtrl,″RecSetMode″,RecSetMode,VT_I4,VTS_I2)

      DISP_FUNCTION(CSRCtrl,″UsrCopy″,UsrCopy,VT_I4,VTS_BSTR VTS_BSTR)

      DISP_FUNCTION(CSRCtrl,″UsrEnable″,UsrEnable,VT_I4,VTS_BSTR
VTS_BSTR WTS_I2)

      DISP_FUNCTION(CSRCtrl,″UsrCreate″,UsrCreate,VT_I4,VTS_BSTR)
				
				<dp n="d561"/>
      DISP_FUNCTION(CSRCtrl,″UsrDelete″,UsrDelete,VT_I4,VTS_BSTR)

      DISP_FUNCTION(CSRCtrl,″UsrGetInfo″,UsrGetInfo,VT_VARIANT,
VTS_BSTR VTS_I2)

      DISP_FUNCTION(CSRCtrl,″UsrIndependent″,UsrIndependent,VT_I4,
VTS_BSTR VTS_BSTR)

      DISP_FUNCTION(CSRCtrl,″UsrRegister″,UsrRegister,VT_I4,VTS_BSTR
VTS_I2 VTS_BSTR)

      DISP_FUNCTION(CSRCtrl,″UsrRename″,UsrRename,VT_I4,VTS_BSTR
VTS_BSTR)

      DISP_FUNCTION(CSRCtrl,″UsrUnregister″,UsrUnregister,VT_I4,
VTS_BSTR VTS_I2 VTS_BSTR)

      DISP_FUNCTION(CSRCtrl,″CtxClose″,CtxClose,VT_I4,VTS_BOOL)

      DISP_FUNCTION(CSRCtrl,″CtxCopy″,CtxCopy,VT_I4,VTS_BSTR VTS_BSTR
VTS_BSTR VTS_BSTR)

      DISP_FUNCTION(CSRCtrl,″CtxCreate″,CtxCreate,VT_I4,VTS_BSTR
VTS_BSTR VTS_BSTR VTS_BSTR)

      DISP_FUNCTION(CSRCtrl,″CtxDelete″,CtxDelete,VT_I4,VTS_BSTR
VTS_BSTR)

      DISP_FUNCTION(CSRCtrl,″CtxDeleteWord″,CtxDeleteWord,VT_I4,
VTS_BSTR VTS_BSTR)

      DISP_FUNCTION(CSRCtrl,″CtxExport″,CtxExport,VT_I4,VTS_BSTR
VTS_BSTR VTS_BSTR)

      DISP FUNCTION(CSRCtrl,″CtxOpen″,CtxOpen,VT_I4,VTS_BSTR VTS_BSTR
VTS_I2)

      DISP_FUNCTION(CSRCtrl,″CtxRename″,CtxRename,VT_I4,VTS_BSTR
VTS_BSTR VTS_BSTR)

      DISP_FUNCTION(CSRCtrl,″WaitForEvent″,WaitForEvent,VT_I4,VTS_BSTR
VTS_I2 VTS_I4)

      DISP_FUNCTION(CSRCtrl,″GetNbrPhrases″,GetNbrPhrases,VT_I2,
VTS_NONE)

      DISP_FUNCTION(CSRCtrl,″GetPhrase″,GetPhrase,VT_BSTR,VTS_I2)

      DISP_FUNCTION(CSRCtrl,″GetPhraseConfLevel″,GetPhraseConfLevel,
VT_I2,VTS_I2)

      //}}AFX_DISPATCH_MAP

      DISP_FUNCTION_ID(CSRCtrl,″AboutBox″,DISPID_ABOUTBOX,AboutBox,
VT_EMPTY,VTS_NONE)
END_DISPATCH_MAP()
////////////////////////////////////////////////////////////////////////////
/
// Event map
BEGIN_EVENT_MAP(CSRCtrl,COleControl)
				
				<dp n="d562"/>
     //{{AFX_EVENT_MAP(CSRCtrl)

     EVENT_CUSTOM(″Result″,FlreResult,VTS_BSTR VTS_I2 VTS_I2)

     EVENT_CUSTOM(″RecError″,FireRecError,VTS_I4 VTS_BSTR)

     EVENT_CUSTOM(″ChangeState″,FireChangeState,VTS_I2)

     //}}AFX_EVENT_MAP
END_EVENT_MAP()
////////////////////////////////////////////////////////////////////////////
/
// Property pages
// TODO Add more property pages as needed.Ramember to inccrease the count!
BEGIN_PROPPAGEIDS(CSRCtrl,3)

      PROPPAGEID(CSRPropPage:guid)

      PROPPAGEID(CPrmPrpPg:guid)

      PROPPAGEID(CAcqPropPage::guid)
END_PROPPAGEIDS(CSRCtrl)
////////////////////////////////////////////////////////////////////////////
/
// Initialize class factory and guod
IMPLEMENT_OLECREATE_EX(CSRCtrl,″NEWSR.SRCtrl.1″,

      0x528c0223,0x72ec,0x11d0,0xa6,0xce,0,0x40,0x33,0x2d,0x1,
0xc5)
////////////////////////////////////////////////////////////////////////////
/
// Type library ID and version
IMPLEMENT_OLETYPELIB(CSRCtrl,_tlid,_wVerMajor,_wVerMinor)
////////////////////////////////////////////////////////////////////////////
/
// Intefface IDs
const IID BASED_CODE IID_DSR=

              {0x528c0221,0x72ec,0x11d0,(0xa6,0xce,0,0x40,0x33,
0x2d,0x1,0xc5)};
				
				<dp n="d563"/>
const IID BASED_COCE IID DSREvents=

              {0x528c0222,0x72ec,0x11d0,{0xa6,0xce,0,0x40,0x33,
9x2d,0x1,0xc5)};
////////////////////////////////////////////////////////////////////////////
/
// Control type information
static const DWORD BASED_CODE_dwSROleMisc=
//      OLEMISC_INVISIBLEATRUNTIME |

      OLEMISC_SETCLIENTSITEIRST  |

      OLEMISC_INSIDEOUT |

      OLEMISC_CANTLINKINSIDE |

      OLEMISC_RECOMPOSEONRESIZE;
IMPLEMENT_OLECTLTYPE(CSRCtrl,IDS_SR,_dwSROleMisc)
////////////////////////////////////////////////////////////////////////////
/
// CSRCtrl::CSRCtrlFactory::UpdateRegistry-
// Adds or removes system registry entries for CSRCtrl
BOOL CSRCtrl::CSRCtrlFactory::UpdateRegistry(BOOL bRegister)
{

     if(bRegister)

            return AfxOleRegisterControlClass{

                    AfxGetInstanceHandle(),

                    m_clsid,

                    m_lpszProgID,

                    IDS_SR,

                    IDB_SR,

                    FAISE,              // Not insertable

                    _dwSROleMisc,

                    _tlid,

                    _wVerMajor,

                    _wVerMinor);

            else

                  return AfxOleUnregisterClass(m_clsid,m_lpszProgID);
}
				
				<dp n="d564"/>
////////////////////////////////////////////////////////////////////////////
/
// CSRCtrl::CSRCtrl-Constructor
CSRCtrl::CSRCtrl()
{

      InitializeIIDs(&amp; IID_DSR,&amp; IID_DSREvents);

      SetInitialSize(32,32);

      PWaveFormats=NULL;

      SR.hDb=0;

      SR.hAsr=0;

      SR.hCtx=0;

      SR.hDict=0;

      LastResult=NULL;

      SuppProp=NULL;

      SuppPropDef=NULL;

      m_Mode=0;

      m_OpenAttr=0;

      m_SaveCtx=FALSE;

      m_XAcqMode=DISP_DEVICEID;

      m_XWaveIndex=0;

      m_control=(long)this;
////////////////////////////////////////////////////////////////////////////
/
// CSRCtrl::-CSRCtrl-Destructor
CSRCtrl::-CSRCtrl()
{

      if(PWaveFormats)

              free(PWaveFormats);

      if(SuppProp)

              GlobalFree(SuppProp);

      if(SuppPropDef)

              GlobalFree(SuppPropDef);
}
				
				<dp n="d565"/>
////////////////////////////////////////////////////////////////////////////
/
// CSRCtrl::OnDraw-Drawing function
void CSRCtrl::OnDraw(

                      CDC* pdc,const CRect &amp; rcBounds,const CRect &amp;
rcInvalid)
{

      pdc->DrawIcon(rcBounds.left,rcBounds.top,

              ((CNewSRApp*)AfxGetApp())->SRIcon);
}
////////////////////////////////////////////////////////////////////////////
/
// CSRCtrl::DoPropExchange-Persistence support
void CSRCtrl::DoPropExchange(CPropExchange* pPX)
(

       ExchangeVersion(pPX,MAKELONG(_wVerMinor,_wVerMajor));

       COleControl::DoPropExchange(pPX);

       PrePropExchange(pPX);

       PX_Syring(pPX,″DataBase″,m_DataBase,m_DataBase);

       PX_String(pPX,″User″,m_User,m_User);

       PX_String(pPX,″Context″,m_Context,m_Context);

       PX_Short(pPX,″Mode″,m_Mode,m_Mode);

       PX_Short(pPX,″OpenAttr″,m_OpenAttr,m_OpenAttr);

       PX_Bool(pPX,″SaveCtx″,M_SaveCtx,m_SaveCtx);

       PX_Long(pPX,″~aveIndex″,M_XWaveIndex,M_XWaveIndex);

       PX_Long(pPX,″XAcqMode″,m_XAcqMode,m_XAcqMode);

       PX_Blob(pPX,″″,SuppProp,SuppPropDef);

       PostPropExchange(pPX);
////////////////////////////////////////////////////////////////////////////
/
// CSRCtrl::OnResetState-Reset control to default state
void CSRCtrl::OnResetState()
{

       InitDefaults();
				
				<dp n="d566"/>
      COleControl::OnResetState();// Resets defaults found in
DoPropExchange
}
////////////////////////////////////////////////////////////////////////////
/
// CSRCtrl::AboutBox-Display an″About″box to the user
void CSRCtrl::AboutBox()
{

      CDialog dlgAbout(IDD_ABOUTBOX_SR);

      dlgAbout.DoModal();
}
////////////////////////////////////////////////////////////////////////////
/
// CSRCtrl message handlers
void CSRCtrl::OnDataBasaChanged()
{

      SetModifiedFlag();
}
void CSRCtrl::OnUserChanged()
{

      SetModifiedFlag();
void CSRCtrl::OnContextChanged()
{

      SetModifiedFlag();
}
void CSRCtrl::OnModeChanged()
{

      SetModifiedFlag();
}
void CSRCtrl::OnOpenAttrChanged()
{

      SetModifiedFlag();
}
				
				<dp n="d567"/>
void CSRCtrl::OnXAcqModeChanged()
{

     SetModifiedFlag();
}
void CSRCtrl::OnXWaveIndexChanged()
{

     SetModifiedFlag();
}
void CSRCtrl::OnSaveCtxChanged()
{

     SetModifiedFlag();
}
//--------------------------Messages processing--------------------------
LRESULT CSRCtrl::OnConfirm(WPARAM wParam,LPARAM lParam){

     MessageBox(″OnConfirm″);

     return 0L;
)
LRESULT CSRCtrl::OnError(WPARAM wParam,LPARAM lParam){

     char errbuff[ASR_MAX_ERROR_LENGTH];

     DWORD size=sizeof(errbuff);

     WORD BlockID LOWORD(lParam);

     WORD ErrCode HIWORD(lParam);

     asrRecGetErrorString(SR.hAsr,BlockID,ErrCode,errbuff,&amp; size);

     FireRecError(ErrCode,errbuff);

     return 0L;
}
LRESULT CSRCtrl::OnGainRequest(WPARAM wParam,LPARAM lParam){

     MessageBox(″OnGainRequest″);

     return 0L;
}
LRESULT CSRCtrl::OnProgress(WPARAM wParam,LPARAM lParam){

     MessageBox(″OnProgress″);

     return 0L;
}
LRESULT CSRCtrl::OnPrompt(WPARAM wParam,LPARAM lParam){

     MessageBox(″OnPrompt″);

     return 0L;
				
				<dp n="d568"/>
LRESULT CSRCtrl::OnState(WPARAM wParam,LPARAM lParam){
      FireChangeState(LOWORD(lParam));

      return 0L;
}
LRESULT CSRCtrl::OnTrained(WPARAM wParam,LPARAM lParam){
      MessageBox(″OnTrained″);

      return 0L;
}
LRESULT CSRCtrl::OnUpdate(WPARAM wParam,LPARAM lParam){

      MessageBox(″OnUpdate″);

      rerun 0L;
}
LRESULT CSRCtrl::OnSRNotify(WPARAM wParam,LPARAM lParam){

      LastResult=(LPASRESULT)lParam;

      FireResult(LastResult->szzUtterances,*(LastResult->lpwConfidences),
LastResult->wN);

      m_WasResult=TRUE;

      return 0L;
}
void CALLBACK ErrorCallback(HASR hAsr,WORD BlockID,ASRERROR ErrorID){
void CSRCtrl::SRCtrlInit()
{

      HCURSOR SaveCursor;

      DWORD size;

      PPARAMINFOLIST ParamInfo;

      SaveCursor=SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));

      CheckError(SR.hDb=asrDbOpen(m_DataBase));

      CheckError(SR.hAsr=asrRecOpenEx(SR.hDb,″Win32″, m_hWnd,
ErrorCallback,NULL,NULL,0));

      CheckError(asrRecSetMode(SR.hAsr,m_Mode));

      CheckError(SR.hCtx=asrCtxOpen(SR.hDb,m_User,m_Context,
m_OpenAttr));
				
				<dp n="d569"/>
      if(SR.hDb>ASRERR_MAXERR){

               DWORD size;

               CheckError(asrDbGetInfo(SR.hDb,ASRDBINFO_WAVEFORMATS, NULL,
&amp; size));

               PWaveFormats=(PWAVEFORMAT)malloc(size);

               CheckError(asrDbGetInfo(SR.hDb,ASRDBINFO_WAVEFORMATS,
PWaveFormats,&amp; size));

      }

      asrRecGetParamInfo(SR.hAsr,NULL,&amp; size);

      ParamInfo=(PPARAMINFOLIST)malloc(size);

      asrRecGetParamInfo(SR.hAsr,ParamInfo,&amp; size);

      for(int i=0;i<ParamInfo->nbrOfParams;i++)

              asrRecSetParam(SR.hAsr,(ParamInfo->info)[i].ParamType,

                      &amp;(PersistProp->Parameters[i]),sizeof(DWORD));

      if(ParamInfo)

              free(ParamInfo);

      ASRACTIVATE AsrActivate=(SR.hCtx,″″);

      CheckError(asrRecCtivate(SR.hAsr,&amp;AsrActivate,1));

      SetCursor(SaveCursor);

      return;
}
void CSRCtrl::ShowProperties()
{

      OnProperties(NULL,NULL,NULL);
long CSRCtrl::RecStart(){

      LPWAVEFORMAT wf;

      WORD type;

      ASRERROR err;

      wf=PWaveFormats+m XWaveIndex;

      switch(m_XAcqMode){

              case DISP_DEVICEID:

                      wf=(LPWAVEFORMAT)m_XWaveIndex;

                      type=WAVEDEVICE;

                      break;

              case DISP_REALTIME:

                      type=REALTIME;

                      break;

              case DISP_NONREALTIME:

                      type=NONREALTIMI;
				
				<dp n="d570"/>
                       break;

      }

      CheckError(err=asrRecAcqOpenEx(SR.hAsr,wf,type));

      CheckError(err=asrRecStart(SR.hAsr,m_hWnd,NULL));

      return 0;
}
long CSRCtrl::RecStop()
{

      ASRERROR err;

      CheckError(err=asrRecBreak(SR.hAsr));

      if(err!=ASRERR_OK){

                return err;

      }

      CheckError(err=asrRecAcqClose(SR.hAsr));

      if(err!=ASRERR_OK){

                return err;

      }

      return 0;
}
long CSRCtrl::RecGetState()
{

      ASRSTATE state;

      CheckError(asrRecGetState(SR.hAsr,&amp;state));

      return state;
}
ASRERROR CSRCtrl::CheckError(long code)
{

      char errbuff[ASR_MAX_ERROR_LENGTH];

      DWORD size=sizeof(errbuff);

      if(code<ASRERR_MAXERR&amp;&amp;code>0)(

              asrRecGetErrorString(SR.hAsr,0,code,errbuff,&amp; size);

              FireRecError(code,errbuff);

      }

      return code;
}
int CSRCtrl::PrePropExchange(CPropExchange* pPX)
{

      return 0;
}
				
				<dp n="d571"/>
int CSRCtrl::PostPropExchange(CPropExchange* pPX)
{

      if(pPX->IsLoading()){

              PersistProp=(PERSIST_PRROP*)(*((DWORD*)SuppProp));

      return 0;
}
void CSRCtrl::InitDefaults()
{

      HDB hDb;

      HASR hAsr;

      PPARAMINFOLIST ParamInfo;

      LPSTR Buffer;

      DWORD size;

      HCURSOR SaveCursor;

      SaveCursor=SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));

      SuppPropDef=GlobalAlloc(GMEM_MOVEABLE,sizeof(PERSIST_PRROP));

      PersistProp=(PERSIST_PRROP*)(*((DWORD*)SuppPropDef));

      PersistProp->dwMySelfSize=sizeof(PERSIST_PRROP);

      asrDbList(NULL,&amp; size);

      Buffer=(LPSTR)malloc(size);

      asrDbList(Buffer,&amp; size);

      hDb=asrDbOpen(Buffer);

      if(Buffer)

              free(Buffer);

      hAsr=asrRecOpen(hDb,″Win32″,NULL,NULL,NULL);

      ASRERROR err=asrRecGetParamInfo(hAsr,NULL,&amp; size);

      ParamInfo=(PPARAMINFOLIST)malloc(size);

      err=asrRecGetParamInfo(hAsr,ParamInfo,&amp; size);

      for(int i=0;i<ParamInfo->nbrOfParams;i++)
PersistProp->Parameters[i]=(ParamInfo->info)[i].Range.Default;

      if(ParamInfo)

              free(ParamInfo);

      if(hAsr>ASRERR_MAXERR)

              asrRecClose(hAsr);

      if(hDb>ASRERR_MAXERR)
				
				<dp n="d572"/>
              asrDbClose(hDb);

      SetCursor(SaveCursor);

      return;
}
BSTR CSRCtrl::GetWords(short Type,LPCTSTR Class)

      CString strResult;

      DWORD dwLength;

      LPSTR Buffer;

      CheckError(asrCtxGetWords(SR.hCtx,Type,Class,NULL,&amp; dwLength));

      Buffer=new char[dwLength];

      CheckError(asrCtxGetWords(SR.hCtx,Type,Class,Buffer,&amp; dwLength));

      MemChange(Buffer,′\0′,′|′,0xFFFFFFFF);

      strResult=(LPSTR)Buffer;

      delete Buffer;

      return strResult.AllocSysString();
}
int CSRCtrl::MemChange(void* Buffer,char c0,char c1,DWORD dwLength){

      LPSTR ptr;

      if(dwLength==0xFFFFFFFF){

              ptr=(LPSTR)Buffer;

              dwLength=0;

              while(!(ptr[0]a′\0′&amp;&amp; ptr[1]==′\0′)){

                       ptr++;

                       dwLength++;

              }

      }

      while(ptr=(LPSTR)memchr(Buffer,c0,dwLength))

               *ptr=cl;

      return 0;
long CSRCtrl::Init()
{

      SRCtrlInit();

      return 0;
}
BOOL CSRCtrl::OnSetExtent(LPSIZEL lpSizeL){

      return FALSE;
				
				<dp n="d573"/>
void CSRCtrl::OnControiChanged()
{

      SetModifiedFlag();
}
long CSRCtrl::Start()
{

      RecStart();

      return 0;
}
long CSRCtrl::Stop()
{

      RecStop();

      return 0;
}
long CSRCtrl::Close()
{

      if(SR.hAsr>ASRERR_MAXERR)

              CheckError(asrRecBreak(SR.hAsr));

      if(SR.hAsr>ASRERR_MAXERR)

              CheckError(asrRecCtxActivate(SR.hAsr,NULL,0));

      if(SR.hCtx>ASRERR_MAXERR){

              CheckError(asrCtxClose(SR.hCtx,m_SaveCtx));

              SR.hCtx=0;

       }

       if(SR.hAsr>ASRERR_MAXERR)

              CheckError(asrRecAcqClose(SR.hAsr));

       if(SR.hAsr>ASRERR_MAXERR){

              CheckError(asrRecClose(SR.hAsr));

              SR.hAsr=0;

       }

       if(SR.hDb>ASRERR_MAXERR){

              CheckError(asrDbClose(SR.hDb));

              SR.hDb=0;

       }

       return 0;
}
				
				<dp n="d574"/>
long CSRCtrl::GetParam(long ParamType)
{

      DWORD Value;

      DWORD size=sizeof(DWORD);

      CheckError(asrRecGetParam(SR.hAsr,ParamType,&amp;Value,&amp;size));

      return Value;
long CSRCtrl::SetParam(long ParamType,long NewValue)
{

      ASRERROR err=CheckError(asrRecSetParam(SR.hAsr,ParamTyPe,&amp; NewValue,sizeof(long)));

      return err;
}
long CSRCtrl::AddUserWord(LPCTSTR Class,LPCTSTR Word)
{

      return CheckError(asrCtxAddUserWord(SR.hAsr,SR.hCtx,Class,Word,
NULL,NULL));
//---------------------------Dictionary---------------------------
long CSRCtrl::DictClose(BOOL SaveChanges)
{

      return asrDictClose(SR.hDict,SaveChanges);
}
long CSRCtrl::DictCopy(LPCTSTR Language,LPCTSTR DictSrc,LPCTSTR DictDest)
{

      return asrDictCopy(SR.hDb,Language,DictSrc,DictDest);
long CSRCtrl::DictCreate(LPCTSTR Language,LPCTSTR Dictionary)
{

      return asrDictCreate(SR.hDb,Language,Dictionary);
long CSRCtrl::DictDelete(LPCTSTR Language,LPCTSTR Dictionary)
{

      return asrDictDelete(SR.hDb,Language,Dictionary);
}
				
				<dp n="d575"/>
long CSRCtrl::DictDeleteException(LPCTSTR Word)
{

      return asrDictDeleteException(SR.hDict,Word);
}
VARIANT CSRCtrl::DictGetInfo(short Type)
{

      LPVOID Buffer;

      DWORD size;

      VARIANT vaResult;

      VariantInit(&amp; vaResult);

      asrDictGetInfo(SR.hDict,Type,NULL,&amp; size);

      Buffer=malloc(size);

      asrDictGetInfo(SR.hDict,Type,Buffer,&amp; size);

      if(Buffer)

              free(Buffer);

      return vaResult;
}
BSTR CSRCtrl::DictGetTranscription(LPCTSTR Word)
{

      LPVOID Buffer;

      DWORD size;

      CString strResult;

      asrDictGetTranscription(SR.hDict,Word,NULL,&amp; size);

      Buffer=malloc(size);

      asrDictGetTranscription(SR.hDict,Word,Buffer,&amp; size);

      strResult=(LPCSTR)Buffer;

      if(Buffer)

              free(Buffer);

      return strResult.AllocSysString();
}
long CSRCtrl::DictOpen(LPCTSTR Language,LPCTSTR Dictionary,short Attrib)
{

      SR.hDict=asrDictOpen(SR.hDb,Language,Dictionary,Attrib);

      return SR.hDict;
}
long CSRCtrl::DictRename(LPCTSTR Language,LPCTSTR DictSrc,LPCTSTR
DictDest)
{

      return asrDictRename(SR.hDb,Language,DictSrc,DictDest);
				
				<dp n="d576"/>
// ---------------------------DataBase---------------------------
long CSRCtrl::DbClose()
{

      return asrDbClose(SR.hDb);
long CSRCtrl::DbCreate(LPCTSTR DbName,LPCTSTR Path)
{

      return asrDbCreate(DbName,Path);
}
long CSRCtrl::DbDelete(LPCTSTR DbName)
{

      return asrDbDelete(DbName);
}
long CSRCtrl::DbExport(short Type,LPCTSTR LangOrUser,LPCTSTR Name,LPCTSTR
Path)
{

      return asrDbExport(SR.hDb,Type,LangOrUser,Name,Path);
}
VARIANT CSRCtrl::DbGetCaps(LPCTSTR Environment,long Type)
{

      VARIANT vaResult;

      VariantInit(&amp;vaResult);

      PENGINECAPS EngineCaps;

      DWORD size;

      asrDbGetCaps(SR.hDb,(LPSTR)Environment,NULL,&amp; size);

      EngineCaps=(PENGINECAPS)malloc(size);

      switch(Type){

              case EC_SZENGFNENAME:

                      vaResult.vt=VT_BSTR;
vaResult.bstrVal=CString(EngineCaps->szEngineName).AllocSysString();

                      break;

              case EC_DWENVIRONMENTS:

                      vaResult.vt=VT_I4;

                      vaResult.lVal=EngineCaps->dwEnvironments;

                      break;

              case EC_DWSEQUENCING:
				
				<dp n="d577"/>
                       vaResult.vt=VT_I4;

                       vaResult.lVal=EngineCaps->dwSequencing;

                       break;

              case EC_DWLANGUAGECAPS:

                       vaResult.vt=VT_I4;

                       vaResult.lVal=EngineCaps->dwLanguageCaps;

                       break;

              case EC_DWUSERCAPS:

                       vaResult.vt=VT_I4;

                       vaResult.lVal=EngineCaps->dwUserCaps;

                       break;

              case EC_DWGRAMMARINSTCAPS:

                       vaResult.vt=VT_I4;

                       vaResult.lVal=EngineCaps->dwGrammarInstCaps;

                       break;

              case EC_DWMAXVOCAB:

                       vaResult.vt=VT_I4;

                       vaResult.lVal=EngineCaps->dwMaxVocab;

                       break;

              case EC_DWMAXPERPLEXITY:

                       vaResult.vt=VT_I4;

                       vaResult.lVal=EngineCaps->dwMaxPlexity;

                       break;

              case EC_DWENGINEFEATURES:

                       vaResult.vt=VT_I4;

                       vaResult.lVal=EngineCaps->dwEngineFeatures;

                       break;

              case EC_SZZGRAMMARNAMES:

                       vaResult.vt=VT_BSTR;

                       MemChange(EngineCaps->szzGrammarNames,′\0′,′|′,
0xFFFFFFFF);
vaResult.bstrVal=CString(EngineCaps->szzGrammarNames).AllocSysString();

                       break;

      }

      if(EngineCaps)

               free(EngineCaps);

      return vaResult;
}
VARIANT CSRCtrl::DbGetInfo(short Type)
{

      VARINT vaResult;
				
				<dp n="d578"/>
       VariantInit(&amp; vaResult);

       LPVOID Buffer;

       DWORD size;

       asrDbGetInfo(SR.hDb,Type,NULL,&amp; size);

       Buffer=malloc(size);

       asrDbGetInfo(SR.hDb,Type,Buffer,&amp; size);

       switch(Type){

              case ASRDBINFO_LANGUAGES:

                       vaResult.vt=VT_BSTR;

                       MemChange(Buffer,′\0′,′|′,size);
vaResult.bstrVal=CString((LPCSTR)Buffer).AllocSysString();

                       break;

              case ASRDBINFO_NBRLANGUAGES:

                       vaResult.vt=VT_I4;

                       vaResult.lVal=*((DWORD*)Buffer);

                       break;

              case ASRDBINFO_USERS:

                       vaResult.vt=VT_BSTR;

                       MemChange(Buffer,′\0′,′|′,size);
vaResult.bstrVal=CString((LPCSTR)Buffer).AllocSysString();

                       break;

              case ASRDBINFO_NBRUSERS:

                       vaResult.vt=VT_I4;

                       vaResult.lVal=*((DWORD*)Buffer);

                       break;

              case ASRDBINFO_ENVIRONMENTS:

                       vaResult.vt=VT_BSTR;

                       MemChange(Buffer,′\0′,′|′,size);
vaResult.bstrVal=CString((LPCSTR)Buffer).AllocSysString();

                       break;

              case ASRDBINFO_NBRENVIRONMENTS:

                       vaResult.vt=VT_I4;

                       vaResult.lVal=*((DWORD*)Buffer);

                       break;

              case ASRDBINFO_CONTEXTS :

                       vaResult.vt=VT_BSTR;

                       MemChange(Buffer,′\0′,′|′,size);
				
				<dp n="d579"/>
vaResult.bstrVal=CString((LPCSTR)Buffer).AllocSysString();

                       break;

              case ASRDBINFO_NBRCONTEXTS:

                       vaResult.vt=VT_I4;

                       vaResult.lVal=*((DWORD*)Buffer);

                       break;

              case ASRDBINFO_WAVEFORMATS:

                       vaResult.vt=VT_I4;

                       vaResult.lVal=-1;

                       break;

              case ASRDBINFO_NBRWAVEFORMATS:

                       vaResult.vt=VT_I4;

                       vaResult.lVal=*((DWORD*)Buffer);

                       break;

              case ASRDBINFO_GRAMMARFORMATS:
                       vaResult.vt=VT_I4;

                       vaResult.lVal=-1;

                       break;

              case ASRDBINFO_NBRGRAMMARFORMATS:

                       vaResult.vt=VT_I4;

                       vaResult.lVal=*((DWORD*)Buffer);

                       break;

              case ASRDBINFO_EXPORTFORMATS:

                       vaResult.vt=VT_I4;

                       vaResult.lVal=-l;

                       break;

              case ASRDBINFO_NBREXPORTFORMATS:

                       vaResult.vt=VT_I4;

                       vaResult.lVal=*((DWORD*)Buffer);

                       break;

              case ASRDBINFO_IMPORTBUFFORMATS:

                       vaResult.vt=VT_I4;

                       vaResult.lVal=-l;

                       break;

              case ASRDBINFO_NBRIMPORTBUFFORMATS:

                       vaResult.vt=VT_I4;

                       vaResult.lVal=*((DWORD*)Buffer);

                       break;

              case ASRDBINFO_EXPORTBUFFORMATS:

                       vaResult.vt=VT_I4;

                       vaResult.lVal=-1;

                       break;
				
				<dp n="d580"/>
              case ASRDBINFO_NBREXPORTBUFFORMATS:

                      vaResult.vt=VT_I4;

                      vaResult.lVal=*((DWORD*)Buffer);

                      break;

      }

      if(Buffer)

              free(Buffer);

      return vaResult;
}
long CSRCtrl::DbGetParamInfo()
{

      return-1;
}
long CSRCtrl::DbInstall(LPCTSTR SetupFile,long hWnd)
{

      return asrDbInstall(SR.hDb,SetupFile,(HWND)hWnd);
}
BSTR CSRCtrl::DbList()
{

      CString strResult;

      LPSTR Buffer;

      DWORD size;

      asrDbList(NULL,&amp; size);

      Buffer=(LPSTR)malloc(size);

      asrDbList(Buffer,&amp; size);

      MemChange(Buffer,′\0′,′|′,size);

      strResult=Buffer;

      if(Buffer)

              free(Buffer);

      return strResult.AllocSysString();
long CSRCtrl::DbOpen(LPCTSTR DbName)
{

      SR.hDb=asrDbOpen(DbName);

      return SR.hDb;
}
				
				<dp n="d581"/>
long CSRCtrl::DbUnInstall(short Type,LPCTSTR ObjectName)
{

      return asrDbUninstall(SR.hDb,Type,ObjectName);
}
//---------------------------Recognition engine---------------------------
long CSRCtrl::RecAcqClose()
{

      return asrRecAcqClose(SR.hAsr);
}
short CSRCtrl::RecAcqGetSignalLevel()
{

      short Level;

      asrRecAcqGetSignalLevel(SR.hAsr,&amp; Level);

      return Level;
}
long CSRCtrl::RecAcqOpenEx(short WaveFormIndex,short Type)
{

      ASRERROR err;

      if(Type==WAVEDEVICE)

               err=asrRecAcqOpenEx(SR.hAsr,(LPWAVEFORMAT)WaveFormIndex,
Type);

      else

               err=asrRecAcqOpenEx(SR.hAsr,PWaveFormats+WaveFormIndex,
Type);

      return err;
}
long CSRCtrl::RecAcqWaveBuffer(LPCTSTR lpBuffer,long dwLength)
{

      return CheckError(asrRecAcqWaveBuffer(SR.hAsr,(LPVOID)lpBuffer,
dwLength));
long CSRCtrl::RecBreak()
{

      return asrRecBreak(SR.hAsr);
}
				
				<dp n="d582"/>
long CSRCtrl::RecClose()
{

      return asrRecClose(SR.hAsr);
}
long CSRCtrl::CtxActivate(BOOL Activate)
}

      if(Activate){

              ASRACTIVATE AsrActivate=(SR.hCtx,″″);

              asrRecCtxActivate(SR.hAsr,&amp;AsrActivate,1);

      }

      else

              asrRecCtxActivate(SR.hAsr,NULL,0);

      return 0;
BSTR CSRCtrl::GetActiveWords()
{

      CString strResult;

      LPSTR ActiveWords;

      DWORD size;

      CheckError(asrRecGetActiveWords(SR.hAsr,SR.hCtx,NULL,NULL,
&amp;size));

      ActiveWords=new char[size];

      CheckError(asrRecGetActiveWords(SR.hAsr,SR.hCtx,NULL,ActiveWords,
&amp; size));

      MemChange(ActiveWords,′\0′,′|′,0xFFFFFFFF);

      strResuit=ActiveWords;

      delete ActiveWords;

      return strResult.AllocSysString();
long CSRCtrl::ActivateWords(short Type,LPCTSTR Class,LPCTSTR Words)
{

      LPSTR Buffer;

      ASRERROR err;

      DWORD size;

      size=strlen(Words)+2;

      Buffer=new char[size];

      strcpy(Buffer,Words);

      Buffer[size-1]=′\0′;

      MemChange(Buffer,′|′,′\0′,size);
				
				<dp n="d583"/>
       CheckError(err=asrRecSetActiveWords(SR.hAsr,SR.hCtx,Type,Class,
Buffer));

       delete Buffer;

       return err;
}
long CSRCtrl::RecSetMode(short NewMode)
{

       return as rRecSetMode(SR.hAsr,NewMode);
}
//---------------------------User---------------------------
long CSRCtrl::UsrCopy(LPCTSTR UserSrc,LPCTSTR UserDest)
}
       return asrUsrCopy(SR.hDb,UserSrc,UserDest);
}
long CSRCtrl::UsrEnable(LPCTSTR UserName,LPCTSTR Language,short Type)
{

       return asrUsrEnable(SR.hDb,UserName,Language,Type);
long CSRCtrl::UsrCreate(LPCTSTR UserName)
{

       return asrUsrCreate(SR.hDb,UserName);
}
long CSRCtrl::UsrDelete(LPCTSTR UserName)
{

       return asrUsrDelete(SR.hDb,UserName);
}
VARIANT CSRCtrl::UsrGetInfo(LPCTSTR UserName,short Type)
{

       LPVOID Buffer;

       DWORD size;

       VARLANT vaResult;

       VariantInit(&amp;vaResult);
       asrUsrGetInfo(SR.hDb,UserName,Type,NULL,&amp;size);

       Buffer=malloc(size);
				
				<dp n="d584"/>
       asrUsrGetInfo(SR.hDb,UserName,Type,Buffer,&amp; size);

       switch(Type){

              case ASRUSRINFO_CONTEXTS:

                       vaResult.vt=VT_BSTR;

                       MemChange(Buffer,′\0′,′|′,size);
vaResult.bstrVal=CString((LPCSTR)Buffer).AllocSysString();

                       break;

              case ASRUSRINFO_LANGUAGES:

                       vaResult.vt=VT_BSTR;

                       MemChange(Buffer,′\0′,′|′,size);
vaResult.bstrVal=CString((LPCSTR)Buffer).AllocSysString();

                       break;

              case ASRUSRINFO_NBRCONTEXTS:

                       vaResult.vt=VT_I4;

                       vaResult.lVal=*((DWORD*)Buffer);

                       break;

              case ASRUSRINFO_NBRLANGUAGES:

                       vaResult.vt=VT_I4;

                       vaResult.lVal=*((DWORD*)Buffer);

                       break;

              case ASRUSRINFO_MODELS:

                       break;

              }

              if(Buffer)

                      free(Buffer);

             return vaResult;
long CSRCtrl::UsrIndependent(LPCTSTR UserName,LPCTSTR Language)
{

      return asrUsrIndependent(SR.hDb,UserName,Language);
}
long CSRCtrl::UsrRegister(LPCTSTR User,short Type,LPCTSTR Name)
{

      return asrUsrRegister(SR.hDb,User,Type,Name);
}
long CSRCtrl::UsrRename(LPCTSTR OldName,LPCTSTR NewName)
{

      return asrUsrRename(SR.hDb,OldName,NewName);
				
				<dp n="d585"/>
long CSRCtrl::UsrUnregister(LPCTSTR User,short Type,LPCTSTR Name)

      return asrUsrUnregister(SR.hDb,User,Type,Name);
//---------------------------Context---------------------------
long CSRCtrl::CtxClose(BOOL Save)
{

      return asrCtxClose(SR.hCtx,Save);
}
long CSRCtrl::CtxCopy(LPCTSTR SrcUser,LPCTSTR SrcContext,LPCTSTR DestUser,
LPCTSTR DestContext)
{

      return asrCtxCopy(SR.hDb,SrcUser,SrcContext,DestUser,
DestContext);
long CSRCtrl::CtxCreate(LPCTSTR User,LPCTSTR Language,LPCTSTR Syntax,
LPCTSTR Context)
{

      return asrCtxCreate(SR.hDb,User,Language,Syntax,Context);
}
long CSRCtrl::CtxDelete(LPCTSTR User,LPCTSTR Context)
{

      return asrCtxDelete(SR.hDb,User,Context);
}
long CSRCtrl::CtxDeleteWord(LPCTSTR Class,LPCTSTR Word)
{

      return asrCtxDeleteWord(SR.hCtx,Class,Word);
}
long CSRCtrl::CtxExport(LPCTSTR User,LPCTSTR Format,LPCTSTR Context)
{

      return asrCtxExport(SR.hDb,User,Format,Context);
}
long CSRCtrl::CtxOpen(LPCTSTR User,LPCTSTR Context,short Attrib)
				
				<dp n="d586"/>
{

      retum asrCtxOpen(SR.hDb,User,Context,Attrib);
}
long CSRCtrl::CtxRename(LPCTSTR User,LPCTSTR OldCtx,LPCTSTR NewCtx)
{

      return asrCtxRename(SR.hDb,User,OldCtx,NewCtx);
}
#define NUM_MIDI_EVENTS 5
#define SR ENABLE                 1
#define MIDI_ENABLE               2
#define SRCTRL_ERROR_TIMEOUT     -1
#define SRCTRL_ERROR_NOTFOUND    -2
#define SRCTRL_ERROR_MAPFORMAT   -3
#define SRCTRL_ERROR_MEMALLOC    -4
#define MAP_MAX_LEN    80
#define ACTIVATE_BUFFER_LENGTH   256
long CSRCtrl::WaitForEvent(LPCTSTR Map,short time_100ms,long dwFlags){

      enum(MIDI_EVENT,SR_EVENT,TIME_OUT);

      long retvalue;

      short break_event=TIME_OUT;

      int i;

      HANDLE hMidiEvents[NUM_MIDI_EVENTS];

      DWORD dwStartTime,dwEndTime;

      CString EventName;

      MSG msg;

      if(dwFlags &amp; MIDI_ENABLE){

               for(i=0;i<NUM_MIDI_EVENTS;i++){
                   EventName. Format(″%s%d″,″BIT″,i);

                   hMidiEvents[i]=CreateEvent(NULL,TRUE,FALSE,
EventName);

                   ResetEvent(hMidiEvents[i]);

            }
				
				<dp n="d587"/>
      }

      if(dwFlags &amp; SR_ENABLE){

               DWORD BufferLength;

               LPSTR words_buffer;

               asrRecGetActiveWords(SR.hAsr,SR.hCtx,NULL,NULL,
&amp;BufferLength);

               words_buffer=(LPSTR)malloc(BufferLength);

               if(words_buffer==NULL){

                               retvalue=SRCTRL_ERROR_MEMALLOC;

                                goto_exit;

               }

               asrRecGetActiveWords(SR.hAsr,SR.hCtx,NULL,words_buffer,
&amp; BufferLength);

               asrRecSetActiveWords(SR.hCtr,SR.hCtx,ASRREC_DISACTIVATION,
NULL,words_buffer);

               free(words_buffer);

               char activate_buffer[ACTIVATE_BUFFER_LENGTH];

               char* token,*word,*ptr,*curr_pos;

               char buffer[MAP_MAX_LEN];

               strcpy(buffer,Map);

               token=strtok(buffer,″,″);

               curr_pos=activate_buffer;

               while(token!=NULL){

                       if((ptr=strchr(token,′/′))==NULL){

                                retvalue=SRCTRL_ERROR_MAPFORMAT;

                                goto_exit;

               }

               *ptr=′\0′;

               word=AllTrim(token);

               strcpy(curr_pos,word);

               curr_pos+=strlen(word)+1;

               token=strtok(NULL,″,″);

       }

       *(curr_pos)=′\0′;

       asrRecSecActiveWords(SR.hAsr,SR.hCtx,
ASRREC_ABSOLUTEACTIVATION,NULL,activate_buffer);

               RecStart();

       }
				
				<dp n="d588"/>
      dwStartTime=timeGetTime();

      dwEndTime=dwStartTime+(time_100ms*100);

      m_WasResult=FALSE;

                 while(timeGetTime()<dwEndTime){

              if(dwFlags &amp; SR_ENABLE){

                      if(PeekMessage(&amp;msg,m_hWnd,ASRM_NOTIFY,
ASRM_NOTIFY,PM_NOREMOVE)){

                             LastResult=(LPASRRESULT)msg.lParam;

                             break_event=SR_EVENT;

                             break;

                      }

                      if(m_WasResult){

                             break_event=SR_EENT;

                             break;

                      }

               }

               if((dwFlags &amp; MIDI_ENABLE) &amp;&amp;

                       (WaitForSingleOtject(hMidiEvents[NUM_MIDI_EVENTS-
1],0))!=WAIT_TIMEOUT){

                       break_event=MIDI_EVENT;

                       break;

               }

       }

       if(dwFlags&amp;SR_ENABLE)

               RecStop();

       switch(break_event){

       case MIDI_EVENT:

               retvalue=0;

               for(i=0;i<NUM_MIDI_EVENTS-1;i++){

                         if(WaitForSingleObject(hMidiEvents[i],
0)==WAIT_OBJECT_0)

                                 retvalue|=(l<<i);

               }

               break;

       case SR_EVENT:

               char result[MAP_MAX_LEN];

               char buffer[MAP_MAX_LEN];
				
				<dp n="d589"/>
            strcpy(buffer,Map);

            char* token,*word,*map_value,*ptr;

            strcpy(result,LastResult->szzUtterances);

            UpperCase(result);

            token=strtok(buffer,″,″);

            while(token!=NULL){

                    UpperCase(token);

                    if((ptr=strchr(token,′/′})==NULL){

                              retvalue=SRCTRL_ERROR_MAPFORMAT;

                              goto_exit;

                    }

                    *ptr=′\0′;

                    word=token;

                    map_value=ptr+1;

                    word=AllTrim(word);

                    map_value=AllTrim(map_value);

                    if(strcmp(result,word)==0){

                           retvalue=atoi(map_value);

                           goto_exit;

                    }

                    token=strtok(NULL,″,″);

          }

          retvalue=SRCTRL_ERROR_NOTFOUND;

          break;

  case TIME_OUT:

          retvalue=SRCTRL_ERROR_TIMEOUT;

          break;
  }
_exit;

    if(dwFlags &amp; MIDI_ENABLE){

             for(i=0;i<NUM_MIDI_EVENTS;i++)

                 CloseHandle(hMidiEvents);

     }

     return retvalue;
}
				
				<dp n="d590"/>
void CSRCtrl::UpperCase(LPCTSTR str){

      char*ptr=(char*)str;

      while(*ptr){

              *ptr=touPper(*ptr);

              ptr++;

      }
}
char* CSRCtrl::AllTrim(char* str){

      char*ptr;

      while(*str==′\t′| | *str==′′)

              str++;

      ptr=str+strlen(str)-1;

      while((*ptr==′\t′| | *ptr===′′) &amp;&amp; str!=ptr)

              ptr--;

      *(ptr+1)=′\0′;

      return str;
}
short CSRCtrl::GetNbrPhrases (){

      if(LastResu1t==NULL)

              return 0;

      else

              return LastResult->wN;
}
BSTR CSRCtrl::GetPhrase(short PhraseNbr){

      CString strResult;

      if(LastResult==NULL)

              strResult=″″;

      else if(PhraseNbr>LastResult->wN | | PhraseNbr<1)

              strResult=″″;

      else{

              char*ptr=(char*)LastResult->szzUtterances;

              for(int i=0;i<PhraseNbr-1;i++){

                      while(*ptr)ptr++;
				
				<dp n="d591"/>
                       ptr++;

             }

             strResult=ptr;

    }

    return strResult,AllocSysString();
}
short CSRCtrl∷GetPhraseConfLevel(short PhraseNbr)(

      if(LastResult==NULL)

              return -1;

      if(PhraseNbr>LastResult->wN||PhraseNbr<1)

              return -1;

      return *(LastResult->lpwConfidences+PhraseNbr-1);
}
Long CSRCtrl∷SetMinConfidenceLevel(short MinConfidenceLevel){

      M_MinConfidenceLevel=MinConfidenceLevel;

      Return 0;
}
}
Long CSRCtrl∷CtxCreateFromList(LPCTSTR WordList){

      Char buffer(512);

      CString word;

      strcpy(buffer,wordlist;

      char seps()=″,\t\n″;

      char  *token;

      DWORD status;

      token=strtok(buffer,seps);

      while(token!=NULL){

         word=token;

         word.TrimLeft();

         word.TrimRight();

         status-asrCtxAddWord(SR.hCtx,NULL,″Word″,word);

         token=strtok(NULL,seps);

      }

      Return 0;
}
				
				<dp n="d592"/>
#include "Stdafx.h"
#include "work.h"
#include "SrCtl.h"
#include "PrmPrpPg.h"
#include "SRPpg.h"
#ifdef_DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[]=_FILE_;
#endif
IMPLEMENT_DYNCREATE(CSRPropPage,COlePropertyPage)
BEGIN_MESSAGE_MAP(CSRPropPage,COlePtopertyPage)

      //((AFX_MSG_MAP(CSRPropPage)

      ON_CBN_SELCHANGE(IDC_CONTEXT,OnSelchangeContext)

      ON_CBN_SELCHANGE(IDC_DATABASE,OnSelchangeDatabase)

      ON_CBN_SELCHANGE(IDC_USER,OnSelchangeUser)

      //}}AEX_MSG_MAP
END_MESSAGE_MAP()
////////////////////////////////////////////////////////////////////////////
/
// Initialize class factory and guid
IMPLEMENT_OLECREATE_EX(CSRPropPage,"NEWSR.SRPropPage.1",

      0x528c0224,0x72ec,0x11d0,0xa6,0xce,0,0x40,0x33,0x2d,0x1,
0xc5)
////////////////////////////////////////////////////////////////////////////
/
// CSRPropPage∷CSRPropPageFactory∷UpdateRegistry-
// Adds or removes system registry entries for CSRPropPage
BOOL CSRPropPage∷CSRPropPageFactory∷UpdateRegistry(BOOL bRegister)
{

      if(bRegister)

             return
AfxOleRegisterPropertyPageClass(AfxGetInstanceHandle(),
				
				<dp n="d593"/>
                      m_clsid,ICS_SR_PPG);

      else

              return AfxOleUnregisterClass(m_clsid,NULL);
}
////////////////////////////////////////////////////////////////////////////
/
// CSRPropPage∷CSRPropPage - Constructor
CSRPropPage∷CSRPropPage():

      COlePropertyPage(IDD,IDS_SR_PPG_CAPTION)
{

      //{{AFX_DATA_INIT(CSRPropPsge)

      m_DataBase=_T("");

      m_User=_T("");

      m_Context=_T("");

      m_Mode=0;

      m_OpenAttr=0;

      //}}AFX_DATA_INIT

      ModeInfoList=NULL;
}
CSRPropPage∷-CSRPropPage(){

      if(ModeInfoList)

              free(ModeInfoList);
}
////////////////////////////////////////////////////////////////////////////
/
// CSRPropPage∷DoDataExchange - Moves data between page and properties
void CSRPropPage∷DoDataExchange(CDataExchange* pDX)
{

      //{{AFX_DATA_MAP(CSRPropPage)

      DDP_CBString(pDX,IDC_DATABASE,m_DataBase,_T("DataBase"));

      DDX_CBString(pDX,IDC_DATABASE,m_DataBase);

      DDP_CBString(pDX,IDC_USER,m_User,_T("User"));

      DDX_CBString(pDX,IDC_USER,m_User);

      DDP_CBString(pDX,IDC_CONTEXT,m_Context,_T("Context"));

      DDX_CBString(pDX,IDC_CONTEXT,m_Context);
				
				<dp n="d594"/>
       DDP_CBIndex(pDX,IDC_MODES,m_Mode,_T("Mode"));

       DDX_CBIndex(pDX,IDC_MODES,m_Mode);

       DDP_CBIndex(PDX,IDC_ATTRI3,m_OpenAttr,_T("OpenAttr")};

       DDX_CBIndex(pDX,IDC_ATTRIB,m_OpenAttr);

       //}}AFX_DATA_MAP

     DDP_PostProcessing(pDX);
///Tools
void CSRPropPage∷FillDataBases(){

    CString tmp;

      DWORD size;

      CComboBox* CurrComboBox;

      char* Suff,*ptr;

      SetControlStatus(IDC_DATABASE,TRUE);

      asrDbList(NULL,&amp;size);

      Buff=(char*) malloc(size);

      ptr=Buff;

      asrDbList(Buff,&amp;size);

      CurrComboBox=(CComboBox*)GetDlgItem(IDC_DATABASE);

      CurrComboBox->ResetContent();

      while((tmp=GetNextString(&amp;ptr))!="")

              CurrCumboBox->AddString(tmp);

      if(Buff)

              free(Buff);

      CurrComboBox->SetCurSel(CurrComboBox->FindString(-1,m_DataBase)};
}
void CSRPropPage∷FillUsers(){

      CString tmp,DbName;

      DWORD size;

      CComboBox* CurrComboBox;

      HDB hDb;

      char* Buff,*ptr;

      SetControlStatus(IDC_USER,TRUE);

      CurrComboBox=(CComboBox*)GetDlgItem(IDC_DATABASE);

      if(CurrComboBox->GetCurSel()==CB_ERR)

             return;

      CurrComboBox->GetLBText(CurrComboBox->GetCurSel(),DbName);

      hDb=asrDbOpen(DbName);

      asrDbGetInfo(hDb,ASRDBINFO_USERS,NULL,&amp;size);

      Buff=(char*)malloc(size);

      asrDbGerInfo(hDb,ASRDBINFO_USERS,Buff,&amp;size);
				
				<dp n="d595"/>
     ptr=Buff;

     CurrComboBox=(CComboBox*)GetDlgItem(IDC_USER);

     CurrComboBox->ResetContent();

     while((tmp=GetNextString(&amp;ptr))!="")

             CurrComboBox->AddString(tmp);

     if(Buff)

             free(Buff);

     if(hDb>ASRERR_MAXERR)

             asrDbClose(hDb);

     CurrComboBox->SetCurSel(CurrComboBox->FindString(-1,m_User));
void CSRPropPage∷FillContexts(){

      CString tmp,user,contaxt,DbName;

      DWORD size;

      CComboBox* CurrComboBox;

      char* Buff,*ptr;

      HDB hDb;

      SetControlStatus(IDC_CONTEXT,TRUE);

      CurrComboBox=(CComboBox*)GetDlgItem(IDC_DATABASE);

      if(CurrComboBox->GetCurSel()==CB_ERR)

              return;

      CurrComboBox->GetLBText(CurrComboBox->GetCurSel(),DbName);

      CurrComboBox=(CComboBox*)GetDlgItem(IDC_USER);

      if(CurrComboBox->GetCurSel()==CB_ERR)

              return;

      CurrComboBox->GetLBText(CurrComboBox->GetCurSel(),user);

      CurrComboBox=(CComboBox*)GetDlgItem(IDC_CONTEXT);

      hDb=asrDbOpen(DbName);

      ASRERROR a=asrUsrGetInfo(hDb,user,ASRUSRINFO_CONTEXTS,NULL,
&amp;size);

      Buff=(char*)malloc(size);

      a=asrUsrGetInfo(hDb,user,ASRUSRINFO_CONTEXTS,Buff,&amp;size);

      ptr=Buff;

      CurrComboBox->ResetContent();

      while((tmp=GetNextString(&amp;ptr))!="")

              CurrComboBox->AddString(tmp);

      if(Buff)

              free(Buff);
				
				<dp n="d596"/>
      if(hDb>ASRERR_MAXERR)

              asrDbClose(hDb);

      CurrComboBox->SetCurSel(CurrComboBox->FindString(-1,m_Context));
////////////////////////////////////////////////////////////////////////////
/
// CSRPropPage message handlers
BOOL CSRPropPage∷OnInitDialog()
{

       HCURSOR SaveCursor;

       SaveCursor=SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));

       COlePropertyPage∷OnInitDialog();

       FillDataBases();

       FillUsers();

       FillContexts();

       FillModes();

       FillOpenAttr();

       SetControlStatus(IDC_DATABASE,TRUE);

       SetCursor(SaveCursor);

       return FALSE;
}
void CSRPropPage∷OnSelchangeContext()
{
void CSRPropPage∷OnSelchangeDatabase()
{

      HCURSOR SaveCursor;

      SaveCursor=SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT));

      FillUsers();

      FillContexts();

      FillModes();

      SetCursor(SaveCursor);
}
void CSRPropPage∷OnSelchangeUser()
{

      FillContexts();
				
				<dp n="d597"/>
void CSRPropPage∷FillModes()
{

      CString tmp,DbName;

      DWORD size;

      CComboBox* CurrComboBox;

      HDB hDb;

      HASR hAsr;

      SetControlStatus(IDC_MODES,TRUE);

      CurrComboBox=(CComboBox*)GetDlgItem(IDC_DATABASE);

      if(CurrComboBox->GetCurSel()==CB_ERR)

             return;

      CurrComboBox->GetLBText(CurrComboBox->GetCurSel(),DbName);

      hDb=asrDbOpen(DbName);

      hAr=asrRecOpenEx(hDb,"Win32",NULL,NULL,NULL,NULL,0);

      asrRecGetModeInfo(hAsr,NULL,&amp;size);

      ModeInfoList=(PMODEINFOLIST)malloc(size);

      asrRecGetModeInfo(hAsr,ModeInfoList,&amp;size);

      CurrComboBox=(CComboBox*)GetDlgItem(IDC_MODES);

      CurrComboBox->ResetContent();

      for(int i=0;i<ModeInfoList->nbrOfModes;i++)

              CurrComboBox->InsertString(ModeInfoList->info[i].ModeType,

              ModeInfoList->info[i].szName);

      if(hDb>ASRERR_MAXERR)

              asrDbClose(hDb);

      if(hAsr>ASRERR_MAXERR)

              asrRecClose(hAsr);
}
void CSRPropPage∷FillOpenAttr()
{

      CComboBox* CurrComboBox;

      CurrCcmboBox=(CComboBox*)GetDlgItem(IDC_ATTRIB);

      CurrCcmboBox->InsertString(-1,"Read access");

      CurrCcmboBox->InsertString(-1,"Write access");

      SetControlStatus(IDC_DATABASE,TRUE);
}
				
				<dp n="d598"/>
#include ″stdafx.h″
#include ″work.h″
CString GetNextString(char** szzString)

      CString RetString=*szzString;

      *szzString+=RetString. GetLength() +1;

      return RetString;
				
				<dp n="d599"/>
// AcqPropage.h:header file
//
////////////////////////////////////////////////////////////////////////////
/
// CAcqPropPage:Property page dialog
#include "work.h"
class CAcqPropPage:public COlePropertyPage
{

    DECLARE_DYNCREATE(CAcqPropPage)

    DECLARE_OLECREATE_EX(CAcqPropPage)
// Constructors
public:

    CString m_DataBase;

    DWORD nFormats;

    CAcqPropPage();

    -CAcqPropPage();
// Tools

    PWAVEFORMAT CurrWaveFormat;
// Dialog Data

    //{{AFX_DATA(CAcqPropPage)

    enum{IDD=IDD_ACQPROPPAGE};

    CEdit m_EditDescription;

    CComboBox    m_WaveList;

    CButton      m_WaveFormat;

    CButton      m_RealTime;

    int m_WaveIndex;

    int m_XAcqMode;

    int m_XSRTransfer;

    //}}AFX_DATA
// Implementation

   void FillWF(int mode);

   void FillID(int mode);
protected:

   virtual void DoDataExchange(CDataExchange* pDX);       // DDX/DDV
support
				
				<dp n="d600"/>
// Message maps
protected:

    //({AFX_MSG(CAcqPropPage)

    virtual BOOL OnInitDialog();

    afx_msg void OnWaveformat();

    afx_msg void OnDeviceid();

    afx_msg void OnSelchangeWavelist();

    afx_msg void OnRealtime();

    afx_msg void OnNonrealtime();

    //}}AFX_MSG

    DECLARE_MESSAGE_MAP()
private:

    void SaveAcqMode();

    enum FillType(FILL_BYDEVICEID,FILL_BYNBRWAVEFORMAT);

    void FillDescription(FillType ftype,WORD wWhat);

    void CheckAcqGroup(BOOL Enable);
};
				
				<dp n="d601"/>
// NewSR.h:main header file for NEWSR.DLL
#if!defined(_AFXCTL_H_)

    #error include ′afxctl.h′ before including this file
#endif
#include "resource.h"         // main symbols
////////////////////////////////////////////////////////////////////////////
/
// CNewSRApp:See NewSR.cpp for implementation.
class CNewSRApp:public COleControlModule
{
public:

    BOOL InitInstance();

    int ExitInstance();

    HICON SRIcon;
};
extern const GUID CDECL tlid;
extern const WORD_wVerMajor;
extern const WORD_wVerMinor;
				
				<dp n="d602"/>
// PrmPrpPq.h:header flie
//
#include "work.h"
#include "resource.h"
#include <afxcmn.h>
////////////////////////////////////////////////////////////////////////////
/
// CPrmPrpPg:Property page dialog
class CPrmPrpPg:public COlePropertyPage
{

    DECLARE_DYNCREATE(CPrmPrpPg)

    DECLARE_OLECREATE_EX(CPrmPrpPg)
// Constructors &amp;&amp; Destructor
public:

     CPrmPrpPg();

     -CPrmPrpPg();
//Tools

    PPARAMINFOLIST ParamInfo;
// Dialog Data

     //{{AFX_DATA(CPrmPrpPg)

     enum{IDD=IDD_PARAMINFO};

     CListBox m_Result;

     CListBox m_ListWords;

     CButton      m_SetDef;

     CSliderCtrl  m_Slider;

     CStatic      m_CurrentValue;

     CStatic      m_Min;

     CStatic      m_Max;

     CStatic      m_Description;

     CListBox m_Params;

     CString      m_DataBase;

     int m_Control;

     //}}AFX_DATA
// Implementation
protected:

    virtual void DoDataExchange(CDataExchange* pDX);        // DDX/DDV
support
				
				<dp n="d603"/>
// Message maps
protected:

     //{{AFX_MSG(CPrmPrpPg)

     virtual BOOL OnInitDialog();

     afx_msg void OnSelchangeListl();

     afx_msg void OnHScroll(UINT nSBCode,UINT nPos,CScrollBar*
pScrollBar);

     afx_msg void OnDefaultvalue();

     //}}AFX_MSG

     DECLARE_MESSAGE_MAP()
};
				
				<dp n="d604"/>
// SRCtl.h :Declaration of the CSRCtrl OLE control class.
////////////////////////////////////////////////////////////////////////////
/
// CSRCtrl:See SRCtl.cpp for implementation.
#include "work.h"
class CSRCtrl:public COleControl
{

    DECLARE_DYNCREATE(CSRCtrl)
private:

    long RecStop();

    long RecStart();

    void ChangeStart();

    CBitmap SRBitMap;
// Constructor
public:

    int MemChange(void* Buffer,char d,char s,DWORD dwLength);

    void InitDefaults();

    int PostPropExchange(CPropExchange* pPX);

    int PrePropExchange(CPropExchange* pPX);

    void SRCtrlInit();

    CSRCtrl();

    ASRERROR CheckError(long code);
// Overrides

    // Drawing function

    virtual void OnDraw(

                    CDC* pdc,const CRect&amp; rcBounds,const CRect&amp;
rcInvalid);

    // Persistence

    virtual void DoPropExchange(CPropExchange* pPX);

    // Reset control state

    virtual void OnResetState();

    virtual BOOL OnSetExtent(LPSIZEL lpSizeL);
				
				<dp n="d605"/>
    // Tools

    SRStruct SR;
//    int InitProperties();

    PWAVEFORMAT PWayeFormats;

    PERSIST_PRROP* PersistProp;
// Implementation
protected:

     -CSRCtrl();

     DECLARE_OLECREATE_EX(CSRCtrl)      // Class factory and guid

     DECLARE_OLETYPELIB(CSRCtrl)        // GetTypeInfo

     DECLARE_PROPPAGEIDS(CSRCtrl)       // Property page IDs

     DECLARE_OLECTLTYPE(CSRCtrl)           // Type name and misc status
// Message maps

    //{{AFX_MSG(CSRCtrl)

    afx_msg LRESULT OnConfirm(WPARAM wParam,LPARAM lParam);

    afx_msg LRESULT OnError(WPARAM wParam,LPARAM lParam);

    afx_msg LRESULT OnGainRequest(WPARAM wParam,LPARAM lParam);

    afx_msg LRESULT OnProgress(WPARAM wParam,LPARAM lParam);

    afx_msg LRESULT OnPrompt(WPARAM wParam,LPARAM lParam);

    afx_msg LRESULT OnState(WPARAM wParam,LPARAM lParam);

    afx_msg LRESULT OnTrained(WPARAM wParam,LPARAM lParam);

    afx_msg LRESULT OnUpdate(WPARAM wParam,LPARAM lParam);

    afx_msg LRESULT OnSRNotify(WPARAM wParam,LPARAM lParam);

    //}}AFX_MSG

    DECLARE_MESSAGE_MAP()
// Dispatch maps

    //{(AFX_DISPATCH(CSRCtrl)

    CString m_DataBase;

    afx_msg void OnDataBaseChanged();

    CString m_User;

    afx_msg void OnUserChanged();

    CString m_Context;

    afx_msg void OnContextChanged();

    short m_Mode;

    afx_msg void OnModeChanged();
				
				<dp n="d606"/>
    short m_OpenAttr;

    afx_msg void OnOpenAttrChanged();

    long m_XAcqMode;

    afx_msg void OnXAcgModeChanged();

    long m_XWaveIndex;

    afx_msg void OnXWaveIndexChanged();

    BOOL m_SaveCtx;

    afx_msg void OnSaveCtxChanged();

    long m_control;

    afx_msg void OnControlChanged();

    afx_msg void ShowProperties();

    afx_msg long RecAcqWaveBuffer(LPCTSTR lpBuffer,long dwLength);

    afx_msg long RecGetState();

    afx_msg BSTR GetWords(short Type,LPCTSTR Class);

    afx_msg long ActivateWords(short Type,LPCTSTR Class,LPCTSTR Words);

    afx_msg BSTR GetActiveWords();

    afx_msg long Init();

    afx_msg long Start();

    afx_msg long Stop();

    afx_msg long Close();

    afx_msg long GetParam(long ParamType);

    afx_msg long SetParam(long ParamType,long NewValue);

    afx_msg long AddUserWord(LPCTSTR Class,LPCTSTR Word);

    afx_msg long CtxActivate(BOOL Activate);

    afx_msg long DictClose(BOOL SaveChanges);

    afx_msg long DictCopy(LPCTSTR Language,LPCTSTR DictSrc,LPCTSTR
DictDest);

    afx_msg long DictCreate(LPCTSTR Language,LPCTSTR Dictionary);

    afx_msg long DictDelete(LPCTSTR Language,LPCTSTR Dictionary);

    afx_msg long DictDeleteException(LPCTSTR Word);

    afx_msg VARIANT DictGetInfo(short Type);

    afx_msg BSTR DictGetTranscription(LPCTSTR Word);

    afx_msg long DictOpen(LPCTSTR Language,LPCTSTR Dictionary,short
Attrib);

    afx_msg long DictRename(LPCTSTR Language,LPCTSTR DictSrc,LPCTSTR
DictDest);

    afx_msg long DbClose();

    afx_msg long DbCreate(LPCTSTR DbName,LPCTSTR Path);

    afx_msg long DbDelete(LPCTSTR DbName);

    afx_msg long DbExport(short Type,LPCTSTR LangOrUser,LPCTSTR Name,
LPCTSTR Path);

    afx_msg VARIANT DbGetCaps(LPCTSTR Environment,long Type);

    afx_mag VARIANT DbGetInfo(short Type);
				
				<dp n="d607"/>
   afx_msg long DbGetParamInfo();

   afx_msg long DbInstall(LPCTSTR SetupFile, long hWnd);

   afx_msg BSTR DbList();

   afx_msg long DbOpen(LPCTSTR DbName);

   afx_msg long DbUnInstall(short Type,LPCTSTR ObjectName);

   afx_msg long RecAcqClose();

   afx_msg short RecAcqGetSignalLevel();

   afx_msg long RecAcqOpenEx(short WaveFormIndex,short Type);

   afx_msg long RecBreak();

   afx_msg long RecClose();

   afx_msg long RecSetMode(short NewMode);

   afx_msg long UsrCopy(LPCTSTR UserSrc,LPCTSTR UserDest);

   afx_msg long UsrEnable(LPCTSTR UserName,LPCTSTR Language,short
Type);

   afx_msg long UsrCreate(LPCTSTR UserName);

   afx_msg long UsrDelete(LPCTSTR UserName);

   afx_msg VARIANT UsrGetInfo(LPCTSTR UserName,short Type);

   afx_msg long UsrIndependent(LPCTSTR UserName,LPCTSTR Language);

   afx_msg long UsrRegister(LPCTSTR User,short Type,LPCTSTR Name);

   afx_msg long UsrRename(LPCTSTR OldName,LPCTSTR NewName);

   afx_msg long UsrUnregister(LPCTSTR User,short Type,LPCTSTR Name);

   afx_msg long CtxCiose(BOOL Save);

   afx_msg long CtxCopy(LPCTSTR SrcUser,LPCTSTR SrcContext,LPCTSTR
DestUser,LPCTSTR DestContext);

   afx_msg long CtxCreate(LPCTSTR User,LPCTSTR Language,LPCTSTR Syntax,
LPCTSTR Context);

   afx_msg long CtxDelete(LPCTSTR User,LPCTSTR Context);

   afx_msg long CtxDeleteWord(LPCTSTR Class,LPCTSTR Word);

   afx_msg long CtxExport(LPCTSTR User,LPCTSTR Format,LPCTSTR Context);

   afx_msg long CtxOpen(LPCTSTR User,LPCTSTR Context,short Attrib);

   afx_msg long CtxRename(LPCTSTR User,LPCTSTR OldCtx,LPCTSTR NewCtx);

   afx_msg long WaitForEvent(LPCTSTR Map,short time_100ms,long
dwFlags);

   afx_msg short GetNbrPhrases();

   afx_msg BSTR GetPhrase(short PhraseNbr);

   afx_msg short GetPhraseConfLevel(short PhraseNbr);

   //}}AFX_DISPATCH

   DECLARE_DISPATCH_MAP()

   afx_msg void AboutBox();

   HGLOBAL SuppProp;

   HGLOBAL SuppPropDef;
				
				<dp n="d608"/>
// Event maps

    //{{AFX_EVENT(CSRCtrl)

    void FireResult(LPCTSTR BestUtterance,short BestConfidence,short
nbrUtterances)

          (FireEvent(eventidResult,EVENT_PARAM(VTS_BSTR VTS_I2 VTS_I2),
BestUtterance,BestConfidence,nbrUtterances);)

   void FireRecError(long id,LPCTSTR ErrorString)

        (FireEvent(eventidRecError,EVENT_PARAM(VTS_I4  VTS_BSTR),id,
ErrorString);)

    void FireChangeState(short NewState)

          {FireEvent(eventidChangeState,EVENT_PARAM(VTS_I2),NewState);}

    //}}AFX_EVENT

    DECLARE_EVENT_MAP()
// Dispatch and event IDs
public:

     BOOL m_WasResult;

     char* AllTrim(char* str);

     void UpperCase(LPCTSTR str);

     LPASRRESULT LastResualt;

     enum{

     //{{AFX_DISP_ID(CSRCtrl)

     dispidDataBase=1L,

     dispidUser=2L,

     dispidContext=3L,

     dispidMode=4L,

     dispidOpenAttr=5L,

     dispidSaveCtx=8L,

     dispidShowProperties=10L,

     dispidRecAcqWaveBuffer=11L,

     dispidRecGetState=12L,

     dispidGetWords=13L,

     dispidActivateWords=14L,

     dispidGetActiveWords=15L,

     dispidInit=16L,

     dispidStart=17L,

     dispidStop=18L,

     dispidClose=19L,

     dispidGetParam=20L,

     dispidSetParam=21L,

     dispidAdUserWord=22L,
				
				<dp n="d609"/>
dispidCtxActivate=23L,
dispidDictClose=24L,
dispidDictCopy=25L,
dispidDictCreate=26L,
dispidDictDelete=27L,
dispidDictDeleteException=28L,
dispidDictGetInfo=29L,
dispidDictGetTranscription=30L,
dispidDictOpen=31L,
dispidDictRename=32L,
dispidDbClose=33L,
dispidDbCreate=34L,
dispicDbDelete=35L,
dispidDbExport=36L,
dispidDbGetCaps=37L,
dispidDbGetInfo=38L,
dispidDbGetParamInfo=39L,
dispidDbInstall=40L,
dispidDbList=41L,
dispidDbOpen=42L,
dispidDbUnInstall=43L,
dispidRecAcqClose=44L,
dispidRecAcqGetSignalLevel=45L,
dispidRecAcqOpenEx=46L,
dispidRecBreak=47L,
dispidRecClose=48L,
dispidRecSetMode=49L,
dispidUsrCopy=50L,
dispidUsrEnable=51L,
dispidUsrCreate=52L,
dispidUsrDelete=53L,
dispidUsrGetInfo=54L,
dispidUsrIndependent=55L,
dispidUsrRegister=56L,
dispidUsrRename=57L,
dispidUsrUnregister=58L,
dispidCtxClose=59L,
dispidCtxCopy=60L,
dispidCtxCreate=61L,
dispidCtxDelete=62L,
dispidCtxDeleteWord=63L,
dispidCtxExport=64L,
disoidCtxOpen=65L,
				
				<dp n="d610"/>
dispidCtxRename=66L,
dispidWaitForEvent=67L,
dispidGetNbrPhrases=68L,
dispidGetPhrase=69L,
dispidGetPhraseConfLevel=70L,
eventidResult=1L,
eventidRecError=2L,
eventidChangeState=3L,
//})AFX_DISP_ID
};
				
				<dp n="d611"/>
// SRPpg.h:Declaration of the CSRPropPage property page class.
////////////////////////////////////////////////////////////////////////////
// CSRPropPage:See SRPpg.cpp.cpp for implementation.
#include"work.h"
class CSRPropPage:public COlePropertyPage
{

    DECLARE_DYNCREATE(CSRPropPage)

    DECLARE_OLECREATE_EX(CSRPropPage)
// Constructor
public:

    CSRPropPage();
// Destructor

    -CSRPropPage();
// Tools

    void FillDataBases();

    void FillUsers();

    void FillContexts();

    void FillModes();

    void FillOpenAttr();

    PMODEINFOLIST ModeInfoList;
// Dialog Data

    //{{AFX_DATA(CSRPropPage)

    enum{IDD=IDD_PROPPAGE_SR};

    CString     m_DataBase;

    CString     m_User;

    CString     m_Context;

    int         m_Mode;

    int         m_OpenAttr;

    //}}AFX_DATA

    //Implementation
protected:

    virtual void DoDataExchange(CDataEXchange* pDX);     // DDX/DDV support
// Message maps
protected:

       //{{AFX_MSG(CSRPropPage)

       virtual BOOL OnIhitDialog();
				
				<dp n="d612"/>
afx_msg void OnSelchangeContext();
afx_msg void OnSelchangeDatabase();
afx_msg void OnSelchangeUser();
//})AFX_MSG
DECLARE_MESSAGE_MAP()
安装源代码
unit Installation;
interface
uses
   Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,DiaLogs,
   StdCtrls,Buttons,NEWSRLib_TL3,OleCtrls,XMIDILib_TLB,
ExtCtrls,PDBEngine;
type
   TMainInstallForm=class(TForm)

   ActivateButton:TBitBtn;

   XMidil:TXMidi;

   SRl:TSR;

   Timerl:TTimer;

   procedure FormCreate(Sender:TObject);

   procedure ExitButtonClick(Sender:TObject);

   procedure ActivateButtonClick(Sender:TObject);

   procedure BitBtn2Click(Sender:TObject);

   procedure FormClose(Sender:TObject;var Action:TCloseAction);

   procedure TimerlTimer(Sender:TObject);
   private

   {Private declarations}
   public

   {Public declarations}

   CurrentPath    :string;

   CreatorPath    :string;

   DatabasePath   :string;

   GraphicsPath   :string;

   AudioPath      :string;

   UsagePath      :string;

   PDBEngine      :TPDBEngine;

   function GetCurrentPath(CurrentExeName:string):string;
   end;
var
   MainInstallForm:TMainInstallForm;
implementation
uses   SerialInstall,ToyInstall;
(SR*.DEM)
				
				<dp n="d615"/>
procedure TMainInstallForm.FormCreate(Sender:TObject);
begin

  //WindowState:=wsMaximized;

  Xmidil.StartHUB;

  SRl.Init;

      //Fill Pathes

      CurrentPath    :=GetCurrentPath(Appiication.ExeName);

      CreatorPath    :=
Copy(CurrentPath,l,Length(CurrentPath)-Length(′Executables\′));

      DatabasePath   :=CreatorPath + ′PESTO\DATABASE\′;

      GraphicsPath   :=CreatorPath + ′PESTO\GRAPHICS\′;

      AudioPath      :=CreatorPath + ′PESTO\AUDIO\′;

      UsagePath      :=CreatorPath + ′PESTO\USAGE\′;

      PDBEngine      :=TPDBEngine.create(self);

      PDBEngine. DataBasePath :=DataBasePath;

      PDBEngine.LoadConfiguration;
end;
function  TMainInstallFom. GetCurrentPath(CurrentExeName:string):
string;
var

  i:integer;
begin

  i:=Length(CurrentExeName);

  While i>0 do

  begin

      if Copy(CurrentExeName,i,1) =′\′then i:=0

      else

        begin

          i:=i-1;

          CurrentExeName:=Copy(CurrentExeName,l,i);

        end;

    end;

    Result:=CurrentExeName;
end;
procedure TMainInstallForm.ExitButtonClick(Sender:TObject);
begin

  Close;
end;
procedure TMainInstallForm.ActivateButtonClick(Sender:TObject);
begin
				
				<dp n="d616"/>
  Hide;

  SerialInstallForm.WindowState:=wsMaximized;

  SerialInstallForm.Show;

  SerialInstallForm.Section:=1;

  SerialInstallForm.ShowSection(1);
end;
procedure TMainInstallForm.BitBtn2Click(Sender:TObject);
begin
  Hide;
  ToyInstallForm.WindowState:=wsMaximized;
  ToyInstallForm.Show;
  ToyInstallForm.Section:=1;
  ToyInstallForm.ShowSecrion(1);
end;
procedure TMainInstallForm.FormClose(Sender:TObject;
  var Action:TCloseAction);
begin
  Xmidil.StopHUB;
  SRl.Close;
  PDBEngine.Free;
  Winexec(PChar(CurrentPath+′StoryTeller.exe′),sw_show);
end;
procedure TMainInstallForm.TimerlTimer(Sender:TObject);
begin
   ActivateButtonClick(nil);
   Timerl.Enabled:=False;
end;
end.
				
				<dp n="d617"/>
program PESTOInstallation;
uses
  Forms,
  Installation in ′Installation.pas′{MainInstallForm},
  SerialInstall in ′SerialInstall.pas′{SerialInstallForm},
  ToyInstall in ′ToyInstall.pas′{ToyInstallForm},
  ToySetup in ′ToySetup.pas′{ToySetupForm},
  PDBEngine in ′PDBEngine.pas′;
{SR*.RES}
begin
   Application.Initialize;
   Application.CreateForm{TMainInstallForm,MainInstallForm};
   Application.CreateForm{TSerialInstallForm,SerialInstallForm};
   Application.CreateForm{TToyInstallForm,ToyInstallForm};
   Application.CreateForm{TToySetupForm,ToySetupForm};
   Application.Run;
end.
				
				<dp n="d618"/>
unit SerialInstall;
interface
uses
  Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs,
  ExtCtrls,Jpeg,ComCtrls;
typeTSerialInstallForm=class(TForm)

  Imagel:TImage;

  TitleImage:TImage;

  Label1Image:TImage;

  Label2Image:TImage;
  Label3Image:TImage;

  Ball1Image:TImage;

  Ball2Image:TImage;

  Ball3Image:TImage;

  BallV1Image:TImage;

  BallV2Image:TImage;

  BallV3Image:TImage;

  Big2Image:TImage;

  Big3Image:TImage;

  BiglImage:TImage;

  Animation1:TAnimate;

  Animation2:TAnimate;

  Animation3:TAnimate;

  NextImage:TImage;

  CutBackImage:TImage;

  CutNextImage:TImage;

  ErrorImage:TImage;

  ClipErrorImage:TImage;

  XErrorAnimate:TAnimate;

  OopsErrorAnimate:TAnimate;

  RetryErrorImage:TImage;

  ExitErrorImage:TImage;

  Label4Image:TImage;

  Ball4Image:TImage;

  HelpImage:TImage;

  ResetImage:TImage;

  procedure NextImageClick(Sender:TObject);

  procedure CutNextImageClick(Sender:TObject);

  procedure CutBackImageClick(Sender:TObject);
				
				<dp n="d619"/>
  procedure FormCreate(Sender:TObject);

  procedure ClipErrorImageClick(Sender:TObject);

  procedure ExitErrorImageClick(Sender:TObject);

  procedure RetryErrorImageClick(Sender:TObject);
  private

  {Private declarations}
  public

  {Public declarations}

  Section:Integer;

  procedure ShowSection(Value:Integer);
  end;
var

   SerialInstallForm:TSerialInstallForm;
implementation
uses Installation,ToyInstall,ToySetup;
{SR* DFM}
procedure TSerialInstallForm.NextImageClick(Sender:TObject);
begin

  ShowSection(2);

  Section:=2;
end;
procedure TSerialInstallForm.CutNextImageClick(Sender:TObject);
var
  HubAck:integer;
begin
   Section:=Section+1;
   if Section=5 then

    begin

        HubAck:=MainInstallForm.Xmidil.HubReset(8*16+2);

        if HubAck<>1 then

        begin

           sleep(200);

           HubAck:=MainInstallForm.Xmdil.HubReset(8*16+2);

        end;

        if HubAck=1 then

          begin
				
				<dp n="d620"/>
           Hide;

           ToySetupForm.WindowState:=wsMaximized;

           ToySetupForm.Show;

           ToySetupForm.Section:=1;

           ToySetupForm.ShowSection(1);

         end

       else

         begin

           Section:=5;

           ShowSection(Section);

         end;

    end

    else

     ShowSection(Section);
end;
procedure TSerialInstallForm.CutBackImageClick(Sender:TObject);
begin

    Section:=Section-1;

    ShowSection(Section);
end;
procedure TSerialInstallForm.ShowSection(Value:Integer);
begin
   case Value of
   1:begin

      Label1Image.Visible    :=True;

      Label2Image.Visible    :=False;

      Label3Image.Visible    :=False;

      Label4Image.Visible    :=False;

      Ball1Image.Visible     :=True;

      Ball2Image.Visible     :=False;

      Ball3Image.Visible     :=False;

      Ball4Image.Visible     :=False;

      BallV1Image.Visible    :=False;

      BallV2Image.Visible    :=False;

      BallV3Image.Visible    :=False;

      BigllImage.Visible     :=True;

      Big2Image.Visible      :=False;

      Big3Image.Visible      :=False;

      Animationl.Visible     :=True;

      Animation2.Visible     :=False;

      Animation3.Visible     :=False;
				
				<dp n="d621"/>
   NextImage.Visible           :=True;

   CutBackImage.Visible        :=False;

   CutNextImage.Visible        :=False;

   ErrorImage.Visible          :=False;

   ClipErrorImage.Visibla      :=False;

   XErrorAnimate.Visible       :=False;

   OopsErrorAnimate.Visible    :=False;

   RetryErrorImage.Visible     :=False;

   ExitErrorImage.Visible      :=False;

   ResetImage.Visible          :=False;
   end;
2:begin

   Label1Image.Visible         :=True;

   Label2Image.Visible         :=True;

   Label3Image.Visible         :=False;

   Label4Image.Visible         :=False;

   Ball1Image.Visible          :=False;

   Ball2Image.Visible          :=True;

   Ball3Image.Visible          :=False;

   Ball4Image.Visible          :=False;

   BallV1Image.Visible         :=True;

   BallV2Image.Visible         :=False;

   BallV3Image.Visible         :=False;

   BiglImage.Visible           :=False;

   Big2Image.Visible           :=True;

   Big3Image.Visible           :=False;

   Animationl.Visible          :=False;

   Animation2.Visible          :=True;

   Animation3.Visible          :=False;

   NextImage.Visible           :=False;

   CutBackImage.Visible        :=True;

   CutNextImage.Visible        :=True;

   ErrorImage.Visible          :=False;

   ClipErrorImage.Visible      :=False;

   XErrorAnimate.Visible       :=False;

   OopsErrorAnimate.Visible    :=False;

   RetryErrorImage.Visible     :=False;

   ExitErrorImage.Visible      :=False;

   ResetImage.Visible          :=False;
   end;
3:begin
				
				<dp n="d622"/>
   Label1Image.Visible        :=True;

   Label2Image.Visible        :=True;

   Label3Image.Visible        :=True;

   Label4Image.Visible        :=False;

   Ball1Image.Visible         :=False;

   Ball2Image.Visible         :=False;

   Ball3Image.Visible         :=True;

   Ball4Image.Visible         :=False;

   BallV1Image.Visible        :=True;

   BallV2Image.Visible        :=True;

   BallV3Image.Visible        :=False;

   Big1Image.Visible          :=False;

   Big2Image.Visible          :=False;

   Big3Image.Visible          :=True;

   Animationl.Visible         :=False;

   Animation2.Visible         :=False;

   Animation3.Visible         :=True;

   NextImage.Visible          :=False;

   CutBackImage.Visible       :=True;

   CutNextImage.Visible       :=True;

   ErrorImage.Visible         :=False;

   ClipErrorImage.Visible     :=False;

   XErrorAnimate.Visible      :=False;

   OopsErrorAnimate.Visible   :=False;

   RetryErrorImage.Visible    :=False;

   ExitErrorImage.Visible     :=False;

   ResetImage.Visible     :=False;
   end;
4:begin

   Label1Image.Visible    :=True;

   Label2Image.Visible    :=True;

   Label3Image.Visible    :=True;

   Label4Image.Visible    :=True;

   Ball1Image.Visible     :=False;

   Bal12Image.Visible     :=False;

   Ball3Image.Visible     :=False;

   Ball4Image.Visible     :=True;

   BallV1Image.Visible    :=True;

   BallV2Image.Visible    :=True;

   BallV3Image.Visible    :=True;

   Big1Image.Visible      :=True;

   Big2Image.Visible      :=False;
				
				<dp n="d623"/>
   Big3Image.Visible           :=False;

   Animation1.Visibie          :=True;

   Animation2.Visible          :=False;

   Animation3.Visible          :=False;

   NextImage.Visible           :=False;

   CutBackImage.Visible        :=True;

   CutNextImage.Visible        :=True;

   ErrorImage.Visible               :=False;

   ClipErrorImage.Visible           :=False;

   XErrorAnimate.Visible            :=False;

   OopsErrorAnimate.Visible         :=False;

   RetryErrorImage.Visible          :=False;

   ExitErrorImage.Visible           :=False;

   ResetImage.Visible           :=True;
   end;
5:begin

   Label1Image.Visible         :=True;

   Label2Image.Visible         :=True;

   Label3Image.Visible         :=True;

   Label4Image.VisIble         :=True;

   Ball1Image.Visible          :=False;

   Ball2Image.Visible          :=False;

   Ball3Image.Visible          :=False;

   Ball4Image.Visible          :=True;

   BallV1Image.Visible         :=True;

   BallV2Image.Visible         :=True;

   BallV3Image.Visible         :=True;

   Big1Image.Visible           :=False;

   Big2Image.Visible           :=False;

   Big3Image.Visible           :=False;

   Animation1.Visible          :=False;

   Animation2.Visible          :=False;

   Animation3.Visible          :=False;

   NextImage.Visible           :=False;

   CutBackImage.Visible        :=False;

   CutNextImage.Visible        :=False;

   ErrorImage.Visible          :=True;

   ClipErrorImage.Visible      :=True;

   XErrorAnimate.Visible       :=False;

   OopsErrorAnimate.Visible    :=True;

   RetryErrorImage.Visible     :=True;

   ExitErrorImage.Visible      :=True;
				
				<dp n="d624"/>
    ResetImage.Visible       :=False;

   end;
   end;
end;
procedure TSerialInstallForm.FormCreate(Sender:TObject);
begin
  With Ball1Image do

  begin

    Left     :=30;

    Top      :=200;

    Height   :=35;

    Width    :=33;

  end;
  With BallV1Image do

  begin

    Left    :=30;

    Top     :=197;

    Height  :=38;

    Width   :=35;

  end;
  With Ball2Image do

  begin

    Left    :=31;
    Top     :=269;

    Height  :=35;

    Width   :=33;

  end;
  With BallV2Image do

  begin

    Left    :=31;

    Top     :=266;

    Height  :=38;

    Width   :=38;

  end;
  With Ball3Image do

  begin

    Left    :=59;
				
				<dp n="d625"/>
  Top      :=352;

  Height   :=35;

  Width    :=33;
  end;
With BailV3Image do
  begin

  Left     :=59;

  Top      :=343;

  Height   :=38;

  Width    :=38;
  end;
With Ball4Image do
  begin

  Left      :=82;

  Top       :=422;

  Height    :=35;

  Width     :=33;
  end;
With NextImage do
   begin

   Left      :=479;

   Top       :=430;

   Height    :=74;

   Width     :=220;
   end;
With CutBackImage do
   begin

   Left      :=483;

   Top       :=429;

   Height    :=77;

   Width     :=108;
   end;
With CutNextImage do
   begin

   Left       :=590;

   Top        :=429;

   Height     :=77;

   Width      :=108;
				
				<dp n="d626"/>
  end;
With BiglImage do
  begin

   Left      :=393;

   Top       :=34;

   Height    :=359;

   Width     :=328;
   end;
With Big2Image do
  begin

  Left       :=393;

  Top        :=34;

  Height     :=319;

  Width      :=352;
  end;
With Big3Image do
  begin

  Left      :=393;

  Top       :=34;

  Height    :=326;

  Width     :=352;
  end;
With Aninationl do
  begin

  FileName  :=MainInstallForm.GraphicsPath+′InstallHUB.Avi′;

  Active    :=True;

  Left      :=593;

  Top       :=294;

  Height    :=40;

  Width     :=32;
  end;
With Animation2 do
  begin

  FileName  :=MainInstallForm.GraphicsPath+′Hub in.Avi′;

  Active    :=True;

  Left      :=503;

  Top       :=226;

  Height    :=60;
				
				<dp n="d627"/>
  Width     :=128;
  end;
With Animaticn3 do
  begin

  FileName  :=MainInstallForm.GraphicsPath+′Electric in.Avi′;

  Active    :=True;

  Left      :=505;

  Top       :=113;

  Height    :=150;

  Width     :=80;
  end;
With XErtorAnimate do
  begin

  FileName  :=MainInstallForm.GraphicsPath+′XOnHUB.Avi′;

  Active    :=True;

  Left      :=418;

  Top       :=158;

  Height    :=100;

  Width     :=112;
  end;
With OopsErrorAnimate do
  begin

  FileName  :=MainInstallForm.GraphicsPath+′Oops.Avi′;

  Active    :=True;

  Left      :=539;

  Top       :=81;

  Height    :=50;

  Width     :=96;
  end;
With ErrorImage do
  begin

  Left      :=405;

  Top       :=140;

  Height    :=125;

  Width     :=362;
  end;
With RetryErrorImage do
  begin
				
				<dp n="d628"/>
    Left     :=301;

    Top      :=296;

    Height   :=55;

    Width    :=89;

  end;
  With ExitErrorImage do

  begin

    Left     :=589;

    Top      :=296;

    Height   :=55;

    Width    :=92;

  end;
  With ClipErrorImage do

  begin

    Left      :=488;

    Top       :=433;

    Height    :=68;

    Width     :=201;

  end;
  With ResetImage do

  begin

    Left    :=580;

    Top     :=175;

    Height  :=86;

    Width   :=171;

  end;
end;
procedure TSerialInstallForm.ClipErrorImageClick(Sender:TObject);
begin
//

    Section  :=1;

    ShowSection(Section);
end;
procedure TSerialInstallForm.ExitErrorImageClick(Sender:TObject);
begin

    close;

    MainInstallForm.Close;
				
				<dp n="d629"/>
end;
procedure TSerialInstallForm.RetryErrorImageClick(Sender:TObject);
begin
//
   Section :=Section-1;
   CutNextImageClick(mil);
end;
end.
				
				<dp n="d630"/>
unit ToyInstall;
interface
uses
  Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,
Dialogs,Jpeg,
   ExtCtrls,CcmCtrls;
type
  TToyInstallForm=class(TForm)

  Imagel:TImage;

  Step1Image:TImage;

  Step2Image:TImage;

  Step3Image:TImage;

  BigStep1Image:TImage;

  BigStep2Image:TImage;

  BigStep3Image:TImage;

  Step1Animate:TAnimate;

  NextButtonImage:TImage;

  DoneButtonImage:TImage;

  Step3BackImage:TImage;

  Step2NextImage:TImage;

  Step2BackImage:TImage;

  procedure NextButtonImageClick(Sender:TObject);

  procedure DoneButtonImageClick(Sender:TObject);

  procedure FormCreate(Sender:TObject);

  procedure Step2BackImageClick(Sender:TObject);

  procedure Step2NextImageClick(Sender:TObject);

  procedure Step3BackImageClick(Sender:TObject);
  private

  {Private declaratioms}
  public

  {Public declarations}

  Section:Integer;

  procedure ShowSection(Value:Integer);
  end;
var
  ToyInstallForm:TToyInstallForm;
implementation
				
				<dp n="d631"/>
uses Installation;
{SR*.DFM)
procedure TToyInstallForm.NextButtonImageClick(Sender:TObject);
begin
   Section  :=2;
   ShowSection(Section);
end;
procedure TToyInstallForm.DoneButtonImageClick(Sender:TObject);
begin

  Close;

  MainInstallForm.close;
end;
procedure TToyInstallForm.FormCreate(Sender:TObject);
begin
//
   With Step1Image do

   begin

     Left    :=46;

     Top     :=128;

     Height  :=224;

     Width   :=275;

   end;
   With Step2Image do

   begin

     Left    :=48;

     Top     :=233;

     Height  :=108;

     Width   :=180;

   end;
   With Step3Image do

   begin

     Left    :=39;

     Top     :=135;

     Height  :=140;

     Width   :=308;

   end:
				
				<dp n="d632"/>
With BigSteplImage do
   begin

   Left     :=405;

   Top      :=48;

   Height   :=354;

   Width    :=360;
   end;
With BigStep2Image do
  begin

  Left     :=416;

  Top      :=61;

  Height   :=341;

  Width    :=335;
  end;
With BigStep3Image do
  begin

  Left    :=419;

  Top     :=53;

  Height  :=343;

  Width   :=326;
  end;
With NextButtonImage do
  begin

  Left    :=478;

  Top     :=430;

  Height  :=74;

  Width   :=223;
  end;
With DoneButtonImage do
  begin

  Left     :=589;

  Top      :=433;

  Height   :=69;

  Width    :=105;
  end;
With Step2BackImage do
  begin

  Left    :=479;
				
				<dp n="d633"/>
    Top     :=429;

    Height  :=77;

    Width   :=110;

  end;
  With Step2NextImage do

  begin

    Left     :=589;

    Top      :=429;

    Height   :=77;

    Width    :=111;

  end;
  With Step3BackImage do

  begin

    Left    :=479;

    Top     :=429;

    Height  :=77;

    Width   :=110;

  end;
  With Step1Animate do

  begin

    FileName:=MainInstallForm.GraphicsPath+′DollFaceMove.Avi′;

    Active     :=True;

    Left       :=539;

    Top        :=119;

    Height     :=80;

    Width      :=80;

  end;
end;
procedure TToyInstallForm.ShowSection(Value:Integer);
begin
   case Value of
   1:begin

      SteplImage.Visible         :=True;

      Step2Image.Visible         :=False;

      Step3Image.Visible         :=False;

      BlgStep1Image.Visible      :=True;

      BigStep2Image.Visible      :=False;

      BigStep3Image.Visible      :=False;

      SteplAnimate.Visible       :=True;
				
				<dp n="d634"/>
    NextButtonImage.Visibie    :=True;

    DoneButtonImage.Visible    :=False;

    Step3BackImage.Visible     :=False;

    Step2NextImage.Visible     :=False;

    Step2BackImage.Visible     :=False;

  end;
 2:begin

    Step1Image.Visible         :=True;

    Step2Image.Visible         :=True;

    Step3Image.Visible         :=False;

    BigStep1Image.Visible      :=False;

    BigStep2Image.Visible      :=true;

    BigStep3Image.Visible      :=False;

    Step1Animate.Visible       :=False;

    NextButtonImage.Visible    :=False;

    DoneButtonImage.Visible    :=False;

    Step3BackImage.Visible     :=False;

    Step2NextImage.Visible     :=True;

    Step2BackImage.Visible     :=True;

  end;
 3:begin

    Step1Image.Visible         :=False;

    Step2Image.Visible         :=False;

    Step3Image.Visible         :=True;

    BigStep1Image.Visible      :=False;

    BigStep2Image.Visible      :=False;

    BigStep3Image.Visible      :=True;

    Step1Animate.Visible       :=False;

    NextButtonImage.Visible    :=False;

    OoneButtonImage.Visible    :=True;

    Step3BackImage.Visible     :=True;

    Step2NextImage.Visible     :=False;

    Step2BackImage.Visible     :=False;

  end;
  end:
end;
procedure TToyInstallForm.Step2BackImageClick(Sender:TObject);
begin

   Section :=1;

   ShowSection(Section):
				
				<dp n="d635"/>
end;
procedure TToyInstallForm.Step2NextImageClick(Sender:TObject);
begin
   Section :=3;
   ShowSection(Section);
end;
procedure TToyInstallForm.Step3BackImageClick(Sender:TObject);
begin
   Section :=2;
   ShowSection(Section);
end;
end.
				
				<dp n="d636"/>
unit ToySetup;
interface
uses
  Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs,
  ExtCtrls,ComCtrls,Menus;
type
  TToySetupForm=class(TForm)

  Imagel:TImage;

  Title1Image:TImage;

  Title3Image:TImage;

  Title2Image:TImge;

  Animatel:TAnimate;

  HelpImage:TImage;

  Big1Image:TImage;

  NextImage:TImage;

  ErrorImage:TImage;

  TextErrorImage:TImage;

  ConfirmImage:TImage;

  CheckImage:TImage;

  CutNextImage:TImage;

  CutRetryImage:TImage;

  Big2Image:TImge;

  Big3Image:TImge;

  ExitImage:TImage;

  MainMenul:TMainMenu;

  testl:TMenuItem;

  escapel:TMenuItem;

  procedure FormCreate(Sender:TObject);

  procedure NextImageClick(Sender:TObject);

  procedure CutNextImageClick(Sender:TObject);

  procedure CutRetryImageClick(Sender:TObject);

  procedure CheckImageClick(Sender:TObject);

  procedure ExitImageClick(Sender:TObject);

  procedure escapelClick(Sender:TObject);
  private

  {Private declarations)
  public

  {Public declaretions}

  Section:Integer;

  procedure ShowSection(Value:Integer);
				
				<dp n="d637"/>
  function  ToyTalk:integer;
  end;
var
   ToySetupForm:TToySetupForm;
implementation
uses Installation;
{SR*.DFM}
procedure TToySetupForm.FormCreate(Sender:TObject);
begin
//
   With Title1Image do

   begin

     Left    :=48;

     Top     :=136;

     Height  :=152;

     Width   :=306;

   end;
   With Title2Image do

   begin

     Left    :=57;

     Top     :=124;

     Height  :=236;

     Width   :=331;

   end;
   With Title3Image do

   begin

     Left    :=33;

     Top     :=125;

     Height  :=273;

     Width   :=392;

   end;
   With Big1Image do

   begin

     Left    :=419;
				
				<dp n="d638"/>
  Top      :=52;

  Height   :=343;

  Width    :=326;
  end;
With Big2Image do
   begin

   Left     :=393;

   Top      :=34;

   Height   :=378;

   Width    :=364;
   end;
With Big3Image do
  begin

  Left     :=411;

  Top      :=51;

  Height   :=337;

  Width    :=342;
  end;
With NextImage do
  begin

  Left     :=478;

  Top      :=430;

  Height   :=74;

  Width    :=223;
  end;
With CheckImage do
  begin

  Left    :=477;

  Top     :=434;

  Height  :=66;

  Width   :=228;
  end;
With CutNextImage do
  begin

  Left     :=478;

  Top      :=435;

  Height   :=66;

  Width    :=110;
				
				<dp n="d639"/>
   end;
With CutRetryImage do
  begin

  Left     :=588;

  Top      :=435;

  Height   :=66;

  Width    :=115;
  end;
With ErrorImage do
  begin

  Left     :=432;

  Top      :=120;

  Height   :=184;

  Width    :=320;
  end;
With TextErrorImage do
  begin

  Left     :=36;

  Top      :=243;

  Height   :=152;

  Width    :=371;
  end;
With ConfirmImage do
  begin

  Left     :=411;

  Top      :=148;

  Height   :=187;

  Width    :=353;
  end;
With Animatel do
  begin

  FileName:=MainInstallForm.GraphicsPath+′oops,Avi′;

  Active     :=True;

  Left       :=534;

  Top        :=64;

  Height     :=50;

  Width      :=96;
  end;
				
				<dp n="d640"/>
end;
procedure TToySetupForm.ShowSecrtion(Value:Integer);
begin
  case Value of
  1:begin      //step 1

     Titie1Image.Visible         :=True;

     Title2Image.Visible         :=False;

     Title3Image.Visible         :=False;

     Big1Image.Visible           :=True;

     Big2Image.Visible           :=False;

     Big3Image.Visible           :=False;

     ErrorImage.Visible          :=False;

     TextErrorImage.Visible      :=False;

     ConfirmImage.Visible        :=False;

     Animatel.Visible            :=False;

     NextImage.Visible           :=True;

     CheckImage.Visible          :=False;

     CutNextImage.Visible        :=False;

     CutRetryImage.Visible       :=False;

   end;
  2:begin        //step 2

     Title1Image.Visible         :=False;

     itle2Image.Visible          :=True;

     Title3Image.Visible         :=False;

     Big1Image.Visible           :=False;

     Big2Image.Visible           :=True;

     Big3Image.Visible           :=False;

     ErrorImage.Visible          :=False;

     TextErrorImage.Visible      :=False;

     ConfirmImage.Visible        :=False;

     Animatel.Visible            :=False;

     NextImage.Visible           :=False;

     CheckImage.Visible          :=False;

     CutNextImage.Visible        :=True;

     CutRetryImage.Visible       :=True;

   end;
  3:begin        //step 3

     Title1Image.Visible         :=False;

     Title2Image.Visible         :=False;

     Title3Image.Visible         :=True;
				
				<dp n="d641"/>
    Big1Image.Visible           :=False;

    Big2Image.Visible           :=False;

    Big3Image.Visible           :=True;

    ErrorImage.Visible          :=False;

    TextErrorImage.Visible      :=False;

    ConfirmImage.Visible        :=False;

    Animatel.Visible            :=False;

    NextImage.Visible           :=False;

    CheckImage.Visible          :=True;

    CutNextImage.Visible        :=False;

    CutRetryImage.Visible       :=False;

  end;
 4:begin      //Confirm

    Title1Image.Visible         :=False;

    Title2Image.Visible         :=False;

    Title3Image.Visible         :=False;

    Big1Image.Visible           :=False;

    Big2Image.Visible           :=False;

    Big3Image.Visible           :=False;

    ErrorImage.Visible          :=False;

    TextErrorImage.Visible      :=False;

    ConfirmImage.Visible        :=True;

    Animatel.Visible            :=False;

    NextImage.Visible           :=True;

    CheckImage.Visible          :=False;

    CutNextImage.Visible        :=False;

    CutRetryImage.Visible       :=False;

  end;
10:begin     //Error

    Title1Image.Visible         :=False;

    Title2Image.Visible         :=False;

    Title3Image.Visible         :=False;

    Big1Image.Visible           :=False;

    Big2Image.Visible           :=False;

    Big3Image.Visible           :=False;

    ErrorImage.Visible          :=True;

    TextErrorImage.Visible      :=True;

    ConfirmImage.Visible        :=False;

    Animatel.Visible            :=True;

    NextImage.Visible           :=True;

    CheckImage.Visible          :=False;
				
				<dp n="d642"/>
      CutNextImage.Visibie       :=False;

      CutRetryImage.Visibie      :=False;

    end;
   end;
end;
				
				<dp n="d643"/>
procedure TToySecupForm. NextImageClick(Sender:TObject);
begin
//  Next
   Section :=Section+1;
   ShowSection(Section);
   if Section=5 then

    begin

       Hide;

       MainInstallForm.Close;

     end;
end;
procedure TToySetupForm.CutNextImageClick(Sender:TObject);
begin
// CutNext

    Section:=Section+1;

    ShowSection(Section);

    if Section=5 then

       begin

          Hide;

          MainInstallForm.Close;

        end;
end;
procedure TToySetupForm.CutRetryImageClick(Sender:TObject);
begin
//  CutRetry
end;
procedure TToySetupForm.CheckImageClick(Sender:TObject);
begin
//  Check
if ToyTalk=1 then
   begin

      CheckImage.Visible          :=False;

      CutNextImage.Visible        :=True;

      CutRetryImage.Visible       :=True;

  end

  else

  begin

    ShowSection(10);

    Section:=2;

  end;
				
				<dp n="d644"/>
function TToySetupForm.ToyTalk:integer;
var
  ToyNo:Integer;
begin
//  ToyTalk

  ToyNo:=MainInstallForm.PDBEngine.ToyNumber;

  if(ToyNo>0)and(ToyNo<32)then

  Result:=MainInstallForm.XMidil.NewToyTalk(ToyNo,

            MainInstallForm.AudioPath+′Install.wav′,0,0,0)

  else

  if ToyNo>31 then Result:=MainInstallForm.XMidil.ToyTalk2(ToyNo,

           MainInstallForm.AudioPath+′Install.wav′,0,0,0,0);
end;
procedure TToySetupForm.ExrtImageClick(Sender:TObject);
begin
//
   hide;
   MainInstallForm.close;
end;
				
				<dp n="d645"/>
procedure TToySetupForm.escapelClick(Sender:TCbject);
begin
//
   hide;
   MainInstallForm.close;
end;
end.
玩具构成源代码
program PESTOConriguration;
uses
  Forms,
  Cofiguration in ′Cofiguration.pas′(ConfigurationForm),
  PDBEngine in ′PDBEngine.pas′;
(SR*.RES)
begin
  Application.Initialize;
  Application.CreateForm(TConfigurationForm,ConfigurationForm);
  Application.Run;
end.
				
				<dp n="d648"/>
unit Cofiguration;
interface
uses
  Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs,
  Buttons,StdCtrls,Spin,PDBEngine,ComCtrls,ExtCtrls,NEWSRLib_TLB,
  OleCtrls,XMIDILib_TLB;
type
  TConfigurationForm=class(TForm)

  SpeedButtonl:TSpeedButton;

  GroupBox1:TGroupBox;

  GroupBox2:TGroupBox;

  GroupBox3:TGroupBox;

  Buttonl:TButton;

  ComboBox1:TComboBox;

  ComboBox2:TComboBox;

  ComboBox3:TComboBox;

  MasterToySpinEdit:TSpinEdit;

  Toy1SpinEdit:TSpinEdit;

  Toy2SpinEdit:TSpinEdit;

  MasterToyLabel:TLabel;

  Toy1Label:TLabel;

  Toy2Label:TLabel;

  Labe16:TLabel;

  Label7:TLabel;

  Label8:TLabel;

  Panell:TPanel;

  TrackBar4:TTrackBar;

  TrackBar5:TTrackBar;

  SpeedButton2:TSpeedButton;

  SpeedButton3:TSpeedButton;

 SpeedButton4:TSpeedButton;

  TitleLabel:TLabel;

  GainlLabel:TLabel;

  VolumelLabel:TLabel;

  SpeedButton5:TSpeedButton;

  SpeedButton6:TSpeedButton;

  Buttcn2:TButton;

  Button3:TButton;

  XMidil:TXMidi;

  SR1:TSR;
				
				<dp n="d649"/>
   Gain2Label:TLabel;

   Volume2Label:TLabel;
   procedure SpeedButtcnlClickSender:TObject);

   procedure FormCreate(Sender:TObject);

   procedure FormClose(Sender:TObject;var Action:TCloseAction);

   procedure SpeedButton2Click(Sender:TObject);

   procedure SpeedButton3Click(Sender:TObject);

   procedure SpeedButton4Click(Sender:TObject);

   procedure SpeedButton5Click(Sender:TObject);

   procedure SpeedButton6Click(Sender:TObject);

   procedure ButtonlClick(Sender:TObject);

   procedure ComboBox1Change(Sender:TObject);

   procedure ComboBox2Change(Sender:TObject);

   procedure ComboBox3Change(Sender:TObject);

   procedure MasterToySpinEditChange(Sender:TObject);

   procedure Toy1SpinEditChange(Sender:TObject);

   procedure Toy2SpinEditChange(Sender:TObject);

   procedure Button2Click(Sender:TObject);

   procedure Button3Click(Sender:TObject);
   private

   {Private declarations}
   public

   {Public declarations}

    DataBaseEngine   :TPDBEngine;

    Currentpath      :string;

    CreatorPath      :string;

    DatabasePath     :string;

    GraphicsPath     :string;

    AudioPath        :string;

    UsagePath        :string;

    PresentationPath :string;

    function GetCurrentPath(CurrentExeName:string):string;

    function ToyTalk(ToyNo:Integer;TalkFiles:string;

                     LTime:Integer):Integer;

    function ToyListen(Map:string;DelayTime:Real) :Integer;

    function ConvertToyNameToNumber(value:string) :Integer;

    procedure FillLabels(value:string);

    function ConvertToyNumberToName(value:Integer):string;
  end;
var
   ConfigurationForm:TConfigurationForm;
				
				<dp n="d650"/>
const
   ToyName1=′Teddy Bear [01H]′;
   ToyName2=′Frog [02H]′;
   ToyName3=′Storyteller 1 [21H]′;
   ToyName4=′Storyteller 2 [22H]′;
   ToyName5=′Storyteller 3 [23H]′;
   ToyGain1=′Microphone′;
   ToyGain2=′Sensitivity′;
   ToyVolume1=′Volume′;
   ToyVolume2=′′;
   HubGain1=′ToysVolume′;
   HubGain2=′′;
   HubVolume1=′Microphone′;
   HubVolume2=′Level ′;
implementation
{SR*.DFM}
procedure TConfigurationForm.SpeedButtonlClick(Sender:TObject);
begin
//
  try

  DataBaseEngine.ToyNumber:=MasterToySpinEdit.Value;

  DataBaseEngine.SaveConfiguration;
  except
  end;
  Close;
end;
procedure TConfigurationForm.FormCreate(Sender:TObject);
var
  temp:integer;
begin
// Fill Pathes

    CurrentPath    :=GetCurrentPath(Application.ExeName);

    CreatorPath    :=
Copy(CurrentPath,l,Length(CurrentPath)-Length(′Executables\′)};

   DatabasePath   :=CreatorPath + ′PESTO\DATABASE\′;

   GraphicsPath   :=CreatorPath + ′PESTO\GRAPHICS\′;

   AudioPath      :=CreatorPath + ′PESTO\AUDIO\′;

   UsagePath      :=CreatorPath + ′PESTO\USAGE\′;
				
				<dp n="d651"/>
    PresentationPath:=AudioPath +′PRESENTATION\′;
//
  try

  DataBaseEngine:=TPDBEngine.create(self);

  DataBaseEngine.DataBasePath:=DatabasePath;

  DataBaseEngine.LoadConfiguration;

  MasterToySpinEdit.Value:=DataBaseEngine.ToyNumber;

  ComboBox1.Text:=ConvertToyNumberToName(MasterToYSpinEdit.Value);
  except
  end;

  Width:=319;

  Height:=407;

  SRl. Init;

  Xmidil.StartHUB;

  ComboBox1.Items.Add(ToyName1);

  ComboBox1.Items.Add(ToyName2);

  ComboBox1.Items.Add(ToyName3);

  ComboBox1.Items.Add(ToyName4);

  ComboBox1.Items.Add(ToyName5);

  ComboBox2.Items.Add(ToyName1);

  ComboBox2.Items.Add(ToyName2);

  ComboBox2.Items.Add(ToyName3);

  ComboBox2.Items.Add(ToyName4);

  ComboBox2.Items.Add(ToyName5);

  ComboBox3.Items.Add (ToyName1);

  ComboBox3.Items.Add(Toyame2);

  ComboBox3.Items.Add(ToyName3);

  ComboBox3.Items.Add(ToyName4);

  ComboBox3.Items.Add(ToyName5);
end;
function TConfigurationForm.GetCurrentPath(CurrentExeName:string):
string;
var
   i:integer;
begin
   i:=Length(CurrentExeName);
   While i>0 do
				
				<dp n="d652"/>
       begin

          if Copy(CurrentExeName,i,1)=′\′then i:=0

          else

        begin

          i:=i-1;

          CurrentExeName:=Copy(CurrentExeName,1,i);

        end;

  end;

  Result:=CurrentExeName;
  end;
  procedure TConfigurationForm.FormClose(Sender:TObject;
  var Action:TCloseAction);
begin
  //
  DataBaseEngine.Free;
  srl.Close;
  Xmidil.StopHUB;
end;
procedure TConfigurationForm.SpeedButton2Click(Sender:TObject);
begin
  FillLabels(′TOY′);
  TitleLabel.Caption:=′Master Toy′;
  width:=631;
end;
procedure TConfigurationForm.SpeedButton3Click(Sender:TObject);
begin
  FillLabels(′TOY′);
  TitleLabel.Caption:=′Toyl′;
  width:=631;
end;
procedure TConfigurationForm.SpeedButton4Click(Sender:TObject);
begin
  FillLabels(′TOY′);
  TitleLabel.Caption:=′Toy2′;
  width:=631;
end;
procedure TConfigurationForm.SpeedButtonSClick(Sender:TCbject);
begin
				
				<dp n="d653"/>
  width:=319;
end;
procedure TConfigurationForm.SpeedButton6Click(Sender:TObject);
begin
  width:=319;
end;
procedure TConfigurationForm.ButtonlClick(Sender:TCbject);
begin
  close;
end;
procedure TConfigurationForm.ComboBox1Change(Sender:TObject);
begin
   MasterToySpinEdit.value:=ConvertToyNameToNumber(ComboBoxl.Text);
end;
procedure TConfigurationForm.ComboBox2Change(Sender:TObject);
begin
   ToylSpinEdit.value:=ConvertToyNameToNumer(ComboBox2.Text);
end;
procedure TConfigurationForm.ComboBox3Change(Sender:TObject);
begin
  Toy2SpinEdit.value:=ConvertToyNameToNumer(ComboBox3.Text);
end;
procedure TConfigurationForm.MasterToySpinEditChange(Sender:TObject);
begin
try
   MasterToyLabel.Caption:=copy(IntToHex(MasterToySpinEdit.Value,2),
length(IntToHex(MasterToySpinEdit.Value,2))-1,2);
except
end;
end;
procedure TConfigurationForm.ToylSpinEditChange(Sender:TObject);
begin
try
   ToylLabel.Caption:=copy(IntToHex(ToyiSpinEdit.Value,2),

                           length(IntToHex(ToylSpinEdit.Value,2))-1,2);
				
				<dp n="d654"/>
except
end;
end;
procedure TConfigurationForm.Toy2SpinEditChange(Sender:TObject);
begin
try

  Toy2Label.Caption:=copy(IntToHex(Toy2SpinEdit.Value,2),

                              length(IntToHex(Toy2SpinEdit.Value,2))-1,2);
except
end;
end;
procedure TConfigurationForm.Button2Click(Sender:TObject);
begin
  FillLabels(′HUB′);
  TitleLabel.Caption:=′HUB′;
  width:=631;
end;
procedure TConfigurationForm.Button3Click(Sender:TObject);
var
  Answer:Integer;
begin
//   Test Script

   ToyTalk(MasterToySpinEdit.Value,PresentationPath+′b8001.wav′,0);

   ToyTalk(Toy1SpinEdit.Value,PresentationPath+′b8002.wav′,0);

   ToyTalk(Toy2SpinEdit.Value,PresentationPath+′b8003.wav′,0);

   ToyTalk(MasterToySpinEdit.Value,PresentationPath+′gm945.wav′,50);

   Answer:=ToyListen(′story/1,song/2′,S);

   if Answer=1 then
ToyTalk(MasterToySpinEdit.Value,PresentationPath+′stm125.wav′,0);

   if Answer=2 then
ToyTalk(MasterToySpinEdit.Value,PresentationPath+′sng320.wav′,0);
end;function TConfigurationForm.ToyTalk(ToyNo:Integer;TalkFiles:string;

                          LTime:Integer):Integer;
begin
   sleep(200);
   if(ToyNo>31)and(ToyNo<>85)then

    begin

      Result:=XMidil.ToyTalk2(ToyNo,TalkFiles,0,LTime,0,0);
				
				<dp n="d655"/>
      if Result<0 then Result:=
XMidil.ToyTaik2(ToyNo,TalkFiles,0,LTime,0,0);

    end;

  if((ToyNo<32>and(ToyNo>0))or(ToyNo=85)then

    begin

      Result:=XMidil.NewToyTalk(ToyNo,TalkFiles,0,9,LTime);

      if Result<0 then Result:=
XMidil.NewTovTalk(ToyNo,TalkFiles,0,9,LTime);

   end;
  sleep(100);
end;
function TConfigurationForm.ToyListen(Map:string; DelayTime:Real):
Integer;
var
   DTime:Integer;
   Flags:Integer;
begin

  DTime:=Trunc(DelayTime*10);

  Flags:=1;

  Result:=srl.WaitForEvent(Map,DTime,Flags);

  if(Result>0)and(srl.GetPhraseConfLevel(1)<5000)then Result:=0;
end;
function TConfigurationForm.ConvertToyNameToNumber(value:string)
Integer;
begin
  if ToyNamel=value then Result:=1;
  if ToyName2=value then Result:=2;
  if ToyName3=value then Result:=33;
  if ToyName4=value then Result:=34;
  if ToyName5=value then Result:=35;
end;
function TConfigurationForm.ConvertToyNumberToName(value:Integer):
string;
begin
   if value=1  then Result:=ToyName1;
   if value=2  then Result:=ToyName2;
   if value=33 then Result:=ToyName3;
   if value=34 then Result:=ToyName4;
   if value=35 then Result:=ToyName5;
end;
				
				<dp n="d656"/>
procedure TConfigurationForm.FillLabels(value:string);
begin
   if value =′HUB′then
   begin

   Gain1Label.caption   :=HubGain1;

   Gain2Label.caption   :=HubGain2;

   Volume1Label.caption :=HubVolume1;

   Volume2Label.caption :=HubVolume2;
   end;
   if value=′TOY′then
   begin

   Gain1Label.caption   :=ToyGain1;

   Gain2Label.caption   :=ToyGain2;

   Volume1Label.caption :=ToyVolume1;

   Volume2Label.caption :=ToyVolume2;
   end;
end;
end.
附录B RS232 Base Revised:Monday April 13,1998001              Revieion:001Bill Of Materials April 13,1998                     15:26:18       Page 1Item      Quantity       Reference                                 Part1         3              C1,C35,C36                              10     nF2         5              C2,C28,C33,C40,C47                    1.0    nF3         9              C3,C5,C21,C25,C29,C34                1.0    uF
                     C38,C42,C454         1              C4                                        10     uF5         4              C6,C7,C14,C15,C16                     0.47   uF6         1              C8                                        0.15   uF7         2              C9,C17                                   3.3    uF8         1              C10                                       33     pF9         2              C11,C43                                  220    pF10        9              C12,C18,C22,C23,C30,C41,            0.1    uF
                     C48,C50,C5211        1              C13                                       47     nF12        1              C19                                       15     pF13        1              C20                                       10     pF14        2              C24,C27                                  100    nF15        1              C26                                       2.2    uF16        2              C32,C31                                  22     pF17        1              C37                                       68     nF18        1              C39                                       22     nF19        1              C44                                       68     pF20        1              C46                                       560    pF21        1              C49                                       100    uF22        1              C51                                       10uF/16V23        1              D1                                        RED24        4              D2,D3,D4,D5                         1N414825        2              JP2,JP1                               JUMPER26        1              J1                                     Antenna27        1              J2                                     CON28C28        1              P1                                     RS23229        2              Q2,Q1                                 2N222230        2              Q3,Q5                                 2N290731        2              Q4,Q6                                 BC54732        15             R1,R2,R4,R6,R9,R10,R12,             47     K
                  R15,R16,R17,R55,R56,R57,
                  R58,R5933                                 1          R3    8.2        K34        1           R5                                         4735        1           R6                                         3.936        9           R7,R29,R32,R45,R53,R62,              1          K
                  R65,R70,R7237        2           R11,R14                                   27          K38        1           R13                                        680         K39        9           R18,R19,R20,R21,R23,R26,             100         K
                  R36,R39,R5440        1           R22                                        33          K41        1           R24                                        51042        3           R25,R43,R74                              1043        2           R27,R66                                   10          K44        1           R28                                        200         K45        1           R30                                        22046        1           R31                                        47047        3           R33,R61,R68                              10048        1           R34                                        5049        1           R35                                        51K50        1           R38                                        5.1         K52        2           R42,R40                                   50053        1           R41                                        7/5         K54        2           R50,R44                                   121         K55        2           R48,R46                                   165         K56        1           R47                                        50          K57        1           R49                                        140         K58        1           R51                                        107         K59        1           R52                                        120         K60                    R60,R63,R67,R72,R73                    2.7         K61                    R64,R69                                   3           K62                    S1                             Reset63                    U1                             MC1311164                    U2                             4053PR65                    U3,U6                         74HC57466                    U4                             PIC16C73 Microchip67                    U5                             626468                    U7                             TL07469                    U8                             RY3 GB021- 900MHz     Sharp70                    Y1                             10.240    MHz71                    Y2                             14.7456   MHz
附录C TOY 900MHZ PRODUCT       Revised:Monday,April 30,1998
               Revision:1.1Bill Of Materials April 13, 1998            15:31:28            Page 1Item      Quantity       Reference                             Part1          1              C1                                  6.9           uF2          2              C2,C4                              27            pF3          1              C3                                  2.2           uF4          12             C5,C6,C7,C9,C20,C24,C25,     .01           uF
                       C27,C30,C41,C46,C485          1              C8                                  100           uF/16V6          4              C10,C33,C34,C37                  10            nF7          1              C11                                 1             nF8          3              C12,C15,C44                       1             uF9          4              C13,C35,C36,C38                  10            uF10         5              C14,C21,C23,C26,C32             0.47          uF11         1              C16                                 3.3           uF12         1              C17                                 150           nF13         1              C18                                 33            pF14         1              C19                                 220           pF15         1              C21                                 6.8           pF16         1              C28                                 15            pF17         2              C45,C29                            10            pF18         1              C31                                 68            nF19         1              C39                                 680           nF20         1              C40                                 47            pF21         1              C42                                 470           nF23         1              D1                                  1N144824         5              D2,D3,D4,D5,D6                  1N414825         1              J1                                  POWER26         1              J2                                  ANT127         1              J3                                  MOTOR  CON28         1              J4                                  MIC29         3              L1,L2,L3                          56           uHN30         2              Q5,Q1                              2N290731         3              3Q2,Q6,Q7                         2N222232         2              Q4,Q3                              2SD183433         1              RS1                                 75034         2              RTC1,R48                           470           K35         1              R1                                  3.3           K 36             16                           R2,R3,R4,R5,R17,R79,R35,               100          K
                                        R35,R40,R41,R43,R49,R50,
                                        R51,R6037             1                            R6                                            10           K38             4                            R7,R8,R11,E39                              51           K39             1                            R9                                            130          K40             1                            R10                                           10           M41             2                            R24,R12                                      4742             6                            R13,R14,R45,R46, R47,R89                 10           K43             1                            R15                                           2            K44             2                            R16,R18                                      22           K45             16                           R20,R21,R23,R26,R27,R28,                47           K
                                        R31,R34,R37,R38,R53,R54,
                                        R55,R56,R57,R                              5846             2                            R22,R42                                      8.2          K47             1                            R24                                           3.9          K48             2                            R29, R33                                     27           K49             1                            R30                                           1.0          K50             1                            R32                                           680          K51             1                            R44                                           47052             1                            U1                                            MC69HC05P353             1                            U2                                            MAX48554             1                            U3                                            MC1311155             1                            U4                                            TL07456             1                            U5                                            1452157             1                            U6                                            RY3 GB05- 900mhZ - Sharp58             1                            U7                                            LM486159             1                            Y1                                            4            MHZ60             1                            Y2                                            10.240MHZ61             1                            EXTRACAP                                      47           Nf
本领域的熟练技术人员可以理解本发明并不限于以上具体示出和描述的。本发明的范围仅由以下的权利要求限定。

Claims (57)

1、一种交互式玩具设备,包括:
具有有趣的物理外观的玩具;
安装在该玩具上的扬声器;
用户输入接收器;
存储有关至少一用户的信息的用户信息存储单元;和
内容控制器,其响应于经该用户输入接收器接收的当前用户输入和该存储单元中存储的信息进行工作,经该扬声器提供音频内容给该用户。
2、根据权利要求1的交互式玩具设备,其中该用户输入接收器包括一音频接收器。
3、根据权利要求2的交互式玩具设备,其中该当前用户输入包括经该音频接收器接收的一言语输入。
4、根据权利要求1的交互式玩具设备,其中该用户输入接收器包括一触觉输入接收器。
5、根据权利要求1的交互式玩具设备,其中该存储单元存储有关至少一用户的个人信息且该内容控制器进行工作以使该音频内容人性化。
6、根据权利要求1的交互式玩具设备,其中该存储单元存储有关至少一用户与该交互式玩具设备的交互的信息且该内容控制器进行工作以根据存储的有关该至少一用户与该交互式玩具设备的过去的交互的信息来控制该音频内容。
7、根据权利要求5的交互式玩具设备,其中该存储单元还存储有关至少一用户与该交互式玩具设备的交互的信息且该内容控制器还进行工作以根据有关该至少一用户与该交互式玩具设备的过去的 交互的信息来控制该音频内容。
8、根据权利要求1的交互式玩具设备,其中该存储单元还存储由一用户经该用户输入接收器言语地输入的信息。
9、根据权利要求5的交互式玩具设备,其中该存储单元还存储由一用户经该用户输入接收器言语地输入的信息。
10、根据权利要求7的交互式玩具设备,其中该存储单元还存储由一用户经该用户输入接收器言语地输入的信息。
11、根据权利要求1的交互式玩具设备,还包括一内容存储单元,存储经该扬声器待被播送给一用户的至少一内容标题的的音频内容,该至少一内容标题是交互式的且包含交互分支。
12、根据权利要求11的交互式玩具设备,其中该至少一内容标题包括:
存储对应的多个内容标题部分的多个音频文件,包括:
至少两个可替换的内容标题部分;和
响应于一任意的一用户输入、一环境条件、一过去的交互、有关一用户的个人信息、一远程计算机、和一与时间有关的条件在这些可替换的用户部分之间的一文本定义分支。
13、根据权利要求5的交互式玩具设备,还包括一内容存储单元,存储经该扬声器待被播送给一用户的至少一内容标题的的音频内容,该至少一内容标题是交互式的且包含交互分支。
14、根据权利要求13的交互式玩具设备,其中该至少一内容标题包括多个内容元素的并行部分,该多个内容元素的并行部分包括至少两个可替换的部分,和在这些可替换的部分之间的以一人性化方式的一文本定义分支。
15、根据权利要求1的交互式玩具设备,其中该用户信息存储 单元被至少部分地定位在该玩具中。
16、根据权利要求1的交互式玩具设备,其中该用户信息存储单元被至少部分地定位在该玩具外。
17、根据权利要求1的交互式玩具设备,其中该内容存储单元被至少部分地定位在该玩具中。
18、根据权利要求1的交互式玩具设备,其中该内容存储单元被至少部分地定位在该玩具外。
19、根据权利要求1的交互式玩具设备,其中该用户输入接收器包括:
安装在该玩具上的一麦克风;和
接收自该麦克风输入的一语句的一语音识别单元。
20、根据权利要求5的交互式玩具设备,其中该用户信息存储单元进行工作以存储有关各可用一唯一码识别的多个用户的个人信息且其中该内容控制器进行工作以提醒任意用户提供该用户码。
21、根据权利要求5的交互式玩具设备,其中该用户信息存储单元进行工作以存储有关一用户的合作行为的信息。
22、具有改变脸部表情的玩具设备,该玩具包括:
多特征化的脸部设备,包括多个可多位置的脸部特征;和
一脸部表情控制单元,其进行工作以至少生成代表至少两个对应的脸部表情的多个脸部特征的位置的三种组合。
23、根据权利要求22的设备,其中该脸部表情控制单元进行工作以使这些特征以不同的速率在多个位置之间变动,从而生成不同情绪的错觉。
24、根据权利要求22的设备,还包括:
一扬声器装置;
存储一音频声明的一音频存储器;和
进行工作以通过该扬声器装置控制该音频声明的输出的一音频输出单元,
且其中该脸部表情控制单元进行工作以与该声明的输出同步地生成多个位置的组合。
25、用于播放一交互式言语游戏的玩具设备,包括:
一玩具;
安装在该玩具上的一扬声器装置;
安装在该玩具上的一麦克风;
接收自该麦克风输入的一语句的一语音识别单元;和
一音频存储单元,用于存储:
通过该扬声器装置待被播放的多个言语游戏段;和
在这些言语游戏段之间的一文本存储定义交互分支。
26、根据权利要求25的玩具设备,其中这些言语游戏段包括提醒一用户生成对该言语游戏的一说出的输入的至少一段。
27、根据权利要求25的玩具设备,其中该至少一段包括两或更多的言语串和一对该用户的提醒以再现这些言语串之一。
28、根据权利要求25的玩具设备,其中该至少一段包括一谜。
29、根据权利要求25的玩具设备,其中这些言语串中的至少一个具有教育内容。
30、根据权利要求25的玩具设备,其中这些言语串中的至少一个包括有关在该游戏中的该用户的行为的性质对用户的一个反馈。
31、根据权利要求1的交互式玩具设备,还包括:
与该玩具一起装配的包括多个可多位置的脸部特征的多特征化脸部设备;和
一脸部表情控制单元,其进行工作以至少生成代表至少两个对应的脸部表情的多个脸部特征的位置的三种组合。
32、根据权利要求31的交互式玩具设备,其中该脸部表情控制单元进行工作以使这些特征以不同的速率在多个位置之间变动,从而生成不同情绪的错觉。
33、根据权利要求31的交互式玩具设备,还包括:
存储一音频声明的一音频存储器;和
进行工作以通过该扬声器装置控制该音频声明的输出的一音频输出单元,
且其中该脸部表情控制单元进行工作以与该声明的输出同步地生成多个位置的组合。
34、根据权利要求1的交互式玩具设备,还包括:
安装在该玩具上的一麦克风;
接收自该麦克风输入的一语句的一语音识别单元;和
一音频存储单元,用于存储:
通过该扬声器装置待被播放的一言语游戏的多个言语游戏段;和
在这些言语游戏段之间的一文本存储定义交互分支。
35、根据权利要求34的交互式玩具设备,其中这些言语游戏段包括提醒一用户生成对该言语游戏的一说出的输入的至少一段。
36、根据权利要求34的交互式玩具设备,其中该至少一段包括两或更多的言语串和一对该用户的提醒以再现这些言语串之一。
37、根据权利要求34的交互式玩具设备,其中该至少一段包括一谜。
38、根据权利要求34的交互式玩具设备,其中这些言语串中的 至少一个具有教育内容。
39、根据权利要求34的交互式玩具设备,其中这些言语串中的至少一个包括有关在该游戏中的该用户的行为的性质对用户的一个反馈。
40、一种玩具交互的方法,包括:
提供具有有趣的物理外观的一玩具;
提供安装在该玩具上的一扬声器;
提供一用户输入接收器;
将有关至少一用户的信息存储进一用户信息存储单元;
经一响应于经该用户输入接收器接收的当前用户输入和该存储单元中存储的信息进行工作的内容控制器,经该扬声器提供音频内容给该用户。
41、根据权利要求40的方法,其中该存储步骤包括存储有关至少一用户的个人信息并经该内容控制器使该音频内容人性化。
42、根据权利要求40的方法,其中该存储步骤包括存储有关至少一用户与该交互式玩具设备的交互的信息且根据存储的有关该至少一用户与该交互式玩具设备的过去的交互的信息经该内容控制器来控制该音频内容。
43、根据权利要求40的方法,还包括在一内容存储单元中存储经该扬声器待被播送给一用户的至少一内容标题的的音频内容,该至少一内容标题是交互式的且包含交互分支。
44、根据权利要求40的方法,还包括存储有关各可用一唯一码识别的多个用户的个人信息且经该内容控制器提醒任意用户提供该用户码。
45、根据权利要求40的方法,还包括存储有关一用户的合作行 为的信息。
46、根据权利要求40的方法,还包括:
提供多特征化的脸部设备,该多特征化的脸部设备包括多个可多位置的脸部特征;及
至少生成代表至少两个对应的脸部表情的多个脸部特征的位置的三种组合。
47、根据权利要求46的方法,还包括使这些特征以不同的速率在多个位置之间变动,从而生成不同情绪的错觉。
48、根据权利要求46的方法,还包括:
存储一音频声明;及
通过该扬声器提供该音频声明;且
与该声明的输出同步地生成多个脸部位置的组合。
49、一种用于使用交互式对象,将编程教授给学生的系统,该系统包括:
一计算机化的学生界面,允许一学生通过定义该交互式对象的特性赋与该交互式对象以生命,该计算机化学生界面进行工作以响应于学生输入至少部分地定义该交互式对象与人之间的交互;和
一计算机化教师界面,允许一教师在定义该交互式对象的特性中监视学生的进度。
50、根据权利要求49的系统,其中该计算机化教师界面允许该教师配置该计算机化学生界面。
51、一种用于将交互式对象的设计和编程教授给学生的教授系统,该系统包括:
一计算机化的学生界面,允许一学生通过定义该交互式对象的特性赋与该交互式对象以生命,该计算机化学生界面进行工作以响 应于学生输入至少部分地定义该交互式对象与人之间的交互;和
一计算机化教师界面,允许一教师配置该计算机化学生界面。
52、一种用于开发情绪上有知觉的计算机化的创造物的计算机系统,包括:
一计算机化的用户界面,允许一用户通过定义一情绪上有知觉的计算机化的创造物与自然人之间的交互来开发该情绪上有知觉的计算机化的创造物,该交互至少包括该情绪上有知觉的计算机化的创造物对从该自然人提供的一刺激所导出的,指示自然人情绪的至少一参数的至少一响应;和
一创造物控制单元,其进行工作以根据由该用户定义的这些特性和交互来控制该情绪上有知觉的创造物。
53、根据权利要求52的系统,其中该指示自然人情绪的参数包括除其语言内容之外的自然人语句的特性。
54、一种用于开发情绪上有知觉的计算机化的创造物的方法,该方法包括:
过定义该情绪上有知觉的计算机化的创造物与自然人之间的交互,该交互至少包括该情绪上有知觉的计算机化的创造物对从该自然人提供的一刺激所导出的,指示自然人情绪的至少一参数的至少一响应;和
根据由该用户定义的这些特性和交互来控制该情绪上有知觉的创造物。
55、一种用于将编程教授给学生的方法,该方法包括:
提供一基于计算机化的虚拟编程的学生界面,允许学生执行虚拟编程;并
提供一计算机化的教师界面,允许教师使配置该计算机化的学 生界面。
56、一种计算机化的情绪上有知觉的计算机化的创造物,包括:
多个交互模式,用于实现对应的多个与自然人的交互,该多个交互至少包括对指示自然人情绪的至少一自然人情绪参数的一响应;和
一情绪感知单元,用于从由该自然人提供的一刺激导出至少一自然人情绪参数,并将该参数提供给多个交互模式中的至少一个。
57、根据权利要求56的创造物,还包括一真实的个体,用于参与多个交互模式中的至少一个。
CN99800961.XA 1998-04-16 1999-04-15 交互式玩具 Pending CN1272800A (zh)

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
IL124122 1998-04-16
IL12412298 1998-04-16
US09/081,255 1998-05-19
US09/081,255 US6160986A (en) 1998-04-16 1998-05-19 Interactive toy

Publications (1)

Publication Number Publication Date
CN1272800A true CN1272800A (zh) 2000-11-08

Family

ID=26323628

Family Applications (1)

Application Number Title Priority Date Filing Date
CN99800961.XA Pending CN1272800A (zh) 1998-04-16 1999-04-15 交互式玩具

Country Status (7)

Country Link
US (1) US6959166B1 (zh)
EP (1) EP0991453A1 (zh)
JP (1) JP3936749B2 (zh)
CN (1) CN1272800A (zh)
AU (1) AU3343199A (zh)
CA (1) CA2296119A1 (zh)
WO (1) WO1999054015A1 (zh)

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101711923B (zh) * 2001-03-30 2012-12-12 伊梅森公司 触觉式玩具遥控器
CN102007457B (zh) * 2008-01-31 2013-07-31 方瑞麟 具有时间同步能力的交互式设备
CN103505880A (zh) * 2012-06-29 2014-01-15 新昌县冠阳技术开发有限公司 一种人与玩具不见面智能交互的装置
CN104575502A (zh) * 2014-11-25 2015-04-29 百度在线网络技术(北京)有限公司 智能玩具及智能玩具的语音交互方法
CN104679378A (zh) * 2013-11-27 2015-06-03 苏州蜗牛数字科技股份有限公司 基于虚拟头像的音乐媒体播放方式
CN106205612A (zh) * 2016-07-08 2016-12-07 北京光年无限科技有限公司 面向智能机器人的信息处理方法及系统
CN106823378A (zh) * 2017-02-20 2017-06-13 包伯瑜 一种角色扮演玩具系统
CN107403566A (zh) * 2016-04-27 2017-11-28 刘锦铭 一种使用虚拟机器人的教育系统
CN108601440A (zh) * 2016-02-05 2018-09-28 美睫训练器材有限公司 用于练习施用睫毛延长物的装置
CN108671552A (zh) * 2018-05-03 2018-10-19 深圳市沃特沃德股份有限公司 智能玩具控制方法及装置
CN110035166A (zh) * 2019-03-20 2019-07-19 广州美术学院 一种关联多个手机终端的互动装置
CN110400494A (zh) * 2018-04-25 2019-11-01 北京快乐智慧科技有限责任公司 一种儿童故事播放的方法和系统

Families Citing this family (102)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6663393B1 (en) * 1999-07-10 2003-12-16 Nabil N. Ghaly Interactive play device and method
US7445550B2 (en) 2000-02-22 2008-11-04 Creative Kingdoms, Llc Magical wand and interactive play experience
US7878905B2 (en) 2000-02-22 2011-02-01 Creative Kingdoms, Llc Multi-layered interactive play experience
US6773344B1 (en) 2000-03-16 2004-08-10 Creator Ltd. Methods and apparatus for integration of interactive toys with interactive television and cellular communication systems
JP2001277166A (ja) * 2000-03-31 2001-10-09 Sony Corp ロボット及びロボットの行動決定方法
AU2001272711A1 (en) * 2000-08-12 2002-02-25 Alexander V. Smirnov Toys imitating characters behaviour
KR100396752B1 (ko) * 2000-08-17 2003-09-02 엘지전자 주식회사 상품을 이용한 완구의 학습/성장 시스템 및 방법
JP4296714B2 (ja) * 2000-10-11 2009-07-15 ソニー株式会社 ロボット制御装置およびロボット制御方法、記録媒体、並びにプログラム
KR20020044736A (ko) * 2000-12-06 2002-06-19 스마트아이엔티 주식회사 교육용 터미널 장치 및 방법
US6910186B2 (en) 2000-12-08 2005-06-21 Kyunam Kim Graphic chatting with organizational avatars
US7457752B2 (en) * 2001-08-14 2008-11-25 Sony France S.A. Method and apparatus for controlling the operation of an emotion synthesizing device
KR100624403B1 (ko) * 2001-10-06 2006-09-15 삼성전자주식회사 인체의 신경계 기반 정서 합성 장치 및 방법
US7037455B2 (en) * 2001-12-21 2006-05-02 Mattel, Inc. Insert molding method
US20070066396A1 (en) 2002-04-05 2007-03-22 Denise Chapman Weston Retail methods for providing an interactive product to a consumer
US20040043373A1 (en) * 2002-09-04 2004-03-04 Kaiserman Jeffrey M. System for providing computer-assisted development
US7238079B2 (en) * 2003-01-14 2007-07-03 Disney Enterprise, Inc. Animatronic supported walking system
US7248170B2 (en) * 2003-01-22 2007-07-24 Deome Dennis E Interactive personal security system
US9446319B2 (en) * 2003-03-25 2016-09-20 Mq Gaming, Llc Interactive gaming toy
JP4007224B2 (ja) * 2003-03-27 2007-11-14 株式会社デンソー ロボット固定装置
US7862428B2 (en) 2003-07-02 2011-01-04 Ganz Interactive action figures for gaming systems
US7465212B2 (en) * 2003-12-31 2008-12-16 Ganz System and method for toy adoption and marketing
US7534157B2 (en) 2003-12-31 2009-05-19 Ganz System and method for toy adoption and marketing
JP4367862B2 (ja) 2003-12-31 2009-11-18 ガンズ,ア・パートナーシップ・オブ・トゥー・オンタリオ・コーポレイションズ 仮想世界プレゼンテーションを提供する方法
US20070299694A1 (en) * 2006-06-26 2007-12-27 Merck David E Patient education management database system
US20080039247A1 (en) * 2006-08-02 2008-02-14 Sandra L. Uhler Footbag And A System Relating Thereto
EP1895505A1 (en) 2006-09-04 2008-03-05 Sony Deutschland GmbH Method and device for musical mood detection
EP1912193A1 (en) * 2006-10-02 2008-04-16 Koninklijke Philips Electronics N.V. Interactive storyteller system
US20080082301A1 (en) * 2006-10-03 2008-04-03 Sabrina Haskell Method for designing and fabricating a robot
US20080082214A1 (en) * 2006-10-03 2008-04-03 Sabrina Haskell Method for animating a robot
US8307295B2 (en) 2006-10-03 2012-11-06 Interbots Llc Method for controlling a computer generated or physical character based on visual focus
NZ564006A (en) 2006-12-06 2009-03-31 2121200 Ontario Inc System and method for product marketing using feature codes
TW200824767A (en) * 2006-12-08 2008-06-16 Yu-Hsi Ho Materialization system for virtual object and method thereof
EP2121155A1 (en) * 2007-02-12 2009-11-25 IM Smiling B.V. Method for controlling an external device via the usb-port of a personal computer
US20080195724A1 (en) * 2007-02-14 2008-08-14 Gopinath B Methods for interactive multi-agent audio-visual platforms
TW200836893A (en) * 2007-03-01 2008-09-16 Benq Corp Interactive home entertainment robot and method of controlling the same
US20080287033A1 (en) * 2007-05-17 2008-11-20 Wendy Steinberg Personalizable Doll
US8128500B1 (en) 2007-07-13 2012-03-06 Ganz System and method for generating a virtual environment for land-based and underwater virtual characters
CN101411946B (zh) * 2007-10-19 2012-03-28 鸿富锦精密工业(深圳)有限公司 玩具恐龙
US20090117819A1 (en) * 2007-11-07 2009-05-07 Nakamura Michael L Interactive toy
US8612302B2 (en) 2007-11-19 2013-12-17 Ganz Credit swap in a virtual world
US8088002B2 (en) * 2007-11-19 2012-01-03 Ganz Transfer of rewards between websites
US8626819B2 (en) * 2007-11-19 2014-01-07 Ganz Transfer of items between social networking websites
US20090132357A1 (en) * 2007-11-19 2009-05-21 Ganz, An Ontario Partnership Consisting Of S.H. Ganz Holdings Inc. And 816877 Ontario Limited Transfer of rewards from a central website to other websites
JP2011507413A (ja) * 2007-12-17 2011-03-03 プレイ・メガフォン・インコーポレイテッド ユーザと双方向システムとの間の双方向交信を管理するためのシステムと方法
US8172637B2 (en) * 2008-03-12 2012-05-08 Health Hero Network, Inc. Programmable interactive talking device
CA2623966A1 (en) * 2008-04-01 2009-01-12 Ganz, An Ontario Partnership Consisting Of 2121200 Ontario Inc. And 2121 812 Ontario Inc. Reverse product purchase in a virtual environment
US20100041312A1 (en) * 2008-08-15 2010-02-18 Paul King Electronic toy and methods of interacting therewith
US20100053862A1 (en) * 2008-09-04 2010-03-04 Burnes Home Accents, Llc Modular digital image display devices and methods for providing the same
US20100100447A1 (en) * 2008-10-21 2010-04-22 Ganz Toy system and extravaganza planner
EP2367606A4 (en) * 2008-11-27 2012-09-19 Univ Stellenbosch BONDING BEHAVIOR SHOWING TOY
US8255807B2 (en) 2008-12-23 2012-08-28 Ganz Item customization and website customization
US8909414B2 (en) 2009-12-14 2014-12-09 Volkswagen Ag Three-dimensional corporeal figure for communication with a passenger in a motor vehicle
US8843553B2 (en) * 2009-12-14 2014-09-23 Volkswagen Ag Method and system for communication with vehicles
US20110202863A1 (en) * 2010-02-18 2011-08-18 Corrallo Charles Shane Computer Entertainment Tracker Application for Limiting Use of Specific Computer Applications and Method of Use
US8308667B2 (en) * 2010-03-12 2012-11-13 Wing Pow International Corp. Interactive massaging device
US8836719B2 (en) 2010-04-23 2014-09-16 Ganz Crafting system in a virtual environment
US8775341B1 (en) 2010-10-26 2014-07-08 Michael Lamport Commons Intelligent control with hierarchical stacked neural networks
US9015093B1 (en) 2010-10-26 2015-04-21 Michael Lamport Commons Intelligent control with hierarchical stacked neural networks
US20120185254A1 (en) * 2011-01-18 2012-07-19 Biehler William A Interactive figurine in a communications system incorporating selective content delivery
US9180380B2 (en) 2011-08-05 2015-11-10 Mattel, Inc. Toy figurine with internal lighting effect
WO2013024470A1 (en) 2011-08-16 2013-02-21 Seebo Interactive Ltd. Connected multi functional system and method of use
WO2013063381A1 (en) * 2011-10-28 2013-05-02 Tovbot Smartphone and internet service enabled robot systems and methods
US9079113B2 (en) * 2012-01-06 2015-07-14 J. T. Labs Limited Interactive personal robotic apparatus
US8721456B2 (en) 2012-02-17 2014-05-13 Ganz Incentivizing playing between websites
US9649565B2 (en) * 2012-05-01 2017-05-16 Activision Publishing, Inc. Server based interactive video game with toys
US10223636B2 (en) 2012-07-25 2019-03-05 Pullstring, Inc. Artificial intelligence script tool
US8972324B2 (en) 2012-07-25 2015-03-03 Toytalk, Inc. Systems and methods for artificial intelligence script modification
US10528385B2 (en) 2012-12-13 2020-01-07 Microsoft Technology Licensing, Llc Task completion through inter-application communication
US9675895B2 (en) 2013-03-13 2017-06-13 Hasbro, Inc. Three way multidirectional interactive toy
US9259659B2 (en) 2013-04-30 2016-02-16 Mattel, Inc. Twist-waist punching figure
US20140329433A1 (en) * 2013-05-06 2014-11-06 Israel Carrero Toy Stuffed Animal with Remote Video and Audio Capability
US10043412B2 (en) 2013-05-26 2018-08-07 Dean Joseph Lore System for promoting travel education
US9406240B2 (en) * 2013-10-11 2016-08-02 Dynepic Inc. Interactive educational system
CN103753538A (zh) * 2014-01-24 2014-04-30 成都万先自动化科技有限责任公司 公司会议讲解服务机器人
CN103753579A (zh) * 2014-01-24 2014-04-30 成都万先自动化科技有限责任公司 新闻播报服务机器人
CN103761932A (zh) * 2014-01-24 2014-04-30 成都万先自动化科技有限责任公司 天气预报播报服务机器人
CN103778576A (zh) * 2014-01-24 2014-05-07 成都万先自动化科技有限责任公司 健身咨询服务机器人
CN103753582A (zh) * 2014-01-24 2014-04-30 成都万先自动化科技有限责任公司 夜游安全服务机器人
US9925456B1 (en) 2014-04-24 2018-03-27 Hasbro, Inc. Single manipulatable physical and virtual game assembly
US20150238879A1 (en) * 2014-05-23 2015-08-27 Bluniz Creative Technology Corporation Remote interactive media
JP6547244B2 (ja) * 2014-06-30 2019-07-24 カシオ計算機株式会社 動作処理装置、動作処理方法及びプログラム
JP6476608B2 (ja) * 2014-06-30 2019-03-06 カシオ計算機株式会社 動作処理装置、動作処理方法及びプログラム
US9814986B2 (en) 2014-07-30 2017-11-14 Hasbro, Inc. Multi sourced point accumulation interactive game
AU2016250773A1 (en) 2015-04-23 2017-10-12 Hasbro, Inc. Context-aware digital play
CN104959985B (zh) * 2015-07-16 2017-10-17 深圳狗尾草智能科技有限公司 一种机器人的控制系统及其方法
KR101824977B1 (ko) * 2015-11-26 2018-02-02 엠텍씨앤케이 주식회사 컨텐츠와 외부기기 연동방법
JP6763167B2 (ja) * 2016-03-23 2020-09-30 カシオ計算機株式会社 学習支援装置、学習支援システム、学習支援方法、ロボット及びプログラム
JP6756130B2 (ja) * 2016-03-23 2020-09-16 カシオ計算機株式会社 学習支援装置、ロボット、学習支援システム、学習支援方法及びプログラム
US10010801B2 (en) * 2016-03-31 2018-07-03 Shenzhen Bell Creative Science and Education Co., Ltd. Connection structures of modular assembly system
US11107021B2 (en) 2016-11-06 2021-08-31 Microsoft Technology Licensing, Llc Presenting and manipulating task items
KR102502228B1 (ko) * 2016-11-10 2023-02-20 워너 브로스. 엔터테인먼트 인크. 환경 제어 특징을 갖는 소셜 로봇
US11045738B1 (en) 2016-12-13 2021-06-29 Hasbro, Inc. Motion and toy detecting body attachment
US10758828B1 (en) 2017-03-17 2020-09-01 Hasbro, Inc. Music mash up collectable card game
US10354176B1 (en) 2017-05-03 2019-07-16 Amazon Technologies, Inc. Fingerprint-based experience generation
US10965391B1 (en) * 2018-01-29 2021-03-30 Amazon Technologies, Inc. Content streaming with bi-directional communication
CN110211434A (zh) * 2019-05-30 2019-09-06 江苏科斗教育科技有限公司 一种人工智能教育编程机器人
RU2712349C1 (ru) * 2019-07-24 2020-01-28 Федеральное государственное бюджетное образовательное учреждение высшего образования "Поволжский государственный технологический университет" Игрушка
US11389735B2 (en) 2019-10-23 2022-07-19 Ganz Virtual pet system
US11358059B2 (en) 2020-05-27 2022-06-14 Ganz Live toy system
TWI774208B (zh) * 2021-01-22 2022-08-11 國立雲林科技大學 故事展演系統及其方法
DE102021106403A1 (de) * 2021-03-16 2022-09-22 Geobra Brandstätter Stiftung & Co. Kg Spielsystem und Spiel mit dem Spielsystem
CN115382224B (zh) * 2022-08-02 2024-02-13 奥飞娱乐股份有限公司 玩具载具的面部切换机构和玩具载具

Family Cites Families (56)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE3009040C2 (de) 1980-03-08 1982-05-19 Hermann Dr. 8510 Fürth Neuhierl Spielfahrzeug mit elektrischer Stromversorgung, elektrischem Antrieb und Funkfernsteuerung
JPS6055985A (ja) 1983-09-05 1985-04-01 株式会社トミー 音声認識玩具
US4679789A (en) 1983-12-26 1987-07-14 Kabushiki Kaisha Universal Video game apparatus with automatic skill level adjustment
US4712184A (en) 1984-09-12 1987-12-08 Haugerud Albert R Computer controllable robotic educational toy
US4642710A (en) * 1985-03-15 1987-02-10 Milton Bradley International, Inc. Animated display controlled by an audio device
US4670848A (en) 1985-04-10 1987-06-02 Standard Systems Corporation Artificial intelligence system
US4752068A (en) * 1985-11-07 1988-06-21 Namco Ltd. Video game machine for business use
EP0265438A1 (en) 1986-05-02 1988-05-04 SIROTA, Vladimir Toy
US4802879A (en) 1986-05-05 1989-02-07 Tiger Electronics, Inc. Action figure toy with graphics display
US4846693A (en) * 1987-01-08 1989-07-11 Smith Engineering Video based instructional and entertainment system using animated figure
US4840602A (en) * 1987-02-06 1989-06-20 Coleco Industries, Inc. Talking doll responsive to external signal
US4857030A (en) 1987-02-06 1989-08-15 Coleco Industries, Inc. Conversing dolls
US4923428A (en) * 1988-05-05 1990-05-08 Cal R & D, Inc. Interactive talking toy
US4858930A (en) * 1988-06-07 1989-08-22 Namco, Ltd. Game system
US5241142A (en) 1988-06-21 1993-08-31 Otis Elevator Company "Artificial intelligence", based learning system predicting "peak-period" ti
US4959037A (en) 1989-02-09 1990-09-25 Henry Garfinkel Writing doll
US5195920A (en) 1989-02-16 1993-03-23 Collier Harry B Radio controlled model vehicle having coordinated sound effects system
SE466029B (sv) 1989-03-06 1991-12-02 Ibm Svenska Ab Anordning och foerfarande foer analys av naturligt spraak i ett datorbaserat informationsbehandlingssystem
US5109222A (en) 1989-03-27 1992-04-28 John Welty Remote control system for control of electrically operable equipment in people occupiable structures
US5182557A (en) 1989-09-20 1993-01-26 Semborg Recrob, Corp. Motorized joystick
US5142803A (en) 1989-09-20 1992-09-01 Semborg-Recrob, Corp. Animated character system with real-time contol
US5021878A (en) 1989-09-20 1991-06-04 Semborg-Recrob, Corp. Animated character system with real-time control
GB8922140D0 (en) 1989-10-02 1989-11-15 Blue Box Toy Factory A toy musical box
US5191615A (en) 1990-01-17 1993-03-02 The Drummer Group Interrelational audio kinetic entertainment system
EP0557444A1 (en) * 1990-11-14 1993-09-01 Best, Robert MacAndrew Talking video games
US5261820A (en) * 1990-12-21 1993-11-16 Dynamix, Inc. Computer simulation playback method and simulation
WO1992015951A1 (en) 1991-03-04 1992-09-17 Inference Corporation Case-based reasoning system
US5209695A (en) 1991-05-13 1993-05-11 Omri Rothschild Sound controllable apparatus particularly useful in controlling toys and robots
EP0527527B1 (en) 1991-08-09 1999-01-20 Koninklijke Philips Electronics N.V. Method and apparatus for manipulating pitch and duration of a physical audio signal
US5281143A (en) 1992-05-08 1994-01-25 Toy Biz, Inc. Learning doll
US5377103A (en) 1992-05-15 1994-12-27 International Business Machines Corporation Constrained natural language interface for a computer that employs a browse function
US5369575A (en) 1992-05-15 1994-11-29 International Business Machines Corporation Constrained natural language interface for a computer system
US5390281A (en) 1992-05-27 1995-02-14 Apple Computer, Inc. Method and apparatus for deducing user intent and providing computer implemented services
US5434777A (en) 1992-05-27 1995-07-18 Apple Computer, Inc. Method and apparatus for processing natural language
US5390282A (en) 1992-06-16 1995-02-14 John R. Koza Process for problem solving using spontaneously emergent self-replicating and self-improving entities
US5270480A (en) 1992-06-25 1993-12-14 Victor Company Of Japan, Ltd. Toy acting in response to a MIDI signal
AU677605B2 (en) 1992-09-04 1997-05-01 Caterpillar Inc. Integrated authoring and translation system
JPH0689274A (ja) 1992-09-08 1994-03-29 Hitachi Ltd 審査支援方法及びシステム
CA2146643A1 (en) 1992-10-19 1994-04-28 Jeffrey Scott Jani Video and radio controlled moving and talking device
US5615112A (en) 1993-01-29 1997-03-25 Arizona Board Of Regents Synthesized object-oriented entity-relationship (SOOER) model for coupled knowledge-base/database of image retrieval expert system (IRES)
US5388493A (en) 1993-11-17 1995-02-14 Curletto; Giorgio F. Extra low profile housing for vertical dual keyboard MIDI wireless controller for accordionists
US5694558A (en) 1994-04-22 1997-12-02 U S West Technologies, Inc. Method and system for interactive object-oriented dialogue management
US5704018A (en) 1994-05-09 1997-12-30 Microsoft Corporation Generating improved belief networks
US5733131A (en) * 1994-07-29 1998-03-31 Seiko Communications Holding N.V. Education and entertainment device with dynamic configuration and operation
US5724074A (en) 1995-02-06 1998-03-03 Microsoft Corporation Method and system for graphically programming mobile toys
US5636994A (en) * 1995-11-09 1997-06-10 Tong; Vincent M. K. Interactive computer controlled doll
US5752880A (en) 1995-11-20 1998-05-19 Creator Ltd. Interactive doll
US5727951A (en) 1996-05-28 1998-03-17 Ho; Chi Fai Relationship-based computer-aided-educational system
US5779486A (en) 1996-03-19 1998-07-14 Ho; Chi Fai Methods and apparatus to assess and enhance a student's understanding in a subject
US6134590A (en) * 1996-04-16 2000-10-17 Webtv Networks, Inc. Method and apparatus for automatically connecting devices to a local network
US5700178A (en) * 1996-08-14 1997-12-23 Fisher-Price, Inc. Emotional expression character
IL120857A (en) * 1997-05-19 2003-03-12 Creator Ltd Programmable assembly toy
US20010032278A1 (en) * 1997-10-07 2001-10-18 Brown Stephen J. Remote generation and distribution of command programs for programmable devices
US6160986A (en) 1998-04-16 2000-12-12 Creator Ltd Interactive toy
US6663393B1 (en) * 1999-07-10 2003-12-16 Nabil N. Ghaly Interactive play device and method
US6439956B1 (en) * 2000-11-13 2002-08-27 Interact Accessories, Inc. RC car device

Cited By (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101711923B (zh) * 2001-03-30 2012-12-12 伊梅森公司 触觉式玩具遥控器
CN102007457B (zh) * 2008-01-31 2013-07-31 方瑞麟 具有时间同步能力的交互式设备
CN103505880A (zh) * 2012-06-29 2014-01-15 新昌县冠阳技术开发有限公司 一种人与玩具不见面智能交互的装置
CN104679378A (zh) * 2013-11-27 2015-06-03 苏州蜗牛数字科技股份有限公司 基于虚拟头像的音乐媒体播放方式
CN104575502A (zh) * 2014-11-25 2015-04-29 百度在线网络技术(北京)有限公司 智能玩具及智能玩具的语音交互方法
CN108601440A (zh) * 2016-02-05 2018-09-28 美睫训练器材有限公司 用于练习施用睫毛延长物的装置
CN108601440B (zh) * 2016-02-05 2022-05-27 美睫训练器材有限公司 用于练习施用睫毛延长物的装置
CN107403566A (zh) * 2016-04-27 2017-11-28 刘锦铭 一种使用虚拟机器人的教育系统
CN106205612B (zh) * 2016-07-08 2019-12-24 北京光年无限科技有限公司 面向智能机器人的信息处理方法及系统
CN106205612A (zh) * 2016-07-08 2016-12-07 北京光年无限科技有限公司 面向智能机器人的信息处理方法及系统
CN106823378A (zh) * 2017-02-20 2017-06-13 包伯瑜 一种角色扮演玩具系统
CN110400494A (zh) * 2018-04-25 2019-11-01 北京快乐智慧科技有限责任公司 一种儿童故事播放的方法和系统
CN108671552A (zh) * 2018-05-03 2018-10-19 深圳市沃特沃德股份有限公司 智能玩具控制方法及装置
CN110035166A (zh) * 2019-03-20 2019-07-19 广州美术学院 一种关联多个手机终端的互动装置

Also Published As

Publication number Publication date
AU3343199A (en) 1999-11-08
JP2002505614A (ja) 2002-02-19
WO1999054015A1 (en) 1999-10-28
US6959166B1 (en) 2005-10-25
CA2296119A1 (en) 1999-10-28
EP0991453A1 (en) 2000-04-12
JP3936749B2 (ja) 2007-06-27

Similar Documents

Publication Publication Date Title
CN1272800A (zh) 交互式玩具
US11511436B2 (en) Robot control method and companion robot
Lundin Inviting queer ideas into the science classroom: Studying sexuality education from a queer perspective
WO2001012285A9 (en) Networked toys
JP2002153672A (ja) 生活用品を利用した玩具の学習/成長システム及びその方法
JP2006061632A (ja) 感情データ提供装置、心理解析装置、および電話ユーザ心理解析方法
JP7193015B2 (ja) コミュニケーション支援プログラム、コミュニケーション支援方法、コミュニケーション支援システム、端末装置及び非言語表現プログラム
Coursey et al. Living with harmony: a personal companion system by Realbotix™
WO2018033066A1 (zh) 机器人的控制方法及陪伴机器人
KR20220129989A (ko) 아바타에 기초한 인터랙션 서비스 방법 및 장치
KR20150095515A (ko) 캐릭터 인형을 이용한 반응형 감성 스마트 토이 시스템
Plourde Babymetal and the Ambivalence of Cuteness
Wang et al. Smart design of intelligent companion toys for preschool children
Cantrell Designing intent: defining critical meaning for nime practitioners.
Wang et al. Internet of toys: an e-Pet overview and proposed innovative social toy service platform
Mival et al. Personification technologies: Developing artificial companions for older people
Falkenberg et al. Creating digital musical instruments with and for children: Including vocal sketching as a method for engaging in codesign
CN202078739U (zh) 一种具有点读功能的智能玩具
CN114712862A (zh) 虚拟宠物交互方法、电子设备及计算机可读存储介质
JP7310907B2 (ja) 対話方法、対話システム、対話装置、およびプログラム
Rizzo et al. The design of udoo boards: contributing to the appropriation of digital technology
Dechaine et al. Linguistics for dummies
Lwin Whose stuff is it?: A museum storyteller’s strategies to engage her audience
Marti Autonomous interactive intermediaries: social intelligence for mobile communication agents
Sutton-Spence et al. Creative Sign Language

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C02 Deemed withdrawal of patent application after publication (patent law 2001)
WD01 Invention patent application deemed withdrawn after publication