IsoFrieze / DiztinGUIsh

A Super NES ROM Disassembler
GNU General Public License v3.0
263 stars 26 forks source link

New Type Proposal: Code PageBank Word Pointer #61

Open werkt opened 3 years ago

werkt commented 3 years ago

A typically used indexed-indirect-* Jxx instruction will reference a table of addresses within the current PBR with an offset.

It would be really helpful to have an annotation for a pointer that allows inference of the IA from the code page, and by extension the 'T' navigation, to use that PBR as the high byte of the long IA.

Further specification could allow for this to be identified as an opcode IA, but I'll take what I can get.

binary1230 commented 3 years ago
  1. I think I'm following that (honestly, I'm a bit weak on my own 65816 assembly, there's some folks in the discord channel I hit up for the more technical questions). If you had a sec, any chance you could sketch out a quick example? maybe a couple screenshots of one of the tables and spell out the desired behavior?

  2. here's the situation with annotations at the moment, it's a bit painful to add new annotations in the main (2.x) branch, there's a bunch of hardcoded stuff and it's a bit of a mess. it's not impossible, just, a little crufty and annoying

however, I'm working on a rewrite of the data model in the 3.x branch, and one of the big items that changed there is, it's very easy to add new annotation types by just deriving from the Annotation class. Serialization happens automatically by reading the public properties. So, after adding the type, it's pretty easy to query and utilize arbitrary annotation types from inside the navigation functions [or, adding those annotation types dynamically from analysis tools etc]

I think it's going to be a while til 3.x is ready though, there's a lot to tie up and refactor still, but, I think this kind of thing could be great. if I'm hearing you right, I'd also be interested.

it'd be cool to also have a way to mark out table start and end so that Diz could show you all the possible places it can jump to. or also, was thinking about adding 'example' annotations to stuff like this, so Diz could tell you things like 'this jump has been observed during gameplay runs and is TYPICALLY going to go here- or here- depending on i.e. which spell is being cast / etc'

binary1230 commented 3 years ago

Thinking out loud...

example of what deriving a new annotation type can look like in the future: https://github.com/binary1230/DiztinGUIsh/blob/master/Diz.Core/model/Annotation.cs#L115

the new data model also has the concept of regions, that could probably be useful for marking the tables as well. https://github.com/binary1230/DiztinGUIsh/blob/master/Diz.Core/model/byteSources/ByteSourceMapping.cs#L55

Currently, that Region concept is being used for things like defining a sequence of bytes as the bytes from a ROM file, then mapping that byte sequence via SNES mappings [like HiRom] into a parent region (i.e. the SNES address space, which is a region)

So, one approach could be, a new region could be derived that marks the bytes within as being associated with some particular Jxx instruction, and it can have data that marks up the way the bytes within it are used to get a final IA address.

or... something.