Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Bunch of minor cleanups. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | ams/sdl |
| Files: | files | file ages | folders |
| SHA3-256: |
2d70efbcc9785975144cd9c8a8a32135 |
| User & Date: | ams 2024-06-26 08:17:28.745 |
Context
|
2024-06-26
| ||
| 08:37 | Get rid of some compiler warnings. check-in: affdaf69ec user: ams tags: ams/sdl | |
| 08:17 | Bunch of minor cleanups. check-in: 2d70efbcc9 user: ams tags: ams/sdl | |
| 05:04 | uch11-backend.h: Include <pthread.h>. check-in: 6d8b526a75 user: ams tags: ams/sdl | |
Changes
Changes to cadet.c.
1 2 3 4 5 6 7 | /* cadet.c --- Space Cadet (aka new) keyboard translation */ #include <stdint.h> #include <string.h> #include <stdbool.h> | | | | < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /* cadet.c --- Space Cadet (aka new) keyboard translation */ #include <stdint.h> #include <string.h> #include <stdbool.h> #include "iob.h" #include "kbd.h" #include "lmch.h" #include "misc.h" #include "ucode.h" #include "utrace.h" /* * Second index in CADET_KBD_MAP, gives which shift must be generated. */ |
| ︙ | ︙ | |||
160 161 162 163 164 165 166 |
if (!keydown && allup_key() == true)
return;
oshift = cadet_shifts;
DEBUG(TRACE_KBD, "kbd (cadet): keysym = 0%o, bi = %d\n", keysym, bi);
if (bi != -1) {
int bucky;
| | | 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
if (!keydown && allup_key() == true)
return;
oshift = cadet_shifts;
DEBUG(TRACE_KBD, "kbd (cadet): keysym = 0%o, bi = %d\n", keysym, bi);
if (bi != -1) {
int bucky;
bucky = kbd_modifier_map[bi];
if (bucky == KBD_NoSymbol) {
WARNING(TRACE_KBD, "kbd (cadet): unbound modifier (keysym = 0%o)\n", keysym);
return;
}
scc = cadet_modifier_map[bucky];
cadet_process_shift(scc, keydown);
DEBUG(TRACE_KBD, "kbd (cadet): bucky pressed; scc = 0%o, shifts = 0%o (previous: 0%o)\n", scc, cadet_shifts, oshift);
|
| ︙ | ︙ |
Changes to cadet.h.
1 2 3 4 5 6 7 8 | #pragma once int cadet_shifts; extern void cadet_init(void); extern void cadet_allup_event(int); extern void cadet_process_key(int, int, int, bool (*)(void)); extern void cadet_press_bucky(int, int *, int *); | > > | 1 2 3 4 5 6 7 8 9 10 | #pragma once #include <stdbool.h> int cadet_shifts; extern void cadet_init(void); extern void cadet_allup_event(int); extern void cadet_process_key(int, int, int, bool (*)(void)); extern void cadet_press_bucky(int, int *, int *); |
Changes to idle.c.
| ︙ | ︙ | |||
8 9 10 11 12 13 14 | #include <unistd.h> #include "idle.h" #include "tv.h" #include "ucode.h" #include "usim.h" | | | | | | | | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
#include <unistd.h>
#include "idle.h"
#include "tv.h"
#include "ucode.h"
#include "usim.h"
static int working;
static size_t last_work;
static size_t last_cycle;
static int reported_idle; /*debug */
static int drl;
static int disk_run_light;
size_t idle_cycles;
size_t idle_quantum;
size_t idle_timeout;
static idle_change_handler change_handler;
static int maxfd;
static int registered_fds[FD_SETSIZE];
void
idle_init(void)
{
int val;
sym_find(&sym_mcr, "A-DISK-RUN-LIGHT", &val);
|
| ︙ | ︙ |
Changes to kbd.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /* kbd.c --- keyboard handling */ #include <err.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "iob.h" #include "kbd.h" #include "usim.h" #include "utrace.h" int kbd_type = 1; /* Default is "cadet". */ uint32_t kbd_scancode; #define KEY_QUEUE_LEN 10 static int key_queue[KEY_QUEUE_LEN]; static int key_queue_optr; static int key_queue_iptr; static int key_queue_free = KEY_QUEUE_LEN; /* * Translation map for the host keyboard to a corresponding Lisp * Machine character or modifier. */ int kbd_map[65535]; | > > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
/* kbd.c --- keyboard handling */
#include <err.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "iob.h"
#include "kbd.h"
#include "cadet.h"
#include "knight.h"
#include "lmch.h"
#include "usim.h"
#include "utrace.h"
int kbd_type = 1; /* Default is "cadet". */
uint32_t kbd_scancode;
#define KEY_QUEUE_LEN 10
static int key_queue[KEY_QUEUE_LEN];
static int key_queue_optr;
static int key_queue_iptr;
static int key_queue_free = KEY_QUEUE_LEN;
/*
* Translation map for the host keyboard to a corresponding Lisp
* Machine character or modifier.
*/
int kbd_map[65535];
int kbd_modifier_map[8];
void
kbd_queue_key_event(int ev)
{
int v;
v = (1 << 16) | ev;
|
| ︙ | ︙ | |||
214 215 216 217 218 219 220 |
#include <X11/X.h> // for FOOMapIndex meh
void
kbd_default_map(void)
{
for (int i = 0; i < (int) NELEM(kbd_map); i++)
kbd_map[i] = LMCH_NoSymbol;
| | | | | | | | | | | | 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
#include <X11/X.h> // for FOOMapIndex meh
void
kbd_default_map(void)
{
for (int i = 0; i < (int) NELEM(kbd_map); i++)
kbd_map[i] = LMCH_NoSymbol;
for (int i = 0; i < (int) NELEM(kbd_modifier_map); i++)
kbd_modifier_map[i] = KBD_NoSymbol;
/* *INDENT-OFF* */
/*
* Initialize keyboard modifiers
*/
kbd_modifier_map[ShiftMapIndex] = KBD_SHIFT; /* Shift */
kbd_modifier_map[LockMapIndex] = KBD_SHIFT_LOCK; /* Caps Lock */
kbd_modifier_map[ControlMapIndex] = KBD_CONTROL; /* Control */
kbd_modifier_map[Mod1MapIndex] = KBD_META; /* Alt */
kbd_modifier_map[Mod2MapIndex] = KBD_NoSymbol; /* Num Lock */
kbd_modifier_map[Mod3MapIndex] = KBD_NoSymbol; /* ??? */
kbd_modifier_map[Mod4MapIndex] = KBD_TOP; /* Super */
kbd_modifier_map[Mod5MapIndex] = KBD_NoSymbol; /* AltGR */
/*
* Initialize keyboard mapping.
*
* We cann't reuse lmch.defs here because the Lisp Machine
* charachter set has names and charachters that do not have a
* corresponding mapping in X11.
|
| ︙ | ︙ |
Changes to kbd.h.
1 2 3 4 | #pragma once #include <stdint.h> | < < < < | | | < | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #pragma once #include <stdint.h> /* * This is an index into knight_modifier_map or cadet_modifier_map, * which is used via kbd_modifier_map (which if KBD_NoSymbol means the * modifier is unmapped). */ #define KBD_NoSymbol -1 #define KBD_SHIFT 0 /* SHIFT BITS */ #define KBD_TOP 1 /* TOP BITS */ #define KBD_CONTROL 2 /* CONTROL BITS */ #define KBD_META 3 /* META BITS */ #define KBD_SHIFT_LOCK 4 /* SHIFT LOCK / CAPS LOCK ON CADET */ /* The following do not exsit on the Knight keyboard. */ #define KBD_MODE_LOCK 5 #define KBD_GREEK 6 #define KBD_REPEAT 7 #define KBD_ALT_LOCK 8 #define KBD_HYPER 9 #define KBD_SUPER 10 extern int kbd_type; extern uint32_t kbd_scancode; extern int kbd_map[65535]; extern int kbd_modifier_map[8]; extern void kbd_init(void); extern void kbd_default_map(void); extern void kbd_event(int, int); extern void kbd_queue_key_event(int); extern void kbd_dequeue_key_event(void); extern void kbd_warm_boot_key(void); extern int kbd_lmchar(const char *); |
Changes to knight.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /* knight.c --- Knight (aka old) keyboard */ #include <err.h> #include <stdio.h> #include <string.h> #include "kbd.h" #include "utrace.h" #define KNIGHT_VANILLA 0 /* VANILLA */ #define KNIGHT_SHIFT 0300 /* SHIFT BITS */ #define KNIGHT_TOP 01400 /* TOP BITS */ #define KNIGHT_CONTROL 06000 /* CONTROL BITS */ #define KNIGHT_META 030000 /* META BITS */ | > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | /* knight.c --- Knight (aka old) keyboard */ #include <err.h> #include <stdio.h> #include <string.h> #include "kbd.h" #include "lmch.h" #include "utrace.h" #define KNIGHT_VANILLA 0 /* VANILLA */ #define KNIGHT_SHIFT 0300 /* SHIFT BITS */ #define KNIGHT_TOP 01400 /* TOP BITS */ #define KNIGHT_CONTROL 06000 /* CONTROL BITS */ #define KNIGHT_META 030000 /* META BITS */ |
| ︙ | ︙ |
Changes to m32.h.
| ︙ | ︙ | |||
13 14 15 16 17 18 19 | co = (ci) ? (((b) >= ~(a)) ? 0:1) : (((b) > ~(a)) ? 0:1) ; #define sub32(a, b, ci, out, co) \ out = (a) - (b) - ((ci) ? 0 : 1); \ co = (unsigned)(out) < (unsigned)(a) ? 1 : 0; #define abs32(a) \ (a) < 0 ? ~(a) + 1 : (a) | | | 13 14 15 16 17 18 19 20 | co = (ci) ? (((b) >= ~(a)) ? 0:1) : (((b) > ~(a)) ? 0:1) ; #define sub32(a, b, ci, out, co) \ out = (a) - (b) - ((ci) ? 0 : 1); \ co = (unsigned)(out) < (unsigned)(a) ? 1 : 0; #define abs32(a) \ (a) < 0 ? ~(a) + 1 : (a) extern uint32_t rol32(uint32_t, int); |
Changes to misc.h.
| ︙ | ︙ | |||
36 37 38 39 40 41 42 | extern char *read_virt_string_fd(int, unsigned int, int); extern uint64_t load_byte(uint64_t, int, int); extern uint64_t deposit_byte(uint64_t, int, int, uint64_t); extern uint32_t ldb(int, uint32_t); extern uint32_t dpb(uint32_t, int, uint32_t); | | | | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | extern char *read_virt_string_fd(int, unsigned int, int); extern uint64_t load_byte(uint64_t, int, int); extern uint64_t deposit_byte(uint64_t, int, int, uint64_t); extern uint32_t ldb(int, uint32_t); extern uint32_t dpb(uint32_t, int, uint32_t); extern uint32_t bit_test(uint32_t, uint32_t); extern bool ldb_test(int, uint32_t); extern void dump_write_header(int, uint32_t, uint32_t); extern void dump_write_data(int, ssize_t, void *); extern void dump_write_segment(int, uint32_t, uint32_t, uint32_t *); extern void dump_write_value(int, uint32_t, uint32_t); extern int32_t dump_find_segment(int, uint32_t); extern int32_t dump_read_segment_single_value(int, uint32_t); |
Changes to sdl1.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | /* sdl1.c --- SDL1 routines used by the TV and KBD interfaces */ #include <signal.h> #include <SDL.h> #include "tv.h" #include "kbd.h" #include "mouse.h" #include "utrace.h" #include "idle.h" SDL_Surface *screen; #include <X11/keysym.h> // for XK_FOO meh #include <X11/X.h> // for FOOMapIndex meh | > > > > < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
/* sdl1.c --- SDL1 routines used by the TV and KBD interfaces
*/
#include <signal.h>
#include <stdbool.h>
#include <SDL.h>
#include "tv.h"
#include "kbd.h"
#include "cadet.h"
#include "knight.h"
#include "mouse.h"
#include "utrace.h"
#include "idle.h"
#include "misc.h"
SDL_Surface *screen;
#include <X11/keysym.h> // for XK_FOO meh
#include <X11/X.h> // for FOOMapIndex meh
static void
sdl1_cleanup(void)
{
SDL_Quit();
}
|
| ︙ | ︙ | |||
196 197 198 199 200 201 202 |
state = SDL_GetKeyState(&statesize);
for (int i = 0; allup && i < statesize; i++) {
int bucky;
if (state[i] != 1)
continue;
| | > > > > > > > > > > > > | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
state = SDL_GetKeyState(&statesize);
for (int i = 0; allup && i < statesize; i++) {
int bucky;
if (state[i] != 1)
continue;
bucky = -1;
// This needs to be cleaned up -- translates scancode to bucky xk/index
switch (i) {
case SDLK_LSHIFT: case SDLK_RSHIFT: bucky = kbd_modifier_map[ShiftMapIndex]; break;
case SDLK_LCTRL: case SDLK_RCTRL: bucky = kbd_modifier_map[ControlMapIndex]; break;
case SDLK_LALT: case SDLK_RALT: bucky = kbd_modifier_map[Mod1MapIndex]; break;
// case SDLK_LGUI: case SDLK_RGUI: bucky = kbd_modifier_map[Mod4MapIndex]; break;
// case SDLK_LSUPER: case SDLK_RSUPER:
// case SDLK_MODE: bucky = kbd_modifier_map[Mod5MapIndex]; break;
// case SDLK_MENU: bucky = kbd_modifier_map[KBD_NoSymbol]; break;
// case SDLK_COMPOSE: bucky = kbd_modifier_map[]; break;
case SDLK_CAPSLOCK:bucky = kbd_modifier_map[LockMapIndex]; break;
}
DEBUG(TRACE_KBD, "cadet_allup_key() - bucky pressed (%d), i = %d\n", bucky, i);
cadet_press_bucky(bucky, &mods, &shifts);
}
if (allup == true) {
DEBUG(TRACE_KBD, "cadet_allup_key() - all-up event; mods = 0%o, shifts = 0%o\n", mods, shifts);
cadet_shifts = shifts;
cadet_allup_event(mods);
|
| ︙ | ︙ | |||
251 252 253 254 255 256 257 |
// if (e->xkey.state & Mod4Mask)
// knight_process_bucky(Mod4MapIndex, &bi);
// if (e->xkey.state & Mod5Mask)
// knight_process_bucky(Mod5MapIndex, &bi);
knight_process_key(e.keysym.sym, bi, keydown);
} else {
bi = sdl1_bucky(e);
| | > > > > > > | | 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
// if (e->xkey.state & Mod4Mask)
// knight_process_bucky(Mod4MapIndex, &bi);
// if (e->xkey.state & Mod5Mask)
// knight_process_bucky(Mod5MapIndex, &bi);
knight_process_key(e.keysym.sym, bi, keydown);
} else {
bi = sdl1_bucky(e);
cadet_process_key(keysym /* xk_keysym */ , bi, keydown, &cadet_allup_key);
}
}
void
update(int u_minh, int u_minv, int hs, int vs)
{
SDL_UpdateRect(screen, u_minh, u_minv, hs, vs);
}
void
sdl1_event(void)
{
SDL_Event ev;
tv_update_screen(&update);
kbd_dequeue_key_event();
while (SDL_PollEvent(&ev)) {
switch (ev.type) {
case SDL_VIDEOEXPOSE:
SDL_UpdateRect(screen, 0, 0, screen->w, screen->h);
break;
case SDL_KEYDOWN:
|
| ︙ | ︙ | |||
295 296 297 298 299 300 301 |
}
void
sdl1_init(void)
{
NOTICE(TRACE_USIM, "tv: using SDL1 backend for monitor and keyboard\n");
| | | | 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
}
void
sdl1_init(void)
{
NOTICE(TRACE_USIM, "tv: using SDL1 backend for monitor and keyboard\n");
tv_foreground = 0xff; // White
tv_background = 0x00; // Black
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE)) {
fprintf(stderr, "SDL_Init(): %s", SDL_GetError());
exit(1);
}
/*
* We still want Ctrl-C to work - undo the SDL redirections.
|
| ︙ | ︙ |
Changes to sdl1.h.
1 2 3 4 5 6 7 | #pragma once #include <SDL.h> extern void sdl1_init(void); extern void sdl1_event(void); | < < < < < | | 1 2 3 4 5 6 7 8 9 10 | #pragma once #include <SDL.h> extern void sdl1_init(void); extern void sdl1_event(void); SDL_Surface *screen; /* hack */ extern void sdl1_beep(int); |
Changes to sdl2.c.
| ︙ | ︙ | |||
150 151 152 153 154 155 156 |
int bucky;
if (state[i] != 1)
continue; /* bucky not pressed */
bucky = -1;
// This needs to be cleaned up -- translates scancode to bucky xk/index
switch (SDL_GetKeyFromScancode(i)) {
| | | | | | | | | | 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
int bucky;
if (state[i] != 1)
continue; /* bucky not pressed */
bucky = -1;
// This needs to be cleaned up -- translates scancode to bucky xk/index
switch (SDL_GetKeyFromScancode(i)) {
case SDLK_LSHIFT: case SDLK_RSHIFT: bucky = kbd_modifier_map[ShiftMapIndex]; break;
case SDLK_LCTRL: case SDLK_RCTRL: bucky = kbd_modifier_map[ControlMapIndex]; break;
case SDLK_LALT: case SDLK_RALT: bucky = kbd_modifier_map[Mod1MapIndex]; break;
case SDLK_LGUI: case SDLK_RGUI: bucky = kbd_modifier_map[Mod4MapIndex]; break;
// case SDLK_LSUPER: case SDLK_RSUPER:
// case SDLK_MODE: bucky = kbd_modifier_map[Mod5MapIndex]; break;
// case SDLK_MENU: bucky = kbd_modifier_map[KBD_NoSymbol]; break;
// case SDLK_COMPOSE: bucky = kbd_modifier_map[]; break;
case SDLK_CAPSLOCK:bucky = kbd_modifier_map[LockMapIndex]; break;
}
DEBUG(TRACE_KBD, "cadet_allup_key() - bucky pressed (%d), i = %d\n", bucky, i);
cadet_press_bucky(bucky, &mods, &shifts);
}
if (allup == true) {
DEBUG(TRACE_KBD, "cadet_allup_key() - all-up event; mods = 0%o, shifts = 0%o\n", mods, shifts);
cadet_shifts = shifts;
|
| ︙ | ︙ | |||
229 230 231 232 233 234 235 |
}
void
sdl2_event(void)
{
SDL_Event ev;
| | | 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
}
void
sdl2_event(void)
{
SDL_Event ev;
tv_update_screen(&update);
kbd_dequeue_key_event();
if (is_mouse_warp) {
is_mouse_warp = 0;
SDL_WarpMouseInWindow(window, mouse_warp_x, mouse_warp_y);
}
while (SDL_PollEvent(&ev)) {
switch (ev.type) {
|
| ︙ | ︙ | |||
344 345 346 347 348 349 350 |
}
void
sdl2_init(void)
{
NOTICE(TRACE_USIM, "tv: using SDL2 backend for monitor and keyboard\n");
| < < < | 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 |
}
void
sdl2_init(void)
{
NOTICE(TRACE_USIM, "tv: using SDL2 backend for monitor and keyboard\n");
xbeep_audio_init();
SDL_CreateWindowAndRenderer(tv_width, tv_height, SDL_WINDOW_OPENGL, &window, &renderer);
SDL_ShowCursor(0); /* Invisible cursor. */
// SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
// SDL_RenderClear(renderer);
// SDL_RenderPresent(renderer);
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"); // make the scaled rendering look smoother.
SDL_RenderSetLogicalSize(renderer, tv_width, tv_height);
texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, tv_width, tv_height);
}
|
Changes to sdl2.h.
1 2 | #pragma once | < < | | 1 2 3 4 5 6 | #pragma once extern void sdl2_init(void); extern void sdl2_event(void); extern void sdl2_beep(int); |
Changes to tv.c.
| ︙ | ︙ | |||
23 24 25 26 27 28 29 | uint32_t tv_width; uint32_t tv_height; uint32_t tv_bitmap[1024 * 1024]; static int tv_csr; static int tv_colorbit; | | | | | 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
uint32_t tv_width;
uint32_t tv_height;
uint32_t tv_bitmap[1024 * 1024];
static int tv_csr;
static int tv_colorbit;
unsigned long tv_background = 0x000000; // Black
unsigned long tv_foreground = 0xffffff; // White
static int u_minh = 0x7fffffff;
static int u_maxh;
static int u_minv = 0x7fffffff;
static int u_maxv;
static void
accumulate_update(int h, int v, int hs, int vs)
{
if (h < u_minh)
u_minh = h;
if (h + hs > u_maxh)
u_maxh = h + hs;
if (v < u_minv)
u_minv = v;
if (v + vs > u_maxv)
u_maxv = v + vs;
}
void
tv_update_screen(void (*fn)(int, int , int , int))
{
int hs;
int vs;
hs = u_maxh - u_minh;
vs = u_maxv - u_minv;
if (u_minh != 0x7fffffff && u_minv != 0x7fffffff && u_maxh && u_maxv) {
|
| ︙ | ︙ | |||
94 95 96 97 98 99 100 |
snprintf(buff, 128, "%i", tv_width);
fputs(buff, f);
fputc(' ', f);
snprintf(buff, 128, "%i", tv_height);
fputs(buff, f);
fputs("\n", f);
for (uint32_t i = 0; i < tv_width * tv_height; i++) {
| | | | 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
snprintf(buff, 128, "%i", tv_width);
fputs(buff, f);
fputc(' ', f);
snprintf(buff, 128, "%i", tv_height);
fputs(buff, f);
fputs("\n", f);
for (uint32_t i = 0; i < tv_width * tv_height; i++) {
fputc(tv_bitmap[i] == tv_foreground ? '1' : '0', f);
if (i % 70 == 0 && i > 0)
fputc('\n', f);
}
fclose(f);
}
void
tv_read(uint32_t offset, uint32_t *pv)
{
unsigned long bits;
offset *= 32;
if (offset > tv_width * tv_height) {
WARNING(TRACE_TV, "tv: tv_read past end; offset %o\n", offset);
*pv = 0;
return;
}
bits = 0;
for (int i = 0; i < 32; i++) {
if (tv_bitmap[offset + i] == tv_foreground)
bits |= 1UL << i;
}
*pv = bits;
}
void
tv_flip_all(void)
|
| ︙ | ︙ | |||
140 141 142 143 144 145 146 |
int h;
int v;
offset *= 32;
v = offset / tv_width;
h = offset % tv_width;
for (int i = 0; i < 32; i++) {
| | | | 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
int h;
int v;
offset *= 32;
v = offset / tv_width;
h = offset % tv_width;
for (int i = 0; i < 32; i++) {
tv_bitmap[offset + i] = (bits & 1) ? tv_foreground : tv_background;
#if WITH_SDL1 /* HACK */
if (screen) {
unsigned char *ps = screen->pixels;
ps[offset + i] = (bits & 1) ? tv_foreground : tv_background;
}
#endif
bits >>= 1;
}
accumulate_update(h, v, 32, 1);
}
|
| ︙ | ︙ | |||
169 170 171 172 173 174 175 |
tv_csr &= ~(1 << 4);
/*
* Handle hardware reverse-video functionality.
*/
if ((v & 4) != tv_colorbit) {
tv_colorbit = v & 4;
| > | | | | | 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
tv_csr &= ~(1 << 4);
/*
* Handle hardware reverse-video functionality.
*/
if ((v & 4) != tv_colorbit) {
tv_colorbit = v & 4;
{
unsigned long temp = tv_foreground;
tv_foreground = tv_background;
tv_background = temp;
}
tv_colorbit = v & 4;
tv_flip_all();
}
deassert_xbus_interrupt();
}
void
|
| ︙ | ︙ |
Changes to tv.h.
1 2 3 4 5 6 7 8 9 | #pragma once #include <stdint.h> extern int tv_monitor; extern uint32_t tv_bitmap[1024 * 1024]; extern uint32_t tv_width; extern uint32_t tv_height; | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #pragma once #include <stdint.h> extern int tv_monitor; extern uint32_t tv_bitmap[1024 * 1024]; extern uint32_t tv_width; extern uint32_t tv_height; extern unsigned long tv_background; extern unsigned long tv_foreground; extern void tv_init(void); extern void tv_poll(void); extern void tv_write(uint32_t, uint32_t); extern void tv_read(uint32_t, uint32_t *); extern void tv_xbus_read(uint32_t, uint32_t *); extern void tv_xbus_write(uint32_t, uint32_t); extern void tv_screenshot(char *); extern void tv_update_screen(void (*fn)(int, int , int , int)); |
Changes to ucfg.c.
| ︙ | ︙ | |||
230 231 232 233 234 235 236 |
* ---!!! We don't differentiate between left/right on
* ---!!! the Lisp Machine side.
*/
if (streq(value, "")) {
warnx("value for %s is empty", name);
return 1;
}
| | | | | | | | | | 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
* ---!!! We don't differentiate between left/right on
* ---!!! the Lisp Machine side.
*/
if (streq(value, "")) {
warnx("value for %s is empty", name);
return 1;
}
if (streq(name, "Shift")) kbd_modifier_map[ShiftMapIndex] = lmbucky(value);
else if (streq(name, "Lock")) kbd_modifier_map[LockMapIndex] = lmbucky(value);
else if (streq(name, "Control")) kbd_modifier_map[ControlMapIndex] = lmbucky(value);
else if (streq(name, "Mod1")) kbd_modifier_map[Mod1MapIndex] = lmbucky(value);
else if (streq(name, "Mod2")) kbd_modifier_map[Mod2MapIndex] = lmbucky(value);
else if (streq(name, "Mod3")) kbd_modifier_map[Mod3MapIndex] = lmbucky(value);
else if (streq(name, "Mod4")) kbd_modifier_map[Mod4MapIndex] = lmbucky(value);
else if (streq(name, "Mod5")) kbd_modifier_map[Mod5MapIndex] = lmbucky(value);
else {
warnx("unknown modifier: %s", name);
return 1;
}
}
#ifdef WITH_X11
|
| ︙ | ︙ |
Changes to uch11-backend.h.
1 2 3 4 5 6 |
#pragma once
#include <pthread.h>
enum
{
| > | | | | | | | | | | < < | | | | < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
#pragma once
#include <pthread.h>
#include <stdbool.h>
enum
{
CHAOS_CSR_TIMER_INTERRUPT_ENABLE = (01 << 00), /* CHBUSY */
CHAOS_CSR_LOOP_BACK = (01 << 01), /* CHLPBK */
CHAOS_CSR_RECEIVE_ALL = (01 << 02), /* CHSPY */
CHAOS_CSR_RECEIVER_CLEAR = (01 << 03),
CHAOS_CSR_RECEIVE_ENABLE = (01 << 04), /* CHREN */
CHAOS_CSR_TRANSMIT_ENABLE = (01 << 05), /* CHRIEN */
CHAOS_CSR_INTERRUPT_ENABLES = (02 << 04),
CHAOS_CSR_TRANSMIT_ABORT = (01 << 06), /* CHABRT */
CHAOS_CSR_TRANSMIT_DONE = (01 << 07), /* CHTDN */
CHAOS_CSR_TRANSMITTER_CLEAR = (01 << 010), /* CHTCLR */
CHAOS_CSR_LOST_COUNT = (04 << 011), /* CHLC */
CHAOS_CSR_RESET = (01 << 015), /* CHRST */
CHAOS_CSR_CRC_ERROR = (01 << 016), /* CHCRC */
CHAOS_CSR_RECEIVE_DONE = (01 << 017), /* CHRDN */
} CHAOS_HARDWARE_VALUES;
extern struct queue_head queuehead;
extern pthread_mutex_t recvqueue;
extern pthread_mutex_t recvqueue;
extern int chaosd_fd;
extern int uch11_backend;
extern int uch11_myaddr;
extern int uch11_serveraddr;
extern bool reconnect_chaos;
extern int uch11_csr;
extern int uch11_bit_count;
extern int uch11_lost_count;
extern unsigned short uch11_xmit_buffer[4096];
extern int uch11_xmit_buffer_size;
extern int uch11_xmit_buffer_ptr;
extern unsigned short uch11_rcv_buffer[4096];
extern unsigned short uch11_rcv_buffer_toss[4096];
extern int uch11_rcv_buffer_ptr;
extern int uch11_rcv_buffer_size;
extern bool uch11_rcv_buffer_empty;
// This hack is so that uch11-backend.h (this file) can be included in
// Chaosnet for Unix.
#ifndef CHAOS_H
#define CHAOS_H
#include <pthread.h>
#include <sys/queue.h>
struct packet_queue
{
TAILQ_ENTRY(packet_queue) next;
struct packet *packet;
};
TAILQ_HEAD(queue_head, packet_queue);
#include "chaos.h"
#include "chunix/chsys.h"
#include "chunix/chconf.h"
#include "chncp/chncp.h"
#endif
|
Changes to uch11-chaosd.c.
1 2 3 | /* Connect to a chaos daemon via a Unix socket. */ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | /* Connect to a chaos daemon via a Unix socket. */ #include <sys/poll.h> #include <sys/socket.h> #include <sys/stat.h> #include <sys/time.h> #include <sys/types.h> #include <sys/uio.h> #include <sys/un.h> #include <netinet/in.h> #include <sys/types.h> #include <sys/socket.h> #include <netdb.h> #include <arpa/inet.h> #include <err.h> #include <pthread.h> #include <stddef.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> #include "uch11.h" #include "uch11-backend.h" #include "chaosd.h" #include "hosttab.h" #include "misc.h" #include "ucfg.h" #include "ucode.h" #include "usim.h" #include "utrace.h" #define UNIX_SOCKET_PATH "/var/tmp/" #define UNIX_SOCKET_CLIENT_NAME "chaosd_" #define UNIX_SOCKET_SERVER_NAME "chaosd_server" #define UNIX_SOCKET_PERM S_IRWXU int |
| ︙ | ︙ |
Changes to uch11-local.c.
1 2 3 | /* Local Chaos -- this should go into chlib.c */ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
/* Local Chaos -- this should go into chlib.c
*/
#include <sys/poll.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <err.h>
#include <pthread.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include "uch11.h"
#include "uch11-backend.h"
#include "chaosd.h"
#include "hosttab.h"
#include "misc.h"
#include "ucfg.h"
#include "ucode.h"
#include "usim.h"
#include "utrace.h"
static void
chaos_queue(struct packet *packet)
{
struct packet_queue *node;
node = malloc(sizeof(struct packet_queue));
|
| ︙ | ︙ |
Changes to uch11.c.
| ︙ | ︙ | |||
44 45 46 47 48 49 50 | int uch11_bit_count; int uch11_lost_count; unsigned short uch11_xmit_buffer[4096]; int uch11_xmit_buffer_size; int uch11_xmit_buffer_ptr; | | | | | | 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | int uch11_bit_count; int uch11_lost_count; unsigned short uch11_xmit_buffer[4096]; int uch11_xmit_buffer_size; int uch11_xmit_buffer_ptr; unsigned short uch11_rcv_buffer[4096]; unsigned short uch11_rcv_buffer_toss[4096]; int uch11_rcv_buffer_ptr; int uch11_rcv_buffer_size; bool uch11_rcv_buffer_empty; int reconnect_delay; bool reconnect_chaos; int (*uch11_send)(char *, int); void uch11_force_reconect(void); extern void uch11_reconnect(void); extern void settreeroot(const char *, const char *prefix); pthread_mutex_t recvqueue; pthread_mutex_t recvqueue; struct queue_head queuehead = TAILQ_HEAD_INITIALIZER(queuehead); // udp int chudpopen(void); int chaos_send_to_udp(char *buffer, int size); |
| ︙ | ︙ |
Changes to ucode.h.
| ︙ | ︙ | |||
75 76 77 78 79 80 81 |
} symtype_t;
typedef struct sym
{
char *name;
uint32_t v;
symtype_t mtype;
| | | | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
} symtype_t;
typedef struct sym
{
char *name;
uint32_t v;
symtype_t mtype;
LIST_ENTRY(sym) next;
} sym_t;
typedef struct symtab
{
char *name;
int sym_count;
LIST_HEAD(symbols, sym) symbols;
} symtab_t;
extern int sym_read_file(symtab_t *, char *);
extern char *sym_find_by_type_val(symtab_t *, symtype_t, uint32_t, int *);
extern int sym_find(symtab_t *, char *, int *);
/// MARK: udiss.c
|
| ︙ | ︙ |
Changes to uexec.c.
| ︙ | ︙ | |||
181 182 183 184 185 186 187 | int last_byte_in_word; /* * This is ugly, but follows the hardware logic (I * need to distill it to intent but it seems correct). */ lc0b = (interrupt_control & (1 << 29) ? 1 : 0) & /* Byte mode. */ | | | 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | int last_byte_in_word; /* * This is ugly, but follows the hardware logic (I * need to distill it to intent but it seems correct). */ lc0b = (interrupt_control & (1 << 29) ? 1 : 0) & /* Byte mode. */ ((mfmem[1] & 1) ? 1 : 0); /* LC0. */ lc1 = (mfmem[1] & 2) ? 1 : 0; last_byte_in_word = (~lc0b & ~lc1) & 1; DEBUG(TRACE_UCODE, "lc0b %d, lc1 %d, last_byte_in_word %d\n", lc0b, lc1, last_byte_in_word); if (last_byte_in_word) /* * Set NEED-FETCH. */ |
| ︙ | ︙ | |||
219 220 221 222 223 224 225 | return res; case 6: return opc; case 7: return q; case 010: return mfmem[020]; | | | | | | | | | | 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
return res;
case 6:
return opc;
case 7:
return q;
case 010:
return mfmem[020];
case 011: { /* MEMORY-MAP-DATA */
uint32_t l2_data;
uint32_t l1_data;
l1_data = 0;
l2_data = 0;
l2_data = map_vtop(mfmem[030], (int *) &l1_data, (int *) 0);
return ((uint32_t) write_fault_bit << 31) | ((uint32_t) access_fault_bit << 30) | ((l1_data & 037) << 24) | (l2_data & 077777777);
}
case 012:
return mfmem[030];
case 013:
return (interrupt_control & (1 << 29)) ? mfmem[1] : mfmem[1] & ~1;
case 014:
res = (spcptr << 24) | (spc[spcptr] & 01777777);
DEBUG(TRACE_MICROCODE, "reading spc[%o] + ptr -> %o\n", spcptr, mdata);
|
| ︙ | ︙ | |||
291 292 293 294 295 296 297 |
if (interrupt_control & (1 << 28)) {
DEBUG(TRACE_UCODE, "ic: bus reset\n");
}
if (interrupt_control & (1 << 29)) {
DEBUG(TRACE_UCODE, "ic: lc byte mode\n");
}
mfmem[1] = (mfmem[1] & ~(017 << 26)) | /* Preserve flags. */
| | | 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
if (interrupt_control & (1 << 28)) {
DEBUG(TRACE_UCODE, "ic: bus reset\n");
}
if (interrupt_control & (1 << 29)) {
DEBUG(TRACE_UCODE, "ic: lc byte mode\n");
}
mfmem[1] = (mfmem[1] & ~(017 << 26)) | /* Preserve flags. */
(interrupt_control & (017 << 26));
break;
case 010: /* C-PDL-BUFFER-POINTER PDL (addressed by pointer) */
DEBUG(TRACE_UCODE, "writing pdl[%o] <- %o\n", mfmem[014], data);
trace_pdlptr_write(data);
pdl[mfmem[014]] = data;
break;
case 011: /* C-PDL-BUFFER-POINTER-PUSH PDL (addressed by pointer, push) */
|
| ︙ | ︙ |
Changes to x11.c.
1 2 3 4 5 6 7 | /* x11.c --- X11 routines used by the TV and KBD interfaces */ #include <err.h> #include <stdio.h> #include <stdlib.h> | < < < < > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | /* x11.c --- X11 routines used by the TV and KBD interfaces */ #include <err.h> #include <stdio.h> #include <stdlib.h> #include "ucode.h" #include "ucfg.h" #include "utrace.h" #include "idle.h" #include "kbd.h" #include "cadet.h" #include "knight.h" #include "mouse.h" #include "tv.h" #include "x11.h" #include "misc.h" #define EVENT_MASK \ ExposureMask | \ KeyPressMask | KeyReleaseMask | \ PointerMotionMask | ButtonPressMask | ButtonReleaseMask | \ EnterWindowMask | LeaveWindowMask |
| ︙ | ︙ | |||
109 110 111 112 113 114 115 |
*
* Also keep track if we should do an all-up event, and track
* the modifiers for later.
*/
for (int modifier = 0; modifier < 8; modifier++) {
int bucky;
| | | 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
*
* Also keep track if we should do an all-up event, and track
* the modifiers for later.
*/
for (int modifier = 0; modifier < 8; modifier++) {
int bucky;
bucky = kbd_modifier_map[modifier];
for (int i = 0; i < modmap->max_keypermod; i++) {
KeyCode keycode;
keycode = modmap->modifiermap[modifier * modmap->max_keypermod + i];
if (keymap[keycode / 8] & (1 << keycode % 8)) {
keymap[keycode / 8] &= ~(1 << keycode % 8); /* Clear the key in KEYMAP. */
DEBUG(TRACE_KBD, "cadet_allup_key() - bucky pressed (%d); keycode = %d\n", bucky, keycode);
|
| ︙ | ︙ | |||
196 197 198 199 200 201 202 |
void
x11_idle_change_handler(int mode)
{
static int width = 22, bottom = 2, right = 2;
switch (mode) {
case IDLE_IDLE:
| | | | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
void
x11_idle_change_handler(int mode)
{
static int width = 22, bottom = 2, right = 2;
switch (mode) {
case IDLE_IDLE:
XSetForeground(display, idle_gc, tv_foreground);
break;
case IDLE_WORKING:
XSetForeground(display, idle_gc, tv_background);
break;
}
XDrawLine(display, window, idle_gc, tv_width - width - right, tv_height - bottom, tv_width - right, tv_height - bottom);
}
void
x11_beep(void)
|
| ︙ | ︙ | |||
229 230 231 232 233 234 235 |
XChangeKeyboardControl(display, KBBellPercent | KBBellPitch | KBBellDuration, &okc);
#endif
}
void
update(int u_minh, int u_minv, int hs, int vs)
{
| | | | | 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
XChangeKeyboardControl(display, KBBellPercent | KBBellPitch | KBBellDuration, &okc);
#endif
}
void
update(int u_minh, int u_minv, int hs, int vs)
{
XPutImage(display, window, gc, ximage, u_minh, u_minv, u_minh, u_minv, hs, vs);
XFlush(display);
}
void
x11_event(void)
{
XEvent e;
tv_update_screen(&update);
kbd_dequeue_key_event();
if (is_mouse_warp) {
is_mouse_warp = 0;
XWarpPointer(display, None, window, 0, 0, 0, 0, mouse_warp_x, mouse_warp_y);
}
while (XCheckWindowEvent(display, window, EVENT_MASK, &e)) {
switch (e.type) {
|
| ︙ | ︙ | |||
313 314 315 316 317 318 319 | display = XOpenDisplay(displayname); if (display == NULL) errx(1, "failed to open display"); idle_register_fd(XConnectionNumber(display)); bitmap_order = BitmapBitOrder(display); xscreen = DefaultScreen(display); color_depth = DisplayPlanes(display, xscreen); | | | | 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | display = XOpenDisplay(displayname); if (display == NULL) errx(1, "failed to open display"); idle_register_fd(XConnectionNumber(display)); bitmap_order = BitmapBitOrder(display); xscreen = DefaultScreen(display); color_depth = DisplayPlanes(display, xscreen); tv_foreground = WhitePixel(display, xscreen); tv_background = BlackPixel(display, xscreen); root = RootWindow(display, xscreen); attr.event_mask = EVENT_MASK; window = XCreateWindow(display, root, 0, 0, tv_width, tv_height, 0, color_depth, InputOutput, visual, CWBorderPixel | CWEventMask, &attr); if (window == None) errx(1, "failed to open window"); if (!XStringListToTextProperty(&window_name, 1, pWindowName)) pWindowName = NULL; |
| ︙ | ︙ |
Changes to x11.h.
1 2 3 4 5 6 7 8 9 10 | #pragma once #include <stdbool.h> #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/keysym.h> extern bool x11_grab_keyboard; | < < < < < | 1 2 3 4 5 6 7 8 9 10 11 12 | #pragma once #include <stdbool.h> #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/keysym.h> extern bool x11_grab_keyboard; extern void x11_init(void); extern void x11_event(void); |