Skip to content
New issue

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

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

Already on GitHub? # to your account

Make the DOSVER function call return 6Fh in C in DOS 1 mode #128

Merged
merged 1 commit into from
Nov 30, 2023

Conversation

Konamiman
Copy link
Owner

@Konamiman Konamiman commented Oct 29, 2023

MSX-DOS doesn't modify the main registers when an unknown function call is invoked, and the Dutch Moonsound Veterans music disk uses this fact to detect the MSX-DOS version in use, like this:

ld c,6Fh  ;_DOSVER function (introduced in MSX-DOS 2)
call F37Dh
ld a,c
cp 6Fh
ret z
;DOS 2 assumed from this point

However this MSX-DOS version detection method is technically incorrect. The MSX-DOS 2 function codes specification says the following regarding the _DOSVER function (emphasis mine):

For compatibility with MSX-DOS 1.0, the following procedure should always be followed in using this function. Firstly if there is any error (A<>0) then it is not MSX-DOS at all. Next look at register B. If this is less than 2 then the system is earlier than 2.00 and registers C and DE are undefined.

Nextor does corrupt the C register when _DOSVER is invoked in MSX-DOS 1 mode (unless the magic numbers are supplied, see the relevant documentation) and this is what causes the music disk to fail. So strictly speaking the reported issue is not a bug in Nextor but an incorrect usage of the function.

However, the fix is trivial and makes Nextor work more consistently with how "pure" MSX-DOS 1 does, thus this pull request implements it: now when _DOSVER is invoked in MSX-DOS 1 mode without the magic numbers supplied, it will preserve the contents of register C.

Closes #120.

The MSX-DOS 2 documentation says that DOSVER in DOS 1 returns B=0
and C undefined, but the fact is that in MSX-DOS 1 register C is
preserved (so 6Fh) and seems like some programs rely on that fact
to detect the DOS 1 mode. Nextor was corrupting C in this case,
so even if strictly speaking that shouldn't be an issue, this commit
changes the behavior of DOSVER in DOS 1 to return C=6Fh.
@Konamiman Konamiman added this to the v2.1.2 milestone Oct 29, 2023
@Konamiman Konamiman self-assigned this Oct 29, 2023
@Konamiman Konamiman changed the base branch from v2.1 to v2.1.2 November 21, 2023 12:19
@Konamiman Konamiman merged commit f73a87d into v2.1.2 Nov 30, 2023
@Konamiman Konamiman mentioned this pull request Nov 30, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DSK/EMU file doesn't start properly.
1 participant