Path: chuka.playstation.co.uk!news From: "CRAIG GRAHAM" Newsgroups: scee.yaroze.programming.3d_graphics Subject: Re: Move error (with source code) Date: 8 Dec 1997 14:45:01 GMT Organization: Intelligent Research Ltd Lines: 85 Message-ID: <01bd03e8$d9ce16a0$6c0b0a0a@newcastle.twowaytv.co.uk> References: <66gfjf$cel4@chuka.playstation.co.uk> NNTP-Posting-Host: 194.131.235.3 X-Newsreader: Microsoft Internet News 4.70.1161 Provenzano Stefano wrote in article <66gfjf$cel4@chuka.playstation.co.uk>... > Hi all, > Very big problem: > I have a program that move a 3D model around the world; using the arrows I > can rotate the model and than move it in that direction. Sometime occour an > error that stop the running and crash the psx, the error is: > "ThePlayStation has generate an Illegal Instruction exception at instruction > address 0x8002861c". > I have not any idea about this error, what instruction cause it and why. > Can anyone read my souce code and then give me some hints?? > > Thanks in advance. > > Dragon > Here's a sample of Dragon's code, the //++cg: bit's are my comments: ====INCLUDED CODE====== void ruota2 (GsCOORDINATE2 *coord_ogg, SVECTOR *vet_rot , int rx, int ry, int rz ) { MATRIX *matTmp; //++cg: Here we have a pointer to a MATRIX, but it's //++cg: not been initialised to actually point anywhere valid ResetMatrix(coord_ogg->coord.m ); vet_rot->vx = (vet_rot->vx+rx)%ONE; vet_rot->vy = (vet_rot->vy+ry)%ONE; vet_rot->vz = (vet_rot->vz+rz)%ONE; RotMatrix(vet_rot, matTmp); //++cg: Dragon now uses the invalid pointer... MulMatrix0(&coord_ogg->coord, matTmp, &coord_ogg->coord); coord_ogg->flg = 0; } ========================== Spot the problem? The variable matTmp is a pointer to a MATRIX, but it's not actually pointing at a MATRIX, it's pointing at a random place in memory - this is causing corruption of the code, hence the > "ThePlayStation has generate an Illegal Instruction exception at instruction > address 0x8002861c". message Dragon is getting..... Here's the fixed version (only for the one function, his code does this all over the place so it need's a fair bit of fixing): void ruota2 (GsCOORDINATE2 *coord_ogg, SVECTOR *vet_rot , int rx, int ry, int rz ) { MATRIX matTmp; //++cg: This is now a real MATRIX, NOT a pointer ResetMatrix(coord_ogg->coord.m ); vet_rot->vx = (vet_rot->vx+rx)%ONE; vet_rot->vy = (vet_rot->vy+ry)%ONE; vet_rot->vz = (vet_rot->vz+rz)%ONE; RotMatrix(vet_rot, &matTmp); //++cg: Initialise the rotation matrix by getting a pointer to matTMP MulMatrix0(&coord_ogg->coord, &matTmp, &coord_ogg->coord); //++cg: again, get a pointer to matTMP coord_ogg->flg = 0; } Laters, Craig.