コード例 #1
0
ファイル: dbg.c プロジェクト: AntiheroSoftware/cc65
static char GetKeyUpdate (void)
/* Wait for a key updating the windows in the background */
{
    static unsigned char Win;

    /* While there are no keys... */
    while (!kbhit ()) {

        switch (Win) {

            case 0:
                UpdateAsm ();
                break;

            case 1:
                UpdateStack ();
                break;

            case 2:
                UpdateCStack ();
                break;

            case 3:
                UpdateDump ();
                break;
        }

        Win = (Win + 1) & 0x03;

    }

    /* We have a key - return it */
    return cgetc ();
}
コード例 #2
0
ファイル: dbg.c プロジェクト: AntiheroSoftware/cc65
static void Redraw (char Frame)
/* Redraw the display in case it's garbled */
{
    /* Redraw the static stuff */
    RedrawStatic (Frame);

    /* Init the window contents */
    UpdateAsm ();
    UpdateReg ();
    UpdateStack ();
    UpdateCStack ();
    UpdateDump ();
}
コード例 #3
0
ファイル: dbg.c プロジェクト: AntiheroSoftware/cc65
static char DumpHandler (void)
/* Get characters and handle them */
{
    char c;
    unsigned BytesPerPage = DumpFrame.fd_height * 8;

    while (1) {

        /* Read and handle input */
        switch (c = GetKeyUpdate ()) {

            case  '+':
                DumpAddr += BytesPerPage;
                break;

            case '-':
                DumpAddr -= BytesPerPage;
                break;

            case 'g':
                InputGoto (&DumpAddr);
                break;

            case 'o':
                DumpHome ();
                break;

            case 'a':
#ifdef CH_CURS_UP
            case CH_CURS_UP:
#endif
                DumpAddr -= 8;
                break;

            case 'z':
#ifdef CH_CURS_DOWN
            case CH_CURS_DOWN:
#endif
                DumpAddr += 8;
                break;

            default:
                return c;

        }

        /* Update the window contents */
        UpdateDump ();
    }
}
コード例 #4
0
ファイル: CapsImage.cpp プロジェクト: FrodeSolheim/capsimg
// convert information about decompressed CT Raw file to generic track data
void CCapsImage::ConvertDumpInfo(PCAPSWH wh)
{
	PDISKTRACKINFO pti = di.pdt;

	// use the number of revolutions that could be stored by pti at most or the number of revolutions sampled if less
	int maxrev = min(CAPS_MTRS, wh->trkcnt);
	pti->rawtrackcnt = maxrev;

	// save the total size of all tracks decoded; don't have to recalculate later
	pti->rawlen = wh->rawlen;

	// prevent deallocating the buffer with the track data
	wh->rawbuf = NULL;

	// longest track found
	int maxtracksize = 0;

	// copy the track buffer start positions and sizes for the decompressed stream
	for (int rev = 0; rev < maxrev; rev++) {
		pti->trackdata[rev] = wh->trkbuf[rev];
		pti->tracksize[rev] = wh->trklen[rev];

		// find the longest track
		if (pti->tracksize[rev] > maxtracksize)
			maxtracksize = pti->tracksize[rev];
	}

	// save the original decoded timing data length
	pti->rawtimebuf = wh->timbuf;
	pti->rawtimecnt = wh->timlen;

	// prevent deallocating the buffer with the timing data
	wh->timbuf = NULL;

	// allocate timing buffer the same size as the longest data track; +1 for alternate density
	pti->timebuf = new UDWORD[maxtracksize + 1];

	// calculate the sum of the timing samples
	double timesum = 0;
	for (int i = 0; i < pti->rawtimecnt; i++) {
		timesum += pti->rawtimebuf[i];
	}

	// normalize all timing values; 1000 is the default value
	// compensate for precision loss to integer values by using a remainder
	int targetsum = pti->rawtimecnt * 1000;
	int actsum = 0;
	double tconv = (double)targetsum / timesum;
	double rem = 0;
	for (int i = 0; i < pti->rawtimecnt; i++) {
		double vr = pti->rawtimebuf[i] * tconv + rem;
		UDWORD vi = (UDWORD)vr;
		rem = vr - vi;
		pti->rawtimebuf[i] = vi;
		actsum += vi;
	}

	// If there is still a difference between the targeted normalized values and the actual values
	// add the remainder to the last timing.
	// tdiff can't be more than the target since it represents the remaining sum of precision losses
	int tdiff = targetsum - actsum;
	if (tdiff > 0)
		pti->rawtimebuf[pti->rawtimecnt - 1] += tdiff;

	// generate 1 revolution of data as default, 5 for analyser
	int trackcnt = (di.flag & DI_LOCK_ANA) ? 5 : 1;

	// 5 revolutions if track update is not used
	if (!(di.flag & DI_LOCK_UPDATEFD))
		trackcnt = 5;

	// the number of revolutions can't be more than the number of track revolutions decoded
	if (trackcnt > maxrev)
		trackcnt = maxrev;

	// write track info
	pti->trackcnt = trackcnt;
	pti->overlap = -1;
	pti->overlapbit = -1;

	// reset random seed
	pti->wseed = 0x87654321;

	// request raw track updates/streaming
	pti->rawdump = 1;
	pti->rawupdate = 1;

	// initialize lookup tables used by the weak bit detector
	InitFirstBitTables();

	// identify and record weak bit areas
	FindWeakBits();

	// first image update to initialize streaming
	UpdateDump();
}
コード例 #5
0
ファイル: dbg.c プロジェクト: AntiheroSoftware/cc65
void DbgEntry (void)
/* Start up the debugger */
{
    static unsigned char FirstTime = 1;
    char c;
    char done;

    /* If this is the first call, setup the display */
    if (FirstTime) {
        FirstTime = 0;

        /* Draw the window, default active frame is ASM frame */
        RedrawStatic (WIN_ASM);
        InitAsm ();
        InitReg ();
        InitStack ();
        InitCStack ();
        UpdateDump ();
    }

    /* Only initialize variables here, don't do a display update. The actual
     * display update will be done while waiting for user input.
     */
    AsmHome ();
    UpdateReg ();               /* Must update this (static later) */
    StackHome ();
    CStackHome ();

    /* Wait for user input */
    done = 0;
    while (!done) {
        c = Frames [ActiveFrame]->fd_func ();
        switch (c) {

            case '1':
            case '2':
            case '3':
            case '4':
            case '5':
                ActivateFrame (c - '1', 0);
                break;

            case '?':
#ifdef CH_F1
            case CH_F1:
#endif
                HelpHandler ();
                break;

            case 'u':
#ifdef CH_F3
            case CH_F3:
#endif
                /* Go until return */
                SetRTSBreak ();
                done = 1;
                break;

            case 'h':
#ifdef CH_F4
            case CH_F4:
#endif
                /* Go to cursor, only possible if cursor not at current PC */
                if (AsmAddr != brk_pc) {
                    DbgSetTmpBreak (AsmAddr);
                    done = 1;
                }
                break;

            case ' ':
#ifdef CH_F7
            case CH_F7:
#endif
                SingleStep (1);
                if (DbgTmpBreaksOk ()) {
                    /* Could set breakpoints */
                    done = 1;
                }
                break;

            case '\n':
#ifdef CH_F8
            case CH_F8:
#endif
                SingleStep (0);
                if (DbgTmpBreaksOk ()) {
                    /* Could set breakpoints */
                    done = 1;
                }
                break;

            case 'c':
            case 0:
                done = 1;
                break;

            case 's':
                /* Skip instruction */
                brk_pc += DbgDisAsmLen (brk_pc);
                InitAsm ();
                break;

            case 'r':
                /* Redraw screen */
                Redraw (ActiveFrame);
                break;

            case 'q':
                /* Quit program */
                clrscr ();
                exit (1);

        }
    }
}