Ejemplo n.º 1
0
void z_scroll_window (void)
{
    zword win = winarg0 ();
    zword y, x;

    flush_buffer ();

    /* Use the correct set of colours when scrolling the window */

    if (win != cwin && h_interpreter_number != INTERP_AMIGA)
        os_set_colour (lo (wp[win].colour), hi (wp[win].colour));

    y = wp[win].y_pos;
    x = wp[win].x_pos;

    os_scroll_area (y,
                    x,
                    y + wp[win].y_size - 1,
                    x + wp[win].x_size - 1,
                    (short) zargs[1]);

    if (win != cwin && h_interpreter_number != INTERP_AMIGA)
        os_set_colour (lo (cwp->colour), hi (cwp->colour));

}/* z_scroll_window */
Ejemplo n.º 2
0
void erase_window (zword win)
{
    zword y = wp[win].y_pos;
    zword x = wp[win].x_pos;

    if (h_version == V6 && win != cwin && !amiga_screen_model ())
        os_set_colour (lo (wp[win].colour), hi (wp[win].colour));

    if (hi (wp[win].colour) != TRANSPARENT_COLOUR) {

        os_erase_area (y,
                       x,
                       y + wp[win].y_size - 1,
                       x + wp[win].x_size - 1,
                       win);

    }

    if (h_version == V6 && win != cwin && !amiga_screen_model ())
        os_set_colour (lo (cwp->colour), hi (cwp->colour));

    reset_cursor (win);

    wp[win].line_count = 0;

}/* erase_window */
Ejemplo n.º 3
0
void z_scroll_window (void)
{
    zword win = winarg0 ();
    zword y, x;

    flush_buffer ();

    /* Use the correct set of colours when scrolling the window */

    if (win != cwin && !amiga_screen_model ())
        os_set_colour (lo (wp[win].colour), hi (wp[win].colour));

    y = wp[win].y_pos;
    x = wp[win].x_pos;

    os_scroll_area (y,
                    x,
                    y + wp[win].y_size - 1,
                    x + wp[win].x_size - 1,
                    (short) zargs[1]);

    if (win != cwin && !amiga_screen_model ())
        os_set_colour (lo (cwp->colour), hi (cwp->colour));

}/* z_scroll_window */
Ejemplo n.º 4
0
static void set_window (zword win)
{

    flush_buffer ();

    cwin = win; cwp = wp + win;

    update_attributes ();

    if (h_version == V6) {

        os_set_colour (lo (cwp->colour), hi (cwp->colour));

        if (os_font_data (cwp->font, &font_height, &font_width))
            os_set_font (cwp->font);

        os_set_text_style (cwp->style);

    } else refresh_text_style ();

    if (h_version != V6 && win != 0) {
        wp[win].y_cursor = 1;
        wp[win].x_cursor = 1;
    }

    update_cursor ();

}/* set_window */
Ejemplo n.º 5
0
void z_set_colour (void)
{
    zword win = (h_version == V6) ? winarg2 () : 0;

    zword fg = zargs[0];
    zword bg = zargs[1];

    flush_buffer ();

    if ((short) fg == -1)	/* colour -1 is the colour at the cursor */
        fg = os_peek_colour ();
    if ((short) bg == -1)
        bg = os_peek_colour ();

    if (fg == 0)		/* colour 0 means keep current colour */
        fg = lo (wp[win].colour);
    if (bg == 0)
        bg = hi (wp[win].colour);

    if (fg == 1)		/* colour 1 is the system default colour */
        fg = h_default_foreground;
    if (bg == 1)
        bg = h_default_background;

    if (fg == TRANSPARENT_COLOUR)
        fg = lo (wp[win].colour);
    if (bg == TRANSPARENT_COLOUR && !(hx_flags & TRANSPARENT_FLAG))
        bg = hi (wp[win].colour);

    if (h_version == V6 && amiga_screen_model ())

        /* Changing colours of window 0 affects the entire screen */

        if (win == 0) {

            int i;

            for (i = 1; i < 8; i++) {

                zword bg2 = hi (wp[i].colour);
                zword fg2 = lo (wp[i].colour);

                if (bg2 < 16)
                    bg2 = (bg2 == lo (wp[0].colour)) ? fg : bg;
                if (fg2 < 16)
                    fg2 = (fg2 == lo (wp[0].colour)) ? fg : bg;

                wp[i].colour = (bg2 << 8) | fg2;

            }

        }

    wp[win].colour = (bg << 8) | fg;

    if (win == cwin || h_version != V6)
        os_set_colour (fg, bg);

}/* z_set_colour */
Ejemplo n.º 6
0
void restart_screen (void)
{

    /* Use default settings */

    os_set_colour (h_default_foreground, h_default_background);

    if (os_font_data (TEXT_FONT, &font_height, &font_width))
        os_set_font (TEXT_FONT);

    os_set_text_style (0);

    cursor = TRUE;

    /* Initialise window properties */

    mwin = 1;

    for (cwp = wp; cwp < wp + 8; cwp++) {
        cwp->y_pos = 1;
        cwp->x_pos = 1;
        cwp->y_size = 0;
        cwp->x_size = 0;
        cwp->y_cursor = 1;
        cwp->x_cursor = 1;
        cwp->left = 0;
        cwp->right = 0;
        cwp->nl_routine = 0;
        cwp->nl_countdown = 0;
        cwp->style = 0;
        cwp->colour = (h_default_background << 8) | h_default_foreground;
        cwp->font = TEXT_FONT;
        cwp->font_size = (font_height << 8) | font_width;
        cwp->attribute = 8;
        cwp->true_fore = hx_fore_colour;
        cwp->true_back = hx_back_colour;
    }

    /* Prepare lower/upper windows and status line */

    wp[0].attribute = 15;

    wp[0].left = option_left_margin;
    wp[0].right = option_right_margin;

    wp[0].x_size = h_screen_width;
    wp[1].x_size = h_screen_width;

    if (h_version <= V3)
        wp[7].x_size = h_screen_width;

    os_restart_game (RESTART_WPROP_SET);

    /* Clear the screen, unsplit it and select window 0 */

    erase_screen ((zword) (-1));

}/* restart_screen */
Ejemplo n.º 7
0
void z_set_colour (void)
{
    zword win = (h_version == V6) ? winarg2 () : 0;

    zword fg = zargs[0];
    zword bg = zargs[1];

    flush_buffer ();

    if ((short) fg == -1)       /* colour -1 is the colour at the cursor */
        fg = os_peek_colour ();
    if ((short) bg == -1)
        bg = os_peek_colour ();

    if (fg == 0)                /* colour 0 means keep current colour */
        fg = lo (wp[win].colour);
    if (bg == 0)
        bg = hi (wp[win].colour);

    if (fg == 1)                /* colour 1 is the system default colour */
        fg = h_default_foreground;
    if (bg == 1)
        bg = h_default_background;

    if (h_version == V6 && h_interpreter_number == INTERP_AMIGA)

        /* Changing colours of window 0 affects the entire screen */

        if (win == 0) {

            int i;

            for (i = 1; i < 8; i++) {

                zword bg2 = hi (wp[i].colour);
                zword fg2 = lo (wp[i].colour);

                if (bg2 < 16)
                    bg2 = (bg2 == lo (wp[0].colour)) ? fg : bg;
                if (fg2 < 16)
                    fg2 = (fg2 == lo (wp[0].colour)) ? fg : bg;

                wp[i].colour = (bg2 << 8) | fg2;

            }

        }

    wp[win].colour = (bg << 8) | fg;

    if (win == cwin || h_version != V6)
        os_set_colour (fg, bg);

}/* z_set_colour */
Ejemplo n.º 8
0
void erase_window (zword win)
{
    zword y = wp[win].y_pos;
    zword x = wp[win].x_pos;

    if (h_version == V6 && win != cwin && h_interpreter_number != INTERP_AMIGA)
        os_set_colour (lo (wp[win].colour), hi (wp[win].colour));

    os_erase_area (y,
                   x,
                   y + wp[win].y_size - 1,
                   x + wp[win].x_size - 1);

    if (h_version == V6 && win != cwin && h_interpreter_number != INTERP_AMIGA)
        os_set_colour (lo (cwp->colour), hi (cwp->colour));

    reset_cursor (win);

    wp[win].line_count = 0;

}/* erase_window */
Ejemplo n.º 9
0
void os_init_screen (void)
{

    /*trace(TRACE_CALLS);*/

    if (initscr() == NULL) {    /* Set up curses */
	os_fatal("Unable to initialize curses. Maybe your $TERM setting is bad.");
	exit(1);
    }
    u_setup.curses_active = 1;	/* Let os_fatal know curses is running */
    cbreak();			/* Raw input mode, no line processing */
    noecho();			/* No input echo */
    nonl();			/* No newline translation */
    intrflush(stdscr, TRUE);	/* Flush output on interrupt */
    keypad(stdscr, TRUE);	/* Enable the keypad and function keys */
    scrollok(stdscr, FALSE);	/* No scrolling unless explicitly asked for */

    if (h_version == V3 && u_setup.tandy_bit != 0)
        h_config |= CONFIG_TANDY;

    if (h_version == V3)
	h_config |= CONFIG_SPLITSCREEN;

    if (h_version >= V4)
	h_config |= CONFIG_BOLDFACE | CONFIG_EMPHASIS | CONFIG_FIXED | CONFIG_TIMEDINPUT;

    if (h_version >= V5)
      h_flags &= ~(GRAPHICS_FLAG | MOUSE_FLAG | MENU_FLAG);

#ifdef NO_SOUND
    if (h_version >= V5)
      h_flags &= ~SOUND_FLAG;

    if (h_version == V3)
      h_flags &= ~OLD_SOUND_FLAG;
#else
    if ((h_version >= 5) && (h_flags & SOUND_FLAG))
	h_flags |= SOUND_FLAG;

    if ((h_version == 3) && (h_flags & OLD_SOUND_FLAG))
	h_flags |= OLD_SOUND_FLAG;

    if ((h_version == 6) && (f_setup.sound != 0))
	h_config |= CONFIG_SOUND;
#endif

    if (h_version >= V5 && (h_flags & UNDO_FLAG))
        if (f_setup.undo_slots == 0)
            h_flags &= ~UNDO_FLAG;

    getmaxyx(stdscr, h_screen_rows, h_screen_cols);

    if (u_setup.screen_height != -1)
	h_screen_rows = u_setup.screen_height;
    if (u_setup.screen_width != -1)
	h_screen_cols = u_setup.screen_width;

    h_screen_width = h_screen_cols;
    h_screen_height = h_screen_rows;

    h_font_width = 1;
    h_font_height = 1;

    /* Must be after screen dimensions are computed.  */
    if (h_version == V6) {
      if (unix_init_pictures())
	h_config |= CONFIG_PICTURES;
      else
	h_flags &= ~GRAPHICS_FLAG;
    }

    /* Use the ms-dos interpreter number for v6, because that's the
     * kind of graphics files we understand.  Otherwise, use DEC.  */
    h_interpreter_number = h_version == 6 ? INTERP_MSDOS : INTERP_DEC_20;
    h_interpreter_version = 'F';

#ifdef COLOR_SUPPORT
    /* Enable colors if the terminal supports them, the user did not
     * disable colors, and the game or user requested colors.  User
     * requests them by specifying a foreground or background.
     */
    u_setup.color_enabled = (has_colors()
			&& !u_setup.disable_color
			&& (((h_version >= 5) && (h_flags & COLOUR_FLAG))
			  || (u_setup.foreground_color != -1)
			  || (u_setup.background_color != -1)));

    /* Maybe we don't want to muck about with changing $TERM to
     * xterm-color which some supposedly current Unicies still don't
     * understand.
     */
    if (u_setup.force_color)
	u_setup.color_enabled = TRUE;

    if (u_setup.color_enabled) {
        h_config |= CONFIG_COLOUR;
        h_flags |= COLOUR_FLAG; /* FIXME: beyond zork handling? */
        start_color();
	h_default_foreground =
	  (u_setup.foreground_color == -1)
	  	? FOREGROUND_DEF : u_setup.foreground_color;
	h_default_background =
	  (u_setup.background_color ==-1)
		? BACKGROUND_DEF : u_setup.background_color;
    } else
#endif /* COLOR_SUPPORT */
    {
	/* Set these per spec 8.3.2. */
	h_default_foreground = WHITE_COLOUR;
	h_default_background = BLACK_COLOUR;
	if (h_flags & COLOUR_FLAG) h_flags &= ~COLOUR_FLAG;
    }
    os_set_colour(h_default_foreground, h_default_background);
    os_erase_area(1, 1, h_screen_rows, h_screen_cols, 0);
}/* os_init_screen */
Ejemplo n.º 10
0
void os_init_screen (void)
{
    if (h_version == V3 && u_setup.tandy_bit != 0)
        h_config |= CONFIG_TANDY;

    if (h_version == V3)
	h_config |= CONFIG_SPLITSCREEN;

    if (h_version >= V4)
	h_config |= CONFIG_BOLDFACE | CONFIG_EMPHASIS | CONFIG_FIXED | CONFIG_TIMEDINPUT;

    if (h_version >= V5)
      h_flags &= ~(GRAPHICS_FLAG | MOUSE_FLAG | MENU_FLAG);

#ifdef NO_SOUND
    if (h_version >= V5)
      h_flags &= ~SOUND_FLAG;

    if (h_version == V3)
      h_flags &= ~OLD_SOUND_FLAG;
#else
    if ((h_version >= 5) && (h_flags & SOUND_FLAG))
	h_flags |= SOUND_FLAG;

    if ((h_version == 3) && (h_flags & OLD_SOUND_FLAG))
	h_flags |= OLD_SOUND_FLAG;

    if ((h_version == 6) && (f_setup.sound != 0)) 
	h_config |= CONFIG_SOUND;
#endif

    if (h_version >= V5 && (h_flags & UNDO_FLAG))
        if (f_setup.undo_slots == 0)
            h_flags &= ~UNDO_FLAG;

    h_screen_rows = kDefaultTextViewHeight; // iphone_textview_height;
    h_screen_cols = iphone_textview_width;

    if (u_setup.screen_height != -1)
        h_screen_rows = u_setup.screen_height;
    if (u_setup.screen_width != -1)
        h_screen_cols = u_setup.screen_width;
    
    h_screen_width = h_screen_cols;
    h_screen_height = h_screen_rows;

    h_font_width = 1;
    h_font_height = 1;

    /* Must be after screen dimensions are computed.  */
#if 0
    if (h_version == V6) {
      if (unix_init_pictures())
	h_config |= CONFIG_PICTURES;
      else
	h_flags &= ~GRAPHICS_FLAG;
    }
#endif

    /* Use the ms-dos interpreter number for v6, because that's the
     * kind of graphics files we understand.  Otherwise, use DEC.  */
    h_interpreter_number = h_version == 6 ? INTERP_MSDOS : INTERP_DEC_20;
    h_interpreter_version = 'F';

#ifdef COLOR_SUPPORT
    /* Enable colors if the terminal supports them, the user did not
     * disable colors, and the game or user requested colors.  User
     * requests them by specifying a foreground or background.
     */
    u_setup.color_enabled = (!u_setup.disable_color
			&& (((h_version >= 5) && (h_flags & COLOUR_FLAG))
			  || (u_setup.foreground_color != -1)
			  || (u_setup.background_color != -1)));

    /* Maybe we don't want to muck about with changing $TERM to
     * xterm-color which some supposedly current Unicies still don't
     * understand.
     */ 
    //if (u_setup.force_color)
	u_setup.color_enabled = TRUE;

    if (u_setup.color_enabled) {
        h_config |= CONFIG_COLOUR;
        h_flags |= COLOUR_FLAG; /* FIXME: beyond zork handling? */
	h_default_foreground =	1; //(u_setup.foreground_color == -1) ? FOREGROUND_DEF : u_setup.foreground_color;
	h_default_background =  1; //(u_setup.background_color ==-1) ? BACKGROUND_DEF : u_setup.background_color;
    } else 
#endif
    {
	/* Set these per spec 8.3.2. */
	h_default_foreground = BLACK_COLOUR;
	h_default_background = WHITE_COLOUR;
	if (h_flags & COLOUR_FLAG) h_flags &= ~COLOUR_FLAG;
    }
    
    iphone_init_screen();    

    //NSLog (@"uiinit f %d b %d\n", h_default_foreground, h_default_background);
#if FROTZ_IOS_PORT
    if (!do_autosave)
#endif
    {
	os_set_colour(h_default_foreground, h_default_background);
	os_erase_area(1, 1, h_screen_rows, h_screen_cols, 0);
    }

}/* os_init_screen */
Ejemplo n.º 11
0
void z_set_true_colour (void)
{
    zword win = (h_version == V6) ? winarg2 () : 0;

    zword true_fg = zargs[0];
    zword true_bg = zargs[1];

    zword fg = 0;
    zword bg = 0;

    flush_buffer ();

    switch ((short) true_fg) {

    case -1:	/* colour -1 is the system default colour */
        fg = h_default_foreground;
        break;

    case -2:	/* colour -2 means keep current colour */
        fg = lo (wp[win].colour);
        break;

    case -3:	/* colour -3 is the colour at the cursor */
        fg = os_peek_colour ();
        break;

    case -4:
        fg = lo (wp[win].colour);
        break;

    default:
        fg = os_from_true_colour (true_fg);
        break;
    }

    switch ((short) true_bg) {

    case -1:	/* colour -1 is the system default colour */
        bg = h_default_background;
        break;

    case -2:	/* colour -2 means keep current colour */
        bg = hi (wp[win].colour);
        break;

    case -3:	/* colour -3 is the colour at the cursor */
        bg = os_peek_colour ();
        break;

    case -4:	/* colour -4 means transparent */
        if (hx_flags & TRANSPARENT_FLAG)
            bg = TRANSPARENT_COLOUR;
        else
            bg = hi (wp[win].colour);
        break;

    default:
        bg = os_from_true_colour (true_bg);
        break;
    }

    wp[win].colour = (bg << 8) | fg;

    if (win == cwin || h_version != V6)
        os_set_colour (fg, bg);

}/* z_set_true_colour */