Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions include/mega65/conio.h
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,8 @@ void fastcall cputs(const unsigned char* s);
* @param y The Y coordinate where string will be printed
* @param s An array of screen codes to print. Must have non-zero length.
* @remarks This function works with screen codes only. To output ordinary
* @warning Undefined behavior if `s` has zero length.
* ASCII/PETSCII strings, use the "pcputsxy" macro. No pointer check is
* performed. If s is null or invalid, behavior is undefined.
*/
void cputsxy(unsigned char x, unsigned char y, const unsigned char* s);

Expand Down Expand Up @@ -946,7 +947,6 @@ void cputcxy(unsigned char x, unsigned char y, unsigned char c);
* @param y The Y coordinate where character will be printed
* @param count The number of characters to output. Must be larger than zero.
* @param c The screen code of the characters to print
* @warning Undefined behavior if `count` is zero.
*/
void cputncxy(
unsigned char x, unsigned char y, unsigned char count, unsigned char c);
Expand Down
19 changes: 11 additions & 8 deletions src/conio.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,11 @@ void cputs(const unsigned char* s)
void cputsxy(unsigned char x, unsigned char y, const unsigned char* s)
{
const unsigned char len = (unsigned char)strlen((const char*)s);
const unsigned int offset = (y * (unsigned int)g_curScreenW) + x;
lcopy((unsigned long)s, SCREEN_RAM_BASE + offset, len);
lfill(COLOR_RAM_BASE + offset, g_curTextColor, len);
if (len > 0) {
const unsigned int offset = (y * (unsigned int)g_curScreenW) + x;
lcopy((unsigned long)s, SCREEN_RAM_BASE + offset, len);
lfill(COLOR_RAM_BASE + offset, g_curTextColor, len);
}
g_curY = y + ((x + len) / g_curScreenW);
g_curX = (x + len) % g_curScreenW;
}
Expand All @@ -590,9 +592,11 @@ void cputcxy(unsigned char x, unsigned char y, unsigned char c)
void cputncxy(
unsigned char x, unsigned char y, unsigned char count, unsigned char c)
{
const unsigned int offset = (y * (unsigned int)g_curScreenW) + x;
lfill(SCREEN_RAM_BASE + offset, c, count);
lfill(COLOR_RAM_BASE + offset, g_curTextColor, count);
if (count > 0) {
const unsigned int offset = (y * (unsigned int)g_curScreenW) + x;
lfill(SCREEN_RAM_BASE + offset, c, count);
lfill(COLOR_RAM_BASE + offset, g_curTextColor, count);
}
g_curY = y + ((x + count) / g_curScreenW);
g_curX = (x + count) % g_curScreenW;
}
Expand Down Expand Up @@ -714,8 +718,7 @@ unsigned char cinput(
}

while (1) {
if (strlen(buffer) != 0)
cputsxy(sx, sy, buffer);
cputsxy(sx, sy, buffer);
blink(1);
cputc(224);
blink(0);
Expand Down