Settings

The page will reload to apply your changes.
Theme

ASCII Art Font

ASCII Art Menu

Original Usenet thread from alt.ascii-art, started 21 Mar 1994.
 _   _                     _        _             _     _           
| | | |___  ___ _ __   ___| |_     / \   _ __ ___| |__ (_)_   _____ 
| | | / __|/ _ \ '_ \ / _ \ __|   / _ \ | '__/ __| '_ \| \ \ / / _ \
| |_| \__ \  __/ | | |  __/ |_   / ___ \| | | (__| | | | |\ V /  __/
 \___/|___/\___|_| |_|\___|\__| /_/   \_\_|  \___|_| |_|_| \_/ \___|
Use this to slow down view of ascii anims (UNIX)

Use this to slow down view of ascii anims (UNIX)

alt.ascii-art · 2 messages · 21 Mar 1994 - 24 Mar 1994
ewh...@uxa.cso.uiuc.edu (Buck Hodges) writes:

> Someone once posted a C program to do a similar thing which would of course 
> work on whatever system had a C compiler.  Maybe they'll post it again.

	Here is `slocat' C-program which was posted here some time
ago. I modified it to use usleep-function instead of dummy for loop,
so this version shouldn't jam the whole computer. 

	Altough usleep is included in standard libraries of most UNIX
systems I found that this is not the case for all systems. To be more
compatible I included it in the code. 

	`slocat' requires name of ascii file (animation) as
first argument and as second argument (optional) the lenght of delay in
milliseconds (default is 400). E.g. `slocat twilight.vt 500' 

	I am not sure wether the system calls are universal enough to
work in other environments than UNIX but it might be worth of try.
Please report any inconveniences caused.
	
------ cut here ------- cut here ------ cut here ------ cut here ------

/*
 *            slocat.c
 *      
 *    slocat <filename> [delay]
 *
 */ 

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <signal.h>
#include <sys/time.h>

#define DEFAULT_DELAY 400

void usleep (unsigned int);

main(int argc,char *argv[])
{
  FILE *f;
  unsigned long int delay;
  char c;

  if ( !argv[2] || (delay = atoi (argv[2])) <1 )
    delay=DEFAULT_DELAY;

  if (!argv[1]) {
    puts ("slocat: file not specified");
    exit (1);
  }

  if (!(f=fopen( argv[1], "r"))) {
    printf ("slocat: can not open %s\n",argv[1]);
    exit (2);
  }

  while ( !feof(f) ) {
    putc( getc(f), stdout );
    usleep (delay);
  }
  fclose(f);
}

void usleep(unsigned int usec)
{
  struct timeval timeout;
  if(usec == 0) 
    return;
  timeout.tv_sec = usec / 1000000;
  timeout.tv_usec = usec - 1000000 * timeout.tv_sec;
  select(1, NULL, NULL, NULL, &timeout);
}

------ cut here ------- cut here ------ cut here ------ cut here ------
	
	-Petri Paavilainen (ppa...@snakemail.hut.fi)

Use of usleep etc.

A much simpler and almost certainly much more portable method (and one that
could be done in almost any language) would be to output a number of NUL
characters after _each_ character output.  The more NULs the slower it goes!
I think almost any operating system/terminal will cope with this.

Just a suggestion.

Eddie

Related ASCII art in the Gallery

Explore these categories from our collection of 11,000+ artworks:

About this thread. These messages were posted publicly to the newsgroup alt.ascii-art in 1994 and are mirrored here unchanged as part of the Historic Archives – only email addresses are masked. The artwork and text belong to their original authors: if you copy a piece, keep the artist's initials or signature intact and credit them where you can. Are you one of the authors? Contact us to get your posts attributed, connected to your artist profile, or removed.

Report this message

Help us keep the archive clean and accurate. Reports are reviewed by a person – nothing is changed automatically.

Help classify this post