void InsertProjectTester::testExistingResourceAccount()
{
    Part pp(0);
    MainDocument part( &pp );
    pp.setDocument( &part );

    addResourceGroup( part );
    Resource *r = addResource( part );
    Account *a = addAccount( part );
    part.addCommand( new ResourceModifyAccountCmd( *r, r->account(), a ) );

    Project &p = part.getProject();
    QVERIFY( p.resourceGroupAt( 0 )->numResources() == 1 );

    QDomDocument doc = part.saveXML();

    Part pp2(0);
    MainDocument part2( &pp2 );
    pp2.setDocument( &part2 );

    part2.insertProject( p, 0, 0 );
    QVERIFY( part2.getProject().resourceGroupAt( 0 )->numResources() == 1 );
    QVERIFY( part2.getProject().accounts().allAccounts().contains( a ) );
    QCOMPARE( part2.getProject().resourceGroupAt( 0 )->resourceAt( 0 )->account(), a );

    part2.addCommand( new ResourceModifyAccountCmd( *(part2.getProject().resourceGroupAt( 0 )->resourceAt( 0 )), part2.getProject().resourceGroupAt( 0 )->resourceAt( 0 )->account(), 0 ) );

    KoXmlDocument xdoc;
    xdoc.setContent( doc.toString() );
    part.loadXML( xdoc, 0 );

    part2.insertProject( part.getProject(), 0, 0 );
    QVERIFY( part2.getProject().resourceGroupAt( 0 )->numResources() == 1 );
    QVERIFY( part2.getProject().accounts().allAccounts().contains( a ) );
    QVERIFY( part2.getProject().resourceGroupAt( 0 )->resourceAt( 0 )->account() == 0 );
}
示例#2
0
//enables you to read input from or to write output to a file
void part4(tok_t *input,char * filename,char * c) {
    int newfd;

    if(c == ">") {
        //printf("PART 4\n");
        if ((newfd = open(filename, O_CREAT|O_WRONLY | O_APPEND, 0644)) < 0) {
            perror(input);
            exit(1);
        }

        dup2(newfd, 1);
        close(newfd);
    }
    if(c == "<") {
        if ((newfd = open(filename, O_RDONLY, 0644)) < 0) {
            perror(input);
            exit(1);
        }
        dup2(newfd,0);
        close(newfd);
    }
    part3(input);
    part2(input);
}
示例#3
0
IddUnitString::IddUnitString (const std::string &s)
    : m_original(s), m_converted(s)
{
    // remove differentiation between kg-H2O and kg-Air (will be kg/kg).
    // better to add kg-H2O and kg-air as separate SI base units?
    m_converted = boost::regex_replace(m_converted,boost::regex("-H2O"),"");
    m_converted = boost::regex_replace(m_converted,boost::regex("-[aA]ir"),"");
    m_converted = boost::regex_replace(m_converted,boost::regex("Water"),"");
    m_converted = boost::regex_replace(m_converted,boost::regex("DryAir"),"");

    // basic replacements
    m_converted = boost::regex_replace(m_converted,boost::regex("-"),"*");
    if (!boost::regex_search(m_converted,boost::regex("H2O"))) {
        m_converted = boost::regex_replace(m_converted,boost::regex("([2-9]+)"),"^\\1");
    }
    else {
        m_converted = boost::regex_replace(m_converted,boost::regex("H2O"),"H_{2}O");
    }
    m_converted = boost::regex_replace(m_converted,boost::regex("deltaC"),"K");
    m_converted = boost::regex_replace(m_converted,boost::regex("minutes"),"min");
    m_converted = boost::regex_replace(m_converted,boost::regex("dimensionless"),"");
    m_converted = boost::regex_replace(m_converted,boost::regex("Person"),"person");
    m_converted = boost::regex_replace(m_converted,boost::regex("Rotations Per Minute"),"rpm");
    m_converted = boost::regex_replace(m_converted,boost::regex("ohms"),"ohm");
    m_converted = boost::regex_replace(m_converted,boost::regex("VA"),"V*A");
    m_converted = boost::regex_replace(m_converted,boost::regex("deltaJ"),"J");
    m_converted = boost::regex_replace(m_converted,boost::regex("rev"),"cycle");
    m_converted = boost::regex_replace(m_converted,boost::regex("Ah"),"A*h");

    // relative temperatures
    if (!boost::regex_match(m_converted,boost::regex("C|F"))) {
        m_converted = boost::regex_replace(m_converted,boost::regex("C"),"K");
        m_converted = boost::regex_replace(m_converted,boost::regex("F"),"R");
    }

    // Multiple /'s
    boost::smatch matches;
    if (boost::regex_match(m_converted,matches,boost::regex("(.*)/\\((.*)/(.*)\\)"))) {
        std::string part1(matches[1].first, matches[1].second);
        std::string part2(matches[2].first, matches[2].second);
        std::string part3(matches[3].first, matches[3].second);
        m_converted = part1 + "*" + part3 + "/" + part2;
    }

    if (boost::regex_match(m_converted,matches,boost::regex("\\((.*)/(.*)\\)/(.*)"))) {
        std::string part1(matches[1].first, matches[1].second);
        std::string part2(matches[2].first, matches[2].second);
        std::string part3(matches[3].first, matches[3].second);
        m_converted = part1 + "/" + part2 + "*" + part3;
    }

    if ((!m_converted.empty()) && boost::regex_search(m_converted,boost::regex("g"))) {
        Unit temp = parseUnitString(m_converted);

        // g -> m(kg)
        int gExp = temp.baseUnitExponent("g");
        if (gExp != 0) {
            temp.setBaseUnitExponent("g",0);
            temp.setBaseUnitExponent("kg",gExp);
            bool ok = temp.setScale(-3 * gExp);
            if (ok) {
                m_converted = temp.standardString();
            }
        }
    }

    if ((!m_converted.empty()) && boost::regex_search(m_converted,boost::regex("micron"))) {
        Unit temp = parseUnitString(m_converted);

        int gExp = temp.baseUnitExponent("micron");
        if (gExp != 0) {
            temp.setBaseUnitExponent("micron",0);
            temp.setBaseUnitExponent("m",gExp);
            bool ok = temp.setScale(-6 * gExp);
            if (ok) {
                m_converted = temp.standardString();
            }
        }
    }
}
示例#4
0
      // this is the real one
   void AtmosphericDrag::doCompute(UTCTime utc, EarthBody& rb, Spacecraft& sc)
   {
      // To consist with STK
      double omega_e = 7.292115E-05;  // IERS 1996 conventions
      //double omega_e = rb.getSpinRate(utc);

      Vector<double> r = sc.R();   // satellite position in m
      Vector<double> v = sc.V();   // satellite velocity in m/s

      const double cd = sc.getDragCoeff();
      const double area = sc.getDragArea();
      const double mass = sc.getDryMass();

      double rmag = norm(r);
      double beta = cd * area / mass;  // [m^2/kg]

      // compute the atmospheric density
      double rho = computeDensity(utc, rb, r, v);   // [kg/m^3]

      // debuging...
      //rho  = 6.3097802844338E-12;
      
      // compute the relative velocity vector and magnitude
      Vector<double> we(3,0.0);
      we(2)= omega_e;

      Vector<double> wxr = cross(we,r);
      Vector<double> vr = v - wxr;
      double vrmag = norm(vr);
      
      // form -1/2 (Cd*A/m) rho
      double coeff = -0.5 * beta * rho;
      double coeff2 = coeff * vrmag;

      // compute the acceleration in ECI frame (km/s^2)
      a = vr * coeff2;                                  ///////// a

      // Partial reference: Montenbruck,P248

      // form partial of drag wrt v  
      // da_dv = -0.5*Cd*(A/M)*p*(vr*transpose(vr)/vr+vr1)
      Matrix<double> tr(3,1,0.0);
      tr(0,0)=vr(0);
      tr(1,0)=vr(1);
      tr(2,0)=vr(2);

      Matrix<double> vrvrt = tr*transpose(tr); 
      vrvrt = vrvrt / vrmag;
      
      double eye3[3*3] = {1,0,0,0,1,0,0,0,1};
      Matrix<double> vrm(3,3,0.0);
      vrm = eye3;

      vrm = vrm * vrmag;
      da_dv = (vrvrt + vrm) * coeff;               //////// da_dv

      // da_dr
      // da_dr = -0.5*Cd*(A/M)*vr*dp_dr-da_dv*X(w)
      da_dr.resize(3,3,0.0);

      Matrix<double> X(3,3,0.0);
      X(0,1) = -we(2);      // -wz
      X(0,2) = +we(1);      //  wy
      X(1,0) = +we(2);      // +wz
      X(1,2) = -we(0);      // -wx
      X(2,0) = -we(1);      // -wy
      X(2,1) = +we(0);      // +wx
      
      Matrix<double> part1(3,3,0.0);
      Matrix<double> part2(3,3,0.0);
      
   
      // Get the J2000 to TOD transformation
      Matrix<double> N = ReferenceFrames::J2kToTODMatrix(utc);

      // Transform r from J2000 to TOD
      Vector<double> r_tod = N * r;
      Position geoidPos(r_tod(0),r_tod(1),r_tod(3));
      
      // Satellite height
      double height = geoidPos.getAltitude()/1000.0;              //  convert to [km]
      
      const int n = CIRA_SIZE; ;

      int bracket = 0;

      if (height >= h0[n-1]) 
      {
         bracket = n - 1;
      }
      else 
      {
         for (int i = 0; i < (n-1); i++) 
         {
            if ((height >= h0[i]) && (height < h0[i+1]))
            {
               bracket = i;
            }
         }
      }  // End 'if (height >= h0[n-1]) '
      
      double Hh = H[bracket];
      double coeff4 = -1.0 / (Hh * rmag);

      Vector<double> drhodr = r*coeff4;
      
      Matrix<double> tr2(3,1,0.0);
      tr2(0,0) = drhodr(0);
      tr2(1,0) = drhodr(1);
      tr2(2,0) = drhodr(2);

      part1 = tr*transpose(tr2);      // //Matrix part1 = vr.outerProduct(drhodr);
      part1 = part1*coeff2;

      //part1 = dp_dr*a/rho;
      part2 =-da_dv*X;
      da_dr = part1-part2;

      // form partial of drag wrt cd
      double coeff3 = coeff2 / cd;
      this->dadcd = vr*coeff3;                        ////////   da_dcd

      this->da_dcd(0,0) = dadcd(0);
      this->da_dcd(1,0) = dadcd(1);
      this->da_dcd(2,0) = dadcd(2);

   }  // End of method 'AtmosphericDrag::doCompute()'
示例#5
0
int main(int argc, char **argv) {
  // CHECK:      in esan::initializeLibrary
  // CHECK:      in esan::initializeCacheFrag
  // CHECK-NEXT: in esan::processCompilationUnitInit
  // CHECK-NEXT: in esan::processCacheFragCompilationUnitInit: {{.*}}struct-simple.cpp with 6 class(es)/struct(s)
  // CHECK-NEXT:  Register struct.A#2#11#11: 2 fields
  // CHECK-NEXT:  Register struct.B#2#3#2:   2 fields
  // CHECK-NEXT:  Register union.U#1#3:      1 fields
  // CHECK-NEXT:  Register struct.S#2#11#11: 2 fields
  // CHECK-NEXT:  Register struct.D#3#14#11#11: 3 fields
  // CHECK-NEXT:  Register struct.anon#3#11#11#11: 3 fields
  // CHECK-NEXT: in esan::processCompilationUnitInit
  // CHECK-NEXT: in esan::processCacheFragCompilationUnitInit: {{.*}}struct-simple.cpp with 0 class(es)/struct(s)
  // CHECK-NEXT: in esan::processCompilationUnitInit
  // CHECK-NEXT: in esan::processCacheFragCompilationUnitInit: {{.*}}struct-simple.cpp with 5 class(es)/struct(s)
  // CHECK-NEXT:  Register class.C#3#14#13#13:  3 fields
  // CHECK-NEXT:  Register struct.anon#2#11#11: 2 fields
  // CHECK-NEXT:  Register union.anon#1#3:      1 fields
  // CHECK-NEXT:  Duplicated struct.S#2#11#11:  2 fields
  // CHECK-NEXT:  Register struct.D#3#11#11#11: 3 fields
  struct C c[2];
  struct S s;
  struct D d;
  c[0].cs.x = 0;
  c[1].cs.y = 1;
  c[0].cu.f = 0.0;
  c[1].cu.d = 1.0;
  c[0].c[2] = 0;
  s.s1 = 0;
  d.d1 = 0;
  d.d2 = 0;
  part1();
  part2();
  return 0;
  // CHECK:      in esan::finalizeLibrary
  // CHECK-NEXT: in esan::finalizeCacheFrag
  // CHECK-NEXT: in esan::processCompilationUnitExit
  // CHECK-NEXT: in esan::processCacheFragCompilationUnitExit: {{.*}}struct-simple.cpp with 5 class(es)/struct(s)
  // CHECK-NEXT:  Unregister class.C#3#14#13#13:  3 fields
  // CHECK-NEXT:   {{.*}} class C
  // CHECK-NEXT:   {{.*}}  size = 32, count = 5, ratio = 3, array access = 5
  // CHECK-NEXT:   {{.*}}  # 0: offset = 0,  size = 8,  count = 2, type = %struct.anon = type { i32, i32 }
  // CHECK-NEXT:   {{.*}}  # 1: offset = 8,  size = 8,  count = 2, type = %union.anon = type { double }
  // CHECK-NEXT:   {{.*}}  # 2: offset = 16, size = 10, count = 1, type = [10 x i8]
  // CHECK-NEXT:  Unregister struct.anon#2#11#11: 2 fields
  // CHECK-NEXT:   {{.*}} struct anon
  // CHECK-NEXT:   {{.*}}  size = 8, count = 2, ratio = 1, array access = 0
  // CHECK-NEXT:   {{.*}}  # 0: offset = 0, size = 4, count = 1, type = i32
  // CHECK-NEXT:   {{.*}}  # 1: offset = 4, size = 4, count = 1, type = i32
  // CHECK-NEXT:  Unregister union.anon#1#3:      1 fields
  // CHECK-NEXT:  Unregister struct.S#2#11#11:    2 fields
  // CHECK-NEXT:   {{.*}} struct S
  // CHECK-NEXT:   {{.*}}  size = 8, count = 2, ratio = 2, array access = 0
  // CHECK-NEXT:   {{.*}}  # 0: count = 2
  // CHECK-NEXT:   {{.*}}  # 1: count = 0
  // CHECK-NEXT:  Unregister struct.D#3#11#11#11: 3 fields
  // CHECK-NEXT:   {{.*}} struct D
  // CHECK-NEXT:   {{.*}}  size = 12, count = 2, ratio = 2, array access = 0
  // CHECK-NEXT:   {{.*}}  # 0: offset = 0, size = 4, count = 1, type = i32
  // CHECK-NEXT:   {{.*}}  # 1: offset = 4, size = 4, count = 1, type = i32
  // CHECK-NEXT:   {{.*}}  # 2: offset = 8, size = 4, count = 0, type = i32
  // CHECK-NEXT: in esan::processCompilationUnitExit
  // CHECK-NEXT: in esan::processCacheFragCompilationUnitExit: {{.*}}struct-simple.cpp with 0 class(es)/struct(s)
  // CHECK-NEXT: in esan::processCompilationUnitExit
  // CHECK-NEXT: in esan::processCacheFragCompilationUnitExit: {{.*}}struct-simple.cpp with 6 class(es)/struct(s)
  // CHECK-NEXT:  Unregister struct.A#2#11#11:    2 fields
  // CHECK-NEXT:   {{.*}} struct A
  // CHECK-NEXT:   {{.*}}  size = 8, count = 2049, ratio = 2048, array access = 0
  // CHECK-NEXT:   {{.*}}  # 0: count = 2048
  // CHECK-NEXT:   {{.*}}  # 1: count = 1
  // CHECK-NEXT:  Unregister struct.B#2#3#2:      2 fields
  // CHECK-NEXT:   {{.*}} struct B
  // CHECK-NEXT:   {{.*}}  size = 16, count = 2097153, ratio = 2097152, array access = 0
  // CHECK-NEXT:   {{.*}}  # 0: count = 1
  // CHECK-NEXT:   {{.*}}  # 1: count = 2097152
  // CHECK-NEXT:  Unregister union.U#1#3:         1 fields
  // CHECK-NEXT:  Duplicated struct.S#2#11#11:    2 fields
  // CHECK-NEXT:  Unregister struct.D#3#14#11#11: 3 fields
  // CHECK-NEXT:  {{.*}} struct D
  // CHECK-NEXT:  {{.*}}  size = 128, count = 2097153, ratio = 2097153, array access = 0
  // CHECK-NEXT:  {{.*}}  # 0: count = 1
  // CHECK-NEXT:  {{.*}}  # 1: count = 0
  // CHECK-NEXT:  {{.*}}  # 2: count = 2097152
  // CHECK-NEXT:  Unregister struct.anon#3#11#11#11: 3 fields
  // CHECK-NEXT:  {{.*}} struct anon
  // CHECK-NEXT:  {{.*}}  size = 12, count = 2097152, ratio = 4194304, array access = 2097152
  // CHECK-NEXT:  {{.*}}  # 0: count = 0
  // CHECK-NEXT:  {{.*}}  # 1: count = 2097152
  // CHECK-NEXT:  {{.*}}  # 2: count = 0
  // CHECK-NEXT: {{.*}}EfficiencySanitizer: total struct field access count = 6293518
}
//
// Scans (parses) input external-format schema name.
//
// This method assumes that the parameter  externalSchemaName  only
// contains the external-format schema name.  The syntax of an
// schema name is
//
//   [ <catalog-name-part> ] . <schema-name-part>
//
// A schema name part must be specified; the catalog name part is optional.
//
// The method returns the number of bytes scanned via the parameter
// bytesScanned.  If the scanned schema name is illegal, bytesScanned
// contains the number of bytes examined when the name is determined
// to be invalid.
//
// If the specified external-format schema name is valid, this method
// returns TRUE and saves the parsed ANSI SQL name part into data
// members catalogNamePart_ and schemaNamePart_; otherwise, it returns
// FALSE and does not changes the contents of the data members.
//
NABoolean
ComSchemaName::scan(const NAString &externalSchemaName,
                    size_t &bytesScanned)
{
  size_t count;
  size_t externalSchemaNameLen = externalSchemaName.length();
  bytesScanned = 0;

  #define COPY_VALIDATED_STRING(x)	\
		      ComAnsiNamePart(x, ComAnsiNamePart::INTERNAL_FORMAT)

  if (( SqlParser_Initialized() && SqlParser_NAMETYPE == DF_NSK)       ||
      (!SqlParser_Initialized() && *externalSchemaName.data() == '\\')) {
    ComMPLoc loc(externalSchemaName);
    switch (loc.getFormat()) {
      case ComMPLoc::SUBVOL:
		catalogNamePart_ = COPY_VALIDATED_STRING(loc.getSysDotVol());
		schemaNamePart_  = COPY_VALIDATED_STRING(loc.getSubvolName());
		bytesScanned = externalSchemaNameLen;
		return TRUE;

      case ComMPLoc::FILE:
		if (!loc.hasSubvolName()) {
		  catalogNamePart_ = "";
		  schemaNamePart_  = COPY_VALIDATED_STRING(loc.getFileName());
		  bytesScanned = externalSchemaNameLen;
		  return TRUE;
		}
    }
  }

  // Each ComAnsiNamePart ctor below must be preceded by "count = 0;"
  // -- see ComAnsiNamePart.cpp, and for a better scan implementation,
  //    see ComObjectName::scan() + ComObjectName(bytesScanned) ctor.

  // ---------------------------------------------------------------------
  // Scan the leftmost ANSI SQL name part.
  // ---------------------------------------------------------------------

  count = 0;
  ComAnsiNamePart part1(externalSchemaName, count);
  bytesScanned += count;
  if (NOT part1.isValid())
    return FALSE;

  if (bytesScanned >= externalSchemaNameLen)
  {
    ComASSERT(bytesScanned == externalSchemaNameLen);
    schemaNamePart_  = part1;
    return TRUE;					// "sch"
  }

  // Get past the period separator
  if (NOT ComSqlText.isPeriod(externalSchemaName[bytesScanned++]))
    return FALSE;

  // ---------------------------------------------------------------------
  // Scan the last ANSI SQL name part
  // ---------------------------------------------------------------------

#pragma nowarn(1506)   // warning elimination 
  Int32 remainingLen = externalSchemaNameLen - bytesScanned;
#pragma warn(1506)  // warning elimination 
  NAString remainingName = externalSchemaName(bytesScanned, remainingLen);
  count = 0;
  ComAnsiNamePart part2(remainingName, count);
  bytesScanned += count;
  if (NOT part2.isValid())
    return FALSE;

  if (bytesScanned == externalSchemaNameLen)
  {
    catalogNamePart_ = part1;
    schemaNamePart_  = part2;
    return TRUE;					// "cat.sch"
  }

  // The specified external-format object name contains some extra
  // trailing characters -- illegal.
  //
  return FALSE;

} // ComSchemaName::scan()
void MultiSolidAsciiStlReader::operate()
{
  QFileInfo file_info(GuiMainWindow::pointer()->getFilename());
  readInputFileName(file_info.completeBaseName() + ".stl");
  if (isValid()) {
    double tol = QInputDialog::getText(NULL, "enter STL tolerance", "tolerance", QLineEdit::Normal, "1e-10").toDouble();
    QList<QString> buffer;
    QList<QString> bc_name;
    {
      QFile file(getFileName());
      if (!file.open(QFile::ReadOnly)) {
        EG_ERR_RETURN("unable to open file");
      }
      QTextStream f(&file);
      QString buf = "";
      QString name = "unknown";
      while (!f.atEnd()) {
        QString line = f.readLine();
        buf += line + "\n"; // endline??
        if (line.left(8) == "endsolid") {
          buffer.append(buf);
          buf = "";
          bc_name.append(name);
        } else if (line.left(5) == "solid") {
          name = line.right(line.size() - 6);
        }
      }
    }
    bool first = true;
    int last_bc = 1;
    foreach (QString buf, buffer) {
      QString file_name = getFileName() + ".tmp";
      {
        QFile file(file_name);
        if (!file.open(QFile::WriteOnly)) {
          EG_ERR_RETURN("unable to open file\"" + file_name + "\" for writing");
        }
        QTextStream f(&file);
        f << buf << endl;
      }
      StlReader stl;
      stl.setTolerance(tol);
      stl.setFileName(file_name);
      EG_VTKSP(vtkUnstructuredGrid, grid);
      stl.setGrid(grid);
      stl.setMaximalCleaningIterations(3);
      stl();

      // @todo set boundary names
      EG_VTKDCC(vtkIntArray, bc, grid, "cell_code");
      for (vtkIdType id_cell = 0; id_cell < grid->GetNumberOfCells(); ++id_cell) {
        bc->SetValue(id_cell, last_bc);
      }
      ++last_bc;

      if (first) {
        first = false;
        makeCopy(grid, m_Grid);
      } else {
        MeshPartition part1(m_Grid, true);
        MeshPartition part2(grid, true);
        part1.addPartition(part2);
      }
    }

    last_bc = 1;
    GuiMainWindow::pointer()->resetXmlDoc();
    GuiMainWindow::pointer()->clearBCs();
    foreach (QString name, bc_name) {
      GuiMainWindow::pointer()->addBC(last_bc, BoundaryCondition(name, "patch"));
      ++last_bc;
    }
示例#8
0
文件: B.C 项目: AoJ/SecondReality
main(int argc,char *argv[])
{
	int	endcnt=0;
	FILE	*f1;
	unsigned u;
	int	a,b,c,d,e,x,y,x2,y2,y1;
	dis_partstart();
	{
		_asm mov ax,13h
		_asm int 10h
	}
	waitb();
	memset(vram0,15,64000);
	while(dis_muscode(1)!=1 && !dis_exit());
	waitb();
	waitb();
	waitb();
	waitb();
	for(x=319;x>=0;x--)
	{
		vram0[x+100*320]=0;
		if(!(x&15)) waitb();
	}
	y1=100; a=100*64; b=0;
	while(y1<200)
	{
		b+=16;
		a+=b;
		y2=a/64;
		if(y2>200) y2=200;
		for(y=y1;y<y2;y++)
		{
			memset(vram0+y*320,0,320);
		}
		y1=y2;
		waitb();
	}
	for(a=0;a<70 && !dis_exit();a++) dis_waitb();
	
	memset(defpal,0,768);
	loadpal(defpal,768);
	outp(0x3c0,0x11+0x20);
	outp(0x3c0,255);
	memset(vram0+0*320,255,35*320);
	memset(vram0+35*320,254,1*320);
	memset(vram0+36*320,0,128*320);
	memset(vram0+164*320,254,1*320);
	memset(vram0+165*320,255,35*320);
	defpal[0*3+0]=0;
	defpal[0*3+1]=0;
	defpal[0*3+2]=20;
	defpal[254*3+0]=45;
	defpal[254*3+1]=45;
	defpal[254*3+2]=45;
	defpal[255*3+0]=0;
	defpal[255*3+1]=0;
	defpal[255*3+2]=0;
	loadpal(defpal,768);
	for(a=0;a<200;a++) rows[a]=a*320;
	background=halloc(16384L,4L);
	memset(background,0,64000);
	dotspnt=dots1;
	if(argc==2) 
	{
		switch(*argv[1])
		{
		case '1' : dotspnt=dots4; break;
		case '2' : mode=5; break;
		case '3' : mode=6; break;
		}
		for(a=0;a<256;a++) vram0[a]=vram0[a+320]=a;
		border=1;
	}
	x=y=c=0;
	
	for(a=0;a<256;a++) vram0[a]=vram0[a+320]=255;
	border=0;
	
	while(!dis_exit() && mode!=-1)
	{
		count++;
		setborder(255);
		waitb();
		if(mode==4 && count>0) loadpal(pal,768);
		if(mode==5 && count>500-17) loadpal(pal,768-6);
		if(mode==6 && count>0 && count<20) loadpal(pal,768-6);
		setborder(0);
		if(mode<4) dodots(background,vram);
		else if(mode==4) dodots2(background,vram);
		switch(mode)
		{
		case 0:
			if(count>32) 
			{ 
				NEXTMODE; 
			}
			break;
		case 1:
			if(!count) 
			{
				x=0;
				part1init();
			}
			else part1();
			break;
		case 2:
			{ 
				NEXTMODE;
				if(dotspnt==dots1) { mode=1; dotspnt=dots2; }
				else if(dotspnt==dots2) { mode=1; dotspnt=dots3; }
				else if(dotspnt==dots3) { mode=1; dotspnt=dots4; }
				else for(a=0;a<2048;a++) adddot(0,0,0,0,0);
			}
			break;
		case 3:
			if(count>40) NEXTMODE;
			break;
		case 4:
			if(count>400) 
			{ 
				NEXTMODE; 
			}
			if(!count)
			{
				pal1colp=1;
				memset(background,0,64000);
				for(dotsp=a=0;a<2048;a++)
				{
					dotsp+=4;
					switch(dotspnt[dotsp])
					{
					case 1 :
					case 2 :
					case 3 : doit2(dotspnt[dotsp+2],dotspnt[dotsp+3],254); break;
					default : dotsp=0; break;
					}
				}
				for(a=3;a<32*3;a+=3) 
				{
					pal[a+0]=0;
					pal[a+1]=0;
					pal[a+2]=20;
				}
			}
			a=252-pal1colp;
			d=a+66; if(d>254) d=254;
			c=63;
			for(;a<d;a++,c-=4)
			{
				if(c<0) c=0;
				b=c*c/64;
				pal[a*3+0]=b;
				pal[a*3+1]=b;
				pal[a*3+2]=b<20?20:b;
			}
			a=(254-65);
			pal[a*3+0]=63;
			pal[a*3+1]=63;
			pal[a*3+2]=63;
			pal[1*3+0]=63;
			pal[1*3+1]=63;
			pal[1*3+2]=63;
			pal1colp++;
			if(count>100) 
			{
				for(a=0;a<2048;a++) adddot(0,0,0,0,0);
				NEXTMODE;
			}
			break;
		case 5:
			if(!count) 
			{
				for(u=0;u<128*320;u++)
				{
					if(vram[u]==254-65) vram[u]=1;
					else vram[u]=0;
				}
				part2init();
			}
			else part2();
			break;
		case 6:
			if(!count) 
			{
				part3init();
			}
			else part3();
			break;
		case 7:
			NEXTMODE;
			if(count>100)
			{ 
				NEXTMODE; 
			}
			break;
		default : 
			mode=-1;
			break;
		}
	}
	if(!dis_indemo())
	{
		_asm mov ax,3h
		_asm int 10h
	}