Use clz instruction to calculate integer logarithms, speeds up decoding of one flac...
[kugel-rb.git] / manual / plugins / chip8emulator.tex
blob79fb095e6d6b25b5017dfff6ad5beed3bc7a6249
1 \subsection{\label{ref:Chip8emulator}Chip{}-8 Emulator}
2 Chip8 is a kind of assembly language for a long-gone architecture.
3 This plugin runs games written using the chip8 instructions.
4 To start a game open a \fname{.ch8} file in the \setting{File Browser}
6 There are lots of tiny Chip8 games (usually only about 256 bytes to a
7 couple of KB) which were made popular by the HP48
8 calculator's emulator for them. The original Chip8 had
9 64x32 pixel graphics, and the new superchip emulator supports 128x64
10 graphics.
12 The only problem is that they are based on a 4x4 keyboard, but since most
13 games do not use all of the buttons, this can easily be worked around.
15 To do this, one may put a \fname{.c8k} file with the same name as the
16 original program which contains new key mappings (for \fname{BLINKY.ch8}, one
17 writes a \fname{BLINKY.c8k} file). That \fname{.c8k} file contains 16
18 characters describing the mapping from the Chip8 keyboard to the default key
19 mapping (that way, several Chip8 keys can be pressed using only one
20 Rockbox key). For example, a file containing the single line:
21 \begin{code}
22 0122458469ABCDEF
23 \end{code}
24 would correspond to the following non-default mappings:
26 3 $\rightarrow$ 2, 6 $\rightarrow$ 8, 7 $\rightarrow$4, 8 $\rightarrow$ 6.
28 The default keymappings are:
29 \begin{table}
30 \begin{center}
31 \begin{tabularx}{.9\textwidth}{c|ccccccccccccccccc}
32 \toprule
33 Chip8 & Off & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9
34 & A & B & C & D & E & F\\
35 \midrule
36 \begin{sideways}Key\end{sideways}
38 % key "off"
39 \begin{sideways}
40 \opt{RECORDER_PAD,ONDIO_PAD,IRIVER_H100_PAD,IRIVER_H300_PAD}{\ButtonOff}
41 \opt{IPOD_4G_PAD,IPOD_3G_PAD}{\ButtonMenu}
42 \opt{IAUDIO_X5_PAD,IRIVER_H10_PAD,SANSA_E200_PAD,SANSA_C200_PAD,GIGABEAT_PAD,MROBE100_PAD}{\ButtonPower}
43 \opt{GIGABEAT_S_PAD}{\ButtonBack}
44 \end{sideways}
46 % Key "0"
48 % "Key "1"
49 \begin{sideways}
50 \opt{RECORDER_PAD}{\ButtonFOne}
51 \opt{ONDIO_PAD}{\ButtonUp}
52 \opt{GIGABEAT_PAD,GIGABEAT_S_PAD,MROBE100_PAD}{\ButtonMenu}
53 \end{sideways}
55 % Key "2"
56 \begin{sideways}
57 \opt{RECORDER_PAD,ONDIO_PAD}{\ButtonUp}
58 \opt{IPOD_4G_PAD,IPOD_3G_PAD,SANSA_E200_PAD}{\ButtonScrollBack}
59 \opt{IRIVER_H100_PAD,IRIVER_H300_PAD,IAUDIO_X5_PAD,GIGABEAT_PAD%
60 ,GIGABEAT_S_PAD,MROBE100_PAD}{\ButtonUp}
61 \opt{IRIVER_H10_PAD}{\ButtonScrollUp}
62 \opt{SANSA_C200_PAD}{\ButtonVolUp}
63 \end{sideways}
65 % Key "3"
66 \begin{sideways}
67 \opt{RECORDER_PAD}{\ButtonFThree}
68 \opt{MROBE100_PAD}{\ButtonPlay}
69 \opt{GIGABEAT_PAD,GIGABEAT_S_PAD}{\ButtonVolDown}
70 \end{sideways}
72 % Key "4"
73 \begin{sideways}
74 \opt{RECORDER_PAD,ONDIO_PAD,IRIVER_H100_PAD,IRIVER_H300_PAD,IPOD_4G_PAD%
75 ,IPOD_3G_PAD,IAUDIO_X5_PAD,IRIVER_H10_PAD,SANSA_E200_PAD,SANSA_C200_PAD%
76 ,GIGABEAT_PAD,GIGABEAT_S_PAD,MROBE100_PAD}{\ButtonLeft}
77 \end{sideways}
79 % Key "5"
80 \begin{sideways}
81 \opt{RECORDER_PAD}{\ButtonPlay}
82 \opt{ONDIO_PAD}{\ButtonMenu}
83 \opt{IRIVER_H100_PAD,IRIVER_H300_PAD,IAUDIO_X5_PAD,SANSA_E200_PAD%
84 ,SANSA_C200_PAD,GIGABEAT_PAD,GIGABEAT_S_PAD,MROBE100_PAD}{\ButtonSelect}
85 \opt{IPOD_4G_PAD,IPOD_3G_PAD,IRIVER_H10_PAD}{\ButtonPlay}
86 \end{sideways}
88 % Key "6"
89 \begin{sideways}
90 \opt{RECORDER_PAD,ONDIO_PAD,IRIVER_H100_PAD,IRIVER_H300_PAD,IPOD_4G_PAD%
91 ,IPOD_3G_PAD,IAUDIO_X5_PAD,IRIVER_H10_PAD,SANSA_E200_PAD,SANSA_C200_PAD%
92 ,GIGABEAT_PAD,GIGABEAT_S_PAD,MROBE100_PAD}{\ButtonRight}
93 \end{sideways}
95 % Key "7"
96 \begin{sideways}
97 \opt{RECORDER_PAD}{\ButtonFTwo}
98 \opt{MROBE100_PAD}{\ButtonDisplay}
99 \opt{GIGABEAT_PAD,GIGABEAT_S_PAD}{\ButtonVolUp}
100 \end{sideways}
102 % Key "8"
103 \begin{sideways}
104 \opt{RECORDER_PAD,ONDIO_PAD,IRIVER_H100_PAD,IRIVER_H300_PAD%
105 ,GIGABEAT_PAD,GIGABEAT_S_PAD,MROBE100_PAD}{\ButtonDown}
106 \opt{IPOD_4G_PAD,IPOD_3G_PAD,SANSA_E200_PAD}{\ButtonScrollFwd}
107 \opt{IAUDIO_X5_PAD}{\ButtonDown}
108 \opt{IRIVER_H10_PAD}{\ButtonScrollDown}
109 \opt{SANSA_C200_PAD}{\ButtonVolDown}
110 \end{sideways}
112 % Key "9"
113 \begin{sideways}
114 \opt{RECORDER_PAD}{\ButtonOn}
115 \opt{GIGABEAT_PAD}{\ButtonA}
116 \opt{GIGABEAT_S_PAD}{\ButtonPlay}
117 \end{sideways}
119 % Key "A"
121 % Key "B"
123 % Key "C"
125 % Key "D"
127 % Key "E"
129 % Key "F"
130 \\\bottomrule
131 \end{tabularx}
132 \end{center}
133 \end{table}
135 Some places where can you can find \fname{.ch8} files:
136 \begin{itemize}
137 \item The PluginChip8 page on www.rockbox.org has several attached:
138 \wikilink{PluginChip8}
139 \item Check out the HP48 chip games section:
140 \url{http://www.hpcalc.org/hp48/games/chip/}
141 \item PC emulator by the guy who wrote the HP48 emulator:
142 \url{http://www.pdc.kth.se/~lfo/chip8/CHIP8.htm}
143 \item Links to other chip8 emulators:
144 \url{http://www.zophar.net/chip8.html}
145 \end{itemize}