Release hardware.inc version 4.10 - #50
Merged
Merged
Conversation
- Add more constants - Deprecate some alias constants - Move change log to HISTORY.md file - Regroup and reformat constants - Define `F`lags in terms of shifted `B`its
Collaborator
Author
|
(I don't have review-request permissions in this repository, so: @ISSOtm @avivace @AntonioND @nitro2k01 @FredrIQ @vulcandth maybe in the next week or so y'all can take a look at this?) |
ISSOtm
self-requested a review
May 17, 2025 16:42
ISSOtm
suggested changes
May 17, 2025
ISSOtm
left a comment
Member
There was a problem hiding this comment.
Thank you very much for this highly thorough change!
The nature of a review means I am only going to point out the things that I disagree with, but I have to say that I'm a big fan of the improvements here, including some of the more intuitive names.
avivace
approved these changes
May 18, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before merging, correct the date in HISTORY.md! Then, do "squash and merge"!
Although this is a large PR, it does not break any backwards compatibility. All the pre-existing constants are still defined. This should be a drop-in replacement for anyone using hardware.inc 4.9.2.
The changes here fall into a few categories:
New constants
A
HARDWARE_INC_VERSIONstring constant (currently"4.10.0") to provide more flexibility than therev_Check_hardware_incmacro.We now consistently define
<REG>B_<FIELD>for bit values (0-7, to be used withbit,set,res) and<REG>F_<FIELD>for flag values (to be used withand,or,xor). Some<REG>F_<FIELD>are also meant as values (to be used withld). Previously many registers had flags but not bits, or sometimes vice-versa, or lacked any field bits/flags at all even though Pan Docs described some.Some new registers:
rKEY0($FF4C) andrBANK($FF50). These are boot ROM registers which were already documented in Pan Docs, but only defined in gb-bootroms.A new
rRTCREG($A000) register that is affected byrRAMBandrRTCLATCHfor MBC3. (pokecrystal's hardware_constants.asm had called thisMBC3RTC.)Some new preferred aliases have been defined:
rJOYPforrP1: Pan Docs already listed this as an alias, and used it more widely thanP1(e.g. in thestopdiagram), and it's more human-readable.rVDMA_*forrHDMA1-5: This continues the pattern of how we addedrAUD*aliases for therNRxxregisters a long time ago (before the initial commit in this repository). I used "VDMA" here for "video DMA", since "horizontal/HBlank DMA" and "general DMA" are the two modes it can take.rVDMA_SRC_HIGHforrHDMA1rVDMA_SRC_LOWforrHDMA2rVDMA_DEST_HIGHforrHDMA3rVDMA_DEST_LOWforrHDMA4rVDMA_LENforrHDMA5rWBKforrSVBKakarSMBK: This was suggested in rHDMAx alternative names #36, and makes more sense as "WRAM bank" (pairing withrVBKfor "VRAM bank").IEB_JOYPADandIEF_JOYPADforIEB_HILOandIEF_HILO: This is the Joypad interrupt, not the "hilo" interrupt.OBJ_Bforsizeof_OAM_ATTRS: This matches theSCRN_X_BandSCRN_Y_Bbyte-size constants, and avoids a one-off lowercase "sizeof_*".PADF_SWAP_*constants as alternatives to the existingPADF_*constants, with a swapped convention of putting Control Pad bits in the low nybble instead of the high nybble.More constants are defined related to tiles, palettes and colors, grouped with the screen-related constants.
A complete list new newly available constants is at https://pastebin.com/V4eq0zPe.
Deprecations
Again, although nothing has been removed, some things have been commented as "deprecated", with preferred alternatives available from RGBASM, RGBLINK, and RGBFIX.
Memory region constants, like
_RAMBANK: since RGBASM 0.7.0, you can doSTARTOF(WRAMX)instead. Note that the actual value gets resolved by RGBLINK, since some settings (like-d/--dmg) can affect which section types span which memory.Cartridge header constants, like
NINTENDO_LOGOorCART_ROM_*MBC values: You can reserve aSECTIONfor your cartridge header filled with $00s, and should use RGBFIX to assign appropriate values inside it (including correct checksums).Reformatting and reorganizing
Comments take up less vertical space. Heading comments have changed from this:
to this:
And subheading comments have changed from this:
to this:
Register readability/writeability indicators have changed from
(R/W)(R)(W)to[r/w][ro][wo].Lowercase
def equinstead ofDEF EQUso the all-caps constant names stand out more.Associated/dependent constants are indented. Now that RGBASM uses
defto introduce definitions, this is legal, and helps to indicate a "hierarchy" of constants (e.g. flag values being derived from bit values).Use
equinstead ofrbto define OAM object field offsets, so we won't be disturbing the value of_RSfor the user.Comments noting which addresses in the $FF00-$FF7F range are "unused", so they don't look like oversights.
The history change log has moved from the top of the file to its own HISTORY.md file. This makes the actual file more compact, and enables Markdown formatting. In future we may want to backfill the changelog with more detail now that it wouldn't be bloating the main file.
Removed the links to Jeff Frohwein's devrs.com because it's now just a HostGator default page, and there's no need to link to his old hardware.inc v2.3 when we have it tagged already.
Resolutions
This resolves many open issues that have been neglected, some for years:
rHDMA1-5now have alternative names, and we've addedrWBK, CGB palette constants, andBGP_SGB_TRANSFER($E4).PADF_*andPADB_*constants don't represent hardware values #37: ThePADF_*constants are here to stay, and we've addedPADF_SWAP_*constants to make it clear that this is a convention, not an inescapable fact of the hardware.Flag values are defined as shiftedBit values when possible. We decided against using macros becausedef REGF_FIELD equ 1 << REGB_FIELDis minimal boilerplate and makes both names easily greppable.rJOYPalias forrP1#47:rJOYPis now defined and preferred torP1.rIE? #48: We now defineIEB/F_JOYPADand have deprecatedIEB/F_HILO.TILE_XandTILE_Yfor the tile width and height of 8 pixels (comparable toSCRN_XandSCRN_Y), andTILE_Bfor the 16-byte size.