Oncoming trains, a video game for SBTCVM and technically its first true video game.
v1.0 has been covered in a video before, though v1.5 offers vastly improved visuals. (relatively)
Wednesday, February 27, 2019
Thursday, February 21, 2019
Video: oncoming trains - a balanced ternary video game for SBTCVM.
A short Video featuring a new SBTCVM game: 'oncoming trains'.
On a Technical level, its SBTCVM's first graphical SBTGA game, and hence its first true video game.
It uses SBTGA mode 30: the vector plotter. that's why it looks so sparse, as the plotter can only do 3 drawing operations: fill screen,draw rectangle, and draw line.
Whether its the first true ternary video game in general, i don't know.
On a Technical level, its SBTCVM's first graphical SBTGA game, and hence its first true video game.
It uses SBTGA mode 30: the vector plotter. that's why it looks so sparse, as the plotter can only do 3 drawing operations: fill screen,draw rectangle, and draw line.
Whether its the first true ternary video game in general, i don't know.
Sunday, January 6, 2019
Gen 2 App: cliclac now has a memory monitor
Memory monitors. computers have had memory monitors for quite some time, but until now SBTCVM has had to do without one.
Its fairly basic at the moment. only having single-address-at-a-time reads and writes, for the data, instruction, and IO buses respectively.
Possible improvements include dumping ranges of memory in a similar fashion to romdump.py (Added), As well as possible disk support when time (and SBTVDI's development state) allows.
via 'L', you can write to the IObus. that may not sound like much, but that means you can do this:
Meet CliCalc Embedded Memory Monitor
![]() | |
| CliCalc Embedded Memory Monitor In all its Glory. |
Its fairly basic at the moment. only having single-address-at-a-time reads and writes, for the data, instruction, and IO buses respectively.
Fun:
via 'L', you can write to the IObus. that may not sound like much, but that means you can do this:
- start clicalc from the xas.py shell (so you can still see the TTY output mirrored to the OS terminal's standard output)
- enter the memory monitor via 'p'
- 'L' command: address 500, value 30 :A grey screen should appear in place of the pygame window's emulated text screen.
- 'L' command: address 507, value 9490 :The screen should turn bright violet/purple
- 'L' command: address 500, value 0 :The tty should now be displayed again.
Friday, January 4, 2019
Developers Notes: Building for the future: looking on at 2019
Its hard to believe its been over 3 years since i started this project. It seems only yesterday that i was running the first tests on SBTCVM Gen2-9's memory framework.
Its gone from a buggy, slow, mess of a python program, to a streamlined, 6.5Khz, modular VM, well suited to running things like calculators, games, and even mouse-driven programs via the pygame frontend.
Its hard to describe how much SSTNPL has helped coding for SBTCVM. everything from the maze engine, to clicalc, to even many of the hardware demos. Its extensive TTY input and output integration, named integers, and its ever powerful 2D integer table system, this clever compiler has certainly helped along things...
SBTCVM Assembly v3:
From its early beginnings in TDA mark 1, to its 9-trit rehash in Mark 2, to its Gen 2-9 rewrite, SBTCVM assembly has been not only the main compilation target for SBTCVM, but for a while, was its only language. While its direct use has dropped considerably since Mark 2, thanks to SSTNPL, its still a key component of SBTCVM's development pipeline, with SSTNPL not only compiling into SBTCVM assembly, but featuring support for its inclusion in-line.
Not only that, the assembler is now the first SBTCVM language with a standard library. with tas0 files for statically linked routines and other bits of data, to .nsp files for namespace variables, which represent the new unified label/compile-time variable system. It even has header variables for controlling the compilation process in more detail.
eXstensible Assembly Script/Shell (XAS):
Despite the name, it does more than script the assembler. This program represents SBTCVM Gen2-9's platform independent build script system & interactive shell. Very handy for building projects with images converted to ternary-packed-art (block art) for example.
It also has a few extra features in interactive mode. such as categorized command help, directory listing and a builtin find command for searching for that pesky file...
SBTCVM Gen2-9:
This is among SBTCVM's greatest landmarks. Gen 2 marks the beginning of not only a new design of SBTCVM's codebase, but a new chapter, for at the very least, SBTCVM. However, perhaps, balanced ternary will one day be more than a mere footnote in computer history, but a major player in computing, once again.
New programming languages:
SBTCVM already has 2 goto-label based languages, (SSTNPL, SBTCVM assembly), but its apparent that a greater variety of languages are needed. While most ideas involve compiled languages, a few are floating about involving interpreted languages, and line editors. not much to show for either, particularly the latter. (eekee's scal for Mark 2, and my clicalc for Gen2-9, are kinda close, but in reality they are just 2 different calculators...)
New Tools:
As more features get added, and as clever programmers take up SBTCVM's challenges, you might just find a growing list of tools, converters, editors, and other nifty things.
New APPs:
New Apps eh? like what? Well more games are almost a given, as both the mouse, and the plotter are yet to be exploited by them. and thats not even counting the tilemap graphics modes currently on the SBTGA drawing board.
However, its also to be expected to find a verity of new tools for various things. they may not all be as fast, nor as polished as the external utilities tend to become, but the important part is whether they work isn't it?
And who knows, perhaps one day, balanced ternary will be, perhaps, a bit less obscure than it is today...
Its gone from a buggy, slow, mess of a python program, to a streamlined, 6.5Khz, modular VM, well suited to running things like calculators, games, and even mouse-driven programs via the pygame frontend.
Looking back on 2018
SSTNPL:Its hard to describe how much SSTNPL has helped coding for SBTCVM. everything from the maze engine, to clicalc, to even many of the hardware demos. Its extensive TTY input and output integration, named integers, and its ever powerful 2D integer table system, this clever compiler has certainly helped along things...
SBTCVM Assembly v3:
From its early beginnings in TDA mark 1, to its 9-trit rehash in Mark 2, to its Gen 2-9 rewrite, SBTCVM assembly has been not only the main compilation target for SBTCVM, but for a while, was its only language. While its direct use has dropped considerably since Mark 2, thanks to SSTNPL, its still a key component of SBTCVM's development pipeline, with SSTNPL not only compiling into SBTCVM assembly, but featuring support for its inclusion in-line.
Not only that, the assembler is now the first SBTCVM language with a standard library. with tas0 files for statically linked routines and other bits of data, to .nsp files for namespace variables, which represent the new unified label/compile-time variable system. It even has header variables for controlling the compilation process in more detail.
eXstensible Assembly Script/Shell (XAS):
Despite the name, it does more than script the assembler. This program represents SBTCVM Gen2-9's platform independent build script system & interactive shell. Very handy for building projects with images converted to ternary-packed-art (block art) for example.
It also has a few extra features in interactive mode. such as categorized command help, directory listing and a builtin find command for searching for that pesky file...
SBTCVM Gen2-9:
This is among SBTCVM's greatest landmarks. Gen 2 marks the beginning of not only a new design of SBTCVM's codebase, but a new chapter, for at the very least, SBTCVM. However, perhaps, balanced ternary will one day be more than a mere footnote in computer history, but a major player in computing, once again.
Looking on at 2019
Among the things being looked into just over the horizon, include quite a few topics..New programming languages:
SBTCVM already has 2 goto-label based languages, (SSTNPL, SBTCVM assembly), but its apparent that a greater variety of languages are needed. While most ideas involve compiled languages, a few are floating about involving interpreted languages, and line editors. not much to show for either, particularly the latter. (eekee's scal for Mark 2, and my clicalc for Gen2-9, are kinda close, but in reality they are just 2 different calculators...)
New Tools:
As more features get added, and as clever programmers take up SBTCVM's challenges, you might just find a growing list of tools, converters, editors, and other nifty things.
New APPs:
New Apps eh? like what? Well more games are almost a given, as both the mouse, and the plotter are yet to be exploited by them. and thats not even counting the tilemap graphics modes currently on the SBTGA drawing board.
However, its also to be expected to find a verity of new tools for various things. they may not all be as fast, nor as polished as the external utilities tend to become, but the important part is whether they work isn't it?
Looking Forward
Its with that, I wish everyone a happy new year, and hope not only SBTCVM's development, but your 2019 as well, goes great this year!And who knows, perhaps one day, balanced ternary will be, perhaps, a bit less obscure than it is today...
Sunday, December 23, 2018
Developers Notes - A Mery New Year And A Happy Holidays - 2018
Tis The season for many projects to
leave holiday greetings on their blogs isn't it?
What then, does this blog offer?
Well, take a look at some of the
fancy jolly footwork of SBTCVM's
enhanced color terminal!
We start with an older text demo that
was spruced up with some clever 3-color
block art wizardry and a nice green backdrop.
Here we find that our 3 eared
mascot is hiding among the
presents early Christmas morning.
I wonder what he may find?
What do you spot in this 27-color
25x81 splash of cheer?
Sunday, November 11, 2018
Gen 2 update: So many colors.
For the longest time, color was the domain of SBTCVM's old plotters and later, SBTGA. now the TTY has returned with a vengeance, in the pygame frontend.
View the dazzling 27-color 3-trit RGB color settings.
Yes! The packed art system has its own colors. Nice isn't it?
Also, the default packed art colors have lost the blue tint, falling back to white grey and black.
More information: tty colors documentation
View the dazzling 27-color 3-trit RGB color settings.
Yes! The packed art system has its own colors. Nice isn't it?
Also, the default packed art colors have lost the blue tint, falling back to white grey and black.
More information: tty colors documentation
Saturday, November 10, 2018
Gen 2 Update: ternary-packed-art encoding
You may be wondering what ternary has to do with art? or what those two have to do with encoding things?
Well, take a look at the screenshot to the right. Notice anything... odd?
That's right! its a curses/log-friendly scheme for terminal block art. its only 3 shades but its 9x more efficient than text art. The catch is: it can only output chunks of pixels 9 characters wide, and 1 character high.
However, an automated, pygame-based conversion tool has been added to the newly created gfxcon.py utility.
To learn more, see: ternary-packed-art documentation on GitHub.
Well, take a look at the screenshot to the right. Notice anything... odd?
That's right! its a curses/log-friendly scheme for terminal block art. its only 3 shades but its 9x more efficient than text art. The catch is: it can only output chunks of pixels 9 characters wide, and 1 character high.
However, an automated, pygame-based conversion tool has been added to the newly created gfxcon.py utility.
To learn more, see: ternary-packed-art documentation on GitHub.
Friday, November 9, 2018
Gen 2 update: pygame frontend
Overview
SBTCVM, for the longest time, used pygame for its frontend. From the first prototype, all the way to Gen 1's last major version: SBTCVM Mark 2Gen 2, however, has taken a more flexible approach. Already having a curses frontend, with a second, tk-based, frontend in planning.
Now, pygame has returned with the recent completion of the TTY emulation, and the basic structure of the pygame frontend's code.
![]() |
| PYG_SBTCVM.py SBTCVM's Pygame frontend. |
UI
Its UI is sparse, similar to other VM's and emulators with an SDL-based display, i.e. DOSBox.In the window title, we see that 3 eared mascot again *1, along with the trom name, and of course, "SBTCVM Gen2-9".
At the moment, only SBTGA v2 mode 0 is supported. If your wondering what that is, its the same TTY the curses frontend emulates.
When SBTGA does start getting implemented though, expect the window to adjust its size periodically.
Footnotes:
- You can find that icon, in its assorted sizes in VMSYSTEM/GFX
Wednesday, October 10, 2018
SSTNPL: tables and iterators
SSTNPL is already a handy language for basic mathematics, and with these 2 new features, it just got a whole lot more capable.
The actual algorithms used are based on work of a nifty new SSTNPL-based maze engine now available in 'APPS' directory in SBTCVM Gen 2's repository.
https://github.com/SBTCVM/SBTCVM-Gen2-9/blob/master/textdocs/SSTNPL/tables.txt
uiter & diter can iterate over a given range of integers (uiter going up from start to end, and diter going down from start to end)
https://github.com/SBTCVM/SBTCVM-Gen2-9/blob/master/textdocs/SSTNPL/iterate.txt
Tables:
SSTNPL now features a 2-axis static-size table system with data read-write.The actual algorithms used are based on work of a nifty new SSTNPL-based maze engine now available in 'APPS' directory in SBTCVM Gen 2's repository.
- read and write values with ease. (especially when paired with the other new SSTNPL feature mentioned below.)
- special macro read instructions for printing characters, ternary and decimal values.
- both raw-string and general data value table rows.
https://github.com/SBTCVM/SBTCVM-Gen2-9/blob/master/textdocs/SSTNPL/tables.txt
Iterators:
two handy iterator instructions. The main inspiration here is wanting an easy way to work with the new tables linearly, without winding up with insanely complex iterator code like what happened with that maze engine i mentioned above.uiter & diter can iterate over a given range of integers (uiter going up from start to end, and diter going down from start to end)
https://github.com/SBTCVM/SBTCVM-Gen2-9/blob/master/textdocs/SSTNPL/iterate.txt
Thursday, September 13, 2018
Gen 2 update: stacks n keyboards.
SBTCVM's CPU makes some progress, as the cpu is now equipped with a whopping 2 stacks.
Along with the cpu, SBTCVM Gen 2-9 is now capable of interactive programs, thanks to a new TTY Input device, that allows for a basic serial text interface.
Aside from the usual assembly enhancements, SSTNPL has gotten its share of changes too:
- you can now create variables based on character code values.
- you can read from the tty input buffer into a variable for easy parsing of keystrokes.
- return is now stackable.
- separate subroutine gotos are required to use return.
- conditional returns are now available.
Monday, August 13, 2018
SSTNPL
SBTCVM for the longest time, only had one programming language: SBTCVM Assembly. However, with Gen 2, that's going to change. In fact, it already has.
Presenting SSTNPL:
SBTCVM Simplified Ternary Numeric Programming Language.
Overall SSTNPL isn't ultra-high-level. For example: it supports in-line assembler and its loop and branching capacity is provided by several goto instructions.
Yea i know, the 'dreaded' goto. But SSTNPL isn't meant to be super abstracted. Its mainly meant as a lower-level language, that abstracts much of the VM's more detailed behaviors, while letting people experiment with them if they wish, and aren't ready to tackle the assembler head-on. It can also be handy for quick math algorithms.
Features:
- built upon a named-integer variable system
- both static, and equals, greater, and less than gotos. (goto, if, ifmore, ifless)
- addresses and memory are handled automatically, using the assembler's builtin variable system.
- simple, easy to follow, syntax.
- quick formatting commands like 'space' and 'newline' paired with the new print, and dumpd/dumpt integer dump commands, make outputting algorithm results a breeze.
https://github.com/SBTCVM/SBTCVM-Gen2-9
Thursday, July 26, 2018
Gen 2 update: 3 new additions to the assembler.
The assembler has grown a bit. Specifically, it has a header variable system, the new nsp framework, as well as the new xas framework. So... Whats all that mean?
source files traditionally had no say in how they were assembled in the past, thats where header variables come in. What they do does vary, however:
assembler mode
head-mode=trom, head-mode=vars
head-mode refers to the mode of the assembler. currently there are two possible values:
Rom Name
head-rname=<rom name>: override the trom output name. (excluding extension)
head-nspout=1: enables .nsp output for that source file. (excludes variables from other nsp files, as well as any builtin variables.
head-nspname=<nsp name>: override the nsp output name. (excluding extension)
head-nspin=<nsp name>: Import an nsp into an assembler file's namespace. you can use this namespace variable multiple times to import multiple .nsp files.
If all this .nsp nonsense sounds complicated, rest assured that one of its main purposes is to make some things easier.
Its main purpose isn't so very useful yet, but once Gen 2 gets a bit further along, its going to come in very handy.
Currently it has 4 commands:
SBTCVM Gen 2-9 repository:
https://github.com/SBTCVM/SBTCVM-Gen2-9
Header Variables.
source files traditionally had no say in how they were assembled in the past, thats where header variables come in. What they do does vary, however:
assembler mode
head-mode=trom, head-mode=vars
head-mode refers to the mode of the assembler. currently there are two possible values:
- trom: normal assembly (this mode will be chosen if head-mode is omitted.)
- vars: don't assemble a trom, but do handle nsp if enabled. (nsp is explained later in this post.)
Rom Name
head-rname=<rom name>: override the trom output name. (excluding extension)
SBTCVM Assembly Namespace (.nsp) files:
.nsp files allow you to use the namespace variables from one assembler source file (.tasm file) in another. here are the needed header variables to use them.head-nspout=1: enables .nsp output for that source file. (excludes variables from other nsp files, as well as any builtin variables.
head-nspname=<nsp name>: override the nsp output name. (excluding extension)
head-nspin=<nsp name>: Import an nsp into an assembler file's namespace. you can use this namespace variable multiple times to import multiple .nsp files.
If all this .nsp nonsense sounds complicated, rest assured that one of its main purposes is to make some things easier.
SBTCVM Assembly Script (XAS)
XAS is an assembly automation script system, that makes multi-source-file projects easy to assemble.Its main purpose isn't so very useful yet, but once Gen 2 gets a bit further along, its going to come in very handy.
Currently it has 4 commands:
- asm: takes name of tasm source file as argument. same as g2asm.py [source file]
- print: print argument to standard output.
- xas: run a xas script from within another xas script. takes script name as argument.
- exit: exit. takes no arguments
SBTCVM Gen 2-9 repository:
https://github.com/SBTCVM/SBTCVM-Gen2-9
Tuesday, July 3, 2018
tutorials: balanced ternary basics
If you happened across SBTCVM and/or Balanced Ternary someplace, and you are wondering what the heck a trit or tryte is, you are at the right place.
Lets start with the very basics:
balanced ternary, like regular ternary (base 3), has 3 digits.
Several notations exist for balanced ternary. the one you use often is best chosen for the circumstance. For example: +0- is supported by all versions of SBTCVM, while p0n is only supported by the newer SBTCVM Gen 2-9 VM, thats still in development.
Here is the number '8' in a few forms of balanced ternary notation:
+0-
p0n
still dont get it? lets count from -4 to +4
-- (nn) -4
-0 (n0) -3
-+ (np) -2
0- (0n) -1
00 (00) 0
0+ (0p) 1
+- (pn) 2
+0 (p0) 3
++ (pp) 4
here are some key terms:
Well. thats a good question! this brings me to another point:
Balanced ternary, like other balanced base numbers, have many subtle differences form bases like binary and decimal. for example: lets compare 8 trits & 8 bits
8 trits | 8 bits
MPI: 3280 | 255
MCV: 6561 | 256
Aside from balanced ternary knocking binary out of the park numerically, notice how with binary, the MPI and MCV equivalents are only 1 off, while in balanced ternary its 3281 off. why is this?
ok but why are MPI and MCV so different?
well. balanced ternary, like other balanced base numbers, is inherently signed. lets look at the combinations of 1 trit:
- (n) accounts for one MPI
0 (0) zero accounts for 1
+ (p) accounts for one MPI
this can be summed up into this formula:
n=length of trits
x=MPI(n)
y=MCV(n)
and then:
x+1+x=y
i.e.
x=MPI(3)=13
y=MCV(3)=27
x+1+x=y
13+1+13=y=27
Lets start with the very basics:
balanced ternary, like regular ternary (base 3), has 3 digits.
Several notations exist for balanced ternary. the one you use often is best chosen for the circumstance. For example: +0- is supported by all versions of SBTCVM, while p0n is only supported by the newer SBTCVM Gen 2-9 VM, thats still in development.
Here is the number '8' in a few forms of balanced ternary notation:
+0-
p0n
- Positive: (+,p) your familiar positive digit.
- Ground: (0) ground, or zero, is in the middle. but that's not even the most confusing bit.
- Negative: (-,n) this is the curve ball, and why 2 in balanced ternary is '+-'
still dont get it? lets count from -4 to +4
-- (nn) -4
-0 (n0) -3
-+ (np) -2
0- (0n) -1
00 (00) 0
0+ (0p) 1
+- (pn) 2
+0 (p0) 3
++ (pp) 4
here are some key terms:
- trit: a balanced ternary digit
- tryte: 6 balanced ternary digits
- KiloTryte (KT): 1093 trytes.
- Kilotrit (Kt): 1093 trits.
- MPI: Max positive integer: maximum positive value a length of trits can represent. ((3^n)-1)/2=MPI where n=length of trits
- MNI: Max negative integer: lowest value a length of trits can represent. is the opposite of MPI.
- MCV: Max combinations value: number of combinations in a length of trits. 3^n=MCV where n=length of trits
Well. thats a good question! this brings me to another point:
Balanced ternary, like other balanced base numbers, have many subtle differences form bases like binary and decimal. for example: lets compare 8 trits & 8 bits
8 trits | 8 bits
MPI: 3280 | 255
MCV: 6561 | 256
Aside from balanced ternary knocking binary out of the park numerically, notice how with binary, the MPI and MCV equivalents are only 1 off, while in balanced ternary its 3281 off. why is this?
ok but why are MPI and MCV so different?
well. balanced ternary, like other balanced base numbers, is inherently signed. lets look at the combinations of 1 trit:
- (n) accounts for one MPI
0 (0) zero accounts for 1
+ (p) accounts for one MPI
this can be summed up into this formula:
n=length of trits
x=MPI(n)
y=MCV(n)
and then:
x+1+x=y
i.e.
x=MPI(3)=13
y=MCV(3)=27
x+1+x=y
13+1+13=y=27
Subscribe to:
Posts (Atom)






