hoglet67 / MMFS

Modern SD Card File System for Acorn 8-bit Machine (Master, Beeb, Electron)
68 stars 17 forks source link

Update *OPT 5,1 to ignore *DISK/*DISC #7

Closed hoglet67 closed 5 years ago

hoglet67 commented 7 years ago

Looking at the MMFS code, there does seem to be a OPT 5,1 implemented that causes DISK and *DISC to do nothing. But what I think is needed here is for them to be ignored and passed down to a lower priority ROM.

SteveFosdick commented 5 years ago

Looking at, and tracing, the code this should already be correct. Using the userport plain MMFS version the DISC command is thus:

.CMD_DISC
     8DBF   A6 F4      LDX &F4
     8DC1   BD F0 0D   LDA &0DF0,X
     8DC4   29 40      AND #&40
     8DC6   F0 01      BEQ &8DC9
     8DC8   60         RTS
.CMD_CARD
     8DC9   A9 FF      LDA #&FF

Tracing this in B-Em, that RTS goes back to code that restores the registers:

8DBF: A6 F4       LDX F4      >s
8DC1: BD F0 0D    LDA 0DF0,X  >r
    registers for core6502
 A=BE X=0D Y=05 S=F3 P= V     PC=8DC1
>writem 0dfd 40
>s
8DC4: 29 40       AND #40     >s
8DC6: F0 01       BEQ 8DC9    >s
8DC8: 60          RTS         >s
8428: 68          PLA         >s
8429: A8          TAY         >s
842A: 68          PLA         >s
842B: AA          TAX         >s
842C: 68          PLA         >s
842D: 60          RTS         >s
F17E: AA          TAX         >r
    registers for core6502
 A=04 X=0D Y=01 S=FA P= V     PC=F17E
>

So at this point A is 04 so this should be unclaimed. I am taking it here that a return to the OS range address is a return into the service call loop over the sideways ROM which I think, from memory starts at F168. This is on a BBC B with OS 1.20.

SteveFosdick commented 5 years ago

And, for completeness, compare with the path where the command is acted upon:

cpu core6502: Break at 8DBF
8DBF: A6 F4       LDX F4      >s
8DC1: BD F0 0D    LDA 0DF0,X  >s
8DC4: 29 40       AND #40     >s
8DC6: F0 01       BEQ 8DC9    >s
8DC9: A9 FF       LDA #FF     >s
8DCB: 20 00 96    JSR 9600    >s
9600: 48          PHA         >s
9601: 8A          TXA         >s
9602: 48          PHA         >s
9603: A9 00       LDA #00     >s
9605: BA          TSX         >s
9606: 9D 09 01    STA 0109,X  >s
9609: 68          PLA         >s
960A: AA          TAX         >s
960B: 68          PLA         >s
960C: 60          RTS         >s

So this subroutine is overwriting the saved value of A on the stack with 0 so the call will be claimed and in the source is called."ReturnWithA0".

hoglet67 commented 5 years ago

Thanks for that analysis Steve.

I've just tested it (with Acorn 1770 DFS 2.26 in a Model B) and it indeed works: https://stardot.org.uk/forums/viewtopic.php?p=245877#p245877

hoglet67 commented 5 years ago

And also works with Solidisk DFS2.2 Issue 2.

Closing....

SteveFosdick commented 5 years ago

Referring back to the thread and the point about other DFSes corrupting MMFS's private workspace it looks to me like the flag for this option is not stored in the private workspace but as a single bit the single byte the OS allows each ROM and in which ROMs typically store the page number of the first page of their private workspace. That scheme assumes the first page of private workspace will never have bit 6 set.