diff options
Diffstat (limited to 'apps/plugins/mandelbrot.c')
-rw-r--r-- | apps/plugins/mandelbrot.c | 37 |
1 files changed, 3 insertions, 34 deletions
diff --git a/apps/plugins/mandelbrot.c b/apps/plugins/mandelbrot.c index 11c51bb556..2f5bc53ab0 100644 --- a/apps/plugins/mandelbrot.c +++ b/apps/plugins/mandelbrot.c | |||
@@ -66,8 +66,6 @@ static unsigned int gbuf_size = 0; | |||
66 | * you're doing. | 66 | * you're doing. |
67 | */ | 67 | */ |
68 | 68 | ||
69 | #define IMIA4 (*((volatile unsigned long*)0x09000180)) /* timer 4 */ | ||
70 | |||
71 | #define GRAY_RUNNING 0x0001 /* grayscale overlay is running */ | 69 | #define GRAY_RUNNING 0x0001 /* grayscale overlay is running */ |
72 | #define GRAY_DEFERRED_UPDATE 0x0002 /* lcd_update() requested */ | 70 | #define GRAY_DEFERRED_UPDATE 0x0002 /* lcd_update() requested */ |
73 | 71 | ||
@@ -91,44 +89,15 @@ static tGraybuf *graybuf = NULL; | |||
91 | 89 | ||
92 | /** prototypes **/ | 90 | /** prototypes **/ |
93 | 91 | ||
94 | void timer_set(unsigned period); | 92 | void timer4_isr(void); |
95 | void timer4_isr(void) __attribute__((interrupt_handler)); | ||
96 | void graypixel(int x, int y, unsigned long pattern); | 93 | void graypixel(int x, int y, unsigned long pattern); |
97 | void grayinvertmasked(int x, int yb, unsigned char mask); | 94 | void grayinvertmasked(int x, int yb, unsigned char mask); |
98 | 95 | ||
99 | /** implementation **/ | 96 | /** implementation **/ |
100 | 97 | ||
101 | /* setup ISR and timer registers */ | ||
102 | void timer_set(unsigned period) | ||
103 | { | ||
104 | if (period) | ||
105 | { | ||
106 | and_b(~0x10, &TSTR); /* Stop the timer 4 */ | ||
107 | and_b(~0x10, &TSNC); /* No synchronization */ | ||
108 | and_b(~0x10, &TMDR); /* Operate normally */ | ||
109 | |||
110 | IMIA4 = (unsigned long) timer4_isr; /* install ISR */ | ||
111 | |||
112 | and_b(~0x01, &TSR4); | ||
113 | TIER4 = 0xF9; /* Enable GRA match interrupt */ | ||
114 | |||
115 | GRA4 = (unsigned short)(period/4 - 1); | ||
116 | TCR4 = 0x22; /* clear at GRA match, sysclock/4 */ | ||
117 | IPRD = (IPRD & 0xFF0F) | 0x0010; /* interrupt priority 1 (lowest) */ | ||
118 | or_b(0x10, &TSTR); /* start timer 4 */ | ||
119 | } | ||
120 | else | ||
121 | { | ||
122 | and_b(~0x10, &TSTR); /* stop the timer 4 */ | ||
123 | IPRD = (IPRD & 0xFF0F); /* disable interrupt */ | ||
124 | } | ||
125 | } | ||
126 | |||
127 | /* timer interrupt handler: display next bitplane */ | 98 | /* timer interrupt handler: display next bitplane */ |
128 | void timer4_isr(void) /* IMIA4 */ | 99 | void timer4_isr(void) /* IMIA4 */ |
129 | { | 100 | { |
130 | and_b(~0x01, &TSR4); /* clear the interrupt */ | ||
131 | |||
132 | rb->lcd_blit(graybuf->data + (graybuf->plane_size * graybuf->cur_plane), | 101 | rb->lcd_blit(graybuf->data + (graybuf->plane_size * graybuf->cur_plane), |
133 | graybuf->x, graybuf->by, graybuf->width, graybuf->bheight, | 102 | graybuf->x, graybuf->by, graybuf->width, graybuf->bheight, |
134 | graybuf->width); | 103 | graybuf->width); |
@@ -505,11 +474,11 @@ void gray_show_display(bool enable) | |||
505 | if (enable) | 474 | if (enable) |
506 | { | 475 | { |
507 | graybuf->flags |= GRAY_RUNNING; | 476 | graybuf->flags |= GRAY_RUNNING; |
508 | timer_set(FREQ / 67); | 477 | rb->plugin_register_timer(FREQ / 67, 1, timer4_isr); |
509 | } | 478 | } |
510 | else | 479 | else |
511 | { | 480 | { |
512 | timer_set(0); | 481 | rb->plugin_unregister_timer(); |
513 | graybuf->flags &= ~GRAY_RUNNING; | 482 | graybuf->flags &= ~GRAY_RUNNING; |
514 | rb->lcd_update(); /* restore whatever there was before */ | 483 | rb->lcd_update(); /* restore whatever there was before */ |
515 | } | 484 | } |