hornc / ctbasic Goto Github PK
View Code? Open in Web Editor NEWCyclic Tag System BASIC (like) compiler toy project with Tektronix 401x graphical output.
Cyclic Tag System BASIC (like) compiler toy project with Tektronix 401x graphical output.
Make animations smoother by changing the interpreter's handling of the -hold
parameter.
Some kind of double buffering which minimises the amount of blank screen time that might arise if the screen is cleared while the next 'frame' is still being assembled.
Can't assume every program is an animation, nor even that every program with a CLS
is an animation.
The -hold
parameter could be replaced by an -fps
, if that seems appropriate.
Update readme with a description of what this thing is. The proof of concept basic idea seems to be working.
It mixes at least three obscure concepts that on the surface have very little to do with each other:
{ 0, 1, ;}
)Describe them, and explain why...
Frame in terms of a fantasy console architecture / virtual machine.
Underlying architecture and command set: cyclic tag (but with the flexibility to run on any cyclic tag equivalent implementation, hence the multiple compile targets)
Tag systems: https://en.wikipedia.org/wiki/Tag_system
and Cyclic tag: https://en.wikipedia.org/wiki/Tag_system#Cyclic_tag_systems
The virtual machine provides output via a memory data store convention which sends blocks of serial data to a hypothetical "display terminal" (VT100 or Tektronix (for lightweight serial graphical output) compatible).
A reduced BASIC-like command subset is used as a "high level" language which is compiled down to cyclic tag 'machine code'. The BASIC keywords really only provide shortcuts for encoding text and graphics into the required serial transmission format. (At least currently) flow control is performed directly as it would be in raw cyclic tag, with an implicit loop over the productions, and output only occurring if the leftmost bit of the current datastring is 1
.
The purpose is to create a somewhat usable Turing complete 'computer' from a very simple foundation, and to produce a range of interesting code examples for cyclic tag systems, that will run in any cyclic tag context (down to rule 110 cellular automata), regardless of whether the output extension exists. Even if it is not implemented, the output will get encoded in the datastring memory, and the intended computations and intermediate data states will all be realized.
Output frames all have 0
bits in position 10, if all other data structures could ensure every 10th bit was also 0
, CLEAR 10
at the end of a program would cleanly exit without having to use large runs of ;
clear symbols, like the CLEAR 600
code used in some early code examples.
END
could be an alias for CLEAR 10
if this convention was followed, and END
would have the effect of eventually terminating a program by reducing the datastring over multiple iterations, without triggering any new additions.
In interactive mode: when the datastring is fully consumed (normally the HALT condition) the interpreter will prompt for input, and if any (non-empty) is received, it will continue to evaluate productions using the current program string.
Static image of the Utah teapot (2d)
Cleanly terminating
Using the patch data from here: http://www.sjbaker.org/wiki/index.php?title=The_History_of_The_Teapot
After the 10th iteration the data string should be completely cleared.
Every other iteration will need to add n dummy bits since the clearing is unconditional.
This is possibly also an issue in https://github.com/hornc/abctag / inherited from there.
Some existing examples add offset bits to break frame alignment to work around this issue
e.g. https://github.com/hornc/CTBASIC/blob/master/examples/ANIMTEST001.bas
and
https://github.com/hornc/CTBASIC/blob/master/examples/1_TO_10_OUTPUT.BAS which has a comment explaining the workaround...
In order to calculate CLEAR
lengths correctly, the number of bits or frames each command adds to the data-string should be listed in the COMMANDS reference.
for example:
PRINT "<string>"
len(<string>) + 2
frames
or
(len(<string>) + 2) * 10
bits
PLOT
and DRAW
have the same fixed length.
CLS
's length depends on the exact clear commands used (which may change).
DATA
will depend on the different formats... ASM
also depends.
CLEAR
can take an id which will be substituted for the actual block lengthThis will save the developer having to keep track of various code lengths and having to adjust corresponding CLEAR
s to get clean behaviour.
This feature isn't very BASIC-like. Investigate prior art.
The Tektronix 401x has various vector style drawing modes:
To investigate:
Add a CT-BASIC command to select which mode / pen is to be used when drawing. (Default is Normal)
Suggested ZX-BASIC command to use:
INK <value>
xterm -hold -t -e "./ct.py --hold 130 <(./CTBASIC.py examples/ANIMTEST001.bas)"
displays only the first frame at commit bded805
The examples work on the graphics
branch and the recent (now deleted) ink
branch.
https://web.archive.org/web/20180308030524/http://uncomp.uwe.ac.uk/genaro/rule110/ctsRule110.html
and datafile: https://web.archive.org/web/20180310202619/http://uncomp.uwe.ac.uk/genaro/rule110/ctsR110.txt
referenced in this paper: http://www.comunidad.escom.ipn.mx/genaro/Papers/Papers_on_CA_files/repCTSR110.pdf
Found via this repo: https://github.com/slightknack/machine-110
A)
./ct.py <(./CTBASIC.py examples/ANIMTEST001.bas) 1
vs.
B)
../abct/abct-cli $(./CTBASIC.py examples/ANIMTEST001.bas -tABCT) 2 | cut -f5 | grep -v '^$'
Expect:
Both should produce identical output: endlessly repeating output
with 2 occurrences of
Tektronix 4010 animation in bitwise cyclic tag.
every iteration.
Actual:
Only A works as expected. B gives one-and-a-half iterations, then halts.
Either:
Test 1 by confirming CT:
10000001001010101000101100101010110101101011101000101110010010110111101011011100101101001010111100001001000000100110100010011000001001100010100110000010010000001011000010101101110010110100101011011010101100001010111010001011010010101101111010110111001001000000101101001010110111001001000000101100010010110100101011101000101110111010110100101011100110101100101010010000001011000110101111001010110001101011011000101101001010110001101001000000101110100010110000101011001110100101110010000001101;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1000000100100011101010010100101011000100100110000010100000001001011110101101010010011000001010000000100011111010000001101;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;10000001001000110110100001100010000001101;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;10000001001010101000101100101010110101101011101000101110010010110111101011011100101101001010111100001001000000100110100010011000001001100010100110000010010000001011000010101101110010110100101011011010101100001010111010001011010010101101111010110111001001000000101101001010110111001001000000101100010010110100101011101000101110111010110100101011100110101100101010010000001011000110101111001010110001101011011000101101001010110001101001000000101110100010110000101011001110100101110010000001101;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1000000100100011101010010110001011001100100101100010101001001001011000101100110010011001101010011100100011111010000001101;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;10000001001000110110100001100010000001101;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
converts to ABCT:
2725982173686371546601146872886478949676848343266687991455439775039246418566991564641072288886220641561220670417516878231337933182184221424474093486845123125288670924515227783347655713180738218612886808832567033405941261870209198197499335522520203793089647883525078726559522656322780833408305628209269451473841003952210357194804200927150864610020756488192140187415701229030023952457438960925517992085597157234115289733115229439541089867784618086421793464268100833257701933775660453143156550120230674427663139648925188894161008175666402137753021069691834098297645921724202153242602931770834033441974631172949352571451809476181649397847949984029722320500590490703749618295737914214793876366690181800306882307438513493238780477058778118173082607282107530831688589902108332787303323549563264682736128778696218029374094176060567774168320432597567000188014389411028017637004562908145413670119998291596935662982757593568414959308475684205073026516105003125317845476108577246127248204080999031261611309305491371624651666947921800000150020852464221004167616123654694382655473799426045366673852202654542189718580937791357707916724009533567448290513254034560106021425092655860067769504879958
For conversion comparison the compiled BCT is
111010101010101110101110111011101110101011101111101011101110111011111011101111101110111111101110101011101111111010111010111011111011111111101110111110111111101011101111101110101110111011111111101010101110101110101010101011101011111011101010111010111110101010101110101111101010111011101011111010101010111010111010101010101110111110101010111011101111101111111010111011111011101011101110111110111110111011101111101010101110111011111110111010101110111110111010111011101111101111111110111011111011111110101110101110101010101011101111101110101110111011111011111110101110101110101010101011101111101010111010111011111011101011101110111111101110101011101111111011111110111011111011101011101110111111101011111011101111101011101110111010111010101010101110111110101011111011101111111110101110111011111010101111101110111110111110101011101111101110101110111011111010101111101110101110101010101011101111111011101010111011111010101011101110111110101111111011101011101111111010111010101010101111101100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111010101010101110101110101011111110111011101011101110101110111011111010101110101110101111101010101011101110101010101010111010111011111111101110111110111011101011101011111010101010111011101010101010101110101011111111111011101010101010111110110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111010101010101110101110101011111011111011101010101111101010111010101010101111101100000000000000000000000000000000000000000111010101010101110101110111011101110101011101111101011101110111011111011101111101110111111101110101011101111111010111010111011111011111111101110111110111111101011101111101110101110111011111111101010101110101110101010101011101011111011101010111010111110101010101110101111101010111011101011111010101010111010111010101010101110111110101010111011101111101111111010111011111011101011101110111110111110111011101111101010101110111011111110111010101110111110111010111011101111101111111110111011111011111110101110101110101010101011101111101110101110111011111011111110101110101110101010101011101111101010111010111011111011101011101110111111101110101011101111111011111110111011111011101011101110111111101011111011101111101011101110111010111010101010101110111110101011111011101111111110101110111011111010101111101110111110111110101011101111101110101110111011111010101111101110101110101010101011101111111011101010111011111010101011101110111110101111111011101011101111111010111010101010101111101100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111010101010101110101110101011111110111011101011101111101010111011111010111110101110101110111110101011101110111010111010111010111011111010101110111110101111101011101011111010111110111011101011111110101110101011111111111011101010101010111110110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111010101010101110101110101011111011111011101010101111101010111010101010101111101100000000000000000000000000000000000000000
Requirements:
relates to d901511
Now that all PRINT
commands end with an ETX
, the context transitions between GRAPHICS
and TEXT
output are not so important. Does the current context system still make sense?
Do PRINT
s inside GFX behave as expected?
are CLEAR
, BIN
, and DATA
treated correctly in all contexts?
What are the relevant cases?
-- allow these characters to appear inside quotes.
Finish PRINT improvements started in #21
Add some fuller PRINT
examples, and tests.
ref: https://worldofspectrum.org/ZXBasicManual/zxmanchap15.html
PRINT separators: ,; '
;
suppress newline,
tab separator'
newline separatorhttps://zxbasic.readthedocs.io/en/docs/syntax/#lines-and-sentences
Implement splitting lines by :
Consider adding the _
underscore to enable split lines to implement the full line / sentence BASIC model.
Produce a better screen capture of the rotating cube example now that CLS
doesn't trigger an INK
change.
Instead of processing the program string symbol-by-symbol (current method), we can speed things up by dividing the program string into different length productions (by splitting on ;
) and examining the datastring for runs of 0
s followed by a 1
to find the next production to append to the right of the datastring and delete n bits from the left.
This means than we won't be doing processing for every command in an inactive production.
For consistency with the rest of the BASIC commands.
relates to #19
Accept line numbered code when parsing.
Line numbers don't really add anything (CT-BASIC code runs in an implicit loop), but allowing them in source would allow for ZX-BASIC / CT-BASIC polyglots.
Using https://github.com/rricharz/Tek4010 static graphics work perfectly:
tek4010 -noexit ./ct.py <(./CTBASIC.py examples/teapot.bas)
but the animations cause the screen to strobe white on CLEAR, which is very jarring.
tek4010 ./ct.py --hold 130 <(./CTBASIC.py examples/CUBE.BAS)
and
tek4010 ./ct.py --hold 130 <(./CTBASIC.py examples/ANIMTEST003.bas)
It's not because of the extra ANSI / RIS code I added (surprisingly), but it appears that the Tektronix ESC
+ FF
causes the screen flash on reset, and that is the authentic behaviour -- which does not occur under xterm
.
It looks like using ESC
+FF
between frames in not the standard way to run animations on a Tektronix display.
TODO:
Is is using "Write-Thru" mode, or specific erasing? I couldn't find clear descriptions of these features in the manual.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.