antialiased font

This commit is contained in:
minjaesong
2020-11-16 13:30:20 +09:00
parent c6260bb355
commit 3aca6c84be
7 changed files with 36 additions and 10 deletions

11
assets/emittest.js Normal file
View File

@@ -0,0 +1,11 @@
con.clear();
con.move(1,1);
for (let i = 0; i < 2048; i++) {
if (i < 1024) con.color_pair(239, 0); else con.color_pair(0, 239);
let cx = (i%80)+1;
let cy = ((i/80)|0)+1;
//serial.printerr(cx+","+cy);
con.move(cy,cx);
con.addch(i%256);
}

View File

@@ -549,7 +549,7 @@ bStatus.builtin = {
let varname = asgnObj.asgnVarName
// check for variable name collision (e.g. 10 K=1TO10 \n 20 FOR I=K should work but 20 FOR K=K must not)
if (bStatus.vars[varname] !== undefined)) throw lang.dupDef(lnum, varname);
if (bStatus.vars[varname] !== undefined) throw lang.dupDef(lnum, varname);
// assign new variable
bStatus.vars[varname] = asgnObj.asgnValue

BIN
cp437_fira_code.kra LFS Normal file

Binary file not shown.

BIN
cp437_fira_code.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -30,8 +30,8 @@ public class AppLoader {
// val vm = VM(64.kB(), TheRealWorld(), arrayOf(GenericBios))
//VM vm = new VM(64 << 10, new TheRealWorld(), new VMProgramRom[]{GenericBios.INSTANCE});
VM vm = new VM(64 << 10, new TheRealWorld(), new VMProgramRom[]{BasicBios.INSTANCE, BasicRom.INSTANCE});
VM vm = new VM(64 << 10, new TheRealWorld(), new VMProgramRom[]{GenericBios.INSTANCE});
//VM vm = new VM(64 << 10, new TheRealWorld(), new VMProgramRom[]{BasicBios.INSTANCE, BasicRom.INSTANCE});
new LwjglApplication(new VMGUI(vm, appConfig), appConfig);
}

View File

@@ -323,7 +323,7 @@ open class GraphicsAdapter(val vm: VM, val config: AdapterConfig) :
for (i in 0 until TEXT_COLS * TEXT_ROWS step 4) {
spriteAndTextArea.setInt(memTextForeOffset + i, foreBits)
spriteAndTextArea.setInt(memTextBackOffset + i, backBits)
spriteAndTextArea.setInt(memTextOffset + i, -1)
spriteAndTextArea.setInt(memTextOffset + i, 0)
}
spriteAndTextArea.setShort(memTextCursorPosOffset, 0)
}
@@ -763,7 +763,7 @@ open class GraphicsAdapter(val vm: VM, val config: AdapterConfig) :
val DEFAULT_CONFIG_COLOR_CRT = AdapterConfig(
"crt_color",
560, 448, 80, 32, 254, 255, 256.kB(), "./FontROM7x14.png", 0.32f
560, 448, 80, 32, 254, 255, 256.kB(), "./cp437_fira_code.png", 0.32f
)
val DEFAULT_CONFIG_PMLCD = AdapterConfig(
"pmlcd_inverted",
@@ -882,6 +882,8 @@ uniform vec2 tilesInAtlas = ivec2(16.0, 16.0);
uniform vec2 atlasTexSize = ivec2(128.0, 224.0);
vec2 tileSizeInPx = atlasTexSize / tilesInAtlas; // should be like ivec2(16, 16)
float fontGamma = 1.8;
ivec2 getTileXY(int tileNumber) {
return ivec2(tileNumber % int(tilesInAtlas.x), tileNumber / int(tilesInAtlas.x));
}
@@ -897,6 +899,15 @@ int getTileFromColor(vec4 color) {
return _colToInt(color) & 0xFFFFF;
}
vec4 fontMix(vec4 zero, vec4 one, float scale) {
return vec4(zero.r * (1 - pow(scale, fontGamma)) + one.r * pow(scale, fontGamma),
zero.g * (1 - pow(scale, fontGamma)) + one.g * pow(scale, fontGamma),
zero.b * (1 - pow(scale, fontGamma)) + one.b * pow(scale, fontGamma),
zero.a * (1 - pow(scale, fontGamma)) + one.a * pow(scale, fontGamma)
);
}
void main() {
// READ THE FUCKING MANUAL, YOU DONKEY !! //
@@ -933,7 +944,8 @@ void main() {
vec4 tileCol = texture2D(tilesAtlas, finalUVCoordForTile);
// apply colour. I'm expecting FONT ROM IMAGE to be greyscale
gl_FragColor = mix(backColFromMap, foreColFromMap, tileCol.r);
// TODO non-linear mix with gamma 2.2
gl_FragColor = fontMix(backColFromMap, foreColFromMap, tileCol.r);
}
""".trimIndent()

View File

@@ -7,14 +7,14 @@ import net.torvald.tsvm.kB
class TexticsAdapter(vm: VM, theme: String) : GraphicsAdapter(vm, AdapterConfig(
"crt_green",
720,
400,
560,
448,
80,
25,
32,
239,
0,
256.kB(),
"./tty.png",
"./cp437_fira_code.png",
0.7f
)) {