Build a ROM with different keyboard layouts

Tutorials and help articles.

(Posts require approval. See pinned post.)
Forum rules
Post guides, tutorials, and other instructional content here.

This topic area requires approval, so please be patient while we review content to make sure it fits the expectations for this topic area.

Tech support questions should be asked in Hardware or Software support.
Post Reply
lamb-duh
Posts: 63
Joined: Fri Jul 10, 2020 7:46 pm

Build a ROM with different keyboard layouts

Post by lamb-duh »


The x16-rom source tree includes a fairly large collection of keyboard layouts (presumably sourced from elsewhere? I could not find attribution) but can only build 12 into ROM. Here is what you need to do to build a ROM with different layouts.

What you need

- git

- python3

- cc65 (old versions without x16 cfg files work)

I have done this on Linux. The build process is incredibly straight-forward, I imagine it will build anywhere those tools will run.

Clone & Checkout

$ git clone https://github.com/commanderx16/x16-rom.git

$ cd x16-rom

$ git checkout r38

Replacing "r38" with the version of the emulator you are using (or a different version at your own discretion).

Choose Layouts

$ cd keymap/

The `klc` directory contains all available keyboard layouts. Make a note of which keyboards you wish to add to the ROM. Only the first part of the file name is needed. Eg. "klc/80A Latin American.klc" is identified by "80A".

Add these to the first line of the file `make_keytab_asm.sh` (in the variable `layouts`). Layouts that will be removed from the ROM do not need to be changed here, and this list does not need to be in any order.

Execute that script,

$ ./make_keytab_asm.sh

NB some keyboard layouts that do not produce any printable characters on the x16 will produce an error and empty output files. Other layouts that do not produce any printable characters will not produce an error. Keep in mind that all keyboard layouts will produce no output for any characters not available in PETSCII or 8859.

Edit `keymays.s`.

This file specifies which keymaps will make it into the final rom and in what order they will be cycled through. Under the comment, "; PETSCII", modify the list of includes to match your own keyboard layout. Each line should be of the form `.include "asm/___.asm"` with the same identifier in the blank. Keyboard layouts you no longer want can be removed by removing the `.include` line. There should be at least one layout and no more than 12.

Following this section, a similar list appears under the comment "; ISO". This list should match the petscii list except that each filename is of the form "asm/i___.asm".

Build the ROM

$ make

If successful, the useable rom is in the file "build/x16/rom.bin". To use this rom in the emulator, either replace the "rom.bin" in the same directory as the emulator, or specify the ROM on the command line with `x16emu -rom custom-rom.bin`

Arctica
Posts: 1
Joined: Mon Aug 23, 2021 6:06 pm

Build a ROM with different keyboard layouts

Post by Arctica »


There is a problem. When I execute ./make_keytab_asm.sh klc/40E\ Hungarian.klc it's just saying errors like this: 

UnicodeEncodeError: 'charmap' codec can't encode character '\xa2' in position 0: character maps to <undefined>

Traceback (most recent call last):

  File "C:\Users\danra\x16-rom\keymap\klc_to_asm.py", line 471, in <module>

    print("; chars: " + pprint.pformat(petscii_chars_not_reachable))

  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1776.0_x64__qbz5n2kfra8p0\lib\encodings\cp1250.py", line 19, in encode

    return codecs.charmap_encode(input,self.errors,encoding_table)[0]

Do you know how to fix this?

Scott Robison
Posts: 952
Joined: Fri Mar 19, 2021 9:06 pm

Build a ROM with different keyboard layouts

Post by Scott Robison »



13 minutes ago, Arctica said:




There is a problem. When I execute ./make_keytab_asm.sh klc/40E\ Hungarian.klc it's just saying errors like this: 



UnicodeEncodeError: 'charmap' codec can't encode character '\xa2' in position 0: character maps to <undefined>

Traceback (most recent call last):

  File "C:\Users\danra\x16-rom\keymap\klc_to_asm.py", line 471, in <module>

    print("; chars: " + pprint.pformat(petscii_chars_not_reachable))

  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.1776.0_x64__qbz5n2kfra8p0\lib\encodings\cp1250.py", line 19, in encode

    return codecs.charmap_encode(input,self.errors,encoding_table)[0]

Do you know how to fix this?



See https://www.python.org/dev/peps/pep-0528/ ... the problem is that you are running on Windows and the default character encoding used by the console is code page 1250. You need to switch to Unicode so that the program can convert unicode characters to something that can be displayed. Or so I infer from the provided information. I am not an expert on getting Python to communicate via the Windows console.

Post Reply