Beispiel #1
0
int m68k_raise_irq(int level, int vector)
{
	M68KCONTEXT.interrupts[0] |= 1 << level;
	m68k_irq_update(0);
	dprintf("lvl: %i, line: %i, irqs: %02x", level, m68k_context.irq, M68KCONTEXT.interrupts[0]);

	return 0;
}
Beispiel #2
0
int m68k_lower_irq(int level)
{
	M68KCONTEXT.interrupts[0] &= ~(1 << level);
	m68k_irq_update(0);
	dprintf("lvl: %i, line: %i, irqs: %02x", level, m68k_context.irq, M68KCONTEXT.interrupts[0]);

	return 0;
}
Beispiel #3
0
static int irq_ack(int level)
{
	M68KCONTEXT.interrupts[0] &= ~(1 << level);
	m68k_irq_update(0);

	dprintf("level: %i, irqs: %02x", level, M68KCONTEXT.interrupts[0]);
	return CYCLONE_INT_ACK_AUTOVECTOR;
}
Beispiel #4
0
static void uae4all_reset(void)
{
    int i;
#if !defined(USE_CYCLONE_CORE) && !defined(USE_FAME_CORE_ARM2)
    m68k_set_context(&micontexto);
#endif
    m68k_reset();
    for(i=1; i<8; i++)
#if defined(DEBUG_INTERRUPTS)
        M68KCONTEXT.interrupts[i]=0xFF;
#else
        M68KCONTEXT.interrupts[i]=0x18+i;
#endif
    M68KCONTEXT.interrupts[0]=0;
    m68k_irq_update(0);
    mispcflags=0;
    _68k_areg(7) = get_long (0x00f80000);
    _68k_setpc(get_long (0x00f80004));
    //_68k_sreg = 0x2700; // already done by m68k_reset()
    mispcflags=0;
#ifdef DEBUG_FRAMERATE
    uae4all_update_time();
#endif
}
Beispiel #5
0
static void m68k_run (void)
{
    uae4all_reset ();
    unsigned cycles, cycles_actual=M68KCONTEXT.cycles_counter;
    for (;;) {
#ifdef DEBUG_M68K
        dbg_cycle(m68k_fetch(m68k_get_pc(),0));
        m68k_emulate(1);

#else
        uae4all_prof_start(0);

        cycles = nextevent - currcycle;
        switch (timeslice_mode) {
        case 3:
            cycles>>=6;
            break;
        case 2:
            cycles>>=7;
            break;
        case 1:
            cycles=(cycles>>8)+(cycles>>9);
            break;
        default:
            cycles>>=8;
            break;
        }

#define NDEBUG_CYCLES
#ifdef DEBUG_CYCLES
        static unsigned next_cycles = 60000000;
        if (M68KCONTEXT.cycles_counter > next_cycles) {
            next_cycles += 100000;
            printf("cycles=%9d|%03i|%03i, pc=%.6x\n", M68KCONTEXT.cycles_counter, cycles, IO_CYCLE, _68k_getpc());
        }

        if (M68KCONTEXT.cycles_counter > 80000000) {
            // exit(0);
        }

        if (M68KCONTEXT.cycles_counter >= 500000000) {
            // do_debug = 1;
        }

#endif

#if defined(FAME_INTERRUPTS_SECURE_PATCH) && defined(FAME_INTERRUPTS_PATCH)
        if (uae4all_go_interrupt)
            m68k_emulate(FAME_INTERRUPTS_PATCH);
        else
#endif
            m68k_emulate(cycles);

        uae4all_prof_end(0);
#endif
#if 0 // def FAME_INTERRUPTS_PATCH
        if (uae4all_go_interrupt)
        {
            /*if (verb)*/ printf("uae4all_go_interrupt: %02x\n", uae4all_go_interrupt);
            M68KCONTEXT.interrupts[0]=uae4all_go_interrupt;
            M68KCONTEXT.execinfo&=0xFF67;
            uae4all_go_interrupt=0;
            m68k_irq_update(0);
        }
#endif

        uae4all_prof_start(1);

        cycles=(M68KCONTEXT.cycles_counter-cycles_actual) * cycles_factor;

#ifdef DEBUG_INTERRUPTS
        dbgf("cycles=%i (%i) -> PC=%.6x\n",cycles>>8,nextevent - currcycle, _68k_getpc());
#endif


#ifdef NO_SHORT_EVENTS
#ifdef PROTECT_INFINITE
        unsigned cuentalo=0;
#endif
        do {
#endif
            do_cycles(cycles);
            if (mispcflags)
                if (do_specialties (cycles))
                    return;
#ifndef DEBUG_M68K
#ifdef NO_SHORT_EVENTS
            cycles=2048;
#ifdef PROTECT_INFINITE
            cuentalo++;
            if (cuentalo>1024) {
                g_emulator.quit_program=RunStateReset;
                return;
            }
#endif
        } while((nextevent - currcycle)<=2048);
#endif
        cycles_actual=M68KCONTEXT.cycles_counter;
#endif
        uae4all_prof_end(1);
    }
}
Beispiel #6
0
static int do_specialties (int cycles)
{
    if (mispcflags & SPCFLAG_COPPER)
    {
#ifdef DEBUG_M68K
        dbg("do_specialties -> do_copper");
#endif
        do_copper ();
    }

    /*n_spcinsns++;*/
    while ((mispcflags & SPCFLAG_BLTNASTY) && cycles > 0) {
        int c = blitnasty();
        if (!c) {
            cycles -= 2 * CYCLE_UNIT;
            if (cycles < CYCLE_UNIT)
                cycles = 0;
            c = 1;
        }
#ifdef DEBUG_M68K
        dbgf("do_specialties -> do_cycles BLTNASTY %i\n",c);
#endif
        do_cycles(c * CYCLE_UNIT);
        if (mispcflags & SPCFLAG_COPPER)
        {
#ifdef DEBUG_M68K
            dbg("do_specialties -> do_copper BLTNASTY");
#endif
            do_copper ();
        }
    }

#ifdef DEBUG_M68K
    while (M68KCONTEXT.execinfo & 0x0080) {
        if (mispcflags & SPCFLAG_BRK)
            break;
        else if (M68KCONTEXT.execinfo & 0x0080)
        {
            int intr = intlev ();
            if (intr != -1 && intr > _68k_intmask)
            {
                M68KCONTEXT.execinfo &= 0xFF7F;
                break;
            }
        }
        dbg("CPU STOPPED !");
        do_cycles(4 * CYCLE_UNIT);
        if (mispcflags & SPCFLAG_COPPER)
        {
            dbg("do_specialties -> do_copper STOPPED");
            do_copper ();
        }
    }
    unset_special (SPCFLAG_STOP);
#endif

#if 0 // !defined(FAME_INTERRUPTS_SECURE_PATCH) && defined(FAME_INTERRUPTS_PATCH)
    if (uae4all_go_interrupt)
    {
        /*if (verb)*/ printf("uae4all_go_interrupt (s): %02x\n", uae4all_go_interrupt);
        M68KCONTEXT.interrupts[0]=uae4all_go_interrupt;
        M68KCONTEXT.execinfo&=0xFF67;
        uae4all_go_interrupt=0;
        m68k_irq_update(0);
    }
#endif

#ifdef SPECIAL_DEBUG_INTERRUPTS
    if ((mispcflags & SPCFLAG_DOINT)&&(!(mispcflags & SPCFLAG_INT))) {
        int intr = intlev ();
#ifdef DEBUG_INTERRUPTS_EXTRA
        dbgf("DOINT : intr = %i, intmask=%i\n", intr, _68k_intmask);
#endif
        unset_special (SPCFLAG_DOINT);
        if (intr != -1 && intr > _68k_intmask) {
            M68KCONTEXT.execinfo&=0xFF6F;
            m68k_raise_irq(intr,M68K_AUTOVECTORED_IRQ);
//		m68k_emulate(0);
        }
    }
    if (mispcflags & SPCFLAG_INT) {
#ifdef DEBUG_INTERRUPTS_EXTRA
        dbg("ESTAMOS EN INT -> PASAMOS A DOINT");
#endif
        unset_special (SPCFLAG_INT);
        set_special (SPCFLAG_DOINT);
    }
#endif

    if (mispcflags & SPCFLAG_BRK) {
        unset_special (SPCFLAG_BRK);
        return 1;
    }
    return 0;
}
Beispiel #7
0
static void m68k_run (void)
{
	uae4all_reset ();
	unsigned cycles, cycles_actual=M68KCONTEXT.cycles_counter;
	for (;;) {
		while (pause_program > 0)
		{
			usleep(200000);
		}
        
#ifdef DEBUG_M68K
		dbg_cycle(m68k_fetch(m68k_get_pc(),0));
		m68k_emulate(1);

#else
		uae4all_prof_start(0);
		cycles = nextevent - currcycle;
		switch (timeslice_mode) {
			case 3:  cycles>>=6; break;
			case 2:  cycles>>=7; break;
			case 1:  cycles=(cycles>>8)+(cycles>>9); break;
			default: cycles>>=8; break;
		}
#ifdef DEBUG_TIMESLICE
		unsigned ts=cycles;
#endif
#if defined(FAME_INTERRUPTS_SECURE_PATCH) && defined(FAME_INTERRUPTS_PATCH)
		if (uae4all_go_interrupt)
			m68k_emulate(FAME_INTERRUPTS_PATCH);
		else
#endif
			m68k_emulate(cycles);
		uae4all_prof_end(0);
#endif
#if 0 // def FAME_INTERRUPTS_PATCH
		if (uae4all_go_interrupt)
		{
			/*if (verb)*/ printf("uae4all_go_interrupt: %02x\n", uae4all_go_interrupt);
			M68KCONTEXT.interrupts[0]=uae4all_go_interrupt;
			M68KCONTEXT.execinfo&=0xFF67;
			uae4all_go_interrupt=0;
			m68k_irq_update(0);
		}
#endif
#ifdef DEBUG_M68K

		if (M68KCONTEXT.execinfo & 0x0080)
			mispcflags|=SPCFLAG_STOP;
#endif
                uae4all_prof_start(1);

		//cycles=((unsigned)(((double)(M68KCONTEXT.cycles_counter-cycles_actual))*cycles_factor))<<8;
		cycles=(M68KCONTEXT.cycles_counter-cycles_actual) * cycles_factor;

#ifdef DEBUG_INTERRUPTS
		dbgf("cycles=%i (%i) -> PC=%.6x\n",cycles>>8,nextevent - currcycle, _68k_getpc());
#endif


#ifdef NO_SHORT_EVENTS
#ifdef PROTECT_INFINITE
		unsigned cuentalo=0;
#endif
		do{
#endif
			do_cycles(cycles);
			if (mispcflags)
				if (do_specialties (cycles))
					return;
#ifndef DEBUG_M68K
#ifdef NO_SHORT_EVENTS
			cycles=2048;
#ifdef PROTECT_INFINITE
			cuentalo++;
			if (cuentalo>1024)
			{
				quit_program=2;
				return;
			}
#endif
		}while((nextevent - currcycle)<=2048);
#endif
		cycles_actual=M68KCONTEXT.cycles_counter;
#endif
                uae4all_prof_end(1);
	}
}