Commit Graph

20 Commits

Author SHA1 Message Date
Zorchenhimer 63de05e9dd
[script] Fix 0xEA; Add 0xEF
- 0xEA `string_write_to_table` - Has an inline word that wasn't being
  captured correctly.
- 0x89 `draw_string` - Figured out what some of the arguments
- 0xEF `draw_string_sprites` - Similar to `draw_string` but uses sprites
  instead of drawing to the background.  Seems to only be used in debug
  code to print three "A" characters in different colors.
2025-09-21 22:45:20 -04:00
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 c43d4dd29c
[script] Update Op Codes
Added:
- 0x89 draw_string
- 0xAA long_jump
- 0xAF string_to_arg_a
- 0xB0 arg_a_to_string
- 0xB4 indirect_copy_471A_4E
- 0xB5 string_copy
- 0xB6 word4E_to_word471A

Renamed:
- 0xB7 deref_ptr_inlne to push_var
- 0xBA push to push_data_indirect
- 0xB8 trim_string_start to trim_string_start_32

Also added a bunch of comments.
2025-09-21 17:23:13 -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
Zorchenhimer d8cc126c04
[script] Move InstrStat to script/stats.go 2025-09-13 14:03:45 -04:00
Zorchenhimer 045f204a6b
[cmd] Add just-stats command
This command is meant for gathering stats across many script files.
Currently breaks due to an oversight in script parsing (if an inline
argument list goes past EOF, everything breaks).
2025-09-06 22:56:10 -04:00
Zorchenhimer db2e5b5f87
[script] Add InlineImmediate field to Instruction
Setting this field to true will skip generating auto labels for the
inline values for the instruction.
2025-09-06 22:55:06 -04:00
Zorchenhimer 4bd0027c70
[script] Add some statisticts tracking
Track the statistics of used instructions for the script.
2025-09-06 22:53:33 -04:00
Zorchenhimer b3312a8500
[rom] Tweaked packet info output
Tweaked the packet info strings to be a little more clear on what fields
are printed.
2025-09-06 22:46:26 -04:00
Zorchenhimer 1ebe698ac4
[rom] Add NoAudio option to export
Added an option to exclude the audio file from the unpacked rom data.
2025-09-06 22:45:33 -04:00
Zorchenhimer 5a001931e7
Added missing cmd/sbutil.go
Not sure how this was missing for so long.  Whoops.
2025-09-06 22:43:13 -04:00
Zorchenhimer 4b9f04874b
[script] Better auto label support
Labels are now their own object instead of just a string.  This allows
for a bit more control with them.  Labels can also now have comments.

Additionally, add the ability to load user-defined labels from a file.
The format of this file is subject to change, but for now it is just a
simple text file.  Each line of the file is a label definition.  Each
line has three fields, separated by spaces.  The first field is the
address, second is the label name, and the rest of the line is a
comment.  If a label name is just a dollar sign ($) it will not have a
name.  This is used when adding comments without a bespoke label.
2025-09-06 22:38:39 -04:00
Zorchenhimer 29e48f3cac
[script] Fix varible inline instructions; Fix off-by-one
- Fixed instructions that have -3 as the OpCount (count then count
  words).  There is not an extra word that acts as the default
  selection.  These instructions do nothing if the argument is out of
  range.
- Fixed off-by-one eating the byte following the -3 OpCount
  instructions.
- Fixed panic when a -2 op code goes beyond the end of the script.
2025-09-06 22:27:45 -04:00
Zorchenhimer 6a3a51fef7
[rom] Fix exported file modes
Export files with mode 0666 instead of 0777.
2025-09-06 22:24:34 -04:00
Zorchenhimer 468f7c780a
Some stuff with the script decoding
I honestly don't remember what these changes are, lol.
2024-09-29 15:03:21 -04:00
Zorchenhimer 3d5790e230
Some cleanup an the decode code
Added a bunch of comments and clarified some variables in the decoding
logic.
2024-09-29 15:00:44 -04:00
Zorchenhimer 928a8e2faf
Start migrating go-nes/studybox stuff over here
I need a bunch of tools for studybox related stuff.  It makes more sense
to have a separate project for them instead of trying to shove all the
functionality I want into a single command in the go-nes project.
2024-05-15 23:47:29 -04:00
Zorchenhimer 0f9ab661cc
Name 0xA3 sprite_setup; Add some comments for documentation 2024-05-15 23:43:29 -04:00
Zorchenhimer 6c72977f17
Initial commit
Starting with some script parsing.  This script is the Domain Specific
Language that is on the tapes of the studybox.  Not every opcode is
fully decoded/named yet.
2024-04-27 15:19:14 -04:00