コード例 #1
0
ファイル: screen.c プロジェクト: A2Command/a2command
void __fastcall writeStatusBar(const char message[])
{
	unsigned char oldX, oldY;

	oldX = wherex();
	oldY = wherey();

	//textcolor(color_text_status);
	revers(true);

	cclearxy(0, 0, size_x);

	cputsxy(0, 0, message);
	
	revers(false);

	gotoxy(oldY, oldY);
}
コード例 #2
0
ファイル: tuilibap.c プロジェクト: hculpan/kbase
void showlistbox(tgui_Obj *obj, int x, int y, int color, int startid){
tgui_Listitem *item;
int i;

    //textcolor(color);
    cputsxy(x,y-1,obj->caption);
    drawbox(x, y, x+obj->width, y + obj->height);
    item = obj->firstitem;
    i=0;
	obj->topid=startid;


    while (item->li_id != startid){
		item=item-> next;
	}


    if (startid != 0 ) cputcxy(x+obj->width-1, y, '+');


	    if (item!=NULL ) {
	        do {
	            if (obj->state == item->li_id ) revers(1);
				cputsxy(x+1,y+i+1,item->caption);
				cclearxy(x+strlen(item->caption)+1 ,y+i+1, obj->width - strlen(item->caption)-1);
				if (obj->state == item->li_id){
					//cclearxy(x+strlen(item->caption)+1 ,y+i+1, obj->width - strlen(item->caption)-1);
					revers(0);
                }
					++i;
	            item=item->next;
			} while (item != obj->firstitem && i+1 < obj->height);
	        if (item != obj->firstitem ) {
				cputcxy(x+obj->width-1, y+obj->height, '+');
			}
			else cputcxy(x+obj->width-1, y+obj->height, ' ');

        }



}   // end of showlistbox
コード例 #3
0
/*-----------------------------------------------------------------------------------*/
static void
s_ctk_draw_dialog(struct ctk_window *dialog)
{
  unsigned char x, y;
  unsigned char i;
  unsigned char x1, y1, x2, y2;
  
  (void)textcolor(DIALOGCOLOR);

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

  x1 = x + 1;
  y1 = y + 1;
  x2 = x1 + dialog->w;
  y2 = y1 + dialog->h;

  /* Draw dialog frame. */
  cvlinexy(x, y1,
	   dialog->h);
  cvlinexy(x2, y1,
	   dialog->h);

  chlinexy(x1, y,
	   dialog->w);
  chlinexy(x1, y2,
	   dialog->w);

  cputcxy(x, y, CH_ULCORNER);
  cputcxy(x, y2, CH_LLCORNER);
  cputcxy(x2, y, CH_URCORNER);
  cputcxy(x2, y2, CH_LRCORNER);
  
  /* Clear dialog contents. */
  for(i = y1; i < y2; ++i) {
    cclearxy(x1, i, dialog->w);
  }

  draw_window_contents(dialog, CTK_FOCUS_DIALOG, 0, sizey,
		       x1, x2, y1, y2);
}
コード例 #4
0
ファイル: main.c プロジェクト: Commodore64HomeBrew/galleryBBS
int showAddrsBar()
{
  int Len;

  cclearxy(0,0,screenW*2);
  chlinexy(0,1,screenW);
  cputsxy(0,0,"URL:");

  //fflush (stdout);
  fgets (url, sizeof (url), stdin);

  /* Remove trailing white space including the line terminator */
  Len = strlen (url);
  while (Len > 0 && isspace (url[Len-1])) {
      --Len;
  }
  url[Len] = '\0';

  if (Len>0) {
      getData();
  }

  return(Len);
}
コード例 #5
0
/*-----------------------------------------------------------------------------------*/
static void
s_ctk_draw_clear_window(struct ctk_window *window,
		      unsigned char focus,
		      unsigned char clipy1,
		      unsigned char clipy2)
{
  unsigned char i;
  unsigned char h;

  if(focus & CTK_FOCUS_WINDOW) {
    (void)textcolor(WINDOWCOLOR_FOCUS);
  } else {
    (void)textcolor(WINDOWCOLOR);
  }
    
  h = window->y + 2 + window->h;

  /* Clear window contents. */
  for(i = window->y + 2; i < h; ++i) {
    if(i >= clipy1 && i < clipy2) {
      cclearxy(window->x + 1, i, window->w);
    }
  }
}
コード例 #6
0
ファイル: tuilibap.c プロジェクト: hculpan/kbase
char process_numbox(tgui_Window *win, tgui_Obj *obj){

int ox, oy, x, maxx, bctr, num;
unsigned key;
unsigned min, max;

char *buf = malloc (sizeof(char)*(obj->width+1));


    strcpy(buf, obj->data);
	num=atoi(buf);

    min=obj->state;
	max=obj->height;

	//textcolor(p4color(obj->color));
    ox = win->x1 + 1 + obj->x;
    oy = win->y1 + 2 + obj->y;
    x=ox;

	//revers(1);
	cputsxy(x,oy, buf);
	//revers(0);


	   revers(1);
	   cputcxy(x+obj->width, oy,'^');
	   revers(0);


	maxx=x+obj->width;
    x=x+strlen(buf);
    bctr=strlen(buf);


	cursor(1);

	do {
		gotoxy(ox+obj->width, oy);
		key = cgetc();
		//gotoxy(3,22);  cprintf ("   "); gotoxy(3,22); cprintf("%d",key);

		if (key == CH_CURS_LEFT || key == CH_CURS_DOWN){
			if (num>min) {
			   // revers(1);
			    --num;
				itoa(num,buf,10);
				gotoxy(ox,oy);
				cclearxy(ox,oy, obj->width);
				gotoxy(ox,oy);
				cputs(buf);

			}

		}
			if (key == CH_CURS_RIGHT || key == CH_CURS_UP){
			if (num<max) {
			   // revers(1);
			    ++num;
				itoa(num,buf,10);
				gotoxy(ox,oy);
				cclearxy(ox, oy, obj->width);
				gotoxy(ox,oy);
				cputs(buf);

			}

		}
	} while (key!=CH_ENTER && key!=CH_F1 );

	cursor(0);

	if (key==CH_ENTER ) {
        revers(0);
        strcpy(obj->data, buf);

	}

	if (key==CH_ESC) {
	   revers(1);
	   gotoxy(ox,oy);
	   cclearxy(ox,oy,obj->width);
	   cputsxy(ox, oy, obj->data);
	}
	revers(0);
	cputcxy(ox+obj->width, oy,'^');


	free(buf);
	return key;

} // end of process_num_text
コード例 #7
0
ファイル: tuilibap.c プロジェクト: hculpan/kbase
void process_listbox(tgui_Window *win, tgui_Obj *obj){

tgui_Listitem *li;
int i, ox, oy, y, ostate, maxy;
unsigned key;

    //textcolor(obj->color);
    ox = win->x1 + 2 + obj->x;
    oy = win->y1 + 3 + obj->y;
	maxy=obj->y + obj->height + 1;

    y=oy;
    li = obj->firstitem;
	ostate = obj->state;
	revers(1);
	cputsxy(ox-1,oy-2, obj->caption);
	revers(0);

	for (i=0; i<obj->topid; i++ ) {
		li = li->next;
	}

	for (i=obj->topid; i<obj->state; i++) {
		li = li->next;
		++y;
	}

   	cursor(1);
	gotoxy(ox,y);

	do {
	   key=cgetc();

	   switch(key){
		   case CH_ENTER:
		       //closewindow(miwin);
                revers(0);
	           cputsxy(ox-1,oy-2, obj->caption);
	           revers(1);
		       return;

		   case CH_F1:
		       //closewindow(miwin);
			   obj->state = ostate;
			   // move bar back to orig place
		       return ;   // escape
		   case CH_CURS_LEFT:
		   case CH_CURS_DOWN:
		       if (li->next->li_id==0) { break; }  //y = oy;
		       revers(0);
  		       cputsxy(ox, y, li->caption);
               cclearxy(ox+strlen(li->caption) ,y, obj->width - strlen(li->caption)-1);
			   li=li->next;
			   obj->state = li->li_id;
			   if (y==maxy ) {
				   obj->topid = obj->topid+1;
				   showlistbox(obj, ox-1, oy-1, obj->color, obj->topid);

			   }


			   if (y<maxy) ++y;

			   if (y == maxy && li->next->li_id ==0){
			       cputcxy(obj->x+obj->width, obj->y+obj->height+2, '_');
			   }
			   else if (y==maxy && li->next->li_id !=0) {

				   cputcxy(obj->x+obj->width, obj->y+obj->height+2, '+');
			   }

			   revers(1);
			   cputsxy(ox, y, li->caption);
			   cclearxy(ox+strlen(li->caption) ,y, obj->width - strlen(li->caption)-1);
			   gotoxy(ox,y);
			   revers(0);
			   if(y==maxy && li->li_id >=(obj->height-1))  cputcxy(obj->x+obj->width, oy-1, '+');

			   break;

		   case CH_CURS_RIGHT:
		   case CH_CURS_UP:
		       if (li->li_id==0) {

				   break; }   // y = my+2+mid;
		       revers(0);
		       cputsxy(ox, y, li->caption);
			   cclearxy(ox+strlen(li->caption) ,y, obj->width - strlen(li->caption)-1);

			   li=li->prev;
			   obj->state = li->li_id;
			   if (y==oy) {
				   obj->topid = obj->topid-1;
				   showlistbox(obj, ox-1, oy-1, obj->color, obj->topid);
			    }

			   if (y > oy) --y;

			   if(y == oy && li->next->li_id != 0){
				   cputcxy(obj->x+obj->width, oy-1, '+');
			   }

			   revers(1);
			   cputsxy(ox, y, li->caption);
			   cclearxy(ox+strlen(li->caption) ,y, obj->width - strlen(li->caption)-1);
			   gotoxy(ox,y);
			   revers(0);

			   if (y==oy && li->li_id==0) cputcxy(obj->x+obj->width, oy-1, '_');

			   if (y==oy && (li->li_id +((obj->height)-1) - 1 < obj->lastitem->li_id ) ) {
				  cputcxy(obj->x+obj->width, oy+obj->height-1, '+');
			   }

			   break;

	       } // switch
	       gotoxy(ox,y);
	   } while(1);




}  // end processs_listbox
コード例 #8
0
ファイル: pencalib.c プロジェクト: Aliandrana/cc65
/*
** There is a delay between when the VIC sends its signal, and when the display
** shows that signal.  There is another delay between the display and when
** the lightpen says that it saw that signal. Each display and pen is different.
** Therefore, the driver must be calibrated to them.  A white bar is painted on
** the screen; and, a line is drawn down the middle of it.  When the user clicks
** on that line, the difference between its position and where the VIC thinks
** that the pen is pointing becomes an offset that is subtracted from what the
** VIC sees.
*/
void __fastcall__ pen_calibrate (unsigned char *XOffset)
{
    unsigned char oldBg = bgcolor (COLOR_BLUE);
    unsigned char oldText = textcolor (COLOR_GRAY3);
    unsigned char oldRev = revers (1);
    unsigned char sprite0Color = VIC.spr_color[0];
    unsigned char width, width2, height, height4, height8;
    struct mouse_info info;

    screensize (&width, &height);
    width2 = width / 2;
    height4 = height / 4;
    height8 = height4 * 8;

    /* Draw a bar and line. */

    clrscr ();
    cclearxy (0, height4, height4 * width);
    cvlinexy (width2, height4 + 1, height4 - 2);
    revers (0);

    /* Print instructions. */

    cputsxy (width2 - (sizeof COMMAND1) / 2, height / 2 + 1, COMMAND1);
    cputsxy (width2 - (sizeof COMMAND2) / 2, height / 2 + 3, COMMAND2);

    VIC.spr_color[0] = COLOR_GRAY2;
    mouse_show ();
    mouse_move (width2 * 8, height8 / 2);

    for (;;) {
        /* Wait for the main button to be released. */

        do ; while ((mouse_buttons () & MOUSE_BTN_LEFT));

        /* Wait for the main button to be pressed. */

        do {
            mouse_info (&info);
        } while (!(info.buttons & MOUSE_BTN_LEFT));

        /* Find out if the pen is on or off the bar. */

        if (info.pos.y < height8 || info.pos.y >= height8 * 2) {
            break;
        }

        /* On the bar; adjust the offset. */
        /* Characters are eight pixels wide.
        ** The VIC-II sees every other pixel;
        ** so, we use half of the difference.
        */

        *XOffset += (info.pos.x - (width2 * 8 + 8/2)) / 2;
    }

    /* Off the bar; wait for the main button to be released. */

    do ; while ((mouse_buttons () & MOUSE_BTN_LEFT));

    mouse_hide ();
    VIC.spr_color[0] = sprite0Color;
    revers (oldRev);
    textcolor (oldText);
    bgcolor (oldBg);
    clrscr ();
}
コード例 #9
0
ファイル: mouse-test.c プロジェクト: cc65/cc65
int main (void)
#endif
{
    struct mouse_info info;
    struct mouse_box full_box, small_box;
    unsigned char width, height;
    char C;
    bool Invisible = true, Done = false, Jailed = false;

#ifdef __ATARIXL__
    cprintf ("adding heap: $%04X bytes at $%04X\r\n",
             &_HIDDEN_RAM_SIZE__ - (&_HIDDEN_RAM_LAST__ - &_HIDDEN_RAM_START__),
             &_HIDDEN_RAM_LAST__);

    _heapadd (&_HIDDEN_RAM_LAST__, (size_t)(&_HIDDEN_RAM_SIZE__ - (&_HIDDEN_RAM_LAST__ - &_HIDDEN_RAM_START__)));
    cgetc ();
#endif

#ifndef NO_DEBUG
    /* Initialize the debugger */
    DbgInit (0);
#endif

    /* Set dark-on-light colors.  Clear the screen. */
#ifdef __CBM__
    (void) bordercolor (COLOR_GRAY2);
    (void) bgcolor (COLOR_WHITE);
    (void) textcolor (COLOR_GRAY1);
#else
    (void) bordercolor (COLOR_BLUE);
    (void) bgcolor (COLOR_WHITE);
    (void) textcolor (COLOR_BLACK);
#endif
    cursor (0);
    clrscr ();

    /* If a lightpen driver is installed, then it can get a calibration value
    ** from this file (if it exists).  Or, the user can adjust the pen; and,
    ** the value will be put into this file, for the next time.
    ** (Other drivers will ignore this.)
    */
#if defined(__C64__) || defined(__C128__) || defined(__CBM510__)
    pen_adjust ("pen.dat");
#endif

#if DYN_DRV
    /* If a dynamically loadable driver is named on the command line,
    ** then use that driver instead of the standard one.
    */
    if (argc > 1) {
        mouse_name = argv[1];
    } else {
#if defined(__ATARI__) || defined(__C64__) || defined(__C128__)
        char selection, flag = 0;
        cprintf ("Select mouse driver:\r\n"
                 "  0 - Joystick\r\n"
#ifdef __ATARI__
                 "  1 - ST Mouse\r\n"
                 "  2 - Amiga Mouse\r\n"
                 "  3 - Atari Trakball\r\n"
                 "  4 - Atari TouchPad\r\n"
#else
                 "  1 - 1351 Mouse\r\n"
                 "  2 - Inkwell Mouse\r\n"
                 "  3 - Paddle\r\n"
#endif
                 "Enter selection: ");
        while (1) {
            switch (selection = cgetc ()) {
            case '0': mouse_name = MSENAME_0; flag = 1; break;
            case '1': mouse_name = MSENAME_1; flag = 1; break;
            case '2': mouse_name = MSENAME_2; flag = 1; break;
            case '3': mouse_name = MSENAME_3; flag = 1; break;
#ifdef __ATARI__
            case '4': mouse_name = MSENAME_4; flag = 1; break;
#endif
            }
            if (flag) break;
        }
        cprintf ("%c\r\nOK, loading \"%s\",\r\nplease wait patiently...\r\n", selection, mouse_name);
#else
        /* Output a warning about the standard driver that is needed. */
        DoWarning ();
        mouse_name = mouse_stddrv;
#endif
    }

    /* Load and install the driver. */
    CheckError ("mouse_load_driver",
                mouse_load_driver (&MOUSE_CALLBACK, mouse_name));
#else  /* not DYN_DRV */
#if !defined(MOUSE_DRIVER) && (defined(__ATARI__) || defined(__C64__) || defined(__C128__))
    {
        char selection, flag = 0;
        cprintf ("Select mouse driver:\r\n"
                 "  0 - Joystick\r\n"
#ifdef __ATARI__
                 "  1 - ST Mouse\r\n"
                 "  2 - Amiga Mouse\r\n"
                 "  3 - Atari Trakball\r\n"
                 "  4 - Atari TouchPad\r\n"
#else
                 "  1 - 1351 Mouse\r\n"
                 "  2 - Inkwell Mouse\r\n"
                 "  3 - Paddle\r\n"
#endif
                 "Enter selection: ");
        while (1) {
            switch (selection = cgetc ()) {
            case '0': mouse_drv_use = MSESTAT_0; flag = 1; break;
            case '1': mouse_drv_use = MSESTAT_1; flag = 1; break;
            case '2': mouse_drv_use = MSESTAT_2; flag = 1; break;
            case '3': mouse_drv_use = MSESTAT_3; flag = 1; break;
#ifdef __ATARI__
            case '4': mouse_drv_use = MSESTAT_4; flag = 1; break;
#endif
            }
            if (flag) break;
        }
    }
#else
    mouse_drv_use = mouse_static_stddrv;
#endif

    /* Install the driver. */
    CheckError ("mouse_install",
                mouse_install (&MOUSE_CALLBACK,
#  ifdef MOUSE_DRIVER
                               MOUSE_DRIVER
#  else
#if defined(__ATARI__) || defined(__C64__) || defined(__C128__)
                               mouse_drv_use
#else
                               mouse_static_stddrv
#endif
#  endif
                               ));
#endif

#ifndef NO_JAIL
    /* Get the initial bounding box. */
    mouse_getbox (&full_box);
#endif

    screensize (&width, &height);

top:
    clrscr ();

    /* Print a help line */
    cputs (" d)ebug  h)ide   q)uit   s)how   j)ail");

    gotoxy (1, 20);
    cprintf ("SP: $%04X", getsp());

    /* Put a cross at the center of the screen. */
    gotoxy (width / 2 - 3, height / 2 - 1);
#if defined(__CBM__)
    cprintf ("%3u,%3u\r\n%*s\xDB", width / 2 * 8 + 4, height / 2 * 8 + 4,
             width / 2, "");
#else
    cprintf ("%3u,%3u\r\n%*s+", width / 2 * 8 + 4, height / 2 * 8 + 4,
             width / 2, "");
#endif

    /* Test loop */
    ShowState (Jailed, Invisible);
    do {
        /* Get the current co-ordinates and button states; and, print them. */
        mouse_info (&info);
        gotoxy (0, 2);
        cprintf (" X  = %3d\r\n", info.pos.x);
        cprintf (" Y  = %3d\r\n", info.pos.y);
        cprintf (" B1 = %c\r\n", (info.buttons & MOUSE_BTN_LEFT) ?
#ifdef __CBM__
                 0x5F
#else
                 'v'
#endif
                 : '^');
        cprintf (" B2 = %c", (info.buttons & MOUSE_BTN_RIGHT) ?
#ifdef __CBM__
                 0x5F
#else
                 'v'
#endif
                 : '^');

        /* Handle user input */
        if (kbhit ()) {
            cclearxy (1, 9, 23);
            switch (tolower (C = cgetc ())) {
#ifndef NO_DEBUG
                case 'd':
                    BREAK();

                    /* The debugger might have changed the colors.
                    ** Restore them.
                    */
#ifdef __CBM__
                    (void) bordercolor (COLOR_GRAY2);
                    (void) bgcolor (COLOR_WHITE);
                    (void) textcolor (COLOR_GRAY1);
#else
                    (void) bordercolor (COLOR_BLUE);
                    (void) bgcolor (COLOR_WHITE);
                    (void) textcolor (COLOR_BLACK);
#endif

                    /* The debugger changed the screen; restore it. */
                    goto top;
#endif
                case 'h':
                    mouse_hide ();
                    ShowState (Jailed, ++Invisible);
                    break;

#ifndef NO_JAIL
                case 'j':
                    if (Jailed) {
                        mouse_setbox (&full_box);
                        Jailed = false;
                    } else {
                        small_box.minx = max (info.pos.x - 10, full_box.minx);
                        small_box.miny = max (info.pos.y - 10, full_box.miny);
                        small_box.maxx = min (info.pos.x + 10, full_box.maxx);
                        small_box.maxy = min (info.pos.y + 10, full_box.maxy);
                        mouse_setbox (&small_box);
                        Jailed = true;
                    }
                    ShowState (Jailed, Invisible);
                    break;
#endif
                case 's':
                    mouse_show ();
                    if (Invisible) {
                        ShowState (Jailed, --Invisible);
                    }
                    break;

                case 'q':
                    Done = true;
                    break;

                default:
                    gotoxy (1, 9);
                    cprintf ("Spurious character: $%02X", C);
            }
        }
    } while (!Done);

#if DYN_DRV
    /* Uninstall and unload the driver. */
    CheckError ("mouse_unload", mouse_unload ());
#else
    /* Uninstall the static driver. */
    CheckError ("mouse_uninstall", mouse_uninstall ());
#endif

    /* Say goodbye */
    cputsxy (0, height / 2 + 3, "Goodbye!");
    return EXIT_SUCCESS;
}
コード例 #10
0
ファイル: mul-test.c プロジェクト: Aliandrana/snesdev
int main(void)
{
    char C;

    /* Clock variable */
    clock_t Ticks;
    unsigned Sec;
    unsigned Milli;

    /* Actual test variables */
    register unsigned lhs = 0;
    register unsigned rhs = 0;
    register unsigned res;

    /* Clear the screen and output an informational message */
    clrscr ();
    screensize (&Width, &Height);
    cprintf ("This program does an exhaustive test of\r\n"
             "the multiplication routine. It runs\r\n"
             "several days, so please wait very\r\n"
             "patiently (or speedup your emulator)\r\n"
             "\r\n"
             "Progress:\r\n");

    /* Remember the current position for the progress bar */
    X = wherex ();
    Y = wherey ();


    /* Read the clock */
    Ticks = clock();


    do {

        /* Update the progress bar */
        ProgressMeter (lhs);

        /* Do one row of tests */
        res = 0;
        do {
            if (lhs * rhs != res) {
                gotoxy (X, Y+1);
                cprintf ("Error on %u * %u: %u != %u\r\n", lhs, rhs, lhs * rhs, res);
                cprintf ("Press a key ..., 'Q' to quit");
                C = toupper (cgetc ());
                cclearxy (X, Y+1, Width);
                cclearxy (X, Y+2, Width);
                if (C == 'Q') {
                    goto Done;
                }
            }
            res += lhs;
        } while (++rhs != 0);

    } while (++lhs != 0);

Done:
    /* Calculate the time used */
    Ticks = clock() - Ticks;
    Sec = (unsigned) (Ticks / CLOCKS_PER_SEC);
    Milli = ((Ticks % CLOCKS_PER_SEC) * 1000) / CLOCKS_PER_SEC;

    /* Print the time used */
    gotoxy (X, Y+1);
    cprintf ("Time used: %u.%03u seconds\n", Sec, Milli);

    return 0;
}
コード例 #11
0
ファイル: mul-test.c プロジェクト: eakmeister/cc65
int main(void)
{
    char C;

    /* Clock variables */
    clock_t Ticks;
    clock_t Wait;
    unsigned Days;
    unsigned Hours;
    unsigned Minu;
    unsigned Sec;
    unsigned Milli;

    /* Actual test variables */
    register unsigned lhs = 0;
    register unsigned rhs = 0;
    register unsigned res;

    /* Clear the screen, and output an informational message. */
    clrscr ();
    screensize (&Width, &Height);
    cprintf ("This program does an exhaustive test of\r\n"
             "the multiplication routine. It runs for\r\n"
             "several days; so, please wait very\r\n"
             "patiently (or, speed up your emulator).\r\n"
             "\n"
             "Progress: ");

    /* Remember the current position for the progress bar */
    X = wherex ();
    Y = wherey ();

    /* Mark the maximum limit of the bar. */
    revers (1);
    cputcxy (BAR_ELEMENTS, Y, ' ');
    cputcxy (BAR_ELEMENTS, Y + 1, ' ');
    revers (0);

/* [Targets that have clock() will define CLOCKS_PER_SEC.] */
#ifdef CLOCKS_PER_SEC

    /* Start timing the test. */
    Ticks = clock();
#endif

    do {

        /* Update the progress bar */
        ProgressMeter (lhs);

/* Enable this to test the progress-meter code.
** (And, run emulators at their maximun speed.)
*/
#if 0
	continue;
#endif

        /* Do one row of tests */
        res = 0;
        do {
            if (lhs * rhs != res) {
#ifdef CLOCKS_PER_SEC
                Wait = clock ();
#endif
                gotoxy (0, Y+3);
                cprintf ("Error on %u * %u: %u != %u\r\n", lhs, rhs, lhs * rhs, res);
                cprintf ("Press a key -- 'Q' to quit. ");
                cursor (1);
                C = toupper (cgetc ());
                cclearxy (0, Y+3, Width);
                cclearxy (0, Y+4, Width);

#ifdef CLOCKS_PER_SEC

                /* Don't time the user's interaction. */
                Ticks += clock () - Wait;
#endif

                if (C == 'Q') {
                    goto Done;
                }
            }

	    if (kbhit () && toupper (cgetc ()) == 'Q') {
		goto Done;
	    }

            res += lhs;
        } while (++rhs != 0);

    } while (++lhs != 0);

Done:
#ifdef CLOCKS_PER_SEC

    /* Calculate the time used */
    Ticks = clock() - Ticks;
    Milli = ((Ticks % CLOCKS_PER_SEC) * 1000) / CLOCKS_PER_SEC;
    Sec = (unsigned) (Ticks / CLOCKS_PER_SEC);
    Minu = Sec / 60;
    Hours = Minu / 60;
    Days = Hours / 24;
    Hours %= 24;
    Minu %= 60;
    Sec %= 60;

    /* Print the time used */
    gotoxy (0, Y+3);
    cprintf ("Time used:\r\n"
             " %u days,\r\n"
             " %u hours,\r\n"
             " %u minutes,\r\n"
             " %u.%03u seconds.\n", Days, Hours, Minu, Sec, Milli);
#endif

#ifdef __ATARI__
    if (_dos_type != SPARTADOS && _dos_type != OSADOS) {
	cprintf ("\rTap a key, to exit. ");
	cgetc();
    }
#endif
    return 0;
}
コード例 #12
0
ファイル: screen.c プロジェクト: A2Command/a2command
enum results __fastcall drawInputDialog(
	unsigned char lineCount,
	unsigned char length,
	unsigned char *message[],
	unsigned char *title,
	unsigned char *resultText)
{
	unsigned char x = 0, y = 0, h = 0, w = 0, i = 0, 
		key = 0, count = 0;
	unsigned result;
	unsigned char *input;
	input = calloc(length+1, sizeof(unsigned char));
	h = lineCount + 6;
	w = length + 6;
	//for(i=0; i<lineCount; ++i);
	//{
	//	if(strlen(message[i]) > w) 
	//		w = strlen(message[i]);
	//}

	x = getCenterX(w);
	y = getCenterY(h);

	writePanel(
		true, false, COLOR_WHITE,
		x, y, h, w,
		title,
		"Cancel",
		"Done");

	for(i=0; i<lineCount; ++i)
	{
		//textcolor(color_text_other);
		cputsxy(x+2, i+2+y,message[i]);
	}	
	++i;
	
	gotoxy(x+2, i+2+y);
	revers(true);
	//textcolor(color_text_other);
	
	cclearxy(x+2, i+2+y, length + 1);
	cputcxy(x+2, i+2+y, '<');
	count = 0;
	key = cgetc();
	while(key != CH_ESC 
		&& key != CH_ENTER)
	{
		writeStatusBarf("%c - %d", key, key);
		if( count < length &&
			(
				(key >= 32 && key <= 126)
			)
		)
		{
			input[count] = key;
			input[count+1] = '\0';
			gotoxy(x+2+count, i+2+y);
			cputc(key);
			++count;
			gotoxy(x+2+count, i+2+y);
			cputc('<');
		}
		else if(
			key == 8
			&& count > 0)
		{
			input[count-1] = '\0';
			gotoxy(x+2+count, i+2+y);
			cputc(' ');
			--count;
			gotoxy(x+2+count, i+2+y);
			cputc('<');
		}

		key = cgetc();
	}

	trimString(input);
	strcpy(resultText, input);

	switch((int)key)
	{
	case CH_ENTER: result = OK_RESULT; break;
	default: result = CANCEL_RESULT; break;
	}

	revers(false);
	free(input);
	return result;
}
コード例 #13
0
ファイル: mousetest.c プロジェクト: FelipeBudinich/cc65
int main (void)
#endif
{
    struct mouse_info info;
    struct mouse_box full_box, small_box;
    unsigned char width, height;
    char C;
    bool Invisible = true, Done = false, Jailed = false;

    /* Initialize the debugger */
    DbgInit (0);

    /* Set dark-on-light colors.  Clear the screen. */
#ifdef __CBM__
    (void) bordercolor (COLOR_GRAY2);
    (void) bgcolor (COLOR_WHITE);
    (void) textcolor (COLOR_GRAY1);
#else
    (void) bordercolor (COLOR_BLUE);
    (void) bgcolor (COLOR_WHITE);
    (void) textcolor (COLOR_BLACK);
#endif
    cursor (0);
    clrscr ();

    /* If a lightpen driver is installed, then it can get a calibration value
    ** from this file (if it exists).  Or, the user can adjust the pen; and,
    ** the value will be put into this file, for the next time.
    ** (Other drivers will ignore this.)
    */
#if defined(__C64__) || defined(__C128__) || defined(__CBM510__)
    pen_adjust ("pen.dat");
#endif

#if DYN_DRV
    /* If a dynamically loadable driver is named on the command line,
    ** then use that driver instead of the standard one.
    */
    if (argc > 1) {
        mouse_name = argv[1];
    } else {
        /* Output a warning about the standard driver that is needed. */
        DoWarning ();
        mouse_name = mouse_stddrv;
    }

    /* Load and install the driver. */
    CheckError ("mouse_load_driver",
                mouse_load_driver (&mouse_def_callbacks, mouse_name));
#else
    /* Install the driver. */
    CheckError ("mouse_install",
                mouse_install (&mouse_def_callbacks,
#  ifdef MOUSE_DRIVER
                               MOUSE_DRIVER
#  else
                               mouse_static_stddrv
#  endif
                               ));
#endif

    /* Get the initial bounding box. */
    mouse_getbox (&full_box);

    screensize (&width, &height);

top:
    clrscr ();

    /* Print a help line */
    cputs (" d)ebug  h)ide   q)uit   s)how   j)ail");

    /* Put a cross at the center of the screen. */
    gotoxy (width / 2 - 3, height / 2 - 1);
#if defined(__CBM__)
    cprintf ("%3u,%3u\r\n%*s\xDB", width / 2 * 8 + 4, height / 2 * 8 + 4,
             width / 2, "");
#else
    cprintf ("%3u,%3u\r\n%*s+", width / 2 * 8 + 4, height / 2 * 8 + 4,
             width / 2, "");
#endif

    /* Test loop */
    ShowState (Jailed, Invisible);
    do {
        /* Get the current co-ordinates and button states; and, print them. */
        mouse_info (&info);
        gotoxy (0, 2);
        cprintf (" X  = %3d\r\n", info.pos.x);
        cprintf (" Y  = %3d\r\n", info.pos.y);
        cprintf (" B1 = %c\r\n", (info.buttons & MOUSE_BTN_LEFT) ?
#ifdef __CBM__
                 0x5F
#else
                 'v'
#endif
                 : '^');
        cprintf (" B2 = %c", (info.buttons & MOUSE_BTN_RIGHT) ?
#ifdef __CBM__
                 0x5F
#else
                 'v'
#endif
                 : '^');

        /* Handle user input */
        if (kbhit ()) {
            cclearxy (1, 9, 23);
            switch (tolower (C = cgetc ())) {
                case 'd':
                    BREAK();

                    /* The debugger might have changed the colors.
                    ** Restore them.
                    */
#ifdef __CBM__
                    (void) bordercolor (COLOR_GRAY2);
                    (void) bgcolor (COLOR_WHITE);
                    (void) textcolor (COLOR_GRAY1);
#else
                    (void) bordercolor (COLOR_BLUE);
                    (void) bgcolor (COLOR_WHITE);
                    (void) textcolor (COLOR_BLACK);
#endif

                    /* The debugger changed the screen; restore it. */
                    goto top;

                case 'h':
                    mouse_hide ();
                    ShowState (Jailed, ++Invisible);
                    break;

                case 'j':
                    if (Jailed) {
                        mouse_setbox (&full_box);
                        Jailed = false;
                    } else {
                        small_box.minx = max (info.pos.x - 10, full_box.minx);
                        small_box.miny = max (info.pos.y - 10, full_box.miny);
                        small_box.maxx = min (info.pos.x + 10, full_box.maxx);
                        small_box.maxy = min (info.pos.y + 10, full_box.maxy);
                        mouse_setbox (&small_box);
                        Jailed = true;
                    }
                    ShowState (Jailed, Invisible);
                    break;

                case 's':
                    mouse_show ();
                    if (Invisible) {
                        ShowState (Jailed, --Invisible);
                    }
                    break;

                case 'q':
                    Done = true;
                    break;

                default:
                    gotoxy (1, 9);
                    cprintf ("Spurious character: $%02X", C);
            }
        }
    } while (!Done);

#if DYN_DRV
    /* Uninstall and unload the driver. */
    CheckError ("mouse_unload", mouse_unload ());
#else
    /* Uninstall the static driver. */
    CheckError ("mouse_uninstall", mouse_uninstall ());
#endif

    /* Say goodbye */
    cputsxy (0, height / 2 + 3, "Goodbye!");
    return EXIT_SUCCESS;
}