************************************************************************                                                                       **       SYSTEM INTERRUPT 6 10mS Clock                                   **                                                                       **************************************************************************DDCA	BCC &DE47   ;bit 6 is in carry so if clear there is no 6 int    	            ;so go on to DE47DDCC	LDA #&40    ;Clear interrupt 6DDCE	STA &FE4D   ;;UPDATE timers routine, There are 2 timer stores &292-6 and &297-B;these are updated by adding 1 to the current timer and storing the;result in the other, the direction of transfer being changed each;time of update.  This ensures that at least 1 timer is valid at any call;as the current timer is only read.  Other methods would cause inaccuracies;if a timer was read whilst being updated.DDD1	LDA &0283   ;get current system clock store pointer (5,or 10)DDD4	TAX         ;put A in XDDD5	EOR #&0F    ;and invert lo nybble (5 becomes 10 and vv)DDD7	PHA         ;store ADDD8	TAY         ;put A in Y    	            ;Carry is always set at this pointDDD9	LDA &0291,X ;get timer valueDDDC	ADC #&00    ;update itDDDE	STA &0291,Y ;store result in alternateDDE1	DEX         ;decrement XDDE2	BEQ &DDE7   ;if 0 exitDDE4	DEY         ;else decrement YDDE5	BNE &DDD9   ;and go back and do next byteDDE7	PLA         ;get back ADDE8	STA &0283   ;and store back in clock pointer (i.e. inverse previous    	            ;contents)DDEB	LDX #&05    ;set loop pointer for countdown timerDDED	INC &029B,X ;increment byte and ifDDF0	BNE &DDFA   ;not 0 then DDFADDF2	DEX         ;else decrement pointerDDF3	BNE &DDED   ;and if not 0 do it againDDF5	LDY #&05    ;process EVENT 5 interval timerDDF7	JSR &E494   ;DDFA	LDA &02B1   ;get byte of inkey countdown timerDDFD	BNE &DE07   ;if not 0 then DE07DDFF	LDA &02B2   ;else get next byteDE02	BEQ &DE0A   ;if 0 DE0ADE04	DEC &02B2   ;decrement 2B2DE07	DEC &02B1   ;and 2B1DE0A	BIT &02CE   ;read bit 7 of envelope processing byteDE0D	BPL &DE1A   ;if 0 then DE1ADE0F	INC &02CE   ;else increment to 0DE12	CLI         ;allow interruptsDE13	JSR &EB47   ;and do routine sound processesDE16	SEI         ;bar interruptsDE17	DEC &02CE   ;DEC envelope processing byte back to 0DE1A	BIT &02D7   ;read speech buffer busy flagDE1D	BMI &DE2B   ;if set speech buffer is empty, skip routineDE1F	JSR &EE6D   ;update speech system variablesDE22	EOR #&A0    ;DE24	CMP #&60    ;DE26	BCC &DE2B   ;if result >=&60 DE2BDE28	JSR &DD79   ;else more speech workDE2B	BIT &D9B7   ;set V and CDE2E	JSR &DCA2   ;check if ACIA needs attentionDE31	LDA &EC     ;check if key has been pressedDE33	ORA &ED     ;DE35	AND &0242   ;(this is 0 if keyboard is to be ignored, else &FF)DE38	BEQ &DE3E   ;if 0 ignore keyboardDE3A	SEC         ;else set carryDE3B	JSR &F065   ;and call keyboardDE3E	JSR &E19B   ;check for data in user defined printer channelDE41	BIT &FEC0   ;if ADC bit 6 is set ADC is not busyDE44	BVS &DE4A   ;so DE4ADE46	RTS         ;else return    	            ;**************************************************************************                                                                       **       SYSTEM INTERRUPT 4 ADC end of conversion                        **                                                                       **************************************************************************DE47	ROL         ;put original bit 4 from FE4D into bit 7 of ADE48	BPL &DE72   ;if not set DE72DE4A	LDX &024C   ;else get current ADC channelDE4D	BEQ &DE6C   ;if 0 DE6CDE4F	LDA &FEC2   ;read low data byteDE52	STA &02B5,X ;store it in &2B6,7,8 or 9DE55	LDA &FEC1   ;get high data byteDE58	STA &02B9,X ;and store it in hi byteDE5B	STX &02BE   ;store in Analogue system flag marking last channelDE5E	LDY #&03    ;handle event 3 conversion completeDE60	JSR &E494   ;DE63	DEX         ;decrement XDE64	BNE &DE69   ;if X=0DE66	LDX &024D   ;get highest ADC channel presenyDE69	JSR &DE8F   ;and start new conversionDE6C	LDA #&10    ;reset interrupt 4DE6E	STA &FE4D   ;DE71	RTS         ;and return**************************************************************************                                                                       **       SYSTEM INTERRUPT 0 Keyboard                                     **                                                                       **************************************************************************    	            ;DE72	ROL         ;get original bit 0 in bit 7 positionDE73	ROL         ;DE74	ROL         ;DE75	ROL         ;DE76	BPL &DE7F   ;if bit 7 clear not a keyboard interruptDE78	JSR &F065   ;else scan keyboardDE7B	LDA #&01    ;A=1DE7D	BNE &DE6E   ;and off to reset interrupt and exitDE7F	JMP &DCF3   ;************** exit routine *********************************************DE82	PLA         ;restore registersDE83	TAY         ;DE84	PLA         ;DE85	TAX         ;DE86	PLA         ;DE87	STA &FC     ;store A**************************************************************************                                                                       **       IRQ2V default entry                                             **************************************************************************DE89	LDA &FC     ;get back original value of ADE8B	RTI         ;and return to calling routine**************************************************************************                                                                       **       OSBYTE 17 Start conversion                                      **                                                                       **************************************************************************    	            ;DE8C	STY &02BE   ;set last channel to finish conversionDE8F	CPX #&05    ;if X<4 thenDE91	BCC &DE95   ;DE95DE93	LDX #&04    ;else X=4DE95	STX &024C   ;store it as current ADC channelDE98	LDY &024E   ;get conversion typeDE9B	DEY         ;decrementDE9C	TYA         ;A=YDE9D	AND #&08    ;and it with 08DE9F	CLC         ;clear carryDEA0	ADC &024C   ;add to current ADCDEA3	SBC #&00    ;-1DEA5	STA &FEC0   ;store to the A/D control panelDEA8	RTS         ;and return    	            ;DEA9	LDA #&C3    ;point to start of string @&C300DEAB	STA &FE     ;store itDEAD	LDA #&00    ;point to lo byteDEAF	STA &FD     ;store it and start loop@DEB1	INY         ;print character in stringDEB2	LDA (&FD),Y ;pointed to by &FD/EDEB4	JSR OSASCI  ;print it expanding Carriage returnsDEB7	TAX         ;store A in XDEB8	BNE &DEB1   ;and loop again if not =0DEBA	RTS         ;else exit*********** OSBYTE 129 TIMED ROUTINE ******************************;ON ENTRY TIME IS IN X,YDEBB	STX &02B1   ;store time in INKEY countdown timerDEBE	STY &02B2   ;which is decremented every 10msDEC1	LDA #&FF    ;A=&FF to flag timed waitDEC3	BNE &DEC7   ;goto DEC7******************************************************************************************************************************************************                                                                      ****      OSRDCH Default entry point                                      ****                                                                      ****      RDCHV entry point       read a character                        ****                                                                      ******************************************************************************************************************************************************DEC5	LDA #&00    ;A=0 to flag wait foreverDEC7	STA &E6     ;store entry value of ADEC9	TXA         ;save X and YDECA	PHA         ;DECB	TYA         ;DECC	PHA         ;DECD	LDY &0256   ;get *EXEC file handleDED0	BEQ &DEE6   ;if 0 (not open) then DEE6DED2	SEC         ;set carryDED3	ROR &EB     ;set bit 7 of CFS active flag to prevent clashesDED5	JSR OSBGET  ;get a byte from the fileDED8	PHP         ;push processor flags to preserve carryDED9	LSR &EB     ;restore &EBDEDB	PLP         ;get back flagsDEDC	BCC &DF03   ;and if carry clear, character found so exit via DF03DEDE	LDA #&00    ;else A=00 as EXEC file emptyDEE0	STA &0256   ;store it in exec file handleDEE3	JSR OSFIND  ;and close file via OSFINDDEE6	BIT &FF     ;check ESCAPE flag, if bit 7 set Escape pressedDEE8	BMI &DF00   ;so off to DF00DEEA	LDX &0241   ;else get current input buffer numberDEED	JSR &E577   ;get a byte from input bufferDEF0	BCC &DF03   ;and exit if character returnedDEF2	BIT &E6     ;(E6=0 or FF)DEF4	BVC &DEE6   ;if entry was OSRDCH not timed keypress, so go back and    	            ;do it again i.e. perform GET functionDEF6	LDA &02B1   ;else check timersDEF9	ORA &02B2   ;DEFC	BNE &DEE6   ;and if not zero go round againDEFE	BCS &DF05   ;else exitDEF0             ..   BCC &DF03DEF2             $æ   BIT &E6DEF4             Pð   BVC &DEE6DEF6             ­±.  LDA &02B1DEF9             .².  ORA &02B2DEFC             Ðè   BNE &DEE6DEFE             °.   BCS &DF05DF00             8    SECDF01             ©.   LDA #&1BDF03             .æ   STA &E6DF05             h    PLADF06             ¨    TAYDF07             h    PLADF08             ª    TAXDF09             ¥æ   LDA &E6DF0B             `    RTS