OS SERIES VI GEOFF COX ************************************************************************* * * * PRINTER DRIVER * * * ************************************************************************* ;A=character to print E114 BIT &027C ;if bit 6 of VDU byte =1 printer is disabled E117 BVS &E139 ;so E139 E119 CMP &0286 ;compare with printer ignore character E11C BEQ &E139 ;if the same E139 E11E PHP ;else save flags E11F SEI ;bar interrupts E120 TAX ;X=A E121 LDA #&04 ;A=4 E123 BIT &027C ;read bit 2 'disable printer driver' E126 BNE &E138 ;if set printer is disabled so exit E138 E128 TXA ;else A=X E129 LDX #&03 ;X=3 E12B JSR &E1F8 ;and put character in printer buffer E12E BCS &E138 ;if carry set on return exit, buffer not full (empty?) E130 BIT &02D2 ;else check buffer busy flag if 0 E133 BPL &E138 ;then E138 to exit E135 JSR &E13A ;else E13A to open printer cahnnel E138 PLP ;get back flags E139 RTS ;and exit E13A LDA &0285 ;check printer destination E13D BEQ &E1AD ;if 0 then E1AD clear printer buffer and exit E13F CMP #&01 ;if parallel printer not selected E141 BNE &E164 ;E164 E143 JSR &E460 ;else read a byte from the printer buffer E146 ROR &02D2 ;if carry is set then 2d2 is -ve E149 BMI &E190 ;so return via E190 E14B LDY #&82 ;else enable interrupt 1 of the external VIA E14D STY &FE6E ; E150 STA &FE61 ;pass code to centronics port E153 LDA &FE6C ;pulse CA2 line to generate STROBE signal E156 AND #&F1 ;to advise printer that E158 ORA #&0C ;valid data is E15A STA &FE6C ;waiting E15D ORA #&0E ; E15F STA &FE6C ; E162 BNE &E190 ;then exit *********:serial printer ********************************************* E164 CMP #&02 ;is it Serial printer?? E166 BNE &E191 ;if not E191 E168 LDY &EA ;else is RS423 in use by cassette?? E16A DEY ; E16B BPL &E1AD ;if so E1AD to flush buffer E16D LSR &02D2 ;else clear buffer busy flag E170 LSR &024F ;and RS423 busy flag E173 JSR &E741 ;count buffer if C is clear on return E176 BCC &E190 ;no room in buffer so exit E178 LDX #&20 ;else E17A LDY #&9F ; ************************************************************************* * * * OSBYTE 156 update ACIA setting and RAM copy * * * ************************************************************************* ;on entry E17C PHP ;push flags E17D SEI ;bar interrupts E17E TYA ;A=Y E17F STX &FA ;&FA=X E181 AND &0250 ;A=old value AND Y EOR X E184 EOR &FA ; E186 LDX &0250 ;get old value in X E189 STA &0250 ;put new value in E18C STA &FE08 ;and store to ACIA control register E18F PLP ;get back flags E190 RTS ;and exit ************ printer is neither serial or parallel so its user type ***** E191 CLC ;clear carry E192 LDA #&01 ;A=1 E194 JSR &E1A2 ; ************************************************************************* * * * OSBYTE 123 Warn printer driver going dormant * * * ************************************************************************* E197 ROR &02D2 ;mark printer buffer empty for osbyte E19A RTS ;and exit E19B BIT &02D2 ;if bit 7 is set buffer is empty E19E BMI &E19A ;so exit E1A0 LDA #&00 ;else A=0 E1A2 LDX #&03 ;X=3 E1A4 LDY &0285 ;Y=printer destination E1A7 JSR &E57E ;to JMP (NETV) E1AA JMP (&0222) ;jump to PRINT VECTOR for special routines *************** Buffer handling ***************************************** ;X=buffer number ;Buffer number Address Flag Out pointer In pointer ;0=Keyboard 3E0-3FF 2CF 2D8 2E1 ;1=RS423 Input A00-AFF 2D0 2D9 2E2 ;2=RS423 output 900-9BF 2D1 2DA 2E3 ;3=printer 880-8BF 2D2 2DB 2E4 ;4=sound0 840-84F 2D3 2DC 2E5 ;5=sound1 850-85F 2D4 2DD 2E6 ;6=sound2 860-86F 2D5 2DE 2E7 ;7=sound3 870-87F 2D6 2DF 2E8 ;8=speech 8C0-8FF 2D7 2E0 2E9 E1AD CLC ;clear carry E1AE PHA ;save A E1AF PHP ;save flags E1B0 SEI ;set interrupts E1B1 BCS &E1BB ;if carry set on entry then E1BB E1B3 LDA &E9AD,X ;else get byte from baud rate/sound data table E1B6 BPL &E1BB ;if +ve the E1BB E1B8 JSR &ECA2 ;else clear sound data E1BB SEC ;set carry E1BC ROR &02CF,X ;rotate buffer flag to show buffer empty E1BF CPX #&02 ;if X>1 then its not an input buffer E1C1 BCS &E1CB ;so E1CB E1C3 LDA #&00 ;else Input buffer so A=0 E1C5 STA &0268 ;store as length of key string E1C8 STA &026A ;and length of VDU queque E1CB JSR &E73B ;then enter via count purge vector any user routines E1CE PLP ;restore flags E1CF PLA ;restore A E1D0 RTS ;and exit ************************************************************************* * * * COUNT PURGE VECTOR DEFAULT ENTRY * * * * * ************************************************************************* ;on entry if V set clear buffer ; if C set get space left ; else get bytes used E1D1 BVC &E1DA ;if bit 6 is set then E1DA E1D3 LDA &02D8,X ;else start of buffer=end of buffer E1D6 STA &02E1,X ; E1D9 RTS ;and exit E1DA PHP ;push flags E1DB SEI ;bar interrupts E1DC PHP ;push flags E1DD SEC ;set carry E1DE LDA &02E1,X ;get end of buffer E1E1 SBC &02D8,X ;subtract start of buffer E1E4 BCS &E1EA ;if carry caused E1EA E1E6 SEC ;set carry E1E7 SBC &E447,X ;subtract buffer start offset (i.e. add buffer length) E1EA PLP ;pull flags E1EB BCC &E1F3 ;if carry clear E1F3 to exit E1ED CLC ;clear carry E1EE ADC &E447,X ;adc to get bytes used E1F1 EOR #&FF ;and invert to get space left E1F3 LDY #&00 ;Y=0 E1F5 TAX ;X=A E1F6 PLP ;get back flags E1F7 RTS ;and exit ********** enter byte in buffer, wait and flash lights if full ********** E1F8 SEI ;prevent interrupts E1F9 JSR &E4B0 ;entera byte in buffer X E1FC BCC &E20D ;if successful exit E1FE JSR &E9EA ;else switch on both keyboard lights E201 PHP ;push p E202 PHA ;push A E203 JSR &EEEB ;switch off unselected LEDs E206 PLA ;get back A E207 PLP ;and flags E208 BMI &E20D ;if return is -ve Escape pressed so exit E20A CLI ;else allow interrupts E20B BCS &E1F8 ;if byte didn't enter buffer go and try it again E20D RTS ;then return ************************************************************************* * * * SAVE/LOAD ENTRY * * * * * ************************************************************************* **************: clear osfile control block workspace ******************** E20E PHA ;push A E20F LDA #&00 ;A=0 E211 STA &02EE,X ;clear osfile control block workspace E214 STA &02EF,X ; E217 STA &02F0,X ; E21A STA &02F1,X ; E21D PLA ;get back A E21E RTS ;and exit *********** shift through osfile control block ************************** E21F STY &E6 ;&E6=Y E221 ROL ;A=A*2 E222 ROL ;*4 E223 ROL ;*8 E224 ROL ;*16 E225 LDY #&04 ;Y=4 E227 ROL ;A=A*32 E228 ROL &02EE,X ;shift bit 7 of A into shift register E22B ROL &02EF,X ;and E22E ROL &02F0,X ;shift E231 ROL &02F1,X ;along E234 BCS &E267 ;if carry set on exit then register has overflowed ;so bad address error E236 DEY ;decrement Y E237 BNE &E227 ;and if Y>0 then do another shift E239 LDY &E6 ;get back original Y E23B RTS ;and exit ************************************************************************* * * * *LOAD ENTRY * * * * * ************************************************************************* E23C LDA #&FF ;signal that load is being performed ************************************************************************* * * * *SAVE ENTRY * * * * * ************************************************************************* ;on entry A=0 for save &ff for load E23E STX &F2 ;store address of rest of command line E240 STY &F3 ; E242 STX &02EE ;x and Y are stored in OSfile control block E245 STY &02EF ; E248 PHA ;Push A E249 LDX #&02 ;X=2 E24B JSR &E20E ;clear the shift register E24E LDY #&FF ;Y=255 E250 STY &02F4 ;store im 2F4 E253 INY ;increment Y E254 JSR &EA1D ;and call GSINIT to prepare for reading text line E257 JSR &EA2F ;read a code from text line if OK read next E25A BCC &E257 ;until end of line reached E25C PLA ;get back A without stack changes E25D PHA ; E25E BEQ &E2C2 ;IF A=0 (SAVE) E2C2 E260 JSR &E2AD ;set up file block E263 BCS &E2A0 ;if carry set do OSFILE E265 BEQ &E2A5 ;else if A=0 goto OSFILE E267 BRK ; E268 DB &FC ; E269 DB 'Bad Address' ;error E274 BRK ; ************************************************************************* * * * OSBYTE 119 ENTRY * * CLOSE SPOOL/ EXEC FILES * * * ************************************************************************* E275 LDX #&10 ;X=10 issue *SPOOL/EXEC files warning E277 JSR &F168 ;and issue call E27A BEQ &E29F ;if a rom accepts and issues a 0 then E29F to return E27C JSR &F68B ;else close the current exec file E27F LDA #&00 ;A=0 ************************************************************************** ************************************************************************** ** ** ** ** ** *SPOOL ** ** ** ************************************************************************** ************************************************************************** E281 PHP ;if A=0 file is closed so E282 STY &E6 ;Store Y E284 LDY &0257 ;get file handle E287 STA &0257 ;store A as file handle E28A BEQ &E28F ;if Y<>0 then E28F E28C JSR OSFIND ;else close file via osfind E28F LDY &E6 ;get back original Y E291 PLP ;pull flags E292 BEQ &E29F ;if A=0 on entry then exit E294 LDA #&80 ;else A=&80 E296 JSR OSFIND ;to open file Y for output E299 TAY ;Y=A E29A BEQ &E310 ;and if this is =0 then E310 BAD COMMAND ERROR E29C STA &0257 ;store file handle E29F RTS ;and exit E2A0 BNE &E310 ;if NE then BAD COMMAND error E2A2 INC &02F4 ;increment 2F4 to 00 E2A5 LDX #&EE ;X=&EE E2A7 LDY #&02 ;Y=&02 E2A9 PLA ;get back A E2AA JMP OSFILE ;and JUMP to OSFILE **** check for hex digit ************************************************ E2AD JSR &E03A ;look for NEWline E2B0 JSR &E08F ;carry is set if it finds hex digit E2B3 BCC &E2C1 ;so E2C1 exit E2B5 JSR &E20E ;clear shift register ************** shift byte into control block *************************** E2B8 JSR &E21F ;shift lower nybble of A into shift register E2BB JSR &E08F ;then check for Hex digit E2BE BCS &E2B8 ;if found then do it again E2C0 SEC ;else set carry E2C1 RTS ;and exit **************; set up OSfile control block **************************** E2C2 LDX #&0A ;X=0A E2C4 JSR &E2AD ; E2C7 BCC &E310 ;if no hex digit found EXIT via BAD Command error E2C9 CLV ;clear bit 6 ******************READ file length from text line************************ E2CA LDA (&F2),Y ;read next byte from text line E2CC CMP #&2B ;is it '+' E2CE BNE &E2D4 ;if not assume its a last byte address so e2d4 E2D0 BIT &D9B7 ;else set V and M flags E2D3 INY ;increment Y to point to hex group E2D4 LDX #&0E ;X=E E2D6 JSR &E2AD ; E2D9 BCC &E310 ;if carry clear no hex digit so exit via error E2DB PHP ;save flags E2DC BVC &E2ED ;if V set them E2ED explicit end address found E2DE LDX #&FC ;else X=&FC E2E0 CLC ;clear carry E2E1 LDA &01FC,X ;and add length data to start address E2E4 ADC &0200,X ; E2E7 STA &0200,X ; E2EA INX ; E2EB BNE &E2E1 ;repeat until X=0 E2ED LDX #&03 ;X=3 E2EF LDA &02F8,X ;copy start adddress to load and execution addresses E2F2 STA &02F4,X ; E2F5 STA &02F0,X ; E2F8 DEX ; E2F9 BPL &E2EF ; E2FB PLP ;get back flag E2FC BEQ &E2A5 ;if end of command line reached then E2A5 ; to do osfile E2FE LDX #&06 ;else set up execution address E300 JSR &E2AD ; E303 BCC &E310 ;if error BAD COMMAND E305 BEQ &E2A5 ;and if end of line reached do OSFILE E307 LDX #&02 ;else set up load address E309 JSR &E2AD ; E30C BCC &E310 ;if error BAD command E30E BEQ &E2A5 ;else on end of line do OSFILE ;anything else is an error!!!! ******** Bad command error ************************************ E310 BRK ; E311 DB &FE ;error number E312 DB 'Bad Command' ; E31D BRK E31E DB &FB ; E31F DB 'Bad Key' ; E326 BRK ************************************************************************* * * * *KEY ENTRY * * * ************************************************************************* E327 JSR &E04E ;set up key number in A E32A BCC &E31D ;if not valid number give error E32C CPX #&10 ;if key number greater than 15 E32E BCS &E31D ;if greater then give error E330 JSR &E045 ;otherwise skip commas, and check for CR E333 PHP ;save flags for later E334 LDX &0B10 ;get pointer to top of existing key strings E337 TYA ;save Y E338 PHA ;to preserve text pointer E339 JSR &E3D1 ;set up soft key definition E33C PLA ;get back Y E33D TAY ; E33E PLP ;and flags E33F BNE &E377 ;if CR found return else E377 to set up new string E341 RTS ;else return to set null string ************************************************************************* * * * *FX OSBYTE * * * ************************************************************************* A=number E342 JSR &E04E ;convert the number to binary E345 BCC &E310 ;if bad number call bad command E347 TXA ;save X ************************************************************************* * * * *CODE *MOTOR *OPT *ROM *TAPE *TV * * * ************************************************************************* ;enter codes *CODE &88 *MOTOR &89 *OPT &8B *TAPE &8C *ROM &8D *TV &90 E348 PHA ;save A E349 LDA #&00 ;clear &E4/E5 E34B STA &E5 ; E34D STA &E4 ; E34F JSR &E043 ;skip commas and check for newline (CR) E352 BEQ &E36C ;if CR found E36C E354 JSR &E04E ;convert character to binary E357 BCC &E310 ;if bad character bad command error E359 STX &E5 ;else save it E35B JSR &E045 ;skip comma and check CR E35E BEQ &E36C ;if CR then E36C E360 JSR &E04E ;get another parameter E363 BCC &E310 ;if bad error E365 STX &E4 ;else store in E4 E367 JSR &E03A ;now we must have a newline E36A BNE &E310 ;if none then output an error E36C LDY &E4 ;Y=third osbyte parameter E36E LDX &E5 ;X=2nd E370 PLA ;A=first E371 JSR OSBYTE ;call osbyte E374 BVS &E310 ;if V set on return then error E376 RTS ;else RETURN ********* *KEY CONTINUED ************************************************ ;X points to last byte of current key definitions E377 SEC ; E378 JSR &EA1E ;look for '"' on return bit 6 E4=1 bit 7=1 if '"'found ;this is a GSINIT call without initial CLC E37B JSR &EA2F ;call GSREAD carry is set if end of line found E37E BCS &E388 ;E388 to deal with end of line E380 INX ;point to first byte of new key definition E381 BEQ &E31D ;if X=0 buffer WILL overflow so exit with BAD KEY error E383 STA &0B00,X ;store character E386 BCC &E37B ;and loop to get next byte if end of line not found E388 BNE &E31D ;if Z clear then no matching '"' found or for some ;other reason line doesn't terminate properly E38A PHP ;else if all OK save flags E38B SEI ;bar interrupts E38C JSR &E3D1 ;and move string E38F LDX #&10 ;set loop counter E391 CPX &E6 ;if key being defined is found E393 BEQ &E3A3 ;then skip rest of loop E395 LDA &0B00,X ;else get start of string X