From: ol.sc
Date: Sun, 14 Feb 2010 23:12:54 +0000 (+0000)
Subject: Initialize _curunit from the zeropage value DEVNUM (aka First Address) in a construct...
X-Git-Tag: V2.13.2~13
X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d1aad57b9865caa61641bbd20557958790b66a84;p=cc65
Initialize _curunit from the zeropage value DEVNUM (aka First Address) in a constructor with a very high priority to be called before DEVNUM gets overwritten by other constructors.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4588 b7a2c559-68d2-44c3-8de9-860c34a00d81
---
diff --git a/asminc/c16.inc b/asminc/c16.inc
new file mode 100644
index 000000000..9372e72c0
--- /dev/null
+++ b/asminc/c16.inc
@@ -0,0 +1,9 @@
+;
+; C16 generic definitions.
+;
+
+
+; ---------------------------------------------------------------------------
+; Zero page, Commodore stuff
+
+DEVNUM := $AE ; Device number
diff --git a/asminc/cbm510.inc b/asminc/cbm510.inc
index 0aad95f49..e98ed4a14 100644
--- a/asminc/cbm510.inc
+++ b/asminc/cbm510.inc
@@ -9,8 +9,9 @@
;-----------------------------------------------------------------------------
; Zeropage stuff
-ExecReg = $0000
-IndReg = $0001
+ExecReg = $00
+IndReg = $01
+DEVNUM = $9F
; ---------------------------------------------------------------------------
; Screen size
diff --git a/asminc/cbm610.inc b/asminc/cbm610.inc
index ea85cd50d..62d0c6a42 100644
--- a/asminc/cbm610.inc
+++ b/asminc/cbm610.inc
@@ -7,10 +7,11 @@
; ---------------------------------------------------------------------------
-; Zeropage registers
+; Zeropage stuff
ExecReg = $00
IndReg = $01
+DEVNUM = $9F
; ---------------------------------------------------------------------------
; Screen size
diff --git a/asminc/pet.inc b/asminc/pet.inc
new file mode 100644
index 000000000..524e83511
--- /dev/null
+++ b/asminc/pet.inc
@@ -0,0 +1,9 @@
+;
+; PET generic definitions.
+;
+
+
+; ---------------------------------------------------------------------------
+; Zero page, Commodore stuff
+
+DEVNUM := $D4 ; Device number
diff --git a/libsrc/c128/Makefile b/libsrc/c128/Makefile
index 248c36fd2..a5c4dde82 100644
--- a/libsrc/c128/Makefile
+++ b/libsrc/c128/Makefile
@@ -53,6 +53,7 @@ OBJS = _scrsize.o \
crt0.o \
color.o \
cputc.o \
+ devnum.o \
fast.o \
get_tv.o \
joy_stddrv.o \
diff --git a/libsrc/c128/devnum.s b/libsrc/c128/devnum.s
new file mode 100644
index 000000000..72007a516
--- /dev/null
+++ b/libsrc/c128/devnum.s
@@ -0,0 +1,7 @@
+;
+; Oliver Schmidt, 2010-02-14
+;
+
+ .include "c128.inc"
+
+ .exportzp devnum := DEVNUM
diff --git a/libsrc/c16/Makefile b/libsrc/c16/Makefile
index 6aa5275dd..06bea22f9 100644
--- a/libsrc/c16/Makefile
+++ b/libsrc/c16/Makefile
@@ -49,6 +49,7 @@ OBJS = _scrsize.o \
conio.o \
cputc.o \
crt0.o \
+ devnum.o \
get_tv.o \
joy_stddrv.o \
kbhit.o \
diff --git a/libsrc/c16/devnum.s b/libsrc/c16/devnum.s
new file mode 100644
index 000000000..105c9bda8
--- /dev/null
+++ b/libsrc/c16/devnum.s
@@ -0,0 +1,7 @@
+;
+; Oliver Schmidt, 2010-02-14
+;
+
+ .include "c16.inc"
+
+ .exportzp devnum := DEVNUM
diff --git a/libsrc/c64/Makefile b/libsrc/c64/Makefile
index 0b3eddeea..073bdcb33 100644
--- a/libsrc/c64/Makefile
+++ b/libsrc/c64/Makefile
@@ -53,6 +53,7 @@ OBJS = _scrsize.o \
color.o \
conio.o \
cputc.o \
+ devnum.o \
get_ostype.o \
get_tv.o \
joy_stddrv.o \
diff --git a/libsrc/c64/devnum.s b/libsrc/c64/devnum.s
new file mode 100644
index 000000000..e7b5f94b2
--- /dev/null
+++ b/libsrc/c64/devnum.s
@@ -0,0 +1,7 @@
+;
+; Oliver Schmidt, 2010-02-14
+;
+
+ .include "c64.inc"
+
+ .exportzp devnum := DEVNUM
diff --git a/libsrc/cbm/filevars.s b/libsrc/cbm/filevars.s
index 54f247d4c..3b6bdb750 100644
--- a/libsrc/cbm/filevars.s
+++ b/libsrc/cbm/filevars.s
@@ -4,15 +4,33 @@
; Variables used for CBM file I/O
;
- .export __curunit
.export __filetype
+ .export __curunit
+ .constructor initcurunit, 30
+ .importzp devnum
.data
-__curunit:
- .byte 8 ; Default is disk
-
__filetype:
.byte 'u' ; Create user files by default
+
+.bss
+
+__curunit:
+ .res 1
+
+
+.segment "INIT"
+
+.proc initcurunit
+
+ lda devnum
+ bne @L0
+ lda #8 ; Default is disk
+ sta devnum
+@L0: sta __curunit
+ rts
+
+.endproc
diff --git a/libsrc/cbm510/Makefile b/libsrc/cbm510/Makefile
index 0eadda41b..e92683dce 100644
--- a/libsrc/cbm510/Makefile
+++ b/libsrc/cbm510/Makefile
@@ -56,6 +56,7 @@ OBJS = _scrsize.o \
color.o \
cputc.o \
crt0.o \
+ devnum.o \
extzp.o \
kbhit.o \
kclose.o \
diff --git a/libsrc/cbm510/devnum.s b/libsrc/cbm510/devnum.s
new file mode 100644
index 000000000..0c6bf2130
--- /dev/null
+++ b/libsrc/cbm510/devnum.s
@@ -0,0 +1,7 @@
+;
+; Oliver Schmidt, 2010-02-14
+;
+
+ .include "cbm510.inc"
+
+ .exportzp devnum := DEVNUM
diff --git a/libsrc/cbm610/Makefile b/libsrc/cbm610/Makefile
index ac0293ed6..1eea7f31f 100644
--- a/libsrc/cbm610/Makefile
+++ b/libsrc/cbm610/Makefile
@@ -47,6 +47,7 @@ OBJS = _scrsize.o \
cputc.o \
crt0.o \
crtc.o \
+ devnum.o \
extzp.o \
get_tv.o \
kbhit.o \
diff --git a/libsrc/cbm610/devnum.s b/libsrc/cbm610/devnum.s
new file mode 100644
index 000000000..75fa4cd2a
--- /dev/null
+++ b/libsrc/cbm610/devnum.s
@@ -0,0 +1,7 @@
+;
+; Oliver Schmidt, 2010-02-14
+;
+
+ .include "cbm610.inc"
+
+ .exportzp devnum := DEVNUM
diff --git a/libsrc/pet/Makefile b/libsrc/pet/Makefile
index 911f9b3ab..b44c383b0 100644
--- a/libsrc/pet/Makefile
+++ b/libsrc/pet/Makefile
@@ -47,6 +47,7 @@ OBJS = _scrsize.o \
conio.o \
cputc.o \
crt0.o \
+ devnum.o \
get_tv.o \
kbhit.o \
kbsout.o \
diff --git a/libsrc/pet/devnum.s b/libsrc/pet/devnum.s
new file mode 100644
index 000000000..82d6b6bc6
--- /dev/null
+++ b/libsrc/pet/devnum.s
@@ -0,0 +1,7 @@
+;
+; Oliver Schmidt, 2010-02-14
+;
+
+ .include "pet.inc"
+
+ .exportzp devnum := DEVNUM
diff --git a/libsrc/plus4/Makefile b/libsrc/plus4/Makefile
index b3a3c4eee..51ef6ef80 100644
--- a/libsrc/plus4/Makefile
+++ b/libsrc/plus4/Makefile
@@ -49,6 +49,7 @@ OBJS = _scrsize.o \
conio.o \
cputc.o \
crt0.o \
+ devnum.o \
get_tv.o \
joy_stddrv.o \
kacptr.o \
diff --git a/libsrc/plus4/devnum.s b/libsrc/plus4/devnum.s
new file mode 100644
index 000000000..d369476e7
--- /dev/null
+++ b/libsrc/plus4/devnum.s
@@ -0,0 +1,7 @@
+;
+; Oliver Schmidt, 2010-02-14
+;
+
+ .include "plus4.inc"
+
+ .exportzp devnum := DEVNUM
diff --git a/libsrc/vic20/Makefile b/libsrc/vic20/Makefile
index 67433999f..50fb0152b 100644
--- a/libsrc/vic20/Makefile
+++ b/libsrc/vic20/Makefile
@@ -46,6 +46,7 @@ OBJS = _scrsize.o \
color.o \
conio.o \
cputc.o \
+ devnum.o \
get_tv.o \
joy_stddrv.o \
kbhit.o \
diff --git a/libsrc/vic20/devnum.s b/libsrc/vic20/devnum.s
new file mode 100644
index 000000000..23a9c3808
--- /dev/null
+++ b/libsrc/vic20/devnum.s
@@ -0,0 +1,7 @@
+;
+; Oliver Schmidt, 2010-02-14
+;
+
+ .include "vic20.inc"
+
+ .exportzp devnum := DEVNUM