#include "platform.h" #include "platform_palette.h" #include "lolevel.h" #define LED_PR 0xC0220120 void shutdown() { volatile long *p = (void*)LED_PR; asm( "MRS R1, CPSR\n" "AND R0, R1, #0x80\n" "ORR R1, R1, #0x80\n" "MSR CPSR_cf, R1\n" :::"r1","r0"); *p = 0x44; // power off. while(1); } void debug_led(int state) { // using power LED, which defaults to on // for debugging turn LED off if state is 1 and on for state = 0 *(int*)LED_PR=state ? 0x46 : 0x44; } // A810 has two 'lights' - Power LED, and AF assist lamp // Power Led = first entry in table (led 0) // AF Assist Lamp = second entry in table (led 1) // State // 0 = LED Off // 1 = LED On // 2 = LED blinks slowly // 3 = LED blinks fast // 5 = LED blinks fast (3 times) void camera_set_led(int led, int state, __attribute__ ((unused))int bright) { static char led_table[2]={0,4}; _LEDDrive(led_table[led%sizeof(led_table)], state<=1 ? !state : state); } int vid_get_viewport_width() { return 360; } long vid_get_viewport_height() { return 240; } void vid_bitmap_refresh() { extern int full_screen_refresh; extern void _ScreenLock(); extern void _ScreenUnlock(); full_screen_refresh |= 3; _ScreenLock(); _ScreenUnlock(); } void *vid_get_bitmap_active_palette() { extern int active_palette_buffer; extern char* palette_buffer[]; void* p = palette_buffer[active_palette_buffer]; // Don't add offset if value is 0 if (p) p += 4; return p; } #ifdef CAM_LOAD_CUSTOM_COLORS // Function to load CHDK custom colors into active Canon palette void load_chdk_palette() { extern int active_palette_buffer; // Only load for the standard record and playback palettes if ((active_palette_buffer == 0) || (active_palette_buffer == 5)) { int *pal = (int*)vid_get_bitmap_active_palette(); if (pal && pal[CHDK_COLOR_BASE+0] != 0x33ADF62) { pal[CHDK_COLOR_BASE+0] = 0x33ADF62; // Red pal[CHDK_COLOR_BASE+1] = 0x326EA40; // Dark Red pal[CHDK_COLOR_BASE+2] = 0x34CD57F; // Light Red pal[CHDK_COLOR_BASE+3] = 0x373BFAE; // Green pal[CHDK_COLOR_BASE+4] = 0x34BD6CA; // Dark Green pal[CHDK_COLOR_BASE+5] = 0x395AB95; // Light Green pal[CHDK_COLOR_BASE+6] = 0x34766F0; // Blue pal[CHDK_COLOR_BASE+7] = 0x31250F3; // Dark Blue pal[CHDK_COLOR_BASE+8] = 0x37F408F; // Cyan pal[CHDK_COLOR_BASE+9] = 0x3512D5B; // Magenta pal[CHDK_COLOR_BASE+10] = 0x3A9A917; // Yellow pal[CHDK_COLOR_BASE+11] = 0x3819137; // Dark Yellow pal[CHDK_COLOR_BASE+12] = 0x3DED115; // Light Yellow pal[CHDK_COLOR_BASE+13] = 0x0090000; // Transparent dark grey extern char palette_control; palette_control = 1; vid_bitmap_refresh(); } } } #endif // Functions for PTP Live View system // 256 entry palette based on 100b sub_FF909B0C int vid_get_palette_type() { return 3; } int vid_get_palette_size() { return 256 * 4; } void *vid_get_bitmap_active_buffer() { return (void*)(*(int*)(0x5400+0x18)); //found @ loc_ff909bb0 a810 100b } // following routines help preventing the "invisible af lock" caused by the movie af scan hack static int af_locked_in_movierec = 0; void _MakeAFScan(__attribute__ ((unused))int *a, __attribute__ ((unused))int b) { _DoAFLock(); af_locked_in_movierec = 1; } void state_check_for_movie_af() { if ((get_movie_status() != VIDEO_RECORD_IN_PROGRESS) && af_locked_in_movierec) { af_locked_in_movierec = 0; _UnlockAF(); } }