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

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

Unused variables and parameters.

  • Property mode set to 100644
File size: 11.7 KB
RevLine 
[f40a309]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
[b28a12e]10#include "ram.h"
[e225e77]11
[f40a309]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
[7258c6a]19int8_t TheBuf[66]; /* display build buffer */
[f40a309]20
[7258c6a]21int8_t *(*BakLine)(void); /* next line backward function pointer */
22int8_t *(*FwdLine)(void); /* next line forward function pointer */
[f40a309]23
[7258c6a]24int16_t PdScDnF; /* scroll down flag */
25int16_t PdScUpF; /* scroll up flag */
[f40a309]26
[7258c6a]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 */
[f40a309]31
[7258c6a]32int8_t *LinePtr; /* line to scroll onto screen */
[f40a309]33
[7258c6a]34uint16_t LineAtr; /* attribute for the new line */
[f40a309]35
[7258c6a]36uint16_t *LineBuf; /* current display memory pointer */
37uint16_t *OldLine; /* old display memory pointer */
38uint16_t *ScObAdr; /* display memory base pointer */
[f40a309]39
[7258c6a]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 */
[f40a309]45
46/*
47 =============================================================================
48 LineFwd() -- return the next patch line in the forward direction
49 =============================================================================
50*/
51
[7258c6a]52int8_t *LineFwd(void)
[f40a309]53{
[7258c6a]54 register int16_t j, k;
[f40a309]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)
[7258c6a]63 return((int8_t *)NULL);
[f40a309]64
65 if (0 EQ (j = findnxt(ptecpos)))
[7258c6a]66 return((int8_t *)NULL);
[f40a309]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
[7258c6a]98int8_t *LineBak(void)
[f40a309]99{
[7258c6a]100 register int16_t j, k;
[f40a309]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)
[7258c6a]109 return((int8_t *)NULL);
[f40a309]110
111 if (0 EQ (j = findprv(ptecpos)))
[7258c6a]112 return((int8_t *)NULL);
[f40a309]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
[7258c6a]144void WrVideo(int16_t row, int16_t col, int8_t *str, uint16_t atr)
[f40a309]145{
[7258c6a]146 register int8_t chr;
[f40a309]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
[7258c6a]166void SetDTop(int16_t row, int16_t scan)
[f40a309]167{
168 if (v_regs[5] & 0x0180)
169 vbank(0);
170
[7258c6a]171 LineBuf = (uint16_t *)((int8_t *)ScObAdr + (row * LineCon));
[f40a309]172
173 if (OldLine NE LineBuf)
[7258c6a]174 v_odtab[ScrlObj][2] = ((int32_t)LineBuf >> 1) & 0xFFFF;
[f40a309]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
[7258c6a]187void UpdVid(int16_t row, int16_t col, int8_t *str, uint16_t atr)
[f40a309]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
[0580615]208void bgncm(void)
[f40a309]209{
[7258c6a]210 register int16_t j;
[f40a309]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
[0580615]236void stopcm(void)
[f40a309]237{
238 if (PdScDnF)
239 SetDTop(CurLine, CurScan = TOPSCAN);
240 else if (PdScUpF)
241 SetDTop(++CurLine, CurScan = TOPSCAN);
242
243 if (NOT ctcsw) { /* if we scrolled ... */
244
245 if (ptecpos) { /* if something is there ... */
246
247 /* refresh editing variables */
248
249 memcpyw(&ptebuf.defnum, &patches[ptecpos].defnum, 6);
250 pteset = TRUE;
251 pte2buf();
252 setptcv();
253
254 } else { /* ... nothing there */
255
256 voidpb(); /* void the patch buffer */
257 }
258 }
259
260 ctcon(); /* re-enable cursor */
261
262 PdScDnF = FALSE; /* turn off the scrolling flags */
263 PdScUpF = FALSE;
264}
265
266/*
267 =============================================================================
268 stopsm() -- stop sequence display cursor motion
269 =============================================================================
270*/
271
[0580615]272void stopsm(void)
[f40a309]273{
274 if (PdScDnF)
275 SetDTop(CurLine, CurScan = TOPSCAN);
276 else if (PdScUpF)
277 SetDTop(++CurLine, CurScan = TOPSCAN);
278
279 memcpyw(&seqbuf, &seqtab[curslin], NSEQW);
280 dsqlin(sqdebuf, curslin);
281 sqdeflg = TRUE;
282 ctcon();
283
284 PdScDnF = FALSE;
285 PdScUpF = FALSE;
286}
287
288/*
289 =============================================================================
290 smscrl() -- smooth scroll the text display up or down
291 =============================================================================
292*/
293
[0580615]294void smscrl(void)
[f40a309]295{
296 if (PdScUpF) { /* SCROLL UP (toward NEW data) ? */
297
298 if (CurScan EQ TOPSCAN) { /* ready for a new line ? */
299
[7258c6a]300 if ((int8_t *)NULL NE (LinePtr = (*FwdLine)())) { /* get a line */
[f40a309]301
302 if (CurLine EQ SmScLim) { /* *** swap display pages *** */
303
304 /* update page we're going to */
305
306 WrVideo(SmScNsl, 0, LinePtr, LineAtr);
307
308 /* point at new page */
309
310 SetDTop(CurLine = 0, CurScan = TOPSCAN);
311
312 } else { /* *** stay on this page *** */
313
314 /* update scroll target line */
315
316 WrVideo(CurLine + SmScNsl, 0, LinePtr, LineAtr);
317
318 /* update other page if it's in range */
319
320 DupLine = CurLine - 2;
321
322 if (DupLine GE 0)
323 WrVideo(DupLine, 0, LinePtr, LineAtr);
324 }
325
326 /* do first scroll up of new line */
327
328 SetDTop(CurLine, --CurScan);
329 }
330
331 } else { /* scrolling -- scroll some more */
332
333 if (CurScan EQ 0)
334 SetDTop(++CurLine, CurScan = TOPSCAN);
335 else
336 SetDTop(CurLine, --CurScan);
337 }
[fa38804]338
[f40a309]339 } else if (PdScDnF) { /* SCROLL DOWN (toward old data) ? */
340
341 if (CurScan EQ TOPSCAN) { /* ready for a new line ? */
342
[7258c6a]343 if ((int8_t *)NULL NE (LinePtr = (*BakLine)())) { /* get a line */
[f40a309]344
345 if (CurLine EQ 0) { /* *** swap display pages *** */
346
347 /* update page we're going to */
348
349 WrVideo(SmScLim - 1, 0, LinePtr, LineAtr);
350
351 /* point at new page */
352
353 SetDTop(CurLine = SmScLim - 1, CurScan = 0);
354
355 } else { /* *** stay on this page *** */
356
357 /* update scroll target line */
358
359 WrVideo(CurLine - 1, 0, LinePtr, LineAtr);
360
361 /* update other page if it's in range */
362
363 DupLine = CurLine + SmScNsl + 1;
364
365 if (DupLine < SmScTop)
366 WrVideo(DupLine, 0, LinePtr, LineAtr);
367
368 /* do first scroll down of new line */
369
370 SetDTop(--CurLine, CurScan = 0);
371 }
372 }
373
374 } else { /* scrolling -- scroll some more */
375
376 if (CurScan NE TOPSCAN)
377 SetDTop(CurLine, ++CurScan);
378 }
379 }
380}
381
382/*
383 =============================================================================
384 smxupd() -- patch / sequence smooth scroll X axis update
385 =============================================================================
386*/
387
[0580615]388void smxupd(void)
[f40a309]389{
[7258c6a]390 int16_t oldcx;
[f40a309]391
392 oldcx = cxval;
393
394 if (submenu) {
395
396 vtccol = XTOC(vtxval += cxrate);
397
398 if (vtccol > 60)
399 vtxval = CTOX(vtccol = 60);
400 else if (vtccol < 2)
401 vtxval = CTOX(vtccol = 2);
402
403 } else {
404
405 cxval += cxrate;
406
407 if (cxval > CTOX(48))
408 cxval = CTOX(48);
409 else if (cxval < CTOX(2))
410 cxval = CTOX(2);
411
412 if (cxval EQ oldcx)
413 return;
414
415 if (47 EQ XTOC(cxval)) {
416
417 if (v_regs[5] & 0x0180)
418 vbank(0);
419
420 vvputsv(obj10, 16, PDBORFG, PDSEQBG,
421 7, 0, "\260", 14, 14, cg3);
422
423 vsplot4(obj10, 16, PDPTRFG,
424 7, 0, "\274", 14, 14, cg3);
425
426 } else if (48 EQ XTOC(cxval)) {
427
428 if (v_regs[5] & 0x0180)
429 vbank(0);
430
431 vvputsv(obj10, 16, PDBORFG, PDSEQBG,
432 7, 0, "\260", 14, 14, cg3);
433
434 vsplot4(obj10, 16, PDPTRFG,
435 7, 0, "\277", 14, 14, cg3);
436
437 }
[9519422]438
[f40a309]439 return;
440 }
441}
442
443/*
444 =============================================================================
445 smy_up() -- patch display smooth scrolling
446 =============================================================================
447*/
448
[7258c6a]449void smy_up(int16_t tag)
[f40a309]450{
451
452 if (0 EQ ptecpos) { /* see if anything is there */
453
454 dptw(); /* try to find something ... */
455 return; /* ... may scroll next time */
456 }
457
458 if (ctcsw) /* if we haven't scrolled yet ... */
459 bgncm(); /* ... setup for scrolling */
460
461 if (tag < 0) { /* scroll up */
462
463 if (0 EQ findnxt(ptecpos))
464 return;
465
466 PdScUpF = TRUE;
467 PdScDnF = FALSE;
468 smscrl();
469
470 } else if (tag > 0) { /* scroll down */
471
472 if (0 EQ findprv(ptecpos))
473 return;
474
475 PdScDnF = TRUE;
476 PdScUpF = FALSE;
477 smscrl();
478 }
479}
480
481/*
482 =============================================================================
483 smyupd() -- patch display smooth scroll Y axis update
484 =============================================================================
485*/
486
[0580615]487void smyupd(void)
[f40a309]488{
489 if (submenu) {
490
491 vtcrow = YTOR(vtyval += cyrate);
492
493 if (vtcrow > 23)
494 vtyval = RTOY(vtcrow = 23);
495 else if (vtcrow < 19)
496 vtyval = RTOY(vtcrow = 19);
497
498 }
499
500#if OLDSCRL
501 smy_up(cyrate);
502#endif
503}
504
505/*
506 =============================================================================
507 sqy_up() -- sequence smooth scrolling
508 =============================================================================
509*/
510
[7258c6a]511void sqy_up(int16_t tag)
[f40a309]512{
513 if (ctcsw)
514 ctcoff();
515
516 if (tag < 0) { /* scroll up */
517
518 PdScUpF = TRUE;
519 PdScDnF = FALSE;
520 smscrl();
521
522 } else if (tag > 0) { /* scroll down */
523
524 PdScDnF = TRUE;
525 PdScUpF = FALSE;
526 smscrl();
527 }
528}
529
530/*
531 =============================================================================
532 sqyupd() -- sequence smooth scroll Y axis update
533 =============================================================================
534*/
535
[0580615]536void sqyupd(void)
[f40a309]537{
538 if (submenu) {
539
540 vtcrow = YTOR(vtyval += cyrate);
541
542 if (vtcrow > 23)
543 vtyval = RTOY(vtcrow = 23);
544 else if (vtcrow < 19)
545 vtyval = RTOY(vtcrow = 19);
546
547 }
548
549#if OLDSCRL
550 sqy_up(cyrate);
551#endif
552}
[6262b5c]553
Note: See TracBrowser for help on using the repository browser.