Exemplo n.º 1
0
static void opCMPF(void)
{
	float val1=u2f(GETREG(GET1));
	float val2=u2f(GETREG(GET2));
	SET_OV(0);
	SET_CY((val2<val1)?1:0);
	val2-=val1;
	SET_Z((val2==0.0)?1:0);
	SET_S((val2<0.0)?1:0);
}
Exemplo n.º 2
0
static void opMULF(void)
{
	//TODO: CY
	float val1=u2f(GETREG(GET1));
	float val2=u2f(GETREG(GET2));
	SET_OV(0);
	val2*=val1;
	SET_Z((val2==0.0)?1:0);
	SET_S((val2<0.0)?1:0);
	SETREG(GET2,f2u(val2));
}
static void
tstmul (unsigned int ux, unsigned int uy, unsigned int ur)
{
	float x = u2f (ux);
	float y = u2f (uy);

	if (f2u (x * y) != ur)
	/* Set a variable rather than aborting here, to simplify tracing when
	   several computations are wrong.  */
		ok = 0;
}
Exemplo n.º 4
0
static void opDIVF(void)
{
	//TODO: CY
	float val1=u2f(GETREG(GET1));
	float val2=u2f(GETREG(GET2));
	SET_OV(0);
	if(val1!=0)
		val2/=val1;
	SET_Z((val2==0.0)?1:0);
	SET_S((val2<0.0)?1:0);
	SETREG(GET2,f2u(val2));
}
Exemplo n.º 5
0
void show_float(unsigned uf)
{
  float f = u2f(uf);
  unsigned exp = get_exp(uf);
  unsigned frac = get_frac(uf);
  unsigned sign = get_sign(uf);

  printf("\nFloating point value %.10g\n", f);
  printf("Bit Representation 0x%.8x, sign = %x, exponent = 0x%.2x, fraction = 0x%.6x\n",
	 uf, sign, exp, frac);
  if (exp == EXP_MASK) {
    if (frac == 0) {
      printf("%cInfinity\n", sign ? '-' : '+');
    } else
      printf("Not-A-Number\n");
  } else {
    int denorm = (exp == 0);
    int uexp = denorm ? 1-BIAS : exp - BIAS;
    int mantissa = denorm ? frac : frac + (1<<FRAC_SIZE);
    float fman = (float) mantissa / (float) (1<<FRAC_SIZE);
    printf("%s.  %c%.10f X 2^(%d)\n",
	   denorm ? "Denormalized" : "Normalized",
	   sign ? '-' : '+',
	   fman, uexp);
  }
}
Exemplo n.º 6
0
float fpwr2(int x) {
	/* Result exponent and fraction */
	unsigned exp, frac;
	unsigned u;

	if (x <  -149) { // -23 + (-126) = -149
		/* Too small. Return 0.0 */
		exp = 0;
		frac = 0;
	} else if (x < -126) { // 1 - 127
		/* Denormalized result */
		exp = 0;
		frac = 1 << (149 + x);
	} else if (x < 	128){ // 254 - 127
		/* Normalized result. */
		exp = x + 127;
		frac = 0; // M = 1 + f = 1 + 0 = 1
	} else {
		/* Too big. Return +oo */
		exp = 255;
		frac = 0;
	}
	/* Pack exp and frac into 32 bits */
	u = exp << 23 | frac;
	/* Return as float */
	return u2f(u);
}
Exemplo n.º 7
0
float fpw2(int x)
{
	/*  Result exponent and fraction */
	unsigned exp, frac;
	unsigned u;
	if (x < -149) {
		/* Too small. Return 0.0 */
		exp = 0;
		frac = 0;
	//	printf("1*__  %d\r\n", x);
	} else if (x < -126){
		/* Denormalized result */
		exp = 0;
		frac = 1 << ( 149 + x);
		//printf("2*__  %d\r\n", x);
	} else if ( x < 129) {
		/*  Normalized result */
		exp = x + 127;
		frac = 0;
		///printf("3*__  %d\r\n", x);
	} else {
		/* Too big. Return +oo */
		exp = 255;
		frac = 0;
	}
	
	/* Pack exp and frac into 32 bits */
	u = exp << 23 | frac;
	/* Return as float */
	return u2f(u);
}
Exemplo n.º 8
0
int opCMPF(void)
{
	float appf;

	F2DecodeFirstOperand(ReadAM, 2);
	F2DecodeSecondOperand(ReadAM, 2);

	appf = u2f(f2Op2) - u2f(f2Op1);

	_Z = (appf == 0);
	_S = (appf < 0);
	_OV = 0;
	_CY = 0;

	F2END();
}
Exemplo n.º 9
0
static UINT32 opCMPF(v60_state *cpustate)
{
	float appf;

	F2DecodeFirstOperand(cpustate, ReadAM, 2);
	F2DecodeSecondOperand(cpustate, ReadAM, 2);

	appf = u2f(cpustate->op2) - u2f(cpustate->op1);

	cpustate->_Z = (appf == 0);
	cpustate->_S = (appf < 0);
	cpustate->_OV = 0;
	cpustate->_CY = 0;

	F2END(cpustate);
}
unsigned test_float_neg(unsigned uf) {
    float f = u2f(uf);
    float nf = -f;
    if (isnan(f))
 return uf;
    else
 return f2u(nf);
}
Exemplo n.º 11
0
unsigned test_float_twice(unsigned uf) {
  float f = u2f(uf);
  float tf = 2*f;
  if (isnan(f))
    return uf;
  else
    return f2u(tf);
}
unsigned test_float_half_denorm(unsigned uf) {
  float f = u2f(uf);
  float hf = 0.5*f;
  if(uf&0x7f800000)
    return uf;
  else
    return f2u(hf);
}
Exemplo n.º 13
0
static void opCVTS(void)
{
	float val1=u2f(GETREG(GET1));
	SET_OV(0);
	SET_Z((val1==0.0)?1:0);
	SET_S((val1<0.0)?1:0);
	SETREG(GET2,(INT32)val1);
}
Exemplo n.º 14
0
unsigned test_float_times64(unsigned uf) {
  float f = u2f(uf);
  float tenf = 64*f;
  if (isnan(f))
    return uf;
  else
    return f2u(tenf);
}
Exemplo n.º 15
0
unsigned test_float_half(unsigned uf) {
  float f = u2f(uf);
  float hf = 0.5*f;
  if (isnan(f))
    return uf;
  else
    return f2u(hf);
}
unsigned test_float_times_four(unsigned uf) {
  float f = u2f(uf);
  float tf = 4*f;
  if (isnan(f))
    return uf;
  else
    return f2u(tf);
}
int test_float_exp(unsigned uf) {
float f = u2f(uf);
 int exp = (uf&0x7f800000) >> 23;
if(!isfinite(f))
  return 0x7fffffff;
if(exp == 0)
  exp++;
return exp - 127;
}
Exemplo n.º 18
0
unsigned test_float_abs(unsigned uf) {
  float f = u2f(uf);
  unsigned unf = f2u(-f);
  if (isnan(f))
    return uf;
  /* An unfortunate hack to get around a limitation of the BDD Checker */
  if ((int) uf < 0)
      return unf;
  else
      return uf;
}
Exemplo n.º 19
0
static UINT32 opNEGFS(v60_state *cpustate)
{
	float appf;

	F2DecodeFirstOperand(cpustate, ReadAM, 2);
	F2DecodeSecondOperand(cpustate, ReadAMAddress, 2);

	appf = -u2f(cpustate->op1);

	cpustate->_OV = 0;
	cpustate->_CY = (appf < 0.0f);
	cpustate->_S = ((f2u(appf) & 0x80000000) != 0);
	cpustate->_Z = (appf == 0.0f);

	F2STOREOPFLOAT(cpustate, 2);
	F2END(cpustate)
}
Exemplo n.º 20
0
int opNEGFS(void)
{
	float appf;

	F2DecodeFirstOperand(ReadAM, 2);
	F2DecodeSecondOperand(ReadAMAddress, 2);

	appf = -u2f(f2Op1);

	_OV=0;
	_CY=(appf < 0.0f);
	_S=((f2u(appf) & 0x80000000)!=0);
	_Z=(appf == 0.0f);

	F2STOREOPFLOAT(2);
	F2END()
}
Exemplo n.º 21
0
static UINT32 opCVTSW(v60_state *cpustate)
{
	float val;

	F2DecodeFirstOperand(cpustate, ReadAM, 2);

	// Convert to UINT32
	val = u2f(cpustate->op1);
	cpustate->modwritevalw = (UINT32)val;

	cpustate->_OV = 0;
	cpustate->_CY =(val < 0.0f);
	cpustate->_S = ((cpustate->modwritevalw & 0x80000000) != 0);
	cpustate->_Z = (val == 0.0f);

	F2WriteSecondOperand(cpustate, 2);
	F2END(cpustate);
}
Exemplo n.º 22
0
int opCVTSW(void)
{
	float val;

	F2DecodeFirstOperand(ReadAM,2);

	// Convert to UINT32
	val = u2f(f2Op1);
	modWriteValW = (UINT32)val;

	_OV=0;
	_CY=(val < 0.0f);
	_S=((modWriteValW & 0x80000000)!=0);
	_Z=(val == 0.0f);

	F2WriteSecondOperand(2);
	F2END();
}
Exemplo n.º 23
0
float fpwr2(int x){
    unsigned exp, frac;
    unsigned u;
    if(x < -149){
        exp = 0;
        frac = 0;
    }else if(x < -126){
        exp = 0;
        frac = 1 << (23+(x+126));
    }else if(x < 127){
        exp = 127 + x;
        frac = 0;
    }else{
        exp = 0xFF;
        frac = 0;
    }

    u = exp << 23 | frac;
    return u2f(u);
}
Exemplo n.º 24
0
static UINT32 opDIVFS(v60_state *cpustate)
{
	UINT32 appw;
	float appf;

	F2DecodeFirstOperand(cpustate, ReadAM, 2);
	F2DecodeSecondOperand(cpustate, ReadAMAddress, 2);

	F2LOADOPFLOAT(cpustate, 2);

	appf /= u2f(cpustate->op1);

	appw = f2u(appf);
	cpustate->_OV = cpustate->_CY = 0;
	cpustate->_S = ((appw & 0x80000000) != 0);
	cpustate->_Z = (appw == 0);

	F2STOREOPFLOAT(cpustate, 2);
	F2END(cpustate)
}
Exemplo n.º 25
0
int opDIVFS(void)
{
	UINT32 appw;
	float appf;

	F2DecodeFirstOperand(ReadAM, 2);
	F2DecodeSecondOperand(ReadAMAddress, 2);

	F2LOADOPFLOAT(2);

	appf *= u2f(f2Op1);

	appw = f2u(appf);
	_OV = _CY = 0;
	_S = ((appw & 0x80000000)!=0);
	_Z = (appw == 0);

	F2STOREOPFLOAT(2);
	F2END()
}
Exemplo n.º 26
0
int test_float_f2i(unsigned uf) {
  float f = u2f(uf);
  int x = (int) f;
  return x;
}
Exemplo n.º 27
0
static float readf(const UINT16 *adr)
{
    return u2f(readi(adr));
}
Exemplo n.º 28
0
void rollext_renderer::process_display_list(uint32_t* disp_ram)
{
	const rectangle& visarea = screen().visible_area();

	render_delegate rd = render_delegate(&rollext_renderer::render_texture_scan, this);

	int num = disp_ram[0xffffc/4];

	for (int i=0; i < num; i++)
	{
		int ii = i * 0x60;

		vertex_t vert[4];

		//int x[4];
		//int y[4];

		// Poly data:
		// Word 0:   xxxxxxxx -------- -------- --------   Command? 0xFC for quads
		//           -------- -------- xxxxxxxx --------   Palette?
		//           -------- -------- -------- xxxxxxxx   Number of verts? (4 for quads)

		// Word 1:   xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx   Vertex 1 X

		// Word 2:   xxxxxxxx xxxxx--- -------- --------   Texture Origin Bottom
		//           -------- -----xxx xxxxxxxx --------   Texture Origin Left

		// Word 3:   xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx   Vertex 1 Y

		// Word 4:   -------- -------- xxxxxxxx xxxxxxxx   ?

		// Word 5:   xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx   Vertex 2 X

		// Word 6:   xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx   Unknown float

		// Word 7:   xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx   Vertex 2 Y

		// Word 8:   -------- -------- -------- --------   ?

		// Word 9:   xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx   Vertex 3 X

		// Word 10:  -------- -------- -------- --------   ?

		// Word 11:  xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx   Vertex 3 Y

		// Word 12:  -------- -------- -------- --------   ?

		// Word 13:  xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx   Vertex 4 X

		// Word 14:  -------- -------- -------- --------   ?

		// Word 15:  xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx   Vertex 4 Y

		// Word 16:  xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx   Unknown float

		// Word 17:  -------- -------- -------- --------   ?

		// Word 18:  xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx   Unknown float

		// Word 19:  -------- -------- -------- --------   ?

		// Word 20:  xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx   Unknown float

		// Word 21:  -------- -------- -------- --------   ?

		// Word 22:  xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx   Unknown float

		// Word 23:  -------- -------- -------- --------   ?

		for (int j=0; j < 4; j++)
		{
			uint32_t ix = disp_ram[(ii + (j*0x10) + 0x4) / 4];
			uint32_t iy = disp_ram[(ii + (j*0x10) + 0xc) / 4];

			vert[j].x = (int)((u2f(ix) / 2.0f) + 256.0f);
			vert[j].y = (int)((u2f(iy) / 2.0f) + 192.0f);
		}

		vert[0].p[0] = 0.0f;        vert[0].p[1] = 1.0f;
		vert[1].p[0] = 0.0f;        vert[1].p[1] = 0.0f;
		vert[2].p[0] = 1.0f;        vert[2].p[1] = 0.0f;
		vert[3].p[0] = 1.0f;        vert[3].p[1] = 1.0f;

		rollext_polydata &extra = object_data_alloc();

		extra.tex_bottom = (disp_ram[(ii + 8) / 4] >> 19) & 0x1fff;
		extra.tex_left = (disp_ram[(ii + 8) / 4] >> 8) & 0x7ff;
		extra.pal = (disp_ram[(ii + 0) / 4] >> 8) & 0x1f;

#if 0
		printf("P%d\n", i);
		for (int j=0; j < 6; j++)
		{
			printf("   %08X %08X %08X %08X", disp_ram[(ii + (j*0x10) + 0) / 4], disp_ram[(ii + (j*0x10) + 4) / 4], disp_ram[(ii + (j*0x10) + 8) / 4], disp_ram[(ii + (j*0x10) + 12) / 4]);
			printf("   %f %f %f %f\n", u2f(disp_ram[(ii + (j*0x10) + 0) / 4]), u2f(disp_ram[(ii + (j*0x10) + 4) / 4]), u2f(disp_ram[(ii + (j*0x10) + 8) / 4]), u2f(disp_ram[(ii + (j*0x10) + 12) / 4]));
		}
#endif

		render_triangle(visarea, rd, 4, vert[0], vert[1], vert[2]);
		render_triangle(visarea, rd, 4, vert[0], vert[2], vert[3]);

	}

	wait();
}
Exemplo n.º 29
0
float model1_state::readf(int adr) const
{
	return u2f(readi(adr));
}