void dumb_init_output(void) { if (h_version == V3) { h_config |= CONFIG_SPLITSCREEN; h_flags &= ~OLD_SOUND_FLAG; } if (h_version >= V5) { h_flags &= ~SOUND_FLAG; } h_screen_height = h_screen_rows; h_screen_width = h_screen_cols; screen_cells = h_screen_rows * h_screen_cols; h_font_width = 1; h_font_height = 1; if (show_line_types == -1) show_line_types = h_version > 3; screen_data = malloc(screen_cells * sizeof(cell)); screen_changes = malloc(screen_cells); os_erase_area(1, 1, h_screen_rows, h_screen_cols, -1); memset(screen_changes, 0, screen_cells); }
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 */
void os_scroll_area (int top, int left, int bottom, int right, int units) { int row, col; top--; left--; bottom--; right--; if (units > 0) { for (row = top; row <= bottom - units; row++) for (col = left; col <= right; col++) dumb_copy_cell(row, col, row + units, col); os_erase_area(bottom - units + 2, left + 1, bottom + 1, right + 1, -1); } else if (units < 0) { for (row = bottom; row >= top - units; row--) for (col = left; col <= right; col++) dumb_copy_cell(row, col, row + units, col); os_erase_area(top + 1, left + 1, top - units, right + 1, -1); } }
void z_erase_picture (void) { int height, width; zword y = zargs[1]; zword x = zargs[2]; flush_buffer (); /* Do nothing if the background is transparent */ if (hi (cwp->colour) == TRANSPARENT_COLOUR) return; if (y == 0) /* use cursor line if y-coordinate is 0 */ y = cwp->y_cursor; if (x == 0) /* use cursor column if x-coordinate is 0 */ x = cwp->x_cursor; os_picture_data (zargs[0], &height, &width); y += cwp->y_pos - 1; x += cwp->x_pos - 1; os_erase_area (y, x, y + height - 1, x + width - 1, -1); }/* z_erase_picture */
void z_erase_line (void) { zword pixels = zargs[0]; zword y, x; flush_buffer (); /* Do nothing if the background is transparent */ if (hi (cwp->colour) == TRANSPARENT_COLOUR) return; /* Clipping at the right margin of the current window */ if (--pixels == 0 || pixels > units_left ()) pixels = units_left (); /* Erase from cursor position */ y = cwp->y_pos + cwp->y_cursor - 1; x = cwp->x_pos + cwp->x_cursor - 1; os_erase_area (y, x, y + font_height - 1, x + pixels - 1, -1); }/* z_erase_line */
/* * os_scroll_area * * Scroll a rectangular area of the screen up (units > 0) or down * (units < 0) and fill the empty space with the current background * colour. Top left coordinates are (1,1). The cursor stays put. * */ void os_scroll_area (int top, int left, int bottom, int right, int units) { top--; left--; bottom--; right--; if ((left == 0) && (right == h_screen_cols - 1)) { static int old_scroll_top = 0; static int old_scroll_bottom = 0; if (!((old_scroll_top == top) && (old_scroll_bottom == bottom))) { old_scroll_top = top; old_scroll_bottom = bottom; setscrreg(top, bottom); } scrollok(stdscr, TRUE); scrl(units); scrollok(stdscr, FALSE); } else { int row, col, x, y; chtype ch; getyx(stdscr, y, x); /* Must turn off attributes during copying. */ attrset(0); if (units > 0) { for (row = top; row <= bottom - units; row++) for (col = left; col <= right; col++) { ch = mvinch(row + units, col); mvaddch(row, col, ch); } } else if (units < 0) { for (row = bottom; row >= top - units; row--) for (col = left; col <= right; col++) { ch = mvinch(row + units, col); mvaddch(row, col, ch); } } /* Restore attributes. */ os_set_text_style(u_setup.current_text_style); move(y, x); } if (units > 0) os_erase_area(bottom - units + 2, left + 1, bottom + 1, right + 1, 0); else if (units < 0) os_erase_area(top + 1, left + 1, top - units, right + 1, 0); }/* os_scroll_area */
void dumb_discard_old_input(int num_chars) { /* Weird discard stuff. Grep spec for 'pain in my butt'. */ /* The old characters should be on the screen just before the cursor. * Erase them. */ cursor_col -= num_chars; if (cursor_col < 0) cursor_col = 0; os_erase_area(cursor_row + 1, cursor_col + 1, cursor_row + 1, cursor_col + num_chars, -1); }
static void erase_screen (zword win) { int i; os_erase_area (1, 1, h_screen_height, h_screen_width); if ((short) win == -1) { split_window (0); set_window (0); reset_cursor (0); } for (i = 0; i < 8; i++) wp[i].line_count = 0; }/* erase_screen */
static void erase_screen (zword win) { int i; if (hi (cwp->colour) != TRANSPARENT_COLOUR) os_erase_area (1, 1, h_screen_height, h_screen_width, -2); if ((short) win == -1) { split_window (0); set_window (0); reset_cursor (0); } for (i = 0; i < 8; i++) wp[i].line_count = 0; }/* erase_screen */
void z_erase_line (void) { zword pixels = zargs[0]; zword y, x; flush_buffer (); /* Clipping at the right margin of the current window */ if (--pixels == 0 || pixels > units_left ()) pixels = units_left (); /* Erase from cursor position */ y = cwp->y_pos + cwp->y_cursor - 1; x = cwp->x_pos + cwp->x_cursor - 1; os_erase_area (y, x, y + font_height - 1, x + pixels - 1); }/* z_erase_line */
/* * screen_erase_input * * Remove an input line that has already been printed from the screen * as if it was deleted by the player. This could be necessary during * playback. * */ void screen_erase_input (const zchar *buf) { if (buf[0] != 0) { int width = os_string_width (buf); zword y; zword x; cwp->x_cursor -= width; y = cwp->y_pos + cwp->y_cursor - 1; x = cwp->x_pos + cwp->x_cursor - 1; os_erase_area (y, x, y + font_height - 1, x + width - 1, -1); os_set_cursor (y, x); } }/* screen_erase_input */
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 */
void z_erase_picture (void) { int height, width; zword y = zargs[1]; zword x = zargs[2]; flush_buffer (); if (y == 0) /* use cursor line if y-coordinate is 0 */ y = cwp->y_cursor; if (x == 0) /* use cursor column if x-coordinate is 0 */ x = cwp->x_cursor; os_picture_data (zargs[0], &height, &width); y += cwp->y_pos - 1; x += cwp->x_pos - 1; os_erase_area (y, x, y + height - 1, x + width - 1); }/* z_erase_picture */
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 */
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 */