Dotneteer / spectnetide

ZX Spectrum IDE with Visual Studio 2017 and 2019 integration
MIT License
205 stars 27 forks source link

VmState files seem to not persist values written to AY-3-8912 I/O ports A and B #230

Closed MDDCloner closed 2 years ago

MDDCloner commented 2 years ago

It seems that the .VmState files do not persist values written to I/O ports A and B in SpectNet.

Looking at the "PsgRegs" section of a .VmState file, the first clue is that the last two entries have Value=0, ModifiedTact=0. More conclusively, writing a value to say PSG port B should be preserved... but it isn't. For example, the following code should result in the value $59 being stored in Port B.

        ld  bc,AY_SELRD_PORT        ; Set AY sound chip I/O port B value to #59 => security thing
        ld  a,AY_PORT_B
        ld  e,#59
        out (c),a
        ld  b,high(AY_SELWR_PORT)
        out (c),e

However after executing this code and doing a "Save VM State", again the last two entries have Value=0, ModifiedTact=0.

For someone who knows what they are doing, the source seems to be in here and I suspect it wouldn't be too difficult a fix. Thoughts?

gusmanb commented 2 years ago

You are correct, the registers 14 and 15 were not backed in the persistence array so those were not saved in the vm state.

I have patched the code and it's ready on the master branch, if I have time I will create a new package this weekend.

Cheers!