Jump to content

User:CytricAcid/Beginner's Guide To ACE/US Red and Blue Guide: Difference between revisions

→‎3. Setting up our first code: Starting to write this section. Stopping here for now because I'm currently uncertain whether 2 (ld [bc], a) is a suitable filler for presenting on the wiki.
m (→‎1. Get 8F through dry underflow: Fixed a grammar problem.)
(→‎3. Setting up our first code: Starting to write this section. Stopping here for now because I'm currently uncertain whether 2 (ld [bc], a) is a suitable filler for presenting on the wiki.)
Line 180:
 
== 3. Setting up our first code ==
The final step is to spell out the arbitrary code you want to execute with items in your inventory. We will start with some simple codes both to verify that your party setup is correct, and to take full control of your inventory (i.e. get any item in any quantity) in order to facilitate making more complicated codes.
 
Arrange your items as follows, starting from the first item in your inventory:
* 8F<ref group="note">Technically, 8F can be in any slot of your inventory, but this slot is the most convenient.</ref>
* (Any non-Key item) ×(any)<ref group="note">In fact, this also works with Key items, but it would be harder to see the effect.</ref>
* Antidote ×43
* Full Heal/Revive ×2
* TM01 ×(any)
{{Explanation|title=ASM translation|contents=
Initially, <code>hl</code> = $D322, i.e. it points to the kind of the third item in the inventory (Antidote), which is also where the execution starts since we jumped here with a <code>jp hl</code> instruction.
{{{!}} class="wikitable"
! Item slot !! Item stack !! Hex !! ASM !! Comments
{{!}}-
{{!}} rowspan=2 {{!}} 3rd {{!}}{{!}} rowspan=2 {{!}} Antidote<br />×43 {{!}}{{!}} 0B {{!}}{{!}} ''dec bc'' {{!}}{{!}} Filler
{{!}}-
{{!}} 2B {{!}}{{!}} '''dec hl''' {{!}}{{!}} hl = $D321 (the quantity of the second item)
{{!}}-
{{!}} rowspan=2 {{!}} 4th {{!}}{{!}} rowspan=2 {{!}} Full Heal<br />×2 {{!}}{{!}} 34 {{!}}{{!}} '''inc [hl]''' {{!}}{{!}} Increases the quantity of the second item
{{!}}-
{{!}} 02 {{!}}{{!}} ''ld [bc], a'' {{!}}{{!}} Filler
{{!}}-
{{!}} 5th {{!}}{{!}} TM01 {{!}}{{!}} C9 {{!}}{{!}} '''ret''' {{!}}{{!}} Returns control to the calling routine
{{!}}}
* {{color|red|If you ever start making your own codes, always remember to end it with a <code>ret</code> instruction. Otherwise the game will continue to execute the remainder of your inventory (and possibly more data following that) as assembly code, which is likely to cause a crash, and potentially worse.}}
** That is, unless you know what you are doing and have a good reason not to (e.g. you ended the code with a <code>jp</code> to another function instead).
* As can be seen above, the "Antidote" in "Antidote ×43" and the "×2" in "Full Heal ×2" are fillers, i.e. you can replace them with "(Something) ×43" and "Full Heal ×(some amount)" respectively as long as the replacement bytes correspond to useless assembly instructions that don't actively mess up the rest of the code.
}}
 
After making sure everything is set up correctly, use 8F. The quantity of the second item should have increased by 1, even going over 99 (which eliminates the need to use MissingNo. to duplicate items in the future).
 
== Notes ==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.