10
20
30
40
50
60
70
80
90
100
110 :
120 OSASCI=&FFE3:OSWRCH=&FFEE:OSNEWL=&FFE7:OSBYTE=&FFF4
130 DIM mcode% &300:load%=&FFFF0900
140 link=&A8:next=&AA:num=&AC
150 :
160 FOR P=0 TO 1
170 P%=load%:O%=mcode%
180 [OPT P*2+4
190 .TitleString
200 EQUS "No. Position Name Version":EQUB 13
210 :
220 .exec%
230 LDA #0:LDX #1:JSR OSBYTE :\ Find machine type
240 TXA:BNE ListStart :\ If not Electron, X<>&00
250 DEC ROMTABLE+1 :\ Change to Electron ROMTABLE
260 .ListStart
270 LDX #0
280 .ListTitleLp
290 LDA TitleString,X:JSR OSASCI:INX:CMP #13
300 BNE ListTitleLp
310 LDA #1:STA num :\ Start with module 1
320 LDA &F4:PHA:LDX #15 :\ Start with ROM 15
330 :
340 .ScanRomLoop
350 JSR SelectRom
360 .ROMTABLE
370 LDA &2A1,X:AND #&C0:BNE P%+5:JMP NextRom :\ Nothing in this slot
380 LDA #&00:STA link+0:LDA #&80:STA link+1 :\ Point to start of ROM
390 :
400 \ Print ROM/Module header
410 .DoRomHeader
420 :
430 \ Print BCD module number
440 JSR PrSpace :\ No hundreds
450 LDA num:CMP #10:BCS PrTens
460 JSR PrSpace:BNE PrUnits :\ No tens
470 .PrTens
480 JSR PrTopNyb :\ Print tens
490 .PrUnits
500 LDA num:JSR PrBotNyb :\ Print units
510 CMP #ASC"9":LDA #1:BCC P%+4:LDA #6 :\ Increment num
520 ADC num:STA num:JSR PrSpace :\ &x9 goes to &y0
530 :
540 \ Convert Module header base to ROM header base
550 LDA link+0:ORA link+1
560 CMP #&80:BEQ PrintAddr :\ At start of ROM, use as base address
570 LDY #3 :\ Offset to Service entry
580 .FindHeaderLp
590 LDA (link),Y:CMP #&4C:BEQ PrintAddr :\ JMP Service found
600 INC link+0:BNE FindHeaderLp
610 INC link+1:BNE FindHeaderLp :\ Look for JMP Service
620 :
630 \ Print module address in hex
640 .PrintAddr
650 LDA #&FF:JSR PrHex:LDA &F4:ORA #&F0:JSR PrHex
660 LDA link+1:JSR PrHex:LDA link+0:JSR PrHex:JSR PrSpace
670 :
680 \ Print ROM/Module title
690 LDX #0:LDY #9:JSR PrOffsetString
700 :
710 \ Align for version string
720 .VersionAlign
730 JSR PrSpace:CPX #21:BCC VersionAlign
740 :
750 \ Look for version string
760 TYA:LDY #7:CMP (link),Y:BNE VersionString
770 :
780 \ No version string, use binary version number
790 \LDY #8:\LDA (link),Y:\TAX :\ Get binary version
800 \BPL NotDNFS:\LDY #16:\LDA (link),Y :\ Bugfix for DNFS
810 \BNE NotDNFS:\TXA:\AND #&7F:\TAX :\ Drop b7 for DNFS
820 LDY #8:LDA (link),Y:AND #&7F:TAX :\ Get binary version
830 .NotDNFS
840 TXA:CPX #10:BCS Binary10Plus :\ >&09, print as x.y0
850 CPX #3:BCS NotBasic:LDY #6 :\ Bugfix for BASIC 1 & 2
860 LDA (link),Y:CMP #&60:BNE NotBasic:INX :\ Basic 0 & 1 becomes 1 & 2
870 .NotBasic
880 TXA:ASL A:ASL A:ASL A:ASL A :\ <&0A, print as x.00
890 .Binary10Plus
900 PHA:JSR PrTopNyb:LDA #ASC".":JSR OSWRCH
910 PLA:JSR PrBotNyb:LDX #3+21 :\ 3 chars printed
920 LDA #0:BEQ ZeroAlign :\ Pad with zeros
930 :
940 \ Version string present, tidy it and print it
950 .VersionString
960 TAY:INY :\ Point to start of version string
970 LDA (link),Y:BNE VersionStringHere :\ Version String<>""
980 :
990 \ Version string is "" (ie &00), scan back for version in title
1000 .VersionLookBack
1010 DEY:LDA (link),Y:CMP #ASC" " :\ Look for space before version string
1020 BNE VersionLookBack:INY
1030 :
1040 \ We now point to a version string
1050 .VersionStringHere
1060 INY:INY
1070 LDA (link),Y:DEY
1080 CMP #ASC".":BEQ VersionDotOk :\ xx.xx -> x.xx
1090 LDA (link),Y:DEY
1100 CMP #ASC".":BEQ VersionDotOk :\ x.xx -> x.xx
1110 LDA (link),Y:JSR PrChar:INY :\ xxx -> x.xx
1120 LDA #ASC".":JSR PrChar
1130 .VersionDotOk
1140 JSR PrOffsetString :\ Version & Date
1150 :
1160 \ Pad version number with zeros
1170 .ZeroAlign
1180 LDA #ASC"0"
1190 CPX #25:BCS CopyrightAlign
1200 JSR PrChar:BNE ZeroAlign
1210 :
1220 \ Pad out to copyright message
1230 .CopyrightAlign
1240 JSR PrSpace:CPX #40:BCC CopyrightAlign
1250 :
1260 \ Print copyright message
1270 LDY #7:LDA (link),Y:TAY :\ Get pointer to (C)
1280 INY:JSR PrOffsetString :\ Print (C) string
1290 .PrintNextLine
1300 JSR OSNEWL
1310 :
1320 \ Look for link to another module
1330 \ -2 JSR
1340 \ -1 prev.lo
1350 \ link+0 -> JMP JSR prev.hi CMP
1360 \ 1 lang.lo prev.lo LDX &01
1370 \ 2 lang.hi prev.hi &F4 BEQ
1380 \ 3 JMP JMP JMP dist
1390 \ 4 next.lo next.lo next.lo RTS
1400 \ 5 next.hi next.hi next.hi NOP
1410 \ 6 type type type type
1420 \ 7 copy copy copy copy
1430 \
1440 \ next+0 -> JSR JSR
1450 \ 1 prev.lo prev.lo
1460 \ 2 prev.hi prev.hi
1470 \ 3 JMP LDX
1480 \ 4 serv.lo &F4
1490 \ 5 serv.hi JMP
1500 \ 6 serv.lo
1510 \ 7 serv.hi
1520 \
1530 LDY #4:LDA (link),Y:STA next+0 :\ next=>next module
1540 INY :LDA (link),Y:STA next+1
1550 LDY #0:LDA (next),Y :\ Check for 'JSR prev'
1560 CMP #&20:BNE NextRom:LDY #3 :\ No prev link, go to next ROM
1570 .ModuleLink
1580 LDA (next),Y:CMP #&4C:BEQ NextModule :\ 'JMP serv', module header
1590 INY:INY:CMP #&A6:BEQ ModuleLink :\ Step past LDX &F4
1600 :
1610 .NextRom :\ No module header, go to next ROM
1620 LDX &F4:DEX:BMI P%+5:JMP ScanRomLoop :\ Loop until ROM 0 done
1630 PLA:TAX :\ Restore original ROM
1640 .SelectRom
1650 STX &F4:JMP &FFB9 :\ Select ROM
1660 :
1670 .NextModule
1680 LDA next+0:STA link+0 :\ Point to this header
1690 LDA next+1:STA link+1
1700 JMP DoRomHeader :\ Jump back to print it
1710 :
1720 .PrTopNyb
1730 LSR A:LSR A:LSR A:LSR A:BPL PrBotNyb
1740 .PrHex
1750 PHA:JSR PrTopNyb:PLA
1760 .PrBotNyb
1770 AND #15:CMP #10:BCC PrDigit
1780 ADC #6:.PrDigit
1790 ADC #48:JMP OSWRCH
1800 :
1810 .PrSpace
1820 LDA #ASC" "
1830 .PrChar
1840 INX:JMP OSWRCH
1850 :
1860 .PrOffsetString
1870 LDA (link),Y:CMP #ASC" ":BCC PrOffsetStringEnd
1880 JSR PrChar:INY:BNE PrOffsetString
1890 .PrOffsetStringEnd
1900 RTS
1910 :
1920 EQUS "v0.16"
1930 ]NEXT
1940 PRINT" *Save SMList ";~mcode%;" ";~O%;" ";~exec%OR&FFFF0000;" ";~load%