Skip to content

Defining F values based on B values #42

Open
@Rangi42

Description

The hardware.inc convention is for <REG>B_<FIELD> to be a 0-7 bit value, and <REG>F_<FIELD> to be the corresponding mask value. A few examples:

DEF LCDCF_OBJ16   EQU %00000100 ; OBJ Construction
DEF LCDCB_OBJ16   EQU 2 ; OBJ Construction

DEF PADF_START  EQU $08
DEF PADB_START  EQU $3

DEF OAMF_PRI        EQU %10000000 ; Priority
DEF OAMB_PRI        EQU 7 ; Priority

I'd like to make these consistent in one of three ways:

  1. Always use binary, e.g. %00000100.
  2. Always use hex, e.g. $08.
  3. Define the F values in terms of the B values, e.g. DEF OAMF_PRI EQU 1 << OAMB_PRI.

The advantage of option 3 would be avoiding redundancy or mismatch between the values, making the connection obvious.

The advantages of 1 or 2 would be explicitly showing the numeric mask value (although that could still be a comment next to the 1 << B, in either bin or hex).

My own preference is for option 3, but I wanted to get feedback from the maintainers here before PRing anything.

(If that is the preference, I'd even consider going further and having a macro like DEF_FLAG OAMB_PRI EQU 7, OAMF_PRI to reduce the line count.)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions