From 89d4f4a90c55d217349767ffc7754350d1f3bb25 Mon Sep 17 00:00:00 2001
From: "ol.sc"
Date: Sun, 21 Oct 2012 14:35:17 +0000
Subject: [PATCH] Introduced getcurrentdevice() and implemented it for CBM and
Apple.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5863 b7a2c559-68d2-44c3-8de9-860c34a00d81
---
include/device.h | 2 ++
libsrc/apple2/Makefile | 1 +
libsrc/apple2/curdevice.s | 27 +++++++++++++++++++++++++++
libsrc/apple2enh/Makefile | 1 +
libsrc/cbm/Makefile | 1 +
libsrc/cbm/curdevice.s | 19 +++++++++++++++++++
6 files changed, 51 insertions(+)
create mode 100644 libsrc/apple2/curdevice.s
create mode 100644 libsrc/cbm/curdevice.s
diff --git a/include/device.h b/include/device.h
index faf674665..68b1c807a 100644
--- a/include/device.h
+++ b/include/device.h
@@ -55,6 +55,8 @@ unsigned char getfirstdevice (void);
unsigned char __fastcall__ getnextdevice (unsigned char device);
+unsigned char getcurrentdevice (void);
+
char* __fastcall__ getdevicedir (unsigned char device, char* buf, size_t size);
diff --git a/libsrc/apple2/Makefile b/libsrc/apple2/Makefile
index ad4573ac3..9f14a081c 100644
--- a/libsrc/apple2/Makefile
+++ b/libsrc/apple2/Makefile
@@ -61,6 +61,7 @@ S_OBJS= _scrsize.o \
cputc.o \
crt0.o \
ctype.o \
+ curdevice.o \
cvline.o \
devicedir.o \
dioclose.o \
diff --git a/libsrc/apple2/curdevice.s b/libsrc/apple2/curdevice.s
new file mode 100644
index 000000000..9781b8ad0
--- /dev/null
+++ b/libsrc/apple2/curdevice.s
@@ -0,0 +1,27 @@
+;
+; Oliver Schmidt, 2012-10-21
+;
+; unsigned char getcurrentdevice (void);
+;
+
+ .export _getcurrentdevice
+ .import __dos_type
+
+ .include "mli.inc"
+
+_getcurrentdevice:
+
+ ; Use unit number of most recent accessed device
+ lda DEVNUM
+ lsr
+ lsr
+ lsr
+ lsr
+
+ ; Check for ProDOS 8
+ ldx __dos_type
+ bne :+
+ lda #$FF ; INVALID_DEVICE
+
+: ldx #$00
+ rts
diff --git a/libsrc/apple2enh/Makefile b/libsrc/apple2enh/Makefile
index 0c564d465..02c6abd68 100644
--- a/libsrc/apple2enh/Makefile
+++ b/libsrc/apple2enh/Makefile
@@ -64,6 +64,7 @@ S_OBJS= _scrsize.o \
cputc.o \
crt0.o \
ctype.o \
+ curdevice.o \
cvline.o \
devicedir.o \
dioclose.o \
diff --git a/libsrc/cbm/Makefile b/libsrc/cbm/Makefile
index 99753dd97..fa64e4f7c 100644
--- a/libsrc/cbm/Makefile
+++ b/libsrc/cbm/Makefile
@@ -68,6 +68,7 @@ S_OBJS = c_acptr.o \
close.o \
closedir.o \
ctype.o \
+ curdevice.o \
cvline.o \
devicedir.o \
dir.o \
diff --git a/libsrc/cbm/curdevice.s b/libsrc/cbm/curdevice.s
new file mode 100644
index 000000000..8c2f7a866
--- /dev/null
+++ b/libsrc/cbm/curdevice.s
@@ -0,0 +1,19 @@
+;
+; Oliver Schmidt, 2012-10-21
+;
+; unsigned char getcurrentdevice (void);
+;
+
+ .export _getcurrentdevice
+ .import curunit
+
+;------------------------------------------------------------------------------
+; _getcurrentdevice
+
+.proc _getcurrentdevice
+
+ lda curunit
+ ldx #$00
+ rts
+
+.endproc
--
2.39.5