コード例 #1
0
ファイル: TicTacToeDisplay.c プロジェクト: brianlwatson/ZYBO
void TicTacToeDisplay_drawX(uint8_t row, uint8_t column)
{
	uint16_t X_ORIGIN = (column*ONE_THIRD_WIDTH) + ONE_THIRD_WIDTH/2;
	uint16_t Y_ORIGIN = (row * ONE_THIRD_HEIGHT)+ ONE_THIRD_HEIGHT/2;
	display_drawLine(X_ORIGIN - X_OFFSET, Y_ORIGIN + X_OFFSET, X_ORIGIN + X_OFFSET, Y_ORIGIN-X_OFFSET, DISPLAY_RED);
	display_drawLine(X_ORIGIN - X_OFFSET, Y_ORIGIN - X_OFFSET, X_ORIGIN + X_OFFSET, Y_ORIGIN+X_OFFSET, DISPLAY_RED);
}
コード例 #2
0
ファイル: TicTacToeDisplay.c プロジェクト: brianlwatson/ZYBO
void TicTacToeDisplay_drawBoardLines()
{
	display_init();
	display_drawLine(0, ONE_THIRD_HEIGHT, FULL_WIDTH, ONE_THIRD_HEIGHT, DISPLAY_WHITE);
	display_drawLine(0, TWO_THIRD_HEIGHT, FULL_WIDTH, TWO_THIRD_HEIGHT, DISPLAY_WHITE);
	display_drawLine(ONE_THIRD_WIDTH, 0, ONE_THIRD_WIDTH, FULL_HEIGHT, DISPLAY_WHITE);
	display_drawLine(TWO_THIRD_WIDTH, 0, TWO_THIRD_WIDTH, FULL_HEIGHT, DISPLAY_WHITE);
}
コード例 #3
0
ファイル: ticTacToeDisplay.c プロジェクト: spence13/330
void ticTacToeDisplay_eraseBoardLines()
{
    //these draw the two vertical lines
    display_drawLine(TICTACTOEDISPLAY_ONE_THIRD_WIDTH, 0, TICTACTOEDISPLAY_ONE_THIRD_WIDTH, TICTACTOEDISPLAY_PIXEL_HEIGHT, TICTACTOEDISPLAY_BLACK);//leftmost
    display_drawLine(TICTACTOEDISPLAY_TWO_THIRD_WIDTH, 0, TICTACTOEDISPLAY_TWO_THIRD_WIDTH, TICTACTOEDISPLAY_PIXEL_HEIGHT, TICTACTOEDISPLAY_BLACK);//rightmost

    //these draw the two horizontal lines
    display_drawLine(0, TICTACTOEDISPLAY_ONE_THIRD_HEIGHT, TICTACTOEDISPLAY_PIXEL_WIDTH, TICTACTOEDISPLAY_ONE_THIRD_HEIGHT, TICTACTOEDISPLAY_BLACK);//topmost
    display_drawLine(0, TICTACTOEDISPLAY_TWO_THIRD_HEIGHT, TICTACTOEDISPLAY_PIXEL_WIDTH, TICTACTOEDISPLAY_TWO_THIRD_HEIGHT, TICTACTOEDISPLAY_BLACK);//bottommost
}
コード例 #4
0
int main() {
	display_init();  // Must init all of the software and underlying hardware for LCD.
	display_fillScreen(DISPLAY_BLACK);  // Blank the screen.

	display_setRotation(0);
	display_drawLine(0,0,240,320,GREEN);
	display_drawLine(240,0,0,320 ,GREEN);
	display_drawCircle(120,80,30,RED);
	display_fillCircle(120,240,30,RED);
	display_drawTriangle(90,160,45,134,45,186,YELLOW);
	display_fillTriangle(150,160,195,134,195,186,YELLOW);

}
コード例 #5
0
ファイル: ticTacToeDisplay.c プロジェクト: spence13/330
void ticTacToeDisplay_eraseX(uint8_t row, uint8_t column)
{
    uint16_t x1 = 0;
    uint16_t x2 = 0;
    uint16_t y1 = 0;
    uint16_t y2 = 0;

    //position the y coordinate correctly depending on row number
    if(row == TICTACTOEDISPLAY_ROW_TOP)//top row
    {
        y1 = TICTACTOEDISPLAY_X_CHAR_TOP_OFFSET;//upper bound of X character
        y2 = TICTACTOEDISPLAY_ONE_THIRD_HEIGHT - TICTACTOEDISPLAY_X_CHAR_TOP_OFFSET;//lower bound of X character
    }
    else if(row == TICTACTOEDISPLAY_ROW_MIDDLE)//middle row
    {
        y1 = TICTACTOEDISPLAY_ONE_THIRD_HEIGHT + TICTACTOEDISPLAY_X_CHAR_TOP_OFFSET;//upper bound of X character
        y2 = TICTACTOEDISPLAY_TWO_THIRD_HEIGHT - TICTACTOEDISPLAY_X_CHAR_TOP_OFFSET;//lower bound of X character
    }
    else if(row == TICTACTOEDISPLAY_ROW_BOTTOM)//bottom row
    {
        y1 = TICTACTOEDISPLAY_TWO_THIRD_HEIGHT + TICTACTOEDISPLAY_X_CHAR_TOP_OFFSET;//upper bound of X character
        y2 = TICTACTOEDISPLAY_PIXEL_HEIGHT - TICTACTOEDISPLAY_X_CHAR_TOP_OFFSET;//lower bound of X character
    }

    //position the x coordinate correctly depending on column number
    if(column == TICTACTOEDISPLAY_COLUMN_LEFT)//left column
    {
        x1 = TICTACTOEDISPLAY_X_CHAR_SIDE_OFFSET;//left bound of X character
        x2 = TICTACTOEDISPLAY_ONE_THIRD_WIDTH - TICTACTOEDISPLAY_X_CHAR_SIDE_OFFSET;//right bound of X character
    }
    else if(column == TICTACTOEDISPLAY_COLUMN_MIDDLE)//middle column
    {
        x1 = TICTACTOEDISPLAY_ONE_THIRD_WIDTH + TICTACTOEDISPLAY_X_CHAR_SIDE_OFFSET;//left bound of X character
        x2 = TICTACTOEDISPLAY_TWO_THIRD_WIDTH - TICTACTOEDISPLAY_X_CHAR_SIDE_OFFSET;//right bound of X character
    }
    else if(column == TICTACTOEDISPLAY_COLUMN_RIGHT)//right column
    {
        x1 = TICTACTOEDISPLAY_TWO_THIRD_WIDTH + TICTACTOEDISPLAY_X_CHAR_SIDE_OFFSET;//left bound of X character
        x2 = TICTACTOEDISPLAY_PIXEL_WIDTH - TICTACTOEDISPLAY_X_CHAR_SIDE_OFFSET;//right bound of X character
    }

    display_drawLine(x1, y1, x2, y2, TICTACTOEDISPLAY_BLACK);//top left to bottom right
    display_drawLine(x1, y2, x2, y1, TICTACTOEDISPLAY_BLACK);//bottom left to top right
}
コード例 #6
0
ファイル: op.c プロジェクト: theanine/chip8
// DXYN: Draws a sprite at coordinate (VX, VY) that has a width of 8 pixels and
// a height of N pixels (1 to 15). Wraps around the screen. Each row of 8 pixels
// is read as bit-coded (with the most significant bit of each byte displayed on
// the left) starting from memory location I; I value doesn’t change after the
// execution of this instruction. All drawing is XOR drawing (i.e. it toggles
// the screen pixels) VF is set to 1 if any screen pixels are flipped from set
// to unset when the sprite is drawn, and to 0 if that doesn’t happen.
static int op_DXXX(word_t op)
{
    int x  = (op >> 8) & 0xF;
    int y  = (op >> 4) & 0xF;
    int n  = (op >> 0) & 0xF;

    uint8_t* sprite = &chip8.ram.bytes[chip8.I];

    REG_VF = 0;

    int i;
    for (i=0; i<n; i++) {
        uint8_t line = sprite[i];
        bool unset = display_drawLine(chip8.V[x], chip8.V[y]+i, line);
        if (unset)
            REG_VF = 1;
    }

    return SUCCESS;
}
コード例 #7
0
// Draws an X at the specified row and column.
void ticTacToeDisplay_drawX(uint8_t row, uint8_t column) {
	switch (row) {
	case 0:
		switch(column) {
		case 0:
			display_drawLine( TICTACTOE_DISP_COLUMN_0_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_0_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_COLUMN_0_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_0_PT - TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW );
			display_drawLine( TICTACTOE_DISP_COLUMN_0_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_0_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_COLUMN_0_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_0_PT + TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW );

			break;
		case 1:
			display_drawLine( TICTACTOE_DISP_COLUMN_1_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_0_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_COLUMN_1_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_0_PT - TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW );
			display_drawLine( TICTACTOE_DISP_COLUMN_1_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_0_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_COLUMN_1_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_0_PT + TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW );
			break;
		case 2:
			display_drawLine( TICTACTOE_DISP_COLUMN_2_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_0_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_COLUMN_2_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_0_PT - TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW );
			display_drawLine( TICTACTOE_DISP_COLUMN_2_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_0_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_COLUMN_2_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_0_PT + TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW );
			break;
		default:break;
		}
		break;
	case 1:
		switch(column) {
		case 0:
			display_drawLine( TICTACTOE_DISP_COLUMN_0_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_1_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_COLUMN_0_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_1_PT - TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW );
			display_drawLine( TICTACTOE_DISP_COLUMN_0_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_1_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_COLUMN_0_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_1_PT + TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW );
			break;
		case 1:
			display_drawLine( TICTACTOE_DISP_COLUMN_1_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_1_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_COLUMN_1_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_1_PT - TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW );
			display_drawLine( TICTACTOE_DISP_COLUMN_1_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_1_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_COLUMN_1_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_1_PT + TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW );
			break;
		case 2:
			display_drawLine( TICTACTOE_DISP_COLUMN_2_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_1_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_COLUMN_2_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_1_PT - TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW );
			display_drawLine( TICTACTOE_DISP_COLUMN_2_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_1_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_COLUMN_2_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_1_PT + TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW );
			break;
		default:break;
		}
		break;
	case 2:
		switch(column) {
		case 0:
			display_drawLine( TICTACTOE_DISP_COLUMN_0_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_2_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_COLUMN_0_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_2_PT - TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW );
			display_drawLine( TICTACTOE_DISP_COLUMN_0_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_2_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_COLUMN_0_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_2_PT + TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW );
			break;
		case 1:
			display_drawLine( TICTACTOE_DISP_COLUMN_1_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_2_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_COLUMN_1_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_2_PT - TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW );
			display_drawLine( TICTACTOE_DISP_COLUMN_1_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_2_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_COLUMN_1_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_2_PT + TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW );
			break;
		case 2:
			display_drawLine( TICTACTOE_DISP_COLUMN_2_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_2_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_COLUMN_2_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_2_PT - TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW );
			display_drawLine( TICTACTOE_DISP_COLUMN_2_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_2_PT - TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_COLUMN_2_PT + TICTACTOE_DISP_RADIUS, TICTACTOE_DISP_ROW_2_PT + TICTACTOE_DISP_RADIUS, DISPLAY_YELLOW );
			break;
		default:break;
		}
		break;
	default:break;
	}
}