Hello!
I think it would be a good idea to merge the functionality of my program PRGInfo into the vic-20 emulator's autostart function:
http://user.tninet.se/~pug510w/datormuseum/prginfo.html
Use similar code to determine the correct way of setting up the ram expansions and then load and start the program or cart image.
Here is the source for the original amiga version (Hisoft Basic 2):
[code]
rem $to c:PRGinfo
rem $nowindow
rem $include chop.bas
function findsys(n$)
r=instr(n$,"SYS")
if r=0 then
findsys=0
exit function
else
findsys=1
r=r+3
l=len(n$)
n$=n$+"a"
a0=asc("A")
b0=asc("0")
b9=asc("9")
print "SYS ";
do while r=<l
b=asc(mid$(n$,r,1))
if b>=a0 then exit loop
if b>=b0 and b=<b9 then print chr$(b);
incr r
loop
print
end if
end function
x$=command$
hej:
chop x$,a$
if a$=="-2" then
minus=1
goto hej
elseif a$=="-h" then
hexa=1
goto hej
elseif a$=="-d" then
deci=1
goto hej
end if
if a$="" or a$="?" then
print "CBM PRG File Info V1.0 - By Anders Persson 2004 (listen.to/boray)"
print
print "Usage:"
print "PRGInfo [-d -h -2] file.prg"
print
print "This program shows information about any CBM 8 bit file."
print "It shows the address space the file uses in memory and also"
print "takes an educated guess of what the file is. (Vic20 8K plugin"
print "at block 5, C64 program, program for unexpanded Vic20 etc..."
print "Note that if you for example have saved a Vic20 program"
print "with a C64, then PRGinfo will think it's a C64 program."
print
print "-d = Return only decimal start address"
print "-h = Return only hexadecimal start address"
print "-2 = Return only address -2 (vic-emu $start address)"
system
end if
if not fexists(a$) then
print a$;" not found."
system
end if
open a$ for input as #1
lb=asc(input$(1,1))
hb=asc(input$(1,1))
l=lof(1)-2
close 1
sa=hb*256+lb
if minus=1 then
if hexa=0 and deci=0 then hexa=1
sa=sa-2
end if
if hexa=1 then print "$";hex$(sa) : system
if deci=1 then print sa : system
print "CBM PRG File Info V1.0 - By Anders Persson 2004 (listen.to/boray)"
print
ea=sa+l
c=len(a$)
do
if c=0 then exit loop
if mid$(a$,c,1)=":" then exit loop
if mid$(a$,c,1)="/" then exit loop
decr c
loop
n$=ucase$(right$(a$,len(a$)-c))
print "File: ";n$
print
print "Address:";sa;"to";ea;" =";l;"bytes"
print " Hex: $";hex$(sa);" to $";hex$(ea)
print
print "My guess:"
if ea>65537 then
print "No CBM 8bit file!!!"
system
end if
if abs(8192-l)<8 and lb=0 then
if sa=40960 then
print "Vic20 8K plugin for block 5."
goto emu1
elseif sa=24576 then
print "Vic20 8K plugin for block 3."
goto emu1
elseif sa=16384 then
print "Vic20 8K plugin for block 2."
goto emu1
elseif sa=8192 then
print "Vic20 8K plugin for block 1."
goto emu1
end if
end if
if abs(4096-l)<8 and lb=0 then
if sa=40960 or sa=40960+4096 then
print "Vic20 4K plugin for block 5."
goto emu1
elseif sa=24576 or sa=24576+4096 then
print "Vic20 4K plugin for block 3."
goto emu1
elseif sa=16384 or sa=16384+4096 then
print "Vic20 4K plugin for block 2."
goto emu1
elseif sa=8192 or sa=8192+4096 then
print "Vic20 4K plugin for block 1."
goto emu1
end if
end if
if lb=1 then
print "Program you can start with RUN on ";
if sa=4097 and ea=<8192 then
print "Unexpanded Vic20."
gosub bas
system
elseif sa=1025 and ea=<8192 then
print "Vic20 with 3K expansion."
gosub bas
system
elseif sa=4609 and ea=<16384 then
print "Vic20 with 8K expansion."
gosub bas
system
elseif sa=4609 and ea=<24576 then
print "Vic20 with 16K expansion."
gosub bas
system
elseif sa=4609 and ea=<32768 then
print "Vic20 with 24K expansion."
gosub bas
system
elseif sa=7169 or sa=16385 then
print "Commodore 128 (or expanded Vic20 with altered basic memory address)."
gosub bas
goto emu2
elseif sa=&h2001 and ea=<32768 then
print "Vic20 with Super Expander (or basic memory address altered for other reason) and 8K Ram expansion or more."
gosub bas
goto emu2
elseif sa>4609 and ea=<32768 then
print "Expanded Vic20, saved from manually altered basic memory address."
gosub bas
goto emu2
elseif sa=&h0801 then
print "Commodore 64"
gosub bas
system
end if
end if
print "Machine language or data for ";
if sa>=4096 and ea=<8192 then
print "Vic20 graphics memory (standard 5K) or C64/128."
goto ml
elseif sa>=828 and ea=<1024 then
print "Cassette buffer or sprite data."
goto ml
elseif sa>=1024 and ea=<8192 then
print "Commodore64/128 or Vic20 with 3K expansion."
goto ml
elseif sa>=4608 and ea=<16384 then
print "Vic20 with 8K expansion or C64/128."
goto ml
elseif sa>=4608 and ea=<24576 then
print "Vic20 with 16K expansion or C64/128."
goto ml
elseif sa>=4608 and ea=<32768 then
print "Vic20 with 24K expansion or C64/128."
goto ml
elseif sa>=40960 and ea=<49152 then
print "Vic20 block 5."
goto ml
else
print "Commodore 64/128"
print
print "LOAD """;n$;""",8,1"
if findsys(n$)=0 then print "SYS";sa;"(maybe)"
system
end if
emu1:
print
print "LOAD """;n$;""",8,1"
if findsys(n$)=0 then print "SYS 64802 (probably)"
print
print "Vic-Emu command line $-load address: $";hex$(sa-2)
emu2:
print
print "Vic-Emu before LOAD:"
print "POKE 43,";lb;":POKE 44,";hb
if lb=1 then print "POKE";sa-1;",0 : NEW"
if sa=>40960 then print "NOTE: Crashes on vic-emu 0.65! Use the command line $-load address instead."
system
bas:
print
print "LOAD """;n$;""",8"
print "RUN"
return
ml:
print
print "LOAD """;n$;""",8,1"
if findsys(n$)=0 then print "SYS";sa;"(maybe)"
goto emu2
[/code]
chop.bas
[code]
SUB CHOP(com$,a$)
while instr(com$," ")=1 or instr(com$," ")=1
com$=right$(com$,len(com$)-1) : wend
x$=left$(com$,1)
if x$="'" or x$="""" then com$=right$(com$,len(com$)-1) else x$=" "
if x$=" " then
qq=instr(com$," ")
q=instr(com$," ")
if q<>0 then
if qq<>0 and qq<q then q=qq
else
q=qq
end if
else
q=instr(com$,x$)
end if
if q=0 then a$=com$ : com$="" : exit sub
a$=left$(com$,q-1) : com$=right$(com$,len(com$)-q)
END SUB
[/code]
Kind Regards,
Anders Persson
Nice idea on the first glance, but there are a few reasons to not do this:
1. The way autostarting is handled would need a big rewrite that wouldn't help the other emulators.
2. As the detection wouldn't be perfect (or f.ex because the user wants to see what happens when loading with the "wrong" memory setup). the improved autostart would need to be conditional, adding to complexity.
3. Consider TAP files, or if a cart (even FE3 or Mega-Cart) is already attached...
4. Automatically switching emulator settings on (seemingly) unrelated actions is something we're trying to get rid of. Ever had disks failing to work because "True drive emulation" magically turned off? ;)
All in all, I'll have to turn this request down and suggest coming up with an external solution. Which, by the looks of it, you actually did: http://user.tninet.se/~jad615g/prgstarter/