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

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

Added missing includes and declarations.

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