E398 CMP &0B00,Y ;compare with start of string Y E39B BNE &E3A3 ;if not the same then skip rest of loop E39D LDA &0B10 ;else store top of string definition E3A0 STA &0B00,X ;in designated key pointer E3A3 DEX ;decrement loop pointer X E3A4 BPL &E391 ;and do it all again E3A6 PLP ;get back flags E3A7 RTS ;and exit ***********: set string lengths ***************************************** E3A8 PHP ;push flags E3A9 SEI ;bar interrupts E3AA LDA &0B10 ;get top of currently defined strings E3AD SEC ; E3AE SBC &0B00,Y ;subtract to get the number of bytes in strings ;above end of string Y E3B1 STA &FB ;store this E3B3 TXA ;save X E3B4 PHA ; E3B5 LDX #&10 ;and X=16 E3B7 LDA &0B00,X ;get start offset (from B00) of key string X E3BA SEC ; E3BB SBC &0B00,Y ;subtract offset of string we are working on E3BE BCC &E3C8 ;if carry clear (B00+Y>B00+X) or E3C0 BEQ &E3C8 ;result (in A)=0 E3C2 CMP &FB ;or greater or equal to number of bytes above ;string we are working on E3C4 BCS &E3C8 ;then E3C8 E3C6 STA &FB ;else store A in &FB E3C8 DEX ;point to next lower key offset E3C9 BPL &E3B7 ;and if 0 or +ve go back and do it again E3CB PLA ;else get back value of X E3CC TAX ; E3CD LDA &FB ;get back latest value of A E3CF PLP ;pull flags E3D0 RTS ;and return ***********: set up soft key definition ********************************* E3D1 PHP ;push P E3D2 SEI ;bar interrupts E3D3 TXA ;save X E3D4 PHA ;push A E3D5 LDY &E6 ;get key number E3D7 JSR &E3A8 ;and set up &FB E3DA LDA &0B00,Y ;get start of string E3DD TAY ;put it in Y E3DE CLC ;clear carry E3DF ADC &FB ;add number of bytes above string E3E1 TAX ;put this in X E3E2 STA &FA ;and store it E3E4 LDA &0268 ;check number of bytes left to remove from key buffer ;if not 0 key is being used (definition expanded so ;error. This stops *KEY 1 "*key1 FRED" etc. E3E7 BEQ &E3F6 ;if not in use continue E3E9 BRK ; E3EA DB &FA ;error number E3EB DB 'Key in use' ; E3F5 BRK ; E3F6 DEC &0284 ;decrement consistence flag to &FF to warn that key ;definitions are being changed E3F9 PLA ;pull A E3FA SEC ; E3FB SBC &FA ;subtract &FA E3FD STA &FA ;and re store it E3FF BEQ &E40D ;if 0 then E40D E401 LDA &0B01,X ;else move string E404 STA &0B01,Y ;from X to Y E407 INY ; E408 INX ; E409 DEC &FA ;for length of string E40B BNE &E401 ; E40D TYA ;store end of moved string(s) E40E PHA ; E40F LDY &E6 ;get back key number E411 LDX #&10 ;point at top of last string E413 LDA &0B00,X ;get this value E416 CMP &0B00,Y ;compare it with start of new or re defined key E419 BCC &E422 ;if less then E422 E41B BEQ &E422 ;if = then E422 E41D SBC &FB ;shift key definitions accordingly E41F STA &0B00,X ; E422 DEX ;point to next lowest string def E423 BPL &E413 ;and if =>0 then loop and do it again E425 LDA &0B10 ;else make top of key definitions E428 STA &0B00,Y ;the start of our key def E42B PLA ;get new end of strings E42C STA &0B10 ;and store it E42F TAX ;put A in X E430 INC &0284 ;reset consistency flag E433 PLP ;restore flags E434 RTS ;and exit **************** BUFFER ADDRESS HI LOOK UP TABLE ************************ E435 DB &03 E436 DB &0A E437 DB &08 E438 DB &07 E439 DB &07 E43A DB &07 E43B DB &07 E43C DB &07 **************** BUFFER ADDRESS LO LOOK UP TABLE ************************ E43D DB &09 E43E DB &00 E43F DB &00 E440 DB &C0 E441 DB &C0 E442 DB &50 E443 DB &60 E444 DB &70 **************** BUFFER START ADDRESS OFFSET **************************** E445 DB &80 E446 DB &00 E447 DB &E0 E448 DB &00 E449 DB &40 E44A DB &C0 E44B DB &F0 E44C DB &F0 *******: get nominal buffer addresses in &FA/B ************************** ; ON ENTRY 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 E450 LDA &E43E,X ;get buffer base address lo E453 STA &FA ;store it E455 LDA &E435,X ;get buffer base address hi E458 STA &FB ;store it E45A RTS ;exit ************************************************************************* * * * OSBYTE 152 Examine Buffer status * * * ************************************************************************* ;on entry X = buffer number ;on exit FA/B points to buffer start Y is offset to next character ;if buffer is empty C=1, Y is preserved else C=0 E45B BIT &D9B7 ;set V and E45E BVS &E461 ;jump to E461 ************************************************************************* * * * OSBYTE 145 Get byte from Buffer * * * ************************************************************************* ;on entry X = buffer number ; ON EXIT Y is character extracted ;if buffer is empty C=1, else C=0 E460 CLV ;clear V E461 JMP (&022C) ;Jump via REMV ************************************************************************* * * * REMV buffer remove vector default entry point * * * ************************************************************************* ;on entry X = buffer number ;on exit if buffer is empty C=1, Y is preserved else C=0 E464 PHP ;push flags E465 SEI ;bar interrupts E466 LDA &02D8,X ;get output pointer for buffer X E469 CMP &02E1,X ;compare to input pointer E46C BEQ &E4E0 ;if equal buffer is empty so E4E0 to exit E46E TAY ;else A=Y E46F JSR &E450 ;and get buffer pointer into FA/B E472 LDA (&FA),Y ;read byte from buffer E474 BVS &E491 ;if V is set (on input) exit with CARRY clear ;Osbyte 152 has been done E476 PHA ;else must be osbyte 145 so save byte E477 INY ;increment Y E478 TYA ;A=Y E479 BNE &E47E ;if end of buffer not reached <>0 E47E E47B LDA &E447,X ;get pointer start from offset table E47E STA &02D8,X ;set buffer output pointer E481 CPX #&02 ;if buffer is input (0 or 1) E483 BCC &E48F ;then E48F E485 CMP &02E1,X ;else for output buffers compare with buffer start E488 BNE &E48F ;if not the same buffer is not empty so E48F E48A LDY #&00 ;buffer is empty so Y=0 E48C JSR &E494 ;and enter EVENT routine to signal EVENT 0 buffer ;becoming empty E48F PLA ;get back byte from buffer E490 TAY ;put it in Y E491 PLP ;get back flags E492 CLC ;clear carry to indicate success E493 RTS ;and exit ************************************************************************** ************************************************************************** ** ** ** CAUSE AN EVENT ** ** ** ************************************************************************** ************************************************************************** ;on entry Y=event number ;A and X may be significant Y=A, A=event no. when event generated @E4A1 ;on exit carry clear indicates action has been taken else carry set E494 PHP ;push flags E495 SEI ;bar interrupts E496 PHA ;push A E497 STA &FA ;&FA=A E499 LDA &02BF,Y ;get enable event flag E49C BEQ &E4DF ;if 0 event is not enabled so exit E49E TYA ;else A=Y E49F LDY &FA ;Y=A E4A1 JSR &F0A5 ;vector through &220 E4A4 PLA ;get back A E4A5 PLP ;get back flags E4A6 CLC ;clear carry for success E4A7 RTS ;and exit ********* check event 2 character entering buffer *********************** E4A8 TYA ;A=Y E4A9 LDY #&02 ;Y=2 E4AB JSR &E494 ;check event E4AE TAY ;Y=A ************************************************************************* * * * OSBYTE 138 Put byte into Buffer * * * ************************************************************************* ;on entry X is buffer number, Y is character to be written E4AF TYA ;A=Y E4B0 JMP (&022A) ;jump to INSBV ************************************************************************* * * * INSBV insert character in buffer vector default entry point * * * ************************************************************************* ;on entry X is buffer number, A is character to be written E4B3 PHP ;save flags E4B4 SEI ;bar interrupts E4B5 PHA ;save A E4B6 LDY &02E1,X ;get buffer input pointer E4B9 INY ;increment Y E4BA BNE &E4BF ;if Y=0 then buffer is full else E4BF E4BC LDY &E447,X ;get default buffer start E4BF TYA ;put it in A E4C0 CMP &02D8,X ;compare it with input pointer E4C3 BEQ &E4D4 ;if equal buffer is full so E4D4 E4C5 LDY &02E1,X ;else get buffer end in Y E4C8 STA &02E1,X ;and set it from A E4CB JSR &E450 ;and point &FA/B at it E4CE PLA ;get back byte E4CF STA (&FA),Y ;store it in buffer E4D1 PLP ;pull flags E4D2 CLC ;clear carry for success E4D3 RTS ;and exit E4D4 PLA ;get back byte E4D5 CPX #&02 ;if we are working on input buffer E4D7 BCS &E4E0 ;then E4E0 E4D9 LDY #&01 ;else Y=1 E4DB JSR &E494 ;to service input buffer full event E4DE PHA ;push A ***** return with carry set ********************************************* E4DF PLA ;restore A E4E0 PLP ;restore flags E4E1 SEC ;set carry E4E2 RTS ;and exit ***************** CODE MODIFIER ROUTINE ********************************* * CHECK FOR ALPHA CHARACTER * ************************************************************************* ;ENTRY character in A ;exit with carry set if non-Alpha character E4E3 PHA ;Save A E4E4 AND #&DF ;convert lower to upper case E4E6 CMP #&41 ;is it 'A' or greater ?? E4E8 BCC &E4EE ;if not exit routine with carry set E4EA CMP #&5B ;is it less than 'Z' E4EC BCC &E4EF ;if so exit with carry clear E4EE SEC ;else clear carry E4EF PLA ;get back original value of A E4F0 RTS ;and Return ; ; *******: INSERT byte in Keyboard buffer ********************************* E4F1 LDX #&00 ;X=0 to indicate keyboard buffer ************************************************************************* * * * OSBYTE 153 Put byte in input Buffer checking for ESCAPE * * * ************************************************************************* ;on entry X = buffer number (either 0 or 1) ;X=1 is RS423 input ;X=0 is Keyboard ;Y is character to be written E4F3 TXA ;A=buffer number E4F4 AND &0245 ;and with RS423 mode (0 treat as keyboard ;1 ignore Escapes no events no soft keys) E4F7 BNE &E4AF ;so if RS423 buffer AND RS423 in normal mode (1) E4AF E4F9 TYA ;else Y=A character to write E4FA EOR &026C ;compare with current escape ASCII code (0=match) E4FD ORA &0275 ;or with current ESCAPE status (0=ESC, 1=ASCII) E500 BNE &E4A8 ;if ASCII or no match E4A8 to enter byte in buffer E502 LDA &0258 ;else get ESCAPE/BREAK action byte E505 ROR ;Rotate to get ESCAPE bit into carry E506 TYA ;get character back in A E507 BCS &E513 ;and if escape disabled exit with carry clear E509 LDY #&06 ;else signal EVENT 6 Escape pressed E50B JSR &E494 ; E50E BCC &E513 ;if event handles ESCAPE then exit with carry clear E510 JSR &E674 ;else set ESCAPE flag E513 CLC ;clear carry E514 RTS ;and exit ******** get a byte from keyboard buffer and interpret as necessary ***** ;on entry A=cursor editing status 1=return &87-&8B, ;2= use cursor keys as soft keys 11-15 ;this area not reached if cursor editing is normal E515 ROR ;get bit 1 into carry E516 PLA ;get back A E517 BCS &E592 ;if carry is set return ;else cursor keys are 'soft' E519 TYA ;A=Y get back original key code (&80-&FF) E51A PHA ;PUSH A E51B LSR ;get high nybble into lo E51C LSR ; E51D LSR ; E51E LSR ;A=8-&F E51F EOR #&04 ;and invert bit 2 ;&8 becomes &C ;&9 becomes &D ;&A becomes &E ;&B becomes &F ;&C becomes &8 ;&D becomes &9 ;&E becomes &A ;&F becomes &B E521 TAY ;Y=A = 8-F E522 LDA &0265,Y ;read 026D to 0274 code interpretation status ;0=ignore key, 1=expand as 'soft' key ;2-&FF add this to base for ASCII code ;note that provision is made for keypad operation ;as codes &C0-&FF cannot be generated from keyboard ;but are recognised by OS ; E525 CMP #&01 ;is it 01 E527 BEQ &E594 ;if so expand as 'soft' key via E594 E529 PLA ;else get back original byte E52A BCC &E539 ;if above CMP generated Carry then code 0 must have ;been returned so E539 to ignore E52C AND #&0F ;else add ASCII to BASE key number so clear hi nybble E52E CLC ;clear carry E52F ADC &0265,Y ;add ASCII base E532 CLC ;clear carry E533 RTS ;and exit ; *********** ERROR MADE IN USING EDIT FACILITY *************************** E534 JSR &E86F ;produce bell E537 PLA ;get back A, buffer number E538 TAX ;X=buffer number ********get byte from buffer ******************************************** E539 JSR &E460 ;get byte from buffer X E53C BCS &E593 ;if buffer empty E593 to exit E53E PHA ;else Push byte E53F CPX #&01 ;and if RS423 input buffer is not the one E541 BNE &E549 ;then E549 E543 JSR &E173 ;else oswrch E546 LDX #&01 ;X=1 (RS423 input buffer) E548 SEC ;set carry E549 PLA ;get back original byte E54A BCC &E551 ;if carry clear (I.E not RS423 input) E551 E54C LDY &0245 ;else Y=RS423 mode (0 treat as keyboard ) E54F BNE &E592 ;if not 0 ignore escapes etc. goto E592 E551 TAY ;Y=A E552 BPL &E592 ;if code is less that &80 its simple so E592 E554 AND #&0F ;else clear high nybble E556 CMP #&0B ;if less than 11 then treat as special code E558 BCC &E519 ;or function key and goto E519 E55A ADC #&7B ;else add &7C (&7B +C) to convert codes B-F to 7-B E55C PHA ;Push A E55D LDA &027D ;get cursor editing status E560 BNE &E515 ;if not 0 (normal) E515 E562 LDA &027C ;else get character destination status ;Bit 0 enables RS423 driver ;BIT 1 disables VDU driver ;Bit 2 disables printer driver ;BIT 3 enables printer independent of CTRL B or CTRL C ;Bit 4 disables spooled output ;BIT 5 not used ;Bit 6 disables printer driver unless VDU 1 precedes character ;BIT 7 not used E565 ROR ;get bit 1 into carry E566 ROR ; E567 PLA ; E568 BCS &E539 ;if carry is set E539 screen disabled E56A CMP #&87 ;else is it COPY key E56C BEQ &E5A6 ;if so E5A6 E56E TAY ;else Y=A E56F TXA ;A=X E570 PHA ;Push X E571 TYA ;get back Y E572 JSR &D8CE ;execute edit action E575 PLA ;restore X E576 TAX ; E577 BIT &025F ;check econet RDCH flag E57A BPL &E581 ;if not set goto E581 E57C LDA #&06 ;else Econet function 6 E57E JMP (&0224) ;to the Econet vector ********* get byte from key string ************************************** ;on entry 0268 contains key length ;and 02C9 key string pointer to next byte E581 LDA &0268 ;get length of keystring E584 BEQ &E539 ;if 0 E539 get a character from the buffer E586 LDY &02C9 ;get soft key expansion pointer E589 LDA &0B01,Y ;get character from string E58C INC &02C9 ;increment pointer E58F DEC &0268 ;decrement length ************** exit with carry clear ************************************ E592 CLC ; E593 RTS ;exit ; *** expand soft key strings ********************************************* Y=pointer to sring number E594 PLA ;restore original code E595 AND #&0F ;blank hi nybble to get key string number E597 TAY ;Y=A E598 JSR &E3A8 ;get string length in A E59B STA &0268 ;and store it E59E LDA &0B00,Y ;get start point E5A1 STA &02C9 ;and store it E5A4 BNE &E577 ;if not 0 then get byte via E577 and exit *********** deal with COPY key ****************************************** E5A6 TXA ;A=X E5A7 PHA ;Push A E5A8 JSR &D905 ;read a character from the screen E5AB TAY ;Y=A E5AC BEQ &E534 ;if not valid A=0 so BEEP E5AE PLA ;else restore X E5AF TAX ; E5B0 TYA ;and Y E5B1 CLC ;clear carry E5B2 RTS ;and exit ************************************************************************* * * * OSBYTE LOOK UP TABLE