Exemple #1
0
int console_putc(int ch) {
#if defined (ARM_ALLOW_MULTI_CORE)
	while (__sync_lock_test_and_set(&lock, 1) == 1);
#endif

	if (ch == (int)'\n') {
		newline();
	} else if (ch == (int)'\r') {
		current_x = 0;
	} else if (ch == (int)'\t') {
		current_x += 4;
	} else {
		draw_char(ch, current_x * FB_CHAR_W, current_y * FB_CHAR_H, cur_fore, cur_back);
		current_x++;
		if (current_x == FB_WIDTH / FB_CHAR_W) {
			newline();
		}
	}

#if defined (ARM_ALLOW_MULTI_CORE)
	__sync_lock_release(&lock);
#endif

	return ch;
}
Exemple #2
0
static void draw_string(int x, int y, const char *s, int w) {
	if (s == NULL)
		return;
	for (; *s && w; w--) {
		draw_char(x++,y,*(s++));
	}
}
Exemple #3
0
void fill_rect( int left, int top, int width, int height, char ch )
{

	int right = left + width - 1;
	int bottom = top + height - 1;

	if( width <= 0 || height <= 0 )
	{
	}
	else if( width == 1 && height == 1 )
	{
		draw_char( left, top, ch );
	}
	else if( width == 1 )
	{
		draw_line( left, top, left, bottom, ch );
	}
	else if ( height == 1 )
	{
		draw_line( left, top, right, top, ch );
	}
	else
	{
		for( int i = 0; i < height; i++ )
		{
			draw_line( left, top + i, right, top + i, ch );
		}
	}
}
Exemple #4
0
static void scroll(void) {
	int i;

	for (i = 0; i < (40 * 29); i++) {
		const int ch = (int) shadow_ram[i + 40].ch;
		const uint16_t fore = shadow_ram[i + 40].fore;
		const uint16_t back = shadow_ram[i + 40].back;
		const uint32_t x = i / 40;
		const uint32_t y = i - 40 * x;

		draw_char(ch, x, y, fore, back);
	}

	for (i = 0; i < 40; i++) {
		draw_char(' ', 29, i, cur_fore, cur_back);
	}
}
Exemple #5
0
void draw_text(int x, int y, const char *text, color_t  c) {
    int counter =0;
    while(text[counter] != '\0') {
        draw_char(x,y,text[counter], c);
        x+=8;
        counter++;
    }
}
Exemple #6
0
void Display::draw_text(uint16_t x, uint16_t y, const char* c)
{
    while (*c != 0) {
        draw_char(x, y, *c);
        x += 7;
        c++;
    }
}
Exemple #7
0
static void draw_text_line(duc_graph *g, double x, double y, double size, char *text, int l)
{
	int i;
	
	for(i=0; i<l; i++) {
		x += draw_char(g, x, y, size, text[i]);
	}
}
Exemple #8
0
void show_route(void)
{
   int k;
   for(k=route_count-1; k>=0; k--)
   {
      draw_char(route[k].x, route[k].y, ' ', 0x47);
   }
}
void draw_string(int x, int y, char *s)
{
	int i;

	for (i = 0; i < strlen(s); i++)
	{
		draw_char(x + i, y, s[i]);
	}
}
Exemple #10
0
void tfont_draw_string(const char* s) {
    if(!tfont_init())
        sys_err("tfont not initialized");
    while(*s) {
        unsigned char ch = (unsigned char) *s++;
        draw_char(ch);
        glTranslatef(_bm_w, 0, 0);
    }
}
Exemple #11
0
void gamelib_mainmenu(){
	int n,j;
	int t = 0;
	double d=0;
	char *text;

	time_t current_time;
	struct tm * time_info;
	char timeString[8];



	while(nunchuck_read()){
		nunchuck_init();
		//nunchuck_read();
		mvprintw(6,0,"nunchuck reinited\n");
	}
	while(buttonC && buttonZ){
		while(nunchuck_read()){
			nunchuck_init();
			//nunchuck_read();
			mvprintw(6,0,"nunchuck reinited\n");
		}
		
		if(t%800 < 100){
			text = "PLAY";
			d = 3.03;
		}
		else if(t%800 < 200) {
			text = "GAMES";
			d = 0.03;
		}	
		else{
			time(&current_time);
			time_info = localtime(&current_time);
			strftime(timeString, 8, "%H:%M", time_info);
			
			if(current_time%2){
				timeString[2] = ' ';
			}
			text = timeString;
			d=0.03;
		}
		
		n=0;
		while(text[n] && n < 6){
			draw_char(n*6+d, text[n]);
			n++;
		}
		blit();
		update();
		
		t++;
	}


}	
Exemple #12
0
void draw_text(uint8_t x, uint8_t y, const char *text, uint8_t r,uint8_t g,uint8_t b)
{
	while (*text)
	{
		draw_char(x,y,*text,r,b,g);
		x+=6;
		text++;
	}

}
Exemple #13
0
/* 
	We do not want to redraw our input window every time the cursor blinks.
	We only redraw the character under the cursor.
	For that we have to known the position in the text at which the cursor is.
	If the cursor is past the last character in the window text, we draw a space.
*/	
static uint8_t
draw_cursor(struct Window *win, uint8_t cursor_pos, uint8_t reversed){
	char ch;
	int cc;
	
	set_font(win->font);			// necessary !
	cc = cursor_col(cursor_pos);
	
	/* If we are past the text length, draw space */
	if (cursor_pos >= win->text_len) ch = ' ';
	else ch = win->txt[cursor_pos];
	
	if (reversed)
		draw_char(win_txt_row(win), win_txt_col(win)+ cc, ch, win->bg_color, win->fg_color, txt_col_lim(win) - cc ); 
	else	
		draw_char(win_txt_row(win), win_txt_col(win)+ cc, ch, win->fg_color, win->bg_color, txt_col_lim(win) - cc ); 
	
	return 1;
};
Exemple #14
0
//Draw a string of chars
void draw_string(char s[], int x, int y) {

	int i;

	for (i = 0; i < strlen(s); i++) {
	
		draw_char(s[i],x,y);
		x += 20;
	}
}
Exemple #15
0
static void draw_page_title(void)
{
	int x, tpos, tlen = strlen(ACTIVE_PAGE.title);

	if (tlen > 0) {
		tpos = 41 - ((tlen + 1) / 2);

		for (x = 1; x < tpos - 1; x++)
			draw_char(154, x, 11, 1, 2);
		draw_char(0, tpos - 1, 11, 1, 2);
		draw_text(ACTIVE_PAGE.title, tpos, 11, 0, 2);
		draw_char(0, tpos + tlen, 11, 1, 2);
		for (x = tpos + tlen + 1; x < 79; x++)
			draw_char(154, x, 11, 1, 2);
	} else {
		for (x = 1; x < 79; x++)
			draw_char(154, x, 11, 1, 2);
	}
}
void main() {
	char * map =
		"####  ####"
		"#  ####  #"
		"#        #"
		"##      ##"
		" #      # "
		" #      # "
		"##      ##"
		"#        #"
		"#  ####  #"
		"####  ####";
	int map_w = 10;

	POINT player = { 2, 2 };
	unsigned char scancode = 0;
	unsigned char ascii = 0;

	clear();
	draw_map(map, 0, 0, map_w, 5);

	do {
		draw_char(' ', player.x, player.y, 15);
		switch (scancode) {
		case 72:
			move(map, &player, player.x, player.y - 1,map_w);
			break;
		case 80:
			move(map, &player, player.x, player.y + 1,map_w);
			break;
		case 75:
			move(map, &player, player.x - 1, player.y,map_w);
			break;
		case 77:
			move(map, &player, player.x + 1, player.y,map_w);
			break;
		}
		draw_char('@', player.x, player.y, 15);

		get_key(&scancode, &ascii);
	}while (scancode != 1);
}
Exemple #17
0
void
draw_text(u32 *pixels, u32 *font, zplString str, i32 font_w, Rect rect) {
    i32 str_len = zpl_string_length(str);
    i32 n = 0;
    
    do {
        draw_char(pixels, font, str[n++], font_w, rect);
        rect.x += rect.w;
    }
    while (--str_len > 0);
}
Exemple #18
0
static void redraw_top_info(void)
{
	char buf[8];

	update_current_instrument();

	draw_text_len(song_get_basename(), 18, 12, 4, 5, 0);
	draw_text_len(current_song->title, 25, 12, 3, 5, 0);

	if ((status.flags & (CLASSIC_MODE | SONG_NEEDS_SAVE)) == SONG_NEEDS_SAVE)
		draw_char('+', 29, 4, 4, 0);

	update_current_order();
	update_current_pattern();
	update_current_row();

	draw_text(numtostr(3, song_get_current_speed(), buf), 50, 4, 5, 0);
	draw_text(numtostr(3, song_get_current_tempo(), buf), 54, 4, 5, 0);
	draw_char('0' + kbd_get_current_octave(), 50, 5, 5, 0);
}
Exemple #19
0
void Display::draw_text(uint16_t x, uint16_t y, const char* c)
{
    if (nullptr == c) {
        return;
    }
    while (*c != 0) {
#ifndef AP_NOTIFY_DISPLAY_USE_EMOJI
        if (*c >= ' ' && *c <= '~') {
            draw_char(x, y, *c - ' ');
        } else {
            // convert oob characters to spaces
            draw_char(x, y, 0);
        }
#else
        draw_char(x, y, *c);
#endif
        x += 7;
        c++;
    }
}
Exemple #20
0
void show_maze(int x0, int y0, int x1, int y1)
{
   int x, y;
   for(y=y0; y<=y1; y++)
   {
      for(x=x0; x<=x1; x++)
      {
         draw_char(x, y, maze[x][y].shape, maze[x][y].color);
      }
   }
}
//Draw a string of chars
void draw_string(char s[], int x, int y) {

	int i;

	for (i = 0; i < strlen(s); i++) {
	
		int amp =  sin(.02 * x) * 30;

		draw_char(s[i],x,y + amp);
		x += 20;
	}
}
Exemple #22
0
int draw_n_char(struct lcd_info *lcd, int x, int y,
	const struct font_desc * font, color_t str_color, color_t back_color, const char *str, int n)
{
	int i;

	for (i = 0; i < n; i++, str++) {
		draw_char(lcd, x, y, font, str_color, back_color, *str);

		x += font->width + font->word_gap * 2;
	}

	return 0;
}
Exemple #23
0
void draw_string(unsigned char top_left_x, unsigned char top_left_y, char *characters) {
	int i = 0;
	// Draw each character until the null terminator is reached
	while (*characters != 0) {
		draw_char(top_left_x+i*5, top_left_y, *(characters));

		// Add a column of spaces here if you want to space out the lettering.
	    // (see lcd.c for a hint on how to do this)

		characters++;
		i++;
	}
}
void show_message(unsigned char message[], struct colour msg_colour){
	
	int i = 0;
	
	for(i = 0; i < (STEPS / (WIDTH + 1)); i++){
		draw_char(
			message[i], 
			i ,
			msg_colour.red, 
			msg_colour.green, 
			msg_colour.blue);
	}
}
Exemple #25
0
void draw_text(int x, int y, const char *text, color_t color)
{	
	const char lineEscape = '\0';
	unsigned char ch;
	int i = 0;
	while(*(text + i) != lineEscape)
	{	
		ch = *(text + i);
		x = x + 8;
		draw_char(x, y, iso_font + ch * 16, color);
		i++;
	}
}
//Draw fight stage
int draw_fight_stage(){ int r, c;
    //Draw basic grass across screen
    for(r = 0; r < num_rows; r++){ // Rows
        for(c = 0; c < num_columns; c++){ 
            block_draw_sp(c, r, &NoGrass_img);
        }
    }
    
    //Spell Rune interface around borders
    //Elec Spell
    for(int i = num_columns-2; i>num_columns-5 ; i--){
        block_draw_sp(i, 0, &Light_img);
    }
    
    //Water Spell
    for(int i = 3; i < 6; i++){
        block_draw_sp(num_columns-1, i, &Water_img);
    }
    
    //Fire Spell
    for(int i = 1; i < 4; i++){
        block_draw_sp(i, 8, &Fire_img);
    }
    
    //Grass Spell
    for(int i = 4; i < 7; i++){
        block_draw_sp(0, i, &Earth_img);
    }
    
    draw_char();
    block_draw(4, 5, ST7735_BLACK);
    block_draw(5, 5, ST7735_BLACK);
    
    int element = random(1, 5); //Random Generation of Enemy
    Serial.print(element);
    if(element == 1){ //Fire Monster
        draw_enemy(&Fmns_img);
    }
    if(element == 2){ //Water Monster
        draw_enemy(&Wmns_img);
    }
    if(element == 3){ //Lightning Monster
        draw_enemy(&Lmns_img);
    }
    if(element == 4){ //Earth Monster
        draw_enemy(&Emns_img);
    }
    
    
    
    return element;}
void simple_rl(void)
{
  unsigned short kp;

  draw_map(PF_OFFSET_X, PF_OFFSET_Y, map);
  draw_char(px, py, '@');
  SMS_displayOn();

  while (true) {
    kp = SMS_getKeysPressed();

    SMS_waitForVBlank();

    draw_char(px, py, ' ');

    if (kp & PORT_A_KEY_UP) { move_to(px, py - 1); }
    if (kp & PORT_A_KEY_DOWN) { move_to(px, py + 1); }
    if (kp & PORT_A_KEY_LEFT) { move_to(px - 1, py); }
    if (kp & PORT_A_KEY_RIGHT) { move_to(px + 1, py); }

    draw_char(px, py, '@');
  }
}
Exemple #28
0
void draw_number(uint8_t x, uint8_t y, int32_t number, uint8_t length, uint8_t pad, uint8_t r, uint8_t g , uint8_t b)
{

	char s[10];
	sprintf(s, "%d", number);
	int len = strlen(s);

	if (length < len) {
		int i;
		for (i = 0; i < length; i++) {
			draw_char(x, y, '*', r,g,b);
			x+=6;
		}
		return;
	}
	int i;
	for (i = 0; i < length - len; i++) {
		draw_char(x, y, pad, r,g,b);
		x+=6;
	}
	draw_text(x, y, (char*)s, r,g,b);

}
Exemple #29
0
void Font::draw(RID p_canvas_item, const Point2 &p_pos, const String &p_text, const Color &p_modulate, int p_clip_w, const Color &p_outline_modulate) const {
	Vector2 ofs;

	int chars_drawn = 0;
	bool with_outline = has_outline();
	for (int i = 0; i < p_text.length(); i++) {

		int width = get_char_size(p_text[i]).width;

		if (p_clip_w >= 0 && (ofs.x + width) > p_clip_w)
			break; //clip

		ofs.x += draw_char(p_canvas_item, p_pos + ofs, p_text[i], p_text[i + 1], with_outline ? p_outline_modulate : p_modulate, with_outline);
		++chars_drawn;
	}

	if (has_outline()) {
		ofs = Vector2(0, 0);
		for (int i = 0; i < chars_drawn; i++) {
			ofs.x += draw_char(p_canvas_item, p_pos + ofs, p_text[i], p_text[i + 1], p_modulate, false);
		}
	}
}
Exemple #30
0
void Font::draw(RID p_canvas_item, const Point2& p_pos, const String& p_text, const Color& p_modulate,int p_clip_w) const {

	Vector2 ofs;

	for (int i=0;i<p_text.length();i++) {

		int width = get_char_size(p_text[i]).width;

		if (p_clip_w>=0 && (ofs.x+width)>p_clip_w)
			break; //clip

		ofs.x+=draw_char(p_canvas_item,p_pos+ofs,p_text[i],p_text[i+1],p_modulate);
	}
}