Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible error in NextLib SaveSD method when file not exist #7

Closed
Duefectu opened this issue Dec 8, 2020 · 4 comments
Closed

Possible error in NextLib SaveSD method when file not exist #7

Duefectu opened this issue Dec 8, 2020 · 4 comments

Comments

@Duefectu
Copy link

Duefectu commented Dec 8, 2020

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.

@em00k
Copy link
Owner

em00k commented Dec 9, 2020

Thanks - $9e is write mode, but if this fixes zesaruxooo then I will commit the change. Thanks

@em00k
Copy link
Owner

em00k commented Dec 9, 2020

updated.

@em00k em00k closed this as completed Dec 9, 2020
@chernandezba
Copy link

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

@em00k
Copy link
Owner

em00k commented Dec 9, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants