Example #1
0
  FOR_BLOCKS(length, dst, src, CAST128_BLOCK_SIZE)
    {
      uint32_t t, l, r;

      /* Get inblock into l,r */
      l = READ_UINT32(src);
      r = READ_UINT32(src+4);

      /* Do the work */
      F1(l, r,  0);
      F2(r, l,  1);
      F3(l, r,  2);
      F1(r, l,  3);
      F2(l, r,  4);
      F3(r, l,  5);
      F1(l, r,  6);
      F2(r, l,  7);
      F3(l, r,  8);
      F1(r, l,  9);
      F2(l, r, 10);
      F3(r, l, 11);
      /* Only do full 16 rounds if key length > 80 bits */
      if (ctx->rounds > 12) {
	F1(l, r, 12);
	F2(r, l, 13);
	F3(l, r, 14);
	F1(r, l, 15);
      }
      /* Put l,r into outblock */
      WRITE_UINT32(dst, r);
      WRITE_UINT32(dst + 4, l);
      /* Wipe clean */
      t = l = r = 0;
    }
Example #2
0
bool unshield_read_common_header(uint8_t** buffer, CommonHeader* common)
{
  uint8_t* p = *buffer;
  common->signature              = READ_UINT32(p); p += 4;

  if (CAB_SIGNATURE != common->signature)
  {
    unshield_error("Invalid file signature");

    if (MSCF_SIGNATURE == common->signature)
      unshield_warning("Found Microsoft Cabinet header. Use cabextract (http://www.kyz.uklinux.net/cabextract.php) to unpack this file.");

    return false;
  }

  common->version                = READ_UINT32(p); p += 4;
  common->volume_info            = READ_UINT32(p); p += 4;
  common->cab_descriptor_offset  = READ_UINT32(p); p += 4;
  common->cab_descriptor_size    = READ_UINT32(p); p += 4;

#if VERBOSE
  unshield_trace("Common header: %08x %08x %08x %08x",
      common->version, 
      common->volume_info, 
      common->cab_descriptor_offset, 
      common->cab_descriptor_size);
#endif

  *buffer = p;
  return true;
}
Example #3
0
void Lingo::c_ifcode() {
	Datum d;
	int savepc = g_lingo->_pc;	/* then part */

	uint then =    READ_UINT32(&(*g_lingo->_currentScript)[savepc]);
	uint elsep =   READ_UINT32(&(*g_lingo->_currentScript)[savepc + 1]);
	uint end =     READ_UINT32(&(*g_lingo->_currentScript)[savepc + 2]);
	uint skipEnd = READ_UINT32(&(*g_lingo->_currentScript)[savepc + 3]);

	debugC(8, kDebugLingoExec, "executing cond (have to %s end)", skipEnd ? "skip" : "execute");
	g_lingo->execute(savepc + 4);	/* condition */

	d = g_lingo->pop();

	if (d.toInt()) {
		debugC(8, kDebugLingoExec, "executing then");
		g_lingo->execute(then + savepc - 1);
	} else if (elsep) { /* else part? */
		debugC(8, kDebugLingoExec, "executing else");
		g_lingo->execute(elsep + savepc - 1);
	}

	if (!g_lingo->_returning && !skipEnd) {
		g_lingo->_pc = end + savepc - 1; /* next stmt */
		debugC(8, kDebugLingoExec, "executing end");
	} else {
		debugC(8, kDebugLingoExec, "Skipped end");
	}
}
Example #4
0
void Lingo::c_repeatwhilecode(void) {
	Datum d;
	int savepc = g_lingo->_pc;

	uint body = READ_UINT32(&(*g_lingo->_currentScript)[savepc]);
	uint end =  READ_UINT32(&(*g_lingo->_currentScript)[savepc + 1]);

	g_lingo->execute(savepc + 2);	/* condition */
	d = g_lingo->pop();
	d.toInt();

	while (d.u.i) {
		g_lingo->execute(body + savepc - 1);	/* body */
		if (g_lingo->_returning)
			break;

		if (g_lingo->_exitRepeat) {
			g_lingo->_exitRepeat = false;
			break;
		}

		g_lingo->execute(savepc + 2);	/* condition */
		d = g_lingo->pop();
		d.toInt();
	}

	if (!g_lingo->_returning)
		g_lingo->_pc = end + savepc - 1; /* next stmt */
}
Example #5
0
void Lingo::c_theentityassign() {
	inst e = (*g_lingo->_currentScript)[g_lingo->_pc++];
	inst f = (*g_lingo->_currentScript)[g_lingo->_pc++];
	Datum id = g_lingo->pop();

	int entity = READ_UINT32(&e);
	int field  = READ_UINT32(&f);

	Datum d = g_lingo->pop();
	g_lingo->setTheEntity(entity, id, field, d);
}
Example #6
0
void Lingo::c_whencode() {
	Datum d;
	uint start = g_lingo->_pc;
	uint end = READ_UINT32(&(*g_lingo->_currentScript)[start]) + start - 1;
	Common::String eventname((char *)&(*g_lingo->_currentScript)[start + 1]);

	start += g_lingo->calcStringAlignment(eventname.c_str()) + 1;

	debugC(1, kDebugLingoExec, "c_whencode([%5d][%5d], %s)", start, end, eventname.c_str());

	int entity = g_lingo->_currentEntityId;
	g_lingo->_currentEntityId = 0;

	g_lingo->define(eventname, start, 0, NULL, end);

	g_lingo->_currentEntityId = entity;

	if (debugChannelSet(1, kDebugLingoExec)) {
		uint pc = start;
		while (pc <= end) {
			Common::String instr = g_lingo->decodeInstruction(pc, &pc);
			debugC(1, kDebugLingoExec, "[%5d] %s", pc, instr.c_str());
		}
	}

	g_lingo->_pc = end;
}
Example #7
0
void Surface::copyToCurrentPortMasked(const Common::Rect &srcRect, const Common::Rect &dstRect, const Surface *mask) const {
	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();
	byte *src = (byte *)_surface->getBasePtr(srcRect.left, srcRect.top);
	byte *dst = (byte *)screen->getBasePtr(dstRect.left, dstRect.top);

	int lineSize = srcRect.width() * _surface->format.bytesPerPixel;

	for (int y = 0; y < srcRect.height(); y++) {
		byte *maskSrc = (byte *)mask->getSurface()->getBasePtr(0, y);

		for (int x = 0; x < srcRect.width(); x++) {
			if (g_system->getScreenFormat().bytesPerPixel == 2) {
				uint16 color = READ_UINT16(maskSrc);
				if (!isTransparent(color))
					memcpy(dst, src, 2);
			} else if (g_system->getScreenFormat().bytesPerPixel == 4) {
				uint32 color = READ_UINT32(maskSrc);
				if (!isTransparent(color))
					memcpy(dst, src, 4);
			}

			src += g_system->getScreenFormat().bytesPerPixel;
			maskSrc += g_system->getScreenFormat().bytesPerPixel;
			dst += g_system->getScreenFormat().bytesPerPixel;
		}

		src += _surface->pitch - lineSize;
		dst += screen->pitch - lineSize;
	}
}
Example #8
0
void Lingo::c_constpush() {
	Datum d;
	inst i = (*g_lingo->_currentScript)[g_lingo->_pc++];
	d.u.i = READ_UINT32(&i);
	d.type = INT;
	g_lingo->push(d);
}
Example #9
0
void Surface::copyToCurrentPortTransparentGlow(const Common::Rect &srcRect, const Common::Rect &dstRect) const {
	// This is the same as copyToCurrentPortTransparent(), but turns the red value of each
	// pixel all the way up.

	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();
	byte *src = (byte *)_surface->getBasePtr(srcRect.left, srcRect.top);
	byte *dst = (byte *)screen->getBasePtr(dstRect.left, dstRect.top);

	int lineSize = srcRect.width() * _surface->format.bytesPerPixel;

	for (int y = 0; y < srcRect.height(); y++) {
		for (int x = 0; x < srcRect.width(); x++) {
			if (g_system->getScreenFormat().bytesPerPixel == 2) {
				uint16 color = READ_UINT16(src);
				if (!isTransparent(color))
					WRITE_UINT16(dst, getGlowColor(color));
			} else if (g_system->getScreenFormat().bytesPerPixel == 4) {
				uint32 color = READ_UINT32(src);
				if (!isTransparent(color))
					WRITE_UINT32(dst, getGlowColor(color));
			}

			src += g_system->getScreenFormat().bytesPerPixel;
			dst += g_system->getScreenFormat().bytesPerPixel;
		}

		src += _surface->pitch - lineSize;
		dst += screen->pitch - lineSize;
	}
}
Example #10
0
void Surface::scaleTransparentCopy(const Common::Rect &srcRect, const Common::Rect &dstRect) const {
	// I'm doing simple linear scaling here
	// dstRect(x, y) = srcRect(x * srcW / dstW, y * srcH / dstH);

	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();

	int srcW = srcRect.width();
	int srcH = srcRect.height();
	int dstW = dstRect.width();
	int dstH = dstRect.height();

	for (int y = 0; y < dstH; y++) {
		for (int x = 0; x < dstW; x++) {
			if (g_system->getScreenFormat().bytesPerPixel == 2) {
				uint16 color = READ_UINT16((byte *)_surface->getBasePtr(
						x * srcW / dstW + srcRect.left,
						y * srcH / dstH + srcRect.top));
				if (!isTransparent(color))
					WRITE_UINT16((byte *)screen->getBasePtr(x + dstRect.left, y + dstRect.top), color);
			} else if (g_system->getScreenFormat().bytesPerPixel == 4) {
				uint32 color = READ_UINT32((byte *)_surface->getBasePtr(
						x * srcW / dstW + srcRect.left,
						y * srcH / dstH + srcRect.top));
				if (!isTransparent(color))
					WRITE_UINT32((byte *)screen->getBasePtr(x + dstRect.left, y + dstRect.top), color);
			}
		}
	}
}
Example #11
0
void Surface::scaleTransparentCopyGlow(const Common::Rect &srcRect, const Common::Rect &dstRect) const {
	// This is the same as scaleTransparentCopy(), but turns the red value of each
	// pixel all the way up.

	Graphics::Surface *screen = ((PegasusEngine *)g_engine)->_gfx->getCurSurface();

	int srcW = srcRect.width();
	int srcH = srcRect.height();
	int dstW = dstRect.width();
	int dstH = dstRect.height();

	for (int y = 0; y < dstH; y++) {
		for (int x = 0; x < dstW; x++) {
			if (g_system->getScreenFormat().bytesPerPixel == 2) {
				uint16 color = READ_UINT16((byte *)_surface->getBasePtr(
						x * srcW / dstW + srcRect.left,
						y * srcH / dstH + srcRect.top));
				if (!isTransparent(color))
					WRITE_UINT16((byte *)screen->getBasePtr(x + dstRect.left, y + dstRect.top), getGlowColor(color));
			} else if (g_system->getScreenFormat().bytesPerPixel == 4) {
				uint32 color = READ_UINT32((byte *)_surface->getBasePtr(
						x * srcW / dstW + srcRect.left,
						y * srcH / dstH + srcRect.top));
				if (!isTransparent(color))
					WRITE_UINT32((byte *)screen->getBasePtr(x + dstRect.left, y + dstRect.top), getGlowColor(color));
			}
		}
	}
}
Example #12
0
void CloudIcon::makeAlphaIcon(const Graphics::Surface &icon, float alpha) {
	_alphaIcon.copyFrom(icon);

	byte *pixels = (byte *)_alphaIcon.getPixels();
	for (int y = 0; y < _alphaIcon.h; y++) {
		byte *row = pixels + y * _alphaIcon.pitch;
		for (int x = 0; x < _alphaIcon.w; x++) {
			uint32 srcColor;
			if (_alphaIcon.format.bytesPerPixel == 2)
				srcColor = READ_UINT16(row);
			else if (_alphaIcon.format.bytesPerPixel == 3)
				srcColor = READ_UINT24(row);
			else
				srcColor = READ_UINT32(row);

			// Update color's alpha
			byte r, g, b, a;
			_alphaIcon.format.colorToARGB(srcColor, a, r, g, b);
			a = (byte)(a * alpha);
			uint32 color = _alphaIcon.format.ARGBToColor(a, r, g, b);

			if (_alphaIcon.format.bytesPerPixel == 2)
				*((uint16 *)row) = color;
			else
				*((uint32 *)row) = color;

			row += _alphaIcon.format.bytesPerPixel;
		}
	}
}
/* in the ENDISx register, FALSE to disable the interrupt */
static os_status setInterruptEnable(os_hwi_handle hwi_num,
                                    bool enable_interrupt)
{
    uint16_t        index;
    uint32_t        endis_reg = 0;
    uint32_t        *endis_reg_ptr;
    os_hwi_handle   epic_hwi_num = 0;
    uint32_t        interrupt_bit = 0;

    /* Don't handle Non-EPIC interrupts don't require any more handling */
    if (hwi_num < EPIC_INTERRUPTS_OFFSET)
        RETURN_ERROR(OS_ERR_HWI_INVALID);
    else /* get the EPIC interrupt zero-based index */
        epic_hwi_num = (os_hwi_handle)(hwi_num - EPIC_INTERRUPTS_OFFSET);

    /* handle the Enable/Disable Interrupts register ENDISx */
    index = (os_hwi_handle)(epic_hwi_num >> 5);           /* /32 , there are 8 ENDISx registers*/
    endis_reg_ptr = (uint32_t *)((g_dsp_plat_map->epic).p_endis);
    endis_reg_ptr += index;

    /* we need to set or clear the corresponding interrupt bit */
    interrupt_bit = (uint32_t)(0x00000001 << (epic_hwi_num & 0x001F));

    READ_UINT32(endis_reg, *endis_reg_ptr);
    if (enable_interrupt)
        endis_reg |= interrupt_bit;
    else
        endis_reg &= ~interrupt_bit;
    WRITE_UINT32(*endis_reg_ptr, endis_reg);

    return OS_SUCCESS;
}
/* Caution: call only when interrupts are disabled  */
static void prioritySet(os_hwi_handle     hwi_num,
                 os_hwi_priority   priority)
{
    uint16_t        index;
    uint32_t        priority_mask;
    uint32_t        *priority_reg_ptr;
    uint32_t        current_reg;
    /* EPIC interrupt:
    Figure out which IPL register it is in. There are four interrupts
    per IPL register. */

    index = (uint16_t)(hwi_num >> 2);           /* /4 */

    priority_reg_ptr = (uint32_t *)((g_dsp_plat_map->epic).p_ipl);
    priority_reg_ptr += index;

    /* Figure out what the priority mask looks like */
    priority_mask = 0x000000FFUL << ((hwi_num & 0x0003) * 8);

    /* For NMI priority, the IPL bits do not matter in the p_ipl */
    /* register, only need to set the INC bit to NMI. */
    if (priority == OS_HWI_PRIORITY_NMI)
        priority = 0x80;
    /* Set priority */
    READ_UINT32(current_reg, *priority_reg_ptr);
    current_reg &= (priority_mask ^ 0xFFFFFFFF);
    /* Set priority to zeroed bits in IPL */
    current_reg |= ((uint32_t)priority) << ((hwi_num & 0x0003) * 8);
    WRITE_UINT32(*priority_reg_ptr,current_reg);
}
Example #15
0
gboolean
mpeg_util_parse_sequence_hdr (MPEGSeqHdr * hdr, GstBuffer * buffer)
{
  GstBitReader reader = GST_BIT_READER_INIT_FROM_BUFFER (buffer);
  guint8 dar_idx, par_idx;
  guint8 load_intra_flag, load_non_intra_flag;

  /* skip sync word */
  if (!gst_bit_reader_skip (&reader, 8 * 4))
    return FALSE;

  /* resolution */
  READ_UINT16 (&reader, hdr->width, 12);
  READ_UINT16 (&reader, hdr->height, 12);

  /* aspect ratio */
  READ_UINT8 (&reader, dar_idx, 4);
  set_par_from_dar (hdr, dar_idx);

  /* framerate */
  READ_UINT8 (&reader, par_idx, 4);
  set_fps_from_code (hdr, par_idx);

  /* bitrate */
  READ_UINT32 (&reader, hdr->bitrate, 18);

  if (!gst_bit_reader_skip (&reader, 1))
    return FALSE;

  /* VBV buffer size */
  READ_UINT16 (&reader, hdr->vbv_buffer, 10);

  /* constrained parameters flag */
  READ_UINT8 (&reader, hdr->constrained_parameters_flag, 1);

  /* intra quantizer matrix */
  READ_UINT8 (&reader, load_intra_flag, 1);
  if (load_intra_flag) {
    gint i;
    for (i = 0; i < 64; i++)
      READ_UINT8 (&reader, hdr->intra_quantizer_matrix[mpeg_zigzag_8x8[i]], 8);
  } else
    memcpy (hdr->intra_quantizer_matrix, default_intra_quantizer_matrix, 64);

  /* non intra quantizer matrix */
  READ_UINT8 (&reader, load_non_intra_flag, 1);
  if (load_non_intra_flag) {
    gint i;
    for (i = 0; i < 64; i++)
      READ_UINT8 (&reader, hdr->non_intra_quantizer_matrix[mpeg_zigzag_8x8[i]],
          8);
  } else
    memset (hdr->non_intra_quantizer_matrix, 16, 64);

  return TRUE;

error:
  GST_WARNING ("error parsing \"Sequence Header\"");
  return FALSE;
}
Example #16
0
void Lingo::c_call() {
	Common::String name((char *)&(*g_lingo->_currentScript)[g_lingo->_pc]);
	g_lingo->_pc += g_lingo->calcStringAlignment(name.c_str());

	int nargs = READ_UINT32(&(*g_lingo->_currentScript)[g_lingo->_pc++]);

	g_lingo->call(name, nargs);
}
uint32_t Transport::status()
{
  uint8_t in[4];
  command(Transport::GET_STATUS, NULL, 0, in, sizeof(in));

  uint32_t status;
  READ_UINT32(&in[0], status);
  return status;
}
Example #18
0
void Lingo::c_repeatwithcode(void) {
	Datum d;
	int savepc = g_lingo->_pc;

	uint init = READ_UINT32(&(*g_lingo->_currentScript)[savepc]);
	uint finish =  READ_UINT32(&(*g_lingo->_currentScript)[savepc + 1]);
	uint body = READ_UINT32(&(*g_lingo->_currentScript)[savepc + 2]);
	int inc = (int32)READ_UINT32(&(*g_lingo->_currentScript)[savepc + 3]);
	uint end =  READ_UINT32(&(*g_lingo->_currentScript)[savepc + 4]);
	Common::String countername((char *)&(*g_lingo->_currentScript)[savepc + 5]);
	Symbol *counter = g_lingo->lookupVar(countername.c_str());

	if (counter->type == CASTREF) {
		error("Cast ref used as index: %s", countername.c_str());
	}

	g_lingo->execute(init + savepc - 1);	/* condition */
	d = g_lingo->pop();
	d.toInt();
	counter->u.i = d.u.i;
	counter->type = INT;

	while (true) {
		g_lingo->execute(body + savepc - 1);	/* body */
		if (g_lingo->_returning)
			break;

		if (g_lingo->_exitRepeat) {
			g_lingo->_exitRepeat = false;
			break;
		}

		counter->u.i += inc;
		g_lingo->execute(finish + savepc - 1);	/* condition */
		d = g_lingo->pop();
		d.toInt();

		if (counter->u.i == d.u.i + inc)
			break;
	}

	if (!g_lingo->_returning)
		g_lingo->_pc = end + savepc - 1; /* next stmt */
}
Example #19
0
int
sftp_get_uint32(struct sftp_input *i, uint32_t *value)
{
  uint8_t buf[4];
  if (!GET_DATA(i, buf))
    return 0;

  *value = READ_UINT32(buf);
  return 1;
}
Example #20
0
uint32_t hwTimer32GlobalGet(soc_timer32_module_t module)
{
    volatile uint32_t reg;
#ifdef HW_TIMER_ERROR_ASSERT
    OS_ASSERT_COND(!(module > NUM_OF_HW_TIMER_32b_MODULES-1));
#endif
    // Reading one of the counters in order to load the global timer
    READ_UINT32(reg, soc_timer32_module[module].tmr[0].tmr_cntr);
    return GET_UINT32(soc_timer32_module[module].tmr_glb);
}
Example #21
0
int
parse_uint32(struct simple_buffer *buffer, uint32_t *result)
{
  if (LEFT < 4)
    return 0;

  *result = READ_UINT32(HERE);
  ADVANCE(4);
  return 1;
}
Example #22
0
static int
read_uint32(FILE *f, uint32_t *n)
{
  uint8_t buf[4];
  if (fread(buf, 1, sizeof(buf), f) != sizeof(buf))
    return 0;

  *n = READ_UINT32(buf);
  return 1;
}
Example #23
0
void Lingo::c_whencode() {
	Datum d;
	int start = g_lingo->_pc;
	int end = READ_UINT32(&(*g_lingo->_currentScript)[start]);
	Common::String eventname((char *)&(*g_lingo->_currentScript)[start]);

	start += g_lingo->calcStringAlignment(eventname.c_str());

	warning("STUB: c_whencode([%5d][%5d], %s)", start, end, eventname.c_str());

	g_lingo->_pc = end;
}
bool osGpioDataRead(int gpio_num, int port)
{
    uint32_t reg;
 
    OS_ASSERT_COND(gpio_num < OS_NUM_OF_GPIO);
    OS_ASSERT_COND(port <= OS_NUM_OF_GPIO_PORTS);
 
    READ_UINT32(reg, g_dsp_pa_ccsr_map->gpio[gpio_num].gpdat);
    if ((reg & (1 << (31-port))) == 0)
        return 0;
    else
        return 1;
}
Example #25
0
Uint32 dw_getPixel(SDL_Surface *s, Uint16 x, Uint16 y) {
	assert(s);
	assert(x < s->w && y < s->h);

	Uint32 bpp = s->format->BytesPerPixel;
	Uint8 *p =  (Uint8 *)s->pixels + (y * s->pitch) + (x * bpp);
	Uint32 pix;

	switch (bpp) {
		case 1: // b/w
			return *p;
		case 2: // 16 bit per pixel
			return READ_UINT16(p);
		case 3:
			pix = p[0] << 24 | p[1] << 16 | p[0] << 0;
			return READ_UINT32(&pix);
		case 4:
			return READ_UINT32(p);
		default: // !?!?
			return 0;
	}
}
Example #26
0
/* Returns 1 of all was well, 0 on error, and -1 on EOF */
int
sftp_read_packet(struct sftp_input *i)
{
  uint8_t buf[4];
  int bytesread = 0;

  if (i->left) /* Unread data? */
    {
      uint8_t d;

      while (i->left &&                         /* Data remaining? */
	     0<sftp_get_data(i, 1, &d)         /* Read OK? */
	     )
	;

      /* Now, there shouldn't be any more data remaining. Next time
       * we're called, the next packet should be read (or we had an
       * error and all data is not read, if that's the case, return
       * error).
       */

      if (i->left)    /* i->left non-zero => sftp_get_data failed => error  */
	return -1; 

      return 0;
    }

  /* First, deallocate the strings. */
  sftp_input_clear_strings(i);

  while (bytesread < sizeof(buf))
    {
      int j = read(i->fd, buf+bytesread, sizeof(buf)-bytesread);

      while(-1==j && EINTR==errno)   /* Loop over EINTR */
	j = read(i->fd, buf+bytesread, sizeof(buf)-bytesread);
  
      if (-1==j) /* Not EINTR but a real error */
	return -1;

      if (j == 0)
	/* EOF */
	return bytesread ? 0 : -1;
      bytesread += j;
    }
  
  i->left = READ_UINT32(buf); /* Store packet size */
  return 1;

}
Example #27
0
void Lingo::c_arraypush() {
	Datum d;
	inst v = (*g_lingo->_currentScript)[g_lingo->_pc++];
	int arraySize = READ_UINT32(&v);

	warning("STUB: c_arraypush()");

	for (int i = 0; i < arraySize; i++)
		g_lingo->pop();

	d.u.i = arraySize;
	d.type = INT;
	g_lingo->push(d);
}
Example #28
0
const SCENE_STRUC *GetSceneStruc(const byte *pStruc) {
	if (TinselVersion == TINSEL_V2)
		return (const SCENE_STRUC *)pStruc;

	// Copy appropriate fields into tempStruc, and return a pointer to it
	const byte *p = pStruc;
	memset(&tempStruc, 0, sizeof(SCENE_STRUC));

	tempStruc.numEntrance = READ_UINT32(p); p += sizeof(uint32);
	tempStruc.numPoly = READ_UINT32(p); p += sizeof(uint32);
	tempStruc.numTaggedActor = READ_UINT32(p); p += sizeof(uint32);
	tempStruc.defRefer = READ_UINT32(p); p += sizeof(uint32);
	tempStruc.hSceneScript = READ_UINT32(p); p += sizeof(uint32);
	tempStruc.hEntrance = READ_UINT32(p); p += sizeof(uint32);
	tempStruc.hPoly = READ_UINT32(p); p += sizeof(uint32);
	tempStruc.hTaggedActor = READ_UINT32(p); p += sizeof(uint32);

	return &tempStruc;
}
bool osGpioEventReadAndClear(int gpio_num, int port)
{
    uint32_t reg;
 
    OS_ASSERT_COND(gpio_num < OS_NUM_OF_GPIO);
    OS_ASSERT_COND(port <= OS_NUM_OF_GPIO_PORTS);
 
    READ_UINT32(reg, g_dsp_pa_ccsr_map->gpio[gpio_num].gpier);
    if ((reg & (1 << (31-port))) == 0)
    {
        return 0;
    }
    else
    {
        CLEAR_LEVEL_INTERRUPT(g_dsp_pa_ccsr_map->gpio[gpio_num].gpier, 1<<(31-port));
        return 1;
    }
}
Example #30
0
bool SaveConverter::swapDataEndian(byte *data, const byte *sizes, uint32 count) {
    if (!data || !sizes || (count == 0))
        return false;

    while (count-- > 0) {
        if      (*sizes == 3) // 32bit value (3 additional bytes)
            WRITE_UINT32(data, SWAP_BYTES_32(READ_UINT32(data)));
        else if (*sizes == 1) // 16bit value (1 additional byte)
            WRITE_UINT16(data, SWAP_BYTES_16(READ_UINT16(data)));
        else if (*sizes != 0) // else, it has to be an 8bit value
            return false;

        count -= *sizes;
        data  += *sizes + 1;
        sizes += *sizes + 1;
    }

    return true;
}