-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathSPI-111.c
More file actions
712 lines (691 loc) · 22.6 KB
/
SPI-111.c
File metadata and controls
712 lines (691 loc) · 22.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
/***********************************************************************************************************************
PicoMite MMBasic
SPI-111.c
<COPYRIGHT HOLDERS> Geoff Graham, Peter Mather
Copyright (c) 2021, <COPYRIGHT HOLDERS> All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the distribution.
3. The name MMBasic be used when referring to the interpreter in any documentation and promotional material and the original copyright message be displayed
on the console at startup (additional copyright messages may be added).
4. All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed
by the <copyright holder>.
5. Neither the name of the <copyright holder> nor the names of its contributors may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDERS> AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDERS> BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
************************************************************************************************************************/
#include <stdarg.h>
#include "MMBasic_Includes.h"
#include "Hardware_Includes.h"
const uint32_t maskSPI111[32] = {0x00000001, 0x00000003, 0x00000007, 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff,
0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff,
0x0001ffff, 0x0003ffff, 0x0007ffff, 0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff, 0x00ffffff,
0x01ffffff, 0x03ffffff, 0x07ffffff, 0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffff};
const uint32_t rmaskSPI111[32] = {0x80000000, 0xC0000000, 0xe0000000, 0xf0000000, 0xf8000000, 0xfc000000, 0xfe000000, 0xff000000,
0xff800000, 0xffC00000, 0xffe00000, 0xfff00000, 0xfff80000, 0xfffc0000, 0xfffe0000, 0xffff0000,
0xffff8000, 0xffffC000, 0xffffe000, 0xfffff000, 0xfffff800, 0xfffffc00, 0xfffffe00, 0xffffff00,
0xffffff80, 0xffffffC0, 0xffffffe0, 0xfffffff0, 0xfffffff8, 0xfffffffc, 0xfffffffe, 0xffffffff};
uint32_t *VideoBufRed = NULL; // Image buffer for red
uint32_t *VideoBufGrn = NULL; // Image buffer for green
uint32_t *VideoBufBlu = NULL; // Image buffer for blue
volatile int lcnt;
volatile int VCount; // counter for the number of lines in a frame
volatile int VState; // the state of the state machine
volatile int showbuffer = 0; // the next counter table (initialise in initVideo() below)
void SPI111hline(int x0, int x1, int y, int con, int which);
inline void plot(int x, int y, int con);
void SPI111init(void)
{
// if(Option.DISPLAY_TYPE !=SPI111) return;
DrawRectangle = DrawRectangleSPI111;
DrawBitmap = DrawBitmapSPI111;
ScrollLCD = ScrollSPI111;
DrawBuffer = DrawBufferSPI111;
ReadBuffer = ReadBufferSPI111;
}
void DrawRectangleSPI111(int x1, int y1, int x2, int y2, int c)
{
int i, t;
int col = 0;
if (c & 0xFF0000)
col = 1;
if (c & 0xFF00)
col += 2;
if (c & 0xFF)
col += 4;
// make sure the coordinates are kept within the display area
if (x2 <= x1)
{
t = x1;
x1 = x2;
x2 = t;
}
if (y2 <= y1)
{
t = y1;
y1 = y2;
y2 = t;
}
if (x1 < 0)
x1 = 0;
if (x1 >= HRes)
x1 = HRes - 1;
if (x2 < 0)
x2 = 0;
if (x2 >= HRes)
x2 = HRes - 1;
if (y1 < 0)
y1 = 0;
if (y1 >= VRes)
y1 = VRes - 1;
if (y2 < 0)
y2 = 0;
if (y2 >= VRes)
y2 = VRes - 1;
for (i = y1; i <= y2; i++)
{
SPI111hline(x1, x2, i, col, 0);
}
}
void DrawBitmapSPI111(int x1, int y1, int width, int height, int scale, int fc, int bc, unsigned char *bitmap)
{
int i, j, k, m;
unsigned char fcol, bcol;
int vertCoord, horizCoord, XStart, XEnd, YEnd;
// adjust when part of the bitmap is outside the displayable coordinates
vertCoord = y1;
if (y1 < 0)
y1 = 0; // the y coord is above the top of the screen
XStart = x1;
if (XStart < 0)
XStart = 0; // the x coord is to the left of the left marginn
XEnd = x1 + (width * scale) - 1;
if (XEnd >= HRes)
XEnd = HRes - 1; // the width of the bitmap will extend beyond the right margin
YEnd = y1 + (height * scale) - 1;
if (YEnd >= VRes)
YEnd = VRes - 1; // the height of the bitmap will extend beyond the bottom margin
fcol = 0;
bcol = 0;
if (fc & 0xFF0000)
fcol = 1;
if (fc & 0xFF00)
fcol += 2;
if (fc & 0xFF)
fcol += 4;
if (bc != -1)
{
if (bc & 0xFF0000)
bcol = 1;
if (bc & 0xFF00)
bcol += 2;
if (bc & 0xFF)
bcol += 4;
}
else
bcol = 0xff;
for (i = 0; i < height; i++)
{ // step thru the font scan line by line
for (j = 0; j < scale; j++)
{ // repeat lines to scale the font
if (vertCoord++ < 0)
continue; // we are above the top of the screen
if (vertCoord > VRes)
return; // we have extended beyond the bottom of the screen
horizCoord = x1;
for (k = 0; k < width; k++)
{ // step through each bit in a scan line
for (m = 0; m < scale; m++)
{ // repeat pixels to scale in the x axis
if (horizCoord++ < 0)
continue; // we have not reached the left margin
if (horizCoord > HRes)
continue; // we are beyond the right margin
if ((bitmap[((i * width) + k) / 8] >> (((height * width) - ((i * width) + k) - 1) % 8)) & 1)
{
plot(horizCoord - 1, vertCoord - 1, fcol);
}
else
{
if (bcol != 0xff)
plot(horizCoord - 1, vertCoord - 1, bcol);
}
}
}
}
}
}
void SPI111hline(int x0, int x1, int y, int con, int which)
{ // draw a horizontal line
uint32_t w1, xx1, w0, xx0, x, xn, i;
const uint32_t a[] = {0xFFFFFFFF, 0x7FFFFFFF, 0x3FFFFFFF, 0x1FFFFFFF, 0xFFFFFFF, 0x7FFFFFF, 0x3FFFFFF, 0x1FFFFFF,
0xFFFFFF, 0x7FFFFF, 0x3FFFFF, 0x1FFFFF, 0xFFFFF, 0x7FFFF, 0x3FFFF, 0x1FFFF,
0xFFFF, 0x7FFF, 0x3FFF, 0x1FFF, 0xFFF, 0x7FF, 0x3FF, 0x1FF,
0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01};
const uint32_t b[] = {0x80000000, 0xC0000000, 0xe0000000, 0xf0000000, 0xf8000000, 0xfc000000, 0xfe000000, 0xff000000,
0xff800000, 0xffC00000, 0xffe00000, 0xfff00000, 0xfff80000, 0xfffc0000, 0xfffe0000, 0xffff0000,
0xffff8000, 0xffffC000, 0xffffe000, 0xfffff000, 0xfffff800, 0xfffffc00, 0xfffffe00, 0xffffff00,
0xffffff80, 0xffffffC0, 0xffffffe0, 0xfffffff0, 0xfffffff8, 0xfffffffc, 0xfffffffe, 0xffffffff};
uint32_t *br, *bg, *bb;
br = VideoBufRed;
bg = VideoBufGrn;
bb = VideoBufBlu;
w0 = y * (SPIints_per_line) + x0 / 32;
xx0 = (x0 & 0x1F);
w1 = y * (SPIints_per_line) + x1 / 32;
xx1 = (x1 & 0x1F);
if (w1 == w0)
{ // special case both inside same word
x = (a[xx0] & b[xx1]);
xn = ~x;
if (con & 1)
br[w0] |= x;
else
br[w0] &= xn; // turn on the red pixel
if (con & 2)
bg[w0] |= x;
else
bg[w0] &= xn; // turn on the green pixel
if (con & 4)
bb[w0] |= x;
else
bb[w0] &= xn; // turn on the blue pixel
}
else
{
if (w1 - w0 > 1)
{ // first deal with full words
for (i = w0 + 1; i < w1; i++)
{
// draw the pixel
br[i] = 0; // turn off the red pixels
bg[i] = 0; // turn off the green pixels
bb[i] = 0; // turn off the blue pixels
if (con & 1)
br[i] = 0xFFFFFFFF; // turn on the red pixels
if (con & 2)
bg[i] = 0xFFFFFFFF; // turn on the green pixels
if (con & 4)
bb[i] = 0xFFFFFFFF; // turn on the blue pixels
}
}
x = ~a[xx0];
br[w0] &= x; // turn off the red pixel
bg[w0] &= x; // turn off the green pixel
bb[w0] &= x; // turn off the blue pixel
x = ~x;
if (con & 1)
br[w0] |= x; // turn on the red pixel
if (con & 2)
bg[w0] |= x; // turn on the green pixel
if (con & 4)
bb[w0] |= x; // turn on the blue pixel
x = ~b[xx1];
br[w1] &= x; // turn off the red pixel
bg[w1] &= x; // turn off the green pixel
bb[w1] &= x; // turn off the blue pixel
x = ~x;
if (con & 1)
br[w1] |= x; // turn on the red pixel
if (con & 2)
bg[w1] |= x; // turn on the green pixel
if (con & 4)
bb[w1] |= x; // turn on the blue pixel
}
}
void DrawBufferSPI111(int x1, int y1, int x2, int y2, unsigned char *p)
{
int t, x, y, w, xd, c1;
unsigned int xx, xxn;
uint32_t *br, *bg, *bb;
br = VideoBufRed, bg = VideoBufGrn, bb = VideoBufBlu;
// make sure the coordinates are kept within the display area
if (x2 <= x1)
{
t = x1;
x1 = x2;
x2 = t;
}
if (y2 <= y1)
{
t = y1;
y1 = y2;
y2 = t;
}
for (y = y1; y <= y2; y++)
{
c1 = y * (SPIints_per_line);
for (x = x1; x <= x2; x++)
{
xx = (0x80000000 >> (x & 0x1f));
xxn = ~xx;
xd = x >> 5;
w = c1 + xd;
// draw the pixel
if (y >= 0 && y < VRes && x >= 0 && x < HRes)
{
if (*p++ > 0x80)
{
bb[w] |= xx;
}
else
{
bb[w] &= xxn;
} // turn on the blue pixel
if (*p++ > 0x80)
{
bg[w] |= xx;
}
else
{
bg[w] &= xxn;
} // turn on the green pixel
if (*p++ > 0x80)
{
br[w] |= xx;
}
else
{
br[w] &= xxn;
} // turn on the red pixel
}
else
p += 3;
}
}
}
void ReadBufferSPI111(int x1, int y1, int x2, int y2, unsigned char *p)
{
int t, x, y, w, xx, xd, c1;
// make sure the coordinates are kept within the display area
if (x2 <= x1)
{
t = x1;
x1 = x2;
x2 = t;
}
if (y2 <= y1)
{
t = y1;
y1 = y2;
y2 = t;
}
for (y = y1; y <= y2; y++)
{
c1 = y * (SPIints_per_line);
for (x = x1; x <= x2; x++)
{
xx = (0x80000000 >> (x & 0x1f));
xd = x >> 5;
w = c1 + xd;
if (y >= 0 && y < VRes && x >= 0 && x < HRes)
{
*p++ = ((VideoBufBlu[w]) & xx) ? 0xff : 0;
*p++ = ((VideoBufGrn[w]) & xx) ? 0xff : 0;
*p++ = ((VideoBufRed[w]) & xx) ? 0xff : 0;
}
else
p += 3;
}
}
}
void plot121(int x, int y, int con)
{
int w, xx, xxn, xd;
uint32_t *br, *bg, *bb;
br = VideoBufRed, bg = VideoBufGrn, bb = VideoBufBlu;
xx = (0x80000000 >> (x & 0x1f));
xd = x >> 5;
w = y * (SPIints_per_line) + xd;
// draw the pixel
xxn = ~xx;
if (con & 1)
br[w] |= xx;
else
br[w] &= xxn; // turn on the red pixel
if (con & 6)
bg[w] |= xx;
else
bg[w] &= xxn; // turn on the green pixel
if (con & 8)
bb[w] |= xx;
else
bb[w] &= xxn; // turn on the blue pixel
}
inline void plot(int x, int y, int con)
{
int w, xx, xxn, xd;
uint32_t *br, *bg, *bb;
br = VideoBufRed, bg = VideoBufGrn, bb = VideoBufBlu;
xx = (0x80000000 >> (x & 0x1f));
xd = x >> 5;
w = y * (SPIints_per_line) + xd;
// draw the pixel
xxn = ~xx;
if (con & 1)
br[w] |= xx;
else
br[w] &= xxn; // turn on the red pixel
if (con & 2)
bg[w] |= xx;
else
bg[w] &= xxn; // turn on the green pixel
if (con & 4)
bb[w] |= xx;
else
bb[w] &= xxn; // turn on the blue pixel
}
void copyframetoscreen(uint8_t *s, int xstart, int xend, int ystart, int yend, int odd)
{
int c;
int i = (xend - xstart + 1) * (yend - ystart + 1);
int x = xstart, y = ystart;
if (odd)
{
c = (*s & 0xF0) >> 4;
plot121(x, y, c);
if (x == xend)
{
x = xstart;
y++;
}
else
x++;
s++;
i--;
}
while (i > 0)
{
c = *s & 0xF;
plot121(x, y, c);
if (x == xend)
{
x = xstart;
y++;
}
else
x++;
if (i > 1)
{
c = (*s & 0xF0) >> 4;
plot121(x, y, c);
if (x == xend)
{
x = xstart;
y++;
}
else
x++;
s++;
i -= 2;
}
}
}
void ScrollSPI111sideways(int lines)
{
int i, j;
uint32_t k, l, prevr = 0, prevg = 0, prevb = 0;
uint32_t *pdr, *pdg, *pdb;
uint32_t *br, *bg, *bb;
br = VideoBufRed, bg = VideoBufGrn, bb = VideoBufBlu;
int m1 = 0x0;
int m2 = 0x0;
if (lines > 0)
{
for (j = 0; j < VRes; j++)
{
pdr = br + (SPIints_per_line * j);
pdg = bg + (SPIints_per_line * j);
pdb = bb + (SPIints_per_line * j);
for (i = 0; i <= HRes / 32; i++)
{
l = *pdr;
k = l & maskSPI111[lines - 1];
l = l >> lines;
l |= prevr;
if (i == 0)
l &= m1;
if (i == HRes / 32)
l &= m2;
*pdr++ = l;
prevr = k << (32 - lines);
l = *pdg;
k = l & maskSPI111[lines - 1];
l = l >> lines;
l |= prevg;
if (i == 0)
l &= m1;
if (i == HRes / 32)
l &= m2;
*pdg++ = l;
prevg = k << (32 - lines);
l = *pdb;
k = l & maskSPI111[lines - 1];
l = l >> lines;
l |= prevb;
if (i == 0)
l &= m1;
if (i == HRes / 32)
l &= m2;
*pdb++ = l;
prevb = k << (32 - lines);
}
}
}
else
{
int m = -lines;
for (j = 0; j < VRes; j++)
{
pdr = br + HRes / 32 + (SPIints_per_line * j);
pdg = bb + HRes / 32 + (SPIints_per_line * j);
pdb = bg + HRes / 32 + (SPIints_per_line * j);
for (i = HRes / 32; i >= 0; i--)
{
l = *pdr;
k = l & rmaskSPI111[m];
l = l << m;
l |= prevr;
if (i == 0)
l &= m1;
if (i == HRes / 32)
l &= m2;
*pdr-- = l;
prevr = k >> (32 - m);
l = *pdg;
k = l & rmaskSPI111[m];
l = l << m;
l |= prevg;
if (i == 0)
l &= m1;
if (i == HRes / 32)
l &= m2;
*pdg-- = l;
prevg = k >> (32 - m);
l = *pdb;
k = l & rmaskSPI111[m];
l = l << m;
l |= prevb;
if (i == 0)
l &= m1;
if (i == HRes / 32)
l &= m2;
*pdb-- = l;
prevb = k >> (32 - m);
}
}
}
}
void ScrollSPI111(int lines)
{
int i, amount;
uint32_t *pdr, *pdg, *pdb;
uint32_t *psr, *psg, *psb;
uint32_t *br, *bg, *bb;
br = VideoBufRed, bg = VideoBufGrn, bb = VideoBufBlu;
if (lines >= 0)
{
amount = SPIints_per_line * (VRes - lines);
pdr = br;
psr = pdr + SPIints_per_line * lines;
pdg = bg;
psg = pdg + SPIints_per_line * lines;
pdb = bb;
psb = pdb + SPIints_per_line * lines;
for (i = 0; i < amount; i += 8)
{
*pdr++ = *psr++; // scroll up
*pdr++ = *psr++; // scroll up
*pdr++ = *psr++; // scroll up
*pdr++ = *psr++; // scroll up
*pdr++ = *psr++; // scroll up
*pdr++ = *psr++; // scroll up
*pdr++ = *psr++; // scroll up
*pdr++ = *psr++; // scroll up
*pdg++ = *psg++;
*pdg++ = *psg++;
*pdg++ = *psg++;
*pdg++ = *psg++;
*pdg++ = *psg++;
*pdg++ = *psg++;
*pdg++ = *psg++;
*pdg++ = *psg++;
*pdb++ = *psb++;
*pdb++ = *psb++;
*pdb++ = *psb++;
*pdb++ = *psb++;
*pdb++ = *psb++;
*pdb++ = *psb++;
*pdb++ = *psb++;
*pdb++ = *psb++;
}
DrawRectangle(0, VRes - lines, HRes - 1, VRes - 1, gui_bcolour); // erase the lines introduced at the bottom
}
else
{
lines = -lines;
amount = SPIints_per_line * (VRes - lines);
psr = br + SPIints_per_line * (VRes - lines);
pdr = psr + SPIints_per_line * lines;
psg = bg + SPIints_per_line * (VRes - lines);
pdg = psg + SPIints_per_line * lines;
psb = bb + SPIints_per_line * (VRes - lines);
pdb = psb + SPIints_per_line * lines;
for (i = 0; i < amount; i += 8)
{
*--pdr = *--psr; // scroll down
*--pdr = *--psr; // scroll down
*--pdr = *--psr; // scroll down
*--pdr = *--psr; // scroll down
*--pdr = *--psr; // scroll down
*--pdr = *--psr; // scroll down
*--pdr = *--psr; // scroll down
*--pdr = *--psr; // scroll down
*--pdg = *--psg;
*--pdg = *--psg;
*--pdg = *--psg;
*--pdg = *--psg;
*--pdg = *--psg;
*--pdg = *--psg;
*--pdg = *--psg;
*--pdg = *--psg;
*--pdb = *--psb;
*--pdb = *--psb;
*--pdb = *--psb;
*--pdb = *--psb;
*--pdb = *--psb;
*--pdb = *--psb;
*--pdb = *--psb;
*--pdb = *--psb;
}
DrawRectangle(0, 0, HRes - 1, lines - 1, gui_bcolour); // erase the lines introduced at the top
}
}
void ScrollSPI111vertical(int lines, int blank)
{
int i, amount;
uint32_t *pdr, *pdg, *pdb;
uint32_t *psr, *psg, *psb;
uint32_t *br, *bg, *bb;
br = VideoBufRed, bg = VideoBufGrn, bb = VideoBufBlu;
if (lines >= 0)
{
amount = SPIints_per_line * (VRes - lines);
pdr = br;
psr = pdr + SPIints_per_line * lines;
pdg = bg;
psg = pdg + SPIints_per_line * lines;
pdb = bb;
psb = pdb + SPIints_per_line * lines;
for (i = 0; i < amount; i += 8)
{
*pdr++ = *psr++; // scroll up
*pdr++ = *psr++; // scroll up
*pdr++ = *psr++; // scroll up
*pdr++ = *psr++; // scroll up
*pdr++ = *psr++; // scroll up
*pdr++ = *psr++; // scroll up
*pdr++ = *psr++; // scroll up
*pdr++ = *psr++; // scroll up
*pdg++ = *psg++;
*pdg++ = *psg++;
*pdg++ = *psg++;
*pdg++ = *psg++;
*pdg++ = *psg++;
*pdg++ = *psg++;
*pdg++ = *psg++;
*pdg++ = *psg++;
*pdb++ = *psb++;
*pdb++ = *psb++;
*pdb++ = *psb++;
*pdb++ = *psb++;
*pdb++ = *psb++;
*pdb++ = *psb++;
*pdb++ = *psb++;
*pdb++ = *psb++;
}
}
else
{
lines = -lines;
amount = SPIints_per_line * (VRes - lines);
psr = br + SPIints_per_line * (VRes - lines);
pdr = psr + SPIints_per_line * lines;
psg = bg + SPIints_per_line * (VRes - lines);
pdg = psg + SPIints_per_line * lines;
psb = bb + SPIints_per_line * (VRes - lines);
pdb = psb + SPIints_per_line * lines;
for (i = 0; i < amount; i += 8)
{
*--pdr = *--psr; // scroll down
*--pdr = *--psr; // scroll down
*--pdr = *--psr; // scroll down
*--pdr = *--psr; // scroll down
*--pdr = *--psr; // scroll down
*--pdr = *--psr; // scroll down
*--pdr = *--psr; // scroll down
*--pdr = *--psr; // scroll down
*--pdg = *--psg;
*--pdg = *--psg;
*--pdg = *--psg;
*--pdg = *--psg;
*--pdg = *--psg;
*--pdg = *--psg;
*--pdg = *--psg;
*--pdg = *--psg;
*--pdb = *--psb;
*--pdb = *--psb;
*--pdb = *--psb;
*--pdb = *--psb;
*--pdb = *--psb;
*--pdb = *--psb;
*--pdb = *--psb;
*--pdb = *--psb;
}
}
}