Exemplo n.º 1
0
PICO_INTERNAL void SekInit(void)
{
#ifdef EMU_C68K
  CycloneInit();
  memset(&PicoCpuCM68k,0,sizeof(PicoCpuCM68k));
  PicoCpuCM68k.IrqCallback=SekIntAck;
  PicoCpuCM68k.ResetCallback=SekResetAck;
  PicoCpuCM68k.UnrecognizedCallback=SekUnrecognizedOpcode;
  PicoCpuCM68k.flags=4;   // Z set
#endif
#ifdef EMU_M68K
  {
    void *oldcontext = m68ki_cpu_p;
    m68k_set_context(&PicoCpuMM68k);
    m68k_set_cpu_type(M68K_CPU_TYPE_68000);
    m68k_init();
    m68k_set_int_ack_callback(SekIntAckM68K);
    m68k_set_tas_instr_callback(SekTasCallback);
    //m68k_pulse_reset();
    m68k_set_context(oldcontext);
  }
#endif
#ifdef EMU_F68K
  {
    void *oldcontext = g_m68kcontext;
    g_m68kcontext = &PicoCpuFM68k;
    memset(&PicoCpuFM68k, 0, sizeof(PicoCpuFM68k));
    fm68k_init();
    PicoCpuFM68k.iack_handler = SekIntAckF68K;
    PicoCpuFM68k.sr = 0x2704; // Z flag
    g_m68kcontext = oldcontext;
  }
#endif
}
Exemplo n.º 2
0
void gen_init (void)
{
	int i;

	/* initialize CPUs */
	m68k_set_cpu_type (M68K_CPU_TYPE_68000);
	m68k_init();
	z80_init(0,0,0,z80_irq_callback);

	/* default 68000 mapping */
	for (i=16; i<24; i++)
	{
		m68k_readmap_8[i]	= ILLEGAL;
		m68k_readmap_16[i]	= ILLEGAL;
		m68k_writemap_8[i]	= ILLEGAL;
		m68k_writemap_16[i]	= ILLEGAL;
	}

	/* Z80, I/O, CONTROL */
	m68k_readmap_8[20]		= SYSTEM_IO;
	m68k_readmap_16[20]		= SYSTEM_IO;
	m68k_writemap_8[20]		= SYSTEM_IO;
	m68k_writemap_16[20]	= SYSTEM_IO;

  /* SEGA PICO */
  if (system_hw == SYSTEM_PICO)
  {
    m68k_readmap_8[16]	  = PICO_HW;
		m68k_readmap_16[16]	  = PICO_HW;
		m68k_writemap_8[16]	  = PICO_HW;
		m68k_writemap_16[16]	= PICO_HW;

		/* Notaz: there is no IO CONTROL area (Z80/YM2612/IO) */
    m68k_readmap_8[20]	  = UNUSED;
		m68k_readmap_16[20]	  = UNUSED;
		m68k_writemap_8[20]	  = UNUSED;
		m68k_writemap_16[20]  = UNUSED;
  }

	/* VDP */
	for (i=24; i<28; i++)
	{
		m68k_readmap_8[i]	= VDP;
		m68k_readmap_16[i]	= VDP;
		m68k_writemap_8[i]	= VDP;
		m68k_writemap_16[i]	= VDP;
	}

	/* WRAM */
	for (i=28; i<32; i++)
	{
		m68k_readmap_8[i]	= WRAM;
		m68k_readmap_16[i]	= WRAM;
		m68k_writemap_8[i]	= WRAM;
		m68k_writemap_16[i]	= WRAM;
	}
}
Exemplo n.º 3
0
// add a 68k cpu
void m1snd_add68k(long clock, void *handlers)
{
	rw68k = handlers;

	// $$$HACK: if this isn't called, model 1/2 games choke (IRQs don't get through)
	// if called up after Taito m68k-based games.
	m68k_init();

	timer_add_cpu(CPU_MC68000, clock, m68k_execute, m68k_cycles_run, m68k_end_timeslice, dummy_getctx, dummy_setctx, NULL);

	m68k_set_cpu_type(M68K_CPU_TYPE_68000);
	m68k_pulse_reset();
}
Exemplo n.º 4
0
void gen_init(void)
{
    int i;

    /* initialize CPUs */
    m68k_set_cpu_type(M68K_CPU_TYPE_68000);
    m68k_init();
    z80_init(0,z80_irq_callback);

    /* initialize 68k mapped memory */
    /* $000000-$7fffff is affected to cartridge area (see cart_hw.c) */
    /* $800000-$ffffff is affected to WRAM (see VDP DMA) */
    for (i=0x80; i<0x100; i++)
    {
        m68k_memory_map[i].base     = work_ram;
        m68k_memory_map[i].read8    = NULL;
        m68k_memory_map[i].read16   = NULL;
        m68k_memory_map[i].write8   = NULL;
        m68k_memory_map[i].write16  = NULL;
        zbank_memory_map[i].read    = NULL;
        zbank_memory_map[i].write   = NULL;
    }

    /* initialize 68k memory handlers */
    for (i=0x80; i<0xe0; i++)
    {
        /* illegal area */
        m68k_memory_map[i].read8    = m68k_lockup_r_8;
        m68k_memory_map[i].read16   = m68k_lockup_r_16;
        m68k_memory_map[i].write8   = m68k_lockup_w_8;
        m68k_memory_map[i].write16  = m68k_lockup_w_16;
        zbank_memory_map[i].read    = zbank_lockup_r;
        zbank_memory_map[i].write   = zbank_lockup_w;
    }

    /* Z80 bus (bank access) */
    zbank_memory_map[0xa0].read   = zbank_lockup_r;
    zbank_memory_map[0xa0].write  = zbank_lockup_w;

    /* I/O & Control registers */
    m68k_memory_map[0xa1].read8   = ctrl_io_read_byte;
    m68k_memory_map[0xa1].read16  = ctrl_io_read_word;
    m68k_memory_map[0xa1].write8  = ctrl_io_write_byte;
    m68k_memory_map[0xa1].write16 = ctrl_io_write_word;
    zbank_memory_map[0xa1].read   = zbank_read_ctrl_io;
    zbank_memory_map[0xa1].write  = zbank_write_ctrl_io;

    /* VDP (initially locked on models with TMSS) */
    if (!(config.tmss & 1))
    {
        for (i=0xc0; i<0xe0; i+=8)
        {
            m68k_memory_map[i].read8    = vdp_read_byte;
            m68k_memory_map[i].read16   = vdp_read_word;
            m68k_memory_map[i].write8   = vdp_write_byte;
            m68k_memory_map[i].write16  = vdp_write_word;
            zbank_memory_map[i].read    = zbank_read_vdp;
            zbank_memory_map[i].write   = zbank_write_vdp;
        }
    }

    /* SEGA PICO */
    if (system_hw == SYSTEM_PICO)
    {
        m68k_memory_map[0x80].read8   = pico_read_byte;
        m68k_memory_map[0x80].read16  = pico_read_word;
        m68k_memory_map[0x80].write8  = m68k_unused_8_w;
        m68k_memory_map[0x80].write16 = m68k_unused_16_w;

        /* there is no I/O area (Notaz) */
        m68k_memory_map[0xa1].read8   = m68k_read_bus_8;
        m68k_memory_map[0xa1].read16  = m68k_read_bus_16;
        m68k_memory_map[0xa1].write8  = m68k_unused_8_w;
        m68k_memory_map[0xa1].write16 = m68k_unused_16_w;

        /* page registers */
        pico_current = 0x00;
        pico_page[0] = 0x00;
        pico_page[1] = 0x01;
        pico_page[2] = 0x03;
        pico_page[3] = 0x07;
        pico_page[4] = 0x0F;
        pico_page[5] = 0x1F;
        pico_page[6] = 0x3F;
    }
}
Exemplo n.º 5
0
void gen_init(void)
{
  int i;

  /* initialize 68k */
  m68k_set_cpu_type(M68K_CPU_TYPE_68000);
  m68k_init();

  /* initialize Z80 */
  z80_init(0,z80_irq_callback);

  /* initialize 68k memory map */
  /* $000000-$7FFFFF is affected to cartridge area (see md_cart.c) */
  for (i=0x80; i<0x100; i++)
  {
    /* $800000-$FFFFFF is affected to WRAM (see VDP DMA) */
    m68k_memory_map[i].base     = work_ram;
    m68k_memory_map[i].read8    = NULL;
    m68k_memory_map[i].read16   = NULL;
    m68k_memory_map[i].write8   = NULL;
    m68k_memory_map[i].write16  = NULL;
    zbank_memory_map[i].read    = NULL;
    zbank_memory_map[i].write   = NULL;
  }

  /* initialize 68k memory handlers */
  for (i=0x80; i<0xe0; i++)
  {
    /* $800000-$DFFFFF : illegal area by default */
    m68k_memory_map[i].read8    = m68k_lockup_r_8;
    m68k_memory_map[i].read16   = m68k_lockup_r_16;
    m68k_memory_map[i].write8   = m68k_lockup_w_8;
    m68k_memory_map[i].write16  = m68k_lockup_w_16;
    zbank_memory_map[i].read    = zbank_lockup_r;
    zbank_memory_map[i].write   = zbank_lockup_w;
  }

  /* $A10000-$A1FFFF : I/O & Control registers */
  m68k_memory_map[0xa1].read8   = ctrl_io_read_byte;
  m68k_memory_map[0xa1].read16  = ctrl_io_read_word;
  m68k_memory_map[0xa1].write8  = ctrl_io_write_byte;
  m68k_memory_map[0xa1].write16 = ctrl_io_write_word;
  zbank_memory_map[0xa1].read   = zbank_read_ctrl_io;
  zbank_memory_map[0xa1].write  = zbank_write_ctrl_io;

  /* $C0xxxx, $C8xxxx, $D0xxxx, $D8xxxx : VDP ports */
  for (i=0xc0; i<0xe0; i+=8)
  {
    m68k_memory_map[i].read8    = vdp_read_byte;
    m68k_memory_map[i].read16   = vdp_read_word;
    m68k_memory_map[i].write8   = vdp_write_byte;
    m68k_memory_map[i].write16  = vdp_write_word;
    zbank_memory_map[i].read    = zbank_read_vdp;
    zbank_memory_map[i].write   = zbank_write_vdp;
  }

  /* MS COMPATIBILITY mode */
  if (system_hw == SYSTEM_PBC)
  {
    /* initialize Z80 read handler */
    /* NB: memory map & write handler are defined by cartridge hardware */
    z80_readmem = z80_sms_memory_r;

    /* initialize Z80 ports handlers */
    z80_writeport = z80_sms_port_w;
    z80_readport  = z80_sms_port_r;

    /* initialize MS cartridge hardware */
    sms_cart_init();
  }
  else
  {
    /* PICO hardware */
    if (system_hw == SYSTEM_PICO)
    {
      /* additional registers mapped to $800000-$80FFFF */
      m68k_memory_map[0x80].read8   = pico_read_byte;
      m68k_memory_map[0x80].read16  = pico_read_word;
      m68k_memory_map[0x80].write8  = m68k_unused_8_w;
      m68k_memory_map[0x80].write16 = m68k_unused_16_w;

      /* there is no I/O area (Notaz) */
      m68k_memory_map[0xa1].read8   = m68k_read_bus_8;
      m68k_memory_map[0xa1].read16  = m68k_read_bus_16;
      m68k_memory_map[0xa1].write8  = m68k_unused_8_w;
      m68k_memory_map[0xa1].write16 = m68k_unused_16_w;

      /* page registers */
      pico_current = 0x00;
      pico_page[0] = 0x00;
      pico_page[1] = 0x01;
      pico_page[2] = 0x03;
      pico_page[3] = 0x07;
      pico_page[4] = 0x0F;
      pico_page[5] = 0x1F;
      pico_page[6] = 0x3F;
    }

    /* initialize Z80 memory map */
    /* $0000-$3FFF is mapped to Z80 RAM (8K mirrored) */
    /* $4000-$FFFF is mapped to hardware but Z80.PC should never point there */
    for (i=0; i<64; i++)
    {
      z80_readmap[i] = &zram[(i & 7) << 10];
    }

    /* initialize Z80 memory handlers */
    z80_writemem  = z80_md_memory_w;
    z80_readmem   = z80_md_memory_r;

    /* initialize Z80 port handlers */
    z80_writeport = z80_unused_port_w;
    z80_readport  = z80_unused_port_r;

    /* initialize MD cartridge hardware */
    md_cart_init();
  }
}
Exemplo n.º 6
0
/*-------------------------------------------------------------------------

	Do all one time initializations.

---------------------------------------------------------------------------*/
void neogeo_initialize ( void )
{
	neogeo_audio_track = NULL;

	/* Create and register the watchdog timer */
	timer_create ( &neogeo_watchdog_timer, neogeo_watchdog_callback );
	timer_register ( &neogeo_watchdog_timer );

	/* Create and register the drawline timer. */
	timer_create ( &neogeo_drawline_timer, neogeo_drawline_callback );
	timer_register ( &neogeo_drawline_timer );

	/* Create and register the screen timer. */
	timer_create ( &neogeo_screen_timer, neogeo_screen_callback );
	timer_register ( &neogeo_screen_timer );

	/* Create and register the VBL timer */
	timer_create ( &neogeo_VBL_timer, neogeo_VBL_callback );
	timer_register ( &neogeo_VBL_timer );

	/* Create and register the HBL timer */
	timer_create ( &neogeo_HIRQ_timer, neogeo_HIRQ_callback );
	timer_register ( &neogeo_HIRQ_timer );

	/* Create and register the CDROM IRQ1 Timer */
	timer_create ( &neogeo_cdrom_irq1_timer, neogeo_cdrom_irq1_callback );
	timer_register ( &neogeo_cdrom_irq1_timer );

	/* Create and register the CDROM IRQ2 Timer */
	timer_create ( &neogeo_cdrom_irq2_timer, neogeo_cdrom_irq2_callback );
	timer_register ( &neogeo_cdrom_irq2_timer );

	/* Create and register the timer for audio commands */
	timer_create ( &neogeo_audio_command_timer, neogeo_audio_command_timer_callback );
	timer_register ( &neogeo_audio_command_timer );

	/* Create and register the YM2610 timers */
	timer_create ( &neogeo_ym2610_timer_a, neogeo_ym2610_timer_callback );
	timer_set_data ( &neogeo_ym2610_timer_a, 0 );
	timer_register ( &neogeo_ym2610_timer_a );

	timer_create ( &neogeo_ym2610_timer_b, neogeo_ym2610_timer_callback );
	timer_set_data ( &neogeo_ym2610_timer_b, 1 );
	timer_register ( &neogeo_ym2610_timer_b );

	/* Initialize the memory lookup table */
	memory_init_lookup();

	/* Initialize the 68000 emulation core */
	m68k_set_cpu_type ( M68K_CPU_TYPE_68000 );
	m68k_init();

	/* Inizialize the z80 core */
	z80_init ( 0, Z80_CLOCK, NULL, neogeo_z80_irq_callback );

	/* Initialize the YM2610 */
	YM2610Init ( 8000000, neogeo_audio_frequency, neogeo_PCM_RAM, 0x100000, YM2610TimerHandler, YM2610IrqHandler );

	/* Patch protection check 1 (Disc recognition) */
	m68k_debug_write_memory_16 ( 0xC0D280, 0x4E71 );

	/* Patch protection check 2 ("Now loading" screen) */
	m68k_debug_write_memory_16 ( 0xC0EB82, 0x4E71 );

	/* CD-Loading "speed hack" ^.^ */
	m68k_debug_write_memory_32 ( 0xC0E764, 0x4E722000 );
	m68k_debug_write_memory_16 ( 0xC0E768, 0x4E71 );

	/* Reset all internal register and variables to a known state */
	neogeo_cold_reset();

	/* Test if the underlying OS has accurate sleep() */
	neogeo_test_delay_accurate();
}
Exemplo n.º 7
0
void real_main (int argc, char **argv)
{
#ifdef USE_SDL
    SDL_Init (SDL_INIT_VIDEO | SDL_INIT_JOYSTICK 
#if !defined(NO_SOUND) && !defined(GP2X)
 			| SDL_INIT_AUDIO
#endif
	);
#endif
	getcwd(launchDir,250);
    /* PocketUAE prefs */
    default_prefs_uae (&currprefs);
    default_prefs();
#ifdef GP2X
    gp2x_init(argc, argv);
#endif
		// Set everthing to default and clear HD settings
		SetDefaultMenuSettings(1);
    loadconfig (1);

    if (! graphics_setup ()) {
		exit (1);
    }

    rtarea_init ();

	hardfile_install();

    if (! setup_sound ()) {
		write_log ("Sound driver unavailable: Sound output disabled\n");
		produce_sound = 0;
    }
    init_joystick ();

	int err = gui_init ();
	if (err == -1) {
	    write_log ("Failed to initialize the GUI\n");
	} else if (err == -2) {
	    exit (0);
	}
    if (sound_available && produce_sound > 1 && ! init_audio ()) {
		write_log ("Sound driver unavailable: Sound output disabled\n");
		produce_sound = 0;
    }

    /* Install resident module to get 8MB chipmem, if requested */
    rtarea_setup ();

    keybuf_init (); /* Must come after init_joystick */

#ifdef USE_AUTOCONFIG
    expansion_init ();
#endif

    memory_init ();

    filesys_install (); 
    native2amiga_install ();

    custom_init (); /* Must come after memory_init */
    DISK_init ();

    m68k_init(0);
    gui_update ();

#ifdef GP2X
    switch_to_hw_sdl(1);
#endif
	{
		start_program ();
	}
    leave_program ();
}
Exemplo n.º 8
0
int main(int argc, char **argv)
{
    int binary_file;
    void *binary_data;
    struct stat sb;
    struct tos_environment te;
    int argb = 1;
    
    verbose = 0;
    
    /* Program usage */
    if (argc < 2)
    {
        printf("Usage: tosemu [-v] <binary> [<args>]\n\n\t<binary> name of binary to execute\n");
        return -1;
    }
    
    /* Check if we want to be verbose */
    if (argc >= 3 && strcmp("-v", argv[1]) == 0)
    {
        verbose = -1;
        argb++;
    }

    /* Open the provided file */
    binary_file = open(argv[argb], O_RDONLY);
    if (binary_file == -1)
    {
        printf("Error: failed to open '%s'\n", argv[argc-1]);
        return -1;
    }
    
    /* Determine the file size */
    fstat(binary_file, &sb);
    
    /* Mmap the file into memory */
    binary_data = mmap(NULL, sb.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, binary_file, 0);
    if (!binary_data)
    {
        printf("Error: failed to mmap '%s'\n", argv[argc-1]);
        close(binary_file);
        return -1;
    }
    
    /* Check that the binary starts with the magix 0x601a sequence */
    if( ((char*)binary_data)[0] != 0x60 || ((char*)binary_data)[1] != 0x1a)
    {
        printf("Error: invalid magic in '%s'\n", argv[argc-1]);
        close(binary_file);
        return -1;
    }
    
    argb++;
    argv += argb;
    argc -= argb;

    /* Setup a TOS environment for the binary */
    if (init_tos_environment(&te, binary_data, sb.st_size, argc, argv))
    {
        printf("Error: failed to initialize TOS environment\n");
        close(binary_file);
        return -1;
    }
    
    /* Close the binary file */
    close(binary_file);

    /* Start execution */

    /* TODO init cpu */
    m68k_init();
    m68k_set_cpu_type(M68K_CPU_TYPE_68000);
    m68k_pulse_reset();

    /* TODO is this really correct, or should it be the MSP? If so, why does that not work? */
    m68k_set_reg(M68K_REG_ISP, 0x600); /* supervisor stack pointer */
    m68k_set_reg(M68K_REG_USP, te.size-4); /* user stack pointer */
    m68k_write_memory_32(te.size, 0x800); /* big endian 0x800 */
    m68k_set_reg(M68K_REG_PC, 0x900); /* Set PC to the binary entry point */
    disable_supervisor_mode();
    
    /* TODO exec */
    while (keepongoing) {
        m68k_execute(1);
    }
  
    /* Clean up */
    free_tos_environment(&te);
    
    return 0; 
}
Exemplo n.º 9
0
void real_main (int argc, char **argv)
{
	int numb;
	char pattern[100];
	char txt[100];
#ifdef USE_SDL
    SDL_Init (SDL_INIT_VIDEO | SDL_INIT_JOYSTICK 
#if !defined(NO_SOUND) && !defined(GP2X)
 			| SDL_INIT_AUDIO
#endif
	);
#endif
  // Initialize timebase
  g_uae_epoch = read_processor_time();
  syncbase = 1000000; // Microseconds

	//------------------------------------------
	//just safe the game conf file for later use
	//------------------------------------------
	if (argc > 1)
	{
		if (strlen(argv[1]) < 255)
		{
			strcpy(uae4all_game_conf_file0, argv[1]);

			strcpy(uae4all_game_conf_file1, argv[1]);
			strcpy(uae4all_game_conf_file2, argv[1]);
			strcpy(uae4all_game_conf_file3, argv[1]);
			strcpy(uae4all_game_conf_file4, argv[1]);
			strcpy(uae4all_game_conf_file5, argv[1]);
			strcpy(uae4all_game_conf_file6, argv[1]);
			strcpy(uae4all_game_conf_file7, argv[1]);
			getNumber(uae4all_game_conf_file0, "disk 1 of %", &numb);

			strcpy(pattern, "disk %");
			sprintf(txt, " of %d", numb);
			strcat(pattern, txt);
		    replaceNumber(uae4all_game_conf_file1, pattern, '2');

			strcpy(pattern, "disk %");
			sprintf(txt, " of %d", numb);
			strcat(pattern, txt);
		    replaceNumber(uae4all_game_conf_file2, pattern, '3');

			strcpy(pattern, "disk %");
			sprintf(txt, " of %d", numb);
			strcat(pattern, txt);
		    replaceNumber(uae4all_game_conf_file3, pattern, '4');

			strcpy(pattern, "disk %");
			sprintf(txt, " of %d", numb);
			strcat(pattern, txt);
		    replaceNumber(uae4all_game_conf_file4, pattern, '5');

			strcpy(pattern, "disk %");
			sprintf(txt, " of %d", numb);
			strcat(pattern, txt);
		    replaceNumber(uae4all_game_conf_file5, pattern, '6');

			strcpy(pattern, "disk %");
			sprintf(txt, " of %d", numb);
			strcat(pattern, txt);
		    replaceNumber(uae4all_game_conf_file6, pattern, '7');

			strcpy(pattern, "disk %");
			sprintf(txt, " of %d", numb);
			strcat(pattern, txt);
		    replaceNumber(uae4all_game_conf_file7, pattern, '8');

		}
	}

	getcwd(launchDir,250);
    /* PocketUAE prefs */
    default_prefs_uae (&currprefs);
    default_prefs();
#ifdef GP2X
    gp2x_init(argc, argv);
#endif
		// Set everthing to default and clear HD settings
		SetDefaultMenuSettings(1);
    loadconfig (1);

    if (! graphics_setup ()) {
		exit (1);
    }

    rtarea_init ();

	hardfile_install();

    if (! setup_sound ()) {
		write_log ("Sound driver unavailable: Sound output disabled\n");
		produce_sound = 0;
    }
    init_joystick ();

	int err = gui_init ();
	if (err == -1) {
	    write_log ("Failed to initialize the GUI\n");
	} else if (err == -2) {
	    exit (0);
	}
    if (sound_available && produce_sound > 1 && ! init_audio ()) {
		write_log ("Sound driver unavailable: Sound output disabled\n");
		produce_sound = 0;
    }

    /* Install resident module to get 8MB chipmem, if requested */
    rtarea_setup ();

    keybuf_init (); /* Must come after init_joystick */

#ifdef USE_AUTOCONFIG
    expansion_init ();
#endif

    memory_init ();

    filesys_install (); 
    native2amiga_install ();

    custom_init (); /* Must come after memory_init */
    DISK_init ();

    m68k_init(0);
    gui_update ();

#ifdef GP2X
    switch_to_hw_sdl(1);
#endif
	{
		start_program ();
	}
    leave_program ();
}
Exemplo n.º 10
0
void m68000_init(void)
{
    m68k_init();
	m68k_set_cpu_type(M68K_CPU_TYPE_68000);
    m68000_set_encrypted_range(0, memory_length_cpu1-1, memory_region_cpu1);
}