void cheat_handle_checkpoint ( void )
{
	if ( KEY_PRESSED(set.key_checkpoint_1) || KEY_PRESSED(set.key_checkpoint_2) )
	{
		int					n = KEY_PRESSED( set.key_checkpoint_1 ) ? 0 : 1;
		struct checkpoint	*cp = gta_checkpoint_info_get( n );
		float				pos[3];

		if ( cp != NULL )
		{
			struct vehicle_info *vehicle_info = vehicle_info_get( VEHICLE_SELF, 0 );

			vect3_copy( cp->position, pos );
			pos[2] += 1.0f;
			cheat_teleport( pos, 0 );		/* XXX interior id? */

			if ( vehicle_info != NULL )
				vehicle_prevent_below_height( vehicle_info, set.checkpoint_min_height );
		}
		else
		{
			cheat_state_text( "Checkpoint does not exist." );
		}
	}
}
void cheat_handle_emo ( struct vehicle_info *vehicle_info, struct actor_info *actor_info, float time_diff )
{
	traceLastFunc( "cheat_handle_emo()" );

	struct vehicle_info *vtemp;

	if ( !isBadPtr_GTA_pPed(actor_info) )
	{
		if ( KEY_PRESSED(set.key_self_destruct) )
			actor_info->hitpoints = 0.0f;
	}
	else if ( !isBadPtr_GTA_pVehicle(vehicle_info) )
	{
		actor_info = actor_info_get(ACTOR_SELF, 0);
		if ( actor_info->state == ACTOR_STATE_DRIVING && actor_info->vehicle->passengers[0] == actor_info )
		{
			if ( KEY_PRESSED(set.key_self_destruct) )
			{
				for ( vtemp = vehicle_info; vtemp != NULL; vtemp = vtemp->trailer )
				{
					if(vtemp == NULL) return;

					vtemp->hitpoints = 1.0f;
					cheat_vehicle_tires_set( vtemp, 1 );
					if ( !set.trailer_support )
						break;
				}
			}
		}
	}
}
void cheat_handle_money ( void )
{
	static uint32_t next_time;

	if ( !cheat_state->_generic.money )
		next_time = time_get();

	if ( KEY_PRESSED(set.key_money) )
		cheat_state->_generic.money ^= 1;

	if ( cheat_state->_generic.money && time_get() >= next_time )
	{
		const int	min = set.money_amount_rand_min;
		const int	max = set.money_amount_rand_max;
		uint32_t	money = gta_money_get();
		int			add;

		if ( money < (uint32_t) set.money_amount_max )
		{
			add = ( (max - min) > 0 ) ? ( rand() % (max - min) ) : 0;
			add = ( (add + 50) / 100 ) * 100;
			money += min + add;
			gta_money_set( money );
		}

		next_time = time_get() + __money_interval_rand_time();
	}
}
Exemple #4
0
void process_kbd(void)
{
	uint8_t key_id;
	
	for (key_id = 0; key_id < KEY_COUNT; key_id++)
		if (KEY_PRESSED(key_id))
		{
			CLEAR_KEY_PRESSED(key_id);
			sprintf(lcd_line1, "PRESSED %d         ", key_id);
		}
}
Exemple #5
0
void update_velocities(Velocity *velocity)
{
  if(KEY_PRESSED(D_LEFT))
  {
    velocity->vx = MAX(velocity->vx - 2, 0);
  }
  if(KEY_PRESSED(D_RIGHT))
  {
    velocity->vx = MIN(velocity->vx + 2, SCREEN_WIDTH / 4);
  }

  if(KEY_PRESSED(D_DOWN))
  {
    velocity->vy = MAX(velocity->vy - 2, -SCREEN_HEIGHT / 3);
  }

  if(KEY_PRESSED(D_UP))
  {
    velocity->vy = MIN(velocity->vy + 2, SCREEN_HEIGHT / 3);
  }
}
Exemple #6
0
void menu_common(void)
{
	if (KEY_PRESSED(KEY_UP))
	{
		menu_item_prev();
		CLEAR_KEY_PRESSED(KEY_UP);
		beep_ms(50);
	}

	if (KEY_PRESSED(KEY_DOWN))
	{
		menu_item_next();
		CLEAR_KEY_PRESSED(KEY_DOWN);
		beep_ms(50);
	}

	if (KEY_PRESSED(KEY_MENU))
	{
		menu_mode_next();
		CLEAR_KEY_PRESSED(KEY_MENU);
		beep_ms(50);
	}
}
void cheat_handle_unfreeze ( struct vehicle_info *vehicle_info, struct actor_info *actor_info, float time_diff )
{
	traceLastFunc( "cheat_handle_unfreeze()" );

	if ( KEY_PRESSED(set.key_anti_freeze) )
	{
		GTAfunc_TogglePlayerControllable(0);
		GTAfunc_LockActor(0);
		pGameInterface->GetCamera()->RestoreWithJumpCut();
		
		// stop all animations
		if ( actor_info != NULL && !actor_info->pedFlags.bInVehicle )
			GTAfunc_DisembarkInstantly();
	}
}
Exemple #8
0
void menu_empty_bath(void)
{
	sprintf(lcd_line0,"якхб бюммш      ");
	sprintf(lcd_line1,"%s                ",
		g_empty_bath_state?"бйкчвем":"бшйкчвем");

	if (KEY_PRESSED(KEY_ENTER))
	{
		CLEAR_KEY_PRESSED(KEY_ENTER);

		g_empty_bath_state ^= 0x01;
		SET_WATER_MODE(WATER_MODE_MANUAL);

		beep_ms(50);
	}

	menu_common();
}
Exemple #9
0
void menu_debug(void)
{
	sprintf(lcd_line0,"пефхл нркюдйх   ");

	sprintf(lcd_line1,"%s                ",
		(g_debug_mode)?"бйкчвем":"бшйкчвем");

	if (KEY_PRESSED(KEY_ENTER))
	{
		CLEAR_KEY_PRESSED(KEY_ENTER);

		g_debug_mode ^= 0x01;

		beep_ms(50);
	}

	menu_common();
}
Exemple #10
0
int run_game(GameData *data)
{
  int cur_shot = 0;
  while(cur_shot < data->num_shots)
  {
    Pacman *cur_pac_shot = (data->shots + cur_shot);
    draw_pacman(cur_pac_shot);
    draw_pebbles(data->pebbles, data->num_pebbles);
    *cur_pac_shot->velocity = *(data->old_velocity);
    Velocity *velocity = cur_pac_shot->velocity;
    while(!KEY_PRESSED(START))
    {
      update_velocities(velocity);
      wait_for_vblank();
      draw_user_velocities(data->velocity_frame_x, data->velocity_frame_y, velocity);
      draw_pacman(cur_pac_shot);
    }
    *(data->old_velocity ) = *cur_pac_shot->velocity;//MUST save old shot

    erase_frame(data->velocity_frame_x, data->bg_color);
    erase_frame(data->velocity_frame_y, data->bg_color);

    //now we run simulation
    fill_frame(data->indicator, GREEN);
    int i = 0;
    while(!off_screen(cur_pac_shot->frame))
    {
      for (i = 0; i < data->num_pebbles; i++) {
        PacmanPebble *cur_pebble = (data->pebbles + i);
        check_collision(cur_pac_shot, cur_pebble);
      }
      wait_for_vblank();
      erase_frame(cur_pac_shot->frame, data->bg_color);
      move_shot(cur_pac_shot);
      draw_pebbles(data->pebbles, data->num_pebbles);
      draw_pacman(cur_pac_shot);
   }

    erase_frame(cur_pac_shot->frame, data->bg_color);
    cur_shot++;
  }
  fill_frame(data->indicator, RED);
  return 0;
}
Exemple #11
0
void menu_usb(void)
{
	sprintf(lcd_line0,"ябъгэ я йнл.оюм.");

	sprintf(lcd_line1,"%s                ",
		(usb_on)?"еярэ":"мер");

	if (!usb_on)
		if (KEY_PRESSED(KEY_ENTER))
		{
			CLEAR_KEY_PRESSED(KEY_ENTER);

			usb_on = 1;

			beep_ms(50);
		}

	menu_common();
}
Exemple #12
0
void cheat_handle_weapon ( void )
{
	struct actor_info	*actor_info = actor_info_get( ACTOR_SELF, ACTOR_ALIVE );
	int					i;

	if ( KEY_PRESSED(set.key_weapon) )
		cheat_state->_generic.weapon ^= 1;	/* toggle weapon cheat */

	if ( cheat_state->_generic.weapon )
	{
		if ( actor_info != NULL )
		{
			for ( i = 0; i < 13; i++ )
			{
				if ( set.weapon[i] == NULL )
					continue;

				if ( set.ammo_random )
				{
					if ( actor_info->weapon[set.weapon[i]->slot].id != set.weapon[i]->id
					 ||	 (
							 actor_info->weapon[set.weapon[i]->slot].ammo == 0
					 &&	 actor_info->weapon[set.weapon[i]->slot].ammo_clip == 0
					 ) )
					{
						int randammo = ( rand() % set.ammo ) + 1;
						int randammoclip = ( rand() % set.ammo_clip ) + 1;
						gta_weapon_set( actor_info, set.weapon[i]->slot, set.weapon[i]->id, randammo, randammoclip );
					}
				}
				else
				{
					gta_weapon_set( actor_info, set.weapon[i]->slot, set.weapon[i]->id, set.ammo, set.ammo_clip );
				}
			}
		}
		else if ( !set.restore_weapons_after_death )
		{
			cheat_state->_generic.weapon = 0;
		}
	}
}
Exemple #13
0
void menu_extruder_pump(void)
{
	sprintf(lcd_line0,"мюяня нукюфдемхъ");
	sprintf(lcd_line1,"%s                ",
		(TEST_SOFT_CONTROL(SOFT_CONTROL_EXTRUDER_PUMP))?"бйкчвем":"бшйкчвем");

	if (KEY_PRESSED(KEY_ENTER))
	{
		CLEAR_KEY_PRESSED(KEY_ENTER);

		if (TEST_SOFT_CONTROL(SOFT_CONTROL_EXTRUDER_PUMP))
			SOFT_CONTROL_OFF(SOFT_CONTROL_EXTRUDER_PUMP);
		else
			SOFT_CONTROL_ON(SOFT_CONTROL_EXTRUDER_PUMP);

		beep_ms(50);
	}

	menu_common();
}
Exemple #14
0
void menu_foil_led(void)
{
	sprintf(lcd_line0,"йнмрпнкэ тнкэцх ");
	sprintf(lcd_line1,"%s                ",
		(TEST_SOFT_CONTROL(SOFT_CONTROL_FOIL_LED))?"бйкчвем":"бшйкчвем");

	if (KEY_PRESSED(KEY_ENTER))
	{
		CLEAR_KEY_PRESSED(KEY_ENTER);

		if (TEST_SOFT_CONTROL(SOFT_CONTROL_FOIL_LED))
			SOFT_CONTROL_OFF(SOFT_CONTROL_FOIL_LED);
		else
			SOFT_CONTROL_ON(SOFT_CONTROL_FOIL_LED);

		beep_ms(50);
	}

	menu_common();
}
Exemple #15
0
void menu_cooler_pump(void)
{
	sprintf(lcd_line0,"мюяня ункнд.сяр.");
	sprintf(lcd_line1,"%s                ",
		(TEST_SOFT_CONTROL(SOFT_CONTROL_COOLER_PUMP))?"бйкчвем":"бшйкчвем");

	if (KEY_PRESSED(KEY_ENTER))
	{
		CLEAR_KEY_PRESSED(KEY_ENTER);

		if (TEST_SOFT_CONTROL(SOFT_CONTROL_COOLER_PUMP))
			SOFT_CONTROL_OFF(SOFT_CONTROL_COOLER_PUMP);
		else
			SOFT_CONTROL_ON(SOFT_CONTROL_COOLER_PUMP);

		beep_ms(50);
	}

	menu_common();
}
Exemple #16
0
void menu_pressure(void)
{
	sprintf(lcd_line0,"бнгдсу б рпсае  ");
	sprintf(lcd_line1,"%s                ",
		(TEST_SOFT_CONTROL(SOFT_CONTROL_PRESSURE))?"бйкчвем":"бшйкчвем");

	if (KEY_PRESSED(KEY_ENTER))
	{
		CLEAR_KEY_PRESSED(KEY_ENTER);

		if (TEST_SOFT_CONTROL(SOFT_CONTROL_PRESSURE))
			SOFT_CONTROL_OFF(SOFT_CONTROL_PRESSURE);
		else
			SOFT_CONTROL_ON(SOFT_CONTROL_PRESSURE);

		beep_ms(50);
	}

	menu_common();
}
Exemple #17
0
void menu_germo(void)
{
	sprintf(lcd_line0,"цеплерхгюжхъ    ");
	sprintf(lcd_line1,"%s                ",
		(TEST_SOFT_CONTROL(SOFT_CONTROL_GERMO))?"бйкчвемю":"бшйкчвемю");

	if (KEY_PRESSED(KEY_ENTER))
	{
		CLEAR_KEY_PRESSED(KEY_ENTER);

		if (TEST_SOFT_CONTROL(SOFT_CONTROL_GERMO))
			SOFT_CONTROL_OFF(SOFT_CONTROL_GERMO);
		else
			SOFT_CONTROL_ON(SOFT_CONTROL_GERMO);

		beep_ms(50);
	}

	menu_common();
}
Exemple #18
0
void menu_sg(void)
{
	sprintf(lcd_line0,"ябюп. цнкнбйю.  ");
	sprintf(lcd_line1,"%s                ",
		(TEST_SOFT_CONTROL(SOFT_CONTROL_SG))?"опхфюрю":"ондмърю");

	if (KEY_PRESSED(KEY_ENTER))
	{
		CLEAR_KEY_PRESSED(KEY_ENTER);

		if (TEST_SOFT_CONTROL(SOFT_CONTROL_SG))
			SOFT_CONTROL_OFF(SOFT_CONTROL_SG);
		else
			SOFT_CONTROL_ON(SOFT_CONTROL_SG);

		beep_ms(50);
	}

	menu_common();
}
Exemple #19
0
void menu_drier(void)
{
	sprintf(lcd_line0,"нясьхрекэ       ");
	sprintf(lcd_line1,"%s                ",
		(TEST_SOFT_CONTROL(SOFT_CONTROL_DRIER))?"бйкчвем":"бшйкчвем");

	if (KEY_PRESSED(KEY_ENTER))
	{
		CLEAR_KEY_PRESSED(KEY_ENTER);

		if (TEST_SOFT_CONTROL(SOFT_CONTROL_DRIER))
			SOFT_CONTROL_OFF(SOFT_CONTROL_DRIER);
		else
			SOFT_CONTROL_ON(SOFT_CONTROL_DRIER);

		beep_ms(50);
	}

	menu_common();
}
Exemple #20
0
void menu_bunker_motor(void)
{
	sprintf(lcd_line0,"дбхц. мюйнохрекъ");
	sprintf(lcd_line1,"%s                ",
		(TEST_SOFT_CONTROL(SOFT_CONTROL_BUNKER_MOTOR))?"бйкчвем":"бшйкчвем");

	if (KEY_PRESSED(KEY_ENTER))
	{
		CLEAR_KEY_PRESSED(KEY_ENTER);

		if (TEST_SOFT_CONTROL(SOFT_CONTROL_BUNKER_MOTOR))
			SOFT_CONTROL_OFF(SOFT_CONTROL_BUNKER_MOTOR);
		else
			SOFT_CONTROL_ON(SOFT_CONTROL_BUNKER_MOTOR);

		beep_ms(50);
	}

	menu_common();
}
Exemple #21
0
void menu_cooler_tube(void)
{
	sprintf(lcd_line0,"опедб.нукюфдемхе");
	sprintf(lcd_line1,"%s                ",
		(TEST_SOFT_CONTROL(SOFT_CONTROL_COOLER_TUBE))?"бйкчвемн":"бшйкчвемн");

	if (KEY_PRESSED(KEY_ENTER))
	{
		CLEAR_KEY_PRESSED(KEY_ENTER);

		if (TEST_SOFT_CONTROL(SOFT_CONTROL_COOLER_TUBE))
			SOFT_CONTROL_OFF(SOFT_CONTROL_COOLER_TUBE);
		else
			SOFT_CONTROL_ON(SOFT_CONTROL_COOLER_TUBE);

		beep_ms(50);
	}

	menu_common();
}
Exemple #22
0
void menu_water_mode(void)
{
	uint16_t water_mode;

	sprintf(lcd_line0,"спнбемэ бндш    ");
	sprintf(lcd_line1,"%d                ", GET_WATER_MODE);

	if (KEY_PRESSED(KEY_ENTER))
	{
		CLEAR_KEY_PRESSED(KEY_ENTER);

		water_mode = GET_WATER_MODE;
		water_mode++;
		if (2 < water_mode)
			water_mode = 0;
		SET_WATER_MODE(water_mode);
		beep_ms(50);
	}

	menu_common();
}
Exemple #23
0
void menu_tractor_lock(void)
{
	sprintf(lcd_line0,"опхфхл рс       ");
	sprintf(lcd_line1,"%s                ",
		(TEST_SOFT_CONTROL(SOFT_CONTROL_TRACTOR_LOCK))?"бйкчвем":"бшйкчвем");

	if (KEY_PRESSED(KEY_ENTER))
	{
		CLEAR_KEY_PRESSED(KEY_ENTER);

		if (TEST_SOFT_CONTROL(SOFT_CONTROL_TRACTOR_LOCK))
			SOFT_CONTROL_OFF(SOFT_CONTROL_TRACTOR_LOCK);
		else
			SOFT_CONTROL_ON(SOFT_CONTROL_TRACTOR_LOCK);

		beep_ms(50);
	}


	menu_common();
}
Exemple #24
0
void menu_fillup_pump(void)
{
	sprintf(lcd_line0,"мюяня мюонкмемхъ");
	sprintf(lcd_line1,"%s                ",
		(TEST_CONTROL(CONTROL_FILLUP_BATH_PUMP))?"бйкчвем":"бшйкчвем");

	if (KEY_PRESSED(KEY_ENTER))
	{
		CLEAR_KEY_PRESSED(KEY_ENTER);

		if (TEST_CONTROL(CONTROL_FILLUP_BATH_PUMP))
			CONTROL_OFF(CONTROL_FILLUP_BATH_PUMP);
		else
			CONTROL_ON(CONTROL_FILLUP_BATH_PUMP);

		SET_WATER_MODE(WATER_MODE_MANUAL);

		beep_ms(50);
	}

	menu_common();
}
Exemple #25
0
void menu_work_pump(void)
{
	sprintf(lcd_line0,"мюяня жхпйскъжхх");
	sprintf(lcd_line1,"%s                ",
		(TEST_CONTROL(CONTROL_WORK_BATH_PUMP))?"бйкчвем":"бшйкчвем");

	if (KEY_PRESSED(KEY_ENTER))
	{
		CLEAR_KEY_PRESSED(KEY_ENTER);

		if (TEST_CONTROL(CONTROL_WORK_BATH_PUMP))
			CONTROL_OFF(CONTROL_WORK_BATH_PUMP);
		else
			CONTROL_ON(CONTROL_WORK_BATH_PUMP);

		SET_WATER_MODE(WATER_MODE_MANUAL);

		beep_ms(50);
	}

	menu_common();
}
Exemple #26
0
void menu_siren_mode(void)
{
	uint16_t siren_mode;

	sprintf(lcd_line0,"пефхл яхпемш    ");
	sprintf(lcd_line1,"%d                ", GET_SIREN_MODE);

	if (KEY_PRESSED(KEY_ENTER))
	{
		CLEAR_KEY_PRESSED(KEY_ENTER);

		siren_mode = GET_SIREN_MODE;
		siren_mode++;
		if (3 < siren_mode)
			siren_mode = 0;
		SET_SIREN_MODE(siren_mode);

		beep_ms(50);
	}

	menu_common();
}
Exemple #27
0
void cheat_handle_misc ( void )
{
	if ( set.clickwarp_enabled )
	{
		if(KEY_PRESSED(set.key_clickwarp_enable))
		{
			g_iCursorEnabled ^= 1;
			toggleSAMPCursor(g_iCursorEnabled);
		}
		if(g_iCursorEnabled && KEY_PRESSED(set.key_clickwarp_click))
		{
			iClickWarpEnabled = 1;
		}
	}

	if ( KEY_PRESSED(set.key_map) )
	{
		cheat_state->_generic.map ^= 1; /* toggle minimap */
	}

	if ( KEY_PRESSED(set.key_map_show_vehicles) )
	{
		cheat_state->_generic.map_vehicles ^= 1;
	}

	if ( KEY_DOWN(set.secondary_key) )
	{
		if ( KEY_PRESSED(set.key_render_player_tags) )
			cheat_state->render_player_tags ^= 1;
		if ( KEY_PRESSED(set.key_render_vehicle_tags) )
			cheat_state->render_vehicle_tags ^= 1;
	}

	/* time */
	if ( set.force_hour >= 0 )
		gta_time_hour_set( set.force_hour );

	/* weather */
	if ( set.force_weather >= 0 )
		gta_weather_state_set( set.force_weather );

	SetCloudsEnabled( set.enable_clouds );
}
Exemple #28
0
void 
playanm(short anim_num)
    {
    unsigned char *animbuf, *palptr;
    int i, j, k, length = 0, numframes = 0;
    int32 handle = -1;
    unsigned char ANIMvesapal[4*256];
    unsigned char tempbuf[256];
    unsigned char *palook_bak = palookup[0];
    UserInput uinfo = { FALSE, FALSE, dir_None };

    ANIMnum = anim_num;

    KB_FlushKeyboardQueue();    
    KB_ClearKeysDown();    
    
    DSPRINTF(ds,"PlayAnm");
    MONO_PRINT(ds);

    DSPRINTF(ds,"PlayAnm");
    MONO_PRINT(ds);

    animbuf = LoadAnm(anim_num);
    if (!animbuf)    
        return;
    
    DSPRINTF(ds,"PlayAnm - Palette Stuff");
    MONO_PRINT(ds);

    for (i = 0; i < 256; i++)
        tempbuf[i] = i;
    palookup[0] = tempbuf;    
        
    ANIM_LoadAnim(animbuf);
    ANIMnumframes = ANIM_NumFrames();
    numframes = ANIMnumframes;
    
    palptr = ANIM_GetPalette();
    for (i = 0; i < 768; i++)
	ANIMvesapal[i] = palptr[i]>>2;

    tilesizx[ANIM_TILE(ANIMnum)] = 200;
    tilesizy[ANIM_TILE(ANIMnum)] = 320;

    clearview(0);

    setbrightness(gs.Brightness,ANIMvesapal,2);
    if (ANIMnum == 1)
        {
        // draw the first frame
        waloff[ANIM_TILE(ANIMnum)] = (intptr_t)ANIM_DrawFrame(1);
        invalidatetile(ANIM_TILE(ANIMnum), 0, 1<<4);
        rotatesprite(0 << 16, 0 << 16, 65536L, 512, ANIM_TILE(ANIMnum), 0, 0, 2 + 4 + 8 + 16 + 64, 0, 0, xdim - 1, ydim - 1);
        }

    SoundState = 0;
    //ototalclock = totalclock + 120*2;
    ototalclock = totalclock;

    for (i = 1; i < numframes; i++)
        {
        while (totalclock < ototalclock)
            {
			handleevents();
            CONTROL_GetUserInput(&uinfo);
            CONTROL_ClearUserInput(&uinfo);
            switch (ANIMnum)
                {
                case ANIM_INTRO:
                    if (KB_KeyWaiting() || uinfo.button0 || uinfo.button1 || quitevent)
                        goto ENDOFANIMLOOP;
                    break;
                case ANIM_SERP:
                    if (KEY_PRESSED(KEYSC_ESC) || uinfo.button1 || quitevent)
                        goto ENDOFANIMLOOP;
                    break;
                }    
                
            getpackets();
            }

        switch (ANIMnum)
            {
            case ANIM_INTRO:
                AnimShareIntro(i,numframes);    
                break;
            case ANIM_SERP:
                AnimSerp(i,numframes);    
                break;
            case ANIM_SUMO:
                AnimSumo(i,numframes);    
                break;
            case ANIM_ZILLA:
                AnimZilla(i,numframes);    
                break;
            }    
            
        waloff[ANIM_TILE(ANIMnum)] = (intptr_t)ANIM_DrawFrame(i);
        invalidatetile(ANIM_TILE(ANIMnum), 0, 1<<4);

        rotatesprite(0 << 16, 0 << 16, 65536L, 512, ANIM_TILE(ANIMnum), 0, 0, 2 + 4 + 8 + 16 + 64, 0, 0, xdim - 1, ydim - 1);
        nextpage();
        }

    // pause on final frame    
    while (totalclock < ototalclock) {
		handleevents();
        getpackets();
	}
        
ENDOFANIMLOOP:

    clearview(0);
    nextpage();
    palookup[0] = palook_bak;
    setbrightness(gs.Brightness, (unsigned char*)palette_data, 2);
    
    KB_FlushKeyboardQueue();    
    KB_ClearKeysDown();    
    ANIM_FreeAnim();
    walock[ANIM_TILE(ANIMnum)] = 1;
    }
void cheat_handle_vehicle_recording ( struct vehicle_info *info, float time_diff )
{
	char buffer[512];
	float set_speed[3];
	float set_spin[3];

	if ( info == NULL || !set.recording_activated )
		return;
	
	traceLastFunc( "cheat_handle_vehicle_recording()" );
	
	// recording key
	if ( KEY_PRESSED(set.key_recording_record) )
	{
		if ( rec_state == RECORDING_RECORD )
		{
			rec_maxNum = rec_index;
			rec_state = RECORDING_OFF;
			return;
		}
		else if ( rec_state == RECORDING_OFF )
		{
			rec_state = RECORDING_RECORD;
			rec_maxNum = 0;
			rec_index = 0;
			rec_playNext = 0.0f;
		}
	}

	if ( KEY_PRESSED(set.key_recording_continueAfterFinish) )
		rec_continueAfterFin ^= 1;

	// play keys
	if ( (KEY_PRESSED(set.key_recording_play) || KEY_PRESSED(set.key_recording_customSpeed)
		|| KEY_PRESSED(set.key_recording_rev) || KEY_PRESSED(set.key_recording_rev_customSpeed)) )
	{
		// if record playing
		if ( rec_state >= RECORDING_PLAY )
		{
			 rec_state = RECORDING_OFF;
			 return;
		}
		else if ( rec_state == RECORDING_OFF )
		{
			// something to play?
			if ( rec_maxNum <= 0 )
			{
				rec_state = RECORDING_OFF;
				return;
			}

			rec_index = 0;
			rec_playNext = 0.0f;

			
			if ( KEY_PRESSED(set.key_recording_play) )
				rec_state = RECORDING_PLAY;
			else if ( KEY_PRESSED(set.key_recording_customSpeed) )
				rec_state = RECORDING_PLAY_CUSTOMSPEED;
			else if ( KEY_PRESSED(set.key_recording_rev) )
			{
				rec_index = (rec_maxNum-1);
				rec_state = RECORDING_PLAY_REV;
			}
			else if ( KEY_PRESSED(set.key_recording_rev_customSpeed) )
			{
				rec_index = (rec_maxNum-1);
				rec_state = RECORDING_PLAY_REV_CUSTOMSPEED;
			}

			// user set a maximum distance to entry point?
			if ( set.recording_maxDistToEntryPoint > 0.0f )
			{
				// check if current selected index is in maxRange, else look for a point closest
				// to the selected beginning, which is in the maxRange
				if ( vect3_dist(rec_pos[rec_index], &info->base.matrix[4*3]) > set.recording_maxDistToEntryPoint )
				{
					int i = rec_index;
					int rec_index_new = -1;

					// not a entry point we want (too far), lets find a better one
					while ( i >= 0 && i < rec_maxNum )
					{
						if ( vect3_dist(rec_pos[i], &info->base.matrix[4*3]) <= set.recording_maxDistToEntryPoint )
						{
							rec_index_new = i;
							break;
						}
						if ( rec_state == RECORDING_PLAY_REV || rec_state == RECORDING_PLAY_REV_CUSTOMSPEED )
							i--;
						else
							i++;
					}

					// nothing close enough found
					if ( rec_index_new == -1 )
					{
						rec_state = RECORDING_OFF;
						cheat_state_text( "Too far from route - maxDist: %0.2f", set.recording_maxDistToEntryPoint );
					}
					else
						rec_index = rec_index_new;
				}
			}
		}
	}

	if ( rec_state == RECORDING_RECORD )
	{
		pD3DFont->PrintShadow( 99, 250, D3DCOLOR_ARGB(255, 255, 0, 0), "Vehicle Recording" );

		if ( (TIME_TO_FLOAT(time_get()) - rec_playNext) < 0.0f )
			return;
		
		vect3_copy( &info->base.matrix[4*3+0], rec_pos[rec_index] );

		vect3_copy( &info->base.matrix[4*0+0], &rec_angle[rec_index][0] );
		vect3_copy( &info->base.matrix[4*1+0], &rec_angle[rec_index][3] );

		vect3_copy( info->spin, rec_spin[rec_index] );
		vect3_copy( info->speed, rec_speed[rec_index] );

		rec_index++;
		rec_playNext = TIME_TO_FLOAT(time_get()) + TIME_TO_FLOAT((float)MSEC_TO_TIME(REC_DEFAULT_WAITTIME));
		if ( rec_index == (REC_ARRAYSIZE-1) )
		{
			rec_maxNum = rec_index;
			rec_state = RECORDING_OFF;
		}
	}
	// >= because only play states should follow after RECORDING_PLAY
	else if ( rec_state >= RECORDING_PLAY )
	{
		// deactivate playing records while air brakeing/sticking
		if ( cheat_state->vehicle.air_brake || cheat_state->vehicle.stick )
		{
			rec_state = RECORDING_OFF;
			return;
		}

		// move into some better place (maybe hud?)
		_snprintf_s( buffer, sizeof(buffer)-1, "Vehicle Play Record%s%s", (rec_state == RECORDING_PLAY_REV
			|| rec_state == RECORDING_PLAY_REV_CUSTOMSPEED) ? " (Rev)" : "",
			rec_continueAfterFin ? " (Continuously)" : "" );
		_snprintf_s( buffer, sizeof(buffer)-1, "%s%s", buffer, (rec_state == RECORDING_PLAY_REV_CUSTOMSPEED
			|| rec_state == RECORDING_PLAY_CUSTOMSPEED) ? " (Custom Speed)" : "" );
		pD3DFont->PrintShadow( 99, 250, D3DCOLOR_ARGB(255, 0, 255, 0), buffer );

		// will need overtime variable for data row skipping
		float overtime = (TIME_TO_FLOAT(time_get()) - rec_playNext);

		// do nothing, if the planned next-frame time wasn't reached yet
		if ( overtime < 0.0f )
			return;
		
		vect3_copy( rec_pos[rec_index], &info->base.matrix[4*3+0] );

		vect3_copy( &rec_angle[rec_index][0], &info->base.matrix[4*0+0] );
		vect3_copy( &rec_angle[rec_index][3], &info->base.matrix[4*1+0] );

		vect3_copy( rec_spin[rec_index], set_spin );
		vect3_copy( rec_speed[rec_index], set_speed );		

		// multiply speed/spin (for ff mode) and set the playNextTick
		if ( rec_state == RECORDING_PLAY_CUSTOMSPEED || rec_state == RECORDING_PLAY_REV_CUSTOMSPEED )
		{
			vect3_mult( set_spin, set.recording_play_customSpeed, set_spin );
			vect3_mult( set_speed, set.recording_play_customSpeed, set_speed );

			// custom speed multiplier faster/higher than possible to play one by one?
			// if its not the first point (rec_playNext still default) skip a few 
			if ( overtime > 0.0f && rec_playNext != 0.0f )
			{
				// (now-plannedArrival) = overtime -> plannedArrival is way back in the past [so we gotta skip
				//   some of the rows to keep up with the recording/show it 'fluent' (or at least somehow timed correct)]

				// determine how many data rows we gotta skip ((now-plannedArrival)/timePerRow)
				float skipAble = overtime / (float)(TIME_TO_FLOAT((float)MSEC_TO_TIME(REC_DEFAULT_WAITTIME))/set.recording_play_customSpeed);
				if ( skipAble > 1.0f )
				{
					int skipAFew = ceil(skipAble);
					if ( skipAFew > 0 && rec_state >= RECORDING_PLAY_REV )
						rec_index -= skipAFew;
					else if ( skipAFew > 0 )
						rec_index += skipAFew;
				}
			}

			// calculate the time for the next data row
			rec_playNext = TIME_TO_FLOAT(time_get())
				+ (TIME_TO_FLOAT((float)MSEC_TO_TIME(REC_DEFAULT_WAITTIME))/set.recording_play_customSpeed );
		}
		else
		{
			// in case REC_DEFAULT_WAITTIME is too low, or this code is running on a slow computer
			// (or player tabbed/paused the game and refocuses the gta window)
			if ( overtime > 0.0f && rec_playNext != 0.0f )
			{
				// determine how many data rows we gotta skip
				float skipAble = overtime / (float)(TIME_TO_FLOAT(MSEC_TO_TIME(REC_DEFAULT_WAITTIME)));
				if ( skipAble > 1.0f )
				{
					int skipAFew = ceil(skipAble);
					if ( skipAFew > 0 && rec_state >= RECORDING_PLAY_REV )
						rec_index -= skipAFew;
					else if ( skipAFew > 0 )
						rec_index += skipAFew;
				}
			}

			rec_playNext = TIME_TO_FLOAT(time_get()) + TIME_TO_FLOAT(MSEC_TO_TIME(REC_DEFAULT_WAITTIME));
		}

		// inverse speed/spin (for rev mode) and set rec_index
		if ( rec_state >= RECORDING_PLAY_REV )
		{
			vect3_mult( set_spin, -1.0f, set_spin );
			vect3_mult( set_speed, -1.0f, set_speed );
			rec_index--;

			// reached end of recording
			if ( rec_index <= 0 )
			{
				if ( !rec_continueAfterFin )
					rec_state = RECORDING_OFF;
				else
				{
					if ( set.recording_maxDistToEntryPoint > 0.0f )
					{
						// deactivate, if new starting position is too far from this point
						if ( vect3_dist(rec_pos[rec_index], rec_pos[(rec_maxNum-1)]) > set.recording_maxDistToEntryPoint )
							rec_state = RECORDING_OFF;
					}
					rec_index = (rec_maxNum-1);
				}
			}
		}
		else
		{
			rec_index++;

			// reached end of recording
			if ( (rec_index >= (REC_ARRAYSIZE-1) || rec_index >= rec_maxNum) )
			{
				if ( !rec_continueAfterFin )
					rec_state = RECORDING_OFF;
				else
				{
					if ( set.recording_maxDistToEntryPoint > 0.0f )
					{
						// deactivate, if new starting position is too far from this point
						if ( vect3_dist(rec_pos[rec_index], rec_pos[0]) > set.recording_maxDistToEntryPoint )
							rec_state = RECORDING_OFF;
					}
					rec_index = 0;
				}
			}
		}	
		
		// copy new speed/spin after it has been adjusted for ff/rev mode
		vect3_copy( set_spin, info->spin );
		vect3_copy( set_speed, info->speed );			
	}
	else
	{
		rec_state = RECORDING_OFF;
	}
}
Exemple #30
0
void
playanm ( short anim_num )
{
    char *animbuf, *palptr;
    long i, j, k, numframes = 0;
    int32 handle = -1;
    char ANIMvesapal[4 * 256];
    char tempbuf[256];
    char *palook_bak = palookup[0];
    ANIMnum = anim_num;
    KB_FlushKeyboardQueue();
    KB_ClearKeysDown();
    DSPRINTF ( ds, "PlayAnm" );
    MONO_PRINT ( ds );
    DSPRINTF ( ds, "PlayAnm" );
    MONO_PRINT ( ds );
    animbuf = LoadAnm ( anim_num );
    
    if ( !animbuf )
    {
        return;
    }
    
    DSPRINTF ( ds, "PlayAnm - Palette Stuff" );
    MONO_PRINT ( ds );
    
    for ( i = 0; i < 256; i++ )
    {
        tempbuf[i] = i;
    }
    
    palookup[0] = tempbuf;
    ANIM_LoadAnim ( ( uint8_t * ) animbuf, length );
    ANIMnumframes = ANIM_NumFrames();
    numframes = ANIMnumframes;
    palptr = ( char * ) ANIM_GetPalette();
    
    for ( i = 0; i < 768; i++ )
    {
        ANIMvesapal[i] = palptr[i] >> 2;
    }
    
    tilesiz[TILE_ANIM].x = 200;
    tilesiz[TILE_ANIM].y = 320;
    setbasepal ( 0, ( const uint8_t * ) ANIMvesapal );
    setbrightness ( gs.Brightness, 0, 2 );
    
    if ( ANIMnum == 1 )
    {
        // draw the first frame
        waloff[TILE_ANIM] = FP_OFF ( ANIM_DrawFrame ( 1 ) );
        invalidatetile ( TILE_ANIM, 0, 1 << 4 );
        rotatesprite ( 0 << 16, 0 << 16, 65536L, 512, TILE_ANIM, 0, 0, 2 + 4 + 8 + 16 + 64, 0, 0, xdim - 1, ydim - 1 );
    }
    
    SoundState = 0;
    //ototalclock = totalclock + 120*2;
    ototalclock = totalclock;
    
    for ( i = 1; i < numframes; i++ )
    {
        while ( totalclock < ototalclock )
        {
            switch ( ANIMnum )
            {
                case 0:
                    if ( KB_KeyWaiting() )
                    {
                        goto ENDOFANIMLOOP;
                    }
                    
                    break;
                    
                case 1:
                    if ( KEY_PRESSED ( KEYSC_ESC ) )
                    {
                        goto ENDOFANIMLOOP;
                    }
                    
                    break;
            }
            
            getpackets();
        }
        
        switch ( ANIMnum )
        {
            case ANIM_INTRO:
                AnimShareIntro ( i, numframes );
                break;
                
            case ANIM_SERP:
                AnimSerp ( i, numframes );
                break;
                
            case ANIM_SUMO:
                AnimSumo ( i, numframes );
                break;
                
            case ANIM_ZILLA:
                AnimZilla ( i, numframes );
                break;
        }
        
        waloff[TILE_ANIM] = FP_OFF ( ANIM_DrawFrame ( i ) );
        invalidatetile ( TILE_ANIM, 0, 1 << 4 );
        rotatesprite ( 0 << 16, 0 << 16, 65536L, 512, TILE_ANIM, 0, 0, 2 + 4 + 8 + 16 + 64, 0, 0, xdim - 1, ydim - 1 );
        nextpage();
    }
    
    // pause on final frame
    while ( totalclock < ototalclock )
    {
        getpackets();
    }
    
ENDOFANIMLOOP:
    clearview ( 0 );
    nextpage();
    palookup[0] = palook_bak;
    //    setbrightness(gs.Brightness, (char*)palette_data, 2);
    setbasepal ( 0, ( const uint8_t * ) palette_data );
    setbrightness ( gs.Brightness, 0, 2 );
    KB_FlushKeyboardQueue();
    KB_ClearKeysDown();
    ANIM_FreeAnim();
    walock[ANIM_TILE ( ANIMnum )] = 1;
}