// Harde poep

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <windows.h>
#include <vfw.h>
#include <digitalv.h>


HINSTANCE hInstance;
HWND hWindow;
BOOL fuckop;
HFONT hFont;
HDC hDC;



char* zooi[] =
{"BOOOO!!","LAM","BULLL!","WE","FLOW","WITH","THE","STREAM","BREAK","YOUR","LIMITS","FREE","YOURSELF","STOP","THE","REPRESSION"};
int zoois = sizeof(zooi) / sizeof(char*);

char* zooi2[] =
{"QUAD","ACME","INFANT","HUGO","METABOLIC","MUX","INFUSE","OVERFLOW","www.microsoft.com","SELECT","SUCCESS","JAL"};
int zooi2s = sizeof(zooi2) / sizeof(char*);


static LONG APIENTRY _winWinProc(HWND hWnd,UINT message,UINT wParam,LONG lParam)
{
	switch(message)
	{
		case WM_CLOSE:
		case WM_DESTROY:
			fuckop = 1;
			break;
	}
	return DefWindowProc(hWnd,message,wParam,lParam);
}


static BOOL _winInitApplication(HANDLE hInstance)
{
	WNDCLASS wc;

	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc = (WNDPROC)_winWinProc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = hInstance;
	wc.hIcon = LoadIcon(NULL,IDI_ASTERISK);
	wc.hCursor = LoadCursor(NULL,IDC_ARROW);
	wc.hbrBackground = CreateSolidBrush(0);
	wc.lpszMenuName = "WIN95";
	wc.lpszClassName = "ZUIG!";
	return RegisterClass(&wc);
}

unsigned long __stdcall Musicplayer(void* fiets)
{
	PlaySound("NIXSIMM.WAV",NULL,SND_FILENAME);
	fuckop=1;
	return 0;
}

void wprintf(int x,int y,char* s)
{
	TextOut(hDC,x,y,s,strlen(s));
}


void Windowz()
{
	MSG msg;
	int oldtime,time;

	oldtime = timeGetTime();
	while(PeekMessage(&msg,0,0,0,PM_REMOVE))
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
}


int PASCAL WinMain(HINSTANCE hInst,HINSTANCE hPrevInst,LPSTR lpCmdLine,int nCmdShow)
{
	MSG msg;
	RECT rc;
	HBRUSH hBr;
	unsigned long threadid;
	float xsize=0,ysize=0;
	int rx,ry;
	MCI_DGV_OPEN_PARMS    mciOpen; 
	MCI_DGV_RECT_PARMS mciRect; 
	HWND hwndMovie;
	   MCI_DGV_WINDOW_PARMS mciWindow; 
    MCI_DGV_PLAY_PARMS mciPlay;    // play parameters 
	MCI_DGV_PUT_PARMS mciPut;
    DWORD dwFlags = MCI_DGV_PLAY_REPEAT; 
	DWORD wDeviceID;
	RECT vierkant;
	int sizes_ready;
	int tx,ty,oldtime,starttime;
	char* txt;
 
    if(!_winInitApplication(hInst))
		return 0;
	hFont = CreateFont(40,0,0,0,FW_REGULAR,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH | FF_SWISS,"Arial");
	hWindow = CreateWindow("ZUIG!","Flush!",WS_CAPTION | WS_SYSMENU | WS_BORDER,320,240,0,0,NULL,NULL,hInst,NULL);
	ShowWindow(hWindow,SW_SHOWNORMAL);
	UpdateWindow(hWindow);
	fuckop = 0;
	hBr = CreateSolidBrush(0x00000);
	CreateThread(NULL,NULL,&Musicplayer,0,0,&threadid);


	mciOpen.lpstrElementName = "nixsimm.avi";  // set the filename 
	mciOpen.dwStyle = WS_CHILD;            // set the style 
	mciOpen.hWndParent = hWindow;             // give a window handle 
		mciSendCommand(0, MCI_OPEN, 
		(DWORD)(MCI_OPEN_ELEMENT|MCI_DGV_OPEN_PARENT|MCI_DGV_OPEN_WS), 
		(DWORD)(LPSTR)&mciOpen);
	wDeviceID = mciOpen.wDeviceID;
	mciSendCommand(wDeviceID, MCI_WHERE, MCI_DGV_WHERE_SOURCE, 
		(DWORD)(LPSTR)&mciRect); 

	rx = 360;
	ry = 288;
	sizes_ready = 0;
	starttime = timeGetTime();
	while(!fuckop && !sizes_ready)
	{
		Windowz();

		if (xsize< rx)
				xsize+=.4f; 
		else
			xsize = rx;
		if (ysize<ry)
				ysize+=0.3f;
		else
			ysize = ry;
		if((xsize == rx) && (ysize == ry))
			sizes_ready = 1;

		SetWindowPos(hWindow,HWND_TOPMOST,320-xsize/2,240-ysize/2,xsize,ysize,0);
	}

    mciWindow.hWnd = hWindow; 
    mciSendCommand(wDeviceID, MCI_WINDOW, MCI_DGV_WINDOW_HWND, 
        (DWORD)(LPSTR)&mciWindow); 
	mciSendCommand(wDeviceID, MCI_PLAY, dwFlags, (DWORD)(LPVOID)&mciPlay);

	oldtime = timeGetTime();

	tx = 12;
	ty = 30;
	txt = zooi[0];
	while(!fuckop && (timeGetTime() < (starttime + 36000)))
	{
		Windowz();
		hDC = GetDC(hWindow);
		SelectObject(hDC,hFont);
		SetTextColor(hDC,0xFFFFFF);
		SetBkMode(hDC,TRANSPARENT);
		SetTextAlign(hDC,TA_LEFT | TA_TOP);
		SelectObject(hDC,hBr);
		if((timeGetTime() - oldtime) >= 100)
		{
			tx = -40 + rand() % rx;
			ty = -40 + rand() % ry;
			txt = zooi[rand() % zoois];
			oldtime = timeGetTime();
		}
		wprintf(tx,ty,txt);
		ReleaseDC(hWindow,hDC);
		UpdateWindow(hWindow);
	}

	ShowWindow(hWindow,SW_HIDE);

	hDC = GetDC(0);
	hFont = CreateFont(120,0,0,0,FW_REGULAR,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH | FF_SWISS,"Arial");
	rc.left = 0;
	rc.right = 9999;
	rc.top = 0;
	rc.bottom = 9999;
	while(!fuckop && (timeGetTime() < (starttime + 76000)))
	{
		Windowz();
		SelectObject(hDC,hFont);
		SetTextColor(hDC,0x0000FF);
		SetBkMode(hDC,TRANSPARENT);
		SetTextAlign(hDC,TA_LEFT | TA_TOP);
		SelectObject(hDC,hBr);
		if((timeGetTime() - oldtime) >= 100)
		{
			tx = -40 + rand() % 1000;
			ty = -40 + rand() % 800;
			txt = zooi2[rand() % zooi2s];
			oldtime = timeGetTime();
			InvalidateRect(0,&rc,0);
		}
		wprintf(tx,ty,txt);
		UpdateWindow(hWindow);
	}
	while(!fuckop);

	while(1)
	{
		hFont = CreateFont(15,0,0,0,FW_REGULAR,FALSE,FALSE,FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH | FF_SWISS,"Arial");
	hBr = CreateSolidBrush(0xCC0000);
	SelectObject(hDC,hFont);
	SetTextColor(hDC,0xCCCCCC);
	SetBkMode(hDC,TRANSPARENT);
	SetTextAlign(hDC,TA_LEFT | TA_TOP);
	SelectObject(hDC,hBr);
	FillRect(hDC,&rc,hBr);		
	wprintf(400,400,"Simm has caused an illegal exception and will be terminated.");
	wprintf(400,430,"This is ofcourse not Microsofts fault, but mainly being caused by Nix.");
	wprintf(400,490,"Press any key to reboot.");
	}
	return 0;
}