Debian Codegraph @

terps/hugo/heglk/heglk.c

raw symbols SCIP
1 /*
2 HEGLK.C
3
4 Glk interface functions for the Hugo Engine
5
6 Copyright (c) 1999-2006 by Kent Tessman
7 */
8
9
10 #include "heheader.h"
11 #include "glk.h"
12
13
14 int hugo_color(int c);
15
16
17 /* Glk main window: */
18 static winid_t mainwin = NULL;
19
20 /* Usually the statusline window: */
21 static winid_t secondwin = NULL;
22
23 /* In case we try to print positioned text to the main window,
24 as in a menu: */
25 static winid_t auxwin = NULL;
26
27 /* A virtual window that points to one of the three above: */
28 static winid_t currentwin = NULL;
29
30 #define CHARWIDTH 1
31 int in_valid_window = false;
32 int glk_fcolor = DEF_FCOLOR, glk_bgcolor = DEF_BGCOLOR;
33 int mainwin_bgcolor;
34 int glk_current_font;
35 char just_cleared_screen = false;
36
37 #define STAT_UNAVAILABLE (-1)
38
39 #include "hemedia.c"
40
41 /* glk_main
42
43 The entry point for Glk: starts up the Hugo Engine.
44 The arguments glk_argc and glk_argv must be made up before
45 glk_main() is called.
46 */
47
48 void glk_main(void)
49 {
50 /* Open the main window... */
51 mainwin = glk_window_open(0, 0, 0, wintype_TextBuffer, 1);
52
53 /* ...and set it up for default output */
54 glk_set_window(currentwin = mainwin);
55
56 /* It's possible that the main window failed to open. There's
57 nothing we can do without it, so exit */
58 if (!mainwin)
59 return;
60
61 he_main(0, NULL); /* no argc, argv */
62 }
63
64
65 /*
66 * MEMORY ALLOCATION:
67 *
68 */
69
70 void *hugo_blockalloc(long num)
71 {
72 return malloc(num * sizeof(char));
73 }
74
75 void hugo_blockfree(void *block)
76 {
77 free(block); /* i.e. free() */
78 }
79
80
81 /*
82 * FILE MANAGEMENT:
83 *
84 */
85
86 /* Glk Hugo doesn't need these; they're handled by the Glk library:
87 void hugo_splitpath(char *path, char *drive, char *dir, char *fname, char *ext)
88 {}
89
90 void hugo_makepath(char *path, char *drive, char *dir, char *fname, char *ext)
91 {}
92
93 void hugo_getfilename(char *a, char *b)
94 {}
95
96 int hugo_overwrite(char *f)
97 {}
98 */
99
100 void hugo_closefiles()
101 {
102 /* Glk closes all files at glk_exit() */
103 }
104
105
106 /*
107 * KEYBOARD INPUT:
108 *
109 */
110
111 /* hugo_getkey */
112
113 int hugo_getkey(void)
114 {
115 /* Not needed here--single-character events are handled
116 solely by hugo_waitforkey(), below */
117
118 return 0;
119 }
120
121
122 /* hugo_getline
123
124 Gets a line of input from the keyboard, storing it in <buffer>.
125 */
126
127 void hugo_getline(char *prmpt)
128 {
129 event_t ev;
130 char gotline = 0;
131
132 /* Just in case we try to get line input from a Glk-illegal
133 window that hasn't been created, switch as a failsafe
134 to mainwin
135 */
136 if (currentwin==NULL)
137 glk_set_window(currentwin = mainwin);
138
139 /* Print prompt */
140 glk_put_string(prmpt);
141
142 /* Request line input */
143 glk_request_line_event(currentwin, buffer, MAXBUFFER, 0);
144
145 while (!gotline)
146 {
147 /* Grab an event */
148 glk_select(&ev);
149
150 switch (ev.type)
151 {
152 case evtype_LineInput:
153 /* (Will always be currentwin, but anyway) */
154 if (ev.win==currentwin)
155 {
156 gotline = true;
157 }
158 break;
159 }
160 }
161
162 /* The line we have received in commandbuf is not null-terminated */
163 buffer[ev.val1] = '\0'; /* i.e., the length */
164
165 /* Copy the input to the script file (if open) */
166 if (script)
167 {
168 /* This looks inefficient, but it's necessary because
169 of the way Glk functions are mapped by stdio
170 */
171 fprintf(script, "%s", prmpt);
172 fprintf(script, "%s", buffer);
173 fprintf(script, "%s", "\n");
174 }
175 }
176
177
178 /* hugo_waitforkey
179
180 Provided to be replaced by multitasking systems where cycling while
181 waiting for a keystroke may not be such a hot idea.
182 */
183
184 int hugo_waitforkey(void)
185 {
186 event_t ev;
187 char gotchar = 0;
188
189 /* Just in case we try to get key input from a Glk-illegal
190 window that hasn't been created, switch as a failsafe
191 to mainwin
192 */
193 if (currentwin==NULL)
194 glk_set_window(currentwin = mainwin);
195
196 #if defined (NO_KEYPRESS_CURSOR)
197 if (currentwin!=mainwin)
198 {
199 glk_window_move_cursor(currentwin, currentpos/CHARWIDTH, currentline-1);
200 hugo_print("*");
201 glk_window_move_cursor(currentwin, currentpos/CHARWIDTH, currentline-1);
202 }
203 #endif
204
205 glk_request_char_event(currentwin);
206
207 while (!gotchar)
208 {
209 /* Grab an event */
210 glk_select(&ev);
211
212 switch (ev.type)
213 {
214 case evtype_CharInput:
215 /* (Will always be mainwin, but anyway) */
216 if (ev.win==currentwin)
217 {
218 gotchar = true;
219 }
220 break;
221 }
222 }
223
224 /* Convert Glk special keycodes: */
225 switch (ev.val1)
226 {
227 case keycode_Left: ev.val1 = 8; break;
228 case keycode_Right: ev.val1 = 21; break;
229 case keycode_Up: ev.val1 = 11; break;
230 case keycode_Down: ev.val1 = 10; break;
231 case keycode_Return: ev.val1 = 13; break;
232 case keycode_Escape: ev.val1 = 27; break;
233 }
234
235 #if defined (NO_KEYPRESS_CURSOR)
236 if (currentwin!=mainwin)
237 {
238 glk_window_move_cursor(currentwin, currentpos/CHARWIDTH, currentline-1);
239 hugo_print(" ");
240 glk_window_move_cursor(currentwin, currentpos/CHARWIDTH, currentline-1);
241 }
242 #endif
243
244 return ev.val1;
245 }
246
247
248 /* hugo_iskeywaiting
249
250 Returns true if a keypress is waiting to be retrieved.
251 */
252
253 int hugo_iskeywaiting(void)
254 {
255 var[system_status] = STAT_UNAVAILABLE;
256 return 0;
257 }
258
259
260 /* hugo_timewait
261
262 Waits for 1/n seconds. Returns false if waiting is unsupported.
263 */
264
265 int hugo_timewait(int n)
266 {
267 glui32 millisecs;
268 event_t ev;
269
270 if (!glk_gestalt(gestalt_Timer, 0))
271 return false;
272 if (n==0) return true;
273
274
275 millisecs = 1000 / n;
276 if (millisecs == 0)
277 millisecs = 1;
278
279 // For the time being, we're going to disallow
280 // millisecond delays in Glk (1) because there's no
281 // point, and (2) so that we can tell we're running
282 // under Glk.
283 if (millisecs < 1000) return false;
284
285 glk_request_timer_events(millisecs);
286 while (1)
287 {
288 glk_select(&ev);
289 if (ev.type == evtype_Timer)
290 break;
291 }
292 glk_request_timer_events(0);
293 return true;
294 }
295
296
297 /*
298 * DISPLAY CONTROL:
299 *
300 */
301
302 void hugo_init_screen(void)
303 {
304 /* Does whatever has to be done to initially set up the display. */
305
306 /* By setting the width and height so high, we're basically
307 forcing the Glk library to deal with text-wrapping and
308 page ends
309 */
310 SCREENWIDTH = 0x7fff;
311 SCREENHEIGHT = 0x7fff;
312 FIXEDCHARWIDTH = 1;
313 FIXEDLINEHEIGHT = 1;
314
315 hugo_settextwindow(1, 1,
316 SCREENWIDTH/FIXEDCHARWIDTH, SCREENHEIGHT/FIXEDLINEHEIGHT);
317 }
318
319
320 void hugo_cleanup_screen(void)
321 {
322 /* Does whatever has to be done to clean up the display pre-termination. */
323 }
324
325
326 #if !defined (PRINTFATALERROR_SUPPLIED)
327 void heglk_printfatalerror(char *err)
328 {
329 static winid_t win = NULL;
330
331 if (!win)
332 {
333 winid_t rootwin = glk_window_get_root();
334 if (!rootwin)
335 win = glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
336 else
337 win = glk_window_open(rootwin, winmethod_Below | winmethod_Fixed,
338 3, wintype_TextBuffer, 0);
339 }
340
341 if (win)
342 {
343 glk_put_string_stream(glk_window_get_stream(win), err);
344 }
345 }
346 #endif /* PRINTFATALERROR_SUPPLIED */
347
348
349 void hugo_clearfullscreen(void)
350 {
351 /* Clears everything on the screen, moving the cursor to the top-left
352 corner of the screen */
353
354 glk_window_clear(mainwin);
355 if (secondwin) glk_window_clear(secondwin);
356 if (auxwin) glk_window_clear(auxwin);
357
358 /* See hugo_print() for the need for this */
359 if (currentwin==mainwin) mainwin_bgcolor = glk_bgcolor;
360
361 /* Must be set: */
362 currentpos = 0;
363 currentline = 1;
364
365 if (!inwindow) just_cleared_screen = true;
366 }
367
368
369 void hugo_clearwindow(void)
370 {
371 /* Clears the currently defined window, moving the cursor to the top-left
372 corner of the window */
373
374 /* If the engine thinks we're in a window, but Glk was
375 unable to comply, don't clear the window, because it's
376 not really a window
377 */
378 if (inwindow && currentwin==mainwin) return;
379 if (currentwin==NULL) return;
380
381 glk_window_clear(currentwin);
382
383 /* See hugo_print() for the need for this */
384 if (currentwin==mainwin) mainwin_bgcolor = glk_bgcolor;
385
386 /* If we're in a fixed-font (i.e., textgrid) auxiliary
387 window when we call for a clear, close auxwin and reset
388 the current window to mainwin
389 */
390 if (auxwin)
391 {
392 stream_result_t sr;
393
394 glk_window_close(auxwin, &sr);
395 auxwin = NULL;
396 glk_set_window(currentwin = mainwin);
397 }
398
399 /* Must be set: */
400 currentpos = 0;
401 currentline = 1;
402
403 if (!inwindow) just_cleared_screen = true;
404 }
405
406
407 void hugo_settextmode(void)
408 {
409 /* This function does whatever is necessary to set the system up for
410 a standard text display */
411
412 charwidth = FIXEDCHARWIDTH;
413 lineheight = FIXEDLINEHEIGHT;
414
415 return;
416 }
417
418
419 void hugo_settextwindow(int left, int top, int right, int bottom)
420 {
421 static int secondwin_bottom = 0;
422
423 /* Hugo's arbitrarily positioned windows don't currently
424 mesh with what Glk has to offer, so we have to ignore any
425 non-Glk-ish Windows and just maintain the current
426 parameters
427 */
428 if ((top!=1 || bottom>=physical_windowbottom/FIXEDLINEHEIGHT+1)
429 /* Pre-v2.4 didn't support proper windowing */
430 && (game_version>=24 || !inwindow))
431 {
432 in_valid_window = false;
433
434 /* Glk-illegal floating window; setting currentwin
435 to NULL will tell hugo_print() not to print in it:
436 */
437 if (bottom<physical_windowbottom/FIXEDLINEHEIGHT+1)
438 {
439 currentwin = NULL;
440 glk_set_window(mainwin);
441 return;
442 }
443 else
444 glk_set_window(currentwin = mainwin);
445 }
446
447 /* Otherwise this is a valid window (positioned along the
448 top of the screen a la a status window), so... */
449 else
450 {
451 /* Arbitrary height of 4 lines for pre-v2.4 windows */
452 if (game_version < 24) bottom = 4;
453
454 /* ...either create a new window if none exists... */
455 if (!secondwin)
456 {
457 glk_stylehint_set (wintype_TextGrid, style_Normal, stylehint_ReverseColor, 1);
458 glk_stylehint_set (wintype_TextGrid, style_Subheader, stylehint_ReverseColor, 1);
459 glk_stylehint_set (wintype_TextGrid, style_Emphasized, stylehint_ReverseColor, 1);
460
461 winid_t p;
462
463 p = glk_window_get_parent(mainwin);
464 secondwin = glk_window_open(mainwin,//p,
465 winmethod_Above | winmethod_Fixed,
466 bottom,
467 wintype_TextGrid,
468 0);
469 }
470
471 /* ...or resize the existing one if necessary */
472 else if (bottom!=secondwin_bottom)
473 {
474 winid_t p;
475
476 p = glk_window_get_parent(secondwin);
477 glk_window_set_arrangement(p,
478 winmethod_Above | winmethod_Fixed,
479 bottom,
480 secondwin);
481 }
482
483 if (secondwin)
484 {
485 if (game_version < 24)
486 glk_window_clear(secondwin);
487
488 glk_set_window(currentwin = secondwin);
489 in_valid_window = true;
490 secondwin_bottom = bottom;
491 }
492 else
493 {
494 currentwin = NULL;
495 glk_set_window(mainwin);
496 secondwin_bottom = 0;
497 return;
498 }
499 }
500
501 physical_windowleft = (left-1)*FIXEDCHARWIDTH;
502 physical_windowtop = (top-1)*FIXEDLINEHEIGHT;
503 physical_windowright = right*FIXEDCHARWIDTH-1;
504 physical_windowbottom = bottom*FIXEDLINEHEIGHT-1;
505 physical_windowwidth = (right-left+1)*FIXEDCHARWIDTH;
506 physical_windowheight = (bottom-top+1)*FIXEDLINEHEIGHT;
507 }
508
509
510 /* heglk_get_linelength
511
512 Specially accommodated in GetProp() in heobject.c.
513 While the engine thinks that the linelength is 0x7fff,
514 this tells things like the display object the actual
515 length. (Defined as ACTUAL_LINELENGTH in heheader.h.)
516 */
517
518 int heglk_get_linelength(void)
519 {
520 static glui32 width;
521
522 /* Try to use whatever fixed-width linelength is available */
523 if (secondwin)
524 glk_window_get_size(secondwin, &width, NULL);
525 else if (auxwin)
526 glk_window_get_size(auxwin, &width, NULL);
527
528 /* Otherwise try to approximate it by the proportionally
529 spaced linelength
530 */
531 else
532 glk_window_get_size(mainwin, &width, NULL);
533
534 /* -1 to override automatic line wrapping */
535 return width-1;
536 }
537
538
539 /* heglk_get_screenheight
540
541 Similar to heglk_get_linelength(). (Defined as
542 ACTUAL_SCREENHEIGHT in heheader.h.)
543 */
544
545 int heglk_get_screenheight(void)
546 {
547 static glui32 height = 0, mainheight = 0;
548
549 if (secondwin)
550 glk_window_get_size(secondwin, NULL, &height);
551 else if (auxwin)
552 glk_window_get_size(auxwin, NULL, &height);
553
554 glk_window_get_size(mainwin, NULL, &mainheight);
555
556 return height+mainheight;
557 }
558
559
560 void hugo_settextpos(int x, int y)
561 {
562 /* The top-left corner of the current active window is (1, 1). */
563
564 if (currentwin==NULL) return;
565
566 /* Try to determine if we're trying to position fixed-width
567 text in the main window, as in a menu, for example
568 */
569 if (!just_cleared_screen && !inwindow &&
570 !(glk_current_font & PROP_FONT)
571 && y!=1 /* not just cls */
572 && y < SCREENHEIGHT-0x0f) /* 0x0f is arbitrary */
573 {
574 /* See if we're already in the auxiliary window */
575 if (currentwin!=auxwin)
576 {
577 /* If not, create it, making it 100% of
578 mainwin's height
579 */
580 if (auxwin==NULL)
581 {
582 auxwin = glk_window_open(mainwin,
583 winmethod_Below | winmethod_Proportional,
584 100,
585 wintype_TextGrid,
586 0);
587 }
588 else
589 glk_window_clear(auxwin);
590
591 glk_set_window(currentwin = auxwin);
592 }
593 }
594
595 /* On the other hand, if we were in a textgrid window and
596 no longer need to be, get out
597 */
598 else if (auxwin)
599 {
600 stream_result_t sr;
601
602 /* Close auxwin */
603 glk_window_close(auxwin, &sr);
604 auxwin = NULL;
605
606 /* Clear the screen (both windows) */
607 glk_window_clear(mainwin);
608 glk_window_clear(secondwin);
609
610 glk_set_window(currentwin = mainwin);
611 }
612
613 just_cleared_screen = false;
614
615 /* Can only move the Glk cursor in a textgrid window */
616 if (currentwin!=mainwin)
617 glk_window_move_cursor(currentwin, x-1, y-1);
618
619 /* Must be set: */
620 currentline = y;
621 currentpos = (x-1)*CHARWIDTH; /* Note: zero-based */
622 }
623
624
625 void hugo_print(char *a)
626 {
627 /* Essentially the same as printf() without formatting, since printf()
628 generally doesn't take into account color setting, font changes,
629 windowing, etc.
630
631 The newline character '\n' must be explicitly included at the end of
632 a line in order to produce a linefeed. The new cursor position is set
633 to the end of this printed text. Upon hitting the right edge of the
634 screen, the printing position wraps to the start of the next line.
635 */
636 static char just_printed_linefeed = false;
637 /* static already_modified_style = false; */
638
639 /* Can't print in a Glk-illegal window since it hasn't been
640 created
641 */
642 if (currentwin==NULL) return;
643
644 /* In lieu of colors, in case we're highlighting something
645 such as a menu selection:
646 */
647 /*
648 if (!inwindow and glk_bgcolor!=mainwin_bgcolor)
649 {
650 if (!already_modified_style)
651 {
652 if (glk_current_font & BOLD_FONT)
653 glk_set_style(style_Normal);
654 else
655 glk_set_style(style_Emphasized);
656 }
657 already_modified_style = true;
658 }
659 else
660 already_modified_style = false;
661 */
662
663 if (a[0]=='\n')
664 {
665 if (!just_printed_linefeed)
666 {
667 glk_put_string("\n");
668 }
669 else
670 just_printed_linefeed = false;
671 }
672 else if (a[0]=='\r')
673 {
674 if (!just_printed_linefeed)
675 {
676 glk_put_string("\n");
677 just_printed_linefeed = true;
678 }
679 else
680 just_printed_linefeed = false;
681 }
682 else
683 {
684 glk_put_string(a);
685 just_printed_linefeed = false;
686 }
687 }
688
689
690 void hugo_scrollwindowup()
691 {
692 /* Glk should look after this for us */
693 }
694
695
696 void hugo_font(int f)
697 {
698 static char using_prop_font = false;
699
700 /* The <f> argument is a mask containing any or none of:
701 BOLD_FONT, UNDERLINE_FONT, ITALIC_FONT, PROP_FONT.
702 */
703 glk_current_font = f;
704
705 glk_set_style(style_Normal);
706
707 if (f & BOLD_FONT)
708 glk_set_style(style_Subheader);
709
710 if (f & UNDERLINE_FONT)
711 glk_set_style(style_Emphasized);
712
713 if (f & ITALIC_FONT)
714 glk_set_style(style_Emphasized);
715
716 if (f & PROP_FONT)
717 using_prop_font = true;
718
719 /* Have to comment this out, it seems, because it will mess up the
720 alignment of the input in the main window
721 if (!(f & PROP_FONT))
722 glk_set_style(style_Preformatted);
723 */
724
725 /* Workaround to decide if we have to open auxwin for positioned
726 non-proportional text:
727 */
728 if (!(f & PROP_FONT))
729 {
730 /* If at top of screen, and changing to a fixed-
731 width font (a situation which wouldn't normally
732 be adjusted for by hugo_settextpos())
733 */
734 if (!inwindow && currentline==1 && currentpos==0 && using_prop_font)
735 {
736 just_cleared_screen = false;
737 hugo_settextpos(1, 2);
738 glk_window_move_cursor(currentwin, 0, 0);
739 }
740 }
741 }
742
743
744 void hugo_settextcolor(int c) /* foreground (print) color */
745 {
746 /* Set the foreground color to hugo_color(c) */
747
748 glk_fcolor = hugo_color(c);
749 }
750
751
752 void hugo_setbackcolor(int c) /* background color */
753 {
754 /* Set the background color to hugo_color(c) */
755
756 glk_bgcolor = hugo_color(c);
757 }
758
759
760 int hugo_color(int c)
761 {
762 /* Color-setting functions should always pass the color through
763 hugo_color() in order to properly set default fore/background
764 colors:
765 */
766
767 if (c==16) c = DEF_FCOLOR;
768 else if (c==17) c = DEF_BGCOLOR;
769 else if (c==18) c = DEF_SLFCOLOR;
770 else if (c==19) c = DEF_SLBGCOLOR;
771 else if (c==20) c = hugo_color(fcolor); /* match foreground */
772
773 /* Uncomment this block of code and change "c = ..." values if the system
774 palette differs from the Hugo palette.
775
776 If colors are unavailable on the system in question, it may suffice
777 to have black, white, and brightwhite (i.e. boldface). It is expected
778 that colored text will be visible on any other-colored background.
779
780 switch (c)
781 {
782 case HUGO_BLACK: c = 0; break;
783 case HUGO_BLUE: c = 1; break;
784 case HUGO_GREEN: c = 2; break;
785 case HUGO_CYAN: c = 3; break;
786 case HUGO_RED: c = 4; break;
787 case HUGO_MAGENTA: c = 5; break;
788 case HUGO_BROWN: c = 6; break;
789 case HUGO_WHITE: c = 7; break;
790 case HUGO_DARK_GRAY: c = 8; break;
791 case HUGO_LIGHT_BLUE: c = 9; break;
792 case HUGO_LIGHT_GREEN: c = 10; break;
793 case HUGO_LIGHT_CYAN: c = 11; break;
794 case HUGO_LIGHT_RED: c = 12; break;
795 case HUGO_LIGHT_MAGENTA: c = 13; break;
796 case HUGO_YELLOW: c = 14; break;
797 case HUGO_BRIGHT_WHITE: c = 15; break;
798 */
799 return c;
800 }
801
802
803 /* CHARACTER AND TEXT MEASUREMENT
804
805 For non-proportional printing, screen dimensions will be given
806 in characters, not pixels.
807
808 For proportional printing, screen dimensions need to be in
809 pixels, and each width routine must take into account the
810 current font and style.
811
812 The hugo_strlen() function is used to give the length of
813 the string not including any non-printing control characters.
814 */
815
816 int hugo_charwidth(char a)
817 {
818 /* As given here, this function works only for non-proportional
819 printing. For proportional printing, hugo_charwidth() should
820 return the width of the supplied character in the current
821 font and style.
822 */
823
824 if (a==FORCED_SPACE)
825 return CHARWIDTH; /* same as ' ' */
826
827 else if ((unsigned char)a >= ' ') /* alphanumeric characters */
828
829 return CHARWIDTH; /* for non-proportional */
830
831 return 0;
832 }
833
834 int hugo_textwidth(char *a)
835 {
836 int i, slen, len = 0;
837
838 slen = (int)strlen(a);
839
840 for (i=0; i<slen; i++)
841 {
842 if (a[i]==COLOR_CHANGE) i+=2;
843 else if (a[i]==FONT_CHANGE) i++;
844 else
845 len += hugo_charwidth(a[i]);
846 }
847
848 return len;
849 }
850
851 int hugo_strlen(char *a)
852 {
853 int i, slen, len = 0;
854
855 slen = (int)strlen(a);
856
857 for (i=0; i<slen; i++)
858 {
859 if (a[i]==COLOR_CHANGE) i+=2;
860 else if (a[i]==FONT_CHANGE) i++;
861 else len++;
862 }
863
864 return len;
865 }
866
867
868 /*
869 * Replacements for things the Glk port doesn't support:
870 *
871 */
872
873 #if !defined (SETTITLE_SUPPORTED)
874 void hugo_setgametitle(char *t)
875 {}
876 #endif
877
878 #if !defined (COMPILE_V25)
879 int hugo_hasvideo(void)
880 {
881 return false;
882 }
883
884 int hugo_playvideo(HUGO_FILE infile, long reslength,
885 char loop_flag, char background, int volume)
886 {
887 fclose(infile);
888 return true;
889 }
890
891 void hugo_stopvideo(void)
892 {}
893 #endif
894
895 #if !defined (GRAPHICS_SUPPORTED)
896 int hugo_hasgraphics(void)
897 {
898 /* Returns true if the current display is capable of graphics display */
899
900 /* If images are being diverted to a window outside of the Glk frame:
901 return 2;
902 */
903 return false; /* graphics unavailable */
904 }
905
906 int hugo_displaypicture(HUGO_FILE infile, long reslength)
907 {
908 fclose(infile);
909 return true;
910 }
911 #endif
912
913 #if !defined (SOUND_SUPPORTED)
914 int hugo_playmusic(HUGO_FILE infile, long reslength, char loop_flag)
915 {
916 fclose(infile);
917 return true; /* not an error */
918 }
919
920 void hugo_musicvolume(int vol)
921 {}
922
923 void hugo_stopmusic(void)
924 {}
925
926 int hugo_playsample(HUGO_FILE infile, long reslength, char loop_flag)
927 {
928 fclose(infile);
929 return true; /* not an error */
930 }
931
932 void hugo_samplevolume(int vol)
933 {}
934
935 void hugo_stopsample(void)
936 {}
937 #endif