コード例 #1
0
ファイル: main.c プロジェクト: ez80/1010CE
void checkBuf() {
	if (!buffer1Active && !buffer2Active && !buffer3Active) {
		clearTile(&buffer1);
		clearTile(&buffer2);
		clearTile(&buffer3);
		setRandomTile(&buffer1);
		setRandomTile(&buffer2);
		setRandomTile(&buffer3);
		buffer1Active = true;
		buffer2Active = true;
		buffer3Active = true;
	}
		if (currentBufferInUse == 1 && !buffer1Active) {
			currentBufferInUse++; 
			checkBuf();
		}
		if (currentBufferInUse == 2 && !buffer2Active) {
			currentBufferInUse++;
			checkBuf();
		}
		if (currentBufferInUse == 3 && !buffer3Active) {
			currentBufferInUse=1;
			checkBuf();
		}
		fixBounds();
}
コード例 #2
0
void pixelDownloader::processSync(int frame, int cmd)
{
   if (!syncOn)
      return;



   syncFrame = frame;
   //if (shared->nodeID == 0)
   //std::cout << "receive sync " << syncFrame << std::endl;

   //sungwon
   //fprintf(stderr, "pixelDownloader::processSync(syncFrame %d, cmd %d), instID %d, streamNum %d, tileNum %d, updatedFrame %d\n",frame, cmd,instID, streamNum, tileNum, updatedFrame);


   // when the sync slave keeps the pace
   if (updatedFrame == syncFrame) {
      swapMontages(); // swap textures (one for display, one for pixel downloading)
   }

   // when the sync slave runs behind and the screen needs to be cleared (only for SOFT_SYNC mode)
   else {
      bool screenUpdate = false;
      for (int i=0; i<tileNum; i++) {
         montagePair &monPair = montageList[i];
         if (monPair.getClearFlag()) {
            clearTile(i);
            screenUpdate = true;
         }
      }
      if (screenUpdate)
         shared->displayObj->setDirty();

      if (cmd == SKIP_FRAME) {
         updatedFrame = syncFrame;


      }
   }


   /**
    * SAGE display has two textures for each image fragment.
One for display. The other to be written new pixels on.
Two textures are swapped once a sync signal arrived
and a new image shows up when the screen is refreshed.
This only happens when the frame number of the image
loaded on the new texture to be shown matches the sync
frame number.
It should match always for HARD-SYNC mode.
But it may not for SOFT-SYNC mode
for which sync frame can proceed even though some slaves
are not ready for going to the next frame.
But I can't guarantee the stability of the SOFT-SYNC mode
of the current implementation (especially for parallel apps).
CONSTANT-SYNC mode was not complete either.

HARD-SYNC and NO-SYNC mode are mostly tested so far.
    */
}
コード例 #3
0
int pixelDownloader::swapMontages()
{
   bool activeMontage = false;

   for (int i=0; i<tileNum; i++) {
      montagePair &monPair = montageList[i];

      if (monPair.isActive()) {
         if (monPair.getClearFlag()) {
            clearTile(i);
         }
         else {
            monPair.swapMontage();
            shared->displayObj->replaceMontage(monPair.getFrontMon());
         }
         activeMontage = true;
      }
   }

   if (activeMontage) {
      shared->displayObj->setDirty();
   }

   return 0;
}
コード例 #4
0
int pixelDownloader::clearScreen()
{
   for (int i=0; i<tileNum; i++) {
      clearTile(i);
   }

   return 0;
}
コード例 #5
0
ファイル: CMap.cpp プロジェクト: RKJokela/rjSokoban
void clearFromDown(std::vector<TileType> &vec, bool* checked, int x, int y) {
    if (x < 0 || x >= MAP_W || y < 0 || y >= MAP_H)
        return;
    clearTile(vec, x, y);
    int i = x + y*MAP_W;
    checked[i] = true;

    // down
    if (!checked[i+MAP_W] && vec[i+MAP_W] != TILE_TYPE_WALL)
        clearFromDown(vec, checked, x, y+1);
    // left
    if (!checked[i-1] && vec[i-1] != TILE_TYPE_WALL)
        clearFromDown(vec, checked, x-1, y);
    // right
    if (!checked[i+1] && vec[i+1] != TILE_TYPE_WALL)
        clearFromDown(vec, checked, x+1, y);
}
コード例 #6
0
VectorTile& VectorTile::operator= (const VectorTile& ref)
{

    if(this == &ref) return *this; /* effective c++ item 11 */

    clearTile();

    poTileID_ = new TileID(*ref.poTileID_);
    poLayer_ = ref.poLayer_;

    int nMax = ref.papoFeatures_.size();
    for(int i=0; i<nMax; ++i)
    {
        papoFeatures_.push_back( ref.papoFeatures_[i]->Clone() );
        poFeatureCompatibleFlags_.push_back(1);
    }
    
    nIterator_ = 0;
    bOriginal_ = ref.isOriginalTile();

    return *this;
}
コード例 #7
0
ファイル: main.c プロジェクト: ez80/1010CE
void startGame()
{
	gc_InitGraph();
	gc_DrawBuffer();
	gc_SetTextColor(0xFF00);
	gc_FillScrn(0xFF);
	gc_SwapDraw();
	srand(*(unsigned long*)0xF30044);
	clearTile(&buffer1);
	clearTile(&buffer2);
	clearTile(&buffer3);
	setRandomTile(&buffer1);
	setRandomTile(&buffer2);
	setRandomTile(&buffer3);
	buffer1Active = true;
	buffer2Active = true;
	buffer3Active = true;
	currentBufferInUse = 1;
	exitSection = false;
	movesRemaining = true;
	boardx = 3;
	boardy = 18;
	selectx = 0;
	selecty = 0;
	score = 0;
	drawBoardStart();
	canDrawTileBool = true;
	while (exitSection == false) {
		checkBuf();
		drawBoardRF();
		gc_SetTextXY(275, 5);
		gc_PrintInt(score, 5);
		if (currentBufferInUse == 1) {
			drawTileHover(buffer1, selectx, selecty);
		}
		if (currentBufferInUse == 2) {
			drawTileHover(buffer2, selectx, selecty);
		}
		if (currentBufferInUse == 3) {
			drawTileHover(buffer3, selectx, selecty);
		}
		/*if (canDrawTileBool == true) {
			gc_SetColorIndex(0x47);
			gc_NoClipRectangleOutline(selectx * 21 + boardx, selecty * 21 + boardy, 21, 21);
		}
		else {
			gc_SetColorIndex(0xE0);
			gc_NoClipRectangleOutline(selectx * 21 + boardx, selecty * 21 + boardy, 21, 21);
		}*/
		drawBuffers();
		gc_SwapDraw();
		if (!darkMode) {
			gc_SetColor(0xFF, gc_RGBTo1555(255, 255, 255));
		}
		else {
			gc_SetColor(0xFF, gc_RGBTo1555(26, 26, 26));
		}
		gc_FillScrn(0xFF);
		key = kb_ScanGroup(kb_group_7);
		if (key & kb_Down) {
			if (currentBufferInUse == 1) {
				inBounds(buffer1, selectx, selecty+1);
			}
			if (currentBufferInUse == 2) {
				inBounds(buffer2, selectx, selecty+1);
			}
			if (currentBufferInUse == 3) {
				inBounds(buffer3, selectx, selecty+1);
			}
			if (selecty < 9 && canDrawTileBool) {
				selecty++;
				if (currentBufferInUse == 1) {
					canDrawTile(buffer1, selectx, selecty);
				}
				if (currentBufferInUse == 2) {
					canDrawTile(buffer2, selectx, selecty);
				}
				if (currentBufferInUse == 3) {
					canDrawTile(buffer3, selectx, selecty);
				}
			}
		}
		if (key & kb_Up) {
			if (currentBufferInUse == 1) {
				inBounds(buffer1, selectx, selecty-1);
			}
			if (currentBufferInUse == 2) {
				inBounds(buffer2, selectx, selecty-1);
			}
			if (currentBufferInUse == 3) {
				inBounds(buffer3, selectx, selecty-1);
			}
			if (selecty > 0 && canDrawTileBool) {
				selecty--;
				if (currentBufferInUse == 1) {
					canDrawTile(buffer1, selectx, selecty);
				}
				if (currentBufferInUse == 2) {
					canDrawTile(buffer2, selectx, selecty);
				}
				if (currentBufferInUse == 3) {
					canDrawTile(buffer3, selectx, selecty);
				}
			}
		}
		if (key & kb_Left) {
			if (currentBufferInUse == 1) {
				inBounds(buffer1, selectx-1, selecty);
			}
			if (currentBufferInUse == 2) {
				inBounds(buffer2, selectx-1, selecty);
			}
			if (currentBufferInUse == 3) {
				inBounds(buffer3, selectx-1, selecty);
			}
			if (selectx > 0 && canDrawTileBool) {
				selectx--;
				if (currentBufferInUse == 1) {
					canDrawTile(buffer1, selectx, selecty);
				}
				if (currentBufferInUse == 2) {
					canDrawTile(buffer2, selectx, selecty);
				}
				if (currentBufferInUse == 3) {
					canDrawTile(buffer3, selectx, selecty);
				}
			}
		}
		if (key & kb_Right) {
			if (currentBufferInUse == 1) {
				inBounds(buffer1, selectx+1, selecty);
			}
			if (currentBufferInUse == 2) {
				inBounds(buffer2, selectx+1, selecty);
			}
			if (currentBufferInUse == 3) {
				inBounds(buffer3, selectx+1, selecty);
			}
			if (selectx < 9 && canDrawTileBool) {
				selectx++;
				if (currentBufferInUse == 1) {
					canDrawTile(buffer1, selectx, selecty);
				}
				if (currentBufferInUse == 2) {
					canDrawTile(buffer2, selectx, selecty);
				}
				if (currentBufferInUse == 3) {
					canDrawTile(buffer3, selectx, selecty);
				}
			}
		}
		if (selectx > 9 || selectx < 0)
		{
			selectx = 0;
		}
		if (selecty > 9 || selecty < 0)
		{
			selecty = 0;
		}
		key = kb_ScanGroup(kb_group_6);
		if (key & kb_Clear) {
			exitSection = true;
		}
		key = kb_ScanGroup(kb_group_1);
		if (key & kb_2nd) {
			if (currentBufferInUse == 1) {
				canDrawTile(buffer1, selectx, selecty);
			}
			if (currentBufferInUse == 2) {
				canDrawTile(buffer2, selectx, selecty);
			}
			if (currentBufferInUse == 3) {
				canDrawTile(buffer3, selectx, selecty);
			}
			if (canDrawTileBool) {
				if (currentBufferInUse == 1) {
					drawTile(buffer1, selectx, selecty);
				}
				if (currentBufferInUse == 2) {
					drawTile(buffer2, selectx, selecty);
				}
				if (currentBufferInUse == 3) {
					drawTile(buffer3, selectx, selecty);
				}

				if (currentBufferInUse == 1) {
					buffer1Active = false;
					clearTile(&buffer1);
				}
				if (currentBufferInUse == 2) {
					buffer2Active = false;
					clearTile(&buffer2);
				}
				if (currentBufferInUse == 3) {
					buffer3Active = false;
					clearTile(&buffer3);
				}
				currentBufferInUse++;
				if (currentBufferInUse == 4) {
					currentBufferInUse = 1;
				}
				checkBuf();
				checkForTileRows();
				if (currentBufferInUse == 1) {
					canDrawTile(buffer1, selectx, selecty);
				}
				if (currentBufferInUse == 2) {
					canDrawTile(buffer2, selectx, selecty);
				}
				if (currentBufferInUse == 3) {
					canDrawTile(buffer3, selectx, selecty);
				}
				anyMovesLeft();
				if (!movesRemaining) {
					exitSection = true;
				}
			}
		}
		if (key & kb_Mode) {
			darkMode = !darkMode;
			while (kb_AnyKey()) {

			}
		}
		key = kb_ScanGroup(kb_group_2);
		if (key & kb_Alpha) {
			currentBufferInUse++;
			if (currentBufferInUse == 4) {
				currentBufferInUse = 1;
			}
			checkBuf();
			dbg_printf(dbgout, "cbiu %d", currentBufferInUse);
			while (kb_AnyKey()) {

			}
		}
	}
		saveNewHS(score);
		dead();
}
コード例 #8
0
ファイル: Rack.cpp プロジェクト: AustinAnderson/ASCII_WORDS
 void Rack::clearCurrentTile(){
     clearTile(ndx);
 }
コード例 #9
0
bool pixelDownloader::reconfigDisplay(int confID)
{
   if (dispConfigID >= confID) {
		sage::printLog("[%d,%d] PDL::reconfigDisplay(%d) : configuration ID error", shared->nodeID, instID, confID);
      return false;
   }

   char *configStr = NULL;
   while (dispConfigID < confID) {
      if (configQueue.size() == 0)
         return false;

      configStr = configQueue.front();
      dispConfigID++;
      configQueue.pop_front();
   }

   int oldRcvs = activeRcvs;
   displayActive = false;

   sageRotation orientation;
   sscanf(configStr, "%d %d %d %d %d %d", &windowLayout.x, &windowLayout.y,
      &windowLayout.width, &windowLayout.height, &activeRcvs, (int *)&orientation);
   windowLayout.setOrientation(orientation);

   // when the window locates on a neighbor tiled display
   if (windowLayout.width == 0 || windowLayout.height == 0) {
      if (syncOn) {
         for (int i=0; i<tileNum; i++)
            montageList[i].clear();
      }
      else {
         clearScreen();
         shared->displayObj->setDirty();
      }
      return true;
   }

   partition->setDisplayLayout(windowLayout);
   partition->clearBlockTable();

   for (int i=0; i<tileNum; i++) {
      montagePair &monPair = montageList[i];
      sageMontage *mon = NULL;

      sageRect tileRect = shared->displayObj->getTileRect(i);
      if (!tileRect.crop(windowLayout)) {
         if (syncOn)
            monPair.clear();
         else {
            clearTile(i);
            shared->displayObj->setDirty();
         }
         continue;
      }

      displayActive = true;

      partition->setTileLayout(tileRect);
      sageRect viewPort = partition->getViewPort();
      sageRect blockLayout = partition->getBlockLayout();

      viewPort.moveOrigin(blockLayout);

      if (monPair.isActive()) {
         //if (shared->nodeID == 5)
         //   std::cerr << "montage active" << std::endl;
         mon = monPair.getBackMon();
         *(sageRect *)mon = tileRect;
         mon->init(viewPort, blockLayout, orientation);
         monPair.renew();
      }
      else {
         //if (shared->nodeID == 5)
         //   std::cerr << "montage inactive" << std::endl;
         mon = monPair.getFrontMon();
         //*(sageRect *)mon = tileRect;
         //mon->init(viewPort, blockLayout, orientation);
         int monIdx = shared->displayObj->addMontage(mon);

         mon = monPair.getBackMon();
         *(sageRect *)mon = tileRect;
         mon->init(viewPort, blockLayout, orientation);
         mon->monIdx = monIdx;
         monPair.renew();

         monPair.activate();
      }

      partition->genBlockTable(i);
   }

   frameSize = blockSize * partition->tableEntryNum();

   if (oldRcvs != activeRcvs)
      updateType = SAGE_UPDATE_SETUP;

   return true;
}
コード例 #10
0
VectorTile::~VectorTile()
{
    clearTile();
}