6502bench icon indicating copy to clipboard operation
6502bench copied to clipboard

data scripts

Open ksherlock opened this issue 11 months ago • 1 comments

Currently scripting seems to be limited to visualization and jsr/jsl/brk checking. While formatting some repetitive data (a table of DCI strings followed by 2 16-bit integers) I yearned for a way to automate it.

TFBD and ORCA/Disassembler both have scripts to format data.

Example from orca/disassembler:

**
*  GSOS_Create - CreateGS parameter block
*
        SCRIPT  GSOS_Create
        @A=@ARG
        @P=[@A]
        DC      @A,I2
        COMMENT @A,pCount
        @A=@A+2
        DC      @A,I4
        COMMENT @A,pathname
        @A=@A+4
        IF      @P<2,doneCreate
        DC      @A,I2
        COMMENT @A,access
        @A=@A+2
        IF      @P<3,doneCreate
        DC      @A,I2
        COMMENT @A,file type
        @A=@A+2
        IF      @P<4,doneCreate
        DC      @A,I4
        COMMENT @A,aux type
        @A=@A+4
        IF      @P<5,doneCreate
        DC      @A,I2
        COMMENT @A,storage type
        @A=@A+2
        IF      @P<6,doneCreate
        DC      @A,I4
        COMMENT @A,eof
        @A=@A+4
        IF      @P<7,doneCreate
        DC      @A,I4
        COMMENT @A,resource eof
.doneCreate
        ENDS

Example from the flaming bird:

**
*  GSOS_Create - CreateGS parameter block
*
GSOS_Create SCRIPT
 @P=[@A]|W-1
 DW @A
 COM @A,pCount
 @A=@A+2
 ADRL @A
 COM @A,pathname ptr
 @A=@A+4
 ON @P,:done,:access,:type,:aux,:storage,:eof
:res ADRL @A+E
 COM @A+E,resource eof
:eof ADRL @A+A
 COM @A+A,eof
:storage DW @A+8
 COM @A+8,storage type
:aux ADRL @A+4
 COM @A+4,auxtype
:type DW @A+2
 COM @A+2,type
:access DW @A
 COM @A,access
:done ENDS

It would be nice if there was similar functionality in SourceGen -- either a data-centric language like they have or just use c# scripting. (with file access the c# script could even execute orca disasm or fb files).

ksherlock avatar Jan 09 '25 19:01 ksherlock

The SourceGen equivalent to the scripts you posted is this. As you note, it's triggered by a JSL, but it's not limited to just formatting the bytes near the JSL. The ProDOS and GS/OS scripts follow the pointers and format the parameter block.

The JSR/JSL/BRK mechanism is essentially passive: you add the script to the project, and magic happens. For visualizers, you add an element that invokes a script with a set of parameters. What you're proposing is essentially a visualizer that applies formatting instead of generating graphics.

I've resisted adding a separate data script mechanism because it's hard to find something that handles all situations without being excessively complex. (Also, I'd be shocked if the number of people who actually used it required more than one hand to count.)

fadden avatar Jan 09 '25 20:01 fadden