Author Topic: Real CPC rejects ASCII BASIC program from CDT by 2CDT.  (Read 603 times)

0 Members and 1 Guest are viewing this topic.

Offline cpcitor

  • The user previously known as FindYWay
  • CPC6128
  • ****
  • Posts: 263
  • Country: fr
  • My heart still runs on traditional CPC.
    • My code for the CPC.
  • Liked: 126
  • Likes Given: 293
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:

Code: [Select]
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:

Code: [Select]
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.
« Last Edit: 21:25, 09 November 17 by cpcitor »
Had a CPC since 1985, currently software dev professional, including embedded systems.

I made 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.

Offline cpcitor

  • The user previously known as FindYWay
  • CPC6128
  • ****
  • Posts: 263
  • Country: fr
  • My heart still runs on traditional CPC.
    • My code for the CPC.
  • Liked: 126
  • Likes Given: 293
Solved!

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

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

Rationale:

Quote
The 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 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.

Offline arnoldemu

  • Supporter
  • 6128 Plus
  • *
  • Posts: 5.335
  • Country: gb
    • Unofficial Amstrad WWW Resource
  • Liked: 2261
  • Likes Given: 3478
Solved!

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

Code: [Select]
{ 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