reko icon indicating copy to clipboard operation
reko copied to clipboard

Feature Request: 16-Bit SegPtr reference lookup compressed to SegPtr

Open Elthial opened this issue 3 years ago • 0 comments

So I am wondering if it is possible to compress a SegPtr lookup in Reko HL code into just the SegPtr and use that to work out further variable references.

The issue is with 16-Bit segmented memory, all the segptr's need to be in the initial [Data] segment (3EDB for me atm) because that's the assumed ds segment unless otherwise provided. This means that any variable reference outside of the [Data] segment must first do a lookup to a [Data] SegPtr lookup table and then do the rest of the ptr.

This is one of the reasons why the variable EQ and types explode so heavily with 16 bit segmented code, as each segment lookup ptr becomes its own eq_**** rather than compressing into a common segptr eq_*****

Additionally this seems to be a breaking factor in defining user defined variables / structs as it is unable to link all the reference together.

Example:

struct Eq_19636 * es_24 = ds->ptr54B8; if ((&es_24->tFFFFC614.b0000)[wLoc04_342 * 0x11] == ~0x00)

which has the reko .inc file of:

{
    unsigned char Name;
    unsigned char Body;
    unsigned char Dexterity;
    unsigned char Charisma;
    unsigned char Skill_BowsAndBlade;
    unsigned char Skill_Pistol;
    unsigned char Skill_Rifle;
    unsigned char Skill_Gunnery;
    unsigned char Skill_Piloting;
    unsigned char Skill_Tech;
    unsigned char Skill_Medical;  
    unsigned char Weapon;
    unsigned char Piloting;
    unsigned char ArmourType;
    unsigned char ArmourValue;
    unsigned char Health;
    unsigned char Riding;
} Infantry;


//Infantry Variables
[[reko::address("3092:C614")]] Infantry CrescentHawk00_Jason; 

es_24 = ds->ptr54B8; references segptr 0x3092 tFFFFC614 is 0xC614 which should be the beginning of the user defined struct.

The struct itself exists in the "3092 global variables" of reko, so the typedef has worked till that point.

Any thoughts on whether this might be possible or any alternative approaches that might be better?

Elthial avatar Jul 02 '22 09:07 Elthial