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

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

Removed form-feed comments.

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