mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-10 21:21:51 +09:00
antialiased font
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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
|
||||
)) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user