home *** CD-ROM | disk | FTP | other *** search
/ 8bitfiles.net/archives / archives.tar / archives / canada-remote-systems / geos / drivers / shelldc2.sda / PRINTERSHELL (.txt) < prev    next >
GEOS ConVerT  |  2019-04-13  |  13KB  |  402 lines

  1. PrinterShell
  2. PRG formatted GEOS file V1.0
  3. Star NX-10
  4. OP V2.0 or higherHELL
  5. ShellHeader
  6. BLASTER'S CONVERTER V2.5
  7. PetASCII
  8. PChanGC
  9. Write Image V2.0
  10. geoWrite    V2.1
  11. .Source code for Printer Shell. DO NOT MODIFY.  For viewing only.
  12.     .include    ShellZero
  13. @MoveData
  14.     ==$c17e
  15. @START OF DRIVER ($7900)
  16.     .psect
  17.     jmp    jInitForPrint
  18.     jmp    jStartPrint
  19.     jmp    jPrintBuffer
  20.     jmp    jStopPrint
  21.     jmp    jGetDimensions
  22.     jmp    rPrintText
  23.     jmp    jStartASCII
  24. @SetNLQ
  25.     lda    #$c0
  26.     sta    PrintMode
  27.     jsr    OpenChannel
  28.     ldx    #mSetNLQ
  29.     jsr    SendMessage
  30. @CloseCha
  31. nnel:
  32.     jmp    rCloseChannel    ;
  33. @Entry fixed at $7922.
  34. @jInitFor
  35. Print:
  36.     jsr    InitForPrint
  37.     ldx    #0    ;Fixes bug in geoCalc.
  38. @SendByte
  39.     jmp    rSendByte    ;
  40. @Entry fixed at $792b.
  41. @OpenChan
  42.     jmp    rOpenChannel    ;
  43. @Entry fixed at $792e.
  44. @OPOffset
  45.     .byte    0    ;Offsets used by OpenWindow (odd bytes).
  46. @Primary
  47.     .byte    nPrimary    ;
  48. @Parameter fixed at $7932.
  49.     .byte    7    ;Second offset.
  50. @Secondar
  51.     .byte    nSecondary    ;
  52. @Parameter fixed at $7934.
  53.     .byte    14    ;Third offset.
  54. @Pointers
  55.     .block    6    ;Three pointers to 640-byte card buffers.
  56. StackSize        =20    ;All calls to Shell subroutines must not have
  57. @StackSav
  58. e:        ;used more than twenty bytes on the stack.
  59.     .block    StackSize
  60. @jGetDime
  61. nsions:
  62.     ldx    #CardsWide    ;
  63. @Parameter fixed at $7951.
  64.     ldy    #CardsLong    ;
  65. @Parameter fixed at $7953.
  66.     lda    #0
  67. @jGetDime
  68. nsions:
  69.     ldx    #CardsWide    ;
  70. @Parameter fixed at $7951.
  71.     ldy    #CardsLong    ;
  72. @Parameter fixed at $7953.
  73.     lda    #0
  74. @SendMess
  75. age:        ;
  76. @Entry fixed at $7957.
  77.     ldy    MessageLength,x    ;Get length of message "X".  
  78. @(At $7958.)
  79.     beq    99$    ;Branch if message length is zero.
  80.     lda    MessageOffset,x    ;Get offset to message "X".
  81. @(At $795d.)
  82. 10$    lda    messages,x    ;Get next byte of message.
  83. @(At $7961.)
  84.     jsr    SendByte    ;Transmit byte to printer.
  85.     inx        ;Step to next byte.
  86.     dey        ;Decrement length counter.
  87.     bne    10$
  88. 99$    rts
  89. @ShiftPix
  90. els:        
  91. @Entry fixed at $796b.
  92.     ldx    #23    ;Shift the pixels within the Window one
  93. 10$    asl    Window+48,x    ;position to the left.  The new pixels on
  94.     rol    Window+24,x    ;the right are cleared.  After 8 shifts, the
  95.     rol    Window,x    ;right hand pane is cleared and the
  96.     dex        ;subroutine returns with the Z-flag set.
  97.     bpl    10$
  98.     dec    PixelCounter    ;PixelCounter is initialized by the
  99.     rts        ;subroutine ColorWindow.
  100. @OpenWind
  101. ow:        
  102. @Entry fixed at $7979.
  103.     sty    ActiveColumn    ;Save active column minus two times eight.
  104.     lda    #<-8    ;Get ready in case we're on column one.
  105.     sta    temp
  106.     bmi    6$    ;Branch if on first column.
  107.     asl    a    ;Maximum value is 80 so carry is clear.
  108.     asl    a
  109.     sta    temp
  110.     lda    #0
  111.     rol    a
  112.     asl    temp
  113.     rol    a
  114. 6$    sta    temp+1
  115.     ldx    #4
  116. 10$    clc
  117.     ldy    OPOffsets,x
  118.     lda    Pointers,x
  119.     adc    temp    ;Low parameter for lda 1234,y.
  120.     sta    OpenPane+7,y
  121.     lda    Pointers+1,x
  122.     adc    temp+1    ;High parameter for lda 1234,y.
  123.     sta    OpenPane+8,y
  124.     bpl    10$
  125.     ; Fall through into ColorWindow on next page.
  126. @ColorWin
  127. dow:        
  128. @ColorWin
  129. dow:        
  130. @Entry fixed at $79aa.
  131.     lda    #8
  132.     sta    PixelCounter
  133.     jsr    OpenRightPane
  134.     jsr    OpenMidPane
  135. @OpenLeft
  136. Pane:
  137.     ldy    ActiveColumn    ;Y points to current middle pane so
  138.     dey        ;decrement it.
  139.     jsr    SetColor    ;Modify "eor #0" instruction of OpenPane.
  140.     ldy    #$ff    ;Y gets incremented to point to first card.
  141.     lda    #0    ;A will index into left pane of window.
  142.     beq    OpenCont    ;(Always)
  143. @OpenMidP
  144.     ldy    ActiveColumn    ;Y points to current middle pane.
  145.     jsr    SetColor    ;Modify "eor #0" instruction of OpenPane.
  146.     ldy    #$07    ;Y gets inc'ed to point to second card.
  147.     lda    #24    ;A will index into middle pane of window.
  148.     bne    OpenCont    ;(Always)
  149. @OpenRigh
  150. tPane:
  151.     ldy    ActiveColumn    ;Y points to current middle pane so
  152.     iny        ;increment it.
  153.     jsr    SetColor    ;Modify "eor #0" instruction of OpenPane.
  154.     ldy    #$0f    ;Y gets inc'ed to point to third card.
  155.     lda    #48    ;A will index into right pane of window.
  156. OpenCont:
  157. CaFr:    ora    #7    ;Offset for PreWindow is modified here.
  158. @OpenPane
  159.     lda    #8    ;Counter for eight bytes per card.
  160.     sta    temp
  161. 10$    inx
  162.     lda    1234,y    ;This address gets modified.
  163.     eor    #0    ;Reserve for color modification.
  164.     sta    PreWindow+15,x    ;Bottom card.
  165.     lda    1234,y    ;This address gets modified.
  166.     eor    #0    ;Reserve for color modification.
  167.     sta    PreWindow+7,x    ;Middle card.
  168.     lda    1234,y    ;This address gets modified.
  169.     eor    #0    ;Reserve for color modification.
  170.     sta    PreWindow-1,x    ;Top card.
  171.     dec    temp
  172.     bne    10$
  173. @SetColor
  174. @SetColor
  175.     lda    (r1),y    ;Get colors for bottom card of pane.
  176.     jsr    CalcColor    ;Calculate active fore/background pixels.
  177.     sta    OpenPane+9    ;Opcode for "lda" or "eor".
  178.     stx    OpenPane+10    ;Parameter "$00" or "$ff".
  179.     lda    (r2),y    ;Get colors for middle card of pane.
  180.     jsr    CalcColor    ;Calculate active fore/background pixels.
  181.     sta    OpenPane+16    ;Opcode for "lda" or "eor".
  182.     stx    OpenPane+17    ;Parameter "$00" or "$ff".
  183.     lda    (r3),y    ;Get colors for top card of pane.
  184.     jsr    CalcColor    ;Calculate active fore/background pixels.
  185.     sta    OpenPane+23    ;Opcode for "lda" or "eor".
  186.     stx    OpenPane+24    ;Parameter "$00" or "$ff".
  187. @CalcColo
  188.     sty    temp    ;Temp save current column postion.
  189. SeFi:    ldy    #0    ;SelectFilter 
  190. @Parameter fixed at $7a1d.
  191.     pha        ;Test for a match of the foreground color.
  192.     lsr    a
  193.     lsr    a
  194.     lsr    a
  195.     lsr    a
  196.     cmp    #8    ;Copy MSB of nybble to carry bit.
  197.     and    #7    ;Three LSBs remain.
  198.     lda    ColorFilters,y    ;Get LSByte of foreground filter 
  199. @(at $7a29)
  200.     bcc    10$    ;Branch if that's the one we need.
  201.     lda    ColorFilters+1,y    ;Else get the MSByte filter.
  202. 10$    and    BitTable,x    ;See if this card's color is on the filter.
  203.     beq    20$    ;Branch if not with ACC=0.
  204.     lda    #2    ;Else use 2 as foreground part of index.
  205. 20$    sta    temp+1
  206.     pla        ;Now test for match of background color.
  207.     and    #$0f
  208.     cmp    #8    ;Copy MSB of nybble to carry bit.
  209.     and    #7    ;Three LSBs remain.
  210.     lda    ColorFilters+2,y    ;Get background filter (LSByte).
  211.     bcc    30$    ;Branch if that's the one we need.
  212.     lda    ColorFilters+3,y    ;Else get the MSByte filter.
  213. 30$    ldy    temp+1
  214.     and    BitTable,x    ;See if this card's color is on the filter.
  215.     beq    40$    ;Branch if not.
  216.     iny        ;Else use 1 as background part of index.
  217. 40$    lda    ColorOpTable,y
  218.     ldx    ColorParmTable,y
  219.     ldy    temp    ;Restore Y.
  220. @ColorOpT
  221. able:
  222.     .byte    $a9,$49,$49,$a9    ;"lda", "eor", "eor", "lda".
  223. @ColorPar
  224. mTable:
  225.     .byte    $00,$ff,$00,$ff
  226. @BitTable
  227.     .byte    1,2,4,8,16,32,64,128    ;
  228. @Table starts at $7a62.
  229. @jStartAS
  230.     lda    #$81    ;Set ASCII Flag.
  231.     bne    ContStart
  232. @jStartAS
  233.     lda    #$81    ;Set ASCII Flag.
  234.     bne    ContStart
  235. @jStartPr
  236.     lda    #$40    ;Clear ASCII Flag, but set bit 6 for StopPrint.
  237. ContStart:    sta    PrintMode
  238.     jsr    OpenChannel    ;Test if printer available.
  239.     jsr    CloseChannel
  240.     ldx    STATUS
  241.     beq    PrMo
  242.     rts        ;Exit with "printer inaccessible".
  243. PrMo:    lda    #0    ;PrintMode 
  244. @Parameter stored a$7a7f.
  245.     bpl    ContPrint
  246.     jmp    rStartText
  247. ContPrint:    tsx        ;Save stack pointer for GetBuffer.
  248.     stx    StackPoint
  249.     jsr    GetBuffer    ;Get first buffer and valid pointers.
  250.     bit    PrintMode
  251.     bvc    SetAppEnv        ;Branch on blank page.
  252.     lda    #7    ;Initialize CardFraction for one full card.
  253.     sta    CardFraction
  254.     lda    r8    ;See if color printing is needed.
  255.     bne    DoBorder    ;Branch if so.
  256.     ldy    #80    ;Else fill bottom color buffer with
  257. BlCo:    lda    #$01    ;black on white 
  258. @(at $7a9d).
  259. 110$    sta    (r1),y
  260.     bne    110$
  261. DoBorder:    ldy    #81    ;Now fill middle buffer for
  262. BoCo:    lda    #$11    ;White on white 
  263. @(at $7aa6).
  264.     sta    (r1),y    ;Fill right border color for bottom buffer.
  265. 210$    sta    (r2),y    ;Fill middle color buffer for blank top border.
  266.     bpl    210$
  267.     sta    (r1),y    ;Fill left border color for bottom buffer.
  268.     ldx    #4
  269. 220$    lda    r5-1,x    ;Initialize top two card buffer pointers.
  270.     sta    Pointers+1,x
  271.     bne    220$
  272.     jsr    NextBuffer
  273.     jsr    PrintPage
  274. @SetAppEn
  275.     ldy    #$8f-$22
  276. 10$    lda    (r4),y
  277.     sta    ProgEnd-ProgEnd+$22,y    ;Force ABS,Y mode on page zero.
  278.     bpl    10$
  279.     jmp    CloseChannel
  280. @MoveDown
  281. @MoveDown
  282. @Entry fixed at $7ace
  283.     sta    temp    ;Number of pixels to move down.
  284.     ldx    $dc01    ;Test for mouse button down (to halt print).
  285.     bne    1111$    ;Branch if so.
  286.     lda    CardFraction    ;Else calculate fractional part of card
  287.     sec        ;to see if necessary to return to application.
  288.     sbc    temp
  289.     bcs    999$    ;Branch if not.
  290. 100$    pha
  291.     jsr    NextBuffer    ;Else get another buffer from the application.
  292.     adc    #8
  293.     bcc    100$
  294. 999$    sta    CardFraction
  295. 1111$    jsr    NextBuffer    ;Mouse button down - cancel print. Keep
  296.     beq    1111$    ;returning to app until it notices button.
  297. @NextBuff
  298. er:        ;Update Pointers and get more data.
  299.     ldy    #80    ;Move color buffers up.
  300. 10$    lda    (r2),y    ;Copy middle color buffer
  301.     sta    (r3),y    ;to top color buffer.
  302.     lda    (r1),y    ;Copy bottom color buffer
  303.     sta    (r2),y    ;to middle color buffer.
  304.     bne    10$
  305.     ldx    #1
  306. 100$    ldy    Pointers+4,x    ;Excange top card buffer pointer
  307.     lda    Pointers+2,x    ;with middle card buffer pointer.
  308.     sta    Pointers+4,x
  309.     sta    Pointers+2,x
  310.     bpl    100$
  311.     bit    PrintMode    ;See if the bottom has already been hit.
  312.     bvs    200$    ;Branch if not.
  313.     dec    PrintMode    ;Else keep track of how many times thru.
  314.     rts        ;Go immediately back to driver.
  315. 200$    sta    r1    ;Copy middle pointer to destination
  316.     lda    Pointers+3    ;parameter for MoveData.
  317.     sta    r1+1
  318.     lda    #>640    ;Number of bytes-to-move parameter
  319.     sta    r2+1    ;for MoveData.
  320.     lda    #<640    
  321.     sta    r2
  322.     jsr    SetAppEnv
  323.     jsr    MoveData    ;Source parameter is already in r0.
  324. @GetBuffe
  325.     ldy    #StackSize    ;Restore Application environment.
  326. GB10:    dey
  327.     sta    StackSave,y
  328. StPo:    cpx    #0    ;StackPoint is modified here.
  329.     bcc    GB10
  330.     sty    StackPoint
  331.     ldx    #0    ;Clear error flag.
  332.     rts        ;Back to application.
  333. @jStopPri
  334.     dec    PrintMode    ;$81 for ASCII, $40 for grap
  335. @jStopPri
  336.     dec    PrintMode    ;$81 for ASCII, $40 for graphics.
  337.     bpl    100$    ;Branch if graphics mode.
  338.     jmp    rStopText
  339. 100$    ldy    #80    ;Fill bottom color buffer with
  340.     lda    BorderColor    ;border colors.
  341. 110$    sta    (r1),y
  342.     bne    110$
  343.     beq    SetDriverEnv    ;(Always)
  344. @jPrintBu
  345. ffer:
  346.     lda    r2+1    ;See if Application and driver want color.
  347. CoFl:    and    #0    ;
  348. @Parameter fixed at $7b57.
  349.     sta    r8    ;Let caller know.
  350.     beq    400$    ;Branch if not color.
  351.     ldy    #0    ;Else pass 80 bytes of color.
  352. 300$    lda    (r2),y    ;Get color passed by Application.
  353.     sta    (r1),y    ;Put in bottom color buffer.
  354.     cpy    #80    ;See if near right border.
  355.     bcc    300$    ;Branch if not yet there.
  356. 400$    lda    r0        ;Adjust bottom pointers.
  357.     sta    Pointers
  358.     lda    r0+1
  359.     sta    Pointers+1
  360. SetDriverEnv:
  361.     ldx    #<-12    ;Calculate buffer pointers.
  362. 8$    lda    r1+12,x
  363.     adc    PointOffTable+12-256,x    ;Zero-page mode.
  364.     sta    r2+12,x
  365.     bne    8$
  366.     jsr    OpenChannel
  367.     ldy    #$8f-$22    ;Save a bunch of zero page locations.
  368. 9$    lda    ProgEnd-ProgEnd+$22,y    ;Force ABS,Y on page zero.
  369.     sta    (r4),y
  370.     bpl    9$
  371.     tsx        ;Re-create driver's stack environment.
  372.     ldy    StackPoint
  373. 10$    lda    StackSave,y
  374.     cpy    #StackSize
  375.     bcc    10$
  376.     stx    StackPoint
  377. @PointOff
  378. Table:        ;Three color buffers, zero-page buffer,
  379.     .word    82,82,82,138,640,640    ;two card buffers, general buffer.
  380.     .word    TextAddress    ;
  381. @Fixed at $7ba8.
  382.     .word    XfaceAddress    ;
  383. @Fixed at $7baa.
  384.     .word    ProgEnd    ;
  385. @Fixed at $7bac.
  386. PrintMode        ==PrMo+$7901
  387. StackPoint        ==StPo+$7901
  388. CardFraction    ==CaFr+$7901
  389. ColorFlag        ==CoFl+$7901
  390. SelectFilter        ==SeFi+$7901
  391. BorderColor    ==BoCo+$7901
  392. BlackColor        ==BlCo+$7901    ;
  393. @Custom code starts at $7bae.
  394. HGEOS Printer Driver Shell    
  395. Page: PAGE
  396. Printed on: DATE    At: TIME    File: PrinterShell
  397. HGEOS Printer Driver Shell    
  398. Page: PAGE
  399. Printed on: DATE    At: TIME    File: PrinterShell
  400. -----------------------------------------------------------------------------------------------
  401. th ACC=0
  402.