TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Bill Birrell
from: Kurt Kuzba
date: 1998-10-14 22:29:16
subject: ans.c 1/2

BB> KK>   ... use a binary append to attach any .ANS file ...
BB> KK>   it opens itself and reads the ansi data and outputs
BB> KK>   ... without ANSI.SYS being installed.
BB>   That sounds like good clean fun, Kurt.
BB>   Would you care to publish it?
   Sure. I also have a small program that can find the size of
   the .EXE from the header without relying on a recompile with
   a magic number for the file size. THAt, however, to my
   knowledge, is only good for DOS .EXE files. I don't know how
   it would work with other platforms.
 /*_|_|   ANS.C   part 1 of 2
 _|_|_|   PUBLIC DOMAIN   Kurt Kuzba   10/10/1998
 _|_|*/
#include 
#include 
#define FileEnd 10322
 /*_|_|   Compile the program, then check the size of the .EXE
 _|_|_|   file produced, and change this number to the size of
 _|_|_|   the .EXE file plus one. Then recompile. One could
 _|_|_|   also include a binary append routine with a switch.
 _|_|*/
int addchar(char *str, int chr)
{
  int len = -1;
  while(str[++len] != 0);
  if(chr != 0)
     {
        str[len++] = (char)chr;
        str[len] = 0;
     }
  return len;
}
void cursor(int c)
{
   unsigned char far *bc = (unsigned char far*)0x00400050L;
   *bc = (unsigned char)(c % 80);
   *(bc + 1) = (unsigned char)(c / 80);
}
void dir_ansi(int ch)
{
   static int H, E, S, C, A, O;
   static char esc[33];
   int len, col, pos, lin;
   int huge *Scr = (int huge *) 0xb8000000l;
   if(H < 25){  H = 25; A = 7; C = S = E = O = 0; }
   if(ch < 0){  H = -ch; return;  }
   if(E != 27)
   {
      if(ch != 27)
      {
         if(ch == 7)  {  printf("0x07"); return;  }
         if(ch == 13) {   C = C - (C % 80); cursor(C); return;  }
         if(ch == 10) {   C = C + 80; cursor(C);   }
         if(ch != 10) *(Scr + C++) = ch + 256 * A;
         if(C >= H * 80)
         {
             int scroll;
             C = C - 80;
             for(scroll = 0; scroll < 80 * (H - 1); scroll++)
                *(Scr + scroll) = *(Scr + scroll + 80);
             for(scroll = 0; scroll < 80; scroll++)
                *(Scr + 80 * (H - 1) + scroll) = 32 + 256 * A;
         }
         cursor(C);
         return;
      }
      else {  E = 27; addchar(esc, ch); return;  }
   }
   if(O != 27 && ch == 34)   {  O = E; return;  }
   if(O == 27) if(ch == 34)  {  O = 0; return;  }
   len = addchar(esc,ch);
   if(len == 2 && ch != '[') {  E = 0; esc[0] = 0; return;  }
 /*_|_|   end   ANS.C   part 1 of 2   */

> ] Their numbers are 664 and 668, the neighbors of the beast...

---
* Origin: *YOPS ]I[* 8.4 GIG * RA/FD/FE * Milwaukee, WI (1:154/750)
SEEN-BY: 396/1 632/0 371 633/260 267 270 371 634/397 635/506 728 810 639/252
SEEN-BY: 670/218
@PATH: 154/750 222 396/1 633/260 635/506 728 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.