From 037981d583e8a10d5670fdaecd407f55540c98c1 Mon Sep 17 00:00:00 2001 From: Lars Brinkhoff Date: Mon, 14 Jan 2019 12:57:46 -0800 Subject: [PATCH] display: Make it possible to adjust Type 342 character grid size. --- display/type340.c | 20 ++++++++++++++++---- display/type340.h | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/display/type340.c b/display/type340.c index 8e6bbbfe..3059f4d3 100644 --- a/display/type340.c +++ b/display/type340.c @@ -122,6 +122,8 @@ static struct type340 { unsigned char intensity; /* 3 bits */ #if TYPE342 unsigned char shift; /* 1 bit */ + unsigned char width; /* character grid width */ + unsigned char height; /* character grid height */ #endif #if TYPE347 ty340word ASR; /* Address Save Register */ @@ -167,6 +169,8 @@ ty340_reset(void *dptr) u->scale = 1; #if TYPE342 u->shift = 0; + u->width = 6; + u->height = 9; #endif #if TYPE347 u->SAVE_FF = 0; @@ -709,6 +713,14 @@ static const unsigned char chars[128][6] = { { 0376, 0376, 0376, 0376, 0376, 0 } /* 77 ??? */ }; +void +ty342_set_grid(int w, int h) +{ + struct type340 *u = UNIT(0); + u->width = w; + u->height = h; +} + /* * type 342 Character/Symbol generator for type 340 display * return true if ESCaped @@ -725,7 +737,7 @@ character(int n, unsigned char c) flags = chars[c][5]; if (flags & CH_LF) { /* LF */ - u->ypos -= u->12*s; + u->ypos -= u->height*s; if (u->ypos < 0) { u->status |= ST340_HEDGE; u->ypos = 0; @@ -747,8 +759,8 @@ character(int n, unsigned char c) if (flags & CH_ESC) { /* escape */ return 1; } - if ((flags & CH_NSPC) && u->xpos >= u->7*s) { - u->xpos -= u->7*s; /* non spacing character */ + if ((flags & CH_NSPC) && u->xpos >= u->width*s) { + u->xpos -= u->width*s; /* non spacing character */ } /* plot character from character set selected by "shift" */ for (x = 0; x < 5; x++) { /* column: 0 to 4, left to right */ @@ -759,7 +771,7 @@ character(int n, unsigned char c) } } } - u->xpos += 7*s; + u->xpos += u->width*s; if (u->xpos > 1023) { u->xpos = 1023; u->status |= ST340_VEDGE; diff --git a/display/type340.h b/display/type340.h index 7bb7af1a..1c39dc1a 100644 --- a/display/type340.h +++ b/display/type340.h @@ -50,6 +50,7 @@ ty340word ty340_reset(void *); ty340word ty340_status(void); ty340word ty340_instruction(ty340word inst); void ty340_set_dac(ty340word addr); +void ty342_set_grid(int, int); /* * calls from type340.c into host simulator