Add sgb.inc - #77
Conversation
Closes gbdev#76
|
Oh, thanks! Good idea to make this a third .inc file, given all those super-specific but official SGB values ( It will need comments briefly mentioning what all these things are, like hardware.inc's heading/subheading/description structure, and to follow the formatting conventions (e.g. lowercase Also, Anyway, this is good reference to expand off of! |
Sure thing, I just had to get something out there quickly.
I'll have a look. Also, I just noticed that the actual |
Add header Add include guard Add comments Lowercase DEFs and EQUs Rename SGB_SOUND_ATTRS to SGB_SOUND_FLAGS
|
Having seen the I'm OK with changing the names, but not with hardcoding the values in binary form. |
May I suggest |
|
Sounds like a good compromise; I could accept an |
|
I understand the convention of using the I am wondering whether |
|
Again, turning it into a prefix seems appropriate:
|
|
As said in #76 I don't like the name I also have some issues with the semantics how things are used in pokered. These constants actually have different meanings, despite being the same value. The first one is a mask to isolate the two lowest bits. The second is the ID for player 1. What the code does is to check if the player ID ever changes from the value for player 1, which also (by design) happens to be the same value that a non-SGB would return when no buttons are selected. This does not actually represent what that code is doing. It's not sending the SGB data at this point, but rather doing a "regular" read of the joypad, which also increments the player index at some stage, maybe when the selected button group changes from Using the data transfer constants is obscuring what the code actually does. (The added delays also obscure what the code does. They shouldn't be needed, although that's Nintendo's fault and a disassembly can't do much about that.) I'd suggest using the regular For hardware.inc, I'd suggest constants with names along these lines: |
|
TODO: once this is merged, replace |
|
Now that I'm thinking about it, I believe this warrants a separate repo. |
|
I think this topically belongs with |
|
It is a companion, but should it be mandatory? The correct way of adding hardware.inc to one's repo is via a submodule. Most users will probably never use sgb.inc, so it will end up just sitting there, polluting their file system. |
|
Arguably, using a submodule is not great, since it introduces an additional point of failure over just vendoring the file. (I prefer it for my own use, but it's less obvious for libraries and such.) Also, using a submodule also unnecessarily imports the Meanwhile, centralising the resources improves their discoverability. |
|
I never actually used submodules so far, so I'm wondering what you mean by them being a point of failure. As for README and LICENSE, those are necessary evils. I'd actually put the mandatory part in |
They require special Git flags to operate (
It's unfortunately not possible. Submodules are always entire repos (and you can't have sparse submodules, either). Subtrees might solve the issue, but I've never experimented with them. |
|
Anyone whose game has an SGB border would have a use for sgb.inc. As for "polluting" the file system with unused files, the same is also true of hardware_compat.inc (and for that matter, README.md, .github/workflows/testing.yml, etc) when using a submodule. The benefit of keeping sgb.inc in the same repo as hardware.inc is making them discoverable together, maintaining the same naming/formatting conventions for both, and keeping them in sync for releases. |
Which is probably 5% of projects, or even less until they reach advanced stages in their development?
Already addressed above.
Hidden directories don't count ;)
I'd argue that that should actually be a separate repo as well.
Agreed.
No reason not to, regardless of how they are organised.
That's precisely my point. You don't want them in sync! |
|
@dmitry-shechtman could you check if you have |
I don't see the option. |
|
@dmitry-shechtman it should be on this page, in the top right options: |
|
Sadly, my sidebar has no such option. |
|
@dmitry-shechtman alright! thanks for checking :/ I suspect this is happening because you are PRing from an organisation, not your personal namespace, and maybe that weirds out GitHub permission system on PR branches.. Can you try to give me ( |
- Additional constants for header byte components - Sentence casing for heading comments - Local vertical alignment, not one column level in the whole file Co-authored-by: Rangi <35663410+Rangi42@users.noreply.github.com>
|
Thank you, I'm able to commit to the PR branch now! I'm just getting some formatting nitpicks out of the way, and may have a few more significant questions/suggestions after that. |
|
Thanks @dmitry-shechtman ! |
Rangi42
left a comment
There was a problem hiding this comment.
Thank you for your patience with this PR! hardware.inc doesn't get frequent updates, but we are looking forward to 6.0 soon, and I'd like this to be a part of it.
| def SGB_MLT_REQ_PLAYERS_ONE equ $00 | ||
| def SGB_MLT_REQ_PLAYERS_TWO equ $01 | ||
| def SGB_MLT_REQ_PLAYERS_FOUR equ $11 |
There was a problem hiding this comment.
If I understand https://gbdev.io/pandocs/SGB_Command_Multiplayer.html#sgb-command-11--mlt_req correctly, should these be binary %00, %01, and %11?
| def SGB_SOUND_B_STOP equ $80 | ||
|
|
||
|
|
||
| ; -- SGB_MLT_REQ ($11) -------------------------------------------------------- |
There was a problem hiding this comment.
This does not add constants for the original hardware.inc request in #76, covering the MLT_REQ data which can be read from the P1/JOYP register.
We already define some SGB-related constants in hardware.inc itself -- including the B_JOYP_SGB_ONE/ZERO and JOYP_SGB_START/FINISH bits essential to all SGB commands -- so that may be the correct place for them after all?
On the other hand, if multiple SGB command types all reuse the P1 register for reading certain command-specific values (I don't know, haven't read about every single one) then sgb.inc would IMO be the correct place, to avoid bloating hardware.inc's JOYP section with mostly SGB-related content.
There was a problem hiding this comment.
I don't think any command expects to read a return via rJOYP. In case of MLT_REQ, joypad reads are now "signed" with the controller number being polled, but as it is permanent, it's a side effect of the command.
I'd suggest relocating B_JOYP_SGB_ONE, JOYP_SGB_START, ... here, because in order to transfer a packet to the SGB, this file will likely be included since it conveniently has the command definition. Besides, it would be very surprising to check for SGB hardware, and do nothing else with it.
|
|
||
|
|
There was a problem hiding this comment.
ATTR_BLK ($04), ATTR_LIN ($05), ATTR_DIV ($06), and ATTR_CHR ($07) all go in-between here, and have A_* byte offsets (and significant bit/mask values for some of those bytes' meanings) which could be defined here. Same goes for the other command types which aren't yet addressed.
|
I don't have much SGB-to-SNES programming experience at all -- I've only dealt with the commands necessary for 4bpp SGB borders -- so may not be the best person to thoroughly review this. However, I can't really tell how the |
|
|
|
For the A typical tilemap entry can then be written as |
Closes #76