Esempio n. 1
0
/* This is the final leg of main() */
int main_loop(const char *filename, system_t type)
{
   vidinfo_t video;

   /* register shutdown, in case of assertions, etc. */
//   atexit(shutdown_everything);

   //if (config.open()) // JMH
   //   return -1;

   if (osd_init())
      return -1;

   osd_getvideoinfo(&video);
   if (vid_init(video.default_width, video.default_height, video.driver))
      return -1;
	//log printf("vid_init done\n");

   console.nextfilename = strdup(filename);
   console.nexttype = type;

//   while (false == console.quit)
//   {
//emu_printf("internal_insert in loop\n");    
      if (internal_insert(console.nextfilename, console.nexttype))
         return 1;
//   }

   return 0;
}
Esempio n. 2
0
extern "C" DLL_EXPORT void CDECL_CALL EmuMain(char *rom)
{
    int i;
    char *s;

    /* If we have special perms, drop them ASAP! */
    vid_preinit();

    init_exports();

    s = strdup(".");
    sys_sanitize(s);
    sys_initpath(s);

    for (i = 0; defaultconfig[i]; i++)
        rc_command(defaultconfig[i]);

    /* FIXME - make interface modules responsible for atexit() */
    atexit(shutdown);
    catch_signals();
    vid_init();
    pcm_init();

    rom = strdup(rom);
    sys_sanitize(rom);

    loader_init(rom);

    emu_reset();
    emu_run();
}
Esempio n. 3
0
int gbcInitialize(int rate)
{
    vid_init();
    pcm_init(rate);

    return 1;
}
Esempio n. 4
0
//main function, execution starts here
main()
{
    int i = 0;
    vid_init();//initialize video

    printf("MTX starts in main()\n");
    init(); // initialize and create P0 as running
    set_vector(80, int80h);

    kfork("/bin/u1");     // P0 kfork() P1

    set_vector(9, kbinth);
    kbd_init();

    //timer init
    lock();
    set_vector(8,tinth);
    timer_init();

    while(1)
    {
      unlock();
      if(readyQueue)
          tswitch();
      else
          halt();
   }
}
Esempio n. 5
0
void MTXInit() {

	//initialize the screen
	vid_init();

	printf("\n");
	printf("MTX Starting in main\n\r");
	init();
	printf("Init complete\n\r");
	setInts();

}
Esempio n. 6
0
int dc_main(void)
{
    unsigned long bin_size = 0xfeedbeef;
    char tmp_str[8];

    vid_init(vid_check_cable(), DM_640x480, PM_RGB565);
    vid_clear(0,100,0);

    /* Relocate the 1st_read.bin */
    bin_size = *((unsigned long *) REAL_LOAD_POINT);
    uint_to_string(bin_size, tmp_str);
    bfont_draw_str(vram_s+10*640+20, 640, "bin_size = ");
    bfont_draw_str(vram_s+50*640+20, 640, tmp_str);
    memmove((unsigned char *) REAL_LOAD_POINT, (unsigned char *) LOADED_POINT, bin_size);

    dbr_set(ubc_works);
    vbr_set(vbr_buffer);

    *UBC_R_BARA = (unsigned int) BREAKPOINT;
    *UBC_R_BAMRA = (1<<2);
    *UBC_R_BBRA = (1<<5) | (1<<4) | (1<<3) | (1<<2);
    *UBC_R_BRCR = (1<<10) | (1<<15) | 1;

    ubc_wait();
    ubc_wait();
    ubc_wait();
    ubc_wait();   

    vid_clear(50,0,50);

    disable_cache();
    (*(void (*)()) REAL_LOAD_POINT) ();

    vid_init(vid_check_cable(), DM_640x480, PM_RGB565);
    vid_clear(100,0,0);
    bfont_draw_str(vram_s+100*640+20, 640, "[UBC] DANGER! We're returned from the game!");
    while(1);
}
Esempio n. 7
0
int main(int argc, char* argv[]) {
	script_init();
	load_ini();
	engine_init(); // includes ttf init too
	vid_init();

	dump_lua();

	game_loop();
	
	engine_shutdown();
	script_shutdown();
	return 0;
}
Esempio n. 8
0
void emu_init(int game_id)
{
	vid_init();
	pcm_init();
	vid_preinit();

	// load ROM & load palette 
	bitbox_rom_load(game_id);

	emu_reset();

	vid_begin();
	lcd_begin();
	emu_started = 1; // at the end , start line blitting
}
Esempio n. 9
0
static int gnuboy_main(const char *rom)
{
    rb->lcd_puts(0,0,"Init video");
    vid_init();
    rb->lcd_puts(0,1,"Init sound");
    pcm_init();
    rb->lcd_puts(0,2,"Loading rom");
    loader_init(rom);
    if(shut)
        return PLUGIN_ERROR;
    rb->lcd_puts(0,3,"Emu reset");
    emu_reset();
    rb->lcd_puts(0,4,"Emu run");
    rb->lcd_clear_display();
    rb->lcd_update();
    emu_run();

    /* never reached */
    return PLUGIN_OK;
}
Esempio n. 10
0
main()
{
    vid_init();
    printf("MTX starts in main()\n");
    init();      // initialize and create P0 as running
    set_vec(80,int80h);
    kfork("/bin/u1");     // P0 kfork() P1

    lock();
    set_vec(8,tinth);
    timer_init();

    while(1){
      printf("P0 running\n");
      if (nproc==2 && proc[1].status != READY)
      printf("no runable process, system halts\n");
      while(!readyQueue);
      printf("P0 switch process\n");
      tswitch();   // P0 switch to run P1
   }
}
Esempio n. 11
0
File: t.c Progetto: jakeknott/cs460
main()
{
    char m;
    vid_init();
    printf("MTX starts in main()\n");
    init();      // initialize and create P0 as running
    set_vector(80, int80h);

    set_vector(12, s0inth); // vector 12 for COM1
    set_vector(11, s1inth); // vector 11 for COM2
    sinit();

    set_vector(9, kbinth);
    kbd_init();


    lock();
    set_vector(8, tinth);
    timer_init();


    mode = LIVE; //used for demoing the time working, set to DEMO to see four procs switch by themselves

    kfork("/bin/u1");     // P0 kfork() P1

    if(mode == DEMO)
    {
        kfork("/bin/u1");
        kfork("/bin/u1");
        kfork("/bin/u1");
    }

    while(1){
        //printf("P0 running\n");
        while(!readyQueue);
            //printf("P0 switch process\n");
            running->status = READY;
            tswitch();         // P0 switch to run P1
   }
}
Esempio n. 12
0
int hardware_periph_init() {
	/* Init sound */
	spu_init();
	spu_dma_init();

	/* Init CD-ROM.. NOTE: NO GD-ROM SUPPORT. ONLY CDs/CDRs. */
	cdrom_init();

	/* Setup maple bus */
	maple_init();

	/* Init video */
	vid_init(DEFAULT_VID_MODE, DEFAULT_PIXEL_MODE);

	/* Setup network (this won't do anything unless we enable netcore) */
	bba_init();
	la_init();

	initted = 2;

	return 0;
}
Esempio n. 13
0
File: main.c Progetto: deadbok/aMOS
int main(void)
{
	init_pmm();

	if (init_mm())
		return(1);

	vid_init();

	vid_set_attr(FG_COLOR, RED);

	printf("\naMOS BOSS V.%s %s\n", STRING_VERSION, BUILD_ARCH);
	printf("Build %s %s by %s on %s\n\n", COMPILE_DATE, COMPILE_TIME, COMPILE_BY, COMPILE_HOST);

	vid_set_attr(FG_COLOR, WHITE);

	init_pit();

	init_tss();

	if (init_intr())
		return(1);

	init_cpu();

	if (init_sched())
		return(1);

	init_fd();

	printf("System memory: %d Mb\n\n", (int)pmm_get_size_mb());
	printf("Free kernel mem: %d bytes\nUsed kernel mem: %d bytes\n", (int)get_free_mem(), (int)get_used_mem());

	for (;;) {}
		
	return(0);
}
Esempio n. 14
0
int app_main(int argc,char** argv)
{
    char * rom;		
/*
		 to use the medios browser you have to define USE_MEDIOS_BROWSER. This completely changes the way the emu works, it mapps button_off
		 to exit the emulator and return to the browser, While exit in the emu ingame menu still completly exits.
		 Cj tell me if you want to do it this way and also let me know if it works for you?
*/

    int i;
    for(i=0;i<argc;i++) printf("%d:%s\n",i,argv[i]);

#ifdef USE_MEDIOS_BROWSER
	while(1)
	{
		osd_setEntirePalette(gui_pal,256);
		gfx_planeSetSize(BMAP1,LCD_WIDTH,LCD_HEIGHT,8);
		gfx_planeSetPos(BMAP1,X_OFFSET,Y_OFFSET);
		iniIcon();
		gfx_openGraphics();
		clearScreen(COLOR_WHITE);
		gfx_fontSet(STD6X9);
		if(argc<2) {
                   ini_file_browser();
		   rom=browse("/",1);
		}
                else {
                  rom = (char *)malloc(MAX_PATH);
                  strcpy(rom,argv[1]);
                }
		if (rom=='0')
		{
			cleanup();
			reload_firmware();
		}
		gfx_openGraphics();
		OSD_BITMAP1_ADDRESS = (int)gfx_planeGetBufferOffset(BMAP1);
		gfx_planeSetSize(BMAP1,160,144,8);
		gfx_planeSetPos(BMAP1,(LCD_WIDTH-OSD_BITMAP1_WIDTH) + X_OFFSET,(LCD_HEIGHT-OSD_BITMAP1_HEIGHT)/2 + Y_OFFSET);
		
		gfx_fillRect(0x00,0,0,160,144);
		
		gfx_fontSet(10);   

    vid_init();
    pcm_init();

    //rom = (char *)malloc(MAX_PATH);
    printf("Rom name : %s\n",rom);
    
    loader_init(rom);

    emu_reset();
    emu_run();
	} 
#endif
#ifndef USE_MEDIOS_BROWSER
		//this uses the avBoy browser and is the default
    gfx_openGraphics();
    OSD_BITMAP1_ADDRESS = (int)gfx_planeGetBufferOffset(BMAP1);
    gfx_planeSetSize(BMAP1,160,144,8);
		gfx_planeSetPos(BMAP1,(LCD_WIDTH-OSD_BITMAP1_WIDTH) + X_OFFSET,(LCD_HEIGHT-OSD_BITMAP1_HEIGHT)/2 + Y_OFFSET);
    
    gfx_fillRect(0x00,0,0,160,144);

    gfx_fontSet(10);   
    
    vid_init();
    pcm_init();
    
    rom = (char *)malloc(MAX_PATH);
    
    printf("argc = %d, argv = %x\n",argc,argv);

    if(argc<2) browser(rom);
    else strcpy(rom,argv[1]);
    
    //browser(rom);
    printf("Rom name : %s (%x,%x)\n",rom,rom,rom+MAX_PATH);

    loader_init(rom);

    emu_reset();
    emu_run();
#endif
    printf("before return\n");
    return 0;
}
Esempio n. 15
0
int
main (int argc, char* argv[])
{
  int cable_type, quit = 0;
  float rot1 = 0.0, rot2 = 0.0, rot3 = 0.0;
  kos_img_t front_txr, back_txr, tmp_img;
  pvr_ptr_t texaddr;
  GLuint texture[8];
  int blendfunc = 2;
  float eye_rot = 0;

  cable_type = vid_check_cable ();
  
  if (cable_type == CT_VGA)
    vid_init (DM_640x480_VGA, PM_RGB565);
  else
    vid_init (DM_640x480_PAL_IL, PM_RGB565);
  
  init_pvr ();

  glKosInit ();

  sphere = mkspheredata (3, &nstrip, &stripl);

  glGenTextures (8, &texture[0]);

#if 1
  kmg_to_img ("/rd/sky1.kmg", &front_txr);
  texaddr = pvr_mem_malloc (front_txr.byte_count);
  pvr_txr_load_kimg (&front_txr, texaddr, PVR_TXRFMT_VQ_ENABLE);
  kos_img_free (&front_txr, 0);
  
  glBindTexture (GL_TEXTURE_2D, texture[0]);
  glKosTex2D (GL_RGB565_TWID | GL_VQ_ENABLE, front_txr.w, front_txr.h,
	      texaddr);

  kmg_to_img ("/rd/sky2o.kmg", &back_txr);
  texaddr = pvr_mem_malloc (back_txr.byte_count);
  pvr_txr_load_kimg (&back_txr, texaddr, PVR_TXRFMT_VQ_ENABLE);
  kos_img_free (&back_txr, 0);

  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);

  glBindTexture (GL_TEXTURE_2D, texture[1]);
  glKosTex2D (GL_ARGB4444_TWID | GL_VQ_ENABLE, back_txr.w, back_txr.h, texaddr);

  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
  
  glBindTexture (GL_TEXTURE_2D, texture[2]);
  kmg_to_img ("/rd/sky3.kmg", &tmp_img);
  texaddr = pvr_mem_malloc (tmp_img.byte_count);
  pvr_txr_load_kimg (&tmp_img, texaddr, PVR_TXRFMT_VQ_ENABLE);
  glKosTex2D (GL_RGB565_TWID | GL_VQ_ENABLE, tmp_img.w, tmp_img.h, texaddr);

  glBindTexture (GL_TEXTURE_2D, texture[3]);
  kmg_to_img ("/rd/sky4.kmg", &tmp_img);
  texaddr = pvr_mem_malloc (tmp_img.byte_count);
  pvr_txr_load_kimg (&tmp_img, texaddr, PVR_TXRFMT_VQ_ENABLE);
  glKosTex2D (GL_RGB565_TWID | GL_VQ_ENABLE, tmp_img.w, tmp_img.h, texaddr);

  glBindTexture (GL_TEXTURE_2D, texture[4]);
  kmg_to_img ("/rd/sky5.kmg", &tmp_img);
  texaddr = pvr_mem_malloc (tmp_img.byte_count);
  pvr_txr_load_kimg (&tmp_img, texaddr, PVR_TXRFMT_VQ_ENABLE);
  glKosTex2D (GL_RGB565_TWID | GL_VQ_ENABLE, tmp_img.w, tmp_img.h, texaddr);

  glBindTexture (GL_TEXTURE_2D, texture[5]);
  kmg_to_img ("/rd/sky6.kmg", &tmp_img);
  texaddr = pvr_mem_malloc (tmp_img.byte_count);
  pvr_txr_load_kimg (&tmp_img, texaddr, PVR_TXRFMT_VQ_ENABLE);
  glKosTex2D (GL_RGB565_TWID | GL_VQ_ENABLE, tmp_img.w, tmp_img.h, texaddr);

  glBindTexture (GL_TEXTURE_2D, texture[6]);
  kmg_to_img ("/rd/sky7.kmg", &tmp_img);
  texaddr = pvr_mem_malloc (tmp_img.byte_count);
  pvr_txr_load_kimg (&tmp_img, texaddr, PVR_TXRFMT_VQ_ENABLE);
  glKosTex2D (GL_RGB565_TWID | GL_VQ_ENABLE, tmp_img.w, tmp_img.h, texaddr);

  glBindTexture (GL_TEXTURE_2D, texture[7]);
  kmg_to_img ("/rd/sky8.kmg", &tmp_img);
  texaddr = pvr_mem_malloc (tmp_img.byte_count);
  pvr_txr_load_kimg (&tmp_img, texaddr, PVR_TXRFMT_VQ_ENABLE);
  glKosTex2D (GL_RGB565_TWID | GL_VQ_ENABLE, tmp_img.w, tmp_img.h, texaddr);

#else  
  png_to_img ("/rd/sky1.png", PNG_MASK_ALPHA, &front_txr);
  texaddr = pvr_mem_malloc (front_txr.w * front_txr.h * 2);
  pvr_txr_load_kimg (&front_txr, texaddr, PVR_TXRLOAD_INVERT_Y);
  kos_img_free (&front_txr, 0);
  
  glBindTexture (GL_TEXTURE_2D, texture[0]);
  glKosTex2D (GL_ARGB1555_TWID, front_txr.w, front_txr.h, texaddr);

  png_to_img ("/rd/sky2o.png", PNG_MASK_ALPHA, &back_txr);
  texaddr = pvr_mem_malloc (back_txr.w * back_txr.h * 2);
  pvr_txr_load_kimg (&back_txr, texaddr, PVR_TXRLOAD_INVERT_Y);
  kos_img_free (&back_txr, 0);

  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);

  glBindTexture (GL_TEXTURE_2D, texture[1]);
  glKosTex2D (GL_ARGB1555_TWID, back_txr.w, back_txr.h, texaddr);

  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
  glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
  
  glBindTexture (GL_TEXTURE_2D, texture[2]);
  texaddr = pvr_mem_malloc (TEXSIZE * TEXSIZE * 2);
  png_to_texture ("/rd/sky3.png", texaddr, PNG_NO_ALPHA);
  glKosTex2D (GL_RGB565_TWID, TEXSIZE, TEXSIZE, texaddr);

  glBindTexture (GL_TEXTURE_2D, texture[3]);
  texaddr = pvr_mem_malloc (TEXSIZE * TEXSIZE * 2);
  png_to_texture ("/rd/sky4.png", texaddr, PNG_NO_ALPHA);
  glKosTex2D (GL_RGB565_TWID, TEXSIZE, TEXSIZE, texaddr);

  glBindTexture (GL_TEXTURE_2D, texture[4]);
  texaddr = pvr_mem_malloc (TEXSIZE * TEXSIZE * 2);
  png_to_texture ("/rd/sky5.png", texaddr, PNG_NO_ALPHA);
  glKosTex2D (GL_RGB565_TWID, TEXSIZE, TEXSIZE, texaddr);

  glBindTexture (GL_TEXTURE_2D, texture[5]);
  texaddr = pvr_mem_malloc (TEXSIZE * TEXSIZE * 2);
  png_to_texture ("/rd/sky6.png", texaddr, PNG_NO_ALPHA);
  glKosTex2D (GL_RGB565_TWID, TEXSIZE, TEXSIZE, texaddr);

  glBindTexture (GL_TEXTURE_2D, texture[6]);
  texaddr = pvr_mem_malloc (TEXSIZE * TEXSIZE * 2);
  png_to_texture ("/rd/sky7.png", texaddr, PNG_NO_ALPHA);
  glKosTex2D (GL_RGB565_TWID, TEXSIZE, TEXSIZE, texaddr);

  glBindTexture (GL_TEXTURE_2D, texture[7]);
  texaddr = pvr_mem_malloc (TEXSIZE * TEXSIZE * 2);
  png_to_texture ("/rd/sky8.png", texaddr, PNG_NO_ALPHA);
  glKosTex2D (GL_RGB565_TWID, TEXSIZE, TEXSIZE, texaddr);
#endif
  
  glEnable (GL_DEPTH_TEST);
  glEnable (GL_CULL_FACE);
  glEnable (GL_TEXTURE_2D);
  glShadeModel (GL_SMOOTH);
  glClearDepth (1.0f);
  glDepthFunc (GL_LEQUAL);
  
  glMatrixMode (GL_PROJECTION);
  glLoadIdentity ();
  gluPerspective (60.0,			/* Field of view in degrees.  */
		  640.0 / 480.0,	/* Aspect ratio.  */
		  1.0,			/* Z near.  */
		  50.0);		/* Z far.  */

  glMatrixMode (GL_MODELVIEW);
  
  while (!quit)
    {
      MAPLE_FOREACH_BEGIN (MAPLE_FUNC_CONTROLLER, cont_state_t, st)
        {
	  if (st->buttons & CONT_START)
	    quit = 1;
	  
	  eye_pos[0] = st->joyx / 25.0;
	  eye_pos[1] = st->joyy / 25.0;
	  eye_pos[2] = 5 * sin (eye_rot);
	  
	  if (st->buttons & CONT_A)
	    blendfunc = 0;
	  else if (st->buttons & CONT_B)
	    blendfunc = 1;
	  else if (st->buttons & CONT_X)
	    blendfunc = 2;
	}
      MAPLE_FOREACH_END ()
      
      draw_vectors = 10;
      
      glLoadIdentity ();
      gluLookAt (eye_pos[0], eye_pos[1], eye_pos[2],	/* Eye position.  */
		 0.0,   0.0,   0.0,			/* Centre.  */
		 0.0,   1.0,   0.0);			/* Up.  */

      glGetFloatv (GL_MODELVIEW_MATRIX, &camera[0][0]);

      invcamera[0][0] = camera[0][0];
      invcamera[0][1] = camera[1][0];
      invcamera[0][2] = camera[2][0];
      invcamera[0][3] = 0.0;

      invcamera[1][0] = camera[0][1];
      invcamera[1][1] = camera[1][1];
      invcamera[1][2] = camera[2][1];
      invcamera[1][3] = 0.0;

      invcamera[2][0] = camera[0][2];
      invcamera[2][1] = camera[1][2];
      invcamera[2][2] = camera[2][2];
      invcamera[2][3] = 0.0;

      invcamera[3][0] = 0.0;
      invcamera[3][1] = 0.0;
      invcamera[3][2] = 0.0;
      invcamera[3][3] = 1.0;

      /*dbgio_printf ("inverted camera orthogonality: %f %f %f\n",
		    (double) vec_dot (invcamera[0], invcamera[1]),
		    (double) vec_dot (invcamera[1], invcamera[2]),
		    (double) vec_dot (invcamera[2], invcamera[0]));*/

      /*dbgio_printf ("Inverted camera matrix:\n");
      for (i = 0; i < 4; i++)
	{
	  dbgio_printf ("[ %f %f %f %f ]\n",
                	(double) invcamera[0][i], (double) invcamera[1][i],
	        	(double) invcamera[2][i], (double) invcamera[3][i]);
	}*/

      glKosBeginFrame ();

      /*glPushMatrix ();
      glTranslatef (-camera[3][0], -camera[3][1], -camera[3][2]);*/
      render_cube (&texture[2]);
      /*glPopMatrix ();*/
      
      glPushMatrix ();
      
      #if 1
      glRotatef (rot1, 0.0, 1.0, 0.0);
      rot1 += 0.7;
      glRotatef (rot2, 1.0, 0.0, 0.0);
      rot2 += 0.29;
      #else
      glRotatef (rot1, 0.0, 0.0, 1.0);
      rot1 += 0.7;
      #endif
      
      if (rot1 >= 360)
        rot1 -= 360;

      if (rot2 >= 360)
        rot2 -= 360;
      
      eye_rot += 0.05;
      if (eye_rot >= 2 * M_PI)
        eye_rot -= 2 * M_PI;
      
      blob_phase += 0.05;
      if (blob_phase >= 24 * M_PI)
        blob_phase -= 24 * M_PI;
      
      /* Render front.  */
      glBindTexture (GL_TEXTURE_2D, texture[0]);
      glTexEnvi (GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE);

      #if 1
      render_blob (sphere, nstrip, stripl, 1);
      #else
      render_torus (1.0, 0.6, 1);
      #endif
            
      glPushMatrix ();
      glRotatef (rot3, 1.0, 0.0, 0.0);
      glTranslatef (2.9, 0.0, 0.0);
      render_torus (0.8, 0.5, 1);
      glPopMatrix ();
      glPushMatrix ();
      glRotatef (-rot3, 1.0, 0.0, 0.0);
      glTranslatef (-2.9, 0.0, 0.0);
      render_torus (0.8, 0.5, 1);
      glPopMatrix ();
      
      glKosFinishList ();

      /* Render back.  */
      glBindTexture (GL_TEXTURE_2D, texture[1]);
      glTexEnvi (GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE);
      if (blendfunc == 0)
        glBlendFunc (GL_SRC_ALPHA, GL_ZERO);
      else if (blendfunc == 1)
        glBlendFunc (GL_ZERO, GL_ONE_MINUS_SRC_ALPHA);
      else
        glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	
      #if 1
      //glDisable (GL_TEXTURE_2D);
      render_blob (sphere, nstrip, stripl, 0);
      //glEnable (GL_TEXTURE_2D);
      #else
      render_torus (1.0, 0.6, 0);
      #endif

      glPushMatrix ();
      glRotatef (rot3, 1.0, 0.0, 0.0);
      glTranslatef (2.9, 0.0, 0.0);
      render_torus (0.8, 0.5, 0);
      glPopMatrix ();
      glPushMatrix ();
      glRotatef (-rot3, 1.0, 0.0, 0.0);
      glTranslatef (-2.9, 0.0, 0.0);
      render_torus (0.8, 0.5, 0);
      glPopMatrix ();

      rot3 += 1;
      if (rot3 >= 360)
        rot3 -= 360;

      glPopMatrix ();
      
      glKosFinishFrame ();
    }
  
  glKosShutdown ();
  
  pvr_shutdown ();
  
  vid_shutdown ();
  /* Make dc-load look nicer.  */
  vid_init (DM_640x480_PAL_IL, PM_RGB565);

  return 0;
}
Esempio n. 16
0
main(int argc,char *argv[])
{
	char huge *sptemp;
	int	huge *ip;
	unsigned int u;
	char	huge *cp;
	int	a,b,c,d,e,f,g,x,y,z;
	#ifdef DEBUG
	fr=fopen("tmp","wt");
	#endif
	indemo=1;

	dis_partstart();
	sprintf(tmpname,"%s.00M",scene);
	if(!indemo) printf("Loading materials %s...\n",tmpname);
	scene0=scenem=readfile(tmpname);

	memcpy(scene0+16+192*3,bg+16,64*3);
	bg2=halloc(16384,4);	
	for(u=z=0;z<4;z++)
	{
		for(y=0;y<200;y++)
		{
			for(x=z;x<320;x+=4)
			{
				a=bg[16+768+x+y*320];
				bg2[u++]=a;
			}
		}
	}
	memcpy(bg,bg2,64000);
	hfree(bg2);

	if(scene0[15]=='C') city=1;
	if(scene0[15]=='R') city=2;
	ip=(int huge *)(scene0+LONGAT(scene0+4));
	conum=d=*ip++;
	for(f=-1,c=1;c<d;c++)
	{	
		e=*ip++;
		if(e>f)
		{
			f=e;
			sprintf(tmpname,"%s.%03i",scene,e);
			if(!indemo) printf("Loading %s... ",tmpname);
			co[c].o=vis_loadobject(tmpname);
			memset(co[c].o->r,0,sizeof(rmatrix));
			memset(co[c].o->r0,0,sizeof(rmatrix));
			co[c].index=e;
			co[c].on=0;
			if(!indemo) printf("(co[%i]:%s)\n",c,co[c].o->name);
		}
		else
		{
			if(!indemo) printf("Copying %s.%03i... ",scene,e);
			for(g=0;g<c;g++) if(co[g].index==e) break;
			memcpy(co+c,co+g,sizeof(struct s_co));
			co[c].o=getmem(sizeof(object));
			memcpy(co[c].o,co[g].o,sizeof(object));
			co[c].o->r=getmem(sizeof(rmatrix));
			co[c].o->r0=getmem(sizeof(rmatrix));
			memset(co[c].o->r,0,sizeof(rmatrix));
			memset(co[c].o->r0,0,sizeof(rmatrix));
			co[c].on=0;
			if(!indemo) printf("(co[%i]:%s)\n",c,co[c].o->name);
		}
	}
	co[0].o=&camobject;
	camobject.r=&cam;
	camobject.r0=&cam;

	sprintf(tmpname,"%s.0AA",scene);
	if(!indemo) printf("Loading animations...\n",tmpname);
	ip=readfile(tmpname);
	while(*ip)
	{
		a=*ip;
		if(a==-1) break;
		sprintf(tmpname,"%s.0%c%c",scene,a/10+'A',a%10+'A');
		if(!indemo) printf("Scene: %s ",tmpname);
		scenelist[scl].data=readfile(tmpname);
		printf("(%i:@%Fp)\n",scl,scenelist[scl].data);
		scl++;
		ip+=2;
	}

	if(!indemo) 
	{
		printf("Press any key to continue...");
		getch();
	}	

	resetscene();

	for(;;)
	{
		_asm
		{
			mov	bx,6
			int	0fch
			mov	a,cx
			mov	b,bx
		}
		if(a>10 && b>46) break;
		if(dis_exit()) return;
	}

 	vid_init(3); ////// oversample x 4
	cp=(char *)(scenem+16);
	vid_setpal(cp);
	vid_window(0L,319L,25L,174L,512L,9999999L);
	
	dis_setcopper(2,copper2);
	dis_partstart();
	xit=0;
	coppercnt=0;
	syncframe=0;
	avgrepeat=1;
	cl[0].ready=0;
	cl[1].ready=0;
	cl[2].ready=0;
	cl[3].ready=1;
	while(!dis_exit() && !xit)
	{
		int fov;
		int onum;
		long pflag;
		long dis;
		long l;
		object *o;
		rmatrix *r;

		_asm
		{
			mov	bx,6
			int	0fch
			mov	a,cx
			mov	b,bx
		}
	        if(a>11 && b>54) break;
		
		deadlock=0;
		while(cl[clw].ready)
		{
			if(deadlock>16) break;
		}
		// Draw to free frame
		vid_setswitch(clw,-1);
		vid_clearbg(bg);
		// Field of vision
		vid_cameraangle(fov);
		// Calc matrices and add to order list (only enabled objects)
		ordernum=0;
		/* start at 1 to skip camera */
		for(a=1;a<conum;a++) if(co[a].on)
		{
			order[ordernum++]=a;
			o=co[a].o;
			memcpy(o->r,o->r0,sizeof(rmatrix));
			calc_applyrmatrix(o->r,&cam);
			b=o->pl[0][1]; // center vertex
			co[a].dist=calc_singlez(b,o->v0,o->r);
		}
		// Zsort
		if(city==1)
		{
			co[2].dist=1000000000L; // for CITY scene, test
			co[7].dist=1000000000L; // for CITY scene, test
			co[13].dist=1000000000L; // for CITY scene, test
		}
		if(city==2)
		{
			co[14].dist=1000000000L; // for CITY scene, test
		}
		for(a=0;a<ordernum;a++) 
		{
			dis=co[c=order[a]].dist;
			for(b=a-1;b>=0 && dis>co[order[b]].dist;b--)
				order[b+1]=order[b];
			order[b+1]=c;
		}
		// Draw
		for(a=0;a<ordernum;a++)
		{
			int	x,y;
			o=co[order[a]].o;
			vis_drawobject(o);
		}
		// **** Drawing completed **** //
		// calculate how many frames late of schedule
		avgrepeat=(avgrepeat+(syncframe-currframe)+1)/2;
		repeat=avgrepeat;
		if(repeat<1) repeat=1;
		cl[clw].frames=repeat;
		cl[clw].ready=1;
		clw++; clw&=3;
		// advance that many frames
		repeat=repeat;
		currframe+=repeat;
	    while(repeat-- && !xit)
	    {
		// parse animation stream for 1 frame
		onum=0;
		while(!xit)
		{
			a=*sp++;
			if(a==0xff)
			{
				a=*sp++;
				if(a<=0x7f)
				{
					fov=a<<8;
					break;
				}
				else if(a==0xff) 
				{
					resetscene();
					xit=1;
					continue;
				}
			}
			if((a&0xc0)==0xc0)
			{
				onum=((a&0x3f)<<4);
				a=*sp++;
			}
			onum=(onum&0xff0)|(a&0xf);
			b=0;
			switch(a&0xc0)
			{
			case 0x80 : b=1; co[onum].on=1; break;
			case 0x40 : b=1; co[onum].on=0; break;
			}
			
			#ifdef DEBUG
			if(b) fprintf(fr,"[%i (%s) ",onum,co[onum].on?"on":"off");
			else fprintf(fr,"[%i (--) ",onum,co[onum].on?"on":"off");
			#endif
			if(onum>=conum)
			{
				return(3);
			}
			
			r=co[onum].o->r0;
			
			pflag=0;
			switch(a&0x30)
			{
			case 0x00 : break;
			case 0x10 : pflag|=*sp++; break;
			case 0x20 : pflag|=sp[0]; 
				    pflag|=(long)sp[1]<<8; 
				    sp+=2; break;
			case 0x30 : pflag|=sp[0]; 
				    pflag|=(long)sp[1]<<8; 
				    pflag|=(long)sp[2]<<16; 
				    sp+=3; break;
			}
			
			#ifdef DEBUG
			fprintf(fr,"pfl:%06lX",pflag);
			#endif
			
			l=lsget(pflag);
			r->x+=l;
			l=lsget(pflag>>2);
			r->y+=l;
			l=lsget(pflag>>4);
			r->z+=l;
			
			#ifdef DEBUG
			fprintf(fr," XYZ:(%li,%li,%li)",r->x,r->y,r->z);
			#endif

			if(pflag&0x40)
			{ // word matrix
				for(b=0;b<9;b++) if(pflag&(0x80<<b))
				{
					r->m[b]+=lsget(2);
				}
			}
			else
			{ // byte matrix
				for(b=0;b<9;b++) if(pflag&(0x80<<b))
				{
					r->m[b]+=lsget(1);
				}
			}

			#ifdef DEBUG
			fprintf(fr,"]\n");
			#endif
		}
	    }
	}
	dis_setcopper(2,NULL);

	vid_setswitch(0,-1);
	vid_clearbg(bg);
	vid_setswitch(1,-1);
	vid_clearbg(bg);
	vid_setswitch(2,-1);
	vid_clearbg(bg);
	vid_setswitch(3,-1);
	vid_clearbg(bg);
	
	if(!dis_indemo())
	{
		vid_deinit();
	}

	#ifdef DEBUG
	fclose(fr);
	#endif
	return(0);
}
Esempio n. 17
0
int main(int argc, char *argv[])
{
	int i;
	char *opt, *arg, *cmd, *s, *rom = 0;

	/* Avoid initializing video if we don't have to */
	for (i = 1; i < argc; i++)
	{
		if (!strcmp(argv[i], "--help"))
			help(base(argv[0]));
		else if (!strcmp(argv[i], "--version"))
			version(base(argv[0]));
		else if (!strcmp(argv[i], "--copying"))
			copying();
		else if (!strcmp(argv[i], "--bind")) i += 2;
		else if (!strcmp(argv[i], "--source")) i++;
		else if (!strcmp(argv[i], "--showvars"))
		{
			show_exports();
			exit(0);
		}
		else if (argv[i][0] == '-' && argv[i][1] == '-');
		else if (argv[i][0] == '-' && argv[i][1]);
		else rom = argv[i];
	}
	
	if (!rom) usage(base(argv[0]));

	/* If we have special perms, drop them ASAP! */
	vid_preinit();

	init_exports();

	s = strdup(argv[0]);
	sys_sanitize(s);
	sys_initpath(s);

	for (i = 0; defaultconfig[i]; i++)
		rc_command(defaultconfig[i]);

	for (i = 1; i < argc; i++)
	{
		if (!strcmp(argv[i], "--bind"))
		{
			if (i + 2 >= argc) die("missing arguments to bind\n");
			cmd = malloc(strlen(argv[i+1]) + strlen(argv[i+2]) + 9);
			sprintf(cmd, "bind %s \"%s\"", argv[i+1], argv[i+2]);
			rc_command(cmd);
			free(cmd);
			i += 2;
		}
		else if (!strcmp(argv[i], "--source"))
		{
			if (i + 1 >= argc) die("missing argument to source\n");
			cmd = malloc(strlen(argv[i+1]) + 6);
			sprintf(cmd, "source %s", argv[++i]);
			rc_command(cmd);
			free(cmd);
		}
		else if (!strncmp(argv[i], "--no-", 5))
		{
			opt = strdup(argv[i]+5);
			while ((s = strchr(opt, '-'))) *s = '_';
			cmd = malloc(strlen(opt) + 7);
			sprintf(cmd, "set %s 0", opt);
			rc_command(cmd);
			free(cmd);
			free(opt);
		}
		else if (argv[i][0] == '-' && argv[i][1] == '-')
		{
			opt = strdup(argv[i]+2);
			if ((s = strchr(opt, '=')))
			{
				*s = 0;
				arg = s+1;
			}
			else arg = "1";
			while ((s = strchr(opt, '-'))) *s = '_';
			while ((s = strchr(arg, ','))) *s = ' ';
			
			cmd = malloc(strlen(opt) + strlen(arg) + 6);
			sprintf(cmd, "set %s %s", opt, arg);
			
			rc_command(cmd);
			free(cmd);
			free(opt);
		}
		/* short options not yet implemented */
		else if (argv[i][0] == '-' && argv[i][1]);
	}

	/* FIXME - make interface modules responsible for atexit() */
	atexit(shutdown);
	catch_signals();
	vid_init();
	pcm_init();

	rom = strdup(rom);
	sys_sanitize(rom);
	
	loader_init(rom);
	
	emu_reset();
	emu_run();

	/* never reached */
	return 0;
}
Esempio n. 18
0
void host_init() 
{
        IS_RUNNING = true;
        com_file_init();
        vid_init();
}
Esempio n. 19
0
File: debug.c Progetto: deadbok/aMOS
void init_debug(void)
{
	vid_init();
}
Esempio n. 20
0
int
main (int argc, char *argv[])
{
  int cable_type;
  int quit = 0;
  float rot1 = 0.0, rot2 = 0.0, rot3 = 0.0;
  kos_img_t cubetxr;
  GLuint texture[2];
  pvr_ptr_t texaddr;
  pvr_ptr_t bumpmap;
  /* Consider this as the vector from the object to the light, for now.  */
  GLfloat light_position[3] = { 0.7, 0.7, 2.0 };
  
  vec_normalize (&light_position[0], &light_position[0]);
  
  cable_type = vid_check_cable ();
  
  printf ("KOS says M_PI is: %f\n", M_PI);
  
  if (cable_type == CT_VGA)
    vid_init (DM_640x480_VGA, PM_RGB565);
  else
    vid_init (DM_640x480_PAL_IL, PM_RGB565);
  
  init_pvr ();
  
  auto_orient ();
  
  png_to_img ("/rd/cube.png", PNG_NO_ALPHA, &cubetxr);
  
  texaddr = pvr_mem_malloc (cubetxr.w * cubetxr.h * 2);
  pvr_txr_load_kimg (&cubetxr, texaddr, PVR_TXRLOAD_INVERT_Y);
  kos_img_free (&cubetxr, 0);
  
  bumpmap = load_bumpmap ("/rd/bump.raw");
  
  vid_border_color (0, 0, 0);
  pvr_set_bg_color (0.0, 0.0, 0.0);
    
  glKosInit ();
  
  glEnable (GL_DEPTH_TEST);
  glEnable (GL_CULL_FACE);
  glEnable (GL_TEXTURE_2D);
  glShadeModel (GL_SMOOTH);
  glClearDepth (1.0f);
  glDepthFunc (GL_LEQUAL);

  glMatrixMode (GL_PROJECTION);
  glLoadIdentity ();
  gluPerspective (45.0,			/* Field of view in degrees.  */
		  640.0 / 480.0,	/* Aspect ratio.  */
		  1.0,			/* Z near.  */
		  50.0);		/* Z far.  */

  glMatrixMode (GL_MODELVIEW);
  glLoadIdentity ();
  gluLookAt (0.0,   0.0,  -4.5,		/* Eye position.  */
	     0.0,   0.0,   0.0,		/* Centre.  */
	     0.0,   1.0,   0.0);	/* Up.  */

  glGenTextures (2, &texture[0]);

  /* Ordinary texture.  */
  glBindTexture (GL_TEXTURE_2D, texture[0]);
  glKosTex2D (GL_RGB565_TWID, cubetxr.w, cubetxr.h, texaddr);

  /* Bump texture.  */
  glBindTexture (GL_TEXTURE_2D, texture[1]);

  /*pvr_poly_cxt_txr (cxt, PVR_LIST_OP_POLY,
                    PVR_TXRFMT_BUMP | PVR_TXRFMT_TWIDDLED,
                    128, 128, bumpmap, PVR_FILTER_BILINEAR);*/
  glKosTex2D (GL_BUMP_TWID, 128, 128, bumpmap);

  glTexEnvi (GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE);

  /* Break the nice abstraction.  Tweak for bump mapping.  */
  /*cxt = (pvr_poly_cxt_t *) texture[1];
  cxt->gen.specular = PVR_SPECULAR_ENABLE;*/
  /*pvr_poly_compile (&bumphdr, cxt);*/
  
  printf ("objmatrix at %p\n", objmatrix);
  
  while (!quit)
    {
      int faces;
      GLfloat transformed_normals
        [sizeof (face_normals) / (3 * sizeof (GLfloat))][3];
      GLfloat transformed_orient
        [sizeof (face_orient) / (3 * sizeof (GLfloat))][3];
      
      MAPLE_FOREACH_BEGIN (MAPLE_FUNC_CONTROLLER, cont_state_t, st)
        if (st->buttons & CONT_START)
	  quit = 1;
      MAPLE_FOREACH_END ()
      
      glKosBeginFrame ();
      
      glPushMatrix ();
      
      glRotatef (rot1, 1.0, 0.0, 0.0);
      glRotatef (rot2, 0.0, 1.0, 0.0);
      glRotatef (rot3, 0.0, 0.0, 1.0);
      
      rot1 += 0.1;
      rot2 += 0.2;
      rot3 += 0.3;

      /* Get the object's transformation matrix.  */
      glGetFloatv (GL_MODELVIEW_MATRIX, &objmatrix[0][0]);
      /* We care only about rotation for now.  */
      objmatrix[0][3] = objmatrix[1][3] = objmatrix[2][3] = 0.0;
      objmatrix[3][0] = objmatrix[3][1] = objmatrix[3][2] = 0.0;
      objmatrix[3][3] = 1.0;

      /*printf ("Got matrix:\n");
      printf ("[ %f %f %f %f ]\n", objmatrix[0][0], objmatrix[0][1],
				   objmatrix[0][2], objmatrix[0][3]);
      printf ("[ %f %f %f %f ]\n", objmatrix[1][0], objmatrix[1][1],
				   objmatrix[1][2], objmatrix[1][3]);
      printf ("[ %f %f %f %f ]\n", objmatrix[2][0], objmatrix[2][1],
				   objmatrix[2][2], objmatrix[2][3]);
      printf ("[ %f %f %f %f ]\n", objmatrix[3][0], objmatrix[3][1],
				   objmatrix[3][2], objmatrix[3][3]);*/

      /* Do these all in one go.  */
      mat_load ((matrix_t *) &objmatrix[0][0]);

      /* Note: mat_transform is only for 3D->2D (perspective)
         transformations!  This won't be quite as quick, most likely.  */
      for (faces = 0; faces < 6; faces++)
        {
	  GLfloat x = face_normals[faces][0];
	  GLfloat y = face_normals[faces][1];
	  GLfloat z = face_normals[faces][2];
	  GLfloat w = 1.0;
	  mat_trans_nodiv (x, y, z, w);
	  transformed_normals[faces][0] = x;
	  transformed_normals[faces][1] = y;
	  transformed_normals[faces][2] = z;

	  x = face_orient[faces][0];
	  y = face_orient[faces][1];
	  z = face_orient[faces][2];
	  w = 1.0;
	  mat_trans_nodiv (x, y, z, w);
	  transformed_orient[faces][0] = x;
	  transformed_orient[faces][1] = y;
	  transformed_orient[faces][2] = z;
	}
      glKosMatrixDirty ();

      glDisable (GL_KOS_OFFSET_COLOR);
      glBindTexture (GL_TEXTURE_2D, texture[0]);
      glDisable (GL_TEXTURE_2D);
      //glBlendFunc (GL_DST_COLOR, GL_ZERO);
      glBlendFunc (GL_ONE, GL_ZERO);

      for (faces = 0; faces < 6; faces++)
        {
	  int strip;
	  	  
	  glBegin (GL_TRIANGLE_STRIP);

	  glColor4ub (colour[faces][0], colour[faces][1], colour[faces][2],
		      colour[faces][3]);

	  for (strip = 0; strip < 4; strip++)
	    {
	      glTexCoord2fv (texcoords[strip]);
	      glVertex3fv (points[tristrips[faces][strip]]);
	    }
	  
	  glEnd ();
	}

      /* Finish opaque list, start transparent list.  */
      glKosFinishList ();

      glBindTexture (GL_TEXTURE_2D, texture[1]);
      glEnable (GL_TEXTURE_2D);
      glEnable (GL_KOS_OFFSET_COLOR);
      glBlendFunc (GL_ZERO, GL_SRC_ALPHA);
      
      for (faces = 0; faces < 6; faces++)
        {
	  int strip, over_pi, over_2pi;
	  GLfloat s_dot_n, f[3], d[3], t, q;
	  GLfloat d_cross_r[3], dxr_len, d_len;

	  s_dot_n = vec_dot (&transformed_normals[faces][0],
			     &light_position[0]);
	  /* Elevation (T) angle:
	     s.n = |s| |n| cos T
	     T = acos (s.n / (|s| * |n|))
	     |s| and |n| are both 1.  */
	  t = M_PI / 2 - acosf (s_dot_n);
	  
	  if (t < 0)
	    t = 0;
	  
	  /* Rotation (Q) angle:
	     d x r = (|d| |r| sin Q) n
	     |d x r| / (|d| |r|) = sin Q.  */
	  vec_scale (&f[0], &transformed_normals[faces][0], s_dot_n);
	  vec_sub (&d[0], &light_position[0], &f[0]);
	  vec_cross (&d_cross_r[0], &d[0], &transformed_orient[faces][0]);
	  dxr_len = vec_length (&d_cross_r[0]);
	  d_len = vec_length (&d[0]);
	  q = asinf (dxr_len / d_len);
	  
	  over_pi = vec_dot (&d[0], &transformed_orient[faces][0]) < 0;
	  if (over_pi)
	    q = M_PI - q;

	  over_2pi
	    = vec_dot (&d_cross_r[0], &transformed_normals[faces][0]) < 0;
	  if (over_2pi)
	    q = 2 * M_PI - q;

	  /*printf ("length of n: %f\n",
		 length (&transformed_normals[faces][0]));
	  printf ("%d: [ %f %f %f ]\n", faces, transformed_normals[faces][0],
	    transformed_normals[faces][1], transformed_normals[faces][2]);

	  printf ("length of r: %f\n", length (&transformed_orient[faces][0]));
	  printf ("%d: [ %f %f %f ]\n", faces, transformed_orient[faces][0],
	    transformed_orient[faces][1], transformed_orient[faces][2]);*/

	  glBegin (GL_TRIANGLE_STRIP);

	  set_bump_direction (t, 2 * M_PI - q, 1.0);
	  glColor4ub (255, 255, 255, 255);

	  for (strip = 0; strip < 4; strip++)
	    {
	      glTexCoord2fv (texcoords[strip]);
	      glVertex3fv (points[tristrips[faces][strip]]);
	    }

	  glEnd ();
	}

      /* Finish opaque polygon list, start translucent polygon list.  */
     /* glKosFinishList ();*/

      glPopMatrix ();
                  
      glKosFinishFrame ();
    }

  glKosShutdown ();
  
  pvr_shutdown ();
  
  vid_shutdown ();
  
  return 0;
}
Esempio n. 21
0
void emu_init()
{
        vid_init();
        pcm_init();
        emu_reset();
}
Esempio n. 22
0
int main(int argc, char* argv[])
{	
#if defined(WINDOWS) && defined(DEBUG)
	//Allocate debugging console
	int conHandle;
	long stdHandle;

	AllocConsole();

    stdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
    conHandle = _open_osfhandle(stdHandle, _O_TEXT);

    *stdout = *_fdopen( conHandle, "w" );

    stdHandle = (long)GetStdHandle(STD_INPUT_HANDLE);
    conHandle = _open_osfhandle(stdHandle, _O_TEXT);

    *stdin  = *_fdopen( conHandle, "r" );

    setvbuf( stdout, NULL, _IONBF, 0 );
    setvbuf( stdin, NULL, _IONBF, 0 );
#endif
	if (argc < 2) 
	{
		char *filename = strrchr(argv[0], '\\'); 
		if (!filename)
			filename = strrchr(argv[0], '/'); 
			
		if (*filename != '\0')
			filename++;
		
		printf("Crisp-8, Syntax:\n%s FILE\n", filename);
		return -1;
	}

	if (!vid_init())
		return -1;

	beeper_init();
	config_loadGlobal(&config);

	Chip8* chip = (Chip8*)calloc(1, sizeof(Chip8));
	if (chip8_loadRom(chip, argv[1]) == -1)
	{
		chip->status = CHIP8_EXIT;
		//TODO:: Create helper_sdl.c
		SDL_FillRect(vid_surface, 0, 0);
		font_renderText(RGB_TO_U32(255, 0, 0), FONT_CENTERED, vid_surface->w/2, 0,
				"Unable to open specified file!\nPlease check if file exists.", argv[1]);
		SDL_Flip(vid_surface);
		SDL_Delay(3000);
	}
	
	while(chip->status != CHIP8_EXIT)
	{
		switch(chip->status)
		{
		case CHIP8_RUNNING:
			chip8_doStep(chip);
			break;
		case CHIP8_DEAD:
		case CHIP8_PAUSED:
			menu_doStep(&chip);
			break;
		default:
			break;
		}
	}
	
	vid_deinit();
	beeper_deinit();
	SDL_Quit();
	
	free(chip);
	
	return 0;
}
Esempio n. 23
0
int main(int argc,char *argv[])
{
	//char huge *sptemp;
	short	huge *ip;
	char	huge *cp;
	int	a,b,c,d,e,f,g;
	#ifdef DEBUG
	//fr=fopen("tmp","wt");
	fr=stdout;
	#endif
	if(argc>1)
	{
		strcpy(scene,argv[1]);
		//strupr(scene);
	}
	else indemo=1;
	
	sprintf(tmpname,"%s.00M",scene);
	if(!indemo) printf("Loading materials %s...\n",tmpname);
	scene0=scenem=readfile(tmpname);

	if(scene0[15]=='C') city=1;
	if(scene0[15]=='R') city=2;
	ip=(short *)(scene0+LONGAT(scene0+4));
	conum=d=*ip++;
	for(f=-1,c=1;c<d;c++)
	{	
		e=*ip++;
		if(e>f)
		{
			f=e;
			sprintf(tmpname,"%s.%03i",scene,e);
			if(!indemo) printf("Loading %s... ",tmpname);
			co[c].o=vis_loadobject(tmpname);
			memset(co[c].o->r,0,sizeof(rmatrix));
			memset(co[c].o->r0,0,sizeof(rmatrix));
			co[c].index=e;
			co[c].on=0;
			if(!indemo) printf("(co[%i]:%s)\n",c,co[c].o->name);
		}
		else
		{
			if(!indemo) printf("Copying %s.%03i... ",scene,e);
			for(g=0;g<c;g++) if(co[g].index==e) break;
			memcpy(co+c,co+g,sizeof(struct s_co));
			co[c].o=getmem(sizeof(object));
			memcpy(co[c].o,co[g].o,sizeof(object));
			co[c].o->r=getmem(sizeof(rmatrix));
			co[c].o->r0=getmem(sizeof(rmatrix));
			memset(co[c].o->r,0,sizeof(rmatrix));
			memset(co[c].o->r0,0,sizeof(rmatrix));
			co[c].on=0;
			if(!indemo) printf("(co[%i]:%s)\n",c,co[c].o->name);
		}
	}
	co[0].o=&camobject;
	camobject.r=&cam;
	camobject.r0=&cam;

	sprintf(tmpname,"%s.0AA",scene);
	if(!indemo) printf("Loading animations... %s\n",tmpname);
	ip=(short *)readfile(tmpname);
	while(*ip)
	{
		a=*ip;
		if(a==-1) break;
		sprintf(tmpname,"%s.0%c%c",scene,a/10+'A',a%10+'A');
		if(!indemo) printf("Scene: %s ",tmpname);
		scenelist[scl].data=readfile(tmpname);
		printf("(%i:@%p)\n",scl,scenelist[scl].data);
		scl++;
		ip+=2;
	}

	if(!indemo) 
	{
		printf("Press any key to continue...\n");
		//getch();
	}	

	resetscene();

	if (init_graphics("Cplay", argc, argv) < 0) {
		fprintf(stderr, "Can't init graphics\n");
		return -1;
	};

	init_opengl();
	set_fps(36);

	vid_init(1); ////// oversample x 4
	cp=(char *)(scenem+16);
	vid_setpal(cp);
#if 0
	outp(0x3c8,0);
	outp(0x3c9,0);
	outp(0x3c9,0);
	outp(0x3c9,0);
#endif
	
	while(1 /*!kbhit()*/)
	{	
		int fov;
		int onum;
		long pflag;
		long dis;
		long l;
		object *o;
		rmatrix *r;
		
		//vid_switch();
		//vid_waitb();
		vid_clear();
		// parse animation stream
		
		onum=0;
		for(;;)
		{
			/*
			sptemp=sp;
			_asm
			{
				mov	ax,word ptr sptemp[0]
				cmp	ax,1000h
				jb	l1
				sub	word ptr sptemp[0],1000h
				add	word ptr sptemp[2],100h
			l1:
			}
			sp=sptemp;
			*/
			a=*sp++;
			if(a==0xff)
			{
				a=*sp++;
				if(a<=0x7f) 
				{
					fov=a<<8;
					break;
				}
				else if(a==0xff) 
				{
					resetscene();
					continue;
				}
			}
			if((a&0xc0)==0xc0)
			{
				onum=((a&0x3f)<<4);
				a=*sp++;
			}
			onum=(onum&0xff0)|(a&0xf);
			b=0;
			switch(a&0xc0)
			{
			case 0x80 : b=1; co[onum].on=1; break;
			case 0x40 : b=1; co[onum].on=0; break;
			}
			
			#ifdef DEBUG
			if(b) fprintf(fr,"[%i (%s) ",onum,co[onum].on?"on":"off");
			else fprintf(fr,"[%i (--) ",onum);
			#endif
			if(onum>=conum) return(3);
			
			r=co[onum].o->r0;
			
			pflag=0;
			switch(a&0x30)
			{
			case 0x00 : break;
			case 0x10 : pflag|=*sp++; break;
			case 0x20 : pflag|=sp[0]; 
				    pflag|=(long)sp[1]<<8; 
				    sp+=2; break;
			case 0x30 : pflag|=sp[0]; 
				    pflag|=(long)sp[1]<<8; 
				    pflag|=(long)sp[2]<<16; 
				    sp+=3; break;
			}
			
			#ifdef DEBUG
			fprintf(fr,"pfl:%06lX",pflag);
			#endif
			
			l=lsget(pflag);
			r->x+=l;
			l=lsget(pflag>>2);
			r->y+=l;
			l=lsget(pflag>>4);
			r->z+=l;
			
			#ifdef DEBUG
			fprintf(fr," XYZ:(%f,%f,%f)",r->x,r->y,r->z);
			#endif

			if(pflag&0x40)
			{ // word matrix
				for(b=0;b<9;b++) if(pflag&(0x80<<b))
				{
					r->m[b]+=lsget(2);
				}
			}
			else
			{ // byte matrix
				for(b=0;b<9;b++) if(pflag&(0x80<<b))
				{
					r->m[b]+=lsget(1);
				}
			}

			#ifdef DEBUG
			fprintf(fr,"]\n");
			#endif
		}
		// Field of vision
		vid_cameraangle(fov);
		// Calc matrices and add to order list (only enabled objects)
		ordernum=0;
		/* start at 1 to skip camera */
		for(a=1;a<conum;a++) if(co[a].on)
		{
			order[ordernum++]=a;
			o=co[a].o;
			memcpy(o->r,o->r0,sizeof(rmatrix));
			calc_applyrmatrix(o->r,&cam);
			b=o->pl[0][1]; // center vertex
			if(co[a].o->name[1]=='_') co[a].dist=1000000000L;
			else co[a].dist=calc_singlez(b,o->v0,o->r);
		}
		// Zsort
		if(city==1)
		{
			co[2].dist=1000000000L; // for CITY scene, test
			co[7].dist=1000000000L; // for CITY scene, test
			co[13].dist=1000000000L; // for CITY scene, test
		}
		if(city==2)
		{
			co[14].dist=1000000000L; // for CITY scene, test
		}
		for(a=0;a<ordernum;a++) 
		{
			dis=co[c=order[a]].dist;
			for(b=a-1;b>=0 && dis>co[order[b]].dist;b--)
				order[b+1]=order[b];
			order[b+1]=c;
		}
		// Draw
		for(a=0;a<ordernum;a++)
		{
			//int	x,y;
			o=co[order[a]].o;
			#ifdef DEBUG
			fprintf(fr,"%s (i:%i Z:%li)\n",o->name,order[a],co[order[a]].dist);
			#endif
			vis_drawobject(o);
		}
		#ifdef DEBUG
		fprintf(fr,"\n");
		#endif

		swap_buffers();
	}

	vid_deinit();

	#ifdef DEBUG
	fclose(fr);	
	#endif
	return(0);
}
Esempio n. 24
0
int
main(int argc, char * const*argv)
{
  unsigned char *key;
  FILE*keysf;
  const char *keysname, *fldsname, *vids;
  char *gdfpath = NULL;
  extern int vid_obey_dots;

  f_log = stderr;

  options(argc,argv,"p:");

  if (!curr_project)
    usage();

  setlocale(LC_ALL,LOCALE);

  vid_obey_dots = 0;
  vidp = vid_init();

  gdfpath = malloc(strlen(curr_project)+1);
  sprintf(gdfpath, "%s", curr_project);

  estp = est_init(gdfpath, "cat");

  dp = dbi_create("cat",
		  se_dir(gdfpath,"cat"),
		  500000,
		  sizeof(struct location8),DBI_ACCRETE);
  dbi_set_cache(dp,cache_size);
  dbi_set_user(dp,d_cat);

  progress("segdfx: creating index %s\n",dp->dir);
  pqidsf = xfopen(se_file(gdfpath,"cat","pqids.lst"),"w");
  fldsname = strdup(se_file(gdfpath,"cat","fieldnames.tab"));
  fldsf = xfopen(fldsname,"w");
  
  runexpat(i_stdin, NULL, startElement, endElement);

  dbi_flush(dp);
  dbi_free(dp);

  est_dump(estp);
  est_term(estp);

  vids = se_file (gdfpath, curr_index, "vid.dat");
  vid_dump_data(vidp,vids);
  vid_term(vidp);
  vidp = NULL;

  progress("segdfx: completed db creation\n");

  dp = dbi_open("cat",se_dir(gdfpath,"cat"));
  if (dp && dp->h.entry_count > 0)
    {
      keysname = strdup(se_file(gdfpath,"cat","key.lst"));
      keysf = xfopen(keysname,"w");
      while (NULL != (key = dbi_each (dp)))
	fprintf(keysf,"%s\n",key);
      xfclose(keysname,keysf);
    }
  else
    {
      fprintf(stderr,"segdfx: no keys in input\n");
    }
  dbi_close(dp);
  xfclose(fldsname,fldsf);

  ce_cfg(gdfpath, "cat", "catalog", "xmd", ce_xmd, NULL);

  return 0;
}
Esempio n. 25
0
int main(int argc, char* argv[])
{
	static struct context ctxt = {0};
	static char in_buf[WIDTH*HEIGHT*2];
	static char out_buf[WIDTH*HEIGHT*2];
	int seq, ret;
	time_t t;
	long last_sec;

	/* 
	 * setup signal
	 */
	if (signal(SIGINT,  sigint_handler) == SIG_ERR) {
        fprintf(stderr, "unable to register signal handler\n");
        exit(0);
    }

	if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
        fprintf(stderr, "unable to disable pipe error handler\n");
        exit(0);
    }

	ctxt.conf.setup_mode = 0;
	ctxt.conf.webcam_limit = 0;
	ctxt.conf.webcam_port = 8081;
	ctxt.conf.webcam_localhost = 0;
	ctxt.conf.webcam_quality = 50;
	ctxt.conf.webcam_maxrate = 30;	
	ctxt.conf.v4l2_palette = 8;
	ctxt.conf.brightness = 128;
	ctxt.conf.frame_limit = 30;
	ctxt.conf.input = 8;
	ctxt.conf.roundrobin_frames = 1;
	ctxt.conf.roundrobin_skip = 1;
	ctxt.conf.width = WIDTH;
	ctxt.conf.height = HEIGHT;
	ctxt.conf.video_device = "/dev/video0";

	//ctxt.imgs.type assigned in vid_v4l2_start()
	//also type is set statically to VIDEO_PALETTE_YUV420P in v4l2_start()

	/*
	 * mjpeg streaming init
	 */
	ret = webcam_init(&ctxt);
	if (ret == -1) {
		fprintf(stderr, "unable to open webcam\n");
		exit(0);
	}
	printf("websocket fd = %d\n", ret);

	/*
	 * webcam init
	 */
	vid_init();
	ret = vid_v4l2_start(&ctxt);
	if (ret == -1) {
		fprintf(stderr, "unable to open start v4l2\n");
		exit(0);
	}

	last_sec = time(NULL);
	for (seq = 0; !finish; seq++) {
		long sec;

		vid_next(&ctxt, in_buf);

		webcam_put(&ctxt, in_buf);

		if (last_sec != (sec = time(NULL))) {
			printf("%d fps\n", seq);
			seq = 0;
			last_sec = sec;
		}

		usleep(1000);

		//printf("webcam_put\n");
		//fflush(stdout);
		//
	}

	vid_close(&ctxt);

    return 0;
}