コード例 #1
0
ファイル: Hello.cpp プロジェクト: yandroskaos/XkyOS
PUBLIC void Main()
{
	//PUT HERE YOUR CODE
	string hello_world = STRING("Hello world!");
	XKY_DEBUG_Message(&hello_world, SRGB(255, 0, 0));
	XKY_OS_Finish();
}
コード例 #2
0
ファイル: chart.cpp プロジェクト: Soltero/reenigne
    void run()
    {
        Vector screenSize(640+2*8, 400+2*8);
        Vector size = screenSize*Vector(5, 8);
        Bitmap<SRGB> output(size);
        output.fill(SRGB(0, 0, 0));
        for (int y = 0; y < size.y; ++y) {
            int yMaj = y/screenSize.y;
            int yMin = y%screenSize.y;
            static const int portValueTable[8] = {
                0x1a00, 0x1e00, 0x0a00, 0x0a10,
                0x0a20, 0x0a30, 0x0e20, 0x0e30};
            int overscan = ((yMin - 8)/12) & 0x0f;
            int portValues = portValueTable[yMaj] | overscan;
            bool bpp1 = ((portValues & 0x1000) != 0);
            bool bw = ((portValues & 0x0400) != 0);
            bool backGroundI = ((portValues & 0x10) != 0);
            bool colorSel = ((portValues & 0x20) != 0);
            int pal[4];
            pal[0] = overscan;
            pal[1] = 2;
            pal[2] = 4;
            pal[3] = 6;
            if (colorSel || bw) {
                pal[1] = 3;
                pal[3] = 7;
            }
            if (colorSel && !bw)
                pal[2] = 5;
            if (backGroundI) {
                pal[1] += 8;
                pal[2] += 8;
                pal[3] += 8;
            }
            char topLine[40];
            memcpy(topLine, " 0 1  2 3  4 5  6 7  8 9  A B  C D  E F ", 40);
            topLine[0] = nybble(portValues >> 12);
            topLine[1] = nybble(portValues >> 8);
            topLine[2] = nybble(portValues >> 4);
            topLine[3] = nybble(portValues);
            for (int x = 0; x < screenSize.x; ++x) {
                if (yMin < 8) {
                    char ch = topLine[x/16];
                    // TODO
                    continue;
                }
                int pattern = (x - 8)/40;
                if (x < 8 || x >= 640 + 8)
                    pattern = 0;

            }


        }

        RawFileFormat raw(size);
        raw.save(output, File("chart.raw"));
    }
コード例 #3
0
ファイル: CBrowser.cpp プロジェクト: eriser/koblo_software-1
void CBrowser::OnDraw(const SRect &rUpdate)
{
	if( !IsVisible() )
		return;

	mpPrimitives->DrawRect(rUpdate, GetRect(), SRGB(192, 192, 192));

	SPos Pos(GetPos() + SPos(miMarginLeft, miMarginTop));
	DrawItems(rUpdate, mItemRoot.SubItems, Pos);
}
コード例 #4
0
ファイル: blittest.c プロジェクト: rofl0r/openDOW
static void clear() {
	uint_fast16_t x, w = VMODE_W;
	uint_fast16_t y, h = VMODE_H;
	sdl_rgb_t *pix, *ptr = pix = (sdl_rgb_t*) surface->pixels;
	uint_fast32_t pitch = surface->pitch / 4, inc = pitch - VMODE_W;
	for(y=0;y<h;y++) {
		for(x=0;x<w;x++) *ptr++ = SRGB(0,0,0);
		ptr+=inc;
	}
}
コード例 #5
0
ファイル: DecoratorDefs.cpp プロジェクト: dyao-vu/meta-core
	SRGB HSBtoRGB( SHSB hsb )
	{
		int h = ( hsb.h % 360 ) / 60;
		int i = h;
		int f = h - i;
		int p = hsb.b * ( 1 - hsb.s );
		int q = hsb.b * ( 1 - hsb.s * f );
		int t = hsb.b * ( 1 - hsb.s * ( 1- f ) );

		if ( hsb.s == 0 )
			return SRGB( hsb.b, hsb.b, hsb.b );

		switch( i ) {
			case 0 : return SRGB( hsb.b, t, p );
			case 1 : return SRGB( q, hsb.b, p );
			case 2 : return SRGB( p, hsb.b, t );
			case 3 : return SRGB( p, q, hsb.b );
			case 4 : return SRGB( t, p, hsb.b );
			default : return SRGB( hsb.b, p, q );
		}
	}
コード例 #6
0
ファイル: Physics.cpp プロジェクト: rein4ce/VoidEngine
NewtonBody* AddBox(CScene *pScene, NewtonWorld *pWorld, Vector3 pos, Vector3 size, Vector3 rot, float mass)
{
	static map<string, CGeometry*> geometries;
	static CMaterial *material = NULL;

	if (!material)
	{
		material = new CMaterial();
		//material->features = EShaderFeature::LIGHT | EShaderFeature::FOG;// | EShaderFeature::SHADOW;
		//material->transparent = true;
		
	}


	string name = str("%f_%f_%f", size.x, size.y, size.z);
	if (geometries.find(name) == geometries.end())
	{
		CGeometry *g = new CCubeGeometry(size.x, size.y, size.z);
		g->materials.AddToTail(material);
		geometries[name] = g;		
	}

	CMesh *box = new CMesh( geometries[name] );

	box->SetPosition(pos);
	box->SetRotation(rot);	
	//box->matrixModel.SetEulerAngles(box->rotation);
	NewtonBody *body = CPhysics::CreateBox(pWorld, box, size.x, size.y, size.z, mass);

	box->color = SRGB(clamp(pos.x*255.0f/32.0f,0,255)*0.9f, clamp(pos.y*255.0f/32.0f,0,255)*0.9f, clamp(pos.z*255.0f/32.0f,0,255)*0.9f);


	//NewtonBodySetMaterialGroupID(body, gLevelBlocksMaterialID);							// ENABLED COLLISION 
	pScene->Add(box);
	NewtonBodySetForceAndTorqueCallback(body, BoxGravityCallback);
	NewtonBodySetAutoSleep(body, 1);			// make boxes go to sleep automatically (default)
	return body;
}
コード例 #7
0
ファイル: EffectsGame.cpp プロジェクト: rein4ce/VoidEngine
void CEffectsGame::UpdateBullets( float frametime )
{
	for (int i=0; i<MAX_BULLETS; i++) 
	{
		if (bullets[i] == NULL) continue;;

		CSprite3D *bullet = bullets[i];

		Vector3 move = bullet->velocity * frametime;
		Vector3 start = bullet->GetPosition();
		bullet->Move(move.x, move.y, move.z);
		bullet->velocity.y -= frametime * cv_bulletGravity.GetFloat();

		bullet->lockedAxis = bullet->velocity;
		bullet->lockedAxis.Normalize();

		Vector3 v = bullet->velocity;
		v.Normalize();
		gRenderer.AddLine(bullet->GetPosition(), bullet->GetPosition() + v, SRGBA(255,230,180,180));


		if (bullet->GetWorldPosition().y < 0) 
		{
			RemoveBullet(i);
		}

		SMapTile *tileHit;
		Vector3 tileHitPos;
		Vector3 pos;
		bool hit = false;
		if (hit = pLevel->CastRay(start, bullet->GetPosition(), OUT tileHitPos, OUT &tileHit, OUT &pos))
		{			
				EnterCriticalSection(&renderCS);
				tileHit->type = 0;
				LeaveCriticalSection(&renderCS);

				// remove tile from the level and mark for update
				SMapChunk *chunk = pLevel->GetChunk(
					floor(tileHitPos.x/SMapChunk::Size),
					floor(tileHitPos.y/SMapChunk::Size),
					floor(tileHitPos.z/SMapChunk::Size) );

				chunk->dirtyBody = true;
				chunk->dirty = true;
				
				// add a box to spawn list
				SSpawnTile s;
				s.pos = tileHitPos;
				s.vel = v * cv_bulletforce.GetFloat();
				boxesToSpawn.push(s);			
				
				// remove bullet
				RemoveBullet(i);

				float puffSpeed = 0.5;

				// add puff effect
				for (int i = 0; i<6; i++)
				{					
					static CTexture *puffTex = new CTexture("particles/explosion4.dds");
					CParticle *p = new CParticle(puffTex);
					p->size = Vector2(1.35, 1.35);
					p->position = pos;
					p->velocity = Vector3( frand(-puffSpeed,puffSpeed), frand(-puffSpeed,puffSpeed), frand(-puffSpeed,puffSpeed) );
					p->lifetime = 1;
					//p->color = SRGBA(155,155,155,255);
					p->color = SRGB(clamp(pos.x*255.0f/32.0f,0,255)*0.9f, clamp(pos.y*255.0f/32.0f,0,255)*0.9f, clamp(pos.z*255.0f/32.0f,0,255)*0.9f);
					p->colorChange = p->color;// SRGBA(255,255,255,0);
					p->colorChange.a = 0;
					p->colorTime = 1;
					p->sizeVel = Vector2(0.85,0.85);
					particles->Add(p);
				}
		}		
	
	}

	//PrintText("Bullets: %d", bulletsNum);
}
コード例 #8
0
ファイル: DecoratorDefs.cpp プロジェクト: dyao-vu/meta-core
	SRGB CRtoRGB( COLORREF rc )
	{
		return SRGB( GetRValue( rc ), GetGValue( rc ), GetBValue( rc ) );
	}
コード例 #9
0
ファイル: vcr_decode.cpp プロジェクト: reenigne/reenigne
    void decodeField()
    {
        while (nn > 0) {
            inputStream.read(&input[0], min(nn, samplesPerFrame));
            nn -= samplesPerFrame;

            Complex<float> linePhase;
            if ((frame & 1) == 0)
                linePhase = framePhase * Complex<float>(0, 1);
            else
                linePhase = framePhase;

            int p = 1824*2 + 1820;
            int x;
            int lows = 0;
            for (x = 0; x < 1820; ++x) {
                if (input[p] < 22)
                    ++lows;
                if (lows > 20)
                    break;
                ++p;
                if (p >= samplesPerFrame - 1)
                    break;
            }
            p += 133 - 20;
            p -= 1820 - 10;
            if (x < 1000)
                p += 1820;

            for (int y = 3; y < 253; ++y) {
                float pFrac;
                p += 1820 - 10;
                for (x = 0; x < 20; ++x) {
                    if (input[p] >= 22)
                        break;
                    ++p;
                    if (p >= samplesPerFrame - 1)
                        break;
                }
                int d = input[p] - input[p - 1];
                if (d == 0)
                    pFrac = 0;
                else
                    pFrac = static_cast<float>(input[p] - 22)/d;
                // 22 position is input[p - pFrac]

                for (x = 0; x < 1820; ++x) {
                    if (p + x - 64 >= samplesPerFrame)
                        break;
                    _fftData[x] = input[p + x - 64];
                }
                for (; x < 2048; ++x)
                    _fftData[x] = 0;

                // TODO: shift by pFrac

                Complex<float> burst = 0;
                int nBurst = (y & 1 ? 46 : 45);
                for (int x = 0; x < nBurst; ++x)
                    burst += _fftData[x + 76]*unit(x*2.0f/91);
                burst /= nBurst;
                burstAcc = burstAcc*0.9f + burst*0.1f;

                Complex<float> localOscillator = 1;
                Complex<float> chromaOscillator = 1;

                float total = 0;
                for (int i = 0; i < 1666; ++i) {
                    float v = _fftData[i + 82].x;
                    _chromaData[i + 82] = v * chromaOscillator;
                    total += v;
                }
                float mean = total/1666;
                for (int i = 0; i < 160; ++i)
                    _chromaData[i] = mean;
                for (int i = 1666+82; i < 2048; ++i)
                    _chromaData[i] = mean;


                for (int i = 0; i < 2048; ++i) {
                    _chromaData[i] *= chromaOscillator;
                    _fftData[i] *= localOscillator;
                    localOscillator *= localOscillatorFrequency;
                    chromaOscillator *= chromaOscillatorFrequency;
                }

                fftwf_execute(_forward);
                fftwf_execute(_chromaForward);
                for (int x = cutoff; x < 2048 - cutoff; ++x)
                    _fftData[x] = 0;
                for (int x = chromaCutoff; x < 2048 - chromaCutoff; ++x)
                    _chromaData[x] = 0;
                fftwf_execute(_chromaBackward);

                fftwf_execute(_backward);
                for (int x = 0; x < 2047; ++x) {
                    float deltaPhase = (_fftData[x + 1]/fftData[x]).argument();
                    // 0  MHz                     <=> 0 deltaPhase
                    // 3.4MHz <=> -40   IRE                             1 MHz
                    //              7.5 IRE <=>   0
                    // 4.4MHz <=> 100   IRE <=> 255                     0 MHz
                    // 315/11MHz                  <=> tau deltaPhase
                    float mhz = deltaPhase*315/(tau*11);
                    float ire = (1.0f - mhz)*140 - 40;
                    fftData[x] = (ire - 7.5f)*255.0f/(100 - 7.5);
                }

                //fftwf_execute(_forward);
                //for (int x = 0; x < 206; ++x) {
                //    fftData[x + 2] *= 50.0f/(preamp[x]*2048.0f);
                //    fftData[2048 - (x + 2)] *= 50.0f/(preamp[x]*2048.0f);
                //}
                //fftwf_execute(_backward);

                Complex<float> chromaPhase = burstAcc.conjugate()*linePhase/burstAcc.modulus();

                for (int x = 0; x < 2048; ++x) {
                    //outputb[x] = byteClamp(fftData[x].x / 2048.0f);
                    float yy = _fftData[x].x;
                    Complex<float> c = _chromaData[x]*chromaPhase / 20.48f; //  / 100.0f;
                    float ii = c.x;
                    float qq = c.y;
                    frameCache[(((frame + 2)%3)*253 + y)*2048 + x] =
                        Vector3<float>(
                            yy + 0.9563*c.x + 0.6210*c.y,
                            yy - 0.2721*c.x - 0.6474*c.y,
                            yy - 1.1069*c.x + 1.7046*c.y);
                }
                if ((frame & 1) != 0)
                    linePhase *= Complex<float>(0, -1);
                else
                    linePhase *= Complex<float>(0, 1);

                //if (frame >= 1041 && frame <= 1638) {
                //    fftwf_execute(forward);
                //    //for (int x = 0; x < 2048; ++x)
                //    //    amplitudes[y*2048 + x] = fftData[x].modulus() / 2048.0f;
                //    amplitudes[y] += fftData[y + 2];
                //}

                //h.write(outputb);
            }
            printf(".");

            for (int y = 3; y < 253; ++y) {
                int p = (((frame + 1)%3)*253 + y)*2048;
                int pu = (((frame + 1)%3)*253 + y - 1)*2048;
                if (y == 0)
                    pu = p;
                int pd = (((frame + 1)%3)*253 + y + 1)*2048;
                if (y == 252)
                    pd = p;
                int pp = ((frame%3)*253 + y)*2048;
                int pn = (((frame + 2)%3)*253 + y)*2048;

                for (int x = 0; x < 2048; ++x) {
                    Vector3<float> c = frameCache[p + x];
                    _outputb0[x] = SRGB(byteClamp(c.x), byteClamp(c.y), byteClamp(c.z));
                    c = (frameCache[pu + x] + frameCache[pd + x] + frameCache[pp + x] + frameCache[pn + x])/4.0f;
                    _outputb1[x] = SRGB(byteClamp(c.x), byteClamp(c.y), byteClamp(c.z));
                }

                if (frame%2 != 0) {
                    h.write(_outputb0);
                    h.write(_outputb1);
                }
                else {
                    h.write(_outputb1);
                    h.write(_outputb0);
                }
            }

            //if (frame >= 1041 && frame <= 1638) {
            //    int bestOffset;
            //    float bestAmplitude = 0;
            //    for (int offset = -10; offset < 10; ++offset) {
            //        float amplitude = 0;
            //        for (int y = 0; y < 253; ++y)
            //            if (y+offset >= 0)
            //                amplitude += amplitudes[y*2048 + y + offset];
            //        if (amplitude > bestAmplitude) {
            //            bestAmplitude = amplitude;
            //            bestOffset = offset;
            //        }
            //    }
            //    printf("frame %i strongest offset %i amplitude %f\n", frame, bestOffset);
            //}

            ++frame;

            if ((frame & 1) == 0)
                framePhase *= Complex<float>(0, 1);

        }
        //for (int y = 0; y < 253; ++y)
        //    printf("  %f, %f,\n", amplitudes[y].x / (1639 - 1041), amplitudes[y].y / (1639 - 1041));
    }
コード例 #10
0
ファイル: MtTest.cpp プロジェクト: yandroskaos/XkyOS
PUBLIC void Main()
{
	if(!LoadRTL(0x40000000)) goto _Finish;

	//Alloc window
	window = XKY_WINDOW_Alloc();
	if(!window)	goto _Finish;

	//Set random seed
	SetSeed(XKY_RTC_Seconds() + XKY_TMR_GetTicks());
	
	//Set exception handler for memory failures
	//XKY_EXCEPTION_SetHandler(0x0E, MtTestExceptionHandler);

	//Set-up stacks so thread finds it's parameters on it
	PAINT_PARAMETERS* p1 = (PAINT_PARAMETERS*)HEAP_Alloc(sizeof(PAINT_PARAMETERS));
	p1->x		= 0;
	p1->y		= 0;
	p1->width	= XKY_WINDOW_GetWidth(window)/2;
	p1->height	= XKY_WINDOW_GetHeight(window)/2;
	p1->color	= SRGB(255, 0, 0);

	PAINT_PARAMETERS* p2 = (PAINT_PARAMETERS*)HEAP_Alloc(sizeof(PAINT_PARAMETERS));
	p2->x		= 0;
	p2->y		= XKY_WINDOW_GetHeight(window)/2;
	p2->width	= XKY_WINDOW_GetWidth(window)/2;
	p2->height	= XKY_WINDOW_GetHeight(window)/2;
	p2->color	= SRGB(0, 255, 0);

	PAINT_PARAMETERS* p3 = (PAINT_PARAMETERS*)HEAP_Alloc(sizeof(PAINT_PARAMETERS));
	p3->x		= XKY_WINDOW_GetWidth(window)/2;
	p3->y		= XKY_WINDOW_GetHeight(window)/2;
	p3->width	= XKY_WINDOW_GetWidth(window)/2;
	p3->height	= XKY_WINDOW_GetHeight(window)/2;
	p3->color	= SRGB(0, 0, 255);

	PAINT_PARAMETERS* p4 = (PAINT_PARAMETERS*)HEAP_Alloc(sizeof(PAINT_PARAMETERS));
	p4->x		= XKY_WINDOW_GetWidth(window)/2;
	p4->y		= 0;
	p4->width	= XKY_WINDOW_GetWidth(window)/2;
	p4->height	= XKY_WINDOW_GetHeight(window)/2;
	p4->color	= SRGB(255, 255, 255);


	//Create threads
	ThreadInit();
	HANDLE t1 = CreateThread(PaintThread, p1);
	HANDLE t2 = CreateThread(PaintThread, p2);
	HANDLE t3 = CreateThread(PaintThread, p3);
	HANDLE t4 = CreateThread(PaintThread, p4);

	//Init scheduler iterator
	scheduler = LIST_First(&threads);

	//Start scheduler
	//XKY_CPU_RegisterCallback(XKY_ADDRESS_SPACE_GetCurrent(), MtCpuTimerCallbackFCFS);
	XKY_CPU_RegisterCallback(XKY_ADDRESS_SPACE_GetCurrent(), MtCpuTimerCallbackRoundRobin);

	while(!ThreadHasFinished(t1) || !ThreadHasFinished(t2) || !ThreadHasFinished(t3) || !ThreadHasFinished(t4));

	//All threads finished
	dword width = XKY_WINDOW_GetWidth(window);
	dword height = XKY_WINDOW_GetHeight(window);

	for(dword x = 0; x < width; x++)
	{
		for(dword y = 0; y < height; y++)
		{
			XKY_WINDOW_SetPixel(window, x, y, TRGB(0, 0, 0));
		}
	}

	XKY_WINDOW_PrintText(window, 200, 200, SRGB(255, 0, 255), &DONE);

_Finish:
	XKY_OS_Finish();
}
コード例 #11
0
ファイル: MtTest_GuestOS.cpp プロジェクト: yandroskaos/XkyOS
//FCFS
PRIVATE bool MtCpuTimerCallbackFCFS(IN CPU_EXECUTION* _execution, IN dword _interrupt_sequence, IN dword _max_interrupt_per_sequence)
{
	//Ok, start
	if(first_time)
	{
		first_time = false;
		//Save
		original = *_execution;

		//Initialize
		c1 = *_execution;
		c2 = *_execution;
		c3 = *_execution;
		c4 = *_execution;

		c1.eax = c2.eax = c3.eax = c4.eax = 0;
		c1.ebx = c2.ebx = c3.ebx = c4.ebx = 0;
		c1.ecx = c2.ecx = c3.ecx = c4.ecx = 0;
		c1.edx = c2.edx = c3.edx = c4.edx = 0;
		c1.esi = c2.esi = c3.esi = c4.esi = 0;
		c1.edi = c2.edi = c3.edi = c4.edi = 0;
		c1.ebp = c2.ebp = c3.ebp = c4.ebp = 0;

		c1.esp = (VIRTUAL)((byte*)p1 - 4);
		c2.esp = (VIRTUAL)((byte*)p2 - 4);
		c3.esp = (VIRTUAL)((byte*)p3 - 4);
		c4.esp = (VIRTUAL)((byte*)p4 - 4);

		c1.eip = c2.eip = c3.eip = c4.eip = (dword)PaintThread;
		c1.eflags = c2.eflags = c3.eflags = c4.eflags = 0x00000202;

		XKY_DEBUG_Data(&Rescheduling1, original.eip, SRGB(255, 0, 255));
		return false;
	}

	if(!thread1_running && !thread2_running && !thread3_running && !thread4_running)
	{
		if(!threads_done)
		{
			threads_done = true;
			*_execution = original;
			XKY_DEBUG_Data(&Rescheduling2, original.eip, SRGB(255, 0, 255));
			return true;
		}
		XKY_DEBUG_Data(&Rescheduling3, _execution->eip, SRGB(255, 0, 255));
		return false;
	}

	*current_execution = *_execution;

	if(current_execution == &c1)
	{
		if(thread1_running)
			return false;
		else
			current_execution = &c2;
	}
	else if(current_execution == &c2)
	{
		if(thread2_running)
			return false;
		else
			current_execution = &c3;
	}
	else if(current_execution == &c3)
	{
		if(thread3_running)
			return false;
		else
			current_execution = &c4;
	}
	else if(current_execution == &c4)
	{	
		if(thread4_running)
			return false;
		else
			current_execution = &original;
	}
	else
	{
		if(thread1_running)
		{
			current_execution = &c1;
		}
	}

	*_execution = *current_execution;
	return true; //Means another thread scheduled
}
コード例 #12
0
ファイル: MtTest_GuestOS.cpp プロジェクト: yandroskaos/XkyOS
PUBLIC void Main()
{
	//Alloc window
	window = XKY_WINDOW_Alloc();
	if(!window)	goto _Finish;

	//Set random seed
	SetSeed(XKY_RTC_Seconds());
	
	//Set exception handler for memory failures
	//XKY_EXCEPTION_SetHandler(0x0E, MtTestExceptionHandler);

	//Alloc stacks
	byte* stack1 = XKY_PAGE_Alloc(0x10000000, 1);
	if(!stack1) goto _Finish;

	byte* stack2 = XKY_PAGE_Alloc(0x20000000, 1);
	if(!stack2) goto _Finish;

	byte* stack3 = XKY_PAGE_Alloc(0x30000000, 1);
	if(!stack3) goto _Finish;

	byte* stack4 = XKY_PAGE_Alloc(0x40000000, 1);
	if(!stack4) goto _Finish;

	//Set-up stacks so thread finds it's parameters on it
	p1 = (PAINT_PARAMETERS*) (stack1 + PAGE_SIZE - sizeof(PAINT_PARAMETERS) - 4);
	p1->xid		= 1;
	p1->running	= &thread1_running;
	p1->x		= 0;
	p1->y		= 0;
	p1->width	= XKY_WINDOW_GetWidth(window)/2;
	p1->height	= XKY_WINDOW_GetHeight(window)/2;
	p1->color	= SRGB(255, 0, 0);

	p2 = (PAINT_PARAMETERS*) (stack2 + PAGE_SIZE - sizeof(PAINT_PARAMETERS) - 4);
	p2->xid		= 2;
	p2->running	= &thread2_running;
	p2->x		= 0;
	p2->y		= XKY_WINDOW_GetHeight(window)/2;
	p2->width	= XKY_WINDOW_GetWidth(window)/2;
	p2->height	= XKY_WINDOW_GetHeight(window)/2;
	p2->color	= SRGB(0, 255, 0);

	p3 = (PAINT_PARAMETERS*) (stack3 + PAGE_SIZE - sizeof(PAINT_PARAMETERS) - 4);
	p3->xid		= 3;
	p3->running	= &thread3_running;
	p3->x		= XKY_WINDOW_GetWidth(window)/2;
	p3->y		= XKY_WINDOW_GetHeight(window)/2;
	p3->width	= XKY_WINDOW_GetWidth(window)/2;
	p3->height	= XKY_WINDOW_GetHeight(window)/2;
	p3->color	= SRGB(0, 0, 255);

	p4 = (PAINT_PARAMETERS*) (stack4 + PAGE_SIZE - sizeof(PAINT_PARAMETERS) - 4);
	p4->xid		= 4;
	p4->running	= &thread4_running;
	p4->x		= XKY_WINDOW_GetWidth(window)/2;
	p4->y		= 0;
	p4->width	= XKY_WINDOW_GetWidth(window)/2;
	p4->height	= XKY_WINDOW_GetHeight(window)/2;
	p4->color	= SRGB(255, 255, 255);

	
	//Create threads
	XKY_CPU_RegisterCallback(XKY_CPU_GetCurrent(), MtCpuTimerCallbackFCFS);

    //Done, stop this thread
	XKY_WINDOW_PrintText(window, 100, 100, SRGB(255, 0, 255), &OK);
	for(;thread1_running || thread2_running || thread3_running || thread4_running;);

	//All threads finished
	dword width = XKY_WINDOW_GetWidth(window);
	dword height = XKY_WINDOW_GetHeight(window);
	for(dword x = 0; x < width; x++)
	{
		for(dword y = 0; y < height; y++)
		{
			XKY_WINDOW_SetPixel(window, x, y, SRGB(0, 0, 0));
		}
	}

	XKY_WINDOW_PrintText(window, 200, 200, SRGB(255, 0, 255), &DONE);

_Finish:
	XKY_OS_Finish();
}