2005-04-12 09:12:48 +00:00
|
|
|
;
|
|
|
|
; Oliver Schmidt, 30.12.2004
|
|
|
|
;
|
|
|
|
; int __fastcall__ close (int fd);
|
|
|
|
;
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.export _close
|
2005-04-12 09:12:48 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.import closedirect, freebuffer
|
2005-04-12 09:12:48 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.include "errno.inc"
|
|
|
|
.include "filedes.inc"
|
2005-04-12 09:12:48 +00:00
|
|
|
|
|
|
|
_close:
|
|
|
|
; Process fd
|
2013-05-09 11:56:54 +00:00
|
|
|
jsr getfd ; Returns A, Y and C
|
|
|
|
bcs errno
|
2005-04-12 09:12:48 +00:00
|
|
|
|
|
|
|
; Check for device
|
2013-05-09 11:56:54 +00:00
|
|
|
bmi zerofd
|
2005-04-12 09:12:48 +00:00
|
|
|
|
|
|
|
; Close file
|
2013-05-09 11:56:54 +00:00
|
|
|
jsr closedirect ; Preserves Y
|
|
|
|
bcs oserr
|
2005-04-12 09:12:48 +00:00
|
|
|
|
|
|
|
; Mark fdtab slot as free
|
2013-05-09 11:56:54 +00:00
|
|
|
zerofd: lda #$00
|
|
|
|
sta fdtab + FD::REF_NUM,y
|
2005-04-12 09:12:48 +00:00
|
|
|
|
|
|
|
; Cleanup I/O buffer
|
2013-05-09 11:56:54 +00:00
|
|
|
jsr freebuffer
|
2005-04-12 09:12:48 +00:00
|
|
|
|
|
|
|
; Return success
|
2013-05-09 11:56:54 +00:00
|
|
|
lda #$00
|
2005-04-12 09:12:48 +00:00
|
|
|
|
2010-06-15 20:38:05 +00:00
|
|
|
; Set __oserror
|
2013-05-09 11:56:54 +00:00
|
|
|
oserr: jmp __mappederrno
|
2010-06-15 21:44:18 +00:00
|
|
|
|
|
|
|
; Set __errno
|
2013-05-09 11:56:54 +00:00
|
|
|
errno: jmp __directerrno
|