From 9aee07c9adf2ddb942a5cea0f46fc6040eed8165 Mon Sep 17 00:00:00 2001 From: Oliver Schmidt Date: Sun, 26 Apr 2015 21:45:33 +0200 Subject: [PATCH] Leverage the recently added exec() cmdline support in the cc65 C library for the Apple ][. --- platform/apple2enh/contiki-conf.h | 1 + platform/apple2enh/lib/pfs.S | 32 ++++++++++++++++++++----------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/platform/apple2enh/contiki-conf.h b/platform/apple2enh/contiki-conf.h index 3f96da1aa..4326efe2d 100644 --- a/platform/apple2enh/contiki-conf.h +++ b/platform/apple2enh/contiki-conf.h @@ -64,5 +64,6 @@ #define WWW_CONF_MAX_FORMACTIONLEN 20 #define WWW_CONF_MAX_INPUTNAMELEN 20 #define WWW_CONF_MAX_INPUTVALUELEN 20 +#define WWW_CONF_WGET_EXEC(url) exec("wget", url) #endif /* CONTIKI_CONF_H_ */ diff --git a/platform/apple2enh/lib/pfs.S b/platform/apple2enh/lib/pfs.S index 00101d329..ed44dfc1e 100644 --- a/platform/apple2enh/lib/pfs.S +++ b/platform/apple2enh/lib/pfs.S @@ -32,13 +32,14 @@ ; ;--------------------------------------------------------------------- .constructor init_pfs - .destructor done_pfs + .destructor done_pfs .importzp ptr1 - .import popax, _uip_aligned_buf - .export _pfs_open, _pfs_read, _pfs_close + .import popax, _uip_aligned_buf + .export _pfs_open, _pfs_read, _pfs_close ;--------------------------------------------------------------------- pathname := $0280 mli := $BF00 +level := $BF94 OPEN_CALL = $C8 READ_CALL = $CA @@ -68,8 +69,11 @@ close_fd: .byte $00 ;REF_NUM .segment "INIT" init_pfs: - ; Get prefix len of path used to load binary - ldx pathname + ; Allow exec() to keep file open + inc level + + ; Get prefix len of path used to load binary + ldx pathname : lda pathname,x cmp #'/' beq :+ @@ -80,6 +84,15 @@ init_pfs: ;--------------------------------------------------------------------- .code +done_pfs: + ; Close all file + lda #$00 + jsr _pfs_close + + ; Allow exec() to keep file open + dec level + rts + _pfs_open: ; Pop and store name jsr popax @@ -131,11 +144,8 @@ _pfs_read: ldx read_count_out+1 rts -done_pfs: - lda #$00 - _pfs_close: - ; Store fd + ; Store fd sta close_fd jsr mli @@ -147,6 +157,6 @@ _pfs_close: error: ; Return -1 lda #$FF - tax - rts + tax + rts ;---------------------------------------------------------------------