mirror of
https://github.com/knightfox75/nds_nflib.git
synced 2025-06-18 16:55:32 -04:00
library: Fix '\n' in NF_WriteText16()
Also, slightly rework the code of NF_WriteText() to match the code sytle of the rest of the library.
This commit is contained in:
parent
70fe30ef29
commit
d892d6cc8a
@ -189,21 +189,25 @@ void NF_WriteText(int screen, u32 layer, u32 x, u32 y, const char *text)
|
|||||||
for (u32 n = 0; n < tsize; n++)
|
for (u32 n = 0; n < tsize; n++)
|
||||||
{
|
{
|
||||||
int value = 0;
|
int value = 0;
|
||||||
if(text[n]==10) value = 10; // If newline found put the character to the newline --BG2CNT
|
|
||||||
else value = text[n] - 32; // Else, skip the first 32 non-printable characters --BG2CNT
|
// If newline found, put the character to the newline. If not, skip the
|
||||||
|
// first 32 characters.
|
||||||
|
if (text[n] == '\n')
|
||||||
|
value = '\n';
|
||||||
|
else
|
||||||
|
value = text[n] - 32;
|
||||||
|
|
||||||
if (value < 0)
|
if (value < 0)
|
||||||
value = 0;
|
value = 0;
|
||||||
|
|
||||||
string[n] = value;
|
string[n] = value;
|
||||||
|
|
||||||
// Handle special characters
|
// Handle special characters (newline characters are special too)
|
||||||
if (string[n] > 95||
|
if ((string[n] > 95) || (string[n] == 10))
|
||||||
string[n]==10) //If the character is a newline, it's a special character --BG2CNT
|
|
||||||
{
|
{
|
||||||
switch (text[n])
|
switch (text[n])
|
||||||
{
|
{
|
||||||
case 10: // \n
|
case '\n':
|
||||||
string[n] = 200;
|
string[n] = 200;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -162,18 +162,26 @@ void NF_WriteText16(int screen, u32 layer, u32 x, u32 y, const char *text)
|
|||||||
// Store the text string in the temporary buffer
|
// Store the text string in the temporary buffer
|
||||||
for (u32 n = 0; n < tsize; n++)
|
for (u32 n = 0; n < tsize; n++)
|
||||||
{
|
{
|
||||||
int value = text[n] - 32; // Skip the first 32 non-printable characters
|
int value = 0;
|
||||||
|
|
||||||
|
// If newline found, put the character to the newline. If not, skip the
|
||||||
|
// first 32 characters.
|
||||||
|
if (text[n] == '\n')
|
||||||
|
value = '\n';
|
||||||
|
else
|
||||||
|
value = text[n] - 32;
|
||||||
|
|
||||||
if (value < 0)
|
if (value < 0)
|
||||||
value = 0;
|
value = 0;
|
||||||
|
|
||||||
string[n] = value;
|
string[n] = value;
|
||||||
|
|
||||||
// Handle special characters
|
// Handle special characters (newline characters are special too)
|
||||||
if (string[n] > 95)
|
if ((string[n] > 95) || (string[n] == 10))
|
||||||
{
|
{
|
||||||
switch (text[n])
|
switch (text[n])
|
||||||
{
|
{
|
||||||
case 10: // \n
|
case '\n':
|
||||||
string[n] = 200;
|
string[n] = 200;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user