r163 - in trunk: . code/tools/asm

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sat Oct 15 21:13:51 EDT 2005


Author: tma
Date: 2005-10-15 21:13:51 -0400 (Sat, 15 Oct 2005)
New Revision: 163

Modified:
   trunk/code/tools/asm/q3asm.c
   trunk/i_o-q3-readme
Log:
* Added option to q3asm to instruct it to create qvms compatible with Q3 1.32b


Modified: trunk/code/tools/asm/q3asm.c
===================================================================
--- trunk/code/tools/asm/q3asm.c	2005-10-14 23:02:57 UTC (rev 162)
+++ trunk/code/tools/asm/q3asm.c	2005-10-16 01:13:51 UTC (rev 163)
@@ -176,9 +176,15 @@
 
 int		numSymbols;
 int		errorCount;
-qboolean  optionVerbose = qfalse;
-qboolean  optionWriteMapFile = qfalse;
 
+typedef struct options_s {
+	qboolean verbose;
+	qboolean writeMapFile;
+	qboolean vanillaQ3Compatibility;
+} options_t;
+
+options_t options = { 0 };
+
 symbol_t	*symbols;
 symbol_t	*lastSymbol = 0;  /* Most recent symbol defined. */
 
@@ -227,7 +233,7 @@
 int
 vreport (const char* fmt, va_list vp)
 {
-  if (optionVerbose != qtrue)
+  if (options.verbose != qtrue)
       return 0;
   return vprintf(fmt, vp);
 }
@@ -1358,6 +1364,7 @@
 	char	imageName[MAX_OS_PATH];
 	vmHeader_t	header;
 	FILE	*f;
+	int		headerSize;
 
 	report( "%i total errors\n", errorCount );
 
@@ -1378,9 +1385,21 @@
 		return;
 	}
 
-	header.vmMagic = VM_MAGIC_VER2;
+	if( !options.vanillaQ3Compatibility ) {
+		header.vmMagic = VM_MAGIC_VER2;
+		headerSize = sizeof( header );
+	} else {
+		header.vmMagic = VM_MAGIC;
+
+		// Don't write the VM_MAGIC_VER2 bits when maintaining 1.32b compatibility.
+		// (I know this isn't strictly correct due to padding, but then platforms
+		// that pad wouldn't be able to write a correct header anyway).  Note: if
+		// vmHeader_t changes, this needs to be adjusted too.
+		headerSize = sizeof( header ) - sizeof( header.jtrgLength );
+	}
+
 	header.instructionCount = instructionCount;
-	header.codeOffset = sizeof( header );
+	header.codeOffset = headerSize;
 	header.codeLength = segment[CODESEG].imageUsed;
 	header.dataOffset = header.codeOffset + segment[CODESEG].imageUsed;
 	header.dataLength = segment[DATASEG].imageUsed;
@@ -1392,11 +1411,15 @@
 
 	CreatePath( imageName );
 	f = SafeOpenWrite( imageName );
-	SafeWrite( f, &header, sizeof( header ) );
+	SafeWrite( f, &header, headerSize );
 	SafeWrite( f, &segment[CODESEG].image, segment[CODESEG].imageUsed );
 	SafeWrite( f, &segment[DATASEG].image, segment[DATASEG].imageUsed );
 	SafeWrite( f, &segment[LITSEG].image, segment[LITSEG].imageUsed );
-	SafeWrite( f, &segment[JTRGSEG].image, segment[JTRGSEG].imageUsed );
+
+	if( !options.vanillaQ3Compatibility ) {
+		SafeWrite( f, &segment[JTRGSEG].image, segment[JTRGSEG].imageUsed );
+	}
+
 	fclose( f );
 }
 
@@ -1460,7 +1483,7 @@
 	WriteVmFile();
 
 	// write the map file even if there were errors
-	if( optionWriteMapFile ) {
+	if( options.writeMapFile ) {
 		WriteMapFile();
 	}
 }
@@ -1519,6 +1542,7 @@
     -f LISTFILE    Read options and list of files to assemble from LISTFILE\n\
     -b BUCKETS     Set symbol hash table to BUCKETS buckets\n\
     -v             Verbose compilation report\n\
+    -vq3           Produce a qvm file compatible with Q3 1.32b\n\
 ", argv[0]);
 	}
 
@@ -1566,15 +1590,20 @@
 Verbosity turns on all messages, error or not.
 Motivation: not wanting to scrollback for pages to find asm error.
 */
-			optionVerbose = qtrue;
+			options.verbose = qtrue;
 			continue;
 		}
 
 		if( !strcmp( argv[ i ], "-m" ) ) {
-			optionWriteMapFile = qtrue;
+			options.writeMapFile = qtrue;
 			continue;
 		}
 
+		if( !strcmp( argv[ i ], "-vq3" ) ) {
+			options.vanillaQ3Compatibility = qtrue;
+			continue;
+		}
+
 		Error( "Unknown option: %s", argv[i] );
 	}
 
@@ -1592,7 +1621,7 @@
 
 		for ( i = 0, s = symbols ; s ; s = s->next, i++ ) /* nop */ ;
 
-		if (optionVerbose)
+		if (options.verbose)
 		{
 			report("%d symbols defined\n", i);
 			hashtable_stats(symtable);

Modified: trunk/i_o-q3-readme
===================================================================
--- trunk/i_o-q3-readme	2005-10-14 23:02:57 UTC (rev 162)
+++ trunk/i_o-q3-readme	2005-10-16 01:13:51 UTC (rev 163)
@@ -110,3 +110,12 @@
 7. Steal underpants
 8. ???
 9. Profit!
+
+Creating mods compatible with Q3 1.32b
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+If you're using this package to create mods for the last official release of
+Q3, it is necessary to pass the commandline option '-vq3' to your invocation
+of q3asm. This is because by default q3asm outputs an updated qvm format that
+is necessary to fix a bug involving the optimising pass of the x86 vm JIT
+compiler. See http://www.quakesrc.org/forums/viewtopic.php?t=5665 (if it still
+exists when you read this) for more details.




More information about the quake3-commits mailing list