1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-26 20:29:34 +00:00

completed and testet cbm_read()

git-svn-id: svn://svn.cc65.org/cc65/trunk@639 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
mrintsch 2001-03-21 20:59:27 +00:00
parent 9528c379c1
commit 787ca6a9dd
3 changed files with 13 additions and 4 deletions

View File

@ -130,8 +130,12 @@ void __fastcall__ cbm_close (unsigned char lfn);
/* 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

View File

@ -23,5 +23,5 @@ S_OBJS = ctype.o getenv.o gotoxy.o gotox.o gotoy.o where.o\
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)

View File

@ -1,3 +1,8 @@
/*
* Marc 'BlackJack' Rintsch, 19.03.2001
*
* int cbm_read(unsigned char lfn, void* buffer, unsigned int size);
*/
#include <cbm.h>
@ -12,9 +17,9 @@ int cbm_read(unsigned char lfn, void* buffer, unsigned int size)
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;
}