Пример #1
0
	bool __CALLOUT InitializeShell() {
		Clear(BLUE);
		const char* str = "PRICE of HONOR!";
		DrawTextString(40,60,str,Length(str),RED,BLUE);
	
		GetBatteryLevel();
		SetScreenBrightness(100);
		char buff[200];
		int res = snprintf(buff,sizeof(buff),"test %d",0);
		DrawPixel(1,1,WHITE);
		DoVibroAndBeep(500);
		ubyte_t l = GetLustraId();
		SendRadioPacket(NULL,0);
		uword_t a = GetArmletId();
		FILE log;
		OpenFile(&log, "log.txt", true);
		char* s = "log test";
		WriteFile(&log, s, Length(s));	
		/*
		//int i = 0;
		//Color area[100];
		//for (i=0; i<100; i++) area[i] = 0xF0F;
		//DrawArea(5,5,area,100,10,10);
		//WriteFile(&log, (char*)area, 100);
		//for (i=0; i<100; i++) area[i] = 0x0;
		//ReadFile(&log, (char*)area, 100);
		//AppendFile(&log, (char*)area, 100);
		//DrawArea(5,5,area,100,10,10);
		*/
		RequestTimer(TimerProc,100);
		int up = GetUpTime();
		int rnd = GetRandom(50);
		//SetCureName is checked in AppMainThread
		//WritePill is checked in AppMainThread
		//StartThread(AppMainThread,NULL);
		return true; //TODO
	}
Пример #2
0
VOID DispHZK16(int x, int y, unsigned char *pHZ  , __COLOR color)
{   
	int QM=0;//区码
	int WM=0;//位码
	unsigned char * p;//汉字库的起始地址
	unsigned char * pm=0;//将要显示的字模的其实地址
	unsigned char mat[16][2];//字模数组
	int i,j,k=0;
	p=(unsigned char *)CHNCHAR_LIB_BASE;
	QM=*pHZ-0xA0;
	WM=*(pHZ+1)-0xA0;
	pm=p+(94*(QM-1)+(WM-1))*32;
	for(i=0;i<16;i++)
		for(j=0;j<2;j++)
			mat[i][j]=*(pm+i*2+j);
		
		for(i=0;i<16;i++)
			for(j=0;j<2;j++)
				for(k=0;k<8;k++)
					if(mat[i][j]&(0x80>>k))
						DrawPixel(&Video,x+j*8+k,y+i,color);
					
					
}
Пример #3
0
void vfeDisplay::DrawPixelBlock(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, const RGBA8 *colour)
{
  for (int y = y1 ; y <= y2; y++)
    for (int x = x1; x <= x2; x++)
      DrawPixel (x, y, *colour++) ;
}
Пример #4
0
////FUNCTIONS//////////////////
//-----------------------------------------------------------------------------
// Name: Main()
// Desc: Whwere all work is done
//-----------------------------------------------------------------------------
bool main()
{
    static SCCOLOR col;
    static UCHAR* back_buf;
    static HDC hDC;
    static int iFrames=0;
    static int x=0;

    col.b = col.r = col.g = 255;

    if(GetKeyStatus(VK_ESCAPE) == true)
        return(0);

    //Clear the surface
    if(!ClrS(lpddsSecondary,wndRect))//can't be within a lock-Unlock block or u can't blt
        return(0);

    //Write text to the Secondary surface remember to Release the DC
    ddReturnVal = lpddsSecondary->GetDC(&hDC);
    if (DDFailedCheck(ddReturnVal, "GetDC() failed", cpErrorBuf ))
    {
        if(ddReturnVal == DDERR_SURFACELOST)
        {
            lpddsSecondary->Restore();
            lpddsSecondary->GetDC(&hDC);
        }
        else
        {
            MessageBox(main_window_handle, cpErrorBuf, "main()", MB_ICONEXCLAMATION);
            return(0);
        }
    }

    static char buffer[1024];
    SetBkColor(hDC,RGB(0,0,0));
    SetBkMode(hDC,OPAQUE);
    sprintf(buffer, "Time elapsed(s)= %d", (int)(gametimer.GetStartElapsedTime()*0.001) );//0.00001666666f
    static DWORD starttime=GetTickCount();
    if( gametimer.Elapsed(starttime,(60/0.001)) )
        sprintf(buffer,"TIME!"," 1 minute");
    SetTextColor(hDC,RGB(255,255,255));
    iFrames++;
    static int FramesPerSec=0;
    FramesPerSec = iFrames/( ((int)(gametimer.GetStartElapsedTime()*0.001)+1) );
    sprintf(buffer, "Frames/s = %d", FramesPerSec);
    TextOut(hDC, 100,100, buffer, strlen(buffer));

    sprintf(buffer, "X= %d", x);
    TextOut(hDC, 100,140, buffer, strlen(buffer));
    ddReturnVal = lpddsSecondary->ReleaseDC(hDC);
    if (DDFailedCheck(ddReturnVal, "ReleaseDC() failed", cpErrorBuf ))
    {
        MessageBox(main_window_handle, cpErrorBuf, "main()", MB_ICONEXCLAMATION);
        return(0);
    }

    //Lock the surface for drawing
    if(!Lock(lpddsSecondary))
        return(0);

    back_buf = (UCHAR*)ddsd.lpSurface;

    //test drawing pixels
    DrawPixel(ddsd,x+200,100,col);
    DrawPixel(ddsd,x+200,101,col);
    DrawPixel(ddsd,x+200,102,col);
    DrawPixel(ddsd,x+200,103,col);
    DrawPixel(ddsd,x+200,104,col);
    DrawPixel(ddsd,x+200,105,col);
    DrawPixel(ddsd,x+200,106,col);
    DrawPixel(ddsd,x+200,107,col);
    DrawPixel(ddsd,x+200,108,col);
    x++;
    if(x>780)
        x=0;

    //test bitmap class
    for (int y=0; y < bitmap1.GetHeight(); y++)
    {
        // copy the line
        memcpy(&back_buf[100+(y+200)*ddsd.lPitch], // dest address
               &bitmap1.GetImageData()[y*bitmap1.GetWidth()*2],   // src address
               bitmap1.GetWidth()*2);                         // bytes to copy
    } // end for y

    //Unlock the surface
    if(!UnLock(lpddsSecondary))
        return(0);

    if(!Lock(Temp))
        return(0);
    back_buf = (UCHAR*)ddsd.lpSurface;
    for (int y=0; y < bitmap2.GetHeight(); y++)
    {
        // copy the line
        memcpy(&back_buf[y*ddsd.lPitch], // dest address
               &bitmap2.GetImageData()[y*bitmap2.GetWidth()*2],   // src address
               bitmap2.GetWidth()*2);                         // bytes to copy
    } // end for y
    if(!UnLock(Temp))
        return(0);
    static RECT temprect= {200,200,520,400};
    static RECT sorc_rect= {0,0,320,200};
    ddReturnVal = lpddsSecondary->Blt(&temprect/*dest rect*/,Temp, //pointer to source surface
                                      &sorc_rect, //pointer to the source rectangle
                                      DDBLT_WAIT | DDBLT_KEYSRC,NULL);
    if (DDFailedCheck(ddReturnVal, "Blt failed", cpErrorBuf ))
    {
        MessageBox(main_window_handle, cpErrorBuf, "Main()", MB_ICONEXCLAMATION);
        return(0);
    }


    static RECT temprect2;
    temprect2.top=200;
    temprect2.left=500;
    temprect2.right=sprite.GetWidth()+500;
    temprect2.bottom=sprite.GetHeight()+200;
    static int i=0;
    ddReturnVal = lpddsSecondary->Blt(&temprect2/*dest rect*/,sprite.GetFrame(i), //pointer to source surface
                                      NULL, //pointer to the source rectangle
                                      DDBLT_WAIT | DDBLT_KEYSRC,NULL/*ddbltfx struct*/);
    if (DDFailedCheck(ddReturnVal, "Blt failed", cpErrorBuf ))
    {
        MessageBox(main_window_handle, cpErrorBuf, "Main()", MB_ICONEXCLAMATION);
        return(0);
    }
    static DWORD start = GetTickCount();
    if(gametimer.Elapsed(start,120))
    {
        i++;
        start = GetTickCount();
    }
    if(i>13)
        i=0;

    static int size=0;
    temprect2.top=500+size;
    temprect2.left=300+size;
    temprect2.bottom=500+myface.GetWidth()+size;
    temprect2.right=300+myface.GetWidth()+size;
    ddReturnVal = lpddsSecondary->Blt(&temprect2/*dest rect*/,myface.GetFrame(0), //pointer to source surface
                                      NULL, //pointer to the source rectangle
                                      DDBLT_WAIT | DDBLT_KEYSRC,NULL/*ddbltfx struct*/);
    if (DDFailedCheck(ddReturnVal, "Blt failed", cpErrorBuf ))
    {
        MessageBox(main_window_handle, cpErrorBuf, "Main()", MB_ICONEXCLAMATION);
        return(0);
    }

    static int what=0;
    what++;
    size= sin(what)+cos(what+5);

    static int j=0;
    static DWORD start2=GetTickCount();
    if(gametimer.Elapsed(start2,50))
    {
        j++;
        start2=GetTickCount();
    }
    if(j>=3)j=0;
    temprect2.top=500;
    temprect2.left=100;
    temprect2.bottom=500+ship.GetHeight();
    temprect2.right=100+ship.GetWidth();
    ddReturnVal = lpddsSecondary->Blt(&temprect2/*dest rect*/,ship.GetFrame(j), //pointer to source surface
                                      NULL, //pointer to the source rectangle
                                      DDBLT_WAIT | DDBLT_KEYSRC,NULL/*ddbltfx struct*/);
    if (DDFailedCheck(ddReturnVal, "Blt failed", cpErrorBuf ))
    {
        MessageBox(main_window_handle, cpErrorBuf, "Main()", MB_ICONEXCLAMATION);
        return(0);
    }

    temprect2.top=400;
    temprect2.left=500;
    temprect2.bottom=400+recttest.GetHeight()+50;
    temprect2.right=500+recttest.GetWidth()+50;

    ddReturnVal = lpddsSecondary->Blt(&temprect2/*dest rect*/,recttest.GetFrame(0), //pointer to source surface
                                      &recttest.GetRect(), //pointer to the source rectangle
                                      DDBLT_WAIT | DDBLT_KEYSRC,NULL/*ddbltfx struct*/);
    if (DDFailedCheck(ddReturnVal, "Blt failed", cpErrorBuf ))
    {
        MessageBox(main_window_handle, cpErrorBuf, "Main()", MB_ICONEXCLAMATION);
        return(0);
    }

    temprect2.top=485;
    temprect2.left=160;
    temprect2.bottom=485+ship2.GetHeight();
    temprect2.right=160+ship2.GetWidth();
    static int k=0;
    static DWORD start3;
    if(gametimer.Elapsed(start3,0))
    {
        k++;
        start3=GetTickCount();
    }
    if(k>=11)k=0;

    ddReturnVal = lpddsSecondary->Blt(&temprect2/*dest rect*/,ship2.GetFrame(0), //pointer to source surface
                                      &ship2.GetRect(), //pointer to the source rectangle
                                      DDBLT_WAIT | DDBLT_KEYSRC,NULL/*ddbltfx struct*/);
    if (DDFailedCheck(ddReturnVal, "Blt failed", cpErrorBuf ))
    {
        MessageBox(main_window_handle, cpErrorBuf, "Main()", MB_ICONEXCLAMATION);
        return(0);
    }

    Flip();

    return(1);
}
Пример #5
0
void Draw_Second_Hand(unsigned int color)                   // »­·ÖÕëͼÐÎÊý¾Ý
{
  unsigned int i                                          ;
  for(i=0;i<100;i++)
    DrawPixel(SEC_HAND_BUF[i][0],SEC_HAND_BUF[i][1],color);
}
Пример #6
0
void LCD12864::DrawCircle(uint8_t x0, uint8_t y0, uint8_t radius)  //Midpouint8_t circle algorithm
  {
    int f = 1 - radius;
    int ddF_x = 1;
    int ddF_y = -2 * radius;
    int x = 0;
    int y = radius;
 
    DrawPixel(x0, y0 + radius);
    DrawPixel(x0, y0 - radius);
    DrawPixel(x0 + radius, y0);
    DrawPixel(x0 - radius, y0);
 
    while(x < y)
    {
      if(f >= 0) 
      {
        y--;
        ddF_y += 2;
        f += ddF_y;
      }
      x++;
      ddF_x += 2;
      f += ddF_x;    
      DrawPixel(x0 + x, y0 + y);
      DrawPixel(x0 - x, y0 + y);
      DrawPixel(x0 + x, y0 - y);
      DrawPixel(x0 - x, y0 - y);
      DrawPixel(x0 + y, y0 + x);
      DrawPixel(x0 - y, y0 + x);
      DrawPixel(x0 + y, y0 - x);
      DrawPixel(x0 - y, y0 - x);
    }
}
Пример #7
0
void DrawWuLine(int X0, int Y0, int X1, int Y1, int BaseColor, int NumLevels,
   unsigned int IntensityBits)
{
   unsigned int IntensityShift, ErrorAdj, ErrorAcc;
   unsigned int ErrorAccTemp, Weighting, WeightingComplementMask;
   int DeltaX, DeltaY, Temp, XDir;

   /* Make sure the line runs top to bottom */
   if (Y0 > Y1) {
      Temp = Y0; Y0 = Y1; Y1 = Temp;
      Temp = X0; X0 = X1; X1 = Temp;
   }
   /* Draw the initial pixel, which is always exactly intersected by
      the line and so needs no weighting */
   DrawPixel(X0, Y0, BaseColor);

   if ((DeltaX = X1 - X0) >= 0) {
      XDir = 1;
   } else {
      XDir = -1;
      DeltaX = -DeltaX; /* make DeltaX positive */
   }
   /* Special-case horizontal, vertical, and diagonal lines, which
      require no weighting because they go right through the center of
      every pixel */
   if ((DeltaY = Y1 - Y0) == 0) {
      /* Horizontal line */
      while (DeltaX-- != 0) {
         X0 += XDir;
         DrawPixel(X0, Y0, BaseColor);
      }
      return;
   }
   if (DeltaX == 0) {
      /* Vertical line */
      do {
         Y0++;
         DrawPixel(X0, Y0, BaseColor);
      } while (--DeltaY != 0);
      return;
   }
   if (DeltaX == DeltaY) {
      /* Diagonal line */
      do {
         X0 += XDir;
         Y0++;
         DrawPixel(X0, Y0, BaseColor);
      } while (--DeltaY != 0);
      return;
   }
   /* Line is not horizontal, diagonal, or vertical */
   ErrorAcc = 0;  /* initialize the line error accumulator to 0 */
   /* # of bits by which to shift ErrorAcc to get intensity level */
   IntensityShift = 16 - IntensityBits;
   /* Mask used to flip all bits in an intensity weighting, producing the
      result (1 - intensity weighting) */
   WeightingComplementMask = NumLevels - 1;
   /* Is this an X-major or Y-major line? */
   if (DeltaY > DeltaX) {
      /* Y-major line; calculate 16-bit fixed-point fractional part of a
         pixel that X advances each time Y advances 1 pixel, truncating the
         result so that we won't overrun the endpoint along the X axis */
      ErrorAdj = ((unsigned long) DeltaX << 16) / (unsigned long) DeltaY;
      /* Draw all pixels other than the first and last */
      while (--DeltaY) {
         ErrorAccTemp = ErrorAcc;   /* remember currrent accumulated error */
         ErrorAcc += ErrorAdj;      /* calculate error for next pixel */
         if (ErrorAcc <= ErrorAccTemp) {
            /* The error accumulator turned over, so advance the X coord */
            X0 += XDir;
         }
         Y0++; /* Y-major, so always advance Y */
         /* The IntensityBits most significant bits of ErrorAcc give us the
            intensity weighting for this pixel, and the complement of the
            weighting for the paired pixel */
         Weighting = ErrorAcc >> IntensityShift;
         DrawPixel(X0, Y0, BaseColor + Weighting);
         DrawPixel(X0 + XDir, Y0,
               BaseColor + (Weighting ^ WeightingComplementMask));
      }
      /* Draw the final pixel, which is always exactly intersected by the line
         and so needs no weighting */
      DrawPixel(X1, Y1, BaseColor);
      return;
   }
Пример #8
0
void AsciiRenderer::OrthoDrawTriangle(const Vector3f& p1, const Vector3f& p2, const Vector3f& p3)
{
	//order points by Y-Position
	const Vector3f* top = &p1;
	const Vector3f* mid = &p2;
	const Vector3f* bot = &p3;
	if(mid->Y < top->Y)
	{
		std::swap(top, mid);
	}
	if(bot->Y < top->Y)
	{
		std::swap(top, bot);
	}
	if(bot->Y < mid->Y)
	{
		std::swap(bot, mid);
	}

	//For every line occupied by this triangle:
	int start = int(Round(top->Y));
	int end = int(Round(bot->Y));
	if(start < 0) start = 0; //no need to draw outside the screen
	if(end >= m_Height) end = m_Height - 1;
	for(int y = start; y <= end; ++y)
	{
		//left position - between top & bot
		Vector3f leftVec, rightVec;
		if(FloatEqual(Round(bot->Y), Round(top->Y))) //both at the same height? take the left one then.
		{
			leftVec = top->X < bot->X ? *top : *bot;
		}
		else //otherwise: LERP
		{
			leftVec = Vector3f::VecLERP(*top, *bot, (y - top->Y) / (bot->Y - top->Y));
		}

		//right position
		const Vector3f* rTop = top;
		const Vector3f* rBot = mid;
		if(y > mid->Y)
		{
			rTop = mid;
			rBot = bot;
		}
		//same height? Use right one
		if(FloatEqual(Round(rTop->Y), Round(rBot->Y)))
		{
			rightVec = rTop->X > rBot->X ? *rTop : *rBot;
		}
		else //LERP
		{
			rightVec = Vector3f::VecLERP(*rTop, *rBot, (y - rTop->Y) / (rBot->Y - rTop->Y));
		}
		//swap em if necessary so we know which one's left
		if(leftVec.X > rightVec.X)
		{
			std::swap(leftVec, rightVec);
		}
		//fill pixels from left to right
		int left = int(Round(leftVec.X));
		int right = int(Round(rightVec.X));
		if(left < 0) left = 0; //no need to draw outside the screen
		if(right >= m_Width) right = m_Width - 1;
		int width = right - left;
		for(int x = 0; x <= width; ++x)
		{
			DrawPixel(left + x, y, LERP(leftVec.Z, rightVec.Z, (FloatEqual(rightVec.X - leftVec.X, 0.f) ? 0.f : ((x + left - leftVec.X)  / (rightVec.X - leftVec.X)))));
		}
	}
}
Пример #9
0
int main(int argc, char **argv)
{
//Initialise SDL
	SDL_Init(SDL_INIT_EVERYTHING);
	
//Setup screen
	SDL_Surface *screen = SDL_SetVideoMode(640, 480, 32, SDL_SWSURFACE);
	
//Load Terrain
	OpenTerrain_Heightmap MyHeightmap;
	MyHeightmap.LoadFromImage("heightmap.png");
	OpenTerrain_DataSource_Heightmap DataSource(&MyHeightmap);
	OpenTerrain_Terrain MyTerrain;
	
	MyTerrain.SetupValues.ChunkSize = 32;
	MyTerrain.SetupValues.ChunksX = 8;
	MyTerrain.SetupValues.ChunksY = 8;
	MyTerrain.SetupValues.LODLevelCount = 1;
	MyTerrain.Setup(&DataSource, 0);
	
//Lock Screen
	LockScreen(screen);
	
//Draw terrain
	unsigned int ChunkVerticesAccross = MyTerrain.ChunkSize + 1;
	for(unsigned int Chunk = 0; Chunk < MyTerrain.LODLevels[0].ChunkCount; Chunk++) {
	//Get chunk
		OpenTerrain_Chunk* ChunkPtr = &MyTerrain.LODLevels[0].Chunks[Chunk];
		
	//Calculate chunk position on screen
		unsigned int ChunkX = ChunkPtr->PosX * ChunkVerticesAccross;
		unsigned int ChunkY = ChunkPtr->PosY * ChunkVerticesAccross;
		
	//Loop through vertices
		for(unsigned int Y = 0; Y < ChunkVerticesAccross; Y++) {
			for(unsigned int X = 0; X < ChunkVerticesAccross; X++) {
			//Get luminance and draw pixel
				unsigned char Luminance = ChunkPtr->Vertices[Y * ChunkVerticesAccross + X] * 255;
				DrawPixel(screen, ChunkX + X, ChunkY + Y, Luminance, Luminance, Luminance);
			}
		}
	}
	
//Unlock screen and update
	UnlockScreen(screen);
	SDL_UpdateRect(screen, 0, 0, 256, 256);
	
//Event loop
    SDL_Event event;
	while(true) {
		while ( SDL_PollEvent(&event) ) {
			switch (event.type) {
				case SDL_QUIT:
					exit(0);
				break;
			}
		}
	}
	
//Return 0
	return 0;
}
Пример #10
0
/**
 * An implementation of the Bresenham Line Algorithm.
 * This is the "optimized" version of drawline2d() from
 * <a href="http://en.wikipedia.org/wiki/Bresenham's_line_algorithm">Wikipedia.org</a>.
 * In this context, this method is used to "fill" the axis along the acoustic axis
 * of the sonar, as defined by the given coordinates, with their probabilities of being
 * occupied.
 *
 * NOTE! FillLine(start, end) does not necessarily return the same result as FillLine(end, start).
 */
struct PointList* FillLine(int x0, int y0, int x1, int y1)
{
    int i;
    int sx, sy;  /* step positive or negative (1 or -1) */
    int dx, dy;  /* delta (difference in X and Y between points) */
    int dx2, dy2;
    int e;
    int temp;

	InitDraw();

    dx = x1 - x0;
    sx = (dx > 0) ? 1 : -1;
    if (dx < 0)
        dx = -dx;

    dy = y1 - y0;
    sy = (dy > 0) ? 1 : -1;
    if (dy < 0)
        dy = -dy;

    dx2 = dx << 1; /* dx2 = 2 * dx */
    dy2 = dy << 1; /* dy2 = 2 * dy */

    if (dy <= dx) { /* steep */
        e = dy2 - dx;

        for (i = 0; i < dx; ++i) {
			DrawPixel( x0, y0, 0 );
			
            while (e >= 0) {
                y0 += sy;
                e -= dx2;
            }

            x0 += sx;
            e += dy2;
        }
    } 
    else {
        // swap x0 <-> y0
        temp = x0;
        x0 = y0;
        y0 = temp;

        // swap dx <-> dy
        temp = dx;
        dx = dy;
        dy = temp;

        // swap dx2 <-> dy2
        temp = dx2;
        dx2 = dy2;
        dy2 = temp;

        // swap sx <-> sy
        temp = sx;
        sx = sy;
        sy = temp;

        e = dy2 - dx;

        for (i = 0; i < dx; ++i) {
			DrawPixel( y0, x0, 0 );

            while (e >= 0) {
                y0 += sy;
                e -= dx2;
            }

            x0 += sx;
            e += dy2;
        }
    }

   return(pointListTop);
}
Пример #11
0
	//-----------------------------------------------------------------------------------------------------------------------------------------
	void Bitmap::DrawPixel(Point p)
	{
		DrawPixel(p, brush.color);
	}
Пример #12
0
/* update framebuffer*/
static void
n3ds888_update(PSD psd, MWCOORD destx, MWCOORD desty, MWCOORD width, MWCOORD height)
{
	if (!width)
		width = psd->xres;
	if (!height)
		height = psd->yres;

/*
typedef unsigned char *		ADDR8;
typedef unsigned short *	ADDR16;
typedef uint32_t *		ADDR32;
*/

	MWCOORD x,y;
	MWPIXELVAL c;

/* got to read from psd->addr and write with DrawPixel()*/

	//if (!((width == 1) || (height == 1))) return;
	//printf("U: %d %d %d %d ",destx,desty,width,height);

/*
if (psd->pixtype == MWPF_TRUECOLOR332)
	{
		unsigned char *addr = psd->addr + desty * psd->pitch + destx;
		for (y = 0; y < height; y++) {
			for (x = 0; x < width; x++) {
				c = addr[x];
				DrawPixel(psd->addr, destx+x, desty+y, c); 
			}
			addr += psd->pitch;
		}
	}
else if ((psd->pixtype == MWPF_TRUECOLOR565) || (psd->pixtype == MWPF_TRUECOLOR555))
	{	
		unsigned char *addr = psd->addr + desty * psd->pitch + (destx << 1);
		for (y = 0; y < height; y++) {
			for (x = 0; x < width*2; x++) {
				MWPIXELVAL c = ((unsigned short *)addr)[x]; 
				DrawPixel(psd->addr, destx+x, desty+y, c); 
			}
			addr += psd->pitch;
		}
	}

else /* 
if (psd->pixtype == MWPF_TRUECOLOR888)
	{
		unsigned char *addr = psd->addr + desty * psd->pitch + destx * 3;
		unsigned int extra = psd->pitch - width * 3;
		for (y = 0; y < height; y++) {
			for (x = 0; x < width*3; x++) {
				MWPIXELVAL c = RGB2PIXEL888(addr[2], addr[1], addr[0]);
				DrawPixel(psd->addr, destx+x, desty+y, c);
				addr += 3;
			}
			addr += extra;
		}
	}
else if (((MWPIXEL_FORMAT == MWPF_TRUECOLOR8888) || (MWPIXEL_FORMAT == MWPF_TRUECOLORABGR)) & (psd->bpp != 8))
	{
		unsigned char *addr = psd->addr + desty * psd->pitch + (destx << 2);
		for (y = 0; y < height; y++) {
			for (x = 0; x < width*4; x++) {				
				MWPIXELVAL c = ((unsigned short *)addr)[x]; //MWPIXELVAL=uint32_t				
				DrawPixel(psd->addr, destx+x, desty+y, c);
	    	}
			addr += psd->pitch;
		}
	}
else /* MWPF_PALETTE*/
	{
		unsigned char *addr = psd->addr + desty * psd->pitch + destx;
		for (y = 0; y < height; y++) {
			for (x = 0; x < width; x++) {
				MWPIXELVAL c = addr[x];
				DrawPixel(psd->addr, destx+x, desty+y, c); 
			}
			addr += psd->pitch;
		}
	}
		gfxFlushBuffers();
//		gfxSwapBuffers();
}
Пример #13
0
/*******************************************************************************
* Function Name  : Draw_Cursor_Meas_Line
* Description    : отрисовка линии курсора автоизмерений
* Input          : None
* Return         : None
*******************************************************************************/
void Draw_Cursor_Meas_Line(uint16_t cursor, DrawState NewState)
{   
	uint16_t cnt_, clrColor;
	uint16_t tmpLineX0 = cursor, tmpLineY0 = lowerLimit + 6;
	uint16_t tmpLineX1 = cursor, tmpLineY1 = upperLimit - lowerLimit - 16;

	if(NewState == CLEAR) // если очистка
	{
		/* устанавливаем цвет графики цветом бордюра области вывода осциллограмм */
		LCD_SetGraphicsColor(Active_BorderColor);	
		
		/* очищаем указатели */
		LCD_DrawLine(leftLimit, upperLimit - 5, rightLimit, upperLimit - 5);
		LCD_DrawLine(cursor - 2, lowerLimit + 5, cursor + 3, lowerLimit + 5);
		
		LCD_SetGraphicsColor(Active_BackColor);
		LCD_DrawLine(cursor - 2, lowerLimit + 4, cursor + 3, lowerLimit + 4);
		LCD_DrawLine(leftLimit, upperLimit - 4, rightLimit, upperLimit - 4);

		/* Очищаем старую линию */
		for (cnt_ = lowerLimit + 6; cnt_ < upperLimit - 9; cnt_++)
		{
			clrColor = Verify_Grid_Match(cursor, cnt_);
						
			if(Verify_Clip_Point(cursor, cnt_) != SET)
			{
				/* устанавливаем цвет точки и выводим точку */
				DrawPixel(cursor, cnt_, clrColor);
			}
		}           
	}
	else if(NewState == CLEAR_ALL)  // если полная очистка
	{
		LCD_SetGraphicsColor(Active_BackColor);
		if(Verify_Clip_Line(&tmpLineX0, &tmpLineY0, &tmpLineX1, &tmpLineY1) != SET)
		{
			LCD_DrawLine(tmpLineX0, tmpLineY0, tmpLineX1, tmpLineY1);
		}
	}	
	else // иначе отрисовка
	{
		/* устанавливаем цвет графики цветом указателей курсоров автоизмерений */
		LCD_SetGraphicsColor(Red);	
		
		/* рисуем указатели */
		LCD_DrawLine(cursor - 2, upperLimit - 5, cursor + 3, upperLimit - 5);
		LCD_DrawLine(cursor - 2, lowerLimit + 5, cursor + 3, lowerLimit + 5);
		LCD_DrawLine(cursor - 2, upperLimit - 4, cursor + 3, upperLimit - 4);
		LCD_DrawLine(cursor - 2, lowerLimit + 4, cursor + 3, lowerLimit + 4);
		
		/* устанавливаем цвет графики цветом сетки */
		LCD_SetGraphicsColor(Gray);	// серый
		
		/* рисуем штрих пунктирную линию*/
		for(cnt_ = lowerLimit + 6; cnt_ < upperLimit - 10; cnt_ += 10)
		{
			if(Verify_Clip_Point(cursor, cnt_) != SET)
			{
				LCD_DrawLine(cursor, cnt_, cursor, cnt_ + 4);
			}
		}
	}          
}
Пример #14
0
void InputControl(){
	p1prev = p1input;
	p2prev = p2input;
	SDL_PumpEvents();
	p1input = 0;
	p2input = 0;
	keys = SDL_GetKeyState(NULL);
	if(keys[SDLK_SPACE]){
		if(pausetimer<=0)
			GamePause();
	}
	if(keys[SDLK_LALT]&&!fpress){ /*if paused advance one frame*/
		if(!pausequeue&&pause){
			pausequeue=1;
			GamePause();
		}
		fpress = 1;
	}else if(!keys[SDLK_LALT]){
		fpress = 0;
	}
	if(keys[SDLK_ESCAPE])
		Quit();


	
	if(keys[SDLK_a])
		p1input |= 1<<7;
	if(keys[SDLK_d])
		p1input |= 1<<6;
	if(keys[SDLK_w])
		p1input |= 1<<5;
	if(keys[SDLK_s])
		p1input |= 1<<4;
	if(keys[SDLK_z])
		p1input |= 1<<3;
	if(keys[SDLK_x])
		p1input |= 1<<2;
	if(keys[SDLK_c])
		p1input |= 1<<1;
	if(keys[SDLK_v])
		p1input |= 1;


	if(keys[SDLK_LEFT])
		p2input |= 1<<7;
	if(keys[SDLK_RIGHT])
		p2input |= 1<<6;
	if(keys[SDLK_UP])
		p2input |= 1<<5;
	if(keys[SDLK_DOWN])
		p2input |= 1<<4;
	if(keys[SDLK_p])
		p2input |= 1<<3;
	if(keys[SDLK_o])
		p2input |= 1<<2;
	if(keys[SDLK_i])
		p2input |= 1<<1;
	if(keys[SDLK_u])
		p2input |= 1;


	if(debuginputs){
		for(i=0;i<8;i++){
			for(int m=0;m<4;m++){
				if(f1.inputs[m] & 1<<i)
					for(k=0;k<bsize;k++)
						for(l=0;l<bsize;l++)
								DrawPixel(screen,255,0,0,5+k+(bsize+1)*(8-i),(m+1)*(bsize+1)+l); 
				else 
					for(k=0;k<bsize;k++)
						for(l=0;l<bsize;l++)
							DrawPixel(screen,0,180,180,5+k+(bsize+1)*(8-i),(m+1)*(bsize+1)+l); 
			}
		}
		for(i=0;i<8;i++){
			for(int m=0;m<4;m++){
				if(f2.inputs[m] & 1<<i)
					for(k=0;k<bsize;k++)
						for(l=0;l<bsize;l++)
							DrawPixel(screen,255,0,0,955+k+(bsize+1)*(8-i),(m+1)*(bsize+1)+l); 
				else 
					for(k=0;k<bsize;k++)
						for(l=0;l<bsize;l++)
							DrawPixel(screen,0,180,180,955+k+(bsize+1)*(8-i),(m+1)*(bsize+1)+l);
			}
		}
	}

}