This source file includes following definitions.
- hook_raw_image_addr
- hook_alt_raw_image_addr
- 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_width
- vid_get_viewport_height
- vid_get_bitmap_fb
- 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 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 void vid_bitmap_refresh() {
19 extern int full_screen_refresh;
20 extern void _ScreenUnlock();
21 extern void _ScreenLock();
22
23 _ScreenLock();
24 full_screen_refresh |= 3;
25 _ScreenUnlock();
26 }
27
28 #define GREEN_LED 0xC0220130
29 #define AF_LED 0xC0223030
30
31 void shutdown() {
32 volatile long *p = (void*)GREEN_LED;
33
34 asm(
35 "MRS R1, CPSR\n"
36 "AND R0, R1, #0x80\n"
37 "ORR R1, R1, #0x80\n"
38 "MSR CPSR_cf, R1\n"
39 :::"r1","r0"
40 );
41
42 *p = 0x44;
43
44 while(1);
45 }
46
47
48 void debug_led(int state) {
49
50
51
52 *(int*)GREEN_LED=state ? 0x46 : 0x44;
53 }
54
55
56
57
58 void camera_set_led(int led, int state, __attribute__ ((unused))int bright) {
59 static char led_table[2]={0,4};
60 if(state<=1) _LEDDrive(led_table[led%sizeof(led_table)], (!state)&1);
61 }
62
63 int get_flash_params_count(void) {
64 return 0xA6;
65 }
66
67
68
69
70
71 extern char active_viewport_buffer;
72 extern void* viewport_buffers[];
73
74 void *vid_get_viewport_fb()
75 {
76
77 return viewport_buffers[0];
78 }
79
80
81 void *vid_get_viewport_live_fb()
82 {
83 if (MODE_IS_VIDEO(mode_get()))
84 return viewport_buffers[0];
85
86
87 return viewport_buffers[(active_viewport_buffer-1)&3];
88 }
89
90
91 int vid_get_viewport_width() {
92 if ((mode_get() & MODE_MASK) == MODE_PLAY) {
93 return 360;
94 }
95 extern int _GetVRAMHPixelsSize();
96 return _GetVRAMHPixelsSize() >> 1;
97 }
98
99
100 long vid_get_viewport_height() {
101 if ((mode_get() & MODE_MASK) == MODE_PLAY) {
102 return 240;
103 }
104 extern int _GetVRAMVPixelsSize();
105 return _GetVRAMVPixelsSize() >> 1;
106 }
107
108 extern int active_bitmap_buffer;
109 extern char* bitmap_buffer[];
110
111 void *vid_get_bitmap_fb() {
112
113 return bitmap_buffer[0];
114 }
115
116
117 int vid_get_viewport_display_xoffset_proper() { return vid_get_viewport_display_xoffset() * 2; }
118 int vid_get_viewport_display_yoffset_proper() { return vid_get_viewport_display_yoffset() * 2; }
119 int vid_get_viewport_height_proper() { return vid_get_viewport_height() * 2; }
120 int vid_get_viewport_fullscreen_height() { return 480; }
121 int vid_get_palette_type() { return 3; }
122 int vid_get_palette_size() { return 256 * 4; }
123
124 void *vid_get_bitmap_active_buffer() {
125 return bitmap_buffer[active_bitmap_buffer];
126 }
127
128 void *vid_get_bitmap_active_palette() {
129 extern int active_palette_buffer;
130 extern char* palette_buffer[];
131 void* p = palette_buffer[active_palette_buffer];
132
133 if (p) p += 4;
134 return p;
135 }
136
137 #ifdef CAM_LOAD_CUSTOM_COLORS
138
139 void load_chdk_palette()
140 {
141 extern int active_palette_buffer;
142
143
144 if ((active_palette_buffer == 0) || (active_palette_buffer == 5))
145 {
146 int *pal = (int*)vid_get_bitmap_active_palette();
147 if (pal && pal[CHDK_COLOR_BASE+0] != 0x33ADF62)
148 {
149 pal[CHDK_COLOR_BASE+0] = 0x33ADF62;
150 pal[CHDK_COLOR_BASE+1] = 0x326EA40;
151 pal[CHDK_COLOR_BASE+2] = 0x34CD57F;
152 pal[CHDK_COLOR_BASE+3] = 0x373BFAE;
153 pal[CHDK_COLOR_BASE+4] = 0x34BD6CA;
154 pal[CHDK_COLOR_BASE+5] = 0x395AB95;
155 pal[CHDK_COLOR_BASE+6] = 0x34766F0;
156 pal[CHDK_COLOR_BASE+7] = 0x31250F3;
157 pal[CHDK_COLOR_BASE+8] = 0x37F408F;
158 pal[CHDK_COLOR_BASE+9] = 0x3512D5B;
159 pal[CHDK_COLOR_BASE+10] = 0x3A9A917;
160 pal[CHDK_COLOR_BASE+11] = 0x3819137;
161 pal[CHDK_COLOR_BASE+12] = 0x3DED115;
162
163 extern char palette_control;
164 palette_control = 1;
165 vid_bitmap_refresh();
166 }
167 }
168 }
169 #endif