TEK 4010/4014 Vector Graphics terminal DEMO

Post your cool example code here.
ChrisMicro
Posts: 308
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by ChrisMicro » Mon Jul 24, 2017 4:02 pm

If you take a look into the TEK-Source I posted earlier in this thread, you can see in line 869 a description and the decoding of the GIN data.

There is a distinction of 2 cases:

Code: Select all

/*--------------------------------------------------------------------------*\
 * decode_gin()
 *
 * Decodes a GIN tek vector string into an xy pair of relative device
 * coordinates.  It's best to not use absolute device coordinates since the
 * coordinate bounds are different depending on the report encoding used.
 *
 * Standard:	<HiX><LoX><HiY><LoY>
 * Extended:	<HiY><Extra><LoY><HiX><LoX>
 * 
 * where <Extra> holds the two low order bits for each coordinate.
\*--------------------------------------------------------------------------*/

static void
decode_gin(char *c, PLGraphicsIn *gin)
{
    int x, y, lc = strlen(c);

    if (lc == 4) {
	x = ((c[0] & 0x1f) << 5) +
	    ((c[1] & 0x1f)     );

	y = ((c[2] & 0x1f) << 5) +
	    ((c[3] & 0x1f)     );

	gin->pX = x;
	gin->pY = y;
	gin->dX = x / (double) TEKX;
	gin->dY = y / (double) TEKY;
    }
    else if (lc == 5) {
	y = ((c[0] & 0x1f) << 7) +
	    ((c[2] & 0x1f) << 2) +
	    ((c[1] & 0x06) >> 2);

	x = ((c[3] & 0x1f) << 7) +
	    ((c[4] & 0x1f) << 2) +
	    ((c[1] & 0x03)     );

	gin->pX = x;
	gin->pY = y;
	gin->dX = x / (double) (TEKX << 2);
	gin->dY = y / (double) (TEKY << 2);
    }
    else {			/* Illegal encoding */
	gin->pX = 0;
	gin->pY = 0;
	gin->dY = 0;
	gin->dX = 0;
    }
}
It is a pity that it is so difficult to reuse this code because I think the implementation is very close to the spec.

User avatar
Pito
Posts: 1627
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by Pito » Mon Jul 24, 2017 4:57 pm

Look at my previous post, the best way is to read TTerm's source :)
Very nice written, easy to read. TT knows more than I expected :)
Frankly, I cannot find TTerm's help or documentation for TEK emulation options.. :?
So we have to read the sources.

From what I've read the GIN mode returns always 10bit values, even you are in 12bit mode..
TT does in the source:

Code: Select all

  ToggleCrossHair(tk,ts,FALSE);
  X = (int)((float)tk->GINX /
			(float)tk->ScreenWidth * (float)ViewSizeX);
  Y = (int)((1.0 - (float)(tk->GINY+1) /
			 (float)tk->ScreenHeight) * (float)ViewSizeY);
  Code[0] = KeyCode;
  Code[1] = (X >> 7) + 32;
  Code[2] = ((X >> 2) & 0x1f) + 32;
  Code[3] = (Y >> 7) + 32;
  Code[4] = ((Y >> 2) & 0x1f) + 32;
  Code[5] = 0x0d;
what is 10bits from max 12bit, afaik.

PS: I bet it can fill the areas with a color as well..
Pukao Hats Cleaning Services Ltd.

User avatar
Pito
Posts: 1627
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by Pito » Mon Jul 24, 2017 7:56 pm

This Mouse demo shows the returned coordinates. Coordinates work as expected.
I get "[36m20" as the mouse button return code - most probably an escape sequence.

UPDATE:
"[36m" is the escape code for cyan color.
When I changed to yellow, I got [33m - the escape code for yellow.
Thus it returns the actual active color. Interesting.. 8-)

The "0x20" is the code for "space", that is the default TEKGINMouseCode for left button (tterm .ini).
You may change it.

Code: Select all

// A simple TEK4010/4014 Vector terminal DEMO
// You need TeraTerm or Xterm switched to TEK4010/14 Emulation
//
// Use fast Serial over USB for best experience
//
//  Shows MOUSE activity and returned X and Y coordinates
//  You must click to get new X and Y
//
// Provided as-is, no warranties of any kind are provided :)
// by Pito 7/2017

#include "Arduino.h"
#include "Tek.h"

TEK tek;

void setup() {
  delay(3000);
  Serial.begin(115200);
}

void loop() {
  uint32_t i = 0;  
  char b0, b1, b2, b3, b4;
  uint16_t x = 0, y = 0, xo = 0, yo = 0;
  
  tek.Tekcls();
  tek.Tekcolor(cyan);
  
  while (1) {
    tek.Tekgin();
    if (Serial.available() > 0) b0 = Serial.read();
    if (Serial.available() > 0) b1 = Serial.read();
    if (Serial.available() > 0) b2 = Serial.read();
    if (Serial.available() > 0) b3 = Serial.read();
    if (Serial.available() > 0) b4 = Serial.read();
    x = 32 * (b1 - 32) + (b2 - 32);
    y = 32 * (b3 - 32) + (b4 - 32);
    tek.Tekalpha();
    tek.Tekfont(small);
    tek.Tekcolor(cyan);
    if ((x != xo) | (y != yo)) {
      Serial.print(b0, HEX);  // KeyCode
      Serial.print("   X=");
      Serial.print(x);
      Serial.print(" Y=");
      Serial.print(y);
      Serial.println();
      xo = x;
      yo = y;
      i++;
    }
    delay(100);
    if (i == 80) {
      tek.Tekcls();
      i = 0;
    }
  }
}
Tek Mouse.JPG
Tek Mouse.JPG (27.58 KiB) Viewed 248 times
.
When moving the crosshair to different places and pressing the keyboard's buttons, you get the Ascii codes of the buttons - see below the last 7 returned hexa values (after the [33m for yellow) came from "qwerty ".
Mouse keyboard keys codes.JPG
Mouse keyboard keys codes.JPG (35.59 KiB) Viewed 240 times
Last edited by Pito on Mon Jul 24, 2017 10:28 pm, edited 1 time in total.
Pukao Hats Cleaning Services Ltd.

User avatar
RogerClark
Posts: 7474
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by RogerClark » Mon Jul 24, 2017 10:28 pm

Thanks Pito

Can you tell me where it needs scientific notation text strings?

Is this for the coordinates or purely for visual text?

Also...
I think you said it does not do fills ??

Is this because the original hardware was a vectior display?

User avatar
Pito
Posts: 1627
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by Pito » Mon Jul 24, 2017 10:39 pm

@Roger, the scifi notation is needed only for printing out the results of user's calculations, not for coordinates.
The coordinates are always integers, 0..4095 for x and y.

The Tektronix 4010/4014 and others are basically very large oscilloscope tubes, with a very long afterglow.
The information painted into the phosphorus by the slim electron beam lasted for an hour at least, unless you did clean screen, which took about 1.5 seconds and the high voltage with the opposite polarity cleaned the charge (causing the glow of the lines) off the screen phosphorus.

Tek is an X-Y Plotter. The screen is like a sheet of paper in an X-Y plotter. The pen's tip is 1 pixel in diameter.
To fill a 300x300 large box with red color means to do 300 lines 300 pixels long.
Tek knows only a single graphical primitive - a line from (a,b) to (c,d).
In past the large surfaces where filled in with a gitter/mesh made of lines.
Last edited by Pito on Mon Jul 24, 2017 11:25 pm, edited 5 times in total.
Pukao Hats Cleaning Services Ltd.

User avatar
RogerClark
Posts: 7474
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by RogerClark » Mon Jul 24, 2017 10:44 pm

Thanks for the info.

I recall some early video games that also used vector displays.

Perhaps we can have Asteriods ;-)

User avatar
RogerClark
Posts: 7474
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by RogerClark » Mon Jul 24, 2017 10:49 pm

Another thought...

Is there a python based TEK emulator?

User avatar
Pito
Posts: 1627
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by Pito » Mon Jul 24, 2017 10:59 pm

I recall some early video games that also used vector displays.
Not only games, but all graphical systems since 50ties till late 70ties (CADs, military gadgets - radars, etc) were using these kind of vector displays.
In order to get 4096x4096 "resolution" (even it was not exactly such) in single color you would need 2Mbytes of video ram when talking a raster mode. That amount of ram was quite expensive at that time..
For example the Intel's 3101 64-bits ram cost $99 in mid 1969, $40 in 1970.
And you needed only one single 3101 chip for the Tek4014 :)
Pukao Hats Cleaning Services Ltd.

stevestrong
Posts: 1821
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by stevestrong » Mon Jul 24, 2017 11:43 pm

Regarding doing fills.
Maybe we can bring Tek to fill out a rectangle if we write a "space" character with the desired color and dimension at the desired coordinate.
Of course, this will only work for horizontally and vertically aligned fills.

User avatar
RogerClark
Posts: 7474
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: TEK 4010/4014 Vector Graphics terminal DEMO

Post by RogerClark » Tue Jul 25, 2017 12:20 am

BTW. I took a look for vector asteroids code

I can't find a definitive source but there is some interesting code in this blog

https://katyscode.wordpress.com/2012/06 ... s-or-less/

Post Reply