Exemple #1
0
int main (void)
{
    unsigned char XSize, YSize;

    /* Set screen colors */
    (void) textcolor (COLOR_WHITE);
    (void) bordercolor (COLOR_BLACK);
    (void) bgcolor (COLOR_BLACK);

    /* Clear the screen, put cursor in upper left corner */
    clrscr ();

    /* Ask for the screen size */
    screensize (&XSize, &YSize);

    /* Draw a border around the screen */

    /* Top line */
    cputc (CH_ULCORNER);
    chline (XSize - 2);
    cputc (CH_URCORNER);

    /* Vertical line, left side */
    cvlinexy (0, 1, YSize - 2);

    /* Bottom line */
    cputc (CH_LLCORNER);
    chline (XSize - 2);
    cputc (CH_LRCORNER);

    /* Vertical line, right side */
    cvlinexy (XSize - 1, 1, YSize - 2);

    /* Write the greeting in the mid of the screen */
    gotoxy ((XSize - strlen (Text)) / 2, YSize / 2);
    cprintf ("%s", Text);

#if defined(__NES__) || defined(__PCE__) || defined(__GAMATE__) || defined(__ATARI5200__)

    /* Wait for the user to press a button */
    joy_install (joy_static_stddrv);
    while (!joy_read (JOY_1)) ;
    joy_uninstall ();

#else

    /* Wait for the user to press a key */
    cgetc ();

#endif

    /* Clear the screen again */
    clrscr ();

    /* Done */
    return EXIT_SUCCESS;
}
Exemple #2
0
static void DrawFrame (register FrameDesc* F, char Active)
/* Draw one window frame */
{
    TextDesc* T;
    unsigned char Count;
    unsigned char tl, tr, bl, br;
    unsigned char x1, y1, width;
    unsigned char OldColor;

    /* Determine the characters for the corners, set frame color */
    if (Active) {
        OldColor = textcolor (COLOR_FRAMEHIGH);
        tl = CH_ULCORNER;
        tr = CH_URCORNER;
        bl = CH_LLCORNER;
        br = CH_LRCORNER;
    } else {
        OldColor = textcolor (COLOR_FRAMELOW);
        tl = F->fd_tl;
        tr = F->fd_tr;
        bl = F->fd_bl;
        br = F->fd_br;
    }

    /* Get the coordinates into locals for faster access */
    x1 = F->fd_x1;
    y1 = F->fd_y1;
    width = F->fd_width;

    /* Top line */
    cputcxy (x1, y1, tl);
    chline (width);
    cputc (tr);

    /* Left line */
    cvlinexy (x1, ++y1, F->fd_height);

    /* Bottom line */
    cputc (bl);
    chline (width);
    cputc (br);

    /* Right line */
    cvlinexy (F->fd_x2, y1, F->fd_height);

    /* If the window has static text associated, print the text */
    (void) textcolor (COLOR_TEXTLOW);
    Count = F->fd_textcount;
    T = F->fd_text;
    while (Count--) {
        cputsxy (x1 + T->x, y1 + T->y, T->text);
        ++T;
    }

    /* Set the old color */
    (void) textcolor (OldColor);
}
Exemple #3
0
int main(void)
{
    int i, j;
    int status;
    char ch, excess_ch;

    while (get_input(&ch, &i, &j, &status))
    {
        excess_ch = getchar();
        if (excess_ch != '\n')
        {
            if (status == 2)
            {
                printf("Too many inputs.\n");
            } else
            {
                printf("Invalid input.\n");
            }

            while (getchar() != '\n');
            continue;
        }
        chline(ch, i, j);
    }
    printf("\nBye!\n");

    return 0;
}
void draw_menu(struct ctk_menu *m, struct ctk_menu *open) {
#if CC_CONF_UNSIGNED_CHAR_BUGS
  unsigned char x2;
  unsigned int x, y;
#else
  unsigned char x2;
  unsigned char x, y;
#endif
  x = cursx;
  cputs(m->title);
  cputc(CH_SPACE);

  if (m == open) {
    x2 = cursx;
    if(x + CTK_CONF_MENUWIDTH > SCREEN_WIDTH) {
      x = SCREEN_WIDTH - CTK_CONF_MENUWIDTH;
    }
  
    for(y = 0; y < m->nitems; y++) {
      if(y == m->active) {
	revers(0);
      }
      gotoxy(x, y + 1);
      if(m->items[y].title[0] == '-') {
	chline(CTK_CONF_MENUWIDTH);
      } else {
	cputs(m->items[y].title);
      }
      clearTo(x + CTK_CONF_MENUWIDTH);
      revers(1);
    }
    gotoxy(x2, 0);
  }
}
Exemple #5
0
int main(void){
		char ch;
		int i,j;
		scanf ( "%c %d %d", &ch, &i, &j );

		chline (ch, i, j);
		return 0;
}
/*---------------------------------------------------------------------------*/
void draw_window_sub(struct ctk_window *window, unsigned char focus) {

  unsigned char x, y;
  unsigned char x1, y1, x2;
  struct ctk_widget *w;
  unsigned char wfocus;

  x = window->x;
  y = window->y + 1;

  x1 = x + 1;
  y1 = y + 1;
  x2 = x1 + window->w;

  // |_
  gotoxy(x, y1);
  cvline(window->h);
  cputc(CH_LLCORNER);
  chline(window->w);
  cputc(CH_LRCORNER);

  // -
  gotoxy(x, y);
  cputc(CH_ULCORNER);
  chline(window->w);
  cputc(CH_URCORNER);
  // |
  gotoxy(x2, y1);
  cvline(window->h);

  /* Draw inactive widgets. */
  for(w = window->inactive; w != NULL; w = w->next) {
    draw_widget(w, x1, y1, focus);
  }

  /* Draw active widgets. */
  for(w = window->active; w != NULL; w = w->next) {
    wfocus = focus;
    if(w == window->focused) {
      wfocus |= CTK_FOCUS_WIDGET;
    }
    draw_widget(w, x1, y1, wfocus);
  }
}
int main(void)
{
    char chInput;
    int nStart, nEnd;
    printf("Enter the character and two lines: \n");
    scanf("%c%d%d", &chInput, &nStart, &nEnd);
    chline(chInput, nStart, nEnd);

    return 0;
}
Exemple #8
0
int main (void)
{
  int x, y;
  char ch;
  printf("Input a char:");
  scanf("%c",&ch);
  printf("Input column and row:");
  scanf("%d%d",&x,&y);
  chline(ch,x,y);
  return 0;
}
Exemple #9
0
int main (void){
		char ch;
		int i,j;

		ch = '*';
		i = 4;
		j = 5;
		chline ( ch, i ,j);
		return 0;

}
Exemple #10
0
int main (void)
{
    char ch;
    int x, y;

    printf ("Please input a char: ");
    ch = getchar ();
    fpurge (stdin);
    printf ("Please input the coordinate to print: ");
    scanf ("%d%d", &x, &y);
    chline (ch, x, y);
    printf ("\n");

    return 0;
}
int main(void)
{
	char ch;
	unsigned int i, j;

	printf("Enter a character and two integers: ");
	while (scanf("%c %u %u", &ch, &i, &j) == 3)
	{
		chline(ch, i, j);
		printf("\n");

		while (getchar() != '\n') continue; // clear input
		
		printf("Enter a character and two integers: ");
	}

	return 0;
}
Exemple #12
0
static void
draw_menu(struct ctk_menu *m, unsigned char open)
{
  unsigned char x, x2, y;

  if(open) {
    x = x2 = wherex();
    if(x2 + CTK_CONF_MENUWIDTH > sizex) {
      x2 = sizex - CTK_CONF_MENUWIDTH;
    }

    for(y = 0; y < m->nitems; ++y) {
      if(y == m->active) {
	(void)textcolor(ACTIVEMENUITEMCOLOR);
	revers(0);
      } else {
	(void)textcolor(MENUCOLOR);	  
	revers(1);
      }
      gotoxy(x2, y + 1);
      if(m->items[y].title[0] == '-') {
	chline(CTK_CONF_MENUWIDTH);
      } else {
	cputs(m->items[y].title);
      }
      if(x2 + CTK_CONF_MENUWIDTH > wherex()) {
	cclear(x2 + CTK_CONF_MENUWIDTH - wherex());
      }
    }

    gotoxy(x, 0);
    (void)textcolor(OPENMENUCOLOR);
    revers(0);
  }

  cputs(m->title);
  cputc(' ');
  (void)textcolor(MENUCOLOR);
  revers(1);
}
/*-----------------------------------------------------------------------------------*/
static void
draw_menu(struct ctk_menu *m)
{
  unsigned char x, x2, y;

  textcolor(VNC_OUT_MENUCOLOR);
  x = wherex();
  cputs(m->title);
  cputc(' ');
  x2 = wherex();
  if(x + CTK_CONF_MENUWIDTH > sizex) {
    x = sizex - CTK_CONF_MENUWIDTH;
  }
  
  
  for(y = 0; y < m->nitems; ++y) {
    if(y == m->active) {
      textcolor(VNC_OUT_ACTIVEMENUCOLOR);
      revers(0);
    } else {
      textcolor(VNC_OUT_MENUCOLOR);	  
    }
    gotoxy(x, y + 1);
    if(m->items[y].title[0] == '-') {
      chline(CTK_CONF_MENUWIDTH);
    } else {
      cputs(m->items[y].title);
    }
    if(x + CTK_CONF_MENUWIDTH > wherex()) {
      cclear(x + CTK_CONF_MENUWIDTH - wherex());
    }
    revers(1);
  }
  
  gotoxy(x2, 0);
  textcolor(VNC_OUT_MENUCOLOR);  

  update_area(x, 0, CTK_CONF_MENUWIDTH, m->nitems + 1);
}
Exemple #14
0
/* Same as "gotoxy (x, y); chline (length);" */
void __fastcall__ chlinexy( unsigned char x, unsigned char y, unsigned char length )
{
	gotoxy( x, y );
	chline( length );
}
Exemple #15
0
/*-----------------------------------------------------------------------------------*/
void
ctk_draw_window(struct ctk_window *window, unsigned char focus,
		unsigned char clipy1, unsigned char clipy2,
		unsigned char draw_borders)
{
#if CTK_CONF_WINDOWS
  unsigned char x, y;
  unsigned char x1, y1, x2, y2;
  unsigned char h;

  if(window->y + CTK_CONF_MENUS >= clipy2) {
    return;
  }
    
  x = window->x;
  y = window->y + CTK_CONF_MENUS;
  x1 = x + 1;
  y1 = y + 1;
  x2 = x1 + window->w;
  y2 = y1 + window->h;

  if(draw_borders) {

    /* Draw window frame. */  
    if(focus & CTK_FOCUS_WINDOW) {
      (void)textcolor(WINDOWCOLOR_FOCUS);
    } else {
      (void)textcolor(WINDOWCOLOR);
    }

    if(y >= clipy1) {
      cputcxy(x, y, (char)CH_ULCORNER);
      gotoxy(wherex() + window->titlelen + CTK_CONF_WINDOWMOVE * 2, wherey());
      chline(window->w - (wherex() - x) - 2);
      cputcxy(x2, y, (char)CH_URCORNER);
    }

    h = window->h;
  
    if(clipy1 > y1) {
      if(clipy1 - y1 < h) {
	h = clipy1 - y1;
	y1 = clipy1;
      } else {
	h = 0;
      }
    }

    if(clipy2 < y1 + h) {
      if(y1 >= clipy2) {
	h = 0;
      } else {
	h = clipy2 - y1;
      }
    }

    cvlinexy(x, y1, h);
    cvlinexy(x2, y1, h);  

    if(y + window->h >= clipy1 && y + window->h < clipy2) {
      cputcxy(x, y2, (char)CH_LLCORNER);
      chlinexy(x1, y2, window->w);
      cputcxy(x2, y2, (char)CH_LRCORNER);
    }
  }

  draw_window_contents(window, focus, clipy1, clipy2, x1, x2, y + 1, y2);

#else /* CTK_CONF_WINDOWS */

  draw_window_contents(window, focus, clipy1, clipy2, 0, window->w, 0, window->h);

#endif /* CTK_CONF_WINDOWS */
}
/*
 * w: widget
 * x, y:  screen position of client drawing area (left, top)
 * clipx, clipy: screen position of client drawing area (right, bottom)
 * clipy1, clipy2: min/max y position of screen
 * focus: boolean
 */
void
draw_widget(struct ctk_widget *w,
	    unsigned char x, unsigned char y,
	    unsigned char focus) {
  unsigned char xpos, ypos, xscroll;
  unsigned char i, j;
  char c, *text;
#if CTK_CONF_ICONS
  unsigned char len;
#endif /* CTK_CONF_ICONS */

  xpos = x + w->x;
  ypos = y + w->y;
    
  revers(focus & CTK_FOCUS_WIDGET);
  gotoxy(xpos, ypos);

  if (w->type == CTK_WIDGET_SEPARATOR) {
    chline(w->w);
  } else if (w->type == CTK_WIDGET_LABEL) {
    text = w->widget.label.text;
    for(i = 0; i < w->h; ++i) {
      gotoxy(xpos, ypos);
      cputsn(text, w->w);
      clearTo(xpos + w->w);
      ++ypos;
      text += w->w;
    }
  } else if (w->type == CTK_WIDGET_BUTTON) {
    cputc('[');
    cputsn(w->widget.button.text, w->w);
    cputc(']');
  } else if (w->type == CTK_WIDGET_HYPERLINK) {
    cputsn(w->widget.hyperlink.text, w->w);
  } else if (w->type == CTK_WIDGET_TEXTENTRY) {
    text = w->widget.textentry.text;
    xscroll = 0;
    if(w->widget.textentry.xpos >= w->w - 1) {
      xscroll = w->widget.textentry.xpos - w->w + 1;
    }
    for(j = 0; j < w->h; ++j) {
      gotoxy(xpos, ypos);
      if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT &&
	 w->widget.textentry.ypos == j) {
	revers(0);
	cputc('>');
	for(i = 0; i < w->w; ++i) {
	  c = text[i + xscroll];
	  revers(i == w->widget.textentry.xpos - xscroll);
	  cputc((c == 0) ? CH_SPACE : c);
	}
	revers(0);
	cputc('<');
      } else {
	cputc(CH_VERTLINE);
	cputsn(text, w->w);
	clearTo(xpos + w->w + 1);
	cputc(CH_VERTLINE);
      }
      ++ypos;
      text += w->w;
    }
#if CTK_CONF_ICONS
  } else if (w->type == CTK_WIDGET_ICON) {
    if(w->widget.icon.textmap != NULL) {
      for(i = 0; i < 3; ++i) {
	gotoxy(xpos, ypos);
	cputc(w->widget.icon.textmap[0 + 3 * i]);
	cputc(w->widget.icon.textmap[1 + 3 * i]);
	cputc(w->widget.icon.textmap[2 + 3 * i]);
	++ypos;
      }
      x = xpos;
  
      len = strlen(w->widget.icon.title);
      if(x + len >= SCREEN_WIDTH) {
	x = SCREEN_WIDTH - len;
      }
      gotoxy(x, ypos);
      cputs(w->widget.icon.title);
    }
#endif /* CTK_CONF_ICONS */
  }
  revers(0);

}
Exemple #17
0
int main (int argc, const char* argv[])
{
    unsigned char SourceId;
    unsigned char TargetId;
    dhandle_t     Source = NULL;
    dhandle_t     Target = NULL;
    unsigned int  SectSize;
    unsigned int  SectCount;
    char*         Buffer;
    unsigned int  Sector;
    unsigned int  ChunkCount;
    unsigned int  ChunkOffset = 0;

    clrscr ();
    screensize (&ScreenX, &ScreenY);

    /* Allow user to read exit messages */
    if (doesclrscrafterexit ()) {
        atexit ((void (*)) cgetc);
    }

    cputs ("Floppy Disk Copy\r\n");
    chline (16);
    cputs ("\r\n");

    /* Get source and target drive id (which may very well be identical) */
    switch (argc) {
      case 1:
        SourceId = AskForDrive ("Source");
        TargetId = AskForDrive ("Target");
        cputs ("\r\n");
        break;

      case 2:
        SourceId = TargetId = atoi (argv[1]);
        break;

      case 3:
        SourceId = atoi (argv[1]);
        TargetId = atoi (argv[2]);
        break;

      default:
        cprintf ("\r\nToo many arguments\r\n");
        return EXIT_FAILURE;
    }

    cputs ("\r\n");

    do {
        /* Check for single drive copy or inital iteration */
        if (SourceId == TargetId || Source == NULL) {
            AskForDisk ("Source", SourceId);
        }

        /* Check for initial iteration */
        if (Source == NULL) {

            /* Open source drive */
            Source = dio_open (SourceId);
            if (Source == NULL) {
                cprintf ("\r\n\nError %d on opening Drive %d\r\n", (int) _oserror, SourceId);
                return EXIT_FAILURE;
            }

            SectSize  = dio_query_sectsize (Source);
            SectCount = dio_query_sectcount (Source);

            /* Allocate buffer */
            Buffer = AllocBuffer (SectSize, SectCount, &ChunkCount);
            if (Buffer == NULL) {
                cputs ("\r\n\nError on allocating Buffer\r\n");
                return EXIT_FAILURE;
            }
        }

        ClearLine ();

        /* Read one chunk of sectors into buffer */
        for (Sector = ChunkOffset; Sector < SectCount && (Sector - ChunkOffset) < ChunkCount; ++Sector) {
            cprintf ("\rReading Sector %d of %d", Sector + 1, SectCount);

            /* Read one sector */
            if (dio_read (Source, Sector, Buffer + (Sector - ChunkOffset) * SectSize) != 0) {
                cprintf ("\r\n\nError %d on reading from Drive %d\r\n", (int) _oserror, SourceId);
                return EXIT_FAILURE;
            }
        }

        /* Check for single drive copy or inital iteration */
        if (TargetId == SourceId || Target == NULL) {
            AskForDisk ("Target", TargetId);
        }

        /* Open target drive on initial iteration */
        if (Target == NULL) {
            Target = dio_open (TargetId);
            if (Target == NULL) {
                cprintf ("\r\n\nError %d on opening Drive %d\r\n", (int) _oserror, TargetId);
                return EXIT_FAILURE;
            }

            /* Check for compatible drives */
            if (dio_query_sectsize (Target)  != SectSize ||
                dio_query_sectcount (Target) != SectCount) {
                cputs ("\r\n\nFormat mismatch between Drives\r\n");
                return EXIT_FAILURE;
            }
        }

        ClearLine ();

        /* Write one chunk of sectors from buffer */
        for (Sector = ChunkOffset; Sector < SectCount && (Sector - ChunkOffset) < ChunkCount; ++Sector) {
            cprintf ("\rWriting Sector %d of %d", Sector + 1, SectCount);

            /* Write one sector */
            if (dio_write (Target, Sector, Buffer + (Sector - ChunkOffset) * SectSize) != 0) {
                cprintf ("\r\n\nError %d on writing to Drive %d\r\n", (int) _oserror, TargetId);
                return EXIT_FAILURE;
            }
        }

        /* Advance to next chunk */
        ChunkOffset += ChunkCount;

    } while (Sector < SectCount);

    ClearLine ();
    cprintf ("\rSuccessfully copied %d Sectors\r\n", SectCount);

    free (Buffer);
    dio_close (Source);
    dio_close (Target);

    return EXIT_SUCCESS;
}
Exemple #18
0
/*-----------------------------------------------------------------------------------*/
void
chlinexy(unsigned char x, unsigned char y, unsigned char length)
{
  gotoxy(x, y);
  chline(length);
}
Exemple #19
0
void  func_9_2(void){
  chline('*',2,5);
  printf("\n");
}
Exemple #20
0
int main()
{
	chline('#', 5, 20);

	return 0;
}