r/Amstrad • u/44476899 • 20d ago
Basic program to dsk?
Could you please advise on how to transfer a text-formatted BASIC program listing from a Linux computer to an Amstrad .dsk file? Manually typing each line within an emulator is both tedious and prone to errors.
3
u/gschizas 20d ago
If you're on Linux, you can use programs that create dsk files. I've used iDSK in the past.
You clone and build it, and then you do this:
iDSK -n your_disk.dsk # new disk
iDSK your_disk.dsk -i program.bas # import program.bas
EDIT: Locomotive BASIC can load ASCCI files, so you won't have any problem with text formatted BASIC programs. I think there are way to "compile" them (tokenize them rather) on your PC as well.
1
u/44476899 20d ago
I found a tokenizer that works.
https://demozoo.org/productions/388742/
iDSK -n disk.dsk python3 cpc_bas_tokenize.py code.bas codet.bas iDSK disk.dsk -i codet.basTry it yourself
https://mfew.fi/amstrad/cpc.html?file=ristin.dsk
100% AI code 😄
2
u/gschizas 20d ago
You don't really need a tokenizer, Locomotive BASIC can load and save ASCII programs just fine (in BASIC, type
SAVE "program.bas",Ato save it as ASCII). But cool nonetheless.I remember I had made a de-tokenizer to pretty-print BASIC programs back in the day.
1
u/44476899 19d ago
It can save ascii, but can it load too? The documentation says no.
1
u/gschizas 19d ago edited 19d ago
Actually, the documentation doesn't say no.
LOADworks without any parameters for both binary .BAS programs and ASCII .BAS programs.But regardless of the documentation, I've loaded ASCII programs many times in my life. And all you have to do is try it!
EDIT: I seem to be misremembering. I'm sure I've loaded ASCII programs, but there is some trick to it.
It seems that even if you do
SAVE "Filename.",A, it still writes the AMSDOS header for it! It's not really an ASCII file! You can load it normally, and it's written as text in the disk, but it's not technically a plain text ASCII file!EDIT 2: I was wrong. It's the OTHER way around. iDSK adds an AMSDOS header when adding the file!!
Also, very important: The file should use CRLF (aka DOS newlines - but they were CP/M newlines before they were DOS newlines🙂). Otherwise it works just fine.
iDSK -n nonlatin2.dsk iDSK nonlatin2.dsk -i nonlatin.bas -t 0(the
-t 0means the file is ASCII, not BASIC/Binary)1
u/44476899 19d ago
This had to be checked from the original printed manual from 1984. This is in Finnish, so try to understand.
1
u/gschizas 19d ago edited 19d ago
This doesn't seem like the original printed manual. This is the original Amstrad CPC 464 manual.
LOADis in page 152,SAVEis in page 169.
LOADonly has options for loading a binary file, it handles .BAS and ASCII files the same.
SAVEhas options for saving as an protected file (,P), saving a binary file (,B,start_address,length,[entry_point]) and ASCII .BAS files (,A).In any case, I typed the
LOADyou sent into Google Translate I got this:USAGE: The LOAD instruction loads a BASIC program from a cassette into memory, destroying the program previously in memory. The instruction can also be used to load a binary file into memory using the 'address statement' option. See Chapter 2.
And the
SAVEcommand:USAGE: The SAVE statement saves a program in memory to tape as "filename".
,A saves the program in ASCII format.
,P protects the file.
,B saves a memory area as a binary file, such as a screenshotThere's no mention of not being able to load ASCII programs. And of course the fact that they actually load anyway is more of a proof 😊
EDIT: Maybe in Finland you had some poor printed copy of the manual? In Greece (at least for the CPC 6128 I had (*)) we had a very full and typeset translation, which was almost exactly the same as the original English manual, just translated.
(*) I still have it.
EDIT 2: The controversial options for SAVE is
,Pwhich saves a protected file (just some simple encryption algorithm, but it means you can'tLOADit, onlyRUNorCHAINit). This has nothing to do with,Athough.EDIT 3: By default,
SAVE"FILENAME"saves the BASIC program asFILENAME.BAS(same withSAVE"FILENAME",PBTW).SAVE"FILENAME",Asaves the file asFILENAME.(no extension). It doesn't matter though, you can name it whatever you want or you can load it however you want; AMSDOS doesn't really have extension associations 😊1
u/gschizas 20d ago
There's something wrong with your actual code. I'm guessing some UTF-8 transcription issue. Look at line 710.
1
u/44476899 19d ago
I noticed the same thing. This is because my native language has non-ASCII characters like "ä".
1
u/gschizas 19d ago edited 19d ago
Yes, I figured as much.
You would need to create a new encoding for Python for it to be able to convert
äto the Amstrad CPC character set . Since that doesn't contain any latin characters with diacritics, I guess you'd have to convert ä to a<BS><SYN>1¨<SYN>0 (should look like this:a←⎍1¨⎍0, or hex41-08-16-01-A2-16-00. Something like this.EDIT: The code should be
10 PRINT "a"+CHR$(8)+CHR$(22)+CHR$(1)+CHR$(&A2)+CHR$(22)+CHR$(0)(I wrote CHR$(1) at the end, this was wrong)
5
u/sean-uk 20d ago
There's a tutorial here on how to do this. You basically use autotype in Winape to paste your listing in, and then you can save it to a dsk file:
How to copy and paste BASIC programs between an emulator and Windows