
new
rem print cartridge to intel hex output
rem with appended checksum line


1 goto80
rem ======all printing=========
rem print or lprint
11 lprint:return
rem print or lprint colon to start line
12 lprint":";:return
rem print or lprint a$
14 lprinta$;:return
rem print or lprint start/len
16 lprint"-start ";b;" len ";l;"."
17 return
rem print or lprint checksums
18 lprint"-cksum ";k3;" ";k4;" ";k7;" ";k8;"."
19 return
rem ======all printing end block=====

rem print byte's hex and add sum to line sum byte
rem input is x
21 i=int(x/16):a$=mid$(h$,i+1,1):gosub14
22 i=(x and15):a$=mid$(h$,i+1,1):gosub14
23 kl=kl+x:return
rem calculate and print line sum byte and crlf
26 x=255and(256-(kl and255))
27 gosub21:gosub11:return


rem clear line checksum
33 kl=0:return


rem clear main checksums and main entry point
80 f3=1:f7=1:k3=0:k4=0:k7=0:k8=0
90 h$="0123456789ABCDEF":print chr$(11)
150 gosub 6000

rem menu input
180 print"1. Print BASIC ROM $0000-$1FFF"
190 print"2. Print Extended ROM $2000-$2FFF"
200 print"3. Print Game ROM $C000-$FFFF"
210 print"x. Exit this program now"
220 print:print"pick 1,2,3, or x";:a$=inkey$
230 a$=inkey$:if a$="x"then end
240 if a$="1"thenb=0:l=32:goto400
250 if a$="2"thenb=32:l=16:goto400
260 if a$="3"thenb=192:l=64:goto400
270 goto230

rem user has chosen
400 print a$:forj=1to9:gosub11:next

rem now loop and print lines of data
500 poke13325,0:poke13326,b
510 for j=0to l-1
520 for k=0to31
530 gosub33:gosub12:x=8:gosub21
rem output address in h/l order
540 x=peek(13326):gosub21:x=peek(13325):gosub21
rem type 0, ordinary data
545 x=0:gosub21
rem byte loop
550 for m=0to7:x=usr(0):x=peek(13327)
560 k3=k3+f3*(x+2):f3=f3+1:if f3>3then f3=1
570 if k3>65535then k3=k3-65536:k4=k4+1
580 k7=k7+f7*(x+1):f7=f7+1:if f7>7then f7=1
590 if k7>65535then k7=k7-65536:k8=k8+1
650 gosub21
660 next: rem m
rem print single line checksum
670 gosub26
680 next: rem k
790 next: rem j

rem print terminator line here
800 gosub33:gosub12:x=0:gosub21
810 x=0:gosub21:x=0:gosub21
820 x=1:gosub21
830 gosub26
835 gosub16:gosub18
840 forj=1to9:gosub11:next
900 print:end


rem subroutine for poking the ml
6000 poke14340,1:poke14341,52:gosub6100:j=usr(0)
6010 gosub6100:return

6100 j=13313
6110 read a$:if a$="z"then return
6120 c=asc(mid$(a$,1,1)):d=c and15:if c>64then d=9+(c and15)
6130 c=asc(mid$(a$,2,1)):e=c and15:if c>64then e=9+(c and15)
6140 c=d*16+e:poke j,c:j=j+1:goto6110
rem out(255),0
6200 data af,d3,ff,c9,z
rem peek and autoincrement
6300 data 2a,0d,34,7e,32,0f,34,23,22,0d,34,c9,00,00,00,z
