Transkeyer
Descripción del contenido de la página
Programa escrito en SBASIC para crear una tabla de teclado de SMSQ/E para un teclado de PC en castellano y juego de caracteres ISO 8859-1.
Para utilizar con la Sinclair QL un juego de caracteres estándar, ISO 8859-1, hacían falta dos cosas: La primera y más sencilla, crear la fuente, para lo que escribí el programa Transfonter; la segunda, crear la tabla de teclado para el sistema operativo SMSQ/E, para lo que escribí Transkeyer (y qxl_kbt_to_data).
El intento de crear una tabla de teclado utilizable fracasó por algo que desde el principio sospechaba: los caracteres de control especiales (por encima del código 191) que la QL usa durante la entrada de textos hacen imposible asociarlos a caracteres normales. Un ejemplo: La letra «Á» («A» con tilde aguda) tiene el código 193 en ISO 8859-1; ese código para la QL es un carácter de control que lleva el cursor al comienzo de la línea (lo que en la QL se hace con la combinación Alt+Izquierda).
A pesar de ello es posible crear códigos fuente en S*BASIC codificados con ISO 8859-1, usando un editor externo, como por ejemplo Vim, que era el objetivo principal, y ver correctamente en la QL tanto el listado del programa como los textos que el programa imprima en pantalla; para ello basta usar la fuente ISO 8859-1 para QL. Lo que no será posible es editar el programa con el editor incorporado en la QL, ni utilizar las funciones de entrada de texto habituales, como INPUT
, pues no habrá relación entre las pulsaciones de teclas y los signos obtenidos cuando estos no sean ASCII. Si el programa necesita recibir entradas con el teclado de caracteres que no sean ASCII, la solución es escribir procedimientos o funciones alternativos para la entrada de textos. En cualquier caso, por supuesto, algunas funciones de S*BASIC relacionadas directamente con el juego de caracteres, como las que pasan de mayúsculas a minúsculas, no funcionarán correctamente y habrá que escribir otras equivalentes.
El programa Transkeyer queda abandonado, pero lo publico por si a alguien se le ocurre alguna solución; aunque temo que no la hay, salvo hacer cambios en el sistema operativo.
Código fuente
rem Transkeyer
rem Copyright (C) 2010,2011 Marcos Cruz (http://programandala.net)
rem License: http://programandala.net/license
rem This program is written in SBASIC.
rem It has been tested with the QPC2 emulator, on Debian with Wine.
rem Its objective is to create a SMSQ/E keyboard table
rem for a PC AT Spanish keyboard and a ISO 8859-1 charset.
rem The encoding of this file is ISO 8859-1.
rem The following QL programs have been used as reference:
rem GenTabla, by Pedro Reina (1995-04-28)
rem gentabla2, modified version by Marcos Cruz (1995)
rem --------------------------------------------
rem Changelog
rem 2010-08-19 First coding.
rem 2010-08-24 First working draft.
rem 2011-02-19 Fixes.
rem 2011-02-20 Rewritten. New data format.
rem 2011-02-21 Project abandoned. The control chars (above code 191) of the original QL charset make it impossible.
rem --------------------------------------------
rem Init
let keyboard_table_file$ = "dos1_sb_es_iso_8859-1_pc_kbt"
let country_code% = 99 : rem fake code for testing
let iso_font_file$ = "dos1_fonts_iso_8859-1_font"
let iso_font_size% = flen(\iso_font_file$)
let iso_font_address = alchp(iso_font_size%)
lbytes iso_font_file$,iso_font_address
let key_codes%=128
let key_blocks%=4
let keyboard_table$=fill$(chr$(0),key_codes%*key_blocks%)
let nonspacing_char_table$ = fill$(chr$(0),256)
let dead_keys$ = "'`¨^"
rem let dead_keys$ = "'`¨^~"
rem let dead_keys$ = ".,:;" : rem debug
rem let dead_keys$ = "1234" : rem debug
let dead_keys% = len(dead_keys$)
let modified_keys$ = "aeiouAEIOU "
let modified_keys% = len(modified_keys$)
dim compound_chars$(dead_keys%,modified_keys%)
let compound_chars$(0) = "áéíóúÁÉÍÓÚ'": rem with accute
let compound_chars$(1) = "àèìòùÀÈÌÒÙ`": rem with grave
let compound_chars$(2) = "äëïöüÄËÏÖܨ": rem with umlaut
let compound_chars$(3) = "âêîôûÂÊÎÔÛ^": rem with circumflex
rem let compound_chars$(4) = "ãeiõuÃEIÕU~": rem with tilde
rem let compound_chars$(0) = "aeiouAEIOUw": rem debug
rem let compound_chars$(1) = "bcdefBCDEFx": rem debug
rem let compound_chars$(2) = "ghijkGHIJKy": rem debug
rem let compound_chars$(3) = "lmnopLMNOPz": rem debug
rem --------------------------------------------
rem Main
cls : csize 2, 1 : print "Transkeyer"\\ : csize 0, 0
print "Creating the keyboard table..."
restore
rep
read pc_key%
if not pc_key% : exit
rem print_using "###",pc_key%!"="!;
for block% = 0 to key_blocks%-1
read ql_char$
rem print ql_char$!;
let keyboard_table$(128*block% + pc_key%+1) = ql_char$
end for
end rep
print "Creating the non-spacing char table..."
for i% = 1 to dead_keys%
let nonspacing_char% = code(dead_keys$(i%))
let nonspacing_char_offset% = i% * (modified_keys%+1)
print "Non-spacing char"!nonspacing_char%!"(";chr$(nonspacing_char%);")"\"points to the "!nonspacing_char_offset%;"th byte of the modified char table."
let nonspacing_char_table$(nonspacing_char%+1) = chr$(nonspacing_char_offset%)
end for
rem --------------------------------------------
rem Output
print "Opening the output file..."
let channel% = fop_over(keyboard_table_file$)
if channel%<0
report channel% : stop : rem error
end if
print "Writing the machine code loader..."
bput #channel%,112,48
bput #channel%,67, 250
bput #channel%,0,6
bput #channel%,78,65
bput #channel%,78,117
print "Writing the table header..."
rem Header:
wput #channel%, 1 : rem keyboard table
wput #channel%, 0 : rem no group
wput #channel%, country_code%
wput #channel%, 0 : rem relative pointer to next table, or zero if no table follows this one
lput #channel%, 4 : rem relative pointer to the preference table
rem Intermediate structure:
wput #channel%, country_code%
wput #channel%, 4 : rem relative pointer to the first section (the keyboard table)
wput #channel%, 2+key_codes%*key_blocks% : rem relative pointer to the second section (the non-spacing char table)
print "Writing the keyboard table..."
print #channel%, keyboard_table$;
print "Writing the non-spacing char table..."
print #channel%,nonspacing_char_table$;
print #channel%, modified_keys$;
bput #channel%, 0
for i% = 0 to dead_keys%-1
print #channel%, compound_chars$(i%);
bput #channel%, 0
end for
close #channel%
print "Done."
stop
rem --------------------------------------------
rem Keyboard table data
rem Every DATA line has five data:
rem 1) PC XT key code
rem 2) QL char
rem 3) QL char with Shift
rem 4) QL char with Control
rem 5) QL char with Shift and Control
rem Esc-F10 row
data 001,chr$(27),"©","ä",chr$(31)
data 059,chr$(0),chr$(0),chr$(0),chr$(0)
data 060,chr$(0),chr$(0),chr$(0),chr$(0)
data 061,chr$(0),chr$(0),chr$(0),chr$(0)
data 062,chr$(0),chr$(0),chr$(0),chr$(0)
data 063,chr$(0),chr$(0),chr$(0),chr$(0)
data 064,chr$(0),chr$(0),chr$(0),chr$(0)
data 065,chr$(0),chr$(0),chr$(0),chr$(0)
data 066,chr$(0),chr$(0),chr$(0),chr$(0)
data 067,chr$(0),chr$(0),chr$(0),chr$(0)
data 068,chr$(0),chr$(0),chr$(0),chr$(0)
rem Top row
data 041,"º","ª",chr$(92),chr$(0)
data 002,"1","!","|","¹"
data 003,"2",'"',"@","²"
data 004,"3","·","#","³"
data 005,"4","$","~","¼" : rem ~ (126) and ¼ (188) don't work, but they are not control chars in the QL charset
data 006,"5","%","¦",chr$(0)
data 007,"6","&","¬","¾"
data 008,"7","/","½",chr$(0)
data 009,"8","(",chr$(0),"æ"
data 010,"9",")","^",chr$(0)
data 011,"0","=","`",chr$(0)
data 012,"'","?",chr$(0),chr$(0)
data 013,"¡","¿","¢",chr$(0)
data 043,"ç","Ç","}",chr$(0) : rem ç and Ç don't work
data 014,chr$(0),chr$(0),chr$(0),chr$(0) : rem ???
rem Second row
data 015,chr$(9),chr$(0),chr$(9),chr$(0)
data 016,"q","Q",chr$(17),chr$(0)
data 017,"w","W",chr$(23),"¤"
data 018,"e","E",chr$(5),"Õ"
data 019,"r","R",chr$(18),chr$(0)
data 020,"t","T",chr$(20),chr$(0)
data 021,"y","Y",chr$(25),"»"
data 022,"u","U",chr$(21),chr$(0)
data 023,"i","I",chr$(9),"Ñ" : rem Ñ does'n work
data 024,"o","O",chr$(15),chr$(0)
data 025,"p","P",chr$(16),"µ"
data 026,"`","^","[",chr$(0)
data 027,"+","*","]","±"
rem Third row
data 058,chr$(0),chr$(0),chr$(0),chr$(0)
data 030,"a","A",chr$(1),"À"
rem data 030,"Á","A",chr$(1),"À" : rem debug: "Á" in ISO 8859-1 is char 193, that is a QL control char (cursor to start of line)
data 031,"s","S",chr$(19),chr$(0)
data 032,"d","D",chr$(4),"Ö"
data 033,"f","F",chr$(6),"Ø"
data 034,"g","G",chr$(7),"Ü"
data 035,"h","H",chr$(8),"Ç"
data 036,"j","J",chr$(10),"Æ"
data 037,"k","K",chr$(11),chr$(0)
data 038,"l","L",chr$(12),chr$(0)
data 039,"ñ","Ñ",chr$(0),chr$(0)
data 040,"'","¨","{","~" : rem three dead keys: ' ¨ ~
data 028,chr$(10),chr$(0),chr$(10),chr$(0)
rem Fourth row
data 042,chr$(0),chr$(0),chr$(0),chr$(0)
data 086,"<",">","«","»"
data 044,"z","Z",chr$(26),"°"
data 045,"x","X",chr$(24),"×"
data 046,"c","C",chr$(3),"©"
data 047,"v","V",chr$(22),"§"
data 048,"b","B",chr$(2),"Å"
data 049,"n","N",chr$(14),chr$(0)
data 050,"m","M",chr$(13),chr$(0)
data 051,",",";",",",";"
data 052,".",":",".",";"
data 053,"-","_",chr$(0),"¯"
data 054,chr$(0),chr$(0),chr$(0),chr$(0)
rem Bottom row
data 029,chr$(0),chr$(0),chr$(0),chr$(0)
data 059,chr$(0),chr$(0),chr$(0),chr$(0)
data 057," ",chr$(0),chr$(0)," "
data 056,chr$(0),chr$(0),chr$(0),chr$(0)
data 029,chr$(0),chr$(0),chr$(0),chr$(0)
rem Odd pad
data 055,"*","*","*","*"
data 070,chr$(0),chr$(0),chr$(0),chr$(0)
data 069,chr$(0),chr$(0),chr$(0),chr$(0)
data 114,chr$(0),chr$(0),chr$(0),chr$(0)
data 103,chr$(0),chr$(0),chr$(0),chr$(0)
data 105,chr$(0),chr$(0),chr$(0),chr$(0)
data 115,chr$(0),chr$(0),chr$(0),chr$(0)
data 111,chr$(0),chr$(0),chr$(0),chr$(0)
data 113,chr$(0),chr$(0),chr$(0),chr$(0)
rem Cursor pad
data 104,chr$(0),chr$(0),chr$(0),chr$(0)
rem data 107,chr$(192),chr$(0),chr$(0),chr$(0) : rem debug: QL control code 192 (cursor left), doesn'n work here
data 107,chr$(0),chr$(0),chr$(0),chr$(0) : rem QL control code 192 (cursor left), doesn'n work here
data 112,chr$(0),chr$(0),chr$(0),chr$(0)
data 109,chr$(0),chr$(0),chr$(0),chr$(0)
rem Numeric pad
data 133,"$",chr$(0),chr$(0),chr$(0)
data 055,"*","*","*","*"
data 074,"","","",""
data 071,"7","7","7","7"
data 072,"8","8","8","8"
data 073,"9","9","9","9"
data 075,"4","4","4","4"
data 076,"5","5","5","5"
data 077,"6","6","6","6"
data 078,"+","+","+","+"
data 079,"1","1","1","1"
data 080,"2","2","2","2"
data 081,"3","3","3","3"
data 082,"0","0","0","0"
data 083,".",".",".","."
data 124,chr$(10),chr$(0),chr$(10),chr$(0)
rem Numeric pad without Num Lock
data 106,chr$(0),chr$(0),chr$(0),chr$(0)
data 103,chr$(0),chr$(0),chr$(0),chr$(0)
data 104,chr$(0),chr$(0),chr$(0),chr$(0)
data 105,chr$(0),chr$(0),chr$(0),chr$(0)
data 107,chr$(0),chr$(0),chr$(0),chr$(0)
data 108,chr$(0),chr$(0),chr$(0),chr$(0)
data 109,chr$(0),chr$(0),chr$(0),chr$(0)
data 110,chr$(0),chr$(0),chr$(0),chr$(0)
data 111,chr$(0),chr$(0),chr$(0),chr$(0)
data 112,chr$(0),chr$(0),chr$(0),chr$(0)
data 113,chr$(0),chr$(0),chr$(0),chr$(0)
data 114,chr$(0),chr$(0),chr$(0),chr$(0)
data 115,chr$(0),chr$(0),chr$(0),chr$(0)
data 0 : rem end of data
rem --------------------------------------------
rem Debug procs
def proc chars_use(address)
char_use #0,address,0
char_use #1,address,0
char_use #2,address,0
end def
def proc ql_es
chars_use 0
kbd_table 34 : rem Spain
end def
def proc ql_en
chars_use 0
kbd_table 44 : rem Great Britain
end def
def proc iso
chars_use iso_font_address
lrespr keyboard_table_file$
kbd_table country_code%
end def
Descargas
- transkeyer_bas (9.14 KiB)
- SMSQ_Language_Dependent_Modules.pdf (314.07 KiB) Artículo de Tony Tebby en que explica el formato de las tablas de teclado de SMSQ. Apareció en la publicación International QL Report en 1995. Agradezco a Salvador Merino y a Pedro Reina su ayuda para localizarlo.