Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


2D array or 3D array

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Discussions
View previous topic :: View next topic  
Author Message
OldCheatEngineUser
Whateven rank
Reputation: 3

Joined: 01 Feb 2016
Posts: 338

PostPosted: Mon Jul 10, 2017 12:27 am    Post subject: 2D array or 3D array Reply with quote

how would two dimensional array would be in assembly.
or more.

EDIT:
who can write a small program with 5x5 (5d array).

and assign random values to these boxes or whatever they called technically.

and when we click on a box the value changes randomly.
anyone interested in this?


also since i talked about dimensional arrays.
why not making a new value type with a table to set address of the value for a game that use dimensional arrays.


it would be great feature. (and it must appear as columns and rows).

_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
patched cheat engine tutorials
Back to top
View user's profile Send private message
FreeER
Expert Cheater
Reputation: 9

Joined: 09 Aug 2013
Posts: 233

PostPosted: Mon Jul 10, 2017 10:46 pm    Post subject: Reply with quote

int x[n][m] with index x[i][j] translates to int x[i*n + j] and of course in bytes that translates to address of x + i*sizeof(int)*n + j*sizeof(int) or x+i*4*n + j*4, something like lea eax, [eax + ebx*4 + ecx] (not sure if that's entirely valid but).

the reason is that memory is flat so if you take a grid like this

Code:

    12345
00- XXXXX
05- XXXXX
10- XXXXX
15- XXXXX
20- XXXXX


and just stick them end to end

00- XXXXX 05- XXXXX 10- XXXXX 15- XXXXX 20- XXXXX

to move 1 row you have to move 5 Xs in memory. To move i rows you have to move i*5 Xs in memory, and to move i rows with n elements per row you have to move i*n Xs. To then select a particular x in the row (aka column) you just have to move by individual Xs, hence the +j. The same applies to higher dimensions, x[n][m][o] for x[i][j][k] is x[i*n*m + j*m + k].
Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 3

Joined: 01 Feb 2016
Posts: 338

PostPosted: Tue Jul 11, 2017 3:23 am    Post subject: Reply with quote

thank you free...

good example, even tho its a lil bit complicated to me.

and I didn't get everything.

but one thing here, you said size.of(int) so addresses will be 4 bytes in memory.
then why in your example its 5bytes?

BTW I don't understand multi dimensional arrays (technically I mean)
they are different than normal array

_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
patched cheat engine tutorials
Back to top
View user's profile Send private message
FreeER
Expert Cheater
Reputation: 9

Joined: 09 Aug 2013
Posts: 233

PostPosted: Tue Jul 11, 2017 9:33 am    Post subject: Reply with quote

OldCheatEngineUser wrote:
but one thing here, you said size.of(int) so addresses will be 4 bytes in memory.
then why in your example its 5bytes?
The Xs weren't meant to represent bytes but elements, and the numbers 1-5, 5,10,etc. were meant to represent the 1 dimensional indices (the 2D indices are pretty easy to see/count for a small 5x5) Smile

OldCheatEngineUser wrote:
BTW I don't understand multi dimensional arrays (technically I mean)
they are different than normal array
except that they're really not. They are, mostly, pointers to a chunk of memory numElements*sizeof(element) in size. The only difference is whether you have "syntactic sugar" to let you access it in terms of multiple-dimensions.

https://www.cse.msu.edu/~cse251/lecture11.pdf seems to provide good info on the subject
Back to top
View user's profile Send private message
OldCheatEngineUser
Whateven rank
Reputation: 3

Joined: 01 Feb 2016
Posts: 338

PostPosted: Tue Jul 11, 2017 11:34 am    Post subject: Reply with quote

FreeER wrote:
https://www.cse.msu.edu/~cse251/lecture11.pdf seems to provide good info on the subject

pretty much good info.
thank you.
ill try the examples of dimensional array. (and debug the example.)

also there is a good subject too, which is pointers to arrays.
this is also a good thing to learn.

_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
patched cheat engine tutorials
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Discussions All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites