2010-04-05 14:11:01 +00:00
|
|
|
;
|
|
|
|
; Copyright (c) 2010, Kajtar Zsolt <soci@c64.rulez.org>
|
|
|
|
; All rights reserved.
|
|
|
|
;
|
|
|
|
; Redistribution and use in source and binary forms, with or without
|
|
|
|
; modification, are permitted provided that the following conditions
|
|
|
|
; are met:
|
|
|
|
; 1. Redistributions of source code must retain the above copyright
|
|
|
|
; notice, this list of conditions and the following disclaimer.
|
|
|
|
; 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
; notice, this list of conditions and the following disclaimer in the
|
|
|
|
; documentation and/or other materials provided with the distribution.
|
|
|
|
; 3. Neither the name of the Institute nor the names of its contributors
|
|
|
|
; may be used to endorse or promote products derived from this software
|
|
|
|
; without specific prior written permission.
|
|
|
|
;
|
|
|
|
; THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
; ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
|
|
; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
; SUCH DAMAGE.
|
|
|
|
;
|
|
|
|
; This file is part of the Contiki operating system.
|
|
|
|
;
|
|
|
|
; Author: Kajtar Zsolt <soci@c64.rulez.org>
|
|
|
|
;
|
|
|
|
;---------------------------------------------------------------------
|
2016-03-28 12:06:47 +00:00
|
|
|
.define F_IDE64 1 ; support IDE64, >= $0100 bytes only
|
|
|
|
|
|
|
|
.importzp ptr1, ptr2
|
|
|
|
.import pfs_rwcommon, pfs_rwsetflags, pfs_rwcommonend
|
|
|
|
.if F_IDE64
|
|
|
|
.import ide64_rwprepare, ide64_rwfinish
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.export _pfs_write
|
2010-04-05 14:11:01 +00:00
|
|
|
;---------------------------------------------------------------------
|
2016-03-28 12:06:47 +00:00
|
|
|
F_NBLK = %01000000 ;block read/write not available
|
|
|
|
|
|
|
|
ST := $90 ;status
|
|
|
|
|
|
|
|
; IDEDOS function
|
|
|
|
WRITE := $DEF1
|
|
|
|
|
|
|
|
; Kernal functions
|
|
|
|
CHKOUT := $FFC9
|
|
|
|
CLRCHN := $FFCC
|
|
|
|
CHROUT := $FFD2
|
2010-04-05 14:11:01 +00:00
|
|
|
;---------------------------------------------------------------------
|
|
|
|
.code
|
|
|
|
|
2016-03-28 12:06:47 +00:00
|
|
|
error5: jsr CLRCHN
|
2010-04-05 14:11:01 +00:00
|
|
|
|
2016-03-28 12:06:47 +00:00
|
|
|
error2: ldx #>-1
|
2010-04-05 14:11:01 +00:00
|
|
|
txa
|
|
|
|
rts
|
|
|
|
|
|
|
|
.proc _pfs_write
|
|
|
|
jsr pfs_rwcommon ; pop params, check handle
|
|
|
|
beq error2 ; not open
|
|
|
|
|
2016-03-28 12:06:47 +00:00
|
|
|
.if F_IDE64
|
|
|
|
asl a
|
2010-04-05 14:11:01 +00:00
|
|
|
bmi nblk ; no block operation
|
|
|
|
|
|
|
|
jsr CHKOUT
|
|
|
|
bcs error2
|
|
|
|
|
|
|
|
; check support
|
|
|
|
jsr ide64_rwprepare
|
|
|
|
bcs norm
|
|
|
|
|
2016-03-28 12:06:47 +00:00
|
|
|
; do a block write
|
2010-04-05 14:11:01 +00:00
|
|
|
jsr WRITE
|
|
|
|
bcs nosup
|
|
|
|
jmp ide64_rwfinish
|
|
|
|
|
|
|
|
nosup: lda #F_NBLK
|
|
|
|
jsr pfs_rwsetflags
|
|
|
|
.endif
|
|
|
|
|
|
|
|
; Valid lfn. Make it the output file
|
|
|
|
nblk: jsr CHKOUT
|
|
|
|
bcs error2
|
|
|
|
|
|
|
|
; Output the next character from the buffer
|
|
|
|
norm: ldy #0
|
|
|
|
@L3: inc ptr1
|
|
|
|
bne @L0
|
|
|
|
inc ptr1+1
|
|
|
|
beq @L2
|
|
|
|
|
|
|
|
@L0: lda (ptr2),y
|
|
|
|
inc ptr2
|
|
|
|
bne @L1
|
|
|
|
inc ptr2+1 ; A = *buf++;
|
|
|
|
@L1: jsr CHROUT
|
|
|
|
lda ST
|
|
|
|
beq @L3
|
|
|
|
bne error5 ; bail out on errors
|
|
|
|
|
2016-03-28 12:06:47 +00:00
|
|
|
; Wrote all chars.; cancel the output channel
|
|
|
|
@L2: jsr CLRCHN
|
2010-04-05 14:11:01 +00:00
|
|
|
|
|
|
|
; Return the number of chars written
|
|
|
|
jmp pfs_rwcommonend
|
|
|
|
.endproc
|