Exemplo n.º 1
0
void env_test(void)
{

    TK_DeInit();
    TK_Init(TK_CTL1_SEN_SEL_16BIT);

    TK_EnableInterrupt(TK_INT_ALL);
    CLS;
    while(1) {
        TK_Device2PC();
    }

}
Exemplo n.º 2
0
Arquivo: acc.c Projeto: Edward850/acc
static void Init(void)
{
	short endianTest = 1;

	if (*(char *)&endianTest)
		acs_BigEndianHost = NO;
	else
		acs_BigEndianHost = YES;
	acs_VerboseMode = YES;
	acs_DebugMode = NO;
	acs_DebugFile = NULL;
	TK_Init();
	SY_Init();
	STR_Init();
	ProcessArgs();
	MS_Message(MSG_NORMAL, "Host byte order: %s endian\n",
		acs_BigEndianHost ? "BIG" : "LITTLE");
}
Exemplo n.º 3
0
/*
==============
main
==============
*/
int main (int argc, char **argv)
{
	int			i;
	char		path[1024];
	char		*basedir;
	double		starttime, endtime;

	printf ("Qdata Plus : "__TIME__" "__DATE__"\n");

	starttime = I_FloatTime();
	basedir = NULL;

	TK_Init();
	ExpandWildcards (&argc, &argv);

	for (i=1 ; i<argc ; i++)
	{
		if (!strcmp(argv[i], "-archive"))
		{
			// -archive f:/quake2/release/dump_11_30
			archive = true;
			strcpy (archivedir, argv[i+1]);
			printf ("Archiving source to: %s\n", archivedir);
			i++;
		}
		else if (!strcmp(argv[i], "-release"))
		{
			g_release = true;
			strcpy (g_releasedir, argv[i+1]);
			printf ("Copy output to: %s\n", g_releasedir);
			i++;
		}
		else if (!strcmp(argv[i], "-base"))
		{
			i++;
			basedir = argv[i];
		}
		else if (!strcmp(argv[i], "-compress"))
		{
			g_compress_pak = true;
			printf ("Compressing pakfile\n");
		}
		else if (!strcmp(argv[i], "-pak"))
		{
			g_release = true;
			g_pak = true;
			printf ("Building pakfile: %s\n", argv[i+1]);
			BeginPak (argv[i+1]);
			i++;
		}
		else if (!strcmp(argv[i], "-only"))
		{
			strcpy (g_only, argv[i+1]);
			printf ("Only grabbing %s\n", g_only);
			i++;
		}
		else if (!strcmpi(argv[i], "-keypress"))
		{
			g_dokeypress = true;
		}
		else if (!strcmp(argv[i], "-3ds"))
		{
			do3ds = true;
			printf ("loading .3ds files\n");
		}
		else if (!strcmp(argv[i], "-materialfile"))
		{
			strcpy(g_materialFile, argv[i+1]);
			printf("Setting material file to %s\n", g_materialFile);
			i++;
		}
/*		else if (!strcmpi(argv[i], "-newgen"))
		{
			if (i < argc-4)
			{
				printf("run new triangle grouping routine here\n");
				NewGen(argv[i+1],argv[i+2],atoi(argv[i+3]),atoi(argv[i+4]));
			}
			else
			{
				printf("qdata -newskin <base.hrc> <skin.pcx> width height\n");
			}
			return 0;
		}
*/		else if (!strcmpi(argv[i], "-genskin"))
		{
			i++;
			if (i < argc-3)
			{
				GenSkin(argv[i],argv[i+1],atol(argv[i+2]),atol(argv[i+3]));
			}
			else
			{
				printf("qdata -genskin <base.hrc> <skin.pcx> <desired width> <desired height>\n");
			}
			return 0;
			
		}
		else if (!strcmpi(argv[i], "-noopts"))
		{
			g_no_opimizations = true;
			printf("not performing optimizations\n");
		}
		else if (!strcmpi(argv[i], "-md2"))
		{
			g_forcemodel = MODEL_MD2;
		}
		else if (!strcmpi(argv[i], "-fm"))
		{
			g_forcemodel = MODEL_FM;
		}
		else if (!strcmpi(argv[i], "-verbose"))
		{
			g_verbose = true;
		}
		else if (!strcmpi(argv[i], "-oldskin"))
		{
			g_allow_newskin = false;
		}
		else if (!strcmpi(argv[i], "-ignoreUV"))
		{
			g_ignoreTriUV = true;
		}
		else if (!strcmpi(argv[i], "-publish"))
		{
			g_publishOutput = true;
		}
		else if (!strcmpi(argv[i], "-nomkdir"))
		{
			g_nomkdir = true;
		}
		else if (argv[i][0] == '-')
			Error ("Unknown option \"%s\"", argv[i]);
		else
			break;
	}

	if (i >= argc)
	{
		Error ("usage: qdata [-archive <directory>]\n"
			"             [-release <directory>]\n"
			"             [-base <directory>]\n"
			"             [-compress]\n"
			"             [-pak <file>]\n"
			"             [-only <model>]\n"
			"             [-keypress]\n"
			"             [-3ds]\n"
			"             [-materialfile <file>]\n"
			"             [-noopts]\n"
			"             [-md2]\n"
			"             [-fm]\n"
			"             [-verbose]\n"
			"             [-ignoreUV]\n"
			"             [-oldskin]\n"
			"             [-publish]\n"
			"             [-nomkdir]\n"
			"             file.qdt\n"
			"or\n"
			"       qdata -genskin <base.hrc> <skin.pcx> <desired width> <desired height>");
	}

	if (do3ds)
		trifileext = ext_3ds;
	else
		trifileext = ext_tri;

	for ( ; i<argc ; i++)
	{
		printf ("--------------- %s ---------------\n", argv[i]);
		// load the script
		strcpy (path, argv[i]);
		DefaultExtension (path, ".qdt");
		DefaultExtension(g_materialFile, ".mat");
		SetQdirFromPath (path);

		printf("workingdir='%s'\n", gamedir);
		if (basedir)
		{
			qdir[0] = 0;
			g_outputDir = basedir;
		}

		printf("outputdir='%s'\n", g_outputDir);

		QFile_ReadMaterialTypes(g_materialFile);
		LoadScriptFile (ExpandArg(path));
		
		//
		// parse it
		//
		ParseScript ();

		// write out the last model
		FinishModel ();
		FMFinishModel ();
		FinishSprite ();
	}

	if (total_textures)
	{
		printf("\n");
		printf("Total textures processed: %d\n",total_textures);
		printf("Average size: %d x %d\n",total_x / total_textures, total_y / total_textures);
	}

	if (g_pak)
		FinishPak ();

	endtime = I_FloatTime();
	printf("Time elapsed:  %f\n", endtime-starttime);
	
	if (g_dokeypress)
	{
		printf("Success! ... Hit a key: ");
		getchar();
	}

	return 0;
}
Exemplo n.º 4
0
static void LoadHTR(char *fileName, triangle_t **triList, int *triangleCount)
{
	int		i, j;
	int		vertexCount;
	int		vertexNum;
	struct vList_s
	{
		float v[3];
	} *vList;
	int		triCount;
	float	origin[3];
	triangle_t	*tList;
	float	x, y, z;
	float	x2, y2, z2;
	float	rx, ry, rz;

	TK_Init();
	TK_OpenSource(fileName);

	TK_Beyond(TK_C_HEXEN);
	TK_Beyond(TK_C_TRIANGLES);
	TK_BeyondRequire(TK_C_VERSION, TK_INTNUMBER);
	if (tk_IntNumber != 1)
	{
		COM_Error("Unsupported version (%d) in file %s\n", tk_IntNumber,
							InputFileName);
	}

	// Get vertex count
	TK_BeyondRequire(TK_VERTICES, TK_INTNUMBER);
	vertexCount = tk_IntNumber;
	vList = (struct vList_s *) SafeMalloc(vertexCount * sizeof(vList[0]));

	// Get triangle count
	TK_BeyondRequire(TK_FACES, TK_INTNUMBER);
	triCount = tk_IntNumber;
	if (triCount >= MAXTRIANGLES)
	{
		COM_Error("Too many triangles in file %s\n", InputFileName);
	}
	*triangleCount = triCount;
	tList = (triangle_t *) SafeMalloc(MAXTRIANGLES * sizeof(triangle_t));
	*triList = tList;

	// Get origin
	TK_Beyond(TK_ORIGIN);
	TK_Require(TK_FLOATNUMBER);
	origin[0] = tk_FloatNumber;
	TK_FetchRequire(TK_FLOATNUMBER);
	origin[1] = tk_FloatNumber;
	TK_FetchRequire(TK_FLOATNUMBER);
	origin[2] = tk_FloatNumber;

	//rx = 90.0/360.0*2.0*MY_PI;
	rx =(float)(FixHTRRotateX/360.0*2.0*MY_PI);
	ry =(float)(FixHTRRotateY/360.0*2.0*MY_PI);
	rz =(float)(FixHTRRotateZ/360.0*2.0*MY_PI);

	// Get vertex list
	for (i = 0; i < vertexCount; i++)
	{
		TK_FetchRequire(TK_VERTEX);
		TK_FetchRequire(TK_FLOATNUMBER);
		x = tk_FloatNumber-origin[0];
		TK_FetchRequire(TK_FLOATNUMBER);
		y = tk_FloatNumber-origin[1];
		TK_FetchRequire(TK_FLOATNUMBER);
		z = tk_FloatNumber-origin[2];

		x += FixHTRTranslateX;
		y += FixHTRTranslateY;
		z += FixHTRTranslateZ;

		y2 = (float)(y*cos(rx)-z*sin(rx));
		z2 = (float)(y*sin(rx)+z*cos(rx));
		y = y2;
		z = z2;
		x2 = (float)(x*cos(ry)+z*sin(ry));
		z2 = (float)(-x*sin(ry)+z*cos(ry));
		x = x2;
		z = z2;
		x2 = (float)(x*cos(rz)-y*sin(rz));
		y2 = (float)(x*sin(rz)+y*cos(rz));
		x = x2;
		y = y2;

		vList[i].v[0] = x;
		vList[i].v[1] = y;
		vList[i].v[2] = z;
	}

	// Get face list
	for (i = 0; i < triCount; i++)
	{
		TK_FetchRequire(TK_FACE);
		TK_FetchRequire(TK_LPAREN);
		for (j = 0; j < 3; j++)
		{
			TK_FetchRequire(TK_INTNUMBER);
			vertexNum = tk_IntNumber-1;
			if (vertexNum >= vertexCount)
			{
				COM_Error("File '%s', line %d:\nVertex number"
					" >= vertexCount: %d\n", tk_SourceName, tk_Line,
					tk_IntNumber);
			}
			tList[i].verts[2-j][0] = vList[vertexNum].v[0];
			tList[i].verts[2-j][1] = vList[vertexNum].v[1];
			tList[i].verts[2-j][2] = vList[vertexNum].v[2];
		}
		TK_FetchRequire(TK_RPAREN);

/*		printf("Face %i:\n  v0: %f, %f, %f\n  v1: %f, %f, %f\n"
			"  v2: %f, %f, %f\n", i,
			tList[i].verts[0][0],
			tList[i].verts[0][1],
			tList[i].verts[0][2],
			tList[i].verts[1][0],
			tList[i].verts[1][1],
			tList[i].verts[1][2],
			tList[i].verts[2][0],
			tList[i].verts[2][1],
			tList[i].verts[2][2]);
*/
	}
}
Exemplo n.º 5
0
static void LoadASC(char *fileName, triangle_t **triList, int *triangleCount)
{
	int		i, j;
	int		vertexCount;
	struct vList_s
	{
		float v[3];
	} *vList;
	int		triCount;
	triangle_t	*tList;
	float	x, y, z;
//	float	x2, y2, z2;
//	float	rx, ry, rz;
	qboolean goodObject;

	TK_Init();
	TK_OpenSource(fileName);

	goodObject = false;
	while (goodObject == false)
	{
		TK_Beyond(TK_C_NAMED);
		TK_Beyond(TK_OBJECT);
		TK_Beyond(TK_C_TRI);
		TK_Beyond(TK_MESH);
		TK_BeyondRequire(TK_C_VERTICES, TK_COLON);
		TK_FetchRequire(TK_INTNUMBER);
		vertexCount = tk_IntNumber;
		if (vertexCount > 0)
		{
			goodObject = true;
		}
	}
	TK_BeyondRequire(TK_C_FACES, TK_COLON);
	TK_FetchRequire(TK_INTNUMBER);
	triCount = tk_IntNumber;
	if (triCount >= MAXTRIANGLES)
	{
		COM_Error("Too many triangles in file %s\n", InputFileName);
	}
	*triangleCount = triCount;
	tList = (triangle_t *) SafeMalloc(MAXTRIANGLES * sizeof(triangle_t));
	*triList = tList;
	TK_BeyondRequire(TK_C_VERTEX, TK_LIST);

/*	rx = ((rotation[0]+90.0)/360.0)*2.0*MY_PI;
	//rx = (rotation[0]/360.0)*2.0*MY_PI;
	ry = (rotation[1]/360.0)*2.0*MY_PI;
	rz = (rotation[2]/360.0)*2.0*MY_PI;
*/
	vList = (struct vList_s *) SafeMalloc(vertexCount * sizeof(vList[0]));
	for (i = 0; i < vertexCount; i++)
	{
		TK_BeyondRequire(TK_C_VERTEX, TK_INTNUMBER);
		if (tk_IntNumber != i)
		{
			COM_Error("File '%s', line %d:\nVertex index mismatch.\n",
						tk_SourceName, tk_Line);
		}
		TK_FetchRequireFetch(TK_COLON);

		TK_BeyondRequire(TK_COLON, TK_FLOATNUMBER);
		x = tk_FloatNumber;
		TK_BeyondRequire(TK_COLON, TK_FLOATNUMBER);
		y = tk_FloatNumber;
		TK_BeyondRequire(TK_COLON, TK_FLOATNUMBER);
		z = tk_FloatNumber;

/*		x2 = x*cos(rz)+y*sin(rz);
		y2 = -x*sin(rz)+y*cos(rz);
		x = x2;
		y = y2;
		y2 = y*cos(rx)+z*sin(rx);
		z2 = -y*sin(rx)+z*cos(rx);
		y = y2;
		z = z2;
		x2 = x*cos(ry)-z*sin(ry);
		z2 = x*sin(ry)+z*cos(ry);
		x = x2;
		z = z2;
*/
		vList[i].v[0] = x;
		vList[i].v[1] = y;
		vList[i].v[2] = z;
	}
	TK_BeyondRequire(TK_C_FACE, TK_LIST);
	for (i = 0; i < triCount; i++)
	{
		TK_BeyondRequire(TK_C_FACE, TK_INTNUMBER);
		if (tk_IntNumber != i)
		{
			COM_Error("File '%s', line %d:\nTriangle index mismatch.\n",
						tk_SourceName, tk_Line);
		}
		for (j = 0; j < 3; j++)
		{
			TK_BeyondRequire(TK_IDENTIFIER, TK_COLON);
			TK_FetchRequire(TK_INTNUMBER);
			if (tk_IntNumber >= vertexCount)
			{
				COM_Error("File '%s', line %d:\nVertex number"
					" > vertexCount: %d\n", tk_SourceName, tk_Line,
					tk_IntNumber);
			}
			tList[i].verts[2-j][0] = vList[tk_IntNumber].v[0];
			tList[i].verts[2-j][1] = vList[tk_IntNumber].v[1];
			tList[i].verts[2-j][2] = vList[tk_IntNumber].v[2];
		}

/*		printf("Face %i:\n  v0: %f, %f, %f\n  v1: %f, %f, %f\n"
			"  v2: %f, %f, %f\n", i,
			tList[i].verts[0][0],
			tList[i].verts[0][1],
			tList[i].verts[0][2],
			tList[i].verts[1][0],
			tList[i].verts[1][1],
			tList[i].verts[1][2],
			tList[i].verts[2][0],
			tList[i].verts[2][1],
			tList[i].verts[2][2]);
*/
	}
}
Exemplo n.º 6
0
static void LoadHRC(char *fileName, triangle_t **triList, int *triangleCount)
{
	int		i, j;
	int		vertexCount;
	struct vList_s
	{
		float v[3];
	} *vList;
	int		triCount;
	triangle_t	*tList;
	float	scaling[3];
	float	rotation[3];
	float	translation[3];
	float	x, y, z;
	float	x2, y2, z2;
	float	rx, ry, rz;

	TK_Init();
	TK_OpenSource(fileName);
	TK_FetchRequire(TK_HRCH);
	TK_FetchRequire(TK_COLON);
	TK_FetchRequire(TK_SOFTIMAGE);
	TK_Beyond(TK_MODEL);
	TK_Beyond(TK_SCALING);
	for (i = 0; i < 3; i++)
	{
		TK_Require(TK_FLOATNUMBER);
		scaling[i] = tk_FloatNumber;
		TK_Fetch();
	}
	TK_Beyond(TK_ROTATION);
	for (i = 0; i < 3; i++)
	{
		TK_Require(TK_FLOATNUMBER);
		rotation[i] = tk_FloatNumber;
		TK_Fetch();
	}
	TK_Beyond(TK_TRANSLATION);
	for (i = 0; i < 3; i++)
	{
		TK_Require(TK_FLOATNUMBER);
		translation[i] = tk_FloatNumber;
		TK_Fetch();
	}

	rx = (float)(((rotation[0]-90.0)/360.0)*2.0*MY_PI);
	ry = (float)((rotation[1]/360.0)*2.0*MY_PI);
	rz = (float)((rotation[2]/360.0)*2.0*MY_PI);

	TK_Beyond(TK_MESH);
	TK_BeyondRequire(TK_VERTICES, TK_INTNUMBER);
	vertexCount = tk_IntNumber;
	vList = (struct vList_s *) SafeMalloc(vertexCount * sizeof(vList[0]));
	for (i = 0; i < vertexCount; i++)
	{
		TK_BeyondRequire(TK_LBRACKET, TK_INTNUMBER);
		if (tk_IntNumber != i)
		{
			COM_Error("File '%s', line %d:\nVertex index mismatch.\n",
						tk_SourceName, tk_Line);
		}
		TK_Beyond(TK_POSITION);
		// Apply the scaling, rotation, and translation in the order
		// specified in the HRC file.  This could be wrong.
		TK_Require(TK_FLOATNUMBER);
		x = tk_FloatNumber*scaling[0];
		TK_FetchRequire(TK_FLOATNUMBER);
		y = tk_FloatNumber*scaling[1];
		TK_FetchRequire(TK_FLOATNUMBER);
		z = tk_FloatNumber*scaling[2];

		y2 = (float)(y*cos(rx)+z*sin(rx));
		z2 = (float)(-y*sin(rx)+z*cos(rx));
		y = y2;
		z = z2;

		x2 = (float)(x*cos(ry)-z*sin(ry));
		z2 = (float)(x*sin(ry)+z*cos(ry));
		x = x2;
		z = z2;

		x2 = (float)(x*cos(rz)+y*sin(rz));
		y2 = (float)(-x*sin(rz)+y*cos(rz));
		x = x2;
		y = y2;

		vList[i].v[0] = x+translation[0];
		vList[i].v[1] = y+translation[1];
		vList[i].v[2] = z+translation[2];
	}
	TK_BeyondRequire(TK_POLYGONS, TK_INTNUMBER);
	triCount = tk_IntNumber;
	if (triCount >= MAXTRIANGLES)
	{
		COM_Error("Too many triangles in file %s\n", InputFileName);
	}
	*triangleCount = triCount;
	tList = (triangle_t *) SafeMalloc(MAXTRIANGLES * sizeof(triangle_t));
	*triList = tList;
	for (i = 0; i < triCount; i++)
	{
		TK_BeyondRequire(TK_LBRACKET, TK_INTNUMBER);
		if (tk_IntNumber != i)
		{
			COM_Error("File '%s', line %d:\nTriangle index mismatch.\n",
						tk_SourceName, tk_Line);
		}
		TK_BeyondRequire(TK_NODES, TK_INTNUMBER);
		if (tk_IntNumber != 3)
		{
			COM_Error("File '%s', line %d:\nBad polygon vertex count: %d.",
					tk_SourceName, tk_Line, tk_IntNumber);
		}
		for (j = 0; j < 3; j++)
		{
			TK_BeyondRequire(TK_LBRACKET, TK_INTNUMBER);
			if (tk_IntNumber != j)
			{
				COM_Error("File '%s', line %d:\nTriangle vertex index"
					" mismatch.  %d should be %d\n", tk_SourceName, tk_Line,
					tk_IntNumber, j);
			}
			TK_BeyondRequire(TK_VERTEX, TK_INTNUMBER);
			tList[i].verts[2-j][0] = vList[tk_IntNumber].v[0];
			tList[i].verts[2-j][1] = vList[tk_IntNumber].v[1];
			tList[i].verts[2-j][2] = vList[tk_IntNumber].v[2];
		}

/*		printf("Face %i:\n  v0: %f, %f, %f\n  v1: %f, %f, %f\n"
			"  v2: %f, %f, %f\n", i,
			tList[i].verts[0][0],
			tList[i].verts[0][1],
			tList[i].verts[0][2],
			tList[i].verts[1][0],
			tList[i].verts[1][1],
			tList[i].verts[1][2],
			tList[i].verts[2][0],
			tList[i].verts[2][1],
			tList[i].verts[2][2]);
*/
	}
}