mirror of
https://github.com/D-Modem/app.git
synced 2026-11-28 17:38:05 -08:00
Commodore and Atari terminals: PETSCII and ATASCII (Phase 5, part of 7) (#35)
* Commodore terminals: PETSCII for the C64, C128, Plus/4, VIC-20 and PET The Commodore 8-bits become terminal types, as CCGMS and Novaterm speak PETSCII. A shared ByteControlInterpreter template does what a home computer's screen editor did (octets read in the machine's own set, the screen's size and palette set while it's the profile, a wrap as soon as the last column is written, cursor keys wrapping round line ends, delete and insert in the line, typing turned back into the set's codes); the PetsciiInterpreter adds Commodore's codes: colours, cursor, HOME, CLR, DEL, INST, RVS, the two sets, the bell, and the C128 and Plus/4 ESC sequences. The profiles are a hierarchy (C64 <- C128 <- C128 80-column, C64 <- Plus/4, C64 <- VIC-20, PET <- PET 80) changing only their screen, palette, sets and extras. The characters are drawn from 8x8 bitmaps: Unscii's glyphs (public domain) for the code points Rebecca Bettencourt's Legacy Computing mappings give each code, generated into LegacyCharsets.kt by tools/gen_legacy_charsets.py. No Commodore ROM font is shipped. Android and iOS draw them in square cells, the view fitted to the machine's columns and no more than its rows. Keys and typing go through the interpreter (TerminalEmulator.keyOctets and charOctets), so a Commodore's cursor keys, F1-F8, CTRL and C= colours and C= graphics send PETSCII; pasted Legacy Computing characters map back. The key bar gets the Commodore pages (RUN/STOP, CLR/HOME, INST/DEL, RVS, F-keys, colour swatches) through a new BarKey.Octets. Captures under a Commodore profile are saved as .seq. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B82eRSyCmXjaURxSYoHxCY * Atari terminals (ATASCII), and the doc comments the docs check wants ATASCII joins PETSCII on the shared ByteControlInterpreter: an Atari 8-bit profile (and one with the XL's international set) speaks the screen editor's codes as Ice-T and BobTerm do: cursor keys wrapping round the screen, CLEAR, BACK S, TAB, EOL, delete and insert of lines and characters, tab stops, the buzzer, ESC to show a control's character, 0x80 up in inverse video. Keys and typing send ATASCII (CTRL with a letter its graphic, the key bar's INV key the next character inverse). The generator adds the two Atari sets, completing their control codes' glyphs from the screen-code mappings and drawing the two Unscii lacks. The tab stops move into the template for the C128 and the Atari alike, and a profile names its capture extension (.seq for the Commodores) instead of the session testing for one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B82eRSyCmXjaURxSYoHxCY --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
1 parent
2642a752a7
commit
a2a7d36688
20 files changed
+1885
-43
No files matched your search
@@ -12,4 +12,13 @@
|
||||
| Inconsolata.ttf | Inconsolata (variable, wght 200-900, wdth 50-200) | OFL 1.1 | google/fonts `ofl/inconsolata` |
|
||||
| DroidSansMono.ttf | Droid Sans Mono | Apache 2.0 | AOSP `platform/frameworks/base/data/fonts` |
|
||||
|
||||
The Commodore and Atari terminal types draw their characters from 8x8 bitmaps in the
|
||||
shared code (`shared/.../terminal/LegacyCharsets.kt`, written by
|
||||
`tools/gen_legacy_charsets.py`), not from a font file here: the glyphs are
|
||||
Unscii 2.1's `unscii-8` (public domain, http://viznut.fi/unscii/), and
|
||||
which character each code is comes from Rebecca Bettencourt's Legacy
|
||||
Computing mappings (`mappings/legacy` in kreativekorp/charset). The
|
||||
Atari's ESC and CLEAR symbols, which Unscii hasn't got, are drawn in the
|
||||
generator. No Commodore or Atari ROM font is shipped.
|
||||
|
||||
The licence texts are in `licenses/`; the app shows them (Settings, Font licences).
|
||||
@@ -260,7 +260,21 @@ class TerminalSession(
|
||||
val a = alt || this.alt.value
|
||||
val c = ctrl || this.ctrl.value
|
||||
releaseLatches()
|
||||
send(synchronized(emulator) { keys.key(k, emulator, shift, a, c) })
|
||||
sendTerminal(synchronized(emulator) { emulator.keyOctets(keys, k, shift, a, c) })
|
||||
}
|
||||
|
||||
/** a key's or a character's octets (the terminal's own, [TerminalEmulator.keyOctets]) to the modem, and on the screen with local echo */
|
||||
fun sendTerminal(b: ByteArray): Boolean {
|
||||
if (b.isEmpty()) return true
|
||||
if (transfer != null) return false
|
||||
if (localEcho) {
|
||||
synchronized(emulator) {
|
||||
// (a VT's Enter echoed as CR LF; a machine's own codes as they are)
|
||||
emulator.append(if (emulator.readsOctets) b else String(b, Charsets.ISO_8859_1).replace("\r", "\r\n").toByteArray(Charsets.ISO_8859_1))
|
||||
}
|
||||
onChange?.invoke()
|
||||
}
|
||||
return link.write(b)
|
||||
}
|
||||
|
||||
/** a character typed, with the latched modifiers and those held */
|
||||
@@ -268,7 +282,7 @@ class TerminalSession(
|
||||
val a = alt || this.alt.value
|
||||
val c = ctrl || this.ctrl.value
|
||||
releaseLatches()
|
||||
send(keys.char(cp, a, c))
|
||||
sendTerminal(synchronized(emulator) { emulator.charOctets(keys, cp, a, c) })
|
||||
}
|
||||
|
||||
/** text typed (the soft keyboard's): its first character takes the latched modifiers */
|
||||
@@ -350,7 +364,7 @@ class TerminalSession(
|
||||
val dir = captureDir() ?: return null
|
||||
dir.mkdirs()
|
||||
val name = "dmodem-" + SimpleDateFormat("yyyyMMdd-HHmmss", Locale.US).format(Date()) +
|
||||
if (charset == TermCharset.CP437) ".ans" else ".log"
|
||||
(emulator.profile.captureExtension ?: if (charset == TermCharset.CP437) ".ans" else ".log")
|
||||
val f = File(dir, name)
|
||||
return try {
|
||||
captureOut = FileOutputStream(f)
|
||||
|
||||
@@ -204,6 +204,11 @@ class TerminalView @JvmOverloads constructor(
|
||||
val down = max(fm.descent, ink.bottom.toFloat())
|
||||
cellH = floor(up + down + 0.5f).coerceAtLeast(1f)
|
||||
ascent = up
|
||||
// (a machine's 8x8 glyphs in square cells, as its screen had them; the font's text centred in them)
|
||||
if (fittedGlyphs) {
|
||||
cellH = floor(cellW + 0.5f).coerceAtLeast(1f)
|
||||
ascent = (cellH - (up + down)) / 2 + up
|
||||
}
|
||||
}
|
||||
|
||||
/** the cells measured again and the emulator fitted to the new size */
|
||||
@@ -218,7 +223,10 @@ class TerminalView @JvmOverloads constructor(
|
||||
val s = session ?: return
|
||||
if (width <= 0 || height <= 0) return
|
||||
val cols = max(1, (width / cellW).toInt())
|
||||
val rows = max(1, (height / cellH).toInt())
|
||||
val fit = max(1, (height / cellH).toInt())
|
||||
// (no more than the machine's screen had: a Commodore's 25)
|
||||
val asked = synchronized(s.emulator) { s.emulator.requestedRows }
|
||||
val rows = if (asked > 0) min(fit, asked) else fit
|
||||
s.resize(cols, rows)
|
||||
scrollRows = scrollRows.coerceIn(0, historySize())
|
||||
}
|
||||
@@ -243,12 +251,19 @@ class TerminalView @JvmOverloads constructor(
|
||||
/** the columns the remote asked for (DECCOLM) that the font is fitted to, 0 for none */
|
||||
private var fittedColumns = 0
|
||||
|
||||
/** the font fitted again if the remote asked for other columns (DECCOLM) */
|
||||
/** whether the cells are fitted to bitmap glyphs (square) */
|
||||
private var fittedGlyphs = false
|
||||
/** the rows the screen was fitted to at most, 0 for none */
|
||||
private var fittedRows = 0
|
||||
|
||||
/** the font fitted again if the remote asked for other columns (DECCOLM), or the profile for its own size and glyphs */
|
||||
private fun fitRequestedColumns() {
|
||||
val e = session?.emulator ?: return
|
||||
val asked = synchronized(e) { e.requestedColumns }
|
||||
if (asked == fittedColumns) return
|
||||
val (asked, glyphs, rows) = synchronized(e) { Triple(e.requestedColumns, e.glyphs != null, e.requestedRows) }
|
||||
if (asked == fittedColumns && glyphs == fittedGlyphs && rows == fittedRows) return
|
||||
fittedColumns = asked
|
||||
fittedGlyphs = glyphs
|
||||
fittedRows = rows
|
||||
measureFont()
|
||||
syncEmulator()
|
||||
resizeEmulator()
|
||||
@@ -422,6 +437,12 @@ class TerminalView @JvmOverloads constructor(
|
||||
flush(x + 1)
|
||||
continue
|
||||
}
|
||||
val g = drawing?.glyphs
|
||||
if (g != null && g.has(cp)) {
|
||||
flush(x + 1)
|
||||
drawGlyph(c, g.glyph(cp), px(x), y, px(x + 1) - px(x))
|
||||
continue
|
||||
}
|
||||
if (settings.drawBoxes && BoxDrawing.handles(cp)) {
|
||||
flush(x + 1)
|
||||
BoxDrawing.draw(c, cp, px(x), y, px(x + 1) - px(x), cellH, fillPaint)
|
||||
@@ -462,6 +483,23 @@ class TerminalView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
/** an 8x8 glyph filling the cell at ([left], [y]), [w] wide, in fillPaint's colour: each row's runs of pixels as one rectangle */
|
||||
private fun drawGlyph(c: Canvas, g: Long, left: Float, y: Float, w: Float) {
|
||||
for (r in 0 until 8) {
|
||||
val bits = org.dmodem.app.terminal.BitmapFont.row(g, r)
|
||||
if (bits == 0) continue
|
||||
val top = y + floor(r * cellH / 8)
|
||||
val bottom = y + floor((r + 1) * cellH / 8)
|
||||
var col = 0
|
||||
while (col < 8) {
|
||||
if (bits and (0x80 ushr col) == 0) { col++; continue }
|
||||
val start = col
|
||||
while (col < 8 && bits and (0x80 ushr col) != 0) col++
|
||||
c.drawRect(left + floor(start * w / 8), top, left + floor(col * w / 8), bottom, fillPaint)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val cluster = StringBuilder()
|
||||
private val wave = android.graphics.Path()
|
||||
|
||||
@@ -566,7 +604,11 @@ class TerminalView @JvmOverloads constructor(
|
||||
textPaint.color = theme.bgArgb
|
||||
textPaint.isFakeBoldText = false
|
||||
textPaint.textSkewX = 0f
|
||||
if (settings.drawBoxes && BoxDrawing.handles(cp)) {
|
||||
val g = e.glyphs
|
||||
if (g != null && g.has(cp)) {
|
||||
fillPaint.color = theme.bgArgb
|
||||
drawGlyph(c, g.glyph(cp), x, y, cw)
|
||||
} else if (settings.drawBoxes && BoxDrawing.handles(cp)) {
|
||||
fillPaint.color = theme.bgArgb
|
||||
BoxDrawing.draw(c, cp, x, y, cw, cellH, fillPaint)
|
||||
} else {
|
||||
|
||||
@@ -45,6 +45,7 @@ import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.luminance
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.input.pointer.pointerInput
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
@@ -554,8 +555,11 @@ private fun ExtraKeys(
|
||||
when (k) {
|
||||
is BarKey.Send -> KeyButton(k.label, repeat = k.repeat) { onKey(k.key) }
|
||||
is BarKey.Type -> KeyButton(k.label) { onText(k.text) }
|
||||
is BarKey.Octets -> KeyButton(k.label, swatch = k.color) {
|
||||
session.sendTerminal(k.octets.toByteArray(Charsets.ISO_8859_1))
|
||||
}
|
||||
BarKey.Ctrl -> KeyButton(k.label, latched = ctrl) { session.ctrl.value = !ctrl }
|
||||
BarKey.Alt -> KeyButton(k.label, latched = alt) { session.alt.value = !alt }
|
||||
is BarKey.Alt -> KeyButton(k.label, latched = alt) { session.alt.value = !alt }
|
||||
// (full screen: the first page's goes back out of it)
|
||||
BarKey.NextPage -> if (fullscreen && page == 0) {
|
||||
KeyButton("EXIT") { onExitFullscreen() }
|
||||
@@ -582,10 +586,20 @@ private fun androidx.compose.foundation.layout.RowScope.KeyButton(
|
||||
label: String,
|
||||
latched: Boolean = false,
|
||||
repeat: Boolean = false,
|
||||
swatch: Int? = null,
|
||||
onPress: () -> Unit,
|
||||
) {
|
||||
val bg = if (latched) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.surfaceVariant
|
||||
val fg = if (latched) MaterialTheme.colorScheme.onPrimary else MaterialTheme.colorScheme.onSurfaceVariant
|
||||
// (a colour key in its colour, its label in black or white, whichever shows)
|
||||
val bg = when {
|
||||
swatch != null -> androidx.compose.ui.graphics.Color(swatch)
|
||||
latched -> MaterialTheme.colorScheme.primary
|
||||
else -> MaterialTheme.colorScheme.surfaceVariant
|
||||
}
|
||||
val fg = when {
|
||||
swatch != null -> if (androidx.compose.ui.graphics.Color(swatch).luminance() > 0.4f) androidx.compose.ui.graphics.Color.Black else androidx.compose.ui.graphics.Color.White
|
||||
latched -> MaterialTheme.colorScheme.onPrimary
|
||||
else -> MaterialTheme.colorScheme.onSurfaceVariant
|
||||
}
|
||||
val scope = rememberCoroutineScope()
|
||||
Box(
|
||||
Modifier
|
||||
|
||||
+17
-1
@@ -40,7 +40,23 @@
|
||||
the keyboard LEDs and parameter reports, and a printer port (from the
|
||||
VT102 on) whose output is saved to a text file. The key bar gains the
|
||||
DEC keypad (PF1-PF4, digits, minus, comma, period, Enter, in numeric or
|
||||
application mode), and a hardware numpad sends those keys. Colour
|
||||
application mode), and a hardware numpad sends those keys. The
|
||||
Commodore types (C64, C128 in 40 or 80 columns, Plus/4, VIC-20, PET in
|
||||
40 or 80 columns) speak PETSCII as CCGMS and Novaterm do: the screen
|
||||
becomes the machine's (40x25, the VIC-20's 22x23) in its palette, drawn
|
||||
in square cells from 8x8 glyphs (Unscii's, public domain, not
|
||||
Commodore's ROMs), with both character sets, the colour and cursor
|
||||
codes, reverse, and the C128's ESC sequences, line feed, underline and
|
||||
flash. Typing and pasting are turned into PETSCII (CTRL and C= with a
|
||||
digit set colours, C= with a letter types its graphic), and the key bar
|
||||
has RUN/STOP, CLR/HOME, INST/DEL, RVS, F1-F8 and a page of colour keys.
|
||||
A capture is saved as a `.seq` file, and "Plain text" sends one back
|
||||
as it is. The Atari 8-bit types (ATASCII, with the graphics set or the
|
||||
XL's international one) give the screen editor's 40x24 in its blues,
|
||||
inverse video, its cursor keys wrapping round the screen, CLEAR, EOL,
|
||||
insert and delete of characters and lines, tabs, the buzzer and ESC to
|
||||
show a control's character; CTRL with a letter types its graphic and
|
||||
the key bar's INV key types the next character inverse. Colour
|
||||
themes (VGA, xterm, Solarized, Dracula, Monokai, Gruvbox, Nord, green
|
||||
and amber phosphor), fonts (Cascadia Code, Sauce Code Pro Nerd Font,
|
||||
Source Code Pro, Roboto Mono, JetBrains Mono, Fira Code, OpenDyslexic
|
||||
|
||||
@@ -30,9 +30,22 @@ final class TerminalModel: ObservableObject {
|
||||
/// the kind of terminal (a profile's id, as Settings keeps it under "terminalProfile")
|
||||
func setProfile(_ id: String) {
|
||||
bridge.profile = id
|
||||
glyphCache.removeAll()
|
||||
revision = bridge.revision
|
||||
}
|
||||
|
||||
/// the profile's glyphs, as they're asked for
|
||||
private var glyphCache: [UInt32: [Int]?] = [:]
|
||||
|
||||
/// the profile's 8x8 glyph for [cp]: its rows, top first, bit 7 the leftmost pixel; nil: drawn with the font
|
||||
func glyph(_ cp: UInt32) -> [Int]? {
|
||||
if let g = glyphCache[cp] { return g }
|
||||
let first = Int(bridge.glyphRow(cp: Int32(bitPattern: cp), row: 0))
|
||||
let g: [Int]? = first < 0 ? nil : [first] + (1..<8).map { Int(bridge.glyphRow(cp: Int32(bitPattern: cp), row: Int32($0))) }
|
||||
glyphCache[cp] = g
|
||||
return g
|
||||
}
|
||||
|
||||
var cols: Int { Int(bridge.cols) }
|
||||
var rows: Int { Int(bridge.rows) }
|
||||
|
||||
@@ -45,10 +58,11 @@ final class TerminalModel: ObservableObject {
|
||||
revision = bridge.revision
|
||||
}
|
||||
|
||||
/// text typed (the keyboard's), Ctrl if the sticky one is down
|
||||
/// text typed (the keyboard's), Ctrl and Alt (a Commodore's C=) if the sticky ones are down
|
||||
func typed(_ text: String) {
|
||||
out(bridge.typed(text: text, ctrl: ctrl, alt: false))
|
||||
out(bridge.typed(text: text, ctrl: ctrl, alt: alt))
|
||||
ctrl = false
|
||||
alt = false
|
||||
}
|
||||
|
||||
/// a key that isn't a character: UP, DOWN, LEFT, RIGHT, ESCAPE, TAB, BACKSPACE, ENTER, F1 ...
|
||||
|
||||
@@ -23,6 +23,9 @@ struct TerminalScreen: View {
|
||||
.onChange(of: fontSize) { _ in fit(geo.size, metrics(geo.size)) }
|
||||
// (the remote's DECCOLM: 80 or 132 columns fitted to the width)
|
||||
.onChange(of: model.bridge.requestedColumns) { _ in fit(geo.size, metrics(geo.size)) }
|
||||
// (a machine's own screen: its rows at most, square cells for its glyphs)
|
||||
.onChange(of: model.bridge.requestedRows) { _ in fit(geo.size, metrics(geo.size)) }
|
||||
.onChange(of: model.bridge.bitmapGlyphs) { _ in fit(geo.size, metrics(geo.size)) }
|
||||
.overlay(KeyInput(model: model, focused: $focused).frame(width: 1, height: 1).opacity(0.01), alignment: .topLeading)
|
||||
.contentShape(Rectangle())
|
||||
.onTapGesture { focused = true }
|
||||
@@ -36,15 +39,20 @@ struct TerminalScreen: View {
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
}
|
||||
|
||||
/// the cells: as many as the remote asked for (DECCOLM) across [size], else at the font size
|
||||
/// the cells: as many as the remote or the machine asked for (DECCOLM, a Commodore's 40) across [size], else at the font size; square for bitmap glyphs
|
||||
private func metrics(_ size: CGSize) -> CellMetrics {
|
||||
let asked = Int(model.bridge.requestedColumns)
|
||||
return asked > 0 && size.width > 0 ? CellMetrics(columns: asked, across: size.width) : CellMetrics(fontSize: fontSize)
|
||||
let m = asked > 0 && size.width > 0 ? CellMetrics(columns: asked, across: size.width) : CellMetrics(fontSize: fontSize)
|
||||
return model.bridge.bitmapGlyphs ? m.squared() : m
|
||||
}
|
||||
|
||||
/// as many cells as fit
|
||||
/// as many cells as fit (no more rows than the machine's screen had)
|
||||
private func fit(_ size: CGSize, _ cell: CellMetrics) {
|
||||
model.resize(cols: max(20, Int(size.width / cell.width)), rows: max(5, Int(size.height / cell.height)))
|
||||
let asked = Int(model.bridge.requestedColumns)
|
||||
let fitRows = max(5, Int(size.height / cell.height))
|
||||
let maxRows = Int(model.bridge.requestedRows)
|
||||
model.resize(cols: asked > 0 ? asked : max(20, Int(size.width / cell.width)),
|
||||
rows: maxRows > 0 ? min(fitRows, maxRows) : fitRows)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +69,16 @@ struct CellMetrics {
|
||||
height = ceil(font.lineHeight)
|
||||
}
|
||||
|
||||
/// a cell as given
|
||||
private init(font: UIFont, width: CGFloat, height: CGFloat) {
|
||||
self.font = font
|
||||
self.width = width
|
||||
self.height = height
|
||||
}
|
||||
|
||||
/// these cells made square (as tall as wide), for 8x8 glyphs
|
||||
func squared() -> CellMetrics { CellMetrics(font: font, width: width, height: width) }
|
||||
|
||||
/// the font size whose cells put [columns] across [width]
|
||||
init(columns: Int, across width: CGFloat) {
|
||||
let probe = UIFont.monospacedSystemFont(ofSize: 100, weight: .regular)
|
||||
@@ -97,6 +115,10 @@ private struct ScreenCanvas: View {
|
||||
let w = CGFloat(run.cells) * cell.width
|
||||
ctx.fill(Path(CGRect(x: x, y: y, width: w, height: cell.height)), with: .color(Color(argb: run.bg)))
|
||||
if run.text.trimmingCharacters(in: .whitespaces).isEmpty { continue }
|
||||
if model.bridge.bitmapGlyphs {
|
||||
drawGlyphs(ctx, run, y: y)
|
||||
continue
|
||||
}
|
||||
var t = Text(run.text).font(run.bold ? bold : regular).foregroundColor(Color(argb: run.fg))
|
||||
if run.italic { t = t.italic() }
|
||||
if run.underline { t = t.underline() }
|
||||
@@ -115,6 +137,32 @@ private struct ScreenCanvas: View {
|
||||
}
|
||||
}
|
||||
|
||||
extension ScreenCanvas {
|
||||
/// a run's characters one cell each from the profile's 8x8 glyphs (a pixel row's runs as one rectangle), the font's for one it hasn't
|
||||
func drawGlyphs(_ ctx: GraphicsContext, _ run: StyledRun, y: CGFloat) {
|
||||
let color = GraphicsContext.Shading.color(Color(argb: run.fg))
|
||||
for (i, ch) in run.text.unicodeScalars.enumerated() {
|
||||
let x = CGFloat(Int(run.col) + i) * cell.width
|
||||
guard let rows = model.glyph(ch.value) else {
|
||||
if ch != " " { ctx.draw(Text(String(ch)).font(Font(cell.font as CTFont)).foregroundColor(Color(argb: run.fg)), at: CGPoint(x: x, y: y), anchor: .topLeading) }
|
||||
continue
|
||||
}
|
||||
var path = Path()
|
||||
for (r, bits) in rows.enumerated() where bits != 0 {
|
||||
var c = 0
|
||||
while c < 8 {
|
||||
if bits & (0x80 >> c) == 0 { c += 1; continue }
|
||||
let start = c
|
||||
while c < 8 && bits & (0x80 >> c) != 0 { c += 1 }
|
||||
path.addRect(CGRect(x: x + CGFloat(start) * cell.width / 8, y: y + CGFloat(r) * cell.height / 8,
|
||||
width: CGFloat(c - start) * cell.width / 8, height: cell.height / 8))
|
||||
}
|
||||
}
|
||||
ctx.fill(path, with: color)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// the keys a phone's keyboard lacks, as the profile's key bar has them
|
||||
/// (the shared Kotlin's pages): Ctrl and Alt sticky, the last key the next page
|
||||
private struct ExtraKeys: View {
|
||||
@@ -143,6 +191,8 @@ private struct ExtraKeys: View {
|
||||
private func key(_ label: String, page p: Int, row: Int, col: Int, pages: Int) -> some View {
|
||||
let action = model.bridge.keyBarAction(page: Int32(p), row: Int32(row), col: Int32(col))
|
||||
let latched = (action == "ctrl" && model.ctrl) || (action == "alt" && model.alt) || (action == "next" && p != 0)
|
||||
// (a colour key shows its colour)
|
||||
let swatch = model.bridge.keyBarColor(page: Int32(p), row: Int32(row), col: Int32(col))
|
||||
return Button {
|
||||
switch action {
|
||||
case "ctrl": model.ctrl.toggle()
|
||||
@@ -155,7 +205,7 @@ private struct ExtraKeys: View {
|
||||
.minimumScaleFactor(0.6).frame(maxWidth: .infinity, minHeight: 30)
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
.tint(latched ? .accentColor : .secondary)
|
||||
.tint(swatch != 0 ? Color(argb: swatch) : latched ? .accentColor : .secondary)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// Copyright (C) 2026 Neo-Desktop
|
||||
package org.dmodem.app.terminal
|
||||
|
||||
/**
|
||||
* An Atari 400/800/XL/XE as a terminal (ATASCII), as Ice-T and BobTerm
|
||||
* are: the screen editor's 40x24 in GRAPHICS 0's two shades of one hue,
|
||||
* the ATASCII set (or the XL's international one), 0x80-0xff the same
|
||||
* characters in inverse video.
|
||||
*/
|
||||
open class AtariProfile : TerminalProfile(), ByteMachine {
|
||||
override val id get() = "atari"
|
||||
override val label get() = "Atari 8-bit"
|
||||
override val term get() = "atascii"
|
||||
override val telnetType get() = "ATASCII"
|
||||
override val glyphs: BitmapFont? get() = LegacyCharsets.GLYPHS
|
||||
|
||||
override val columns get() = 40
|
||||
override val rows get() = 24
|
||||
/** GRAPHICS 0: the background (COLOR2, $94) and the text in a lighter shade of its blue (COLOR1's luminance) */
|
||||
override val palette: IntArray get() = intArrayOf(0xff1d5dae.toInt(), 0xffa8d8ff.toInt())
|
||||
override val defaultColor get() = 1
|
||||
override val background get() = 0
|
||||
|
||||
/** the character set (0x00-0x7f's code points; 0x80-0xff are them reversed) */
|
||||
open val atasciiSet: IntArray get() = LegacyCharsets.ATARI_GRAPHICS
|
||||
|
||||
override val keyBar: List<KeyBarPage> get() = listOf(KeyBars.ATARI)
|
||||
|
||||
/** an [AtasciiInterpreter] */
|
||||
override fun interpreter(t: TerminalEmulator): TerminalInterpreter = AtasciiInterpreter(t, this)
|
||||
}
|
||||
|
||||
/** An Atari XL/XE with its international set (accented letters where the graphics were) */
|
||||
open class AtariInternationalProfile : AtariProfile() {
|
||||
override val id get() = "atari-intl"
|
||||
override val label get() = "Atari 8-bit (international)"
|
||||
override val atasciiSet: IntArray get() = LegacyCharsets.ATARI_INTERNATIONAL
|
||||
}
|
||||
|
||||
/**
|
||||
* The Atari's screen editor: its cursor keys (1C-1F, wrapping round the
|
||||
* screen, not scrolling), CLEAR (7D), BACK S (7E), TAB (7F), EOL (9B),
|
||||
* delete and insert line (9C, 9D) and character (FE, FF), tab stops (9E,
|
||||
* 9F), the buzzer (FD), and ESC to show the next code's character instead
|
||||
* of doing it. Any other code is a character, reversed from 0x80.
|
||||
*/
|
||||
open class AtasciiInterpreter(t: TerminalEmulator, private val m: AtariProfile) : ByteControlInterpreter(t, m) {
|
||||
/** an ESC came: the next code is shown, not done */
|
||||
private var literal = false
|
||||
|
||||
/** as at the start: no ESC pending */
|
||||
override fun reset() {
|
||||
super.reset()
|
||||
literal = false
|
||||
}
|
||||
|
||||
/** an octet: shown after an ESC, else done if it is a control, else shown */
|
||||
override fun process(cp: Int) {
|
||||
if (literal) {
|
||||
literal = false
|
||||
show(cp)
|
||||
return
|
||||
}
|
||||
if (!control(cp)) show(cp)
|
||||
}
|
||||
|
||||
/** code [b]'s character, reversed from 0x80 */
|
||||
private fun show(b: Int) {
|
||||
val inverse = b >= 0x80
|
||||
if (inverse != reverse) reverseTo(inverse)
|
||||
put(charOf(b))
|
||||
}
|
||||
|
||||
/** code [b]'s character (a reversed one's plain one) */
|
||||
override fun charOf(b: Int): Int = m.atasciiSet[b and 0x7f]
|
||||
|
||||
/** the screen editor's control codes: true if [b] was one */
|
||||
override fun control(b: Int): Boolean {
|
||||
when (b) {
|
||||
0x1b -> literal = true
|
||||
0x1c -> t.moveCursor(t.cursorX, if (t.cursorY == 0) t.rows - 1 else t.cursorY - 1)
|
||||
0x1d -> t.moveCursor(t.cursorX, if (t.cursorY == t.rows - 1) 0 else t.cursorY + 1)
|
||||
0x1e -> t.moveCursor(if (t.cursorX == 0) t.cols - 1 else t.cursorX - 1, t.cursorY)
|
||||
0x1f -> t.moveCursor(if (t.cursorX == t.cols - 1) 0 else t.cursorX + 1, t.cursorY)
|
||||
0x7d -> clear()
|
||||
0x7e -> backSpace()
|
||||
0x7f -> tab()
|
||||
0x9b -> newLine()
|
||||
0x9c -> t.deleteLines(1)
|
||||
0x9d -> t.insertLines(1)
|
||||
0x9e -> tabStop(false)
|
||||
0x9f -> tabStop(true)
|
||||
0xfd -> bell()
|
||||
0xfe -> t.deleteChars(1)
|
||||
0xff -> insertBlank()
|
||||
else -> return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/** BACK S: the cursor left, the character there blanked (the rest of the line stays) */
|
||||
private fun backSpace() {
|
||||
if (t.cursorX == 0) return
|
||||
t.moveCursor(t.cursorX - 1, t.cursorY)
|
||||
t.style = Style.erased(look())
|
||||
t.eraseChars(1)
|
||||
t.style = look()
|
||||
}
|
||||
|
||||
/** an Atari's keys: the cursor keys, RETURN as EOL, BACK S, DELETE and INSERT (with SHIFT the line), TAB, ESC, SHIFT+HOME as CLEAR */
|
||||
override fun keyOctets(k: Key, shift: Boolean, alt: Boolean, ctrl: Boolean): ByteArray? {
|
||||
val b = when (k) {
|
||||
Key.UP -> 0x1c
|
||||
Key.DOWN -> 0x1d
|
||||
Key.LEFT -> 0x1e
|
||||
Key.RIGHT -> 0x1f
|
||||
Key.ENTER, Key.KP_ENTER -> 0x9b
|
||||
Key.BACKSPACE -> if (shift) 0x9c else 0x7e
|
||||
Key.DELETE -> if (shift) 0x9c else 0xfe
|
||||
Key.INSERT -> if (shift) 0x9d else 0xff
|
||||
Key.TAB -> if (shift) 0x9f else 0x7f
|
||||
Key.ESCAPE -> 0x1b
|
||||
Key.HOME -> if (shift) 0x7d else return ByteArray(0)
|
||||
in Key.KP_0..Key.KP_9 -> '0'.code + (k.ordinal - Key.KP_0.ordinal)
|
||||
Key.KP_MINUS -> '-'.code
|
||||
Key.KP_COMMA -> ','.code
|
||||
Key.KP_PERIOD -> '.'.code
|
||||
else -> return ByteArray(0)
|
||||
}
|
||||
return byteArrayOf(b.toByte())
|
||||
}
|
||||
|
||||
/** a character typed or pasted as its ATASCII code, reversed with the inverse key (Alt) */
|
||||
override fun charOctets(cp: Int, alt: Boolean, ctrl: Boolean): ByteArray? {
|
||||
val b = code(cp, ctrl) ?: return ByteArray(0)
|
||||
// (the inverse key, as Alt: the character reversed)
|
||||
return byteArrayOf((if (alt && b !in CONTROLS) b or 0x80 else b).toByte())
|
||||
}
|
||||
|
||||
/** what the keyboard sends for [cp], with CTRL its graphic */
|
||||
private fun code(cp: Int, ctrl: Boolean): Int? {
|
||||
if (ctrl) {
|
||||
val upper = if (cp in 'a'.code..'z'.code) cp - 32 else cp
|
||||
when {
|
||||
upper in 'A'.code..'Z'.code -> return upper - '@'.code
|
||||
cp == ','.code -> return 0x00
|
||||
cp == '.'.code -> return 0x60
|
||||
cp == ';'.code -> return 0x7b
|
||||
}
|
||||
}
|
||||
return when (cp) {
|
||||
'\r'.code, '\n'.code -> 0x9b
|
||||
0x08, 0x7f -> 0x7e
|
||||
0x1b -> 0x1b
|
||||
else -> codeIn(m.atasciiSet, cp, 0x20..0x7c) ?: codeIn(m.atasciiSet, cp, 0x00..0x1a) ?: '?'.code
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
/** the codes that are the editor's controls, not characters */
|
||||
private val CONTROLS = setOf(0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x7d, 0x7e, 0x7f, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, 0xfd, 0xfe, 0xff)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// Copyright (C) 2026 Neo-Desktop
|
||||
package org.dmodem.app.terminal
|
||||
|
||||
/**
|
||||
* Glyphs drawn from bitmaps rather than a font: 8x8 cells, a code point's
|
||||
* eight rows packed in a Long (the top row in the high byte, its leftmost
|
||||
* pixel the byte's high bit). What a profile whose terminal had its own
|
||||
* character ROM (Commodore's, Atari's) draws its cells with.
|
||||
*/
|
||||
class BitmapFont(private val codes: IntArray, private val bits: LongArray) {
|
||||
/** the glyphs it has */
|
||||
val size: Int get() = codes.size
|
||||
|
||||
/** whether it has [cp]'s glyph */
|
||||
fun has(cp: Int): Boolean = index(cp) >= 0
|
||||
|
||||
/** [cp]'s glyph (0 if it has none: a blank) */
|
||||
fun glyph(cp: Int): Long {
|
||||
val i = index(cp)
|
||||
return if (i >= 0) bits[i] else 0L
|
||||
}
|
||||
|
||||
/** [cp]'s place in [codes] (they're in order), -1 if it isn't there */
|
||||
private fun index(cp: Int): Int {
|
||||
var lo = 0
|
||||
var hi = codes.size - 1
|
||||
while (lo <= hi) {
|
||||
val mid = (lo + hi) ushr 1
|
||||
val c = codes[mid]
|
||||
when {
|
||||
c < cp -> lo = mid + 1
|
||||
c > cp -> hi = mid - 1
|
||||
else -> return mid
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
companion object {
|
||||
/** whether row [row] (0 top) of glyph [g] has pixel [col] (0 left) set */
|
||||
fun pixel(g: Long, row: Int, col: Int): Boolean = (g ushr ((7 - row) * 8 + (7 - col))) and 1L != 0L
|
||||
|
||||
/** row [row] (0 top) of glyph [g], its leftmost pixel the high bit */
|
||||
fun row(g: Long, row: Int): Int = ((g ushr ((7 - row) * 8)) and 0xff).toInt()
|
||||
|
||||
/** "CP:ROWS;" entries (hex: the code point, then the 16 digits of its rows), in code point order */
|
||||
fun parse(s: String): BitmapFont {
|
||||
val entries = s.split(';').filter { it.isNotEmpty() }
|
||||
val codes = IntArray(entries.size)
|
||||
val bits = LongArray(entries.size)
|
||||
for ((i, e) in entries.withIndex()) {
|
||||
val colon = e.indexOf(':')
|
||||
codes[i] = e.substring(0, colon).toInt(16)
|
||||
bits[i] = e.substring(colon + 1).toULong(16).toLong()
|
||||
}
|
||||
return BitmapFont(codes, bits)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// Copyright (C) 2026 Neo-Desktop
|
||||
package org.dmodem.app.terminal
|
||||
|
||||
/**
|
||||
* What a home computer's screen editor was, as a terminal: octets read
|
||||
* as they come (the machine's own character set, not the user's), each
|
||||
* either one of its control codes or a character of its current set,
|
||||
* written in its colour and reverse. The machines (Commodore's PETSCII,
|
||||
* Atari's ATASCII) each give their codes and sets; what they share is
|
||||
* here: the screen's size and palette set on the emulator while it's
|
||||
* theirs, a wrap as soon as the last column is written (no deferred
|
||||
* wrap), cursor keys that wrap round the line ends, delete and insert
|
||||
* within the line, and typing turned back into the set's codes.
|
||||
*/
|
||||
abstract class ByteControlInterpreter(t: TerminalEmulator, private val machine: ByteMachine) : TerminalInterpreter(t) {
|
||||
/** the colour (an index of the machine's palette) the characters are written in */
|
||||
protected var color = machine.defaultColor
|
||||
/** the characters written reversed */
|
||||
protected var reverse = false
|
||||
/** the attributes the machine adds (a C128's underline and flash) */
|
||||
protected var extraAttrs = 0
|
||||
|
||||
init {
|
||||
attach()
|
||||
}
|
||||
|
||||
override val readsOctets: Boolean get() = true
|
||||
|
||||
/** the machine's size and palette on the emulator */
|
||||
private fun attach() {
|
||||
t.requestedColumns = machine.columns
|
||||
t.requestedRows = machine.rows
|
||||
t.autowrap = true
|
||||
val p = machine.palette
|
||||
for (i in p.indices) t.setColorOverride(i, p[i])
|
||||
t.setColorOverride(256, p[machine.defaultColor])
|
||||
t.setColorOverride(257, p[machine.background])
|
||||
t.style = look()
|
||||
}
|
||||
|
||||
/** the view's size and the theme's colours back, for the profile taking over */
|
||||
override fun detach() {
|
||||
t.requestedColumns = 0
|
||||
t.requestedRows = 0
|
||||
t.resetColors(0..257)
|
||||
t.style = Style.NORMAL
|
||||
}
|
||||
|
||||
/** the machine as it starts: its colour, no reverse, the tab stops, its screen and palette */
|
||||
override fun reset() {
|
||||
color = machine.defaultColor
|
||||
reverse = false
|
||||
extraAttrs = 0
|
||||
resetTabs()
|
||||
attach()
|
||||
}
|
||||
|
||||
/** reverse and the machine's attributes off */
|
||||
override fun softReset() {
|
||||
reverse = false
|
||||
extraAttrs = 0
|
||||
t.style = look()
|
||||
}
|
||||
|
||||
/** an octet: one of the machine's control codes, else a character of its set */
|
||||
override fun process(cp: Int) {
|
||||
if (control(cp)) return
|
||||
val c = charOf(cp)
|
||||
if (c != 0) put(c)
|
||||
}
|
||||
|
||||
/** octet [b] as one of the machine's control codes: true if it was one (and done) */
|
||||
protected abstract fun control(b: Int): Boolean
|
||||
|
||||
/** octet [b] as a character of the current set (its code point), 0 for none */
|
||||
protected abstract fun charOf(b: Int): Int
|
||||
|
||||
/** what's written now looks like: the colour, reverse, the machine's attributes */
|
||||
protected fun look(): Long =
|
||||
Style.of(color, Style.DEFAULT_BG, (if (reverse) Style.INVERSE else 0) or extraAttrs)
|
||||
|
||||
/** the colour written in from now on */
|
||||
protected fun colorTo(c: Int) {
|
||||
color = c
|
||||
t.style = look()
|
||||
}
|
||||
|
||||
/** reverse on or off from now on */
|
||||
protected fun reverseTo(on: Boolean) {
|
||||
reverse = on
|
||||
t.style = look()
|
||||
}
|
||||
|
||||
/** [a] on or off among the machine's attributes from now on */
|
||||
protected fun attrTo(a: Int, on: Boolean) {
|
||||
extraAttrs = if (on) extraAttrs or a else extraAttrs and a.inv()
|
||||
t.style = look()
|
||||
}
|
||||
|
||||
/** character [cp] written at the cursor, the cursor to the next cell (past the last column: the next line's start) */
|
||||
protected fun put(cp: Int) {
|
||||
t.style = look()
|
||||
t.print(cp)
|
||||
if (t.pendingWrap) newLine(wrapped = true)
|
||||
}
|
||||
|
||||
/** the cursor to the next line's start, the screen scrolled at the bottom ([wrapped]: the line runs on into it) */
|
||||
protected fun newLine(wrapped: Boolean = false) {
|
||||
if (wrapped) t.line(t.cursorY).wrapped = true
|
||||
t.carriageReturn()
|
||||
t.index()
|
||||
}
|
||||
|
||||
/** the cursor up a line (at the top: stays) */
|
||||
protected fun up() {
|
||||
t.moveCursor(t.cursorX, t.cursorY - 1)
|
||||
}
|
||||
|
||||
/** the cursor down a line (at the bottom: the screen scrolls) */
|
||||
protected fun down() {
|
||||
val x = t.cursorX
|
||||
t.index()
|
||||
t.moveCursor(x, t.cursorY)
|
||||
}
|
||||
|
||||
/** the cursor left (at a line's start: the end of the one above, at home it stays) */
|
||||
protected fun left() {
|
||||
when {
|
||||
t.cursorX > 0 -> t.moveCursor(t.cursorX - 1, t.cursorY)
|
||||
t.cursorY > 0 -> t.moveCursor(t.cols - 1, t.cursorY - 1)
|
||||
}
|
||||
}
|
||||
|
||||
/** the cursor right (at a line's end: the next one's start, scrolling at the bottom) */
|
||||
protected fun right() {
|
||||
if (t.cursorX < t.cols - 1) t.moveCursor(t.cursorX + 1, t.cursorY) else newLine()
|
||||
}
|
||||
|
||||
/** the cursor home, top left */
|
||||
protected fun home() {
|
||||
t.moveCursor(0, 0)
|
||||
}
|
||||
|
||||
/** the screen cleared, the cursor home */
|
||||
protected fun clear() {
|
||||
t.style = Style.erased(look())
|
||||
t.eraseDisplay(2)
|
||||
home()
|
||||
t.style = look()
|
||||
}
|
||||
|
||||
/** the character left of the cursor deleted, the rest of the line pulled left (at a line's start: the one above's last) */
|
||||
protected fun deleteBack() {
|
||||
if (t.cursorX == 0 && t.cursorY == 0) return
|
||||
left()
|
||||
t.style = Style.erased(look())
|
||||
t.deleteChars(1)
|
||||
t.style = look()
|
||||
}
|
||||
|
||||
/** a blank at the cursor, the rest of the line pushed right */
|
||||
protected fun insertBlank() {
|
||||
t.style = Style.erased(look())
|
||||
t.insertChars(1)
|
||||
t.style = look()
|
||||
}
|
||||
|
||||
/** the tab stops (every eighth column to begin with) */
|
||||
protected val tabs = BooleanArray(256) { it % 8 == 0 && it > 0 }
|
||||
|
||||
/** the cursor to the next tab stop (the line's last column if none) */
|
||||
protected fun tab() {
|
||||
var x = t.cursorX + 1
|
||||
while (x < t.cols - 1 && !tabs[x]) x++
|
||||
t.moveCursor(x.coerceAtMost(t.cols - 1), t.cursorY)
|
||||
}
|
||||
|
||||
/** a tab stop at the cursor's column set or cleared */
|
||||
protected fun tabStop(on: Boolean) {
|
||||
if (t.cursorX in tabs.indices) tabs[t.cursorX] = on
|
||||
}
|
||||
|
||||
/** the tab stops back to every eighth column ([every]: true), or all cleared */
|
||||
protected fun resetTabs(every: Boolean = true) {
|
||||
for (i in tabs.indices) tabs[i] = every && i % 8 == 0 && i > 0
|
||||
}
|
||||
|
||||
/** the bell */
|
||||
protected fun bell() {
|
||||
t.listener?.onBell()
|
||||
}
|
||||
|
||||
/** code point [cp] as the first code in [codes] of set [set] (256 code points, 0 for none) that has it; null if none does */
|
||||
protected fun codeIn(set: IntArray, cp: Int, codes: IntRange = set.indices): Int? {
|
||||
for (b in codes) if (set[b] == cp) return b
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The machine a [ByteControlInterpreter] is: its screen's size and its
|
||||
* palette (ARGB, in its own colour order), the colour it writes in and
|
||||
* the background at the start.
|
||||
*/
|
||||
interface ByteMachine {
|
||||
val columns: Int
|
||||
val rows: Int
|
||||
val palette: IntArray
|
||||
val defaultColor: Int
|
||||
val background: Int
|
||||
}
|
||||
@@ -0,0 +1,338 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// Copyright (C) 2026 Neo-Desktop
|
||||
package org.dmodem.app.terminal
|
||||
|
||||
/**
|
||||
* A Commodore 8-bit as a terminal (PETSCII): the C64 and the machines
|
||||
* around it, each a subclass changing only what its machine had (a
|
||||
* VIC-20's narrow screen and fewer colours, a C128's escape sequences, its
|
||||
* 80-column chip's palette and underline, a PET's green screen and no
|
||||
* colours, a Plus/4's flash). They share [PetsciiInterpreter].
|
||||
*/
|
||||
abstract class CommodoreProfile : TerminalProfile(), ByteMachine {
|
||||
override val term get() = "petscii"
|
||||
override val telnetType get() = "PETSCII"
|
||||
override val glyphs: BitmapFont? get() = LegacyCharsets.GLYPHS
|
||||
override val captureExtension: String? get() = ".seq"
|
||||
|
||||
override val columns get() = 40
|
||||
override val rows get() = 25
|
||||
/** light blue on black, as the terminal programs start (the C64 itself starts light blue on blue) */
|
||||
override val defaultColor get() = 14
|
||||
override val background get() = 0
|
||||
|
||||
/** the character sets: upper case and graphics, lower and upper case (256 code points each, 0 none) */
|
||||
open val upperSet: IntArray get() = LegacyCharsets.C64_UPPER
|
||||
open val lowerSet: IntArray get() = LegacyCharsets.C64_LOWER
|
||||
|
||||
/** CTRL 1-8's colour codes (colours 0-7) */
|
||||
open val ctrlColors: List<Int> get() = listOf(0x90, 0x05, 0x1c, 0x9f, 0x9c, 0x1e, 0x1f, 0x9e)
|
||||
/** C= 1-8's (colours 8-15), none on a machine without them */
|
||||
open val cbmColors: List<Int> get() = listOf(0x81, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b)
|
||||
|
||||
/** whether ESC starts one of the C128's and Plus/4's editor sequences */
|
||||
open val escapes: Boolean get() = false
|
||||
/** the codes that turn an attribute on and off ([Style] bits): a C128's underline and flash */
|
||||
open val attrCodes: Map<Int, Pair<Int, Boolean>> get() = emptyMap()
|
||||
/** whether TAB (09) and LF (0A) are the C128's tab and line feed, not the C64's case lock and nothing */
|
||||
open val tabAndLineFeed: Boolean get() = false
|
||||
|
||||
/** the colour codes and the colours they set */
|
||||
val colorCodes: Map<Int, Int> by lazy {
|
||||
(ctrlColors.mapIndexed { i, c -> c to i } + cbmColors.mapIndexed { i, c -> c to 8 + i }).toMap()
|
||||
}
|
||||
|
||||
override val keyBar: List<KeyBarPage> by lazy {
|
||||
listOf(KeyBars.COMMODORE_MAIN, KeyBars.COMMODORE_FUNCTION) +
|
||||
(if (ctrlColors.isEmpty()) emptyList() else listOf(KeyBars.commodoreColors(palette, ctrlColors, cbmColors)))
|
||||
}
|
||||
|
||||
/** a [PetsciiInterpreter] for this machine */
|
||||
override fun interpreter(t: TerminalEmulator): TerminalInterpreter = PetsciiInterpreter(t, this)
|
||||
}
|
||||
|
||||
/** The palettes (ARGB, in the VIC-II's colour order unless said otherwise). */
|
||||
object CommodorePalettes {
|
||||
/** Philip Timmermann's "Pepto" measurements of the VIC-II */
|
||||
val PEPTO = argb(
|
||||
0x000000, 0xffffff, 0x68372b, 0x70a4b2, 0x6f3d86, 0x588d43, 0x352879, 0xb8c76f,
|
||||
0x6f4f25, 0x433900, 0x9a6759, 0x444444, 0x6c6c6c, 0x9ad284, 0x6c5eb5, 0x959595,
|
||||
)
|
||||
|
||||
/** Pepto's later "Colodore" */
|
||||
val COLODORE = argb(
|
||||
0x000000, 0xffffff, 0x813338, 0x75cec8, 0x8e3c97, 0x56ac4d, 0x2e2c9b, 0xedf171,
|
||||
0x8e5029, 0x553800, 0xc46c71, 0x4a4a4a, 0x7b7b7b, 0xa9ff9f, 0x706deb, 0xb2b2b2,
|
||||
)
|
||||
|
||||
/** the VIC-20's VIC chip: eight colours, then the eight lighter ones only its background and border had */
|
||||
val VIC20 = argb(
|
||||
0x000000, 0xffffff, 0xb61f21, 0x4df0ff, 0xb43fff, 0x44e237, 0x1a34ff, 0xdcd71b,
|
||||
0xca5400, 0xe9b072, 0xe79293, 0x9af7fd, 0xe09fff, 0x8fe493, 0x8290ff, 0xe5de85,
|
||||
)
|
||||
|
||||
/** the C128's VDC (RGBI), each VIC-II colour as the 80-column screen shows it */
|
||||
val VDC: IntArray = run {
|
||||
val rgbi = intArrayOf(
|
||||
0x000000, 0x555555, 0x0000aa, 0x5555ff, 0x00aa00, 0x55ff55, 0x00aaaa, 0x55ffff,
|
||||
0xaa0000, 0xff5555, 0xaa00aa, 0xff55ff, 0xaa5500, 0xffff55, 0xaaaaaa, 0xffffff,
|
||||
)
|
||||
// (the C128 editor's table: the VIC-II's colour numbers to the VDC's)
|
||||
val vicToVdc = intArrayOf(0, 15, 8, 7, 11, 4, 2, 13, 10, 12, 9, 1, 6, 5, 3, 14)
|
||||
IntArray(16) { 0xff000000.toInt() or rgbi[vicToVdc[it]] }
|
||||
}
|
||||
|
||||
/** the Plus/4's TED: the colour codes' sixteen colours, near what its default luminances give */
|
||||
val TED = argb(
|
||||
0x000000, 0xffffff, 0x9c3e3e, 0x5ab5b5, 0x9f4ba8, 0x5aa33e, 0x5250c4, 0xb5b54a,
|
||||
0xa36a2b, 0x7d5a1b, 0x85a33e, 0xc7637a, 0x3ea383, 0x6a8cd9, 0x4f5fb3, 0x7ec26b,
|
||||
)
|
||||
|
||||
/** a PET's phosphor: dark, then its green */
|
||||
val PET_GREEN = argb(0x000000, 0x41ff00)
|
||||
|
||||
/** 0xRRGGBB values as opaque ARGB */
|
||||
private fun argb(vararg rgb: Int): IntArray = IntArray(rgb.size) { 0xff000000.toInt() or rgb[it] }
|
||||
}
|
||||
|
||||
/** Commodore 64: 40x25, 16 colours, the screen editor's control codes */
|
||||
open class C64Profile : CommodoreProfile() {
|
||||
override val id get() = "c64"
|
||||
override val label get() = "Commodore 64"
|
||||
override val palette: IntArray get() = CommodorePalettes.PEPTO
|
||||
}
|
||||
|
||||
/** Commodore 128 in 40 columns: a C64 with the editor's ESC sequences, TAB, LF and the bell */
|
||||
open class C128Profile : C64Profile() {
|
||||
override val id get() = "c128"
|
||||
override val label get() = "Commodore 128 (40 col.)"
|
||||
override val escapes get() = true
|
||||
override val tabAndLineFeed get() = true
|
||||
}
|
||||
|
||||
/** Commodore 128 in 80 columns (the VDC): RGBI colours, underline and flash */
|
||||
open class C128VdcProfile : C128Profile() {
|
||||
override val id get() = "c128-80"
|
||||
override val label get() = "Commodore 128 (80 col.)"
|
||||
override val columns get() = 80
|
||||
override val palette: IntArray get() = CommodorePalettes.VDC
|
||||
override val attrCodes: Map<Int, Pair<Int, Boolean>> get() = mapOf(
|
||||
0x02 to (Style.UNDERLINE to true), 0x82 to (Style.UNDERLINE to false),
|
||||
0x0f to (Style.BLINK to true), 0x8f to (Style.BLINK to false),
|
||||
)
|
||||
}
|
||||
|
||||
/** Commodore Plus/4 and C16: a C64's codes with the TED's colours, flash, and the C128's ESC sequences */
|
||||
open class Plus4Profile : C64Profile() {
|
||||
override val id get() = "plus4"
|
||||
override val label get() = "Commodore Plus/4"
|
||||
override val palette: IntArray get() = CommodorePalettes.TED
|
||||
override val escapes get() = true
|
||||
override val attrCodes: Map<Int, Pair<Int, Boolean>> get() = mapOf(
|
||||
0x82 to (Style.BLINK to true), 0x84 to (Style.BLINK to false),
|
||||
)
|
||||
}
|
||||
|
||||
/** VIC-20: 22x23, eight colours for characters, its own sets */
|
||||
open class Vic20Profile : C64Profile() {
|
||||
override val id get() = "vic20"
|
||||
override val label get() = "Commodore VIC-20"
|
||||
override val columns get() = 22
|
||||
override val rows get() = 23
|
||||
override val palette: IntArray get() = CommodorePalettes.VIC20
|
||||
override val defaultColor get() = 1
|
||||
override val upperSet: IntArray get() = LegacyCharsets.VIC_UPPER
|
||||
override val lowerSet: IntArray get() = LegacyCharsets.VIC_LOWER
|
||||
override val cbmColors: List<Int> get() = emptyList()
|
||||
}
|
||||
|
||||
/** Commodore PET (40 columns): green on black, no colours, its own sets */
|
||||
open class PetProfile : CommodoreProfile() {
|
||||
override val id get() = "pet"
|
||||
override val label get() = "Commodore PET (40 col.)"
|
||||
override val palette: IntArray get() = CommodorePalettes.PET_GREEN
|
||||
override val defaultColor get() = 1
|
||||
override val upperSet: IntArray get() = LegacyCharsets.PET_UPPER
|
||||
override val lowerSet: IntArray get() = LegacyCharsets.PET_LOWER
|
||||
override val ctrlColors: List<Int> get() = emptyList()
|
||||
override val cbmColors: List<Int> get() = emptyList()
|
||||
}
|
||||
|
||||
/** Commodore PET 8032: a PET with 80 columns */
|
||||
open class Pet80Profile : PetProfile() {
|
||||
override val id get() = "pet80"
|
||||
override val label get() = "Commodore PET (80 col.)"
|
||||
override val columns get() = 80
|
||||
}
|
||||
|
||||
/**
|
||||
* The PETSCII screen editor, as CCGMS and Novaterm have it: the colour
|
||||
* codes, the cursor keys (11 91 1D 9D), HOME, CLR, DEL, INST, RVS on and
|
||||
* off, the two character sets (0E lower case, 8E upper), RETURN and its
|
||||
* shifted one ending reverse, the bell; on a C128 or Plus/4 its ESC
|
||||
* sequences (window, insert and delete line, scrolling, erasing). Quote
|
||||
* mode is the editor's, not a terminal's, so there's none.
|
||||
*/
|
||||
open class PetsciiInterpreter(t: TerminalEmulator, private val m: CommodoreProfile) : ByteControlInterpreter(t, m) {
|
||||
/** the lower and upper case set (0E), not the upper case and graphics one (8E) */
|
||||
var lowerCase = false
|
||||
private set
|
||||
/** the octet after an ESC, on a machine with the sequences */
|
||||
private var esc = false
|
||||
|
||||
private val set: IntArray get() = if (lowerCase) m.lowerSet else m.upperSet
|
||||
|
||||
/** as at the start: the upper case and graphics set, no ESC pending */
|
||||
override fun reset() {
|
||||
super.reset()
|
||||
lowerCase = false
|
||||
esc = false
|
||||
}
|
||||
|
||||
/** octet [b] in the set in use */
|
||||
override fun charOf(b: Int): Int = set[b]
|
||||
|
||||
/** the colour, attribute, cursor, editing and set codes, and ESC sequences on the machines with them */
|
||||
override fun control(b: Int): Boolean {
|
||||
if (esc) {
|
||||
esc = false
|
||||
escape(b)
|
||||
return true
|
||||
}
|
||||
m.colorCodes[b]?.let { colorTo(it); return true }
|
||||
m.attrCodes[b]?.let { (a, on) -> attrTo(a, on); return true }
|
||||
when (b) {
|
||||
0x07 -> bell()
|
||||
0x09 -> if (m.tabAndLineFeed) tab()
|
||||
0x0a -> if (m.tabAndLineFeed) down()
|
||||
0x0d, 0x8d -> {
|
||||
newLine()
|
||||
reverseTo(false)
|
||||
}
|
||||
0x0e -> lowerCase = true
|
||||
0x8e -> lowerCase = false
|
||||
0x11 -> down()
|
||||
0x91 -> up()
|
||||
0x1d -> right()
|
||||
0x9d -> left()
|
||||
0x12 -> reverseTo(true)
|
||||
0x92 -> reverseTo(false)
|
||||
0x13 -> home()
|
||||
0x93 -> clear()
|
||||
0x14 -> deleteBack()
|
||||
0x94 -> insertBlank()
|
||||
0x1b -> esc = m.escapes
|
||||
// (the rest of 00-1F and 80-9F: nothing; the case lock, the function keys' codes)
|
||||
else -> return b < 0x20 || b in 0x80..0x9f
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
/** ESC [c]: the C128 editor's (and the Plus/4's) */
|
||||
private fun escape(c: Int) {
|
||||
when (c.toChar()) {
|
||||
'@' -> t.eraseDisplay(0)
|
||||
'A' -> t.insertMode = true
|
||||
'C' -> t.insertMode = false
|
||||
'D' -> t.deleteLines(1)
|
||||
'I' -> t.insertLines(1)
|
||||
'J' -> t.moveCursor(0, t.cursorY)
|
||||
'K' -> t.moveCursor(endOfLine(), t.cursorY)
|
||||
'O' -> {
|
||||
t.insertMode = false
|
||||
reverseTo(false)
|
||||
}
|
||||
'P' -> t.eraseLine(1)
|
||||
'Q' -> t.eraseLine(0)
|
||||
'T' -> t.setRegion(t.cursorY, t.bottom)
|
||||
'B' -> t.setRegion(t.top, t.cursorY)
|
||||
'V' -> t.scrollUp(t.top, t.bottom)
|
||||
'W' -> t.scrollDown(t.top, t.bottom)
|
||||
'N' -> t.reverseVideo = false
|
||||
'R' -> t.reverseVideo = true
|
||||
'Y' -> resetTabs()
|
||||
'Z' -> resetTabs(every = false)
|
||||
}
|
||||
}
|
||||
|
||||
/** the column after the line's last character (its last column if it's full) */
|
||||
private fun endOfLine(): Int {
|
||||
val l = t.line(t.cursorY)
|
||||
var x = t.cols - 1
|
||||
while (x > 0 && (l.chars[x] == 0 || l.chars[x] == ' '.code)) x--
|
||||
return (x + 1).coerceAtMost(t.cols - 1)
|
||||
}
|
||||
|
||||
/** a Commodore's keys: the cursor keys, HOME and CLR, INST and DEL, RETURN, RUN/STOP, F1-F8 (none for the others) */
|
||||
override fun keyOctets(k: Key, shift: Boolean, alt: Boolean, ctrl: Boolean): ByteArray? {
|
||||
val b = when (k) {
|
||||
Key.UP -> 0x91
|
||||
Key.DOWN -> 0x11
|
||||
Key.LEFT -> 0x9d
|
||||
Key.RIGHT -> 0x1d
|
||||
Key.HOME -> if (shift) 0x93 else 0x13
|
||||
Key.INSERT -> 0x94
|
||||
Key.BACKSPACE, Key.DELETE -> if (shift) 0x94 else 0x14
|
||||
Key.ENTER, Key.KP_ENTER -> if (shift) 0x8d else 0x0d
|
||||
Key.ESCAPE -> 0x03
|
||||
Key.TAB -> 0x09
|
||||
Key.F1 -> 0x85
|
||||
Key.F3 -> 0x86
|
||||
Key.F5 -> 0x87
|
||||
Key.F7 -> 0x88
|
||||
Key.F2 -> 0x89
|
||||
Key.F4 -> 0x8a
|
||||
Key.F6 -> 0x8b
|
||||
Key.F8 -> 0x8c
|
||||
in Key.KP_0..Key.KP_9 -> '0'.code + (k.ordinal - Key.KP_0.ordinal)
|
||||
Key.KP_MINUS -> '-'.code
|
||||
Key.KP_COMMA -> ','.code
|
||||
Key.KP_PERIOD -> '.'.code
|
||||
else -> return ByteArray(0)
|
||||
}
|
||||
return byteArrayOf(b.toByte())
|
||||
}
|
||||
|
||||
/** a character typed or pasted as its PETSCII code (nothing for none) */
|
||||
override fun charOctets(cp: Int, alt: Boolean, ctrl: Boolean): ByteArray? {
|
||||
val b = code(cp, alt, ctrl) ?: return ByteArray(0)
|
||||
return byteArrayOf(b.toByte())
|
||||
}
|
||||
|
||||
/** what the keyboard sends for [cp] with C= ([alt]) or CTRL: a colour, a graphic, a control code, the set's character */
|
||||
private fun code(cp: Int, alt: Boolean, ctrl: Boolean): Int? {
|
||||
val upper = if (cp in 'a'.code..'z'.code) cp - 32 else cp
|
||||
if (ctrl) {
|
||||
when (cp) {
|
||||
in '1'.code..'8'.code -> return m.ctrlColors.getOrNull(cp - '1'.code)
|
||||
'9'.code -> return 0x12
|
||||
'0'.code -> return 0x92
|
||||
}
|
||||
if (upper in 'A'.code..'Z'.code) return upper - '@'.code
|
||||
}
|
||||
if (alt) {
|
||||
if (cp in '1'.code..'8'.code) return m.cbmColors.getOrNull(cp - '1'.code)
|
||||
if (upper in 'A'.code..'Z'.code) return CBM_GRAPHICS[upper - 'A'.code]
|
||||
}
|
||||
return when {
|
||||
cp == '\r'.code || cp == '\n'.code -> 0x0d
|
||||
cp == 0x08 || cp == 0x7f -> 0x14
|
||||
cp == 0x1b -> 0x03
|
||||
// letters: unshifted in the graphics set (what its keyboard sends), cased in the other
|
||||
cp in 'a'.code..'z'.code -> cp - 32
|
||||
cp in 'A'.code..'Z'.code -> if (lowerCase) cp + 0x80 else cp
|
||||
cp == '^'.code -> 0x5e
|
||||
cp == '_'.code -> 0x5f
|
||||
// (a shifted or C= graphic's code over its copy at 60-7F and E0-FE)
|
||||
else -> codeIn(set, cp, 0x20..0x5f) ?: codeIn(set, cp, 0xa0..0xdf) ?: codeIn(set, cp) ?: '?'.code
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
/** C= and A-Z: the graphics on the keys' left fronts */
|
||||
private val CBM_GRAPHICS = intArrayOf(
|
||||
0xb0, 0xbf, 0xbc, 0xac, 0xb1, 0xbb, 0xa5, 0xb4, 0xa2, 0xb5, 0xa1, 0xb6, 0xa7,
|
||||
0xaa, 0xb9, 0xaf, 0xab, 0xb2, 0xae, 0xa3, 0xb8, 0xbe, 0xb3, 0xbd, 0xb7, 0xad,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -22,10 +22,11 @@ sealed class BarKey {
|
||||
override val label get() = "CTRL"
|
||||
}
|
||||
|
||||
/** Alt, down for the next key */
|
||||
data object Alt : BarKey() {
|
||||
override val label get() = "ALT"
|
||||
}
|
||||
/** Alt, down for the next key (a Commodore's C= key) */
|
||||
data class Alt(override val label: String = "ALT") : BarKey()
|
||||
|
||||
/** octets sent as they are (Latin-1, one character each): a machine's own codes ([color]: the swatch it shows, ARGB) */
|
||||
data class Octets(val octets: String, override val label: String, val color: Int? = null) : BarKey()
|
||||
|
||||
/** to the next page (from the last, the first): shown as that page's name */
|
||||
data object NextPage : BarKey() {
|
||||
@@ -48,7 +49,7 @@ object KeyBars {
|
||||
BarKey.Type("|"),
|
||||
),
|
||||
listOf(
|
||||
BarKey.Send(Key.TAB, "TAB"), BarKey.Ctrl, BarKey.Alt, BarKey.Send(Key.LEFT, "←", repeat = true),
|
||||
BarKey.Send(Key.TAB, "TAB"), BarKey.Ctrl, BarKey.Alt(), BarKey.Send(Key.LEFT, "←", repeat = true),
|
||||
BarKey.Send(Key.DOWN, "↓", repeat = true), BarKey.Send(Key.RIGHT, "→", repeat = true),
|
||||
BarKey.Send(Key.PAGE_DOWN, "PGDN"), BarKey.NextPage,
|
||||
),
|
||||
@@ -82,6 +83,67 @@ object KeyBars {
|
||||
),
|
||||
)
|
||||
|
||||
/** a Commodore's: RUN/STOP, CLR/HOME, INST/DEL, RVS ON/OFF, C=, the cursor keys, its symbols */
|
||||
val COMMODORE_MAIN = KeyBarPage(
|
||||
"C=",
|
||||
listOf(
|
||||
listOf(
|
||||
BarKey.Octets("\u0003", "STOP"), BarKey.Octets("\u0093", "CLR"), BarKey.Send(Key.HOME, "HOME"),
|
||||
BarKey.Send(Key.UP, "↑", repeat = true), BarKey.Send(Key.INSERT, "INST"), BarKey.Octets("\u0012", "RVS"),
|
||||
BarKey.Octets("\u0092", "OFF"), BarKey.Type("£"),
|
||||
),
|
||||
listOf(
|
||||
BarKey.Ctrl, BarKey.Alt("C="), BarKey.Send(Key.LEFT, "←", repeat = true), BarKey.Send(Key.DOWN, "↓", repeat = true),
|
||||
BarKey.Send(Key.RIGHT, "→", repeat = true), BarKey.Type("↑", "^"), BarKey.Type("←", "_"), BarKey.NextPage,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
/** F1-F8 (F2, F4, F6, F8 the shifted ones) and DEL */
|
||||
val COMMODORE_FUNCTION = KeyBarPage(
|
||||
"F1",
|
||||
listOf(
|
||||
listOf(fn(0), fn(2), fn(4), fn(6), BarKey.Send(Key.BACKSPACE, "DEL", repeat = true)),
|
||||
listOf(fn(1), fn(3), fn(5), fn(7), BarKey.NextPage),
|
||||
),
|
||||
)
|
||||
|
||||
/** the colours, CTRL 1-8 and C= 1-8, each key showing its colour on [palette] (16 ARGB, the machine's order) */
|
||||
fun commodoreColors(palette: IntArray, ctrlCodes: List<Int>, cbmCodes: List<Int>): KeyBarPage {
|
||||
/** the key for colour code [code], colour [i] */
|
||||
fun key(code: Int, i: Int) = BarKey.Octets(code.toChar().toString(), COMMODORE_COLOR_NAMES[i], palette[i])
|
||||
return KeyBarPage(
|
||||
"COL",
|
||||
listOf(
|
||||
ctrlCodes.mapIndexed { i, c -> key(c, i) },
|
||||
cbmCodes.mapIndexed { i, c -> key(c, 8 + i) } + BarKey.NextPage,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
/** the 16 colours' short names, in the machines' order */
|
||||
private val COMMODORE_COLOR_NAMES = listOf(
|
||||
"BLK", "WHT", "RED", "CYN", "PUR", "GRN", "BLU", "YEL",
|
||||
"ORN", "BRN", "LRD", "DGY", "GRY", "LGN", "LBL", "LGY",
|
||||
)
|
||||
|
||||
/** an Atari's: ESC, CLEAR, INSERT and DELETE (character, and with SHIFT the line), BACK S, TAB, the inverse key, CTRL for the graphics */
|
||||
val ATARI = KeyBarPage(
|
||||
"ATR",
|
||||
listOf(
|
||||
listOf(
|
||||
BarKey.Send(Key.ESCAPE, "ESC"), BarKey.Octets("\u007d", "CLR"), BarKey.Send(Key.INSERT, "INS"),
|
||||
BarKey.Send(Key.UP, "↑", repeat = true), BarKey.Send(Key.DELETE, "DEL", repeat = true),
|
||||
BarKey.Octets("\u009d", "INS LN"), BarKey.Octets("\u009c", "DEL LN"),
|
||||
),
|
||||
listOf(
|
||||
BarKey.Send(Key.TAB, "TAB"), BarKey.Ctrl, BarKey.Alt("INV"), BarKey.Send(Key.LEFT, "←", repeat = true),
|
||||
BarKey.Send(Key.DOWN, "↓", repeat = true), BarKey.Send(Key.RIGHT, "→", repeat = true),
|
||||
BarKey.Send(Key.BACKSPACE, "BK S", repeat = true),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
/** the bar most terminals have: the main keys and the function keys */
|
||||
val STANDARD = listOf(MAIN, FUNCTION)
|
||||
|
||||
|
||||
@@ -0,0 +1,358 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// Copyright (C) 2026 Neo-Desktop
|
||||
// Generated by tools/gen_legacy_charsets.py: don't edit by hand.
|
||||
package org.dmodem.app.terminal
|
||||
|
||||
/**
|
||||
* The 8-bit home computers' character sets, each code (0x00..0xff) as its
|
||||
* Unicode code point (0: not a character), from Rebecca Bettencourt's
|
||||
* Legacy Computing mappings; and [GLYPHS], an 8x8 glyph for every one of
|
||||
* them, from Unscii (public domain; the two it hasn't, the Atari's ESC
|
||||
* and CLEAR symbols, drawn in the generator).
|
||||
*/
|
||||
internal object LegacyCharsets {
|
||||
/** Commodore 64/128 and Plus/4, upper case and graphics (c64ipri.txt) */
|
||||
val C64_UPPER: IntArray = intArrayOf(
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
||||
0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x5A, 0x5B, 0xA3, 0x5D, 0x2191, 0x2190,
|
||||
0x2500, 0x2660, 0x1FB72, 0x1FB78, 0x1FB77, 0x1FB76, 0x1FB7A, 0x1FB71,
|
||||
0x1FB74, 0x256E, 0x2570, 0x256F, 0x1FB7C, 0x2572, 0x2571, 0x1FB7D,
|
||||
0x1FB7E, 0x2022, 0x1FB7B, 0x2665, 0x1FB70, 0x256D, 0x2573, 0x25CB,
|
||||
0x2663, 0x1FB75, 0x2666, 0x253C, 0x1FB8C, 0x2502, 0x3C0, 0x25E5,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0xA0, 0x258C, 0x2584, 0x2594, 0x2581, 0x258F, 0x2592, 0x2595,
|
||||
0x1FB8F, 0x25E4, 0x1FB87, 0x251C, 0x2597, 0x2514, 0x2510, 0x2582,
|
||||
0x250C, 0x2534, 0x252C, 0x2524, 0x258E, 0x258D, 0x1FB88, 0x1FB82,
|
||||
0x1FB83, 0x2583, 0x1FB7F, 0x2596, 0x259D, 0x2518, 0x2598, 0x259A,
|
||||
0x2500, 0x2660, 0x1FB72, 0x1FB78, 0x1FB77, 0x1FB76, 0x1FB7A, 0x1FB71,
|
||||
0x1FB74, 0x256E, 0x2570, 0x256F, 0x1FB7C, 0x2572, 0x2571, 0x1FB7D,
|
||||
0x1FB7E, 0x2022, 0x1FB7B, 0x2665, 0x1FB70, 0x256D, 0x2573, 0x25CB,
|
||||
0x2663, 0x1FB75, 0x2666, 0x253C, 0x1FB8C, 0x2502, 0x3C0, 0x25E5,
|
||||
0xA0, 0x258C, 0x2584, 0x2594, 0x2581, 0x258F, 0x2592, 0x2595,
|
||||
0x1FB8F, 0x25E4, 0x1FB87, 0x251C, 0x2597, 0x2514, 0x2510, 0x2582,
|
||||
0x250C, 0x2534, 0x252C, 0x2524, 0x258E, 0x258D, 0x1FB88, 0x1FB82,
|
||||
0x1FB83, 0x2583, 0x1FB7F, 0x2596, 0x259D, 0x2518, 0x2598, 0x259A,
|
||||
)
|
||||
|
||||
/** Commodore 64/128 and Plus/4, lower and upper case (c64ialt.txt) */
|
||||
val C64_LOWER: IntArray = intArrayOf(
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
||||
0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
|
||||
0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
|
||||
0x78, 0x79, 0x7A, 0x5B, 0xA3, 0x5D, 0x2191, 0x2190,
|
||||
0x2500, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x5A, 0x253C, 0x1FB8C, 0x2502, 0x1FB96, 0x1FB98,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0xA0, 0x258C, 0x2584, 0x2594, 0x2581, 0x258F, 0x2592, 0x2595,
|
||||
0x1FB8F, 0x1FB99, 0x1FB87, 0x251C, 0x2597, 0x2514, 0x2510, 0x2582,
|
||||
0x250C, 0x2534, 0x252C, 0x2524, 0x258E, 0x258D, 0x1FB88, 0x1FB82,
|
||||
0x1FB83, 0x2583, 0x2713, 0x2596, 0x259D, 0x2518, 0x2598, 0x259A,
|
||||
0x2500, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x5A, 0x253C, 0x1FB8C, 0x2502, 0x1FB96, 0x1FB98,
|
||||
0xA0, 0x258C, 0x2584, 0x2594, 0x2581, 0x258F, 0x2592, 0x2595,
|
||||
0x1FB8F, 0x1FB99, 0x1FB87, 0x251C, 0x2597, 0x2514, 0x2510, 0x2582,
|
||||
0x250C, 0x2534, 0x252C, 0x2524, 0x258E, 0x258D, 0x1FB88, 0x1FB82,
|
||||
0x1FB83, 0x2583, 0x2713, 0x2596, 0x259D, 0x2518, 0x2598, 0x259A,
|
||||
)
|
||||
|
||||
/** VIC-20, upper case and graphics (cvicipri.txt) */
|
||||
val VIC_UPPER: IntArray = intArrayOf(
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
||||
0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x5A, 0x5B, 0xA3, 0x5D, 0x2191, 0x2190,
|
||||
0x2500, 0x2660, 0x1FB72, 0x1FB78, 0x1FB77, 0x1FB76, 0x1FB7A, 0x1FB71,
|
||||
0x1FB74, 0x256E, 0x2570, 0x256F, 0x1FB7C, 0x2572, 0x2571, 0x1FB7D,
|
||||
0x1FB7E, 0x2022, 0x1FB7B, 0x2665, 0x1FB70, 0x256D, 0x2573, 0x25CB,
|
||||
0x2663, 0x1FB75, 0x2666, 0x253C, 0x1FB8C, 0x2502, 0x3C0, 0x25E5,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0xA0, 0x258C, 0x2584, 0x2594, 0x2581, 0x258F, 0x2592, 0x2595,
|
||||
0x1FB8F, 0x25E4, 0x1FB87, 0x251C, 0x2597, 0x2514, 0x2510, 0x2582,
|
||||
0x250C, 0x2534, 0x252C, 0x2524, 0x258E, 0x258D, 0x1FB88, 0x1FB82,
|
||||
0x1FB83, 0x2583, 0x1FB7F, 0x2596, 0x259D, 0x2518, 0x2598, 0x259A,
|
||||
0x2500, 0x2660, 0x1FB72, 0x1FB78, 0x1FB77, 0x1FB76, 0x1FB7A, 0x1FB71,
|
||||
0x1FB74, 0x256E, 0x2570, 0x256F, 0x1FB7C, 0x2572, 0x2571, 0x1FB7D,
|
||||
0x1FB7E, 0x2022, 0x1FB7B, 0x2665, 0x1FB70, 0x256D, 0x2573, 0x25CB,
|
||||
0x2663, 0x1FB75, 0x2666, 0x253C, 0x1FB8C, 0x2502, 0x3C0, 0x25E5,
|
||||
0xA0, 0x258C, 0x2584, 0x2594, 0x2581, 0x258F, 0x2592, 0x2595,
|
||||
0x1FB8F, 0x25E4, 0x1FB87, 0x251C, 0x2597, 0x2514, 0x2510, 0x2582,
|
||||
0x250C, 0x2534, 0x252C, 0x2524, 0x258E, 0x258D, 0x1FB88, 0x1FB82,
|
||||
0x1FB83, 0x2583, 0x1FB7F, 0x2596, 0x259D, 0x2518, 0x2598, 0x259A,
|
||||
)
|
||||
|
||||
/** VIC-20, lower and upper case (cvicialt.txt) */
|
||||
val VIC_LOWER: IntArray = intArrayOf(
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
||||
0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
|
||||
0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
|
||||
0x78, 0x79, 0x7A, 0x5B, 0xA3, 0x5D, 0x2191, 0x2190,
|
||||
0x2500, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x5A, 0x253C, 0x1FB8C, 0x2502, 0x1FB95, 0x1FB98,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0xA0, 0x258C, 0x2584, 0x2594, 0x2581, 0x258F, 0x2592, 0x2595,
|
||||
0x1FB8F, 0x1FB99, 0x1FB87, 0x251C, 0x2597, 0x2514, 0x2510, 0x2582,
|
||||
0x250C, 0x2534, 0x252C, 0x2524, 0x258E, 0x258D, 0x1FB88, 0x1FB82,
|
||||
0x1FB83, 0x2583, 0x2713, 0x2596, 0x259D, 0x2518, 0x2598, 0x259A,
|
||||
0x2500, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x5A, 0x253C, 0x1FB8C, 0x2502, 0x1FB95, 0x1FB98,
|
||||
0xA0, 0x258C, 0x2584, 0x2594, 0x2581, 0x258F, 0x2592, 0x2595,
|
||||
0x1FB8F, 0x1FB99, 0x1FB87, 0x251C, 0x2597, 0x2514, 0x2510, 0x2582,
|
||||
0x250C, 0x2534, 0x252C, 0x2524, 0x258E, 0x258D, 0x1FB88, 0x1FB82,
|
||||
0x1FB83, 0x2583, 0x2713, 0x2596, 0x259D, 0x2518, 0x2598, 0x259A,
|
||||
)
|
||||
|
||||
/** PET, upper case and graphics (cpetipri.txt) */
|
||||
val PET_UPPER: IntArray = intArrayOf(
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
||||
0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x2191, 0x2190,
|
||||
0x2500, 0x2660, 0x1FB72, 0x1FB78, 0x1FB77, 0x1FB76, 0x1FB7A, 0x1FB71,
|
||||
0x1FB74, 0x256E, 0x2570, 0x256F, 0x1FB7C, 0x2572, 0x2571, 0x1FB7D,
|
||||
0x1FB7E, 0x2022, 0x1FB7B, 0x2665, 0x1FB70, 0x256D, 0x2573, 0x25CB,
|
||||
0x2663, 0x1FB75, 0x2666, 0x253C, 0x1FB8C, 0x2502, 0x3C0, 0x25E5,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0xA0, 0x258C, 0x2584, 0x2594, 0x2581, 0x258F, 0x2592, 0x2595,
|
||||
0x1FB8F, 0x25E4, 0x1FB87, 0x251C, 0x2597, 0x2514, 0x2510, 0x2582,
|
||||
0x250C, 0x2534, 0x252C, 0x2524, 0x258E, 0x258D, 0x1FB88, 0x1FB82,
|
||||
0x1FB83, 0x2583, 0x1FB7F, 0x2596, 0x259D, 0x2518, 0x2598, 0x259A,
|
||||
0x2500, 0x2660, 0x1FB72, 0x1FB78, 0x1FB77, 0x1FB76, 0x1FB7A, 0x1FB71,
|
||||
0x1FB74, 0x256E, 0x2570, 0x256F, 0x1FB7C, 0x2572, 0x2571, 0x1FB7D,
|
||||
0x1FB7E, 0x2022, 0x1FB7B, 0x2665, 0x1FB70, 0x256D, 0x2573, 0x25CB,
|
||||
0x2663, 0x1FB75, 0x2666, 0x253C, 0x1FB8C, 0x2502, 0x3C0, 0x25E5,
|
||||
0xA0, 0x258C, 0x2584, 0x2594, 0x2581, 0x258F, 0x2592, 0x2595,
|
||||
0x1FB8F, 0x25E4, 0x1FB87, 0x251C, 0x2597, 0x2514, 0x2510, 0x2582,
|
||||
0x250C, 0x2534, 0x252C, 0x2524, 0x258E, 0x258D, 0x1FB88, 0x1FB82,
|
||||
0x1FB83, 0x2583, 0x1FB7F, 0x2596, 0x259D, 0x2518, 0x2598, 0x259A,
|
||||
)
|
||||
|
||||
/** PET, lower and upper case (cpetialt.txt) */
|
||||
val PET_LOWER: IntArray = intArrayOf(
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
||||
0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
|
||||
0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
|
||||
0x78, 0x79, 0x7A, 0x5B, 0x5C, 0x5D, 0x2191, 0x2190,
|
||||
0x2500, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x5A, 0x253C, 0x1FB8C, 0x2502, 0x1FB95, 0x1FB98,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0xA0, 0x258C, 0x2584, 0x2594, 0x2581, 0x258F, 0x2592, 0x2595,
|
||||
0x1FB8F, 0x1FB99, 0x1FB87, 0x251C, 0x2597, 0x2514, 0x2510, 0x2582,
|
||||
0x250C, 0x2534, 0x252C, 0x2524, 0x258E, 0x258D, 0x1FB88, 0x1FB82,
|
||||
0x1FB83, 0x2583, 0x2713, 0x2596, 0x259D, 0x2518, 0x2598, 0x259A,
|
||||
0x2500, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x5A, 0x253C, 0x1FB8C, 0x2502, 0x1FB95, 0x1FB98,
|
||||
0xA0, 0x258C, 0x2584, 0x2594, 0x2581, 0x258F, 0x2592, 0x2595,
|
||||
0x1FB8F, 0x1FB99, 0x1FB87, 0x251C, 0x2597, 0x2514, 0x2510, 0x2582,
|
||||
0x250C, 0x2534, 0x252C, 0x2524, 0x258E, 0x258D, 0x1FB88, 0x1FB82,
|
||||
0x1FB83, 0x2583, 0x2713, 0x2596, 0x259D, 0x2518, 0x2598, 0x259A,
|
||||
)
|
||||
|
||||
/** Atari 8-bit ATASCII, the graphics set (0x80-0xff: 0x00-0x7f reversed) (atari8ig.txt) */
|
||||
val ATARI_GRAPHICS: IntArray = intArrayOf(
|
||||
0x2665, 0x251C, 0x23B9, 0x2518, 0x2524, 0x2510, 0x2571, 0x2572,
|
||||
0x25E2, 0x2597, 0x25E3, 0x259D, 0x2598, 0x23BA, 0x23BD, 0x2596,
|
||||
0x2663, 0x250C, 0x2500, 0x253C, 0x2022, 0x2584, 0x23B8, 0x252C,
|
||||
0x2534, 0x258C, 0x2514, 0x241B, 0x2191, 0x2193, 0x2190, 0x2192,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
||||
0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
|
||||
0x2666, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
|
||||
0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
|
||||
0x78, 0x79, 0x7A, 0x2660, 0x7C, 0x1F8B0, 0x25C0, 0x25B6,
|
||||
0x2665, 0x251C, 0x23B9, 0x2518, 0x2524, 0x2510, 0x2571, 0x2572,
|
||||
0x25E2, 0x2597, 0x25E3, 0x259D, 0x2598, 0x23BA, 0x23BD, 0x2596,
|
||||
0x2663, 0x250C, 0x2500, 0x253C, 0x2022, 0x2584, 0x23B8, 0x252C,
|
||||
0x2534, 0x258C, 0x2514, 0x241B, 0x2191, 0x2193, 0x2190, 0x2192,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
||||
0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
|
||||
0x2666, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
|
||||
0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
|
||||
0x78, 0x79, 0x7A, 0x2660, 0x7C, 0x1F8B0, 0x25C0, 0x25B6,
|
||||
)
|
||||
|
||||
/** Atari 8-bit ATASCII, the international set (0x80-0xff: 0x00-0x7f reversed) (atari8ii.txt) */
|
||||
val ATARI_INTERNATIONAL: IntArray = intArrayOf(
|
||||
0xE1, 0xF9, 0xD1, 0xC9, 0xE7, 0xF4, 0xF2, 0xEC,
|
||||
0xA3, 0xEF, 0xFC, 0xE4, 0xD6, 0xFA, 0xF3, 0xF6,
|
||||
0xDC, 0xE2, 0xFB, 0xEE, 0xE9, 0xE8, 0xF1, 0xEA,
|
||||
0xE5, 0xE0, 0xC5, 0x241B, 0x2191, 0x2193, 0x2190, 0x2192,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
||||
0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
|
||||
0xA1, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
|
||||
0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
|
||||
0x78, 0x79, 0x7A, 0xC4, 0x7C, 0x1F8B0, 0x25C0, 0x25B6,
|
||||
0xE1, 0xF9, 0xD1, 0xC9, 0xE7, 0xF4, 0xF2, 0xEC,
|
||||
0xA3, 0xEF, 0xFC, 0xE4, 0xD6, 0xFA, 0xF3, 0xF6,
|
||||
0xDC, 0xE2, 0xFB, 0xEE, 0xE9, 0xE8, 0xF1, 0xEA,
|
||||
0xE5, 0xE0, 0xC5, 0x241B, 0x2191, 0x2193, 0x2190, 0x2192,
|
||||
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
|
||||
0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
|
||||
0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
|
||||
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
|
||||
0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F,
|
||||
0xA1, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
|
||||
0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
|
||||
0x78, 0x79, 0x7A, 0xC4, 0x7C, 0x1F8B0, 0x25C0, 0x25B6,
|
||||
)
|
||||
|
||||
/** the glyphs: each code point (hex) and its eight rows (top first, high bit leftmost) */
|
||||
val GLYPHS: BitmapFont = BitmapFont.parse(
|
||||
"20:0000000000000000;21:1818181818001800;22:6666660000000000;23:6C6CFE6CFE6C6C00;" +
|
||||
"24:183E603C067C1800;25:00C6CC183066C600;26:386C3876DCCC7600;27:1818300000000000;" +
|
||||
"28:0C18303030180C00;29:30180C0C0C183000;2A:00663CFF3C660000;2B:0018187E18180000;" +
|
||||
"2C:0000000000181830;2D:0000007E00000000;2E:0000000000181800;2F:03060C183060C000;" +
|
||||
"30:3C666E7666663C00;31:1838181818187E00;32:3C660C1830607E00;33:3C66061C06663C00;" +
|
||||
"34:1C3C6CCCFE0C0C00;35:7E607C0606663C00;36:1C30607C66663C00;37:7E06060C18181800;" +
|
||||
"38:3C66663C66663C00;39:3C66663E060C3800;3A:0018180000181800;3B:0018180000181830;" +
|
||||
"3C:0C18306030180C00;3D:00007E007E000000;3E:6030180C18306000;3F:3C66060C18001800;" +
|
||||
"40:7CC6DEDEDEC07C00;41:183C66667E666600;42:7C66667C66667C00;43:3C66606060663C00;" +
|
||||
"44:786C6666666C7800;45:7E60607C60607E00;46:7E60607C60606000;47:3C66606E66663E00;" +
|
||||
"48:6666667E66666600;49:7E18181818187E00;4A:0606060606663C00;4B:C6CCD8F0D8CCC600;" +
|
||||
"4C:6060606060607E00;4D:C6EEFED6C6C6C600;4E:C6E6F6DECEC6C600;4F:3C66666666663C00;" +
|
||||
"50:7C66667C60606000;51:3C666666666C3600;52:7C66667C6C666600;53:3C66603C06663C00;" +
|
||||
"54:7E18181818181800;55:6666666666663C00;56:66666666663C1800;57:C6C6C6D6FEEEC600;" +
|
||||
"58:C3663C183C66C300;59:C3663C1818181800;5A:7E060C1830607E00;5B:3C30303030303C00;" +
|
||||
"5C:C06030180C060300;5D:3C0C0C0C0C0C3C00;5E:10386CC600000000;5F:00000000000000FF;" +
|
||||
"60:180C060000000000;61:00003C063E663E00;62:60607C6666667C00;63:00003C6060603C00;" +
|
||||
"64:06063E6666663E00;65:00003C667E603C00;66:1C307C3030303000;67:00003E66663E067C;" +
|
||||
"68:60607C6666666600;69:1800381818181E00;6A:0C000C0C0C0C0C78;6B:6060666C786C6600;" +
|
||||
"6C:3818181818181E00;6D:0000CCFED6D6C600;6E:00007C6666666600;6F:00003C6666663C00;" +
|
||||
"70:00007C66667C6060;71:00003E66663E0606;72:00007C6660606000;73:00003E603C067C00;" +
|
||||
"74:30307E3030301E00;75:0000666666663E00;76:00006666663C1800;77:0000C6C6D67C6C00;" +
|
||||
"78:0000C66C386CC600;79:00006666663E063C;7A:00007E0C18307E00;7B:0E18187018180E00;" +
|
||||
"7C:1818181818181800;7D:7018180E18187000;7E:76DC000000000000;A0:0000000000000000;" +
|
||||
"A1:1800181818181800;A3:386C60F06066FC00;C4:66003C667E666600;C5:1818003C667E6600;" +
|
||||
"C9:0E00FEC0F8C0FE00;D1:76DC00C6F6DEC600;D6:66007CC6C6C67C00;DC:6600C6C6C6C67C00;" +
|
||||
"E0:70003C063E663E00;E1:0E003C063E663E00;E2:1866003E66C67E00;E4:66003C063E663E00;" +
|
||||
"E5:1818003E66C67E00;E7:00003C6060603C18;E8:70003C667E603C00;E9:0E003C667E603C00;" +
|
||||
"EA:1866003C7E603C00;EC:7000381818183C00;EE:1866003818183C00;EF:6600381818183C00;" +
|
||||
"F1:76DC007C66666600;F2:70003C6666663C00;F3:0E003C6666663C00;F4:1866003C66663C00;" +
|
||||
"F6:66003C6666663C00;F9:7000666666663E00;FA:0E00666666663E00;FB:1866006666663E00;" +
|
||||
"FC:6600666666663E00;3C0:0000FF6666666600;2022:0000183C3C180000;2190:0010307F7F301000;" +
|
||||
"2191:183C7E1818181818;2192:00080CFEFE0C0800;2193:18181818187E3C18;23B8:C0C0C0C0C0C0C0C0;" +
|
||||
"23B9:0303030303030303;23BA:FFFF000000000000;23BD:0000000000FFFF00;241B:007E605048444200;" +
|
||||
"2500:000000FFFF000000;2502:1818181818181818;250C:0000001F1F181818;2510:000000F8F8181818;" +
|
||||
"2514:1818181F1F000000;2518:181818F8F8000000;251C:1818181F1F181818;2524:181818F8F8181818;" +
|
||||
"252C:000000FFFF181818;2534:181818FFFF000000;253C:181818FFFF181818;256D:000000070F1C1818;" +
|
||||
"256E:000000E0F0381818;256F:181838F0E0000000;2570:18181C0F07000000;2571:03060C183060C080;" +
|
||||
"2572:C06030180C060301;2573:C3663C183C66C381;2581:00000000000000FF;2582:000000000000FFFF;" +
|
||||
"2583:0000000000FFFFFF;2584:00000000FFFFFFFF;258C:F0F0F0F0F0F0F0F0;258D:E0E0E0E0E0E0E0E0;" +
|
||||
"258E:C0C0C0C0C0C0C0C0;258F:8080808080808080;2592:AA55AA55AA55AA55;2594:FF00000000000000;" +
|
||||
"2595:0101010101010101;2596:00000000F0F0F0F0;2597:000000000F0F0F0F;2598:F0F0F0F000000000;" +
|
||||
"259A:F0F0F0F00F0F0F0F;259D:0F0F0F0F00000000;25B6:C0F0FCFFFFFCF0C0;25C0:030F3FFFFF3F0F03;" +
|
||||
"25CB:003C664242663C00;25E2:0103070F1F3F7FFF;25E3:80C0E0F0F8FCFEFF;25E4:FFFEFCF8F0E0C080;" +
|
||||
"25E5:FF7F3F1F0F070301;2660:10387CFEFE387C00;2663:1818666618183C00;2665:6CFEFEFE7C381000;" +
|
||||
"2666:10387CFE7C381000;2713:02060CD8F0E0C000;1F8B0:0078605048040200;1FB70:6060606060606060;" +
|
||||
"1FB71:3030303030303030;1FB72:1818181818181818;1FB74:0C0C0C0C0C0C0C0C;1FB75:0606060606060606;" +
|
||||
"1FB76:00FFFF0000000000;1FB77:0000FFFF00000000;1FB78:000000FFFF000000;1FB7A:00000000FFFF0000;" +
|
||||
"1FB7B:0000000000FFFF00;1FB7C:C0C0C0C0C0C0C0FF;1FB7D:FFC0C0C0C0C0C0C0;1FB7E:FF03030303030303;" +
|
||||
"1FB7F:03030303030303FF;1FB82:FFFF000000000000;1FB83:FFFFFF0000000000;1FB87:0303030303030303;" +
|
||||
"1FB88:0707070707070707;1FB8C:A050A050A050A050;1FB8F:00000000AA55AA55;1FB95:CCCC3333CCCC3333;" +
|
||||
"1FB96:3333CCCC3333CCCC;1FB98:CC663399CC663399;1FB99:3366CC993366CC99;" +
|
||||
"",
|
||||
)
|
||||
}
|
||||
@@ -88,22 +88,38 @@ class TerminalBridge(cols: Int, rows: Int) {
|
||||
c.code
|
||||
}
|
||||
i++
|
||||
if (cp == '\n'.code || cp == '\r'.code) {
|
||||
out.append(keys.key(Key.ENTER, emulator, alt = alt))
|
||||
continue
|
||||
val b = if (cp == '\n'.code || cp == '\r'.code) {
|
||||
emulator.keyOctets(keys, Key.ENTER, alt = alt)
|
||||
} else {
|
||||
emulator.charOctets(keys, cp, alt, ctrl)
|
||||
}
|
||||
out.append(keys.char(cp, alt, ctrl))
|
||||
out.append(latin1(b))
|
||||
}
|
||||
return octets(out.toString())
|
||||
return out.toString()
|
||||
}
|
||||
|
||||
/** a key that isn't a character ([Key]'s names: UP, ESCAPE, F1 …) as octets in Latin-1; "" for no such key */
|
||||
fun key(name: String, shift: Boolean = false, alt: Boolean = false, ctrl: Boolean = false): String {
|
||||
val k = Key.entries.firstOrNull { it.name == name } ?: return ""
|
||||
if (k == Key.BACKSPACE) return keys.backspace.code.toChar().toString()
|
||||
return octets(keys.key(k, emulator, shift, alt, ctrl))
|
||||
return latin1(emulator.keyOctets(keys, k, shift, alt, ctrl))
|
||||
}
|
||||
|
||||
/** the rows the view should have at most (a Commodore's 25), 0 for as many as fit */
|
||||
val requestedRows: Int get() = emulator.requestedRows
|
||||
|
||||
/** whether the cells are drawn from 8x8 bitmaps (the profile's machine's glyphs), not the font */
|
||||
val bitmapGlyphs: Boolean get() = emulator.glyphs != null
|
||||
|
||||
/** row [row] (0 top) of [cp]'s 8x8 glyph, its leftmost pixel bit 7; -1 if the profile has no glyph for it (drawn with the font) */
|
||||
fun glyphRow(cp: Int, row: Int): Int {
|
||||
val g = emulator.glyphs ?: return -1
|
||||
if (!g.has(cp)) return -1
|
||||
return BitmapFont.row(g.glyph(cp), row)
|
||||
}
|
||||
|
||||
/** the swatch (ARGB) the key at ([row], [col]) of page [page] shows, 0 for none */
|
||||
fun keyBarColor(page: Int, row: Int, col: Int): Int = (keyAt(page, row, col) as? BarKey.Octets)?.color ?: 0
|
||||
|
||||
/** row [row]'s size: 0 single, 1 double width, 2 double height's top half, 3 its bottom half */
|
||||
fun lineSize(row: Int): Int = emulator.line(row).size.ordinal
|
||||
|
||||
@@ -125,7 +141,7 @@ class TerminalBridge(cols: Int, rows: Int) {
|
||||
/** what the key at ([row], [col]) of page [page] is: "ctrl", "alt", "next" (page), or "" for one that sends */
|
||||
fun keyBarAction(page: Int, row: Int, col: Int): String = when (keyAt(page, row, col)) {
|
||||
BarKey.Ctrl -> "ctrl"
|
||||
BarKey.Alt -> "alt"
|
||||
is BarKey.Alt -> "alt"
|
||||
BarKey.NextPage -> "next"
|
||||
else -> ""
|
||||
}
|
||||
@@ -135,6 +151,7 @@ class TerminalBridge(cols: Int, rows: Int) {
|
||||
when (val k = keyAt(page, row, col)) {
|
||||
is BarKey.Send -> key(k.key.name, alt = alt, ctrl = ctrl)
|
||||
is BarKey.Type -> typed(k.text, ctrl, alt)
|
||||
is BarKey.Octets -> k.octets
|
||||
else -> ""
|
||||
}
|
||||
|
||||
@@ -144,9 +161,6 @@ class TerminalBridge(cols: Int, rows: Int) {
|
||||
/** the screen's text from (row, col) to (row2, col2), for copying */
|
||||
fun text(row: Int, col: Int, row2: Int, col2: Int): String = emulator.text(row, col, row2, col2)
|
||||
|
||||
/** [s] in the character set, as Latin-1 text (one character an octet) */
|
||||
private fun octets(s: String): String {
|
||||
val b = emulator.decoder.charset.encode(s)
|
||||
return CharArray(b.size) { (b[it].toInt() and 0xff).toChar() }.concatToString()
|
||||
}
|
||||
/** octets as Latin-1 text (one character each) */
|
||||
private fun latin1(b: ByteArray): String = CharArray(b.size) { (b[it].toInt() and 0xff).toChar() }.concatToString()
|
||||
}
|
||||
@@ -68,7 +68,7 @@ class TerminalEmulator(
|
||||
private set
|
||||
var cursorY = 0
|
||||
private set
|
||||
private var pendingWrap = false
|
||||
internal var pendingWrap = false
|
||||
/** the rendition the next characters are written in */
|
||||
internal var style = Style.NORMAL
|
||||
|
||||
@@ -131,9 +131,13 @@ class TerminalEmulator(
|
||||
for (i in range) if (i in colorOverrides.indices) colorOverrides[i] = -1
|
||||
}
|
||||
|
||||
/** the columns the remote asked for (DECCOLM: 80 or 132), for the view to fit; 0: none asked */
|
||||
/** the columns the view should fit across its width (DECCOLM's 80 or 132, a Commodore's 40); 0: as many as the font gives */
|
||||
var requestedColumns = 0
|
||||
private set
|
||||
internal set
|
||||
|
||||
/** the rows the screen should have at most (a Commodore's 25); 0: as many as fit */
|
||||
var requestedRows = 0
|
||||
internal set
|
||||
|
||||
/** the keyboard's four LEDs (DECLL), L1 the lowest bit */
|
||||
var leds = 0
|
||||
@@ -179,6 +183,7 @@ class TerminalEmulator(
|
||||
set(v) {
|
||||
if (v === field) return
|
||||
field = v
|
||||
interpreter.detach()
|
||||
interpreter = v.interpreter(this)
|
||||
homeOnClear = v.homeOnClear
|
||||
softReset()
|
||||
@@ -190,12 +195,31 @@ class TerminalEmulator(
|
||||
|
||||
private val sink = TermDecoder.Sink { cp -> interpreter.process(cp) }
|
||||
|
||||
/** the remote's octets, decoded in [decoder]'s set */
|
||||
/** the remote's octets, decoded in [decoder]'s set (or as they are, to an interpreter that reads octets) */
|
||||
fun append(data: ByteArray, length: Int = data.size) {
|
||||
decoder.decode(data, length, sink)
|
||||
if (interpreter.readsOctets) {
|
||||
for (i in 0 until length) interpreter.process(data[i].toInt() and 0xff)
|
||||
} else {
|
||||
decoder.decode(data, length, sink)
|
||||
}
|
||||
revision++
|
||||
}
|
||||
|
||||
/** what key [k] sends, as octets: the interpreter's own, else [keys]' sequence in the character set */
|
||||
fun keyOctets(keys: KeyEncoder, k: Key, shift: Boolean = false, alt: Boolean = false, ctrl: Boolean = false): ByteArray =
|
||||
interpreter.keyOctets(k, shift, alt, ctrl)
|
||||
?: decoder.charset.encode(keys.key(k, this, shift, alt, ctrl))
|
||||
|
||||
/** what a character typed (or pasted) sends, as octets: the interpreter's own, else [keys]' in the character set */
|
||||
fun charOctets(keys: KeyEncoder, cp: Int, alt: Boolean = false, ctrl: Boolean = false): ByteArray =
|
||||
interpreter.charOctets(cp, alt, ctrl) ?: decoder.charset.encode(keys.char(cp, alt, ctrl))
|
||||
|
||||
/** whether the remote's octets are read as they come, in the terminal's own set (a Commodore's), not the user's */
|
||||
val readsOctets: Boolean get() = interpreter.readsOctets
|
||||
|
||||
/** the glyphs its cells are drawn with, a bitmap font the profile's machine had (null: the view's font) */
|
||||
val glyphs: BitmapFont? get() = profile.glyphs
|
||||
|
||||
/** text, as code points (the tests, local echo) */
|
||||
fun appendText(s: String) {
|
||||
var i = 0
|
||||
@@ -667,6 +691,7 @@ class TerminalEmulator(
|
||||
focusEvents = false
|
||||
cursorStyle = 0
|
||||
requestedColumns = 0
|
||||
requestedRows = 0
|
||||
leds = 0
|
||||
vt52Keys = false
|
||||
sixelScrolling = true
|
||||
|
||||
@@ -25,4 +25,16 @@ abstract class TerminalInterpreter(protected val t: TerminalEmulator) {
|
||||
|
||||
/** the character sets saved with the cursor back ([charsetState]'s, or null: the defaults) */
|
||||
open fun restoreCharsetState(s: Any?) {}
|
||||
|
||||
/** whether it reads the remote's octets as they come (its own character set), not code points decoded in the user's */
|
||||
open val readsOctets: Boolean get() = false
|
||||
|
||||
/** what key [k] sends on this terminal, as octets; null: the VT sequences ([KeyEncoder]) */
|
||||
open fun keyOctets(k: Key, shift: Boolean, alt: Boolean, ctrl: Boolean): ByteArray? = null
|
||||
|
||||
/** what character [cp] typed or pasted sends on this terminal, as octets; null: [KeyEncoder]'s, in the character set */
|
||||
open fun charOctets(cp: Int, alt: Boolean, ctrl: Boolean): ByteArray? = null
|
||||
|
||||
/** another profile's interpreter taking over: what this one set on the screen (its size, its colours) undone */
|
||||
open fun detach() {}
|
||||
}
|
||||
@@ -24,6 +24,12 @@ abstract class TerminalProfile {
|
||||
/** ESC[2J homes the cursor, as ANSI.SYS did (BBS screens expect it) */
|
||||
open val homeOnClear: Boolean get() = false
|
||||
|
||||
/** the bitmap glyphs its cells are drawn with (its machine's character ROM, as Unscii draws it); null: the view's font */
|
||||
open val glyphs: BitmapFont? get() = null
|
||||
|
||||
/** a capture's file extension, where its machine's files had their own (a Commodore's .seq); null: the app's */
|
||||
open val captureExtension: String? get() = null
|
||||
|
||||
/** the keys the apps' bar offers, page by page */
|
||||
open val keyBar: List<KeyBarPage> get() = KeyBars.STANDARD
|
||||
|
||||
@@ -150,12 +156,21 @@ object TerminalProfiles {
|
||||
val VT220: TerminalProfile = Vt220Profile()
|
||||
val XTERM: TerminalProfile = XtermProfile()
|
||||
val ANSI_BBS: TerminalProfile = AnsiBbsProfile()
|
||||
val C64: TerminalProfile = C64Profile()
|
||||
val C128: TerminalProfile = C128Profile()
|
||||
val C128_80: TerminalProfile = C128VdcProfile()
|
||||
val PLUS4: TerminalProfile = Plus4Profile()
|
||||
val VIC20: TerminalProfile = Vic20Profile()
|
||||
val PET: TerminalProfile = PetProfile()
|
||||
val PET80: TerminalProfile = Pet80Profile()
|
||||
val ATARI: TerminalProfile = AtariProfile()
|
||||
val ATARI_INTL: TerminalProfile = AtariInternationalProfile()
|
||||
|
||||
/** the default: what the app was before profiles */
|
||||
val DEFAULT: TerminalProfile get() = XTERM
|
||||
|
||||
/** in the pickers' order */
|
||||
val all: List<TerminalProfile> = listOf(XTERM, ANSI_BBS, VT52, VT100, VT102, VT220)
|
||||
val all: List<TerminalProfile> = listOf(XTERM, ANSI_BBS, VT52, VT100, VT102, VT220, C64, C128, C128_80, PLUS4, VIC20, PET, PET80, ATARI, ATARI_INTL)
|
||||
|
||||
/** the profile [id] names, or null for none or one not known */
|
||||
fun byId(id: String?): TerminalProfile? = all.firstOrNull { it.id == id }
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// Copyright (C) 2026 Neo-Desktop
|
||||
package org.dmodem.app.terminal
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
import kotlin.test.Test
|
||||
|
||||
class AtasciiTest {
|
||||
|
||||
private val keys = KeyEncoder()
|
||||
|
||||
/** an Atari's screen, 40x24 */
|
||||
private fun term(profile: TerminalProfile = TerminalProfiles.ATARI) = TerminalEmulator(40, 24, 100, profile)
|
||||
|
||||
/** octets fed in as they are */
|
||||
private fun TerminalEmulator.send(vararg b: Int) = append(ByteArray(b.size) { b[it].toByte() })
|
||||
|
||||
/** the octets [b] as ints */
|
||||
private fun ints(b: ByteArray) = b.map { it.toInt() and 0xff }
|
||||
|
||||
/** its screen, its characters (0x80 up reversed), ESC showing a control's character */
|
||||
@Test
|
||||
fun charactersAndInverse() {
|
||||
val t = term()
|
||||
assertEquals(40, t.requestedColumns)
|
||||
assertEquals(24, t.requestedRows)
|
||||
t.send(0x41, 0x00, 0x60, 0x7b, 0xc1, 0x1b, 0x1c, 0x1b, 0x7d)
|
||||
assertEquals("A♥♦♠A↑\uD83E\uDCB0", t.line(0).text())
|
||||
val l = t.line(0)
|
||||
assertEquals(0, Style.attrs(l.styles[0]) and Style.INVERSE)
|
||||
assertTrue(Style.attrs(l.styles[4]) and Style.INVERSE != 0)
|
||||
assertEquals(0, Style.attrs(l.styles[5]) and Style.INVERSE)
|
||||
val i = term(TerminalProfiles.ATARI_INTL)
|
||||
i.send(0x7b)
|
||||
assertEquals("Ä", i.line(0).text())
|
||||
}
|
||||
|
||||
/** the cursor keys wrap round the screen; EOL, CLEAR, BACK S, delete and insert */
|
||||
@Test
|
||||
fun editing() {
|
||||
val t = term()
|
||||
t.send(0x1c)
|
||||
assertEquals(23, t.cursorY)
|
||||
t.send(0x1d, 0x1e)
|
||||
assertEquals(0, t.cursorY)
|
||||
assertEquals(39, t.cursorX)
|
||||
t.send(0x1f)
|
||||
assertEquals(0, t.cursorX)
|
||||
t.send(0x41, 0x42, 0x43, 0x7e)
|
||||
assertEquals("AB", t.line(0).text())
|
||||
assertEquals(2, t.cursorX)
|
||||
t.send(0x1e, 0x1e, 0xfe)
|
||||
assertEquals("B", t.line(0).text())
|
||||
t.send(0xff)
|
||||
assertEquals(" B", t.line(0).text())
|
||||
t.send(0x9b)
|
||||
assertEquals(1, t.cursorY)
|
||||
assertEquals(0, t.cursorX)
|
||||
t.send(0x7d)
|
||||
assertEquals("", t.line(0).text())
|
||||
assertEquals(0, t.cursorY)
|
||||
}
|
||||
|
||||
/** its keys and typing: EOL for Enter, CTRL with a letter its graphic, the inverse key reversing */
|
||||
@Test
|
||||
fun keysAndTyping() {
|
||||
val t = term()
|
||||
assertEquals(listOf(0x9b), ints(t.keyOctets(keys, Key.ENTER)))
|
||||
assertEquals(listOf(0x1c), ints(t.keyOctets(keys, Key.UP)))
|
||||
assertEquals(listOf(0x7e), ints(t.keyOctets(keys, Key.BACKSPACE)))
|
||||
assertEquals(listOf(0x01), ints(t.charOctets(keys, 'a'.code, ctrl = true)))
|
||||
assertEquals(listOf(0x60), ints(t.charOctets(keys, '.'.code, ctrl = true)))
|
||||
assertEquals(listOf(0xe1), ints(t.charOctets(keys, 'a'.code, alt = true)))
|
||||
assertEquals(listOf(0x7b), ints(t.charOctets(keys, '♠'.code)))
|
||||
assertEquals(listOf(0x3f), ints(t.charOctets(keys, '~'.code)))
|
||||
}
|
||||
|
||||
/** every character of both sets has its glyph */
|
||||
@Test
|
||||
fun glyphs() {
|
||||
for (set in listOf(LegacyCharsets.ATARI_GRAPHICS, LegacyCharsets.ATARI_INTERNATIONAL)) {
|
||||
for (cp in set) if (cp != 0) assertTrue(LegacyCharsets.GLYPHS.has(cp), "U+" + cp.toString(16))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,202 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// Copyright (C) 2026 Neo-Desktop
|
||||
package org.dmodem.app.terminal
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertNull
|
||||
import kotlin.test.assertTrue
|
||||
import kotlin.test.Test
|
||||
|
||||
class PetsciiTest {
|
||||
|
||||
private val keys = KeyEncoder()
|
||||
|
||||
/** a terminal of [profile], 40x25 as the view would fit it */
|
||||
private fun term(profile: TerminalProfile = TerminalProfiles.C64, cols: Int = 40, rows: Int = 25) =
|
||||
TerminalEmulator(cols, rows, 100, profile)
|
||||
|
||||
/** octets fed in as they are */
|
||||
private fun TerminalEmulator.send(vararg b: Int) = append(ByteArray(b.size) { b[it].toByte() })
|
||||
|
||||
/** [s]'s characters fed in as octets */
|
||||
private fun TerminalEmulator.send(s: String) = append(s.latin1())
|
||||
|
||||
/** the octets [b] as ints */
|
||||
private fun ints(b: ByteArray) = b.map { it.toInt() and 0xff }
|
||||
|
||||
/** the C64 asks for its screen and palette, and a VT profile after it gets the view's back */
|
||||
@Test
|
||||
fun theMachinesScreen() {
|
||||
val t = term(TerminalProfiles.XTERM)
|
||||
t.profile = TerminalProfiles.C64
|
||||
assertEquals(40, t.requestedColumns)
|
||||
assertEquals(25, t.requestedRows)
|
||||
assertTrue(t.readsOctets)
|
||||
assertEquals(CommodorePalettes.PEPTO[2], t.colorOverride(2))
|
||||
assertEquals(CommodorePalettes.PEPTO[0], t.colorOverride(257))
|
||||
assertTrue(t.glyphs != null)
|
||||
t.profile = TerminalProfiles.XTERM
|
||||
assertEquals(0, t.requestedColumns)
|
||||
assertEquals(0, t.requestedRows)
|
||||
assertEquals(-1, t.colorOverride(2))
|
||||
assertNull(t.glyphs)
|
||||
assertEquals(22, term(TerminalProfiles.VIC20).requestedColumns)
|
||||
assertEquals(80, term(TerminalProfiles.C128_80).requestedColumns)
|
||||
}
|
||||
|
||||
/** octets aren't decoded in the user's set: 0xC1 is the graphics set's spade, the other set's capital A */
|
||||
@Test
|
||||
fun theTwoSets() {
|
||||
val t = term()
|
||||
t.decoder.charset = TermCharset.UTF8
|
||||
t.send(0x41, 0xc1, 0x5c)
|
||||
assertEquals("A♠£", t.line(0).text())
|
||||
t.send(0x0e, 0x41, 0xc1, 0x8e, 0x41)
|
||||
assertEquals("A♠£aAA", t.line(0).text())
|
||||
}
|
||||
|
||||
/** the colour codes, reverse on and off, RETURN ending reverse */
|
||||
@Test
|
||||
fun coloursAndReverse() {
|
||||
val t = term()
|
||||
t.send(0x1c, 'A'.code, 0x12, 'B'.code, 0x9a, 0x0d, 'C'.code)
|
||||
val l = t.line(0)
|
||||
assertEquals(2, Style.fg(l.styles[0]))
|
||||
assertEquals(0, Style.attrs(l.styles[0]) and Style.INVERSE)
|
||||
assertTrue(Style.attrs(l.styles[1]) and Style.INVERSE != 0)
|
||||
val c = t.line(1).styles[0]
|
||||
assertEquals(14, Style.fg(c))
|
||||
assertEquals(0, Style.attrs(c) and Style.INVERSE)
|
||||
// (a VIC-20 has no C= colours, a PET none at all)
|
||||
val v = term(TerminalProfiles.VIC20)
|
||||
v.send(0x81, 'A'.code)
|
||||
assertEquals(1, Style.fg(v.line(0).styles[0]))
|
||||
val p = term(TerminalProfiles.PET)
|
||||
p.send(0x1c, 'A'.code)
|
||||
assertEquals(1, Style.fg(p.line(0).styles[0]))
|
||||
}
|
||||
|
||||
/** the cursor keys wrap round the line ends; HOME and CLR; the last column wraps at once */
|
||||
@Test
|
||||
fun cursorAndWrap() {
|
||||
val t = term(cols = 40, rows = 3)
|
||||
t.send(0x9d)
|
||||
assertEquals(0, t.cursorX)
|
||||
t.send(0x11, 0x9d)
|
||||
assertEquals(39, t.cursorX)
|
||||
assertEquals(0, t.cursorY)
|
||||
t.send(0x1d)
|
||||
assertEquals(0, t.cursorX)
|
||||
assertEquals(1, t.cursorY)
|
||||
t.send(0x91, 0x91)
|
||||
assertEquals(0, t.cursorY)
|
||||
t.send(0x13)
|
||||
t.send("x".repeat(40))
|
||||
assertEquals(0, t.cursorX)
|
||||
assertEquals(1, t.cursorY)
|
||||
// (down at the bottom scrolls)
|
||||
t.send(0x11, 0x11)
|
||||
assertEquals(2, t.cursorY)
|
||||
assertEquals("", t.line(0).text().trim())
|
||||
t.send(0x93)
|
||||
assertEquals(0, t.cursorX)
|
||||
assertEquals(0, t.cursorY)
|
||||
}
|
||||
|
||||
/** DEL takes the character before the cursor, INST opens a space */
|
||||
@Test
|
||||
fun deleteAndInsert() {
|
||||
val t = term()
|
||||
t.send("ABC")
|
||||
t.send(0x9d, 0x14)
|
||||
assertEquals("AC", t.line(0).text())
|
||||
assertEquals(1, t.cursorX)
|
||||
t.send(0x94)
|
||||
assertEquals("A C", t.line(0).text())
|
||||
}
|
||||
|
||||
/** the C128's ESC sequences, its line feed and the VDC's underline */
|
||||
@Test
|
||||
fun c128() {
|
||||
val t = term(TerminalProfiles.C128)
|
||||
t.send("HELLO")
|
||||
t.send(0x9d, 0x9d, 0x1b, 'Q'.code)
|
||||
assertEquals("HEL", t.line(0).text())
|
||||
t.send(0x0a)
|
||||
assertEquals(1, t.cursorY)
|
||||
assertEquals(3, t.cursorX)
|
||||
val c64 = term()
|
||||
c64.send(0x0a)
|
||||
assertEquals(0, c64.cursorY)
|
||||
val v = term(TerminalProfiles.C128_80, cols = 80)
|
||||
v.send(0x02, 'U'.code, 0x82, 'N'.code)
|
||||
assertTrue(Style.attrs(v.line(0).styles[0]) and Style.UNDERLINE != 0)
|
||||
assertEquals(0, Style.attrs(v.line(0).styles[1]) and Style.UNDERLINE)
|
||||
}
|
||||
|
||||
/** the keys a C64 sends: the cursor keys, the function keys, RETURN, DEL */
|
||||
@Test
|
||||
fun keys() {
|
||||
val t = term()
|
||||
assertEquals(listOf(0x91), ints(t.keyOctets(keys, Key.UP)))
|
||||
assertEquals(listOf(0x1d), ints(t.keyOctets(keys, Key.RIGHT)))
|
||||
assertEquals(listOf(0x89), ints(t.keyOctets(keys, Key.F2)))
|
||||
assertEquals(listOf(0x0d), ints(t.keyOctets(keys, Key.ENTER)))
|
||||
assertEquals(listOf(0x14), ints(t.keyOctets(keys, Key.BACKSPACE)))
|
||||
assertEquals(listOf(0x93), ints(t.keyOctets(keys, Key.HOME, shift = true)))
|
||||
assertTrue(t.keyOctets(keys, Key.PAGE_UP).isEmpty())
|
||||
}
|
||||
|
||||
/** typing: letters by the set, CTRL and C= with digits the colours, C= with a letter its graphic, a pasted graphic its code */
|
||||
@Test
|
||||
fun typing() {
|
||||
val t = term()
|
||||
assertEquals(listOf(0x41), ints(t.charOctets(keys, 'a'.code)))
|
||||
assertEquals(listOf(0x41), ints(t.charOctets(keys, 'A'.code)))
|
||||
assertEquals(listOf(0x1c), ints(t.charOctets(keys, '3'.code, ctrl = true)))
|
||||
assertEquals(listOf(0x81), ints(t.charOctets(keys, '1'.code, alt = true)))
|
||||
assertEquals(listOf(0xb0), ints(t.charOctets(keys, 'a'.code, alt = true)))
|
||||
assertEquals(listOf(0x03), ints(t.charOctets(keys, 'c'.code, ctrl = true)))
|
||||
assertEquals(listOf(0xc1), ints(t.charOctets(keys, '♠'.code)))
|
||||
assertEquals(listOf(0x5c), ints(t.charOctets(keys, '£'.code)))
|
||||
assertEquals(listOf(0x3f), ints(t.charOctets(keys, '{'.code)))
|
||||
t.send(0x0e)
|
||||
assertEquals(listOf(0x41), ints(t.charOctets(keys, 'a'.code)))
|
||||
assertEquals(listOf(0xc1), ints(t.charOctets(keys, 'A'.code)))
|
||||
// (an xterm's are as they were)
|
||||
val x = term(TerminalProfiles.XTERM)
|
||||
assertEquals("\u001b[A", x.keyOctets(keys, Key.UP).decodeToString())
|
||||
assertEquals("a", x.charOctets(keys, 'a'.code).decodeToString())
|
||||
assertFalse(x.readsOctets)
|
||||
}
|
||||
|
||||
/** every character of every Commodore set has its glyph, and the glyphs read as stored */
|
||||
@Test
|
||||
fun glyphs() {
|
||||
val g = LegacyCharsets.GLYPHS
|
||||
for (set in listOf(LegacyCharsets.C64_UPPER, LegacyCharsets.C64_LOWER, LegacyCharsets.VIC_UPPER,
|
||||
LegacyCharsets.VIC_LOWER, LegacyCharsets.PET_UPPER, LegacyCharsets.PET_LOWER)) {
|
||||
for (cp in set) if (cp != 0) assertTrue(g.has(cp), "U+" + cp.toString(16))
|
||||
}
|
||||
// (the left half block: its left four pixels; a space: none)
|
||||
val half = g.glyph(0x258c)
|
||||
assertEquals(0xf0, BitmapFont.row(half, 0))
|
||||
assertTrue(BitmapFont.pixel(half, 7, 0))
|
||||
assertFalse(BitmapFont.pixel(half, 7, 7))
|
||||
assertEquals(0L, g.glyph(' '.code))
|
||||
assertFalse(g.has(0x4e00))
|
||||
}
|
||||
|
||||
/** a Commodore's key bar: its keys, the colour page's swatches in its palette */
|
||||
@Test
|
||||
fun keyBar() {
|
||||
val bar = TerminalProfiles.C64.keyBar
|
||||
assertEquals(3, bar.size)
|
||||
val colours = bar[2].rows[0].filterIsInstance<BarKey.Octets>()
|
||||
assertEquals(8, colours.size)
|
||||
assertEquals("\u001c", colours[2].octets)
|
||||
assertEquals(CommodorePalettes.PEPTO[2], colours[2].color)
|
||||
assertEquals(2, TerminalProfiles.PET.keyBar.size)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
# Copyright (C) 2026 Neo-Desktop
|
||||
"""
|
||||
Writes shared/.../terminal/LegacyCharsets.kt: the 8-bit home computers'
|
||||
character sets as Unicode (Rebecca Bettencourt's Legacy Computing
|
||||
mappings) and an 8x8 glyph for each character they use (Unscii's, public
|
||||
domain), so the app draws them as those machines did without shipping
|
||||
their ROM fonts.
|
||||
|
||||
python3 tools/gen_legacy_charsets.py UNSCII_8_HEX MAPPINGS_DIR
|
||||
|
||||
UNSCII_8_HEX is unscii-8.hex (http://viznut.fi/unscii/); MAPPINGS_DIR is
|
||||
mappings/legacy of https://github.com/kreativekorp/charset.
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
# (the Kotlin name, the mapping file, what it is)
|
||||
SETS = [
|
||||
("C64_UPPER", "c64ipri", "Commodore 64/128 and Plus/4, upper case and graphics"),
|
||||
("C64_LOWER", "c64ialt", "Commodore 64/128 and Plus/4, lower and upper case"),
|
||||
("VIC_UPPER", "cvicipri", "VIC-20, upper case and graphics"),
|
||||
("VIC_LOWER", "cvicialt", "VIC-20, lower and upper case"),
|
||||
("PET_UPPER", "cpetipri", "PET, upper case and graphics"),
|
||||
("PET_LOWER", "cpetialt", "PET, lower and upper case"),
|
||||
("ATARI_GRAPHICS", "atari8ig", "Atari 8-bit ATASCII, the graphics set (0x80-0xff: 0x00-0x7f reversed)"),
|
||||
("ATARI_INTERNATIONAL", "atari8ii", "Atari 8-bit ATASCII, the international set (0x80-0xff: 0x00-0x7f reversed)"),
|
||||
]
|
||||
|
||||
# (a CHR$() mapping without its control codes' glyphs, and the screen-code one they come from)
|
||||
VIDEO = {"atari8ig": "atari8vg", "atari8ii": "atari8vi"}
|
||||
|
||||
|
||||
# glyphs Unscii hasn't got, drawn here (the Atari's ESC and CLEAR symbols: arrows to the upper left)
|
||||
EXTRA = {
|
||||
0x241B: ["........", ".######.", ".##.....", ".#.#....", ".#..#...", ".#...#..", ".#....#.", "........"],
|
||||
0x1F8B0: ["........", ".####...", ".##.....", ".#.#....", ".#..#...", ".....#..", "......#.", "........"],
|
||||
}
|
||||
|
||||
|
||||
def atari_screen_code(a):
|
||||
"""an ATASCII code (0x00..0x7f) as its screen code"""
|
||||
if a < 0x20:
|
||||
return a + 0x40
|
||||
if a < 0x60:
|
||||
return a - 0x20
|
||||
return a
|
||||
|
||||
OUT = "shared/src/commonMain/kotlin/org/dmodem/app/terminal/LegacyCharsets.kt"
|
||||
|
||||
|
||||
def mapping(path):
|
||||
"""a mapping file's codes and code points (the first of a sequence)"""
|
||||
m = {}
|
||||
for line in open(path, encoding="utf-8"):
|
||||
if not line.startswith("0x"):
|
||||
continue
|
||||
f = line.split("\t")
|
||||
# (a reversed character's: drawn as its plain one, reversed)
|
||||
if f[1].startswith("<"):
|
||||
continue
|
||||
cp = f[1].split("+")[0].strip()
|
||||
m[int(f[0], 16)] = int(cp, 16)
|
||||
return m
|
||||
|
||||
|
||||
def glyphs(path):
|
||||
"""unscii-8.hex's 8x8 glyphs, by code point"""
|
||||
g = {}
|
||||
for line in open(path):
|
||||
cp, bits = line.strip().split(":")
|
||||
if len(bits) == 16:
|
||||
g[int(cp, 16)] = bits.upper()
|
||||
return g
|
||||
|
||||
|
||||
def main():
|
||||
"""the tables and glyphs read, LegacyCharsets.kt written"""
|
||||
hexfile, mapdir = sys.argv[1], sys.argv[2]
|
||||
font = glyphs(hexfile)
|
||||
for cp, rows in EXTRA.items():
|
||||
font.setdefault(cp, "".join("%02X" % int(r.replace(".", "0").replace("#", "1"), 2) for r in rows))
|
||||
tables = []
|
||||
used = set(range(0x20, 0x7F))
|
||||
for name, f, what in SETS:
|
||||
m = mapping(os.path.join(mapdir, f + ".txt"))
|
||||
if f in VIDEO:
|
||||
v = mapping(os.path.join(mapdir, VIDEO[f] + ".txt"))
|
||||
for a in range(0x80):
|
||||
if a not in m:
|
||||
m[a] = v[atari_screen_code(a)]
|
||||
m = {a: m[a & 0x7F] for a in range(256)}
|
||||
t = [m.get(c, 0) for c in range(256)]
|
||||
tables.append((name, f, what, t))
|
||||
used.update(cp for cp in t if cp)
|
||||
missing = sorted(cp for cp in used if cp not in font)
|
||||
if missing:
|
||||
print("no glyph for: " + " ".join("U+%04X" % cp for cp in missing), file=sys.stderr)
|
||||
out = []
|
||||
w = out.append
|
||||
w("// SPDX-License-Identifier: AGPL-3.0-only")
|
||||
w("// Copyright (C) 2026 Neo-Desktop")
|
||||
w("// Generated by tools/gen_legacy_charsets.py: don't edit by hand.")
|
||||
w("package org.dmodem.app.terminal")
|
||||
w("")
|
||||
w("/**")
|
||||
w(" * The 8-bit home computers' character sets, each code (0x00..0xff) as its")
|
||||
w(" * Unicode code point (0: not a character), from Rebecca Bettencourt's")
|
||||
w(" * Legacy Computing mappings; and [GLYPHS], an 8x8 glyph for every one of")
|
||||
w(" * them, from Unscii (public domain; the two it hasn't, the Atari's ESC")
|
||||
w(" * and CLEAR symbols, drawn in the generator).")
|
||||
w(" */")
|
||||
w("internal object LegacyCharsets {")
|
||||
for name, f, what, t in tables:
|
||||
w(" /** %s (%s.txt) */" % (what, f))
|
||||
w(" val %s: IntArray = intArrayOf(" % name)
|
||||
for i in range(0, 256, 8):
|
||||
w(" " + ", ".join("0x%X" % cp for cp in t[i:i + 8]) + ",")
|
||||
w(" )")
|
||||
w("")
|
||||
have = sorted(cp for cp in used if cp in font)
|
||||
w(" /** the glyphs: each code point (hex) and its eight rows (top first, high bit leftmost) */")
|
||||
w(" val GLYPHS: BitmapFont = BitmapFont.parse(")
|
||||
for i in range(0, len(have), 4):
|
||||
w(" \"" + "".join("%X:%s;" % (cp, font[cp]) for cp in have[i:i + 4]) + "\" +")
|
||||
w(" \"\",")
|
||||
w(" )")
|
||||
w("}")
|
||||
open(OUT, "w").write("\n".join(out) + "\n")
|
||||
print("%d sets, %d glyphs, %d missing" % (len(tables), len(have), len(missing)))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user