diff --git a/ards.c b/ards.c new file mode 100755 index 0000000..1c418ec --- /dev/null +++ b/ards.c @@ -0,0 +1,160 @@ +/* + * 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. + * + */ + +#define WRITE_TROUGH_INTENSITY 0.5 // green only +#define NORMAL_INTENSITY 0.8 +#define CURSOR_INTENSITY 0.8 +#define BRIGHT_SPOT_COLOR 1.0,1.0,1.0 +#define BRIGHT_SPOT_COLOR_HALF 0.3,0.6,0.3 +#define BLACK_COLOR 0.0,0.08,0.0 // effect of flood gun + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "main.h" +#include "tek4010.h" + +extern void gtk_main_quit(); +extern int globalClearPersistent; +extern int windowWidth; +extern int windowHeight; + +extern int argFull; + +extern int hDotsPerChar; +extern int vDotsPerChar; + +extern int refresh_interval; // after this time in msec next refresh is done +extern long refreshCount; + +extern int showCursor; // set of cursor is shown (not set in graphics mode) +extern int isBrightSpot; // set if there is currently a bright spot on the screen + +extern double efactor; +extern int eoffx; + +static long startPaintTime; + +extern long mSeconds(); +extern void doCursor(cairo_t *cr2); +extern void clearPersistent(cairo_t *cr, cairo_t *cr2); +extern void clearSecond(cairo_t *cr2); +extern void clearPersistent(cairo_t *cr, cairo_t *cr2); +extern int isInput(); +extern int getInputChar(); + +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 + +{ + int ch; + char s[2]; + + refreshCount++; // to calculate the average refresh rate + + int xlast = 0; + int ylast = 0; + + if (first) { + first = 0; + int actualWidth; + if (argFull) { + efactor = windowHeight / 780.0; + actualWidth = (int)(efactor * 1024.0); + eoffx = (windowWidth - actualWidth) / 2; + refresh_interval = (int)(30.0 * efactor * efactor); + } + else { + efactor = 1.0; + actualWidth = windowWidth; + eoffx = 0; + refresh_interval = 30; + } + hDotsPerChar = actualWidth / 74; + vDotsPerChar = windowHeight / 35; + windowWidth = actualWidth; + // printf("Scaling: %0.2f\n", efactor); + // printf("Offset: %d\n",eoffx); + // printf("Refresh interval: %d\n",refresh_interval); + } + + startPaintTime = mSeconds(); // start to measure time for this draw operation + + showCursor = 1; + isBrightSpot = 0; + + // clear the second surface + clearSecond(cr2); + + // clear persistent surface, if necessary + if (globalClearPersistent) { + clearPersistent(cr,cr2); + } + + cairo_set_antialias(cr, CAIRO_ANTIALIAS_BEST); + cairo_set_line_width (cr, 1); + cairo_set_source_rgb(cr, 0, NORMAL_INTENSITY, 0); + + cairo_select_font_face(cr, "Monospace", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); + cairo_select_font_face(cr2, "Monospace", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); + + if (argFull > 0.0) { + cairo_set_font_size(cr, (int)(efactor * 18)); + cairo_set_font_size(cr2,(int)(efactor * 18)); + } + else { + cairo_set_font_size(cr, 18); + cairo_set_font_size(cr2, 18); + } + + do { + ch = getInputChar(); + + + + + // decode and act here + printf("-ARDS mode not yet implemented\n"); + exit(1); + + + } + while (((mSeconds() - startPaintTime) < refresh_interval)); + + // display cursor + + if (showCursor && (isInput() == 0)) doCursor(cr2); + +} diff --git a/main.c b/main.c index 1f2b6af..55220dc 100644 --- a/main.c +++ b/main.c @@ -47,8 +47,12 @@ extern FILE *putKeys; +char *windowName; + static int global_firstcall; + extern int argFull; +extern int argARDS; int windowWidth; int windowHeight; @@ -102,7 +106,10 @@ static void do_drawing(cairo_t *cr, GtkWidget *widget) printf("Cannot create drawing surfaces\n"); exit(1); } - tek4010_draw(permanent_cr, temporary_cr, global_firstcall); + if (argARDS) + ards_draw(permanent_cr, temporary_cr, global_firstcall); + else + tek4010_draw(permanent_cr, temporary_cr, global_firstcall); global_firstcall = FALSE; cairo_set_source_surface(cr, permanent_surface, 0, 0); @@ -225,7 +232,7 @@ int main (int argc, char *argv[]) g_timeout_add(TIME_INTERVAL, (GSourceFunc) on_timer_event, (gpointer) window); } - gtk_window_set_title(GTK_WINDOW(window), WINDOW_NAME); + gtk_window_set_title(GTK_WINDOW(window), windowName); if (strlen(ICON_NAME) > 0) { gtk_window_set_icon_from_file(GTK_WINDOW(window), ICON_NAME, NULL); diff --git a/main.h b/main.h index 5782132..d04f01f 100644 --- a/main.h +++ b/main.h @@ -7,4 +7,6 @@ int tek4010_on_timer_event(); int tek4010_clicked(int button, int x, int y); void tek4010_quit(); +void ards_draw(cairo_t *cr, cairo_t *cr2, int first); + diff --git a/makefile b/makefile index b052f12..6174c88 100644 --- a/makefile +++ b/makefile @@ -4,8 +4,8 @@ CFLAGS = `pkg-config --cflags gtk+-3.0` all: tek4010 -tek4010: main.c tek4010.c tek4010.h main.h - gcc -o tek4010 main.c tek4010.c tek4010.h main.h $(LIBS) $(CFLAGS) +tek4010: main.c main.h tek4010.c tek4010.h ards.c + gcc -o tek4010 main.c tek4010.c ards.c $(LIBS) $(CFLAGS) -install: - ./install \ No newline at end of file +install: tek4010 + ./install diff --git a/tek4010 b/tek4010 index 51da374..7c30fcc 100755 Binary files a/tek4010 and b/tek4010 differ diff --git a/tek4010.c b/tek4010.c index 19df09e..8da294a 100755 --- a/tek4010.c +++ b/tek4010.c @@ -1,7 +1,7 @@ /* * tek4010.c * - * A tek 4010 graphics emulator + * A tek4010/4014 graphics emulator * * Copyright 2019 rricharz * @@ -56,12 +56,14 @@ extern void gtk_main_quit(); extern int globalClearPersistent; extern int windowWidth; extern int windowHeight; +extern char *windowName; int argNoexit = 0; // options int argRaw = 0; int argBaud = 19200; int argTab1 = 0; int argFull = 0; +int argARDS = 0; int refresh_interval; // after this time in msec next refresh is done @@ -79,14 +81,17 @@ double dashset[] = {2,6,2,2,6,3,3,3,6,6}; static int plotPointMode = 0; // plot point mode static int writeThroughMode = 0; // write through mode static int debugCount = 0; -static double efactor; -static int eoffx; -static long refreshCount = 0; // variables for baud rate and refresh rate measurements +double efactor; +int eoffx; + +long refreshCount = 0; // variables for baud rate and refresh rate measurements + static long charCount = 0; static long charResetCount = 0; static long characterInterval = 0; -static long startPaintTime; + +long startPaintTime; // mode handles the current state of the emulator: // @@ -196,7 +201,8 @@ void tek4010_init(int argc, char* argv[]) char *argv2[20]; size_t bufsize = 127; int firstArg = 1; - printf("tek4010 version 1.0.2\n"); + printf("tek4010 version 1.0.3\n"); + windowName = "Tektronix 4010/4014 emulator"; if ((argc<2) || (argc>19)) { printf("Error:number of arguments\n"); exit(1); @@ -229,6 +235,10 @@ void tek4010_init(int argc, char* argv[]) argTab1 = 1; else if (strcmp(argv[firstArg],"-full") == 0) argFull = 1; + else if (strcmp(argv[firstArg],"-ARDS") == 0) { + argARDS = 1; + windowName = "ARDS emulator"; + } else { printf("tek4010: unknown argument %s\n", argv[firstArg]); exit(1); @@ -633,8 +643,6 @@ void emulateDeflectionTime() void tek4010_draw(cairo_t *cr, cairo_t *cr2, int first) // draw onto the main window using cairo -// width is the actual width of the main window -// height is the actual height of the main window // cr is used for persistent drawing, cr2 for temporary drawing { diff --git a/tek4010.h b/tek4010.h index a0fa6c4..c70058f 100644 --- a/tek4010.h +++ b/tek4010.h @@ -1,8 +1,7 @@ #define A_WINDOW_WIDTH 1024 // proposed width of main window #define A_WINDOW_HEIGHT 780 // proposed height of main window -#define WINDOW_NAME "Tektronix 4010/4014" // name of main window #define ICON_NAME "" // path to icon for window -#define TIME_INTERVAL 30 // time interval for timer function in msec +#define TIME_INTERVAL 10 // time interval for timer function in msec // 0 means no timer function diff --git a/versions.txt b/versions.txt index ad60dd9..04b0ba8 100644 --- a/versions.txt +++ b/versions.txt @@ -1,3 +1,12 @@ +Version 1.0.3 April 11, 2019 +============================ +Phase: beta test +New features: +- added skeleton for ARDS emulation +Bug fixes: +- fixed make install +Appearance: + Version 1.0.2 April 10, 2019 ============================ Phase: beta test