Re: Coordinates to world map location
Quote:
Originally Posted by Vash
Well the world map, excluding the area with walls, is 64x64 slots. We're trying to edit the individual slot you're standing on, not the entire acre (16x16).
no .. i mean .. the world map has 16 tiles with each tiles has 16 x 16 slot .. so it is
(16 * 16) * 16
256 * 16
4096 and since map is a perfect square that would makes it 64x64
but in RAM it was distributed by tile and not by 64x64 .. so meaning row 1 to 16 and column 1 to 16 or TIle 1 uses the addresses 0x21E3124 to 0x21E3322 while row 1 to 16 and column 17 to 32 or the Tile 2 use the addresses 0x21E3324 to 0x21E3522 .. so meaning tile 6 or row 17 to 32 and column 17 to 32 is using 0x21E3b24 to 0x21E3d22
and then above situation where it is in row 64 and column 2 meaning it was under the tile 13
http://toenailed.game-hackers.com/images/tile13.PNG
anyway my solution .. is to calculate where tile you are and calculate on what slot you are on that tile .. ill post it later .. i just need to shorten it a bit ..
Re: Coordinates to world map location
Nice job toe, mind sending me the source when your done?
Re: Coordinates to world map location
Ah yes, I understand. The addresses don't go in order properly. Well I hope you get it working. It will be one epic code haha.
Re: Coordinates to world map location
"Amateur Coding"
As soon as people see this post, they will say, " :o ! This is Amateur coding!?" and run away.
:lol:
Re: Coordinates to world map location
lol... I was thinking the same thing..
Re: Coordinates to world map location
anyway im still lazy so ill just give the idea
Code:
[TileNo] = ((((([rowSlot]+16)-1)/16)-1)*4) + ((([columnSlot]+16)-1)/16)
[TileNo] = (((((64+16)-1)/16)-1)*4) + (((2+16)-1)/16)
[TileNo] = (((((80)-1)/16)-1)*4) + (((18)-1)/16)
[TileNo] = (((79/16)-1)*4) + (17/16)
[TileNo] = ((4-1)*4) + 1
[TileNo] = (3*4) + 1
[TileNo] = 12 + 1
[TileNo] = 13
Code:
[SlotNo] = ((([rowSlot] - ((([rowSlot]-1)/16)*16))-1)*16) + ([columnSlot] - ((([columnSlot]-1)/16)*16))
[SlotNo] = (((64 - ((64-1/16)*16))-1)*16) + ((2 - (((2-1)/16)*16))
[SlotNo] = (((64 - ((63/16)*16))-1)*16) + (2 - ((1/16)*16))
[SlotNo] = (((64 - ((3)*16))-1)*16) + (2 - (0*16))
[SlotNo] = (((64 - 48)-1)*16) + (2 - 0)
[SlotNo] = (((16-1)*16) + 2
[SlotNo] = ((15 * 16) + 2
[SlotNo] = ((15 * 16) + 2
[SlotNo] = 240 + 2
[SlotNo] = 242
Code:
[FinalAddress] = ((([TileNo]-1) * 256) + ([SlotNo]-1))*2) + 0x021E3124
[FinalAddress] = (((13-1) * 256) + (242-1)*2) + 0x021E3124
[FinalAddress] = ((12 * 256) + 241)*2) + 0x021E3124
[FinalAddress] = (3072 + 241)*2) + 0x021E3124
[FinalAddress] = (3313*2) + 0x021E3124
[FinalAddress] = 0x19E2 + 0x021E3124
[FinalAddress] = 0x21E4B06
obviously in asm it can be shorten a polish a bit .. but still as i imagine this .. final code would be as long as my LOZ Dpad
PS. all remainder is ignored
for division in ARM ASM use this routine
Code:
mov r0,#0
mov r1,#0x3E @---dividend
mov r2,#0xF @---divisor
div:
cmp r1,r2
addge r0,#1
subge r1,r2
bge div
after the routine r0 = has the qoutient & r1 = has the remainder/Modulus
Re: Coordinates to world map location
Wow. All I can say is wow. That is one advanced formula right there. I don't even want to ask how you came up with it. Excellent work! I can't wait for the final code...
EDIT: I guess I'll give it a shot, since I just got your direct quote saying you would hope I could do it :) I'll give it a go. heheh
Re: Coordinates to world map location
this is the continuation of the recent code we are using .. obviously this is just a sample and very badly coded .. it might have error and obviously it can be shorten .. i just try to make it understandable to every one and hope even for the newbie ..
since r0 = rowSlot and r1 = columnSlot from viewtopic.php?p=3421#p3421
Code:
@((((([rowSlot]+16)-1)/16)-1)*4) + ((([columnSlot]+16)-1)/16)
@[TileNo] r2 will have the [TileNo]
add r8,r0, #16
bl checke
sub r6,#1
mov r2,r6, lsl #2
add r8,r1, #16
bl checke
add r2,r6
@((([rowSlot] - ((([rowSlot]-1)/16)*16))-1)*16) + ([columnSlot] - ((([columnSlot]-1)/16)*16))
@[SlotNo] r3 will have the [SlotNo]
mov r8,r0
bl checke
mov r3,#16
mul r4,r3,r6
sub r4,#1
mul r4,r3
sub r4,r0
mov r8,r1
bl checke
mul r3,r6
sub r3,r1
add r3,r4
@FInalAddress r0 will have the Final Address
@((([TileNo]-1) * 256) + ([SlotNo]-1))*2) + 0x021E3124
sub r3, #1
lsl r3, #8
sub r4,#1
lsl r4, #1
add r4,r3
ldr r1, =0x021E3124
add r4,r1
Here is the last macro and must be added on the last part of the wholecode
Code:
checke:
sub r8, #1
mov r6,#0
div:
cmp r8,#16
addge r6,#1
subge r8,#16
bge div
bx lr
r4 will contain the Final Address
Re: Coordinates to world map location
Interesting. Since r4 receives the final address, can you make it write that address to 0x02000000? I just want to see if it's working properly.
EDIT:
I just changed this section to:
Code:
@FInalAddress r0 will have the Final Address
@((([TileNo]-1) * 256) + ([SlotNo]-1))*2) + 0x021E3124
sub r3, #1
lsl r3, #8
sub r4,#1
lsl r4, #1
add r4,r3
ldr r1, =0x021E3124
add r4,r1
ldr r5, =0x02000000
str r4,[r5]
Wouldn't that put the final address at 0x02000000?
Re: Coordinates to world map location
Yes vash, from looking at it quickly it would.. but why even bother putting it to 0x02000000 when you can do the rest in ASM?