Kodewerx
https://www.kodewerx.org/forum/

Very noob question
https://www.kodewerx.org/forum/viewtopic.php?f=11&t=6398
Page 1 of 1

Author:  Apache81 [ Thu Dec 04, 2008 11:29 am ]
Post subject:  Very noob question

Hi to everyone !!!

I would like to create an Action Replay code for Nintendo DS that does the following things:

1) x = value at address XXXXXXXX
2) y = value at address YYYYYYYY
3) if x < y
4) XXXXXXXX = yyyyyyyy
5) else do nothing

Please, can anyone help me to do this in ASM and then in AR code?

Thank you very much !!! :)

Author:  HyperHacker [ Thu Dec 04, 2008 8:26 pm ]
Post subject:  Re: Very noob question

So in step 4, copy from YYYYYYYY to XXXXXXXX, or write some other value?

Author:  Apache81 [ Fri Dec 05, 2008 3:34 am ]
Post subject:  Re: Very noob question

Ok... I'll be more precise !!!

Castlevania Order of Ecclesia (EUR). I found these address:

0210792c -> 32 bit -> gold
021078d0 -> 16 bit -> current hp
021078d2 -> 16 bit -> hp max
021078d4 -> 16 bit -> current mp
021078d6 -> 16 bit -> mp max
021078d8 -> 16 bit -> current hearts
021078da -> 16 bit -> hearts max

Handle the gold is simple. i.e. AR CODE -> 0210792C 0098967F -> 9,999,999 gold ever (constant WORD memory writing)

I would like to make this simple piece of code:
- load max
- load current
- if current < max
- current = max
- end
one code for hp, one for mp and one for hearts amount but I'm not able to do it !!!

Can you help me understand how AR Code works? I also saw the wiki of kodewerx but I was not able to do what I would.

THANK YOU VERY MUCH !!!

Author:  A_Random_Person [ Fri Dec 05, 2008 8:02 pm ]
Post subject:  Re: Very noob question

.....

6210792C 0098967F //if 0x210792C is not equal to 0x98967F
0210792C 0098967F //then write 0x98967F to 0x210792C
D2000000 00000000 //end code...

just as an example..

Author:  Apache81 [ Sat Dec 06, 2008 12:27 pm ]
Post subject:  Re: Very noob question

A_Random_Person wrote:
6210792C 0098967F //if 0x210792C is not equal to 0x98967F
0210792C 0098967F //then write 0x98967F to 0x210792C
D2000000 00000000 //end code...


Yes... that's simple !!!
But how about to check if 2 values stored in 2 different memory locations are different?
I mean:
Code:
821078d0 121078d2 // if half-word 0x21078d0 < halfword 0x021078d2

will work or not?
It's correct to write this kind of instruction?

I know that in ASM if you want to check 2 memories value you have to do something like this:
Code:
   load 0x21078d0, r0    // load memory value in register 0
   load 0x021078d2, r1  // load memory value in register 1
   if r0 < r1   // check them
      store r1, 0x21078d0  // store r1 value in memory location

Author:  A_Random_Person [ Sat Dec 06, 2008 2:32 pm ]
Post subject:  Re: Very noob question

You mean...something like...
Code:
   ldr r0, =0x021078d0    // load memory value in register 0
   ldr r1, =0x021078d2  // load memory value in register 1
   ldrh r2, [r0] //load half-word at r0 into r2
   ldrh r3, [r1] //load half-word at r1 into r3
   cmp r2, r3   // compare r2 to r3
         strlth r3, [r0]  // if less than store r3 into r0...

?

Author:  Hextator [ Sat Dec 06, 2008 3:18 pm ]
Post subject: 

Those codes already exist.

Datel made them, I believe.

At least, they did for (U). For (E), I'm not sure, but seeing as where they are based is European, they probably hacked (E) first.

Just look at (U) and port the codes if (E) doesn't have them.

As for porting the checksum bypass code, you'll have to look at the general area I overwrote in (U) and look for a similar routine signature nearby in (E). Problem solved.

Author:  Apache81 [ Sat Dec 06, 2008 5:40 pm ]
Post subject:  Re: Very noob question

---------------------
For A_Random_Person
---------------------
Ok, ok... I think I mean:
Code:
   /* START --> dunno if yours are correct and not these... I mean if I need also the passages in the r2 and r3 */
      ldrh r0, =0x021078d0    // load half-word memory value in register 0
      ldrh r1, =0x021078d2  // load half-word memory value in register 1
   /*<-- END */
   cmp r0, r1   // compare r0 to r1
         strlth r1, [0x021078d0]  // if less than store only half-word r1 into half-word memory location (not all 32 bit)

Hope I was clear... sorry to make you bother guys !! :(


--------
For Zeld
--------
Maybe the U version codes could work... but I would like to understand how AR and ARM ASM work so I could try to make my personal code for my favourites games !!! :)

Author:  kenobi [ Tue Dec 09, 2008 2:30 pm ]
Post subject:  Re: Very noob question

Personaly I wouldn't care about checking if current < max, just copy the max value over the current one all the time.
(unless it causes a known problem ?)
Exemple for HP :
D3000000 021078D2
F21078D0 00000002

Now if you really want to compare two "unknown" values, you'll indeed have to use asm.

Author:  Apache81 [ Wed Dec 10, 2008 4:55 am ]
Post subject:  Re: Very noob question

:shock:
Ok, ok... I see !!!
So you're suggesting me to do like this:
Code:
D3000000 021078D2
F21078D0 00000002  // copy 00000002 bytes (16 bit) to 0x021078D0 into the offset
D2000000 00000000  // exit code... needed?


But what D3000000 021078D2 exactly do? In http://doc.kodewerx.net/hacking_nds.html it doesn't seems to appear as an instruction... I can only think that this will set the offset to a specified memory location (0x021078D2).

I've to say that this is just a very good solution !!!
THANK YOU VERY MUCH !!!

However I would like to ask you if you could be so kindly to tech me also how to write the ASM and the AR with the value check... just to let me understand how it works !!!
THANKS AGAIN !!! :)

Author:  kenobi [ Wed Dec 10, 2008 11:37 am ]
Post subject:  Re: Very noob question

Check the Type 0x0F (Memory Copy Code). It explains why the D3 code type is needed.
The code will copy 2 bytes from 0x021078D2 to 0x021078D0.
A D2 (or D3000000 00000000) code type will indeed be needed to finally clear the offset. (But if you're doing to use 3 memory copy code all together (hp, mp, hearts), you can put it just once after the last memory copy code.)

Author:  Apache81 [ Wed Dec 10, 2008 11:59 am ]
Post subject:  Re: Very noob question

Thank you very very much !!! :D

Page 1 of 1 All times are UTC - 8 hours [ DST ]
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/