| 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 | long *ptr; |
|---|
| 16 | |
|---|
| 17 | // sanity check (pointless with automemiso) |
|---|
| 18 | if ((long)&link_bss_end > (MEMISOSTART + MEMISOSIZE)){ |
|---|
| 19 | started(); |
|---|
| 20 | shutdown(); |
|---|
| 21 | } |
|---|
| 22 | |
|---|
| 23 | // initialize .bss senment |
|---|
| 24 | while (bss<&link_bss_end) |
|---|
| 25 | *bss++ = 0; |
|---|
| 26 | |
|---|
| 27 | boot(); |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | // TODO setting the DP button as a shortcut to movie in canon menu |
|---|
| 32 | // gives a value of (current mode)+1024 while movie is recording, unless |
|---|
| 33 | // already in movie mode |
|---|
| 34 | static struct { |
|---|
| 35 | int hackmode; |
|---|
| 36 | int canonmode; |
|---|
| 37 | } modemap[] = { |
|---|
| 38 | { MODE_AUTO, 32768 }, |
|---|
| 39 | { MODE_M, 32769 }, |
|---|
| 40 | { MODE_P, 32772 }, |
|---|
| 41 | { MODE_PORTRAIT, 0x800D }, |
|---|
| 42 | { MODE_NIGHT_SNAPSHOT, 0x800B }, |
|---|
| 43 | { MODE_SCN_KIDS_PETS, 0x8010 }, |
|---|
| 44 | { MODE_SCN_INDOOR, 0x8011 }, |
|---|
| 45 | { MODE_SCN_SUNSET, 0x4012 }, |
|---|
| 46 | { MODE_SCN_FOLIAGE, 0x4013 }, |
|---|
| 47 | { MODE_SCN_SNOW, 0x4014 }, |
|---|
| 48 | { MODE_SCN_BEACH, 0x4015 }, |
|---|
| 49 | { MODE_SCN_FIREWORK, 0x4016 }, |
|---|
| 50 | { MODE_SCN_NIGHT_SCENE, 0x4006 }, //AKA Long Shutter --- unclear, 13-Mar-2010/fe50 |
|---|
| 51 | { MODE_SCN_UNDERWATER, 0x4017 }, |
|---|
| 52 | { MODE_SCN_AQUARIUM, 0x4018 }, |
|---|
| 53 | { MODE_SCN_ISO_3200, 0x401D }, |
|---|
| 54 | { MODE_DIGITAL_MACRO, 0x4208 }, |
|---|
| 55 | { MODE_SCN_COLOR_ACCENT, 0x421B }, |
|---|
| 56 | { MODE_SCN_COLOR_SWAP, 0x421C }, |
|---|
| 57 | { MODE_STITCH, 0x420A }, |
|---|
| 58 | // { MODE_QUICK, 33312 }, |
|---|
| 59 | |
|---|
| 60 | { MODE_VIDEO_STD, 0xA29 }, |
|---|
| 61 | { MODE_VIDEO_COLOR_ACCENT, 0xA27 }, |
|---|
| 62 | { MODE_VIDEO_COLOR_SWAP, 0xA28 }, |
|---|
| 63 | }; |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | #define MODESCNT (sizeof(modemap)/sizeof(modemap[0])) |
|---|
| 67 | |
|---|
| 68 | //SD780 is [f/3.2 is 6mm] [f/3.5 7mm] [f/4.5 11mm] [f/5 15mm] [f/5.8 18mm] |
|---|
| 69 | //SD780 is 5.9-17.9mm f/3.2-5.8 (35mm film equivalent: 33-100mm) |
|---|
| 70 | //SD780 is CF_EFL = (33/6)*10000=55000 or (100/18)*10000=55555. |
|---|
| 71 | static const int fl_tbl[] = {6000, 7000, 11000, 15000, 18000}; |
|---|
| 72 | #define NUM_FL (sizeof(fl_tbl)/sizeof(fl_tbl[0])) |
|---|
| 73 | #define CF_EFL 55278 // split the difference |
|---|
| 74 | |
|---|
| 75 | const int zoom_points = NUM_FL; |
|---|
| 76 | |
|---|
| 77 | int get_effective_focal_length(int zp) { |
|---|
| 78 | return (CF_EFL*get_focal_length(zp))/10000; |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | int get_focal_length(int zp) { |
|---|
| 82 | if (zp<0) return fl_tbl[0]; |
|---|
| 83 | else if (zp>NUM_FL-1) return fl_tbl[NUM_FL-1]; |
|---|
| 84 | else return fl_tbl[zp]; |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | int get_zoom_x(int zp) { |
|---|
| 88 | if (zp<1) return 10; |
|---|
| 89 | else if (zp>NUM_FL-1) return fl_tbl[NUM_FL-1]*10/fl_tbl[0]; |
|---|
| 90 | else return fl_tbl[zp]*10/fl_tbl[0]; |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | /* |
|---|
| 94 | physw_ bit OK |
|---|
| 95 | */ |
|---|
| 96 | //VERIFY_SD780 this was mode_get() previously |
|---|
| 97 | int mode_get2() { |
|---|
| 98 | int mode, i, t=0xFF; |
|---|
| 99 | mode = (physw_status[1] & 0x00000001)?MODE_REC:MODE_PLAY; |
|---|
| 100 | |
|---|
| 101 | _GetPropertyCase(PROPCASE_SHOOTING_MODE, &t, 4); |
|---|
| 102 | //draw_txt_string(20, 11, osd_buf, conf.osd_color); |
|---|
| 103 | for (i=0; i<MODESCNT; ++i) { |
|---|
| 104 | if (modemap[i].canonmode == t) { |
|---|
| 105 | return (mode | (modemap[i].hackmode & MODE_SHOOTING_MASK)); |
|---|
| 106 | } |
|---|
| 107 | } |
|---|
| 108 | return (mode); |
|---|
| 109 | } |
|---|
| 110 | |
|---|
| 111 | //VERIFY_SD780 min observed |
|---|
| 112 | long get_vbatt_min() |
|---|
| 113 | { |
|---|
| 114 | return 3375; // hnikesch on forum |
|---|
| 115 | } |
|---|
| 116 | |
|---|
| 117 | //VERIFY_SD780 max observed |
|---|
| 118 | long get_vbatt_max() |
|---|
| 119 | { |
|---|
| 120 | return 4125; // fresh off charger slightly greater |
|---|
| 121 | } |
|---|
| 122 | |
|---|
| 123 | #if CAM_CONSOLE_LOG_ENABLED |
|---|
| 124 | |
|---|
| 125 | #define DEV_HDR_WRITE_OFFSET (0x14C/4) |
|---|
| 126 | |
|---|
| 127 | typedef int DEV_HDR; |
|---|
| 128 | |
|---|
| 129 | int (*_tyWriteOrig)(DEV_HDR *hdr, char *buf, int len); |
|---|
| 130 | |
|---|
| 131 | |
|---|
| 132 | int hook_tyWriteOrig(DEV_HDR *hdr, char *buf, int len) |
|---|
| 133 | { |
|---|
| 134 | // Slow, but stable writes |
|---|
| 135 | FILE *fd = fopen("A/stdout.txt", "a"); |
|---|
| 136 | if (fd) { |
|---|
| 137 | fwrite(buf, 1, len, fd); |
|---|
| 138 | fclose(fd); |
|---|
| 139 | } |
|---|
| 140 | |
|---|
| 141 | return _tyWriteOrig(hdr, buf, len); |
|---|
| 142 | |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | void console_init() |
|---|
| 146 | { |
|---|
| 147 | DEV_HDR *DRV_struct; |
|---|
| 148 | |
|---|
| 149 | DRV_struct = _iosDevFind("/tyCo/0", 0); |
|---|
| 150 | |
|---|
| 151 | _tyWriteOrig = (void*)DRV_struct[DEV_HDR_WRITE_OFFSET]; |
|---|
| 152 | |
|---|
| 153 | FILE *fd = fopen("A/chdklog.txt", "a"); |
|---|
| 154 | if (fd) { |
|---|
| 155 | // can't be used with "Fut" API |
|---|
| 156 | //fprintf(fd, "DRV_struct: %x, _tyWriteOrig: %x\n", DRV_struct, _tyWriteOrig); |
|---|
| 157 | char buf[256]; |
|---|
| 158 | int buflen = sprintf(buf, "DRV_struct: %x, _tyWriteOrig: %x\n", DRV_struct, _tyWriteOrig); |
|---|
| 159 | fwrite(buf, 1, buflen, fd); |
|---|
| 160 | } |
|---|
| 161 | |
|---|
| 162 | FILE *fdout = fopen("A/stdout.txt", "r"); |
|---|
| 163 | if (fdout) |
|---|
| 164 | { |
|---|
| 165 | DRV_struct[DEV_HDR_WRITE_OFFSET] = (int)hook_tyWriteOrig; |
|---|
| 166 | fclose(fdout); |
|---|
| 167 | // fprintf(fd, "tyWrite replaced, camera log enabled\n"); |
|---|
| 168 | fwrite("tyWrite replaced, camera log enabled\n", 1, sizeof("tyWrite replaced, camera log enabled\n"), fd); |
|---|
| 169 | } |
|---|
| 170 | |
|---|
| 171 | if (fd) |
|---|
| 172 | { |
|---|
| 173 | fclose(fd); |
|---|
| 174 | } |
|---|
| 175 | |
|---|
| 176 | } |
|---|
| 177 | |
|---|
| 178 | #endif |
|---|