From b74d292847b22cf282ff8ae7d1b51df34176ce4d Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Wed, 25 Mar 2026 03:08:11 -0400 Subject: Banish cgetc(), and all its annoyances. Much more flexible and precise keyboard control, see keytab.[ch] and kgetc.[ch] --- src/keytab.c | 274 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 274 insertions(+) create mode 100644 src/keytab.c (limited to 'src/keytab.c') diff --git a/src/keytab.c b/src/keytab.c new file mode 100644 index 0000000..5fd8963 --- /dev/null +++ b/src/keytab.c @@ -0,0 +1,274 @@ +#include "keytab.h" + +/* +This table is a modified version of the one from the XL OS ROM. +Atari uses $80 to mean "unused". Here, I use 0 to mean unused. +Also, Atari's table is only 192 bytes. This is 256 bytes because +it includes ctrl-shift combos. +*/ + +char keytab[256] = { +// no modifier + 0x6c, // 0 = l + 0x6a, // 1 = j + 0x3b, // 2 = ; + XCH_SCR1, // 3 = 1200XL F1 + XCH_SCR2, // 4 = 1200XL F2 + 0x6b, // 5 = k + 0x2b, // 6 = + + 0x2a, // 7 = * + 0x6f, // 8 = o + 0x00, // 9 = (unused) + 0x70, // 10 = p + 0x75, // 11 = u + 0x9b, // 12 = EOL + 0x69, // 13 = i + 0x2d, // 14 = - + 0x3d, // 15 = = + 0x76, // 16 = v + 0x00, // 17 = (unused) + 0x63, // 18 = c + XCH_SCR3, // 19 = 1200XL F3 + XCH_SCR4, // 20 = 1200XL F4 + 0x62, // 21 = b + 0x78, // 22 = x + 0x7a, // 23 = z + 0x34, // 24 = 4 + 0x00, // 25 = (unused) + 0x33, // 26 = 3 + 0x36, // 27 = 6 + 0x1b, // 28 = esc + 0x35, // 29 = 5 + 0x32, // 30 = 2 + 0x31, // 31 = 1 + 0x2c, // 32 = , + 0x20, // 33 = space + 0x2e, // 34 = . + 0x6e, // 35 = n + 0x00, // 36 = (unused) + 0x6d, // 37 = m + 0x2f, // 38 = / + 0x02, // 39 = inverse (toggle bold) + 0x72, // 40 = r + 0x00, // 41 = (unused) + 0x65, // 42 = e + 0x79, // 43 = y + XCH_TAB, // 44 = tab + 0x74, // 45 = t + 0x77, // 46 = w + 0x71, // 47 = q + 0x39, // 48 = 9 + 0x00, // 49 = (unused) + 0x30, // 50 = 0 + 0x37, // 51 = 7 + XCH_BS, // 52 = ~ + 0x38, // 53 = 8 + 0x3c, // 54 = < + 0x3e, // 55 = > + 0x66, // 56 = f + 0x68, // 57 = h + 0x64, // 58 = d + 0x00, // 59 = (unused) + XCH_CAPS, // 60 = caps toggle + 0x67, // 61 = g + 0x73, // 62 = s + 0x61, // 63 = a + +// shift + 0x4c, // 64 = L + 0x4a, // 65 = J + 0x3a, // 66 = : + XCH_SCR5, // 67 = 1200XL Shift-F1 + XCH_SCR6, // 68 = 1200XL Shift-F2 + 0x4b, // 69 = K + 0x5c, // 70 = "\" + 0x5e, // 71 = ^ + 0x4f, // 72 = O + 0x00, // 73 = (unused) + 0x50, // 74 = P + 0x55, // 75 = U + 0x9b, // 76 = EOL + 0x49, // 77 = I + 0x5f, // 78 = _ + 0x7c, // 79 = | + 0x56, // 80 = V + 0x00, // 81 = (unused) + 0x43, // 82 = C + XCH_SCR7, // 83 = 1200XL Shift-F3 + XCH_ACTIVE, // 84 = 1200XL Shift-F4 + 0x42, // 85 = B + 0x58, // 86 = X + 0x5a, // 87 = Z + 0x24, // 88 = $ + 0x00, // 89 = (unused) + 0x23, // 90 = # + 0x26, // 91 = & + 0x60, // 92 = ` (atari shift-esc) + 0x25, // 93 = % + 0x22, // 94 = " + 0x21, // 95 = ! + 0x5b, // 96 = [ + 0x20, // 97 = space + 0x5d, // 98 = ] + 0x4e, // 99 = N + 0x00, // 100 = (unused) + 0x4d, // 101 = M + 0x3f, // 102 = ? + 0x00, // 103 = inverse + 0x52, // 104 = R + 0x00, // 105 = (unused) + 0x45, // 106 = E + 0x59, // 107 = Y + 0x00, // 108 = shift-tab + 0x54, // 109 = T + 0x57, // 110 = W + 0x51, // 111 = Q + 0x28, // 112 = ( + 0x00, // 113 = (unused) + 0x29, // 114 = ) + 0x27, // 115 = ' + 0x9c, // 116 = del line + 0x40, // 117 = @ + XCH_CLS, // 118 = } + 0x9d, // 119 = ins line + 0x46, // 120 = F + 0x48, // 121 = H + 0x44, // 122 = D + 0x00, // 123 = (unused) + XCH_CAPS, // 124 = caps lock + 0x47, // 125 = G + 0x53, // 126 = S + 0x41, // 127 = A + +// ctrl + 0x0c, // 128 = ^L + 0x00, // 129 = ^J + 0x00, // 130 = ^:, unused + 0x00, // 131 = (unused) + 0x00, // 132 = (unused) + 0x0b, // 133 = ^K + XCH_LEFT, // 134 = atari left arrow + XCH_RIGHT, // 135 = atari right arrow + 0x0f, // 136 = ^O + 0x00, // 137 = (unused) + 0x10, // 138 = ^P + 0x15, // 139 = ^U + 0x9b, // 140 = EOL + XCH_ITAL, // 141 = ^I: IRC italics format + XCH_UP, // 142 = atari up arrow + XCH_DOWN, // 143 = atari down arrow + 0x16, // 144 = ^V + 0x00, // 145 = (unused) + 0x03, // 146 = ^C + 0x00, // 147 = 1200XL ctrl-F3 (?) + 0x00, // 148 = (unused) + XCH_LWORD, // 149 = ^B + 0x18, // 150 = ^X + 0x1a, // 151 = ^Z + XCH_SCR4, // 152 = inverse 4 (switch to screen 4) + 0x00, // 153 = (unused) + XCH_SCR3, // 154 = inverse 3 (switch to screen 3) + XCH_SCR6, // 155 = inverse 6 (switch to screen 6) + 0x7e, // 156 = ~ (tilde, aka atari ctrl-esc) + XCH_SCR5, // 157 = inverse 5 (switch to screen 5) + XCH_SCR2, // 158 = inverse 2 (switch to screen 2) + XCH_SCR1, // 159 = inverse 1 (switch to screen 1) + 0x7b, // 160 = { + 0x20, // 161 = space + 0x7d, // 162 = } + 0x0e, // 163 = ^N + 0x00, // 164 = (unused) + 0x00, // 165 = ^M + 0x00, // 166 = (unused) + 0x00, // 167 = inverse + 0x12, // 168 = ^R + 0x00, // 169 = (unused) + 0x05, // 170 = ^E + 0x19, // 171 = ^Y + 0x00, // 172 = ctrl-tab + 0x14, // 173 = ^T + 0x17, // 174 = ^W + 0x11, // 175 = ^Q + 0x00, // 176 = inverse 9 (if we ever support 9 screens) + 0x00, // 177 unused? not XCH_SCR1? + 0x00, // 178 = inverse 0 (if we ever support 10 screens) + XCH_SCR7, // 179 = inverse 7 (switch to screen 7) + 0xfe, // 180 = del chr + 0x00, // 181 = inverse 8 (if we ever support 8 screens) + XCH_CLS, // 182 = } + 0xff, // 183 = ins chr + XCH_RWORD, // 184 = ^F + 0x08, // 185 = ^H + 0x04, // 186 = ^D + 0x00, // 187 = (unused) + 0x00, // 188 = ctrl-caps (unused) + 0x07, // 189 = ^G + 0x13, // 190 = ^S + 0x01, // 191 = ^A + +// ctrl+shift + 0x00, // 192 + 0x00, // 193 + 0x00, // 194 + 0x00, // 195 + 0x00, // 196 + 0x00, // 197 + 0x00, // 198 + 0x00, // 199 + 0x00, // 200 + 0x00, // 201 + 0x00, // 202 + XCH_UNDER, // 203 + 0x00, // 204 + 0x00, // 205 + XCH_LWORD, // 206, ctrl+shift+up + XCH_RWORD, // 207, ctrl+shift+down + 0x00, // 208 + 0x00, // 209 + 0x00, // 210 + 0x00, // 211 + 0x00, // 212 + 0x00, // 213 + 0x00, // 214 + 0x00, // 215 + 0x00, // 216 + 0x00, // 217 + 0x00, // 218 + 0x00, // 219 + 0x00, // 220 + 0x00, // 221 + 0x00, // 222 + 0x00, // 223 + 0x00, // 224 + 0x00, // 225 + 0x00, // 226 + 0x00, // 227 + 0x00, // 228 + 0x00, // 229 + 0x00, // 230 + 0x00, // 231 + 0x00, // 232 + 0x00, // 233 + 0x00, // 234 + 0x00, // 235 + 0x00, // 236 + 0x00, // 237 + 0x00, // 238 + 0x00, // 239 + 0x00, // 240 + 0x00, // 241 + 0x00, // 242 + 0x00, // 243 + 0x00, // 244 + 0x00, // 245 + 0x00, // 246 + 0x00, // 247 + 0x00, // 248 + 0x00, // 249 + 0x00, // 250 + 0x00, // 251 + 0x00, // 252 + 0x00, // 253 + 0x00, // 254 + 0x00, // 255 +}; -- cgit v1.2.3