Jspice3
mfbcursr.c File Reference
#include "mfb.h"
#include "mfbP.h"
#include <ctype.h>
#include <time.h>
Include dependency graph for mfbcursr.c:

Go to the source code of this file.

Functions

static int kb_point ()
 
static void newmark ()
 
static int mouse_point ()
 
static void get_config ()
 
static void dummy ()
 
int MFBPoint (int *x, int *y, int *key, int *button)
 
static int kb_point (int *x, int *y, int *key, int *button)
 
static void newmark (int xold, int yold, int x, int y)
 
static int mouse_point (int *x, int *y, int *key, int *button)
 
void MFBPointerInit ()
 
void MFBPointerClose ()
 
static void get_config (int *irq, int *adrs, int *pointer)
 

Variables

static void(* pointer_status )()
 
static void(* pointer_on )()
 
static void(* pointer_off )()
 
static void(* pointer_close )()
 
int functkey_dx
 

Function Documentation

static void dummy ( )
static

Definition at line 550 of file mfbcursr.c.

550 {}
static void get_config ( )
static
static void get_config ( int *  irq,
int *  adrs,
int *  pointer 
)
static

Definition at line 489 of file mfbcursr.c.

492 {
493  FILE *fp;
494  char s[128], *getenv();
495  int i = 0;
496  static int savirq,savadrs,savtype;
497 
498  if (savtype) {
499  *irq = savirq;
500  *adrs = savadrs;
501  *pointer = savtype;
502  return;
503  }
504 
505  fp = fopen("mfb.rc","r");
506  if (!fp) {
507  strcpy(s,MFBRCD);
508  strcat(s,"\\mfb.rc");
509  fp = fopen(s,"r");
510  }
511  if (!fp) {
512  /* No mfb.rc file found. Is there a mouse driver? */
513  if (ms_hreset())
514  *pointer = MSMOUSE;
515  else
516  *pointer = KBRD;
517  savtype = *pointer;
518  return;
519  }
520  while (fgets(s,128,fp) != NULL) {
521  if (*s == '#') continue;
522  switch (i) {
523  case 0:
524  sscanf(s,"%d",irq);
525  break;
526  case 1:
527  sscanf(s,"%x",adrs);
528  break;
529  case 2:
530  if (!strncmp(s,"pad",3))
531  *pointer = MMTAB;
532  else if (!strncmp(s,"mouse",5))
533  *pointer = MSMOUSE;
534  else if (!strncmp(s,"keys",4))
535  *pointer = KBRD;
536  break;
537  default:
538  break;
539  }
540  i++;
541  }
542  fclose(fp);
543  savirq = *irq;
544  savadrs = *adrs;
545  savtype = *pointer;
546 }
int ms_hreset()
Definition: msinterf.c:71
char * strcpy()
Definition: cddefs.h:119
#define MMTAB
Definition: mfbp.h:92
#define KBRD
Definition: mfbp.h:90
char * MFBRCD
char * getenv(char *c)
Definition: libfuncs.c:106
#define NULL
Definition: spdefs.h:121
#define MSMOUSE
Definition: mfbp.h:91
static int kb_point ( )
static
static int kb_point ( int *  x,
int *  y,
int *  key,
int *  button 
)
static

Definition at line 62 of file mfbcursr.c.

66 {
67  int k;
68  int xo = 8, yo = 7, x2o, y2o;
69  int xs = pc.xsize - 1;
70  int ys = pc.ysize - 1;
71 
73 
74  if (functkey_dx == 0)
75  functkey_dx = pc.xsize/32;
76 
77  x2o = xo << 1;
78  y2o = yo << 1;
79 
80  *key = '\0';
81 
82  for (;;) {
83  k = MFBGetchar();
84  switch (k) {
85 
86  /* arrow keys */
87  case 333: /* right */
88  if (pc.cursx < xs - pc.curstep - xo) {
90  }
91  break;
92  case 331: /* left */
93  if (pc.cursx > pc.curstep - xo) {
95  }
96  break;
97  case 328: /* up */
98  if (pc.cursy < ys - pc.curstep + yo) {
100  }
101  break;
102  case 336: /* down */
103  if (pc.cursy > pc.curstep + yo) {
105  }
106  break;
107  case 372: /* control right */
108  if (pc.cursx < xs - xo) {
110  }
111  break;
112  case 371: /* control left */
113  if (pc.cursx > -xo) {
115  }
116  break;
117  case 397: /* control up */
118  if (pc.cursy < ys + yo) {
120  }
121  break;
122  case 401: /* control down */
123  if (pc.cursy > yo) {
125  }
126  break;
127  case 413: /* alt right */
128  if (pc.cursx < xs - pc.curleap - xo) {
130  }
131  break;
132  case 411: /* alt left */
133  if (pc.cursx > pc.curleap - xo) {
135  }
136  break;
137  case 408: /* alt up */
138  if (pc.cursy < ys - pc.curleap + yo) {
140  }
141  break;
142  case 416: /* alt down */
143  if (pc.cursy > pc.curleap + yo) {
145  }
146  break;
147 
148  /* function keys */
149 #ifdef SELECT
150  case 315: /* F1 */
151  *x = functkey_dx;
152  goto select;
153  case 316: /* F2 */
154  *x = 3*functkey_dx;
155  goto select;
156  case 317: /* F3 */
157  *x = 5*functkey_dx;
158  goto select;
159  case 318: /* F4 */
160  *x = 7*functkey_dx;
161  goto select;
162  case 319: /* F5 */
163  *x = 9*functkey_dx;
164  goto select;
165  case 320: /* F6 */
166  *x = 11*functkey_dx;
167  goto select;
168  case 321: /* F7 */
169  *x = 13*functkey_dx;
170  goto select;
171  case 322: /* F8 */
172  *x = 15*functkey_dx;
173  goto select;
174  case 323: /* F9 */
175  *x = 17*functkey_dx;
176  goto select;
177  case 324: /* F10 */
178  *x = 19*functkey_dx;
179  goto select;
180  case 389: /* F11 */
181  *x = 21*functkey_dx;
182  goto select;
183  case 390: /* F12 */
184  *x = 23*functkey_dx;
185  goto select;
186 #endif
187 
188  /* page keys */
189  case 327: /* HOME */
190  newmark(pc.cursx,pc.cursy,1,ys-1);
191  break;
192  case 335: /* END */
193  newmark(pc.cursx,pc.cursy,xs-x2o-1,y2o+1);
194  break;
195  case 329: /* PgUp */
196  newmark(pc.cursx,pc.cursy,pc.cursx,ys-1);
197  break;
198  case 337: /* PgDn */
199  newmark(pc.cursx,pc.cursy,pc.cursx,y2o+1);
200  break;
201  case 338: /* INS */
202  newmark(pc.cursx,pc.cursy,xs/2 - xo,ys/2 + yo);
203  break;
204 
205 
206  case 13: /* CR */ /* yellow button */
207  *x = pc.cursx + xo;
208  *y = pc.cursy - yo;
209  *button = 1;
210  goto terminate;
211  case 10: /* LF */ /* white button */
212  *x = pc.cursx + xo;
213  *y = pc.cursy - yo;
214  *button = 2;
215  goto terminate;
216  case 339: /*DEL */ /* green button */
217  *x = pc.cursx + xo;
218  *y = pc.cursy - yo;
219  *button = 8;
220  goto terminate;
221  case 284: /* alt ENTER */ /* blue button */
222  *x = pc.cursx + xo;
223  *y = pc.cursy - yo;
224  *button = 4;
225  goto terminate;
226  default:
227  *key = k;
228  *button = 0;
229  *x = pc.cursx + xo;
230  *y = pc.cursy - yo;
231  goto terminate;
232  }
233  }
234 
235 #ifdef SELECT
236 select:
237  *y = pc.functkey_yband;
238  *button = 1;
239 #endif
240 
241 terminate:
243  return (MFBOK);
244 }
void MFBDrawCursor(int x, int y)
Definition: mfbmark.c:26
#define MFBOK
Definition: mfb.h:491
int curleap
Definition: mfbp.h:59
int functkey_dx
Definition: mfbcursr.c:42
int ysize
Definition: mfbp.h:54
int curstep
Definition: mfbp.h:58
int MFBGetchar()
Definition: mfbopen.c:259
int cursx
Definition: mfbp.h:51
int functkey_yband
Definition: mfbp.h:66
int xsize
Definition: mfbp.h:53
static void newmark()
struct mfbpc pc
Definition: mfbopen.c:14
void MFBEraseCursor(int x, int y)
Definition: mfbmark.c:48
int cursy
Definition: mfbp.h:52
int MFBPoint ( int *  x,
int *  y,
int *  key,
int *  button 
)

Definition at line 46 of file mfbcursr.c.

49 {
50  switch (pc.pointertype) {
51  case MSMOUSE:
52  case MMTAB:
53  return (mouse_point(x,y,key,button));
54  case KBRD:
55  return (kb_point(x,y,key,button));
56  }
57  return (0);
58 }
int pointertype
Definition: mfbp.h:60
#define MMTAB
Definition: mfbp.h:92
static int mouse_point()
#define KBRD
Definition: mfbp.h:90
#define MSMOUSE
Definition: mfbp.h:91
static int kb_point()
struct mfbpc pc
Definition: mfbopen.c:14
void MFBPointerClose ( )

Definition at line 481 of file mfbcursr.c.

483 {
484  pointer_close();
485 }
static void(* pointer_close)()
Definition: mfbcursr.c:39
void MFBPointerInit ( )

Definition at line 440 of file mfbcursr.c.

442 {
443  int irq = 4, serport = 0x3f8; /* default to com1 */
444  int type;
445 
446  /* Pointer type can be coerced by setting pc.pointertype
447  * before calling this routine.
448  */
449  type = pc.pointertype;
450  get_config(&irq,&serport,&type);
451 
452  if (!pc.pointertype) pc.pointertype = type;
453  switch (pc.pointertype) {
454  case MSMOUSE:
455  ms_start();
460  break;
461 
462 #ifdef DPAD_SUPPORT
463  case MMTAB:
464  dp_start(irq,serport);
469  break;
470 #endif
471 
472  default:
473  case KBRD:
475  break;
476  }
477 }
int pointertype
Definition: mfbp.h:60
static void(* pointer_close)()
Definition: mfbcursr.c:39
void dp_pointer_off()
Definition: dpinterf.c:87
static void(* pointer_on)()
Definition: mfbcursr.c:37
void dp_start()
static void dummy()
Definition: mfbcursr.c:550
#define MMTAB
Definition: mfbp.h:92
#define KBRD
Definition: mfbp.h:90
void dp_status()
Definition: types.c:18
static void(* pointer_off)()
Definition: mfbcursr.c:38
void dp_end()
Definition: dpinterf.c:62
void dp_pointer_on()
Definition: dpinterf.c:74
void ms_pointer_off()
Definition: msinterf.c:98
#define MSMOUSE
Definition: mfbp.h:91
void ms_end()
Definition: msinterf.c:62
void ms_start()
Definition: msinterf.c:15
void ms_pointer_on()
Definition: msinterf.c:85
void ms_status()
static void(* pointer_status)()
Definition: mfbcursr.c:36
struct mfbpc pc
Definition: mfbopen.c:14
static void get_config()
static int mouse_point ( )
static
static int mouse_point ( int *  x,
int *  y,
int *  key,
int *  button 
)
static

Definition at line 284 of file mfbcursr.c.

288 {
289  int b = 0;
290  int k;
291  int xlast, ylast;
292 
293  *key = '\0';
294 
295  do {
296  ms_status(&pc.cursx,&pc.cursy,&b);
297  } while (b);
298  ms_point(&pc.cursx,&pc.cursy,&k,&b);
299 
300  switch (b & 7) {
301 
302  case 0:
303 #ifdef SELECT
304  if (functkey_dx == 0)
305  functkey_dx = pc.xsize/32;
306 
307  switch (k) {
308 
309  /* function keys */
310 
311  case 315: /* F1 */
312  *x = functkey_dx;
313  goto select;
314 
315  case 316: /* F2 */
316  *x = 3*functkey_dx;
317  goto select;
318 
319  case 317: /* F3 */
320  *x = 5*functkey_dx;
321  goto select;
322 
323  case 318: /* F4 */
324  *x = 7*functkey_dx;
325  goto select;
326 
327  case 319: /* F5 */
328  *x = 9*functkey_dx;
329  goto select;
330 
331  case 320: /* F6 */
332  *x = 11*functkey_dx;
333  goto select;
334 
335  case 321: /* F7 */
336  *x = 13*functkey_dx;
337  goto select;
338 
339  case 322: /* F8 */
340  *x = 15*functkey_dx;
341  goto select;
342 
343  case 323: /* F9 */
344  *x = 17*functkey_dx;
345  goto select;
346 
347  case 324: /* F10 */
348  *x = 19*functkey_dx;
349  goto select;
350 
351  case 389: /* F11 */
352  *x = 21*functkey_dx;
353  goto select;
354 
355  case 390: /* F12 */
356  *x = 23*functkey_dx;
357  goto select;
358 
359  /* arrow keys */
360  /* case 333: right */
361  /* case 331: left */
362  case 328: /* up */
363  case 336: /* down */
364  *x = pc.xsize - functkey_dx;
365  goto select;
366 
367  case 13: /* CR */ /* yellow button */
368  *button = 1;
369  goto terminate;
370 
371  case 10: /* LF */ /* white button */
372  *button = 2;
373  goto terminate;
374 
375  case 339: /*DEL */ /* green button */
376  *button = 3;
377  goto terminate;
378 
379  case 284: /* alt ENTER */ /* blue button */
380  *button = 4;
381  goto terminate;
382 
383  default:
384  *key = k;
385  *button = 0;
386  goto terminate;
387  }
388 #else /*SELECT */
389  *key = k;
390  *button = 0;
391  goto terminate;
392 #endif
393 
394  case 1: /* center, yellow */
395  *button = 1;
396  goto terminate;
397 
398  case 2:
399  /* right, blue */
400  *button = 4;
401  goto terminate;
402 
403  case 3: /* center and right */
404  *button = 1;
405  goto terminate;
406 
407  case 4: /* left, white */
408  *button = 2;
409  goto terminate;
410 
411  case 5: /* left and center, or lower center, green */
412  *button = 8;
413  goto terminate;
414 
415  case 6: /* rignt and left */
416  *button = 1;
417  goto terminate;
418 
419  case 7:
420  *button = 1;
421  goto terminate;
422  }
423 
424 #ifdef SELECT
425 select:
426  *y = pc.functkey_yband;
427  if (*x > pc.xsize-functkey_dx) *x = pc.xsize-functkey_dx;
428  *button = 1;
429  return (MFBOK);
430 #endif
431 
432 terminate:
433  *x = pc.cursx;
434  *y = pc.cursy;
435  return (MFBOK);
436 }
void ms_point()
#define MFBOK
Definition: mfb.h:491
int functkey_dx
Definition: mfbcursr.c:42
int cursx
Definition: mfbp.h:51
int functkey_yband
Definition: mfbp.h:66
int xsize
Definition: mfbp.h:53
void ms_status()
struct mfbpc pc
Definition: mfbopen.c:14
int cursy
Definition: mfbp.h:52
static void newmark ( )
static
static void newmark ( int  xold,
int  yold,
int  x,
int  y 
)
static

Definition at line 248 of file mfbcursr.c.

251 {
252  MFBEraseCursor(xold,yold);
253  pc.cursx = x;
254  pc.cursy = y;
255  MFBDrawCursor(x,y);
256 }
void MFBDrawCursor(int x, int y)
Definition: mfbmark.c:26
int cursx
Definition: mfbp.h:51
struct mfbpc pc
Definition: mfbopen.c:14
void MFBEraseCursor(int x, int y)
Definition: mfbmark.c:48
int cursy
Definition: mfbp.h:52

Variable Documentation

int functkey_dx

Definition at line 42 of file mfbcursr.c.

void(* pointer_close) ()
static

Definition at line 39 of file mfbcursr.c.

void(* pointer_off) ()
static

Definition at line 38 of file mfbcursr.c.

void(* pointer_on) ()
static

Definition at line 37 of file mfbcursr.c.

void(* pointer_status) ()
static

Definition at line 36 of file mfbcursr.c.