8-Bit Software Online Conversion
:0.S.PSave - Listing
10REM P(artial)SAVE utility V.1.2
20REM by M.Bobrowski 8'90
30:
40pptr=&A8:ptr=&70:lineno=&72:number=
&74:temp=&76:crflag=&78:endflag=&79
50osargs=&FFDA:osfile=&FFDD:osword=&F
FF1:osbyte=&FFF4:osasci=&FFE3:osnewl=&FF
E7:osrdch=&FFE0
60:
70FOR pass=0 TO 3 STEP 3
80P%=&900
90[OPT pass
100.read`command
110LDA #1:LDX #pptr:LDY #0:JSR osargs
120LDA #5:LDX #pptr:LDY #0:JSR osword
130LDA pptr+4:CMP #13:BNE main
140.syntax
150BRK:EQUB 128:EQUS "Syntax: *PSAVE <
fsp>,<lineno>,(<lineno>)":EQUB0
160:
170.main
180JSR read`filename:BNE nosave
190JSR set`fileblock
200LDA #1:STA endflag:JSR read`param
210LDA &18:STA ptr+1:LDA #0:STA ptr
220JSR read`program
230LDA crflag:BEQ second`param
240½set TOP as endaddress
250LDA &12:STA endaddr:LDA &13:STA end
addr+1
260BNE save
270.second`param
280DEC endflag
290JSR read`param:LDA crflag:BEQ synta
x
300JSR read`program
310.save
320LDA #0:LDX #fileblock MOD 256:LDY #
fileblock DIV 256:JSR osfile
330LDA endflag:BEQ exit
340.nosave
350RTS
360.exit
370LDA temp:LDY #1:STA (ptr),Y
380RTS
390:
400.read`filename
410LDY #0
420.rfn2
430LDA (pptr),Y:CMP #13:BEQ syntax
440CMP #ASC",":BEQ rfn3:CMP #32:BEQ rf
n3
450STA filename,Y:INY:BNE rfn2
460.rfn3
470TYA:ADC pptr:STA pptr
480LDA #13:STA filename,Y
490½ check filename
500JSR zero
510LDX #fileblock MOD 256:LDY #fileblo
ck DIV 256
520LDA #5:JSR osfile:CMP #1:BNE notpre
sent
530JSR printname:JSR message
540EQUS " file exists on disc."+CHR$13
+"Overwrite it (Y/N)?"+CHR$0
550.getyn
560LDA #15:LDX #1:JSR osbyte:JSR osrdc
h
570CMP #27:BEQ escape
580AND #&5F:CMP #ASC("Y"):BEQ yn2
590CMP #ASC"N":BNE getyn
600.yn2
610TAY:JSR osasci:JSR osnewl:BNE erfn
620.notpresent
630LDY #ASC"Y"
640.erfn
650CPY #ASC"Y":RTS
660:
670.escape
680BRK:EQUB 17:EQUS "Escape":EQUB 0
690:
700.set`fileblock
710JSR zero:LDA #&82:JSR osbyte
720STX loadaddr+2:STX execaddr+2:STX s
tartaddr+2:STX endaddr+2
730STY loadaddr+3:STY execaddr+3:STY s
tartaddr+3:STY endaddr+3
740½read OSHWM
750CLC:ADC #1:JSR osbyte
760STX loadaddr:STY loadaddr+1
770½set execaddr
780LDA #&23:STA execaddr:LDA #&80:STA
execaddr+1
790RTS
800:
810.read`param
820LDA #0:STA number:STA number+1:TAY
830.getchar
840LDA (pptr),Y
850CMP #13:BEQ gch2
860CMP #ASC",":BEQ gch2
870CMP #32:BEQ gch2
880JSR mult`ten
890LDA (pptr),Y
900SEC:SBC #ASC"0"
910CMP #10:BCS badnum
920JSR inc`num
930CPY #6:BNE getchar
940BEQ toobig
950.gch2
960STA temp
970LDA number+1:BMI toobig
980LDA temp:CMP #13:BNE update
990LDA #&FF:STA crflag:RTS
1000.update
1010TYA:ADC pptr:STA pptr
1020LDA #0:STA crflag:RTS
1030:
1040.badnum
1050BRK:EQUB 255:EQUS"Bad number"
1060.toobig
1070BRK:EQUB 20:EQUS"Too big":BRK
1080:
1090.inc`num
1100CLC:ADC number:STA number
1110LDA number+1:ADC #0:STA number+1
1120INY:RTS
1130.mult`ten
1140JSR mult`two
1150LDA number+1:PHA:LDA number:PHA
1160JSR mult`two:JSR mult`two
1170PLA:CLC:ADC number:STA number
1180PLA:ADC number+1:STA number+1
1190RTS
1200.mult`two
1210ASL number:ROL number+1
1220RTS
1230:
1240.read`program
1250LDY #0:LDA (ptr),Y
1260CMP #&0D:BNE badprog
1270INY:LDA (ptr),Y:STA lineno+1
1280CMP #&FF:BEQ notfound
1290INY:LDA (ptr),Y:STA lineno
1300½compare
1310LDA lineno+1:CMP number+1:BCC getne
xtline
1320BNE notfound
1330LDA lineno:CMP number:BCC getnextli
ne
1340BNE notfound
1350LDA endflag:BEQ set`endpoint
1360LDA ptr:STA startaddr:LDA ptr+1:STA
startaddr+1
1370RTS
1380.set`endpoint
1390INY:LDA (ptr),Y
1400CLC:ADC ptr:STA ptr:BCC sep2
1410INC ptr+1
1420.sep2
1430LDY #1:LDA (ptr),Y:STA temp
1440LDA #&FF:STA (ptr),Y
1450CLC:LDA ptr:ADC #2:STA endaddr
1460LDA ptr+1:ADC #0:STA endaddr+1
1470RTS
1480:
1490.getnextline
1500INY:LDA (ptr),Y
1510CLC:ADC ptr:STA ptr:BCC continue
1520INC ptr+1
1530.continue
1540JMP read`program
1550:
1560.badprog
1570BRK:EQUB 0:EQUS"Bad program"
1580.notfound
1590BRK:EQUB 41:EQUS"No such line":BRK
1600:
1610.printname
1620LDX #0
1630.pfn1
1640LDA filename,X:CMP #13:BEQ pnf2
1650JSR osasci:INX:BNE pfn1
1660.pnf2
1670RTS
1680:
1690.message
1700PLA:STA temp:PLA:STA temp+1
1710LDY #1
1720.mes1
1730LDA (temp),Y:BEQ mes2
1740JSR osasci:INY:BNE mes1
1750.mes2
1760INC temp:BNE mes3:INC temp+1
1770.mes3
1780DEY:BPL mes2
1790JMP (temp)
1800:
1810.zero
1820LDA #0:LDX #15
1830.zero2
1840STA fileblock+2,X:DEX:BPL zero2
1850RTS
1860:
1870.fileblock
1880EQUW filename
1890.loadaddr:EQUD 0
1900.execaddr:EQUD 0
1910.startaddr:EQUD 0
1920.endaddr:EQUD 0
1930.filename
1940EQUS STRING$(20,CHR$0)
1950:]
1960NEXT
1970:
1980PRINT'"To save object code press CO
PY ";:REPEAT UNTIL INKEY-106:PRINT
1990OSCLI"SAVE PSAVE 900 "+STR$÷P%
2000END