void z_save_undo( void ) { /* Check if undo is available first */ if ( undo_datap != NULL ) { /* Save the undo data and return success */ save_restore( NULL, UNDO_SAVE ); undo_valid = TRUE; store_operand( 1 ); } else { /* If no memory for data area then say undo is not available */ store_operand( ( zword_t ) - 1 ); } } /* z_save_undo */
void z_restore_undo( void ) { /* Check if undo is available first */ if ( undo_datap != NULL ) { /* If no undo save done then return an error */ if ( undo_valid == TRUE ) { /* Restore the undo data and return success */ save_restore( NULL, UNDO_RESTORE ); store_operand( 2 ); } else { store_operand( 0 ); } } else { /* If no memory for data area then say undo is not available */ store_operand( ( zword_t ) - 1 ); } } /* z_restore_undo */
int z_restore( int argc, zword_t table, zword_t bytes, zword_t name ) { char new_name[Z_FILENAME_MAX + Z_PATHNAME_MAX + 1]; char default_name[Z_FILENAME_MAX + Z_PATHNAME_MAX + 1]; FILE *afp; #if defined BUFFER_FILES char afpbuffer[BUFSIZ]; #endif int status; status = 0; if ( argc == 3 ) { get_default_name( default_name, name ); if ( get_file_name( new_name, default_name, GAME_LOAD_AUX ) == 0 ) { goto finished; } if ( ( afp = fopen( new_name, "rb" ) ) == NULL ) { goto finished; } #if defined BUFFER_FILES setbuf( afp, afpbuffer ); #endif status = fread( datap + table, bytes, 1, afp ); fclose( afp ); if ( status != 0 ) { strcpy( auxilary_name, default_name ); } status = !status; } else { /* Get the file name */ status = 1; if ( get_file_name( new_name, save_name, GAME_RESTORE ) == 0 ) { /* Do the restore operation */ if ( save_restore( new_name, GAME_RESTORE ) == 0 ) { /* Reset the status region (this is just for Seastalker) */ if ( h_type < V4 ) { z_split_window( 0 ); blank_status_line( ); } /* Cleanup file */ file_cleanup( new_name, GAME_SAVE ); /* Save the new name as the default file name */ strcpy( save_name, new_name ); /* Indicate success */ status = 0; } } } finished: /* Return result of save to Z-code */ if ( h_type < V4 ) { conditional_jump( status == 0 ); } else { store_operand( (zword_t)(( status == 0 ) ? 2 : 0) ); } return ( status ); } /* z_restore */
//***************************************************************************** // // This function restores the game state. // //***************************************************************************** int restore(void) { store_operand(0); return(1); }
//***************************************************************************** // // This function saves the current game state. This is a NOP since saving is // not supported. // //***************************************************************************** int save(void) { store_operand(0); return(1); }
//***************************************************************************** // // This function undoes a restore operation. // //***************************************************************************** void undo_restore(void) { store_operand((zword_t)-1); }
//***************************************************************************** // // This function undoes a save operation. // //***************************************************************************** void undo_save(void) { store_operand((zword_t)-1); }
void z_load( zword_t variable ) { store_operand( load_variable( variable ) ); } /* load */