i think you are confusing what my exact problem is Samurai , for one thing I -HAVE- to be able to patch back in the original index number.... it's a game data-editor, and thats how that bit of original data is stored. currently i read the index number, and turn it back to coordinates to be able to "read" the data into the map viewer... the editor will have to patch any changed index numbers back in, before re-saving the original memory block as the game exe.
the "max" values for each floor are already stored into memory when the data block is read, so it should be possible to calculate any numbers needed pretty fast. (level sizes are contained in the map-header)
its not that i'm particularly trying to save memory / be efficient .... the problem is that counting through index numbers uniquely until they "hit" the location i am after is... well... bad coding!
there has to be a more effiective way of doing it, that doesnt take AMOS 30 odd sconds just to find one number.
for example, running it would look something like this:
input (level 3, x 10 y 20)
level=0 : counter=0
not target level : counter=counter+ map(0,x size) * map(0,y size) : inc level
level=1
not target level : counter=counter+ map(1,x size) * map(1,y size) : inc level
level=2
not target level : counter=counter+ map(2,x size) * map(2,y size) : inc level
level =3
target level
counter=counter+target Y * width
counter=counter+target x
index number=counter
im not sure.... but i think this would be how it would run, but of course, not how it would be coded