CPCWiki forum

General Category => Programming => Topic started by: santi.ontanon on 21:41, 16 May 24

Title: Saving BASIC text file to .cdt
Post by: santi.ontanon on 21:41, 16 May 24
Hi!

I am trying to save a little BASIC program I wrote on a text file in my computer to a .cdt file to load it on an emulator, and I am having troubles. I can easily add it to a .dsk file with something like

./idsk test.dsk -i test.bas -t 0 -n
and that works fine!

But if I try to add it to a .cdt file, with something like this:

./2cdt -s 0 -n -r test test.bas test.cdt
When I then open an emulator and try to load the file with LOAD"", I just get a "Memory full" message from the BASIC interpreter, and if I "LIST", nothing was loaded.

What am I doing wrong? haha 
Title: Re: Saving BASIC text file to .cdt
Post by: Jean-Marie on 23:04, 16 May 24
Generally, I use the Autotype from clipboard feature on Caprice Forever (https://www.cpc-power.com/cpcarchives/index.php?page=articles&num=445) emulator. It can be painfully slow if the Basic listing is long, but that's a "no-brainer" method.
For some reason, you'll have to check on the Expert Mode from the Help menu first, or the feature won't show up.
You can then create a tape file from the menu, and save your basic listing onto it.
You have the equivalent method on WinApe, but it doesn't seem to work any longer on Windows 11; in my case, it displays some garbled characters. 
Title: Re: Saving BASIC text file to .cdt
Post by: santi.ontanon on 23:57, 16 May 24
Thanks for the suggestion!! This would be definitively enough for my use case for now. Unfortunately "Caprice Forever" is a Windows-only application, and I do not have access to any Windows machine. All my machines at home and at work are Linux/Mac. I tried running it with wine, but it does not seem to work either... hmm... I can run caprice32 no problem (I compiled it from source and it runs, but it does not seem to have that feature).
Title: Re: Saving BASIC text file to .cdt
Post by: santi.ontanon on 00:19, 17 May 24
Is the problem that the basic file to load into the .cdt has to be tokenized BASIC, rather than a text file? (surprising, since I can save a text file to a .dsk and load it fine though).
Title: Re: Saving BASIC text file to .cdt
Post by: Jean-Marie on 01:44, 17 May 24
If you have a Memory full error displayed, that could mean the file header is incorrect and was created for a binary content rather than a Basic one. A basic file must have a flag set up accordingly, and a start address equal to 170h.
You can test your luck with WinAPE which is said to work correctly with WINE.
Title: Re: Saving BASIC text file to .cdt
Post by: Jean-Marie on 02:16, 17 May 24
I managed to have it working with ACE/DL emulator, which has a Linux version (http://www.roudoudou.com/ACE-DL/).
You must first save your Basic file in a text format with a BAS extension. Give it a short name, and no spaces nor special characters.
Press F12 to display the menu, then select Floppy & Drives, then Create new floppy in Drive A.
Press F12 again, click again on Floppy & Drives, then on Manage Floppy in Drive A.
From there, you can drag & drop your file in the window, and it will be written directly on the disk.
Finally, press F4 to save the DSK file.
Important: you must tick on the ASCII Import checkbox before dragging the file.
Title: Re: Saving BASIC text file to .cdt
Post by: santi.ontanon on 03:14, 17 May 24
Thanks again! I'll give this emulator a try too! 

But actually, I just figured it out using 2cdt! Finally!! What I was missing is to save the block in "cpctxt" format! Thanks a lot for the help though, I've discovered a couple of new emulators I didn't know! (I'm relatively new to the CPC world, as I do most of my development for MSX, and I am not very familiar with the CPC tools!)
Title: Re: Saving BASIC text file to .cdt
Post by: MoteroV4 on 04:19, 17 May 24
In case it helps you, this is an example of "maketape.sh" with "2cdt" tool that I used a while ago to create the "cdt" that I presented to CPCRetrodev:

#!/bin/bash
# Los nombres de los archivos, son sensibles a Mayúsculas
# NOTA: los ficheros BAS hechos con editor no llevan cabecera AMSDOS. Crear el diskete normalmente,
# cargarlos en Winape y grabarlos con save "nombre.BAS", para convertirlos de ASCII a binario (BAS).
# Aparte ocupan la mitad. Y en ASCII tardaban mucho en cargarse, antes de convertirlos en BAS.
# Finalmente extraerlos del diskete con CPCDiskXP. Usar estos para empaquetarlos en la distribución
# final en disco y en cinta. Se distinguen porque van en letras mayúsculas.
# Para compilar Proyecto en Cinta: ./maketape.sh

ICDT=$CPCT_PATH/tools/2cdt/bin/2cdt
TARGET=memtrainer.cdt

# Crear un nuevo fichero CDT con el nombre de mi "target"
$ICDT -n . $TARGET > /dev/null

# Fuentes de ficheros a insertar en el CDT
#cargador
SOURCE1=MEMTRAIN.BAS
#pantalla
SOURCE2=MEMTRAIN.SCR
#basic ppal.
SOURCE3=SIMON.BAS
#fuentes
SOURCE4=SPACEAGE.FNT
#sprites y ASM
SOURCE5=SIMONBIN.BIN
#musica
SOURCE6=SIMBUFER.BIN


$ICDT -r Memtrainer $SOURCE1 $TARGET
$ICDT -r memtrain.scr -L 0xC000 $SOURCE2 $TARGET > /dev/null
$ICDT -r simon.bas $SOURCE3 $TARGET > /dev/null

$ICDT -r spaceage.fnt -L 0xA074 -X 0xA074 $SOURCE4 $TARGET > /dev/null

$ICDT -r simonbin.bin -L 0x6000 -X 0x9452 $SOURCE5 $TARGET > /dev/null

#$ICDT -r simbufer.bin -L 0x5000 -X 0x05786 $SOURCE6 $TARGET > /dev/null
$ICDT -r simbufer.bin -L 0xC000 $SOURCE6 $TARGET > /dev/null
Title: Re: Saving BASIC text file to .cdt
Post by: santi.ontanon on 12:18, 17 May 24
Thanks!! Yeah, that's very useful!
Powered by SMFPacks Menu Editor Mod