avatar_cpcitor

Real CPC rejects ASCII BASIC program from CDT by 2CDT.

Started by cpcitor, 20:21, 09 November 17

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

cpcitor

Hello.

Here's a minimal test case:

{ echo '10 print "hello"' | recode ../CRLF ; } > h.bas ; 2cdt -n -F 0 h.bas h.cdt

This creates a file h.bas which contains this:

hd h.bas
00000000  31 30 20 70 72 69 6e 74  20 22 68 65 6c 6c 6f 22  |10 print "hello"|
00000010  0d 0a                                             |..|
00000012


... then it adds it to a new CDT file using 2cdt, which says:

Type set to: 0
Will write file h.bas to h.cdt
File length: 18
File is to short to have a header


I then use playtzx to send it yo a CPC.

The CPC loads it okay, returns immediately.

But if I do "LIST" it waits a second then says "Syntax Error".

2CDT help says: "-F <number>    = Define or override file type (0=BASIC, 2=Binary (default if no header)) etc."

All seem correct.

Why doesn't the CPC accept the ASCII file?

Addendum: using CPC's cat command, file type column says '$', while it normally says '%' for an ASCII program.

I guess the CDT is incorrect for this reason: it is announced as a regular BASIC program, not an ASCII program.

Thank you for any help.
Had a CPC since 1985, currently software dev professional, including embedded systems.

I made in 2013 the first CPC cross-dev environment that auto-installs C compiler and tools: cpc-dev-tool-chain: a portable toolchain for C/ASM development targetting CPC, later forked into CPCTelera.

cpcitor

Solved!

Reading Soft968 chapter 8 I understand I have to tell 2cdt to use type 22 like this:

{ echo '10 print "hello"' | recode ../CRLF ; } > h.bas ; 2cdt -n -F 22 h.bas h.cdt


Rationale:

QuoteThe file type (byte 18) is split into a number of fields:
Bit 0 Protection
Bits 1..3 File contents
Bits 4..7 Version
Page 8.4
If this bit is set the file is protected in some way.
0 = Internal BASIC.
1 = Binary.
2 = Screen image.
3 = ASCII.
4..7 are unallocated.
ASCII files should be version 1, all other files
should be version 0.

Bits 4 makes 16.
Value 3 in bits 1..3 makes value 6.
16 + 6 = 22.

Had a CPC since 1985, currently software dev professional, including embedded systems.

I made in 2013 the first CPC cross-dev environment that auto-installs C compiler and tools: cpc-dev-tool-chain: a portable toolchain for C/ASM development targetting CPC, later forked into CPCTelera.

arnoldemu

Quote from: cpcitor on 20:35, 09 November 17
Solved!

Reading Soft968 chapter 8 I understand I have to tell 2cdt to use type 22 like this:

{ echo '10 print "hello"' | recode ../CRLF ; } > h.bas ; 2cdt -n -F 22 h.bas h.cdt


Rationale:

Bits 4 makes 16.
Value 3 in bits 1..3 makes value 6.
16 + 6 = 22.
I will add 'ASCII=22' to the 2cdt help.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

Powered by SMFPacks Menu Editor Mod