; TERM 2222222222222222222222222 linkct * TCTRLB linkno * TCTRLB+1 linkst * TCTRLB+2 beep * 7 empty * &FF gotoli * &96 ; ; ;************************************************** ;* linkh - link handler ;* ;* user interface for requesting linked pages ;* ;* gets link number requested and, if valid ;* (0-23), passes it to "grab link" routine ;* ;* allows editing of number on screen and ;* validatesAn each key-presso. ofAe digitstc. ;* ;* initiated by 0-9 key being struck and on entry, ;* ascii value of this first digit is in A ;* ;* onAX exit, A,Y lost ;************************************************** ; linkh ; ; ------ initialisation -------- ; Pha ; entry digit Jsr StrMes = "Link " Nop Pla ; get back entry digit Tax Jsr oswrch ; echo it LdyIM empty ; set second digit to empty ; ; ------ keyboard interpreter ---------- ; linkhr Jsr osrdch ; wait for next key press Bcc link04 CmpIM &1B ; check for ESCAPE Bne link04 Jmp link01 ; link04 CmpIM &0D ; return? Beq link05 CmpIM &7F ; delete? Beq linkhd CmpIM "0" ; valid digit? Bcc linkhi CmpIM ":" ; less than or equal to 9 ? Bcc linkhv ; linkhi LdaIM beep Jsr oswrch Jmp linkhr ; linkhv CpxIM empty Bne link06 Tax ; first digit Bpl linkhe ; always true ; link06 CpyIM empty ; two digits already? Bne linkhi ; yes CpxIM "3" ; inspect first digit to find valid values for second Bcs linkhi ; if first >= 3 then no second allowed CpxIM "2" ; if first = 2 then second must be <= 3 Bne linkha ; if first < 2 then second can be 0-9 CmpIM "4" Bcs linkhi linkha Tay ; accept second digit linkhe Jsr oswrch Jmp linkhr ; linkhd CpxIM empty ; any current digits? Beq linkhi ; no. can't delete Jsr oswrch ; yes. echo delete LdaIM empty CpyIM empty ; which one? Beq linkhs Tay Bne linkhr ; always true ; linkhs Tax Bne linkhr ; always true ; link05 CpxIM empty ; check for no digits Bne linkho Jmp link02 ; linkho LdaIM 0 Sta linkno ; prepare field for ascii to decimal conversion Sta tscr00 ; set to NULL in case unused CpyIM empty ; one lump or two? Beq link03 Txa ; get tens digit Sta Tscrat ; save ascii form for "Waiting " message Sec SbcIM "0" ; convert from ascii to decimal digit ASLA ; multiply digit by ten Sta linkno ; store 2*y temporarily ASLA ASLA Adc linkno ; carry always clear Sta linkno Tya Sta tscr00 ; save ascii form for "Waiting " message Bpl link07 ; always true ; link03 Txa Sta Tscrat link07 Sec SbcIM "0" ; strip ascii base Clc Adc linkno Sta linkno ; LdaIM gotoli ; osword switch Sta linkct LdyIM :MSB: linkct ; pointers to control block LdxIM :LSB: linkct LdaIM &7A ; osword call number Jsr osword Lda linkst ; inspect return status Bne zinkzz Jsr StrMes = "Waiting for link " Nop Lda Tscrat ; print link number requested in ascii Jsr oswrch Lda tscr00 Jmp oswrch ; print second digit (may be null) and return ; zinkzz CmpIM 1 Bne linkhn Jsr StrMes = "No such link" Nop Rts ; linkhn Jsr StrMes = "No links present" Nop Rts ; link01 LdaIM &7E Jsr osbyte ; acknowledge escape condition link02 Jsr StrMes ; clear "Link " message Nop Rts ; ; ; LNK FINAL END