[cc65] Atari Library dosdetect.s

From: Shawn Jefferson <jefferson_shawn_a8bit1yahoo.com>
Date: 2007-03-25 03:01:03
Hi,

I'm working on a project where it would be nice to be
able to detect when I'm running with NODOS.  I noticed
that the Atari library defaults to ATARIDOS when it
can't detect the DOS.  Could a change similiar to what
I've done below be made?

The following files would need changes (as far as I
can tell): dosdetect.s, getargs.s getdefdev.s

With dosdetect.s I tested running from the Atarimax
Maxflash cartridge and from MyPicoDOS, both report
NODOS for _dos_type.  If a DOS does exist (and I
tested about 10 different DOS versions), there will
always be $00 $07 in $702/$703.  It would be nice to
detect other versions of DOS, but the overhead might
not be worth it, since dosdetect is always linked in. 
There are subtle differences in the the $700-70F area
that might help if a "bigger" dosdetect were to be
written.

dosdetect.s:
;
; Freddy Offenga & Christian Groessler, June 2004
;
; detect the DOS version we're running on
;

	.include        "atari.inc"
	.constructor    detect,26
	.export         __dos_type

;
------------------------------------------------------------------------
; DOS type detection

.segment        "INIT"

detect: lda     $703
	cmp     #7
	bne     nodos

	lda     #ATARIDOS
	sta     __dos_type      ; set default

	lda     DOS
	cmp     #'S'            ; SpartaDOS
	beq     spdos
	cmp     #'M'            ; MyDOS
	beq     mydos

	ldy     #COMTAB
	lda     #$4C
	cmp     (DOSVEC),y
	bne     done

	ldy     #ZCRNAME
	cmp     (DOSVEC),y
	bne     done

	ldy     #6              ; OS/A+ has a jmp here
	cmp     (DOSVEC),y
	beq     done
	lda     #OSADOS
	sta     __dos_type
	rts

nodos:  lda     #NODOS
	sta     __dos_type
	rts

spdos:  lda     #SPARTADOS
	sta     __dos_type
	rts

mydos:  lda     #MYDOS
	sta     __dos_type
done:   rts

;
------------------------------------------------------------------------
; Data

	.bss

__dos_type:     .res    1

getargs.s (only changes I made):
	lda     __dos_type      ; which DOS?
	cmp     #ATARIDOS
	beq     nargdos         ; DOS does not support
arguments
	cmp     #NODOS
	beq     nargdos
	cmp     #MYDOS
	bne     argdos          ; DOS supports arguments
nargdos:rts

getdefdev.s (only changes I made):
	lda     __dos_type      ; which DOS?
	cmp     #ATARIDOS
	beq     finish
	cmp     #MYDOS
	beq     finish
	cmp     #NODOS
	beq     finish

With getargs.s and getdefdev.s, it might be better to
check for the existence of a DOS and branch based on
that (only two I think support those features?
SpartaDOS and OSA)



 
____________________________________________________________________________
________
Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives.
http://tools.search.yahoo.com/toolbar/features/mail/


----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sun Mar 25 03:01:17 2007

This archive was generated by hypermail 2.1.8 : 2007-03-25 03:01:20 CEST