]> git.sur5r.net Git - cc65/blob - libsrc/cbm/cbm_write.c
info about c1541 in docs, lowered highest available address to $6000 due to
[cc65] / libsrc / cbm / cbm_write.c
1 /*
2  * Marc 'BlackJack' Rintsch, 25.03.2001
3  *
4  * int cbm_write(unsigned char lfn, void* buffer, unsigned int size);
5  */
6
7 #include <cbm.h>
8
9 extern unsigned char _oserror;
10
11 int cbm_write(unsigned char lfn, void* buffer, unsigned int size) {
12
13     static unsigned int byteswritten;
14     
15     /* if we can't change to the outputchannel #lfn then return an error */
16     if (_oserror = cbm_k_ckout(lfn)) return -1;
17     
18     byteswritten = 0;
19     
20     while (byteswritten<size && !cbm_k_readst()) {
21         cbm_k_bsout(((unsigned char*)buffer)[byteswritten++]);
22     }
23
24     if (cbm_k_readst()) {
25         _oserror = 5; /* device not present */
26         byteswritten = -1;
27     }
28         
29     cbm_k_clrch();
30     
31     return byteswritten;
32 }