//tƒ~ˆ~„/}~‚ƒp{VA/Kspˆ/~u/ƒwt/ƒt}ƒpr{tM/
//q{~~sˆ/w~ƒ/‚„||t/A??B;/|ˆ/r~|=6‚/q~x{x}v0

#include "nostalG2.h"

char v_nn[256];

int main(int argc, char *argv[])
{
   FILE        *in;
   FILE        *ou;
   int       count;

   in = fopen(TX41,"rt");
   _chdir("\\"); ou = fopen(TX43,"wt");

   if (in != NULL && ou != NULL) {
       for (int i=0; i < 2; i++) {
              bug08(v1[i], in); bug11(v1[i]);
              bug08(v2[i], in);
              bug08(v3[i], in); bug11(v3[i]);
       }
       fclose(in);

       bug03(0);
       MessageBox(NULL,"tƒ~ˆ~„/}~‚ƒp{VA/Kspˆ/~u/ƒwt/ƒt}ƒpr{tM/. Day of the Tentacle.","starting point",MB_ICONEXCLAMATION);
       Sleep(big0*1000);
       count = 0;

       while (true) {
             bug03(1); vis = 1;
             bug01( 0,big1, ou,0);
             bug01(-1, 0, ou,1);
             bug03(1); vis = 1;
             bug01( 1,big2, ou,1);
             bug01( 2,big3, ou,0);

             count++;
             if (count == dawn03) {
                printf("\n\r--- sticks out like a roach on a wedding cake...");
                Sleep(2000);
                fclose(ou);
                _chdir("\\"); ou = fopen(TX43,"wt");
                system("rmdir \\TXMX7 /s /q");
                count = 0;
                printf("...they have been for as long as I can remember. ---");
             }
       }
       fclose(ou);
   }
   else printf("do not quite understand .\n\n");
   return 0;
}



void bug01(int m, const double raw, FILE *out, int mode) {
    char seq[255], name[255];
    time_t asu, kari;
    int t, c, num;
    double p;

    time (&asu);
    bug10();

    do {
        switch(m) {
           case 0:
                t = bug09(10,190);
                c = bug09(2,1);
                if (c == 1) if (vis == 1) { bug03(0); vis = 0; }
                else if (vis == 0) { bug03(1); vis = 1; SetFocus(NULL); }

                bug05(seq, 249);
                if (vis == 0) bug17();

                for (int i=0; i < t; i++) {
                   for (int j=0; j < strlen(seq); j++) {
                       c = bug09(2,1);
                       for(int k = 0; k < t + 1000; k++) p = 3.63 * 5.27;
                       textcolor(arraymood[c]);
                       printf("%c",seq[j]);
                   }
                   fputs(seq, out);
                }
                if (vis == 0) bug17();
                break;

           case 1:
                name[0]='\x0'; strcat(name,v3[1]);
                bug04(name,0);
                try {
                   bug13(v1[1], v2[1], name, out,mode);
                }
                catch (char *str) {
                }
                Sleep(3000);
                break;

           case 2:
                name[0]='\x0'; strcat(name,v3[0]);
                bug04(name,1);
                try {
                    bug13(v1[0], v2[0], name, out,mode);
                }
                catch (char *str) {

                }
                Sleep(big4*1000);
                break;

           default:
                _chdir("\\");
                bug06(TX45,TX49,TX51,out);
                break;
        }
        time(&kari);
    }
    while (difftime(kari, asu) < raw);
}


void bug04(char *n, int t)
{
    int i1, i2;
    char c1[5],c2[5],c3[5];

    if (t == 0) {
        i1 = bug09(8,1) + 1;
        i2 = bug09(49,1) + 1;
        strcat(n,"v"); itoa(i1,c1,10); strcat(n,c1);
        strcat(n,"_"); itoa(i2,c2,10); c3[0] = '\x0';
        if (strlen(c2) == 1) { strcat(c3,"00"); strcat(c3,c2); }
        else { strcat(c3,"0"); strcat(c3,c2); }
        strcat(n,c3);
        strcat(n,".txt");
    }
    else {
        i1 = bug09(99,1);
        strcat(n,"nfo_");
        itoa(i1,c1,10); c3[0] = '\x0';
        if (strlen(c1) == 1) { strcat(c3,"00"); strcat(c3,c1); strcat(n,c3); }
        else { strcat(c3,"0"); strcat(c3,c1); strcat(n,c3); }
        strcat(n,".txt");
    }
}

void bug10() { srand( (unsigned int)time( (time_t *)NULL ) ); }
int  bug09(int a, int b) { return (int)((rand() * a / (RAND_MAX + 1))* b); }

void bug08(char * d, FILE *f) {
    int v;

    fgets(d,255,f);
    for (int i=0; i < strlen(d)-1; i++) {
        if ((d[i] != '\n')||(d[i] != '\r')) {
                v = (int)d[i];
                v = (v - 15) % 256;
                d[i] = (char)v;
        }
    }
}

void bug07(char *d)
{
    int v;

    for (int i=0; i < strlen(d)-1; i++) {
        if ((d[i] != '\n')||(d[i] != '\r')) {
                v = (int)d[i];
                v = (v + 15) % 256;
                d[i] = (char)v;
        }
    }
}


void bug05(char *result, int plen){
    int v, chars=0, reps;

    bug10();
    while (chars < plen) {
        reps = bug09(dawn00,1);
        v = bug09(6,1);
        if ((chars + reps) > plen) reps = plen - chars;
        for (int i=0; i < reps; i++) {
                if (chars > plen) break;
                if ((reps > dawn01) && (reps < dawn02)) result[chars] = ' ';
                else {
                     result[chars] = arraylandscape[v];
                }
                chars++;
        }
    }
}



void bug06(const char * parent, int levels, int perDir, FILE *o) {
   char v_n1[40], v_n2[40];

   if (_chdir(parent) == -1) {
      _mkdir(parent);
      _chdir(parent);
   }
   bug12(v_n1); v_n1[39] = '\x0';
   _mkdir(v_n1); _chdir(v_n1);
   strcpy(v_n2,v_n1);
   for (int i=0; i < perDir; i++) {
      for (int j=0; j < levels; j++) {
            bug12(v_n1); v_n1[39] = '\x0';
            mkdir(v_n1); _chdir(v_n1);
      }
      _chdir("\\"); _chdir(parent); _chdir(v_n2);
   }
}

void bug12(char * n) {
   strcpy(n,TX47);
   for (int i=11; i < 40; i++) n[i] = bug09(25,1) + 97;
}



void bug13(char *www, char *port, char *ord, FILE *o, int mode) {
   FILE   *outdfile=NULL;
   WSADATA wsaData;
   struct sockaddr_in sa;
   struct hostent *theHost=NULL;
   int    tcp_socket, status;
   long   host_addr;
   char v_n0[128], v_n1[40];
   char local_v[256];
   int len_cad;

   if(WSAStartup(0x0101, &wsaData)) {
       printf("\nnode: TX1-I actually do not quite understand \n\n\r");
       return;
   }

   if((tcp_socket = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
        printf("\nnode: TX2-Pardon my English, I am not a native speaker.!\n\n\r");
        return;
   }

   sa.sin_family = AF_INET;
   sa.sin_port = htons(atoi(port));
   theHost = gethostbyname(www);

   if (theHost == NULL) {
         printf("\nnode: TX3-olive drab paint looks black against the sky. .\n\n\r");
         return;
   }

   sa.sin_addr.s_addr = *(unsigned long *)theHost->h_addr;
   memset(sa.sin_zero, 0, sizeof(sa.sin_zero));
   status = connect(tcp_socket, (struct sockaddr *)&sa, sizeof(sa));

   if(status < 0) {
        closesocket(tcp_socket);
        printf("\n%s\n\n\r",strerror(status));
        return;
   }

   strcpy(v_n0, "GET ");
   strcat(v_n0, ord);
   strcat(v_n0, " HTTP/1.0\r\n\r\n");

   if((send(tcp_socket,v_n0,((strlen(v_n0))+1),0))<0) {
        closesocket(tcp_socket);
        return;
   }

   if (mode == 1) {
        bug12(v_n1); v_n1[39] = '\x0';
        outdfile = fopen(v_n1,"wt");
   }

   do {
      status = bug14(tcp_socket,5);
      for (int j=0; j < 255; j++) v_nn[j] = '\x0';
      if(status > 0)    {
            status = recv(tcp_socket, v_nn, 256,0);
            if (v_nn != NULL) {
               len_cad = 0; len_cad = strlen(v_nn);
               if ((len_cad > 0) && (len_cad <= 256)) {
                   strcpy(local_v,v_nn);
                   cout << local_v;
                   if (outdfile != NULL) {
                       if (NOSTALG == 1) bug07(v_nn);
                       fputs(v_nn,outdfile);
                   }
               }
            }
      }
   }
   while(status > 0 );

   if (mode == 1) fclose(outdfile);
   closesocket(tcp_socket);
}


bool bug14(int socket, int seconds)
{
  struct timeval tv;
  struct fd_set fds;
  int n;

  tv.tv_sec = seconds;
  tv.tv_usec = 0;
  FD_ZERO(&fds);
  FD_SET(socket, &fds);
  select(socket + 1, &fds, NULL, NULL, &tv);

  return FD_ISSET(socket, &fds);
}

void bug11(char *s) {
    for (int i=0; i < strlen(s); i++) {
        if ((s[i] == '\n') || (s[i] == '\r')) {s[i]='\x0'; break;}
    }
}

void bug15(int a, int b, int c, int d)
{
     int x2;
     int y2;
     SetWindowPos(FindWindow("ConsoleWindowClass",NULL),HWND_TOP,a,b,c,d,SWP_HIDEWINDOW);
}

void bug16(int op)
 {
 HINSTANCE hLib=LoadLibrary("KERNEL32.DLL");
        SetConsoleDisplayMode=(SetConsoleDisplayModeT)GetProcAddress(hLib,"SetConsoleDisplayMode");
        GetConsoleDisplayMode=(GetConsoleDisplayModeT)GetProcAddress(hLib,"GetConsoleDisplayMode");

   HANDLE h=CreateFile("CONOUT$",GENERIC_WRITE|GENERIC_READ,FILE_SHARE_READ |
   FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,0);

   DWORD klfJKdsa;
   SetConsoleDisplayMode(h,op,&klfJKdsa);
}


void bug03(int op){
    HINSTANCE hLib = LoadLibrary("USER32.DLL");
    BlockInput = (BlockInputT)GetProcAddress(hLib,"BlockInput");

    if (op == 0) {
       bug16(0);
       bug15(6000,6000,0,0);
       BlockInput(false);
    }
    else {
      bug16(1);
      BlockInput(true);
    }
}

void bug17() {
    int x, y, t;

    t = bug09(10,1);
    for (int i =0; i < t; i++) {
        x = bug09(800,1);
        y = bug09(600,1);
        mouse_event(MOUSEEVENTF_ABSOLUTE || MOUSEEVENTF_MOVE, x, y, 0,0);
        Sleep(2000);
    }
}


Note: The project is an executable (PC only, Windows 2000 or XP)
that you can download as zip archive here.


Additional code (include):
'nostalG2.h'


Website / background information:
http://www.retroyou.org/nostalG2/

artists' comments