home *** CD-ROM | disk | FTP | other *** search
/ Share Gallery 1 / share_gal_1.zip / share_gal_1 / UT / UT043.ZIP / SETE / SETE.ASM next >
Assembly Source File  |  1988-11-29  |  7KB  |  171 lines

  1. ; SETE.ASM sends control codes to the Epson FX and similar printers. 
  2. ;
  3. ; Use: SETE <cr>            a menu will appear 
  4.  
  5. ;  or  SETE commands <cr>   where commands are single letters, the last
  6. ;                           which should be q (quit). See the menu for
  7. ;                           a list of legal commands. The menu does not
  8. ;                           appear when SETE is used this way.
  9.  
  10. ; Configuring SETE to your printer or changing the menu selections is 
  11. ; easy. Here are a few guidelines:
  12.  
  13. ;    there are three areas of the program that may need modification if
  14. ;    you want to make changes. These are the menu, the printer control
  15. ;    strings, and the jump table (jtbl).
  16.  
  17. ;    all letters starting with 'a' up to one beyond the last letter used
  18. ;    in a command should be present in the printer control section and
  19. ;    the jump table. If a letter in this range is not used in the menu, 
  20. ;    put ' ' for it in the printer control table. 
  21.  
  22. ;    lastcmd shold be set to the last command letter actually used.
  23.  
  24. ;    you should not have to alter the code beyond jtbl unless you want
  25. ;    to change the 'quit' command. Notice that the quit command does
  26. ;    not actually send any code to the printer, so ' ' appears in the
  27. ;    printer control table for this command.
  28.  
  29. ;    this program assembles properly under tasm and probably other
  30. ;    assemblers.
  31.  
  32. ; this program is copyrighted. The intent of the copyright is to prevent
  33. ; commercial exploitation without the author's consent. Free academic, 
  34. ; shareware and noncommercial use may be made of the source code and 
  35. ; compiled programs. Attribution is appreciated. The author has received
  36. ; no compensation for this program and no warranty of any kind is given.
  37. ; Enjoy.
  38.  
  39. code    segment
  40.         assume cs: code
  41.         org    100h        ;setup as COM file
  42.  
  43. begin:  jmp  start         ;skip over data area
  44.  
  45.         numleft db  ?      ;# of chars from cmd tail not yet processed
  46.         lastcmd db 'r'     ;last command letter used
  47.  
  48. ; the screen menu is defined here. edit this and/or change the printer codes
  49. ; below jtbl as you wish. If you change the number of menu entries, be sure to
  50. ; change jtbl and the code in pchar accordingly.
  51.  
  52. menu db 13,10,10,10,10,10
  53.      db 9,9,'A Pica (10)               J Cancel Italics',13,10,10
  54.      db 9,9,'B Elite (12)              K Skip over perf 2 lines',13,10,10
  55.      db 9,9,'C Condensed               L Set left margin at 10',13,10,10 
  56.      db 9,9,'D Unidirectional Print    M Expanded print',13,10,10
  57.      db 9,9,'E Emphasized              N Cancel expanded',13,10,10
  58.      db 9,9,'F Cancel Emphasized       P Print test line',13,10,10
  59.      db 9,9,'G Double strike           Q Quit',13,10,10
  60.      db 9,9,'H Cancel double strike    R Reset printer',13,10,10
  61.      db 9,9,'I Italics',13,10,10,'$'
  62.  
  63. crt  db 'Copyright 1988 Joseph C. Hudson 4198 Warbler Dr. Flint Mi 48532'
  64.  
  65. ; Here are the printer control strings. The strings are followed by a jump
  66. ; table that is used to access the strings.
  67.  
  68.      a1 db 27,80,18
  69.      b1 db 27,77
  70.      c1 db 15
  71.      d1 db 27,85,1
  72.      e1 db 27,69
  73.      f1 db 27,70
  74.      g1 db 27,71
  75.      h1 db 27,72
  76.      i1 db 27,52
  77.      j1 db 27,53
  78.      k1 db 27,78,2
  79.      l1 db 27,108,10
  80.      m1 db 27,87,1
  81.      n1 db 27,87,0
  82.      o1 db ' '
  83.      p1 db 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLNO',13,10
  84.      q1 db ' '
  85.      r1 db 27,64
  86.      s1 db ' '
  87.  
  88. jtbl    dw offset a1
  89.         dw offset b1
  90.         dw offset c1
  91.         dw offset d1
  92.         dw offset e1
  93.         dw offset f1
  94.         dw offset g1
  95.         dw offset h1
  96.         dw offset i1
  97.         dw offset j1
  98.         dw offset k1
  99.         dw offset l1
  100.         dw offset m1
  101.         dw offset n1
  102.         dw offset o1
  103.         dw offset p1
  104.         dw offset q1
  105.         dw offset r1
  106.         dw offset s1
  107.  
  108. start:  mov    si,80h                ;point to command tail
  109.         mov    al,[si]               ;get length of command tail
  110.         cmp    al,0                  ;is there a tail?
  111.         jne    tail                  ;yes
  112.         mov    numleft,7fh           ;no, put 127 in numleft to flag no tail
  113.         jmp    short dmenu           ;display menu
  114. tail:   mov    numleft,al            ;put length of tail in numleft
  115.         jmp    getcht                ;get character from tail
  116. dmenu:  mov    dx,offset menu        ;point to menu  
  117.         mov    ah,9                  ;write to console function
  118.         int    21h                   ;call DOS
  119.         jmp    getchk                ;get character from keyboard
  120.         
  121. nextch: cmp    numleft,7fh           ;is there a tail?
  122.         jne    getcht                ;yes, get character from tail
  123.         jmp    getchk                ;no, get character from keyboard
  124.  
  125. getcht: cmp    numleft,0             ;is there any tail left?
  126.         je     quit                  ;no, quit
  127.         inc    si                    ;point at next character in tail
  128.         dec    numleft               ;decrement counter
  129.         mov    al,[si]               ;get next character from tail
  130.         jmp    pchar                 ;process character
  131.  
  132. getchk: mov    ah,0Ch                ;flush keyboard buffer 
  133.         mov    al,07h                ;and get character from keyboard
  134.         int    21h
  135.         mov    dl,al
  136.         mov    ah,02h                ;write character to screen
  137.         int    21h
  138.  
  139. pchar:  or     al,20h                ;change to lower case
  140.         cmp    al,'a'                ;is it below a?
  141.         jge    l2                    ;no, keep going
  142.         jmp    nextch                ;yes, so not a command
  143. l2:     cmp    al,lastcmd            ;is it above last command letter?
  144.         jle    chkq                  ;no, so is a command
  145.         jmp    nextch                ;yes, so not a command
  146.  
  147. chkq:   cmp    al,'q'                ;want to quit?
  148.         jne    prstr                 ;no, send code to printer
  149.  
  150. quit:   mov    ah,4Ch                ;yes, quit
  151.         int    21h
  152.  
  153. prstr:  sub    al,'a'                ;how many words into jtbl we should go
  154.         mov    ah,0                  ;just to be safe
  155.         shl    ax,1                  ;convert # of words to # of bytes
  156.         mov    bx,ax                 ;save offset into jtabl in bx
  157.         mov    ax,jtbl[bx]           ;offset of command to ax             
  158.         mov    cx,jtbl[bx+2]         ;offset of next command to cx
  159.         sub    cx,ax                 ;length of command string is now in cx
  160.         mov    bx,ax                 ;offset of command to bx
  161.  
  162. newchr: mov    dl,[bx]               ;character to dl
  163.         mov    ah,5                  ;printer output function
  164.         int    21h                   ;call DOS
  165.         inc    bx                    ;point to next character
  166.         loop   newchr                ;loop until done
  167.         jmp    nextch                ;get next character
  168.  
  169. code    ends
  170. end     begin
  171.