-
Notifications
You must be signed in to change notification settings - Fork 22
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
PADF_*
and PADB_*
constants don't represent hardware values
#37
Comments
i dont see the point of constants that.. arent exactly usable unless you store read input states in two separate bytes |
The constants are useful for defining your own without pulling up Pan Docs ( |
I raised this issue on the Discord because I was trying to migrate the LADX disassembly from Although these values don't represent hardware, I do think there's value in utility as well. My hope when originally standardizing this ancient file was that people would use it, for both disassemblies of official games and for homebrew. If this is desirable we could create a second set of constants that have the inverted nybble order. (If we do, I would propose we call them something more agnostic than "SGB" and "GBA" order.) It wouldn't reflect hardware per se, but it would reflect extremely common boilerplate that makes developing for the GB a little less cumbersome. Failing that, I do think we should at least have constants for the input states, for the reasons @aaaaaa123456789 stated. |
Considering the register is called As was mentioned by zlago, I am in favour of a companion file that provides what otherwise becomes boilerplate. Seeing as it seems to make consensus, I'll open an issue for it. |
What's wrong with the names "SGB nibble order" and "GBA nibble order"? They correspond to the behavior of other GB-adjacent Nintendo products, namely the Super Game Boy accessory's ICD2 bridge chip and the Game Boy Advance platform. I imagine that this companion file would include commonly used definitions that are pedantically not directly hardware-related. Instead of having a separate file, would it be useful to condition these definitions on not having defined
|
First of all, if a constant for "extra" definitions was to be added, it would have to be opt in, not opt out. If you want to make a "standard library", the proper way to do that is to make an actual standard library repository. (As for the SGB/GBA nibble orders: those represent non-GB hardware (and specifically, hardware that a GB/GBC game has no way to access), and therefore they don't belong here any more than Dreamcast constants do.) |
Opposition to removalI oppose removing these constants, mostly for the sake of backward compatibility. If hardware.inc was designed from scratch now I would agree that those constants should not have been added. Now they are there, and a bunch of source code likely relies on them. Teaching users of hardware.inc that stuff will potentially break in every new version of the library because constants are deprecated left and right is an excellent way of making people give up and not update, which benefits no one in the long run. In my opinion the cost of removing them and causing trouble for users is higher than the cost of keeping things that technically don't belong in the file. What might sway my opinion is if it's either shown that few projects actually rely on these constants, or that there's some other natural place for them to go, so that they don't have to be ad hoc defined by every person whose project is broken by the change. Opposition to "SGB/GBA order"I oppose calling calling the nibble order by SGB or GBA, as this is "neither here nor there". The internal representation in the SGB and GBA registers have no bearing on what code running on the Gameboy's CPU is doing. Statistics of de facto usageRegarding the question of how opinionated the nibble order is, I created a small script that looped through my copy of GoodGBX. The test methodology is mainly as follows: look for The results are as follows: There may be some false results, but the trend is clear. LADX is in the minority. Joypad in upper nibble (same as hardware.inc's constants) is by far the most common. This likely also what Nintendo promoted in their example code. So, as far as the constants are opinionated they are in good company. Suggested actionIn my opinion, the way forward is this:
Natural nibble order in GBC test mode (side note)A fun thing to note is that there is a natural nibble order on GBC, stemming from the undocumented register FF63. However, this register is only available in test mode (requiring hardware modifications or similar). So this really has no bearing on what hardware.inc should do, as it doesn't document undocumented registers that are not available in the regular "user mode" context. Just a side note. |
Is Order Crossing next?Super Game Boy order can be accessed through Game Boy software that sends 65816 code in |
I sincerely don't think that would be at all relevant here. |
As you mentioned, such code would be 65816, running on the SNES. Thus, it would have no use of |
The
PADF_*
andPADB_*
constants have been around for a long time, but they don't describe any hardware at all. Their values represent the bitfields of the synthetic joypad value computed by some games after reading both lines of inputs and packing them into a single value; they represent convention, not hardware, and as such, they don't belong here. (This is not a statement about their utility: regardless of their value, it's a fact that there's nothing at all in the GB/GBC hardware representing the "down" D-pad button by the value $80.)The correct values for the F series of constants for the right, left, up and down buttons are respectively 1, 2, 4 and 8, not their current values of $10, $20, $40 and $80. (The B series should be likewise adjusted.) These values overlap with the respective values for A, B, select and start: those bits also overlap in hardware, and thus the correct hardware constants should have the same values. However, changing the values of the defined constants would represent a silent incompatible change, which would be undoubtedly undesirable.
Therefore, my proposal is:
INPUTF_SELECT
andINPUTF_UP
, both equal to 4.)Any thoughts?
The text was updated successfully, but these errors were encountered: