-
Coordinates to world map location [Complete/Full Source]
Something I wrote up. I've been thinking about this for a while. Any input would be nice (Virus, Toe, etc).
Code:
My theory,
Using ASM, make a code that uses your coordinates to compare to your location on the world
map (the layer where the items are stored). For example, in the very top left the
coordinates read D70F D70F and the item slot location is 0x021E3124. I've found that
the first byte in each coordinate is unimportant to this code. What is important is the
second byte (0F in this example). This byte increases less rapidly so in each item slot
on the world map (moving across it) this value will only increase maybe 30-40 (dec).
Here is my idea, in each item slot on the world map, you can increase the coordinate by
32 (dec) and you will roughly be in the same spot on the next item slot. So when people
use this code, they use the activator, it rounds this second byte to the nearest multiple
of 16 so it'll put them roughly in the middle of the item slot they are on. This will
make it easier for the rest of the code. Once they're in the same spot on each item slot we can
add the same value to the coordinates to get the item slot address. Basically, this is a
way of using the coordinates to get your location on the world map. In theory, you could
use this to make a code that allows you to delete an item you're standing on without
using search and replace and replacing all instances of the item and without knowing the
item's exact coordinate.
EXAMPLE:
Item Slot 1 (Top left corner): 0x021E3124
2nd byte of Coordinates (Multiple of 16): 10
Add to address (slot addr-coord): 21E3114
Item slot 2: 0x021E3126
2nd byte of Coordinates (Multiple of 16/add 32): 30
Add to address: 21E30F6
Item slot 3: 0x021e3128
2nd byte of coordinates: 50
Add to address: 21E30D8
I'm stuck at this part. If we get the '2nd byte of coordinates' always divisible by 16 (dec)
and we add 32 to it each time to get onto the next item slot then shouldn't the 'Add to
address' always be equal? Any input to make this work would be helpful. Right now we would
have to not only get the 2nd bytes divisible by 16, but we would have to add 30 to each
'Add to address' value depending on what the 2nd byte was.
Extremely confusing. I'm hoping the more advanced hackers can help me out. The only reason I posted this in Amateur Coding is because it's a work in progress.
-
Re: Coordinates to world map location
im bit lazy to play the game .. ill try to debug and see how the game calculated the location later ..
btw as i understand on your post .. the 2nd byte of coordinate is more like incremented by 32[20h] that initiate/starts with 16[10h]
so formula is like
Code:
16 + (([MapSlotNo]-1) * 32)
for example for Slot 2
16 + ((2-1)*32)
16 + ((1)*32)
16 + 32
48[30h]
Slot 3
16 + ((3-1)*32)
16 + ((2)*32)
16 + 64
80[50h]
if it really works that way then Slot 4 is like this
16 + ((4-1)*32)
16 + ((3)*32)
16 + 96
112[70h]
now to reverse that formula, this should be look like
if [2ndByte] is less than 48 then [MapSlotNo] = 1
now here is the formula if [2ndByte] is greater than or equal to 48
[MapSlotNo] = (([2ndByte] - 16)/32) + 1
for example if 2ndByte value is 54[36h]
[MapSlotNo] = ((54-16)/32) + 1
[MapSlotNo] = (38/32) + 1
[MapSlotNo] = 1+ 1 //remainder is ignored
[MapSlotNo] = 2
now to retrieve the Final Address the formula is like this
[FinalAddress] = (([MapSlotNo]-1) * 2) + 0x021E3124
so for example if Slot 2
[FinalAddress] = ((2-1)*2) + 0x021E3124
[FinalAddress] = ((1)*2) + 0x021E3124
[FinalAddress] = 2 + 0x021E3124
[FinalAddress] = 0x021E3126
To simplified the two formula .. the new formula can be
if [2ndByte] is less than 48[30h] then
Code:
[MapSlotAddress] = 0x021E3124
if [2ndByte] is greater or equal to 48[30h] then
Code:
[MapSlotAddress] = 0x021E3124 + ((([2ndByte]-16)/32) * 2)
so to retrieve a data using that formula its more like like this in ASM
Code:
mov r0,#0
ldr r1,SecByte
ldrb r1,[r1] //retrieve the 2nd byte
sub r1, #16 //deduct it by 16[10h]
div: //since ARM doesnt have Division we will make our own, r0 = r1/32
cmp r1, #32 // compare value of r1 with 32[20h]
addge r0,#1 //increment r0 with 1 if r1 is greater or equal with 32
subge r1, #32 //sub r1, #32 if r1 is greater or equal with 32
bge div // loop if r1 is greater or equal with 32
//after the loop, r0 = quotient & r1 = remainder/Modulus
end:
lsl r0,#1 //left-shift with 1 is the same as r0*2
ldr r1, Map
add r0,r1 //add value of r0 to the Map location
ldr r0,[r0] // retrieve value in r0 which is the final Address
bx lr
SecByte:
.long 0x00000000 // hehehe im too lazy to check
Map:
.long 0x021E3124
PS.
as always the above code is for bases of idea since it will only work on the first seven slot of the map since it was designed only to check for a byte which is maximum of 255[FFh] .. the next issues to solve was the remaining slot using the other bytes of coordinate mod..
-
Re: Coordinates to world map location
Very nice. The coordinates are technically structured like this:
Code:
D7 0F 02 00 D7 0F 02 00
|Left/Right| | Up/Down |
The first 4 bytes are Left/Right. When the first byte reaches it's max it increases the 2nd byte by 1. We would have to use the 2nd AND 3rd byte now because when the 2nd byte reaches it's max it increases the 3rd byte by 1. The 3rd byte only gets up to a max of 09 when you're all the way to the right (without going past the normal town borders). The minimum is 02 for this value (all the way to the left when boundaries are normal). This could make it much more difficult. Let me know if you have any idea how we could do this...
Oh and the basic idea behind this method is to use it for an in game world map modifier. It could be combined with the Text to Item code so when you stand on an item, enter the text of a new item in the chat, activate the code the item you're standing on will turn into your new item. Or you could use this method for a more basic code. You stand on something, activate, and it changes to whatever value you set up in the code.
EDIT: The coordinates address are both pointers. You'd have to ask Virus for that information. He did, afterall, create the coordinates mod.
-
Re: Coordinates to world map location
I have the coord mod in ASM... >_>
-
Re: Coordinates to world map location
Could you post the source with notes for Toe? I know the coordinates are pointers so maybe that could help him. If the source is private (since it is Zeld's work) I understand.
-
Re: Coordinates to world map location
Quote:
Originally Posted by Maniac
I have the coord mod in ASM... >_>
is it ASM hack or Custom ASM Routine?
Quote:
Originally Posted by Vash
EDIT: The coordinates address are both pointers. You'd have to ask Virus for that information. He did, afterall, create the coordinates mod.
frankly i don't have problem with pointers .. im just lazy to look for it in releases hehehe
to retrieve the value of it can be this
Code:
ldr r0, =0x21C6DEC
ldr r0,[r0]
cmp r0, #0
ldrne r0,[r0,#0xFFFFFAC0]
andne r1, r0, #0xFF00
r1 will hold the 2nd byte .. while r0 has the whole x - coordinate
anyway .. ill post later the 3rd byte computation .. according to your post ..
[im still on my lazy self hehehe]
-
Re: Coordinates to world map location
Haha, alright sounds good.
-
Re: Coordinates to world map location
Quote:
Originally Posted by toenailed
is it ASM hack or Custom ASM Routine?
ASM Routine I do believe. lol
-
Re: Coordinates to world map location
my country is currently experiencing "la nina" phenomenon .. and the current weather makes me so lazy anyway ill just base this according to your post
now instead of using a per byte check, we try to use a whole 32bit of coordinate both of x and y..
so for example if slot 2, 3rdd byte is 0x02 and 2nd byte is 0x30 then it is clear to say that lower than 0x023000 is Slot 1 and we just need to make a computation on more than slot 1
one whole row has 64 slots while column has 64 slot, so meaning the column 64 and row 64 has a value of 0x9F0xx in x - coordinate and 0x9F0xx in y - coordinate .. and so our formula will be
Legend:
x = x-coordinate
y = y-coordinate
Code:
if [x] < 0x023000 then rowSlot = 1 else
rowSlot = ((([x] lsr 8) - 0x0210)/32) + 1
if [y] < 0x023000 then columnSlot = 1 else
columnSlot = ((([y] lsr 8) - 0x0210)/32) + 1
in ASM
Code:
ldr r0, =0x21C6DEC
ldr r0,[r0]
cmp r0,#0
bxeq lr
mov r12,lr
ldr r3,[r0,#0xFFFFFAC0] @ y - coordinate , [value @ r0] - #0x540
bl checkslot @ check rowSlot
mov r1,r2 @ r1 has the rowSlot
ldr r3,[r0,#0xFFFFFAB8] @ x - coordinate , [value @ r0] - #0x548
bl checkslot @ check columnSlot
mov r0,r2 @ r0 has the columnSlot
@..........................
@ insert unsolve issues here
@..........................
mov pc, r12
checkslot:
lsr r3, #8
mov r2,#1
cmp r3,#0x0230
bxlt lr
sub r3, #0x0210
div:
cmp r3, #32
addge r2,#1
subge r3,#32
bge div
bx lr
so for example if x - coordinate has 0x9FO1F and y - coordinate has 0x230D7
rowSlot = ((((0x9FO1F ) lsr 8) - 0x0210)/0x20) + 1
rowSlot = ((((0x9FO) - 0x0210)/0x20) + 1
rowSlot = (0x7E0/0x20) + 1
rowSlot = 63 + 1
rowSlot = 64
columnSlot = ((((0x0230D7) lsr 8) - 0x0210)/0x20) + 1
columnSlot = (((0x0230) - 0x0210)/0x20) + 1
columnSlot = (0x20/0x20) +1
columnSlot = 1 + 1
columnSlot = 2
it means that the character is in Row 64 at column 2 of the map .. now there is one more issue need to be solve ..
the map has 16 tiles with 16x16 square .. (you can confirm it in animal map) .. and the first tile uses the first 512bytes while second tile uses the second 512bytes and so on .. so we cannot directly use .. 0x21E3124 + ((((rowSlot-1)*64) + (columnSlot-1))*2) .. instead we need a different approach
-
Re: Coordinates to world map location
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).
-
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?
-
Re: Coordinates to world map location
As I said above, I just wanted to make sure it was giving the proper address. By putting it at 0x02000000 I can check.
-
Re: Coordinates to world map location
-
Re: Coordinates to world map location
-
Re: Coordinates to world map location
-
Re: Coordinates to world map location
If you understand the language XD
-
Re: Coordinates to world map location
text the hex item then Press A + B
Code:
023FF090 012FFF11
E0000000 000000D4
E3A00301 E5D00130
E35000FC 112FFF1E
E28F1001 E12FFF11
6809492B D0522900
255446F4 3D01012D
594B43ED F837F000
3D081C10 F000594B
1C11F832 35101C05
F83AF000 00921E72
35101C0D F834F000
1C051992 F830F000
1B040134 01243C01
F0001C0D 0133F829
191B1ACB 02123A01
18D43B01 49150064
49151864 200C2200
3101780B DC012B60
E0003B30 40833B57
380418D2 DAF32800
46E66022 0A1B4770
24232201 42A30124
1B1BDB0D 2B203320
3201DB09 E7FA3B20
26003D01 DB022D10
3D103601 4770E7FA
021C6DEC 021E3124
022AF136 00000000
023FF090 E3520003
i tried this only in no$gba debugger using my trainermaker (with convert to asm, 0.03b has issues with using codehandler danng) and the issue so far is it gives two item next to each other [sometimes it gives two different item] .. maybe i just made some small mistake .. the small location inaccuracy on some portion is more on the 2ndbyte issues since the exact value per slot is around 7800 to 8100 ..
.. its already very late here .. ill just post the source tomorrow .. and some fix.. im felt very tired today
EDIT: anyway .. ill just post the source ... i know its still messy .. ill refix it tomorrow
Code:
mov r0,#0x04000000
ldrb r0,[r0,#0x130]
cmp r0,#0xFC
bxne lr
ldr r1, =0x21C6DEC
ldr r1,[r1]
cmp r1,#0
beq exit
mov r12,lr
ldr r3,[r1,#0xFFFFFAC0]
bl checkslot
mov r0,r2
ldr r3,[r1,#0xFFFFFAB8]
bl checkslot
mov r1,r2
add r5,r0, #16
bl checke
sub r2,r6,#1
lsl r2,#2
add r5,r1, #16
bl checke
add r2,r6
mov r5,r0
bl checke
lsl r4,r6,#4
sub r4,r0,r4
sub r4,#1
lsl r4,#4
mov r5,r1
bl checke
lsl r3,r6,#4
sub r3,r1,r3
add r3,r4
sub r2,#1
lsl r2,#8
sub r3,#1
add r4,r2,r3
lsl r4,#1
ldr r1, =0x021E3124
add r4,r1
ldr r1, =0x22AF136
mov r2,#0x0
mov r0,#0xC
loop:
ldrb r3,[r1],#1
cmp r3,#0x60
sublt r3,#0x30
subgt r3,#0x57
add r2,r3, lsl r0
sub r0,#0x4
cmp r0,#0
bge loop
strh r2,[r4]
mov lr,r12
bx lr
checkslot:
lsr r3,#8
mov r2,#1
mov r4,#0x23
lsl r4,#4
cmp r3,r4
blt exit
sub r3,r4
add r3,#0x20
div0:
cmp r3,#32
blt exit
add r2,#1
sub r3,#32
b div0
checke:
sub r5,#1
mov r6,#0
div:
cmp r5,#16
blt exit
add r6,#1
sub r5,#16
b div
exit:
bx lr
-
Re: Coordinates to world map location
Yeah, it seems to add a random red tulips to where you're standing along with the item you entered. Could this be because you have it taking 4 bytes from the text location instead of 2? Then it would make sense that it's writing 4 bytes (your item+0000).
EDIT: It also appears that the formula is off just a little bit for the item slots. It seems you forgot the +1 on the end of the X-slot and Y-slot formulas. The item appears one slot above and to the left of you. Solved by adding one to both the X and Y item slots.
-
Re: Coordinates to world map location
Thanks toe, I'll work on the fixes :)
-
Re: Coordinates to world map location
Maniac has it working pretty much 100%. The odd thing is about 50% of the time it's dead accurate for the slot you're standing on. The other 50% it goes maybe one to the right or one below you. Any idea why, Toe? A mistake in the formula possibly?
-
Re: Coordinates to world map location
Quote:
Originally Posted by Vash
Maniac has it working pretty much 100%. The odd thing is about 50% of the time it's dead accurate for the slot you're standing on. The other 50% it goes maybe one to the right or one below you. Any idea why, Toe? A mistake in the formula possibly?
actually there is no mistake in formula but we have to retrieve the actual difference of coordinate per map slot .. since the actual difference of 2ndbyte per slot is below 32[0x20] but higher than 30[0x1E] so lowest(1st) byte of coordinate is very important to retrieve a 100% accuracy (topleft most part is 0x020FD7 while topright most part is 0x09F029, will little calculation you will notice that there is a [-/+]0x29 to [-/+]0x52 missing difference per slot which can affect the other portion of the map slot, if we use the 2ndbyte solution) .. anyway its too early in the morning here in philippines ill just ill try to check later this afternoon the exact value of per slot size with coordinate
EDIT: 2nd Slot starts at 0x00022000 both at x and y coordinate .. so 2ndbyte should start at 0x20 .. except the first slot all slot is 0x2000 big .. so old formula can still be use but instead of 0x0210 .. we will use 0x0220 ... and still incremented with 0x20 ..
Code:
if [x] < 0x022000 then rowSlot = 1 else
rowSlot = (((([x] >> 8) - 0x0220)+32)/32) + 1
if [y] < 0x022000 then rowSlot = 1 else
columnSlot= (((([y] >> 8) - 0x0220)+32)/32) + 1
or simply
Code:
rowSlot = ((([x] >> 8) - 0x0200)/32) + 1
columnSlot = ((([y] >> 8) - 0x0200)/32) + 1
anyway i made two version ..
Final Test Code, Press L + R
NOTE: Type the HexItem then Press L+R to replace the item
that the character is Standing
Code:
94000130 FCFF0000
023FF090 012FFF11
E0000000 000000C0
E28F1001 E12FFF11
68124A2A D04D2A00
46B046F4 59534D26
F835F000 3D081C08
F0005953 1C05F830
F0003510 1E72F838
1C0D0092 F0003510
1992F832 F0001C05
0134F82E 3C011B04
1C0D0124 F827F000
1ACB0133 3A01191B
3B010212 006418D4
18644915 25004915
220F200C 3101780B
DB002B3A 40133309
18ED4083 D5F53804
46468025 0A1B4760
24202101 1B1B0124
DB0B2B20 DA092940
3B203101 3D01E7F8
2D102600 3601DB02
E7FA3D10 00004770
FFFFFAC0 021C6DEC
021E3124 022AF136
023FF090 E3520003
D2000000 00000000
Press L + R + A to replace item where the Character is Standing
Press L + R + A + DPAD to replace the item next to where the character is standing, depending on the pressed DPAD location
Code:
94000130 FCFE0000
023FF090 012FFF11
E0000000 00000104
E28F1001 E12FFF11
68124A3B D04F2A00
46B046F4 59534D36
F837F000 3D081C08
F0005953 F000F832
1C05F844 F0003510
1E72F838 1C0D0092
F0003510 1992F832
F0001C05 0134F82E
3C011B04 1C0D0124
F827F000 1ACB0133
3A01191B 3B010212
006418D4 18644925
25004925 220F200C
3101780B DB002B3A
40133309 18ED4083
D5F53804 46468025
0A1B4760 24202101
1B1B0124 DB0B2B20
DA092940 3B203101
3D01E7F8 2D102600
3601DB02 DAFA3D10
4C104770 29017824
2940D007 2510D005
D00D422C 422C2520
2801D00C 2840D0F0
2540D0EE D007422C
422C2580 E7E7D006
E7F23101 E7F03901
E7E13801 E7DF3001
FFFFFAC0 04000130
021C6DEC 021E3124
022AF136 00000000
023FF090 E3520003
D2000000 00000000
heres the routine that was added on the 2nd version, to check what DPAD was pressed
r0 = has the rowSlot and r1 = has the columnSlot
Code:
checkDPAD:
mov r4,#0x04000000
ldrb r4,[r4,#0x130]
leftright:
cmp r1,#1
beq updown
cmp r1,#64
beq updown
tst r4,#0x10
addeq r1,#1
tst r4,#0x20
subeq r1,#1
updown:
cmp r0,#1
bxeq lr
cmp r0,#64
bxeq lr
tst r4,#0x40
subeq r0,#1
tst r4,#0x80
addeq r0,#1
bx lr
EDIT: i accidentally used r6 in FInal Test Code .. it might cause a culprit in actual ARDS
-
Re: Coordinates to world map location
Yes those two recent codes work fine. Also All that weird stuff in the earlier posts is too advanced for me so thanks for figuring all that out. :D (AND that I can't figure anything out anyway!! :roll:)
-
Re: Coordinates to world map location
I just want to make everybody aware that this topic wasn't deleted, it was just moved to the Staff Only section for the time being. If the code is released I will move this topic back.
-
Re: Coordinates to world map location
Source code and Formulation
here is the source code and formulation .. i been busy for a while so i just post it out
Code:
[rowSlot] = ((([x] >> 8) - 0x0200)/32) + 1
[columnSlot] = ((([y] >> 8) - 0x0200)/32) + 1
[TileNo] = ((((([rowSlot]+16)-1)/16)-1)*4) + ((([columnSlot]+16)-1)/16)
[SlotNo] = ((([rowSlot] - ((([rowSlot]-1)/16)*16))-1)*16) + ([columnSlot] - ((([columnSlot]-1)/16)*16))
[FinalAddress] = ((([TileNo]-1) * 256) + ([SlotNo]-1))*2) + 0x021E3124
Code:
@--- my trademark
add r1,pc,#1
bx r1
.thumb
@--- my trademark
@[pointer] = r2
ldr r2, pointer
ldr r2,[r2]
cmp r2,#0
beq exit
mov r12,lr
@[rowSlot] = r0
ldr r5,far
ldr r3,[r2,r5]
bl checkslot
mov r0,r1
@[columnSlot] = r1
sub r5,#8
ldr r3,[r2,r5]
bl checkslot
@[TileNo] = r2
mov r5,r0
add r5, #16
bl checke
sub r2,r4,#1
lsl r2,#2
mov r5,r1
add r5,#16
bl checke
add r2,r4
@[SlotNo] = r3
mov r5,r0
bl checke
lsl r3,r4,#4
sub r3,r0,r3
sub r3,#1
lsl r3,#4
mov r5,r1
bl checke
lsl r4,#4
sub r4,r1,r4
add r3,r4
@[FinalAddres] = r4
sub r2,#1
lsl r2,#8
sub r3,#1
add r4,r2,r3
lsl r4,#1
ldr r1, map
add r4,r1
@[texttoItem] = r5
ldr r1, text
mov r5,#0x0
mov r0,#0xC
mov r2,#0xF
loop:
ldrb r3,[r1]
add r1,#1
cmp r3,#0x3A
blt number
add r3,#9
number:
and r3,r2
lsl r3,r0
add r5,r3
sub r0,#0x4
bpl loop
@[write] == OK
strh r5,[r4]
bx r12
@[division macro]
checkslot:
lsr r3, #8
mov r1,#1
mov r4,#0x20
lsl r4,#4
sub r3,r4
div0:
cmp r3,#32
blt exit
cmp r1,#64
bge exit
add r1,#1
sub r3,#32
b div0
checke:
sub r5,#1
mov r4,#0
div:
cmp r5,#16
blt exit
add r4,#1
sub r5,#16
b div
exit:
bx lr
.arm
far:
.long 0xFFFFFAC0
pointer:
.long 0x021C6DEC
map:
.long 0x021E3124
text:
.long 0x022AF136
Here is with the DPAD Check
Code:
@--- my trademark
add r1,pc,#1
bx r1
.thumb
@--- my trademark
@[pointer] = r2
ldr r2, pointer
ldr r2,[r2]
cmp r2,#0
beq exit
mov r12,lr
@[rowSlot] = r0
ldr r5,far
ldr r3,[r2,r5]
bl checkslot
mov r0,r1
@[columnSlot] = r1
sub r5,#8
ldr r3,[r2,r5]
bl checkslot
bl notStanding
@[TileNo] = r2
mov r5,r0
add r5, #16
bl checke
sub r2,r4,#1
lsl r2,#2
mov r5,r1
add r5,#16
bl checke
add r2,r4
@[SlotNo] = r3
mov r5,r0
bl checke
lsl r3,r4,#4
sub r3,r0,r3
sub r3,#1
lsl r3,#4
mov r5,r1
bl checke
lsl r4,#4
sub r4,r1,r4
add r3,r4
@[FinalAddres] = r4
sub r2,#1
lsl r2,#8
sub r3,#1
add r4,r2,r3
lsl r4,#1
ldr r1, map
add r4,r1
@[texttoItem] = r5
ldr r1, text
mov r5,#0x0
mov r0,#0xC
mov r2,#0xF
loop:
ldrb r3,[r1]
add r1,#1
cmp r3,#0x3A
blt number
add r3,#9
number:
and r3,r2
lsl r3,r0
add r5,r3
sub r0,#0x4
bpl loop
@[write] == OK
strh r5,[r4]
bx r12
@[division macro]
checkslot:
lsr r3,#8
mov r1,#1
mov r4,#0x20
lsl r4,#4
sub r3,r4
div0:
cmp r3,#32
blt exit
cmp r1,#64
bge exit
add r1,#1
sub r3,#32
b div0
checke:
sub r5,#1
mov r4,#0
div:
cmp r5,#16
blt exit
add r4,#1
sub r5,#16
bge div
exit:
bx lr
notStanding:
ldr r4,button
ldrb r4,[r4]
cmp r1,#1
beq updown
cmp r1,#64
beq updown
mov r5,#0x10
tst r4,r5
beq right
mov r5,#0x20
tst r4,r5
beq left
updown:
cmp r0,#1
beq exit
cmp r0,#64
beq exit
mov r5,#0x40
tst r4,r5
beq up
mov r5,#0x80
tst r4,r5
beq down
b exit
right:
add r1,#1
b updown
left:
sub r1,#1
b updown
up:
sub r0,#1
b exit
down:
add r0,#1
b exit
.arm
far:
.long 0xFFFFFAC0
button:
.long 0x04000130
pointer:
.long 0x021C6DEC
map:
.long 0x021E3124
text:
.long 0x022AF136
-
Re: Coordinates to world map location
EDIT: Nevermind. Nicely done :)
-
Re: Coordinates to world map location
Thanks guys me and Itsmegames are learning a lot!