Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix screen code naming #59

Merged
merged 4 commits into from
Aug 24, 2024
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Simple C library for the MEGA65
~~~sh
cd mega65-libc
cmake -DCMAKE_PREFIX_PATH=$HOME/llvm-mos -B build
cd build
make
make test # if `xmega65` (Xemu) was in your path when running cmake
~~~
Expand Down
19 changes: 18 additions & 1 deletion include/mega65/fcio.h
Original file line number Diff line number Diff line change
Expand Up @@ -516,14 +516,31 @@ fciInfo* fc_displayFCIFile(char* filename, byte x0, byte y0);
void fc_plotExtChar(byte x, byte y, byte c);

/**
* @brief plot petscii character
* @brief plot screencode character
*
* @param x screen column
* @param y screen row
* @param c character code
* @param color character colour
* @param exAttr extended attributes
*/
void fc_plotScreenChar(byte x, byte y, byte c, byte color, byte exAttr);

/**
* @deprecated The function name is misleading as the supplied character code
* is expected to be a screen character code, not a PETSCII code.
* Use @ref fc_plotScreenChar(byte, byte, byte, byte, byte) instead.
* @brief plot screencode character
*
* @param x screen column
* @param y screen row
* @param c character code
* @param color character colour
* @param exAttr extended attributes
*/
#ifdef __clang__
[[deprecated("Use fc_plotScreenChar() instead.")]]
#endif
void fc_plotPetsciiChar(byte x, byte y, byte c, byte color, byte exAttr);

#endif // __MEGA65_FCIO_H
19 changes: 12 additions & 7 deletions src/fcio.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ himemPtr fc_allocPalMem(word size)
return 0;
}

char asciiToPetscii(byte c)
char asciiToScreencode(byte c)
{
// TODO: could be made much faster with translation table
if (c == '_') {
Expand All @@ -356,7 +356,7 @@ char asciiToPetscii(byte c)
if (c >= 192) {
return c - 128;
}
return c;
return (char)c;
}

#ifdef __clang__
Expand Down Expand Up @@ -741,7 +741,7 @@ void cr(void)
}
}

void fc_plotPetsciiChar(byte x, byte y, byte c, byte color, byte exAttr)
mlund marked this conversation as resolved.
Show resolved Hide resolved
void fc_plotScreenChar(byte x, byte y, byte c, byte color, byte exAttr)
{
word adrOffset;
adrOffset = (x * 2) + (y * 2 * gScreenColumns);
Expand All @@ -751,6 +751,11 @@ void fc_plotPetsciiChar(byte x, byte y, byte c, byte color, byte exAttr)
lpoke(gFcioConfig->colourBase + adrOffset, 0);
}

void fc_plotPetsciiChar(byte x, byte y, byte c, byte color, byte exAttr)
{
fc_plotScreenChar(x, y, c, color, exAttr);
}

byte fc_wherex(void)
{
return gCurrentWin->xc;
Expand Down Expand Up @@ -781,9 +786,9 @@ void fc_putc(char c)
return;
}

out = asciiToPetscii(c);
out = asciiToScreencode((byte)c);

fc_plotPetsciiChar(gCurrentWin->xc + gCurrentWin->x0,
fc_plotScreenChar(gCurrentWin->xc + gCurrentWin->x0,
gCurrentWin->yc + gCurrentWin->y0, out, gCurrentWin->textcolor,
gCurrentWin->extAttributes);
gCurrentWin->xc++;
Expand All @@ -800,7 +805,7 @@ void fc_putc(char c)
}

if (csrflag) {
fc_plotPetsciiChar(gCurrentWin->xc + gCurrentWin->x0,
fc_plotScreenChar(gCurrentWin->xc + gCurrentWin->x0,
gCurrentWin->yc + gCurrentWin->y0, CURSOR_CHARACTER,
gCurrentWin->textcolor, 16);
}
Expand Down Expand Up @@ -849,7 +854,7 @@ void fc_cursor(byte onoff)
{
csrflag = onoff;

fc_plotPetsciiChar(gCurrentWin->xc + gCurrentWin->x0,
fc_plotScreenChar(gCurrentWin->xc + gCurrentWin->x0,
gCurrentWin->yc + gCurrentWin->y0, (csrflag ? CURSOR_CHARACTER : 32),
gCurrentWin->textcolor, (csrflag ? 16 : 0));
}
Expand Down
Loading