
// cl /Fa simple.cpp

// dumps asm out to file :)

#define SCREEN_WIDTH	640
#define SCREEN_HEIGHT	480

int framebuffer = 0xf0010000 + 640*320 + 80;

void DrawPixel(int x, int y, unsigned int dwPixelColourRGB) // AARRGGBB
{
	// Placed into memory in the order BLUE-GREEN-RED not RGB as you'd think :)
    ((unsigned char*)framebuffer)[(x + y*SCREEN_WIDTH)*4+0] = dwPixelColourRGB & 0x000000ff;
	((unsigned char*)framebuffer)[(x + y*SCREEN_WIDTH)*4+1] = (dwPixelColourRGB & 0x0000ff00) >> 8;
	((unsigned char*)framebuffer)[(x + y*SCREEN_WIDTH)*4+2] = (dwPixelColourRGB & 0x00ff0000) >> 16;
}


int main()
{

	while(true)
	{

		DrawPixel(SCREEN_WIDTH/2 ,SCREEN_HEIGHT/2, 0xffff00);
		
	}

  return 0;
}

/*
#include <stdio.h>

// cl /Fa simple.cpp

// dumps asm out to file :)

#define SCREEN_WIDTH	640
#define SCREEN_HEIGHT	480

int framebuffer = 0xf0010000 + 640*320 + 80;

void DrawPixel(int x, int y, unsigned int dwPixelColourRGB) // AARRGGBB
{
	// Placed into memory in the order BLUE-GREEN-RED not RGB as you'd think :)
    ((unsigned char*)framebuffer)[(x + y*SCREEN_WIDTH)*4+0] = dwPixelColourRGB & 0x000000ff;
	((unsigned char*)framebuffer)[(x + y*SCREEN_WIDTH)*4+1] = (dwPixelColourRGB & 0x0000ff00) >> 8;
	((unsigned char*)framebuffer)[(x + y*SCREEN_WIDTH)*4+2] = (dwPixelColourRGB & 0x00ff0000) >> 16;
}

// This is our super cool line drawing function - of course I'm neglecting
// boundary checking (e.g. clipping), but I'm sure you can add that in later :)
void DrawLine( int x0, int y0, int x1, int y1, unsigned int dwColour )
{
	y1 = (SCREEN_HEIGHT)-y1;
	y0 = (SCREEN_HEIGHT)-y0;

	int deltax = x1-x0;
	int deltay = y1-y0;
	double m = (double)deltay/(double)deltax;

	for( int x=0; x<=deltax; x++ )
	{
		double y=m*(double)x;
		DrawPixel( x0+x, y0+y, dwColour);
	}
}

int main()
{

  	unsigned int c=0;
	while(true)
	{
		c+= 10;

		DrawLine( 0,0, 470, 639, 0x00ffffff );
		
	}

  return 0;
}
*/

