using System.Runtime.InteropServices; namespace XFEEDToolBox.Plugin; internal static unsafe partial class Navigation { static uint GalaxyServiceFactsSelfTest() { var memory=Platform.Allocate(0x10000);if(memory==0)return 0; try { var table=memory+0x1000;var expectedImage=table-0x5242530;var source=memory+0x4000; var map=source+0x118;var storage=memory+0x6000;var rows=storage+8;const ulong capacity=16; const ulong address=9007199254740995UL;var slot=GalaxyFactHash(address)&15;var row=rows+(nuint)slot*16; Write(source,table);Write(source-0x58,expectedImage+0x52423E8);Write(source-0x50,expectedImage+0x5242430); Write(table,expectedImage+0x1E110C0);Write(table+8,expectedImage+0x201130);Write(table+0x50,expectedImage+0x1E220B0); Write(map+8,0UL);Write(map+0x10,0UL);Write(map+0x18,(nuint)0);uint passed=0; if(CopyGalaxyServiceFacts(source,expectedImage,address,out var fact)&&fact is null)passed|=1; Write(map+8,1UL);Write(map+0x10,capacity);Write(map+0x18,storage);Write(storage,1UL<<(int)slot);Write(row,address); // All ten options are exercised through their real six-byte fields. var all=true; for(var index=0;index<10;index++) { for(nuint i=0;i<6;i++)Write(row+8+i,(byte)0); if(index<4)Write(row+10,(byte)(index+1));else if(index<6)Write(row+11,(byte)(index-3)); else Write(row+8+(nuint)(index switch{6=>1,7=>0,8=>4,_=>5}),(byte)1); all&=CopyGalaxyServiceFacts(source,expectedImage,address,out fact)&&fact is{} actual&&actual.mask==(1<RunTest(GalaxyServiceFactsSelfTest); #endif }