IonicWind Software

Aurora Compiler => General Discussion => Topic started by: sapero on April 25, 2007, 09:43:54 AM

Title: Programming a Star Wars Movie ?
Post by: sapero on April 25, 2007, 09:43:54 AM
 ;D Here is a 3MB ascii Star-Wars movie. It uses telnet to download it, then you can replay it from local file:
Have phun!import int WSAStartup(int x,void *p);
import int socket(int q,int w,int e);
import int connect(int q,void *w,int e);
import int GetTickCount();
import int recv(int q,void *w,int e,int r);
import int closesocket(int q);
import int WSACleanup();
import int Sleep(int q);
import int system(...);
extern _printbuf as string;

#use "ws2_32.lib"

struct HDR
{
int sleep;
int datalen;
int data[0];
}

sub main()
{
download();
//replay();
system("pause");
}

sub replay()
{
int hFile = OpenFile(GetStartPath()+"StarWars.txt", MODE_READ);

HDR hdr;
while (!read(hFile, &hdr, sizeof(hdr)))
{
Sleep(hdr.sleep);
if (hdr.datalen > 32767) hdr.datalen = 32767;
read(hFile, &_printbuf, hdr.datalen);
_printbuf[hdr.datalen+1] = 0;
locate(1, 1);
print(_printbuf);
}
CloseFile(hFile);
}


sub download()
{
int received = 0;
WSAStartup(0x202, &_printbuf);
int sock = socket(2, 1, 6);

unsigned int64 scin[2];scin[0] = 17398472716125732866q, 0q; // towel.blinkenlights.nl:23
connect(sock, &scin, sizeof(scin));
int hFile = OpenFile(GetStartPath()+"StarWars.txt", MODE_CREATE | MODE_WRITE);

HDR hdr;
int time = GetTickCount();

hdr.datalen = recv(sock, &_printbuf, 32767, 0);
while (hdr.datalen > 0)
{
hdr.sleep = GetTickCount() - time;
time = GetTickCount();

write(hFile, &hdr, sizeof(hdr));
write(hFile, &_printbuf, hdr.datalen);

_printbuf[hdr.datalen] = 0;
received += hdr.datalen;
locate(1,1);

print(_printbuf);
SetConsoleTitle(sprint(received/1024.0, " kB"));

hdr.datalen = recv(sock, &_printbuf, 32767, 0);
}
CloseFile(hFile);
closesocket(sock);
WSACleanup();
}
Title: Re: Programming a Star Wars Movie ?
Post by: Rock Ridge Farm (Larry) on April 25, 2007, 10:20:04 AM
I get an error about a restricted port.
Title: Re: Programming a Star Wars Movie ?
Post by: sapero on April 25, 2007, 11:36:52 AM
Maybe try directly from the command prompt:telnet towel.blinkenlights.nl
Using the telnet you can not save this "movie". Telnet port (23) must be enabled in your firewall to view/download this ascii movie.
If your still unable to connect, download the movie from http://www.mytempdir.com/1308532 unpack it where the above program was compiled (in main change download to replay) and run.
Title: Re: Programming a Star Wars Movie ?
Post by: ExMember001 on April 25, 2007, 03:31:34 PM
hehe thats cool ;)
Title: Re: Programming a Star Wars Movie ?
Post by: Rock Ridge Farm (Larry) on April 25, 2007, 05:55:53 PM
That worked. Kool.
Some people have lots of time on their hands.