I finally made some sort of KNJLIB system...
How does it work?
@ASC0'label for the ASCII character data
DATA 10,10,0'char data width, data height and char width (char data w/h are actually not used)
DATA &H40F,&H0F,&H4F,&H40,&H8F,&HAF,&HEF,&HA55,&H3FF,&H2CD'character data
The code above is an example of the data structure for each ASCII that is supported. Invalid ones default to a different one (in my system: &H
E01B
The 3DS's font displays this ASCII as a different "replacement" character than the standardized inverted question mark box. SmileBASIC's font doesn't support it.)
GPRINT0 X,Y,S,C,W,EX,EY
X - horizontal offset
Y - vertical offset
S - String/Numerical value
C - Display color (Can be changed using a tag in string)
W - Text wrap flag (0=off 1=on)
EX, EY - Position where text wraps or ends prematurely
Tags
%E - Insert a line break
%CRRGGBB - Change color R,G,B - RGB in hex
%B - Enable / Disable bold
%I - Enable / Disable italic (WIP)
%U - Enable / Disable underlining
%S - Enable / Disable striking
%Wnn - Change spacing (nn=0: default)
%Hnn - Change line spacing (nn=13: default)
%R - Reset text formatting (normal text using color C ↑)
The DEF (not up-to-date)
DEF GPRINT0 X,Y,S,C,W,EX,EY
VAR OC=C,OX=X,OY=Y,I,_B,B,IT,U,ST,S$,TMP,NUL,D,HEI=13,SP
IF TYPEOF(S)!=2 THEN S$=STR$(S) ELSE S$=S
WHILE I<LEN(S$)
IF S$[I]=="%" THEN
IF S$[I+1]=="E"THEN OX=X:INC OY,HEI:INC I,2CONTINUE
IF S$[I+1]=="R"THEN C=OC:B=0IT=0U=0ST=0D=0HEI=13INC I,2CONTINUE
IF S$[I+1]=="C"THEN C=VAL("&HFF"+MID$(S$,I+2,6))INC I,8CONTINUE
IF S$[I+1]=="B"THEN B=!B:INC I,2CONTINUE
'IF S$[I+1]=="I"THEN IT=!IT:INC I,2CONTINUE
IF S$[I+1]=="U"THEN U=!U:INC I,2CONTINUE
IF S$[I+1]=="S"THEN ST=!ST:INC I,2CONTINUE
ENDIF
_B=0
WHILE _B<=B
IF CHKLABEL("@ASC"+STR$(ASC(S$))) THEN RESTORE "@ASC"+STR$(ASC(S$)) ELSE RESTORE "@ASC"+STR$(&HE01B)
READ NUL,NUL,SP
_Y=0
WHILE _Y<11
READ TMP
_X=0
WHILE _X<11
IF TMP AND POW(2,10-_X)THEN GPSET OX+(10-_X),OY+_Y,C
INC _X
WEND
INC _Y
WEND
INC _B
WEND
IF U THEN GLINE OX,OY+11,OX+SP+D+B,OY+11,C
IF ST THEN GLINE OX,OY+5,OX+SP+D+B,OY+5,C
INC OX,SP+D+B
IF W THEN IF OX>EX THEN INC OY,HEI:OX=X
IF OY>IFF(W,511,EY) THEN BREAK
INC I
WEND
END
It uses WHILE loops so it's a tiny bit faster when display a bigger string than using FOR.
OC holds the color you put in the argument. This can be used when %R is reached in a string to reset the color.
OX and OY are used instead of the originals.
NUL is simply taking the data that isn't needed (character data width/height in this case)
TMP holds the _Yth row of the character data itself that it GPSETs one at a time. (Improvements must be made)
SP contains the width of the character itself.
B, IT, U and ST are self-explanatory.
_B is there to repeat the loop once more when B is set using %B once
D is the amount of extra pixels to space 2 characters. Negative values for D brings the characters closer together.
HEI is the amount of pixels to go down from the top of a character when a line break occures using %E or the wrap flag is set.
You might have noticed S and S$. Because DEFs aren't strictly checked for the type the variables have, I can use S for both numericals and strings. Depending on TYPEOF's result, S$ will hold the string contained in S or use the string version of the numerical contained in S. Just make sure both types don't occure together. I might change it, so a numerical in S uses the ASCII character with the unicode offset U+S identical to GPUTCHR.
The TYPEOF and IFF functions are in XCMD.LIB, so I don't need to explain these.
Speaking of, the data and the DEF (obviously) sit within XCMD.LIB so the font can be used by user apps or other built-in programs.
EDIT: Could not give at this time
Umm, no. Checked code and added phrases for "Magistr"! lol
EDIT 2: I missed something. Sorry!
EDIT 3:
Boy, how many mistakes do I make...
Hence, why I am not so intermediate. lol