Bug fixes. fwrite and fread now return expected values.
This commit is contained in:
parent
bc01375056
commit
94a84e3920
3 changed files with 29 additions and 22 deletions
|
@ -182,11 +182,11 @@ int16_t fileRead(void *buf, uint16_t nbytes, uint16_t nmemb, uint8_t *fd) {
|
||||||
|
|
||||||
while (gathered < bytes) {
|
while (gathered < bytes) {
|
||||||
returned = kernelRead(*fd, data + gathered, bytes - gathered);
|
returned = kernelRead(*fd, data + gathered, bytes - gathered);
|
||||||
if (returned <= 0) break;
|
if (returned <= 0) return -1;
|
||||||
gathered += returned;
|
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;
|
bytes -= written;
|
||||||
}
|
}
|
||||||
|
|
||||||
return total;
|
return nmemb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -74,21 +74,30 @@ void textClear(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Define text color.
|
void textDefineBackgroundColor(byte slot, byte r, byte g, byte b) {
|
||||||
void textDefineColor(byte slot, byte fr, byte fg, byte fb, byte br, byte bg, byte bb) {
|
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;
|
byte *write;
|
||||||
|
|
||||||
write = (byte *)VKY_TXT_FGLUT + mathUnsignedMultiply(slot, 4);
|
write = (byte *)VKY_TXT_FGLUT + mathUnsignedMultiply(slot, 4);
|
||||||
*write++ = fb;
|
*write++ = b;
|
||||||
*write++ = fg;
|
*write++ = g;
|
||||||
*write++ = fr;
|
*write++ = r;
|
||||||
*write++ = 0xff;
|
*write++ = 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
write = (byte *)VKY_TXT_BGLUT + mathUnsignedMultiply(slot, 4);
|
|
||||||
*write++ = bb;
|
void textEnableBackgroundColors(bool b) {
|
||||||
*write++ = bg;
|
POKE(VKY_MSTR_CTRL_1, (PEEK(VKY_MSTR_CTRL_1) & 0xef) | (b << 4));
|
||||||
*write++ = br;
|
|
||||||
*write++ = 0xff;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -210,14 +219,10 @@ void textReset(void) {
|
||||||
textSetCursor(0);
|
textSetCursor(0);
|
||||||
|
|
||||||
// Set up default text colors.
|
// Set up default text colors.
|
||||||
for (x=0; x<TEXTCOLORS_COUNT; x++)
|
for (x=0; x<TEXTCOLORS_COUNT; x++) {
|
||||||
textDefineColor(x,
|
textDefineForegroundColor(x, textColors[x].r, textColors[x].g, textColors[x].b);
|
||||||
textColors[x].r,
|
textDefineBackgroundColor(x, textColors[x].r, textColors[x].g, textColors[x].b);
|
||||||
textColors[x].g,
|
}
|
||||||
textColors[x].b,
|
|
||||||
textColors[x].r,
|
|
||||||
textColors[x].g,
|
|
||||||
textColors[x].b);
|
|
||||||
|
|
||||||
textClear();
|
textClear();
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,9 @@ extern colorT textColors[16];
|
||||||
void __putchar(char c); // Allows printf().
|
void __putchar(char c); // Allows printf().
|
||||||
|
|
||||||
void textClear(void);
|
void textClear(void);
|
||||||
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);
|
||||||
|
void textDefineForegroundColor(byte slot, byte r, byte g, byte b);
|
||||||
|
void textEnableBackgroundColors(bool b);
|
||||||
void textGetXY(byte *x, byte *y);
|
void textGetXY(byte *x, byte *y);
|
||||||
void textGotoXY(byte x, byte y);
|
void textGotoXY(byte x, byte y);
|
||||||
void textPrint(char *message);
|
void textPrint(char *message);
|
||||||
|
|
Loading…
Add table
Reference in a new issue