April 15, 2024, 10:24:02 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Programming a Star Wars Movie ?

Started by sapero, April 25, 2007, 09:43:54 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sapero

April 25, 2007, 09:43:54 AM Last Edit: April 25, 2007, 09:45:44 AM by sapero
 ;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();
}

Rock Ridge Farm (Larry)

I get an error about a restricted port.

sapero

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.

ExMember001


Rock Ridge Farm (Larry)

That worked. Kool.
Some people have lots of time on their hands.