Re: [cc65] Reading Directory on Atari

From: Shawn Jefferson <jefferson_shawn_a8bit1yahoo.com>
Date: 2005-12-27 23:17:53
--- Christian Groessler <chris@groessler.org> wrote:

> Thanks for the hint. There is still some parsing
> needed for the different
> DOS versions, but this sounds more doable. I will
> try to implement it for
> the Atari.

Hi Chris,

All three major DOSes (DOS 2.5, SpartaDOS 3.3a, and
MyDOS 4.53) that I tested give the same output for the
normal read directory CIOV call.

Thanks to your help, I got the following code working
to read and parse the directory entry (it's still
pretty rough, lots of things need to be fixed still):


		.include    "atari.inc"
		.export     _open_dir, _read_dir_entry, _close_dir
		.export     _diriocb
		.import     findfreeiocb, clriocb
		.import     __oserror, __do_oserror
		.import     return0, return1
		.importzp   tmp1, tmp2, ptr1



_open_dir:      sta tmp1
		stx tmp2
		jsr findfreeiocb
		beq iocbok
		jmp return0

iocbok:         stx diriocb
		jsr clriocb
		ldx diriocb
		lda tmp1
		sta ICBAL,x
		lda tmp2
		sta ICBAH,x
		lda #OPEN
		sta ICCOM,x
		lda #OPEN|DIRECT
		sta ICAX1,x
		;lda #6
		;sta ICAX2,x
		jsr CIOV
		bmi cioerr
		lda #0
		sta __oserror
		jmp return1

cioerr:         jmp __do_oserror

_close_dir:     lda #CLOSE
		ldx diriocb
		sta ICCOM,x
		jsr CIOV
		rts

_read_dir_entry:
		sta ptr1
		stx ptr1+1
		lda diriocb
		tax
		lda #GETREC
		;lda #GETCHR
		sta ICCOM,x
		lda ptr1
		sta ICBAL,x
		lda ptr1+1
		sta ICBAH,x
		lda #$80
		sta ICBLL,x
		lda #0
		sta ICBLH,x
		jsr CIOV
		bmi cioerr
		lda #0
		sta __oserror
		jmp return1


	    .bss

_diriocb:
diriocb:    .res    1


#include <atari.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <ctype.h>


unsigned char __fastcall__ open_dir(char *drive);
void close_dir(void);
unsigned char __fastcall__ read_dir_entry(char
*entry);
extern unsigned char diriocb;


unsigned char main(void)
{
  unsigned char ret, i, j;
  char entry[128], filename[13];

  ret = open_dir("D1:*.*");
  if (!ret) return(0);

  while(1) {
    ret = read_dir_entry(&entry);
    if (ret == 255) break;
    if (isdigit(entry[0])) break;
    printf("entry:%s ", entry);

    // parse the directory entry
    j = 0;
    for(i=2; i<10; ++i) {
      if (isspace(entry[i]))
	break;
      filename[j] = entry[i];
      ++j;
    }
    filename[j] = '.';
    ++j;

    for(i=10; i<13; ++i) {
      if (isspace(entry[i]))
	break; 
      filename[j] = entry[i];
      ++j;
    }
    filename[j] = '\0';

    printf("filename:%s\n", filename);
    cgetc();
  }

  close_dir();
  return(1);
}







	
		
__________________________________ 
Yahoo! for Good - Make a difference this year. 
http://brand.yahoo.com/cybergivingweek2005/
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Dec 27 23:18:06 2005

This archive was generated by hypermail 2.1.8 : 2005-12-27 23:18:10 CET