diff --git a/f256lib/file.c b/f256lib/file.c index b3bcd1e..c7557d7 100644 --- a/f256lib/file.c +++ b/f256lib/file.c @@ -182,11 +182,11 @@ int16_t fileRead(void *buf, uint16_t nbytes, uint16_t nmemb, uint8_t *fd) { while (gathered < bytes) { returned = kernelRead(*fd, data + gathered, bytes - gathered); - if (returned <= 0) break; + if (returned <= 0) return -1; gathered += returned; } - return gathered; + return nmemb; } @@ -382,7 +382,7 @@ int16_t fileWrite(void *buf, uint16_t nbytes, uint16_t nmemb, uint8_t *fd) { bytes -= written; } - return total; + return nmemb; } diff --git a/f256lib/text.c b/f256lib/text.c index a27a8b3..f382a0d 100644 --- a/f256lib/text.c +++ b/f256lib/text.c @@ -74,21 +74,30 @@ void textClear(void) { } -// Define text color. -void textDefineColor(byte slot, byte fr, byte fg, byte fb, byte br, byte bg, byte bb) { +void textDefineBackgroundColor(byte slot, byte r, byte g, byte b) { + byte *write; + + write = (byte *)VKY_TXT_BGLUT + mathUnsignedMultiply(slot, 4); + *write++ = b; + *write++ = g; + *write++ = r; + *write++ = 0xff; +} + + +void textDefineForegroundColor(byte slot, byte r, byte g, byte b) { byte *write; write = (byte *)VKY_TXT_FGLUT + mathUnsignedMultiply(slot, 4); - *write++ = fb; - *write++ = fg; - *write++ = fr; + *write++ = b; + *write++ = g; + *write++ = r; *write++ = 0xff; +} - write = (byte *)VKY_TXT_BGLUT + mathUnsignedMultiply(slot, 4); - *write++ = bb; - *write++ = bg; - *write++ = br; - *write++ = 0xff; + +void textEnableBackgroundColors(bool b) { + POKE(VKY_MSTR_CTRL_1, (PEEK(VKY_MSTR_CTRL_1) & 0xef) | (b << 4)); } @@ -210,14 +219,10 @@ void textReset(void) { textSetCursor(0); // Set up default text colors. - for (x=0; x