k !X;ENCODING FOR VOICEBOX EDITORX; by A. A. NOGASNX;FORMAT FROM BASIC: X=USR(ADR(MATCH$),ADR(ALLO$),ADR(INBUF$),ADR(OUTBUF$))X;(X;SYSTEM EQUATES2 FR0< ERRFGFX;P%X;DELIMITER EQUATES (ASCII VALUES)Z SPACE d STAR*n COMMA,x PERIOD. SLASH/ SEMI;X;X;PROGRAM EQUATES PGSIX CONTFG;;Continuation flgOLDLEN;;Pntr to bufferOUTOFF;;Pntr to bufferINOFF;;Offset into;input stringCDOFF;;Offset intoCDOFF;;decode stringENCODE;;CounterOLDAL;;Offset INBUF$DELIM;;Delimiter storgeBUFIN;;Allophone bufferBUFMAT ;;matching bufferBUFOUT;;Output buffer"X;,X;PROGRAM ZERO-PAGE VECTORS6 OUTVEC@ INVECJ CDVECTX;^hX;rX;PROGRAM STARTS HERE|X;SETUP ZERO-PAGE VECTORS7;;# OF ARGUMENTS$>;;SET COUNTERLOOP17;:MOVE VECT addrsPOUTVEC90;;ARE WE DONE?HLOOP1;;NO, CONTINUEX;"X;CLEAR PAGE 6 POINTERS/BUFFERSQCONTFG;;CHECK FOR;CONTINUATIONFCLEAR;;BRANCHX;#X;UPON CONTINUATION CLEAR PAGE 6X;NOT USED BY ROUTINEQ>$>;;SKIP CONTFG AND  ;OLDLEN LOOP2PPGSIX9;;CLEAR PROGRAM;POINTERS/COUNTERS2&(>;;ARE WE DONE?0HLOOP2;;IF NOT, CONTINUE:$OLDLEN;;GET OFFSETD &OUTOFFN LOOP3PBUFOUT9;;CLEAR UNUSEDS;OUTPUT BUFFERX2b(>;;ARE WE DONE?lHLOOP3;;NO, CONTINUEvFGET1;;YES, BRANCHX;#X;CLEAR PAGE SIX-no continuationCLEARA;;PUT 0 IN ALOOP4PPGSIX92HLOOP4;;CONTINUEX;X;LOAD ALLOPHONE INTO BUFINX;%X;PREPARE TO CODE NEW ALLOPHONE --X;CLEAR INPUT BUFFER GET1Q> PENCODE PCDOFF PBUFIN  PBUFIN PBUFIN X;*#X;GET AN ALLOPHONE TO BE ENCODED4%INOFF;;GET OFFSET>$>HLOOP5Q@INVEC7;;NEXT CHARRX;\X;CHECK FOR DELIMITERf R>SPACEpFDLSET;;BRANCH OUTz R>COMMA FDLSET R>PERIOD FDLSET R>SLASH FDLSET R>SEMI FDLSET R>STAR FDLSETX;X;CHECK FOR BUFIN OVERFLOW(>;;IS BUFFER FULL?FERR1;;BUFFER OVERFLOWX;X;STORE ALLOPHONE CHARACTER X;CHARACTER IS IN ACCUMULATORX;OFFSET IN X REGISTER$ PBUFIN9.2;;UPDATE COUNTERS83B;;;FLAG BRANCHLELOOP5;;ALWAYS TAKENVX;`#X;ERROR -- INPUT BUFFER OVERFLOWjERR1%OLDAL;;GET POINTERtQ@INVEC7;;FIRST CHAR~L>;;CONVERTP@INVEC7;;STORE BACK$>;;CLEAR F.P.&FR02;;1=BUFFER OVERFLO &ERRFG:X;X;PASS BRANCH BACK TO GET1GET2EGET1X;X;STORE DELIMITER CHARACTER X;CHARACTER IS IN ACCUMULATOR DLSETPDELIM;;SAVE DELIMITER 3'INOFF;;POINT TO FIRSTX; CHARACTER AFTER DELIMITERX;(!X;CLEAR DECODE MATCHING BUFFER2CLRMATQ>< PBUFMATFPBUFMATPPBUFMATZX;d%X;MOVE DECODE ALLOPHONES TO BUFFERn$>x %CDOFFLOOP6Q@CDVEC7;;DECODE CHARGEXCODE;;EXIT LOOPPBUFMAT9;;STORE23;;;FLAG BRANCHELOOP6;;ALWAYS TAKENX;X;END OF MATCH ALLOPHONEEXCODEM>;;TURN OFF HI BIT PBUFMAT93'CDOFF;;POINT NEXT ALLOX;$X;ATTEMPT MATCH OF BUFIN & BUFMAT QBUFIN" RBUFMAT, HNXTRY6 QBUFIN@RBUFMATJ HNXTRYT QBUFIN^RBUFMATh HNXTRYr;;;FLAG BRANCH|ESTORE;;MATCH SUCCESSFULX;"X;FAILURE TO MATCH ALLO IN BUIN!NXTRY#ENCODE;;UPDATE COUNTERQENCODE;;END OF CODES?R>A;;ARE WE DONE?FERR2;;NO, FLAG ERROR;;;FLAG BRANCH ECLRMATX;X;ERROR -- ILLEGAL ALLOPHONEERR2%OLDAL;;OFFSET TO ALLOQ@INVEC7;;GET FIRST CHARL>;:CONVERTP@INVEC7;;STORE BACK$>;;F.P. REGISTER 0&FR0&202;;2=ILLEGAL ALLO:&ERRFG;;SET ERROR CODED:NX;XX;PASS BRANCH BACK TO GET2bGET3EGET2lX;vX;PERFORM ANY TRANSLATIONSTORE$OUTOFFQENCODE;;GET CODE COUNTERR>";;ASCII QUOTATION?HSTORE2;;NO, NULL MATCH?L>@;;CONVERT TO "b"STORE2R>@HSTORE3;;STORE ALLO CODE;EDLOUT;;NO OUTPUTSTORE3PBUFOUT9;;CODED ALLO#OUTOFF;;UPDATE BUF PNTR2(>;;BUFFER OVERFLOW?FERR3;;GO ERROR ROUTINE X; X;PERFORM DELIMITER FUNCTIONS "X;X = OFFSET INTO OUTPUT BUFFER*"DLOUTQDELIM;;RECOVER DELIMITR4 R>SLASH> HDLOUT2H;R ELPBK2\X;fX;CHECK FOR SPACEpDLOUT2R>SPACEz HDLOUT3Q>;;50 ms silence PBUFOUT9; ELPBKX;X;CHECK FOR COMMADLOUT3R>COMMA HDLOUT4Q>;;100 ms silence PBUFOUT9; ELPBKX; X;CHECK FOR PERIOD DLOUT4R>PERIOD HDLOUT5$ Q>;;200 ms silence. PBUFOUT98 X;B %X;RETURN FOR NXT ALLOPHONE ROUTINEL "LPBK#OUTOFF;;MOVE OUTPUT PNTRV 2` (>;;BUFFER OVERFLOW?j FERR3t LPBK2QINOFF~ POLDAL;;ERROR OFFSET ; EGET3 X; !X;ERROR -- OUTPUT BUF OVERFLOW ERR3%OLDAL LOOP7Q@INVEC7 L> P@INVEC7 3 )INOFF;;ARE WE DONE? HLOOP7;;NO, CONTINUE $>;;F.P. REGISTER 0 &FR0 $>;;ERROR CODE &ERRFG :( X;2 #X;CONTINUATION OF DELIMITER FUNC< X;CHECK FOR SEMICOLONF DLOUT5R>SEMIP HDLOUT6Z &OLDLEN;;SET BUFF POINTERd Q>n PCONTFG;;FLG CONTINUATIONx : X; X;DELIMITER MUST BE * (EOL) DLOUT6Q> PBUFOUT9;;10 ms silence PCONTFG;;CLEAR FLAG PERRFG;;CLEAR ERRORS 2;;CONVERT OFFSET &FR0;;STORE LENGTH %FR0;;GET COUNT MOVBUF1;;UPDATE POINTER QBUFOUT8;;GET DATA P@OUTVEC7;;PUT INTO STR )>;;ARE WE DONE? HMOVBUF :