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

  1. ; SETNX.ASM sends control codes to the Star NX10 and similar printers. 
  2. ;
  3. ; Use: SETNX <cr>            a menu will appear 
  4.  
  5. ;  or  SETNX 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 SETNX is used this way.
  9.  
  10. ; Configuring SETNX 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 'v'     ;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
  53.      db 9,9,'A Pica (10)               L Cancel Letter Quality',13,10,10
  54.      db 9,9,'B Elite (12)              M Immediate Mode',13,10,10
  55.      db 9,9,'C Condensed               N Cancel Immediate Mode',13,10,10 
  56.      db 9,9,'D Unidirectional Print    O Skip Over Perf 4 Lines',13,10,10
  57.      db 9,9,'E Expanded                P Print Test Line',13,10,10
  58.      db 9,9,'F Cancel Expanded         Q Quit',13,10,10
  59.      db 9,9,'G Emphasized              R Reset Printer',13,10,10
  60.      db 9,9,'H Cancel Emphasized       S Set Left Margin at 5',13,10,10
  61.      db 9,9,'I Double Strike           T L Mar 8 Rt Mar 72',13,10,10
  62.      db 9,9,'J Cancel Double Strike    U 6 Lines Per Inch',13,10,10
  63.      db 9,9,'K Letter Quality          V 8 Lines Per Inch',13,10,10,'$'
  64.  
  65. crt  db 'Copyright 1988 Joseph C. Hudson 4198 Warbler Dr. Flint Mi 48532'
  66.  
  67. ; Here are the printer control strings. The strings are followed by a jump
  68. ; table that is used to access the strings.
  69.  
  70.      a1 db 27,80
  71.      b1 db 27,77
  72.      c1 db 27,15
  73.      d1 db 27,85,1
  74.      e1 db 27,87,1
  75.      f1 db 27,87,0
  76.      g1 db 27,69
  77.      h1 db 27,70
  78.      i1 db 27,71
  79.      j1 db 27,72
  80.      k1 db 27,120,1
  81.      l1 db 27,120,0
  82.      m1 db 27,105,1
  83.      n1 db 27,105,0
  84.      o1 db 27,78,2,27,114,2
  85.      p1 db 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLNO',13,10
  86.      q1 db ' '
  87.      r1 db 27,64
  88.      s1 db 27,108,5
  89.      t1 db 27,88,8,64
  90.      u1 db 27,65,12,27,50
  91.      v1 db 27,65,9,27,50
  92.      w1 db ' '
  93.  
  94. jtbl    dw offset a1
  95.         dw offset b1
  96.         dw offset c1
  97.         dw offset d1
  98.         dw offset e1
  99.         dw offset f1
  100.         dw offset g1
  101.         dw offset h1
  102.         dw offset i1
  103.         dw offset j1
  104.         dw offset k1
  105.         dw offset l1
  106.         dw offset m1
  107.         dw offset n1
  108.         dw offset o1
  109.         dw offset p1
  110.         dw offset q1
  111.         dw offset r1
  112.         dw offset s1
  113.         dw offset t1
  114.         dw offset u1
  115.         dw offset v1
  116.         dw offset w1
  117.  
  118. start:  mov    si,80h                ;point to command tail
  119.         mov    al,[si]               ;get length of command tail
  120.         cmp    al,0                  ;is there a tail?
  121.         jne    tail                  ;yes
  122.         mov    numleft,7fh           ;no, put 127 in numleft to flag no tail
  123.         jmp    short dmenu           ;display menu
  124. tail:   mov    numleft,al            ;put length of tail in numleft
  125.         jmp    getcht                ;get character from tail
  126. dmenu:  mov    dx,offset menu        ;point to menu  
  127.         mov    ah,9                  ;write to console function
  128.         int    21h                   ;call DOS
  129.         jmp    getchk                ;get character from keyboard
  130.         
  131. nextch: cmp    numleft,7fh           ;is there a tail?
  132.         jne    getcht                ;yes, get character from tail
  133.         jmp    getchk                ;no, get character from keyboard
  134.  
  135. getcht: cmp    numleft,0             ;is there any tail left?
  136.         je     quit                  ;no, quit
  137.         inc    si                    ;point at next character in tail
  138.         dec    numleft               ;decrement counter
  139.         mov    al,[si]               ;get next character from tail
  140.         jmp    pchar                 ;process character
  141.  
  142. getchk: mov    ah,0Ch                ;flush keyboard buffer 
  143.         mov    al,07h                ;and get character from keyboard
  144.         int    21h
  145.         mov    dl,al
  146.         mov    ah,02h                ;write character to screen
  147.         int    21h
  148.  
  149. pchar:  or     al,20h                ;change to lower case
  150.         cmp    al,'a'                ;is it below a?
  151.         jge    l2                    ;no, keep going
  152.         jmp    nextch                ;yes, so not a command
  153. l2:     cmp    al,lastcmd            ;is it above last command letter?
  154.         jle    chkq                  ;no, so is a command
  155.         jmp    nextch                ;yes, so not a command
  156.  
  157. chkq:   cmp    al,'q'                ;want to quit?
  158.         jne    prstr                 ;no, send code to printer
  159.  
  160. quit:   mov    ah,4Ch                ;yes, quit
  161.         int    21h
  162.  
  163. prstr:  sub    al,'a'                ;how many words into jtbl we should go
  164.         mov    ah,0                  ;just to be safe
  165.         shl    ax,1                  ;convert # of words to # of bytes
  166.         mov    bx,ax                 ;save offset into jtabl in bx
  167.         mov    ax,jtbl[bx]           ;offset of command to ax             
  168.         mov    cx,jtbl[bx+2]         ;offset of next command to cx
  169.         sub    cx,ax                 ;length of command string is now in cx
  170.         mov    bx,ax                 ;offset of command to bx
  171.  
  172. newchr: mov    dl,[bx]               ;character to dl
  173.         mov    ah,5                  ;printer output function
  174.         int    21h                   ;call DOS
  175.         inc    bx                    ;point to next character
  176.         loop   newchr                ;loop until done
  177.         jmp    nextch                ;get next character
  178.  
  179. code    ends
  180. end     begin
  181.