home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / canada-remote-systems / geos / drivers / nx1000sr.sfx / snx1000c.src (.txt) < prev   
GEOS ConVerT  |  1990-02-12  |  27KB  |  705 lines

  1. SNX1000C.src
  2. PRG formatted GEOS file V1.0
  3. StarNX-1000C
  4. OP V2.0 or higher
  5. FOR USE WITH
  6. BLASTER'S CONVERTER V2.5
  7. C64 ALL VERSIONS
  8. T/D VH7-1.0
  9. Write Image V2.1
  10. geoWrite    V2.1
  11. .This is the source code for ReColor.  It can be viewed be geoWrite.
  12. ; *** StarNX-1000C Main Program:  This is a printer driver for the Star NX-1000C printer.
  13. .if    Pass1        ; Only need to include these files
  14.             ;    during assembler's first pass.
  15. .include    geosSym        ; Get GEOS definitions.
  16. .include    geosMac        ; Get     GEOS macro definitions.
  17. .endif
  18. CardsWide ==    $50    ; 80 Commdore cards wide.
  19. CardsDeep    ==    $5e    ; 94 Commdore cards deep.
  20. SecAddr    ==    $05    ; Set secondary address to lowercase.
  21. PrintAddr    ==    $04    ; Set printer number to 4.
  22. SecAdMsk    ==    $60
  23. FF    ==    $0c    ; Form feed CHR$(12)
  24. Ciout    ==    $ffa8
  25. Listen    ==    $ffb1
  26. Unlsn    ==    $ffae
  27. Second    ==    $ff93
  28.     .psect        ; Program code starts here (GeoLinker will
  29.             ;    set the start address: $7900)
  30. ; *** This will be the start of the program main code.
  31.      @PRGStart
  32. :            ; This label will set the start address.
  33.             ; This is the printer driver jump table.
  34.      @P_InitForPrint
  35.     jmp    r_InitForPrint        ; This driver uses this routine to allow the
  36.             ;   user to set: Pitch, Spacing, NLQ Font, etc.
  37.      @P_StartPrint
  38. :            ; Performs initialization necessary before
  39.     jmp    r_StartPrint    ;   printing each page of a document.
  40.      @P_PrintBuffer
  41. :            ; Prints out the indicated 640 byte buffer of
  42.     jmp    r_PrintBuffer    ;   graphic data as created by a application.
  43.      @P_StopPrint
  44. :            ; Called at end of every page to flush output
  45.     jmp    r_StopPrint        ;   buffer and tell the printer to form feed.
  46.      @P_GetDimensions
  47. :        ; Returns the dimensions in cards of the
  48.     jmp    r_GetDimensions    ;   rectangle that will print in an 8x10 area
  49.             ;   of the screen.
  50.      @P_PrintASCII
  51. :            ; Prints a null terminated ASCII string to the
  52.     jmp    r_PrintASCII        ;   printer.
  53.      @P_StartASCII
  54.     jmp    r_StartASCII        ; Initilizes the printer to receive ASCII print
  55.             ;   streams.
  56.      @P_SetNLQ
  57. :            ; Initilizes the printer to NEAR LETTER QUALITY
  58.     jmp    r_SetNLQ        ;   mode.
  59. ; *** RAM stroage buffers and flags.
  60.      @PrinterName
  61.     .byte    "StarNX-1000C",0    ; Name of printer.
  62. ; *** RAM stroage buffers and flags.
  63.      @PrinterName
  64.     .byte    "StarNX-1000C",0    ; Name of printer.
  65.      @PrntBlCard
  66.     .byte    0,0,0,0,0,0,0,0    ; Printable character block.
  67.      @BreakCount
  68.     .byte    0
  69.      @CardWidth
  70.     .byte    0    ; Width of the print buffer line in cards.
  71.      @Scount
  72.     .byte    0    ; String output routine counter.
  73.      @CardCount
  74.     .byte    0
  75.      @ModeFlag
  76.     .byte    0    ; Either $00=GRAPHICS, or $FF=ASCII for draft
  77.             ;   or NLQ mode.
  78. .if (0)
  79. ---------------------------------------------------------------------------------------------------------      
  80. @r_InitForPrint
  81. ---------------------------------------------------------------------------------------------------------
  82.      @   
  83.  Function
  84. :    Performes printer dependent initilization once per document.
  85.      @ Called By:    
  86.      @GEOS 
  87. Application.
  88.  Pass:
  89.         Nothing.
  90.      @        
  91.  Returned:
  92.     Nothing.
  93.  Destroyed:
  94.     Nothing.
  95.  Synopsis:
  96.     InitForPrint is the first of the routines to be called.  It sends the printer and
  97.         special commands it needs to print GEOS documents.  In some printer drivers
  98.         this routine does nothing.
  99. ---------------------------------------------------------------------------------------------------------.endif
  100.      @r_InitForPrint
  101.     rts        ; Just exit.  Nothing to do...
  102. .if (0)
  103. ---------------------------------------------------------------------------------------
  104. .if (0)
  105. ---------------------------------------------------------------------------------------------------------      
  106. @r_StartPrint
  107. ---------------------------------------------------------------------------------------------------------
  108.      @   
  109.  Function
  110. :    Perform initialization necessary before printing each page of a document.
  111.      @ Called By:    
  112.      @GEOS
  113.  Application.
  114.  Pass:
  115.         Nothing.
  116.      @        
  117.  Returned:
  118.     Nothing.
  119.  Destroyed:
  120.     a, x, y, r3
  121.  Synopsis:
  122.     This is the StartPrint routine as discussed above.  It initilized the serial bus to
  123.         the printer, sets up the printer to receive graphic data.
  124.      @        
  125. ---------------------------------------------------------------------------------------------------------.endif
  126.      @r_StartPrint
  127.     LoadB    ModeFlag,#$00    ; Set graphics mode.
  128.      @StartIn
  129.     lda    #PrintAddr    ; Set to channel 4.
  130.     jsr    SetDevice
  131.     jsr    InitForIO    ; Set I/O space in, interrupt disable.
  132.     LoadB    STATUS,#$00    ; Set error byte to zero. (no error)
  133.     jsr    OpenFile    ; Open a file to the printer.
  134.     lda    STATUS    ; Check to see if there was an error.
  135.     bne    10$    ; Yes there was an error.
  136.     jsr    OpenPrint    ; Open a channel to the printer.
  137.     jsr    InitPrinter    ; Initialize the printer for graphics mode.
  138.     jsr    ClosePrint    ; Close the print channel.
  139.     jsr    Delay    ; Wait for weird timing problems.
  140.     jsr    DoneWithIO    ; Set memory map back, enable interrupts.
  141.     ldx    #$00    ; Set error to zero. (no error)
  142.     rts        ; Return from routine.
  143.      @10
  144. $:    pha        ; Save error returned from routines.
  145.             ;   bit 0 set: timeout, write.
  146.             ;   bit 7 set: device not present.
  147.     jsr    CloseFile    ; Close the file anyway.
  148.     jsr    DoneWithIO    ; Set memory map back, enable interrupts.
  149.     pla            ; Recover the error returned.
  150.     tax        ; Pass out to .X.
  151.     rts        ; Return from routine.
  152.      @Delay
  153. :            ; Wait for weird timing problems.
  154.     ldx    #$00
  155.      @20
  156. $:    ldy    #$00
  157.      @30
  158. $:    dey
  159.     bne    30$
  160.     bne    20$
  161.     rts        ; Return from delay.
  162. .if (0)
  163. ------------------
  164. .if (0)
  165. ---------------------------------------------------------------------------------------------------------  
  166.      
  167. @InitPrinter  (subroutine)
  168. ---------------------------------------------------------------------------------------------------------
  169.      @Function
  170. :    Initilizes the Star NX-1000C to line-feed 8/72"    
  171.      @ Called By:    
  172. r_StartPrint
  173.  Pass:
  174.         Nothing.
  175.      @        
  176.  Returned:
  177.     r3 - #LFSetTbl
  178.         Scount - #$ff
  179.         y - #$00
  180.  Destroyed:
  181.  Synopsis:
  182.     Output to the printer a string of characters whick initializes it.  See the 
  183.         printer's owners manual.    
  184.      @        
  185. ---------------------------------------------------------------------------------------------------------.endif
  186.      @InitPrinter
  187.     bit    ModeFlag    ; See if printing ASCII or Graphic mode.
  188.     bmi    10$    ; Branch if ASCII.
  189.     LoadW    r3,#LFSetTbl    ; Table of bytes for initilization.
  190.     lda    #[(LFSetEnd-LFSetTbl)    ; Length of string.
  191.     jmp    SendString    ; Output the string.
  192.      @10
  193. $:    LoadW    r3,#ASCIITbl    ; Table of bytes for ASCII initilization.
  194.     lda    #[(ASCIIEnd-ASCIITbl)    ; Length of string.
  195.     jmp    SendString    ; Output the string.
  196.      @LFSetTbl
  197.     .byte    27,64    ; Reset printer.
  198.     .byte    27,65,8    ; Set 8/72" linefeed.
  199.      @LFSetEnd
  200.      @ASCIITbl
  201.     .byte    27,64    ; Reset printer.
  202.     .byte    27,93,49    ; Set ASCII operating mode.
  203.     .byte    27,50    ; Set linespacing to 1/6 inch.
  204.     .byte    27,82,1    ; Set USA character set.
  205.     .byte    27,126,49    ; Set slash zero.
  206.      @ASCIIEnd
  207. .if (0)
  208. ---------------------------------------------------------------------------------------------------------      
  209. @r_PrintBuffer
  210. ---------------------------------------------------------------------------------------------------------
  211.      @ Function
  212. :    Print out the indicated 640 byte buffer of graphic data (80 cards) as created
  213.         by an application.
  214.      @ Called By:    
  215.      @GEOS
  216.  Application.
  217.  Pass:
  218.         r0 - address of the 640 bytes to be printed.
  219.         r1 - address of an additional 640 byte buffer for PrintBuffer to use.
  220.         NOTE: This buffer may not change between calls to PrintBuffer.  7 bit printers
  221.             use it to store the left over scanlines between calls.  Each time PrintBuffer
  222.             is called it is passed 8 scanlines of data but only 7 may be printed.
  223.      @        
  224.  Returned:
  225.     r0, r2 - unchanged.
  226.  Destroyed:
  227.     a, x, y, r3
  228.  Synopsis:
  229.     PrintBuffer, as described in more detail above, is the top level routine that
  230.         dumps data from the GEOS 640 byte buffer maintained in the Commdore 64 to
  231.         the printer using the serial port.
  232.      @        
  233. ---------------------------------------------------------------------------------------------------------.endif
  234.      @r_PrintBuffer
  235.     lda    #PrintAddr    ; Set to channel 4.
  236.     jsr    SetDevice    ; Set GEOS device number.
  237.     jsr    InitForIO    ; Put I/O space in, disable interrupts.
  238.     jsr    OpenPrint    ; Open channel to printer.
  239.     MoveW    r0,r3    ; Set r3 to r0.
  240.     jsr    PrintPrintBuffer    ; Print the users 8 bit high buffer.
  241.     jsr    Greturn    ; Do a CR only.
  242.     jsr    ClosePrint    ; Close the print channel.
  243.     jsr    DoneWithIO    ; Put back memory map, enable interrupts.
  244.     rts        ; All done exit routine.
  245. .if (0)
  246. -----------------------------------------------------------
  247. .if (0)
  248. ---------------------------------------------------------------------------------------------------------
  249. @Greturn & FormFeed  (subroutine)
  250. ---------------------------------------------------------------------------------------------------------
  251.  Function
  252. :    Prints out a carriage return.  Exit graphics mode and print the form feed     
  253.         character.    
  254.      @ Called By:    
  255. PrintBuffer
  256.  Pass:
  257.         Nothing.
  258.      @        
  259.  Returned:
  260.     Nothing.
  261.  Destroyed:
  262.     a, variabled destroyed by Ciout.
  263.  Synopsis:
  264.     Outputs the CR or Form feed    
  265.      @        
  266. ---------------------------------------------------------------------------------------------------------.endif
  267.      @Greturn
  268.     lda    #CR    ; Carriage return.
  269.     jsr    Ciout    ; Sent it.
  270.     rts        ; Exit.
  271.      @FormFeed
  272.     lda    #FF    ; FormFeed.
  273.     jsr    Ciout    ; Sent it.
  274.     rts        ; Exit.
  275. .if (0)
  276. ----------------------------------------------------------------------------------------------
  277. .if (0)
  278. ---------------------------------------------------------------------------------------------------------
  279. @PrintPrintBuffer  (subroutine)
  280. ---------------------------------------------------------------------------------------------------------
  281.  Function
  282. :    Prints out the print buffer pointed to by r3.
  283.      @ Called By:    
  284. PrintBuffer
  285.  Pass:
  286.          r3 - address of start of buffer to print.
  287.      @        
  288.  Returned:
  289.     r3 - unchanged.
  290.  Destroyed:
  291.     a, x, y, r0 - r15
  292.  Synopsis:
  293.     Checks to see if the buffer is empty before printing the data.  Then for each
  294.         card in the buffer, rotate the data and send it to the printer.    
  295.      @        
  296. ---------------------------------------------------------------------------------------------------------.endif
  297.      @PrintPrintBuffer
  298.     PushW    r3    ; Save the buffer pointer.
  299.     jsr    TestBuffer    ; See if the buffer is all zeros.
  300.     bcs    10$    ; If thereis data in the buffer, send it.
  301.     PopW    r3    ; Dummy pop.
  302.     rts        ; Return from subroutine.
  303.      @10
  304. $:    jsr    SetGraphics    ; Set graphics mode for this line.
  305.     PopW    r3    ; Restore the buffer pointer.
  306.     lda    #CardsWide    ; Load the card count (up to 80).
  307.     sbc    CardCount
  308.      @20
  309. $:    txa        ; Save .X.
  310.     jsr    Rotate    ; Rotate the card...
  311.     jsr    SendBuff    ; Send the rotated card.
  312.     AddVW    #$08,r3    ; Update pointer to buffer.
  313.     pla        ; Recover .X.
  314.     dex        ; Done?
  315.     bne    20$    ; If not, do another card.
  316.     rts        ; Return to subroutine.
  317. .if (0)
  318. -----------
  319. .if (0)
  320. ---------------------------------------------------------------------------------------------------------
  321. @TestBuffer  (subroutine)
  322. ---------------------------------------------------------------------------------------------------------
  323.      @Function
  324. :    Tests buffer to see if there is anything to print.
  325.      @ Called By:    
  326. PrintPrintBuffer
  327.  Pass:
  328.         r3 - pointer to begining of print buffer to test.
  329.      @        
  330.  Returned:
  331.     carry - carry flag = 1 if data in the buffer, else carry flag = 0.
  332.  Destroyed:
  333.     a, x, r3
  334.  Synopsis:
  335.     Check all the bytes in the buffer to see if all are $00    
  336.      @        
  337. ---------------------------------------------------------------------------------------------------------.endif
  338.      @TestBuffer
  339.     LoadB    CardCount,#$00
  340.     ldx    #$07    ; Assume 8 bit high printhead.
  341.     stx    Scount    ; Save.
  342.     AddVW    #((CardsWide-1)<<3),r3
  343.     ldx    #CardsWide    ; Load the cards/line.
  344.      @10
  345. $:    ldy    Scount    ; Get the line count.
  346.      @20
  347. $:    lda    (r3),y    ; Check a byte.
  348.     bne    30$    ; If zero, skip to check another byte.
  349.     dey        ; Point at next card.
  350.     bpl    20$    ; If not at end, check next byte in this card.
  351.     sec        ; Point at next card.
  352.     lda    r3L
  353.     sbc    #$08
  354.     sta    r3L
  355.     lda    r3H
  356.     sbc    #$00
  357.     sta    r3H
  358.     inc    CardCount
  359.     dex        ; See if all the cards are done.
  360.     bne    10$    ; If not done, do another card.
  361.     clc        ; If here, then line was clear.
  362.     rts        ; Return from subroutine.
  363.      @30
  364. $:    sec        ; Set the carry to signal data found.
  365.     rts        ; Return from subroutine.
  366. .if (0)
  367. ---------------------------------------------------------------------------------------------------------
  368. @SetGraphics  (subroutine)
  369. ---------------------------------------------------------------------------------------------------------
  370.      @ Function
  371. :    Set the Star NX-1000C into 640 column graphics mode.    
  372.      @ Called By:    
  373. PrintPrintBuffer
  374.  Pass:
  375.         CardCount - the number of the card being processed.
  376.      @        
  377.  Returned:
  378.     r3 - #WsDgPhTbl, the printer width table.
  379.         Scount - #$ff
  380.         y - 0
  381.  Destroyed:
  382.  Synopsis:
  383.     Tell the printer the graphics mode and how many bytes to expect.    
  384.      @        
  385. ---------------------------------------------------------------------------------------------------------
  386. .endif
  387.      @SetGraphics
  388.     LoadB    r3H,#$00    ; Clear top byte.
  389.     MoveB    CardCount,r3L    ; Load CardCount into low byte.
  390.     asl    r3L    ; x 8.
  391.     rol    r3H
  392.     asl    r3L
  393.     rol    r3H
  394.     asl    r3L
  395.     rol    r3H
  396.     lda    #[(CardsWide<<3)    ; Get total width for page in bytes.
  397.     sbc    r3L
  398.     sta    WsDgPhTbl+3
  399.     lda    #](CardsWide<<3)    ; Get total width for page in bytes.
  400.     sbc    r3H
  401.     sta    WsDgPhTbl+4
  402.     LoadW    r3,WsDgPhTbl    ; Table of control bytes for 640 col. Sgl den.
  403.     lda    #[(WsDgPhEnd-WsDgPhTbl)    ; Length of string.
  404.     jmp    SendString    ; Output the string.
  405.      @WsDgPhTbl
  406.     .byte    27,42    ; Select graphics mode.
  407.     .byte    4        ; Select CRT graphics 80 dots per inch.
  408.     .byte    128,2    ; Number of graphics bytes to output.
  409.      @WsDgPhEnd
  410. .if (0)
  411. -------------
  412. .if (0)
  413. ---------------------------------------------------------------------------------------------------------
  414. @Rotate  (subroutine)
  415. ---------------------------------------------------------------------------------------------------------
  416.      @ Function
  417. :    Rotates a hi-res bit-mapped card from the 640 byte print buffer to an 8 byte 
  418.         buffer which is then ready for sending to the printer.    
  419.      @ Called By:    
  420. PrintPrintBuffer
  421.  Pass:
  422.         r3 - address of the card to be operated on.
  423.      @        
  424.  Returned:
  425.     PrntBlCard - rotated data placed here.
  426.  Destroyed:
  427.     a, x, y
  428.  Synopsis:
  429.     Create the nth byte in the PrntBlCard out of the nth bit of each of the bytes 
  430.         in the card pointed to by r3.  This rotates a hi-res bit-mapped card from the 
  431.         640 byte print buffer pointed at by r3 into the PrntBlCard 8 byte buffer.    
  432.      @        
  433. ---------------------------------------------------------------------------------------------------------
  434. .endif
  435. Rotate:
  436.     sei        ; Disable any IRQs.
  437.     ldy    #$07    ; Initialize the index into the card.
  438.      @10
  439. $:    lda    (r3),y    ; Get the byte from the card.
  440.     ldx    #$07    ; Initialize the index into the printable card.
  441.      @20
  442. $:    ror    a    ; Get the least significant bit into carry.
  443.     ror    PrntBlCard,x    ; Shift into the printable card table.
  444.     dex        ; Next bit.
  445.     bpl    20$    ; If not done, store another bit.
  446.     dey        ; Next byte.
  447.     bpl    10$    ; If not done, load another byte.
  448.     cli        ; Clear interrupt disable bit.
  449.     rts        ; Return from subroutine.
  450. .if (0)
  451. ---------------------------------------------------------------------------------------------------------
  452. @SendBuff  (subroutine)
  453. --------------------------------------------------------------------------------------------------------
  454.      @ Function
  455.     Sends a printable card out the serial port.
  456.      @ Called By:    
  457. PrintPrintBuffer
  458.  Pass:
  459.         PrntBlCard - this buffer contains the rotated card data.
  460.  Returned:
  461.     Nothing.
  462.  Destroyed:
  463.     a, x
  464.  Synopsis:
  465.     After a card has been rotated so that the bytes each represent a vertical 
  466.         column of bits to go to the printer, SendBuff sends the card accross the
  467.         serial bus.    
  468. ---------------------------------------------------------------------------------------------------------
  469. .endif
  470.      @SendBuff
  471.     ldx    #$00    ; Initialize the count.
  472.      @10
  473. $:    txa        ; Save count.
  474.     lda    PrntBlCard,x    ; Get byte to send.
  475.     jsr    Ciout    ; Send this byte.
  476.     tax        ; Recover the count.
  477.     inx        ; Point to next byte.
  478.     cpx    #$08    ; Are we done with all of the bytes?
  479.     bne    10$    ; If not, continue with sending.
  480.     rts        ; All done.
  481. .if (0)
  482. ------------------------------------
  483. .if (0)
  484. ---------------------------------------------------------------------------------------------------------
  485. @r_StopPrint
  486. ---------------------------------------------------------------------------------------------------------
  487.      @ Function
  488. :     Called at end of every page to flush output buffer and tell the printer to form 
  489.         feed. 
  490.      @ Called By:    
  491.      @GEOS
  492.  Application.
  493.  Pass:
  494.         r0 - address of the 640 bytes (80 cards) to be printed.
  495.         r1 - address of an additional 640 byte buffer for PrintBuffer to use.
  496.         NOTE: This buffer may not change between calls to PrintBuffer.  7 bit printers 
  497.            use it to store the left over scanlines between calls.  Each time
  498.      @         
  499. PrintBuffer
  500.           is called it is passed 8 scanlines of data but only 7 may be printed.
  501.  Returned:
  502.     r0, r1 - Unchanged.
  503.  Destroyed:
  504.     a, x, y, r3
  505.  Synopsis:
  506.     StopPrint is called after all cards for a giving page have been sent to the 
  507.         printer.  It does a SetDevice, InitForIO, makes the printer listen, and if the
  508.         printhead was printing 7-bit high data, flushes out any remaining lines of data
  509.         in the print buffer.  It then does a form-feed and an unlisten, closes the 
  510.         Commdore output file, and does a DoneWithIO.
  511. ---------------------------------------------------------------------------------------------------------
  512. .endif
  513.      @r_StopPrint
  514.     lda    #PrintAddr    ; Set to channel 4.
  515.     jsr    SetDevice    ; Set GEOS device number.
  516.     jsr    InitForIO    ; Put I/O space in, disable interrupts.
  517.     jsr    OpenPrint    ; Open channel to printer.
  518.     jsr    FormFeed    ; Do a form feed.
  519.     jsr    DoBeep    ; This will cause the printer to beep.
  520.             ;   Chr$(7).
  521.     jsr    ClosePrint    ; Close channel to printer.
  522.     jsr    CloseFile    ; Close the print file.
  523.     jsr    DoneWithIO    ; Put back memory map, enable interrupts.
  524.     rts        ; Return from routine.
  525.      @DoBeep
  526.     lda    #$07    ; Chr$(7)  Bell
  527.     jsr    Ciout    ; Send it.
  528.     rts        ; All done.
  529. .if (0)
  530. --------------------------------
  531. .if (0)
  532. ---------------------------------------------------------------------------------------------------------
  533. @r_GetDimensions
  534. ---------------------------------------------------------------------------------------------------------
  535.      @ Function
  536. Return the dimesnsions in cards of the rectangle that will print in an 8 x 10
  537.         area of the screen.
  538.      @ Called By:    
  539.      @GEOS
  540.  Application.
  541.  Pass:
  542.         Nothing.
  543.  Returned:
  544.     X = Width, in cards, that this printer can put accross a page.
  545.         Y = Height, in  cards, that this printer can put down a page.
  546.  Destroyed:
  547.     Nothing.
  548.  Synopsis:
  549.     GetDimensions returns the number of cards wide and high that this printer is 
  550.         capable of printing out on 8 x 10 subset of an 8 1/2 by 11 inch page.    
  551. ---------------------------------------------------------------------------------------------------------
  552. .endif
  553.      @r_GetDimensions
  554.     ldx    #CardsWide    ; Get number of cards wide and
  555.     ldy    #CardsDeep    ;   get the number of cards high.
  556.     lda    #$00    ; Set for graphics driver only.
  557.     rts        ; Return from routine.
  558. .if (0)
  559. ---------------------------------------------------
  560. .if (0)
  561. ---------------------------------------------------------------------------------------------------------
  562. @r_PrintASCII
  563. ---------------------------------------------------------------------------------------------------------
  564.      @ Function
  565. Prints a null terminated ASCII string to the printer.
  566.      @ Called By:    
  567.      @GEOS
  568.  Application.
  569.  Pass:
  570.         r0 - pointer to the ASCII string.
  571.         r1 - pointer to the 640 byte buffer for the printer driver to use.
  572.  Returned:
  573.     Nothing.
  574.  Destroyed:
  575.     Assume all registers.
  576.  Synopsis:
  577.     Sends a null terminated ASCII string to the printer.  All carriage returns and 
  578.         linefeeds must be handled by the application.  Carriage returns are mapped in
  579.         to cr-lf.    
  580.      @: Star NX-1000C 
  581. printer only requires a carriage return to be sent to it.
  582. ---------------------------------------------------------------------------------------------------------
  583. .endif
  584.      @r_PrintASCII
  585.     lda    #PrintAddr    ; Set to channel 4.
  586.     jsr    SetDevice    ; Set to printer device.
  587.     jsr    InitForIO    ; Put I/O space in and disable interrupts.
  588.     jsr    OpenPrint    ; Open print channel.
  589.      @10
  590. $:    ldy    #$00    ; Init the index into ASCII string.
  591.     lda    (r0),y    ; Get the character.
  592.     beq    30$    ; Is it a null?  Yes, end of string, exit.
  593.     jsr    Ciout    ; Output the character.
  594.     inc    r0    ; Move pointer to next character.
  595.     bne    20$
  596.     inc    r0+1
  597.      @20
  598. $:    clv
  599.     bvc    10$
  600.      @30
  601. $:    jsr    ClosePrint    ; Close the print channel.
  602.     jsr    DoneWithIO    ; Put memory map back, enable interrupts.
  603.     rts        ; Return from routine.
  604. .if (0)
  605. -----------------------------------------------------------------------------------------------
  606. .if (0)
  607. ---------------------------------------------------------------------------------------------------------
  608. @r_StartASCII
  609. ---------------------------------------------------------------------------------------------------------
  610.      @ Function
  611. Initialize the Star NX-1000C to receive ASCII print streams.
  612.      @ Called By:    
  613.      @GEOS
  614.  Application.
  615.  Pass:
  616.         Nothing.
  617.  Returned:
  618.     Nothing.
  619.  Destroyed:
  620.  Synopsis:
  621.     Just sets the mode flag.  Called by the user at beginning of each document.    
  622. ---------------------------------------------------------------------------------------------------------
  623. .endif
  624.      @r_StartASCII
  625.     LoadB    ModeFlag,#$ff    ; Set mode to ASCII printing.
  626.     jmp    StartIn    ; Pick up rest of StartPrint.
  627. .if (0)
  628. ---------------------------------------------------------------------------------------------------------
  629. @r_SetNL
  630. .if (0)
  631. ---------------------------------------------------------------------------------------------------------
  632. @r_SetNLQ
  633. ---------------------------------------------------------------------------------------------------------
  634.      @ Function
  635. Initilize the Star NX-1000C to near letter quality mode.
  636.      @ Called By:    
  637.      @GEOS
  638.  Application.
  639.  Pass:
  640.         Nothing.
  641.  Returned:
  642.     Nothing.
  643.  Destroyed:
  644.  Synopsis:
  645.     Sent the printer driver the correct initilization bytes to put it in NLQ mode.    
  646. ---------------------------------------------------------------------------------------------------------
  647. .endif
  648.      @r_SetNLQ
  649.     lda    #PrintAddr    ; Set to channel 4.
  650.     jsr    SetDevice    ; Set device number.
  651.     jsr    InitForIO    ; Put I/O space in, disable interrupts.
  652.     jsr    OpenPrint    ; Open channel to printer.
  653.     LoadW    r3,#NLQTable    ; Table of initilization bytes to send.
  654.     lda    #[(NLQEnd-NLQTable)    ; The length of the table.
  655.     jsr    SendString    ; Output the table.
  656.     jsr    ClosePrint    ; Close the print channel.
  657.     jsr    DoneWithIO    ; Put memory map back, enable interrupts.
  658.     rts        ; Return from routine.
  659.      @NLQTable
  660.     .byte    27,107    ; Select NLQ type style code.
  661.     .byte    0    ; Select COURIER type style.
  662.     .byte    27,120,49    ; Select NLQ characters.
  663.      @NLQEnd:
  664. ; *** These are the utilities used by this printer driver.
  665.      @OpenFile
  666.     lda    #PrintAddr
  667.     jsr    Listen
  668.     lda    #$90 | SecAdMsk | Sec
  669. ; *** These are the utilities used by this printer driver.
  670.      @OpenFile
  671.     lda    #PrintAddr
  672.     jsr    Listen
  673.     lda    #$90 | SecAdMsk | SecAddr
  674.     jsr    Second
  675.     jsr    Unlsn
  676.      @CloseFile
  677.     lda    #PrintAddr
  678.     jsr    Listen
  679.     lda    #$80 | SecAdMsk | SecAddr
  680.     jsr    Second
  681.     jsr    Unlsn
  682.      @OpenPrint
  683.     lda    #PrintAddr
  684.     jsr    Listen
  685.     lda    SecAdMsk | SecAddr
  686.     jsr    Second
  687.      @ClosePrint
  688.     jsr    Unlsn
  689.      @SendString
  690.     sta    Scount    ; Number of characters to send.
  691.     ldy    #$00    ; Set index to zero.
  692.      @10
  693. $:    lda    (r3),y    ; Get a character from location pointed to
  694.             ;   by r3 and .Y.
  695.     jsr    Ciout    ; Send that character to the printer.
  696.     iny        ; Increase index for next character.
  697.     cpy    Scount    ; Have we sent all of the characters?
  698.     bne    10$    ; No, get another character.
  699.     rts        ; Yes, exit this subroutine.
  700.      @Credits
  701. :            ; My Credits.
  702.     .byte    "By: James W. Pyle III  (C) 1989 Microtech Softworks, Inc.",0
  703.      @PRGEnd
  704. :    .end            ; End of main code for header.
  705.