Guides:Coin Case ACE: Difference between revisions
m
→TM Quantities to sell
No edit summary |
|||
(22 intermediate revisions by the same user not shown) | |||
Line 12:
When using the Coin Case while a Bellsprout/Machop's cry and specific newly loaded tiles are buffered in memory, the game will execute code in various places before finally ending up in the $FA98-$FA9B range, which is echo ram containing the stat exp data of party pokémon #3.
Using specific
In practice, the initial Coin Case ACE setup will be created using the following general process:
# Obtain the Coin Case
# Give
# Set up a specific movement pattern in the Goldenrod Radio Tower to be able to execute ACE
==Step 1:
# Catch any pokémon and nickname it "MAILWRITER".
# Go to Goldenrod City and obtain the Coin Case by picking it up in the Goldenrod Underground.
# After obtaining the Coin Case, go to the Game Corner.
#* If you do not have any coins yet, simply buy 100 coins.
#* If you already have coins stored in the coin case, make sure that the first digit of the total number of held coins equals "1".
# In the Goldenrod Dept. Store, buy a Flower Mail.
==Step 2:
Now that we have the Coin Case, we'll need to set up everything needed to actually safely use it. Using a specific setup, we can force the Coin Case to execute code starting from the second character of the last read mail. From here, we need to ensure that we have the proper setup to execute box name codes.
* Prepare a mail to ensure that a box name code can be executed
* Prepare specific box names to run a simple test code.
Line 47 ⟶ 40:
## Any
## Any
## "
## Any
## Any
## Any
# Finally, give the "
{| class="wikitable" style="margin-left: auto; margin-right: auto; border: none;"
|
[[File:
|}
Note: there is nothing unique about the MAILWRITER pokémon that requires it to be in the 3rd party slot. Later parts of the setup will, however, write data to the MAILWRITER pokémon, so it's convenient to keep it in the third party slot for now.
===Preparing a test box name code===
Line 62 ⟶ 57:
{| class="wikitable" style="margin-left: auto; margin-right: auto; border: none;"
|
[[File:Coin Case ACE tester box name.png|frameless]]
|}
==Step
In order to use ACE, always perform the following steps:
{| class="wikitable" style="margin-left: auto; margin-right: auto; border: none;"
|
[[File:EN Coin Case ACE start.png]]
||
[[File:EN Coin Case ACE end.png]]
|}
* '''Make sure to set box 1 as the current active box.'''
* Go to the Goldenrod Radio Tower and take the stairs up to the second floor. Move to the spot indicated by the above screenshot on the left. '''Save the game while you're still standing on this spot and reset the game.'''
* After reloading, take the following steps until you reach the spot indicated by the above screenshot on the left:
*# 3 steps rightwards
*# 2 steps upwards
*# 1 step leftwards
* Open the start menu, open the pokédex, then listen to the cry of Bellsprout.
* Go to the Pokémon menu and read the previously mentioned mail.
Line 80 ⟶ 86:
If the test code crashes, check the following:
* Did you correctly follow the previous steps?
* Is the current active box set to box 1?
* Make sure that the first digit of the total amount of coins is equal to "1". 100 is a good total for this setup.
* Is the box name code correctly entered?
* Is the content of the mail correct?
'''Anytime you wish to execute wrong pocket Coin Case ACE, you'll need to repeat the steps outlined at the beginning of this section. Always make sure the
=Setting up an ACE environment=
Line 98 ⟶ 104:
The mail writer itself will be installed in the TM/HM pocket through the following two step process:
# Execute a box code using Coin Case ACE that sets the quantities of all 50 TMs to x255, as well as placing a TM25 in the main item pocket. On top of that, it will modify the data of party pokémon #
# Sell TMs in specific quantities so that the amount of TMs in the TM/HM pocket spell out a small mail writer program.
==Step
* Rename box names to form the following. '''Please mind the differences between uppercase X ([[File:Character UCX.png]]), lowercase x ([[File:Character lcx.png]]) and multiplication symbol ([[File:Character mul.png]])'''.
Line 107 ⟶ 113:
{| class="wikitable" style="margin-left: auto; margin-right: auto; border: none;"
|
[[File:
|}
*
* Ensure that you have everything set up for Coin Case ACE:
** "
** Read the correct mail beforehand
** Perform all steps necessary to execute Coin Case ACE
Line 119 ⟶ 125:
* Use the Coin Case once. If the code was executed successfully, switch to the TM/HM pocket. '''It should now contain every TM at a quantity of x255. The code will also overwrite the first item in the main item pocket to be a TM25.'''
==Step
Now that we have obtained x255 of every TM, we'll be selling specific amounts of these in order to form a program. This program differs slightly depending on the specific language you're using.
Line 205 ⟶ 211:
|TM35 SLEEP TALK ||x239 ||8000
|-
|TM36 SLUDGE BOMB ||x58 ||
|-
|TM37 SANDSTORM ||x27 ||228000
Line 242 ⟶ 248:
# Use TM25. If everything went correctly, this will start the mail writer and open a screen asking you to input text for a mail.
# From now on, you can repeat this process at any time to start the mail writer.
Since we aren't planning on using the Coin Case anymore, the mail that was previously given to MAILWRITER can be removed. It is no longer relevant for the remainder of the setup.
If the game crashes, first recheck if all TM quantities are correct. If all quantities are correct, you may need to redo the setup for the "MAILWRITER" pokémon. This can be done using the box codes included a bit further below.
A note on the nicknamed pokémon: when running the box name code, we altered
==Step
'''From now on, simply go through the necessary steps to use TM25 to start up the RAM writer.'''
Line 277 ⟶ 285:
* [[User:TimoVM/Mail Writer Codes|Mail codes]]: this page contains a collection of assembly for mail codes that can be used for a variety of common purposes such as fixing the side effects of the ACE setup, editing pokémon and items, etc..
* [[User:TimoVM/RAM Writer|RAM writer]]: (recommended for more experienced users) this page contains the assembly for a large one-size-fits all program that allows you to edit any value in RAM with a user-friendly GUI. It will also fix the side effects of the ACE setup when you first run it.
=Addendum: repairing the "MAILWRITER" pokémon=
Line 287 ⟶ 293:
*# Any
*# Any
*# "
*# Any
*# Any
*# Any
* Enter the following language-specific box name. '''Please mind the differences between uppercase X ([[File:Character UCX.png]]), lowercase x ([[File:Character lcx.png]]) and multiplication symbol ([[File:Character mul.png]])'''.
Line 298 ⟶ 304:
|}
* Read the mail held by the "
* Go to
* Use the Coin Case to execute the code. If the game crashes, doublecheck the box name code and ensure you've performed every step of the process correctly.
* If the code executes succesfully without crashing the game, the "MAILWRITER" nicknamed pokémon has now been repaired.
Line 306 ⟶ 312:
==Plain text transcripts of codes==
{| class="wikitable" style="margin-left: auto; margin-right: auto; border: none;"
! Language !! English
|-
! scope="row" |
||
<pre>h h 's z 2 Pk 'l 0 9 ♀ . 9 Pk * ' ]
h 'd</pre>
|-
! scope="row" | Test box name
||
<pre>0 9 é A ♀ h 'd</pre>
|-
! scope="row" | Setup box name
||
Box 1: A p é 3 2 'v 9 5
Line 326 ⟶ 331:
Box 3: ? b é , 2 'v ♂ 5
Box 4: é 2 2 'v ? é 5 2
Box 5: ? E é
Box 6: é ♀ 2 é
Box 7: ♀ ♀ ♀ ♀ ♀ 's
Box 8: ? 'm é
Box 9: é y ♀ 'v - é 8 4
Box 10: 'v x é
|-
! scope="row" |
||
Box 1: A p 'v 6 é ) 4 5
Line 345 ⟶ 350:
===Effect of the Coin Case===
Activating the Coin Case causes arbitrary code execution from $E112 onward, which is echo ram for $C112. This region corresponds with sound data and can be manipulated by buffering pokémon cries.
Playing Bellsprout or Machop's cry will buffer $33 at $C117. This opcode increments the stack pointer, desyncing the stack.
The sound that plays when swapping item pockets clears some bad data around the $C16x region. It also places a $C1 at $C16E, popping a value from the stack to registers bc.
The sound that plays when confirming the use of the Coin Case places $80 A1 D0 at $C192. Due to prior opcodes setting the value of register bc to $0000, the condition for the return will always be true. Thanks to incrementing the stack pointer and popping the stack once, the next return address will redirect execution to $EB12, echo ram for $CB12.
From $CB12, the game will nopslide until $CC20 is reached. This region contains data on buffered tiles that are added when the player moves around . Due to our specific movement pattern within the Goldenrod Radio Tower, this results in the following data, starting from $CC20:
<pre>
At start, hl = $B2B2 and sp : $DFBC
39 add sp ; hl = $926E
39 add sp ; hl = $722A
39 add sp ; hl = $51E6
39 add sp ; hl = $31A2
39 add sp ; hl = $115E
39 add sp ; hl = $F11A
39 add sp ; hl = $D0D6
39 add sp ; hl = $904E
39 add sp ; hl = $700A
39 add sp ; hl = $4FC6
39 add sp ; hl = $2F82, carry flag set
30 31 jr nc, $31 ; Ignore thanks to previous carry
1A ld a, (de)
1B dec de
1A ld a, (de)
1B dec de
0A ld a, (bc)
0B dec bc
01 01 01 ld bc, $0101
01 01 01 ld bc, $0101
01 01 01 ld bc, $0101
01 01 01 ld bc, $0101
01 01 01 ld bc, $0101
01 39 39 ld bc, $3939
39 add sp ; hl = $0F3E
39 add sp ; hl = $EEFA, desired result in h, zero flag set
00 nop
00 nop
00 nop
00 nop
00 nop
00 nop
00 nop
00 nop
00 nop
00 nop
00 nop
00 nop
00 nop
00 nop
00 nop
00 nop
00 nop
00 nop
00 nop
00 nop
01 01 01 ld bc, $0101
01 01 01 ld bc, $0101
01 01 01 ld bc, $0101
01 01 01 ld bc, $0101
01 01 01 ld bc, $0101
01 00 00 ld bc, $0000
00 nop
00 nop
84 add h
9B sbc e
A4 and h
9B scb e ; The result of these arithmatic opcodes aren't relevant, but they do reset the zero flag
C4 9B E4 call nz, $E49B ; Corresponds to lower parts of screen tile data
</pre>
The main result of this region is to set h to $EE, followed by a call to screen tile data.
Before ACE is triggered, the game will already print the amount of coins on screen. In particular, a number of coins whose first digit is equal to 1 will lead to $F7 (rst30h) being printed to $C4E1. The region between $C49B and $C4E1 is filled with harmless data consisting of blank tiles ($7F), textbox tiles ($7A-$7C) and arithmatic opcodes for the "Coins:" text ($82 AE A8 AD B2 9C). The end result is that a is set to be equal to $EE, the value stored in h, right before rst30h is activated.
rst30h is technically an unused reset vector, but accidentally contains the last three bytes of JumpTable function, usually accessed by rst28h:
<pre>
6F ld l, a ; hl = $EEEE
D1 pop de ; Pops the return address to registers de
E9 jp hl ; Jump to $EEEE, the second character of the last read mail
</pre>
This allows us to finally reach the last read mail, a region of memory that we have a good amount of control over.
===Effect of the mail===
Line 371 ⟶ 444:
<pre>
A7 and a ; Reset carry flag
D4 B9 F8 call nc, $F8B9 ; Box names start at $D8BF/F8BF, setting the active box to box 1 will ensure we can safely slide through.
E1 pop hl ; Additional pop to clear return address of call to screen data
D1 pop de ; Set de to $0075, which holds value $00. Ensures that print function will end immediately after resuming
E8 FF add sp, -1 ; Fix the effect of increasing the stack pointer
E0 9F ld ($FF9F), a ; Ensures return to ROM bank 3 after resuming execution
A7 and a ; Reset carry flag. Not strictly necessary, but added for safety for now
</pre>
Line 417 ⟶ 472:
The code overwrites part of itself to call the byteFill function. This will fill the area between $D57E and $D5AF with $FF values, setting all 50 TM quantities to 255.
Separately, this code overwrites the latter half of party pokémon #
Lastly, the value of the first item ID in the main item pocket is overwritten so that it becomes a TM25.
Line 451 ⟶ 506:
Box 5: $D8E3
E6 84 and $84 ; a = $04
EA
D6 86 sub $86 ; a = $7E
FB ei
Line 458 ⟶ 513:
Box 6: $D8EC
EA F5 F8 ld ($F8F5), a
EA
F6 FF or $FF ; a = $FF, reset carry flag
21
Line 468 ⟶ 523:
50 ld d, b
Box 8: $
E6 D2 and $D2 ; a = $D2
EA
D6 FA sub $FA ; a = $D8, TM25's item ID
FB ei
50 ld d, b
Box 9: $
EA B8 F5 ld (wItems), a ; Main item pocket, first item ID
D6 E3 sub $E3 ; a = $F5
EA
50 ld d, b
Box 10: $
D6 B7 sub $B7 ; a = 3E, reset carry flag
EA
D0 ret nc
50 ld d, b
Line 569 ⟶ 624:
C3 7E F5 jp wTMsHMs ; Carry and zero flag are both reset when using TM25
</pre>
[[Category:Guides]]
|