Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ReadNoiseSample design flaw fix #944

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions docs/design_flaws.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ These are parts of the code that do not work *incorrectly*, like [bugs and glitc
- [`ITEM_C3` and `ITEM_DC` break up the continuous sequence of TM items](#item_c3-and-item_dc-break-up-the-continuous-sequence-of-tm-items)
- [Pokédex entry banks are derived from their species IDs](#pokédex-entry-banks-are-derived-from-their-species-ids)
- [Identical sine wave code and data is repeated five times](#identical-sine-wave-code-and-data-is-repeated-five-times)
- [`ReadNoiseSample` makes percussion last one frame longer than it should](#readnoisesample-makes-percussion-last-one-frame-longer-than-it-should)
- [`GetForestTreeFrame` works, but it's still bad](#getforesttreeframe-works-but-its-still-bad)


Expand Down Expand Up @@ -735,6 +736,29 @@ ENDM
**Fix:** Edit [home/sine.asm](https://github.com/pret/pokecrystal/blob/master/home/sine.asm) to contain a single copy of the (co)sine code in bank 0, and call it from those five sites.


## `ReadNoiseSample` makes percussion last one frame longer than it should

In ```ReadNoiseSample```, the first byte is split into a purely cosmetic hi nybble to make importing RBY noise data a matter of copy-paste, and a lo nybble for the length.

All the RBY percussion is already there, and drums that are two or more notes long indicate the same note length structure as in RBY. However, because of the way ```ReadNoiseSample``` stores this first byte, this length is one frame longer than intended, meaning minimum note length is two instead of one. This makes the old drums with two or more notes sound slower than they should be and therefore vice versa for newer songs that utilize this new behavior.

**Fix:**

Edit ```ReadNoiseSample``` in [audio/engine.asm](https://github.com/pret/pokecrystal/blob/master/audio/engine.asm):
```diff
inc de

cp sound_ret_cmd
jr z, .quit

and $f
- inc a
ld [wNoiseSampleDelay], a
```

An example of how Gen II music will sound with this fix/tweak is: https://soundcloud.com/aizakku-horooee/drum-test-ss-aqua


## `GetForestTreeFrame` works, but it's still bad

The routine `GetForestTreeFrame` in [engine/tilesets/tileset_anims.asm](https://github.com/pret/pokecrystal/blob/master/engine/tilesets/tileset_anims.asm) is hilariously inefficient.
Expand Down