summaryrefslogtreecommitdiff
path: root/apps/plugins/lib/gray_scroll.c
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2006-08-07 01:46:42 +0000
committerJens Arnold <amiconn@rockbox.org>2006-08-07 01:46:42 +0000
commitc214e7bb0c3e97d22ecedb1c62f193e19a1d4818 (patch)
tree6d8b18694076dcf1d0fa2f02f558f78e572327b4 /apps/plugins/lib/gray_scroll.c
parent5375e26e51e9c6eaded4f733bf60cc8bbf662a8a (diff)
downloadrockbox-c214e7bb0c3e97d22ecedb1c62f193e19a1d4818.tar.gz
rockbox-c214e7bb0c3e97d22ecedb1c62f193e19a1d4818.zip
Grayscale library ported to the grayscale iPods, first version. Added C reference versions of gray_update_rect() for both horizontal and vertical pixel packing. gray_update_rect() and gray_ub_gray_bitmap_part() not yet assembler optimised. Grayscale screendump doesn't work yet. * Fixed button assignments for iPod in grayscale.c
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10468 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/lib/gray_scroll.c')
-rw-r--r--apps/plugins/lib/gray_scroll.c397
1 files changed, 373 insertions, 24 deletions
diff --git a/apps/plugins/lib/gray_scroll.c b/apps/plugins/lib/gray_scroll.c
index 3cdb7d5afe..df5dc57044 100644
--- a/apps/plugins/lib/gray_scroll.c
+++ b/apps/plugins/lib/gray_scroll.c
@@ -11,7 +11,8 @@
11* Scrolling routines 11* Scrolling routines
12* 12*
13* This is a generic framework to display up to 33 shades of grey 13* This is a generic framework to display up to 33 shades of grey
14* on low-depth bitmap LCDs (Archos b&w, Iriver 4-grey) within plugins. 14* on low-depth bitmap LCDs (Archos b&w, Iriver 4-grey, iPod 4-grey)
15* within plugins.
15* 16*
16* Copyright (C) 2004-2006 Jens Arnold 17* Copyright (C) 2004-2006 Jens Arnold
17* 18*
@@ -30,6 +31,96 @@
30 31
31/*** Scrolling ***/ 32/*** Scrolling ***/
32 33
34#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
35
36/* Scroll left */
37void gray_scroll_left(int count)
38{
39 unsigned char *data, *data_end;
40 int length, blank;
41
42 if ((unsigned)count >= (unsigned)_gray_info.width)
43 return;
44
45 data = _gray_info.cur_buffer;
46 data_end = data + MULU16(_gray_info.width, _gray_info.height);
47 length = _gray_info.width - count;
48 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
49 _gray_info.fg_index : _gray_info.bg_index;
50
51 do
52 {
53 _gray_rb->memmove(data, data + count, length);
54 _gray_rb->memset(data + length, blank, count);
55 data += _gray_info.width;
56 }
57 while (data < data_end);
58}
59
60/* Scroll right */
61void gray_scroll_right(int count)
62{
63 unsigned char *data, *data_end;
64 int length, blank;
65
66 if ((unsigned)count >= (unsigned)_gray_info.width)
67 return;
68
69 data = _gray_info.cur_buffer;
70 data_end = data + MULU16(_gray_info.width, _gray_info.height);
71 length = _gray_info.width - count;
72 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
73 _gray_info.fg_index : _gray_info.bg_index;
74
75 do
76 {
77 _gray_rb->memmove(data + count, data, length);
78 _gray_rb->memset(data, blank, count);
79 data += _gray_info.width;
80 }
81 while (data < data_end);
82}
83
84/* Scroll up */
85void gray_scroll_up(int count)
86{
87 long shift, length;
88 int blank;
89
90 if ((unsigned)count >= (unsigned)_gray_info.height)
91 return;
92
93 shift = MULU16(_gray_info.width, count);
94 length = MULU16(_gray_info.width, _gray_info.height - count);
95 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
96 _gray_info.fg_index : _gray_info.bg_index;
97
98 _gray_rb->memmove(_gray_info.cur_buffer, _gray_info.cur_buffer + shift,
99 length);
100 _gray_rb->memset(_gray_info.cur_buffer + length, blank, shift);
101}
102
103/* Scroll down */
104void gray_scroll_down(int count)
105{
106 long shift, length;
107 int blank;
108
109 if ((unsigned)count >= (unsigned)_gray_info.height)
110 return;
111
112 shift = MULU16(_gray_info.width, count);
113 length = MULU16(_gray_info.width, _gray_info.height - count);
114 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
115 _gray_info.fg_index : _gray_info.bg_index;
116
117 _gray_rb->memmove(_gray_info.cur_buffer + shift, _gray_info.cur_buffer,
118 length);
119 _gray_rb->memset(_gray_info.cur_buffer, blank, shift);
120}
121
122#else /* LCD_PIXELFORMAT == VERTICAL_PACKING */
123
33/* Scroll left */ 124/* Scroll left */
34void gray_scroll_left(int count) 125void gray_scroll_left(int count)
35{ 126{
@@ -44,7 +135,8 @@ void gray_scroll_left(int count)
44 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ? 135 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
45 _gray_info.fg_index : _gray_info.bg_index; 136 _gray_info.fg_index : _gray_info.bg_index;
46 137
47 _gray_rb->memmove(_gray_info.cur_buffer, _gray_info.cur_buffer + shift, length); 138 _gray_rb->memmove(_gray_info.cur_buffer, _gray_info.cur_buffer + shift,
139 length);
48 _gray_rb->memset(_gray_info.cur_buffer + length, blank, shift); 140 _gray_rb->memset(_gray_info.cur_buffer + length, blank, shift);
49} 141}
50 142
@@ -62,7 +154,8 @@ void gray_scroll_right(int count)
62 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ? 154 blank = (_gray_info.drawmode & DRMODE_INVERSEVID) ?
63 _gray_info.fg_index : _gray_info.bg_index; 155 _gray_info.fg_index : _gray_info.bg_index;
64 156
65 _gray_rb->memmove(_gray_info.cur_buffer + shift, _gray_info.cur_buffer, length); 157 _gray_rb->memmove(_gray_info.cur_buffer + shift, _gray_info.cur_buffer,
158 length);
66 _gray_rb->memset(_gray_info.cur_buffer, blank, shift); 159 _gray_rb->memset(_gray_info.cur_buffer, blank, shift);
67} 160}
68 161
@@ -113,6 +206,7 @@ void gray_scroll_down(int count)
113 } 206 }
114 while (data < data_end); 207 while (data < data_end);
115} 208}
209#endif /* LCD_PIXELFORMAT */
116 210
117/*** Unbuffered scrolling functions ***/ 211/*** Unbuffered scrolling functions ***/
118 212
@@ -148,6 +242,260 @@ void gray_ub_scroll_down(int count)
148 242
149#else /* !SIMULATOR */ 243#else /* !SIMULATOR */
150 244
245#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
246
247/* Scroll left */
248void gray_ub_scroll_left(int count)
249{
250 int shift, length;
251 unsigned char *ptr, *ptr_end;
252
253 if ((unsigned) count >= (unsigned) _gray_info.width)
254 return;
255
256 shift = count >> 3;
257 count &= 7;
258
259 if (shift)
260 {
261 length = _gray_info.bwidth - shift;
262 ptr = _gray_info.plane_data;
263 ptr_end = ptr + _gray_info.plane_size;
264
265 /* Scroll row by row to minimize flicker */
266 do
267 {
268 unsigned char *ptr_row = ptr;
269 unsigned char *row_end = ptr_row
270 + MULU16(_gray_info.plane_size, _gray_info.depth);
271 do
272 {
273 _gray_rb->memmove(ptr_row, ptr_row + shift, length);
274 _gray_rb->memset(ptr_row + length, 0, shift);
275 ptr_row += _gray_info.plane_size;
276 }
277 while (ptr_row < row_end);
278
279 ptr += _gray_info.bwidth;
280 }
281 while (ptr < ptr_end);
282 }
283 if (count)
284 {
285 asm (
286 "mov r4, %[high] \n"
287
288 ".sl_rloop: \n"
289 "mov r5, %[addr] \n"
290 "mov r2, %[dpth] \n"
291
292 ".sl_oloop: \n"
293 "mov r6, r5 \n"
294 "mov r3, %[cols] \n"
295 "mov r1, #0 \n"
296
297 ".sl_iloop: \n"
298 "mov r1, r1, lsr #8 \n"
299 "ldrb r0, [r6, #-1]! \n"
300 "orr r1, r1, r0, lsl %[cnt] \n"
301 "strb r1, [r6] \n"
302
303 "subs r3, r3, #1 \n"
304 "bne .sl_iloop \n"
305
306 "add r5, r5, %[psiz] \n"
307 "subs r2, r2, #1 \n"
308 "bne .sl_oloop \n"
309
310 "add %[addr],%[addr],%[bwid] \n"
311 "subs r4, r4, #1 \n"
312 "bne .sl_rloop \n"
313 : /* outputs */
314 : /* inputs */
315 [dpth]"r"(_gray_info.depth),
316 [high]"r"(_gray_info.height),
317 [bwid]"r"(_gray_info.bwidth),
318 [cols]"r"(_gray_info.bwidth - shift),
319 [psiz]"r"(_gray_info.plane_size),
320 [addr]"r"(_gray_info.plane_data + _gray_info.bwidth - shift),
321 [cnt] "r"(count)
322 : /* clobbers */
323 "r0", "r1", "r2", "r3", "r4", "r5", "r6"
324 );
325 }
326}
327
328/* Scroll right */
329void gray_ub_scroll_right(int count)
330{
331 int shift, length;
332 unsigned char *ptr, *ptr_end;
333
334 if ((unsigned) count >= (unsigned) _gray_info.width)
335 return;
336
337 shift = count >> 3;
338 count &= 7;
339
340 if (shift)
341 {
342 length = _gray_info.bwidth - shift;
343 ptr = _gray_info.plane_data;
344 ptr_end = ptr + _gray_info.plane_size;
345
346 /* Scroll row by row to minimize flicker */
347 do
348 {
349 unsigned char *ptr_row = ptr;
350 unsigned char *row_end = ptr_row
351 + MULU16(_gray_info.plane_size, _gray_info.depth);
352 do
353 {
354 _gray_rb->memmove(ptr_row + shift, ptr_row, length);
355 _gray_rb->memset(ptr_row, 0, shift);
356 ptr_row += _gray_info.plane_size;
357 }
358 while (ptr_row < row_end);
359
360 ptr += _gray_info.bwidth;
361 }
362 while (ptr < ptr_end);
363 }
364 if (count)
365 {
366 asm (
367 "mov r4, %[high] \n"
368
369 ".sr_rloop: \n"
370 "mov r5, %[addr] \n"
371 "mov r2, %[dpth] \n"
372
373 ".sr_oloop: \n"
374 "mov r6, r5 \n"
375 "mov r3, %[cols] \n"
376 "mov r1, #0 \n"
377
378 ".sr_iloop: \n"
379 "ldrb r0, [r6] \n"
380 "orr r1, r0, r1, lsl #8 \n"
381 "mov r0, r1, lsr %[cnt] \n"
382 "strb r0, [r6], #1 \n"
383
384 "subs r3, r3, #1 \n"
385 "bne .sr_iloop \n"
386
387 "add r5, r5, %[psiz] \n"
388 "subs r2, r2, #1 \n"
389 "bne .sr_oloop \n"
390
391 "add %[addr],%[addr],%[bwid] \n"
392 "subs r4, r4, #1 \n"
393 "bne .sr_rloop \n"
394 : /* outputs */
395 : /* inputs */
396 [dpth]"r"(_gray_info.depth),
397 [high]"r"(_gray_info.height),
398 [bwid]"r"(_gray_info.bwidth),
399 [cols]"r"(_gray_info.bwidth - shift),
400 [psiz]"r"(_gray_info.plane_size),
401 [addr]"r"(_gray_info.plane_data + shift),
402 [cnt] "r"(count)
403 : /* clobbers */
404 "r0", "r1", "r2", "r3", "r4", "r5", "r6"
405 );
406 }
407}
408
409/* Scroll up */
410void gray_ub_scroll_up(int count)
411{
412 long blockshift;
413 unsigned char *ptr, *ptr_end1, *ptr_end2;
414
415 if ((unsigned) count >= (unsigned) _gray_info.height)
416 return;
417
418 blockshift = MULU16(_gray_info.bwidth, count);
419 ptr = _gray_info.plane_data;
420 ptr_end2 = ptr + _gray_info.plane_size;
421 ptr_end1 = ptr_end2 - blockshift;
422 /* Scroll row by row to minimize flicker */
423 do
424 {
425 unsigned char *ptr_row = ptr;
426 unsigned char *row_end = ptr_row
427 + MULU16(_gray_info.plane_size, _gray_info.depth);
428 if (ptr < ptr_end1)
429 {
430 do
431 {
432 _gray_rb->memcpy(ptr_row, ptr_row + blockshift,
433 _gray_info.bwidth);
434 ptr_row += _gray_info.plane_size;
435 }
436 while (ptr_row < row_end);
437 }
438 else
439 {
440 do
441 {
442 _gray_rb->memset(ptr_row, 0, _gray_info.bwidth);
443 ptr_row += _gray_info.plane_size;
444 }
445 while (ptr_row < row_end);
446 }
447
448 ptr += _gray_info.bwidth;
449 }
450 while (ptr < ptr_end2);
451}
452
453/* Scroll down */
454void gray_ub_scroll_down(int count)
455{
456 long blockshift;
457 unsigned char *ptr, *ptr_end1, *ptr_end2;
458
459 if ((unsigned) count >= (unsigned) _gray_info.height)
460 return;
461
462 blockshift = MULU16(_gray_info.bwidth, count);
463 ptr_end2 = _gray_info.plane_data;
464 ptr_end1 = ptr_end2 + blockshift;
465 ptr = ptr_end2 + _gray_info.plane_size;
466 /* Scroll row by row to minimize flicker */
467 do
468 {
469 unsigned char *ptr_row, *row_end;
470
471 ptr -= _gray_info.bwidth;
472 ptr_row = ptr;
473 row_end = ptr_row + MULU16(_gray_info.plane_size, _gray_info.depth);
474
475 if (ptr >= ptr_end1)
476 {
477 do
478 {
479 _gray_rb->memcpy(ptr_row, ptr_row - blockshift,
480 _gray_info.bwidth);
481 ptr_row += _gray_info.plane_size;
482 }
483 while (ptr_row < row_end);
484 }
485 else
486 {
487 do
488 {
489 _gray_rb->memset(ptr_row, 0, _gray_info.bwidth);
490 ptr_row += _gray_info.plane_size;
491 }
492 while (ptr_row < row_end);
493 }
494 }
495 while (ptr > ptr_end2);
496}
497#else /* LCD_PIXELFORMAT == VERTICAL_PACKING */
498
151/* Scroll left */ 499/* Scroll left */
152void gray_ub_scroll_left(int count) 500void gray_ub_scroll_left(int count)
153{ 501{
@@ -156,17 +504,17 @@ void gray_ub_scroll_left(int count)
156 504
157 if ((unsigned) count >= (unsigned) _gray_info.width) 505 if ((unsigned) count >= (unsigned) _gray_info.width)
158 return; 506 return;
159 507
160 length = _gray_info.width - count; 508 length = _gray_info.width - count;
161 ptr = _gray_info.plane_data; 509 ptr = _gray_info.plane_data;
162 ptr_end = ptr + _gray_info.plane_size; 510 ptr_end = ptr + _gray_info.plane_size;
163 511
164 /* Scroll row by row to minimize flicker (pixel block rows) */ 512 /* Scroll row by row to minimize flicker (pixel block rows) */
165 do 513 do
166 { 514 {
167 unsigned char *ptr_row = ptr; 515 unsigned char *ptr_row = ptr;
168 unsigned char *row_end = ptr_row 516 unsigned char *row_end = ptr_row
169 + MULU16(_gray_info.plane_size, _gray_info.depth); 517 + MULU16(_gray_info.plane_size, _gray_info.depth);
170 do 518 do
171 { 519 {
172 _gray_rb->memmove(ptr_row, ptr_row + count, length); 520 _gray_rb->memmove(ptr_row, ptr_row + count, length);
@@ -188,17 +536,17 @@ void gray_ub_scroll_right(int count)
188 536
189 if ((unsigned) count >= (unsigned) _gray_info.width) 537 if ((unsigned) count >= (unsigned) _gray_info.width)
190 return; 538 return;
191 539
192 length = _gray_info.width - count; 540 length = _gray_info.width - count;
193 ptr = _gray_info.plane_data; 541 ptr = _gray_info.plane_data;
194 ptr_end = ptr + _gray_info.plane_size; 542 ptr_end = ptr + _gray_info.plane_size;
195 543
196 /* Scroll row by row to minimize flicker (pixel block rows) */ 544 /* Scroll row by row to minimize flicker (pixel block rows) */
197 do 545 do
198 { 546 {
199 unsigned char *ptr_row = ptr; 547 unsigned char *ptr_row = ptr;
200 unsigned char *row_end = ptr_row 548 unsigned char *row_end = ptr_row
201 + MULU16(_gray_info.plane_size, _gray_info.depth); 549 + MULU16(_gray_info.plane_size, _gray_info.depth);
202 do 550 do
203 { 551 {
204 _gray_rb->memmove(ptr_row + count, ptr_row, length); 552 _gray_rb->memmove(ptr_row + count, ptr_row, length);
@@ -221,10 +569,10 @@ void gray_ub_scroll_up(int count)
221 569
222 if ((unsigned) count >= (unsigned) _gray_info.height) 570 if ((unsigned) count >= (unsigned) _gray_info.height)
223 return; 571 return;
224 572
225 shift = count >> _PBLOCK_EXP; 573 shift = count >> 3;
226 count &= (_PBLOCK-1); 574 count &= 7;
227 575
228 if (shift) 576 if (shift)
229 { 577 {
230 blockshift = MULU16(_gray_info.width, shift); 578 blockshift = MULU16(_gray_info.width, shift);
@@ -235,7 +583,7 @@ void gray_ub_scroll_up(int count)
235 do 583 do
236 { 584 {
237 unsigned char *ptr_row = ptr; 585 unsigned char *ptr_row = ptr;
238 unsigned char *row_end = ptr_row 586 unsigned char *row_end = ptr_row
239 + MULU16(_gray_info.plane_size, _gray_info.depth); 587 + MULU16(_gray_info.plane_size, _gray_info.depth);
240 if (ptr < ptr_end1) 588 if (ptr < ptr_end1)
241 { 589 {
@@ -263,7 +611,7 @@ void gray_ub_scroll_up(int count)
263 } 611 }
264 if (count) 612 if (count)
265 { 613 {
266#if (CONFIG_CPU == SH7034) && (LCD_DEPTH == 1) 614#if CONFIG_CPU == SH7034
267 /* scroll column by column to minimize flicker */ 615 /* scroll column by column to minimize flicker */
268 asm ( 616 asm (
269 "mov #0,r6 \n" /* x = 0 */ 617 "mov #0,r6 \n" /* x = 0 */
@@ -345,7 +693,7 @@ void gray_ub_scroll_up(int count)
345 : /* clobbers */ 693 : /* clobbers */
346 "r0", "r1", "r2", "r3", "r4", "r5", "r6" 694 "r0", "r1", "r2", "r3", "r4", "r5", "r6"
347 ); 695 );
348#elif defined(CPU_COLDFIRE) && (LCD_DEPTH == 2) 696#elif defined(CPU_COLDFIRE)
349 /* scroll column by column to minimize flicker */ 697 /* scroll column by column to minimize flicker */
350 asm ( 698 asm (
351 "move.l %[wide],%%d4\n" /* columns = width */ 699 "move.l %[wide],%%d4\n" /* columns = width */
@@ -406,9 +754,9 @@ void gray_ub_scroll_down(int count)
406 if ((unsigned) count >= (unsigned) _gray_info.height) 754 if ((unsigned) count >= (unsigned) _gray_info.height)
407 return; 755 return;
408 756
409 shift = count >> _PBLOCK_EXP; 757 shift = count >> 3;
410 count &= (_PBLOCK-1); 758 count &= 7;
411 759
412 if (shift) 760 if (shift)
413 { 761 {
414 blockshift = MULU16(_gray_info.width, shift); 762 blockshift = MULU16(_gray_info.width, shift);
@@ -448,7 +796,7 @@ void gray_ub_scroll_down(int count)
448 } 796 }
449 if (count) 797 if (count)
450 { 798 {
451#if (CONFIG_CPU == SH7034) && (LCD_DEPTH == 1) 799#if CONFIG_CPU == SH7034
452 /* scroll column by column to minimize flicker */ 800 /* scroll column by column to minimize flicker */
453 asm ( 801 asm (
454 "mov #0,r6 \n" /* x = 0 */ 802 "mov #0,r6 \n" /* x = 0 */
@@ -529,7 +877,7 @@ void gray_ub_scroll_down(int count)
529 : /* clobbers */ 877 : /* clobbers */
530 "r0", "r1", "r2", "r3", "r4", "r5", "r6" 878 "r0", "r1", "r2", "r3", "r4", "r5", "r6"
531 ); 879 );
532#elif defined(CPU_COLDFIRE) && (LCD_DEPTH == 2) 880#elif defined(CPU_COLDFIRE)
533 /* scroll column by column to minimize flicker */ 881 /* scroll column by column to minimize flicker */
534 asm ( 882 asm (
535 "move.l %[wide],%%d4\n" /* columns = width */ 883 "move.l %[wide],%%d4\n" /* columns = width */
@@ -576,7 +924,8 @@ void gray_ub_scroll_down(int count)
576#endif 924#endif
577 } 925 }
578} 926}
927#endif /* LCD_PIXELFORMAT */
928
579#endif /* !SIMULATOR */ 929#endif /* !SIMULATOR */
580 930
581#endif /* HAVE_LCD_BITMAP */ 931#endif /* HAVE_LCD_BITMAP */
582