Page 1 of 1

Lua and Memory Access Troubles

Posted: Sun Oct 14, 2018 7:19 am
by jan
Hey guys,

I recently purchased the emulator and love it. I am interested in writing some Lua scripts to add some functionality to Animal Crossing: Wild World. However, I am running into an issue with memory access. I simply want to change the item value in one of my inventory slots, but nothing happens.
  • I am not exactly sure how to use drastic.set_ds_memory_<cpu>_<size>(address, value)
  • What should I use for CPU and size? Right now, the values I want to change are in hexadecimal.
  • I have the address 021D8E80, which I got from DeSmuME, and value 137F; how do I enter that into the functions arguments? Is it like (0x021D8E80, 4991)?
  • When I get the address and write it to my log, it gives me a totally different value than anticipated.
It works fine when I use 121D8E80 0000137F with Action Replay.

Thanks!

Re: Lua and Memory Access Troubles

Posted: Sun Oct 28, 2018 9:36 pm
by Exophase
CPU should refers to the two processors on the DS and should be "arm7" or "arm9". If in doubt you most likely want to use arm9. If it's to main memory as your access is it shouldn't make a difference though.

Size is the width of the memory access, which can be 8, 16, or 32 for 8-bit, 16-bit, or 32-bit accesses.

So if you want to do a 32-bit of write 0x137F to 0x021D8E80 you would do:

drastic.set_ds_memory_arm9_32(0x021D8E80, 0x137F)

Re: Lua and Memory Access Troubles

Posted: Sun Nov 25, 2018 2:30 pm
by jan
Exophase wrote:
Sun Oct 28, 2018 9:36 pm
CPU should refers to the two processors on the DS and should be "arm7" or "arm9". If in doubt you most likely want to use arm9. If it's to main memory as your access is it shouldn't make a difference though.

Size is the width of the memory access, which can be 8, 16, or 32 for 8-bit, 16-bit, or 32-bit accesses.

So if you want to do a 32-bit of write 0x137F to 0x021D8E80 you would do:

drastic.set_ds_memory_arm9_32(0x021D8E80, 0x137F)
Thanks for the info. I realized I was using the wrong version of AC:WW, so everything works now.