Kaj de Vos Posted June 18, 2021 Share Posted June 18, 2021 (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 June 18, 2021 by Kaj de Vos Still don't want D: replaced with smileys 1 Quote Link to comment Share on other sites More sharing options...
drac030 Posted June 18, 2021 Share Posted June 18, 2021 1 Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted June 18, 2021 Author Share Posted June 18, 2021 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? Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted June 18, 2021 Author Share Posted June 18, 2021 Ah, at least 80 columns does work. ? Quote Link to comment Share on other sites More sharing options...
drac030 Posted June 18, 2021 Share Posted June 18, 2021 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: The program: test.zip 1 Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted June 18, 2021 Author Share Posted June 18, 2021 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? Quote Link to comment Share on other sites More sharing options...
drac030 Posted June 18, 2021 Share Posted June 18, 2021 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. 1 1 Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted June 19, 2021 Author Share Posted June 19, 2021 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? Quote Link to comment Share on other sites More sharing options...
sanny Posted June 19, 2021 Share Posted June 19, 2021 (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 June 19, 2021 by sanny Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted June 19, 2021 Author Share Posted June 19, 2021 Yes, the code is in initcwd.s. It doesn't work with SpartaDOS X. Quote Link to comment Share on other sites More sharing options...
sanny Posted June 19, 2021 Share Posted June 19, 2021 I need to check... Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted June 19, 2021 Author Share Posted June 19, 2021 I published a new version with @drac030's extensions and a few more tweaks. The link is the same. Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted June 19, 2021 Author Share Posted June 19, 2021 I haven't tested on SpartaDOS X yet, but here is the CC65 patch: https://language.meta.frl/tools/CC65/Atari/8-bit/getcwd-SDX.diff Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted June 20, 2021 Author Share Posted June 20, 2021 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. Quote Link to comment Share on other sites More sharing options...
drac030 Posted June 20, 2021 Share Posted June 20, 2021 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. Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted June 20, 2021 Author Share Posted June 20, 2021 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. Quote Link to comment Share on other sites More sharing options...
drac030 Posted June 20, 2021 Share Posted June 20, 2021 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). Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted June 20, 2021 Author Share Posted June 20, 2021 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. Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted June 20, 2021 Author Share Posted June 20, 2021 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. Quote Link to comment Share on other sites More sharing options...
drac030 Posted June 20, 2021 Share Posted June 20, 2021 (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 June 20, 2021 by drac030 Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted June 20, 2021 Author Share Posted June 20, 2021 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. Quote Link to comment Share on other sites More sharing options...
drac030 Posted June 20, 2021 Share Posted June 20, 2021 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. Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted June 20, 2021 Author Share Posted June 20, 2021 Got it to work properly on SpartaDOS 2.3e, even on a non-SpartaDOS disk. Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted June 20, 2021 Author Share Posted June 20, 2021 Need to detect SpartaDOS 1.1 to not return an incorrect result. Quote Link to comment Share on other sites More sharing options...
Kaj de Vos Posted June 20, 2021 Author Share Posted June 20, 2021 Need to detect RealDOS, too, to return the best result. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.