I've got it hooked up to the logic analyser now, and it's working to a degree - there are some prediction failures however, either due to my device logging the data wrongly or something to do with the way the logic analyser and decoder are sampling the signal from my device.
To do this I've connected the eight data bits from my device to the logic analyser, along with the clock pulse signal which behaves a lot like phi2 - the counters count up on the rising edge, so sampling the data on the falling edge should be good. The Arduino code is meant to do this at a sedate rate - with at least 10us low and 10us high on every cycle - but I actually had to set the sample rate in sigrok-cli rather high, or it was missing data.
I haven't figured out the method for doing synchronous captures with it yet, but I saw hoglet's posts about that and will try that when I get my head around it! This is an asynchronous capture of my device replaying the log it took from my test program booting up and starting to copy itself to RAM:
Code:
gfoot@box:~/logicanalyzer/6502Decoder$ sigrok-cli -d fx2lafw --config samplerate=500KHz --channels D0,D1,D2,D3,D4,D5,D6,D7,D8 -o data2.bin -O binary --triggers D8=r --samples=1000000
gfoot@box:~/logicanalyzer/6502Decoder$ ./decode6502 -h -s --sync= --rdy= --rst= --rnw= --phi2=8 --vecrst=a2e000 --cpu=65c02 <data2.bin
???? : : RESET !! : A=?? X=?? Y=?? SP=?? N=? V=? D=0 I=1 Z=? C=?
E000 : A2 FF : LDX #FF : A=?? X=FF Y=?? SP=?? N=1 V=? D=0 I=1 Z=0 C=?
E002 : 9A : TXS : A=?? X=FF Y=?? SP=FF N=1 V=? D=0 I=1 Z=0 C=?
E003 : 58 : CLI : A=?? X=FF Y=?? SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E004 : A0 42 : LDY #42 : A=?? X=FF Y=42 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E006 : B9 1E E0 : LDA E01E,Y : A=F9 X=FF Y=42 SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E009 : 99 FF FF : STA FFFF,Y : A=F9 X=FF Y=42 SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E00C : 88 : DEY : A=F9 X=FF Y=41 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E00D : D0 F7 : BNE E006 : A=F9 X=FF Y=41 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E006 : B9 1E E0 : LDA E01E,Y : A=80 X=FF Y=41 SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E009 : 99 FF FF : STA FFFF,Y : A=80 X=FF Y=41 SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E00C : 88 : DEY : A=80 X=FF Y=40 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E00D : D0 F7 : BNE E006 : A=80 X=FF Y=40 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E006 : B9 1E E0 : LDA E01E,Y : A=FF X=FF Y=40 SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E009 : 99 FF FF : STA FFFF,Y : A=FF X=FF Y=40 SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E00C : 88 : DEY : A=FF X=FF Y=3F SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E00D : D0 F7 : BNE E006 : A=FF X=FF Y=3F SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E006 : B9 1E E0 : LDA E01E,Y : A=70 X=FF Y=3F SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E009 : 99 FF FF : STA FFFF,Y : A=70 X=FF Y=3F SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E00C : 88 : DEY : A=70 X=FF Y=3E SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E00D : D0 F7 : BNE E006 : A=70 X=FF Y=3E SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E006 : B9 1E E0 : LDA E01E,Y : A=8E X=FF Y=3E SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E009 : 99 FF FF : STA FFFF,Y : A=8E X=FF Y=3E SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E00C : 88 : DEY : A=8E X=FF Y=3D SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E00D : D0 F7 : BNE E006 : A=8E X=FF Y=3D SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E006 : B9 1E E0 : LDA E01E,Y : A=F5 X=FF Y=3D SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E009 : 99 FF FF : STA FFFF,Y : A=F5 X=FF Y=3D SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E00C : 88 : DEY : A=F5 X=FF Y=3C SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E00D : D0 F7 : BNE E006 : A=F5 X=FF Y=3C SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E006 : B9 1E E0 : LDA E01E,Y : A=A2 X=FF Y=3C SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E009 : 99 FF FF : STA FFFF,Y : A=A2 X=FF Y=3C SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E00C : 88 : DEY : A=A2 X=FF Y=3B SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E00D : D0 F7 : BNE E006 : A=A2 X=FF Y=3B SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E006 : B9 1E E0 : LDA E01E,Y : A=C8 X=FF Y=3B SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E009 : 99 FF FF : STA FFFF,Y : A=C8 X=FF Y=3B SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E00C : 88 : DEY : A=C8 X=FF Y=3A SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E00D : D0 F7 : BNE E006 : A=C8 X=FF Y=3A SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E006 : B9 1E E0 : LDA E01E,Y : A=80 X=FF Y=3A SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E009 : 99 FF FF : STA FFFF,Y : A=80 X=FF Y=3A SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E00C : 88 : DEY : A=80 X=FF Y=39 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E00D : D0 F7 : BNE E006 : A=80 X=FF Y=39 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E006 : B9 1E E0 : LDA E01E,Y : A=EF X=FF Y=39 SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E009 : 99 FF FF : STA FFFF,Y : A=EF X=FF Y=39 SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E00C : 88 : DEY : A=EF X=FF Y=38 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E00D : D0 F7 : BNE E006 : A=EF X=FF Y=38 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E006 : B9 1E E0 : LDA E01E,Y : A=10 X=FF Y=38 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E009 : 99 FF FF : STA FFFF,Y : A=10 X=FF Y=38 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E00C : 88 : DEY : A=10 X=FF Y=37 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E00D : D0 F7 : BNE E006 : A=10 X=FF Y=37 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E006 : B9 1E E0 : LDA E01E,Y : A=01 X=FF Y=37 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E009 : 99 FF FF : STA FFFF,Y : A=01 X=FF Y=37 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E00C : 88 : DEY : A=01 X=FF Y=36 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E00D : D0 F7 : BNE E006 : A=01 X=FF Y=36 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E006 : B9 1E E0 : LDA E01E,Y : A=E6 X=FF Y=36 SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E009 : 99 FF FF : STA FFFF,Y : A=E6 X=FF Y=36 SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E00C : 88 : DEY : A=E6 X=FF Y=35 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E00D : D0 F7 : BNE E006 : A=E6 X=FF Y=35 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E006 : B9 1E E0 : LDA E01E,Y : A=F3 X=FF Y=35 SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E009 : 99 FF FF : STA FFFF,Y : A=F3 X=FF Y=35 SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E00C : 88 : DEY : A=F3 X=FF Y=34 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E00D : D0 F7 : BNE E006 : A=F3 X=FF Y=34 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E006 : B9 1E E0 : LDA E01E,Y : A=D0 X=FF Y=34 SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E009 : 99 FF FF : STA FFFF,Y : A=D0 X=FF Y=34 SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E00C : 88 : DEY : A=D0 X=FF Y=33 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E00D : D0 F7 : BNE E006 : A=D0 X=FF Y=33 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E006 : B9 1E E0 : LDA E01E,Y : A=88 X=FF Y=33 SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E009 : 99 FF FF : STA FFFF,Y : A=88 X=FF Y=33 SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E00C : 88 : DEY : A=88 X=FF Y=32 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E00D : D0 F7 : BNE E006 : A=88 X=FF Y=32 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E006 : B9 1E E0 : LDA E01E,Y : A=09 X=FF Y=32 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E009 : 99 FF FF : STA FFFF,Y : A=09 X=FF Y=32 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E00C : 88 : DEY : A=09 X=FF Y=31 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E00D : D0 F7 : BNE E006 : A=09 X=FF Y=31 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E006 : B9 1E E0 : LDA E01E,Y : A=D0 X=FF Y=31 SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E009 : 99 FF FF : STA FFFF,Y : A=D0 X=FF Y=31 SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E00C : 88 : DEY : A=D0 X=FF Y=30 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E00D : D0 F7 : BNE E006 : A=D0 X=FF Y=30 SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E006 : B9 1E E0 : LDA E01E,Y : A=00 X=FF Y=30 SP=FF N=0 V=? D=0 I=0 Z=1 C=?
E009 : 99 FF FF : STA FFFF,Y : A=FF X=FF Y=30 SP=FF N=0 V=? D=0 I=0 Z=1 C=? prediction failed
E00C : 88 : DEY : A=FF X=FF Y=2F SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E00D : D0 F7 : BNE E006 : A=FF X=FF Y=2F SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E006 : B9 1E E0 : LDA E01E,Y : A=D1 X=FF Y=2F SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E009 : 99 FF FF : STA FFFF,Y : A=D1 X=FF Y=2F SP=FF N=1 V=? D=0 I=0 Z=0 C=?
E00C : 88 : DEY : A=D1 X=FF Y=2E SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E00D : D0 F7 : BNE E006 : A=D1 X=FF Y=2E SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E006 : B9 1E E0 : LDA E01E,Y : A=01 X=FF Y=2E SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E009 : 99 FF FF : STA FFFF,Y : A=DF X=FF Y=2E SP=FF N=0 V=? D=0 I=0 Z=0 C=? prediction failed
E00C : 88 : DEY : A=DF X=FF Y=2D SP=FF N=0 V=? D=0 I=0 Z=0 C=?
E00D : D0 F7 : BNE E006 : A=DF X=FF Y=2D SP=FF N=0 V=? D=0 I=0 Z=0 C=?
... etc ...
Edit - I've investigated that further, and there were two problems there. One was that the logic analyser was sampling at a much lower rate than I was requesting - I don't know why. I turned up its sample rate to compensate, but coming back to it all later on I found that it wasn't running slow any more, so all of a sudden I had far too many captures, and I've turned that down again now in my command line, to 50kHz. My sketch is inserting at least 100us delay on each phase of the clock, and this leads to five or six samples being taken within each clock period, which feels like a good amount.
The more serious problem was that I was tapping the data bus of my computer on the far side of a transceiver, and the propagation delay of the transceiver was leading to my circuit sampling the data bus too early. Inserting two AHCT inverters between the CPU clock and my circuit delayed things enough to resolve that. Connecting it to the CPU's data bus directly also worked but I'd like to avoid adding load to that if possible.
I also had bugs to fix in my Arduino sketch code, and it's still pretty terrible code - I don't find Arduino code comfortable to write. I will revisit it another time though, and for now I'll draw a line under this, make a PCB and say it works.