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
7 extern long link_bss_start;
8 extern long link_bss_end;
9 extern void boot();
10
11
12 void startup()
13 {
14 long *bss = &link_bss_start;
15
16
17 if ((long)&link_bss_end > (MEMISOSTART + MEMISOSIZE)){
18 started();
19 shutdown();
20 }
21
22
23 while (bss<&link_bss_end)
24 *bss++ = 0;
25
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 330
78 #define CF_EFL_DIV 59
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
113
114 long get_vbatt_min()
115 {
116 return 3375;
117 }
118
119
120 long get_vbatt_max()
121 {
122 return 4125;
123 }
124
125 #if CAM_CONSOLE_LOG_ENABLED
126
127 #define DEV_HDR_WRITE_OFFSET (0x14C/4)
128
129 typedef int DEV_HDR;
130
131 int (*_tyWriteOrig)(DEV_HDR *hdr, char *buf, int len);
132
133
134 int hook_tyWriteOrig(DEV_HDR *hdr, char *buf, int len)
135 {
136
137 FILE *fd = fopen("A/stdout.txt", "a");
138 if (fd) {
139 fwrite(buf, 1, len, fd);
140 fclose(fd);
141 }
142
143 return _tyWriteOrig(hdr, buf, len);
144
145 }
146
147 void cam_console_init()
148 {
149 DEV_HDR *DRV_struct;
150
151 DRV_struct = _iosDevFind("/tyCo/0", 0);
152
153 _tyWriteOrig = (void*)DRV_struct[DEV_HDR_WRITE_OFFSET];
154
155 FILE *fd = fopen("A/chdklog.txt", "a");
156 if (fd) {
157
158
159 char buf[256];
160 int buflen = sprintf(buf, "DRV_struct: %x, _tyWriteOrig: %x\n", DRV_struct, _tyWriteOrig);
161 fwrite(buf, 1, buflen, fd);
162 }
163
164 FILE *fdout = fopen("A/stdout.txt", "r");
165 if (fdout)
166 {
167 DRV_struct[DEV_HDR_WRITE_OFFSET] = (int)hook_tyWriteOrig;
168 fclose(fdout);
169
170 fwrite("tyWrite replaced, camera log enabled\n", 1, sizeof("tyWrite replaced, camera log enabled\n"), fd);
171 }
172
173 if (fd)
174 {
175 fclose(fd);
176 }
177
178 }
179
180 #endif