Kodewerx https://www.kodewerx.org/forum/ |
|
AR NDS If scope https://www.kodewerx.org/forum/viewtopic.php?f=17&t=7252 |
Page 1 of 1 |
Author: | Fla8246 [ Sat Apr 03, 2010 3:00 am ] |
Post subject: | AR NDS If scope |
Hi, I would like to understand how the if code work. In c# the if statement is if (condiction) { }//end if In AR it should be: 9xxxxxxx yyyyyyyy D0000000 00000000 But what happen if i do : 9xxxxxxx yyyyyyyy 9xxxxxxx yyyyyyyy D0000000 00000000 <--does this line refer to the line above or to the first line? D0000000 00000000 Thank you |
Author: | Parasyte [ Sat Apr 03, 2010 11:10 am ] |
Post subject: | Re: AR NDS If scope |
The Dx code types act almost equivalent to the } curly bracket; like popping from a stack. Code: 9xxxxxxx yyyyyyyy ; First condition 9xxxxxxx yyyyyyyy ; Second condition D0000000 00000000 ; End second condition D0000000 00000000 ; End first condition A shorter form of this example is: Code: 9xxxxxxx yyyyyyyy ; First condition
9xxxxxxx yyyyyyyy ; Second condition D2000000 00000000 ; End all conditions |
Author: | Fla8246 [ Mon Apr 05, 2010 8:42 am ] |
Post subject: | Re: AR NDS If scope |
Ok, thank you, my next question is the following: if I write this: Code: //IF button Pressed 94000130 000003F9 //Set Stored to current value DA000000 0215A228 //Stored +1 D4000000 00000001 //If address = 1330 Then 0 9215A228 00001330 D5000000 00000000 D0000000 00000000 //If address = 18 Then 1330 9215A228 00000018 D5000000 00001330 D0000000 00000000 //SET VALUES D7000000 0215A228 D7000000 022AD61E //Close If and clear Stored D2000000 00000000 Could you tell me why the set values is always executed, even if I don't press any button? I tried removing the 2 if clause and without them it works ok. The work around I found is the following, but I don't understand why the previous one doesn't work Code: //IF button Pressed 94000130 000003F9 //Set Stored to current value DA000000 0215A228 //Stored +1 D4000000 00000001 //If address = 1330 Then 0 9215A228 00001330 D5000000 00000000 D0000000 00000000 //If address = 18 Then 1330 9215A228 00000018 D5000000 00001330 D0000000 00000000 //IF button Pressed <-------------------------AGAIN------- 94000130 000003F9 //SET VALUES D7000000 0215A228 D7000000 022AD61E //Close If and clear Stored D2000000 00000000 Thank you p.s. if you are interested the code above is used to cicle the codes (first position) in "Avalon Code" (E) |
Author: | Parasyte [ Mon Apr 05, 2010 8:31 pm ] |
Post subject: | Re: AR NDS If scope |
You might want to use the MASK bits for the activator, as specified here: viewtopic.php?f=11&t=98&p=7453#p7453 Next, you should verify the addresses you are writing to with the D7 code types: Code: D7000000 0215A228 D7000000 022AD61E These write the data register to addresses 0x0215A228 and 0x022AD620. If you knew that, cool... read on. Finally, the code logic seems ... awkward. Consider the pseudo code version: Code: if (data_reg == 0x1330) { data_reg = 0; } if (data_reg == 0x18) { data_reg = 0x1330; } If you were to press the button (set in your activator) for just a split-second, this code would do some really strange things:
Remember that the game runs at 30 or 60fps (depends on the game!) meaning all of this could potentially happen in under 1 second. It's not clear if that is the behavior you were intending, but that's what the code does. As for your question, I don't actually have an answer for you. All I can suggest is that your latter code looks like the best way to do it, anyway. With one exception: the first activator is no longer necessary. Put the activator around just the write codes (D7) and you will be fine. |
Author: | Fla8246 [ Wed Apr 07, 2010 11:21 pm ] |
Post subject: | Re: AR NDS If scope |
Thank you, I didn't understand why the code I wrote was called more the once. The behaviour I was looking for is the following: The address 0x0215A228 and 0x022AD620 is where the slot 1 "item" is stored. The hex values from 0x0000 to 0x0018 indicate the various "item" of the game, item 0x1330 is the empty "item" What I would like to do was look at the current value, add 1 save the value. The reason why I put the if is that 0x0019 is an invalid item and to avoid it I restart from "item" 0x0000, adding an extra step to allow the empty "item". The problem as you said is the way the "procedure" is called more than once every second. Do you know how I could avoid this behaviour and wait for the bottun up event? Is there and advantage in using the MASK bits for the activator? Thank you |
Author: | Parasyte [ Thu Apr 08, 2010 5:31 pm ] |
Post subject: | Re: AR NDS If scope |
The advantage to using the MASK bits in button activators is that it allows you to also press other buttons at the same time, since they will be masked out (ignored). This is really nice in many cases. I'll give you an example: The Metroid Prime: Hunters "Levitate" code allows you to fly by holding B. If I wanted to fly to the top of the map and snipe enemies, I would just have to hold B until I reached the top, and I wouldn't come down until I released B. Sounds perfect, right? Well, consider if the code was not masking out any other buttons... What happens if I shoot (L or R buttons) while I'm holding B at the top of the map? Well, the activator fails when you press L or R! And then you start to fall. This is because B [~0x0002] != B + R [~0x0102] != B + L [~0x0202] != B + R + L [~0x0302] If you are checking the pad register for a simple equality, then your activator will fail under this kind of condition (pressing your activator button combination + any other button). The mask feature can effectively solve this problem. This is why I originally suggested the universal activators in that form. To answer your other question, there has been some recent talk on a related subject: viewtopic.php?f=17&t=7240 Just read the whole thread. How do you use a code like that? Well, here's the code: Code: Button-Down Activator Enabler 023FE074 012FFF11 E0000000 00000034 E9F00024 E9F02024 E05000B0 E1D212BC E1800001 E05210B0 E04200B0 E1E00000 E0000001 E1C200B2 E12FFF1E 04000130 027FFF7C 00000000 023FE074 E3520003 Just place that into its own code on your AR. It will give you a new special 16-bit variable at address 0x027FFF7E. This variable records only button-down transitions. To use it: Code: 927FFF7E 0000xxxx For xxxx: 0001: A 0002: B 0004: Select 0008: Start 0010: Right 0020: Left 0040: Up 0080: Down 0100: R 0200: L 0400: X 0800: Y 2000: Debug Button (not available on commercial NDS) 8000: NDS not folded Now you have an activator that will only trigger once when a button is pressed. The first problem with this code is that you cannot reliably combine multiple buttons. Another problem with this code is that you can't just hold the button to continue firing the activator. (Like holding a key on your keyboard... it won't automagically do that.) I'll fix those problems if someone doesn't get to it before I do. Anyway, this should solve your immediate problem. Just replace the original universal activator with this one, and remember to turn on the button-down activator enabler as above. Let me know how it works for you. |
Author: | Fla8246 [ Sat Apr 10, 2010 12:26 am ] |
Post subject: | Re: AR NDS If scope |
Thank you, it work great. But how do you know that the game is not using the address 0x027FFF7E for something else? Is there a way to find unused address? Thanks |
Author: | Parasyte [ Sat Apr 10, 2010 11:29 am ] |
Post subject: | Re: AR NDS If scope |
Because I know that the address range 0x027FFF60 - 0x027FFF7F are reserved for the Nitro debugger! |
Author: | Hextator [ Sat Apr 10, 2010 9:24 pm ] |
Post subject: | Re: AR NDS If scope |
Why the 7? |
Author: | Parasyte [ Sun Apr 11, 2010 11:25 am ] |
Post subject: | Re: AR NDS If scope |
Because even though the commercial NDS only has 4MB of main RAM, the Nitro debugger has 8MB. And while we're at it, the commercial DSi has 16MB of main system memory. So on DSi (in real DSi mode) you would have to change the pointers to 02FFFF7E, for example. |
Author: | Hextator [ Sun Apr 11, 2010 3:08 pm ] |
Post subject: | Re: AR NDS If scope |
If it's reserved for nitro, then extending to 8 meg by using the debugger would effectively nullify your belief that the area is free, right? And if the NEW DSs that no one cares about have 16 meg, then why not just use F the whole way and not worry about it ever again? Edit: Ugh, why does this site still have no center tag but a heaping helping of bad smilies? Para, you're lazy. |
Author: | Parasyte [ Sun Apr 11, 2010 3:21 pm ] |
Post subject: | Re: AR NDS If scope |
It's not just "my believe" that those 32 bytes are unused, but a documented fact. The reason I use the address near the 8MB mark was for some level of future-proofing the code[s]. But this obviously wasn't enough. Using 02FFFF7E from the beginning would have been much more future-proofed. |
Author: | Parasyte [ Tue Apr 13, 2010 4:52 pm ] |
Post subject: | Re: AR NDS If scope |
Fla8246: Does the "Button-Down Activator Enabler" code work for you as I described? |
Page 1 of 1 | All times are UTC - 8 hours [ DST ] |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |