source: buchla-68k/ram/smscrl.c@ 6262b5c

Last change on this file since 6262b5c was 6262b5c, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Added include files for global functions and variables.

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