-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathst520.c
1022 lines (830 loc) · 19.2 KB
/
st520.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
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
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
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
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
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
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
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
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
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
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
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
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
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
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
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
998
999
1000
/*
The routines in this file provide support for the Atari 520 or 1040ST
using VT52 emulation. The I/O services are provided here as well. It
compiles into nothing if not a 520ST style device.
*/
#define termdef 1 /* don't define "term" external */
#include <stdio.h>
#include "estruct.h"
#include "edef.h"
#if ATARI & ST520 & MEGAMAX
#include <osbind.h>
#include <ctype.h>
#define LINEA_INIT 0xA000
#define V_CEL_WR -0x28
#define V_CEL_MY -0x2a
#define V_CEL_HT -0x2e
#define V_FNT_AD -0x16
#define V_OFF_AD -0x0a
#define V_DISAB -346
#define NROW 25 /* Screen size. */
#define NCOL 80 /* Edit if you want to. */
#define MARGIN 8 /* size of minimim margin and */
#define SCRSIZ 64 /* scroll size for extended lines */
#define NPAUSE 25 /* # times thru update to pause */
#define BIAS 0x20 /* Origin 0 coordinate bias. */
#define ESC 0x1B /* ESC character. */
#define BEL 0x07 /* ascii bell character */
extern int st520move(); /* Forward references. */
extern int st520eeol();
extern int st520eeop();
extern int st520beep();
extern int st520open();
extern int st520close();
extern int st520rev();
extern int st520kopen();
extern int st520kclose();
extern int st520chgrez();
#if COLOR
extern int st520fcol();
extern int st520bcol();
int cfcolor = -1; /* current fg (character) color */
int cbcolor = -1; /* current bg color */
int oldpal[8]; /* pallette when emacs was invoked */
int newpal[8] = { /* default emacs pallette */
0x000, 0x700, 0x070, 0x770, 0x007, 0x707, 0x077, 0x777};
#endif
int STncolors = 0; /* number of colors */
int STrez; /* physical screen resolution */
/*
* Dispatch table. All the
* hard fields just point into the
* terminal I/O code.
*/
TERM term = {
NROW-1,
NCOL,
MARGIN,
MARGIN,
SCRSIZ,
NPAUSE,
&st520open,
&st520close,
&st520kopen,
&st520kclose,
&ttgetc,
&ttputc,
&ttflush,
&st520move,
&st520eeol,
&st520eeop,
&st520beep,
&st520rev
#if MULTREZ
, &st520chgrez
#endif
#if COLOR
, &st520fcol,
&st520bcol
#endif
};
struct KBDvecs {
int (*midivec) ();
int (*vkbderr) ();
int (*vmiderr) ();
int (*statvec) ();
int (*mousevec) ();
int (*clockvec) ();
int (*joyvec) ();
int (*midisys) ();
int (*ikbdsys) ();
};
struct Param {
char topmode;
char buttons;
char xparam;
char yparam;
int xmax,ymax;
int xinitial,yinitial;
};
struct KBDvecs *kbdvecs;
struct Param *paramp;
char kbdcmds[25];
st520move(row, col)
{
ttputc(ESC);
ttputc('Y');
ttputc(row+BIAS);
ttputc(col+BIAS);
}
st520eeol()
{
ttputc(ESC);
ttputc('K');
}
st520eeop()
{
#if COLOR
st520fcol(gfcolor);
st520bcol(gbcolor);
#endif
ttputc(ESC);
ttputc('J');
}
st520rev(status) /* set the reverse video state */
int status; /* TRUE = reverse video, FALSE = normal video */
{
if(status) {
ttputc(ESC);
ttputc('p');
}
else {
ttputc(ESC);
ttputc('q');
}
}
#if COLOR
st520fcol(color)
int color;
{
if(color == cfcolor || !STncolors)
return;
else {
ttputc(ESC);
ttputc('b');
ttputc(color & 0x0f);
cfcolor = color;
}
}
st520bcol(color)
int color;
{
if(color == cbcolor || !STncolors)
return;
else {
ttputc(ESC);
ttputc('c');
ttputc(color & 0x0f);
cbcolor = color;
}
}
#endif
st520beep()
{
#ifdef BEL
ttputc(BEL);
ttflush();
#endif
}
st520open()
{
int i,j,k;
long phys, log; /* screen bases */
/* IMPORTANT: it is ABSOLUTELY necessary that the default resolution be the
* largest possible so that display will allocate (malloc) the maximum
* size for the VIDEO arrray
*/
STrez = Getrez();
switch(STrez) {
case 0: /* low res 25x40 16 colors */
phys = Physbase();
log = Logbase();
Setscreen(log, phys, 1);
STrez = 1;
/* fall thru to med res */
case 1: /* med res 25x80 4 colors */
term.t_nrow = 25 - 1;
term.t_ncol = 80;
grez = 1;
#if COLOR
STncolors = 4;
for(i=0;i<8;i++) {
oldpal[i] = Setcolor(i,newpal[i]);
}
#endif
break;
case 2: /* high res 25x80 no colors */
term.t_nrow = 40 - 1;
term.t_ncol = 80;
grez = 2;
make_8x10(); /* create a smaller font */
set_40(); /* and go to 40 line mode */
#if COLOR
STncolors = 0;
#endif
break;
}
revexist = TRUE;
eolexist = TRUE;
paramp = (struct Param *)malloc(sizeof(struct Param));
kbdvecs = (struct KBDvecs *)Kbdvbase();
paramp -> topmode = 0;
paramp -> buttons = 4;
paramp -> xparam = 8;
paramp -> yparam = 10;
paramp -> xmax = 79;
paramp -> ymax = 23;
paramp -> xinitial = 0;
paramp -> yinitial = 0;
Initmous(1,paramp,kbdvecs -> mousevec);
i = 0;
kbdcmds[i++] = 0x0a; /*set mouse keycode mode */
kbdcmds[i++] = 0x08;
kbdcmds[i++] = 0x0a;
Ikbdws(i-1,&kbdcmds[0]);
Cursconf(1,0);
Cursconf(3,0);
Cconout(27);Cconout('E');
ttopen();
}
st520close()
{
int i,j,k;
i = 0;
kbdcmds[i++] = 0x80; /*reset mouse keycode mode */
kbdcmds[i++] = 0x01;
Ikbdws(i-1,&kbdcmds[0]);
if(grez == 2 && STrez == 2) /* b/w monitor in 40 row mode */
restore();
#if COLOR
for(i=0;i<STncolors;i++)
Setcolor(i,oldpal[i]);
#endif
Cconout(27);Cconout('E');
paramp -> buttons = 0;
Initmous(2,paramp,kbdvecs -> mousevec);
i = 0;
kbdcmds[i++] = 0x80; /*reset the keyboard*/
kbdcmds[i++] = 0x01;
Ikbdws(i-1,&kbdcmds[0]);
Cursconf(1,0);
ttclose();
}
st520kopen()
{
}
st520kclose()
{
}
st520chgrez(nurez)
int nurez;
{
int ierr, i, j ,k;
long phys, log; /* screen bases */
char dum[80]; /* for debugging only */
if(grez == nurez)
return(TRUE);
if(STrez == 2) { /* b/w monitor-only allow hi | med rez */
switch(nurez) {
case 2: /* high res */
term.t_nrow = 40 - 1;
term.t_ncol = 80;
make_8x10(); /* create a smaller font */
set_40(); /* and go to 40 line mode */
grez = 2;
sgarbf = TRUE;
onlywind(1,1);
break;
case 1: /* med res */
term.t_nrow = 25 - 1;
term.t_ncol = 80;
restore();
grez = 1;
sgarbf = TRUE;
onlywind(1,1);
break;
default:
mlwrite("Invalid resolution");
return(FALSE);
break;
}
}
else { /* color monitor-only allow low | medium resolution */
phys = Physbase();
log = Logbase();
switch(nurez) {
case 1:
term.t_nrow = 25 - 1;
term.t_ncol = 80;
Setscreen(log, phys, 1);
STncolors = 4;
grez = 1;
sgarbf = TRUE;
onlywind(1,1);
break;
case 0:
term.t_nrow = 25 - 1;
term.t_ncol = 40;
Setscreen(log, phys, 0);
STncolors = 8;
grez = 0;
sgarbf = TRUE;
onlywind(1,1);
break;
default:
mlwrite("%Invalid resolution");
return(FALSE);
break;
}
}
}
STcurblink(onoff)
int onoff;
{
if(onoff)
Cursconf(2,0);
else
Cursconf(3,0);
}
char parm_save[28];
long fnt_8x10[640];
make_8x10()
{
int i,j,k;
long savea23[2];
for(i=0;i<640;i++)
fnt_8x10[i] = 0;
asm {
movem.l A2-A3,savea23(A6)
dc.w LINEA_INIT ;A1 -> array of font headers
lea parm_save(A4),A2 ;A2 -> parameters savearea
move.l V_OFF_AD(A0),(A2)+
move.l V_FNT_AD(A0),(A2)+
move.w V_CEL_HT(A0),(A2)+
move.w V_CEL_MY(A0),(A2)+
move.w V_CEL_WR(A0),(A2)+
move.l 04(A1),A1 ; A1 -> 8x8 font header
move.l 76(A1),A2 ; A2 -> 8x8 font data
lea fnt_8x10+0x100(A4),A3 ; A3 -> 2nd line of font buffer
move.w #0x200-1,D0 ; D0 <- longword counter for font xfer
fnt_loop:
move.l (A2)+,(A3)+
dbf D0,fnt_loop
movem.l savea23(A6),A2-A3
}
}
set_40()
{
long savea23[2];
asm {
;
; use the 8x10 character set: 40 line mode
;
movem.l A2-A3,savea23(A6)
dc.w LINEA_INIT
move.l 04(A1),A1 ; A1 -> 8x8 font header
move.l 72(A1),V_OFF_AD(A0) ; v_off_ad <- 8x8 offset table addr
lea fnt_8x10(A4),A2
move.l A2,V_FNT_AD(A0) ; v_fnt_ad <- 8x10 font data addr
move.w #10,V_CEL_HT(A0) ; v_cel_ht <- 10 8x10 cell height
move.w #39,V_CEL_MY(A0) ; v_cel_my <- 39 maximum cell "Y"
move.w #800,V_CEL_WR(A0) ; v_cel_wr <- 800 offset to cell Y+1
movem.l savea23,A2-A3
}
}
set_20()
{
long savea23[2];
asm {
;
; use the 8x10 character set: 20 line mode
;
movem.l A2-A3,savea23(A6)
dc.w LINEA_INIT ; A0 -> line A variables
move.l 04(A1),A1 ; A1 -> 8x8 font header
move.l 72(A1),V_OFF_AD(A0) ; v_off_ad <- 8x8 offset table addr
lea fnt_8x10(A4),A2
move.l A2,V_FNT_AD(A0) ; v_fnt_ad <- 8x10 font data addr
move.w #10,V_CEL_HT(A0) ; v_cel_ht <- 10 8x10 cell height
move.w #19,V_CEL_MY(A0) ; v_cel_my <- 19 maximum cell "Y"
move.w #1600,V_CEL_WR(A0) ; v_cel_wr <- 800 offset to cell Y+1
movem.l savea23,A2-A3
}
}
restore()
{
long savea23[2];
asm {
; return what was saved in parameter save zone
movem.l A2-A3,savea23(A6)
dc.w LINEA_INIT ; a0 -> line A variables
lea parm_save(A4),A2 ; a2 -> parameter save area
move.l (A2)+,V_OFF_AD(A0)
move.l (A2)+,V_FNT_AD(A0)
move.w (A2)+,V_CEL_HT(A0)
move.w (A2)+,V_CEL_MY(A0)
move.w (A2)+,V_CEL_WR(A0)
movem.l savea23(A6),A2-A3
}
}
GetCurStat(onoff)
int onoff;
{
long savea23[2];
asm {
movem.l A2-A3,savea23(A6)
dc.w LINEA_INIT ; a0 -> line A variables
move.w V_DISAB(A0),onoff(A6) ; 0 = cursor visible
moveq #0,D0
move.w V_DISAB(A0),D0
movem.l savea23(A6),A2-A3
}
}
#else
#if ATARI & ST520 & LATTICE
/*
These routines provide support for the ATARI 1040ST using
the LATTICE compiler using the virtual VT52 Emulator
*/
#define NROW 40 /* Screen size. */
#define NCOL 80 /* Edit if you want to. */
#define MARGIN 8 /* size of minimim margin and */
#define SCRSIZ 64 /* scroll size for extended lines */
#define NPAUSE 300 /* # times thru update to pause */
#define BIAS 0x20 /* Origin 0 coordinate bias. */
#define ESC 0x1B /* ESC character. */
#define BEL 0x07 /* ASCII bell character */
/**** ST Internals definitions *****/
/* BIOS calls */
#define BCONSTAT 1 /* return input device status */
#define CONIN 2 /* read character from device */
#define BCONOUT 3 /* write character to device */
/* XBIOS calls */
#define INITMOUS 0 /* initialize the mouse */
#define GETREZ 4 /* get current resolution */
#define SETSCREEN 5 /* set screen resolution */
#define SETPALETTE 6 /* set the color pallette */
#define SETCOLOR 7 /* set or read a color */
#define CURSCONF 21 /* set cursor configuration */
#define IKBDWS 25 /* intelligent keyboard send command */
#define KBDVBASE 34 /* get keyboard table base */
/* GEMDOS calls */
#define EXEC 0x4b /* Exec off a process */
#define CON 2 /* CON: Keyboard and screen device */
/* LINE A variables */
#define LINEA_INIT 0xA000
#define V_CEL_WR -0x28
#define V_CEL_MY -0x2a
#define V_CEL_HT -0x2e
#define V_FNT_AD -0x16
#define V_OFF_AD -0x0a
#define V_DISAB -346
/* Palette color definitions */
#define LOWPAL "000700070770007707077777"
#define MEDPAL "000700007777"
#define HIGHPAL "000111"
/* ST Global definitions */
/* keyboard vector table */
struct KVT {
long midivec; /* midi input */
long vkbderr; /* keyboard error */
long vmiderr; /* MIDI error */
long statvec; /* IKBD status */
int (*mousevec)(); /* mouse vector */
long clockvec; /* clock vector */
long joyvec; /* joystict vector */
} *ktable;
int (*sysmint)(); /* system mouse interupt handler */
/* mouse parameter table */
struct Param {
char topmode;
char buttons;
char xparam;
char yparam;
int xmax,ymax;
int xinitial,yinitial;
} mparam;
int initrez; /* initial screen resolution */
int currez; /* current screen resolution */
char resname[][8] = { /* screen resolution names */
"LOW", "MEDIUM", "HIGH", "DENSE"
};
short spalette[16]; /* original color palette settings */
short palette[16]; /* current palette settings */
extern VOID stmove(); /* Forward references. */
extern VOID steeol();
extern VOID steeop();
extern VOID stbeep();
extern int stopen();
extern int stclose();
extern int stgetc();
extern int stputc();
extern VOID strev();
extern int strez();
extern int stkopen();
extern int stkclose();
#if COLOR
extern VOID stfcol();
extern VOID stbcol();
#endif
/*
* Dispatch table. All the
* hard fields just point into the
* terminal I/O code.
*/
TERM term = {
NROW-1,
NROW-1,
NCOL,
NCOL,
MARGIN,
SCRSIZ,
NPAUSE,
&stopen,
&stclose,
&stkopen,
&stkclose,
&stgetc,
&stputc,
&ttflush,
&stmove,
&steeol,
&steeop,
&stbeep,
&strev,
&strez
#if COLOR
, &stfcol,
&stbcol
#endif
};
VOID stmove(row, col)
{
stputc(ESC);
stputc('Y');
stputc(row+BIAS);
stputc(col+BIAS);
}
VOID steeol()
{
stputc(ESC);
stputc('K');
}
VOID steeop()
{
#if COLOR
stfcol(gfcolor);
stbcol(gbcolor);
#endif
stputc(ESC);
stputc('J');
}
VOID strev(status) /* set the reverse video state */
int status; /* TRUE = reverse video, FALSE = normal video */
{
if (currez > 1) {
stputc(ESC);
stputc(status ? 'p' : 'q');
}
}
#if COLOR
mapcol(clr) /* medium rez color translation */
int clr; /* emacs color number to translate */
{
static int mctable[] = {0, 1, 2, 3, 2, 1, 2, 3};
if (currez != 1)
return(clr);
else
return(mctable[clr]);
}
VOID stfcol(color) /* set the forground color */
int color; /* color to set forground to */
{
if (currez < 2) {
stputc(ESC);
stputc('b');
stputc(mapcol(color));
}
}
VOID stbcol(color) /* set the background color */
int color; /* color to set background to */
{
if (currez < 2) {
stputc(ESC);
stputc('c');
stputc(mapcol(color));
}
}
#endif
VOID stbeep()
{
stputc(BEL);
ttflush();
}
domouse() /* mouse interupt handler */
{
return((*sysmint)());
}
stkopen() /* open the keyboard (and mouse) */
{
/* grab the keyboard vector table */
ktable = (struct KVT *)xbios(KBDVBASE);
sysmint = ktable->mousevec; /* save mouse vector */
/* initialize the mouse */
mparam.topmode = 0;
mparam.buttons = 4;
mparam.xparam = 8;
mparam.yparam = 10;
mparam.xmax = 79;
mparam.ymax = 23;
mparam.xinitial = 0;
mparam.yinitial = 0;
xbios(INITMOUS, 4, &mparam, &domouse);
}
stopen() /* open the screen */
{
int i;
ttopen();
eolexist = TRUE;
/* switch to a steady cursor */
xbios(CURSCONF, 3);
/* save the current color palette */
for (i=0; i<16; i++)
spalette[i] = xbios(SETCOLOR, i, -1);
/* and find the current resolution */
initrez = currez = xbios(GETREZ);
strcpy(sres, resname[currez]);
/* set up the screen size and palette */
switch (currez) {
case 0: term.t_mrow = 25 - 1;
term.t_nrow = 25 - 1;
term.t_ncol = 40;
strcpy(palstr, LOWPAL);
break;
case 1: term.t_mrow = 25 - 1;
term.t_nrow = 25 - 1;
strcpy(palstr, MEDPAL);
break;
case 2: term.t_mrow = 40 - 1;
term.t_nrow = 25 - 1;
strcpy(palstr, HIGHPAL);
}
/* and set up the default palette */
spal(palstr);
stputc(ESC); /* automatic overflow off */
stputc('w');
stputc(ESC); /* turn cursor on */
stputc('e');
}
stkclose() /* close the keyboard (and mouse) */
{
static char resetcmd[] = {0x80, 0x01}; /* keyboard reset command */
/* restore the mouse interupt routines */
xbios(INITMOUS, 2, &mparam, (long)sysmint);
/* and reset the keyboard controller */
xbios(IKBDWS, 1, &resetcmd[0]);
}
stclose()
{
stputc(ESC); /* auto overflow on */
stputc('v');
/* switch to a flashing cursor */
xbios(CURSCONF, 2);
/* restore the original screen resolution */
strez(resname[initrez]);
/* restore the original palette settings */
xbios(SETPALETTE, spalette);
ttclose();
}
/* spal(pstr): reset the current palette according to a
"palette string" of the form
000111222333444555666777
which contains the octal values for the palette registers
*/
spal(pstr)
char *pstr; /* palette string */
{
int pal; /* current palette position */
int clr; /* current color value */
int i;
for (pal = 0; pal < 16; pal++) {
if (*pstr== 0)
break;
/* parse off a color */
clr = 0;
for (i = 0; i < 3; i++)
if (*pstr)
clr = clr * 16 + (*pstr++ - '0');
palette[pal] = clr;
};
/* and now set it */
xbios(SETPALETTE, palette);
}
stgetc() /* get a char from the keyboard */
{
int rval; /* return value from BIOS call */
static int funkey = 0; /* held fuction key scan code */
/* if there is a pending function key, return it */
if (funkey) {
rval = funkey;
funkey = 0;
} else {
/* waiting... flash the cursor */
xbios(CURSCONF, 2);
/* get the character */
rval = bios(CONIN, CON);
if ((rval & 255) == 0) {
funkey = (rval >> 16) & 255;
rval = 0;
}
/* and switch to a steady cursor */
xbios(CURSCONF, 3);
}
return(rval & 255);
}
stputc(c) /* output char c to the screen */
char c; /* character to print out */
{
bios(BCONOUT, CON, c);
}
strez(newrez) /* change screen resolution */
char *newrez; /* requested resolution */
{
int nrez; /* requested new resolution */
/* first, decode the resolution name */
for (nrez = 0; nrez < 4; nrez++)
if (strcmp(newrez, resname[nrez]) == 0)
break;
if (nrez == 4) {
mlwrite("%%No such resolution");
return(FALSE);
}
/* next, make sure this resolution is legal for this monitor */
if ((currez < 2 && nrez > 1) || (currez > 1 && nrez < 2)) {
mlwrite("%%Resolution illegal for this monitor");
return(FALSE);
}
/* eliminate non-changes */
if (currez == nrez)
return(TRUE);
/* finally, make the change */
switch (nrez) {
case 0: /* low resolution - 16 colors */
newwidth(TRUE, 40);
strcpy(palstr, LOWPAL);
xbios(SETSCREEN, -1, -1, 0);
break;
case 1: /* medium resolution - 4 colors */
newwidth(TRUE, 80);
strcpy(palstr, MEDPAL);
xbios(SETSCREEN, -1, -1, 1);
break;
case 2: /* High resolution - 2 colors - 25 lines */
newsize(TRUE, 25);
strcpy(palstr, HIGHPAL);
/* change char set back to normal */
break;
case 3: /* Dense resolution - 2 colors - 40 lines */
/* newsize(TRUE, 40); */
strcpy(palstr, HIGHPAL);
/*change char set size */
break;
}
/* and set up the default palette */
spal(palstr);
currez = nrez;
strcpy(sres, resname[currez]);
stputc(ESC); /* automatic overflow off */
stputc('w');
stputc(ESC); /* turn cursor on */
stputc('e');
return(TRUE);
}
system(cmd) /* call the system to execute a new program */
char *cmd; /* command to execute */
{
char *pptr; /* pointer into program name */
char pname[NSTRING]; /* name of program to execute */
char tail[NSTRING]; /* command tail */
/* scan off program name.... */
pptr = pname;
while (*cmd && (*cmd != ' ' && *cmd != '\t'))
*pptr++ = *cmd++;
*pptr = 0;
/* create program name length/string */
tail[0] = strlen(cmd);
strcpy(&tail[1], cmd);
/* go do it! */
return(gemdos( (int)EXEC,
(int)0,
(char *)pname,
(char *)tail,
(char *)NULL));
}
#if TYPEAH
typahead()
{
int rval; /* return value from BIOS call */
/* get the status of the console */
rval = bios(BCONSTAT, CON);
/* end return the results */
if (rval == 0)
return(FALSE);