struct TVert
{
float x,y,z;
float sel;
};
typedef TVert TGrid[32][32];
typedef TGrid *PGrid;
looks simple doesn't it
TVert is 16 bytes long,
TGrid is 1024 TVerts (32 rows of 32 TVerts) should be a nice 16384 bytes
PGrid points to a TGrid
Here is the code from the function
int x; these are only here to show the types
int y;
PGrid Grid; note Grid is pointing to the correct
location by the time
the code below is executed
for (x=0;x<32;x++)
for (y=0;y<32;y++)
{
Grid[x][y]->x=31-Grid[x][y]->x;
Grid[x][y]->y=31-Grid[x][y]->y;
Grid[x][y]->z=31-Grid[x][y]->z;
}
:mad:
It Didn't work, had a major crash , so I traced it and this is what I found
:confused:
This is what it is when compiled
You will notice i have put some comments in to help identify what its doing
x=0 :10012F21 C745EC00000000 mov [ebp-14], 00000000 :10012F28 EB09 jmp 10012F33 x++ :10012F2A 8B45EC mov eax, dword ptr [ebp-14] :10012F2D 83C001 add eax, 00000001 :10012F30 8945EC mov dword ptr [ebp-14], eax x<32 :10012F33 837DEC20 cmp dword ptr [ebp-14], 00000020 :10012F37 0F8DA8000000 jnl 10012FE5 y=0 :10012F3D C745E000000000 mov [ebp-20], 00000000 :10012F44 EB09 jmp 10012F4F y++ :10012F46 8B45E0 mov eax, dword ptr [ebp-20] :10012F49 83C001 add eax, 00000001 :10012F4C 8945E0 mov dword ptr [ebp-20], eax y<32 :10012F4F 837DE020 cmp dword ptr [ebp-20], 00000020 :10012F53 0F8D87000000 jnl 10012FE0 x*16384 :10012F59 8B45EC mov eax, dword ptr [ebp-14] :10012F5C C1E00E shl eax, 0E +grid :10012F5F 034508 add eax, dword ptr [ebp+08] y*512 :10012F62 8B4DE0 mov ecx, dword ptr [ebp-20] :10012F65 C1E109 shl ecx, 09 1-grid[x][y].x :10012F68 D90408 fld dword ptr [eax+ecx] :10012F6B DC2DA0D90110 fsubr qword ptr [1001D9A0] x*16384 :10012F71 8B55EC mov edx, dword ptr [ebp-14] :10012F74 C1E20E shl edx, 0E +grid :10012F77 035508 add edx, dword ptr [ebp+08] y*512 :10012F7A 8B45E0 mov eax, dword ptr [ebp-20] :10012F7D C1E009 shl eax, 09 grid[x][y].x= :10012F80 D91C02 fstp dword ptr [edx+eax] x*16384 :10012F83 8B45EC mov eax, dword ptr [ebp-14] :10012F86 C1E00E shl eax, 0E +grid :10012F89 034508 add eax, dword ptr [ebp+08] y*512 :10012F8C 8B4DE0 mov ecx, dword ptr [ebp-20] :10012F8F C1E109 shl ecx, 09 1-grid[x][y].y // grid[x][y]+4 bytes :10012F92 D9440804 fld dword ptr [eax+ecx+04] :10012F96 DC2DA0D90110 fsubr qword ptr [1001D9A0] x*16384 :10012F9C 8B55EC mov edx, dword ptr [ebp-14] :10012F9F C1E20E shl edx, 0E +grid :10012FA2 035508 add edx, dword ptr [ebp+08] y*512 :10012FA5 8B45E0 mov eax, dword ptr [ebp-20] :10012FA8 C1E009 shl eax, 09 grid[x][y].y= :10012FAB D95C0204 fstp dword ptr [edx+eax+04] x*16384 :10012FAF 8B45EC mov eax, dword ptr [ebp-14] :10012FB2 C1E00E shl eax, 0E +grid :10012FB5 034508 add eax, dword ptr [ebp+08] y*512 :10012FB8 8B4DE0 mov ecx, dword ptr [ebp-20] :10012FBB C1E109 shl ecx, 09 1-grid[x][y].z // grid[x][y]+8 bytes :10012FBE D9440808 fld dword ptr [eax+ecx+08] :10012FC2 DC2DA0D90110 fsubr qword ptr [1001D9A0] x*16384 :10012FC8 8B55EC mov edx, dword ptr [ebp-14] :10012FCB C1E20E shl edx, 0E +grid :10012FCE 035508 add edx, dword ptr [ebp+08] y*512 :10012FD1 8B45E0 mov eax, dword ptr [ebp-20] :10012FD4 C1E009 shl eax, 09 grid[x][y].z= :10012FD7 D95C0208 fstp dword ptr [edx+eax+08] :10012FDB E966FFFFFF jmp 10012F46 :10012FE0 E945FFFFFF jmp 10012F2A
It dosnt take rocket science to see that 512 bytes are being allocated for each 16 byte structure
anyone know how to fix it so the elements of the array are stacked togeather without the extra 496 unused bytes in between
:cursing:


Sign In
Create Account


Back to top









