🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: net.micro.atari16
2 messages
2 total messages Started by mdoerr Tue, 21 Oct 1986 14:58
KKiillll those double characters! - (nf)
#2514
Author: mdoerr
Date: Tue, 21 Oct 1986 14:58
204 lines
6565 bytes
# This is a shell archive.
# Remove everything above and including the cut line.
# Then run the rest of the file through sh.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar:	Shell Archiver
# Run the following text with /bin/sh to create:
#	RMBS.DOC
#	RMBS.C
#
# This archive created:  Oct 21, 1986 -- 12:39:52
# By:	a friendly ATARI ST hacker  (using that wonderful machine :-)
#
echo shar: extracting RMBS.DOC
sed 's/^XX//' << \SHAR_EOF > RMBS.DOC
XXKKiillll those double characters!
XX
XXI finally got tired of the horrible sounds my C.Itoh 8510A printer is doing,
XXwhen printing proff'ed documents in incremental print mode. To cure the
XXproblem, I've written a simple filter to convert overstrike sequences to
XXthe corresponding printer control codes. As there have been some requests
XXfor such a utility, I'm posting the program to the net.
XX
XXThis is a true filter, i.e. reading from stdin and writing to stdout. Watch
XXout for the problems, that Megamax-C is having with I/O-Redirection. The
XXTTP-Application runs fine from the DESKTOP and any COMMAND shell, that
XXdoesn't do redirection of its own. I ran into problems with the COMMAND.PRG,
XXthat comes with the developers kit and the Michtron shell. I suspect problems
XXwith the Beckmeyer shell, too. The filter works nicely with the COMMAND.TOS,
XXthat has been posted by franco@iuvax (thanx a lot!) many months ago.
XXBTW: Lattice-C is also doing I/O-Redirection of its own. Expect similiar 
XXproblems as with Megamax-C.
XX
XXThe filter does a little more than is absolutely necessary. I suppose it can
XXhandle nroff output, too. But this hasn't been tested, yet.
XX
XXSend     v v v
XX       /-------\
XX     O-|  bug  |    reports to   ...!seismo!unido!uklirb!mdoerr
XX       \-------/
XX         ^ ^ ^
XX
SHAR_EOF
if test 1279 -ne "`wc -c RMBS.DOC`"
then
echo shar: error transmitting RMBS.DOC '(should have been 1279 characters)'
fi
echo shar: extracting RMBS.C
sed 's/^XX//' << \SHAR_EOF > RMBS.C
XX/*	rmbs.c	(V.1.0)
XX *
XX *	Rmbs converts the output of text formatters like proff or nroff
XX *	(not tested) into a form that is less harmful to the mechanics
XX *	of a modern matrix printer. These formatters highlight text by a
XX *	technique called overstriking. Rmbs tries to detect the character
XX *	sequences that are output for bold, bold and underlined and 
XX *	underlined text and converts them to the corresponding control
XX *	codes of the printer.
XX *
XX *	Proff outputs the following sequences:
XX *	Bold:			'char' '\b' 'char'
XX *	Underlined:		'_' '\b' 'char'
XX *	Bold & Underlined:	'_' '\b' '_' '\b' 'char' '\b' 'char'
XX *	This implies an ambiguity that cannot be easily resolved: What
XX *	does '_' '\b' '_' stand for? Is it a bold or an underlined '_'?
XX *	For ease of coding I've decided, that it's a bold '_'.
XX *
XX *	Because the printer control codes are hardwired into the program, 
XX *	you must build a different version of the program for every printer
XX *	you have. As most people (including me) have only one printer, I
XX *	didn't want to bother with a suitable data base of printer codes.
XX *
XX *	Although there's a high probability, that there's no true original
XX *	idea in this program, you should give me credit, if you debug,
XX *	modify, enhance, or give it away. Lightning shall strike your
XX *	computer(s), if you sell this program or any close derivatives
XX *	for profit.
XX *
XX *	Michael Doerr	(uucp: ...!seismo!unido!uklirb!mdoerr)
XX *	University of Kaiserslautern (West Germany)
XX */
XX
XX/* This is the only printer specific part of the program. Change the
XX * control codes according to your printer manual.
XX * These codes are for the C.Itoh 8510A:
XX */
XX#define	BOLD_ON		"\033!"
XX#define	BOLD_OFF	"\033\""
XX#define	ULIN_ON		"\033X"
XX#define	ULIN_OFF	"\033Y"
XX
XX
XX#include <stdio.h>
XX
XX/* character attributes */
XX#define	NONE		0
XX#define	BOLD		1
XX#define	ULIN		2
XX
XXtypedef	int	WORD;
XXtypedef	char	BYTE;
XXtypedef	union	{
XX    WORD	w;
XX    struct	{
XX	BYTE    ch;
XX	BYTE    attrib;
XX    } s;
XX} elem;
XX
XX#define	line_len	300
XXelem	line[line_len];
XX
XXmain(argc, argv)
XXint	argc;
XXchar	**argv;
XX{
XX    int     i, high;
XX    BYTE    ch;
XX
XX    for (i = 0; i < line_len;)
XX	line[i++].w = 0;
XX    i = high = 0;
XX
XX    while ((ch = getchar) != EOF)
XX    {
XX	if (ch == '\n')
XX	{
XX	    print_line(high);
XX	    i = high = 0;
XX	    continue;
XX	}
XX	else if (ch == '\b')
XX	    i--;
XX	else if (line[i].s.ch == '\0')
XX	    line[i++].s.ch = ch;
XX	else if (line[i].s.ch == ch)
XX	    line[i++].s.attrib |= BOLD;
XX	else if (line[i].s.ch == '_')
XX	{
XX	    line[i].s.ch = ch;
XX	    line[i++].s.attrib |= ULIN;
XX	}
XX	else if (ch == '_')
XX	    line[i++].s.attrib |= ULIN;
XX	if (i < 0)
XX	    i = 0;
XX	else if (high < i)
XX	    high = i;
XX	if (i == line_len)
XX	    i = line_len-1;
XX    } /* while */
XX    if (high > 0)
XX	print_line(high);
XX} /* main */
XX
XXprint_line(high)
XXint	high;
XX{
XX    int     i;
XX    BYTE    new, old = NONE;
XX
XX    for (i = 0; i < high;)
XX    {
XX	if (old != (new = line[i].s.attrib))
XX	{
XX	    change_state(old, new);
XX	    old = new;
XX	}
XX	putchar(line[i].s.ch);
XX	line[i++].w = 0;
XX    }
XX    if (old != NONE)
XX	change_state(old, NONE);
XX    putchar('\n');
XX} /* print_line */
XX
XX#define	putstr(str)	char *s = str; s--; while(*++s) putchar(*s)
XX
XXchange_state(old, new)
XXBYTE	old, new;
XX{
XX    if ((old ^ new) & BOLD)
XX    {
XX	if (new & BOLD)
XX	{   putstr(BOLD_ON);	}
XX	else
XX	{   putstr(BOLD_OFF);	}
XX    }
XX    if ((old ^ new) & ULIN)
XX    {
XX	if (new & ULIN)
XX	{   putstr(ULIN_ON);	}
XX	else
XX	{   putstr(ULIN_OFF);	}
XX    }
XX}
XX
SHAR_EOF
if test 3413 -ne "`wc -c RMBS.C`"
then
echo shar: error transmitting RMBS.C '(should have been 3413 characters)'
fi
# End of shell archive
exit 0
TRAPs from an interrupt handler and micro C Shell
#2655
Author: braner
Date: Mon, 03 Nov 1986 04:13
31 lines
2031 bytes
[]

Following this posting you will find a posting of source code
for a program that compresses ST pictures AND codes them into
a text file that can be sent through e-mail.  The text file's
length depends on the picture, but for simple pictures (e.g.
an image of a desktop with some icons and an open dialog box)
it is about 4000 to 8000 chars, i.e. 12 to 25% of the bitmap
size in RAM.  The combination code/compress algorithm is the
culprit for those ratios.

The program is installed in RAM, and activated later upon an
Alt-Help.  Then, instead of printing the screen, it codes it
and saves it on the disk.  (I have also written a program that
decodes and decompresses the text file, shows the picture on
the screen, and can also save it uncompressed in DEGAS format.
I am waiting for net.atari16.sources to post it, and the 2
executables.)

To do what it does, the program calls various OS routines (via TRAPs).
But, the program is called from the keyboard interrupt handler,
and it is officially verboten to do OS calls from there!!
I did it anyway, because I didn't know what else to do.  And
it seems to work - from the desktop.  But when called from
inside micro-C-Shell, the system hangs.  Removing all the TRAPs
makes the program docile (but also futile...).

Can some expert out there tell us what to do about it, and/or how
to write files without TRAPs?

- Moshe Braner
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads