Fix a symbol/data mismatch in wLinkPlayer*, and mailmsg#141
Fix a symbol/data mismatch in wLinkPlayer*, and mailmsg#141Narishma-gb wants to merge 16 commits intopret:masterfrom
wLinkPlayer*, and mailmsg#141Conversation
|
Converted to draft. I'd like to work on what's happening to the received party data during the link session, which shouldn't use |
|
I went a bit further and arranged some symbols for party mail, on top of enemy party data. Here's how it goes, for
For the opponent player's party, the received raw data is stored at the far end of WRAM, at Symbols have been updated in
There are some necessary but not very satisfactory changes:
|
|
The latest addition is a reformat of |
|
@Narishma-gb If this is entirely done, please unmark as draft and I'll get around to reviewing it. Thanks! |
- Expand "`TC`" to "`TimeCapsule`"/"`TIME_CAPSULE`" (unusual abbreviation)
- Rephrase "other Game Boy" to "other player" ("link player" is commonly used already)
- Prefer multiple `SECTION UNION`s to nested `UNION`s
- Comment `for` loops with the range of defined labels
- Use an assert to clarify the mistake with `wLinkData` vs `wLinkReceivedMailEnd`
|
One last addition, where |
Rangi42
left a comment
There was a problem hiding this comment.
Great work with this one! IMO it's ready to approve + squash + merge as-is, but still have some ideas.
-
I'm not totally sure which of the code in engine/link/link.asm would need modifying if
ds SERIAL_PADDING_LENGTH ; unused but written towere removed. ThewTimeCapsulePatchedDatalabel is referenced in a few places, and the step-by-step nature of how data gets read/written makes it hard to see where it goes a little too far. A comment at the code which writes to those bytes would help. -
It's very helpful to not be using the generic
wLinkDatabuffer any more... except for inClearLinkData, since the point is to clear "the whole multi-use link data buffer". But since we're using a wholeSECTION UNIONjust for that buffer, do we really need a generic label at all? How about this:ld bc, STARTOF("Overworld Map") + SIZEOF("Overworld Map") - wLinkReceivedMail ; should be wLinkReceivedMailEnd - wLinkReceivedMail
ClearLinkData: ld hl, STARTOF("Overworld Map") ld bc, SIZEOF("Overworld Map")
That would match how we clear the "Miscellaneous" buffer in engine/games/unown_puzzle.asm. More importantly, it would guarantee that
ClearLinkDataclears the whole buffer -- as-is, someone could conceivably add more than 1300 bytes to one of theSECTION UNIONs, and leavewLinkDatanot covering the whole thing.The main reason I'd hesitate is that the section name, "Overworld Map", is not obviously link related. But IMO people deal with map size limits a lot more often than link data buffer size limits (e.g. you make a 30x31-block map and now you're overflowing the buffer), so that's the "primary" purpose of the whole
SECTION UNION. What do you think?
|
|
Thanks, that does look suitable! The data that gets "temporarily stored here before applying patch data" can be for regular link or for Time Capsule link. In both cases it starts with the player's name and party species, but those interior labels don't actually get used. So I don't think we need them shared with a |
|
Turns out that the |
|
@Narishma-gb I don't want to merge my own changes without them being looked over first, and also, I think the labels can still be improved/shortened. In particular, the " (Also I don't mean to unilaterally refactor/replace parts of your PR, it's just easier to commit changes than describe them -- plus the process of making the changes helps discover what is/isn't an improvement, e.g. the location of |
|
(Game Freak reused |
|
I'm tempted to add these two macros (or at least the first MACRO party_species_list
\1PartyCount:: db
\1PartySpecies:: ds PARTY_LENGTH
\1PartyEnd:: db ; older code doesn't check PartyCount
ENDM
MACRO party_mons_with_names
\1PartyMons::
; \1PartyMon1 - \1PartyMon6
for n, 1, PARTY_LENGTH + 1
\1PartyMon{d:n}:: \2party_struct \1PartyMon{d:n}
endr
\1PartyMonOTs::
; \1PartyMon1OT - \1PartyMon6OT
for n, 1, PARTY_LENGTH + 1
\1PartyMon{d:n}OT:: ds NAME_LENGTH
endr
\1PartyMonNicknames::
; \1PartyMon1Nickname - \1PartyMon6Nickname
for n, 1, PARTY_LENGTH + 1
\1PartyMon{d:n}Nickname:: ds MON_NAME_LENGTH
endr
ENDMThere are seven places they would be useful, not just in link code, e.g.: ; player's party data, formatted for link transfer (Gen 2 link session)
wLinkSendParty::
wLinkSendPartyPreamble:: ds SERIAL_PREAMBLE_LENGTH
wLinkSendPartyPlayerName:: ds NAME_LENGTH
wLinkSendPartyList:: party_species_list wLinkSendParty
wLinkSendPartyPlayerID:: dw
wLinkSendPartyMons:: party_mons_with_names wLinkSendPartyPlayer, ,
wLinkSendPartyPadding:: ds SERIAL_PADDING_LENGTH
wLinkSendPartyEnd::; after the initial link session, the other player's party data
; is temporarily stored here before applying patch data
wLinkTimeCapsulePartyData::
; link player's name and party species are not patched,
; as they normally don't contain SERIAL_NO_DATA_BYTE
wLinkTimeCapsulePlayerName:: ds NAME_LENGTH
wLinkTimeCapsulePartyList:: party_species_list wLinkTimeCapsuleParty
wTimeCapsulePatchedData:: party_mons_with_names wTimeCapsule, red_
wLinkTimeCapsulePartyPadding:: ds SERIAL_PADDING_LENGTH
wLinkTimeCapsulePartyDataEnd::; enemy party
wOTPartyData::
wOTPlayerName:: ds NAME_LENGTH
wOTPlayerID:: dw
ds 8
wOTPartyList:: party_species_list wOT
UNION
; ot party mons
wOTPartyData:: party_mons_with_names wOT, ,
wOTPartyDataEnd:: |
|
I have no issue with anyone adding changes to the PR, I left it open so it could happen. And it was a modest goal initially, just aligning some data in WRAM.
As I understand, it's possible for a link data stream to be slightly off by a byte or so, compared to what is expected. This is due to the fact that one gameboy decides when data should be sent/received, and assumes the other is also ready when it is. The first sent byte could be lost, and the first received byte could be (No padding bytes at the end, but the mail patch list is already longer than its maximum used size). The same reasoning applies to There is no mention of Time Capsule here, I don't know if it's worth mentioning (TC data being shorter, it would be included within Perhaps labels aren't well chosen, and should reflect the difference between raw and processed data? I used Received in this case, and not in other UNIONs. Although I kept |
Fixes #140
MAIL_MSG_LENGTHis redefined as2 * MAIL_LINE_LENGTH, so that it's still linked to themailmsgmacro.