home *** CD-ROM | disk | FTP | other *** search
- ; get.asm
- ;---------------------------------------------------------
- ; CS-DOS Command: get filename,linenumber
- ;---------------------------------------------------------
-
- z61 = $0061 ; pointer into RAM0
- status = $0090 ; i/o status byte
- poker = $0016 ; line number
- txttab = $002d ; start of text
- txttop = $1210 ; top of basic text
- max0 = $1212 ; top of RAM for RAM0
- int08 = $1708 ; open file
- int0d = $170d ; print ds$
- int0e = $170e ; terminate program
- int11 = $1711 ; evaluate constant
- int3f = $173f ; Open %x for burst read
- sw1 = $1bfc ; command line switch
- lnkprg = $4f4f ; link program lines
- stop = $ffe1
-
- star = $0b00 ; run on 40 column screen
- .wor star ; shell put us in bank15
- * = star
-
- jmp get
- dw Date
-
- get ldx #1 ; first parameter is filename
- jsr int3f ; open it for burst read (any filetype will do)
- bcc get0 ; open went ok
- lda #3 ; Error, just quit
- jmp int0e
-
- get0 ldx #2 ; line # is %2
- jsr int11 ; int11 puts value of %x in poker
- jsr fndlin ; get start of line into z61
- bcs ed33 ; Line number is very high...append
- lda poker ; line specified?
- ora poker+1
- php
- ldy #2 ; make it the current line number
- lda (z61),y
- sta poker
- iny
- lda (z61),y
- sta poker+1
- plp
- bne ed33 ; line was given...use it
- lda #<1000 ; else 1000 is 1st line
- sta poker
- lda #>1000
- sta poker+1
- ed33 lda #0
- sta $ff00
- ed3 sec ; don't input past end of available RAM
- lda max0 ; top of RAM0
- sbc z61 ; minus pointer
- lda max0+1
- sbc z61+1
- bcc edx ; past end...abort
- cmp #2 ; leave at least one page free
- bcc edx
- ldy #0 ; stash line link
- lda #1
- jsr stsh
- jsr stsh
- lda poker
- jsr stsh
- lda poker+1
- ed0 jsr stsh
- ed6 jsr $1779 ; chrin or burst fetch
- jsr cvt ; convert to petscii (maybe)
- bit status
- bmi eol
- bvs eol
- cmp #13
- beq eeol
- cmp #10 ; skip line feeds
- beq ed6
- cpy #$9f ; max of 159 characters/line
- bcc ed0
- jsr stsh
- eol cmp #13
- beq eeol
- jsr stsh
- eeol cpy #4
- bne eeeol
- lda #" "
- jsr stsh
- eeeol lda #0
- jsr stsh
- clc
- tya
- adc z61
- sta z61
- bcc ed7
- inc z61+1
- ed7 clc
- lda poker
- adc #10
- sta poker
- bcc ed1
- inc poker+1
- ed1 bit status
- bvs edx
- bmi edx
- jsr stop
- bne ed3
- edx lda #0
- tay
- jsr stsh
- jsr stsh
- clc
- lda z61
- adc #2
- sta txttop
- lda z61+1
- adc #0
- sta txttop+1
- rn1010 jsr lnkprg ; let BASIC establish new line links
- lda #0
- jmp int0e ; close + quit
-
- stsh sta $ff01 ; put byte in bank0
- pha ; save it
- sta (z61),y ; store it
- iny
- lda #0 ; and back to bank 15
- sta $ff00
- pla
- rts
-
- ;---------------------------------------------------------------
- ; Picked this routine out of ROM...it runs faster in Common RAM
- ;---------------------------------------------------------------
-
- fndlin lda txttab
- ldx txttab+1
- sta $ff01
- fnd0 ldy #1
- sta z61
- stx z61+1
- lda (z61),y
- beq eop ; end of program
- iny
- iny
- lda poker+1
- cmp (z61),y
- bcc fndx
- beq fnd1
- dey
- bne fnd2
- fnd1 lda poker
- dey
- cmp (z61),y
- bcc fndx
- beq fndx
- fnd2 ldy #2
- lda (z61),y
- sta oldlin
- iny
- lda (z61),y
- sta oldlin+1
- dey
- dey
- lda (z61),y
- tax
- dey
- lda (z61),y
- bcs fnd0
- fndx clc
- rts
-
- eop ldy #0
- lda (txttab),y
- iny
- ora (txttab),y
- bne eop0
- sta poker
- sta poker+1
- beq fndx
-
- eop0 clc
- lda oldlin
- adc #10
- sta poker
- lda oldlin+1
- adc #0
- sta poker+1
- sec
- rts
-
- ;---------------------------
- ; ascii conversion routines
- ;---------------------------
-
- cvt pha ; Check for /a switch
- lda sw1
- cmp #"a"
- beq a2p
- pla ; Not there, don't convert
- rts
-
- a2p pla
- cmp #"a"
- bcc a2px
- cmp #$5b
- bcs a2p2
- ora #$80
- bne a2px
-
- a2p2 cmp #$61
- bcc a2px
- cmp #$7b
- bcs a2px
- and #$df
- a2px rts
-
- oldlin *=*+2
-
- .end
-