Sometimes a variable has more than one name. Versions of the emulator Mesen published prior to third quarter 2022 have had trouble sorting this out, causing emu.getLabelAddress in a Lua script to stop execution with the error "label not found".
For example, six bytes of an actor's state may be devoted to the state of an actor's physics, such as subpixel position and velocity. Actors that don't use momentum and instead need more complex state may reuse those six bytes for something else, such as the state of their AI. I've modeled this as giving an alias to one of the momentum-related variable names.
In one of a game's core files:
Code: Select all
actor_dxsub: .res NUM_ACTORS ; Actors with momentum
actor_dx: .res NUM_ACTORS ; Actors with momentum
actor_xsub: .res NUM_ACTORS ; Actors with momentum
actor_x: .res NUM_ACTORS ; All actors
actor_xscr: .res NUM_ACTORS ; All actors
actor_dysub: .res NUM_ACTORS ; Actors with momentum
actor_dy: .res NUM_ACTORS ; Actors with momentum
actor_ysub: .res NUM_ACTORS ; Actors with momentum
actor_y: .res NUM_ACTORS ; All actors
actor_yscr: .res NUM_ACTORS ; All actors
Code: Select all
num_bubbles = actor_xsub
Code: Select all
spirit_distance = actor_xsub
Code: Select all
seen_space_characters = actor_xsub
However, this convention breaks when a source file defines multiple labels with :.
Code: Select all
Ann_cels:
.incbin "Ann_cels.chr"
Ann_cels_end:
Andy_cels:
.incbin "Andy_cels.chr"
Andy_cels_end:
- Whether the symbol is ever defined with a nonzero size=
- How many other translation units .import the symbol, represented in the .dbg file as count of sym entries of the same name= with type=imp
- type=lab beats type=equ, as before
To better inform the priorities that a debugger can put in place, what are the usual conventions in ca65 programs to distinguish among canonical labels, alias labels, and non-address symbols?