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