This source file includes following definitions.
- hook_raw_image_addr
- hook_alt_raw_image_addr
- camera_jpeg_count_str
- get_flash_params_count
- vid_bitmap_refresh
- shutdown
- debug_led
- camera_set_led
- vid_get_viewport_yscale
- vid_get_viewport_fb
- vid_get_viewport_live_fb
- vid_get_viewport_fb_d
- vid_get_bitmap_fb
- vid_get_viewport_width
- vid_get_viewport_height
- vid_get_viewport_display_xoffset
- vid_get_viewport_display_xoffset_proper
- vid_get_viewport_height_proper
- vid_get_viewport_buffer_width_proper
- vid_get_viewport_fullscreen_height
- vid_get_palette_type
- vid_get_palette_size
- vid_get_aspect_ratio
- vid_get_bitmap_active_buffer
- vid_get_bitmap_active_palette
- load_chdk_palette
1 #include "platform.h"
2 #include "platform_palette.h"
3 #include "lolevel.h"
4
5 extern int active_raw_buffer;
6 extern char* raw_buffers[];
7
8 char *hook_raw_image_addr()
9 {
10 return raw_buffers[active_raw_buffer];
11 }
12
13 char *hook_alt_raw_image_addr()
14 {
15 return raw_buffers[(active_raw_buffer^1)];
16 }
17
18
19 char *camera_jpeg_count_str()
20 {
21 extern char jpeg_count_str[];
22 return jpeg_count_str;
23 }
24
25 int get_flash_params_count(void)
26 {
27 return 0xa6;
28 }
29
30 void vid_bitmap_refresh()
31 {
32 extern int full_screen_refresh;
33 extern void _ScreenUnlock();
34 extern void _ScreenLock();
35
36 full_screen_refresh |= 3;
37 _ScreenLock();
38 _ScreenUnlock();
39 }
40
41
42 void shutdown()
43 {
44 volatile long *p = (void*)0xC022001C;
45
46 asm(
47 "MRS R1, CPSR\n"
48 "AND R0, R1, #0x80\n"
49 "ORR R1, R1, #0x80\n"
50 "MSR CPSR_cf, R1\n"
51 :::"r1","r0");
52
53 *p = 0x44;
54
55 while(1);
56 }
57
58
59
60 void debug_led(__attribute__ ((unused))int state) {
61
62
63
64
65
66 }
67
68
69
70
71
72 void camera_set_led(int led, int state, __attribute__ ((unused))int bright) {
73 static char led_table[2]={0,4};
74 if(state<=1) _LEDDrive(led_table[led%sizeof(led_table)], (!state)&1);
75 }
76
77
78
79
80
81
82 extern char active_viewport_buffer;
83 extern void* viewport_buffers[];
84
85
86
87 int vid_get_viewport_yscale() {
88 if (camera_info.state.mode_play) {
89 return 2;
90 }
91 if (is_video_recording()) {
92
93 if(shooting_get_prop(PROPCASE_VIDEO_RESOLUTION) == 5) {
94 return 1;
95 }
96 return 2;
97 }
98 if (camera_info.state.mode_shooting == MODE_FISHEYE) {
99 return 1;
100 }
101 return 2;
102 }
103
104 void *vid_get_viewport_fb()
105 {
106
107 return viewport_buffers[0];
108 }
109
110 void *vid_get_viewport_live_fb()
111 {
112
113 if (camera_info.state.mode_video || is_video_recording())
114 return viewport_buffers[(active_viewport_buffer-1)&3];
115
116
117
118 return viewport_buffers[(active_viewport_buffer-1)&7];
119 }
120
121 void *vid_get_viewport_fb_d()
122 {
123 extern char *viewport_fb_d;
124 return viewport_fb_d;
125 }
126
127
128 extern int active_bitmap_buffer;
129 extern char* bitmap_buffer[];
130
131 void *vid_get_bitmap_fb()
132 {
133
134 return bitmap_buffer[0];
135 }
136
137 int vid_get_viewport_width()
138 {
139 if (camera_info.state.mode_play)
140 {
141 return 480;
142 }
143 extern int _GetVRAMHPixelsSize();
144 return _GetVRAMHPixelsSize() >> 1;
145 }
146
147
148 long vid_get_viewport_height()
149 {
150 if(camera_info.state.mode_play) {
151 return 240;
152 }
153 extern int _GetVRAMVPixelsSize();
154
155 int h = _GetVRAMVPixelsSize();
156 if (vid_get_viewport_yscale() == 1) {
157 return h;
158 }
159
160 return h>>1;
161 }
162
163 int vid_get_viewport_display_xoffset()
164 {
165 if (camera_info.state.mode_play)
166 {
167 return 0;
168 }
169 else
170 {
171
172
173 static long vp_w[5] = { 60, 0, 36, 104 };
174 return vp_w[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
175 }
176 }
177
178
179
180 int vid_get_viewport_display_xoffset_proper() { return vid_get_viewport_display_xoffset() * 2; }
181 int vid_get_viewport_height_proper() { return vid_get_viewport_height()*vid_get_viewport_yscale(); }
182 int vid_get_viewport_buffer_width_proper() { return 960; }
183 int vid_get_viewport_fullscreen_height() { return 240*vid_get_viewport_yscale(); }
184
185 int vid_get_palette_type() { return 3; }
186 int vid_get_palette_size() { return 256 * 4; }
187 int vid_get_aspect_ratio() { return 1; }
188
189 void *vid_get_bitmap_active_buffer()
190 {
191 return bitmap_buffer[active_bitmap_buffer];
192 }
193
194 void *vid_get_bitmap_active_palette()
195 {
196 extern int active_palette_buffer;
197 extern char* palette_buffer[];
198 unsigned char color_option;
199
200
201 get_parameter_data(0x1a,&color_option,1);
202 char *p = palette_buffer[active_palette_buffer + color_option];
203
204 if(p) {
205 p+=4;
206 }
207 return p;
208 }
209
210 #ifdef CAM_LOAD_CUSTOM_COLORS
211
212 void load_chdk_palette()
213 {
214 extern int active_palette_buffer;
215
216
217
218 if ((active_palette_buffer == 0) || (active_palette_buffer == 16))
219 {
220 int *pal = (int*)vid_get_bitmap_active_palette();
221 if(pal) {
222 if (pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
223 {
224 pal[CHDK_COLOR_BASE+0] = 0x33ADF62;
225 pal[CHDK_COLOR_BASE+1] = 0x326EA40;
226 pal[CHDK_COLOR_BASE+2] = 0x34CD57F;
227 pal[CHDK_COLOR_BASE+3] = 0x373BFAE;
228 pal[CHDK_COLOR_BASE+4] = 0x34BD6CA;
229 pal[CHDK_COLOR_BASE+5] = 0x395AB95;
230 pal[CHDK_COLOR_BASE+6] = 0x34766F0;
231 pal[CHDK_COLOR_BASE+7] = 0x31250F3;
232 pal[CHDK_COLOR_BASE+8] = 0x37F408F;
233 pal[CHDK_COLOR_BASE+9] = 0x3512D5B;
234 pal[CHDK_COLOR_BASE+10] = 0x3A9A917;
235 pal[CHDK_COLOR_BASE+11] = 0x3819137;
236 pal[CHDK_COLOR_BASE+12] = 0x3DED115;
237
238 vid_bitmap_refresh();
239 }
240 }
241 }
242 }
243 #endif