-
Notifications
You must be signed in to change notification settings - Fork 806
Code cleanup
These are all general issues with the pokecrystal code. Keep an eye out for opportunities to refactor them.
Use the style guide
Reformat code to adhere to STYLE.md. (Converting labels to .snake_case
is one that stands out.)
As of 0.3.7, we have these features that are little-used:
-
~
works for bytes, so we can do~X
instead of$ff ^ X
-
HIGH()
andLOW()
work for constants -
BANK(@)
gets the current bank;BANK("Section Name")
is also valid (some labels can thus be removed) -
\
continues lines, like in C or Python, which could help clean up long macros (trainer
,npctrade
) and implement new ones (like for data/trainers/attributes.asm or data/pokemon/base_stats/*.asm)
Look for UnknownText_*
, UnknownScript_*
, Unknown_*
, and Function_*
.
Most of the time, raw numbers should not exist because there are more meaningful replacements. Examples:
-
BANK(Label)
: Mostly finished for WRAM labels, but still a problem with mobile code. -
SomeLabelEnd - SomeLabel
: Some structs and sub-structs still have hard-coded sizes like this. -
(SomeGFXLabel.End - SomeGFXLabel) / LEN_2BPP_TILE
: pokered and pokegold-spaceworld already do this. -
Bit flags: Use
SOME_BIT_F
constants instead of hard-coding bits 0-7 for thebit
/res
/set
instructions. Find opportunities with:grep -rE --include='*.asm' --exclude-dir=mobile '^\s(bit|res|set) [0-7],'
-
Bit masks: Use
1 << SOME_BIT_F
masks and themaskbits
macro. -
Jumptable indexes: Look for raw values being loaded into
[wJumptableIndex]
.
Text label styles in data/text/
Currently a mixture of Text_*
, *Text
, and BattleText_*
. Likewise for the engine/ labels that just text_jump
to one of them.
-
Curr
->Cur
-
wMapObjects
and friends to be re-formatted towObjectEvents
-
wObjectStructs
and friends to be re-formatted towMapObjects
- Removal of struct macros which include only a partial label definition (e.g.
wNorthMapConnection:: map_connection_struct wNorth
)
Namely determining the purpose of them and when they should be defined.