Ejemplo n.º 1
0
void Message::processNext(updateSpeed speed)
{
    do
    {
        if(stream.nextIsWhitespace())
        {
            do
            {
                if(stream.getCharacter()==' ')
                    renderer.putChar(' ');
                else // Line break; stream already advanced
                    renderer.startNewLine();
            } while(stream.nextIsWhitespace());
            
            if(wordWrappingEnabled && !renderer.atLineStart())
                checkWordWrapping();
        }
        
        char c=stream.getCharacter();
        if(c>' ')
        {
            renderer.putChar(c);
            if(speed!=spd_instant)
                sfx(textSFX);
        }
        else
            executeControlCode(c-1);
    } while(speed==spd_instant && !stream.atEnd());
}
Ejemplo n.º 2
0
void GetTriforce::activate()
{
    //get rid off all sprites but Link
    guys.clear();
    items.clear();
    Ewpns.clear();
    Lwpns.clear();
    Sitems.clear();
    chainlinks.clear();
    
    //decorations.clear();
    if(!COOLSCROLL)
        show_subscreen_items=false;
    
    sfx(itemsbuf[triforceID].playsound);
    music_stop();
    
    if(itemsbuf[triforceID].misc1)
        jukebox(itemsbuf[triforceID].misc1+ZC_MIDI_COUNT-1);
    else
        try_zcmusic((char*)"zelda.nsf",5, ZC_MIDI_TRIFORCE);
        
    if(itemsbuf[triforceID].flags & ITEM_GAMEDATA)
        game->lvlitems[dlevel]|=liTRIFORCE;
}
Ejemplo n.º 3
0
FUNCTION int Q4JY(obj user, loc place)
{
  int Q5NC = 0x00;
  loc Q4VS = loc( getLocation(user) );
  int success = 0x00;
  int walldur = Q4RN(user, Q42S(this));
  faceHere(user, getDirectionInternal(Q4VS, place));
  int Q4HC = getX(place) - getX(Q4VS);
  int Q4HD = getY(place) - getY(Q4VS);
  loc Q5ID = loc( place );
  loc Q5IE = loc( place );
  loc Q5IF = loc( place );
  loc Q5IG = loc( place );
  int Q67X;
  int Q44V = Q4HC;
  if(Q44V < 0x00)
  {
    Q44V = 0x00 - Q44V;
  }
  int Q44W = Q4HD;
  if(Q44W < 0x00)
  {
    Q44W = 0x00 - Q44W;
  }
  if(Q44V < Q44W)
  {
    setX(Q5ID, getX(place) + 0x01);
    setX(Q5IE, getX(place) - 0x01);
    setX(Q5IF, getX(place) + 0x02);
    setX(Q5IG, getX(place) - 0x02);
    Q67X = 0x398C;
  }
  else
  {
    setY(Q5ID, getY(place) + 0x01);
    setY(Q5IE, getY(place) - 0x01);
    setY(Q5IF, getY(place) + 0x02);
    setY(Q5IG, getY(place) - 0x02);
    Q67X = 0x3996;
  }
  doLocAnimation(place, 0x376A, 0x09, 0x0A, 0x00, 0x00);
  doLocAnimation(Q5ID, 0x376A, 0x09, 0x0A, 0x00, 0x00);
  doLocAnimation(Q5IE, 0x376A, 0x09, 0x0A, 0x00, 0x00);
  doLocAnimation(Q5IF, 0x376A, 0x09, 0x0A, 0x00, 0x00);
  doLocAnimation(Q5IG, 0x376A, 0x09, 0x0A, 0x00, 0x00);
  int Q5EC = 0x00;
  if(Q657(user, 0x37C3, place, Q67X, Q5EC, walldur, 0x01, 0x01) || Q657(user, 0x37C3, Q5ID, Q67X, Q5EC, walldur, 0x01, 0x02) || Q657(user, 0x37C3, Q5IE, Q67X, Q5EC, walldur, 0x01, 0x03) || Q657(user, 0x37C3, Q5IF, Q67X, Q5EC, walldur, 0x01, 0x04) || Q657(user, 0x37C3, Q5IG, Q67X, Q5EC, walldur, 0x01, 0x05))
  {
    Q5NC = 0x01;
    sfx(place, 0x020C, 0x00);
  }
  if(!getCompileFlag(0x01))
  {
    Q554(user, walldur);
  }
  Q5UQ(this);
  return(Q5NC);
}
Ejemplo n.º 4
0
FUNCTION int Q658(obj user)
{
  int Q62A = getObjType(this);
  if(hasObjVar(this, "fuel"))
  {
    int fuel = getObjVar(this, "fuel");
  }
  switch(Q62A)
  {
  case 0x0B1A:
    setObjVar(this, "burning", 0x00);
    setType(this, 0x0A26);
    break;
  case 0x0B1D:
    setObjVar(this, "burning", 0x00);
    setType(this, 0x0A27);
    break;
  case 0x0B26:
    setObjVar(this, "burning", 0x00);
    setType(this, 0x0A29);
    break;
  case 0x1854:
    setObjVar(this, "burning", 0x00);
    setType(this, 0x1853);
    break;
  case 0x1858:
    setObjVar(this, "burning", 0x00);
    setType(this, 0x1857);
    break;
  case 0x184A:
    setObjVar(this, "burning", 0x00);
    setType(this, 0x1849);
    break;
  case 0x184E:
    setObjVar(this, "burning", 0x00);
    setType(this, 0x184D);
    break;
  case 0x0A0F:
    systemMessage(user, "You blow out the candle, and discard it.");
    destroyOne(this);
    break;
  case 0x0A12:
    systemMessage(user, "You douse the torch, and discard it.");
    destroyOne(this);
    break;
  case 0x0A15:
  case 0x0A1A:
  case 0x0A22:
    setObjVar(this, "burning", 0x00);
    setType(this, Q62A + 0x03);
    break;
  default:
    return(0x00);
    break;
  }
  sfx(getLocation(this), 0x47, 0x00);
  return(0x01);
}
Ejemplo n.º 5
0
FUNCTION void Q5VC(obj attacker)
{
  obj n = createGlobalNPCAtSpecificLoc(0x0232, getLocation(this));
  setHue(n, getHue(this));
  int Q4XB = getCurHP(this);
  Q4XB = Q4XB / 0x02;
  setCurHP(n, Q4XB);
  setCurHP(this, Q4XB);
  attack(n, attacker);
  sfx(getLocation(this), random(0x01C8, 0x01CC), 0x00);
  bark(n, "*The slime splits when struck!*");
  return;
}
Ejemplo n.º 6
0
FUNCTION int Q4MJ(obj user)
{
  int Q5NC = 0x00;
  int Q4NC;
  loc Q4VS = loc( getLocation(user) );
  loc there = loc( Q5I9(user) );
  if(!isInMap(there))
  {
    Q4RD(user);
    systemMessage(user, "There is no room to summon that here.");
  }
  else
  {
    faceHere(user, getDirectionInternal(Q4VS, there));
    if(hasObjVar(this, "magicItemModifier"))
    {
      int Q52W = getObjVar(this, "magicItemModifier");
      Q4NC = 0x06 * Q52W;
    }
    else
    {
      if(getSkillLevel(user, 0x19) < 0x0A)
      {
        Q4NC = 0x14;
      }
      else
      {
        Q4NC = 0x14 * getSkillLevel(user, 0x19) / 0x05;
      }
    }
    obj Q4PE = createGlobalNPCAt(0x0259, there, 0x00);
    if(Q4PE != NULL())
    {
      doLocAnimation(there, 0x3728, 0x0A, 0x0A, 0x00, 0x00);
      sfx(there, 0x0217, 0x00);
      setType(Q4PE, 0x0F);
      animateMobile(Q4PE, 0x0C, 0x0F, 0x01, 0x00, 0x00);
      attachScript(Q4PE, "destcrea");
      setObjVar(Q4PE, "summonDifficulty", 0x02EE);
      int Q5ND = Q558(Q4PE, user, 0x64, 0x01);
      callback(Q4PE, Q4NC, 0x08);
      Q5NC = 0x01;
    }
    else
    {
      bark(user, "Whoops...something got in the way.");
    }
  }
  Q5UQ(this);
  return(Q5NC);
}
Ejemplo n.º 7
0
TRIGGER( use )(obj user)
{
  int Q68D = random(0x00, 0x63);
  if(Q68D < 0x05)
  {
    Q635(this);
  }
  else
  {
    if(Q68D < 0x14)
    {
      sfx(getLocation(this), 0x78, 0x00);
    }
    else
    {
      if(Q68D < 0x28)
      {
        sfx(getLocation(this), 0x79, 0x00);
      }
    }
  }
  return(0x01);
}
Ejemplo n.º 8
0
FUNCTION int Q4IT(obj user, obj usedon, int Q4ID, int Q5NM)
{
  int Q5NC = 0x00;
  if(Q50G(usedon))
  {
    int Q4NC;
    loc Q4VS = loc( getLocation(user) );
    loc there = loc( getLocation(usedon) );
    int Q5VZ;
    faceHere(user, getDirectionInternal(Q4VS, there));
    if(hasObjVar(this, "magicItemModifier"))
    {
      int Q52W = getObjVar(this, "magicItemModifier");
      Q4NC = 0x06 * Q52W;
      Q5VZ = Q52W;
    }
    else
    {
      Q4NC = 0x06 * getSkillLevel(user, 0x19) / 0x05;
      Q5VZ = (getSkillLevel(user, 0x19) / 0x0A) + 0x01;
    }
    int Q5A7 = 0x373A;
    int Q5AN = 0x01EA;
    if(!Q4ID)
    {
      Q5A7 = 0x374A;
      Q5AN = 0x01E1;
      Q5VZ = 0x00 - Q5VZ;
    }
    sfx(there, 0x01EA, 0x00);
    doMobAnimation(usedon, Q5A7, 0x0A, 0x0F, 0x00, 0x00);
    for(int s = 0x00; s < 0x03; s ++)
    {
      if(Q41Q(usedon, s, Q5VZ, Q4NC))
      {
        Q5NC = 0x01;
      }
    }
    if(!Q4ID)
    {
      Q422(user, usedon, 0x00, Q5NM);
      Q5UK(user, usedon, 0x02, Q5NM);
      Q41C(user, usedon, Q5NM);
      receiveUnhealthyActionFrom(usedon, user);
    }
  }
  Q5UQ(this);
  return(Q5NC);
}
Ejemplo n.º 9
0
TRIGGER( use )(obj user)
{
  loc Q4N2 = loc( 0x14A4, 0x0227, 0x00 );
  list Q5DQ;
  int Q5I4;
  if(!hasObjVar(this, "working"))
  {
    setObjVar(this, "working", Q5I4);
    sfx(getLocation(this), 0x4A, 0x00);
    messageToRange(Q4N2, 0x01, "unlocked", Q5DQ);
    setType(this, 0x108D);
    callback(this, 0x01, 0x27);
  }
  return(0x00);
}
Ejemplo n.º 10
0
FUNCTION int Q4LI(obj user, obj usedon, int Q5NM)
{
  int Q5NC = 0x00;
  if(Q50G(usedon))
  {
    if(!getMobFlag(usedon, 0x02))
    {
      int Q4NC;
      loc Q4VS = loc( getLocation(user) );
      loc there = loc( getLocation(usedon) );
      faceHere(user, getDirectionInternal(Q4VS, there));
      if(hasObjVar(this, "magicItemModifier"))
      {
        Q4NC = 0x02 * (getObjVar(this, "magicItemModifier")) + 0x05;
      }
      else
      {
        Q4NC = (getSkillLevel(user, 0x19) / 0x0A + 0x01) * 0x02 + 0x05;
      }
      if(Q4CN(NULL(), usedon, 0x05))
      {
        Q4NC = Q4NC / 0x02;
      }
      doMobAnimation(usedon, 0x376A, 0x06, Q4NC, 0x00, 0x00);
      sfx(there, 0x0204, 0x00);
      setWaitState(usedon, Q4NC);
      int Q67T = waitState(usedon);
      setMobFlag(usedon, 0x02, 0x01);
      scriptTrig(usedon, 0x01, user);
      if(isValid(usedon))
      {
        Q422(user, usedon, 0x00, Q5NM);
        if(isValid(usedon))
        {
          Q5UK(user, usedon, 0x02, Q5NM);
          if(isValid(usedon))
          {
            attachScript(usedon, "rempara");
            callback(usedon, Q4NC, 0x0D);
          }
        }
      }
    }
  }
  Q5UQ(this);
  return(Q5NC);
}
Ejemplo n.º 11
0
FUNCTION int Q4K8(obj user, obj usedon, int Q5NM)
{
  int Q5NC = 0x00;
  if(Q50G(usedon))
  {
    Q5NC = 0x01;
    loc Q4VS = loc( getLocation(user) );
    loc there = loc( getLocation(usedon) );
    faceHere(user, getDirectionInternal(Q4VS, there));
    doMobAnimation(usedon, 0x374A, 0x0A, 0x0F, 0x00, 0x00);
    sfx(there, 0x01F1, 0x00);
    int Q527 = Q429(this, user, usedon, 0x01, Q5NM);
    Q5UK(user, usedon, 0x02, Q5NM);
  }
  Q5UQ(this);
  return(Q5NC);
}
Ejemplo n.º 12
0
FUNCTION int Q4MA(obj user, obj usedon, int Q5VX, int Q4ID, int Q5NM)
{
  int Q5NC = 0x00;
  int Q463;
  int Q4NC;
  if(Q50G(usedon))
  {
    loc Q4VS = loc( getLocation(user) );
    loc there = loc( getLocation(usedon) );
    faceHere(user, getDirectionInternal(Q4VS, there));
    if(hasObjVar(this, "magicItemModifier"))
    {
      int Q52W = getObjVar(this, "magicItemModifier");
      Q4NC = 0x06 * Q52W;
      Q463 = Q52W;
    }
    else
    {
      Q4NC = 0x06 * getSkillLevel(user, 0x19) / 0x05 + 0x01;
      Q463 = getSkillLevel(user, 0x19) / 0x0A + 0x01;
    }
    if(!Q4ID)
    {
      Q463 = 0x00 - Q463;
    }
    if(!Q41Q(usedon, Q5VX, Q463, Q4NC))
    {
      Q5NC = 0x01;
      Q4RD(user);
    }
    else
    {
      doMobAnimation(usedon, Q4T7(Q5VX, Q4ID), 0x0A, 0x0F, 0x00, 0x00);
      sfx(there, Q4TA(Q5VX, Q4ID), 0x00);
    }
    if(!Q4ID)
    {
      Q422(user, usedon, 0x00, Q5NM);
      Q5UK(user, usedon, 0x02, Q5NM);
      Q41C(user, usedon, Q5NM);
      receiveUnhealthyActionFrom(usedon, user);
    }
  }
  Q5UQ(this);
  return(Q5NC);
}
Ejemplo n.º 13
0
STKUNIT_UNIT_TEST(function, stringFunction_arithmetic_ops)
{
  EXCEPTWATCH;
  for (unsigned ipts = 0; ipts < NPTS; ipts++)
  {
    double x = testpoints[ipts][0];
    double y = testpoints[ipts][1];
    double z = testpoints[ipts][2];
    double t = testpoints[ipts][3];

    // start_demo_stringFunction_arithmetic_ops
    StringFunction sfx("x");                               //python:  sfx = percept.StringFunction("x")
    StringFunction sfy("y");
    StringFunction sfxy(" x - y ");

    // build a new StringFunction from two existing ones
    StringFunction sfxy2 = sfx - sfy;
    double         xy    = x - y;
    double         vxy   = eval(x, y, z, t, sfxy);
    double         vxy2  = eval(x, y, z, t, sfxy2);

    // the two different functions should give the same result
    STKUNIT_EXPECT_DOUBLE_EQ(vxy, vxy2);

    // and they should give the same result as C++
    STKUNIT_EXPECT_DOUBLE_EQ(vxy, xy);

    // end_demo

    StringFunction sfx1("x");
    StringFunction sfy1("y");
    double vx = eval(x, y, z, t, sfx1);
    STKUNIT_EXPECT_DOUBLE_EQ(vx, x);
    double vy = eval(x, y, z, t, sfy1);
    STKUNIT_EXPECT_DOUBLE_EQ(vy, y);

    DO_OP_STKUNIT_UNIT_TEST(-, _minus);
    DO_OP_STKUNIT_UNIT_TEST(+, _plus);
    DO_OP_STKUNIT_UNIT_TEST(*, _mult);
    DO_OP_STKUNIT_UNIT_TEST(/, _div);
  }
}
Ejemplo n.º 14
0
void putendmsg(const char *s,int x,int y,int speed,void(proc)())
{
    int i=0;
    int c=(int)strlen(s)*speed;
    
    for(int f=0; f<c && !Quit; f++)
    {
        if((f%speed)==0)
        {
            if(s[i]!=' ')
                sfx(WAV_MSG);
                
            textprintf_ex(framebuf,zfont,x+(i<<3),y,WHITE,0,"%c",s[i]);
            ++i;
        }
        
        proc();
        advanceframe(true);
    }
}
Ejemplo n.º 15
0
FUNCTION int Q4KL(obj user, obj usedon, int Q5NM)
{
  int Q5NC = 0x00;
  if(Q50G(usedon))
  {
    int damage;
    loc Q4VS = loc( getLocation(user) );
    loc there = loc( getLocation(usedon) );
    faceHere(user, getDirectionInternal(Q4VS, there));
    Q5NC = 0x01;
    doMissile_Mob2Mob(user, usedon, 0x36E4, 0x05, 0x00, 0x00);
    sfx(Q4VS, 0x01E5, 0x00);
    Q57M = usedon;
    Q57L = user;
    Q5UK(user, usedon, 0x02, Q5NM);
    callback(this, 0x01, 0x19);
    Q5NQ = Q5NM;
  }
  Q5UR(this, Q5NC);
  return(Q5NC);
}
Ejemplo n.º 16
0
FUNCTION int Q4MQ(obj user, obj usedon)
{
  int Q5NC = 0x00;
  if(Q50J(usedon))
  {
    loc Q4VS = loc( getLocation(user) );
    loc there = loc( getLocation(usedon) );
    faceHere(user, getDirectionInternal(Q4VS, there));
    doLocAnimation(there, 0x376A, 0x09, 0x20, 0x00, 0x00);
    sfx(there, 0x01FF, 0x00);
    if(hasObjVar(usedon, "isLocked"))
    {
      int Q53N = getObjVar(usedon, "isLocked");
      int Q54R = getSkillLevelReal(user, 0x19) / 0x05;
      if(Q53N < 0xFF)
      {
        int Q53M = Q53N;
        if(Q54R < Q53M)
        {
          barkTo(user, user, "My spell does not seem to have an effect on that lock.");
        }
        else
        {
          removeObjVar(usedon, "isLocked");
          Q5NC = 0x01;
        }
      }
      else
      {
        barkTo(user, user, "My spell had no effect on that lock.");
      }
    }
    else
    {
      barkTo(user, user, "That did not need to be unlocked.");
    }
  }
  Q5UQ(this);
  return(Q5NC);
}
Ejemplo n.º 17
0
void LinkHandler::addDecorations()
{
    fix x=Link.getX();
    fix y=Link.getY();
    fix z=Link.getZ();
    if(isGrassType(COMBOTYPE(x,y+15)) && isGrassType(COMBOTYPE(x+15,y+15))&& z<=8)
    {
        if(!tallGrassDeco)
        {
            tallGrassDeco.reset(new dTallGrass(x, y, dTALLGRASS, 0));
            decorations.add(tallGrassDeco.get());
        }
    }
    else if(tallGrassDeco)
        tallGrassDeco.del();

    if((COMBOTYPE(x,y+15)==cSHALLOWWATER)&&(COMBOTYPE(x+15,y+15)==cSHALLOWWATER) && z==0)
    {
        if(!ripplesDeco)
        {
            ripplesDeco.reset(new dRipples(x, y, dRIPPLES, 0));
            decorations.add(ripplesDeco.get());
        }
    }
    else if(ripplesDeco)
        ripplesDeco.del();

    if(Link.hoverclk>0)
    {
        if(!hoverDeco)
        {
            hoverDeco.reset(new dHover(x, y, dHOVER, 0));
            decorations.add(hoverDeco.get());
            sfx(itemsbuf[current_item_id(itype_hoverboots)].usesound,pan(int(x)));
        }
    }
    else if(hoverDeco)
        hoverDeco.del();
}
Ejemplo n.º 18
0
QStringList Subtitle::Private::find()
{
    if (file_name.isEmpty())
        return QStringList();
    // !fuzzyMatch: return the file
    if (!fuzzy_match) {
        return QStringList() << file_name;
    }
    // found files will be sorted by extensions in sfx order
    QStringList sfx(suffixes);
    if (sfx.isEmpty())
        sfx = supported_suffixes;
    if (sfx.isEmpty())
        return QStringList() << file_name;
    QFileInfo fi(file_name);
    QString name = fi.fileName();
    QString base_name = fi.completeBaseName(); // a.mp4=>a, video suffix has only 1 dot
    QStringList filters, fileters_base;
    foreach (const QString& suf, sfx) {
        filters.append(QString("%1*.%2").arg(name).arg(suf));
        if (name != base_name)
            fileters_base.append(QString("%1*.%2").arg(base_name).arg(suf));
    }
Ejemplo n.º 19
0
STKUNIT_UNIT_TEST(function, stringFunction_test_alias)
{
  EXCEPTWATCH;
  StringFunction sfx("x", Name("sfx"), Dimensions(3), Dimensions(1));
  StringFunction sfy("y", Name("sfy"), Dimensions(3), Dimensions(1));
  StringFunction sfxy("x-y", Name("sfxy"), Dimensions(3), Dimensions(1));
  StringFunction sfembedded("sfxy", Name("sfembedded"), Dimensions(3), Dimensions(1));
  double x = 1.234;
  double y = 5.678;
  double z = 0;
  double t = 0;
  double xy = x-y;
  //StringFunction sfxy1== sfx-sfy;
  eval_print(1,2,3,0, sfxy);
  double vx = eval(x, y, z, t, sfx);
  std::cout << "x = " << x << " vx= " << vx << std::endl;
  STKUNIT_EXPECT_DOUBLE_EQ(vx, x);
  double vy = eval(x, y, z, t, sfy);
  STKUNIT_EXPECT_DOUBLE_EQ(vy, y);
  double vxy = eval(x, y, z, t, sfxy);
  STKUNIT_EXPECT_DOUBLE_EQ(vxy, xy);

  // embedded function
  std::cout << "sfembedded = ..." << sfembedded << std::endl;
  eval_print(1,2,3,0, sfembedded);
  std::cout << "sfembedded = " << eval(x, y, z, t, sfembedded) << std::endl;

  double vxy1 = eval(x, y, z, t, sfembedded);
  STKUNIT_EXPECT_DOUBLE_EQ(vxy1, xy);

  sfembedded.add_alias("sfalias");
  StringFunction sftestalias("sfalias", Name("sftestalias"));
  double vxy2 = eval(x, y, z, t, sftestalias);
  std::cout << "sftestalias = " << eval(x, y, z, t, sftestalias) << std::endl;
  STKUNIT_EXPECT_DOUBLE_EQ(vxy2, xy);
}
Ejemplo n.º 20
0
FUNCTION int Q4LV(obj user, obj usedon)
{
  int Q5NC = 0x00;
  if(Q50G(usedon))
  {
    int Q4NC;
    int defenseBonus;
    loc Q4VS = loc( getLocation(user) );
    loc there = loc( getLocation(usedon) );
    faceHere(user, getDirectionInternal(Q4VS, there));
    if(!hasScript(usedon, "remprtct"))
    {
      doMobAnimation(usedon, 0x375A, 0x09, 0x14, 0x00, 0x00);
      sfx(there, 0x01ED, 0x00);
      if(hasObjVar(this, "magicItemModifier"))
      {
        int Q52W = getObjVar(this, "magicItemModifier");
        Q4NC = 0x06 * Q52W;
        defenseBonus = 0x07;
      }
      else
      {
        defenseBonus = (getSkillLevel(user, 0x19) / 0x0A);
        Q4NC = 0x06 * getSkillLevel(user, 0x19) / 0x05;
      }
      setNaturalAC(usedon, getNaturalAC(usedon) + defenseBonus);
      setObjVar(usedon, "defenseBonus", defenseBonus);
      attachScript(usedon, "remprtct");
      int Q527 = Q41J(user, usedon, 0x00, this);
      callback(usedon, Q4NC, 0x13);
      Q5NC = 0x01;
    }
  }
  Q5UQ(this);
  return(Q5NC);
}
Ejemplo n.º 21
0
void ending()
{
    /*
      *************************
      * WIN THE GAME SEQUENCE *
      *************************
      0    LINK at ZELDA's side
      288  begin WIPE (8px per side per step, each 5 frames)
      363  WIPE complete, DOT out, A/B items out
      QMisc.colors.link_dot = 255;
      show_subscreen_items = false;
      365  first MESSAGE character in
      371  next character in
      407  last character in
      668  LINK out, ZELDA out
      669  LINK in (TRIFORCE overhead), ZELDA in (TRIFORCE overhead)
      733  BLUE flash bg
      734  RED
      735  GREEN
      736  BLACK
      ...
      860  BLACK, LINK out, ZELDA out
      861  LINK in, ZELDA in
      927  first MSG character in
      935  next character in
      1335 last character in
      1461 LINK out, ZELDA out
      1493 begin SCROLL
      */
    
    //get rid off all sprites but Link and Zelda
    items.clear();
    Ewpns.clear();
    Lwpns.clear();
    Sitems.clear();
    chainlinks.clear();
    decorations.clear();
    
    music_stop();
    kill_sfx();
    sfx(WAV_ZELDA);
    Quit=0;
    
    game->set_cheat(game->get_cheat() | (cheat>1)?1:0);
    
    draw_screen_clip_rect_x1=0;
    draw_screen_clip_rect_x2=255;
    draw_screen_clip_rect_y1=0;
    draw_screen_clip_rect_y2=223;
    //draw_screen_clip_rect_show_link=true;
    //draw_screen_clip_rect_show_guys=false;
    
    for(int f=0; f<365; f++)
    {
        if(f==363)
        {
            //363  WIPE complete, DOT out, A/B items out
            QMisc.colors.link_dot = 255;
            show_subscreen_items = false;
            
            for(int i = guys.Count() - 1; i >= 0; i--)
            {
                if(guys.spr(i)->id > gDUMMY9)
                {
                    guys.del(i);
                }
            }
            
            guys.draw(framebuf,true);
            Link.draw(framebuf);
        }
        
        if(f>=288 && ((f-288)%5 == 0))
        {
            //288  begin WIPE (8px per side per step, each 5 frames)
            //TODO::
            draw_screen_clip_rect_x1+=8;
            draw_screen_clip_rect_x2-=8;
            //draw_screen_clip_rect_show_guys=true;
        }
        
        draw_screen(tmpscr);
        advanceframe(true);
        
        if(Quit) return;
    }
    
    clear_bitmap(msgdisplaybuf);
    draw_screen(tmpscr);
    advanceframe(true);
    
    draw_screen_clip_rect_x1=0;
    draw_screen_clip_rect_x2=255;
    //draw_screen_clip_rect_show_guys=false;
    
    char tmpmsg[6][25];
    
    for(int x=0; x<3; x++)
    {
        sprintf(tmpmsg[x], "%.24s", MsgStrings[QMisc.endstring].s+(24*x));
        //    sprintf(tmpmsg[x], "%.24s", MsgStrings[QMisc.endstring].s+(24*x));
        //    strncpy(tmpmsg[x], MsgStrings[QMisc.endstring].s+(24*x), 24);
    }
    
    for(int x=0; x<3; x++)
    {
        sprintf(tmpmsg[x+3], "%.24s", MsgStrings[QMisc.endstring+1].s+(24*x));
        //    strncpy(tmpmsg[x+3], MsgStrings[QMisc.endstring+1].s+(24*x), 24);
    }
    
    if(QMisc.endstring==0)
    {
        putendmsg("THANKS LINK,YOU'RE",32,96,6,noproc);
        putendmsg("THE HERO OF HYRULE.",32,112,6,noproc);
    }
    else
    {
        putendmsg(tmpmsg[0],32,80,6,noproc);
        putendmsg(tmpmsg[1],32,96,6,noproc);
        putendmsg(tmpmsg[2],32,112,6,noproc);
    }
    
    for(int f=408; f<927; f++)
    {
        /*
          668  LINK out, ZELDA out
          669  LINK in (TRIFORCE overhead), ZELDA in (TRIFORCE overhead)
          733  BLUE flash bg
          734  RED
          735  GREEN
          736  BLACK
          ...
          860  BLACK, LINK out, ZELDA out
          861  LINK in, ZELDA in
          */
        if(f==668)
        {
            rectfill(framebuf,120,129,152,145,0);
            blit(framebuf, tmp_bmp, 120,113, 0,0, 32,32);
        }
        
        if(f==860)
        {
            blit(tmp_bmp, framebuf, 0,0, 120,113, 32,32);
        }
        
        if(f==669 || f==861)
        {
            overtile16(framebuf,36,120,129,6,0);//draw Zelda two-handed overhead
            overtile16(framebuf,BSZ?32:29,136,129,6,0);//draw Link two-handed overhead
        }
        
        if(f==733)
        {
            blit(framebuf,scrollbuf,0,playing_field_offset!=0?168:0,0,0,256,passive_subscreen_height);
            
            for(int y=0; y<224; y++)
            {
                for(int x=0; x<256; x++)
                {
                    if(!(framebuf->line[y][x]&15))
                    {
                        framebuf->line[y][x]=16;
                    }
                }
            }
        }
        
        if(f>=733 && f<861)
        {
            static byte flash[4] = {0x12,0x16,0x2A,0x0F};
            RAMpal[16] = NESpal(flash[(f-733)&3]);
            refreshpal=true;
        }
        
        if(f==861)
        {
            blit(scrollbuf,framebuf,0,0,0,playing_field_offset!=0?168:0,256,passive_subscreen_height);
            try_zcmusic((char*)"zelda.nsf", 1, ZC_MIDI_ENDING);
            
            for(int y=0; y<224; y++)
            {
                for(int x=0; x<256; x++)
                {
                    if(framebuf->line[y][x]==16)
                    {
                        framebuf->line[y][x]=0;
                    }
                }
            }
        }
        
        if(f>668 && f!=860)
        {
            put_triforce();
        }
        
        advanceframe(true);
        
        if(Quit)
        {
            return;
        }
    }
    
    if(QMisc.endstring==0)
    {
        putendmsg("FINALLY,",96,160,8,put_triforce);
        putendmsg("PEACE RETURNS TO HYRULE.",32,176,8,put_triforce);
        putendmsg("THIS ENDS THE STORY.",48,200,8,put_triforce);
    }
    else
    {
        putendmsg(tmpmsg[3],32,160,6,noproc);
        putendmsg(tmpmsg[4],32,176,6,noproc);
        putendmsg(tmpmsg[5],32,200,6,noproc);
    }
    
    for(int f=1336; f<1492; f++)
    {
        if(f<1461)
        {
            put_triforce();
        }
        
        if(f==1461)
        {
            blit(tmp_bmp,framebuf,0,0,120,113,32,32);
        }
        
        advanceframe(true);
        
        if(Quit)
        {
            return;
        }
    }
    
    clear_bitmap(scrollbuf);
    blit(framebuf,scrollbuf,0,0,0,0,256,224);
    endingpal();
    // draw the brick
    puttile16(scrollbuf,3,256,0,csBOSS,0);
    
    int len=600*2;
    
    if(game->get_quest()>1)
    {
        len=720*2;
    }
    
    int creditsLine=0;
    int endTextLine=0;
    
    const EndingTextLine* endText;
    int numEndTextLines=0;
    int deathsYPos=-1;
    int timeYPos=-1;
    
    switch(game->get_quest())
    {
    case 1:
        endText=quest1End;
        numEndTextLines=numQuest1EndLines;
        break;
        
    case 2:
        endText=quest2End;
        numEndTextLines=numQuest2EndLines;
        deathsYPos=792;
        break;
        
    case 3:
    case 4:
        endText=quest34End;
        numEndTextLines=numQuest34EndLines;
        deathsYPos=792;
        break;
        
    default:
        endText=customQuestEnd;
        numEndTextLines=numCustomQuestEndLines;
        deathsYPos=784;
        timeYPos=800;
        break;
    }
    
    for(int f=0; f<len; f++)
    {
        if(!(f&15))
        {
            int y=(f>>1)+224;
            
            if(y>240 && y<584)
            {
                brick(24,224);
                brick(224,224);
            }
            
            if(y==240 || y==584)
            {
                for(int x=24; x<=224; x+=8)
                {
                    brick(x,224);
                }
            }
            
            if(creditsLine<numCreditsLines)
            {
                if(y==credits[creditsLine].yPos)
                {
                    textout_ex(scrollbuf,
                               zfont,
                               credits[creditsLine].text,
                               credits[creditsLine].xPos,
                               224,
                               credits[creditsLine].color,
                               0);
                    creditsLine++;
                }
            }
            else
            {
                if(endTextLine<numEndTextLines &&
                   y==endText[endTextLine].yPos)
                {
                    textout_ex(scrollbuf,
                               zfont,
                               endText[endTextLine].text,
                               endText[endTextLine].xPos,
                               224,
                               endText[endTextLine].color,
                               0);
                    endTextLine++;
                }
                else if(y==deathsYPos)
                    textprintf_ex(scrollbuf, zfont, 72, 224, red, 0,
                                  "%-8s -%3d", game->get_name(), game->get_deaths());
                else if(y==timeYPos)
                {
                    if(game->get_timevalid() && !game->get_cheat())
                        textout_centre_ex(scrollbuf, zfont, time_str_med(game->get_time()), 128, 224, blue, 0);
                }
            }
        }
        
        if(f==112)                                              // after subscreen has scrolled away
        {
            init_NES_mode();
            loadpalset(9,pSprite(spPILE));
            endingpal();
        }
        
        if(f&1)
        {
            blit(scrollbuf,scrollbuf,0,1,0,0,256,232);
        }
        
        blit(scrollbuf,framebuf,0,0,0,0,256,224);
        advanceframe(true);
        
        if(Quit)
        {
            return;
        }
        
        load_control_state();
        rSbtn();
    }
Ejemplo n.º 22
0
TRIGGER( targetobj )(obj user, obj usedon)
{
  if(usedon == NULL())
  {
    return(0x00);
  }
  if(isEquipped(usedon))
  {
    systemMessage(user, "Can't Dye clothing that is being worn.");
    return(0x00);
  }
  int Q66P = getObjType(usedon);
  int Q61R = getHue(this);
  loc Q66R = loc( getLocation(usedon) );
  switch(Q66P)
  {
  case 0x0DEF:
  case 0x0DF8:
  case 0x0DF9:
  case 0x0E1D:
  case 0x0E1E:
  case 0x0E1F:
  case 0x0E75:
  case 0x0E76:
  case 0x0F95:
  case 0x0F96:
  case 0x0F97:
  case 0x0F98:
  case 0x0F99:
  case 0x0F9A:
  case 0x0F9B:
  case 0x0F9C:
  case 0x0F9C:
  case 0x0FA0:
  case 0x0FA1:
  case 0x101F:
  case 0x13A4:
  case 0x0BD5:
  case 0x0BD6:
  case 0x0BD7:
  case 0x0BD8:
  case 0x0BD9:
  case 0x0BDA:
  case 0x0BDB:
  case 0x0BDC:
  case 0x0BDD:
  case 0x0BDE:
  case 0x1515:
  case 0x1516:
  case 0x1517:
  case 0x1518:
  case 0x152E:
  case 0x152F:
  case 0x1530:
  case 0x1531:
  case 0x1537:
  case 0x1538:
  case 0x1539:
  case 0x153A:
  case 0x153B:
  case 0x153C:
  case 0x153D:
  case 0x153E:
  case 0x153F:
  case 0x1540:
  case 0x1541:
  case 0x1542:
  case 0x1543:
  case 0x1544:
  case 0x170B:
  case 0x170C:
  case 0x170F:
  case 0x1710:
  case 0x1711:
  case 0x1712:
  case 0x1713:
  case 0x1714:
  case 0x1715:
  case 0x1716:
  case 0x1717:
  case 0x1718:
  case 0x1719:
  case 0x171A:
  case 0x171B:
  case 0x171C:
  case 0x175D:
  case 0x175E:
  case 0x175F:
  case 0x1760:
  case 0x1761:
  case 0x1762:
  case 0x1763:
  case 0x1764:
  case 0x1765:
  case 0x1766:
  case 0x1767:
  case 0x1768:
  case 0x1914:
  case 0x1915:
  case 0x1B74:
  case 0x1B75:
  case 0x1EFD:
  case 0x1EFE:
  case 0x1EFF:
  case 0x1F00:
  case 0x1F01:
  case 0x1F02:
  case 0x1F03:
  case 0x1F04:
  case 0x1F7B:
  case 0x1F7C:
  case 0x1F9F:
  case 0x1FA0:
  case 0x1FA1:
  case 0x1FA2:
  case 0x1F7B:
  case 0x1F7C:
  case 0x1FA1:
  case 0x1FA1:
  case 0x1FFD:
  case 0x1FFE:
    sfx(Q66R, 0x023E, 0x00);
    setHue(usedon, Q61R);
    break;
  }
  return(0x00);
}
Ejemplo n.º 23
0
void CacheList::load_cache_prof_info(char *filename, level *lev)
{
  int j;
  for (j=0; j<this->total; j++)
    if (list[j].last_access>=0)      // reset all loaded cache items to 0, all non-load to -1
      list[j].last_access=0;

  preload_cache(lev);                // preliminary guesses at stuff to load

  int load_fail=1;
  bFILE *fp=open_file(filename,"rb");
  if (!fp->open_failure())
  {
    spec_directory sd(fp);
    spec_entry *se=sd.find("cache profile info");   // see if the cache profile info is in the file
    if (se)
    {
      fp->seek(se->offset,0);

      char name[255];
      int tnames=0;
      int *fnum_remap;    // remaps old filenumbers into current ones

      tnames=fp->read_uint16();
      if (tnames)                     /// make sure there isn't bad info in the file
      {
    fnum_remap=(int *)malloc(sizeof(int)*tnames);

    int i;
    for (i=0; i<tnames; i++)
    {
      fp->read(name,fp->read_uint8());
      fnum_remap[i]=-1;                    // initialize the map to no-map

      int j;
      for (j=0; j<crc_manager.total_filenames(); j++)
        if (!strcmp(crc_manager.get_filename(j),name))
          fnum_remap[i]=j;
    }

    int tsaved = fp->read_uint32();


    int *priority=(int *)malloc(tsaved*sizeof(int));
    memset(priority,0xff,tsaved*sizeof(int));   // initialize to -1
    int tmatches=0;

    sorted_id_list=(int *)malloc(sizeof(int)*total);
    for (j=0; j<total; j++) sorted_id_list[j]=j;
    qsort(sorted_id_list,total,sizeof(int),s_offset_compare);

    for (i=0; i<tsaved; i++)
    {
      fp->read_uint8(); // read type
      short file_num=fp->read_uint16();
      if (file_num>=tnames)  // bad data?
        file_num=-1;
      else file_num=fnum_remap[file_num];

      uint32_t offset=fp->read_uint32();

      // search for a match
      j=search(sorted_id_list,file_num,offset);
      if (j!=-1)
      {
        if (list[j].last_access<0)  // if not loaded
          list[j].last_access=-2;      // mark as needing loading
        else list[j].last_access=2;   // mark as loaded and needing to stay that way
        priority[i]=j;
        tmatches++;
      }
    }

    free(sorted_id_list);            // was used for searching, no longer needed

    for (j=0; j<total; j++)
      if (list[j].last_access==0)
        unmalloc(list+j);             // free any cache entries that are not accessed at all in the level


    ful=0;
    int tcached=0;
    for (j=0; j<total; j++)    // now load all of the objects until full
    {
//      stat_man->update(j*70/total+25);
      if (list[j].file_number>=0 && list[j].last_access==-2)
      {
        list[j].last_access=-1;
        if (!ful)
        {
          switch (list[j].type)
          {
        case SPEC_BACKTILE : backt(j); break;
        case SPEC_FORETILE : foret(j); break;
        case SPEC_CHARACTER :
        case SPEC_CHARACTER2 : fig(j); break;
        case SPEC_IMAGE : img(j); break;
        case SPEC_PARTICLE : part(j); break;
        case SPEC_EXTERN_SFX : sfx(j); break;
        case SPEC_EXTERNAL_LCACHE : lblock(j); break;
        case SPEC_PALETTE : ctint(j); break;
          }
          tcached++;
        }
      }
    }
    load_fail=0;
//    if (full())
//      dprintf("Cache filled while loading\n");

    if (tsaved>tmatches)
      tmatches=tsaved+1;

    last_access=tmatches+1;
    for (i=0; i<tsaved; i++)      // reorder the last access of each cache to reflect prioirties
    {
      if (priority[i]!=-1)
      {
        if (list[priority[i]].last_access!=-1)            // make sure this wasn't the last item
          list[priority[i]].last_access=tmatches--;
      }
    }

    free(priority);
    free(fnum_remap);


      }
    }
  }

  if (load_fail) // no cache file, go solely on above gueses
  {
    int j;
    for (j=0; j<total; j++)    // now load all of the objects until full, don't free old stuff
    {
//      stat_man->update(j*70/total+25);

      if (list[j].file_number>=0 && list[j].last_access==-2)
      {
    list[j].last_access=-1;
    if (!ful)
    {
      switch (list[j].type)
      {
        case SPEC_BACKTILE : backt(j); break;
        case SPEC_FORETILE : foret(j); break;
        case SPEC_CHARACTER :
        case SPEC_CHARACTER2 : fig(j); break;
        case SPEC_IMAGE : img(j); break;
        case SPEC_PARTICLE : part(j); break;
        case SPEC_EXTERN_SFX : sfx(j); break;
        case SPEC_EXTERNAL_LCACHE : lblock(j); break;
        case SPEC_PALETTE : ctint(j); break;
      }
    }
      }
    }
    if (full())
      dprintf("Cache filled while loading\n");
  }
  delete fp;
}
Ejemplo n.º 24
0
FUNCTION int Q659(obj user)
{
  int Q62A = getObjType(this);
  if(hasObjVar(this, "fuel"))
  {
    int fuel = getObjVar(this, "fuel");
  }
  switch(Q62A)
  {
  case 0x0A26:
    setObjVar(this, "burning", 0x01);
    setType(this, 0x0B1A);
    break;
  case 0x0A27:
    setObjVar(this, "burning", 0x01);
    setType(this, 0x0B1D);
    break;
  case 0x0A29:
    setObjVar(this, "burning", 0x01);
    setType(this, 0x0B26);
    break;
  case 0x1853:
    setObjVar(this, "burning", 0x01);
    setType(this, 0x1854);
    break;
  case 0x1857:
    setObjVar(this, "burning", 0x01);
    setType(this, 0x1858);
    break;
  case 0x1849:
    setObjVar(this, "burning", 0x01);
    setType(this, 0x184A);
    break;
  case 0x184D:
    setObjVar(this, "burning", 0x01);
    setType(this, 0x184E);
    break;
  case 0x0A28:
    int Q527;
    obj Q47F = getBackpack(user);
    obj Q5BO = requestCreateObjectAt(0x0A0F, getLocation(user));
    setObjVar(this, "fuel", 0x64);
    setObjVar(Q5BO, "burning", 0x01);
    attachscript(Q5BO, "torch");
    callback(Q5BO, 0x1E, 0x39);
    if(!isInContainer(this))
    {
      Q527 = teleport(Q5BO, getLocation(this));
      if(getQuantity(this) > 0x01)
      {
        destroyOne(this);
        if(canHold(Q47F, this))
        {
          systemMessage(user, "You put the remaining unlit candles into your backpack.");
          Q527 = putObjContainer(this, Q47F);
        }
        else
        {
          systemMessage(user, "You put the remaining unlit candles at your feet.");
          Q527 = teleport(this, getLocation(user));
        }
      }
    }
    else
    {
      destroyOne(this);
      if(getItemAtSlot(user, 0x02) != NULL())
      {
        systemMessage(user, "You cannot hold the candle, so it has been placed at your feet.");
      }
      else
      {
        Q527 = equipObj(Q5BO, user, 0x02);
        systemMessage(user, "You put the candle in your left hand.");
      }
    }
    if(getQuantity(this) == 0x01)
    {
      destroyOne(this);
    }
    break;
  case 0x0F64:
  case 0x0F6B:
    Q47F = getBackpack(user);
    obj Q5CB = requestCreateObjectAt(0x0A12, getLocation(user));
    setObjVar(this, "fuel", 0x64);
    setObjVar(Q5CB, "burning", 0x01);
    attachscript(Q5CB, "torch");
    callback(Q5CB, 0x1E, 0x39);
    if(!isInContainer(this))
    {
      Q527 = teleport(Q5CB, getLocation(this));
      if(getQuantity(this) > 0x01)
      {
        destroyOne(this);
        if(canHold(Q47F, this))
        {
          systemMessage(user, "You put the remaining unlit torches into your backpack.");
          Q527 = putObjContainer(this, Q47F);
        }
        else
        {
          systemMessage(user, "You put the remaining unlit torches at your feet.");
          Q527 = teleport(this, getLocation(user));
        }
      }
    }
    else
    {
      destroyOne(this);
      if(getItemAtSlot(user, 0x02) != NULL())
      {
        systemMessage(user, "You cannot hold the torch, so it has been placed at your feet.");
      }
      else
      {
        Q527 = equipObj(Q5CB, user, 0x02);
        systemMessage(user, "You put the torch in your left hand.");
      }
    }
    if(getQuantity(this) == 0x01)
    {
      destroyOne(this);
    }
    break;
  case 0x0A18:
  case 0x0A1D:
  case 0x0A25:
    if(fuel > 0x00)
    {
      setObjVar(this, "burning", 0x01);
      callback(this, 0x1E, 0x39);
      setType(this, Q62A - 0x03);
    }
    else
    {
      systemMessage(user, "The lantern is out of fuel.");
    }
    break;
  default:
    return(0x00);
    break;
  }
  sfx(getLocation(this), 0x47, 0x00);
  return(0x01);
}
Ejemplo n.º 25
0
void GanonIntro::update()
{
    /*
    ************************
    * GANON INTRO SEQUENCE *
    ************************
    -25 DOT updates
    -24 LINK in
    0 TRIFORCE overhead - code begins at this point (counter == 0)
    47 GANON in
    58 LIGHT step
    68 LIGHT step
    78 LIGHT step
    255 TRIFORCE out
    256 TRIFORCE in
    270 TRIFORCE out
    271 GANON out, LINK face up
    */
    
    if(counter==47)
    {
        music_stop();
        stop_sfx(WAV_ROAR);
        sfx(WAV_GASP);
        sfx(WAV_GANON);
        int Id=0;
        
        for(int i=0; i<eMAXGUYS; i++)
        {
            if(guysbuf[i].flags2&eneflag_ganon)
            {
                Id=i;
                break;
            }
        }
        
        if(current_item(itype_ring))
            addenemy(160,96,Id,0);
        else
            addenemy(80,32,Id,0);
    }
    
    else if(counter==48)
    {
        lighting(true,true); // Hmm. -L
        counter += 30;
    }
    
    //NES Z1, the triforce vanishes for one frame in two cases
    //while still showing Link's two-handed overhead sprite.
    else if(counter==255 || counter==270)
        link.setHeldItem(-1);
    
    else if(counter==256)
        link.setHeldItem(getItemID(itemsbuf,itype_triforcepiece,1));
    
    counter++;
    if(counter<271)
        return;
    
    link.setAction(none);
    link.dir=up;
    
    if(!getmapflag() && (tunes[MAXMIDIS-1].data))
        jukebox(MAXMIDIS-1);
    else
        playLevelMusic();
        
    currcset=DMaps[currdmap].color;
    showCurrentDMapIntro();
    cont_sfx(WAV_ROAR);
    finish();
}
Ejemplo n.º 26
0
FUNCTION void Q635(obj cow)
{
  sfx(getLocation(this), 0x79, 0x00);
  animateMobile(this, 0x08, 0x00, 0x03, 0x00, 0x00);
  return;
}
Ejemplo n.º 27
0
/// This test uses a back door to the function that passes in the element to avoid the lookup of the element when the
///  StringFunction contains references to FieldFunctions
void TEST_norm_string_function_turbo_timings(TurboOption turboOpt)
{
  EXCEPTWATCH;
  //stk::diag::WriterThrowSafe _write_throw_safe(dw());
  //dw().setPrintMask(dw_option_mask.parse(vm["dw"].as<std::string>().c_str()));
  //dw().setPrintMask(LOG_NORM+LOG_ALWAYS);

  dw().m(LOG_NORM) << "TEST.norm.string_function " << stk::diag::dendl;

  /// create a meta data/bulk data empty pair
  PerceptMesh eMesh(3u);

  if (1)
  {
    // Need a symmetric mesh around the origin for some of the tests below to work correctly (i.e. have analytic solutions)
    const size_t nxyz = 4;
    const size_t num_x = nxyz;
    const size_t num_y = nxyz;
    const size_t num_z = nxyz;
    std::string config_mesh =
      Ioss::Utils::to_string(num_x) + "x" +
      Ioss::Utils::to_string(num_y) + "x" +
      Ioss::Utils::to_string(num_z) + "|bbox:-0.5,-0.5,-0.5,0.5,0.5,0.5";
	
    eMesh.new_mesh(GMeshSpec(config_mesh));

    eMesh.commit();
  }

  mesh::fem::FEMMetaData& metaData = *eMesh.get_fem_meta_data();
  mesh::BulkData& bulkData = *eMesh.get_bulk_data();

  /// the coordinates field is always created by the PerceptMesh read operation, here we just get the field
  mesh::FieldBase *coords_field = metaData.get_field<mesh::FieldBase>("coordinates");

  /// create a field function from the existing coordinates field
  FieldFunction ff_coords("ff_coords", coords_field, &bulkData,
                          Dimensions(3), Dimensions(3), FieldFunction::SIMPLE_SEARCH );

  /// the function to be integrated:  sqrt(Integral[x^2, dxdydz]) =?= sqrt(x^3/3 @ [-0.5, 0.5]) ==> sqrt(0.25/3)
  StringFunction sfx("x", Name("sfx"), Dimensions(3), Dimensions(1) );

  ff_coords.add_alias("mc");
  //StringFunction sfcm("sqrt(mc[0]*mc[0]+mc[1]*mc[1]+mc[2]*mc[2])", Name("sfcm"), Dimensions(3), Dimensions(1));
  StringFunction sfx_mc("mc[0]", Name("sfx_mc"), Dimensions(3), Dimensions(1) );

  /// the function to be integrated:  sqrt(Integral[x^2, dxdydz]) =?= sqrt(x^3/3 @ [-0.5, 0.5]) ==> sqrt(0.25/3)

  /// A place to hold the result.
  /// This is a "writable" function (we may want to make this explicit - StringFunctions are not writable; FieldFunctions are
  /// since we interpolate values to them from other functions).
  ConstantFunction sfx_res(0.0, "sfx_res");
  ConstantFunction sfx_res_turbo(0.0, "sfx_res_turbo");
  ConstantFunction sfx_res_slow(0.0, "sfx_res_slow");
  ConstantFunction sfx_res_fast(0.0, "sfx_res_fast");

#define COL_SEP "|"
#define EXPR_CELL_WIDTH (80)

#define TIME_IT2(expr_none,expr_turbo,msg,topt)                         \
  {                                                                     \
    double TURBO_NONE_time    = 0;                                      \
    double TURBO_ON_time = 0;                                           \
    TIME_IT(expr_none,TURBO_NONE_time);                                 \
    TIME_IT(expr_turbo,TURBO_ON_time);                                  \
    if (1) std::cout << msg << #topt << "for expression= " << QUOTE(expr_none) << " timings= " << std::endl; \
    if (1) std::cout << "TURBO_NONE_time= " << TURBO_NONE_time << " "   \
                     << ( turboOpt==TURBO_ELEMENT?"TURBO_ELEMENT_time":"TURBO_BUCKET_time") <<"= " << TURBO_ON_time \
                     << " ratio= " << TURBO_NONE_time/TURBO_ON_time << std::endl; \
  }

  int numIter = 1;
  for (int iter = 0; iter < numIter; iter++)
  {
    /// Create the operator that will do the work
    /// get the l2 norm
    Norm<2> l2Norm      (bulkData, &metaData.universal_part(), TURBO_NONE);
    Norm<2> l2Norm_turbo(bulkData, &metaData.universal_part(), turboOpt);

    //double TURBO_ELEMENT_time=0;
    TIME_IT2(l2Norm(sfx, sfx_res); , l2Norm_turbo(sfx, sfx_res_turbo);, "Should be the same turboOpt= ", turboOpt );
Ejemplo n.º 28
0
void FaroresWindAction::update()
{
    if(timer>0)
    {
        timer--;
        if(phase!=1) // Whatever
            return;
    }
    
    int ltile=0;
    int lflip=0;
    
    switch(phase)
    {
    //if(timer==0)
    case 0:
        {
            linktile(&ltile, &lflip, ls_stab, down, zinit.linkanimationstyle);
            unpack_tile(newtilebuf, ltile, lflip, true);
            memcpy(linkTile, unpackbuf, 256);
            
            if(get_bit(quest_rules,qr_EXPANDEDLTM))
                ltile+=item_tile_mod();
            
            linktile(&link.tile, &link.flip, &link.extend, ls_pound, down, zinit.linkanimationstyle);
            
            if(get_bit(quest_rules,qr_EXPANDEDLTM))
            {
                link.tile+=item_tile_mod();
            }
        }
        phase=1;
        timer=64;
        // Fall though
        
    case 1:
        link.setX(fix(baseX+((rand()%3)-1)));
        link.setY(fix(baseY+((rand()%3)-1)));
        if(timer==0)
            phase=2;
        break;
        
    case 2:
        link.setX(fix(baseX));
        link.setY(fix(baseY));
        linktile(&link.tile, &link.flip, &link.extend, ls_stab, down, zinit.linkanimationstyle);
        
        if(get_bit(quest_rules,qr_EXPANDEDLTM))
            link.tile+=item_tile_mod();
        
        phase=3;
        timer=32;
        break;
    
    case 3:
        if(get_bit(quest_rules,qr_MORESOUNDS))
            sfx(itemsbuf[magicitem].usesound,pan(int(link.getX())));
            
        link.setDontDraw(true);
        
        for(int i=0; i<16; ++i)
        {
            for(int j=0; j<16; ++j)
            {
                if(linkTile[i*16+j])
                {
                    if(itemsbuf[magicitem].misc1==1)  // Twilight
                    {
                        particles.add(new pTwilight(link.getX()+j, link.getY()-link.getZ()+i, 5, 0, 0, (rand()%8)+i*4));
                        int k=particles.Count()-1;
                        particle *p = (particle*)(particles.spr(k));
                        p->step=3;
                    }
                    else if(itemsbuf[magicitem].misc1==2)  // Sands of Hours
                    {
                        particles.add(new pTwilight(link.getX()+j, link.getY()-link.getZ()+i, 5, 1, 2, (rand()%16)+i*2));
                        int k=particles.Count()-1;
                        particle *p = (particle*)(particles.spr(k));
                        p->step=4;
                        
                        if(rand()%10 < 2)
                        {
                            p->color=1;
                            p->cset=0;
                        }
                    }
                    else
                    {
                        particles.add(new pFaroresWindDust(link.getX()+j, link.getY()-link.getZ()+i, 5, 6, linkTile[i*16+j], rand()%96));
                        
                        int k=particles.Count()-1;
                        particle *p = (particle*)(particles.spr(k));
                        p->angular=true;
                        p->angle=rand();
                        p->step=(((double)j)/8);
                        p->yofs=link.getYOfs();
                    }
                }
            }
        }
        phase=4;
        timer=130;
        break;
    
    case 4:
        restart_level();
        magicitem=-1;
        link.setDontDraw(false);
        link.currentItemAction=this; // This won't do...
        phase=5;
        
        break;
    }
}
Ejemplo n.º 29
0
void GameOver::update()
{
    if(counter<254)
    {
        if(counter<=32)
            link.setHitTimer(32-counter);
        
        if(counter>=62 && counter<138)
        {
            switch((counter-62)%20)
            {
            case 0:
                link.dir=right;
                break;
                
            case 5:
                link.dir=up;
                break;
                
            case 10:
                link.dir=left;
                break;
                
            case 15:
                link.dir=down;
                break;
            }
            
            link.linkstep();
        }
        
        if(counter>=194 && counter<208)
        {
            if(counter==194)
                link.setAction(dying);
                
            link.extend = 0;
            link.cs = wpnsbuf[iwDeath].csets&15;
            link.tile = wpnsbuf[iwDeath].tile;
            
            if(BSZ)
                link.tile+=(counter-194)/3;
            else if(counter>=204)
                link.tile++;
        }
        
        if(counter==208)
            link.setDontDraw(true);
            
        if(get_bit(quest_rules,qr_FADE))
        {
            if(counter < 170)
            {
                if(counter<60)
                {
                    draw_screen(tmpscr);
                    //reuse our static subscreen
                    set_clip_rect(framebuf, 0, 0, framebuf->w, framebuf->h);
                    blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
                }
                
                if(counter==60)
                {
                    red_shift();
                    create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
                    create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
                    memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
                    
                    for(int q=0; q<PAL_SIZE; q++)
                    {
                        trans_table2.data[0][q] = q;
                        trans_table2.data[q][q] = q;
                    }
                }
                
                if(counter>=60 && counter<=169)
                {
                    draw_screen(tmpscr);
                    //reuse our static subscreen
                    blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
                    red_shift();
                    
                }
                
                if(counter>=139 && counter<=169)//fade from red to black
                {
                    fade_interpolate(RAMpal,black_palette,RAMpal, (counter-138)<<1, 224, 255);
                    create_rgb_table_range(&rgb_table, RAMpal, 208, 239, NULL);
                    create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
                    memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
                    
                    for(int q=0; q<PAL_SIZE; q++)
                    {
                        trans_table2.data[0][q] = q;
                        trans_table2.data[q][q] = q;
                    }
                    
                    refreshpal=true;
                }
            }
            else //counter>=170
            {
                if(counter==170)//make Link grayish
                {
                    fade_interpolate(RAMpal,black_palette,RAMpal,64, 224, 255);
                    
                    for(int i=CSET(6); i < CSET(7); i++)
                    {
                        int g = (RAMpal[i].r + RAMpal[i].g + RAMpal[i].b)/3;
                        RAMpal[i] = _RGB(g,g,g);
                    }
                    
                    refreshpal = true;
                }
                
                //draw only link. otherwise black layers might cover him.
                rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
                link.draw(framebuf);
                blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
            }
        }
        else //!qr_FADE
        {
            if(counter==58)
            {
                for(int i = 0; i < 96; i++)
                    tmpscr->cset[i] = 3;
                    
                for(int j=0; j<6; j++)
                    if(tmpscr->layermap[j]>0)
                        for(int i=0; i<96; i++)
                            tmpscr2[j].cset[i] = 3;
            }
            
            if(counter==59)
            {
                for(int i = 96; i < 176; i++)
                    tmpscr->cset[i] = 3;
                    
                for(int j=0; j<6; j++)
                    if(tmpscr->layermap[j]>0)
                        for(int i=96; i<176; i++)
                            tmpscr2[j].cset[i] = 3;
            }
            
            if(counter==60)
            {
                for(int i=0; i<176; i++)
                {
                    tmpscr->cset[i] = 2;
                }
                
                for(int j=0; j<6; j++)
                    if(tmpscr->layermap[j]>0)
                        for(int i=0; i<176; i++)
                            tmpscr2[j].cset[i] = 2;
                            
                for(int i=1; i<16; i+=3)
                {
                    RAMpal[CSET(2)+i]   = NESpal(0x17);
                    RAMpal[CSET(2)+i+1] = NESpal(0x16);
                    RAMpal[CSET(2)+i+2] = NESpal(0x26);
                }
                
                refreshpal=true;
            }
            
            if(counter==139)
                slide_in_color(0x06);
                
            if(counter==149)
                slide_in_color(0x07);
                
            if(counter==159)
                slide_in_color(0x0F);
                
            if(counter==169)
            {
                slide_in_color(0x0F);
                slide_in_color(0x0F);
            }
            
            if(counter==170)
            {
                for(int i=1; i<16; i+=3)
                {
                    RAMpal[CSET(6)+i]   = NESpal(0x10);
                    RAMpal[CSET(6)+i+1] = NESpal(0x30);
                    RAMpal[CSET(6)+i+2] = NESpal(0x00);
                    refreshpal = true;
                }
            }
            
            if(counter < 169)
            {
                draw_screen(tmpscr);
                //reuse our static subscreen
                blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
            }
            else
            {
                //draw only link. otherwise black layers might cover him.
                rectfill(framebuf,0,playing_field_offset,255,167+playing_field_offset,0);
                link.draw(framebuf);
                blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
            }
        }
    }
    else if(counter<350)//draw 'GAME OVER' text
    {
        clear_bitmap(framebuf);
        blit(subscrbmp,framebuf,0,0,0,0,256,passive_subscreen_height);
        textout_ex(framebuf,zfont,"GAME OVER",96,playing_field_offset+80,1,-1);
    }
    else
    {
        clear_bitmap(framebuf);
    }
    
    //SFX... put them all here
    switch(counter)
    {
    case   0:
        sfx(WAV_OUCH,pan(int(link.x)));
        break;
        
    case  60:
        sfx(WAV_SPIRAL);
        break;
        
    case 194:
        sfx(WAV_MSG);
        break;
    }
    
    //advanceframe(true);
    counter++;
    if(counter<353)
        return;
    
    finish();
    destroy_bitmap(subscrbmp);
    link.setAction(none);
    link.setDontDraw(false);
}
Ejemplo n.º 30
0
void Message::executeControlCode(char code)
{
    int arg1, arg2, arg3;
    int numArgs=getNumControlCodeArgs(code);
    
    if(numArgs>=1)
        arg1=stream.getControlCodeArgument();
    if(numArgs>=2)
        arg2=stream.getControlCodeArgument();
    if(numArgs==3)
        arg3=stream.getControlCodeArgument();
    
    switch(code)
    {
        // Message property change codes
    case MSGC_SPEED:
        textSpeed=arg1;
        break;
        
    case MSGC_COLOUR:
        renderer.setColor(CSET(arg1)+arg2);
        break;
        
        // Message switch codes
    case MSGC_GOTOIFRAND:
        if(arg1<=1 || rand()%arg1==0)
            manager.switchTo(arg2);
        break;
        
    case MSGC_GOTOIFGLOBAL: // Screen->D[], not global. Should be renamed.
        {
            arg1=vbound(arg1, 0, 7);
            int scr=(get_currdmap()<<7)+get_currscr();
            if(DMaps[get_currdmap()].type!=dmOVERW)
                scr-=DMaps[get_currdmap()].xoff;
            
            if(game->screen_d[scr][arg1]>=arg2)
                manager.switchTo(arg3);
            break;
        }
        
    case MSGC_GOTOIF: // If item. Rename this one, too.
        if(arg1>=0 && arg1<MAXITEMS && game->item[arg1])
            manager.switchTo(arg2);
        break;
        
    case MSGC_GOTOIFCTR:
        if(game->get_counter(arg1)>=arg2)
            manager.switchTo(arg3);
        break;
        
    case MSGC_GOTOIFCTRPC:
        {
            int amount=(arg2*game->get_maxcounter(arg1))/100;
            if(game->get_counter(arg1)>=amount)
                manager.switchTo(arg3);
            break;
        }
        
    case MSGC_GOTOIFTRICOUNT:
        if(TriforceCount()>=arg1)
            manager.switchTo(arg2);
        break;
        
    case MSGC_GOTOIFTRI:
        if(arg1>=0 && arg1<MAXLEVELS && (game->lvlitems[arg1]&liTRIFORCE)!=0)
            manager.switchTo(arg2);
        break;
        
        // Item and counter codes
    case MSGC_CTRUP:
        game->change_counter(arg2, arg1);
        break;
    
    case MSGC_CTRDN:
        game->change_counter(-arg2, arg1);
        break;
    
    case MSGC_CTRSET:
        game->set_counter(vbound(arg2, 0, game->get_maxcounter(arg1)), arg1);
        break;
    
    case MSGC_CTRUPPC:
        {
            int amount=(arg2*game->get_maxcounter(arg1))/100;
            game->change_counter(arg2, amount);
            break;
        }
        
    case MSGC_CTRDNPC:
        {
            int amount=(arg2*game->get_maxcounter(arg1))/100;
            game->change_counter(-arg2, amount);
            break;
        }
        
    case MSGC_CTRSETPC:
        {
            int amount=vbound((arg2*game->get_maxcounter(arg1))/100,
              0, game->get_maxcounter(arg1));
            game->set_counter(amount, arg1);
            break;
        }
        
    case MSGC_GIVEITEM:
        getitem(arg1);
        break;
        
    case MSGC_TAKEITEM:
        takeitem(arg1);
        break;
        
        // Other codes
    case MSGC_MIDI:
        if(arg1==0)
            music_stop();
        else
            jukebox(arg1+(ZC_MIDI_COUNT-1));
        break;
        
    case MSGC_SFX:
        sfx(arg1);
        break;
    }
}