Only a handful ZX81-chars does not exist in unicode.
Vb81_XuR\Zx81_Fonts folder.
Only a handful ZX81-chars does not exist in unicode.
That one isn't a problem because in most code (i.e. non ZX81 BASIC) if it uses ** then it's accounted for...likely because it doesn't add context issues like " does...whereas if you use C/C++/Java/Perl/Python, you can't type a string like "Say ""hi"" to your neighbor" but instead have to do something like "Say \"hi\" to your neighbor" and thus the escape is a bit more natural since it's practiced elsewhere. I'd be fine with \"" actually instead of \" and, in fact, internally the ZXSimulator use \"" to keep things simple (since all other escape characters are length two) and when I read it in I look for \" and add a " and when I write it out I remove the extra ".
Sorry, I should have given a better example. I have seen code like {128}{128}{128} and figured that the { and } are being used to allow ZX81 numeric code values to be used instead of character sequences such as \::\::\:: which I think represents the same thing.
I haven't seen that used before.bwinkel67 wrote: ↑Thu Apr 30, 2020 10:30 pm Sorry, I should have given a better example. I have seen code like {128}{128}{128} and figured that the { and } are being used to allow ZX81 numeric code values to be used instead of character sequences such as \::\::\:: which I think represents the same thing.
The C source is available here:
Ok, I see where you are coming from.
"Zxtoken" (win32) had been included in Vb81.Another possible solution then is to have yet another utility
Oh, no I was asking for zxtool.exe source. Have been looking for it without success. Found this but I'm not sure if it is the same zxtool.exe since it's an entire library of tools and the specific is called zxtools.exe (note the s):Fruitcake wrote: ↑Thu Apr 30, 2020 10:52 pm The C source is available here:
http://freestuff.grok.co.uk/zxtext2p/index.html
Code: Select all
<assembly xmlns="urn:schemas\
-microsoft-com:asm.v1" manifestVersion="1.0">^M
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">^M
<security>^M
<requestedPrivileges>^M
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>^M
</requestedPrivileges>^M
</security>^M
</trustInfo>^M
</assembly>
Code: Select all
Complete Object Locator'^@^@^@ Class Hierarchy Descriptor'^@^@^@^@ Base Class Array'^@^@ Base Class Descriptor at (^@ Type Descriptor'^@^@^@`local static thread guard'^@`managed vector copy constructor iterator'^@^@`vector vbase copy constructor iterator'^@^@^@^@`vector copy constructor iterator'^@^@`dynamic atexit destructor for '^@^@^@^@`dynamic initializer for '^@^@`eh vector vbase copy constructor iterator'^@`eh vector copy constructor iterator'^@^@^@`managed vector destructor iterator'^@^@^@^@`managed vector constructor iterator'^@^@^@`placement delete[] closure'^@^@^@^@`placement delete closure'^@^@`omni callsig'^@^@ delete[]^@^@^@ new[]^@^@`local vftable constructor closure'^@`local vftable'^@`RTTI^@^@^@`EH^@`udt returning'^@`copy constructor closure'^@^@`eh vector vbase constructor iterator'^@^@`eh vector destructor iterator'^@`eh vector constructor iterator'^@^@^@^@`virtual displacement map'^@^@`vector vbase constructor iterator'^@`vector destructor iterator'^@^@^@^@`vector constructor iterator'^@^@^@`scalar deleting destructor'^@^@^@^@`default constructor closure'^@^@^@`vector deleting destructor'^@^@^@^@`vbase destructor'^@^@`string'^@^@^@^@`local static guard'^@^@^@^@`typeof'^@^@^@^@`vcall'^@`vbtable'^@^@^@`vftable'^@^@^@^=^@^@|=^@^@&=^@^@<<=^@>>=^@/=^@^@-=^@^@+=^@^@*=^@^@||^@^@&&^@^@|^@^@^@^^@^@^@~^@^@^@()^@^@%^@^@^@->*^@&^@^@^@--^@^@++^@^@->^@^@operator^@^@^@^@[]^@^@!=^@^@==^@^@!^@^@^@<<^@^@>>^@^@ delete^@ new^@^@^@^@__unaligned^@__restrict^@^@__ptr64^@__eabi^@^@__clrcall^@^@^@__fastcall^@^@__thiscall^@^@__stdcall^@^@^@__pascal^
If you look at this you'll see that the HTML listings use that mechanism. How that was converted I haven't looked into yet.Fruitcake wrote: ↑Thu Apr 30, 2020 10:52 pmI haven't seen that used before.bwinkel67 wrote: ↑Thu Apr 30, 2020 10:30 pm Sorry, I should have given a better example. I have seen code like {128}{128}{128} and figured that the { and } are being used to allow ZX81 numeric code values to be used instead of character sequences such as \::\::\:: which I think represents the same thing.
I found it...the author wrote a simple Perl program to do the conversion from .p to txt.
Code: Select all
#!f:/opt/perl/bin/perl
########################################################################
#
# program : zl
# version : @(#)bin zl v1.1 11/15/98
# author : Steven Reid (slreid@micron.net)
# purpose : To convert ZX81 programs (P files) to HTML
# (by default) or text (using the "text' option).
# Currently, zl sends to standard out.
# note : You'll probably need to change the first line to
# the location of your perl executable.
# usage : zl {ZX81 Program} [text]
# or
# zl {ZX81 Program} [text] > {filename}
#
#########################################################################
# initialize environment
$|++; # unbuffer output
use strict;
# load packages
# define constants
my @ZX81_CHAR_TABLE = (
' ','{1}','{2}','{7}','{4}',
'{5}','{T}','{E}','{A}','{D}',
'{S}','"','#','$',':',
'?','(',')','>','<',
'=','+','-','*','/',
';',',','.','0','1',
'2','3','4','5','6',
'7','8','9','A','B',
'C','D','E','F','G',
'H','I','J','K','L',
'M','N','O','P','Q',
'R','S','T','U','V',
'W','X','Y','Z','RND',
'INKEY$','PI','CALL ','ERR MSGS ','DPOKE ',
'ERROR ','CHAR ',' ','TRACE ','DRAW ',
'UNDRAW ','PROTECT ','EDIT ','AUTO ','DEF PROC ',
'END PROC ','','DELETE ','DO ','LOOP ',
'EXIT ','UNTIL ','WHILE ','WHEN ','INDENT ',
'RESEQ ','OFF','CURSOR ','DATA ','RESTORE ',
'READ ','NOSTALGIC ','USER ','*','ON',
'HOME ','BREAK ','DPEEK ','LINE ','POP ',
'PUSH ','CLR STACK ','DUP ','ELSE ','END WHEN ',
'?','?','?','?','?',
'?','?','?','?','?',
'?','?','?','?','?',
'?','?','?','[ ]','{Q}',
'{W}','{6}','{R}','{8}','{Y}',
'{E}','{H}','{G}','{F}','["]',
'[#]','[$]','[:]','[?]','[(]',
'[)]','[>]','[<]','[=]','[+]',
'[-]','[*]','[/]','[;]','[,]',
'[.]','[0]','[1]','[2]','[3]',
'[4]','[5]','[6]','[7]','[8]',
'[9]','[A]','[B]','[C]','[D]',
'[E]','[F]','[G]','[H]','[I]',
'[J]','[K]','[L]','[M]','[N]',
'[O]','[P]','[Q]','[R]','[S]',
'[T]','[U]','[V]','[W]','[X]',
'[Y]','[Z]','""','AT ','TAB ',
'?','CODE ','VAL ','LEN ','SIN ',
'COS ','TAN ','ASN ','ACS ','ATN ',
'LN ','EXP ','INT ','SQR ','SGN ',
'ABS ','PEEK ','USR ','STR$ ','CHR$ ',
'NOT ','**',' OR ',' AND ','<=',
'>=','<>',' THEN ',' TO ',' STEP ',
'LPRINT ','LLIST ','STOP ','SLOW ','FAST ',
'NEW ','SCROLL ','CONT ','DIM ','REM ',
'FOR ','GOTO ','GOSUB ','INPUT ','LOAD ',
'LIST ','LET ','PAUSE ','NEXT ','POKE ',
'PRINT ','PLOT ','RUN ','SAVE ','RAND ',
'IF ','CLS ','UNPLOT ','CLEAR ','RETURN ',
'COPY '
);
my $SYSTEM_VARS_START = 16393;
my $PROGRAM_START = 16509;
my @KEYBOARD = (246, 252, 234, 247, 249, 254, 250, 238, 244, 245, 255, 253, 232, 251, 231, 243,
242, 230, 248, 233, 235, 236, 237, 239, 240, 241);
my @SHIFT = (117, 218, 222, 223, 192, 217, 224, 219, 221, 220, 227, 225, 228, 229, 226, 216);
my @FUNCTION = (199, 200, 201, 207, 64, 213, 214, 196, 211, 194, 202, 203, 209, 210, 208, 197,
198, 212, 205, 206, 193, 65, 215, 66);
# define variables
use subs qw(peek newline getchar);
my $in = shift || die "input file required!\n";
my $html = (shift || '') eq 'text' ? 0 : 1;
my $ptr = $PROGRAM_START; # ZX81 memory pointer
my $cnt = 0; # line pointer
my $len = 0; # length of line
my $p = ''; # program file
my $c = ''; # char value
my $z = ''; # temp space
# main loop
# set up character set
if ($html) {
for (@KEYBOARD, @SHIFT, @FUNCTION) {
$ZX81_CHAR_TABLE[$_] = "<B>$ZX81_CHAR_TABLE[$_]</B>";
}
$ZX81_CHAR_TABLE[0] = ' '; # ' ';
$ZX81_CHAR_TABLE[11] = '"'; # '"';
$ZX81_CHAR_TABLE[12] = '£'; # '£';
$ZX81_CHAR_TABLE[18] = '>'; # '<';
$ZX81_CHAR_TABLE[19] = '<'; # '>';
$ZX81_CHAR_TABLE[128] = '[ ]'; # '[ ]';
$ZX81_CHAR_TABLE[139] = '"'; # '["]';
$ZX81_CHAR_TABLE[140] = '[£]'; # '[£]';
$ZX81_CHAR_TABLE[146] = '[>]'; # '[<]';
$ZX81_CHAR_TABLE[147] = '[<]'; # '[>]';
$ZX81_CHAR_TABLE[219] = '<B><=</B>'; # '<=';
$ZX81_CHAR_TABLE[220] = '<B>>=</B>'; # '>=';
$ZX81_CHAR_TABLE[221] = '<B><></B>'; # '<>';
$ZX81_CHAR_TABLE[192] = '<B>""</B>'; # '""';
}
# open the ZX81 program file
open P, $in or die "can't open file: $in ($!)\n";
binmode P; # required for DOS, UNIX ignores this
if ($html) {
print "<HTML>\n<HEAD>\n<TITLE>ZX81 Program: \U$in</TITLE>\n</HEAD>\n",
qq(<BODY BGCOLOR="#FFFFFF" TEXT="#000000">\n),
qq(<H1>ZX81 Program: \U$in</H1><HR>\n\n);
} else {
print "ZX81 Program: \U$in\n";
}
# get system variables
my $sys;
read P, $sys, $PROGRAM_START - $SYSTEM_VARS_START;
my $D_FILE = peek ($sys, 3);
my $VARS = peek ($sys, 7);
my $E_LINE = peek ($sys, 11);
my $STKBOT = peek ($sys, 17);
my $STKEND = peek ($sys, 19);
if ($html) {
print <<HTML;
<P><B>SYSTEM VARIABLES</B><P><TT>
PROG : $PROGRAM_START<BR>
D-FILE: $D_FILE<BR>
VARS : $VARS<BR>
E-LINE: $E_LINE<BR>
STKBOT: $STKBOT<BR>
STKEND: $STKEND<BR>
</TT></P><HR><P>
<B>LEGEND</B><P>
<TT>[A]</TT> means INVERSE A<BR>
<TT>{A}</TT> means GRAPHICS A<BR>
<TT><B>PRINT </B></TT> means treat as KEYWORD P<BR>
</P><HR><P>
<B>PROGRAM LISTING</B><BR><TT>
HTML
} else {
print "\n----- SYSTEM VARIABLES -----\n\n";
printf "PROG : %5d\n", $PROGRAM_START;
printf "D_FILE: %5d\n", $D_FILE;
printf "VARS : %5d\n", $VARS;
printf "E_LINE: %5d\n", $E_LINE;
printf "STKBOT: %5d\n", $STKBOT;
printf "STKEND: %5d\n", $STKEND;
print "\n----- LEGEND -----\n\n";
print "[A] means INVERSE A\n";
print "{A} means GRAPHICS A\n";
print "# is subsituted for the British pound sign.\n" if $ZX81_CHAR_TABLE[12] eq '#';
print "\n----- START OF LISTING -----\n";
}
# convert file to text
newline;
while ( $ptr < $D_FILE ) {
$c = getchar; $ptr++;
if ($c == 118) { # end of line
newline;
} elsif ( $c == 126 ) { # hidden number
read P, $z, 5; $ptr+=5; # $cnt+=5;
} else { # print value
print $ZX81_CHAR_TABLE[$c];
}
}
if ($html) { print "</TT></P><HR>\n</BODY>\n</HTML>" }
else { print "\n\n----- END OF LISTING -----\n" }
close P;
# end main
########################################################################
sub peek {
my ($str, $pos) = @_;
my $x = unpack 'C', substr $str, $pos, 1;
my $y = unpack 'C', substr $str, $pos+1, 1;
return ( $x + 256 * $y );
}
########################################################################
sub newline {
if ( $ptr >= $D_FILE ) { return }
my $line = 256 * (getchar) + (getchar);
read P, $z, 2;
print qq(<BR><FONT COLOR="#0000FF">) if $html;
$p = sprintf "\n%4d ", $line; $p =~ s/ /\ /gs if $html; print $p;
print qq(</FONT>) if $html;
$ptr += 4;
}
########################################################################
sub getchar { return unpack 'C', getc P }
########################################################################
Mine was compiled on W7/GCC/WinDev with optimisations.Wow, this version is 36K in size. I have another, older one that is 120K in size and both seem to do the same thing. I guess it was compiled in a better environment for Windows?
A variety of formats to choose between!
Plus system variables, BASIC variables and display file...
I see there is a P2TXT utility here: