fix regression from r4111 in store/restore matrix operations regarding stack size and overflow. also fix regression from other time in the handling of push/pop commands regarding stack size and overflow (fixes sims games and spiderman games). also a bunch of unrelated license cleanup i foolishly mixed in here
This commit is contained in:
parent
d546cd53c5
commit
16dd75b1e4
|
@ -1,22 +1,19 @@
|
||||||
/* Copyright (C) 2006 yopyop
|
/*
|
||||||
yopyop156@ifrance.com
|
Copyright (C) 2006 yopyop
|
||||||
yopyop156.ifrance.com
|
Copyright (C) 2006-2012 DeSmuME team
|
||||||
|
|
||||||
This file is part of DeSmuME
|
This file is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
DeSmuME is free software; you can redistribute it and/or modify
|
This file is distributed in the hope that it will be useful,
|
||||||
it under the terms of the GNU General Public License as published by
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
(at your option) any later version.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
DeSmuME is distributed in the hope that it will be useful,
|
You should have received a copy of the GNU General Public License
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
along with the this software. If not, see <http://www.gnu.org/licenses/>.
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with DeSmuME; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
Copyright (C) 2006 yopyop
|
Copyright (C) 2006 yopyop
|
||||||
Copyright (C) 2007 shash
|
Copyright (C) 2007 shash
|
||||||
Copyright (C) 2007-2011 DeSmuME team
|
Copyright (C) 2007-2012 DeSmuME team
|
||||||
|
|
||||||
This file is free software: you can redistribute it and/or modify
|
This file is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
Copyright (C) 2006 yopyop
|
Copyright (C) 2006 yopyop
|
||||||
Copyright (C) 2007 shash
|
Copyright (C) 2007 shash
|
||||||
Copyright (C) 2007-2011 DeSmuME team
|
Copyright (C) 2007-2012 DeSmuME team
|
||||||
|
|
||||||
This file is free software: you can redistribute it and/or modify
|
This file is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
Copyright (C) 2006 yopyop
|
Copyright (C) 2006 yopyop
|
||||||
Copyright (C) 2008-2011 DeSmuME team
|
Copyright (C) 2008-2012 DeSmuME team
|
||||||
|
|
||||||
This file is free software: you can redistribute it and/or modify
|
This file is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -1,23 +1,20 @@
|
||||||
/*
|
/*
|
||||||
Copyright (C) 2006 yopyop
|
Copyright (C) 2006 yopyop
|
||||||
Copyright (C) 2006-2007 shash
|
Copyright (C) 2006-2007 shash
|
||||||
Copyright (C) 2008-2011 DeSmuME team
|
Copyright (C) 2008-2012 DeSmuME team
|
||||||
|
|
||||||
This file is part of DeSmuME
|
This file is free software: you can redistribute it and/or modify
|
||||||
|
|
||||||
DeSmuME is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
DeSmuME is distributed in the hope that it will be useful,
|
This file is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with DeSmuME; if not, write to the Free Software
|
along with the this software. If not, see <http://www.gnu.org/licenses/>.
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// ARM core TODO:
|
// ARM core TODO:
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
/* Copyright (C) 2006 yopyop
|
/*
|
||||||
Copyright (C) 2009-2010 DeSmuME team
|
Copyright (C) 2006 yopyop
|
||||||
|
Copyright (C) 2009-2012 DeSmuME team
|
||||||
|
|
||||||
This file is free software: you can redistribute it and/or modify
|
This file is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This file is distributed in the hope that it will be useful,
|
This file is distributed in the hope that it will be useful,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
This file is free software: you can redistribute it and/or modify
|
This file is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This file is distributed in the hope that it will be useful,
|
This file is distributed in the hope that it will be useful,
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
/* Copyright (C) 2006 yopyop
|
/*
|
||||||
Copyright (C) 2008-2011 DeSmuME team
|
Copyright (C) 2006 yopyop
|
||||||
|
Copyright (C) 2008-2012 DeSmuME team
|
||||||
|
|
||||||
This file is free software: you can redistribute it and/or modify
|
This file is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This file is distributed in the hope that it will be useful,
|
This file is distributed in the hope that it will be useful,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
This file is free software: you can redistribute it and/or modify
|
This file is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This file is distributed in the hope that it will be useful,
|
This file is distributed in the hope that it will be useful,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
Copyright (C) 2006 yopyop
|
Copyright (C) 2006 yopyop
|
||||||
Copyright (C) 2008-2011 DeSmuME team
|
Copyright (C) 2008-2012 DeSmuME team
|
||||||
|
|
||||||
This file is free software: you can redistribute it and/or modify
|
This file is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -863,9 +863,13 @@ static void gfx3d_glPopMatrix(s32 i)
|
||||||
//this command always works on both pos and vector when either pos or pos-vector are the current mtx mode
|
//this command always works on both pos and vector when either pos or pos-vector are the current mtx mode
|
||||||
short mymode = (mode==1?2:mode);
|
short mymode = (mode==1?2:mode);
|
||||||
|
|
||||||
//6 bits, sign extended
|
|
||||||
//this was necessary to fix sims apartment pets
|
|
||||||
//i = (i<<26)>>26;
|
//i = (i<<26)>>26;
|
||||||
|
//previously, we sign extended here. that isnt really necessary since the stacks are apparently modularly addressed. so i am somewhat doubtful that this is a real concept.
|
||||||
|
//example:
|
||||||
|
//suppose we had a -30 that would be %100010.
|
||||||
|
//which is the same as adding 34. if our stack was at 17 then one way is 17-30(+32)=19 and the other way is 17+34(-32)=19
|
||||||
|
|
||||||
|
//please note that our ability to skip treating this as signed is dependent on the modular addressing later. if that ever changes, we need to change this back.
|
||||||
|
|
||||||
MatrixStackPopMatrix(mtxCurrent[mymode], &mtxStack[mymode], i);
|
MatrixStackPopMatrix(mtxCurrent[mymode], &mtxStack[mymode], i);
|
||||||
|
|
||||||
|
@ -886,8 +890,13 @@ static void gfx3d_glStoreMatrix(u32 v)
|
||||||
v = 0;
|
v = 0;
|
||||||
|
|
||||||
v &= 31;
|
v &= 31;
|
||||||
//this behaviour is unverified. gbatek suggests that it may be meaningful somehow.
|
|
||||||
if(v==31) return;
|
//according to gbatek, 31 works but sets the stack overflow flag
|
||||||
|
//spider-man 2 tests this on the spiderman model (and elsewhere)
|
||||||
|
//i am somewhat skeptical of this, but we'll leave it this way for now.
|
||||||
|
//a test shouldnt be too hard
|
||||||
|
if(v==31)
|
||||||
|
MMU_new.gxstat.se = 1;
|
||||||
|
|
||||||
MatrixStackLoadMatrix (&mtxStack[mymode], v, mtxCurrent[mymode]);
|
MatrixStackLoadMatrix (&mtxStack[mymode], v, mtxCurrent[mymode]);
|
||||||
|
|
||||||
|
@ -909,12 +918,13 @@ static void gfx3d_glRestoreMatrix(u32 v)
|
||||||
|
|
||||||
v &= 31;
|
v &= 31;
|
||||||
|
|
||||||
//this seems to do something irrational if v==31, as far as we know.
|
//according to gbatek, 31 works but sets the stack overflow flag
|
||||||
//lets arbitrarily choose to use entry -
|
//spider-man 2 tests this on the spiderman model (and elsewhere)
|
||||||
if(v==31) {
|
//i am somewhat skeptical of this, but we'll leave it this way for now.
|
||||||
v = 0;
|
//a test shouldnt be too hard
|
||||||
printf("gfx3d_glRestoreMatrix is using -1. why would anyone do this? please report!\n");
|
if(v==31)
|
||||||
}
|
MMU_new.gxstat.se = 1;
|
||||||
|
|
||||||
|
|
||||||
MatrixCopy (mtxCurrent[mymode], MatrixStackGetPos(&mtxStack[mymode], v));
|
MatrixCopy (mtxCurrent[mymode], MatrixStackGetPos(&mtxStack[mymode], v));
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
Copyright (C) 2006-2007 shash
|
Copyright (C) 2006-2007 shash
|
||||||
Copyright (C) 2007-2011 DeSmuME team
|
Copyright (C) 2007-2012 DeSmuME team
|
||||||
|
|
||||||
This file is free software: you can redistribute it and/or modify
|
This file is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -149,19 +149,6 @@ void MatrixInit (float *matrix)
|
||||||
matrix[0] = matrix[5] = matrix[10] = matrix[15] = 1.f;
|
matrix[0] = matrix[5] = matrix[10] = matrix[15] = 1.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MatrixTranspose(s32 *matrix)
|
|
||||||
{
|
|
||||||
float temp;
|
|
||||||
#define swap(A,B) temp = matrix[A];matrix[A] = matrix[B]; matrix[B] = temp;
|
|
||||||
swap(1,4);
|
|
||||||
swap(2,8);
|
|
||||||
swap(3,0xC);
|
|
||||||
swap(6,9);
|
|
||||||
swap(7,0xD);
|
|
||||||
swap(0xB,0xE);
|
|
||||||
#undef swap
|
|
||||||
}
|
|
||||||
|
|
||||||
void MatrixIdentity (s32 *matrix)
|
void MatrixIdentity (s32 *matrix)
|
||||||
{
|
{
|
||||||
matrix[1] = matrix[2] = matrix[3] = matrix[4] = 0;
|
matrix[1] = matrix[2] = matrix[3] = matrix[4] = 0;
|
||||||
|
@ -258,12 +245,10 @@ static void MatrixStackSetStackPosition (MatrixStack *stack, int pos)
|
||||||
if((stack->position < 0) || (stack->position > stack->size))
|
if((stack->position < 0) || (stack->position > stack->size))
|
||||||
MMU_new.gxstat.se = 1;
|
MMU_new.gxstat.se = 1;
|
||||||
|
|
||||||
//this behaviour is unverified, but its more logical than the old code which would wrap around and turn negative
|
//once upon a time, we tried clamping to the size.
|
||||||
//it may still be right to wrap around, but we have no proof right now one way or another
|
//this utterly broke sims 2 apartment pets.
|
||||||
if(stack->position < 0)
|
//changing to wrap around made it work perfectly
|
||||||
stack->position = 0;
|
stack->position = ((u32)stack->position) & stack->size;
|
||||||
if(stack->position > stack->size)
|
|
||||||
stack->position = stack->size;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MatrixStackPushMatrix (MatrixStack *stack, const s32 *ptr)
|
void MatrixStackPushMatrix (MatrixStack *stack, const s32 *ptr)
|
||||||
|
|
|
@ -56,7 +56,6 @@ void MatrixCopy (s32 * matrixDST, const s32 * matrixSRC);
|
||||||
int MatrixCompare (const s32 * matrixDST, const float * matrixSRC);
|
int MatrixCompare (const s32 * matrixDST, const float * matrixSRC);
|
||||||
void MatrixIdentity (s32 *matrix);
|
void MatrixIdentity (s32 *matrix);
|
||||||
|
|
||||||
void MatrixTranspose (s32 *matrix);
|
|
||||||
void MatrixStackInit (MatrixStack *stack);
|
void MatrixStackInit (MatrixStack *stack);
|
||||||
void MatrixStackSetMaxSize (MatrixStack *stack, int size);
|
void MatrixStackSetMaxSize (MatrixStack *stack, int size);
|
||||||
void MatrixStackPushMatrix (MatrixStack *stack, const s32 *ptr);
|
void MatrixStackPushMatrix (MatrixStack *stack, const s32 *ptr);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Copyright (C) 2006 Normmatt
|
Copyright (C) 2006 Normmatt
|
||||||
Copyright (C) 2006 Theo Berkau
|
Copyright (C) 2006 Theo Berkau
|
||||||
Copyright (C) 2007 Pascal Giard
|
Copyright (C) 2007 Pascal Giard
|
||||||
Copyright (C) 2008-2011 DeSmuME team
|
Copyright (C) 2008-2012 DeSmuME team
|
||||||
|
|
||||||
This file is free software: you can redistribute it and/or modify
|
This file is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
This file is free software: you can redistribute it and/or modify
|
This file is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This file is distributed in the hope that it will be useful,
|
This file is distributed in the hope that it will be useful,
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
This file is free software: you can redistribute it and/or modify
|
This file is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This file is distributed in the hope that it will be useful,
|
This file is distributed in the hope that it will be useful,
|
||||||
|
|
Loading…
Reference in New Issue