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