Beispiel #1
1
static WORD gem_if(WORD opcode)
{
    WORD i;
    const BYTE *pctrl;

    control[0] = opcode;

    pctrl = &ctrl_cnts[(opcode - 10) * 3];
    for (i = 1; i <= CTRL_CNT; i++)
        control[i] = *pctrl++;

    gem(&gb);

    return (WORD)RET_CODE;
}
Beispiel #2
0
/* ************************************************************** */
void
mexFunction(
  int nlhs, mxArray *plhs[],
  int nrhs, const mxArray *prhs[]
) {
  char *g;            /* M char array data reformatted for C */
  int  oN, iN, gN;    /* lengths of M char array data */
  int f; int* fp;     /* flag bits */
  int idx; short *pr; /* for M mxChar type */
  mwSize dims[2];
  
  /* check inputs */
  mxAssert(nrhs == 2 || nrhs == 3, "bad call: use gem(i,g) or gem(i,g,f)");    
  mxAssert(nlhs<=1, "bad call: use o = gem(i,g)");

  /* grab user input text */
  mxAssert(mxIsChar(prhs[0]),  "bad call 1rst arg: requires char");    
  iN = mxGetM(prhs[0])*mxGetN(prhs[0]);
  mxAssert(iN<DATALIM, "bad call 1rst arg: input is too long");
  pr = (short*)mxGetData(prhs[0]);
  for (idx=0; idx<iN; idx++) input[idx] = (unsigned char)*(pr+idx)&0xFF;
  input[iN] = 0;                            /* null terminate */
  i = input;                                /* the input */
  
  /* grab user grammar */
  mxAssert(mxIsChar(prhs[1]),  "bad call 2nd arg: requires char");   
  gN = mxGetM(prhs[1])*mxGetN(prhs[1]);
  mxAssert(gN<DATALIM, "bad call 2nd arg: input is too long");
  pr = (short*)mxGetData(prhs[1]);
  for (idx=0; idx<gN; idx++) code[idx] = (unsigned char)*(pr+idx)&0xFF;
  code[gN] = 0;                             /* null terminate */
  g = code;                                 /* the code */
  
  /* grab flags */
  if (nrhs == 3) {
    mxAssert(mxIsUint32(prhs[2]), "bad call 3rd arg: requires int32");   
    fp = (int*)mxGetData(prhs[2]);         /* flag bits */
    f = *fp;
  } else {
    f = 0;                                  /* no flags */
  }
  
  pregem(i, iN, g, gN, f);                  /* set up globals */
  gem();                                    /* translate */
  
  /* push output */
  oN = o-output+1;                          /* number of output chars */
  o = output;
  dims[0] = 1; dims[1] = oN;
  plhs[0] = mxCreateCharArray(2, (const mwSize*)&dims); 
  pr = (short*)mxGetData(plhs[0]);          /* 16 bits per char */
  for (idx=0; idx<oN; idx++) *(pr+idx) = (*o++)&0xFF;
}
Beispiel #3
0
bool GameSurface::FillRow()
{
	const auto findAboveGem = [&](decltype(m_gems.size()) gemIndex)
	{
		for (int i = gemIndex - COLUMNS; i >= 0; i -= COLUMNS)
		{
			if (m_gems[i].GetColor() != GemColor::EMPTY)
			{
				return static_cast<decltype(k_noGem)>(i);
			}
		}
		return k_noGem;
	};
	bool nextRow = true;
	for (auto row = 0; row < ROWS && nextRow; ++row)
	{
		for (auto column = 0; column < COLUMNS; ++column)
		{
			const auto currentRow = ROWS - row - 1;
			auto index = column + currentRow * COLUMNS;
			if (m_gems[index].IsEmpty())
			{
				auto otherIndex = findAboveGem(index);
				auto position = CalculateGemPosition(index);
				position.X = 0;
				if (otherIndex != k_noGem)
				{
					position.Y = -(position.Y - CalculateGemPosition(otherIndex).Y);
					std::swap(m_gems[index], m_gems[otherIndex]);
					m_gems[index].SetOffset(position);
				}
				else
				{
					position.Y = -OFFSET_Y - position.Y;
					GemSurface gem(*this, position);
					m_gems[index] = gem;
					m_gems[index].SetOffset(position);
				}
				m_animation = Animation::FALL_ANIMATION;
				nextRow = false;
			}
		}
	}
	return nextRow;
}
Beispiel #4
0
int
more_web(char *fpath, int promptend)
{
  char *ch;
  char genbuf[41];

  if (ch = strstr(fpath, "mailto:"))
  {
    if (!HAS_PERM(PERM_LOGINOK))
    {
      outmsg(" ±zªºÅv­­¤£¨¬µLªk¨Ï¥Îinternet mail... ");
      return 0;
    }
    if (!not_addr(&ch[7]) &&
	getdata(b_lines - 1, 0, "[±H«H]¥DÃD¡G", genbuf, 40, DOECHO, 0))
    {
      do_send(&ch[7], genbuf);
    }
    else
    {
      outmsg(" ¦¬«H¤Hemail ©Î ¼ÐÃD ¦³»~... ");
    }
    return 0;
  }
#if 0
  if (ch = strstr(fpath, "gopher://"))
  {
    ITEM item;
    strcpy(item.X.G.server, &ch[9]);
    strcpy(item.X.G.path, "1/");
    item.X.G.port = 70;
    gem(fpath, &item, 0);
    return 0;
  }
#endif
  /* wildcat : ¤ä´©ª½±µ¶i¤J¬ÝªO */
  if (ch = strstr(fpath, "board://"))
  {
    char bname[20], bpath[60], oldch[STRLEN];
    struct stat st;
    int mode0 = currutmp->mode;
    int stat0 = currstat;
    int pos;
    boardheader *bhdr, *getbcache();

    strcpy(oldch, ch);
    strcpy(bname, strtok(oldch + 8, "#"));
    setbpath(bpath, bname);
    if ((*bname == '\0') || (stat(bpath, &st) == -1))
    {
      pressanykey(err_bid);
      return RC_FULL;
    }

    if (bhdr = getbcache(bname))
    {
      if (Ben_Perm(bhdr) != 1)
      {
	pressanykey("§A¨S¦³¶i¤J¸ÓªOªºÅv­­");
	return 0;
      }
    }
    else
    {
      pressanykey("§A¨S¦³¶i¤J¸ÓªOªºÅv­­");
      return 0;
    }
    /* shakalaca.000123: ¤ä´©¬Ý¬Y¤@½g */
    if (ch = strstr(fpath, "#"))
    {
      fileheader fhdr;

      pos = atoi(ch + 1);
      setbdir(bpath, bname);
      rec_get(bpath, &fhdr, sizeof(fileheader), pos);
      setbfile(bpath, bname, fhdr.filename);
      more(bpath, 0);
    }
    else
    {
      /* shakalaca.000124: ¸Ñ¨M "¥¼Åª" °ÝÃD.. */
      brc_initial(bname);
      Read();
    }

    currutmp->mode = mode0;
    currstat = stat0;
    return 0;
  }
}