10
20
30 :
40 OSRDRM=&FFB9:OSASCI=&FFE3:OSNEWL=&FFE7:OSWRCH=&FFEE
50 DIM mcode% &1000
60 ver$="1.20":date$="(15 Mar 1989)"
70 :
80 len%=0:FOR pass%=0 TO 3
90 P%=&8100-128*(pass%AND2)
100 O%=mcode%+len%*(pass%AND2)DIV2
110 opt%=VALMID$("4647",pass%+1,1)
120 [OPT opt%
130 .Start
140 BRK:EQUW RelocTable
150 JMP Serv
160 EQUB &82:EQUB Copy-Start
170 EQUB &00:EQUS "Print FS Calls"
180 EQUB &00:EQUS ver$+" "+date$
190 .Copy
200 EQUB &00:EQUS "(C)JGH":EQUB &00
210 :
220 .Serv
230 CMP #&0F:BNE ServExit
240 PHA:LDY #0
250 .Serv0Flp
260 LDA FSCallBase+000,Y:STA &900,Y
270 LDA FSCallBase+256,Y:STA &A00,Y
280 INY:BNE Serv0Flp
290 JSR &900
300 PLA
310 .ServExit
320 RTS
330 :
340 .FSCallBase
350 ]
360 P%=&900
370 [OPT opt%
380 .FSCallStart
390 LDY #13
400 .InitLp
410 LDA &212,Y:LDX Vectors,Y
420 STA Vectors,Y:TXA:STA &212,Y
430 DEY:BPL InitLp
440 RTS
450 :
460 .Vectors
470 EQUW File:EQUW Args:EQUW BGet
480 EQUW BPut:EQUW GBPB:EQUW Find
490 EQUW Fsc
500 :
510 .Calls
520 EQUS "FILEARGSBGETBPUTGBPBFINDFSCV"
530 :
540 .File
550 JSR Store1:LDX #0:JSR PrCallAXY
560 JSR PrWord2
570 LDY #0:LDA (&70),Y:STA &76:INY
580 LDA (&70),Y:STA &77:DEY
590 JSR PrName
600 JSR Load1:JSR CallFile:JSR Store2
610 JSR PrWord2:JMP Load2
620 .CallFile
630 JMP (Vectors+0)
640 :
650 .Args
660 JSR Store1:LDX #4:JSR PrCallAXY
670 JSR PrZPage
680 JSR Load1:JSR CallArgs:JSR Store2
690 JSR PrZPage:JMP Load2
700 .CallArgs
710 JMP (Vectors+2)
720 :
730 .BGet
740 JMP (Vectors+4)
750 :
760 .BPut
770 JMP (Vectors+6)
780 :
790 .GBPB
800 JSR Store1:LDX #16:JSR PrCallAXY
810 JSR PrByte:JSR Pr3Words
820 JSR Load1:JSR CallGBPB:JSR Store2
830 JSR PrByte:JSR Pr3Words:JMP Load2
840 .CallGBPB
850 JMP (Vectors+8)
860 :
870 .Find
880 JSR Store1:LDX #20:JSR PrCallAXY
890 LDA &72:BEQ Close
900 JSR PrName70
910 .Close
920 JSR Load1:JSR CallFind:JSR Store2
930 JMP Load2
940 .CallFind
950 JMP (Vectors+10)
960 :
970 .Fsc
980 JSR Store1:LDX #24:JSR PrCallAXY
990 LDA &72:BEQ FscNoName:CMP #1:BEQ FscNoName
1000 CMP #6:BEQ FscNoName:CMP #7:BEQ FscNoName
1010 JSR PrName70
1020 .FscNoName
1030 JSR Load1:JSR CallFscv:JSR Store2:JMP Load2
1040 .CallFscv
1050 JMP (Vectors+12)
1060 :
1070 .PrSpace
1080 LDA #32:JMP OSWRCH
1090 :
1100 .PrCarry
1110 PHP:PHA:JSR PrSpace
1120 LDA #ASC"C":JSR OSWRCH
1130 PLA:PLP:PHP:PHA:BCS PrCarrySet
1140 LDA #ASC"C":BNE PrCarryEnd
1150 .PrCarrySet
1160 LDA #ASC"S"
1170 .PrCarryEnd
1180 JSR OSWRCH:JSR PrSpace
1190 PLA:PLP:RTS
1200 :
1210 .PrCallAXY
1220 LDY #4
1230 .PrCallLp
1240 LDA Calls,X:JSR OSWRCH
1250 INX:DEY:BNE PrCallLp
1260 BEQ PrAXY
1270 :
1280 .Store2
1290 JSR Store2b
1300 :
1310 .PrCarryAXY
1320 JSR PrCarry
1330 :
1340 .PrAXY
1350 JSR PrSpace
1360 LDA #ASC"A":JSR OSWRCH:JSR PrEqu
1370 LDA &72:JSR PrHex
1380 :
1390 .PrXY
1400 LDX #1:.PrXYLp
1410 JSR PrSpace
1420 TXA:ORA #ASC"X":JSR OSWRCH
1430 JSR PrEqu:LDA &70,X:JSR PrHex
1440 DEX:BPL PrXYLp
1450 .PrXYEnd
1460 RTS
1470 :
1480 .PrEqu
1490 LDA #ASC"=":JMP OSWRCH
1500 :
1510 .PrZPage
1520 JSR PrSpace:LDX &74
1530 LDA 3,X:JSR PrHex:LDA 2,X:JSR PrHex
1540 LDA 1,X:JSR PrHex:LDA 0,X:JMP PrHex
1550 :
1560 .PrName70
1570 LDA &70:STA &76:LDA &71:STA &77
1580 .PrName
1590 JSR PrSpace:.PrNameLp
1600 LDA (&76),Y:CMP #ASC" "
1610 BCC PrXYEnd
1620 JSR OSWRCH:INY:BNE PrNameLp
1630 :
1640 .Store1
1650 STX &74:STY &75
1660 .Store2b
1670 STX &70:STY &71:STA &72
1680 PHP:PLA:STA &73:RTS
1690 :
1700 .PrHex
1710 PHA:LSR A:LSR A:LSR A:LSR A
1720 JSR PrNyb:PLA
1730 .PrNyb
1740 AND #15:CMP #10:BCC PrDig
1750 ADC #6:.PrDig
1760 ADC #48:JMP OSWRCH
1770 :
1780 .PrByte
1790 JSR PrSpace:LDY #0
1800 LDA (&70),Y:INY:JMP PrHex
1810 :
1820 .PrWord2
1830 LDY #2:JSR PrWord
1840 .Pr3Words
1850 JSR PrWord:JSR PrWord
1860 .PrWord
1870 JSR PrSpace:LDX #4:INY:INY:INY
1880 .PrWordLp
1890 LDA (&74),Y:DEY:JSR PrHex
1900 DEX:BNE PrWordLp
1910 INY:INY:INY:INY:INY
1920 RTS
1930 :
1940 .Load1
1950 .Load2
1960 JSR OSNEWL
1970 LDA &73:PHA:LDA &72
1980 LDX &70:LDY &71:PLP
1990 RTS
2000 :
2010 .FSCallEnd
2020 ]
2030 P%=FSCallEnd-FSCallStart+FSCallBase
2040 [OPT opt%
2050 :
2060 .RelocTable
2070 ]:len%=RelocTable-Start:NEXT
2080 PROCMakeRelocTable
2090 PRINT"*SAVE FSCallROM ";~mcode%+len%;" ";~O%;" 0 FFFBBC00"
2100 END
2110 :
2120 DEFPROCMakeRelocTable
2130 base80%=mcode%+len%:base81%=mcode%:byte%=0:count%=0:off%=0:REPEAT
2140 byte80%=base80%?off%:byte81%=base81%?off%:IF off%>=len%:byte80%=&80:byte81%=&80
2150 IF ((byte81%-byte80%) AND &FE)<>0 THEN PRINT "ERROR: Offset by more than one page at &";~&8000+off%
2160 IF (byte80% AND &C0)=&80:byte%=byte%DIV2+128*(byte81%-byte80%):count%=count%+1
2170 IF count%=8:?O%=byte%:O%=O%+1:byte%=0:count%=0
2180 off%=off%+1:UNTILoff%>=len% AND count%=0
2190 ENDPROC