home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
8bitfiles.net/archives
/
archives.tar
/
archives
/
canada-remote-systems
/
geos
/
drivers
/
nx1000sr.sfx
/
snx1000c.src
(
.txt
)
< prev
Wrap
GEOS ConVerT
|
1990-02-12
|
27KB
|
705 lines
SNX1000C.src
PRG formatted GEOS file V1.0
StarNX-1000C
OP V2.0 or higher
FOR USE WITH
BLASTER'S CONVERTER V2.5
C64 ALL VERSIONS
T/D VH7-1.0
Write Image V2.1
geoWrite V2.1
.This is the source code for ReColor. It can be viewed be geoWrite.
; *** StarNX-1000C Main Program: This is a printer driver for the Star NX-1000C printer.
.if Pass1 ; Only need to include these files
; during assembler's first pass.
.include geosSym ; Get GEOS definitions.
.include geosMac ; Get GEOS macro definitions.
.endif
CardsWide == $50 ; 80 Commdore cards wide.
CardsDeep == $5e ; 94 Commdore cards deep.
SecAddr == $05 ; Set secondary address to lowercase.
PrintAddr == $04 ; Set printer number to 4.
SecAdMsk == $60
FF == $0c ; Form feed CHR$(12)
Ciout == $ffa8
Listen == $ffb1
Unlsn == $ffae
Second == $ff93
.psect ; Program code starts here (GeoLinker will
; set the start address: $7900)
; *** This will be the start of the program main code.
@PRGStart
: ; This label will set the start address.
; This is the printer driver jump table.
@P_InitForPrint
jmp r_InitForPrint ; This driver uses this routine to allow the
; user to set: Pitch, Spacing, NLQ Font, etc.
@P_StartPrint
: ; Performs initialization necessary before
jmp r_StartPrint ; printing each page of a document.
@P_PrintBuffer
: ; Prints out the indicated 640 byte buffer of
jmp r_PrintBuffer ; graphic data as created by a application.
@P_StopPrint
: ; Called at end of every page to flush output
jmp r_StopPrint ; buffer and tell the printer to form feed.
@P_GetDimensions
: ; Returns the dimensions in cards of the
jmp r_GetDimensions ; rectangle that will print in an 8x10 area
; of the screen.
@P_PrintASCII
: ; Prints a null terminated ASCII string to the
jmp r_PrintASCII ; printer.
@P_StartASCII
jmp r_StartASCII ; Initilizes the printer to receive ASCII print
; streams.
@P_SetNLQ
: ; Initilizes the printer to NEAR LETTER QUALITY
jmp r_SetNLQ ; mode.
; *** RAM stroage buffers and flags.
@PrinterName
.byte "StarNX-1000C",0 ; Name of printer.
; *** RAM stroage buffers and flags.
@PrinterName
.byte "StarNX-1000C",0 ; Name of printer.
@PrntBlCard
.byte 0,0,0,0,0,0,0,0 ; Printable character block.
@BreakCount
.byte 0
@CardWidth
.byte 0 ; Width of the print buffer line in cards.
@Scount
.byte 0 ; String output routine counter.
@CardCount
.byte 0
@ModeFlag
.byte 0 ; Either $00=GRAPHICS, or $FF=ASCII for draft
; or NLQ mode.
.if (0)
---------------------------------------------------------------------------------------------------------
@r_InitForPrint
---------------------------------------------------------------------------------------------------------
@
Function
: Performes printer dependent initilization once per document.
@ Called By:
@GEOS
Application.
Pass:
Nothing.
@
Returned:
Nothing.
Destroyed:
Nothing.
Synopsis:
InitForPrint is the first of the routines to be called. It sends the printer and
special commands it needs to print GEOS documents. In some printer drivers
this routine does nothing.
---------------------------------------------------------------------------------------------------------.endif
@r_InitForPrint
rts ; Just exit. Nothing to do...
.if (0)
---------------------------------------------------------------------------------------
.if (0)
---------------------------------------------------------------------------------------------------------
@r_StartPrint
---------------------------------------------------------------------------------------------------------
@
Function
: Perform initialization necessary before printing each page of a document.
@ Called By:
@GEOS
Application.
Pass:
Nothing.
@
Returned:
Nothing.
Destroyed:
a, x, y, r3
Synopsis:
This is the StartPrint routine as discussed above. It initilized the serial bus to
the printer, sets up the printer to receive graphic data.
@
---------------------------------------------------------------------------------------------------------.endif
@r_StartPrint
LoadB ModeFlag,#$00 ; Set graphics mode.
@StartIn
lda #PrintAddr ; Set to channel 4.
jsr SetDevice
jsr InitForIO ; Set I/O space in, interrupt disable.
LoadB STATUS,#$00 ; Set error byte to zero. (no error)
jsr OpenFile ; Open a file to the printer.
lda STATUS ; Check to see if there was an error.
bne 10$ ; Yes there was an error.
jsr OpenPrint ; Open a channel to the printer.
jsr InitPrinter ; Initialize the printer for graphics mode.
jsr ClosePrint ; Close the print channel.
jsr Delay ; Wait for weird timing problems.
jsr DoneWithIO ; Set memory map back, enable interrupts.
ldx #$00 ; Set error to zero. (no error)
rts ; Return from routine.
@10
$: pha ; Save error returned from routines.
; bit 0 set: timeout, write.
; bit 7 set: device not present.
jsr CloseFile ; Close the file anyway.
jsr DoneWithIO ; Set memory map back, enable interrupts.
pla ; Recover the error returned.
tax ; Pass out to .X.
rts ; Return from routine.
@Delay
: ; Wait for weird timing problems.
ldx #$00
@20
$: ldy #$00
@30
$: dey
bne 30$
bne 20$
rts ; Return from delay.
.if (0)
------------------
.if (0)
---------------------------------------------------------------------------------------------------------
@InitPrinter (subroutine)
---------------------------------------------------------------------------------------------------------
@Function
: Initilizes the Star NX-1000C to line-feed 8/72"
@ Called By:
r_StartPrint
Pass:
Nothing.
@
Returned:
r3 - #LFSetTbl
Scount - #$ff
y - #$00
Destroyed:
Synopsis:
Output to the printer a string of characters whick initializes it. See the
printer's owners manual.
@
---------------------------------------------------------------------------------------------------------.endif
@InitPrinter
bit ModeFlag ; See if printing ASCII or Graphic mode.
bmi 10$ ; Branch if ASCII.
LoadW r3,#LFSetTbl ; Table of bytes for initilization.
lda #[(LFSetEnd-LFSetTbl) ; Length of string.
jmp SendString ; Output the string.
@10
$: LoadW r3,#ASCIITbl ; Table of bytes for ASCII initilization.
lda #[(ASCIIEnd-ASCIITbl) ; Length of string.
jmp SendString ; Output the string.
@LFSetTbl
.byte 27,64 ; Reset printer.
.byte 27,65,8 ; Set 8/72" linefeed.
@LFSetEnd
@ASCIITbl
.byte 27,64 ; Reset printer.
.byte 27,93,49 ; Set ASCII operating mode.
.byte 27,50 ; Set linespacing to 1/6 inch.
.byte 27,82,1 ; Set USA character set.
.byte 27,126,49 ; Set slash zero.
@ASCIIEnd
.if (0)
---------------------------------------------------------------------------------------------------------
@r_PrintBuffer
---------------------------------------------------------------------------------------------------------
@ Function
: Print out the indicated 640 byte buffer of graphic data (80 cards) as created
by an application.
@ Called By:
@GEOS
Application.
Pass:
r0 - address of the 640 bytes to be printed.
r1 - address of an additional 640 byte buffer for PrintBuffer to use.
NOTE: This buffer may not change between calls to PrintBuffer. 7 bit printers
use it to store the left over scanlines between calls. Each time PrintBuffer
is called it is passed 8 scanlines of data but only 7 may be printed.
@
Returned:
r0, r2 - unchanged.
Destroyed:
a, x, y, r3
Synopsis:
PrintBuffer, as described in more detail above, is the top level routine that
dumps data from the GEOS 640 byte buffer maintained in the Commdore 64 to
the printer using the serial port.
@
---------------------------------------------------------------------------------------------------------.endif
@r_PrintBuffer
lda #PrintAddr ; Set to channel 4.
jsr SetDevice ; Set GEOS device number.
jsr InitForIO ; Put I/O space in, disable interrupts.
jsr OpenPrint ; Open channel to printer.
MoveW r0,r3 ; Set r3 to r0.
jsr PrintPrintBuffer ; Print the users 8 bit high buffer.
jsr Greturn ; Do a CR only.
jsr ClosePrint ; Close the print channel.
jsr DoneWithIO ; Put back memory map, enable interrupts.
rts ; All done exit routine.
.if (0)
-----------------------------------------------------------
.if (0)
---------------------------------------------------------------------------------------------------------
@Greturn & FormFeed (subroutine)
---------------------------------------------------------------------------------------------------------
Function
: Prints out a carriage return. Exit graphics mode and print the form feed
character.
@ Called By:
PrintBuffer
Pass:
Nothing.
@
Returned:
Nothing.
Destroyed:
a, variabled destroyed by Ciout.
Synopsis:
Outputs the CR or Form feed
@
---------------------------------------------------------------------------------------------------------.endif
@Greturn
lda #CR ; Carriage return.
jsr Ciout ; Sent it.
rts ; Exit.
@FormFeed
lda #FF ; FormFeed.
jsr Ciout ; Sent it.
rts ; Exit.
.if (0)
----------------------------------------------------------------------------------------------
.if (0)
---------------------------------------------------------------------------------------------------------
@PrintPrintBuffer (subroutine)
---------------------------------------------------------------------------------------------------------
Function
: Prints out the print buffer pointed to by r3.
@ Called By:
PrintBuffer
Pass:
r3 - address of start of buffer to print.
@
Returned:
r3 - unchanged.
Destroyed:
a, x, y, r0 - r15
Synopsis:
Checks to see if the buffer is empty before printing the data. Then for each
card in the buffer, rotate the data and send it to the printer.
@
---------------------------------------------------------------------------------------------------------.endif
@PrintPrintBuffer
PushW r3 ; Save the buffer pointer.
jsr TestBuffer ; See if the buffer is all zeros.
bcs 10$ ; If thereis data in the buffer, send it.
PopW r3 ; Dummy pop.
rts ; Return from subroutine.
@10
$: jsr SetGraphics ; Set graphics mode for this line.
PopW r3 ; Restore the buffer pointer.
lda #CardsWide ; Load the card count (up to 80).
sbc CardCount
@20
$: txa ; Save .X.
jsr Rotate ; Rotate the card...
jsr SendBuff ; Send the rotated card.
AddVW #$08,r3 ; Update pointer to buffer.
pla ; Recover .X.
dex ; Done?
bne 20$ ; If not, do another card.
rts ; Return to subroutine.
.if (0)
-----------
.if (0)
---------------------------------------------------------------------------------------------------------
@TestBuffer (subroutine)
---------------------------------------------------------------------------------------------------------
@Function
: Tests buffer to see if there is anything to print.
@ Called By:
PrintPrintBuffer
Pass:
r3 - pointer to begining of print buffer to test.
@
Returned:
carry - carry flag = 1 if data in the buffer, else carry flag = 0.
Destroyed:
a, x, r3
Synopsis:
Check all the bytes in the buffer to see if all are $00
@
---------------------------------------------------------------------------------------------------------.endif
@TestBuffer
LoadB CardCount,#$00
ldx #$07 ; Assume 8 bit high printhead.
stx Scount ; Save.
AddVW #((CardsWide-1)<<3),r3
ldx #CardsWide ; Load the cards/line.
@10
$: ldy Scount ; Get the line count.
@20
$: lda (r3),y ; Check a byte.
bne 30$ ; If zero, skip to check another byte.
dey ; Point at next card.
bpl 20$ ; If not at end, check next byte in this card.
sec ; Point at next card.
lda r3L
sbc #$08
sta r3L
lda r3H
sbc #$00
sta r3H
inc CardCount
dex ; See if all the cards are done.
bne 10$ ; If not done, do another card.
clc ; If here, then line was clear.
rts ; Return from subroutine.
@30
$: sec ; Set the carry to signal data found.
rts ; Return from subroutine.
.if (0)
---------------------------------------------------------------------------------------------------------
@SetGraphics (subroutine)
---------------------------------------------------------------------------------------------------------
@ Function
: Set the Star NX-1000C into 640 column graphics mode.
@ Called By:
PrintPrintBuffer
Pass:
CardCount - the number of the card being processed.
@
Returned:
r3 - #WsDgPhTbl, the printer width table.
Scount - #$ff
y - 0
Destroyed:
Synopsis:
Tell the printer the graphics mode and how many bytes to expect.
@
---------------------------------------------------------------------------------------------------------
.endif
@SetGraphics
LoadB r3H,#$00 ; Clear top byte.
MoveB CardCount,r3L ; Load CardCount into low byte.
asl r3L ; x 8.
rol r3H
asl r3L
rol r3H
asl r3L
rol r3H
lda #[(CardsWide<<3) ; Get total width for page in bytes.
sbc r3L
sta WsDgPhTbl+3
lda #](CardsWide<<3) ; Get total width for page in bytes.
sbc r3H
sta WsDgPhTbl+4
LoadW r3,WsDgPhTbl ; Table of control bytes for 640 col. Sgl den.
lda #[(WsDgPhEnd-WsDgPhTbl) ; Length of string.
jmp SendString ; Output the string.
@WsDgPhTbl
.byte 27,42 ; Select graphics mode.
.byte 4 ; Select CRT graphics 80 dots per inch.
.byte 128,2 ; Number of graphics bytes to output.
@WsDgPhEnd
.if (0)
-------------
.if (0)
---------------------------------------------------------------------------------------------------------
@Rotate (subroutine)
---------------------------------------------------------------------------------------------------------
@ Function
: Rotates a hi-res bit-mapped card from the 640 byte print buffer to an 8 byte
buffer which is then ready for sending to the printer.
@ Called By:
PrintPrintBuffer
Pass:
r3 - address of the card to be operated on.
@
Returned:
PrntBlCard - rotated data placed here.
Destroyed:
a, x, y
Synopsis:
Create the nth byte in the PrntBlCard out of the nth bit of each of the bytes
in the card pointed to by r3. This rotates a hi-res bit-mapped card from the
640 byte print buffer pointed at by r3 into the PrntBlCard 8 byte buffer.
@
---------------------------------------------------------------------------------------------------------
.endif
Rotate:
sei ; Disable any IRQs.
ldy #$07 ; Initialize the index into the card.
@10
$: lda (r3),y ; Get the byte from the card.
ldx #$07 ; Initialize the index into the printable card.
@20
$: ror a ; Get the least significant bit into carry.
ror PrntBlCard,x ; Shift into the printable card table.
dex ; Next bit.
bpl 20$ ; If not done, store another bit.
dey ; Next byte.
bpl 10$ ; If not done, load another byte.
cli ; Clear interrupt disable bit.
rts ; Return from subroutine.
.if (0)
---------------------------------------------------------------------------------------------------------
@SendBuff (subroutine)
--------------------------------------------------------------------------------------------------------
@ Function
Sends a printable card out the serial port.
@ Called By:
PrintPrintBuffer
Pass:
PrntBlCard - this buffer contains the rotated card data.
Returned:
Nothing.
Destroyed:
a, x
Synopsis:
After a card has been rotated so that the bytes each represent a vertical
column of bits to go to the printer, SendBuff sends the card accross the
serial bus.
---------------------------------------------------------------------------------------------------------
.endif
@SendBuff
ldx #$00 ; Initialize the count.
@10
$: txa ; Save count.
lda PrntBlCard,x ; Get byte to send.
jsr Ciout ; Send this byte.
tax ; Recover the count.
inx ; Point to next byte.
cpx #$08 ; Are we done with all of the bytes?
bne 10$ ; If not, continue with sending.
rts ; All done.
.if (0)
------------------------------------
.if (0)
---------------------------------------------------------------------------------------------------------
@r_StopPrint
---------------------------------------------------------------------------------------------------------
@ Function
: Called at end of every page to flush output buffer and tell the printer to form
feed.
@ Called By:
@GEOS
Application.
Pass:
r0 - address of the 640 bytes (80 cards) to be printed.
r1 - address of an additional 640 byte buffer for PrintBuffer to use.
NOTE: This buffer may not change between calls to PrintBuffer. 7 bit printers
use it to store the left over scanlines between calls. Each time
@
PrintBuffer
is called it is passed 8 scanlines of data but only 7 may be printed.
Returned:
r0, r1 - Unchanged.
Destroyed:
a, x, y, r3
Synopsis:
StopPrint is called after all cards for a giving page have been sent to the
printer. It does a SetDevice, InitForIO, makes the printer listen, and if the
printhead was printing 7-bit high data, flushes out any remaining lines of data
in the print buffer. It then does a form-feed and an unlisten, closes the
Commdore output file, and does a DoneWithIO.
---------------------------------------------------------------------------------------------------------
.endif
@r_StopPrint
lda #PrintAddr ; Set to channel 4.
jsr SetDevice ; Set GEOS device number.
jsr InitForIO ; Put I/O space in, disable interrupts.
jsr OpenPrint ; Open channel to printer.
jsr FormFeed ; Do a form feed.
jsr DoBeep ; This will cause the printer to beep.
; Chr$(7).
jsr ClosePrint ; Close channel to printer.
jsr CloseFile ; Close the print file.
jsr DoneWithIO ; Put back memory map, enable interrupts.
rts ; Return from routine.
@DoBeep
lda #$07 ; Chr$(7) Bell
jsr Ciout ; Send it.
rts ; All done.
.if (0)
--------------------------------
.if (0)
---------------------------------------------------------------------------------------------------------
@r_GetDimensions
---------------------------------------------------------------------------------------------------------
@ Function
Return the dimesnsions in cards of the rectangle that will print in an 8 x 10
area of the screen.
@ Called By:
@GEOS
Application.
Pass:
Nothing.
Returned:
X = Width, in cards, that this printer can put accross a page.
Y = Height, in cards, that this printer can put down a page.
Destroyed:
Nothing.
Synopsis:
GetDimensions returns the number of cards wide and high that this printer is
capable of printing out on 8 x 10 subset of an 8 1/2 by 11 inch page.
---------------------------------------------------------------------------------------------------------
.endif
@r_GetDimensions
ldx #CardsWide ; Get number of cards wide and
ldy #CardsDeep ; get the number of cards high.
lda #$00 ; Set for graphics driver only.
rts ; Return from routine.
.if (0)
---------------------------------------------------
.if (0)
---------------------------------------------------------------------------------------------------------
@r_PrintASCII
---------------------------------------------------------------------------------------------------------
@ Function
Prints a null terminated ASCII string to the printer.
@ Called By:
@GEOS
Application.
Pass:
r0 - pointer to the ASCII string.
r1 - pointer to the 640 byte buffer for the printer driver to use.
Returned:
Nothing.
Destroyed:
Assume all registers.
Synopsis:
Sends a null terminated ASCII string to the printer. All carriage returns and
linefeeds must be handled by the application. Carriage returns are mapped in
to cr-lf.
@: Star NX-1000C
printer only requires a carriage return to be sent to it.
---------------------------------------------------------------------------------------------------------
.endif
@r_PrintASCII
lda #PrintAddr ; Set to channel 4.
jsr SetDevice ; Set to printer device.
jsr InitForIO ; Put I/O space in and disable interrupts.
jsr OpenPrint ; Open print channel.
@10
$: ldy #$00 ; Init the index into ASCII string.
lda (r0),y ; Get the character.
beq 30$ ; Is it a null? Yes, end of string, exit.
jsr Ciout ; Output the character.
inc r0 ; Move pointer to next character.
bne 20$
inc r0+1
@20
$: clv
bvc 10$
@30
$: jsr ClosePrint ; Close the print channel.
jsr DoneWithIO ; Put memory map back, enable interrupts.
rts ; Return from routine.
.if (0)
-----------------------------------------------------------------------------------------------
.if (0)
---------------------------------------------------------------------------------------------------------
@r_StartASCII
---------------------------------------------------------------------------------------------------------
@ Function
Initialize the Star NX-1000C to receive ASCII print streams.
@ Called By:
@GEOS
Application.
Pass:
Nothing.
Returned:
Nothing.
Destroyed:
Synopsis:
Just sets the mode flag. Called by the user at beginning of each document.
---------------------------------------------------------------------------------------------------------
.endif
@r_StartASCII
LoadB ModeFlag,#$ff ; Set mode to ASCII printing.
jmp StartIn ; Pick up rest of StartPrint.
.if (0)
---------------------------------------------------------------------------------------------------------
@r_SetNL
.if (0)
---------------------------------------------------------------------------------------------------------
@r_SetNLQ
---------------------------------------------------------------------------------------------------------
@ Function
Initilize the Star NX-1000C to near letter quality mode.
@ Called By:
@GEOS
Application.
Pass:
Nothing.
Returned:
Nothing.
Destroyed:
Synopsis:
Sent the printer driver the correct initilization bytes to put it in NLQ mode.
---------------------------------------------------------------------------------------------------------
.endif
@r_SetNLQ
lda #PrintAddr ; Set to channel 4.
jsr SetDevice ; Set device number.
jsr InitForIO ; Put I/O space in, disable interrupts.
jsr OpenPrint ; Open channel to printer.
LoadW r3,#NLQTable ; Table of initilization bytes to send.
lda #[(NLQEnd-NLQTable) ; The length of the table.
jsr SendString ; Output the table.
jsr ClosePrint ; Close the print channel.
jsr DoneWithIO ; Put memory map back, enable interrupts.
rts ; Return from routine.
@NLQTable
.byte 27,107 ; Select NLQ type style code.
.byte 0 ; Select COURIER type style.
.byte 27,120,49 ; Select NLQ characters.
@NLQEnd:
; *** These are the utilities used by this printer driver.
@OpenFile
lda #PrintAddr
jsr Listen
lda #$90 | SecAdMsk | Sec
; *** These are the utilities used by this printer driver.
@OpenFile
lda #PrintAddr
jsr Listen
lda #$90 | SecAdMsk | SecAddr
jsr Second
jsr Unlsn
@CloseFile
lda #PrintAddr
jsr Listen
lda #$80 | SecAdMsk | SecAddr
jsr Second
jsr Unlsn
@OpenPrint
lda #PrintAddr
jsr Listen
lda SecAdMsk | SecAddr
jsr Second
@ClosePrint
jsr Unlsn
@SendString
sta Scount ; Number of characters to send.
ldy #$00 ; Set index to zero.
@10
$: lda (r3),y ; Get a character from location pointed to
; by r3 and .Y.
jsr Ciout ; Send that character to the printer.
iny ; Increase index for next character.
cpy Scount ; Have we sent all of the characters?
bne 10$ ; No, get another character.
rts ; Yes, exit this subroutine.
@Credits
: ; My Credits.
.byte "By: James W. Pyle III (C) 1989 Microtech Softworks, Inc.",0
@PRGEnd
: .end ; End of main code for header.