Closed skx closed 4 months ago
Suspecting a bug in the BBCBASIC itself.
The following session demonstrates both a load and a save:
BBC BASIC (Z80) Version 3.00
(C) Copyright R.T.Russell 1987
>load "FOO"
Mistake
>LOAD "FOO"
CP/M Error
>10 PRINT "OK"
>SAVE "STEVE"
CP/M Error
>*CPM
B>exit
In the case of a load we get a single log, shows the file doesn't exist, as expected. Attempting to open a file that does exist we see no further I/O.
For the SAVE call we see only a single call to F_DELETE, there is no subsequent open/write/close. I need to add logging to the F_DELETE call to see which file is even tried to be deleted - but in this case nothing existed anyway.
OK Running SAVE "CAKE"
results in the single BDOS call:
{"time":"2024-06-21T13:32:13.39065192+03:00","level":"INFO","msg":"BDOS","name":
"F_DELETE","syscall":19,"syscallHex":"0x13","registers":{"A":"13","B":"00","C":"
13","D":"00","E":"5C","F":"3A","H":"3E","L":"00","BC":"0013","DE":"005C","HL":"3
E00"}}
{"time":"2024-06-21T13:32:13.390701097+03:00","level":"DEBUG","msg":"SysCallDeleteFile","glob":"CAKE.BBC"}
Which is crazy. I think not a bug in the emulator, just in the binary. Will investigate sources to take it further:
OK this change lets us get further:
index c5c3004..ee23c85 100644
--- a/cpm.asm
+++ b/cpm.asm
@@ -433,7 +433,7 @@ INCRDF: CALL INCSEC
READ: CALL SETDMA
LD A,33
BDOS1: CALL BDOS0 ;*
- JR NZ,CPMERR ;*
+; JR NZ,CPMERR ;* - steve
OR A ;*
RET ;*
CPMERR: LD A,255 ;* CP/M 3
Looks like it is expecting the zero flag to be set for some reason, when calling CP/M.
Now we fail with a better error and cake.bbc
was created:
A>b:
B>bbcbasic
BBC BASIC (Z80) Version 3.00
(C) Copyright R.T.Russell 1987
>10 PRINT "CAKE"
>SAVE "CAKE"
{"time":"2024-06-21T13:55:37.554230916+03:00","level":"ERROR","msg":"Unimplemented BDOS Syscall","syscall":40,"syscallHex":"0x28"}
Error running CCP: UNIMPLEMENTED
That means I need to add support for:
BDOS function 40 (F_WRITEZF) - Write random with zero fill Supported by: CP/M 2.2 and later.
Entered with C=28h, DE=FCB address. Returns error codes in BA and HL.
As function 34, but if the write is to a newly allocated disc block the remainder of the block is filled with zeroes.
Success!
Now it works:
(C) Copyright R.T.Russell 1987
>10 PRINT "SAVED?"
>SAVE "CAKE"
>LIST
10 PRINT "SAVED?"
>NEW
>LIST
>LOAD "CAKE"
>LIST
10 PRINT "SAVED?"
>
Realized the real issue isn't to do with A-register, or Z-flag, instead it is the 16 bit return value which is expected.
Reopening for a fix that doesn't require any binary change to BBCBASIC.COM
This happens in both
cpmulater
andiz-cpm
so it might be a porting issue.Either way resolve it.