Bug 3026 - PowerPC q3asm doesn't produce usable QVM files
Status: RESOLVED FIXED
Alias: None
Product: ioquake3
Classification: Unclassified
Component: Misc
Version: unspecified
Hardware: Macintosh MacOS X
: P2 trivial
Assignee: Zachary J. Slater
QA Contact: ioquake3 bugzilla mailing list
URL:
: 3381
Depends on:
Blocks:
 
Reported: 2007-02-13 03:08 EST by scriptythekid
Modified: 2007-10-13 08:06:08 EDT
1 user (show)

See Also:


Attachments
includepath and directories fixed (576 bytes, patch)
2007-02-13 06:04 EST, scriptythekid

Description scriptythekid 2007-02-13 03:08:47 EST
code/game/game.sh
/game cyberloode$ ./game.sh 
cpp: ../../qcommon/q_shared.h:110 ../g_local.h:25 ../g_main.c:24 Could not find include file "q_platform.h"

q_math.c & q_shared.c are missing in dir game.

use tools:
http://www.netwolf.free.fr/mac-qvmtools/

solution:
add -I../../qcommon to the q3lcc statement in game.sh
copy q_math.c & q_shared.c to dir game before compiling


ps: hey first bug report in my life, sure as hell sux...
Comment 1 scriptythekid 2007-02-13 06:04:40 EST
Created attachment 1262 [details]
includepath and directories fixed

added inlcudeDir qcommon to the q3lcc command
changed 2 file locations in the script
  from code/game/q_math.c to code/qcommon/q_math.c
  same for q_shared.c
Comment 2 Ryan C. Gordon 2007-05-21 11:22:28 EDT
Setting a QA contact on all ioquake3 bugs, even resolved ones. Sorry if you get a flood of email from this, it should only happen once. Apologies for the incovenience.

--ryan.

Comment 3 Tim Angus 2007-08-23 11:37:58 EDT
The QVMs are built as part of the normal build process, no external tools are necessary. Tony says that the ppc QVM compiler doesn't work, so it's better to fix this than bring in patches to external tools.

Perhaps you could determine what is fixed by the tools here http://www.netwolf.free.fr/mac-qvmtools/ and create a patch that merges the changes back to ioq3. Contact the author(s) I guess.
Comment 4 Tony J. White 2007-10-09 09:56:53 EDT
*** Bug 3381 has been marked as a duplicate of this bug. ***
Comment 5 doomagent13 2007-10-10 19:57:36 EDT
Do we know which part of the qvm compilation process causes the problem?  Is it the '.c' to '.asm', or the '.asm's to '.qvm'?  (Or is the quake3 qvm process significantly different from the trem process?)
Comment 6 Tim Angus 2007-10-11 05:22:04 EDT
Chances are it's q3asm. My first suspicion would be the file writes not dealing with endianness. Failing that, writing non-packed structs to file may be causing problems. It's easy enough to debug, just compare a valid QVM with the broken one and find where they differ.
Comment 7 doomagent13 2007-10-11 07:08:33 EDT
Here is a comparison: (game.qvm is Lakitu's, vm/game.qvm is my compilation of it using the appropriate svn and his patch) NOTE:  It looked a little different in terminal.

diff -a game.qvm vm/game.qvm
1c1
? ErC?$P?t??H$??P=x             ( 
                &
---
? rE?C$???tH??$?Pdx             ( 
                &
3399c3399
< ***g_actionPrefixg_allowActionsg_allowShareg_rankingsg_dretchPuntmaing_tagg_devmapKillerHPg_antiSpawnBlockg_minLevelToSpecMM1g_publicSayadminsg_myStatsg_privateMessagesg_minLevelToJoinTeam120g_adminTempBang_adminNameProtectg_adminSayFilterg_adminParseSayadmin.logg_adminLogadmin.datg_adming_layoutAutog_layoutsg_mapConfigsLoadedg_mapConfigs15g_shoveg_initialMapRotationg_currentMap-1g_currentMapRotationg_debugMapRotationg_deconDeadg_markDeconstruct2000g_floodMinTime5000g_floodMaxDemeritsg_chatTeamPrefixg_disabledBuildablesg_disabledClassesg_disabledEquipmentg_unlaggedg_teamImbalanceWarningsg_alienStage3Thresholdg_alienStage2Thresholdg_alienMaxStageg_alienKillsg_alienStage40g_humanStage3Thresholdg_humanStage2Thresholdg_humanMaxStageg_humanKillsg_humanStageg_alienBuildPoints100g_humanBuildPointspmove_msecpmove_fixedg_clientUpgradeNoticeg_smoothClientsNewbie#g_newbieNamePrefixg_newbieNumberingg_maxNameChangesg_minNameChangePeriod500g_minCommandPeriodg_listEntityg_designateVotes50g_mapVotesPercent75g_suddenDeathVotePercentg_voteLimitg_allowVote70g_podiumDrop80g_podiumDistcom_bloodg_motdg_debugAllocg_debugDamageg_debugMoveg_inactivity20g_forcerespawng_weaponTeamRespawn5g_weaponrespawn3g_quadfactor1000g_knockback800g_gravity320g_speeddedicatedg_needpassg_filterBang_banIPsg_passwordg_logFileSyncgames.logg_logFileg_doWarmup10g_warmupg_teamForceBalanceg_teamAutoJoing_devmapNoStructDmgg_devmapNoGod1g_friendlyFireMovementAttacksg_friendlyBuildableFireg_retributiong_friendlyFireHumansg_friendlyFireAliensg_friendlyFireg_synchronousClientsg_suddenDeath2g_suddenDeathMode30g_suddenDeathTime45timelimitg_maxGameClients8sv_maxclientsffPsv_mapnameg_lockTeamsAtStart0g_restartedAug 23 2007gamedatebasegamenamesv_cheats%x%x%08x%08xg_disabledBuildablesg_disabledClassesg_disabledEquipmentg_alienStage^3WARNING: unknown buildable %s
---
> ***g_actionPrefixg_allowActionsg_allowShareg_rankingsg_dretchPuntmaing_tagg_devmapKillerHPg_antiSpawnBlockg_minLevelToSpecMM1g_publicSayadminsg_myStatsg_privateMessagesg_minLevelToJoinTeam120g_adminTempBang_adminNameProtectg_adminSayFilterg_adminParseSayadmin.logg_adminLogadmin.datg_adming_layoutAutog_layoutsg_mapConfigsLoadedg_mapConfigs15g_shoveg_initialMapRotationg_currentMap-1g_currentMapRotationg_debugMapRotationg_deconDeadg_markDeconstruct2000g_floodMinTime5000g_floodMaxDemeritsg_chatTeamPrefixg_disabledBuildablesg_disabledClassesg_disabledEquipmentg_unlaggedg_teamImbalanceWarningsg_alienStage3Thresholdg_alienStage2Thresholdg_alienMaxStageg_alienKillsg_alienStage40g_humanStage3Thresholdg_humanStage2Thresholdg_humanMaxStageg_humanKillsg_humanStageg_alienBuildPoints100g_humanBuildPointspmove_msecpmove_fixedg_clientUpgradeNoticeg_smoothClientsNewbie#g_newbieNamePrefixg_newbieNumberingg_maxNameChangesg_minNameChangePeriod500g_minCommandPeriodg_listEntityg_designateVotes50g_mapVotesPercent75g_suddenDeathVotePercentg_voteLimitg_allowVote70g_podiumDrop80g_podiumDistcom_bloodg_motdg_debugAllocg_debugDamageg_debugMoveg_inactivity20g_forcerespawng_weaponTeamRespawn5g_weaponrespawn3g_quadfactor1000g_knockback800g_gravity320g_speeddedicatedg_needpassg_filterBang_banIPsg_passwordg_logFileSyncgames.logg_logFileg_doWarmup10g_warmupg_teamForceBalanceg_teamAutoJoing_devmapNoStructDmgg_devmapNoGod1g_friendlyFireMovementAttacksg_friendlyBuildableFireg_retributiong_friendlyFireHumansg_friendlyFireAliensg_friendlyFireg_synchronousClientsg_suddenDeath2g_suddenDeathMode30g_suddenDeathTime45timelimitg_maxGameClients8sv_maxclientsffPsv_mapnameg_lockTeamsAtStart0g_restartedOct  9 2007gamedatebasegamenamesv_cheats%x%x%08x%08xg_disabledBuildablesg_disabledClassesg_disabledEquipmentg_alienStage^3WARNING: unknown buildable %s
Comment 8 Tim Angus 2007-10-11 07:23:29 EDT
Based on that I'd say endianness is definitely a problem. You could try the following hacky patch:

Index: code/tools/asm/q3asm.c
===================================================================
--- code/tools/asm/q3asm.c      (revision 1193)
+++ code/tools/asm/q3asm.c      (working copy)
@@ -527,10 +527,10 @@
        if ( seg->imageUsed >= MAX_IMAGE - 4) {
                Error( "MAX_IMAGE" );
        }
-       seg->image[ seg->imageUsed ] = v & 255;
-       seg->image[ seg->imageUsed + 1 ] = ( v >> 8 ) & 255;
-       seg->image[ seg->imageUsed + 2 ] = ( v >> 16 ) & 255;
-       seg->image[ seg->imageUsed + 3 ] = ( v >> 24 ) & 255;
+       seg->image[ seg->imageUsed + 3 ] = v & 255;
+       seg->image[ seg->imageUsed + 2 ] = ( v >> 8 ) & 255;
+       seg->image[ seg->imageUsed + 1 ] = ( v >> 16 ) & 255;
+       seg->image[ seg->imageUsed + 0 ] = ( v >> 24 ) & 255;
        seg->imageUsed += 4;
 }
Comment 9 doomagent13 2007-10-11 23:04:00 EDT
Didnt fix it--the comparison churns out pretty much the whole of both files now.
Comment 10 Tim Angus 2007-10-12 05:21:09 EDT
Could you paste the output of the following (*without* applying the patch):

xxd valid_game.qvm > valid_game.qvm.txt
xxd ppc_game.qvm > ppc_game.qvm.txt
diff -u valid_game.qvm.txt ppc_game.qvm.txt

Thanks.
Comment 11 Tim Angus 2007-10-12 15:17:52 EDT
bugzilla-daemon@icculus.org wrote:
> http://bugzilla.icculus.org/show_bug.cgi?id=3026

[I don't have my bugzilla credentials here, so PM]

This should fix it:

Index: code/tools/asm/q3asm.c
===================================================================
--- code/tools/asm/q3asm.c	(Revision 1193)
+++ code/tools/asm/q3asm.c	(Arbeitskopie)
@@ -1356,6 +1356,7 @@
 	vmHeader_t	header;
 	FILE	*f;
 	int		headerSize;
+	int i;
 
 	report( "%i total errors\n", errorCount );
 
@@ -1400,6 +1401,11 @@
 
 	report( "Writing to %s\n", imageName );
 
+	// byte swap the header
+	for ( i = 0 ; i < sizeof( vmHeader_t ) / 4 ; i++ ) {
+		((int *)&header)[i] = LittleLong( ((int *)&header)[i] );
+	}
+
 	CreatePath( imageName );
 	f = SafeOpenWrite( imageName );
 	SafeWrite( f, &header, headerSize );

cu
Ludwig

-- 
 (o_   Ludwig Nussel
 //\   
 V_/_  http://www.suse.de/
SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg)
Comment 12 doomagent13 2007-10-12 22:36:07 EDT
diff -u good_game.qvm.txt ppc_game.qvm.txt
--- good_game.qvm.txt   2007-10-12 22:15:29.000000000 -0400
+++ ppc_game.qvm.txt    2007-10-12 22:17:13.000000000 -0400
@@ -1,6 +1,6 @@
-0000000: 4514 7212 43a7 0200 2400 0000 50e3 0700  E.r.C...$...P...
-0000010: 74e3 0700 b448 0000 24c6 0000 6450 3d01  t....H..$...dP=.
-0000020: 7810 0000 0320 0000 0009 1400 0000 0928  x.... .........(
+0000000: 1272 1445 0002 a743 0000 0024 0007 e350  .r.E...C...$...P
+0000010: 0007 e374 0000 48b4 0000 c624 013d 5064  ...t..H....$.=Pd
+0000020: 0000 1078 0320 0000 0009 1400 0000 0928  ...x. .........(
 0000030: 0000 001d 2009 1400 0000 1d08 0000 0000  .... ...........
 0000040: 0d83 0000 0009 1400 0000 1d08 0900 0000  ................
 0000050: 0f83 0000 0009 1400 0000 1d08 0200 0000  ................
@@ -33677,7 +33677,7 @@
 00838c0: 6600 5000 7376 5f6d 6170 6e61 6d65 0067  f.P.sv_mapname.g
 00838d0: 5f6c 6f63 6b54 6561 6d73 4174 5374 6172  _lockTeamsAtStar
 00838e0: 7400 3000 675f 7265 7374 6172 7465 6400  t.0.g_restarted.
-00838f0: 4175 6720 3233 2032 3030 3700 6761 6d65  Aug 23 2007.game
+00838f0: 4f63 7420 3131 2032 3030 3700 6761 6d65  Oct 11 2007.game
 0083900: 6461 7465 0062 6173 6500 6761 6d65 6e61  date.base.gamena
 0083910: 6d65 0000 7376 5f63 6865 6174 7300 0000  me..sv_cheats...
 0083920: 2578 2578 0025 3038 7825 3038 7800 675f  %x%x.%08x%08x.g_

That patch FIXED the problem!!!
THANK YOU!!!

By the way, here is the diff for the working qvm:
diff -u good_game.qvm.txt ppc_test_game.qvm.txt
--- good_game.qvm.txt   2007-10-12 22:15:29.000000000 -0400
+++ ppc_test_game.qvm.txt       2007-10-12 22:23:49.000000000 -0400
@@ -33677,7 +33677,7 @@
 00838c0: 6600 5000 7376 5f6d 6170 6e61 6d65 0067  f.P.sv_mapname.g
 00838d0: 5f6c 6f63 6b54 6561 6d73 4174 5374 6172  _lockTeamsAtStar
 00838e0: 7400 3000 675f 7265 7374 6172 7465 6400  t.0.g_restarted.
-00838f0: 4175 6720 3233 2032 3030 3700 6761 6d65  Aug 23 2007.game
+00838f0: 4f63 7420 3131 2032 3030 3700 6761 6d65  Oct 11 2007.game
 0083900: 6461 7465 0062 6173 6500 6761 6d65 6e61  date.base.gamena
 0083910: 6d65 0000 7376 5f63 6865 6174 7300 0000  me..sv_cheats...
 0083920: 2578 2578 0025 3038 7825 3038 7800 675f  %x%x.%08x%08x.g_

I guess you should clean this up. (I have NO idea how to do so.)

(In reply to comment #10)
> Could you paste the output of the following (*without* applying the patch):
> 
> xxd valid_game.qvm > valid_game.qvm.txt
> xxd ppc_game.qvm > ppc_game.qvm.txt
> diff -u valid_game.qvm.txt ppc_game.qvm.txt
> 
> Thanks.
> 

Comment 13 Tim Angus 2007-10-13 08:06:08 EDT
In theory, this should be fixed by r1197. If not, reopen.