This source file includes following definitions.
- startup
- get_effective_focal_length
- get_focal_length
- get_zoom_x
- get_vbatt_min
- get_vbatt_max
- hook_tyWriteOrig
- cam_console_init
1 #include "lolevel.h"
2 #include "platform.h"
3 #include "core.h"
4 #include "keyboard.h"
5
6 #include "sd1200_debug.h"
7
8 extern long link_bss_start;
9 extern long link_bss_end;
10 extern void boot();
11
12
13 void startup()
14 {
15 long *bss = &link_bss_start;
16
17
18 if ((long)&link_bss_end > (MEMISOSTART + MEMISOSIZE)){
19 started();
20 shutdown();
21 }
22
23
24 while (bss<&link_bss_end)
25 *bss++ = 0;
26 boot();
27 }
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 #define NUM_FL 7
69 #define NUM_DATA 3
70 extern int focus_len_table[NUM_FL*NUM_DATA];
71
72
73
74
75
76
77 #define CF_EFL 350
78 #define CF_EFL_DIV 62
79
80 const int zoom_points = NUM_FL;
81
82 int get_effective_focal_length(int zp) {
83 return (CF_EFL*get_focal_length(zp))/CF_EFL_DIV;
84 }
85
86 int get_focal_length(int zp) {
87 if (zp < 0) zp = 0;
88 else if (zp >= NUM_FL) zp = NUM_FL-1;
89 return focus_len_table[zp*NUM_DATA];
90 }
91
92 int get_zoom_x(int zp) {
93 return get_focal_length(zp)*10/focus_len_table[0];
94 }
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112 long get_vbatt_min()
113 {
114 return 3425;
115 }
116
117 long get_vbatt_max()
118 {
119 return 4000;
120 }
121
122 #if CAM_CONSOLE_LOG_ENABLED
123
124 #define DEV_HDR_WRITE_OFFSET (0x14C/4)
125
126 typedef int DEV_HDR;
127
128 int (*_tyWriteOrig)(DEV_HDR *hdr, char *buf, int len);
129
130
131 int hook_tyWriteOrig(DEV_HDR *hdr, char *buf, int len)
132 {
133
134 FILE *fd = fopen("A/stdout.txt", "a");
135 if (fd) {
136 fwrite(buf, 1, len, fd);
137 fclose(fd);
138 }
139
140 return _tyWriteOrig(hdr, buf, len);
141
142 }
143
144 void cam_console_init()
145 {
146 DEV_HDR *DRV_struct;
147
148 DRV_struct = _iosDevFind("/tyCo/0", 0);
149
150 _tyWriteOrig = (void*)DRV_struct[DEV_HDR_WRITE_OFFSET];
151
152 FILE *fd = fopen("A/chdklog.txt", "a");
153 if (fd) {
154
155
156 char buf[256];
157 int buflen = sprintf(buf, "DRV_struct: %x, _tyWriteOrig: %x\n", DRV_struct, _tyWriteOrig);
158 fwrite(buf, 1, buflen, fd);
159 }
160
161 FILE *fdout = fopen("A/stdout.txt", "r");
162 if (fdout)
163 {
164 DRV_struct[DEV_HDR_WRITE_OFFSET] = (int)hook_tyWriteOrig;
165 fclose(fdout);
166
167 fwrite("tyWrite replaced, camera log enabled\n", 1, sizeof("tyWrite replaced, camera log enabled\n"), fd);
168 }
169
170 if (fd)
171 {
172 fclose(fd);
173 }
174
175 }
176
177 #endif