Skip to content

Commit

Permalink
Make openw, closew take channel as input argument
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotlinski committed Jul 22, 2013
1 parent 955405e commit 8490eda
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
35 changes: 20 additions & 15 deletions durexforth.a
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ CHRIN = $ffcf
CHROUT = $ffd2
LOAD = $ffd5
SAVE = $ffd8
WRITEFILENO = $f

CURSOR_COLOR = $286

Expand Down Expand Up @@ -1993,19 +1992,22 @@ _LINEBUF
COMPILE_FILENO
!word 0

; CLOSEW
; CLOSEW ( file# -- )
!word LINK
!set LINK = * - 2
!byte 6
!text "closew"
CLOSEW
stx tmp_x
lda #WRITEFILENO
lda 0,x
sta TMP
stx TMP2
jsr CLOSE
ldx #WRITEFILENO
ldx TMP
jsr CHKOUT
jsr _errorchread
ldx tmp_x
ldx TMP2
inx
inx
+NEXT

_errorchread
Expand Down Expand Up @@ -2196,34 +2198,37 @@ save_binary_srange_end_hi = *+1
inx
+NEXT


; OPENW ( strptr strlen ) open file for writing
; OPENW ( strptr strlen file# ) open file for writing
!word LINK
!set LINK = * - 2
!byte 5
!text "openw"
OPENW
stx tmp_x
lda 0,x
sta TMP ; fileno
stx TMP2

lda 0, x
ldy 3, x
pha
lda 2, x
ldy 5, x
pha
lda 4, x
tax
pla

jsr SETNAM
lda #WRITEFILENO ; file number
lda TMP ; file number
ldx #8 ; default to device 8
tay ; secondary address
jsr SETLFS
jsr OPEN
bcs .could_not_open

ldx #WRITEFILENO ; file number
ldx TMP ; file number
jsr CHKOUT

ldx tmp_x
ldx TMP2
inx
inx
inx
inx
inx
Expand Down
2 changes: 1 addition & 1 deletion forth_src/base.fs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ swap ( strlen strlen strptr tmpbuf+2 )
rot ( strlen strptr tmpbuf+2 strlen )
cmove ( strlen )
r> swap 2+ ( tmp strlen )
openw closew ;
f openw f closew ;

hide pushya

Expand Down
8 changes: 4 additions & 4 deletions forth_src/vi.fs
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,8 @@ join-lines del-char
filename-len c@ +
CR swap c!

drivebuf filename-len c@ 4 + openw
closew
drivebuf filename-len c@ 4 +
f openw f closew

# rename to new backup
drivebuf
Expand All @@ -547,8 +547,8 @@ join-lines del-char
filename-len c@ + # filename ok
CR swap c!

drivebuf filename-len c@ 2 * 5 + openw
closew
drivebuf filename-len c@ 2 * 5 +
f openw f closew
;

: write-file
Expand Down

0 comments on commit 8490eda

Please sign in to comment.