Mr-Wiseguy / lnkconv

Converter for sn sdk object files
2 stars 0 forks source link

file format #1

Open ksherlock opened 1 year ago

ksherlock commented 1 year ago

Hi there,

The other day I was looking for information on SN Object files and this was the only information I found. This was very helpful and I was able to work out some more information (via the 65816 version of the SN assembler):

Record $1e: (created with /z): This sets the current file/line number.

Parameters:

Record $22: (created with /z): This increments the current line number

Parameters:

Record $24: (created with /z): This adjusts the current line number:

Parameters:

Record $0a: Relocation record This consists of the header format you worked out and an expression tree:

Header:

type values:

Expression tree:

This is an expression composed of 1 or more binary operators and terminals (constants, external symbols references, and internal section references). There is no explicit count or terminator but the length starts at 1, decrements every time a parameter is read, and increments by 2 whenever a binary operator is encountered.

operators:

terminals:

An expression like a+b*c+1 would create a tree like this:

    +
   / \
  1   +
     / \
    *   a
   / \
  c   b

which is encoded as: + 1 + * c b a (operator, left child, right child, recursively)

You could rebuild the tree to evaluate it or just process it backwards as RPN (a b c * + 1 +)

Mr-Wiseguy commented 1 year ago

Thanks! As it stands I ended up using a different solution for my project (a decompilation of an N64 game) that avoided needing to handle SN objects, but I'll be sure to share this info with some others who would be interested in knowing it.