source: buchla-68k/ram/smscrl.c@ 599d89b

Last change on this file since 599d89b was 0c834c5, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Prototypes for global function pointers. Consistent global types.

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