Exemple #1
0
/* Delete Extended DOS Partition Interface */
void Delete_Extended_DOS_Partition_Interface()
{
  int input=0;
  Partition_Table *pDrive = &part_table[flags.drive_number-0x80];

  Clear_Screen(0);

  Print_Centered(4,"Delete Extended DOS Partition",BOLD);

  Display_Primary_Partition_Information_SS();

  BlinkPrintAt(4,18,"WARNING!");

  printf(" Data in the deleted Extended DOS Partition will be lost.");
  printAt(4,19,"Do you wish to continue (Y/N).................? ");

  flags.esc=FALSE;
  input=(int)Input(1,52,19,YN,0,0,ESCR,0,0,NULL,NULL);

  if( (flags.esc==FALSE) && (input==TRUE) )
    {
    Delete_Primary_Partition(int(pDrive->ptr_ext_part-pDrive->pri_part));
    Clear_Extended_Partition_Table(flags.drive_number-128);

    Clear_Screen(0);
    Print_Centered(4,"Delete Extended DOS Partition",BOLD);
    Display_Primary_Partition_Information_SS();

    cprintAt(4,21,"Extended DOS Partition deleted");

    printAt(4,24,"                                    ");

    Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL);
    }
}
Exemple #2
0
void
UI::draw (int width, int height, StringModel *str)
{
  float fProportion = 20;
  float fSize = fmin(width,height) / fProportion;
  font.FaceSize(fSize);
  char buf[100];

  sprintf(buf,"tension   %9.7lf", str->Ktension);
  printAt ( 0, 0.9*height, buf );

  sprintf(buf,"damping  %9.7lf", str->Kdamping);
  printAt ( 0, 0.8*height, buf );

  sprintf(buf,"vib freq    %9.4lf Hz", str->vibratorFreq);
  printAt ( 0, 0.7*height, buf );
  
  sprintf(buf,"vib amp    %9.4lf mm", str->vibratorAmplitude*1000);
  printAt ( 0, 0.6*height, buf );

  if ( str->vibratorOn ) 
    sprintf(buf,"vib on");
  else
    sprintf(buf,"vib off");
  printAt ( 0, 0.5*height, buf );

  
}
Exemple #3
0
/* Delete Non-DOS Partition User Interface */
void Delete_N_DOS_Partition_Interface()
{
  int input=0;

  Clear_Screen(0);
  Print_Centered(4,"Delete Non-DOS Partition",BOLD);

  Display_Primary_Partition_Information_SS();

  BlinkPrintAt(4,18,"WARNING!");

  printf(" Data in the deleted Non-DOS Partition will be lost.");
  printAt(4,19,"What Non-DOS Partition do you want to delete..? ");

  flags.esc=FALSE;
  input=(int)Input(1,52,19,NUM,1,4,ESCR,-1,0,NULL,NULL); /* 4 needs changed to the max num of partitions */

  if(flags.esc==FALSE)
    {
    Delete_Primary_Partition(input-1);

    Clear_Screen(0);
    Print_Centered(4,"Delete Non-DOS Partition",BOLD);
    Display_Primary_Partition_Information_SS();
    cprintAt(4,21,"Non-DOS Partition deleted");
    printAt(4,24,"                                    ");

    Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL);
    }
}
Exemple #4
0
void pressSpeedKey() {
    int f, key;

    for (f = 0; f < 51; ++f) {
        BIFROSTH_setTile(rand()%9, rand()%9, rand()%8);
    }
    in_wait_nokey();

    printInk(7);
    printAt(22, 1);
    printf("CHOOSE SPEED 2-4 OR 0 TO EXIT");

    while ((key = in_inkey()) != '0') {
        switch (key) {
            case '2':
                BIFROSTH_resetAnimSlow();
                printInk(5);
                printAt(20, 25);
                printf(" slow)");
                break;
            case '4':
                BIFROSTH_resetAnimFast();
                printInk(5);
                printAt(20, 25);
                printf(" fast)");
                break;
        }
    }

    printAt(22, 1);
    printf("                             ");
}
/*
 *  drawValues()
 *  ------
 *  Draw the values in the lower left corner
 */
void drawValues()
{
  if (toggleValues) {
    glColor3f(0.8,0.8,0.8);
    printAt(5,5,"View Angle (th, ph) =(%d, %d)", th,ph);
    printAt(5,25,"Projection mode =(%s)", toggleMode?"Perspective":"Orthogonal");
  }
}
Exemple #6
0
/* Display/Modify Partition Information */
void Display_Partition_Information()
{
  int input;
  Partition_Table *pDrive = &part_table[flags.drive_number-0x80];

  Beginning:

  Clear_Screen(0);
  if(flags.extended_options_flag==FALSE)
   Print_Centered(4,"Display Partition Information",BOLD);
  else Print_Centered(4,"Display/Modify Partition Information",BOLD);

  Display_Primary_Partition_Information_SS();

  if(pDrive->num_of_log_drives>0)
    {
    printAt(4,17,"The Extended DOS Partition contains Logical DOS Drives.");
    printAt(4,18,"Do you want to display the logical drive information (Y/N)......?");

    if(flags.extended_options_flag==TRUE)
      {
      printAt(4,19,"  (Optional:  Type the number of the partition to modify.)");

      input=(int)Input(1,69,18,YN,0,0,ESCR,1,0,"1","4");

      if( ((input-48)>=1) && ((input-48)<=4) )
        {
        Modify_Primary_Partition_Information((input-48));
        goto Beginning;
        }
      }
    else input=(int)Input(1,69,18,YN,0,0,ESCR,1,0,NULL,NULL);

    if(input==TRUE)
      {
      Display_Or_Modify_Logical_Drive_Information();
      if(flags.extended_options_flag==TRUE) goto Beginning;
      }
    }
  else
    {
    if(flags.extended_options_flag==FALSE)
     Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL);
    else
     {
     printAt(4,18,"Enter the number of the partition you want to modify (1-4)......?");

     flags.esc=FALSE;
     input=(int)Input(1,69,18,NUM,1,4,ESCR,1,0,NULL,NULL);

     if(flags.esc==FALSE)
       {
       Modify_Primary_Partition_Information(input);
       goto Beginning;
       }
     }
    }
}
static inline void printStatus(uint16 curX, uint16 curY, bool inCmdMode)
{
    // The trailing spaces clears out junky characters! Keep them
    // Also the 181 and 198 are hybrid boxed drawing chars. Not adding them
    printCharAt((char) 181, black, 1, 24);
    printAt(inCmdMode ? " CMD     " : " INS     ", dark_grey, 2, 24);
    printAt(itos10(curX - 1), black, 7, 24);
    printAt(":     ", black, 10, 24);
    printAt(itos10(curY - 5), black, 12, 24);
    printCharAt((char) 198, black, 16, 24);
}
Exemple #8
0
void pressAnyKey() {
    in_wait_nokey();

    printInk(7);
    printAt(22, 1);
    printf("PRESS ANY KEY");

    in_wait_key();

    printAt(22, 1);
    printf("             ");
}
/*
 *  drawParameters()
 *  ------
 *  Draw the parameters in the lower left corner
 */
void drawParameters(void)
{
  if (toggleParams) {
    glColor3fv(white);
    /*  Display parameters */
    printAt(5,5,"Angle=%d,%d  Dim=%.1f FOV=%d Light=%s",
	    th,ph,dim,fov,toggleLight?"On":"Off");
    if (toggleLight) {
      printAt(5,45,"Distance=%d Elevation=%.1f Ambient=%d",distance,lightY,ambient);
      printAt(5,25,"Diffuse=%d Specular=%d Emission=%d Shininess=%.0f",
	      diffuse,specular,emission,shinyvec[0]);
    }
  }
}
void drawRelevantParameters(void)
{
  if (vals) {
    glColor3fv(white);
    
    printAt(5,5,"Angle=%d,%d  Dim=%.1f FOV=%d Light=%s",
	    th,ph,dim,fov,light?"On":"Off");
    if (light) {
      printAt(5,45,"Distance=%d Elevation=%.1f",distance,lightY);
      printAt(5,25,"Ambient=%d  Diffuse=%d Specular=%d Emission=%d Shininess=%.0f",
	      ambient,diffuse,specular,emission,shinyvec[0]);
    }
  }
}
void sidebarRow(int x, int y, int obj, char* text)
{
  glColor3fv(white);
  if (objectSelected == obj) glColor3f(1,0,1);
  printAt(x,y,text);
  glColor3fv(white);
}
Exemple #12
0
// this is shown at the top of every unanswered question during 'me' setup
void meHeader()
{
    clearLine(0,26,0x88);

    drawFrame(header_background, 20, 8, 60, 11);
    printAt("Me Setup Process", 0x3D, 21, 9);
}
Exemple #13
0
/* Change Current Fixed Disk Drive */
void Change_Current_Fixed_Disk_Drive()
{
  int new_drive_number;
  int old_drive_number=flags.drive_number;

  Clear_Screen(0);
  Print_Centered(0,"Change Current Fixed Disk Drive",BOLD);

  Display_All_Drives();

  printAt(4,21,"Enter Fixed Disk Drive Number (1-%d)......................."
                                       ,(flags.maximum_drive_number-127));

  new_drive_number=(int)Input(1,62,21,NUM,1,(flags.maximum_drive_number-127)
   ,ESCR,(flags.drive_number-127),0,NULL,NULL);

  if( (new_drive_number<=0)
   || (new_drive_number>(flags.maximum_drive_number-127)) )
    {
    flags.drive_number=old_drive_number;
    }
  else
    {
    flags.drive_number=new_drive_number+127;
    }
}
Exemple #14
0
void setup()
{
    clearLine(0,26,0x66);

    // show a small title to let the user know what they are doing
    drawFrame(header_background, 20, 8, 60, 11);
    printAt("Q OS Setup Process", desc_foreground, 21, 9);

    messageBox("Welcome to Q OS. Press <RET> to begin\n\rthe setup process.");

    // get the user ot enter a PC-NAME and UserName for there Q OS Account
    pcName = messageBox_I("Enter a name to assign to this\n\rcomputer.");
    userName = messageBox_I("Enter a username to assign to your\n\rQ OS user account.");

    // get the user to enter a password to protect there account on Q OS
    password = messageBox_Pass("Enter a password to protect your\n\raccount");

    // this is mostly just a proof of concpet nad does nothing except ask a question for now
    if(messageBox_YN("Do you want to use the Q Data Cloud\n\rservice?") == 1)
    {
        useQDC= true;

        email = messageBox_I("Enter your email to be used with the\n\rQ Data Cloud.");
    }

    // require the user to login with their new account
    loggedIn = false;
    logout();
}
static inline void printStatus(bool inColorMode)
{
    // The trailing spaces clears out junky characters! Keep them
    // Also the 181 and 198 are hybrid boxed drawing chars. Not adding them
    printCharAt((char) 181, black, 2, 24);
    printAt(inColorMode ? " PENCIL "
            : " ERASER ", dark_grey, 3, 24);
    printCharAt((char) 198, black, 11, 24);
}
void oldWriter()
{
	paintScreen(screen_color);

	drawFrame(header_background, 0, 0, 80, 4);
	printAt("Q OS Text Editor\r\n", header_foreground, 1, 1);
	printAt("Simple Text Editor built for Q OS by Raph Hennessy & Plankp T",desc_foreground,1,2);

	drawBorder(screen_background, 0, 4, 80, sh - 1);

	cursorY = 5;
	cursorX = 1;
	updateCursor();

	writing = true;
	printAt(writerContents,black,1,5);
	writerContents = readstr();
	writing = false;
}
Exemple #17
0
/* Delete Primary DOS Partition Interface */
void Delete_Primary_DOS_Partition_Interface()
{
  int input=0;
  int partition_to_delete;

  Clear_Screen(0);

  Print_Centered(4,"Delete Primary DOS Partition",BOLD);
  Display_Primary_Partition_Information_SS();

  BlinkPrintAt(4,19,"WARNING!");

  printf(" Data in the deleted Primary DOS Partition will be lost.");
  printAt(4,20,"What primary partition do you want to delete..? ");

  flags.esc=FALSE;
  input=(int)Input(1,52,20,NUM,1,4,ESCR,-1,0,NULL,NULL); /* 4 needs changed to the max num of partitions */

  if(flags.esc==FALSE)
    {
    partition_to_delete=input-1;

    printAt(4,22,"Are you sure (Y/N)..............................? ");
    flags.esc=FALSE;
    input=(int)Input(1,54,22,YN,0,0,ESCR,0,0,NULL,NULL);

    if( (input==TRUE) && (flags.esc==FALSE) )
      {
      Delete_Primary_Partition(partition_to_delete);

      Clear_Screen(0);

      Print_Centered(4,"Delete Primary DOS Partition",BOLD);
      /* */
      Display_Primary_Partition_Information_SS();
      cprintAt(4,21,"Primary DOS Partition deleted");

      Input(0,0,0,ESC,0,0,ESCC,0,0,NULL,NULL);
      }
    }
}
Exemple #18
0
int c_main( void ) {
  UBreakIterator *boundary;
  char           cStringToExamine[] = "Aaa bbb ccc. Ddd eee fff.";
  UChar          stringToExamine[sizeof(cStringToExamine)+1]; 
  UErrorCode     status = U_ZERO_ERROR;

  printf("\n\n"
	 "C Boundary Analysis\n"
	 "-------------------\n\n");

  printf("Examining: %s\n", cStringToExamine);
  u_uastrcpy(stringToExamine, cStringToExamine);
        
  /*print each sentence in forward and reverse order*/
  boundary = ubrk_open(UBRK_SENTENCE, "en_us", stringToExamine,
		       -1, &status);
  if (U_FAILURE(status)) {
    printf("ubrk_open error: %s\n", u_errorName(status));
    exit(1);
  }

  printf("\n----- Sentence Boundaries, forward: -----------\n"); 
  printEachForward(boundary, stringToExamine);
  printf("\n----- Sentence Boundaries, backward: ----------\n");
  printEachBackward(boundary, stringToExamine);
  ubrk_close(boundary);
    
  /*print each word in order*/
  boundary = ubrk_open(UBRK_WORD, "en_us", stringToExamine,
		       u_strlen(stringToExamine), &status);
  printf("\n----- Word Boundaries, forward: -----------\n"); 
  printEachForward(boundary, stringToExamine);
  printf("\n----- Word Boundaries, backward: ----------\n");
  printEachBackward(boundary, stringToExamine);
  /*print first element*/
  printf("\n----- first: -------------\n");
  printFirst(boundary, stringToExamine);
  /*print last element*/
  printf("\n----- last: --------------\n");
  printLast(boundary, stringToExamine);
  /*print word at charpos 10 */
  printf("\n----- at pos 10: ---------\n");
  printAt(boundary, 10 , stringToExamine);
    
  ubrk_close(boundary);

  printf("\nEnd of C boundary analysis\n");
  return 0;
}
Exemple #19
0
/* List the Partition Types */
void List_Partition_Types()
{
  int index=0;
  int row=4;
  int column=0;
  do
    {
    if( (index==0) || (index==64) || (index==128) || (index==192) )
      {
      Clear_Screen(0);
      Print_Centered(1,"List Partition Types",BOLD);
      row=4;
      column=0;
      }

    if( row==20 )
      {
      row=4;
      column += 20;
      }

    cprintAt(column,row,"%3d ",index);
    printf("%s",partition_lookup_table_buffer_long[index]);

    if( (index==63) || (index==127) || (index==191) || (index==255) )
      {

     printAt(0,23,"Press ");cprintf("Any Key");printf(" to continue");

     asm{
       mov ah,7
       int 0x21
       }
      }

    row++;
    index++;
    }while(index<=255);
Exemple #20
0
/* Get input from keyboard */
unsigned long Input(int size_of_field,int x_position,int y_position,int type
 ,int min_range,long max_range,int return_message,long default_value
 ,long maximum_possible_percentage,char optional_char_1[1],char optional_char_2[1])
{
  /*
  size_of_field:                 number of characters for the user to enter,
                                 if size of field is 0 then no input box
				 is drawn on the screen.
  x_position, y_position:        screen coordinates to place the input box
  type                           type of input--CHAR  A single character as
                                                      specified by min_range
                                                      and max_range.  min_range
                                                      and max_range are the
                                                      min. and max. ASCII
                                                      values possible for this
                                                      input field. The ASCII
                                                      values in these 2 fields
                                                      should be of capital
                                                      characters only.  If the
                                                      user enters a lower case
                                                      character it will be
						      converted to uppercase.
						YN    Either a yes or no.
						NUM   A number as specified
                                                      by min_range and
                                                      max_range.
                                                NUMP  A number or percentage
                                                      within the limits of
                                                      the size_of_field.
                                                ESC   Waits for the ESC key
                                                      only
  return_message                                ESCR  Displays "Press
                                                      Esc to return to FDISK
						      Options"
                                                ESCE  Displays "Press
						      Esc to exit FDISK"
                                                ESCC  Displays "Press Esc to
                                                      continue"
						NONE  Does not display a
                                                      return message.
  default_value                  The default value that is displayed for
                                 input.  This option only works with the NUM
				 type or the YN type.
                                 Set this to -1 if it is not used.
  maximum_possible_percentage                   If type is NUMP, this is the
                                                maximum percentage possible.
  optional_char_1[1] and
  optional_char_2[1]             2 optional character fields for use with
                                 the NUM type when size_of_field==1
                                 Also is used as two option number fields
                                 (converted to char value) when type==CHAR
                                 and a single digit numeric input is possible.
                                 In this case these two variables define a
                                 range.  When type==YN this functions the same
                                 as with NUM type above.
  */

  char input;
  char line_buffer[18];

  unsigned long multiplier;

  int char_max_range;
  int default_value_preentered=FALSE;
  int index;
  int invalid_input=FALSE;
  int line_buffer_index=0;
  int proper_input_given=FALSE;
  int percent_entered=FALSE;
  int percent_just_entered=FALSE;

  unsigned long data_max_range=max_range;
  unsigned long data;

  /* Clear line buffer */
  index=0;
  do
    {
    line_buffer[index]=0;
    index++;
    }while(index<10);

  /* Place appropriate text on the screen prior to obtaining input */
  if(type!=ESC)
    {
    Position_Cursor(x_position,y_position);

    cprintf("[");

    index=0;
    do
      {
      cprintf(" ");
      index++;
      }while(index<size_of_field);

    cprintf("]");
    }

  /* Display the return message */
  if( (return_message==ESCR) || (return_message==ESCE) || (return_message==ESCC) )
    {
    printAt(4,24,"                                                 ");
    printAt(4,24,catgets(cat,4,1,"Press"));
    cprintf(" Esc ");
    printf(catgets(cat,4,2,"to"));
    printf(" ");
    }

  if(return_message==ESCR) printf(catgets(cat,4,3,"return to FDISK options"));

  if(return_message==ESCE) printf(catgets(cat,4,4,"exit FDISK"));

  if(return_message==ESCC) printf(catgets(cat,4,5,"continue"));

  /* Set the default value for NUM type, if applicable */
  if( (default_value>=0) && (type==NUM) && (size_of_field==1) )
    {
    Position_Cursor(x_position+1,y_position);
    printf("%d",default_value);
    line_buffer_index=0;
    line_buffer[0]=default_value+48;
    }

  /* Set the default value for NUMP type, if applicable */
  if( (default_value>=0) && (type==NUMP) && (size_of_field>1) )
    {
    ltoa(default_value,line_buffer,10);
    line_buffer_index=strlen(line_buffer);

    /* Display line_buffer */
    index=line_buffer_index;
    do
      {
      Position_Cursor((x_position+size_of_field-line_buffer_index+index)
       ,y_position);
      index--;
      cprintf("%c",line_buffer[index]);
      }while(index>0);

    default_value_preentered=TRUE;
    }

  /* Set the default value for YN type, if applicable */
  if( (default_value>=0) && (type==YN) && (size_of_field==1) )
    {
    Position_Cursor(x_position+1,y_position);

    if(default_value==1)
      {
      printf("Y");
      line_buffer_index=0;
      line_buffer[0]='Y';
      data=TRUE;
      }

    if(default_value==0)
      {
      printf("N");
      line_buffer_index=0;
      line_buffer[0]='N';
      data=FALSE;
      }
    }

  do
    {
    if(type!=ESC) Position_Cursor((size_of_field+x_position),y_position);

    /* Obtain keypress from keyboard */
    asm{
      mov ah,7
      int 0x21
      mov BYTE PTR input,al
      }

    /* Zero the default value if type==NUMP, the enter, esc, or backspace key */
    /* has not been pressed, and the default value is pre-entered. */
    if( (default_value>=0) && (type==NUMP) && (size_of_field>1)
     && (input!=8) && (input!=13) && (input!=27)
     && (default_value_preentered==TRUE) )
      {
      line_buffer_index=0;

      index=0;
      do
        {
        line_buffer[index]=0;
        index++;
        }while(index<10);

      default_value_preentered=FALSE;
      }

    /* Clear error messages from screen */
    if(type!=YN)
      {
      printAt(4,22,"                                                              ");
      }

    printAt(4,23,"                                                    ");
    Position_Cursor(4,24);

    /* Esc key has been hit */
    if(input==27)
      {
      flags.esc=TRUE;
      proper_input_given=TRUE;
      data=0;
      type=99;
      }

    /* Enter key has been hit */
    if(input==13)
      {
      if( ( (type==CHAR) || (type==YN) ) && (line_buffer[0]!=0) && ( (data==TRUE) || (data==FALSE) || (data!=99) ) )
        {
        proper_input_given=TRUE;

        type=99;
        }

      if( (type==NUMYN) && (line_buffer[0]!=0) )
        {
        data=line_buffer[0];
        proper_input_given=TRUE;
        type=99;
        }

      if( (type==CHARNUM) && (line_buffer[0]!=0) )
        {
        proper_input_given=TRUE;
	data=line_buffer[0];

        type=99;
        }

      if( (type==NUMCHAR) && (line_buffer[0]!=0) )
        {
        proper_input_given=TRUE;
        data=line_buffer[0];

        type=99;
        }

      if( (type==NUM) && (line_buffer[0]!=0) )
        {
        proper_input_given=TRUE;

        /* Convert line_buffer to an unsigned integer in data */
        data=0;
        index=strlen(line_buffer)-1;
        multiplier=1;
        do
          {
          data=data+((line_buffer[index]-48)*multiplier);
          index--;
          multiplier=multiplier*10;
          }while(index>=0);

        /* Make sure that data is <= max_range */
        if(data>data_max_range)
          {
          data=0;
          proper_input_given=FALSE;

	  cprintAt(4,22,catgets(cat,4,6,"Requested partition size exceeds the maximum available space"));

	  /* Set input=0xff to avoid processing this time around */
          input='\xff';
          }
        else type=99;
        }

      if( (type==NUMP) && (line_buffer[0]!=0) )
        {
        proper_input_given=TRUE;

        /* Convert line_buffer to an unsigned integer in data */
        data=0;
        index=strlen(line_buffer)-1;

        if(percent_entered==TRUE) index--;

        multiplier=1;
        do
          {
          data=data+((line_buffer[index]-48)*multiplier);
          index--;
          multiplier=multiplier*10;
          }while(index>=0);


        if(percent_entered==TRUE) data=(data*data_max_range)/maximum_possible_percentage;

        /* Make sure that data is <= max_range */
        if(data>data_max_range)
          {
	  data=0;
          proper_input_given=FALSE;

	  cprintAt(4,22,catgets(cat,4,6,"Requested partition size exceeds the maximum available space"));

	  /* Set input=0xff to avoid processing this time around */
          input='\xff';
          }
        else type=99;
        }

#ifdef DEBUG
      if( (debug.input_routine==TRUE) && (type==99) )
        {
        Clear_Screen(NULL);

        printf("Input entered by user:  %d",data);
        Pause();
        }
#endif
      }

#ifdef DEBUG
    if(debug.input_routine==TRUE)
      {
      printAt(50,22,"                  ");

      printAt(50,22,"Input:  %d",input);
      }
#endif

    /* Process the backspace key if type==CHARNUM. */
    if( (type==CHARNUM) && (input==8) )
      {
      type=NUM;

      input='\xff';
      line_buffer[0]='0';
      line_buffer_index=1;

      Position_Cursor((x_position+1),y_position);
      cprintf("%c",line_buffer[0]);
      }

    /* Process a legitimate entry if type==CHARNUM. */
    if( (type==CHARNUM) && ( ((input-48)>=1) && ((input-48)<=max_range) ) )
      {
      type=NUM;

      line_buffer[0]='0';
      line_buffer_index=1;
      }

    if( (type==CHARNUM)
     && ( (input==optional_char_1[0])
     || ( (input-32)==optional_char_1[0])
     || (input==optional_char_2[0])
     || ( (input-32)==optional_char_2[0]) ) )
      {
      if(input>=97) input=input-32;

      line_buffer_index=1;
      line_buffer[0]=input;
      input='\xff';
      type=CHARNUM;

      Position_Cursor((x_position+1),y_position);
      cprintf("%c",line_buffer[0]);
      }

    /* Process a legitimate entry if type==NUMYN. */
    if( (type==NUMYN) && ( (input=='Y') || (input=='N') || (input=='y')
     || (input=='n') ) )
      {
      type=YN;

      line_buffer[0]=' ';
      line_buffer_index=1;
      }

    /* Process a legitimate entry if type==NUMCHAR. */
    if( (type==NUMCHAR) && (optional_char_1[0]!=NULL)
     && (optional_char_2[0]!=NULL) )
      {
      char_max_range=atoi(optional_char_2);

      if( (input>='1') && (input<=(char_max_range+48)) )
        {
        line_buffer_index=1;
        line_buffer[0]=input;
        type=NUMCHAR;

        Position_Cursor((x_position+1),y_position);
        cprintf("%c",line_buffer[0]);
        }

      if( (input<'1') || (input>(char_max_range+48)) )
        {
        line_buffer_index=0;
        line_buffer[0]=0;
        type=CHAR;
        }
      }

    /* Process optional character fields. */
    if( (type==NUM) && ( (optional_char_1[0]!=NULL)
     || (optional_char_2[0]!=NULL) ) )
      {
      if( (input==optional_char_1[0]) || ( (input-32)==optional_char_1[0]) )
        {
	if(input>=97) input=input-32;

        line_buffer_index=1;
        line_buffer[0]=input;
        input='\xff';
        type=CHARNUM;

        Position_Cursor((x_position+1),y_position);
        cprintf("%c",line_buffer[0]);
        }

      if( (input==optional_char_2[0]) || ( (input-32)==optional_char_2[0]) )
        {
        if(input>=97) input=input-32;

        line_buffer_index=1;
        line_buffer[0]=input;
        input='\xff';
        type=CHARNUM;

        Position_Cursor((x_position+1),y_position);
        cprintf("%c",line_buffer[0]);
        }
      }

    if( (type==CHAR) && (optional_char_1[0]!=NULL)
     && (optional_char_2[0]!=NULL) )
      {
      char_max_range=atoi(optional_char_2);

      if( (input>='1') && (input<=(char_max_range+48)) )
        {
        line_buffer_index=1;
        line_buffer[0]=input;
        type=NUMCHAR;

        Position_Cursor((x_position+1),y_position);
        cprintf("%c",line_buffer[0]);
        }
      }

    if( ( (type==YN) || (type==NUMYN) ) && (optional_char_1[0]!=NULL)
     && (optional_char_2[0]!=NULL) )
      {
      char_max_range=atoi(optional_char_2);

      if( (input>='1') && (input<=(char_max_range+48)) )
        {
        line_buffer_index=1;
        line_buffer[0]=input;
        type=NUMYN;

        Position_Cursor((x_position+1),y_position);
        cprintf("%c",line_buffer[0]);
        }
      }

    if(type==CHAR)
      {
      /* Convert to upper case, if necessary. */
      if(input>=97) input=input-32;

      if( (input>=min_range) && (input<=max_range) )
        {
        line_buffer[0]=input;
        data=input;
        }
      else
        {
        proper_input_given=FALSE;
	line_buffer[0]=' ';
        data=99;

        Position_Cursor(4,23);
        cprintf("Invalid entry, please enter %c-",min_range);
        cprintf("%c.",max_range);
        }

      Position_Cursor((x_position+1),y_position);
      cprintf("%c",line_buffer[0]);
      }

    /* Process the backspace key if type==NUMCHAR. */
    if( (type==NUMCHAR) && (input==8) )
      {
      type=CHAR;

      line_buffer[0]=' ';
      line_buffer_index=1;

      Position_Cursor((x_position+1),y_position);
      cprintf("%c",line_buffer[0]);
      }

    if(type==YN)
      {
      switch (input) {
	case 'Y':
	  line_buffer[0]='Y';
	  data=TRUE;
	  break;
	case 'y':
	  line_buffer[0]='Y';
	  data=TRUE;
	  break;
	case 'N':
	  line_buffer[0]='N';
	  data=FALSE;
	  break;
	case 'n':
	  line_buffer[0]='N';
	  data=FALSE;
	  break;
	default:
	  proper_input_given=FALSE;
	  line_buffer[0]=' ';
	  data=99;

	  cprintAt(4,23,catgets(cat,4,7,"Invalid entry, please enter Y-N."));

	}

      Position_Cursor((x_position+1),y_position);
      cprintf("%c",line_buffer[0]);
      }

    /* Process the backspace key if type==NUMYN. */
    if( (type==NUMYN) && (input==8) )
      {
      type=YN;
      line_buffer[0]=' ';
      line_buffer_index=1;

      Position_Cursor((x_position+1),y_position);
      cprintf("%c",line_buffer[0]);
      }

    if( (type==NUM) && (input!='\xff') )
      {
      /* If the backspace key has not been hit. */
      if(input!=8)
        {
	invalid_input=FALSE;

        if(size_of_field>1)
	  {
	  min_range=0;
	  max_range=9;
	  }

	if( (input>='0') && (input<='9') )input=input-48;
	else
	  {
	  if(input<10) input=11;
	  }

	if( ( (size_of_field>1) && (input>max_range) ) || (input>9) )
	  {
	  proper_input_given=FALSE;

	  cprintAt(4,23,"Invalid entry, please enter %d-%d.",min_range,max_range);
	  invalid_input=TRUE;
	  }

	if( (size_of_field==1) && ( (input<min_range) || ( (input>max_range) && (input<10) ) ) )
	  {
	  proper_input_given=FALSE;

	  cprintAt(4,23,"%d is not a choice, please enter ",input);
	  cprintf("%d-%d.",min_range,max_range);
	  invalid_input=TRUE;
	  }

	if( (invalid_input==FALSE) && (line_buffer_index==size_of_field) && (size_of_field>1) )
	  {
	  proper_input_given=FALSE;

	  cprintAt(4,23,catgets(cat,4,8,"Invalid entry."));
	  invalid_input=TRUE;
          }

	if( (invalid_input==FALSE) && (line_buffer_index==size_of_field) && (size_of_field==1) )
	  {
	  line_buffer_index=0;
	  }

	if(invalid_input==FALSE)
	  {
	  if( (line_buffer_index==1) && (line_buffer[0]=='0') )
	    {
	    line_buffer[0]=0;
	    line_buffer_index=0;
	    }

	  line_buffer[line_buffer_index]=(input+48);
	  line_buffer_index++;
	  }
	}
      else
	{
	/* If the backspace key has been hit */
	line_buffer_index--;
	if(line_buffer_index<0) line_buffer_index=0;
	line_buffer[line_buffer_index]=0;

	if(line_buffer_index==0)
	  {
	  line_buffer[0]='0';
	  line_buffer_index=1;
	  }
	}

      /* Clear text box before displaying line_buffer */
      index=0;
      do
	{
	Position_Cursor((x_position+1+index),y_position);
	printf(" ");

	index++;
	}while(index<size_of_field);

      /* Display line_buffer */
      index=line_buffer_index;
      do
	{
	Position_Cursor((x_position+size_of_field-line_buffer_index+index),y_position);
	index--;
	cprintf("%c",line_buffer[index]);
	}while(index>0);
      }

    if( (type==NUMP) && (input!='\xff') )
      {
      /* If the backspace key has not been hit. */
      if(input!=8)
	{
	invalid_input=FALSE;

	if(size_of_field>1)
	  {
	  min_range=0;
	  max_range=9;
	  }

	if( (input=='%') && (percent_entered==FALSE) )
	  {
	  percent_entered=TRUE;
	  percent_just_entered=TRUE;
	  }

	if( (input>='0') && (input<='9') )input=input-48;
	else
	  {
	  if(input<10) input=11;
	  }

	if( (percent_entered==FALSE) && (percent_just_entered==FALSE) && ( ( (size_of_field>1) && (input>max_range) ) || (input>9) ) )
	  {
	  proper_input_given=FALSE;

	  cprintAt(4,23,"Invalid entry, please enter %d-%d.",min_range,max_range);
	  invalid_input=TRUE;
	  }

	if( (percent_entered==FALSE) && (size_of_field==1) && ( (input<min_range) || ( (input>max_range) && (input<10) ) ) )
	  {
	  proper_input_given=FALSE;

	  cprintAt(4,23,"%d is not a choice, please enter ",input);
	  cprintf("%d-%d.",min_range,max_range);
	  invalid_input=TRUE;
	  }

	if( ( (percent_entered==TRUE) && (percent_just_entered==FALSE) ) || ( (invalid_input==FALSE) && (line_buffer_index==size_of_field) && (size_of_field>1) ) )
	  {
	  proper_input_given=FALSE;

	  cprintAt(4,23,catgets(cat,4,8,"Invalid entry."));
          invalid_input=TRUE;
	  }

        if( (invalid_input==FALSE) && (line_buffer_index==size_of_field) && (size_of_field==1) )
          {
          line_buffer_index=0;
          }

        if(invalid_input==FALSE)
          {
          if( (line_buffer_index==1) && (line_buffer[0]=='0') )
            {
            line_buffer[0]=0;
            line_buffer_index=0;
            }

          if(percent_just_entered==TRUE)
            {
            percent_just_entered=FALSE;
            line_buffer[line_buffer_index]='%';
            line_buffer_index++;
            }
          else
            {
            line_buffer[line_buffer_index]=(input+48);
            line_buffer_index++;
            }
          }
        }
      else
        {
	/* If the backspace key has been hit */
        line_buffer_index--;
        if(line_buffer_index<0) line_buffer_index=0;
        line_buffer[line_buffer_index]=0;

	if(line_buffer_index==0)
          {
          line_buffer[0]='0';
          line_buffer_index=1;
          }

        if(percent_entered==TRUE) percent_entered=FALSE;
        }

      /* Clear text box before displaying line_buffer */
      index=0;
      do
        {
        Position_Cursor((x_position+1+index),y_position);
        printf(" ");

        index++;
        }while(index<size_of_field);

      /* Display line_buffer */
      index=line_buffer_index;
      do
        {
        Position_Cursor((x_position+size_of_field-line_buffer_index+index),y_position);
        index--;
        cprintf("%c",line_buffer[index]);
        }while(index>0);
      }

#ifdef DEBUG
    if(debug.input_routine==TRUE)
      {
      printAt(60,23,"                ");

      printAt(60,24,"                ");

      printAt(50,23,"Line Buffer:  %10s",line_buffer);

      printAt(50,24,"Line Buffer Index:  %d",line_buffer_index);

      if(percent_entered==TRUE)
        {
        printAt(75,24,"P");
        }
      else
        {
        printAt(75,24,"  ");
        }
      }
#endif

    /* Place brackets back on screen as a precautionary measure. */
    if(type!=ESC)
      {
      Position_Cursor(x_position,y_position);
      cprintf("[");

      Position_Cursor((x_position+size_of_field+1),y_position);
      cprintf("]");
      }

    }while(proper_input_given==FALSE);

  return(data);
}
Exemple #21
0
// print the current state on the last line of the lcd
void LcdDisplay::printState(void) {
    uint16_t time = UINT16_MAX; // init to max
    uint8_t state = tempControl.getDisplayState();
    if(state != stateOnDisplay) { //only print static text when state has changed
        stateOnDisplay = state;
        // Reprint state and clear rest of the line
        const char * part1 = STR_empty_string;
        const char * part2 = STR_empty_string;
        switch (state) {
        case IDLE:
            part1 = PSTR("Idl");
            part2 = STR_ing_for;
            break;
        case WAITING_TO_COOL:
            part1 = STR_Wait_to_;
            part2 = STR_Cool;
            break;
        case WAITING_TO_HEAT:
            part1 = STR_Wait_to_;
            part2 = STR_Heat;
            break;
        case WAITING_FOR_PEAK_DETECT:
            part1 = PSTR("Waiting for peak");
            break;
        case COOLING:
            part1 = STR_Cool;
            part2 = STR_ing_for;
            break;
        case HEATING:
            part1 = STR_Heat;
            part2 = STR_ing_for;
            break;
        case COOLING_MIN_TIME:
            part1 = STR_Cool;
            part2 = STR__time_left;
            break;
        case HEATING_MIN_TIME:
            part1 = STR_Heat;
            part2 = STR__time_left;
            break;
        case DOOR_OPEN:
            part1 = PSTR("Door open");
            break;
        case STATE_OFF:
            part1 = PSTR("Temp. control OFF");
            break;
        default:
            part1 = PSTR("Unknown status!");
            break;
        }
        printAt_P(0, 3, part1);
        lcd.print_P(part2);
        lcd.printSpacesToRestOfLine();
    }
    uint16_t sinceIdleTime = tempControl.timeSinceIdle();
    if(state==IDLE) {
        time = 	min(tempControl.timeSinceCooling(), tempControl.timeSinceHeating());
    }
    else if(state==COOLING || state==HEATING) {
        time = sinceIdleTime;
    }
    else if(state==COOLING_MIN_TIME) {
        time = MIN_COOL_ON_TIME-sinceIdleTime;
    }

    else if(state==HEATING_MIN_TIME) {
        time = MIN_HEAT_ON_TIME-sinceIdleTime;
    }
    else if(state == WAITING_TO_COOL || state == WAITING_TO_HEAT) {
        time = tempControl.getWaitTime();
    }
    if(time != UINT_MAX) {
        char timeString[10];
#if DISPLAY_TIME_HMS  // 96 bytes more space required. 
        unsigned int minutes = time/60;
        unsigned int hours = minutes/60;
        int stringLength = sprintf_P(timeString, PSTR("%dh%02dm%02d"), hours, minutes%60, time%60);
        char * printString = timeString;
        if(!hours) {
            printString = &timeString[2];
            stringLength = stringLength-2;
        }
        printAt(20-stringLength, 3, printString);
#else
        int stringLength = sprintf_P(timeString, STR_FMT_U, (unsigned int)time);
        printAt(20-stringLength, 3, timeString);
#endif
    }
}
Exemple #22
0
void me(string args)
{
    if (!hasSetup)
    {
        if (streql(splitArg(args, 1), "-H"))
        {
            // a super legit help section brought to you by @plankp
            print("\nMe is here to help you... Believe me...", brown);
        }
        else if (streql(splitArg(args, 1), "TEST") && !hasSetup)
        {
            hasSetup = true;
            messageBox("\nYou have skipped the Me setup process.");
        }
        else if (!hasSetup)
        {
            meHeader();

            messageBox("\nWelcome to Me. To start using Me,\n\rpress <RET> to setup Me.");

            meHeader();

            name = messageBox_I("What is your name?");

            meHeader();

            while (!birthYearValid)
            {
                birthYear = messageBox_I("What year were you born in?");
                birthYearInt = stoi(birthYear);

                // need to make this always the current year + 1
                if (birthYearInt < getTime("year") && birthYearInt > 1900)
                {
                    birthYearValid = true;
                    goodAnswer();
                }

                if (!birthYearValid)
                {
                    badAnswer();
                }
            }

            meHeader();

            while (!birthDateValid)
            {
                newline();
                birthDate = messageBox_I("What day were you born on");
                birthDateInt = stoi(birthDate);

                if (birthDateInt < 32)
                {
                    birthDateValid = true;
                    goodAnswer();
                }

                if (!birthDateValid)
                {
                    badAnswer();
                }
            }

            meHeader();

            while (!birthMonthValid)
            {
                newline();
                birthMonth = messageBox_I("What month were you born in?");
                birthMonth = toUpper(birthMonth);

                if (findInDictionary("me/setup/month.text",birthMonth))
                {
                    birthMonthValid = true;
                    goodAnswer();
                }

                if (!birthMonthValid)
                {
                    badAnswer();
                }
            }

            meHeader();

            while (!continentValid)
            {

                newline();
                continent = messageBox_I("What continent do you live in?");
                continent = toUpper(continent);

                if (findInDictionary("me/setup/continent.text",continent))
                {
                    continentValid = true;
                    goodAnswer();
                }

                if (!continentValid)
                {
                    badAnswer();
                }
            }

            meHeader();

            while (!countryValid)
            {
                newline();
                country = messageBox_I("What country do you live in?");
                country = toUpper(country);

                if (findInDictionary("me/setup/country.text",country))
                {
                    countryValid = true;
                    goodAnswer();
                }

                if (!countryValid)
                {
                    badAnswer();
                }
            }

            meHeader();

            while (!stateValid)
            {
                newline();
                state = messageBox_I("What state/province do you live in?");
                state = toUpper(state);

                if (findInDictionary("me/setup/state.text",state))
                {
                    stateValid = true;
                    goodAnswer();
                }

                if (!stateValid)
                {
                    badAnswer();
                }
            }

            meHeader();

            newline();
            city = messageBox_I("What city/town do you live in?");

            clearLine(0,26,0x88);

            drawFrame(header_background, 20, 8, 60, 11);
            printAt("Me Setup Process", 0x3D, 21, 9);

            while (!zipValid)
            {
                newline();
                zip = messageBox_I("What is your zip/post code?");
                zipInt = htoi(zip);
                if (zipInt > 0)
                {
                    zipValid = true;
                    goodAnswer();
                }
                else
                {
                    badAnswer();
                }
            }

            meHeader();

            hasSetup = "true";
            messageBox("Me is now ready to use! Type 'me' on\n\rthe command line to begin.");

            printIntro();
            drawBorder(screen_background, 0, 4, 80, sh - 1);

            actualY = 5;
            printAt("Q-Kernel>  ", light_grey, 1, actualY);
        }
        else
        {
            print("\nYou have already completed the setup process for Me!",purple);
        }
    }
    else if (streql(splitArg(args, 1),""))
    {
        querying = true;
        string meArgs = NULL;

        while (querying)
        {
            newline();

            //meArgs = "";
            print("me>  ",green);
            meArgs = readstr();

            print(answer(meArgs,0),red);
        }
    }
    else
    {
        answer(args,1);
    }
}
Exemple #23
0
// this is shown when someone enters an invalid answer during the 'me' setup
void badAnswer()
{
    drawFrame(header_background, 20, 8, 60, 11);
    printAt("Invalid", 0x34, 21, 9);
}
Exemple #24
0
// we show this is a correct answer is given during the 'me' setup
void goodAnswer()
{
    drawFrame(header_background, 20, 8, 60, 11);
    printAt("Good", 0x32, 21, 9);
}
string initWriter()
{
	string vidmem = (string) 0xb8000;
    char oldmem[strlen(vidmem)];
    strcpy(oldmem, vidmem);

	paintScreen(screen_color);

	drawFrame(header_background, 0, 0, 80, 4);
	printAt("Q OS Text Editor\r\n", header_foreground, 1, 1);
	printAt("Simple Text Editor built for Q OS by Raph Hennessy & Plankp T",desc_foreground,1,2);

	drawBorder(screen_background, 0, 4, 80, sh - 1);

	cursorY = 5;
	cursorX = 1;
	updateCursor();

    bool inCmdMode = true;
    uint16 curX = 1, curY = 5;
    uint32 index = 0;
    strbuilder_t data = strbuilder_init();
    int k;
    while(true)
    {
        cursorX = curX % sw;
        cursorY = curY;
        updateCursor();

        cursorBoundsCheck(&curX, &curY, &index);
        printStatus(curX, curY, inCmdMode);

        if(inCmdMode)
        {
            k = waitUntilKey(7, 0x10 /*Q*/, 0x17 /*I*/, 0x18 /*O*/, 0x3A /*<CAPS>*/, 0x23 /*H*/, 0x26 /*L*/, 0x2D /*X*/);
            switch(k)
            {
            case 0x10:
                goto end;
            case 0x17:
                inCmdMode = false;
                break;
            case 0x18:
                appendln(&data, &curX, &curY, &index);
                inCmdMode = false;
                break;
            case 0x23:
                moveCursorLeft(&curX, &curY, &index);
                break;
            case 0x26:
                moveCursorRight(&curX, &curY, &index);
                break;
            case 0x2D:
                deleteCharAt(&curX, &curY, &index, &data);
                break;
            }
        } else {
            k = getKeycode() / KC_MAGIC_VAL;
            char charInput = ' ';
            switch(k)
            {
            case 0x01:
                inCmdMode = true;
                break;
            case 0x1C:
				cursorBoundsCheck(&curX, &curY, &index);
                appendln(&data, &curX, &curY, &index);
                break;
            case 0x48:
                curY--;
                curX = 1;
				cursorBoundsCheck(&curX, &curY, &index);
                break;
            case 0x4B:
                moveCursorLeft(&curX, &curY, &index);
                break;
            case 0x4D:
                moveCursorRight(&curX, &curY, &index);
                break;
            case 0x50:
                curY++;
                curX = 1;
                cursorBoundsCheck(&curX, &curY, &index);
                break;
            case 0x0E:
                deleteCharAt(&curX, &curY, &index, &data);
                break;
            default:
                if(k < 59 && k > 0)
                {
                    charInput = retCorrespChar(kbShiftChars[k], kbLowerChars[k]);
                    if(charInput == 0)
                    {
                        break;
                    }
                    insertCharAt(&curX, &curY, &index, &data, charInput);
                }
                break;
            }
        }
    }
end: // Sorry for the mom spaghetti code
    // Must be last line (before any prints)
	strcpy(vidmem, oldmem);
    string msg = strbuilder_tostr(data);
    if(msg == NULL)
    {
        msg = "";
    }
    strbuilder_destroy(&data);
    cursorX = 1;
	cursorY = 5;
    print(msg, black);
    return msg;
}
void sidebarDisplay(void)
{
  int line = 1;
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glLoadIdentity();

  sidebarRow(80, windowHeight-DEF_TEXT_Y_OFFSET*line, -1, "3Defense");
  printAt(10, windowHeight-DEF_TEXT_Y_OFFSET*++line, "WAVE: %d out of %d", waveNumber, lastWave);
  printAt(10, windowHeight-DEF_TEXT_Y_OFFSET*++line, "SCORE: %d", score);
  printAt(10, windowHeight-DEF_TEXT_Y_OFFSET*++line, "LIVES: %d", lives);
  printAt(10, windowHeight-DEF_TEXT_Y_OFFSET*++line, "MONEY: %d", money);
  printAt(10, windowHeight-DEF_TEXT_Y_OFFSET*++line, "SCROLLS: %d", scrolls);

  setFont("helvetica",12);
  sidebarRow(5, windowHeight-DEF_TEXT_Y_OFFSET*++line, -1, "Select a tower to build:");
  setFont("helvetica",18);
  sidebarRow(10, windowHeight-DEF_TEXT_Y_OFFSET*++line, DEF_OBJ_SEL, "[0] none");
  sidebarRow(10, windowHeight-DEF_TEXT_Y_OFFSET*++line, OBJ_BASIC, "[1] basic");
  sidebarRow(10, windowHeight-DEF_TEXT_Y_OFFSET*++line, OBJ_ADV, "[2] advanced");
  sidebarRow(10, windowHeight-DEF_TEXT_Y_OFFSET*++line, OBJ_CONE, "[3] cone");
  sidebarRow(10, windowHeight-DEF_TEXT_Y_OFFSET*++line, OBJ_ADV_CONE, "[4] advanced cone");
  sidebarRow(10, windowHeight-DEF_TEXT_Y_OFFSET*++line, OBJ_SQUARE, "[5] square");
  sidebarRow(10, windowHeight-DEF_TEXT_Y_OFFSET*++line, OBJ_ADV_SQUARE, "[6] advanced square");
  sidebarRow(10, windowHeight-DEF_TEXT_Y_OFFSET*++line, OBJ_FIRE, "[SHIFT+1] fire");
  sidebarRow(10, windowHeight-DEF_TEXT_Y_OFFSET*++line, OBJ_FIRE2, "[SHIFT+2] advanced fire");
  sidebarRow(10, windowHeight-DEF_TEXT_Y_OFFSET*++line, OBJ_ICE, "[SHIFT+3] ice");
  sidebarRow(10, windowHeight-DEF_TEXT_Y_OFFSET*++line, OBJ_ICE2, "[SHIFT+4] advanced ice");
  sidebarRow(10, windowHeight-DEF_TEXT_Y_OFFSET*++line, OBJ_EARTH, "[SHIFT+5] earth");
  sidebarRow(10, windowHeight-DEF_TEXT_Y_OFFSET*++line, OBJ_EARTH2, "[SHIFT+6] advanced earth");
  sidebarRow(10, windowHeight-DEF_TEXT_Y_OFFSET*++line, OBJ_POISON, "[SHIFT+7] poison");
  sidebarRow(10, windowHeight-DEF_TEXT_Y_OFFSET*++line, OBJ_POISON2, "[SHIFT+8] advanced poison");

  ++line;
  setFont("helvetica",12);
  glColor3fv(white);
  printAt(5, windowHeight-DEF_TEXT_Y_OFFSET*++line, "INFO");
  printAt(5, windowHeight-DEF_TEXT_Y_OFFSET*++line, "%s",info);
  printAt(5, windowHeight-DEF_TEXT_Y_OFFSET*++line, "TOWER INFO");
  if (objectSelected != DEF_OBJ_SEL || objectPicked != DEF_OBJ_PICKED) {
    printAt(5, windowHeight-DEF_TEXT_Y_OFFSET*++line, "Name: %s", currentTowerName);
    printAt(5, windowHeight-DEF_TEXT_Y_OFFSET*++line, "Cost: %d", currentTowerCost);
    printAt(5, windowHeight-DEF_TEXT_Y_OFFSET*++line, "Damage: %d", currentTowerDamage);
    printAt(5, windowHeight-DEF_TEXT_Y_OFFSET*++line, "Range: %d", currentTowerRange);
    printAt(5, windowHeight-DEF_TEXT_Y_OFFSET*++line, "Fire Rate: %d", currentTowerFireRate);
    printAt(5, windowHeight-DEF_TEXT_Y_OFFSET*++line, "Description:");
    printAt(5, windowHeight-DEF_TEXT_Y_OFFSET*++line, "   %s", currentTowerDescription);
  }
  if (debug) printAt(5, windowHeight-DEF_TEXT_Y_OFFSET*++line, "Object Picked: %d", objectPicked);
  setFont("helvetica",18);

  glFlush();
  glutSwapBuffers();
}
void painterIntro()
{
    drawFrame(header_background, 0, 0, 80, 4);
    printAt("Q OS Drawing Application\r\n", header_foreground, 1, 1);
    printAt("Dumb Drawing App for Q OS by Raph Hennessy",desc_foreground,1,2);
}
Exemple #28
0
void parseCommand(char *command, int *trainSpeeds, int *train) {
  char *argv[MAX_ARGS];
  int argc = formatArgs(command, argv);

  if(strcmp(argv[0], "tr") == 0) {
    if(numArgs(argc, argv) != 2) {
      printColored(RED, BLACK, "Error: command tr expects 2 arguments\r");
    }else{
      int trainNumber = strToInt(getArgument(argc, argv, 0));
      int trainSpeed = strToInt(getArgument(argc, argv, 1));
      if(trainNumber == -1 || trainNumber < 1 || trainNumber > 80) {
	printColored(RED, BLACK, "Error: train number must be a number between 1 and 80\r");
      }else if(trainSpeed == -1 || trainSpeed < 0 || trainSpeed > 14) {
	printColored(RED, BLACK, "Error: train speed must be a number between 0 and 14\r");
      }else {
	Putc2(1, (char)trainSpeed, (char)trainNumber);
	trainSpeeds[trainNumber] = trainSpeed;
      }
    }
  }else if(strcmp(argv[0], "rv") == 0) {
    if(numArgs(argc, argv) != 1) {
      printColored(RED, BLACK, "Error: command rv expects an argument\r");
    }else{
      int trainNumber = strToInt(getArgument(argc, argv, 0));
      if(trainNumber == -1 || trainNumber < 1 || trainNumber > 80) {
	printColored(RED, BLACK, "Error: train number must be a number between 1 and 80\r");
      }else{
	Putc2(1, (char)0, (char)trainNumber);
	int reverseTask = Create(1, reverser);
        int reply;
	struct trainInfo info;
	info.speed = trainSpeeds[trainNumber];
	info.number = trainNumber;
	Send(reverseTask, (char *)&info, sizeof(struct trainInfo), (char *)&reply, sizeof(int));
      }
    }
  }else if(strcmp(argv[0], "sw") == 0) {
    if(numArgs(argc, argv) != 2) {
      printColored(RED, BLACK, "Error: command sw expects two arguments\r");
    }else{
      int switchNumber = strToInt(getArgument(argc, argv, 0));
      if(strcmp(getArgument(argc, argv, 1), "S") == 0) {
        setSwitchState(switchNumber, 'S');
      }else if(strcmp(getArgument(argc, argv, 1), "C") == 0) {
	setSwitchState(switchNumber, 'C');
      }else{
	printColored(RED, BLACK, "Error: switch direction must be 'S' or 'C'\r");
      }
    }
  }else if(strcmp(argv[0], "q") == 0) {
    outputEscape("[2J");
    moveCursor(1,1);
    Shutdown();
  }else if(strcmp(argv[0], "setTrack") == 0) {
    if(numArgs(argc, argv) != 1) {
      printColored(RED, BLACK, "Error: command setTrack expects an argument\r");
    }else{
      if(strcmp(getArgument(argc, argv, 0), "A") == 0) {
	setTrack(TRACKA);
      }else if(strcmp(getArgument(argc, argv, 0), "B") == 0) {
	setTrack(TRACKB);
      }else{
	printColored(RED, BLACK, "Error: track must be A or B\r");
      }
    }
  }else if(strcmp(argv[0], "move") == 0) {
    if(numArgs(argc, argv) != 3) {
      printColored(RED, BLACK, "Error: command move expects two arguments\r");
    }else{
      struct TrainMessage msg;
      int trainNum = strToInt(getArgument(argc, argv, 0));
      msg.type = TRAINGOTO;
      strcpy(msg.dest, getArgument(argc, argv, 1));
      msg.doReverse = getFlag(argc, argv, "r");
      msg.speed = strToInt(getArgument(argc, argv, 2));
      if(train[trainNum] == -1) {
	printColored(RED, BLACK, "Error: train %d has not been initialized\r", trainNum);
      }else{
        int reply;
        Send(train[trainNum], (char *)&msg, sizeof(struct TrainMessage), (char *)&reply, sizeof(int));
      }
    }
  }else if(strcmp(argv[0], "randomizeSwitches") == 0) {
    int i;
    seed(Time());
    for(i=1; i<19; i++) {
      int dir = random() % 2;
      if(dir == 0) {
	setSwitchState(i, 'S');
      }else{
	setSwitchState(i, 'C');
      }
    }
    for(i=153; i<157; i++) {
      int dir = random() % 2;
      if(dir == 0) {
	setSwitchState(i, 'S');
      }else{
	setSwitchState(i, 'C');
      }
    }
  }else if(strcmp(argv[0], "init") == 0) {
    if(numArgs(argc, argv) != 1) {
      printColored(RED, BLACK, "Error: command init expects an argument\r");
    }else{
      struct TrainMessage msg;
      int trainNum = strToInt(getArgument(argc, argv, 0));
      int reply;
      if(train[trainNum] == -1) {
	train[trainNum] = Create(2, trainTask);
	Send(train[trainNum], (char *)&trainNum, sizeof(int), (char *)&reply, sizeof(int));
      }
      msg.type = TRAININIT;
      Send(train[trainNum], (char *)&msg, sizeof(struct TrainMessage), (char *)&reply, sizeof(int));
    }
  }else if(strcmp(argv[0], "d") == 0) {
    track_node track[TRACK_MAX];
    initTrack(track);
    int trainNum = 45;
    int trainSpeed = strToInt(getArgument(argc, argv, 0));
    Putc2(1, (char)trainSpeed, (char)trainNum);
    int sensor, lastSensor = waitOnAnySensor(), lastTime = Time(), time;
    int v = 0;
    while(true) {
      sensor = waitOnAnySensor();
      time = Time();
      if(sensor == 71) break;

      int timeDelta = (time - lastTime);
      int distance = BFS(lastSensor, sensor, track, NULL, false);
      int newVelocity = (500*distance)/timeDelta;
      v *= 95;
      v += newVelocity;
      v /= 100;
      lastTime = time;
      lastSensor = sensor;
      printAt(9, 1, "Velocity: %dmm/s\r", v);
    }
    Putc2(1, (char)0, (char)trainNum);
  }else if(strcmp(argv[0], "a") == 0) {
    track_node track[TRACK_MAX];
    initTrack(track);
    int trainNum = 45;
    int trainSpeed = strToInt(getArgument(argc, argv, 2));
    int source = 0, dest = 0;
    int velocity[15];
    initVelocities(trainNum, velocity);
    while(source < TRACK_MAX && strcmp(track[source].name, getArgument(argc, argv, 0)) != 0) source++;
    while(dest < TRACK_MAX && strcmp(track[dest].name, getArgument(argc, argv, 1)) != 0) dest++;

    int distance = BFS(source, dest, track, NULL, false);

    Putc2(1, (char)trainSpeed, (char)trainNum);
    int t0 = Time();
    printf("Time 0: %d\r", t0);
    waitOnSensor(dest);
    int t2 = Time();
    Putc2(1, (char)0, (char)trainNum);
    printf("Time 2: %d\r", t2);

    int t1 = -(200*distance)/velocity[trainSpeed];
    t1 -= t0;
    t1 += 2*t2;
    printf("Time 1: %d\r", t1);
    printf("Accelerating to speed %d takes %d ticks\r", trainSpeed, t1-t0);
  }else if(strcmp(argv[0], "clear") == 0) {
    moveCursor(13, 1);
    outputEscape("[J");
  }else if(strcmp(argv[0], "configureVelocities") == 0) {
    struct TrainMessage msg;
    msg.type = TRAINCONFIGVELOCITY;
    if(argc != 2) {
      printColored(RED, BLACK, "Command configureVelocities expects an argument\r");
    }else{
      int trainNum = strToInt(getArgument(argc, argv, 0));
      int reply;
      if(train[trainNum] == -1) {
	train[trainNum] = Create(2, trainTask);
	Send(train[trainNum], (char *)&trainNum, sizeof(int), (char *)&reply, sizeof(int));
      }
      Send(train[trainNum], (char *)&msg, sizeof(struct TrainMessage), (char *)&reply, sizeof(int));
    }
  }else{
    printColored(RED, BLACK, "Unrecognized command: \"%s\"\r", command);
  }
}
Exemple #29
0
main()
{
    int f, g, a, b, c;

    zx_border(0);
    zx_cls(0);
    printPaper(0);
    printInk(6);
    printAt(4, 22);
    printf("BIFROST*");
    printAt(5, 23);
    printf("ENGINE");
    printAt(6, 24);
    printf("DEMO");
    printInk(4);
    printAt(10, 24);
    printf("with");
    printAt(11, 23);
    printf("z88dk!");

    BIFROSTH_resetTileImages(_ctiles);
    
    for (f = 0; f < 81; ++f) {
        BIFROSTH_tilemap[f] = BIFROSTH_STATIC + f;
    }

    BIFROSTH_start();

    while (1) {
        pressAnyKey();

        printInk(5);
        printAt(20, 1);
        printf("Demonstrating static tiles");

        for (f = 0; f < 81; ++f) {
            BIFROSTH_tilemap[f] = BIFROSTH_STATIC + (rand()%26)+8;
        }
        pressAnyKey();

        printInk(5);
        printAt(20, 1);
        printf("Animated tiles (4 frames) ");

        pressSpeedKey();

        printInk(5);
        printAt(20, 17);
        printf("2");

        BIFROSTH_resetAnim2Frames();
        pressSpeedKey();
        BIFROSTH_resetAnim4Frames();

        printInk(5);
        printAt(20, 1);
        printf("Directly modifying areas      ");

        M_BIFROSTH_SETTILE(4, 4, BIFROSTH_DISABLED);
        M_BIFROSTH_SETTILE(4, 5, BIFROSTH_DISABLED);

        printAt(9, 9);
        printf("BIFR");
        printAt(10, 9);
        printf("OST*");

        for (c = 0; c < 8; ++c) {
            a = rand()%8;
            for (b = 0; b < 2; ++b) {
                for (f = 8+72+0; f < 8+72+16; ++f) {
                    for (g = 9; g < 13; ++g) {
                        *BIFROSTH_findAttrH(f, g) = (b == 0 ? a*8 : a);
                        a = (a == 7 ? 3 : a+1);
                    }
                }
            }
        }
    }
}
int painter(string args)
{
    if (streql(splitArg(args, 1), "-H"))
    {
        print("\nPainter is a simple drawing app for Q OS",red);
        print("\nTo use it, type 'painter' on the command line.",red);
        print("\nUse the arrow keys to draw lines on your screen.",red);
        print("\nPress the spacebar to reset your drawing.",red);
        print("\nPress X to change the X location of your pen and Y to change the Y location.",red);
    }
    else
    {
        // Run the setup function for painter
        resetPainter();
        bool isDrawing = true;
#define GET_PAINT_COLOR isDrawing ? 0x00 : screen_color
        // Begin the actual painter program
        while (true)
        {

            if (paintX < 1)
            {
                paintX = 1;
            }
            else if (paintX > 78)
            {
                paintX = 78;
            }

            if (paintY < 5)
            {
                paintY = 5;
            }
            else if (paintY > 23)
            {
                paintY = 23;
            }

            printAt("*",0xDD,paintX,paintY);
            printStatus(isDrawing);

            int key = getKeycode() / KC_MAGIC_VAL;

            switch (key)
            {
            case 1:
                // Escape Pressed
                clearScreen();
                return 0;
            case 72:
                // Up Arrow Pressed
                printAt(" ", GET_PAINT_COLOR, paintX, paintY);
                paintY--;
                break;
            case 80:
                // Down Arrow Pressed
                printAt(" ", GET_PAINT_COLOR, paintX, paintY);
                paintY++;
                break;
            case 75:
                // Left Arrow Pressed
                printAt(" ", GET_PAINT_COLOR, paintX, paintY);
                paintX--;
                break;
            case 77:
                // Right Arrow Pressed
                printAt(" ", GET_PAINT_COLOR, paintX, paintY);
                paintX++;
                break;
            case 57:
                // Spacebar Pressed
                resetPainter();
                break;
            case 0x2E:
                // C pressed
                isDrawing = true;
                break;
            case 0x12:
                // E pressed
                isDrawing = false;
                break;
            case -82:
                // X Released
                printAt(" ",screen_color,paintX,paintY);

                drawFrame(header_background, 0, 0, 80, 4);
                printAt("What X Posiiton do you want to move the pen to?\r\n", header_foreground, 1, 1);

                cursorX = 1;
                cursorY = 2;

                // we need to make the text below when input show in a blue on aqua font...
                paintX = stoi(readstr());

                painterIntro();
                break;
            case -106:
                // Y Pressed
                printAt(" ",screen_color,paintX,paintY);

                drawFrame(header_background, 0, 0, 80, 4);
                printAt("What Y Posiiton do you want to move the pen to?\r\n", header_foreground, 1, 1);

                cursorX = 1;
                cursorY = 2;

                // we need to make the text below when input show in a blue on aqua font...
                paintY = stoi(readstr());

                painterIntro();
                break;
            default:
                break;
            }
        }
    }


    return 0;

}