1
0
mirror of https://github.com/rricharz/Tek4010.git synced 2026-04-17 00:36:02 +00:00

Use space instead of tab and remove any trailing spaces (cosmetic changes)

This commit is purely cosmetic and 'git diff -b' does not show any changes
This commit is contained in:
hanyazou
2024-06-02 17:02:51 +09:00
parent 9c59624961
commit 0b1bc0e421
5 changed files with 427 additions and 427 deletions

54
apl/apltest.c vendored
View File

@@ -7,39 +7,39 @@
int main (int argc, char *argv[])
{
int ch, i;
int ch, i;
printf("\nStandard character set:\n");
printf("\nStandard character set:\n");
printf(" ");
for (i = 0; i < 10; i++) printf("%1d ",i);
for (ch = 30; ch <= 126; ch++) {
if ((ch % 10) == 0) {
printf("\n%03d ", ch);
}
if (ch > 32)
printf("%c ", ch);
else
printf(" ");
}
printf("\n");
for (i = 0; i < 10; i++) printf("%1d ",i);
for (ch = 30; ch <= 126; ch++) {
if ((ch % 10) == 0) {
printf("\n%03d ", ch);
}
if (ch > 32)
printf("%c ", ch);
else
printf(" ");
}
printf("\n");
printf("\nTektronix APL character set:\n");
putchar(27); putchar(14); // switch to alternative character set
printf(" ");
for (i = 0; i < 10; i++) printf("%1d ",i);
for (ch = 30; ch <= 126; ch++) {
if ((ch % 10) == 0) {
printf("\n%03d ", ch);
}
if (ch >32)
printf("%c ", ch);
else
printf(" ");
}
putchar(27); putchar(14); // switch to alternative character set
printf(" ");
for (i = 0; i < 10; i++) printf("%1d ",i);
for (ch = 30; ch <= 126; ch++) {
if ((ch % 10) == 0) {
printf("\n%03d ", ch);
}
if (ch >32)
printf("%c ", ch);
else
printf(" ");
}
printf("\n\noverstrike test");
putchar(62); putchar(32);
putchar(79); putchar(8); putchar(63); putchar(32);
putchar(76); putchar(8); putchar(43);
putchar(27); putchar(15); // switch back to standard character set
printf("\n");
putchar(27); putchar(15); // switch back to standard character set
printf("\n");
}

View File

@@ -1,32 +1,32 @@
/*
* ards.c
*
*
* ARDS option for tek4010 graphics emulator
*
*
* Copyright 2019 Lars Brinkhoff
*
*
* https://github.com/rricharz/Tek4010
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <sys/types.h>
@@ -77,40 +77,40 @@ static void draw_vector (cairo_t *cr, cairo_t *cr2)
void ards_draw(cairo_t *cr, cairo_t *cr2, int first)
// draw onto the main window using cairo
// cr is used for persistent drawing, cr2 for temporary drawing
// cr is used for persistent drawing, cr2 for temporary drawing
{
{
int ch;
refreshCount++; // to calculate the average refresh rate
if (first) {
first = 0;
efactor = windowWidth / 1080.0;
// fprintf (stderr, "efactor: %0.2f\n", efactor);
refresh_interval = 50;
refresh_interval = 50;
tube_changeCharacterSize(cr, cr2, 80, 50, efactor * 1.1);
}
startPaintTime = tube_mSeconds(); // start to measure time for this draw operation
showCursor = 1;
isBrightSpot = 0;
// clear the second surface
tube_clearSecond(cr2);
// clear persistent surface, if necessary
if (tube_doClearPersistent) {
tube_clearPersistent(cr,cr2);
}
tube_setupPainting(cr, cr2, STANDARD_FONT);
do {
ch = tube_getInputChar();
if (tube_isInput() == 0) {
}
@@ -118,123 +118,123 @@ void ards_draw(cairo_t *cr, cairo_t *cr2, int first)
return; // no char available, need to allow for updates
}
//fprintf (stderr, "\n[INPUT %03o [%d/%d]]", ch, mode, args);
//fprintf (stderr, "\n[INPUT %03o [%d/%d]]", ch, mode, args);
if (args > 0) {
data[--args] = ch;
}
if (args > 0) {
data[--args] = ch;
}
switch (ch) {
case 007:
mode = 0;
args = 0;
break;
case 010:
mode = 0;
args = 0;
x0 -= hDotsPerChar;
break;
case 012:
mode = 0;
args = 0;
y0 -= vDotsPerChar;
break;
case 014:
mode = 0;
args = 0;
x0 = -485;
y0 = 450;
tube_clearPersistent(cr, cr2);
break;
case 015:
mode = 0;
args = 0;
x0 = -479;
break;
case 034:
mode = 0;
args = 0;
break;
case 035:
//fprintf (stderr, "[POINT]");
mode = 1;
args = 4;
break;
case 036:
//fprintf (stderr, "[E VEC]");
mode = 2;
args = 4;
break;
case 037:
//fprintf (stderr, "[S VEC]");
mode = 3;
args = 2;
break;
default:
if (args == 0) {
switch (mode) {
case 0:
//fprintf (stderr, "[SYMBOL %c @ %d, %d]", ch, x0, y0);
draw_char (cr, cr2, ch);
break;
case 1:
args = 4;
x0 = (data[3] & 076) >> 1;
x0 |= (data[2] & 037) << 5;
if (data[3] & 1)
x0 = -x0;
y0 = (data[1] & 076) >> 1;
y0 |= (data[0] & 037) << 5;
if (data[1] & 1)
y0 = -y0;
//fprintf (stderr, "[POINT @ %d, %d]", x0, y0);
break;
case 2:
args = 4;
x2 = (data[3] & 076) >> 1;
x2 |= (data[2] & 037) << 5;
if (data[3] & 1)
x2 = -x2;
x2 += x0;
y2 = (data[1] & 076) >> 1;
y2 |= (data[0] & 037) << 5;
if (data[1] & 1)
y2 = -y2;
y2 += y0;
//fprintf (stderr, "[E VEC @ %d,%d - %d,%d]", x0, y0, x2, y2);
if (data[2] & 040)
; //fprintf (stderr, "[INVISIBLE]");
else
draw_vector(cr, cr2);
if (data[0] & 040)
; //fprintf (stderr, "[DOTTED]");
x0 = x2;
y0 = y2;
break;
case 3:
args = 2;
x2 = (data[1] & 076) >> 1;
if (data[1] & 1)
x2 = -x2;
x2 += x0;
y2 = (data[0] & 076) >> 1;
if (data[0] & 1)
y2 = -y2;
y2 += y0;
draw_vector(cr, cr2);
//fprintf (stderr, "[S VEC @ %d,%d - %d,%d]", x0, y0, x2, y2);
x0 = x2;
y0 = y2;
break;
}
}
break;
}
switch (ch) {
case 007:
mode = 0;
args = 0;
break;
case 010:
mode = 0;
args = 0;
x0 -= hDotsPerChar;
break;
case 012:
mode = 0;
args = 0;
y0 -= vDotsPerChar;
break;
case 014:
mode = 0;
args = 0;
x0 = -485;
y0 = 450;
tube_clearPersistent(cr, cr2);
break;
case 015:
mode = 0;
args = 0;
x0 = -479;
break;
case 034:
mode = 0;
args = 0;
break;
case 035:
//fprintf (stderr, "[POINT]");
mode = 1;
args = 4;
break;
case 036:
//fprintf (stderr, "[E VEC]");
mode = 2;
args = 4;
break;
case 037:
//fprintf (stderr, "[S VEC]");
mode = 3;
args = 2;
break;
default:
if (args == 0) {
switch (mode) {
case 0:
//fprintf (stderr, "[SYMBOL %c @ %d, %d]", ch, x0, y0);
draw_char (cr, cr2, ch);
break;
case 1:
args = 4;
x0 = (data[3] & 076) >> 1;
x0 |= (data[2] & 037) << 5;
if (data[3] & 1)
x0 = -x0;
y0 = (data[1] & 076) >> 1;
y0 |= (data[0] & 037) << 5;
if (data[1] & 1)
y0 = -y0;
//fprintf (stderr, "[POINT @ %d, %d]", x0, y0);
break;
case 2:
args = 4;
x2 = (data[3] & 076) >> 1;
x2 |= (data[2] & 037) << 5;
if (data[3] & 1)
x2 = -x2;
x2 += x0;
y2 = (data[1] & 076) >> 1;
y2 |= (data[0] & 037) << 5;
if (data[1] & 1)
y2 = -y2;
y2 += y0;
//fprintf (stderr, "[E VEC @ %d,%d - %d,%d]", x0, y0, x2, y2);
if (data[2] & 040)
; //fprintf (stderr, "[INVISIBLE]");
else
draw_vector(cr, cr2);
if (data[0] & 040)
; //fprintf (stderr, "[DOTTED]");
x0 = x2;
y0 = y2;
break;
case 3:
args = 2;
x2 = (data[1] & 076) >> 1;
if (data[1] & 1)
x2 = -x2;
x2 += x0;
y2 = (data[0] & 076) >> 1;
if (data[0] & 1)
y2 = -y2;
y2 += y0;
draw_vector(cr, cr2);
//fprintf (stderr, "[S VEC @ %d,%d - %d,%d]", x0, y0, x2, y2);
x0 = x2;
y0 = y2;
break;
}
}
break;
}
}
while (((tube_mSeconds() - startPaintTime) < refresh_interval));
// display cursor
if (showCursor && (tube_isInput() == 0)) tube_doCursor(cr2);
}

View File

@@ -2,33 +2,33 @@
*
* main.c
* provides a simple framework for basic drawing with cairo and gtk+ 3.0
*
*
* Version adapted for tek4010
*
*
* Copyright 2016,2019 rricharz
*
* https://github.com/rricharz/Tek4010
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*
*
*
*/
#define TIME_INTERVAL 35 // time interval for timer function in msec (after last refresh)
#define GDK_DISABLE_DEPRECATION_WARNINGS
#include <stdio.h>
@@ -63,18 +63,18 @@ extern int tube_doClearPersistent;
static void do_drawing(cairo_t *, GtkWidget *);
static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr,
static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr,
gpointer user_data)
{
do_drawing(cr, widget);
return FALSE;
{
do_drawing(cr, widget);
return FALSE;
}
static gboolean on_timer_event(GtkWidget *widget)
{
if (tube_on_timer_event())
if (tube_on_timer_event())
gtk_widget_queue_draw(widget);
return TRUE;
return TRUE;
}
static gboolean clicked(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
@@ -86,22 +86,22 @@ static gboolean clicked(GtkWidget *widget, GdkEventButton *event, gpointer user_
static void on_quit_event()
{
tube_quit();
gtk_main_quit();
tube_quit();
gtk_main_quit();
exit(0);
}
static void do_drawing(cairo_t *cr, GtkWidget *widget)
{
static cairo_surface_t *permanent_surface, *temporary_surface;
g_source_remove(global_timeout_ref); // stop timer, in case do_drawing takes too long
if (global_firstcall) {
if (global_firstcall) {
// force aspect ratio by making black stripes at left and right, or top and bottom
gtk_window_get_size(GTK_WINDOW(window), &windowWidth, &windowHeight);
// gtk_window_set_resizable(GTK_WINDOW(window), 0); // do not allow further resizing
if ((windowWidth != 1024) || (windowHeight != 768)) {
if (windowWidth > (int)((double)windowHeight * aspectRatio + 0.5)) {
windowWidthOffset = (windowWidth - (int)((double)windowHeight * aspectRatio)) / 2;
@@ -114,19 +114,19 @@ static void do_drawing(cairo_t *cr, GtkWidget *widget)
}
printf("Window dimensions: %d x %d\n", windowWidth, windowHeight);
permanent_surface = cairo_surface_create_similar(cairo_get_target(cr),
CAIRO_CONTENT_COLOR, windowWidth, windowHeight);
permanent_surface = cairo_surface_create_similar(cairo_get_target(cr),
CAIRO_CONTENT_COLOR, windowWidth, windowHeight);
temporary_surface = cairo_surface_create_similar(cairo_get_target(cr),
CAIRO_CONTENT_COLOR_ALPHA, windowWidth, windowHeight);
CAIRO_CONTENT_COLOR_ALPHA, windowWidth, windowHeight);
if (argHideCursor) { // hide cursor (does not allow GIN mode)
GdkCursor* Cursor = gdk_cursor_new(GDK_BLANK_CURSOR);
GdkWindow* win = gtk_widget_get_window(window);
gdk_window_set_cursor((win), Cursor);
}
}
cairo_t *permanent_cr = cairo_create(permanent_surface);
}
cairo_t *permanent_cr = cairo_create(permanent_surface);
cairo_t *temporary_cr = cairo_create(temporary_surface);
if ((permanent_cr == NULL) || (temporary_cr == NULL)) {
printf("Cannot create drawing surfaces\n");
@@ -136,10 +136,10 @@ static void do_drawing(cairo_t *cr, GtkWidget *widget)
ards_draw(permanent_cr, temporary_cr, global_firstcall);
else
tek4010_draw(permanent_cr, temporary_cr, global_firstcall);
global_firstcall = FALSE;
global_firstcall = FALSE;
cairo_set_source_surface(cr, permanent_surface, windowWidthOffset, windowHeightOffset);
cairo_paint(cr);
cairo_set_source_surface(cr, permanent_surface, windowWidthOffset, windowHeightOffset);
cairo_paint(cr);
if (argFast) {
cairo_set_source_surface(cr, temporary_surface, windowWidthOffset, windowHeightOffset);
cairo_paint(cr);
@@ -150,8 +150,8 @@ static void do_drawing(cairo_t *cr, GtkWidget *widget)
cairo_paint(cr);
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
}
cairo_destroy(permanent_cr);
cairo_destroy(permanent_cr);
cairo_destroy(temporary_cr);
global_timeout_ref = g_timeout_add(TIME_INTERVAL, (GSourceFunc) on_timer_event,
(gpointer) window);
@@ -161,16 +161,16 @@ static void on_key_press(GtkWidget *widget, GdkEventKey *event, gpointer user_da
{
int ch;
// printf("key pressed, state =%04X, keyval=%04X, isGinMode = %d\r\n", event->state, event->keyval, isGinMode);
if ((event->keyval == 0xFF50) || // "home" key
(event->keyval == 0xFF55) || // "page up" key
(event->keyval == 0xFF56)) // "page down" key
(event->keyval == 0xFF56)) // "page down" key
{
tube_doClearPersistent = 1;
gtk_widget_queue_draw(widget);
return;
}
if (event->keyval == 0x8BF) { // "option b" sends break code to target
if (putKeys) {
printf("sending break code\n");
@@ -178,7 +178,7 @@ static void on_key_press(GtkWidget *widget, GdkEventKey *event, gpointer user_da
putc(0xF3, putKeys);
}
}
// control keys
else if ((event->keyval >= 0xFF00) && (event->keyval <= 0xFF1F))
ch = event->keyval & 0x1F;
@@ -206,29 +206,29 @@ static void on_key_press(GtkWidget *widget, GdkEventKey *event, gpointer user_da
aplMode = 0;
// printf("Setting APL mode to 0 from keyboard\n");
return;
}
}
else
ch = event->keyval & 0x1F;
}
else if (event->keyval == 0xFF52) ch = 16; // arrow up for history up
else if (event->keyval == 0xFF54) ch = 14; // arrow down for history down
else if ((event->state & GDK_MOD1_MASK) && (aplMode)) { // alt key
printf("alt key, ch = %4X\n", event->keyval & 0x7F);
ch = (event->keyval & 0x7F) + 128;
}
// normal keys
else if ((event->keyval >= 0x0020) && (event->keyval <= 0x007F))
ch = event->keyval & 0x7F;
else return;
if (isGinMode) { // need to pass key to GIN mode handling, not to child process
isGinMode = ch;
gtk_widget_queue_draw(widget);
}
else if (putKeys) {
// pipe key to child process, if stream open
if (aplMode) {
@@ -246,18 +246,18 @@ static void on_key_press(GtkWidget *widget, GdkEventKey *event, gpointer user_da
int main (int argc, char *argv[])
{
GtkWidget *darea;
GtkWidget *darea;
int askWindowWidth;
int askWindowHeight;
tube_init(argc, argv);
if (argARDS) {
askWindowWidth = 1080;
askWindowHeight = 1414;
askWindowHeight = 1414;
}
else if (argFull) {
askWindowWidth = 4096;
askWindowHeight = 3120;
@@ -266,15 +266,15 @@ int main (int argc, char *argv[])
askWindowWidth = 1024;
askWindowHeight = 780;
}
aspectRatio = (double)askWindowWidth / (double)askWindowHeight;
gtk_init(&argc, &argv);
global_firstcall = TRUE;
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
aspectRatio = (double)askWindowWidth / (double)askWindowHeight;
gtk_init(&argc, &argv);
global_firstcall = TRUE;
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
// set the background color
GdkColor color;
color.red = 0;
@@ -282,31 +282,31 @@ int main (int argc, char *argv[])
color.blue = 0;
gtk_widget_modify_bg(window, GTK_STATE_NORMAL, &color);
darea = gtk_drawing_area_new();
gtk_container_add(GTK_CONTAINER(window), darea);
gtk_widget_add_events(window, GDK_BUTTON_PRESS_MASK);
darea = gtk_drawing_area_new();
gtk_container_add(GTK_CONTAINER(window), darea);
gtk_widget_add_events(window, GDK_BUTTON_PRESS_MASK);
gtk_widget_add_events(window, GDK_KEY_PRESS_MASK);
gtk_widget_set_events(darea,gtk_widget_get_events(darea) | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK);
g_signal_connect(G_OBJECT(darea), "draw", G_CALLBACK(on_draw_event), NULL);
g_signal_connect(G_OBJECT(darea), "destroy", G_CALLBACK(on_quit_event), NULL);
g_signal_connect(G_OBJECT(darea), "button-press-event", G_CALLBACK(clicked), NULL);
g_signal_connect(G_OBJECT(darea), "draw", G_CALLBACK(on_draw_event), NULL);
g_signal_connect(G_OBJECT(darea), "destroy", G_CALLBACK(on_quit_event), NULL);
g_signal_connect(G_OBJECT(darea), "button-press-event", G_CALLBACK(clicked), NULL);
g_signal_connect(G_OBJECT(window), "key_press_event", G_CALLBACK(on_key_press), NULL);
GdkScreen *screen = gtk_window_get_screen(GTK_WINDOW(window));
int screenWidth = gdk_screen_get_width(screen);
int screenHeight = gdk_screen_get_height(screen);
printf("Screen dimensions: %d x %d\n", screenWidth, screenHeight);
if (argFull) {
int screenWidth = gdk_screen_get_width(screen);
int screenHeight = gdk_screen_get_height(screen);
printf("Screen dimensions: %d x %d\n", screenWidth, screenHeight);
if (argFull) {
// DISPLAY UNDECORATED FULL SCREEN WINDOW
gtk_window_set_decorated(GTK_WINDOW(window), FALSE);
gtk_window_fullscreen(GTK_WINDOW(window));
gtk_window_set_keep_above(GTK_WINDOW(window), FALSE);
windowWidth = screenWidth;
windowHeight = screenHeight;
gtk_window_set_decorated(GTK_WINDOW(window), FALSE);
gtk_window_fullscreen(GTK_WINDOW(window));
gtk_window_set_keep_above(GTK_WINDOW(window), FALSE);
windowWidth = screenWidth;
windowHeight = screenHeight;
}
else {
// DISPLAY DECORATED WINDOW
if (argFullV || (askWindowHeight > (screenHeight - BORDER))) {
@@ -316,23 +316,23 @@ int main (int argc, char *argv[])
gtk_window_set_decorated(GTK_WINDOW(window), TRUE);
gtk_window_set_default_size(GTK_WINDOW(window), askWindowWidth, askWindowHeight);
windowWidth = askWindowWidth;
windowHeight = askWindowHeight;
windowHeight = askWindowHeight;
}
// printf("Requested window dimensions: %d x %d\n", windowWidth, windowHeight);
if (TIME_INTERVAL > 0) {
// Add timer event
// Register the timer and set time in mS.
// The timer_event() function is called repeatedly until it returns FALSE.
global_timeout_ref = g_timeout_add(TIME_INTERVAL, (GSourceFunc) on_timer_event,
// Add timer event
// Register the timer and set time in mS.
// The timer_event() function is called repeatedly until it returns FALSE.
global_timeout_ref = g_timeout_add(TIME_INTERVAL, (GSourceFunc) on_timer_event,
(gpointer) window);
}
}
gtk_window_set_title(GTK_WINDOW(window), windowName);
gtk_widget_show_all(window);
gtk_window_set_title(GTK_WINDOW(window), windowName);
gtk_main();
gtk_widget_show_all(window);
return 0;
gtk_main();
return 0;
}

View File

@@ -1,39 +1,39 @@
/*
* tek4010.c
*
*
* A tek4010/4014 graphics emulator
*
*
* Copyright 2019 rricharz
*
*
* https://github.com/rricharz/Tek4010
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*/
#define DEBUG 0 // print debug info
#define TODO (long)(32) // draw multiple objects until screen updates
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <sys/types.h>
@@ -87,14 +87,14 @@ int intensityTable[] = {14,16,17,19, 20,22,23,25, 28,31,34,38, 41,33,47,50,
4, 4, 4, 5, 5, 5, 6, 6, 7, 8, 9,10, 11,12,12,13,
14,16,17,19, 20,22,23,25, 28,31,34,38, 41,44,47,50,
56,62,69,75, 81,88,94,100, 56,63,69,75, 81,88};
void tek4010_checkLimits(cairo_t *cr, cairo_t *cr2)
/* check whether char is in visibel space */
{
/* don't check here for leftmargin, graphics needs to write characters to the whole screen */
if (tube_x0 < 0) tube_x0 = 0;
if (tube_x0 > windowWidth - hDotsPerChar) {
tube_x0 = leftmargin; tube_y0 -= vDotsPerChar;
}
@@ -127,9 +127,9 @@ void sendCoordinates()
int x,y,ch;
x = (int)((double)tube_x0 / efactor);
y = (int)((double)tube_y0 / efactor);
if (DEBUG) printf("sendCoordinates, x=%d, y=%d\n", x, y);
ch = (x >> 5) + 0x20;
putc(ch, putKeys);
ginCharacter[4] = ch; // save to check for echo
@@ -153,7 +153,7 @@ void enqMode()
if (mode == 0) status += 4;
putc(status,putKeys); // send status byte
sendCoordinates();
putc(13, putKeys); // cannot send a EOT here
putc(13, putKeys); // cannot send a EOT here
}
void ginMode(cairo_t *cr, cairo_t *cr2)
@@ -180,7 +180,7 @@ void ginSend(int ch)
putc(13,putKeys); // cr
ginCharacter[0] = 13;
// prepare to suppress unwanted echoed characters.
isGinSuppress = 6;
isGinSuppress = 6;
}
void tek4010_clicked(int x, int y)
@@ -204,7 +204,7 @@ void tek4010_escapeCodeHandler(cairo_t *cr, cairo_t *cr2, int ch)
enqMode();
mode = 0; break;
case 6: break;
case 8: // backspace during ESC
tube_x0 -= hDotsPerChar;
tek4010_checkLimits(cr, cr2);
@@ -241,13 +241,13 @@ void tek4010_escapeCodeHandler(cairo_t *cr, cairo_t *cr2, int ch)
todo = 0;
// printf("Setting APL mode to 0 from computer\n");
break;
case 23: system("scrot --focussed"); mode= 0; break;
case 26: // sub
ginMode(cr, cr2);
break;
// modes 27 and 29 - 31 are identical in all modes
case 28: // record separator
if (DEBUG) printf("Special point plot mode, mode=%d\n",savemode);
@@ -262,11 +262,11 @@ void tek4010_escapeCodeHandler(cairo_t *cr, cairo_t *cr2, int ch)
case '9': tube_changeCharacterSize(cr, cr2, 81, 38, efactor * 0.9); mode = 0; break;
case ':': tube_changeCharacterSize(cr, cr2, 121, 58, efactor * 0.65); mode = 0; break;
case ';': tube_changeCharacterSize(cr, cr2, 133, 64, efactor * 0.55); mode = 0; break;
case '[': printf("Ignoring ANSI escape sequence: [");
mode=31;
break;
// normal mode
case '`': ltype = SOLID; writeThroughMode = 0; mode = savemode; break;
case 'a': ltype = DOTTED; writeThroughMode = 0; mode = savemode; break;
@@ -274,12 +274,12 @@ void tek4010_escapeCodeHandler(cairo_t *cr, cairo_t *cr2, int ch)
case 'c': ltype = SHORTDASH;writeThroughMode = 0; mode = savemode; break;
case 'd': ltype = LONGDASH; writeThroughMode = 0; mode = savemode; break;
case 'e': ltype = SOLID; writeThroughMode = 0; mode = savemode; break;
case 'f': ltype = SOLID; writeThroughMode = 0; mode = savemode; break;
case 'f': ltype = SOLID; writeThroughMode = 0; mode = savemode; break;
case 'g': ltype = SOLID; writeThroughMode = 0; mode = savemode; break;
// defocussed mode
case 'h':
case 'i':
case 'i':
case 'j':
case 'k':
case 'l':
@@ -287,7 +287,7 @@ void tek4010_escapeCodeHandler(cairo_t *cr, cairo_t *cr2, int ch)
case 'n':
case 'o': if (DEBUG) printf("Defocussed mode ESC %c not supported, ignored\n", ch);
mode = 101; break;
// write-trough mode
case 'p': ltype = SOLID; writeThroughMode = 1; mode = 101; showCursor = 0; break;
case 'q': ltype = DOTTED; writeThroughMode = 1; mode = 101; showCursor = 0; break;
@@ -296,13 +296,13 @@ void tek4010_escapeCodeHandler(cairo_t *cr, cairo_t *cr2, int ch)
case 't': ltype = LONGDASH; writeThroughMode = 1; mode = 101; showCursor = 0; break;
case 'u': ltype = SOLID; writeThroughMode = 1; mode = 101; showCursor = 0; break;
case 'v': ltype = SOLID; writeThroughMode = 1; mode = 101; showCursor = 0; break;
case 'w': ltype = SOLID; writeThroughMode = 1; mode = 101; showCursor = 0; break;
default:
case 'w': ltype = SOLID; writeThroughMode = 1; mode = 101; showCursor = 0; break;
default:
printf("Ignoring escape code: 0x%02x\n",ch);
mode = 0;
break;
}
break;
}
}
int tek4010_checkReturnToAlpha(int ch)
@@ -340,42 +340,42 @@ int digit(char ch)
void tek4010_draw(cairo_t *cr, cairo_t *cr2, int first)
// draw onto the main window using cairo
// cr is used for persistent drawing, cr2 for temporary drawing
// cr is used for persistent drawing, cr2 for temporary drawing
{
{
int ch, tag;
refreshCount++;
if (first) {
first = 0;
first = 0;
efactor = windowWidth / 1024.0;
refresh_interval = 50;
tube_changeCharacterSize(cr, cr2, 74, 35, efactor);
if (efactor > 0.8) pensize = efactor * 1.25;
if (windowWidth != 1024) printf("Scaling: %0.3f\n", efactor / 4.0);
}
startPaintTime = tube_mSeconds(); // start to measure time for this draw operation
showCursor = 1;
isBrightSpot = 0;
// clear the second surface
tube_clearSecond(cr2);
// clear persistent surface, if necessary
if (tube_doClearPersistent) {
tube_clearPersistent(cr,cr2);
if (!argKeepSize)
tube_changeCharacterSize(cr, cr2, 74, 35, efactor);
}
if (aplMode)
tube_setupPainting(cr, cr2, APL_FONT);
else
tube_setupPainting(cr, cr2, STANDARD_FONT);
if (plotPointMode)
todo = 100 * TODO;
else if (writeThroughMode)
@@ -387,18 +387,18 @@ void tek4010_draw(cairo_t *cr, cairo_t *cr2, int first)
do {
ch = tube_getInputChar();
if (tube_isInput() == 0) {
todo = 0;
}
if (ch == -1) {
if ((mode == 0) && showCursor) tube_doCursor(cr2);
if (mode != 60) return; // no char available, need to allow for updates
}
// Try suppressing GIN echoed characters here.
if (isGinSuppress){
// Try suppressing GIN echoed characters here.
if (isGinSuppress){
if (ch == 10) // additional line feed may be echoed if cr is typed
return;
if ((ch & 0x7F) == ginCharacter[isGinSuppress - 1]) {
@@ -412,10 +412,10 @@ void tek4010_draw(cairo_t *cr, cairo_t *cr2, int first)
ch & 0x7F, ginCharacter[isGinSuppress - 1]);
isGinSuppress = 0;
}
}
}
// if (aplMode) printf("Receiving character %d from host\n", ch);
if (DEBUG) {
printf("mode=%d, ch code %02X",mode,ch);
if ((ch>0x20)&&(ch<=0x7E)) printf(" (%c)",ch);
@@ -429,9 +429,9 @@ void tek4010_draw(cairo_t *cr, cairo_t *cr2, int first)
// the following chars are identical in all modes (with exception: 13,28)
// see 4014 user manual, table on page G1 ff
switch (ch) {
case 7: tek4010_bell();
case 7: tek4010_bell();
goto endDo;
case 10: // new line
tube_y0 -= vDotsPerChar;
@@ -446,8 +446,8 @@ void tek4010_draw(cairo_t *cr, cairo_t *cr2, int first)
break;
case 27: // escape code, all modes
savemode = mode;
mode = 30;
goto endDo;
mode = 30;
goto endDo;
case 28: // file separator >> point plot mode
if (mode != 30) { // special handling in ESC mode
mode = 5;
@@ -468,22 +468,22 @@ void tek4010_draw(cairo_t *cr, cairo_t *cr2, int first)
mode = 0;
goto endDo;
}
// handle skipping coordinate bytes
// this cannot be done in switch(mode) below, because multiple bytes
// can be skipped and the current byte must be executed after a mode change
tag = (ch >> 5) & 3;
if ((mode >= 1) && (mode <= 8)) {
if ((mode == 5) && (ch == 29)) {
if (DEBUG) printf("group separator, go from mode 5 to mode 1\n");
mode = 1;
goto endDo; // goto end of do loop
}
if (DEBUG) {
if (mode & 1)
printf(" mode=%d,tag=%d-H-val=%d,",
@@ -491,13 +491,13 @@ void tek4010_draw(cairo_t *cr, cairo_t *cr2, int first)
else
printf(" mode=%d,tag=%d-L-val=%d,",
mode,tag, ch & 31);
printf("xh=%d,xl=%d,yh=%d,yl=%d\n",xh,xl,yh,yl);
printf("xh=%d,xl=%d,yh=%d,yl=%d\n",xh,xl,yh,yl);
}
if (tag != 0) {
if ((mode == 1) && (tag != 1)) mode = 2;
if ((mode == 3) && (tag == 3)) {
// this overwrites the extra data byte of the 4014 for the
// persistent mode coordinates and stores it for further use
@@ -506,11 +506,11 @@ void tek4010_draw(cairo_t *cr, cairo_t *cr2, int first)
if (DEBUG)
printf("4014 coordinates, overwrite last value\n");
}
if ((mode == 2) && (tag != 3)) mode = 3;
if ((mode == 3) && (tag != 1)) mode = 4;
if ((mode == 5) && (tag != 1)) mode = 6;
if ((mode == 5) && (tag != 1)) mode = 6;
if ((mode == 7) && (tag == 3)) {
// this overwrites the extra data byte of the 4014 for the
@@ -520,8 +520,8 @@ void tek4010_draw(cairo_t *cr, cairo_t *cr2, int first)
if (DEBUG)
printf("4014 coordinates, overwrite last value\n");
}
if ((mode == 6) && (tag != 3)) mode = 7;
if ((mode == 6) && (tag != 3)) mode = 7;
if ((mode == 7) && (tag != 1)) mode = 8;
}
else {
@@ -531,13 +531,13 @@ void tek4010_draw(cairo_t *cr, cairo_t *cr2, int first)
else if (DEBUG) printf("Plot mode, unknown char %d, plotPointMode = %d\n",ch,plotPointMode);
return;
}
}
// handling anything specific to a mode
switch (mode) {
switch (mode) {
case 1: plotPointMode = 0; // normal graphics mode, starting coordinates
yh = 32 * (ch & 31); mode++;
if (DEBUG) printf("setting yh to %d\n", yh);
@@ -593,27 +593,27 @@ void tek4010_draw(cairo_t *cr, cairo_t *cr2, int first)
tube_y2 = yh + yl;
}
if (DEBUG) printf(">>>>>xl=%d\n",xl);
if (plotPointMode>0.0) {
// draw the point
tube_drawPoint(cr, cr2);
todo--;
}
else {
tube_drawVector(cr,cr2);
todo--;
todo--;
}
showCursor = 0;
tube_x0 = tube_x2; // prepare for additional vectors
tube_y0 = tube_y2;
if (specialPlotMode) mode = 50; // another intensity/focus char follows
else mode = 5;
if (specialPlotMode) mode = 50; // another intensity/focus char follows
else mode = 5;
break;
case 30: // escape code handler
tek4010_escapeCodeHandler(cr, cr2, ch);
@@ -639,7 +639,7 @@ void tek4010_draw(cairo_t *cr, cairo_t *cr2, int first)
tube_y2 = tube_y0;
if (penDown) tube_drawPoint(cr, cr2);
}
else if (DEBUG) printf("Illegal byte 0x%02X in incremental plot\n", ch);
else if (DEBUG) printf("Illegal byte 0x%02X in incremental plot\n", ch);
break;
case 50:// special plot mode
tag = ch >> 5;
@@ -648,7 +648,7 @@ void tek4010_draw(cairo_t *cr, cairo_t *cr2, int first)
defocussed = (tag == 1);
intensity = intensityTable[ch - 32];
if (DEBUG) printf("defocussed = %d, intensity = %d%%\n", defocussed, intensity);
mode = 5; // coordinates follow
mode = 5; // coordinates follow
break;
case 60:// crosshair mode
if (isGinMode > 1) { // key stroken by user
@@ -661,7 +661,7 @@ void tek4010_draw(cairo_t *cr, cairo_t *cr2, int first)
else
ginMode(cr, cr2);
break;
case 101:
case 101:
if (DEBUG) printf("Ignore until group separator, ch = %02x\n", ch);
if (ch == 29) mode = 1;
break;
@@ -690,7 +690,7 @@ void tek4010_draw(cairo_t *cr, cairo_t *cr2, int first)
default: if ((ch >= 32) && (ch <127)) { // printable character
tek4010_checkLimits(cr, cr2);
tube_drawCharacter(cr,cr2, ch);
tube_drawCharacter(cr,cr2, ch);
todo-= 2;
}
break;
@@ -702,9 +702,9 @@ void tek4010_draw(cairo_t *cr, cairo_t *cr2, int first)
endDo:;
}
while ((todo > 0) && ((tube_mSeconds() - startPaintTime) < refresh_interval));
// display cursor
if (showCursor && (tube_isInput() == 0)) tube_doCursor(cr2);
}

View File

@@ -1,44 +1,44 @@
/*
* tube.c
*
*
* A tek4010/4014 graphics emulator
*
*
* Copyright 2019 rricharz
*
*
* https://github.com/rricharz/Tek4010
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301, USA.
*
*/
#define DEBUG 0 // print debug info
#define DEBUGMAX 0 // exit after DEBUGMAX chars, 0 means no exit
#define WRITE_TROUGH_INTENSITY 0.5 // green only
#define NORMAL_INTENSITY 0.7 // green only
#define CURSOR_INTENSITY 0.7 // green only
#define BRIGHT_SPOT_INTENSITY 1.0 // light green
#define BRIGHT_SPOT_INTENSITY 1.0 // light green
#define BLACK_INTENSITY 0.08 // effect of flood gun
#define FADE 0.3 // lower value means slower fading
#define FADE 0.3 // lower value means slower fading
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <sys/types.h>
@@ -146,7 +146,7 @@ long tube_mSeconds()
if (!initialized) startTime = t;
initialized = 1;
t = t - startTime;
if (t < 0) t += 86400000;
if (t < 0) t += 86400000;
return t;
}
@@ -162,7 +162,7 @@ long tube_u100ResetSeconds(int reset)
charResetCount = 0;
}
t = t - startTime;
if (t < 0) t += 864000000;
if (t < 0) t += 864000000;
return t;
}
@@ -191,7 +191,7 @@ int tube_getInputChar()
// get a char from getDataPipe, if available, otherwise return -1
{
static long lastTime = 0;
long t = tube_u100ResetSeconds(0);
if (tube_isInput()) {
// handle baud rate since last no input available
@@ -240,11 +240,11 @@ void readKeyTranslationTable()
{
FILE *confFile;
int code1, code2, i;
char *homedir = getpwuid(getuid())->pw_dir;
char s[255];
char *homedir = getpwuid(getuid())->pw_dir;
char s[255];
memset(keyTable, 0, sizeof(keyTable));
strcpy(s, homedir);
strcat(s, "/.tek4010conf/aplkeys" );
// printf("Looking for conf file %s\n",s);
@@ -264,7 +264,7 @@ void readKeyTranslationTable()
exit(1);
}
}
else
else
fscanf(confFile,"%s\n",s); // skip comment line
}
fclose(confFile);
@@ -298,7 +298,7 @@ void tube_init(int argc, char* argv[])
printf("Error:number of arguments\n");
exit(1);
}
if ((strcmp(argv[firstArg],"-h") == 0) || (strcmp(argv[firstArg],"--help") == 0)){
printf(helpStr);
exit(0);
@@ -309,7 +309,7 @@ void tube_init(int argc, char* argv[])
argNoexit = 1;
argc--;
}
while ((argv[firstArg][0] == '-') && (firstArg < argc-1)) {
if (strcmp(argv[firstArg],"-raw") == 0)
argRaw = 1;
@@ -362,27 +362,27 @@ void tube_init(int argc, char* argv[])
else if (strcmp(argv[firstArg],"-wait") == 0) {
argWait = 3;
if (firstArg < argc-2) {
if ((argv[firstArg+1][0] >= '0') &&
(argv[firstArg+1][0] <= '9')) {
if ((argv[firstArg+1][0] >= '0') &&
(argv[firstArg+1][0] <= '9')) {
firstArg++;
argWait = atoi(argv[firstArg]);
}
}
// printf("Waiting %d seconds after end of plot\n", argWait);
}
// printf("Waiting %d seconds after end of plot\n", argWait);
}
else {
printf("tek4010: unknown argument %s\n", argv[firstArg]);
exit(1);
}
firstArg++;
}
if (argBaud > 20000) argFast = 1;
if (argBaud > 20000) argFast = 1;
// A child process for rsh is forked and communication
// between parent and child are established
// expand argv[firstArg] to full path and check, whether it exists
char *str = (char *) malloc(bufsize * sizeof(char));
if (str == NULL) {
@@ -394,15 +394,15 @@ void tube_init(int argc, char* argv[])
FILE *fullPath = popen(str,"r");
if (fullPath) {
getline(&str, &bufsize,fullPath);
// remove the endline character
str[strlen(str)-1] = 0;
if (strncmp(str,"which",5) == 0) {
printf("Unknown command %s\n", argv[firstArg]);
exit(1);
}
argv[firstArg] = str;
pclose(fullPath);
}
@@ -410,24 +410,24 @@ void tube_init(int argc, char* argv[])
printf("Unknown command %s\n", argv[firstArg]);
exit(1);
}
characterInterval = 100000 / argBaud; // in 100 usecs, assuming 1 start and 1 stop bit.
if (DEBUG) printf("character_interval = %0.1f msec\n",(double)characterInterval/10.0);
tube_doClearPersistent = 1;
// create pipes for communication between parent and child
if (pipe(getDataPipe) == -1) {
printf("Cannot initialize data pipe\n");
exit(1);
}
if (pipe(putKeysPipe) == -1) {
printf("Cannot initialize key pipe\n");
exit(1);
}
// now fork a child process
pid_t pid = fork();
if (pid == -1) {
@@ -435,43 +435,43 @@ void tube_init(int argc, char* argv[])
exit(1);
}
else if (pid == 0) { // child process
// we need a second string array with an empty string as last item!
argv2[0] = argv[firstArg];
for (int i = 1; i < argc; i++)
argv2[i] = argv[firstArg+i-1];
argv2[argc-firstArg+1] = (char*) NULL;
// int i = 0;
// do {
// printf("argv2[%d] = %s\n",i,argv2[i]);
// i++;
// }
// while (argv2[i] != (char*) NULL);
// set stdout of child process to getDataPipe
while ((dup2(getDataPipe[1], STDOUT_FILENO) == -1) && (errno == EINTR)) {}
close(getDataPipe[1]); // not used anymore
close(getDataPipe[0]); // not used
// set stdin of child process to putKeysPipe
while ((dup2(putKeysPipe[0], STDIN_FILENO) == -1) && (errno == EINTR)) {}
close(putKeysPipe[1]); // not used
close(putKeysPipe[0]); // not used anymore
// run rsh in the child process
execv(argv2[0],argv2+1);
free(str);
exit(0);
}
// parent process
free(str);
close(getDataPipe[1]); // not used
close(putKeysPipe[0]); // not used
// use termios to turn off line buffering for both pipes
// struct termios term;
// tcgetattr(getDataPipe[0], &term);
@@ -479,7 +479,7 @@ void tube_init(int argc, char* argv[])
// tcsetattr(getDataPipe[0], TCSANOW,&term);
// tcgetattr(putKeysPipe[1], &term);
// tcsetattr(putKeysPipe[0], TCSANOW,&term);
// open now a stream from the getDataPipe descriptor
getData = fdopen(getDataPipe[0],"r");
if (getData == 0) {
@@ -487,7 +487,7 @@ void tube_init(int argc, char* argv[])
exit(1);
}
setbuf(getData,0);
// open now a stream from the putKeysPipe descriptor
putKeys = fdopen(putKeysPipe[1],"w");
if (putKeys == 0) {
@@ -495,9 +495,9 @@ void tube_init(int argc, char* argv[])
exit(1);
}
setbuf(putKeys,0);
tube_mSeconds(); // initialize the timer
tube_u100ResetSeconds(1);
tube_u100ResetSeconds(1);
}
int tube_on_timer_event()
@@ -508,9 +508,9 @@ int tube_on_timer_event()
// if there is a char available on the input stream
// or there is still a bright spot, return 1 to ask for
// one more redraw
// is child process still running?
int status;
if (argWait && (tube_isInput() == 0) && (waitpid(-1, &status, WNOHANG))) {
if (firstWait == 0)
@@ -522,7 +522,7 @@ int tube_on_timer_event()
printf("Process has been terminated after %d seconds\n", argWait);
exit(0);
}
}
}
}
else if ((!argNoexit) && (tube_isInput() == 0) && (waitpid(-1, &status, WNOHANG))) {
long t = tube_mSeconds();
@@ -538,7 +538,7 @@ int tube_on_timer_event()
}
return (isBrightSpot || tube_isInput());
}
int tube_clicked(int button, int x, int y)
// is called if a mouse button is clicked in the window
// button = 1: means left mouse button; button = 3 means right mouse button
@@ -550,7 +550,7 @@ int tube_clicked(int button, int x, int y)
tek4010_clicked(x, windowHeight - y);
return 1;
}
return 0;
return 0;
}
void tube_quit()
@@ -593,12 +593,12 @@ void tube_clearPersistent(cairo_t *cr, cairo_t *cr2)
ylast = 0;
specialPlotMode = 0;
defocussed = 0;
intensity = 100;
intensity = 100;
}
void tube_clearSecond(cairo_t *cr2)
// clear second surface
{
{
if (argFast) {
cairo_set_source_rgba(cr2, 0, 0, 0, 0);
cairo_set_operator(cr2, CAIRO_OPERATOR_SOURCE);
@@ -648,9 +648,9 @@ void tube_line_type(cairo_t *cr, cairo_t *cr2, enum LineType ln)
void tube_drawCharacter(cairo_t *cr, cairo_t *cr2, char ch)
{
char s[8];
if (ch < 32) return; // non printable control character
if (aplMode) {
switch (ch) {
case 32: sprintf(s," ");
@@ -669,7 +669,7 @@ void tube_drawCharacter(cairo_t *cr, cairo_t *cr2, char ch)
break;
case 39: sprintf(s,"]");
break;
case 40: sprintf(s,"\u2228");
case 40: sprintf(s,"\u2228");
break;
case 41: sprintf(s,"\u2227");
break;
@@ -685,9 +685,9 @@ void tube_drawCharacter(cairo_t *cr, cairo_t *cr2, char ch)
break;
case 47: sprintf(s,"/");
break;
// 48 - 57: Digits
case 58: sprintf(s,"(");
break;
case 59: sprintf(s,"[");
@@ -699,7 +699,7 @@ void tube_drawCharacter(cairo_t *cr, cairo_t *cr2, char ch)
case 62: sprintf(s,":");
break;
case 63: sprintf(s,"\\");
break;
break;
case 64: sprintf(s,"\u00AF");
break;
case 65: sprintf(s,"\u237A");
@@ -732,7 +732,7 @@ void tube_drawCharacter(cairo_t *cr, cairo_t *cr2, char ch)
break;
case 79: sprintf(s,"\u25CB");
break;
case 80: sprintf(s,"\u22c6");
break;
case 81: sprintf(s,"?");
@@ -767,9 +767,9 @@ void tube_drawCharacter(cairo_t *cr, cairo_t *cr2, char ch)
break;
case 96: sprintf(s,"\u22C4");
break;
// 97 - 122 capital letters
case 123: sprintf(s,"{");
break;
case 124: sprintf(s,"\u22A3");
@@ -778,38 +778,38 @@ void tube_drawCharacter(cairo_t *cr, cairo_t *cr2, char ch)
break;
case 126: sprintf(s,"$");
break;
default: if ((ch>=48) && (ch<=57)) sprintf(s,"%c", ch); // digits
else if ((ch>=97) && (ch<=122)) sprintf(s,"%c", ch - 32); // capital letters
else sprintf(s," ");
break;
}
}
}
else {
s[0] = ch;
s[1] = 0;
}
cairo_set_font_size(cr, currentFontSize);
cairo_set_font_size(cr2,currentFontSize);
cairo_set_font_size(cr2,currentFontSize);
if (writeThroughMode) { // draw the write-through character
cairo_set_source_rgb(cr2, 0, WRITE_TROUGH_INTENSITY, 0);
cairo_move_to(cr2, tube_x0, windowHeight - tube_y0 + currentCharacterOffset);
cairo_show_text(cr2, s);
}
else {
// draw the character
cairo_set_source_rgb(cr, 0, BLACK_INTENSITY + ((NORMAL_INTENSITY - BLACK_INTENSITY) * intensity) / 100, 0);
cairo_move_to(cr, tube_x0, windowHeight - tube_y0 + currentCharacterOffset);
cairo_show_text(cr, s);
// draw the bright spot
cairo_set_source_rgb(cr2, BRIGHT_SPOT_INTENSITY/2, BRIGHT_SPOT_INTENSITY, BRIGHT_SPOT_INTENSITY/2);
cairo_move_to(cr2, tube_x0, windowHeight - tube_y0 + currentCharacterOffset);
cairo_show_text(cr2, s);
cairo_show_text(cr2, s);
}
tube_x0 += hDotsPerChar;
isBrightSpot = 1;
}
@@ -835,26 +835,26 @@ void tube_drawPoint(cairo_t *cr, cairo_t *cr2)
cairo_move_to(cr, tube_x2, windowHeight - tube_y2);
cairo_line_to(cr, tube_x2 + 1, windowHeight - tube_y2 + 1);
cairo_stroke (cr);
// speed is a problem here
// do not draw adjacent bright spots
if (((tube_x2 - xlast) > 2) || ((xlast - tube_x2) > 2) ||
((tube_y2 - ylast) > 2) || ((ylast - tube_y2) > 2)) {
// draw the bright spot
cairo_set_line_width (cr2, 0.1);
double bsc = (BRIGHT_SPOT_INTENSITY * intensity) / 100;
cairo_set_source_rgb(cr2, bsc/2, bsc, bsc/2);
cairo_set_source_rgb(cr2, bsc/2, bsc, bsc/2);
cairo_arc(cr2, tube_x2, windowHeight - tube_y2, 2 + defocussed, 0, PI2);
cairo_fill(cr2);
xlast = tube_x2;
ylast = tube_y2;
}
isBrightSpot = 1;
isBrightSpot = 1;
}
void tube_crosshair(cairo_t *cr, cairo_t *cr2)
@@ -866,7 +866,7 @@ void tube_crosshair(cairo_t *cr, cairo_t *cr2)
cairo_line_to(cr2, tube_x0, windowHeight);
cairo_move_to(cr2, 0, windowHeight - tube_y0);
cairo_line_to(cr2, windowWidth, windowHeight - tube_y0);
cairo_stroke (cr2);
cairo_stroke (cr2);
}
void tube_drawVector(cairo_t *cr, cairo_t *cr2)
@@ -887,7 +887,7 @@ void tube_drawVector(cairo_t *cr, cairo_t *cr2)
cairo_line_to(cr2, tube_x2, windowHeight - tube_y2);
cairo_stroke (cr2);
}
else {
// draw the actual vector on permanent surface
cairo_set_line_width (cr, pensize + defocussed);
@@ -896,11 +896,11 @@ void tube_drawVector(cairo_t *cr, cairo_t *cr2)
cairo_move_to(cr, tube_x0, windowHeight - tube_y0);
cairo_line_to(cr, tube_x2, windowHeight - tube_y2);
cairo_stroke (cr);
// draw the bright spot
cairo_set_line_width (cr, (pensize+1) + defocussed);
cairo_set_source_rgb(cr2, BRIGHT_SPOT_INTENSITY/2, BRIGHT_SPOT_INTENSITY, BRIGHT_SPOT_INTENSITY/2);
cairo_set_source_rgb(cr2, BRIGHT_SPOT_INTENSITY/2, BRIGHT_SPOT_INTENSITY, BRIGHT_SPOT_INTENSITY/2);
cairo_move_to(cr2, tube_x0, windowHeight - tube_y0);
cairo_line_to(cr2, tube_x2, windowHeight - tube_y2);
cairo_stroke(cr2);
@@ -911,11 +911,11 @@ void tube_drawVector(cairo_t *cr, cairo_t *cr2)
void tube_setupPainting(cairo_t *cr, cairo_t *cr2, char *fontName)
{
cairo_set_antialias(cr, CAIRO_ANTIALIAS_BEST);
cairo_set_line_width (cr, pensize);
cairo_set_source_rgb(cr, 0, NORMAL_INTENSITY, 0);
cairo_set_antialias(cr, CAIRO_ANTIALIAS_BEST);
cairo_set_line_width (cr, pensize);
cairo_set_source_rgb(cr, 0, NORMAL_INTENSITY, 0);
cairo_select_font_face(cr, fontName, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_select_font_face(cr2, fontName, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_select_font_face(cr2, fontName, CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
}
void tube_changeCharacterSize(cairo_t *cr, cairo_t *cr2,int charsPerLine, int charsPerPage, double fontSize)
@@ -931,7 +931,7 @@ void tube_changeCharacterSize(cairo_t *cr, cairo_t *cr2,int charsPerLine, int ch
currentFontSize = (int) (fontSize * STANDARD_FONT_SIZE);
}
cairo_set_font_size(cr, currentFontSize);
cairo_set_font_size(cr2,currentFontSize);
cairo_set_font_size(cr2,currentFontSize);
if (argARDS) {
cairo_font_extents(cr, &et);
currentCharacterOffset =(int)et.ascent;