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
- vid_get_viewport_fb
- vid_get_viewport_live_fb
- vid_get_viewport_fb_d
- vid_get_bitmap_fb
- vid_get_viewport_byte_width
- vid_get_viewport_yscale
- vid_get_viewport_width
- vid_get_viewport_display_xoffset
- vid_get_viewport_height
- 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
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 0xC0220110
56
57 void debug_led(int state)
58 {
59 *(int*)LED_PR=state ? 0x46 : 0x44;
60 }
61
62
63
64
65 void camera_set_led(int led, int state, __attribute__ ((unused))int bright) {
66 static char led_table[2]={7,11};
67 _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state);
68 }
69
70 int get_flash_params_count(void){
71 return 0xA0;
72 }
73
74
75
76
77
78 extern char active_viewport_buffer;
79 extern void* viewport_buffers[];
80
81 void *vid_get_viewport_fb()
82 {
83
84 return viewport_buffers[0];
85 }
86
87 void *vid_get_viewport_live_fb()
88 {
89 int b = (active_viewport_buffer-1)&3;
90 if ((b == 3) && (camera_info.state.mode_video || ((camera_info.state.mode & MODE_SHOOTING_MASK) == MODE_VIDEO_MOVIE_DIGEST) || (get_movie_status()==VIDEO_RECORD_IN_PROGRESS)))
91 b = 2;
92
93
94 return viewport_buffers[b];
95 }
96
97 void *vid_get_viewport_fb_d()
98 {
99 extern char *viewport_fb_d;
100 return viewport_fb_d;
101 }
102
103
104 extern int active_bitmap_buffer;
105 extern char* bitmap_buffer[];
106
107 void *vid_get_bitmap_fb()
108 {
109
110 return bitmap_buffer[0];
111 }
112
113
114 int vid_get_viewport_byte_width() {
115 return 960 * 6 / 4;
116 }
117
118
119 int vid_get_viewport_yscale() {
120 return 2;
121 }
122
123 int vid_get_viewport_width()
124 {
125 if (camera_info.state.mode_play)
126 {
127 return 480;
128 }
129 extern int _GetVRAMHPixelsSize();
130 return _GetVRAMHPixelsSize() >> 1;
131 }
132
133 int vid_get_viewport_display_xoffset()
134 {
135 if (camera_info.state.mode_play)
136 {
137 return 0;
138 }
139 else
140 {
141
142
143 static long vp_w[5] = { 60, 0, 36, 104 };
144 return vp_w[shooting_get_prop(PROPCASE_ASPECT_RATIO)];
145 }
146 }
147
148 long vid_get_viewport_height(){ return 240; }
149
150
151
152 int vid_get_viewport_display_xoffset_proper() { return vid_get_viewport_display_xoffset() * 2; }
153 int vid_get_viewport_height_proper() { return 480; }
154 int vid_get_viewport_buffer_width_proper() { return 960; }
155 int vid_get_viewport_fullscreen_height() { return 480; }
156 int vid_get_palette_type() { return 3; }
157 int vid_get_palette_size() { return 256 * 4; }
158 int vid_get_aspect_ratio() { return 1; }
159
160 void *vid_get_bitmap_active_buffer()
161 {
162 return bitmap_buffer[active_bitmap_buffer];
163 }
164
165 void *vid_get_bitmap_active_palette()
166 {
167 extern int active_palette_buffer;
168 extern char* palette_buffer[];
169
170 int color_option = 0;
171 get_parameter_data(0x1a, &color_option, 1);
172 void* p = palette_buffer[active_palette_buffer+color_option];
173
174 if (p) p += 8;
175 return p;
176 }
177
178
179 void load_chdk_palette()
180 {
181 extern int active_palette_buffer;
182
183 if ((active_palette_buffer == 0) || (active_palette_buffer == 16))
184 {
185 int *pal = (int*)vid_get_bitmap_active_palette();
186 if (pal && (pal[CHDK_COLOR_BASE+0] != 0x33ADF62))
187 {
188 pal[CHDK_COLOR_BASE+0] = 0x33ADF62;
189 pal[CHDK_COLOR_BASE+1] = 0x326EA40;
190 pal[CHDK_COLOR_BASE+2] = 0x34CD57F;
191 pal[CHDK_COLOR_BASE+3] = 0x373BFAE;
192 pal[CHDK_COLOR_BASE+4] = 0x34BD6CA;
193 pal[CHDK_COLOR_BASE+5] = 0x395AB95;
194 pal[CHDK_COLOR_BASE+6] = 0x34766F0;
195 pal[CHDK_COLOR_BASE+7] = 0x31250F3;
196 pal[CHDK_COLOR_BASE+8] = 0x37F408F;
197 pal[CHDK_COLOR_BASE+9] = 0x3512D5B;
198 pal[CHDK_COLOR_BASE+10] = 0x3A9A917;
199 pal[CHDK_COLOR_BASE+11] = 0x3819137;
200 pal[CHDK_COLOR_BASE+12] = 0x3DED115;
201 pal[CHDK_COLOR_BASE+13] = 0x0090000;
202
203 extern char palette_control;
204 palette_control = 1;
205 vid_bitmap_refresh();
206 }
207 }
208 }