cbm_write() added
changed/added some comments all cbm_* IO functions are using _oserror now git-svn-id: svn://svn.cc65.org/cc65/trunk@682 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
32
libsrc/cbm/cbm_write.c
Normal file
32
libsrc/cbm/cbm_write.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Marc 'BlackJack' Rintsch, 25.03.2001
|
||||
*
|
||||
* int cbm_write(unsigned char lfn, void* buffer, unsigned int size);
|
||||
*/
|
||||
|
||||
#include <cbm.h>
|
||||
|
||||
extern unsigned char _oserror;
|
||||
|
||||
int cbm_write(unsigned char lfn, void* buffer, unsigned int size) {
|
||||
|
||||
static unsigned int byteswritten;
|
||||
|
||||
/* if we can't change to the outputchannel #lfn then return an error */
|
||||
if (_oserror = cbm_k_ckout(lfn)) return -1;
|
||||
|
||||
byteswritten = 0;
|
||||
|
||||
while (byteswritten<size && !cbm_k_readst()) {
|
||||
cbm_k_bsout(((unsigned char*)buffer)[byteswritten++]);
|
||||
}
|
||||
|
||||
if (cbm_k_readst()) {
|
||||
_oserror = 5; /* device not present */
|
||||
byteswritten = -1;
|
||||
}
|
||||
|
||||
cbm_k_clrch();
|
||||
|
||||
return byteswritten;
|
||||
}
|
||||
Reference in New Issue
Block a user