home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / PROGRAMS / WSTAR / ANYCODE3.LBR / ANYCODE3.AZM / ANYCODE3.ASM
Assembly Source File  |  2000-06-30  |  5KB  |  164 lines

  1. ;    *****************************************************************
  2. ;    *                                *
  3. ;    *              *** ANYCODE3.ASM ***            *
  4. ;    *                                *
  5. ;    *          by R. F. Binder, 23 Mar 1987            *
  6. ;    *                                *
  7. ;    *     A patch to WordStar that permits insertion of        *
  8. ;    *     illegal characters into WordStar text files -        *
  9. ;    *     can be used to send ESCAPE sequences or other        *
  10. ;    *     function commands not "installed" in Wordstar        *
  11. ;    *     to a printer.                        *
  12. ;    *                                *
  13. ;    *     Based on ANYCODE.ASM, by D. M. Hurst, and up-        *
  14. ;    *     ward compatible with it.  Works as follows:        *
  15. ;    *                                *
  16. ;    *     1.  To send a single character, enter a back-        *
  17. ;    *         accent, followed by two Hex-ASCII charac-        *
  18. ;    *         ters representing the two nibbles of your        *
  19. ;    *         desired character, e.g., `0F = <SI>        *
  20. ;    *                                *
  21. ;    *     2.  To send <ESC> followed by one  character,        *
  22. ;    *         enter a tilde, followed by two characters        *
  23. ;    *         as described above, e.g., ~45 = <ESC> E        *
  24. ;    *                                *
  25. ;    *     Codes may be concatenated in longer sequences        *
  26. ;    *     if needed; e.g., ~4E`08 = Set 8-line perfora-        *
  27. ;    *     tion skip on Epson printers.                *
  28. ;    *                                *
  29. ;    *         ADDED FEATURES OVER ANYCODE.ASM            *
  30. ;    *                                *
  31. ;    *     1.  Accepts lower-case characters for codes -        *
  32. ;    *         "1b" will be read same as "1B"            *
  33. ;    *                                *
  34. ;    *     2.  Uses repeat of lead-in character to cause        *
  35. ;    *         printing of that character ("embedded de-        *
  36. ;    *         limiter" handling).                *
  37. ;    *                                *
  38. ;    *     Install using  D. M. Hurst's instructions for        *
  39. ;    *     ANYCODE.ASM.                        *
  40. ;    *                                *
  41. ;    *****************************************************************
  42.  
  43. ;23-Mar-87 Fixed bug in CPI instruction at label ASCHX:
  44.  
  45. ;    EQUATES FOR FLAG CHARACTERS
  46.  
  47. ;    If you desire other leadin characters, change these two
  48. ;    equates - no other changes required
  49.  
  50. ecode    equ    '~'    ; Leadin character for ESCAPE sequence
  51. hcode    equ    '`'    ; leadin character for hexcode sequence
  52.  
  53.  
  54. ;    MISCELLANEOUS EQUATES
  55.  
  56. chout    equ    5    ; CP/M character-output BIOS call number
  57. esc    equ    1Bh    ; ESCAPE character for printing
  58. fdos    equ    5    ; CP/M BIOS call entry point
  59.  
  60.  
  61.     org    02BBh    ; WS 2.26/3.0 (02DEh) - WS 3.3 (02BBh)
  62.  
  63. anycd:
  64.     lxi    h,seqst    ; set flags address
  65.     mov    e,a    ; put input character out of harm's way
  66.  
  67.     mov    a,m    ; fetch "sequence started" flag
  68.     ora    a    ; are we already in an ANYCODE sequence?
  69.     jnz    proc    ; yes, process character as needed
  70.  
  71.     mov    a,e    ; no, assume this is a leadin character...
  72.     sta    lead    ; ...and save it away
  73.  
  74.     lxi    b,hcode*256+ecode    ; set for leadin checks
  75.  
  76.     cmp    c    ; is this character a hexcode leadin?
  77.     jz    ldone    ; yes, set flags for start of sequence
  78.  
  79.     cmp    b    ; no, is it an <ESC> sequence leadin?
  80.     jnz    pout    ; no, not a leadin at all - print normally
  81.  
  82. ldone:
  83.     mov    m,l    ; leadin - set "sequence started" flag nonzero
  84.     inx    h    ; point at "first character" flag...
  85.     mov    m,l    ; ...and set it nonzero
  86.     ret        ; go get next character
  87.  
  88. proc:
  89.     inx    h    ; point at "first character" flag...
  90.     mov    a,m    ; ...and fetch it
  91.     ora    a    ; are we doing the first character?
  92.     jz    char2    ; no, second character - process it
  93.  
  94.     lda    lead    ; yes, first character - repeat of leadin?
  95.     sub    e
  96.     jnz    char1    ; no, it's a first character - process it
  97.  
  98.     dcx    h    ; yes, repeat - clear "sequence started" flag
  99.     mov    m,a    ; (the SUB E above left A cleared)
  100.  
  101. ;    We only need to clear the "sequence started" flag because the
  102. ;    "first character" flag is a don't care if not in a sequence -
  103. ;    it gets set automatically on sequence entry.
  104.  
  105.     jmp    pout    ; go print the repeated character
  106.  
  107. char1:
  108.     call    aschx    ; first character - extract nibble value...
  109.     rlc        ; ...and shift into upper nibble
  110.     rlc
  111.     rlc
  112.     rlc
  113.     sta    splch    ; save for addition of second nibble
  114.     xra    a    ; clear the "first character" flag
  115.     mov    m,a
  116.     ret        ; go get second character to process
  117.  
  118. aschx:
  119.     mov    a,e    ; fetch saved character to extract nibble
  120.     cpi    3Ah    ; is this character alpha or numeric?
  121.     jm    numer    ; numeric - continue conversion
  122.  
  123.     sui    7    ; alpha - fake into hex value
  124.  
  125. numer:
  126.     ani    0Fh    ; mask off upper nibble leaving binary
  127.     ret
  128.  
  129. char2:
  130.     call    aschx    ; extract second nibble value...
  131.     mov    b,a    ; ...and save it a moment
  132.     lda    splch    ; fetch first nibble...
  133.     ora    b    ; ...and combine the two nibbles
  134.     sta    splch    ; save the resulting character
  135.  
  136.     xra    a    ; clear "sequence started" flag
  137.     dcx    h
  138.     mov    m,a
  139.  
  140.     lda    lead    ; fetch leadin character
  141.     cpi    ecode    ; is this an <ESC> sequence?
  142.     jnz    doprt    ; no, it's hexcode - go print
  143.  
  144.     mvi    e,esc    ; yes, <ESC> sequence...
  145.     call    pout    ; ...print an <ESC> first
  146.  
  147. doprt:
  148.     lda    splch    ; preliminaries done, print character
  149.     mov    e,a
  150.  
  151. pout:
  152.     mvi    c,chout    ; set for character-output BIOS call
  153.     jmp    fdos    ; output character (use BIOS RET to end)
  154.  
  155.  
  156. ;     STORAGE LOCATIONS
  157.  
  158. seqst    db    0    ; "sequence started" flag space
  159. fl    db    0    ; "first character" flag space
  160. lead    db    0    ; leadin character save
  161. splch    db    0    ; special built-up character save
  162.  
  163.     end
  164.