; ISCALL.MAC - 12 Aug 85 - Local mods by K1BC ; C.FILE added 9/7/85 by w0rli. .z80 maclib TNC.LIB entry iscall,ascitb,c.file,c.alfa,c.lc,c.num cseg ; Parameters ncpcs equ 6 ;Number of characters per callsign ; Bits in ASCII character table, for various uses. c.ctl equ 01H ;Char is a control (00-1F) c.supp equ 02H ;Char should be suppressed while monitoring c.alfa equ 04H ;Char is A-Z or a-z cb.alf equ 2 ; Bit number for above value c.num equ 08H ;Char is 0-9 c.lc equ 10H ;Char is a-z c.wsp equ 20H ;Char is space or tab c.file equ 40H ;Char is legal in file name ; Routine to determine whether a string is a legitimate callsign. ; We look for the string to be one of the patterns at ISCPAT ; NOTE: ; Callsign to be tested MUST be padded with spaces to 6 chars, and ; Callsign to be tested MUST have had "-1" SSID stripped off. ; ; This algorithm will catch such common spurious calls as the following, ; which have actually been seen: ; ALL or NTS or GOD ; completely blank or missing ; ABCDEF ; TEST ; AFA1XX or NNN0XX ; ; Calling sequence: ; HL points to first character of the alleged callsign. ; call iscall ; returns CY flag clear if it looks OK ; CY flag set it is looks wrong ; ; all registers clobbered by this routine iscall: ld de, iscpat ;Point at possible patterns push hl ;Start of the alleged callsign iscl1: ;Back here for each possible pattern to check ld bc, 0 ;B counts chars up to 6 pop hl ;Get start of callsign ld a, (de) ;Any more patterns to test? or a ; .. scf ;Set failure flag for caller ret z ;Return if tried all patterns and failed. push hl ;Save start of test call for loop ld c, a ;Hold length of pattern in C inc de ;Step past length of pattern iscl2: push de ;Get bits for callsign char push hl ld d, 0 ld a, (hl) and 7FH ;Junk possible parity bit from char ld e, a ;Compute table offset ld hl, ascitb add hl, de ld a, (hl) ;Get the bits pop de pop hl and (hl) ;See if bit on in pattern and in callsign ex de, hl jp z, iscl3 ;Go if not a match inc hl ;Step source pointer inc de ;Step pattern pointer inc b ;Count up to 6 chars in source dec c ;Count thru pattern jp nz, iscl2 ;Go if more to check ; Here if all chars had right type thru length of pattern. ; This is a match if length was 6, or if shorter but source is ; followed by white space. ld a, b ;Is it 6? cp ncpcs ; .. jp z, iscl4 ;Yes, so it is a match. push hl push de ld a, (hl) ;Not 6 chars long. Get next char in source and 7FH ;Flush parity bit ld d, 0 ld e, a ld hl, ascitb add hl, de ld a, (hl) ;Bits for the following character pop de pop hl and c.wsp ;Is it white space? jp nz, iscl4 ;Yes, so it is a match ;Pattern was not a match. Go see if any more patterns to try. jp iscl1 ;Try another pattern ;Here if pattern failed to match before we counted thru it all the way. ;Have to step past the rest of it to find next one. iscl3: inc de ;Step pattern pointer dec c ;Count thru pattern jp nz, iscl3 ;Go if more to check jp iscl1 ;Now go check possible further patterns ; Here if pattern was a match. Straighten out the stack and return success. iscl4: pop hl ;Restore start of source callsign or a ;Clear carry flag, means was good. ret ; Back to caller ; Here are the legal patterns of callsigns. Format is: Length byte, then ; that many bytes of pattern. Then another length byte, zero to end. ; The pattern is c.alfa for a letter and c.num for a digit. iscpat: db 3,c.alfa,c.num,c.alfa ;N6V db 4,c.alfa,c.num,c.alfa,c.alfa ;K1BC db 4,c.alfa,c.alfa,c.num,c.alfa ;KD2S db 4,c.num,c.alfa,c.num,c.alfa ;4U1U db 5,c.alfa,c.num,c.alfa,c.alfa,c.alfa ;W0RLI db 5,c.alfa,c.alfa,c.num,c.alfa,c.alfa ;KD6SQ db 5,c.num,c.alfa,c.num,c.alfa,c.alfa ;4U1UN db 5,c.alfa,c.num,c.num,c.alfa,c.alfa ;W84OG db 5,c.alfa,c.alfa,c.num,c.num,c.alfa ;WX84X db 6,c.alfa,c.alfa,c.num,c.alfa,c.alfa,c.alfa ;WB1EMT db 6,c.num,c.alfa,c.num,c.alfa,c.alfa,c.alfa ;4U1ITU db 6,c.alfa,c.num,c.num,c.alfa,c.alfa,c.alfa ;W84OGX db 6,c.alfa,c.alfa,c.num,c.num,c.alfa,c.alfa ;WX84OG db 0 ;End of list ;Table of descriptors for the 128 ASCII characters. Should be page-aligned ; for easier reference, but... ;Bytes are indexed by the ASCII character number. ;This block of 128 bytes looks like a waste of space, but it is made ; up by being used in a bunch of comparison tests. ascitb: db c.ctl+c.supp ;^@ db c.ctl+c.supp ;^A db c.ctl+c.supp ;^B db c.ctl+c.supp ;^C db c.ctl+c.supp ;^D db c.ctl+c.supp ;^E db c.ctl+c.supp ;^F db c.ctl+c.supp ;^G - Bell db c.ctl ;^H - Backspace db c.ctl+c.wsp ;^I - Tab db c.ctl ;^J - Linefeed db c.ctl+c.supp ;^K - Vert tab db c.ctl+c.supp ;^L - Formfeed db c.ctl ;^M - Carriage Return db c.ctl+c.supp ;^N db c.ctl+c.supp ;^O db c.ctl+c.supp ;^P db c.ctl ;^Q - XON db c.ctl+c.supp ;^R db c.ctl ;^S - XOFF db c.ctl+c.supp ;^T db c.ctl+c.supp ;^U db c.ctl+c.supp ;^V db c.ctl+c.supp ;^W db c.ctl+c.supp ;^X db c.ctl+c.supp ;^Y db c.ctl+c.supp ;^Z db c.ctl+c.supp ;^[ - ESC db c.ctl+c.supp ;^\ db c.ctl+c.supp ;^] db c.ctl+c.supp ;^^ db c.ctl+c.supp ;^_ db c.wsp+c.file ; space 040 02H db c.file ; ! db c.file ; " db c.file ; # db c.file ; $ db c.file ; % db c.file ; & db c.file ; ' db c.file ;( 050 28H db c.file ;) db 0 ;* db c.file ;+ db 0 ;, db c.file ;- db 0 ;. db c.file ;/ ;0-9 060-071 30H-39H rept 10 db c.num+c.file endm db 0 ;: 072 3AH db 0 ;; db 0 ;< db 0 ;= db 0 ;> db 0 ;? db c.file ;@ 100 40H ;A-Z 101-132 41H-5AH rept 26 db c.alfa+c.file endm db 0 ;[ 133 5BH db c.file ;\ db 0 ;] db c.file ;^ db c.file ;_ db c.file ;` 140 60H ;a-z 141-172 61H-7AH rept 26 db c.alfa+c.lc endm db c.file ;{ db c.file ;| db c.file ;} db c.file ;~ db c.supp ;DELETE end