source: buchla-68k/orig/RAM/SMSCRL.C@ cbe2c15

Last change on this file since cbe2c15 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago

Imported original source code.

  • Property mode set to 100755
File size: 13.9 KB
Line 
1/*
2 =============================================================================
3 smscrl.c -- MIDAS-VII smooth scrolling functions
4 Version 37 -- 1989-11-16 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#define OLDSCRL 0
9
10#include "stddefs.h"
11#include "graphdef.h"
12#include "hwdefs.h"
13#include "vsdd.h"
14#include "curpak.h"
15#include "patch.h"
16
17#include "midas.h"
18#include "ptdisp.h"
19
20#define SS_NSL 16 /* number of scrolled lines */
21#define SS_TOP (2 * (SS_NSL + 1)) /* total line count */
22#define SS_LIM (SS_TOP - SS_NSL) /* top line limit */
23#define SS_LEN 48 /* length of a scrolled line */
24#define NSCANS 14 /* number of scan lines */
25#define TOPSCAN (NSCANS - 1) /* top scan line */
26
27extern short cmtype; /* cursor type */
28extern short ctcsw; /* cursor status */
29extern short curslin; /* current sequence line */
30extern short cxrate; /* cursor X update rate */
31extern short cxval; /* cursor X location */
32extern short cyrate; /* cursor Y update rate */
33extern short cyval; /* cursor Y location */
34extern short ptecpos; /* current patch index */
35extern short pteset; /* ptebuf set flag */
36extern short sqdeflg; /* sequence data entry flag */
37extern short stccol; /* main cursor column */
38extern short submenu; /* submenu switch */
39extern short vtccol; /* submenu cursor column */
40extern short vtcrow; /* submenu cursor row */
41extern short vtxval; /* submenu cursor x value */
42extern short vtyval; /* subment cursor y value */
43
44extern unsigned short *obj10; /* sequence status object pointer */
45
46extern unsigned short cg3[]; /* character generator table */
47
48extern char ptdebuf[]; /* patch data entry buffer */
49extern char sqdebuf[]; /* sequence data entry buffer */
50
51extern struct patch ptebuf; /* current patch image */
52extern struct patch patches[]; /* the patch table */
53
54extern struct seqent seqbuf; /* sequence line buffer */
55extern struct seqent seqtab[]; /* sequence table */
56
57char TheBuf[66]; /* display build buffer */
58
59/*
60
61*/
62
63char *(*BakLine)(); /* next line backward function pointer */
64char *(*FwdLine)(); /* next line forward function pointer */
65
66short PdScDnF; /* scroll down flag */
67short PdScUpF; /* scroll up flag */
68
69short CurLine; /* top line being displayed */
70short CurScan; /* current scan line */
71short DupLine; /* write pointer for other page */
72short ScrlObj; /* object descriptor table index */
73
74char *LinePtr; /* line to scroll onto screen */
75
76unsigned short LineAtr; /* attribute for the new line */
77
78unsigned short *LineBuf; /* current display memory pointer */
79unsigned short *OldLine; /* old display memory pointer */
80unsigned short *ScObAdr; /* display memory base pointer */
81
82short LineCon = SS_LEN * 3; /* line offset constant */
83short LineLen = SS_LEN; /* length of a scrolled line */
84short SmScLim = SS_LIM; /* top line limit */
85short SmScNsl = SS_NSL; /* number of scrolled lines */
86short SmScTop = SS_TOP; /* total line count */
87
88/*
89
90*/
91
92/*
93 =============================================================================
94 LineFwd() -- return the next patch line in the forward direction
95 =============================================================================
96*/
97
98char *
99LineFwd()
100{
101 register short j, k;
102
103 for (j = 0; j < 48; j++)
104 TheBuf[j] = ' ';
105
106 TheBuf[0] = '\260';
107 TheBuf[48] = '\0';
108
109 if (0 EQ ptecpos)
110 return((char *)NULL);
111
112 if (0 EQ (j = findnxt(ptecpos)))
113 return((char *)NULL);
114
115 ptecpos = j;
116
117 memcpyw(&ptebuf.defnum, &patches[ptecpos].defnum, 6);
118 pteset = TRUE;
119 pte2buf();
120
121 k = ptecpos;
122
123 for (j = 0; j < 8; j++)
124 if (0 EQ (k = findnxt(k)))
125 return(TheBuf);
126
127 dspdfst(&TheBuf[ 2], patches[k].defnum);
128 dspdfst(&TheBuf[15], patches[k].stmnum);
129 dspdest(&TheBuf[28], &patches[k]);
130
131 for (j = 0; j < 50; j++)
132 if(TheBuf[j] EQ '\0')
133 TheBuf[j] = ' ';
134
135 TheBuf[48] = '\0';
136 return(TheBuf);
137}
138
139/*
140
141*/
142
143/*
144 =============================================================================
145 LineBak() -- return the next patch line in the backward direction
146 =============================================================================
147*/
148
149char *
150LineBak()
151{
152 register short j, k;
153
154 for (j = 0; j < 48; j++)
155 TheBuf[j] = ' ';
156
157 TheBuf[0] = '\260';
158 TheBuf[48] = '\0';
159
160 if (0 EQ ptecpos)
161 return((char *)NULL);
162
163 if (0 EQ (j = findprv(ptecpos)))
164 return((char *)NULL);
165
166 ptecpos = j;
167
168 memcpyw(&ptebuf.defnum, &patches[ptecpos].defnum, 6);
169 pteset = TRUE;
170 pte2buf();
171
172 k = ptecpos;
173
174 for (j = 0; j < 7; j++)
175 if (0 EQ (k = findprv(k)))
176 return(TheBuf);
177
178 dspdfst(&TheBuf[ 2], patches[k].defnum);
179 dspdfst(&TheBuf[15], patches[k].stmnum);
180 dspdest(&TheBuf[28], &patches[k]);
181
182 for (j = 0; j < 50; j++)
183 if(TheBuf[j] EQ '\0')
184 TheBuf[j] = ' ';
185
186 TheBuf[48] = '\0';
187 return(TheBuf);
188}
189
190/*
191
192*/
193
194/*
195 =============================================================================
196 WrVideo() -- write a line to the video display
197 =============================================================================
198*/
199
200WrVideo(row, col, str, atr)
201register short row, col;
202register char *str;
203register unsigned short atr;
204{
205 register char chr;
206
207 if (v_regs[5] & 0x0180)
208 vbank(0);
209
210 while ('\0' NE (chr = *str++)) {
211
212 vputcv(ScObAdr, row, col, chr,
213 (col EQ 0) ? PTBATR : atr, LineLen);
214
215 col++;
216 }
217}
218
219/*
220
221*/
222
223/*
224 =============================================================================
225 SetDTop() -- set the top line of the display
226 =============================================================================
227*/
228
229SetDTop(row, scan)
230short row, scan;
231{
232 if (v_regs[5] & 0x0180)
233 vbank(0);
234
235 LineBuf = (unsigned short *)((char *)ScObAdr + (row * LineCon));
236
237 if (OldLine NE LineBuf)
238 v_odtab[ScrlObj][2] = ((char *)LineBuf >> 1) & 0xFFFF;
239
240 OldLine = LineBuf;
241
242 v_odtab[ScrlObj][0] = (v_odtab[ScrlObj][0] & 0x0FFF) | (scan << 12);
243}
244
245/*
246
247*/
248
249/*
250 =============================================================================
251 UpdVid() -- update the video display on both pages
252 =============================================================================
253*/
254
255UpdVid(row, col, str, atr)
256short row, col;
257char *str;
258unsigned short atr;
259{
260 WrVideo(CurLine + row, col, str, atr);
261
262 DupLine = CurLine + SmScNsl + 2 + row;
263
264 if (DupLine < SmScTop)
265 WrVideo(DupLine, col, str, PTPATR);
266
267 DupLine = CurLine - SmScNsl - 2 + row;
268
269 if (DupLine GE 0)
270 WrVideo(DupLine, col, str, PTPATR);
271}
272
273/*
274
275*/
276
277/*
278 =============================================================================
279 bgncm() -- begin patch display cursor motion
280 =============================================================================
281*/
282
283bgncm()
284{
285 register short j;
286
287 memcpyw(&ptebuf.defnum, &patches[ptecpos].defnum, 6);
288 pteset = TRUE;
289 pte2buf();
290
291 memcpy(TheBuf, ptdebuf, 48);
292
293 for (j = 0; j < 50; j++)
294 if(TheBuf[j] EQ '\0')
295 TheBuf[j] = ' ';
296
297 TheBuf[0] = '\260';
298 TheBuf[1] = ' ';
299 TheBuf[48] = '\0';
300
301 UpdVid(7, 0, TheBuf, PTPATR);
302 ctcoff();
303}
304
305/*
306
307*/
308
309/*
310 =============================================================================
311 stopcm() -- stop patch display cursor motion
312 =============================================================================
313*/
314
315stopcm()
316{
317 register short i;
318
319 if (PdScDnF)
320 SetDTop(CurLine, CurScan = TOPSCAN);
321 else if (PdScUpF)
322 SetDTop(++CurLine, CurScan = TOPSCAN);
323
324 if (NOT ctcsw) { /* if we scrolled ... */
325
326 if (ptecpos) { /* if something is there ... */
327
328 /* refresh editing variables */
329
330 memcpyw(&ptebuf.defnum, &patches[ptecpos].defnum, 6);
331 pteset = TRUE;
332 pte2buf();
333 setptcv();
334
335 } else { /* ... nothing there */
336
337 voidpb(); /* void the patch buffer */
338 }
339 }
340
341 ctcon(); /* re-enable cursor */
342
343 PdScDnF = FALSE; /* turn off the scrolling flags */
344 PdScUpF = FALSE;
345}
346
347/*
348
349*/
350
351/*
352 =============================================================================
353 stopsm() -- stop sequence display cursor motion
354 =============================================================================
355*/
356
357stopsm()
358{
359 register short i;
360
361 if (PdScDnF)
362 SetDTop(CurLine, CurScan = TOPSCAN);
363 else if (PdScUpF)
364 SetDTop(++CurLine, CurScan = TOPSCAN);
365
366 memcpyw(&seqbuf, &seqtab[curslin], NSEQW);
367 dsqlin(sqdebuf, curslin);
368 sqdeflg = TRUE;
369 ctcon();
370
371 PdScDnF = FALSE;
372 PdScUpF = FALSE;
373}
374
375/*
376
377*/
378
379/*
380 =============================================================================
381 smscrl() -- smooth scroll the text display up or down
382 =============================================================================
383*/
384
385smscrl()
386{
387 if (PdScUpF) { /* SCROLL UP (toward NEW data) ? */
388
389 if (CurScan EQ TOPSCAN) { /* ready for a new line ? */
390
391 if ((char *)NULL NE (LinePtr = (*FwdLine)())) { /* get a line */
392
393 if (CurLine EQ SmScLim) { /* *** swap display pages *** */
394
395 /* update page we're going to */
396
397 WrVideo(SmScNsl, 0, LinePtr, LineAtr);
398
399 /* point at new page */
400
401 SetDTop(CurLine = 0, CurScan = TOPSCAN);
402
403 } else { /* *** stay on this page *** */
404
405 /* update scroll target line */
406
407 WrVideo(CurLine + SmScNsl, 0, LinePtr, LineAtr);
408
409 /* update other page if it's in range */
410
411 DupLine = CurLine - 2;
412
413 if (DupLine GE 0)
414 WrVideo(DupLine, 0, LinePtr, LineAtr);
415 }
416
417 /* do first scroll up of new line */
418
419 SetDTop(CurLine, --CurScan);
420 }
421
422 } else { /* scrolling -- scroll some more */
423
424 if (CurScan EQ 0)
425 SetDTop(++CurLine, CurScan = TOPSCAN);
426 else
427 SetDTop(CurLine, --CurScan);
428 }
429/*
430
431*/
432 } else if (PdScDnF) { /* SCROLL DOWN (toward old data) ? */
433
434 if (CurScan EQ TOPSCAN) { /* ready for a new line ? */
435
436 if ((char *)NULL NE (LinePtr = (*BakLine)())) { /* get a line */
437
438 if (CurLine EQ 0) { /* *** swap display pages *** */
439
440 /* update page we're going to */
441
442 WrVideo(SmScLim - 1, 0, LinePtr, LineAtr);
443
444 /* point at new page */
445
446 SetDTop(CurLine = SmScLim - 1, CurScan = 0);
447
448 } else { /* *** stay on this page *** */
449
450 /* update scroll target line */
451
452 WrVideo(CurLine - 1, 0, LinePtr, LineAtr);
453
454 /* update other page if it's in range */
455
456 DupLine = CurLine + SmScNsl + 1;
457
458 if (DupLine < SmScTop)
459 WrVideo(DupLine, 0, LinePtr, LineAtr);
460
461 /* do first scroll down of new line */
462
463 SetDTop(--CurLine, CurScan = 0);
464 }
465 }
466
467 } else { /* scrolling -- scroll some more */
468
469 if (CurScan NE TOPSCAN)
470 SetDTop(CurLine, ++CurScan);
471 }
472 }
473}
474
475/*
476
477*/
478
479/*
480 =============================================================================
481 smxupd() -- patch / sequence smooth scroll X axis update
482 =============================================================================
483*/
484
485smxupd()
486{
487 short oldcx;
488
489 oldcx = cxval;
490
491 if (submenu) {
492
493 vtccol = XTOC(vtxval += cxrate);
494
495 if (vtccol > 60)
496 vtxval = CTOX(vtccol = 60);
497 else if (vtccol < 2)
498 vtxval = CTOX(vtccol = 2);
499
500 } else {
501
502 cxval += cxrate;
503
504 if (cxval > CTOX(48))
505 cxval = CTOX(48);
506 else if (cxval < CTOX(2))
507 cxval = CTOX(2);
508
509 if (cxval EQ oldcx)
510 return;
511
512 if (47 EQ XTOC(cxval)) {
513
514 if (v_regs[5] & 0x0180)
515 vbank(0);
516
517 vvputsv(obj10, 16, PDBORFG, PDSEQBG,
518 7, 0, "\260", 14, 14, cg3);
519
520 vsplot4(obj10, 16, PDPTRFG,
521 7, 0, "\274", 14, 14, cg3);
522
523 } else if (48 EQ XTOC(cxval)) {
524
525 if (v_regs[5] & 0x0180)
526 vbank(0);
527
528 vvputsv(obj10, 16, PDBORFG, PDSEQBG,
529 7, 0, "\260", 14, 14, cg3);
530
531 vsplot4(obj10, 16, PDPTRFG,
532 7, 0, "\277", 14, 14, cg3);
533
534 }
535
536 return;
537 }
538}
539
540/*
541
542*/
543
544/*
545 =============================================================================
546 smy_up() -- patch display smooth scrolling
547 =============================================================================
548*/
549
550smy_up(tag)
551short tag;
552{
553
554 if (0 EQ ptecpos) { /* see if anything is there */
555
556 dptw(); /* try to find something ... */
557 return; /* ... may scroll next time */
558 }
559
560 if (ctcsw) /* if we haven't scrolled yet ... */
561 bgncm(); /* ... setup for scrolling */
562
563 if (tag < 0) { /* scroll up */
564
565 if (0 EQ findnxt(ptecpos))
566 return;
567
568 PdScUpF = TRUE;
569 PdScDnF = FALSE;
570 smscrl();
571
572 } else if (tag > 0) { /* scroll down */
573
574 if (0 EQ findprv(ptecpos))
575 return;
576
577 PdScDnF = TRUE;
578 PdScUpF = FALSE;
579 smscrl();
580 }
581}
582
583/*
584
585*/
586
587/*
588 =============================================================================
589 smyupd() -- patch display smooth scroll Y axis update
590 =============================================================================
591*/
592
593smyupd()
594{
595 if (submenu) {
596
597 vtcrow = YTOR(vtyval += cyrate);
598
599 if (vtcrow > 23)
600 vtyval = RTOY(vtcrow = 23);
601 else if (vtcrow < 19)
602 vtyval = RTOY(vtcrow = 19);
603
604 }
605
606#if OLDSCRL
607 smy_up(cyrate);
608#endif
609}
610
611/*
612
613*/
614
615/*
616 =============================================================================
617 sqy_up() -- sequence smooth scrolling
618 =============================================================================
619*/
620
621sqy_up(tag)
622short tag;
623{
624 if (ctcsw)
625 ctcoff();
626
627 if (tag < 0) { /* scroll up */
628
629 PdScUpF = TRUE;
630 PdScDnF = FALSE;
631 smscrl();
632
633 } else if (tag > 0) { /* scroll down */
634
635 PdScDnF = TRUE;
636 PdScUpF = FALSE;
637 smscrl();
638 }
639}
640
641/*
642
643*/
644
645/*
646 =============================================================================
647 sqyupd() -- sequence smooth scroll Y axis update
648 =============================================================================
649*/
650
651sqyupd()
652{
653 if (submenu) {
654
655 vtcrow = YTOR(vtyval += cyrate);
656
657 if (vtcrow > 23)
658 vtyval = RTOY(vtcrow = 23);
659 else if (vtcrow < 19)
660 vtyval = RTOY(vtcrow = 19);
661
662 }
663
664#if OLDSCRL
665 sqy_up(cyrate);
666#endif
667}
Note: See TracBrowser for help on using the repository browser.