Harry Potter Posted March 2, 2021 Share Posted March 2, 2021 I am wondering how to handle drive access on an Atari 8 computer using cc65. I am also wondering how to handle keyboard input from assembler. I want to create Atari 8 ports of SimpleIO, MadLib and Template Creator. BTW, should I advertise Template Creator for DOS and Windows here? Quote Link to comment Share on other sites More sharing options...
danwinslow Posted March 2, 2021 Share Posted March 2, 2021 (edited) Well, you could use the usual C suspects such as fopen, fread, fscanf, etc.. Or you could go down 1 layer to the CIO routines, which involves filling out a memory structure and calling a few OS routines. See De Re Atari and/or Mapping the Atari for more info. https://www.atariarchives.org/dere/chapt08.php#H8_6 https://www.atariarchives.org/mapping/memorymap.php Edited March 2, 2021 by danwinslow Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted March 2, 2021 Author Share Posted March 2, 2021 You've been helpful. Thank you. 1 Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted March 2, 2021 Share Posted March 2, 2021 small example of cc65 code, just checks a file exists :- // gets input filename and checks if it exists int getinfile(void) { int done=0; char ret; FILE *finput; char infile[30]; gets(infile); // dummy to clear buffer of CR do { clearline(0,12); clearline(0,10); printf("Enter Input Filename (RETURN to Abort)"); clearline(0,11); gets(infile); if((strlen(infile)) == 0) // CR so abort return(1); ret = checkfile(); if(strlen(infile) > 30) { clearline(0,12); printf("Filename too long %s",infile); delay(90); } else { finput=fopen(infile,"r"); // check if file exists if(finput == NULL) { clearline(0,12); printf("File does not exist"); delay(90); } else { fclose(finput); done=1; } } }while(!done); return(0); } Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted March 2, 2021 Author Share Posted March 2, 2021 (edited) I thank you for your information. All I really need that can't be accessed via the ANSI C functions is the file attributes. I don't know how to access the attributes of an Atari 8 file. Edited March 2, 2021 by Harry Potter I forgot to mention something. Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted March 2, 2021 Share Posted March 2, 2021 If your using Spartados X there's a section on file attributes using the ATR command, reading the attributes doesn't seem to be covered (at least I can't see it). It will also depend on what DOS your using, in Atari DOS's I think you can only lock a file and the way to see that is open the disk directory and look for a "*" in the filename. Here's a quick BASIC program that opens the directory and displays the contents 1 TRAP 100 10 OPEN #1,2,0,"D:*.*" 20 GET #1,A 30 ? CHR$(A); 40 GOTO 20 100 CLOSE #1 READY RUN * DOS SYS 037 * DUP SYS 042 CENT2021M65 009 CENT2021ASM 016 CENT2021OBJ 002 TESTBOOTOBJ 018 CENTNEW M65 016 CENTNEW OBJ 004 CENTNEW ASM 031 * TEMP00 ASM 007 532 FREE SECTORS READY Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted March 2, 2021 Author Share Posted March 2, 2021 I have everything I need; thank you. Just one more question: How do I read the directory from a cc65 program? Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted March 2, 2021 Share Posted March 2, 2021 (edited) I think the only way is to use direct CIO calls as @danwinslow said, you would need to set the AUX1 byte to 2, in the OPEN then read a character at a time to retrieve the directory listing . Probably easier to do it as an assembler procedure within cc65 Edited March 2, 2021 by TGB1718 Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted March 2, 2021 Author Share Posted March 2, 2021 Okay. Thank you. Quote Link to comment Share on other sites More sharing options...
ilmenit Posted March 3, 2021 Share Posted March 3, 2021 13 hours ago, danwinslow said: Well, you could use the usual C suspects such as fopen, fread, fscanf, etc.. Or you could go down 1 layer to the CIO routines, which involves filling out a memory structure and calling a few OS routines. See De Re Atari and/or Mapping the Atari for more info. https://www.atariarchives.org/dere/chapt08.php#H8_6 https://www.atariarchives.org/mapping/memorymap.php In CC65 there is one more intermediate layer between C functions (like fopen, fread etc) and OS routines: #include <fcntl.h> with functions such as open, read, write etc. - they are smaller variants of the fXXX functions. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted March 3, 2021 Author Share Posted March 3, 2021 Thanks, again. Quote Link to comment Share on other sites More sharing options...
sanny Posted March 3, 2021 Share Posted March 3, 2021 16 hours ago, Harry Potter said: I have everything I need; thank you. Just one more question: How do I read the directory from a cc65 program? opendir/readdir/closedir 1 Quote Link to comment Share on other sites More sharing options...
sanny Posted March 3, 2021 Share Posted March 3, 2021 17 hours ago, Harry Potter said: I thank you for your information. All I really need that can't be accessed via the ANSI C functions is the file attributes. I don't know how to access the attributes of an Atari 8 file. What attributes are you talking about? Quote Link to comment Share on other sites More sharing options...
danwinslow Posted March 3, 2021 Share Posted March 3, 2021 I think he means things like size, date, etc. He might also mean permissions, but of course most 8bits are anarchy in that department. It's an interestig question though - do any 8bits have anything like file ownership and individual r/w permissions? Going OT because I can and the OP has already said he has quite enough info/ 5 hours ago, ilmenit said: In CC65 there is one more intermediate layer between C functions (like fopen, fread etc) and OS routines: #include <fcntl.h> with functions such as open, read, write etc. - they are smaller variants of the fXXX functions. Yep, true, and that's actually part of the base C library on any box, which is why I lumped it all in together. Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted March 3, 2021 Share Posted March 3, 2021 Did a bit of checking, I think the answer is that cc65 does not support retrieving file attributes, in C you can use the stat() function. Although cc65 has the header file sys/stat.h it is all but empty, it should at the very least have this:- struct stat { dev_t st_dev; /* ID of device containing file */ ino_t st_ino; /* inode number */ mode_t st_mode; /* protection */ nlink_t st_nlink; /* number of hard links */ uid_t st_uid; /* user ID of owner */ gid_t st_gid; /* group ID of owner */ dev_t st_rdev; /* device ID (if special file) */ off_t st_size; /* total size, in bytes */ blksize_t st_blksize; /* blocksize for file system I/O */ blkcnt_t st_blocks; /* number of 512B blocks allocated */ time_t st_atime; /* time of last access */ time_t st_mtime; /* time of last modification */ time_t st_ctime; /* time of last status change */ }; So a simple piece of code to use it could be:- int main ( int argc, char *argv[]) { struct stat MyStat; if(argc <= 1) { printf("Usage:= mystat <filename>\n"); exit(1); } if (stat(argv[(argc - 1)], &MyStat) < 0) printf("Error = %s\n", strerror(errno)); else printf( "File Permissions:= %d\n", MyStat.st_mode ); return 0; } Quote Link to comment Share on other sites More sharing options...
sanny Posted March 3, 2021 Share Posted March 3, 2021 Yes, that's missing in cc65. I've also noticed that now. Do you know how to get that information inside the "stat" struct on the Atari? MyDOS, Sparta, AtariDOS would be the main targets. Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted March 3, 2021 Share Posted March 3, 2021 I think you would have to write something yourself to deal with those as they have different attributes, Sparta has the most features I think, but as I said before, I know how to set attributes, but not found a way to see them, AtariDOS, it's the "*" in the filename for a locked file, so fairly easy to detect that, I've not used MyDos, but you may find some info here :- http://www.mathyvannisselroy.nl/mydos.htm Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted March 3, 2021 Author Share Posted March 3, 2021 By "attributes" I mean anything attached to a file that may need to be preserved when copying a file. If that is not necessary, then I have everything I need. Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted March 3, 2021 Share Posted March 3, 2021 Have a look at SpartadosX Copy command, it does allow for some attributes to be preserved These switches are available: /B - backup mode /C - confirmation mode /D - do not preserve date and time /I - ask before overwriting a file /K - copy and set attribute '+A' to the original file /M - delete the source file (move) /N - skip existing destination entries /Q - do not print anything (except error messages) /R - dig recursively into subdirectories /S - switch off display during copy /V - summary (number of files and directories copied) 1 Quote Link to comment Share on other sites More sharing options...
sanny Posted March 4, 2021 Share Posted March 4, 2021 Look at the 'stat' struct posted before. I would need to programmatically query this info (when available, uid for example doesn't exist on the Atari DOSes I know) Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted March 4, 2021 Share Posted March 4, 2021 (edited) @Harry Potter What are the use-cases in the library/wrapper you are building for these - on the A8 platform they aren't too much use, with the exception of SpartaDos where, say you wanted to make a Make tool, then timestamps would be useful. But in stock Atari DOS you've typically only got a 'deleted' or 'locked' flag to go with, no timestamp. Edited March 4, 2021 by Wrathchild Quote Link to comment Share on other sites More sharing options...
danwinslow Posted March 4, 2021 Share Posted March 4, 2021 Hehe, posting a technical question on this board is like waving a raw T-bone in front of a pack of hungry wolves. Smart ones. 1 Quote Link to comment Share on other sites More sharing options...
TGB1718 Posted March 4, 2021 Share Posted March 4, 2021 ? ? ? ? ? ? ? ? ? ? ? ? ? Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted March 4, 2021 Author Share Posted March 4, 2021 Okay. SimpleIO is a quick-and-dirty solution for writing to the screen and accepting keyboard input that uses the kernal directly; MadLib is my version of the MadLib word game with eight stories, and Template Creator is a program that can derive new files from old ones. Quote Link to comment Share on other sites More sharing options...
+CharlieChaplin Posted March 4, 2021 Share Posted March 4, 2021 Hmmm, file status? Something like: normal file file locked file deleted file not closed <filename.ext> file occupies sectors beyond 720 (Atari DOS 2.5 and compatibles in 130k format) file beyond sector 720 and locked file beyond sector 720 and deleted file beyond sector 720 and not closed file uses both sides of a disk (e.g. on a 360k disk) not a file, just a DIR comment (usually with a length of 000 sectors) sub-directory (MyDOS, SpartaDOS, etc.) ... Maybe a XIO 13 (status request) can help here ? 1 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.