; ***************************************************************** ; * * ; * *** ANYCODE3.ASM *** * ; * * ; * by R. F. Binder, 23 Mar 1987 * ; * * ; * A patch to WordStar that permits insertion of * ; * illegal characters into WordStar text files - * ; * can be used to send ESCAPE sequences or other * ; * function commands not "installed" in Wordstar * ; * to a printer. * ; * * ; * Based on ANYCODE.ASM, by D. M. Hurst, and up- * ; * ward compatible with it. Works as follows: * ; * * ; * 1. To send a single character, enter a back- * ; * accent, followed by two Hex-ASCII charac- * ; * ters representing the two nibbles of your * ; * desired character, e.g., `0F = * ; * * ; * 2. To send followed by one character, * ; * enter a tilde, followed by two characters * ; * as described above, e.g., ~45 = E * ; * * ; * Codes may be concatenated in longer sequences * ; * if needed; e.g., ~4E`08 = Set 8-line perfora- * ; * tion skip on Epson printers. * ; * * ; * ADDED FEATURES OVER ANYCODE.ASM * ; * * ; * 1. Accepts lower-case characters for codes - * ; * "1b" will be read same as "1B" * ; * * ; * 2. Uses repeat of lead-in character to cause * ; * printing of that character ("embedded de- * ; * limiter" handling). * ; * * ; * Install using D. M. Hurst's instructions for * ; * ANYCODE.ASM. * ; * * ; ***************************************************************** ;23-Mar-87 Fixed bug in CPI instruction at label ASCHX: ; EQUATES FOR FLAG CHARACTERS ; If you desire other leadin characters, change these two ; equates - no other changes required ecode equ '~' ; Leadin character for ESCAPE sequence hcode equ '`' ; leadin character for hexcode sequence ; MISCELLANEOUS EQUATES chout equ 5 ; CP/M character-output BIOS call number esc equ 1Bh ; ESCAPE character for printing fdos equ 5 ; CP/M BIOS call entry point org 02BBh ; WS 2.26/3.0 (02DEh) - WS 3.3 (02BBh) anycd: lxi h,seqst ; set flags address mov e,a ; put input character out of harm's way mov a,m ; fetch "sequence started" flag ora a ; are we already in an ANYCODE sequence? jnz proc ; yes, process character as needed mov a,e ; no, assume this is a leadin character... sta lead ; ...and save it away lxi b,hcode*256+ecode ; set for leadin checks cmp c ; is this character a hexcode leadin? jz ldone ; yes, set flags for start of sequence cmp b ; no, is it an sequence leadin? jnz pout ; no, not a leadin at all - print normally ldone: mov m,l ; leadin - set "sequence started" flag nonzero inx h ; point at "first character" flag... mov m,l ; ...and set it nonzero ret ; go get next character proc: inx h ; point at "first character" flag... mov a,m ; ...and fetch it ora a ; are we doing the first character? jz char2 ; no, second character - process it lda lead ; yes, first character - repeat of leadin? sub e jnz char1 ; no, it's a first character - process it dcx h ; yes, repeat - clear "sequence started" flag mov m,a ; (the SUB E above left A cleared) ; We only need to clear the "sequence started" flag because the ; "first character" flag is a don't care if not in a sequence - ; it gets set automatically on sequence entry. jmp pout ; go print the repeated character char1: call aschx ; first character - extract nibble value... rlc ; ...and shift into upper nibble rlc rlc rlc sta splch ; save for addition of second nibble xra a ; clear the "first character" flag mov m,a ret ; go get second character to process aschx: mov a,e ; fetch saved character to extract nibble cpi 3Ah ; is this character alpha or numeric? jm numer ; numeric - continue conversion sui 7 ; alpha - fake into hex value numer: ani 0Fh ; mask off upper nibble leaving binary ret char2: call aschx ; extract second nibble value... mov b,a ; ...and save it a moment lda splch ; fetch first nibble... ora b ; ...and combine the two nibbles sta splch ; save the resulting character xra a ; clear "sequence started" flag dcx h mov m,a lda lead ; fetch leadin character cpi ecode ; is this an sequence? jnz doprt ; no, it's hexcode - go print mvi e,esc ; yes, sequence... call pout ; ...print an first doprt: lda splch ; preliminaries done, print character mov e,a pout: mvi c,chout ; set for character-output BIOS call jmp fdos ; output character (use BIOS RET to end) ; STORAGE LOCATIONS seqst db 0 ; "sequence started" flag space fl db 0 ; "first character" flag space lead db 0 ; leadin character save splch db 0 ; special built-up character save end