Skip to content

Commit

Permalink
Improve line breaks, bug fix for "\n" as line breaks
Browse files Browse the repository at this point in the history
Update makefile and changelog
  • Loading branch information
R-YaTian committed Dec 12, 2023
1 parent d1d7f73 commit 0c1bea4
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 14 deletions.
4 changes: 4 additions & 0 deletions picodrive-make
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(APP_ROMFS)
endif

ifneq ($(RELEASE),)
CXXFLAGS += -DEMU_RELEASE
endif

#---------------------------------------------------------------------------------
# OS detection to automatically determine the correct makerom variant to use for
# CIA creation
Expand Down
1 change: 1 addition & 0 deletions readme-picodrive.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ This emulator uses the same user interface as VirtuaNES for 3DS, TemperPCE for 3
### v0.95c
- Fully Simplified Chinese support, big thx to [xxxxst](https://github.com/xxxxst)
- Now will sort files by Chinese Pinyin
- UI: Improve line breaks, bug fix for "\n" as line breaks
- Implement standard/ssf2 mapper. This fix "Demons Of Asteborg", "Astebros" and etc
- Fix config saving
- Fix crashing when exit from CIA version
Expand Down
1 change: 1 addition & 0 deletions readme-temperpce.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ This emulator bears the same user interface as VirtuaNES for 3DS and Snes9x for
### v1.03c
- Fully Simplified Chinese support, big thx to [xxxxst](https://github.com/xxxxst)
- Now will sort files by Chinese Pinyin
- UI: Improve line breaks, bug fix for "\n" as line breaks
- Fix config saving
- Fix crashing when exit from CIA version

Expand Down
1 change: 1 addition & 0 deletions readme-virtuanes.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ It also runs on your New 3DS as well!
### v1.03c
- Fully Simplified Chinese support, big thx to [xxxxst](https://github.com/xxxxst)
- Now will sort files by Chinese Pinyin
- UI: Improve line breaks, bug fix for "\n" as line breaks
- Fix config saving
- Fix crashing when exit from CIA version
- Add embedded input redirect server to support 2 players, thx [CarlosEFML](https://github.com/CarlosEFML)
Expand Down
46 changes: 32 additions & 14 deletions src/3ds/3dsui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,9 +537,9 @@ void ui3dsDrawStringWithWrapping(int x0, int y0, int x1, int y1, int color, int
int slen = strlen(buffer);

int curStartPos = 0;
int curEndPos = slen - 1;
int lineWidth = 0;
for (int i = 0; i < slen; )
int curEndPos = slen
uint16 lineWidth = 0;
for (int i = 0; i <= slen; )
{
if (i != curStartPos)
{
Expand All @@ -550,10 +550,32 @@ void ui3dsDrawStringWithWrapping(int x0, int y0, int x1, int y1, int color, int
else if (buffer[i] == '\n') // \n as line breaks.
{
curEndPos = i - 1;
lineWidth = 999999; // force the line break.
lineWidth = 65535; // force the line break.
}
}
lineWidth += fontWidth[buffer[i]];

// check utf8 char is chinese
if((buffer[i] & 0xF0) == 0xE0 && i <= slen - 2) {
uint8 c2 = buffer[i + 1];
uint8 c3 = buffer[i + 2];

uint16 chUtf8 = ((buffer[i] & 0x0F) << 12)
| ((c2 & 0x3F) << 6)
| ((c3 & 0x3F));
uint16 chGBK = getGbkChar(chUtf8);

uint8 cg1 = (chGBK & 0xFF00) >> 8;
uint8 cg2 = (chGBK & 0x00FF);

if(cg1 >= gbkRowStart && cg1 <= gbkRowEnd
&& cg2 >= gbkColStart && cg2 <= gbkColEnd) {
lineWidth += 12;
i += 2;
} else
lineWidth += fontWidth[buffer[i]];
} else
lineWidth += fontWidth[buffer[i]];

if (lineWidth > maxWidth)
{
// Break the line here
Expand All @@ -563,26 +585,22 @@ void ui3dsDrawStringWithWrapping(int x0, int y0, int x1, int y1, int color, int

if (strLineCount >= 30) break;

if (lineWidth != 999999)
if (lineWidth != 65535)
{
i = curEndPos + 1;
while (buffer[i] == ' ')
i++;
}
else
{
} else
i = curEndPos + 2;
}
curStartPos = i;
curEndPos = slen - 1;
curEndPos = slen;
lineWidth = 0;
}
else
} else
i++;
}

// Output the last line.
curEndPos = slen - 1;
curEndPos = slen;
if (curStartPos <= curEndPos)
{
strLineStart[strLineCount] = curStartPos;
Expand Down
4 changes: 4 additions & 0 deletions temperpce-make
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(APP_ROMFS)
endif

ifneq ($(RELEASE),)
CXXFLAGS += -DEMU_RELEASE
endif

#---------------------------------------------------------------------------------
# OS detection to automatically determine the correct makerom variant to use for
# CIA creation
Expand Down
4 changes: 4 additions & 0 deletions virtuanes-make
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(APP_ROMFS)
endif

ifneq ($(RELEASE),)
CXXFLAGS += -DEMU_RELEASE
endif

#---------------------------------------------------------------------------------
# OS detection to automatically determine the correct makerom variant to use for
# CIA creation
Expand Down

0 comments on commit 0c1bea4

Please sign in to comment.