Пример #1
0
void csw_load(char *fn)
{
        int end,c;
        uint32_t destlen = 8 * 1024 * 1024;
        uint8_t *tempin;
        if (csw_f) fclose(csw_f);
        if (csw_dat) free(csw_dat);
        csw_ena = 1;
        /*Allocate buffer*/
        csw_dat = malloc(8 * 1024 * 1024);
        /*Open file and get size*/
        csw_f = x_fopen(fn,"rb");
        if (!csw_f)
        {
                free(csw_dat);
                csw_dat = NULL;
                return;
        }
        fseek(csw_f, -1, SEEK_END);
        end = ftell(csw_f);
        fseek(csw_f, 0, SEEK_SET);
        /*Read header*/
        fread(csw_head, 0x34, 1, csw_f);
        for (c = 0; c < csw_head[0x23]; c++) getc(csw_f);
        /*Allocate temporary memory and read file into memory*/
        end -= ftell(csw_f);
        tempin = malloc(end);
        fread(tempin, end, 1, csw_f);
        fclose(csw_f);
//        sprintf(csws,"Decompressing %i %i\n",destlen,end);
//        fputs(csws,cswlog);
        /*Decompress*/
        uncompress(csw_dat, (unsigned long *)&destlen, tempin, end);
        free(tempin);
        /*Reset data pointer*/
        csw_point = 0;
        dcd();
        tapellatch  = (1000000 / (1200 / 10)) / 64;
        tapelcount  = 0;
	tape_loaded = 1;
}
Пример #2
0
Файл: uef.c Проект: fesh0r/b-em
void uef_poll()
{
        int c;
        uint32_t templ;
        float *tempf;
        uint8_t temp;
        if (!uef_f)
           return;
        if (!uef_inchunk)
        {
                uef_startchunk = 1;
//                printf("%i ",gztell(uef));
                gzread(uef_f, &uef_chunkid, 2);
                gzread(uef_f, &uef_chunklen, 4);
                if (gzeof(uef_f))
                {
                        gzseek(uef_f, 12, SEEK_SET);
                        gzread(uef_f, &uef_chunkid, 2);
                        gzread(uef_f, &uef_chunklen, 4);
                        uefloop = 1;
                }
                uef_inchunk = 1;
                uef_chunkpos = 0;
//                printf("Chunk ID %04X len %i\n",uef_chunkid,uef_chunklen);
        }
//        else
//           printf("Chunk %04X\n",uef_chunkid);
        switch (uef_chunkid)
        {
                case 0x000: /*Origin*/
                for (c = 0; c < uef_chunklen; c++)
                    gzgetc(uef_f);
                uef_inchunk = 0;
                return;

                case 0x005: /*Target platform*/
                for (c = 0; c < uef_chunklen; c++)
                    gzgetc(uef_f);
                uef_inchunk = 0;
                return;

                case 0x100: /*Raw data*/
                if (uef_startchunk)
                {
                        dcdlow();
                        uef_startchunk = 0;
                }
                uef_chunklen--;
                if (!uef_chunklen)
                {
                        uef_inchunk = 0;
                }
                uef_receive(gzgetc(uef_f));
                return;

                case 0x104: /*Defined data*/
                if (!uef_chunkpos)
                {
                        uef_chunkdatabits = gzgetc(uef_f);
                        gzgetc(uef_f);
                        gzgetc(uef_f);
                        uef_chunklen -= 3;
                        uef_chunkpos = 1;
                }
                else
                {
                        uef_chunklen--;
                        if (uef_chunklen <= 0)
                           uef_inchunk = 0;
                        temp = gzgetc(uef_f);
//                        printf("%i : %i %02X\n",gztell(uef),uef_chunklen,temp);
                        if (uef_chunkdatabits == 7) uef_receive(temp & 0x7F);
                        else                        uef_receive(temp);
                }
                return;

                case 0x110: /*High tone*/
                uef_toneon = 2;
                if (!uef_intone)
                {
                        dcd();
                        uef_intone = gzgetc(uef_f);
                        uef_intone |= (gzgetc(uef_f) << 8);
                        uef_intone /= 20;
                        if (!uef_intone) uef_intone = 1;
//                        printf("uef_intone %i\n",uef_intone);
                }
                else
                {
                        uef_intone--;
                        if (uef_intone == 0)
                        {
                                uef_inchunk = 0;
                        }
                }
                return;

                case 0x111: /*High tone with dummy byte*/
                uef_toneon = 2;
                if (!uef_intone)
                {
                        dcd();
                        uef_intone = gzgetc(uef_f);
                        uef_intone |= (gzgetc(uef_f)<<8);
                        uef_intone /= 20;
                        if (!uef_intone) uef_intone = 1;
                }
                else
                {
                        uef_intone--;
                        if (uef_intone == 0 && uef_inchunk == 2)
                        {
                                uef_inchunk = 0;
                        }
                        else if (!uef_intone)
                        {
                                uef_inchunk = 2;
                                uef_intone = gzgetc(uef_f);
                                uef_intone |= (gzgetc(uef_f) << 8);
                                uef_intone /= 20;
                                if (!uef_intone) uef_intone = 1;
                                uef_receive(0xAA);
                        }
                }
                return;

                case 0x112: /*Gap*/
                uef_toneon = 0;
                if (!uef_intone)
                {
//                        dcd();
                        uef_intone = gzgetc(uef_f);
                        uef_intone |= (gzgetc(uef_f) << 8);
                        uef_intone /= 20;
//                        printf("gap uef_intone %i\n",uef_intone);
                        if (!uef_intone) uef_intone = 1;
                }
                else
                {
                        uef_intone--;
                        if (uef_intone == 0)
                        {
                                uef_inchunk = 0;
                        }
                }
                return;

                case 0x113: /*Float baud rate*/
                templ = gzgetc(uef_f);
                templ |= (gzgetc(uef_f) << 8);
                templ |= (gzgetc(uef_f) << 16);
                templ |= (gzgetc(uef_f) << 24);
                tempf = (float *)&templ;
                tapellatch = (1000000 / ((*tempf) / 10)) / 64;
                pps = (*tempf) / 10;
                uef_inchunk = 0;
                return;

                case 0x116: /*Float gap*/
                uef_toneon = 0;
                if (!uef_chunkpos)
                {
                        templ = gzgetc(uef_f);
                        templ |= (gzgetc(uef_f) << 8);
                        templ |= (gzgetc(uef_f) << 16);
                        templ |= (gzgetc(uef_f) << 24);
                        tempf = (float *)&templ;
                        uef_chunkf = *tempf;
                        //printf("Gap %f %i\n",uef_chunkf,pps);
                        uef_chunkpos = 1;
//                        uef_chunkf=4;
                }
                else
                {
//                        printf("Gap now %f\n",uef_chunkf);
                        uef_chunkf -= ((float)1 / (float)pps);
                        if (uef_chunkf <= 0) uef_inchunk = 0;
                }
                return;

                case 0x114: /*Security waves*/
                case 0x115: /*Polarity change*/
//                default:
                for (c = 0; c < uef_chunklen; c++)
                    gzgetc(uef_f);
                uef_inchunk = 0;
                return;

                default:
                for (c = 0; c < uef_chunklen; c++)
                    gzgetc(uef_f);
                uef_inchunk = 0;
                return;
//116 : float gap
//113 : float baud rate

        }
//        allegro_exit();
//        printf("Bad chunk ID %04X length %i\n",uef_chunkid,uef_chunklen);
//        exit(-1);
}
Пример #3
0
bool PerigeeMove::Run()
{
	if ( m_options.debug_prompt )
	{
		DlgConfirmDelete dcd(m_files);
		CString csCaption;
		CString csTempl;
		CString csPrompt;

		csCaption.LoadString(IDS_CONFIRM_MOVE);
		csTempl.LoadString(IDS_CONFIRM_MOVE_PROMPT_TEMPL);
		csPrompt.Format(csTempl, (LPCTSTR)m_files[0].dest);

		dcd.ChangeCaption(csCaption, csPrompt);

		if ( IDCANCEL == dcd.DoModal() )
		{
			return false;
		}
	}
	
	m_progress.ShowWindow(SW_SHOW);


	// On Windows Vista, verify the user has permission to create files
	// in the destination folder, and prompt for elevation otherwise
	if (!m_files.empty() && EnableElevatePrompt() &&
		!VistaHelper::CheckAccess(m_files[0].dest, GENERIC_WRITE, m_token))
	{
		CString message;
		message.Format(IDS_ELEVATION_REQUIRED_TO_CREATE_FILES_IN_FOLDER, m_files[0].dest);
		DoElevatePrompt(message);
		if (m_cancel)
			return false;
	}

	PostPrompt();

	Reset();
	if (!InitIt())
		return false;

	for(;;)
	{
		Reset();
		if ( DoIt() )
		{
			return true;
		}

		if ( m_cancel )
			return false;

		bool retry = false;

		// if we're in "postpone" mode, enable prompting now
		if (m_options.overwrite == CPerigeeCopyOptions::overwrite_postpone) {
			retry = true;
			m_options.overwrite = CPerigeeCopyOptions::overwrite_prompt;
		}

		// show skipped files dialog
		if (!retry) {
			PrePrompt(false);
			CDialogFailedFiles dff(NULL, m_error_files);
			retry = IDOK == dff.DoModal();
			PostPrompt();
		}

		if ( retry )
		{
			// move failed files back to source list and try again
			m_files.clear();
			for(file_list::iterator it = m_error_files.begin(); 
				it != m_error_files.end(); ++it)
			{
				if ( it->error_type < warn_first )
				{
					m_files.push_back(*it);
				}
			}
		}
		else
		{
			return false;
		}
	}
}