From 0bbfbadc3938948771a98608c5bc6633eaa7bbc5 Mon Sep 17 00:00:00 2001 From: Dave Murphy Date: Sun, 25 Feb 2018 13:51:35 +0000 Subject: [PATCH] switch to 16x16 console font --- nx/data/default_font.bin | Bin 2048 -> 8192 bytes nx/include/switch/runtime/devices/console.h | 12 ++--- nx/source/runtime/devices/console.c | 56 ++++++++++++-------- 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/nx/data/default_font.bin b/nx/data/default_font.bin index e3ae20b324d5a53e08bdf62063e67cd2744475e1..758460e4575c67ffe8c8782da2fa479f2df287f0 100644 GIT binary patch literal 8192 zcmb7|&5GkX5QPod4&+q^vNibC4R_m+S21L3@IBv&j=QY3GczSfNmZ)nBT&ayEnP!!Mu?N`~>j1v3LKWvk$3J@ay+`Foy<@J;;$0a+CZ(gSQRa zFlm5a(`#A^%+owYH#z~<_($%*+kLwO;2|Rl*J0hJZMu*5F_`(JF|Ok}EQ9@0=^p4M zMh0_e_&m%S(lc+fs|03ky5jq#!E(K8umh|$bRc<+zwteByrVk)A_oPG-z{yg=cIA_ z9`Lb8Ozs2q62o)lk^HfzLJQG>Lht>9AKxfX&u5(x`K-ZJK6ari)hdSiSD1Bp#?);b z{2YK?$HN9K5NrcIl}+1`FZ>0wu6)~9P4SIAK;^$F?RjkdRr#OhyHjya7=RAAIrZbk z$&X6sL7kZeGiN(`w%c|iC+ls!kt%8){p`WU_!uA5p6+#J$x z;S&}u2W|H|1o7kVbf5f=dETFd<2aDFuG{i{cfMEqFZ{^&cH(R0^WI=z)$ezUa_26g z$LSM$?AOC!JrePI;4S?_K5==Ez5n(fdD|>`sQKCbYcV(RJ^sq4PtoP{DJR4aRDJ)l zuJuJPdI%BBx`*U6_`ol6(F1??U;0Yf-?rel_vB539l#E?ufRI?9V^KoK748;Ik@6`pY$hw*7SJ5?;P>72A{^K-b{Tf zMlb&F4%L}-?R*6T_}t>W*9;(NqVX z{is#EQGmfnj0Aw@5;z^=b3v3=+o z*o-{q2YJI@%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U|I5 zL3}#nh30s(5a#*J<6z7kmJZ?K$G3d@PuMi*8b#dqZtJ89)U|y#9`e=_zEB?!}uZl&8xGwXJtnJB1ZFh9P=kr*Vk0C1llA+ev=u45RTK| zoFXOW<^3X7uObOZsHdu%wy7(@bU=kvm#eo`RY~>h)!7?x(&qKo^3xth?cVH-*;)JV=HuqC$xLTj-=3pi*Izo; z=LW#M^D+KT;9><4KJV|WWKEMxCpZV1RB#F!95k39hq~{3GTHMJTyN|@ac!sI+tag; z!FWVrn`&DVf_T-F6o?cJmI`xzp zCrO^1p4q&dBt9?XV?O7XB!$b1eBk&#{;#JP*9UM`b*%T;7waBIq9%p{=2UHBdVPQ2o{G9@^k2GM0Qn=y|k6yS__K3v@K h=W)n3xJ8}|`4s2Q=O&xCt_zWK1Z>@U1{w{){sXV$9)kb? diff --git a/nx/include/switch/runtime/devices/console.h b/nx/include/switch/runtime/devices/console.h index 9ed7b748..0d16a6aa 100644 --- a/nx/include/switch/runtime/devices/console.h +++ b/nx/include/switch/runtime/devices/console.h @@ -37,7 +37,7 @@ typedef bool(*ConsolePrint)(void* con, int c); /// A font struct for the console. typedef struct ConsoleFont { - u8* gfx; ///< A pointer to the font graphics + u16* gfx; ///< A pointer to the font graphics u16 asciiOffset; ///< Offset to the first valid character in the font table u16 numChars; ///< Number of characters in the font graphics }ConsoleFont; @@ -51,18 +51,18 @@ typedef struct ConsoleFont * { * //Font: * { - * (u8*)default_font_bin, //font gfx + * (u16*)default_font_bin, //font gfx * 0, //first ascii character in the set * 128, //number of characters in the font set * }, * 0,0, //cursorX cursorY * 0,0, //prevcursorX prevcursorY - * 160, //console width - * 90, //console height + * 80, //console width + * 45, //console height * 0, //window x * 0, //window y - * 160, //window width - * 90, //window height + * 80, //window width + * 45, //window height * 3, //tab size * 0, //font character offset * 0, //print callback diff --git a/nx/source/runtime/devices/console.c b/nx/source/runtime/devices/console.c index eba57fa6..bb9c03f3 100644 --- a/nx/source/runtime/devices/console.c +++ b/nx/source/runtime/devices/console.c @@ -42,7 +42,7 @@ PrintConsole defaultConsole = { //Font: { - (u8*)default_font_bin, //font gfx + (u16*)default_font_bin, //font gfx 0, //first ascii character in the set 256 //number of characters in the font set }, @@ -50,12 +50,12 @@ PrintConsole defaultConsole = (u32*)NULL, 0,0, //cursorX cursorY 0,0, //prevcursorX prevcursorY - 160, //console width - 90, //console height + 80, //console width + 45, //console height 0, //window x 0, //window y - 160, //window width - 90, //window height + 80, //window width + 45, //window height 3, //tab size 7, // foreground color 0, // background color @@ -623,18 +623,18 @@ static void newRow(void) { int i,j; u32 x, y; - x = currentConsole->windowX * 8; - y = currentConsole->windowY * 8; + x = currentConsole->windowX * 16; + y = currentConsole->windowY * 16; - for (i=0; iwindowWidth*8; i++) { + for (i=0; iwindowWidth*16; i++) { u32 *from; u32 *to; - for (j=0;j<(currentConsole->windowHeight-1)*8;j++) { + for (j=0;j<(currentConsole->windowHeight-1)*16;j++) { to = ¤tConsole->frameBuffer[gfxGetFramebufferDisplayOffset(x + i, y + j)]; - from = ¤tConsole->frameBuffer[gfxGetFramebufferDisplayOffset(x + i, y + 8 + j)]; + from = ¤tConsole->frameBuffer[gfxGetFramebufferDisplayOffset(x + i, y + 16 + j)]; *to = *from; to = ¤tConsole->frameBuffer2[gfxGetFramebufferDisplayOffset(x + i, y + j)]; - from = ¤tConsole->frameBuffer2[gfxGetFramebufferDisplayOffset(x + i, y + 8 + j)]; + from = ¤tConsole->frameBuffer2[gfxGetFramebufferDisplayOffset(x + i, y + 16 + j)]; *to = *from; } } @@ -648,7 +648,7 @@ void consoleDrawChar(int c) { c -= currentConsole->font.asciiOffset; if ( c < 0 || c > currentConsole->font.numChars ) return; - u8 *fontdata = currentConsole->font.gfx + (8 * c); + u16 *fontdata = currentConsole->font.gfx + (16 * c); int writingColor = currentConsole->fg; int screenColor = currentConsole->bg; @@ -668,27 +668,37 @@ void consoleDrawChar(int c) { u32 bg = colorTable[screenColor]; u32 fg = colorTable[writingColor]; - u64 bval = *((u64*)fontdata); + u128 *tmp = (u128*)fontdata; - if (currentConsole->flags & CONSOLE_UNDERLINE) bval |= 0xffUL << 7*8; + u128 bvaltop = tmp[0]; + u128 bvalbtm = tmp[1]; - if (currentConsole->flags & CONSOLE_CROSSED_OUT) bval |= 0xff << 3*8; + if (currentConsole->flags & CONSOLE_UNDERLINE) bvalbtm |= (u128)0xffffULL << 7*16; - u8 mask = 0x80; + if (currentConsole->flags & CONSOLE_CROSSED_OUT) bvaltop |= (u128)0xffffULL << 7*16; + + u16 mask = 0x8000; int i, j; - int x = (currentConsole->cursorX + currentConsole->windowX) * 8; - int y = ((currentConsole->cursorY + currentConsole->windowY) *8 ); + int x = (currentConsole->cursorX + currentConsole->windowX) * 16; + int y = ((currentConsole->cursorY + currentConsole->windowY) *16 ); u32 *screen; - for (i=0;i<8;i++) { + for (i=0;i<16;i++) { for (j=0;j<8;j++) { - screen = ¤tConsole->frameBuffer[gfxGetFramebufferDisplayOffset(x + i, y + j)]; - if (bval >> (8*j) & mask) { *screen = fg; }else{ *screen = bg; } - screen = ¤tConsole->frameBuffer2[gfxGetFramebufferDisplayOffset(x + i, y + j)]; - if (bval >> (8*j) & mask) { *screen = fg; }else{ *screen = bg; } + uint32_t screenOffset = gfxGetFramebufferDisplayOffset(x + i, y + j); + screen = ¤tConsole->frameBuffer[screenOffset]; + if (bvaltop >> (16*j) & mask) { *screen = fg; }else{ *screen = bg; } + screen = ¤tConsole->frameBuffer2[screenOffset]; + if (bvaltop >> (16*j) & mask) { *screen = fg; }else{ *screen = bg; } + + screenOffset = gfxGetFramebufferDisplayOffset(x + i, y + j + 8); + screen = ¤tConsole->frameBuffer[screenOffset]; + if (bvalbtm >> (16*j) & mask) { *screen = fg; }else{ *screen = bg; } + screen = ¤tConsole->frameBuffer2[screenOffset]; + if (bvalbtm >> (16*j) & mask) { *screen = fg; }else{ *screen = bg; } } mask >>= 1; }