Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Indent files. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | ams/sdl |
Files: | files | file ages | folders |
SHA3-256: |
cb74f9ba59b7c84b8401260d0195e978 |
User & Date: | ams 2024-06-19 07:15:39 |
Context
2024-06-25
| ||
07:04 | x11.c: Minor fixes; use new API. check-in: ef2b653529 user: ams tags: ams/sdl | |
2024-06-19
| ||
07:15 | Indent files. check-in: cb74f9ba59 user: ams tags: ams/sdl | |
07:03 | Minor cleanups. check-in: c56a574a07 user: ams tags: ams/sdl | |
Changes
Changes to cadet.c.
︙ | ︙ | |||
144 145 146 147 148 149 150 | cadet_shifts &= ~(1 << CADET_IX_TOP); else if ((scc == CADET_LEFT_SHIFT) || (scc == CADET_RIGHT_SHIFT)) cadet_shifts &= ~(1 << CADET_IX_SHIFT); } } void | < | | | | | | 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | cadet_shifts &= ~(1 << CADET_IX_TOP); else if ((scc == CADET_LEFT_SHIFT) || (scc == CADET_RIGHT_SHIFT)) cadet_shifts &= ~(1 << CADET_IX_SHIFT); } } void cadet_process_key(int keysym, /* keysym, acts as index into kbd_map */ int bi, /* bucky, acts as index into modifier_map */ int keydown, /* if key is down or up */ bool (*allup_key)(void) ) { int lmchar; /* Lisp Machine charachter to insert */ int scc; /* Space Cadet scancode. */ int wantshift; /* Index into second column in cadet_kbd_map. */ int shkey; /* Shift key being pressed. */ int oshift; |
︙ | ︙ |
Changes to iob.c.
︙ | ︙ | |||
66 67 68 69 70 71 72 | iob_csr &= ~(1 << 4); /* Clear CSR<4>. */ break; case 0106: *pv = (mouse_rawx << 12) | (mouse_rawy << 14) | (mouse_x & 07777); INFO(TRACE_IOB | TRACE_UNIBUS, "unibus: mouse x %011o\n", *pv); break; case 0110: | | | | 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | iob_csr &= ~(1 << 4); /* Clear CSR<4>. */ break; case 0106: *pv = (mouse_rawx << 12) | (mouse_rawy << 14) | (mouse_x & 07777); INFO(TRACE_IOB | TRACE_UNIBUS, "unibus: mouse x %011o\n", *pv); break; case 0110: INFO(TRACE_IOB | TRACE_UNIBUS, "unibus: beep\n"); /* * This is triggered by older code that does a %UNIBUS-READ. */ // MMcM: It's the number of microseconds between triggers of the // flip-flop. That is, half the wavelength. So the frequency is, I // think, (/ 1e6 (* #o1350 2)). So I guess 672Hz. And duration is // only .13sec. #if WITH_X11 x11_beep(); #elif WITH_SDL1 |
︙ | ︙ |
Changes to kbd.c.
︙ | ︙ | |||
17 18 19 20 21 22 23 | #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; | < | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #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 modifier_map[8]; |
︙ | ︙ | |||
94 95 96 97 98 99 100 | /* You hold down all four control and meta keys on your keyboard, and hit return if you want to use the same virtual memory as now, or rubout if you want to load a new copy of virtual memory. Hitting other keys is undefined. | < < < < | 93 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 129 130 131 132 133 134 135 | /* You hold down all four control and meta keys on your keyboard, and hit return if you want to use the same virtual memory as now, or rubout if you want to load a new copy of virtual memory. Hitting other keys is undefined. The incantations used for warm-booting and cold-booting involve holding down all four control and meta keys simultaneously (the two to the left of the space bar and the two to the right of the space bar), and striking RUBOUT for a cold-boot or RETURN for a warm-boot. This combination of keys is extremely difficult to type accidentally. RMS@MIT-AI 01/02/79 05:17:38 To: (BUG LISPM) at MIT-AI C-M-C-M-digit should load the band for that digit. ;Enter here from the PROM. Virtual memory is not valid yet. (LOC 6) PROM (JUMP-NOT-EQUAL-XCT-NEXT Q-R A-ZERO PROM) ;These 2 instructions duplicate the prom ((Q-R) ADD Q-R A-MINUS-ONE) ;;; Decide whether to restore virtual memory from saved band on disk, i.e. ;;; whether this is a cold boot or a warm boot. If the keyboard has input ;;; available, and the character was RETURN (rather than RUBOUT), it's a warm boot. (CALL-XCT-NEXT PHYS-MEM-READ) ((VMA) (A-CONSTANT 17772045)) ;Unibus address 764112 (KBD CSR) (JUMP-IF-BIT-CLEAR (BYTE-FIELD 1 5) MD ;If keyboard is not ready, COLD-BOOT) ; assume we are supposed to cold-boot (CALL-XCT-NEXT PHYS-MEM-READ) ((VMA) (A-CONSTANT 17772040)) ;Unibus address 764100 (KBD LOW) ((MD) (BYTE-FIELD 6 0) MD) ;Get keycode (JUMP-EQUAL MD (A-CONSTANT 46) COLD-BOOT) ;This is cold-boot if key is RUBOUT ((MD) (A-CONSTANT 46)) ;Standardize mode. Mostly, set to NORMAL speed (CALL-XCT-NEXT PHYS-MEM-WRITE) ;40 is PROM-DISABLE, 2 is NORMAL speed. ((VMA) (A-CONSTANT 17773005)) ;Unibus 766012 (JUMP BEG0000) // ukbd -- cadet prom ;Is request to boot machine if both controls and both metas are held ;down, along with rubout or return. We have just sent the key-down codes ;for all of those keys. We now send a boot character, then set a flag preventing ;sending of up-codes until the next down-code. This gives the machine time |
︙ | ︙ | |||
211 212 213 214 215 216 217 | for (int i = 0; lmchar_map[i].name; i++) { if (streq(key, lmchar_map[i].name) == true) return lmchar_map[i].lmchar; } return LMCH_NoSymbol; } | | | | 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | for (int i = 0; lmchar_map[i].name; i++) { if (streq(key, lmchar_map[i].name) == true) return lmchar_map[i].lmchar; } return LMCH_NoSymbol; } #include <X11/keysym.h> // for XK_FOO meh #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(modifier_map); i++) |
︙ | ︙ | |||
385 386 387 388 389 390 391 | kbd_map[XK_space] = LMCH_space; /* *INDENT-ON* */ } void kbd_init(void) { | | | 380 381 382 383 384 385 386 387 388 389 390 391 392 | kbd_map[XK_space] = LMCH_space; /* *INDENT-ON* */ } void kbd_init(void) { // kbd_default_map(); if (kbd_type == 0) knight_init(); else cadet_init(); } |
Changes to mouse.c.
︙ | ︙ | |||
53 54 55 56 57 58 59 | } void mouse_poll(void) { static int prevstate; int state; | > | | 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | } void mouse_poll(void) { static int prevstate; int state; enum { Sdisabled, Sopen, Soff, Son }; state = DTP_FIX_VAL(amem[a_mouse_cursor_state]); if (state != prevstate && state == Son) { is_mouse_warp = 1; mouse_warp_x = DTP_FIX_VAL(amem[a_mouse_x]); mouse_warp_y = DTP_FIX_VAL(amem[a_mouse_y]); } |
︙ | ︙ |
Changes to sdl1.c.
︙ | ︙ | |||
9 10 11 12 13 14 15 | #include "kbd.h" #include "mouse.h" #include "utrace.h" #include "idle.h" SDL_Surface *screen; | | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #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 /* * This is shared between x11.c, and sdl1.c ... the only difference is * the hook in send_accumulated_updates. */ unsigned long Background; |
︙ | ︙ | |||
55 56 57 58 59 60 61 | } u_minh = 0x7fffffff; u_maxh = 0; u_minv = 0x7fffffff; u_maxv = 0; } | | | | > | > | > | | | | > | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | } u_minh = 0x7fffffff; u_maxh = 0; u_minv = 0x7fffffff; u_maxv = 0; } static void sdl1_cleanup(void) { SDL_Quit(); } /* * Returns the X11 modifier index of KEYCODE, or -1 if not found. */ static int sdl1_bucky(SDL_KeyboardEvent e) { int mod = SDL_GetModState(); if (mod & KMOD_CTRL && (e.keysym.sym == SDLK_LCTRL || e.keysym.sym == SDLK_RCTRL)) return ControlMapIndex; if (mod & KMOD_SHIFT && (e.keysym.sym == SDLK_LSHIFT || e.keysym.sym == SDLK_RSHIFT)) return ShiftMapIndex; if (mod & KMOD_ALT && (e.keysym.sym == SDLK_LALT || e.keysym.sym == SDLK_RALT)) return Mod1MapIndex; // if (mod & KMOD_NUM) return Mod2MapIndex; // if (mod & KMOD_MODE) return Mod3MapIndex; // if (mod & KMOD_GUI && (e.keysym.sym == SDLK_LGUI || e.keysym.sym == SDLK_RGUI)) return Mod4MapIndex; // if (mod & KMOD_SCROLL) return Mod5MapIndex; return -1; } static int sdl1_keysym_to_xk(SDL_KeyboardEvent e) { /* *INDENT-OFF* */ switch (e.keysym.sym) { case SDLK_ESCAPE: return XK_Escape; case SDLK_F1: return XK_F1; case SDLK_F2: return XK_F2; case SDLK_F3: return XK_F3; case SDLK_F4: return XK_F4; case SDLK_F5: return XK_F5; |
︙ | ︙ | |||
158 159 160 161 162 163 164 | case SDLK_LSHIFT: return XK_Shift_L; case SDLK_RSHIFT: return XK_Shift_R; case SDLK_LCTRL: return XK_Control_L; case SDLK_RCTRL: return XK_Control_R; case SDLK_CAPSLOCK: return XK_Caps_Lock; // case ???: return XK_Shift_Lock; | | | | | | | > | 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | case SDLK_LSHIFT: return XK_Shift_L; case SDLK_RSHIFT: return XK_Shift_R; case SDLK_LCTRL: return XK_Control_L; case SDLK_RCTRL: return XK_Control_R; case SDLK_CAPSLOCK: return XK_Caps_Lock; // case ???: return XK_Shift_Lock; // case SDLK_LGUI: return XK_Meta_L; // case SDLK_RGUI: return XK_Meta_R; case SDLK_LALT: return XK_Alt_L; case SDLK_RALT: return XK_Alt_R; // case SDLK_LSUPER: return XK_Super_L; // case SDLK_RSUPER: return XK_Super_R; // case SDLK_LHYPER: return XK_Hyper_L; // case SDLK_RHYPER: return XK_Hyper_R; default: return XK_VoidSymbol; } /* *INDENT-ON* */ } bool cadet_allup_key(void) { bool allup; int mods; |
︙ | ︙ | |||
210 211 212 213 214 215 216 | /* * Takes E, converts it into a LM (hardware) keycode and sends it to * the IOB KBD. */ static void process_key(SDL_KeyboardEvent e, int keydown) { | | | | | | | | | | | | | | | | | | | | 215 216 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 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 | /* * Takes E, converts it into a LM (hardware) keycode and sends it to * the IOB KBD. */ static void process_key(SDL_KeyboardEvent e, int keydown) { // KeySym keysym; // SDLKey keycode; int keysym; int bi; unsigned char buf[5]; idle_keyboard_activity(); keysym = sdl1_keysym_to_xk(e); if (keysym == XK_VoidSymbol || keysym > NELEM(kbd_map)) { NOTICE(TRACE_USIM, "kbd (cadet@sdl1): unable to translate to keysym (keysym = 0%o, 0%o)\n", keysym, e.keysym.sym); return; } if (kbd_type == 0) { if (!keydown) return; bi = 0; // if (e->xkey.state & ShiftMask) // knight_process_bucky(ShiftMapIndex, &bi); // if (e->xkey.state & LockMask) // knight_process_bucky(LockMapIndex, &bi); // if (e->xkey.state & ControlMask) // knight_process_bucky(ControlMapIndex, &bi); // if (e->xkey.state & Mod1Mask) // knight_process_bucky(Mod1MapIndex, &bi); // if (e->xkey.state & Mod2Mask) // knight_process_bucky(Mod2MapIndex, &bi); // if (e->xkey.state & Mod3Mask) // knight_process_bucky(Mod3MapIndex, &bi); // 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, bi, keydown); } } |
︙ | ︙ | |||
290 291 292 293 294 295 296 | } void sdl1_init(void) { NOTICE(TRACE_USIM, "tv: using SDL1 backend for monitor and keyboard\n"); | | | | 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 | } void sdl1_init(void) { NOTICE(TRACE_USIM, "tv: using SDL1 backend for monitor and keyboard\n"); Foreground = 0xff; // White 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 sdl2.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* sdl2.c --- SDL2 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" | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | /* sdl2.c --- SDL2 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" #include <X11/keysym.h> // for XK_FOO meh #include <X11/X.h> // for FOOMapIndex meh SDL_Window *window; SDL_Renderer *renderer; SDL_Texture *texture; /* * This is shared between x11.c, and sdl2.c ... the only difference is |
︙ | ︙ | |||
43 44 45 46 47 48 49 | if (v + vs > u_maxv) u_maxv = v + vs; } static void send_accumulated_updates(void) { | | | | | | | | | | | | | > | > | > | | | > | > | 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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | if (v + vs > u_maxv) u_maxv = v + vs; } static void send_accumulated_updates(void) { // 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) { SDL_UpdateTexture(texture, NULL, tv_bitmap, tv_width * sizeof(Uint32)); // Flush SDL_RenderClear(renderer); SDL_RenderCopy(renderer, texture, NULL, NULL); SDL_RenderPresent(renderer); // } // u_minh = 0x7fffffff; // u_maxh = 0; // u_minv = 0x7fffffff; // u_maxv = 0; } //typedef struct SDL_Keysym //{ // SDL_Scancode scancode; /**< SDL physical key code - see SDL_Scancode for details */ // SDL_Keycode sym; /**< SDL virtual key code - see SDL_Keycode for details */ // Uint16 mod; /**< current key modifiers */ // Uint32 unused; //} SDL_Keysym; int sdl2_bucky(SDL_KeyboardEvent e) { int mod = SDL_GetModState(); if (mod & KMOD_CTRL && (e.keysym.sym == SDLK_LCTRL || e.keysym.sym == SDLK_RCTRL)) return ControlMapIndex; if (mod & KMOD_SHIFT && (e.keysym.sym == SDLK_LSHIFT || e.keysym.sym == SDLK_RSHIFT)) return ShiftMapIndex; if (mod & KMOD_ALT && (e.keysym.sym == SDLK_LALT || e.keysym.sym == SDLK_RALT)) return Mod1MapIndex; // if (mod & KMOD_NUM) return Mod2MapIndex; // if (mod & KMOD_MODE) return Mod3MapIndex; if (mod & KMOD_GUI && (e.keysym.sym == SDLK_LGUI || e.keysym.sym == SDLK_RGUI)) return Mod4MapIndex; // if (mod & KMOD_SCROLL) return Mod5MapIndex; return -1; } int sdl2_keysym_to_xk(SDL_KeyboardEvent e) { /* *INDENT-OFF* */ switch (e.keysym.sym) { case SDLK_ESCAPE: return XK_Escape; case SDLK_F1: return XK_F1; case SDLK_F2: return XK_F2; case SDLK_F3: return XK_F3; case SDLK_F4: return XK_F4; case SDLK_F5: return XK_F5; |
︙ | ︙ | |||
167 168 169 170 171 172 173 | case SDLK_CAPSLOCK: return XK_Caps_Lock; // case ???: return XK_Shift_Lock; case SDLK_LGUI: return XK_Meta_L; case SDLK_RGUI: return XK_Meta_R; case SDLK_LALT: return XK_Alt_L; case SDLK_RALT: return XK_Alt_R; | | | | | > | 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | case SDLK_CAPSLOCK: return XK_Caps_Lock; // case ???: return XK_Shift_Lock; case SDLK_LGUI: return XK_Meta_L; case SDLK_RGUI: return XK_Meta_R; case SDLK_LALT: return XK_Alt_L; case SDLK_RALT: return XK_Alt_R; // case SDLK_LSUPER: return XK_Super_L; // case SDLK_RSUPER: return XK_Super_R; // case SDLK_LHYPER: return XK_Hyper_L; // case SDLK_RHYPER: return XK_Hyper_R; default: return XK_VoidSymbol; } /* *INDENT-ON* */ } bool cadet_allup_key(void) { bool allup; int mods; |
︙ | ︙ | |||
211 212 213 214 215 216 217 | } return allup; } static void process_key(SDL_KeyboardEvent e, int keydown) { | | | | 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | } return allup; } static void process_key(SDL_KeyboardEvent e, int keydown) { // KeySym keysym; // SDLKey keycode; int bi; int keysym; idle_keyboard_activity(); keysym = sdl2_keysym_to_xk(e); if (keysym == XK_VoidSymbol || keysym > NELEM(kbd_map)) { |
︙ | ︙ | |||
234 235 236 237 238 239 240 | int mod = SDL_GetModState(); if (mod & KMOD_SHIFT) knight_process_bucky(ShiftMapIndex, &bi); if (mod & KMOD_CAPS) knight_process_bucky(LockMapIndex, &bi); if (mod & KMOD_CTRL) knight_process_bucky(ControlMapIndex, &bi); | | | | | | | | | | | | | | 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | int mod = SDL_GetModState(); if (mod & KMOD_SHIFT) knight_process_bucky(ShiftMapIndex, &bi); if (mod & KMOD_CAPS) knight_process_bucky(LockMapIndex, &bi); if (mod & KMOD_CTRL) knight_process_bucky(ControlMapIndex, &bi); // if (mod & Mod1Mask) // knight_process_bucky(Mod1MapIndex, &bi); // if (mod & Mod2Mask) // knight_process_bucky(Mod2MapIndex, &bi); // if (mod & Mod3Mask) // knight_process_bucky(Mod3MapIndex, &bi); // if (mod & Mod4Mask) // knight_process_bucky(Mod4MapIndex, &bi); // if (mod & Mod5Mask) // knight_process_bucky(Mod5MapIndex, &bi); knight_process_key(e.keysym.sym, bi, keydown); } else { bi = sdl2_bucky(e); cadet_process_key(keysym /* xk_keysym */ , bi, keydown, &cadet_allup_key); } } void sdl2_event(void) { SDL_Event ev; send_accumulated_updates(); 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) { case SDL_WINDOWEVENT: SDL_UpdateTexture(texture, NULL, tv_bitmap, tv_width * sizeof(Uint32)); // flush SDL_RenderClear(renderer); SDL_RenderCopy(renderer, texture, NULL, NULL); SDL_RenderPresent(renderer); break; case SDL_KEYDOWN: process_key(ev.key, 1); |
︙ | ︙ | |||
296 297 298 299 300 301 302 | float xbeep_volume = 1.0f; int AMPLITUDE = 28000; const int SAMPLE_RATE = 44100; int xbeep_sample_nr = 0; float xbeep_freq = 0.0f; | > | | | | | | | > | > > | > | > | > > | > | | | | | | | | | | | < < < | 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 | float xbeep_volume = 1.0f; int AMPLITUDE = 28000; const int SAMPLE_RATE = 44100; int xbeep_sample_nr = 0; float xbeep_freq = 0.0f; void xbeep_audio_callback(void *user_data, Uint8 *raw_buffer, int bytes) { Sint16 *buffer = (Sint16 *) raw_buffer; int length = bytes / 2; // 2 bytes per sample for AUDIO_S16SYS float *freq = (float *) (user_data); int amp = AMPLITUDE * xbeep_volume; for (int i = 0; i < length; i++, xbeep_sample_nr++) { double time = (double) xbeep_sample_nr / (double) SAMPLE_RATE; buffer[i] = (Sint16) (amp * sin(2.0f * M_PI * (*freq) * time)); // render sine wave } } void xbeep_audio_init(void) { SDL_AudioSpec want; SDL_AudioSpec have; want.freq = SAMPLE_RATE; want.format = AUDIO_S16SYS; want.channels = 1; want.samples = 2048; want.callback = xbeep_audio_callback; want.userdata = &xbeep_freq; if (SDL_OpenAudio(&want, &have) != 0) SDL_LogError(SDL_LOG_CATEGORY_AUDIO, "Failed to open audio: %s", SDL_GetError()); if (want.format != have.format) SDL_LogError(SDL_LOG_CATEGORY_AUDIO, "Failed to get the desired AudioSpec"); SDL_PauseAudio(1); } void xbeep_audio_close(void) { SDL_CloseAudio(); } void xbeep(int halfwavelength, int duration) { xbeep_freq = 1000000.0f / (float) (halfwavelength * 2); xbeep_sample_nr = 0; SDL_PauseAudio(0); SDL_Delay(duration / 1000); SDL_PauseAudio(1); } void sdl2_beep(int v) { ///XBEEP (MISC-INST-ENTRY %BEEP) ///;;; First argument is half-wavelength, second is duration. Both are in microseconds. ///;;; M-1 has 2nd argument (duration) which is added to initial time-check ///;;; M-2 contains most recent time check ///;;; to compute quitting time ///;;; M-C contains 1st argument, the wavelength ///;;; M-4 contains the time at which the next click must be done. ///;;; Note that the 32-bit clock wraps around once an hour, we have to be careful ///;;; to compare clock values in the correct way, namely without overflow checking. extern uint32_t mmem[32]; #define DTP_FIX_VAL(x) ((x) & ((1 << 24) - 1)) #define DTP_FIX(x) (DTP_FIX_VAL(x) | 5 << 25) int wavelength = DTP_FIX_VAL(mmem[7]); //M-C M-MEM 7 int duration = DTP_FIX_VAL(mmem[22]); //M-1 M-MEM 22 xbeep(wavelength, duration); } void sdl2_init(void) { NOTICE(TRACE_USIM, "tv: using SDL2 backend for monitor and keyboard\n"); Foreground = 0xffffff; // White Background = 0x000000; // Black 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 tv.c.
︙ | ︙ | |||
125 126 127 128 129 130 131 | } void tv_xbus_write(uint32_t offset, uint32_t v) { tv_csr = v; tv_csr &= ~(1 << 4); | | | | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | } void tv_xbus_write(uint32_t offset, uint32_t v) { tv_csr = v; tv_csr &= ~(1 << 4); /* * Handle hardware reverse-video functionality. */ if ((v & 4) != tv_colorbit) { tv_colorbit = v & 4; unsigned long temp = Foreground; Foreground = Background; Background = temp; tv_colorbit = v & 4; tv_flip_all(); } deassert_xbus_interrupt(); } void |
︙ | ︙ |
Changes to ucode.c.
︙ | ︙ | |||
27 28 29 30 31 32 33 | size_t cycles; int full_trace_lc = 0; int full_trace_repeat_counter = 0; int full_trace_last_lc = 0; | < | 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | size_t cycles; int full_trace_lc = 0; int full_trace_repeat_counter = 0; int full_trace_last_lc = 0; void run(void) { p1 = 0; p0_pc = 0; p1_pc = 0; inhibit = false; |
︙ | ︙ | |||
647 648 649 650 651 652 653 | */ dump_write_header(fd, str4("EOF_"), 0); fsync(fd); close(fd); } void | | | 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 | */ dump_write_header(fd, str4("EOF_"), 0); fsync(fd); close(fd); } void extra_dump_state(char *suffix) // Rename function, merge with save_state, and allow for a template or extra parameter (int incremenet?). { char buffer[256]; static int dump_nr = 0; snprintf(buffer, 256, "/tmp/usim-%03d-%s.state", dump_nr++, suffix); save_state(buffer); printf(".. dumped to file %s\n", buffer); |
︙ | ︙ | |||
768 769 770 771 772 773 774 | printf("LC reached #x%x, dumping state...\n", lc); return true; } } return false; } | < < < | 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 | printf("LC reached #x%x, dumping state...\n", lc); return true; } } return false; } int npc_dump_values[256] = { 0 }; int npc_dump_index = 0; void add_dump_npc(int npc) { printf("adding npc dump value #x%x\n", npc); npc_dump_values[npc_dump_index++] = npc; } |
︙ | ︙ |
Changes to ucode.h.
︙ | ︙ | |||
93 94 95 96 97 98 99 | 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 char *uinst_desc(uint64_t, symtab_t *); | < < < | 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | 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 char *uinst_desc(uint64_t, symtab_t *); /// MARK: utrace.h ??? extern void run(void); void add_dump_lc(int lc); void add_dump_npc(int lc); void add_trace_vmem(int vmem); struct page_s { |
︙ | ︙ | |||
124 125 126 127 128 129 130 | void trace_pdlidx_read(int value); void trace_pdlptr_read(int value); void trace_pdlidx_write(int value); void trace_pdlptr_write(int value); void trace_ucode(void); void record_pc_history(int pc); void check_npc_dump(); | < < | 121 122 123 124 125 126 127 | void trace_pdlidx_read(int value); void trace_pdlptr_read(int value); void trace_pdlidx_write(int value); void trace_pdlptr_write(int value); void trace_ucode(void); void record_pc_history(int pc); void check_npc_dump(); |
Changes to udiss.c.
︙ | ︙ | |||
94 95 96 97 98 99 100 | switch (m) { case 0: type_field(MMEM, u, 032, 006); break; case 1: fsource = load_byte(u, 032, 005); switch (fsource) { | > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > | 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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | switch (m) { case 0: type_field(MMEM, u, 032, 006); break; case 1: fsource = load_byte(u, 032, 005); switch (fsource) { case 0: PRIN1SP("READ-I-ARG"); break; case 1: PRIN1SP("MICRO-STACK-PNTR-AND-DATA"); break; case 2: PRIN1SP("PDL-BUFFER-POINTER"); break; case 3: PRIN1SP("PDL-BUFFER-INDEX"); break; case 4: PRIN1SP("FSOURCE-%o", fsource); break; case 5: PRIN1SP("C-PDL-BUFFER-INDEX"); break; case 6: PRIN1SP("C-OPC-BUFFER"); break; case 7: PRIN1SP("Q-R"); break; case 8: PRIN1SP("VMA"); break; case 9: PRIN1SP("MEMORY-MAP-DATA"); break; case 10: PRIN1SP("MD"); break; case 11: PRIN1SP("LOCATION-COUNTER"); break; case 12: PRIN1SP("MICRO-STACK-PNTR-AND-DATA-POP"); break; case 13 ... 19: PRIN1SP("FSOURCE-%o", fsource); break; case 20: PRIN1SP("C-PDL-BUFFER-POINTER-POP"); break; case 21: PRIN1SP("C-PDL-BUFFER-POINTER"); break; case 22: PRIN1SP("FSOURCE-%o", fsource); break; case 23 ... 31: PRIN1SP("FSOURCE-%o", fsource); break; } } } static void q_dest_desc(uint64_t u) { |
︙ | ︙ | |||
142 143 144 145 146 147 148 | m_dest_desc(uint64_t u) { int fdest; type_field(MMEM, u, 016, 005); fdest = load_byte(u, 023, 005); switch (fdest) { | | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > | 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 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 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | m_dest_desc(uint64_t u) { int fdest; type_field(MMEM, u, 016, 005); fdest = load_byte(u, 023, 005); switch (fdest) { case 0: break; case 1: PRIN1SP("LOCATION-COUNTER"); break; case 2: PRIN1SP("INTERRUPT-CONTROL"); break; case 3 ... 7: PRIN1SP("FDEST-%o", fdest); break; case 8: PRIN1SP("C-PDL-BUFFER-POINTER"); break; case 9: PRIN1SP("C-PDL-BUFFER-POINTER-PUSH"); break; case 10: PRIN1SP("C-PDL-BUFFER-INDEX"); break; case 11: PRIN1SP("PDL-BUFFER-INDEX"); break; case 12: PRIN1SP("PDL-BUFFER-POINTER"); break; case 13: PRIN1SP("MICRO-STACK-DATA-PUSH"); break; case 14: PRIN1SP("OA-REG-LOW"); break; case 15: PRIN1SP("OA-REG-HI"); break; case 16: PRIN1SP("VMA"); break; case 17: PRIN1SP("VMA-START-READ"); break; case 18: PRIN1SP("VMA-START-WRITE"); break; case 19: PRIN1SP("VMA-WRITE-MAP"); break; case 20 ... 23: PRIN1SP("FDEST-%o", fdest); break; case 24: PRIN1SP("MD"); break; case 25: PRIN1SP("FDEST-%o", fdest); break; case 26: PRIN1SP("MD-START-WRITE"); break; case 27: PRIN1SP("MD-WRITE-MAP"); break; case 28 ... 31: PRIN1SP("FDEST-%o", fdest); break; } } static void dest_desc_1(uint64_t u) { int dest; int alu; PRIN1(" ("); dest = load_byte(u, 031, 001); switch (dest) { case 0: m_dest_desc(u); break; case 1: a_dest_desc(u); break; } alu = load_byte(u, 053, 002); dest = load_byte(u, 000, 002); if (alu == 0 && dest == 3) PRIN1("Q-R"); PRIN1(") "); } |
︙ | ︙ | |||
230 231 232 233 234 235 236 | int mf; int q; int alu; int ilong; dest_desc(u); alu_function = load_byte(u, 003, 006); | | > | > > | > > | > > | > > | > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > | > > | > > | > | > > | > > | > | > | > | > > | > > | > > | > > | > > | > > > | > | 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 | int mf; int q; int alu; int ilong; dest_desc(u); alu_function = load_byte(u, 003, 006); switch (alu_function) { case 0: PRIN1SP("SETZ"); break; case 1: PRIN1SP("AND"); break; case 2: PRIN1SP("ANDCA"); break; case 3: PRIN1SP("SETM"); break; case 4: PRIN1SP("ANDCM"); break; case 5: /* SETA */ break; case 6: PRIN1SP("XOR"); break; case 7: PRIN1SP("IOR"); break; case 8: PRIN1SP("ANDCB"); break; case 9: PRIN1SP("EQV"); break; case 10: PRIN1SP("SETCA"); break; case 11: PRIN1SP("ORCA"); break; case 12: PRIN1SP("SETCM"); break; case 13: PRIN1SP("ORCM"); break; case 14: PRIN1SP("ORCB"); break; case 15: PRIN1SP("SETO"); break; case 16 ... 21: PRIN1SP("ALU-FUNCTION-%o", alu_function); break; case 22: PRIN1SP("SUB"); break; case 23 ... 24: PRIN1SP("ALU-FUNCTION-%o", alu_function); break; case 25: PRIN1SP("ADD"); break; case 26 ... 27: PRIN1SP("ALU-FUNCTION-%o", alu_function); break; case 28: PRIN1SP("INCM"); break; case 29 ... 30: PRIN1SP("ALU-FUNCTION-%o", alu_function); break; case 31: PRIN1SP("LSHM"); break; case 32: PRIN1SP("MUL"); break; case 33: PRIN1SP("DIV"); break; case 34 ... 36: PRIN1SP("ALU-FUNCTION-%o", alu_function); break; case 37: PRIN1SP("DIVRC"); break; case 38 ... 40: PRIN1SP("ALU-FUNCTION-%o", alu_function); break; case 41: PRIN1SP("DIVFS"); break; case 42 ... 63: PRIN1SP("ALU-FUNCTION-%o", alu_function); break; } alu = load_byte(u, 003, 006); if (alu == 026) sub_carry_desc(u); else normal_carry_desc(u); output_selector = load_byte(u, 014, 002); switch (output_selector) { case 0: PRIN1SP("OUTPUT-SELECTOR-%o", output_selector); break; case 1: break; case 2: PRIN1SP("OUTPUT-SELECTOR-RIGHTSHIFT-1"); break; case 3: PRIN1SP("OUTPUT-SELECTOR-LEFTSHIFT-1"); break; } q = load_byte(u, 000, 002); switch (q) { case 0: break; case 1: PRIN1SP("SHIFT-Q-LEFT"); break; case 2: PRIN1SP("SHIFT-Q-RIGHT"); break; case 3: break; } m_source_desc(u); type_field(AMEM, u, 040, 012); mf = load_byte(u, 012, 002); switch (mf) { case 0: break; case 1 ... 3: PRIN1SP("MF-%o", mf); break; } ilong = load_byte(u, 055, 001); switch (ilong) { case 0: break; case 1: PRIN1SP("ILONG"); break; } } static void type_jump_condition(int number) { switch ((number & 01400) >> 010) { case 0: PRIN1("JUMP"); break; case 1: PRIN1("CALL"); break; case 2: PRIN1("POPJ"); break; case 3: default: PRIN1("CALL-POPJ-??"); break; } if ((040 & number) == 0) { PRIN1("-IF-BIT-"); if ((0100 & number) == 0) PRIN1("Set"); else PRIN1("Clear"); |
︙ | ︙ | |||
325 326 327 328 329 330 331 | int cond; if ((0100 & number) == 0) cond = 07 & number; else cond = (07 & number) + 010; switch (cond) { | | > > > | > > | > > | > > | > > | > > | > > | > | > > > | > > | > > | > > | > > | > > | > > | > | > > | | 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 | int cond; if ((0100 & number) == 0) cond = 07 & number; else cond = (07 & number) + 010; switch (cond) { case 0: tem = "T"; break; case 1: tem = "-LESS-THAN"; break; case 2: tem = "-LESS-OR-EQUAL"; break; case 3: tem = "-EQUAL"; break; case 4: tem = "-IF-PAGE-FAULT"; break; case 5: tem = "-IF-PAGE-FAULT-OR-INTERRUPT"; break; case 6: tem = "-IF-SEQUENCE-BREAK"; break; case 7: tem = "NIL"; break; case 8: tem = "T"; break; case 9: tem = "-GREATER-OR-EQUAL"; break; case 10: tem = "-GREATER-THAN"; break; case 11: tem = "-NOT-EQUAL"; break; case 12: tem = "-IF-NO-PAGE-FAULT"; break; case 13: tem = "-IF-NO-PAGE-FAULT-OR-INTERRUPT"; break; case 14: tem = "-IF-NO-SEQUENCE-BREAK"; break; case 15: tem = "-NEVER"; break; default: tem = NULL; break; } if (strcmp(tem, "T") == 0) { if ((0200 & number) == 0) PRIN1("-XCT-NEXT"); PRIN1(" JUMP-CONDITION "); PRIN1("%o", 07 & number); if ((0100 & number) == 0) PRIN1("(Inverted)"); } else { if (strcmp(tem, "NIL") != 0) PRIN1("%s", tem); if ((0200 & number) == 0) PRIN1("-XCT-NEXT"); |
︙ | ︙ | |||
372 373 374 375 376 377 378 | type_jump_condition(load_byte(u, 000, 012)); m_source_desc(u); type_field(AMEM, u, 040, 012); type_field(IMEM, u, 014, 016); mf = load_byte(u, 012, 002); switch (mf) { | | > | > > | > > | > | 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 | type_jump_condition(load_byte(u, 000, 012)); m_source_desc(u); type_field(AMEM, u, 040, 012); type_field(IMEM, u, 014, 016); mf = load_byte(u, 012, 002); switch (mf) { case 0: break; case 1 ... 3: PRIN1SP("MF-%o", mf); break; } ilong = load_byte(u, 055, 001); switch (ilong) { case 0: break; case 1: PRIN1SP("ILONG"); break; } } static void dsp_const_desc(uint64_t u) { PRIN1(" ("); |
︙ | ︙ | |||
402 403 404 405 406 407 408 | int ilong; int push_own_address_p; int ifetch_p; int disp_const; PRIN1SP("DISPATCH"); disp_const = load_byte(u, 040, 012); | | < | > > | > > | > > | > | > | > > | > > | > > | > > | > > | > > | > | > | > > | > > | > | 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 | int ilong; int push_own_address_p; int ifetch_p; int disp_const; PRIN1SP("DISPATCH"); disp_const = load_byte(u, 040, 012); if (disp_const == 0); else dsp_const_desc(u); byte_field_out(u, load_byte(u, 000, 010), true, false); m_source_desc(u); type_field(DMEM, u, 014, 013); push_own_address_p = load_byte(u, 031, 001); if (push_own_address_p == 1) PRIN1SP("PUSH-OWN-ADDRESS"); ifetch_p = load_byte(u, 030, 001); if (ifetch_p == 1) PRIN1SP("IFETCH"); map = load_byte(u, 010, 002); switch (map) { case 0: break; case 1: PRIN1SP("MAP-14"); break; case 2: PRIN1SP("MAP-15"); break; case 3: PRIN1SP("MAP-BOTH-14-AND-15"); break; } mf = load_byte(u, 012, 002); switch (mf) { case 0: break; case 1 ... 3: PRIN1SP("MF-%o", mf); break; } ilong = load_byte(u, 055, 001); switch (ilong) { case 0: break; case 1: PRIN1SP("ILONG"); break; } } static void byt_desc(uint64_t u) { int byte_operation; int mf; int ilong; dest_desc(u); byte_operation = load_byte(u, 014, 002); switch (byte_operation) { case 0: PRIN1SP("BYTE-OPERATION-%o", byte_operation); break; case 1: PRIN1SP("LDB"); break; case 2: PRIN1SP("SELECTIVE-DEPOSIT"); break; case 3: PRIN1SP("DPB"); break; } byte_field_out(u, load_byte(u, 000, 012), false, true); m_source_desc(u); type_field(AMEM, u, 040, 012); mf = load_byte(u, 012, 002); switch (mf) { case 0: break; case 1 ... 3: PRIN1SP("MF-%o", mf); break; } ilong = load_byte(u, 055, 001); switch (ilong) { case 0: break; case 1: PRIN1SP("ILONG"); break; } } /* * Modify S so that there are no spaces after opening parenthesis, and * before closing parenthesis. */ |
︙ | ︙ | |||
506 507 508 509 510 511 512 | uinstbuf[0] = '\0'; uinstbufp = uinstbuf; uinstsymtab = *symtab; PRIN1("("); popj_after_next_p = load_byte(u, 052, 001); switch (popj_after_next_p) { | | > > | > > | > > | > > | > > | > | > > | > | > > | > | 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 | uinstbuf[0] = '\0'; uinstbufp = uinstbuf; uinstsymtab = *symtab; PRIN1("("); popj_after_next_p = load_byte(u, 052, 001); switch (popj_after_next_p) { case 0: break; case 1: PRIN1SP("POPJ-AFTER-NEXT"); break; } opclass = load_byte(u, 053, 002); switch (opclass) { case 0: alu_desc(u); break; case 1: jmp_desc(u); break; case 2: dsp_desc(u); break; case 3: byt_desc(u); break; } stat_bit = load_byte(u, 056, 001); switch (stat_bit) { case 0: break; case 1: PRIN1SP("STAT-BIT"); break; } bit_47 = load_byte(u, 057, 001); switch (bit_47) { case 0: break; case 1: PRIN1SP("BIT-47"); break; } PRIN1(")"); uinst_strip(uinstbuf); return uinstbuf; } |
Changes to uexec.c.
︙ | ︙ | |||
77 78 79 80 81 82 83 | int alu_carry; uint32_t alu_out; bool oal; bool oah; uint32_t out; | < | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | int alu_carry; uint32_t alu_out; bool oal; bool oah; uint32_t out; uint64_t ir(int pos, int len) { return ((uint64_t) (p0 >> pos)) & ((1 << len) - 1); } |
︙ | ︙ | |||
144 145 146 147 148 149 150 | */ int advanceLC(int ppc) { int old_lc; record_lc_history(); | | | | | 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | */ int advanceLC(int ppc) { int old_lc; record_lc_history(); old_lc = mfmem[1] & 0377777777; /* LC is 26 bits. */ if (should_dump_lc(old_lc)) { char buffer[256]; snprintf(buffer, 256, "lc-%d", old_lc); extra_dump_state(buffer); } if (interrupt_control & (1 << 29)) { mfmem[1]++; /* Byte mode. */ } else { mfmem[1] += 2; /* 16-bit mode. */ } /* * NEED-FETCH? */ if (mfmem[1] & (1UL << 31UL)) { mfmem[1] &= ~(1UL << 31UL); mfmem[020] = old_lc >> 2; |
︙ | ︙ | |||
181 182 183 184 185 186 187 | int lc1; int last_byte_in_word; /* * This is ugly, but follows the hardware logic (I * need to distill it to intent but it seems correct). */ | | | > | > | > | > | | > | > > | | | | | | | | | > | > | | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 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 | int lc1; 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. */ mfmem[1] |= (1UL << 31UL); } return ppc; } uint32_t mfread(int addr) { int res; switch (addr & 037) { case 0: return mfmem[0]; case 1: return (spcptr << 24) | (spc[spcptr] & 01777777); case 2: return mfmem[014] & 01777; case 3: return mfmem[013] & 01777; case 5: DEBUG(TRACE_MICROCODE, "reading pdl[%o] -> %o\n", mfmem[013], pdl[mfmem[013]]); res = pdl[mfmem[013]]; trace_pdlidx_read(mdata); 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); spcptr = (spcptr - 1) & 037; return res; case 024: DEBUG(TRACE_MICROCODE, "reading pdl[%o] -> %o, pop\n", mfmem[014], pdl[mfmem[014]]); |
︙ | ︙ | |||
248 249 250 251 252 253 254 | } } void mfwrite(int dest, uint64_t data) { switch (dest >> 5) { | | | | | | | | | | | | | | | | | | | | | | 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | } } void mfwrite(int dest, uint64_t data) { switch (dest >> 5) { case 1: /* LOCATION-COUNTER LC (location counter) 26 bits. */ DEBUG(TRACE_UCODE, "writing LC <- %o\n", data); mfmem[1] = (mfmem[1] & ~0377777777) | (data & 0377777777); if (interrupt_control & (1 << 29)) { /* * ---!!! Not sure about byte mode... */ } else { /* * In half word mode, low order bit is * ignored. */ mfmem[1] &= ~1; } /* * Set NEED-FETCH. */ mfmem[1] |= (1UL << 31UL); break; case 2: /* INTERRUPT-CONTROL Interrupt Control <29-26>. */ DEBUG(TRACE_UCODE, "writing IC <- %o\n", data); interrupt_control = data; if (interrupt_control & (1 << 26)) { DEBUG(TRACE_UCODE, "ic: sequence break request\n"); } if (interrupt_control & (1 << 27)) { DEBUG(TRACE_UCODE, "ic: interrupt enable\n"); } 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) */ mfmem[014] = (mfmem[014] + 1) & 01777; DEBUG(TRACE_UCODE, "writing pdl[%o] <- %o, push\n", mfmem[014], data); trace_pdlptr_push(data); pdl[mfmem[014]] = data; break; case 012: /* C-PDL-BUFFER-INDEX PDL (address by index). */ DEBUG(TRACE_UCODE, "writing pdl[%o] <- %o\n", mfmem[013], data); pdl[mfmem[013]] = data; trace_pdlidx_write(data); break; case 013: /* PDL-BUFFER-INDEX PDL index. */ DEBUG(TRACE_UCODE, "pdl-index <- %o\n", data); mfmem[013] = data & 01777; break; case 014: /* PDL-BUFFER-POINTER PDL pointer. */ DEBUG(TRACE_UCODE, "pdl-ptr <- %o\n", data); mfmem[014] = data & 01777; break; case 015: /* MICRO-STACK-DATA-PUSH SPC data, push. */ pushSPC(data); break; case 016: /* OA-REG-LO Next instruction modifier (lo). */ mfmem[016] = data & 0377777777; oal = true; DEBUG(TRACE_UCODE, "setting oa_reg lo %o\n", mfmem[016]); break; case 017: /* OA-REG-HI Next instruction modifier (hi). */ mfmem[017] = data; oah = true; DEBUG(TRACE_UCODE, "setting oa_reg hi %o\n", mfmem[017]); break; case 020: /* VMA VMA register (memory address). */ mfmem[020] = data; break; case 021: /* VMA-START-READ VMA register, start main memory read. */ mfmem[020] = data; vmRead(mfmem[020], &new_md); new_md_delay = 2; break; case 022: /* VMA-START-WRITE VMA register, start main memory write. */ mfmem[020] = data; vmWrite(mfmem[020], mfmem[030]); break; case 023: /* VMA-WRITE-MAP VMA register, write map. */ mfmem[020] = data; DEBUG(TRACE_VM, "vma-write-map md=%o, vma=%o (addr %o)\n", mfmem[030], mfmem[020], mfmem[030] >> 13); mapWrite(); break; case 030: /* MEMORY-DATA MD register (memory data). */ mfmem[030] = data; DEBUG(TRACE_UCODE, "md<-%o\n", mfmem[030]); break; case 031: /* MEMORY-DATA-START-READ */ mfmem[030] = data; vmRead(mfmem[020], &new_md); new_md_delay = 2; break; case 032: /* MEMORY-DATA-START-WRITE */ mfmem[030] = data; vmWrite(mfmem[020], mfmem[030]); break; case 033: /* MEMORY-DATA-WRITE-MAP MD register, write map (like 23). */ mfmem[030] = data; DEBUG(TRACE_UCODE, "memory-data-write-map md=%o, vma=%o (addr %o)\n", mfmem[030], mfmem[020], mfmem[030] >> 13); mapWrite(); break; } } |
︙ | ︙ | |||
465 466 467 468 469 470 471 | alu_carry = (lv >> 32) ? 1 : 0; break; case 025: lv = (int64_t) (mdata | ~adata) + (mdata & adata) + (cin ? 1 : 0); alu_out = (uint32_t) lv; alu_carry = (lv >> 32) ? 1 : 0; break; | | | | | | > > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > > | > | > > | 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 | alu_carry = (lv >> 32) ? 1 : 0; break; case 025: lv = (int64_t) (mdata | ~adata) + (mdata & adata) + (cin ? 1 : 0); alu_out = (uint32_t) lv; alu_carry = (lv >> 32) ? 1 : 0; break; case 026: /* [M-A-1] [SUB] */ sub32(mdata, adata, cin, alu_out, alu_carry); break; case 027: lv = (int64_t) (mdata | ~adata) + mdata + (cin ? 1 : 0); alu_out = (uint32_t) lv; alu_carry = (lv >> 32) ? 1 : 0; break; case 030: lv = (int64_t) (mdata | adata) + (cin ? 1 : 0); alu_out = (uint32_t) lv; alu_carry = (lv >> 32) ? 1 : 0; break; case 031: /* [ADD] [M+A+1] */ add32(mdata, adata, cin, alu_out, alu_carry); break; case 032: lv = (int64_t) (mdata | adata) + (mdata & ~adata) + (cin ? 1 : 0); alu_out = (uint32_t) lv; alu_carry = (lv >> 32) ? 1 : 0; break; case 033: lv = (int64_t) (mdata | adata) + mdata + (cin ? 1 : 0); alu_out = (uint32_t) lv; alu_carry = (lv >> 32) ? 1 : 0; break; case 034: /* [M+1] */ alu_out = mdata + (cin ? 1 : 0); alu_carry = 0; if (mdata == (int) 0xffffffff && cin) alu_carry = 1; break; case 035: lv = (int64_t) mdata + (mdata & adata) + (cin ? 1 : 0); alu_out = (uint32_t) lv; alu_carry = (lv >> 32) ? 1 : 0; break; case 036: lv = (int64_t) mdata + (mdata | ~adata) + (cin ? 1 : 0); alu_out = (uint32_t) lv; alu_carry = (lv >> 32) ? 1 : 0; break; case 037: /* [M+M] [M+M+1] */ add32(mdata, mdata, cin, alu_out, alu_carry); break; } } void logiOps(int op) { switch (op) { case 000: alu_out = 0; break; case 001: alu_out = mdata & adata; break; case 002: alu_out = mdata & ~adata; break; case 003: alu_out = mdata; break; case 004: alu_out = ~mdata & adata; break; case 005: alu_out = adata; break; case 006: alu_out = mdata ^ adata; break; case 007: alu_out = mdata | adata; break; case 010: alu_out = ~adata & ~mdata; break; case 011: alu_out = adata == mdata; break; case 012: alu_out = ~adata; break; case 013: alu_out = mdata | ~adata; break; case 014: alu_out = ~mdata; break; case 015: alu_out = ~mdata | adata; break; case 016: alu_out = ~mdata | ~adata; break; case 017: alu_out = ~0; break; } } void divOps(int op) { int cin = ir(2, 1); |
︙ | ︙ | |||
677 678 679 680 681 682 683 | break; } } disp_addr &= 03777; DEBUG(TRACE_MICROCODE, "dispatch[%o] -> %o ", disp_addr, dmem[disp_addr]); disp_addr = dmem[disp_addr]; mfmem[0] = disp_const; | | | 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 | break; } } disp_addr &= 03777; DEBUG(TRACE_MICROCODE, "dispatch[%o] -> %o ", disp_addr, dmem[disp_addr]); disp_addr = dmem[disp_addr]; mfmem[0] = disp_const; target = disp_addr & 037777; /* 14 bits. */ n = (disp_addr >> 14) & 1; p = (disp_addr >> 15) & 1; r = (disp_addr >> 16) & 1; DEBUG(TRACE_MICROCODE, "%s%s%s\n", n ? "N " : "", p ? "P " : "", r ? "R " : ""); if (n_plus1 && n) { npc--; } |
︙ | ︙ | |||
727 728 729 730 731 732 733 | int rot = ir(0, 5); DEBUG(TRACE_MICROCODE, "jump-if-bit; rot %o, before %o ", rot, mdata); mdata = rol32(mdata, rot); DEBUG(TRACE_MICROCODE, "after %o\n", mdata); return mdata & 1; } | < | > > | > | > | | | | | > | 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 | int rot = ir(0, 5); DEBUG(TRACE_MICROCODE, "jump-if-bit; rot %o, before %o ", rot, mdata); mdata = rol32(mdata, rot); DEBUG(TRACE_MICROCODE, "after %o\n", mdata); return mdata & 1; } // Internal condition. switch (ir(0, 4)) { case 0: /* illegal ??? */ break; case 1: return mdata < adata; case 2: return mdata <= adata; case 3: return mdata == adata; case 4: return page_fault_flag; /* vmaok */ case 5: DEBUG(TRACE_MICROCODE, "jump i|pf\n"); /* pgf.or.int */ return page_fault_flag | (interrupt_control & (1 << 27) ? interrupt_pending_flag : 0); case 6: DEBUG(TRACE_MICROCODE, "jump i|pf|sb\n"); /* pgf.or.int.sb */ return page_fault_flag | (interrupt_control & (1 << 27) ? interrupt_pending_flag : 0) | (interrupt_control & (1 << 26)); case 7: return 1; } } void jmp(void) { int target = ir(12, 14); |
︙ | ︙ | |||
822 823 824 825 826 827 828 | int left_mask_index; uint32_t left_mask; uint32_t right_mask; int right_mask_index; right_mask_index = pos; | | | | 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 | int left_mask_index; uint32_t left_mask; uint32_t right_mask; int right_mask_index; right_mask_index = pos; left_mask_index = (right_mask_index + widthm1) & 037; /* mod 32? */ left_mask = ~0; right_mask = ~0; left_mask >>= 31 - left_mask_index; right_mask <<= right_mask_index; //DEBUG(TRACE_MICROCODE, "widthm1 %o, pos %o, mr_sr_bits %o\n", widthm1, pos, mr_sr_bits); DEBUG(TRACE_MICROCODE, "left_mask_index %o, right_mask_index %o\n", left_mask_index, right_mask_index); DEBUG(TRACE_MICROCODE, "left_mask %o, right_mask %o, mask %o\n", left_mask, right_mask, left_mask & right_mask); return left_mask & right_mask; } void byt(void) { int dest = ir(14, 12); int mr_sr_bits = ir(12, 2); int pos = ir(0, 5); // p0 & 037; uint32_t mask; DEBUG(TRACE_MICROCODE, "a=%o (%o), m=%o (%o), dest=%o\n", aaddr, adata, maddr, mdata, dest); if (ir(10, 2) == 3) pos = lcbytemode(); |
︙ | ︙ | |||
928 929 930 931 932 933 934 | popj = ir(42, 1); aaddr = ir(32, 10); maddr = ir(26, 5); adata = amem[aaddr]; mdata = (ir(31, 1) == 0) ? mmem[maddr] : mfread(maddr); op = ir(43, 2); switch (op) { | | > > | > > | > > | > > | 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 | popj = ir(42, 1); aaddr = ir(32, 10); maddr = ir(26, 5); adata = amem[aaddr]; mdata = (ir(31, 1) == 0) ? mmem[maddr] : mfread(maddr); op = ir(43, 2); switch (op) { case 0: alu(); break; case 1: jmp(); break; case 2: dsp(); break; case 3: byt(); break; } if (popj) { int old_npc; DEBUG(TRACE_MICROCODE, "popj; "); old_npc = npc; npc = popSPC(); |
︙ | ︙ |
Changes to x11.c.
︙ | ︙ | |||
136 137 138 139 140 141 142 | DEBUG(TRACE_KBD, "cadet_allup_key() - found a key that is up which is not a shift; keymap[%d] = 0%o\n", i, keymap[i]); allup = false; break; } } if (allup == true) { DEBUG(TRACE_KBD, "cadet_allup_key() - all-up event; mods = 0%o, shifts = 0%o\n", mods, shifts); | | | | | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | DEBUG(TRACE_KBD, "cadet_allup_key() - found a key that is up which is not a shift; keymap[%d] = 0%o\n", i, keymap[i]); allup = false; break; } } if (allup == true) { DEBUG(TRACE_KBD, "cadet_allup_key() - all-up event; mods = 0%o, shifts = 0%o\n", mods, shifts); cadet_shifts = shifts; /* Keep track of shifts. */ cadet_allup_event(mods); /* Generate all-up event. */ } return allup; } /* * Takes E, converts it into a LM (hardware) keycode and sends it to * the IOB KBD. */ static void process_key(XEvent *e, int keydown) { KeySym keysym; KeyCode keycode; static XComposeStatus status; int bi; unsigned char buf[5]; idle_keyboard_activity(); XLookupString(&e->xkey, (char *) buf, sizeof(buf), &keysym, &status); keycode = x11_keysym_to_keycode(keysym); if (keycode == NoSymbol || keysym > NELEM(kbd_map)) { NOTICE(TRACE_USIM, "kbd (cadet@x11): unable to translate to keycode (keysym = 0%o)\n", keysym); return; } if (kbd_type == 0) { if (!keydown) |
︙ | ︙ | |||
251 252 253 254 255 256 257 | XKeyboardControl kc; XKeyboardControl okc; static int onoff = 100; onoff = -onoff; XGetKeyboardControl(display, &okc); | | | | | | 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 | XKeyboardControl kc; XKeyboardControl okc; static int onoff = 100; onoff = -onoff; XGetKeyboardControl(display, &okc); kc.key_click_percent = 0; /* 0 - 100 */ kc.bell_percent = 100; /* 0 - 100 */ kc.bell_pitch = 755; /* Hz */ kc.bell_duration = 10; /* milliseconds */ XChangeKeyboardControl(display, KBBellPercent | KBBellPitch | KBBellDuration, &kc); XBell(display, onoff); /* display, percent */ XChangeKeyboardControl(display, KBBellPercent | KBBellPitch | KBBellDuration, &okc); } void x11_event(void) |
︙ | ︙ |