Slow down the animation
Νήμα μηνυμάτων · created 1994-02-09 · last edited 2026-11-22 · Γλώσσα τεκμηρίου: Αγγλικά
Πηγή: asciiart.eu
Ομάδα συζήτησης:
alt.ascii-art.animation
February 1994: the first ‘how do I slow it down?’ of the group, and Rick Busdiecker’s answer: scat, a small program that writes character by character with a delay. The first slow-down tool in the group, before cat -u and vtcat.
Quoted in the article:
alt.ascii-art.animation · 5 posts · 1994-02-09 09:58:25 UTC – 1994-03-01 22:37:04 UTC
gRaPpLe <gra...@netcom.com> ·
Most of the animation with goes by too quickly for me
to read text and such. Is there a way to cat the file
slowly?
--
-------
gRaPpLe: v) To struggle, grasp, restrain or tackle. gRa...@nEtCoM.CoM
Haywierd, Ca USA
Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fd588,75064a58c47bba35,start X-Google-Attributes: gidfd588,public X-Google-ArrivalTime: 1994-02-09 01:58:25 PST Newsgroups: alt.ascii-art.animation Path: gmd.de!newsserver.jvnc.net!howland.reston.ans.net!agate!apple.com!amd!amdahl!netcomsv!netcom.com!grapple From: gra...@netcom.com (gRaPpLe) Subject: Slow down the animation Message-ID: <gra...@netcom.com> Organization: The Corner Of B & Kelly X-Newsreader: TIN [version 1.2 PL1] Date: Wed, 9 Feb 1994 09:58:25 GMT Lines: 8
Rick Busdiecker <rf...@lehman.com> ·
In article <gra...@netcom.com> gra...@netcom.com (gRaPpLe) writes:
Newsgroups: alt.ascii-art.animation
From: gra...@netcom.com (gRaPpLe)
Organization: The Corner Of B & Kelly
Date: Wed, 9 Feb 1994 09:58:25 GMT
Most of the animation with goes by too quickly for me
to read text and such. Is there a way to cat the file
slowly?
I wrote a quick hack called scat that does does this. It does
character by character I/O with a delay function called between
characters. In fact, the call to usleep() in delay() is currently
commented out because it was slow enough just forcing things to be
character by character.
Rick
- - - - - - - - - - - - - - - - Cut here - - - - - - - - - - - - - - -
/* -*- Mode: C -*- */
/*
* scat - intentionally slow version of cat
*
* This code has been put in the public domain by the author.
*
*/
static const char RCS_Id [] =
"$Id: scat.c,v 1.3 1993/12/13 15:13:48 rfb Exp $";
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
static char* program_name = NULL;
static void delay (void);
int main (int, char**);
static void process_file (const char* file);
static void process_stream (FILE* stream);
static void
delay (void)
{
/* usleep (1000); */
}
int
main (int argument_count,
char** argument_vector)
{
int argument_index;
int do_input = 1;
program_name = argument_vector [0];
for (argument_index = 1; argument_index < argument_count; ++argument_index)
{
char* argument = argument_vector [argument_index];
if (argument [0] == '-')
{
fprintf (stderr, "\n%s: Unrecognized option: %s\n", program_name,
argument);
exit (1);
}
else
{
process_file (argument);
do_input = 0;
}
}
if (do_input) process_stream (stdin);
return 0;
}
void
process_file (const char* file)
{
FILE* stream;
if ((stream = fopen (file, "r")) == NULL)
{
fprintf (stderr, "\nCannot read %s\n", file);
exit (1);
}
process_stream (stream);
}
void
process_stream (FILE* stream)
{
while (! feof (stream))
{
int character = getc (stream);
if (character == EOF)
{
fclose (stream);
return;
}
fflush (stream);
delay ();
putc (character, stdout);
}
}
- - - - - - - - - - - - - - - - Cut here - - - - - - - - - - - - - - -
--
Rick Busdiecker <rf...@lehman.com> and <rf...@cmu.edu>
Lehman Brothers
388 Greenwich Street ``A great many people think they are thinking when
New York, NY 10013 they are merely rearranging their prejudices.''
(212) 464-4750 - William James
Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fd588,75064a58c47bba35 X-Google-Attributes: gidfd588,public X-Google-ArrivalTime: 1994-02-11 06:46:33 PST Newsgroups: alt.ascii-art.animation Path: gmd.de!xlink.net!howland.reston.ans.net!agate!ames!sgiblab!twg.com!eco.twg.com!psinntp!lehman.com!newshost!rfb From: rf...@lehman.com (Rick Busdiecker) Subject: Re: Slow down the animation In-Reply-To: gra...@netcom.com's message of Wed, 9 Feb 1994 09:58:25 GMT To: gra...@netcom.com (gRaPpLe) Message-ID: <RFB...@fnord.lehman.com> Lines: 114 Sender: new...@lehman.com (News) Nntp-Posting-Host: fnord Organization: Lehman Brothers, Inc. References: <gra...@netcom.com> Date: Fri, 11 Feb 1994 14:46:33 GMT
Tom R. Loden *8^0 <lod...@ll.mit.edu> ·
Well, on a Sun SPARC II, it didn't seem to slow things down
at all. But using usleep() was TOO slow. I found inserting
a dummy loop did just fine.
==============================================================
Tom R. Loden MIT Lincoln Lab Marry a job.
Lexington, MA 02173 Buy a wife and kids.
617-981-3249 Have a house together.
Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fd588,75064a58c47bba35 X-Google-Attributes: gidfd588,public X-Google-ArrivalTime: 1994-02-17 06:34:11 PST Newsgroups: alt.ascii-art.animation Path: gmd.de!newsserver.jvnc.net!netnews.upenn.edu!msuinfo!agate!howland.reston.ans.net!noc.near.net!ll.mit.edu!loden From: lod...@ll.mit.edu (Tom R. Loden *8^0) Subject: Re: Slow down the animation Message-ID: <199...@ll.mit.edu> Sender: new...@ll.mit.edu Reply-To: lod...@ll.mit.edu (Tom R. Loden *8^0) Organization: MIT Lincoln Lab References: <RFB...@fnord.lehman.com> Date: Thu, 17 Feb 94 14:34:11 GMT Lines: 9
David Lindes <lin...@training.asd.sgi.com> ·
In <199...@ll.mit.edu>,
lod...@ll.mit.edu (Tom R. Loden *8^0) writes:
> Well, on a Sun SPARC II, it didn't seem to slow things down
> at all. But using usleep() was TOO slow. I found inserting
> a dummy loop did just fine.
( it did slow it down on mine... but on other points:...)
problem with dummy loops is they're much less processor efficient.
also, you CAN change the argument to usleep()... the argument is in
microseconds (and will be some arbitrary amount more than what you
specify, depending on system load, overhead for the call, etc.).
(what i did was to add something like this in the code:...
/* delay between charachters, in microseconds */
#define DELAY 1000
...and change the "1000" argument to usleep() to "DELAY")
unfortunately, on the system i'm currently on, i don't have usleep,
or it's in a library other than what i'm compiling with, or
something, but there are a few other things that i would suggest to
make the program more efficient (which you'll then slow back down,
to make it be just as you want it)
first, you might want to get rid of the fflush(), and optionally
replace it with a call to put you in cbreak mode. (not sure off
hand how to do this on most platforms when you're not acting on
stdin as your stream... though i suppose you could close stdin and
re-open it as the other file, and then just call cbreak() ;-)
also, change your primary loop do something more like this:
while ( (c=getc(stream))!=EOF )
{
delay ();
putc (c, stdout);
}
fclose (stream);
(the old version, which i'd have to post this to go back to, at the
moment, was SOMETHING like:
while( feof(stream) != EOF )
{
int c=getc(stream);
if(c==EOF)
{
fclose(stream);
return;
}
fflush(stream);
putc(c,stdout);
}
... much more overhead, more calls, etc., slowing the program down
tremendously.)
there may be other things you can do too, but i'm not thinking of
much more, at the moment...
cheers.
david lindes
lin...@asd.sgi.com
P.S. PLEASE NOTE: the intent of this message is not to cut down
anyone's code!!! the intent is to provide some suggestions
that may help more people have a more versitile "scat"
program. i hope it helps.
P.P.S. #include <std_disclaimer.h>
Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fd588,75064a58c47bba35 X-Google-Attributes: gidfd588,public X-Google-ArrivalTime: 1994-02-28 21:29:35 PST Newsgroups: alt.ascii-art.animation Path: gmd.de!xlink.net!howland.reston.ans.net!usenet.ins.cwru.edu!nigel.msen.com!well!barrnet.net!sgiblab!sgigate.sgi.com!odin!training!lindes From: lin...@training.asd.sgi.com (David Lindes) Subject: Re: Slow down the animation Message-ID: <CLz...@odin.corp.sgi.com> Sender: new...@odin.corp.sgi.com (Net News) Nntp-Posting-Host: training.asd.sgi.com Organization: Silicon Graphics, Inc. Mountain View, CA References: <RFB...@fnord.lehman.com> <199...@ll.mit.edu> Date: Tue, 1 Mar 1994 05:29:35 GMT Lines: 78
Raja Daoud <raj...@osc.edu> ·
lin...@training.asd.sgi.com (David Lindes) writes:
>unfortunately, on the system i'm currently on, i don't have usleep,
>or it's in a library other than what i'm compiling with, or
>something, [...]
If you're interested, you can roll your own usleep() using select():
#include <errno.h>
#include <sys/types.h>
#include <sys/time.h>
void
my_usleep(usec)
int usec;
{
struct timeval timeout;
timeout.tv_sec = usec / 1000000;
timeout.tv_usec = usec % 1000000;
while ((select(0, (fd_set *) 0, (fd_set *) 0,
(fd_set *) 0, &timeout) < 0) && (errno == EINTR));
}
Hope this helps.
--Raja
Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fd588,75064a58c47bba35 X-Google-Attributes: gidfd588,public X-Google-ArrivalTime: 1994-03-01 14:37:04 PST Path: gmd.de!xlink.net!howland.reston.ans.net!math.ohio-state.edu!mane.cgrg.ohio-state.edu!hawkeye.osc.edu!not-for-mail From: raj...@osc.edu (Raja Daoud) Newsgroups: alt.ascii-art.animation Subject: Re: Slow down the animation Date: 1 Mar 1994 17:37:04 -0500 Organization: The Ohio Supercomputer Center Lines: 29 Message-ID: <2l0g2g$29...@hawkeye.osc.edu> NNTP-Posting-Host: hawkeye.osc.edu
Πηγή: asciiart.eu
Τα μηνύματα, και τα έργα που περιέχουν, ανήκουν στους δημιουργούς τους και δημοσιεύονται εδώ ως αρχείο. Αν είστε ένας από αυτούς και θέλετε διόρθωση ή αφαίρεση, γράψτε μου.
| Διαθέσιμα τεκμήρια | size | download | |
|---|---|---|---|
| tdefdcd4db8.json (json)mail-usenet-thread 0.6αντίγραφο στο αρχείο, δεν διανέμεται | 39K | – | |