mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 11:51:49 +09:00
alphabetised hangul display test
This commit is contained in:
BIN
assets/FontROM7x14_HANGUL.kra
LFS
Normal file
BIN
assets/FontROM7x14_HANGUL.kra
LFS
Normal file
Binary file not shown.
BIN
assets/FontROM7x14_HI__HANGUL.bmp
Normal file
BIN
assets/FontROM7x14_HI__HANGUL.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
BIN
assets/FontROM7x14_HI__HANGUL.png
Normal file
BIN
assets/FontROM7x14_HI__HANGUL.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
188
assets/disk0/home/hangultest.js
Normal file
188
assets/disk0/home/hangultest.js
Normal file
@@ -0,0 +1,188 @@
|
||||
//sys.poke(-1299460, 19) // map the font ROM to the mapping area
|
||||
//sys.poke(-1299460, 19) // write to the font ROM
|
||||
|
||||
let chrmap = {
|
||||
0: '\xA6', // ㄱ
|
||||
1: '\xA7', // ㄴ
|
||||
2: '\xA8', // ㄷ
|
||||
3: '\xA9', // ㄹ
|
||||
4: '\xAA', // ㅁ
|
||||
5: '\xAB', // ㅂ
|
||||
6: '\xAC', // ㅅ
|
||||
7: '\xAD', // ㅇ
|
||||
8: '\xAE', // ㅈ
|
||||
9: '\xAF', // ㅊ
|
||||
10: '\xD0', // ㅋ
|
||||
11: '\xD1', // ㅌ
|
||||
12: '\xD2', // ㅍ
|
||||
13: '\xD3', // ㅎ
|
||||
|
||||
10: '\xD4', // ㅏ
|
||||
11: '\xD5', // ㅐ
|
||||
12: '\xD6', // ㅑ
|
||||
13: '\xD7', // ㅒ
|
||||
14: '\xB5', // ㅓ
|
||||
15: '\xB6', // ㅔ
|
||||
16: '\xB7', // ㅕ
|
||||
17: '\xB8', // ㅖ
|
||||
18: '\xBD', // ㅗ
|
||||
19: '\xBE', // ㅛ
|
||||
20: '\xC6', // ㅜ
|
||||
21: '\xC7', // ㅠ
|
||||
22: '\xD8', // ㅡ
|
||||
23: '\xCF', // ㅣ
|
||||
|
||||
30: '\x9D', // ₩
|
||||
}
|
||||
|
||||
let hangulIdisasm = [
|
||||
'\xA6',
|
||||
'\xA6\xA6',
|
||||
'\xA7',
|
||||
'\xA8',
|
||||
'\xA8\xA8',
|
||||
'\xA9',
|
||||
'\xAA',
|
||||
'\xAB',
|
||||
'\xAB\xAB',
|
||||
'\xAC',
|
||||
'\xAC\xAC',
|
||||
'\xAD',
|
||||
'\xAE',
|
||||
'\xAE\xAE',
|
||||
'\xAF',
|
||||
'\xD0',
|
||||
'\xD1',
|
||||
'\xD2',
|
||||
'\xD3',
|
||||
]
|
||||
|
||||
let hangulPdisasm = [
|
||||
'\xD4',
|
||||
'\xD5',
|
||||
'\xD6',
|
||||
'\xD7',
|
||||
'\xB5',
|
||||
'\xB6',
|
||||
'\xB7',
|
||||
'\xB8',
|
||||
'\xBD',
|
||||
'\xBD\xD4',
|
||||
'\xBD\xD5',
|
||||
'\xBD\xCF',
|
||||
'\xBE',
|
||||
'\xC6',
|
||||
'\xC6\xB5',
|
||||
'\xC6\xB6',
|
||||
'\xC6\xCF',
|
||||
'\xC7',
|
||||
'\xD8',
|
||||
'\xD8\xCF',
|
||||
'\xCF',
|
||||
]
|
||||
|
||||
let hangulFdisasm = [
|
||||
'',
|
||||
'\xA6',
|
||||
'\xA6\xA6',
|
||||
'\xA6\xAC',
|
||||
'\xA7',
|
||||
'\xA7\xAE',
|
||||
'\xA7\xD3',
|
||||
'\xA8',
|
||||
'\xA9',
|
||||
'\xA9\xA6',
|
||||
'\xA9\xAA',
|
||||
'\xA9\xAB',
|
||||
'\xA9\xAC',
|
||||
'\xA9\xD1',
|
||||
'\xA9\xD2',
|
||||
'\xA9\xD3',
|
||||
'\xAA',
|
||||
'\xAB',
|
||||
'\xAB\xAC',
|
||||
'\xAC',
|
||||
'\xAC\xAC',
|
||||
'\xAD',
|
||||
'\xAE',
|
||||
'\xAF',
|
||||
'\xD0',
|
||||
'\xD1',
|
||||
'\xD2',
|
||||
'\xD3',
|
||||
]
|
||||
|
||||
let UTF8_ACCEPT = 0
|
||||
let UTF8D = [
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
|
||||
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
||||
8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
|
||||
10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8,
|
||||
0,12,24,36,60,96,84,12,12,12,48,72, 12,12,12,12,12,12,12,12,12,12,12,12,
|
||||
12, 0,12,12,12,12,12, 0,12, 0,12,12, 12,24,12,12,12,12,12,24,12,24,12,12,
|
||||
12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24,12,12,
|
||||
12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36,12,12,
|
||||
12,36,12,12,12,12,12,12,12,12,12,12,
|
||||
]
|
||||
|
||||
/**
|
||||
* @param utf8text A JS string in UTF-8
|
||||
* @return array of Unicode codepoints
|
||||
*/
|
||||
function utf8decode(utf8text) {
|
||||
var state = UTF8_ACCEPT
|
||||
var codep = 0
|
||||
var codepoints = []
|
||||
|
||||
for (let i=0; i < utf8text.length; i++) {
|
||||
let byte = utf8text.charCodeAt(i)
|
||||
let type = UTF8D[byte]
|
||||
codep = (state != UTF8_ACCEPT) ?
|
||||
(byte & 0x3f) | (codep << 6) : (0xff >> type) & (byte)
|
||||
state = UTF8D[256 + state + type]
|
||||
if (state == UTF8_ACCEPT)
|
||||
codepoints.push(codep)
|
||||
}
|
||||
return codepoints
|
||||
}
|
||||
|
||||
let str = "한글 TVDOS 0마당 3고개" // in utf-8 for TSVM
|
||||
|
||||
/**
|
||||
* @param codepoint A single Unicode character in codepoint
|
||||
* @return A string representation of the character in TSVM codepage converted from the codepoint
|
||||
*/
|
||||
function hangulDecode(codepoints) {
|
||||
let s = ''
|
||||
|
||||
for (let i = 0; i < codepoints.length; i++) {
|
||||
let codepoint = codepoints[i]
|
||||
let c1 = codepoints[i+1]
|
||||
|
||||
|
||||
serial.println(codepoint.toString(16))
|
||||
serial.println(String.fromCharCode(codepoint))
|
||||
|
||||
|
||||
if (0xAC00 <= codepoint && codepoint <= 0xD7A3) {
|
||||
let i = ((codepoint - 0xAC00) / 588)|0
|
||||
let p = ((codepoint - 0xAC00) / 28 % 21)|0
|
||||
let f = (codepoint - 0xAC00) % 28
|
||||
s += (hangulIdisasm[i] + hangulPdisasm[p] + hangulFdisasm[f])
|
||||
if (0xAC00 <= c1 && c1 <= 0xD7A3) s += ' '
|
||||
}
|
||||
else if (0x20A9 == codepoint) s += '\x9D'
|
||||
else {
|
||||
s += String.fromCharCode(codepoint)
|
||||
if (0xAC00 <= c1 && c1 <= 0xD7A3) s += ' '
|
||||
}
|
||||
}
|
||||
|
||||
return s
|
||||
}
|
||||
|
||||
println(hangulDecode(utf8decode(str)))
|
||||
@@ -177,6 +177,7 @@ From the start of the memory space:
|
||||
unused
|
||||
1920
|
||||
mapped to font ROM
|
||||
Font Mapping area holds 128 characters in consecutive order, each character is always 15 bytes.
|
||||
|
||||
2 bytes
|
||||
Cursor position in: (y*80 + x)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package net.torvald.tsvm;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
|
||||
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
|
||||
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
|
||||
@@ -49,6 +48,6 @@ public class AppLoader {
|
||||
pipvm, 160, 140
|
||||
))));
|
||||
|
||||
new Lwjgl3Application(new VMGUI(pip, WIDTH, HEIGHT), appConfig);
|
||||
new Lwjgl3Application(new VMGUI(reference, WIDTH, HEIGHT), appConfig);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.torvald.terrarum.modulecomputers.tsvmperipheral.WorldRadar
|
||||
import net.torvald.tsvm.peripheral.*
|
||||
import java.io.File
|
||||
|
||||
|
||||
class EmulInstance(
|
||||
val vm: VM,
|
||||
val display: String?,
|
||||
@@ -71,8 +72,8 @@ class VMGUI(val loaderInfo: EmulInstance, val viewportWidth: Int, val viewportHe
|
||||
private fun init() {
|
||||
if (loaderInfo.display != null) {
|
||||
val loadedClass = Class.forName(loaderInfo.display)
|
||||
val loadedClassConstructor = loadedClass.getConstructor(vm::class.java)
|
||||
val loadedClassInstance = loadedClassConstructor.newInstance(vm)
|
||||
val loadedClassConstructor = loadedClass.getConstructor(String::class.java, vm::class.java)
|
||||
val loadedClassInstance = loadedClassConstructor.newInstance("./assets", vm)
|
||||
gpu = (loadedClassInstance as GraphicsAdapter)
|
||||
|
||||
vm.getIO().blockTransferPorts[0].attachDevice(TestDiskDrive(vm, 0, File(loaderInfo.diskPath)))
|
||||
|
||||
Reference in New Issue
Block a user