Update to SDCC 3.5.0
- Replace make_labels with sed script, because the map file format
changed.
- Remove __fastcall__ in the single place where it was still present
(leftover from CC65)
- Use __z88dk_fastcall where possible in the conio driver, speeding up
drawing a little further.
- Allow "unsafe reads" since we don't have any read-sensitive IO mapped
in memory space.
There changes free an extra 900 bytes of RAM, making us closer to 25K
RAM free (with memstat runnning).
diff --git a/contiki-cpc/Makefile.common b/contiki-cpc/Makefile.common
index b0acfa6..9aeba3c 100644
--- a/contiki-cpc/Makefile.common
+++ b/contiki-cpc/Makefile.common
@@ -17,9 +17,9 @@
-I $(CONTIKI)/lib \
-I $(CONTIKI)/ppp \
-I $(CONTIKI)/uip \
- -mz80 -D__fastcall__=/**/ -D__CPC__ -DCLK_TCK=16384 \
+ -mz80 -D__CPC__ -DCLK_TCK=16384 \
-DCTK_CONIO --funsigned-char \
- --no-std-crt0 --opt-code-size
+ --no-std-crt0 --opt-code-size --allow-unsafe-read
CLFLAGS=
OPT=
diff --git a/contiki-cpc/Makefile.cpc b/contiki-cpc/Makefile.cpc
index 896da84..d2a303f 100644
--- a/contiki-cpc/Makefile.cpc
+++ b/contiki-cpc/Makefile.cpc
@@ -101,7 +101,8 @@
contiki: $(CONTIKI_OBJ)
$(LD) -f arch/contiki.lnk
- ./bin/make_labels contiki.map arch/contiki_labels.s
+ #./bin/make_labels contiki.map arch/contiki_labels.s
+ sed -n "/^_CODE\|^_DATA\|_INITIALIZED/,/^Area/ s/^ \([0-9A-F]*\) \([^ ]*\) .*/ \2 == 0x\1/p" contiki.map > arch/contiki_labels.s
makebin -p -s 65535 < contiki.ihx > contiki.raw
dd if=contiki.raw of=contiki.bin bs=256 skip=1
cpcfs contiki.dsk f
diff --git a/contiki-cpc/apps/configedit.c b/contiki-cpc/apps/configedit.c
index 5d43f72..ec672f4 100644
--- a/contiki-cpc/apps/configedit.c
+++ b/contiki-cpc/apps/configedit.c
@@ -197,7 +197,7 @@
return nt;
}
/*-----------------------------------------------------------------------------------*/
-static char * __fastcall__
+static char *
copystr(char *dst, char *src, int len)
{
char *nt = nullterminate(src);
diff --git a/contiki-cpc/arch/conio.s b/contiki-cpc/arch/conio.s
index fd7f084..1a6379f 100644
--- a/contiki-cpc/arch/conio.s
+++ b/contiki-cpc/arch/conio.s
@@ -52,10 +52,8 @@
.globl _gotox
_gotox::
- ld hl,#2
- add hl,sp
- ld a,(hl)
- inc a
+ ld a,l
+ inc a
jp 0xBB6F ; TXT SET COLUMN
; void gotoy (unsigned char y);
@@ -64,9 +62,7 @@
.globl _gotoy
_gotoy::
- ld hl,#2
- add hl,sp
- ld a,(hl)
+ ld a,l
inc a
jp 0xBB72 ; TXT SET ROW
@@ -115,10 +111,8 @@
.globl _cputc
_cputc::
- ld hl,#2
- add hl,sp
- ld a,(hl)
- jp 0xbb5b ; TXT OUTPUT
+ ld a,l
+ jp 0xbb5a ; TXT OUTPUT
; void cputcxy (unsigned char x, unsigned char y, char c)
@@ -148,11 +142,7 @@
.globl _cputs
_cputs::
- ld hl,#2
- add hl,sp
- ld e,(hl)
- inc hl
- ld d,(hl)
+ ex de,hl
cputs$:
ld a,(de)
inc de
@@ -200,60 +190,33 @@
-; unsigned char textcolor (unsigned char color);
-; Set the color for text output. The old color setting is returned.
+; void textcolor (unsigned char color);
+; Set the color for text output.
.globl _textcolor
_textcolor::
- ld hl,#2
- add hl,sp
- ld a,(hl)
- ld d,a
- call 0xBB93 ; TXT GET PEN
- ld e,a
- ld a,d
- call 0xBB90 ; TXT SET PEN
- ld l,e
- ret
+ ld a,l
+ jp 0xBB90 ; TXT SET PEN
-; unsigned char bgcolor (unsigned char color);
-; Set the color for the background. The old color setting is returned. */
+; void bgcolor (unsigned char color);
+; Set the color for the background. */
.globl _bgcolor
_bgcolor::
- ld hl,#2
- add hl,sp
- ld a,(hl)
- ld d,a
- call 0xBB99 ; TXT GET PAPER
- ld e,a
- ld a,d
- call 0xBB96 ; TXT SET PAPER
- ld l,e
- ret
+ ld a,l
+ jp 0xBB96 ; TXT SET PAPER
-; unsigned char bordercolor (unsigned char color);
-; Set the color for the border. The old color setting is returned.
+; void bordercolor (unsigned char color);
+; Set the color for the border.
.globl _bordercolor
_bordercolor::
- ld hl,#2
- add hl,sp
- ld a,(hl)
- push af
- call 0xBC3B ; SCR GET BORDER
- pop af
- ld d,b
- ld b,a
- ld c,a
- push de
- call 0xBC38 ; SCR SET BORDER
- pop de
- ld l,d
- ret
+ ld b,l
+ ld c,l
+ jp 0xBC38 ; SCR SET BORDER
; void chline (unsigned char length);
; Output a horizontal line with the given length starting at the current
@@ -262,9 +225,7 @@
.globl _chline
_chline::
- ld hl,#2
- add hl,sp
- ld a,(hl)
+ ld a,l
or a
ret z
ld b,a
@@ -309,9 +270,7 @@
.globl _cvline
_cvline::
- ld hl,#2
- add hl,sp
- ld a,(hl)
+ ld a,l
or a
ret z
ld b,a
@@ -360,9 +319,7 @@
.globl _cclear
_cclear::
- ld hl,#2
- add hl,sp
- ld b,(hl)
+ ld b,l
ld c,#0x020 ; White space
cclearloop$:
push bc
diff --git a/contiki-cpc/ctk/conio.h b/contiki-cpc/ctk/conio.h
index 859e905..8dfe8d2 100644
--- a/contiki-cpc/ctk/conio.h
+++ b/contiki-cpc/ctk/conio.h
@@ -22,9 +22,9 @@
unsigned char kbhit (void);
-void gotox (unsigned char x);
+void gotox (unsigned char x) __z88dk_fastcall;
-void gotoy (unsigned char y);
+void gotoy (unsigned char y) __z88dk_fastcall;
void gotoxy (unsigned char x, unsigned char y);
@@ -32,31 +32,31 @@
unsigned char wherey (void);
-void cputc (char c);
+void cputc (char c) __z88dk_fastcall;
void cputcxy (unsigned char x, unsigned char y, char c);
-void cputs (char* s);
+void cputs (char* s) __z88dk_fastcall;
char cgetc (void);
-void revers (char);
+void revers (char) __z88dk_fastcall;
-void textcolor (unsigned char color);
+void textcolor (unsigned char color) __z88dk_fastcall;
-void bgcolor (unsigned char color);
+void bgcolor (unsigned char color) __z88dk_fastcall;
-void bordercolor (unsigned char color);
+void bordercolor (unsigned char color) __z88dk_fastcall;
-void chline (unsigned char length);
+void chline (unsigned char length) __z88dk_fastcall;
void chlinexy (unsigned char x, unsigned char y, unsigned char length);
-void cvline (unsigned char length);
+void cvline (unsigned char length) __z88dk_fastcall;
void cvlinexy (unsigned char x, unsigned char y, unsigned char length);
-void cclear (unsigned char length);
+void cclear (unsigned char length) __z88dk_fastcall;
void cclearxy (unsigned char x, unsigned char y, unsigned char length);