Possible error in NextLib SaveSD method when file not exist
Duefectu opened this issue · 4 comments
In SaveSD method, after "fileopen" label loads b register with 158 ($9e), but this value isn't a valid, or at least documented value.
In ZEsarUX emulator don't work if the file not exist.
fileopen:
ld b,158 ; mode write
;db 33 ; open
;ld b,$0c
push ix
pop hl
; ld a,42
rst $08
db $9a ; F_OPEN
ld (filehandle),a
ret
Changing "ld b,158" by "ld b,$0e" works in ZEsarUX and CSpect emulators and in ZX-DOS+/GomaDOS+ devices.
fileopen:
ld b,$0e ; mode write
;db 33 ; open
;ld b,$0c
push ix
pop hl
; ld a,42
rst $08
db $9a ; F_OPEN
ld (filehandle),a
ret
Don't know if there is a hidden feature or really is a bug.
Thanks - $9e is write mode, but if this fixes zesaruxooo then I will commit the change. Thanks
updated.
This is not an issue with "zesaruxooo", it's a bug in your code
According to esxdos and nextzxos api:
F_OPEN ($9a)
B= access modes, a combination of:
any/all of:
esx_mode_read $01
esx_mode_write $02
esx_mode_user_header $40
plus one of:
esx_mode_open_exist $00
esx_mode_open_creat $08
esx_mode_creat_noexist $04
esx_mode_creat_trunc $0c
Your "ld b,158 (9EH)" does not match any of these modes combinations. Probably it's working on CSpect and real Next probably because they look only at bits of the value, not at the absolute value. But on ZEsarUX (using the esxdos handler, not on mmc emulation) I do look at the absolute value, to avoid mistakes and bugs like this
$9e is NOT a "write mode" for B register. You are confusing this B mode with the F_WRITE call ($9e)
Cheers