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

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

Zero redundant declarations.

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