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