This page is only an old draft and will be updated and cleaned eventually.

Random Number Generator (RNG)


RNG Calculation

You can calculate the next RNG state with the following lua script.
function getNextRNG(lowRNG, upRNG)
 local temp = upRNG + ((2^0x2 * upRNG) % 2^0x10)
 lowRNG = lowRNG * 2 + math.floor(temp / 2^0x10) + upRNG + math.floor((lowRNG * 2 + math.floor(temp / 2^0x10)) / 2^0x10)
 return lowRNG % 0x10000, temp % 0x10000 -- return RNG L, RNG U

RNG Addresses

0x206376016-bitRNG Lower 2 bytes
0x206376216-bitRNG Upper 2 bytes

Passed Value

A 16-bit value is passed to the function in register 0. The function then returns a value between 0 (inclusive) and the passed value (exclusive).
r0 = (r0 * lowRNG) >> 0x10	// lowRNG is after the calculation for the next state

Battle Uses

Item Drop Test

Return address (r14): 0x020BB710
Passed Value: 0x2710 (10,000)
The item's drop rate is multiplied by the drop rate multiplier and stored in register 8 during the RNG execution. If the returned value is less than the value in register 8, the test is passed and the item is dropped. Else, the drop test is considered failed and continues to the next item in the table.

Overworld Movement

Important Addresses

0x207415C32-bitCurrent X Coordinate
0x207416032-bitCurrent Y Coordinate

Battle Mechanics

Light Puck (Puck)

Travel Time

The Puck begins moving to the next partner two frames after the character holding the Puck (either character if the Puck is not in play) damages an enemy with a combo finisher. The value is set, when the Puck begins moving, to the base value of 89 and is reduced by 1 every frame until 0. Upon turning 0 from traveling, the value becomes 1 the next frame and the pass is considered complete. The value becomes 0 afterwards. Attempting to change this value directly to 0 will cause the game to reset the value to the base value.
This value is signed. All negative values are treated like 1 and will turn to 0 on the next frame to complete the pass normally.

Hold Time

The Puck can only be held for a limited amount of time before disappearing from play. The value is reset, when passing the Puck, to the base value of 930 and reduced by 30 for every pass. This includes the pass the puck is created so maximum base value without clothes is 900. The value is reduced by 1 every frame until 0.
This value is signed. All negative values are treated like 1 and will turn to 0 on the next frame for the Puck to disappear from play normally.
This value is used the frame before a combo finisher by the character holding the Puck deals damage to determine the increase/decrease of the Puck's Damage Multiplier.
Value/Max ValueMultiplier Change
98%+50 (+x0.5)
92%+20 (+x0.2)
70%+10 (+x0.1)
0%-100 (-x1.0)

Damage Multiplier

The Puck multiplies the damage dealt by a combo finisher if the character is currently holding it. The value is reset, when the Puck is created by the first pass, to the base value of 200. The value is then increased or decreased, when passing the Puck, based on the Puck Hold Time value. The value is a percentage so the value must be divided by 100 to get the true multiplier.
The minimum value is 200 (x2) and maximum is 500 (x5). Any values beyond this range will be set to the minimum (if under) or the maximum (if over). This value is signed and all negative values will be set to 200.
The Damage Multiplier applied to damage is after the increase or decrease. This must be noted because the Damage Multiplier in RAM is updated after the affected damage is dealt.

Useful Puck Addresses

All Puck addresses are stored in the Battle GUI Linked List except the following:
0x23918CD8-bitCurrent Puck Pass Count

Hit Points

A single address contains the current amount of Hit Points despite the two characters seeming to have their own Hit Point bars. The game only uses the current Hit Points. The damage received by the characters is only for graphical purposes and specific clothing abilities.

HP Related Addresses

0x23918B016-bitCurrent HP
0x23918B216-bitMaximum HP
0x23918B416-bitDamage Received on Top Screen
0x23918B616-bitDamage Received on Bottom Screen

Item Drop

Drop Rate Multiplier (for Battles)

The Drop Rate Multiplier can be temporarily multiplied by the amount of chained battles. This value is moved to a new address after the chain is finalized for use in battle.

Item Drop Table

Each enemy has an item drop table containing one item and drop rate for each difficulty. Starting at the item for the current difficulty, a drop test is executed. If the test is successful, the item is dropped. If the test is unsuccessful, the game moves down a difficulty and tries again. If the game reaches the end of the enemy's drop table without dropping an item, no item is dropped.

Useful Item Drop Related Addresses

0x2071D2416-bitDrop Rate Multiplier
0x239187216-bitDrop Rate Multiplier for Battle(s)

Battle Field Object/GUI Linked Lists

Linked Lists

All GUI elements and Field Objects are stored within Linked Lists during battles.
Known heads and tails of these linked lists are listed below:
Head AddressTail AddressDescription
0x235406C0x235408CField Objects, Bottom Screen
0x235C0F80x235C118Field Objects, Top Screen
0x23641840x23641A4GUI Elements

Basic Struct

This is used by all following structs, which are extended from this struct.
0x08 maybe be used to point to where the assets for the object are located.
0x0032-bitUnknown Purpose
0x51342403 if Valid Object
0x0432-bitPointer to Data Name
0x0832-bitSize of Object
0x0C32-bitEnd of List if 0xFFFFFFFF
Additional Objects if 0x0
0x1032-bitPointer to Head if Tail
0x1432-bitPointer to Tail if Head
0x1832-bitPointer to Next Object
0x1C32-bitPointer to Previous Object

Puck Data Struct

Found in the GUI Linked List.
This is available when a partner is present. This struct contains a preallocated linked list which is consistent enough for the following addresses to be static.
The value of 0x08 is usually 0x7E0.
0x0E432-bitRandom 1a
0x0E832-bitRandom 1b
0x7BC32-bitTravel Time
0x7CC32-bitPuck Decay
0x7D016-bitDamage Multiplier
0x7D416-bitHold Time
Random 1: Set at beginning of battle. Unknown purpose

Rebootable Pin Struct

Found in the GUI Linked List.
This is used by most pins that are able to reboot.
The value of 0x08 is usually 0x2C0. Occasionally, a newly created GUI Object would share this value during battle.
0x3E16-bitAttack Power
0x6416-bitUses Left
0x6616-bitMaximum Uses
Not set until after a boot
0x6816-bitBoot Time Left
0x0 if never booted yet
0xFFFF after a complete boot

Enemy Struct

Found in the Field Object Linked List.
This is used by all enemies.
0x7A16-bitInvulnerability Left
0x8C16-bitCurrent Hp
0x8E16-bitMaximum Hp
0x9832-bitPointer to Mirrored Enemy

Prize Struct

Found in the Field Object Linked List.
This is used by Item Drops that float to a character and is collected.
0x8C16-bitPrize Collect Time
Collect Prize on 0

Static enemy data

Starting address

You can find the starting address of an enemy's data at 0x20E0E24 + (0x2670 * Enemy Id). The enemy id is their noise report number minus one.

Data Map

0x2C16-bitItem Id for the "Easy Drop"
0x2E16-bitItem Id for the "Normal Drop"
0x3016-bitItem Id for the "Hard Drop"
0x3216-bitItem Id for the "Ultimate Drop"
0x3416-bitDrop rate for the "Easy Drop"
0x3616-bitDrop rate for the "Normal Drop"
0x3816-bitDrop rate for the "Hard Drop"
0x3A16-bitDrop rate for the "Ultimate Drop"

Other Useful Addresses

0x2066A4432-bitTotal Session Time (In frames)
0 = Easy
1 = Normal
2 = Hard
3 = Ultimate
0x2071D29.22-bitAuto Partner
0 = Manual
1 = Slow
2 = Mid
3 = Fast
0x2071D29.42-bitCurrent Pin Deck
0 = Deck 1
1 = Deck 2
2 = Deck 3
3 = Deck 4
0x2071D29.61-bitQuick Buy Items
0x2071D29.71-bitQuick Sell Pins
0x2073AA432-bitGameplay Time (In frames)
0x2074E7C8-bitCurrent Level (Max)
0x2074E8016-bitXp until Next Level
0x2074E9832-bitBattle Time (In frames)
0x23A22D48-bitCurrent Level (Reduced)

GameResources/DS/TheWorldEndsWithYou last edited by Zanoab on 3/10/2015 7:01 PM
Page History Latest diff List referrers View Source