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