Exemple #1
0
void computer_writemem_byte(int cpu, int addr, int value)
{
    int oldcpu = cpu_getactivecpu();
    memory_set_context(cpu);
    MEMORY_WRITE(cpu, addr, value);
    if (oldcpu != cpu)
		memory_set_context(oldcpu);
}
Exemple #2
0
int computer_readmem_byte(int cpu, int addr)
{
    int oldcpu = cpu_getactivecpu(), result;
    memory_set_context(cpu);
    result = MEMORY_READ(cpu, addr);
    if (oldcpu != cpu)
    	memory_set_context(oldcpu);
    return result;
}
Exemple #3
0
static void c128_bankswitch (int reset)
{
    if (mmu_cpu != MMU_CPU8502)
    {
        if (!MMU_CPU8502)
        {
            DBG_LOG (1, "switching to z80",
                     ("active %d\n",cpu_getactivecpu()) );
            memory_set_context(0);
            c128_bankswitch_z80();
            memory_set_context(1);
            cpunum_set_input_line(0, INPUT_LINE_HALT, CLEAR_LINE);
            cpunum_set_input_line(1, INPUT_LINE_HALT, ASSERT_LINE);
        }
        else
        {
            DBG_LOG (1, "switching to m6502",
                     ("active %d\n",cpu_getactivecpu()) );
            memory_set_context(1);
            c128_bankswitch_128(reset);
            memory_set_context(0);
            cpunum_set_input_line(0, INPUT_LINE_HALT, ASSERT_LINE);
            cpunum_set_input_line(1, INPUT_LINE_HALT, CLEAR_LINE);

            /* NPW 19-Nov-2005 - In the C128, CPU #0 starts out and hands over
             * control to CPU #1.  CPU #1 seems to execute garbage from 0x0000
             * up to 0x1100, at which point it finally hits some code
             * (presumably set up by CPU #1.) This always worked, but when I
             * changed the m8502 CPU core to use an internal memory map, it
             * started BRK-ing forever when trying to execute 0x0000.
             *
             * I am not sure whether the C128 actually executes this invalid
             * memory or if this is a bug in the C128 driver.  In any case, the
             * driver used to work with this behavior, so I am doing this hack
             * where I set CPU #1's PC to 0x1100 on reset.
             */
            if (cpunum_get_reg(1, REG_PC) == 0x0000)
                cpunum_set_reg(1, REG_PC, 0x1100);
        }
        mmu_cpu = MMU_CPU8502;
        return;
    }
    if (!MMU_CPU8502)
        c128_bankswitch_z80();
    else
        c128_bankswitch_128(reset);
}
Exemple #4
0
/* to do support weired comparator settings */
static void hp48_config(void)
{
    int begin, end;

    /* lowest priority first */
    memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0, 0xfffff, 0, 0, MRA8_ROM);
    memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0, 0xfffff, 0, 0, MWA8_NOP);
    if (hp48s.mem[CARD1].adr!=-1)
    {
        begin=hp48s.mem[CARD1].adr&hp48s.mem[CARD1].size&~0xfff;
        end=begin|(hp48s.mem[CARD1].size^0xff000)|0xfff;
        if (end!=begin)
        {
            memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, begin, end, 0, 0, MRA8_BANK1);
            memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, begin, end, 0, 0, MWA8_BANK1);
            memory_set_bankptr(1, hp48_card1);
        }
    }
    if (hp48s.mem[CARD2].adr!=-1) {
        begin=hp48s.mem[CARD2].adr&hp48s.mem[CARD2].size&~0xfff;
        end=begin|(hp48s.mem[CARD2].size^0xff000)|0xfff;
        if (end!=begin) {
            memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, begin, end, 0, 0, MRA8_BANK2);
            memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, begin, end, 0, 0, MWA8_BANK2);
            memory_set_bankptr(2, hp48_card2);
        }
    }
    if (hp48s.mem[RAM].adr!=-1) {
        begin=hp48s.mem[RAM].adr&hp48s.mem[RAM].size&~0xfff;
        end=begin|(hp48s.mem[RAM].size^0xff000)|0xfff;
        if (end!=begin) {
            memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, begin, end, 0, 0, MRA8_BANK3);
            memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, begin, end, 0, 0, MWA8_BANK3);
            memory_set_bankptr(3, hp48_ram);
        }
    }
    if (hp48s.mem[HDW].adr!=-1)
    {
        memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, hp48s.mem[HDW].adr&~0x3f,
                                     hp48s.mem[HDW].adr|0x3f, 0, 0, hp48_read);
        memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, hp48s.mem[HDW].adr&~0x3f,
                                      hp48s.mem[HDW].adr|0x3f, 0, 0, hp48_write);
    }
    memory_set_context(0);
}
Exemple #5
0
INLINE void set_cpu_context(int cpunum)
{
	int newfamily = cpu[cpunum].family;
	int oldcontext = cpu_active_context[newfamily];

	/* if we need to change contexts, save the one that was there */
	if (oldcontext != cpunum && oldcontext != -1)
		(*cpu[oldcontext].intf.get_context)(cpu[oldcontext].context);

	/* swap memory spaces */
	activecpu = cpunum;
	memory_set_context(cpunum);

	/* if the new CPU's context is not swapped in, do it now */
	if (oldcontext != cpunum)
	{
		(*cpu[cpunum].intf.set_context)(cpu[cpunum].context);
		cpu_active_context[newfamily] = cpunum;
	}
}