Animal Crossing City Folk Coordinates Help

Started by dragonboy269, February 11, 2010, 07:30:05 AM

Previous topic - Next topic

dragonboy269

I've been making a "Search/teleport" code
This code will search the map for weeds, and if it finds weeds, it'll teleport your character to the first weed it finds.

Anyone with ACCF and a USBGecko wanna help me out here? I have an ASM routine already written that should work, just not the right address to write the coordinates to. (i know its wrong because i write to it and my character doesn't move at all) Soo if anyone can quickly find where the coordinates are stored, annd how they are structured, that would help me a lot. I coded this by pure guessing, based on how they were structured in Animal Crossing Wild World, the only difference being ACCF has a 5x5 acre grid, and ACWW has a 4x4 acre grid (with each acre having 16x16 slots)
[spoiler]
li r5,0                  //set a counter to 0
lis r14, 0x90E8
ori r14,r14,0xF052          //set r14 to 0x2 before the first map slot
addi r17,r14,0x3202        //set r17 to the final mapslot

mapSearch:
lhzu r27,2(r14)               //load the item in each slot
cmpwi r27,0x57              //check if that item is a weed (weeds are any value between 0x57 and 0x5A)
blt notWeeds
cmpwi r27,0x5A
ble SetCoordinates         //if so, start messing with your coordinates
notWeeds:
addi r5,r5,0x1                //if not, add to the counter
cmpw r14,r17                //and search the next slot, if we aren't at the last slot
ble mapSearch
blr                               //once we've searched all slots, end the code

SetCoordinates:

andi. r9,r5,0xFF             //get the slot number
srwi r5,r5,0x8               //and the acre the weed is in (by dividing by 256)
li r30,0x5

divw r30,r5,r30             //get the acre row and acre column by dividing by 5 (because the map is 5x5 acres) r30 holds the quotient, r5 holds remainder
mulli r14,r30,0x5
subi r5,r5,r14

slwi r14,r30,0x5            //multiply both by 32, this is to get the correct coordinates (16 slots, and each slot increases coordinates by 2)
slwi r17,r5,0x5
andi. r5,r9,0xF             //divide by 16 to get the individual row/columns (each acre is 16x16 slots)
srwi r9,r9,0x4

slwi r5,r5,0x1              //multiply by 2 and add to coordinates
add r17,r17,r5
slwi r9,r9,0x1
add r14,r14,r9

addi r17,r17,0x11        //the coordinates in the top left corner are 0x11 0x11, (i think? for the exact middle of the slot) so adding this to what we got will give us the item's coordinates
addi r14,r14,0x11
lis r30,0x80E6            
stbu r17,0x38D7(r30)  //store the x coordinate in 80E638D7 (this is the wrong address, someone help?)
stb r14,0x8(r30)        //store the y coordinate in 80E638DB (same as above)
blr
[/spoiler]

I'm not very experienced with PowerPC assembly either, so if you see something I can simplify, go ahead and tell me.
If you have any requests for AC:WW/AC:CF codes, send me a message. :D