示例#1
0
int help(int action)
   {
   static FCODE unknowntopic_msg[] = "Unknown Help Topic";
   HIST      curr;
   int       oldlookatmouse;
   int       oldhelpmode;
   int       flags;
   HIST      next;

   if (helpmode == -1)   /* is help disabled? */
      {
      return (0);
      }

   if (help_file == -1)
      {
      buzzer(2);
      return (0);
      }

   buffer = (char far *)farmemalloc((long)MAX_PAGE_SIZE + sizeof(LINK)*max_links +
                        sizeof(PAGE)*max_pages);

   if (buffer == NULL)
      {
      buzzer(2);
      return (0);
      }

   link_table = (LINK far *)(&buffer[MAX_PAGE_SIZE]);
   page_table = (PAGE far *)(&link_table[max_links]);

   oldlookatmouse = lookatmouse;
   lookatmouse = 0;
   timer_start -= clock_ticks();
   stackscreen();

   if (helpmode >= 0)
      {
      next.topic_num = label[helpmode].topic_num;
      next.topic_off = label[helpmode].topic_off;
      }
   else
      {
      next.topic_num = helpmode;
      next.topic_off = 0;
      }

   oldhelpmode = helpmode;

   if (curr_hist <= 0)
      action = ACTION_CALL;  /* make sure it isn't ACTION_PREV! */

   do
      {
      switch(action)
         {
         case ACTION_PREV2:
            if (curr_hist > 0)
               curr = hist[--curr_hist];

            /* fall-through */

         case ACTION_PREV:
            if (curr_hist > 0)
               curr = hist[--curr_hist];
            break;

         case ACTION_QUIT:
            break;

         case ACTION_INDEX:
            next.topic_num = label[HELP_INDEX].topic_num;
            next.topic_off = label[HELP_INDEX].topic_off;

            /* fall-through */

         case ACTION_CALL:
            curr = next;
            curr.link = 0;
            break;
         } /* switch */

      flags = 0;
      if (curr.topic_num == label[HELP_INDEX].topic_num)
         flags |= F_INDEX;
      if (curr_hist > 0)
         flags |= F_HIST;

      if ( curr.topic_num >= 0 )
         action = help_topic(&curr, &next, flags);
      else
         {
         if ( curr.topic_num == -100 )
            {
            print_document("FRACTINT.DOC", print_doc_msg_func, 1);
            action = ACTION_PREV2;
            }

         else if ( curr.topic_num == -101 )
            action = ACTION_PREV2;

         else
            {
            display_page(unknowntopic_msg, NULL, 0, 0, 1, 0, NULL, NULL);
            action = -1;
            while (action == -1)
               {
               switch (getakey())
                  {
                  case ESC:      action = ACTION_QUIT;  break;
                  case ALT_F1:   action = ACTION_PREV;  break;
                  case F1:       action = ACTION_INDEX; break;
                  } /* switch */
               } /* while */
            }
         } /* else */

      if ( action != ACTION_PREV && action != ACTION_PREV2 )
         {
         if (curr_hist >= MAX_HIST)
            {
            int ctr;

            for (ctr=0; ctr<MAX_HIST-1; ctr++)
               hist[ctr] = hist[ctr+1];

            curr_hist = MAX_HIST-1;
            }
         hist[curr_hist++] = curr;
         }
      }
   while (action != ACTION_QUIT);

   farmemfree((BYTE far *)buffer);

   unstackscreen();
   lookatmouse = oldlookatmouse;
   helpmode = oldhelpmode;
   timer_start += clock_ticks();

   return(0);
   }
示例#2
0
void intro()
{
    // following overlayed data safe if "putstrings" are resident
#ifdef XFRACT
    static char PRESS_ENTER[] = {"Press ENTER for main menu, Shift-1 for help."};
#else
    static char PRESS_ENTER[] = {"Press ENTER for main menu, F1 for help."};
#endif
    int       toprow, botrow, delaymax;
    char      oldchar;
    std::vector<int> authors;
    char credits[32768] = { 0 };
    char screen_text[32768];
    int       oldlookatmouse;
    int       oldhelpmode;

    timer_start -= clock_ticks();       // "time out" during help
    oldlookatmouse = lookatmouse;
    oldhelpmode = helpmode;
    lookatmouse = 0;                    // de-activate full mouse checking

    int i = 32767 + read_help_topic(INTRO_AUTHORS, 0, 32767, screen_text);
    screen_text[i++] = '\0';
    i = 32767 + read_help_topic(INTRO_CREDITS, 0, 32767, credits);
    credits[i++] = '\0';

    int j = 0;
    authors.push_back(0);               // find the start of each credit-line
    for (i = 0; credits[i] != 0; i++)
        if (credits[i] == 10)
            authors.push_back(i+1);
    authors.push_back(i);

    helptitle();
#define END_MAIN_AUTHOR 5
    toprow = END_MAIN_AUTHOR+1;
#ifndef XFRACT
    botrow = 21;
#else
    botrow = 20;
    putstringcenter(21, 0, 80, C_TITLE,
                    "Unix/X port of fractint by Ken Shirriff");
#endif
    putstringcenter(1, 0, 80, C_TITLE, PRESS_ENTER);
    driver_put_string(2, 0, C_CONTRIB, screen_text);
    driver_set_attr(2, 0, C_AUTHDIV1, 80);
    driver_set_attr(END_MAIN_AUTHOR, 0, C_AUTHDIV1, 80);
    driver_set_attr(22, 0, C_AUTHDIV2, 80);
    driver_set_attr(3, 0, C_PRIMARY, 80*(END_MAIN_AUTHOR-3));
    driver_set_attr(23, 0, C_TITLE_LOW, 160);
    for (int i = 3; i < END_MAIN_AUTHOR; ++i)
        driver_set_attr(i, 21, C_CONTRIB, 58);
    driver_set_attr(toprow, 0, C_CONTRIB, (21-END_MAIN_AUTHOR)*80);
    srand((unsigned int)clock_ticks());
    j = rand()%(j-(botrow-toprow)); // first to use
    i = j+botrow-toprow; // last to use
    oldchar = credits[authors.at(i+1)];
    credits[authors.at(i+1)] = 0;
    driver_put_string(toprow, 0, C_CONTRIB, credits+authors.at(j));
    credits[authors.at(i+1)] = oldchar;
    delaymax = 10;
    driver_hide_text_cursor();
    helpmode = HELPMENU;
    while (! driver_key_pressed())
    {
#ifdef XFRACT
        if (slowdisplay)
            delaymax *= 15;
#endif
        for (j = 0; j < delaymax && !(driver_key_pressed()); j++)
            driver_delay(100);
        if (driver_key_pressed() == FIK_SPACE)
        {   // spacebar pauses
            driver_get_key();
            driver_wait_key_pressed(0);
            if (driver_key_pressed() == FIK_SPACE)
                driver_get_key();
        }
        delaymax = 15;
        driver_scroll_up(toprow, botrow);
        i++;
        if (credits[authors.at(i)] == 0)
            i = 0;
        oldchar = credits[authors.at(i+1)];
        credits[authors.at(i+1)] = 0;
        driver_put_string(botrow, 0, C_CONTRIB, &credits[authors.at(i)]);
        driver_set_attr(botrow, 0, C_CONTRIB, 80);
        credits[authors.at(i+1)] = oldchar;
        driver_hide_text_cursor(); // turn it off
    }

    lookatmouse = oldlookatmouse;                // restore the mouse-checking
    helpmode = oldhelpmode;
    return;
}
示例#3
0
extern uint64_t clock_microseconds(struct Clock const * clock)
{
        return clock_ticks_to_microseconds(clock, clock_ticks(clock));
}