Finalize update t SDCC 4.2

Overall a gain of 2K of memory, not bad at all!
diff --git a/README.md b/README.md
index 82fa6db..0100c57 100644
--- a/README.md
+++ b/README.md
@@ -135,11 +135,11 @@
 
 Contiki uses the space usually reserved to BASIC, from &100 to &3700, for its
 kernel. Since the Firmware and AMSDOS reserve all memory from &A700 up, this 
-leaves more than 29K of free RAM for applications. Not bad, but we can do better.
+leaves more than 30K of free RAM for applications. Not bad, but we can do better.
 
 Current memory usage (with memstats.prg + desktop.prg running):
-* Heap size: 29218 bytes
-* Free memory: 24423 bytes
+* Heap size: 30681 bytes
+* Free memory: 26219 bytes
 
 Firmware-based CTK driver
 -------------------------
diff --git a/contiki-cpc/Makefile.common b/contiki-cpc/Makefile.common
index b22e4ea..c4005d5 100644
--- a/contiki-cpc/Makefile.common
+++ b/contiki-cpc/Makefile.common
@@ -18,7 +18,7 @@
 	-I $(CONTIKI)/ppp \
 	-I $(CONTIKI)/uip \
 	-mz80 -D__CPC__ -DCLK_TCK=16384 \
-	-DCTK_CONIO --max-allocs-per-node 50000 \
+	-DCTK_CONIO --max-allocs-per-node 1000000 \
 	--no-std-crt0 --opt-code-size --allow-unsafe-read
 
 CLFLAGS= 
diff --git a/contiki-cpc/arch/arch.c b/contiki-cpc/arch/arch.c
index b090326..48facc4 100644
--- a/contiki-cpc/arch/arch.c
+++ b/contiki-cpc/arch/arch.c
@@ -8,11 +8,7 @@
 	return _clock_val;
 }
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-
 int ctk_arch_isprint(char c)
 {
-	return isprint(c);
+	return (unsigned char)c > 32;
 }
diff --git a/contiki-cpc/ctk/ctk-conio-service.c b/contiki-cpc/ctk/ctk-conio-service.c
index 3985711..08f52c1 100644
--- a/contiki-cpc/ctk/ctk-conio-service.c
+++ b/contiki-cpc/ctk/ctk-conio-service.c
@@ -56,6 +56,19 @@
 // The revers function does nothing in our conio driver anyway.
 #define revers(x)
 
+#if 0
+static void revers(bool invert)
+{
+	static bool isInverted;
+	if (isInverted == invert)
+		return;
+
+	__asm
+		call 0xBB9C
+	__endasm
+}
+#endif
+
 /*-----------------------------------------------------------------------------------*/
 static void
 s_ctk_draw_init(void)
@@ -189,7 +202,7 @@
 	} else {
 	  revers(wfocus != 0 && j == w->widget.textentry.ypos);
 	  cvlinexy(xpos, ypos, 1);
-	  gotoxy(xpos + 1, ypos);          
+	  gotoxy(xpos + 1, ypos);
 	  cputsn(text, w->w);
 	  i = wherex();
 	  if(i - xpos - 1 < w->w) {
@@ -300,13 +313,13 @@
 	// - Y1
 	// - X1
   __asm
+		LD d,l
+		LD e,A
+
 		pop bc ; RV
 		pop hl ; x1 y1
 		push bc
 
-		LD d,l
-		LD e,A
-
 		call	0xBB99 ; TXT GET PAPER
 
 		; A contains PAPER number
diff --git a/contiki-cpc/loader/dir.s b/contiki-cpc/loader/dir.s
index e2b97fa..71edec1 100644
--- a/contiki-cpc/loader/dir.s
+++ b/contiki-cpc/loader/dir.s
@@ -22,35 +22,15 @@
 		.globl __readdir
 		.area _CODE
 
-;;------------------------------------------------------------------
-;; find BIOS SET MESSAGE command
-;; this is used to disable disc messages.
-;; this is compatible with other DOSs that also provide this command
 ;; void _readdir(void*)
 ;; Input: pointer to buffer in HL
 __readdir::
 
-;ld hl,#cmd_bios_set_message
-;call kl_find_command
-;ret nc
+	; The AMSDOS call corrupts IX, which must be saved for SDCC code to work
+	PUSH IX
 
-;; command found
-
-;; store address of command
-;ld (bios_set_message),hl
-;ld a,c
-;; store "rom select" of command
-;ld (bios_set_message+2),a
-
-;;------------------------------------------------------------------
-
-;; do CAT
-EX DE,HL ;; Put pointer to buffer in DE instead
-
-;;------------------------------------------------------------------
-;; display files from data generated by CAS CATALOG function
-
-;; perform a CAT command
+	; The parameter is passed in HL but we need it in DE
+	EX DE,HL
 
 ;; disable disc messages. Error messages will not be displayed.
 ld a,#0xff
@@ -60,11 +40,12 @@
 ;; disable text output
 call txt_vdu_disable
 
-xor a
-ld (de),a
+	; Make sure to return an empty buffer if getting the catalog fails
+	xor a
+	ld (DE),a
 
 ;; do catalog
-call cas_catalog
+	call cas_catalog
 
 ;; enable text output
 call txt_vdu_enable
@@ -73,6 +54,8 @@
 xor a
 rst 0x018						;; KL FAR CALL
 .dw bios_set_message
+
+	POP IX
 ret
 
 
@@ -83,7 +66,3 @@
 .dw 0xc033                    ;; address of function
 .db 7                    ;; "rom select" for function
 
-
-;cmd_bios_set_message:
-;.db #0x01+#0x80				;; this is the "BIOS SET MESSAGE" RSX
-