/****************************************************************************
OS/A65 Version 2.0.0
Multitasking Operating System for 6502 Computers
Generic spooler device
Copyright (C) 1989-1998 Andre Fachat
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
****************************************************************************/
#define ANZINSTR 16
.(
.word spoolend
jmp spoolprg
.asc "spooler",0
.data
anzinstr .byt 0
outstr .byt 0
status .byt 0
byte .byt 0
instr .dsb ANZINSTR
.text
spoolprg cmp #DC_RES
bne sp1
lda #0
sta anzinstr
sta status
clc
rts
sp1 cmp #DC_IRQ
bne sp2
lda status
and #DC_SW_RX
beq spi1
lda status
and #DC_SW_TX
beq spi4
spil lda status
and #1
bne spi2
ldx instr
jsr GETC
bcc spi2b
cmp #E_EOF
bne spi4
ldx instr
lda #SC_NUL
jsr STRCMD
dec anzinstr
beq rxoff
ldx #0
spi3 lda instr+1,x
sta instr,x
cpx anzinstr
bcs sp4
inx
bne spi3
spi2b sta byte
lda #1
ora status
sta status
spi2 lda byte
ldx outstr
jsr PUTC
bcs spi5
lda status
and #%11111110
sta status
jmp spil
spi4 ldx outstr
lda #SC_STAT
jsr STRCMD
spi5 cmp #E_NUL
beq rxoff
spi1 clc
lda #E_NOIRQ
rts
sp2 cmp #DC_RX_OFF
beq rxoff
cmp #DC_TX_OFF
bne sp3
rxoff lda status
and #DC_SW_RX
beq spe4
ldx outstr
lda #SC_EOF
jsr STRCMD
spe4 lda status
and #DC_SW_TX
beq spe1
ldx #0
spe2 cpx anzinstr
bcs spe1
lda #SC_NUL
jsr STRCMD
inx
bne spe2
spe1 lda #0
sta anzinstr
sta status
beq ok
sp3 cmp #DC_RX_ON
bne sp4
lda #DC_SW_RX
bne setst
sp4 cmp #DC_TX_ON
bne sp5
lda #DC_SW_TX
setst ora status
sta status
ok lda #0
.byt $2c
spdevon lda #E_DON
.byt $2c
sp7 lda #E_NOTIMP
cmp #1
rts
sp5 cmp #DC_GS
bne sp6
lda status
ldx anzinstr
cpx #ANZINSTR
bcs spdevon
tya
sta instr,x
inc anzinstr
jmp ok
sp6 cmp #DC_PS
bne sp7
lda status
and #DC_SW_RX
bne spdevon
sty outstr
jmp ok
#undef ANZINSTR
spoolend .)