I've always preferred "$2007" to "PPU_DATA", and I find the latter to be obfuscating rather than the former, but opinions differ. I would say that the NES only has 8 PPU registers. So relative to other systems, the numbers are less difficult to keep in memory.
tepples wrote:I didn't get a chance to make analogous names for the audio regs that caught on.
The PPU registers at least
mostly have a single function per register. This is not really true for half the audio registers. Naming them effectively is not so easy a problem.
I think it was feos_tas that added
these names to FCEUX. I disabled them immediately.
The other thing about the audio registers is most programs hardly ever write an audio register in more than one place in the code. There's a lot less need to have a name for a thing that appears exactly once.
Code: Select all
(PPU_CTRL_NMI_ON | PPU_CTRL_BG_ADDR_0 | PPU_CTRL_SPR_ADDR_1)
vs.
$80
TBH, I find the former obfuscating in its verbosity. $80 as a hex number is very easily remembered as a byte with only the high bit set, and I do easily remember that the high bit of $2000 controls the NMI, as from using that register I find it's the most important bit.
The rest of the bits of $2000 I don't remember. I look them up when I need to use them, and it's really not any kind of problem to do so. I have to interact with them so few times in the code that I see no reason to build verbose constants to help me construct these bitfields. BTW, I very often like to use binary notation like %10000000 instead of $80 for things that are bitfields, but depends on the situation.
Actually, the most likely thing I'd do would probably be to annotate it with a comment, rather than creating bitfield constants:
Code: Select all
%10001010 ; NMI on, nametable $2800
I do, on the other hand have bitfield construction constants for controller reading stuff. PAD_L, PAD_A, PAD_SELECT. Those I find quite useful, as controller bitfield parsing tends to have many cases in a typical program, each with very specialized needs. Very different situation than with $2000 which gets used maybe 3 places in the code. Also, the order of controller bits as left to right or right to left is arbitrary, depending on how you stored the bits as they were read; there's much more need to use defined constants when something is arbitrary or could change. $2000 on the other hand is always $2000.
$2006 and $2007 get used in a lot of places in the code, but for the same reason they're very memorable. Both of them also have very simple function, no bit packing, just a whole byte with one purpose.
$2004 doesn't need a name because you're not going to use it anyway. ;P
Et cetera.
Anyhow, you should use the style that feels effective to you. Lots of people like the defined names for these registers, and they seem to be included by default by Mesen and FCEUX at this point. Some people, like me, feel the opposite. I don't think it's a no brainer that this is the better way to go.