[avida-cvs] avida(Sherri) CVS commits: /current/source/main org_message.cc org_message.hh /current/source/tools datafile.hh slice.cc slice.hh /current/source/utils/hist_map hist_map.cc /current/source/viewers Makefile.am bar_screen.cc environment_screen.cc environment_screen.hh map_screen.cc map_screen.hh ncurses-viewer.ilk symbol_util.cc text_screen.cc text_screen.hh view.cc view.hh zoom_screen.cc zoom_screen.hh

goingssh avida-cvs at alife.org
Tue Aug 19 18:50:22 PDT 2003


goingssh		Tue Aug 19 10:50:22 2003 EDT

  Added files:                 (Branch: Sherri)
    /avida/current/source/viewers	environment_screen.cc 
                                 	environment_screen.hh 
                                 	ncurses-viewer.ilk 
    /avida/current/source/main	org_message.cc org_message.hh 

  Modified files:              
    /avida/current/source/tools	datafile.hh slice.cc slice.hh 
    /avida/current/source/utils/hist_map	hist_map.cc 
    /avida/current/source/viewers	Makefile.am bar_screen.cc 
                                 	map_screen.cc map_screen.hh 
                                 	symbol_util.cc text_screen.cc 
                                 	text_screen.hh view.cc view.hh 
                                 	zoom_screen.cc zoom_screen.hh 
  Log:
  updating my branch to be current with head branch
  
-------------- next part --------------
Index: avida/current/source/tools/datafile.hh
diff -u avida/current/source/tools/datafile.hh:1.13 avida/current/source/tools/datafile.hh:1.13.2.1
--- avida/current/source/tools/datafile.hh:1.13	Sat May 17 02:48:15 2003
+++ avida/current/source/tools/datafile.hh	Tue Aug 19 10:50:15 2003
@@ -99,6 +99,7 @@
   void Write( int i,                 const char * descr );
   void Write( const char * data_str, const char * descr );
   void WriteBlockElement (double x, int element, int x_size );
+  void WriteBlockElement (int i, int element, int x_size );
 
   /**
    * Writes a descriptive string into a data file. The string is only
Index: avida/current/source/tools/slice.cc
diff -u avida/current/source/tools/slice.cc:1.10 avida/current/source/tools/slice.cc:1.10.2.1
--- avida/current/source/tools/slice.cc:1.10	Sat May 17 02:48:15 2003
+++ avida/current/source/tools/slice.cc	Tue Aug 19 10:50:15 2003
@@ -32,9 +32,11 @@
 //  cConstSchedule
 ////////////////////
 
-cConstSchedule::cConstSchedule(int _item_count) : cSchedule(_item_count)
+cConstSchedule::cConstSchedule(int _item_count)
+  : cSchedule(_item_count), is_active(_item_count)
 {
   last_id = 0;
+  is_active.SetAll(false);
 }
 
 cConstSchedule::~cConstSchedule()
@@ -47,10 +49,22 @@
   return true;
 }
 
+void cConstSchedule::Adjust(int item_id, const cMerit & merit)
+{
+  if (merit == 0.0) is_active[item_id] = false;
+  else is_active[item_id] = true;
+}
+
+
 int cConstSchedule::GetNextID()
 {
-  last_id++;
-  if (last_id == item_count) last_id = 0;
+  // Grab the next ID...
+  if (++last_id == item_count) last_id = 0;
+
+  // Make sure we actually have an active ID...
+  while (is_active[last_id] == false) {
+    if (++last_id == item_count) last_id = 0;
+  }
   return last_id;
 }
 
Index: avida/current/source/tools/slice.hh
diff -u avida/current/source/tools/slice.hh:1.5 avida/current/source/tools/slice.hh:1.5.2.1
--- avida/current/source/tools/slice.hh:1.5	Tue Apr 15 13:14:18 2003
+++ avida/current/source/tools/slice.hh	Tue Aug 19 10:50:15 2003
@@ -43,12 +43,13 @@
 class cConstSchedule : public cSchedule {
 private:
   int last_id;
+  tArray<bool> is_active;
 public:
   cConstSchedule(int _item_count);
   ~cConstSchedule();
 
   bool OK();
-  void Adjust(int item_id, const cMerit & merit) { ; }
+  void Adjust(int item_id, const cMerit & merit);
 
   int GetNextID();
 };
Index: avida/current/source/utils/hist_map/hist_map.cc
diff -u avida/current/source/utils/hist_map/hist_map.cc:1.2 avida/current/source/utils/hist_map/hist_map.cc:1.2.2.1
--- avida/current/source/utils/hist_map/hist_map.cc:1.2	Sat May 17 02:48:15 2003
+++ avida/current/source/utils/hist_map/hist_map.cc	Tue Aug 19 10:50:16 2003
@@ -42,10 +42,8 @@
     
     int total_count = 0;
 
-    int line_num = 0;
-    while (file.GetNumLines() > 0) {
-      line_num++;
-      cString cur_line = file.RemoveLine();
+    for (int line_num = 0; line_num < file.GetNumLines(); line_num++) {
+      cString cur_line = file.GetLine(line_num);
       int value = -1;
       int count = -1;
       
@@ -60,7 +58,7 @@
       if (value < 0) {
 	cout << "Error in file '" << argv[i+3]
 	     << "': Only posive values allowed." << endl
-	     << "   (line = " << line_num
+	     << "   (line = " << line_num+1
 	     << ",  count = " << count
 	     << ",  value = '" << value << "')" << endl;
 	return 1;
Index: avida/current/source/viewers/Makefile.am
diff -u avida/current/source/viewers/Makefile.am:1.14.2.1 avida/current/source/viewers/Makefile.am:1.14.2.2
--- avida/current/source/viewers/Makefile.am:1.14.2.1	Fri May 23 12:05:39 2003
+++ avida/current/source/viewers/Makefile.am	Tue Aug 19 10:50:16 2003
@@ -5,6 +5,7 @@
 
 viewer_SOURCES = ansi.cc		ansi.hh			\
 		bar_screen.cc		bar_screen.hh		\
+		environment_screen.cc	environment_screen.hh	\
 		hist_screen.cc		hist_screen.hh		\
 		map_screen.cc		map_screen.hh		\
 		menu.cc			menu.hh			\
Index: avida/current/source/viewers/bar_screen.cc
diff -u avida/current/source/viewers/bar_screen.cc:1.7 avida/current/source/viewers/bar_screen.cc:1.7.2.1
--- avida/current/source/viewers/bar_screen.cc:1.7	Sat May 17 02:48:16 2003
+++ avida/current/source/viewers/bar_screen.cc	Tue Aug 19 10:50:16 2003
@@ -7,6 +7,7 @@
 
 #include "../main/population.hh"
 #include "../main/stats.hh"
+#include "../main/environment.hh"
 
 #include "bar_screen.hh"
 
@@ -23,21 +24,39 @@
   SetBoldColor(COLOR_WHITE);
 
   Box();
-  VLine(19);
-  VLine(Width() - 14);
+  VLine(18);
+  
 
-  int offset = 7 + (prog_name.GetSize() + 1) / 2;
+  int offset = prog_name.GetSize() + 4;
+  VLine(Width() - offset - 2);
   Print(1, Width() - offset, "%s", prog_name());
 
-  Print(1, 3, "Update:");
-  Print(1, 22, "[M]ap  [S]tats  [O]ptions  [Z]oom  [Q]uit");
+  Print(1, 2, "Update:");
+
+  if(info.GetPopulation().GetEnvironment().GetResourceLib().GetSize() > 0)
+    Print(1, 20, "[M]ap [S]tats [O]ptions [Z]oom [E]nviron [Q]uit");
+  else
+    Print(1, 20, "[M]ap  [S]tats  [O]ptions  [Z]oom  [Q]uit");
 
   SetBoldColor(COLOR_CYAN);
-  Print(1, 23, 'M');
-  Print(1, 30, 'S');
-  Print(1, 39, 'O');
-  Print(1, 50, 'Z');
-  Print(1, 58, 'Q');
+
+  if(info.GetPopulation().GetEnvironment().GetResourceLib().GetSize() > 0)
+    {
+      Print(1, 21, 'M');
+      Print(1, 27, 'S');
+      Print(1, 35, 'O');
+      Print(1, 45, 'Z');
+      Print(1, 52, 'E');
+      Print(1, 62, 'Q');
+    }
+  else
+    {
+      Print(1, 21, 'M');
+      Print(1, 28, 'S');
+      Print(1, 37, 'O');
+      Print(1, 48, 'Z');
+      Print(1, 56, 'Q');
+    }
 
   Refresh();
 }
Index: avida/current/source/viewers/map_screen.cc
diff -u avida/current/source/viewers/map_screen.cc:1.10 avida/current/source/viewers/map_screen.cc:1.10.2.1
--- avida/current/source/viewers/map_screen.cc:1.10	Sat May 17 02:48:16 2003
+++ avida/current/source/viewers/map_screen.cc	Tue Aug 19 10:50:16 2003
@@ -24,7 +24,6 @@
 cMapScreen::cMapScreen(int _y_size, int _x_size, int _y_start,
       int _x_start, cViewInfo & in_info, cPopulation & in_pop) :
   cScreen(_y_size, _x_size, _y_start, _x_start, in_info),
-  mode(MAP_BASIC),
   x_size(in_pop.GetWorldX()),
   y_size(in_pop.GetWorldY()),
   population(in_pop)
@@ -37,6 +36,12 @@
 {
 }
 
+void cMapScreen::Draw()
+{
+  CenterActiveCPU();
+  Update();
+ 
+}
 void cMapScreen::Update()
 {
   // Get working in multiple modes!!
@@ -45,17 +50,17 @@
 
   const int name_x = Width() - 20;
   const int name_y = Height() - 1;
-  if (mode == MAP_BASIC)           Print(name_y, name_x, " Genotype View ");
-  else if (mode == MAP_SPECIES)    Print(name_y, name_x, " Species View  ");
-  else if (mode == MAP_COMBO)      Print(name_y, name_x, "  Combo View   ");
-  else if (mode == MAP_INJECT)     Print(name_y, name_x, " Modified View ");
-  else if (mode == MAP_RESOURCE)   Print(name_y, name_x, " Resource View ");
-  else if (mode == MAP_AGE)        Print(name_y, name_x, "   Age View    ");
-  else if (mode == MAP_BREED_TRUE) Print(name_y, name_x, "Breed True View");
-  else if (mode == MAP_PARASITE)   Print(name_y, name_x, " Parasite View ");
-  else if (mode == MAP_MUTATIONS)  Print(name_y, name_x, " Mutation View ");
-  else if (mode == MAP_THREAD)     Print(name_y, name_x, "  Thread View  ");
-  else if (mode == MAP_LINEAGE)    Print(name_y, name_x, " Lineage View  ");
+  if (info.GetMapMode() == MAP_BASIC)           Print(name_y, name_x, " Genotype View ");
+  else if (info.GetMapMode() == MAP_SPECIES)    Print(name_y, name_x, " Species View  ");
+  else if (info.GetMapMode() == MAP_COMBO)      Print(name_y, name_x, "  Combo View   ");
+  else if (info.GetMapMode() == MAP_INJECT)     Print(name_y, name_x, " Modified View ");
+  else if (info.GetMapMode() == MAP_RESOURCE)   Print(name_y, name_x, " Resource View ");
+  else if (info.GetMapMode() == MAP_AGE)        Print(name_y, name_x, "   Age View    ");
+  else if (info.GetMapMode() == MAP_BREED_TRUE) Print(name_y, name_x, "Breed True View");
+  else if (info.GetMapMode() == MAP_PARASITE)   Print(name_y, name_x, " Parasite View ");
+  else if (info.GetMapMode() == MAP_MUTATIONS)  Print(name_y, name_x, " Mutation View ");
+  else if (info.GetMapMode() == MAP_THREAD)     Print(name_y, name_x, "  Thread View  ");
+  else if (info.GetMapMode() == MAP_LINEAGE)    Print(name_y, name_x, " Lineage View  ");
 
 
   // Draw the [<] and [>] around the map mode....
@@ -76,7 +81,7 @@
   int virtual_x = corner_id % x_size;
   int virtual_y = corner_id / x_size;
 
-  info.SetupSymbolMaps(mode, HasColors());
+  info.SetupSymbolMaps(info.GetMapMode(), HasColors());
 
   for (int y = 0; y < Height() - 1 && y < y_size; y++) {
     Move(y, 0);
@@ -128,13 +133,15 @@
     break;
   case '>':
   case '.':
-    ++mode %= NUM_MAPS;
+    info.IncMapMode();
+    //++map_mode %= NUM_MAPS;
     Update();
     break;
   case '<':
   case ',':
-    mode += NUM_MAPS;
-    --mode %= NUM_MAPS;
+    info.DecMapMode();
+    //map_mode += NUM_MAPS;
+    //--map_mode %= NUM_MAPS;
     Update();
     break;
   }
Index: avida/current/source/viewers/map_screen.hh
diff -u avida/current/source/viewers/map_screen.hh:1.7 avida/current/source/viewers/map_screen.hh:1.7.4.1
--- avida/current/source/viewers/map_screen.hh:1.7	Sun Nov 11 15:21:03 2001
+++ avida/current/source/viewers/map_screen.hh	Tue Aug 19 10:50:16 2003
@@ -14,7 +14,7 @@
 
 class cMapScreen : public cScreen {
 private:
-  int mode;
+  //int mode;
 
   int x_size;
   int y_size;
@@ -33,7 +33,7 @@
   ~cMapScreen();
 
   // Virtual in base screen!
-  void Draw() { ; }
+  void Draw();
   void Update();
   void DoInput(int in_char);
 
Index: avida/current/source/viewers/symbol_util.cc
diff -u avida/current/source/viewers/symbol_util.cc:1.4 avida/current/source/viewers/symbol_util.cc:1.4.2.1
--- avida/current/source/viewers/symbol_util.cc:1.4	Sat May 17 02:48:16 2003
+++ avida/current/source/viewers/symbol_util.cc	Tue Aug 19 10:50:16 2003
@@ -13,7 +13,10 @@
 #include "../main/organism.hh"
 #include "../main/population_cell.hh"
 #include "../main/species.hh"
-
+#include "../main/config.hh"
+#include "../cpu/hardware_base.hh"
+#include "../cpu/hardware_4stack.hh"
+#include "../cpu/hardware_cpu.hh"
 
 using namespace std;
 
@@ -112,8 +115,23 @@
 //    if (thread_count < 20) return 'X';
 //    if (thread_count < 80) return 'L';
 //    if (thread_count < 200) return 'C';
-  
-  return '+';
+  //const cHardwareBase * hardware; 
+  int num_threads;
+  if(cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_ORIGINAL)
+    {
+      //const cHardwareCPU & hard_cpu= (cHardwareCPU &) cell.GetOrganism()->GetHardware();
+      //num_threads = hard_cpu.GetNumThreads();
+      num_threads = ((cHardwareCPU &) cell.GetOrganism()->GetHardware()).GetNumThreads();
+      return (char) ('0' + num_threads);
+    }
+  else
+    {
+      //const cHardware4Stack & hard_4stack= (cHardware4Stack &) cell.GetOrganism()->GetHardware();
+      //num_threads = hard_4stack.GetNumThreads();
+      num_threads = ((cHardware4Stack &) cell.GetOrganism()->GetHardware()).GetNumThreads();
+      return (char) ('0' + num_threads);
+    }
+  //return '+';
 }
 
 char cSymbolUtil::GetLineageSymbol(const cPopulationCell & cell)
Index: avida/current/source/viewers/text_screen.cc
diff -u avida/current/source/viewers/text_screen.cc:1.12 avida/current/source/viewers/text_screen.cc:1.12.2.1
--- avida/current/source/viewers/text_screen.cc:1.12	Sat May 17 14:23:26 2003
+++ avida/current/source/viewers/text_screen.cc	Tue Aug 19 10:50:16 2003
@@ -28,6 +28,7 @@
   saved_inst_set = NULL;
   thread_lock = -1;
   step_organism_id = -1;
+  map_mode=0;
 
   // Handle genotype & species managing...
 
@@ -81,7 +82,8 @@
     map_method = &cSymbolUtil::GetSpeciesSymbol;
     break;
   case MAP_INJECT:
-    map_method = &cSymbolUtil::GetModifiedSymbol;
+    if (use_color) color_method = &cSymbolUtil::GetModifiedSymbol;
+    else map_method = &cSymbolUtil::GetModifiedSymbol;
     break;
   case MAP_RESOURCE:
     map_method = &cSymbolUtil::GetResourceSymbol;
@@ -102,8 +104,8 @@
     else map_method = &cSymbolUtil::GetMutSymbol;
     break;
   case MAP_THREAD:
-    if (use_color) color_method = &cSymbolUtil::GetThreadSymbol;
-    else map_method = &cSymbolUtil::GetThreadSymbol;
+    //if (use_color) color_method = &cSymbolUtil::GetThreadSymbol;
+    map_method = &cSymbolUtil::GetThreadSymbol;
     break;
   case MAP_LINEAGE:
     if (use_color) color_method = &cSymbolUtil::GetLineageSymbol;
Index: avida/current/source/viewers/text_screen.hh
diff -u avida/current/source/viewers/text_screen.hh:1.10 avida/current/source/viewers/text_screen.hh:1.10.2.1
--- avida/current/source/viewers/text_screen.hh:1.10	Sat May 17 14:54:55 2003
+++ avida/current/source/viewers/text_screen.hh	Tue Aug 19 10:50:16 2003
@@ -59,6 +59,7 @@
   int pause_level;
   int thread_lock;
   int step_organism_id;
+  int map_mode;
 
   // Instruction Libraries.
   cInstSet const * saved_inst_set;
@@ -86,7 +87,10 @@
   tArray<char> & GetColorMap() { return color_map; }
   char & MapSymbol(int pos) { return map[pos]; }
   char & ColorSymbol(int pos) { return color_map[pos]; }
-
+  int GetMapMode() { return map_mode; }
+  void IncMapMode() { ++map_mode%=NUM_MAPS; }
+  void DecMapMode();
+    
   void EngageStepMode();
   void DisEngageStepMode();
 
@@ -144,6 +148,12 @@
 ///////////////
 //  cViewInfo
 ///////////////
+
+inline void cViewInfo::DecMapMode()
+{
+  map_mode+=NUM_MAPS; 
+  --map_mode %= NUM_MAPS; 
+}
 
 inline bool cViewInfo::InGenChart(cGenotype * in_gen)
 {
Index: avida/current/source/viewers/view.cc
diff -u avida/current/source/viewers/view.cc:1.10 avida/current/source/viewers/view.cc:1.10.2.1
--- avida/current/source/viewers/view.cc:1.10	Sat May 17 02:48:16 2003
+++ avida/current/source/viewers/view.cc	Tue Aug 19 10:50:16 2003
@@ -29,6 +29,7 @@
 #include "hist_screen.hh"
 #include "options_screen.hh"
 #include "zoom_screen.hh"
+#include "environment_screen.hh"
 
 
 using namespace std;
@@ -52,6 +53,7 @@
   hist_screen    = new cHistScreen    (0,0,3,0,info, in_population);
   options_screen = new cOptionsScreen (0,0,3,0,info);
   zoom_screen    = new cZoomScreen    (0,0,3,0,info, in_population);
+  environment_screen = new cEnvironmentScreen (0,0,3,0,info, in_population);
 
   info.SetActiveCell( &( in_population.GetCell(0) ) );
 }
@@ -63,6 +65,7 @@
   if (hist_screen) delete hist_screen;
   if (options_screen) delete options_screen;
   if (zoom_screen) delete zoom_screen;
+  if (environment_screen) delete environment_screen;
 
   EndProg(0);
 }
@@ -94,6 +97,8 @@
     cur_screen = options_screen;
   } else if (in_mode == MODE_ZOOM) {
     cur_screen = zoom_screen;
+  } else if (in_mode == MODE_ENVIRONMENT) {
+    cur_screen = environment_screen;
   }
 }
 
@@ -120,11 +125,12 @@
 void cView::NotifyUpdate()
 {
   // If we're locked onto a specific thread, only stop for it.
-  if (info.GetPauseLevel() == PAUSE_ADVANCE_STEP &&
+  /*if (info.GetPauseLevel() == PAUSE_ADVANCE_STEP &&
       info.GetThreadLock() != -1  &&
       info.GetThreadLock() != info.GetActiveCell()->GetOrganism()->GetHardware().ViewerLock()){
     return;
-  }
+    }*/
+
 
   bar_screen->Update();
   info.UpdateSymbols();
@@ -233,6 +239,11 @@
     case 'p':
     case 'P':
       TogglePause();
+      break;
+    case 'e':
+    case 'E':
+      if(info.GetPopulation().GetEnvironment().GetResourceLib().GetSize() > 0)
+	ChangeCurScreen(environment_screen);
       break;
     case 's':
     case 'S':
Index: avida/current/source/viewers/view.hh
diff -u avida/current/source/viewers/view.hh:1.9 avida/current/source/viewers/view.hh:1.9.4.1
--- avida/current/source/viewers/view.hh:1.9	Sun Nov 11 15:21:03 2001
+++ avida/current/source/viewers/view.hh	Tue Aug 19 10:50:16 2003
@@ -15,6 +15,7 @@
 #define MODE_HIST    3
 #define MODE_OPTIONS 4
 #define MODE_ZOOM    5
+#define MODE_ENVIRONMENT 6
 
 #include "text_screen.hh"
 
@@ -25,6 +26,7 @@
 class cHistScreen;
 class cOptionsScreen;
 class cZoomScreen;
+class cEnvironmentScreen;
 
 class cView {
 private:
@@ -34,12 +36,12 @@
   static cTextWindow * base_window;
   static cScreen * cur_screen;
   static cBarScreen * bar_screen;
-
   cMapScreen * map_screen;
   cStatsScreen * stats_screen;
   cHistScreen * hist_screen;
   cOptionsScreen * options_screen;
   cZoomScreen * zoom_screen;
+  cEnvironmentScreen * environment_screen;
 
   // Window managing functions...
 
Index: avida/current/source/viewers/zoom_screen.cc
diff -u avida/current/source/viewers/zoom_screen.cc:1.24 avida/current/source/viewers/zoom_screen.cc:1.24.2.1
--- avida/current/source/viewers/zoom_screen.cc:1.24	Sat May 17 14:23:26 2003
+++ avida/current/source/viewers/zoom_screen.cc	Tue Aug 19 10:50:16 2003
@@ -18,6 +18,7 @@
 #include "../main/tasks.hh"
 
 #include "../cpu/hardware_cpu.hh"
+#include "../cpu/hardware_4stack.hh"
 
 #include "zoom_screen.hh"
 
@@ -39,12 +40,16 @@
   memory_offset = 0;
   parasite_zoom = false;
   mode = ZOOM_MODE_STATS;
-  map_mode = MAP_BASIC;
+  //map_mode = MAP_BASIC;
   inst_view_mode = true;
   active_section = ZOOM_SECTION_MEMORY;
   task_offset = 0;
+  //hardware_type = info.GetActiveCell()->GetOrganism()->GetHardware().GetType();
+  cur_stack=0;
+  cur_mem_space=0;
+  cur_view_thread=0;
 
-  map_mode = MAP_BASIC;
+  //map_mode = MAP_BASIC;
   mini_center_id = 0;
   map_x_size = population.GetWorldX();
   map_y_size = population.GetWorldY();
@@ -75,14 +80,20 @@
   if (info.GetPauseLevel()) {
     Print(OPTIONS_Y+2, OPTIONS_X+6, "P");
     Print(OPTIONS_Y+3, OPTIONS_X+3, "N");
-    Print(OPTIONS_Y+4, OPTIONS_X+3, "Space");
+    //Print(OPTIONS_Y+4, OPTIONS_X+3, "Space");
   } else {
     Print(OPTIONS_Y+2, OPTIONS_X+3, "P");
   }
 
   // Redirect to the proper Draw() method.
 
-  if (mode == ZOOM_MODE_CPU) DrawCPU();
+  if (mode == ZOOM_MODE_CPU)
+    {
+      if(cConfig::GetHardwareType()==HARDWARE_TYPE_CPU_ORIGINAL) 
+	DrawCPU_Original();
+      if(cConfig::GetHardwareType()==HARDWARE_TYPE_CPU_4STACK) 
+	DrawCPU_4Stack();
+    }
   else if (mode == ZOOM_MODE_STATS) DrawStats();
   else if (mode == ZOOM_MODE_GENOTYPE) DrawGenotype();
 
@@ -118,11 +129,23 @@
 
   Print(10, 27, "Thread:");
   Print(11, 27, "IP....:");
-  Print(12, 27, "AX....:");
-  Print(13, 27, "BX....:");
-  Print(14, 27, "CX....:");
-  Print(15, 27, "Stack.:");
-  Print(16, 27, "---- Memory ----");
+
+  if(cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_ORIGINAL)
+    {
+      Print(12, 27, "AX....:");
+      Print(13, 27, "BX....:");
+      Print(14, 27, "CX....:");
+      Print(15, 27, "Stack.:");
+      Print(16, 27, "---- Memory ----");
+    }
+  else if(cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_4STACK)
+    {
+      Print(12, 27, "Stack AX:");
+      Print(13, 27, "Stack BX:");
+      Print(14, 27, "Stack CX:");
+      Print(15, 27, "Stack DX:");
+      Print(16, 27, "---- Memory ----");
+    }
 
   Print(CPU_FLAGS_Y, CPU_FLAGS_X, "---- Flags ----");
 
@@ -159,11 +182,9 @@
     Print(Height()-1, Width() - 21, "<-");
     Print(Height()-1, Width() - 11, "->");
   }
-
-
 }
 
-void cZoomScreen::DrawCPU()
+void cZoomScreen::DrawCPU_Original()
 {
   SetColor(COLOR_WHITE);
 
@@ -211,9 +232,8 @@
 
   Print(OPTIONS_Y+6, OPTIONS_X+2, "[E]dit Component");
   Print(OPTIONS_Y+7, OPTIONS_X+2, "[V]iew Component");
-#ifdef THREADS
-  Print(OPTIONS_Y+8, OPTIONS_X+2, "[T]hread Options");
-#endif
+  if(cConfig::GetMaxCPUThreads() >1)
+    Print(OPTIONS_Y+8, OPTIONS_X+2, "Next [T]hread");
   Print(OPTIONS_Y+9, OPTIONS_X+2, "[TAB] Shift Active");
 
   if (info.GetPauseLevel()) {
@@ -226,9 +246,8 @@
   SetBoldColor(COLOR_CYAN);
   Print(OPTIONS_Y+6, OPTIONS_X+3, "E");
   Print(OPTIONS_Y+7, OPTIONS_X+3, "V");
-#ifdef THREADS
-  Print(OPTIONS_Y+8, OPTIONS_X+3, "T");
-#endif
+  if(cConfig::GetMaxCPUThreads() >1)
+    Print(OPTIONS_Y+8, OPTIONS_X+8, "T");
   Print(OPTIONS_Y+9, OPTIONS_X+3, "TAB");
 
   if (info.GetPauseLevel()) {
@@ -261,6 +280,109 @@
   Print(19, 52, "Thread.......:");
 }
 
+void cZoomScreen::DrawCPU_4Stack()
+{
+  SetColor(COLOR_WHITE);
+
+  // --== Registers ==--
+  Box(REG_X, REG_Y-1, 19, 8);
+  Print(REG_Y, REG_X + 2, "Stacks:");
+  HLine(REG_Y + 1, REG_X, 19);
+
+  SetBoldColor(COLOR_WHITE);
+  Print(REG_Y + 2, REG_X + 2, "AX:");
+  Print(REG_Y + 3, REG_X + 2, "BX:");
+  Print(REG_Y + 4, REG_X + 2, "CX:");
+  Print(REG_Y + 5, REG_X + 2, "DX:");
+  SetColor(COLOR_WHITE);
+
+  // --== Inputs ==--
+  Box(INPUT_X, INPUT_Y-1, 16, 8);
+  Print(INPUT_Y, INPUT_X + 2, "Inputs:");
+  HLine(INPUT_Y+1, INPUT_X, 16);
+
+  // --== Mini-Map ==--
+  Box(MINI_MAP_X, MINI_MAP_Y, 17, 3);
+  Print(MINI_MAP_Y + 1, MINI_MAP_X + 2, "Mini-Map");
+  //HLine(MINI_MAP_Y + 2, MINI_MAP_X, 19);
+
+  SetBoldColor(COLOR_WHITE);
+  Print(MINI_MAP_Y + 11, MINI_MAP_X,  "[ ]           [ ]");
+  SetBoldColor(COLOR_CYAN);
+  Print(MINI_MAP_Y + 11, MINI_MAP_X + 1,  '-');
+  Print(MINI_MAP_Y + 11, MINI_MAP_X + 15, '+');
+  SetColor(COLOR_WHITE);
+
+  // --== Memory ==--
+  Box(MEMORY_X, MEMORY_Y, 36, 5 + MEMORY_PRE_SIZE + MEMORY_POST_SIZE);
+  Print(MEMORY_Y + 1, MEMORY_X + 2,  "Memory Space");
+  HLine(MEMORY_Y + 2, MEMORY_X, 36);
+
+  // --== Stack ==--
+  Box(STACK_X, STACK_Y-1, 15, 8);
+  HLine(STACK_Y + 1, STACK_X, 15);
+
+  // --== Options ==--
+  SetBoldColor(COLOR_YELLOW);
+  Print(OPTIONS_Y, OPTIONS_X+4,    "Component Zoom");
+  SetBoldColor(COLOR_WHITE);
+
+  //Print(OPTIONS_Y+6, OPTIONS_X+2, "[E]dit Component");
+  //Print(OPTIONS_Y+7, OPTIONS_X+2, "[V]iew Component");
+  Print(OPTIONS_Y+5, OPTIONS_X+2, "Next Stac[K]");
+  if(cConfig::GetMaxCPUThreads() >1)
+  Print(OPTIONS_Y+6, OPTIONS_X+2, "Next [T]hread");
+  //Print(OPTIONS_Y+9, OPTIONS_X+2, "[TAB] Shift Active");
+
+  if (info.GetPauseLevel()) {
+    Print(OPTIONS_Y+7, OPTIONS_X+2, "[UP, DOWN]");
+    Print(OPTIONS_Y+8, OPTIONS_X+2, "Scroll Instruction");
+    Print(OPTIONS_Y+9, OPTIONS_X+2, "[LEFT, RIGHT]");
+    Print(OPTIONS_Y+10, OPTIONS_X+2, "Change Mem Space");
+  } else {
+    Print(OPTIONS_Y+7, OPTIONS_X+2, "               ");
+    Print(OPTIONS_Y+8, OPTIONS_X+2, "                  ");
+    Print(OPTIONS_Y+9, OPTIONS_X+2, "               ");
+    Print(OPTIONS_Y+10, OPTIONS_X+2, "                 ");
+  }
+
+
+  SetBoldColor(COLOR_CYAN);
+  Print(OPTIONS_Y+5, OPTIONS_X+12, "K");
+  if(cConfig::GetMaxCPUThreads() >1)
+  Print(OPTIONS_Y+6, OPTIONS_X+8, "T");
+
+  if (info.GetPauseLevel()) {
+    Print(OPTIONS_Y+7, OPTIONS_X+3, "UP, DOWN");
+    Print(OPTIONS_Y+9, OPTIONS_X+3, "LEFT, RIGHT");
+  }
+
+  // Highlight the active section...
+  SetActiveSection(active_section);
+
+  // Add on a bunch of special characters to smooth the view out...
+  Print(INPUT_Y - 1, INPUT_X, CHAR_TTEE);
+  Print(INPUT_Y + 1, INPUT_X, CHAR_PLUS);
+  Print(INPUT_Y + 6, INPUT_X, CHAR_BTEE);
+
+  Print(STACK_Y - 1, STACK_X, CHAR_TTEE);
+  Print(STACK_Y + 1, STACK_X, CHAR_PLUS);
+  Print(STACK_Y + 6, STACK_X, CHAR_BTEE);
+
+
+  // A few stats on this screen...
+
+  SetBoldColor(COLOR_WHITE);
+
+  Print(13, 52, "Location.....:");
+  Print(14, 52, "Genotype ID..:");
+  Print(15, 52, "Genotype Name:");
+
+  Print(17, 52, "Faults.......:");
+  Print(18, 52, "Offspring....:");
+  Print(19, 52, "Thread.......:");
+}
+
 void cZoomScreen::DrawGenotype()
 {
   SetBoldColor(COLOR_YELLOW);
@@ -306,16 +428,15 @@
 
 void cZoomScreen::Update()
 {
-  if (mode == ZOOM_MODE_CPU){
-    UpdateCPU();
-  }
-  else if (mode == ZOOM_MODE_STATS) UpdateStats();
+  cHardwareBase & hardware = info.GetActiveCell()->GetOrganism()->GetHardware();
+  if(mode == ZOOM_MODE_CPU) UpdateCPU(hardware);
+  else if (mode == ZOOM_MODE_STATS) UpdateStats(hardware);
   else if (mode == ZOOM_MODE_GENOTYPE) UpdateGenotype();
 
   Refresh();
 }
 
-void cZoomScreen::UpdateStats()
+void cZoomScreen::UpdateStats(cHardwareBase & hardware)
 {
   if (info.GetActiveCell() == NULL ||
       info.GetActiveCell()->IsOccupied() == false) return;
@@ -323,8 +444,8 @@
   cGenotype * genotype = info.GetActiveGenotype();
   cPhenotype & phenotype = info.GetActiveCell()->GetOrganism()->GetPhenotype();
 
-  cHardwareCPU & hardware =
-    (cHardwareCPU &) info.GetActiveCell()->GetOrganism()->GetHardware();
+  //cHardwareBase & hardware =
+  //  info.GetActiveCell()->GetOrganism()->GetHardware();
 
   SetBoldColor(COLOR_CYAN);
 
@@ -354,34 +475,14 @@
   Print(7, 39, "%9d ", phenotype.GetGestationStart());
   Print(8, 39, "%9d ", phenotype.GetNumDivides());
 
-
   if (info.GetThreadLock() != -1) Print(10, 36, "LOCKED");
   else Print(10, 36, "      ");
-  Print(10, 43, "%2d/%2d", hardware.GetCurThread() + 1,
-	hardware.GetNumThreads());
-  Print(12, 34, "%14d", hardware.Register(0));
-  Print(13, 34, "%14d", hardware.Register(1));
-  Print(14, 34, "%14d", hardware.Register(2));
-  Print(15, 34, "%14d", hardware.GetStack(0));
+  
+  if(cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_ORIGINAL)
+    UpdateStats_CPU(hardware);
 
-  cCPUHead inst_ptr(hardware.IP());
-  const cInstSet & inst_set = hardware.GetInstSet();
-
-  for (int pos = 0; pos < 3; pos++) {
-    // Clear the line
-    Print(17+pos, 29, "                    ");
-    if (inst_ptr.InMemory() == false) continue;
-    if (pos == 1) SetColor(COLOR_CYAN);
-
-    // Draw the current instruction.
-      Print(17+pos, 29, "%s",	inst_set.GetName(inst_ptr.GetInst())());
-    inst_ptr.Advance();
-  }
-
-  // Flags...
-  if (hardware.GetMalActive()) SetBoldColor(COLOR_CYAN);
-  else SetColor(COLOR_CYAN);
-  Print(CPU_FLAGS_Y + 1, CPU_FLAGS_X + 1, "Mem Allocated");
+  if(cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_4STACK)
+    UpdateStats_4Stack(hardware);
 
   if (phenotype.ParentTrue()) SetBoldColor(COLOR_CYAN);
   else SetColor(COLOR_CYAN);
@@ -450,27 +551,158 @@
   Print(2, 40, "[%2d, %2d] ",
 	id % population.GetWorldX(), id / population.GetWorldY());
 
-  // And print the IP.
+  
 
-  const cCPUHead & active_inst_ptr = hardware.IP();
+}
+
+void cZoomScreen::UpdateStats_CPU(cHardwareBase & hardware)
+{
+  cHardwareCPU & hardwareCPU = (cHardwareCPU &) hardware;
+
+  Print(10, 43, "%2d/%2d", hardwareCPU.GetCurThread() + 1,
+	hardwareCPU.GetNumThreads());
+
+  Print(12, 34, "%14d", hardwareCPU.Register(0));
+  Print(13, 34, "%14d", hardwareCPU.Register(1));
+  Print(14, 34, "%14d", hardwareCPU.Register(2));
+  Print(15, 34, "%14d", hardwareCPU.GetStack(0));
+
+  cCPUHead inst_ptr(hardwareCPU.IP());
+   const cInstSet & inst_set = hardwareCPU.GetInstSet();
+  
+  for (int pos = 0; pos < 3; pos++) {
+    // Clear the line
+    Print(17+pos, 29, "                    ");
+    if (inst_ptr.InMemory() == false) continue;
+    if (pos == 1) SetColor(COLOR_CYAN);
+
+    // Draw the current instruction.
+      Print(17+pos, 29, "%s",	inst_set.GetName(inst_ptr.GetInst())());
+    inst_ptr.Advance();
+  }
+
+  // Flags...
+  if (hardwareCPU.GetMalActive()) SetBoldColor(COLOR_CYAN);
+  else SetColor(COLOR_CYAN);
+  Print(CPU_FLAGS_Y + 1, CPU_FLAGS_X + 1, "Mem Allocated");
+ 
+  // And print the IP.
+  const cCPUHead & active_inst_ptr = hardwareCPU.IP();
   // @CAO assume no parasites for now.
   int cur_id = info.GetActiveCell()->GetID();
   //active_inst_ptr.GetCurHardware()->GetOrganism()->GetEnvironment()->GetID();
   Print(11, 36, "%12s", cStringUtil::Stringf("[%2d,%2d] : %2d",
 	cur_id % population.GetWorldX(), cur_id / population.GetWorldX(),
 	active_inst_ptr.GetPosition())() );
+}
+
+void cZoomScreen::UpdateStats_4Stack(cHardwareBase & hardware)
+{
+  cHardware4Stack & hardware4Stack = (cHardware4Stack &) hardware;
 
+  Print(10, 43, "%2d/%2d", hardware4Stack.GetCurThread() + 1,
+	hardware4Stack.GetNumThreads());
+
+  Print(12, 34, "%14d", hardware4Stack.Stack(0).Top());
+  Print(13, 34, "%14d", hardware4Stack.Stack(1).Top());
+  Print(14, 34, "%14d", hardware4Stack.Stack(2).Top());
+  Print(15, 34, "%14d", hardware4Stack.Stack(3).Top());
+
+  c4StackHead inst_ptr(hardware4Stack.IP());
+   const cInstSet & inst_set = hardware4Stack.GetInstSet();
+  
+  for (int pos = 0; pos < 3; pos++) {
+    // Clear the line
+    Print(17+pos, 29, "                    ");
+    if (inst_ptr.InMemory() == false) continue;
+    if (pos == 1) SetColor(COLOR_CYAN);
+
+    // Draw the current instruction.
+      Print(17+pos, 29, "%s",	inst_set.GetName(inst_ptr.GetInst())());
+    inst_ptr.Advance();
+  }
+
+  // Flags...
+  //if (hardwareCPU.GetMalActive()) SetBoldColor(COLOR_CYAN);
+  //else SetColor(COLOR_CYAN);
+  //Print(CPU_FLAGS_Y + 1, CPU_FLAGS_X + 1, "Mem Allocated");
+ 
+  // And print the IP.
+  const c4StackHead & active_inst_ptr = hardware4Stack.IP();
+  // @CAO assume no parasites for now.
+  //int cur_id = info.GetActiveCell()->GetID();
+  //active_inst_ptr.GetCurHardware()->GetOrganism()->GetEnvironment()->GetID();
+  Print(11, 36, "%12s", cStringUtil::Stringf("(%2d, %2d)",
+	active_inst_ptr.GetMemSpace(),
+	active_inst_ptr.GetPosition())() );
 }
 
-void cZoomScreen::UpdateCPU()
+void cZoomScreen::UpdateCPU(cHardwareBase & hardware)
 {
-  cHardwareCPU & hardware =
-    (cHardwareCPU &) info.GetActiveCell()->GetOrganism()->GetHardware();
+  // Place the visible section of the current memory onto the screen.
+
+  SetBoldColor(COLOR_WHITE);
+  if (info.GetPauseLevel() == PAUSE_OFF) {
+    // If not paused, then set user desired offset to zero AND always show
+    // the code that is executing (ie. do not show original Parasite code if
+    // host is executing)
+    memory_offset = 0;
+    parasite_zoom = false;
+  }
+
+  Print(14, 69, "%10d", info.GetActiveGenotypeID());
+  Print(15, 69, "%10s", info.GetActiveName()());
+
+  cPhenotype & phenotype = info.GetActiveCell()->GetOrganism()->GetPhenotype();
+  Print(17, 69, "%10d", phenotype.GetCurNumErrors());
+  Print(18, 69, "%10d", phenotype.GetNumDivides());
+  if (info.GetThreadLock() != -1) Print(19, 67, "LOCKED");
+  else Print(19, 67, "      ");
+
+  if(cConfig::GetHardwareType()==HARDWARE_TYPE_CPU_ORIGINAL)
+    UpdateCPU_Original(hardware);
+  else if(cConfig::GetHardwareType()==HARDWARE_TYPE_CPU_4STACK)
+    UpdateCPU_4Stack(hardware);
+
+  // Place the input buffer on the screen.
+
+  SetBoldColor(COLOR_CYAN);
+  Print(INPUT_Y+3, INPUT_X+2, "%12d", info.GetActiveCell()->GetInput(0));
+
+  SetColor(COLOR_CYAN);
+  for (int i = 1; i < IO_SIZE; i++) {
+    Print(INPUT_Y+3+i, INPUT_X+2, "%12d", info.GetActiveCell()->GetInput(i));
+  }
+
+  const cString & cur_fault = phenotype.GetFault();
+  if (cur_fault.GetSize() > 0) {
+    SetBoldColor(COLOR_RED);
+    Print(FAULT_Y, FAULT_X, "Fault:");
+    SetBoldColor(COLOR_CYAN);
+    Print(FAULT_Y, FAULT_X + 7, cur_fault());
+  } else {
+    Print(FAULT_Y, FAULT_X, "                                        ");
+  }
+
+  SetBoldColor(COLOR_WHITE);
+
+  Print(13, 70, "[%3d,%3d] ",
+	info.GetActiveID() % population.GetWorldX(),
+	info.GetActiveID() / population.GetWorldY());
+
+  SetBoldColor(COLOR_CYAN);
+  Refresh();
+}
+
+void cZoomScreen::UpdateCPU_Original(cHardwareBase & hardware)
+{
+  cHardwareCPU & hardwareCPU = (cHardwareCPU &) hardware;
+  //hardwareCPU.SetThread(cur_view_thread);
 
   // Place the registers onto the screen.
   SetBoldColor(COLOR_CYAN);
   for (int i = 0; i < NUM_REGISTERS; i++) {
-    Print(REG_Y+3 + i, REG_X+6, "%11d", hardware.Register(i));
+    Print(REG_Y+3 + i, REG_X+6, "%11d", hardwareCPU.Register(i));
   }
 
   // Place the active stack onto the screen.
@@ -478,14 +710,14 @@
   // Stack A
   // SetBoldColor(COLOR_CYAN);   // -Redundant
   SetColor(COLOR_WHITE);
-  char stack_letter = 'A' + hardware.GetActiveStackID();
+  char stack_letter = 'A' + hardwareCPU.GetActiveStackID();
   Print(STACK_Y + 1, STACK_X + 2, "Stack %c", stack_letter);
 
   SetBoldColor(COLOR_CYAN);
-  Print(STACK_Y+3, STACK_X + 2, "%11d", hardware.GetStack(0));
+  Print(STACK_Y+3, STACK_X + 2, "%11d", hardwareCPU.GetStack(0));
   SetColor(COLOR_CYAN);
   for (int i = 1; i <= 2; i++) {
-    Print(STACK_Y+3 + i, STACK_X+2, "%11d", hardware.GetStack(i));
+    Print(STACK_Y+3 + i, STACK_X+2, "%11d", hardwareCPU.GetStack(i));
   }
 
   // Place the input buffer on the screen.
@@ -498,38 +730,20 @@
     Print(INPUT_Y+3+i, INPUT_X+2, "%12d", info.GetActiveCell()->GetInput(i));
   }
 
-  // Place the visible section of the current memory onto the screen.
-
-  SetBoldColor(COLOR_WHITE);
-  if (info.GetPauseLevel() == PAUSE_OFF) {
-    // If not paused, then set user desired offset to zero AND always show
-    // the code that is executing (ie. do not show original Parasite code if
-    // host is executing)
-    memory_offset = 0;
-    parasite_zoom = false;
-  }
-
-  Print(14, 69, "%10d", info.GetActiveGenotypeID());
-  Print(15, 69, "%10s", info.GetActiveName()());
-
-  cPhenotype & phenotype = info.GetActiveCell()->GetOrganism()->GetPhenotype();
-  Print(17, 69, "%10d", phenotype.GetCurNumErrors());
-  Print(18, 69, "%10d", phenotype.GetNumDivides());
-  if (info.GetThreadLock() != -1) Print(19, 67, "LOCKED");
-  else Print(19, 67, "      ");
-  Print(19, 74, "%2d/%2d", hardware.GetCurThread() + 1,
-	hardware.GetNumThreads());
-
+  Print(19, 74, "%2d/%2d", hardwareCPU.GetCurThread() + 1,
+	hardwareCPU.GetNumThreads());
+  
   // This line gets the creature that is currently executing. Usually the
   // creature we are viewing, but can also be a different one (if this is a
   // parasite).
-
+  
   const cCPUMemory & memory = (parasite_zoom) ?
-    hardware.GetMemory() : hardware.IP().GetMemory();
+    hardware.GetMemory() : hardwareCPU.IP().GetMemory();
   SetColor(COLOR_WHITE);
   Print(MEMORY_Y + 1, MEMORY_X + 9, "%4d", memory.GetSize());
-
-
+  
+  
+  
   // Nothing past this point gets executed for empty creatures....
   if (memory.GetSize() == 0) {
     for (int i = -MEMORY_PRE_SIZE; i <= MEMORY_POST_SIZE; i++) {
@@ -537,12 +751,12 @@
     }
     return;
   }
-
+  
   int adj_inst_ptr = 0;
-  int base_inst_ptr = hardware.IP().GetPosition();
+  int base_inst_ptr = hardwareCPU.IP().GetPosition();
   if (base_inst_ptr < 0 || parasite_zoom == true) base_inst_ptr = 0;
 
-  const cInstSet & inst_set = hardware.GetInstSet();
+  const cInstSet & inst_set = hardwareCPU.GetInstSet();
 
   // Determine the center (must be between 0 and size - 1)
   int center_pos = (base_inst_ptr + memory_offset) % memory.GetSize();
@@ -601,40 +815,163 @@
 	Print(MEMORY_Y + MEMORY_PRE_SIZE + 3 + i, MEMORY_X + 27, "Bp");
       }
 
-      if (adj_inst_ptr == hardware.GetHead(HEAD_READ).GetPosition()) {
+      if (adj_inst_ptr == hardwareCPU.GetHead(HEAD_READ).GetPosition()) {
 	Print(MEMORY_Y + MEMORY_PRE_SIZE + 3 + i, MEMORY_X + 30, "R");
       }
-      if (adj_inst_ptr == hardware.GetHead(HEAD_WRITE).GetPosition()) {
+      if (adj_inst_ptr == hardwareCPU.GetHead(HEAD_WRITE).GetPosition()) {
 	Print(MEMORY_Y + MEMORY_PRE_SIZE + 3 + i, MEMORY_X + 31, "W");
       }
-      if (adj_inst_ptr == hardware.GetHead(HEAD_FLOW).GetPosition()) {
+      if (adj_inst_ptr == hardwareCPU.GetHead(HEAD_FLOW).GetPosition()) {
 	  Print(MEMORY_Y + MEMORY_PRE_SIZE + 3 + i, MEMORY_X + 32, "F");
       }
     }
-
     SetColor(COLOR_WHITE);
   }
 
   DrawMiniMap();
+}
 
-  const cString & cur_fault = phenotype.GetFault();
-  if (cur_fault.GetSize() > 0) {
-    SetBoldColor(COLOR_RED);
-    Print(FAULT_Y, FAULT_X, "Fault:");
-    SetBoldColor(COLOR_CYAN);
-    Print(FAULT_Y, FAULT_X + 7, cur_fault());
-  } else {
-    Print(FAULT_Y, FAULT_X, "                                        ");
+void cZoomScreen::UpdateCPU_4Stack(cHardwareBase & hardware)
+{
+  cHardware4Stack & hardware4Stack = (cHardware4Stack &) hardware;
+  
+  if(cur_view_thread>=hardware4Stack.GetNumThreads())
+    {
+      cur_view_thread=0;
+      cur_mem_space = hardware4Stack.IP(cur_view_thread).GetMemSpace();
+    }
+  //hardware4Stack.SetThread(cur_view_thread);
+  c4StackHead & cur_ip = hardware4Stack.IP(cur_view_thread);
+
+  // Place the stacks onto the screen.
+  SetBoldColor(COLOR_CYAN);
+  for (int i = 0; i < 4; i++) {
+    Print(REG_Y+2 + i, REG_X+6, "%11d", hardware4Stack.Stack(i, cur_view_thread).Top());
   }
 
-  SetBoldColor(COLOR_WHITE);
+  // Place the active stack onto the screen.
 
-  Print(13, 70, "[%3d,%3d] ",
-	info.GetActiveID() % population.GetWorldX(),
-	info.GetActiveID() / population.GetWorldY());
+  // Stack AX
+  //SetBoldColor(COLOR_CYAN);   // -Redundant
+  SetColor(COLOR_WHITE);
+  
+  Print(STACK_Y, STACK_X + 2, "Stack   :");
+  Print(STACK_Y, STACK_X + 8, "%s" , hardware4Stack.GetActiveStackID(cur_stack)());
 
-  SetBoldColor(COLOR_CYAN);
-  Refresh();
+  //SetBoldColor(COLOR_CYAN);
+  //Print(STACK_Y+2, STACK_X + 2, "%11d", hardware4Stack.GetStack(0, cur_stack));
+  SetColor(COLOR_CYAN);
+  for (int i = 0; i <= 3; i++) {
+    Print(STACK_Y+2 + i, STACK_X+2, "%11d", hardware4Stack.GetStack(i, cur_stack, cur_view_thread));
+   }
+
+  Print(19, 74, "%2d/%2d", cur_view_thread + 1,
+	hardware4Stack.GetNumThreads());
+  
+  // This line gets the creature that is currently executing. Usually the
+  // creature we are viewing, but can also be a different one (if this is a
+  // parasite).
+  
+  const cCPUMemory & memory = hardware4Stack.GetMemory(cur_mem_space);
+  SetBoldColor(COLOR_BLUE);
+  Print(MEMORY_Y + 1, MEMORY_X + 8, " Space ");	
+  SetColor(COLOR_WHITE);
+  Print(MEMORY_Y + 1, MEMORY_X + 15, "%2d", cur_mem_space);
+  
+  Print(MEMORY_Y + 1, MEMORY_X + 17, ":");	
+  Print(MEMORY_Y + 1, MEMORY_X + 18, "%4d", memory.GetSize());
+  
+  
+  
+  // Nothing past this point gets executed for empty creatures....
+  if (memory.GetSize() == 0) {
+    for (int i = -MEMORY_PRE_SIZE; i <= MEMORY_POST_SIZE; i++) {
+      HLine(MEMORY_Y + MEMORY_PRE_SIZE + 3 + i, MEMORY_X, 36);
+    }
+    return;
+  }
+  
+  int adj_inst_ptr = 0;
+  int base_inst_ptr = cur_ip.GetPosition();
+  if (base_inst_ptr < 0 || parasite_zoom == true) base_inst_ptr = 0;
+
+  const cInstSet & inst_set = hardware4Stack.GetInstSet();
+
+  // Determine the center (must be between 0 and size - 1)
+  int center_pos = (base_inst_ptr + memory_offset) % memory.GetSize();
+  if (center_pos < 0) center_pos += memory.GetSize();
+
+  for (int i = -MEMORY_PRE_SIZE; i <= MEMORY_POST_SIZE; i++) {
+    adj_inst_ptr = (center_pos + i) % (memory.GetSize() + 1);
+    if (adj_inst_ptr < 0) adj_inst_ptr += memory.GetSize() + 1;
+
+    if (adj_inst_ptr == memory.GetSize()) {
+      HLine(MEMORY_Y + MEMORY_PRE_SIZE + 3 + i, MEMORY_X, 36);
+    } else {
+      Print(MEMORY_Y + MEMORY_PRE_SIZE + 3 + i, MEMORY_X, CHAR_VLINE);
+      Print(MEMORY_Y + MEMORY_PRE_SIZE + 3 + i, MEMORY_X + 35, CHAR_VLINE);
+
+      // If we are on the instruction about to be executed by the CPU,
+      // hilight it...
+      if (adj_inst_ptr == base_inst_ptr && 
+	  hardware4Stack.IP(cur_view_thread).GetMemSpace() == cur_mem_space) {
+	SetBoldColor(COLOR_WHITE);
+	Print(MEMORY_Y + MEMORY_PRE_SIZE + 3 + i, MEMORY_X + 1, "%3d: ",
+		  adj_inst_ptr);
+	SetBoldColor(COLOR_CYAN);
+      } else {
+	if (i == 0) SetBoldColor(COLOR_YELLOW);
+	Print(MEMORY_Y + MEMORY_PRE_SIZE + 3 + i, MEMORY_X + 1, "%3d: ",
+		  adj_inst_ptr);
+	// If we are scrolling through memory, make the current position
+	// yellow.
+	if (i == 0) SetColor(COLOR_YELLOW);
+	else SetColor(COLOR_CYAN);
+      }
+
+      // Print the instruction...
+      Print(MEMORY_Y + MEMORY_PRE_SIZE + 3 + i, MEMORY_X + 6, "%8s ",
+	    inst_set.GetName( memory[adj_inst_ptr] )());
+
+      Print(MEMORY_Y + MEMORY_PRE_SIZE + 3 + i, MEMORY_X + 15,
+         "                    ");
+
+      // Only list the "Cpy" flag or the "Inj" flag...
+      if (memory.FlagCopied(adj_inst_ptr) == true) {
+	Print(MEMORY_Y + MEMORY_PRE_SIZE + 3 + i, MEMORY_X + 16, "Cpy");
+      }
+      if (memory.FlagInjected(adj_inst_ptr) == true) {
+	Print(MEMORY_Y + MEMORY_PRE_SIZE + 3 + i, MEMORY_X + 16, "Inj");
+      }
+
+      // Other flags we're interested in...
+      if (memory.FlagMutated(adj_inst_ptr) == true) {
+	Print(MEMORY_Y + MEMORY_PRE_SIZE + 3 + i, MEMORY_X + 20, "Mut");
+	}
+      if (memory.FlagExecuted(adj_inst_ptr) == true) {
+	  Print(MEMORY_Y + MEMORY_PRE_SIZE + 3 + i, MEMORY_X + 24, "Exe");
+      }
+      if (memory.FlagBreakpoint(adj_inst_ptr) == true) {
+	Print(MEMORY_Y + MEMORY_PRE_SIZE + 3 + i, MEMORY_X + 28, "Bp");
+      }
+
+      if (adj_inst_ptr == hardware4Stack.GetHead(HEAD_READ, cur_view_thread).GetPosition() &&
+	  cur_mem_space == hardware4Stack.GetHead(HEAD_READ, cur_view_thread).GetMemSpace()) {
+	Print(MEMORY_Y + MEMORY_PRE_SIZE + 3 + i, MEMORY_X + 31, "R");
+      }
+      if (adj_inst_ptr == hardware4Stack.GetHead(HEAD_WRITE, cur_view_thread).GetPosition() &&
+	  cur_mem_space == hardware4Stack.GetHead(HEAD_WRITE, cur_view_thread).GetMemSpace()) {
+	Print(MEMORY_Y + MEMORY_PRE_SIZE + 3 + i, MEMORY_X + 32, "W");
+      }
+      if (adj_inst_ptr == hardware4Stack.GetHead(HEAD_FLOW, cur_view_thread).GetPosition() &&
+	  cur_mem_space == hardware4Stack.GetHead(HEAD_FLOW, cur_view_thread).GetMemSpace()) {
+	  Print(MEMORY_Y + MEMORY_PRE_SIZE + 3 + i, MEMORY_X + 33, "F");
+      }
+    }
+    SetColor(COLOR_WHITE);
+  }
+
+  DrawMiniMap();
 }
 
 void cZoomScreen::UpdateGenotype()
@@ -1064,15 +1401,40 @@
   case ZOOM_SECTION_MEMORY:
     return cCoords(MEMORY_X, MEMORY_Y);
     break;
+
   case ZOOM_SECTION_REGISTERS:
-    return cCoords(REG_X, REG_Y);
+    if(cConfig::GetHardwareType()==HARDWARE_TYPE_CPU_ORIGINAL)
+    {
+      return cCoords(REG_X, REG_Y);
+    }
+    else if(cConfig::GetHardwareType()==HARDWARE_TYPE_CPU_4STACK)
+      {
+	return cCoords(REG_X, REG_Y-1);
+      }
     break;
+    
   case ZOOM_SECTION_STACK:
-    return cCoords(STACK_X, STACK_Y);
+    if(cConfig::GetHardwareType()==HARDWARE_TYPE_CPU_ORIGINAL)
+      {
+	return cCoords(STACK_X, STACK_Y);
+      }
+    else if(cConfig::GetHardwareType()==HARDWARE_TYPE_CPU_4STACK)
+      {
+	return cCoords(STACK_X, STACK_Y-1);
+      }
     break;
+
   case ZOOM_SECTION_INPUTS:
-    return cCoords(INPUT_X, INPUT_Y);
+    if(cConfig::GetHardwareType()==HARDWARE_TYPE_CPU_ORIGINAL)
+      {
+	return cCoords(INPUT_X, INPUT_Y);
+      }
+    else if(cConfig::GetHardwareType()==HARDWARE_TYPE_CPU_4STACK)
+      {
+	return cCoords(INPUT_X, INPUT_Y-1);
+      }
     break;
+    
   case ZOOM_SECTION_MAP:
     return cCoords(MINI_MAP_X, MINI_MAP_Y);
     break;
@@ -1081,27 +1443,87 @@
   return cCoords(0,0);
 }
 
+/*
 cString cZoomScreen::GetSectionName(int in_section)
 {
   switch (in_section) {
   case ZOOM_SECTION_MEMORY:
-    return cString("Memory");
+    if(cConfig::GetHardwareType()==HARDWARE_TYPE_CPU_ORIGINAL)
+      {
+	 return cString("Memory");
+      }
+    else if(cConfig::GetHardwareType()==HARDWARE_TYPE_CPU_4STACK)
+      {
+	return cString("Memory Space");
+      }
     break;
+
   case ZOOM_SECTION_REGISTERS:
-    return cString("Registers");
+    if(cConfig::GetHardwareType()==HARDWARE_TYPE_CPU_ORIGINAL)
+      {
+	 return cString("Registers:");
+      }
+    else if(cConfig::GetHardwareType()==HARDWARE_TYPE_CPU_4STACK)
+      {
+	return cString("Stacks:");
+      }
     break;
+
   case ZOOM_SECTION_STACK:
-    return cString("Stack");
+    return cString("Stack ");
     break;
+
   case ZOOM_SECTION_INPUTS:
-    return cString("Inputs");
+    return cString("Inputs:");
     break;
+
   case ZOOM_SECTION_MAP:
     return cString("Mini-Map");
     break;
   }
 
   return cString("Unknown!");
+}*/
+
+char* cZoomScreen::GetSectionName(int in_section)
+{
+  switch (in_section) {
+  case ZOOM_SECTION_MEMORY:
+    if(cConfig::GetHardwareType()==HARDWARE_TYPE_CPU_ORIGINAL)
+      {
+	 return "Memory";
+      }
+    else if(cConfig::GetHardwareType()==HARDWARE_TYPE_CPU_4STACK)
+      {
+	return "Memory Space";
+      }
+    break;
+
+  case ZOOM_SECTION_REGISTERS:
+    if(cConfig::GetHardwareType()==HARDWARE_TYPE_CPU_ORIGINAL)
+      {
+	 return "Registers:";
+      }
+    else if(cConfig::GetHardwareType()==HARDWARE_TYPE_CPU_4STACK)
+      {
+	return "Stacks:";
+      }
+    break;
+
+  case ZOOM_SECTION_STACK:
+    return "Stack ";
+    break;
+
+  case ZOOM_SECTION_INPUTS:
+    return "Inputs:";
+    break;
+
+  case ZOOM_SECTION_MAP:
+    return "Mini-Map";
+    break;
+  }
+
+  return "Unknown!";
 }
 
 void cZoomScreen::SetActiveSection(int in_section)
@@ -1111,16 +1533,16 @@
     cCoords sect_coords(GetSectionCoords(active_section));
     sect_coords.Translate(2, 1);
     SetColor(COLOR_WHITE);
-    Print(sect_coords.GetY(), sect_coords.GetX(),
-	  GetSectionName(active_section)());
+    Print(sect_coords.GetY(), sect_coords.GetX(), "%s",
+	  GetSectionName(active_section));
     active_section = in_section;
   }
 
   cCoords sect_coords(GetSectionCoords(active_section));
   sect_coords.Translate(2, 1);
   SetBoldColor(COLOR_BLUE);
-  Print(sect_coords.GetY(), sect_coords.GetX(),
-	GetSectionName(active_section)());
+  Print(sect_coords.GetY(), sect_coords.GetX(), "%s",
+	GetSectionName(active_section));
   SetColor(COLOR_WHITE);
 }
 
@@ -1132,12 +1554,36 @@
   if (mode == ZOOM_MODE_STATS    && DoInputStats(in_char)) return;
   if (mode == ZOOM_MODE_GENOTYPE && DoInputGenotype(in_char)) return;
 
+  int num_threads;
+  if(cConfig::GetHardwareType()==HARDWARE_TYPE_CPU_ORIGINAL)
+    {
+       cHardwareCPU & hardwareCPU = 
+      (cHardwareCPU &) info.GetActiveCell()->GetOrganism()->GetHardware();
+       num_threads = hardwareCPU.GetNumThreads();
+    }
+  else if(cConfig::GetHardwareType()==HARDWARE_TYPE_CPU_4STACK)
+    {
+      cHardware4Stack & hardware4Stack = 
+	(cHardware4Stack &) info.GetActiveCell()->GetOrganism()->GetHardware();
+      num_threads = hardware4Stack.GetNumThreads();
+    }
   switch(in_char) {
   case 't':
   case 'T':
-    ThreadOptions();
+    if(num_threads>1)
+      {
+	memory_offset=0;
+	++cur_view_thread%=num_threads;
+	if(cConfig::GetHardwareType()==HARDWARE_TYPE_CPU_4STACK)
+	  {
+	    cHardware4Stack & hardware4Stack = 
+	      (cHardware4Stack &) info.GetActiveCell()->GetOrganism()->GetHardware();
+	    cur_mem_space=hardware4Stack.IP(cur_view_thread).GetMemSpace();
+	  }
+	//ThreadOptions();
+	Update();
+      }
     break;
-
   /*
     case 'x':
     case 'X':
@@ -1187,6 +1633,7 @@
     if (active_section == ZOOM_SECTION_MAP) {
       mini_center_id += map_x_size;
       mini_center_id %= population.GetSize();
+      cur_view_thread=0;
       if (population.GetCell(mini_center_id).IsOccupied()) {
 	memory_offset = 0;
 	info.SetActiveCell( &(population.GetCell(mini_center_id)));
@@ -1201,6 +1648,7 @@
   case KEY_UP:
     if (active_section == ZOOM_SECTION_MAP) {
       mini_center_id -= map_x_size;
+      cur_view_thread=0;
       if (mini_center_id < 0) mini_center_id += population.GetSize();
       if (population.GetCell(mini_center_id).IsOccupied()) {
 	memory_offset = 0;
@@ -1214,15 +1662,23 @@
     break;
   case '6':
   case KEY_RIGHT:
-    if (active_section == ZOOM_SECTION_MAP) {
-      mini_center_id++;
-      if (mini_center_id == population.GetSize()) mini_center_id = 0;
-      if (population.GetCell(mini_center_id).IsOccupied()) {
-	memory_offset = 0;
-	info.SetActiveCell( &(population.GetCell(mini_center_id)));
+    if (active_section == ZOOM_SECTION_MAP) 
+      {
+	mini_center_id++;
+	if (mini_center_id == population.GetSize()) mini_center_id = 0;
+	if (population.GetCell(mini_center_id).IsOccupied()) {
+	  memory_offset = 0;
+	  info.SetActiveCell( &(population.GetCell(mini_center_id)));
+	}
       }
-      Update();
-    }
+    else if (active_section == ZOOM_SECTION_MEMORY)
+      {
+	if(cConfig::GetHardwareType() == HARDWARE_TYPE_CPU_4STACK)
+	  {
+	    ++cur_mem_space%=4;
+	  }
+      }
+    Update(); 
     break;
   case '4':
   case KEY_LEFT:
@@ -1233,18 +1689,39 @@
 	memory_offset = 0;
 	info.SetActiveCell( &(population.GetCell(mini_center_id)));
       }
-      Update();
     }
+    else if (active_section == ZOOM_SECTION_MEMORY) {
+      if(cConfig::GetHardwareType()==HARDWARE_TYPE_CPU_4STACK)
+	{
+	  cur_mem_space+=3;
+	  cur_mem_space%=4;
+	}
+    }
+    Update();
+    break;
+  case 'K':
+  case 'k':
+    if(cConfig::GetHardwareType()==HARDWARE_TYPE_CPU_4STACK) {
+      ++cur_stack%=4;
+    }
+    Update();
     break;
+    //case '<':
+    // if(hardware_type==HARDWARE_TYPE_CPU_4STACK)
+    //  {
+    //cur_stack=(cur_stack-1);
+    //if(cur_stack<0) cur_stack=3;
+    //}
+    //Update();
+    //break;
   case '+':
   case '=':
-    ++map_mode %= NUM_MAPS;
+    info.IncMapMode();
     Update();
     break;
   case '-':
   case '_':
-    map_mode += NUM_MAPS;
-    --map_mode %= NUM_MAPS;
+    info.DecMapMode();
     Update();
     break;
   case '\n':
@@ -1340,26 +1817,27 @@
 
   // Setup the start color for the map...
   SetColor(COLOR_WHITE);
+  mini_center_id = info.GetActiveCell()->GetID();
 
   const int name_x = MINI_MAP_X + 4;
   const int name_y = MINI_MAP_Y + 11;
-  if (mode == MAP_BASIC)           Print(name_y, name_x, "Genotypes");
-  else if (mode == MAP_SPECIES)    Print(name_y, name_x, " Species ");
-  else if (mode == MAP_COMBO)      Print(name_y, name_x, "  Combo  ");
-  else if (mode == MAP_INJECT)     Print(name_y, name_x, "Modified ");
-  else if (mode == MAP_RESOURCE)   Print(name_y, name_x, "Resources");
-  else if (mode == MAP_AGE)        Print(name_y, name_x, "   Age   ");
-  else if (mode == MAP_BREED_TRUE) Print(name_y, name_x, "BreedTrue");
-  else if (mode == MAP_PARASITE)   Print(name_y, name_x, "Parasites");
-  else if (mode == MAP_MUTATIONS)  Print(name_y, name_x, "Mutations");
-  else if (mode == MAP_THREAD)     Print(name_y, name_x, " Threads ");
-  else if (mode == MAP_LINEAGE)    Print(name_y, name_x, " Lineage ");
+  if (info.GetMapMode() == MAP_BASIC)           Print(name_y, name_x, "Genotypes");
+  else if (info.GetMapMode() == MAP_SPECIES)    Print(name_y, name_x, " Species ");
+  else if (info.GetMapMode() == MAP_COMBO)      Print(name_y, name_x, "  Combo  ");
+  else if (info.GetMapMode() == MAP_INJECT)     Print(name_y, name_x, "Modified ");
+  else if (info.GetMapMode() == MAP_RESOURCE)   Print(name_y, name_x, "Resources");
+  else if (info.GetMapMode() == MAP_AGE)        Print(name_y, name_x, "   Age   ");
+  else if (info.GetMapMode() == MAP_BREED_TRUE) Print(name_y, name_x, "BreedTrue");
+  else if (info.GetMapMode() == MAP_PARASITE)   Print(name_y, name_x, "Parasites");
+  else if (info.GetMapMode() == MAP_MUTATIONS)  Print(name_y, name_x, "Mutations");
+  else if (info.GetMapMode() == MAP_THREAD)     Print(name_y, name_x, " Threads ");
+  else if (info.GetMapMode() == MAP_LINEAGE)    Print(name_y, name_x, " Lineage ");
 
 
   int virtual_x = (mini_center_id % map_x_size) + map_x_size;
   int virtual_y = (mini_center_id / map_x_size) + map_y_size;
 
-  info.SetupSymbolMaps(mode, HasColors());
+  info.SetupSymbolMaps(info.GetMapMode(), HasColors());
 
   for (int y = -3; y <= 3 && y < map_y_size - 3; y++) {
     Move(MINI_MAP_Y + 6 + y, MINI_MAP_X + 2);
Index: avida/current/source/viewers/zoom_screen.hh
diff -u avida/current/source/viewers/zoom_screen.hh:1.7 avida/current/source/viewers/zoom_screen.hh:1.7.4.1
--- avida/current/source/viewers/zoom_screen.hh:1.7	Sun Nov 11 15:21:03 2001
+++ avida/current/source/viewers/zoom_screen.hh	Tue Aug 19 10:50:16 2003
@@ -66,19 +66,28 @@
   int map_y_size;
 
   int mode;
-  int map_mode;
+  //int map_mode;
   bool inst_view_mode;
   int memory_offset;
   bool parasite_zoom; // If true, then view original parasite code, not host
   int active_section;
   int task_offset;
+  //int hardware_type;
+  int cur_stack;
+  int cur_mem_space;
+  int cur_view_thread;
 
 private:
-  void DrawCPU();
+  void DrawCPU_Original();
+  void DrawCPU_4Stack();
   void DrawStats();
   void DrawGenotype();
-  void UpdateCPU();
-  void UpdateStats();
+  void UpdateCPU(cHardwareBase & hardware);
+  void UpdateCPU_Original(cHardwareBase & hardware);
+  void UpdateCPU_4Stack(cHardwareBase & hardware);
+  void UpdateStats(cHardwareBase & hardware);
+  void UpdateStats_CPU(cHardwareBase & hardware);
+  void UpdateStats_4Stack(cHardwareBase & hardware);
   void UpdateGenotype();
 
   void EditMemory();
@@ -93,7 +102,8 @@
   void ViewThreads();
 
   cCoords GetSectionCoords(int in_section);
-  cString GetSectionName(int in_section);
+  //cString GetSectionName(int in_section);
+  char* GetSectionName(int in_section);
   void SetActiveSection(int in_section);
 
   void DrawMiniMap();

Index: avida/current/source/viewers/environment_screen.cc
+++ avida/current/source/viewers/environment_screen.cc
//////////////////////////////////////////////////////////////////////////////
// Copyright (C) 1993 - 2001 California Institute of Technology             //
//                                                                          //
// Read the COPYING and README files, or contact 'avida at alife.org',         //
// before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
//////////////////////////////////////////////////////////////////////////////

#include "../main/config.hh"
#include "../main/environment.hh"
#include "../main/genebank.hh"
#include "../main/genotype.hh"
#include "../main/population.hh"
#include "../main/species.hh"
#include "../main/stats.hh"
#include "../main/tasks.hh"
#include "../main/population_cell.hh"
#include "../main/organism.hh"

#include "environment_screen.hh"


using namespace std;


void cEnvironmentScreen::Draw()
{
  SetBoldColor(COLOR_WHITE);
  Print(1, 54, "[ ]               [ ]");
  if (info.GetPauseLevel()) {
    Print(3, 54, "Un-[ ]ause");
    Print(4, 54, "[ ]ext Update");
  } else {
    Print(3, 54, "[ ]ause   ");
    Print(4, 54, "             ");
  }
 
  SetBoldColor(COLOR_CYAN);
  Print(1, 55, "<");
  Print(1, 73, ">");
  Print(5, 54, "[        ]");
  if (info.GetPauseLevel()) {
    Print(3, 58, "P");
    Print(4, 55, "N");
  } else {
    Print(3, 55, "P");
  }
  Print(5, 55, "UP, DOWN");

  if(mode==ENVIRONMENT_MODE_RESOURCE)
    DrawResource();
  else
    DrawReaction();
  Update();
}

void cEnvironmentScreen::DrawResource()
{
  const cResourceLib & res_lib = population.GetEnvironment().GetResourceLib();

  SetBoldColor(COLOR_WHITE);
   
  Print(0, 0, " --Name-- ");
  Print(0, 12, "--Inflow--");
  Print(0, 24, "--Outflow--");
  Print(0, 37, "--Quantity--");
  
  Print(res_lib.GetSize()+3, 2, "Reactions associated with Resource ");
  Print(res_lib.GetSize()+4, 2, "--Name--  --Num Rxns (last update)--  --");
  
  Print(6, 54, "Next Resource");
  
  SetBoldColor(COLOR_CYAN);
  for(int i=0; i<res_lib.GetSize(); i++)
    {
      Print(i+1, 1, res_lib.GetResource(i)->GetName());
      Print(i+1, 12, "%7.2f", res_lib.GetResource(i)->GetInflow());
      Print(i+1, 24, "%7.2f", res_lib.GetResource(i)->GetOutflow());
    }
  if (info.GetPauseLevel()) {
    Print(3, 58, "P");
    Print(4, 55, "N");
  } else {
    Print(3, 55, "P");
  }
  Print(5, 55, "UP, DOWN");
  

  SetColor(COLOR_WHITE);
  Box(0, res_lib.GetSize()+2, Width(), Height()-res_lib.GetSize()-2);

  SetBoldColor(COLOR_YELLOW);
  Print(1, 58, "Resource View");
}

void cEnvironmentScreen::DrawReaction()
{
  const cReactionLib & rxn_lib = population.GetEnvironment().GetReactionLib();

  SetBoldColor(COLOR_WHITE);
   
  Print(0, 0, " --Name-- ");
  //Print(0, 12, "--Inflow--");
  //Print(0, 24, "--Outflow--");
  //Print(0, 37, "--Quantity--");
  
  Print(rxn_lib.GetSize()+3, 2, "Resources associated with Reaction ");
  Print(rxn_lib.GetSize()+4, 2, "--Name--  --Inflow--  --Outflow--  --Quantity--");
  
  Print(6, 54, "Next Reaction");
  
  SetBoldColor(COLOR_CYAN);
  for(int i=0; i<rxn_lib.GetSize(); i++)
    {
      Print(i+1, 1, rxn_lib.GetReaction(i)->GetName());
      //Print(i+1, 12, "%7.2f", res_lib.GetResource(i)->GetInflow());
      //Print(i+1, 24, "%7.2f", res_lib.GetResource(i)->GetOutflow());
    }  

  SetColor(COLOR_WHITE);
  Box(0, rxn_lib.GetSize()+2, Width(), Height()-rxn_lib.GetSize()-2);

  SetBoldColor(COLOR_YELLOW);
  Print(1, 58, "Reaction View");
}

void cEnvironmentScreen::Update()
{
  if(mode==ENVIRONMENT_MODE_RESOURCE)
    UpdateResource();
  else
    UpdateReaction();
  Refresh();
}

void cEnvironmentScreen::UpdateResource()
{
  const cResourceLib & res_lib = population.GetEnvironment().GetResourceLib();
  const cReactionLib & rxn_lib = population.GetEnvironment().GetReactionLib();

  SetBoldColor(COLOR_CYAN);
  //int j=0;
  //int last_count=0;
  for(int i=0; i<population.GetResources().GetSize(); i++)
    {
      Print(i+1, 40, "%7.2f", population.GetResources()[i]);
      //if(population.GetResources()[i]/last_count < population.GetResources()[i].
      //Print(i+2, 65, "%7.2f", population.GetResources()[i]/last_count);
    }
 
  SetBoldColor(COLOR_BLUE);
  Print(res_selection+1, 1, res_lib.GetResource(res_selection)->GetName());
  Print(res_selection+1, 12, "%7.2f", res_lib.GetResource(res_selection)->GetInflow());
  Print(res_selection+1, 24, "%7.2f", res_lib.GetResource(res_selection)->GetOutflow());
  Print(res_selection+1, 40, "%7.2f", population.GetResources()[res_selection]);
 
  int offset=0;

  SetBoldColor(COLOR_CYAN);
  for(int i=0; i<rxn_lib.GetSize(); i++)
    {
      for(int j=0; j<rxn_lib.GetReaction(i)->GetProcesses().GetSize(); j++)
	{
	  if(rxn_lib.GetReaction(i)->GetProcesses().GetPos(j)->GetResource()->GetName() == 
	     res_lib.GetResource(res_selection)->GetName())
	    {
	      Print(population.GetResources().GetSize()+5+offset, 2, 
		    rxn_lib.GetReaction(i)->GetName());
	      offset++;
	    }
	}
    }
  
  SetBoldColor(COLOR_WHITE);
  Print(res_lib.GetSize()+3, 37, "%s", res_lib.GetResource(res_selection)->GetName().GetData());
  Print(res_lib.GetSize()+3, res_lib.GetResource(res_selection)->GetName().GetSize()+37, ":");
  Print(res_lib.GetSize()+3, res_lib.GetResource(res_selection)->GetName().GetSize()+38, "        ");
    
}

void cEnvironmentScreen::UpdateReaction()
{
  const cReactionLib & rxn_lib = population.GetEnvironment().GetReactionLib();
  const cResourceLib & res_lib = population.GetEnvironment().GetResourceLib();

  SetBoldColor(COLOR_CYAN);
  //int j=0;
  //int last_count=0;
  for(int i=0; i<population.GetStats().GetReactions().GetSize(); i++)
    {
      Print(i+1, 40, "%7.2f", population.GetStats().GetReactions()[i]);
      //if(population.GetResources()[i]/last_count < population.GetResources()[i].
      //Print(i+2, 65, "%7.2f", population.GetResources()[i]/last_count);
    }
 
  SetBoldColor(COLOR_BLUE);
  Print(rxn_selection+1, 1, rxn_lib.GetReaction(rxn_selection)->GetName());
  Print(rxn_selection+1, 40, "%7.2f", population.GetStats().GetReactions()[rxn_selection]);
    

  int offset=0;

  SetBoldColor(COLOR_CYAN);
  for(int i=0; i<rxn_lib.GetReaction(rxn_selection)->GetProcesses().GetSize(); i++)
    {
      Print(population.GetStats().GetReactions().GetSize()+5+offset, 2, 
	    rxn_lib.GetReaction(rxn_selection)->GetProcesses().GetPos(i)->GetResource()->GetName());
      Print(population.GetStats().GetReactions().GetSize()+5+offset, 13, "%7.2f",
	    rxn_lib.GetReaction(rxn_selection)->GetProcesses().GetPos(i)->GetResource()->GetInflow());
      Print(population.GetStats().GetReactions().GetSize()+5+offset, 25, "%7.2f",
	    rxn_lib.GetReaction(rxn_selection)->GetProcesses().GetPos(i)->GetResource()->GetOutflow());
      for(int j=0; j<res_lib.GetSize(); j++)
	{
	  if(res_lib.GetResource(j)->GetName() ==
	     rxn_lib.GetReaction(rxn_selection)->GetProcesses().GetPos(i)->GetResource()->GetName())
	    Print(population.GetStats().GetReactions().GetSize()+5+offset, 40, "%7.2f", 
		  population.GetResources()[j]);
	}
      offset++;  
    }
  SetBoldColor(COLOR_WHITE);
  Print(rxn_lib.GetSize()+3, 37, "%s", rxn_lib.GetReaction(rxn_selection)->GetName().GetData());
  Print(rxn_lib.GetSize()+3, rxn_lib.GetReaction(rxn_selection)->GetName().GetSize()+37, ":");
  Print(rxn_lib.GetSize()+3, rxn_lib.GetReaction(rxn_selection)->GetName().GetSize()+38, "        ");
   
}

void cEnvironmentScreen::DoInput(int in_char)
{
  int last_selection;
  const cResourceLib & res_lib = population.GetEnvironment().GetResourceLib();
  const cReactionLib & rxn_lib = population.GetEnvironment().GetReactionLib();
  SetBoldColor(COLOR_CYAN);

  switch (in_char) {
  case KEY_DOWN:
    if(mode==ENVIRONMENT_MODE_RESOURCE ) {
      last_selection=res_selection;
      res_selection++;
      res_selection%=population.GetResources().GetSize();

      Print(last_selection+1, 1, res_lib.GetResource(last_selection)->GetName());
      Print(last_selection+1, 12, "%7.2f", res_lib.GetResource(last_selection)->GetInflow());
      Print(last_selection+1, 24, "%7.2f", res_lib.GetResource(last_selection)->GetOutflow());
    }
    else {
      last_selection=rxn_selection;
      rxn_selection++;
      rxn_selection%=population.GetStats().GetReactions().GetSize();

      Print(last_selection+1, 1, rxn_lib.GetReaction(last_selection)->GetName());
      //Print(last_selection+1, 12, "%7.2f", rxn_lib.GetReaction(last_selection)->GetInflow());
      //Print(last_selection+1, 24, "%7.2f", rxn_lib.GetReaction(last_selection)->GetOutflow());
    }

    Update();
    break;
  case KEY_UP:
    if(mode==ENVIRONMENT_MODE_RESOURCE) {
      last_selection=res_selection;
      res_selection--;
      if(res_selection < 0) res_selection=population.GetResources().GetSize()-1;
   
      Print(last_selection+1, 1, res_lib.GetResource(last_selection)->GetName());
      Print(last_selection+1, 12, "%7.2f", res_lib.GetResource(last_selection)->GetInflow());
      Print(last_selection+1, 24, "%7.2f", res_lib.GetResource(last_selection)->GetOutflow());
    }
    else {
      last_selection=rxn_selection;
      rxn_selection--;
      if(rxn_selection < 0) rxn_selection=population.GetStats().GetReactions().GetSize()-1;
   
      Print(last_selection+1, 1, rxn_lib.GetReaction(last_selection)->GetName());
      //Print(last_selection+1, 12, "%7.2f", rxn_lib.GetReaction(last_selection)->GetInflow());
      //Print(last_selection+1, 24, "%7.2f", rxn_lib.GetReaction(last_selection)->GetOutflow());
    }

    Update();
    break;
  case '>':
  case '<':
    if(mode==ENVIRONMENT_MODE_RESOURCE)
      mode=ENVIRONMENT_MODE_REACTION;
    else
      mode=ENVIRONMENT_MODE_RESOURCE;
    Clear();
    Draw();
    break;
    }
}


Index: avida/current/source/viewers/environment_screen.hh
+++ avida/current/source/viewers/environment_screen.hh
//////////////////////////////////////////////////////////////////////////////
// Copyright (C) 1993 - 2001 California Institute of Technology             //
//                                                                          //
// Read the COPYING and README files, or contact 'avida at alife.org',         //
// before continuing.  SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE.     //
//////////////////////////////////////////////////////////////////////////////

#ifndef VIEW_ENVIRONMENT_SCREEN_HH
#define VIEW_ENVIRONMENT_SCREEN_HH

#include "text_screen.hh"

class cEnvironmentScreen : public cScreen {
protected:
  cPopulation & population;
  int mode;
  int res_selection;
  int rxn_selection;
  //int task_offset;
  //int task_rows;
  //int task_cols;
  static const int ENVIRONMENT_MODE_RESOURCE = 0;
  static const int ENVIRONMENT_MODE_REACTION = 1;

public:
  cEnvironmentScreen(int y_size, int x_size, int y_start, int x_start,
	       cViewInfo & in_info, cPopulation & in_pop) :
    cScreen(y_size, x_size, y_start, x_start, in_info),
    population(in_pop) { mode=ENVIRONMENT_MODE_RESOURCE; res_selection=rxn_selection=0; }
    //task_rows = Height() - 16;
    // task_cols = Width() / 20;
  //}
  virtual ~cEnvironmentScreen() { ; }

  // Virtual in base screen...
  void Draw();
  void Update();
  void DoInput(int in_char);

  void DrawResource();
  void DrawReaction();
  void UpdateResource();
  void UpdateReaction();
};

#endif

Index: avida/current/source/viewers/ncurses-viewer.ilk
+++ avida/current/source/viewers/ncurses-viewer.ilk

Index: avida/current/source/main/org_message.cc
+++ avida/current/source/main/org_message.cc
#include "org_message.hh"
#include <string>
#include <sstream>

void cOrgMessage::SetData(int in_data)
{
  std::stringstream ss;
  ss << in_data;
  ss >> data;
}

void cOrgMessage::SetData(double in_data)
{
  std::stringstream ss;
  ss << in_data;
  ss >> data;
}

void cOrgMessage::GetData(int & in_data)
{
  in_data=atoi(data.c_str());
}

void cOrgMessage::GetData(double & in_data)
{
  in_data=atof(data.c_str());
}

Index: avida/current/source/main/org_message.hh
+++ avida/current/source/main/org_message.hh
#include <string>

class cOrgMessage {
private:
  int time;
  int sender_id;
  int recipient_id;
  std::string label;
  std::string data;

public:
  cOrgMessage() { time=sender_id=recipient_id=-1; label=data=""; }
  cOrgMessage(std::string in_label, std::string in_data) 
  { label = in_label; data = in_data; }
  
  void SetTime(int in_time) { time = in_time; }
  void SetSenderID(int in_id) { sender_id = in_id; }
  void SetRecipientID(int in_id) { recipient_id = in_id; }
  void SetLabel(int in_label) { label = in_label; }
  
  void SetData(std::string in_data) { data = in_data; }
  void SetData(int in_data);
  void SetData(double in_data);

  void GetData(std::string & in_data) { in_data=data; }
  void GetData(int & in_data);
  void GetData(double & in_data);
};


More information about the Avida-cvs mailing list