Exemple #1
0
/*
 * Display XRICK splash screen
 *
 * return: SCREEN_RUNNING, SCREEN_DONE, SCREEN_EXIT
 */
screen_status_t
screen_xrick(void)
{
	static uint8_t seq = 0;
	static uint8_t wait = 0;

	if (seq == 0) {
		sysvid_clear();
		draw_img(IMG_SPLASH);
		game_rects = &draw_SCREENRECT;
		seq = 1;
	}

	switch (seq) {
	case 1:  /* wait */
		if (wait++ > 0x2) {
#ifdef ENABLE_SOUND
			game_setmusic("sounds/bullet.wav", 1);
#endif
			seq = 2;
			wait = 0;
		}
		break;

	case 2:  /* wait */
		if (wait++ > 0x20) {
			seq = 99;
			wait = 0;
		}
		break;
	}

	if (control.exit)  /* check for exit request */
		return SCREEN_EXIT;

	if (seq == 99) {  /* we're done */
		sysvid_clear();
		sysvid_setGamePalette();
		seq = 0;
		return SCREEN_DONE;
	}

	return SCREEN_RUNNING;
}
Exemple #2
0
/*
 * Display XRICK splash screen
 *
 * return: SCREEN_RUNNING, SCREEN_DONE, SCREEN_EXIT
 */
U8
screen_xrick(void)
{
    static U8 seq = 0;
    static U8 wait = 0;

    if (seq == 0) {
        sysvid_clear();
        draw_img(img_splash);
        game_rects = &draw_SCREENRECT;
        seq = 1;
    }

    switch (seq) {
    case 1:  /* wait */
        if (wait++ > 0x2) {
#ifdef ENABLE_SOUND
            game_setmusic(soundBullet, 1);
#endif
            seq = 2;
            wait = 0;
        }
        break;

    case 2:  /* wait */
        if (wait++ > 0x20) {
            seq = 99;
            wait = 0;
        }
    }

    if (control_test(Control_EXIT))  /* check for exit request */
        return SCREEN_EXIT;

    if (seq == 99) {  /* we're done */
        sysvid_clear();
        sysvid_setGamePalette();
        seq = 0;
        return SCREEN_DONE;
    }

    return SCREEN_RUNNING;
}
Exemple #3
0
/*
 * Prepare frame
 *
 * This function loops forever: use 'return' when a frame is ready.
 * When returning, game_rects must contain every parts of the buffer
 * that have been modified.
 */
static void
frame(void)
{
	while (1) {

		switch (game_state) {



#ifdef ENABLE_DEVTOOLS
		case DEVTOOLS:
			switch (devtools_run()) {
			case SCREEN_RUNNING:
				return;
			case SCREEN_DONE:
				game_state = INIT_GAME;
				break;
			case SCREEN_EXIT:
				game_state = EXIT;
				return;
			}
		break;
#endif



		case XRICK:
			switch(screen_xrick()) {
			case SCREEN_RUNNING:
				return;
			case SCREEN_DONE:
#ifdef ENABLE_DEVTOOLS
				game_state = DEVTOOLS;
#else
				game_state = INIT_GAME;
#endif
				break;
			case SCREEN_EXIT:
				game_state = EXIT;
				return;
			}
		break;



		case INIT_GAME:
			init();
			game_state = INTRO_MAIN;
			break;



		case INTRO_MAIN:
			switch (screen_introMain()) {
			case SCREEN_RUNNING:
				return;
			case SCREEN_DONE:
				game_state = INTRO_MAP;
				break;
			case SCREEN_EXIT:
				game_state = EXIT;
				return;
			}
		break;



		case INTRO_MAP:
			switch (screen_introMap()) {
			case SCREEN_RUNNING:
				return;
			case SCREEN_DONE:
				game_waitevt = FALSE;
				game_state = INIT_BUFFER;
				break;
			case SCREEN_EXIT:
				game_state = EXIT;
				return;
			}
		break;



		case INIT_BUFFER:
			sysvid_clear();                 /* clear buffer */
			draw_map();                     /* draw the map onto the buffer */
			draw_drawStatus();              /* draw the status bar onto the buffer */
#ifdef ENABLE_CHEATS
			draw_infos();                   /* draw the info bar onto the buffer */
#endif
			game_rects = &draw_SCREENRECT;  /* request full buffer refresh */
			game_state = PLAY0;
			return;



		case PAUSE_PRESSED1:
			screen_pause(TRUE);
			game_state = PAUSE_PRESSED1B;
			break;



		case PAUSE_PRESSED1B:
			if (control_status & CONTROL_PAUSE)
				return;
			game_state = PAUSED;
			break;



		case PAUSED:
			if (control_status & CONTROL_PAUSE)
				game_state = PAUSE_PRESSED2;
			if (control_status & CONTROL_EXIT)
				game_state = EXIT;
			return;



		case PAUSE_PRESSED2:
			if (!(control_status & CONTROL_PAUSE)) {
				game_waitevt = FALSE;
				screen_pause(FALSE);
#ifdef ENABLE_SOUND
				syssnd_pause(FALSE, FALSE);
#endif
				game_state = PLAY2;
			}
		return;



		case PLAY0:
			play0();
			break;



		case PLAY1:
			if (control_status & CONTROL_PAUSE) {
#ifdef ENABLE_SOUND
				syssnd_pause(TRUE, FALSE);
#endif
				game_waitevt = TRUE;
				game_state = PAUSE_PRESSED1;
			}
			else if (control_active == FALSE) {
#ifdef ENABLE_SOUND
				syssnd_pause(TRUE, FALSE);
#endif
				game_waitevt = TRUE;
				screen_pause(TRUE);
				game_state = PAUSED;
			}
			else
				game_state = PLAY2;
			break;



		case PLAY2:
			if E_RICK_STTST(E_RICK_STDEAD) {  /* rick is dead */
				if (game_cheat1 || --game_lives) {
					game_state = RESTART;
				} else {
					game_state = GAMEOVER;
				}
			}
			else if (game_chsm)  /* request to chain to next submap */
				game_state = CHAIN_SUBMAP;
			else
				game_state = PLAY3;
			break;



    case PLAY3:
      play3();
      return;



    case CHAIN_SUBMAP:
      if (map_chain())
	game_state = CHAIN_END;
      else {
	game_bullets = 0x06;
	game_bombs = 0x06;
	game_map++;

	if (game_map == 0x04) {
	  /* reached end of game */
	  /* FIXME @292?*/
	}

	game_state = CHAIN_MAP;
      }
      break;



    case CHAIN_MAP:                             /* CHAIN MAP */
      switch (screen_introMap()) {
      case SCREEN_RUNNING:
	return;
      case SCREEN_DONE:
	if (game_map >= 0x04) {  /* reached end of game */
	  sysarg_args_map = 0;
	  sysarg_args_submap = 0;
	  game_state = GAMEOVER;
	}
	else {  /* initialize game */
	  ent_ents[1].x = map_maps[game_map].x;
	  ent_ents[1].y = map_maps[game_map].y;
	  map_frow = (U8)map_maps[game_map].row;
	  game_submap = map_maps[game_map].submap;
	  game_state = CHAIN_END;
	}
	break;
      case SCREEN_EXIT:
	game_state = EXIT;
	return;
      }
      break;



    case CHAIN_END:
      map_init();                     /* initialize the map */
      isave();                        /* save data in case of a restart */
      ent_clprev();                   /* cleanup entities */
      draw_map();                     /* draw the map onto the buffer */
      draw_drawStatus();              /* draw the status bar onto the buffer */
      game_rects = &draw_SCREENRECT;  /* request full screen refresh */
      game_state = PLAY3;
      return;



    case SCROLL_UP:
      switch (scroll_up()) {
      case SCROLL_RUNNING:
	return;
      case SCROLL_DONE:
	game_state = PLAY0;
	break;
      }
      break;



    case SCROLL_DOWN:
      switch (scroll_down()) {
      case SCROLL_RUNNING:
	return;
      case SCROLL_DONE:
	game_state = PLAY0;
	break;
      }
      break;



    case RESTART:
      restart();
      game_state = PLAY0;
      return;



    case GAMEOVER:
      switch (screen_gameover()) {
      case SCREEN_RUNNING:
	return;
      case SCREEN_DONE:
	game_state = GETNAME;
	break;
      case SCREEN_EXIT:
	game_state = EXIT;
	break;
      }
      break;



    case GETNAME:
      switch (screen_getname()) {
      case SCREEN_RUNNING:
	return;
      case SCREEN_DONE:
	game_state = INIT_GAME;
	return;
      case SCREEN_EXIT:
	game_state = EXIT;
	break;
      }
      break;



    case EXIT:
      return;

    }
  }
Exemple #4
0
/*
 * Map introduction
 *
 * ASM: 1948
 *
 * return: SCREEN_RUNNING, SCREEN_DONE, SCREEN_EXIT
 */
U8
screen_introMap(void)
{

//char tutu[50];
//sprintf(tutu,"imap ctrl=%d seq=%d, %d %d          ",control_status,seq, 0 , SCREEN_TIMEOUT);
//slPrint(tutu,slLocate(3,14));

  switch (seq) {
  case 0:
//	slPrint("befor sysvid_clear",slLocate(3,15));
    sysvid_clear();
//	slPrint("after sysvid_clear",slLocate(3,15));
#ifdef GFXPC
    draw_tilesBank = 1;
    draw_filter = 0xAAAA;
#endif
#ifdef GFXST
    draw_tilesBank = 0;
#endif
    draw_tllst = screen_imaptext[game_map];
    draw_setfb(32, 0);
    draw_tilesSubList();

    draw_setfb(32, 96);
#ifdef GFXPC
    draw_filter = 0x5555;
#endif
    draw_tilesList();

    game_rects = NULL;

#ifdef GFXPC
    draw_filter = 0xFFFF;
#endif
//	slPrint("befor init          ",slLocate(3,15));
    init();
//	slPrint("after init          ",slLocate(3,15));
    nextstep();
//	slPrint("after nextstep          ",slLocate(3,15));
    drawcenter();
//	slPrint("after drawcenter          ",slLocate(3,15));
    drawtb();
//	slPrint("after drawtb          ",slLocate(3,15));
    drawlr();
//	slPrint("after drawlr          ",slLocate(3,15));
    drawsprite();
//	slPrint("after drawsprite          ",slLocate(3,15));
    control_last = 0;

    game_rects = &draw_SCREENRECT;

#ifdef ENABLE_SOUND
	game_setmusic(map_maps[game_map].tune, 1);
#endif
//	slPrint("after game_setmusic          ",slLocate(3,15));

	seq = 1;
    break;
  case 1:  /* top and bottom borders */
    drawtb();
    game_rects = &anim_rect;
    seq = 2;
    break;
  case 2:  /* background and sprite */
    anim();
    drawcenter();
    drawsprite();
    game_rects = &anim_rect;
    seq = 3;
    break;
  case 3:  /* all borders */
    drawtb();
    drawlr();
    game_rects = &anim_rect;
    seq = 1;
    break;
  case 4:  /* wait for key release */
    if (!(control_status & CONTROL_FIRE))
      seq = 5;
    else
	  {
	  //control_status =0;
      sys_sleep(50); /* .5s */
	  }
    break;
  }

  if (control_status & CONTROL_FIRE) {  /* end as soon as key pressed */
    seq = 4;
  }

  if (control_status & CONTROL_EXIT)  /* check for exit request */
    return SCREEN_EXIT;

  if (seq == 5) {  /* end as soon as key pressed */
    sysvid_clear();
    seq = 0;
	return SCREEN_DONE;
  }
  else
    return SCREEN_RUNNING;
}
Exemple #5
0
/*
 * Main introduction
 *
 * return: SCREEN_RUNNING, SCREEN_DONE, SCREEN_EXIT
 */
U8
screen_introMain(void)
{
  static U8 seq = 0;
  static U8 seen = 0;
  static U8 first = TRUE;
  static U8 period = 0;
  static U32 tm = 0;
	U8 i, s[32];
//char tutu[50];
//sprintf(tutu,"seen %d ctrl=%d seq=%d, %d %d          ",seen,control_status,seq, 0 , SCREEN_TIMEOUT);

//slPrint(tutu,slLocate(2,14));
//slPrintHex(control_status,slLocate(1,2));
  if (seq == 0) {
    draw_tilesBank = 0;
    if (first == TRUE)
      seq = 1;
    else
      seq = 4;
    period = game_period;
    game_period = 50;
    game_rects = &draw_SCREENRECT;
#ifdef ENABLE_SOUND
	game_setmusic("sounds/tune5.wav", -1);
#endif
  }

syssnd_play(music_snd, 1);
//sprintf(tutu,"seen %d ctrl=%d seq=%d, %d %d          ",seen,control_status,seq, 0 , SCREEN_TIMEOUT);
 //slPrint(tutu,slLocate(2,15));

  switch (seq) {
  case 1:  /* dispay hall of fame */
    sysvid_clear();
    tm = sys_gettime();

#ifdef GFXPC
    /* Rick Dangerous title */
    draw_tllst = (U8 *)screen_imainrdt;
    draw_setfb(32, 16);
    draw_filter = 0xaaaa;
    draw_tilesList();

    /* Core Design copyright + press space to start */
    draw_tllst = (U8 *)screen_imaincdc;
    draw_setfb(64, 80);
    draw_filter = 0x5555;
    draw_tilesList();
#endif

#ifdef GFXST
    draw_pic(0, 0, 0x140, 0xc8, pic_splash);
#endif

    seq = 2;
    break;

  case 2:  /* wait for key pressed or timeout */
    if (control_status & CONTROL_FIRE)
	  {
	  //slPrint("2 key pressed",slLocate(3,3));
      seq = 3;
	  }
    else if (sys_gettime() - tm > SCREEN_TIMEOUT) {
      seen++;
//while(1);

      seq = 4;
      //control_status =0;
    }
	//char fff2[50];
	//sprintf ( fff2,"2 not press %d %d",	 control_status, CONTROL_FIRE);
	  //slPrint(fff2,slLocate(3,3));
    break;

  case 3:  /* wait for key released */
    if (!(control_status & CONTROL_FIRE)) {
      if (seen++ == 0)
	seq = 4;
      else
	seq = 7;
	  //while(1);
    }
	//control_status =0;
    break;

  case 4:  /* display Rick Dangerous title and Core Design copyright */
	  //slPrint("case 3         ",slLocate(3,3));
    sysvid_clear();
    tm = sys_gettime();

    /* hall of fame title */
#ifdef GFXPC
    draw_tllst = (U8 *)screen_imainhoft;
    draw_setfb(32, 0);
    draw_filter = 0xaaaa;
    draw_tilesList();
#endif
#ifdef GFXST
    draw_pic(0, 0, 0x140, 0x20, pic_haf);
#endif

    /* hall of fame content */
    draw_setfb(56, 40);
#ifdef GFXPC
    draw_filter = 0x5555;
#endif 
    for (i = 0; i < 8; i++) {
      sprintf((char *)s, "%06d@@@....@@@%s",
	      game_hscores[i].score, game_hscores[i].name);
      s[26] = '\377'; s[27] = '\377'; s[28] = '\376';
      draw_tllst = s;
      draw_tilesList();
    }
    seq = 5;
    break;

  case 5:  /* wait for key pressed or timeout */
    if (control_status & CONTROL_FIRE)
	  {
							  //slPrint("5 key pressed",slLocate(3,3));
//    if (!(control_status & CONTROL_FIRE)) 
      seq = 6;
	  }
    else if (sys_gettime() - tm > SCREEN_TIMEOUT) {
      seen++;
      seq = 1;
    }
    break;

  case 6:  /* wait for key released */
    if (!(control_status & CONTROL_FIRE)) {
      if (seen++ == 0)
	seq = 1;
      else
	seq = 7;
	  //while(1);
    }
  //else
		  //control_status =0;
    break;
  }

  if (control_status & CONTROL_EXIT)  /* check for exit request */
    return SCREEN_EXIT;

  if (seq == 7) {  /* we're done */
    sysvid_clear();
    seq = 0;
    seen = 0;
    first = FALSE;
    game_period = period;
    return SCREEN_DONE;
  }
  else
    return SCREEN_RUNNING;
}