Skip to content

Instantly share code, notes, and snippets.

@ExpHP
Last active August 17, 2023 05:22
Show Gist options
  • Select an option

  • Save ExpHP/88bdef8f28f46fe4af6ab2e013b75896 to your computer and use it in GitHub Desktop.

Select an option

Save ExpHP/88bdef8f28f46fe4af6ab2e013b75896 to your computer and use it in GitHub Desktop.

Revisions

  1. ExpHP revised this gist Sep 2, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions 1_anm-parser.md
    Original file line number Diff line number Diff line change
    @@ -130,8 +130,8 @@ Aside from the layer, the one bitflag, and a pointer to a "root" VM, nothing els
    The specific instruction you use decides where the object is placed:

    * 500 inserts **at the back of the `world` list.** This is a list of ANMs that exist *in the game world.* When you pause the game, these ANMs stop running. They are only allowed to use **layers 0 to 35** (if you try to use others, the game will change the layer on you).
    * 501 inserts **at the front of the `world` list.** This probably lets you achieve a different z-ordering.
    * 502 inserts **at the back of the `ui` list.** This is a list of ANMs that exist outside of the game world. These ANMs alre *always* running. They are only allowed to use **layers 36 to 42** (if you try to use others, the game will change the layer on you).
    * 501 inserts **at the back of the `ui` list.** This is a list of ANMs that exist outside of the game world. These ANMs alre *always* running. They are only allowed to use **layers 36 to 42** (if you try to use others, the game will change the layer on you).
    * 502 inserts **at the front of the `world` list.** This probably lets you achieve a different z-ordering.
    * 503 inserts **at the front of the `ui` list.**

    Unless stated otherwise, all other child creation opcodes insert the child in the same place as 500 does.
  2. ExpHP revised this gist Aug 30, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 0_announcement.md
    Original file line number Diff line number Diff line change
    @@ -2,4 +2,4 @@

    Much of the information here is old and outdated!

    Visit my new site at [exphp.github.io](https://exphp.github.io/thpages/#anm/ins).
    Visit my new site at [exphp.github.io/thpages](https://exphp.github.io/thpages/#anm/ins).
  3. ExpHP revised this gist Aug 18, 2020. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions 0_announcement.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    ## Announcement regarding this gist

    Much of the information here is old and outdated!

    Visit my new site at [exphp.github.io](https://exphp.github.io/thpages/#anm/ins).
  4. ExpHP revised this gist Aug 2, 2020. 1 changed file with 8 additions and 6 deletions.
    14 changes: 8 additions & 6 deletions 1_anm-parser.md
    Original file line number Diff line number Diff line change
    @@ -93,7 +93,7 @@ Calling `setLayer` also changes this flag; it will typically automatically set i

    The description on the wiki makes absolutely no sense.

    Judging from the implementation, this is the `___Time` version of 429 `windowBlinds`.
    Judging from the implementation, this is the `___Time` version of 429 `repeat`.

    ### 422

    @@ -191,13 +191,15 @@ I have tentatively named 3 `run`, though I know someone else has named it `stop`

    The following commands have been verified to have no immediate effect inside `anm_parser` besides setting bitfields.

    (**Update Aug 2020:** Though I still don't intend to update this document much, I've labeled in bold the ones whose purpose I have since identified)

    * `Unknown305(bool)`
    * `Unknown306(bool)`
    * `Unknown307(bool)`
    * `Unknown311(bool)`
    * `Unknown312(twoBit, twoBit)`
    * `Unknown313(threeBit)` (as mentioned, `setLayer` may also change these bits)
    * `Unknown314(bool)`
    * `Unknown311(bool)` (**resample mode** when scale != 1)
    * `Unknown312(twoBit, twoBit)` (**scroll mode** ("texture address mode" in D3D-speak))
    * `Unknown313(threeBit)` *(now partially understood as a resolution scaling mode)*
    * `Unknown314(bool)` *(moves around as parent rotates)*
    * `Unknown315(bool)`
    * `Unknown316()` (enables a bit)
    * `Unknown317()` (disables that bit)
    @@ -222,7 +224,7 @@ If you see *(unknown)* it means I did not spot any usage of it in this function.
    * **`530:1`**: Enabled by 316, disabled by 317
    * **`530:2`**: Enabled by 401 `rotate`, 410 `rotateTime`, 414 `rotateTime2d`
    * **`530:3`**: Enabled by 402 `scale`, 412 `scaleTime`, 434, 435
    * **`530:4`**: Enabled by 429 `windowBlinds`, 430
    * **`530:4`**: Enabled by 429 `repeat`, 430
    * **`530:(5-9)`**: Set by 303 `blendMode`
    * **`530:9`**: *(unknown)*
    * **`530:10`**: "Alternate start pos flag"
  5. ExpHP revised this gist Aug 1, 2020. 2 changed files with 14 additions and 39 deletions.
    20 changes: 14 additions & 6 deletions 1_anm-parser.md
    Original file line number Diff line number Diff line change
    @@ -77,9 +77,17 @@ Calling either 413 `rgb1Time` or 414 `alpha1Time` has the side-effect of causing

    I have no idea what the wiki is saying about this or how it's supposed to differ from `alpha1Time` and `alpha2Time`, but it modifies the same fields as `alpha2Time`.

    ### 438 `setVisible(twoBit)`
    ### 438 `setOrigin(twoBit)`

    This actually sets a two bit field instead of a 1-bit field. We know that the lowest bit is a visibility flag. What is the other bit?
    **EDIT 2020-08-01: Chinese wiki is mistaken; this does not toggle visibility.**

    On a VM that is a root VM (no parent), this determines what coordinates in the D3D surface correspond to (0,0).

    - `ins_438(0)`: No correction (use the the upper left corner)
    - `ins_438(1)`: A setting appropriate for objects always drawn at 640x480 (most game elements). It's the location of ECL's (0,0) during the first few stages of rendering (see [TH14 D3D investigation](#file-4_d3d-md)).
    - `ins_438(2)`: A setting appropriate for objects drawn at full resolution (text and UI elements). It's the location of ECL's (0,0) in rendering stages that occur *after* the 384x448 game region is upscaled to the window resolution.

    Calling `setLayer` also changes this flag; it will typically automatically set it to the origin appropriate for that layer's rendering stage.

    ### 430

    @@ -282,11 +290,11 @@ If you see *(unknown)* it means I did not spot any usage of it in this function.
    + When this flag is 0, some functions contain additional code that take into account the parent (or root?) VM's scale and rotation.
    * **`534:17`**: *(unknown)*
    * **`534:(18-20)`**:
    + Set by 438 `setVisible`.
    + Set by 438 `setOrigin`.
    + 304 `setLayer(layer)` also affects this:
    - if `3 <= layer <= 19`, it calls `setVisible(0b01)`
    - if `20 <= layer <= 23`, it calls `setVisible(0b10)`
    - otherwise, it calls `setVisible(0b00)`
    - if `3 <= layer <= 19`, it calls `setOrigin(0b01)`
    - if `20 <= layer <= 23`, it calls `setOrigin(0b10)`
    - otherwise, it calls `setOrigin(0b00)`
    + Set to `0b00` at `0x4071da`
    + Usage at `0x406bb1`
    + Usage at `0x467f20` (comparison to `0b00`)
    33 changes: 0 additions & 33 deletions 9_revisions.md
    Original file line number Diff line number Diff line change
    @@ -1,33 +0,0 @@
    ## Mar 14 2020

    Shared

    ## Mar 17 2020

    - Added flags touched by setLayer
    - Added investigation results for 500-503

    ## Mar 18 2020

    - Added investigation results for 504, 505, 506, 509. Only 508 remains in this series.

    ## Mar 18 2020 (second edit)

    - Added investigation results for 508.

    ## Mar 20 2020

    - Proper notes for 418 and 419

    ## Mar 21 2020

    - Preliminary results from 3

    ## Mar 22 2020

    - I ctrl+F'd for bitflag usage and found a ton of results.

    ## May 7 2020

    - Huge update after looking at `on_tick` and `on_draw` functions. Differences between 500-503 are now understood.
    - I also added a giant table of `on_tick` function descriptions because fuggit.
  6. ExpHP revised this gist Jul 25, 2020. 2 changed files with 29 additions and 0 deletions.
    29 changes: 29 additions & 0 deletions 4_d3d.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    # TH14 D3D investigation

    `MotherInf` (called `Supervisor` in my ReData) contains a ton of high-level rendering stuff, including some of the most critically important `on_draw` funcs, such as those that call `SetRenderTarget`.

    In modern games, it has 4 `AnmVms`, and 3 pointers to `IDirect3DSurface9`s. The three surfaces are:

    * Two temporary surfaces used for rendering the "game region" of the screen. The game switches back and between them at various steps for reasons, as described soon.
    + Surface 0 is the texture for text.anm entry2.
    + Surface 1 is the texture for text.anm entry3.
    * The third is the D3D Device BackBuffer. The majority of GUI stuff and "full-resolution" graphical elements are drawn directly to this (though a couple are drawn a bit earlier so they get rotated by seija).

    The four `AnmVm`s use scripts from text.anm, and they are used to paste stuff rendered from one of the two temporary surfaces to the other. Here's what happens: (DDC)

    * `SetRenderTarget(`**`Surface0`**`)`
    * Draws the **Stage and Layers 0-5, 30-31** at 640x480
    * `SetRenderTarget(`**`Surface1`**`)`
    * use vm 0 (text.anm scripts 59-61) to copy from Surface 0
    * Draw **Layers 6-11 (enemies mostly)** at 640x480
    * `SetRenderTarget(`**`Surface0`**`)`
    * use vm 1 (text.anm scripts 65-67) to copy from Surface 1
    * Draw **Layers 12-19, bullets, items, player** at 640x480
    * `SetRenderTarget(`**`Surface1`**`)`
    * use vm 2 (text.anm scripts 62-64) to copy from Surface 0, **upscaling to full resolution**
    * Draw **Layers 20-23, Ascii Group 1** at full resolution (this is probably **spell name/hist** and **in-world ascii**)
    * `SetRenderTarget(`**`BackBuffer`**`)`
    * use vm 3 (text.anm scripts 68-70) to copy from Surface 1, **with seija's effects**
    * Draw **Layers 24-29, 34-35, Ascii Groups 0 & 2** (this is probably **gui, pause menu, main menu etc.**)

    Spreadsheet if you *really* want to drown in details https://docs.google.com/spreadsheets/d/1ovAPn9Ib7wxFBuTtT63oXgjfzbEq60ikSu7BxhZz-vM/edit#gid=0
    File renamed without changes.
  7. ExpHP revised this gist Jun 22, 2020. 1 changed file with 1 addition and 36 deletions.
    37 changes: 1 addition & 36 deletions 3_bonus_on-tick.md
    Original file line number Diff line number Diff line change
    @@ -1,36 +1 @@
    # TH16 `on_tick` table

    As a bonus, since I looked at all the `on_draw`s, why not look at all of the `on_tick`s? It's useful knowledge to know the order in which things occur:

    | `this` | TH15<br>Prio. | TH16<br>Prio. | TH17<br>Prio. | TH16<br>Addr. | Notes |
    | --- | --- | --- | --- | --- |:--- |
    | **Some D3D thing** | `0x01` | `0x01` | `0x01` | `0x43b3d0` | Reads raw keyboard input. Supervises threads? Does D3D... stuff. Switches gamemodes. |
    | **`Thread63c`** | `0x03` | `0x03` | `0x03` | `0x43b290` | Checks the configured game resolution and... lolidunno |
    | **`AsciiManager`** | `0x04` | `0x04` | `0x05` | `0x408070` | Simply ticks down `remaining_time` (`+0x12c` in TH16) fields on strings and deletes expired ones. |
    | **`DebugSprtView`** | `0x05` | | | | |
    | **`DebugSptTest`** | `0x05` | | | | |
    | **`MainMenuThread`** | `0x06` | `0x06` | `0x07` | `0x44af80` | Allows navigating the main menu. |
    | **`DebugSoundTest`** | `0x08` | | | | |
    | **`AnmManager`** (1) | `0x09` | `0x09` | `0x0a` | `0x46e710` | This is `on_tick__ui`. It advances ANM VMs in layers 36 to 42 and rebuilds their layer lists. |
    | **`PauseMenu`** | `0x0a` | `0x0a` | `0x0b` | `0x43e3f0` | Implements Pause and Game Over menu. |
    | **`HelpManual`** | `0x0b` | `0x0b` | `0x0c` | `0x401300` | Responds to keyboard input while the help menu is open. |
    | **`TrophyManager`** | | | `0x0e` | N/A | |
    | **`GameThread`** | `0x0f` | `0x0f` | `0x10` | `0x42db70` | Appears to be responsible for stage transitions and Stage/Game clear bonuses at stage end. **When the game is paused, this returns `3`, telling the game not to run the rest of the `on_tick` functions.**|
    | **`ReplayManager`** (1) | `0x10` | `0x10` | `0x11` | `0x448e30` or <br/> `0x447fd0` | One of these functions is used when recording replays, the other is used when playing them back. Both are responsible for setting the game INPUT globals. |
    | **`Stage`** | `0x11` | `0x11` | `0x12` | `0x40a7a0` | Plays STD script, does... things! Things it does! |
    | **`ScreenEffect`** | `0x14` | `0x13` | `0x14` | Various | There's many of these. They do things like screen shake and fades to black. |
    | **`PopupManager`** | `0x15` | `0x14` | `0x15` | `0x449ea0` | Updates those tiny little score, PIV, power and graze popup texts written in kanji numerals. |
    | **`Player`** | `0x17` | `0x16` | `0x17` | `0x442560` | **HUGE.** Watches input, moves, initiates bombs, shoots, moves player bullets, precomputes hurtbox... |
    | **`(pl0x.sht) ShotType`** | `0x19` | `0x18` | `0x19` | `0x40da60` | Runs per-tick logic of a bomb if the player is using one. |
    | **`(pl0xsub.sht) ShotType`** | | `0x19` | | `0x40da60` | Same but for season releases. |
    | **`EnemyManager`** | `0x1a` | `0x1a` | `0x1b` | `0x41af44` | For each enemy, runs ECL, takes damage from the Player, maybe kills the player, and lots, lots more. |
    | **`LaserManager`** | `0x1b` | `0x1b` | `0x1c` | `0x431330` | Runs game logic for each laser, similar to bullets. |
    | **`BulletManager`** | `0x1c` | `0x1c` | `0x1d` | `0x412c50` | Moves enemy bullets. Check graze conditions, maybe kill the player. |
    | **`ItemManager`** | `0x1d` | `0x1d` | `0x1e` | `0x4308f0` | Moves items, checks for PoC/autocollect/attraction/pickup, performs item pickup effects. |
    | **`GoastManager`** | | | `0x1f` | N/A | Makes tokens move. Not sure if this is responsible for otter hypers, or if that's done in `Player::on_tick`. |
    | **`Spellcard`** | `0x1f` | `0x1e` | `0x20` | `0x417ee0` | Messes with anms, updates spell bonus, checks for bomb usage. |
    | **`EffectManager`** | `0x20` | `0x1f` | `0x21` | `0x418ab0` | TH12-14: Noop. TH15-17: Checks the list of running effect anm ids and zeros out any that have finished. This is pointless in TH16-17, but in TH15 this bookkeeping was necessary for Pointdevice. |
    | **`Gui`** | `0x21` | `0x20` | `0x22` | `0x429af0` | Refreshes all the counters on the right side of the screen and many HUD elements. Might also be responsible for boss dialogue? I dunno it's very big leave me alone |
    | **`AnmManager`** (2) | `0x22` | `0x21` | `0x23` | `0x46e710` | This is `on_tick__ui`. It advances ANM VMs in layers 0 to 41 and rebuilds their layer lists. |
    | **`ReplayManager`** (2) | `0x23` | `0x22` | `0x24` | `0x448e40` | Implements speedup while holding Ctrl on replay playback. |
    | **`Ending`** | `0x24` | `0x23` | `0x25` | `0x4196c0` | Shows the ending and staff roll. |
    See https://gist.github.com/ExpHP/9547aee1b37682f934da399a7d2b41f4 for a list of `on_tick` priorities in almost all games
  8. ExpHP revised this gist Jun 11, 2020. 2 changed files with 3 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion 3_bonus_on-tick.md
    Original file line number Diff line number Diff line change
    @@ -29,7 +29,7 @@ As a bonus, since I looked at all the `on_draw`s, why not look at all of the `on
    | **`ItemManager`** | `0x1d` | `0x1d` | `0x1e` | `0x4308f0` | Moves items, checks for PoC/autocollect/attraction/pickup, performs item pickup effects. |
    | **`GoastManager`** | | | `0x1f` | N/A | Makes tokens move. Not sure if this is responsible for otter hypers, or if that's done in `Player::on_tick`. |
    | **`Spellcard`** | `0x1f` | `0x1e` | `0x20` | `0x417ee0` | Messes with anms, updates spell bonus, checks for bomb usage. |
    | **`Global2020`** | `0x20` | `0x1f` | `0x21` | `0x418ab0` | Scans an array of anm ids at `this+0x1c` and replaces them with `0` if the ANM VMs cannot be found. 🤷 |
    | **`EffectManager`** | `0x20` | `0x1f` | `0x21` | `0x418ab0` | TH12-14: Noop. TH15-17: Checks the list of running effect anm ids and zeros out any that have finished. This is pointless in TH16-17, but in TH15 this bookkeeping was necessary for Pointdevice. |
    | **`Gui`** | `0x21` | `0x20` | `0x22` | `0x429af0` | Refreshes all the counters on the right side of the screen and many HUD elements. Might also be responsible for boss dialogue? I dunno it's very big leave me alone |
    | **`AnmManager`** (2) | `0x22` | `0x21` | `0x23` | `0x46e710` | This is `on_tick__ui`. It advances ANM VMs in layers 0 to 41 and rebuilds their layer lists. |
    | **`ReplayManager`** (2) | `0x23` | `0x22` | `0x24` | `0x448e40` | Implements speedup while holding Ctrl on replay playback. |
    3 changes: 2 additions & 1 deletion 4_revisions.md
    Original file line number Diff line number Diff line change
    @@ -29,4 +29,5 @@ Shared

    ## May 7 2020

    - Huge update after looking at `on_tick` and `on_draw` functions. Differences between 500-503 are now understood.
    - Huge update after looking at `on_tick` and `on_draw` functions. Differences between 500-503 are now understood.
    - I also added a giant table of `on_tick` function descriptions because fuggit.
  9. ExpHP revised this gist May 23, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 1_anm-parser.md
    Original file line number Diff line number Diff line change
    @@ -246,10 +246,10 @@ If you see *(unknown)* it means I did not spot any usage of it in this function.
    + Usage at `0x46757f`
    * **`534:(5-7)`**: *(unknown)*
    + At `0x46e783`, these anms will only be rendered if these flags are `0b00`.
    + When an ANM file is about to be unloaded, a function is called to set this to `0b01` on every ANM VM using that ANM file.
    + Usage at `0x4684ce`
    + Usage at `0x46e3b9`
    + Set to `0b10` at `0x46e6df`
    + Set to `0b01` at `0x46f1ea`, `0x46f2c2` and more.
    * **`534:7`**:
    + Set by 424 `autoRotate`
    + Usage at `0x41d414`.
  10. ExpHP revised this gist May 22, 2020. 1 changed file with 32 additions and 29 deletions.
    61 changes: 32 additions & 29 deletions 3_bonus_on-tick.md
    Original file line number Diff line number Diff line change
    @@ -2,32 +2,35 @@

    As a bonus, since I looked at all the `on_draw`s, why not look at all of the `on_tick`s? It's useful knowledge to know the order in which things occur:

    | `this` | Priority | Address | Notes |
    | --- | --- | --- |:--- |
    | **`0x4c10d0`** | `0x01` | `0x43b3d0` | Reads raw keyboard input. Supervises threads? Does D3D... stuff. Switches gamemodes. |
    | **`Thread63c`** | `0x03` | `0x43b290` | Checks the configured game resolution and... lolidunno |
    | **`AsciiManager`** | `0x04` | `0x408070` | Simply ticks down `remaining_time` (`+0x12c`) fields on strings and deletes expired ones. |
    | **`MainMenuThread`** | `0x06` | `0x44af80` | Allows navigating the main menu. |
    | **`AnmManager`** | `0x09` | `0x46e710` | This is `on_tick__ui`. It advances ANM VMs in layers 36 to 42 and rebuilds their layer lists. |
    | **`Global3f4`** | `0x0a` | `0x43e3f0` | Related to the Pause menu. |
    | **`HelpManual`** | `0x0b` | `0x401300` | Responds to keyboard input while the help menu is open. |
    | **`ThreadB4`** | `0x0f` | `0x42db70` | I think this object is the main game thread, but it doesn't have much work to do thanks to everything else. **When the game is paused, this returns `3`, telling the game not to run the rest of the `on_tick` functions.**|
    | **`ReplayManager`** | `0x10` | `0x448e30` or <br/> `0x447fd0` | One of these functions is used when recording replays, the other is used when playing them back. Both are responsible for setting the game INPUT globals. |
    | **`Stage`** | `0x11` | `0x40a7a0` | Plays STD script, does... things! Things it does! |
    | **`Unknown40`** | `0x13` | Various | Numerous things create these objects, such as ECL `screenShake`, and they have different `on_tick`s. |
    | **`AsciiPopups`** | `0x14` | `0x449ea0` | Updates those tiny little score, PIV, power and graze popup texts written in kanji numerals. |
    | **`Player`** | `0x16` | `0x442560` | **HUGE.** Watches input, moves, initiates bombs, shoots, moves player bullets, precomputes hurtbox... |
    | **`ShotType`** | `0x18` | `0x40da60` | Character. Runs per-tick logic of a bomb if the player is using one. |
    | **`ShotType`** | `0x19` | `0x40da60` | Subseason. Same but for releases. |
    | **`EnemyManager`** | `0x1a` | `0x41af44` | For each enemy, runs ECL, takes damage from the Player, maybe kills the player, and lots, lots more. |
    | **`LaserManager`** | `0x1b` | `0x431330` | Runs game logic for each laser, similar to bullets. |
    | **`BulletManager`** | `0x1c` | `0x412c50` | Moves enemy bullets. Check graze conditions, maybe kill the player. |
    | **`ItemManager`** | `0x1d` | `0x4308f0` | Moves items, checks for PoC/autocollect/attraction/pickup, performs item pickup effects. |
    | **`Spellcard`** | `0x1e` | `0x417ee0` | Messes with anms, updates spell bonus, checks for bomb usage. |
    | **`Global2020`** | `0x1f` | `0x418ab0` | Scans an array of anm ids at `this+0x1c` and replaces them with `0` if the ANM VMs cannot be found. 🤷 |
    | **`Gui`** | `0x20` | `0x429af0` | Refreshes all the counters on the right side of the screen and many HUD elements. Might also be responsible for boss dialogue? I dunno it's very big leave me alone |
    | **`AnmManager`** | `0x21` | `0x46e710` | This is `on_tick__ui`. It advances ANM VMs in layers 0 to 41 and rebuilds their layer lists. |
    | **`ReplayManager`** | `0x22` | `0x448e40` | Implements speedup while holding Ctrl on replay playback. |
    | **`Ending`** | `0x23` | `0x4196c0` | Shows the ending and staff roll. |

    TH17 is sure to have some differences. (for instance, TH17 has no subseason ShotType, but it has a TokenManager, so some ids are surely shifted).
    | `this` | TH15<br>Prio. | TH16<br>Prio. | TH17<br>Prio. | TH16<br>Addr. | Notes |
    | --- | --- | --- | --- | --- |:--- |
    | **Some D3D thing** | `0x01` | `0x01` | `0x01` | `0x43b3d0` | Reads raw keyboard input. Supervises threads? Does D3D... stuff. Switches gamemodes. |
    | **`Thread63c`** | `0x03` | `0x03` | `0x03` | `0x43b290` | Checks the configured game resolution and... lolidunno |
    | **`AsciiManager`** | `0x04` | `0x04` | `0x05` | `0x408070` | Simply ticks down `remaining_time` (`+0x12c` in TH16) fields on strings and deletes expired ones. |
    | **`DebugSprtView`** | `0x05` | | | | |
    | **`DebugSptTest`** | `0x05` | | | | |
    | **`MainMenuThread`** | `0x06` | `0x06` | `0x07` | `0x44af80` | Allows navigating the main menu. |
    | **`DebugSoundTest`** | `0x08` | | | | |
    | **`AnmManager`** (1) | `0x09` | `0x09` | `0x0a` | `0x46e710` | This is `on_tick__ui`. It advances ANM VMs in layers 36 to 42 and rebuilds their layer lists. |
    | **`PauseMenu`** | `0x0a` | `0x0a` | `0x0b` | `0x43e3f0` | Implements Pause and Game Over menu. |
    | **`HelpManual`** | `0x0b` | `0x0b` | `0x0c` | `0x401300` | Responds to keyboard input while the help menu is open. |
    | **`TrophyManager`** | | | `0x0e` | N/A | |
    | **`GameThread`** | `0x0f` | `0x0f` | `0x10` | `0x42db70` | Appears to be responsible for stage transitions and Stage/Game clear bonuses at stage end. **When the game is paused, this returns `3`, telling the game not to run the rest of the `on_tick` functions.**|
    | **`ReplayManager`** (1) | `0x10` | `0x10` | `0x11` | `0x448e30` or <br/> `0x447fd0` | One of these functions is used when recording replays, the other is used when playing them back. Both are responsible for setting the game INPUT globals. |
    | **`Stage`** | `0x11` | `0x11` | `0x12` | `0x40a7a0` | Plays STD script, does... things! Things it does! |
    | **`ScreenEffect`** | `0x14` | `0x13` | `0x14` | Various | There's many of these. They do things like screen shake and fades to black. |
    | **`PopupManager`** | `0x15` | `0x14` | `0x15` | `0x449ea0` | Updates those tiny little score, PIV, power and graze popup texts written in kanji numerals. |
    | **`Player`** | `0x17` | `0x16` | `0x17` | `0x442560` | **HUGE.** Watches input, moves, initiates bombs, shoots, moves player bullets, precomputes hurtbox... |
    | **`(pl0x.sht) ShotType`** | `0x19` | `0x18` | `0x19` | `0x40da60` | Runs per-tick logic of a bomb if the player is using one. |
    | **`(pl0xsub.sht) ShotType`** | | `0x19` | | `0x40da60` | Same but for season releases. |
    | **`EnemyManager`** | `0x1a` | `0x1a` | `0x1b` | `0x41af44` | For each enemy, runs ECL, takes damage from the Player, maybe kills the player, and lots, lots more. |
    | **`LaserManager`** | `0x1b` | `0x1b` | `0x1c` | `0x431330` | Runs game logic for each laser, similar to bullets. |
    | **`BulletManager`** | `0x1c` | `0x1c` | `0x1d` | `0x412c50` | Moves enemy bullets. Check graze conditions, maybe kill the player. |
    | **`ItemManager`** | `0x1d` | `0x1d` | `0x1e` | `0x4308f0` | Moves items, checks for PoC/autocollect/attraction/pickup, performs item pickup effects. |
    | **`GoastManager`** | | | `0x1f` | N/A | Makes tokens move. Not sure if this is responsible for otter hypers, or if that's done in `Player::on_tick`. |
    | **`Spellcard`** | `0x1f` | `0x1e` | `0x20` | `0x417ee0` | Messes with anms, updates spell bonus, checks for bomb usage. |
    | **`Global2020`** | `0x20` | `0x1f` | `0x21` | `0x418ab0` | Scans an array of anm ids at `this+0x1c` and replaces them with `0` if the ANM VMs cannot be found. 🤷 |
    | **`Gui`** | `0x21` | `0x20` | `0x22` | `0x429af0` | Refreshes all the counters on the right side of the screen and many HUD elements. Might also be responsible for boss dialogue? I dunno it's very big leave me alone |
    | **`AnmManager`** (2) | `0x22` | `0x21` | `0x23` | `0x46e710` | This is `on_tick__ui`. It advances ANM VMs in layers 0 to 41 and rebuilds their layer lists. |
    | **`ReplayManager`** (2) | `0x23` | `0x22` | `0x24` | `0x448e40` | Implements speedup while holding Ctrl on replay playback. |
    | **`Ending`** | `0x24` | `0x23` | `0x25` | `0x4196c0` | Shows the ending and staff roll. |
  11. ExpHP revised this gist May 16, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 3_bonus_on-tick.md
    Original file line number Diff line number Diff line change
    @@ -28,6 +28,6 @@ As a bonus, since I looked at all the `on_draw`s, why not look at all of the `on
    | **`Gui`** | `0x20` | `0x429af0` | Refreshes all the counters on the right side of the screen and many HUD elements. Might also be responsible for boss dialogue? I dunno it's very big leave me alone |
    | **`AnmManager`** | `0x21` | `0x46e710` | This is `on_tick__ui`. It advances ANM VMs in layers 0 to 41 and rebuilds their layer lists. |
    | **`ReplayManager`** | `0x22` | `0x448e40` | Implements speedup while holding Ctrl on replay playback. |
    | **`Global24`** | `0x23` | `0x4196c0` | Somewhat involved. I think this object might represent the Ending? |
    | **`Ending`** | `0x23` | `0x4196c0` | Shows the ending and staff roll. |

    TH17 is sure to have some differences. (for instance, TH17 has no subseason ShotType, but it has a TokenManager, so some ids are surely shifted).
  12. ExpHP revised this gist May 16, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions 3_bonus_on-tick.md
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ As a bonus, since I looked at all the `on_draw`s, why not look at all of the `on
    | **`Global3f4`** | `0x0a` | `0x43e3f0` | Related to the Pause menu. |
    | **`HelpManual`** | `0x0b` | `0x401300` | Responds to keyboard input while the help menu is open. |
    | **`ThreadB4`** | `0x0f` | `0x42db70` | I think this object is the main game thread, but it doesn't have much work to do thanks to everything else. **When the game is paused, this returns `3`, telling the game not to run the rest of the `on_tick` functions.**|
    | **`Global31c`** | `0x10` | `0x448e30` or <br/> `0x447fd0` | Input related. My guess is this sets the global input variables for the game world. I imagine that the reason for having two possible callbacks is because one is for replays. |
    | **`ReplayManager`** | `0x10` | `0x448e30` or <br/> `0x447fd0` | One of these functions is used when recording replays, the other is used when playing them back. Both are responsible for setting the game INPUT globals. |
    | **`Stage`** | `0x11` | `0x40a7a0` | Plays STD script, does... things! Things it does! |
    | **`Unknown40`** | `0x13` | Various | Numerous things create these objects, such as ECL `screenShake`, and they have different `on_tick`s. |
    | **`AsciiPopups`** | `0x14` | `0x449ea0` | Updates those tiny little score, PIV, power and graze popup texts written in kanji numerals. |
    @@ -27,7 +27,7 @@ As a bonus, since I looked at all the `on_draw`s, why not look at all of the `on
    | **`Global2020`** | `0x1f` | `0x418ab0` | Scans an array of anm ids at `this+0x1c` and replaces them with `0` if the ANM VMs cannot be found. 🤷 |
    | **`Gui`** | `0x20` | `0x429af0` | Refreshes all the counters on the right side of the screen and many HUD elements. Might also be responsible for boss dialogue? I dunno it's very big leave me alone |
    | **`AnmManager`** | `0x21` | `0x46e710` | This is `on_tick__ui`. It advances ANM VMs in layers 0 to 41 and rebuilds their layer lists. |
    | **`Global31c`** | `0x22` | `0x448e40` | This code has no side-effects. Strange. |
    | **`ReplayManager`** | `0x22` | `0x448e40` | Implements speedup while holding Ctrl on replay playback. |
    | **`Global24`** | `0x23` | `0x4196c0` | Somewhat involved. I think this object might represent the Ending? |

    TH17 is sure to have some differences. (for instance, TH17 has no subseason ShotType, but it has a TokenManager, so some ids are surely shifted).
  13. ExpHP revised this gist May 9, 2020. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion 2_anm_update_funcs.md
    Original file line number Diff line number Diff line change
    @@ -122,4 +122,6 @@ Most of the non-`AnmManager` `on_draw` functions are **not** responsible for dra
    * **`AnmManager`** at priority 0x50: Renders **UI layer 41**
    * **`AsciiManager`** at priority 0x51: Changes coordinate system. Draws **ASCII group 1**
    * **`AnmManager`** at priority 0x52: Renders **layer 31**
    * **`AnmManager`** at priority 0x53: Renders **UI layer 42**
    * **`AnmManager`** at priority 0x53: Renders **UI layer 42**

    Where's layer 33? Noooobody knooooooooows 👻
  14. ExpHP revised this gist May 9, 2020. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions 2_anm_update_funcs.md
    Original file line number Diff line number Diff line change
    @@ -118,9 +118,8 @@ Most of the non-`AnmManager` `on_draw` functions are **not** responsible for dra
    * **`(Unknown)`** at priority 0x4a. (I think this is the pause menu or game over screen)
    * **`AnmManager`** at priority 0x4d: Renders **layer 29**
    * **`AnmManager`** at priority 0x4e: Renders **UI layer 40**
    * **`AnmManager`** at priority 0x4f: Renders **layer 30**
    * **`AnmManager`** at priority 0x50: Renders **UI layer 41**
    * **`AsciiManager`** at priority 0x51: Changes coordinate system. Draws **ASCII group 1**
    * **`AnmManager`** at priority 0x52: Renders **layer 31**
    * **`AnmManager`** at priority 0x53: Renders **UI layer 42**

    Where's layer 30? Noooobody knooooooooows 👻
    * **`AnmManager`** at priority 0x53: Renders **UI layer 42**
  15. ExpHP revised this gist May 9, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 3_bonus_on-tick.md
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@ As a bonus, since I looked at all the `on_draw`s, why not look at all of the `on

    | `this` | Priority | Address | Notes |
    | --- | --- | --- |:--- |
    | **`0x4c10d0`** | `0x01` | `0x43b3d0` | Reads raw keyboard input. Supervises threads? Does D3D... stuff. |
    | **`0x4c10d0`** | `0x01` | `0x43b3d0` | Reads raw keyboard input. Supervises threads? Does D3D... stuff. Switches gamemodes. |
    | **`Thread63c`** | `0x03` | `0x43b290` | Checks the configured game resolution and... lolidunno |
    | **`AsciiManager`** | `0x04` | `0x408070` | Simply ticks down `remaining_time` (`+0x12c`) fields on strings and deletes expired ones. |
    | **`MainMenuThread`** | `0x06` | `0x44af80` | Allows navigating the main menu. |
  16. ExpHP revised this gist May 8, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 3_bonus_on-tick.md
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ As a bonus, since I looked at all the `on_draw`s, why not look at all of the `on
    | **`AnmManager`** | `0x09` | `0x46e710` | This is `on_tick__ui`. It advances ANM VMs in layers 36 to 42 and rebuilds their layer lists. |
    | **`Global3f4`** | `0x0a` | `0x43e3f0` | Related to the Pause menu. |
    | **`HelpManual`** | `0x0b` | `0x401300` | Responds to keyboard input while the help menu is open. |
    | **`ThreadB4`** | `0x0f` | `0x42db70` | I think this object is the main game thread, but it doesn't have much work to do thanks to everything else. |
    | **`ThreadB4`** | `0x0f` | `0x42db70` | I think this object is the main game thread, but it doesn't have much work to do thanks to everything else. **When the game is paused, this returns `3`, telling the game not to run the rest of the `on_tick` functions.**|
    | **`Global31c`** | `0x10` | `0x448e30` or <br/> `0x447fd0` | Input related. My guess is this sets the global input variables for the game world. I imagine that the reason for having two possible callbacks is because one is for replays. |
    | **`Stage`** | `0x11` | `0x40a7a0` | Plays STD script, does... things! Things it does! |
    | **`Unknown40`** | `0x13` | Various | Numerous things create these objects, such as ECL `screenShake`, and they have different `on_tick`s. |
  17. ExpHP revised this gist May 8, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 3_bonus_on-tick.md
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ As a bonus, since I looked at all the `on_draw`s, why not look at all of the `on
    | **`ItemManager`** | `0x1d` | `0x4308f0` | Moves items, checks for PoC/autocollect/attraction/pickup, performs item pickup effects. |
    | **`Spellcard`** | `0x1e` | `0x417ee0` | Messes with anms, updates spell bonus, checks for bomb usage. |
    | **`Global2020`** | `0x1f` | `0x418ab0` | Scans an array of anm ids at `this+0x1c` and replaces them with `0` if the ANM VMs cannot be found. 🤷 |
    | **`Gui`** | `0x20` | `0x429af0` | Refreshes all the counters on the right side of the screen and many HUD elements. Might also be responsible for boss dialogue? I dunno |
    | **`Gui`** | `0x20` | `0x429af0` | Refreshes all the counters on the right side of the screen and many HUD elements. Might also be responsible for boss dialogue? I dunno it's very big leave me alone |
    | **`AnmManager`** | `0x21` | `0x46e710` | This is `on_tick__ui`. It advances ANM VMs in layers 0 to 41 and rebuilds their layer lists. |
    | **`Global31c`** | `0x22` | `0x448e40` | This code has no side-effects. Strange. |
    | **`Global24`** | `0x23` | `0x4196c0` | Somewhat involved. I think this object might represent the Ending? |
  18. ExpHP revised this gist May 8, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 3_bonus_on-tick.md
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ As a bonus, since I looked at all the `on_draw`s, why not look at all of the `on
    | **`ItemManager`** | `0x1d` | `0x4308f0` | Moves items, checks for PoC/autocollect/attraction/pickup, performs item pickup effects. |
    | **`Spellcard`** | `0x1e` | `0x417ee0` | Messes with anms, updates spell bonus, checks for bomb usage. |
    | **`Global2020`** | `0x1f` | `0x418ab0` | Scans an array of anm ids at `this+0x1c` and replaces them with `0` if the ANM VMs cannot be found. 🤷 |
    | **`Gui`** | `0x20` | `0x429af0` | Refreshes all the counters on the right side of the screen and many HUD elements. Might also be responsible for dialogue? I dunno |
    | **`Gui`** | `0x20` | `0x429af0` | Refreshes all the counters on the right side of the screen and many HUD elements. Might also be responsible for boss dialogue? I dunno |
    | **`AnmManager`** | `0x21` | `0x46e710` | This is `on_tick__ui`. It advances ANM VMs in layers 0 to 41 and rebuilds their layer lists. |
    | **`Global31c`** | `0x22` | `0x448e40` | This code has no side-effects. Strange. |
    | **`Global24`** | `0x23` | `0x4196c0` | Somewhat involved. I think this object might represent the Ending? |
  19. ExpHP revised this gist May 8, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 3_bonus_on-tick.md
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ As a bonus, since I looked at all the `on_draw`s, why not look at all of the `on
    | **`ItemManager`** | `0x1d` | `0x4308f0` | Moves items, checks for PoC/autocollect/attraction/pickup, performs item pickup effects. |
    | **`Spellcard`** | `0x1e` | `0x417ee0` | Messes with anms, updates spell bonus, checks for bomb usage. |
    | **`Global2020`** | `0x1f` | `0x418ab0` | Scans an array of anm ids at `this+0x1c` and replaces them with `0` if the ANM VMs cannot be found. 🤷 |
    | **`Gui`** | `0x20` | `0x429af0` | Extremely involved. |
    | **`Gui`** | `0x20` | `0x429af0` | Refreshes all the counters on the right side of the screen and many HUD elements. Might also be responsible for dialogue? I dunno |
    | **`AnmManager`** | `0x21` | `0x46e710` | This is `on_tick__ui`. It advances ANM VMs in layers 0 to 41 and rebuilds their layer lists. |
    | **`Global31c`** | `0x22` | `0x448e40` | This code has no side-effects. Strange. |
    | **`Global24`** | `0x23` | `0x4196c0` | Somewhat involved. I think this object might represent the Ending? |
  20. ExpHP revised this gist May 8, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 3_bonus_on-tick.md
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ As a bonus, since I looked at all the `on_draw`s, why not look at all of the `on
    | **`Global3f4`** | `0x0a` | `0x43e3f0` | Related to the Pause menu. |
    | **`HelpManual`** | `0x0b` | `0x401300` | Responds to keyboard input while the help menu is open. |
    | **`ThreadB4`** | `0x0f` | `0x42db70` | I think this object is the main game thread, but it doesn't have much work to do thanks to everything else. |
    | **`Global31c`** | `0x10` | `0x448e30` or <br/> `0x447fd0` | Input related. |
    | **`Global31c`** | `0x10` | `0x448e30` or <br/> `0x447fd0` | Input related. My guess is this sets the global input variables for the game world. I imagine that the reason for having two possible callbacks is because one is for replays. |
    | **`Stage`** | `0x11` | `0x40a7a0` | Plays STD script, does... things! Things it does! |
    | **`Unknown40`** | `0x13` | Various | Numerous things create these objects, such as ECL `screenShake`, and they have different `on_tick`s. |
    | **`AsciiPopups`** | `0x14` | `0x449ea0` | Updates those tiny little score, PIV, power and graze popup texts written in kanji numerals. |
  21. ExpHP revised this gist May 8, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 3_bonus_on-tick.md
    Original file line number Diff line number Diff line change
    @@ -24,7 +24,7 @@ As a bonus, since I looked at all the `on_draw`s, why not look at all of the `on
    | **`BulletManager`** | `0x1c` | `0x412c50` | Moves enemy bullets. Check graze conditions, maybe kill the player. |
    | **`ItemManager`** | `0x1d` | `0x4308f0` | Moves items, checks for PoC/autocollect/attraction/pickup, performs item pickup effects. |
    | **`Spellcard`** | `0x1e` | `0x417ee0` | Messes with anms, updates spell bonus, checks for bomb usage. |
    | **`Global2020`** | `0x1f` | `0x418ab0` | Scans an array of anm ids at `this+0x1c` and replaces them with `0` if the ANM VMs cannot be found. found. |
    | **`Global2020`** | `0x1f` | `0x418ab0` | Scans an array of anm ids at `this+0x1c` and replaces them with `0` if the ANM VMs cannot be found. 🤷 |
    | **`Gui`** | `0x20` | `0x429af0` | Extremely involved. |
    | **`AnmManager`** | `0x21` | `0x46e710` | This is `on_tick__ui`. It advances ANM VMs in layers 0 to 41 and rebuilds their layer lists. |
    | **`Global31c`** | `0x22` | `0x448e40` | This code has no side-effects. Strange. |
  22. ExpHP revised this gist May 8, 2020. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions 3_bonus_on-tick.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    # TH16 `on_tick` table

    As a bonus, since I looked at all the `on_draw`s, why not look at all of the `on_tick`s? It's useful knowledge to know the order in which things occur:

    | `this` | Priority | Address | Notes |
  23. ExpHP revised this gist May 8, 2020. 1 changed file with 27 additions and 27 deletions.
    54 changes: 27 additions & 27 deletions 3_bonus_on-tick.md
    Original file line number Diff line number Diff line change
    @@ -1,31 +1,31 @@
    As a bonus, since I looked at all the `on_draw`s, why not look at all of the `on_tick`s? It's useful knowledge to know the order in which things occur:

    `this` | Priority | Address | Notes
    === | === | === |===
    **`0x4c10d0`** | `0x01` | `0x43b3d0` | Reads raw keyboard input. Supervises threads? Does D3D... stuff.
    **`Thread63c`** | `0x03` | `0x43b290` | Checks the configured game resolution and... lolidunno
    **`AsciiManager`** | `0x04` | `0x408070` | Simply ticks down `remaining_time` (`+0x12c`) fields on strings and deletes expired ones.
    **`MainMenuThread`** | `0x06` | `0x44af80` | Allows navigating the main menu.
    **`AnmManager`** | `0x09` | `0x46e710` | This is `on_tick__ui`. It advances ANM VMs in layers 36 to 42 and rebuilds their layer lists.
    **`Global3f4`** | `0x0a` | `0x43e3f0` | Related to the Pause menu.
    **`HelpManual`** | `0x0b` | `0x401300` | Responds to keyboard input while the help menu is open.
    **`ThreadB4`** | `0x0f` | `0x42db70` | I think this object is the main game thread, but it doesn't have much work to do thanks to everything else.
    **`Global31c`** | `0x10` | `0x448e30` or <br/> `0x447fd0` | Input related.
    **`Stage`** | `0x11` | `0x40a7a0` | Plays STD script, does... things! Things it does!
    **`Unknown40`** | `0x13` | Various | Numerous things create these objects, such as ECL `screenShake`, and they have different `on_tick`s.
    **`AsciiPopups`** | `0x14` | `0x449ea0` | Updates those tiny little score, PIV, power and graze popup texts written in kanji numerals.
    **`Player`** | `0x16` | `0x442560` | **HUGE.** Watches input, moves, initiates bombs, shoots, moves player bullets, precomputes hurtbox...
    **`ShotType`** | `0x18` | `0x40da60` | Character. Runs per-tick logic of a bomb if the player is using one.
    **`ShotType`** | `0x19` | `0x40da60` | Subseason. Same but for releases.
    **`EnemyManager`** | `0x1a` | `0x41af44` | For each enemy, runs ECL, takes damage from the Player, maybe kills the player, and lots, lots more.
    **`LaserManager`** | `0x1b` | `0x431330` | Runs game logic for each laser, similar to bullets.
    **`BulletManager`** | `0x1c` | `0x412c50` | Moves enemy bullets. Check graze conditions, maybe kill the player.
    **`ItemManager`** | `0x1d` | `0x4308f0` | Moves items, checks for PoC/autocollect/attraction/pickup, performs item pickup effects.
    **`Spellcard`** | `0x1e` | `0x417ee0` | Messes with anms, updates spell bonus, checks for bomb usage.
    **`Global2020`** | `0x1f` | `0x418ab0` | Scans an array of anm ids at `this+0x1c` and replaces them with `0` if the ANM VMs cannot be found. found.
    **`Gui`** | `0x20` | `0x429af0` | Extremely involved.
    **`AnmManager`** | `0x21` | `0x46e710` | This is `on_tick__ui`. It advances ANM VMs in layers 0 to 41 and rebuilds their layer lists.
    **`Global31c`** | `0x22` | `0x448e40` | This code has no side-effects. Strange.
    **`Global24`** | `0x23` | `0x4196c0` | Somewhat involved. I think this object might represent the Ending?
    | `this` | Priority | Address | Notes |
    | --- | --- | --- |:--- |
    | **`0x4c10d0`** | `0x01` | `0x43b3d0` | Reads raw keyboard input. Supervises threads? Does D3D... stuff. |
    | **`Thread63c`** | `0x03` | `0x43b290` | Checks the configured game resolution and... lolidunno |
    | **`AsciiManager`** | `0x04` | `0x408070` | Simply ticks down `remaining_time` (`+0x12c`) fields on strings and deletes expired ones. |
    | **`MainMenuThread`** | `0x06` | `0x44af80` | Allows navigating the main menu. |
    | **`AnmManager`** | `0x09` | `0x46e710` | This is `on_tick__ui`. It advances ANM VMs in layers 36 to 42 and rebuilds their layer lists. |
    | **`Global3f4`** | `0x0a` | `0x43e3f0` | Related to the Pause menu. |
    | **`HelpManual`** | `0x0b` | `0x401300` | Responds to keyboard input while the help menu is open. |
    | **`ThreadB4`** | `0x0f` | `0x42db70` | I think this object is the main game thread, but it doesn't have much work to do thanks to everything else. |
    | **`Global31c`** | `0x10` | `0x448e30` or <br/> `0x447fd0` | Input related. |
    | **`Stage`** | `0x11` | `0x40a7a0` | Plays STD script, does... things! Things it does! |
    | **`Unknown40`** | `0x13` | Various | Numerous things create these objects, such as ECL `screenShake`, and they have different `on_tick`s. |
    | **`AsciiPopups`** | `0x14` | `0x449ea0` | Updates those tiny little score, PIV, power and graze popup texts written in kanji numerals. |
    | **`Player`** | `0x16` | `0x442560` | **HUGE.** Watches input, moves, initiates bombs, shoots, moves player bullets, precomputes hurtbox... |
    | **`ShotType`** | `0x18` | `0x40da60` | Character. Runs per-tick logic of a bomb if the player is using one. |
    | **`ShotType`** | `0x19` | `0x40da60` | Subseason. Same but for releases. |
    | **`EnemyManager`** | `0x1a` | `0x41af44` | For each enemy, runs ECL, takes damage from the Player, maybe kills the player, and lots, lots more. |
    | **`LaserManager`** | `0x1b` | `0x431330` | Runs game logic for each laser, similar to bullets. |
    | **`BulletManager`** | `0x1c` | `0x412c50` | Moves enemy bullets. Check graze conditions, maybe kill the player. |
    | **`ItemManager`** | `0x1d` | `0x4308f0` | Moves items, checks for PoC/autocollect/attraction/pickup, performs item pickup effects. |
    | **`Spellcard`** | `0x1e` | `0x417ee0` | Messes with anms, updates spell bonus, checks for bomb usage. |
    | **`Global2020`** | `0x1f` | `0x418ab0` | Scans an array of anm ids at `this+0x1c` and replaces them with `0` if the ANM VMs cannot be found. found. |
    | **`Gui`** | `0x20` | `0x429af0` | Extremely involved. |
    | **`AnmManager`** | `0x21` | `0x46e710` | This is `on_tick__ui`. It advances ANM VMs in layers 0 to 41 and rebuilds their layer lists. |
    | **`Global31c`** | `0x22` | `0x448e40` | This code has no side-effects. Strange. |
    | **`Global24`** | `0x23` | `0x4196c0` | Somewhat involved. I think this object might represent the Ending? |

    TH17 is sure to have some differences. (for instance, TH17 has no subseason ShotType, but it has a TokenManager, so some ids are surely shifted).
  24. ExpHP revised this gist May 8, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 3_bonus_on-tick.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    As a bonus, since I looked at all the `on_draw`s, why not look at all of the `on_tick`s? It's useful knowledge to know the order in which things occur:

    `this` | Priority | Address | Notes
    --- | --- | --- | ---
    === | === | === |===
    **`0x4c10d0`** | `0x01` | `0x43b3d0` | Reads raw keyboard input. Supervises threads? Does D3D... stuff.
    **`Thread63c`** | `0x03` | `0x43b290` | Checks the configured game resolution and... lolidunno
    **`AsciiManager`** | `0x04` | `0x408070` | Simply ticks down `remaining_time` (`+0x12c`) fields on strings and deletes expired ones.
  25. ExpHP revised this gist May 8, 2020. 1 changed file with 25 additions and 25 deletions.
    50 changes: 25 additions & 25 deletions 3_bonus_on-tick.md
    Original file line number Diff line number Diff line change
    @@ -2,30 +2,30 @@ As a bonus, since I looked at all the `on_draw`s, why not look at all of the `on

    `this` | Priority | Address | Notes
    --- | --- | --- | ---
    **`0x4c10d0`** | `0x01` | `0x43b3d0` | Reads raw keyboard input. Supervises threads? Does D3D... stuff.
    **`Thread63c`** | `0x03` | `0x43b290` | Checks the configured game resolution and... lolidunno
    **`AsciiManager`** | `0x04` | `0x408070` | Simply ticks down `remaining_time` (`+0x12c`) fields on strings and deletes expired ones.
    **`MainMenuThread`** | `0x06` | `0x44af80` | Allows navigating the main menu.
    **`AnmManager`** | `0x09` | `0x46e710` | This is `on_tick__ui`. It advances ANM VMs in layers 36 to 42 and rebuilds their layer lists.
    **`Global3f4`** | `0x0a` | `0x43e3f0` | Related to the Pause menu.
    **`HelpManual`** | `0x0b` | `0x401300` | Responds to keyboard input while the help menu is open.
    **`ThreadB4`** | `0x0f` | `0x42db70` | I think this object is the main game thread, but it doesn't have much work to do thanks to everything else.
    **`Global31c`** | `0x10` | `0x448e30` or <br/> `0x447fd0` | Input related.
    **`Stage`** | `0x11` | `0x40a7a0` | Plays STD script, does... things! Things it does!
    **`Unknown40`** | `0x13` | Various | Numerous things create these objects, such as ECL `screenShake`, and they have different `on_tick`s.
    **`AsciiPopups`** | `0x14` | `0x449ea0` | Updates those tiny little score, PIV, power and graze popup texts written in kanji numerals.
    **`Player`** | `0x16` | `0x442560` | **HUGE.** Watches input, moves, initiates bombs, shoots, moves player bullets, precomputes hurtbox...
    **`ShotType`** | `0x18` | `0x40da60` | Character. Runs per-tick logic of a bomb if the player is using one.
    **`ShotType`** | `0x19` | `0x40da60` | Subseason. Same but for releases.
    **`EnemyManager`** | `0x1a` | `0x41af44` | For each enemy, runs ECL, takes damage from the Player, maybe kills the player, and lots, lots more.
    **`LaserManager`** | `0x1b` | `0x431330` | Runs game logic for each laser, similar to bullets.
    **`BulletManager`** | `0x1c` | `0x412c50` | Moves enemy bullets. Check graze conditions, maybe kill the player.
    **`ItemManager`** | `0x1d` | `0x4308f0` | Moves items, checks for PoC/autocollect/attraction/pickup, performs item pickup effects.
    **`Spellcard`** | `0x1e` | `0x417ee0` | Messes with anms, updates spell bonus, checks for bomb usage.
    **`Global2020`** | `0x1f` | `0x418ab0` | Scans an array of anm ids at `this+0x1c` and replaces them with `0` if the ANM VMs cannot be found. found.
    **`Gui`** | `0x20` | `0x429af0` | Extremely involved.
    **`AnmManager`** | `0x21` | `0x46e710` | This is `on_tick__ui`. It advances ANM VMs in layers 0 to 41 and rebuilds their layer lists.
    **`Global31c`** | `0x22` | `0x448e40` | This code has no side-effects. Strange.
    **`Global24`** | `0x23` | `0x4196c0` | Somewhat involved. I think this object might represent the Ending?
    **`0x4c10d0`** | `0x01` | `0x43b3d0` | Reads raw keyboard input. Supervises threads? Does D3D... stuff.
    **`Thread63c`** | `0x03` | `0x43b290` | Checks the configured game resolution and... lolidunno
    **`AsciiManager`** | `0x04` | `0x408070` | Simply ticks down `remaining_time` (`+0x12c`) fields on strings and deletes expired ones.
    **`MainMenuThread`** | `0x06` | `0x44af80` | Allows navigating the main menu.
    **`AnmManager`** | `0x09` | `0x46e710` | This is `on_tick__ui`. It advances ANM VMs in layers 36 to 42 and rebuilds their layer lists.
    **`Global3f4`** | `0x0a` | `0x43e3f0` | Related to the Pause menu.
    **`HelpManual`** | `0x0b` | `0x401300` | Responds to keyboard input while the help menu is open.
    **`ThreadB4`** | `0x0f` | `0x42db70` | I think this object is the main game thread, but it doesn't have much work to do thanks to everything else.
    **`Global31c`** | `0x10` | `0x448e30` or <br/> `0x447fd0` | Input related.
    **`Stage`** | `0x11` | `0x40a7a0` | Plays STD script, does... things! Things it does!
    **`Unknown40`** | `0x13` | Various | Numerous things create these objects, such as ECL `screenShake`, and they have different `on_tick`s.
    **`AsciiPopups`** | `0x14` | `0x449ea0` | Updates those tiny little score, PIV, power and graze popup texts written in kanji numerals.
    **`Player`** | `0x16` | `0x442560` | **HUGE.** Watches input, moves, initiates bombs, shoots, moves player bullets, precomputes hurtbox...
    **`ShotType`** | `0x18` | `0x40da60` | Character. Runs per-tick logic of a bomb if the player is using one.
    **`ShotType`** | `0x19` | `0x40da60` | Subseason. Same but for releases.
    **`EnemyManager`** | `0x1a` | `0x41af44` | For each enemy, runs ECL, takes damage from the Player, maybe kills the player, and lots, lots more.
    **`LaserManager`** | `0x1b` | `0x431330` | Runs game logic for each laser, similar to bullets.
    **`BulletManager`** | `0x1c` | `0x412c50` | Moves enemy bullets. Check graze conditions, maybe kill the player.
    **`ItemManager`** | `0x1d` | `0x4308f0` | Moves items, checks for PoC/autocollect/attraction/pickup, performs item pickup effects.
    **`Spellcard`** | `0x1e` | `0x417ee0` | Messes with anms, updates spell bonus, checks for bomb usage.
    **`Global2020`** | `0x1f` | `0x418ab0` | Scans an array of anm ids at `this+0x1c` and replaces them with `0` if the ANM VMs cannot be found. found.
    **`Gui`** | `0x20` | `0x429af0` | Extremely involved.
    **`AnmManager`** | `0x21` | `0x46e710` | This is `on_tick__ui`. It advances ANM VMs in layers 0 to 41 and rebuilds their layer lists.
    **`Global31c`** | `0x22` | `0x448e40` | This code has no side-effects. Strange.
    **`Global24`** | `0x23` | `0x4196c0` | Somewhat involved. I think this object might represent the Ending?

    TH17 is sure to have some differences. (for instance, TH17 has no subseason ShotType, but it has a TokenManager, so some ids are surely shifted).
  26. ExpHP revised this gist May 8, 2020. 2 changed files with 31 additions and 0 deletions.
    31 changes: 31 additions & 0 deletions 3_bonus_on-tick.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    As a bonus, since I looked at all the `on_draw`s, why not look at all of the `on_tick`s? It's useful knowledge to know the order in which things occur:

    `this` | Priority | Address | Notes
    --- | --- | --- | ---
    **`0x4c10d0`** | `0x01` | `0x43b3d0` | Reads raw keyboard input. Supervises threads? Does D3D... stuff.
    **`Thread63c`** | `0x03` | `0x43b290` | Checks the configured game resolution and... lolidunno
    **`AsciiManager`** | `0x04` | `0x408070` | Simply ticks down `remaining_time` (`+0x12c`) fields on strings and deletes expired ones.
    **`MainMenuThread`** | `0x06` | `0x44af80` | Allows navigating the main menu.
    **`AnmManager`** | `0x09` | `0x46e710` | This is `on_tick__ui`. It advances ANM VMs in layers 36 to 42 and rebuilds their layer lists.
    **`Global3f4`** | `0x0a` | `0x43e3f0` | Related to the Pause menu.
    **`HelpManual`** | `0x0b` | `0x401300` | Responds to keyboard input while the help menu is open.
    **`ThreadB4`** | `0x0f` | `0x42db70` | I think this object is the main game thread, but it doesn't have much work to do thanks to everything else.
    **`Global31c`** | `0x10` | `0x448e30` or <br/> `0x447fd0` | Input related.
    **`Stage`** | `0x11` | `0x40a7a0` | Plays STD script, does... things! Things it does!
    **`Unknown40`** | `0x13` | Various | Numerous things create these objects, such as ECL `screenShake`, and they have different `on_tick`s.
    **`AsciiPopups`** | `0x14` | `0x449ea0` | Updates those tiny little score, PIV, power and graze popup texts written in kanji numerals.
    **`Player`** | `0x16` | `0x442560` | **HUGE.** Watches input, moves, initiates bombs, shoots, moves player bullets, precomputes hurtbox...
    **`ShotType`** | `0x18` | `0x40da60` | Character. Runs per-tick logic of a bomb if the player is using one.
    **`ShotType`** | `0x19` | `0x40da60` | Subseason. Same but for releases.
    **`EnemyManager`** | `0x1a` | `0x41af44` | For each enemy, runs ECL, takes damage from the Player, maybe kills the player, and lots, lots more.
    **`LaserManager`** | `0x1b` | `0x431330` | Runs game logic for each laser, similar to bullets.
    **`BulletManager`** | `0x1c` | `0x412c50` | Moves enemy bullets. Check graze conditions, maybe kill the player.
    **`ItemManager`** | `0x1d` | `0x4308f0` | Moves items, checks for PoC/autocollect/attraction/pickup, performs item pickup effects.
    **`Spellcard`** | `0x1e` | `0x417ee0` | Messes with anms, updates spell bonus, checks for bomb usage.
    **`Global2020`** | `0x1f` | `0x418ab0` | Scans an array of anm ids at `this+0x1c` and replaces them with `0` if the ANM VMs cannot be found. found.
    **`Gui`** | `0x20` | `0x429af0` | Extremely involved.
    **`AnmManager`** | `0x21` | `0x46e710` | This is `on_tick__ui`. It advances ANM VMs in layers 0 to 41 and rebuilds their layer lists.
    **`Global31c`** | `0x22` | `0x448e40` | This code has no side-effects. Strange.
    **`Global24`** | `0x23` | `0x4196c0` | Somewhat involved. I think this object might represent the Ending?

    TH17 is sure to have some differences. (for instance, TH17 has no subseason ShotType, but it has a TokenManager, so some ids are surely shifted).
    File renamed without changes.
  27. ExpHP revised this gist May 7, 2020. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions 2_anm_update_funcs.md
    Original file line number Diff line number Diff line change
    @@ -91,6 +91,7 @@ Most of the non-`AnmManager` `on_draw` functions are **not** responsible for dra
    * **`AnmManager`** at priority 0x22: Renders **layer 16**
    * **`LaserManager`** at priority 0x23
    * **`AnmManager`** at priority 0x24: Renders **layer 17**
    * **`BulletManager`** at priority 0x25
    * **`AnmManager`** at priority 0x27: Renders **layer 18**
    * **`ShotType`** for player at priority 0x28
    * **`ShotType`** for subseason at priority 0x29
  28. ExpHP revised this gist May 7, 2020. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions 2_anm_update_funcs.md
    Original file line number Diff line number Diff line change
    @@ -121,3 +121,5 @@ Most of the non-`AnmManager` `on_draw` functions are **not** responsible for dra
    * **`AsciiManager`** at priority 0x51: Changes coordinate system. Draws **ASCII group 1**
    * **`AnmManager`** at priority 0x52: Renders **layer 31**
    * **`AnmManager`** at priority 0x53: Renders **UI layer 42**

    Where's layer 30? Noooobody knooooooooows 👻
  29. ExpHP revised this gist May 7, 2020. 1 changed file with 8 additions and 8 deletions.
    16 changes: 8 additions & 8 deletions 2_anm_update_funcs.md
    Original file line number Diff line number Diff line change
    @@ -18,20 +18,20 @@ There are two `on_tick` functions, one for each of the two lists that the differ
    * Runs every drawn frame **of the TH16 window**.
    * Iterates over the list stored at **`AnmManager+0xdc`**.
    * Runs the ANM parser for one frame on each VM.
    * As it is doing so, it rebuilds the per-layer lists for layers `0 <= layer < 36`. (more info about these in `on_draw`)
    * **If the layer is >= 36, the game will forcibly change it into this range:**
    * Layers `36 <= layer <= 42` are mapped to `24 <= layer <= 30` by subtracting 12.
    * Invalid layers (`layer > 42`) are left as is and will likely crash the program.
    * As it is doing so, it rebuilds the per-layer lists for layers `36 <= layer <= 42`. (more info about these in `on_draw`)
    * **The game will forcibly change the layer into this range if it is not already:**
    * Layers `24 <= layer <= 30` are mapped to `36 <= layer <= 42` by adding 12.
    * Layers `0 <= layer < 24` and invalid layers `layer > 42` are all mapped to layer `38`.

    ### `on_tick__world`
    * Has priority `0x21` (runs pretty late; after all game logic).
    * Runs on every frame **of the game world.** (so it **does not** run while paused!)
    * Iterates over the list stored at **`AnmManager+0xe4`**.
    * Runs the ANM parser for one frame on each VM.
    * As it is doing so, it rebuilds the per-layer lists for layers `36 <= layer <= 42`. (more info about these in `on_draw`)
    * **The game will forcibly change the layer into this range if it is not already:**
    * Layers `24 <= layer <= 30` are mapped to `36 <= layer <= 42` by adding 12.
    * Layers `0 <= layer < 24` and invalid layers `layer > 42` are all mapped to layer `38`.
    * As it is doing so, it rebuilds the per-layer lists for layers `0 <= layer < 36`. (more info about these in `on_draw`)
    * **If the layer is >= 36, the game will forcibly change it into this range:**
    * Layers `36 <= layer <= 42` are mapped to `24 <= layer <= 30` by subtracting 12.
    * Invalid layers (`layer > 42`) are left as is and will likely crash the program.

    ### Additional notes:

  30. ExpHP revised this gist May 7, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion 2_anm_update_funcs.md
    Original file line number Diff line number Diff line change
    @@ -47,7 +47,7 @@ Each of the 39 `on_draw` function is responsible for drawing a single layer. So

    ### The `per_layer` lists

    (**NOTE: These details were completely changed in TH17!** I'm not 100% sure what happened yet; he removed the dummy AnmVms and I think the linked lists became doubly-linked? I suspect that this change is responsible for the 8 bytes added to `sizeof(AnmVm)` in TH17)
    (**NOTE: These details were completely changed in TH17!** I'm not 100% sure what happened yet; he removed the dummy AnmVms and I think the linked lists became doubly-linked? I suspect that this change is responsible for the 4 bytes added to `sizeof(AnmVm)` in TH17)

    The per-layer lists are singly-linked lists whose `next` pointers are stored at `AnmVm+0x5a8`. As described earlier, they are reconstructed every frame in the `on_tick` methods, and then iterated over by the `on_draw` methods.