Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard: Compress keymaps #25

Closed
mist64 opened this issue Sep 18, 2019 · 4 comments
Closed

Keyboard: Compress keymaps #25

mist64 opened this issue Sep 18, 2019 · 4 comments
Labels
[KERNAL] Part of KERNAL size optimization Will reduce ROM size
Milestone

Comments

@mist64
Copy link
Collaborator

mist64 commented Sep 18, 2019

Currently, we map the PS/2 scancode to the PETSCII or ISO-8859-15 character.

The PS/2 scancodes are very sparse, so each table is 91 bytes. But there are only 48 non-control keys on ISO keyboards.

By mapping the PS/2 scancode to a value from 0-47 first, and using a 48-entry table, the size of the tables can almost be cut in half.

In addition, the scripts should make sure identical maps (e.g. Ctrl+character on Nordic and US) only end up in the ROM once. So it may even make sense to break the 48 scancodes into "A-Z" (26) and "rest" (22), because A-Z tend to be the same for most keyboards.

@mist64
Copy link
Collaborator Author

mist64 commented Sep 23, 2019

@mist64 mist64 added [KERNAL] Part of KERNAL size optimization Will reduce ROM size labels Mar 22, 2022
@mist64
Copy link
Collaborator Author

mist64 commented Apr 30, 2022

I am no longer convinced of this:

  • Mapping everything onto 48ish codes might work, but there could be a keyboard layout that I'm not aware of now that doesn't fit into this.
  • We have plenty of ROM space now and could use more than one bank for keymaps.
  • We will support user-defined keyboard layouts (Support user-defined keyboard layouts #258), so the user can always have the autoboot script load a layout from disk.
  • If we reserve ~600 bytes in banked RAM for a loadable keyboard layout anyway, we might as well store compressed layouts in ROM and decompress one into RAM. A quick test got 630 bytes down to 349 bytes for "en_US". This way we can store about 23 keymap pairs (PET & ISO) on 16 KB ROM bank.

@mist64
Copy link
Collaborator Author

mist64 commented May 1, 2022

#258 just defined a fixed keytab format at a fixed banked RAM location.
The next step would be to store the layouts in ROM compressed using the KERNAL's LZSA support. And then to add more layouts.

LZSA gets the 1302 byte keymaps down to 438-478 bytes (average: 459). Plus 8 bytes index header. That's about 35 keyboard layouts. (The previous calculation assumed we'd compress PET and ISO separately.)

@mist64
Copy link
Collaborator Author

mist64 commented May 1, 2022

I asked users in the forum
https://www.commanderx16.com/forum/index.php?/topic/2782-keyboard-layout-survey/
and on FB
https://www.facebook.com/groups/CommanderX16/posts/1158745751543184
what keyboard layout they use. I already did that back in 2019, but maybe I can get a better signal now.

@mist64 mist64 changed the title Keyboard: Use more condensed keymaps Keyboard: Compress keymaps May 3, 2022
@mist64 mist64 added this to the r41 milestone May 3, 2022
@mist64 mist64 closed this as completed in 93e00e0 May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[KERNAL] Part of KERNAL size optimization Will reduce ROM size
Projects
None yet
Development

No branches or pull requests

1 participant