home *** CD-ROM | disk | FTP | other *** search
- ;put.asm
- ;============================================================
- ; user installable command: put filename startline endline
- ;============================================================
-
- z61 = $0061
- int04 = $1704
- int09 = $1709
- int0e = $170e
- int11 = $1711
- int0b = $170b
- int0d = $170d
- int13 = $1713
- sw1 = $1bfc
- chrout = $ffd2
- chkout = $ffc9
- clrchn = $ffcc
- poker = $0016
- fndlin = $5064
- stop = $ffe1
- primm = $ff7d
-
- star = $0b00
- .wor star
- * = star
-
- jmp put
- dw Date
-
- put lda #0
- sta $ff00
- ldx #1 ; put only?
- jsr int04
- bcc put00
- jsr primm
- .asc 13,"Syntax: put[/a] filename start end",13,0
- jmp int0e
-
- put00 ldx #3 ; get endline
- jsr int11 ; returns value of %3 in .x lo .a hi
- bcc put1 ; it was there, use it
- lda #$ff ; otherwise use $ffff
- tax
- put1 stx endlin
- sta endlin+1
- ldx #2
- jsr int11 ; get start line
- bcc put2 ; it was there...use it
- lda #0 ; otherwise use zero
- tax
- put2 stx poker
- sta poker+1
- jsr fndlin ; find 1st line
- ldx #1 ; first scratch it
- jsr int13
- ldx #1 ; open %1 for write
- lda #"s" ; as a seq file
- jsr int09
- bcc put0 ; open went fine
- jsr int0d ; print disk status
- jmp int0e ; and..abort
-
- putxx jmp putx
-
- put0 lda #0 ; bank 15
- sta $ff00
- jsr chkout ; setup for output
- bcs putxx ; disk error
- put3 ldy #0
- sta $ff01 ; get from bank0
- lda (z61),y ; check if all done (link=0)
- iny
- ora (z61),y
- beq putxx ; end of program...quit
- jsr putlin ; send line to output
- ldy #3 ; check if line# in range
- lda (z61),y ; 1st check high byte
- cmp endlin+1
- bcc put4 ; less...next line
- beq put5 ; equal..check low byte too
- bcs putxx ; greater...quit
-
- put5 dey ; check low byte
- lda (z61),y
- cmp endlin
- bcc put4 ; less..next line
- bcs putxx ; past end...done
-
- put4 ldy #0 ; next line
- lda (z61),y ; get address of next line
- pha
- iny
- lda (z61),y
- sta z61+1
- pla
- sta z61
- jmp put3 ; and repeat
-
- putlin ldy #4 ; offset to data
- put7 sta $ff01
- lda (z61),y ; get from bank0
- iny
- ldx #0
- stx $ff00 ; bank 15 for chrout
- cmp #0 ; end of line?
- beq put6 ; yes..do a cr
- jsr cvt
- jsr chrout ; otherwise spit it out
- bcs putx ; error...abort
- bcc put7 ; ok..next char
-
- put6 lda #13 ; done line..cr and return
- jsr chrout
- lda sw1 ; ascii convert?
- cmp #"a" ; ascii convert?
- bne put66
- lda #10 ; ok. add line feed
- jsr chrout
- put66 jsr stop
- beq putxy
- sta $ff01 ; and reset bank0 for main routine
- rts
-
- putxy pla
- pla
- putx lda #0
- sta $ff00
- jsr clrchn
- jsr int0b ; check ds$ and abort if error
- puty jmp int0e ; close all files and back to BASIC
-
- endlin .wor 0
-
-
- ;-------------------------------------------
- ; Convert PETSCII to ASCII if /a is present
- ;-------------------------------------------
-
- cvt pha
- lda sw1
- cmp #"a"
- beq p2a
- pla
- rts
-
- p2a pla
- cmp #"a"
- bcc p2ax
- cmp #$5b
- bcs p2a2
- ora #$20
- bne p2ax
-
- p2a2 cmp #$c1
- bcc p2ax
- cmp #$db
- bcs p2ax
- and #$7f
- p2ax rts
-
- .end
-