nesdev.com
http://forums.nesdev.com/

Debugging a label in CA65
http://forums.nesdev.com/viewtopic.php?f=2&t=16016
Page 1 of 1

Author:  dullahan [ Fri Jun 02, 2017 4:22 pm ]
Post subject:  Debugging a label in CA65

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:
Code:
.pushseg
.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

  ...

  metasprite_ids:
    .byte metasprite_names::door, metasprite_names::z75

  metasprite_cols:
    .byte 17, 22

  metasprite_rows:
    .byte 4, 7
   
  metasprite_args:
    .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?

Author:  tepples [ Fri Jun 02, 2017 5:41 pm ]
Post subject:  Re: Debugging a label in CA65

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:
Code:
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?

Author:  dullahan [ Fri Jun 02, 2017 9:22 pm ]
Post subject:  Re: Debugging a label in CA65

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.

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/