Commit Graph

3 Commits

Author SHA1 Message Date
Zorchenhimer 193ce21297
[script] Rework CDL & Label stuff
Labels are now in a json file instead of a dumb custom format.  This
should make things easier to maintain, both in code and data.  Address
values are in hexadecimal format inside strings.

The CDL handling has been cleaned up a bit.  Internally, all the values
are indexed by CPU address instead of by file offset.  This is done
because it seems that *all* of the tapes put *all* of their scripts
starting at $6000.  The only difference between locations is the bank ID
used.  An offset of +/-0x6000 has been added in a bunch of places to keep
the index values in CPU address space.

Additionally, setting CDL data for Data has been fixed.  This includes
creating tokens for Unknown and Data bytes so they can be output in the
source.  They will have a label of either "UNKN" or "DATA" in the
bytecode column.

Some smaller things:
- EntryPoints array is now in the CDL, allowing to add more starting
  points for SmartParse().
- script-decode.go now accepts a --no-addr-prefix to suppress the
  address output on the beginning of each line of script.  This enables
  diffing scripts and having the output mean something.
- `push_data` string has been tweaked.  Instead of using %q for
  everything, we build a string from scratch.  If there are no bytes
  outside of the ASCII printable character range just print the ASCII.
  Otherwise, print out the hex value for every byte.  If an individual
  byte is printable ASCII, print that charater in curly brackets.
- Label files will be updated with auto-generated labels.
- Provding a non-existent filename for labels or CDL will print a
  warning, but will write out a file if no other errors occur.
- Added DebugCDL() that will write the raw CDL values to a file.  This
  enables comparing the CDL values directly to the script binary.
- Added newlines after `long_return` and `long_jump`
2025-09-21 22:26:59 -04:00
Zorchenhimer bfc7beb382
[script] Improve CDL logic
- CDL data can now be output to a file.  If --cdl-output isn't given,
  but --cdl is given, the input file is overwritten with the new data.
  If no CDL file is given no data is written.
- Count arguments as "Code"
- The SmartParse function no longer creates a new CDL.  It will use and
  update what it was given.
- The just-stats command does not write CDL data even though it
  generates it.

Variable length arguments are not properly handled yet.  Currently, just
the OP code and first argument (length) are set at Code.  The rest are
ignored.
2025-09-14 18:06:46 -04:00
Zorchenhimer 11cfad1e1a
[script] Add CDL; Add "smart" parsing
- Added a CDL implementation.  It is still very incomplete and is not
  really used yet.
- Added "smart" parsing.  This will disassemble the code and follow any
  jumps and calls.  Anything not found by this is currently excluded
  from output.
2025-09-14 16:52:06 -04:00