Jump to content
Kaj de Vos

First DOS tool in new programming language

Recommended Posts

Posted (edited)

Previous demo here

 

It's the first anniversary of my language project. To celebrate, here is the first tool written in it:

 

https://language.meta.frl/programs/DOS/platforms/Atari/8-bit/WHERE.XEX

 

 

It's an alternative for the ?DIR command in SpartaDOS and RealDOS, the pwd command on Unix systems, and the cd command (without parameter) in MS-DOS/Windows.

 

An amazing amount of design and research went into this tiny and seemingly trivial program. It will be a template for future programs. Here are just some of the issues with making it cross-platform:

 

https://eklitzke.org/path-max-is-tricky

 

For reference, here is the very same program compiled for my 64-bit Linux development system:

 

https://language.meta.frl/programs/DOS/platforms/Linux/64-bit/AMD/where

 

Thanks go to the people here for their advice, especially @sanny, who helped get it to work, and extended CC65.

 

It's probably most comfortable to rename the Atari version to WHERE.COM for SpartaDOS and RealDOS. The Linux version needs to be made executable as per usual:

chmod +x where

On command-line systems, a few command-line options are available:

where help

where about

where version

Linux:

./where help

Without parameters, on command-line systems, the program will just print the current working folder and return to the command-line. On Atari systems with a menu-based DOS, it will ask for a key press before returning, to give you the chance to read the output before the menu clears the screen.

 

The program is really only useful on SpartaDOS version 3 and up and on RealDOS, possibly also on SpartaDOS 2. On other DOS'es, including SpartaDOS 1, it cannot get the current working folder. It will report > (the root folder in SpartaDOS format) which is correct for DOS'es that don't support sub-directories. On MyDOS, it will report "D:" which is not very useful, but not incorrect, because it denotes the current drive and working folder.

where help

gets formatted for 40-columns display. If you have an 80-colums driver that properly sets RMARGN, and on Linux, the output is formatted for 80-columns display.

 

(Do wide-display drivers set RMARGN? The wide display mode in Altirra does not, so it doesn't get the wide formatting.)

 

Any error messages are also formatted for 40-columns and 80-colums displays accordingly.

 

Test reports are welcome, especially for SpartaDOS 2, RealDOS, and 80-colums drivers.

Edited by Kaj de Vos
Still don't want D: replaced with smileys
  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks! So it doesn't work on SpartaDOS X?

 

There is so much that I forgot from a quarter century ago. Is there any change in SDX in the XIO command for getting the working folder, compared to SpartaDOS 3?

Share this post


Link to post
Share on other sites
42 minutes ago, Kaj de Vos said:

Is there any change in SDX in the XIO command for getting the working folder, compared to SpartaDOS 3?

To be honest, I do not know - my first SpartaDOS years back then was SpartaDOS X and so it remains until this day. The CIO is not often used in SDX utilities, so I just checked, if XIO 48 works as advertised in the SDX User's Manual, section 6.3.18. But it seems so:

 

obraz.thumb.png.e9243b57df791ce8c435048e6cb14188.png

 

The program:

 

test.zip

  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks! Odd. I will have to see if the problem is in my code or in CC65.

 

I will also have to change the \ to internal (universal) format. Does SDX still take the original > SpartaDOS path separator?

Share this post


Link to post
Share on other sites
5 minutes ago, Kaj de Vos said:

I will have to see if the problem is in my code or in CC65.

After the recent, much revealing discussion on the left margin issue in CC65 libs, I would not be much surprised if it was the latter.

 

6 minutes ago, Kaj de Vos said:

Does SDX still take the original > SpartaDOS path separator?

Yes, "\" and ">" are equivalent as path separators in SDX.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

CC65's implementation doesn't pass the "D:" to the XIO command. I guess that's the main problem, because then the DOS can't know of which drive you want the working folder.

 

It also doesn't seem to set the auxiliary bytes to zero. Does that matter?

Share this post


Link to post
Share on other sites
Posted (edited)

If you use `open()` CC65 does prepend Dn: to the file name.

 

Edit: I see. You are talking about `getcwd()`, aren't you? Yes, there is no such thing. SpartaDOS should use the current drive.

Edited by sanny

Share this post


Link to post
Share on other sites

Sigh, I have it working on SDX now, but now it doesn't work on SpartaDOS 3 anymore. Stay tuned.

 

On a positive note, it's very exciting to run SpartaDOS X again after a quarter century, especially with a (c) 2020.

Share this post


Link to post
Share on other sites

It was said above that SpartaDOS should use the current drive. It might be worth then taking a look a the code which gets the information on the current drive from the system and how it is done.

Share this post


Link to post
Share on other sites

Yes, I'm currently including that.

 

Your example with "D:" only works on SDX. It's nice, but the example in the manual uses "Dx:" and that is what earlier SpartaDOS requires. It's a bit of a mystery how it worked before without being passed this value.

Share this post


Link to post
Share on other sites
17 minutes ago, Kaj de Vos said:

but the example in the manual uses "Dx:"

That is no matter: "Dx:" in SpartaDOS X also means "D:" (then x = current drive and is implied).

Share this post


Link to post
Share on other sites

Passing an empty string doesn't work. I'm pretty sure SpartaDOS 3 just happened to work because a file spec from some previous boot operation happened to linger in the IOCB.

Share this post


Link to post
Share on other sites
1 minute ago, drac030 said:

That is no matter: "Dx:" in SpartaDOS X also means "D:" (then x = current drive and is implied).

Yes, on SDX, not on previous SpartaDOS.

Share this post


Link to post
Share on other sites
Posted (edited)
18 minutes ago, Kaj de Vos said:

Yes, on SDX, not on previous SpartaDOS.

I know, I am just saying that it is no matter that the manual says "Dx:", because this does not forbid using "D:" anyways. Of course SD 3 (maybe except 3.2g) has no concept of current drive IIRC, so what is "current" must be established by other means.

Edited by drac030

Share this post


Link to post
Share on other sites

SpartaDOS 3 has no current drive, at least not denoted for the outer world by "D:", but it does have a current folder on each drive.

 

More anomalies. When the XIO call is made to work, CC65 returns proper paths for SpartaDOS 3, but when SpartaDOS X is in a root, getcwd () returns an empty string, which is not standards-compliant. The SDX command line behaves the same. The XIO interface changed behaviour quite a bit.

Share this post


Link to post
Share on other sites
23 minutes ago, Kaj de Vos said:

CC65 returns proper paths for SpartaDOS 3, but when SpartaDOS X is in a root, getcwd () returns an empty string

Yup, it has always been so in SDX: "path to root directory", when at the root, it is NUL.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...