2001-03-30 18:18:40 +00:00
|
|
|
/*
|
|
|
|
* Marc 'BlackJack' Rintsch, 25.03.2001
|
|
|
|
*
|
|
|
|
* int cbm_write(unsigned char lfn, void* buffer, unsigned int size);
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <cbm.h>
|
2001-09-15 23:39:47 +00:00
|
|
|
#include <errno.h>
|
2001-03-30 18:18:40 +00:00
|
|
|
|
|
|
|
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()) {
|
2001-09-15 23:39:47 +00:00
|
|
|
_oserror = 5; /* device not present */
|
2001-03-30 18:18:40 +00:00
|
|
|
byteswritten = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
cbm_k_clrch();
|
|
|
|
|
|
|
|
return byteswritten;
|
|
|
|
}
|