mirror of
https://github.com/UberGames/lilium-voyager.git
synced 2024-12-14 14:11:15 +00:00
* Added option to q3asm to instruct it to create qvms compatible with Q3 1.32b
This commit is contained in:
parent
0dc1ed4125
commit
e652200405
2 changed files with 49 additions and 11 deletions
|
@ -176,8 +176,14 @@ int passNumber;
|
||||||
|
|
||||||
int numSymbols;
|
int numSymbols;
|
||||||
int errorCount;
|
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 *symbols;
|
||||||
symbol_t *lastSymbol = 0; /* Most recent symbol defined. */
|
symbol_t *lastSymbol = 0; /* Most recent symbol defined. */
|
||||||
|
@ -227,7 +233,7 @@ int opcodesHash[ NUM_SOURCE_OPS ];
|
||||||
int
|
int
|
||||||
vreport (const char* fmt, va_list vp)
|
vreport (const char* fmt, va_list vp)
|
||||||
{
|
{
|
||||||
if (optionVerbose != qtrue)
|
if (options.verbose != qtrue)
|
||||||
return 0;
|
return 0;
|
||||||
return vprintf(fmt, vp);
|
return vprintf(fmt, vp);
|
||||||
}
|
}
|
||||||
|
@ -1358,6 +1364,7 @@ void WriteVmFile( void ) {
|
||||||
char imageName[MAX_OS_PATH];
|
char imageName[MAX_OS_PATH];
|
||||||
vmHeader_t header;
|
vmHeader_t header;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
int headerSize;
|
||||||
|
|
||||||
report( "%i total errors\n", errorCount );
|
report( "%i total errors\n", errorCount );
|
||||||
|
|
||||||
|
@ -1378,9 +1385,21 @@ void WriteVmFile( void ) {
|
||||||
return;
|
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.instructionCount = instructionCount;
|
||||||
header.codeOffset = sizeof( header );
|
header.codeOffset = headerSize;
|
||||||
header.codeLength = segment[CODESEG].imageUsed;
|
header.codeLength = segment[CODESEG].imageUsed;
|
||||||
header.dataOffset = header.codeOffset + segment[CODESEG].imageUsed;
|
header.dataOffset = header.codeOffset + segment[CODESEG].imageUsed;
|
||||||
header.dataLength = segment[DATASEG].imageUsed;
|
header.dataLength = segment[DATASEG].imageUsed;
|
||||||
|
@ -1392,11 +1411,15 @@ void WriteVmFile( void ) {
|
||||||
|
|
||||||
CreatePath( imageName );
|
CreatePath( imageName );
|
||||||
f = SafeOpenWrite( imageName );
|
f = SafeOpenWrite( imageName );
|
||||||
SafeWrite( f, &header, sizeof( header ) );
|
SafeWrite( f, &header, headerSize );
|
||||||
SafeWrite( f, &segment[CODESEG].image, segment[CODESEG].imageUsed );
|
SafeWrite( f, &segment[CODESEG].image, segment[CODESEG].imageUsed );
|
||||||
SafeWrite( f, &segment[DATASEG].image, segment[DATASEG].imageUsed );
|
SafeWrite( f, &segment[DATASEG].image, segment[DATASEG].imageUsed );
|
||||||
SafeWrite( f, &segment[LITSEG].image, segment[LITSEG].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 );
|
fclose( f );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1460,7 +1483,7 @@ void Assemble( void ) {
|
||||||
WriteVmFile();
|
WriteVmFile();
|
||||||
|
|
||||||
// write the map file even if there were errors
|
// write the map file even if there were errors
|
||||||
if( optionWriteMapFile ) {
|
if( options.writeMapFile ) {
|
||||||
WriteMapFile();
|
WriteMapFile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1519,6 +1542,7 @@ Assemble LCC bytecode assembly to Q3VM bytecode.\n\
|
||||||
-f LISTFILE Read options and list of files to assemble from LISTFILE\n\
|
-f LISTFILE Read options and list of files to assemble from LISTFILE\n\
|
||||||
-b BUCKETS Set symbol hash table to BUCKETS buckets\n\
|
-b BUCKETS Set symbol hash table to BUCKETS buckets\n\
|
||||||
-v Verbose compilation report\n\
|
-v Verbose compilation report\n\
|
||||||
|
-vq3 Produce a qvm file compatible with Q3 1.32b\n\
|
||||||
", argv[0]);
|
", argv[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1566,12 +1590,17 @@ By default (no -v option), q3asm remains silent except for critical errors.
|
||||||
Verbosity turns on all messages, error or not.
|
Verbosity turns on all messages, error or not.
|
||||||
Motivation: not wanting to scrollback for pages to find asm error.
|
Motivation: not wanting to scrollback for pages to find asm error.
|
||||||
*/
|
*/
|
||||||
optionVerbose = qtrue;
|
options.verbose = qtrue;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !strcmp( argv[ i ], "-m" ) ) {
|
if( !strcmp( argv[ i ], "-m" ) ) {
|
||||||
optionWriteMapFile = qtrue;
|
options.writeMapFile = qtrue;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !strcmp( argv[ i ], "-vq3" ) ) {
|
||||||
|
options.vanillaQ3Compatibility = qtrue;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1592,7 +1621,7 @@ Motivation: not wanting to scrollback for pages to find asm error.
|
||||||
|
|
||||||
for ( i = 0, s = symbols ; s ; s = s->next, i++ ) /* nop */ ;
|
for ( i = 0, s = symbols ; s ; s = s->next, i++ ) /* nop */ ;
|
||||||
|
|
||||||
if (optionVerbose)
|
if (options.verbose)
|
||||||
{
|
{
|
||||||
report("%d symbols defined\n", i);
|
report("%d symbols defined\n", i);
|
||||||
hashtable_stats(symtable);
|
hashtable_stats(symtable);
|
||||||
|
|
|
@ -110,3 +110,12 @@ follows:
|
||||||
7. Steal underpants
|
7. Steal underpants
|
||||||
8. ???
|
8. ???
|
||||||
9. Profit!
|
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.
|
||||||
|
|
Loading…
Reference in a new issue