{$ifndef unix}
{$A+,B-,D+,E+,F-,G+,I+,L+,N+,O+,P+,Q-,R-,S+,T-,V-,X+,Y+}
{$else}
{$B-,I+,S-,T-,X+}
{$endif}
unit menus3;

interface

procedure planmenu(rasse,id,x,y,z,Location:longint);

implementation

uses
 tstring,
 types,
 utils,
 kb,
 evgraph,
{$ifndef unix}
 crt,
{$else}
 xcrt,
{$endif}
 grafik,
 data,
 maus2kb,
 schedule,
 listen,
 menus1,
 menus2,
 menus4,
 menus5,
 menus6;

procedure planmenu(rasse,id,x,y,z,Location:longint);
var
 sd,
 md:t_bdata;

 IsShip,
 IsOwnShip,
 IsOpponent,
 tIsShip,
 tIsOpponent,
 CanFight:boolean;
 Missionen:word;
 Showthing,
 tshowthing:word;

 tPlanetNr,

 BaseNr,
 tBaseNr,

 shipnr,
 tshipnr,

 oshipnr,
 toshipnr:longint;

 planet,
 tplanet:tp_planet;

 base,
 tbase:tp_starbase;

 ship,
 oship,
 tship,
 toship:tp_schiff;

 redraw:byte;
 dx,
 dy,
 dz,
 dt,
 targetx,
 targety,
 targetz:sint;
 s:string;
 c:char;
 cs:byte;
 tm:word;
 st:array[1..6] of char;

 procedure missionselect;
 var
  i:byte;
  d:t_bdata;
 begin
  initb(d,8,16*20,21,8,15,8);
  window(6,16*20-2,9+21*8,16*20+1+8*16);
  writeg(d,#12'Option:');
  for i:=0 to 6 do writeg(d,#13#10#0'C'#$8c+char(i+49)+':'#0'C'#$8e+pmissionen[i]);
  repeat
   i:=byte(kbreadkey);
   if i=0 then kbreadkey
   else if byte(i-49)<7 then begin
    planet^.mission:=i-49;
    exit;
   end else if i=27 then exit;
  until false;;
 end;

 procedure tastatur;
 begin
  with planet^ do repeat
   if redraw<>3 then begin
    DisplayStars(rasse,x,y,z,targetx,targety,targetz);
    begin
     tPlanetNr:=PlanID(targetx,targety,targetz);
     tplanet:=getplan(tplanetnr);
     tBaseNr:=BaseID(targetx,targety,targetz);
     tbase:=getbase(tBaseNr);
     if (tshowthing<>3)
     or(tship=nil)
     or(tship^.posx<>targetx)
     or(tship^.posy<>targety)
     or(tship^.posz<>targetz)
     then begin
      tshipnr:=firstship(rasse,targetx,targety,targetz,5);
      if tshipnr=id_nr then tshipnr:=nextship(tshipnr,rasse,targetx,targety,targetz,5);
      if tshipnr=id_nr then tshipnr:=-1;
      tship:=getship(tshipnr);
     end;
     if (tshowthing<>4)
     or(toship=nil)
     or(toship^.posx<>targetx)
     or(toship^.posy<>targety)
     or(toship^.posz<>targetz)
     then begin
      toshipnr:=firstship(rasse,targetx,targety,targetz,7);
      if toshipnr=id_nr then tshipnr:=nextship(toshipnr,rasse,targetx,targety,targetz,7);
      if toshipnr=id_nr then toshipnr:=-1;
      toship:=getship(toshipnr);
     end;
     tisopponent:=(toshipnr<>-1)or(tbasenr<>-1)and(tbase^.owner<>rasse);
     tIsShip:=tshipnr<>-1;
    end;
    writeg(md,#12#0'C'#$f'Auf: '#0'C'#$e+l2s(posx,5,true,false,false)+'X'+
		  l2s(posy,5,true,false,false)+'Y'+l2s(posz,5,true,false,false)+'Z'#0'C'#$7#13#10);
    if BaseNr<>-1 then begin
     if showthing=0 then showthing:=2;
     if showthing=2 then writeg(md,#0'C'#$e);
     writeg(md,'<B>asis '#0'C'#$7);
    end;
    if isship then begin
     if showthing=0 then showthing:=3;
     if showthing=3 then writeg(md,#0'C'#$e);
     writeg(md,'<S>chiff '#0'C'#$7);
    end;
    if Oshipnr<>-1 then begin
     if showthing=0 then showthing:=4;
     if showthing=4 then writeg(md,#0'C'#$c);
     writeg(md,'<G>egner '#0'C'#$7);
    end;
    case showthing of
     1:begin
      writeg(md,#13#10#0'C'#$c'X:'#0'C'#$e+planet^.name+#13#10);
      with ship^
      do if (basenr<>-1) then begin
       writeg(md,rassen[base^.owner]+#13#10);
      end else if planet^.racetyp=rasse then begin
       writeg(md,rassen[planet^.racetyp]+#13#10);
      end else writeg(md,#10);
     end;
     2:writeg(md,#13#10#0'C'#$c'X:'#0'C'#$e+base^.name+#13#10+
		       rassen[base^.owner]+#13#10);
     3:writeg(md,#13#10#0'C'#$c'X:'#0'C'#$e+ship^.schiffname+#13#10#10);
     4:writeg(md,#13#10#0'C'#$c'X:'#0'C'#$e+oship^.schiffname+#13#10+
		       rassen[oship^.owner]+#13#10);
    else
     writeg(md,#13#10#10#10);
    end;
    writeg(md,#0'C'#$c'N'#0'C'#$f'ach:'#0'C'#$e+l2s(targetx,5,true,false,false)+'X'+
		  l2s(targety,5,true,false,false)+'Y'+l2s(targetz,5,true,false,false)+'Z');
    if mlock then writeg(md,'  '#0'C'#$40'MLOCK');
    writeg(md,#0'C'#$7#13#10);
    if (tPlanetNr<>-1)and(tplanetnr<>id) then begin
     if tshowthing=0 then begin
      tshowthing:=1;
      sound(3000);kbdelay(250000);nosound;mreset;kbreset;
     end;
     if tshowthing=1 then writeg(md,#0'C'#$e);
     writeg(md,'<P>lanet '#0'C'#$7);
    end else if tshowthing=1 then tshowthing:=0;
    if tBaseNr<>-1 then begin
     if tshowthing=0 then begin
      tshowthing:=2;
      sound(3000);kbdelay(250000);nosound;mreset;kbreset;
     end;
     if tshowthing=2 then writeg(md,#0'C'#$e);
     writeg(md,'<B>asis '#0'C'#$7);
    end else if tshowthing=2 then tshowthing:=0;
    if tisship then begin
     if tshowthing=0 then begin
      tshowthing:=3;
      sound(2000);kbdelay(250000);nosound;mreset;kbreset;
     end;
     if tshowthing=3 then begin
      writeg(md,#0'C'#$e);
     end;
     writeg(md,'<S>chiffe '#0'C'#$7);
    end else if tshowthing=3 then tshowthing:=0;
    if toShipNr<>-1 then begin
     if tshowthing=0 then begin
      tshowthing:=4;
      sound(2000);kbdelay(250000);nosound;mreset;kbreset;
     end;
     if tshowthing=4 then writeg(md,#0'C'#$c);
     writeg(md,'<G>egner '#0'C'#$7);
    end else if tshowthing=4 then tshowthing:=0;
    dx:=dist(posx,posy,posz,targetx,targety,targetz);
    case tshowthing of
     1:begin
      writeg(md,#13#10#0'C'#$c'Y:'#0'C'#$e+tplanet^.name+#13#10);
      with tship^
      do if (tbasenr<>-1) then begin
       writeg(md,rassen[tbase^.owner]+#13#10);
      end else if tplanet^.racetyp=rasse then begin
       writeg(md,rassen[tplanet^.racetyp]+#13#10);
      end else writeg(md,#10);
      if dx<=75 then showph(336,0,tplanet^.bild)
      else filledrectangle(336,0,336+31,31,0);
     end;
     2:begin
      writeg(md,#13#10#0'C'#$c'Y:'#0'C'#$e+tbase^.name+#13#10+
		       rassen[tbase^.owner]+#13#10);
      if dx<=75 then showph(336,0,169)
      else filledrectangle(336,0,336+31,31,0);
     end;
     3:begin
      writeg(md,#13#10#0'C'#$c'Y:'#0'C'#$e+tship^.schiffname+#13#10#10);
      if dx<=75 then showph(336,0,hulls[tship^.typnr].bild)
      else filledrectangle(336,0,336+31,31,0);
     end;
     4:begin
      writeg(md,#13#10#0'C'#$c'Y:'#0'C'#$e+toship^.schiffname+#13#10+
		       rassen[toship^.owner]+#13#10);
      if dx<=75 then showph(336,0,hulls[toship^.typnr].bild)
      else filledrectangle(336,0,336+31,31,0);
     end;
    else
     filledrectangle(336,0,336+31,31,0);
     writeg(md,#13#10#10#10);
    end;
    writeg(md,#0'C'#$e'Distanz:'#0'C'#$a+
	   w2s(dx,6,false,false)+#13#10#10);

    if (dx>75)or(tshowthing=0) then writeg(md,#0'C'#$7'Visueller Kontakt...')
    else writeg(md,#0'C'#$c'V'#0'C'#$f'isueller Kontakt...');
    DisplayStars(rasse,x,y,z,targetx,targety,targetz);
   end;
   showph(592,436,rasse+242);
   repeat
    dx:=dist(posx,posy,posz,targetx,targety,targetz);
    writeg(md,#13#10);
    redraw:=0;
    c:=upcase(kbreadkey);
    if c=#0 then cs:=byte(kbreadkey) else cs:=kbscancode;
    if keyhandle(c,cs,rasse,posx,posy,posz,targetx,targety,targetz,redraw)
    then begin
     if redraw=3 then redraw:=2
     else if redraw=2 then redraw:=1;
    end else case c of
     #0:case cs of

      $30:{Ab}begin
       if BaseNr<>-1 then showthing:=2;
       if tBaseNr<>-1 then tshowthing:=2;
       redraw:=1;
      end;

      $22:{Ag}begin
       if isopponent then begin
	showthing:=4;
	oshipnr:=shiplist(rasse,x,y,z,7,id_nr,'Gegnerische Schiffe bei Schiff',0);
	if oshipnr=-1 then showthing:=0 else oship:=getship(oshipnr);
	redraw:=2;
       end;
       if tisopponent then begin
	tshowthing:=4;
	toshipnr:=shiplist(rasse,targetx,targety,targetz,7,id_nr,'Gegnerische Schiffe bei Zielpunkt',0);
	if toshipnr=-1 then tshowthing:=0 else toship:=getship(toshipnr);
	redraw:=2;
       end;
      end;

      $19:{Ap}begin
       if tPlanetNr<>-1 then tshowthing:=1;
       redraw:=1;
      end;

      $1f:{As}begin
       if isship then showthing:=3;
       if tisship then tshowthing:=3;
       redraw:=2;
      end;

      $3b:{F1}begin
       if racetax<100 then inc(racetax);
       redraw:=3;
      end;

      $3c:{F2}begin
       if nativetax<100 then inc(nativetax);
       redraw:=3;
      end;

      $41:{F5}if supplies>=100 then begin
       dec(supplies,100);
       inc(creds,100);
       redraw:=3;
      end;

      $40:{F6}if supplies>=10 then begin
       dec(supplies,10);
       inc(creds,10);
       redraw:=3;
      end;

      $3f:{F7}if supplies>=1 then begin
       dec(supplies,1);
       inc(creds,1);
       redraw:=3;
      end;

      255:{Mausklick}begin
       dx:=planlist(rasse,x,y,z,4);
       if dx=-2 then begin
	window(44*8-2,20*16-2,65*8+1,21*16+1);
	writex(45,21,$4f,'kein Planet in Sektor');
	while not kbkeypressed do begin
	 filledrectangle2(44*8,20*16,65*8-1,21*16-1,1,2);
	 kbdelay(250000);
	 if not kbkeypressed
	 then filledrectangle2(44*8,20*16,65*8-1,21*16-1,$fe,1);
	 kbdelay(250000);
	end;
	kbreset;
       end else if dx<>-1 then begin
	tplanet:=getplan(dx);
	with tplanet^ do begin
	 targetx:=posx;
	 targety:=posy;
	 targetz:=posz;
	 tshowthing:=1;
	 tplanetnr:=id_nr;
	end;
       end;
       redraw:=2;
      end;
     end;
     'P':begin
      NeuerName(name,20);
      redraw:=3;
     end;
     'O':begin
       MissionSelect;
      redraw:=2;
     end;
     'N':begin
      dx:=planlist(rasse,x,y,z,4);
      if dx=-2 then begin
       window(44*8-2,20*16-2,65*8+1,21*16+1);
       writex(45,21,$4f,'kein Planet in Sektor');
       while not kbkeypressed do begin
	filledrectangle2(44*8,20*16,65*8-1,21*16-1,1,2);
	kbdelay(250000);
	if not kbkeypressed
	then filledrectangle2(44*8,20*16,65*8-1,21*16-1,$fe,1);
	kbdelay(250000);
       end;
       kbreset;
      end else if dx<>-1 then begin
       tplanet:=getplan(dx);
       with tplanet^ do begin
	targetx:=posx;
	targety:=posy;
	targetz:=posz;
	tshowthing:=1;
	tplanetnr:=id_nr;
       end;
      end;
      redraw:=2;
     end;
     'V':if dist(posx,posy,posz,targetx,targety,targetz)<=75 then begin
      case tshowthing of
       1:if tplanet^.racetyp=rasse then visualcontact(rasse,2,tplanetnr)
	 else if (tbasenr<>-1)or(tshipnr<>-1) then visualcontact(rasse,5,tplanetnr)
	 else visualcontact(rasse,4,tplanetnr);
       2:if tbase^.owner=rasse then visualcontact(rasse,1,tbasenr)
	 else visualcontact(rasse,6,tbasenr);
       3:visualcontact(rasse,0,tshipnr);
       4:visualcontact(rasse,3,toshipnr);
      end;
      redraw:=2;
     end;
     #02:{Cb}begin
      if BaseNr<>-1 then showthing:=2;
      if tBaseNr<>-1 then tshowthing:=2;
      redraw:=1;
     end;
     #07:{Cg}begin
      if isopponent then showthing:=4;{**}
      if tisopponent then tshowthing:=4;
      redraw:=1;
     end;
     #16:{Cp}begin
      if tPlanetNr<>-1 then tshowthing:=1;
      redraw:=1;
     end;
     #19:{Cs}begin
      if isship then showthing:=3;
      if tisship then tshowthing:=3;
      redraw:=1;
     end;
     #$0d:{Cm}begin
      dt:=maxmines(planet);
      if dt>supplies then dt:=supplies;
      if dt>0 then begin
       if 5*dt>supplies+creds then dt:=(supplies+creds) div 5;
       if dt>0 then begin
	inc(mines,dt);
	dec(supplies,dt);
	dt:=(5-1)*dt;
	if dt>creds then begin
	 dec(dt,creds);
	 dec(supplies,dt);
	 creds:=0;
	end else dec(creds,dt);
	redraw:=3;
       end;
      end;
     end;
     #$06:{Cf}begin
      dt:=maxfacts(planet);
      if dt>supplies then dt:=supplies;
      if dt>0 then begin
       if 4*dt>supplies+creds then dt:=(supplies+creds) div 4;
       if dt>0 then begin
	inc(facts,dt);
	dec(supplies,dt);
	dt:=(4-1)*dt;
	if dt>creds then begin
	 dec(dt,creds);
	 dec(supplies,dt);
	 creds:=0;
	end else dec(creds,dt);
	redraw:=3;
       end;
      end;
     end;
     #$01:{Ca}begin
      dt:=maxdefs(planet);
      if dt>supplies then dt:=supplies;
      if dt>0 then begin
       if 11*dt>supplies+creds then dt:=(supplies+creds) div 11;
       if dt>0 then begin
	inc(defs,dt);
	dec(supplies,dt);
	dt:=(11-1)*dt;
	if dt>creds then begin
	 dec(dt,creds);
	 dec(supplies,dt);
	 creds:=0;
	end else dec(creds,dt);
	redraw:=3;
       end;
      end;
     end;
     #$0b:{Ck}begin
      dt:=maxforts(planet);
      if forts>=100 then begin
       dx:=100;
      end else if forts>=10 then begin
       dx:=34;
       if dt+forts>100 then dt:=100-forts;
      end else begin
       dx:=12;
       if dt+forts>10 then dt:=10-forts;
      end;
      if dt>supplies then dt:=supplies;
      if dt>0 then begin
       if dx*dt>supplies+creds then dt:=(supplies+creds) div dx;
       if dt>0 then begin
	inc(forts,dt);
	dec(supplies,dt);
	dt:=(dx-1)*dt;
	if dt>creds then begin
	 dec(dt,creds);
	 dec(supplies,dt);
	 creds:=0;
	end else dec(creds,dt);
	redraw:=3;
       end;
      end;
     end;
     '+':begin
      runmenu(planmenu,rasse,nextplan(id,rasse,0,0,0,1),0,0,0,0);
      kbreset;
      redraw:=4;
     end;
     '-':begin
      runmenu(planmenu,rasse,lastplan(id,rasse,0,0,0,1),0,0,0,0);
      kbreset;
      redraw:=4;
     end;
     'X':case showthing of
      2:if base^.owner=rasse then begin
       runmenu(basemenu,rasse,basenr,0,0,0,0);
       redraw:=4;
      end else begin
       visualcontact(rasse,6,basenr);
       redraw:=2;
      end;
      3:begin
       runmenu(shipmenu,rasse,shipnr,0,0,0,0);
       redraw:=4;
      end;
      4:begin
       visualcontact(rasse,3,oshipnr);
       redraw:=2;
      end;
     end;
     'Y':case tshowthing of
      1:if tplanet^.racetyp=rasse then begin
       runmenu(planmenu,rasse,tplanetnr,0,0,0,0);
       redraw:=4;
      end else begin
       if tplanet^.racetyp=rasse then visualcontact(rasse,2,tplanetnr)
       else if (tbasenr<>-1)or(tshipnr<>-1) then visualcontact(rasse,5,tplanetnr)
       else visualcontact(rasse,4,tplanetnr);
       redraw:=2;
      end;
      2:if tbase^.owner=rasse then begin
       runmenu(basemenu,rasse,tbasenr,0,0,0,0);
       redraw:=4;
      end else begin
       visualcontact(rasse,6,tbasenr);
       redraw:=2;
      end;
      3:begin
       runmenu(shipmenu,rasse,tshipnr,0,0,0,0);
       redraw:=4;
      end;
      4:begin
       visualcontact(rasse,3,toshipnr);
       redraw:=2;
      end;
     end;
     '1':begin
      if racetax>0 then dec(racetax);
      redraw:=3;
     end;
     '2':begin
      if nativetax>0 then dec(nativetax);
      redraw:=3;
     end;
     'M':if (mines<maxmines(planet))and(supplies>=1)and(supplies+creds>4) then begin
      inc(mines);
      dec(supplies);
      if creds<4 then begin
       dec(supplies,4-creds);
       creds:=0;
      end else dec(creds,4);
      redraw:=3;
     end;
     'F':if (facts<maxfacts(planet))and(supplies>=1)and(supplies+creds>3) then begin
      inc(facts);
      dec(supplies);
      if creds<3 then begin
       dec(supplies,3-creds);
       creds:=0;
      end else dec(creds,3);
      redraw:=3;
     end;
     'A':if (defs<maxdefs(planet))and(supplies>=1)and(supplies+creds>10) then begin
      inc(defs);
      dec(supplies);
      if creds<10 then begin
       dec(supplies,10-creds);
       creds:=0;
      end else dec(creds,10);
      redraw:=3;
     end;
     'K':begin
      if forts>=100 then begin
       dx:=99;
      end else if forts>=10 then begin
       dx:=33;
      end else begin
       dx:=11;
      end;
      if (forts<maxforts(planet))and(supplies>=1)and(supplies+creds>dx) then begin
       inc(forts);
       dec(supplies);
       if creds<dx then begin
	dec(supplies,dx-creds);
	creds:=0;
       end else dec(creds,dx);
       redraw:=3;
      end;
     end;
    end;
   until redraw>0;
  until redraw>1;
 end;

begin
 showthing:=0;
 tshowthing:=0;
 initb(sd,8,8,40,29,15,0);
 initb(md,340,264,36,13,15,0);
 toship:=nil;
 tship:=nil;
 if id=-1 then id:=planid(x,y,z);
 if id=-1 then begin
  oldmenu;
  exit;
 end;
 planet:=getplan(id);
 if planet=nil then begin
  oldmenu;
  exit;
 end;
 with planet^ do begin
  x:=posx;
  y:=posy;
  z:=posz;
  BaseNr:=BaseID(posx,posy,posz);
  if baseNr<>-1 then base:=getbase(basenr) else base:=nil;
  CanFight:=defs<>0;
  Missionen:=$3f or byte(canfight) shl 6;
  shipnr:=firstship(rasse,x,y,z,5);
  ship:=getship(shipnr);
  isship:=shipnr<>-1;

  oshipnr:=firstship(rasse,posx,posy,posz,7);
  oship:=getship(oshipnr);

  targetx:=posx;
  targety:=posy;
  targetz:=posz;
 end;
 redraw:=0;
 with planet^ do repeat
  if redraw<>3 then begin
   ClearScreen(0);
   Window(6,6,329,473);
   Window(338,262,629,473);
  end;

  writeg(sd,#0'C'#$c#12'P'#0'C'#$f'lanet:'#0'C'#$e+name);
  showp(224,149,bild);
  writeg(sd,#13#10#0'C'#$f'Klima: '#0'C'#$e+klima[nklima(climate)]+'  ');
  tm:=trunc(optiair(rasse,climate)*1000+0.5);
  if tm<>1000 then begin
   st:=w2s(tm,4,false,false);
   if st[3]=' ' then st[3]:='0';
{   st[0]:=#6;}
   st[5]:=st[4];
   st[4]:='.';
   st[6]:='%';
  end else st:='';
  writeg(sd,#0'C'#$b+st+'Optimal');
  writeg(sd,#13#10#0'C'#$f'Luft : '#0'C'#$e+air[nair(climate)]+
	    #0'C'#$f' Typ: '#0'C'#$a+w2s(climate shr 12,2,false,false));
  writeg(sd,#13#10#10#0'C'#$f'Kolonisten:'#0'C'#$a+l2s(raceanz,8,false,false,false));
  if raceanz<>0 then begin
   case ncontent(racecont) of
    0:writeg(sd,#0'C'#$d);
    1..2:writeg(sd,#0'C'#$c);
    3:writeg(sd,#0'C'#$e);
   end;
   writeg(sd,' '+bev[ncontent(racecont)]);
   dt:=contentchg(planet);
   if dt>0 then begin
    writeg(sd,#0'C'#$a' '#24);
    if dt>5 then writeg(sd,#24);
   end else if dt=0 then writeg(sd,#0'C'#$e' '#26)
   else begin
    if dt>-6 then writeg(sd,#0'C'#$e' '#25)
    else writeg(sd,#0'C'#$c' '#25);
    if dt<-10 then begin
     if dt<-15 then writeg(sd,#25)
     else writeg(sd,#0'C'#$e#25);
    end;
   end;
  end;
  writeg(sd,#13#10#0'C'#$e'Milit„r   :'#0'C'#$a+l2s(soldiers(planet),8,false,false,false));
  writeg(sd,   #13#10#0'C'#$f'Natives   :'#0'C'#$a+l2s(nativeanz,8,false,false,false));
  if nativeanz<>0 then begin
   case ncontent(nativecont) of
    0:writeg(sd,#0'C'#$d);
    1..2:writeg(sd,#0'C'#$c);
    3:writeg(sd,#0'C'#$e);
   end;
   writeg(sd,' '+bev[ncontent(nativecont)]);
   dt:=ncontentchg(planet);
   if dt>0 then begin
    writeg(sd,#0'C'#$a' '#24);
    if dt>5 then writeg(sd,#24);
   end else if dt=0 then writeg(sd,#0'C'#$e' '#26)
   else begin
    if dt>-6 then writeg(sd,#0'C'#$e' '#25)
    else writeg(sd,#0'C'#$c' '#25);
    if dt<-10 then begin
     if dt<-15 then writeg(sd,#25)
     else writeg(sd,#0'C'#$e#25);
    end;
   end;
   writeg(sd,#13#10#0'C'#$e+natives[nativetyp]);
  end else writeg(sd,#10);
  writeg(sd,#13#10#0'C'#$e'Ges./Max. :'#0'C'#$a+l2s(nativeanz+raceanz,8,false,false,false)+
	    '/'+l2s(size,8,false,false,false));
  writeg(sd,#13#10#10#0'C'#$7'             F'#0'C'#$c'1');
  if nativeanz<>0 then writeg(sd,#0'C'#$7'     F'#0'C'#$c'2');
  writeg(sd,#13#10#0'C'#$f'Steuern :'#0'C'#$a+w2s(racetax,6,false,false)+'%');
  if nativeanz<>0 then writeg(sd,w2s(nativetax,6,false,false)+'%');
  writeg(sd,#13#10#0'C'#$e'Einnahme:'#0'C'#$a+l2s(income(planet),6,false,false,false));
  if nativeanz<>0 then writeg(sd,l2s(nincome(planet),7,false,false,false));
  writeg(sd,#13#10#10#0'C'#$c'M'#0'C'#$f'inen       :'#0'C'#$a+w2s(mines,5,false,false)+
	       #0'C'#$e'/'#0'C'#$a+w2s(maxmines(planet),4,false,false)+#0'C'#$7' ( 4 Cred+1 Ware)'+
	       #13#10#0'C'#$c'F'#0'C'#$f'abriken    :'#0'C'#$a+w2s(facts,5,false,false)+
	       #0'C'#$e'/'#0'C'#$a+w2s(maxfacts(planet),4,false,false)+#0'C'#$7' ( 3 Cred+1 Ware)'+
	       #13#10#0'C'#$c'A'#0'C'#$f'bwehrposten:'#0'C'#$a+w2s(defs,5,false,false)+
	       #0'C'#$e'/'#0'C'#$a+w2s(maxdefs(planet),4,false,false)+#0'C'#$7' (10 Cred+1 Ware)'+
	       #13#10#0'C'#$c'K'#0'C'#$f'asernen    :'#0'C'#$a+w2s(forts,5,false,false)+
	       #0'C'#$e'/'#0'C'#$a+w2s(maxforts(planet),4,false,false)+#0'C'#$7' (');
  if forts>=100 then writeg(sd,'99')
  else if forts>=10 then writeg(sd,'33')
  else writeg(sd,'11');
  writeg(sd,' Cred+1 Ware)');

  writeg(sd,#13#10#10#0'C'#$f'Rohstoffe:          im Boden:   KT/Mine:');

  writeg(sd,#13#10#0'C'#$e' Neutronium :'#0'C'#$a+w2s(minedneutr,6,false,false)
	    +w2s(neutr,7,false,false)
	    +#0'C'#$e+w2s(vertneutr,8,false,false)
	    +'/100'#13#10#0'C'#$e' Molybdenium:'#0'C'#$a+w2s(minedmolyb,6,false,false)
	    +w2s(molyb,7,false,false)
	    +#0'C'#$e+w2s(vertmolyb,8,false,false)
	    +'/100'#13#10#0'C'#$e' Duranium   :'#0'C'#$a+w2s(mineddura,6,false,false)
	    +w2s(dura,7,false,false)
	    +#0'C'#$e+w2s(vertdura,8,false,false)
	    +'/100'#13#10#0'C'#$e' Tritanium  :'#0'C'#$a+w2s(minedtrit,6,false,false)
	    +w2s(trit,7,false,false)
	    +#0'C'#$e+w2s(verttrit,8,false,false)+'/100');
  writeg(sd,#13#10#0'C'#$e' Waren      :'#0'C'#$a+w2s(supplies,6,false,false)
	    +#0'C'#$7'  Verkauf: '#0'C'#$c'F5 F6 F7'
	    +#13#10#0'C'#$e' Credits    :'#0'C'#$a+w2s(creds,6,false,false));
  writeg(sd,#13#10#10#0'C'#$c'O'#0'C'#$f'ption:'#13#10#0'C'#$e' '+pmissionen[mission]);
  tastatur;
 until redraw=4;
end;

end.