This repository has been archived by the owner on Aug 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
metroid_free.c
105 lines (100 loc) · 7.04 KB
/
metroid_free.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
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
//**************************************************
//* PLACE THESE VARIABLE DEFS AT BEGINNING OF FILE *
//**************************************************
#define ANIM_SIZE 352 // number of bytes in array, max is 1024 (minimize where possible)
#define IDLE_FRAMES 5 //number of total frames
//********************************************
//* Compression ratio: 1.261 to 1 *
//* Estimated PROGMEM Usage: 1396 bytes *
//********************************************
static const char PROGMEM frame[ANIM_SIZE] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0x80, 0x60, 0x60, 0x18, 0x18, 0x18, 0x18, 0x06, 0x06, 0x06, 0x06,
0x06, 0x06, 0x06, 0x06, 0x18, 0x18, 0x18, 0x18, 0x60, 0x60, 0x80, 0x80, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xF8, 0xF8, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00,
0x06, 0x06, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0xF8,
0xF8, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x78, 0x78, 0x80, 0x80, 0xE0, 0xE0, 0x18, 0x18,
0x60, 0x60, 0x80, 0x80, 0x80, 0x80, 0x60, 0x60, 0x18, 0x18, 0xE0, 0xE0, 0x80, 0x80, 0x78,
0x78, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x07, 0x07,
0x06, 0x06, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x06, 0x06, 0x07, 0x07, 0x01,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static const uint16_t PROGMEM cumsum_inds[IDLE_FRAMES+1] = {
0, 98, 196, 270, 344, 344,
};
static const uint16_t PROGMEM change_inds[344] = {
230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244,
245, 246, 247, 248, 249, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265,
266, 267, 270, 271, 274, 275, 276, 277, 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, 324, 325, 326, 327, 328, 329, 330, 331, 334, 335, 336, 337,
340, 341, 342, 343, 344, 345, 346, 347, 230, 231, 232, 233, 234, 235, 236,
237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 256, 257,
258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 270, 271, 274, 275, 276,
277, 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, 324, 325, 326, 327,
328, 329, 330, 331, 334, 335, 336, 337, 340, 341, 342, 343, 344, 345, 346,
347, 206, 207, 208, 209, 228, 229, 230, 231, 234, 235, 238, 239, 240, 241,
244, 245, 248, 249, 250, 251, 258, 259, 260, 261, 262, 263, 266, 267, 270,
271, 274, 275, 280, 281, 282, 283, 284, 285, 290, 291, 292, 293, 294, 295,
296, 297, 298, 299, 300, 301, 306, 307, 308, 309, 310, 311, 312, 313, 314,
315, 316, 317, 328, 329, 330, 331, 332, 333, 338, 339, 340, 341, 342, 343,
206, 207, 208, 209, 228, 229, 230, 231, 234, 235, 238, 239, 240, 241, 244,
245, 248, 249, 250, 251, 258, 259, 260, 261, 262, 263, 266, 267, 270, 271,
274, 275, 280, 281, 282, 283, 284, 285, 290, 291, 292, 293, 294, 295, 296,
297, 298, 299, 300, 301, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315,
316, 317, 328, 329, 330, 331, 332, 333, 338, 339, 340, 341, 342, 343,
};
static const char PROGMEM change_vals[344] = {
0x80, 0x80, 0x60, 0x60, 0x60, 0x60, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x60,
0x60, 0x60, 0x60, 0x80, 0x80, 0xF8, 0xF8, 0x06, 0x06, 0x01, 0x01, 0x01, 0x01, 0x78, 0x78,
0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x60, 0x60, 0x01, 0x01, 0x01, 0x01, 0x06, 0x06, 0xF8,
0xF8, 0x01, 0x01, 0x06, 0x06, 0xF8, 0xF8, 0x78, 0x78, 0x18, 0x18, 0x7C, 0x7E, 0x06, 0x06,
0x1E, 0x1E, 0x1E, 0x1E, 0x06, 0x06, 0x7E, 0x7C, 0x18, 0x18, 0x78, 0x78, 0xF8, 0xF8, 0x06,
0x06, 0x01, 0x01, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x60, 0x60, 0x18, 0x18, 0x18, 0x18, 0x06,
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x18, 0x18, 0x18, 0x18, 0x60, 0x60, 0x00, 0x00,
0xF8, 0xF8, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x06, 0x06, 0x60, 0x60, 0x00,
0x00, 0x00, 0x00, 0x07, 0x07, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x78, 0x78,
0x80, 0x80, 0xE0, 0xE0, 0x18, 0x18, 0x60, 0x60, 0x80, 0x80, 0x80, 0x80, 0x60, 0x60, 0x18,
0x18, 0xE0, 0xE0, 0x80, 0x80, 0x78, 0x78, 0x07, 0x07, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
0x07, 0x07, 0x06, 0x06, 0x01, 0x01, 0x01, 0x01, 0x06, 0x06, 0x07, 0x07, 0x01, 0x01, 0x00,
0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0xE0, 0xE0, 0x86, 0x86, 0x81, 0x81, 0x01, 0x01,
0x06, 0x06, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xF8, 0x07, 0x07, 0x81, 0x81, 0x01,
0x01, 0x80, 0x80, 0x07, 0x07, 0xF8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1F, 0xE0, 0xE0,
0x00, 0x00, 0x01, 0xF9, 0xF8, 0xF8, 0xF9, 0xF9, 0xF8, 0x00, 0x00, 0x00, 0xE0, 0xE0, 0x1F,
0x1F, 0x00, 0x00, 0x06, 0x06, 0x1E, 0x1F, 0x18, 0x18, 0x18, 0x18, 0x1F, 0x1E, 0x06, 0x06,
0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x60, 0x60, 0x18, 0x18, 0x06, 0x06, 0x06, 0x06, 0x18,
0x18, 0x60, 0x60, 0x80, 0x80, 0xF8, 0xF8, 0x07, 0x07, 0x00, 0x00, 0x66, 0x66, 0x06, 0x06,
0x60, 0x60, 0x00, 0x00, 0x07, 0x07, 0xF8, 0xF8, 0x07, 0x07, 0x78, 0x78, 0x80, 0x80, 0xE0,
0xE0, 0x18, 0x18, 0x60, 0x60, 0x60, 0x60, 0x18, 0x18, 0xE0, 0xE0, 0x80, 0x80, 0x78, 0x78,
0x07, 0x07, 0x07, 0x07, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x07, 0x07,
};
uint16_t index_start = 0;
uint16_t index_end = 0;
static void change_frame_bytewise(uint8_t frame_number){
// for n changes this frame, change those bytes by change_inds and change_vals
index_start = pgm_read_word(cumsum_inds + (frame_number-1));
index_end = pgm_read_word(cumsum_inds + (frame_number));
if (index_start != index_end){ // if a change in buffer
for (uint16_t i=index_start; i < index_end; i++){
oled_write_raw_byte(pgm_read_byte(change_vals + i), pgm_read_word(change_inds + i));
}
}
}