-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscroll.c
70 lines (53 loc) · 1.86 KB
/
scroll.c
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
/*****************************************
NAAGTRO version 2
scroll.c Scrolling text effect
(C) March 5, 2023 M. Feliks
*****************************************/
#include <string.h>
#include "scroll.h"
#include "fontnew.h"
static char scrolltext[] = "Hi!!!!! I combined my old graphical effects into one package. Finally! These are only the effects implemented in C. The effects implemented in Assembler are a different story... To switch to the next effect, press any key. They don't switch automatically. Once you reach the last effect, this demo will end. Enjoy! ";
static unsigned char scrollbuffer[320 * 8];
static unsigned int curr_char = 0, curr_col = 0;
void init_scroll()
{
memset(scrollbuffer, 0, 320 * 8);
}
void do_scroll(int y, unsigned char* frame_buffer)
{
char my_char;
unsigned char *ptr_char, *ptr_buffer, *ptr_fb;
int col_idx;
int i, j;
my_char = scrolltext[curr_char % ( (sizeof (scrolltext) / sizeof (char)) - 1)];
if (my_char >= 'a' && my_char <= 'z') {
my_char += ('A' - 'a');
}
ptr_char = &chardata[((my_char - ' ') & 63) << 3];
col_idx = 7 - (curr_col & 7);
for (i = 0; i < 8; i++, ptr_char++) {
if ((*ptr_char >> col_idx) & 1) {
*(scrollbuffer + i * 320 + 319) = (unsigned char)(64 + i);
}
else {
*(scrollbuffer + i * 320 + 319) = 0;
}
}
for (i = 0; i < 8; i++) {
ptr_buffer = scrollbuffer + 320 * i;
for (j = 0; j < 319; j++, ptr_buffer++) {
*ptr_buffer = *(ptr_buffer + 1);
}
}
ptr_buffer = scrollbuffer;
ptr_fb = frame_buffer + y * 320;
for (i = 0; i < 320 * 8; i++, ptr_buffer++, ptr_fb++) {
if (*ptr_buffer != 0) {
*ptr_fb = *ptr_buffer;
}
}
curr_col++;
if (curr_col % 8 == 0) {
curr_char++;
}
}