Skip to content

Commit 879391b

Browse files
committed
console co-ords are 1-based
1 parent 5c17088 commit 879391b

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

libctru/source/console.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ PrintConsole defaultConsole =
6060
0,0, //prevcursorX prevcursorY
6161
40, //console width
6262
30, //console height
63-
0, //window x
64-
0, //window y
63+
1, //window x
64+
1, //window y
6565
40, //window width
6666
30, //window height
6767
3, //tab size
@@ -205,9 +205,8 @@ static inline void consolePosition(int x, int y) {
205205
if(y > currentConsole->windowHeight)
206206
y = currentConsole->windowHeight;
207207

208-
// 1-based adjustment
209-
currentConsole->cursorX = x - 1;
210-
currentConsole->cursorY = y - 1;
208+
currentConsole->cursorX = x;
209+
currentConsole->cursorY = y;
211210
}
212211

213212
#define _ANSI_MAXARGS 16
@@ -872,12 +871,12 @@ void consolePrintChar(int c) {
872871
case 8:
873872
currentConsole->cursorX--;
874873

875-
if(currentConsole->cursorX < 0) {
876-
if(currentConsole->cursorY > 0) {
874+
if(currentConsole->cursorX < 1) {
875+
if(currentConsole->cursorY > 1) {
877876
currentConsole->cursorX = currentConsole->windowX - 1;
878877
currentConsole->cursorY--;
879878
} else {
880-
currentConsole->cursorX = 0;
879+
currentConsole->cursorX = 1;
881880
}
882881
}
883882

@@ -890,12 +889,12 @@ void consolePrintChar(int c) {
890889
case 10:
891890
newRow();
892891
case 13:
893-
currentConsole->cursorX = 0;
892+
currentConsole->cursorX = 1;
894893
gfxFlushBuffers();
895894
break;
896895
default:
897-
if(currentConsole->cursorX >= currentConsole->windowWidth) {
898-
currentConsole->cursorX = 0;
896+
if(currentConsole->cursorX > currentConsole->windowWidth) {
897+
currentConsole->cursorX = 1;
899898

900899
newRow();
901900
}

0 commit comments

Comments
 (0)