Пример #1
0
/**
  Calculates the x and y coordinates so that the given image
  would be displayed in screen center at the current resolution.
  Image width and height are given explicitly to allow for arbitrary
  calculations useful for sprites.

  @param[in] ImageWidth   Image width.
  @param[in] ImageHeight  Image height.
  @param[out] PositionX   Screen X coordinate of the top left corner
                          of the centered image.
  @param[out] PositionX   Screen Y coordinate of the top left corner
                          of the centered image.

  @retval EFI_SUCCESS     Screen center values were successfully
                          calculated for the current resolution
						  and specified image.
  @retval other           Either no graphics adapter was found,
                          the image was too big to fit on the
						  screen at current resolution or some
						  other problem was encountered.
  
**/
EFI_STATUS
CalculatePositionForCenter(
	IN	UINTN	ImageWidth,
	IN	UINTN	ImageHeight,
	OUT	UINTN	*PositionX,
	OUT	UINTN	*PositionY)
{
	if (EFI_ERROR(EnsureDisplayAvailable())) {
		PrintDebug(L"No display adapters found, unable to calculate centered position\n");
		return EFI_DEVICE_ERROR;
	}

	if (ImageWidth == 0 || ImageHeight == 0 
		|| ImageWidth > DisplayInfo.HorizontalResolution
		|| ImageHeight > DisplayInfo.VerticalResolution) {
		PrintDebug(L"Wrong image size (%ux%u) for this screen resolution (%ux%u)\n", 
			ImageWidth, ImageHeight, DisplayInfo.HorizontalResolution, DisplayInfo.VerticalResolution);
		return EFI_INVALID_PARAMETER;
	}

	*PositionX = (DisplayInfo.HorizontalResolution / 2) - (ImageWidth / 2);
	*PositionY = (DisplayInfo.VerticalResolution / 2) - (ImageHeight / 2);

	if (*PositionX + ImageWidth > DisplayInfo.HorizontalResolution)
		*PositionX = DisplayInfo.HorizontalResolution - ImageWidth;
	if (*PositionY + ImageHeight > DisplayInfo.VerticalResolution)
		*PositionY = DisplayInfo.VerticalResolution - ImageHeight;

	//PrintDebug(L"Top left corner position for centered image: %u,%u\n", *PositionX, *PositionY);

	return EFI_SUCCESS;
}
Пример #2
0
static int makeReservation(MultiTrainDriver* me, int stoppingDistance) {
  if (me->tailMode) {
    PrintDebug(me->ui, "Cannot make reservation in tail mode");
    return RESERVE_SUCESS;
  } else if (!me->reserveTrackMode) {
    PrintDebug(me->ui, "No reservation mode");
    return RESERVE_SUCESS;
  }
  int isStationary = me->stoppedCount == me->numTrainInGroup;
  TrackLandmark sensors[MAX_TRAIN_IN_GROUP * 10];
  int sensorIndex = 0;
  // bad merging code here
  for (int i = 0; i < me->numTrainInGroup; i++) {
    int numSensor = isStationary ? 1 : me->numSensorToReserve[i];
    for (int j = 0; j < numSensor; j++) {
      int isInQueue = 0;
      for (int k = 0; k < sensorIndex; k++) {
        if (sensors[k].type == me->sensorToReserve[i][j].type &&
            sensors[k].num1 == me->sensorToReserve[i][j].num1 &&
            sensors[k].num2 == me->sensorToReserve[i][j].num2) {
          isInQueue = 1;
          break;
        }
      }
      if (!isInQueue) {
        sensors[sensorIndex++] = me->sensorToReserve[i][j];
      }
    }
  }

  ReleaseOldAndReserveNewTrackMsg qMsg;
  qMsg.type = RELEASE_OLD_N_RESERVE_NEW;
  qMsg.trainNum = me->trainNum;
  qMsg.stoppingDistance = isStationary ? 1 : stoppingDistance;
  qMsg.lastSensor = sensors[0];

  //TrainDebug(me, "Reserving track");
  qMsg.numPredSensor = sensorIndex - 1;
  for (int i = 1; i < sensorIndex; i++) {
    qMsg.predSensor[i-1] = sensors[i];
    //printLandmark(me, &qMsg.predSensor[i-1]);
  }

  int previousLandmarkState = me->reserveFailedLandmark.type;
  // reserveFailedlandmark is not really being used right now
  int len = Send(
      me->trackManager,
      (char*)&qMsg, sizeof(ReleaseOldAndReserveNewTrackMsg),
      (char*)&(me->reserveFailedLandmark), sizeof(TrackLandmark));
  if (len > 0) {
    printLandmark(me, &me->reserveFailedLandmark);
    return RESERVE_FAIL;
  } else if (!isStationary &&
      previousLandmarkState != LANDMARK_BAD &&
      me->reserveFailedLandmark.type != LANDMARK_BAD){
    //TrainDebug(me, "Got landmark bad.");
    me->reserveFailedLandmark.type = LANDMARK_BAD;
  }
  return RESERVE_SUCESS;
}
Пример #3
0
/**
  Prints important information about the currently running video
  mode. Initializes adapters if they have not yet been detected.

**/
VOID
PrintVideoInfo()
{
	UINT32									MaxMode;
	UINT32									i;
	EFI_GRAPHICS_OUTPUT_MODE_INFORMATION	*ModeInfo;
	UINTN									SizeOfInfo;
	EFI_STATUS								Status;

	if (EFI_ERROR(EnsureDisplayAvailable())) {
		PrintDebug(L"No display adapters found, unable to print display information\n");
		return;
	}

	PrintDebug(L"Current mode:\n");
	PrintDebug(L"  HorizontalResolution = %u\n", DisplayInfo.HorizontalResolution);
	PrintDebug(L"  VerticalResolution = %u\n", DisplayInfo.VerticalResolution);
	PrintDebug(L"  PixelFormat = %u\n", DisplayInfo.PixelFormat);
	PrintDebug(L"  PixelsPerScanLine = %u\n", DisplayInfo.PixelsPerScanLine);
	PrintDebug(L"  FrameBufferBase = %x\n", DisplayInfo.FrameBufferBase);
	PrintDebug(L"  FrameBufferSize = %u\n", DisplayInfo.FrameBufferSize);

	// Query available modes.
	MaxMode = DisplayInfo.GOP->Mode->MaxMode;
	PrintDebug(L"Available modes (MaxMode = %u):\n", MaxMode);
	for (i = 0; i < MaxMode; i++) {
			
		Status = DisplayInfo.GOP->QueryMode(DisplayInfo.GOP, i, &SizeOfInfo, &ModeInfo);
		if (!EFI_ERROR(Status)) {
			PrintDebug(L"  Mode%u: %ux%u\n", i, ModeInfo->HorizontalResolution, ModeInfo->VerticalResolution);
		}
	}
}
Пример #4
0
void PrintErrorDebug(char *msg)
{
	LPVOID lpMsgBuf;
	char *buf;

	/* Get last error message */
	if (!FormatMessage( 
				FORMAT_MESSAGE_ALLOCATE_BUFFER | 
				FORMAT_MESSAGE_FROM_SYSTEM | 
				FORMAT_MESSAGE_IGNORE_INSERTS,
				NULL,
				GetLastError(),
				MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
				(LPTSTR) &lpMsgBuf,
				0,
				NULL ))
	{
		/* FormatMessage failed! */
		PrintDebug("FormatMessage() failed. %s ", msg);
		return;
	}

	/* Cut of CR/LFs */
	buf = (char *)lpMsgBuf;
	buf[strlen(buf) - 3] = '\0';

	PrintDebug("%s %s", msg, (LPCTSTR)lpMsgBuf);

}
Пример #5
0
int v3_handle_svm_halt(struct guest_info * info)
{
  if (info->cpl!=0) { 
    v3_raise_exception(info, GPF_EXCEPTION);
  } else {
    
    // What we should do is starting waiting on an OS event that will
    // result in an injection of an interrupt.
    
    // What we will hackishly do instead is resume on any event
    // Plus is this totally GeekOS specific
    
    ullong_t yield_start = 0;
    ullong_t yield_stop = 0;
    uint32_t gap = 0;
    
    PrintDebug("GeekOS Yield\n");
    
    rdtscll(yield_start);
    V3_Yield();
    rdtscll(yield_stop);
    
    
    //v3_update_time(info, yield_stop - yield_start);
    gap = yield_stop - yield_start;
    v3_raise_irq(info, 0);
    
    PrintDebug("GeekOS Yield Done (%d cycles)\n", gap);
    
    info->rip+=1;
  }
    
  return 0;

}
Пример #6
0
/* force-kill as a last resort */
static BOOL
TerminateOpenVPN (connection_t *c)
{
    DWORD exit_code = 0;
    BOOL retval = TRUE;

    if (!c->hProcess)
        return retval;
    if (!GetExitCodeProcess (c->hProcess, &exit_code))
    {
        PrintDebug (L"In TerminateOpenVPN: failed to get process status: error = %lu", GetLastError());
        return FALSE;
    }
    if (exit_code == STILL_ACTIVE)
    {
        retval = TerminateProcess (c->hProcess, 1);
        if (retval)
            PrintDebug (L"Openvpn Process for config '%s' terminated", c->config_name);
        else
            PrintDebug (L"Failed to terminate openvpn Process for config '%s'", c->config_name);
    }
    else
        PrintDebug(L"In TerminateOpenVPN: Process is not active");

    return retval;
}
Пример #7
0
static int read_data_port(ushort_t port, void * dst, uint_t length, struct vm_device * dev) {
  struct serial_state * state = (struct serial_state *)dev->private_data;
  char * val = (char *)dst;
  PrintDebug("Read from Data Port 0x%x\n", port);

  if (length != 1) {
    PrintDebug("Invalid length(%d) in write to 0x%x\n", length, port);
    return -1;
  }

  switch (port) {
  case COM1_DATA_PORT:
    dequeue_data(&(state->com1.tx_buffer), val);
    break;
  case COM2_DATA_PORT:
    dequeue_data(&(state->com2.tx_buffer), val);
    break;
  case COM3_DATA_PORT:
    dequeue_data(&(state->com3.tx_buffer), val);
    break;
  case COM4_DATA_PORT:
    dequeue_data(&(state->com4.tx_buffer), val);
    break;
  default:
    return -1;
  }
  

  return length;
}
Пример #8
0
static int write_ctrl_port(ushort_t port, void * src, uint_t length, struct vm_device * dev) {
  struct serial_state * state = (struct serial_state *)dev->private_data;
  char * val = (char *)src;
  PrintDebug("Write to Control Port (val=%x)\n", *(char *)src);

  if (length != 1) {
    PrintDebug("Invalid Write length to control port %d\n", port);
    return -1;
  }

  switch (port) {
  case COM1_IRQ_ENABLE_PORT:
    if (handle_ier_write(&(state->com1), (struct irq_enable_reg *)val) == -1) {
      return -1;
    }
    break;
  case COM2_IRQ_ENABLE_PORT:
    if (handle_ier_write(&(state->com2), (struct irq_enable_reg *)val) == -1) {
      return -1;
    }
    break;
  case COM3_IRQ_ENABLE_PORT:
    if (handle_ier_write(&(state->com3), (struct irq_enable_reg *)val) == -1) {
      return -1;
    }
    break;
  case COM4_IRQ_ENABLE_PORT:
    if (handle_ier_write(&(state->com4), (struct irq_enable_reg *)val) == -1) {
      return -1;
    }
    break;

  case COM1_FIFO_CTRL_PORT:
  case COM2_FIFO_CTRL_PORT:
  case COM3_FIFO_CTRL_PORT:
  case COM4_FIFO_CTRL_PORT:

  case COM1_LINE_CTRL_PORT:
  case COM2_LINE_CTRL_PORT:
  case COM3_LINE_CTRL_PORT:
  case COM4_LINE_CTRL_PORT:

  case COM1_MODEM_CTRL_PORT:
  case COM2_MODEM_CTRL_PORT:
  case COM3_MODEM_CTRL_PORT:
  case COM4_MODEM_CTRL_PORT:
    


  default:
    return -1;
  }


  return -1;
}
Пример #9
0
//
// EvalPartition
//
// -AJA- Evaluate a partition seg & determine the cost, taking into
//       account the number of splits, difference between left &
//       right, and linedefs that are tagged 'precious'.
//
// Returns the computed cost, or a negative value if the seg should be
// skipped altogether.
//
static int EvalPartition(superblock_t *seg_list, seg_t *part, 
    int best_cost)
{
  eval_info_t info;

  /* initialise info structure */
  info.cost   = 0;
  info.splits = 0;
  info.iffy   = 0;
  info.near_miss  = 0;

  info.real_left  = 0;
  info.real_right = 0;
  info.mini_left  = 0;
  info.mini_right = 0;
  
  if (EvalPartitionWorker(seg_list, part, best_cost, &info))
    return -1;
  
  /* make sure there is at least one real seg on each side */
  if (info.real_left == 0 || info.real_right == 0)
  {
#   if DEBUG_PICKNODE
    PrintDebug("Eval : No real segs on %s%sside\n", 
        info.real_left  ? "" : "left ", 
        info.real_right ? "" : "right ");
#   endif

    return -1;
  }

  /* increase cost by the difference between left & right */
  info.cost += 100 * ABS(info.real_left - info.real_right);

  // -AJA- allow miniseg counts to affect the outcome, but only to a
  //       lesser degree than real segs.
  
  info.cost += 50 * ABS(info.mini_left - info.mini_right);

  // -AJA- Another little twist, here we show a slight preference for
  //       partition lines that lie either purely horizontally or
  //       purely vertically.
  
  if (part->pdx != 0 && part->pdy != 0)
    info.cost += 25;

# if DEBUG_PICKNODE
  PrintDebug("Eval %p: splits=%d iffy=%d near=%d left=%d+%d right=%d+%d "
      "cost=%d.%02d\n", part, info.splits, info.iffy, info.near_miss, 
      info.real_left, info.mini_left, info.real_right, info.mini_right, 
      info.cost / 100, info.cost % 100);
# endif
 
  return info.cost;
}
Пример #10
0
intr_type_t v3_get_intr_type(struct guest_info * info) {
  struct v3_intr_state * intr_state = &(info->intr_state);

  if (intr_state->excp_pending) {
    PrintDebug("[get_intr_type] Exception\n");
    return EXCEPTION;
  } else if (intr_state->controller->intr_pending(intr_state->controller_state)) {
    PrintDebug("[get_intr_type] External_irq\n");
    return EXTERNAL_IRQ;
  }
    PrintDebug("[get_intr_type] Invalid_Intr\n");
  return INVALID_INTR;
}
Пример #11
0
//
// InitEndian
//
// Parts inspired by the Yadex endian.cc code.
//
void InitEndian(void)
{
  volatile union
  {
    uint8_g mem[32];
    uint32_g val;
  }
  u;
 
  /* sanity-check type sizes */

  if (sizeof(uint8_g) != 1)
    FatalError("Sanity check failed: sizeof(uint8_g) = %d", 
        (int)sizeof(uint8_g));

  if (sizeof(uint16_g) != 2)
    FatalError("Sanity check failed: sizeof(uint16_g) = %d", 
        (int)sizeof(uint16_g));

  if (sizeof(uint32_g) != 4)
    FatalError("Sanity check failed: sizeof(uint32_g) = %d", 
        (int)sizeof(uint32_g));

  /* check endianness */

  memset((uint32_g *) u.mem, 0, sizeof(u.mem));

  u.mem[0] = 0x70;  u.mem[1] = 0x71;
  u.mem[2] = 0x72;  u.mem[3] = 0x73;

# if DEBUG_ENDIAN
  PrintDebug("Endianness magic value: 0x%08x\n", u.val);
# endif

  if (u.val == 0x70717273)
    cpu_big_endian = 1;
  else if (u.val == 0x73727170)
    cpu_big_endian = 0;
  else
    FatalError("Sanity check failed: weird endianness (0x%08x)", u.val);

# if DEBUG_ENDIAN
  PrintDebug("Endianness = %s\n", cpu_big_endian ? "BIG" : "LITTLE");

  PrintDebug("Endianness check: 0x1234 --> 0x%04x\n", 
      (int) Endian_U16(0x1234));
  
  PrintDebug("Endianness check: 0x11223344 --> 0x%08x\n", 
      Endian_U32(0x11223344));
# endif
}
Пример #12
0
// ==============================================================================
// Enables and disables debug mode
// ==============================================================================
void SetDebug(bool value) {
    if(value == true) {
        Globals.DebugMode = true;
    }
    if(value == true) {
        PrintDebug("SYSTEM: Debug mode: Enabled.");
    }
    else {
        PrintDebug("SYSTEM: Debug mode: Disabled.");
    }
    if(value == false) {
        Globals.DebugMode = false;
    }
}
Пример #13
0
//
// WriteLumpData
//
static void WriteLumpData(lump_t *lump)
{
  size_t len;
  int align_size;

  cur_comms->file_pos++;
  DisplaySetBar(1, cur_comms->file_pos);
  DisplayTicker();

# if DEBUG_LUMP
  if (lump->flags & LUMP_COPY_ME)
    PrintDebug("Copying... %s (%d)\n", lump->name, lump->length);
  else
    PrintDebug("Writing... %s (%d)\n", lump->name, lump->length);
# endif
  
  if (ftell(out_file) != lump->new_start)
    PrintWarn("Consistency failure writing %s (%08lX, %08X\n", 
      lump->name, ftell(out_file), lump->new_start);
 
  if (lump->length == 0)
    return;

  if (lump->flags & LUMP_COPY_ME)
  {
    lump->data = UtilCalloc(lump->length);

    fseek(in_file, lump->start, SEEK_SET);

    len = fread(lump->data, lump->length, 1, in_file);

    if (len != 1)
      PrintWarn("Trouble reading lump %s to copy\n", lump->name);
  }

  len = fwrite(lump->data, lump->length, 1, out_file);
   
  if (len != 1)
    PrintWarn("Trouble writing lump %s\n", lump->name);
  
  align_size = ALIGN_LEN(lump->length) - lump->length;

  if (align_size > 0)
    fwrite(align_filler, align_size, 1, out_file);

  UtilFree(lump->data);

  lump->data = NULL;
}
Пример #14
0
void CalculateWallTips(void)
{
  int i;
  float_g x1;
  float_g y1;
  float_g x2;
  float_g y2;

  sector_t *left;
  sector_t *right;

  DisplayTicker();

  for (i=0; i < num_linedefs; i++)
  {
    linedef_t *line = lev_linedefs[i];

    if (line->self_ref && cur_info->skip_self_ref)
      continue;

    x1 = line->start->x;
    y1 = line->start->y;
    x2 = line->end->x;
    y2 = line->end->y;

    left  = (line->left)  ? line->left->sector  : NULL;
    right = (line->right) ? line->right->sector : NULL;
    
    VertexAddWallTip(line->start, x2-x1, y2-y1, left, right);
    VertexAddWallTip(line->end,   x1-x2, y1-y2, right, left);
  }
 
# if DEBUG_WALLTIPS
  for (i=0; i < num_vertices; i++)
  {
    vertex_t *vert = LookupVertex(i);
    wall_tip_t *tip;

    PrintDebug("WallTips for vertex %d:\n", i);

    for (tip=vert->tip_set; tip; tip=tip->next)
    {
      PrintDebug("  Angle=%1.1f left=%d right=%d\n", tip->angle,
        tip->left ? tip->left->index : -1,
        tip->right ? tip->right->index : -1);
    }
  }
# endif
}
Пример #15
0
// ==============================================================================
// Initializes everything
// ==============================================================================
int Init() {
    if(SDL_Init(SDL_INIT_EVERYTHING) != 0) {
        PrintDebug("<ERROR> Init() -> Error in SDL_Init(SDL_INIT_EVERYTHING).\nError string:\n\n",SDL_GetError());
    } else {
        PrintDebug("VIDEO: [Good] SDL initialized");
        VideoInfo = SDL_GetVideoInfo();
        if ( !VideoInfo )	{
            PrintDebug("<ERROR> ::Init () -> Video query failed.\nError string:\n\n",SDL_GetError());
            return -1;
        } else {
            return 1;
        }
    }
    return 0;
}
Пример #16
0
 // If a block has multiple entries but no exits, and it is small enough, it is useful to split it.
 // A common example is a C++ function where everything ends up at a final exit block and does some
 // RAII cleanup. Without splitting, we will be forced to introduce labelled loops to allow
 // reaching the final block
 void SplitDeadEnds() {
   unsigned TotalCodeSize = 0;
   for (BlockSet::iterator iter = Live.begin(); iter != Live.end(); iter++) {
     Block *Curr = *iter;
     TotalCodeSize += strlen(Curr->Code);
   }
   BlockSet Splits;
   BlockSet Removed;
   //DebugDump(Live, "before");
   for (BlockSet::iterator iter = Live.begin(); iter != Live.end(); iter++) {
     Block *Original = *iter;
     if (Original->BranchesIn.size() <= 1 || Original->BranchesOut.size() > 0) continue; // only dead ends, for now
     if (contains(Original->BranchesOut, Original)) continue; // cannot split a looping node
     if (strlen(Original->Code)*(Original->BranchesIn.size()-1) > TotalCodeSize/5) continue; // if splitting increases raw code size by a significant amount, abort
     // Split the node (for simplicity, we replace all the blocks, even though we could have reused the original)
     PrintDebug("Splitting block %d\n", Original->Id);
     for (BlockSet::iterator iter = Original->BranchesIn.begin(); iter != Original->BranchesIn.end(); iter++) {
       Block *Prior = *iter;
       Block *Split = new Block(Original->Code, Original->BranchVar);
       Parent->AddBlock(Split);
       PrintDebug("  to %d\n", Split->Id);
       Split->BranchesIn.insert(Prior);
       Branch *Details = Prior->BranchesOut[Original];
       Prior->BranchesOut[Split] = new Branch(Details->Condition, Details->Code);
       Prior->BranchesOut.erase(Original);
       for (BlockBranchMap::iterator iter = Original->BranchesOut.begin(); iter != Original->BranchesOut.end(); iter++) {
         Block *Post = iter->first;
         Branch *Details = iter->second;
         Split->BranchesOut[Post] = new Branch(Details->Condition, Details->Code);
         Post->BranchesIn.insert(Split);
       }
       Splits.insert(Split);
       Removed.insert(Original);
     }
     for (BlockBranchMap::iterator iter = Original->BranchesOut.begin(); iter != Original->BranchesOut.end(); iter++) {
       Block *Post = iter->first;
       Post->BranchesIn.erase(Original);
     }
     //DebugDump(Live, "mid");
   }
   for (BlockSet::iterator iter = Splits.begin(); iter != Splits.end(); iter++) {
     Live.insert(*iter);
   }
   for (BlockSet::iterator iter = Removed.begin(); iter != Removed.end(); iter++) {
     Live.erase(*iter);
   }
   //DebugDump(Live, "after");
 }
Пример #17
0
/**
 * Set file position
 *
 * @v This			File handle
 * @v Position		New file position
 * @ret Status		EFI status code
 */
static EFI_STATUS EFIAPI
FileSetPosition(EFI_FILE_HANDLE This, UINT64 Position)
{
	EFI_GRUB_FILE *File = _CR(This, EFI_GRUB_FILE, EfiFile);
	UINT64 FileSize;

	PrintInfo(L"SetPosition(%llx|'%s', %lld) %s\n", (UINT64) This,
		FileName(File), Position, (File->IsDir)?L"<DIR>":L"");

	/* If this is a directory, reset the Index to the start */
	if (File->IsDir) {
		if (Position != 0)
			return EFI_INVALID_PARAMETER;
		File->DirIndex = 0;
		return EFI_SUCCESS;
	}

	/* Fail if we attempt to seek past the end of the file (since
	 * we do not support writes).
	 */
	FileSize = GrubGetFileSize(File);
	if (Position > FileSize) {
		PrintError(L"'%s': Cannot seek to %#llx of %llx\n",
				FileName(File), Position, FileSize);
		return EFI_UNSUPPORTED;
	}

	/* Set position */
	GrubSetFileOffset(File, Position);
	PrintDebug(L"'%s': Position set to %llx\n",
			FileName(File), Position);

	return EFI_SUCCESS;
}
Пример #18
0
static seg_t *FindFastSeg(superblock_t *seg_list, const bbox_t *bbox)
{
  seg_t *best_H = NULL;
  seg_t *best_V = NULL;

  int mid_x = (bbox->minx + bbox->maxx) / 2;
  int mid_y = (bbox->miny + bbox->maxy) / 2;

  EvaluateFastWorker(seg_list, &best_H, &best_V, mid_x, mid_y);

  int H_cost = -1;
  int V_cost = -1;

  if (best_H)
    H_cost = EvalPartition(seg_list, best_H, 99999999);

  if (best_V)
    V_cost = EvalPartition(seg_list, best_V, 99999999);

# if DEBUG_PICKNODE
  PrintDebug("FindFastSeg: best_H=%p (cost %d) | best_V=%p (cost %d)\n",
             best_H, H_cost, best_V, V_cost);
# endif

  if (H_cost < 0 && V_cost < 0)
    return NULL;

  if (H_cost < 0) return best_V;
  if (V_cost < 0) return best_H;

  return (V_cost < H_cost) ? best_V : best_H;
}
Пример #19
0
//==============================================================================
// Brief  : 更新処理
// Return : void							: なし
// Arg    : void							: なし
//==============================================================================
void CSceneRanking::Update( void )
{
	// デバッグ表示
	PrintDebug( _T( "ランキング\n" ) );

	// カメラの更新
	D3DXMATRIX	mtxView;			// ビュー行列
	D3DXMATRIX	mtxOrtho;			// 正射影行列
	for( int cntCamera = 0; cntCamera < MAX_CAMERA; ++cntCamera )
	{
		m_ppCamera[ cntCamera ]->Update();
	}
	mtxView = m_ppCamera[ 0 ]->GetView();
	mtxOrtho = m_ppCamera[ 0 ]->GetOrtho();

	// 描画用変換行列の更新
	m_pArgument->m_pRenderMatrix2D->SetProjection( &mtxOrtho );
	m_pArgument->m_pRenderMatrix3D->SetView( &mtxView );

	// シーン遷移
	if( m_pArgument->m_pFade->GetState() == CObjectFade::STATE_OUT_END )
	{
		SetSceneNext( CManagerScene::SCENE_TITLE );
		EndScene();
	}
	if( m_pArgument->m_pInput->IsTrigger( CManagerInput::KEY_DECISION ) )
	{
		if( m_pArgument->m_pFade->GetState() != CObjectFade::STATE_OUT_WHILE )
		{
			m_pArgument->m_pFade->FadeOut( 20 );
		}
	}
}
Пример #20
0
//
// ReadDirEntry
//
static void ReadDirEntry(void)
{
  size_t len;
  raw_wad_entry_t entry;
  lump_t *lump;
  
  DisplayTicker();

  len = fread(&entry, sizeof(entry), 1, in_file);

  if (len != 1)
    FatalError("Trouble reading wad directory");

  lump = NewLump(UtilStrNDup(entry.name, 8));

  lump->start  = UINT32(entry.start);
  lump->length = UINT32(entry.length);

# if DEBUG_DIR
  PrintDebug("Read dir... %s\n", lump->name);
# endif

  // link it in
  lump->next = NULL;
  lump->prev = wad.dir_tail;

  if (wad.dir_tail)
    wad.dir_tail->next = lump;
  else
    wad.dir_head = lump;

  wad.dir_tail = lump;
}
Пример #21
0
void DrawScene()
{
	//glColor4ub(255, 255, 255, 255);
#ifdef _DEBUG_TIMINGS
	drawtime = GetTickCount() - drawtime_prv;
#endif
	
	//if(gui) gui->DrawAll();
	if(gui) gui->Draw();
	if(game) game->Draw();

//#ifdef _DEBUG_
	if(cfg.debug)
		PrintDebug();
//#endif

	frames++;

#ifdef _DEBUG_TIMINGS

	drawtime_prv = GetTickCount();

	drawtime_med += drawtime;

#endif
}
Пример #22
0
int v3_hook_irq(struct guest_info * info, 
		uint_t irq,
		int (*handler)(struct guest_info * info, struct v3_interrupt * intr, void * priv_data),
		void  * priv_data) 
{
  struct v3_irq_hook * hook = (struct v3_irq_hook *)V3_Malloc(sizeof(struct v3_irq_hook));

  if (hook == NULL) { 
    return -1; 
  }

  if (get_irq_hook(info, irq) != NULL) {
    PrintError("IRQ %d already hooked\n", irq);
    return -1;
  }

  hook->handler = handler;
  hook->priv_data = priv_data;
  
  info->intr_state.hooks[irq] = hook;

  if (V3_Hook_Interrupt(info, irq)) { 
    PrintError("hook_irq: failed to hook irq %d\n", irq);
    return -1;
  } else {
    PrintDebug("hook_irq: hooked irq %d\n", irq);
    return 0;
  }
}
Пример #23
0
//
// ReadLumpData
//
static void ReadLumpData(lump_t *lump)
{
  size_t len;

  cur_comms->file_pos++;
  DisplaySetBar(1, cur_comms->file_pos);
  DisplayTicker();

# if DEBUG_LUMP
  PrintDebug("Reading... %s (%d)\n", lump->name, lump->length);
# endif
  
  if (lump->length == 0)
    return;

  lump->data = UtilCalloc(lump->length);

  fseek(in_file, lump->start, SEEK_SET);

  len = fread(lump->data, lump->length, 1, in_file);

  if (len != 1)
  {
    if (wad.current_level)
      PrintWarn("Trouble reading lump '%s' in %s\n",
          lump->name, wad.current_level->name);
    else
      PrintWarn("Trouble reading lump '%s'\n", lump->name);
  }

  lump->flags &= ~LUMP_READ_ME;
}
Пример #24
0
/*
 * http://sourceforge.net/p/tianocore/edk2-MdeModulePkg/ci/master/tree/Universal/Disk/DiskIoDxe/DiskIo.c
 * To check if your driver has a chance to apply to the controllers sent during
 * the supported detection phase, try to open the child protocols they are meant
 * to consume in exclusive access (here EFI_DISK_IO).
 */
static EFI_STATUS EFIAPI
FSBindingSupported(EFI_DRIVER_BINDING_PROTOCOL *This,
		EFI_HANDLE ControllerHandle,
		EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
{
	EFI_STATUS Status;
	EFI_DISK_IO *DiskIo;

	/* Don't handle this unless we can get exclusive access to DiskIO through it */
	Status = BS->OpenProtocol(ControllerHandle,
			&DiskIoProtocol, (VOID **) &DiskIo,
			This->DriverBindingHandle, ControllerHandle,
			EFI_OPEN_PROTOCOL_BY_DRIVER);
	if (EFI_ERROR(Status))
		return Status;

	PrintDebug(L"FSBindingSupported\n");

	/* The whole concept of BindingSupported is to hint at what we may
	 * actually support, but not check if the target is valid or
	 * initialize anything, so we must close all protocols we opened.
	 */
	BS->CloseProtocol(ControllerHandle, &DiskIoProtocol,
			This->DriverBindingHandle, ControllerHandle);

	return EFI_SUCCESS;
}
Пример #25
0
static void LogProcess(Log* log, const char* msg, va_list args, LogLevel level)
{
	LogEntry entry;
	entry.message = StringFormatArgs(msg, args);
	entry.level = level;

	if(log)
		LogWrite(log, &entry);
	else
		puts(entry.message.CString());

	switch(level)
	{
	case LogLevel::Debug:
	{
		StringFormat(g_LogBuffer, "%s\n", entry.message.CString());
		PrintDebug(g_LogBuffer);
		break;
	}
	case LogLevel::Assert:
		assert(false);
		break;
	case LogLevel::Info:
	case LogLevel::Warn:
	case LogLevel::Error:
		break;
	default:
	fld_unreachable("Invalid log level");
	};
}
Пример #26
0
/**
  Clears screen in both text and graphics modes.

**/
VOID
ClearScreen()
{
    EFI_UGA_PIXEL	FillColor;
	
	FillColor.Red		= 0;
	FillColor.Green		= 0;
	FillColor.Blue		= 0;
	FillColor.Reserved	= 0;

	if (EFI_ERROR(EnsureDisplayAvailable())) {
		PrintDebug(L"No display adapters found, unable to clear screen\n");
		return;
	}

	SwtichToGraphics(FALSE);

	if (DisplayInfo.Protocol == GOP) {
		DisplayInfo.GOP->Blt(
			DisplayInfo.GOP,
			(EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)&FillColor,
			EfiBltVideoFill,
			0, 0, 0, 0,
			DisplayInfo.HorizontalResolution, DisplayInfo.VerticalResolution, 0);
	} else if (DisplayInfo.Protocol == UGA) {
		DisplayInfo.UGA->Blt(
			DisplayInfo.UGA,
			&FillColor,
			EfiUgaVideoFill,
			0, 0, 0, 0,
			DisplayInfo.HorizontalResolution, DisplayInfo.VerticalResolution, 0);
	}
}
Пример #27
0
// ==============================================================================
// Resizes the current window
// ==============================================================================
void ResizeWindow(bool Auto, int NewWidth, int NewHeight, Camera *cam) {
    if(Auto == true) {
        NewWidth = Event.resize.w;
        NewHeight = Event.resize.h;
    }
    GLfloat ratio;
    if ( NewWidth <= 0 ) {
        NewWidth = 1;
    }
    if ( NewHeight <= 0 ) {
        NewHeight = 1;
    }

    Screen = SDL_SetVideoMode( NewWidth, NewHeight, SCREEN_DEPTH, VideoFlags );
    if ( !Screen ) {
        PrintDebug("<ERROR> GP3DResizeWindow() -> Could not get a surface after resize.\nError string:\n\n",SDL_GetError());
    }

    ratio = ( GLfloat )NewWidth / ( GLfloat )NewHeight;
    glViewport( 0, 0, ( GLsizei )NewWidth, ( GLsizei )NewHeight );
    glMatrixMode( GL_PROJECTION );
    glLoadIdentity( );
    gluPerspective( cam->CameraFov, ratio, cam->CameraMinRange, cam->CameraMaxRange );
    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity( );
}
Пример #28
0
void scene::DrawScene()
{
	glColor4ub(255 - GLOBAL_COLOR_RED,
		255 - GLOBAL_COLOR_GREEN,
		255 - GLOBAL_COLOR_BLUE,
		255 - GLOBAL_COLOR_ALPHA);

	if(GLOBAL_QUAKE_ENABLED)
	{
		glPushMatrix();
		ApplyQuake();
	}

	if(iichan)
		iichan->Draw();

	// матрица восстанавливается перед отрисовкой HUD

	if(gui)
		gui->Draw();
	


	if(cfg.debug)
		PrintDebug();

	if(cfg.show_fps)
		PrintFPS();

	frames++;
}
Пример #29
0
static void CountGroups(void)
{
  // Note: this routine is destructive to the group numbers
  
  int i;

  for (i=0; i < num_sectors; i++)
  {
    sector_t *sec = LookupSector(i);
    sector_t *tmp;

    int group = sec->rej_group;
    int num = 0;

    if (group < 0)
      continue;

    sec->rej_group = -1;
    num++;

    for (tmp=sec->rej_next; tmp != sec; tmp=tmp->rej_next)
    {
      tmp->rej_group = -1;
      num++;
    }

    PrintDebug("Group %d  Sectors %d\n", group, num);
  }
}
Пример #30
0
static void MarkPolyobjSector(sector_t *sector)
{
  int i;
    
  if (! sector)
    return;

# if DEBUG_POLYOBJ
  PrintDebug("  Marking SECTOR %d\n", sector->index);
# endif

  /* already marked ? */
  if (sector->has_polyobj)
    return;

  /* mark all lines of this sector as precious, to prevent the sector
   * from being split.
   */ 
  sector->has_polyobj = TRUE;

  for (i = 0; i < num_linedefs; i++)
  {
    linedef_t *L = lev_linedefs[i];

    if ((L->right && L->right->sector == sector) ||
        (L->left && L->left->sector == sector))
    {
      L->is_precious = TRUE;
    }
  }
}