/* Closes a file */
int cbm_read(unsigned char lfn, void* buffer, unsigned int size);
+/* Reads up to "size" bytes from a file to "buffer".
+ * Returns the number of actually read bytes, 0 if there are no bytes left (EOF)
+ * or -1 in case of an error. _oserror contains an errorcode then (see table below).
+ */
-/* Errorcodes of load, save, open functions:
+/* Errorcodes of cbm_* I/O functions:
*
* errorcode BASIC error
* 1 = too many files
all: $(C_OBJS) $(S_OBJS)
clean:
- @rm -f *~ $(C_OBJS:.c=.s) $(C_OBJS) $(S_OBJS)
+ @rm -f *~ *.bck $(C_OBJS:.o=.s) $(C_OBJS) $(S_OBJS)
+/*
+ * Marc 'BlackJack' Rintsch, 19.03.2001
+ *
+ * int cbm_read(unsigned char lfn, void* buffer, unsigned int size);
+ */
#include <cbm.h>
bytesread = 0;
- while (bytesread<size) {
+ while (bytesread<size && !cbm_k_readst()) {
tmp = cbm_k_basin();
- if (cbm_k_readst()) break;
+ if (cbm_k_readst() & 0xBF) break;
((unsigned char*)buffer)[bytesread++] = tmp;
}