⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 screen.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 2 页
字号:
#ifndef lintstatic char	*sccsid = "@(#)screen.c	4.1	(ULTRIX)	11/23/87";#endif lint/************************************************************************ *									* *			Copyright (c) 1985 by				* *		Digital Equipment Corporation, Maynard, MA		* *			All rights reserved.				* *									* *   This software is furnished under a license and may be used and	* *   copied  only  in accordance with the terms of such license and	* *   with the  inclusion  of  the  above  copyright  notice.   This	* *   software  or  any  other copies thereof may not be provided or	* *   otherwise made available to any other person.  No title to and	* *   ownership of the software is hereby transferred.			* *									* *   The information in this software is subject to change  without	* *   notice  and should not be construed as a commitment by Digital	* *   Equipment Corporation.						* *									* *   Digital assumes no responsibility for the use  or  reliability	* *   of its software on equipment which is not supplied by Digital.	* *									* ************************************************************************/* * screen.c * * Name:	starship * Purpose:	Screen update routines are in this file. *		They update the screen image from the shared data. * Environment:	Ultrix-32, optionally with shared memory * Compile:	see Makefile * Date:	April 18, 1985 * Author:	Alan Delorey * Remarks:    These are the voyages of the independent star ships.Whose lifetime mission: To explore strange new galaxies,		        To seek out and destroy other star ships,		        To boldly go where no other star ship dares!*//* * Modification history * * 4-18-85 *	Derived from former file "two.c" which had ship action & screen *	update routines together.  Ship action & screen update are now *	split into action.c & screen.c */#include "star.h"#include <sys/types.h>#include <sys/ipc.h>#include <sys/shm.h>#include <curses.h>	/* also includes <sgtty.h> and <stdio.h> *//* external variables */extern struct univ *uptr;		/* ptr to shared memory segment */#ifdef SHMEMextern int shmid;			/* used to remove shared seg */#endif SHMEM/* Define new access paths to variables that are now in one struct, * to facilitate shared memory */#define universe uptr->quadrants#define num_users uptr->Num_users#define wait uptr->Wait#define ships uptr->Ships#define drones uptr->Dronesextern char bell;		/* bell char *//*****************************************************************************//*									     *//*    		START INTERNAL PROCEDURES				     *//*									     *//*****************************************************************************/update_screen (ship_ch)    char ship_ch;    /* Udates the screen for (the present caller (ship_ch).       The display flags in ship record are checked to see which       fields need to be updated.    */    {     char tmp_str[25];  /* to convert numbers to string */    register struct ship *pships;    register int bi;    printf_srscan(ship_ch);    printf_lrscan(ship_ch);    pships = ships + (ship_ch - A);    if (pships->dis_msg)	 {		/* display message on user's screen */	 pships->dis_msg = false;	 pships->msg_timer = 0;	 move_to(MESSAGER, MESSAGEC);	 clear_to_eol();	 refresh_scr();	 move_to(MESSAGER, MESSAGEC);	 char_out (bell);	 string_out (pships->msg_buf);	 clear_to_eol();	 refresh_scr();	 /*	  * radio messages from ships start with "#-#".  So if 2nd char is a	  * '-' then we assume its a message from another ship & save its	  * coordinates.	  */	 if (pships->msg_buf[1] == '-')	     {	     pships->radiorow = pships->msg_buf[0] - 48;	     pships->radiocol = pships->msg_buf[2] - 48;	     }	 }    else {	 pships->msg_timer++;	 if (pships->msg_timer > MSG_TIME)	     {	     /* clean up msg line */	     move_to (MESSAGER, MESSAGEC);	     clear_to_eol();	     refresh_scr();	     pships->msg_timer = 0;	     };	 };    if (pships->dis_map)	{	pships->dis_map = false;	pships->map_timer = 0;	pships->dis_dir = true;	draw_map();	switch (pships->bearing)	    {	    case 1:		move_to(MAPDISPR + pships->q_row + 2, MAPDISPC + pships->q_col);		char_out('/');		break;	    case 2:		move_to(MAPDISPR + pships->q_row + 2, MAPDISPC + pships->q_col+1);		char_out('|');		break;	    case 3:		move_to(MAPDISPR + pships->q_row + 2, MAPDISPC + pships->q_col+2);		char_out('\\');		break;	    case 4:		move_to(MAPDISPR + pships->q_row + 1, MAPDISPC + pships->q_col);		char_out('-');		break;	    case 6:		move_to(MAPDISPR + pships->q_row + 1, MAPDISPC + pships->q_col+2);		char_out('-');		break;	    case 7:		move_to(MAPDISPR + pships->q_row, MAPDISPC + pships->q_col);		char_out('\\');		break;	    case 8:		move_to(MAPDISPR + pships->q_row, MAPDISPC + pships->q_col + 1);		char_out('|');		break;	    case 9:		move_to(MAPDISPR + pships->q_row, MAPDISPC + pships->q_col + 2);		char_out('/');		break;	    }	/* end switch (bearing) */	for (bi = 0; bi < NUMBASES; bi++)	    if (pships->bases[bi][0] != -1)		{		move_to(MAPDISPR + pships->bases[bi][0] + 1,			MAPDISPC + pships->bases[bi][1] + 1);		char_out('+');		}	if (pships->radiorow != -1)	    {	    move_to(MAPDISPR + pships->radiorow + 1, MAPDISPC + pships->radiocol + 1);	    char_out('r');	    }	if (pships->locater != -1)	    {	    move_to(MAPDISPR + pships->locater + 1, MAPDISPC + pships->locatec + 1);	    char_out('l');	    }	move_to(MAPDISPR + pships->q_row + 1, MAPDISPC + pships->q_col + 1);	char_out(pships->ship_ch);	}   /* end if (dis_map) */    else	{	if (pships->dis_dir)	    {	    pships->map_timer++;	    if (pships->map_timer > MAP_TIME)		{		pships->dis_dir = false;		draw_dir();		}	    }	}    if (pships->dis_energy)	 {	 sprintf (tmp_str, "%5d", pships->energy);	 move_to(ENERGYR,ENERGYC);	 string_out (tmp_str);	 pships->dis_energy = false;	 };    if (pships->shield_time > 0)	 {	 pships->shield_time = pships->shield_time - 1;	 if (pships->shield_time == 0)	      strcpy(tmp_str, "    0");	 else sprintf (tmp_str, " *%3d", pships->shield_time);	 move_to(SHIELDSR, SHIELDSC);	 string_out (tmp_str);	 }    else if (pships->dis_shields)	     {	     sprintf (tmp_str,"%5d", pships->shields);	     move_to(SHIELDSR, SHIELDSC);	     string_out (tmp_str);	     pships->dis_shields = false;	     };    if (pships->torp_time > 0)	 {	 pships->torp_time--;	 if (pships->torp_time == 0)	      pships->dis_torpedos = true;	 else {	      sprintf (tmp_str, "*%3d", pships->torp_time);	      move_to(TORPR, TORPC);	      string_out (tmp_str);	      };	 };    if (pships->dis_torpedos)	 {	 sprintf (tmp_str,"%4d", pships->torpedos);	 move_to(TORPR,TORPC);	 string_out (tmp_str);	 pships->dis_torpedos = false;	 };    if (pships->phasers > 0)	 {	 pships->phasers--;	 if (pships->phasers == 0)	      strcpy(tmp_str, " opr");	 else sprintf (tmp_str, "*%3d", pships->phasers);	 move_to(PHASERR, PHASERC);	 string_out (tmp_str);	 };    if (pships->warp_drive > 0)	 {	 pships->warp_drive = pships->warp_drive - 1;	 if (pships->warp_drive == 0)	      strcpy(tmp_str, " opr");	 else sprintf (tmp_str, "*%3d", pships->warp_drive);	 move_to(WARPDRIVER,WARPDRIVEC);	 string_out (tmp_str);	 };    if (pships->impulse > 0)	 {	 pships->impulse = pships->impulse - 1;	 if (pships->impulse == 0)	      strcpy(tmp_str, " opr");	 else sprintf (tmp_str, "*%3d", pships->impulse);	 move_to(IMPULSER, IMPULSEC);	 string_out (tmp_str);	 };    if (pships->life_supp_time > 0)	 {	 pships->life_supp_time -= 1;	 if (pships->life_supp_time == 0)	      pships->life_support = GREEN;	 switch ((int)pships->life_support)	 {	     case 0:		strcpy (tmp_str,"   RED");		break;	     case 1:		strcpy (tmp_str,"YELLOW");		break;	     case 2:		strcpy (tmp_str," GREEN");		break;	 };	 move_to(LIFESUPR, LIFESUPC);	 string_out (tmp_str);	 };    if (pships->sr_scan > 0)	 {	 pships->sr_scan = pships->sr_scan - 1;	 if (pships->sr_scan == 0)	      strcpy(tmp_str, " opr");	 else sprintf (tmp_str, "*%3d", pships->sr_scan);	 move_to(SRCONDR, SRCONDC);	 string_out (tmp_str);	 };    if (pships->lr_scan > 0)	 {	 pships->lr_scan = pships->lr_scan - 1;	 if (pships->lr_scan == 0)	      strcpy(tmp_str, " opr");	 else sprintf (tmp_str, "*%3d", pships->lr_scan);	 move_to(LRCONDR, LRCONDC);	 string_out (tmp_str);	 };    if (pships->radio > 0)	 {	 pships->radio = pships->radio - 1;	 if (pships->radio == 0)	      strcpy(tmp_str, " opr");	 else sprintf (tmp_str, "*%3d", pships->radio);	 move_to(RADIOR, RADIOC);	 string_out (tmp_str);	 };    if (pships->sensors > 0)	 {	 pships->sensors = pships->sensors - 1;	 if (pships->sensors == 0)	      strcpy(tmp_str, " opr");	 else sprintf (tmp_str, "*%3d", pships->sensors);	 move_to(SENSORR, SENSORC);	 string_out (tmp_str);	 };    if (pships->cloaking > 0)	 {	 pships->cloaking = pships->cloaking - 1;	 if (pships->cloaking == 0)	      strcpy(tmp_str, " opr");	 else sprintf (tmp_str, "*%3d", pships->cloaking);	 move_to(CLOAKINGR, CLOAKINGC);	 string_out (tmp_str);	 };    if (pships->dis_quad)	 {	 sprintf (tmp_str, "%d-%d", pships->q_row, pships->q_col);	 move_to(QUADR,QUADC);	 string_out (tmp_str);	 pships->dis_quad = false;	 };    if ((pships->warp_speed > 0)||(pships->dis_sector))	 {	 sprintf (tmp_str, "%d-%d", pships->s_row, pships->s_col);	 move_to(SECTORR,SECTORC);	 string_out (tmp_str);	 pships->dis_sector = false;	 };    if (pships->dis_warp_set)	 {	 sprintf (tmp_str, "%3.1f",pships->warp_set);	 move_to(WARPSETR,WARPSETC);	 string_out (tmp_str);	 pships->dis_warp_set = false;	 };    if (pships->dis_warp_speed)	 {	 sprintf (tmp_str, "%3.1f", pships->warp_speed);	 move_to(WARPSPEEDR,WARPSPEEDC);	 string_out (tmp_str);	 pships->dis_warp_speed = false;	 };    if (pships->dis_bearing)	 {	 sprintf (tmp_str, "%d", pships->bearing);	 move_to(BEARINGR,BEARINGC);	 string_out (tmp_str);	 pships->dis_bearing = false;	 };    /* if anyone entered or left the game, update fleet display */    if (pships->dis_fleet)	 {	 pships->dis_fleet = false;	 update_fleet();	 };    /* refresh_scr to show long and short range scan, and ship status displays */    refresh_scr();    };  /* proc update screen */printf_srscan(ship_ch)    char ship_ch;	/* Writes out the srscan area around a ship.  It is assumed that the	 * ship will appear in the middle (the SHDISPR,SHDISPC location)	 * of the srscan.	*/		{	register int i,j;	/* loop indicies */	register struct ship *pships; /* pointer to ship structure */	int sqr;		/* starting quad row */	int sqc;		/* starting quad col */	int ssr;		/* starting sector row */	int ssc;		/* starting sector col */	int cqr;		/* current quad row */	int cqc;		/* current quad col */	register int csr;	/* current sector row */	register int csc;	/* current sector col */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -