usim

Check-in [b24e6a0b4b]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Start adding boiler plate to implement %BEEP.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | ams/sdl
Files: files | file ages | folders
SHA3-256: b24e6a0b4bb0384c45b31477e60ab4497ba474b786d9e9d2721b9d1cdae14d84
User & Date: ams 2024-06-18 09:02:19
Context
2024-06-18
11:02
sdl2.c: Snatch LD beep code; we have beeps .. beep beep. check-in: baee42c695 user: ams tags: ams/sdl
09:02
Start adding boiler plate to implement %BEEP. check-in: b24e6a0b4b user: ams tags: ams/sdl
08:40
Minor cleanups. check-in: 303b8a6283 user: ams tags: ams/sdl
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to iob.c.

58
59
60
61
62
63
64
65












66

67
68
69
70
71
72
73
		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");












		fprintf(stderr, "\a");	/* Beep! */

		break;
	case 0112:
		*pv = iob_csr;
		INFO(TRACE_IOB | TRACE_UNIBUS, "unibus: kbd csr %011o\n", *pv);
		break;
	case 0120:
		iob_usec = get_us_clock();







|
>
>
>
>
>
>
>
>
>
>
>
>

>







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
		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_SDL2
		sdl2_beep();
#else
		fprintf(stderr, "\a");	/* Beep! */
#endif
		break;
	case 0112:
		*pv = iob_csr;
		INFO(TRACE_IOB | TRACE_UNIBUS, "unibus: kbd csr %011o\n", *pv);
		break;
	case 0120:
		iob_usec = get_us_clock();
132
133
134
135
136
137
138












139
140
141
142
143
144
145
		INFO(TRACE_IOB | TRACE_UNIBUS, "unibus: mouse y\n");
		break;
	case 0106:
		INFO(TRACE_IOB | TRACE_UNIBUS, "unibus: mouse x\n");
		break;
	case 0110:
		INFO(TRACE_IOB | TRACE_UNIBUS, "unibus: beep\n");












		break;
	case 0112:
		INFO(TRACE_IOB | TRACE_UNIBUS, "unibus: kbd csr\n");
		iob_csr = (iob_csr & ~017) | (v & 017);
		break;
	case 0120:
		INFO(TRACE_IOB | TRACE_UNIBUS, "unibus: usec clock\n");







>
>
>
>
>
>
>
>
>
>
>
>







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
		INFO(TRACE_IOB | TRACE_UNIBUS, "unibus: mouse y\n");
		break;
	case 0106:
		INFO(TRACE_IOB | TRACE_UNIBUS, "unibus: mouse x\n");
		break;
	case 0110:
		INFO(TRACE_IOB | TRACE_UNIBUS, "unibus: beep\n");
		/* 
		 * Triggered via %BEEP.
		 */
#if WITH_X11
		x11_beep();
#elif WITH_SDL1
		sdl1_beep();
#elif WITH_SDL2
		sdl2_beep();
#else
		fprintf(stderr, "\a");	/* Beep! */
#endif
		break;
	case 0112:
		INFO(TRACE_IOB | TRACE_UNIBUS, "unibus: kbd csr\n");
		iob_csr = (iob_csr & ~017) | (v & 017);
		break;
	case 0120:
		INFO(TRACE_IOB | TRACE_UNIBUS, "unibus: usec clock\n");

Changes to sdl1.c.

247
248
249
250
251
252
253





254
255
256
257
258
259
260
			break;
		case SDL_QUIT:
			exit(0);
			break;
		}
	}
}






void
sdl1_init(void)
{
	NOTICE(TRACE_USIM, "tv: using SDL backend for monitor and keyboard\n");

	Foreground = 0xff; // White







>
>
>
>
>







247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
			break;
		case SDL_QUIT:
			exit(0);
			break;
		}
	}
}

void
sdl1_beep()
{
}

void
sdl1_init(void)
{
	NOTICE(TRACE_USIM, "tv: using SDL backend for monitor and keyboard\n");

	Foreground = 0xff; // White

Changes to sdl2.c.

258
259
260
261
262
263
264




265
266
267
268
269
270
271
		case SDL_QUIT:
			exit(0);
			break;
		}
	}
}






void
sdl2_init(void)
{
	NOTICE(TRACE_USIM, "tv: using SDL backend for monitor and keyboard\n");

	Foreground = 0xffffff; // White







>
>
>
>







258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
		case SDL_QUIT:
			exit(0);
			break;
		}
	}
}

void
sdl2_beep()
{
}

void
sdl2_init(void)
{
	NOTICE(TRACE_USIM, "tv: using SDL backend for monitor and keyboard\n");

	Foreground = 0xffffff; // White

Changes to x11.c.

180
181
182
183
184
185
186



















187
188
189
190
191
192
193
	case IDLE_WORKING:
		XSetForeground(display, idle_gc, Background);
		break;
	}
	XDrawLine(display, window, idle_gc, tv_width - width - right, tv_height - bottom, tv_width - right, tv_height - bottom);
}




















void
x11_event(void)
{
	XEvent e;

	send_accumulated_updates();
	kbd_dequeue_key_event();







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
	case IDLE_WORKING:
		XSetForeground(display, idle_gc, Background);
		break;
	}
	XDrawLine(display, window, idle_gc, tv_width - width - right, tv_height - bottom, tv_width - right, tv_height - bottom);
}

void
x11_beep(void)
{
	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)
{
	XEvent e;

	send_accumulated_updates();
	kbd_dequeue_key_event();