This source file includes following definitions.
- startup
- screen_opened
- screen_rotated
- get_effective_focal_length
- get_focal_length
- get_zoom_x
- get_vbatt_min
- get_vbatt_max
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 int screen_opened(void) {
30
31 return !(physw_status[1] & 0x01000000);
32 }
33
34 int screen_rotated(void) {
35
36 return !(physw_status[1] & 0x00080000);
37 }
38
39 static const struct {
40 int zp, fl;
41 } fl_tbl[] = {
42 { 0, 5000 },
43 { 11, 6190 },
44 { 41, 12610 },
45 { 64, 25240 },
46 { 86, 45470 },
47 { 105, 65880 },
48 { 128, 100000 },
49 };
50 #define NUM_FL (int)(sizeof(fl_tbl)/sizeof(fl_tbl[0]))
51 #define CF_EFL 5600
52
53 const int zoom_points = 129;
54
55 int get_effective_focal_length(int zp) {
56 return (CF_EFL*get_focal_length(zp))/1000;
57 }
58
59 int get_focal_length(int zp) {
60 int i;
61
62 if (zp<fl_tbl[0].zp)
63 return fl_tbl[0].fl;
64 else if (zp>fl_tbl[NUM_FL-1].zp)
65 return fl_tbl[NUM_FL-1].fl;
66 else
67 for (i=1; i<NUM_FL; ++i) {
68 if (zp==fl_tbl[i-1].zp)
69 return fl_tbl[i-1].fl;
70 else if (zp==fl_tbl[i].zp)
71 return fl_tbl[i].fl;
72 else if (zp<fl_tbl[i].zp)
73 return fl_tbl[i-1].fl+(zp-fl_tbl[i-1].zp)*(fl_tbl[i].fl-fl_tbl[i-1].fl)/(fl_tbl[i].zp-fl_tbl[i-1].zp);
74 }
75 return fl_tbl[NUM_FL-1].fl;
76 }
77
78 int get_zoom_x(int zp) {
79 return get_focal_length(zp)*10/fl_tbl[0].fl;
80 }
81
82 long get_vbatt_min()
83 {
84 return 4550;
85 }
86
87 long get_vbatt_max()
88 {
89 return 5150;
90 }
91