예제 #1
0
TextureFormat const *
TextureFormat::fromImageType(AbstractImage::Type type, bool is_depth)
{
  if (is_depth)
  {
    switch (type)
    {
      case AbstractImage::Type::LUMINANCE_16U : return DEPTH16();
      case AbstractImage::Type::LUMINANCE_32U : return DEPTH32();
      case AbstractImage::Type::LUMINANCE_32F : return DEPTH32F();
      default: throw Error("TextureFormat: No supported depth texture format corresponds to the specified image format");
    }
  }

  enum { COLOR_ORDER_RGB, COLOR_ORDER_BGR } color_order;
  color_order = (AbstractImage::Channel::RED < AbstractImage::Channel::BLUE ? COLOR_ORDER_RGB : COLOR_ORDER_BGR);

  switch (type)
  {
    case AbstractImage::Type::LUMINANCE_8U  : return L8();
    case AbstractImage::Type::LUMINANCE_16U : return L16();
    case AbstractImage::Type::LUMINANCE_32F : return L32F();
    case AbstractImage::Type::RGB_8U        : return color_order == COLOR_ORDER_RGB ? RGB8() : BGR8();
    case AbstractImage::Type::RGBA_8U       : return color_order == COLOR_ORDER_RGB ? RGBA8() : BGRA8();
    case AbstractImage::Type::RGB_16U       : return color_order == COLOR_ORDER_RGB ? RGB16() : BGR16();
    case AbstractImage::Type::RGBA_16U      : return color_order == COLOR_ORDER_RGB ? RGBA16() : BGRA16();
    case AbstractImage::Type::RGB_32F       : return color_order == COLOR_ORDER_RGB ? RGB32F() : BGR32F();
    case AbstractImage::Type::RGBA_32F      : return color_order == COLOR_ORDER_RGB ? RGBA32F() : BGRA32F();
    default: throw Error("TextureFormat: No supported texture format corresponds to the specified image format");
  }
}
예제 #2
0
felica *
felica_polling(pasori *pp, uint16 systemcode, uint8 RFU, uint8 timeslot)
{
	felica *f;
	uint8 cmd[5];
	uint8 resp[DATASIZE + 1];
	int l, n, offset;

	Log("%s\n", __func__);

	if (pp == NULL) {
		return NULL;
	}

	cmd[0] = (uint8) FELICA_CMD_POLLING;	/* command code */
	cmd[1] = H8(systemcode);
	cmd[2] = L8(systemcode);
	cmd[3] = RFU;				/* zero */
	cmd[4] = timeslot;
	n = 5;

	switch (pp->type) {
	case PASORI_TYPE_S310:
	case PASORI_TYPE_S320:
		offset = 0;
		pasori_write(pp, cmd, &n);
		break;
	case PASORI_TYPE_S330:
		offset = 3;
		pasori_list_passive_target(pp, cmd, &n);
		break;
	}

	n = DATASIZE;
	l = _felica_pasori_read(pp, resp, &n, offset);
	if (l) {
		return NULL;
	}

	if (resp[0] != FELICA_ANS_POLLING) {
		Log("!!!INVALID RETURN VALUE (%d)\n", resp[0]);
		return NULL;
	}
	f = (felica *) malloc(sizeof(felica));
	f->p = pp;

	memcpy(f->IDm, &resp[1], FELICA_IDM_LENGTH);
	memcpy(f->PMm, &resp[9], FELICA_PMM_LENGTH);

	f->systemcode = systemcode;
	f->area_num = 0;
	f->service_num = 0;

	return f;
}
예제 #3
0
static int
pack_block_info(int n, felica_block_info *info, int *service_num, uint8 *services, uint8 *data)
{
	int i, len, snum, s, slist[16] = {0};
	uint8 *blklist;

	snum = 0;
	len = 0;
	blklist = data;
	for (i = 0; i < n; i++) {
		if (len >= DATASIZE) return -1;

		s = search_service(snum, slist, info[i].service);
		if (s < 0) {
			if (snum >= (int) (sizeof(slist)/sizeof(*slist))) {
				return -1;
			}

			slist[snum] = info[i].service;
			services[snum * 2] = L8(info[i].service);
			services[snum *2 + 1] = H8(info[i].service);
			s = snum;
			snum++;
		}

		blklist[0] = ((info[i].mode << 4) & 0x07) + (s & 0x0f);
		if (info[i].block > 255) {
			blklist[1] = L8(info[i].block);
			blklist[2] = H8(info[i].block);
			blklist += 3;
			len += 3;
		} else {
			blklist[0] |= 0x80;		/* element size == 2 */
			blklist[1] = info[i].block;
			blklist += 2;
			len += 2;
		}
	}

	*service_num = snum;
	return len;
}
예제 #4
0
TextureFormat const *
TextureFormat::fromCode(Code code)
{
  switch (code)
  {
    case Code::L8:
      return L8();

    case Code::L16:
      return L16();

    case Code::L16F:
      return L16F();

    case Code::L32F:
      return L32F();

    case Code::A8:
      return A8();

    case Code::A16:
      return A16();

    case Code::A16F:
      return A16F();

    case Code::A32F:
      return A32F();

    case Code::LA4:
      return LA4();

    case Code::LA8:
      return LA8();

    case Code::LA16:
      return LA16();

    case Code::LA16F:
      return LA16F();
      break;

    case Code::LA32F:
      return LA32F();

    case Code::RGB5:
      return RGB5();

    case Code::RGB5A1:
      return RGB5A1();

    case Code::RGB8:
      return RGB8();

    case Code::RGB10:
      return RGB10();

    case Code::RGB10A2:
      return RGB10A2();

    case Code::RGB16:
      return RGB16();

    case Code::RGB32F:
      return RGB32F();

    case Code::R11G11B10F:
      return R11G11B10F();

    case Code::RGB9E5F:
      return RGB9E5F();

    case Code::RGB8I:
      return RGB8I();

    case Code::RGB8UI:
      return RGB8UI();

    case Code::ARGB8:
      return NULL;

    case Code::BGR8:
      return BGR8();

    case Code::BGRA8:
      return BGRA8();

    case Code::BGR16:
      return BGR16();

    case Code::BGRA16:
      return BGRA16();

    case Code::BGR32F:
      return BGR32F();

    case Code::BGRA32F:
      return BGRA32F();

    case Code::R8:
      return R8();

    case Code::RG8:
      return RG8();

    case Code::RG8I:
      return RG8I();

    case Code::RG8UI:
      return RG8UI();

    case Code::RG16F:
      return RG16F();

    case Code::RGBA8:
      return RGBA8();

    case Code::RGBA16:
      return RGBA16();

    case Code::RGBA16F:
      return RGBA16F();

    case Code::RGBA32F:
      return RGBA32F();

    case Code::RGBA32UI:
      return RGBA32UI();

    case Code::BAYER_RGGB8:

      // TODO
    case Code::BAYER_GRBG8:

      // TODO
    case Code::BAYER_GBRG8:

      // TODO
    case Code::BAYER_BGGR8:

      // TODO
    case Code::BAYER_RGGB32F:

      // TODO
    case Code::BAYER_GRBG32F:

      // TODO
    case Code::BAYER_GBRG32F:

      // TODO
    case Code::BAYER_BGGR32F:

      // TODO
    case Code::HSV8:

      // TODO
    case Code::HSV32F:
      // TODO
      return NULL;
      break;

    case Code::RGB_DXT1:
      return RGB_DXT1();
      break;

    case Code::RGBA_DXT1:
      return RGBA_DXT1();
      break;

    case Code::RGBA_DXT3:
      return RGBA_DXT3();
      break;

    case Code::RGBA_DXT5:
      return RGBA_DXT5();
      break;

    case Code::SRGB8:
      return SRGB8();
      break;

    case Code::SRGBA8:
      return SRGBA8();
      break;

    case Code::SL8:
      return SL8();
      break;

    case Code::SLA8:
      return SLA8();
      break;

    case Code::SRGB_DXT1:
      return SRGB_DXT1();
      break;

    case Code::SRGBA_DXT1:
      return SRGBA_DXT1();
      break;

    case Code::SRGBA_DXT3:
      return SRGBA_DXT3();
      break;

    case Code::SRGBA_DXT5:
      return SRGBA_DXT5();
      break;

    case Code::DEPTH16:
      return DEPTH16();
      break;

    case Code::DEPTH24:
      return DEPTH24();
      break;

    case Code::DEPTH32:
      return DEPTH32();
      break;

    case Code::DEPTH32F:
      return DEPTH32F();
      break;

    case Code::STENCIL1:
      return STENCIL1();
      break;

    case Code::STENCIL4:
      return STENCIL4();
      break;

    case Code::STENCIL8:
      return STENCIL8();
      break;

    case Code::STENCIL16:
      return STENCIL16();
      break;

    case Code::DEPTH24_STENCIL8:
      return DEPTH24_STENCIL8();
      break;

    case Code::YUV420_PLANAR:
      return YUV420_PLANAR();
      break;

    case Code::YUV422:
      return YUV422();
      break;

    case Code::YUV444:
      return YUV444();
      break;

    default:
      return NULL;
  }
}
예제 #5
0
파일: llrem.cpp 프로젝트: chenbk85/QOR
	//------------------------------------------------------------------------------
	virtual FP Generate()
	{
		nsArch::nsx86::Cx86HLAIntrinsics& HLA( *( dynamic_cast< nsArch::nsx86::Cx86HLAIntrinsics* >( m_pHLA ) ) );
		nsArch::nsx86::CCPU& CPU = dynamic_cast< nsArch::nsx86::CCPU& >( TheMachine()->Logic().CPU() );

		//static const Cmp_unsigned__int32 PAGESIZE = 4096;

		CPU.clear();

		nsArch::nsx86::CLabel L1( CPU.newLabel() );
		nsArch::nsx86::CLabel L2( CPU.newLabel() );
		nsArch::nsx86::CLabel L3( CPU.newLabel() );
		nsArch::nsx86::CLabel L4( CPU.newLabel() );
		nsArch::nsx86::CLabel L5( CPU.newLabel() );
		nsArch::nsx86::CLabel L6( CPU.newLabel() );
		nsArch::nsx86::CLabel L7( CPU.newLabel() );
		nsArch::nsx86::CLabel L8( CPU.newLabel() );
		
		//CPU.int3();

		CPU.push( CPU.reg_ebx() );
		CPU.push( CPU.reg_edi() );

		CPU.xor_( CPU.reg_edi(), CPU.reg_edi() );									//result sign assumed positive
		CPU.mov( CPU.reg_eax(), nsArch::nsx86::CMem( CPU.reg_esp(), 16 ) );			//Hi Word of dividend
		CPU.or_( CPU.reg_eax(), CPU.reg_eax() );									//test to see if signed
		CPU.jge( L1 );																//skip rest if a is already positive

		CPU.inc( CPU.reg_edi() );													//complement result sign flag bit
		CPU.mov( CPU.reg_edx(), nsArch::nsx86::CMem( CPU.reg_esp(), 12 ) );			//Lo Word of dividend
		CPU.neg( CPU.reg_eax() );													//make a positive
		CPU.neg( CPU.reg_edx() );
		CPU.sbb( CPU.reg_eax(), 0 );
		CPU.mov( nsArch::nsx86::CMem( CPU.reg_esp(), 16 ), CPU.reg_eax() );			//save positive value
		CPU.mov( nsArch::nsx86::CMem( CPU.reg_esp(), 12 ), CPU.reg_edx() );

	CPU.bind( L1 );

		CPU.mov( CPU.reg_eax(), nsArch::nsx86::CMem( CPU.reg_esp(), 24 ) );			//hi word of b
		CPU.or_( CPU.reg_eax(), CPU.reg_eax() );									//test to see if signed
		CPU.jge( L2 );																//skip rest if b is already positive
		CPU.mov( CPU.reg_edx(), nsArch::nsx86::CMem( CPU.reg_esp(), 20 ) );			//lo word of b
		CPU.neg( CPU.reg_eax() );													//make b positive
		CPU.neg( CPU.reg_edx() );
		CPU.sbb( CPU.reg_eax(), 0 );
		CPU.mov( nsArch::nsx86::CMem( CPU.reg_esp(), 24 ), CPU.reg_eax() );
		CPU.mov( nsArch::nsx86::CMem( CPU.reg_esp(), 20 ), CPU.reg_edx() );			//save positive value

	CPU.bind( L2 );

		CPU.or_( CPU.reg_eax(), CPU.reg_eax() );									//check to see if divisor < 4194304K
		CPU.jnz( L3 );																//nope, gotta do this the hard way

		CPU.mov( CPU.reg_ecx(), nsArch::nsx86::CMem( CPU.reg_esp(), 20 ) );			//load divisor
		CPU.mov( CPU.reg_eax(), nsArch::nsx86::CMem( CPU.reg_esp(), 16 ) );			//load high word of dividend

		CPU.xor_( CPU.reg_edx(), CPU.reg_edx() );
		CPU.div( CPU.reg_ecx() );													//edx <- remainder

		CPU.mov( CPU.reg_eax(), nsArch::nsx86::CMem( CPU.reg_esp(), 12 ) );			//edx:eax <- remainder:lo word of dividend
		CPU.div( CPU.reg_ecx() );													//edx <- final remainder
		CPU.mov( CPU.reg_eax(), CPU.reg_edx() );									//edx:eax <- remainder
		CPU.xor_( CPU.reg_edx(), CPU.reg_edx() );									
		CPU.dec( CPU.reg_edi() );													//check result sign flag
		CPU.jns( L4 );																//negate result, restore stack and return
		CPU.jmp( L8 );																//result sign ok, restore stack and return

	CPU.bind( L3 );

		CPU.mov( CPU.reg_ebx(), CPU.reg_eax() );									//ebx:ecx <- divisor
		CPU.mov( CPU.reg_ecx(), nsArch::nsx86::CMem( CPU.reg_esp(), 20 ) );			//load low word of divisor
		CPU.mov( CPU.reg_edx(), nsArch::nsx86::CMem( CPU.reg_esp(), 16 ) );			//load high word of dividend
		CPU.mov( CPU.reg_eax(), nsArch::nsx86::CMem( CPU.reg_esp(), 12 ) );			//load low word of dividend

	CPU.bind( L5 );

		CPU.shr( CPU.reg_ebx(), 1 );												//shift divisor right one bit
		CPU.rcr( CPU.reg_ecx(), 1 );
		CPU.shr( CPU.reg_edx(), 1 );												//shift dividend right one bit
		CPU.rcr( CPU.reg_eax(), 1 );
		CPU.or_( CPU.reg_ebx(), CPU.reg_ebx() );
		CPU.jnz( L5 );																//loop until divisor < 4194304K

		CPU.div( CPU.reg_ecx() );													//now divide, ignore remainder

		CPU.mov( CPU.reg_ecx(), CPU.reg_eax() );									//save a copy of quotient in ECX

		CPU.mul( nsArch::nsx86::dword_ptr( CPU.reg_esp(), 24 ) );
		CPU.xchg( CPU.reg_ecx(), CPU.reg_eax() );									//save product, get quotient in EAX
		CPU.mul( nsArch::nsx86::dword_ptr( CPU.reg_esp(), 20 ) );
		CPU.add( CPU.reg_edx(), CPU.reg_ecx() );									//EDX:EAX = QUOT * DVSR
		CPU.jc( L6 );																//carry means Quotient is off by 1

		CPU.cmp( CPU.reg_edx(), nsArch::nsx86::CMem( CPU.reg_esp(), 16 ) );			//compare hi words of result and original
		CPU.ja( L6 );																//if result > original, do subtract
		CPU.jb( L7 );																//if result < original, we are ok
		CPU.cmp( CPU.reg_eax(), nsArch::nsx86::CMem( CPU.reg_esp(), 12 ) );			// hi words are equal, compare lo words
		CPU.jbe( L7 );																//if less or equal we are ok, else subtract

	CPU.bind( L6 );

		CPU.sub( CPU.reg_eax(), nsArch::nsx86::CMem( CPU.reg_esp(), 20 ) );			//subtract divisor from result
		CPU.sbb( CPU.reg_edx(), nsArch::nsx86::CMem( CPU.reg_esp(), 24 ) );

	CPU.bind( L7 );

		CPU.sub( CPU.reg_eax(), nsArch::nsx86::CMem( CPU.reg_esp(), 12 ) );			//subtract dividend from result
		CPU.sbb( CPU.reg_edx(), nsArch::nsx86::CMem( CPU.reg_esp(), 16 ) );

		CPU.dec( CPU.reg_edi() );													//check result sign flag
		CPU.jns( L8 );																//result is ok, restore stack and return

	CPU.bind( L4 );

		CPU.neg( CPU.reg_edx() );													//otherwise, negate the result
		CPU.neg( CPU.reg_eax() );
		CPU.sbb( CPU.reg_edx(), 0 );

	CPU.bind( L8 );

		CPU.pop( CPU.reg_edi() );
		CPU.pop( CPU.reg_ebx() );

		CPU.ret( nsArch::nsx86::CImm( 16 ) );

		// Make JIT function.
		FP fn = reinterpret_cast< FP >( CPU.make() );

		// Ensure that everything is ok and write the launchpad
		if( fn )
		{
			m_bGenerated = true;
			if( m_pLaunchPad )
			{
				HLA.WriteLaunchPad( (byte*)fn, m_pLaunchPad );
			}
		}

		return fn;
	}
예제 #6
0
L00407AF7(
    unsigned int __eax,                    // r0
    signed int __ebx,                      // r1
    signed int __ecx,                      // r2
    signed int __edx,                      // r3
    signed int __edi,                      // r4
    signed int __esi                       // r5
)
{
    unsigned int _t314;                    // _t314
    signed int _t315;                      // _t315
    unsigned int _t316;                    // _t316
    unsigned int _t317;                    // _t317
    _unknown_ _t321;                       // _t321
    _unknown_ _t322;                       // _t322
    _unknown_ _t323;                       // _t323
    _unknown_ _t325;                       // _t325
    signed int _t330;                      // _t330
    signed int _t333;                      // _t333
    _unknown_ _t335;                       // _t335
    signed int _t337;                      // _t337
    signed int _t338;                      // _t338
    signed int _t340;                      // _t340
    signed int _t341;                      // _t341
    signed int _t345;                      // _t345
    signed int _t346;                      // _t346
    signed int _t347;                      // _t347
    signed int _t349;                      // _t349
    _unknown_ _t353;                       // _t353
    _unknown_ _t355;                       // _t355
    _unknown_ _t356;                       // _t356
    _unknown_ _t357;                       // _t357
    _unknown_ _t358;                       // _t358
    _unknown_ _t360;                       // _t360
    _unknown_ _t361;                       // _t361

    _t346 = __esi;
    __edx = __edx;
    _t314 = __eax;
    _t345 = __edi | -711097728 | _t346 | -1673015420;
    asm("rcr al, cl");
    _t337 =  !__ecx;
    _t333 = __ebx & _t337;
    _t338 = _t337 | _t333;
    _push(_t338);
    _push(__esp);
    _push(191);
    if(_t345 != -938470053) {
        _pop(__ecx);
        _t338 =  !_t338;
        _push(_t338);
        L8();
        _pop(__ecx);
        _t315 = 1;
L5:
        _t316 = _t315;
        if(_t353 != 0) {
            _t340 = _t338 - 1 >> 15;
            __eflags = __edx - -528831735;
            if(__edx != -528831735) {
            } else {
                goto L10;
            }
            goto L43;
L10:
            asm("std ");
            _push(ss);
            asm("xchg ebp, eax");
            __esp = __esp + 1;
            asm("cwde ");
            __eflags = _t316 & -755611034;
            goto L11;
        }