Skip to content

Bulk multibyte#4626

Open
SuuperW wants to merge 3 commits intomasterfrom
bulk_multibyte
Open

Bulk multibyte#4626
SuuperW wants to merge 3 commits intomasterfrom
bulk_multibyte

Conversation

@SuuperW
Copy link
Copy Markdown
Contributor

@SuuperW SuuperW commented Feb 11, 2026

To enable bulk poke/peek access for 16 and 32 bit values, I have given MemoryDomain , IMemoryApi, and MemoryLuaLibrary some new functions.

Check if completed:

@YoshiRulz YoshiRulz mentioned this pull request Feb 12, 2026
2 tasks
Copy link
Copy Markdown
Member

@YoshiRulz YoshiRulz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On top of cleaning up IMemoryApi, I would also like to clean up Range<T> (#3965) before adding new uses to MemoryDomain.

ushort[] ReadU16Range(long addr, int count, string domain = null);
uint[] ReadU32Range(long addr, int count, string domain = null);
void WriteU16Range(long addr, Span<ushort> memoryblock, string domain = null);
void WriteU32Range(long addr, Span<uint> memoryblock, string domain = null);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Write*Range signatures are fine for Span, but then why do Read*Range allocate and return arrays?
See also #3472.
Not that you need these anyway, since the caller can just MemoryMarshal.Cast to/from byte.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was just a lot simpler to do it that way, and the byte one returns an array IIRC so I was following that.
I knew you were wanting to update some of this stuff anyway, so I didn't think it very important.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update on this: The new read methods return IReadOnlyList, so as to match the existing ReadByteRange method. I considered changing them all to accept a Span instead but that's too much work to do before release.
The existing WriteByteRange method was changed to accept a Span though, since this is good and easy to do and makes it match the new ones.

Comment thread src/BizHawk.Client.Common/Api/Interfaces/IMemoryApi.cs Outdated
Comment thread src/BizHawk.Emulation.Common/Base Implementations/MemoryDomain.cs
Comment thread src/BizHawk.Emulation.Common/Base Implementations/MemoryDomain.cs Outdated
Comment thread src/BizHawk.Emulation.Common/Base Implementations/MemoryDomain.cs Outdated
@SuuperW
Copy link
Copy Markdown
Contributor Author

SuuperW commented Feb 22, 2026

Regarding all of your comments about being able to just convert between bulk byte and bulk int reads: No. The only reason I made this is to support #4555. The core MUST know what size we are reading, and the various sized reads cannot simply be re-interpreted as another.

@vadosnaprimer
Copy link
Copy Markdown
Contributor

Conflicts appeared, but also it's unclear from the discussion if there's anything else that has to change still.

@SuuperW
Copy link
Copy Markdown
Contributor Author

SuuperW commented Apr 16, 2026

I was going to wait for Yoshi to finish #3965 but I can go ahead and fix some stuff here in a few days.

@vadosnaprimer
Copy link
Copy Markdown
Contributor

I was going to wait for Yoshi to finish #3965

That one looks like it will require 20 more years to get done abandoned forever.

@SuuperW
Copy link
Copy Markdown
Contributor Author

SuuperW commented Apr 18, 2026

Fixed bugs and added tests for the bulk API methods. That code is absolutely horrible, matching the existing bulk byte methods.

IMemoryApi.WriteByteRange was changed from accepting a IReadOnlyList<byte> to Span<byte> which is technically an API change but byte[] works for both without an explicit cast. That lets it use the new underlying MemoryDomain.BulkPokeByte, and it also what the new bulk poke API methods do. If we need the version that accepts a list, I can make overloads for them.

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.

3 participants