コード例 #1
0
ファイル: snapshots.c プロジェクト: tibounise/400plus
int snapshot_write(char *name) {
	const int version = SETTINGS_VERSION;

	int  result = FALSE;
	int  file   = -1;

	snapshot_t buffer = {
		DPData     : DPData,
		settings   : settings,
		menu_order : menu_order,
	};

	if ((file = FIO_OpenFile(name, O_CREAT | O_WRONLY , 644)) == -1)
		goto end;

	if (FIO_WriteFile(file, (void*)&version, sizeof(version)) != sizeof(version))
		goto end;

	if (FIO_WriteFile(file, (void*)&buffer, sizeof(buffer)) != sizeof(buffer))
		goto end;

	if (FIO_CloseFile(file) == -1)
		goto end;

	result = TRUE;

end:
	if (file != -1)
		FIO_CloseFile(file);

	return result;
}
コード例 #2
0
ファイル: cmodes.c プロジェクト: easyaspi314/400plus
void cmodes_write() {
	const int version = SNAPSHOT_VERSION;
	int file = -1;

	if ((file = FIO_OpenFile(MKPATH_NEW(CMODES_CONFIG), O_CREAT | O_WRONLY)) == -1)
		if (status.folder_exists || (file = FIO_OpenFile(MKPATH_OLD(CMODES_CONFIG), O_CREAT | O_WRONLY)) == -1)
			goto end;

	FIO_WriteFile(file, (void*)&version,        sizeof(version));
	FIO_WriteFile(file, (void*)&cmodes_config, sizeof(cmodes_config));
	FIO_CloseFile(file);

end:
	if (file != -1)
		FIO_CloseFile(file);
}
コード例 #3
0
ファイル: lv_rec.c プロジェクト: frantony/magic-lantern
/* add a footer to given file handle to  */
unsigned int lv_rec_save_footer(FILE *save_file, lv_rec_save_data_t *save_data)
{
    lv_rec_file_footer_t footer;
    
    if(save_data->options.rawMode)
    {
        strcpy((char*)footer.magic, "RAW");
    }
    else
    {
        strcpy((char*)footer.magic, "YUV");
    }
    
    if(save_data->options.singleFile)
    {
        strcpy((char*)&footer.magic[3], "M");
    }
    else
    {
        strcpy((char*)&footer.magic[3], "I");
    }
    
    footer.xRes = save_data->width;
    footer.yRes = save_data->finalHeight;
    footer.frameSize = save_data->finalHeight * save_data->bytesPerLine;
    footer.frameCount = save_data->frameCount;
    footer.frameSkip = save_data->options.frameSkip;
    
    footer.sourceFpsx1000 = fps_get_current_x1000();
    footer.raw_info = raw_info;
    
    FIO_WriteFile(save_file, &footer, sizeof(lv_rec_file_footer_t));
    
    return sizeof(lv_rec_file_footer_t);
}
コード例 #4
0
ファイル: shootspy.c プロジェクト: frantony/magic-lantern
void save_log()
{
    NotifyBox(1000, "%d ", strlen(log));
    FILE* f = FIO_CreateFileEx(CARD_DRIVE"shoot.log");
    FIO_WriteFile(f, UNCACHEABLE(log), strlen(log));
    FIO_CloseFile(f);
    beep();
}
コード例 #5
0
ファイル: main.c プロジェクト: jbuchbinder/40d_dev
//dump ram and rom
void dumpmemo()
{
	FIO_RemoveFile("B:/RAMDUMP.BIN");
	int f = FIO_CreateFile("B:/RAMDUMP.BIN");
	
	if (f!=-1) { 
		FIO_WriteFile(f, (void*)0xFFFF0000, 4);
		FIO_WriteFile(f, (void*)4, 0x1900-4);
		FIO_WriteFile(f, (void*)0x1900, 32*1024*1024-0x1900);
		
		FIO_CloseFile(f);
	}
	
	f = FIO_OpenFile("B:/ROMDUMP.BIN", 0, 0644);
	FIO_CloseFile(f);
	
	if (f==-1) { 
		f = FIO_CreateFile("B:/ROMDUMP.BIN");		
		FIO_WriteFile(f, (void*)0xFF800000, 8*1024*1024);
		FIO_CloseFile(f);
	}
}
コード例 #6
0
ファイル: config.c プロジェクト: HulaSamsquanch/1100d_lantern
unsigned int module_config_save(char *filename, module_entry_t *module)
{
    if (!module->config)
        return -1;

    char* msg = fio_malloc(MAX_SIZE);
    msg[0] = '\0';

    snprintf( msg, MAX_SIZE,
              "# Config file for module %s (%s)\n\n",
              module->name, module->filename
            );

    int count = 0;
    for (module_config_t * mconfig = module->config; mconfig && mconfig->name; mconfig++)
    {
        if (*(int*)mconfig->ref->value == mconfig->ref->default_value)
            continue;

        snprintf(msg + strlen(msg), MAX_SIZE - strlen(msg) - 1,
                 "%s = %d\r\n",
                 mconfig->ref->name,
                 *(int*) mconfig->ref->value
                );

        count++;
    }

    if (count == 0)
    {
        /* everything is default, just delete the config file */
        FIO_RemoveFile(filename);
        goto finish;
    }

    FILE * file = FIO_CreateFile( filename );
    if (!file)
    {
        fio_free(msg);
        return -1;
    }

    FIO_WriteFile(file, msg, strlen(msg));

    FIO_CloseFile( file );
finish:
    fio_free(msg);
    return 0;
}
コード例 #7
0
ファイル: lv_rec.c プロジェクト: frantony/magic-lantern
unsigned int lv_rec_save_block(FILE *save_file, lv_rec_save_data_t *save_data, unsigned int length, int skip_saving)
{
    unsigned int written = 0;
    
    while(length > 0)
    {
        /* get next chunk in buffer */
        if(!save_data->chunkData.chunkAvail)
        {
            lv_rec_next_chunk(&save_data->chunkData);
        }
        
        /* end of suite reached, wrap over */
        if(!save_data->chunkData.chunkAvail)
        {
            save_data->chunkData.currentChunk = NULL;
            lv_rec_next_chunk(&save_data->chunkData);
        }
        
        /* this should not happen */
        if(!save_data->chunkData.chunkAvail)
        {
            break;
        }
        unsigned int avail = MIN(save_data->chunkData.chunkAvail, length);
        
        if(!skip_saving)
        {
            FIO_WriteFile(save_file, UNCACHEABLE(&save_data->chunkData.chunkAddress[save_data->chunkData.chunkOffset]), avail);
            written += avail;
        }
        
        length -= avail;
        save_data->chunkData.chunkOffset += avail;
        save_data->chunkData.chunkAvail -= avail;
    }
    
    return written;
}
コード例 #8
0
ファイル: utils.c プロジェクト: AEUG/400plus
void dump_memory() {
	char filename[20] = "A:/12345678.MEM";
	time_t t;
	struct tm tm;

	time(&t);
	localtime_r(&t, &tm);

	sprintf(filename, "A:/%02d%02d%02d%02d.MEM", tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);

	debug_log("Dumping memory to %s.\n", filename);
	int file = FIO_OpenFile(filename, O_CREAT | O_WRONLY , 644);

	if (file == -1) {
		debug_log("ERROR: can't open file for writing (%s)", filename);
		beep();
		beep();
	} else {
		int addr=0;
		int power_off_state = DPData.auto_power_off;

		send_to_intercom(IC_SET_AUTO_POWER_OFF, false);

		while (addr<0x800000) { // dump 8MB of RAM
			char buf[0x800];
			// i don't know why, but if we try to pass the mem address (addr) directly to
			// FIO_WriteFile, we get zero-filled file... so we need local buffer as a proxy
			// note: do not increase the size of the local buffer too much, because it is in the stack
			LEDBLUE ^= 2;
			memcpy(buf, (void*)addr, 0x800);
			FIO_WriteFile(file, buf, 0x800);
			addr += 0x800;
		}
		FIO_CloseFile(file);

		send_to_intercom(IC_SET_AUTO_POWER_OFF, power_off_state);
	}
	beep();
}
コード例 #9
0
ファイル: main.c プロジェクト: easyaspi314/400plus
void start_up() {
	// Check and create our 400PLUS folder
	status.folder_exists = check_create_folder();

	// Recover persisting information
	persist_read();

	// Read settings from file
	settings_read();

	// If configured, start debug mode
	if (settings.debug_on_poweron)
		start_debug_mode();

	// If configured, restore AEB
	if (settings.persist_aeb)
		send_to_intercom(IC_SET_AE_BKT, persist.aeb);

	// Enable IR remote
	// i'm not sure where to call this? perhaps this isn't the right place.
	if (settings.remote_enable)
		remote_on();

	// Enable extended ISOs
	// Enable (hidden) CFn.8 for ISO H
	send_to_intercom(IC_SET_CF_EXTEND_ISO, 1);

	// Enable realtime ISO change
	send_to_intercom(IC_SET_REALTIME_ISO_0, 0);
	send_to_intercom(IC_SET_REALTIME_ISO_1, 0);

	// Set current language
	enqueue_action(lang_pack_init);

	// Read custom modes configuration from file
	enqueue_action(cmodes_read);

	// And optionally apply a custom mode
	enqueue_action(cmode_recall);

    // turn off the blue led after it was lighten by our hack_task_MainCtrl()
	eventproc_EdLedOff();

#ifdef MEMSPY
	debug_log("starting memspy task");
	CreateTask("memspy", 0x1e, 0x1000, memspy_task, 0);
#endif

#if 0
	debug_log("=== DUMPING DDD ===");
	printf_DDD_log( (void*)(int)(0x00007604+0x38) );

	debug_log("maindlg @ 0x%08X, handler @ 0x%08X", hMainDialog, hMainDialog->event_handler);

	debug_log("dumping");
	long *addr   = (long*) 0x7F0000;

	int file = FIO_OpenFile("A:/dump.bin", O_CREAT | O_WRONLY , 644);

	if (file != -1) {
		FIO_WriteFile(file, addr, 0xFFFF);
		FIO_CloseFile(file);
		beep();
	}
#endif
}
コード例 #10
0
ファイル: config.c プロジェクト: HulaSamsquanch/1100d_lantern
int config_save_file(const char *filename)
{
    int count = 0;

    DebugMsg( DM_MAGIC, 3, "%s: saving to %s", __func__, filename );

#define MAX_SIZE 10240
    char* msg = fio_malloc(MAX_SIZE);
    msg[0] = '\0';

    snprintf( msg, MAX_SIZE,
              "# Magic Lantern %s (%s)\n"
              "# Built on %s by %s\n",
              build_version,
              build_id,
              build_date,
              build_user
            );

    struct tm now;
    LoadCalendarFromRTC( &now );

    snprintf(msg + strlen(msg), MAX_SIZE - strlen(msg),
             "# Configuration saved on %04d/%02d/%02d %02d:%02d:%02d\n",
             now.tm_year + 1900,
             now.tm_mon + 1,
             now.tm_mday,
             now.tm_hour,
             now.tm_min,
             now.tm_sec
            );

    for(struct config_var *var = _config_vars_start; var < _config_vars_end ; var++ )
    {
        if (*(int*)var->value == var->default_value)
            continue;

        snprintf(msg + strlen(msg), MAX_SIZE - strlen(msg) - 1,
                 "%s = %d\r\n",
                 var->name,
                 *(int*) var->value
                );

        count++;
    }

    FILE * file = FIO_CreateFile( filename );
    if(!file)
    {
        fio_free(msg);
        return -1;
    }

    FIO_WriteFile(file, msg, strlen(msg));

    FIO_CloseFile( file );

    fio_free(msg);

    return count;
}