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

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

Removed redundant declarations.

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