This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Debugging a label in CA65

Debugging a label in CA65
by on (#197244)
I have hit a wall in debugging an issue. I hope typing up the issue and/or getting in front of other sets of eyes may help me move forward. Suggestions for what is going on here or what I might try next are welcome!

First, here is a snippet of a file which contains an encoded level:
.segment "LEVELS"
.proc playground
  ; metasprite count
  .byte 2
  ; metasprite IDs
  .word metasprite_ids

  ; metasprite column positions
  .word metasprite_cols

  ; metasprite row and length bytes
  .word metasprite_rows
  ; metasprite_args
  .word metasprite_args


    .byte metasprite_names::door, metasprite_names::z75

    .byte 17, 22

    .byte 4, 7
    .byte 7

I recently added metasprite_args which points at a list of bytes which are arguments for metasprites. The weird thing is that this label evaluates to $00 when assembled with ca65. The previous label metasprite_rows points at a non-zero address, but not metasprite_args.

Why is this label $00 rather than address(metasprite_rows) + 2?
Re: Debugging a label in CA65
by on (#197246)
Let's form a Minimal, Complete, and Verifiable Example (MCVE). In particular, give us something we can assemble that still produces the misbehavior. I understand your actual source code may contain proprietary information that you want to keep confidential until your product is released. But you cut out so much, and in such a way, that your snippet doesn't assemble:
dotdotdot.s(5): Error: Unexpected trailing garbage characters
dotdotdot.s(21): Error: Unexpected trailing garbage characters
dotdotdot.s(24): Error: No such scope: `metasprite_names'
dotdotdot.s(24): Error: Unexpected trailing garbage characters

What else can you cut out of your original file to keep it assembling while preserving the misbehavior?
Re: Debugging a label in CA65
by on (#197258)
Thanks for your reply Tepples. :D I stepped through the code again and found the root cause--the level loader was inc'ing Y one too many times due to an old field I had removed from the level format.