Пример #1
0
void GlkInterface::erase_window(zword w) {
	if (w == 0)
		glk_window_clear(gos_lower);
	else if (gos_upper) {
#ifdef GARGLK
		garglk_set_reversevideo_stream(
			glk_window_get_stream(gos_upper),
			true);
#endif /* GARGLK */
		
		memset(statusline, ' ', sizeof statusline);
		glk_window_clear(gos_upper);
		reset_status_ht();
		curr_status_ht = 0;
	}
}
Пример #2
0
void GlkInterface::split_window(zword lines) {
	if (!gos_upper)
		return;

	// The top line is always set for V1 to V3 games
	if (h_version < V4)
		lines++;

	if (!lines || lines > curr_status_ht) {
		uint height;

		glk_window_get_size(gos_upper, nullptr, &height);
		if (lines != height)
			glk_window_set_arrangement(
				glk_window_get_parent(gos_upper),
				winmethod_Above | winmethod_Fixed,
				lines, nullptr);
		curr_status_ht = lines;
	}
	mach_status_ht = lines;
	if (cury > lines)
	{
		glk_window_move_cursor(gos_upper, 0, 0);
		curx = cury = 1;
	}
	gos_update_width();

	if (h_version == V3)
		glk_window_clear(gos_upper);
}
Пример #3
0
static void draw_statuswin(void)
{
    glui32 width, height;

    if (!statuswin) {
        /* It is possible that the window was not successfully
            created. If that's the case, don't try to draw it. */
        return;
    }

    glk_set_window(statuswin);
    glk_window_clear(statuswin);

    glk_window_get_size(statuswin, &width, &height);

    /* Draw a decorative compass rose in the center. */
    width = (width/2);
    if (width > 0)
        width--;
    height = (height/2);
    if (height > 0)
        height--;

    glk_window_move_cursor(statuswin, width, height+0);
    glk_put_string("\\|/");
    glk_window_move_cursor(statuswin, width, height+1);
    glk_put_string("-*-");
    glk_window_move_cursor(statuswin, width, height+2);
    glk_put_string("/|\\");

}
Пример #4
0
void hugo_clearfullscreen(void)
{
/* Clears everything on the screen, moving the cursor to the top-left
   corner of the screen */

	glk_window_clear(mainwin);
	if (secondwin) glk_window_clear(secondwin);
	if (auxwin) glk_window_clear(auxwin);

	/* See hugo_print() for the need for this */
	if (currentwin==mainwin) mainwin_bgcolor = glk_bgcolor;

	/* Must be set: */
	currentpos = 0;
	currentline = 1;

	if (!inwindow) just_cleared_screen = true;
}
Пример #5
0
void print_two_rows(winid_t win)
{
	glui32 width, height;
	glk_window_get_size(win, &width, &height);
	
	glk_set_window(win);
	glk_window_clear(win);

	glui32 x = (width >= 6)? width / 2 - 3 : 0;
	glui32 y = (height > 0)? (height - 1) / 2 : 0;

	glk_window_move_cursor(win, x, y);
	glk_put_string("C: 2");
	glk_window_move_cursor(win, x + 3, y + 1);
	glk_put_string("rows");
}
Пример #6
0
void os_banner_clear(void *banner_handle)
{
    osbanid_t banner = banner_handle;
    if (!banner || !banner->valid)
        return;

    if (banner->win)
    {
        winid_t win = banner->win;
        glk_window_clear(win);
    }

    banner_contents_clear(banner->contents);
    banner->contents = 0;
    banner->newline = 0;
    banner->move = 0;
    banner->x = 0;
    banner->y = 0;
}
Пример #7
0
void center_text(winid_t win, char *text)
{
	glui32 width, height;
	glk_window_get_size(win, &width, &height);
	
	glk_set_window(win);
	glk_window_clear(win);
	
	if(glk_window_get_type(win) == wintype_TextGrid) {
		glk_window_move_cursor(win, width / 2 - strlen(text) / 2, height / 2);
		glk_put_string(text);
	} else if(glk_window_get_type(win) == wintype_TextBuffer) {
		int count;
		for(count = 0; count < height / 2; count++)
			glk_put_char('\n');
		for(count = 0; 
			count < (int)(SPACE_FACTOR * (width / 2 - strlen(text) / 2)); 
			count++)
			glk_put_char(' ');
		glk_put_string(text);
	}
}
Пример #8
0
void hugo_clearwindow(void)
{
/* Clears the currently defined window, moving the cursor to the top-left
   corner of the window */

	/* If the engine thinks we're in a window, but Glk was
	   unable to comply, don't clear the window, because it's
	   not really a window
	*/
	if (inwindow && currentwin==mainwin) return;
	if (currentwin==NULL) return;

	glk_window_clear(currentwin);

	/* See hugo_print() for the need for this */
	if (currentwin==mainwin) mainwin_bgcolor = glk_bgcolor;

	/* If we're in a fixed-font (i.e., textgrid) auxiliary
	   window when we call for a clear, close auxwin and reset
	   the current window to mainwin
	*/
	if (auxwin)
	{
		stream_result_t sr;

		glk_window_close(auxwin, &sr);
		auxwin = NULL;
		glk_set_window(currentwin = mainwin);
	}

	/* Must be set: */
	currentpos = 0;
	currentline = 1;

	if (!inwindow) just_cleared_screen = true;
}
Пример #9
0
/* This draws some corner decorations in *every* key window -- the
    one created at startup, and any later ones. It finds them all
    with glk_window_iterate. */
static void draw_keywins(void)
{
    winid_t win;
    glui32 rock;
    glui32 width, height;

    for (win = glk_window_iterate(NULL, &rock);
            win;
            win = glk_window_iterate(win, &rock)) {
        if (rock == KEYWINROCK) {
            glk_set_window(win);
            glk_window_clear(win);
            glk_window_get_size(win, &width, &height);
            glk_window_move_cursor(win, 0, 0);
            glk_put_char('O');
            glk_window_move_cursor(win, width-1, 0);
            glk_put_char('O');
            glk_window_move_cursor(win, 0, height-1);
            glk_put_char('O');
            glk_window_move_cursor(win, width-1, height-1);
            glk_put_char('O');
        }
    }
}
Пример #10
0
static void Look(void)
{
	static char *ExitNames[6]=
	{
		"North","South","East","West","Up","Down"
	};
	Room *r;
	int ct,f;
	int pos;

	if(split_screen)
		glk_window_clear(Top);

	if((BitFlags&(1<<DARKBIT)) && Items[LIGHT_SOURCE].Location!= CARRIED
	            && Items[LIGHT_SOURCE].Location!= MyLoc)
	{
		if(Options&YOUARE)
			wprintf(Top,"You can't see. It is too dark!\n");
		else
			wprintf(Top,"I can't see. It is too dark!\n");
		if (Options & TRS80_STYLE)
			wprintf(Top,TRS80_LINE);
		return;
	}
	r=&Rooms[MyLoc];
	if(*r->Text=='*')
		wprintf(Top,"%s\n",r->Text+1);
	else
	{
		if(Options&YOUARE)
			wprintf(Top,"You are in a %s\n",r->Text);
		else
			wprintf(Top,"I'm in a %s\n",r->Text);
	}
	ct=0;
	f=0;
	wprintf(Top,"\nObvious exits: ");
	while(ct<6)
	{
		if(r->Exits[ct]!=0)
		{
			if(f==0)
				f=1;
			else
				wprintf(Top,", ");
			wprintf(Top,"%s",ExitNames[ct]);
		}
		ct++;
	}
	if(f==0)
		wprintf(Top,"none");
	wprintf(Top,".\n");
	ct=0;
	f=0;
	pos=0;
	while(ct<=GameHeader.NumItems)
	{
		if(Items[ct].Location==MyLoc)
		{
			if(f==0)
			{
				if(Options&YOUARE)
				{
					wprintf(Top,"\nYou can also see: ");
					pos=18;
				}
				else
				{
					wprintf(Top,"\nI can also see: ");
					pos=16;
				}
				f++;
			}
			else if (!(Options & TRS80_STYLE))
			{
				wprintf(Top," - ");
				pos+=3;
			}
			if(pos+strlen(Items[ct].Text)>(Width-10))
			{
				pos=0;
				wprintf(Top,"\n");
			}
			wprintf(Top,"%s",Items[ct].Text);
			pos += strlen(Items[ct].Text);
			if (Options & TRS80_STYLE)
			{
				wprintf(Top,". ");
				pos+=2;
			}
		}
		ct++;
	}
	wprintf(Top,"\n");
	if (Options & TRS80_STYLE)
		wprintf(Top,TRS80_LINE);
}
Пример #11
0
static void ClearScreen(void)
{
	glk_window_clear(Bottom);
}
Пример #12
0
/*======================================================================*/
void statusline(void)
{
#ifdef HAVE_GLK
  glui32 glkWidth;
  char line[100];
  int pcol = col;

  if (!statusLineOption) return;
  if (glkStatusWin == NULL)
    return;

  glk_set_window(glkStatusWin);
  glk_window_clear(glkStatusWin);
  glk_window_get_size(glkStatusWin, &glkWidth, NULL);

#ifdef HAVE_GARGLK
  int i;
  glk_set_style(style_User1);
  for (i = 0; i < glkWidth; i++)
    glk_put_char(' ');
#endif

  onStatusLine = TRUE;
  col = 1;
  glk_window_move_cursor(glkStatusWin, 1, 0);
  sayInstance(where(HERO, TRUE));

  // TODO Add status message1  & 2 as author customizable messages
  if (header->maximumScore > 0)
    sprintf(line, "Score %d(%d)/%d moves", current.score, (int)header->maximumScore, current.tick);
  else
    sprintf(line, "%d moves", current.tick);
  glk_window_move_cursor(glkStatusWin, glkWidth-strlen(line)-1, 0);
  glk_put_string(line);
  needSpace = FALSE;

  col = pcol;
  onStatusLine = FALSE;

  glk_set_window(glkMainWin);
#else
#ifdef HAVE_ANSI
  char line[100];
  int i;
  int pcol = col;

  if (!statusLineOption) return;
  /* ansi_position(1,1); ansi_bold_on(); */
  printf("\x1b[1;1H");
  printf("\x1b[7m");

  onStatusLine = TRUE;
  col = 1;
  sayInstance(where(HERO, FALSE));

  if (header->maximumScore > 0)
    sprintf(line, "Score %d(%d)/%d moves", current.score, header->maximumScore, current.tick);
  else
    sprintf(line, "%ld moves", (long)current.tick);
  for (i=0; i < pageWidth - col - strlen(line); i++) putchar(' ');
  printf(line);
  printf("\x1b[m");
  printf("\x1b[%d;1H", pageLength);

  needSpace = FALSE;
  capitalize = TRUE;

  onStatusLine = FALSE;
  col = pcol;
#endif
#endif
}
Пример #13
0
void glk_main(void)
{
    winid_t win_a = NULL, win_b = NULL, win_c = NULL, win_d = NULL;
	
	fprintf(stderr, "TEST CASES FROM GLK SPEC\n\n"
			"(Press a key in window A to continue each time)\n\n"
			"Say you do two splits, each a 50-50 percentage split. You start\n"
			"with the original window A, and split that into A and B; then\n"
			"you split B into B and C.\n\n");
	
	win_a = glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
	win_b = glk_window_open(win_a, winmethod_Proportional | winmethod_Below,
							50, wintype_TextBuffer, 0);
	win_c = glk_window_open(win_b, winmethod_Proportional | winmethod_Below,
							50, wintype_TextBuffer, 0);
	if(!win_a || !win_b || !win_c)
		return;
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_c, "C");
	
	wait_for_key(win_a);
	glk_window_close(glk_window_get_root(), NULL);
	
	fprintf(stderr, "Or, you could split A into A and B, and then split A\n"
			"again into A and C.\n\n");
	
	win_a = glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
	win_b = glk_window_open(win_a, winmethod_Proportional | winmethod_Below,
							50, wintype_TextBuffer, 0);
	win_c = glk_window_open(win_a, winmethod_Proportional | winmethod_Below,
							50, wintype_TextBuffer, 0);
	if(!win_a || !win_b || !win_c)
		return;
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_c, "C");
	
	wait_for_key(win_a);
	glk_window_close(glk_window_get_root(), NULL);
	
	fprintf(stderr, "Here are more ways to perform the first example; all of\n"
			"them have the same tree structure, but look different on the\n"
			"screen. Here, we turn the second split (B into B/C) upside down;\n"
			"we put the new window (C) above the old window (B).\n\n");
	
	win_a = glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
	win_b = glk_window_open(win_a, winmethod_Proportional | winmethod_Below,
							50, wintype_TextBuffer, 0);
	win_c = glk_window_open(win_b, winmethod_Proportional | winmethod_Above,
							50, wintype_TextBuffer, 0);
	if(!win_a || !win_b || !win_c)
		return;
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_c, "C");
	
	wait_for_key(win_a);
	glk_window_close(glk_window_get_root(), NULL);
			
	fprintf(stderr, "Here, we mess with the percentages. The first split (A\n"
			"into A/B) is a 25-75 split, which makes B three times the size\n"
			"of A. The second (B into B/C) is a 33-66 split, which makes C\n"
			"twice the size of B. This looks rather like the second example,\n"
			"but has a different internal structure.\n\n");
	
	win_a = glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
	win_b = glk_window_open(win_a, winmethod_Proportional | winmethod_Below,
							75, wintype_TextBuffer, 0);
	win_c = glk_window_open(win_b, winmethod_Proportional | winmethod_Below,
							67, wintype_TextBuffer, 0);
	if(!win_a || !win_b || !win_c)
		return;
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_c, "C");
	
	wait_for_key(win_a);
	glk_window_close(glk_window_get_root(), NULL);
	
	fprintf(stderr, "Here, the second split (B into B/C) is vertical instead\n"
			"of horizontal, with the new window (C) on the left of the old\n"
			"one.\n\n");
	
	win_a = glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
	win_b = glk_window_open(win_a, winmethod_Proportional | winmethod_Below,
							50, wintype_TextBuffer, 0);
	win_c = glk_window_open(win_b, winmethod_Proportional | winmethod_Left,
							50, wintype_TextBuffer, 0);
	if(!win_a || !win_b || !win_c)
		return;
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_c, "C");
	
	wait_for_key(win_a);
	glk_window_close(glk_window_get_root(), NULL);
	
	fprintf(stderr, "In the following two-split process, you can see that\n"
			"when a window is split, it is replaced by a new pair window, and\n"
			"moves down to become one of its two children.\n\n");
	
	if(!(win_a = glk_window_open(0, 0, 0, wintype_TextBuffer, 0)))
		return;
	center_text(win_a, "A");
	wait_for_key(win_a);
	
	if(!(win_b = glk_window_open(win_a, 
								 winmethod_Proportional | winmethod_Below,
								 50, wintype_TextBuffer, 0)))
		return;
	center_text(win_a, "A");
	center_text(win_b, "B");
	wait_for_key(win_a);
	
	if(!(win_c = glk_window_open(win_b, winmethod_Proportional | winmethod_Left,
								 50, wintype_TextBuffer, 0)))
		return;
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_c, "C");
	wait_for_key(win_a);
	
	glk_window_close(glk_window_get_root(), NULL);
	
	fprintf(stderr, "What happens when there is a conflict? The rules are\n"
			"simple. Size control always flows down the tree, and the player\n"
			"is at the top. Let's bring out an example: first we split A into\n"
			"A and B, with a 50%% proportional split. Then we split A into A\n"
			"and C, with C above, being a text grid window, and C gets a\n"
			"fixed size of two rows (as measured in its own font size). A\n"
			"gets whatever remains of the 50%% it had before.\n\n");
	
	win_a = glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
	win_b = glk_window_open(win_a, winmethod_Proportional | winmethod_Below,
							50, wintype_TextBuffer, 0);
	win_c = glk_window_open(win_a, winmethod_Fixed | winmethod_Above,
							2, wintype_TextGrid, 0);
	if(!win_a || !win_b || !win_c)
		return;
	center_text(win_a, "A");
	center_text(win_b, "B: 50%");
	print_two_rows(win_c);
	wait_for_key(win_a);
	
	fprintf(stderr, "(Stage 1) Now the player stretches the window\n"
			"vertically.\n\n");
	
	wait_for_key(win_a);
	
	fprintf(stderr, "(Stage 2) Then the user maliciously starts squeezing the\n"
			"window down, in stages.\n\n");
	
	center_text(win_a, "A");
	center_text(win_b, "B: 50%");
	print_two_rows(win_c);
	wait_for_key(win_a);
	
	fprintf(stderr, "(Stage 3) The logic remains the same. At stage 3,\n"
			"there's no room left for A, so it winds up with zero height.\n"
			"Nothing displayed in A will be visible.\n\n");
	
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_c, "C");
	wait_for_key(win_a);
	
	fprintf(stderr, "(Stage 4) At stage 4, there isn't even room in the upper\n"
			"50%% to give C its two rows; so it only gets one.\n\n");
	
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_c, "C");
	wait_for_key(win_a);
	
	fprintf(stderr, "(Stage 5) Finally, C is squashed out of existence as\n"
			"well.\n\n");
	
	center_text(win_a, "A");
	center_text(win_b, "B");
	wait_for_key(win_a);
	
	glk_window_close(glk_window_get_root(), NULL);
	
	fprintf(stderr, "What happens when you split a fixed-size window? The\n"
			"resulting pair window retains the same size constraint as the\n"
			"original window that was split. The key window for the original\n"
			"split is still the key window for that split, even though it's\n"
			"now a grandchild instead of a child.\n\n");
	
	if(!(win_a = glk_window_open(0, 0, 0, wintype_TextBuffer, 0)))
		return;
	center_text(win_a, "A");
	wait_for_key(win_a);
	
	fprintf(stderr, "After the first split, the new pair window (O1, which\n"
			"covers the whole screen) knows that its first child (A) is above\n"
			"the second, and gets 50%% of its own area. (A is the key window\n"
			"for this split, but a proportional split doesn't care about key\n"
			"windows.)\n\n");
	
	if(!(win_b = glk_window_open(win_a, 
								 winmethod_Proportional | winmethod_Below,
								 50, wintype_TextBuffer, 0)))
		return;
	center_text(win_a, "A: 50%");
	center_text(win_b, "B");
	wait_for_key(win_a);
	
	fprintf(stderr, "After the second split, all this remains true; O1 knows\n"
			"that its first child gets 50%% of its space, and A is O1's key\n"
			"window. But now O1's first child is O2 instead of A. The newer\n"
			"pair window (O2) knows that its first child (C) is above the\n"
			"second, and gets a fixed size of two rows. (As measured in C's\n"
			"font, because C is O2's key window.)\n\n");
	
	if(!(win_c = glk_window_open(win_a, winmethod_Fixed | winmethod_Above, 2,
								 wintype_TextGrid, 0)))
		return;
	center_text(win_a, "A");
	center_text(win_b, "B");
	print_two_rows(win_c);
	wait_for_key(win_a);
	
	fprintf(stderr, "If we split C, now, the resulting pair will still be two\n"
			"C-font rows high -- that is, tall enough for two lines of\n"
			"whatever font C displays. For the sake of example, we'll do this\n"
			"vertically.\n\n");
	
	if(!(win_d = glk_window_open(win_c, 
								 winmethod_Proportional | winmethod_Right,
								 50, wintype_TextBuffer, 0)))
		return;
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_c, "C");
	center_text(win_d, "D");
	wait_for_key(win_a);
	
	fprintf(stderr, "When you close a window (and it is not the root window),\n"
			"the other window in its pair takes over all the freed-up area.\n"
			"Let's close D, in the current example:\n\n");
	
	glk_window_close(win_d, NULL);
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_c, "C");
	wait_for_key(win_a);
	
	fprintf(stderr, "But what if we had closed C instead of D? We would have\n"
			"gotten this:\n\n");
	
	glk_window_close(glk_window_get_root(), NULL);
	win_a = glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
	win_b = glk_window_open(win_a, winmethod_Proportional | winmethod_Below, 50,
							wintype_TextBuffer, 0);
	win_c = glk_window_open(win_a, winmethod_Fixed | winmethod_Above, 2,
							wintype_TextGrid, 0);
	win_d = glk_window_open(win_c, winmethod_Proportional | winmethod_Right, 50,
							wintype_TextBuffer, 0);
	glk_window_close(win_c, NULL);
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_d, "D");
	wait_for_key(win_a);
	
	fprintf(stderr, "Consider the example above, where D had collapsed to\n"
			"zero height. Say D was a text buffer window. You could make a\n"
			"more useful layout:\n\n");
	winid_t o2 = glk_window_get_parent(win_d);
	glk_window_set_arrangement(o2, winmethod_Above | winmethod_Fixed, 3, win_d);
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_d, "D");
	wait_for_key(win_a);
	
	fprintf(stderr, "If you later wanted to expand D to five rows:\n\n");
	glk_window_set_arrangement(o2, winmethod_Above | winmethod_Fixed, 5, NULL);
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_d, "D");
	wait_for_key(win_a);
	
	fprintf(stderr, "This changes the constraint to be on the lower child of\n"
			"O2, which is A. The key window is still D; so A would then be\n"
			"three rows high as measured in D's font, and D would get the\n"
			"rest of O2's space. That may not be what you want.\n\n");
	glk_window_set_arrangement(o2, winmethod_Below | winmethod_Fixed, 3, NULL);
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_d, "D");
	wait_for_key(win_a);
	
	fprintf(stderr, "To set A to be three rows high as measured in A's font,\n"
			"you would do:\n\n");
	glk_window_set_arrangement(o2, winmethod_Below | winmethod_Fixed, 3, win_a);
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_d, "D");
	wait_for_key(win_a);
	
	fprintf(stderr, "Or you could change O2 to a proportional split:\n\n");
	glk_window_set_arrangement(o2, winmethod_Below | winmethod_Proportional, 30,
							   NULL);
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_d, "D");
	wait_for_key(win_a);
	
	fprintf(stderr, "Or:\n\n");
	glk_window_set_arrangement(o2, winmethod_Above | winmethod_Proportional, 70,
							   NULL);
	center_text(win_a, "A");
	center_text(win_b, "B");
	center_text(win_d, "D");
	wait_for_key(win_a);
	
	glk_window_close(win_d, NULL);
	glk_window_close(win_b, NULL);
	glk_window_clear(win_a);
	glk_set_window(win_a);
	glk_put_string("That's all, folks...");
}
Пример #14
0
void hugo_settextpos(int x, int y)
{
/* The top-left corner of the current active window is (1, 1). */

	if (currentwin==NULL) return;

	/* Try to determine if we're trying to position fixed-width
	   text in the main window, as in a menu, for example
	*/
	if (!just_cleared_screen && !inwindow &&
		!(glk_current_font & PROP_FONT)
		&& y!=1			/* not just cls */
		&& y < SCREENHEIGHT-0x0f)	/* 0x0f is arbitrary */
	{
		/* See if we're already in the auxiliary window */
		if (currentwin!=auxwin)
		{
			/* If not, create it, making it 100% of
			   mainwin's height
			*/
			if (auxwin==NULL)
			{
				auxwin = glk_window_open(mainwin,
					winmethod_Below | winmethod_Proportional,
					100,
					wintype_TextGrid,
					0);
			}
			else
				glk_window_clear(auxwin);

			glk_set_window(currentwin = auxwin);
		}
	}

	/* On the other hand, if we were in a textgrid window and
	   no longer need to be, get out
	*/
	else if (auxwin)
	{
		stream_result_t sr;

		/* Close auxwin */
		glk_window_close(auxwin, &sr);
		auxwin = NULL;

		/* Clear the screen (both windows) */
		glk_window_clear(mainwin);
		glk_window_clear(secondwin);

		glk_set_window(currentwin = mainwin);
	}

	just_cleared_screen = false;

	/* Can only move the Glk cursor in a textgrid window */
	if (currentwin!=mainwin)
		glk_window_move_cursor(currentwin, x-1, y-1);

	/* Must be set: */
	currentline = y;
	currentpos = (x-1)*CHARWIDTH;   /* Note:  zero-based */
}
Пример #15
0
void hugo_settextwindow(int left, int top, int right, int bottom)
{
	static int secondwin_bottom = 0;

	/* Hugo's arbitrarily positioned windows don't currently
	   mesh with what Glk has to offer, so we have to ignore any
	   non-Glk-ish Windows and just maintain the current
	   parameters
	*/
	if ((top!=1 || bottom>=physical_windowbottom/FIXEDLINEHEIGHT+1)
		/* Pre-v2.4 didn't support proper windowing */
		&& (game_version>=24 || !inwindow))
	{
		in_valid_window = false;
		
		/* Glk-illegal floating window; setting currentwin
		   to NULL will tell hugo_print() not to print in it:
		*/
		if (bottom<physical_windowbottom/FIXEDLINEHEIGHT+1)
		{
			currentwin = NULL;
			glk_set_window(mainwin);
			return;
		}
		else
			glk_set_window(currentwin = mainwin);
	}

	/* Otherwise this is a valid window (positioned along the
	   top of the screen a la a status window), so... */
	else
	{
		/* Arbitrary height of 4 lines for pre-v2.4 windows */
		if (game_version < 24) bottom = 4;

		/* ...either create a new window if none exists... */
		if (!secondwin)
		{
			glk_stylehint_set (wintype_TextGrid, style_Normal, stylehint_ReverseColor, 1);
			glk_stylehint_set (wintype_TextGrid, style_Subheader, stylehint_ReverseColor, 1);
			glk_stylehint_set (wintype_TextGrid, style_Emphasized, stylehint_ReverseColor, 1);

			winid_t p;

			p = glk_window_get_parent(mainwin);
			secondwin = glk_window_open(mainwin,//p,
				winmethod_Above | winmethod_Fixed,
				bottom,
				wintype_TextGrid,
				0);
		}

		/* ...or resize the existing one if necessary */
		else if (bottom!=secondwin_bottom)
		{
			winid_t p;

			p  = glk_window_get_parent(secondwin);
			glk_window_set_arrangement(p, 
				winmethod_Above | winmethod_Fixed,
				bottom,
				secondwin);
		}

		if (secondwin)
		{
			if (game_version < 24)
				glk_window_clear(secondwin);

			glk_set_window(currentwin = secondwin);
			in_valid_window = true;
			secondwin_bottom = bottom;
		}
		else
		{
			currentwin = NULL;
			glk_set_window(mainwin);
			secondwin_bottom = 0;
			return;
		}
	}

	physical_windowleft = (left-1)*FIXEDCHARWIDTH;
	physical_windowtop = (top-1)*FIXEDLINEHEIGHT;
	physical_windowright = right*FIXEDCHARWIDTH-1;
	physical_windowbottom = bottom*FIXEDLINEHEIGHT-1;
	physical_windowwidth = (right-left+1)*FIXEDCHARWIDTH;
	physical_windowheight = (bottom-top+1)*FIXEDLINEHEIGHT;
}
Пример #16
0
void gidispatch_call(glui32 funcnum, glui32 numargs, gluniversal_t *arglist)
{
  gidispatch_function_t *gidispatch_function;
  char *prototype;
  int argument = 0;
  int slot = 0;
  
  gidispatch_function = gidispatch_get_function_by_id(funcnum);
  prototype = gidispatch_prototype(funcnum);
  printf("DEBUG: dispatch call name=%s, prototype=%s, numargs=%u -- ", gidispatch_function->name, prototype, (unsigned int)numargs);
  
  if (strcmp(prototype, "4IuIuIuIs") == 0) {
    printf("%u, %u, %u, %d\n", arglist[0].uint, arglist[1].uint, arglist[2].uint, arglist[3].sint);
  } else if (strcmp(prototype, "3IuIu:Iu") == 0) {
    printf("%u, %u, returning a glui32\n", arglist[0].uint, arglist[1].uint);
  } else if (strcmp(prototype, "3Qa<Iu:Qa") == 0) {
    printf("win at %p, outref to a glui32, returning a winid_t\n", arglist[0].opaqueref);
  } else if (strcmp(prototype, "3Qc<Iu:Qc") == 0) {
    printf("fileref at %p, outref to a glui32, returning a frefid_t\n", arglist[0].opaqueref);
  } else if (strcmp(prototype, "1Qa:") == 0) {
    printf("win at %p\n", arglist[0].opaqueref);
  } else if (strcmp(prototype, "6QaIuIuIuIu:Qa") == 0) {
    printf("win at %p, %u, %u, %u, %u, returning a winid_t\n", arglist[0].opaqueref, arglist[1].uint, arglist[2].uint, arglist[3].uint, arglist[4].uint);
  } else if (strcmp(prototype, "4IuIuIuIs:") == 0) {
    printf("%u, %u, %u, %d\n", arglist[0].uint, arglist[1].uint, arglist[2].uint, arglist[3].sint);
  } else if (strcmp(prototype, "1Qb:") == 0) {
    printf("stream at %p\n", arglist[0].opaqueref);
  } else if (strcmp(prototype, "1Iu:") == 0) {
    printf("%u\n", arglist[0].uint);
  } else if (strcmp(prototype, "2Qb<[2IuIu]:") == 0) {
    printf("stream at %p, some struct stuff here\n", arglist[0].opaqueref);
  } else if (strcmp(prototype, "3IuIuIu:") == 0) {
    printf("%u, %u, %u\n", arglist[0].uint, arglist[1].uint, arglist[2].uint);
  } else if (strcmp(prototype, "1:Qb") == 0) {
    printf("returning a strid_t\n");
  } else if (strcmp(prototype, "4&+#!IuIuIu:Qb") == 0) {
    printf("retained, nonnull, array of glui32 at %p for length %u, %u, %u, returning a strid_t\n", arglist[1].array, arglist[2].uint, arglist[3].uint, arglist[4].uint);
  } else if (strcmp(prototype, "2Qc:Iu") == 0) {
    printf("fileref at %p, returning a glui32\n", arglist[0].opaqueref);
  } else if (strcmp(prototype, "1<+[4IuQaIuIu]:") == 0) {
    printf("some struct stuff here, nonnull\n");
  } else if (strcmp(prototype, "1:Qb") == 0) {
    printf("returning a strid_t\n");
  } else if (strcmp(prototype, "2Qb:Is") == 0) {
    printf("stream at %p, returning a glsi32\n", arglist[0].opaqueref);
  } else if (strcmp(prototype, "2Qc:Iu") == 0) {
    printf("fileref at %p, returning a glui32\n", arglist[0].opaqueref);
  } else if (strcmp(prototype, "3Qa&+#!CnIu:") == 0) {
    printf("win at %p, retained, nonnull, array of char at %p for length %u, %u\n", arglist[0].opaqueref, arglist[2].array, arglist[3].uint, arglist[4].uint);
  } else if (strcmp(prototype, "3Qb<Iu:Qb") == 0) {
    printf("stream at %p, outref to a glui32, returning a strid_t\n", arglist[0].opaqueref);
  } else if (strcmp(prototype, "4&+#!CnIuIu:Qb") == 0) {
    printf("retained, nonnull, array of char at %p for length %u, %u, %u, returning a strid_t\n", arglist[1].array, arglist[2].uint, arglist[3].uint, arglist[4].uint);
  } else if (strcmp(prototype, "4&+#!IuIuIu:Qb") == 0) {
    printf("retained, nonnull, array of glui32 at %p for length %u, %u, %u, returning a strid_t\n", arglist[1].array, arglist[2].uint, arglist[3].uint, arglist[4].uint);
  } else if (strcmp(prototype, "4IuSIu:Qc") == 0) {
    printf("%u, %s, %u, returning a frefid_t\n", arglist[0].uint, arglist[1].charstr, arglist[2].uint);
  } else if (strcmp(prototype, "4QcIuIu:Qb") == 0) {
    printf("fileref at %p, %u, %u, returning a strid_t\n", arglist[0].opaqueref, arglist[1].uint, arglist[2].uint);
  } else if (strcmp(prototype, "3Qa<Iu<Iu:") == 0) {
    printf("win at %p, outref to a glui32, outref to a glui32\n", arglist[0].opaqueref);
  } else if (strcmp(prototype, "6QaIuIsIsIuIu:") == 0) {
    printf("win at %p, %u, %d, %d, %u, %u\n", arglist[0].opaqueref, arglist[1].uint, arglist[2].sint, arglist[3].sint, arglist[4].uint, arglist[5].uint);
  } else if (strcmp(prototype, "4Iu<Iu<Iu:Iu") == 0) {
    printf("%u, outref to a glui32, outref to a glui32, returning a glui32\n", arglist[0].uint);
  } else {
    printf("unhandled prototype\n");
  }
  
  switch (funcnum) {
  case 0x0004: /* gestalt */
    arglist[3].uint = glk_gestalt(arglist[0].uint, arglist[1].uint);
    break;
  case 0x0005: /* gestalt_ext */
    if (arglist[2].ptrflag) {
      arglist[6].uint = glk_gestalt_ext(arglist[0].uint, arglist[1].uint,
                                        arglist[3].array, arglist[4].uint);
    }
    else {
      arglist[4].uint = glk_gestalt_ext(arglist[0].uint, arglist[1].uint,
                                        NULL, 0);
    }
    break;
  case 0x0020: /* window_iterate */
    if (arglist[1].ptrflag) 
      arglist[4].opaqueref = glk_window_iterate(arglist[0].opaqueref, &arglist[2].uint);
    else
      arglist[3].opaqueref = glk_window_iterate(arglist[0].opaqueref, NULL);
    break;
  case 0x0023: /* window_open */
    arglist[6].opaqueref = glk_window_open(arglist[0].opaqueref, arglist[1].uint, 
                                           arglist[2].uint, arglist[3].uint, arglist[4].uint);
    break;

  case 0x0025: /* window_get_size */
    {
      int ix = 1;
      glui32 *ptr1, *ptr2;
      if (!arglist[ix].ptrflag) {
        ptr1 = NULL;
      }
      else {
        ix++;
        ptr1 = &(arglist[ix].uint);
      }
      ix++;
      if (!arglist[ix].ptrflag) {
        ptr2 = NULL;
      }
      else {
        ix++;
        ptr2 = &(arglist[ix].uint);
      }
      ix++;
      glk_window_get_size(arglist[0].opaqueref, ptr1, ptr2);
    }
    break;
  case 0x0028: /* window_get_type */
    arglist[2].uint = glk_window_get_type(arglist[0].opaqueref);
    break;
  case 0x002A: /* window_clear */
    glk_window_clear(arglist[0].opaqueref);
    break;
  case 0x002B: /* window_move_cursor */
    glk_window_move_cursor(arglist[0].opaqueref, arglist[1].uint, 
                           arglist[2].uint);
    break;
  case 0x002F: /* set_window */
    glk_set_window(arglist[0].opaqueref);
    break;
    
  case 0x0040: /* stream_iterate */
    if (arglist[1].ptrflag) 
      arglist[4].opaqueref = glk_stream_iterate(arglist[0].opaqueref, &arglist[2].uint);
    else
      arglist[3].opaqueref = glk_stream_iterate(arglist[0].opaqueref, NULL);
    break;
  case 0x0042: /* stream_open_file */
    arglist[4].opaqueref = glk_stream_open_file(arglist[0].opaqueref, arglist[1].uint, 
                                                arglist[2].uint);
    break;
  case 0x0043: /* stream_open_memory */
    if (arglist[0].ptrflag) 
      arglist[6].opaqueref = glk_stream_open_memory(arglist[1].array, 
                                                    arglist[2].uint, arglist[3].uint, arglist[4].uint);
    else
      arglist[4].opaqueref = glk_stream_open_memory(NULL, 
                                                    0, arglist[1].uint, arglist[2].uint);
    break;
  case 0x0044: /* stream_close */
    if (arglist[1].ptrflag) {
      stream_result_t dat;
      glk_stream_close(arglist[0].opaqueref, &dat);
      arglist[2].uint = dat.readcount;
      arglist[3].uint = dat.writecount;
    }
    else {
      glk_stream_close(arglist[0].opaqueref, NULL);
    }
    break;
  case 0x0047: /* stream_set_current */
    glk_stream_set_current(arglist[0].opaqueref);
    break;
  case 0x0048: /* stream_get_current */
    arglist[1].opaqueref = glk_stream_get_current();
    break;

  case 0x0061: /* fileref_create_by_name */
    arglist[4].opaqueref = glk_fileref_create_by_name(arglist[0].uint, 
                                                      arglist[1].charstr, arglist[2].uint);
    break;
  case 0x0062: /* fileref_create_by_prompt */
    arglist[4].opaqueref = glk_fileref_create_by_prompt(arglist[0].uint, 
                                                        arglist[1].uint, arglist[2].uint);
    break;
  case 0x0067: /* fileref_does_file_exist */
    arglist[2].uint = glk_fileref_does_file_exist(arglist[0].opaqueref);
    break;

  case 0x0086: /* set_style */
    glk_set_style(arglist[0].uint);
    break;
  case 0x0087: /* set_style_stream */
    glk_set_style_stream(arglist[0].opaqueref, arglist[1].uint);
    break;
    
  case 0x0090: /* get_char_stream */
    arglist[2].sint = glk_get_char_stream(arglist[0].opaqueref);
    break;

  case 0x00B0: /* stylehint_set */
    glk_stylehint_set(arglist[0].uint, arglist[1].uint,
                      arglist[2].uint, arglist[3].sint);
    break;
    
  case 0x00C0: /* select */
    if (arglist[0].ptrflag) {
      event_t dat;
      glk_select(&dat);
      arglist[1].uint = dat.type;
      arglist[2].opaqueref = dat.win;
      arglist[3].uint = dat.val1;
      arglist[4].uint = dat.val2;
    }
    else {
      glk_select(NULL);
    }
    break;
  
  case 0x00D0: /* request_line_event */
    if (arglist[1].ptrflag)
      glk_request_line_event(arglist[0].opaqueref, arglist[2].array,
                             arglist[3].uint, arglist[4].uint);
    else
      glk_request_line_event(arglist[0].opaqueref, NULL,
                             0, arglist[2].uint);
    break;
  case 0x00D2: /* request_char_event */
    glk_request_char_event(arglist[0].opaqueref);
    break;
    
  case 0x00E0: /* image_get_info */
    {
      int ix = 1;
      glui32 *ptr1, *ptr2;
      if (!arglist[ix].ptrflag) {
        ptr1 = NULL;
      }
      else {
        ix++;
        ptr1 = &(arglist[ix].uint);
      }
      ix++;
      if (!arglist[ix].ptrflag) {
        ptr2 = NULL;
      }
      else {
        ix++;
        ptr2 = &(arglist[ix].uint);
      }
      ix++;
      ix++;
      arglist[ix].uint = glk_image_get_info(arglist[0].uint, ptr1, ptr2);
    }
    break;
  case 0x00E1: /* image_draw */
    arglist[5].uint = glk_image_draw(arglist[0].opaqueref, 
                                     arglist[1].uint,
                                     arglist[2].sint, arglist[3].sint);
    break;
  case 0x00E2: /* image_draw_scaled */
    arglist[7].uint = glk_image_draw_scaled(arglist[0].opaqueref, 
                                            arglist[1].uint,
                                            arglist[2].sint, arglist[3].sint,
                                            arglist[4].uint, arglist[5].uint);
    break;
  case 0x00EA: /* window_fill_rect */
    glk_window_fill_rect(arglist[0].opaqueref, arglist[1].uint,
                         arglist[2].sint, arglist[3].sint,
                         arglist[4].uint, arglist[5].uint);
    break;


  case 0x0128: /* put_char_uni */
    glk_put_char_uni(arglist[0].uint);
    break;
  case 0x0139: /* stream_open_memory_uni */
    if (arglist[0].ptrflag) 
      arglist[6].opaqueref = glk_stream_open_memory_uni(arglist[1].array, 
                                                        arglist[2].uint, arglist[3].uint, arglist[4].uint);
    else
      arglist[4].opaqueref = glk_stream_open_memory_uni(NULL, 
                                                        0, arglist[1].uint, arglist[2].uint);
    break;
    
  default:
    printf("Unhandled call to %s via dispatch\n", gidispatch_function->name);
#if 0
  case 0x0001: /* exit */
    glk_exit();
    break;
  case 0x0002: /* set_interrupt_handler */
    /* cannot be invoked through dispatch layer */
    break;
  case 0x0003: /* tick */
    glk_tick();
    break;
  case 0x0021: /* window_get_rock */
    arglist[2].uint = glk_window_get_rock(arglist[0].opaqueref);
    break;
  case 0x0022: /* window_get_root */
    arglist[1].opaqueref = glk_window_get_root();
    break;
  case 0x0024: /* window_close */
    if (arglist[1].ptrflag) {
      stream_result_t dat;
      glk_window_close(arglist[0].opaqueref, &dat);
      arglist[2].uint = dat.readcount;
      arglist[3].uint = dat.writecount;
    }
    else {
      glk_window_close(arglist[0].opaqueref, NULL);
    }
    break;
  case 0x0026: /* window_set_arrangement */
    glk_window_set_arrangement(arglist[0].opaqueref, arglist[1].uint, 
                               arglist[2].uint, arglist[3].opaqueref);
    break;
  case 0x0027: /* window_get_arrangement */
    {
      int ix = 1;
      glui32 *ptr1, *ptr2;
      winid_t *ptr3;
      if (!arglist[ix].ptrflag) {
        ptr1 = NULL;
      }
      else {
        ix++;
        ptr1 = &(arglist[ix].uint);
      }
      ix++;
      if (!arglist[ix].ptrflag) {
        ptr2 = NULL;
      }
      else {
        ix++;
        ptr2 = &(arglist[ix].uint);
      }
      ix++;
      if (!arglist[ix].ptrflag) {
        ptr3 = NULL;
      }
      else {
        ix++;
        ptr3 = (winid_t *)(&(arglist[ix].opaqueref));
      }
      ix++;
      glk_window_get_arrangement(arglist[0].opaqueref, ptr1, ptr2, ptr3);
    }
    break;
  case 0x0029: /* window_get_parent */
    arglist[2].opaqueref = glk_window_get_parent(arglist[0].opaqueref);
    break;
  case 0x002C: /* window_get_stream */
    arglist[2].opaqueref = glk_window_get_stream(arglist[0].opaqueref);
    break;
  case 0x002D: /* window_set_echo_stream */
    glk_window_set_echo_stream(arglist[0].opaqueref, arglist[1].opaqueref);
    break;
  case 0x002E: /* window_get_echo_stream */
    arglist[2].opaqueref = glk_window_get_echo_stream(arglist[0].opaqueref);
    break;
  case 0x0030: /* window_get_sibling */
    arglist[2].opaqueref = glk_window_get_sibling(arglist[0].opaqueref);
    break;
  case 0x0041: /* stream_get_rock */
    arglist[2].uint = glk_stream_get_rock(arglist[0].opaqueref);
    break;
  case 0x0045: /* stream_set_position */
    glk_stream_set_position(arglist[0].opaqueref, arglist[1].sint,
                            arglist[2].uint);
    break;
  case 0x0046: /* stream_get_position */
    arglist[2].uint = glk_stream_get_position(arglist[0].opaqueref);
    break;
  case 0x0048: /* stream_get_current */
    arglist[1].opaqueref = glk_stream_get_current();
    break;
  case 0x0060: /* fileref_create_temp */
    arglist[3].opaqueref = glk_fileref_create_temp(arglist[0].uint, 
                                                   arglist[1].uint);
    break;
  case 0x0063: /* fileref_destroy */
    glk_fileref_destroy(arglist[0].opaqueref);
    break;
  case 0x0064: /* fileref_iterate */
    if (arglist[1].ptrflag) 
      arglist[4].opaqueref = glk_fileref_iterate(arglist[0].opaqueref, &arglist[2].uint);
    else
      arglist[3].opaqueref = glk_fileref_iterate(arglist[0].opaqueref, NULL);
    break;
  case 0x0065: /* fileref_get_rock */
    arglist[2].uint = glk_fileref_get_rock(arglist[0].opaqueref);
    break;
  case 0x0066: /* fileref_delete_file */
    glk_fileref_delete_file(arglist[0].opaqueref);
    break;
  case 0x0068: /* fileref_create_from_fileref */
    arglist[4].opaqueref = glk_fileref_create_from_fileref(arglist[0].uint, 
                                                           arglist[1].opaqueref, arglist[2].uint);
    break;
  case 0x0080: /* put_char */
    glk_put_char(arglist[0].uch);
    break;
  case 0x0081: /* put_char_stream */
    glk_put_char_stream(arglist[0].opaqueref, arglist[1].uch);
    break;
  case 0x0082: /* put_string */
    glk_put_string(arglist[0].charstr);
    break;
  case 0x0083: /* put_string_stream */
    glk_put_string_stream(arglist[0].opaqueref, arglist[1].charstr);
    break;
  case 0x0084: /* put_buffer */
    if (arglist[0].ptrflag) 
      glk_put_buffer(arglist[1].array, arglist[2].uint);
    else
      glk_put_buffer(NULL, 0);
    break;
  case 0x0085: /* put_buffer_stream */
    if (arglist[1].ptrflag) 
      glk_put_buffer_stream(arglist[0].opaqueref, 
                            arglist[2].array, arglist[3].uint);
    else
      glk_put_buffer_stream(arglist[0].opaqueref, 
                            NULL, 0);
    break;
  case 0x0091: /* get_line_stream */
    if (arglist[1].ptrflag) 
      arglist[5].uint = glk_get_line_stream(arglist[0].opaqueref, 
                                            arglist[2].array, arglist[3].uint);
    else
      arglist[3].uint = glk_get_line_stream(arglist[0].opaqueref, 
                                            NULL, 0);
    break;
  case 0x0092: /* get_buffer_stream */
    if (arglist[1].ptrflag) 
      arglist[5].uint = glk_get_buffer_stream(arglist[0].opaqueref, 
                                              arglist[2].array, arglist[3].uint);
    else
      arglist[3].uint = glk_get_buffer_stream(arglist[0].opaqueref, 
                                              NULL, 0);
    break;
  case 0x00A0: /* char_to_lower */
    arglist[2].uch = glk_char_to_lower(arglist[0].uch);
    break;
  case 0x00A1: /* char_to_upper */
    arglist[2].uch = glk_char_to_upper(arglist[0].uch);
    break;
  case 0x00B1: /* stylehint_clear */
    glk_stylehint_clear(arglist[0].uint, arglist[1].uint,
                        arglist[2].uint);
    break;
  case 0x00B2: /* style_distinguish */
    arglist[4].uint = glk_style_distinguish(arglist[0].opaqueref, arglist[1].uint,
                                            arglist[2].uint);
    break;
  case 0x00B3: /* style_measure */
    if (arglist[3].ptrflag)
      arglist[6].uint = glk_style_measure(arglist[0].opaqueref, arglist[1].uint,
                                          arglist[2].uint, &(arglist[4].uint));
    else
      arglist[5].uint = glk_style_measure(arglist[0].opaqueref, arglist[1].uint,
                                          arglist[2].uint, NULL);
    break;
  case 0x00C1: /* select_poll */
    if (arglist[0].ptrflag) {
      event_t dat;
      glk_select_poll(&dat);
      arglist[1].uint = dat.type;
      arglist[2].opaqueref = dat.win;
      arglist[3].uint = dat.val1;
      arglist[4].uint = dat.val2;
    }
    else {
      glk_select_poll(NULL);
    }
    break;
  case 0x00D1: /* cancel_line_event */
    if (arglist[1].ptrflag) {
      event_t dat;
      glk_cancel_line_event(arglist[0].opaqueref, &dat);
      arglist[2].uint = dat.type;
      arglist[3].opaqueref = dat.win;
      arglist[4].uint = dat.val1;
      arglist[5].uint = dat.val2;
    }
    else {
      glk_cancel_line_event(arglist[0].opaqueref, NULL);
    }
    break;
  case 0x00D3: /* cancel_char_event */
    glk_cancel_char_event(arglist[0].opaqueref);
    break;
  case 0x00D4: /* request_mouse_event */
    glk_request_mouse_event(arglist[0].opaqueref);
    break;
  case 0x00D5: /* cancel_mouse_event */
    glk_cancel_mouse_event(arglist[0].opaqueref);
    break;
  case 0x00D6: /* request_timer_events */
    glk_request_timer_events(arglist[0].uint);
    break;

#ifdef GLK_MODULE_IMAGE
  case 0x00E8: /* window_flow_break */
    glk_window_flow_break(arglist[0].opaqueref);
    break;
  case 0x00E9: /* window_erase_rect */
    glk_window_erase_rect(arglist[0].opaqueref,
                          arglist[1].sint, arglist[2].sint,
                          arglist[3].uint, arglist[4].uint);
    break;
  case 0x00EB: /* window_set_background_color */
    glk_window_set_background_color(arglist[0].opaqueref, arglist[1].uint);
    break;
#endif /* GLK_MODULE_IMAGE */

#ifdef GLK_MODULE_SOUND
  case 0x00F0: /* schannel_iterate */
    if (arglist[1].ptrflag) 
      arglist[4].opaqueref = glk_schannel_iterate(arglist[0].opaqueref, &arglist[2].uint);
    else
      arglist[3].opaqueref = glk_schannel_iterate(arglist[0].opaqueref, NULL);
    break;
  case 0x00F1: /* schannel_get_rock */
    arglist[2].uint = glk_schannel_get_rock(arglist[0].opaqueref);
    break;
  case 0x00F2: /* schannel_create */
    arglist[2].opaqueref = glk_schannel_create(arglist[0].uint);
    break;
  case 0x00F3: /* schannel_destroy */
    glk_schannel_destroy(arglist[0].opaqueref);
    break;
  case 0x00F8: /* schannel_play */
    arglist[3].uint = glk_schannel_play(arglist[0].opaqueref, arglist[1].uint);
    break;
  case 0x00F9: /* schannel_play_ext */
    arglist[5].uint = glk_schannel_play_ext(arglist[0].opaqueref, 
                                            arglist[1].uint, arglist[2].uint, arglist[3].uint);
    break;
  case 0x00FA: /* schannel_stop */
    glk_schannel_stop(arglist[0].opaqueref);
    break;
  case 0x00FB: /* schannel_set_volume */
    glk_schannel_set_volume(arglist[0].opaqueref, arglist[1].uint);
    break;
  case 0x00FC: /* sound_load_hint */
    glk_sound_load_hint(arglist[0].uint, arglist[1].uint);
    break;
#endif /* GLK_MODULE_SOUND */

#ifdef GLK_MODULE_HYPERLINKS
  case 0x0100: /* set_hyperlink */
    glk_set_hyperlink(arglist[0].uint);
    break;
  case 0x0101: /* set_hyperlink_stream */
    glk_set_hyperlink_stream(arglist[0].opaqueref, arglist[1].uint);
    break;
  case 0x0102: /* request_hyperlink_event */
    glk_request_hyperlink_event(arglist[0].opaqueref);
    break;
  case 0x0103: /* cancel_hyperlink_event */
    glk_cancel_hyperlink_event(arglist[0].opaqueref);
    break;
#endif /* GLK_MODULE_HYPERLINKS */
            
#ifdef GLK_MODULE_UNICODE
  case 0x0120: /* buffer_to_lower_case_uni */
    if (arglist[0].ptrflag) 
      arglist[5].uint = glk_buffer_to_lower_case_uni(arglist[1].array, arglist[2].uint, arglist[3].uint);
    else
      arglist[3].uint = glk_buffer_to_lower_case_uni(NULL, 0, arglist[1].uint);
    break;
  case 0x0121: /* buffer_to_upper_case_uni */
    if (arglist[0].ptrflag) 
      arglist[5].uint = glk_buffer_to_upper_case_uni(arglist[1].array, arglist[2].uint, arglist[3].uint);
    else
      arglist[3].uint = glk_buffer_to_upper_case_uni(NULL, 0, arglist[1].uint);
    break;
  case 0x0122: /* buffer_to_title_case_uni */
    if (arglist[0].ptrflag) 
      arglist[6].uint = glk_buffer_to_title_case_uni(arglist[1].array, arglist[2].uint, arglist[3].uint, arglist[4].uint);
    else
      arglist[4].uint = glk_buffer_to_title_case_uni(NULL, 0, arglist[1].uint, arglist[2].uint);
    break;
  case 0x0129: /* put_string_uni */
    glk_put_string_uni(arglist[0].unicharstr);
    break;
  case 0x012A: /* put_buffer_uni */
    if (arglist[0].ptrflag) 
      glk_put_buffer_uni(arglist[1].array, arglist[2].uint);
    else
      glk_put_buffer_uni(NULL, 0);
    break;
  case 0x012B: /* put_char_stream_uni */
    glk_put_char_stream_uni(arglist[0].opaqueref, arglist[1].uint);
    break;
  case 0x012C: /* put_string_stream_uni */
    glk_put_string_stream_uni(arglist[0].opaqueref, arglist[1].unicharstr);
    break;
  case 0x012D: /* put_buffer_stream_uni */
    if (arglist[1].ptrflag) 
      glk_put_buffer_stream_uni(arglist[0].opaqueref, 
                                arglist[2].array, arglist[3].uint);
    else
      glk_put_buffer_stream_uni(arglist[0].opaqueref, 
                                NULL, 0);
    break;
  case 0x0130: /* get_char_stream_uni */
    arglist[2].sint = glk_get_char_stream_uni(arglist[0].opaqueref);
    break;
  case 0x0131: /* get_buffer_stream_uni */
    if (arglist[1].ptrflag) 
      arglist[5].uint = glk_get_buffer_stream_uni(arglist[0].opaqueref, 
                                                  arglist[2].array, arglist[3].uint);
    else
      arglist[3].uint = glk_get_buffer_stream_uni(arglist[0].opaqueref, 
                                                  NULL, 0);
    break;
  case 0x0132: /* get_line_stream_uni */
    if (arglist[1].ptrflag) 
      arglist[5].uint = glk_get_line_stream_uni(arglist[0].opaqueref, 
                                                arglist[2].array, arglist[3].uint);
    else
      arglist[3].uint = glk_get_line_stream_uni(arglist[0].opaqueref, 
                                                NULL, 0);
    break;
  case 0x0138: /* stream_open_file_uni */
    arglist[4].opaqueref = glk_stream_open_file_uni(arglist[0].opaqueref, arglist[1].uint, 
                                                    arglist[2].uint);
    break;
  case 0x0140: /* request_char_event_uni */
    glk_request_char_event_uni(arglist[0].opaqueref);
    break;
  case 0x0141: /* request_line_event_uni */
    if (arglist[1].ptrflag)
      glk_request_line_event_uni(arglist[0].opaqueref, arglist[2].array,
                                 arglist[3].uint, arglist[4].uint);
    else
      glk_request_line_event_uni(arglist[0].opaqueref, NULL,
                                 0, arglist[2].uint);
    break;
#endif /* GLK_MODULE_UNICODE */
#endif /* 0 */
  }
}
Пример #17
0
/* Clear a window. */
static void verb_clear(winid_t win)
{
    glk_window_clear(win);
}