From 0d16275af35998cccbd531b2e5f76d309d0cd4b8 Mon Sep 17 00:00:00 2001 From: Scott Duensing Date: Sun, 9 Sep 2018 20:27:54 -0500 Subject: [PATCH] Text now comes from the bottom of the screen. --- joeyio.c | 2 +- main.c | 2 + screen.c | 508 +++++++++++++++++++++++++++---------------------------- 3 files changed, 257 insertions(+), 255 deletions(-) diff --git a/joeyio.c b/joeyio.c index 74b5b22..246b762 100644 --- a/joeyio.c +++ b/joeyio.c @@ -16,8 +16,8 @@ void clear_line(void) { void clear_screen(void) { termClearScreen(); + termMoveCursor(1, screen_rows); jlDisplayPresent(); - termMoveCursor(1, 1); } diff --git a/main.c b/main.c index 3ca3d3b..fa582d4 100644 --- a/main.c +++ b/main.c @@ -101,6 +101,8 @@ int main(void) { termStart(font, 0, 0, 40, 25); termDestruciveBackspace(false); + termMoveCursor(1, 25); + termSaveCursor(); process_arguments("gamedata.z5"); configure(V1, V8); diff --git a/screen.c b/screen.c index 825ba7d..749ccd2 100644 --- a/screen.c +++ b/screen.c @@ -1,14 +1,14 @@ -/* $Id: screen.c,v 1.3 2000/07/05 15:20:34 jholder Exp $ +/* $Id: screen.c,v 1.3 2000/07/05 15:20:34 jholder Exp $ * -------------------------------------------------------------------- - * see doc/License.txt for License Information + * see doc/License.txt for License Information * -------------------------------------------------------------------- - * - * File name: $Id: screen.c,v 1.3 2000/07/05 15:20:34 jholder Exp $ - * - * Description: - * - * Modification history: + * + * File name: $Id: screen.c,v 1.3 2000/07/05 15:20:34 jholder Exp $ + * + * Description: + * + * Modification history: * $Log: screen.c,v $ * Revision 1.3 2000/07/05 15:20:34 jholder * Updated code to remove warnings. @@ -44,49 +44,49 @@ void z_set_window( zword_t w ) { - int row, col; + int row, col; - flush_buffer( FALSE ); + flush_buffer( FALSE ); - screen_window = w; + screen_window = w; - if ( screen_window == STATUS_WINDOW ) - { + if ( screen_window == STATUS_WINDOW ) + { - /* Status window: disable formatting and select status window */ + /* Status window: disable formatting and select status window */ - formatting = OFF; - scripting_disable = ON; - select_status_window( ); + formatting = OFF; + scripting_disable = ON; + select_status_window( ); - /* Put cursor at top of status area */ + /* Put cursor at top of status area */ - if ( h_type < V4 ) - move_cursor( 2, 1 ); - else - move_cursor( 1, 1 ); + if ( h_type < V4 ) + move_cursor( 2, 1 ); + else + move_cursor( 1, 1 ); - } - else - { + } + else + { - /* Text window: enable formatting and select text window */ + /* Text window: enable formatting and select text window */ - select_text_window( ); - scripting_disable = OFF; - formatting = ON; + select_text_window( ); + scripting_disable = OFF; + formatting = ON; - /* Move cursor if it has been left in the status area */ + /* Move cursor if it has been left in the status area */ - get_cursor_position( &row, &col ); - if ( row <= status_size ) - move_cursor( status_size + 1, 1 ); + get_cursor_position( &row, &col ); + if ( row <= status_size ) + move_cursor( status_size + 1, 1 ); - } + } - /* Force text attribute to normal rendition */ + /* Force text attribute to normal rendition */ - set_attribute( NORMAL ); + set_attribute( NORMAL ); } /* z_set_window */ @@ -102,59 +102,59 @@ void z_set_window( zword_t w ) void z_split_window( zword_t lines ) { - /* Maximum status window size is 255 */ + /* Maximum status window size is 255 */ - lines &= 0xff; + lines &= 0xff; - /* The top line is always set for V1 to V3 games, so account for it here. */ + /* The top line is always set for V1 to V3 games, so account for it here. */ - if ( h_type < V4 ) - lines++; + if ( h_type < V4 ) + lines++; - if ( lines ) - { + if ( lines ) + { - /* If size is non zero the turn on the status window */ + /* If size is non zero the turn on the status window */ - status_active = ON; + status_active = ON; - /* Bound the status size to one line less than the total screen height */ + /* Bound the status size to one line less than the total screen height */ - if ( lines > ( zword_t ) ( screen_rows - 1 ) ) - status_size = ( zword_t ) ( screen_rows - 1 ); - else - status_size = lines; + if ( lines > ( zword_t ) ( screen_rows - 1 ) ) + status_size = ( zword_t ) ( screen_rows - 1 ); + else + status_size = lines; - /* Create the status window, or resize it */ + /* Create the status window, or resize it */ - create_status_window( ); + create_status_window( ); - /* Need to clear the status window for type 3 games */ + /* Need to clear the status window for type 3 games */ - if ( h_type < V4 ) - z_erase_window( STATUS_WINDOW ); + if ( h_type < V4 ) + z_erase_window( STATUS_WINDOW ); - } - else - { + } + else + { - /* Lines are zero so turn off the status window */ + /* Lines are zero so turn off the status window */ - status_active = OFF; + status_active = OFF; - /* Reset the lines written counter and status size */ + /* Reset the lines written counter and status size */ - lines_written = 0; - status_size = 0; + lines_written = 0; + status_size = 0; - /* Delete the status window */ + /* Delete the status window */ - delete_status_window( ); + delete_status_window( ); - /* Return cursor to text window */ + /* Return cursor to text window */ - select_text_window( ); - } + select_text_window( ); + } } /* z_split_window */ @@ -167,26 +167,26 @@ void z_split_window( zword_t lines ) void z_erase_window( zword_t w ) { - flush_buffer( TRUE ); + flush_buffer( TRUE ); - if ( ( zbyte_t ) w == ( zbyte_t ) Z_SCREEN ) - { - clear_screen( ); - } - else if ( ( zbyte_t ) w == TEXT_WINDOW ) - { - clear_text_window( ); - } - else if ( ( zbyte_t ) w == STATUS_WINDOW ) - { - clear_status_window( ); - return; - } + if ( ( zbyte_t ) w == ( zbyte_t ) Z_SCREEN ) + { + clear_screen( ); + } + else if ( ( zbyte_t ) w == TEXT_WINDOW ) + { + clear_text_window( ); + } + else if ( ( zbyte_t ) w == STATUS_WINDOW ) + { + clear_status_window( ); + return; + } - if ( h_type > V4 ) - move_cursor( 1, 1 ); - else - move_cursor( screen_rows, 1 ); + //if ( h_type > V4 ) + // move_cursor( 1, 1 ); + //else + move_cursor( screen_rows, 1 ); } /* z_erase_window */ @@ -199,8 +199,8 @@ void z_erase_window( zword_t w ) void z_erase_line( zword_t flag ) { - if ( flag == TRUE ) - clear_line( ); + if ( flag == TRUE ) + clear_line( ); } /* z_erase_line */ /* @@ -212,17 +212,17 @@ void z_erase_line( zword_t flag ) void z_set_cursor( zword_t row, zword_t column ) { - /* Can only move cursor if format mode is off and in status window */ + /* Can only move cursor if format mode is off and in status window */ - if ( formatting == OFF && screen_window == STATUS_WINDOW ) - { - move_cursor( row, column ); - } + if ( formatting == OFF && screen_window == STATUS_WINDOW ) + { + move_cursor( row, column ); + } #ifdef STRICTZ - else - { - report_strictz_error( STRZERR_MOV_CURSOR, "@set_cursor called outside the status window!" ); - } + else + { + report_strictz_error( STRZERR_MOV_CURSOR, "@set_cursor called outside the status window!" ); + } #endif } /* z_set_cursor */ @@ -235,11 +235,11 @@ void z_set_cursor( zword_t row, zword_t column ) static void pad_line( int column ) { - int i; + int i; - for ( i = status_pos; i < column; i++ ) - write_char( ' ' ); - status_pos = column; + for ( i = status_pos; i < column; i++ ) + write_char( ' ' ); + status_pos = column; } /* pad_line */ /* @@ -251,82 +251,82 @@ static void pad_line( int column ) void z_show_status( void ) { - int i, count = 0, end_of_string[3]; - char *status_part[3]; + int i, count = 0, end_of_string[3]; + char *status_part[3]; - /* Move the cursor to the top line of the status window, set the reverse - * rendition and print the status line */ + /* Move the cursor to the top line of the status window, set the reverse + * rendition and print the status line */ - z_set_window( STATUS_WINDOW ); - move_cursor( 1, 1 ); - set_attribute( REVERSE ); + z_set_window( STATUS_WINDOW ); + move_cursor( 1, 1 ); + set_attribute( REVERSE ); - /* Redirect output to the status line buffer */ + /* Redirect output to the status line buffer */ - z_output_stream( 3, 0 ); + z_output_stream( 3, 0 ); - /* Print the object description for global variable 16 */ + /* Print the object description for global variable 16 */ - pad_line( 1 ); - status_part[count] = &status_line[status_pos]; - if ( load_variable( 16 ) != 0 ) - z_print_obj( load_variable( 16 ) ); - end_of_string[count++] = status_pos; - status_line[status_pos++] = '\0'; + pad_line( 1 ); + status_part[count] = &status_line[status_pos]; + if ( load_variable( 16 ) != 0 ) + z_print_obj( load_variable( 16 ) ); + end_of_string[count++] = status_pos; + status_line[status_pos++] = '\0'; - if ( get_byte( H_CONFIG ) & CONFIG_TIME ) - { + if ( get_byte( H_CONFIG ) & CONFIG_TIME ) + { - /* If a time display print the hours and minutes from global - * variables 17 and 18 */ + /* If a time display print the hours and minutes from global + * variables 17 and 18 */ - pad_line( screen_cols - 21 ); - status_part[count] = &status_line[status_pos]; - write_string( " Time: " ); - print_time( load_variable( 17 ), load_variable( 18 ) ); - end_of_string[count++] = status_pos; - status_line[status_pos++] = '\0'; - } - else - { + pad_line( screen_cols - 21 ); + status_part[count] = &status_line[status_pos]; + write_string( " Time: " ); + print_time( load_variable( 17 ), load_variable( 18 ) ); + end_of_string[count++] = status_pos; + status_line[status_pos++] = '\0'; + } + else + { - /* If a moves/score display print the score and moves from global - * variables 17 and 18 */ + /* If a moves/score display print the score and moves from global + * variables 17 and 18 */ - pad_line( screen_cols - 31 ); - status_part[count] = &status_line[status_pos]; - write_string( " Score: " ); - z_print_num( load_variable( 17 ) ); - end_of_string[count++] = status_pos; - status_line[status_pos++] = '\0'; + pad_line( screen_cols - 31 ); + status_part[count] = &status_line[status_pos]; + write_string( " Score: " ); + z_print_num( load_variable( 17 ) ); + end_of_string[count++] = status_pos; + status_line[status_pos++] = '\0'; - pad_line( screen_cols - 15 ); - status_part[count] = &status_line[status_pos]; - write_string( " Moves: " ); - z_print_num( load_variable( 18 ) ); - end_of_string[count++] = status_pos; - status_line[status_pos++] = '\0'; - } + pad_line( screen_cols - 15 ); + status_part[count] = &status_line[status_pos]; + write_string( " Moves: " ); + z_print_num( load_variable( 18 ) ); + end_of_string[count++] = status_pos; + status_line[status_pos++] = '\0'; + } - /* Pad the end of status line with spaces then disable output redirection */ + /* Pad the end of status line with spaces then disable output redirection */ - pad_line( screen_cols ); - z_output_stream( ( zword_t ) - 3, 0 ); + pad_line( screen_cols ); + z_output_stream( ( zword_t ) - 3, 0 ); - /* Try and print the status line for a proportional font screen. If this - * fails then remove embedded nulls in status line buffer and just output - * it to the screen */ + /* Try and print the status line for a proportional font screen. If this + * fails then remove embedded nulls in status line buffer and just output + * it to the screen */ - if ( print_status( count, status_part ) == FALSE ) - { - for ( i = 0; i < count; i++ ) - status_line[end_of_string[i]] = ' '; - status_line[status_pos] = '\0'; - write_string( status_line ); - } + if ( print_status( count, status_part ) == FALSE ) + { + for ( i = 0; i < count; i++ ) + status_line[end_of_string[i]] = ' '; + status_line[status_pos] = '\0'; + write_string( status_line ); + } - set_attribute( NORMAL ); - z_set_window( TEXT_WINDOW ); + set_attribute( NORMAL ); + z_set_window( TEXT_WINDOW ); } /* z_show_status */ @@ -340,29 +340,29 @@ void z_show_status( void ) void blank_status_line( void ) { - /* Move the cursor to the top line of the status window, set the reverse - * rendition and print the status line */ + /* Move the cursor to the top line of the status window, set the reverse + * rendition and print the status line */ - z_set_window( STATUS_WINDOW ); - move_cursor( 1, 1 ); - set_attribute( REVERSE ); + z_set_window( STATUS_WINDOW ); + move_cursor( 1, 1 ); + set_attribute( REVERSE ); - /* Redirect output to the status line buffer and pad the status line with - * spaces then disable output redirection */ + /* Redirect output to the status line buffer and pad the status line with + * spaces then disable output redirection */ - z_output_stream( 3, 0 ); - pad_line( screen_cols ); - status_line[status_pos] = '\0'; - z_output_stream( ( zword_t ) - 3, 0 ); + z_output_stream( 3, 0 ); + pad_line( screen_cols ); + status_line[status_pos] = '\0'; + z_output_stream( ( zword_t ) - 3, 0 ); - /* Write the status line */ + /* Write the status line */ - write_string( status_line ); + write_string( status_line ); - /* Turn off attributes and return to text window */ + /* Turn off attributes and return to text window */ - set_attribute( NORMAL ); - z_set_window( TEXT_WINDOW ); + set_attribute( NORMAL ); + z_set_window( TEXT_WINDOW ); } /* blank_status_line */ @@ -375,8 +375,8 @@ void blank_status_line( void ) void output_string( const char *s ) { - while ( *s ) - output_char( *s++ ); + while ( *s ) + output_char( *s++ ); } /* output_string */ /* @@ -388,8 +388,8 @@ void output_string( const char *s ) void output_line( const char *s ) { - output_string( s ); - output_new_line( ); + output_string( s ); + output_new_line( ); } /* output_line */ /* @@ -401,13 +401,13 @@ void output_line( const char *s ) void output_char( int c ) { - /* If output is enabled then either select the rendition attribute - * or just display the character */ + /* If output is enabled then either select the rendition attribute + * or just display the character */ - if ( outputting == ON ) - { - display_char( (unsigned int)(c & 0xff) ); - } + if ( outputting == ON ) + { + display_char( (unsigned int)(c & 0xff) ); + } } /* output_char */ /* @@ -419,53 +419,53 @@ void output_char( int c ) void output_new_line( void ) { - int row, col; + int row, col; - /* Don't print if output is disabled or replaying commands */ + /* Don't print if output is disabled or replaying commands */ - if ( outputting == ON ) - { + if ( outputting == ON ) + { - if ( formatting == ON && screen_window == TEXT_WINDOW ) - { + if ( formatting == ON && screen_window == TEXT_WINDOW ) + { - /* If this is the text window then scroll it up one line */ + /* If this is the text window then scroll it up one line */ - scroll_line( ); + scroll_line( ); - /* See if we have filled the screen. The spare line is for - * the [MORE] message - */ + /* See if we have filled the screen. The spare line is for + * the [MORE] message + */ - if ( ++lines_written >= ( ( screen_rows - top_margin ) - status_size - 1 ) ) - { + if ( ++lines_written >= ( ( screen_rows - top_margin ) - status_size - 1 ) ) + { - /* Display the new status line while the screen in paused */ + /* Display the new status line while the screen in paused */ - if ( h_type < V4 ) - z_show_status( ); + if ( h_type < V4 ) + z_show_status( ); - /* Reset the line count and display the more message */ + /* Reset the line count and display the more message */ - lines_written = 0; + lines_written = 0; - if ( replaying == OFF ) - { - get_cursor_position( &row, &col ); - output_string( "[MORE]" ); - ( void ) input_character( 0 ); - move_cursor( row, col ); - output_string( " " ); - move_cursor( row, col ); - /* clear_line (); */ - } - } - } - else - /* If this is the status window then just output a new line */ + if ( replaying == OFF ) + { + get_cursor_position( &row, &col ); + output_string( "[MORE]" ); + ( void ) input_character( 0 ); + move_cursor( row, col ); + output_string( " " ); + move_cursor( row, col ); + /* clear_line (); */ + } + } + } + else + /* If this is the status window then just output a new line */ - output_char( '\n' ); - } + output_char( '\n' ); + } } /* output_new_line */ @@ -482,40 +482,40 @@ void output_new_line( void ) void z_print_table( int argc, zword_t * argv ) { - unsigned long address; - unsigned int width, height; - unsigned int row, column; + unsigned long address; + unsigned int width, height; + unsigned int row, column; - /* Supply default arguments */ + /* Supply default arguments */ - if ( argc < 3 ) - argv[2] = 1; + if ( argc < 3 ) + argv[2] = 1; - /* Don't do anything if the window is zero high or wide */ + /* Don't do anything if the window is zero high or wide */ - if ( argv[1] == 0 || argv[2] == 0 ) - return; + if ( argv[1] == 0 || argv[2] == 0 ) + return; - /* Get coordinates of top left corner of rectangle */ + /* Get coordinates of top left corner of rectangle */ - get_cursor_position( ( int * ) &row, ( int * ) &column ); + get_cursor_position( ( int * ) &row, ( int * ) &column ); - address = argv[0]; + address = argv[0]; - /* Write text in width * height rectangle */ + /* Write text in width * height rectangle */ - for ( height = 0; height < argv[2]; height++ ) - { + for ( height = 0; height < argv[2]; height++ ) + { - for ( width = 0; width < argv[1]; width++ ) - write_char( read_data_byte( &address ) ); + for ( width = 0; width < argv[1]; width++ ) + write_char( read_data_byte( &address ) ); - /* Put cursor back to lefthand side of rectangle on next line */ + /* Put cursor back to lefthand side of rectangle on next line */ - if ( height != (unsigned)( argv[2] - 1 ) ) - move_cursor( ++row, column ); + if ( height != (unsigned)( argv[2] - 1 ) ) + move_cursor( ++row, column ); - } + } } /* z_print_table */ @@ -528,15 +528,15 @@ void z_print_table( int argc, zword_t * argv ) void z_set_font( zword_t new_font ) { - zword_t old_font = font; + zword_t old_font = font; - if ( new_font != old_font ) - { - font = new_font; - set_font( font ); - } + if ( new_font != old_font ) + { + font = new_font; + set_font( font ); + } - store_operand( old_font ); + store_operand( old_font ); } /* z_set_font */ @@ -564,14 +564,14 @@ void z_set_font( zword_t new_font ) void z_set_colour( zword_t foreground, zword_t background ) { - if ( ( ZINT16 ) foreground < -1 || ( ZINT16 ) foreground > 9 || ( ZINT16 ) background < -1 || - ( ZINT16 ) background > 9 ) - fatal( "Bad colour!" ); + if ( ( ZINT16 ) foreground < -1 || ( ZINT16 ) foreground > 9 || ( ZINT16 ) background < -1 || + ( ZINT16 ) background > 9 ) + fatal( "Bad colour!" ); - flush_buffer( FALSE ); + flush_buffer( FALSE ); - set_colours( foreground, background ); + set_colours( foreground, background ); - return; + return; } /* z_set_colour */