From 1c7c44e12c14255987014954692d0ab3b5f1e11a Mon Sep 17 00:00:00 2001
From: jede <jede@oric.org>
Date: Sun, 24 Sep 2017 11:46:52 +0200
Subject: [PATCH 01/10] adding some vars

---
 asminc/telestrat.inc | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/asminc/telestrat.inc b/asminc/telestrat.inc
index 8a51e1c32..d630c9fb3 100644
--- a/asminc/telestrat.inc
+++ b/asminc/telestrat.inc
@@ -26,6 +26,15 @@ RESB            := $02
 
 TR0             := $0C
 TR1             := $0D
+TR2             := $0E
+TR3             := $0F
+TR4             := $10
+TR5             := $11
+TR6             := $12
+TR7             := $13
+
+
+
 
 PTR_READ_DEST   := $2C           ; used for XFREAD and XWRITE only in telemon 3.0
 
@@ -109,6 +118,7 @@ XTEXT            = $19
 XHIRES           = $1A
 XFILLM           = $1C
 XMINMA           = $1F
+XVARS            = $24          ; only in TELEMON 3.0, in telemon 2.4, it's XNOMFI ($24)
 XFREAD           = $27          ; only in TELEMON 3.0
 XOPEN            = $30          ; only in TELEMON 3.0
 XCOSCR           = $34          ; switch off cursor
@@ -146,8 +156,8 @@ BUFEDT           := $590
 MAX_BUFEDT_LENGTH=110
 
 ; Hardware
-CH376_DATA       :=$340
-CH376_COMMAND    :=$341
+CH376_DATA       := $340
+CH376_COMMAND    := $341
 
 ; MACRO 
 

From c640619db5e9a1965a6f3a2631d8bb771b578ea3 Mon Sep 17 00:00:00 2001
From: jede <jede@oric.org>
Date: Sun, 24 Sep 2017 11:55:37 +0200
Subject: [PATCH 02/10] Add some bytes in ZP block in order to able to link
 with o65 files

---
 cfg/telestrat.cfg | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/cfg/telestrat.cfg b/cfg/telestrat.cfg
index 395a936e1..35fd5a984 100644
--- a/cfg/telestrat.cfg
+++ b/cfg/telestrat.cfg
@@ -4,7 +4,7 @@ SYMBOLS {
     __RAMEND__:    type = weak, value = $9800;
 }
 MEMORY {
-    ZP:      file = "", define = yes, start = $00E0,            size = $001A;
+    ZP:      file = "", define = yes, start = $00B0,            size = $003A;
     ORIXHDR: file = %O, type   = ro,  start = $0000,            size = $001F;
     BASHEAD: file = %O, define = yes, start = $0801,            size = $000D;
     MAIN:    file = %O, define = yes, start = __BASHEAD_LAST__, size = __RAMEND__ - __MAIN_START__;
@@ -38,3 +38,5 @@ FEATURES {
             segment = RODATA,
             import  = __CALLIRQ__;
 }
+
+

From fdd789edd8c2c5780aa3ad7ef9908f042308fd35 Mon Sep 17 00:00:00 2001
From: jede <jede@oric.org>
Date: Sun, 24 Sep 2017 11:56:55 +0200
Subject: [PATCH 03/10] correcting some return lines

---
 cfg/telestrat.cfg | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/cfg/telestrat.cfg b/cfg/telestrat.cfg
index 35fd5a984..2b26f4d6e 100644
--- a/cfg/telestrat.cfg
+++ b/cfg/telestrat.cfg
@@ -37,6 +37,4 @@ FEATURES {
             count   = __INTERRUPTOR_COUNT__,
             segment = RODATA,
             import  = __CALLIRQ__;
-}
-
-
+}
\ No newline at end of file

From d4c6c995ba70f95b1692677e5acf04ecbba19ef3 Mon Sep 17 00:00:00 2001
From: jede <jede@oric.org>
Date: Sun, 24 Sep 2017 11:57:52 +0200
Subject: [PATCH 04/10] Correcting missing return line :/

---
 cfg/telestrat.cfg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cfg/telestrat.cfg b/cfg/telestrat.cfg
index 2b26f4d6e..42e8d2cb5 100644
--- a/cfg/telestrat.cfg
+++ b/cfg/telestrat.cfg
@@ -37,4 +37,4 @@ FEATURES {
             count   = __INTERRUPTOR_COUNT__,
             segment = RODATA,
             import  = __CALLIRQ__;
-}
\ No newline at end of file
+}

From 60e41e3110f881975f3dd075bfdb34595d4bb973 Mon Sep 17 00:00:00 2001
From: jede <jede@oric.org>
Date: Sun, 24 Sep 2017 19:22:43 +0200
Subject: [PATCH 05/10] Adding XVARS primitive

---
 asminc/telestrat.inc | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/asminc/telestrat.inc b/asminc/telestrat.inc
index d630c9fb3..48e3a9347 100644
--- a/asminc/telestrat.inc
+++ b/asminc/telestrat.inc
@@ -15,6 +15,7 @@ FUNCTKEY        = $A5
 
 FNAME_LEN       = 11            ; maximum length of file-name
 
+FILENAME_MAX    = 100
 
 ; ---------------------------------------------------------------------------
 ; Zero page
@@ -139,6 +140,11 @@ XINK             = $93
 XEXPLO           = $9C 
 XPING            = $9D
 
+; ---------------------------------------------------------------------------
+; ROM entries variables
+
+PWD_PTR          = $00
+
 ; ---------------------------------------------------------------------------
 ; Page $200
 SCRX             := $220

From fabb6acf3ffb53e4a20b4e163941c58d66dbdf39 Mon Sep 17 00:00:00 2001
From: jede <jede@oric.org>
Date: Sun, 24 Sep 2017 19:23:44 +0200
Subject: [PATCH 06/10] Initcwd is now working for telestrat

---
 libsrc/telestrat/initcwd.s | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 libsrc/telestrat/initcwd.s

diff --git a/libsrc/telestrat/initcwd.s b/libsrc/telestrat/initcwd.s
new file mode 100644
index 000000000..84ab3fb35
--- /dev/null
+++ b/libsrc/telestrat/initcwd.s
@@ -0,0 +1,28 @@
+;
+; Oliver Schmidt, 18.04.2005
+;
+
+        .export         initcwd
+        .import         __cwd
+
+        .include        "zeropage.inc"
+        .include        "telestrat.inc"
+
+
+initcwd:
+        ldx     #PWD_PTR
+        BRK_TELEMON XVARS
+        sta     tmp1
+        sty     tmp1+1
+
+        ldy     #$00
+loop:        
+        lda     (tmp1),y
+        beq     done
+        sta     __cwd,y
+        iny
+        bne     loop
+       
+done:   
+        sta     (tmp2),y
+        rts

From 5bbb27c8af558be6ed5b88f67bec972023c940de Mon Sep 17 00:00:00 2001
From: jede <jede@oric.org>
Date: Sun, 24 Sep 2017 20:04:50 +0200
Subject: [PATCH 07/10] Fixing bug for cwd

---
 libsrc/telestrat/initcwd.s | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libsrc/telestrat/initcwd.s b/libsrc/telestrat/initcwd.s
index 84ab3fb35..ae25817d9 100644
--- a/libsrc/telestrat/initcwd.s
+++ b/libsrc/telestrat/initcwd.s
@@ -24,5 +24,5 @@ loop:
         bne     loop
        
 done:   
-        sta     (tmp2),y
+        sta     _cwd,y
         rts

From 86741cb1ddea6da58eb3462e5e120929c6928ea5 Mon Sep 17 00:00:00 2001
From: jede <jede@oric.org>
Date: Sun, 24 Sep 2017 20:07:02 +0200
Subject: [PATCH 08/10] correcting missing _

---
 libsrc/telestrat/initcwd.s | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libsrc/telestrat/initcwd.s b/libsrc/telestrat/initcwd.s
index ae25817d9..df2ceb63b 100644
--- a/libsrc/telestrat/initcwd.s
+++ b/libsrc/telestrat/initcwd.s
@@ -24,5 +24,5 @@ loop:
         bne     loop
        
 done:   
-        sta     _cwd,y
+        sta     __cwd,y
         rts

From d8904c550bb7c4fabe5e80737e542aa5c88eb206 Mon Sep 17 00:00:00 2001
From: jede <jede@oric.org>
Date: Mon, 25 Sep 2017 21:39:57 +0200
Subject: [PATCH 09/10] Fixing buffer overflow with cwd command (FILENAME_MAX
 must be at 50 +1 bytes)

---
 asminc/stdio.inc           |  2 ++
 asminc/telestrat.inc       |  3 ++-
 include/stdio.h            |  2 ++
 libsrc/telestrat/initcwd.s | 13 ++++++++-----
 4 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/asminc/stdio.inc b/asminc/stdio.inc
index 18a7541e0..3b22c47f6 100644
--- a/asminc/stdio.inc
+++ b/asminc/stdio.inc
@@ -47,6 +47,8 @@ FILENAME_MAX    = 64+1
 FILENAME_MAX    = 12+1
 .elseif .defined(__LUNIX__)
 FILENAME_MAX    = 80+1
+.elseif .defined(__TELESTRAT__)
+FILENAME_MAX    = 50+1
 .else
 FILENAME_MAX    = 16+1
 .endif
diff --git a/asminc/telestrat.inc b/asminc/telestrat.inc
index 48e3a9347..ffe78ad6e 100644
--- a/asminc/telestrat.inc
+++ b/asminc/telestrat.inc
@@ -15,7 +15,7 @@ FUNCTKEY        = $A5
 
 FNAME_LEN       = 11            ; maximum length of file-name
 
-FILENAME_MAX    = 100
+FILENAME_MAX    = 200
 
 ; ---------------------------------------------------------------------------
 ; Zero page
@@ -151,6 +151,7 @@ SCRX             := $220
 SCRY             := $224
 ADSCRL           := $218
 ADSCRH           := $21C
+IRQVECTOR        := $2FA
 
 
 ; ---------------------------------------------------------------------------
diff --git a/include/stdio.h b/include/stdio.h
index c2c735cb0..a3facd513 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -75,6 +75,8 @@ extern FILE* stderr;
 #  define FILENAME_MAX  (12+1)
 #elif defined(__LUNIX__)
 #  define FILENAME_MAX  (80+1)
+#elif defined(__TELESTRAT__)
+#  define FILENAME_MAX  (50+1)
 #else
 #  define FILENAME_MAX  (16+1)
 #endif
diff --git a/libsrc/telestrat/initcwd.s b/libsrc/telestrat/initcwd.s
index df2ceb63b..f359ebeb4 100644
--- a/libsrc/telestrat/initcwd.s
+++ b/libsrc/telestrat/initcwd.s
@@ -1,5 +1,5 @@
 ;
-; Oliver Schmidt, 18.04.2005
+; Jede (jede@oric.org) 24.09.2017
 ;
 
         .export         initcwd
@@ -10,14 +10,17 @@
 
 
 initcwd:
+       
         ldx     #PWD_PTR
         BRK_TELEMON XVARS
-        sta     tmp1
-        sty     tmp1+1
-
+        
+        sta     ptr1
+        sty     ptr1+1
+        
         ldy     #$00
+        
 loop:        
-        lda     (tmp1),y
+        lda     (ptr1),y
         beq     done
         sta     __cwd,y
         iny

From 95a88a787d413553912a58770e045e7631744eb1 Mon Sep 17 00:00:00 2001
From: jede <jede@oric.org>
Date: Mon, 25 Sep 2017 21:47:05 +0200
Subject: [PATCH 10/10] remove FILENAME_MAX

---
 asminc/telestrat.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/asminc/telestrat.inc b/asminc/telestrat.inc
index ffe78ad6e..8e6a66bbd 100644
--- a/asminc/telestrat.inc
+++ b/asminc/telestrat.inc
@@ -15,7 +15,7 @@ FUNCTKEY        = $A5
 
 FNAME_LEN       = 11            ; maximum length of file-name
 
-FILENAME_MAX    = 200
+
 
 ; ---------------------------------------------------------------------------
 ; Zero page