Skip to content

Add SGB commands constants, refactor ATTR_BLK and CheckSGB - #597

Draft
Narishma-gb wants to merge 4 commits into
pret:masterfrom
Narishma-gb:sgb_cmd
Draft

Narishma-gb wants to merge 4 commits into
pret:masterfrom
Narishma-gb:sgb_cmd

Conversation

@Narishma-gb

Copy link
Copy Markdown
Contributor

This makes the sgb_packets.asm file contents easier to grasp, as the raw values are replaced with their CMD_* constants. sgb_cmd has a default packet size of 1, and checks for illegal packet count values.
ATTR_BLK will now calculate the number of packets necessary for the data, and add the relevant padding bytes. I reused the "dbing then defining" trick.
Should all macros be moved to sgb_constants.asm, or left in sgb_packets.asm?

In CheckSGB, JOYP_GET_* constants are used instead of the packet handling constants. I renamed JOYP_SGB_MLT_REQ into SGB_JOYP_ID_MASK and moved it to sgb_constants.asm. It helps seeing this function as an attempt to cycle through the 2-player input that we've temporarily set.

@Narishma-gb

Narishma-gb commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor Author

For some reason, GitHub decided that no job was to run, but I have no idea why this happened. 😕

@Rangi42

Rangi42 commented Aug 6, 2026

Copy link
Copy Markdown
Member

I'm going to draft this one for now, because the next hardware.inc release might be ready in the coming weeks and it may include sgb.inc. This is good timing though, I can look at this PR to consider what else might be useful in that file.

@Rangi42
Rangi42 marked this pull request as draft August 6, 2026 20:41
@Narishma-gb

Copy link
Copy Markdown
Contributor Author

I definitely agree with gbdev/hardware.inc#77 (comment)
We did the same homework and reached the same conclusion. 😁

@Narishma-gb

Copy link
Copy Markdown
Contributor Author

This reformats BorderPalettes so that necessary padding isn't confused with empty ROM data.
With the info at https://snes.nesdev.org/wiki/Tilemaps and Pan Docs it stands to reason that the extra $100 bytes are another 4 rows of tilemap data, that doesn't get used.
SNES_TILEMAP_WIDTH could be a nice addition to sgb.inc
The "mystery" of the auto assigned palette color 0 is a case of what's known as the backdrop color.

@Narishma-gb

Copy link
Copy Markdown
Contributor Author

I see hardware.inc v6 was released, but sgb.inc was still WIP at that time and didn't get included. Should this PR be kept on hold, or continue separately with the current constants, or include the latest unreleased sgb.inc? There is no hurry, so I'm fine with either solution.

@Rangi42

Rangi42 commented Oct 19, 2026

Copy link
Copy Markdown
Member

No sgb.inc is released yet -- if it gets included in hardware.inc, it will be in a future version, or maybe it'll end up being its own repo -- so since this PR does not use sgb.inc directly, it's unaffected. (Although if you're keeping names in sync between here and the planned sgb.inc PR, that's great.)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants