C64 Maxi Umbau auf Raspberry Pi

Da das original Board echt nix kann, habe ich da einen Raspberry Pi 4 eingebaut. Mit ein paar Competition Pro USB ist das Feeling schon echt gut 😊

Leider habe ich noch keine Möglichkeit gefunden, die Tastatur außerhalb von VICE zu remappen.

Tastatur und seitliche USB-Ports mit dem Raspberry Pi nutzen

Die drei USB-Ports an der Seite sind sehr praktisch, die kann man sehr einfach weiternutzen:

Pasted image 20250501125415.png

Aus https://thec64community.online/thread/557/mod-convert-thec64-maxi-keyboard bzw. https://arananet-net.kinja.com/convirtiendo-el-teclado-de-un-c64-maxi-a-usb-1840718503

Mit einem kleinen USB-Breakout-Bord einfach die Tastatur an den Pi anschließen.

Power-LED via Batocera steuern

In /userdata/system folgende Datei custom.sh hinterlegen:

#!/bin/bash
# custom.sh - place to /userdata/system
# by cyperghost 23/11/19
#

if [[ $1 == start ]]; then
    gpioset gpiochip0 17=1
fi

if [[ $1 == stop ]]; then
    batocera-es-swissknife --emukill
fi

Die LED muss natürlich an GPIO 17 und GND angeschlossen sein. Die LED leuchtet, wenn Batocera komplett gebootet ist

Herunterfahren über seitlichen Schalter

Dazu muss "/etc/init.d/S92switch setup" aufgerufen werden und die Option "PIN56PUSH" ausgewählt werden. Nach einem Reboot funktioniert das dann entsprechend.

Der Schalter muss dazu natürlich auch an GPIO 5 und 6 angeschlossen sein 😊

Tastatur

Einige Informationen über das Mapping der Tastatur gibt es hier:

https://www.bartneck.de/2020/04/03/keyboard-mapping-of-c64-vic-20-on-raspbian/

und hier:

https://thec64community.online/thread/688/c64-keyboard-mapping

Hier das Mapping der Sondertasten:

Pasted image 20250501123245.png

![[sdl-thec64-C64.vkm.txt]]

Mappings für VICE Batocera

Als Symbolic Mapping für VICE/Batocera (ablegen in userdata/bios/C64/sdl_sym.vkm):

# VICE keyboard mapping file for THEC64 and Retropie
# Edited by Javier Albarracin in Lima Peru
#
# A Keyboard map is read in as patch to the current map.
#
# File format:
# - comment lines start with '#'
# - keyword lines start with '!keyword'
# - normal line has 'keysym/scancode row column shiftflag'
#
# Keywords and their lines are:
# '!CLEAR'               clear whole table
# '!INCLUDE filename'    read file as mapping file
# '!LSHIFT row col'      left shift keyboard row/column
# '!RSHIFT row col'      right shift keyboard row/column
# '!VSHIFT shiftkey'     virtual shift key (RSHIFT or LSHIFT)
# '!SHIFTL shiftkey'     shift lock key (RSHIFT or LSHIFT)
# '!LCTRL row col'       left control keyboard row/column
# '!VCTRL ctrlkey'       virtual control key (LCTRL)
# '!LCBM row col'        left CBM keyboard row/column
# '!VCBM cbmkey'         virtual CBM key (LCBM)
# '!UNDEF keysym'        remove keysym from table
#
# Shiftflag can have the values:
# 0      key is not shifted for this keysym/scancode
# 1      key is combined with shift for this keysym/scancode
# 2      key is left shift on emulated machine
# 4      key is right shift on emulated machine
# 8      key can be shifted or not with this keysym/scancode
# 16     deshift key for this keysym/scancode
# 32     another definition for this keysym/scancode follows
# 64     key is shift-lock on emulated machine
# 128    shift modifier required on host
# 256    key is used for an alternative keyboard mapping
# 512    alt-r (alt-gr) modifier required on host
# 1024   ctrl modifier required on host
# 2048   key is combined with cbm for this keysym/scancode
# 4096   key is combined with ctrl for this keysym/scancode
# 8192   key is (left) cbm on emulated machine
# 16384  key is (left) ctrl on emulated machine
#
# to migrate older keymaps and use the CBM and/or CTRL related features:
#
# - define !LCTRL, !VCTRL, !LCBM, !VCBM
# - add 'key is (left) cbm/ctrl on emulated machine' flags to
#   all keys that map to the cbm or ctrl key respectively.
#
# after that the virtual cbm/ctrl flags and requiring host modifiers
# should work as expected. keep an eye on the error messages.
#
# Negative row values:
# 'keysym -1 n' joystick keymap A, direction n
# 'keysym -2 n' joystick keymap B, direction n
# 'keysym -3 0' first RESTORE key
# 'keysym -3 1' second RESTORE key
# 'keysym -4 0' 40/80 column key
# 'keysym -4 1' CAPS (ASCII/DIN) key
# 'keysym -5 n' joyport keypad, key n
#
# Joystick direction values:
# 0      Fire
# 1      South/West
# 2      South
# 3      South/East
# 4      West
# 5      East
# 6      North/West
# 7      North
# 8      North/East
#
# Joyport keypad key layout:
# --------------------------
# |  0 |  1 |  2 |  3 |  4 |
# --------------------------
# |  5 |  6 |  7 |  8 |  9 |
# --------------------------
# | 10 | 11 | 12 | 13 | 14 |
# --------------------------
# | 15 | 16 | 17 | 18 | 19 |
# --------------------------
#
# When a bigger spaced key is used,
# it uses the upper left most key value.
#
# Symbolic USER Mapping for RETROPIE "TheC64", US Layout, C64, SDL
# Credits: Javier Albarracin V. file modded from Keyrah/Vice/Libretro 
# BE AWARE THAT LINUX KEYBOARD HAS TO BE IN "US AMERICAN" FOR THIS TO WORK
# this keyboard map applies for the "vice" setting for TheC64 Keyboard and
# maps all 64 keys, plus restore, to the respective emulated keys in VICE. 
# This however leaves no key free to enter the menu - one way to work
# around this is to configure a joystick key to enter the menu.
# 
# Don't forget to edit the file /opt/retropie/configs/c64/sdl-vicerc
# and include this lines to the end (without the starting "#"):
# KeymapUserSymFile="/opt/retropie/configs/c64/sdl-keyt64-C64.vkm"
# KeymapIndex=2
#
#
#       +-----+-----+-----+-----+-----+-----+-----+-----+
#       |Bit 0|Bit 1|Bit 2|Bit 3|Bit 4|Bit 5|Bit 6|Bit 7|
# +-----+-----+-----+-----+-----+-----+-----+-----+-----+
# |Bit 0| DEL |Retrn|C_L/R|  F7 |  F1 |  F3 |  F5 |C_U/D|
# +-----+-----+-----+-----+-----+-----+-----+-----+-----+
# |Bit 1| 3 # |  W  |  A  | 4 $ |  Z  |  S  |  E  | S_L |
# +-----+-----+-----+-----+-----+-----+-----+-----+-----+
# |Bit 2| 5 % |  R  |  D  | 6 & |  C  |  F  |  T  |  X  |
# +-----+-----+-----+-----+-----+-----+-----+-----+-----+
# |Bit 3| 7 ' |  Y  |  G  | 8 ( |  B  |  H  |  U  |  V  |
# +-----+-----+-----+-----+-----+-----+-----+-----+-----+
# |Bit 4| 9 ) |  I  |  J  |  0  |  M  |  K  |  O  |  N  |
# +-----+-----+-----+-----+-----+-----+-----+-----+-----+
# |Bit 5|  +  |  P  |  L  |  -  | . > | : [ |  @  | , < |
# +-----+-----+-----+-----+-----+-----+-----+-----+-----+
# |Bit 6|POUND|  *  | ; ] | HOME| S_R |  =  | A_UP| / ? |
# +-----+-----+-----+-----+-----+-----+-----+-----+-----+
# |Bit 7| 1 ! |A_LFT| CTRL| 2 " |SPACE|  C= |  Q  | R/S |
# +-----+-----+-----+-----+-----+-----+-----+-----+-----+
#

!CLEAR
!LSHIFT 1 7
!RSHIFT 6 4
!VSHIFT RSHIFT
!SHIFTL LSHIFT
!LCTRL 7 2
!VCTRL LCTRL
!LCBM 7 5
!VCBM LCBM

8   0 0 8               /*          Del -> Del          */
13  0 1 8               /*       Return -> Return       */
275 0 2 8               /*        Right -> CRSR RIGHT   */
276 0 2 1               /*         Left -> CRSR LEFT    */
288 0 3 8               /*           F7 -> F7           */
289 0 3 1               /*           F8 -> F8           */
282 0 4 8               /*           F1 -> F1           */
283 0 4 1               /*           F2 -> F2           */
284 0 5 8               /*           F3 -> F3           */
285 0 5 1               /*           F4 -> F4           */
286 0 6 8               /*           F5 -> F5           */
287 0 6 1               /*           F6 -> F6           */
273 0 7 1               /*      CRSR UP -> CRSR UP      */
274 0 7 8               /*    CRSR DOWN -> CRSR DOWN    */ 
51  1 0 8               /*            3 -> 3            */
52  1 3 8               /*            4 -> 4            */
304 1 7 2               /*   Left Shift -> Left Shift   */
301 1 7 64              /*   Shift Lock -> Shift Lock   */ 
53  2 0 8               /*            5 -> 5            */
54  2 3 8               /*            6 -> 6            */
55  3 0 8               /*            7 -> 7            */
56  3 3 8               /*            8 -> 8            */
57  4 0 8               /*            9 -> 9            */
48  4 3 8               /*            0 -> 0            */
270 5 0 8               /*            + -> +            */
269 5 3 8               /*            - -> -            */
46  5 4 8               /*            . -> .            */
91  5 5 8               /*            : -> :            */
92  5 6 8               /*            @ -> @            */
44  5 7 8               /*            , -> ,            */
45  6 0 8               /*       Pound -> Pound         */
59  6 1 8               /*            * -> *            */
93  6 2 8               /*            ; -> ;            */
278 6 3 8               /*     CLR/HOME -> CLR/HOME     */
303 6 4 4               /*  Right Shift -> Right Shift  */
61  6 5 8               /*            = -> =            */
39  6 6 8               /*     Up Arrow -> Up Arrow     */
47  6 7 8               /*            / -> /            */
49  7 0 8               /*            1 -> 1            */
96  7 1 8               /*   Left Arrow -> Left Arrow   */
306 7 2 8               /*         Ctrl -> Ctrl         */
50  7 3 8               /*            2 -> 2            */
32  7 4 8               /*        Space -> Space        */
310 7 5 8               /*       TheC64 -> CBM          */
27  7 7 8               /*     Run/Stop -> Run/Stop     */
97  1 2 8               /*            A -> A            */
98  3 4 8               /*            B -> B            */
99  2 4 8               /*            C -> C            */
100 2 2 8               /*            D -> D            */
101 1 6 8               /*            E -> E            */
102 2 5 8               /*            F -> F            */
103 3 2 8               /*            G -> G            */
104 3 5 8               /*            H -> H            */
105 4 1 8               /*            I -> I            */
106 4 2 8               /*            J -> J            */
107 4 5 8               /*            K -> K            */
108 5 2 8               /*            L -> L            */
109 4 4 8               /*            M -> M            */
110 4 7 8               /*            N -> N            */
111 4 6 8               /*            O -> O            */
112 5 1 8               /*            P -> P            */
113 7 6 8               /*            Q -> Q            */
114 2 1 8               /*            R -> R            */
115 1 5 8               /*            S -> S            */
116 2 6 8               /*            T -> T            */
117 3 6 8               /*            U -> U            */
118 3 7 8               /*            V -> V            */
119 1 1 8               /*            W -> W            */
120 2 7 8               /*            X -> X            */
121 3 1 8               /*            Y -> Y            */
122 1 4 8               /*            Z -> Z            */

#
# Restore key mappings
#
9 -3 0

#
# joyport attached keypad key mapping
#
300 -5 0
263 -5 1
264 -5 2
265 -5 3
267 -5 4
302 -5 5
260 -5 6
261 -5 7

Also Positional Mapping (ablegen in /userdata/bios/vice/C64/sdl_pos.vkm)

# BMC64 keyboard mapping file for TheC64 ('Maxi')
#
# A Keyboard map is read in as patch to the current map.
#
# File format:
# - comment lines start with '#'
# - keyword lines start with '!keyword'
# - normal line has 'keysym/scancode row column shiftflag'
#
# Keywords and their lines are:
# '!CLEAR'               clear whole table
# '!INCLUDE filename'    read file as mapping file
# '!LSHIFT row col'      left shift keyboard row/column
# '!RSHIFT row col'      right shift keyboard row/column
# '!VSHIFT shiftkey'     virtual shift key (RSHIFT or LSHIFT)
# '!UNDEF keysym'        remove keysym from table
#
# Shiftflag can have the values:
# 0      key is not shifted for this keysym/scancode
# 1      key is shifted for this keysym/scancode
# 2      left shift
# 4      right shift
# 8      key can be shifted or not with this keysym/scancode
# 16     deshift key for this keysym/scancode
# 32     another definition for this keysym/scancode follows
#
# Negative row values:
# 'keysym -1 n' joystick #1, direction n
# 'keysym -2 n' joystick #2, direction n
# 'keysym -3 0' first RESTORE key
# 'keysym -3 1' second RESTORE key
# 'keysym -4 0' 40/80 column key
# 'keysym -4 1' CAPS (ASCII/DIN) key
#

!CLEAR
!LSHIFT 1 7
!RSHIFT 6 4
!VSHIFT RSHIFT

Control_L 7 2 8 /* Ctrl */
Super_L 7 5 0   /* Commodore Key */
BackSpace 0 0 8
Down 0 7 8
Escape 7 7 8    /* RunStop */
F1 0 4 8
F2 0 4 1
F3 0 5 8
F4 0 5 1
F5 0 6 8
F6 0 6 1
F7 0 3 8
F8 0 3 1
Home 6 3 8      /* Clr */
Insert 0 0 16   /* Insert */
Left 0 2 1
Return 0 1 8
Right 0 2 8
Shift_L 1 7 2
Shift_R 6 4 4
Up 0 7 1
KP_Add 5 0 8          /* + */
KP_Subtract 5 3 8     /* - */
Apostrophe 6 6 8      /* Up Arrow */
LeftBracket 5 5 8     /* : -> : */
SemiColon  6 1 8      /* * -> * */
Comma  5 7 8          /* , -> , */
BackSlash  5 6 8      /* @ -> @ */
Pound 6 5 0           /* equal */
Equals  6 5 8         /* = -> = */
Period  5 4 8         /* . */
Dash  6 0 8           /* Pound */
SingleQuote 6 6 8     /* Up Arrow */
Slash  6 7 8          /* / -> / */
Space 7 4 8           /* space */
Insert 6 0 8          /* sterling */
RightBracket  6 2 8   /* ; -> ; */
BackQuote 7 1 0       /* arrowleft */
Del 6 6 8             /* arrowup */
0 4 3 8
1 7 0 8
2 7 3 8
3 1 0 8
4 1 3 8
5 2 0 8
6 2 3 8
7 3 0 8
8 3 3 8
9 4 0 8
a 1 2 8
b 3 4 8
c 2 4 8
d 2 2 8
e 1 6 8
f 2 5 8
g 3 2 8
h 3 5 8
i 4 1 8
j 4 2 8
k 4 5 8
l 5 2 8
m 4 4 8
n 4 7 8
o 4 6 8
p 5 1 8
q 7 6 8
r 2 1 8
s 1 5 8
t 2 6 8
u 3 6 8
v 3 7 8
w 1 1 8
x 2 7 8
y 3 1 8
z 1 4 8

# Restore key mappings
CapsLock -4 1
Tab -3 0